1
0
Fork 0
forked from nuttx/nuttx-update

net/: Fix some incorrect comments that go back for years (but have also been cloned in newer files). The network was once interrupt driver, but now runs on the work queue with a semaphore to enforce mutual exclusion.

This commit is contained in:
Gregory Nutt 2018-06-23 14:09:06 -06:00
parent a0e169ad7b
commit aabdc00e8c
24 changed files with 98 additions and 138 deletions

View file

@ -63,7 +63,7 @@
* OK if packet has been processed, otherwise ERROR.
*
* Assumptions:
* This function is called at the interrupt level with interrupts disabled.
* This function is called at the with the network disabled.
*
****************************************************************************/

View file

@ -128,9 +128,7 @@ FAR struct bluetooth_conn_s *bluetooth_conn_alloc(void)
{
FAR struct bluetooth_conn_s *conn;
/* The free list is only accessed from user, non-interrupt level and
* is protected by a semaphore (that behaves like a mutex).
*/
/* The free list is protected by the network lock */
net_lock();
conn = (FAR struct bluetooth_conn_s *)
@ -162,9 +160,7 @@ void bluetooth_conn_free(FAR struct bluetooth_conn_s *conn)
FAR struct bluetooth_container_s *container;
FAR struct bluetooth_container_s *next;
/* The free list is only accessed from user, non-interrupt level and
* is protected by a semaphore (that behaves like a mutex).
*/
/* The free list is protected by the network lock. */
DEBUGASSERT(conn->bc_crefs == 0);

View file

@ -73,7 +73,7 @@
****************************************************************************/
/* This structure holds the state of the send operation until it can be
* operated upon from the interrupt level.
* operated upon from the event handler.
*/
struct bluetooth_sendto_s

View file

@ -63,8 +63,7 @@
* in an I/O buffer chain, rather than a flat buffer.
*
* Assumptions:
* Called from the interrupt level or, at a minimum, with interrupts
* disabled.
* Called with the network locked.
*
****************************************************************************/

View file

@ -91,8 +91,7 @@
* no header on the data.
*
* Assumptions:
* Called from the interrupt level or, at a minimum, with interrupts
* disabled.
* Called with the network locked.
*
****************************************************************************/

View file

@ -118,9 +118,7 @@ FAR struct icmp_conn_s *icmp_alloc(void)
FAR struct icmp_conn_s *conn = NULL;
int ret;
/* The free list is only accessed from user, non-interrupt level and
* is protected by a semaphore (that behaves like a mutex).
*/
/* The free list is protected by a semaphore (that behaves like a mutex). */
ret = net_lockedwait(&g_free_sem);
if (ret >= 0)
@ -156,9 +154,7 @@ void icmp_free(FAR struct icmp_conn_s *conn)
{
int ret;
/* The free list is only accessed from user, non-interrupt level and
* is protected by a semaphore (that behaves like a mutex).
*/
/* The free list is protected by a semaphore (that behaves like a mutex). */
DEBUGASSERT(conn->crefs == 0);

View file

@ -127,13 +127,14 @@ static inline int recvfrom_timeout(FAR struct icmp_recvfrom_s *pstate)
* Name: recvfrom_eventhandler
*
* Description:
* This function is called from the interrupt level to perform the actual
* This function is called with the network locked to perform the actual
* ECHO request and/or ECHO reply actions when polled by the lower, device
* interfacing layer.
*
* Input Parameters:
* dev The structure of the network driver that caused the interrupt
* conn The received packet, cast to void *
* dev The structure of the network driver that generated the
* event.
* conn The received packet, cast to (void *)
* pvpriv An instance of struct icmp_recvfrom_s cast to void*
* flags Set of events describing why the callback was invoked
*
@ -274,7 +275,7 @@ end_wait:
* Input Parameters:
* conn - IPPROTO_ICMP socket connection structure containing the read-
* ahead data.
* dev The structure of the network driver that caused the interrupt
* dev The structure of the network driver that generated the event.
* pstate recvfrom state structure
*
* Returned Value:

View file

@ -226,14 +226,15 @@ static void sendto_request(FAR struct net_driver_s *dev,
* Name: sendto_eventhandler
*
* Description:
* This function is called from the interrupt level to perform the actual
* This function is called with the network locked to perform the actual
* ECHO request and/or ECHO reply actions when polled by the lower, device
* interfacing layer.
*
* Input Parameters:
* dev The structure of the network driver that caused the interrupt
* conn The received packet, cast to void *
* pvpriv An instance of struct icmp_sendto_s cast to void*
* dev The structure of the network driver that generated the
* event.
* conn The received packet, cast to (void *)
* pvpriv An instance of struct icmp_sendto_s cast to (void *)
* flags Set of events describing why the callback was invoked
*
* Returned Value:
@ -265,7 +266,7 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev,
/* Check:
* If the outgoing packet is available (it may have been claimed
* by a sendto interrupt serving a different thread)
* by a sendto event handler serving a different thread)
* -OR-
* If the output buffer currently contains unprocessed incoming
* data.

View file

@ -72,7 +72,7 @@
****************************************************************************/
/* This structure holds the state of the send operation until it can be
* operated upon from the interrupt level.
* operated upon by the event handler.
*/
struct icmpv6_router_s

View file

@ -118,9 +118,7 @@ FAR struct icmpv6_conn_s *icmpv6_alloc(void)
FAR struct icmpv6_conn_s *conn = NULL;
int ret;
/* The free list is only accessed from user, non-interrupt level and
* is protected by a semaphore (that behaves like a mutex).
*/
/* The free list is protected by a semaphore (that behaves like a mutex). */
ret = net_lockedwait(&g_free_sem);
if (ret >= 0)
@ -156,9 +154,7 @@ void icmpv6_free(FAR struct icmpv6_conn_s *conn)
{
int ret;
/* The free list is only accessed from user, non-interrupt level and
* is protected by a semaphore (that behaves like a mutex).
*/
/* The free list is protected by a semaphore (that behaves like a mutex). */
DEBUGASSERT(conn->crefs == 0);

View file

@ -77,7 +77,7 @@
****************************************************************************/
/* This structure holds the state of the send operation until it can be
* operated upon from the interrupt level.
* operated upon from the event handler.
*/
struct icmpv6_neighbor_s

View file

@ -130,13 +130,14 @@ static inline int recvfrom_timeout(FAR struct icmpv6_recvfrom_s *pstate)
* Name: recvfrom_eventhandler
*
* Description:
* This function is called from the interrupt level to perform the actual
* This function is called with the network locked to perform the actual
* ECHO request and/or ECHO reply actions when polled by the lower, device
* interfacing layer.
*
* Input Parameters:
* dev The structure of the network driver that caused the interrupt
* conn The received packet, cast to void *
* dev The structure of the network driver that generated the
* event
* conn The received packet, cast to (void *)
* pvpriv An instance of struct icmpv6_recvfrom_s cast to void*
* flags Set of events describing why the callback was invoked
*
@ -277,7 +278,7 @@ end_wait:
* Input Parameters:
* conn - IPPROTO_ICMP6 socket connection structure containing the read-
* ahead data.
* dev The structure of the network driver that caused the interrupt
* dev The structure of the network driver that generated the event.
* pstate recvfrom state structure
*
* Returned Value:

View file

@ -217,14 +217,15 @@ static void sendto_request(FAR struct net_driver_s *dev,
* Name: sendto_eventhandler
*
* Description:
* This function is called from the interrupt level to perform the actual
* This function is called with the network locked to perform the actual
* ECHO request and/or ECHO reply actions when polled by the lower, device
* interfacing layer.
*
* Input Parameters:
* dev The structure of the network driver that caused the interrupt
* pvconn The received packet, cast to void *
* pvpriv An instance of struct icmpv6_sendto_s cast to void*
* dev The structure of the network driver that generated the
* event
* pvconn The received packet, cast to (void *)
* pvpriv An instance of struct icmpv6_sendto_s cast to (void *)
* flags Set of events describing why the callback was invoked
*
* Returned Value:
@ -256,7 +257,7 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev,
/* Check:
* If the outgoing packet is available (it may have been claimed
* by a sendto interrupt serving a different thread)
* by a sendto event handler serving a different thread)
* -OR-
* If the output buffer currently contains unprocessed incoming
* data.
@ -471,10 +472,8 @@ ssize_t icmpv6_sendto(FAR struct socket *psock, FAR const void *buf, size_t len,
netdev_txnotify_dev(dev);
/* Wait for either the send to complete or for timeout to occur. (1)
* net_lockedwait will also terminate if a signal is received, (2)
* interrupts may be disabled! They will be re-enabled while the
* task sleeps and automatically re-enabled when the task restarts.
/* Wait for either the send to complete or for timeout to occur.
* net_lockedwait will also terminate if a signal is received.
*/
ninfo("Start time: 0x%08x\n", state.snd_time);

View file

@ -63,7 +63,7 @@
* OK if packet has been processed, otherwise ERROR.
*
* Assumptions:
* This function is called at the interrupt level with interrupts disabled.
* This function is called with the network locked.
*
****************************************************************************/

View file

@ -122,9 +122,7 @@ FAR struct ieee802154_conn_s *ieee802154_conn_alloc(void)
{
FAR struct ieee802154_conn_s *conn;
/* The free list is only accessed from user, non-interrupt level and
* is protected by a semaphore (that behaves like a mutex).
*/
/* The free list is protected by the network lock. */
net_lock();
conn = (FAR struct ieee802154_conn_s *)
@ -156,9 +154,7 @@ void ieee802154_conn_free(FAR struct ieee802154_conn_s *conn)
FAR struct ieee802154_container_s *container;
FAR struct ieee802154_container_s *next;
/* The free list is only accessed from user, non-interrupt level and
* is protected by a semaphore (that behaves like a mutex).
*/
/* The free list is protected by the network lock. */
DEBUGASSERT(conn->crefs == 0);

View file

@ -69,7 +69,7 @@
****************************************************************************/
/* This structure holds the state of the send operation until it can be
* operated upon from the interrupt level.
* operated upon by the event handler.
*/
struct ieee802154_sendto_s
@ -473,9 +473,9 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
/* Perform the send operation */
/* Initialize the state structure. This is done with interrupts
* disabled because we don't want anything to happen until we
* are ready.
/* Initialize the state structure. This is done with the network
* locked because we don't want anything to happen until we are
* ready.
*/
net_lock();
@ -515,10 +515,8 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
netdev_txnotify_dev(&radio->r_dev);
/* Wait for the send to complete or an error to occur: NOTES: (1)
* net_lockedwait will also terminate if a signal is received, (2)
* interrupts may be disabled! They will be re-enabled while the
* task sleeps and automatically re-enabled when the task restarts.
/* Wait for the send to complete or an error to occur.
* net_lockedwait will also terminate if a signal is received.
*/
ret = net_lockedwait(&state.is_sem);

View file

@ -150,7 +150,7 @@ static inline void inet_update_recvlen(FAR struct inet_recvfrom_s *pstate,
* Copy the read data from the packet
*
* Input Parameters:
* dev The structure of the network driver that caused the interrupt
* dev The structure of the network driver that generated the event.
* pstate recvfrom state structure
*
* Returned Value:
@ -198,7 +198,7 @@ static size_t inet_recvfrom_newdata(FAR struct net_driver_s *dev,
* Copy the read data from the packet
*
* Input Parameters:
* dev The structure of the network driver that caused the interrupt
* dev The structure of the network driver that generated the event
* pstate recvfrom state structure
*
* Returned Value:
@ -270,7 +270,7 @@ static inline void inet_tcp_newdata(FAR struct net_driver_s *dev,
* Copy the read data from the packet
*
* Input Parameters:
* dev The sructure of the network driver that caused the interrupt
* dev The sructure of the network driver that generated the event
* pstate recvfrom state structure
*
* Returned Value:
@ -611,11 +611,11 @@ static inline void inet_tcp_sender(FAR struct net_driver_s *dev,
* Name: inet_tcp_eventhandler
*
* Description:
* This function is called from the interrupt level to perform the actual
* This function is called with the network locked to perform the actual
* TCP receive operation via by the lower, device interfacing layer.
*
* Input Parameters:
* dev The structure of the network driver that caused the interrupt
* dev The structure of the network driver that generated the event.
* pvconn The connection structure associated with the socket
* flags Set of events describing why the callback was invoked
*
@ -974,11 +974,11 @@ static void inet_udp_terminate(FAR struct inet_recvfrom_s *pstate, int result)
* Name: inet_udp_eventhandler
*
* Description:
* This function is called from the interrupt level to perform the actual
* This function is called with the network locked to perform the actual
* UDP receive operation via by the lower, device interfacing layer.
*
* Input Parameters:
* dev The structure of the network driver that caused the interrupt
* dev The structure of the network driver that generated the event.
* pvconn The connection structure associated with the socket
* flags Set of events describing why the callback was invoked
*
@ -1141,7 +1141,7 @@ static void inet_recvfrom_initialize(FAR struct socket *psock, FAR void *buf,
#if defined(NET_UDP_HAVE_STACK) || defined(NET_TCP_HAVE_STACK)
static ssize_t inet_recvfrom_result(int result, struct inet_recvfrom_s *pstate)
{
/* Check for a error/timeout detected by the interrupt handler. Errors are
/* Check for a error/timeout detected by the event handler. Errors are
* signaled by negative errno values for the rcv length
*/
@ -1198,9 +1198,8 @@ static ssize_t inet_udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t
/* Perform the UDP recvfrom() operation */
/* Initialize the state structure. This is done with interrupts
* disabled because we don't want anything to happen until we
* are ready.
/* Initialize the state structure. This is done with the network locked
* because we don't want anything to happen until we are ready.
*/
net_lock();
@ -1273,15 +1272,13 @@ static ssize_t inet_udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t
state.ir_cb->event = inet_udp_eventhandler;
/* Wait for either the receive to complete or for an error/timeout
* to occur. NOTES: (1) net_lockedwait will also terminate if a
* signal is received, (2) interrupts are disabled! They will be
* re-enabled while the task sleeps and automatically re-enabled
* when the task restarts.
* to occur. net_lockedwait will also terminate if a signal is
* received.
*/
ret = net_lockedwait(&state. ir_sem);
/* Make sure that no further interrupts are processed */
/* Make sure that no further events are processed */
udp_callback_free(dev, conn, state.ir_cb);
ret = inet_recvfrom_result(ret, &state);
@ -1325,9 +1322,8 @@ static ssize_t inet_tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t
struct inet_recvfrom_s state;
int ret;
/* Initialize the state structure. This is done with interrupts
* disabled because we don't want anything to happen until we
* are ready.
/* Initialize the state structure. This is done with the network locked
* because we don't want anything to happen until we are ready.
*/
net_lock();
@ -1449,17 +1445,13 @@ static ssize_t inet_tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t
state.ir_cb->event = inet_tcp_eventhandler;
/* Wait for either the receive to complete or for an error/timeout
* to occur.
*
* NOTES: (1) net_lockedwait will also terminate if a signal is
* received, (2) interrupts may be disabled! They will be re-
* enabled while the task sleeps and automatically re-enabled when
* the task restarts.
* to occur. net_lockedwait will also terminate if a signal isi
* received.
*/
ret = net_lockedwait(&state.ir_sem);
/* Make sure that no further interrupts are processed */
/* Make sure that no further events are processed */
tcp_callback_free(conn, state.ir_cb);
ret = inet_recvfrom_result(ret, &state);

View file

@ -189,13 +189,14 @@ static inline bool ipfwd_addrchk(FAR struct forward_s *fwd)
* Name: ipfwd_eventhandler
*
* Description:
* This function is called from the interrupt level to perform the actual
* This function is called with the network locked to perform the actual
* send operation when polled by the lower, device interfacing layer.
*
* Input Parameters:
* dev The structure of the network driver that caused the interrupt
* conn An instance of the forwarding structure cast to void *
* pvpriv An instance of struct forward_s cast to void*
* dev The structure of the network driver that generated the
* event
* conn An instance of the forwarding structure cast to (void *)
* pvpriv An instance of struct forward_s cast to (void *)
* flags Set of events describing why the callback was invoked
*
* Returned Value:

View file

@ -63,7 +63,7 @@
* OK if packet has been processed, otherwise ERROR.
*
* Assumptions:
* This function is called at the interrupt level with interrupts disabled.
* This function is called with the network locked.
*
****************************************************************************/

View file

@ -152,9 +152,7 @@ FAR struct pkt_conn_s *pkt_alloc(void)
{
FAR struct pkt_conn_s *conn;
/* The free list is only accessed from user, non-interrupt level and
* is protected by a semaphore (that behaves like a mutex).
*/
/* The free list is protected by a semaphore (that behaves like a mutex). */
_pkt_semtake(&g_free_sem);
conn = (FAR struct pkt_conn_s *)dq_remfirst(&g_free_pkt_connections);
@ -184,9 +182,7 @@ FAR struct pkt_conn_s *pkt_alloc(void)
void pkt_free(FAR struct pkt_conn_s *conn)
{
/* The free list is only accessed from user, non-interrupt level and
* is protected by a semaphore (that behaves like a mutex).
*/
/* The free list is protected by a semaphore (that behaves like a mutex). */
DEBUGASSERT(conn->crefs == 0);

View file

@ -67,7 +67,7 @@
****************************************************************************/
/* This structure holds the state of the send operation until it can be
* operated upon from the interrupt level.
* operated upon by the event handler.
*/
struct send_s
@ -99,9 +99,9 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
if (pstate)
{
/* Check if the outgoing packet is available. It may have been claimed
* by a send interrupt serving a different thread -OR- if the output
* buffer currently contains unprocessed incoming data. In these cases
* we will just have to wait for the next polling cycle.
* by a send event handler serving a different thread -OR- if the
* output buffer currently contains unprocessed incoming data. In
* these cases we will just have to wait for the next polling cycle.
*/
if (dev->d_sndlen > 0 || (flags & PKT_NEWDATA) != 0)
@ -197,9 +197,8 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
/* Perform the send operation */
/* Initialize the state structure. This is done with interrupts
* disabled because we don't want anything to happen until we
* are ready.
/* Initialize the state structure. This is done with the network locked
* because we don't want anything to happen until we are ready.
*/
net_lock();
@ -235,15 +234,13 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
netdev_txnotify_dev(dev);
/* Wait for the send to complete or an error to occur: NOTES: (1)
* net_lockedwait will also terminate if a signal is received, (2)
* interrupts may be disabled! They will be re-enabled while the
* task sleeps and automatically re-enabled when the task restarts.
/* Wait for the send to complete or an error to occur.
* net_lockedwait will also terminate if a signal is received.
*/
ret = net_lockedwait(&state.snd_sem);
/* Make sure that no further interrupts are processed */
/* Make sure that no further events are processed */
pkt_callback_free(dev, conn, state.snd_cb);
}

View file

@ -71,7 +71,7 @@
* Private Types
****************************************************************************/
/* This is the state data provided to the send interrupt logic. No actions
/* This is the state data provided to the send event handler. No actions
* can be taken until the until we receive the TX poll, then we can call
* sixlowpan_queue_frames() with this data strurcture.
*/
@ -138,11 +138,11 @@ static inline bool send_timeout(FAR struct sixlowpan_send_s *sinfo)
* Name: send_eventhandler
*
* Description:
* This function is called from the interrupt level to perform the actual
* This function is called with the network locked to perform the actual
* send operation when polled by the lower, device interfacing layer.
*
* Input Parameters:
* dev - The structure of the network driver that caused the interrupt
* dev - The structure of the network driver that generated the event.
* conn - The connection structure associated with the socket
* flags - Set of events describing why the callback was invoked
*
@ -251,7 +251,7 @@ end_wait:
*
* Input Parameters:
* dev - The IEEE802.15.4 MAC network driver interface.
* list - Head of callback list for send interrupt
* list - Head of callback list for send events
* ipv6hdr - IPv6 header followed by UDP or ICMPv6 header.
* buf - Data to send
* len - Length of data to send
@ -316,10 +316,8 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
netdev_txnotify_dev(dev);
/* Wait for the send to complete or an error to occur: NOTES: (1)
* net_lockedwait will also terminate if a signal is received, (2) interrupts
* may be disabled! They will be re-enabled while the task sleeps and
* automatically re-enabled when the task restarts.
/* Wait for the send to complete or an error to occur.
* net_lockedwait will also terminate if a signal is received.
*/
ninfo("Wait for send complete\n");
@ -330,7 +328,7 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
sinfo.s_result = ret;
}
/* Make sure that no further interrupts are processed */
/* Make sure that no further events are processed */
devif_conn_callback_free(dev, sinfo.s_cb, list);
}

View file

@ -83,7 +83,7 @@
* Private Types
****************************************************************************/
/* This is the state data provided to the send interrupt logic. No actions
/* This is the state data provided to the send event handler. No actions
* can be taken until the until we receive the TX poll, then we can call
* sixlowpan_queue_frames() with this data strurcture.
*/
@ -325,13 +325,13 @@ static inline bool send_timeout(FAR struct sixlowpan_send_s *sinfo)
* Name: tcp_send_eventhandler
*
* Description:
* This function is called from the interrupt level to perform the actual
* This function is called with the network locked to perform the actual
* TCP send operation when polled by the lower, device interfacing layer.
*
* Input Parameters:
* dev - The structure of the network driver that caused the interrupt
* dev - The structure of the network driver that generated the event.
* pvconn - The connection structure associated with the socket
* pvpriv - The interrupt handler's private data argument
* pvpriv - The event handler's private data argument
* flags - Set of events describing why the callback was invoked
*
* Returned Value:
@ -463,7 +463,7 @@ static uint16_t tcp_send_eventhandler(FAR struct net_driver_s *dev,
}
/* Check if the outgoing packet is available (it may have been claimed
* by a sendto interrupt serving a different thread).
* by a sendto event handler serving a different thread).
*/
#if 0 /* We can't really support multiple senders on the same TCP socket */
@ -708,10 +708,8 @@ static int sixlowpan_send_packet(FAR struct socket *psock,
netdev_txnotify_dev(dev);
/* Wait for the send to complete or an error to occur: NOTES: (1)
* net_lockedwait will also terminate if a signal is received, (2)
* interrupts may be disabled! They will be re-enabled while the
* task sleeps and automatically re-enabled when the task restarts.
/* Wait for the send to complete or an error to occur.
* net_lockedwait will also terminate if a signal is received.
*/
ninfo("Wait for send complete\n");
@ -722,7 +720,7 @@ static int sixlowpan_send_packet(FAR struct socket *psock,
sinfo.s_result = ret;
}
/* Make sure that no further interrupts are processed */
/* Make sure that no further events are processed */
tcp_callback_free(conn, sinfo.s_cb);
}

View file

@ -121,9 +121,7 @@ FAR struct usrsock_conn_s *usrsock_alloc(void)
{
FAR struct usrsock_conn_s *conn;
/* The free list is only accessed from user, non-interrupt level and
* is protected by a semaphore (that behaves like a mutex).
*/
/* The free list is protected by a semaphore (that behaves like a mutex). */
_usrsock_semtake(&g_free_sem);
conn = (FAR struct usrsock_conn_s *)dq_remfirst(&g_free_usrsock_connections);
@ -158,9 +156,7 @@ FAR struct usrsock_conn_s *usrsock_alloc(void)
void usrsock_free(FAR struct usrsock_conn_s *conn)
{
/* The free list is only accessed from user, non-interrupt level and
* is protected by a semaphore (that behaves like a mutex).
*/
/* The free list is protected by a semaphore (that behaves like a mutex). */
DEBUGASSERT(conn->crefs == 0);