2007-09-02 23:58:35 +02:00
|
|
|
/****************************************************************************
|
2014-06-29 02:07:02 +02:00
|
|
|
* net/devif/devif.h
|
2007-09-02 23:58:35 +02:00
|
|
|
*
|
2017-03-31 23:09:07 +02:00
|
|
|
* Copyright (C) 2007-2009, 2013-2017 Gregory Nutt. All rights reserved.
|
2012-02-23 03:07:38 +01:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
2007-09-02 23:58:35 +02:00
|
|
|
*
|
|
|
|
* This logic was leveraged from uIP which also has a BSD-style license:
|
|
|
|
*
|
|
|
|
* Author Adam Dunkels <adam@dunkels.com>
|
|
|
|
* Copyright (c) 2001-2003, Adam Dunkels.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote
|
|
|
|
* products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
|
|
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
|
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
|
|
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-01-15 03:44:35 +01:00
|
|
|
#ifndef __NET_DEVIF_DEVIF_H
|
|
|
|
#define __NET_DEVIF_DEVIF_H
|
2007-09-02 23:58:35 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
2007-11-07 00:38:14 +01:00
|
|
|
#include <nuttx/config.h>
|
|
|
|
#ifdef CONFIG_NET
|
|
|
|
|
2009-12-15 15:53:45 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2007-09-23 22:45:30 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <arch/irq.h>
|
2014-06-26 15:29:16 +02:00
|
|
|
|
2014-07-05 03:13:08 +02:00
|
|
|
#include <nuttx/net/ip.h>
|
2007-09-02 23:58:35 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
2014-04-12 20:13:01 +02:00
|
|
|
* Pre-processor Definitions
|
2007-09-02 23:58:35 +02:00
|
|
|
****************************************************************************/
|
2019-11-27 15:09:51 +01:00
|
|
|
|
2014-07-07 01:22:02 +02:00
|
|
|
/* The following flags may be set in the set of flags by the lower, device-
|
|
|
|
* interfacing layer before calling through the socket layer callback. The
|
|
|
|
* TCP_ACKDATA, XYZ_NEWDATA, and TCP_CLOSE flags may be set at the same time,
|
|
|
|
* whereas the others are mutually exclusive.
|
2014-07-05 00:38:51 +02:00
|
|
|
*
|
2015-05-28 16:55:36 +02:00
|
|
|
* Connection Specific Events: These are events that may be notified
|
|
|
|
* through callback lists residing in TCP, UDP, or PKT port connection
|
|
|
|
* structures:
|
|
|
|
*
|
2015-05-27 19:39:44 +02:00
|
|
|
* TCP_ACKDATA IN: Signifies that the outstanding data was ACKed and
|
|
|
|
* the socket layer should send out new data instead
|
2020-06-15 10:23:25 +02:00
|
|
|
* of retransmitting the last data. (TCP only)
|
2015-05-27 19:39:44 +02:00
|
|
|
* OUT: Input state must be preserved on output.
|
|
|
|
*
|
|
|
|
* TCP_NEWDATA IN: Set to indicate that the peer has sent us new data.
|
2020-06-15 10:23:25 +02:00
|
|
|
* UDP_NEWDATA OUT: Cleared (only) by the socket layer logic to
|
|
|
|
* ICMP_NEWDATA indicate that the new data was consumed,
|
|
|
|
* ICMPv6_NEWDATA suppressing further attempts to process the new
|
|
|
|
* PKT_NEWDATA data.
|
2019-11-27 15:09:51 +01:00
|
|
|
* BLUETOOTH_NEWDATA
|
2018-03-31 22:55:03 +02:00
|
|
|
* IEEE802154_NEWDATA
|
2015-01-23 21:06:08 +01:00
|
|
|
*
|
2015-05-27 19:39:44 +02:00
|
|
|
* TCP_SNDACK IN: Not used; always zero
|
2020-06-15 10:23:25 +02:00
|
|
|
* OUT: Set by the socket layer if the new data was
|
|
|
|
* consumed and an ACK should be sent in the response.
|
|
|
|
* (TCP only)
|
2015-01-23 21:06:08 +01:00
|
|
|
*
|
2015-05-27 19:39:44 +02:00
|
|
|
* TCP_REXMIT IN: Tells the socket layer to retransmit the data that
|
|
|
|
* was last sent. (TCP only)
|
|
|
|
* OUT: Not used
|
2015-01-23 21:06:08 +01:00
|
|
|
*
|
2020-06-15 10:23:25 +02:00
|
|
|
* TCP_POLL IN: Used for polling the socket layer. This is
|
|
|
|
* UDP_POLL provided periodically from the drivers to support
|
|
|
|
* PKT_POLL (1) timed operations, and (2) to check if the
|
|
|
|
* BLUETOOTH_POLL socket layer has data that it wants to send.
|
|
|
|
* IEEE802154_POLL These are socket oriented callbacks where the
|
|
|
|
* context depends on the specific set.
|
2015-05-27 23:04:51 +02:00
|
|
|
* OUT: Not used
|
2015-01-23 21:06:08 +01:00
|
|
|
*
|
2015-05-27 19:39:44 +02:00
|
|
|
* TCP_BACKLOG IN: There is a new connection in the backlog list set
|
|
|
|
* up by the listen() command. (TCP only)
|
|
|
|
* OUT: Not used
|
|
|
|
*
|
|
|
|
* TCP_CLOSE IN: The remote host has closed the connection, thus the
|
|
|
|
* connection has gone away. (TCP only)
|
|
|
|
* OUT: The socket layer signals that it wants to close the
|
|
|
|
* connection. (TCP only)
|
|
|
|
*
|
2020-06-15 10:23:25 +02:00
|
|
|
* TCP_ABORT IN: The remote host has aborted the connection, thus
|
|
|
|
* the connection has gone away. (TCP only)
|
2015-05-27 19:39:44 +02:00
|
|
|
* OUT: The socket layer signals that it wants to abort the
|
|
|
|
* connection. (TCP only)
|
|
|
|
*
|
2020-06-15 10:23:25 +02:00
|
|
|
* TCP_CONNECTED IN: We have got a connection from a remote host and
|
|
|
|
* have set up a new connection for it, or an active
|
|
|
|
* connection has been successfully established.
|
|
|
|
* (TCP only)
|
2015-05-27 19:39:44 +02:00
|
|
|
* OUT: Not used
|
|
|
|
*
|
|
|
|
* TCP_TIMEDOUT IN: The connection has been aborted due to too many
|
|
|
|
* retransmissions. (TCP only)
|
|
|
|
* OUT: Not used
|
|
|
|
*
|
2015-05-28 16:55:36 +02:00
|
|
|
* Device Specific Events: These are events that may be notified through
|
|
|
|
* callback lists residing in the network device structure.
|
|
|
|
*
|
2020-06-15 10:23:25 +02:00
|
|
|
* ARP_POLL IN: Used for polling the socket layer. This is
|
|
|
|
* provided periodically from the drivers to support
|
|
|
|
* (1) timed operations, and (2) to check if the ARP
|
|
|
|
* layer needs to send an ARP request. This is a
|
|
|
|
* device oriented event, not associated with a
|
|
|
|
* socket.
|
2015-05-28 16:55:36 +02:00
|
|
|
* OUT: Not used
|
|
|
|
*
|
2020-06-15 10:23:25 +02:00
|
|
|
* ICMP_POLL IN: Used for polling the socket layer. This is
|
|
|
|
* provided periodically from the drivers to support
|
|
|
|
* (1) timed operations, and (2) to check if the ICMP
|
|
|
|
* layer needs to send an ARP request. This is a
|
|
|
|
* device oriented event, not associated with a
|
|
|
|
* socket. This differs from ICMPv6_POLL only in that
|
|
|
|
* the appdata pointer is set differently.
|
2015-05-28 16:55:36 +02:00
|
|
|
* OUT: Not used
|
|
|
|
*
|
2020-06-15 10:23:25 +02:00
|
|
|
* ICMPv6_POLL IN: Used for polling the socket layer. This is
|
|
|
|
* provided periodically from the drivers to support
|
|
|
|
* (1) timed operations, and (2) to check if the ICMP
|
|
|
|
* layer needs to send an ARP request. This is a
|
|
|
|
* device oriented event, not associated with a
|
|
|
|
* socket. This differs from ICMP_POLL only in that
|
|
|
|
* the appdata pointer is set differently.
|
2015-05-28 16:55:36 +02:00
|
|
|
* OUT: Not used
|
|
|
|
*
|
2017-07-08 17:56:08 +02:00
|
|
|
* IPFWD_POLL IN: Used for polling for forwarded packets layer. This
|
2020-06-15 10:23:25 +02:00
|
|
|
* is provided periodically from the drivers to
|
|
|
|
* support to check if there is a packet waiting to be
|
|
|
|
* forward on the device. This is a device oriented
|
|
|
|
* event, not associated with a socket. The appdata
|
|
|
|
* pointer is not used in this case.
|
2017-07-08 17:56:08 +02:00
|
|
|
* OUT: Not used
|
|
|
|
*
|
2015-05-27 19:39:44 +02:00
|
|
|
* NETDEV_DOWN: IN: The network device has been taken down.
|
|
|
|
* OUT: Not used
|
2014-07-05 00:38:51 +02:00
|
|
|
*/
|
|
|
|
|
2017-07-08 17:56:08 +02:00
|
|
|
/* Bits 0-9: Connection specific event bits */
|
2015-05-28 16:55:36 +02:00
|
|
|
|
2017-08-19 16:48:52 +02:00
|
|
|
#define TCP_ACKDATA (1 << 0)
|
|
|
|
#define TCP_NEWDATA (1 << 1)
|
|
|
|
#define UDP_NEWDATA TCP_NEWDATA
|
2019-11-27 15:09:51 +01:00
|
|
|
#define ICMP_NEWDATA TCP_NEWDATA
|
|
|
|
#define ICMPv6_NEWDATA TCP_NEWDATA
|
2018-03-31 22:55:03 +02:00
|
|
|
#define BLUETOOTH_NEWDATA TCP_NEWDATA
|
2017-08-19 16:48:52 +02:00
|
|
|
#define IEEE802154_NEWDATA TCP_NEWDATA
|
|
|
|
#define PKT_NEWDATA TCP_NEWDATA
|
2020-06-15 10:23:25 +02:00
|
|
|
#define CAN_NEWDATA TCP_NEWDATA
|
2017-08-19 16:48:52 +02:00
|
|
|
#define WPAN_NEWDATA TCP_NEWDATA
|
|
|
|
#define IPFWD_NEWDATA TCP_NEWDATA
|
|
|
|
#define TCP_SNDACK (1 << 2)
|
|
|
|
#define TCP_REXMIT (1 << 3)
|
|
|
|
#define TCP_POLL (1 << 4)
|
|
|
|
#define UDP_POLL TCP_POLL
|
|
|
|
#define PKT_POLL TCP_POLL
|
2020-06-15 10:23:25 +02:00
|
|
|
#define CAN_POLL TCP_POLL
|
2018-03-31 22:55:03 +02:00
|
|
|
#define BLUETOOTH_POLL TCP_POLL
|
2017-08-19 16:48:52 +02:00
|
|
|
#define IEEE802154_POLL TCP_POLL
|
|
|
|
#define WPAN_POLL TCP_POLL
|
|
|
|
#define TCP_BACKLOG (1 << 5)
|
|
|
|
#define TCP_CLOSE (1 << 6)
|
|
|
|
#define TCP_ABORT (1 << 7)
|
|
|
|
#define TCP_CONNECTED (1 << 8)
|
|
|
|
#define TCP_TIMEDOUT (1 << 9)
|
2015-05-28 16:55:36 +02:00
|
|
|
|
2019-11-27 15:09:51 +01:00
|
|
|
/* Bits 10-11: Unused, available */
|
|
|
|
|
|
|
|
/* Bit 12: Device specific event bits */
|
2015-05-28 16:55:36 +02:00
|
|
|
|
2017-08-19 16:48:52 +02:00
|
|
|
#define NETDEV_DOWN (1 << 12)
|
2017-07-08 17:56:08 +02:00
|
|
|
|
|
|
|
/* Bits 13-15: Encoded device specific poll events. Unlike connection
|
|
|
|
* oriented poll events, device related poll events must distinguish
|
|
|
|
* between what is being polled for since the callbacks all reside in
|
|
|
|
* the same list in the network device structure.
|
|
|
|
*/
|
|
|
|
|
2017-08-19 16:48:52 +02:00
|
|
|
#define DEVPOLL_SHIFT (13)
|
|
|
|
#define DEVPOLL_MASK (7 << DEVPOLL_SHIFT)
|
|
|
|
# define DEVPOLL_NONE (0 << DEVPOLL_SHIFT)
|
|
|
|
# define ARP_POLL (1 << DEVPOLL_SHIFT)
|
|
|
|
# define ICMP_POLL (2 << DEVPOLL_SHIFT)
|
|
|
|
# define ICMPv6_POLL (3 << DEVPOLL_SHIFT)
|
|
|
|
# define IPFWD_POLL (4 << DEVPOLL_SHIFT)
|
2014-07-07 01:22:02 +02:00
|
|
|
|
2015-05-28 16:55:36 +02:00
|
|
|
/* The set of events that and implications to the TCP connection state */
|
|
|
|
|
2015-05-30 17:12:27 +02:00
|
|
|
#define TCP_CONN_EVENTS \
|
|
|
|
(TCP_CLOSE | TCP_ABORT | TCP_CONNECTED | TCP_TIMEDOUT | NETDEV_DOWN)
|
|
|
|
|
|
|
|
#define TCP_DISCONN_EVENTS \
|
|
|
|
(TCP_CLOSE | TCP_ABORT | TCP_TIMEDOUT | NETDEV_DOWN)
|
2007-09-02 23:58:35 +02:00
|
|
|
|
2015-01-17 14:42:09 +01:00
|
|
|
/* IPv4/IPv6 Helpers */
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IPv4
|
|
|
|
# define DEVIF_IS_IPv4(dev) IFF_IS_IPv4(dev->d_flags)
|
|
|
|
#else
|
|
|
|
# define DEVIF_IS_IPv4(dev) (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IPv6
|
|
|
|
# define DEVIF_IS_IPv6(dev) IFF_IS_IPv6(dev->d_flags)
|
|
|
|
#else
|
|
|
|
# define DEVIF_IS_IPv6(dev) (0)
|
|
|
|
#endif
|
|
|
|
|
2007-09-02 23:58:35 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Type Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-05-28 20:01:38 +02:00
|
|
|
/* Describes a connection/device event callback interface
|
2014-07-05 00:38:51 +02:00
|
|
|
*
|
2015-05-28 20:01:38 +02:00
|
|
|
* nxtconn - Supports a singly linked list that supports connection
|
|
|
|
* specific event handlers.
|
|
|
|
* nxtdev - Supports a singly linked list that supports device specific
|
|
|
|
* event handlers
|
2014-07-05 00:38:51 +02:00
|
|
|
* event - Provides the address of the callback function entry point.
|
2015-05-28 20:01:38 +02:00
|
|
|
* pvconn is a pointer to a connection-specific datat structure
|
|
|
|
* such as struct tcp_conn_s or struct udp_conn_s.
|
2014-07-07 01:22:02 +02:00
|
|
|
* priv - Holds a reference to socket layer specific data that will
|
2014-07-05 00:38:51 +02:00
|
|
|
* provided
|
2014-07-07 01:22:02 +02:00
|
|
|
* flags - Set by the socket layer to inform the lower layer which flags
|
2015-05-28 20:01:38 +02:00
|
|
|
* are and are not handled by the callback.
|
2014-07-05 00:38:51 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct net_driver_s; /* Forward reference */
|
2017-03-31 16:58:14 +02:00
|
|
|
|
|
|
|
typedef CODE uint16_t (*devif_callback_event_t)(FAR struct net_driver_s *dev,
|
|
|
|
FAR void *pvconn,
|
|
|
|
FAR void *pvpriv,
|
|
|
|
uint16_t flags);
|
|
|
|
|
2014-07-05 00:38:51 +02:00
|
|
|
struct devif_callback_s
|
|
|
|
{
|
2015-05-28 20:01:38 +02:00
|
|
|
FAR struct devif_callback_s *nxtconn;
|
2021-09-21 05:43:31 +02:00
|
|
|
FAR struct devif_callback_s *prevconn;
|
2015-05-28 20:01:38 +02:00
|
|
|
FAR struct devif_callback_s *nxtdev;
|
2017-03-31 16:58:14 +02:00
|
|
|
FAR devif_callback_event_t event;
|
2014-07-05 00:38:51 +02:00
|
|
|
FAR void *priv;
|
|
|
|
uint16_t flags;
|
|
|
|
};
|
|
|
|
|
2007-09-02 23:58:35 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
2007-11-07 00:38:14 +01:00
|
|
|
|
2017-08-07 21:03:23 +02:00
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
#define EXTERN extern "C"
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
2007-11-07 00:38:14 +01:00
|
|
|
|
2007-09-02 23:58:35 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-06-29 02:07:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: devif_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform initialization of the network device interface layer
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2014-06-29 02:07:02 +02:00
|
|
|
* None
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2014-06-29 02:07:02 +02:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void devif_initialize(void);
|
|
|
|
|
2014-06-25 18:34:52 +02:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: devif_callback_init
|
2014-06-25 18:34:52 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Configure the pre-allocated callback structures into a free list.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2016-02-25 17:43:51 +01:00
|
|
|
* This function must be called with the network locked.
|
2014-06-25 18:34:52 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2008-09-01 15:59:54 +02:00
|
|
|
|
2014-06-29 02:36:09 +02:00
|
|
|
void devif_callback_init(void);
|
2008-09-01 15:59:54 +02:00
|
|
|
|
2014-06-25 18:34:52 +02:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: devif_callback_alloc
|
2014-06-25 18:34:52 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Allocate a callback container from the free list.
|
|
|
|
*
|
2015-06-03 16:11:57 +02:00
|
|
|
* If dev is non-NULL, then this function verifies that the device
|
|
|
|
* reference is still valid and that the device is still UP status. If
|
|
|
|
* those conditions are not true, this function will fail to allocate the
|
|
|
|
* callback.
|
|
|
|
*
|
2014-06-25 18:34:52 +02:00
|
|
|
* Assumptions:
|
2016-02-25 17:43:51 +01:00
|
|
|
* This function must be called with the network locked.
|
2014-06-25 18:34:52 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-05-28 20:01:38 +02:00
|
|
|
FAR struct devif_callback_s *
|
|
|
|
devif_callback_alloc(FAR struct net_driver_s *dev,
|
net/devif/devif_callback.c: corrected the connection event list to work as FIFO instead of LIFO.
In case of enabled packet forwarding mode, packets were forwarded in a reverse order
because of LIFO behavior of the connection event list.
The issue exposed only during high network traffic. Thus the event list started to grow
that resulted in changing the order of packets inside of groups of several packets
like the following: 3, 2, 1, 6, 5, 4, 8, 7 etc.
Remarks concerning the connection event list implementation:
* Now the queue (list) is FIFO as it should be.
* The list is singly linked.
* The list has a head pointer (inside of outer net_driver_s structure),
and a tail pointer is added into outer net_driver_s structure.
* The list item is devif_callback_s structure.
It still has two pointers to two different list chains (*nxtconn and *nxtdev).
* As before the first argument (*dev) of the list functions can be NULL,
while the other argument (*list) is effective (not NULL).
* An extra (*tail) argument is added to devif_callback_alloc()
and devif_conn_callback_free() functions.
* devif_callback_alloc() time complexity is O(1) (i.e. O(n) to fill the whole list).
* devif_callback_free() time complexity is O(n) (i.e. O(n^2) to empty the whole list).
* devif_conn_event() time complexity is O(n).
2021-08-29 22:57:26 +02:00
|
|
|
FAR struct devif_callback_s **list_head,
|
|
|
|
FAR struct devif_callback_s **list_tail);
|
2014-06-25 18:34:52 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: devif_conn_callback_free
|
2014-06-25 18:34:52 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2015-06-03 16:11:57 +02:00
|
|
|
* Return a connection/port callback container to the free list.
|
|
|
|
*
|
|
|
|
* This function is just a front-end for devif_callback_free(). If the
|
|
|
|
* dev argument is non-NULL, it will verify that the device reference is
|
|
|
|
* still valid before attempting to free the callback structure. A
|
|
|
|
* non-NULL list pointer is assumed to be valid in any case.
|
|
|
|
*
|
|
|
|
* The callback structure will be freed in any event.
|
2014-06-25 18:34:52 +02:00
|
|
|
*
|
|
|
|
* Assumptions:
|
2016-02-25 17:43:51 +01:00
|
|
|
* This function must be called with the network locked.
|
2015-06-03 16:11:57 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void devif_conn_callback_free(FAR struct net_driver_s *dev,
|
|
|
|
FAR struct devif_callback_s *cb,
|
net/devif/devif_callback.c: corrected the connection event list to work as FIFO instead of LIFO.
In case of enabled packet forwarding mode, packets were forwarded in a reverse order
because of LIFO behavior of the connection event list.
The issue exposed only during high network traffic. Thus the event list started to grow
that resulted in changing the order of packets inside of groups of several packets
like the following: 3, 2, 1, 6, 5, 4, 8, 7 etc.
Remarks concerning the connection event list implementation:
* Now the queue (list) is FIFO as it should be.
* The list is singly linked.
* The list has a head pointer (inside of outer net_driver_s structure),
and a tail pointer is added into outer net_driver_s structure.
* The list item is devif_callback_s structure.
It still has two pointers to two different list chains (*nxtconn and *nxtdev).
* As before the first argument (*dev) of the list functions can be NULL,
while the other argument (*list) is effective (not NULL).
* An extra (*tail) argument is added to devif_callback_alloc()
and devif_conn_callback_free() functions.
* devif_callback_alloc() time complexity is O(1) (i.e. O(n) to fill the whole list).
* devif_callback_free() time complexity is O(n) (i.e. O(n^2) to empty the whole list).
* devif_conn_event() time complexity is O(n).
2021-08-29 22:57:26 +02:00
|
|
|
FAR struct devif_callback_s **list_head,
|
|
|
|
FAR struct devif_callback_s **list_tail);
|
2015-06-03 16:11:57 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: devif_dev_callback_free
|
2015-06-03 16:11:57 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Return a device callback container to the free list.
|
|
|
|
*
|
|
|
|
* This function is just a front-end for devif_callback_free(). If the
|
|
|
|
* de argument is non-NULL, it will verify that the device reference is
|
|
|
|
* still valid before attempting to free the callback structure. It
|
|
|
|
* differs from devif_conn_callback_free in that connection/port-related
|
|
|
|
* connections are also associated with the device and, hence, also will
|
|
|
|
* not be valid if the device pointer is not valid.
|
|
|
|
*
|
|
|
|
* The callback structure will be freed in any event.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2016-02-25 17:43:51 +01:00
|
|
|
* This function must be called with the network locked.
|
2014-06-25 18:34:52 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2014-06-12 19:52:06 +02:00
|
|
|
|
2015-06-03 16:11:57 +02:00
|
|
|
void devif_dev_callback_free(FAR struct net_driver_s *dev,
|
|
|
|
FAR struct devif_callback_s *cb);
|
2014-06-12 19:52:06 +02:00
|
|
|
|
2014-06-25 18:34:52 +02:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: devif_conn_event
|
2014-06-25 18:34:52 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Execute a list of callbacks.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2015-05-27 19:39:44 +02:00
|
|
|
* dev - The network device state structure associated with the network
|
|
|
|
* device that initiated the callback event.
|
|
|
|
* pvconn - Holds a reference to the TCP connection structure or the UDP
|
2022-01-17 22:08:54 +01:00
|
|
|
* port structure. It can be NULL if the event is not related to a TCP
|
2015-05-27 19:39:44 +02:00
|
|
|
* connection or UDP port.
|
2015-05-28 20:01:38 +02:00
|
|
|
* flags - The bit set of events to be notified.
|
|
|
|
* list - The list to traverse in performing the notifications
|
2015-05-27 19:39:44 +02:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2015-05-27 19:39:44 +02:00
|
|
|
* The updated flags as modified by the callback functions.
|
|
|
|
*
|
2014-06-25 18:34:52 +02:00
|
|
|
* Assumptions:
|
2016-02-25 17:43:51 +01:00
|
|
|
* This function must be called with the network locked.
|
2014-06-25 18:34:52 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2014-06-12 19:52:06 +02:00
|
|
|
|
2015-05-28 20:01:38 +02:00
|
|
|
uint16_t devif_conn_event(FAR struct net_driver_s *dev, FAR void *pvconn,
|
|
|
|
uint16_t flags, FAR struct devif_callback_s *list);
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: devif_dev_event
|
2015-05-28 20:01:38 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Execute a list of callbacks using the device event chain.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2015-05-28 20:01:38 +02:00
|
|
|
* dev - The network device state structure associated with the network
|
|
|
|
* device that initiated the callback event.
|
|
|
|
* pvconn - Holds a reference to the TCP connection structure or the UDP
|
2022-01-17 22:08:54 +01:00
|
|
|
* port structure. It can be NULL if the event is not related to a TCP
|
2015-05-28 20:01:38 +02:00
|
|
|
* connection or UDP port.
|
|
|
|
* flags - The bit set of events to be notified.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2015-05-28 20:01:38 +02:00
|
|
|
* The updated flags as modified by the callback functions.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2016-02-25 17:43:51 +01:00
|
|
|
* This function must be called with the network locked.
|
2015-05-28 20:01:38 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
uint16_t devif_dev_event(FAR struct net_driver_s *dev, void *pvconn,
|
|
|
|
uint16_t flags);
|
2014-06-12 19:52:06 +02:00
|
|
|
|
2014-06-25 18:34:52 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Send data on the current connection.
|
|
|
|
*
|
2014-07-07 01:22:02 +02:00
|
|
|
* This function is used to send out a single segment of TCP data. Only
|
|
|
|
* socket logic that have been invoked by the lower level for event
|
2014-06-25 18:34:52 +02:00
|
|
|
* processing can send data.
|
|
|
|
*
|
|
|
|
* The amount of data that actually is sent out after a call to this
|
2016-05-30 17:31:44 +02:00
|
|
|
* function is determined by the maximum amount of data TCP allows. The
|
|
|
|
* network will automatically crop the data so that only the appropriate
|
2015-08-27 16:39:17 +02:00
|
|
|
* amount of data is sent. The mss field of the TCP connection structure
|
|
|
|
* can be used to determine the amount of data that actually will be sent.
|
2014-06-25 18:34:52 +02:00
|
|
|
*
|
2014-07-07 01:22:02 +02:00
|
|
|
* Note: This function does not guarantee that the sent data will
|
|
|
|
* arrive at the destination. If the data is lost in the network, the
|
|
|
|
* TCP socket layer will be invoked with the TCP_REXMIT flag set. The
|
|
|
|
* socket layer will then have to resend the data using this function.
|
2014-06-25 18:34:52 +02:00
|
|
|
*
|
|
|
|
* data A pointer to the data which is to be sent.
|
|
|
|
*
|
|
|
|
* len The maximum amount of data bytes to be sent.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2014-06-12 19:52:06 +02:00
|
|
|
|
2014-06-29 02:36:09 +02:00
|
|
|
void devif_send(FAR struct net_driver_s *dev, FAR const void *buf, int len);
|
2014-06-12 19:52:06 +02:00
|
|
|
|
2015-05-28 20:01:38 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: devif_iob_send
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called from socket logic in response to a xmit or poll request from the
|
|
|
|
* the network interface driver.
|
|
|
|
*
|
|
|
|
* This is identical to calling devif_send() except that the data is
|
|
|
|
* in an I/O buffer chain, rather than a flat buffer.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2016-02-25 17:43:51 +01:00
|
|
|
* This function must be called with the network locked.
|
2015-05-28 20:01:38 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2017-05-09 15:34:59 +02:00
|
|
|
#ifdef CONFIG_MM_IOB
|
2014-06-25 18:34:52 +02:00
|
|
|
struct iob_s;
|
2014-06-29 02:36:09 +02:00
|
|
|
void devif_iob_send(FAR struct net_driver_s *dev, FAR struct iob_s *buf,
|
|
|
|
unsigned int len, unsigned int offset);
|
2014-06-25 18:34:52 +02:00
|
|
|
#endif
|
2014-06-12 19:52:06 +02:00
|
|
|
|
2015-05-28 20:01:38 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: devif_pkt_send
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called from socket logic in order to send a raw packet in response to
|
2017-05-11 21:35:56 +02:00
|
|
|
* an xmit or poll request from the network interface driver.
|
2015-05-28 20:01:38 +02:00
|
|
|
*
|
|
|
|
* This is almost identical to calling devif_send() except that the data to
|
|
|
|
* be sent is copied into dev->d_buf (vs. dev->d_appdata), since there is
|
|
|
|
* no header on the data.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2016-02-25 17:43:51 +01:00
|
|
|
* This function must be called with the network locked.
|
2015-05-28 20:01:38 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-06-15 10:23:25 +02:00
|
|
|
#if defined(CONFIG_NET_PKT)
|
2014-06-29 02:36:09 +02:00
|
|
|
void devif_pkt_send(FAR struct net_driver_s *dev, FAR const void *buf,
|
|
|
|
unsigned int len);
|
2014-06-25 18:34:52 +02:00
|
|
|
#endif
|
2014-06-12 19:52:06 +02:00
|
|
|
|
2020-06-15 10:23:25 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: devif_can_send
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called from socket logic in order to send a raw packet in response to
|
|
|
|
* an xmit or poll request from the network interface driver.
|
|
|
|
*
|
|
|
|
* This is almost identical to calling devif_send() except that the data to
|
|
|
|
* be sent is copied into dev->d_buf (vs. dev->d_appdata), since there is
|
|
|
|
* no header on the data.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function must be called with the network locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#if defined(CONFIG_NET_CAN)
|
|
|
|
void devif_can_send(FAR struct net_driver_s *dev, FAR const void *buf,
|
|
|
|
unsigned int len);
|
|
|
|
#endif
|
|
|
|
|
2007-09-02 23:58:35 +02:00
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-11-07 00:38:14 +01:00
|
|
|
#endif /* CONFIG_NET */
|
2022-01-15 03:44:35 +01:00
|
|
|
#endif /* __NET_DEVIF_DEVIF_H */
|