From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by dpdk.org (Postfix) with ESMTP id 718DFB63E for ; Tue, 17 Feb 2015 01:13:21 +0100 (CET) Received: by mail-wi0-f179.google.com with SMTP id hi2so29495679wib.0 for ; Mon, 16 Feb 2015 16:13:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=UDlzFAXIEG3L0wx9xeKIAXvKtxUaV0CY6/X7DSDm2iM=; b=LWcc1EPiFyixKMGEpTId0D3WvwtWgSXUdvuhcrYOXh6y/kcWfA7408T4xo/i8HglTr CGcTUgApderPo8Y+ctjCDEtxKuELbULR+/hFeqyFBj758Qz9AzSCE4cLRDwMZdv/dRZq el3kf3g1sgKRYq7bkqcP3YKDNZxLwZbKp2PyA8fIc9fzUZzQ7ApEK0BMM18+DTn3XolD 9mei77Ov6wb7s0FKIox5T9TbSTKjLR0l+RBgPpqajjP8r2l84vxzOp7AsBcdZVN96Vxy O5QE3C7hw4D2B2l2mQcVg16fE57hwjs3WlCbbTQ0IsMqfTvAqChTUZ/xvZLaE8GnOZEg Pf1Q== X-Gm-Message-State: ALoCoQnAn3XgqqmLe3NSgf5GsWnQ6teURkixDHcUB/ZWLiks9rqKIhyTFc2RpInIiYgVuLE+vBoX X-Received: by 10.194.201.103 with SMTP id jz7mr57154153wjc.14.1424132001268; Mon, 16 Feb 2015 16:13:21 -0800 (PST) Received: from xps13.localnet (guy78-1-82-235-116-147.fbx.proxad.net. [82.235.116.147]) by mx.google.com with ESMTPSA id yy9sm24971291wjc.20.2015.02.16.16.13.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Feb 2015 16:13:20 -0800 (PST) From: Thomas Monjalon To: Tetsuya Mukawa , Michael Qiu Date: Tue, 17 Feb 2015 01:12:46 +0100 Message-ID: <1579136.8KQIkXORqn@xps13> Organization: 6WIND User-Agent: KMail/4.14.4 (Linux/3.18.4-1-ARCH; KDE/4.14.4; x86_64; ; ) In-Reply-To: <1424060073-23484-2-git-send-email-mukawa@igel.co.jp> References: <1423470639-15744-2-git-send-email-mukawa@igel.co.jp> <1424060073-23484-1-git-send-email-mukawa@igel.co.jp> <1424060073-23484-2-git-send-email-mukawa@igel.co.jp> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v8 01/14] eal_pci: Add flag to hold kernel driver type 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: , X-List-Received-Date: Tue, 17 Feb 2015 00:13:21 -0000 2015-02-16 13:14, Tetsuya Mukawa: > From: Michael Qiu > > Currently, dpdk has no ability to know which type of driver( > vfio-pci/igb_uio/uio_pci_generic) the device used. It only can > check whether vfio is enabled or not staticly. > > It really useful to have the flag, becasue different type need to > handle differently in runtime. For example, pci memory map, > pot hotplug, and so on. > > This patch add a flag field for pci device to solve above issue. > > Signed-off-by: Michael Qiu > Signed-off-by: Tetsuya Mukawa > --- > lib/librte_eal/common/include/rte_pci.h | 8 +++++ > lib/librte_eal/linuxapp/eal/eal_pci.c | 53 +++++++++++++++++++++++++++++++-- > 2 files changed, 59 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h > index 66ed793..7b48b55 100644 > --- a/lib/librte_eal/common/include/rte_pci.h > +++ b/lib/librte_eal/common/include/rte_pci.h > @@ -139,6 +139,13 @@ struct rte_pci_addr { > > struct rte_devargs; > > +enum rte_pt_driver { > + RTE_PT_UNKNOWN = 0, > + RTE_PT_IGB_UIO = 1, > + RTE_PT_VFIO = 2, > + RTE_PT_UIO_GENERIC = 3, > +}; What means PT? > + > /** > * A structure describing a PCI device. > */ > @@ -152,6 +159,7 @@ struct rte_pci_device { > uint16_t max_vfs; /**< sriov enable if not zero */ > int numa_node; /**< NUMA node connection */ > struct rte_devargs *devargs; /**< Device user arguments */ > + enum rte_pt_driver pt_driver; /**< Driver of passthrough */ I'm not sure passtrough is the right word for this kind of driver. What about "kernel driver"? > }; > > /** Any PCI device identifier (vendor, device, ...) */ > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c > index 15db9c4..e760452 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_pci.c > +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c > @@ -97,6 +97,35 @@ error: > return -1; > } > > +static int > +pci_get_kernel_driver_by_path(const char *filename, char *dri_name) > +{ > + int count; > + char path[PATH_MAX]; > + char *name; > + > + if (!filename || !dri_name) > + return -1; > + > + count = readlink(filename, path, PATH_MAX); > + if (count >= PATH_MAX) > + return -1; > + > + /* For device does not have a driver */ > + if (count < 0) > + return 1; > + > + path[count] = '\0'; > + > + name = strrchr(path, '/'); > + if (name) { > + strncpy(dri_name, name + 1, strlen(name + 1) + 1); > + return 0; > + } > + > + return -1; > +} > + > void * > pci_find_max_end_va(void) > { > @@ -222,11 +251,12 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, > char filename[PATH_MAX]; > unsigned long tmp; > struct rte_pci_device *dev; > + char driver[PATH_MAX]; > + int ret; > > dev = malloc(sizeof(*dev)); > - if (dev == NULL) { > + if (dev == NULL) > return -1; > - } > > memset(dev, 0, sizeof(*dev)); > dev->addr.domain = domain; > @@ -305,6 +335,25 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, > return -1; > } > > + /* parse driver */ > + snprintf(filename, sizeof(filename), "%s/driver", dirname); > + ret = pci_get_kernel_driver_by_path(filename, driver); > + if (!ret) { > + if (!strcmp(driver, "vfio-pci")) > + dev->pt_driver = RTE_PT_VFIO; > + else if (!strcmp(driver, "igb_uio")) > + dev->pt_driver = RTE_PT_IGB_UIO; > + else if (!strcmp(driver, "uio_pci_generic")) > + dev->pt_driver = RTE_PT_UIO_GENERIC; > + else > + dev->pt_driver = RTE_PT_UNKNOWN; > + } else if (ret < 0) { > + RTE_LOG(ERR, EAL, "Fail to get kernel driver\n"); > + free(dev); > + return -1; > + } else > + dev->pt_driver = RTE_PT_UNKNOWN; Why not considering a NONE value? Example: for virtio with port I/O. > + > /* device is valid, add in list (sorted) */ > if (TAILQ_EMPTY(&pci_device_list)) { > TAILQ_INSERT_TAIL(&pci_device_list, dev, next); >