From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 00883A046B for ; Fri, 23 Aug 2019 12:43:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4C8E21BFD5; Fri, 23 Aug 2019 12:42:29 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 7B6751BFAF for ; Fri, 23 Aug 2019 12:42:21 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7NAe7WE025810; Fri, 23 Aug 2019 03:42:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=rElaDV7XgYz09iodMjbR4M3X45a1tJ9mko/MkwJo/FI=; b=x7Hzo3MJA1IZE6C9yM61eNSQtdnWv4HKOzXzI8fxvYmzfb/NrcaaVqRkCwIq5kBupGEX EvlR1R5nuOQgljWC+8C0mRRZ3zmHo1drQg3L+ex0V/nEdxaIQUtd6zwqsRZ0YZsO1+xS AHfZ0bj6B9k0cnLy+vtDf9noT8lG4mVN1Lh+2XHtgIOVWcoBWTDiUQcl9fYkAXxTMJhT db8sYV1/nDv/0Cm0SqJAge2ZaMnExCyhzAEAQBdEZdcTGxL+q1+d6xnaA/IRX07xm24x UDATRKIkaI9xq2ug9a8ae/MxkZGOYc7hbaUfj3pdz8klp/SR7n+nLrIk2mY+xxVAweJv DQ== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2uhag2801s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 23 Aug 2019 03:42:20 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 23 Aug 2019 03:42:18 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.36.59) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Fri, 23 Aug 2019 03:42:18 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GJg+hDbgNFlWpRoBUljkd83Feh8IjQibPzTH2FEt8/ceW/fm/JKlDnBOL0eiFG9njgV1huY+TXgUzXAil6LCUEv3j+EnKxen4MtXhPRfTilEWdrAPLAJHYeeQ9akeY6eB/Uk4Lfwd9Fsct83zrH8D6wN0YpgRtJip9HX7/N+6ptBGOhOiXykwjo0seda40/tKacEzJUgFgikgimHF7ya2n9yilzxbQvpD9Mg+iAr5aiVzlJ+u7RYiC3WqFTKk5kFJumhzDrkGloAekTll17eagMbkwneRB89v5WLkbXNKXBdUJsXsXfH3sDDjrCwMNIPSGbpGaY4uUYbcqR6B8eHGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rElaDV7XgYz09iodMjbR4M3X45a1tJ9mko/MkwJo/FI=; b=Xm+6j5Wh7bUOW1/mR4WsCL1ZCUN6UJdxWQbgTs1qj7KRRN6XlFd7Ba5HzlOOSdnkYieSaUHNbuat0zzds/8ib/6t3ujpRYlE8ljEf65IIe7ed6Yp2NPy/oCDGRdBFvtaFEdJ4vw2G06XSyEj+7OMWjtixt9zdXMAX9gSeb18xhtCRGd3zRnMW6q+Rf+3wrKLaEW5QCxUaQS4pvO1hAP2O4TVI/I5y7bfMqh2i4SgTT0gppY61vLzOBk2M5fp6IMiIj/a0F5wWrBsEL7t5zZgedA1+rPbEPXRk4BKwobx/3fUch/QgUov7qKE5ZBfPu+lx7hB329C+30WAhwbC7uCeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector2-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rElaDV7XgYz09iodMjbR4M3X45a1tJ9mko/MkwJo/FI=; b=Pn/F/QIlbbDJH5I3VgiPsA7/NgLO4sI0byNLwjdiUk4G5TaoDF6ElWAcDmGkYLusbZu6uL6D3FaANNFpotyEw9/ypIlcBRTBQsOoa2y32Be8IWO7uHwUcDjthF713L65/snBLMg/NUpMWxppXMyyxvUzpwIiMnHHGtUFUM6helo= Received: from MN2PR18MB2797.namprd18.prod.outlook.com (20.179.22.16) by MN2PR18MB2830.namprd18.prod.outlook.com (20.179.23.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.18; Fri, 23 Aug 2019 10:42:15 +0000 Received: from MN2PR18MB2797.namprd18.prod.outlook.com ([fe80::28ff:b1d2:ef69:5e84]) by MN2PR18MB2797.namprd18.prod.outlook.com ([fe80::28ff:b1d2:ef69:5e84%5]) with mapi id 15.20.2178.018; Fri, 23 Aug 2019 10:42:15 +0000 From: Nagadheeraj Rottela To: "akhil.goyal@nxp.com" , "pablo.de.lara.guarch@intel.com" CC: "dev@dpdk.org" , Srikanth Jampala , Nagadheeraj Rottela Thread-Topic: [PATCH v3 05/11] crypto/nitrox: add software queue management functionality Thread-Index: AQHVWZ9tRbuSCd+GIE2zh3OU5tfXtA== Date: Fri, 23 Aug 2019 10:42:15 +0000 Message-ID: <20190823104144.19300-6-rnagadheeraj@marvell.com> References: <20190717052837.647-1-rnagadheeraj@marvell.com> <20190823104144.19300-1-rnagadheeraj@marvell.com> In-Reply-To: <20190823104144.19300-1-rnagadheeraj@marvell.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PN1PR01CA0110.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00::26) To MN2PR18MB2797.namprd18.prod.outlook.com (2603:10b6:208:a0::16) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.13.6 x-originating-ip: [115.113.156.2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0300c292-7322-46ea-b6ad-08d727b69037 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR18MB2830; x-ms-traffictypediagnostic: MN2PR18MB2830: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:79; x-forefront-prvs: 0138CD935C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(366004)(396003)(376002)(136003)(346002)(189003)(199004)(26005)(81166006)(14454004)(2616005)(476003)(5660300002)(86362001)(71190400001)(71200400001)(316002)(486006)(36756003)(25786009)(66066001)(53936002)(11346002)(446003)(305945005)(7736002)(54906003)(110136005)(256004)(14444005)(6486002)(99286004)(3846002)(6436002)(6116002)(478600001)(2906002)(186003)(30864003)(8936002)(6512007)(50226002)(81156014)(55236004)(102836004)(1076003)(107886003)(4326008)(64756008)(66946007)(66446008)(8676002)(66556008)(66476007)(2501003)(6506007)(386003)(52116002)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2830; H:MN2PR18MB2797.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: kprVm0NPa6lBwg1NSwYOp+2vc8XssPblUySPOwNtvWHX+karurHAeFxoHeDcSHiKF6+NP7IrB4X8aBcy9JucuJ7vnXNsWorqfGxPgOH8jIsd3H0v1fsJztS0YxkEKzvP++4KJ8GozGvyHJtk7DGpT0cz7oAnudzxSE89TMoGb0x86nbIlx58nMGqsEpWWkZosGqPZcuCXL4sWaWcqmKL1iU154MU7hAVk8YPoSuRToVvXBUSOFPlC75ghu1Hl4Ori8PgX1zJxti1CgcbxaaKxd76UErQWejJndpw1KrJ8QGU/SVBK2BPdD9ylkOlFHUfS87oDFzFLuu4lRQr9jNyKRAf/uV+JFbJeKxfspy6CVqB5x4EFpVGQHsiApuulCfUm0UcbXPnSvr4Mp4lPhvqdY/w9eBkkh0AMtaf1l09S/k= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 0300c292-7322-46ea-b6ad-08d727b69037 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Aug 2019 10:42:15.4965 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 2T97/ki+4/n3ETaEN1ktn/B+hqiEL2xSdfp1BWV+Pftcnt99TyVol5cZMEGG46C6Gw+8tfrLznP2P7JWY2VTAnBHvb0lUaD4V5MXt8iW6jY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB2830 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-23_04:2019-08-21,2019-08-23 signatures=0 Subject: [dpdk-dev] [PATCH v3 05/11] crypto/nitrox: add software queue management functionality X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Add software queue management code corresponding to queue pair setup and release functions. Signed-off-by: Nagadheeraj Rottela --- drivers/crypto/nitrox/Makefile | 2 + drivers/crypto/nitrox/meson.build | 2 + drivers/crypto/nitrox/nitrox_qp.c | 74 +++++++++++++++++ drivers/crypto/nitrox/nitrox_qp.h | 40 +++++++++ drivers/crypto/nitrox/nitrox_sym.c | 132 ++++++++++++++++++++++++++= ++-- drivers/crypto/nitrox/nitrox_sym_reqmgr.c | 56 +++++++++++++ drivers/crypto/nitrox/nitrox_sym_reqmgr.h | 13 +++ 7 files changed, 312 insertions(+), 7 deletions(-) create mode 100644 drivers/crypto/nitrox/nitrox_qp.c create mode 100644 drivers/crypto/nitrox/nitrox_qp.h create mode 100644 drivers/crypto/nitrox/nitrox_sym_reqmgr.c create mode 100644 drivers/crypto/nitrox/nitrox_sym_reqmgr.h diff --git a/drivers/crypto/nitrox/Makefile b/drivers/crypto/nitrox/Makefil= e index dedb74a34..f56992770 100644 --- a/drivers/crypto/nitrox/Makefile +++ b/drivers/crypto/nitrox/Makefile @@ -28,5 +28,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PMD_NITROX) +=3D nitrox_hal.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_NITROX) +=3D nitrox_logs.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_NITROX) +=3D nitrox_sym.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_NITROX) +=3D nitrox_sym_capabilities.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_NITROX) +=3D nitrox_sym_reqmgr.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_NITROX) +=3D nitrox_qp.c =20 include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/crypto/nitrox/meson.build b/drivers/crypto/nitrox/meso= n.build index 7c565c5a4..03788366b 100644 --- a/drivers/crypto/nitrox/meson.build +++ b/drivers/crypto/nitrox/meson.build @@ -14,4 +14,6 @@ sources =3D files( 'nitrox_logs.c', 'nitrox_sym.c', 'nitrox_sym_capabilities.c', + 'nitrox_sym_reqmgr.c', + 'nitrox_qp.c' ) diff --git a/drivers/crypto/nitrox/nitrox_qp.c b/drivers/crypto/nitrox/nitr= ox_qp.c new file mode 100644 index 000000000..9673bb4f3 --- /dev/null +++ b/drivers/crypto/nitrox/nitrox_qp.c @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + +#include +#include + +#include "nitrox_qp.h" +#include "nitrox_hal.h" +#include "nitrox_logs.h" + +#define MAX_CMD_QLEN 16384 + +static int +nitrox_setup_ridq(struct nitrox_qp *qp, int socket_id) +{ + size_t ridq_size =3D qp->count * sizeof(*qp->ridq); + + qp->ridq =3D rte_zmalloc_socket("nitrox ridq", ridq_size, + RTE_CACHE_LINE_SIZE, + socket_id); + if (!qp->ridq) { + NITROX_LOG(ERR, "Failed to create rid queue\n"); + return -ENOMEM; + } + + return 0; +} + +int +nitrox_qp_setup(struct nitrox_qp *qp, uint8_t *bar_addr, const char *dev_n= ame, + uint32_t nb_descriptors, uint8_t instr_size, int socket_id) +{ + int err; + uint32_t count; + + RTE_SET_USED(bar_addr); + RTE_SET_USED(instr_size); + count =3D rte_align32pow2(nb_descriptors); + if (count > MAX_CMD_QLEN) { + NITROX_LOG(ERR, "%s: Number of descriptors too big %d," + " greater than max queue length %d\n", + dev_name, count, + MAX_CMD_QLEN); + return -EINVAL; + } + + qp->count =3D count; + qp->head =3D qp->tail =3D 0; + rte_atomic16_init(&qp->pending_count); + err =3D nitrox_setup_ridq(qp, socket_id); + if (err) + goto ridq_err; + + return 0; + +ridq_err: + return err; + +} + +static void +nitrox_release_ridq(struct nitrox_qp *qp) +{ + rte_free(qp->ridq); +} + +int +nitrox_qp_release(struct nitrox_qp *qp, uint8_t *bar_addr) +{ + RTE_SET_USED(bar_addr); + nitrox_release_ridq(qp); + return 0; +} diff --git a/drivers/crypto/nitrox/nitrox_qp.h b/drivers/crypto/nitrox/nitr= ox_qp.h new file mode 100644 index 000000000..cf0102ff9 --- /dev/null +++ b/drivers/crypto/nitrox/nitrox_qp.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + +#ifndef _NITROX_QP_H_ +#define _NITROX_QP_H_ + +#include + +#include + +struct nitrox_softreq; + +struct rid { + struct nitrox_softreq *sr; +}; + +struct nitrox_qp { + struct rid *ridq; + uint32_t count; + uint32_t head; + uint32_t tail; + struct rte_mempool *sr_mp; + struct rte_cryptodev_stats stats; + uint16_t qno; + rte_atomic16_t pending_count; +}; + +static inline bool +nitrox_qp_is_empty(struct nitrox_qp *qp) +{ + return (rte_atomic16_read(&qp->pending_count) =3D=3D 0); +} + +int nitrox_qp_setup(struct nitrox_qp *qp, uint8_t *bar_addr, + const char *dev_name, uint32_t nb_descriptors, + uint8_t inst_size, int socket_id); +int nitrox_qp_release(struct nitrox_qp *qp, uint8_t *bar_addr); + +#endif /* _NITROX_QP_H_ */ diff --git a/drivers/crypto/nitrox/nitrox_sym.c b/drivers/crypto/nitrox/nit= rox_sym.c index c05042e54..05f089cae 100644 --- a/drivers/crypto/nitrox/nitrox_sym.c +++ b/drivers/crypto/nitrox/nitrox_sym.c @@ -10,9 +10,12 @@ #include "nitrox_sym.h" #include "nitrox_device.h" #include "nitrox_sym_capabilities.h" +#include "nitrox_qp.h" +#include "nitrox_sym_reqmgr.h" #include "nitrox_logs.h" =20 #define CRYPTODEV_NAME_NITROX_PMD crypto_nitrox +#define NPS_PKT_IN_INSTR_SIZE 64 =20 struct nitrox_sym_device { struct rte_cryptodev *cdev; @@ -78,12 +81,127 @@ nitrox_sym_dev_info_get(struct rte_cryptodev *cdev, info->sym.max_nb_sessions =3D 0; } =20 +static void +nitrox_sym_dev_stats_get(struct rte_cryptodev *cdev, + struct rte_cryptodev_stats *stats) +{ + int qp_id; + + for (qp_id =3D 0; qp_id < cdev->data->nb_queue_pairs; qp_id++) { + struct nitrox_qp *qp =3D cdev->data->queue_pairs[qp_id]; + + if (!qp) + continue; + + stats->enqueued_count +=3D qp->stats.enqueued_count; + stats->dequeued_count +=3D qp->stats.dequeued_count; + stats->enqueue_err_count +=3D qp->stats.enqueue_err_count; + stats->dequeue_err_count +=3D qp->stats.dequeue_err_count; + } +} + +static void +nitrox_sym_dev_stats_reset(struct rte_cryptodev *cdev) +{ + int qp_id; + + for (qp_id =3D 0; qp_id < cdev->data->nb_queue_pairs; qp_id++) { + struct nitrox_qp *qp =3D cdev->data->queue_pairs[qp_id]; + + if (!qp) + continue; + + memset(&qp->stats, 0, sizeof(qp->stats)); + } +} + static int -nitrox_sym_dev_qp_release(struct rte_cryptodev *cdev, uint16_t qp_id) +nitrox_sym_dev_qp_setup(struct rte_cryptodev *cdev, uint16_t qp_id, + const struct rte_cryptodev_qp_conf *qp_conf, + int socket_id) { - RTE_SET_USED(cdev); - RTE_SET_USED(qp_id); + struct nitrox_sym_device *sym_dev =3D cdev->data->dev_private; + struct nitrox_device *ndev =3D sym_dev->ndev; + struct nitrox_qp *qp =3D NULL; + int err; + + NITROX_LOG(DEBUG, "queue %d\n", qp_id); + if (qp_id >=3D ndev->nr_queues) { + NITROX_LOG(ERR, "queue %u invalid, max queues supported %d\n", + qp_id, ndev->nr_queues); + return -EINVAL; + } + + if (cdev->data->queue_pairs[qp_id]) { + err =3D nitrox_sym_dev_qp_release(cdev, qp_id); + if (err) + return err; + } + + qp =3D rte_zmalloc_socket("nitrox PMD qp", sizeof(*qp), + RTE_CACHE_LINE_SIZE, + socket_id); + if (!qp) { + NITROX_LOG(ERR, "Failed to allocate nitrox qp\n"); + return -ENOMEM; + } + + qp->qno =3D qp_id; + err =3D nitrox_qp_setup(qp, ndev->bar_addr, cdev->data->name, + qp_conf->nb_descriptors, NPS_PKT_IN_INSTR_SIZE, + socket_id); + if (unlikely(err)) + goto qp_setup_err; + + qp->sr_mp =3D nitrox_sym_req_pool_create(cdev, qp->count, qp_id, + socket_id); + if (unlikely(!qp->sr_mp)) + goto req_pool_err; + + cdev->data->queue_pairs[qp_id] =3D qp; + NITROX_LOG(DEBUG, "queue %d setup done\n", qp_id); return 0; + +req_pool_err: + nitrox_qp_release(qp, ndev->bar_addr); +qp_setup_err: + rte_free(qp); + return err; +} + +static int +nitrox_sym_dev_qp_release(struct rte_cryptodev *cdev, uint16_t qp_id) +{ + struct nitrox_sym_device *sym_dev =3D cdev->data->dev_private; + struct nitrox_device *ndev =3D sym_dev->ndev; + struct nitrox_qp *qp; + int err; + + NITROX_LOG(DEBUG, "queue %d\n", qp_id); + if (qp_id >=3D ndev->nr_queues) { + NITROX_LOG(ERR, "queue %u invalid, max queues supported %d\n", + qp_id, ndev->nr_queues); + return -EINVAL; + } + + qp =3D cdev->data->queue_pairs[qp_id]; + if (!qp) { + NITROX_LOG(DEBUG, "queue %u already freed\n", qp_id); + return 0; + } + + if (!nitrox_qp_is_empty(qp)) { + NITROX_LOG(ERR, "queue %d not empty\n", qp_id); + return -EAGAIN; + } + + cdev->data->queue_pairs[qp_id] =3D NULL; + err =3D nitrox_qp_release(qp, ndev->bar_addr); + nitrox_sym_req_pool_free(qp->sr_mp); + rte_free(qp); + NITROX_LOG(DEBUG, "queue %d release done\n", qp_id); + + return err; } =20 static struct rte_cryptodev_ops nitrox_cryptodev_ops =3D { @@ -93,11 +211,11 @@ static struct rte_cryptodev_ops nitrox_cryptodev_ops = =3D { .dev_close =3D nitrox_sym_dev_close, .dev_infos_get =3D nitrox_sym_dev_info_get, =20 - .stats_get =3D NULL, - .stats_reset =3D NULL, + .stats_get =3D nitrox_sym_dev_stats_get, + .stats_reset =3D nitrox_sym_dev_stats_reset, =20 - .queue_pair_setup =3D NULL, - .queue_pair_release =3D NULL, + .queue_pair_setup =3D nitrox_sym_dev_qp_setup, + .queue_pair_release =3D nitrox_sym_dev_qp_release, =20 .sym_session_get_size =3D NULL, .sym_session_configure =3D NULL, diff --git a/drivers/crypto/nitrox/nitrox_sym_reqmgr.c b/drivers/crypto/nit= rox/nitrox_sym_reqmgr.c new file mode 100644 index 000000000..42d67317c --- /dev/null +++ b/drivers/crypto/nitrox/nitrox_sym_reqmgr.c @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + +#include +#include +#include + +#include "nitrox_sym_reqmgr.h" +#include "nitrox_logs.h" + +struct nitrox_softreq { + rte_iova_t iova; +}; + +static void +softreq_init(struct nitrox_softreq *sr, rte_iova_t iova) +{ + memset(sr, 0, sizeof(*sr)); + sr->iova =3D iova; +} + +static void +req_pool_obj_init(__rte_unused struct rte_mempool *mp, + __rte_unused void *opaque, void *obj, + __rte_unused unsigned int obj_idx) +{ + softreq_init(obj, rte_mempool_virt2iova(obj)); +} + +struct rte_mempool * +nitrox_sym_req_pool_create(struct rte_cryptodev *cdev, uint32_t nobjs, + uint16_t qp_id, int socket_id) +{ + char softreq_pool_name[RTE_RING_NAMESIZE]; + struct rte_mempool *mp; + + snprintf(softreq_pool_name, RTE_RING_NAMESIZE, "%s_sr_%d", + cdev->data->name, qp_id); + mp =3D rte_mempool_create(softreq_pool_name, + RTE_ALIGN_MUL_CEIL(nobjs, 64), + sizeof(struct nitrox_softreq), + 64, 0, NULL, NULL, req_pool_obj_init, NULL, + socket_id, 0); + if (unlikely(!mp)) + NITROX_LOG(ERR, "Failed to create req pool, qid %d, err %d\n", + qp_id, rte_errno); + + return mp; +} + +void +nitrox_sym_req_pool_free(struct rte_mempool *mp) +{ + rte_mempool_free(mp); +} diff --git a/drivers/crypto/nitrox/nitrox_sym_reqmgr.h b/drivers/crypto/nit= rox/nitrox_sym_reqmgr.h new file mode 100644 index 000000000..5953c958c --- /dev/null +++ b/drivers/crypto/nitrox/nitrox_sym_reqmgr.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + +#ifndef _NITROX_SYM_REQMGR_H_ +#define _NITROX_SYM_REQMGR_H_ + +struct rte_mempool *nitrox_sym_req_pool_create(struct rte_cryptodev *cdev, + uint32_t nobjs, uint16_t qp_id, + int socket_id); +void nitrox_sym_req_pool_free(struct rte_mempool *mp); + +#endif /* _NITROX_SYM_REQMGR_H_ */ --=20 2.13.6