net: sockets: Extend ioctl poll protocol with offloading feature

Allow to use offloaded `poll` implementation via the existing ioctl poll
control mechanism.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2020-01-14 13:59:12 +01:00 committed by Anas Nashif
commit 561973060e
2 changed files with 13 additions and 2 deletions

View file

@ -140,6 +140,7 @@ enum {
ZFD_IOCTL_LSEEK,
ZFD_IOCTL_POLL_PREPARE,
ZFD_IOCTL_POLL_UPDATE,
ZFD_IOCTL_POLL_OFFLOAD,
ZFD_IOCTL_GETSOCKNAME,
};

View file

@ -1052,7 +1052,7 @@ int z_impl_zsock_poll(struct zsock_pollfd *fds, int nfds, int timeout)
pev = poll_events;
for (pfd = fds, i = nfds; i--; pfd++) {
struct net_context *ctx;
void *ctx;
int result;
/* Per POSIX, negative fd's are just ignored */
@ -1077,6 +1077,16 @@ int z_impl_zsock_poll(struct zsock_pollfd *fds, int nfds, int timeout)
*/
timeout = K_NO_WAIT;
continue;
} else if (result == -EXDEV) {
/* If POLL_PREPARE returned EXDEV, it means
* it detected an offloaded socket.
* In case the fds array contains a mixup of offloaded
* and non-offloaded sockets, the offloaded poll handler
* shall return an error.
*/
return z_fdtable_call_ioctl(vtable, ctx,
ZFD_IOCTL_POLL_OFFLOAD,
fds, nfds, timeout);
} else if (result != 0) {
errno = -result;
return -1;
@ -1098,7 +1108,7 @@ int z_impl_zsock_poll(struct zsock_pollfd *fds, int nfds, int timeout)
pev = poll_events;
for (pfd = fds, i = nfds; i--; pfd++) {
struct net_context *ctx;
void *ctx;
int result;
pfd->revents = 0;