From patchwork Tue Aug 14 14:30:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Boccassi X-Patchwork-Id: 43708 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 33E324CB3; Tue, 14 Aug 2018 16:30:51 +0200 (CEST) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id 73EA64C99 for ; Tue, 14 Aug 2018 16:30:50 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id l2-v6so10627196wme.1 for ; Tue, 14 Aug 2018 07:30:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8jA1rguQNQsWxOIHsHF/vAjDwGqJikL8hM7ycAKTsa4=; b=JwevxhoWeZmiiYGMdyvj6aWLvLDjz6mZ2h1j+lmawdcC5xBm1vARQGxeeEUSYnCIV0 pK+iA0jzPmFCxqmOBlBiIhlxLDuoKW/JsgnyRT3MH3HXHrAQKPRlrJ3d7DTeGYM4s9CF 1tRidScOytyfUF2cMceUTgUO1Ak1zHuqUI9RktrQAzRgWwQYh3N9iEfa8Mxs8WIrdB1H N6hMMita8kiW/Kce2UglEYX5neBBwrlahpLKn3gZZC7zvpYZe9rF8sTxFey/3D7H2MTH TtuOtpn+BEbNev88QekONRxBD75vxw/ldFxV63PbRtYtQBMpBXWUj8K97LxRKkdYLiR8 BVeA== X-Gm-Message-State: AOUpUlGNDx9CVUwpQSH2ix0bivdkY99oSWTOXybyIEHpbWf19gCWCJsl gw1VxdNIpUpCUPHqxI7dIOkT2Omw X-Google-Smtp-Source: AA+uWPwRRxP2YOXyJRHdCdX9SWecp8y0ZemMEjJkfgHOUmaNOCV3VsEgeLvcz0AeaJg9mB3Oe0DKyg== X-Received: by 2002:a1c:8291:: with SMTP id e139-v6mr11886623wmd.39.1534257049770; Tue, 14 Aug 2018 07:30:49 -0700 (PDT) Received: from localhost ([2001:1be0:110d:fcfe:41aa:5bfa:6cf3:7531]) by smtp.gmail.com with ESMTPSA id z141-v6sm13937088wmc.3.2018.08.14.07.30.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Aug 2018 07:30:48 -0700 (PDT) From: Luca Boccassi To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, zhihong.wang@intel.com, tiwei.bie@intel.com, bruce.richardson@intel.com, Luca Boccassi Date: Tue, 14 Aug 2018 15:30:34 +0100 Message-Id: <20180814143035.19640-1-bluca@debian.org> X-Mailer: git-send-email 2.18.0 Subject: [dpdk-dev] [PATCH 1/2] bus/pci: harmonize and document rte_pci_read_config return value X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- drivers/bus/pci/bsd/pci.c | 4 +++- drivers/bus/pci/rte_bus_pci.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c index 655b34b7e4..175d83cf1b 100644 --- a/drivers/bus/pci/bsd/pci.c +++ b/drivers/bus/pci/bsd/pci.c @@ -439,6 +439,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, @@ -469,7 +471,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 0d1955ffe0..df8f64798d 100644 --- a/drivers/bus/pci/rte_bus_pci.h +++ b/drivers/bus/pci/rte_bus_pci.h @@ -219,6 +219,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);