Commit Graph

359 Commits

Author SHA1 Message Date
wangchen 99ee94728a net:add IP_MULTICAST_IF & IPV6_MULTICAST_IF function implementation
refer to https://man7.org/linux/man-pages/man7/ip.7.html
IP_MULTICAST_IF (since Linux 1.2)
              Set the local device for a multicast socket.  The argument
              for setsockopt(2) is an ip_mreqn or (since Linux 3.5)
              ip_mreq structure similar to IP_ADD_MEMBERSHIP, or an
              in_addr structure.  (The kernel determines which structure
              is being passed based on the size passed in optlen.)  For
              getsockopt(2), the argument is an in_addr structure.
refer to https://man7.org/linux/man-pages/man7/ipv6.7.html
IPV6_MULTICAST_IF
              Set the device for outgoing multicast packets on the
              socket.  This is allowed only for SOCK_DGRAM and SOCK_RAW
              socket.  The argument is a pointer to an interface index
              (see netdevice(7)) in an integer.
testcase1:
TEST_IMPL(udp_multicast_interface) {
/* TODO(gengjiawen): Fix test on QEMU. */
  RETURN_SKIP("Test does not currently work in QEMU");

  int r;
  uv_udp_send_t req;
  uv_buf_t buf;
  struct sockaddr_in addr;
  struct sockaddr_in baddr;

  close_cb_called = 0;
  sv_send_cb_called = 0;
  ASSERT(0 == uv_ip4_addr("239.255.0.1", TEST_PORT, &addr));

  r = uv_udp_init(uv_default_loop(), &server);
  ASSERT(r == 0);

  ASSERT(0 == uv_ip4_addr("0.0.0.0", 0, &baddr));
  r = uv_udp_bind(&server, (const struct sockaddr*)&baddr, 0);
  ASSERT(r == 0);

  r = uv_udp_set_multicast_interface(&server, "0.0.0.0");
  ASSERT(r == 0);

  /* server sends "PING" */
  buf = uv_buf_init("PING", 4);
  r = uv_udp_send(&req,
                  &server,
                  &buf,
                  1,
                  (const struct sockaddr*)&addr,
                  sv_send_cb);
  ASSERT(r == 0);

  ASSERT(close_cb_called == 0);
  ASSERT(sv_send_cb_called == 0);

  /* run the loop till all events are processed */
  uv_run(uv_default_loop(), UV_RUN_DEFAULT);

  ASSERT(sv_send_cb_called == 1);
  ASSERT(close_cb_called == 1);

  ASSERT(client.send_queue_size == 0);
  ASSERT(server.send_queue_size == 0);

  MAKE_VALGRIND_HAPPY();
  return 0;
}
testcase2:
TEST_IMPL(udp_multicast_interface6) {
/* TODO(gengjiawen): Fix test on QEMU. */
  RETURN_SKIP("Test does not currently work in QEMU");

  int r;
  uv_udp_send_t req;
  uv_buf_t buf;
  struct sockaddr_in6 addr;
  struct sockaddr_in6 baddr;

  if (!can_ipv6())
    RETURN_SKIP("IPv6 not supported");

  close_cb_called = 0;
  sv_send_cb_called = 0;

  ASSERT(0 == uv_ip6_addr("::1", TEST_PORT, &addr));

  r = uv_udp_init(uv_default_loop(), &server);
  ASSERT(r == 0);

  ASSERT(0 == uv_ip6_addr("::", 0, &baddr));
  r = uv_udp_bind(&server, (const struct sockaddr*)&baddr, 0);
  ASSERT(r == 0);

  r = uv_udp_set_multicast_interface(&server, "::1%lo0");
  r = uv_udp_set_multicast_interface(&server, NULL);
  ASSERT(r == 0);

  /* server sends "PING" */
  buf = uv_buf_init("PING", 4);
  r = uv_udp_send(&req,
                  &server,
                  &buf,
                  1,
                  (const struct sockaddr*)&addr,
                  sv_send_cb);
  ASSERT(r == 0);

  ASSERT(close_cb_called == 0);
  ASSERT(sv_send_cb_called == 0);

  /* run the loop till all events are processed */
  uv_run(uv_default_loop(), UV_RUN_DEFAULT);

  ASSERT(sv_send_cb_called == 1);
  ASSERT(close_cb_called == 1);

  MAKE_VALGRIND_HAPPY();
  return 0;
}

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2023-08-25 17:16:50 +08:00
Ville Juven 9cd8ea32d1 net/xx/wrbuffer: Do not use SEM_INITIALIZER for buffers
Using the macro places the buffers into .data section which means they
will consume the full buffer size of flash / read only memory as well.

Place the buffers into .bss to avoid this case.
2023-08-25 00:02:07 +08:00
Zhe Weng d44e19d115 mm/iob: Add support for increasing length in iob_update_pktlen
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-22 16:34:21 +09:00
Zhe Weng efc75de61e net/udp: Fix hybrid dual-stack IPv6/IPv4 socket
- Fix `ip6_map_ipv4addr` and `ip6_get_ipv4addr` macro to work under
  different endianness.
- Use `iob_reserve` instead of `iob_trimhead` in `udp_datahandler`.
  - Because we may set `sockaddr_in6` into IPv4 header, which causes
    `offset` become negative. `iob_reserve` can hold this case while
    `iob_trimhead` cannot.
- Select IPv4 domain in send case.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-22 09:09:21 +08:00
Zhe Weng d3bca3c2cf net: Add FIOC_FILEPATH ioctl support for ICMP(v6)/RPMsg/Usrsock sockets
Example of /proc/PID/group/fd in this case:

FD  OFLAGS  TYPE POS       PATH
3   3       9    0         icmp:[dev eth0, id 1, flg 1]
4   3       9    0         icmp6:[dev eth0, id 2, flg 1]
5   3       9    0         rpmsg:[ap:[test:0]<->remote] # server side
5   3       9    0         rpmsg:[remote<->ap:[test:0]] # client side

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-15 15:00:59 +08:00
Zhe Weng d98bfc3e49 net/icmpv6: Fix `icmpv6_neighbor` for link-local address
The netdev of link-local address cannot be auto decided, and the link-local address should always be reguarded as address on local network.

The problem we met:
When using `icmpv6_autoconfig` with multiple netdev, the `icmpv6_neighbor` may take out wrong netdev with ip address already set, then it may send solicitation with wrong address (`dev->d_ipv6draddr`) on wrong device, and regard the link-local address as conflict (because `dev->d_ipv6draddr` exists on this network).

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-11 02:00:39 +08:00
Zhe Weng 817a43de4d net: Add FIOC_FILEPATH ioctl support for tcp/udp/local sockets
Example of /proc/PID/group/fd, which prints the file path:

FD  OFLAGS  TYPE POS       PATH
0   3       1    0         /dev/console
1   3       1    0         /dev/console
2   3       1    0         /dev/console
3   3       9    0         udp:[0.0.0.0:10197<->114.118.7.163:123, tx 0/16384, rx 0/16384, flg 1]
4   1027    9    0         tcp:[0.0.0.0:23<->0.0.0.0:0, tx 0/16384, rx 0/16384 + ofo 0, st 01, flg 31]
5   67      9    0         local:[md:ap]

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-07 08:08:37 -07:00
wangchen b10d6be17a net:Add check for address binding
Signed-off-by: wangchen <wangchen41@xiaomi.com>
2023-08-03 03:16:31 -07:00
wangchen 842b6b88d3 net/udp:add check of the ip packet length
Signed-off-by: wangchen <wangchen41@xiaomi.com>
2023-08-03 00:15:28 -07:00
Petro Karashchenko 6621dc016b net/udp: remove FAR from non-pointer variables
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-07-31 18:56:40 -07:00
Zhe Weng 075eb6a6d2 net/udp: Change conn->readahead to I/O buffer chain
When using IOB queue to store readahead data, we use one IOB for each
UDP packet. Then if the packets are very small, like 10Bytes per packet,
we'll use ~1600 IOBs just for 16KB recv buffer size, which is wasteful
and dangerous. So change conn->readahead to a single IOB chain like TCP.

Benefits:
- Using memory and IOBs more efficiently (small packets are common in
  UDP)

Side effects:
- UDP recv buffer size may count the overhead
- A little bit drop in performance (<1%, more seek & copy)

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-07-18 10:51:45 +08:00
Xiang Xiao abfe082a6f Kconfig: Simplify the conditional default statement
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-16 14:39:20 -03:00
wangyingdong a7926405ca net/udp: Fix the bug of overwriting when the udp recv buffer is full
Signed-off-by: wangyingdong <wangyingdong@xiaomi.com>
2023-07-14 07:53:37 +02:00
wangyingdong 57bf3e1fea net: Add msg_peek support for udp and tcp
Signed-off-by: wangyingdong <wangyingdong@xiaomi.com>
2023-07-13 19:40:04 +08:00
chao an 6ee9ec7656 build: add initial cmake build system
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)

------------------

How to test

From within nuttx/. Configure:

cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja

(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja

This uses ninja generator (install with sudo apt install ninja-build). To build:

$ cmake --build build

menuconfig:

$ cmake --build build -t menuconfig

--------------------------

2. cmake/build: reformat the cmake style by cmake-format

https://github.com/cheshirekow/cmake_format

$ pip install cmakelang

$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done

Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-08 13:50:48 +08:00
Stuart Ianna 30f8cf541c net/udp: Populate the udp connection structure with the address family.
The udp connection structure contains the field, "domain", which defines which address family it belongs to. Prior to this change, this field was only populated correctly if IPv4 and IPv6 was enabled. As a result, packet information was not processed in udp_recvpktinfo, as expected when the appropriate socket option was enabled.
2023-06-27 14:58:12 +08:00
Fotis Panagiotopoulos 3c54d82d81 net: Fix task block when devif_send fails.
When a task needs to send data, a callback is allocated and the
transmission is happening in a worker task through devif_send.
Synchronization between the two tasks (sender & worker) is
achieved by a semaphore.

If devif_send fails, this semaphore was never posted, leaving
the sending task blocked indefinitely. This commit fixes this
by checking the return code of netif_send, and posting this
semaphore in case of failure.

Polling then stops, and execution is resumed on the sending
task.
2023-06-01 17:05:54 +08:00
chao an 589d4a9f8e net/semantic/parser: fix compile warning found by sparse
Reference:
https://linux.die.net/man/1/sparse

Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-30 23:00:00 +08:00
Petro Karashchenko b944886659 net/udp: remove FAR for non-pointer variables
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-05-19 02:40:38 +08:00
liqinhui a9640bad1a net: Add the check that socket domain is equal to bound address type, when do bind.
When do socket bind, if the connection domain is not equal to the bound address type, this will cause the stack-buffer-overflow.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-05-18 01:08:38 +03:00
zhanghongyu 1def5da221 net: move ttl field into socket_conn_s struct
move ttl filed from udp_conn_s to socket_conn_s structure to make it more than just control udp.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-13 12:39:53 +08:00
zhanghongyu 91e13c47ae net: remove conn-related casts
remove redundant casts associated with psock

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-10 19:32:09 -03:00
zhanghongyu e10fda570b udp: change PKTINFO flag to socket_conn_s struct
move the IPPROTO_IP/IPPROTO_IPV6 flag into the socket_conn_s structure to
make it more than just control udp.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-09 07:53:56 +02:00
Zhe Weng 26e2e1e32f net/udp: Remove wrong check in udp_readahead
- Before IOB offload, srcaddr / src_addr_size / ifindex are written into
  IOB by iob_trycopyin, so io_pktlen > 0 is always true, this check is
  correct at that time. (It won't fail with zero-length UDP datagram.)
- After IOB offload, srcaddr / src_addr_size / ifindex are written into
  offset 0, without increasing io_pktlen. So this check will fail with
  zero-length UDP datagram now.
- We need to support zero-length UDP datagram and this check is
  unnecessary at this point.
  - https://stackoverflow.com/questions/5307031/how-to-detect-receipt-of-a-0-length-udp-datagram
  - https://github.com/apache/nuttx/blob/nuttx-12.1.0/net/udp/udp_callback.c#L214

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-05-05 11:25:07 +03:00
zhanghongyu c288752bef recvmsg: control msg support multi-attribute return
adapts to third-party code compilation. in the process of porting ConnMan,
multiple control message options are enabled, such as IPV6_RECVPKTINFO and
IPV6_RECVHOPLIMIT, so I changed the Filling implementation of the control
message.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-04 12:04:11 +02:00
Fotis Panagiotopoulos 5e625b9cdb Performance optimizations in connection allocations. 2023-02-28 14:23:16 +01:00
Xiang Xiao 2c5f653bfd Remove the tail spaces from all files except Documentation
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-26 13:24:24 -08:00
Zhe Weng 0069eefd4b net/udp: Add drop count when limited by recv bufsize
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-02-24 14:36:01 +02:00
Fotis Panagiotopoulos 7f3591b9cc Improvements in UDP connections allocation. 2023-02-20 09:06:46 +08:00
zhanghongyu a2097cfb71 net: modify find device logic
The priorities for finding a network adapter are as follows:
1. if laddr is not ANY, use laddr to find device;
2. if laddr is ANY, and bound index is not 0, use bound index
   to find device;
3. if laddr is ANY and no device is bound, use raddr to find
   device.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-02-12 01:25:34 +08:00
Zhe Weng aad1a70bc5 net/udp: Support binding to same addr/port if SO_REUSEADDR is specified.
Ref: On Linux, if SO_REUSEADDR(sk_reuse) is set for both sockets, port will not be regarded as inuse. https://github.com/torvalds/linux/blob/v6.1/net/ipv4/udp.c#L146

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-02-10 10:01:08 +01:00
zhanghongyu 3e4e416786 tcp/udp_connect: If the remote addr is ANY, change it to LOOPBACK
Behavior alignment to Linux

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-29 13:46:43 +08:00
梁超众 5012195bde support ipv4 ToS and ipv6 TrafficClass
Signed-off-by: 梁超众 <liangchaozhong@xiaomi.com>
2023-01-29 13:43:44 +08:00
zhanghongyu 1857a4a3c8 udp: Ipv4/6 can be bound to the same port
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-28 23:28:33 +02:00
zhanghongyu 99c2d2009a udp: remove DEBUGASSERT for ip6_is_ipv4addr
fix build break if enable CONFIG_NET_IPv6 only

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-28 09:04:29 +02:00
chao an 2afa1b3b64 net/udp: correct linger timeout
UDP linger timeout will be wrongly converted to UINT_MAX by _SO_TIMEOUT() when it is set to 0,

net/socket/socket.h:
|
| #  define _SO_TIMEOUT(t) ((t) ? (t) * MSEC_PER_DSEC : UINT_MAX)

net/udp/udp_close.c:
|
| if (_SO_GETOPT(conn->sconn.s_options, SO_LINGER))
|   {
|     timeout = _SO_TIMEOUT(conn->sconn.s_linger);
|   }

this change will correct this behavior, if the linger is set to 0, the timeout value should be 0

Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-18 02:47:12 +08:00
Xiang Xiao a851ad84c3 net: consistent the net sem wait naming conversion
to prepare the new mutex wait function

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-15 12:31:30 -03:00
chao an 8a63d29c6e net/devif_poll: optimize device buffer alloc in txpoll
Allocate the device buffer only if the protocol really need to send data.
not all protocols require the driver to prepare additional iob before
sending, especially UDP, each iob reserves l2/l3 header in advance
after prepare write buffer, net device could reuse this entry to send directly

Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-13 16:41:10 +08:00
Zhe Weng 6222ad5764 Revert "net: downgrade iob priority of input/udp/icmp to avoid blocking devif"
This reverts commit d87620abc9.
2023-01-12 01:56:18 +08:00
Zhe Weng d87620abc9 net: downgrade iob priority of input/udp/icmp to avoid blocking devif
When trying to use iperf2, we found it comsumes all the IOB when sending UDP packets, then devif_poll has no IOB to send the packet out, so speed drops to 0 and never recovers.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-05 22:25:19 +08:00
Xiang Xiao d5689e070b net/arp: Remove nuttx/net/arp.h
1.move ARPHRD_ETHER to netinet/arp.h
1.move arp_entry_s to net/arp/arp.h
2.move arp_input to nuttx/net/netdev.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-16 22:10:59 +02:00
chao an 3a50911810 net/udp: correct udp send timeout
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-16 09:51:15 +08:00
chao an 11de08de27 net/devif_send: replace all block send to nonblock mode
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-08 09:53:15 +01:00
chao an 82d67b201a net/offload: add offload support for pkt/arp
1. add offload support for pkt/arp
2. Reset the d_buf to NULL if d_iob has released

Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-04 01:34:30 +08:00
chao an 34d2cde8a8 net/l2/l3/l4: add support of iob offload
1. Add new config CONFIG_NET_LL_GUARDSIZE to isolation of l2 stack,
   which will benefit l3(IP) layer for multi-MAC(l2) implementation,
   especially in some NICs such as celluler net driver.

new configuration options: CONFIG_NET_LL_GUARDSIZE

CONFIG_NET_LL_GUARDSIZE will reserved l2 buffer header size of
network buffer to isolate the L2/L3 (MAC/IP) data on network layer,
which will be beneficial to L3 network layer protocol transparent
transmission and forwarding

------------------------------------------------------------
Layout of frist iob entry:

        iob_data (aligned by CONFIG_IOB_ALIGNMENT)
            |
            |                  io_offset(CONFIG_NET_LL_GUARDSIZE)
            |                                |
            -------------------------------------------------
      iob   |            Reserved            |    io_len    |
            -------------------------------------------------

-------------------------------------------------------------
Layout of different NICs implementation:

        iob_data (aligned by CONFIG_IOB_ALIGNMENT)
            |
            |                 io_offset(CONFIG_NET_LL_GUARDSIZE)
            |                                |
            -------------------------------------------------
 Ethernet   |       Reserved    | ETH_HDRLEN |    io_len    |
            ---------------------------------|---------------
 8021Q      |   Reserved  | ETH_8021Q_HDRLEN |    io_len    |
            ---------------------------------|---------------
 ipforward  |            Reserved            |    io_len    |
            -------------------------------------------------

--------------------------------------------------------------------

2. Support iob offload to l2 driver to avoid unnecessary memory copy

Support send/receive iob vectors directly between the NICs and l3/l4
stack to avoid unnecessary memory copies, especially on hardware that
supports Scatter/gather, which can greatly improve performance.

new interface to support iob offload:

  ------------------------------------------
  |    IOB version     |     original      |
  |----------------------------------------|
  |  devif_iob_poll()  |   devif_poll()    |
  |       ...          |       ...         |
  ------------------------------------------

--------------------------------------------------------------------

1> NIC hardware support Scatter/gather transfer

TX:

                tcp_poll()/udp_poll()/pkt_poll()/...(l3|l4)
                           /              \
                          /                \
devif_poll_[l3|l4]_connections()     devif_iob_send() (nocopy:udp/icmp/...)
           /                                   \      (copy:tcp)
          /                                     \
  devif_iob_poll("NIC"_txpoll)                callback() // "NIC"_txpoll
                                                  |
                            dev->d_iob:           |
                                                ---------------         ---------------
                             io_data       iob1 |  |          |    iob3 |  |          |
                                    \           ---------------         ---------------
                                  ---------------  |       --------------- |
                             iob0 |  |          |  |  iob2 |  |          | |
                                  ---------------  |       --------------- |
                                     \             |          /           /
                                        \          |       /           /
                                   ----------------------------------------------
                    NICs io vector |    |    |    |    |    |    |    |    |    |
                                   ----------------------------------------------

RX:

  [tcp|udp|icmp|...]ipv[4|6]_data_handler()(iob_concat/append to readahead)
                    |
                    |
      [tcp|udp|icmp|...]_ipv[4|6]_in()/...
                    |
                    |
          pkt/ipv[4/6]_input()/...
                    |
                    |
     NICs io vector receive(iov_base to each iobs)

--------------------------------------------------------------------

2> CONFIG_IOB_BUFSIZE is greater than MTU:

TX:

"(CONFIG_IOB_BUFSIZE) > (MAX_NETDEV_PKTSIZE + CONFIG_NET_GUARDSIZE + CONFIG_NET_LL_GUARDSIZE)"

                tcp_poll()/udp_poll()/pkt_poll()/...(l3|l4)
                           /              \
                          /                \
devif_poll_[l3|l4]_connections()     devif_iob_send() (nocopy:udp/icmp/...)
           /                                   \      (copy:tcp)
          /                                     \
  devif_iob_poll("NIC"_txpoll)                callback() // "NIC"_txpoll
                                                  |
                                             "NIC"_send()
                          (dev->d_iob->io_data[CONFIG_NET_LL_GUARDSIZE - NET_LL_HDRLEN(dev)])

RX:

  [tcp|udp|icmp|...]ipv[4|6]_data_handler()(iob_concat/append to readahead)
                    |
                    |
      [tcp|udp|icmp|...]_ipv[4|6]_in()/...
                    |
                    |
          pkt/ipv[4/6]_input()/...
                    |
                    |
     NICs io vector receive(iov_base to io_data)

--------------------------------------------------------------------

3> Compatible with all old flat buffer NICs

TX:
                tcp_poll()/udp_poll()/pkt_poll()/...(l3|l4)
                           /              \
                          /                \
devif_poll_[l3|l4]_connections()     devif_iob_send() (nocopy:udp/icmp/...)
           /                                   \      (copy:tcp)
          /                                     \
  devif_iob_poll(devif_poll_callback())  devif_poll_callback() /* new interface, gather iobs to flat buffer */
       /                                           \
      /                                             \
 devif_poll("NIC"_txpoll)                     "NIC"_send()(dev->d_buf)

RX:

  [tcp|udp|icmp|...]ipv[4|6]_data_handler()(iob_concat/append to readahead)
                    |
                    |
      [tcp|udp|icmp|...]_ipv[4|6]_in()/...
                    |
                    |
               netdev_input()  /* new interface, Scatter/gather flat/iob buffer */
                    |
                    |
          pkt/ipv[4|6]_input()/...
                    |
                    |
    NICs io vector receive(Orignal flat buffer)

3. Iperf passthrough on NuttX simulator:

  -------------------------------------------------
  |  Protocol      | Server | Client |            |
  |-----------------------------------------------|
  |  TCP           |  813   |   834  |  Mbits/sec |
  |  TCP(Offload)  | 1720   |  1100  |  Mbits/sec |
  |  UDP           |   22   |   757  |  Mbits/sec |
  |  UDP(Offload)  |   25   |  1250  |  Mbits/sec |
  -------------------------------------------------

Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-03 11:47:04 +08:00
liyi 391b501639 net: extract l3 header build code into new functions
Signed-off-by: liyi <liyi25@xiaomi.com>
2022-11-29 18:36:15 +08:00
chao an d54a20b393 net/tcp/udp: remove all domain assertion
fix build break if enable CONFIG_NET_IPv6 only

In file included from tcp/tcp_sendfile.c:38:
tcp/tcp_sendfile.c: In function ‘sendfile_eventhandler’:
tcp/tcp_sendfile.c:173:27: error: ‘struct tcp_conn_s’ has no member named ‘domain’
  173 |           DEBUGASSERT(conn->domain == PF_INET6);
      |                           ^~

Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-29 17:28:36 +08:00
chao an 3caa551ff4 net: remove psock reference from connect
Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-24 22:57:42 +08:00
Xiang Xiao 7f380533a3 net/udp: NET_BROADCAST shouldn't configurable if NET_UDP_NO_STACK enable
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-22 20:45:26 +09:00
anjiahao d07792a343 Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-14 09:34:04 +09:00