Skip to content

Commit e4a1905

Browse files
jukkarnashif
authored andcommitted
net: Add alignment support for net_buf data length alloc
The alignment value tells the amount of alignment of buffer length when allocating net_buf data for sending. By default there is no special alignment. This is needed for example with Nordic Wi-Fi chip that uses SPI driver that expects 4 byte alignment for the length of the data that is being sent. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
1 parent fd0b148 commit e4a1905

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

subsys/net/ip/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,18 @@ config NET_PKT_BUF_USER_DATA_SIZE
907907
help
908908
User data size used in rx and tx network buffers.
909909

910+
config NET_PKT_BUF_TX_DATA_ALLOC_ALIGN_LEN
911+
int "Amount of alignment for TX net_buf allocations"
912+
default 0
913+
range 0 8
914+
depends on NET_BUF_VARIABLE_DATA_SIZE
915+
help
916+
This value tell amount of alignment of buffer length when allocating
917+
net_buf data for sending. By default there is no special alignment.
918+
This is needed for example with Nordic Wi-Fi chip that uses SPI driver
919+
that expects 4 byte alignment for the length of the data and the start
920+
of the data that is being sent.
921+
910922
config NET_HEADERS_ALWAYS_CONTIGUOUS
911923
bool
912924
help

subsys/net/ip/net_pkt.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,11 @@ NET_BUF_POOL_FIXED_DEFINE(tx_bufs, CONFIG_NET_BUF_TX_COUNT, CONFIG_NET_BUF_DATA_
142142

143143
NET_BUF_POOL_VAR_DEFINE(rx_bufs, CONFIG_NET_BUF_RX_COUNT, CONFIG_NET_PKT_BUF_RX_DATA_POOL_SIZE,
144144
CONFIG_NET_PKT_BUF_USER_DATA_SIZE, NULL);
145-
NET_BUF_POOL_VAR_DEFINE(tx_bufs, CONFIG_NET_BUF_TX_COUNT, CONFIG_NET_PKT_BUF_TX_DATA_POOL_SIZE,
146-
CONFIG_NET_PKT_BUF_USER_DATA_SIZE, NULL);
145+
146+
NET_BUF_POOL_VAR_ALIGN_DEFINE(tx_bufs, CONFIG_NET_BUF_TX_COUNT,
147+
CONFIG_NET_PKT_BUF_TX_DATA_POOL_SIZE,
148+
CONFIG_NET_PKT_BUF_USER_DATA_SIZE, NULL,
149+
CONFIG_NET_PKT_BUF_TX_DATA_ALLOC_ALIGN_LEN);
147150

148151
#endif /* CONFIG_NET_BUF_FIXED_DATA_SIZE */
149152

tests/drivers/wifi/nrf_wifi/testcase.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ tests:
4040
drivers.wifi.build.p2p:
4141
extra_configs:
4242
- CONFIG_NRF70_P2P_MODE=y
43+
drivers.wifi.build.tx_align:
44+
extra_configs:
45+
- CONFIG_NET_PKT_BUF_TX_DATA_ALLOC_ALIGN_LEN=4
46+
- CONFIG_NET_BUF_VARIABLE_DATA_SIZE=y

0 commit comments

Comments
 (0)