From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0082.outbound.protection.outlook.com [104.47.33.82]) by dpdk.org (Postfix) with ESMTP id F0E551BA10 for ; Mon, 9 Apr 2018 23:01:24 +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=mkpaEbyI/SImnnGnL4vwYc6okZ1PF1UyQQy4YjLXFdc=; b=j3YWRJQOWn0TM02cMzxG8jny5S5PNSSYrihRbl1aJVcgJc/srTgPPOgKjpezuAt5hco3+VuvR4My2aF6Sic+MFNWrLTlxqEcScYj0k36gT01b/2jFkcYdwHIITrDCYc4JNJ+UXCUnTqSFyTA3CXqkm5zgDg/Gxk0Dsiee9mnaog= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from localhost.localdomain (111.93.218.67) by MWHPR07MB3470.namprd07.prod.outlook.com (2603:10b6:301:63::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.653.12; Mon, 9 Apr 2018 21:01:21 +0000 From: Pavan Nikhilesh To: jerin.jacob@caviumnetworks.com, santosh.shukla@caviumnetworks.com, erik.g.carrillo@intel.com Cc: dev@dpdk.org, Pavan Nikhilesh Date: Tue, 10 Apr 2018 02:30:26 +0530 Message-Id: <20180409210035.23278-3-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180409210035.23278-1-pbhagavatula@caviumnetworks.com> References: <20180216213700.3415-1-pbhagavatula@caviumnetworks.com> <20180409210035.23278-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BM1PR01CA0088.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1::28) To MWHPR07MB3470.namprd07.prod.outlook.com (2603:10b6:301:63::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d315165-c3da-4725-b34b-08d59e5d0d84 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(2017052603328)(7153060)(7193020); SRVR:MWHPR07MB3470; X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 3:1R6VSJyzGjIMVO+xvlI+cpK+0eNz87SJYsIvsd7JzEm4CtEs2VNkhIBuU1mXwNMKjjgNtUjosA+fUPnx1bHYAidQETLk536Lcqp2I1pUEuRhaeBalEZbQT6de1Hy4lRCGy0C5/jZ9G1iMhq7cplS15i01y74Ujow8CQ1qeTEGnQwL2BqaGQbFPoTJRNdnvBJKuchCGqLGaSwW77d5D6tOn22p39uzWBrntBtQDYANqqRCXujMiTRotAQjXeB1DAk; 25:E6bCf3rNI+of2rdc9dTlrwNkRe6J5d2hUKnBv0oXf3g/oGPZBYSfoqHejDEFyEKjqqmTHYpIxjipmZAF9nK2nlwQItN8mcualIoUlAzuuCZo+RMSLHvXUPM7l3xjjU4ccPviU6wfmUzBlKi6/UNNLI9ir9sVOoMHgV3BwrT6/RZJuuejJsuRggXAcyRG2En3rhmd4LXSLoES9P4uOLKumhJqn23sEj2tTBGE2r2Q1BCguf7Nc9DUaagIVg+Ot+11FHl7Z5VCl6MFaSeMcwzBGrkjTZcOu4piTbo+oJM/xaxMdlHpAtbOJIyTEYAKZo0jcTYg/CJIeH91cXOPSWKYjA==; 31:rRou0IqyyrHKeOYAXN8cXe4SDS2hYOc086GDjz9bevrhRnU5PxJ+54FH/f04xgTvFDyVrAf8D9+/1EV2NcXikRrCWV8eqvcr3Kib3VwiW0tGtuDhRLYe4QgVr6vyPIDl0l349HJHwPHNhfj2+ojjzuaYVN9i+H+tbmXKO8XHsBtiVqJaR36OLHKTRBpdzPT3hYfHD9vgaVw2/GXYoSxeqixZFbLxKw/rq4gHFseJ+do= X-MS-TrafficTypeDiagnostic: MWHPR07MB3470: X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 20:hQh9JUNXxiNxsCTHVjjS8MLWn0/GU96w0xcSFHG3d6S7JctOhkDCyXTfY65caEam5X5YPlMFGH1hIkdCaXhgH6uw+58N8g/+b0yMzBERVdFdD6itMjP49wX5N2ytRbY1gZht3zKrAWikvKY8ry4G3h9AMxeJxseDmirHUw4+fhoCW2+mxy937xWEyaZZ1xt7DfWbzE9jsXsft/DkBqBHXYDdH9DODan+kmZPiJEdMg6mFaopPCMgej7E+mc2N4N9gnbYoctoovoefKl1SGlCDIUfL3EnfsOJ3Zx7UPVYig3A6NbcgBAm9M69JV1b89N0rJwDwQRZLJmHhoIEKo1kBrR9wpMSVpNUlRkuCbfS5mdrmj2isPSRFB+NTdQlBkZYEbJmkD9mzztVfgkwcmrPh+rjLy50IDo0EWIkqoIMgMjNJOLkKsqzEV2SOkI1RYLC5Slk1MuF6D0/xCyuQkldJ0w1qtHs5zeqxHO8cw3bXHdyOkCrKgyAYE47OsnqwURrT6NrW4a/JNsJ9sESG9tPVqLGHl/xS9MbJ3/D94zFfQSRm9cXBeOPzc5H7o46QejchvBR97h470meSjc9081ni4NvLFsCWAHYcGWJOAHmXEI=; 4:/3GoFs8jHi4ToJN8Th3tjY9ufOp4oXlPuwh6rx0Gx/6jL0azLLT165tomJ2kQcKKy2BZPSEBkPloRyOB0P1QpU9Or1BymTMU9vf5pZUJObd2PqCLC9ZIchcGU6B5cQwSoRcTRBi8Bjm21su86atK8xFZ6UGwTfWGBHwkdfPRrn7vB0RhqQxDaZgUDs+Xb9RvjaIMnygp3sWWwLcdaF78DiLLFm8/2VLWVTM9omv/6IAApIPkDhrVg6mCXfOcqB+O8LGLvd1ORy6V+I4+oIWsmw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501327)(52105095)(3002001)(10201501046)(93006095)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:MWHPR07MB3470; BCL:0; PCL:0; RULEID:; SRVR:MWHPR07MB3470; X-Forefront-PRVS: 0637FCE711 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(366004)(376002)(346002)(39860400002)(396003)(39380400002)(189003)(199004)(107886003)(48376002)(446003)(1857600001)(50466002)(97736004)(66066001)(2906002)(53936002)(6512007)(42882007)(59450400001)(81166006)(956004)(81156014)(25786009)(16526019)(6116002)(2616005)(476003)(5660300001)(6486002)(3846002)(11346002)(8936002)(26005)(50226002)(8676002)(486006)(47776003)(1076002)(478600001)(105586002)(76176011)(68736007)(72206003)(7736002)(106356001)(5009440100003)(305945005)(4326008)(6506007)(316002)(16586007)(386003)(51416003)(52116002)(36756003)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB3470; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR07MB3470; 23:GHLp4YagPVF9qtUwdMkjb0cOtBtDkpDpG0i/sqs50?= =?us-ascii?Q?UsQE2n5qeHalBA7lxWTyA1MNd+TTIHbmTjuyLkWs1+pVNqwHACNcPMBjaCie?= =?us-ascii?Q?C6JhfN9TSGeRgGUUm6xrW3Z/2zJT0+dUZLCZFF1nI63DPi3Xw50IYKd8DVCS?= =?us-ascii?Q?Y8ddZGsYpcjTFTJESTqvzQv0IukTF4mtRrvcgoGdkOO2aVWIk+uMu0JKXQVu?= =?us-ascii?Q?NQYCEodbOAJTfUNp62NQEQUC24KOjQBrxk/C8njad+xT1hSN83Aet1fq1C3a?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EVLG4Pfj2Pe1+kIyW4zQnLxLMf74+hl6XOWny6aQ2913OxJEnYU=; 24:b7eUR1/Y3FGgiyzfP7FiU53gy61grmzMmUddOaWOU9wkFJGwxh3DM9uUN6lJtMaatyzHOC2WKb4HkWJxiwITR8I+bQsaDe95N+OBSrOsBqg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 7:yowVefIN1H/je8m4AuROxrW/ISUTOMv2bTvuy7B1f8LdUy2DAEo9I4MXV1EYo+Md4Uh0xIzPu89aG/ZbN6VpSwRw0nFgTPbYrY+tK8gR3ZqlJrtcPSdMCGC7w1JeXw49izl0BbgZt3O730V3rCxw/jDO9wWd+GBfU7Ri7Tn1AtmEh4J7jW3dpRwaYW0cb69+4jsxCfJsZMlu75L27qfeypBOlm+re8mgkTjj9OE9xMIQKBWh9jElDn7NW5cSLK1c X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2018 21:01:21.7178 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8d315165-c3da-4725-b34b-08d59e5d0d84 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3470 Subject: [dpdk-dev] [PATCH v4 02/11] event/octeontx: add support to probe timvf PCIe 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: Mon, 09 Apr 2018 21:01:26 -0000 On Octeontx HW, each event timer device is enumerated as separate SRIOV VF PCIe device. In order to expose as a event timer device: On PCIe probe, the driver stores the information associated with the PCIe device and later when appliacation requests for a event timer device through `rte_event_timer_adapter_create` the driver infrastructure creates the timer adapter with earlier probed PCIe VF devices. Signed-off-by: Pavan Nikhilesh Acked-by: Jerin Jacob --- drivers/event/octeontx/timvf_evdev.h | 33 ++++++ drivers/event/octeontx/timvf_probe.c | 148 +++++++++++++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 drivers/event/octeontx/timvf_evdev.h create mode 100644 drivers/event/octeontx/timvf_probe.c diff --git a/drivers/event/octeontx/timvf_evdev.h b/drivers/event/octeontx/timvf_evdev.h new file mode 100644 index 000000000..7e577edf4 --- /dev/null +++ b/drivers/event/octeontx/timvf_evdev.h @@ -0,0 +1,33 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017 Cavium, Inc + */ + +#ifndef __TIMVF_EVDEV_H__ +#define __TIMVF_EVDEV_H__ + +#include + +#include + +#define timvf_log(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, otx_logtype_timvf, \ + "[%s] %s() " fmt "\n", \ + RTE_STR(event_timer_octeontx), __func__, ## args) + +#define timvf_log_info(fmt, ...) timvf_log(INFO, fmt, ##__VA_ARGS__) +#define timvf_log_dbg(fmt, ...) timvf_log(DEBUG, fmt, ##__VA_ARGS__) +#define timvf_log_err(fmt, ...) timvf_log(ERR, fmt, ##__VA_ARGS__) +#define timvf_func_trace timvf_log_dbg + +extern int otx_logtype_timvf; + +struct timvf_info { + uint16_t domain; /* Domain id */ + uint8_t total_timvfs; /* Total timvf available in domain */ +}; + +int timvf_info(struct timvf_info *tinfo); +void *timvf_bar(uint8_t id, uint8_t bar); + +#endif /* __TIMVF_EVDEV_H__ */ diff --git a/drivers/event/octeontx/timvf_probe.c b/drivers/event/octeontx/timvf_probe.c new file mode 100644 index 000000000..08dbd2be9 --- /dev/null +++ b/drivers/event/octeontx/timvf_probe.c @@ -0,0 +1,148 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017 Cavium, Inc + */ + +#include +#include +#include +#include + +#include + +#include "ssovf_evdev.h" +#include "timvf_evdev.h" + +#ifndef PCI_VENDOR_ID_CAVIUM +#define PCI_VENDOR_ID_CAVIUM (0x177D) +#endif + +#define PCI_DEVICE_ID_OCTEONTX_TIM_VF (0xA051) +#define TIM_MAX_RINGS (64) + +struct timvf_res { + uint16_t domain; + uint16_t vfid; + void *bar0; + void *bar2; + void *bar4; +}; + +struct timdev { + uint8_t total_timvfs; + struct timvf_res rings[TIM_MAX_RINGS]; +}; + +static struct timdev tdev; + +int +timvf_info(struct timvf_info *tinfo) +{ + int i; + struct ssovf_info info; + + if (tinfo == NULL) + return -EINVAL; + + if (!tdev.total_timvfs) + return -ENODEV; + + if (ssovf_info(&info) < 0) + return -EINVAL; + + for (i = 0; i < tdev.total_timvfs; i++) { + if (info.domain != tdev.rings[i].domain) { + timvf_log_err("GRP error, vfid=%d/%d domain=%d/%d %p", + i, tdev.rings[i].vfid, + info.domain, tdev.rings[i].domain, + tdev.rings[i].bar0); + return -EINVAL; + } + } + + tinfo->total_timvfs = tdev.total_timvfs; + tinfo->domain = info.domain; + return 0; +} + +void* +timvf_bar(uint8_t id, uint8_t bar) +{ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return NULL; + + if (id > tdev.total_timvfs) + return NULL; + + switch (bar) { + case 0: + return tdev.rings[id].bar0; + case 4: + return tdev.rings[id].bar4; + default: + return NULL; + } +} + +static int +timvf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) +{ + uint64_t val; + uint16_t vfid; + struct timvf_res *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[4].addr == NULL) { + timvf_log_err("Empty bars %p %p", + pci_dev->mem_resource[0].addr, + pci_dev->mem_resource[4].addr); + return -ENODEV; + } + + val = rte_read64((uint8_t *)pci_dev->mem_resource[0].addr + + 0x100 /* TIM_VRINGX_BASE */); + vfid = (val >> 23) & 0xff; + if (vfid >= TIM_MAX_RINGS) { + timvf_log_err("Invalid vfid(%d/%d)", vfid, TIM_MAX_RINGS); + return -EINVAL; + } + + res = &tdev.rings[tdev.total_timvfs]; + res->vfid = vfid; + res->bar0 = pci_dev->mem_resource[0].addr; + res->bar2 = pci_dev->mem_resource[2].addr; + res->bar4 = pci_dev->mem_resource[4].addr; + res->domain = (val >> 7) & 0xffff; + tdev.total_timvfs++; + rte_wmb(); + + timvf_log_dbg("Domain=%d VFid=%d bar0 %p total_timvfs=%d", res->domain, + res->vfid, pci_dev->mem_resource[0].addr, + tdev.total_timvfs); + return 0; +} + + +static const struct rte_pci_id pci_timvf_map[] = { + { + RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, + PCI_DEVICE_ID_OCTEONTX_TIM_VF) + }, + { + .vendor_id = 0, + }, +}; + +static struct rte_pci_driver pci_timvf = { + .id_table = pci_timvf_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_IOVA_AS_VA, + .probe = timvf_probe, + .remove = NULL, +}; + +RTE_PMD_REGISTER_PCI(octeontx_timvf, pci_timvf); -- 2.17.0