From 413eceeddbe47bc71e3283b59e99aaf481f9b7ea Mon Sep 17 00:00:00 2001 From: Chen Caidy Date: Wed, 19 Jul 2023 12:09:15 +0000 Subject: [PATCH] net: gptp: fix follow_up message correction_field According to IEEE802.1AS Table 11-6 and 10.6.2.2.9, 802.1AS using peer-to-peer delay mechanism, two-step clock, Grand master clock should keep this correction_field as zero. Signed-off-by: Chen Caidy --- subsys/net/l2/ethernet/gptp/gptp_md.c | 16 ---------------- subsys/net/l2/ethernet/gptp/gptp_messages.c | 7 +++++-- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/subsys/net/l2/ethernet/gptp/gptp_md.c b/subsys/net/l2/ethernet/gptp/gptp_md.c index 5c53df4fb3e..fd0c62182a4 100644 --- a/subsys/net/l2/ethernet/gptp/gptp_md.c +++ b/subsys/net/l2/ethernet/gptp/gptp_md.c @@ -38,22 +38,6 @@ static void gptp_md_follow_up_prepare(struct net_pkt *pkt, hdr = GPTP_HDR(pkt); fup = GPTP_FOLLOW_UP(pkt); - /* - * Compute correction field according to IEEE802.1AS 11.2.14.2.3. - * - * The correction_field already contains the timestamp of the sync - * message. - * - * TODO: if the value to be stored in correction_field is too big to - * be represented, the field should be set to all 1's except the most - * significant bit. - */ - hdr->correction_field -= sync_send->upstream_tx_time; - hdr->correction_field *= sync_send->rate_ratio; - hdr->correction_field += sync_send->follow_up_correction_field; - hdr->correction_field <<= 16; - hdr->correction_field = htonll(hdr->correction_field); - memcpy(&hdr->port_id.clk_id, &sync_send->src_port_id.clk_id, GPTP_CLOCK_ID_LEN); diff --git a/subsys/net/l2/ethernet/gptp/gptp_messages.c b/subsys/net/l2/ethernet/gptp/gptp_messages.c index 1aa6b64a38b..cb6fcf5bf38 100644 --- a/subsys/net/l2/ethernet/gptp/gptp_messages.c +++ b/subsys/net/l2/ethernet/gptp/gptp_messages.c @@ -271,8 +271,11 @@ struct net_pkt *gptp_prepare_follow_up(int port, struct net_pkt *sync) hdr->ptp_version = GPTP_VERSION; hdr->sequence_id = sync_hdr->sequence_id; hdr->domain_number = 0U; - /* Store timestamp value in correction field. */ - hdr->correction_field = gptp_timestamp_to_nsec(&sync->timestamp); + /* + * Grand master clock should keep correction_field at zero, + * according to IEEE802.1AS Table 11-6 and 10.6.2.2.9 + */ + hdr->correction_field = 0LL; hdr->flags.octets[0] = 0U; hdr->flags.octets[1] = GPTP_FLAG_PTP_TIMESCALE; hdr->message_length = htons(sizeof(struct gptp_hdr) +