[dpdk-dev] [PATCH v8 03/11] vdev: copy device info to eth_dev data

Bernard Iremonger bernard.iremonger at intel.com
Tue Nov 3 14:01:57 CET 2015


initialise dev_flags, driver, kdrv, drv_name and numa_node fields in eth_dev data.

for the following vdevs:
null
ring
pcap
af_packet
xenvirt
mpipe
bonding

Signed-off-by: Bernard Iremonger <bernard.iremonger at intel.com>
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 12 ++++++++----
 drivers/net/bonding/rte_eth_bond_api.c    | 11 +++++++++--
 drivers/net/mpipe/mpipe_tilegx.c          |  7 +++++++
 drivers/net/null/rte_eth_null.c           | 13 +++++++++----
 drivers/net/pcap/rte_eth_pcap.c           | 13 ++++++++-----
 drivers/net/ring/rte_eth_ring.c           | 13 ++++++++-----
 drivers/net/xenvirt/rte_eth_xenvirt.c     |  8 ++++++--
 7 files changed, 55 insertions(+), 22 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index bfde661..2f14482 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -5,7 +5,7 @@
  *
  *   Originally based upon librte_pmd_pcap code:
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   Copyright(c) 2014 6WIND S.A.
  *   All rights reserved.
  *
@@ -656,8 +656,8 @@ rte_pmd_init_internals(const char *name,
 	/*
 	 * now put it all together
 	 * - store queue data in internals,
-	 * - store numa_node info in pci_driver
-	 * - point eth_dev_data to internals and pci_driver
+	 * - store numa_node in eth_dev
+	 * - point eth_dev_data to internals
 	 * - and point eth_dev structure to new eth_dev_data structure
 	 */
 
@@ -674,7 +674,11 @@ rte_pmd_init_internals(const char *name,
 
 	(*eth_dev)->data = data;
 	(*eth_dev)->dev_ops = &ops;
-	(*eth_dev)->pci_dev = pci_dev;
+	(*eth_dev)->driver = NULL;
+	(*eth_dev)->data->dev_flags = 0;
+	(*eth_dev)->data->drv_name = drivername;
+	(*eth_dev)->data->kdrv = RTE_KDRV_NONE;
+	(*eth_dev)->data->numa_node = numa_node;
 
 	return 0;
 
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 92073df..34adbde 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -44,6 +44,8 @@
 
 #define DEFAULT_POLLING_INTERVAL_10_MS (10)
 
+const char pmd_bond_driver_name[] = "rte_bond_pmd";
+
 int
 valid_bonded_ethdev(const struct rte_eth_dev *eth_dev)
 {
@@ -163,8 +165,6 @@ number_of_sockets(void)
 	return ++sockets;
 }
 
-const char pmd_bond_driver_name[] = "rte_bond_pmd";
-
 static struct rte_pci_id pci_id_table = {
 	.device_id = PCI_ANY_ID,
 	.subsystem_device_id = PCI_ANY_ID,
@@ -252,6 +252,13 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	eth_dev->dev_ops = &default_dev_ops;
 	eth_dev->pci_dev = pci_dev;
 
+	eth_dev->data->dev_flags = RTE_ETH_DEV_INTR_LSC |
+		RTE_ETH_DEV_DETACHABLE;
+	eth_dev->driver = NULL;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->data->drv_name = pmd_bond_driver_name;
+	eth_dev->data->numa_node =  socket_id;
+
 	rte_spinlock_init(&internals->lock);
 
 	internals->port_id = eth_dev->data->port_id;
diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c
index 6e3e304..4dc32f7 100644
--- a/drivers/net/mpipe/mpipe_tilegx.c
+++ b/drivers/net/mpipe/mpipe_tilegx.c
@@ -80,6 +80,7 @@ struct mpipe_context {
 
 static struct mpipe_context mpipe_contexts[GXIO_MPIPE_INSTANCE_MAX];
 static int mpipe_instances;
+static const char *drivername = "MPIPE PMD";
 
 /* Per queue statistics. */
 struct mpipe_queue_stats {
@@ -1595,6 +1596,12 @@ rte_pmd_mpipe_devinit(const char *ifname,
 	eth_dev->pci_dev = &priv->pci_dev;
 	eth_dev->data->mac_addrs = &priv->mac_addr;
 
+	eth_dev->data->dev_flags = 0;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->driver = NULL;
+	eth_dev->data->drv_name = drivername;
+	eth_dev->data->numa_node = instance;
+
 	eth_dev->dev_ops      = &mpipe_dev_ops;
 	eth_dev->rx_pkt_burst = &mpipe_recv_pkts;
 	eth_dev->tx_pkt_burst = &mpipe_xmit_pkts;
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 64e9000..11d6037 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -540,8 +540,8 @@ eth_dev_null_create(const char *name,
 
 	/* now put it all together
 	 * - store queue data in internals,
-	 * - store numa_node info in pci_driver
-	 * - point eth_dev_data to internals and pci_driver
+	 * - store numa_node info in ethdev data
+	 * - point eth_dev_data to internals
 	 * - and point eth_dev structure to new eth_dev_data structure
 	 */
 	/* NOTE: we'll replace the data element, of originally allocated eth_dev
@@ -571,10 +571,15 @@ eth_dev_null_create(const char *name,
 
 	eth_dev->data = data;
 	eth_dev->dev_ops = &ops;
-	eth_dev->pci_dev = pci_dev;
-	eth_dev->driver = &rte_null_pmd;
+
 	TAILQ_INIT(&eth_dev->link_intr_cbs);
 
+	eth_dev->driver = NULL;
+	eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->data->drv_name = drivername;
+	eth_dev->data->numa_node = numa_node;
+
 	/* finally assign rx and tx ops */
 	if (packet_copy) {
 		eth_dev->rx_pkt_burst = eth_null_copy_rx;
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index f2e4634..850274c 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   Copyright(c) 2014 6WIND S.A.
  *   All rights reserved.
  *
@@ -845,8 +845,8 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 
 	/* now put it all together
 	 * - store queue data in internals,
-	 * - store numa_node info in pci_driver
-	 * - point eth_dev_data to internals and pci_driver
+	 * - store numa_node info in eth_dev
+	 * - point eth_dev_data to internals
 	 * - and point eth_dev structure to new eth_dev_data structure
 	 */
 	/* NOTE: we'll replace the data element, of originally allocated eth_dev
@@ -874,8 +874,11 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 
 	(*eth_dev)->data = data;
 	(*eth_dev)->dev_ops = &ops;
-	(*eth_dev)->pci_dev = pci_dev;
-	(*eth_dev)->driver = &rte_pcap_pmd;
+	(*eth_dev)->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
+	(*eth_dev)->driver = NULL;
+	(*eth_dev)->data->kdrv = RTE_KDRV_NONE;
+	(*eth_dev)->data->drv_name = drivername;
+	(*eth_dev)->data->numa_node = numa_node;
 
 	return 0;
 
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 0ba36d5..77ac23a 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -304,11 +304,10 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 	if (eth_dev == NULL)
 		goto error;
 
-
 	/* now put it all together
 	 * - store queue data in internals,
-	 * - store numa_node info in pci_driver
-	 * - point eth_dev_data to internals and pci_driver
+	 * - store numa_node info in eth_dev_data
+	 * - point eth_dev_data to internals
 	 * - and point eth_dev structure to new eth_dev_data structure
 	 */
 	/* NOTE: we'll replace the data element, of originally allocated eth_dev
@@ -338,9 +337,13 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 	data->mac_addrs = &internals->address;
 
 	eth_dev->data = data;
-	eth_dev->driver = &rte_ring_pmd;
+	eth_dev->driver = NULL;
 	eth_dev->dev_ops = &ops;
-	eth_dev->pci_dev = pci_dev;
+	eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->data->drv_name = drivername;
+	eth_dev->data->numa_node = numa_node;
+
 	TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
 	/* finally assign rx and tx ops */
diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c
index b527552..6f9d96f 100644
--- a/drivers/net/xenvirt/rte_eth_xenvirt.c
+++ b/drivers/net/xenvirt/rte_eth_xenvirt.c
@@ -67,7 +67,7 @@
 /* virtio_idx is increased after new device is created.*/
 static int virtio_idx = 0;
 
-static const char *drivername = "xen dummy virtio PMD";
+static const char *drivername = "xen virtio PMD";
 
 static struct rte_eth_link pmd_link = {
 		.link_speed = 10000,
@@ -688,8 +688,12 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 
 	eth_dev->data = data;
 	eth_dev->dev_ops = &ops;
+
 	eth_dev->data->dev_flags = RTE_PCI_DRV_DETACHABLE;
-	eth_dev->pci_dev = pci_dev;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->data->drv_name = drivername;
+	eth_dev->driver = NULL;
+	eth_dev->data->numa_node = numa_node;
 
 	eth_dev->rx_pkt_burst = eth_xenvirt_rx;
 	eth_dev->tx_pkt_burst = eth_xenvirt_tx;
-- 
1.9.1



More information about the dev mailing list