On Mon, Nov 09, 2020 at 01:44:57PM -0800, Richard Cochran wrote:
> The PMC agent's implementation should not be exposed to its users. This
> patch hides the details and provides a method to create an instance. In
> addition, the signature of the receive callback is made generic, removing
> the container_of pattern meant for sub-classing modules.
>
> Signed-off-by: Richard Cochran <[email protected]>
> ---
> phc2sys.c | 75 +++++++++++++++++++++++++++++------------------------
> pmc_agent.c | 58 ++++++++++++++++++++++++++++++++++++-----
> pmc_agent.h | 62 +++++++++++++++++++++++++++++++------------
> 3 files changed, 137 insertions(+), 58 deletions(-)
>
> diff --git a/phc2sys.c b/phc2sys.c
> index c1eab1b..9e47b4f 100644
> --- a/phc2sys.c
> +++ b/phc2sys.c
> @@ -1020,11 +1017,12 @@ int main(int argc, char *argv[])
> {
> char *config = NULL, *dst_name = NULL, *progname, *src_name = NULL;
> char uds_local[MAX_IFNAME_SIZE + 1];
> + int autocfg = 0, c, domain_number = 0, index, ntpshm_segment, offset;
> + int pps_fd = -1, print_level = LOG_INFO, r = -1, rt = 0;
> + int wait_sync = 0;
> struct clock *src, *dst;
> struct config *cfg;
> struct option *opts;
> - int autocfg = 0, c, domain_number = 0, index, ntpshm_segment;
> - int pps_fd = -1, print_level = LOG_INFO, r = -1, rt = 0, wait_sync = 0;
> double phc_rate, tmp;
> struct phc2sys_private priv = {
> .phc_readings = 5,
This change looks a bit noisy when all it does is introduce the "offset"
variable, but ok.
> diff --git a/pmc_agent.c b/pmc_agent.c
> index e83895c..8ccafe2 100644
> --- a/pmc_agent.c
> +++ b/pmc_agent.c
> @@ -19,6 +19,7 @@
> */
> #include <net/if.h>
> #include <poll.h>
> +#include <stdlib.h>
>
> #include "notification.h"
> #include "pmc_agent.h"
> @@ -32,6 +33,22 @@
> * renewed.
> */
>
> +struct pmc_agent {
> + struct pmc *pmc;
> + uint64_t pmc_last_update;
> +
> + struct ClockIdentity clock_identity;
> + int clock_identity_set;
> + int leap;
> + int pmc_ds_requested;
> + int sync_offset;
> + int utc_offset_traceable;
> +
> + /* Callback on message reception */
> + pmc_node_recv_subscribed_t *recv_subscribed;
> + void *recv_context;
Now that the pmc_agent is going to have a more 'stable' interface, I
wonder if this callback is even properly placed in struct pmc_agent and
shouldn't be a simple argument passed to run_pmc_events(), considering
that this is the only place where it's called from. It would also
simplify the implementation, with those "excluded" managementId's.
Of course, that can come later.
> +};
> +
> static void send_subscription(struct pmc_agent *node)
> {
> struct subscribe_events_np sen;
> @@ -58,5 +46,45 @@ int run_pmc_get_utc_offset(struct pmc_agent *agent, int
> timeout);
> int get_mgt_id(struct ptp_message *msg);
> void *get_mgt_data(struct ptp_message *msg);
>
> -#endif
>
> +/**
> + * Creates an instance of a PMC agent.
> + * @return Pointer to a PMC instance on sauces, NULL otherwise.
Sauces?
> + */
> +struct pmc_agent *pmc_agent_create(void);
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel