Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
---
 port.c | 13 +++++++++++++
 port.h | 14 ++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/port.c b/port.c
index 5868983..a1ad6f6 100644
--- a/port.c
+++ b/port.c
@@ -117,6 +117,7 @@ struct port {
        int                 path_trace_enabled;
        int                 rx_timestamp_offset;
        int                 tx_timestamp_offset;
+       int                 link_status;
        struct fault_interval flt_interval_pertype[FT_CNT];
        enum fault_type     last_fault_type;
        unsigned int        versionNumber; /*UInteger4*/
@@ -2357,6 +2358,17 @@ int port_number(struct port *p)
        return portnum(p);
 }
 
+int port_link_status_get(struct port *p)
+{
+       return p->link_status;
+}
+
+void port_link_status_set(struct port *p, int up)
+{
+       p->link_status = up ? 1 : 0;
+       pr_notice("port %hu: link %s", portnum(p), up ? "up" : "down");
+}
+
 int port_manage(struct port *p, struct port *ingress, struct ptp_message *msg)
 {
        struct management_tlv *mgt;
@@ -2573,6 +2585,7 @@ struct port *port_open(int phc_index,
        p->path_trace_enabled = config_get_int(cfg, p->name, 
"path_trace_enabled");
        p->rx_timestamp_offset = config_get_int(cfg, p->name, "ingressLatency");
        p->tx_timestamp_offset = config_get_int(cfg, p->name, "egressLatency");
+       p->link_status = 1;
        p->clock = clock;
        p->trp = transport_create(cfg, transport);
        if (!p->trp)
diff --git a/port.h b/port.h
index 662eaef..19dec4a 100644
--- a/port.h
+++ b/port.h
@@ -127,6 +127,20 @@ struct PortIdentity port_identity(struct port *p);
 int port_number(struct port *p);
 
 /**
+ * Obtain the link status of a port.
+ * @param p        A port instance.
+ * @return         One (1) if the link is up, zero otherwise.
+ */
+int port_link_status_get(struct port *p);
+
+/**
+ * Sets the link status for a port.
+ * @param p        A port instance.
+ * @param up       Pass one (1) if the link is up and zero if down.
+ */
+void port_link_status_set(struct port *p, int up);
+
+/**
  * Manage a port according to a given message.
  * @param p        A pointer previously obtained via port_open().
  * @param ingress  The port on which 'msg' was received.
-- 
2.1.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to