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 41FBEA0471 for ; Wed, 17 Jul 2019 07:30:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9706E1B9F6; Wed, 17 Jul 2019 07:29:19 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 17CF61B94F for ; Wed, 17 Jul 2019 07:29:10 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x6H5PZaj023793 for ; Tue, 16 Jul 2019 22:29:10 -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=qWwnSmGY0SLSq2hBmaFT2/iOnubdBRLZ8dNDtsxCncoCNBWiBnJbr2q28VwIBWeLJOTE rA/ZLA5R/46uh78PXXbAKsUK3URl+zRh3xtK/BOI1pyxu7Aw2RKqrNbMTyQmMmn+R6Tl dridfPVLBfwgZAkV+JXZQ/cYTuShw8ZVTamlc2sbCUC8S98Og7j7BfsiUvthxhUD6TWX 1JbE0bP0Gny1GWCi4eMw0ot4gBIF4iVTlLa9YBwAFVbv59zKxoSzjd3pjagEaOswojqy XHYu5SAUcKBlLcmEb0ySEhh1hDBfR5KZ36QFVDhqWw5dwZbwbUygaovesOxTmJ8Ffdgt 6Q== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2ts07vet1t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 16 Jul 2019 22:29:10 -0700 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 16 Jul 2019 22:29:09 -0700 Received: from NAM01-BY2-obe.outbound.protection.outlook.com (104.47.34.53) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Tue, 16 Jul 2019 22:29:08 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dHe7HQ3rU8K8w8me4rErfPhLIF+tu3djQP5qFODoAhj19Sdn+ikkt+gRtKaNbH6WY/d9i3RRui9WKmbKju7bZIF4C/vzf26Hz/aDZ3n7NcRkdlOE7Xxoi+YmxeHWZsHJc2+GOaPl1PRIqJWcFhMRT1D1Suo6N5pQ5b21NXQMT3+Gl6eQpxL+ggXXp7wAgyz09e9IiJOV/zikh1KwoFMkuinkgT0Qcgn6Xd67ZUO1SBIEeIjuof+3vdRtmV+GDXrcQ6gd9liFJBh6j+VdE00q6rtR3zSzotxdGo/5pxMOkgTUrIC1StAbLj5OOgUShq10xWsbLLDbpE5GtARfxhwd2g== 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=nsEjxnbpqK7mQLQjUTnXsfR0T6yFwqn8ab0QWUm9S4hgRNfwn9Pf88lR4ES8s24Y2zosE8lAAlzOkOGx1fnQs5c8oN01i7/msTMrtR0XOhXEsPRGgOqzfflx6KnCUFNqSTz0nXauaeO75InJvKDVd5lAQMD/TgSgtzMgaFuiJiHVG3Aw8HN9jPQ97K9axmdLhlhE5qJJgHiYGzaMd14NXEIsR10HcGNmL1yg9CWIGZpSfMnu12cwAwWruYd7O/uyXXoqyACW+o8IJoVv+QJq1GOkxTfRfJsVZu/xcRixIU2C+xfTDxznlqalt/RkOZnh2t+8HuCmg3Qod0zWClB6PQ== 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=V3rp/ZuCConBpWnu/JJRa2Efk2bq/hWG5hEjgVZdQ7M/rRyTVrxmgydRDOo+uMOUwNAx+jGUT14YiL+2EWv+Xh+1apIkr7liGSQeVstIIYxqMOWguzRjR9N9ibMmaY/YdLcvSkAfZ01MkSkIxnR+vU5msA+PvmSIb7oShuXlOdc= Received: from MN2PR18MB2797.namprd18.prod.outlook.com (20.179.22.16) by MN2PR18MB2767.namprd18.prod.outlook.com (20.179.20.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2073.11; Wed, 17 Jul 2019 05:29:07 +0000 Received: from MN2PR18MB2797.namprd18.prod.outlook.com ([fe80::5d53:ac2e:80ec:cd8f]) by MN2PR18MB2797.namprd18.prod.outlook.com ([fe80::5d53:ac2e:80ec:cd8f%6]) with mapi id 15.20.2073.012; Wed, 17 Jul 2019 05:29:07 +0000 From: Nagadheeraj Rottela To: "dev@dpdk.org" CC: Srikanth Jampala , Nagadheeraj Rottela Thread-Topic: [PATCH 05/10] crypto/nitrox: add software queue management functionality Thread-Index: AQHVPGCO5uiBXn/qY0Sgks8gwA97+A== Date: Wed, 17 Jul 2019 05:29:07 +0000 Message-ID: <20190717052837.647-6-rnagadheeraj@marvell.com> References: <20190717052837.647-1-rnagadheeraj@marvell.com> In-Reply-To: <20190717052837.647-1-rnagadheeraj@marvell.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BMXPR01CA0001.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:d::11) 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: 8ba38d47-e0d9-4b86-cd83-08d70a77b094 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR18MB2767; x-ms-traffictypediagnostic: MN2PR18MB2767: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:79; x-forefront-prvs: 01018CB5B3 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(346002)(366004)(396003)(39860400002)(136003)(199004)(189003)(55236004)(6512007)(66066001)(66946007)(66476007)(66446008)(86362001)(64756008)(66556008)(107886003)(14444005)(71190400001)(99286004)(256004)(71200400001)(7736002)(305945005)(54906003)(5660300002)(1730700003)(486006)(53936002)(26005)(81166006)(316002)(50226002)(6486002)(81156014)(8676002)(1076003)(6506007)(4326008)(25786009)(386003)(30864003)(6116002)(11346002)(2616005)(3846002)(2351001)(6916009)(478600001)(14454004)(476003)(446003)(8936002)(68736007)(76176011)(102836004)(36756003)(186003)(52116002)(5640700003)(2906002)(6436002)(2501003); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2767; 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-message-info: qsyf0LYgyUpNhS4VO8nj3QURyzohvsyzFB7hBfWfKH23O195PlTR5EQQkqgyGhvGuRpXbHZuTblfAPsS6RLRbA74xO8ThEgWw8JymcIBUbnKmRkhPYfk6hif9HTo9Y32nF4fw2UdfJcoxsChrx1X8uxO+iIKxWmVBp4gGbaja4PK658IDVYNaqZMM3O0Rwhr1Uh3BprjdRufmiyBA2oIQSkuXrpNw/G0Vd8Cn1HhPi0jspGTxA/YwQlETDh5GemCbJ8CxoF+XHU8Lsc99W2TiBQtxEJ1Ed8IMDFtiikGCQph3obCKZAc464NQTKHJotPYRUhwTLomWpESquyFhyX/6+XkkGX09R80L6jk2uiBCe4p96qAMBBdVGi1OYQgXRFYM3AcNZHy8T/nDvO7ZvOa5Wxiv+4/DuqWGRqdDJhZYs= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 8ba38d47-e0d9-4b86-cd83-08d70a77b094 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jul 2019 05:29:07.8091 (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: rnagadheeraj@marvell.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB2767 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-07-17_02:2019-07-16,2019-07-17 signatures=0 Subject: [dpdk-dev] [PATCH 05/10] 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