This change introduces a new TLV to convey link delay measurements by the Common Mean Link Delay Service (CMLDS) (as specified in IEEE 1588/16.6.3) over the management interface. Also updated 'pmc' to support the new MID, MID_CMLDS_INFO_NP.
Co-authored-by: Andrew Zaborowski <andrew.zaborow...@intel.com> Signed-off-by: Kishen Maloor <kishen.mal...@intel.com> --- clock.c | 1 - msg.h | 2 ++ pmc.c | 10 ++++++++++ pmc_common.c | 1 + port.c | 12 ++++++++++++ tlv.c | 14 ++++++++++++++ tlv.h | 9 +++++++++ 7 files changed, 48 insertions(+), 1 deletion(-) diff --git a/clock.c b/clock.c index 75d7c4008977..85f2a04867e5 100644 --- a/clock.c +++ b/clock.c @@ -47,7 +47,6 @@ #include "util.h" #define N_CLOCK_PFD (N_POLLFD + 1) /* one extra per port, for the fault timer */ -#define POW2_41 ((double)(1ULL << 41)) struct interface { STAILQ_ENTRY(interface) list; diff --git a/msg.h b/msg.h index b7423eec8778..0feb6c4b18fa 100644 --- a/msg.h +++ b/msg.h @@ -69,6 +69,8 @@ #define SIGNAL_NO_CHANGE -128 #define SIGNAL_SET_INITIAL 126 +#define POW2_41 ((double)(1ULL << 41)) + enum timestamp_type { TS_SOFTWARE, TS_HARDWARE, diff --git a/pmc.c b/pmc.c index 00e691f0c244..fbf312cb6c53 100644 --- a/pmc.c +++ b/pmc.c @@ -169,6 +169,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp) struct subscribe_events_np *sen; struct port_properties_np *ppn; struct port_hwclock_np *phn; + struct cmlds_info_np *cmlds; struct timePropertiesDS *tp; struct management_tlv *mgt; struct time_status_np *tsn; @@ -651,6 +652,15 @@ static void pmc_show(struct ptp_message *msg, FILE *fp) fprintf(fp, "LOG_MIN_PDELAY_REQ_INTERVAL " IFMT "logMinPdelayReqInterval %hhd", mtd->val); break; + case MID_CMLDS_INFO_NP: + cmlds = (struct cmlds_info_np *) mgt->data; + fprintf(fp, "CMLDS INFO " + IFMT "serviceMeasurementValid %i" + IFMT "meanLinkDelay %" PRId64 + IFMT "scaledNeighborRateRatio %" PRId32, + cmlds->serviceMeasurementValid, cmlds->meanLinkDelay, + cmlds->scaledNeighborRateRatio); + break; } out: fprintf(fp, "\n"); diff --git a/pmc_common.c b/pmc_common.c index a03f191e8dc6..50d9db46aa92 100644 --- a/pmc_common.c +++ b/pmc_common.c @@ -156,6 +156,7 @@ struct management_id idtab[] = { { "UNICAST_MASTER_TABLE_NP", MID_UNICAST_MASTER_TABLE_NP, do_get_action }, { "PORT_HWCLOCK_NP", MID_PORT_HWCLOCK_NP, do_get_action }, { "POWER_PROFILE_SETTINGS_NP", MID_POWER_PROFILE_SETTINGS_NP, do_set_action }, + { "CMLDS_INFO_NP", MID_CMLDS_INFO_NP, do_get_action }, }; static void do_get_action(struct pmc *pmc, int action, int index, char *str) diff --git a/port.c b/port.c index 3453716f6020..d61e9b67e422 100644 --- a/port.c +++ b/port.c @@ -887,6 +887,7 @@ static int port_management_fill_response(struct port *target, struct clock_description *desc; struct port_properties_np *ppn; struct port_hwclock_np *phn; + struct cmlds_info_np *cmlds; struct management_tlv *tlv; struct port_stats_np *psn; struct foreign_clock *fc; @@ -1129,6 +1130,17 @@ static int port_management_fill_response(struct port *target, memcpy(pwr, &target->pwr, sizeof(*pwr)); datalen = sizeof(*pwr); break; + case MID_CMLDS_INFO_NP: + cmlds = (struct cmlds_info_np *)tlv->data; + cmlds->serviceMeasurementValid = + /* IEEE1588-2019 16.6.3.2 h) 1) */ + target->peer_portid_valid && !target->pdr_missing && + !target->multiple_pdr_detected; + cmlds->meanLinkDelay = target->peerMeanPathDelay; + cmlds->scaledNeighborRateRatio = + (Integer32) (target->nrate.ratio * POW2_41 - POW2_41); + datalen = sizeof(*cmlds); + break; default: /* The caller should *not* respond to this message. */ tlv_extra_recycle(extra); diff --git a/tlv.c b/tlv.c index 79400126cbc4..aefbcb9f744e 100644 --- a/tlv.c +++ b/tlv.c @@ -176,6 +176,7 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len, struct port_properties_np *ppn; struct port_hwclock_np *phn; struct timePropertiesDS *tp; + struct cmlds_info_np *cmlds; struct time_status_np *tsn; struct port_stats_np *psn; int extra_len = 0, i, len; @@ -490,6 +491,13 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len, if (data_len != 0) goto bad_length; break; + case MID_CMLDS_INFO_NP: + if (data_len < sizeof(struct cmlds_info_np)) + goto bad_length; + cmlds = (struct cmlds_info_np *)m->data; + net2host64_unaligned(&cmlds->meanLinkDelay); + NTOHL(cmlds->scaledNeighborRateRatio); + break; } if (extra_len) { if (extra_len % 2) @@ -514,6 +522,7 @@ static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra) struct subscribe_events_np *sen; struct port_properties_np *ppn; struct port_hwclock_np *phn; + struct cmlds_info_np *cmlds; struct timePropertiesDS *tp; struct time_status_np *tsn; struct port_stats_np *psn; @@ -672,6 +681,11 @@ static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra) HTONL(pwr->networkTimeInaccuracy); HTONL(pwr->totalTimeInaccuracy); break; + case MID_CMLDS_INFO_NP: + cmlds = (struct cmlds_info_np *)m->data; + host2net64_unaligned(&cmlds->meanLinkDelay); + HTONL(cmlds->scaledNeighborRateRatio); + break; } } diff --git a/tlv.h b/tlv.h index 8b51ffd88816..73b6078e2efd 100644 --- a/tlv.h +++ b/tlv.h @@ -130,6 +130,9 @@ enum management_action { #define MID_PORT_HWCLOCK_NP 0xC009 #define MID_POWER_PROFILE_SETTINGS_NP 0xC00A +/* CMLDS management ID values */ +#define MID_CMLDS_INFO_NP 0xC00B + /* Management error ID values */ #define MID_RESPONSE_TOO_BIG 0x0001 #define MID_NO_SUCH_ID 0x0002 @@ -473,6 +476,12 @@ struct msg_interface_rate_tlv { UInteger16 numberOfBitsAfterTimestamp; } PACKED; +struct cmlds_info_np { + Integer8 serviceMeasurementValid; + TimeInterval meanLinkDelay; + Integer32 scaledNeighborRateRatio; +} PACKED; + /** * Allocates a new tlv_extra structure. * @return Pointer to a new structure on success or NULL otherwise. -- 2.31.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel