[dpdk-dev] [PATCH v2] pci: keep API compatibility with mmap values
Thomas Monjalon
thomas at monjalon.net
Sat Jul 11 11:51:31 CEST 2020
10/07/2020 23:07, Dmitry Kozlyuk:
> On Fri, 10 Jul 2020 22:40:34 +0200, Thomas Monjalon wrote:
> > The function pci_map_resource() returns MAP_FAILED in case of error.
> > When replacing the call to mmap() by rte_mem_map(),
> > the error code became NULL, breaking the API.
> > This function is probably not used outside of DPDK,
> > but it is still a problem for two reasons:
> > - the deprecation process was not followed
> > - the Linux function pci_vfio_mmap_bar() is broken for i40e
> >
> > The error code is reverted to the Unix value MAP_FAILED.
> > Windows needs to define this special value (-1 as in Unix).
> > After proper deprecation process, the API could be changed again
> > if really needed.
> >
> > Because of the switch from mmap() to rte_mem_map(),
> > another part of the API was changed: "int additional_flags"
> > are defined as "additional flags for the mapping range"
> > without mentioning it was directly used in mmap().
> > Currently it is directly used in rte_mem_map(),
> > that's why the values rte_map_flags must be mapped (sic) on the mmap ones
> > in case of Unix OS.
> >
> > These are side effects of a badly defined API using Unix values.
> >
> > Bugzilla ID: 503
> > Fixes: 2fd3567e5425 ("pci: use OS generic memory mapping functions")
> > Cc: talshn at mellanox.com
> >
> > Reported-by: David Marchand <david.marchand at redhat.com>
> > Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
> > ---
> > v2: move MAP_FAILED from sys/mman.h to rte_os.h
> > ---
> > drivers/bus/pci/bsd/pci.c | 2 +-
> > drivers/bus/pci/linux/pci_uio.c | 2 +-
> > drivers/bus/pci/linux/pci_vfio.c | 4 ++--
> > drivers/bus/pci/pci_common_uio.c | 2 +-
> > lib/librte_eal/include/rte_eal_paging.h | 10 ++++++++++
> > lib/librte_eal/windows/include/rte_os.h | 6 ++++++
> > lib/librte_pci/rte_pci.c | 1 +
> > lib/librte_pci/rte_pci.h | 2 +-
> > 8 files changed, 23 insertions(+), 6 deletions(-)
>
> Acked-by: Dmitry Kozlyuk <dmitry.kozliuk at gmail.com>
>
> No Intel NIC to test, but LGTM and compiles OK for Windows.
Tested-by: Lihong Ma <lihongx.ma at intel.com>
Applied
More information about the dev
mailing list