DPDK patches and discussions
 help / color / mirror / Atom feed
From: Haiyue Wang <haiyue.wang@intel.com>
To: dev@dpdk.org
Cc: qi.z.zhang@intel.com, liang-min.wang@intel.com,
	Haiyue Wang <haiyue.wang@intel.com>, Ray Kinsella <mdr@ashroe.eu>,
	Neil Horman <nhorman@tuxdriver.com>,
	Gaetan Rivet <grive@u256.net>
Subject: [dpdk-dev] [PATCH v1 1/3] bus/pci: enable PCI master in command register
Date: Wed, 21 Apr 2021 13:02:41 +0800	[thread overview]
Message-ID: <20210421050243.130585-2-haiyue.wang@intel.com> (raw)
In-Reply-To: <20210421050243.130585-1-haiyue.wang@intel.com>

This adds the support to set 'Bus Master Enable' bit in the PCI command
register.

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
---
 drivers/bus/pci/pci_common.c  | 20 ++++++++++++++++++++
 drivers/bus/pci/rte_bus_pci.h | 12 ++++++++++++
 drivers/bus/pci/version.map   |  1 +
 lib/librte_pci/rte_pci.h      |  4 ++++
 4 files changed, 37 insertions(+)

diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index ee7f966358..b631cb9c7e 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -746,6 +746,26 @@ rte_pci_find_ext_capability(struct rte_pci_device *dev, uint32_t cap)
 	return 0;
 }
 
+int
+rte_pci_enable_bus_master(struct rte_pci_device *dev)
+{
+	uint16_t cmd;
+
+	if (rte_pci_read_config(dev, &cmd, sizeof(cmd), RTE_PCI_COMMAND) < 0) {
+		RTE_LOG(ERR, EAL, "error in reading PCI command register\n");
+		return -1;
+	}
+
+	cmd |= RTE_PCI_COMMAND_MASTER;
+
+	if (rte_pci_write_config(dev, &cmd, sizeof(cmd), RTE_PCI_COMMAND) < 0) {
+		RTE_LOG(ERR, EAL, "error in writing PCI command register\n");
+		return -1;
+	}
+
+	return 0;
+}
+
 struct rte_pci_bus rte_pci_bus = {
 	.bus = {
 		.scan = rte_pci_scan,
diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h
index 64886b4731..83caf477ba 100644
--- a/drivers/bus/pci/rte_bus_pci.h
+++ b/drivers/bus/pci/rte_bus_pci.h
@@ -249,6 +249,18 @@ void rte_pci_dump(FILE *f);
 __rte_experimental
 off_t rte_pci_find_ext_capability(struct rte_pci_device *dev, uint32_t cap);
 
+/**
+ * Enables Bus Master for device's PCI command register.
+ *
+ *  @param dev
+ *    A pointer to rte_pci_device structure.
+ *
+ *  @return
+ *  0 on success, -1 on error in PCI config space read/write.
+ */
+__rte_experimental
+int rte_pci_enable_bus_master(struct rte_pci_device *dev);
+
 /**
  * Register a PCI driver.
  *
diff --git a/drivers/bus/pci/version.map b/drivers/bus/pci/version.map
index f33ed0abd1..b271e48a8f 100644
--- a/drivers/bus/pci/version.map
+++ b/drivers/bus/pci/version.map
@@ -20,5 +20,6 @@ DPDK_21 {
 EXPERIMENTAL {
 	global:
 
+	rte_pci_enable_bus_master;
 	rte_pci_find_ext_capability;
 };
diff --git a/lib/librte_pci/rte_pci.h b/lib/librte_pci/rte_pci.h
index a8f8e404a9..1f33d687f4 100644
--- a/lib/librte_pci/rte_pci.h
+++ b/lib/librte_pci/rte_pci.h
@@ -32,6 +32,10 @@ extern "C" {
 
 #define RTE_PCI_VENDOR_ID	0x00	/* 16 bits */
 #define RTE_PCI_DEVICE_ID	0x02	/* 16 bits */
+#define RTE_PCI_COMMAND		0x04	/* 16 bits */
+
+/* PCI Command Register */
+#define RTE_PCI_COMMAND_MASTER	0x4	/* Bus Master Enable */
 
 /* PCI Express capability registers */
 #define RTE_PCI_EXP_DEVCTL	8	/* Device Control */
-- 
2.31.1


  reply	other threads:[~2021-04-21  5:22 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-21  5:02 [dpdk-dev] [PATCH v1 0/3] Fix PF reset causes VF memory request failure Haiyue Wang
2021-04-21  5:02 ` Haiyue Wang [this message]
2021-04-21  5:02 ` [dpdk-dev] [PATCH v1 2/3] net/iavf: enable PCI bus master after reset Haiyue Wang
2021-04-21  5:02 ` [dpdk-dev] [PATCH v1 3/3] net/i40e: " Haiyue Wang
2021-04-21 11:59 ` [dpdk-dev] [PATCH v1 0/3] Fix PF reset causes VF memory request failure Zhang, Qi Z
2021-04-22  1:18 ` [dpdk-dev] [PATCH v2 0/3] fix " Haiyue Wang
2021-04-22  1:18   ` [dpdk-dev] [PATCH v2 1/3] bus/pci: enable PCI master in command register Haiyue Wang
2021-04-23 10:43     ` Kinsella, Ray
2021-04-23 12:07       ` Wang, Haiyue
2021-04-22  1:18   ` [dpdk-dev] [PATCH v2 2/3] net/iavf: enable PCI bus master after reset Haiyue Wang
2021-04-22  1:18   ` [dpdk-dev] [PATCH v2 3/3] net/i40e: " Haiyue Wang
2021-04-23 11:39 ` [dpdk-dev] [PATCH v3 0/3] fix PF reset causes VF memory request failure Haiyue Wang
2021-04-23 11:39   ` [dpdk-dev] [PATCH v3 1/3] bus/pci: enable PCI master in command register Haiyue Wang
2021-04-23 12:32     ` Kinsella, Ray
2021-04-27  9:28     ` David Marchand
2021-04-27 13:34       ` Wang, Haiyue
2021-04-27 13:40         ` David Marchand
2021-04-23 11:40   ` [dpdk-dev] [PATCH v3 2/3] net/iavf: enable PCI bus master after reset Haiyue Wang
2021-04-23 11:40   ` [dpdk-dev] [PATCH v3 3/3] net/i40e: " Haiyue Wang
2021-04-27 13:39 ` [dpdk-dev] [PATCH v4 0/3] fix PF reset causes VF memory request failure Haiyue Wang
2021-04-27 13:39   ` [dpdk-dev] [PATCH v4 1/3] bus/pci: set PCI master in command register Haiyue Wang
2021-04-27 15:07     ` Kinsella, Ray
2021-04-27 13:39   ` [dpdk-dev] [PATCH v4 2/3] net/iavf: enable PCI bus master after reset Haiyue Wang
2021-04-28  3:34     ` Zhang, Qi Z
2021-05-04 11:32     ` David Marchand
2021-05-04 15:07       ` Wang, Haiyue
2021-05-05  2:56       ` Wang, Haiyue
2021-05-05  8:39         ` David Marchand
2021-05-06  3:02           ` Wang, Haiyue
2021-04-27 13:39   ` [dpdk-dev] [PATCH v4 3/3] net/i40e: " Haiyue Wang
2021-04-28  3:35     ` Zhang, Qi Z
2021-05-06  3:49 ` [dpdk-dev] [PATCH v5 0/3] fix PF reset causes VF memory request failure Haiyue Wang
2021-05-06  3:49   ` [dpdk-dev] [PATCH v5 1/3] bus/pci: set PCI master in command register Haiyue Wang
2021-05-06  3:49   ` [dpdk-dev] [PATCH v5 2/3] net/iavf: enable PCI bus master after reset Haiyue Wang
2021-05-06  3:49   ` [dpdk-dev] [PATCH v5 3/3] net/i40e: " Haiyue Wang
2021-05-23 11:46 ` [dpdk-dev] [PATCH v6 0/3] fix PF reset causes VF memory request failure Haiyue Wang
2021-05-23 11:46   ` [dpdk-dev] [PATCH v6 1/3] bus/pci: set PCI master in command register Haiyue Wang
2021-05-23 11:46   ` [dpdk-dev] [PATCH v6 2/3] net/iavf: enable PCI bus master after reset Haiyue Wang
2021-05-23 11:46   ` [dpdk-dev] [PATCH v6 3/3] net/i40e: " Haiyue Wang
2021-05-24  1:23 ` [dpdk-dev] [PATCH v7 0/3] fix PF reset causes VF memory request failure Haiyue Wang
2021-05-24  1:23   ` [dpdk-dev] [PATCH v7 1/3] bus/pci: set PCI master in command register Haiyue Wang
2021-05-24  1:23   ` [dpdk-dev] [PATCH v7 2/3] net/iavf: enable PCI bus master after reset Haiyue Wang
2021-06-04  2:07     ` Xing, Beilei
2021-05-24  1:23   ` [dpdk-dev] [PATCH v7 3/3] net/i40e: " Haiyue Wang
2021-06-04  1:58     ` Xing, Beilei
2021-06-08  8:31   ` [dpdk-dev] [PATCH v7 0/3] fix PF reset causes VF memory request failure David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210421050243.130585-2-haiyue.wang@intel.com \
    --to=haiyue.wang@intel.com \
    --cc=dev@dpdk.org \
    --cc=grive@u256.net \
    --cc=liang-min.wang@intel.com \
    --cc=mdr@ashroe.eu \
    --cc=nhorman@tuxdriver.com \
    --cc=qi.z.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).