From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 967A8B682 for ; Tue, 17 Feb 2015 04:09:25 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 16 Feb 2015 19:09:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,591,1418112000"; d="scan'208";a="653044568" Received: from kmsmsx151.gar.corp.intel.com ([172.21.73.86]) by orsmga001.jf.intel.com with ESMTP; 16 Feb 2015 19:09:23 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by KMSMSX151.gar.corp.intel.com (172.21.73.86) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 17 Feb 2015 11:09:21 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.192]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.209]) with mapi id 14.03.0195.001; Tue, 17 Feb 2015 11:09:19 +0800 From: "Qiu, Michael" To: Thomas Monjalon , Tetsuya Mukawa Thread-Topic: [dpdk-dev] [PATCH v8 01/14] eal_pci: Add flag to hold kernel driver type Thread-Index: AQHQSZ8kPPxDvFsDFkasDbqH0nfIgg== Date: Tue, 17 Feb 2015 03:09:19 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286CEA640@SHSMSX101.ccr.corp.intel.com> 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> <1579136.8KQIkXORqn@xps13> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 03:09:26 -0000 On 2/17/2015 8:13 AM, Thomas Monjalon wrote:=0A= > 2015-02-16 13:14, Tetsuya Mukawa:=0A= >> From: Michael Qiu =0A= >>=0A= >> Currently, dpdk has no ability to know which type of driver(=0A= >> vfio-pci/igb_uio/uio_pci_generic) the device used. It only can=0A= >> check whether vfio is enabled or not staticly.=0A= >>=0A= >> It really useful to have the flag, becasue different type need to=0A= >> handle differently in runtime. For example, pci memory map,=0A= >> pot hotplug, and so on.=0A= >>=0A= >> This patch add a flag field for pci device to solve above issue.=0A= >>=0A= >> Signed-off-by: Michael Qiu =0A= >> Signed-off-by: Tetsuya Mukawa =0A= >> ---=0A= >> lib/librte_eal/common/include/rte_pci.h | 8 +++++=0A= >> lib/librte_eal/linuxapp/eal/eal_pci.c | 53 ++++++++++++++++++++++++++= +++++--=0A= >> 2 files changed, 59 insertions(+), 2 deletions(-)=0A= >>=0A= >> diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/co= mmon/include/rte_pci.h=0A= >> index 66ed793..7b48b55 100644=0A= >> --- a/lib/librte_eal/common/include/rte_pci.h=0A= >> +++ b/lib/librte_eal/common/include/rte_pci.h=0A= >> @@ -139,6 +139,13 @@ struct rte_pci_addr {=0A= >> =0A= >> struct rte_devargs;=0A= >> =0A= >> +enum rte_pt_driver {=0A= >> + RTE_PT_UNKNOWN =3D 0,=0A= >> + RTE_PT_IGB_UIO =3D 1,=0A= >> + RTE_PT_VFIO =3D 2,=0A= >> + RTE_PT_UIO_GENERIC =3D 3,=0A= >> +};=0A= > What means PT?=0A= >=0A= >> +=0A= >> /**=0A= >> * A structure describing a PCI device.=0A= >> */=0A= >> @@ -152,6 +159,7 @@ struct rte_pci_device {=0A= >> uint16_t max_vfs; /**< sriov enable if not zero = */=0A= >> int numa_node; /**< NUMA node connection */= =0A= >> struct rte_devargs *devargs; /**< Device user arguments */= =0A= >> + enum rte_pt_driver pt_driver; /**< Driver of passthrough */=0A= > I'm not sure passtrough is the right word for this kind of driver.=0A= > What about "kernel driver"?=0A= =0A= We only care vfio and uio driver, here pass through means pass the=0A= devices from kernel to userspace=0A= =0A= If use "kernel driver"or "kn_driver", there will be some issue that we=0A= set to "UNKNOWN" when the devices use the native linux kernel driver.=0A= =0A= =0A= >=0A= >> };=0A= >> =0A= >> /** Any PCI device identifier (vendor, device, ...) */=0A= >> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linu= xapp/eal/eal_pci.c=0A= >> index 15db9c4..e760452 100644=0A= >> --- a/lib/librte_eal/linuxapp/eal/eal_pci.c=0A= >> +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c=0A= >> @@ -97,6 +97,35 @@ error:=0A= >> return -1;=0A= >> }=0A= >> =0A= >> +static int=0A= >> +pci_get_kernel_driver_by_path(const char *filename, char *dri_name)=0A= >> +{=0A= >> + int count;=0A= >> + char path[PATH_MAX];=0A= >> + char *name;=0A= >> +=0A= >> + if (!filename || !dri_name)=0A= >> + return -1;=0A= >> +=0A= >> + count =3D readlink(filename, path, PATH_MAX);=0A= >> + if (count >=3D PATH_MAX)=0A= >> + return -1;=0A= >> +=0A= >> + /* For device does not have a driver */=0A= >> + if (count < 0)=0A= >> + return 1;=0A= >> +=0A= >> + path[count] =3D '\0';=0A= >> +=0A= >> + name =3D strrchr(path, '/');=0A= >> + if (name) {=0A= >> + strncpy(dri_name, name + 1, strlen(name + 1) + 1);=0A= >> + return 0;=0A= >> + }=0A= >> +=0A= >> + return -1;=0A= >> +}=0A= >> +=0A= >> void *=0A= >> pci_find_max_end_va(void)=0A= >> {=0A= >> @@ -222,11 +251,12 @@ pci_scan_one(const char *dirname, uint16_t domain,= uint8_t bus,=0A= >> char filename[PATH_MAX];=0A= >> unsigned long tmp;=0A= >> struct rte_pci_device *dev;=0A= >> + char driver[PATH_MAX];=0A= >> + int ret;=0A= >> =0A= >> dev =3D malloc(sizeof(*dev));=0A= >> - if (dev =3D=3D NULL) {=0A= >> + if (dev =3D=3D NULL)=0A= >> return -1;=0A= >> - }=0A= >> =0A= >> memset(dev, 0, sizeof(*dev));=0A= >> dev->addr.domain =3D domain;=0A= >> @@ -305,6 +335,25 @@ pci_scan_one(const char *dirname, uint16_t domain, = uint8_t bus,=0A= >> return -1;=0A= >> }=0A= >> =0A= >> + /* parse driver */=0A= >> + snprintf(filename, sizeof(filename), "%s/driver", dirname);=0A= >> + ret =3D pci_get_kernel_driver_by_path(filename, driver);=0A= >> + if (!ret) {=0A= >> + if (!strcmp(driver, "vfio-pci"))=0A= >> + dev->pt_driver =3D RTE_PT_VFIO;=0A= >> + else if (!strcmp(driver, "igb_uio"))=0A= >> + dev->pt_driver =3D RTE_PT_IGB_UIO;=0A= >> + else if (!strcmp(driver, "uio_pci_generic"))=0A= >> + dev->pt_driver =3D RTE_PT_UIO_GENERIC;=0A= >> + else=0A= >> + dev->pt_driver =3D RTE_PT_UNKNOWN;=0A= >> + } else if (ret < 0) {=0A= >> + RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");=0A= >> + free(dev);=0A= >> + return -1;=0A= >> + } else=0A= >> + dev->pt_driver =3D RTE_PT_UNKNOWN;=0A= > Why not considering a NONE value? Example: for virtio with port I/O.=0A= =0A= Why NONE? Do you mean, leave it unset? RTE_PT_UNKNOWN equals to zero,=0A= when code runs here means the devices does not have a driver or not bind=0A= to any driver.=0A= =0A= For virtio with port I/O, as I know it will use the kernel driver=0A= virtio-pci. So it will not run here.=0A= =0A= Thanks,=0A= Michael=0A= >=0A= >> +=0A= >> /* device is valid, add in list (sorted) */=0A= >> if (TAILQ_EMPTY(&pci_device_list)) {=0A= >> TAILQ_INSERT_TAIL(&pci_device_list, dev, next);=0A= >>=0A= >=0A= >=0A= =0A=