Commit 42a827c7 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/libwr: add SFP matching based on vendor name and part number

SFP matching is done by in order:
-vendor name, part number, serial
-vendor name, part number
-part number

If .config's entry (i.e. serial) is not empty match will happen only with
specific serial.

Additionally:
-Change default defines in Kconfig
-Update user manual with matching info
-Remove entry from wrs-todo about matching SFP vendor
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 686f4c25
......@@ -231,7 +231,7 @@ menu "SFP and Media Timing Configuration"
config SFP00_PARAMS
string "Parameters for one SFP device type"
default "name=AXGE-1254-0531,tx=10,rx=10,wl_txrx=1310+1490"
default "vn=Axcen Photonics,pn=AXGE-1254-0531,tx=10,rx=10,wl_txrx=1310+1490"
help
This parameter, and the following ones, are used to
configure the timing parameters of a specific SFP
......@@ -242,7 +242,7 @@ config SFP00_PARAMS
config SFP01_PARAMS
string "Parameters for one SFP device type"
default "name=AXGE-3454-0531,tx=10,rx=10,wl_txrx=1490+1310"
default "vn=Axcen Photonics,pn=AXGE-3454-0531,tx=10,rx=10,wl_txrx=1490+1310"
config SFP02_PARAMS
string "Parameters for one SFP device type"
......
......@@ -217,13 +217,6 @@ interface with gateware is now simpler than it was, but software still
has remnants of old data structure. Also, the multi-threaded approach
is overkill, and the program could benefit from a simplification.
@item The SFP code needs to be cleaned up. There is unsafe string
management in 16-wide non-terminated fields, and we don't really
report all the information we have (we should copy all SFP
information to shmem: we are almost there but not completely).
Moreover, using the device name without the vendor
name is unsafe: some vendors use generic device names.
@item The @t{TRACE} support it not really working. We have serious
warning messages that were never reported. We should really print
everything to stderr and let syslog manage it (according to user
......
......@@ -553,7 +553,7 @@ This is, for explanation's sake, an example of such items:
@smallexample
CONFIG_PORT09_PARAMS="name=wr9,tx=226214,rx=226758,role=slave,fiber=2"
CONFIG_SFP00_PARAMS="name=AXGE-1254-0531,tx=0,rx=0,wl_txrx=1310+1490"
CONFIG_SFP00_PARAMS="pn=AXGE-1254-0531,tx=0,rx=0,wl_txrx=1310+1490"
CONFIG_FIBER02_PARAMS="alpha_1310_1490=2.6787e-04"
@end smallexample
......@@ -589,6 +589,35 @@ wavelength, and is determined, again, by calibration.
Please note that only one alpha value is provided, because the
opposite one (@t{alpha_1490_1310}) is calculated by software.
@subheading SFP name matching
SFP matching is based on vendor name (@i{vn}), part number (@i{pn}) and vendor
serial (@i{vs}). While matching SFP's values are compared with values stored in
@t{CONFIG_SFPXX_PARAMS}.
First try is to match all SFP identifiers (@i{vn}, @i{pn} and @i{vs}) with
stored in config. If match is not successful, @i{vn} and @i{pn} of SFP are
compared only with config entries without vendor serial. If match is still not
found SFP's values are compared with config entries, which has defined only
part number. Such approach prevents matching SFPs to config entires with
defined serial.
Below are shown matching examples:
@smallexample
CONFIG_SFP00_PARAMS="vn=Axcen Photonics,pn=AXGE-3454-0531,vs=AX12390009629,tx=0,rx=0,..."
@end smallexample
Above config may be matched only to one SFP.
@smallexample
CONFIG_SFP01_PARAMS="vn=Axcen Photonics,pn=AXGE-3454-0531,tx=0,rx=0,wl_txrx=1310+1490"
@end smallexample
Above config may be matched only to SFP with vendor name "Axcen Photonics" and
part number "AXGE-3454-0531", with exception to these SFPs that were matched to
example like above (with vendor serial defined).
@smallexample
CONFIG_SFP02_PARAMS="pn=AXGE-3454-0531,tx=0,rx=0,wl_txrx=1310+1490"
@end smallexample
Config above will be matched to all SFPs with part number "AXGE-3454-0531",
that were not matched by configs above.
@subheading Other Deployments
The example above matches the choices we make at CERN, where our
......
......@@ -562,15 +562,28 @@ int shw_sfp_read_db(void)
int error, val, index;
for (index = 0; ; index++) {
error = libwr_cfg_convert2("SFP%02i_PARAMS", "name",
error = libwr_cfg_convert2("SFP%02i_PARAMS", "pn",
LIBWR_STRING, s, index);
if (error)
return 0; /* no more, no error */
sfp = calloc(1, sizeof(*sfp));
strncpy(sfp->part_num, s, sizeof(sfp->part_num));
sfp->vendor_name[0] = 0;
error = libwr_cfg_convert2("SFP%02i_PARAMS", "vn",
LIBWR_STRING, s, index);
/* copy vendor name if found */
if (!error)
strncpy(sfp->vendor_name, s, sizeof(sfp->vendor_name));
sfp->vendor_serial[0] = 0;
error = libwr_cfg_convert2("SFP%02i_PARAMS", "vs",
LIBWR_STRING, s, index);
/* copy serial name if found */
if (!error)
strncpy(sfp->vendor_serial, s,
sizeof(sfp->vendor_serial));
sfp->flags = SFP_FLAG_CLASS_DATA; /* never used */
/* These are uint32_t as I write this. So use "int val" */
......@@ -610,7 +623,8 @@ struct shw_sfp_caldata *shw_sfp_get_cal_data(int num,
struct shw_sfp_header *head)
{
struct shw_sfp_caldata *t;
struct shw_sfp_caldata *other = NULL;
struct shw_sfp_caldata *match_pn_vn = NULL;
struct shw_sfp_caldata *match_pn = NULL;
char *vn = (char *)head->vendor_name;
char *pn = (char *)head->vendor_pn;
char *vs = (char *)head->vendor_serial;
......@@ -639,16 +653,26 @@ struct shw_sfp_caldata *shw_sfp_get_cal_data(int num,
/* In the first pass, look for serial number */
while (t) {
// printf("search1 %s %s\n", t->part_num, t->vendor_serial);
/* TODO: Add vendor matching */
if (strncmp(pn, t->part_num, 16) == 0
&& strncmp(t->vendor_serial, "", 16) == 0)
other = t;
else if (strncmp(pn, t->part_num, 16) == 0
&& strncmp(vs, t->vendor_serial, 16) == 0)
if (t->vendor_name[0] == 0
&& strncmp(pn, t->part_num, 16) == 0
&& t->vendor_serial[0] == 0)
/* matched pn, but vn and vs not defined */
match_pn = t;
else if (strncmp(vn, t->vendor_name, 16) == 0
&& strncmp(pn, t->part_num, 16) == 0
&& t->vendor_serial[0] == 0)
/* matched vn, pn, but vs not defined */
match_pn_vn = t;
else if (strncmp(vn, t->vendor_name, 16) == 0
&& strncmp(pn, t->part_num, 16) == 0
&& strncmp(vs, t->vendor_serial, 16) == 0)
/* matched vn, pn, vs */
return t;
t = t->next;
}
if (other)
return other;
if (match_pn_vn)
return match_pn_vn;
if (match_pn)
return match_pn;
return NULL;
}
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