Skip to contentSkip to conversation

ethdev: The users could get device types now

PATCH In review Ding Heng 4 participants 4 messages Sep 28, 2014 – Sep 29, 2014 2 messages not in the archive

lore
Share & tools
lore

Ding Heng

author
#0 lore raw

PATCH 1/1 ethdev: The users could get device types now

As different PMDs support different features, application may want to know the NIC type of a port, then decide how to use that port. Add a new field in struct rte_eth_dev, users are able to get device type now.

---
 lib/librte_ether/rte_ethdev.c | 32 ++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h | 20 ++++++++++++++++++++
 2 files changed, 52 insertions(+)
lib/librte_ether/rte_ethdev.c +32 -0
index fd1010a..490ea3a 100644
@@ -235,6 +235,38 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 	if (diag == 0)
 		return (0);
 
+	/* Define the device type */
+	if (strcmp(eth_drv->pci_drv.name, "rte_i40e_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_I40E;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_i40evf_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_I40E_VF;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_em_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_EM;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_igb_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_IGB;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_igbvf_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_IGB_VF;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_ixgbe_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_IXGBE;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_ixgbevf_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_IXGBE_VF;
+	else if (strcmp(eth_drv->pci_drv.name, "eth_bond") == 0)
+		eth_dev->dev_type = ETH_DEV_BOND;
+	else if (strcmp(eth_drv->pci_drv.name, "eth_ring") == 0)
+		eth_dev->dev_type = ETH_DEV_RING;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_virtio_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_VIRTIO;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_vmxnet3_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_VMXNET3;
+	else if (strcmp(eth_drv->pci_drv.name, "eth_xenvirt") == 0)
+		eth_dev->dev_type = ETH_DEV_XENVIRT;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_max_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_MAX;
+	else if (strcmp(eth_drv->pci_drv.name, "eth_pcap") == 0)
+		eth_dev->dev_type = ETH_DEV_PCAP;
+	else
+		eth_dev->dev_type = ETH_DEV_UNKNOWN;
+
 	PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u device_id=0x%x)"
 			" failed\n", pci_drv->name,
 			(unsigned) pci_dev->id.vendor_id,
lib/librte_ether/rte_ethdev.h +20 -0
index 50df654..83a7ea5 100644
@@ -268,6 +268,25 @@ enum rte_eth_rx_mq_mode {
 	ETH_MQ_RX_VMDQ_DCB_RSS, /**< Enable both VMDQ and DCB in VMDq */
 };
 
+/*Device type*/
+enum rte_eth_dev_type {
+	ETH_DEV_UNKNOWN = 0,
+	ETH_DEV_EM,
+	ETH_DEV_IGB,
+	ETH_DEV_IGB_VF,
+	ETH_DEV_IXGBE,
+	ETH_DEV_IXGBE_VF,
+	ETH_DEV_I40E,
+	ETH_DEV_I40E_VF,
+	ETH_DEV_BOND,
+	ETH_DEV_PCAP,
+	ETH_DEV_RING,
+	ETH_DEV_VIRTIO,
+	ETH_DEV_VMXNET3,
+	ETH_DEV_XENVIRT,
+	ETH_DEV_MAX
+};
+
 /**
  * for rx mq mode backward compatible
  */
@@ -1487,6 +1506,7 @@ struct rte_eth_dev {
 	struct eth_dev_ops *dev_ops;    /**< Functions exported by PMD */
 	struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */
 	struct rte_eth_dev_cb_list callbacks; /**< User application callbacks */
+	enum rte_eth_dev_type dev_type;  /**< Device type info. */
 };
 
 struct rte_eth_dev_sriov {
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): 1411874836-3274-1-git-send-email-hengx.ding-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

Acked-by
#2 lore raw
Quoted 100 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ding Heng
Sent: Sunday, September 28, 2014 11:27 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH] ethdev: The users could get device types now

As different PMDs support different features, application may want to know the NIC type of a port, then decide how to use that port.
Add a new field in struct rte_eth_dev, users are able to get device type now.

---
 lib/librte_ether/rte_ethdev.c | 32 ++++++++++++++++++++++++++++++++
lib/librte_ether/rte_ethdev.h | 20 ++++++++++++++++++++
 2 files changed, 52 insertions(+)
lib/librte_ether/rte_ethdev.c index renamed from lib/librte_ether/rte_ethdev.c +0 -0

fd1010a..490ea3a 100644

lib/librte_ether/rte_ethdev.c +32 -0
@@ -235,6 +235,38 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 	if (diag == 0)
 		return (0);
 
+	/* Define the device type */
+	if (strcmp(eth_drv->pci_drv.name, "rte_i40e_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_I40E;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_i40evf_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_I40E_VF;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_em_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_EM;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_igb_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_IGB;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_igbvf_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_IGB_VF;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_ixgbe_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_IXGBE;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_ixgbevf_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_IXGBE_VF;
+	else if (strcmp(eth_drv->pci_drv.name, "eth_bond") == 0)
+		eth_dev->dev_type = ETH_DEV_BOND;
+	else if (strcmp(eth_drv->pci_drv.name, "eth_ring") == 0)
+		eth_dev->dev_type = ETH_DEV_RING;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_virtio_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_VIRTIO;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_vmxnet3_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_VMXNET3;
+	else if (strcmp(eth_drv->pci_drv.name, "eth_xenvirt") == 0)
+		eth_dev->dev_type = ETH_DEV_XENVIRT;
+	else if (strcmp(eth_drv->pci_drv.name, "rte_max_pmd") == 0)
+		eth_dev->dev_type = ETH_DEV_MAX;
+	else if (strcmp(eth_drv->pci_drv.name, "eth_pcap") == 0)
+		eth_dev->dev_type = ETH_DEV_PCAP;
+	else
+		eth_dev->dev_type = ETH_DEV_UNKNOWN;
+
 	PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u

device_id=0x%x)"

lib/librte_ether/rte_ethdev.c +0 -0
 			" failed\n", pci_drv->name,
 			(unsigned) pci_dev->id.vendor_id,
lib/librte_ether/rte_ethdev.h index renamed from lib/librte_ether/rte_ethdev.h +0 -0

50df654..83a7ea5 100644

lib/librte_ether/rte_ethdev.h +20 -1
@@ -268,6 +268,25 @@ enum rte_eth_rx_mq_mode {
 	ETH_MQ_RX_VMDQ_DCB_RSS, /**< Enable both VMDQ and DCB in
 VMDq */  };
 
+/*Device type*/
+enum rte_eth_dev_type {
+	ETH_DEV_UNKNOWN = 0,
+	ETH_DEV_EM,
+	ETH_DEV_IGB,
+	ETH_DEV_IGB_VF,
+	ETH_DEV_IXGBE,
+	ETH_DEV_IXGBE_VF,
+	ETH_DEV_I40E,
+	ETH_DEV_I40E_VF,
+	ETH_DEV_BOND,
+	ETH_DEV_PCAP,
+	ETH_DEV_RING,
+	ETH_DEV_VIRTIO,
+	ETH_DEV_VMXNET3,
+	ETH_DEV_XENVIRT,
+	ETH_DEV_MAX
+};
+
 /**
  * for rx mq mode backward compatible
  */
@@ -1487,6 +1506,7 @@ struct rte_eth_dev {
 	struct eth_dev_ops *dev_ops;    /**< Functions exported by PMD */
 	struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */
 	struct rte_eth_dev_cb_list callbacks; /**< User application callbacks */
+	enum rte_eth_dev_type dev_type;  /**< Device type info. */
 };
 
 struct rte_eth_dev_sriov {
--

1.9.3

#3 lore raw
In reply to a message not in the archive
Quoted 6 lines · Ding Heng

As different PMDs support different features, application may want to know the NIC type of a port, then decide how to use that port. Add a new field in struct rte_eth_dev, users are able to get device type now.

Nack. This patch embodies PMD specific information in a common library, which really isn't necessecary. It implies that developers who maintain PMDs outside of the core dpdk still need to do some maintenence in the core for all the dpdk
features to work. Its also a layering violation. The core shouldn't have to
know any specifics about a driver to initalize it, even its name.

If an application wants to know what type of driver a NIC is, the application can just interrogate the pci drivers name field directly.

Neil

A message that is not in the archive (sent off-list or not yet received): 20140928123640.GC30445-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]

#5 lore raw

Agree with NACK. This type of string matching won't scale.
THe better way is to encapsulate required behavior in feature flags. I started that with drv_flags, and that seems natural home for such device specific stuff.

Quoted 23 lines · Neil Horman
Quoted 6 lines · Ding Heng

As different PMDs support different features, application may want to know the NIC type of a port, then decide how to use that port. Add a new field in struct rte_eth_dev, users are able to get device type now.

Nack. This patch embodies PMD specific information in a common library, which
really isn't necessecary. It implies that developers who maintain PMDs outside
of the core dpdk still need to do some maintenence in the core for all the dpdk
features to work. Its also a layering violation. The core shouldn't
have to
know any specifics about a driver to initalize it, even its name.

If an application wants to know what type of driver a NIC is, the application can just interrogate the pci drivers name field directly.

Neil