Commit a66df444 authored by Adam Wujek's avatar Adam Wujek 💬

arch-wrs: add global_ext_data to pp_globals and move wr_data to shmem

Part of a process to move wrs-servo internal data into shmem
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 2181324a
...@@ -53,6 +53,7 @@ static DSCurrent currentDS; ...@@ -53,6 +53,7 @@ static DSCurrent currentDS;
static DSParent parentDS; static DSParent parentDS;
static DSTimeProperties timePropertiesDS; static DSTimeProperties timePropertiesDS;
static struct pp_servo servo; static struct pp_servo servo;
static struct wr_servo_state_t servo_state;
static struct wr_dsport wr_dsport = { static struct wr_dsport wr_dsport = {
.ops = &wrpc_wr_operations, .ops = &wrpc_wr_operations,
...@@ -91,6 +92,7 @@ static struct pp_globals ppg_static = { ...@@ -91,6 +92,7 @@ static struct pp_globals ppg_static = {
.currentDS = &currentDS, .currentDS = &currentDS,
.parentDS = &parentDS, .parentDS = &parentDS,
.timePropertiesDS = &timePropertiesDS, .timePropertiesDS = &timePropertiesDS,
.global_ext_data = &servo_state,
}; };
int wrc_ptp_init() int wrc_ptp_init()
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# define BUILT_WITH_WHITERABBIT 0 # define BUILT_WITH_WHITERABBIT 0
#endif #endif
#define WRS_PPSI_SHMEM_VERSION 1 #define WRS_PPSI_SHMEM_VERSION 2 /* added global_ext_data to pp_globals */
/* /*
* These are the functions provided by the various wrs files * These are the functions provided by the various wrs files
......
...@@ -145,6 +145,9 @@ int main(int argc, char **argv) ...@@ -145,6 +145,9 @@ int main(int argc, char **argv)
ppg->rt_opts = &__pp_default_rt_opts; ppg->rt_opts = &__pp_default_rt_opts;
ppg->max_links = PP_MAX_LINKS; ppg->max_links = PP_MAX_LINKS;
ppg->global_ext_data = alloc_fn(ppsi_head,
sizeof(struct wr_servo_state_t));
/* NOTE: arch_data is not in shmem */
ppg->arch_data = malloc( sizeof(struct unix_arch_data)); ppg->arch_data = malloc( sizeof(struct unix_arch_data));
ppg->pp_instances = alloc_fn(ppsi_head, ppg->pp_instances = alloc_fn(ppsi_head,
ppg->max_links * sizeof(*ppi)); ppg->max_links * sizeof(*ppi));
...@@ -186,7 +189,6 @@ int main(int argc, char **argv) ...@@ -186,7 +189,6 @@ int main(int argc, char **argv)
} }
} }
for (i = 0; i < ppg->nlinks; i++) { for (i = 0; i < ppg->nlinks; i++) {
ppi = INST(ppg, i); ppi = INST(ppg, i);
NP(ppi)->ch[PP_NP_EVT].fd = -1; NP(ppi)->ch[PP_NP_EVT].fd = -1;
NP(ppi)->ch[PP_NP_GEN].fd = -1; NP(ppi)->ch[PP_NP_GEN].fd = -1;
......
...@@ -226,6 +226,7 @@ struct pp_globals { ...@@ -226,6 +226,7 @@ struct pp_globals {
int rxdrop, txdrop; /* fault injection, per thousand */ int rxdrop, txdrop; /* fault injection, per thousand */
void *arch_data; /* if arch needs it */ void *arch_data; /* if arch needs it */
void *global_ext_data; /* if protocol ext needs it */
/* FIXME Here include all is common to many interfaces */ /* FIXME Here include all is common to many interfaces */
}; };
......
...@@ -24,14 +24,13 @@ static int wr_init(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -24,14 +24,13 @@ static int wr_init(struct pp_instance *ppi, unsigned char *pkt, int plen)
static int wr_open(struct pp_globals *ppg, struct pp_runtime_opts *rt_opts) static int wr_open(struct pp_globals *ppg, struct pp_runtime_opts *rt_opts)
{ {
static struct wr_data_t wr_data; /* WR-specific global data */
int i; int i;
/* If current arch (e.g. wrpc) is not using the 'pp_links style' /* If current arch (e.g. wrpc) is not using the 'pp_links style'
* configuration, just assume there is one ppi instance, * configuration, just assume there is one ppi instance,
* already configured properly by the arch's main loop */ * already configured properly by the arch's main loop */
if (ppg->nlinks == 0) { if (ppg->nlinks == 0) {
INST(ppg, 0)->ext_data = &wr_data; INST(ppg, 0)->ext_data = ppg->global_ext_data;
return 0; return 0;
} }
...@@ -40,7 +39,7 @@ static int wr_open(struct pp_globals *ppg, struct pp_runtime_opts *rt_opts) ...@@ -40,7 +39,7 @@ static int wr_open(struct pp_globals *ppg, struct pp_runtime_opts *rt_opts)
/* FIXME check if correct: assign to each instance the same /* FIXME check if correct: assign to each instance the same
* wr_data. May I move it to pp_globals? */ * wr_data. May I move it to pp_globals? */
INST(ppg, i)->ext_data = &wr_data; INST(ppg, i)->ext_data = ppg->global_ext_data;
if (ppi->cfg.ext == PPSI_EXT_WR) { if (ppi->cfg.ext == PPSI_EXT_WR) {
switch (ppi->role) { switch (ppi->role) {
......
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