aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2024-01-19 21:19:57 +0100
committerFlorin Coras <florin.coras@gmail.com>2024-01-20 18:28:09 +0000
commit038dad7ef29b0b724071edb5f8cc7a9845584454 (patch)
treefd49f72aa41a215b73be0409dc1f512e1f82bef2 /src
parent5840c66bbc15b265e280997b028442f9fedd92f6 (diff)
buffers: add compile-time option to set buffer alignment
Type: improvement Change-Id: I88c4c45bed0bdd8686e17e4f77a7d32a08c995aa Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmake/platform/octeon10.cmake1
-rw-r--r--src/vlib/CMakeLists.txt6
-rw-r--r--src/vlib/buffer.c6
-rw-r--r--src/vlib/buffer.h3
-rw-r--r--src/vlib/config.h.in3
5 files changed, 11 insertions, 8 deletions
diff --git a/src/cmake/platform/octeon10.cmake b/src/cmake/platform/octeon10.cmake
index da7dbabdc7b..cc2b292a419 100644
--- a/src/cmake/platform/octeon10.cmake
+++ b/src/cmake/platform/octeon10.cmake
@@ -1,3 +1,4 @@
set(VPP_PLATFORM_CACHE_LINE_SIZE 64)
set(VPP_PLATFORM_MARCH_FLAGS -march=armv8.3-a+crypto+sve2-bitperm)
+set(VPP_PLATFORM_BUFFER_ALIGN 128)
diff --git a/src/vlib/CMakeLists.txt b/src/vlib/CMakeLists.txt
index 76de4edcde2..9c4121672a5 100644
--- a/src/vlib/CMakeLists.txt
+++ b/src/vlib/CMakeLists.txt
@@ -22,6 +22,12 @@ else()
set(BUFFER_ALLOC_FAULT_INJECTOR 0 CACHE STRING "fault injector off")
endif()
+if(VPP_PLATFORM_BUFFER_ALIGN)
+ set(VLIB_BUFFER_ALIGN ${VPP_PLATFORM_BUFFER_ALIGN})
+else()
+ set(VLIB_BUFFER_ALIGN ${VPP_CACHE_LINE_SIZE})
+endif()
+
set(PRE_DATA_SIZE 128 CACHE STRING "Buffer headroom size.")
if (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG")
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c
index 005326d3906..82fe6412781 100644
--- a/src/vlib/buffer.c
+++ b/src/vlib/buffer.c
@@ -471,11 +471,7 @@ static uword
vlib_buffer_alloc_size (uword ext_hdr_size, uword data_size)
{
uword alloc_size = ext_hdr_size + sizeof (vlib_buffer_t) + data_size;
- alloc_size = CLIB_CACHE_LINE_ROUND (alloc_size);
-
- /* in case when we have even number of cachelines, we add one more for
- * better cache occupancy */
- alloc_size |= CLIB_CACHE_LINE_BYTES;
+ alloc_size = round_pow2 (alloc_size, VLIB_BUFFER_ALIGN);
return alloc_size;
}
diff --git a/src/vlib/buffer.h b/src/vlib/buffer.h
index a747ea9f966..7d45689ed19 100644
--- a/src/vlib/buffer.h
+++ b/src/vlib/buffer.h
@@ -47,8 +47,7 @@
#include <vppinfra/lock.h>
#include <vlib/error.h> /* for vlib_error_t */
-#include <vlib/config.h> /* for __PRE_DATA_SIZE */
-#define VLIB_BUFFER_PRE_DATA_SIZE __PRE_DATA_SIZE
+#include <vlib/config.h> /* for VLIB_BUFFER_PRE_DATA_SIZE */
#define VLIB_BUFFER_DEFAULT_DATA_SIZE (2048)
diff --git a/src/vlib/config.h.in b/src/vlib/config.h.in
index 19ec10cfcca..b233b327d31 100644
--- a/src/vlib/config.h.in
+++ b/src/vlib/config.h.in
@@ -16,7 +16,8 @@
#ifndef included_vlib_config_h
#define included_vlib_config_h
-#define __PRE_DATA_SIZE @PRE_DATA_SIZE@
+#define VLIB_BUFFER_PRE_DATA_SIZE @PRE_DATA_SIZE@
+#define VLIB_BUFFER_ALIGN @VLIB_BUFFER_ALIGN@
#define VLIB_BUFFER_ALLOC_FAULT_INJECTOR @BUFFER_ALLOC_FAULT_INJECTOR@
#define VLIB_PROCESS_LOG2_STACK_SIZE @VLIB_PROCESS_LOG2_STACK_SIZE@