Commit 3980379b authored by Aurelio Colosimo's avatar Aurelio Colosimo

Set wr configuration at startup, according to /etc/ppsi.conf

Signed-off-by: Aurelio Colosimo's avatarAurelio Colosimo <aurelio@aureliocolosimo.it>
parent 77ac021b
......@@ -20,6 +20,7 @@
#include <ppsi/ppsi.h>
#include <ppsi-wrs.h>
#include "../proto-ext-whiterabbit/wr-api.h"
CONST_VERBOSITY int pp_diag_verbosity = 0;
......@@ -115,16 +116,18 @@ int main(int argc, char **argv)
ppi->slave_only = 1;
}
/* FIXME set ppi ext enable as defined in its pp_link */
ppi->portDS = calloc(1, sizeof(*ppi->portDS));
if (!ppi->portDS)
exit(__LINE__);
ppi->portDS->ext_dsport = calloc(1, sizeof(struct wr_dsport));
if (!ppi->portDS->ext_dsport)
exit(__LINE__);
/* The following default names depend on TIME= at build time */
ppi->n_ops = &DEFAULT_NET_OPS;
ppi->t_ops = &DEFAULT_TIME_OPS;
if (!ppi->portDS)
exit(__LINE__);
}
if (pp_parse_cmdline(ppg, argc, argv) != 0)
......
......@@ -21,10 +21,37 @@ 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 struct wr_data_t wr_data; /* WR-specific global data */
int i;
/* FIXME: used by arch-wrpc only; iface_name should be assigned
* in main in every arch*/
if ((ppg->nlinks == 1) && (!ppg->pp_instances[0].iface_name))
ppg->pp_instances[0].iface_name = "wr1";
for (i = 0; i < ppg->nlinks; i++) {
struct pp_link *lnk = &ppg->links[i];
struct pp_instance *ppi = &ppg->pp_instances[i];
/* FIXME check if correct: assign to each instance the same
* wr_data. May I move it to pp_globals? */
ppg->pp_instances[i].ext_data = &wr_data;
if (lnk->ext) {
switch (lnk->role) {
case 1:
WR_DSPOR(ppi)->wrConfig = WR_M_ONLY;
break;
case 2:
WR_DSPOR(ppi)->wrConfig = WR_S_ONLY;
break;
default:
WR_DSPOR(ppi)->wrConfig = WR_M_AND_S;
}
}
else
WR_DSPOR(ppi)->wrConfig = NON_WR;
}
/* FIXME handle more ports */
ppg->pp_instances[0].iface_name = "wr1";
ppg->pp_instances[0].ext_data = &wr_data;
return 0;
}
......
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