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 A346FA0613 for ; Thu, 26 Sep 2019 14:37:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 986511B203; Thu, 26 Sep 2019 14:36:57 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 8E6384C8E for ; Thu, 26 Sep 2019 14:36:54 +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 x8QCX3fX029082; Thu, 26 Sep 2019 05:36:52 -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=bDdQifW42IT8Gt+W2paWYnVHTJHK+RnAnY+jiOyYfOU=; b=cdnX/LcpIg5MNP956sZPBLKlkj8USKj46YAIQOWvYRyvwk+w2Q1P74t+mq/coo8jRn5m sCMjyD+xNkx4aq8XZ4aL8MqxY2xGJf5TBj8aGdEVVN4qca/WqdBUCZHwMAyqFNadCtm/ pBy9pCrBkygezywHGWx2UZa3wxkvblae3zqQpusydJ59svu6YRPw73ulW5h10xVMP8c9 M/cSTsa9mB1ohILVm2Q/vVFnT+s16QTY6WiAGCUi24TTg8+9dBea69/3Ukp1/IdQL+XX FP4bU/NOjG0bcyDRks8SxDhlYIZPCnUflScwhiZl7gcNl13AdsO66vRhCec7CFzh71mk Sw== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2v8vf20786-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 05:36:52 -0700 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 05:36:50 -0700 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (104.47.45.56) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 05:36:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aSwBLKv4HP2XRBcC99I1rEmPIM1lQF/nKY2f8wLNaBvMidaoluYU457Uf5DNN46LP96nZbm0uaF8G0DCOSCrGcxd/qNlYJ8iPzn8ZAprKWJvuxlgy9IqG8zs/jfe0DfhisLwljQv9p5AlJNhTth0OD5G4gdX65/4YdLvNP5c8bUVFGLIAkzJvFDKlv7FZuajFZ6L0BJQklZrVklYldLipPlt4xDrmHgudy/Z5OpMEIYt6VMa18NykzAlU/ePm0bMbtgMu9EEscFpbuY5/3YAb+QvNd+GkjZndSKawHfAtU8qqqGlcGTQKepTiSh4Y8rHDDm9lrpNjifWypSX5FC40g== 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=bDdQifW42IT8Gt+W2paWYnVHTJHK+RnAnY+jiOyYfOU=; b=XN5xCfLdZ3OU7ilQ8L22U0stzCbJXq9V+Ww1Fs7zKxeXfzBGQQ8ikIZs1jqxM5Hs6x89UVoH9S1rMeeHKCzAr/Z4mTBhZBVmUBgkASvcEGLj4RTU5GuiAjGxdofNSzUBm0QE8oBYuM0vRH/LL1QQuVSOVbk8qxZqhTFpcUqzY8qy6C1F5Ax9/guQlqScXMi0+hLM1F4vw6gLjwL/mPtpO+hp0Mw2S5DxX1x0XEaow+szmq66wSZTjTCsq8agUV17o6OZ9LBRr5vR/lELjVU38XDzSRVJ0YIrJ1DA57ZzadoBPK8mF6RU3+5obB1k/oeJk+cazl13kal2OTknWm6nOA== 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=bDdQifW42IT8Gt+W2paWYnVHTJHK+RnAnY+jiOyYfOU=; b=k1+d4JVcyDccT3KHwMYsVZS3tL3d15LLru6Tu+tbLuQPc9ZaLyM1I654DMjVMr1rRG60ts4ewNai8cTw6CjKlrpboBuNyjZxcS/htryd4zQpjg4v2Xutt1yhoSd/c2fGV5VsSFfYXzTPVEgIWGVawXhpCEQet/gdubCAc2DEHuI= 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:49 +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:49 +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 2/8] crypto/nitrox: create Nitrox symmetric cryptodev Thread-Index: AQHVdGcRP6LWsRA86k61muC8YbHL4A== Date: Thu, 26 Sep 2019 12:36:49 +0000 Message-ID: <20190926123609.28417-3-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: 6eb58e06-ec3e-4827-acf7-08d7427e3363 x-ms-traffictypediagnostic: MN2PR18MB2766: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:13; 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)(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: tFnSl6Vhk8e0PMqDcRU4BS2ZQ4r0HWtKTIqqD+KsE51DnMpNK4KvGCzzpyQCcia7XTJTa/KSbjCFcbCqk/daZYQ3R88g4B9iqKQokoYPdPXkxd2MAu2z0CeB/rP7E2VTJog4vwG+gzUuy3KvdCKOazO4sjxodJRbnWzUqEqfg7uMHvoUBlroH/OFKFi1FGPNe6Xh5Sf5jztQfL9YUgps8agvXsxO/DdXzsM0ORus151JbXYmBRMdG5bewbf+TciCRy9GGPhjUAveLDbq/poV9r9URAppEQyXcQMYcYiCcTZiGWV9MjqsJ6QXEWjdAhCmABKJfWpy5bUe47jOqC3Wn/kTVNppeXK2b84h2Wp9eL3YEvZKlbH44ahbN9F+ZnKla+XR4ZGe4+ldGvBcVsajlOoeW4nolAuHZc3l0oEoKlc= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 6eb58e06-ec3e-4827-acf7-08d7427e3363 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Sep 2019 12:36:49.3856 (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: r8FdTrN0lZdyqvsvvMY0iNVLAOelrot1vbcoDlSBKpNl7M/5NpVYv3149vVUGQp1dg+Vmay0XoCVlY3nNxRwZfICiuyXAbVn0J+YfwfDRe0= 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 2/8] crypto/nitrox: create Nitrox symmetric cryptodev 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 Nitrox symmetric cryptodev with following operations, - dev_configure - dev_start - dev_stop - dev_close - dev_infos_get Signed-off-by: Nagadheeraj Rottela --- drivers/crypto/nitrox/Makefile | 1 + drivers/crypto/nitrox/meson.build | 1 + drivers/crypto/nitrox/nitrox_device.c | 13 +++ drivers/crypto/nitrox/nitrox_device.h | 4 + drivers/crypto/nitrox/nitrox_sym.c | 163 ++++++++++++++++++++++++++++++= ++++ drivers/crypto/nitrox/nitrox_sym.h | 13 +++ 6 files changed, 195 insertions(+) create mode 100644 drivers/crypto/nitrox/nitrox_sym.c create mode 100644 drivers/crypto/nitrox/nitrox_sym.h diff --git a/drivers/crypto/nitrox/Makefile b/drivers/crypto/nitrox/Makefil= e index 7681a6603..06c96ccd7 100644 --- a/drivers/crypto/nitrox/Makefile +++ b/drivers/crypto/nitrox/Makefile @@ -26,5 +26,6 @@ LDLIBS +=3D -lrte_cryptodev 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 =20 include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/crypto/nitrox/meson.build b/drivers/crypto/nitrox/meso= n.build index ad81f8cd8..1277cf58e 100644 --- a/drivers/crypto/nitrox/meson.build +++ b/drivers/crypto/nitrox/meson.build @@ -12,4 +12,5 @@ sources =3D files( 'nitrox_device.c', 'nitrox_hal.c', 'nitrox_logs.c', + 'nitrox_sym.c', ) diff --git a/drivers/crypto/nitrox/nitrox_device.c b/drivers/crypto/nitrox/= nitrox_device.c index a73528211..5b319dd68 100644 --- a/drivers/crypto/nitrox/nitrox_device.c +++ b/drivers/crypto/nitrox/nitrox_device.c @@ -6,6 +6,7 @@ =20 #include "nitrox_device.h" #include "nitrox_hal.h" +#include "nitrox_sym.h" =20 #define PCI_VENDOR_ID_CAVIUM 0x177d #define NITROX_V_PCI_VF_DEV_ID 0x13 @@ -66,6 +67,7 @@ nitrox_pci_probe(struct rte_pci_driver *pci_drv __rte_unu= sed, struct rte_pci_device *pdev) { struct nitrox_device *ndev; + int err; =20 /* Nitrox CSR space */ if (!pdev->mem_resource[0].addr) @@ -76,6 +78,12 @@ nitrox_pci_probe(struct rte_pci_driver *pci_drv __rte_un= used, return -ENOMEM; =20 ndev_init(ndev, pdev); + err =3D nitrox_sym_pmd_create(ndev); + if (err) { + ndev_release(ndev); + return err; + } + return 0; } =20 @@ -83,11 +91,16 @@ static int nitrox_pci_remove(struct rte_pci_device *pdev) { struct nitrox_device *ndev; + int err; =20 ndev =3D find_ndev(pdev); if (!ndev) return -ENODEV; =20 + err =3D nitrox_sym_pmd_destroy(ndev); + if (err) + return err; + ndev_release(ndev); return 0; } diff --git a/drivers/crypto/nitrox/nitrox_device.h b/drivers/crypto/nitrox/= nitrox_device.h index 0d0167de2..6b8095f42 100644 --- a/drivers/crypto/nitrox/nitrox_device.h +++ b/drivers/crypto/nitrox/nitrox_device.h @@ -8,10 +8,14 @@ #include #include =20 +struct nitrox_sym_device; + struct nitrox_device { TAILQ_ENTRY(nitrox_device) next; struct rte_pci_device *pdev; uint8_t *bar_addr; + struct nitrox_sym_device *sym_dev; + struct rte_device rte_sym_dev; uint16_t nr_queues; }; =20 diff --git a/drivers/crypto/nitrox/nitrox_sym.c b/drivers/crypto/nitrox/nit= rox_sym.c new file mode 100644 index 000000000..12817c6c7 --- /dev/null +++ b/drivers/crypto/nitrox/nitrox_sym.c @@ -0,0 +1,163 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + +#include + +#include +#include + +#include "nitrox_sym.h" +#include "nitrox_device.h" +#include "nitrox_logs.h" + +#define CRYPTODEV_NAME_NITROX_PMD crypto_nitrox_sym + +struct nitrox_sym_device { + struct rte_cryptodev *cdev; + struct nitrox_device *ndev; +}; + +uint8_t nitrox_sym_drv_id; +static const char nitrox_sym_drv_name[] =3D RTE_STR(CRYPTODEV_NAME_NITROX_= PMD); +static const struct rte_driver nitrox_rte_sym_drv =3D { + .name =3D nitrox_sym_drv_name, + .alias =3D nitrox_sym_drv_name +}; + +static int nitrox_sym_dev_qp_release(struct rte_cryptodev *cdev, + uint16_t qp_id); + +static int +nitrox_sym_dev_config(struct rte_cryptodev *cdev, + struct rte_cryptodev_config *config) +{ + struct nitrox_sym_device *sym_dev =3D cdev->data->dev_private; + struct nitrox_device *ndev =3D sym_dev->ndev; + + if (config->nb_queue_pairs > ndev->nr_queues) { + NITROX_LOG(ERR, "Invalid queue pairs, max supported %d\n", + ndev->nr_queues); + return -EINVAL; + } + + return 0; +} + +static int +nitrox_sym_dev_start(struct rte_cryptodev *cdev) +{ + /* SE cores initialization is done in PF */ + RTE_SET_USED(cdev); + return 0; +} + +static void +nitrox_sym_dev_stop(struct rte_cryptodev *cdev) +{ + /* SE cores cleanup is done in PF */ + RTE_SET_USED(cdev); +} + +static int +nitrox_sym_dev_close(struct rte_cryptodev *cdev) +{ + int i, ret; + + for (i =3D 0; i < cdev->data->nb_queue_pairs; i++) { + ret =3D nitrox_sym_dev_qp_release(cdev, i); + if (ret) + return ret; + } + + return 0; +} + +static void +nitrox_sym_dev_info_get(struct rte_cryptodev *cdev, + struct rte_cryptodev_info *info) +{ + struct nitrox_sym_device *sym_dev =3D cdev->data->dev_private; + struct nitrox_device *ndev =3D sym_dev->ndev; + + if (!info) + return; + + info->max_nb_queue_pairs =3D ndev->nr_queues; + info->feature_flags =3D cdev->feature_flags; + info->driver_id =3D nitrox_sym_drv_id; + info->sym.max_nb_sessions =3D 0; +} + +static int +nitrox_sym_dev_qp_release(struct rte_cryptodev *cdev, uint16_t qp_id) +{ + RTE_SET_USED(cdev); + RTE_SET_USED(qp_id); + return 0; +} + +static struct rte_cryptodev_ops nitrox_cryptodev_ops =3D { + .dev_configure =3D nitrox_sym_dev_config, + .dev_start =3D nitrox_sym_dev_start, + .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, + .sym_session_get_size =3D NULL, + .sym_session_configure =3D NULL, + .sym_session_clear =3D NULL +}; + +int +nitrox_sym_pmd_create(struct nitrox_device *ndev) +{ + char name[RTE_CRYPTODEV_NAME_MAX_LEN]; + struct rte_cryptodev_pmd_init_params init_params =3D { + .name =3D "", + .socket_id =3D ndev->pdev->device.numa_node, + .private_data_size =3D sizeof(struct nitrox_sym_device) + }; + struct rte_cryptodev *cdev; + + rte_pci_device_name(&ndev->pdev->addr, name, sizeof(name)); + snprintf(name + strlen(name), RTE_CRYPTODEV_NAME_MAX_LEN, "_n5sym"); + ndev->rte_sym_dev.driver =3D &nitrox_rte_sym_drv; + ndev->rte_sym_dev.numa_node =3D ndev->pdev->device.numa_node; + ndev->rte_sym_dev.devargs =3D NULL; + cdev =3D rte_cryptodev_pmd_create(name, &ndev->rte_sym_dev, + &init_params); + if (!cdev) { + NITROX_LOG(ERR, "Cryptodev '%s' creation failed\n", name); + return -ENODEV; + } + + ndev->rte_sym_dev.name =3D cdev->data->name; + cdev->driver_id =3D nitrox_sym_drv_id; + cdev->dev_ops =3D &nitrox_cryptodev_ops; + cdev->enqueue_burst =3D NULL; + cdev->dequeue_burst =3D NULL; + cdev->feature_flags =3D RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO | + RTE_CRYPTODEV_FF_HW_ACCELERATED; + + ndev->sym_dev =3D cdev->data->dev_private; + ndev->sym_dev->cdev =3D cdev; + ndev->sym_dev->ndev =3D ndev; + NITROX_LOG(DEBUG, "Created cryptodev '%s', dev_id %d, drv_id %d\n", + cdev->data->name, cdev->data->dev_id, nitrox_sym_drv_id); + return 0; +} + +int +nitrox_sym_pmd_destroy(struct nitrox_device *ndev) +{ + return rte_cryptodev_pmd_destroy(ndev->sym_dev->cdev); +} + +static struct cryptodev_driver nitrox_crypto_drv; +RTE_PMD_REGISTER_CRYPTO_DRIVER(nitrox_crypto_drv, + nitrox_rte_sym_drv, + nitrox_sym_drv_id); diff --git a/drivers/crypto/nitrox/nitrox_sym.h b/drivers/crypto/nitrox/nit= rox_sym.h new file mode 100644 index 000000000..f30847e8a --- /dev/null +++ b/drivers/crypto/nitrox/nitrox_sym.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + +#ifndef _NITROX_SYM_H_ +#define _NITROX_SYM_H_ + +struct nitrox_device; + +int nitrox_sym_pmd_create(struct nitrox_device *ndev); +int nitrox_sym_pmd_destroy(struct nitrox_device *ndev); + +#endif /* _NITROX_SYM_H_ */ --=20 2.13.6