Skip to content

Commit

Permalink
tc: Add the transparent clock implementation.
Browse files Browse the repository at this point in the history
This patch adds code that sends an event messages received on one port out
all the other ports and calculates the residence time.  The correction,
ingress port, and the original message are remembered in a TC transmit
descriptor.  These descriptors are recycled in a memory pool in a similar
way to the message buffers.

Signed-off-by: Richard Cochran <[email protected]>
  • Loading branch information
richardcochran committed May 1, 2018
1 parent 4cfbb26 commit a13212f
Show file tree
Hide file tree
Showing 7 changed files with 634 additions and 2 deletions.
1 change: 1 addition & 0 deletions clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ void clock_destroy(struct clock *c)
}
memset(c, 0, sizeof(*c));
msg_cleanup();
tc_cleanup();
}

static int clock_fault_timeout(struct port *port, int set)
Expand Down
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ LDLIBS = -lm -lrt $(EXTRA_LDFLAGS)
PRG = ptp4l hwstamp_ctl nsm phc2sys phc_ctl pmc timemaster
OBJ = bmc.o clock.o clockadj.o clockcheck.o config.o fault.o \
filter.o fsm.o hash.o linreg.o mave.o mmedian.o msg.o ntpshm.o nullf.o phc.o \
pi.o port.o print.o ptp4l.o raw.o rtnl.o servo.o sk.o stats.o telecom.o tlv.o \
transport.o tsproc.o udp.o udp6.o uds.o util.o version.o
pi.o port.o print.o ptp4l.o raw.o rtnl.o servo.o sk.o stats.o tc.o telecom.o \
tlv.o transport.o tsproc.o udp.o udp6.o uds.o util.o version.o

OBJECTS = $(OBJ) hwstamp_ctl.o nsm.o phc2sys.o phc_ctl.o pmc.o pmc_common.o \
sysoff.o timemaster.o
Expand Down
3 changes: 3 additions & 0 deletions port.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "print.h"
#include "rtnl.h"
#include "sk.h"
#include "tc.h"
#include "tlv.h"
#include "tmv.h"
#include "tsproc.h"
Expand Down Expand Up @@ -1534,6 +1535,7 @@ void port_disable(struct port *p)
{
int i;

tc_flush(p);
flush_last_sync(p);
flush_delay_req(p);
flush_peer_delay(p);
Expand Down Expand Up @@ -2777,6 +2779,7 @@ struct port *port_open(int phc_index,
}

memset(p, 0, sizeof(*p));
TAILQ_INIT(&p->tc_transmitted);

switch (type) {
case CLOCK_TYPE_ORDINARY:
Expand Down
5 changes: 5 additions & 0 deletions port.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,9 @@ enum fault_type last_fault_type(struct port *port);
void fault_interval(struct port *port, enum fault_type ft,
struct fault_interval *i);

/**
* Release all of the memory in the TC transmit descriptor cache.
*/
void tc_cleanup(void);

#endif
10 changes: 10 additions & 0 deletions port_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ struct nrate_estimator {
int ratio_valid;
};

struct tc_txd {
TAILQ_ENTRY(tc_txd) list;
struct ptp_message *msg;
tmv_t residence;
int ingress_port;
};

struct port {
LIST_ENTRY(port) list;
char *name;
Expand Down Expand Up @@ -113,6 +120,7 @@ struct port {
int min_neighbor_prop_delay;
int net_sync_monitor;
int path_trace_enabled;
int tc_spanning_tree;
Integer64 rx_timestamp_offset;
Integer64 tx_timestamp_offset;
enum link_state link_status;
Expand All @@ -121,6 +129,8 @@ struct port {
unsigned int versionNumber; /*UInteger4*/
/* foreignMasterDS */
LIST_HEAD(fm, foreign_clock) foreign_masters;
/* TC book keeping */
TAILQ_HEAD(tct, tc_txd) tc_transmitted;
};

#define portnum(p) (p->portIdentity.portNumber)
Expand Down
Loading

0 comments on commit a13212f

Please sign in to comment.