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 D6720A0471 for ; Fri, 19 Jul 2019 14:34:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BD58D1B952; Fri, 19 Jul 2019 14:33:45 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 1947658C6 for ; Fri, 19 Jul 2019 14:33:39 +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 x6JCGNNq026073 for ; Fri, 19 Jul 2019 05:33:38 -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=C8A5iN7YLLps7QbD2MrrglDrZ31vf/EtWAXNfyhXFrvNvNAXGqr6pZ3SWI+m7bo97EdS a5OJq3PQkMmyLVjn1XWkuqgJq3XlvGSe8WuBaEz9yedaIacAvyZa3Xa3KR37xOK5hQSy f9vHyd8AqCU3+WgCSEjkirShD5FOXjBnos9d9WM+f8VBv9A2eekaDag+ZsMUj4Dv4Kwy klDl/yUS3eccXlvUkt3bVc2/HyNhWktNcQkDaTHp0l6KKDEuRsPVgn5bdwbtTCUU7ORU gtjvFZHmKMxJMZyvRwsxjJZzKn5evlw812mes7XQRRAtvvzaf9cYHxkJ2vNGetBKYBn5 VQ== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2ts0a2gfpq-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 19 Jul 2019 05:33:38 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 19 Jul 2019 05:33:35 -0700 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (104.47.42.59) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Fri, 19 Jul 2019 05:33:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DokG2GqDj9S6x5rOAjsY0ke3uBn45lusqhshR55XdE+puHljsSd/oRfJw/VwAassxovCl4xFUIVeRKm77xsjY3FwBKExMmBEruoIXxCFUi3a37SEIuaNVS2jms82GBhoEazJZDRmhlqInNa009b3+ilFRGsyW90fzHpTgfFbbC4TLM9ZFnIzu2qmprByI5GpJB3UakED94bf6580tovrhy5aV7JPwaPogkodZ4S9a84u4kBhLxKvgXcKpNvwLFweoR9PwkJrYI5PmDZUQQ8ylu89Y5dluBIpeogL8FneCLyZQeaccpvQmUl3dl5Odsl+HhywG1gKaoXEMLjfPZScgw== 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=Czs23T+XdkleyU+3WoMFxOykUcDLOWlOa0tlhMqvB8XWIQaCMKRayNeqihd7GCsAdVQuwSs6y06qiyBalxh4eMe5Z/++VSTfLwDia8m/wWDk9d90kjOiBjN34A5+0Z8WrAZ9NfjD7xen6PF0yodHOprpWEEUIeQIz2oenaf2WPyZjNIa7WWjsnEvMTWHxHR0gWNsk4xKzQ0tlkzZJj0UlprvJ0p8vCfi/WMCmyBFy+Q2V6fkC0Ow6KjRXT6OJPHREvvBfORQiGyUrYyetAbKHOUWGD+NxT63dSO+3E84gM+fdiEQxvsCLXgzEOnZYXdnpsrsmbRNrDcsbnUgSOxO4A== 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=gdy/2aJJEVXlz9z8CpFEeSxu8pHmMpMMKZazw7Nfg6Dj3E0SY0Jwb5mqFaNZ5gvuVQC3ZqDsEGm8gKapmc9JXC1tMr9rhaoOLefSqo2c2s8/0GKoUGvY7VtKcrWaTj67B+EosLYIuYYz4S982ZVNRmPAVXQOHN/f4GfSulRBUlc= Received: from MN2PR18MB2797.namprd18.prod.outlook.com (20.179.22.16) by MN2PR18MB3294.namprd18.prod.outlook.com (10.255.237.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2094.11; Fri, 19 Jul 2019 12:33:34 +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.2094.011; Fri, 19 Jul 2019 12:33:34 +0000 From: Nagadheeraj Rottela To: "dev@dpdk.org" CC: Srikanth Jampala , Nagadheeraj Rottela Thread-Topic: [PATCH v2 02/10] crypto/nitrox: add PCI probe and remove routines Thread-Index: AQHVPi4uwrzW2lHxuEO2AFkNq1aCpw== Date: Fri, 19 Jul 2019 12:33:34 +0000 Message-ID: <20190719123309.24417-3-rnagadheeraj@marvell.com> References: <20190717052837.647-1-rnagadheeraj@marvell.com> <20190719123309.24417-1-rnagadheeraj@marvell.com> In-Reply-To: <20190719123309.24417-1-rnagadheeraj@marvell.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1a::34) 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: fb90c798-7551-4777-0c66-08d70c45509d 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:MN2PR18MB3294; x-ms-traffictypediagnostic: MN2PR18MB3294: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:153; x-forefront-prvs: 01039C93E4 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(39860400002)(366004)(396003)(346002)(136003)(199004)(189003)(186003)(26005)(68736007)(53936002)(76176011)(102836004)(99286004)(486006)(55236004)(386003)(6506007)(52116002)(6436002)(5640700003)(64756008)(81156014)(14444005)(2616005)(476003)(3846002)(2906002)(256004)(11346002)(446003)(8676002)(6512007)(2501003)(6486002)(2351001)(6116002)(54906003)(86362001)(14454004)(36756003)(316002)(25786009)(478600001)(6916009)(66066001)(7736002)(4326008)(66476007)(107886003)(8936002)(71200400001)(1076003)(50226002)(305945005)(81166006)(5660300002)(66446008)(66946007)(1730700003)(71190400001)(66556008); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB3294; 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: b5h8eFUP5Nh/oW5wyNUmMuHPde6ZXP6gVE7toRX/zpNX7OUmTThxVj6iNmbjAq4mqPBGVcTyJ1MIPusGeTlSrmM7iepNYfGTRk1/xwp8gxhB/ygyyXWQjcVUhX4LplkFLq8Dl7618tzgKoaWtVOfyec2VEr4oCN5kaEpECL+pX7Rwfi3MenPPiS6T1dQ4c/hdL7I2oOWY7RIQYO731TpizwymOP/pEhZCYlfZVJroAsd0caG0pVEfLgsjJthhg9LS85RlQAhiDU1T7z1ovTX/g9T/KQnHV5dw/rwqF5fr8Ljl+JsvaYORJZbdNcQO3Y00fKyipeMhhkT2DRBYGPkbsqDpmN+ULv5pxAAyiTj5ZvOf/yM2/vK2zqP28ERC4nBX/v8M1sBpbKunQXLSqAK5JSL8zdHfI32l9BCJaGneow= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: fb90c798-7551-4777-0c66-08d70c45509d X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2019 12:33:34.3049 (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: MN2PR18MB3294 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-07-19_08:2019-07-19,2019-07-19 signatures=0 Subject: [dpdk-dev] [PATCH v2 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