06c396fbe3
The issue reported is a particular case of a BC configured with redundant PTP clocks with same priority. When a clock recovers from a failure, as both clock were configured with same priority it's expected the active clock source to remain active. But if the recovered clock presented a better local clock class than active, it was being selected active. This specific case was fixed. Closes-bug: 2084723 Test plan: BC with same priority PASS: Start the PTP service with all clocks out of requirements, one is selected, no matter which one. PASS: Then, when the backup clock recovers from failure it is selected active. PASS: Then, when the other clock recovers from failure it remains as backup, no matter the local clock class. PASS: Then, when the active goes out of requirement, the backup is set active. Test plan: GM with same priority PASS: Start the PTP service with all clocks out of requirements, one is selected, no matter which one. PASS: Then, when the backup clock recovers from failure it is selected active. PASS: Then, when the other clock recovers from failure it remains as backup, no matter the local clock class. PASS: Then, when the active goes out of requirement, the backup is set active. Change-Id: Id2568bc8bbaad4cbf15070314f7904d3c3bbd53d Signed-off-by: Andre Mauricio Zelak <andre.zelak@windriver.com>
129 lines
3.8 KiB
Diff
129 lines
3.8 KiB
Diff
From: Andre Mauricio Zelak <andre.zelak@windriver.com>
|
|
Date: Mon, 12 Jun 2023 14:59:57 -0300
|
|
Subject: [PATCH 18/61] Find a better home for the management TLV data helper
|
|
function.
|
|
|
|
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
|
|
|
|
[commit 5dd47c873cae8e0a2815b43c1ef3a86b9aca9dac upstream]
|
|
Signed-off-by: Andre Mauricio Zelak <andre.zelak@windriver.com>
|
|
---
|
|
msg.h | 12 ++++++++++++
|
|
phc2sys.c | 2 +-
|
|
pmc_agent.c | 18 +++++-------------
|
|
pmc_agent.h | 1 -
|
|
4 files changed, 18 insertions(+), 15 deletions(-)
|
|
|
|
diff --git a/msg.h b/msg.h
|
|
index b600ff0..84380da 100644
|
|
--- a/msg.h
|
|
+++ b/msg.h
|
|
@@ -247,6 +247,18 @@ static inline uint8_t management_action(struct ptp_message *m)
|
|
return m->management.flags & 0x0f;
|
|
}
|
|
|
|
+/**
|
|
+ * Obtain the data field from the TLV in a management message.
|
|
+ * @param m A management message.
|
|
+ * @return A pointer to the TLV data field.
|
|
+ */
|
|
+static inline void *management_tlv_data(struct ptp_message *msg)
|
|
+{
|
|
+ struct management_tlv *mgt;
|
|
+ mgt = (struct management_tlv *) msg->management.suffix;
|
|
+ return mgt->data;
|
|
+}
|
|
+
|
|
/**
|
|
* Obtain the ID field from the TLV in a management message.
|
|
* @param m A management message.
|
|
diff --git a/phc2sys.c b/phc2sys.c
|
|
index 1f74f27..280e249 100644
|
|
--- a/phc2sys.c
|
|
+++ b/phc2sys.c
|
|
@@ -824,7 +824,7 @@ static int phc2sys_recv_subscribed(void *context, struct ptp_message *msg,
|
|
return 0;
|
|
switch (mgt_id) {
|
|
case TLV_PORT_DATA_SET:
|
|
- pds = get_mgt_data(msg);
|
|
+ pds = management_tlv_data(msg);
|
|
port = port_get(priv, pds->portIdentity.portNumber);
|
|
if (!port) {
|
|
pr_info("received data for unknown port %s",
|
|
diff --git a/pmc_agent.c b/pmc_agent.c
|
|
index 6dfb3ca..6e9c023 100644
|
|
--- a/pmc_agent.c
|
|
+++ b/pmc_agent.c
|
|
@@ -85,14 +85,6 @@ static int is_msg_mgt(struct ptp_message *msg)
|
|
return 0;
|
|
}
|
|
|
|
-void *get_mgt_data(struct ptp_message *msg)
|
|
-{
|
|
- struct management_tlv *mgt;
|
|
-
|
|
- mgt = (struct management_tlv *) msg->management.suffix;
|
|
- return mgt->data;
|
|
-}
|
|
-
|
|
static int get_mgt_err_id(struct ptp_message *msg)
|
|
{
|
|
struct management_error_status *mgt;
|
|
@@ -188,7 +180,7 @@ int run_pmc_wait_sync(struct pmc_agent *node, int timeout)
|
|
if (res <= 0)
|
|
return res;
|
|
|
|
- data = get_mgt_data(msg);
|
|
+ data = management_tlv_data(msg);
|
|
portState = ((struct portDS *)data)->portState;
|
|
msg_put(msg);
|
|
|
|
@@ -212,7 +204,7 @@ int run_pmc_get_utc_offset(struct pmc_agent *node, int timeout)
|
|
if (res <= 0)
|
|
return res;
|
|
|
|
- tds = (struct timePropertiesDS *)get_mgt_data(msg);
|
|
+ tds = (struct timePropertiesDS *) management_tlv_data(msg);
|
|
if (tds->flags & PTP_TIMESCALE) {
|
|
node->sync_offset = tds->currentUtcOffset;
|
|
if (tds->flags & LEAP_61)
|
|
@@ -242,7 +234,7 @@ int run_pmc_get_number_ports(struct pmc_agent *node, int timeout)
|
|
if (res <= 0)
|
|
return res;
|
|
|
|
- dds = (struct defaultDS *)get_mgt_data(msg);
|
|
+ dds = (struct defaultDS *) management_tlv_data(msg);
|
|
res = dds->numberPorts;
|
|
msg_put(msg);
|
|
return res;
|
|
@@ -281,7 +273,7 @@ int run_pmc_port_properties(struct pmc_agent *node, int timeout,
|
|
if (res <= 0)
|
|
goto out;
|
|
|
|
- ppn = get_mgt_data(msg);
|
|
+ ppn = management_tlv_data(msg);
|
|
if (ppn->portIdentity.portNumber != port) {
|
|
msg_put(msg);
|
|
continue;
|
|
@@ -314,7 +306,7 @@ int run_pmc_clock_identity(struct pmc_agent *node, int timeout)
|
|
if (res <= 0)
|
|
return res;
|
|
|
|
- dds = (struct defaultDS *)get_mgt_data(msg);
|
|
+ dds = (struct defaultDS *) management_tlv_data(msg);
|
|
memcpy(&node->clock_identity, &dds->clockIdentity,
|
|
sizeof(struct ClockIdentity));
|
|
node->clock_identity_set = 1;
|
|
diff --git a/pmc_agent.h b/pmc_agent.h
|
|
index 09249ff..f3a26fe 100644
|
|
--- a/pmc_agent.h
|
|
+++ b/pmc_agent.h
|
|
@@ -43,7 +43,6 @@ int run_pmc_port_properties(struct pmc_agent *agent, int timeout,
|
|
unsigned int port, int *state,
|
|
int *tstamping, char *iface);
|
|
int run_pmc_get_utc_offset(struct pmc_agent *agent, int timeout);
|
|
-void *get_mgt_data(struct ptp_message *msg);
|
|
|
|
|
|
/**
|