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

userspace/wrsw_hal: make hal support wriX interfaces

Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 177e1b76
...@@ -92,13 +92,17 @@ static int hal_port_init(int index) ...@@ -92,13 +92,17 @@ static int hal_port_init(int index)
struct hal_port_state *p = &ports[index]; struct hal_port_state *p = &ports[index];
char name[128], s[128]; char name[128], s[128];
int val, error; int val, error;
int port_i;
/* index is 0..17, port_i 1..18 */
port_i = index + 1;
/* make sure the states and other variables are in their init state */ /* make sure the states and other variables are in their init state */
hal_port_reset_state(p); hal_port_reset_state(p);
/* read dot-config values for this index, starting from name */ /* read dot-config values for this index, starting from name */
error = libwr_cfg_convert2("PORT%02i_PARAMS", "name", LIBWR_STRING, error = libwr_cfg_convert2("PORT%02i_PARAMS", "name", LIBWR_STRING,
name, index); name, port_i);
if (error) if (error)
return -1; return -1;
strncpy(p->name, name, 16); strncpy(p->name, name, 16);
...@@ -112,23 +116,26 @@ static int hal_port_init(int index) ...@@ -112,23 +116,26 @@ static int hal_port_init(int index)
val = 18 * 800; /* magic default from previous code */ val = 18 * 800; /* magic default from previous code */
error = libwr_cfg_convert2("PORT%02i_PARAMS", "tx", LIBWR_INT, error = libwr_cfg_convert2("PORT%02i_PARAMS", "tx", LIBWR_INT,
&val, index); &val, port_i);
if (error) if (error)
pr_error("port index %i (%s): no \"tx=\" specified\n", pr_error("port %i (%s): no \"tx=\" specified\n",
index, name); port_i, name);
p->calib.phy_tx_min = val; p->calib.phy_tx_min = val;
val = 18 * 800; /* magic default from previous code */ val = 18 * 800; /* magic default from previous code */
error = libwr_cfg_convert2("PORT%02i_PARAMS", "rx", LIBWR_INT, error = libwr_cfg_convert2("PORT%02i_PARAMS", "rx", LIBWR_INT,
&val, index); &val, port_i);
if (error) if (error)
pr_error("port index %i (%s): no \"rx=\" specified\n", pr_error("port %i (%s): no \"rx=\" specified\n",
index, name); port_i, name);
p->calib.phy_rx_min = val; p->calib.phy_rx_min = val;
p->calib.delta_tx_board = 0; /* never set */ p->calib.delta_tx_board = 0; /* never set */
p->calib.delta_rx_board = 0; /* never set */ p->calib.delta_rx_board = 0; /* never set */
sscanf(p->name + 2, "%d", &p->hw_index); /* get the number of a port from notation wriX */
sscanf(p->name + 3, "%d", &p->hw_index);
/* hw_index is 0..17, p->name wri1..18 */
p->hw_index--;
p->t2_phase_transition = DEFAULT_T2_PHASE_TRANS; p->t2_phase_transition = DEFAULT_T2_PHASE_TRANS;
p->t4_phase_transition = DEFAULT_T4_PHASE_TRANS; p->t4_phase_transition = DEFAULT_T4_PHASE_TRANS;
...@@ -148,36 +155,36 @@ static int hal_port_init(int index) ...@@ -148,36 +155,36 @@ static int hal_port_init(int index)
strcpy(s, "non-wr"); /* default if no string passed */ strcpy(s, "non-wr"); /* default if no string passed */
p->mode = HEXP_PORT_MODE_NON_WR; p->mode = HEXP_PORT_MODE_NON_WR;
error = libwr_cfg_convert2("PORT%02i_PARAMS", "role", error = libwr_cfg_convert2("PORT%02i_PARAMS", "role",
LIBWR_STRING, s, index); LIBWR_STRING, s, port_i);
if (error) if (error)
pr_error("port index %i (%s): " pr_error("port %i (%s): "
"no \"role=\" specified\n", index, name); "no \"role=\" specified\n", port_i, name);
for (rp = rt; rp->name; rp++) for (rp = rt; rp->name; rp++)
if (!strcasecmp(s, rp->name)) if (!strcasecmp(s, rp->name))
break; break;
p->mode = rp->value; p->mode = rp->value;
if (!rp->name) if (!rp->name)
pr_error("port index %i (%s): invalid role " pr_error("port %i (%s): invalid role "
"\"%s\" specified\n", index, name, s); "\"%s\" specified\n", port_i, name, s);
pr_debug("Port %s: mode %i\n", p->name, val); pr_debug("Port %s: mode %i\n", p->name, val);
} }
/* Get fiber type */ /* Get fiber type */
error = libwr_cfg_convert2("PORT%02i_PARAMS", "fiber", error = libwr_cfg_convert2("PORT%02i_PARAMS", "fiber",
LIBWR_INT, &p->fiber_index, index); LIBWR_INT, &p->fiber_index, port_i);
if (error) { if (error) {
pr_error("port index %i (%s): " pr_error("port %i (%s): "
"no \"fiber=\" specified, default fiber to 0\n", "no \"fiber=\" specified, default fiber to 0\n",
index, name); port_i, name);
p->fiber_index = 0; p->fiber_index = 0;
} }
if (p->fiber_index > 3) { if (p->fiber_index > 3) {
pr_error("port index %i (%s): " pr_error("port %i (%s): "
"not supported \"fiber=\" value, default to 0\n", "not supported \"fiber=\" value, default to 0\n",
index, name); port_i, name);
p->fiber_index = 0; p->fiber_index = 0;
} }
...@@ -230,6 +237,7 @@ int hal_port_init_all(char *logfilename) ...@@ -230,6 +237,7 @@ int hal_port_init_all(char *logfilename)
for (index = 0; index < HAL_MAX_PORTS; index++) for (index = 0; index < HAL_MAX_PORTS; index++)
if (hal_port_init(index) < 0) if (hal_port_init(index) < 0)
break; break;
hal_port_nports = index; hal_port_nports = index;
pr_info("Number of physical ports supported in HW: %d\n", pr_info("Number of physical ports supported in HW: %d\n",
......
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