From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by dpdk.org (Postfix) with ESMTP id AB6BC7D0D for ; Thu, 1 Jun 2017 12:10:52 +0200 (CEST) Received: by mail-wm0-f52.google.com with SMTP id d127so53580906wmf.0 for ; Thu, 01 Jun 2017 03:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=bGhQgcDCUGU+jchvRIUvzwW/fm5y/wKIMm/FGf6AcIo=; b=rgEGkP36eltwT7506jSm1oPmx1yGdlTUoOQDOqPumaNViQogGXWrcVkKfmjSGG9S0s 8F8OP0PlxMl3g5exdzuyJ43eC+zpjdlqML4p4ubRV9mJQNG28oiTrumT9t+nm3HrQnw/ KhB3+nkY5Kkvll588t4ZxQ1SMhnhX80QBwXE2LSFtMl4bM3yWwe/H+r5fvLPGHSFpAoc GyBPgChyOym72/DKhLH3iAiq/H9KA5a80wd4i8DG2VSaCyQfl47tyhBZX/YPkq6VFCSQ nOxJX8ANAZdbdQE9UErdqf/NVG6/LWQWJiorbu804H1M4sJII4Rw+04cgqu8+6/cI5E5 3miA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=bGhQgcDCUGU+jchvRIUvzwW/fm5y/wKIMm/FGf6AcIo=; b=YuWT9Y35+L6vjOgQ9rPQs8iNM8R/N724NdziT4VfSe1EEukFGS22gmGb1sNrtW5kds 2YoYlw+7hZfA8mSg4RjRtXM7GUfLITrn2HPkm045cMuppR8LXbHGTogTNjLcq8yd0DTe OYiJPahrUux8xHXmOFo842+zM3hDqp4QpcYcp6dPEeWaXnYtwSNEi/QkWNH8Etc9ZofM +Z4h1MCnA6fhhDyZleJUnzOkO189bXyakntJgU7tp0AeXG5nNMIsXQQMO+E0roftK0YM 0Ak6IiKqvwU2YhxHZ1mSaFlkkdMnObb0zpbcsi20tN27F5CM3FggPm0/gPRduZQlZulO unsA== X-Gm-Message-State: AODbwcC9kSIZCV1utVCc4BDwgeWBRZ7ntdFpNrfhy62SuuSliJPVml2k pPcuuIYQSZXfFFTb2bA= X-Received: by 10.28.27.197 with SMTP id b188mr1095322wmb.61.1496311851955; Thu, 01 Jun 2017 03:10:51 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id y19sm1022569wmh.21.2017.06.01.03.10.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Jun 2017 03:10:50 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 1 Jun 2017 12:10:26 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 11/14] devargs: generic device representation 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, 01 Jun 2017 10:10:53 -0000 Remove the dependency of this subsystem upon bus specific device representation. Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus. Signed-off-by: Gaetan Rivet --- app/test-pmd/testpmd.c | 9 ++---- lib/librte_eal/common/eal_common_devargs.c | 48 +++++------------------------ lib/librte_eal/common/eal_common_pci.c | 9 ++++-- lib/librte_eal/common/eal_common_vdev.c | 15 +++++---- lib/librte_eal/common/include/rte_devargs.h | 16 ++-------- lib/librte_eal/common/include/rte_vdev.h | 2 +- 6 files changed, 26 insertions(+), 73 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index d1041af..daeece2 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1807,7 +1807,6 @@ rmv_event_callback(void *arg) { struct rte_eth_dev *dev; struct rte_devargs *da; - char name[32] = ""; uint8_t port_id = (intptr_t)arg; RTE_ETH_VALID_PORTID_OR_RET(port_id); @@ -1816,12 +1815,8 @@ rmv_event_callback(void *arg) stop_port(port_id); close_port(port_id); - if (da->type == RTE_DEVTYPE_VIRTUAL) - snprintf(name, sizeof(name), "%s", da->virt.drv_name); - else if (da->type == RTE_DEVTYPE_WHITELISTED_PCI) - rte_pci_device_name(&da->pci.addr, name, sizeof(name)); - printf("removing device %s\n", name); - rte_eal_dev_detach(name); + printf("removing device %s\n", da->name); + rte_eal_dev_detach(da->name); dev->state = RTE_ETH_DEV_UNUSED; } diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index a5014bf..51ffb45 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -40,7 +40,6 @@ #include #include -#include #include #include "eal_private.h" @@ -112,24 +111,10 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) if (rte_eal_parse_devargs_str(dev, &buf, &devargs->args)) goto fail; - switch (devargs->type) { - case RTE_DEVTYPE_WHITELISTED_PCI: - case RTE_DEVTYPE_BLACKLISTED_PCI: - /* try to parse pci identifier */ - if (eal_parse_pci_BDF(buf, &devargs->pci.addr) != 0 && - eal_parse_pci_DomBDF(buf, &devargs->pci.addr) != 0) - goto fail; - - break; - case RTE_DEVTYPE_VIRTUAL: - /* save driver name */ - ret = snprintf(devargs->virt.drv_name, - sizeof(devargs->virt.drv_name), "%s", buf); - if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name)) - goto fail; - - break; - } + /* save device name. */ + ret = snprintf(devargs->name, sizeof(devargs->name), "%s", buf); + if (ret < 0 || ret >= (int)sizeof(devargs->name)) + goto fail; if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) { if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) { bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST; @@ -181,27 +166,10 @@ rte_eal_devargs_dump(FILE *f) { struct rte_devargs *devargs; - fprintf(f, "User device white list:\n"); + fprintf(f, "User device list:\n"); TAILQ_FOREACH(devargs, &devargs_list, next) { - if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) - fprintf(f, " PCI whitelist " PCI_PRI_FMT " %s\n", - devargs->pci.addr.domain, - devargs->pci.addr.bus, - devargs->pci.addr.devid, - devargs->pci.addr.function, - devargs->args); - else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) - fprintf(f, " PCI blacklist " PCI_PRI_FMT " %s\n", - devargs->pci.addr.domain, - devargs->pci.addr.bus, - devargs->pci.addr.devid, - devargs->pci.addr.function, - devargs->args); - else if (devargs->type == RTE_DEVTYPE_VIRTUAL) - fprintf(f, " VIRTUAL %s %s\n", - devargs->virt.drv_name, - devargs->args); - else - fprintf(f, " UNKNOWN %s\n", devargs->args); + fprintf(f, " [%s]: %s %s\n", + (devargs->bus ? devargs->bus->name : "??"), + devargs->name, devargs->args); } } diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index c698cf8..d6658c2 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -102,12 +102,15 @@ const char *pci_get_sysfs_path(void) static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev) { struct rte_devargs *devargs; + struct rte_pci_addr addr; + struct rte_bus *pbus; + pbus = rte_bus_from_name(PCI_BUS_NAME); TAILQ_FOREACH(devargs, &devargs_list, next) { - if (devargs->type != RTE_DEVTYPE_BLACKLISTED_PCI && - devargs->type != RTE_DEVTYPE_WHITELISTED_PCI) + if (devargs->bus != pbus) continue; - if (!rte_eal_compare_pci_addr(&dev->addr, &devargs->pci.addr)) + devargs->bus->parse(devargs->name, &addr); + if (!rte_eal_compare_pci_addr(&dev->addr, &addr)) return devargs; } return NULL; diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index ea58706..f618bbb 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -186,9 +186,8 @@ alloc_devargs(const char *name, const char *args) if (args) devargs->args = strdup(args); - ret = snprintf(devargs->virt.drv_name, - sizeof(devargs->virt.drv_name), "%s", name); - if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name)) { + ret = snprintf(devargs->name, sizeof(devargs->name), "%s", name); + if (ret < 0 || ret >= (int)sizeof(devargs->name)) { free(devargs->args); free(devargs); return NULL; @@ -223,7 +222,7 @@ rte_vdev_init(const char *name, const char *args) dev->device.devargs = devargs; dev->device.numa_node = SOCKET_ID_ANY; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name; ret = vdev_probe_all_drivers(dev); if (ret) { @@ -304,7 +303,7 @@ vdev_scan(void) if (devargs->bus != vbus) continue; - dev = find_vdev(devargs->virt.drv_name); + dev = find_vdev(devargs->name); if (dev) continue; @@ -314,7 +313,7 @@ vdev_scan(void) dev->device.devargs = devargs; dev->device.numa_node = SOCKET_ID_ANY; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name; TAILQ_INSERT_TAIL(&vdev_device_list, dev, next); } @@ -358,13 +357,13 @@ vdev_find_device(rte_dev_match_t match, const void *data) static int vdev_plug(struct rte_devargs *da) { - return rte_vdev_init(da->virt.drv_name, da->args); + return rte_vdev_init(da->name, da->args); } static int vdev_unplug(struct rte_devargs *da) { - return rte_vdev_uninit(da->virt.drv_name); + return rte_vdev_uninit(da->name); } static struct rte_bus rte_vdev_bus = { diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h index 1f50a24..6a26d3d 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -50,7 +50,6 @@ extern "C" { #include #include -#include #include /** @@ -77,21 +76,10 @@ struct rte_devargs { TAILQ_ENTRY(rte_devargs) next; /** Type of device. */ enum rte_devtype type; - RTE_STD_C11 - union { - /** Used if type is RTE_DEVTYPE_*_PCI. */ - struct { - /** PCI location. */ - struct rte_pci_addr addr; - } pci; - /** Used if type is RTE_DEVTYPE_VIRTUAL. */ - struct { - /** Driver name. */ - char drv_name[32]; - } virt; - }; /** Bus handle for the device. */ struct rte_bus *bus; + /** Name of the device. */ + char name[32]; /** Arguments string as given by user or "" for no argument. */ char *args; }; diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h index 2d02c68..4debcde 100644 --- a/lib/librte_eal/common/include/rte_vdev.h +++ b/lib/librte_eal/common/include/rte_vdev.h @@ -52,7 +52,7 @@ static inline const char * rte_vdev_device_name(const struct rte_vdev_device *dev) { if (dev && dev->device.devargs) - return dev->device.devargs->virt.drv_name; + return dev->device.devargs->name; return NULL; } -- 2.1.4