Re: [Linuxptp-devel] [PATCH v1 1/2] msg: Enable changing PTP message header version

2023-03-07 Thread Richard Cochran
On Tue, Mar 07, 2023 at 04:13:50PM +0100, Maciek Machnikowski wrote:
> Some hardware can't properly timestamp packets with the new PTP
> header version 2.1. This patch introduces a global var ptp_hdr_ver
> that can be changed externally to allow legacy PTP version to be
> advertised.

As previously discussed, I won't support borken hardware going forward.

Thanks,
Richard


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v1 1/2] msg: Enable changing PTP message header version

2023-03-07 Thread Maciek Machnikowski
Some hardware can't properly timestamp packets with the new PTP
header version 2.1. This patch introduces a global var ptp_hdr_ver
that can be changed externally to allow legacy PTP version to be
advertised.

Signed-off-by: Maciek Machnikowski 
---
 msg.c  |  1 +
 msg.h  |  5 +
 port.c | 18 +-
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/msg.c b/msg.c
index c2d358b..f9a0958 100644
--- a/msg.c
+++ b/msg.c
@@ -29,6 +29,7 @@
 #include "tlv.h"
 
 int assume_two_step = 0;
+uint8_t ptp_hdr_ver = PTP_VERSION;
 
 /*
  * Head room fits a VLAN Ethernet header, and 'msg' is 64 bit aligned.
diff --git a/msg.h b/msg.h
index b7423ee..4a48c6c 100644
--- a/msg.h
+++ b/msg.h
@@ -444,6 +444,11 @@ static inline Boolean msg_unicast(struct ptp_message *m)
return field_is_set(m, 0, UNICAST);
 }
 
+/**
+ * Work around HW assuming PTP message version 2.0
+ */
+extern uint8_t ptp_hdr_ver;
+
 /**
  * Work around buggy 802.1AS switches.
  */
diff --git a/port.c b/port.c
index 3453716..43dc04d 100644
--- a/port.c
+++ b/port.c
@@ -1538,7 +1538,7 @@ static int port_pdelay_request(struct port *p)
msg->hwts.type = p->timestamping;
 
msg->header.tsmt   = PDELAY_REQ | p->transportSpecific;
-   msg->header.ver= PTP_VERSION;
+   msg->header.ver= ptp_hdr_ver;
msg->header.messageLength  = sizeof(struct pdelay_req_msg);
msg->header.domainNumber   = clock_domain_number(p->clock);
msg->header.correction = -p->asymmetry;
@@ -1602,7 +1602,7 @@ int port_delay_request(struct port *p)
msg->hwts.type = p->timestamping;
 
msg->header.tsmt   = DELAY_REQ | p->transportSpecific;
-   msg->header.ver= PTP_VERSION;
+   msg->header.ver= ptp_hdr_ver;
msg->header.messageLength  = sizeof(struct delay_req_msg);
msg->header.domainNumber   = clock_domain_number(p->clock);
msg->header.correction = -p->asymmetry;
@@ -1655,7 +1655,7 @@ int port_tx_announce(struct port *p, struct address *dst, 
uint16_t sequence_id)
msg->hwts.type = p->timestamping;
 
msg->header.tsmt   = ANNOUNCE | p->transportSpecific;
-   msg->header.ver= PTP_VERSION;
+   msg->header.ver= ptp_hdr_ver;
msg->header.messageLength  = sizeof(struct announce_msg);
msg->header.domainNumber   = clock_domain_number(p->clock);
msg->header.sourcePortIdentity = p->portIdentity;
@@ -1738,7 +1738,7 @@ int port_tx_sync(struct port *p, struct address *dst, 
uint16_t sequence_id)
msg->hwts.type = p->timestamping;
 
msg->header.tsmt   = SYNC | p->transportSpecific;
-   msg->header.ver= PTP_VERSION;
+   msg->header.ver= ptp_hdr_ver;
msg->header.messageLength  = sizeof(struct sync_msg);
msg->header.domainNumber   = clock_domain_number(p->clock);
msg->header.sourcePortIdentity = p->portIdentity;
@@ -1774,7 +1774,7 @@ int port_tx_sync(struct port *p, struct address *dst, 
uint16_t sequence_id)
fup->hwts.type = p->timestamping;
 
fup->header.tsmt   = FOLLOW_UP | p->transportSpecific;
-   fup->header.ver= PTP_VERSION;
+   fup->header.ver= ptp_hdr_ver;
fup->header.messageLength  = sizeof(struct follow_up_msg);
fup->header.domainNumber   = clock_domain_number(p->clock);
fup->header.sourcePortIdentity = p->portIdentity;
@@ -2124,7 +2124,7 @@ static int process_delay_req(struct port *p, struct 
ptp_message *m)
msg->hwts.type = p->timestamping;
 
msg->header.tsmt   = DELAY_RESP | p->transportSpecific;
-   msg->header.ver= PTP_VERSION;
+   msg->header.ver= ptp_hdr_ver;
msg->header.messageLength  = sizeof(struct delay_resp_msg);
msg->header.domainNumber   = m->header.domainNumber;
msg->header.correction = m->header.correction;
@@ -2316,7 +2316,7 @@ int process_pdelay_req(struct port *p, struct ptp_message 
*m)
rsp->hwts.type = p->timestamping;
 
rsp->header.tsmt   = PDELAY_RESP | p->transportSpecific;
-   rsp->header.ver= PTP_VERSION;
+   rsp->header.ver= ptp_hdr_ver;
rsp->header.messageLength  = sizeof(struct pdelay_resp_msg);
rsp->header.domainNumber   = m->header.domainNumber;
rsp->header.sourcePortIdentity = p->portIdentity;
@@ -2363,7 +2363,7 @@ int process_pdelay_req(struct port *p, struct ptp_message 
*m)
fup->hwts.type = p->timestamping;
 
fup->header.tsmt   = PDELAY_RESP_FOLLOW_UP | 
p->transportSpecific;
-   fup->header.ver= PTP_VERSION;
+   fup->header.ver= ptp_hdr_ver;