Commit f4ba7815 authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Jim Harris
Browse files

pci: fix config access return codes on BSD



BSD implementation for config access in DPDK seems to
return 0 on success while Linux implementation returns 0
only on failure. The env wrapper was always treating 0 as
an error and caused some of our PCI initialization code
to fail prematurely.

At one point DPDK harmonized this BSD behavior with Linux,
but only for config reads.

Fixes #484

Change-Id: I4ea850ea50f5e667fad28e8125209b21c377a2a3
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/432401


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent dadd2a6d
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -303,6 +303,11 @@ spdk_pci_device_cfg_read(struct spdk_pci_device *dev, void *value, uint32_t len,
#else
	rc = rte_eal_pci_read_config(dev, value, len, offset);
#endif

#if defined(__FreeBSD__) && RTE_VERSION < RTE_VERSION_NUM(18, 11, 0, 0)
	/* Older DPDKs return 0 on success and -1 on failure */
	return rc;
#endif
	return (rc > 0 && (uint32_t) rc == len) ? 0 : -1;
}

@@ -316,6 +321,11 @@ spdk_pci_device_cfg_write(struct spdk_pci_device *dev, void *value, uint32_t len
#else
	rc = rte_eal_pci_write_config(dev, value, len, offset);
#endif

#ifdef __FreeBSD__
	/* DPDK returns 0 on success and -1 on failure */
	return rc;
#endif
	return (rc > 0 && (uint32_t) rc == len) ? 0 : -1;
}