Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ CONFIG_NET_BROADCAST=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_NOTIFIER=y
CONFIG_NET_TCP_WRITE_BUFFERS=y
CONFIG_NET_UDP=y
CONFIG_NFILE_DESCRIPTORS=8
Expand Down Expand Up @@ -90,7 +91,6 @@ CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_MDIO=y
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_TCP_NOTIFIER=y
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USERMAIN_STACKSIZE=4096
CONFIG_USER_ENTRYPOINT="nsh_main"
Expand Down
30 changes: 0 additions & 30 deletions include/nuttx/wqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,36 +309,6 @@ struct work_notifier_s
worker_t worker; /* The worker function to schedule */
};

/* This structure describes one notification list entry. It is cast-
* compatible with struct work_notifier_s. This structure is an allocated
* container for the user notification data. It is allocated because it
* must persist until the work is executed and must be freed using
* kmm_free() by the work.
*
* With the work notification is scheduled, the work function will receive
* the allocated instance of struct work_notifier_entry_s as its input
* argument. When it completes the notification operation, the work function
* is responsible for freeing that instance.
*/

struct work_notifier_entry_s
{
/* This must appear at the beginning of the structure. A reference to
* the struct work_notifier_entry_s instance must be cast-compatible with
* struct dq_entry_s.
*/

struct work_s work; /* Used for scheduling the work */

/* User notification information */

struct work_notifier_s info; /* The notification info */

/* Additional payload needed to manage the notification */

int16_t key; /* Unique ID for the notification */
};

/****************************************************************************
* Public Data
****************************************************************************/
Expand Down
7 changes: 0 additions & 7 deletions net/bluetooth/bluetooth_recvfrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,6 @@ ssize_t bluetooth_recvfrom(FAR struct socket *psock, FAR void *buf,
(void)nxsem_init(&state.ir_sem, 0, 0); /* Doesn't really fail */
(void)nxsem_setprotocol(&state.ir_sem, SEM_PRIO_NONE);

/* Set the socket state to receiving */

psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_RECV);

/* Set up the callback in the connection */

state.ir_cb = bluetooth_callback_alloc(&radio->r_dev, conn);
Expand Down Expand Up @@ -418,9 +414,6 @@ ssize_t bluetooth_recvfrom(FAR struct socket *psock, FAR void *buf,
ret = -EBUSY;
}

/* Set the socket state to idle */

psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
nxsem_destroy(&state.ir_sem);

errout_with_lock:
Expand Down
8 changes: 0 additions & 8 deletions net/bluetooth/bluetooth_sendto.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,6 @@ ssize_t psock_bluetooth_sendto(FAR struct socket *psock, FAR const void *buf,
return -ENODEV;
}

/* Set the socket state to sending */

psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_SEND);

/* Perform the send operation */

/* Initialize the state structure. This is done with the network locked
Expand Down Expand Up @@ -345,10 +341,6 @@ ssize_t psock_bluetooth_sendto(FAR struct socket *psock, FAR const void *buf,
nxsem_destroy(&state.is_sem);
net_unlock();

/* Set the socket state to idle */

psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);

/* Check for a errors, Errors are signaled by negative errno values
* for the send length
*/
Expand Down
6 changes: 5 additions & 1 deletion net/icmp/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ if NET_ICMP && !NET_ICMP_NO_STACK
config NET_ICMP_SOCKET
bool "IPPROTO_ICMP socket support"
default n
select MM_IOB
---help---
Enable support for IPPROTO_ICMP sockets. These sockets are needed
for application level support for sending ECHO (ping) requests and
Expand All @@ -35,7 +36,10 @@ if NET_ICMP_SOCKET
config NET_ICMP_NCONNS
int "Max ICMP packet sockets"
default 4
depends on MM_IOB

config NET_ICMP_NPOLLWAITERS
int "Number of ICMP poll waiters"
default 1

endif # NET_ICMP_SOCKET
endif # NET_ICMP && !NET_ICMP_NO_STACK
Expand Down
5 changes: 1 addition & 4 deletions net/icmp/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ NET_CSRCS += icmp_input.c

ifeq ($(CONFIG_NET_ICMP_SOCKET),y)
SOCK_CSRCS += icmp_sockif.c icmp_poll.c icmp_conn.c icmp_sendto.c
SOCK_CSRCS += icmp_recvfrom.c
ifeq ($(CONFIG_MM_IOB),y)
SOCK_CSRCS += icmp_netpoll.c
endif
SOCK_CSRCS += icmp_recvfrom.c icmp_netpoll.c
endif

# Include ICMP build support
Expand Down
25 changes: 19 additions & 6 deletions net/icmp/icmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,24 @@
* Public types
****************************************************************************/

struct socket; /* Forward reference */
struct sockaddr; /* Forward reference */
struct pollfd; /* Forward reference */

#ifdef CONFIG_NET_ICMP_SOCKET
/* Representation of a IPPROTO_ICMP socket connection */

struct devif_callback_s; /* Forward reference */

/* This is a container that holds the poll-related information */

struct icmp_poll_s
{
FAR struct socket *psock; /* IPPROTO_ICMP socket structure */
FAR struct pollfd *fds; /* Needed to handle poll events */
FAR struct devif_callback_s *cb; /* Needed to teardown the poll */
};

struct icmp_conn_s
{
/* Common prologue of all connection structures. */
Expand All @@ -97,14 +110,18 @@ struct icmp_conn_s

FAR struct net_driver_s *dev; /* Needed to free the callback structure */

#ifdef CONFIG_MM_IOB
/* ICMP response read-ahead list. A singly linked list of type struct
* iob_qentry_s where the ICMP read-ahead data for the current ID is
* retained.
*/

struct iob_queue_s readahead; /* Read-ahead buffering */
#endif

/* The following is a list of poll structures of threads waiting for
* socket events.
*/

struct icmp_poll_s pollinfo[CONFIG_NET_ICMP_NPOLLWAITERS];
};
#endif

Expand All @@ -130,10 +147,6 @@ EXTERN const struct sock_intf_s g_icmp_sockif;
* Public Function Prototypes
****************************************************************************/

struct socket; /* Forward reference */
struct sockaddr; /* Forward reference */
struct pollfd; /* Forward reference */

/****************************************************************************
* Name: icmp_input
*
Expand Down
48 changes: 14 additions & 34 deletions net/icmp/icmp_netpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,12 @@
#include <poll.h>
#include <debug.h>

#include <nuttx/kmalloc.h>
#include <nuttx/net/net.h>

#include <devif/devif.h>
#include "devif/devif.h"
#include "netdev/netdev.h"
#include "icmp/icmp.h"

#ifdef CONFIG_MM_IOB

/****************************************************************************
* Private Types
****************************************************************************/

/* This is an allocated container that holds the poll-related information */

struct icmp_poll_s
{
FAR struct socket *psock; /* IPPROTO_ICMP socket structure */
FAR struct pollfd *fds; /* Needed to handle poll events */
FAR struct devif_callback_s *cb; /* Needed to teardown the poll */
};

/****************************************************************************
* Private Functions
****************************************************************************/
Expand Down Expand Up @@ -178,18 +162,22 @@ int icmp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)

DEBUGASSERT(conn != NULL && fds != NULL);

/* Allocate a container to hold the poll information */

info = (FAR struct icmp_poll_s *)kmm_malloc(sizeof(struct icmp_poll_s));
if (!info)
{
return -ENOMEM;
}

/* Some of the following must be atomic */

net_lock();

/* Find a container to hold the poll information */

info = conn->pollinfo;
while (info->psock != NULL)
{
if (++info >= &conn->pollinfo[CONFIG_NET_ICMP_NPOLLWAITERS])
{
ret = -ENOMEM;
goto errout_with_lock;
}
}

/* Allocate a ICMP callback structure */

cb = icmp_callback_alloc(conn->dev, conn);
Expand Down Expand Up @@ -249,11 +237,7 @@ int icmp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
nxsem_post(fds->sem);
}

net_unlock();
return OK;

errout_with_lock:
kmm_free(info);
net_unlock();
return ret;
}
Expand Down Expand Up @@ -293,20 +277,16 @@ int icmp_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds)
{
/* Release the callback */

net_lock();
icmp_callback_free(conn->dev, conn, info->cb);
net_unlock();

/* Release the poll/select data slot */

info->fds->priv = NULL;

/* Then free the poll info container */

kmm_free(info);
info->psock = NULL;
}

return OK;
}

#endif /* !CONFIG_MM_IOB */
4 changes: 0 additions & 4 deletions net/icmp/icmp_sockif.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ int icmp_listen(FAR struct socket *psock, int backlog)
static int icmp_netpoll(FAR struct socket *psock, FAR struct pollfd *fds,
bool setup)
{
#ifdef CONFIG_MM_IOB
/* Check if we are setting up or tearing down the poll */

if (setup)
Expand All @@ -460,9 +459,6 @@ static int icmp_netpoll(FAR struct socket *psock, FAR struct pollfd *fds,

return icmp_pollteardown(psock, fds);
}
#else
return -ENOSYS;
#endif /* CONFIG_MM_IOB */
}

/****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion net/icmpv6/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if NET_ICMPv6 && !NET_ICMPv6_NO_STACK
config NET_ICMPv6_SOCKET
bool "IPPROTO_ICMP6 socket support"
default n
select MM_IOB
---help---
Enable support for IPPROTO_ICMP6 sockets. These sockets are needed
for application level support for sending ICMPv7 ECHO requests and
Expand Down Expand Up @@ -203,7 +204,10 @@ if NET_ICMPv6_SOCKET
config NET_ICMPv6_NCONNS
int "Max ICMPv6 packet sockets"
default 4
depends on MM_IOB

config NET_ICMPv6_NPOLLWAITERS
int "Number of ICMPv6 poll waiters"
default 1

endif # NET_ICMPv6_SOCKET

Expand Down
5 changes: 1 addition & 4 deletions net/icmpv6/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ NET_CSRCS += icmpv6_linkipaddr.c

ifeq ($(CONFIG_NET_ICMPv6_SOCKET),y)
SOCK_CSRCS += icmpv6_sockif.c icmpv6_conn.c icmpv6_sendto.c
SOCK_CSRCS += icmpv6_recvfrom.c
ifeq ($(CONFIG_MM_IOB),y)
SOCK_CSRCS += icmpv6_netpoll.c
endif
SOCK_CSRCS += icmpv6_recvfrom.c icmpv6_netpoll.c
endif

ifeq ($(CONFIG_NET_ICMPv6_NEIGHBOR),y)
Expand Down
29 changes: 21 additions & 8 deletions net/icmpv6/icmpv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,26 @@
* Public Type Definitions
****************************************************************************/

struct timespec; /* Forward reference */
struct net_driver_s; /* Forward reference */
struct socket; /* Forward reference */
struct sockaddr; /* Forward reference */
struct pollfd; /* Forward reference */

#ifdef CONFIG_NET_ICMPv6_SOCKET
/* Representation of a IPPROTO_ICMP socket connection */

struct devif_callback_s; /* Forward reference */

/* This is a container that holds the poll-related information */

struct icmpv6_poll_s
{
FAR struct socket *psock; /* IPPROTO_ICMP6 socket structure */
FAR struct pollfd *fds; /* Needed to handle poll events */
FAR struct devif_callback_s *cb; /* Needed to teardown the poll */
};

struct icmpv6_conn_s
{
/* Common prologue of all connection structures. */
Expand All @@ -98,14 +113,18 @@ struct icmpv6_conn_s

FAR struct net_driver_s *dev; /* Needed to free the callback structure */

#ifdef CONFIG_MM_IOB
/* ICMPv6 response read-ahead list. A singly linked list of type struct
* iob_qentry_s where the ICMPv6 read-ahead data for the current ID is
* retained.
*/

struct iob_queue_s readahead; /* Read-ahead buffering */
#endif

/* The following is a list of poll structures of threads waiting for
* socket events.
*/

struct icmpv6_poll_s pollinfo[CONFIG_NET_ICMPv6_NPOLLWAITERS];
};
#endif

Expand Down Expand Up @@ -155,12 +174,6 @@ EXTERN const struct sock_intf_s g_icmpv6_sockif;
* Public Function Prototypes
****************************************************************************/

struct timespec; /* Forward reference */
struct net_driver_s; /* Forward reference */
struct socket; /* Forward reference */
struct sockaddr; /* Forward reference */
struct pollfd; /* Forward reference */

/****************************************************************************
* Name: icmpv6_input
*
Expand Down
Loading