Skip to content

Commit

Permalink
Revert "net: sockets: move poll implementation to zvfs"
Browse files Browse the repository at this point in the history
This reverts commit 93973e2.

PR zephyrproject-rtos#73978 introduced a regression.
Unfortunately this PR cannot be reverted without reverting also
Let's revert both PRs to stabilize main again towards the 3.7 release.

For more details on the issue see
zephyrproject-rtos#75205

Signed-off-by: Alberto Escolar Piedras <[email protected]>
  • Loading branch information
aescolar authored and nashif committed Jul 3, 2024
1 parent 14e4de6 commit 1df86af
Show file tree
Hide file tree
Showing 15 changed files with 239 additions and 275 deletions.
5 changes: 1 addition & 4 deletions include/zephyr/net/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,7 @@ static inline int zsock_ioctl_wrapper(int sock, unsigned long request, ...)
* it may conflict with generic POSIX ``poll()`` function).
* @endrst
*/
static inline int zsock_poll(struct zsock_pollfd *fds, int nfds, int timeout)
{
return zvfs_poll(fds, nfds, timeout);
}
__syscall int zsock_poll(struct zsock_pollfd *fds, int nfds, int timeout);

/**
* @brief Get various socket options
Expand Down
8 changes: 5 additions & 3 deletions include/zephyr/net/socket_poll.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#ifndef ZEPHYR_INCLUDE_NET_SOCKET_POLL_H_
#define ZEPHYR_INCLUDE_NET_SOCKET_POLL_H_

#include <zephyr/sys/fdtable.h>

/* Setting for pollfd to avoid circular inclusion */

/**
Expand All @@ -27,7 +25,11 @@ extern "C" {
*
* An array of these descriptors is passed as an argument to poll().
*/
#define zsock_pollfd zvfs_pollfd
struct zsock_pollfd {
int fd; /**< Socket descriptor */
short events; /**< Requested events */
short revents; /**< Returned events */
};

#ifdef __cplusplus
}
Expand Down
18 changes: 0 additions & 18 deletions include/zephyr/sys/fdtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@
#define ZVFS_MODE_IFLNK 0120000
#define ZVFS_MODE_IFSOCK 0140000

#define ZVFS_POLLIN BIT(0)
#define ZVFS_POLLPRI BIT(1)
#define ZVFS_POLLOUT BIT(2)
#define ZVFS_POLLERR BIT(3)
#define ZVFS_POLLHUP BIT(4)
#define ZVFS_POLLNVAL BIT(5)

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -199,17 +192,6 @@ static inline int zvfs_fdtable_call_ioctl(const struct fd_op_vtable *vtable, voi
return res;
}

struct zvfs_pollfd {
int fd;
short events;
short revents;
};

__syscall int zvfs_poll(struct zvfs_pollfd *fds, int nfds, int poll_timeout);

struct zsock_fd_set {
uint32_t bitset[(CONFIG_ZVFS_OPEN_MAX + 31) / 32];
};
/**
* Request codes for fd_op_vtable.ioctl().
*
Expand Down
3 changes: 0 additions & 3 deletions lib/os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ zephyr_sources(
)

zephyr_sources_ifdef(CONFIG_FDTABLE fdtable.c)
zephyr_syscall_header_ifdef(CONFIG_FDTABLE
${ZEPHYR_BASE}/include/zephyr/sys/fdtable.h
)

zephyr_sources_ifdef(CONFIG_CBPRINTF_COMPLETE cbprintf_complete.c)
zephyr_sources_ifdef(CONFIG_CBPRINTF_NANO cbprintf_nano.c)
Expand Down
1 change: 0 additions & 1 deletion lib/os/zvfs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

zephyr_library()
zephyr_library_sources_ifdef(CONFIG_ZVFS_EVENTFD zvfs_eventfd.c)
zephyr_library_sources_ifdef(CONFIG_ZVFS_POLL zvfs_poll.c)
20 changes: 1 addition & 19 deletions lib/os/zvfs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if ZVFS

config ZVFS_EVENTFD
bool "ZVFS event file descriptor support"
imply ZVFS_POLL
select POLL
help
Enable support for ZVFS event file descriptors. An eventfd can
be used as an event wait/notify mechanism together with POSIX calls
Expand All @@ -33,22 +33,4 @@ config ZVFS_EVENTFD_MAX

endif # ZVFS_EVENTFD

config ZVFS_POLL
bool "ZVFS poll"
select POLL
help
Enable support for zvfs_poll().

if ZVFS_POLL

config ZVFS_POLL_MAX
int "Max number of supported zvfs_poll() entries"
default 6 if WIFI_NM_WPA_SUPPLICANT
default 4 if SHELL_BACKEND_TELNET
default 3
help
Maximum number of entries supported for poll() call.

endif # ZVFS_POLL

endif # ZVFS
212 changes: 0 additions & 212 deletions lib/os/zvfs/zvfs_poll.c

This file was deleted.

3 changes: 1 addition & 2 deletions lib/posix/options/Kconfig.device_io
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ menu "POSIX device I/O"

config POSIX_DEVICE_IO
bool "POSIX device I/O [EXPERIMENTAL]"
select FDTABLE
select EXPERIMENTAL
select REQUIRES_FULL_LIBC
select ZVFS
select ZVFS_POLL
help
Select 'y' here and Zephyr will provide an implementation of the POSIX_DEVICE_IO Option
Group such as FD_CLR(), FD_ISSET(), FD_SET(), FD_ZERO(), close(), fdopen(), fileno(), open(),
Expand Down
3 changes: 2 additions & 1 deletion lib/posix/options/device_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ FUNC_ALIAS(open, _open, int);

int poll(struct pollfd *fds, int nfds, int timeout)
{
return zvfs_poll(fds, nfds, timeout);
/* TODO: create zvfs_poll() and dispatch to subsystems based on file type */
return zsock_poll(fds, nfds, timeout);
}

ssize_t pread(int fd, void *buf, size_t count, off_t offset)
Expand Down
7 changes: 4 additions & 3 deletions subsys/net/lib/sockets/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

menuconfig NET_SOCKETS
bool "BSD Sockets compatible API"
select ZVFS
select ZVFS_POLL
select FDTABLE
help
Provide BSD Sockets like API on top of native Zephyr networking API.

Expand Down Expand Up @@ -48,7 +47,9 @@ config NET_SOCKETS_POSIX_NAMES

config NET_SOCKETS_POLL_MAX
int "Max number of supported poll() entries"
default ZVFS_POLL_MAX
default 6 if WIFI_NM_WPA_SUPPLICANT
default 4 if SHELL_BACKEND_TELNET
default 3
help
Maximum number of entries supported for poll() call.

Expand Down
Loading

0 comments on commit 1df86af

Please sign in to comment.