net: Add Kconfig for net buf alignment

Add a NET_BUF_ALIGNMENT kconfig to make net buffer alignment configurable.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
This commit is contained in:
Declan Snyder 2023-12-11 10:57:10 -06:00 committed by Carles Cufí
parent 263846dd67
commit e913ccc753
2 changed files with 14 additions and 0 deletions

View file

@ -28,7 +28,11 @@ extern "C" {
*/
/* Alignment needed for various parts of the buffer definition */
#if CONFIG_NET_BUF_ALIGNMENT == 0
#define __net_buf_align __aligned(sizeof(void *))
#else
#define __net_buf_align __aligned(CONFIG_NET_BUF_ALIGNMENT)
#endif
/**
* @brief Define a net_buf_simple stack variable.

View file

@ -51,6 +51,16 @@ config NET_BUF_POOL_USAGE
* total size of the pool is calculated
* pool name is stored and can be shown in debugging prints
config NET_BUF_ALIGNMENT
int "Network buffer alignment restriction"
default 0
help
Alignment restriction for network buffers. This is useful for
some hardware IP with DMA that requires the buffers to be aligned
to a certain byte boundary, or dealing with cache line restrictions.
Default value of 0 means the alignment will be the size of a void pointer,
any other value will force the alignment of a net buffer in bytes.
endif # NET_BUF
config NETWORKING