Re: [Linuxptp-devel] [PATCH v7 1/2] pmc_agent: Add option to run callback for signaling messages

2023-12-04 Thread Maciek Machnikowski



On 04/12/2023 17:46, Richard Cochran wrote:
> On Mon, Dec 04, 2023 at 08:39:47AM +0100, Maciek Machnikowski wrote:
>> Hey, please take a look at these patches and merge them if there are no
>> bugs in this code.
> 
> I don't understand the need for this series.
> What problem does it solve?
> 
> Thanks,
> Richard

If you have a remote node that is connected to a PPS signal and have no
trusted NTP or NMEA data you can use an incoming PTP traffic for
recovering the ToD for a given PPS.

It solves this problem for Assisted Partial Timing Support (APTS)
deployment where a node is connected to the PPS signal from a GNSS
receiver, but doesn't have the serial port (e.x. shared GNSS receiver).

Thanks,
Maciek


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH v7 1/2] pmc_agent: Add option to run callback for signaling messages

2023-12-04 Thread Richard Cochran
On Mon, Dec 04, 2023 at 08:39:47AM +0100, Maciek Machnikowski wrote:
> Hey, please take a look at these patches and merge them if there are no
> bugs in this code.

I don't understand the need for this series.
What problem does it solve?

Thanks,
Richard


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH v7 1/2] pmc_agent: Add option to run callback for signaling messages

2023-12-03 Thread Maciek Machnikowski
Hey, please take a look at these patches and merge them if there are no
bugs in this code.

Thanks,
Maciek

On 10/11/2023 15:14, Maciek Machnikowski wrote:
> Add option to run callback that when the PMC agent receives signaling 
> messages.
> 
> v2: changed pmc_agent implementation to not use a separate callback
> v3: updated poll thread to use less CPU
> v4: changed sleep routine to usleep, simplified poll thread
> v5: make sure management_tlv_id is not called on non-management messages
> v6: optimized code to not check signaling_cb_ena on management messages
> v7: rebase
> 
> Signed-off-by: Maciek Machnikowski 
> ---
>  pmc_agent.c | 22 --
>  pmc_agent.h |  7 +++
>  2 files changed, 27 insertions(+), 2 deletions(-)
> 
> diff --git a/pmc_agent.c b/pmc_agent.c
> index 62d1a86..bea6b59 100644
> --- a/pmc_agent.c
> +++ b/pmc_agent.c
> @@ -42,6 +42,7 @@ struct pmc_agent {
>   bool dds_valid;
>   int leap;
>   int pmc_ds_requested;
> + bool signaling_cb_ena;
>   bool stay_subscribed;
>   int sync_offset;
>   int utc_offset_traceable;
> @@ -127,6 +128,7 @@ static int run_pmc(struct pmc_agent *node, int timeout, 
> int ds_id,
>  #define N_FD 1
>   struct pollfd pollfd[N_FD];
>   int cnt, res;
> + bool skip_cb;
>  
>   while (1) {
>   pollfd[0].fd = pmc_get_transport_fd(node->pmc);
> @@ -178,9 +180,19 @@ static int run_pmc(struct pmc_agent *node, int timeout, 
> int ds_id,
>   node->pmc_ds_requested = 0;
>   return RUN_PMC_NODEV;
>   }
> - if (res <= 0 ||
> +
> + /* Skip callback if message is not management */
> + skip_cb = (res <= 0) ? true : false;
> +
> + /* Run the callback on signaling messages if configured */
> + if (res == 0 && node->signaling_cb_ena &&
> + msg_type(*msg) == SIGNALING) {
> + skip_cb = false;
> + }
> +
> + if (skip_cb ||
>   node->recv_subscribed(node->recv_context, *msg, ds_id) ||
> - management_tlv_id(*msg) != ds_id) {
> + (res == 1 && management_tlv_id(*msg) != ds_id)) {
>   msg_put(*msg);
>   *msg = NULL;
>   continue;
> @@ -430,3 +442,9 @@ bool pmc_agent_utc_offset_traceable(struct pmc_agent 
> *agent)
>  {
>   return agent->utc_offset_traceable;
>  }
> +
> +void pmc_agent_enable_signaling_cb(struct pmc_agent *agent, bool enable)
> +{
> + agent->signaling_cb_ena = enable;
> +}
> +
> diff --git a/pmc_agent.h b/pmc_agent.h
> index 2fb1cc8..9ae37f7 100644
> --- a/pmc_agent.h
> +++ b/pmc_agent.h
> @@ -170,4 +170,11 @@ int pmc_agent_update(struct pmc_agent *agent);
>   */
>  bool pmc_agent_utc_offset_traceable(struct pmc_agent *agent);
>  
> +/**
> + * Enables or disables callback on signaling messages
> + * @param agent  Pointer to a PMC instance obtained via @ref 
> pmc_agent_create().
> + * @param enable - if set to true, callback will be called on signaling msgs
> + */
> +void pmc_agent_enable_signaling_cb(struct pmc_agent *agent, bool enable);
> +
>  #endif


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v7 1/2] pmc_agent: Add option to run callback for signaling messages

2023-11-10 Thread Maciek Machnikowski
Add option to run callback that when the PMC agent receives signaling messages.

v2: changed pmc_agent implementation to not use a separate callback
v3: updated poll thread to use less CPU
v4: changed sleep routine to usleep, simplified poll thread
v5: make sure management_tlv_id is not called on non-management messages
v6: optimized code to not check signaling_cb_ena on management messages
v7: rebase

Signed-off-by: Maciek Machnikowski 
---
 pmc_agent.c | 22 --
 pmc_agent.h |  7 +++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/pmc_agent.c b/pmc_agent.c
index 62d1a86..bea6b59 100644
--- a/pmc_agent.c
+++ b/pmc_agent.c
@@ -42,6 +42,7 @@ struct pmc_agent {
bool dds_valid;
int leap;
int pmc_ds_requested;
+   bool signaling_cb_ena;
bool stay_subscribed;
int sync_offset;
int utc_offset_traceable;
@@ -127,6 +128,7 @@ static int run_pmc(struct pmc_agent *node, int timeout, int 
ds_id,
 #define N_FD 1
struct pollfd pollfd[N_FD];
int cnt, res;
+   bool skip_cb;
 
while (1) {
pollfd[0].fd = pmc_get_transport_fd(node->pmc);
@@ -178,9 +180,19 @@ static int run_pmc(struct pmc_agent *node, int timeout, 
int ds_id,
node->pmc_ds_requested = 0;
return RUN_PMC_NODEV;
}
-   if (res <= 0 ||
+
+   /* Skip callback if message is not management */
+   skip_cb = (res <= 0) ? true : false;
+
+   /* Run the callback on signaling messages if configured */
+   if (res == 0 && node->signaling_cb_ena &&
+   msg_type(*msg) == SIGNALING) {
+   skip_cb = false;
+   }
+
+   if (skip_cb ||
node->recv_subscribed(node->recv_context, *msg, ds_id) ||
-   management_tlv_id(*msg) != ds_id) {
+   (res == 1 && management_tlv_id(*msg) != ds_id)) {
msg_put(*msg);
*msg = NULL;
continue;
@@ -430,3 +442,9 @@ bool pmc_agent_utc_offset_traceable(struct pmc_agent *agent)
 {
return agent->utc_offset_traceable;
 }
+
+void pmc_agent_enable_signaling_cb(struct pmc_agent *agent, bool enable)
+{
+   agent->signaling_cb_ena = enable;
+}
+
diff --git a/pmc_agent.h b/pmc_agent.h
index 2fb1cc8..9ae37f7 100644
--- a/pmc_agent.h
+++ b/pmc_agent.h
@@ -170,4 +170,11 @@ int pmc_agent_update(struct pmc_agent *agent);
  */
 bool pmc_agent_utc_offset_traceable(struct pmc_agent *agent);
 
+/**
+ * Enables or disables callback on signaling messages
+ * @param agent  Pointer to a PMC instance obtained via @ref 
pmc_agent_create().
+ * @param enable - if set to true, callback will be called on signaling msgs
+ */
+void pmc_agent_enable_signaling_cb(struct pmc_agent *agent, bool enable);
+
 #endif
-- 
2.30.2



___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel