[dpdk-dev] [PATCH v6 2/9] pci: use OS generic memory mapping functions
Dmitry Kozlyuk
dmitry.kozliuk at gmail.com
Fri Jun 19 00:44:24 CEST 2020
[snip]
> @@ -154,14 +154,15 @@ pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size,
> void *mapaddr;
>
> /* Map the PCI memory resource of device */
> - mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,
> - MAP_SHARED | additional_flags, fd, offset);
> - if (mapaddr == MAP_FAILED) {
> + mapaddr = rte_mem_map(requested_addr, size,
> + RTE_PROT_READ | RTE_PROT_WRITE,
> + RTE_MAP_SHARED | additional_flags, fd, offset);
> + if (mapaddr == NULL) {
> RTE_LOG(ERR, EAL,
> - "%s(): cannot mmap(%d, %p, 0x%zx, 0x%llx): %s (%p)\n",
> + "%s(): cannot map resource(%d, %p, 0x%zx, 0x%llx): %s (%p)\n",
> __func__, fd, requested_addr, size,
> (unsigned long long)offset,
> - strerror(errno), mapaddr);
> + strerror(rte_errno), mapaddr);
rte_errno should use rte_strerror().
> } else
> RTE_LOG(DEBUG, EAL, " PCI memory mapped at %p\n", mapaddr);
>
> @@ -176,7 +177,7 @@ pci_unmap_resource(void *requested_addr, size_t size)
> return;
>
> /* Unmap the PCI memory resource of device */
> - if (munmap(requested_addr, size)) {
> + if (rte_mem_unmap(requested_addr, size)) {
> RTE_LOG(ERR, EAL, "%s(): cannot munmap(%p, %#zx): %s\n",
> __func__, requested_addr, size,
> strerror(errno));
errno should be rte_errno, strerror() should be rte_strerror().
Also the message mentions munmap().
--
Dmitry Kozlyuk
More information about the dev
mailing list