Commit 9a1d10b6 authored by Tristan Gingold's avatar Tristan Gingold

rename arch_data fields to reduce ambiguity

parent 60f708fd
......@@ -36,8 +36,8 @@ struct pp_sim_net_delay {
* chtype is the channel and delay_ns is the time that should pass from when the
* packet is sent until it will be received from the destination.
* Every time a packet is sent a structure like this is filled and stored in the
* ppg->arch_data so that we always know which is the first packet that has to
* be received and when.
* ppg->arch_glbl_data so that we always know which is the first packet that
* has to be received and when.
*/
struct sim_pending_pkt {
int64_t delay_ns;
......@@ -64,7 +64,7 @@ struct sim_ppg_arch_data {
static inline struct sim_ppg_arch_data *SIM_PPG_ARCH(struct pp_globals *ppg)
{
return (struct sim_ppg_arch_data *)(ppg->arch_data);
return (struct sim_ppg_arch_data *)(ppg->arch_glbl_data);
}
/*
......@@ -101,7 +101,7 @@ struct sim_ppi_arch_data {
static inline struct sim_ppi_arch_data *SIM_PPI_ARCH(struct pp_instance *ppi)
{
return (struct sim_ppi_arch_data *)(ppi->arch_data);
return (struct sim_ppi_arch_data *)(ppi->arch_inst_data);
}
static inline struct pp_instance *pp_sim_get_master(struct pp_globals *ppg)
......
......@@ -105,8 +105,8 @@ const struct wrh_operations wrh_oper = {
/*
* In arch-sim we use two pp_instances in the same pp_globals to represent
* two different machines. This means *completely differnt* machines, with
* their own Data Sets. Given we can't put more all the different Data Sets
* in the same ppg, we stored them in the ppi->arch_data of every instance.
* their own Data Sets. Given we can't put more all the different Data Sets in
* the same ppg, we stored them in the ppi->arch_inst_data of every instance.
* This function is used to set the inner Data Sets pointer of the ppg to
* point to the Data Sets related to the pp_instange passed as argument
*/
......@@ -148,9 +148,9 @@ static int sim_ppi_init(struct pp_instance *ppi, int which_ppi)
ppi->proto = PP_DEFAULT_PROTO;
ppi->__tx_buffer = malloc(PP_MAX_FRAME_LENGTH);
ppi->__rx_buffer = malloc(PP_MAX_FRAME_LENGTH);
ppi->arch_data = calloc(1, sizeof(struct sim_ppi_arch_data));
ppi->arch_inst_data = calloc(1, sizeof(struct sim_ppi_arch_data));
ppi->portDS = calloc(1, sizeof(*ppi->portDS));
if ((!ppi->arch_data) || (!ppi->portDS))
if ((!ppi->arch_inst_data) || (!ppi->portDS))
return -1;
ppi->ext_hooks=&pp_hooks;
......@@ -220,10 +220,10 @@ int main(int argc, char **argv)
ppg = calloc(1, sizeof(struct pp_globals));
ppg->max_links = 2; // master and slave, nothing else
ppg->arch_data = calloc(1, sizeof(struct sim_ppg_arch_data));
ppg->arch_glbl_data = calloc(1, sizeof(struct sim_ppg_arch_data));
ppg->pp_instances = calloc(ppg->max_links, sizeof(struct pp_instance));
if ((!ppg->arch_data) || (!ppg->pp_instances))
if ((!ppg->arch_glbl_data) || (!ppg->pp_instances))
return -1;
/* Alloc data stuctures inside the pp_instances */
......
......@@ -9,7 +9,7 @@
* These are the functions provided by the various unix files
*/
#define POSIX_ARCH(ppg) ((struct unix_arch_data *)(ppg->arch_data))
#define POSIX_ARCH(ppg) ((struct unix_arch_data *)(ppg->arch_glbl_data))
struct unix_arch_data {
struct timeval tv;
};
......
......@@ -54,10 +54,10 @@ int main(int argc, char **argv)
/* We are hosted, so we can allocate */
ppg->max_links = PP_MAX_LINKS;
ppg->arch_data = calloc(1, sizeof(struct unix_arch_data));
ppg->arch_glbl_data = calloc(1, sizeof(struct unix_arch_data));
ppg->pp_instances = calloc(ppg->max_links, sizeof(struct pp_instance));
if ((!ppg->arch_data) || (!ppg->pp_instances)) {
if ((!ppg->arch_glbl_data) || (!ppg->pp_instances)) {
fprintf(stderr, "ppsi: out of memory\n");
exit(1);
}
......
......@@ -101,7 +101,7 @@ struct pp_globals ppg_static = {
.max_links = PP_MAX_LINKS,
.nlinks = 1,
/* rt_opts set by pp_init_globals */
.arch_data = &wrpc_arch_data,
.arch_glbl_data = &wrpc_arch_data,
};
......
......@@ -95,12 +95,12 @@ int32_t wrpc_get_clock_period(void);
static inline wrpc_arch_data_t *WRPC_ARCH_I(struct pp_instance *ppi)
{
return (wrpc_arch_data_t *) GLBS(ppi)->arch_data;
return (wrpc_arch_data_t *) GLBS(ppi)->arch_glbl_data;
}
static inline wrpc_arch_data_t *WRPC_ARCH_G(struct pp_globals *ppg)
{
return (wrpc_arch_data_t *) ppg->arch_data;
return (wrpc_arch_data_t *) ppg->arch_glbl_data;
}
static inline void wrc_ptp_get_leapsec(int *ptp, int *system)
......
......@@ -37,13 +37,11 @@ static inline struct hal_port_state *pp_wrs_lookup_port(char *name)
#define DEFAULT_TO 200000 /* ms */
#define POSIX_ARCH(ppg) ((struct unix_arch_data *)(ppg->arch_data))
#define POSIX_ARCH(ppg) ((struct unix_arch_data *)(ppg->arch_glbl_data))
struct unix_arch_data {
struct timeval tv;
};
#define WRH_GLOBAL_ARCH(ppg) ((wrs_arch_data *)(ppg->arch_data))
typedef struct wrs_arch_data_t {
struct unix_arch_data unix_data; // Must be kept at first position
wrh_timing_mode_locking_state_t timingModeLockingState; /* Locking state for PLL */
......@@ -53,12 +51,12 @@ typedef struct wrs_arch_data_t {
static inline wrs_arch_data_t *WRS_ARCH_I(struct pp_instance *ppi)
{
return (wrs_arch_data_t *) GLBS(ppi)->arch_data;
return (wrs_arch_data_t *) GLBS(ppi)->arch_glbl_data;
}
static inline wrs_arch_data_t *WRS_ARCH_G(struct pp_globals *ppg)
{
return (wrs_arch_data_t *) ppg->arch_data;
return (wrs_arch_data_t *) ppg->arch_glbl_data;
}
extern void wrs_main_loop(struct pp_globals *ppg);
......
......@@ -229,11 +229,11 @@ int main(int argc, char **argv)
ppg->max_links = PP_MAX_LINKS;
ppg->arch_data = wrs_shm_alloc(ppsi_head, sizeof(wrs_arch_data_t));
ppg->arch_glbl_data = wrs_shm_alloc(ppsi_head, sizeof(wrs_arch_data_t));
ppg->pp_instances = wrs_shm_alloc(ppsi_head,
ppg->max_links * sizeof(struct pp_instance));
if ((!ppg->arch_data) || (!ppg->pp_instances)) {
if ((!ppg->arch_glbl_data) || (!ppg->pp_instances)) {
fprintf(stderr, "ppsi: out of memory\n");
exit(1);
}
......
......@@ -66,7 +66,7 @@ struct pp_channel {
int fd; /* Posix wants fid descriptor */
void *custom; /* Other archs want other stuff */
};
void *arch_data; /* Other arch-private info, if any */
void *arch_chan_data; /* Other arch-private info, if any */
unsigned char addr[PP_MAC_ADRESS_SIZE]; /* Our own MAC address */
int pkt_present;
};
......@@ -217,7 +217,7 @@ struct pp_instance {
int state;
int next_state, next_delay, is_new_state; /* set by state processing */
const struct pp_state_table_item *current_state_item;
void *arch_data; /* if arch needs it */
void *arch_inst_data; /* if arch needs it */
void *ext_data; /* if protocol ext needs it */
int protocol_extension; /* PPSI_EXT_NONE, PPSI_EXT_WR, PPSI_EXT_L1S */
const struct pp_ext_hooks *ext_hooks; /* if protocol ext needs it */
......@@ -331,7 +331,7 @@ struct pp_globals {
int rxdrop, txdrop; /* fault injection, per thousand */
void *arch_data; /* if arch needs it */
void *arch_glbl_data; /* if arch needs it */
void *global_ext_data; /* if protocol ext needs it */
/* FIXME Here include all is common to many interfaces */
......
......@@ -228,7 +228,7 @@ static int wrs_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
struct scm_timestamping *sts = NULL;
struct tpacket_auxdata *aux = NULL;
s = (struct wrs_socket*)ppi->ch[PP_NP_GEN].arch_data;
s = (struct wrs_socket*)ppi->ch[PP_NP_GEN].arch_chan_data;
memset(&msg, 0, sizeof(msg));
msg.msg_iov = &entry;
......@@ -505,7 +505,7 @@ static int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,enum pp_msg_
int ret, fd, drop;
char prefix[32];
s = (struct wrs_socket *)ppi->ch[PP_NP_GEN].arch_data;
s = (struct wrs_socket *)ppi->ch[PP_NP_GEN].arch_chan_data;
/*
* To fake a packet loss, we must corrupt the frame; we need
......@@ -661,7 +661,7 @@ static int wrs_net_init(struct pp_instance *ppi)
int r, i;
struct hal_port_state *p;
if (ppi->ch[PP_NP_GEN].arch_data)
if (ppi->ch[PP_NP_GEN].arch_chan_data)
wrs_net_exit(ppi);
/* Generic OS work is done by standard Unix stuff */
......@@ -695,15 +695,15 @@ static int wrs_net_init(struct pp_instance *ppi)
s->dmtd_phase_valid = 0;
ppi->ch[PP_NP_GEN].arch_data = s;
ppi->ch[PP_NP_EVT].arch_data = s;
ppi->ch[PP_NP_GEN].arch_chan_data = s;
ppi->ch[PP_NP_EVT].arch_chan_data = s;
tmo_init(&s->dmtd_update_tmo, DMTD_UPDATE_INTERVAL);
for (i = PP_NP_GEN, r = 0; i <= PP_NP_EVT && r == 0; i++)
r = wrs_enable_timestamps(ppi, ppi->ch[i].fd);
if (r) {
ppi->ch[PP_NP_GEN].arch_data = NULL;
ppi->ch[PP_NP_EVT].arch_data = NULL;
ppi->ch[PP_NP_GEN].arch_chan_data = NULL;
ppi->ch[PP_NP_EVT].arch_chan_data = NULL;
free(s);
}
return r;
......@@ -712,9 +712,9 @@ static int wrs_net_init(struct pp_instance *ppi)
static int wrs_net_exit(struct pp_instance *ppi)
{
unix_net_ops.exit(ppi);
free(ppi->ch[PP_NP_GEN].arch_data);
ppi->ch[PP_NP_GEN].arch_data = NULL;
ppi->ch[PP_NP_EVT].arch_data = NULL;
free(ppi->ch[PP_NP_GEN].arch_chan_data);
ppi->ch[PP_NP_GEN].arch_chan_data = NULL;
ppi->ch[PP_NP_EVT].arch_chan_data = NULL;
return 0;
}
......
......@@ -30,7 +30,7 @@ struct dump_info dump_ppsi_info[] = {
DUMP_FIELD(int, rxdrop),
DUMP_FIELD(int, txdrop),
DUMP_FIELD(pointer, arch_data),
DUMP_FIELD(pointer, arch_glbl_data),
DUMP_FIELD(pointer, global_ext_data),
......@@ -214,7 +214,7 @@ struct dump_info dump_ppsi_info[] = {
DUMP_FIELD(int, next_delay),
DUMP_FIELD(yes_no, is_new_state),
DUMP_FIELD(pointer, current_state_item),
DUMP_FIELD(pointer, arch_data),
DUMP_FIELD(pointer, arch_inst_data),
DUMP_FIELD(pointer, ext_data),
DUMP_FIELD(protocol_extension, protocol_extension),
DUMP_FIELD(pointer, ext_hooks),
......@@ -235,12 +235,12 @@ struct dump_info dump_ppsi_info[] = {
/* This is a sub-structure */
DUMP_FIELD(int, ch[0].fd),
DUMP_FIELD(pointer, ch[0].custom),
DUMP_FIELD(pointer, ch[0].arch_data),
DUMP_FIELD(pointer, ch[0].arch_chan_data),
DUMP_FIELD_SIZE(bina, ch[0].addr, 6),
DUMP_FIELD(yes_no, ch[0].pkt_present),
DUMP_FIELD(int, ch[1].fd),
DUMP_FIELD(pointer, ch[1].custom),
DUMP_FIELD(pointer, ch[1].arch_data),
DUMP_FIELD(pointer, ch[1].arch_chan_data),
DUMP_FIELD_SIZE(bina, ch[1].addr, 6),
DUMP_FIELD(yes_no, ch[1].pkt_present),
......@@ -392,9 +392,9 @@ void dump_mem_ppsi_wrpc(void *mapaddr, unsigned long ppg_off)
dump_many_fields(mapaddr + ppg_off, "pp_globals", prefix);
arch_data_offset = wrpc_get_pointer(mapaddr + ppg_off,
"pp_globals", "arch_data");
"pp_globals", "arch_glbl_data");
if (arch_data_offset) {
prefix = "ppsi.arch_data";
prefix = "ppsi.arch_glbl_data";
printf("%s at 0x%lx\n", prefix, arch_data_offset);
dump_many_fields(mapaddr + arch_data_offset, "wrpc_arch_data_t",
prefix);
......
......@@ -25,7 +25,7 @@ struct dump_info ppg_info [] = {
DUMP_FIELD(int, rxdrop),
DUMP_FIELD(int, txdrop),
DUMP_FIELD(pointer, arch_data),
DUMP_FIELD(pointer, arch_glbl_data),
DUMP_FIELD(pointer, global_ext_data),
};
......@@ -238,7 +238,7 @@ struct dump_info ppi_info [] = {
DUMP_FIELD(yes_no, is_new_state),
DUMP_FIELD(exstate,extState),
DUMP_FIELD(pp_pdstate,pdstate),
DUMP_FIELD(pointer, arch_data),
DUMP_FIELD(pointer, arch_inst_data),
DUMP_FIELD(pointer, ext_data),
DUMP_FIELD(protocol_extension, protocol_extension),
DUMP_FIELD(pointer, ext_hooks),
......@@ -260,12 +260,12 @@ struct dump_info ppi_info [] = {
/* This is a sub-structure */
DUMP_FIELD(int, ch[0].fd),
DUMP_FIELD(pointer, ch[0].custom),
DUMP_FIELD(pointer, ch[0].arch_data),
DUMP_FIELD(pointer, ch[0].arch_chan_data),
DUMP_FIELD_SIZE(bina, ch[0].addr, 6),
DUMP_FIELD(yes_no, ch[0].pkt_present),
DUMP_FIELD(int, ch[1].fd),
DUMP_FIELD(pointer, ch[1].custom),
DUMP_FIELD(pointer, ch[1].arch_data),
DUMP_FIELD(pointer, ch[1].arch_chan_data),
DUMP_FIELD_SIZE(bina, ch[1].addr, 6),
DUMP_FIELD(yes_no, ch[1].pkt_present),
......@@ -783,7 +783,7 @@ int dump_ppsi_mem(struct wrs_shm_head *head)
#if CONFIG_ARCH_IS_WRS
{
wrs_arch_data_t *arch_data=wrs_shm_follow(head, WRS_ARCH_G(ppg));
dump_many_fields(arch_data, wrs_arch_data_info, ARRAY_SIZE(wrs_arch_data_info),"ppsi.arch_data");
dump_many_fields(arch_data, wrs_arch_data_info, ARRAY_SIZE(wrs_arch_data_info),"ppsi.arch_inst_data");
}
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment