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 C581CA0613 for ; Thu, 26 Sep 2019 14:37:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CD9C41B99D; Thu, 26 Sep 2019 14:37:00 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id CEAA11B079 for ; Thu, 26 Sep 2019 14:36:56 +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 x8QCX4rC029128; Thu, 26 Sep 2019 05:36:56 -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=C75mahVrbDNHpyjU0UphGzVFbHMFkgc6bQ+ZL65nrr8njSWw3fAaoQfITtS4gUCrqlCY 6j39uCD+1tW3OVmOdUu7Qh6tLLSuE0T4kLFBXAZFTkEZkNYyTbXapm3935LLZNh+uxLB jh/ATDzOWthvMekDfzoRjPZ8+mVZhqGmJvOWngxACIzxozb9i3xc/d1d+BG9NHcBgnjZ 3ung6BA7XjSL/TMaqySjeDDY5ptVZnpFOz7Qm7m69ffqQ1PNulCGJ7fwv/bJ/SXAdUhx 9eUhdF2pbMd7y5bmqHJjrs5T/HgdJEll2ntEp0lAePpDrHWQa4gVjiXyMuc3kjlNcWoB Dw== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 2v8vf2078a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 05:36:56 -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; Thu, 26 Sep 2019 05:36:52 -0700 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (104.47.45.57) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 05:36:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C8bPBwI6MJ1B9jzLcqP1e0/fQrDBPBNWkjJu/DeqXBmXq9HbR2loJJMB4O6Jnbrayg4GMn+UOgYPPiWaDyoI1YFdON/Oqzpljyu3Ox3aijBVFn3M4eQh2OEL8at7v3urNC/VcgN9DyL0kYh/7a4tw4F4xNNOu5SwGWY2+J+iXfGyC+yKKsbV3ee+tseDr6lHbxLVMs6HnwYM2ylS6ETduSkXMX0oBqPLl0rFF/2vzUqKdEtsM2C8AI2OOLXGbne8IGMY8yLxX/qjxGQHMooEqCGgFA9MzicBESibt8qtPnjrSRcuL+hEoFVd6SYdzJ7bH9h+FQaP6LrS2V0d4rD8VQ== 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=bQ7MzvS8IY+S48DEGH+ixZQiCgCZkKECxzcT2vYrTba9ldOSeDHQ9rU4GkK3aMP667DLbhCDMiQ3tmWUTUooeaErVjnsuPsr7yKFAMKKyRNE/NbxwbwgEYG/xlETRSR8S5+iH2PZLMUIjsWNgmHlgOVzI5OzaVQgFbpE9n1lgW7WZ5RA0xCRVXHHMCUinCzOxTFDf4Cz7emLJi6IDYn5qUcAkvySmak6FNaQeC5dfv0OrtRN9FvMXaoatb+YQLlHybGCm08hoeM2I1tb8WWLC9uOk++Xq6XXUEOD5lYSofVvxEBQID2bTf2Q2d+E+PqnQdP+tOPjwuRRExRyPYvHrg== 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=TkhmDU7bKgh/9N1VeV/niEhhlL9qqFD0ELgNWiV5NDSKswVdVj4xhh7RAxK++5ZWs3pd6VMfzVZPtkdNxE7OKlyl9HXaf8jak6ZwH/OBkSjWBFRiyS6DxexPVocg0uoqd2CJzqTdxCFRGjgeyJcgDB/mIJ2N69R/WoZjrOhbzbI= Received: from MN2PR18MB2797.namprd18.prod.outlook.com (20.179.22.16) by MN2PR18MB2766.namprd18.prod.outlook.com (20.178.255.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.17; Thu, 26 Sep 2019 12:36:51 +0000 Received: from MN2PR18MB2797.namprd18.prod.outlook.com ([fe80::2010:7134:bdcf:8ad9]) by MN2PR18MB2797.namprd18.prod.outlook.com ([fe80::2010:7134:bdcf:8ad9%7]) with mapi id 15.20.2284.028; Thu, 26 Sep 2019 12:36:51 +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 v5 3/8] crypto/nitrox: add software queue management functionality Thread-Index: AQHVdGcSgJPd7qiM3ESETMiPNlC7TQ== Date: Thu, 26 Sep 2019 12:36:51 +0000 Message-ID: <20190926123609.28417-4-rnagadheeraj@marvell.com> References: <20190716091016.4788-1-rnagadheeraj@marvell.com> <20190926123609.28417-1-rnagadheeraj@marvell.com> In-Reply-To: <20190926123609.28417-1-rnagadheeraj@marvell.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR01CA0127.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:40::21) 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: 924d2ff4-e3de-45d4-05e7-08d7427e3498 x-ms-traffictypediagnostic: MN2PR18MB2766: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:61; x-forefront-prvs: 0172F0EF77 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(346002)(39860400002)(136003)(396003)(366004)(199004)(189003)(4326008)(66946007)(2501003)(66476007)(64756008)(66556008)(14444005)(256004)(3846002)(6116002)(66446008)(81156014)(8936002)(81166006)(8676002)(66066001)(7736002)(50226002)(305945005)(386003)(102836004)(52116002)(6506007)(55236004)(76176011)(26005)(11346002)(446003)(99286004)(186003)(14454004)(1076003)(478600001)(30864003)(36756003)(86362001)(54906003)(110136005)(2906002)(71200400001)(71190400001)(316002)(6486002)(5660300002)(476003)(6512007)(6436002)(486006)(107886003)(2616005)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2766; 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: UzpPU1QrFvnDD6szuvcJ81XAaCKoWrkBxNnI/JzZFnKw5d9O8Qytt5Mvtd8JNXnCYa+zRLCSIItjm0GKIzsnTHXQOEY7sE0k86xRa7G7OfwI2Bm83BB2twEG0R90SF5NpiPhefeZPmrsZ9pjGKVKUvFDa7YnDLOekh+FzdWO5gKrLt4UDhSflxJFwOR38NJHJxmymzA/4BkdFR/R9m29pla8HrfN3UOSWfgX6tubu43hU0mfB9x7QCWLFvbNTPZ/y1MhANq/ccKfCwODjyCxD7z5tO/IrQOuSe8BDhwvvKL1Svc7FKHrF+DM/VjpiPqU+kOwRE+NYchoEZegehnmxbynfW7Zotycx6mhWDhS+cStSAZurDVE2R5+ypaDMcJJtyrDYJ9SpMcLqZNKFQ11lAAnBO9zOxKDdCnm3VaKhpA= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 924d2ff4-e3de-45d4-05e7-08d7427e3498 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Sep 2019 12:36:51.4193 (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: MgL8MXhWlCRATXPEgPdQgz0d9itvcLrW4OkleluSrHkw7KbR5Gvz0ai8bTj0Hhb5R/lNHB0I7hjIFzTSQxiC6atAYNICJsyIT3cpE6KyEX4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB2766 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_06:2019-09-25,2019-09-26 signatures=0 Subject: [dpdk-dev] [PATCH v5 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