[Linuxptp-devel] [PATCH] ptp4l: version preparation for IEEE 1588-2019

2021-02-19 Thread Yangbo Lu
IEEE 1588-2019 specified new UInteger4 type minorVersionPTP field in header,
and minorVersionNumber data in portDS. It has the value 1 for IEEE 1588-2019,
and has the value 0 for IEEE 1588-2008.

This patch is to make versionNumber and minorVersionNumber configurable, rather
than using hard-coded IEEE 1588-2008 version, for PTP packets.
This is just preparation for future features support and profiles support based
on IEEE 1588-2019.

It seems IEEE 1588-2019 specified minorVersionNumber in portDS, but not in
PORT_DATA_SET management TLV data field. It's confusing. So this patch hasn't
added the minorVersionNumber in portDS making this as a TODO thing.

Signed-off-by: Yangbo Lu 
---
 config.c|  2 ++
 configs/default.cfg |  2 ++
 msg.c   |  5 +
 msg.h   |  5 +++--
 port.c  | 23 +--
 port_private.h  |  3 ++-
 port_signaling.c|  2 +-
 ptp4l.8 |  8 
 8 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/config.c b/config.c
index 341f887..69cfb10 100644
--- a/config.c
+++ b/config.c
@@ -273,6 +273,7 @@ struct config_item config_tab[] = {
GLOB_ITEM_STR("manufacturerIdentity", "00:00:00"),
GLOB_ITEM_INT("max_frequency", 9, 0, INT_MAX),
PORT_ITEM_INT("min_neighbor_prop_delay", -2000, INT_MIN, -1),
+   PORT_ITEM_INT("minorVersionNumber", 0, 0, 1),
PORT_ITEM_INT("msg_interval_request", 0, 0, 1),
PORT_ITEM_INT("neighborPropDelayThresh", 2000, 0, INT_MAX),
PORT_ITEM_INT("net_sync_monitor", 0, 0, 1),
@@ -332,6 +333,7 @@ struct config_item config_tab[] = {
GLOB_ITEM_STR("userDescription", ""),
GLOB_ITEM_INT("utc_offset", CURRENT_UTC_OFFSET, 0, INT_MAX),
GLOB_ITEM_INT("verbose", 0, 0, 1),
+   PORT_ITEM_INT("versionNumber", 2, 2, 2),
GLOB_ITEM_INT("write_phase_mode", 0, 0, 1),
 };
 
diff --git a/configs/default.cfg b/configs/default.cfg
index 9604219..139ace0 100644
--- a/configs/default.cfg
+++ b/configs/default.cfg
@@ -40,6 +40,8 @@ BMCAptp
 inhibit_announce0
 inhibit_delay_req   0
 ignore_source_id0
+versionNumber   2
+minorVersionNumber  0
 #
 # Run time options
 #
diff --git a/msg.c b/msg.c
index d1619d4..a2f0567 100644
--- a/msg.c
+++ b/msg.c
@@ -27,9 +27,6 @@
 #include "print.h"
 #include "tlv.h"
 
-#define VERSION_MASK 0x0f
-#define VERSION  0x02
-
 int assume_two_step = 0;
 
 /*
@@ -80,7 +77,7 @@ static void announce_post_recv(struct announce_msg *m)
 
 static int hdr_post_recv(struct ptp_header *m)
 {
-   if ((m->ver & VERSION_MASK) != VERSION)
+   if ((m->ver & VERSION_MASK) != PTP_VERSION)
return -EPROTO;
m->messageLength = ntohs(m->messageLength);
m->correction = net2host64(m->correction);
diff --git a/msg.h b/msg.h
index a71df16..469f2ac 100644
--- a/msg.h
+++ b/msg.h
@@ -30,7 +30,8 @@
 #include "tlv.h"
 #include "tmv.h"
 
-#define PTP_VERSION 2
+#define PTP_VERSION2   /* This is major revision */
+#define VERSION_MASK   0x0f
 
 /* Values for the messageType field */
 #define SYNC  0x0
@@ -89,7 +90,7 @@ enum controlField {
 
 struct ptp_header {
uint8_t tsmt; /* transportSpecific | messageType */
-   uint8_t ver;  /* reserved  | versionPTP  */
+   uint8_t ver;  /* minorVersionPTP | versionPTP */
UInteger16  messageLength;
UInteger8   domainNumber;
Octet   reserved1;
diff --git a/port.c b/port.c
index 2bb974c..6423484 100644
--- a/port.c
+++ b/port.c
@@ -1353,7 +1353,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= p->minorVersionNumber << 4 | 
p->versionNumber;
msg->header.messageLength  = sizeof(struct pdelay_req_msg);
msg->header.domainNumber   = clock_domain_number(p->clock);
msg->header.correction = -p->asymmetry;
@@ -1417,7 +1417,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= p->minorVersionNumber << 4 | 
p->versionNumber;
msg->header.messageLength  = sizeof(struct delay_req_msg);
msg->header.domainNumber   = clock_domain_number(p->clock);
msg->header.correction = -p->asymmetry;
@@ -1470,7 +1470,7 @@ int port_tx_announce(struct port *p, struct address *dst)
msg->hwts.type = p->timestamping;
 
msg->header.tsmt   = ANNOUNCE | p->transportSpecific;
-   msg->header.ver= PTP_VERSION;
+   msg->header.ver= 

Re: [Linuxptp-devel] [PATCH 2/2] Clock Class Threshold Feature addition for PTP4L

2021-02-19 Thread Keller, Jacob E



> -Original Message-
> From: Richard Cochran 
> Sent: Tuesday, February 16, 2021 8:21 PM
> To: Keller, Jacob E 
> Cc: linuxptp-devel@lists.sourceforge.net
> Subject: Re: [Linuxptp-devel] [PATCH 2/2] Clock Class Threshold Feature 
> addition
> for PTP4L
> 
> On Tue, Feb 16, 2021 at 02:08:44PM -0800, Jacob Keller wrote:
> > On 2/14/2021 9:59 PM, Karthikkumar V wrote:
> > > - c->clock_class_threshold = config_get_int(config, NULL,
> "clockClassThreshold");
> > > + c->clock_class_threshold = config_get_int(config, NULL,
> "clock_class_threshold");
> > >
> >
> >
> > Why this change? It seems weird to remove this variable and introduce
> > another? clockClassThreshold is supposed to be the standard isn't it?
> 
> I think Karthikkumar made a delta patch to the previous one.
> 
> (and no, there is no clockClassThreshold in 1588)
> 


Ok, that makes more sense, thanks!

> Thanks,
> Richard


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