Skip to content

Commit

Permalink
SWPTP-897: configurable delay resp alarm and hybrid thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
abower-amd committed Jan 18, 2024
1 parent ce3316e commit 8876524
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 10 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ Changelog
### v3.7.1.1006

Features:
~ Add configurable missing delay response thresholds (SWPTP-897)
- max_missing_delayresps <for-alarm> <for-hybrid-fallback>
- default changed from "3 3" to "5 3".
~ Command line enhancements to support container usage (SWPTP-1401)
- Allow config to be read from stdin with '-f -'
- Add '--console' option to redirect logs to console
Expand Down
7 changes: 3 additions & 4 deletions src/ptp/ptpd2/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
/* timeout for receiving DelayResps, expressed in 2^x seconds (e.g. -2 = 250ms) */
#define DEFAULT_DELAY_RESP_RECEIPT_TIMEOUT -2
/* how many missing delay responses in a row before we raise an alarm */
#define DELAY_RESP_MISSING_ALARM_THRESHOLD 3
#define DEFAULT_DELAY_RESP_ALARM_THRESHOLD 5
/* Number of hybrid delay response failures before we revert to multicast mode */
#define DEFAULT_DELAY_RESP_HYBRID_THRESHOLD 3

/* Values for PTP filters */
#define DEFAULT_MPD_FILTER_SIZE 8
Expand Down Expand Up @@ -103,9 +105,6 @@ section 7.6.2.4, page 55:
/* After a fault occurs, seconds to wait before re-initialising */
#define PTPD_FAULT_RESTART_INTERVAL 5

/* Number of hybrid delay response failures before we revert to multicast mode */
#define PTPD_HYBRID_MODE_DELAY_RESP_MAX_FAILURES (3)

/* features, only change to refelect changes in implementation */
#define PTPD_TWO_STEP_FLAG TRUE

Expand Down
3 changes: 3 additions & 0 deletions src/ptp/ptpd2/datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ typedef struct ptpd_port_config {
Integer8 delayRespReceiptTimeout;
Integer8 minPdelayReqInterval;

Integer8 delayRespAlarmThreshold;
Integer8 delayRespHybridThreshold;

ClockQuality clockQuality;
TimePropertiesDS timeProperties;
UInteger8 priority1;
Expand Down
12 changes: 6 additions & 6 deletions src/ptp/ptpd2/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,9 @@ doTimerTick(RunTimeOpts *rtOpts, PtpClock *ptpClock)
/* Record the fact that we didn't get a timely response
* and set the alarm if it's happened too many times. */
ptpClock->sequentialMissingDelayResps++;
if (ptpClock->sequentialMissingDelayResps >= DELAY_RESP_MISSING_ALARM_THRESHOLD) {
if (ptpClock->sequentialMissingDelayResps >= rtOpts->delayRespAlarmThreshold) {
SYNC_MODULE_ALARM_SET(ptpClock->portAlarms, NO_DELAY_RESPS);
ptpClock->sequentialMissingDelayResps = DELAY_RESP_MISSING_ALARM_THRESHOLD;
ptpClock->sequentialMissingDelayResps = rtOpts->delayRespAlarmThreshold;
}
ptpClock->counters.delayRespTimeouts++;

Expand All @@ -682,12 +682,12 @@ doTimerTick(RunTimeOpts *rtOpts, PtpClock *ptpClock)
(ptpClock->effective_comm_caps.delayRespCapabilities & PTPD_COMM_MULTICAST_CAPABLE) &&
(ptpClock->unicast_delay_resp_failures >= 0)) {
ptpClock->unicast_delay_resp_failures++;
if (ptpClock->unicast_delay_resp_failures >= PTPD_HYBRID_MODE_DELAY_RESP_MAX_FAILURES) {
if (ptpClock->unicast_delay_resp_failures >= rtOpts->delayRespHybridThreshold) {
ptpClock->effective_comm_caps.delayRespCapabilities &= ~PTPD_COMM_UNICAST_CAPABLE;
WARNING("ptp %s: failed to receive DelayResp %d times in "
"hybrid mode. Reverting to multicast mode.\n",
rtOpts->name,
PTPD_HYBRID_MODE_DELAY_RESP_MAX_FAILURES);
rtOpts->delayRespHybridThreshold);
}
}

Expand All @@ -708,9 +708,9 @@ doTimerTick(RunTimeOpts *rtOpts, PtpClock *ptpClock)
/* Record the fact that we didn't get a timely response,
* and set the alarm if it's happened too many times. */
ptpClock->sequentialMissingDelayResps++;
if (ptpClock->sequentialMissingDelayResps >= DELAY_RESP_MISSING_ALARM_THRESHOLD) {
if (ptpClock->sequentialMissingDelayResps >= rtOpts->delayRespAlarmThreshold) {
SYNC_MODULE_ALARM_SET(ptpClock->portAlarms, NO_DELAY_RESPS);
ptpClock->sequentialMissingDelayResps = DELAY_RESP_MISSING_ALARM_THRESHOLD;
ptpClock->sequentialMissingDelayResps = rtOpts->delayRespAlarmThreshold;
}
ptpClock->counters.delayRespTimeouts++;
}
Expand Down
3 changes: 3 additions & 0 deletions src/ptp/ptpd2/ptpd_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ void ptpd_config_port_initialise(struct ptpd_port_config *config,
config->syncReceiptTimeout = DEFAULT_SYNC_RECEIPT_TIMEOUT;
config->delayRespReceiptTimeout = DEFAULT_DELAY_RESP_RECEIPT_TIMEOUT;

config->delayRespAlarmThreshold = DEFAULT_DELAY_RESP_ALARM_THRESHOLD;
config->delayRespHybridThreshold = DEFAULT_DELAY_RESP_HYBRID_THRESHOLD;

config->path_delay_filter_size = DEFAULT_MPD_FILTER_SIZE;
config->path_delay_filter_ageing = DEFAULT_MPD_FILTER_AGEING;
config->outlier_filter_size = DEFAULT_OUTLIER_FILTER_SIZE;
Expand Down
36 changes: 36 additions & 0 deletions src/ptp/sfptpd_ptp_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,35 @@ static int parse_delayresp_pkt_timeout(struct sfptpd_config_section *section, co
return 0;
}

static int parse_max_missing_delayresps(struct sfptpd_config_section *section, const char *option,
unsigned int num_params, const char * const params[])
{
sfptpd_ptp_module_config_t *ptp = (sfptpd_ptp_module_config_t *)section;
int tokens;
int value;

assert(num_params == 2);

tokens = sscanf(params[0], "%i", &value);
if (tokens != 1)
return EINVAL;

if (value < 0 || value > INT8_MAX)
return ERANGE;

ptp->ptpd_port.delayRespAlarmThreshold = value;

tokens = sscanf(params[0], "%i", &value);
if (tokens != 1)
return EINVAL;

if (value < 0 || value > INT8_MAX)
return ERANGE;

ptp->ptpd_port.delayRespHybridThreshold = value;
return 0;
}

static int parse_max_foreign_records(struct sfptpd_config_section *section, const char *option,
unsigned int num_params, const char * const params[])
{
Expand Down Expand Up @@ -1451,6 +1480,13 @@ static const sfptpd_config_option_t ptp_config_options[] =
"The PTP Delay Response receipt timeout in 2^NUMBER seconds. Default value -2.",
1, SFPTPD_CONFIG_SCOPE_INSTANCE, false,
parse_delayresp_pkt_timeout},
{"max_missing_delayresps", "A B",
"The maximimum number of missing delay responses to alarm (A) "
"or fall back from hybrid mode (B). Default "
STRINGIFY(DEFAULT_DELAY_RESP_ALARM_THRESHOLD) " "
STRINGIFY(DEFAULT_DELAY_RESP_HYBRID_THRESHOLD) ".",
2, SFPTPD_CONFIG_SCOPE_INSTANCE, false,
parse_max_missing_delayresps},
{"ptp_max_foreign_records", "NUMBER",
"The maximum number of PTP foreign master records.",
1, SFPTPD_CONFIG_SCOPE_GLOBAL, false,
Expand Down

0 comments on commit 8876524

Please sign in to comment.