From patchwork Mon Jul 20 06:41:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Lakkireddy X-Patchwork-Id: 6513 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id A588FC3C8; Mon, 20 Jul 2015 08:41:51 +0200 (CEST) Received: from stargate3.asicdesigners.com (stargate.chelsio.com [67.207.112.58]) by dpdk.org (Postfix) with ESMTP id 9DAE3C3C0 for ; Mon, 20 Jul 2015 08:41:50 +0200 (CEST) Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94]) by stargate3.asicdesigners.com (8.13.8/8.13.8) with ESMTP id t6K6feD7026715; Sun, 19 Jul 2015 23:41:41 -0700 From: Rahul Lakkireddy To: dev@dpdk.org Date: Mon, 20 Jul 2015 12:11:11 +0530 Message-Id: X-Mailer: git-send-email 2.4.1 In-Reply-To: References: In-Reply-To: References: Cc: Felix Marti , Kumar Sanghvi , Nirranjan Kirubaharan Subject: [dpdk-dev] [PATCH v2 1/3] nic_uio: Fix to allow any device to be bound to nic_uio X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" nic_uio requires the pci ids to be present in rte_pci_dev_ids.h in order to bind the devices to nic_uio. However, it's better to remove this whitelist of pci ids, and instead rely on hw.nic_uio.bdfs kenv parameter to allow binding any device to nic_uio. Suggested-by: David Marchand Signed-off-by: Rahul Lakkireddy Signed-off-by: Kumar Sanghvi --- v2: - Replace "Intel(R) DPDK" with just "DPDK" in device description for nic_uio. lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 48 +++++++++------------------------ 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c index 2354e84..f868dc8 100644 --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c @@ -106,24 +106,6 @@ struct pci_bdf { uint32_t function; }; - -#define RTE_PCI_DEV_ID_DECL_EM(vend, dev) {vend, dev}, -#define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) {vend, dev}, -#define RTE_PCI_DEV_ID_DECL_IGBVF(vend, dev) {vend, dev}, -#define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev) {vend, dev}, -#define RTE_PCI_DEV_ID_DECL_IXGBEVF(vend, dev) {vend, dev}, -#define RTE_PCI_DEV_ID_DECL_I40E(vend, dev) {vend, dev}, -#define RTE_PCI_DEV_ID_DECL_I40EVF(vend, dev) {vend, dev}, -#define RTE_PCI_DEV_ID_DECL_VIRTIO(vend, dev) {vend, dev}, -#define RTE_PCI_DEV_ID_DECL_VMXNET3(vend, dev) {vend, dev}, -#define RTE_PCI_DEV_ID_DECL_ENIC(vend, dev) {vend, dev}, - -const struct device devices[] = { -#include -}; -#define NUM_DEVICES (sizeof(devices)/sizeof(devices[0])) - - static devclass_t nic_uio_devclass; DEFINE_CLASS_0(nic_uio, nic_uio_driver, nic_uio_methods, sizeof(struct nic_uio_softc)); @@ -195,11 +177,10 @@ nic_uio_probe (device_t dev) { int i; - for (i = 0; i < NUM_DEVICES; i++) - if (pci_get_vendor(dev) == devices[i].vend && - pci_get_device(dev) == devices[i].dev) { - - device_set_desc(dev, "Intel(R) DPDK PCI Device"); + for (i = 0; i < num_detached; i++) + if (pci_get_vendor(dev) == pci_get_vendor(detached_devices[i]) && + pci_get_device(dev) == pci_get_device(detached_devices[i])) { + device_set_desc(dev, "DPDK PCI Device"); return BUS_PROBE_SPECIFIC; } @@ -256,7 +237,6 @@ static void nic_uio_load(void) { uint32_t bus, device, function; - int i; device_t dev; char bdf_str[256]; char *token, *remaining; @@ -295,17 +275,15 @@ nic_uio_load(void) if (dev == NULL) continue; - for (i = 0; i < NUM_DEVICES; i++) - if (pci_get_vendor(dev) == devices[i].vend && - pci_get_device(dev) == devices[i].dev) { - if (num_detached < MAX_DETACHED_DEVICES) { - printf("nic_uio_load: detaching and storing dev=%p\n", dev); - detached_devices[num_detached++] = dev; - } else - printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n", - MAX_DETACHED_DEVICES, dev); - device_detach(dev); - } + if (num_detached < MAX_DETACHED_DEVICES) { + printf("nic_uio_load: detaching and storing dev=%p\n", + dev); + detached_devices[num_detached++] = dev; + } else { + printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n", + MAX_DETACHED_DEVICES, dev); + } + device_detach(dev); } }