aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/odp_buffer_internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'platform/linux-generic/include/odp_buffer_internal.h')
-rw-r--r--platform/linux-generic/include/odp_buffer_internal.h99
1 files changed, 25 insertions, 74 deletions
diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h
index a580c82d5..66b2a454c 100644
--- a/platform/linux-generic/include/odp_buffer_internal.h
+++ b/platform/linux-generic/include/odp_buffer_internal.h
@@ -1,10 +1,8 @@
-/* Copyright (c) 2013, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2013-2018 Linaro Limited
+ * Copyright (c) 2019-2021 Nokia
*/
-
/**
* @file
*
@@ -24,88 +22,41 @@ extern "C" {
#include <odp/api/buffer.h>
#include <odp/api/debug.h>
#include <odp/api/align.h>
-#include <odp_align_internal.h>
#include <odp_config_internal.h>
#include <odp/api/byteorder.h>
#include <odp/api/thread.h>
#include <odp/api/event.h>
-#include <odp_forward_typedefs_internal.h>
-#include <odp_schedule_if.h>
+#include <odp_event_internal.h>
#include <stddef.h>
-#define BUFFER_BURST_SIZE CONFIG_BURST_SIZE
-
-/* Common buffer header */
-struct odp_buffer_hdr_t {
- /* Buffer index in the pool */
- uint32_t index;
-
- /* Initial buffer data pointer and length */
- uint8_t *base_data;
- uint8_t *buf_end;
-
- /* Max data size */
- uint32_t size;
-
- /* Pool type */
- int8_t type;
-
- /* Burst counts */
- uint8_t burst_num;
- uint8_t burst_first;
-
- /* Segment count */
- uint8_t segcount;
-
- /* Segments */
- struct {
- void *hdr;
- uint8_t *data;
- uint32_t len;
- } seg[CONFIG_PACKET_MAX_SEGS];
-
- /* Next buf in a list */
- struct odp_buffer_hdr_t *next;
-
- /* User context pointer or u64 */
- union {
- uint64_t buf_u64;
- void *buf_ctx;
- const void *buf_cctx; /* const alias for ctx */
- };
+/* Internal buffer header */
+typedef struct ODP_ALIGNED_CACHE odp_buffer_hdr_t {
+ /* Common event header */
+ _odp_event_hdr_t event_hdr;
/* User area pointer */
- void *uarea_addr;
-
- /* User area size */
- uint32_t uarea_size;
-
- /* Event type. Maybe different than pool type (crypto compl event) */
- int8_t event_type;
+ void *uarea_addr;
- /* Burst table */
- struct odp_buffer_hdr_t *burst[BUFFER_BURST_SIZE];
+ /* Data */
+ uint8_t data[];
+} odp_buffer_hdr_t;
- /* Used only if _ODP_PKTIO_IPC is set.
- * ipc mapped process can not walk over pointers,
- * offset has to be used */
- uint64_t ipc_data_offset;
+/* Buffer header size is critical for performance. Ensure that it does not accidentally
+ * grow over cache line size. Note that ODP_ALIGNED_CACHE rounds up struct size to a multiple of
+ * ODP_CACHE_LINE_SIZE. */
+ODP_STATIC_ASSERT(sizeof(odp_buffer_hdr_t) <= ODP_CACHE_LINE_SIZE, "BUFFER_HDR_SIZE_ERROR");
- /* Pool handle: will be removed, used only for odp_packet_pool()
- * inlining */
- odp_pool_t pool_hdl;
-
- /* Pool pointer */
- void *pool_ptr;
-
- /* Data or next header */
- uint8_t data[0];
-} ODP_ALIGNED_CACHE;
+static inline odp_buffer_hdr_t *_odp_buf_hdr(odp_buffer_t buf)
+{
+ return (odp_buffer_hdr_t *)(uintptr_t)buf;
+}
-ODP_STATIC_ASSERT(CONFIG_PACKET_MAX_SEGS < 256,
- "CONFIG_PACKET_MAX_SEGS_TOO_LARGE");
+static inline void _odp_buffer_subtype_set(odp_buffer_t buffer, int subtype)
+{
+ odp_buffer_hdr_t *buf_hdr = _odp_buf_hdr(buffer);
-ODP_STATIC_ASSERT(BUFFER_BURST_SIZE < 256, "BUFFER_BURST_SIZE_TOO_LARGE");
+ buf_hdr->event_hdr.subtype = subtype;
+}
#ifdef __cplusplus
}