aboutsummaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorTuomas Taipale <tuomas.taipale@nokia.com>2022-04-02 06:11:26 +0000
committerMatias Elo <matias.elo@nokia.com>2022-05-02 17:02:50 +0300
commit5f40ae132514316fa73ff5c311e185350f9189dd (patch)
treed696d46f0079f545cc70492b642b9cf00053152f /platform
parentf20ea066401dd189253967bc78e4e28fc142c6c3 (diff)
linux-gen: pool: add memory source operations interface
New `_odp_pool_mem_src_ops_t` interface can be used to adapt ODP packet pools to be used as a memory source for e.g. zero-copy packet IO purposes. For now, pools can only be assigned to a single operations provider. When an active memory source user is found, rest are disabled to avoid conflicting configurations. Signed-off-by: Tuomas Taipale <tuomas.taipale@nokia.com> Reviewed-by: Matias Elo <matias.elo@nokia.com>
Diffstat (limited to 'platform')
-rw-r--r--platform/linux-generic/Makefile.am1
-rw-r--r--platform/linux-generic/include/odp_pool_internal.h26
-rw-r--r--platform/linux-generic/odp_pool.c2
-rw-r--r--platform/linux-generic/odp_pool_mem_src_ops.c13
4 files changed, 42 insertions, 0 deletions
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 49565502f..d76dd81e1 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -209,6 +209,7 @@ __LIB__libodp_linux_la_SOURCES = \
odp_parse.c \
odp_pkt_queue.c \
odp_pool.c \
+ odp_pool_mem_src_ops.c \
odp_queue_basic.c \
odp_queue_if.c \
odp_queue_lf.c \
diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h
index 4c9f9a9ce..68f13472c 100644
--- a/platform/linux-generic/include/odp_pool_internal.h
+++ b/platform/linux-generic/include/odp_pool_internal.h
@@ -28,6 +28,8 @@ extern "C" {
#include <odp_ring_ptr_internal.h>
#include <odp/api/plat/strong_types.h>
+#define _ODP_POOL_MEM_SRC_DATA_SIZE 128
+
typedef struct ODP_ALIGNED_CACHE pool_cache_t {
/* Number of buffers in cache */
uint32_t cache_num;
@@ -55,6 +57,8 @@ typedef struct ODP_ALIGNED_CACHE {
/* Callback function for pool destroy */
typedef void (*pool_destroy_cb_fn)(void *pool);
+struct _odp_pool_mem_src_ops_t;
+
typedef struct pool_t {
odp_ticketlock_t lock ODP_ALIGNED_CACHE;
odp_pool_t pool_hdl;
@@ -99,6 +103,9 @@ typedef struct pool_t {
uint8_t mem_from_huge_pages;
pool_destroy_cb_fn ext_destroy;
void *ext_desc;
+ const struct _odp_pool_mem_src_ops_t *mem_src_ops;
+ /* Private area for memory source operations */
+ uint8_t mem_src_data[_ODP_POOL_MEM_SRC_DATA_SIZE] ODP_ALIGNED_CACHE;
struct ODP_ALIGNED_CACHE {
odp_atomic_u64_t alloc_ops;
@@ -130,6 +137,25 @@ typedef struct pool_global_t {
} pool_global_t;
+/* Operations for when ODP packet pool is used as a memory source for e.g. zero-copy packet IO
+ * purposes */
+typedef struct _odp_pool_mem_src_ops_t {
+ /* Name of the ops provider */
+ const char *name;
+ /* Signal if ops provider is an active user for the pool as a memory source */
+ odp_bool_t (*is_active)(void);
+ /* Force disable for the ops provider (for now, if one active memory source user is found,
+ * others are disabled) */
+ void (*force_disable)(void);
+ /* Adjust pool block sizes as required by memory consumer */
+ void (*adjust_size)(uint8_t *data, uint32_t *block_size, uint32_t *block_offset,
+ uint32_t *flags);
+ /* Bind the pool as a memory source */
+ int (*bind)(uint8_t *data, pool_t *pool);
+ /* Unbind the pool as a memory source */
+ void (*unbind)(uint8_t *data);
+} _odp_pool_mem_src_ops_t;
+
extern pool_global_t *_odp_pool_glb;
static inline pool_t *pool_entry(uint32_t pool_idx)
diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index 48bd4a4df..b39028231 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -64,6 +64,8 @@ typedef struct pool_local_t {
} pool_local_t;
+extern const _odp_pool_mem_src_ops_t * const _odp_pool_mem_src_ops[];
+
pool_global_t *_odp_pool_glb;
static __thread pool_local_t local;
diff --git a/platform/linux-generic/odp_pool_mem_src_ops.c b/platform/linux-generic/odp_pool_mem_src_ops.c
new file mode 100644
index 000000000..14b85a77b
--- /dev/null
+++ b/platform/linux-generic/odp_pool_mem_src_ops.c
@@ -0,0 +1,13 @@
+/* Copyright (c) 2022, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp/autoheader_internal.h>
+#include <odp_pool_internal.h>
+
+/* List of available ODP packet pool memory source operations. Array must be NULL terminated */
+const _odp_pool_mem_src_ops_t * const _odp_pool_mem_src_ops[] = {
+ NULL
+};