env_dpdk: dont treat NULL as error in spdk_map_bar_rte()

We use `spdk_map_bar_rte()` to read mapped addresses
from PCI BARs.
This function is currently checking for NULL in each pair.
But in PCI memory, some registers can be left unused,
in which case they are set to 0.
As a result, we may read some NULL pointers from BARs,
which is OK.
To check if given address is indeed invalid, we should first
check if it is used.
So it is best to delegate such checks to the
user of this function.
In fact, users already do the NULL check where it is needed
(ex: virtio_pci.c:390, nvme_pcie.c:589)
so this patch just removes them from `spdk_map_bar_rte()`.

This solves github issue #1206

Change-Id: I88021ceca1b9e9d503b224f790819999cd16da01
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1129
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Vitaliy Mysak 2020-03-04 10:56:42 +01:00 committed by Tomasz Zawadzki
parent 9d93c08234
commit d4653a31e0

View File

@ -62,15 +62,7 @@ spdk_map_bar_rte(struct spdk_pci_device *device, uint32_t bar,
struct rte_pci_device *dev = device->dev_handle;
*mapped_addr = dev->mem_resource[bar].addr;
if (*mapped_addr == NULL) {
return -1;
}
*phys_addr = (uint64_t)dev->mem_resource[bar].phys_addr;
if (*phys_addr == 0) {
return -1;
}
*size = (uint64_t)dev->mem_resource[bar].len;
return 0;