From patchwork Sun Aug 29 12:51:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 97513 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 01DF0A0C46; Sun, 29 Aug 2021 14:52:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 355EF410D7; Sun, 29 Aug 2021 14:52:09 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id E5452410D7 for ; Sun, 29 Aug 2021 14:52:07 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 17T9b6dZ028559; Sun, 29 Aug 2021 05:52:02 -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=3zP8+v3yJCyfXqp+AONzzdSw7abgSQ519Pz24LLkLoE=; b=SKATlbcZXHO+laxo9vwT0tC91unSzmumyb3xxKnQ2OhcR41q2OrJS9Mgf0eepLE/29si MtVfX5XHNtb9BpD3Yvc+a6w/7syxamEHWRNVPfhKrCkqT+vnV4V25fprYjLhWLloa11f 4KGW3GXIWmcmTwWr+V7V/Zm0acMjZCvl1+xF/mkCsJb6GXJtJGi9ftFQvfA7TFOemScZ EE2+15xBbYwIvBnH8cXzjlCh/dQzD8dW2PkO5I5Ok3Lj3QsD8KG852t4DtzHMlNhVaGv KoMNIjsCstDxTRzf3dMMZyZEPSVmTH19VRT21RUv0h4c2Ya8fW/GJ8D3zMktdR7ZKKvc /g== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 3aqmnmtmj5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 29 Aug 2021 05:52:01 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sun, 29 Aug 2021 05:51:59 -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; Sun, 29 Aug 2021 05:51:59 -0700 Received: from localhost.localdomain (unknown [10.28.36.185]) by maili.marvell.com (Postfix) with ESMTP id 76C083F706F; Sun, 29 Aug 2021 05:51:54 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , , , , , , , , , Akhil Goyal Date: Sun, 29 Aug 2021 18:21:33 +0530 Message-ID: <20210829125139.2173235-3-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210829125139.2173235-1-gakhil@marvell.com> References: <20210829125139.2173235-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: Vts_vZHaLObOWaESC4o-Hq2ggrUJaB9f X-Proofpoint-GUID: Vts_vZHaLObOWaESC4o-Hq2ggrUJaB9f 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-29_04,2021-08-27_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH 2/8] cryptodev: move inline APIs into separate structure 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" Move fastpath inline function pointers from rte_cryptodev into a separate structure accessed via a flat array. The intension is to make rte_cryptodev and related structures private to avoid future API/ABI breakages. Signed-off-by: Akhil Goyal Tested-by: Rebecca Troy Acked-by: Fan Zhang --- lib/cryptodev/cryptodev_pmd.c | 33 ++++++++++++++++++++++++++++++ lib/cryptodev/cryptodev_pmd.h | 9 ++++++++ lib/cryptodev/rte_cryptodev.c | 3 +++ lib/cryptodev/rte_cryptodev_core.h | 19 +++++++++++++++++ lib/cryptodev/version.map | 4 ++++ 5 files changed, 68 insertions(+) diff --git a/lib/cryptodev/cryptodev_pmd.c b/lib/cryptodev/cryptodev_pmd.c index 71e34140cd..46772dc355 100644 --- a/lib/cryptodev/cryptodev_pmd.c +++ b/lib/cryptodev/cryptodev_pmd.c @@ -158,3 +158,36 @@ rte_cryptodev_pmd_destroy(struct rte_cryptodev *cryptodev) return 0; } + +static uint16_t +dummy_crypto_enqueue_burst(__rte_unused uint8_t dev_id, + __rte_unused uint8_t qp_id, + __rte_unused struct rte_crypto_op **ops, + __rte_unused uint16_t nb_ops) +{ + CDEV_LOG_ERR( + "crypto enqueue burst requested for unconfigured crypto device"); + return 0; +} + +static uint16_t +dummy_crypto_dequeue_burst(__rte_unused uint8_t dev_id, + __rte_unused uint8_t qp_id, + __rte_unused struct rte_crypto_op **ops, + __rte_unused uint16_t nb_ops) +{ + CDEV_LOG_ERR( + "crypto enqueue burst requested for unconfigured crypto device"); + return 0; +} + +void +rte_cryptodev_api_reset(struct rte_cryptodev_api *api) +{ + static const struct rte_cryptodev_api dummy = { + .enqueue_burst = dummy_crypto_enqueue_burst, + .dequeue_burst = dummy_crypto_dequeue_burst, + }; + + *api = dummy; +} diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h index f775ba6beb..eeaea13a23 100644 --- a/lib/cryptodev/cryptodev_pmd.h +++ b/lib/cryptodev/cryptodev_pmd.h @@ -520,6 +520,15 @@ RTE_INIT(init_ ##driver_id)\ driver_id = rte_cryptodev_allocate_driver(&crypto_drv, &(drv));\ } +/** + * Reset crypto device fastpath APIs to dummy values. + * + * @param The *api* pointer to reset. + */ +__rte_internal +void +rte_cryptodev_api_reset(struct rte_cryptodev_api *api); + static inline void * get_sym_session_private_data(const struct rte_cryptodev_sym_session *sess, uint8_t driver_id) { diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 9fa3aff1d3..26f8390668 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -54,6 +54,9 @@ static struct rte_cryptodev_global cryptodev_globals = { .nb_devs = 0 }; +/* Public fastpath APIs. */ +struct rte_cryptodev_api *rte_cryptodev_api; + /* spinlock for crypto device callbacks */ static rte_spinlock_t rte_cryptodev_cb_lock = RTE_SPINLOCK_INITIALIZER; diff --git a/lib/cryptodev/rte_cryptodev_core.h b/lib/cryptodev/rte_cryptodev_core.h index 1633e55889..ec38f70e0c 100644 --- a/lib/cryptodev/rte_cryptodev_core.h +++ b/lib/cryptodev/rte_cryptodev_core.h @@ -25,6 +25,25 @@ typedef uint16_t (*enqueue_pkt_burst_t)(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops); /**< Enqueue packets for processing on queue pair of a device. */ +typedef uint16_t (*rte_crypto_dequeue_burst_t)(uint8_t dev_id, uint8_t qp_id, + struct rte_crypto_op **ops, + uint16_t nb_ops); +/**< @internal Dequeue processed packets from queue pair of a device. */ +typedef uint16_t (*rte_crypto_enqueue_burst_t)(uint8_t dev_id, uint8_t qp_id, + struct rte_crypto_op **ops, + uint16_t nb_ops); +/**< @internal Enqueue packets for processing on queue pair of a device. */ + +struct rte_cryptodev_api { + rte_crypto_enqueue_burst_t enqueue_burst; + /**< PMD enqueue burst function. */ + rte_crypto_dequeue_burst_t dequeue_burst; + /**< PMD dequeue burst function. */ + uintptr_t reserved[6]; +} __rte_cache_aligned; + +extern struct rte_cryptodev_api *rte_cryptodev_api; + /** * @internal * The data part, with no function pointers, associated with each device. diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map index 2fdf70002d..050089ae55 100644 --- a/lib/cryptodev/version.map +++ b/lib/cryptodev/version.map @@ -57,6 +57,9 @@ DPDK_22 { rte_cryptodev_sym_session_init; rte_cryptodevs; + #added in 21.11 + rte_cryptodev_api; + local: *; }; @@ -114,6 +117,7 @@ INTERNAL { global: rte_cryptodev_allocate_driver; + rte_cryptodev_api_reset; rte_cryptodev_pmd_allocate; rte_cryptodev_pmd_callback_process; rte_cryptodev_pmd_create;