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
Fotis Panagiotopoulos
90a93a7474
Improvements in ICMPv6 connections allocation.
2023-02-20 09:06:46 +08:00
SPRESENSE
277e0b941a
include/sys/socket.h: Add SOCK_CTRL to socket type
...
SOCK_CTRL is added to provide special control over network drivers
and daemons. Currently, SOCK_DGRAM and SOCK_STREAM perform this control,
but these use socket resources. In the case of usersocket in particular,
this is a waste of the device's limited socket resources.
2023-02-16 12:13:01 +09:00
Xiang Xiao
0ef073573a
net: Remove protocol argument from si_setup callback
...
since the implementor could get the same value from socket::s_proto
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-13 22:41:19 +08:00
Masayuki Ishikawa
3f3e090716
Revert "include/sys/socket.h: Add SOCK_CTRL to socket type"
...
This reverts commit abba05a934
.
2023-02-09 09:13:14 +01:00
SPRESENSE
abba05a934
include/sys/socket.h: Add SOCK_CTRL to socket type
...
SOCK_CTRL is added to provide special control over network drivers
and daemons. Currently, SOCK_DGRAM and SOCK_STREAM perform this control,
but these use socket resources. In the case of usersocket in particular,
this is a waste of the device's limited socket resources.
2023-02-08 20:43:33 +08:00
luojun1
861004725a
Fix ICMPv6 RA parsing procedure
...
Signed-off-by: luojun1 <luojun1@xiaomi.com>
2023-01-29 14:32:59 +08:00
梁超众
5012195bde
support ipv4 ToS and ipv6 TrafficClass
...
Signed-off-by: 梁超众 <liangchaozhong@xiaomi.com>
2023-01-29 13:43:44 +08:00
luojun1234
ff3733b5b5
Support fragmentation and reassembly
...
Signed-off-by: luojun1 <luojun1@xiaomi.com>
2023-01-17 14:01:37 +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
chao an
0cbbbb9215
net/devif: reuse devif_send() for can/pkt/icmp stack
...
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
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
Zhe Weng
025430a964
net/icmpv6: Fix icmpv6_reply function
...
Fix icmpv6_reply logic broken by commit 48311cc61f
and 391b501639
.
- 48311cc61f
"Fix unaligned memory access when creating ICMP Port Unreachable messages"
- It removed `htonl` function outside `data`, then the byte order may be wrong, so add `htons` back.
- 391b501639
"net: extract l3 header build code into new functions"
- It mis-removed the `memmove`, and the icmpv6 has no payload copied after this commit.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-02 15:26:45 +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
Zhe Weng
869c93638d
net/icmpv6: Fix ipv6->len
in icmpv6_reply
...
The `ipv6->len` is the length excluding the IPv6 header, so need to be `dev->d_len - IPv6_HDRLEN`.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-24 23:19:10 +08:00
Zhe Weng
a26ea96f3b
net/icmpv6: Fix datalen
in icmpv6_reply
...
The `datalen` indicates the whole len of original packet, which will become the payload inside icmpv6 packet.
Using `datalen = (ipv4->len[0] << 8) + ipv4->len[1]` in icmp_reply is correct, because it includes IPv4 header, but when coming to IPv6, the `len` does not include the header, so we need to add it back.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-24 23:19:10 +08:00
Zhe Weng
233974b327
net/icmpv6: Fix icmpv6 checksum calculation in icmpv6_reply
...
The second param of icmpv6_chksum is `iplen`, which indicates `The size of the IPv6 header`.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-24 23:19:10 +08:00
chao an
873023f89b
net/icmp[v6]: destroy nxsem properly
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-21 01:15:48 +08:00
chao an
6898409d04
net/icmp[v6]: ICMP[v6]_NO_STACK should not depends on NET_IPv4/6
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-20 08:16:20 -03:00
chao an
a8d3286258
net: move device buffer define to common header
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-10-28 00:32:16 -04:00
anjiahao
5724c6b2e4
sem:remove sem default protocl
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-10-22 14:50:48 +08:00
anjiahao
d1d46335df
Replace nxsem API when used as a lock with nxmutex API
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 15:59:46 +09:00
Xiang Xiao
40ef5bc6db
libc: Move queue.h from include to include/nuttx
...
to avoid the conflict with libuv's queue.h
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-26 08:04:58 +02:00
wangbowen6
344c8be049
poll: add poll_notify() api and call it in all drivers
...
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-09-26 12:06:32 +08:00
Xiang Xiao
e0bb281e7a
net: Align the prototype of sock_intf_s::si_ioctl with file_operations::ioctl
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-06 22:46:37 +08:00
chao.an
162fcd10ca
net: cleanup pvconn reference to avoid confuse
...
More reference:
https://github.com/apache/incubator-nuttx/pull/5252
https://github.com/apache/incubator-nuttx/pull/5434
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 20:58:11 +08:00
chao.an
77a99acc98
net/icmpv6: fix build break "duplicate macro parameter"
...
Error: net/icmpv6/icmpv6.h:442:33: error: duplicate macro parameter "d"
# define icmpv6_setaddresses(d,d,p,p) (0)
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 10:00:22 +02:00
zhanghongyu
cc421e43e4
icmpv6: add NTOHL when parse ICMPV6 option MTU
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 10:00:22 +02:00
luojun1
00cf3e559d
update IPv6 NIC parameters unconditionally when ICMPv6 RA is received
...
Signed-off-by: luojun1 <luojun1@xiaomi.com>
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 10:00:22 +02:00
luojun1
7c2986bb34
finetune the RA parsing procedure
...
Signed-off-by: luojun1 <luojun1@xiaomi.com>
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 10:00:22 +02:00
Huang Qi
e4e3208180
Replace all strncpy with strlcpy for safety
...
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-08-25 13:38:36 +08:00
Xiang Xiao
ba9486de4a
iob: Remove iob_user_e enum and related code
...
since it is impossible to track producer and consumer
correctly if TCP/IP stack pass IOB directly to netdev
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-15 08:41:20 +03:00
chao.an
8ae8c10954
net/poll: fix race condition if connect free before poll teardown
...
Net poll teardown is not protected by net lock, if the conn is released
before teardown, the assertion failure will be triggered during free dev
callback, this patch will add the net lock around net poll teardown to
fix race condition
nuttx/libs/libc/assert/lib_assert.c:36
nuttx/net/devif/devif_callback.c:85
nuttx/net/tcp/tcp_netpoll.c:405
nuttx/fs/vfs/fs_poll.c:244
nuttx/fs/vfs/fs_poll.c:500
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-07-09 19:11:42 +08:00
Xiang Xiao
abc72ad128
net: Ensure sendmsg and sendfile return -EAGAIN in case of timeout
...
instead of -ETIMEOUT, as specify here:
https://pubs.opengroup.org/onlinepubs/009604599/functions/sendmsg.html
https://man7.org/linux/man-pages/man2/sendfile.2.html
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-28 06:19:13 +03:00
zhanghongyu
c50d7e174f
net: tcp/udp/icmp/icmpv6 add FIONSPACE support
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-04-02 13:39:38 +08:00
Xiang Xiao
7598070508
net: Remove the unnecessary initialization code
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-12 19:24:17 +02:00
chao.an
3fce144aeb
net/inet: move recv/send timeout into socket_conn_s
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
99cde13a11
net/inet: move socket flags into socket_conn_s
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
e02711e114
net/icmpv6: replace the common connect prologue
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
Petro Karashchenko
08043fb5bc
net: unify FAR keyword usage for all net buffer memory mapped buffers
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-20 01:42:56 +08:00
Petro Karashchenko
9551de7115
net: use HTONS, NTOHS, HTONL, NTOHL macro in kernel code
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-18 10:59:47 +01:00
chao.an
0d7f12c489
net/icmp: fix build break if enable NET_ALLOC_CONNS
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-17 13:34:49 +08:00
chao.an
a1bf9ca88b
net/icmp[v6]: add support for CONFIG_NET_ALLOC_CONNS
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-04 14:36:07 +08:00
Norman Rasmussen
48311cc61f
Fix unaligned memory access when creating ICMP Port Unreachable messages
...
commit 3b69d09c80
corrected the
unreachable handling for net/udp/icmp but introduced an unaligned store.
This splits the uint32_t data field into a two element uint16_t data
field to avoid the unaligned store.
2021-12-28 03:51:53 -06:00
chao.an
3b69d09c80
net/udp/icmp: correct the unreadchable handling
...
Reference RFC1122:
https://datatracker.ietf.org/doc/html/rfc1122
----------------------------------------------
4.1.3 SPECIFIC ISSUES
4.1.3.1 Ports
If a datagram arrives addressed to a UDP port for which
there is no pending LISTEN call, UDP SHOULD send an ICMP
Port Unreachable message.
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-11-26 08:47:54 -06:00
Alexander Lunev
1e25602678
net/can,icmp,icmpv6,tcp,tcp_timer,udp: device should poll only those connections that are bound to the device.
...
tcp_timer: eliminated false decrements of conn->timer in case of multiple network adapters.
The false timer decrements sometimes provoked TCP spurious retransmissions due to premature timeouts.
2021-10-11 23:09:00 -07:00