Up until now, the code has always fetched the time stamp immediately
after transmitting a message.  However, a transparent clock will want
to forward a given incoming message out all egress ports with as
little delay as possible, in order to minimize the residence time of
the message within the switch.

This patch adds a new transmit mode for event messages that will be
used to signal the new behavior.

Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
---
 raw.c       | 14 +++++++++++++-
 transport.h |  1 +
 udp.c       | 16 ++++++++++++++--
 udp6.c      | 16 ++++++++++++++--
 4 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/raw.c b/raw.c
index 937f473..8dc50bc 100644
--- a/raw.c
+++ b/raw.c
@@ -296,9 +296,21 @@ static int raw_send(struct transport *t, struct fdarray 
*fda,
 {
        struct raw *raw = container_of(t, struct raw, t);
        ssize_t cnt;
-       int fd = event ? fda->fd[FD_EVENT] : fda->fd[FD_GENERAL];
        unsigned char pkt[1600], *ptr = buf;
        struct eth_hdr *hdr;
+       int fd = -1;
+
+       switch (event) {
+       case TRANS_GENERAL:
+               fd = fda->fd[FD_GENERAL];
+               break;
+       case TRANS_EVENT:
+       case TRANS_ONESTEP:
+       case TRANS_P2P1STEP:
+       case TRANS_DEFER_EVENT:
+               fd = fda->fd[FD_EVENT];
+               break;
+       }
 
        ptr -= sizeof(*hdr);
        len += sizeof(*hdr);
diff --git a/transport.h b/transport.h
index 5c8a051..171e59f 100644
--- a/transport.h
+++ b/transport.h
@@ -50,6 +50,7 @@ enum transport_event {
        TRANS_EVENT,
        TRANS_ONESTEP,
        TRANS_P2P1STEP,
+       TRANS_DEFER_EVENT,
 };
 
 struct transport;
diff --git a/udp.c b/udp.c
index 3ac489e..6ebec3e 100644
--- a/udp.c
+++ b/udp.c
@@ -219,10 +219,22 @@ static int udp_send(struct transport *t, struct fdarray 
*fda,
                    enum transport_event event, int peer, void *buf, int len,
                    struct address *addr, struct hw_timestamp *hwts)
 {
-       ssize_t cnt;
-       int fd = event ? fda->fd[FD_EVENT] : fda->fd[FD_GENERAL];
        struct address addr_buf;
        unsigned char junk[1600];
+       ssize_t cnt;
+       int fd = -1;
+
+       switch (event) {
+       case TRANS_GENERAL:
+               fd = fda->fd[FD_GENERAL];
+               break;
+       case TRANS_EVENT:
+       case TRANS_ONESTEP:
+       case TRANS_P2P1STEP:
+       case TRANS_DEFER_EVENT:
+               fd = fda->fd[FD_EVENT];
+               break;
+       }
 
        if (!addr) {
                memset(&addr_buf, 0, sizeof(addr_buf));
diff --git a/udp6.c b/udp6.c
index 12213d7..9978844 100644
--- a/udp6.c
+++ b/udp6.c
@@ -230,10 +230,22 @@ static int udp6_send(struct transport *t, struct fdarray 
*fda,
                     struct address *addr, struct hw_timestamp *hwts)
 {
        struct udp6 *udp6 = container_of(t, struct udp6, t);
-       ssize_t cnt;
-       int fd = event ? fda->fd[FD_EVENT] : fda->fd[FD_GENERAL];
        struct address addr_buf;
        unsigned char junk[1600];
+       ssize_t cnt;
+       int fd = -1;
+
+       switch (event) {
+       case TRANS_GENERAL:
+               fd = fda->fd[FD_GENERAL];
+               break;
+       case TRANS_EVENT:
+       case TRANS_ONESTEP:
+       case TRANS_P2P1STEP:
+       case TRANS_DEFER_EVENT:
+               fd = fda->fd[FD_EVENT];
+               break;
+       }
 
        if (!addr) {
                memset(&addr_buf, 0, sizeof(addr_buf));
-- 
2.11.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
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to