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 <chen@caidy.cc>
This commit is contained in:
Chen Caidy 2023-07-19 12:09:15 +00:00 committed by Anas Nashif
commit 413eceeddb
2 changed files with 5 additions and 18 deletions

View file

@ -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);

View file

@ -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) +