On Tue, Feb 15, 2022 at 10:55:45AM -0800, Alexander Bulimov via Linuxptp-devel
wrote:
> 4857dd.fffe.0e91da-1 seq 0 RESPONSE MANAGEMENT
> MID_UNICAST_MASTER_TABLE_NP
> actualTableSize 9
> BM identity address
> state clockClass clockQuality offsetScaledLogVariance p1 p2
> no b8cef6.fffe.7349d4-1 2401:db00:2515:f001:face:0:2a3:0
> HAVE_ANN 6 0x21 0x59e0 128 128
> yes b8cef6.fffe.0210e4-1 2401:db00:2515:f001:face:0:3d1:0
> HAVE_SYDY 6 0x21 0x59e0 128 128
> no b8cef6.fffe.057e20-1 2401:db00:2515:f001:face:0:3fa:0
> HAVE_ANN 6 0x21 0x59e0 128 128
> no b8cef6.fffe.7349dc-1 2401:db00:2515:f001:face:0:da:0
> HAVE_ANN 6 0x21 0x59e0 128 128
> no ffffff.ffff.ffffff-65535 2401:db00:2515:f002:face:0:11b:0
> WAIT 0 0x00 0x0000 0 0
> no b8cef6.fffe.7349c4-1 2401:db00:2515:f002:face:0:1ec:0
> HAVE_ANN 6 0x21 0x59e0 128 128
> no ffffff.ffff.ffffff-65535 2401:db00:2515:f002:face:0:94:0
> WAIT 0 0x00 0x0000 0 0
> no ffffff.ffff.ffffff-65535 192.168.0.1
> WAIT 0 0x00 0x0000 0 0
> no b8cef6.fffe.7349c8-1 2401:db00:2515:f002:face:0:b7:0
> HAVE_ANN 6 0x21 0x59e0 128 128
>
> I realize that this is can be controversial
> (for one, no other PMC command provides table-like output),
> so I'm happy to hear your suggestion.
This looks okay to me as it is both human readable and fairly easy to
parse with a script.
> diff --git a/ddt.h b/ddt.h
> index ef30f73..7a95344 100644
> --- a/ddt.h
> +++ b/ddt.h
> @@ -120,4 +120,14 @@ struct PortServiceStats {
> uint64_t followup_mismatch;
> };
>
> +struct UnicastMasterEntry {
Please use lower case + underscore for custom code. See
CODING_STYLE.org for rationale.
> + uint8_t selected;
> + Enumeration8 portState;
> + struct PortIdentity portIdentity;
> + struct ClockQuality clockQuality;
> + UInteger8 priority1;
> + UInteger8 priority2;
> + struct PortAddress address;
> +} PACKED;
> +
> #endif
> diff --git a/pmc.c b/pmc.c
> index 2e5e93e..577e479 100644
> --- a/pmc.c
> +++ b/pmc.c
> @@ -88,6 +88,24 @@ static void pmc_show_rx_sync_timing(struct
> slave_rx_sync_timing_record *record,
> SHOW_TIMESTAMP(record->syncEventIngressTimestamp));
> }
>
> +
> +static void pmc_show_unicast_master_entry(struct UnicastMasterEntry *entry,
> + FILE *fp)
> +{
> + fprintf(fp,
> + IFMT "%s %-24s %-34s %-9s %-10hhu 0x%02hhx 0x%04hx
> %-3hhu %-3hhu",
> + entry->selected ? "yes" : "no ",
> + pid2str(&entry->portIdentity),
> + portaddr2str(&entry->address),
> + ustate2str(entry->portState),
> + entry->clockQuality.clockClass,
> + entry->clockQuality.clockAccuracy,
> + entry->clockQuality.offsetScaledLogVariance,
> + entry->priority1,
> + entry->priority2
> + );
> +}
> +
> static void pmc_show_signaling(struct ptp_message *msg, FILE *fp)
> {
> struct slave_rx_sync_timing_record *sync_record;
> @@ -149,6 +167,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
> struct time_status_np *tsn;
> struct port_stats_np *pcp;
> struct port_service_stats_np *pssp;
> + struct unicast_master_table_np *umtn;
Please form reverse Christmas tree, and move pssp up as well.
> struct tlv_extra *extra;
> struct port_ds_np *pnp;
> struct defaultDS *dds;
> @@ -157,6 +176,9 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
> struct portDS *p;
> struct TLV *tlv;
> int action;
> + uint8_t *buf;
> +
> + struct UnicastMasterEntry *ume;
ditto
> diff --git a/pmc_common.c b/pmc_common.c
> index b691bbb..4ed781f 100644
> --- a/pmc_common.c
> +++ b/pmc_common.c
> @@ -124,6 +124,7 @@ struct management_id idtab[] = {
> { "UNICAST_NEGOTIATION_ENABLE", MID_UNICAST_NEGOTIATION_ENABLE,
> not_supported },
> { "UNICAST_MASTER_TABLE", MID_UNICAST_MASTER_TABLE, not_supported },
> { "UNICAST_MASTER_MAX_TABLE_SIZE", MID_UNICAST_MASTER_MAX_TABLE_SIZE,
> not_supported },
> + { "UNICAST_MASTER_TABLE_NP", MID_UNICAST_MASTER_TABLE_NP, do_get_action
> },
This is list in numerical order, so place MID_UNICAST_MASTER_TABLE_NP
0xC008 after MID_PORT_SERVICE_STATS_NP 0xC007.
While you are at it, can you fix the order of
{ "PORT_DATA_SET_NP", MID_PORT_DATA_SET_NP, do_set_action },
{ "PORT_STATS_NP", MID_PORT_STATS_NP, do_get_action },
{ "PORT_SERVICE_STATS_NP", MID_PORT_SERVICE_STATS_NP, do_get_action },
{ "PORT_PROPERTIES_NP", MID_PORT_PROPERTIES_NP, do_get_action },
please?
> @@ -799,6 +800,7 @@ static int port_management_fill_response(struct port
> *target,
> struct port_properties_np *ppn;
> struct port_stats_np *psn;
> struct port_service_stats_np *pssn;
> + struct unicast_master_table_np *umtn;
ditto
> struct management_tlv *tlv;
> struct port_ds_np *pdsnp;
> struct tlv_extra *extra;
> @@ -807,6 +809,10 @@ static int port_management_fill_response(struct port
> *target,
> uint16_t u16;
> uint8_t *buf;
> int datalen;
> + struct unicast_master_address *ucma;
> + struct UnicastMasterEntry *ume;
> + struct PortIdentity pid;
> + struct foreign_clock *fc;
ditto
>
> extra = tlv_extra_alloc();
> if (!extra) {
> diff --git a/tlv.c b/tlv.c
> index df516be..f5420f7 100644
> --- a/tlv.c
> +++ b/tlv.c
> @@ -127,6 +127,8 @@ static int mgt_post_recv(struct management_tlv *m,
> uint16_t data_len,
> struct defaultDS *dds;
> struct parentDS *pds;
> struct portDS *p;
> + struct unicast_master_table_np *umtn;
> + struct UnicastMasterEntry *ume;
ditto
> uint8_t *buf;
> uint16_t u16;
> @@ -396,7 +426,10 @@ static void mgt_pre_send(struct management_tlv *m,
> struct tlv_extra *extra)
> struct currentDS *cds;
> struct parentDS *pds;
> struct portDS *p;
> + struct unicast_master_table_np *umtn;
> + struct UnicastMasterEntry *ume;
> int i;
> + uint8_t *buf;
ditto
> @@ -355,6 +356,11 @@ struct port_service_stats_np {
> struct PortServiceStats stats;
> } PACKED;
>
> +struct unicast_master_table_np {
> + uint16_t actualTableSize;
lowercase + underscore
> + struct UnicastMasterEntry unicast_masters[0];
> +} PACKED;
> +
> #define PROFILE_ID_LEN 6
>
> struct mgmt_clock_description {
Thanks,
Richard
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel