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 7136FA2EDB for ; Tue, 1 Oct 2019 08:41:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F35071BDFD; Tue, 1 Oct 2019 08:41:30 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id C21391B9B5 for ; Tue, 1 Oct 2019 08:41:29 +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 x916fITs024669; Mon, 30 Sep 2019 23:41:29 -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=qWZaXb377d12GHJUYkTExINLk+YYlwb4Xx+ZxpsvOjc=; b=nFzcUNFPVzINdOuzNgP7ES5qFIhAvuObbGKLzHxXbj2wx7dPTDgKeo+zo0kM8RnWosMk 1aADYdKcqejdAqLlg/mgTXNmHcvkufhXtaoMW+M+RO6ExXvf/zhY/HgKRAUxDDWLsf6n 1U2oo1Ngz7iFAo4OfD65PDmemybe18RB1Wm6SXU1FjaUzFDqdFVu81//wBSr5dbj4K8y 37H8GFjo/FGZPyd4eegjbwuUcsDLkdnerrcPQWinwoGreXMnDPfjC1C7lX+TEoorJbUh G9h/LBdl7MthKclCWcZZsrx0zW6i+X5gjXXZZWhx0RiwnchU5QAqV1IzjYE9HyOuBYT0 mw== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2va71mh7v8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 30 Sep 2019 23:41:28 -0700 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 23:41:26 -0700 Received: from NAM04-SN1-obe.outbound.protection.outlook.com (104.47.44.51) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 23:41:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KQ2oo6H8buaoKG97DzFshrLm7+Oiu7wceSFAoLlbwgt6kVFhJE/yAe3yM0IRgjZUhdJP7cLCM6SS4gcnJlKfDL8Aiwv+ycriPHGPxczOflorWKEwF3M5Gj0okWLh4zodLIHexYgLvpH61Dudxkv7L4IOVKZjewejvitsNDDm7xoijUcDRsMDYCwqDgmNaALaHaQmF4GpiGNqXUgzYxAsrn6iY1lLn1c1W+jEr+DAmd9bAr8M7AsO4iMqiTTiVLUIkaTe0lNrRSr9PZzEqelzRzA1tZk3H+YOY5VhmLpYRV0UcrUgOi3Bu6HE+UdstLuUlt4txasjIXc6HiLXt32MBw== 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=qWZaXb377d12GHJUYkTExINLk+YYlwb4Xx+ZxpsvOjc=; b=Am7kJyn86EXfAoMGkTTopHIU+TQaT3Ta/YUROZlvL8ExitmeGDUOfXrfQVatJ3al+vrZ28UMkYgR0aFkj7aIxEVjVODXXMgM31XIi+WpknLwT63BWFtiZ0X8SGGKtYyoUkmDg/jLcX6Nfgax7OWT86/kADS2R2I2qM5iUsw430+Lr6kNOKIkFU7Qj2uPMizc2HTJNpV7lr/zLEq8udIeK5ysoy4+v/7ANbW7nQOgwLQ2pDZtaEdz7wcRv2UEED/u1Lx8Nivprj5nWAooCnePwckgjcOnPuhdH6KJ3BrFWGAz0dGkZGzGD3Aj/GpF1WFCBdW/vmPpjkwlQmSwS4jlVA== 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=qWZaXb377d12GHJUYkTExINLk+YYlwb4Xx+ZxpsvOjc=; b=sXs6qAiCbzCtwsOw3jtV5ByNpza6OEAgX2SsbsdK4Xp8V2lPb1ylxyNejNUg8Q1Dmipj1jGirb/NRzOHLXzFch+0gQ/RCi1LGo5xce2FlfZ1CD8R/WF/TWj7BIXqNjCbk6cr/w4k8iYgUXi8fRx1XgbzvFo4of9CRhfl9P0YOP8= Received: from MN2PR18MB2797.namprd18.prod.outlook.com (20.179.22.16) by MN2PR18MB3375.namprd18.prod.outlook.com (10.255.238.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.15; Tue, 1 Oct 2019 06:41:25 +0000 Received: from MN2PR18MB2797.namprd18.prod.outlook.com ([fe80::259c:a73e:a83:ccfe]) by MN2PR18MB2797.namprd18.prod.outlook.com ([fe80::259c:a73e:a83:ccfe%4]) with mapi id 15.20.2305.017; Tue, 1 Oct 2019 06:41:25 +0000 From: Nagadheeraj Rottela To: "akhil.goyal@nxp.com" , "pablo.de.lara.guarch@intel.com" CC: Srikanth Jampala , "dev@dpdk.org" , Nagadheeraj Rottela Thread-Topic: [PATCH v7 3/8] crypto/nitrox: add software queue management functionality Thread-Index: AQHVeCM+EFnl+M7kAUii35NiNmZqNw== Date: Tue, 1 Oct 2019 06:41:25 +0000 Message-ID: <20191001064048.5624-4-rnagadheeraj@marvell.com> References: <20190716091016.4788-1-rnagadheeraj@marvell.com> <20191001064048.5624-1-rnagadheeraj@marvell.com> In-Reply-To: <20191001064048.5624-1-rnagadheeraj@marvell.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PN1PR0101CA0050.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::12) 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: b2113c72-6653-4006-82d4-08d7463a6147 x-ms-traffictypediagnostic: MN2PR18MB3375: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:61; x-forefront-prvs: 0177904E6B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(396003)(39850400004)(346002)(136003)(376002)(199004)(189003)(66946007)(76176011)(6512007)(66556008)(476003)(81166006)(66476007)(478600001)(446003)(14444005)(52116002)(256004)(99286004)(486006)(81156014)(8936002)(305945005)(2616005)(64756008)(5660300002)(4326008)(66066001)(316002)(11346002)(6436002)(25786009)(2906002)(386003)(71200400001)(71190400001)(14454004)(107886003)(6486002)(55236004)(102836004)(110136005)(54906003)(8676002)(2501003)(186003)(66446008)(6116002)(3846002)(50226002)(86362001)(30864003)(26005)(36756003)(1076003)(7736002)(6506007); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB3375; H:MN2PR18MB2797.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: EQrTEpB55HusIku1gnghIVHWh7rctSS7DIPJIx6364bUQCUEV+msdNbuSf0Vw7N3dDC8UQjixSBS/K6/JuIb3deGhlvrcItuOXK3tnAh5Xs7PJj4xkMEeEye87hudf2iXRNPTkewZGr9egk9z86h3X3VAj/gKDV7HIbKSUxgfK/nZX39FtrTT6avLdoPyw31SmHQ1d0yiKBaEgWiYWRPhDoexSDUBdf7mOIJpRFdHulJrbt+yiQ4pZW9D9C2h0rem2moDk+lSupXQZiJMLP9xOQnFjm1wHCaHx6xLALy5kUGh4iC7FrSWx4sOmrMA4nG2W4P9nFnzPU3WffT6hJTYebkjyjnhqRx+ipB9pGHDTjpZJd+qm94Oq0H24dqYZOnWK6qlcOINhmM11tD6P0TxeFniCzlKmJfpXszKtwlIRg= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: b2113c72-6653-4006-82d4-08d7463a6147 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Oct 2019 06:41:25.2077 (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: XmYQv093WmWMRtIyTfGvTKKF9MvdF8g6bJ3yP6SGR/595NjfbuEqddWlg7YWEc8qCfj+fzd9uRwvctCRxLr3WCrCLTRa8txGHfSyvig6ZgM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB3375 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-01_03:2019-09-30,2019-10-01 signatures=0 Subject: [dpdk-dev] [PATCH v7 3/8] 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 | 131 ++++++++++++++++++++++++++= ++-- drivers/crypto/nitrox/nitrox_sym_reqmgr.c | 56 +++++++++++++ drivers/crypto/nitrox/nitrox_sym_reqmgr.h | 13 +++ 7 files changed, 311 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 06c96ccd7..72530ee1d 100644 --- a/drivers/crypto/nitrox/Makefile +++ b/drivers/crypto/nitrox/Makefile @@ -27,5 +27,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PMD_NITROX) +=3D nitrox_device.c 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_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 1277cf58e..06e006e24 100644 --- a/drivers/crypto/nitrox/meson.build +++ b/drivers/crypto/nitrox/meson.build @@ -13,4 +13,6 @@ sources =3D files( 'nitrox_hal.c', 'nitrox_logs.c', 'nitrox_sym.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 12817c6c7..0ac490829 100644 --- a/drivers/crypto/nitrox/nitrox_sym.c +++ b/drivers/crypto/nitrox/nitrox_sym.c @@ -9,9 +9,12 @@ =20 #include "nitrox_sym.h" #include "nitrox_device.h" +#include "nitrox_qp.h" +#include "nitrox_sym_reqmgr.h" #include "nitrox_logs.h" =20 #define CRYPTODEV_NAME_NITROX_PMD crypto_nitrox_sym +#define NPS_PKT_IN_INSTR_SIZE 64 =20 struct nitrox_sym_device { struct rte_cryptodev *cdev; @@ -89,12 +92,126 @@ 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 { @@ -103,10 +220,10 @@ static struct rte_cryptodev_ops nitrox_cryptodev_ops = =3D { .dev_stop =3D nitrox_sym_dev_stop, .dev_close =3D nitrox_sym_dev_close, .dev_infos_get =3D nitrox_sym_dev_info_get, - .stats_get =3D NULL, - .stats_reset =3D NULL, - .queue_pair_setup =3D NULL, - .queue_pair_release =3D NULL, + .stats_get =3D nitrox_sym_dev_stats_get, + .stats_reset =3D nitrox_sym_dev_stats_reset, + .queue_pair_setup =3D nitrox_sym_dev_qp_setup, + .queue_pair_release =3D nitrox_sym_dev_qp_release, .sym_session_get_size =3D NULL, .sym_session_configure =3D NULL, .sym_session_clear =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