From 6bf1af641fe44da72f6bbe30217c8d08a7309792 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Thu, 8 Nov 2018 11:56:55 +0100 Subject: [PATCH] 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: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/432401 (master) Reviewed-on: https://review.gerrithub.io/435682 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/env_dpdk/pci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/env_dpdk/pci.c b/lib/env_dpdk/pci.c index 4153ac93e..4d63d2bcd 100644 --- a/lib/env_dpdk/pci.c +++ b/lib/env_dpdk/pci.c @@ -299,6 +299,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; } @@ -312,6 +317,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; }