From: Pavan Nikhilesh <pbhagavat...@marvell.com> Move fastpath inline function pointers from rte_eventdev into a separate structure accessed via a flat array. The intension is to make rte_eventdev and related structures private to avoid future API/ABI breakages.`
Signed-off-by: Pavan Nikhilesh <pbhagavat...@marvell.com> --- lib/eventdev/eventdev_pmd.h | 10 ++++ lib/eventdev/eventdev_private.c | 100 +++++++++++++++++++++++++++++++ lib/eventdev/meson.build | 1 + lib/eventdev/rte_eventdev.c | 25 +++++++- lib/eventdev/rte_eventdev_core.h | 44 ++++++++++++++ lib/eventdev/version.map | 4 ++ 6 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 lib/eventdev/eventdev_private.c diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h index a25d3f1fb5..5eaa29fe14 100644 --- a/lib/eventdev/eventdev_pmd.h +++ b/lib/eventdev/eventdev_pmd.h @@ -1193,6 +1193,16 @@ __rte_internal int rte_event_pmd_release(struct rte_eventdev *eventdev); +/** + * Reset eventdevice fastpath APIs to dummy values. + * + * @param rba + * The *api* pointer to reset. + */ +__rte_internal +void +rte_event_dev_api_reset(struct rte_eventdev_api *api); + #ifdef __cplusplus } #endif diff --git a/lib/eventdev/eventdev_private.c b/lib/eventdev/eventdev_private.c new file mode 100644 index 0000000000..c60fd2b522 --- /dev/null +++ b/lib/eventdev/eventdev_private.c @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2021 Marvell. + */ + +#include "eventdev_pmd.h" +#include "rte_eventdev.h" + +static uint16_t +dummy_event_enqueue(__rte_unused uint8_t dev_id, __rte_unused uint8_t port_id, + __rte_unused const struct rte_event *ev) +{ + RTE_EDEV_LOG_ERR( + "event enqueue requested for unconfigured event device"); + return 0; +} + +static uint16_t +dummy_event_enqueue_burst(__rte_unused uint8_t dev_id, + __rte_unused uint8_t port_id, + __rte_unused const struct rte_event ev[], + __rte_unused uint16_t nb_events) +{ + RTE_EDEV_LOG_ERR( + "event enqueue burst requested for unconfigured event device"); + return 0; +} + +static uint16_t +dummy_event_dequeue(__rte_unused uint8_t dev_id, __rte_unused uint8_t port_id, + __rte_unused struct rte_event *ev, + __rte_unused uint64_t timeout_ticks) +{ + RTE_EDEV_LOG_ERR( + "event dequeue requested for unconfigured event device"); + return 0; +} + +static uint16_t +dummy_event_dequeue_burst(__rte_unused uint8_t dev_id, + __rte_unused uint8_t port_id, + __rte_unused struct rte_event ev[], + __rte_unused uint16_t nb_events, + __rte_unused uint64_t timeout_ticks) +{ + RTE_EDEV_LOG_ERR( + "event dequeue burst requested for unconfigured event device"); + return 0; +} + +static uint16_t +dummy_event_tx_adapter_enqueue(__rte_unused uint8_t dev_id, + __rte_unused uint8_t port_id, + __rte_unused struct rte_event ev[], + __rte_unused uint16_t nb_events) +{ + RTE_EDEV_LOG_ERR( + "event Tx adapter enqueue requested for unconfigured event device"); + return 0; +} + +static uint16_t +dummy_event_tx_adapter_enqueue_same_dest(__rte_unused uint8_t dev_id, + __rte_unused uint8_t port_id, + __rte_unused struct rte_event ev[], + __rte_unused uint16_t nb_events) +{ + RTE_EDEV_LOG_ERR( + "event Tx adapter enqueue same destination requested for unconfigured event device"); + return 0; +} + +static uint16_t +dummy_event_crypto_adapter_enqueue(__rte_unused uint8_t dev_id, + __rte_unused uint8_t port_id, + __rte_unused struct rte_event ev[], + __rte_unused uint16_t nb_events) +{ + RTE_EDEV_LOG_ERR( + "event crypto adapter enqueue requested for unconfigured event device"); + return 0; +} + +void +rte_event_dev_api_reset(struct rte_eventdev_api *api) +{ + static const struct rte_eventdev_api dummy = { + .enqueue = dummy_event_enqueue, + .enqueue_burst = dummy_event_enqueue_burst, + .enqueue_new_burst = dummy_event_enqueue_burst, + .enqueue_forward_burst = dummy_event_enqueue_burst, + .dequeue = dummy_event_dequeue, + .dequeue_burst = dummy_event_dequeue_burst, + .txa_enqueue = dummy_event_tx_adapter_enqueue, + .txa_enqueue_same_dest = + dummy_event_tx_adapter_enqueue_same_dest, + .ca_enqueue = dummy_event_crypto_adapter_enqueue, + }; + + *api = dummy; +} diff --git a/lib/eventdev/meson.build b/lib/eventdev/meson.build index 8b51fde361..9051ff04b7 100644 --- a/lib/eventdev/meson.build +++ b/lib/eventdev/meson.build @@ -8,6 +8,7 @@ else endif sources = files( + 'eventdev_private.c', 'rte_eventdev.c', 'rte_event_ring.c', 'eventdev_trace_points.c', diff --git a/lib/eventdev/rte_eventdev.c b/lib/eventdev/rte_eventdev.c index 21c5c55086..5ff8596788 100644 --- a/lib/eventdev/rte_eventdev.c +++ b/lib/eventdev/rte_eventdev.c @@ -44,6 +44,9 @@ static struct rte_eventdev_global eventdev_globals = { .nb_devs = 0 }; +/* Public fastpath APIs. */ +struct rte_eventdev_api *rte_eventdev_api; + /* Event dev north bound API implementation */ uint8_t @@ -394,8 +397,9 @@ int rte_event_dev_configure(uint8_t dev_id, const struct rte_event_dev_config *dev_conf) { - struct rte_eventdev *dev; struct rte_event_dev_info info; + struct rte_eventdev_api api; + struct rte_eventdev *dev; int diag; RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); @@ -564,10 +568,14 @@ rte_event_dev_configure(uint8_t dev_id, return diag; } + api = rte_eventdev_api[dev_id]; + rte_event_dev_api_reset(&api); + /* Configure the device */ diag = (*dev->dev_ops->dev_configure)(dev); if (diag != 0) { RTE_EDEV_LOG_ERR("dev%d dev_configure = %d", dev_id, diag); + rte_event_dev_api_reset(&api); rte_event_dev_queue_config(dev, 0); rte_event_dev_port_config(dev, 0); } @@ -1396,6 +1404,7 @@ rte_event_dev_close(uint8_t dev_id) return -EBUSY; } + rte_event_dev_api_reset(&rte_eventdev_api[dev_id]); rte_eventdev_trace_close(dev_id); return (*dev->dev_ops->dev_close)(dev); } @@ -1479,6 +1488,20 @@ rte_event_pmd_allocate(const char *name, int socket_id) } } + if (rte_eventdev_api == NULL) { + rte_eventdev_api = rte_zmalloc("Eventdev_api", + sizeof(struct rte_eventdev_api) * + RTE_EVENT_MAX_DEVS, + RTE_CACHE_LINE_SIZE); + if (rte_eventdev_api == NULL) { + RTE_EDEV_LOG_ERR( + "Unable to allocate memory for fastpath eventdev API array"); + return NULL; + } + for (dev_id = 0; dev_id < RTE_EVENT_MAX_DEVS; dev_id++) + rte_event_dev_api_reset(&rte_eventdev_api[dev_id]); + } + if (rte_event_pmd_get_named_dev(name) != NULL) { RTE_EDEV_LOG_ERR("Event device with name %s already " "allocated!", name); diff --git a/lib/eventdev/rte_eventdev_core.h b/lib/eventdev/rte_eventdev_core.h index 97dfec1ae1..4a7edacb0e 100644 --- a/lib/eventdev/rte_eventdev_core.h +++ b/lib/eventdev/rte_eventdev_core.h @@ -12,23 +12,39 @@ extern "C" { #endif +typedef uint16_t (*rte_event_enqueue_t)(uint8_t dev_id, uint8_t port_id, + const struct rte_event *ev); typedef uint16_t (*event_enqueue_t)(void *port, const struct rte_event *ev); /**< @internal Enqueue event on port of a device */ +typedef uint16_t (*rte_event_enqueue_burst_t)(uint8_t dev_id, uint8_t port_id, + const struct rte_event ev[], + uint16_t nb_events); typedef uint16_t (*event_enqueue_burst_t)(void *port, const struct rte_event ev[], uint16_t nb_events); /**< @internal Enqueue burst of events on port of a device */ +typedef uint16_t (*rte_event_dequeue_t)(uint8_t dev_id, uint8_t port_id, + struct rte_event *ev, + uint64_t timeout_ticks); typedef uint16_t (*event_dequeue_t)(void *port, struct rte_event *ev, uint64_t timeout_ticks); /**< @internal Dequeue event from port of a device */ +typedef uint16_t (*rte_event_dequeue_burst_t)(uint8_t dev_id, uint8_t port_id, + struct rte_event ev[], + uint16_t nb_events, + uint64_t timeout_ticks); typedef uint16_t (*event_dequeue_burst_t)(void *port, struct rte_event ev[], uint16_t nb_events, uint64_t timeout_ticks); /**< @internal Dequeue burst of events from port of a device */ +typedef uint16_t (*rte_event_tx_adapter_enqueue_t)(uint8_t dev_id, + uint8_t port_id, + struct rte_event ev[], + uint16_t nb_events); typedef uint16_t (*event_tx_adapter_enqueue)(void *port, struct rte_event ev[], uint16_t nb_events); /**< @internal Enqueue burst of events on port of a device */ @@ -40,11 +56,39 @@ typedef uint16_t (*event_tx_adapter_enqueue_same_dest)(void *port, * burst having same destination Ethernet port & Tx queue. */ +typedef uint16_t (*rte_event_crypto_adapter_enqueue_t)(uint8_t dev_id, + uint8_t port_id, + struct rte_event ev[], + uint16_t nb_events); typedef uint16_t (*event_crypto_adapter_enqueue)(void *port, struct rte_event ev[], uint16_t nb_events); /**< @internal Enqueue burst of events on crypto adapter */ +struct rte_eventdev_api { + rte_event_enqueue_t enqueue; + /**< PMD enqueue function. */ + rte_event_enqueue_burst_t enqueue_burst; + /**< PMD enqueue burst function. */ + rte_event_enqueue_burst_t enqueue_new_burst; + /**< PMD enqueue burst new function. */ + rte_event_enqueue_burst_t enqueue_forward_burst; + /**< PMD enqueue burst fwd function. */ + rte_event_dequeue_t dequeue; + /**< PMD dequeue function. */ + rte_event_dequeue_burst_t dequeue_burst; + /**< PMD dequeue burst function. */ + rte_event_tx_adapter_enqueue_t txa_enqueue; + /**< PMD Tx adapter enqueue function. */ + rte_event_tx_adapter_enqueue_t txa_enqueue_same_dest; + /**< PMD Tx adapter enqueue same destination function. */ + rte_event_crypto_adapter_enqueue_t ca_enqueue; + /**< PMD Crypto adapter enqueue function. */ + uintptr_t reserved[2]; +} __rte_cache_aligned; + +extern struct rte_eventdev_api *rte_eventdev_api; + #define RTE_EVENTDEV_NAME_MAX_LEN (64) /**< @internal Max length of name of event PMD */ diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index 5f1fe412a4..bc2912dcfd 100644 --- a/lib/eventdev/version.map +++ b/lib/eventdev/version.map @@ -85,6 +85,9 @@ DPDK_22 { rte_event_timer_cancel_burst; rte_eventdevs; + #added in 21.11 + rte_eventdev_api; + local: *; }; @@ -141,6 +144,7 @@ EXPERIMENTAL { INTERNAL { global: + rte_event_dev_api_reset; rte_event_pmd_selftest_seqn_dynfield_offset; rte_event_pmd_allocate; rte_event_pmd_get_named_dev; -- 2.17.1