From e913ccc75354537627e6735892aaa20ba268ffe9 Mon Sep 17 00:00:00 2001 From: Declan Snyder Date: Mon, 11 Dec 2023 10:57:10 -0600 Subject: [PATCH] net: Add Kconfig for net buf alignment Add a NET_BUF_ALIGNMENT kconfig to make net buffer alignment configurable. Signed-off-by: Declan Snyder --- include/zephyr/net/buf.h | 4 ++++ subsys/net/Kconfig | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/zephyr/net/buf.h b/include/zephyr/net/buf.h index 948517428f..94b0b9a753 100644 --- a/include/zephyr/net/buf.h +++ b/include/zephyr/net/buf.h @@ -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. diff --git a/subsys/net/Kconfig b/subsys/net/Kconfig index fad47cfe88..57706cd2f5 100644 --- a/subsys/net/Kconfig +++ b/subsys/net/Kconfig @@ -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