Commit c9c5dca0 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

ptpd: disable port (go to PTP_DISABLED state) if WR link setup fails

parent b71700e2
......@@ -59,6 +59,7 @@
#endif
#define DEFAULT_PARENTS_STATS FALSE
#define DEFAULT_DISABLE_FALLBACK_WHEN_WR_FAILS TRUE
/* features, only change to refelect changes in implementation */
#define NUMBER_PORTS 2
......
......@@ -707,6 +707,7 @@ typedef struct {
Boolean autoPortDiscovery;
Boolean primarySource;
Boolean masterOnly;
Boolean disableFallbackIfWRFails;
} RunTimeOpts;
#endif /*DATATYPES_H_*/
......@@ -65,7 +65,7 @@ PtpPortDS * ptpdStartup(int argc, char **argv, Integer16 *ret, RunTimeOpts *rtOp
int startupMode = DEFAULT_STARTUP_MODE; //1=> daemon, 0=>nondaemon
/* parse command line arguments */
while( (c = getopt(argc, argv, "?cf:dDABMSNPxta:w:M:b:1:2:3:u:l:o:n:y:m:gv:r:s:p:q:i:eh")) != -1 ) {
while( (c = getopt(argc, argv, "?cf:dDABMSNPxta:w:M:b:1:2:3:u:l:o:n:y:m:g:v:r:s:p:q:i:eh")) != -1 ) {
switch(c) {
case '?':
printf(
......@@ -85,6 +85,7 @@ PtpPortDS * ptpdStartup(int argc, char **argv, Integer16 *ret, RunTimeOpts *rtOp
"-r NUMBER specify system clock accuracy\n"
"-v NUMBER specify system clock class\n"
"-p NUMBER specify priority1 attribute\n"
"-g [0/1] enable/disable fallback to standard PTP mode in case of WR initialization failure\n"
"-d run in daemon mode !!! \n"
"-c run in non-daemon mode\n"
"-A WR: hands free - multiport mode, autodetection of ports and interfaces ,"
......@@ -194,6 +195,8 @@ PtpPortDS * ptpdStartup(int argc, char **argv, Integer16 *ret, RunTimeOpts *rtOp
// break;
case 'g':
rtOpts->disableFallbackIfWRFails=strtol(optarg, 0, 0) ? TRUE : FALSE;
break;
// case 's':
......
......@@ -39,6 +39,7 @@ RunTimeOpts rtOpts = {
.wrStateTimeout = WR_DEFAULT_STATE_TIMEOUT_MS,
.phyCalibrationRequired = WR_DEFAULT_PHY_CALIBRATION_REQUIRED,
.masterOnly = FALSE,
.disableFallbackIfWRFails = DEFAULT_DISABLE_FALLBACK_WHEN_WR_FAILS
/********************************************************/
};
......
......@@ -206,16 +206,20 @@ void wrTimerExpired(UInteger8 currentState, RunTimeOpts *rtOpts, PtpPortDS *ptpP
}
else
{
PTPD_TRACE(TRACE_WR_PROTO, ptpPortDS,"WR_Slave_TIMEOUT: state[=%d] timeout, repeated %d times, going to Standard PTP\n", \
// PTPD_TRACE(TRACE_WR_PROTO, ptpPortDS,"WR_Slave_TIMEOUT: state[=%d] timeout, repeated %d times, going to Standard PTP\n", \
currentState,ptpPortDS->currentWRstateCnt );
ptpPortDS->wrModeON = FALSE;
toWRState(WRS_IDLE, rtOpts, ptpPortDS);
if(wrMode == WR_MASTER)
if(rtOpts->disableFallbackIfWRFails)
{
PTPD_TRACE(TRACE_WR_PROTO, ptpPortDS,"WR_Slave_TIMEOUT: state[=%d] timeout, disabling port (standard PTP fallback OFF).\n", currentState);
toState(PTP_DISABLED, rtOpts, ptpPortDS);
} else if(wrMode == WR_MASTER)
toState(PTP_MASTER, rtOpts, ptpPortDS);
else
toState(PTP_SLAVE, rtOpts, ptpPortDS);
else toState(PTP_SLAVE, rtOpts, ptpPortDS);
/*
* RE-INITIALIZATION OF White Rabbit Data Sets
* (chapter (Re-)Initialization of wrspec
......
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