From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0055.outbound.protection.outlook.com [104.47.36.55]) by dpdk.org (Postfix) with ESMTP id 2E6B47CE5 for ; Thu, 31 Aug 2017 16:55:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=JpuqJxdFl0nXvrEPi67KiOWL5enNlZRrHprW+XjOx9k=; b=C6slWS8UOa/r8P6MB+MlnPgTckKjHImcC0f29IQjOEOYnckEFoI7L1LgNSo1puXYb6Yn089d3+eZ4PoSxF9bhwkV63vbf3E4Bwt2U2gPW/pfqF80HS3/SodWMujBZFeFjxL9CQwSPcqv59S9s0MMpSmBQAfch4KCj5Z4lDFKK1w= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.JacobKollanukkaran@cavium.com; Received: from jerin.domain.name (171.76.126.71) by SN2PR07MB2526.namprd07.prod.outlook.com (2603:10b6:804:6::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Thu, 31 Aug 2017 14:55:31 +0000 From: Jerin Jacob To: dev@dpdk.org Cc: ferruh.yigit@intel.com, santosh.shukla@caviumnetworks.com, Jerin Jacob Date: Thu, 31 Aug 2017 20:24:16 +0530 Message-Id: <20170831145436.5397-7-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170831145436.5397-1-jerin.jacob@caviumnetworks.com> References: <20170831145436.5397-1-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [171.76.126.71] X-ClientProxiedBy: MA1PR01CA0109.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::25) To SN2PR07MB2526.namprd07.prod.outlook.com (2603:10b6:804:6::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 134453e7-2766-4b1d-6715-08d4f08054b6 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:SN2PR07MB2526; X-Microsoft-Exchange-Diagnostics: 1; SN2PR07MB2526; 3:QV6xhd315baLCGONzpwmy6VbDYZQM75vZbeEa5C5LJGBjlpuHUVvRxQyyee9GtGjj4/+XECEHzWaw/W+5KpWgemtOxsi0xlEJnFJCX0zrfdGnbUJcEi0V+7e+jeZ1t/LppPzyUdNk0IkC5QonP4uEUVuTi/n/fLeG0pnSa4ZBmtAo8Ub4ifo+F2RjSh9KkScydv6Yn+K+N3XS6rA4gmtqVaaU5JcHmAYV2/RTnKukY9XOJIAT42RWOxijTT0qMs5; 25:jRLRuYGqZeVrqOIbaBmUmhf0XQtFVR9oRdW8YxDs1GpqmXYQsDuMDzylbQ7ARiqOuiIUrYOTId+w6zOKUzUY75ghYV70d3uT8ncI7QUb7dITo9XCMXrEyB7l5f1GEUh9vFgMVEWR6Ie3tZApRZkv5DzJ64wo9YntmV92K4FHjzhxy8bhTsOPDOyAPtt+Nfw/c3oG8yQZw4RuDe+CxJFBqwqfd6Y4tAtc3yFYmjy3yoMYGV9CxEcLMZVbzmEeP1moTF+C2OrvBrltgZbznWDQ0G9P7y3/bNWdhIylrxvkrEHsoG5WU8FFl/AP5xhP0mYgg0d0E4uBcNeMI2F183o7aQ==; 31:Fj/COVyMLlVedAqOhlBKyzJzJspLIWVyCZqNE12oVowdhwyi2xp5hDALE5dBvHXQ5KpVQV25z0gCl+3BUIItSe5TuwRxiiZTPcDDzXEJ4CYyUBNDyRP9QDYmPWd2Le2RNBHtYKEY7j/jkDi6L45vYLhswvz9F80c4BMDlmRemf047K+B3ef+2EC3sfuvMgpDkCH32I+Dt4zI9Z0jJGI9JeoYoorF12Ep4p0Tx1e+FQ0= X-MS-TrafficTypeDiagnostic: SN2PR07MB2526: X-Microsoft-Exchange-Diagnostics: 1; SN2PR07MB2526; 20:uuzOQ42V/36JYnZtphy/5Wcu+K6ieFiwe9rcgg+BeZw90p86Q6bl5aDlwdATV6lJLyafl7Uu1WsT4ykpWPHs/L1t1O2v+Fq3hwJgtaIChq7d33rifq+duHCjKS+HtCYjgcdx+bV6V0nbDp+vl8qmHupdZ8cFNZYlt0IDtljj+UMJbd0ooq8Anw1aW6p0HL97fj8i9OVqFv65kXzzzLoBx74DG4CphnhPwu11moVWoRhSueEaO4v+1/fSUf3iUZsknmbfiGfqbmYaAAGh1MmvCzRL+ifdEvwykWvPEpRWyP53tuf2aP5Fmu6bQFrStGYswKRgJjAaJ/EanmH3HRPSBfp+gbu3uEDKYy7HY1PCrAaNbWMrm2oHmgRTWE2injjwZdkuJlsqvtLUHzRxeuuMMVN0L11p3ErQq0eK/XxkPNa9bB9B5vjHNSi/Y2gs/jBjQS2sJ4ldH9DlkjW2PKklAxOB+Nu6lTmddfL2cLI9Oevfy/6SCKVapGIMS8/IioGh0tsqFF7QG2T7WNMjsWFxfUcp/I3rcpJ/KU3FkyNjF5Z5zy9DymNXeKnKicXOkAnOx3tjyc90d+1p4Xa6xIkEFWQ1UeTotMo967qgDDdmDCw=; 4:9qHQQZoCfktzoIPVXYmz17wgd2DFS2qpYoa09sQ8gQHyzrXtO0z6RoGtYBz2MsV1edEAJo8qzfCbPBXoweseuC9Im3lPRDlSBLqDTT/hqNSYG6ikiVNEZ0s6MrzlnFV1LYFomMP53L5fOeDH2Uing9uA+czI49XSBmUGd20cBghLApFLjJ9cEEZyH+sgbSa31RxibEthbF4etgAudGJ6rNx869nMoRoE67zN6ff3EESh07uI6600KkRv+MANRFuU X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(100000703101)(100105400095)(10201501046)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123562025)(20161123560025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN2PR07MB2526; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN2PR07MB2526; X-Forefront-PRVS: 04163EF38A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(25786009)(1076002)(53936002)(3846002)(6116002)(575784001)(478600001)(110136004)(72206003)(7736002)(6666003)(107886003)(6512007)(305945005)(6506006)(36756003)(6486002)(68736007)(5003940100001)(189998001)(50986999)(42882006)(106356001)(101416001)(76176999)(2950100002)(6916009)(5660300001)(2361001)(33646002)(2351001)(2906002)(4326008)(97736004)(105586002)(48376002)(50466002)(81166006)(66066001)(69596002)(8936002)(47776003)(53416004)(8676002)(50226002)(81156014)(42186005); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR07MB2526; H:jerin.domain.name; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN2PR07MB2526; 23:IFVDp6xMY2weEWnbnII4EvY93kRqCos5XLPTAC+BI?= =?us-ascii?Q?GTKQ3mno3lBIiM8yetDZm8MPBljbivjYfrcDt056efXnhlhc2qp9mdzF6pc2?= =?us-ascii?Q?ruBTiV7sOPl9s3ek76VPLUxvDvWu0WImRQZXp2A5S1uwbwAuw2lln1+eh284?= =?us-ascii?Q?A91yvNKGzGpxCbzI25B8I7d9/+iRvJ5rg6cwLaKS+EKlD3dVYN4qoqJXF9Cl?= =?us-ascii?Q?CWrYrKLweXncN3OoX7WT7lE1gh+mUKEQszGhELcpyZrlfTUDjUQDXzaHapYu?= =?us-ascii?Q?60A1N9FAut1qTSdm3E37revM/C0JqIUVNvJtvrKODb13RocVj5gtjhj9KQoW?= =?us-ascii?Q?NGm3pC0gEbYRRakNL2+pUkQMOPDTzB4GGzR+oSpUAvSoidlS4wILBD1viedr?= =?us-ascii?Q?tCtzk/HMVyWDOhyDp2YMGgqwwYRzVevbWHzKIZ0L9dCIHkgfYC6Nw4aQ32Bp?= =?us-ascii?Q?eih0WIFTWzwKcyI4uGNtW1fAHxv/vAejGkLGUwdbYayQA21B3mLf36Akhj+T?= =?us-ascii?Q?asAtzo2c/1KdYAoHswvEjlKnWlAp37fBv/s4Rlg7falvXRZNBnIJpHEZLwpS?= =?us-ascii?Q?jky9S2LGCr5RwT/keF7g78YIGiBmlM7XR7Qe89s5hUSSMfrfP63/IXzYDv7+?= =?us-ascii?Q?jEkHt6idWpk5EEpj9gTWKEtHGZnILpk5nwhlegncWW6ZJKGr6NZSgRngViSj?= =?us-ascii?Q?mHKIHhULHXyEvoIoKLM5rr09mJOTAkuEimdaDhPf16+0vh0rvQPJhyznleBe?= =?us-ascii?Q?nb7nARI3lyboIZOSWWm8M0nVzEibR96ggbsJkTAClG9ORh4QggslspDM5Akm?= =?us-ascii?Q?zl8+ci++wJA+m97QvOUWHPP98EV3An/BnLOBzTO2ejTpD67z1WFTzg6LVjEm?= =?us-ascii?Q?nz0SoSYpmOXaop1xj3pSMH+AjBQHjVNbgcfnsrUun/q76feXVbiLGhNq36M2?= =?us-ascii?Q?B48DU2n7sgZLOXIc8moVjABm0xvjX54nQdf2sLbqyWFXJmlyzIpI1SOtBJBD?= =?us-ascii?Q?pIhYOLiK8ee6Re9e0KST1tdSlou0G9kz2FoE7bA495Gn5U2UlANsksFOPRRd?= =?us-ascii?Q?YthurliIwF/lYY9InbvG8WuRCxshE73E9UXsVfBg3OJgGlVQ/u1yUfE2ekl8?= =?us-ascii?Q?2yZmt6n/nSer35FJ5EwOb2OfL/Jz50xBb7qmlq8izEPdMdLSm+dDadYPAvpn?= =?us-ascii?Q?YRrQhNYvQvHTbc=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN2PR07MB2526; 6:bAvPDVk3FqoGfanFvGxJHsuAJCvP9aTI/HG2eN14+qkU+etggTuUY/P3dKEZ9WB4fLkZUnY1Cnzlkd/J0MCI2JOS2Dvvi/1aZejnI7FGeGb0SKoa1ZajOeS01M/2kbzf1jmwtYSaHckwz8lUbhOJXVVRlJYITEJ0ezgdsXRcr1qTxorP3gO1GHZkWBYFkYnfaaCDlm+k0iQgv+yGBESfCiN/58AtDhO/Iwtc9OBEWxtkvPgs9nLpzDIOfyEYMVjO8N+AU4N8M+g/b7YPPEdaoZw+Gpeuho4UdQd+V6FJfutGhMcfadBhSPHc1GzISyCiiS0aWfQhCG9x82GcyeTfyw==; 5:T4SB8HWIymO3bf9Ssy2PyrJlwfPY2r5EU+WD6cR/on/XdARkluaxCaI7tRoTbEM2J/NSFpXwF4EmYLJ8+z55rItOK+dMygdmDSeLcdXdOCBVFJ3E3+C7hbgHKpS2+UuhHmt8bFK+vDvqhxWVkHCQFA==; 24:8sA5Kuva71XpoHSenn2kgdaBuiwGGmlb6A+FhlVacXmNJ9A2Cbhd4TdVNPWv25hNWPiS8WdfZVE6wNmMoMYm+TEvxxvzGfSstLR2CgIsz/A=; 7:7qyHY9RAnIZxd/AFHnR+4UCPiPRLbWpg5oiifPiQfaZRC6+Ze7F4cB6atJn2LXDNczMMf9IZznVdlmYbkLTCy/j18oT8C+zoRiAIa4y73DX1KQ6VdZou4kqN5SPpe0bg2m0PoQIbjYZAOE/xgS4DP27jdz2AnhFogdl8tF80EcPJz0Ih8Bx/N+II1jrXg/Sz5t+IjHMjQfQXJZb9ql/VgmmXxmxFHi6RajoHMXOxJyc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2017 14:55:31.3333 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR07MB2526 Subject: [dpdk-dev] [PATCH 06/26] net/octeontx/base: probe PKI and PKO PCIe VF devices 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: , X-List-Received-Date: Thu, 31 Aug 2017 14:55:35 -0000 An octeontx ethdev device consists of multiple PKO VF devices and an PKI VF device. On Octeontx HW, each Rx queues are enumerated as SSOVF device which is exposed as event_octeontx device, Tx queues are enumerated as PKOVF device, and ingress packet configuration is accomplished through PKIVF device. In order to expose as an single ethdev instance, On PCIe VF probe, the driver stores the information associated with the PCIe VF device and later with vdev infrastructure creates ethdev device with earlier probed PCIe VF device. Signed-off-by: Jerin Jacob Co-authored-by: Santosh Shukla --- drivers/net/octeontx/Makefile | 2 + drivers/net/octeontx/base/octeontx_pkivf.c | 70 ++++++++++++ drivers/net/octeontx/base/octeontx_pkovf.c | 175 +++++++++++++++++++++++++++++ drivers/net/octeontx/base/octeontx_pkovf.h | 63 +++++++++++ 4 files changed, 310 insertions(+) create mode 100644 drivers/net/octeontx/base/octeontx_pkivf.c create mode 100644 drivers/net/octeontx/base/octeontx_pkovf.c create mode 100644 drivers/net/octeontx/base/octeontx_pkovf.h diff --git a/drivers/net/octeontx/Makefile b/drivers/net/octeontx/Makefile index 91de31864..65de34c87 100644 --- a/drivers/net/octeontx/Makefile +++ b/drivers/net/octeontx/Makefile @@ -50,6 +50,8 @@ VPATH += $(SRCDIR)/base # # all source are stored in SRCS-y # +SRCS-$(CONFIG_RTE_LIBRTE_OCTEONTX_PMD) += octeontx_pkovf.c +SRCS-$(CONFIG_RTE_LIBRTE_OCTEONTX_PMD) += octeontx_pkivf.c SRCS-$(CONFIG_RTE_LIBRTE_OCTEONTX_PMD) += octeontx_bgx.c LDLIBS += -lrte_eventdev diff --git a/drivers/net/octeontx/base/octeontx_pkivf.c b/drivers/net/octeontx/base/octeontx_pkivf.c new file mode 100644 index 000000000..724acf0e8 --- /dev/null +++ b/drivers/net/octeontx/base/octeontx_pkivf.c @@ -0,0 +1,70 @@ +/* + * BSD LICENSE + * + * Copyright (C) Cavium Inc. 2017. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Cavium networks nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include + +#include +#include + +#define PCI_VENDOR_ID_CAVIUM 0x177D +#define PCI_DEVICE_ID_OCTEONTX_PKI_VF 0xA0DD + +/* PKIVF pcie device */ +static int +pkivf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) +{ + RTE_SET_USED(pci_drv); + RTE_SET_USED(pci_dev); + + /* For secondary processes, the primary has done all the work */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + return 0; +} + +static const struct rte_pci_id pci_pkivf_map[] = { + { + RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, + PCI_DEVICE_ID_OCTEONTX_PKI_VF) + }, + { + .vendor_id = 0, + }, +}; + +static struct rte_pci_driver pci_pkivf = { + .id_table = pci_pkivf_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING, + .probe = pkivf_probe, +}; + +RTE_PMD_REGISTER_PCI(octeontx_pkivf, pci_pkivf); diff --git a/drivers/net/octeontx/base/octeontx_pkovf.c b/drivers/net/octeontx/base/octeontx_pkovf.c new file mode 100644 index 000000000..599edefd0 --- /dev/null +++ b/drivers/net/octeontx/base/octeontx_pkovf.c @@ -0,0 +1,175 @@ +/* + * BSD LICENSE + * + * Copyright (C) Cavium Inc. 2017. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Cavium networks nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "../octeontx_logs.h" +#include "octeontx_io.h" +#include "octeontx_pkovf.h" + +struct octeontx_pko_iomem { + uint8_t *va; + phys_addr_t iova; + size_t size; +}; + +#define PKO_IOMEM_NULL (struct octeontx_pko_iomem){0, 0, 0} + +struct octeontx_pko_fc_ctl_s { + int64_t buf_cnt; + int64_t padding[(PKO_DQ_FC_STRIDE / 8) - 1]; +}; + +struct octeontx_pkovf { + uint8_t *bar0; + uint8_t *bar2; + uint16_t domain; + uint16_t vfid; +}; + +struct octeontx_pko_vf_ctl_s { + rte_spinlock_t lock; + + struct octeontx_pko_iomem fc_iomem; + struct octeontx_pko_fc_ctl_s *fc_ctl; + struct octeontx_pkovf pko[PKO_VF_MAX]; + struct { + uint64_t chanid; + } dq_map[PKO_VF_MAX * PKO_VF_NUM_DQ]; +}; + +static struct octeontx_pko_vf_ctl_s pko_vf_ctl; + +static void +octeontx_pkovf_setup(void) +{ + static bool init_once; + int i; + + RTE_SET_USED(i); + if (!init_once) { + rte_spinlock_init(&pko_vf_ctl.lock); + + pko_vf_ctl.fc_iomem = PKO_IOMEM_NULL; + pko_vf_ctl.fc_ctl = NULL; + + for (i = 0; i < PKO_VF_MAX; i++) { + pko_vf_ctl.pko[i].bar0 = NULL; + pko_vf_ctl.pko[i].bar2 = NULL; + pko_vf_ctl.pko[i].domain = ~(uint16_t)0; + pko_vf_ctl.pko[i].vfid = ~(uint16_t)0; + } + + for (i = 0; i < (PKO_VF_MAX * PKO_VF_NUM_DQ); i++) + pko_vf_ctl.dq_map[i].chanid = 0; + + init_once = true; + } +} + +/* PKOVF pcie device*/ +static int +pkovf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) +{ + uint64_t val; + uint16_t vfid; + uint16_t domain; + uint8_t *bar0; + uint8_t *bar2; + struct octeontx_pkovf *res; + + RTE_SET_USED(pci_drv); + + /* For secondary processes, the primary has done all the work */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + if (pci_dev->mem_resource[0].addr == NULL || + pci_dev->mem_resource[2].addr == NULL) { + octeontx_log_err("Empty bars %p %p", + pci_dev->mem_resource[0].addr, + pci_dev->mem_resource[2].addr); + return -ENODEV; + } + bar0 = pci_dev->mem_resource[0].addr; + bar2 = pci_dev->mem_resource[2].addr; + + octeontx_pkovf_setup(); + + /* get vfid and domain */ + val = octeontx_read64(bar0 + PKO_VF_DQ_FC_CONFIG); + domain = (val >> 7) & 0xffff; + vfid = (val >> 23) & 0xffff; + + if (unlikely(vfid >= PKO_VF_MAX)) { + octeontx_log_err("pko: Invalid vfid %d", vfid); + return -EINVAL; + } + + res = &pko_vf_ctl.pko[vfid]; + res->vfid = vfid; + res->domain = domain; + res->bar0 = bar0; + res->bar2 = bar2; + + octeontx_log_dbg("Domain=%d group=%d", res->domain, res->vfid); + return 0; +} + +#define PCI_VENDOR_ID_CAVIUM 0x177D +#define PCI_DEVICE_ID_OCTEONTX_PKO_VF 0xA049 + +static const struct rte_pci_id pci_pkovf_map[] = { + { + RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, + PCI_DEVICE_ID_OCTEONTX_PKO_VF) + }, + { + .vendor_id = 0, + }, +}; + +static struct rte_pci_driver pci_pkovf = { + .id_table = pci_pkovf_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING, + .probe = pkovf_probe, +}; + +RTE_PMD_REGISTER_PCI(octeontx_pkovf, pci_pkovf); diff --git a/drivers/net/octeontx/base/octeontx_pkovf.h b/drivers/net/octeontx/base/octeontx_pkovf.h new file mode 100644 index 000000000..bca4b2836 --- /dev/null +++ b/drivers/net/octeontx/base/octeontx_pkovf.h @@ -0,0 +1,63 @@ +/* + * BSD LICENSE + * + * Copyright (C) Cavium Inc. 2017. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Cavium networks nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __OCTEONTX_PKO_H__ +#define __OCTEONTX_PKO_H__ + +/* PKO maximum constants */ +#define PKO_VF_MAX (32) +#define PKO_VF_NUM_DQ (8) +#define PKO_MAX_NUM_DQ (8) +#define PKO_DQ_DRAIN_TO (1000) + +#define PKO_DQ_FC_SKID (4) +#define PKO_DQ_FC_DEPTH_PAGES (2048) +#define PKO_DQ_FC_STRIDE_16 (16) +#define PKO_DQ_FC_STRIDE_128 (128) +#define PKO_DQ_FC_STRIDE PKO_DQ_FC_STRIDE_16 + +#define PKO_DQ_KIND_BIT 49 +#define PKO_DQ_STATUS_BIT 60 +#define PKO_DQ_OP_BIT 48 + +/* PKO VF register offsets from VF_BAR0 */ +#define PKO_VF_DQ_SW_XOFF(gdq) (0x000100 | (gdq) << 17) +#define PKO_VF_DQ_WM_CTL(gdq) (0x000130 | (gdq) << 17) +#define PKO_VF_DQ_WM_CNT(gdq) (0x000150 | (gdq) << 17) +#define PKO_VF_DQ_FC_CONFIG (0x000160) +#define PKO_VF_DQ_FC_STATUS(gdq) (0x000168 | (gdq) << 17) +#define PKO_VF_DQ_OP_SEND(gdq, op) (0x001000 | (gdq) << 17 | (op) << 3) +#define PKO_VF_DQ_OP_OPEN(gdq) (0x001100 | (gdq) << 17) +#define PKO_VF_DQ_OP_CLOSE(gdq) (0x001200 | (gdq) << 17) +#define PKO_VF_DQ_OP_QUERY(gdq) (0x001300 | (gdq) << 17) + +#endif /* __OCTEONTX_PKO_H__ */ -- 2.14.1