Commit ca05b6f3 authored by Jean-Claude BAU's avatar Jean-Claude BAU Committed by Adam Wujek

Configuration enhancement (follow up)

        - Add new config parameters (l1SyncRxCoherencyIsRequired,...)
        - Add new profile: CUSTOM. It will be mostly used for testing
        - Fix issue on state name: "pre_master" instead of "pre-master"
parent e4b95a9e
This diff is collapsed.
This diff is collapsed.
Subproject commit ce55ff3d4cd2eaec31d2d8a439df19fe863850e1
Subproject commit 443c6dfc6754f0e9e998e3cf04765dc4a04a8ab6
......@@ -107,7 +107,7 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
struct PortIdentity *pi = p;
struct ClockQuality *cq = p;
char format[16];
uint64_t sec, nano, pico;
uint64_t sec, nano, pico, femto;
int i;
char pname[128];
......@@ -187,18 +187,26 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
#define TIME_FRACBITS 16
#define TIME_FRACMASK 0xFFFF
#define TIME_SIGNMASK 0x8000000000000000
case dump_type_time:
{
char sign='+';
int64_t scaled_nsecs=t->scaled_nsecs;
uint64_t scaled_nsecs=t->scaled_nsecs;
int64_t secs=t->secs;
if ( scaled_nsecs < 0) {
if ( (scaled_nsecs & TIME_SIGNMASK) || secs<0) {
sign='-';
scaled_nsecs= ~scaled_nsecs+1;
secs=-secs;
}
nano = scaled_nsecs >> TIME_FRACBITS;
pico = scaled_nsecs & TIME_FRACMASK;
pico = (pico * 1000) >> TIME_FRACBITS;
femto = scaled_nsecs & TIME_FRACMASK;
femto = (femto * 1000 * 1000 ) >> TIME_FRACBITS;
pico= (femto/1000);
if ((femto % 1000)>500) {
pico++; // rounding
}
printf("correct=%i, value=%10c%lli.%09"PRIu64".%03"PRIu64"\n",
!is_incorrect(t),sign, t->secs, nano,pico);
}
......@@ -212,15 +220,25 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
#define TIME_INTERVAL_FRACBITS 16
#define TIME_INTERVAL_FRACMASK 0xFFFF
#define TIME_INTERVAL_SIGNMASK 0x8000000000000000
case dump_type_TimeInterval:
{
int64_t scaled_nsecs=*ti;
char sign='+';
uint64_t scaled_nsecs=*ti;
if ( scaled_nsecs & TIME_INTERVAL_SIGNMASK) {
sign='-';
scaled_nsecs= ~scaled_nsecs+1;
}
nano = scaled_nsecs >> TIME_INTERVAL_FRACBITS;
pico = scaled_nsecs & TIME_INTERVAL_FRACMASK;
pico = (pico * 1000) >> TIME_INTERVAL_FRACBITS;
printf("%10"PRId64".%03"PRIu64"\n", nano,pico);
femto = scaled_nsecs & TIME_INTERVAL_FRACMASK;
femto = (femto * 1000 * 1000 ) >> TIME_INTERVAL_FRACBITS;
pico= (femto/1000);
if ((femto % 1000)>500) {
pico++; // rounding
}
printf("%10c%"PRId64".%03"PRIu64"\n", sign,nano,pico);
}
break;
......
......@@ -118,9 +118,11 @@ static int hal_port_init(int index)
{
struct hal_port_state *p = &ports[index];
int i;
char name[128];
int val, error;
char key[128];
int val;
int wrInstanceFound=0;
int port_i;
char *retValue;
/* index is 0..17, port_i 1..18 */
port_i = index + 1;
......@@ -128,15 +130,14 @@ static int hal_port_init(int index)
/* make sure the states and other variables are in their init state */
hal_port_reset_state(p);
/* read dot-config values for this index, starting from name */
error = libwr_cfg_convert2("PORT%02i_PARAMS", "iface", LIBWR_STRING,
name, port_i);
if (error)
/* read dot-config values to get the interface name */
sprintf(key,"PORT%02i_IFACE",port_i);
if( (retValue=libwr_cfg_get(key))==NULL)
return -1;
strncpy(p->name, name, 16);
strncpy(p->name, retValue, 16);
/* check if the port is built into the firmware, if not, we are done */
if (!hal_port_check_presence(name, p->hw_addr))
if (!hal_port_check_presence(p->name, p->hw_addr))
return -1;
p->state = HAL_PORT_STATE_DISABLED;
......@@ -144,34 +145,36 @@ static int hal_port_init(int index)
/* Search an instance using the WR profile */
for (i=1; i<=2; i++) {
char str[32];
if ( !(error = libwr_cfg_convert2("PORT%02i_INST%02i", "prof", LIBWR_STRING,
str, port_i,i))) {
if ( strcasecmp("WR",str)==0 )
break; // Found
sprintf(key,"PORT%02i_INST%02i_PROFILE_WR",port_i,i);
if( ((retValue=libwr_cfg_get(key))!=NULL) && (*retValue=='y') ) {
wrInstanceFound++;
break; // Found
}
}
val = 18 * 800; /* magic default from previous code */
if ( !error ) {
if ( wrInstanceFound ) {
// WR instance found
val = 18 * 800; /* magic default from previous code */
error = libwr_cfg_convert2("PORT%02i_INST%02i", "tx", LIBWR_INT,
&val, port_i,i);
if (error)
pr_error("port %i (%s): no \"tx=\" specified\n",
port_i, name);
p->calib.phy_tx_min = val;
error = libwr_cfg_convert2("PORT%02i_INST%02i", "rx", LIBWR_INT,
&val, port_i,i);
if (error)
pr_error("port %i (%s): no \"rx=\" specified\n",
port_i, name);
p->calib.phy_rx_min = val;
for ( i=0; i<2; i++ ) {
char *latency=i==0 ? "EGRESS": "INGRESS";
uint32_t *phy_min=i==0 ? &p->calib.phy_tx_min: &p->calib.phy_rx_min;
sprintf(key,"PORT%02i_INST%02i_%s_LATENCY",port_i,i,latency);
if( (retValue=libwr_cfg_get(key))==NULL ) {
pr_error("port %i (%s): no key \"%s\" specified\n",
port_i, p->name,key);
} else {
if (sscanf(retValue, "%i", &val) != 1) {
pr_error("port %i (%s): Invalid key \"%s\" value (%d)\n",
port_i, p->name, key,*retValue);
}
}
*phy_min = val;
}
} else {
pr_error("port %i (%s): no WhiteRabbit instance defined\n",
port_i, name);
port_i, p->name);
p->calib.phy_tx_min = p->calib.phy_rx_min = val;
}
......@@ -187,21 +190,24 @@ static int hal_port_init(int index)
p->clock_period = REF_CLOCK_PERIOD_PS;
/* Get fiber type */
error = libwr_cfg_convert2("PORT%02i_PARAMS", "fiber",
LIBWR_INT, &p->fiber_index, port_i);
if (error) {
pr_error("port %i (%s): "
"no \"fiber=\" specified, default fiber to 0\n",
port_i, name);
p->fiber_index = 0;
p->fiber_index = 0; /* Default fiber value */
sprintf(key,"PORT%02i_INST%02i_FIBER",port_i,i);
if( (retValue=libwr_cfg_get(key))==NULL ) {
pr_error("port %i (%s): no key \"%s\" specified. Default fiber 0\n",
port_i, p->name,key);
} else {
if (sscanf(retValue, "%i", &p->fiber_index) != 1) {
pr_error("port %i (%s): Invalid key \"%s\" value (%d). Default fiber 0\n",
port_i, p->name, key,*retValue);
}
}
if (p->fiber_index > 3) {
pr_error("port %i (%s): "
"not supported \"fiber=\" value, default to 0\n",
port_i, name);
"not supported fiber value (%d), default to 0\n",
port_i, p->name,p->fiber_index);
p->fiber_index = 0;
}
}
/* Used to pre-calibrate the TX path for each port. No more in V3 */
......
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