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 B6607A0471 for ; Wed, 17 Jul 2019 07:29:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1FA3F1B965; Wed, 17 Jul 2019 07:29:13 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id F04462BAB for ; Wed, 17 Jul 2019 07:29:06 +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 x6H5PL4k005631 for ; Tue, 16 Jul 2019 22:29:06 -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=3a8pwVIu+gigUJBxJDA4KLRzxrJmkm19MSEHBqVZa7w=; b=CispYAKoQnZprIqAXkxuNBXpuAMDjpG+EgaNtmk11YyxtoQPsg+/bBLVMjm50kiAH3W0 uWdNrumT1uMPkLl083nwFavbKAU3RoW34JMV6pJs4EEWuWfV9px3TdsBJ50SUYYzh7Hi yxLwrLJVkpidq3arBzSh3cYruRwfpq2h2ifJhy69nY/YRkayXieNRzHvYGCA7Lu1zLZ6 uqfvQFotmU3IagtemWmtCAzBpMmAPkKdjlI+5eX+/FzpI35x0lMs5dhwNPIgWZlw6Iwb t4xAZ8ssfKkkGt8y1ICUrmEWZMWNN3GYUKgasdB+NumaIeZb6CUZMsTnXb7a248R21bp pg== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2ts0a26925-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 16 Jul 2019 22:29:06 -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; Tue, 16 Jul 2019 22:29:04 -0700 Received: from NAM01-BY2-obe.outbound.protection.outlook.com (104.47.34.53) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Tue, 16 Jul 2019 22:29:04 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M7X/6bNfUo/Ri2GoxI9JYp7qPITQKlGWT3sm/edRC22iBq24zrtgT6vLHTn59iC5Mcpqj/CDL6wgIO1tGmKjVbXl8xFO7yTMy9CuRjoJeFpPfha+cw1l1vEDfC+fZ3UW+H4daIaW8tZRchZgZzLb+Fr+3pTEw+n2bAwOjijCPsZyr12T916ogi5fcamHbCjD7oOdwiIYu03u6641l1G1jlndY+U1x4t2IfFguoRTf/CYs8jih8T0DTKDYDJiCVThj5qBd7dEgAbwQ0vv3Tpl+jnY60tLJKp8YIkUq3LSyqu/4oviP1z1vmqrsEgDxukzKO6k63LcD0x9YTdTP6HBWw== 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=3a8pwVIu+gigUJBxJDA4KLRzxrJmkm19MSEHBqVZa7w=; b=EsBf14NMJQ+QchO/xh5wAj7QzUshROedmCvgKwc0I2r3I0XkhgqPW4Tznqsx/Q/gCYOWn5Mu8zAsz5JBGB5Jutkbdz1+drdMj8I5IXrM5cZWvCXaxZ5k+ZUrt7F19UOiN7eZB7OY68iiCc6PPhq7Zomk87HIV/6d7Hc9rDhtLblOB1fIAPHO8csRT6Tfg3jobpuMdD43423PdykSNlcUATOIE9qwN+wL/ljDi/9/Gg9qeZx99Ww4cznBH/gdYla+2WlmSG9hr6GmnxbTsHctpEdWbSCcVw5Yi5TAI7SkqbSzlgF4pSoOHYdfxys2CucVuLIXtRY2RIYl0eEPsPQQMw== 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=3a8pwVIu+gigUJBxJDA4KLRzxrJmkm19MSEHBqVZa7w=; b=JDOEEJevjjc32vvhdF0uByiwMH3gGRzv/4MpZKLfoDfZLEo/JRh4oWeQGNTfLFbqWimYD4+1SI4SkWbP9X0Uw5TcVH2+g6jlBUpOjzgrHMoX1Ieoop1MEVJemjiRY5VaKvBdKjjmrup85WpH+D4FGk+DC4CODsNGtSIQnRlwB2k= 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:03 +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:03 +0000 From: Nagadheeraj Rottela To: "dev@dpdk.org" CC: Srikanth Jampala , Nagadheeraj Rottela Thread-Topic: [PATCH 02/10] crypto/nitrox: add PCI probe and remove routines Thread-Index: AQHVPGCL2L+Gsr3D20CaJ3sn85pTqA== Date: Wed, 17 Jul 2019 05:29:03 +0000 Message-ID: <20190717052837.647-3-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: 22c39b9e-a79c-4ca1-6e7f-08d70a77adc9 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:153; 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)(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: 5Aa3OXXTG3X/eqjxQJNMXsYyrcqsl8pM3Y4BdpzB1bP0hD6ggm61wb8hd8FTg97cwkAQlZL2oVN2KvtrZZA735DnC+f2wF718wykLCcYPdVP/gRei7tijOKyGRO4GCBr5bVWZk0myyvooFnUlTscnE4oTpqCW0lno+zwwIY4ISkKVCXNGG4uZoBODivfxW0mbJ7Xnz4rb6gSM/bBdF7RXp+BcziEEpT42ImZXezI9prh3geVXj05F6PndyARFIqomaebuyV2Fh4RovF15k9XDUvheHYO42CGNwSnZleqW88AW4Bz6ePMB5UkB2hWYpIQPs417M+CA1s7BOkjajie+ugu0A0M6HgWWgXbxMCUamYjRVLvyw9CYAMC6AAXlswJ19dgBgmScAemrcaYYpl8k/8dDmF8GQrXg67FZutc+VM= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 22c39b9e-a79c-4ca1-6e7f-08d70a77adc9 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jul 2019 05:29:03.1418 (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 02/10] crypto/nitrox: add PCI probe and remove routines 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 pci probe, remove and hardware init routines. Signed-off-by: Nagadheeraj Rottela --- drivers/crypto/nitrox/Makefile | 1 + drivers/crypto/nitrox/meson.build | 1 + drivers/crypto/nitrox/nitrox_csr.h | 28 +++++++++ drivers/crypto/nitrox/nitrox_device.c | 105 ++++++++++++++++++++++++++++++= ++++ drivers/crypto/nitrox/nitrox_device.h | 18 ++++++ drivers/crypto/nitrox/nitrox_hal.c | 86 ++++++++++++++++++++++++++++ drivers/crypto/nitrox/nitrox_hal.h | 37 ++++++++++++ 7 files changed, 276 insertions(+) create mode 100644 drivers/crypto/nitrox/nitrox_csr.h create mode 100644 drivers/crypto/nitrox/nitrox_device.h create mode 100644 drivers/crypto/nitrox/nitrox_hal.c create mode 100644 drivers/crypto/nitrox/nitrox_hal.h diff --git a/drivers/crypto/nitrox/Makefile b/drivers/crypto/nitrox/Makefil= e index da33a1d2a..bc0220964 100644 --- a/drivers/crypto/nitrox/Makefile +++ b/drivers/crypto/nitrox/Makefile @@ -24,5 +24,6 @@ LDLIBS +=3D -lrte_cryptodev =20 # library source files SRCS-$(CONFIG_RTE_LIBRTE_PMD_NITROX) +=3D nitrox_device.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_NITROX) +=3D nitrox_hal.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 0afb14b00..f1c96b84d 100644 --- a/drivers/crypto/nitrox/meson.build +++ b/drivers/crypto/nitrox/meson.build @@ -10,4 +10,5 @@ deps +=3D ['bus_pci'] allow_experimental_apis =3D true sources =3D files( 'nitrox_device.c', + 'nitrox_hal.c', ) diff --git a/drivers/crypto/nitrox/nitrox_csr.h b/drivers/crypto/nitrox/nit= rox_csr.h new file mode 100644 index 000000000..879104515 --- /dev/null +++ b/drivers/crypto/nitrox/nitrox_csr.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + +#ifndef _NITROX_CSR_H_ +#define _NITROX_CSR_H_ + +#include +#include + +#define CSR_DELAY 30 + +/* AQM Virtual Function Registers */ +#define AQMQ_QSZX(_i) (0x20008 + ((_i)*0x40000)) + +static inline uint64_t +nitrox_read_csr(uint8_t *bar_addr, uint64_t offset) +{ + return rte_read64(bar_addr + offset); +} + +static inline void +nitrox_write_csr(uint8_t *bar_addr, uint64_t offset, uint64_t value) +{ + rte_write64(value, (bar_addr + offset)); +} + +#endif /* _NITROX_CSR_H_ */ diff --git a/drivers/crypto/nitrox/nitrox_device.c b/drivers/crypto/nitrox/= nitrox_device.c index d26535dee..5628c6d8b 100644 --- a/drivers/crypto/nitrox/nitrox_device.c +++ b/drivers/crypto/nitrox/nitrox_device.c @@ -1,3 +1,108 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright(C) 2019 Marvell International Ltd. */ + +#include + +#include "nitrox_device.h" +#include "nitrox_hal.h" + +TAILQ_HEAD(ndev_list, nitrox_device); +static struct ndev_list ndev_list =3D TAILQ_HEAD_INITIALIZER(ndev_list); + +static struct nitrox_device * +ndev_allocate(struct rte_pci_device *pdev) +{ + struct nitrox_device *ndev; + + ndev =3D rte_zmalloc_socket("nitrox device", sizeof(*ndev), + RTE_CACHE_LINE_SIZE, + pdev->device.numa_node); + if (!ndev) + return NULL; + + TAILQ_INSERT_TAIL(&ndev_list, ndev, next); + return ndev; +} + +static void +ndev_init(struct nitrox_device *ndev, struct rte_pci_device *pdev) +{ + enum nitrox_vf_mode vf_mode; + + ndev->pdev =3D pdev; + ndev->bar_addr =3D pdev->mem_resource[0].addr; + vf_mode =3D vf_get_vf_config_mode(ndev->bar_addr); + ndev->nr_queues =3D vf_config_mode_to_nr_queues(vf_mode); +} + +static struct nitrox_device * +find_ndev(struct rte_pci_device *pdev) +{ + struct nitrox_device *ndev; + + TAILQ_FOREACH(ndev, &ndev_list, next) + if (ndev->pdev =3D=3D pdev) + return ndev; + + return NULL; +} + +static void +ndev_release(struct nitrox_device *ndev) +{ + if (!ndev) + return; + + TAILQ_REMOVE(&ndev_list, ndev, next); + rte_free(ndev); +} + +static int +nitrox_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, + struct rte_pci_device *pdev) +{ + struct nitrox_device *ndev; + + /* Nitrox CSR space */ + if (!pdev->mem_resource[0].addr) + return -EINVAL; + + ndev =3D ndev_allocate(pdev); + if (!ndev) + return -ENOMEM; + + ndev_init(ndev, pdev); + return 0; +} + +static int +nitrox_pci_remove(struct rte_pci_device *pdev) +{ + struct nitrox_device *ndev; + + ndev =3D find_ndev(pdev); + if (!ndev) + return -ENODEV; + + ndev_release(ndev); + return 0; +} + +static struct rte_pci_id pci_id_nitrox_map[] =3D { + { + /* Nitrox 5 VF */ + RTE_PCI_DEVICE(0x177d, 0x13) + }, + {.device_id =3D 0}, +}; + +static struct rte_pci_driver nitrox_pmd =3D { + .id_table =3D pci_id_nitrox_map, + .drv_flags =3D RTE_PCI_DRV_NEED_MAPPING, + .probe =3D nitrox_pci_probe, + .remove =3D nitrox_pci_remove, +}; + +RTE_PMD_REGISTER_PCI(nitrox, nitrox_pmd); +RTE_PMD_REGISTER_PCI_TABLE(nitrox, pci_id_nitrox_map); diff --git a/drivers/crypto/nitrox/nitrox_device.h b/drivers/crypto/nitrox/= nitrox_device.h new file mode 100644 index 000000000..0d0167de2 --- /dev/null +++ b/drivers/crypto/nitrox/nitrox_device.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + +#ifndef _NITROX_DEVICE_H_ +#define _NITROX_DEVICE_H_ + +#include +#include + +struct nitrox_device { + TAILQ_ENTRY(nitrox_device) next; + struct rte_pci_device *pdev; + uint8_t *bar_addr; + uint16_t nr_queues; +}; + +#endif /* _NITROX_DEVICE_H_ */ diff --git a/drivers/crypto/nitrox/nitrox_hal.c b/drivers/crypto/nitrox/nit= rox_hal.c new file mode 100644 index 000000000..3dee59215 --- /dev/null +++ b/drivers/crypto/nitrox/nitrox_hal.c @@ -0,0 +1,86 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + +#include +#include +#include +#include + +#include "nitrox_hal.h" +#include "nitrox_csr.h" + +#define MAX_VF_QUEUES 8 +#define MAX_PF_QUEUES 64 + +int +vf_get_vf_config_mode(uint8_t *bar_addr) +{ + union aqmq_qsz aqmq_qsz; + uint64_t reg_addr; + int q, vf_mode; + + aqmq_qsz.u64 =3D 0; + aqmq_qsz.s.host_queue_size =3D 0xDEADBEEF; + + reg_addr =3D AQMQ_QSZX(0); + nitrox_write_csr(bar_addr, reg_addr, aqmq_qsz.u64); + rte_delay_us_block(CSR_DELAY); + + aqmq_qsz.u64 =3D 0; + for (q =3D 1; q < MAX_VF_QUEUES; q++) { + reg_addr =3D AQMQ_QSZX(q); + aqmq_qsz.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + if (aqmq_qsz.s.host_queue_size =3D=3D 0xDEADBEEF) + break; + } + + switch (q) { + case 1: + vf_mode =3D NITROX_MODE_VF128; + break; + case 2: + vf_mode =3D NITROX_MODE_VF64; + break; + case 4: + vf_mode =3D NITROX_MODE_VF32; + break; + case 8: + vf_mode =3D NITROX_MODE_VF16; + break; + default: + vf_mode =3D 0; + break; + } + + return vf_mode; +} + +int +vf_config_mode_to_nr_queues(enum nitrox_vf_mode vf_mode) +{ + int nr_queues; + + switch (vf_mode) { + case NITROX_MODE_PF: + nr_queues =3D MAX_PF_QUEUES; + break; + case NITROX_MODE_VF16: + nr_queues =3D 8; + break; + case NITROX_MODE_VF32: + nr_queues =3D 4; + break; + case NITROX_MODE_VF64: + nr_queues =3D 2; + break; + case NITROX_MODE_VF128: + nr_queues =3D 1; + break; + default: + nr_queues =3D 0; + break; + } + + return nr_queues; +} diff --git a/drivers/crypto/nitrox/nitrox_hal.h b/drivers/crypto/nitrox/nit= rox_hal.h new file mode 100644 index 000000000..6184211a5 --- /dev/null +++ b/drivers/crypto/nitrox/nitrox_hal.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + +#ifndef _NITROX_HAL_H_ +#define _NITROX_HAL_H_ + +#include +#include + +#include "nitrox_csr.h" + +union aqmq_qsz { + uint64_t u64; + struct { +#if RTE_BYTE_ORDER =3D=3D RTE_BIG_ENDIAN + uint64_t raz : 32; + uint64_t host_queue_size : 32; +#else + uint64_t host_queue_size : 32; + uint64_t raz : 32; +#endif + } s; +}; + +enum nitrox_vf_mode { + NITROX_MODE_PF =3D 0x0, + NITROX_MODE_VF16 =3D 0x1, + NITROX_MODE_VF32 =3D 0x2, + NITROX_MODE_VF64 =3D 0x3, + NITROX_MODE_VF128 =3D 0x4, +}; + +int vf_get_vf_config_mode(uint8_t *bar_addr); +int vf_config_mode_to_nr_queues(enum nitrox_vf_mode vf_mode); + +#endif /* _NITROX_HAL_H_ */ --=20 2.13.6