From: devasishsyncmonk <devasish....@syncmonk.net>

adding interface rate TLV as defined by ITU-T G.8275.2 Annex D to
enable master to communicate PTP port interface rate to slave.

Signed-off-by: Greg Armstrong <greg.armstrong...@renesas.com>
Signed-off-by: Leon Goldin <leon.goldin...@renesas.com>
Signed-off-by: Devasish Dey <devasish....@syncmonk.net>
Signed-off-by: Vipin Sharma <vipin.sha...@syncmonk.net>

-v1: initial commit
-v2: maintaining alphabetical sequence for the config.
---
 clock.c  |  7 +++++++
 clock.h  |  7 +++++++
 config.c |  1 +
 pdt.h    |  1 +
 tlv.c    |  1 +
 tlv.h    | 15 +++++++++++++++
 6 files changed, 32 insertions(+)

diff --git a/clock.c b/clock.c
index 086b1a8..c6708e0 100644
--- a/clock.c
+++ b/clock.c
@@ -137,6 +137,7 @@ struct clock {
        struct monitor *slave_event_monitor;
        int step_window_counter;
        int step_window;
+       bool iface_rate_tlv;
 };
 
 struct clock the_clock;
@@ -1106,6 +1107,7 @@ struct clock *clock_create(enum clock_type type, struct 
config *config,
        c->utc_offset = config_get_int(config, NULL, "utc_offset");
        c->time_source = config_get_int(config, NULL, "timeSource");
        c->step_window = config_get_int(config, NULL, "step_window");
+       c->iface_rate_tlv = config_get_int(config, NULL, "interface_rate_tlv");
 
        if (c->free_running) {
                c->clkid = CLOCK_INVALID;
@@ -2083,6 +2085,11 @@ struct servo *clock_servo(struct clock *c)
        return c->servo;
 }
 
+bool clock_interface_rate_tlv (struct clock *c)
+{
+       return c->iface_rate_tlv;
+}
+
 enum servo_state clock_servo_state(struct clock *c)
 {
        return c->servo_state;
diff --git a/clock.h b/clock.h
index 0534f21..b393c3e 100644
--- a/clock.h
+++ b/clock.h
@@ -388,4 +388,11 @@ void clock_check_ts(struct clock *c, uint64_t ts);
  */
 double clock_rate_ratio(struct clock *c);
 
+/**
+ * Obtain interface rate tlv support configuration.
+ * @param c  The clock instance.
+ * @return   The interface_rate_supoort config true if supported, else false.
+ */
+bool clock_interface_rate_tlv(struct clock *c);
+
 #endif
diff --git a/config.c b/config.c
index e454c91..be19143 100644
--- a/config.c
+++ b/config.c
@@ -267,6 +267,7 @@ struct config_item config_tab[] = {
        PORT_ITEM_INT("inhibit_delay_req", 0, 0, 1),
        PORT_ITEM_INT("inhibit_multicast_service", 0, 0, 1),
        GLOB_ITEM_INT("initial_delay", 0, 0, INT_MAX),
+       PORT_ITEM_INT("interface_rate_tlv", 0, 0, 1),
        GLOB_ITEM_INT("kernel_leap", 1, 0, 1),
        GLOB_ITEM_STR("leapfile", NULL),
        PORT_ITEM_INT("logAnnounceInterval", 1, INT8_MIN, INT8_MAX),
diff --git a/pdt.h b/pdt.h
index e46b218..1ad23d4 100644
--- a/pdt.h
+++ b/pdt.h
@@ -39,6 +39,7 @@ typedef uint16_t  UInteger16;
 typedef int32_t   Integer32;
 typedef uint32_t  UInteger32;
 typedef int64_t   Integer64;
+typedef uint64_t  UInteger64;
 typedef uint8_t   Octet;
 
 #endif
diff --git a/tlv.c b/tlv.c
index 1c13460..35bee4f 100644
--- a/tlv.c
+++ b/tlv.c
@@ -35,6 +35,7 @@
        (tlv->length < sizeof(struct type) - sizeof(struct TLV))
 
 uint8_t ieee8021_id[3] = { IEEE_802_1_COMMITTEE };
+uint8_t itu_t_id[3] = { ITU_T_COMMITTEE };
 
 static TAILQ_HEAD(tlv_pool, tlv_extra) tlv_pool =
        TAILQ_HEAD_INITIALIZER(tlv_pool);
diff --git a/tlv.h b/tlv.h
index 8966696..1dfaac8 100644
--- a/tlv.h
+++ b/tlv.h
@@ -395,6 +395,21 @@ struct tlv_extra {
        };
 };
 
+/* Organizationally Unique Identifiers */
+#define ITU_T_COMMITTEE 0x00, 0x19, 0xA7
+extern uint8_t itu_t_id[3];
+
+struct msg_interface_rate_tlv {
+       Enumeration16 type;
+       UInteger16    length;
+       Octet         id[3];
+       Octet         subtype[3];
+       UInteger64    interfaceBitPeriod;
+       UInteger16    numberOfBitsBeforeTimestamp;
+       UInteger16    numberOfBitsAfterTimestamp;
+} PACKED;
+
+
 /**
  * Allocates a new tlv_extra structure.
  * @return  Pointer to a new structure on success or NULL otherwise.
-- 
2.34.1



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

Reply via email to