Discussion:
[Linuxptp-devel] [PATCH] pmc: support getting the port properties np.
Mykola Zhuravel
2017-07-17 14:22:29 UTC
Permalink
Signed-off-by: Mykola Zhuravel <***@mellanox.com>
---
pmc.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/pmc.c b/pmc.c
index af9cc63..0faa770 100644
--- a/pmc.c
+++ b/pmc.c
@@ -107,6 +107,7 @@ struct management_id idtab[] = {
{ "DELAY_MECHANISM", TLV_DELAY_MECHANISM, do_get_action },
{ "LOG_MIN_PDELAY_REQ_INTERVAL", TLV_LOG_MIN_PDELAY_REQ_INTERVAL, do_get_action },
{ "PORT_DATA_SET_NP", TLV_PORT_DATA_SET_NP, do_set_action },
+ { "PORT_PROPERTIES_NP", TLV_PORT_PROPERTIES_NP, do_get_action },
};

static const char *action_string[] = {
@@ -196,6 +197,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
struct mgmt_clock_description *cd;
struct portDS *p;
struct port_ds_np *pnp;
+ struct port_properties_np *ppnp;
if (msg_type(msg) != MANAGEMENT) {
return;
}
@@ -477,6 +479,19 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
fprintf(fp, "LOG_MIN_PDELAY_REQ_INTERVAL "
IFMT "logMinPdelayReqInterval %hhd", mtd->val);
break;
+ case TLV_PORT_PROPERTIES_NP:
+ ppnp = (struct port_properties_np *) mgt->data;
+ if (ppnp->port_state > PS_SLAVE) {
+ ppnp->port_state = 0;
+ }
+ fprintf(fp, "PORT_PROPERTIES_NP "
+ IFMT "portIdentity %s"
+ IFMT "portState %s"
+ IFMT "timestamping %hhu"
+ IFMT "interface %s",
+ pid2str(&ppnp->portIdentity), ps_str[ppnp->port_state],
+ ppnp->timestamping, text2str(&ppnp->interface));
+ break;
}
out:
fprintf(fp, "\n");
--
2.8.4
Richard Cochran
2017-07-18 09:16:41 UTC
Permalink
Post by Mykola Zhuravel
+ ppnp = (struct port_properties_np *) mgt->data;
+ if (ppnp->port_state > PS_SLAVE) {
+ ppnp->port_state = 0;
+ }
+ fprintf(fp, "PORT_PROPERTIES_NP "
+ IFMT "portIdentity %s"
+ IFMT "portState %s"
+ IFMT "timestamping %hhu"
This patch is okay as far as it goes, but can't we have a human
readable string here?
Post by Mykola Zhuravel
+ IFMT "interface %s",
+ pid2str(&ppnp->portIdentity), ps_str[ppnp->port_state],
+ ppnp->timestamping, text2str(&ppnp->interface));
+ break;
Thanks,
Richard
Richard Cochran
2017-07-18 12:55:11 UTC
Permalink
Will printout below be a good example?
sending: GET PORT_PROPERTIES_NP
e41d2d.fffe.446581-1 seq 0 RESPONSE MANAGEMENT PORT_PROPERTIES_NP
Port Identity: e41d2d.fffe.446581-1
Port State: MASTER
Time Stamping: 1
Interface: eth11.0
The time stamping field originates from an enumerated type. You can
let the pmc program print the corresponding human readable string:

Port Identity: e41d2d.fffe.446581-1
Port State: MASTER
Time Stamping: hardware
Interface: eth11.0

Thanks,
Richard
Mykola Zhuravel
2017-07-18 15:20:16 UTC
Permalink
Signed-off-by: Mykola Zhuravel <***@mellanox.com>
---
pmc.c | 15 +++++++++++++++
util.c | 7 +++++++
util.h | 5 +++++
3 files changed, 27 insertions(+)

diff --git a/pmc.c b/pmc.c
index af9cc63..a991880 100644
--- a/pmc.c
+++ b/pmc.c
@@ -107,6 +107,7 @@ struct management_id idtab[] = {
{ "DELAY_MECHANISM", TLV_DELAY_MECHANISM, do_get_action },
{ "LOG_MIN_PDELAY_REQ_INTERVAL", TLV_LOG_MIN_PDELAY_REQ_INTERVAL, do_get_action },
{ "PORT_DATA_SET_NP", TLV_PORT_DATA_SET_NP, do_set_action },
+ { "PORT_PROPERTIES_NP", TLV_PORT_PROPERTIES_NP, do_get_action },
};

static const char *action_string[] = {
@@ -196,6 +197,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
struct mgmt_clock_description *cd;
struct portDS *p;
struct port_ds_np *pnp;
+ struct port_properties_np *ppnp;
if (msg_type(msg) != MANAGEMENT) {
return;
}
@@ -477,6 +479,19 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
fprintf(fp, "LOG_MIN_PDELAY_REQ_INTERVAL "
IFMT "logMinPdelayReqInterval %hhd", mtd->val);
break;
+ case TLV_PORT_PROPERTIES_NP:
+ ppnp = (struct port_properties_np *) mgt->data;
+ if (ppnp->port_state > PS_SLAVE) {
+ ppnp->port_state = 0;
+ }
+ fprintf(fp, "PORT_PROPERTIES_NP "
+ IFMT "portIdentity %s"
+ IFMT "portState %s"
+ IFMT "timestamping %s"
+ IFMT "interface %s",
+ pid2str(&ppnp->portIdentity), ps_str[ppnp->port_state],
+ ts_str[ppnp->timestamping], text2str(&ppnp->interface));
+ break;
}
out:
fprintf(fp, "\n");
diff --git a/util.c b/util.c
index 2b880ff..5f439fd 100644
--- a/util.c
+++ b/util.c
@@ -34,6 +34,13 @@

static int running = 1;

+const char *ts_str[] = {
+ "SOFTWARE",
+ "HARDWARE",
+ "LEGACY HARDWARE",
+ "ONESTEP",
+};
+
const char *ps_str[] = {
"NONE",
"INITIALIZING",
diff --git a/util.h b/util.h
index 0c1a357..9b41d89 100644
--- a/util.h
+++ b/util.h
@@ -26,6 +26,11 @@
#include "ether.h"

/**
+ * Table of human readable strings, one for each type of time stamp.
+ */
+extern const char *ts_str[];
+
+/**
* Table of human readable strings, one for each port state.
*/
extern const char *ps_str[];
--
2.8.4

-----Original Message-----
From: Richard Cochran [mailto:***@gmail.com]
Sent: Tuesday, July 18, 2017 3:55 PM
To: Mykola Zhuravel <***@mellanox.com>
Cc: linuxptp-***@lists.sourceforge.net; Eilon Greenstein <***@mellanox.com>; Amit Nishry <***@mellanox.com>
Subject: Re: [Linuxptp-devel] [PATCH] pmc: support getting the port properties np.
Will printout below be a good example?
sending: GET PORT_PROPERTIES_NP
e41d2d.fffe.446581-1 seq 0 RESPONSE MANAGEMENT PORT_PROPERTIES_NP
Port Identity: e41d2d.fffe.446581-1
Port State: MASTER
Time Stamping: 1
Interface: eth11.0
The time stamping field originates from an enumerated type. You can let the pmc program print the corresponding human readable string:

Port Identity: e41d2d.fffe.446581-1
Port State: MASTER
Time Stamping: hardware
Interface: eth11.0

Thanks,
Richard
Loading...