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:
parent
bdc535dba3
commit
561973060e
2 changed files with 13 additions and 2 deletions
|
@ -140,6 +140,7 @@ enum {
|
||||||
ZFD_IOCTL_LSEEK,
|
ZFD_IOCTL_LSEEK,
|
||||||
ZFD_IOCTL_POLL_PREPARE,
|
ZFD_IOCTL_POLL_PREPARE,
|
||||||
ZFD_IOCTL_POLL_UPDATE,
|
ZFD_IOCTL_POLL_UPDATE,
|
||||||
|
ZFD_IOCTL_POLL_OFFLOAD,
|
||||||
ZFD_IOCTL_GETSOCKNAME,
|
ZFD_IOCTL_GETSOCKNAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1052,7 +1052,7 @@ int z_impl_zsock_poll(struct zsock_pollfd *fds, int nfds, int timeout)
|
||||||
|
|
||||||
pev = poll_events;
|
pev = poll_events;
|
||||||
for (pfd = fds, i = nfds; i--; pfd++) {
|
for (pfd = fds, i = nfds; i--; pfd++) {
|
||||||
struct net_context *ctx;
|
void *ctx;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
/* Per POSIX, negative fd's are just ignored */
|
/* 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;
|
timeout = K_NO_WAIT;
|
||||||
continue;
|
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) {
|
} else if (result != 0) {
|
||||||
errno = -result;
|
errno = -result;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1098,7 +1108,7 @@ int z_impl_zsock_poll(struct zsock_pollfd *fds, int nfds, int timeout)
|
||||||
|
|
||||||
pev = poll_events;
|
pev = poll_events;
|
||||||
for (pfd = fds, i = nfds; i--; pfd++) {
|
for (pfd = fds, i = nfds; i--; pfd++) {
|
||||||
struct net_context *ctx;
|
void *ctx;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
pfd->revents = 0;
|
pfd->revents = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue