DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] ethdev: remove driver name from device private data
@ 2017-05-26 11:15 Ferruh Yigit
  2017-06-06 15:10 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
  0 siblings, 1 reply; 24+ messages in thread
From: Ferruh Yigit @ 2017-05-26 11:15 UTC (permalink / raw)
  To: Declan Doherty, Rahul Lakkireddy, Hemant Agrawal, Shreyansh Jain,
	Helin Zhang, Jingjing Wu, Wenzhuo Lu, Konstantin Ananyev,
	Bruce Richardson, Pascal Mazon, Shrikrishna Khare, Jianfeng Tan,
	Thomas Monjalon
  Cc: dev, Ferruh Yigit, Gaetan Rivet, Jan Blunck

rte_driver->name has the driver name and all physical and virtual
devices has access to it.

Previously it was not possible for virtual ethernet devices to access
rte_driver->name field (because eth_dev used to keep only pci_dev),
and it was required to save driver name in the device private struct.

After re-works on bus and vdev, it is possible for all bus types to
access rte_driver.

It is able to remove the driver name from ethdev device private data and
use eth_dev->device->driver->name.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
Cc: Jan Blunck <jblunck@infradead.org>
---
 drivers/net/bonding/rte_eth_bond_api.c | 4 ++--
 drivers/net/cxgbe/sge.c                | 6 +++---
 drivers/net/dpaa2/dpaa2_ethdev.c       | 1 -
 drivers/net/i40e/i40e_ethdev.c         | 3 +--
 drivers/net/i40e/i40e_fdir.c           | 2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c       | 2 +-
 drivers/net/ring/rte_eth_ring.c        | 1 -
 drivers/net/tap/rte_eth_tap.c          | 1 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c   | 2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c  | 1 -
 lib/librte_ether/rte_ethdev.c          | 8 ++++----
 lib/librte_ether/rte_ethdev.h          | 1 -
 lib/librte_ether/rte_ethdev_pci.h      | 1 -
 lib/librte_ether/rte_ethdev_vdev.h     | 1 -
 14 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 36ec65d..164eb59 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -48,11 +48,11 @@ int
 check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev)
 {
 	/* Check valid pointer */
-	if (eth_dev->data->drv_name == NULL)
+	if (eth_dev->device->driver->name == NULL)
 		return -1;
 
 	/* return 0 if driver name matches */
-	return eth_dev->data->drv_name != pmd_bond_drv.driver.name;
+	return eth_dev->device->driver->name != pmd_bond_drv.driver.name;
 }
 
 int
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 2f9e12c..84ed42a 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -1641,7 +1641,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 	iq->size = cxgbe_roundup(iq->size, 16);
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 eth_dev->data->drv_name,
+		 eth_dev->device->driver->name,
 		 fwevtq ? "fwq_ring" : "rx_ring",
 		 eth_dev->data->port_id, queue_id);
 	snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
@@ -1694,7 +1694,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 		fl->size = cxgbe_roundup(fl->size, 8);
 
 		snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-			 eth_dev->data->drv_name,
+			 eth_dev->device->driver->name,
 			 fwevtq ? "fwq_ring" : "fl_ring",
 			 eth_dev->data->port_id, queue_id);
 		snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
@@ -1890,7 +1890,7 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
 	nentries = txq->q.size + s->stat_len / sizeof(struct tx_desc);
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 eth_dev->data->drv_name, "tx_ring",
+		 eth_dev->device->driver->name, "tx_ring",
 		 eth_dev->data->port_id, queue_id);
 	snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
 
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 4de1e0c..da309ac 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1464,7 +1464,6 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	eth_dev->dev_ops = &dpaa2_ethdev_ops;
-	eth_dev->data->drv_name = rte_dpaa2_pmd.driver.name;
 
 	eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx;
 	eth_dev->tx_pkt_burst = dpaa2_dev_tx;
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index d57a7af..0ac85f0 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -10714,8 +10714,7 @@ i40e_filter_restore(struct i40e_pf *pf)
 static bool
 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
 {
-	if (strcmp(dev->data->drv_name,
-		   drv->driver.name))
+	if (strcmp(dev->device->driver->name, drv->driver.name))
 		return false;
 
 	return true;
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index 9c1ab6e..77c23e0 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -256,7 +256,7 @@ i40e_fdir_setup(struct i40e_pf *pf)
 
 	/* reserve memory for the fdir programming packet */
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d",
-			eth_dev->data->drv_name,
+			eth_dev->device->driver->name,
 			I40E_FDIR_MZ_NAME,
 			eth_dev->data->port_id);
 	mz = i40e_memzone_reserve(z_name, I40E_FDIR_PKT_LEN, SOCKET_ID_ANY);
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index e674586..026178b 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4670,7 +4670,7 @@ ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
 static bool
 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
 {
-	if (strcmp(dev->data->drv_name, drv->driver.name))
+	if (strcmp(dev->device->driver->name, drv->driver.name))
 		return false;
 
 	return true;
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 87d2258..81bc120 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -342,7 +342,6 @@ do_eth_dev_ring_create(const char *name,
 	eth_dev->dev_ops = &ops;
 	data->dev_flags = RTE_ETH_DEV_DETACHABLE;
 	data->kdrv = RTE_KDRV_NONE;
-	data->drv_name = pmd_ring_drv.driver.name;
 	data->numa_node = numa_node;
 
 	/* finally assign rx and tx ops */
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 1bb660e..305f018 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -1220,7 +1220,6 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
 	data->dev_private = pmd;
 	data->dev_flags = RTE_ETH_DEV_DETACHABLE | RTE_ETH_DEV_INTR_LSC;
 	data->numa_node = numa_node;
-	data->drv_name = pmd_tap_drv.driver.name;
 
 	data->dev_link = pmd_link;
 	data->mac_addrs = &pmd->eth_addr;
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index 17b471f..5b7c8ab 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -141,7 +141,7 @@ gpa_zone_reserve(struct rte_eth_dev *dev, uint32_t size,
 	const struct rte_memzone *mz;
 
 	snprintf(z_name, sizeof(z_name), "%s_%d_%s",
-		 dev->data->drv_name, dev->data->port_id, post_string);
+		 dev->device->driver->name, dev->data->port_id, post_string);
 
 	mz = rte_memzone_lookup(z_name);
 	if (!reuse) {
diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c
index 7bd29fa..e404b77 100644
--- a/drivers/net/xenvirt/rte_eth_xenvirt.c
+++ b/drivers/net/xenvirt/rte_eth_xenvirt.c
@@ -672,7 +672,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 
 	eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
 	eth_dev->data->kdrv = RTE_KDRV_NONE;
-	eth_dev->data->drv_name = pmd_xenvirt_drv.driver.name;
 	eth_dev->data->numa_node = numa_node;
 
 	eth_dev->rx_pkt_burst = eth_xenvirt_rx;
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 83898a8..258b4d9 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -753,13 +753,13 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	if ((dev_conf->intr_conf.lsc == 1) &&
 		(!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
 			RTE_PMD_DEBUG_TRACE("driver %s does not support lsc\n",
-					dev->data->drv_name);
+					dev->device->driver->name);
 			return -EINVAL;
 	}
 	if ((dev_conf->intr_conf.rmv == 1) &&
 	    (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_RMV))) {
 		RTE_PMD_DEBUG_TRACE("driver %s does not support rmv\n",
-				    dev->data->drv_name);
+				    dev->device->driver->name);
 		return -EINVAL;
 	}
 
@@ -1900,7 +1900,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 
 	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
 	(*dev->dev_ops->dev_infos_get)(dev, dev_info);
-	dev_info->driver_name = dev->data->drv_name;
+	dev_info->driver_name = dev->device->driver->name;
 	dev_info->nb_rx_queues = dev->data->nb_rx_queues;
 	dev_info->nb_tx_queues = dev->data->nb_tx_queues;
 }
@@ -2789,7 +2789,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->data->drv_name, ring_name,
+		 dev->device->driver->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 f23d116..97c3b8e 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1739,7 +1739,6 @@ struct rte_eth_dev_data {
 	uint32_t dev_flags; /**< Capabilities */
 	enum rte_kernel_driver kdrv;    /**< Kernel driver passthrough */
 	int numa_node;  /**< NUMA node connection */
-	const char *drv_name;   /**< Driver name */
 };
 
 /** Device supports hotplug detach */
diff --git a/lib/librte_ether/rte_ethdev_pci.h b/lib/librte_ether/rte_ethdev_pci.h
index d3bc03c..69aab03 100644
--- a/lib/librte_ether/rte_ethdev_pci.h
+++ b/lib/librte_ether/rte_ethdev_pci.h
@@ -69,7 +69,6 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev,
 
 	eth_dev->data->kdrv = pci_dev->kdrv;
 	eth_dev->data->numa_node = pci_dev->device.numa_node;
-	eth_dev->data->drv_name = pci_dev->driver->driver.name;
 }
 
 /**
diff --git a/lib/librte_ether/rte_ethdev_vdev.h b/lib/librte_ether/rte_ethdev_vdev.h
index fa2cb61..4d2c3e2 100644
--- a/lib/librte_ether/rte_ethdev_vdev.h
+++ b/lib/librte_ether/rte_ethdev_vdev.h
@@ -77,7 +77,6 @@ rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
 
 	eth_dev->data->kdrv = RTE_KDRV_NONE;
 	eth_dev->data->numa_node = dev->device.numa_node;
-	eth_dev->data->drv_name = dev->device.driver->name;
 	return eth_dev;
 }
 
-- 
2.9.3

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [dpdk-dev] [PATCH v2] ethdev: remove driver name from device private data
  2017-05-26 11:15 [dpdk-dev] [PATCH] ethdev: remove driver name from device private data Ferruh Yigit
@ 2017-06-06 15:10 ` Ferruh Yigit
  2017-06-06 15:31   ` Gaëtan Rivet
                     ` (4 more replies)
  0 siblings, 5 replies; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-06 15:10 UTC (permalink / raw)
  To: Stephen Hurd, Ajit Khaparde, Declan Doherty, Rahul Lakkireddy,
	Hemant Agrawal, Shreyansh Jain, Helin Zhang, Jingjing Wu,
	Wenzhuo Lu, Konstantin Ananyev, Bruce Richardson, Pascal Mazon,
	Shrikrishna Khare, Jianfeng Tan, Thomas Monjalon
  Cc: dev, Ferruh Yigit, Gaetan Rivet, Jan Blunck

rte_driver->name has the driver name and all physical and virtual
devices has access to it.

Previously it was not possible for virtual ethernet devices to access
rte_driver->name field (because eth_dev used to keep only pci_dev),
and it was required to save driver name in the device private struct.

After re-works on bus and vdev, it is possible for all bus types to
access rte_driver.

It is able to remove the driver name from ethdev device private data and
use eth_dev->device->driver->name.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
Cc: Jan Blunck <jblunck@infradead.org>

v2:
* rebase on latest next-net
---
 drivers/net/bnxt/bnxt_ethdev.c         | 2 +-
 drivers/net/bonding/rte_eth_bond_api.c | 4 ++--
 drivers/net/cxgbe/sge.c                | 6 +++---
 drivers/net/dpaa2/dpaa2_ethdev.c       | 1 -
 drivers/net/i40e/i40e_ethdev.c         | 3 +--
 drivers/net/i40e/i40e_fdir.c           | 2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c       | 2 +-
 drivers/net/ring/rte_eth_ring.c        | 1 -
 drivers/net/tap/rte_eth_tap.c          | 1 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c   | 2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c  | 1 -
 lib/librte_ether/rte_ethdev.c          | 8 ++++----
 lib/librte_ether/rte_ethdev.h          | 1 -
 lib/librte_ether/rte_ethdev_pci.h      | 1 -
 lib/librte_ether/rte_ethdev_vdev.h     | 1 -
 15 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index f9bedf7..15195c3 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1940,7 +1940,7 @@ static struct rte_pci_driver bnxt_rte_pmd = {
 static bool
 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
 {
-	if (strcmp(dev->data->drv_name, drv->driver.name))
+	if (strcmp(dev->device->driver->name, drv->driver.name))
 		return false;
 
 	return true;
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 36ec65d..164eb59 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -48,11 +48,11 @@ int
 check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev)
 {
 	/* Check valid pointer */
-	if (eth_dev->data->drv_name == NULL)
+	if (eth_dev->device->driver->name == NULL)
 		return -1;
 
 	/* return 0 if driver name matches */
-	return eth_dev->data->drv_name != pmd_bond_drv.driver.name;
+	return eth_dev->device->driver->name != pmd_bond_drv.driver.name;
 }
 
 int
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 9cbd4ec..d088065 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -1691,7 +1691,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 	iq->size = cxgbe_roundup(iq->size, 16);
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 eth_dev->data->drv_name,
+		 eth_dev->device->driver->name,
 		 fwevtq ? "fwq_ring" : "rx_ring",
 		 eth_dev->data->port_id, queue_id);
 	snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
@@ -1745,7 +1745,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 		fl->size = cxgbe_roundup(fl->size, 8);
 
 		snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-			 eth_dev->data->drv_name,
+			 eth_dev->device->driver->name,
 			 fwevtq ? "fwq_ring" : "fl_ring",
 			 eth_dev->data->port_id, queue_id);
 		snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
@@ -1945,7 +1945,7 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
 	nentries = txq->q.size + s->stat_len / sizeof(struct tx_desc);
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 eth_dev->data->drv_name, "tx_ring",
+		 eth_dev->device->driver->name, "tx_ring",
 		 eth_dev->data->port_id, queue_id);
 	snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
 
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 4de1e0c..da309ac 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1464,7 +1464,6 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	eth_dev->dev_ops = &dpaa2_ethdev_ops;
-	eth_dev->data->drv_name = rte_dpaa2_pmd.driver.name;
 
 	eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx;
 	eth_dev->tx_pkt_burst = dpaa2_dev_tx;
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 2f1cd85..078a808 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -10738,8 +10738,7 @@ i40e_filter_restore(struct i40e_pf *pf)
 static bool
 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
 {
-	if (strcmp(dev->data->drv_name,
-		   drv->driver.name))
+	if (strcmp(dev->device->driver->name, drv->driver.name))
 		return false;
 
 	return true;
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index 9c1ab6e..77c23e0 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -256,7 +256,7 @@ i40e_fdir_setup(struct i40e_pf *pf)
 
 	/* reserve memory for the fdir programming packet */
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d",
-			eth_dev->data->drv_name,
+			eth_dev->device->driver->name,
 			I40E_FDIR_MZ_NAME,
 			eth_dev->data->port_id);
 	mz = i40e_memzone_reserve(z_name, I40E_FDIR_PKT_LEN, SOCKET_ID_ANY);
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 504e951..ebc5467 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4659,7 +4659,7 @@ ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
 static bool
 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
 {
-	if (strcmp(dev->data->drv_name, drv->driver.name))
+	if (strcmp(dev->device->driver->name, drv->driver.name))
 		return false;
 
 	return true;
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index d4dce95..bb5e322 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -342,7 +342,6 @@ do_eth_dev_ring_create(const char *name,
 	eth_dev->dev_ops = &ops;
 	data->dev_flags = RTE_ETH_DEV_DETACHABLE;
 	data->kdrv = RTE_KDRV_NONE;
-	data->drv_name = pmd_ring_drv.driver.name;
 	data->numa_node = numa_node;
 
 	/* finally assign rx and tx ops */
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 1bb660e..305f018 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -1220,7 +1220,6 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
 	data->dev_private = pmd;
 	data->dev_flags = RTE_ETH_DEV_DETACHABLE | RTE_ETH_DEV_INTR_LSC;
 	data->numa_node = numa_node;
-	data->drv_name = pmd_tap_drv.driver.name;
 
 	data->dev_link = pmd_link;
 	data->mac_addrs = &pmd->eth_addr;
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index ee48a9e..292a671 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -141,7 +141,7 @@ gpa_zone_reserve(struct rte_eth_dev *dev, uint32_t size,
 	const struct rte_memzone *mz;
 
 	snprintf(z_name, sizeof(z_name), "%s_%d_%s",
-		 dev->data->drv_name, dev->data->port_id, post_string);
+		 dev->device->driver->name, dev->data->port_id, post_string);
 
 	mz = rte_memzone_lookup(z_name);
 	if (!reuse) {
diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c
index 7bd29fa..e404b77 100644
--- a/drivers/net/xenvirt/rte_eth_xenvirt.c
+++ b/drivers/net/xenvirt/rte_eth_xenvirt.c
@@ -672,7 +672,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 
 	eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
 	eth_dev->data->kdrv = RTE_KDRV_NONE;
-	eth_dev->data->drv_name = pmd_xenvirt_drv.driver.name;
 	eth_dev->data->numa_node = numa_node;
 
 	eth_dev->rx_pkt_burst = eth_xenvirt_rx;
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index d257406..f5378a4 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -753,13 +753,13 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	if ((dev_conf->intr_conf.lsc == 1) &&
 		(!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
 			RTE_PMD_DEBUG_TRACE("driver %s does not support lsc\n",
-					dev->data->drv_name);
+					dev->device->driver->name);
 			return -EINVAL;
 	}
 	if ((dev_conf->intr_conf.rmv == 1) &&
 	    (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_RMV))) {
 		RTE_PMD_DEBUG_TRACE("driver %s does not support rmv\n",
-				    dev->data->drv_name);
+				    dev->device->driver->name);
 		return -EINVAL;
 	}
 
@@ -1900,7 +1900,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 
 	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
 	(*dev->dev_ops->dev_infos_get)(dev, dev_info);
-	dev_info->driver_name = dev->data->drv_name;
+	dev_info->driver_name = dev->device->driver->name;
 	dev_info->nb_rx_queues = dev->data->nb_rx_queues;
 	dev_info->nb_tx_queues = dev->data->nb_tx_queues;
 }
@@ -2789,7 +2789,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->data->drv_name, ring_name,
+		 dev->device->driver->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 b9fd8d3..05ae574 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1674,7 +1674,6 @@ struct rte_eth_dev_data {
 	uint32_t dev_flags; /**< Capabilities */
 	enum rte_kernel_driver kdrv;    /**< Kernel driver passthrough */
 	int numa_node;  /**< NUMA node connection */
-	const char *drv_name;   /**< Driver name */
 };
 
 /** Device supports hotplug detach */
diff --git a/lib/librte_ether/rte_ethdev_pci.h b/lib/librte_ether/rte_ethdev_pci.h
index d3bc03c..69aab03 100644
--- a/lib/librte_ether/rte_ethdev_pci.h
+++ b/lib/librte_ether/rte_ethdev_pci.h
@@ -69,7 +69,6 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev,
 
 	eth_dev->data->kdrv = pci_dev->kdrv;
 	eth_dev->data->numa_node = pci_dev->device.numa_node;
-	eth_dev->data->drv_name = pci_dev->driver->driver.name;
 }
 
 /**
diff --git a/lib/librte_ether/rte_ethdev_vdev.h b/lib/librte_ether/rte_ethdev_vdev.h
index fa2cb61..4d2c3e2 100644
--- a/lib/librte_ether/rte_ethdev_vdev.h
+++ b/lib/librte_ether/rte_ethdev_vdev.h
@@ -77,7 +77,6 @@ rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
 
 	eth_dev->data->kdrv = RTE_KDRV_NONE;
 	eth_dev->data->numa_node = dev->device.numa_node;
-	eth_dev->data->drv_name = dev->device.driver->name;
 	return eth_dev;
 }
 
-- 
2.9.3

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [dpdk-dev] [PATCH v2] ethdev: remove driver name from device private data
  2017-06-06 15:10 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
@ 2017-06-06 15:31   ` Gaëtan Rivet
  2017-06-07  4:52   ` Shreyansh Jain
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 24+ messages in thread
From: Gaëtan Rivet @ 2017-06-06 15:31 UTC (permalink / raw)
  To: Ferruh Yigit
  Cc: Stephen Hurd, Ajit Khaparde, Declan Doherty, Rahul Lakkireddy,
	Hemant Agrawal, Shreyansh Jain, Helin Zhang, Jingjing Wu,
	Wenzhuo Lu, Konstantin Ananyev, Bruce Richardson, Pascal Mazon,
	Shrikrishna Khare, Jianfeng Tan, Thomas Monjalon, dev,
	Jan Blunck

Hi Ferruh,

On Tue, Jun 06, 2017 at 04:10:08PM +0100, Ferruh Yigit wrote:
> rte_driver->name has the driver name and all physical and virtual
> devices has access to it.
> 
> Previously it was not possible for virtual ethernet devices to access
> rte_driver->name field (because eth_dev used to keep only pci_dev),
> and it was required to save driver name in the device private struct.
> 
> After re-works on bus and vdev, it is possible for all bus types to
> access rte_driver.
> 
> It is able to remove the driver name from ethdev device private data and
> use eth_dev->device->driver->name.
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
> Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
> Cc: Jan Blunck <jblunck@infradead.org>
> 

I'm not sure I am the one who should give his opinion on this, I only
took the work from Jan and ported it for integration.

However, as far as I am concerned, I agree with this change.

> v2:
> * rebase on latest next-net
> ---
>  drivers/net/bnxt/bnxt_ethdev.c         | 2 +-
>  drivers/net/bonding/rte_eth_bond_api.c | 4 ++--
>  drivers/net/cxgbe/sge.c                | 6 +++---
>  drivers/net/dpaa2/dpaa2_ethdev.c       | 1 -
>  drivers/net/i40e/i40e_ethdev.c         | 3 +--
>  drivers/net/i40e/i40e_fdir.c           | 2 +-
>  drivers/net/ixgbe/ixgbe_ethdev.c       | 2 +-
>  drivers/net/ring/rte_eth_ring.c        | 1 -
>  drivers/net/tap/rte_eth_tap.c          | 1 -
>  drivers/net/vmxnet3/vmxnet3_ethdev.c   | 2 +-
>  drivers/net/xenvirt/rte_eth_xenvirt.c  | 1 -
>  lib/librte_ether/rte_ethdev.c          | 8 ++++----
>  lib/librte_ether/rte_ethdev.h          | 1 -
>  lib/librte_ether/rte_ethdev_pci.h      | 1 -
>  lib/librte_ether/rte_ethdev_vdev.h     | 1 -
>  15 files changed, 14 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
> index f9bedf7..15195c3 100644
> --- a/drivers/net/bnxt/bnxt_ethdev.c
> +++ b/drivers/net/bnxt/bnxt_ethdev.c
> @@ -1940,7 +1940,7 @@ static struct rte_pci_driver bnxt_rte_pmd = {
>  static bool
>  is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
>  {
> -	if (strcmp(dev->data->drv_name, drv->driver.name))
> +	if (strcmp(dev->device->driver->name, drv->driver.name))
>  		return false;
>  
>  	return true;
> diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
> index 36ec65d..164eb59 100644
> --- a/drivers/net/bonding/rte_eth_bond_api.c
> +++ b/drivers/net/bonding/rte_eth_bond_api.c
> @@ -48,11 +48,11 @@ int
>  check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev)
>  {
>  	/* Check valid pointer */
> -	if (eth_dev->data->drv_name == NULL)
> +	if (eth_dev->device->driver->name == NULL)
>  		return -1;
>  
>  	/* return 0 if driver name matches */
> -	return eth_dev->data->drv_name != pmd_bond_drv.driver.name;
> +	return eth_dev->device->driver->name != pmd_bond_drv.driver.name;
>  }
>  
>  int
> diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
> index 9cbd4ec..d088065 100644
> --- a/drivers/net/cxgbe/sge.c
> +++ b/drivers/net/cxgbe/sge.c
> @@ -1691,7 +1691,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
>  	iq->size = cxgbe_roundup(iq->size, 16);
>  
>  	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
> -		 eth_dev->data->drv_name,
> +		 eth_dev->device->driver->name,
>  		 fwevtq ? "fwq_ring" : "rx_ring",
>  		 eth_dev->data->port_id, queue_id);
>  	snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
> @@ -1745,7 +1745,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
>  		fl->size = cxgbe_roundup(fl->size, 8);
>  
>  		snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
> -			 eth_dev->data->drv_name,
> +			 eth_dev->device->driver->name,
>  			 fwevtq ? "fwq_ring" : "fl_ring",
>  			 eth_dev->data->port_id, queue_id);
>  		snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
> @@ -1945,7 +1945,7 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
>  	nentries = txq->q.size + s->stat_len / sizeof(struct tx_desc);
>  
>  	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
> -		 eth_dev->data->drv_name, "tx_ring",
> +		 eth_dev->device->driver->name, "tx_ring",
>  		 eth_dev->data->port_id, queue_id);
>  	snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
>  
> diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
> index 4de1e0c..da309ac 100644
> --- a/drivers/net/dpaa2/dpaa2_ethdev.c
> +++ b/drivers/net/dpaa2/dpaa2_ethdev.c
> @@ -1464,7 +1464,6 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
>  	}
>  
>  	eth_dev->dev_ops = &dpaa2_ethdev_ops;
> -	eth_dev->data->drv_name = rte_dpaa2_pmd.driver.name;
>  
>  	eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx;
>  	eth_dev->tx_pkt_burst = dpaa2_dev_tx;
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 2f1cd85..078a808 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -10738,8 +10738,7 @@ i40e_filter_restore(struct i40e_pf *pf)
>  static bool
>  is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
>  {
> -	if (strcmp(dev->data->drv_name,
> -		   drv->driver.name))
> +	if (strcmp(dev->device->driver->name, drv->driver.name))
>  		return false;
>  
>  	return true;
> diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
> index 9c1ab6e..77c23e0 100644
> --- a/drivers/net/i40e/i40e_fdir.c
> +++ b/drivers/net/i40e/i40e_fdir.c
> @@ -256,7 +256,7 @@ i40e_fdir_setup(struct i40e_pf *pf)
>  
>  	/* reserve memory for the fdir programming packet */
>  	snprintf(z_name, sizeof(z_name), "%s_%s_%d",
> -			eth_dev->data->drv_name,
> +			eth_dev->device->driver->name,
>  			I40E_FDIR_MZ_NAME,
>  			eth_dev->data->port_id);
>  	mz = i40e_memzone_reserve(z_name, I40E_FDIR_PKT_LEN, SOCKET_ID_ANY);
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
> index 504e951..ebc5467 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -4659,7 +4659,7 @@ ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
>  static bool
>  is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
>  {
> -	if (strcmp(dev->data->drv_name, drv->driver.name))
> +	if (strcmp(dev->device->driver->name, drv->driver.name))
>  		return false;
>  
>  	return true;
> diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
> index d4dce95..bb5e322 100644
> --- a/drivers/net/ring/rte_eth_ring.c
> +++ b/drivers/net/ring/rte_eth_ring.c
> @@ -342,7 +342,6 @@ do_eth_dev_ring_create(const char *name,
>  	eth_dev->dev_ops = &ops;
>  	data->dev_flags = RTE_ETH_DEV_DETACHABLE;
>  	data->kdrv = RTE_KDRV_NONE;
> -	data->drv_name = pmd_ring_drv.driver.name;
>  	data->numa_node = numa_node;
>  
>  	/* finally assign rx and tx ops */
> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
> index 1bb660e..305f018 100644
> --- a/drivers/net/tap/rte_eth_tap.c
> +++ b/drivers/net/tap/rte_eth_tap.c
> @@ -1220,7 +1220,6 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
>  	data->dev_private = pmd;
>  	data->dev_flags = RTE_ETH_DEV_DETACHABLE | RTE_ETH_DEV_INTR_LSC;
>  	data->numa_node = numa_node;
> -	data->drv_name = pmd_tap_drv.driver.name;
>  
>  	data->dev_link = pmd_link;
>  	data->mac_addrs = &pmd->eth_addr;
> diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
> index ee48a9e..292a671 100644
> --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
> +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
> @@ -141,7 +141,7 @@ gpa_zone_reserve(struct rte_eth_dev *dev, uint32_t size,
>  	const struct rte_memzone *mz;
>  
>  	snprintf(z_name, sizeof(z_name), "%s_%d_%s",
> -		 dev->data->drv_name, dev->data->port_id, post_string);
> +		 dev->device->driver->name, dev->data->port_id, post_string);
>  
>  	mz = rte_memzone_lookup(z_name);
>  	if (!reuse) {
> diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c
> index 7bd29fa..e404b77 100644
> --- a/drivers/net/xenvirt/rte_eth_xenvirt.c
> +++ b/drivers/net/xenvirt/rte_eth_xenvirt.c
> @@ -672,7 +672,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
>  
>  	eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
>  	eth_dev->data->kdrv = RTE_KDRV_NONE;
> -	eth_dev->data->drv_name = pmd_xenvirt_drv.driver.name;
>  	eth_dev->data->numa_node = numa_node;
>  
>  	eth_dev->rx_pkt_burst = eth_xenvirt_rx;
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index d257406..f5378a4 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -753,13 +753,13 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>  	if ((dev_conf->intr_conf.lsc == 1) &&
>  		(!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
>  			RTE_PMD_DEBUG_TRACE("driver %s does not support lsc\n",
> -					dev->data->drv_name);
> +					dev->device->driver->name);
>  			return -EINVAL;
>  	}
>  	if ((dev_conf->intr_conf.rmv == 1) &&
>  	    (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_RMV))) {
>  		RTE_PMD_DEBUG_TRACE("driver %s does not support rmv\n",
> -				    dev->data->drv_name);
> +				    dev->device->driver->name);
>  		return -EINVAL;
>  	}
>  
> @@ -1900,7 +1900,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
>  
>  	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
>  	(*dev->dev_ops->dev_infos_get)(dev, dev_info);
> -	dev_info->driver_name = dev->data->drv_name;
> +	dev_info->driver_name = dev->device->driver->name;
>  	dev_info->nb_rx_queues = dev->data->nb_rx_queues;
>  	dev_info->nb_tx_queues = dev->data->nb_tx_queues;
>  }
> @@ -2789,7 +2789,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->data->drv_name, ring_name,
> +		 dev->device->driver->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 b9fd8d3..05ae574 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -1674,7 +1674,6 @@ struct rte_eth_dev_data {
>  	uint32_t dev_flags; /**< Capabilities */
>  	enum rte_kernel_driver kdrv;    /**< Kernel driver passthrough */
>  	int numa_node;  /**< NUMA node connection */
> -	const char *drv_name;   /**< Driver name */
>  };
>  
>  /** Device supports hotplug detach */
> diff --git a/lib/librte_ether/rte_ethdev_pci.h b/lib/librte_ether/rte_ethdev_pci.h
> index d3bc03c..69aab03 100644
> --- a/lib/librte_ether/rte_ethdev_pci.h
> +++ b/lib/librte_ether/rte_ethdev_pci.h
> @@ -69,7 +69,6 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev,
>  
>  	eth_dev->data->kdrv = pci_dev->kdrv;
>  	eth_dev->data->numa_node = pci_dev->device.numa_node;
> -	eth_dev->data->drv_name = pci_dev->driver->driver.name;
>  }
>  
>  /**
> diff --git a/lib/librte_ether/rte_ethdev_vdev.h b/lib/librte_ether/rte_ethdev_vdev.h
> index fa2cb61..4d2c3e2 100644
> --- a/lib/librte_ether/rte_ethdev_vdev.h
> +++ b/lib/librte_ether/rte_ethdev_vdev.h
> @@ -77,7 +77,6 @@ rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
>  
>  	eth_dev->data->kdrv = RTE_KDRV_NONE;
>  	eth_dev->data->numa_node = dev->device.numa_node;
> -	eth_dev->data->drv_name = dev->device.driver->name;
>  	return eth_dev;
>  }
>  
> -- 
> 2.9.3
> 

-- 
Gaëtan Rivet
6WIND

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [dpdk-dev] [PATCH v2] ethdev: remove driver name from device private data
  2017-06-06 15:10 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
  2017-06-06 15:31   ` Gaëtan Rivet
@ 2017-06-07  4:52   ` Shreyansh Jain
  2017-06-07 16:11   ` Jan Blunck
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 24+ messages in thread
From: Shreyansh Jain @ 2017-06-07  4:52 UTC (permalink / raw)
  To: Ferruh Yigit
  Cc: Stephen Hurd, Ajit Khaparde, Declan Doherty, Rahul Lakkireddy,
	Hemant Agrawal, Helin Zhang, Jingjing Wu, Wenzhuo Lu,
	Konstantin Ananyev, Bruce Richardson, Pascal Mazon,
	Shrikrishna Khare, Jianfeng Tan, Thomas Monjalon, dev,
	Gaetan Rivet, Jan Blunck

On Tuesday 06 June 2017 08:40 PM, Ferruh Yigit wrote:
> rte_driver->name has the driver name and all physical and virtual
> devices has access to it.
> 
> Previously it was not possible for virtual ethernet devices to access
> rte_driver->name field (because eth_dev used to keep only pci_dev),
> and it was required to save driver name in the device private struct.
> 
> After re-works on bus and vdev, it is possible for all bus types to
> access rte_driver.
> 
> It is able to remove the driver name from ethdev device private data and
> use eth_dev->device->driver->name.
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
> Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
> Cc: Jan Blunck <jblunck@infradead.org>
> 
> v2:
> * rebase on latest next-net
> ---
>   drivers/net/bnxt/bnxt_ethdev.c         | 2 +-
>   drivers/net/bonding/rte_eth_bond_api.c | 4 ++--
>   drivers/net/cxgbe/sge.c                | 6 +++---
>   drivers/net/dpaa2/dpaa2_ethdev.c       | 1 -
>   drivers/net/i40e/i40e_ethdev.c         | 3 +--
>   drivers/net/i40e/i40e_fdir.c           | 2 +-
>   drivers/net/ixgbe/ixgbe_ethdev.c       | 2 +-
>   drivers/net/ring/rte_eth_ring.c        | 1 -
>   drivers/net/tap/rte_eth_tap.c          | 1 -
>   drivers/net/vmxnet3/vmxnet3_ethdev.c   | 2 +-
>   drivers/net/xenvirt/rte_eth_xenvirt.c  | 1 -
>   lib/librte_ether/rte_ethdev.c          | 8 ++++----
>   lib/librte_ether/rte_ethdev.h          | 1 -
>   lib/librte_ether/rte_ethdev_pci.h      | 1 -
>   lib/librte_ether/rte_ethdev_vdev.h     | 1 -
>   15 files changed, 14 insertions(+), 22 deletions(-)
> 

Apologies for delay in responding. I am OK with respect to the dpaa2 
change. Otherwise as well:

Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [dpdk-dev] [PATCH v2] ethdev: remove driver name from device private data
  2017-06-06 15:10 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
  2017-06-06 15:31   ` Gaëtan Rivet
  2017-06-07  4:52   ` Shreyansh Jain
@ 2017-06-07 16:11   ` Jan Blunck
  2017-06-09 14:22     ` Ferruh Yigit
  2017-06-08 20:58   ` Thomas Monjalon
  2017-06-09 17:51   ` [dpdk-dev] [PATCH v3 1/3] net/ring: set ethernet device field Ferruh Yigit
  4 siblings, 1 reply; 24+ messages in thread
From: Jan Blunck @ 2017-06-07 16:11 UTC (permalink / raw)
  To: Ferruh Yigit
  Cc: Stephen Hurd, Ajit Khaparde, Declan Doherty, Rahul Lakkireddy,
	Hemant Agrawal, Shreyansh Jain, Helin Zhang, Jingjing Wu,
	Wenzhuo Lu, Konstantin Ananyev, Bruce Richardson, Pascal Mazon,
	Shrikrishna Khare, Jianfeng Tan, Thomas Monjalon, dev,
	Gaetan Rivet

On Tue, Jun 6, 2017 at 5:10 PM, Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> rte_driver->name has the driver name and all physical and virtual
> devices has access to it.
>
> Previously it was not possible for virtual ethernet devices to access
> rte_driver->name field (because eth_dev used to keep only pci_dev),
> and it was required to save driver name in the device private struct.
>
> After re-works on bus and vdev, it is possible for all bus types to
> access rte_driver.
>
> It is able to remove the driver name from ethdev device private data and
> use eth_dev->device->driver->name.
>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
> Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
> Cc: Jan Blunck <jblunck@infradead.org>
>
> v2:
> * rebase on latest next-net

Acked-by: Jan Blunck <jblunck@infradead.org>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [dpdk-dev] [PATCH v2] ethdev: remove driver name from device private data
  2017-06-06 15:10 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
                     ` (2 preceding siblings ...)
  2017-06-07 16:11   ` Jan Blunck
@ 2017-06-08 20:58   ` Thomas Monjalon
  2017-06-09 10:51     ` Ferruh Yigit
  2017-06-09 17:51   ` [dpdk-dev] [PATCH v3 1/3] net/ring: set ethernet device field Ferruh Yigit
  4 siblings, 1 reply; 24+ messages in thread
From: Thomas Monjalon @ 2017-06-08 20:58 UTC (permalink / raw)
  To: Ferruh Yigit
  Cc: dev, Stephen Hurd, Ajit Khaparde, Declan Doherty,
	Rahul Lakkireddy, Hemant Agrawal, Shreyansh Jain, Helin Zhang,
	Jingjing Wu, Wenzhuo Lu, Konstantin Ananyev, Bruce Richardson,
	Pascal Mazon, Shrikrishna Khare, Jianfeng Tan, Gaetan Rivet,
	Jan Blunck

06/06/2017 17:10, Ferruh Yigit:
> rte_driver->name has the driver name and all physical and virtual
> devices has access to it.
> 
> Previously it was not possible for virtual ethernet devices to access
> rte_driver->name field (because eth_dev used to keep only pci_dev),
> and it was required to save driver name in the device private struct.
> 
> After re-works on bus and vdev, it is possible for all bus types to
> access rte_driver.
> 
> It is able to remove the driver name from ethdev device private data and
> use eth_dev->device->driver->name.
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
> Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
> Cc: Jan Blunck <jblunck@infradead.org>
> 
> v2:
> * rebase on latest next-net

This patch must be applied after merging next-net.
Do you plan a pull request soon?

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [dpdk-dev] [PATCH v2] ethdev: remove driver name from device private data
  2017-06-08 20:58   ` Thomas Monjalon
@ 2017-06-09 10:51     ` Ferruh Yigit
  0 siblings, 0 replies; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-09 10:51 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, Stephen Hurd, Ajit Khaparde, Declan Doherty,
	Rahul Lakkireddy, Hemant Agrawal, Shreyansh Jain, Helin Zhang,
	Jingjing Wu, Wenzhuo Lu, Konstantin Ananyev, Bruce Richardson,
	Pascal Mazon, Shrikrishna Khare, Jianfeng Tan, Gaetan Rivet,
	Jan Blunck

On 6/8/2017 9:58 PM, Thomas Monjalon wrote:
> 06/06/2017 17:10, Ferruh Yigit:
>> rte_driver->name has the driver name and all physical and virtual
>> devices has access to it.
>>
>> Previously it was not possible for virtual ethernet devices to access
>> rte_driver->name field (because eth_dev used to keep only pci_dev),
>> and it was required to save driver name in the device private struct.
>>
>> After re-works on bus and vdev, it is possible for all bus types to
>> access rte_driver.
>>
>> It is able to remove the driver name from ethdev device private data and
>> use eth_dev->device->driver->name.
>>
>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>> ---
>> Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
>> Cc: Jan Blunck <jblunck@infradead.org>
>>
>> v2:
>> * rebase on latest next-net
> 
> This patch must be applied after merging next-net.
> Do you plan a pull request soon?

Agreed to sync drivers to main tree before upcoming eal changes.

I will send an early pull request on Monday. Including this patch in it.

There will be another pull request before integration (rc1) as usual.

Thanks,
ferruh

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [dpdk-dev] [PATCH v2] ethdev: remove driver name from device private data
  2017-06-07 16:11   ` Jan Blunck
@ 2017-06-09 14:22     ` Ferruh Yigit
  2017-06-09 15:49       ` Ferruh Yigit
  0 siblings, 1 reply; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-09 14:22 UTC (permalink / raw)
  To: Jan Blunck
  Cc: Stephen Hurd, Ajit Khaparde, Declan Doherty, Rahul Lakkireddy,
	Hemant Agrawal, Shreyansh Jain, Helin Zhang, Jingjing Wu,
	Wenzhuo Lu, Konstantin Ananyev, Bruce Richardson, Pascal Mazon,
	Shrikrishna Khare, Jianfeng Tan, Thomas Monjalon, dev,
	Gaetan Rivet

On 6/7/2017 5:11 PM, Jan Blunck wrote:
> On Tue, Jun 6, 2017 at 5:10 PM, Ferruh Yigit <ferruh.yigit@intel.com> wrote:
>> rte_driver->name has the driver name and all physical and virtual
>> devices has access to it.
>>
>> Previously it was not possible for virtual ethernet devices to access
>> rte_driver->name field (because eth_dev used to keep only pci_dev),
>> and it was required to save driver name in the device private struct.
>>
>> After re-works on bus and vdev, it is possible for all bus types to
>> access rte_driver.
>>
>> It is able to remove the driver name from ethdev device private data and
>> use eth_dev->device->driver->name.
>>
>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>> ---
>> Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
>> Cc: Jan Blunck <jblunck@infradead.org>
>>
>> v2:
>> * rebase on latest next-net
> 
> Acked-by: Jan Blunck <jblunck@infradead.org>

Applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [dpdk-dev] [PATCH v2] ethdev: remove driver name from device private data
  2017-06-09 14:22     ` Ferruh Yigit
@ 2017-06-09 15:49       ` Ferruh Yigit
  0 siblings, 0 replies; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-09 15:49 UTC (permalink / raw)
  To: Jan Blunck
  Cc: Stephen Hurd, Ajit Khaparde, Declan Doherty, Rahul Lakkireddy,
	Hemant Agrawal, Shreyansh Jain, Helin Zhang, Jingjing Wu,
	Wenzhuo Lu, Konstantin Ananyev, Bruce Richardson, Pascal Mazon,
	Shrikrishna Khare, Jianfeng Tan, Thomas Monjalon, dev,
	Gaetan Rivet

On 6/9/2017 3:22 PM, Ferruh Yigit wrote:
> On 6/7/2017 5:11 PM, Jan Blunck wrote:
>> On Tue, Jun 6, 2017 at 5:10 PM, Ferruh Yigit <ferruh.yigit@intel.com> wrote:
>>> rte_driver->name has the driver name and all physical and virtual
>>> devices has access to it.
>>>
>>> Previously it was not possible for virtual ethernet devices to access
>>> rte_driver->name field (because eth_dev used to keep only pci_dev),
>>> and it was required to save driver name in the device private struct.
>>>
>>> After re-works on bus and vdev, it is possible for all bus types to
>>> access rte_driver.
>>>
>>> It is able to remove the driver name from ethdev device private data and
>>> use eth_dev->device->driver->name.
>>>
>>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>>> ---
>>> Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
>>> Cc: Jan Blunck <jblunck@infradead.org>
>>>
>>> v2:
>>> * rebase on latest next-net
>>
>> Acked-by: Jan Blunck <jblunck@infradead.org>
> 
> Applied to dpdk-next-net/master, thanks.

Nope. This breaks ring PMD, because it doesn't set eth_dev->device properly.

And the API it provides to create ring PMD makes things more
complicated, because that API doesn't create vdev at all, so when ring
PMD created via API instead of generic way, it doesn't have rte_device
at all ...

I am dropping patch from the next-net, and will send a new version of it.

Thanks,
ferruh

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [dpdk-dev] [PATCH v3 1/3] net/ring: set ethernet device field
  2017-06-06 15:10 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
                     ` (3 preceding siblings ...)
  2017-06-08 20:58   ` Thomas Monjalon
@ 2017-06-09 17:51   ` Ferruh Yigit
  2017-06-09 17:51     ` [dpdk-dev] [PATCH v3 2/3] net/ring: create vdev from PMD specific API Ferruh Yigit
                       ` (2 more replies)
  4 siblings, 3 replies; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-09 17:51 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Ferruh Yigit

The eth_dev->device link was missing for ring PMD, adding it.

This is to generalize rte_device access from eth_dev.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/ring/rte_eth_ring.c | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index d4dce95..6feb137 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -263,7 +263,8 @@ static int
 do_eth_dev_ring_create(const char *name,
 		struct rte_ring * const rx_queues[], const unsigned nb_rx_queues,
 		struct rte_ring *const tx_queues[], const unsigned nb_tx_queues,
-		const unsigned numa_node, enum dev_action action)
+		const unsigned int numa_node, enum dev_action action,
+		struct rte_eth_dev **eth_dev_p)
 {
 	struct rte_eth_dev_data *data = NULL;
 	struct pmd_internals *internals = NULL;
@@ -349,6 +350,8 @@ do_eth_dev_ring_create(const char *name,
 	eth_dev->rx_pkt_burst = eth_ring_rx;
 	eth_dev->tx_pkt_burst = eth_ring_tx;
 
+	*eth_dev_p = eth_dev;
+
 	return data->port_id;
 
 error:
@@ -369,6 +372,8 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		const unsigned nb_tx_queues,
 		const unsigned numa_node)
 {
+	struct rte_eth_dev *eth_dev = NULL;
+
 	/* do some parameter checking */
 	if (rx_queues == NULL && nb_rx_queues > 0) {
 		rte_errno = EINVAL;
@@ -384,7 +389,8 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 	}
 
 	return do_eth_dev_ring_create(name, rx_queues, nb_rx_queues,
-			tx_queues, nb_tx_queues, numa_node, DEV_ATTACH);
+			tx_queues, nb_tx_queues, numa_node, DEV_ATTACH,
+			&eth_dev);
 }
 
 int
@@ -396,7 +402,7 @@ rte_eth_from_ring(struct rte_ring *r)
 
 static int
 eth_dev_ring_create(const char *name, const unsigned numa_node,
-		enum dev_action action)
+		enum dev_action action, struct rte_eth_dev **eth_dev)
 {
 	/* rx and tx are so-called from point of view of first port.
 	 * They are inverted from the point of view of second port
@@ -418,7 +424,7 @@ eth_dev_ring_create(const char *name, const unsigned numa_node,
 	}
 
 	if (do_eth_dev_ring_create(name, rxtx, num_rings, rxtx, num_rings,
-		numa_node, action) < 0)
+		numa_node, action, eth_dev) < 0)
 		return -1;
 
 	return 0;
@@ -508,6 +514,7 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 	struct rte_kvargs *kvlist = NULL;
 	int ret = 0;
 	struct node_action_list *info = NULL;
+	struct rte_eth_dev *eth_dev = NULL;
 
 	name = rte_vdev_device_name(dev);
 	params = rte_vdev_device_args(dev);
@@ -515,12 +522,13 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 	RTE_LOG(INFO, PMD, "Initializing pmd_ring for %s\n", name);
 
 	if (params == NULL || params[0] == '\0') {
-		ret = eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE);
+		ret = eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE,
+				&eth_dev);
 		if (ret == -1) {
 			RTE_LOG(INFO, PMD,
 				"Attach to pmd_ring for %s\n", name);
 			ret = eth_dev_ring_create(name, rte_socket_id(),
-						  DEV_ATTACH);
+						  DEV_ATTACH, &eth_dev);
 		}
 	}
 	else {
@@ -530,13 +538,13 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 			RTE_LOG(INFO, PMD, "Ignoring unsupported parameters when creating"
 					" rings-backed ethernet device\n");
 			ret = eth_dev_ring_create(name, rte_socket_id(),
-						  DEV_CREATE);
+						  DEV_CREATE, &eth_dev);
 			if (ret == -1) {
 				RTE_LOG(INFO, PMD,
 					"Attach to pmd_ring for %s\n",
 					name);
 				ret = eth_dev_ring_create(name, rte_socket_id(),
-							  DEV_ATTACH);
+							  DEV_ATTACH, &eth_dev);
 			}
 			return ret;
 		} else {
@@ -560,7 +568,8 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 			for (info->count = 0; info->count < info->total; info->count++) {
 				ret = eth_dev_ring_create(info->list[info->count].name,
 							  info->list[info->count].node,
-							  info->list[info->count].action);
+							  info->list[info->count].action,
+							  &eth_dev);
 				if ((ret == -1) &&
 				    (info->list[info->count].action == DEV_CREATE)) {
 					RTE_LOG(INFO, PMD,
@@ -568,12 +577,16 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 						name);
 					ret = eth_dev_ring_create(name,
 							info->list[info->count].node,
-							DEV_ATTACH);
+							DEV_ATTACH,
+							&eth_dev);
 				}
 			}
 		}
 	}
 
+	if (eth_dev)
+		eth_dev->device = &dev->device;
+
 out_free:
 	rte_kvargs_free(kvlist);
 	rte_free(info);
-- 
2.9.4

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [dpdk-dev] [PATCH v3 2/3] net/ring: create vdev from PMD specific API
  2017-06-09 17:51   ` [dpdk-dev] [PATCH v3 1/3] net/ring: set ethernet device field Ferruh Yigit
@ 2017-06-09 17:51     ` Ferruh Yigit
  2017-06-12 13:25       ` Bruce Richardson
  2017-06-09 17:51     ` [dpdk-dev] [PATCH v3 3/3] ethdev: remove driver name from device private data Ferruh Yigit
  2017-06-12 14:13     ` [dpdk-dev] [PATCH v4 1/3] net/ring: set ethernet device field Ferruh Yigit
  2 siblings, 1 reply; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-09 17:51 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Ferruh Yigit

When ring PMD created via PMD specific API instead of EAL abstraction
it is missing the virtual device creation done by EAL vdev.

And this makes eth_dev unusable exact same as other PMDs used, because
of some missing fields, like rte_device->name.

Now API creates a virtual device and sets proper fields, not all, and it
still won't be linked in the virtual device list eal keeps track. But
makes PMD usable in usual manner.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/ring/rte_eth_ring.c | 49 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 6feb137..a9355ff 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -365,6 +365,41 @@ do_eth_dev_ring_create(const char *name,
 	return -1;
 }
 
+static struct rte_vdev_device *
+alloc_vdev(const char *name)
+{
+	struct rte_devargs *devargs = NULL;
+	struct rte_vdev_device *vdev = NULL;
+	int ret;
+
+	devargs = calloc(1, sizeof(*devargs));
+	if (!devargs)
+		goto out_free;
+
+	vdev = calloc(1, sizeof(*vdev));
+	if (!vdev)
+		goto out_free;
+
+	devargs->type = RTE_DEVTYPE_VIRTUAL;
+	ret = snprintf(devargs->virt.drv_name, sizeof(devargs->virt.drv_name),
+			"%s", name);
+	if (ret < 0)
+		goto out_free;
+
+	vdev->device.devargs = devargs;
+	vdev->device.numa_node = SOCKET_ID_ANY;
+	vdev->device.name = devargs->virt.drv_name;
+
+	vdev->device.driver = &pmd_ring_drv.driver;
+
+	return vdev;
+
+out_free:
+	free(devargs);
+	free(vdev);
+	return NULL;
+}
+
 int
 rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		const unsigned nb_rx_queues,
@@ -373,6 +408,8 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		const unsigned numa_node)
 {
 	struct rte_eth_dev *eth_dev = NULL;
+	struct rte_vdev_device *vdev;
+	int ret;
 
 	/* do some parameter checking */
 	if (rx_queues == NULL && nb_rx_queues > 0) {
@@ -388,9 +425,19 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		return -1;
 	}
 
-	return do_eth_dev_ring_create(name, rx_queues, nb_rx_queues,
+	vdev = alloc_vdev(name);
+	if (!vdev) {
+		rte_errno = EINVAL;
+		return -1;
+	}
+
+	ret = do_eth_dev_ring_create(name, rx_queues, nb_rx_queues,
 			tx_queues, nb_tx_queues, numa_node, DEV_ATTACH,
 			&eth_dev);
+
+	eth_dev->device = &vdev->device;
+
+	return ret;
 }
 
 int
-- 
2.9.4

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [dpdk-dev] [PATCH v3 3/3] ethdev: remove driver name from device private data
  2017-06-09 17:51   ` [dpdk-dev] [PATCH v3 1/3] net/ring: set ethernet device field Ferruh Yigit
  2017-06-09 17:51     ` [dpdk-dev] [PATCH v3 2/3] net/ring: create vdev from PMD specific API Ferruh Yigit
@ 2017-06-09 17:51     ` Ferruh Yigit
  2017-06-12 14:13     ` [dpdk-dev] [PATCH v4 1/3] net/ring: set ethernet device field Ferruh Yigit
  2 siblings, 0 replies; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-09 17:51 UTC (permalink / raw)
  To: Bruce Richardson, Stephen Hurd, Ajit Khaparde, Declan Doherty,
	Rahul Lakkireddy, Hemant Agrawal, Shreyansh Jain, Helin Zhang,
	Jingjing Wu, Wenzhuo Lu, Konstantin Ananyev, Pascal Mazon,
	Shrikrishna Khare, Jianfeng Tan, Thomas Monjalon
  Cc: dev, Ferruh Yigit

rte_driver->name has the driver name and all physical and virtual
devices has access to it.

Previously it was not possible for virtual ethernet devices to access
rte_driver->name field (because eth_dev used to keep only pci_dev),
and it was required to save driver name in the device private struct.

After re-works on bus and vdev, it is possible for all bus types to
access rte_driver.

It is able to remove the driver name from ethdev device private data and
use eth_dev->device->driver->name.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
Acked-by: Jan Blunck <jblunck@infradead.org>
---
 drivers/net/bnxt/bnxt_ethdev.c         | 2 +-
 drivers/net/bonding/rte_eth_bond_api.c | 4 ++--
 drivers/net/cxgbe/sge.c                | 6 +++---
 drivers/net/dpaa2/dpaa2_ethdev.c       | 1 -
 drivers/net/i40e/i40e_ethdev.c         | 3 +--
 drivers/net/i40e/i40e_fdir.c           | 2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c       | 2 +-
 drivers/net/ring/rte_eth_ring.c        | 1 -
 drivers/net/tap/rte_eth_tap.c          | 1 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c   | 2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c  | 1 -
 lib/librte_ether/rte_ethdev.c          | 8 ++++----
 lib/librte_ether/rte_ethdev.h          | 1 -
 lib/librte_ether/rte_ethdev_pci.h      | 1 -
 lib/librte_ether/rte_ethdev_vdev.h     | 1 -
 15 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 79e800b..a2d46ee 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1922,7 +1922,7 @@ static struct rte_pci_driver bnxt_rte_pmd = {
 static bool
 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
 {
-	if (strcmp(dev->data->drv_name, drv->driver.name))
+	if (strcmp(dev->device->driver->name, drv->driver.name))
 		return false;
 
 	return true;
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 36ec65d..164eb59 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -48,11 +48,11 @@ int
 check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev)
 {
 	/* Check valid pointer */
-	if (eth_dev->data->drv_name == NULL)
+	if (eth_dev->device->driver->name == NULL)
 		return -1;
 
 	/* return 0 if driver name matches */
-	return eth_dev->data->drv_name != pmd_bond_drv.driver.name;
+	return eth_dev->device->driver->name != pmd_bond_drv.driver.name;
 }
 
 int
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 9cbd4ec..d088065 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -1691,7 +1691,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 	iq->size = cxgbe_roundup(iq->size, 16);
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 eth_dev->data->drv_name,
+		 eth_dev->device->driver->name,
 		 fwevtq ? "fwq_ring" : "rx_ring",
 		 eth_dev->data->port_id, queue_id);
 	snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
@@ -1745,7 +1745,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 		fl->size = cxgbe_roundup(fl->size, 8);
 
 		snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-			 eth_dev->data->drv_name,
+			 eth_dev->device->driver->name,
 			 fwevtq ? "fwq_ring" : "fl_ring",
 			 eth_dev->data->port_id, queue_id);
 		snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
@@ -1945,7 +1945,7 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
 	nentries = txq->q.size + s->stat_len / sizeof(struct tx_desc);
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 eth_dev->data->drv_name, "tx_ring",
+		 eth_dev->device->driver->name, "tx_ring",
 		 eth_dev->data->port_id, queue_id);
 	snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
 
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 4de1e0c..da309ac 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1464,7 +1464,6 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	eth_dev->dev_ops = &dpaa2_ethdev_ops;
-	eth_dev->data->drv_name = rte_dpaa2_pmd.driver.name;
 
 	eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx;
 	eth_dev->tx_pkt_burst = dpaa2_dev_tx;
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index f614949..d3428b9 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -10738,8 +10738,7 @@ i40e_filter_restore(struct i40e_pf *pf)
 static bool
 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
 {
-	if (strcmp(dev->data->drv_name,
-		   drv->driver.name))
+	if (strcmp(dev->device->driver->name, drv->driver.name))
 		return false;
 
 	return true;
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index ca423d9..a970b56 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -239,7 +239,7 @@ i40e_fdir_setup(struct i40e_pf *pf)
 
 	/* reserve memory for the fdir programming packet */
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d",
-			eth_dev->data->drv_name,
+			eth_dev->device->driver->name,
 			I40E_FDIR_MZ_NAME,
 			eth_dev->data->port_id);
 	mz = i40e_memzone_reserve(z_name, I40E_FDIR_PKT_LEN, SOCKET_ID_ANY);
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 504e951..ebc5467 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4659,7 +4659,7 @@ ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
 static bool
 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
 {
-	if (strcmp(dev->data->drv_name, drv->driver.name))
+	if (strcmp(dev->device->driver->name, drv->driver.name))
 		return false;
 
 	return true;
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index a9355ff..2ab764b 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -343,7 +343,6 @@ do_eth_dev_ring_create(const char *name,
 	eth_dev->dev_ops = &ops;
 	data->dev_flags = RTE_ETH_DEV_DETACHABLE;
 	data->kdrv = RTE_KDRV_NONE;
-	data->drv_name = pmd_ring_drv.driver.name;
 	data->numa_node = numa_node;
 
 	/* finally assign rx and tx ops */
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 1bb660e..305f018 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -1220,7 +1220,6 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
 	data->dev_private = pmd;
 	data->dev_flags = RTE_ETH_DEV_DETACHABLE | RTE_ETH_DEV_INTR_LSC;
 	data->numa_node = numa_node;
-	data->drv_name = pmd_tap_drv.driver.name;
 
 	data->dev_link = pmd_link;
 	data->mac_addrs = &pmd->eth_addr;
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index ee48a9e..292a671 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -141,7 +141,7 @@ gpa_zone_reserve(struct rte_eth_dev *dev, uint32_t size,
 	const struct rte_memzone *mz;
 
 	snprintf(z_name, sizeof(z_name), "%s_%d_%s",
-		 dev->data->drv_name, dev->data->port_id, post_string);
+		 dev->device->driver->name, dev->data->port_id, post_string);
 
 	mz = rte_memzone_lookup(z_name);
 	if (!reuse) {
diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c
index 7bd29fa..e404b77 100644
--- a/drivers/net/xenvirt/rte_eth_xenvirt.c
+++ b/drivers/net/xenvirt/rte_eth_xenvirt.c
@@ -672,7 +672,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 
 	eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
 	eth_dev->data->kdrv = RTE_KDRV_NONE;
-	eth_dev->data->drv_name = pmd_xenvirt_drv.driver.name;
 	eth_dev->data->numa_node = numa_node;
 
 	eth_dev->rx_pkt_burst = eth_xenvirt_rx;
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index d257406..f5378a4 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -753,13 +753,13 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	if ((dev_conf->intr_conf.lsc == 1) &&
 		(!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
 			RTE_PMD_DEBUG_TRACE("driver %s does not support lsc\n",
-					dev->data->drv_name);
+					dev->device->driver->name);
 			return -EINVAL;
 	}
 	if ((dev_conf->intr_conf.rmv == 1) &&
 	    (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_RMV))) {
 		RTE_PMD_DEBUG_TRACE("driver %s does not support rmv\n",
-				    dev->data->drv_name);
+				    dev->device->driver->name);
 		return -EINVAL;
 	}
 
@@ -1900,7 +1900,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 
 	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
 	(*dev->dev_ops->dev_infos_get)(dev, dev_info);
-	dev_info->driver_name = dev->data->drv_name;
+	dev_info->driver_name = dev->device->driver->name;
 	dev_info->nb_rx_queues = dev->data->nb_rx_queues;
 	dev_info->nb_tx_queues = dev->data->nb_tx_queues;
 }
@@ -2789,7 +2789,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->data->drv_name, ring_name,
+		 dev->device->driver->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 d1297a5..00dc063 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1674,7 +1674,6 @@ struct rte_eth_dev_data {
 	uint32_t dev_flags; /**< Capabilities */
 	enum rte_kernel_driver kdrv;    /**< Kernel driver passthrough */
 	int numa_node;  /**< NUMA node connection */
-	const char *drv_name;   /**< Driver name */
 };
 
 /** Device supports hotplug detach */
diff --git a/lib/librte_ether/rte_ethdev_pci.h b/lib/librte_ether/rte_ethdev_pci.h
index d3bc03c..69aab03 100644
--- a/lib/librte_ether/rte_ethdev_pci.h
+++ b/lib/librte_ether/rte_ethdev_pci.h
@@ -69,7 +69,6 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev,
 
 	eth_dev->data->kdrv = pci_dev->kdrv;
 	eth_dev->data->numa_node = pci_dev->device.numa_node;
-	eth_dev->data->drv_name = pci_dev->driver->driver.name;
 }
 
 /**
diff --git a/lib/librte_ether/rte_ethdev_vdev.h b/lib/librte_ether/rte_ethdev_vdev.h
index fa2cb61..4d2c3e2 100644
--- a/lib/librte_ether/rte_ethdev_vdev.h
+++ b/lib/librte_ether/rte_ethdev_vdev.h
@@ -77,7 +77,6 @@ rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
 
 	eth_dev->data->kdrv = RTE_KDRV_NONE;
 	eth_dev->data->numa_node = dev->device.numa_node;
-	eth_dev->data->drv_name = dev->device.driver->name;
 	return eth_dev;
 }
 
-- 
2.9.4

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [dpdk-dev] [PATCH v3 2/3] net/ring: create vdev from PMD specific API
  2017-06-09 17:51     ` [dpdk-dev] [PATCH v3 2/3] net/ring: create vdev from PMD specific API Ferruh Yigit
@ 2017-06-12 13:25       ` Bruce Richardson
  2017-06-12 14:08         ` Ferruh Yigit
  0 siblings, 1 reply; 24+ messages in thread
From: Bruce Richardson @ 2017-06-12 13:25 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev

On Fri, Jun 09, 2017 at 06:51:19PM +0100, Ferruh Yigit wrote:
> When ring PMD created via PMD specific API instead of EAL abstraction
> it is missing the virtual device creation done by EAL vdev.
> 
> And this makes eth_dev unusable exact same as other PMDs used, because
> of some missing fields, like rte_device->name.
> 
> Now API creates a virtual device and sets proper fields, not all, and it
> still won't be linked in the virtual device list eal keeps track. But
> makes PMD usable in usual manner.
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---

Is a better fix not to have this API call into the EAL to create the
vdev and add it to the lists as with other vdevs? [If it makes it easier,
the extra parameters passed in to the library-local function can be
saved in a context that can be accessed when the EAL calls back into the
driver, rather than having to flatten them out into devargs and re-parsed
again.]

Regards,
/Bruce

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [dpdk-dev] [PATCH v3 2/3] net/ring: create vdev from PMD specific API
  2017-06-12 13:25       ` Bruce Richardson
@ 2017-06-12 14:08         ` Ferruh Yigit
  2017-06-12 14:19           ` Bruce Richardson
  0 siblings, 1 reply; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-12 14:08 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On 6/12/2017 2:25 PM, Bruce Richardson wrote:
> On Fri, Jun 09, 2017 at 06:51:19PM +0100, Ferruh Yigit wrote:
>> When ring PMD created via PMD specific API instead of EAL abstraction
>> it is missing the virtual device creation done by EAL vdev.
>>
>> And this makes eth_dev unusable exact same as other PMDs used, because
>> of some missing fields, like rte_device->name.
>>
>> Now API creates a virtual device and sets proper fields, not all, and it
>> still won't be linked in the virtual device list eal keeps track. But
>> makes PMD usable in usual manner.
>>
>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>> ---
> 
> Is a better fix not to have this API call into the EAL to create the
> vdev and add it to the lists as with other vdevs? [If it makes it easier,
> the extra parameters passed in to the library-local function can be
> saved in a context that can be accessed when the EAL calls back into the
> driver, rather than having to flatten them out into devargs and re-parsed
> again.]

Let me send the patch as suggested.

Using EAL API is better idea I think, but overall this ring PMD looked
like hack after changes.

Please check the latest patch, if we want to keep ring PMD API, perhaps
we should postpone removing drv_name patch.

> 
> Regards,
> /Bruce
> 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [dpdk-dev] [PATCH v4 1/3] net/ring: set ethernet device field
  2017-06-09 17:51   ` [dpdk-dev] [PATCH v3 1/3] net/ring: set ethernet device field Ferruh Yigit
  2017-06-09 17:51     ` [dpdk-dev] [PATCH v3 2/3] net/ring: create vdev from PMD specific API Ferruh Yigit
  2017-06-09 17:51     ` [dpdk-dev] [PATCH v3 3/3] ethdev: remove driver name from device private data Ferruh Yigit
@ 2017-06-12 14:13     ` Ferruh Yigit
  2017-06-12 14:13       ` [dpdk-dev] [PATCH v4 2/3] net/ring: use EAL APIs in PMD specific API Ferruh Yigit
                         ` (2 more replies)
  2 siblings, 3 replies; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-12 14:13 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Ferruh Yigit

The eth_dev->device link was missing for ring PMD, adding it.

This is to generalize rte_device access from eth_dev.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/ring/rte_eth_ring.c | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index d4dce95..6feb137 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -263,7 +263,8 @@ static int
 do_eth_dev_ring_create(const char *name,
 		struct rte_ring * const rx_queues[], const unsigned nb_rx_queues,
 		struct rte_ring *const tx_queues[], const unsigned nb_tx_queues,
-		const unsigned numa_node, enum dev_action action)
+		const unsigned int numa_node, enum dev_action action,
+		struct rte_eth_dev **eth_dev_p)
 {
 	struct rte_eth_dev_data *data = NULL;
 	struct pmd_internals *internals = NULL;
@@ -349,6 +350,8 @@ do_eth_dev_ring_create(const char *name,
 	eth_dev->rx_pkt_burst = eth_ring_rx;
 	eth_dev->tx_pkt_burst = eth_ring_tx;
 
+	*eth_dev_p = eth_dev;
+
 	return data->port_id;
 
 error:
@@ -369,6 +372,8 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		const unsigned nb_tx_queues,
 		const unsigned numa_node)
 {
+	struct rte_eth_dev *eth_dev = NULL;
+
 	/* do some parameter checking */
 	if (rx_queues == NULL && nb_rx_queues > 0) {
 		rte_errno = EINVAL;
@@ -384,7 +389,8 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 	}
 
 	return do_eth_dev_ring_create(name, rx_queues, nb_rx_queues,
-			tx_queues, nb_tx_queues, numa_node, DEV_ATTACH);
+			tx_queues, nb_tx_queues, numa_node, DEV_ATTACH,
+			&eth_dev);
 }
 
 int
@@ -396,7 +402,7 @@ rte_eth_from_ring(struct rte_ring *r)
 
 static int
 eth_dev_ring_create(const char *name, const unsigned numa_node,
-		enum dev_action action)
+		enum dev_action action, struct rte_eth_dev **eth_dev)
 {
 	/* rx and tx are so-called from point of view of first port.
 	 * They are inverted from the point of view of second port
@@ -418,7 +424,7 @@ eth_dev_ring_create(const char *name, const unsigned numa_node,
 	}
 
 	if (do_eth_dev_ring_create(name, rxtx, num_rings, rxtx, num_rings,
-		numa_node, action) < 0)
+		numa_node, action, eth_dev) < 0)
 		return -1;
 
 	return 0;
@@ -508,6 +514,7 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 	struct rte_kvargs *kvlist = NULL;
 	int ret = 0;
 	struct node_action_list *info = NULL;
+	struct rte_eth_dev *eth_dev = NULL;
 
 	name = rte_vdev_device_name(dev);
 	params = rte_vdev_device_args(dev);
@@ -515,12 +522,13 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 	RTE_LOG(INFO, PMD, "Initializing pmd_ring for %s\n", name);
 
 	if (params == NULL || params[0] == '\0') {
-		ret = eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE);
+		ret = eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE,
+				&eth_dev);
 		if (ret == -1) {
 			RTE_LOG(INFO, PMD,
 				"Attach to pmd_ring for %s\n", name);
 			ret = eth_dev_ring_create(name, rte_socket_id(),
-						  DEV_ATTACH);
+						  DEV_ATTACH, &eth_dev);
 		}
 	}
 	else {
@@ -530,13 +538,13 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 			RTE_LOG(INFO, PMD, "Ignoring unsupported parameters when creating"
 					" rings-backed ethernet device\n");
 			ret = eth_dev_ring_create(name, rte_socket_id(),
-						  DEV_CREATE);
+						  DEV_CREATE, &eth_dev);
 			if (ret == -1) {
 				RTE_LOG(INFO, PMD,
 					"Attach to pmd_ring for %s\n",
 					name);
 				ret = eth_dev_ring_create(name, rte_socket_id(),
-							  DEV_ATTACH);
+							  DEV_ATTACH, &eth_dev);
 			}
 			return ret;
 		} else {
@@ -560,7 +568,8 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 			for (info->count = 0; info->count < info->total; info->count++) {
 				ret = eth_dev_ring_create(info->list[info->count].name,
 							  info->list[info->count].node,
-							  info->list[info->count].action);
+							  info->list[info->count].action,
+							  &eth_dev);
 				if ((ret == -1) &&
 				    (info->list[info->count].action == DEV_CREATE)) {
 					RTE_LOG(INFO, PMD,
@@ -568,12 +577,16 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 						name);
 					ret = eth_dev_ring_create(name,
 							info->list[info->count].node,
-							DEV_ATTACH);
+							DEV_ATTACH,
+							&eth_dev);
 				}
 			}
 		}
 	}
 
+	if (eth_dev)
+		eth_dev->device = &dev->device;
+
 out_free:
 	rte_kvargs_free(kvlist);
 	rte_free(info);
-- 
2.9.4

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [dpdk-dev] [PATCH v4 2/3] net/ring: use EAL APIs in PMD specific API
  2017-06-12 14:13     ` [dpdk-dev] [PATCH v4 1/3] net/ring: set ethernet device field Ferruh Yigit
@ 2017-06-12 14:13       ` Ferruh Yigit
  2017-06-12 14:20         ` Bruce Richardson
  2017-06-12 14:13       ` [dpdk-dev] [PATCH v4 3/3] ethdev: remove driver name from device private data Ferruh Yigit
  2017-06-12 15:25       ` [dpdk-dev] [PATCH v5 1/3] net/ring: set ethernet device field Ferruh Yigit
  2 siblings, 1 reply; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-12 14:13 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Ferruh Yigit

When ring PMD created via PMD specific API instead of EAL abstraction
it is missing the virtual device creation done by EAL vdev.

And this makes eth_dev unusable exact same as other PMDs used, because
of some missing fields, like rte_device->name.

Now API calls EAL APIs to create ring PMDs.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/ring/rte_eth_ring.c | 75 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 69 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 6feb137..d656b55 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -45,12 +45,22 @@
 #define ETH_RING_NUMA_NODE_ACTION_ARG	"nodeaction"
 #define ETH_RING_ACTION_CREATE		"CREATE"
 #define ETH_RING_ACTION_ATTACH		"ATTACH"
+#define ETH_RING_INTERNAL_ARG		"internal"
 
 static const char *valid_arguments[] = {
 	ETH_RING_NUMA_NODE_ACTION_ARG,
+	ETH_RING_INTERNAL_ARG,
 	NULL
 };
 
+struct ring_internal_args {
+		struct rte_ring * const *rx_queues;
+		const unsigned nb_rx_queues;
+		struct rte_ring * const *tx_queues;
+		const unsigned nb_tx_queues;
+		const unsigned numa_node;
+};
+
 enum dev_action {
 	DEV_CREATE,
 	DEV_ATTACH
@@ -372,7 +382,17 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		const unsigned nb_tx_queues,
 		const unsigned numa_node)
 {
-	struct rte_eth_dev *eth_dev = NULL;
+	struct ring_internal_args args = {
+		.rx_queues = rx_queues,
+		.nb_rx_queues = nb_rx_queues,
+		.tx_queues = tx_queues,
+		.nb_tx_queues = nb_tx_queues,
+		.numa_node = numa_node,
+	};
+	char args_str[32] = { 0 };
+	char ring_name[32] = { 0 };
+	uint8_t port_id = RTE_MAX_ETHPORTS;
+	int ret;
 
 	/* do some parameter checking */
 	if (rx_queues == NULL && nb_rx_queues > 0) {
@@ -388,9 +408,18 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		return -1;
 	}
 
-	return do_eth_dev_ring_create(name, rx_queues, nb_rx_queues,
-			tx_queues, nb_tx_queues, numa_node, DEV_ATTACH,
-			&eth_dev);
+	snprintf(args_str, 32, "%s=%p", ETH_RING_INTERNAL_ARG, &args);
+	snprintf(ring_name, 32, "net_ring_%s", name);
+
+	ret = rte_vdev_init(ring_name, args_str);
+	if (ret) {
+		rte_errno = EINVAL;
+		return -1;
+	}
+
+	rte_eth_dev_get_port_by_name(ring_name, &port_id);
+
+	return port_id;
 }
 
 int
@@ -508,6 +537,20 @@ static int parse_kvlist (const char *key __rte_unused, const char *value, void *
 }
 
 static int
+parse_internal_args (const char *key __rte_unused, const char *value,
+		void *data)
+{
+	struct ring_internal_args *internal_args = data;
+	void *args;
+
+	sscanf(value, "%p", &args);
+
+	*internal_args = *(struct ring_internal_args *)args;
+
+	return 0;
+}
+
+static int
 rte_pmd_ring_probe(struct rte_vdev_device *dev)
 {
 	const char *name, *params;
@@ -515,6 +558,7 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 	int ret = 0;
 	struct node_action_list *info = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
+	struct ring_internal_args internal_args;
 
 	name = rte_vdev_device_name(dev);
 	params = rte_vdev_device_args(dev);
@@ -530,8 +574,7 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 			ret = eth_dev_ring_create(name, rte_socket_id(),
 						  DEV_ATTACH, &eth_dev);
 		}
-	}
-	else {
+	} else {
 		kvlist = rte_kvargs_parse(params, valid_arguments);
 
 		if (!kvlist) {
@@ -546,7 +589,27 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 				ret = eth_dev_ring_create(name, rte_socket_id(),
 							  DEV_ATTACH, &eth_dev);
 			}
+
+			if (eth_dev)
+				eth_dev->device = &dev->device;
+
 			return ret;
+		}
+
+		if (rte_kvargs_count(kvlist, ETH_RING_INTERNAL_ARG) == 1) {
+			ret = rte_kvargs_process(kvlist, ETH_RING_INTERNAL_ARG,
+						 parse_internal_args,
+						 &internal_args);
+			ret = do_eth_dev_ring_create(name,
+				internal_args.rx_queues,
+				internal_args.nb_rx_queues,
+				internal_args.tx_queues,
+				internal_args.nb_tx_queues,
+				internal_args.numa_node,
+				DEV_ATTACH,
+				&eth_dev);
+			if (ret >= 0)
+				ret = 0;
 		} else {
 			ret = rte_kvargs_count(kvlist, ETH_RING_NUMA_NODE_ACTION_ARG);
 			info = rte_zmalloc("struct node_action_list",
-- 
2.9.4

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [dpdk-dev] [PATCH v4 3/3] ethdev: remove driver name from device private data
  2017-06-12 14:13     ` [dpdk-dev] [PATCH v4 1/3] net/ring: set ethernet device field Ferruh Yigit
  2017-06-12 14:13       ` [dpdk-dev] [PATCH v4 2/3] net/ring: use EAL APIs in PMD specific API Ferruh Yigit
@ 2017-06-12 14:13       ` Ferruh Yigit
  2017-06-12 15:25       ` [dpdk-dev] [PATCH v5 1/3] net/ring: set ethernet device field Ferruh Yigit
  2 siblings, 0 replies; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-12 14:13 UTC (permalink / raw)
  To: Bruce Richardson, Stephen Hurd, Ajit Khaparde, Declan Doherty,
	Rahul Lakkireddy, Hemant Agrawal, Shreyansh Jain, Helin Zhang,
	Jingjing Wu, Wenzhuo Lu, Konstantin Ananyev, Pascal Mazon,
	Shrikrishna Khare, Jianfeng Tan, Thomas Monjalon
  Cc: dev, Ferruh Yigit

rte_driver->name has the driver name and all physical and virtual
devices has access to it.

Previously it was not possible for virtual ethernet devices to access
rte_driver->name field (because eth_dev used to keep only pci_dev),
and it was required to save driver name in the device private struct.

After re-works on bus and vdev, it is possible for all bus types to
access rte_driver.

It is able to remove the driver name from ethdev device private data and
use eth_dev->device->driver->name.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
Acked-by: Jan Blunck <jblunck@infradead.org>
---
 drivers/net/bnxt/bnxt_ethdev.c         | 2 +-
 drivers/net/bonding/rte_eth_bond_api.c | 4 ++--
 drivers/net/cxgbe/sge.c                | 6 +++---
 drivers/net/dpaa2/dpaa2_ethdev.c       | 1 -
 drivers/net/i40e/i40e_ethdev.c         | 3 +--
 drivers/net/i40e/i40e_fdir.c           | 2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c       | 2 +-
 drivers/net/ring/rte_eth_ring.c        | 1 -
 drivers/net/tap/rte_eth_tap.c          | 1 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c   | 2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c  | 1 -
 lib/librte_ether/rte_ethdev.c          | 8 ++++----
 lib/librte_ether/rte_ethdev.h          | 1 -
 lib/librte_ether/rte_ethdev_pci.h      | 1 -
 lib/librte_ether/rte_ethdev_vdev.h     | 1 -
 15 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 79e800b..a2d46ee 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1922,7 +1922,7 @@ static struct rte_pci_driver bnxt_rte_pmd = {
 static bool
 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
 {
-	if (strcmp(dev->data->drv_name, drv->driver.name))
+	if (strcmp(dev->device->driver->name, drv->driver.name))
 		return false;
 
 	return true;
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 36ec65d..164eb59 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -48,11 +48,11 @@ int
 check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev)
 {
 	/* Check valid pointer */
-	if (eth_dev->data->drv_name == NULL)
+	if (eth_dev->device->driver->name == NULL)
 		return -1;
 
 	/* return 0 if driver name matches */
-	return eth_dev->data->drv_name != pmd_bond_drv.driver.name;
+	return eth_dev->device->driver->name != pmd_bond_drv.driver.name;
 }
 
 int
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 9cbd4ec..d088065 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -1691,7 +1691,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 	iq->size = cxgbe_roundup(iq->size, 16);
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 eth_dev->data->drv_name,
+		 eth_dev->device->driver->name,
 		 fwevtq ? "fwq_ring" : "rx_ring",
 		 eth_dev->data->port_id, queue_id);
 	snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
@@ -1745,7 +1745,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 		fl->size = cxgbe_roundup(fl->size, 8);
 
 		snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-			 eth_dev->data->drv_name,
+			 eth_dev->device->driver->name,
 			 fwevtq ? "fwq_ring" : "fl_ring",
 			 eth_dev->data->port_id, queue_id);
 		snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
@@ -1945,7 +1945,7 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
 	nentries = txq->q.size + s->stat_len / sizeof(struct tx_desc);
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 eth_dev->data->drv_name, "tx_ring",
+		 eth_dev->device->driver->name, "tx_ring",
 		 eth_dev->data->port_id, queue_id);
 	snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
 
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 4de1e0c..da309ac 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1464,7 +1464,6 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	eth_dev->dev_ops = &dpaa2_ethdev_ops;
-	eth_dev->data->drv_name = rte_dpaa2_pmd.driver.name;
 
 	eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx;
 	eth_dev->tx_pkt_burst = dpaa2_dev_tx;
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index f614949..d3428b9 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -10738,8 +10738,7 @@ i40e_filter_restore(struct i40e_pf *pf)
 static bool
 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
 {
-	if (strcmp(dev->data->drv_name,
-		   drv->driver.name))
+	if (strcmp(dev->device->driver->name, drv->driver.name))
 		return false;
 
 	return true;
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index ca423d9..a970b56 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -239,7 +239,7 @@ i40e_fdir_setup(struct i40e_pf *pf)
 
 	/* reserve memory for the fdir programming packet */
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d",
-			eth_dev->data->drv_name,
+			eth_dev->device->driver->name,
 			I40E_FDIR_MZ_NAME,
 			eth_dev->data->port_id);
 	mz = i40e_memzone_reserve(z_name, I40E_FDIR_PKT_LEN, SOCKET_ID_ANY);
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 504e951..ebc5467 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4659,7 +4659,7 @@ ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
 static bool
 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
 {
-	if (strcmp(dev->data->drv_name, drv->driver.name))
+	if (strcmp(dev->device->driver->name, drv->driver.name))
 		return false;
 
 	return true;
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index d656b55..2f4d298 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -353,7 +353,6 @@ do_eth_dev_ring_create(const char *name,
 	eth_dev->dev_ops = &ops;
 	data->dev_flags = RTE_ETH_DEV_DETACHABLE;
 	data->kdrv = RTE_KDRV_NONE;
-	data->drv_name = pmd_ring_drv.driver.name;
 	data->numa_node = numa_node;
 
 	/* finally assign rx and tx ops */
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 1bb660e..305f018 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -1220,7 +1220,6 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
 	data->dev_private = pmd;
 	data->dev_flags = RTE_ETH_DEV_DETACHABLE | RTE_ETH_DEV_INTR_LSC;
 	data->numa_node = numa_node;
-	data->drv_name = pmd_tap_drv.driver.name;
 
 	data->dev_link = pmd_link;
 	data->mac_addrs = &pmd->eth_addr;
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index ee48a9e..292a671 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -141,7 +141,7 @@ gpa_zone_reserve(struct rte_eth_dev *dev, uint32_t size,
 	const struct rte_memzone *mz;
 
 	snprintf(z_name, sizeof(z_name), "%s_%d_%s",
-		 dev->data->drv_name, dev->data->port_id, post_string);
+		 dev->device->driver->name, dev->data->port_id, post_string);
 
 	mz = rte_memzone_lookup(z_name);
 	if (!reuse) {
diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c
index 7bd29fa..e404b77 100644
--- a/drivers/net/xenvirt/rte_eth_xenvirt.c
+++ b/drivers/net/xenvirt/rte_eth_xenvirt.c
@@ -672,7 +672,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 
 	eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
 	eth_dev->data->kdrv = RTE_KDRV_NONE;
-	eth_dev->data->drv_name = pmd_xenvirt_drv.driver.name;
 	eth_dev->data->numa_node = numa_node;
 
 	eth_dev->rx_pkt_burst = eth_xenvirt_rx;
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 9227ecc..81a45c0 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -752,13 +752,13 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	if ((dev_conf->intr_conf.lsc == 1) &&
 		(!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
 			RTE_PMD_DEBUG_TRACE("driver %s does not support lsc\n",
-					dev->data->drv_name);
+					dev->device->driver->name);
 			return -EINVAL;
 	}
 	if ((dev_conf->intr_conf.rmv == 1) &&
 	    (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_RMV))) {
 		RTE_PMD_DEBUG_TRACE("driver %s does not support rmv\n",
-				    dev->data->drv_name);
+				    dev->device->driver->name);
 		return -EINVAL;
 	}
 
@@ -1899,7 +1899,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 
 	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
 	(*dev->dev_ops->dev_infos_get)(dev, dev_info);
-	dev_info->driver_name = dev->data->drv_name;
+	dev_info->driver_name = dev->device->driver->name;
 	dev_info->nb_rx_queues = dev->data->nb_rx_queues;
 	dev_info->nb_tx_queues = dev->data->nb_tx_queues;
 }
@@ -2788,7 +2788,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->data->drv_name, ring_name,
+		 dev->device->driver->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 b0d2353..050a425 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1674,7 +1674,6 @@ struct rte_eth_dev_data {
 	uint32_t dev_flags; /**< Capabilities */
 	enum rte_kernel_driver kdrv;    /**< Kernel driver passthrough */
 	int numa_node;  /**< NUMA node connection */
-	const char *drv_name;   /**< Driver name */
 };
 
 /** Device supports hotplug detach */
diff --git a/lib/librte_ether/rte_ethdev_pci.h b/lib/librte_ether/rte_ethdev_pci.h
index d3bc03c..69aab03 100644
--- a/lib/librte_ether/rte_ethdev_pci.h
+++ b/lib/librte_ether/rte_ethdev_pci.h
@@ -69,7 +69,6 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev,
 
 	eth_dev->data->kdrv = pci_dev->kdrv;
 	eth_dev->data->numa_node = pci_dev->device.numa_node;
-	eth_dev->data->drv_name = pci_dev->driver->driver.name;
 }
 
 /**
diff --git a/lib/librte_ether/rte_ethdev_vdev.h b/lib/librte_ether/rte_ethdev_vdev.h
index fa2cb61..4d2c3e2 100644
--- a/lib/librte_ether/rte_ethdev_vdev.h
+++ b/lib/librte_ether/rte_ethdev_vdev.h
@@ -77,7 +77,6 @@ rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
 
 	eth_dev->data->kdrv = RTE_KDRV_NONE;
 	eth_dev->data->numa_node = dev->device.numa_node;
-	eth_dev->data->drv_name = dev->device.driver->name;
 	return eth_dev;
 }
 
-- 
2.9.4

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [dpdk-dev] [PATCH v3 2/3] net/ring: create vdev from PMD specific API
  2017-06-12 14:08         ` Ferruh Yigit
@ 2017-06-12 14:19           ` Bruce Richardson
  2017-06-12 14:38             ` Ferruh Yigit
  0 siblings, 1 reply; 24+ messages in thread
From: Bruce Richardson @ 2017-06-12 14:19 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev

On Mon, Jun 12, 2017 at 03:08:31PM +0100, Ferruh Yigit wrote:
> On 6/12/2017 2:25 PM, Bruce Richardson wrote:
> > On Fri, Jun 09, 2017 at 06:51:19PM +0100, Ferruh Yigit wrote:
> >> When ring PMD created via PMD specific API instead of EAL abstraction
> >> it is missing the virtual device creation done by EAL vdev.
> >>
> >> And this makes eth_dev unusable exact same as other PMDs used, because
> >> of some missing fields, like rte_device->name.
> >>
> >> Now API creates a virtual device and sets proper fields, not all, and it
> >> still won't be linked in the virtual device list eal keeps track. But
> >> makes PMD usable in usual manner.
> >>
> >> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> >> ---
> > 
> > Is a better fix not to have this API call into the EAL to create the
> > vdev and add it to the lists as with other vdevs? [If it makes it easier,
> > the extra parameters passed in to the library-local function can be
> > saved in a context that can be accessed when the EAL calls back into the
> > driver, rather than having to flatten them out into devargs and re-parsed
> > again.]
> 
> Let me send the patch as suggested.
> 
> Using EAL API is better idea I think, but overall this ring PMD looked
> like hack after changes.
> 
> Please check the latest patch, if we want to keep ring PMD API, perhaps
> we should postpone removing drv_name patch.
> 
The new patch looks ok to me. I actually don't think it looks that
hacked together. :-)

/Bruce

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [dpdk-dev] [PATCH v4 2/3] net/ring: use EAL APIs in PMD specific API
  2017-06-12 14:13       ` [dpdk-dev] [PATCH v4 2/3] net/ring: use EAL APIs in PMD specific API Ferruh Yigit
@ 2017-06-12 14:20         ` Bruce Richardson
  0 siblings, 0 replies; 24+ messages in thread
From: Bruce Richardson @ 2017-06-12 14:20 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev

On Mon, Jun 12, 2017 at 03:13:53PM +0100, Ferruh Yigit wrote:
> When ring PMD created via PMD specific API instead of EAL abstraction
> it is missing the virtual device creation done by EAL vdev.
> 
> And this makes eth_dev unusable exact same as other PMDs used, because
> of some missing fields, like rte_device->name.
> 
> Now API calls EAL APIs to create ring PMDs.
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [dpdk-dev] [PATCH v3 2/3] net/ring: create vdev from PMD specific API
  2017-06-12 14:19           ` Bruce Richardson
@ 2017-06-12 14:38             ` Ferruh Yigit
  0 siblings, 0 replies; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-12 14:38 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On 6/12/2017 3:19 PM, Bruce Richardson wrote:
> On Mon, Jun 12, 2017 at 03:08:31PM +0100, Ferruh Yigit wrote:
>> On 6/12/2017 2:25 PM, Bruce Richardson wrote:
>>> On Fri, Jun 09, 2017 at 06:51:19PM +0100, Ferruh Yigit wrote:
>>>> When ring PMD created via PMD specific API instead of EAL abstraction
>>>> it is missing the virtual device creation done by EAL vdev.
>>>>
>>>> And this makes eth_dev unusable exact same as other PMDs used, because
>>>> of some missing fields, like rte_device->name.
>>>>
>>>> Now API creates a virtual device and sets proper fields, not all, and it
>>>> still won't be linked in the virtual device list eal keeps track. But
>>>> makes PMD usable in usual manner.
>>>>
>>>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>>>> ---
>>>
>>> Is a better fix not to have this API call into the EAL to create the
>>> vdev and add it to the lists as with other vdevs? [If it makes it easier,
>>> the extra parameters passed in to the library-local function can be
>>> saved in a context that can be accessed when the EAL calls back into the
>>> driver, rather than having to flatten them out into devargs and re-parsed
>>> again.]
>>
>> Let me send the patch as suggested.
>>
>> Using EAL API is better idea I think, but overall this ring PMD looked
>> like hack after changes.
>>
>> Please check the latest patch, if we want to keep ring PMD API, perhaps
>> we should postpone removing drv_name patch.
>>
> The new patch looks ok to me. I actually don't think it looks that
> hacked together. :-)

That is good, if you are happy with the patch, I guess we can get the
patchset.

Thanks,
ferruh

> 
> /Bruce
> 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [dpdk-dev] [PATCH v5 1/3] net/ring: set ethernet device field
  2017-06-12 14:13     ` [dpdk-dev] [PATCH v4 1/3] net/ring: set ethernet device field Ferruh Yigit
  2017-06-12 14:13       ` [dpdk-dev] [PATCH v4 2/3] net/ring: use EAL APIs in PMD specific API Ferruh Yigit
  2017-06-12 14:13       ` [dpdk-dev] [PATCH v4 3/3] ethdev: remove driver name from device private data Ferruh Yigit
@ 2017-06-12 15:25       ` Ferruh Yigit
  2017-06-12 15:25         ` [dpdk-dev] [PATCH v5 2/3] net/ring: use EAL APIs in PMD specific API Ferruh Yigit
                           ` (2 more replies)
  2 siblings, 3 replies; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-12 15:25 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Ferruh Yigit

The eth_dev->device link was missing for ring PMD, adding it.

This is to generalize rte_device access from eth_dev.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/ring/rte_eth_ring.c | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index d4dce95..6feb137 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -263,7 +263,8 @@ static int
 do_eth_dev_ring_create(const char *name,
 		struct rte_ring * const rx_queues[], const unsigned nb_rx_queues,
 		struct rte_ring *const tx_queues[], const unsigned nb_tx_queues,
-		const unsigned numa_node, enum dev_action action)
+		const unsigned int numa_node, enum dev_action action,
+		struct rte_eth_dev **eth_dev_p)
 {
 	struct rte_eth_dev_data *data = NULL;
 	struct pmd_internals *internals = NULL;
@@ -349,6 +350,8 @@ do_eth_dev_ring_create(const char *name,
 	eth_dev->rx_pkt_burst = eth_ring_rx;
 	eth_dev->tx_pkt_burst = eth_ring_tx;
 
+	*eth_dev_p = eth_dev;
+
 	return data->port_id;
 
 error:
@@ -369,6 +372,8 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		const unsigned nb_tx_queues,
 		const unsigned numa_node)
 {
+	struct rte_eth_dev *eth_dev = NULL;
+
 	/* do some parameter checking */
 	if (rx_queues == NULL && nb_rx_queues > 0) {
 		rte_errno = EINVAL;
@@ -384,7 +389,8 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 	}
 
 	return do_eth_dev_ring_create(name, rx_queues, nb_rx_queues,
-			tx_queues, nb_tx_queues, numa_node, DEV_ATTACH);
+			tx_queues, nb_tx_queues, numa_node, DEV_ATTACH,
+			&eth_dev);
 }
 
 int
@@ -396,7 +402,7 @@ rte_eth_from_ring(struct rte_ring *r)
 
 static int
 eth_dev_ring_create(const char *name, const unsigned numa_node,
-		enum dev_action action)
+		enum dev_action action, struct rte_eth_dev **eth_dev)
 {
 	/* rx and tx are so-called from point of view of first port.
 	 * They are inverted from the point of view of second port
@@ -418,7 +424,7 @@ eth_dev_ring_create(const char *name, const unsigned numa_node,
 	}
 
 	if (do_eth_dev_ring_create(name, rxtx, num_rings, rxtx, num_rings,
-		numa_node, action) < 0)
+		numa_node, action, eth_dev) < 0)
 		return -1;
 
 	return 0;
@@ -508,6 +514,7 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 	struct rte_kvargs *kvlist = NULL;
 	int ret = 0;
 	struct node_action_list *info = NULL;
+	struct rte_eth_dev *eth_dev = NULL;
 
 	name = rte_vdev_device_name(dev);
 	params = rte_vdev_device_args(dev);
@@ -515,12 +522,13 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 	RTE_LOG(INFO, PMD, "Initializing pmd_ring for %s\n", name);
 
 	if (params == NULL || params[0] == '\0') {
-		ret = eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE);
+		ret = eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE,
+				&eth_dev);
 		if (ret == -1) {
 			RTE_LOG(INFO, PMD,
 				"Attach to pmd_ring for %s\n", name);
 			ret = eth_dev_ring_create(name, rte_socket_id(),
-						  DEV_ATTACH);
+						  DEV_ATTACH, &eth_dev);
 		}
 	}
 	else {
@@ -530,13 +538,13 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 			RTE_LOG(INFO, PMD, "Ignoring unsupported parameters when creating"
 					" rings-backed ethernet device\n");
 			ret = eth_dev_ring_create(name, rte_socket_id(),
-						  DEV_CREATE);
+						  DEV_CREATE, &eth_dev);
 			if (ret == -1) {
 				RTE_LOG(INFO, PMD,
 					"Attach to pmd_ring for %s\n",
 					name);
 				ret = eth_dev_ring_create(name, rte_socket_id(),
-							  DEV_ATTACH);
+							  DEV_ATTACH, &eth_dev);
 			}
 			return ret;
 		} else {
@@ -560,7 +568,8 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 			for (info->count = 0; info->count < info->total; info->count++) {
 				ret = eth_dev_ring_create(info->list[info->count].name,
 							  info->list[info->count].node,
-							  info->list[info->count].action);
+							  info->list[info->count].action,
+							  &eth_dev);
 				if ((ret == -1) &&
 				    (info->list[info->count].action == DEV_CREATE)) {
 					RTE_LOG(INFO, PMD,
@@ -568,12 +577,16 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 						name);
 					ret = eth_dev_ring_create(name,
 							info->list[info->count].node,
-							DEV_ATTACH);
+							DEV_ATTACH,
+							&eth_dev);
 				}
 			}
 		}
 	}
 
+	if (eth_dev)
+		eth_dev->device = &dev->device;
+
 out_free:
 	rte_kvargs_free(kvlist);
 	rte_free(info);
-- 
2.9.4

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [dpdk-dev] [PATCH v5 2/3] net/ring: use EAL APIs in PMD specific API
  2017-06-12 15:25       ` [dpdk-dev] [PATCH v5 1/3] net/ring: set ethernet device field Ferruh Yigit
@ 2017-06-12 15:25         ` Ferruh Yigit
  2017-06-12 15:25         ` [dpdk-dev] [PATCH v5 3/3] ethdev: remove driver name from device private data Ferruh Yigit
  2017-06-12 15:37         ` [dpdk-dev] [PATCH v5 1/3] net/ring: set ethernet device field Ferruh Yigit
  2 siblings, 0 replies; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-12 15:25 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Ferruh Yigit

When ring PMD created via PMD specific API instead of EAL abstraction
it is missing the virtual device creation done by EAL vdev.

And this makes eth_dev unusable exact same as other PMDs used, because
of some missing fields, like rte_device->name.

Now API calls EAL APIs to create ring PMDs.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---

v5:
* fix build error
* add sanity check where addr get
---
 drivers/net/ring/rte_eth_ring.c | 83 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 77 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 6feb137..73ec2e4 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -45,12 +45,23 @@
 #define ETH_RING_NUMA_NODE_ACTION_ARG	"nodeaction"
 #define ETH_RING_ACTION_CREATE		"CREATE"
 #define ETH_RING_ACTION_ATTACH		"ATTACH"
+#define ETH_RING_INTERNAL_ARG		"internal"
 
 static const char *valid_arguments[] = {
 	ETH_RING_NUMA_NODE_ACTION_ARG,
+	ETH_RING_INTERNAL_ARG,
 	NULL
 };
 
+struct ring_internal_args {
+	struct rte_ring * const *rx_queues;
+	const unsigned int nb_rx_queues;
+	struct rte_ring * const *tx_queues;
+	const unsigned int nb_tx_queues;
+	const unsigned int numa_node;
+	void *addr; /* self addr for sanity check */
+};
+
 enum dev_action {
 	DEV_CREATE,
 	DEV_ATTACH
@@ -372,7 +383,18 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		const unsigned nb_tx_queues,
 		const unsigned numa_node)
 {
-	struct rte_eth_dev *eth_dev = NULL;
+	struct ring_internal_args args = {
+		.rx_queues = rx_queues,
+		.nb_rx_queues = nb_rx_queues,
+		.tx_queues = tx_queues,
+		.nb_tx_queues = nb_tx_queues,
+		.numa_node = numa_node,
+		.addr = &args,
+	};
+	char args_str[32] = { 0 };
+	char ring_name[32] = { 0 };
+	uint8_t port_id = RTE_MAX_ETHPORTS;
+	int ret;
 
 	/* do some parameter checking */
 	if (rx_queues == NULL && nb_rx_queues > 0) {
@@ -388,9 +410,18 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		return -1;
 	}
 
-	return do_eth_dev_ring_create(name, rx_queues, nb_rx_queues,
-			tx_queues, nb_tx_queues, numa_node, DEV_ATTACH,
-			&eth_dev);
+	snprintf(args_str, 32, "%s=%p", ETH_RING_INTERNAL_ARG, &args);
+	snprintf(ring_name, 32, "net_ring_%s", name);
+
+	ret = rte_vdev_init(ring_name, args_str);
+	if (ret) {
+		rte_errno = EINVAL;
+		return -1;
+	}
+
+	rte_eth_dev_get_port_by_name(ring_name, &port_id);
+
+	return port_id;
 }
 
 int
@@ -508,6 +539,23 @@ static int parse_kvlist (const char *key __rte_unused, const char *value, void *
 }
 
 static int
+parse_internal_args(const char *key __rte_unused, const char *value,
+		void *data)
+{
+	struct ring_internal_args **internal_args = data;
+	void *args;
+
+	sscanf(value, "%p", &args);
+
+	*internal_args = args;
+
+	if ((*internal_args)->addr != args)
+		return -1;
+
+	return 0;
+}
+
+static int
 rte_pmd_ring_probe(struct rte_vdev_device *dev)
 {
 	const char *name, *params;
@@ -515,6 +563,7 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 	int ret = 0;
 	struct node_action_list *info = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
+	struct ring_internal_args *internal_args;
 
 	name = rte_vdev_device_name(dev);
 	params = rte_vdev_device_args(dev);
@@ -530,8 +579,7 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 			ret = eth_dev_ring_create(name, rte_socket_id(),
 						  DEV_ATTACH, &eth_dev);
 		}
-	}
-	else {
+	} else {
 		kvlist = rte_kvargs_parse(params, valid_arguments);
 
 		if (!kvlist) {
@@ -546,7 +594,30 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 				ret = eth_dev_ring_create(name, rte_socket_id(),
 							  DEV_ATTACH, &eth_dev);
 			}
+
+			if (eth_dev)
+				eth_dev->device = &dev->device;
+
 			return ret;
+		}
+
+		if (rte_kvargs_count(kvlist, ETH_RING_INTERNAL_ARG) == 1) {
+			ret = rte_kvargs_process(kvlist, ETH_RING_INTERNAL_ARG,
+						 parse_internal_args,
+						 &internal_args);
+			if (ret < 0)
+				goto out_free;
+
+			ret = do_eth_dev_ring_create(name,
+				internal_args->rx_queues,
+				internal_args->nb_rx_queues,
+				internal_args->tx_queues,
+				internal_args->nb_tx_queues,
+				internal_args->numa_node,
+				DEV_ATTACH,
+				&eth_dev);
+			if (ret >= 0)
+				ret = 0;
 		} else {
 			ret = rte_kvargs_count(kvlist, ETH_RING_NUMA_NODE_ACTION_ARG);
 			info = rte_zmalloc("struct node_action_list",
-- 
2.9.4

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [dpdk-dev] [PATCH v5 3/3] ethdev: remove driver name from device private data
  2017-06-12 15:25       ` [dpdk-dev] [PATCH v5 1/3] net/ring: set ethernet device field Ferruh Yigit
  2017-06-12 15:25         ` [dpdk-dev] [PATCH v5 2/3] net/ring: use EAL APIs in PMD specific API Ferruh Yigit
@ 2017-06-12 15:25         ` Ferruh Yigit
  2017-06-12 15:37         ` [dpdk-dev] [PATCH v5 1/3] net/ring: set ethernet device field Ferruh Yigit
  2 siblings, 0 replies; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-12 15:25 UTC (permalink / raw)
  To: Bruce Richardson, Stephen Hurd, Ajit Khaparde, Declan Doherty,
	Rahul Lakkireddy, Hemant Agrawal, Shreyansh Jain, Helin Zhang,
	Jingjing Wu, Wenzhuo Lu, Konstantin Ananyev, Pascal Mazon,
	Shrikrishna Khare, Jianfeng Tan, Thomas Monjalon
  Cc: dev, Ferruh Yigit

rte_driver->name has the driver name and all physical and virtual
devices has access to it.

Previously it was not possible for virtual ethernet devices to access
rte_driver->name field (because eth_dev used to keep only pci_dev),
and it was required to save driver name in the device private struct.

After re-works on bus and vdev, it is possible for all bus types to
access rte_driver.

It is able to remove the driver name from ethdev device private data and
use eth_dev->device->driver->name.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
Acked-by: Jan Blunck <jblunck@infradead.org>
---
 drivers/net/bnxt/bnxt_ethdev.c         | 2 +-
 drivers/net/bonding/rte_eth_bond_api.c | 4 ++--
 drivers/net/cxgbe/sge.c                | 6 +++---
 drivers/net/dpaa2/dpaa2_ethdev.c       | 1 -
 drivers/net/i40e/i40e_ethdev.c         | 3 +--
 drivers/net/i40e/i40e_fdir.c           | 2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c       | 2 +-
 drivers/net/ring/rte_eth_ring.c        | 1 -
 drivers/net/tap/rte_eth_tap.c          | 1 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c   | 2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c  | 1 -
 lib/librte_ether/rte_ethdev.c          | 8 ++++----
 lib/librte_ether/rte_ethdev.h          | 1 -
 lib/librte_ether/rte_ethdev_pci.h      | 1 -
 lib/librte_ether/rte_ethdev_vdev.h     | 1 -
 15 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 79e800b..a2d46ee 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1922,7 +1922,7 @@ static struct rte_pci_driver bnxt_rte_pmd = {
 static bool
 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
 {
-	if (strcmp(dev->data->drv_name, drv->driver.name))
+	if (strcmp(dev->device->driver->name, drv->driver.name))
 		return false;
 
 	return true;
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 36ec65d..164eb59 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -48,11 +48,11 @@ int
 check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev)
 {
 	/* Check valid pointer */
-	if (eth_dev->data->drv_name == NULL)
+	if (eth_dev->device->driver->name == NULL)
 		return -1;
 
 	/* return 0 if driver name matches */
-	return eth_dev->data->drv_name != pmd_bond_drv.driver.name;
+	return eth_dev->device->driver->name != pmd_bond_drv.driver.name;
 }
 
 int
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 9cbd4ec..d088065 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -1691,7 +1691,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 	iq->size = cxgbe_roundup(iq->size, 16);
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 eth_dev->data->drv_name,
+		 eth_dev->device->driver->name,
 		 fwevtq ? "fwq_ring" : "rx_ring",
 		 eth_dev->data->port_id, queue_id);
 	snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
@@ -1745,7 +1745,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 		fl->size = cxgbe_roundup(fl->size, 8);
 
 		snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-			 eth_dev->data->drv_name,
+			 eth_dev->device->driver->name,
 			 fwevtq ? "fwq_ring" : "fl_ring",
 			 eth_dev->data->port_id, queue_id);
 		snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
@@ -1945,7 +1945,7 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
 	nentries = txq->q.size + s->stat_len / sizeof(struct tx_desc);
 
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 eth_dev->data->drv_name, "tx_ring",
+		 eth_dev->device->driver->name, "tx_ring",
 		 eth_dev->data->port_id, queue_id);
 	snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
 
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 4de1e0c..da309ac 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1464,7 +1464,6 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	eth_dev->dev_ops = &dpaa2_ethdev_ops;
-	eth_dev->data->drv_name = rte_dpaa2_pmd.driver.name;
 
 	eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx;
 	eth_dev->tx_pkt_burst = dpaa2_dev_tx;
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index f614949..d3428b9 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -10738,8 +10738,7 @@ i40e_filter_restore(struct i40e_pf *pf)
 static bool
 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
 {
-	if (strcmp(dev->data->drv_name,
-		   drv->driver.name))
+	if (strcmp(dev->device->driver->name, drv->driver.name))
 		return false;
 
 	return true;
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index ca423d9..a970b56 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -239,7 +239,7 @@ i40e_fdir_setup(struct i40e_pf *pf)
 
 	/* reserve memory for the fdir programming packet */
 	snprintf(z_name, sizeof(z_name), "%s_%s_%d",
-			eth_dev->data->drv_name,
+			eth_dev->device->driver->name,
 			I40E_FDIR_MZ_NAME,
 			eth_dev->data->port_id);
 	mz = i40e_memzone_reserve(z_name, I40E_FDIR_PKT_LEN, SOCKET_ID_ANY);
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 504e951..ebc5467 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4659,7 +4659,7 @@ ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
 static bool
 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
 {
-	if (strcmp(dev->data->drv_name, drv->driver.name))
+	if (strcmp(dev->device->driver->name, drv->driver.name))
 		return false;
 
 	return true;
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 73ec2e4..e3843d4 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -354,7 +354,6 @@ do_eth_dev_ring_create(const char *name,
 	eth_dev->dev_ops = &ops;
 	data->dev_flags = RTE_ETH_DEV_DETACHABLE;
 	data->kdrv = RTE_KDRV_NONE;
-	data->drv_name = pmd_ring_drv.driver.name;
 	data->numa_node = numa_node;
 
 	/* finally assign rx and tx ops */
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 1bb660e..305f018 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -1220,7 +1220,6 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
 	data->dev_private = pmd;
 	data->dev_flags = RTE_ETH_DEV_DETACHABLE | RTE_ETH_DEV_INTR_LSC;
 	data->numa_node = numa_node;
-	data->drv_name = pmd_tap_drv.driver.name;
 
 	data->dev_link = pmd_link;
 	data->mac_addrs = &pmd->eth_addr;
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index ee48a9e..292a671 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -141,7 +141,7 @@ gpa_zone_reserve(struct rte_eth_dev *dev, uint32_t size,
 	const struct rte_memzone *mz;
 
 	snprintf(z_name, sizeof(z_name), "%s_%d_%s",
-		 dev->data->drv_name, dev->data->port_id, post_string);
+		 dev->device->driver->name, dev->data->port_id, post_string);
 
 	mz = rte_memzone_lookup(z_name);
 	if (!reuse) {
diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c
index 7bd29fa..e404b77 100644
--- a/drivers/net/xenvirt/rte_eth_xenvirt.c
+++ b/drivers/net/xenvirt/rte_eth_xenvirt.c
@@ -672,7 +672,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 
 	eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
 	eth_dev->data->kdrv = RTE_KDRV_NONE;
-	eth_dev->data->drv_name = pmd_xenvirt_drv.driver.name;
 	eth_dev->data->numa_node = numa_node;
 
 	eth_dev->rx_pkt_burst = eth_xenvirt_rx;
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 9227ecc..81a45c0 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -752,13 +752,13 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	if ((dev_conf->intr_conf.lsc == 1) &&
 		(!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
 			RTE_PMD_DEBUG_TRACE("driver %s does not support lsc\n",
-					dev->data->drv_name);
+					dev->device->driver->name);
 			return -EINVAL;
 	}
 	if ((dev_conf->intr_conf.rmv == 1) &&
 	    (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_RMV))) {
 		RTE_PMD_DEBUG_TRACE("driver %s does not support rmv\n",
-				    dev->data->drv_name);
+				    dev->device->driver->name);
 		return -EINVAL;
 	}
 
@@ -1899,7 +1899,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 
 	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
 	(*dev->dev_ops->dev_infos_get)(dev, dev_info);
-	dev_info->driver_name = dev->data->drv_name;
+	dev_info->driver_name = dev->device->driver->name;
 	dev_info->nb_rx_queues = dev->data->nb_rx_queues;
 	dev_info->nb_tx_queues = dev->data->nb_tx_queues;
 }
@@ -2788,7 +2788,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->data->drv_name, ring_name,
+		 dev->device->driver->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 b0d2353..050a425 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1674,7 +1674,6 @@ struct rte_eth_dev_data {
 	uint32_t dev_flags; /**< Capabilities */
 	enum rte_kernel_driver kdrv;    /**< Kernel driver passthrough */
 	int numa_node;  /**< NUMA node connection */
-	const char *drv_name;   /**< Driver name */
 };
 
 /** Device supports hotplug detach */
diff --git a/lib/librte_ether/rte_ethdev_pci.h b/lib/librte_ether/rte_ethdev_pci.h
index d3bc03c..69aab03 100644
--- a/lib/librte_ether/rte_ethdev_pci.h
+++ b/lib/librte_ether/rte_ethdev_pci.h
@@ -69,7 +69,6 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev,
 
 	eth_dev->data->kdrv = pci_dev->kdrv;
 	eth_dev->data->numa_node = pci_dev->device.numa_node;
-	eth_dev->data->drv_name = pci_dev->driver->driver.name;
 }
 
 /**
diff --git a/lib/librte_ether/rte_ethdev_vdev.h b/lib/librte_ether/rte_ethdev_vdev.h
index fa2cb61..4d2c3e2 100644
--- a/lib/librte_ether/rte_ethdev_vdev.h
+++ b/lib/librte_ether/rte_ethdev_vdev.h
@@ -77,7 +77,6 @@ rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
 
 	eth_dev->data->kdrv = RTE_KDRV_NONE;
 	eth_dev->data->numa_node = dev->device.numa_node;
-	eth_dev->data->drv_name = dev->device.driver->name;
 	return eth_dev;
 }
 
-- 
2.9.4

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [dpdk-dev] [PATCH v5 1/3] net/ring: set ethernet device field
  2017-06-12 15:25       ` [dpdk-dev] [PATCH v5 1/3] net/ring: set ethernet device field Ferruh Yigit
  2017-06-12 15:25         ` [dpdk-dev] [PATCH v5 2/3] net/ring: use EAL APIs in PMD specific API Ferruh Yigit
  2017-06-12 15:25         ` [dpdk-dev] [PATCH v5 3/3] ethdev: remove driver name from device private data Ferruh Yigit
@ 2017-06-12 15:37         ` Ferruh Yigit
  2 siblings, 0 replies; 24+ messages in thread
From: Ferruh Yigit @ 2017-06-12 15:37 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On 6/12/2017 4:25 PM, Ferruh Yigit wrote:
> The eth_dev->device link was missing for ring PMD, adding it.
> 
> This is to generalize rte_device access from eth_dev.
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>

Series applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2017-06-12 15:37 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-26 11:15 [dpdk-dev] [PATCH] ethdev: remove driver name from device private data Ferruh Yigit
2017-06-06 15:10 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
2017-06-06 15:31   ` Gaëtan Rivet
2017-06-07  4:52   ` Shreyansh Jain
2017-06-07 16:11   ` Jan Blunck
2017-06-09 14:22     ` Ferruh Yigit
2017-06-09 15:49       ` Ferruh Yigit
2017-06-08 20:58   ` Thomas Monjalon
2017-06-09 10:51     ` Ferruh Yigit
2017-06-09 17:51   ` [dpdk-dev] [PATCH v3 1/3] net/ring: set ethernet device field Ferruh Yigit
2017-06-09 17:51     ` [dpdk-dev] [PATCH v3 2/3] net/ring: create vdev from PMD specific API Ferruh Yigit
2017-06-12 13:25       ` Bruce Richardson
2017-06-12 14:08         ` Ferruh Yigit
2017-06-12 14:19           ` Bruce Richardson
2017-06-12 14:38             ` Ferruh Yigit
2017-06-09 17:51     ` [dpdk-dev] [PATCH v3 3/3] ethdev: remove driver name from device private data Ferruh Yigit
2017-06-12 14:13     ` [dpdk-dev] [PATCH v4 1/3] net/ring: set ethernet device field Ferruh Yigit
2017-06-12 14:13       ` [dpdk-dev] [PATCH v4 2/3] net/ring: use EAL APIs in PMD specific API Ferruh Yigit
2017-06-12 14:20         ` Bruce Richardson
2017-06-12 14:13       ` [dpdk-dev] [PATCH v4 3/3] ethdev: remove driver name from device private data Ferruh Yigit
2017-06-12 15:25       ` [dpdk-dev] [PATCH v5 1/3] net/ring: set ethernet device field Ferruh Yigit
2017-06-12 15:25         ` [dpdk-dev] [PATCH v5 2/3] net/ring: use EAL APIs in PMD specific API Ferruh Yigit
2017-06-12 15:25         ` [dpdk-dev] [PATCH v5 3/3] ethdev: remove driver name from device private data Ferruh Yigit
2017-06-12 15:37         ` [dpdk-dev] [PATCH v5 1/3] net/ring: set ethernet device field Ferruh Yigit

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).