From: Pavan Nikhilesh <pbhagavat...@marvell.com> Add helper functions and macros to help drivers to transition to new fastpath interface.
Signed-off-by: Pavan Nikhilesh <pbhagavat...@marvell.com> --- lib/eventdev/eventdev_pmd.h | 396 ++++++++++++++++++++++++++++++++++++ lib/eventdev/rte_eventdev.c | 174 ++++++++++++++++ lib/eventdev/version.map | 18 ++ 3 files changed, 588 insertions(+) diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h index 5eaa29fe14..f3a221e688 100644 --- a/lib/eventdev/eventdev_pmd.h +++ b/lib/eventdev/eventdev_pmd.h @@ -1203,6 +1203,402 @@ __rte_internal void rte_event_dev_api_reset(struct rte_eventdev_api *api); +/** + * @internal + * Helper routine for event fastpath APIs. + * Should be called as first thing on entrance to the PMD's rte_event_* + * implementation. + * Does necessary checks and returns pointer to event port identifier. + * + * @param dev_id + * The device identifier of the Event device. + * @param port + * The identifier of the event port. + * + * @return + * Pointer to the event port. + */ +__rte_internal +static inline void * +_rte_event_dev_prolog(uint8_t dev_id, uint8_t port_id) +{ + struct rte_eventdev *dev; + + dev = &rte_eventdevs[dev_id]; + +#ifdef RTE_LIBRTE_EVENTDEV_DEBUG + if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) { + rte_errno = EINVAL; + return 0; + } + + if (port_id >= dev->data->nb_ports) { + rte_errno = EINVAL; + return 0; + } +#endif + + return dev->data->ports[port_id]; +} + +#define _RTE_EVENT_ENQ_FUNC(fn) _rte_event_enq_##fn +#define _RTE_EVENT_ENQ_BURST_FUNC(fn) _rte_event_enq_burst_##fn +#define _RTE_EVENT_DEQ_FUNC(fn) _rte_event_deq_##fn +#define _RTE_EVENT_DEQ_BURST_FUNC(fn) _rte_event_deq_burst_##fn +#define _RTE_EVENT_TXA_ENQ_BURST_FUNC(fn) _rte_event_txa_enq_burst_##fn +#define _RTE_EVENT_CA_ENQ_BURST_FUNC(fn) _rte_event_ca_enq_burst_##fn + +/** + * @internal + * Helper macro to create new API wrappers for existing PMD enqueue/dequeue + * functions. + */ +#define _RTE_EVENT_ENQ_PROTO(fn) \ + uint16_t _RTE_EVENT_ENQ_FUNC(fn)(uint8_t dev_id, uint8_t port_id, \ + const struct rte_event *ev) + +#define _RTE_EVENT_ENQ_BURST_PROTO(fn) \ + uint16_t _RTE_EVENT_ENQ_BURST_FUNC(fn)( \ + uint8_t dev_id, uint8_t port_id, const struct rte_event ev[], \ + uint16_t nb_events) + +#define _RTE_EVENT_DEQ_PROTO(fn) \ + uint16_t _RTE_EVENT_DEQ_FUNC(fn)(uint8_t dev_id, uint8_t port_id, \ + struct rte_event *ev, \ + uint64_t timeout_ticks) + +#define _RTE_EVENT_DEQ_BURST_PROTO(fn) \ + uint16_t _RTE_EVENT_DEQ_BURST_FUNC(fn)( \ + uint8_t dev_id, uint8_t port_id, struct rte_event ev[], \ + uint16_t nb_events, uint64_t timeout_ticks) + +#define _RTE_EVENT_TXA_ENQ_BURST_PROTO(fn) \ + uint16_t _RTE_EVENT_TXA_ENQ_BURST_FUNC(fn)( \ + uint8_t dev_id, uint8_t port_id, struct rte_event ev[], \ + uint16_t nb_events) + +#define _RTE_EVENT_CA_ENQ_BURST_PROTO(fn) \ + uint16_t _RTE_EVENT_CA_ENQ_BURST_FUNC(fn)( \ + uint8_t dev_id, uint8_t port_id, struct rte_event ev[], \ + uint16_t nb_events) + +/** + * @internal + * Helper macro to create new API wrappers for existing PMD enqueue/dequeue + * functions. + */ +#define _RTE_EVENT_ENQ_DEF(fn) \ + _RTE_EVENT_ENQ_PROTO(fn) \ + { \ + void *port = _rte_event_dev_prolog(dev_id, port_id); \ + return fn(port, ev); \ + } + +#define _RTE_EVENT_ENQ_BURST_DEF(fn) \ + _RTE_EVENT_ENQ_BURST_PROTO(fn) \ + { \ + void *port = _rte_event_dev_prolog(dev_id, port_id); \ + return fn(port, ev, nb_events); \ + } + +#define _RTE_EVENT_DEQ_DEF(fn) \ + _RTE_EVENT_DEQ_PROTO(fn) \ + { \ + void *port = _rte_event_dev_prolog(dev_id, port_id); \ + return fn(port, ev, timeout_ticks); \ + } + +#define _RTE_EVENT_DEQ_BURST_DEF(fn) \ + _RTE_EVENT_DEQ_BURST_PROTO(fn) \ + { \ + void *port = _rte_event_dev_prolog(dev_id, port_id); \ + return fn(port, ev, nb_events, timeout_ticks); \ + } + +#define _RTE_EVENT_TXA_ENQ_BURST_DEF(fn) \ + _RTE_EVENT_TXA_ENQ_BURST_PROTO(fn) \ + { \ + void *port = _rte_event_dev_prolog(dev_id, port_id); \ + return fn(port, ev, nb_events); \ + } + +#define _RTE_EVENT_CA_ENQ_BURST_DEF(fn) \ + _RTE_EVENT_CA_ENQ_BURST_PROTO(fn) \ + { \ + void *port = _rte_event_dev_prolog(dev_id, port_id); \ + return fn(port, ev, nb_events); \ + } + +/** + * @internal + * Helper routine to get enqueue function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * The function if valid else NULL + */ +__rte_internal +rte_event_enqueue_t +rte_event_get_enq_fn(uint8_t dev_id); + +/** + * @internal + * Helper routine to get enqueue burst function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * The function if valid else NULL + */ +__rte_internal +rte_event_enqueue_burst_t +rte_event_get_enq_burst_fn(uint8_t dev_id); + +/** + * @internal + * Helper routine to get enqueue new events function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * The function if valid else NULL + */ +__rte_internal +rte_event_enqueue_burst_t +rte_event_get_enq_new_burst_fn(uint8_t dev_id); + +/** + * @internal + * Helper routine to get enqueue forward events function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * The function if valid else NULL + */ +__rte_internal +rte_event_enqueue_burst_t +rte_event_get_enq_fwd_burst_fn(uint8_t dev_id); + + +/** + * @internal + * Helper routine to get dequeue function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * The function if valid else NULL + */ +__rte_internal +rte_event_dequeue_t +rte_event_get_deq_fn(uint8_t dev_id); + +/** + * @internal + * Helper routine to get dequeue burst function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * The function if valid else NULL + */ +__rte_internal +rte_event_dequeue_burst_t +rte_event_get_deq_burst_fn(uint8_t dev_id); + +/** + * @internal + * Helper routine to get Tx adapter enqueue function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * The function if valid else NULL + */ +__rte_internal +rte_event_tx_adapter_enqueue_t +rte_event_get_tx_adapter_enq_fn(uint8_t dev_id); + +/** + * + * @internal + * Helper routine to get Tx adapter enqueue same port function of a given + * device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * The function if valid else NULL + */ +__rte_internal +rte_event_tx_adapter_enqueue_t +rte_event_get_tx_adapter_enq_same_dest_fn(uint8_t dev_id); + + +/** + * @internal + * Helper routine to get crypto adapter enqueue function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * The enqueue function if valid else NULL + */ +__rte_internal +rte_event_crypto_adapter_enqueue_t +rte_event_get_crypto_adapter_enq_fn(uint8_t dev_id); + +/** + * @internal + * Helper routine to set enqueue function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * 0 Success. + * -EINVALID Failure if dev_id or fn are in-valid. + */ +__rte_internal +int +rte_event_set_enq_fn(uint8_t dev_id, rte_event_enqueue_t fn); + +/** + * @internal + * Helper routine to set enqueue burst function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * 0 Success. + * -EINVALID Failure if dev_id or fn are in-valid. + */ +__rte_internal +int +rte_event_set_enq_burst_fn(uint8_t dev_id, rte_event_enqueue_burst_t fn); + +/** + * @internal + * Helper routine to set enqueue new burst function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * 0 Success. + * -EINVALID Failure if dev_id or fn are in-valid. + */ +__rte_internal +int +rte_event_set_enq_new_burst_fn(uint8_t dev_id, rte_event_enqueue_burst_t fn); + +/** + * @internal + * Helper routine to set enqueue forward burst function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * 0 Success. + * -EINVALID Failure if dev_id or fn are in-valid. + */ +__rte_internal +int +rte_event_set_enq_fwd_burst_fn(uint8_t dev_id, rte_event_enqueue_burst_t fn); + +/** + * @internal + * Helper routine to set dequeue function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * 0 Success. + * -EINVALID Failure if dev_id or fn are in-valid. + */ +__rte_internal +int +rte_event_set_deq_fn(uint8_t dev_id, rte_event_dequeue_t fn); + +/** + * @internal + * Helper routine to set dequeue burst function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * 0 Success. + * -EINVALID Failure if dev_id or fn are in-valid. + */ +__rte_internal +int +rte_event_set_deq_burst_fn(uint8_t dev_id, rte_event_dequeue_burst_t fn); + +/** + * @internal + * Helper routine to set Tx adapter enqueue burst function of a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * 0 Success. + * -EINVALID Failure if dev_id or fn are in-valid. + */ +__rte_internal +int +rte_event_set_tx_adapter_enq_fn(uint8_t dev_id, + rte_event_tx_adapter_enqueue_t fn); + +/** + * @internal + * Helper routine to set Tx adapter enqueue same destination burst function of + * a given device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * 0 Success. + * -EINVALID Failure if dev_id or fn are in-valid. + */ +__rte_internal +int +rte_event_set_tx_adapter_enq_same_dest_fn(uint8_t dev_id, + rte_event_tx_adapter_enqueue_t fn); + +/** + * @internal + * Helper routine to set crypto adapter enqueue burst function of a given + * device. + * + * @param dev_id + * The device identifier of the Event device. + * + * @return + * 0 Success. + * -EINVALID Failure if dev_id or fn are in-valid. + */ +__rte_internal +int +rte_event_set_crypto_adapter_enq_fn(uint8_t dev_id, + rte_event_crypto_adapter_enqueue_t fn); + #ifdef __cplusplus } #endif diff --git a/lib/eventdev/rte_eventdev.c b/lib/eventdev/rte_eventdev.c index 5ff8596788..941e1e7c8e 100644 --- a/lib/eventdev/rte_eventdev.c +++ b/lib/eventdev/rte_eventdev.c @@ -1866,6 +1866,180 @@ handle_queue_xstats(const char *cmd __rte_unused, return eventdev_build_telemetry_data(dev_id, mode, port_queue_id, d); } +rte_event_enqueue_t +rte_event_get_enq_fn(uint8_t dev_id) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS) { + rte_errno = EINVAL; + return NULL; + } + return rte_eventdev_api[dev_id].enqueue; +} + +rte_event_enqueue_burst_t +rte_event_get_enq_burst_fn(uint8_t dev_id) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS) { + rte_errno = EINVAL; + return NULL; + } + return rte_eventdev_api[dev_id].enqueue_burst; +} + +rte_event_enqueue_burst_t +rte_event_get_enq_new_burst_fn(uint8_t dev_id) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS) { + rte_errno = EINVAL; + return NULL; + } + return rte_eventdev_api[dev_id].enqueue_new_burst; +} + +rte_event_enqueue_burst_t +rte_event_get_enq_fwd_burst_fn(uint8_t dev_id) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS) { + rte_errno = EINVAL; + return NULL; + } + return rte_eventdev_api[dev_id].enqueue_forward_burst; +} + +rte_event_dequeue_t +rte_event_get_deq_fn(uint8_t dev_id) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS) { + rte_errno = EINVAL; + return NULL; + } + return rte_eventdev_api[dev_id].dequeue; +} + +rte_event_dequeue_burst_t +rte_event_get_deq_burst_fn(uint8_t dev_id) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS) { + rte_errno = EINVAL; + return NULL; + } + return rte_eventdev_api[dev_id].dequeue_burst; +} + +rte_event_tx_adapter_enqueue_t +rte_event_get_tx_adapter_enq_fn(uint8_t dev_id) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS) { + rte_errno = EINVAL; + return NULL; + } + return rte_eventdev_api[dev_id].txa_enqueue; +} + +rte_event_tx_adapter_enqueue_t +rte_event_get_tx_adapter_enq_same_dest_fn(uint8_t dev_id) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS) { + rte_errno = EINVAL; + return NULL; + } + return rte_eventdev_api[dev_id].txa_enqueue_same_dest; +} + +rte_event_crypto_adapter_enqueue_t +rte_event_get_crypto_adapter_enq_fn(uint8_t dev_id) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS) { + rte_errno = EINVAL; + return NULL; + } + return rte_eventdev_api[dev_id].ca_enqueue; +} + +int +rte_event_set_enq_fn(uint8_t dev_id, rte_event_enqueue_t fn) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS || fn == NULL) + return -EINVAL; + rte_eventdev_api[dev_id].enqueue = fn; + return 0; +} + +int +rte_event_set_enq_burst_fn(uint8_t dev_id, rte_event_enqueue_burst_t fn) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS || fn == NULL) + return -EINVAL; + rte_eventdev_api[dev_id].enqueue_burst = fn; + return 0; +} + +int +rte_event_set_enq_new_burst_fn(uint8_t dev_id, rte_event_enqueue_burst_t fn) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS || fn == NULL) + return -EINVAL; + rte_eventdev_api[dev_id].enqueue_new_burst = fn; + return 0; +} + +int +rte_event_set_enq_fwd_burst_fn(uint8_t dev_id, rte_event_enqueue_burst_t fn) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS || fn == NULL) + return -EINVAL; + rte_eventdev_api[dev_id].enqueue_forward_burst = fn; + return 0; +} + +int +rte_event_set_deq_fn(uint8_t dev_id, rte_event_dequeue_t fn) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS || fn == NULL) + return -EINVAL; + rte_eventdev_api[dev_id].dequeue = fn; + return 0; +} + +int +rte_event_set_deq_burst_fn(uint8_t dev_id, rte_event_dequeue_burst_t fn) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS || fn == NULL) + return -EINVAL; + rte_eventdev_api[dev_id].dequeue_burst = fn; + return 0; +} + +int +rte_event_set_tx_adapter_enq_fn(uint8_t dev_id, + rte_event_tx_adapter_enqueue_t fn) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS || fn == NULL) + return -EINVAL; + rte_eventdev_api[dev_id].txa_enqueue = fn; + return 0; +} + +int +rte_event_set_tx_adapter_enq_same_dest_fn(uint8_t dev_id, + rte_event_tx_adapter_enqueue_t fn) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS || fn == NULL) + return -EINVAL; + rte_eventdev_api[dev_id].txa_enqueue_same_dest = fn; + return 0; +} + +int +rte_event_set_crypto_adapter_enq_fn(uint8_t dev_id, + rte_event_crypto_adapter_enqueue_t fn) +{ + if (dev_id >= RTE_EVENT_MAX_DEVS || fn == NULL) + return -EINVAL; + rte_eventdev_api[dev_id].ca_enqueue = fn; + return 0; +} + RTE_INIT(eventdev_init_telemetry) { rte_telemetry_register_cmd("/eventdev/dev_list", handle_dev_list, diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index bc2912dcfd..d89cbc337e 100644 --- a/lib/eventdev/version.map +++ b/lib/eventdev/version.map @@ -145,6 +145,24 @@ INTERNAL { global: rte_event_dev_api_reset; + rte_event_get_crypto_adapter_enq_fn; + rte_event_get_deq_burst_fn; + rte_event_get_deq_fn; + rte_event_get_enq_burst_fn; + rte_event_get_enq_fn; + rte_event_get_enq_fwd_burst_fn; + rte_event_get_enq_new_burst_fn; + rte_event_get_tx_adapter_enq_fn; + rte_event_get_tx_adapter_enq_same_dest_fn; + rte_event_set_crypto_adapter_enq_fn; + rte_event_set_deq_burst_fn; + rte_event_set_deq_fn; + rte_event_set_enq_burst_fn; + rte_event_set_enq_fn; + rte_event_set_enq_fwd_burst_fn; + rte_event_set_enq_new_burst_fn; + rte_event_set_tx_adapter_enq_fn; + rte_event_set_tx_adapter_enq_same_dest_fn; rte_event_pmd_selftest_seqn_dynfield_offset; rte_event_pmd_allocate; rte_event_pmd_get_named_dev; -- 2.17.1