This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, cloud-dev has been updated via c6a520126eff39b7ebce8e790fb960259ce8f812 (commit) via d27a5b7e08a5cdce84bad9607ce94a5fcbe00ee2 (commit) via ad728d38a886b876c2ab300e9a64d711b2638b0a (commit) via 6448dbc4114c655f1de056ea18003956f3b91b76 (commit) from a1f50ad720e11a54b13c4786cad4687cb5c4ec2a (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit c6a520126eff39b7ebce8e790fb960259ce8f812 Author: Balakrishna Garapati balakrishna.garapati@linaro.org Date: Fri Sep 8 14:05:07 2017 +0200
linux-dpdk:introduce buffer submodule
Signed-off-by: Balakrishna Garapati balakrishna.garapati@linaro.org Reviewed-by: Honnappa Nagarahalli honnappa.nagarahalli@arm.com Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Yi He yi.he@linaro.org
diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am index 168e0f92..93086570 100644 --- a/platform/linux-dpdk/Makefile.am +++ b/platform/linux-dpdk/Makefile.am @@ -168,6 +168,7 @@ odpdrvplatinclude_HEADERS = \
noinst_HEADERS = \ + ${top_srcdir}/platform/linux-generic/include/odp_buffer_subsystem.h \ ${top_srcdir}/platform/linux-generic/include/_fdserver_internal.h \ ${top_srcdir}/platform/linux-generic/include/_ishm_internal.h \ ${top_srcdir}/platform/linux-generic/include/_ishmphy_internal.h \ @@ -255,6 +256,7 @@ __LIB__libodp_dpdk_la_SOURCES = \ ../linux-generic/odp_rwlock.c \ ../linux-generic/odp_rwlock_recursive.c \ ../linux-generic/pool/subsystem.c \ + ../linux-generic/buffer/subsystem.c \ ../linux-generic/odp_schedule_if.c \ ../linux-generic/schedule/generic.c \ ../linux-generic/schedule/iquery.c \ @@ -303,6 +305,7 @@ __LIB__libodp_dpdk_la_SOURCES += arch/x86/cpu_flags.c \ endif
pool/dpdk.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +buffer/dpdk.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE if ODP_SCHEDULE_SCALABLE ../linux-generic/schedule/scalable.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE else diff --git a/platform/linux-dpdk/buffer/dpdk.c b/platform/linux-dpdk/buffer/dpdk.c index 3c71fef8..346549ec 100644 --- a/platform/linux-dpdk/buffer/dpdk.c +++ b/platform/linux-dpdk/buffer/dpdk.c @@ -7,30 +7,96 @@ #include <odp/api/buffer.h> #include <odp_buffer_internal.h> #include <odp_buffer_inlines.h> +#include <odp_buffer_subsystem.h> #include <odp_debug_internal.h> +#include <odp_pool_internal.h>
#include <string.h> #include <stdio.h> #include <inttypes.h>
-odp_buffer_t odp_buffer_from_event(odp_event_t ev) +static odp_buffer_t buffer_alloc(odp_pool_t pool_hdl) +{ + odp_buffer_t buffer; + pool_entry_dp_t *pool_dp; + + ODP_ASSERT(odp_pool_to_entry_cp(pool_hdl)->params.type == + ODP_POOL_BUFFER || + odp_pool_to_entry_cp(pool_hdl)->params.type == + ODP_POOL_TIMEOUT); + + pool_dp = odp_pool_to_entry_dp(pool_hdl); + + buffer = (odp_buffer_t)rte_ctrlmbuf_alloc(pool_dp->rte_mempool); + + if ((struct rte_mbuf *)buffer == NULL) { + rte_errno = ENOMEM; + return ODP_BUFFER_INVALID; + } + + buf_hdl_to_hdr(buffer)->next = NULL; + return buffer; +} + +static odp_buffer_t dpdk_buffer_alloc(odp_pool_t pool_hdl) +{ + ODP_ASSERT(ODP_POOL_INVALID != pool_hdl); + + return buffer_alloc(pool_hdl); +} + +static int dpdk_buffer_alloc_multi(odp_pool_t pool_hdl, + odp_buffer_t buf[], + int num) +{ + int i; + + ODP_ASSERT(ODP_POOL_INVALID != pool_hdl); + + for (i = 0; i < num; i++) { + buf[i] = buffer_alloc(pool_hdl); + if (buf[i] == ODP_BUFFER_INVALID) + return rte_errno == ENOMEM ? i : -EINVAL; + } + return i; +} + +static void dpdk_buffer_free(odp_buffer_t buf) +{ + struct rte_mbuf *mbuf = (struct rte_mbuf *)buf; + + rte_ctrlmbuf_free(mbuf); +} + +static void dpdk_buffer_free_multi(const odp_buffer_t buf[], int num) +{ + int i; + + for (i = 0; i < num; i++) { + struct rte_mbuf *mbuf = (struct rte_mbuf *)buf[i]; + + rte_ctrlmbuf_free(mbuf); + } +} + +static odp_buffer_t dpdk_buffer_from_event(odp_event_t ev) { return (odp_buffer_t)ev; }
-odp_event_t odp_buffer_to_event(odp_buffer_t buf) +static odp_event_t dpdk_buffer_to_event(odp_buffer_t buf) { return (odp_event_t)buf; }
-void *odp_buffer_addr(odp_buffer_t buf) +static void *dpdk_buffer_addr(odp_buffer_t buf) { odp_buffer_hdr_t *hdr = buf_hdl_to_hdr(buf);
return hdr->mb.buf_addr; }
-uint32_t odp_buffer_size(odp_buffer_t buf) +static uint32_t dpdk_buffer_size(odp_buffer_t buf) { odp_buffer_hdr_t *hdr = buf_hdl_to_hdr(buf); struct rte_mbuf *mbuf = (struct rte_mbuf *)hdr; @@ -52,7 +118,7 @@ void _odp_buffer_type_set(odp_buffer_t buf, int type) hdr->type = type; }
-int odp_buffer_is_valid(odp_buffer_t buf) +static int dpdk_buffer_is_valid(odp_buffer_t buf) { /* We could call rte_mbuf_sanity_check, but that panics * and aborts the program */ @@ -71,43 +137,71 @@ int odp_buffer_snprint(char *str, uint32_t n, odp_buffer_t buf)
hdr = buf_hdl_to_hdr(buf);
- len += snprintf(&str[len], n-len, + len += snprintf(&str[len], n - len, "Buffer\n"); - len += snprintf(&str[len], n-len, + len += snprintf(&str[len], n - len, " pool %p\n", hdr->mb.pool); - len += snprintf(&str[len], n-len, - " phy_addr %"PRIu64"\n", hdr->mb.buf_physaddr); - len += snprintf(&str[len], n-len, + len += snprintf(&str[len], n - len, + " phy_addr %" PRIu64 "\n", hdr->mb.buf_physaddr); + len += snprintf(&str[len], n - len, " addr %p\n", hdr->mb.buf_addr); - len += snprintf(&str[len], n-len, + len += snprintf(&str[len], n - len, " size %u\n", hdr->mb.buf_len); - len += snprintf(&str[len], n-len, + len += snprintf(&str[len], n - len, " ref_count %i\n", rte_mbuf_refcnt_read(&hdr->mb)); - len += snprintf(&str[len], n-len, + len += snprintf(&str[len], n - len, " odp type %i\n", hdr->type);
return len; }
-void odp_buffer_print(odp_buffer_t buf) +static void dpdk_buffer_print(odp_buffer_t buf) { int max_len = 512; char str[max_len]; int len;
- len = odp_buffer_snprint(str, max_len-1, buf); + len = odp_buffer_snprint(str, max_len - 1, buf); str[len] = 0;
ODP_PRINT("\n%s\n", str); }
-uint64_t odp_buffer_to_u64(odp_buffer_t hdl) +static uint64_t dpdk_buffer_to_u64(odp_buffer_t hdl) { return _odp_pri(hdl); }
-odp_pool_t odp_buffer_pool(odp_buffer_t buf) +static odp_pool_t dpdk_buffer_pool(odp_buffer_t buf) { return buf_hdl_to_hdr(buf)->pool_hdl; } + +odp_buffer_module_t dpdk_buffer = { + .base = { + .name = "dpdk_buffer", + .init_local = NULL, + .term_local = NULL, + .init_global = NULL, + .term_global = NULL, + }, + .buffer_alloc = dpdk_buffer_alloc, + .buffer_alloc_multi = dpdk_buffer_alloc_multi, + .buffer_free = dpdk_buffer_free, + .buffer_free_multi = dpdk_buffer_free_multi, + .buffer_from_event = dpdk_buffer_from_event, + .buffer_to_event = dpdk_buffer_to_event, + .buffer_addr = dpdk_buffer_addr, + .buffer_size = dpdk_buffer_size, + .buffer_is_valid = dpdk_buffer_is_valid, + .buffer_print = dpdk_buffer_print, + .buffer_to_u64 = dpdk_buffer_to_u64, + .buffer_pool = dpdk_buffer_pool, +}; + +ODP_MODULE_CONSTRUCTOR(dpdk_buffer) +{ + odp_module_constructor(&dpdk_buffer); + odp_subsystem_register_module(buffer, &dpdk_buffer); +} diff --git a/platform/linux-dpdk/odp_packet.c b/platform/linux-dpdk/odp_packet.c index 23aec95e..b2860a77 100644 --- a/platform/linux-dpdk/odp_packet.c +++ b/platform/linux-dpdk/odp_packet.c @@ -90,7 +90,7 @@ static odp_packet_t packet_alloc(odp_pool_t pool_hdl, uint32_t len) struct rte_mbuf *mbuf;
ODP_ASSERT(odp_pool_to_entry_cp(pool_hdl)->params.type - != ODP_POOL_PACKET); + == ODP_POOL_PACKET);
pool_dp = odp_pool_to_entry_dp(pool_hdl);
diff --git a/platform/linux-dpdk/pool/dpdk.c b/platform/linux-dpdk/pool/dpdk.c index 499bea12..6acc4e90 100644 --- a/platform/linux-dpdk/pool/dpdk.c +++ b/platform/linux-dpdk/pool/dpdk.c @@ -549,68 +549,6 @@ static odp_pool_t dpdk_pool_lookup(const char *name) return pool_hdl; }
-static odp_buffer_t buffer_alloc(odp_pool_t pool_hdl) -{ - odp_buffer_t buffer; - pool_entry_cp_t *pool_cp; - pool_entry_dp_t *pool_dp; - - pool_cp = odp_pool_to_entry_cp(pool_hdl); - pool_dp = odp_pool_to_entry_dp(pool_hdl); - - ODP_ASSERT(pool_cp->params.type != ODP_POOL_BUFFER && - pool_cp->params.type != ODP_POOL_TIMEOUT); - - buffer = (odp_buffer_t)rte_ctrlmbuf_alloc(pool_dp->rte_mempool); - - if ((struct rte_mbuf *)buffer == NULL) { - rte_errno = ENOMEM; - return ODP_BUFFER_INVALID; - } - - buf_hdl_to_hdr(buffer)->next = NULL; - return buffer; -} - -odp_buffer_t odp_buffer_alloc(odp_pool_t pool_hdl) -{ - ODP_ASSERT(ODP_POOL_INVALID != pool_hdl); - - return buffer_alloc(pool_hdl); -} - -int odp_buffer_alloc_multi(odp_pool_t pool_hdl, odp_buffer_t buf[], int num) -{ - int i; - - ODP_ASSERT(ODP_POOL_INVALID != pool_hdl); - - for (i = 0; i < num; i++) { - buf[i] = buffer_alloc(pool_hdl); - if (buf[i] == ODP_BUFFER_INVALID) - return rte_errno == ENOMEM ? i : -EINVAL; - } - return i; -} - -void odp_buffer_free(odp_buffer_t buf) -{ - struct rte_mbuf *mbuf = (struct rte_mbuf *)buf; - - rte_ctrlmbuf_free(mbuf); -} - -void odp_buffer_free_multi(const odp_buffer_t buf[], int num) -{ - int i; - - for (i = 0; i < num; i++) { - struct rte_mbuf *mbuf = (struct rte_mbuf *)buf[i]; - - rte_ctrlmbuf_free(mbuf); - } -} - static void dpdk_pool_print(odp_pool_t pool_hdl) { pool_entry_dp_t *pool_dp = odp_pool_to_entry_dp(pool_hdl);
commit d27a5b7e08a5cdce84bad9607ce94a5fcbe00ee2 Author: Balakrishna Garapati balakrishna.garapati@linaro.org Date: Fri Sep 8 13:59:08 2017 +0200
linux-dpdk:prepare for buffer submodule
Signed-off-by: Balakrishna Garapati balakrishna.garapati@linaro.org Reviewed-by: Honnappa Nagarahalli honnappa.nagarahalli@arm.com Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Yi He yi.he@linaro.org
diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am index f8fa67a6..168e0f92 100644 --- a/platform/linux-dpdk/Makefile.am +++ b/platform/linux-dpdk/Makefile.am @@ -227,7 +227,7 @@ __LIB__libodp_dpdk_la_SOURCES = \ ../linux-generic/odp_atomic.c \ ../linux-generic/odp_barrier.c \ ../linux-generic/odp_bitmap.c \ - odp_buffer.c \ + buffer/dpdk.c \ ../linux-generic/odp_byteorder.c \ ../linux-generic/odp_classification.c \ ../linux-generic/odp_cpu.c \ diff --git a/platform/linux-dpdk/odp_buffer.c b/platform/linux-dpdk/buffer/dpdk.c similarity index 100% rename from platform/linux-dpdk/odp_buffer.c rename to platform/linux-dpdk/buffer/dpdk.c
commit ad728d38a886b876c2ab300e9a64d711b2638b0a Author: Joyce Kong joyce.kong@arm.com Date: Tue Sep 5 14:39:24 2017 +0800
linux-gen: queue: add queue module to subsystem
Signed-off-by: Joyce Kong joyce.kong@arm.com Reviewed-by: Yi He yi.he@linaro.org Reviewed-by: Kevin Wang kevin.wang@arm.com Reviewed-by: Honnappa Nagarahalli honnappa.nagarahalli@arm.com Reviewed-by: Brian Brooks brian.brooks@arm.com Reviewed-by: Bill Fischofer bill.fischofer@linaro.org
diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am index 587d4836..f8fa67a6 100644 --- a/platform/linux-dpdk/Makefile.am +++ b/platform/linux-dpdk/Makefile.am @@ -201,6 +201,7 @@ noinst_HEADERS = \ ${srcdir}/include/odp_posix_extensions.h \ ${top_srcdir}/platform/linux-generic/include/odp_queue_internal.h \ ${top_srcdir}/platform/linux-generic/include/odp_queue_if.h \ + ${top_srcdir}/platform/linux-generic/include/odp_queue_subsystem.h \ ${top_srcdir}/platform/linux-generic/include/odp_ring_internal.h \ ${top_srcdir}/platform/linux-generic/include/odp_schedule_if.h \ ${top_srcdir}/platform/linux-generic/include/odp_schedule_subsystem.h \ @@ -247,8 +248,10 @@ __LIB__libodp_dpdk_la_SOURCES = \ ../linux-generic/pktio/loop.c \ ../linux-generic/odp_pkt_queue.c \ pool/dpdk.c \ - ../linux-generic/odp_queue.c \ ../linux-generic/odp_queue_if.c \ + ../linux-generic/queue/subsystem.c \ + ../linux-generic/queue/generic.c \ + ../linux-generic/queue/scalable.c \ ../linux-generic/odp_rwlock.c \ ../linux-generic/odp_rwlock_recursive.c \ ../linux-generic/pool/subsystem.c \ @@ -313,6 +316,11 @@ else endif endif endif +if ODP_SCHEDULE_SCALABLE +../linux-generic/queue/scalable.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +else +../linux-generic/queue/generic.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +endif
# Build modular framework into odp-linux library modularframeworkdir = $(top_srcdir)/frameworks/modular diff --git a/platform/linux-dpdk/include/odp_buffer_inlines.h b/platform/linux-dpdk/include/odp_buffer_inlines.h index a2fa502f..05c8d931 100644 --- a/platform/linux-dpdk/include/odp_buffer_inlines.h +++ b/platform/linux-dpdk/include/odp_buffer_inlines.h @@ -29,6 +29,11 @@ static inline odp_buffer_hdr_t *buf_hdl_to_hdr(odp_buffer_t buf) return (odp_buffer_hdr_t *)(void *)buf; }
+static inline odp_buffer_t buf_from_buf_hdr(odp_buffer_hdr_t *hdr) +{ + return (odp_buffer_t)hdr; +} + static inline odp_event_type_t _odp_buffer_event_type(odp_buffer_t buf) { return buf_hdl_to_hdr(buf)->event_type; diff --git a/platform/linux-dpdk/include/odp_config_internal.h b/platform/linux-dpdk/include/odp_config_internal.h index ea469ee4..6aadc93f 100644 --- a/platform/linux-dpdk/include/odp_config_internal.h +++ b/platform/linux-dpdk/include/odp_config_internal.h @@ -22,6 +22,13 @@ extern "C" { #define ODP_CONFIG_QUEUES 1024
/* + * Maximum queue depth. Maximum number of elements that can be stored in a + * queue. This value is used only when the size is not explicitly provided + * during queue creation. + */ +#define CONFIG_QUEUE_SIZE 4096 + +/* * Maximum number of ordered locks per queue */ #define CONFIG_QUEUE_MAX_ORD_LOCKS 4 diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c index cd7abce6..737b5331 100644 --- a/platform/linux-dpdk/odp_init.c +++ b/platform/linux-dpdk/odp_init.c @@ -352,7 +352,7 @@ int odp_init_global(odp_instance_t *instance, } stage = POOL_INIT;
- if (queue_fn->init_global()) { + if (odp_queue_init_global()) { ODP_ERR("ODP queue init failed.\n"); goto init_failed; } @@ -495,7 +495,7 @@ int _odp_term_global(enum init_stage stage) /* Fall through */
case QUEUE_INIT: - if (queue_fn->term_global()) { + if (odp_queue_term_global()) { ODP_ERR("ODP queue term failed.\n"); rc = -1; } diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index b542966f..c13d73b5 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -277,10 +277,10 @@ __LIB__libodp_linux_la_SOURCES = \ pool/generic.c \ pool/subsystem.c \ odp_pkt_queue.c \ - odp_queue.c \ odp_queue_if.c \ queue/subsystem.c \ - odp_queue_scalable.c \ + queue/generic.c \ + queue/scalable.c \ odp_rwlock.c \ odp_rwlock_recursive.c \ odp_schedule_if.c \ @@ -347,6 +347,11 @@ endif if ODP_SCHEDULE_IQUERY schedule/iquery.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE endif +if ODP_SCHEDULE_SCALABLE +queue/scalable.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +else +queue/generic.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +endif
# Build modular framework into odp-linux library modularframeworkdir = $(top_srcdir)/frameworks/modular diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index 2c935a9f..1fb38648 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -109,6 +109,8 @@ int odp_classification_term_global(void);
int odp_queue_init_global(void); int odp_queue_term_global(void); +int odp_queue_init_local(void); +int odp_queue_term_local(void);
int odp_crypto_init_global(void); int odp_crypto_term_global(void); diff --git a/platform/linux-generic/include/odp_queue_if.h b/platform/linux-generic/include/odp_queue_if.h index 410c6b79..863aa3ce 100644 --- a/platform/linux-generic/include/odp_queue_if.h +++ b/platform/linux-generic/include/odp_queue_if.h @@ -18,77 +18,33 @@ extern "C" {
#define QUEUE_MULTI_MAX CONFIG_BURST_SIZE
-/* Queue API functions */ -typedef struct { - odp_queue_t (*queue_create)(const char *name, - const odp_queue_param_t *param); - int (*queue_destroy)(odp_queue_t queue); - odp_queue_t (*queue_lookup)(const char *name); - int (*queue_capability)(odp_queue_capability_t *capa); - int (*queue_context_set)(odp_queue_t queue, void *context, - uint32_t len); - void *(*queue_context)(odp_queue_t queue); - int (*queue_enq)(odp_queue_t queue, odp_event_t ev); - int (*queue_enq_multi)(odp_queue_t queue, const odp_event_t events[], - int num); - odp_event_t (*queue_deq)(odp_queue_t queue); - int (*queue_deq_multi)(odp_queue_t queue, odp_event_t events[], - int num); - odp_queue_type_t (*queue_type)(odp_queue_t queue); - odp_schedule_sync_t (*queue_sched_type)(odp_queue_t queue); - odp_schedule_prio_t (*queue_sched_prio)(odp_queue_t queue); - odp_schedule_group_t (*queue_sched_group)(odp_queue_t queue); - int (*queue_lock_count)(odp_queue_t queue); - uint64_t (*queue_to_u64)(odp_queue_t hdl); - void (*queue_param_init)(odp_queue_param_t *param); - int (*queue_info)(odp_queue_t queue, odp_queue_info_t *info); -} queue_api_t; - /* Internal abstract queue handle */ typedef struct { char dummy; } _queue_t; typedef _queue_t *queue_t;
#define QUEUE_NULL ((queue_t)NULL)
-typedef int (*queue_init_global_fn_t)(void); -typedef int (*queue_term_global_fn_t)(void); -typedef int (*queue_init_local_fn_t)(void); -typedef int (*queue_term_local_fn_t)(void); -typedef queue_t (*queue_from_ext_fn_t)(odp_queue_t handle); -typedef odp_queue_t (*queue_to_ext_fn_t)(queue_t q_int); typedef int (*queue_enq_fn_t)(queue_t q_int, odp_buffer_hdr_t *); typedef int (*queue_enq_multi_fn_t)(queue_t q_int, odp_buffer_hdr_t **, int); typedef odp_buffer_hdr_t *(*queue_deq_fn_t)(queue_t q_int); typedef int (*queue_deq_multi_fn_t)(queue_t q_int, odp_buffer_hdr_t **, int); -typedef odp_pktout_queue_t (*queue_get_pktout_fn_t)(queue_t q_int); -typedef void (*queue_set_pktout_fn_t)(queue_t q_int, odp_pktio_t pktio, - int index); -typedef odp_pktin_queue_t (*queue_get_pktin_fn_t)(queue_t q_int); -typedef void (*queue_set_pktin_fn_t)(queue_t q_int, odp_pktio_t pktio, - int index); -typedef void (*queue_set_enq_deq_fn_t)(queue_t q_int, - queue_enq_fn_t enq, - queue_enq_multi_fn_t enq_multi, - queue_deq_fn_t deq, - queue_deq_multi_fn_t deq_multi);
/* Queue functions towards other internal components */ typedef struct { - queue_init_global_fn_t init_global; - queue_term_global_fn_t term_global; - queue_init_local_fn_t init_local; - queue_term_local_fn_t term_local; - queue_from_ext_fn_t from_ext; - queue_to_ext_fn_t to_ext; + queue_t (*from_ext)(odp_queue_t handle); + odp_queue_t (*to_ext)(queue_t q_int); queue_enq_fn_t enq; queue_enq_multi_fn_t enq_multi; queue_deq_fn_t deq; queue_deq_multi_fn_t deq_multi; - queue_get_pktout_fn_t get_pktout; - queue_set_pktout_fn_t set_pktout; - queue_get_pktin_fn_t get_pktin; - queue_set_pktin_fn_t set_pktin; - queue_set_enq_deq_fn_t set_enq_deq_fn; + odp_pktout_queue_t (*get_pktout)(queue_t q_int); + void (*set_pktout)(queue_t q_int, odp_pktio_t pktio, int index); + odp_pktin_queue_t (*get_pktin)(queue_t q_int); + void (*set_pktin)(queue_t q_int, odp_pktio_t pktio, int index); + void (*set_enq_deq_fn)(queue_t q_int, queue_enq_fn_t enq, + queue_enq_multi_fn_t enq_multi, + queue_deq_fn_t deq, + queue_deq_multi_fn_t deq_multi); } queue_fn_t;
extern const queue_fn_t *queue_fn; diff --git a/platform/linux-generic/include/odp_queue_subsystem.h b/platform/linux-generic/include/odp_queue_subsystem.h index c63309fa..2c62af37 100644 --- a/platform/linux-generic/include/odp_queue_subsystem.h +++ b/platform/linux-generic/include/odp_queue_subsystem.h @@ -5,6 +5,7 @@ * * SPDX-License-Identifier: BSD-3-Clause */ + #ifndef ODP_QUEUE_SUBSYSTEM_H #define ODP_QUEUE_SUBSYSTEM_H
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 340171a5..d5a85d76 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -172,7 +172,7 @@ int odp_init_global(odp_instance_t *instance, } stage = POOL_INIT;
- if (queue_fn->init_global()) { + if (odp_queue_init_global()) { ODP_ERR("ODP queue init failed.\n"); goto init_failed; } @@ -313,7 +313,7 @@ int _odp_term_global(enum init_stage stage) /* Fall through */
case QUEUE_INIT: - if (queue_fn->term_global()) { + if (odp_queue_term_global()) { ODP_ERR("ODP queue term failed.\n"); rc = -1; } @@ -408,7 +408,7 @@ int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type) } stage = POOL_INIT;
- if (queue_fn->init_local()) { + if (odp_queue_init_local()) { ODP_ERR("ODP queue local init failed.\n"); goto init_fail; } @@ -454,7 +454,7 @@ int _odp_term_local(enum init_stage stage) /* Fall through */
case QUEUE_INIT: - if (queue_fn->term_local()) { + if (odp_queue_term_local()) { ODP_ERR("ODP queue local term failed.\n"); rc = -1; } diff --git a/platform/linux-generic/odp_queue_if.c b/platform/linux-generic/odp_queue_if.c index d7471dfc..f77405a9 100644 --- a/platform/linux-generic/odp_queue_if.c +++ b/platform/linux-generic/odp_queue_if.c @@ -1,111 +1,15 @@ /* Copyright (c) 2017, ARM Limited * All rights reserved. * - * SPDX-License-Identifier: BSD-3-Clause + * SPDX-License-Identifier: BSD-3-Clause */ - #include <odp_queue_if.h>
-extern const queue_api_t queue_scalable_api; extern const queue_fn_t queue_scalable_fn; - -extern const queue_api_t queue_default_api; extern const queue_fn_t queue_default_fn;
#ifdef ODP_SCHEDULE_SCALABLE -const queue_api_t *queue_api = &queue_scalable_api; const queue_fn_t *queue_fn = &queue_scalable_fn; #else -const queue_api_t *queue_api = &queue_default_api; const queue_fn_t *queue_fn = &queue_default_fn; #endif - -odp_queue_t odp_queue_create(const char *name, const odp_queue_param_t *param) -{ - return queue_api->queue_create(name, param); -} - -int odp_queue_destroy(odp_queue_t queue) -{ - return queue_api->queue_destroy(queue); -} - -odp_queue_t odp_queue_lookup(const char *name) -{ - return queue_api->queue_lookup(name); -} - -int odp_queue_capability(odp_queue_capability_t *capa) -{ - return queue_api->queue_capability(capa); -} - -int odp_queue_context_set(odp_queue_t queue, void *context, uint32_t len) -{ - return queue_api->queue_context_set(queue, context, len); -} - -void *odp_queue_context(odp_queue_t queue) -{ - return queue_api->queue_context(queue); -} - -int odp_queue_enq(odp_queue_t queue, odp_event_t ev) -{ - return queue_api->queue_enq(queue, ev); -} - -int odp_queue_enq_multi(odp_queue_t queue, const odp_event_t events[], int num) -{ - return queue_api->queue_enq_multi(queue, events, num); -} - -odp_event_t odp_queue_deq(odp_queue_t queue) -{ - return queue_api->queue_deq(queue); -} - -int odp_queue_deq_multi(odp_queue_t queue, odp_event_t events[], int num) -{ - return queue_api->queue_deq_multi(queue, events, num); -} - -odp_queue_type_t odp_queue_type(odp_queue_t queue) -{ - return queue_api->queue_type(queue); -} - -odp_schedule_sync_t odp_queue_sched_type(odp_queue_t queue) -{ - return queue_api->queue_sched_type(queue); -} - -odp_schedule_prio_t odp_queue_sched_prio(odp_queue_t queue) -{ - return queue_api->queue_sched_prio(queue); -} - -odp_schedule_group_t odp_queue_sched_group(odp_queue_t queue) -{ - return queue_api->queue_sched_group(queue); -} - -int odp_queue_lock_count(odp_queue_t queue) -{ - return queue_api->queue_lock_count(queue); -} - -uint64_t odp_queue_to_u64(odp_queue_t hdl) -{ - return queue_api->queue_to_u64(hdl); -} - -void odp_queue_param_init(odp_queue_param_t *param) -{ - return queue_api->queue_param_init(param); -} - -int odp_queue_info(odp_queue_t queue, odp_queue_info_t *info) -{ - return queue_api->queue_info(queue, info); -} diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/queue/generic.c similarity index 85% rename from platform/linux-generic/odp_queue.c rename to platform/linux-generic/queue/generic.c index 46197e00..37f13d03 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/queue/generic.c @@ -1,12 +1,13 @@ /* Copyright (c) 2013, Linaro Limited * All rights reserved. * - * SPDX-License-Identifier: BSD-3-Clause + * SPDX-License-Identifier: BSD-3-Clause */
#include <odp/api/queue.h> #include <odp_queue_internal.h> #include <odp_queue_if.h> +#include <odp_queue_subsystem.h> #include <odp/api/std_types.h> #include <odp/api/align.h> #include <odp/api/buffer.h> @@ -65,7 +66,7 @@ queue_entry_t *get_qentry(uint32_t queue_id) return &queue_tbl->queue[queue_id]; }
-static int queue_init_global(void) +static int generic_queue_init_global(void) { uint32_t i; odp_shm_t shm; @@ -86,6 +87,7 @@ static int queue_init_global(void) for (i = 0; i < ODP_CONFIG_QUEUES; i++) { /* init locks */ queue_entry_t *queue = get_qentry(i); + LOCK_INIT(&queue->s.lock); queue->s.index = i; queue->s.handle = queue_from_id(i); @@ -102,17 +104,17 @@ static int queue_init_global(void) return 0; }
-static int queue_init_local(void) +static int generic_queue_init_local(void) { return 0; }
-static int queue_term_local(void) +static int generic_queue_term_local(void) { return 0; }
-static int queue_term_global(void) +static int generic_queue_term_global(void) { int ret = 0; int rc = 0; @@ -138,7 +140,7 @@ static int queue_term_global(void) return rc; }
-static int queue_capability(odp_queue_capability_t *capa) +static int generic_queue_capability(odp_queue_capability_t *capa) { memset(capa, 0, sizeof(odp_queue_capability_t));
@@ -153,27 +155,27 @@ static int queue_capability(odp_queue_capability_t *capa) return 0; }
-static odp_queue_type_t queue_type(odp_queue_t handle) +static odp_queue_type_t generic_queue_type(odp_queue_t handle) { return handle_to_qentry(handle)->s.type; }
-static odp_schedule_sync_t queue_sched_type(odp_queue_t handle) +static odp_schedule_sync_t generic_queue_sched_type(odp_queue_t handle) { return handle_to_qentry(handle)->s.param.sched.sync; }
-static odp_schedule_prio_t queue_sched_prio(odp_queue_t handle) +static odp_schedule_prio_t generic_queue_sched_prio(odp_queue_t handle) { return handle_to_qentry(handle)->s.param.sched.prio; }
-static odp_schedule_group_t queue_sched_group(odp_queue_t handle) +static odp_schedule_group_t generic_queue_sched_group(odp_queue_t handle) { return handle_to_qentry(handle)->s.param.sched.group; }
-static int queue_lock_count(odp_queue_t handle) +static int generic_queue_lock_count(odp_queue_t handle) { queue_entry_t *queue = handle_to_qentry(handle);
@@ -181,8 +183,8 @@ static int queue_lock_count(odp_queue_t handle) (int)queue->s.param.sched.lock_count : -1; }
-static odp_queue_t queue_create(const char *name, - const odp_queue_param_t *param) +static odp_queue_t generic_queue_create(const char *name, + const odp_queue_param_t *param) { uint32_t i; queue_entry_t *queue; @@ -247,9 +249,10 @@ void queue_destroy_finalize(uint32_t queue_index) UNLOCK(&queue->s.lock); }
-static int queue_destroy(odp_queue_t handle) +static int generic_queue_destroy(odp_queue_t handle) { queue_entry_t *queue; + queue = handle_to_qentry(handle);
if (handle == ODP_QUEUE_INVALID) @@ -292,8 +295,8 @@ static int queue_destroy(odp_queue_t handle) return 0; }
-static int queue_context_set(odp_queue_t handle, void *context, - uint32_t len ODP_UNUSED) +static int generic_queue_context_set(odp_queue_t handle, void *context, + uint32_t len ODP_UNUSED) { odp_mb_full(); handle_to_qentry(handle)->s.param.context = context; @@ -301,12 +304,12 @@ static int queue_context_set(odp_queue_t handle, void *context, return 0; }
-static void *queue_context(odp_queue_t handle) +static void *generic_queue_context(odp_queue_t handle) { return handle_to_qentry(handle)->s.param.context; }
-static odp_queue_t queue_lookup(const char *name) +static odp_queue_t generic_queue_lookup(const char *name) { uint32_t i;
@@ -424,7 +427,8 @@ static int queue_int_enq(queue_t q_int, odp_buffer_hdr_t *buf_hdr) return -1; }
-static int queue_enq_multi(odp_queue_t handle, const odp_event_t ev[], int num) +static int generic_queue_enq_multi(odp_queue_t handle, + const odp_event_t ev[], int num) { queue_entry_t *queue = handle_to_qentry(handle);
@@ -438,7 +442,7 @@ static int queue_enq_multi(odp_queue_t handle, const odp_event_t ev[], int num) (odp_buffer_hdr_t **)(uintptr_t)ev, num); }
-static int queue_enq(odp_queue_t handle, odp_event_t ev) +static int generic_queue_enq(odp_queue_t handle, odp_event_t ev) { queue_entry_t *queue = handle_to_qentry(handle);
@@ -543,7 +547,8 @@ static odp_buffer_hdr_t *queue_int_deq(queue_t q_int) return NULL; }
-static int queue_deq_multi(odp_queue_t handle, odp_event_t ev[], int num) +static int generic_queue_deq_multi(odp_queue_t handle, odp_event_t ev[], + int num) { queue_entry_t *queue = handle_to_qentry(handle);
@@ -554,7 +559,7 @@ static int queue_deq_multi(odp_queue_t handle, odp_event_t ev[], int num) (odp_buffer_hdr_t **)ev, num); }
-static odp_event_t queue_deq(odp_queue_t handle) +static odp_event_t generic_queue_deq(odp_queue_t handle) { queue_entry_t *queue = handle_to_qentry(handle);
@@ -593,7 +598,7 @@ static int queue_init(queue_entry_t *queue, const char *name, return 0; }
-static void queue_param_init(odp_queue_param_t *params) +static void generic_queue_param_init(odp_queue_param_t *params) { memset(params, 0, sizeof(odp_queue_param_t)); params->type = ODP_QUEUE_TYPE_PLAIN; @@ -604,7 +609,7 @@ static void queue_param_init(odp_queue_param_t *params) params->sched.group = ODP_SCHED_GROUP_ALL; }
-static int queue_info(odp_queue_t handle, odp_queue_info_t *info) +static int generic_queue_info(odp_queue_t handle, odp_queue_info_t *info) { uint32_t queue_id; queue_entry_t *queue; @@ -681,7 +686,7 @@ int queue_empty(uint32_t queue_index) return ret; }
-static uint64_t queue_to_u64(odp_queue_t hdl) +static uint64_t generic_queue_to_u64(odp_queue_t hdl) { return _odp_pri(hdl); } @@ -744,33 +749,42 @@ static odp_queue_t queue_to_ext(queue_t q_int) }
/* API functions */ -queue_api_t queue_default_api = { - .queue_create = queue_create, - .queue_destroy = queue_destroy, - .queue_lookup = queue_lookup, - .queue_capability = queue_capability, - .queue_context_set = queue_context_set, - .queue_context = queue_context, - .queue_enq = queue_enq, - .queue_enq_multi = queue_enq_multi, - .queue_deq = queue_deq, - .queue_deq_multi = queue_deq_multi, - .queue_type = queue_type, - .queue_sched_type = queue_sched_type, - .queue_sched_prio = queue_sched_prio, - .queue_sched_group = queue_sched_group, - .queue_lock_count = queue_lock_count, - .queue_to_u64 = queue_to_u64, - .queue_param_init = queue_param_init, - .queue_info = queue_info +odp_queue_module_t generic_queue = { + .base = { + .name = "generic_queue", + .init_global = generic_queue_init_global, + .term_global = generic_queue_term_global, + .init_local = generic_queue_init_local, + .term_local = generic_queue_term_local, + }, + .create = generic_queue_create, + .destroy = generic_queue_destroy, + .lookup = generic_queue_lookup, + .capability = generic_queue_capability, + .context_set = generic_queue_context_set, + .context = generic_queue_context, + .enq = generic_queue_enq, + .enq_multi = generic_queue_enq_multi, + .deq = generic_queue_deq, + .deq_multi = generic_queue_deq_multi, + .type = generic_queue_type, + .sched_type = generic_queue_sched_type, + .sched_prio = generic_queue_sched_prio, + .sched_group = generic_queue_sched_group, + .lock_count = generic_queue_lock_count, + .to_u64 = generic_queue_to_u64, + .param_init = generic_queue_param_init, + .info = generic_queue_info, };
+ODP_MODULE_CONSTRUCTOR(generic_queue) +{ + odp_module_constructor(&generic_queue); + odp_subsystem_register_module(queue, &generic_queue); +} + /* Functions towards internal components */ queue_fn_t queue_default_fn = { - .init_global = queue_init_global, - .term_global = queue_term_global, - .init_local = queue_init_local, - .term_local = queue_term_local, .from_ext = queue_from_ext, .to_ext = queue_to_ext, .enq = queue_int_enq, @@ -781,5 +795,5 @@ queue_fn_t queue_default_fn = { .set_pktout = queue_set_pktout, .get_pktin = queue_get_pktin, .set_pktin = queue_set_pktin, - .set_enq_deq_fn = queue_set_enq_deq_func + .set_enq_deq_fn = queue_set_enq_deq_func, }; diff --git a/platform/linux-generic/odp_queue_scalable.c b/platform/linux-generic/queue/scalable.c similarity index 89% rename from platform/linux-generic/odp_queue_scalable.c rename to platform/linux-generic/queue/scalable.c index 503b40f5..020b790d 100644 --- a/platform/linux-generic/odp_queue_scalable.c +++ b/platform/linux-generic/queue/scalable.c @@ -3,7 +3,7 @@ * Copyright (c) 2017, Linaro Limited * All rights reserved. * - * SPDX-License-Identifier: BSD-3-Clause + * SPDX-License-Identifier: BSD-3-Clause */
#include <odp/api/hints.h> @@ -22,6 +22,7 @@ #include <odp_packet_io_internal.h> #include <odp_pool_internal.h> #include <odp_queue_scalable_internal.h> +#include <odp_queue_subsystem.h> #include <odp_schedule_if.h> #include <_ishm_internal.h> #include <_ishmpool_internal.h> @@ -182,7 +183,7 @@ rwin_create_failed: return -1; }
-static int queue_init_global(void) +static int scalable_queue_init_global(void) { uint32_t i; uint64_t pool_size; @@ -258,7 +259,7 @@ queue_tbl_ishm_alloc_failed: return -1; }
-static int queue_term_global(void) +static int scalable_queue_term_global(void) { int ret = 0; int rc = 0; @@ -285,17 +286,17 @@ static int queue_term_global(void) return rc; }
-static int queue_init_local(void) +static int scalable_queue_init_local(void) { return 0; }
-static int queue_term_local(void) +static int scalable_queue_term_local(void) { return 0; }
-static int queue_capability(odp_queue_capability_t *capa) +static int scalable_queue_capability(odp_queue_capability_t *capa) { memset(capa, 0, sizeof(odp_queue_capability_t));
@@ -312,27 +313,27 @@ static int queue_capability(odp_queue_capability_t *capa) return 0; }
-static odp_queue_type_t queue_type(odp_queue_t handle) +static odp_queue_type_t scalable_queue_type(odp_queue_t handle) { return qentry_from_int(queue_from_ext(handle))->s.type; }
-static odp_schedule_sync_t queue_sched_type(odp_queue_t handle) +static odp_schedule_sync_t scalable_queue_sched_type(odp_queue_t handle) { return qentry_from_int(queue_from_ext(handle))->s.param.sched.sync; }
-static odp_schedule_prio_t queue_sched_prio(odp_queue_t handle) +static odp_schedule_prio_t scalable_queue_sched_prio(odp_queue_t handle) { return qentry_from_int(queue_from_ext(handle))->s.param.sched.prio; }
-static odp_schedule_group_t queue_sched_group(odp_queue_t handle) +static odp_schedule_group_t scalable_queue_sched_group(odp_queue_t handle) { return qentry_from_int(queue_from_ext(handle))->s.param.sched.group; }
-static int queue_lock_count(odp_queue_t handle) +static int scalable_queue_lock_count(odp_queue_t handle) { queue_entry_t *queue = qentry_from_int(queue_from_ext(handle));
@@ -340,8 +341,8 @@ static int queue_lock_count(odp_queue_t handle) (int)queue->s.param.sched.lock_count : -1; }
-static odp_queue_t queue_create(const char *name, - const odp_queue_param_t *param) +static odp_queue_t scalable_queue_create(const char *name, + const odp_queue_param_t *param) { int queue_idx; odp_queue_t handle = ODP_QUEUE_INVALID; @@ -375,7 +376,7 @@ static odp_queue_t queue_create(const char *name, return handle; }
-static int queue_destroy(odp_queue_t handle) +static int scalable_queue_destroy(odp_queue_t handle) { queue_entry_t *queue; sched_elem_t *q; @@ -451,8 +452,8 @@ static int queue_destroy(odp_queue_t handle) return 0; }
-static int queue_context_set(odp_queue_t handle, void *context, - uint32_t len ODP_UNUSED) +static int scalable_queue_context_set(odp_queue_t handle, void *context, + uint32_t len ODP_UNUSED) { odp_mb_full(); qentry_from_int(queue_from_ext(handle))->s.param.context = context; @@ -460,12 +461,12 @@ static int queue_context_set(odp_queue_t handle, void *context, return 0; }
-static void *queue_context(odp_queue_t handle) +static void *scalable_queue_context(odp_queue_t handle) { return qentry_from_int(queue_from_ext(handle))->s.param.context; }
-static odp_queue_t queue_lookup(const char *name) +static odp_queue_t scalable_queue_lookup(const char *name) { uint32_t i;
@@ -645,7 +646,8 @@ static int _queue_enq(queue_t handle, odp_buffer_hdr_t *buf_hdr) _queue_enq_multi(handle, &buf_hdr, 1) == 1) ? 0 : -1; }
-static int queue_enq_multi(odp_queue_t handle, const odp_event_t ev[], int num) +static int scalable_queue_enq_multi(odp_queue_t handle, + const odp_event_t ev[], int num) { odp_buffer_hdr_t *buf_hdr[QUEUE_MULTI_MAX]; queue_entry_t *queue; @@ -662,7 +664,7 @@ static int queue_enq_multi(odp_queue_t handle, const odp_event_t ev[], int num) return queue->s.enqueue_multi(qentry_to_int(queue), buf_hdr, num); }
-static int queue_enq(odp_queue_t handle, odp_event_t ev) +static int scalable_queue_enq(odp_queue_t handle, odp_event_t ev) { odp_buffer_hdr_t *buf_hdr; queue_entry_t *queue; @@ -827,7 +829,8 @@ static odp_buffer_hdr_t *_queue_deq(queue_t handle) return NULL; }
-static int queue_deq_multi(odp_queue_t handle, odp_event_t ev[], int num) +static int scalable_queue_deq_multi(odp_queue_t handle, odp_event_t ev[], + int num) { queue_entry_t *queue;
@@ -835,10 +838,11 @@ static int queue_deq_multi(odp_queue_t handle, odp_event_t ev[], int num) num = QUEUE_MULTI_MAX;
queue = qentry_from_int(queue_from_ext(handle)); - return queue->s.dequeue_multi(qentry_to_int(queue), (odp_buffer_hdr_t **)ev, num); + return queue->s.dequeue_multi(qentry_to_int(queue), + (odp_buffer_hdr_t **)ev, num); }
-static odp_event_t queue_deq(odp_queue_t handle) +static odp_event_t scalable_queue_deq(odp_queue_t handle) { queue_entry_t *queue;
@@ -846,7 +850,7 @@ static odp_event_t queue_deq(odp_queue_t handle) return (odp_event_t)queue->s.dequeue(qentry_to_int(queue)); }
-static void queue_param_init(odp_queue_param_t *params) +static void scalable_queue_param_init(odp_queue_param_t *params) { memset(params, 0, sizeof(odp_queue_param_t)); params->type = ODP_QUEUE_TYPE_PLAIN; @@ -857,7 +861,7 @@ static void queue_param_init(odp_queue_param_t *params) params->sched.group = ODP_SCHED_GROUP_ALL; }
-static int queue_info(odp_queue_t handle, odp_queue_info_t *info) +static int scalable_queue_info(odp_queue_t handle, odp_queue_info_t *info) { uint32_t queue_id; queue_entry_t *queue; @@ -896,7 +900,7 @@ static int queue_info(odp_queue_t handle, odp_queue_info_t *info) return 0; }
-static uint64_t queue_to_u64(odp_queue_t hdl) +static uint64_t scalable_queue_to_u64(odp_queue_t hdl) { return _odp_pri(hdl); } @@ -956,33 +960,42 @@ static odp_queue_t queue_to_ext(queue_t handle) }
/* API functions */ -queue_api_t queue_scalable_api = { - .queue_create = queue_create, - .queue_destroy = queue_destroy, - .queue_lookup = queue_lookup, - .queue_capability = queue_capability, - .queue_context_set = queue_context_set, - .queue_context = queue_context, - .queue_enq = queue_enq, - .queue_enq_multi = queue_enq_multi, - .queue_deq = queue_deq, - .queue_deq_multi = queue_deq_multi, - .queue_type = queue_type, - .queue_sched_type = queue_sched_type, - .queue_sched_prio = queue_sched_prio, - .queue_sched_group = queue_sched_group, - .queue_lock_count = queue_lock_count, - .queue_to_u64 = queue_to_u64, - .queue_param_init = queue_param_init, - .queue_info = queue_info +odp_queue_module_t scalable_queue = { + .base = { + .name = "scalable_queue", + .init_global = scalable_queue_init_global, + .term_global = scalable_queue_term_global, + .init_local = scalable_queue_init_local, + .term_local = scalable_queue_term_local, + }, + .create = scalable_queue_create, + .destroy = scalable_queue_destroy, + .lookup = scalable_queue_lookup, + .capability = scalable_queue_capability, + .context_set = scalable_queue_context_set, + .context = scalable_queue_context, + .enq = scalable_queue_enq, + .enq_multi = scalable_queue_enq_multi, + .deq = scalable_queue_deq, + .deq_multi = scalable_queue_deq_multi, + .type = scalable_queue_type, + .sched_type = scalable_queue_sched_type, + .sched_prio = scalable_queue_sched_prio, + .sched_group = scalable_queue_sched_group, + .lock_count = scalable_queue_lock_count, + .to_u64 = scalable_queue_to_u64, + .param_init = scalable_queue_param_init, + .info = scalable_queue_info, };
+ODP_MODULE_CONSTRUCTOR(scalable_queue) +{ + odp_module_constructor(&scalable_queue); + odp_subsystem_register_module(queue, &scalable_queue); +} + /* Functions towards internal components */ queue_fn_t queue_scalable_fn = { - .init_global = queue_init_global, - .term_global = queue_term_global, - .init_local = queue_init_local, - .term_local = queue_term_local, .from_ext = queue_from_ext, .to_ext = queue_to_ext, .enq = _queue_enq, @@ -993,5 +1006,5 @@ queue_fn_t queue_scalable_fn = { .set_pktout = queue_set_pktout, .get_pktin = queue_get_pktin, .set_pktin = queue_set_pktin, - .set_enq_deq_fn = queue_set_enq_deq_func + .set_enq_deq_fn = queue_set_enq_deq_func, }; diff --git a/platform/linux-generic/queue/subsystem.c b/platform/linux-generic/queue/subsystem.c index d4707f0f..e4c66a2b 100644 --- a/platform/linux-generic/queue/subsystem.c +++ b/platform/linux-generic/queue/subsystem.c @@ -5,8 +5,11 @@ * * SPDX-License-Identifier: BSD-3-Clause */ -#include <odp_module.h> +#include <odp/api/queue.h> +#include <odp_internal.h> +#include <odp_debug_internal.h> #include <odp_queue_subsystem.h> +#include <odp_module.h>
ODP_SUBSYSTEM_DEFINE(queue, "queue public APIs", QUEUE_SUBSYSTEM_VERSION);
@@ -14,3 +17,248 @@ ODP_SUBSYSTEM_CONSTRUCTOR(queue) { odp_subsystem_constructor(queue); } + +int odp_queue_init_global(void) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->base.init_global); + + return mod->base.init_global(); +} + +int odp_queue_term_global(void) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->base.term_global); + + return mod->base.term_global(); +} + +int odp_queue_init_local(void) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->base.init_local); + + return mod->base.init_local(); +} + +int odp_queue_term_local(void) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->base.term_local); + + return mod->base.term_local(); +} + +odp_queue_t odp_queue_create(const char *name, + const odp_queue_param_t *param) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->create); + + return mod->create(name, param); +} + +int odp_queue_destroy(odp_queue_t queue_hdl) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->destroy); + + return mod->destroy(queue_hdl); +} + +odp_queue_t odp_queue_lookup(const char *name) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->lookup); + + return mod->lookup(name); +} + +int odp_queue_capability(odp_queue_capability_t *capa) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->capability); + + return mod->capability(capa); +} + +int odp_queue_context_set(odp_queue_t queue_hdl, void *context, + uint32_t len ODP_UNUSED) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->context_set); + + return mod->context_set(queue_hdl, context, len); +} + +void *odp_queue_context(odp_queue_t queue_hdl) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->context); + + return mod->context(queue_hdl); +} + +int odp_queue_enq(odp_queue_t queue_hdl, odp_event_t ev) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->enq); + + return mod->enq(queue_hdl, ev); +} + +int odp_queue_enq_multi(odp_queue_t queue_hdl, + const odp_event_t events[], int num) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->enq_multi); + + return mod->enq_multi(queue_hdl, events, num); +} + +odp_event_t odp_queue_deq(odp_queue_t queue_hdl) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->deq); + + return mod->deq(queue_hdl); +} + +int odp_queue_deq_multi(odp_queue_t queue_hdl, odp_event_t events[], int num) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->deq_multi); + + return mod->deq_multi(queue_hdl, events, num); +} + +odp_queue_type_t odp_queue_type(odp_queue_t queue_hdl) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->type); + + return mod->type(queue_hdl); +} + +odp_schedule_sync_t odp_queue_sched_type(odp_queue_t queue_hdl) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->sched_type); + + return mod->sched_type(queue_hdl); +} + +odp_schedule_prio_t odp_queue_sched_prio(odp_queue_t queue_hdl) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->sched_prio); + + return mod->sched_prio(queue_hdl); +} + +odp_schedule_group_t odp_queue_sched_group(odp_queue_t queue_hdl) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->sched_group); + + return mod->sched_group(queue_hdl); +} + +int odp_queue_lock_count(odp_queue_t queue_hdl) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->lock_count); + + return mod->lock_count(queue_hdl); +} + +uint64_t odp_queue_to_u64(odp_queue_t queue_hdl) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->to_u64); + + return mod->to_u64(queue_hdl); +} + +void odp_queue_param_init(odp_queue_param_t *params) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->param_init); + + return mod->param_init(params); +} + +int odp_queue_info(odp_queue_t queue_hdl, odp_queue_info_t *info) +{ + odp_queue_module_t *mod = + odp_subsystem_active_module(queue, mod); + + ODP_ASSERT(mod); + ODP_ASSERT(mod->info); + + return mod->info(queue_hdl, info); +}
commit 6448dbc4114c655f1de056ea18003956f3b91b76 Author: Joyce Kong joyce.kong@arm.com Date: Tue Sep 5 14:21:36 2017 +0800
linux-gen: queue: apply modular framework and create subsystem
Signed-off-by: Joyce Kong joyce.kong@arm.com Reviewed-by: Yi He yi.he@linaro.org Reviewed-by: Kevin Wang kevin.wang@arm.com Reviewed-by: Honnappa Nagarahalli honnappa.nagarahalli@arm.com Reviewed-by: Brian Brooks brian.brooks@arm.com Reviewed-by: Bill Fischofer bill.fischofer@linaro.org
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index cbbefa4e..b542966f 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -192,6 +192,7 @@ noinst_HEADERS = \ ${srcdir}/include/odp_packet_socket.h \ ${srcdir}/include/odp_packet_tap.h \ ${srcdir}/include/odp_pkt_queue_internal.h \ + ${srcdir}/include/odp_queue_subsystem.h \ ${srcdir}/include/odp_pool_internal.h \ ${srcdir}/include/odp_pool_subsystem.h \ ${srcdir}/include/odp_posix_extensions.h \ @@ -278,6 +279,7 @@ __LIB__libodp_linux_la_SOURCES = \ odp_pkt_queue.c \ odp_queue.c \ odp_queue_if.c \ + queue/subsystem.c \ odp_queue_scalable.c \ odp_rwlock.c \ odp_rwlock_recursive.c \ diff --git a/platform/linux-generic/include/odp_queue_subsystem.h b/platform/linux-generic/include/odp_queue_subsystem.h new file mode 100644 index 00000000..c63309fa --- /dev/null +++ b/platform/linux-generic/include/odp_queue_subsystem.h @@ -0,0 +1,76 @@ +/* Copyright (c) 2017, ARM Limited. All rights reserved. + * + * Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#ifndef ODP_QUEUE_SUBSYSTEM_H +#define ODP_QUEUE_SUBSYSTEM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp_module.h> +#include <odp/api/queue.h> + +#define QUEUE_SUBSYSTEM_VERSION 0x00010000UL + +/* ODP queue public APIs subsystem */ +ODP_SUBSYSTEM_DECLARE(queue); + +/* Subsystem APIs declarations */ +ODP_SUBSYSTEM_API(queue, odp_queue_t, create, const char *name, + const odp_queue_param_t *param); +ODP_SUBSYSTEM_API(queue, int, destroy, odp_queue_t queue); +ODP_SUBSYSTEM_API(queue, odp_queue_t, lookup, const char *name); +ODP_SUBSYSTEM_API(queue, int, capability, odp_queue_capability_t *capa); +ODP_SUBSYSTEM_API(queue, int, context_set, odp_queue_t queue, + void *context, uint32_t len); +ODP_SUBSYSTEM_API(queue, void *, context, odp_queue_t queue); +ODP_SUBSYSTEM_API(queue, int, enq, odp_queue_t queue, odp_event_t ev); +ODP_SUBSYSTEM_API(queue, int, enq_multi, odp_queue_t queue, + const odp_event_t events[], int num); +ODP_SUBSYSTEM_API(queue, odp_event_t, deq, odp_queue_t queue); +ODP_SUBSYSTEM_API(queue, int, deq_multi, odp_queue_t queue, + odp_event_t events[], int num); +ODP_SUBSYSTEM_API(queue, odp_queue_type_t, type, odp_queue_t queue); +ODP_SUBSYSTEM_API(queue, odp_schedule_sync_t, sched_type, odp_queue_t queue); +ODP_SUBSYSTEM_API(queue, odp_schedule_prio_t, sched_prio, odp_queue_t queue); +ODP_SUBSYSTEM_API(queue, odp_schedule_group_t, sched_group, + odp_queue_t queue); +ODP_SUBSYSTEM_API(queue, int, lock_count, odp_queue_t queue); +ODP_SUBSYSTEM_API(queue, uint64_t, to_u64, odp_queue_t hdl); +ODP_SUBSYSTEM_API(queue, void, param_init, odp_queue_param_t *param); +ODP_SUBSYSTEM_API(queue, int, info, odp_queue_t queue, + odp_queue_info_t *info); + +typedef ODP_MODULE_CLASS(queue) { + odp_module_base_t base; + + odp_api_proto(queue, enq_multi) enq_multi; + odp_api_proto(queue, deq_multi) deq_multi; + odp_api_proto(queue, enq) enq; + odp_api_proto(queue, deq) deq; + odp_api_proto(queue, context) context; + odp_api_proto(queue, sched_type) sched_type; + odp_api_proto(queue, sched_prio) sched_prio; + odp_api_proto(queue, sched_group) sched_group; + odp_api_proto(queue, create) create; + odp_api_proto(queue, destroy) destroy; + odp_api_proto(queue, lookup) lookup; + odp_api_proto(queue, capability) capability; + odp_api_proto(queue, context_set) context_set; + odp_api_proto(queue, type) type; + odp_api_proto(queue, lock_count) lock_count; + odp_api_proto(queue, to_u64) to_u64; + odp_api_proto(queue, param_init) param_init; + odp_api_proto(queue, info) info; +} odp_queue_module_t; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/queue/subsystem.c b/platform/linux-generic/queue/subsystem.c new file mode 100644 index 00000000..d4707f0f --- /dev/null +++ b/platform/linux-generic/queue/subsystem.c @@ -0,0 +1,16 @@ +/* Copyright (c) 2017, ARM Limited. All rights reserved. + * + * Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#include <odp_module.h> +#include <odp_queue_subsystem.h> + +ODP_SUBSYSTEM_DEFINE(queue, "queue public APIs", QUEUE_SUBSYSTEM_VERSION); + +ODP_SUBSYSTEM_CONSTRUCTOR(queue) +{ + odp_subsystem_constructor(queue); +}
-----------------------------------------------------------------------
Summary of changes: platform/linux-dpdk/Makefile.am | 15 +- platform/linux-dpdk/buffer/dpdk.c | 207 ++++++++++++++++ platform/linux-dpdk/include/odp_buffer_inlines.h | 5 + platform/linux-dpdk/include/odp_config_internal.h | 7 + platform/linux-dpdk/odp_buffer.c | 113 --------- platform/linux-dpdk/odp_init.c | 4 +- platform/linux-dpdk/odp_packet.c | 2 +- platform/linux-dpdk/pool/dpdk.c | 62 ----- platform/linux-generic/Makefile.am | 11 +- platform/linux-generic/include/odp_internal.h | 2 + platform/linux-generic/include/odp_queue_if.h | 64 +---- .../linux-generic/include/odp_queue_subsystem.h | 77 ++++++ platform/linux-generic/odp_init.c | 8 +- platform/linux-generic/odp_queue_if.c | 98 +------- .../linux-generic/{odp_queue.c => queue/generic.c} | 112 +++++---- .../{odp_queue_scalable.c => queue/scalable.c} | 113 +++++---- platform/linux-generic/queue/subsystem.c | 264 +++++++++++++++++++++ 17 files changed, 728 insertions(+), 436 deletions(-) create mode 100644 platform/linux-dpdk/buffer/dpdk.c delete mode 100644 platform/linux-dpdk/odp_buffer.c create mode 100644 platform/linux-generic/include/odp_queue_subsystem.h rename platform/linux-generic/{odp_queue.c => queue/generic.c} (85%) rename platform/linux-generic/{odp_queue_scalable.c => queue/scalable.c} (89%) create mode 100644 platform/linux-generic/queue/subsystem.c
hooks/post-receive