Signed-off-by: Richard Cochran <[email protected]>
---
port.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/port.c b/port.c
index 34837cc..c8c4424 100644
--- a/port.c
+++ b/port.c
@@ -74,6 +74,10 @@ struct port {
struct fdarray fda;
int fault_fd;
int phc_index;
+
+ void (*dispatch)(struct port *p, enum fsm_event event, int mdiff);
+ enum fsm_event (*event)(struct port *p, int fd_index);
+
int jbod;
struct foreign_clock *best;
enum syfu_state syfu;
@@ -2162,6 +2166,11 @@ static void port_p2p_transition(struct port *p, enum
port_state next)
void port_dispatch(struct port *p, enum fsm_event event, int mdiff)
{
+ p->dispatch(p, event, mdiff);
+}
+
+static void bc_dispatch(struct port *p, enum fsm_event event, int mdiff)
+{
enum port_state next;
if (clock_slave_only(p->clock)) {
@@ -2240,6 +2249,11 @@ static void port_link_status(void *ctx, int index, int
linkup)
enum fsm_event port_event(struct port *p, int fd_index)
{
+ return p->event(p, fd_index);
+}
+
+static enum fsm_event bc_event(struct port *p, int fd_index)
+{
enum fsm_event event = EV_NONE;
struct ptp_message *msg;
int cnt, fd = p->fda.fd[fd_index], err;
@@ -2587,6 +2601,7 @@ struct port *port_open(int phc_index,
struct interface *interface,
struct clock *clock)
{
+ enum clock_type type = clock_type(clock);
struct config *cfg = clock_config(clock);
struct port *p = malloc(sizeof(*p));
enum transport_type transport;
@@ -2597,6 +2612,18 @@ struct port *port_open(int phc_index,
memset(p, 0, sizeof(*p));
+ switch (type) {
+ case CLOCK_TYPE_ORDINARY:
+ case CLOCK_TYPE_BOUNDARY:
+ p->dispatch = bc_dispatch;
+ p->event = bc_event;
+ break;
+ case CLOCK_TYPE_P2P:
+ case CLOCK_TYPE_E2E:
+ case CLOCK_TYPE_MANAGEMENT:
+ return NULL;
+ }
+
p->state_machine = clock_slave_only(clock) ? ptp_slave_fsm : ptp_fsm;
p->phc_index = phc_index;
p->jbod = config_get_int(cfg, interface->name, "boundary_clock_jbod");
--
2.13.0
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel