From: David Marchand <david.marchand@6wind.com>
To: Olivier Matz <olivier.matz@6wind.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
Chao Zhu <chaozhu@linux.vnet.ibm.com>,
Yuanhan Liu <yuanhan.liu@linux.intel.com>,
"Xie, Huawei" <huawei.xie@intel.com>
Subject: Re: [dpdk-dev] [PATCH v2 5/7] eal/linux: mmap ioports on ppc64
Date: Tue, 17 May 2016 17:54:01 +0200 [thread overview]
Message-ID: <CALwxeUsY7Khn27RhKpDzdMV4VC9OcidHA2hTxHXeX3yuNWiCNQ@mail.gmail.com> (raw)
In-Reply-To: <1463479192-2488-6-git-send-email-olivier.matz@6wind.com>
Hello Olivier,
On Tue, May 17, 2016 at 11:59 AM, Olivier Matz <olivier.matz@6wind.com> wrote:
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> index ac449c5..077ad96 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> @@ -411,81 +412,153 @@ pci_uio_ioport_map(struct rte_pci_device *dev, int bar,
> RTE_LOG(DEBUG, EAL, "PCI Port IO found start=0x%lx\n", start);
>
> p->base = start;
> + p->len = 0;
> return 0;
> +}
> #else
> - RTE_SET_USED(dev);
> - RTE_SET_USED(bar);
> - RTE_SET_USED(p);
> +int
> +pci_uio_ioport_map(struct rte_pci_device *dev, int bar,
> + struct rte_pci_ioport *p)
> +{
> + FILE *f;
> + char buf[BUFSIZ];
> + char filename[PATH_MAX];
> + uint64_t phys_addr, end_addr, flags;
> + int fd, i;
> + void *addr;
> +
> + /* open and read addresses of the corresponding resource in sysfs */
> + snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT "/resource",
> + SYSFS_PCI_DEVICES, dev->addr.domain, dev->addr.bus,
> + dev->addr.devid, dev->addr.function);
> + f = fopen(filename, "r");
> + if (f == NULL) {
> + RTE_LOG(ERR, EAL, "Cannot open sysfs resource: %s\n",
> + strerror(errno));
> + return -1;
> + }
> + for (i = 0; i < bar + 1; i++) {
> + if (fgets(buf, sizeof(buf), f) == NULL) {
> + RTE_LOG(ERR, EAL, "Cannot read sysfs resource\n");
> + goto error;
> + }
> + }
> + if (pci_parse_one_sysfs_resource(buf, sizeof(buf), &phys_addr,
> + &end_addr, &flags) < 0)
> + goto error;
> + if ((flags & IORESOURCE_IO) == 0) {
> + RTE_LOG(ERR, EAL, "BAR %d is not an IO resource\n", bar);
> + goto error;
> + }
> + snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT "/resource%d",
> + SYSFS_PCI_DEVICES, dev->addr.domain, dev->addr.bus,
> + dev->addr.devid, dev->addr.function, bar);
> +
> + /* mmap the pci resource */
> + fd = open(filename, O_RDWR);
> + if (fd < 0) {
> + RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", filename,
> + strerror(errno));
> + goto error;
> + }
> + addr = mmap(NULL, end_addr + 1, PROT_READ | PROT_WRITE,
> + MAP_SHARED, fd, 0);
Sorry, did not catch it in v1, but a close(fd) is missing here.
With this, I think the patchset looks good.
Just missing some opinion from the virtio maintainers ?
> + if (addr == MAP_FAILED) {
> + RTE_LOG(ERR, EAL, "Cannot mmap IO port resource: %s\n",
> + strerror(errno));
> + goto error;
> + }
> +
> + /* strangely, the base address is mmap addr + phys_addr */
> + p->base = (uintptr_t)addr + phys_addr;
> + p->len = end_addr + 1;
> + RTE_LOG(DEBUG, EAL, "PCI Port IO found start=0x%"PRIx64"\n", p->base);
> + fclose(f);
> +
> + return 0;
> +
> +error:
> + fclose(f);
> return -1;
> -#endif
> }
> +#endif
--
David Marchand
next prev parent reply other threads:[~2016-05-17 15:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-13 12:50 [dpdk-dev] [PATCH 0/7] virtio-net support " Olivier Matz
2016-05-13 12:50 ` [dpdk-dev] [PATCH 1/7] eal: fix typos in ioport API doxygen comments Olivier Matz
2016-05-13 12:50 ` [dpdk-dev] [PATCH 2/7] eal/linux: only call iopl on x86 Olivier Matz
2016-05-13 12:50 ` [dpdk-dev] [PATCH 3/7] eal/linux: remove invalid comment Olivier Matz
2016-05-13 12:50 ` [dpdk-dev] [PATCH 4/7] eal/linux: split function parsing pci resources in sysfs Olivier Matz
2016-05-13 12:50 ` [dpdk-dev] [PATCH 5/7] eal/linux: mmap ioports on ppc64 Olivier Matz
2016-05-13 14:33 ` David Marchand
2016-05-13 16:36 ` Olivier Matz
2016-05-13 12:50 ` [dpdk-dev] [PATCH 6/7] virtio: fix pci accesses for ppc64 in legacy mode Olivier Matz
2016-05-13 14:28 ` David Marchand
2016-05-13 16:34 ` Olivier Matz
2016-05-13 12:50 ` [dpdk-dev] [PATCH 7/7] config: enable virtio-net pmd for ppc64 Olivier Matz
2016-05-17 9:59 ` [dpdk-dev] [PATCH v2 0/7] virtio-net support on ppc64 Olivier Matz
2016-05-17 9:59 ` [dpdk-dev] [PATCH v2 1/7] eal: fix typos in ioport API doxygen comments Olivier Matz
2016-05-17 9:59 ` [dpdk-dev] [PATCH v2 2/7] eal/linux: only call iopl on x86 Olivier Matz
2016-05-17 9:59 ` [dpdk-dev] [PATCH v2 3/7] eal/linux: remove invalid comment Olivier Matz
2016-05-17 9:59 ` [dpdk-dev] [PATCH v2 4/7] eal/linux: split function parsing pci resources in sysfs Olivier Matz
2016-05-17 9:59 ` [dpdk-dev] [PATCH v2 5/7] eal/linux: mmap ioports on ppc64 Olivier Matz
2016-05-17 15:54 ` David Marchand [this message]
2016-05-18 11:17 ` Olivier Matz
2016-05-23 13:07 ` Yuanhan Liu
2016-05-23 13:40 ` Olivier Matz
2016-05-24 5:15 ` Yuanhan Liu
2016-05-30 8:45 ` Olivier Matz
2016-06-15 16:13 ` Thomas Monjalon
2016-05-17 9:59 ` [dpdk-dev] [PATCH v2 6/7] virtio: fix pci accesses for ppc64 in legacy mode Olivier Matz
2016-05-19 9:13 ` Chao Zhu
2016-05-20 12:11 ` Olivier Matz
2016-05-20 12:18 ` Olivier Matz
2016-05-24 6:28 ` Chao Zhu
2016-05-17 9:59 ` [dpdk-dev] [PATCH v2 7/7] config: enable virtio-net pmd for ppc64 Olivier Matz
2016-06-15 17:08 ` [dpdk-dev] [PATCH v2 0/7] virtio-net support on ppc64 Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALwxeUsY7Khn27RhKpDzdMV4VC9OcidHA2hTxHXeX3yuNWiCNQ@mail.gmail.com \
--to=david.marchand@6wind.com \
--cc=chaozhu@linux.vnet.ibm.com \
--cc=dev@dpdk.org \
--cc=huawei.xie@intel.com \
--cc=olivier.matz@6wind.com \
--cc=yuanhan.liu@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).