DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jan Blunck <jblunck@infradead.org>
To: dev@dpdk.org
Cc: shreyansh.jain@nxp.com, david.marchand@6wind.com,
	stephen@networkplumber.org
Subject: [dpdk-dev] [PATCH v3 9/9] ethdev: Decouple struct rte_eth_dev from struct rte_pci_device
Date: Tue, 20 Dec 2016 12:11:55 +0100	[thread overview]
Message-ID: <1482232315-21626-10-git-send-email-jblunck@infradead.org> (raw)
In-Reply-To: <1482232315-21626-1-git-send-email-jblunck@infradead.org>

Signed-off-by: Jan Blunck <jblunck@infradead.org>
---
 app/test/virtual_pmd.c                  |  4 ++--
 drivers/net/bonding/rte_eth_bond_args.c | 12 ++++++++++--
 drivers/net/cxgbe/cxgbe_main.c          |  4 ++--
 drivers/net/fm10k/fm10k_ethdev.c        |  6 +++---
 drivers/net/virtio/virtio_user_ethdev.c |  1 -
 lib/librte_eal/common/include/rte_pci.h |  6 ++++++
 lib/librte_ether/rte_ethdev.c           |  6 +++---
 lib/librte_ether/rte_ethdev.h           |  4 ++--
 8 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 65b44c6..bd30b14 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -625,8 +625,8 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 	dev_private->dev_ops = virtual_ethdev_default_dev_ops;
 	eth_dev->dev_ops = &dev_private->dev_ops;
 
-	eth_dev->pci_dev = pci_dev;
-	eth_dev->pci_dev->device.driver = &eth_drv->pci_drv.driver;
+	pci_dev->device.driver = &eth_drv->pci_drv.driver;
+	eth_dev->device = &pci_dev->device;
 
 	eth_dev->rx_pkt_burst = virtual_ethdev_rx_burst_success;
 	eth_dev->tx_pkt_burst = virtual_ethdev_tx_burst_success;
diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index 02ecde6..29436ea 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -54,15 +54,23 @@ const char *pmd_bond_init_valid_arguments[] = {
 static inline int
 find_port_id_by_pci_addr(const struct rte_pci_addr *pci_addr)
 {
+	struct rte_pci_device *pci_dev;
 	struct rte_pci_addr *eth_pci_addr;
 	unsigned i;
 
 	for (i = 0; i < rte_eth_dev_count(); i++) {
 
-		if (rte_eth_devices[i].pci_dev == NULL)
+		/* Currently populated by rte_eth_copy_pci_info().
+		 *
+		 * TODO: Once the PCI bus has arrived we should have a better
+		 * way to test for being a PCI device or not.
+		 */
+		if (rte_eth_devices[i].data->kdrv == RTE_KDRV_UNKNOWN ||
+		    rte_eth_devices[i].data->kdrv == RTE_KDRV_NONE)
 			continue;
 
-		eth_pci_addr = &(rte_eth_devices[i].pci_dev->addr);
+		pci_dev = ETH_DEV_PCI_DEV(&rte_eth_devices[i]);
+		eth_pci_addr = &pci_dev->addr;
 
 		if (pci_addr->bus == eth_pci_addr->bus &&
 			pci_addr->devid == eth_pci_addr->devid &&
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index 922155b..ea13c7e 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -1163,14 +1163,14 @@ int cxgbe_probe(struct adapter *adapter)
 		pi->eth_dev->data = data;
 
 allocate_mac:
-		pi->eth_dev->pci_dev = adapter->pdev;
+		pi->eth_dev->device = &adapter->pdev->device;
 		pi->eth_dev->data->dev_private = pi;
 		pi->eth_dev->driver = adapter->eth_dev->driver;
 		pi->eth_dev->dev_ops = adapter->eth_dev->dev_ops;
 		pi->eth_dev->tx_pkt_burst = adapter->eth_dev->tx_pkt_burst;
 		pi->eth_dev->rx_pkt_burst = adapter->eth_dev->rx_pkt_burst;
 
-		rte_eth_copy_pci_info(pi->eth_dev, pi->eth_dev->pci_dev);
+		rte_eth_copy_pci_info(pi->eth_dev, adapter->pdev);
 
 		TAILQ_INIT(&pi->eth_dev->link_intr_cbs);
 
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 5d0bce5..5718b39 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -678,7 +678,7 @@ fm10k_dev_tx_init(struct rte_eth_dev *dev)
 		/* Enable use of FTAG bit in TX descriptor, PFVTCTL
 		 * register is read-only for VF.
 		 */
-		if (fm10k_check_ftag(dev->pci_dev->device.devargs)) {
+		if (fm10k_check_ftag(dev->device->devargs)) {
 			if (hw->mac.type == fm10k_mac_pf) {
 				FM10K_WRITE_REG(hw, FM10K_PFVTCTL(i),
 						FM10K_PFVTCTL_FTAG_DESC_ENABLE);
@@ -2740,7 +2740,7 @@ fm10k_set_tx_function(struct rte_eth_dev *dev)
 	int use_sse = 1;
 	uint16_t tx_ftag_en = 0;
 
-	if (fm10k_check_ftag(dev->pci_dev->device.devargs))
+	if (fm10k_check_ftag(dev->device->devargs))
 		tx_ftag_en = 1;
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
@@ -2771,7 +2771,7 @@ fm10k_set_rx_function(struct rte_eth_dev *dev)
 	uint16_t i, rx_using_sse;
 	uint16_t rx_ftag_en = 0;
 
-	if (fm10k_check_ftag(dev->pci_dev->device.devargs))
+	if (fm10k_check_ftag(dev->device->devargs))
 		rx_ftag_en = 1;
 
 	/* In order to allow Vector Rx there are a few configuration
diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 406beea..8cb983c 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -310,7 +310,6 @@ virtio_user_eth_dev_alloc(const char *name)
 	data->numa_node = SOCKET_ID_ANY;
 	data->kdrv = RTE_KDRV_NONE;
 	data->dev_flags = RTE_ETH_DEV_DETACHABLE;
-	eth_dev->pci_dev = NULL;
 	eth_dev->driver = NULL;
 	return eth_dev;
 }
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 9ce8847..19deaf6 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -160,6 +160,12 @@ struct rte_pci_device {
 	enum rte_kernel_driver kdrv;            /**< Kernel driver passthrough */
 };
 
+/**
+ * @internal
+ * Helper macro for drivers that need to convert to struct rte_pci_device.
+ */
+#define DEV_PCI_DEV(ptr) container_of(ptr, struct rte_pci_device, device)
+
 /** Any PCI device identifier (vendor, device, ...) */
 #define PCI_ANY_ID (0xffff)
 #define RTE_CLASS_ANY_ID (0xffffff)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 4ecea50..cc01672 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -257,7 +257,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
 		if (eth_dev->data->dev_private == NULL)
 			rte_panic("Cannot allocate memzone for private port data\n");
 	}
-	eth_dev->pci_dev = pci_dev;
+	eth_dev->device = &pci_dev->device;
 	eth_dev->intr_handle = &pci_dev->intr_handle;
 	eth_dev->driver = eth_drv;
 	eth_dev->data->rx_mbuf_alloc_failed = 0;
@@ -318,7 +318,7 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 		rte_free(eth_dev->data->dev_private);
 
-	eth_dev->pci_dev = NULL;
+	eth_dev->device = NULL;
 	eth_dev->driver = NULL;
 	eth_dev->data = NULL;
 
@@ -2578,7 +2578,7 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
 	const struct rte_memzone *mz;
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 dev->driver->pci_drv.driver.name, ring_name,
+		 dev->data->drv_name, ring_name,
 		 dev->data->port_id, queue_id);
 
 	mz = rte_memzone_lookup(z_name);
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index f1f656a..58ef798 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1628,7 +1628,7 @@ struct rte_eth_dev {
 	struct rte_eth_dev_data *data;  /**< Pointer to device data */
 	const struct eth_driver *driver;/**< Driver for this device */
 	const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
-	struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */
+	struct rte_device *device; /**< Backing device for this device */
 	struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
 	/** User application callbacks for NIC interrupts */
 	struct rte_eth_dev_cb_list link_intr_cbs;
@@ -1649,7 +1649,7 @@ struct rte_eth_dev {
  * @internal
  * Helper for drivers that need to convert from rte_eth_dev to rte_pci_device.
  */
-#define ETH_DEV_PCI_DEV(ptr) ((ptr)->pci_dev)
+#define ETH_DEV_PCI_DEV(ptr) DEV_PCI_DEV((ptr)->device)
 
 struct rte_eth_dev_sriov {
 	uint8_t active;               /**< SRIOV is active with 16, 32 or 64 pools */
-- 
2.7.4

  parent reply	other threads:[~2016-12-20 11:12 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-20 11:11 [dpdk-dev] [PATCH v3 0/9] Decouple ethdev from PCI device Jan Blunck
2016-12-20 11:11 ` [dpdk-dev] [PATCH v3 1/9] eal: define container_of macro Jan Blunck
2016-12-20 11:11 ` [dpdk-dev] [PATCH v3 2/9] ethdev: Helper to convert to struct rte_pci_device Jan Blunck
2016-12-20 15:38   ` Stephen Hemminger
2016-12-20 11:11 ` [dpdk-dev] [PATCH v3 3/9] drivers: Use ETH_DEV_PCI_DEV() helper Jan Blunck
2016-12-21  9:50   ` Shreyansh Jain
2016-12-21  9:57     ` Shreyansh Jain
2016-12-20 11:11 ` [dpdk-dev] [PATCH v3 4/9] virtio: Don't fill dev_info->driver_name Jan Blunck
2016-12-20 12:17   ` Ferruh Yigit
2016-12-20 12:40     ` Jan Blunck
2016-12-20 12:58       ` Ferruh Yigit
2016-12-20 11:11 ` [dpdk-dev] [PATCH v3 5/9] virtio: Add vtpci_intr_handle() helper to get rte_intr_handle Jan Blunck
2016-12-20 11:11 ` [dpdk-dev] [PATCH v3 6/9] virtio: Don't depend on struct rte_eth_dev's pci_dev Jan Blunck
2016-12-20 11:11 ` [dpdk-dev] [PATCH v3 7/9] ethdev: Move filling of rte_eth_dev_info->pci_dev to dev_infos_get() Jan Blunck
2016-12-20 15:41   ` Stephen Hemminger
2016-12-21 15:35     ` Jan Blunck
2016-12-21  9:54   ` Shreyansh Jain
2016-12-20 11:11 ` [dpdk-dev] [PATCH v3 8/9] ethdev: Decouple interrupt handling from PCI device Jan Blunck
2016-12-20 11:11 ` Jan Blunck [this message]
2016-12-21 10:00 ` [dpdk-dev] [PATCH v3 0/9] Decouple ethdev " Shreyansh Jain
2016-12-21 15:12   ` Jan Blunck

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=1482232315-21626-10-git-send-email-jblunck@infradead.org \
    --to=jblunck@infradead.org \
    --cc=david.marchand@6wind.com \
    --cc=dev@dpdk.org \
    --cc=shreyansh.jain@nxp.com \
    --cc=stephen@networkplumber.org \
    /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).