From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 373A67E13 for ; Sun, 28 Sep 2014 05:21:28 +0200 (CEST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by fmsmga102.fm.intel.com with ESMTP; 27 Sep 2014 20:27:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,612,1406617200"; d="scan'208";a="480479286" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by azsmga001.ch.intel.com with ESMTP; 27 Sep 2014 20:27:55 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s8S3RstV008452; Sun, 28 Sep 2014 11:27:54 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s8S3RpPL003309; Sun, 28 Sep 2014 11:27:53 +0800 Received: (from hengdinx@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s8S3RpI0003305; Sun, 28 Sep 2014 11:27:51 +0800 From: Ding Heng To: dev@dpdk.org Date: Sun, 28 Sep 2014 11:27:16 +0800 Message-Id: <1411874836-3274-1-git-send-email-hengx.ding@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] ethdev: The users could get device types now X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Sep 2014 03:21:28 -0000 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. Signed-off-by: Ding Heng --- lib/librte_ether/rte_ethdev.c | 32 ++++++++++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 20 ++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index fd1010a..490ea3a 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -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, diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 50df654..83a7ea5 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -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