Xiang Xiao
9e4a1be8d4
mm/iob: Replace the critical section with spin lock
...
Base on discusion: https://github.com/apache/nuttx/issues/10981
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-30 11:18:34 +02:00
zhanghongyu
13f59128fd
iob: limit the iob bufsize is sufficient to fill all L2/L3/L4 headers
...
rndis header length is 36, L2 header is 14, IPv6 header is 40, tcp header is 56 when sack option count is 4(default max_ofosegs is 4). so the iob bufsize should greater than we need.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-09-20 14:35:22 +08:00
xuxin19
5b6488f09f
cmake:complete missing changes during cmake reforming for mm
...
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2023-09-08 21:20:16 +03: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
e2c9aa6588
mm/iob: Fix IOB length in `iob_reserve`
...
If we apply `iob_reserve` on an IOB with `io_offset != 0`, the `head->io_pktlen` and `iob->io_len` will become wrong value, because we only need to trim `offset - iob->io_offset`.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-22 09:09:21 +08:00
zhanghongyu
1d6b9d3e98
iob: add elapse calc for iob_allocwait
...
Correct the calculation of timeout time
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-08-19 21:22:09 +08:00
zhanghongyu
69667e2c73
iob: iob_clone_partial support Negative offset
...
make the function can correctly handle negative offset cases
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-08-19 01:41:29 +08:00
zhanghongyu
0216224260
iob_alloc: change sem_post to count++
...
if there are two throttled wait, when iob_free occurs, one of wait
will be awakened to execute iob_alloc_committed, but it will fail
to execute, sem will be posted at this time, then another wait will
be awakened. after the other wait thread is awakened, This step is
repeated. the two threads are in the critical_section state and
cannot be switched to other threads. then cpu will busy util timeout.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-08-11 08:54:05 -06: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
Zhe Weng
44a04733d4
mm/iob: Don't return NULL in iob_pack
...
We don't want to get a NULL pointer after iob_pack on an IOB chain with
several iobs with length 0, it should return one IOB with length 0.
Otherwise each place calls iob_pack needs to check the result.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-04-22 19:26:22 +08:00
Zhe Weng
cd1decf4a5
mm/iob: Support neg offset in iob_clone
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-03-08 23:09:25 +02:00
Gustavo Henrique Nihei
e6b204f438
nuttx: Use MIN/MAX definitions from "sys/param.h"
...
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2023-02-01 23:47:44 +08:00
Zhe Weng
be89bcc044
mm/iob: Support negative offset when copyin/out.
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-31 00:39:15 +08:00
chao an
e6b37f2b2d
mm/iob: revert "modify iob to support header padding and alignment features"
...
we don't need to implement l2 isolation through io_head, iob offload will use io_offset
-------------------------------------------------------------
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 |
-------------------------------------------------
--------------------------------------------------------------------
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-21 01:43:02 +08:00
chao an
6e380c0978
mm/iob: add a helper function to get iob count in chain
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-21 01:40:24 +08:00
chao an
4f239e145e
Revert "mm/iob/contig: enhance iob contig to support iob chain"
...
This reverts commit 56a4e90dc4
.
2022-12-19 01:32:05 +08:00
chao an
56a4e90dc4
mm/iob/contig: enhance iob contig to support iob chain
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-18 21:15:47 +08:00
chao an
881c9d9fac
mm/iob: add support of partial bytes clone
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-14 21:37:20 +08:00
chao an
d6d56c3372
mm/iob: add support of nonblock iob_clone
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-14 21:37:20 +08:00
chao an
e2b00a9fcc
mm/iob: reserved bytes should be updated after each iteration
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-07 21:24:25 +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
chao an
cdaa2ba8d4
mm/iob: new function iob_update_pktlen() to update packet length of the iob
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-29 13:16:23 +08:00
chao an
b452e2fddf
mm/iob: new function iob_reserve() to adjust headroom offset
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-29 13:16:23 +08:00
yinshengkai
85f727f232
tools: replace INCDIR to Makefile variable
...
In the past, header file paths were generated by the incdir command
Now they are generated by concatenating environment variables
In this way, when executing makefile, no shell command will be executed,
it will improve the speed of executing makfile
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2022-11-03 19:59:55 +08:00
yinshengkai
95d9abcf58
tools: replace DEFINE script to Makefile variable
...
In the past, predefined macros were generated by define.sh scripts
Now they are generated by concatenating environment variables
In this way, when executing makefile, no shell command will be executed,
it will improve the speed of executing makfile
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2022-11-03 19:59:55 +08:00
anjiahao
e1ca516488
use SEM_INITIALIZER inside of NXSEM_INITIALIZER
...
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
130b196876
Refine how to specify iob and ramlog data section
...
1.Remove the default value(.bss)
2.Remove !ARCH_SIM dependence
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-25 14:05:17 +02: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
luojun1
bee9dcc73a
Add Kconfig option, user can specify the location of g_iob_buffer
...
Signed-off-by: luojun1 <luojun1@xiaomi.com>
2022-08-14 21:00:28 +08:00
luojun1
4e62772be5
modify iob to support header padding and alignment features
...
Signed-off-by: luojun1 <luojun1@xiaomi.com>
2022-08-14 21:00:28 +08:00
Xiang Xiao
c26bb35843
Remove the private NULL, TRUE and FALSE macros
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-07-31 22:12:57 +03:00
Xiang Xiao
1fb8c13e5e
Replace nxsem_timedwait_uninterruptible with nxsem_tickwait_uninterruptible
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-15 13:55:58 +03:00
Xiang Xiao
9072eecc30
sched/wqueue: Change the return type of work_notifier_teardown to void
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-14 00:35:29 +03:00
Xiang Xiao
d9a442a859
mm/iob: Remove initialized static variable inside iob_initialize
...
since it's impossible to call iob_initialize twice
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-12 15:06:39 -03:00
chao.an
0b18cfbd9a
mm/iob: add support of alloc with timeout iob_timedalloc()
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-17 11:55:29 -03:00
Chery Dan
8d799f2148
Fix IOB functions
...
The operations of struct iob_queue_s in qh_head & qh_tail are performed with interrupts disabled.
change iflags to flags
add header file ref
update for check
2021-11-11 08:47:03 -06:00
YAMAMOTO Takashi
5b1f2dff5f
iob_tryalloc: Fix throttled allocation
...
If threads are blocking for throttled allocation,
g_throttle_sem.semcount doesn't represent the number of
usable IOBs well.
Note: For non-throttled allocations, the g_iob_committed mechanism
is a rescue. But there is no equivalent for throttled allocations.
2021-08-02 11:25:55 -07:00
YAMAMOTO Takashi
e96a870485
iob_tryalloc: Remove a wrong assertion
2021-08-02 11:25:55 -07:00
YAMAMOTO Takashi
7a580ae3bc
iob_trimhead: fix an integer truncation
...
I guess this fixes https://github.com/apache/incubator-nuttx/issues/4181
2021-07-20 14:20:29 +08:00
chao.an
ebf89ff63b
mm/iob: add iob_get_queue_size() helper
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-05 06:20:52 -05:00
YAMAMOTO Takashi
314237588e
Add iob_tailroom
...
I plan to use this for tcp.
2021-06-30 06:40:13 -05:00
YAMAMOTO Takashi
7599ca4e95
Kconfig: mention that IOB_NCHAINS is not used by TCP anymore
2021-06-30 06:40:13 -05:00
chao.an
2c51c29768
mm/iob: add an interface to support dequeue an iob from the queue
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-10 10:45:30 -05:00
Xiang Xiao
2e54df0f35
Don't include assert.h from public header file
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-03 08:36:03 -07:00
Alin Jerpelea
3744eb8b5f
mm: update licenses to Apache
...
Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-05-27 08:07:25 +09:00
YAMAMOTO Takashi
f8d56b9da2
iob_trimhead.c: Fix a comment typo
2021-03-16 02:07:34 -07:00
YAMAMOTO Takashi
6b9d2fef00
mm/iob/Kconfig: Fix a typo (other other -> other)
2021-03-16 02:07:34 -07:00
Gustavo Henrique Nihei
330eff36d7
sourcefiles: Fix relative path in file header
2021-03-09 23:18:28 +08:00
Alin Jerpelea
acb8ad4c7b
mm: nxstyle fixes
...
Nxstyle fixes to pass CI
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-09 01:21:53 -08:00