From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by dpdk.org (Postfix) with ESMTP id 9A5555A92 for ; Fri, 30 Jan 2015 00:14:54 +0100 (CET) Received: by mail-wi0-f173.google.com with SMTP id r20so33912537wiv.0 for ; Thu, 29 Jan 2015 15:14:54 -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=vJUqxhftyTe4Ar4clAA9VB6cxEexa5tRX4v0dncgyAU=; b=DbUtFJkvjx44k0Y7cb3WhTrjP6CEUk7ntDTFCG7VPoEQXvmGCT2o4nSAWMS+uSA9dp gkHt4P1j6symHlSEjOon5LWd/pUhVtJdex2wqAtJabboVsaTADslv8PNL4bfHknKkQh7 YEDMVqutL1YrX8Y5cfEQmUrTQ38Nr2oNCpg4pQmEDNs4H3P5D6+isiJLx7OCJzi/k+yl gmjUEe6coHA0itgdwk0WIsCAxxpuZRHE77N6CpC4Dn4P2veTkVjDO7HryWOZP6vshUeo 3AVYY5MdWE3p7NAcReIdylyAutukuCNKVZ/rI+5QQtUQjORzUeycLexgpqBnzLl1FTxY 0NYw== X-Gm-Message-State: ALoCoQl81j1c4X17E1/+lTtg9XoW9TwwIV7yzL4bRYrluh6oPvjTUA/sH9CkT8rwdDgoOeF/WDFM X-Received: by 10.180.37.77 with SMTP id w13mr4805929wij.66.1422573294428; Thu, 29 Jan 2015 15:14:54 -0800 (PST) Received: from xps13.localnet (136-92-190-109.dsl.ovh.fr. [109.190.92.136]) by mx.google.com with ESMTPSA id u18sm12344929wjq.42.2015.01.29.15.14.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jan 2015 15:14:53 -0800 (PST) From: Thomas Monjalon To: Ouyang Changchun Date: Fri, 30 Jan 2015 00:14:27 +0100 Message-ID: <2200098.eUytGrRrjF@xps13> Organization: 6WIND User-Agent: KMail/4.14.4 (Linux/3.18.4-1-ARCH; KDE/4.14.4; x86_64; ; ) In-Reply-To: <1422516249-14596-18-git-send-email-changchun.ouyang@intel.com> References: <1422326164-13697-1-git-send-email-changchun.ouyang@intel.com> <1422516249-14596-1-git-send-email-changchun.ouyang@intel.com> <1422516249-14596-18-git-send-email-changchun.ouyang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v3 17/25] virtio: Use port IO to get PCI resource. 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: Thu, 29 Jan 2015 23:14:54 -0000 Hi Changchun, 2015-01-29 15:24, Ouyang Changchun: > Make virtio not require UIO for some security reasons, this is to match 6Wind's virtio-net-pmd. Thanks for your effort. I think port IO is a really interesting option but it needs more EAL rework to be correctly integrated. Then virtio-net-pmd (http://dpdk.org/browse/virtio-net-pmd/) will be obsolete and moved in a deprecated area. > --- a/config/common_linuxapp > +++ b/config/common_linuxapp > +# Only for VIRTIO PMD currently > +CONFIG_RTE_EAL_PORT_IO=n This is the first problem. We must stop adding new build-time options. We should be able to choose between PCI mapping and port IO at runtime. > +/** Device needs port IO(done with /proc/ioports) */ > +#ifdef RTE_EAL_PORT_IO > +#define RTE_PCI_DRV_PORT_IO 0x0002 > +#endif A flag should never be ifdef'ed. > @@ -574,7 +574,10 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d > /* map resources for devices that use igb_uio */ > ret = pci_map_device(dev); > if (ret != 0) > - return ret; > +#ifdef RTE_EAL_PORT_IO > + if ((dr->drv_flags & RTE_PCI_DRV_PORT_IO) == 0) > +#endif > + return ret; > } else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND && > rte_eal_process_type() == RTE_PROC_PRIMARY) { > /* unbind current driver */ Why do you need this ugly return? > --- a/lib/librte_pmd_virtio/virtio_ethdev.c > +++ b/lib/librte_pmd_virtio/virtio_ethdev.c > @@ -961,6 +961,71 @@ static int virtio_resource_init(struct rte_pci_device *pci_dev) > start, size); > return 0; > } > + > +#ifdef RTE_EAL_PORT_IO > +/* Extract port I/O numbers from proc/ioports */ > +static int virtio_resource_init_by_portio(struct rte_pci_device *pci_dev) > +{ > + uint16_t start, end; > + int size; > + FILE *fp; > + char *line = NULL; > + char pci_id[16]; > + int found = 0; > + size_t linesz; > + > + snprintf(pci_id, sizeof(pci_id), PCI_PRI_FMT, > + pci_dev->addr.domain, > + pci_dev->addr.bus, > + pci_dev->addr.devid, > + pci_dev->addr.function); > + > + fp = fopen("/proc/ioports", "r"); > + if (fp == NULL) { > + PMD_INIT_LOG(ERR, "%s(): can't open ioports", __func__); > + return -1; > + } > + > + while (getdelim(&line, &linesz, '\n', fp) > 0) { > + char *ptr = line; > + char *left; > + int n; > + > + n = strcspn(ptr, ":"); > + ptr[n] = 0; > + left = &ptr[n+1]; > + > + while (*left && isspace(*left)) > + left++; > + > + if (!strncmp(left, pci_id, strlen(pci_id))) { > + found = 1; > + > + while (*ptr && isspace(*ptr)) > + ptr++; > + > + sscanf(ptr, "%04hx-%04hx", &start, &end); > + size = end - start + 1; > + > + break; > + } > + } > + > + free(line); > + fclose(fp); > + > + if (!found) > + return -1; > + > + pci_dev->mem_resource[0].addr = (void *)(uintptr_t)(uint32_t)start; > + pci_dev->mem_resource[0].len = (uint64_t)size; > + PMD_INIT_LOG(DEBUG, > + "PCI Port IO found start=0x%lx with size=0x%lx", > + start, size); > + return 0; > +} > +#endif This part should be a Linux EAL service. > +#ifdef RTE_EAL_PORT_IO > +static struct eth_driver rte_virtio_pmd = { > + { > + .name = "rte_virtio_pmd", > + .id_table = pci_id_virtio_map, > + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_PORT_IO | Why does it need PCI mapping in port IO mode? > + RTE_PCI_DRV_INTR_LSC, > + }, > + .eth_dev_init = eth_virtio_dev_init, > + .dev_private_size = sizeof(struct virtio_hw), > +}; > +#else > static struct eth_driver rte_virtio_pmd = { > { > .name = "rte_virtio_pmd", This is the biggest problem. You are defining port IO as a different driver instead of providing a way to choose the method for each virtio device. I think that you should use devargs to configure the pci device. Thanks -- Thomas