summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2018-08-28 11:12:39 +0100
committerThomas Monjalon <thomas@monjalon.net>2018-10-29 00:32:14 +0100
commite8d435f1f3a16b02011f604581c80d09fea3a44f (patch)
tree62ec39f87c38ec4dc7a93f9bcaee0946dcea6b4a
parent075b182b54ce90e0a22810e67cf3204e22673bac (diff)
downloaddpdk-e8d435f1f3a16b02011f604581c80d09fea3a44f.zip
dpdk-e8d435f1f3a16b02011f604581c80d09fea3a44f.tar.gz
dpdk-e8d435f1f3a16b02011f604581c80d09fea3a44f.tar.xz
bus/pci: harmonize return value of config read
On Linux, rte_pci_read_config on success returns the number of read bytes, but on BSD it returns 0. Document the return values, and have BSD behave as Linux does. At least one case (bnx2x PMD) treats 0 as an error, so the change makes sense also for that. Signed-off-by: Luca Boccassi <bluca@debian.org> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
-rw-r--r--drivers/bus/pci/bsd/pci.c4
-rw-r--r--drivers/bus/pci/rte_bus_pci.h2
2 files changed, 5 insertions, 1 deletions
diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c
index 40641ca..d09f8ee 100644
--- a/drivers/bus/pci/bsd/pci.c
+++ b/drivers/bus/pci/bsd/pci.c
@@ -441,6 +441,8 @@ int rte_pci_read_config(const struct rte_pci_device *dev,
{
int fd = -1;
int size;
+ /* Copy Linux implementation's behaviour */
+ const int return_len = len;
struct pci_io pi = {
.pi_sel = {
.pc_domain = dev->addr.domain,
@@ -471,7 +473,7 @@ int rte_pci_read_config(const struct rte_pci_device *dev,
}
close(fd);
- return 0;
+ return return_len;
error:
if (fd >= 0)
diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h
index 8252fa6..f0d6d81 100644
--- a/drivers/bus/pci/rte_bus_pci.h
+++ b/drivers/bus/pci/rte_bus_pci.h
@@ -223,6 +223,8 @@ void rte_pci_unregister(struct rte_pci_driver *driver);
* The length of the data buffer.
* @param offset
* The offset into PCI config space
+ * @return
+ * Number of bytes read on success, negative on error.
*/
int rte_pci_read_config(const struct rte_pci_device *device,
void *buf, size_t len, off_t offset);