Skip to content

Commit

Permalink
port: Provide methods to set and get the link status.
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Cochran <[email protected]>
  • Loading branch information
richardcochran committed Oct 16, 2016
1 parent e995cf7 commit 5e3156d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions port.c
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions port.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,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().
Expand Down

0 comments on commit 5e3156d

Please sign in to comment.