adding TLV support for MID_PORT_PTSF_DATA_NP
Signed-off-by: Greg Armstrong <[email protected]>
Signed-off-by: Leon Goldin <[email protected]>
Signed-off-by: Devasish Dey <[email protected]>
Signed-off-by: Vipin Sharma <[email protected]>
---
pmc.c | 16 ++++++++++++++++
pmc_common.c | 1 +
port.c | 8 ++++++++
tlv.c | 11 +++++++++++
tlv.h | 5 +++++
5 files changed, 41 insertions(+)
diff --git a/pmc.c b/pmc.c
index cdc76c8..34c9609 100644
--- a/pmc.c
+++ b/pmc.c
@@ -176,6 +176,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
struct currentDS *cds;
struct parentDS *pds;
struct portDS *p;
+ struct port_ptsf_data_np *ptsf_data;
struct TLV *tlv;
uint8_t *buf;
int action;
@@ -607,6 +608,21 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
fprintf(fp, "LOG_MIN_PDELAY_REQ_INTERVAL "
IFMT "logMinPdelayReqInterval %hhd", mtd->val);
break;
+ case MID_PORT_PTSF_DATA_NP:
+ ptsf_data = (struct port_ptsf_data_np *) mgt->data;
+ fprintf(fp, "PORT_PTSF_DATA_NP "
+ IFMT "signalFail %hu"
+ IFMT "PTSF.lossSync %d"
+ IFMT "PTSF.syncMsgLoss %d"
+ IFMT "PTSF.delayRespMsgLoss %d"
+ IFMT "PTSF.unusable %d",
+ ptsf_data->signalFail ? 1 : 0,
+ ((ptsf_data->signalFail & PDS_PTSF_LOSS_SYNC) |
+ (ptsf_data->signalFail & PDS_PTSF_LOSS_DELAY_RESP)) ?
1 : 0,
+ ptsf_data->signalFail & PDS_PTSF_LOSS_SYNC ? 1 : 0,
+ ptsf_data->signalFail & PDS_PTSF_LOSS_DELAY_RESP ? 1 :
0,
+ ptsf_data->signalFail & PDS_PTSF_UNUSABLE ? 1 : 0);
+ break;
}
out:
fprintf(fp, "\n");
diff --git a/pmc_common.c b/pmc_common.c
index 1dd89f6..9570841 100644
--- a/pmc_common.c
+++ b/pmc_common.c
@@ -154,6 +154,7 @@ struct management_id idtab[] = {
{ "PORT_SERVICE_STATS_NP", MID_PORT_SERVICE_STATS_NP, do_get_action },
{ "UNICAST_MASTER_TABLE_NP", MID_UNICAST_MASTER_TABLE_NP, do_get_action
},
{ "PORT_HWCLOCK_NP", MID_PORT_HWCLOCK_NP, do_get_action },
+ { "PORT_PTSF_DATA_NP", MID_PORT_PTSF_DATA_NP, do_get_action },
};
static void do_get_action(struct pmc *pmc, int action, int index, char *str)
diff --git a/port.c b/port.c
index 8075896..ff00e46 100644
--- a/port.c
+++ b/port.c
@@ -852,6 +852,7 @@ static int port_management_fill_response(struct port
*target,
struct PortIdentity pid;
const char *ts_label;
struct portDS *pds;
+ struct port_ptsf_data_np *ptsf_data;
uint16_t u16;
uint8_t *buf;
int datalen;
@@ -1074,6 +1075,12 @@ static int port_management_fill_response(struct port
*target,
PORT_HWCLOCK_VCLOCK : 0;
datalen = sizeof(*phn);
break;
+ case MID_PORT_PTSF_DATA_NP:
+ ptsf_data = (struct port_ptsf_data_np *)tlv->data;
+ ptsf_data->portIdentity = target->portIdentity;
+ ptsf_data->signalFail = target->signalFail;
+ datalen = sizeof(*ptsf_data);
+ break;
default:
/* The caller should *not* respond to this message. */
tlv_extra_recycle(extra);
@@ -1118,6 +1125,7 @@ static int port_management_set(struct port *target,
int respond = 0;
struct management_tlv *tlv;
struct port_ds_np *pdsnp;
+
tlv = (struct management_tlv *) req->management.suffix;
switch (id) {
diff --git a/tlv.c b/tlv.c
index 1c13460..745c96a 100644
--- a/tlv.c
+++ b/tlv.c
@@ -130,6 +130,7 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t
data_len,
struct defaultDS *dds;
struct parentDS *pds;
struct portDS *p;
+ struct port_ptsf_data_np *ptsf_data;
uint8_t *buf;
uint16_t u16;
@@ -407,6 +408,10 @@ static int mgt_post_recv(struct management_tlv *m,
uint16_t data_len,
if (data_len != 0)
goto bad_length;
break;
+ case MID_PORT_PTSF_DATA_NP:
+ ptsf_data = (struct port_ptsf_data_np *) m->data;
+ ptsf_data->portIdentity.portNumber =
ntohs(ptsf_data->portIdentity.portNumber);
+ break;
}
if (extra_len) {
if (extra_len % 2)
@@ -437,6 +442,7 @@ static void mgt_pre_send(struct management_tlv *m, struct
tlv_extra *extra)
struct currentDS *cds;
struct parentDS *pds;
struct portDS *p;
+ struct port_ptsf_data_np *ptsf_data;
uint8_t *buf;
int i;
@@ -569,6 +575,11 @@ static void mgt_pre_send(struct management_tlv *m, struct
tlv_extra *extra)
phn->portIdentity.portNumber =
htons(phn->portIdentity.portNumber);
phn->phc_index = htonl(phn->phc_index);
break;
+ case MID_PORT_PTSF_DATA_NP:
+ ptsf_data = (struct port_ptsf_data_np *) m->data;
+ ptsf_data->portIdentity.portNumber =
+ htons(ptsf_data->portIdentity.portNumber);
+ break;
}
}
diff --git a/tlv.h b/tlv.h
index 8966696..c29f5f2 100644
--- a/tlv.h
+++ b/tlv.h
@@ -128,6 +128,7 @@ enum management_action {
#define MID_PORT_SERVICE_STATS_NP 0xC007
#define MID_UNICAST_MASTER_TABLE_NP 0xC008
#define MID_PORT_HWCLOCK_NP 0xC009
+#define MID_PORT_PTSF_DATA_NP 0xC00A
/* Management error ID values */
#define MID_RESPONSE_TOO_BIG 0x0001
@@ -367,6 +368,10 @@ struct port_service_stats_np {
struct PortServiceStats stats;
} PACKED;
+struct port_ptsf_data_np {
+ struct PortIdentity portIdentity;
+ UInteger8 signalFail;
+} PACKED;
struct unicast_master_table_np {
uint16_t actual_table_size;
struct unicast_master_entry unicast_masters[0];
--
2.25.1
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel