From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4B840A0C58; Mon, 23 Aug 2021 21:41:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 69918411C9; Mon, 23 Aug 2021 21:40:44 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 2D37B41165 for ; Mon, 23 Aug 2021 21:40:43 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17NHEvpY021118; Mon, 23 Aug 2021 12:40:40 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=YfMYn9Px1wV46ll6OpiiAManuqdwMkHn9G2zAb5KR4E=; b=hmNfI+vMO2POHMY8Ox8ftzTVmry11fW8WMfPhLVxnmS73vdGxYKuuEhHcKGQIb+LL2Sb /ZntthueSnVFdEFNK0ADN3isLW0CIKaId7cKJ1r6dal8Bzr3ohN5T8r2rzFqfEcaY50J 2H/yCDr9R1QL11ShaT4pvDj5mG4c25F6hForFu2DSbqRsCRhqnOe1lDLSuNgyddcRulQ j18Z1uXIC4/U/VUSSjDs7UMZwIJX9ye2FTCiq0zTAg6dRRPUMn8Vxy2X09e1h0bxIj8c /1AISgZL5a3q9srpZkG5W8wr6nVKkOKvdjjN9CoI7cdCzMEy6UmFC+ngHoErmVQjkyEZ /w== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com with ESMTP id 3amfwj0h64-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 23 Aug 2021 12:40:40 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 23 Aug 2021 12:40:38 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 23 Aug 2021 12:40:38 -0700 Received: from BG-LT7430.marvell.com (BG-LT7430.marvell.com [10.28.177.176]) by maili.marvell.com (Postfix) with ESMTP id 0B0FE5B693C; Mon, 23 Aug 2021 12:40:36 -0700 (PDT) From: To: , Ray Kinsella CC: , , Pavan Nikhilesh Date: Tue, 24 Aug 2021 01:10:09 +0530 Message-ID: <20210823194020.1229-5-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210823194020.1229-1-pbhagavatula@marvell.com> References: <20210823194020.1229-1-pbhagavatula@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: 4MIJHkrhrUgN04w7vGLkMhYK5TpbqJ8N X-Proofpoint-GUID: 4MIJHkrhrUgN04w7vGLkMhYK5TpbqJ8N X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-08-23_04,2021-08-23_01,2020-04-07_01 Subject: [dpdk-dev] [RFC 05/15] eventdev: add helper functions for new driver API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Pavan Nikhilesh Add helper functions and macros to help drivers to transition to new fastpath interface. Signed-off-by: Pavan Nikhilesh --- 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