Commit 680ab8f4 authored by Jean-Claude BAU's avatar Jean-Claude BAU

[Feature:#33] Improve Calibration database syntax in dotconfig

- Increase up to 18 the number of SFPs and Fibers
- Add config parameter: CONFIG_N_SFP_ENTRIES (Number of SFP entries in
the DB)
- Add config parameter: CONFIG_N_FIBER_ENTRIES (Number of FIBER entries
in the DB)
- This 2 new parameters are used by HAL to parse the DB
- Use the TX SFP wave length as a key to retreive the SFP entry in the
DB
parent 296f6ff4
......@@ -389,110 +389,7 @@ endmenu
source Kconfig_port_timing.in
menu "SFP and Media Timing Configuration"
config SFP00_PARAMS
string "Parameters for one SFP device type"
default "vn=Axcen Photonics,pn=AXGE-1254-0531,tx=0,rx=0,wl_txrx=1310+1490"
help
This parameter, and the following ones, are used to
configure the timing parameters of a specific SFP
transceiver. The transceiver name is autodected for each port
in the White Rabbit Switch, and you need one configuration
entry for each transceiver type that is installed in your
device.
vn (optional) - Vendor Name of an SFP
pn - Part Number of an SFP
vs (optional) - Vendor Serial (serial number) of an SFP
tx - TX delay of an SFP
rx - RX delay of an SFP
wl_txrx - Tx wavelength separated by "+" with Rx wavelength of an SFP;
for example wl_txrx=1490+1310
config SFP01_PARAMS
string "Parameters for one SFP device type"
default "vn=Axcen Photonics,pn=AXGE-3454-0531,tx=0,rx=0,wl_txrx=1490+1310"
help
Please check the help of SFP00_PARAMS
config SFP02_PARAMS
string "Parameters for one SFP device type"
default "vn=APAC Opto,pn=LS38-C3S-TC-N-B9,tx=761,rx=557,wl_txrx=1310+1490"
help
Please check the help of SFP00_PARAMS
config SFP03_PARAMS
string "Parameters for one SFP device type"
default "vn=APAC Opto,pn=LS48-C3S-TC-N-B4,tx=-29,rx=507,wl_txrx=1490+1310"
help
Please check the help of SFP00_PARAMS
config SFP04_PARAMS
string "Parameters for one SFP device type"
default "vn=ZyXEL,pn=SFP-BX1490-10-D,tx=0,rx=0,wl_txrx=1490+1310"
help
Please check the help of SFP00_PARAMS
config SFP05_PARAMS
string "Parameters for one SFP device type"
default "vn=ZyXEL,pn=SFP-BX1310-10-D,tx=0,rx=0,wl_txrx=1310+1490"
help
Please check the help of SFP00_PARAMS
config SFP06_PARAMS
string "Parameters for one SFP device type"
help
Please check the help of SFP00_PARAMS
config SFP07_PARAMS
string "Parameters for one SFP device type"
help
Please check the help of SFP00_PARAMS
config SFP08_PARAMS
string "Parameters for one SFP device type"
help
Please check the help of SFP00_PARAMS
config SFP09_PARAMS
string "Parameters for one SFP device type"
help
Please check the help of SFP00_PARAMS
config FIBER00_PARAMS
string "Alpha parameters for fiber type 0"
default "alpha_1310_1490=2.6787e-04"
help
This parameter specify the physical features of used fiber type.
Specify the alpha value for each pair of used wavelengths.
This parameter follows a format:
alpha_XXXX_YYYY=1.23e-04,alpha_AAAA_BBBB=4.56e-04,...
where XXX_YYYY and AAAA_BBBB are pairs of used wavelengths,
1.23e-04, 4.56e-04 are alpha values to be used for particular
wavelengths
The index ("00" onwards) is used to match the port
(CONFIG_PORTxx_PARAMS) with one of several installed fiber types.
config FIBER01_PARAMS
string "Alpha parameters for fiber type 1"
default "alpha_1310_1490=2.6787e-04"
help
Please check the help of FIBER00_PARAMS
config FIBER02_PARAMS
string "Alpha parameters for fiber type 2"
default "alpha_1310_1490=2.6787e-04"
help
Please check the help of FIBER00_PARAMS
config FIBER03_PARAMS
string "Alpha parameters for fiber type 3"
default "alpha_1310_1490=2.6787e-04"
help
Please check the help of FIBER00_PARAMS
endmenu
source Kconfig_sfp_fiber.in
choice
prompt "Timing Mode"
......
This diff is collapsed.
#!/bin/bash
# Jean-Claude BAU @CERN
# script to generate Kconfig SFP and fiber configuration.
#
# Parameters:
# -o file Overwrite the default output file name
#
OUTPUT_FILE="Kconfig_sfp_fiber.in"
script_name="$0"
#decode script parameters
while getopts o: option
do
case "${option}" in
"o") OUTPUT_FILE=${OPTARG};;
esac
done
function print_header() {
echo -e "menu \"SFP and Media Timing Configuration\"" >$OUTPUT_FILE
}
function print_footer() {
echo -e "\nendmenu" >>$OUTPUT_FILE
}
function print_sfp_header() {
#remove leading zero
local maxSfp=$(expr $1 + 0)
local nbSfp=${#sfp_params[@]}
echo -e "\nconfig N_SFP_ENTRIES" >>$OUTPUT_FILE
echo -e "\tint \"Number of SFP entries in SFP configuration DB\"" >>$OUTPUT_FILE
echo -e "\trange 0 $maxSfp" >>$OUTPUT_FILE
echo -e "\thelp" >>$OUTPUT_FILE
echo -e "\tThis parameter defines the number of SFP entries" >>$OUTPUT_FILE
echo -e "\tthat can be set in the configuration database" >>$OUTPUT_FILE
echo -e "\tIncrease this number to add a new SFP entry." >>$OUTPUT_FILE
echo -e "\nmenu \"SFPs configuration DB\"" >>$OUTPUT_FILE
}
function print_sfp_entry() {
#remove leading zero
local maxSfp=$(expr $1 + 0)
local idSfp=$(expr $2 + 0)
echo -e "\nconfig SFP${2}_PARAMS" >>$OUTPUT_FILE
echo -e "\tstring \"Parameters for SFP $idSfp\"" >>$OUTPUT_FILE
depends=""
fid=$(expr $idSfp + 1)
for i in `seq $fid $maxSfp`; do
if [ "$depends" != "" ] ; then depends="$depends ||"; fi
depends="$depends N_SFP_ENTRIES=$i"
done
echo -e "\tdepends on $depends" >>$OUTPUT_FILE
echo -e "\tdefault \"${sfp_params[$idSfp]]}\"" >>$OUTPUT_FILE
echo -e "\thelp" >>$OUTPUT_FILE
echo -e "\tThis parameter, and the following ones, are used to" >>$OUTPUT_FILE
echo -e "\tconfigure the timing parameters of a specific SFP" >>$OUTPUT_FILE
echo -e "\ttransceiver. The transceiver name is autodected for each port" >>$OUTPUT_FILE
echo -e "\tin the White Rabbit Switch, and you need one configuration" >>$OUTPUT_FILE
echo -e "\tentry for each transceiver type that is installed in your" >>$OUTPUT_FILE
echo -e "\tdevice." >>$OUTPUT_FILE
echo -e "\tvn (optional) - Vendor Name of an SFP" >>$OUTPUT_FILE
echo -e "\tpn - Part Number of an SFP" >>$OUTPUT_FILE
echo -e "\tvs (optional) - Vendor Serial (serial number) of an SFP" >>$OUTPUT_FILE
echo -e "\ttx - TX delay of an SFP" >>$OUTPUT_FILE
echo -e "\trx - RX delay of an SFP" >>$OUTPUT_FILE
echo -e "\twl_txrx - Tx wavelength separated by "+" with Rx wavelength of an SFP;" >>$OUTPUT_FILE
echo -e "\tfor example wl_txrx=1490+1310" >>$OUTPUT_FILE
echo -e "\tTo set a new SFP entry, increment the parameter " >>$OUTPUT_FILE
echo -e "\t\"Number of SFP entries in SFP configuration DB\" in the upper menu." >>$OUTPUT_FILE
}
function print_sfp_footer() {
echo -e "\nendmenu" >>$OUTPUT_FILE
}
function print_fiber_header() {
#remove leading zero
local maxFiber=$(expr $1 + 0)
local nbFiber=${#fiber_params[@]}
echo -e "\nconfig N_FIBER_ENTRIES" >>$OUTPUT_FILE
echo -e "\tint \"Number of fiber entries in fiber configuration DB\"" >>$OUTPUT_FILE
echo -e "\trange 0 $maxFiber" >>$OUTPUT_FILE
echo -e "\thelp" >>$OUTPUT_FILE
echo -e "\tThis parameter defines the number of fiber entries" >>$OUTPUT_FILE
echo -e "\tthat can be set in the configuration database" >>$OUTPUT_FILE
echo -e "\tIncrease this number to add a new fiber entry." >>$OUTPUT_FILE
echo -e "\nmenu \"Fibers configuration DB\"" >>$OUTPUT_FILE
}
function print_fiber_entry() {
#remove leading zero
local maxFiber=$(expr $1 + 0)
local idFiber=$(expr $2 + 0)
echo -e "\nconfig FIBER${2}_PARAMS" >>$OUTPUT_FILE
echo -e "string \"Parameters for fiber type $idFiber\"" >>$OUTPUT_FILE
depends=""
fid=$(expr $idFiber + 1)
for i in `seq $fid $maxFiber`; do
if [ "$depends" != "" ] ; then depends="$depends ||"; fi
depends="$depends N_FIBER_ENTRIES=$i"
done
echo -e "\tdepends on $depends" >>$OUTPUT_FILE
echo -e "\tdefault \"${fiber_params[$idFiber]}\"" >>$OUTPUT_FILE
echo -e "\thelp" >>$OUTPUT_FILE
echo -e "\tThis parameter specify the physical features of used fiber type." >>$OUTPUT_FILE
echo -e "\tSpecify the alpha value for each pair of used wavelengths." >>$OUTPUT_FILE
echo -e "\tThis parameter follows a format:" >>$OUTPUT_FILE
echo -e "\talpha_XXXX_YYYY=1.23e-04,alpha_AAAA_BBBB=4.56e-04,..." >>$OUTPUT_FILE
echo -e "\twhere XXX_YYYY and AAAA_BBBB are pairs of used wavelengths," >>$OUTPUT_FILE
echo -e "\t1.23e-04, 4.56e-04 are alpha values to be used for particular" >>$OUTPUT_FILE
echo -e "\twavelengths." >>$OUTPUT_FILE
echo -e "\tTo set a new fiber entry, increment the parameter " >>$OUTPUT_FILE
echo -e "\t\"Number of fiber entries in fiber configuration DB\" in the upper menu." >>$OUTPUT_FILE
}
function print_fiber_footer() {
echo -e "\nendmenu" >>$OUTPUT_FILE
}
declare sfp_params=(
"vn=Axcen Photonics,pn=AXGE-1254-0531,tx=0,rx=0,wl_txrx=1310+1490"
"vn=Axcen Photonics,pn=AXGE-3454-0531,tx=0,rx=0,wl_txrx=1490+1310"
"vn=APAC Opto,pn=LS38-C3S-TC-N-B9,tx=761,rx=557,wl_txrx=1310+1490"
"vn=APAC Opto,pn=LS48-C3S-TC-N-B4,tx=-29,rx=507,wl_txrx=1490+1310"
"vn=ZyXEL,pn=SFP-BX1490-10-D,tx=0,rx=0,wl_txrx=1490+1310"
"vn=ZyXEL,pn=SFP-BX1310-10-D,tx=0,rx=0,wl_txrx=1310+1490"
)
declare fiber_params=(
"alpha_1310_1490=2.6787e-04"
"alpha_1310_1490=2.6787e-04"
"alpha_1310_1490=2.6787e-04"
"alpha_1310_1490=2.6787e-04"
)
print_header
mxSFPs=18
print_sfp_header $mxSFPs
lid=$(expr $mxSFPs - 1)
for i_sfp in `seq -f "%02.0f" 0 $lid`; do
print_sfp_entry $mxSFPs $i_sfp
done
print_sfp_footer
mxFibers=18
print_fiber_header $mxFibers
lid=$(expr $mxFibers - 1)
for i_fiber in `seq -f "%02.0f" 0 $lid`; do
print_fiber_entry $mxFibers $i_fiber
done
print_fiber_footer
print_footer
......@@ -15,7 +15,8 @@ OBJDUMP = $(CROSS_COMPILE)objdump
CFLAGS = -D KBUILD_NO_NLS
# most of this is just copying stuff in
RFILES = Kconfig_port_timing.in Kconfig Kconfig_vlans.in dot-config wrs_release_defconfig
RFILES = Kconfig_sfp_fiber.in Kconfig_port_timing.in Kconfig Kconfig_vlans.in \
dot-config wrs_release_defconfig
XFILES = conf mconf nconf
FILES = $(RFILES) $(XFILES)
......
......@@ -276,6 +276,11 @@ int shw_sfp_header_verify(struct shw_sfp_header *head)
!shw_sfp_header_verify_ext(head)) ? 0 : -1;
}
static inline int getSfpTxWaveLength (struct shw_sfp_header *head) {
return (head->tx_wavelength[0] << 8)
+ head->tx_wavelength[1];
}
void shw_sfp_print_header(struct shw_sfp_header *head)
{
int i;
......@@ -305,8 +310,7 @@ void shw_sfp_print_header(struct shw_sfp_header *head)
for (i = 0; i < 4; i++)
printf("%c", head->vendor_rev[i]);
printf("\n");
printf("TX Wavelength: %d\n", (head->tx_wavelength[0] << 8)
+ head->tx_wavelength[1]);
printf("TX Wavelength: %d\n", getSfpTxWaveLength(head));
printf("Options: %04X\n", ((uint16_t *) head->options)[0]);
printf("Bitrate (MAX): %02X\n", head->br_max);
printf("Bitrate (MIN): %02X\n", head->br_min);
......@@ -690,9 +694,21 @@ int shw_sfp_read_db(void)
{
struct shw_sfp_caldata *sfp;
char s[128];
int error, val, index;
int error, val, index, nbSfpEntries;
char *retValue;
char *keySfpEntries="N_SFP_ENTRIES";
/* read dot-config values to get the number of defined fibers */
if( (retValue=libwr_cfg_get(keySfpEntries))==NULL) {
pr_error("Key \"%s\" is not defined\n",keySfpEntries);
return -1;
}
if (sscanf(retValue, "%i", &nbSfpEntries) != 1) {
pr_error("Invalid key \"%s\" value (%d)\n",keySfpEntries,*retValue);
return -1;
}
for (index = 0; ; index++) {
for (index = 0; index<nbSfpEntries; index++) {
error = libwr_cfg_convert2("SFP%02i_PARAMS", "pn",
LIBWR_STRING, s, index);
if (error)
......@@ -751,6 +767,16 @@ int shw_sfp_read_db(void)
return 0;
}
static inline void removeTrailingSpaces(char *p, int strSize) {
int i;
for (i = strSize-1; i >= 0 ; i--) {
if (p[i] != 0x20)
break;
p[i] = 0;
}
}
struct shw_sfp_caldata *shw_sfp_get_cal_data(int num,
struct shw_sfp_header *head)
{
......@@ -760,30 +786,20 @@ struct shw_sfp_caldata *shw_sfp_get_cal_data(int num,
char *vn = (char *)head->vendor_name;
char *pn = (char *)head->vendor_pn;
char *vs = (char *)head->vendor_serial;
int i;
int txWaveLength=getSfpTxWaveLength(head);
/* Replace spaces at the end of strings with 0 needed for
* string comparison inside shw_sfp_get_cal_data.
* String may contain spaces, standard says only about space padding */
for (i = 15; i >= 0 ; i--) {
if (vn[i] != 0x20)
break;
vn[i] = 0;
}
for (i = 15; i >= 0 ; i--) {
if (pn[i] != 0x20)
break;
pn[i] = 0;
}
for (i = 15; i >= 0 ; i--) {
if (vs[i] != 0x20)
break;
vs[i] = 0;
}
removeTrailingSpaces(vn,sizeof(head->vendor_name));
removeTrailingSpaces(pn,sizeof(head->vendor_pn));
removeTrailingSpaces(vs,sizeof(head->vendor_serial));
t = shw_sfp_cal_list;
/* In the first pass, look for serial number */
while (t) {
if ( t->tx_wl == txWaveLength ) {
if (t->vendor_name[0] == 0
&& strncmp(pn, t->part_num, 16) == 0
&& t->vendor_serial[0] == 0)
......@@ -791,7 +807,7 @@ struct shw_sfp_caldata *shw_sfp_get_cal_data(int num,
match_pn = t;
else if (strncmp(vn, t->vendor_name, 16) == 0
&& strncmp(pn, t->part_num, 16) == 0
&& t->vendor_serial[0] == 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
......@@ -799,6 +815,7 @@ struct shw_sfp_caldata *shw_sfp_get_cal_data(int num,
&& strncmp(vs, t->vendor_serial, 16) == 0)
/* matched vn, pn, vs */
return t;
}
t = t->next;
}
if (match_pn_vn)
......
......@@ -149,7 +149,6 @@ int halexp_pps_cmd(int cmd, hexp_pps_params_t * params)
case HEXP_PPSG_CMD_GET_TIMING_MODE:{
ret=hal_get_timing_mode();
printf("JCB: shw_pps_get_timing_mode() returns %d\n",ret);
return ret;
}
......
......@@ -113,6 +113,7 @@ static int hal_port_init(int index)
char key[128];
int port_i;
char *retValue;
int maxFibers;
/* index is 0..17, port_i 1..18 */
port_i = index + 1;
......@@ -158,8 +159,19 @@ static int hal_port_init(int index)
port_i, p->name, key,*retValue);
}
}
/* read dot-config values to get the number of defined fibers */
strcpy(key,"N_FIBER_ENTRIES");
if( (retValue=libwr_cfg_get(key))==NULL) {
pr_error("port %i (%s): no key \"%s\" specified\n",
port_i, p->name,key);
maxFibers=-1;
} else
if (sscanf(retValue, "%i", &maxFibers) != 1) {
pr_error("Invalid key \"%s\" value (%d)\n",key,*retValue);
maxFibers=-1;
}
if (p->fiber_index > 3) {
if (p->fiber_index > maxFibers) {
pr_error("port %i (%s): "
"not supported fiber value (%d), default to 0\n",
port_i, p->name,p->fiber_index);
......@@ -643,8 +655,9 @@ void hal_port_update_all()
hal_port_poll_sfp();
for (i = 0; i < HAL_MAX_PORTS; i++)
if (ports[i].in_use)
if (ports[i].in_use) {
hal_port_fsm(&ports[i]);
}
if (hal_shmem->read_sfp_diag == READ_SFP_DIAG_ENABLE
&& libwr_tmo_expired(&update_sfp_dom_tmo)) {
......
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