eal/windows: fix IOVA mode detection and handling
authorDmitry Kozlyuk <dkozlyuk@nvidia.com>
Mon, 25 Oct 2021 12:20:52 +0000 (15:20 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 25 Oct 2021 18:59:40 +0000 (20:59 +0200)
commit0c8fc83a71f37107ad0b205b2a176fde9188390e
tree2beb8e2389adf806936792c497869a691f2363f2
parente6732d0d6e26e37e2e0c22050b350bdd7df34009
eal/windows: fix IOVA mode detection and handling

Windows EAL did not detect IOVA mode and worked incorrectly
if physical addresses could not be obtained
(if virt2phys driver was missing or inaccessible).
In this case, rte_mem_virt2iova() reported RTE_BAD_IOVA for any address.
Inability to obtain IOVA, be it PA or VA, should cause a failure
for the DPDK allocator, but it was hidden by the implementation,
so allocations did not fail when they should.
The mode when DPDK cannot obtain PA but can work is IOVA-as-VA mode.
However, rte_eal_iova_mode() always returned RTE_IOVA_DC
(while it should only ever return RTE_IOVA_PA or RTE_IOVA_VA),
because IOVA mode detection was not implemented.

Implement IOVA mode detection:
1. Always allow to force --iova-mode=va.
2. Allow to force --iova-mode=pa only if virt2phys is available.
3. If no mode is forced and virt2phys is available,
   select the mode according to bus requests, default to PA.
4. If no mode is forced but virt2phys is unavailable, default to VA.
Fix rte_mem_virt2iova() by returning VA when using IOVA-as-VA.
Fix rte_eal_iova_mode() by returning the selected mode.

Fixes: 2a5d547a4a9b ("eal/windows: implement basic memory management")
Cc: stable@dpdk.org
Reported-by: Tal Shnaiderman <talshn@nvidia.com>
Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Tested-by: Pallavi Kadam <pallavi.kadam@intel.com>
Acked-by: Pallavi Kadam <pallavi.kadam@intel.com>
lib/eal/windows/eal.c
lib/eal/windows/eal_memalloc.c
lib/eal/windows/eal_memory.c