This patch borns from my requirements and it permits to have a
configurable portNumber.


Signed-off-by: Luigi Mantellini <luigi.mantell...@sm-optics.com>
---
 clock.c  | 12 +++++++++++-
 config.c |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/clock.c b/clock.c
index d584748..cdde645 100644
--- a/clock.c
+++ b/clock.c
@@ -826,12 +826,22 @@ static int clock_add_port(struct clock *c, const
char *phc_device,
                          struct interface *iface)
 {
        struct port *p, *piter, *lastp = NULL;
+       int port_number = config_get_int(c->config,
interface_name(iface), "portNumber");
 
        if (clock_resize_pollfd(c, c->nports + 2)) {
                return -1;
        }
+
+       if (port_number) {
+               c->last_port_number = (c->last_port_number >
port_number ?
+                                      c->last_port_number :
port_number) + 1;
+       } else {
+               port_number = ++c->last_port_number;
+       }
+
        p = port_open(phc_device, phc_index, timestamping,
-                     ++c->last_port_number, iface, c);
+                     port_number, iface, c);
+
        if (!p) {
                /* No need to shrink pollfd */
                return -1;
diff --git a/config.c b/config.c
index bf1049f..933b540 100644
--- a/config.c
+++ b/config.c
@@ -291,6 +291,7 @@ struct config_item config_tab[] = {
        GLOB_ITEM_DBL("pi_proportional_exponent", -0.3, -DBL_MAX,
DBL_MAX),
        GLOB_ITEM_DBL("pi_proportional_norm_max", 0.7, DBL_MIN, 1.0),
        GLOB_ITEM_DBL("pi_proportional_scale", 0.0, 0.0, DBL_MAX),
+       GLOB_ITEM_INT("portNumber", 0, 0, UINT16_MAX),
        GLOB_ITEM_INT("priority1", 128, 0, UINT8_MAX),
        GLOB_ITEM_INT("priority2", 128, 0, UINT8_MAX),
        GLOB_ITEM_STR("productDescription", ";;"),
-- 
2.30.1





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

Reply via email to