Discussion:
[Linuxptp-devel] [PATCH RFC 0/8] Single field clock management requests
Richard Cochran
2013-03-03 19:35:03 UTC
Permalink
This series add support for the various single field GET requests that
apply to a clock. A similar pattern can be used for six of the port
requests.

Warning: compile tested only.

Richard Cochran (8):
Add an all purpose, single byte management TLV.
Add support for the priority1 management request.
Add support for the priority2 management request.
Add support for the domain management request.
Add support for the slave_only management request.
Add support for the clock_accuracy management request.
Add support for the traceability management request.
Add support for the timescale management request.

clock.c | 43 +++++++++++++++++++++++++++++++++++++++++++
pmc.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++-------
tlv.h | 5 +++++
3 files changed, 94 insertions(+), 7 deletions(-)
--
1.7.2.5
Richard Cochran
2013-03-03 19:35:04 UTC
Permalink
Many of the single field management messages have just two bytes, one for
the data value and one for padding. This patch adds a structure that can
be used for all of these management IDs.

Signed-off-by: Richard Cochran <***@gmail.com>
---
tlv.h | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/tlv.h b/tlv.h
index b437286..9992fc3 100644
--- a/tlv.h
+++ b/tlv.h
@@ -114,6 +114,11 @@ struct management_tlv {
Octet data[0];
} PACKED;

+struct management_tlv_datum {
+ uint8_t val;
+ uint8_t reserved;
+} PACKED;
+
struct management_error_status {
Enumeration16 type;
UInteger16 length;
--
1.7.2.5
Richard Cochran
2013-03-03 19:35:05 UTC
Permalink
Signed-off-by: Richard Cochran <***@gmail.com>
---
clock.c | 7 +++++++
pmc.c | 8 +++++++-
2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/clock.c b/clock.c
index 87a2275..4cca1a4 100644
--- a/clock.c
+++ b/clock.c
@@ -156,6 +156,7 @@ static int clock_management_get_response(struct clock *c, struct port *p,
{
int datalen = 0, err, pdulen, respond = 0;
struct management_tlv *tlv;
+ struct management_tlv_datum *mtd;
struct ptp_message *rsp;
struct time_status_np *tsn;
struct PortIdentity pid = port_identity(p);
@@ -197,6 +198,12 @@ static int clock_management_get_response(struct clock *c, struct port *p,
datalen = sizeof(c->tds);
respond = 1;
break;
+ case PRIORITY1:
+ mtd = (struct management_tlv_datum *) tlv->data;
+ mtd->val = c->dds.priority1;
+ datalen = sizeof(*mtd);
+ respond = 1;
+ break;
case TIME_STATUS_NP:
tsn = (struct time_status_np *) tlv->data;
tsn->master_offset = c->master_offset;
diff --git a/pmc.c b/pmc.c
index 633eeaa..e79fa63 100644
--- a/pmc.c
+++ b/pmc.c
@@ -64,7 +64,7 @@ struct management_id idtab[] = {
{ "CURRENT_DATA_SET", CURRENT_DATA_SET, do_get_action },
{ "PARENT_DATA_SET", PARENT_DATA_SET, do_get_action },
{ "TIME_PROPERTIES_DATA_SET", TIME_PROPERTIES_DATA_SET, do_get_action },
- { "PRIORITY1", PRIORITY1, not_supported },
+ { "PRIORITY1", PRIORITY1, do_get_action },
{ "PRIORITY2", PRIORITY2, not_supported },
{ "DOMAIN", DOMAIN, not_supported },
{ "SLAVE_ONLY", SLAVE_ONLY, not_supported },
@@ -175,6 +175,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
int action;
struct TLV *tlv;
struct management_tlv *mgt;
+ struct management_tlv_datum *mtd;
struct defaultDS *dds;
struct currentDS *cds;
struct parentDS *pds;
@@ -312,6 +313,11 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
tp->flags & FREQ_TRACEABLE ? 1 : 0,
tp->timeSource);
break;
+ case PRIORITY1:
+ mtd = (struct management_tlv_datum *) mgt->data;
+ fprintf(fp, "PRIORITY1 "
+ IFMT "priority1 %hhu", mtd->val);
+ break;
case TIME_STATUS_NP:
tsn = (struct time_status_np *) mgt->data;
fprintf(fp, "TIME_STATUS_NP "
--
1.7.2.5
Richard Cochran
2013-03-03 19:35:06 UTC
Permalink
Signed-off-by: Richard Cochran <***@gmail.com>
---
clock.c | 6 ++++++
pmc.c | 7 ++++++-
2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/clock.c b/clock.c
index 4cca1a4..02b3a0f 100644
--- a/clock.c
+++ b/clock.c
@@ -204,6 +204,12 @@ static int clock_management_get_response(struct clock *c, struct port *p,
datalen = sizeof(*mtd);
respond = 1;
break;
+ case PRIORITY2:
+ mtd = (struct management_tlv_datum *) tlv->data;
+ mtd->val = c->dds.priority2;
+ datalen = sizeof(*mtd);
+ respond = 1;
+ break;
case TIME_STATUS_NP:
tsn = (struct time_status_np *) tlv->data;
tsn->master_offset = c->master_offset;
diff --git a/pmc.c b/pmc.c
index e79fa63..169b0a6 100644
--- a/pmc.c
+++ b/pmc.c
@@ -65,7 +65,7 @@ struct management_id idtab[] = {
{ "PARENT_DATA_SET", PARENT_DATA_SET, do_get_action },
{ "TIME_PROPERTIES_DATA_SET", TIME_PROPERTIES_DATA_SET, do_get_action },
{ "PRIORITY1", PRIORITY1, do_get_action },
- { "PRIORITY2", PRIORITY2, not_supported },
+ { "PRIORITY2", PRIORITY2, do_get_action },
{ "DOMAIN", DOMAIN, not_supported },
{ "SLAVE_ONLY", SLAVE_ONLY, not_supported },
{ "TIME", TIME, not_supported },
@@ -318,6 +318,11 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
fprintf(fp, "PRIORITY1 "
IFMT "priority1 %hhu", mtd->val);
break;
+ case PRIORITY2:
+ mtd = (struct management_tlv_datum *) mgt->data;
+ fprintf(fp, "PRIORITY2 "
+ IFMT "priority2 %hhu", mtd->val);
+ break;
case TIME_STATUS_NP:
tsn = (struct time_status_np *) mgt->data;
fprintf(fp, "TIME_STATUS_NP "
--
1.7.2.5
Richard Cochran
2013-03-03 19:35:07 UTC
Permalink
Signed-off-by: Richard Cochran <***@gmail.com>
---
clock.c | 6 ++++++
pmc.c | 7 ++++++-
2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/clock.c b/clock.c
index 02b3a0f..f5aa3c4 100644
--- a/clock.c
+++ b/clock.c
@@ -210,6 +210,12 @@ static int clock_management_get_response(struct clock *c, struct port *p,
datalen = sizeof(*mtd);
respond = 1;
break;
+ case DOMAIN:
+ mtd = (struct management_tlv_datum *) tlv->data;
+ mtd->val = c->dds.domainNumber;
+ datalen = sizeof(*mtd);
+ respond = 1;
+ break;
case TIME_STATUS_NP:
tsn = (struct time_status_np *) tlv->data;
tsn->master_offset = c->master_offset;
diff --git a/pmc.c b/pmc.c
index 169b0a6..7d56183 100644
--- a/pmc.c
+++ b/pmc.c
@@ -66,7 +66,7 @@ struct management_id idtab[] = {
{ "TIME_PROPERTIES_DATA_SET", TIME_PROPERTIES_DATA_SET, do_get_action },
{ "PRIORITY1", PRIORITY1, do_get_action },
{ "PRIORITY2", PRIORITY2, do_get_action },
- { "DOMAIN", DOMAIN, not_supported },
+ { "DOMAIN", DOMAIN, do_get_action },
{ "SLAVE_ONLY", SLAVE_ONLY, not_supported },
{ "TIME", TIME, not_supported },
{ "CLOCK_ACCURACY", CLOCK_ACCURACY, not_supported },
@@ -323,6 +323,11 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
fprintf(fp, "PRIORITY2 "
IFMT "priority2 %hhu", mtd->val);
break;
+ case DOMAIN:
+ mtd = (struct management_tlv_datum *) mgt->data;
+ fprintf(fp, "DOMAIN "
+ IFMT "domainNumber %hhu", mtd->val);
+ break;
case TIME_STATUS_NP:
tsn = (struct time_status_np *) mgt->data;
fprintf(fp, "TIME_STATUS_NP "
--
1.7.2.5
Richard Cochran
2013-03-03 19:35:08 UTC
Permalink
Signed-off-by: Richard Cochran <***@gmail.com>
---
clock.c | 6 ++++++
pmc.c | 7 ++++++-
2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/clock.c b/clock.c
index f5aa3c4..4913d02 100644
--- a/clock.c
+++ b/clock.c
@@ -216,6 +216,12 @@ static int clock_management_get_response(struct clock *c, struct port *p,
datalen = sizeof(*mtd);
respond = 1;
break;
+ case SLAVE_ONLY:
+ mtd = (struct management_tlv_datum *) tlv->data;
+ mtd->val = c->dds.flags & DDS_SLAVE_ONLY;
+ datalen = sizeof(*mtd);
+ respond = 1;
+ break;
case TIME_STATUS_NP:
tsn = (struct time_status_np *) tlv->data;
tsn->master_offset = c->master_offset;
diff --git a/pmc.c b/pmc.c
index 7d56183..cd48e19 100644
--- a/pmc.c
+++ b/pmc.c
@@ -67,7 +67,7 @@ struct management_id idtab[] = {
{ "PRIORITY1", PRIORITY1, do_get_action },
{ "PRIORITY2", PRIORITY2, do_get_action },
{ "DOMAIN", DOMAIN, do_get_action },
- { "SLAVE_ONLY", SLAVE_ONLY, not_supported },
+ { "SLAVE_ONLY", SLAVE_ONLY, do_get_action },
{ "TIME", TIME, not_supported },
{ "CLOCK_ACCURACY", CLOCK_ACCURACY, not_supported },
{ "UTC_PROPERTIES", UTC_PROPERTIES, not_supported },
@@ -328,6 +328,11 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
fprintf(fp, "DOMAIN "
IFMT "domainNumber %hhu", mtd->val);
break;
+ case SLAVE_ONLY:
+ mtd = (struct management_tlv_datum *) mgt->data;
+ fprintf(fp, "SLAVE_ONLY "
+ IFMT "slaveOnly %d", mtd->val & DDS_SLAVE_ONLY ? 1 : 0);
+ break;
case TIME_STATUS_NP:
tsn = (struct time_status_np *) mgt->data;
fprintf(fp, "TIME_STATUS_NP "
--
1.7.2.5
Richard Cochran
2013-03-03 19:35:09 UTC
Permalink
Signed-off-by: Richard Cochran <***@gmail.com>
---
clock.c | 6 ++++++
pmc.c | 7 ++++++-
2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/clock.c b/clock.c
index 4913d02..59b8703 100644
--- a/clock.c
+++ b/clock.c
@@ -222,6 +222,12 @@ static int clock_management_get_response(struct clock *c, struct port *p,
datalen = sizeof(*mtd);
respond = 1;
break;
+ case CLOCK_ACCURACY:
+ mtd = (struct management_tlv_datum *) tlv->data;
+ mtd->val = c->dds.clockQuality.clockAccuracy;
+ datalen = sizeof(*mtd);
+ respond = 1;
+ break;
case TIME_STATUS_NP:
tsn = (struct time_status_np *) tlv->data;
tsn->master_offset = c->master_offset;
diff --git a/pmc.c b/pmc.c
index cd48e19..a46f4f2 100644
--- a/pmc.c
+++ b/pmc.c
@@ -69,7 +69,7 @@ struct management_id idtab[] = {
{ "DOMAIN", DOMAIN, do_get_action },
{ "SLAVE_ONLY", SLAVE_ONLY, do_get_action },
{ "TIME", TIME, not_supported },
- { "CLOCK_ACCURACY", CLOCK_ACCURACY, not_supported },
+ { "CLOCK_ACCURACY", CLOCK_ACCURACY, do_get_action },
{ "UTC_PROPERTIES", UTC_PROPERTIES, not_supported },
{ "TRACEABILITY_PROPERTIES", TRACEABILITY_PROPERTIES, not_supported },
{ "TIMESCALE_PROPERTIES", TIMESCALE_PROPERTIES, not_supported },
@@ -333,6 +333,11 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
fprintf(fp, "SLAVE_ONLY "
IFMT "slaveOnly %d", mtd->val & DDS_SLAVE_ONLY ? 1 : 0);
break;
+ case CLOCK_ACCURACY:
+ mtd = (struct management_tlv_datum *) mgt->data;
+ fprintf(fp, "CLOCK_ACCURACY "
+ IFMT "clockAccuracy 0x%02hhx", mtd->val);
+ break;
case TIME_STATUS_NP:
tsn = (struct time_status_np *) mgt->data;
fprintf(fp, "TIME_STATUS_NP "
--
1.7.2.5
Richard Cochran
2013-03-03 19:35:10 UTC
Permalink
Signed-off-by: Richard Cochran <***@gmail.com>
---
clock.c | 6 ++++++
pmc.c | 10 +++++++++-
2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/clock.c b/clock.c
index 59b8703..bf4286c 100644
--- a/clock.c
+++ b/clock.c
@@ -228,6 +228,12 @@ static int clock_management_get_response(struct clock *c, struct port *p,
datalen = sizeof(*mtd);
respond = 1;
break;
+ case TRACEABILITY_PROPERTIES:
+ mtd = (struct management_tlv_datum *) tlv->data;
+ mtd->val = c->tds.flags & (TIME_TRACEABLE|FREQ_TRACEABLE);
+ datalen = sizeof(*mtd);
+ respond = 1;
+ break;
case TIME_STATUS_NP:
tsn = (struct time_status_np *) tlv->data;
tsn->master_offset = c->master_offset;
diff --git a/pmc.c b/pmc.c
index a46f4f2..0539fe2 100644
--- a/pmc.c
+++ b/pmc.c
@@ -71,7 +71,7 @@ struct management_id idtab[] = {
{ "TIME", TIME, not_supported },
{ "CLOCK_ACCURACY", CLOCK_ACCURACY, do_get_action },
{ "UTC_PROPERTIES", UTC_PROPERTIES, not_supported },
- { "TRACEABILITY_PROPERTIES", TRACEABILITY_PROPERTIES, not_supported },
+ { "TRACEABILITY_PROPERTIES", TRACEABILITY_PROPERTIES, do_get_action },
{ "TIMESCALE_PROPERTIES", TIMESCALE_PROPERTIES, not_supported },
{ "PATH_TRACE_LIST", PATH_TRACE_LIST, not_supported },
{ "PATH_TRACE_ENABLE", PATH_TRACE_ENABLE, not_supported },
@@ -338,6 +338,14 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
fprintf(fp, "CLOCK_ACCURACY "
IFMT "clockAccuracy 0x%02hhx", mtd->val);
break;
+ case TRACEABILITY_PROPERTIES:
+ mtd = (struct management_tlv_datum *) mgt->data;
+ fprintf(fp, "TRACEABILITY_PROPERTIES "
+ IFMT "timeTraceable %d"
+ IFMT "frequencyTraceable %d",
+ mtd->val & TIME_TRACEABLE ? 1 : 0,
+ mtd->val & FREQ_TRACEABLE ? 1 : 0);
+ break;
case TIME_STATUS_NP:
tsn = (struct time_status_np *) mgt->data;
fprintf(fp, "TIME_STATUS_NP "
--
1.7.2.5
Richard Cochran
2013-03-03 19:35:11 UTC
Permalink
Signed-off-by: Richard Cochran <***@gmail.com>
---
clock.c | 6 ++++++
pmc.c | 7 ++++++-
2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/clock.c b/clock.c
index bf4286c..96be630 100644
--- a/clock.c
+++ b/clock.c
@@ -234,6 +234,12 @@ static int clock_management_get_response(struct clock *c, struct port *p,
datalen = sizeof(*mtd);
respond = 1;
break;
+ case TIMESCALE_PROPERTIES:
+ mtd = (struct management_tlv_datum *) tlv->data;
+ mtd->val = c->tds.flags & PTP_TIMESCALE;
+ datalen = sizeof(*mtd);
+ respond = 1;
+ break;
case TIME_STATUS_NP:
tsn = (struct time_status_np *) tlv->data;
tsn->master_offset = c->master_offset;
diff --git a/pmc.c b/pmc.c
index 0539fe2..e8e0510 100644
--- a/pmc.c
+++ b/pmc.c
@@ -72,7 +72,7 @@ struct management_id idtab[] = {
{ "CLOCK_ACCURACY", CLOCK_ACCURACY, do_get_action },
{ "UTC_PROPERTIES", UTC_PROPERTIES, not_supported },
{ "TRACEABILITY_PROPERTIES", TRACEABILITY_PROPERTIES, do_get_action },
- { "TIMESCALE_PROPERTIES", TIMESCALE_PROPERTIES, not_supported },
+ { "TIMESCALE_PROPERTIES", TIMESCALE_PROPERTIES, do_get_action },
{ "PATH_TRACE_LIST", PATH_TRACE_LIST, not_supported },
{ "PATH_TRACE_ENABLE", PATH_TRACE_ENABLE, not_supported },
{ "GRANDMASTER_CLUSTER_TABLE", GRANDMASTER_CLUSTER_TABLE, not_supported },
@@ -346,6 +346,11 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
mtd->val & TIME_TRACEABLE ? 1 : 0,
mtd->val & FREQ_TRACEABLE ? 1 : 0);
break;
+ case TIMESCALE_PROPERTIES:
+ mtd = (struct management_tlv_datum *) mgt->data;
+ fprintf(fp, "TIMESCALE_PROPERTIES "
+ IFMT "ptpTimescale %d", mtd->val & PTP_TIMESCALE ? 1 : 0);
+ break;
case TIME_STATUS_NP:
tsn = (struct time_status_np *) mgt->data;
fprintf(fp, "TIME_STATUS_NP "
--
1.7.2.5
Richard Cochran
2013-03-03 20:02:15 UTC
Permalink
Post by Richard Cochran
Warning: compile tested only.
So now I did give this a test, and it looks okay, so far.

Thanks,
Richard

Loading...