Previously the poll in sk_receive would "timeout" and when it did so would check the ERRQUEUE for data and set POLLERR. This meant that if sk_tx_timeout was set to 100 each poll would wait for 100ms rather than exiting immediately when ERRQUEUE data was available.
Implement the SO_SELECT_ERR_QUEUE socket option that enables ERRQUEUE messages to be polled for under the POLLPRI flag, greatly increasing the number of packets per second that can be sent from linuxptp. Signed-off-by: Joe Schaack <jscha...@xes-inc.com> --- sk.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sk.c b/sk.c index c48cf45..7573e56 100644 --- a/sk.c +++ b/sk.c @@ -230,7 +230,7 @@ int sk_receive(int fd, void *buf, int buflen, msg.msg_controllen = sizeof(control); if (flags == MSG_ERRQUEUE) { - struct pollfd pfd = { fd, 0, 0 }; + struct pollfd pfd = { fd, POLLPRI, 0 }; res = poll(&pfd, 1, sk_tx_timeout); if (res < 1) { pr_err(res ? "poll for tx timestamp failed: %m" : @@ -238,8 +238,8 @@ int sk_receive(int fd, void *buf, int buflen, pr_err("increasing tx_timestamp_timeout may correct " "this issue, but it is likely caused by a driver bug"); return res; - } else if (!(pfd.revents & POLLERR)) { - pr_err("poll for tx timestamp woke up on non ERR event"); + } else if (!(pfd.revents & POLLPRI)) { + pr_err("poll for tx timestamp woke up on non ERRQUEUE event"); return -1; } } @@ -352,6 +352,13 @@ int sk_timestamping_init(int fd, const char *device, enum timestamp_type type, return -1; } + flags = 1; + if (setsockopt(fd, SOL_SOCKET, SO_SELECT_ERR_QUEUE, + &flags, sizeof(flags)) < 0) { + pr_err("ioctl SO_SELECT_ERR_QUEUE failed: %m"); + return -1; + } + /* Enable the sk_check_fupsync option, perhaps. */ if (sk_general_init(fd)) { return -1; -- 1.9.1 ------------------------------------------------------------------------------ _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel