[Linuxptp-devel] [PATCH 2/5] pmc: Move private macros back into their source files.
The header file, pmc_common.h, makes some private macros public. The intent was to use those macros in SNMP code, but that development never materialized into production code. This patch removes the private macros from public view. Signed-off-by: Richard Cochran --- pmc.c| 1 + pmc_common.c | 5 + pmc_common.h | 6 -- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pmc.c b/pmc.c index 4e6043b..e3cd6f3 100644 --- a/pmc.c +++ b/pmc.c @@ -38,6 +38,7 @@ static struct pmc *pmc; #define IFMT "\n\t\t" +#define P41 ((double)(1ULL << 41)) static char *text2str(struct PTPText *text) { diff --git a/pmc_common.c b/pmc_common.c index 3aab4b9..92daf20 100644 --- a/pmc_common.c +++ b/pmc_common.c @@ -27,6 +27,11 @@ #include "util.h" #include "pmc_common.h" +#define BAD_ACTION -1 +#define BAD_ID -1 +#define AMBIGUOUS_ID -2 +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + /* Field Len Type diff --git a/pmc_common.h b/pmc_common.h index b1fdcd6..9fa72de 100644 --- a/pmc_common.h +++ b/pmc_common.h @@ -25,12 +25,6 @@ #include "msg.h" #include "transport.h" -#define BAD_ACTION -1 -#define BAD_ID -1 -#define AMBIGUOUS_ID -2 -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#define P41 ((double)(1ULL << 41)) - struct pmc; struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type, -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH 5/5] pmc: Allow multiple local subscribers.
If more than one local UDS client subscribes to push notifications, only the last one receives data from the ptp4l service. This happens because ptp4l uses the PortIdentity as a unique key to track client subscriptions. As a result, it is not possible for both phc2sys and pmc to receive push notifications at the same time, for example. This patch sets the PortIdentity.portNumber attribute of UDS clients to the local process ID, making each such client subscription unique. Signed-off-by: Richard Cochran --- pmc_common.c | 19 --- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pmc_common.c b/pmc_common.c index f89d87c..822dd6d 100644 --- a/pmc_common.c +++ b/pmc_common.c @@ -18,8 +18,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include -#include #include +#include +#include +#include #include "notification.h" #include "print.h" @@ -353,13 +355,16 @@ struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type, if (!pmc) return NULL; - if (transport_type != TRANS_UDS && - generate_clock_identity(&pmc->port_identity.clockIdentity, - iface_name)) { - pr_err("failed to generate a clock identity"); - goto failed; + if (transport_type == TRANS_UDS) { + pmc->port_identity.portNumber = getpid(); + } else { + if (generate_clock_identity(&pmc->port_identity.clockIdentity, + iface_name)) { + pr_err("failed to generate a clock identity"); + goto failed; + } + pmc->port_identity.portNumber = 1; } - pmc->port_identity.portNumber = 1; pmc_target_all(pmc); pmc->boundary_hops = boundary_hops; -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH 1/5] clock: Reply with correct payload length for SUBSCRIBE_EVENTS_NP queries.
The clock layer indeed replies to management GET actions for this item, but it sends an empty management message by mistake. This patch fixes the issue by replying with a payload of the correct length. While we are at it, correct overly zealous line breaking according to our coding style. Signed-off-by: Richard Cochran --- clock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clock.c b/clock.c index 6f9cc21..b928f56 100644 --- a/clock.c +++ b/clock.c @@ -442,6 +442,7 @@ static int clock_management_fill_response(struct clock *c, struct port *p, } sen = (struct subscribe_events_np *)tlv->data; clock_get_subscription(c, req, sen->bitmask, &sen->duration); + datalen = sizeof(*sen); break; default: /* The caller should *not* respond to this message. */ @@ -513,8 +514,7 @@ static int clock_management_set(struct clock *c, struct port *p, break; case TLV_SUBSCRIBE_EVENTS_NP: sen = (struct subscribe_events_np *)tlv->data; - clock_update_subscription(c, req, sen->bitmask, - sen->duration); + clock_update_subscription(c, req, sen->bitmask, sen->duration); respond = 1; break; } -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH 4/5] pmc: Subscribe to port state push notification events when requested.
Allow interactive input like set SUBSCRIBE_EVENTS_NP duration 60 NOTIFY_PORT_STATE on to request push notifications from the ptp4l service. Signed-off-by: Richard Cochran --- pmc_common.c | 25 ++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/pmc_common.c b/pmc_common.c index 92daf20..f89d87c 100644 --- a/pmc_common.c +++ b/pmc_common.c @@ -21,6 +21,7 @@ #include #include +#include "notification.h" #include "print.h" #include "tlv.h" #include "transport.h" @@ -106,6 +107,7 @@ struct management_id idtab[] = { { "PRIMARY_DOMAIN", TLV_PRIMARY_DOMAIN, not_supported }, { "TIME_STATUS_NP", TLV_TIME_STATUS_NP, do_get_action }, { "GRANDMASTER_SETTINGS_NP", TLV_GRANDMASTER_SETTINGS_NP, do_set_action }, + { "SUBSCRIBE_EVENTS_NP", TLV_SUBSCRIBE_EVENTS_NP, do_set_action }, /* Port management ID values */ { "NULL_MANAGEMENT", TLV_NULL_MANAGEMENT, null_management }, { "CLOCK_DESCRIPTION", TLV_CLOCK_DESCRIPTION, do_get_action }, @@ -139,12 +141,13 @@ static void do_get_action(struct pmc *pmc, int action, int index, char *str) static void do_set_action(struct pmc *pmc, int action, int index, char *str) { + int cnt, code = idtab[index].code, freq_traceable, leap_59, leap_61, + ptp_timescale, time_traceable, utc_off_valid; struct grandmaster_settings_np gsn; struct management_tlv_datum mtd; + struct subscribe_events_np sen; struct port_ds_np pnp; - int cnt, code = idtab[index].code; - int leap_61, leap_59, utc_off_valid; - int ptp_timescale, time_traceable, freq_traceable; + char onoff[4] = {0}; switch (action) { case GET: @@ -215,6 +218,22 @@ static void do_set_action(struct pmc *pmc, int action, int index, char *str) gsn.time_flags |= FREQ_TRACEABLE; pmc_send_set_action(pmc, code, &gsn, sizeof(gsn)); break; + case TLV_SUBSCRIBE_EVENTS_NP: + memset(&sen, 0, sizeof(sen)); + cnt = sscanf(str, " %*s %*s " +"duration %hu " +"NOTIFY_PORT_STATE %3s ", +&sen.duration, onoff); + if (cnt != 2) { + fprintf(stderr, "%s SET needs 2 values\n", + idtab[index].name); + break; + } + if (!strcasecmp(onoff, "on")) { + sen.bitmask[0] = 1 << NOTIFY_PORT_STATE; + } + pmc_send_set_action(pmc, code, &sen, sizeof(sen)); + break; case TLV_PORT_DATA_SET_NP: cnt = sscanf(str, " %*s %*s " "neighborPropDelayThresh %u " -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH 3/5] pmc: Allow printing of the SUBSCRIBE_EVENTS_NP tlv.
While we are at it, reformat the pmc_show() function into reverse Christmas tree order. Signed-off-by: Richard Cochran --- pmc.c | 32 +--- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/pmc.c b/pmc.c index e3cd6f3..f074621 100644 --- a/pmc.c +++ b/pmc.c @@ -28,6 +28,7 @@ #include "ds.h" #include "fsm.h" +#include "notification.h" #include "pmc_common.h" #include "print.h" #include "tlv.h" @@ -56,22 +57,23 @@ static char *bin2str(Octet *data, int len) static void pmc_show(struct ptp_message *msg, FILE *fp) { - int action; - struct TLV *tlv; - struct management_tlv *mgt; + struct grandmaster_settings_np *gsn; + struct mgmt_clock_description *cd; + struct subscribe_events_np *sen; struct management_tlv_datum *mtd; - struct defaultDS *dds; - struct currentDS *cds; - struct parentDS *pds; + struct port_properties_np *ppn; struct timePropertiesDS *tp; + struct management_tlv *mgt; struct time_status_np *tsn; - struct grandmaster_settings_np *gsn; - struct mgmt_clock_description *cd; + struct port_stats_np *pcp; struct tlv_extra *extra; - struct portDS *p; struct port_ds_np *pnp; - struct port_properties_np *ppn; - struct port_stats_np *pcp; + struct defaultDS *dds; + struct currentDS *cds; + struct parentDS *pds; + struct portDS *p; + struct TLV *tlv; + int action; if (msg_type(msg) != MANAGEMENT) { return; @@ -295,6 +297,14 @@ static void pmc_show(struct ptp_message *msg, FILE *fp) gsn->time_flags & FREQ_TRACEABLE ? 1 : 0, gsn->time_source); break; + case TLV_SUBSCRIBE_EVENTS_NP: + sen = (struct subscribe_events_np *) mgt->data; + fprintf(fp, "SUBSCRIBE_EVENTS_NP " + IFMT "duration %hu" + IFMT "NOTIFY_PORT_STATE %s", + sen->duration, + (sen->bitmask[0] & 1 << NOTIFY_PORT_STATE) ? "on" : "off"); + break; case TLV_PORT_DATA_SET: p = (struct portDS *) mgt->data; if (p->portState > PS_SLAVE) { -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH 0/5] Push notification support for pmc
This series enables the PTP Management Client (pmc) program to receive push notifications. An example interactive session looks like this. set SUBSCRIBE_EVENTS_NP duration 600 NOTIFY_PORT_STATE on sending: SET SUBSCRIBE_EVENTS_NP a0369f.fffe.1c386c-0 seq 0 RESPONSE MANAGEMENT SUBSCRIBE_EVENTS_NP duration 600 NOTIFY_PORT_STATE on a0369f.fffe.1c386c-1 seq 0 RESPONSE MANAGEMENT PORT_DATA_SET portIdentitya0369f.fffe.1c386c-1 portState LISTENING logMinDelayReqInterval 0 peerMeanPathDelay 0 logAnnounceInterval 1 announceReceiptTimeout 3 logSyncInterval 0 delayMechanism 1 logMinPdelayReqInterval 0 versionNumber 2 a0369f.fffe.1c386c-1 seq 1 RESPONSE MANAGEMENT PORT_DATA_SET portIdentitya0369f.fffe.1c386c-1 portState MASTER logMinDelayReqInterval 0 peerMeanPathDelay 0 logAnnounceInterval 1 announceReceiptTimeout 3 logSyncInterval 0 delayMechanism 1 logMinPdelayReqInterval 0 versionNumber 2 ... Richard Cochran (5): clock: Reply with correct payload length for SUBSCRIBE_EVENTS_NP queries. pmc: Move private macros back into their source files. pmc: Allow printing of the SUBSCRIBE_EVENTS_NP tlv. pmc: Subscribe to port state push notification events when requested. pmc: Allow multiple local subscribers. clock.c | 4 ++-- pmc.c| 33 ++--- pmc_common.c | 49 +++-- pmc_common.h | 6 -- 4 files changed, 63 insertions(+), 29 deletions(-) -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
Re: [Linuxptp-devel] [PATCH 5/5] pmc: Allow multiple local subscribers.
> -Original Message- > From: Richard Cochran > Sent: Friday, April 03, 2020 7:30 AM > To: linuxptp-devel@lists.sourceforge.net > Subject: [Linuxptp-devel] [PATCH 5/5] pmc: Allow multiple local subscribers. > > If more than one local UDS client subscribes to push notifications, > only the last one receives data from the ptp4l service. This happens > because ptp4l uses the PortIdentity as a unique key to track client > subscriptions. As a result, it is not possible for both phc2sys and > pmc to receive push notifications at the same time, for example. > > This patch sets the PortIdentity.portNumber attribute of UDS clients > to the local process ID, making each such client subscription unique. > > Signed-off-by: Richard Cochran > --- > pmc_common.c | 19 --- > 1 file changed, 12 insertions(+), 7 deletions(-) > > diff --git a/pmc_common.c b/pmc_common.c > index f89d87c..822dd6d 100644 > --- a/pmc_common.c > +++ b/pmc_common.c > @@ -18,8 +18,10 @@ > * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > */ > #include > -#include > #include > +#include > +#include > +#include > > #include "notification.h" > #include "print.h" > @@ -353,13 +355,16 @@ struct pmc *pmc_create(struct config *cfg, enum > transport_type transport_type, > if (!pmc) > return NULL; > > - if (transport_type != TRANS_UDS && > - generate_clock_identity(&pmc->port_identity.clockIdentity, > - iface_name)) { > - pr_err("failed to generate a clock identity"); > - goto failed; > + if (transport_type == TRANS_UDS) { > + pmc->port_identity.portNumber = getpid(); > + } else { > + if (generate_clock_identity(&pmc->port_identity.clockIdentity, > + iface_name)) { > + pr_err("failed to generate a clock identity"); > + goto failed; > + } > + pmc->port_identity.portNumber = 1; Ah, so previously we always set them to 1, but now we use the pid for local UDS, and a clock identity for remote ones. Nice > } > - pmc->port_identity.portNumber = 1; > pmc_target_all(pmc); > > pmc->boundary_hops = boundary_hops; > -- > 2.20.1 > > > > ___ > Linuxptp-devel mailing list > Linuxptp-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linuxptp-devel ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel