DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] e1000: add firmware version get
@ 2016-11-17  9:42 Qiming Yang
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 1/5] ethdev: " Qiming Yang
                   ` (7 more replies)
  0 siblings, 8 replies; 128+ messages in thread
From: Qiming Yang @ 2016-11-17  9:42 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, jingjing.wu, jing.d.chen, Qiming Yang

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
 drivers/net/e1000/igb_ethdev.c | 46 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 2fddf0c..c47f1c8 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -120,6 +120,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
 				    unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
+static void eth_igb_fw_version_get(struct rte_eth_dev *dev,
+				   char *fw_version, int fw_length);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static const uint32_t *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -388,6 +390,7 @@ static const struct eth_dev_ops eth_igb_ops = {
 	.xstats_get_names     = eth_igb_xstats_get_names,
 	.stats_reset          = eth_igb_stats_reset,
 	.xstats_reset         = eth_igb_xstats_reset,
+	.fw_version_get       = eth_igb_fw_version_get,
 	.dev_infos_get        = eth_igb_infos_get,
 	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
 	.mtu_set              = eth_igb_mtu_set,
@@ -1977,6 +1980,49 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
 }
 
 static void
+eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+		       int fw_length)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_fw_version fw;
+
+	e1000_get_fw_version(hw, &fw);
+
+	switch (hw->mac.type) {
+	case e1000_i210:
+	case e1000_i211:
+		if (!(e1000_get_flash_presence_i210(hw))) {
+			snprintf(fw_version, fw_length,
+				 "%2d.%2d-%d",
+				 fw.invm_major, fw.invm_minor,
+				 fw.invm_img_type);
+			break;
+		}
+		/* fall through */
+	default:
+		/* if option rom is valid, display its version too*/
+		if (fw.or_valid) {
+			snprintf(fw_version, fw_length,
+				 "%d.%d, 0x%08x, %d.%d.%d",
+				 fw.eep_major, fw.eep_minor, fw.etrack_id,
+				 fw.or_major, fw.or_build, fw.or_patch);
+		/* no option rom */
+		} else {
+			if (fw.etrack_id != 0X0000) {
+			snprintf(fw_version, fw_length,
+				 "%d.%d, 0x%08x",
+				 fw.eep_major, fw.eep_minor, fw.etrack_id);
+			} else {
+			snprintf(fw_version, fw_length,
+				 "%d.%d.%d",
+				 fw.eep_major, fw.eep_minor, fw.eep_build);
+			}
+		}
+		break;
+	}
+}
+
+static void
 eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH 1/5] ethdev: add firmware version get
  2016-11-17  9:42 [dpdk-dev] [PATCH] e1000: add firmware version get Qiming Yang
@ 2016-11-17  9:42 ` Qiming Yang
  2016-11-17 13:36   ` Thomas Monjalon
                     ` (2 more replies)
  2016-11-17  9:42 ` [dpdk-dev] [PATCH] ethtool: dispaly bus info and " Qiming Yang
                   ` (6 subsequent siblings)
  7 siblings, 3 replies; 128+ messages in thread
From: Qiming Yang @ 2016-11-17  9:42 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, jingjing.wu, jing.d.chen, Qiming Yang

This patch added API for 'rte_eth_dev_fwver_get'

void rte_eth_dev_fwver_get(uint8_t port_id,
char *fw_version, int fw_length);

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++++++
 lib/librte_ether/rte_ethdev.h          | 18 ++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  7 +++++++
 3 files changed, 37 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index fde8112..793e50f 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1538,6 +1538,18 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
 }
 
 void
+rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int fw_length)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
+	dev = &rte_eth_devices[port_id];
+
+	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->fw_version_get);
+	(*dev->dev_ops->fw_version_get)(dev, fw_version, fw_length);
+}
+
+void
 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 {
 	struct rte_eth_dev *dev;
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 9678179..cf54f1b 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1150,6 +1150,10 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
 /**< @internal Check DD bit of specific RX descriptor */
 
+typedef void (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
+				    char *fw_version, int fw_length);
+/**< @internal Get firmware information of an Ethernet device. */
+
 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
 	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
 
@@ -1444,6 +1448,7 @@ struct eth_dev_ops {
 	/**< Get names of extended statistics. */
 	eth_queue_stats_mapping_set_t queue_stats_mapping_set;
 	/**< Configure per queue stat counter mapping. */
+	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
 	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
 	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
 	/**< Get packet types supported and identified by device*/
@@ -2385,6 +2390,19 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
 void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
 
 /**
+ * Retrieve the firmware version of an Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param fw_version
+ *   A pointer the firmware version of an Ethernet device
+ * @param fw_length
+ *   The size of the firmware version, which should be large enough to store
+ *   the firmware version of the device.
+ */
+void rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int fw_length);
+
+/**
  * Retrieve the supported packet types of an Ethernet device.
  *
  * When a packet type is announced as supported, it *must* be recognized by
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index 72be66d..5e6387f 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -147,3 +147,10 @@ DPDK_16.11 {
 	rte_eth_dev_pci_remove;
 
 } DPDK_16.07;
+
+DPDK_17.02 {
+	global:
+
+	rte_eth_dev_fwver_get;
+
+} DPDK_16.11;
-- 
2.7.4

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

* [dpdk-dev] [PATCH] ethtool: dispaly bus info and firmware version
  2016-11-17  9:42 [dpdk-dev] [PATCH] e1000: add firmware version get Qiming Yang
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 1/5] ethdev: " Qiming Yang
@ 2016-11-17  9:42 ` Qiming Yang
  2016-11-17  9:42 ` [dpdk-dev] [PATCH] i40e: add firmware version get Qiming Yang
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2016-11-17  9:42 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, jingjing.wu, jing.d.chen, Qiming Yang

This patch enhances the ethtool-API to support to show the
bus information and firmware version as same as kernel
version ethtool displayed.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
 examples/ethtool/ethtool-app/ethapp.c | 2 ++
 examples/ethtool/lib/rte_ethtool.c    | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
index 38e466c..9b77385 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -184,6 +184,8 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
 		printf("Port %i driver: %s (ver: %s)\n",
 			id_port, info.driver, info.version
 		      );
+		printf("bus-info: %s\n", info.bus_info);
+		printf("firmware-version: %s\n", info.fw_version);
 	}
 }
 
diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index a1f91d4..542179c 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -54,6 +54,9 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
+	rte_eth_dev_fwver_get(port_id, drvinfo->fw_version,
+			      sizeof(drvinfo->fw_version));
+
 	memset(&dev_info, 0, sizeof(dev_info));
 	rte_eth_dev_info_get(port_id, &dev_info);
 
-- 
2.7.4

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

* [dpdk-dev] [PATCH] i40e: add firmware version get
  2016-11-17  9:42 [dpdk-dev] [PATCH] e1000: add firmware version get Qiming Yang
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 1/5] ethdev: " Qiming Yang
  2016-11-17  9:42 ` [dpdk-dev] [PATCH] ethtool: dispaly bus info and " Qiming Yang
@ 2016-11-17  9:42 ` Qiming Yang
  2016-11-17  9:42 ` [dpdk-dev] [PATCH] ixgbe: " Qiming Yang
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2016-11-17  9:42 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, jingjing.wu, jing.d.chen, Qiming Yang

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 67778ba..f79bc5e 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -324,6 +324,8 @@ static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
 					    uint16_t queue_id,
 					    uint8_t stat_idx,
 					    uint8_t is_rx);
+static void i40e_fw_version_get(struct rte_eth_dev *dev,
+				char *fw_version, int fw_length);
 static void i40e_dev_info_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static int i40e_vlan_filter_set(struct rte_eth_dev *dev,
@@ -503,6 +505,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.stats_reset                  = i40e_dev_stats_reset,
 	.xstats_reset                 = i40e_dev_stats_reset,
 	.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
+	.fw_version_get               = i40e_fw_version_get,
 	.dev_infos_get                = i40e_dev_info_get,
 	.dev_supported_ptypes_get     = i40e_dev_supported_ptypes_get,
 	.vlan_filter_set              = i40e_vlan_filter_set,
@@ -2577,6 +2580,18 @@ i40e_dev_queue_stats_mapping_set(__rte_unused struct rte_eth_dev *dev,
 }
 
 static void
+i40e_fw_version_get(struct rte_eth_dev *dev, char *fw_version, int fw_length)
+{
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	snprintf(fw_version, fw_length,
+		 "%d.%d%d 0x%04x",
+		 ((hw->nvm.version >> 12) & 0xf),
+		 ((hw->nvm.version >> 4) & 0xff),
+		 (hw->nvm.version & 0xf), hw->nvm.eetrack);
+}
+
+static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH] ixgbe: add firmware version get
  2016-11-17  9:42 [dpdk-dev] [PATCH] e1000: add firmware version get Qiming Yang
                   ` (2 preceding siblings ...)
  2016-11-17  9:42 ` [dpdk-dev] [PATCH] i40e: add firmware version get Qiming Yang
@ 2016-11-17  9:42 ` Qiming Yang
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 2/5] e1000: " Qiming Yang
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2016-11-17  9:42 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, jingjing.wu, jing.d.chen, Qiming Yang

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index edc9b22..da9aa31 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -193,6 +193,8 @@ static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint16_t queue_id,
 					     uint8_t stat_idx,
 					     uint8_t is_rx);
+static void ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+				 int fw_length);
 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
 			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -537,6 +539,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.xstats_reset         = ixgbe_dev_xstats_reset,
 	.xstats_get_names     = ixgbe_dev_xstats_get_names,
 	.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
+	.fw_version_get       = ixgbe_fw_version_get,
 	.dev_infos_get        = ixgbe_dev_info_get,
 	.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
 	.mtu_set              = ixgbe_dev_mtu_set,
@@ -3029,6 +3032,21 @@ ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
 }
 
 static void
+ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, int fw_length)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u16 eeprom_verh, eeprom_verl;
+	u32 etrack_id;
+
+	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
+	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
+
+	etrack_id = (eeprom_verh << 16) | eeprom_verl;
+	snprintf(fw_version, fw_length,
+		 "0x%08x", etrack_id);
+}
+
+static void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH 2/5] e1000: add firmware version get
  2016-11-17  9:42 [dpdk-dev] [PATCH] e1000: add firmware version get Qiming Yang
                   ` (3 preceding siblings ...)
  2016-11-17  9:42 ` [dpdk-dev] [PATCH] ixgbe: " Qiming Yang
@ 2016-11-17  9:42 ` Qiming Yang
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 3/5] ixgbe: " Qiming Yang
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2016-11-17  9:42 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, jingjing.wu, jing.d.chen, Qiming Yang

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
 drivers/net/e1000/igb_ethdev.c | 46 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 2fddf0c..c47f1c8 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -120,6 +120,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
 				    unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
+static void eth_igb_fw_version_get(struct rte_eth_dev *dev,
+				   char *fw_version, int fw_length);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static const uint32_t *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -388,6 +390,7 @@ static const struct eth_dev_ops eth_igb_ops = {
 	.xstats_get_names     = eth_igb_xstats_get_names,
 	.stats_reset          = eth_igb_stats_reset,
 	.xstats_reset         = eth_igb_xstats_reset,
+	.fw_version_get       = eth_igb_fw_version_get,
 	.dev_infos_get        = eth_igb_infos_get,
 	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
 	.mtu_set              = eth_igb_mtu_set,
@@ -1977,6 +1980,49 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
 }
 
 static void
+eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+		       int fw_length)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_fw_version fw;
+
+	e1000_get_fw_version(hw, &fw);
+
+	switch (hw->mac.type) {
+	case e1000_i210:
+	case e1000_i211:
+		if (!(e1000_get_flash_presence_i210(hw))) {
+			snprintf(fw_version, fw_length,
+				 "%2d.%2d-%d",
+				 fw.invm_major, fw.invm_minor,
+				 fw.invm_img_type);
+			break;
+		}
+		/* fall through */
+	default:
+		/* if option rom is valid, display its version too*/
+		if (fw.or_valid) {
+			snprintf(fw_version, fw_length,
+				 "%d.%d, 0x%08x, %d.%d.%d",
+				 fw.eep_major, fw.eep_minor, fw.etrack_id,
+				 fw.or_major, fw.or_build, fw.or_patch);
+		/* no option rom */
+		} else {
+			if (fw.etrack_id != 0X0000) {
+			snprintf(fw_version, fw_length,
+				 "%d.%d, 0x%08x",
+				 fw.eep_major, fw.eep_minor, fw.etrack_id);
+			} else {
+			snprintf(fw_version, fw_length,
+				 "%d.%d.%d",
+				 fw.eep_major, fw.eep_minor, fw.eep_build);
+			}
+		}
+		break;
+	}
+}
+
+static void
 eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH 3/5] ixgbe: add firmware version get
  2016-11-17  9:42 [dpdk-dev] [PATCH] e1000: add firmware version get Qiming Yang
                   ` (4 preceding siblings ...)
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 2/5] e1000: " Qiming Yang
@ 2016-11-17  9:42 ` Qiming Yang
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 4/5] i40e: " Qiming Yang
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 5/5] ethtool: dispaly bus info and firmware version Qiming Yang
  7 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2016-11-17  9:42 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, jingjing.wu, jing.d.chen, Qiming Yang

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index edc9b22..da9aa31 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -193,6 +193,8 @@ static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint16_t queue_id,
 					     uint8_t stat_idx,
 					     uint8_t is_rx);
+static void ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+				 int fw_length);
 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
 			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -537,6 +539,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.xstats_reset         = ixgbe_dev_xstats_reset,
 	.xstats_get_names     = ixgbe_dev_xstats_get_names,
 	.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
+	.fw_version_get       = ixgbe_fw_version_get,
 	.dev_infos_get        = ixgbe_dev_info_get,
 	.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
 	.mtu_set              = ixgbe_dev_mtu_set,
@@ -3029,6 +3032,21 @@ ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
 }
 
 static void
+ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, int fw_length)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u16 eeprom_verh, eeprom_verl;
+	u32 etrack_id;
+
+	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
+	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
+
+	etrack_id = (eeprom_verh << 16) | eeprom_verl;
+	snprintf(fw_version, fw_length,
+		 "0x%08x", etrack_id);
+}
+
+static void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH 4/5] i40e: add firmware version get
  2016-11-17  9:42 [dpdk-dev] [PATCH] e1000: add firmware version get Qiming Yang
                   ` (5 preceding siblings ...)
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 3/5] ixgbe: " Qiming Yang
@ 2016-11-17  9:42 ` Qiming Yang
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 5/5] ethtool: dispaly bus info and firmware version Qiming Yang
  7 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2016-11-17  9:42 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, jingjing.wu, jing.d.chen, Qiming Yang

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 67778ba..f79bc5e 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -324,6 +324,8 @@ static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
 					    uint16_t queue_id,
 					    uint8_t stat_idx,
 					    uint8_t is_rx);
+static void i40e_fw_version_get(struct rte_eth_dev *dev,
+				char *fw_version, int fw_length);
 static void i40e_dev_info_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static int i40e_vlan_filter_set(struct rte_eth_dev *dev,
@@ -503,6 +505,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.stats_reset                  = i40e_dev_stats_reset,
 	.xstats_reset                 = i40e_dev_stats_reset,
 	.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
+	.fw_version_get               = i40e_fw_version_get,
 	.dev_infos_get                = i40e_dev_info_get,
 	.dev_supported_ptypes_get     = i40e_dev_supported_ptypes_get,
 	.vlan_filter_set              = i40e_vlan_filter_set,
@@ -2577,6 +2580,18 @@ i40e_dev_queue_stats_mapping_set(__rte_unused struct rte_eth_dev *dev,
 }
 
 static void
+i40e_fw_version_get(struct rte_eth_dev *dev, char *fw_version, int fw_length)
+{
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	snprintf(fw_version, fw_length,
+		 "%d.%d%d 0x%04x",
+		 ((hw->nvm.version >> 12) & 0xf),
+		 ((hw->nvm.version >> 4) & 0xff),
+		 (hw->nvm.version & 0xf), hw->nvm.eetrack);
+}
+
+static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH 5/5] ethtool: dispaly bus info and firmware version
  2016-11-17  9:42 [dpdk-dev] [PATCH] e1000: add firmware version get Qiming Yang
                   ` (6 preceding siblings ...)
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 4/5] i40e: " Qiming Yang
@ 2016-11-17  9:42 ` Qiming Yang
  2016-11-18  1:10   ` Remy Horton
  7 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2016-11-17  9:42 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, jingjing.wu, jing.d.chen, Qiming Yang

This patch enhances the ethtool-API to support to show the
bus information and firmware version as same as kernel
version ethtool displayed.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
 examples/ethtool/ethtool-app/ethapp.c | 2 ++
 examples/ethtool/lib/rte_ethtool.c    | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
index 38e466c..9b77385 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -184,6 +184,8 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
 		printf("Port %i driver: %s (ver: %s)\n",
 			id_port, info.driver, info.version
 		      );
+		printf("bus-info: %s\n", info.bus_info);
+		printf("firmware-version: %s\n", info.fw_version);
 	}
 }
 
diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index a1f91d4..542179c 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -54,6 +54,9 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
+	rte_eth_dev_fwver_get(port_id, drvinfo->fw_version,
+			      sizeof(drvinfo->fw_version));
+
 	memset(&dev_info, 0, sizeof(dev_info));
 	rte_eth_dev_info_get(port_id, &dev_info);
 
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH 1/5] ethdev: add firmware version get
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 1/5] ethdev: " Qiming Yang
@ 2016-11-17 13:36   ` Thomas Monjalon
  2016-11-18  2:10     ` Yang, Qiming
  2016-11-18  1:09   ` Remy Horton
  2016-12-06  7:16   ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw " Qiming Yang
  2 siblings, 1 reply; 128+ messages in thread
From: Thomas Monjalon @ 2016-11-17 13:36 UTC (permalink / raw)
  To: Qiming Yang; +Cc: dev, remy.horton, jingjing.wu, jing.d.chen

2016-11-17 17:42, Qiming Yang:
> This patch added API for 'rte_eth_dev_fwver_get'
> 
> void rte_eth_dev_fwver_get(uint8_t port_id,
> char *fw_version, int fw_length);

Copying some code here doesn't help really help.
Could you describe what we can expect in this string?
How can we compare this version number across different
devices of the same driver?
How does it apply to FPGA devices?
What is the potential use?

[...]
>  /**
> + * Retrieve the firmware version of an Ethernet device.

We should stop talking about Ethernet device.
Networking device is more appropriate.
And in this case, "device" is enough.

> + *
> + * @param port_id
> + *   The port identifier of the Ethernet device.
> + * @param fw_version
> + *   A pointer the firmware version of an Ethernet device
> + * @param fw_length
> + *   The size of the firmware version, which should be large enough to store
> + *   the firmware version of the device.

How do we know that the length is too small?

> + */
> +void rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int fw_length);

Why not returning some errors?

You forgot to remove the deprecation notice in this patch.

PS: the series is broken as some patches are not numbered and this one is
not the first one. Please use a cover-letter to introduce such series.

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

* Re: [dpdk-dev] [PATCH 1/5] ethdev: add firmware version get
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 1/5] ethdev: " Qiming Yang
  2016-11-17 13:36   ` Thomas Monjalon
@ 2016-11-18  1:09   ` Remy Horton
  2016-11-18  2:18     ` Yang, Qiming
  2016-12-06  7:16   ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw " Qiming Yang
  2 siblings, 1 reply; 128+ messages in thread
From: Remy Horton @ 2016-11-18  1:09 UTC (permalink / raw)
  To: Qiming Yang, dev; +Cc: jingjing.wu, jing.d.chen


On 17/11/2016 17:42, Qiming Yang wrote:
> This patch added API for 'rte_eth_dev_fwver_get'
>
> void rte_eth_dev_fwver_get(uint8_t port_id,
> char *fw_version, int fw_length);

Suggest description such as:

This patch adds ethdev API for fetching firmware version.

Also see Thomas's comments. Looks like some stale patches got picked up 
by 'git send-mail *.patch'..

..Remy

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

* Re: [dpdk-dev] [PATCH 5/5] ethtool: dispaly bus info and firmware version
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 5/5] ethtool: dispaly bus info and firmware version Qiming Yang
@ 2016-11-18  1:10   ` Remy Horton
  0 siblings, 0 replies; 128+ messages in thread
From: Remy Horton @ 2016-11-18  1:10 UTC (permalink / raw)
  To: Qiming Yang, dev; +Cc: jingjing.wu, jing.d.chen


On 17/11/2016 17:42, Qiming Yang wrote:
> This patch enhances the ethtool-API to support to show the
> bus information and firmware version as same as kernel
> version ethtool displayed.

Suggest rewording as:

This patch enhances the ethtool example to support to show
bus information and firmware version, in the same way that
the Linux kernel ethtool does.

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

* Re: [dpdk-dev] [PATCH 1/5] ethdev: add firmware version get
  2016-11-17 13:36   ` Thomas Monjalon
@ 2016-11-18  2:10     ` Yang, Qiming
  0 siblings, 0 replies; 128+ messages in thread
From: Yang, Qiming @ 2016-11-18  2:10 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Horton, Remy, Wu, Jingjing, Chen, Jing D

Hi, Thomas

-----Original Message-----
From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] 
Sent: Thursday, November 17, 2016 9:37 PM
To: Yang, Qiming <qiming.yang@intel.com>
Cc: dev@dpdk.org; Horton, Remy <remy.horton@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Chen, Jing D <jing.d.chen@intel.com>
Subject: Re: [dpdk-dev] [PATCH 1/5] ethdev: add firmware version get

2016-11-17 17:42, Qiming Yang:
> This patch added API for 'rte_eth_dev_fwver_get'
> 
> void rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int 
> fw_length);

Copying some code here doesn't help really help.
Could you describe what we can expect in this string?
How can we compare this version number across different devices of the same driver?
How does it apply to FPGA devices?
What is the potential use?

Qiming: I'll add more describes in the next version.

[...]
>  /**
> + * Retrieve the firmware version of an Ethernet device.

We should stop talking about Ethernet device.
Networking device is more appropriate.
And in this case, "device" is enough.

Qiming: Got it.

> + *
> + * @param port_id
> + *   The port identifier of the Ethernet device.
> + * @param fw_version
> + *   A pointer the firmware version of an Ethernet device
> + * @param fw_length
> + *   The size of the firmware version, which should be large enough to store
> + *   the firmware version of the device.

How do we know that the length is too small?

Qiming: The length is a number large enough to store the firmware version. Original I use a fixed number 20, but in order to be more flexible, I replace it into a variable. 

> + */
> +void rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int 
> +fw_length);

Why not returning some errors?

Qiming: It's a good advice.

You forgot to remove the deprecation notice in this patch.

PS: the series is broken as some patches are not numbered and this one is not the first one. Please use a cover-letter to introduce such series.

Qiming: It's my fault. Thank you for your reminder, I will pay attention next time.

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

* Re: [dpdk-dev] [PATCH 1/5] ethdev: add firmware version get
  2016-11-18  1:09   ` Remy Horton
@ 2016-11-18  2:18     ` Yang, Qiming
  0 siblings, 0 replies; 128+ messages in thread
From: Yang, Qiming @ 2016-11-18  2:18 UTC (permalink / raw)
  To: Horton, Remy, dev; +Cc: Wu, Jingjing, Chen, Jing D

Yes, that's my fault. I have set their statuses to 'suspended'

Qiming

-----Original Message-----
From: Horton, Remy 
Sent: Friday, November 18, 2016 9:10 AM
To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org
Cc: Wu, Jingjing <jingjing.wu@intel.com>; Chen, Jing D <jing.d.chen@intel.com>
Subject: Re: [PATCH 1/5] ethdev: add firmware version get


On 17/11/2016 17:42, Qiming Yang wrote:
> This patch added API for 'rte_eth_dev_fwver_get'
>
> void rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int 
> fw_length);

Suggest description such as:

This patch adds ethdev API for fetching firmware version.

Also see Thomas's comments. Looks like some stale patches got picked up by 'git send-mail *.patch'..

..Remy

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

* [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get
  2016-11-17  9:42 ` [dpdk-dev] [PATCH 1/5] ethdev: " Qiming Yang
  2016-11-17 13:36   ` Thomas Monjalon
  2016-11-18  1:09   ` Remy Horton
@ 2016-12-06  7:16   ` Qiming Yang
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 1/5] ethdev: add firmware " Qiming Yang
                       ` (6 more replies)
  2 siblings, 7 replies; 128+ messages in thread
From: Qiming Yang @ 2016-12-06  7:16 UTC (permalink / raw)
  To: dev; +Cc: Qiming Yang

Now, the example ethtool can only show the driver information. From
customers' point of view, it should be better if we can have the same
way that the Linux kernel ethtool does to show the bus-info and
firmware-version.

These five patches add a new API to fetch firmware version and implement
the display in example ethtool.

Qiming Yang (5):
  ethdev: add firmware version get
  net/e1000: add firmware version get
  net/ixgbe: add firmware version get
  net/i40e: add firmware version get
  ethtool: dispaly bus info and firmware version

 drivers/net/e1000/igb_ethdev.c         | 46 ++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.c         | 15 +++++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c       | 18 +++++++++++++
 examples/ethtool/ethtool-app/ethapp.c  |  2 ++
 examples/ethtool/lib/rte_ethtool.c     |  3 +++
 lib/librte_ether/rte_ethdev.c          | 12 +++++++++
 lib/librte_ether/rte_ethdev.h          | 18 +++++++++++++
 lib/librte_ether/rte_ether_version.map |  7 ++++++
 8 files changed, 121 insertions(+)

-- 
2.7.4

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

* [dpdk-dev] [PATCH v2 1/5] ethdev: add firmware version get
  2016-12-06  7:16   ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw " Qiming Yang
@ 2016-12-06  7:16     ` Qiming Yang
  2016-12-08 11:07       ` Ferruh Yigit
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 2/5] net/e1000: " Qiming Yang
                       ` (5 subsequent siblings)
  6 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2016-12-06  7:16 UTC (permalink / raw)
  To: dev; +Cc: Qiming Yang

This patch adds a new API 'rte_eth_dev_fwver_get' for fetching firmware
version by a given device.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
v2 changes:
* modified some comment statements.
---
---
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++++++
 lib/librte_ether/rte_ethdev.h          | 18 ++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  7 +++++++
 3 files changed, 37 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index fde8112..793e50f 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1538,6 +1538,18 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
 }
 
 void
+rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int fw_length)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
+	dev = &rte_eth_devices[port_id];
+
+	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->fw_version_get);
+	(*dev->dev_ops->fw_version_get)(dev, fw_version, fw_length);
+}
+
+void
 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 {
 	struct rte_eth_dev *dev;
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 9678179..2c05df4 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1150,6 +1150,10 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
 /**< @internal Check DD bit of specific RX descriptor */
 
+typedef void (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
+				    char *fw_version, int fw_length);
+/**< @internal Get firmware information of an Ethernet device. */
+
 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
 	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
 
@@ -1444,6 +1448,7 @@ struct eth_dev_ops {
 	/**< Get names of extended statistics. */
 	eth_queue_stats_mapping_set_t queue_stats_mapping_set;
 	/**< Configure per queue stat counter mapping. */
+	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
 	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
 	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
 	/**< Get packet types supported and identified by device*/
@@ -2385,6 +2390,19 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
 void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
 
 /**
+ * Retrieve the firmware version of a device.
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param fw_version
+ *   A array pointer to store the firmware version of a device,
+ *   allocated by caller.
+ * @param fw_length
+ *   The size of the array pointed by fw_version.
+ */
+void rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int fw_length);
+
+/**
  * Retrieve the supported packet types of an Ethernet device.
  *
  * When a packet type is announced as supported, it *must* be recognized by
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index 72be66d..5e6387f 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -147,3 +147,10 @@ DPDK_16.11 {
 	rte_eth_dev_pci_remove;
 
 } DPDK_16.07;
+
+DPDK_17.02 {
+	global:
+
+	rte_eth_dev_fwver_get;
+
+} DPDK_16.11;
-- 
2.7.4

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

* [dpdk-dev] [PATCH v2 2/5] net/e1000: add firmware version get
  2016-12-06  7:16   ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw " Qiming Yang
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 1/5] ethdev: add firmware " Qiming Yang
@ 2016-12-06  7:16     ` Qiming Yang
  2016-12-07  1:16       ` Lu, Wenzhuo
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 3/5] net/ixgbe: " Qiming Yang
                       ` (4 subsequent siblings)
  6 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2016-12-06  7:16 UTC (permalink / raw)
  To: dev; +Cc: Qiming Yang

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
 drivers/net/e1000/igb_ethdev.c | 46 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 2fddf0c..c47f1c8 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -120,6 +120,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
 				    unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
+static void eth_igb_fw_version_get(struct rte_eth_dev *dev,
+				   char *fw_version, int fw_length);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static const uint32_t *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -388,6 +390,7 @@ static const struct eth_dev_ops eth_igb_ops = {
 	.xstats_get_names     = eth_igb_xstats_get_names,
 	.stats_reset          = eth_igb_stats_reset,
 	.xstats_reset         = eth_igb_xstats_reset,
+	.fw_version_get       = eth_igb_fw_version_get,
 	.dev_infos_get        = eth_igb_infos_get,
 	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
 	.mtu_set              = eth_igb_mtu_set,
@@ -1977,6 +1980,49 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
 }
 
 static void
+eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+		       int fw_length)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_fw_version fw;
+
+	e1000_get_fw_version(hw, &fw);
+
+	switch (hw->mac.type) {
+	case e1000_i210:
+	case e1000_i211:
+		if (!(e1000_get_flash_presence_i210(hw))) {
+			snprintf(fw_version, fw_length,
+				 "%2d.%2d-%d",
+				 fw.invm_major, fw.invm_minor,
+				 fw.invm_img_type);
+			break;
+		}
+		/* fall through */
+	default:
+		/* if option rom is valid, display its version too*/
+		if (fw.or_valid) {
+			snprintf(fw_version, fw_length,
+				 "%d.%d, 0x%08x, %d.%d.%d",
+				 fw.eep_major, fw.eep_minor, fw.etrack_id,
+				 fw.or_major, fw.or_build, fw.or_patch);
+		/* no option rom */
+		} else {
+			if (fw.etrack_id != 0X0000) {
+			snprintf(fw_version, fw_length,
+				 "%d.%d, 0x%08x",
+				 fw.eep_major, fw.eep_minor, fw.etrack_id);
+			} else {
+			snprintf(fw_version, fw_length,
+				 "%d.%d.%d",
+				 fw.eep_major, fw.eep_minor, fw.eep_build);
+			}
+		}
+		break;
+	}
+}
+
+static void
 eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH v2 3/5] net/ixgbe: add firmware version get
  2016-12-06  7:16   ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw " Qiming Yang
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 1/5] ethdev: add firmware " Qiming Yang
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 2/5] net/e1000: " Qiming Yang
@ 2016-12-06  7:16     ` Qiming Yang
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 4/5] net/i40e: " Qiming Yang
                       ` (3 subsequent siblings)
  6 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2016-12-06  7:16 UTC (permalink / raw)
  To: dev; +Cc: Qiming Yang

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index edc9b22..da9aa31 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -193,6 +193,8 @@ static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint16_t queue_id,
 					     uint8_t stat_idx,
 					     uint8_t is_rx);
+static void ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+				 int fw_length);
 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
 			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -537,6 +539,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.xstats_reset         = ixgbe_dev_xstats_reset,
 	.xstats_get_names     = ixgbe_dev_xstats_get_names,
 	.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
+	.fw_version_get       = ixgbe_fw_version_get,
 	.dev_infos_get        = ixgbe_dev_info_get,
 	.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
 	.mtu_set              = ixgbe_dev_mtu_set,
@@ -3029,6 +3032,21 @@ ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
 }
 
 static void
+ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, int fw_length)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u16 eeprom_verh, eeprom_verl;
+	u32 etrack_id;
+
+	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
+	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
+
+	etrack_id = (eeprom_verh << 16) | eeprom_verl;
+	snprintf(fw_version, fw_length,
+		 "0x%08x", etrack_id);
+}
+
+static void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH v2 4/5] net/i40e: add firmware version get
  2016-12-06  7:16   ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw " Qiming Yang
                       ` (2 preceding siblings ...)
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 3/5] net/ixgbe: " Qiming Yang
@ 2016-12-06  7:16     ` Qiming Yang
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 5/5] ethtool: dispaly bus info and firmware version Qiming Yang
                       ` (2 subsequent siblings)
  6 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2016-12-06  7:16 UTC (permalink / raw)
  To: dev; +Cc: Qiming Yang

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 67778ba..f79bc5e 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -324,6 +324,8 @@ static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
 					    uint16_t queue_id,
 					    uint8_t stat_idx,
 					    uint8_t is_rx);
+static void i40e_fw_version_get(struct rte_eth_dev *dev,
+				char *fw_version, int fw_length);
 static void i40e_dev_info_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static int i40e_vlan_filter_set(struct rte_eth_dev *dev,
@@ -503,6 +505,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.stats_reset                  = i40e_dev_stats_reset,
 	.xstats_reset                 = i40e_dev_stats_reset,
 	.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
+	.fw_version_get               = i40e_fw_version_get,
 	.dev_infos_get                = i40e_dev_info_get,
 	.dev_supported_ptypes_get     = i40e_dev_supported_ptypes_get,
 	.vlan_filter_set              = i40e_vlan_filter_set,
@@ -2577,6 +2580,18 @@ i40e_dev_queue_stats_mapping_set(__rte_unused struct rte_eth_dev *dev,
 }
 
 static void
+i40e_fw_version_get(struct rte_eth_dev *dev, char *fw_version, int fw_length)
+{
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	snprintf(fw_version, fw_length,
+		 "%d.%d%d 0x%04x",
+		 ((hw->nvm.version >> 12) & 0xf),
+		 ((hw->nvm.version >> 4) & 0xff),
+		 (hw->nvm.version & 0xf), hw->nvm.eetrack);
+}
+
+static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH v2 5/5] ethtool: dispaly bus info and firmware version
  2016-12-06  7:16   ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw " Qiming Yang
                       ` (3 preceding siblings ...)
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 4/5] net/i40e: " Qiming Yang
@ 2016-12-06  7:16     ` Qiming Yang
  2016-12-23 12:50       ` Ferruh Yigit
  2016-12-27 13:06       ` [dpdk-dev] [PATCH v3] " Qiming Yang
  2016-12-08  8:34     ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get Remy Horton
  2016-12-27 12:30     ` [dpdk-dev] [PATCH v3 0/4] new API 'rte_eth_dev_fw_info_get' Qiming Yang
  6 siblings, 2 replies; 128+ messages in thread
From: Qiming Yang @ 2016-12-06  7:16 UTC (permalink / raw)
  To: dev; +Cc: Qiming Yang

This patch enhances the ethtool example to support to show
bus information and firmware version, in the same way that
the Linux kernel ethtool does.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
v2 changes:
*  modified the commit log
---
---
 examples/ethtool/ethtool-app/ethapp.c | 2 ++
 examples/ethtool/lib/rte_ethtool.c    | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
index 38e466c..9b77385 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -184,6 +184,8 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
 		printf("Port %i driver: %s (ver: %s)\n",
 			id_port, info.driver, info.version
 		      );
+		printf("bus-info: %s\n", info.bus_info);
+		printf("firmware-version: %s\n", info.fw_version);
 	}
 }
 
diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index a1f91d4..542179c 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -54,6 +54,9 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
+	rte_eth_dev_fwver_get(port_id, drvinfo->fw_version,
+			      sizeof(drvinfo->fw_version));
+
 	memset(&dev_info, 0, sizeof(dev_info));
 	rte_eth_dev_info_get(port_id, &dev_info);
 
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH v2 2/5] net/e1000: add firmware version get
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 2/5] net/e1000: " Qiming Yang
@ 2016-12-07  1:16       ` Lu, Wenzhuo
  0 siblings, 0 replies; 128+ messages in thread
From: Lu, Wenzhuo @ 2016-12-07  1:16 UTC (permalink / raw)
  To: Yang, Qiming, dev; +Cc: Yang, Qiming

Hi Qiming,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Qiming Yang
> Sent: Tuesday, December 6, 2016 3:16 PM
> To: dev@dpdk.org
> Cc: Yang, Qiming
> Subject: [dpdk-dev] [PATCH v2 2/5] net/e1000: add firmware version get
Seems commit log is missing.

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

* Re: [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get
  2016-12-06  7:16   ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw " Qiming Yang
                       ` (4 preceding siblings ...)
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 5/5] ethtool: dispaly bus info and firmware version Qiming Yang
@ 2016-12-08  8:34     ` Remy Horton
  2016-12-12  1:43       ` Yang, Qiming
  2016-12-22 11:07       ` Thomas Monjalon
  2016-12-27 12:30     ` [dpdk-dev] [PATCH v3 0/4] new API 'rte_eth_dev_fw_info_get' Qiming Yang
  6 siblings, 2 replies; 128+ messages in thread
From: Remy Horton @ 2016-12-08  8:34 UTC (permalink / raw)
  To: Qiming Yang, dev


On 06/12/2016 15:16, Qiming Yang wrote:
[..]
> Qiming Yang (5):
>   ethdev: add firmware version get
>   net/e1000: add firmware version get
>   net/ixgbe: add firmware version get
>   net/i40e: add firmware version get
>   ethtool: dispaly bus info and firmware version

s/dispaly/display

doc/guides/rel_notes/release_17_02.rst ought to be updated as well. Code 
itself looks ok though..

Acked-by: Remy Horton <remy.horton@intel.com>

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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: add firmware version get
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 1/5] ethdev: add firmware " Qiming Yang
@ 2016-12-08 11:07       ` Ferruh Yigit
  2016-12-12  1:28         ` Yang, Qiming
  0 siblings, 1 reply; 128+ messages in thread
From: Ferruh Yigit @ 2016-12-08 11:07 UTC (permalink / raw)
  To: Qiming Yang, dev; +Cc: Thomas Monjalon

Hi Qiming,

On 12/6/2016 7:16 AM, Qiming Yang wrote:
> This patch adds a new API 'rte_eth_dev_fwver_get' for fetching firmware
> version by a given device.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>

<...>

> @@ -1444,6 +1448,7 @@ struct eth_dev_ops {
>  	/**< Get names of extended statistics. */
>  	eth_queue_stats_mapping_set_t queue_stats_mapping_set;
>  	/**< Configure per queue stat counter mapping. */
> +	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */

Hi Qiming,

Not sure if I am missing something but this change is for following [1]
deprecation notice, right?
If so, notice suggest updating rte_eth_dev_info_get() to include
fw_version, but this patch adds a new eth_dev_ops.

Is it agreed to add a new eth_dev_ops for this?


[1]
* In 17.02 ABI change is planned: the ``rte_eth_dev_info`` structure
  will be extended with a new member ``fw_version`` in order to store
  the NIC firmware version.



>  	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
>  	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
>  	/**< Get packet types supported and identified by device*/

<...>

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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: add firmware version get
  2016-12-08 11:07       ` Ferruh Yigit
@ 2016-12-12  1:28         ` Yang, Qiming
  0 siblings, 0 replies; 128+ messages in thread
From: Yang, Qiming @ 2016-12-12  1:28 UTC (permalink / raw)
  To: Yigit, Ferruh, dev; +Cc: Thomas Monjalon, Horton, Remy

Hi, Yigit
Yes, we had planned to add  fw_version in rte_eth_dev_info_get(). But Remy think we should better to implement this feature through a way don't break the original ABI. So I change the implement.

-----Original Message-----
From: Yigit, Ferruh 
Sent: Thursday, December 8, 2016 7:07 PM
To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org
Cc: Thomas Monjalon <thomas.monjalon@6wind.com>
Subject: Re: [dpdk-dev] [PATCH v2 1/5] ethdev: add firmware version get

Hi Qiming,

On 12/6/2016 7:16 AM, Qiming Yang wrote:
> This patch adds a new API 'rte_eth_dev_fwver_get' for fetching 
> firmware version by a given device.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>

<...>

> @@ -1444,6 +1448,7 @@ struct eth_dev_ops {
>  	/**< Get names of extended statistics. */
>  	eth_queue_stats_mapping_set_t queue_stats_mapping_set;
>  	/**< Configure per queue stat counter mapping. */
> +	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */

Hi Qiming,

Not sure if I am missing something but this change is for following [1] deprecation notice, right?
If so, notice suggest updating rte_eth_dev_info_get() to include fw_version, but this patch adds a new eth_dev_ops.

Is it agreed to add a new eth_dev_ops for this?


[1]
* In 17.02 ABI change is planned: the ``rte_eth_dev_info`` structure
  will be extended with a new member ``fw_version`` in order to store
  the NIC firmware version.



>  	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
>  	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
>  	/**< Get packet types supported and identified by device*/

<...>

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

* Re: [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get
  2016-12-08  8:34     ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get Remy Horton
@ 2016-12-12  1:43       ` Yang, Qiming
  2016-12-22 11:07       ` Thomas Monjalon
  1 sibling, 0 replies; 128+ messages in thread
From: Yang, Qiming @ 2016-12-12  1:43 UTC (permalink / raw)
  To: Horton, Remy, dev

Hi, Remy
I'll add this update in v3 patch, thank you for your remind.
BTW, It looks like Yigit don't agree the implement we used, he think we'd better not add a new ops to get this info.

-----Original Message-----
From: Horton, Remy 
Sent: Thursday, December 8, 2016 4:34 PM
To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get


On 06/12/2016 15:16, Qiming Yang wrote:
[..]
> Qiming Yang (5):
>   ethdev: add firmware version get
>   net/e1000: add firmware version get
>   net/ixgbe: add firmware version get
>   net/i40e: add firmware version get
>   ethtool: dispaly bus info and firmware version

s/dispaly/display

doc/guides/rel_notes/release_17_02.rst ought to be updated as well. Code itself looks ok though..

Acked-by: Remy Horton <remy.horton@intel.com>

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

* Re: [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get
  2016-12-08  8:34     ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get Remy Horton
  2016-12-12  1:43       ` Yang, Qiming
@ 2016-12-22 11:07       ` Thomas Monjalon
  2016-12-22 14:36         ` Ferruh Yigit
  1 sibling, 1 reply; 128+ messages in thread
From: Thomas Monjalon @ 2016-12-22 11:07 UTC (permalink / raw)
  To: Qiming Yang; +Cc: dev, Remy Horton

2016-12-08 16:34, Remy Horton:
> 
> On 06/12/2016 15:16, Qiming Yang wrote:
> [..]
> > Qiming Yang (5):
> >   ethdev: add firmware version get
> >   net/e1000: add firmware version get
> >   net/ixgbe: add firmware version get
> >   net/i40e: add firmware version get
> >   ethtool: dispaly bus info and firmware version
> 
> s/dispaly/display
> 
> doc/guides/rel_notes/release_17_02.rst ought to be updated as well. Code 
> itself looks ok though..
> 
> Acked-by: Remy Horton <remy.horton@intel.com>

It must be a feature in the table (doc/guides/nics/features/).
The deprecation notice must be removed also.

I think it is OK to add a new dev_ops and a new API function for firmware
query. Generally speaking, it is a good thing to avoid putting all
informations in the same structure (e.g. rte_eth_dev_info). However, there
is a balance to find. Could we plan to add more info to this new query?
Instead of
	rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int fw_length)
could it fill a struct?
	rte_eth_dev_fw_info_get(uint8_t port_id, struct rte_eth_dev_fw_info *fw_info)

We already have
	rte_eth_dev_get_reg_info(uint8_t port_id, struct rte_dev_reg_info *info)
with
	uint32_t version; /**< Device version */

There are also these functions (a bit related):
	rte_eth_dev_get_eeprom_length(uint8_t port_id)
	rte_eth_dev_get_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info)

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

* Re: [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get
  2016-12-22 11:07       ` Thomas Monjalon
@ 2016-12-22 14:36         ` Ferruh Yigit
  2016-12-22 14:47           ` Thomas Monjalon
  0 siblings, 1 reply; 128+ messages in thread
From: Ferruh Yigit @ 2016-12-22 14:36 UTC (permalink / raw)
  To: Thomas Monjalon, Qiming Yang; +Cc: dev, Remy Horton

On 12/22/2016 11:07 AM, Thomas Monjalon wrote:
> 2016-12-08 16:34, Remy Horton:
>>
>> On 06/12/2016 15:16, Qiming Yang wrote:
>> [..]
>>> Qiming Yang (5):
>>>   ethdev: add firmware version get
>>>   net/e1000: add firmware version get
>>>   net/ixgbe: add firmware version get
>>>   net/i40e: add firmware version get
>>>   ethtool: dispaly bus info and firmware version
>>
>> s/dispaly/display
>>
>> doc/guides/rel_notes/release_17_02.rst ought to be updated as well. Code 
>> itself looks ok though..
>>
>> Acked-by: Remy Horton <remy.horton@intel.com>
> 
> It must be a feature in the table (doc/guides/nics/features/).
> The deprecation notice must be removed also.
> 
> I think it is OK to add a new dev_ops and a new API function for firmware
> query. Generally speaking, it is a good thing to avoid putting all
> informations in the same structure (e.g. rte_eth_dev_info). 

OK.

> However, there
> is a balance to find. Could we plan to add more info to this new query?
> Instead of
> 	rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int fw_length)

Here there is another problem, the content and the format of the string
is not defined. In this patchset it is not same for different PMDs.
This is OK for just printing the data, but not good for an API. How can
the application know what to expect.

> could it fill a struct?
> 	rte_eth_dev_fw_info_get(uint8_t port_id, struct rte_eth_dev_fw_info *fw_info)

I believe this is better. But the problem we are having with this usage
is: ABI breakage.

Since this struct will be a public structure, in the future if we want
to add a new field to the struct, it will break the ABI, and just this
change will cause a new version for whole ethdev library!

When all required fields received via arguments, one by one, instead of
struct, at least ABI versioning can be done on the API when new field
added, and can be possible to escape from ABI breakage. But this will be
ugly when number of arguments increased.

Or any other opinion on how to define API to reduce ABI breakage?

> 
> We already have
> 	rte_eth_dev_get_reg_info(uint8_t port_id, struct rte_dev_reg_info *info)
> with
> 	uint32_t version; /**< Device version */
> 
> There are also these functions (a bit related):
> 	rte_eth_dev_get_eeprom_length(uint8_t port_id)
> 	rte_eth_dev_get_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info)
> 

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

* Re: [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get
  2016-12-22 14:36         ` Ferruh Yigit
@ 2016-12-22 14:47           ` Thomas Monjalon
  2016-12-22 15:05             ` Ferruh Yigit
  0 siblings, 1 reply; 128+ messages in thread
From: Thomas Monjalon @ 2016-12-22 14:47 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: Qiming Yang, dev, Remy Horton

2016-12-22 14:36, Ferruh Yigit:
> On 12/22/2016 11:07 AM, Thomas Monjalon wrote:
> > I think it is OK to add a new dev_ops and a new API function for firmware
> > query. Generally speaking, it is a good thing to avoid putting all
> > informations in the same structure (e.g. rte_eth_dev_info). 
> 
> OK.
> 
> > However, there
> > is a balance to find. Could we plan to add more info to this new query?
> > Instead of
> > 	rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int fw_length)
[...]
> > could it fill a struct?
> > 	rte_eth_dev_fw_info_get(uint8_t port_id, struct rte_eth_dev_fw_info *fw_info)
> 
> I believe this is better. But the problem we are having with this usage
> is: ABI breakage.
> 
> Since this struct will be a public structure, in the future if we want
> to add a new field to the struct, it will break the ABI, and just this
> change will cause a new version for whole ethdev library!
> 
> When all required fields received via arguments, one by one, instead of
> struct, at least ABI versioning can be done on the API when new field
> added, and can be possible to escape from ABI breakage. But this will be
> ugly when number of arguments increased.
> 
> Or any other opinion on how to define API to reduce ABI breakage?

You're right.
But I don't think we should have a function per data. Just because it would
be ugly :)
I hope the ABI could become stable with time.

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

* Re: [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get
  2016-12-22 14:47           ` Thomas Monjalon
@ 2016-12-22 15:05             ` Ferruh Yigit
  2016-12-22 15:31               ` Thomas Monjalon
  0 siblings, 1 reply; 128+ messages in thread
From: Ferruh Yigit @ 2016-12-22 15:05 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Qiming Yang, dev, Remy Horton

On 12/22/2016 2:47 PM, Thomas Monjalon wrote:
> 2016-12-22 14:36, Ferruh Yigit:
>> On 12/22/2016 11:07 AM, Thomas Monjalon wrote:
>>> I think it is OK to add a new dev_ops and a new API function for firmware
>>> query. Generally speaking, it is a good thing to avoid putting all
>>> informations in the same structure (e.g. rte_eth_dev_info). 
>>
>> OK.
>>
>>> However, there
>>> is a balance to find. Could we plan to add more info to this new query?
>>> Instead of
>>> 	rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int fw_length)
> [...]
>>> could it fill a struct?
>>> 	rte_eth_dev_fw_info_get(uint8_t port_id, struct rte_eth_dev_fw_info *fw_info)
>>
>> I believe this is better. But the problem we are having with this usage
>> is: ABI breakage.
>>
>> Since this struct will be a public structure, in the future if we want
>> to add a new field to the struct, it will break the ABI, and just this
>> change will cause a new version for whole ethdev library!
>>
>> When all required fields received via arguments, one by one, instead of
>> struct, at least ABI versioning can be done on the API when new field
>> added, and can be possible to escape from ABI breakage. But this will be
>> ugly when number of arguments increased.
>>
>> Or any other opinion on how to define API to reduce ABI breakage?
> 
> You're right.
> But I don't think we should have a function per data. Just because it would
> be ugly :)

I am no suggesting function per data, instead something like:

rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t maj, uint32_t min);

And in the future if we need etrack_id too, we can have both in
versioned manner:

rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t maj, uint32_t min);

rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t maj, uint32_t min,
	uint32_t etrack_id);

So my concern was if the number of the arguments becomes too many by time.


> I hope the ABI could become stable with time.
> 

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

* Re: [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get
  2016-12-22 15:05             ` Ferruh Yigit
@ 2016-12-22 15:31               ` Thomas Monjalon
  2016-12-23 12:48                 ` Ferruh Yigit
  2017-01-05  3:04                 ` Zhang, Helin
  0 siblings, 2 replies; 128+ messages in thread
From: Thomas Monjalon @ 2016-12-22 15:31 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: Qiming Yang, dev, Remy Horton

2016-12-22 15:05, Ferruh Yigit:
> On 12/22/2016 2:47 PM, Thomas Monjalon wrote:
> > 2016-12-22 14:36, Ferruh Yigit:
> >> On 12/22/2016 11:07 AM, Thomas Monjalon wrote:
> >>> I think it is OK to add a new dev_ops and a new API function for firmware
> >>> query. Generally speaking, it is a good thing to avoid putting all
> >>> informations in the same structure (e.g. rte_eth_dev_info). 
> >>
> >> OK.
> >>
> >>> However, there
> >>> is a balance to find. Could we plan to add more info to this new query?
> >>> Instead of
> >>> 	rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int fw_length)
> > [...]
> >>> could it fill a struct?
> >>> 	rte_eth_dev_fw_info_get(uint8_t port_id, struct rte_eth_dev_fw_info *fw_info)
> >>
> >> I believe this is better. But the problem we are having with this usage
> >> is: ABI breakage.
> >>
> >> Since this struct will be a public structure, in the future if we want
> >> to add a new field to the struct, it will break the ABI, and just this
> >> change will cause a new version for whole ethdev library!
> >>
> >> When all required fields received via arguments, one by one, instead of
> >> struct, at least ABI versioning can be done on the API when new field
> >> added, and can be possible to escape from ABI breakage. But this will be
> >> ugly when number of arguments increased.
> >>
> >> Or any other opinion on how to define API to reduce ABI breakage?
> > 
> > You're right.
> > But I don't think we should have a function per data. Just because it would
> > be ugly :)
> 
> I am no suggesting function per data, instead something like:
> 
> rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t maj, uint32_t min);
> 
> And in the future if we need etrack_id too, we can have both in
> versioned manner:
> 
> rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t maj, uint32_t min);
> 
> rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t maj, uint32_t min,
> 	uint32_t etrack_id);

Oh I see. So it can be versioned with compat macros.

> So my concern was if the number of the arguments becomes too many by time.

It looks to be a good proposal. We should not have a dozen of arguments.

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

* Re: [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get
  2016-12-22 15:31               ` Thomas Monjalon
@ 2016-12-23 12:48                 ` Ferruh Yigit
  2017-01-05  3:04                 ` Zhang, Helin
  1 sibling, 0 replies; 128+ messages in thread
From: Ferruh Yigit @ 2016-12-23 12:48 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Qiming Yang, dev, Remy Horton

On 12/22/2016 3:31 PM, Thomas Monjalon wrote:
> 2016-12-22 15:05, Ferruh Yigit:
>> On 12/22/2016 2:47 PM, Thomas Monjalon wrote:
>>> 2016-12-22 14:36, Ferruh Yigit:
>>>> On 12/22/2016 11:07 AM, Thomas Monjalon wrote:
>>>>> I think it is OK to add a new dev_ops and a new API function for firmware
>>>>> query. Generally speaking, it is a good thing to avoid putting all
>>>>> informations in the same structure (e.g. rte_eth_dev_info). 
>>>>
>>>> OK.
>>>>
>>>>> However, there
>>>>> is a balance to find. Could we plan to add more info to this new query?
>>>>> Instead of
>>>>> 	rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int fw_length)
>>> [...]
>>>>> could it fill a struct?
>>>>> 	rte_eth_dev_fw_info_get(uint8_t port_id, struct rte_eth_dev_fw_info *fw_info)
>>>>
>>>> I believe this is better. But the problem we are having with this usage
>>>> is: ABI breakage.
>>>>
>>>> Since this struct will be a public structure, in the future if we want
>>>> to add a new field to the struct, it will break the ABI, and just this
>>>> change will cause a new version for whole ethdev library!
>>>>
>>>> When all required fields received via arguments, one by one, instead of
>>>> struct, at least ABI versioning can be done on the API when new field
>>>> added, and can be possible to escape from ABI breakage. But this will be
>>>> ugly when number of arguments increased.
>>>>
>>>> Or any other opinion on how to define API to reduce ABI breakage?
>>>
>>> You're right.
>>> But I don't think we should have a function per data. Just because it would
>>> be ugly :)
>>
>> I am no suggesting function per data, instead something like:
>>
>> rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t maj, uint32_t min);
>>
>> And in the future if we need etrack_id too, we can have both in
>> versioned manner:
>>
>> rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t maj, uint32_t min);
>>
>> rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t maj, uint32_t min,
>> 	uint32_t etrack_id);
> 
> Oh I see. So it can be versioned with compat macros.
> 
>> So my concern was if the number of the arguments becomes too many by time.
> 
> It looks to be a good proposal. We should not have a dozen of arguments.
> 

So, I suggest trying this approach in this API.


Overall, change request for the patch becomes:
1- Change API, is following arguments good enough to start with?:
- FW_major_number
- FW_minor_number
- FW_patch_number
- Etrack_id

If so, API becomes:
rte_eth_dev_fw_version_get(uint8_t port_id, uint32_t *fw_major,
	uint32_t *fw_minor, uint32_t *fw_patch, uint32_t *etrack_id);

! Note, I have renamed API to rte_eth_dev_fw_version_get() from
rte_eth_dev_fw_info_get() mentioned above, to narrow the scope of API.

and dev_ops name keeps same: fw_version_get

2- Add new feature in feature table (doc/guides/nics/features/), first
patch can add to the default one, and each driver patch implements this
feature should update its feature table.
Feature name can be "FW version"

3- Remove deprecation notice in the first patch.


Thanks,
ferruh

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

* Re: [dpdk-dev] [PATCH v2 5/5] ethtool: dispaly bus info and firmware version
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 5/5] ethtool: dispaly bus info and firmware version Qiming Yang
@ 2016-12-23 12:50       ` Ferruh Yigit
  2016-12-27 13:06       ` [dpdk-dev] [PATCH v3] " Qiming Yang
  1 sibling, 0 replies; 128+ messages in thread
From: Ferruh Yigit @ 2016-12-23 12:50 UTC (permalink / raw)
  To: Qiming Yang, dev

On 12/6/2016 7:16 AM, Qiming Yang wrote:
> This patch enhances the ethtool example to support to show
> bus information and firmware version, in the same way that
> the Linux kernel ethtool does.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> ---
> v2 changes:
> *  modified the commit log
> ---
> ---
>  examples/ethtool/ethtool-app/ethapp.c | 2 ++
>  examples/ethtool/lib/rte_ethtool.c    | 3 +++
>  2 files changed, 5 insertions(+)
> 
> diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
> index 38e466c..9b77385 100644
> --- a/examples/ethtool/ethtool-app/ethapp.c
> +++ b/examples/ethtool/ethtool-app/ethapp.c
> @@ -184,6 +184,8 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
>  		printf("Port %i driver: %s (ver: %s)\n",
>  			id_port, info.driver, info.version
>  		      );
> +		printf("bus-info: %s\n", info.bus_info);

Can you please remove above line from this patch, if you want can be a
separate patch.

Thanks,
ferruh

> +		printf("firmware-version: %s\n", info.fw_version);
>  	}
>  }
>  
> diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c

<...>

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

* [dpdk-dev] [PATCH v3 0/4] new API 'rte_eth_dev_fw_info_get'
  2016-12-06  7:16   ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw " Qiming Yang
                       ` (5 preceding siblings ...)
  2016-12-08  8:34     ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get Remy Horton
@ 2016-12-27 12:30     ` Qiming Yang
  2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get Qiming Yang
                         ` (4 more replies)
  6 siblings, 5 replies; 128+ messages in thread
From: Qiming Yang @ 2016-12-27 12:30 UTC (permalink / raw)
  To: dev, thomas.monjalon; +Cc: remy.horton, ferruh.yigit, Qiming Yang

These four patches added a new function ``rte_eth_dev_fwver_get()``
to fetch firmware related information by a given device.
Information include major firmware version, minor firmware
version, patch number and etrack id.

Qiming Yang (4):
  ethdev: add firmware information get
  net/e1000: add firmware version get
  net/ixgbe: add firmware version get
  net/i40e: add firmware version get

 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/nics/features/i40e.ini      |  1 +
 doc/guides/nics/features/igb.ini       |  1 +
 doc/guides/nics/features/ixgbe.ini     |  1 +
 doc/guides/rel_notes/release_17_02.rst |  4 ++++
 drivers/net/e1000/igb_ethdev.c         | 43 ++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.c         | 15 ++++++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c       | 17 ++++++++++++++
 lib/librte_ether/rte_ethdev.c          | 14 +++++++++++
 lib/librte_ether/rte_ethdev.h          | 23 ++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 11 files changed, 121 insertions(+)

-- 
2.7.4

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

* [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get
  2016-12-27 12:30     ` [dpdk-dev] [PATCH v3 0/4] new API 'rte_eth_dev_fw_info_get' Qiming Yang
@ 2016-12-27 12:30       ` Qiming Yang
  2017-01-02 15:38         ` Thomas Monjalon
  2017-01-03 14:58         ` Ferruh Yigit
  2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 2/4] net/e1000: add firmware version get Qiming Yang
                         ` (3 subsequent siblings)
  4 siblings, 2 replies; 128+ messages in thread
From: Qiming Yang @ 2016-12-27 12:30 UTC (permalink / raw)
  To: dev, thomas.monjalon; +Cc: remy.horton, ferruh.yigit, Qiming Yang

This patch adds a new API 'rte_eth_dev_fw_info_get' for fetching
firmware related information by a given device.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
v2 changes:
* modified some comment statements.
v3 changes:
* change API, use rte_eth_dev_fw_info_get(uint8_t port_id,
  uint32_t *fw_major, uint32_t *fw_minor, uint32_t *fw_patch,
  uint32_t *etrack_id) instead of rte_eth_dev_fwver_get(uint8_t port_id,
  char *fw_version, int fw_length).
  Add statusment in /doc/guides/nics/features/default.ini and
  release_17_02.rst.
---
---
 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/rel_notes/release_17_02.rst |  4 ++++
 lib/librte_ether/rte_ethdev.c          | 14 ++++++++++++++
 lib/librte_ether/rte_ethdev.h          | 23 +++++++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 5 files changed, 43 insertions(+)

diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
index f1bf9bf..8237ee4 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -66,3 +66,4 @@ x86-64               =
 Usage doc            =
 Design doc           =
 Perf doc             =
+FW version           =
diff --git a/doc/guides/rel_notes/release_17_02.rst b/doc/guides/rel_notes/release_17_02.rst
index 180af82..f6dc6c0 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,10 @@ New Features
   See the :ref:`Generic flow API <Generic_flow_API>` documentation for more
   information.
 
+* **Added firmware information get API.**
+ Added a new function ``rte_eth_dev_fw_info_get()`` to fetch firmware related
+ information by a given device. Information include major firmware version,
+ minor firmware version, patch number and etrack id.
 
 Resolved Issues
 ---------------
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 280f0db..f399f09 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1586,6 +1586,20 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
 }
 
 void
+rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t *fw_major, uint32_t *fw_minor,
+	uint32_t *fw_patch, uint32_t *etrack_id)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
+	dev = &rte_eth_devices[port_id];
+
+	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->fw_version_get);
+	(*dev->dev_ops->fw_version_get)(dev, fw_major, fw_minor,
+					fw_patch, etrack_id);
+}
+
+void
 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 {
 	struct rte_eth_dev *dev;
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index fb51754..829f652 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1150,6 +1150,11 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
 /**< @internal Check DD bit of specific RX descriptor */
 
+typedef void (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
+		uint32_t *fw_major, uint32_t *fw_minor,
+		uint32_t *fw_patch, uint32_t *etrack_id);
+/**< @internal Get firmware information of an Ethernet device. */
+
 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
 	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
 
@@ -1457,6 +1462,7 @@ struct eth_dev_ops {
 	eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
 	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
 	/**< Get packet types supported and identified by device. */
+	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
 
 	vlan_filter_set_t          vlan_filter_set; /**< Filter VLAN Setup. */
 	vlan_tpid_set_t            vlan_tpid_set; /**< Outer/Inner VLAN TPID Setup. */
@@ -2395,6 +2401,23 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
 void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
 
 /**
+ * Retrieve the firmware version of a device.
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param fw_major
+ *   A array pointer to store the major firmware version of a device.
+ * @param fw_minor
+ *   A array pointer to store the minor firmware version of a device.
+ * @param fw_patch
+ *   A array pointer to store the firmware patch number of a device.
+ * @param etrack_id
+ *   A array pointer to store the nvm version of a device.
+ */
+void rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t *fw_major,
+	uint32_t *fw_minor, uint32_t *fw_patch, uint32_t *etrack_id);
+
+/**
  * Retrieve the supported packet types of an Ethernet device.
  *
  * When a packet type is announced as supported, it *must* be recognized by
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index a021781..a89bfaa 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -156,5 +156,6 @@ DPDK_17.02 {
 	rte_flow_flush;
 	rte_flow_query;
 	rte_flow_validate;
+	rte_eth_dev_fw_info_get;
 
 } DPDK_16.11;
-- 
2.7.4

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

* [dpdk-dev] [PATCH v3 2/4] net/e1000: add firmware version get
  2016-12-27 12:30     ` [dpdk-dev] [PATCH v3 0/4] new API 'rte_eth_dev_fw_info_get' Qiming Yang
  2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get Qiming Yang
@ 2016-12-27 12:30       ` Qiming Yang
  2017-01-03 15:02         ` Ferruh Yigit
  2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 3/4] net/ixgbe: " Qiming Yang
                         ` (2 subsequent siblings)
  4 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2016-12-27 12:30 UTC (permalink / raw)
  To: dev, thomas.monjalon; +Cc: remy.horton, ferruh.yigit, Qiming Yang

This patch adds a new function eth_igb_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
v3 changes:
 * use eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
   u32 *fw_minor, u32 *fw_minor, u32 *fw_patch, u32 *etrack_id) instead
   of eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
   int fw_length). Add statusment in /doc/guides/nics/features/igb.ini.
---
---
 doc/guides/nics/features/igb.ini |  1 +
 drivers/net/e1000/igb_ethdev.c   | 43 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/doc/guides/nics/features/igb.ini b/doc/guides/nics/features/igb.ini
index 9fafe72..ffd87ba 100644
--- a/doc/guides/nics/features/igb.ini
+++ b/doc/guides/nics/features/igb.ini
@@ -39,6 +39,7 @@ EEPROM dump          = Y
 Registers dump       = Y
 BSD nic_uio          = Y
 Linux UIO            = Y
+FW version           = Y
 Linux VFIO           = Y
 x86-32               = Y
 x86-64               = Y
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 4a15447..25344b7 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -120,6 +120,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
 				    unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
+static void eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
+		u32 *fw_minor, u32 *fw_patch, u32 *etrack_id);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static const uint32_t *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -389,6 +391,7 @@ static const struct eth_dev_ops eth_igb_ops = {
 	.xstats_get_names     = eth_igb_xstats_get_names,
 	.stats_reset          = eth_igb_stats_reset,
 	.xstats_reset         = eth_igb_xstats_reset,
+	.fw_version_get       = eth_igb_fw_version_get,
 	.dev_infos_get        = eth_igb_infos_get,
 	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
 	.mtu_set              = eth_igb_mtu_set,
@@ -1981,6 +1984,46 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
 }
 
 static void
+eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major, u32 *fw_minor,
+			u32 *fw_patch, u32 *etrack_id)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_fw_version fw;
+
+	e1000_get_fw_version(hw, &fw);
+
+	switch (hw->mac.type) {
+	case e1000_i210:
+	case e1000_i211:
+		if (!(e1000_get_flash_presence_i210(hw))) {
+			*fw_major = fw.invm_major;
+			*fw_minor = fw.invm_minor;
+			break;
+		}
+		/* fall through */
+	default:
+		/* if option rom is valid, display its version too*/
+		if (fw.or_valid) {
+			*fw_major = fw.eep_major;
+			*fw_minor = fw.eep_minor;
+			*etrack_id = fw.etrack_id;
+			*fw_patch = fw.or_patch;
+		/* no option rom */
+		} else {
+			if (fw.etrack_id != 0X0000) {
+			*fw_major = fw.eep_major;
+			*fw_minor = fw.eep_minor;
+			*etrack_id = fw.etrack_id;
+			} else {
+			*fw_major = fw.eep_major;
+			*fw_minor = fw.eep_minor;
+			}
+		}
+		break;
+	}
+}
+
+static void
 eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH v3 3/4] net/ixgbe: add firmware version get
  2016-12-27 12:30     ` [dpdk-dev] [PATCH v3 0/4] new API 'rte_eth_dev_fw_info_get' Qiming Yang
  2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get Qiming Yang
  2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 2/4] net/e1000: add firmware version get Qiming Yang
@ 2016-12-27 12:30       ` Qiming Yang
  2017-01-03 15:04         ` Ferruh Yigit
  2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 4/4] net/i40e: " Qiming Yang
  2017-01-04 12:03       ` [dpdk-dev] [PATCH v4 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  4 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2016-12-27 12:30 UTC (permalink / raw)
  To: dev, thomas.monjalon; +Cc: remy.horton, ferruh.yigit, Qiming Yang

This patch add a new function ixgbe_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
v3 changes:
 * use ixgbe_fw_version_get(struct rte_eth_dev *dev,
   __rte_unused u32 *fw_major, __rte_unused u32 *fw_minor,
   __rte_unused u32 *fw_patch, u32 *etrack_id) instead of
    ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
   int fw_length). Add statusment in /doc/guides/nics/features/ixgbe.ini.
---
---
 doc/guides/nics/features/ixgbe.ini |  1 +
 drivers/net/ixgbe/ixgbe_ethdev.c   | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/doc/guides/nics/features/ixgbe.ini b/doc/guides/nics/features/ixgbe.ini
index 4a5667f..e4a0830 100644
--- a/doc/guides/nics/features/ixgbe.ini
+++ b/doc/guides/nics/features/ixgbe.ini
@@ -52,3 +52,4 @@ Linux VFIO           = Y
 ARMv8                = Y
 x86-32               = Y
 x86-64               = Y
+FW_version           = Y
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index ec2edad..e2234c0 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -193,6 +193,9 @@ static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint16_t queue_id,
 					     uint8_t stat_idx,
 					     uint8_t is_rx);
+static void ixgbe_fw_version_get(struct rte_eth_dev *dev,
+	__rte_unused u32 *fw_major, __rte_unused u32 *fw_minor,
+	__rte_unused u32 *fw_patch, u32 *etrack_id);
 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
 			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -538,6 +541,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.xstats_reset         = ixgbe_dev_xstats_reset,
 	.xstats_get_names     = ixgbe_dev_xstats_get_names,
 	.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
+	.fw_version_get       = ixgbe_fw_version_get,
 	.dev_infos_get        = ixgbe_dev_info_get,
 	.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
 	.mtu_set              = ixgbe_dev_mtu_set,
@@ -3029,6 +3033,19 @@ ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
 }
 
 static void
+ixgbe_fw_version_get(struct rte_eth_dev *dev, __rte_unused u32 *fw_major,
+	__rte_unused u32 *fw_minor, __rte_unused u32 *fw_patch, u32 *etrack_id)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u16 eeprom_verh, eeprom_verl;
+
+	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
+	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
+
+	*etrack_id = (eeprom_verh << 16) | eeprom_verl;
+}
+
+static void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
-- 
2.7.4

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

* [dpdk-dev] [PATCH v3 4/4] net/i40e: add firmware version get
  2016-12-27 12:30     ` [dpdk-dev] [PATCH v3 0/4] new API 'rte_eth_dev_fw_info_get' Qiming Yang
                         ` (2 preceding siblings ...)
  2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 3/4] net/ixgbe: " Qiming Yang
@ 2016-12-27 12:30       ` Qiming Yang
  2017-01-04 12:03       ` [dpdk-dev] [PATCH v4 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  4 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2016-12-27 12:30 UTC (permalink / raw)
  To: dev, thomas.monjalon; +Cc: remy.horton, ferruh.yigit, Qiming Yang

This patch add a new function i40e_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
v3 changes:
 * use i40e_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
   u32 *fw_minor, __rte_unused u32 *fw_patch, u32 *etrack_id)
   instead of i40e_fw_version_get(struct rte_eth_dev *dev,
   char *fw_version, int fw_length). Add statusment in
   /doc/guides/nics/features/i40e.ini.
---
---
 doc/guides/nics/features/i40e.ini |  1 +
 drivers/net/i40e/i40e_ethdev.c    | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/doc/guides/nics/features/i40e.ini b/doc/guides/nics/features/i40e.ini
index 0d143bc..6dab9f7 100644
--- a/doc/guides/nics/features/i40e.ini
+++ b/doc/guides/nics/features/i40e.ini
@@ -46,3 +46,4 @@ Linux VFIO           = Y
 x86-32               = Y
 x86-64               = Y
 ARMv8                = Y
+FW version           = Y
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 8f63044..1dbbcc4 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -324,6 +324,8 @@ static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
 					    uint16_t queue_id,
 					    uint8_t stat_idx,
 					    uint8_t is_rx);
+static void i40e_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
+	u32 *fw_minor, __rte_unused u32 *fw_patch, u32 *etrack_id);
 static void i40e_dev_info_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static int i40e_vlan_filter_set(struct rte_eth_dev *dev,
@@ -503,6 +505,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.stats_reset                  = i40e_dev_stats_reset,
 	.xstats_reset                 = i40e_dev_stats_reset,
 	.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
+	.fw_version_get               = i40e_fw_version_get,
 	.dev_infos_get                = i40e_dev_info_get,
 	.dev_supported_ptypes_get     = i40e_dev_supported_ptypes_get,
 	.vlan_filter_set              = i40e_vlan_filter_set,
@@ -2590,6 +2593,18 @@ i40e_dev_queue_stats_mapping_set(__rte_unused struct rte_eth_dev *dev,
 }
 
 static void
+i40e_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major, u32 *fw_minor,
+		__rte_unused u32 *fw_patch, u32 *etrack_id)
+{
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	*fw_major = (hw->nvm.version >> 12) & 0xf;
+	*fw_minor = ((hw->nvm.version >> 4) & 0xff) * 10 +
+			(hw->nvm.version & 0xf);
+	*etrack_id = hw->nvm.eetrack;
+}
+
+static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH v3] ethtool: dispaly bus info and firmware version
  2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 5/5] ethtool: dispaly bus info and firmware version Qiming Yang
  2016-12-23 12:50       ` Ferruh Yigit
@ 2016-12-27 13:06       ` Qiming Yang
  2017-01-04  7:51         ` Wu, Jingjing
  2017-01-04 12:18         ` [dpdk-dev] [PATCH v4] ethtool: dispaly bus information Qiming Yang
  1 sibling, 2 replies; 128+ messages in thread
From: Qiming Yang @ 2016-12-27 13:06 UTC (permalink / raw)
  To: dev, thomas.monjalon; +Cc: remy.horton, ferruh.yigit, Qiming Yang

This patch enhances the ethtool example to support to show
bus information and firmware version, in the same way that
the Linux kernel ethtool does.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
v3 changes:
 * split this patch from the patch set of rte_eth_dev_fw_info_get
   use the new version function.
---
---
 examples/ethtool/ethtool-app/ethapp.c |  2 ++
 examples/ethtool/lib/rte_ethtool.c    | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
index 6aeaa06..192d941 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -185,6 +185,8 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
 		printf("Port %i driver: %s (ver: %s)\n",
 			id_port, info.driver, info.version
 		      );
+		printf("bus-info: %s\n", info.bus_info);
+		printf("firmware-version: %s\n", info.fw_version);
 	}
 }
 
diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index 6f0ce84..f62f1d3 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -54,6 +54,11 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
+	uint32_t fw_major = 0;
+	uint32_t fw_minor = 0;
+	uint32_t etrack = 0;
+
+	rte_eth_dev_fw_info_get(port_id, &fw_major, &fw_minor, NULL, &etrack);
 	memset(&dev_info, 0, sizeof(dev_info));
 	rte_eth_dev_info_get(port_id, &dev_info);
 
@@ -61,6 +66,12 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 		dev_info.driver_name);
 	snprintf(drvinfo->version, sizeof(drvinfo->version), "%s",
 		rte_version());
+	if (strcmp(drvinfo->driver, "net_ixgbe") == 0)
+		snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
+			 "0x%08x", etrack);
+	else
+		snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
+			 "%d.%02d 0x%08x", fw_major, fw_minor, etrack);
 	if (dev_info.pci_dev)
 		snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info),
 			"%04x:%02x:%02x.%x",
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get
  2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get Qiming Yang
@ 2017-01-02 15:38         ` Thomas Monjalon
       [not found]           ` <F5DF4F0E3AFEF648ADC1C3C33AD4DBF16EDC9515@SHSMSX101.ccr.corp.intel.com>
  2017-01-03 14:58         ` Ferruh Yigit
  1 sibling, 1 reply; 128+ messages in thread
From: Thomas Monjalon @ 2017-01-02 15:38 UTC (permalink / raw)
  To: Qiming Yang; +Cc: dev, remy.horton, ferruh.yigit

2016-12-27 20:30, Qiming Yang:
>  /**
> + * Retrieve the firmware version of a device.
> + *
> + * @param port_id
> + *   The port identifier of the device.
> + * @param fw_major
> + *   A array pointer to store the major firmware version of a device.
> + * @param fw_minor
> + *   A array pointer to store the minor firmware version of a device.
> + * @param fw_patch
> + *   A array pointer to store the firmware patch number of a device.
> + * @param etrack_id
> + *   A array pointer to store the nvm version of a device.
> + */
> +void rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t *fw_major,
> +	uint32_t *fw_minor, uint32_t *fw_patch, uint32_t *etrack_id);

I have a reserve about the naming etrack_id.
Please could you point to a document explaining this ID?
Is it known outside of Intel?

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

* Re: [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get
       [not found]             ` <10603884.vrshqR2O82@xps13>
@ 2017-01-03  9:05               ` Yang, Qiming
  2017-01-03 14:49                 ` Ferruh Yigit
  0 siblings, 1 reply; 128+ messages in thread
From: Yang, Qiming @ 2017-01-03  9:05 UTC (permalink / raw)
  To: Yigit, Ferruh; +Cc: dev, Horton, Remy, Thomas Monjalon

Hi, Ferruh
Please see the question below. In my opinion, etrack_id is just a name used to define the ID of one NIC.
In kernel version ethtool, it will print this ID in the line of firmware verison. 
I know what is etrack_id mean, but I really don't know why this named etrack_id.
Can you explain this question?
 
-----Original Message-----
From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] 
Sent: Tuesday, January 3, 2017 4:40 PM
To: Yang, Qiming <qiming.yang@intel.com>
Subject: Re: [PATCH v3 1/4] ethdev: add firmware information get

Please reply below the question and on the mailing list.
You'll have to explain why this name etrack_id.

2017-01-03 03:28, Yang, Qiming:
> Hi, Thomas
> etrack_id is not a terminology, it's decided by me.
> Which is store the unique number of the firmware.
> firmware-version: 5.04 0x800024ca
> 800024ca is the etrack_id of this NIC.
> 
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] 
> Sent: Monday, January 2, 2017 11:39 PM
> To: Yang, Qiming <qiming.yang@intel.com>
> Cc: dev@dpdk.org; Horton, Remy <remy.horton@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: Re: [PATCH v3 1/4] ethdev: add firmware information get
> 
> 2016-12-27 20:30, Qiming Yang:
> >  /**
> > + * Retrieve the firmware version of a device.
> > + *
> > + * @param port_id
> > + *   The port identifier of the device.
> > + * @param fw_major
> > + *   A array pointer to store the major firmware version of a device.
> > + * @param fw_minor
> > + *   A array pointer to store the minor firmware version of a device.
> > + * @param fw_patch
> > + *   A array pointer to store the firmware patch number of a device.
> > + * @param etrack_id
> > + *   A array pointer to store the nvm version of a device.
> > + */
> > +void rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t *fw_major,
> > +	uint32_t *fw_minor, uint32_t *fw_patch, uint32_t *etrack_id);
> 
> I have a reserve about the naming etrack_id.
> Please could you point to a document explaining this ID?
> Is it known outside of Intel?

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

* Re: [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get
  2017-01-03  9:05               ` Yang, Qiming
@ 2017-01-03 14:49                 ` Ferruh Yigit
  2017-01-04  3:33                   ` Yang, Qiming
  0 siblings, 1 reply; 128+ messages in thread
From: Ferruh Yigit @ 2017-01-03 14:49 UTC (permalink / raw)
  To: Yang, Qiming; +Cc: dev, Horton, Remy, Thomas Monjalon

On 1/3/2017 9:05 AM, Yang, Qiming wrote:
> Hi, Ferruh
> Please see the question below. In my opinion, etrack_id is just a name used to define the ID of one NIC.
> In kernel version ethtool, it will print this ID in the line of firmware verison. 
> I know what is etrack_id mean, but I really don't know why this named etrack_id.

Hi Qiming,

I suggested the API based on fields you already used in your patch.

So, this API is to get FW version, is etrack_id something that defines
(part of) firmware version?

Thanks,
ferruh


> Can you explain this question?
>  
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] 
> Sent: Tuesday, January 3, 2017 4:40 PM
> To: Yang, Qiming <qiming.yang@intel.com>
> Subject: Re: [PATCH v3 1/4] ethdev: add firmware information get
> 
> Please reply below the question and on the mailing list.
> You'll have to explain why this name etrack_id.
> 
> 2017-01-03 03:28, Yang, Qiming:
>> Hi, Thomas
>> etrack_id is not a terminology, it's decided by me.
>> Which is store the unique number of the firmware.
>> firmware-version: 5.04 0x800024ca
>> 800024ca is the etrack_id of this NIC.
>>
>> -----Original Message-----
>> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] 
>> Sent: Monday, January 2, 2017 11:39 PM
>> To: Yang, Qiming <qiming.yang@intel.com>
>> Cc: dev@dpdk.org; Horton, Remy <remy.horton@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
>> Subject: Re: [PATCH v3 1/4] ethdev: add firmware information get
>>
>> 2016-12-27 20:30, Qiming Yang:
>>>  /**
>>> + * Retrieve the firmware version of a device.
>>> + *
>>> + * @param port_id
>>> + *   The port identifier of the device.
>>> + * @param fw_major
>>> + *   A array pointer to store the major firmware version of a device.
>>> + * @param fw_minor
>>> + *   A array pointer to store the minor firmware version of a device.
>>> + * @param fw_patch
>>> + *   A array pointer to store the firmware patch number of a device.
>>> + * @param etrack_id
>>> + *   A array pointer to store the nvm version of a device.
>>> + */
>>> +void rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t *fw_major,
>>> +	uint32_t *fw_minor, uint32_t *fw_patch, uint32_t *etrack_id);
>>
>> I have a reserve about the naming etrack_id.
>> Please could you point to a document explaining this ID?
>> Is it known outside of Intel?
> 
> 

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

* Re: [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get
  2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get Qiming Yang
  2017-01-02 15:38         ` Thomas Monjalon
@ 2017-01-03 14:58         ` Ferruh Yigit
  1 sibling, 0 replies; 128+ messages in thread
From: Ferruh Yigit @ 2017-01-03 14:58 UTC (permalink / raw)
  To: Qiming Yang, dev, thomas.monjalon; +Cc: remy.horton

On 12/27/2016 12:30 PM, Qiming Yang wrote:
> This patch adds a new API 'rte_eth_dev_fw_info_get' for fetching
> firmware related information by a given device.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> Acked-by: Remy Horton <remy.horton@intel.com>
> ---
> v2 changes:
> * modified some comment statements.
> v3 changes:
> * change API, use rte_eth_dev_fw_info_get(uint8_t port_id,
>   uint32_t *fw_major, uint32_t *fw_minor, uint32_t *fw_patch,
>   uint32_t *etrack_id) instead of rte_eth_dev_fwver_get(uint8_t port_id,
>   char *fw_version, int fw_length).
>   Add statusment in /doc/guides/nics/features/default.ini and
>   release_17_02.rst.
> ---
> ---
>  doc/guides/nics/features/default.ini   |  1 +
>  doc/guides/rel_notes/release_17_02.rst |  4 ++++
>  lib/librte_ether/rte_ethdev.c          | 14 ++++++++++++++
>  lib/librte_ether/rte_ethdev.h          | 23 +++++++++++++++++++++++
>  lib/librte_ether/rte_ether_version.map |  1 +
>  5 files changed, 43 insertions(+)

This patch also should remove deprecation notice.
Item 3 of the requested changes.

> 
> diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
> index f1bf9bf..8237ee4 100644
> --- a/doc/guides/nics/features/default.ini
> +++ b/doc/guides/nics/features/default.ini
> @@ -66,3 +66,4 @@ x86-64               =
>  Usage doc            =
>  Design doc           =
>  Perf doc             =
> +FW version           =

I am not sure about this location, I think it can be before "EEPROM
dump", what do you think?

> diff --git a/doc/guides/rel_notes/release_17_02.rst b/doc/guides/rel_notes/release_17_02.rst
> index 180af82..f6dc6c0 100644
> --- a/doc/guides/rel_notes/release_17_02.rst
> +++ b/doc/guides/rel_notes/release_17_02.rst
> @@ -52,6 +52,10 @@ New Features
>    See the :ref:`Generic flow API <Generic_flow_API>` documentation for more
>    information.
>  
> +* **Added firmware information get API.**
> + Added a new function ``rte_eth_dev_fw_info_get()`` to fetch firmware related
> + information by a given device. Information include major firmware version,
> + minor firmware version, patch number and etrack id.
>  
>  Resolved Issues
>  ---------------
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index 280f0db..f399f09 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -1586,6 +1586,20 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
>  }
>  
>  void
> +rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t *fw_major, uint32_t *fw_minor,
> +	uint32_t *fw_patch, uint32_t *etrack_id)

I am for rte_eth_dev_fw_version_get(), to limit the scope of the API.
And API name and eth_dev_ops name should match..

> +{
> +	struct rte_eth_dev *dev;
> +
> +	RTE_ETH_VALID_PORTID_OR_RET(port_id);
> +	dev = &rte_eth_devices[port_id];
> +

What do you think setting all arguments to zero here?

> +	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->fw_version_get);
> +	(*dev->dev_ops->fw_version_get)(dev, fw_major, fw_minor,
> +					fw_patch, etrack_id);
> +}
> +

<...>

> --- a/lib/librte_ether/rte_ether_version.map
> +++ b/lib/librte_ether/rte_ether_version.map
> @@ -156,5 +156,6 @@ DPDK_17.02 {
>  	rte_flow_flush;
>  	rte_flow_query;
>  	rte_flow_validate;
> +	rte_eth_dev_fw_info_get;

Please add this alphabetically sorted.

>  
>  } DPDK_16.11;
> 

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

* Re: [dpdk-dev] [PATCH v3 2/4] net/e1000: add firmware version get
  2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 2/4] net/e1000: add firmware version get Qiming Yang
@ 2017-01-03 15:02         ` Ferruh Yigit
  2017-01-04  3:14           ` Yang, Qiming
  0 siblings, 1 reply; 128+ messages in thread
From: Ferruh Yigit @ 2017-01-03 15:02 UTC (permalink / raw)
  To: Qiming Yang, dev, thomas.monjalon; +Cc: remy.horton

On 12/27/2016 12:30 PM, Qiming Yang wrote:
> This patch adds a new function eth_igb_fw_version_get.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> ---
> v3 changes:
>  * use eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
>    u32 *fw_minor, u32 *fw_minor, u32 *fw_patch, u32 *etrack_id) instead
>    of eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
>    int fw_length). Add statusment in /doc/guides/nics/features/igb.ini.
> ---
> ---
>  doc/guides/nics/features/igb.ini |  1 +
>  drivers/net/e1000/igb_ethdev.c   | 43 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+)
> 
> diff --git a/doc/guides/nics/features/igb.ini b/doc/guides/nics/features/igb.ini
> index 9fafe72..ffd87ba 100644
> --- a/doc/guides/nics/features/igb.ini
> +++ b/doc/guides/nics/features/igb.ini
> @@ -39,6 +39,7 @@ EEPROM dump          = Y
>  Registers dump       = Y
>  BSD nic_uio          = Y
>  Linux UIO            = Y
> +FW version           = Y

Please keep same location with default.ini file. Why you are putting
this just into middle of the uio and vfio?

>  Linux VFIO           = Y
>  x86-32               = Y
>  x86-64               = Y
> diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
> index 4a15447..25344b7 100644
> --- a/drivers/net/e1000/igb_ethdev.c
> +++ b/drivers/net/e1000/igb_ethdev.c
> @@ -120,6 +120,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
>  				    unsigned limit);
>  static void eth_igb_stats_reset(struct rte_eth_dev *dev);
>  static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
> +static void eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
> +		u32 *fw_minor, u32 *fw_patch, u32 *etrack_id);

I think you can use a struct as parameter here. But beware, that struct
should NOT be a public struct.

>  static void eth_igb_infos_get(struct rte_eth_dev *dev,
>  			      struct rte_eth_dev_info *dev_info);
>  static const uint32_t *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev);
> @@ -389,6 +391,7 @@ static const struct eth_dev_ops eth_igb_ops = {
>  	.xstats_get_names     = eth_igb_xstats_get_names,
>  	.stats_reset          = eth_igb_stats_reset,
>  	.xstats_reset         = eth_igb_xstats_reset,
> +	.fw_version_get       = eth_igb_fw_version_get,
>  	.dev_infos_get        = eth_igb_infos_get,
>  	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
>  	.mtu_set              = eth_igb_mtu_set,
> @@ -1981,6 +1984,46 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
>  }
>  

<...>

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

* Re: [dpdk-dev] [PATCH v3 3/4] net/ixgbe: add firmware version get
  2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 3/4] net/ixgbe: " Qiming Yang
@ 2017-01-03 15:04         ` Ferruh Yigit
  2017-01-04  2:44           ` Yang, Qiming
  0 siblings, 1 reply; 128+ messages in thread
From: Ferruh Yigit @ 2017-01-03 15:04 UTC (permalink / raw)
  To: Qiming Yang, dev, thomas.monjalon; +Cc: remy.horton

On 12/27/2016 12:30 PM, Qiming Yang wrote:
> This patch add a new function ixgbe_fw_version_get.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>

<...>

>  
>  static void
> +ixgbe_fw_version_get(struct rte_eth_dev *dev, __rte_unused u32 *fw_major,
> +	__rte_unused u32 *fw_minor, __rte_unused u32 *fw_patch, u32 *etrack_id)

This API at least provide major and minor fw versions I think. Isn't
there any kind of FW version information for ixgbe? Just providing
etrack_id is not looking good.

> +{
> +	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	u16 eeprom_verh, eeprom_verl;
> +
> +	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
> +	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
> +
> +	*etrack_id = (eeprom_verh << 16) | eeprom_verl;
> +}
> +
> +static void
>  ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
>  {
>  	struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
> 

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

* Re: [dpdk-dev] [PATCH v3 3/4] net/ixgbe: add firmware version get
  2017-01-03 15:04         ` Ferruh Yigit
@ 2017-01-04  2:44           ` Yang, Qiming
  2017-01-04  9:06             ` Ferruh Yigit
  0 siblings, 1 reply; 128+ messages in thread
From: Yang, Qiming @ 2017-01-04  2:44 UTC (permalink / raw)
  To: Yigit, Ferruh, dev, thomas.monjalon; +Cc: Horton, Remy

You can see the kernel version ethtool, use command 'ethtool -i  <ixgbe NIC name>'
driver: ixgbe
version: 4.2.1-k
firmware-version: 0x61bf0001

Ixgbe's FW version do not have the major and minor number, and the original purpose of this function is get FW version, so I think it's enough. 

-----Original Message-----
From: Yigit, Ferruh 
Sent: Tuesday, January 3, 2017 11:04 PM
To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org; thomas.monjalon@6wind.com
Cc: Horton, Remy <remy.horton@intel.com>
Subject: Re: [PATCH v3 3/4] net/ixgbe: add firmware version get

On 12/27/2016 12:30 PM, Qiming Yang wrote:
> This patch add a new function ixgbe_fw_version_get.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>

<...>

>  
>  static void
> +ixgbe_fw_version_get(struct rte_eth_dev *dev, __rte_unused u32 *fw_major,
> +	__rte_unused u32 *fw_minor, __rte_unused u32 *fw_patch, u32 
> +*etrack_id)

This API at least provide major and minor fw versions I think. Isn't there any kind of FW version information for ixgbe? Just providing etrack_id is not looking good.

> +{
> +	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	u16 eeprom_verh, eeprom_verl;
> +
> +	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
> +	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
> +
> +	*etrack_id = (eeprom_verh << 16) | eeprom_verl; }
> +
> +static void
>  ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info 
> *dev_info)  {
>  	struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
> 

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

* Re: [dpdk-dev] [PATCH v3 2/4] net/e1000: add firmware version get
  2017-01-03 15:02         ` Ferruh Yigit
@ 2017-01-04  3:14           ` Yang, Qiming
  2017-01-04  8:47             ` Ferruh Yigit
  0 siblings, 1 reply; 128+ messages in thread
From: Yang, Qiming @ 2017-01-04  3:14 UTC (permalink / raw)
  To: Yigit, Ferruh, dev, thomas.monjalon; +Cc: Horton, Remy

See the reply below.

-----Original Message-----
From: Yigit, Ferruh 
Sent: Tuesday, January 3, 2017 11:03 PM
To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org; thomas.monjalon@6wind.com
Cc: Horton, Remy <remy.horton@intel.com>
Subject: Re: [PATCH v3 2/4] net/e1000: add firmware version get

On 12/27/2016 12:30 PM, Qiming Yang wrote:
> This patch adds a new function eth_igb_fw_version_get.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> ---
> v3 changes:
>  * use eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
>    u32 *fw_minor, u32 *fw_minor, u32 *fw_patch, u32 *etrack_id) instead
>    of eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
>    int fw_length). Add statusment in /doc/guides/nics/features/igb.ini.
> ---
> ---
>  doc/guides/nics/features/igb.ini |  1 +
>  drivers/net/e1000/igb_ethdev.c   | 43 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+)
> 
> diff --git a/doc/guides/nics/features/igb.ini 
> b/doc/guides/nics/features/igb.ini
> index 9fafe72..ffd87ba 100644
> --- a/doc/guides/nics/features/igb.ini
> +++ b/doc/guides/nics/features/igb.ini
> @@ -39,6 +39,7 @@ EEPROM dump          = Y
>  Registers dump       = Y
>  BSD nic_uio          = Y
>  Linux UIO            = Y
> +FW version           = Y

Please keep same location with default.ini file. Why you are putting this just into middle of the uio and vfio?
Qiming: It's a clerical error, I want to add this line at the end of this file.

>  Linux VFIO           = Y
>  x86-32               = Y
>  x86-64               = Y
> diff --git a/drivers/net/e1000/igb_ethdev.c 
> b/drivers/net/e1000/igb_ethdev.c index 4a15447..25344b7 100644
> --- a/drivers/net/e1000/igb_ethdev.c
> +++ b/drivers/net/e1000/igb_ethdev.c
> @@ -120,6 +120,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
>  				    unsigned limit);
>  static void eth_igb_stats_reset(struct rte_eth_dev *dev);  static 
> void eth_igb_xstats_reset(struct rte_eth_dev *dev);
> +static void eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
> +		u32 *fw_minor, u32 *fw_patch, u32 *etrack_id);

I think you can use a struct as parameter here. But beware, that struct should NOT be a public struct.
Qiming: I think only add a private struct for igb is unnecessary. Keep the arguments consistent with rte_eth_dev_fw_info_get is better.
What do you think?

>  static void eth_igb_infos_get(struct rte_eth_dev *dev,
>  			      struct rte_eth_dev_info *dev_info);  static const uint32_t 
> *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev); @@ -389,6 
> +391,7 @@ static const struct eth_dev_ops eth_igb_ops = {
>  	.xstats_get_names     = eth_igb_xstats_get_names,
>  	.stats_reset          = eth_igb_stats_reset,
>  	.xstats_reset         = eth_igb_xstats_reset,
> +	.fw_version_get       = eth_igb_fw_version_get,
>  	.dev_infos_get        = eth_igb_infos_get,
>  	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
>  	.mtu_set              = eth_igb_mtu_set,
> @@ -1981,6 +1984,46 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)  
> }
>  

<...>

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

* Re: [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get
  2017-01-03 14:49                 ` Ferruh Yigit
@ 2017-01-04  3:33                   ` Yang, Qiming
  2017-01-04  7:48                     ` Wu, Jingjing
  0 siblings, 1 reply; 128+ messages in thread
From: Yang, Qiming @ 2017-01-04  3:33 UTC (permalink / raw)
  To: Yigit, Ferruh; +Cc: dev, Horton, Remy, Thomas Monjalon

Yes, in my opinion it is. And I use this name already exist in the share code from ND team.

-----Original Message-----
From: Yigit, Ferruh 
Sent: Tuesday, January 3, 2017 10:49 PM
To: Yang, Qiming <qiming.yang@intel.com>
Cc: dev@dpdk.org; Horton, Remy <remy.horton@intel.com>; Thomas Monjalon <thomas.monjalon@6wind.com>
Subject: Re: [PATCH v3 1/4] ethdev: add firmware information get

On 1/3/2017 9:05 AM, Yang, Qiming wrote:
> Hi, Ferruh
> Please see the question below. In my opinion, etrack_id is just a name used to define the ID of one NIC.
> In kernel version ethtool, it will print this ID in the line of firmware verison. 
> I know what is etrack_id mean, but I really don't know why this named etrack_id.

Hi Qiming,

I suggested the API based on fields you already used in your patch.

So, this API is to get FW version, is etrack_id something that defines (part of) firmware version?

Thanks,
ferruh


> Can you explain this question?
>  
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Tuesday, January 3, 2017 4:40 PM
> To: Yang, Qiming <qiming.yang@intel.com>
> Subject: Re: [PATCH v3 1/4] ethdev: add firmware information get
> 
> Please reply below the question and on the mailing list.
> You'll have to explain why this name etrack_id.
> 
> 2017-01-03 03:28, Yang, Qiming:
>> Hi, Thomas
>> etrack_id is not a terminology, it's decided by me.
>> Which is store the unique number of the firmware.
>> firmware-version: 5.04 0x800024ca
>> 800024ca is the etrack_id of this NIC.
>>
>> -----Original Message-----
>> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
>> Sent: Monday, January 2, 2017 11:39 PM
>> To: Yang, Qiming <qiming.yang@intel.com>
>> Cc: dev@dpdk.org; Horton, Remy <remy.horton@intel.com>; Yigit, Ferruh 
>> <ferruh.yigit@intel.com>
>> Subject: Re: [PATCH v3 1/4] ethdev: add firmware information get
>>
>> 2016-12-27 20:30, Qiming Yang:
>>>  /**
>>> + * Retrieve the firmware version of a device.
>>> + *
>>> + * @param port_id
>>> + *   The port identifier of the device.
>>> + * @param fw_major
>>> + *   A array pointer to store the major firmware version of a device.
>>> + * @param fw_minor
>>> + *   A array pointer to store the minor firmware version of a device.
>>> + * @param fw_patch
>>> + *   A array pointer to store the firmware patch number of a device.
>>> + * @param etrack_id
>>> + *   A array pointer to store the nvm version of a device.
>>> + */
>>> +void rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t *fw_major,
>>> +	uint32_t *fw_minor, uint32_t *fw_patch, uint32_t *etrack_id);
>>
>> I have a reserve about the naming etrack_id.
>> Please could you point to a document explaining this ID?
>> Is it known outside of Intel?
> 
> 

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

* Re: [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get
  2017-01-04  3:33                   ` Yang, Qiming
@ 2017-01-04  7:48                     ` Wu, Jingjing
  2017-01-04  8:43                       ` Ferruh Yigit
  0 siblings, 1 reply; 128+ messages in thread
From: Wu, Jingjing @ 2017-01-04  7:48 UTC (permalink / raw)
  To: Yang, Qiming, Yigit, Ferruh; +Cc: dev, Horton, Remy, Thomas Monjalon


> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Yang, Qiming
> Sent: Wednesday, January 4, 2017 11:33 AM
> To: Yigit, Ferruh <ferruh.yigit@intel.com>
> Cc: dev@dpdk.org; Horton, Remy <remy.horton@intel.com>; Thomas Monjalon
> <thomas.monjalon@6wind.com>
> Subject: Re: [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get
> 
> Yes, in my opinion it is. And I use this name already exist in the share code from
> ND team.
> 
> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Tuesday, January 3, 2017 10:49 PM
> To: Yang, Qiming <qiming.yang@intel.com>
> Cc: dev@dpdk.org; Horton, Remy <remy.horton@intel.com>; Thomas Monjalon
> <thomas.monjalon@6wind.com>
> Subject: Re: [PATCH v3 1/4] ethdev: add firmware information get
> 
> On 1/3/2017 9:05 AM, Yang, Qiming wrote:
> > Hi, Ferruh
> > Please see the question below. In my opinion, etrack_id is just a name used to
> define the ID of one NIC.
> > In kernel version ethtool, it will print this ID in the line of firmware verison.
> > I know what is etrack_id mean, but I really don't know why this named
> etrack_id.
> 
> Hi Qiming,
> 
> I suggested the API based on fields you already used in your patch.
> 
> So, this API is to get FW version, is etrack_id something that defines (part of)
> firmware version?
> 
> Thanks,
> ferruh
> 
> 
Different HW may have different version format, so it is better to use string.

And I prefer the API definition in your v2 patch like

rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int fw_length);

Thanks
Jingjing

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

* Re: [dpdk-dev] [PATCH v3] ethtool: dispaly bus info and firmware version
  2016-12-27 13:06       ` [dpdk-dev] [PATCH v3] " Qiming Yang
@ 2017-01-04  7:51         ` Wu, Jingjing
  2017-01-04 12:18         ` [dpdk-dev] [PATCH v4] ethtool: dispaly bus information Qiming Yang
  1 sibling, 0 replies; 128+ messages in thread
From: Wu, Jingjing @ 2017-01-04  7:51 UTC (permalink / raw)
  To: Yang, Qiming, dev, thomas.monjalon
  Cc: Horton, Remy, Yigit, Ferruh, Yang, Qiming



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Qiming Yang
> Sent: Tuesday, December 27, 2016 9:06 PM
> To: dev@dpdk.org; thomas.monjalon@6wind.com
> Cc: Horton, Remy <remy.horton@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>; Yang, Qiming <qiming.yang@intel.com>
> Subject: [dpdk-dev] [PATCH v3] ethtool: dispaly bus info and firmware version
> 
> This patch enhances the ethtool example to support to show bus information
> and firmware version, in the same way that the Linux kernel ethtool does.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> ---
> v3 changes:
>  * split this patch from the patch set of rte_eth_dev_fw_info_get
>    use the new version function.
> ---
> ---
>  examples/ethtool/ethtool-app/ethapp.c |  2 ++
>  examples/ethtool/lib/rte_ethtool.c    | 11 +++++++++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/examples/ethtool/ethtool-app/ethapp.c
> b/examples/ethtool/ethtool-app/ethapp.c
> index 6aeaa06..192d941 100644
> --- a/examples/ethtool/ethtool-app/ethapp.c
> +++ b/examples/ethtool/ethtool-app/ethapp.c
> @@ -185,6 +185,8 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
>  		printf("Port %i driver: %s (ver: %s)\n",
>  			id_port, info.driver, info.version
>  		      );
> +		printf("bus-info: %s\n", info.bus_info);

This patch has dependence on your get_fw_version patch set.

I think you may misunderstand Ferruh's comments,
I think what he said was ask you to remove bus-info print (above line) from that patch set,
but keep firmware version print.

Thanks
Jingjing

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

* Re: [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get
  2017-01-04  7:48                     ` Wu, Jingjing
@ 2017-01-04  8:43                       ` Ferruh Yigit
  2017-01-05  1:04                         ` Wu, Jingjing
  0 siblings, 1 reply; 128+ messages in thread
From: Ferruh Yigit @ 2017-01-04  8:43 UTC (permalink / raw)
  To: Wu, Jingjing, Yang, Qiming; +Cc: dev, Horton, Remy, Thomas Monjalon

On 1/4/2017 7:48 AM, Wu, Jingjing wrote:
> 
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Yang, Qiming
>> Sent: Wednesday, January 4, 2017 11:33 AM
>> To: Yigit, Ferruh <ferruh.yigit@intel.com>
>> Cc: dev@dpdk.org; Horton, Remy <remy.horton@intel.com>; Thomas Monjalon
>> <thomas.monjalon@6wind.com>
>> Subject: Re: [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get
>>
>> Yes, in my opinion it is. And I use this name already exist in the share code from
>> ND team.
>>
>> -----Original Message-----
>> From: Yigit, Ferruh
>> Sent: Tuesday, January 3, 2017 10:49 PM
>> To: Yang, Qiming <qiming.yang@intel.com>
>> Cc: dev@dpdk.org; Horton, Remy <remy.horton@intel.com>; Thomas Monjalon
>> <thomas.monjalon@6wind.com>
>> Subject: Re: [PATCH v3 1/4] ethdev: add firmware information get
>>
>> On 1/3/2017 9:05 AM, Yang, Qiming wrote:
>>> Hi, Ferruh
>>> Please see the question below. In my opinion, etrack_id is just a name used to
>> define the ID of one NIC.
>>> In kernel version ethtool, it will print this ID in the line of firmware verison.
>>> I know what is etrack_id mean, but I really don't know why this named
>> etrack_id.
>>
>> Hi Qiming,
>>
>> I suggested the API based on fields you already used in your patch.
>>
>> So, this API is to get FW version, is etrack_id something that defines (part of)
>> firmware version?
>>
>> Thanks,
>> ferruh
>>
>>
> Different HW may have different version format, so it is better to use string.
> 
> And I prefer the API definition in your v2 patch like
> 
> rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int fw_length);

The problem with this is the format and content of the string is not
defined, as you said different HW has different version format. This is
no problem if you will only print the string.

But this is a public API, if an application wants to call this API and
do something useful according the FW version information, it will need
to parse the string, and it will not able to parse it because format of
the string is not defined. By making API fill some defined variables,
app won't need to parse them, and API output won't be HW dependent.

Thanks,
ferruh

> 
> Thanks
> Jingjing
> 

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

* Re: [dpdk-dev] [PATCH v3 2/4] net/e1000: add firmware version get
  2017-01-04  3:14           ` Yang, Qiming
@ 2017-01-04  8:47             ` Ferruh Yigit
  0 siblings, 0 replies; 128+ messages in thread
From: Ferruh Yigit @ 2017-01-04  8:47 UTC (permalink / raw)
  To: Yang, Qiming, dev, thomas.monjalon; +Cc: Horton, Remy

On 1/4/2017 3:14 AM, Yang, Qiming wrote:
> See the reply below.
> 
> -----Original Message-----
> From: Yigit, Ferruh 
> Sent: Tuesday, January 3, 2017 11:03 PM
> To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org; thomas.monjalon@6wind.com
> Cc: Horton, Remy <remy.horton@intel.com>
> Subject: Re: [PATCH v3 2/4] net/e1000: add firmware version get
> 
> On 12/27/2016 12:30 PM, Qiming Yang wrote:
>> This patch adds a new function eth_igb_fw_version_get.
>>
>> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
>> ---
>> v3 changes:
>>  * use eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
>>    u32 *fw_minor, u32 *fw_minor, u32 *fw_patch, u32 *etrack_id) instead
>>    of eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
>>    int fw_length). Add statusment in /doc/guides/nics/features/igb.ini.
>> ---
>> ---
>>  doc/guides/nics/features/igb.ini |  1 +
>>  drivers/net/e1000/igb_ethdev.c   | 43 ++++++++++++++++++++++++++++++++++++++++
>>  2 files changed, 44 insertions(+)
>>
>> diff --git a/doc/guides/nics/features/igb.ini 
>> b/doc/guides/nics/features/igb.ini
>> index 9fafe72..ffd87ba 100644
>> --- a/doc/guides/nics/features/igb.ini
>> +++ b/doc/guides/nics/features/igb.ini
>> @@ -39,6 +39,7 @@ EEPROM dump          = Y
>>  Registers dump       = Y
>>  BSD nic_uio          = Y
>>  Linux UIO            = Y
>> +FW version           = Y
> 
> Please keep same location with default.ini file. Why you are putting this just into middle of the uio and vfio?
> Qiming: It's a clerical error, I want to add this line at the end of this file.
> 
>>  Linux VFIO           = Y
>>  x86-32               = Y
>>  x86-64               = Y
>> diff --git a/drivers/net/e1000/igb_ethdev.c 
>> b/drivers/net/e1000/igb_ethdev.c index 4a15447..25344b7 100644
>> --- a/drivers/net/e1000/igb_ethdev.c
>> +++ b/drivers/net/e1000/igb_ethdev.c
>> @@ -120,6 +120,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
>>  				    unsigned limit);
>>  static void eth_igb_stats_reset(struct rte_eth_dev *dev);  static 
>> void eth_igb_xstats_reset(struct rte_eth_dev *dev);
>> +static void eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
>> +		u32 *fw_minor, u32 *fw_patch, u32 *etrack_id);
> 
> I think you can use a struct as parameter here. But beware, that struct should NOT be a public struct.
> Qiming: I think only add a private struct for igb is unnecessary. Keep the arguments consistent with rte_eth_dev_fw_info_get is better.
> What do you think?

Both are OK.
Normally, I believe using struct is better. But we are not using struct
in public API because of the ABI compatibility issues. Here it is
internal usage, there is no ABI breakage concern, so it may be possible
to use a struct.
But if you prefer to keep the arguments same here with public API, that
is fine.

> 
>>  static void eth_igb_infos_get(struct rte_eth_dev *dev,
>>  			      struct rte_eth_dev_info *dev_info);  static const uint32_t 
>> *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev); @@ -389,6 
>> +391,7 @@ static const struct eth_dev_ops eth_igb_ops = {
>>  	.xstats_get_names     = eth_igb_xstats_get_names,
>>  	.stats_reset          = eth_igb_stats_reset,
>>  	.xstats_reset         = eth_igb_xstats_reset,
>> +	.fw_version_get       = eth_igb_fw_version_get,
>>  	.dev_infos_get        = eth_igb_infos_get,
>>  	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
>>  	.mtu_set              = eth_igb_mtu_set,
>> @@ -1981,6 +1984,46 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)  
>> }
>>  
> 
> <...>
> 

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

* Re: [dpdk-dev] [PATCH v3 3/4] net/ixgbe: add firmware version get
  2017-01-04  2:44           ` Yang, Qiming
@ 2017-01-04  9:06             ` Ferruh Yigit
  2017-01-04  9:48               ` Yang, Qiming
  0 siblings, 1 reply; 128+ messages in thread
From: Ferruh Yigit @ 2017-01-04  9:06 UTC (permalink / raw)
  To: Yang, Qiming, dev, thomas.monjalon; +Cc: Horton, Remy

On 1/4/2017 2:44 AM, Yang, Qiming wrote:
> You can see the kernel version ethtool, use command 'ethtool -i  <ixgbe NIC name>'
> driver: ixgbe
> version: 4.2.1-k
> firmware-version: 0x61bf0001
> 
> Ixgbe's FW version do not have the major and minor number, and the original purpose of this function is get FW version, so I think it's enough.

Is etrack_id a unique value that defines the FW version on its own?

And is above definition true for all NICs (or at least Intel ones)?
Because I can see i40e is using 4 bit value for etrack_id ?

> 
> -----Original Message-----
> From: Yigit, Ferruh 
> Sent: Tuesday, January 3, 2017 11:04 PM
> To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org; thomas.monjalon@6wind.com
> Cc: Horton, Remy <remy.horton@intel.com>
> Subject: Re: [PATCH v3 3/4] net/ixgbe: add firmware version get
> 
> On 12/27/2016 12:30 PM, Qiming Yang wrote:
>> This patch add a new function ixgbe_fw_version_get.
>>
>> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> 
> <...>
> 
>>  
>>  static void
>> +ixgbe_fw_version_get(struct rte_eth_dev *dev, __rte_unused u32 *fw_major,
>> +	__rte_unused u32 *fw_minor, __rte_unused u32 *fw_patch, u32 
>> +*etrack_id)
> 
> This API at least provide major and minor fw versions I think. Isn't there any kind of FW version information for ixgbe? Just providing etrack_id is not looking good.
> 
>> +{
>> +	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
>> +	u16 eeprom_verh, eeprom_verl;
>> +
>> +	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
>> +	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
>> +
>> +	*etrack_id = (eeprom_verh << 16) | eeprom_verl; }
>> +
>> +static void
>>  ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info 
>> *dev_info)  {
>>  	struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
>>
> 

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

* Re: [dpdk-dev] [PATCH v3 3/4] net/ixgbe: add firmware version get
  2017-01-04  9:06             ` Ferruh Yigit
@ 2017-01-04  9:48               ` Yang, Qiming
  2017-01-04 12:01                 ` Ferruh Yigit
  0 siblings, 1 reply; 128+ messages in thread
From: Yang, Qiming @ 2017-01-04  9:48 UTC (permalink / raw)
  To: Yigit, Ferruh, dev, thomas.monjalon; +Cc: Horton, Remy

Yes,  etrack_id is an unique value. But not all NICs have this value.
I didn't find any value about fw version in fm10k.
I40e is 8 bit too.
firmware-version: 5.04 0x800024ca

-----Original Message-----
From: Yigit, Ferruh 
Sent: Wednesday, January 4, 2017 5:06 PM
To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org; thomas.monjalon@6wind.com
Cc: Horton, Remy <remy.horton@intel.com>
Subject: Re: [PATCH v3 3/4] net/ixgbe: add firmware version get

On 1/4/2017 2:44 AM, Yang, Qiming wrote:
> You can see the kernel version ethtool, use command 'ethtool -i  <ixgbe NIC name>'
> driver: ixgbe
> version: 4.2.1-k
> firmware-version: 0x61bf0001
> 
> Ixgbe's FW version do not have the major and minor number, and the original purpose of this function is get FW version, so I think it's enough.

Is etrack_id a unique value that defines the FW version on its own?

And is above definition true for all NICs (or at least Intel ones)?
Because I can see i40e is using 4 bit value for etrack_id ?

> 
> -----Original Message-----
> From: Yigit, Ferruh 
> Sent: Tuesday, January 3, 2017 11:04 PM
> To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org; thomas.monjalon@6wind.com
> Cc: Horton, Remy <remy.horton@intel.com>
> Subject: Re: [PATCH v3 3/4] net/ixgbe: add firmware version get
> 
> On 12/27/2016 12:30 PM, Qiming Yang wrote:
>> This patch add a new function ixgbe_fw_version_get.
>>
>> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> 
> <...>
> 
>>  
>>  static void
>> +ixgbe_fw_version_get(struct rte_eth_dev *dev, __rte_unused u32 *fw_major,
>> +	__rte_unused u32 *fw_minor, __rte_unused u32 *fw_patch, u32 
>> +*etrack_id)
> 
> This API at least provide major and minor fw versions I think. Isn't there any kind of FW version information for ixgbe? Just providing etrack_id is not looking good.
> 
>> +{
>> +	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
>> +	u16 eeprom_verh, eeprom_verl;
>> +
>> +	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
>> +	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
>> +
>> +	*etrack_id = (eeprom_verh << 16) | eeprom_verl; }
>> +
>> +static void
>>  ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info 
>> *dev_info)  {
>>  	struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
>>
> 

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

* Re: [dpdk-dev] [PATCH v3 3/4] net/ixgbe: add firmware version get
  2017-01-04  9:48               ` Yang, Qiming
@ 2017-01-04 12:01                 ` Ferruh Yigit
  0 siblings, 0 replies; 128+ messages in thread
From: Ferruh Yigit @ 2017-01-04 12:01 UTC (permalink / raw)
  To: Yang, Qiming, dev, thomas.monjalon; +Cc: Horton, Remy

On 1/4/2017 9:48 AM, Yang, Qiming wrote:
> Yes,  etrack_id is an unique value. But not all NICs have this value.
> I didn't find any value about fw version in fm10k.

Yes, you are right, following is from i40e datasheet:

"
The EEPROM Manager tool writes a unique 32-bit eTrack_ID number in two
sequential NVM words.
The eTrack_ID is written when EEPROM Manager tool creates an image on
the Intel network. The eTrack_ID DB tracks NVM images back to a specific
SCM build
"

So it is unique, and can be used to identify FW version. And yes it can
be enough on its own without having major minor FW version fields.

> I40e is 8 bit too.
> firmware-version: 5.04 0x800024ca

Right, I read it wrong, i40e also has 32bits etrack-id.

Thanks,
ferruh

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

* [dpdk-dev] [PATCH v4 0/5] new API 'rte_eth_dev_fw_version_get'
  2016-12-27 12:30     ` [dpdk-dev] [PATCH v3 0/4] new API 'rte_eth_dev_fw_info_get' Qiming Yang
                         ` (3 preceding siblings ...)
  2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 4/4] net/i40e: " Qiming Yang
@ 2017-01-04 12:03       ` Qiming Yang
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 1/5] ethdev: add firmware version get Qiming Yang
                           ` (5 more replies)
  4 siblings, 6 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-04 12:03 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, helin.zhang, remy.horton, Qiming Yang

Now, the example ethtool can only show the driver information. From
customers' point of view, it should be better if we can have the same
way that the Linux kernel ethtool does to show firmware-version.

These five patches added a new function ``rte_eth_dev_fw_version_get()``
to fetch firmware version related information and implement the
display in example ethtool.

Qiming Yang (5):
  ethdev: add firmware version get
  net/e1000: add firmware version get
  net/ixgbe: add firmware version get
  net/i40e: add firmware version get
  ethtool: dispaly firmware version

 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/nics/features/i40e.ini      |  1 +
 doc/guides/nics/features/igb.ini       |  1 +
 doc/guides/nics/features/ixgbe.ini     |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ----
 doc/guides/rel_notes/release_17_02.rst |  3 +++
 drivers/net/e1000/igb_ethdev.c         | 43 ++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.c         | 15 ++++++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c       | 17 ++++++++++++++
 examples/ethtool/ethtool-app/ethapp.c  |  1 +
 examples/ethtool/lib/rte_ethtool.c     | 12 ++++++++++
 lib/librte_ether/rte_ethdev.c          | 14 +++++++++++
 lib/librte_ether/rte_ethdev.h          | 23 ++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 14 files changed, 133 insertions(+), 4 deletions(-)

-- 
2.7.4

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

* [dpdk-dev] [PATCH v4 1/5] ethdev: add firmware version get
  2017-01-04 12:03       ` [dpdk-dev] [PATCH v4 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
@ 2017-01-04 12:03         ` Qiming Yang
  2017-01-05 13:44           ` Thomas Monjalon
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 2/5] net/e1000: " Qiming Yang
                           ` (4 subsequent siblings)
  5 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2017-01-04 12:03 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, helin.zhang, remy.horton, Qiming Yang

This patch adds a new API 'rte_eth_dev_fw_version_get' for
fetching firmware version related information by a given device.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
v2 changes:
* modified some comment statements.
v3 changes:
* change API, use rte_eth_dev_fw_info_get(uint8_t port_id,
  uint32_t *fw_major, uint32_t *fw_minor, uint32_t *fw_patch,
  uint32_t *etrack_id) instead of rte_eth_dev_fwver_get(uint8_t port_id,
  char *fw_version, int fw_length).
  Add statusment in /doc/guides/nics/features/default.ini and
  release_17_02.rst.
v4 changes:
* remove deprecation notice, rename API as rte_eth_dev_fw_version_get
---
---
 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ----
 doc/guides/rel_notes/release_17_02.rst |  3 +++
 lib/librte_ether/rte_ethdev.c          | 14 ++++++++++++++
 lib/librte_ether/rte_ethdev.h          | 23 +++++++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 6 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
index f1bf9bf..ae40d57 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -50,6 +50,7 @@ Timesync             =
 Basic stats          =
 Extended stats       =
 Stats per queue      =
+FW version           =
 EEPROM dump          =
 Registers dump       =
 Multiprocess aware   =
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 1438c77..291e03d 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -30,10 +30,6 @@ Deprecation Notices
   ``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
   segments limit to be transmitted by device for TSO/non-TSO packets.
 
-* In 17.02 ABI change is planned: the ``rte_eth_dev_info`` structure
-  will be extended with a new member ``fw_version`` in order to store
-  the NIC firmware version.
-
 * ethdev: an API change is planned for 17.02 for the function
   ``_rte_eth_dev_callback_process``. In 17.02 the function will return an ``int``
   instead of ``void`` and a fourth parameter ``void *ret_param`` will be added.
diff --git a/doc/guides/rel_notes/release_17_02.rst b/doc/guides/rel_notes/release_17_02.rst
index 180af82..d6958d4 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,9 @@ New Features
   See the :ref:`Generic flow API <Generic_flow_API>` documentation for more
   information.
 
+* **Added firmware version get API.**
+ Added a new function ``rte_eth_dev_fw_version_get()`` to fetch firmware version
+ related information by a given device.
 
 Resolved Issues
 ---------------
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 280f0db..a4b20b5 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1586,6 +1586,20 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
 }
 
 void
+rte_eth_dev_fw_version_get(uint8_t port_id, uint32_t *fw_major,
+		uint32_t *fw_minor, uint32_t *fw_patch, uint32_t *etrack_id)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
+	dev = &rte_eth_devices[port_id];
+
+	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->fw_version_get);
+	(*dev->dev_ops->fw_version_get)(dev, fw_major, fw_minor,
+					fw_patch, etrack_id);
+}
+
+void
 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 {
 	struct rte_eth_dev *dev;
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index fb51754..9c7efa1 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1150,6 +1150,11 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
 /**< @internal Check DD bit of specific RX descriptor */
 
+typedef void (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
+		uint32_t *fw_major, uint32_t *fw_minor,
+		uint32_t *fw_patch, uint32_t *etrack_id);
+/**< @internal Get firmware version information of an Ethernet device. */
+
 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
 	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
 
@@ -1457,6 +1462,7 @@ struct eth_dev_ops {
 	eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
 	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
 	/**< Get packet types supported and identified by device. */
+	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
 
 	vlan_filter_set_t          vlan_filter_set; /**< Filter VLAN Setup. */
 	vlan_tpid_set_t            vlan_tpid_set; /**< Outer/Inner VLAN TPID Setup. */
@@ -2395,6 +2401,23 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
 void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
 
 /**
+ * Retrieve the firmware version of a device.
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param fw_major
+ *   A pointer to store the major firmware version of a device.
+ * @param fw_minor
+ *   A pointer to store the minor firmware version of a device.
+ * @param fw_patch
+ *   A pointer to store the firmware patch number of a device.
+ * @param etrack_id
+ *   A pointer to store the nvm version of a device.
+ */
+void rte_eth_dev_fw_version_get(uint8_t port_id, uint32_t *fw_major,
+	uint32_t *fw_minor, uint32_t *fw_patch, uint32_t *etrack_id);
+
+/**
  * Retrieve the supported packet types of an Ethernet device.
  *
  * When a packet type is announced as supported, it *must* be recognized by
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index a021781..0cf94ed 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -151,6 +151,7 @@ DPDK_17.02 {
 	global:
 
 	_rte_eth_dev_reset;
+	rte_eth_dev_fw_version_get;
 	rte_flow_create;
 	rte_flow_destroy;
 	rte_flow_flush;
-- 
2.7.4

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

* [dpdk-dev] [PATCH v4 2/5] net/e1000: add firmware version get
  2017-01-04 12:03       ` [dpdk-dev] [PATCH v4 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 1/5] ethdev: add firmware version get Qiming Yang
@ 2017-01-04 12:03         ` Qiming Yang
  2017-01-04 13:59           ` Ferruh Yigit
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 3/5] net/ixgbe: " Qiming Yang
                           ` (3 subsequent siblings)
  5 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2017-01-04 12:03 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, helin.zhang, remy.horton, Qiming Yang

This patch adds a new function eth_igb_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
v3 changes:
 * use eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
   u32 *fw_minor, u32 *fw_minor, u32 *fw_patch, u32 *etrack_id) instead
   of eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
   int fw_length). Add statusment in /doc/guides/nics/features/igb.ini.
---
---
 doc/guides/nics/features/igb.ini |  1 +
 drivers/net/e1000/igb_ethdev.c   | 43 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/doc/guides/nics/features/igb.ini b/doc/guides/nics/features/igb.ini
index 9fafe72..26ae008 100644
--- a/doc/guides/nics/features/igb.ini
+++ b/doc/guides/nics/features/igb.ini
@@ -35,6 +35,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 BSD nic_uio          = Y
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 4a15447..25344b7 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -120,6 +120,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
 				    unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
+static void eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
+		u32 *fw_minor, u32 *fw_patch, u32 *etrack_id);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static const uint32_t *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -389,6 +391,7 @@ static const struct eth_dev_ops eth_igb_ops = {
 	.xstats_get_names     = eth_igb_xstats_get_names,
 	.stats_reset          = eth_igb_stats_reset,
 	.xstats_reset         = eth_igb_xstats_reset,
+	.fw_version_get       = eth_igb_fw_version_get,
 	.dev_infos_get        = eth_igb_infos_get,
 	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
 	.mtu_set              = eth_igb_mtu_set,
@@ -1981,6 +1984,46 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
 }
 
 static void
+eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major, u32 *fw_minor,
+			u32 *fw_patch, u32 *etrack_id)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_fw_version fw;
+
+	e1000_get_fw_version(hw, &fw);
+
+	switch (hw->mac.type) {
+	case e1000_i210:
+	case e1000_i211:
+		if (!(e1000_get_flash_presence_i210(hw))) {
+			*fw_major = fw.invm_major;
+			*fw_minor = fw.invm_minor;
+			break;
+		}
+		/* fall through */
+	default:
+		/* if option rom is valid, display its version too*/
+		if (fw.or_valid) {
+			*fw_major = fw.eep_major;
+			*fw_minor = fw.eep_minor;
+			*etrack_id = fw.etrack_id;
+			*fw_patch = fw.or_patch;
+		/* no option rom */
+		} else {
+			if (fw.etrack_id != 0X0000) {
+			*fw_major = fw.eep_major;
+			*fw_minor = fw.eep_minor;
+			*etrack_id = fw.etrack_id;
+			} else {
+			*fw_major = fw.eep_major;
+			*fw_minor = fw.eep_minor;
+			}
+		}
+		break;
+	}
+}
+
+static void
 eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH v4 3/5] net/ixgbe: add firmware version get
  2017-01-04 12:03       ` [dpdk-dev] [PATCH v4 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 1/5] ethdev: add firmware version get Qiming Yang
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 2/5] net/e1000: " Qiming Yang
@ 2017-01-04 12:03         ` Qiming Yang
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 4/5] net/i40e: " Qiming Yang
                           ` (2 subsequent siblings)
  5 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-04 12:03 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, helin.zhang, remy.horton, Qiming Yang

This patch add a new function ixgbe_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
v3 changes:
 * use ixgbe_fw_version_get(struct rte_eth_dev *dev,
   __rte_unused u32 *fw_major, __rte_unused u32 *fw_minor,
   __rte_unused u32 *fw_patch, u32 *etrack_id) instead of
    ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
   int fw_length). Add statusment in /doc/guides/nics/features/ixgbe.ini.
---
---
 doc/guides/nics/features/ixgbe.ini |  1 +
 drivers/net/ixgbe/ixgbe_ethdev.c   | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/doc/guides/nics/features/ixgbe.ini b/doc/guides/nics/features/ixgbe.ini
index 4a5667f..b46287a 100644
--- a/doc/guides/nics/features/ixgbe.ini
+++ b/doc/guides/nics/features/ixgbe.ini
@@ -43,6 +43,7 @@ Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
+FW_version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 Multiprocess aware   = Y
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index ec2edad..e2234c0 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -193,6 +193,9 @@ static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint16_t queue_id,
 					     uint8_t stat_idx,
 					     uint8_t is_rx);
+static void ixgbe_fw_version_get(struct rte_eth_dev *dev,
+	__rte_unused u32 *fw_major, __rte_unused u32 *fw_minor,
+	__rte_unused u32 *fw_patch, u32 *etrack_id);
 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
 			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -538,6 +541,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.xstats_reset         = ixgbe_dev_xstats_reset,
 	.xstats_get_names     = ixgbe_dev_xstats_get_names,
 	.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
+	.fw_version_get       = ixgbe_fw_version_get,
 	.dev_infos_get        = ixgbe_dev_info_get,
 	.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
 	.mtu_set              = ixgbe_dev_mtu_set,
@@ -3029,6 +3033,19 @@ ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
 }
 
 static void
+ixgbe_fw_version_get(struct rte_eth_dev *dev, __rte_unused u32 *fw_major,
+	__rte_unused u32 *fw_minor, __rte_unused u32 *fw_patch, u32 *etrack_id)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u16 eeprom_verh, eeprom_verl;
+
+	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
+	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
+
+	*etrack_id = (eeprom_verh << 16) | eeprom_verl;
+}
+
+static void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
-- 
2.7.4

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

* [dpdk-dev] [PATCH v4 4/5] net/i40e: add firmware version get
  2017-01-04 12:03       ` [dpdk-dev] [PATCH v4 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                           ` (2 preceding siblings ...)
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 3/5] net/ixgbe: " Qiming Yang
@ 2017-01-04 12:03         ` Qiming Yang
  2017-01-04 14:00           ` Ferruh Yigit
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 5/5] ethtool: dispaly firmware version Qiming Yang
  2017-01-08  4:11         ` [dpdk-dev] [PATCH v5 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  5 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2017-01-04 12:03 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, helin.zhang, remy.horton, Qiming Yang

This patch add a new function i40e_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
v3 changes:
 * use i40e_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
   u32 *fw_minor, __rte_unused u32 *fw_patch, u32 *etrack_id)
   instead of i40e_fw_version_get(struct rte_eth_dev *dev,
   char *fw_version, int fw_length). Add statusment in
   /doc/guides/nics/features/i40e.ini.
---
---
 doc/guides/nics/features/i40e.ini |  1 +
 drivers/net/i40e/i40e_ethdev.c    | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/doc/guides/nics/features/i40e.ini b/doc/guides/nics/features/i40e.ini
index 0d143bc..6dab9f7 100644
--- a/doc/guides/nics/features/i40e.ini
+++ b/doc/guides/nics/features/i40e.ini
@@ -46,3 +46,4 @@ Linux VFIO           = Y
 x86-32               = Y
 x86-64               = Y
 ARMv8                = Y
+FW version           = Y
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 8f63044..1dbbcc4 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -324,6 +324,8 @@ static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
 					    uint16_t queue_id,
 					    uint8_t stat_idx,
 					    uint8_t is_rx);
+static void i40e_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
+	u32 *fw_minor, __rte_unused u32 *fw_patch, u32 *etrack_id);
 static void i40e_dev_info_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static int i40e_vlan_filter_set(struct rte_eth_dev *dev,
@@ -503,6 +505,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.stats_reset                  = i40e_dev_stats_reset,
 	.xstats_reset                 = i40e_dev_stats_reset,
 	.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
+	.fw_version_get               = i40e_fw_version_get,
 	.dev_infos_get                = i40e_dev_info_get,
 	.dev_supported_ptypes_get     = i40e_dev_supported_ptypes_get,
 	.vlan_filter_set              = i40e_vlan_filter_set,
@@ -2590,6 +2593,18 @@ i40e_dev_queue_stats_mapping_set(__rte_unused struct rte_eth_dev *dev,
 }
 
 static void
+i40e_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major, u32 *fw_minor,
+		__rte_unused u32 *fw_patch, u32 *etrack_id)
+{
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	*fw_major = (hw->nvm.version >> 12) & 0xf;
+	*fw_minor = ((hw->nvm.version >> 4) & 0xff) * 10 +
+			(hw->nvm.version & 0xf);
+	*etrack_id = hw->nvm.eetrack;
+}
+
+static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH v4 5/5] ethtool: dispaly firmware version
  2017-01-04 12:03       ` [dpdk-dev] [PATCH v4 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                           ` (3 preceding siblings ...)
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 4/5] net/i40e: " Qiming Yang
@ 2017-01-04 12:03         ` Qiming Yang
  2017-01-04 14:00           ` Ferruh Yigit
  2017-01-08  4:11         ` [dpdk-dev] [PATCH v5 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  5 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2017-01-04 12:03 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, helin.zhang, remy.horton, Qiming Yang

This patch enhances the ethtool example to support to show
firmware version, in the same way that the Linux kernel
ethtool does.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
v4 changes:
 * split bus info print from this patch set
---
---
 examples/ethtool/ethtool-app/ethapp.c |  1 +
 examples/ethtool/lib/rte_ethtool.c    | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
index 6aeaa06..85c31ac 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -185,6 +185,7 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
 		printf("Port %i driver: %s (ver: %s)\n",
 			id_port, info.driver, info.version
 		      );
+		printf("firmware-version: %s\n", info.fw_version);
 	}
 }
 
diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index 6f0ce84..741468f 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -54,6 +54,12 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
+	uint32_t fw_major = 0;
+	uint32_t fw_minor = 0;
+	uint32_t etrack = 0;
+
+	rte_eth_dev_fw_version_get(port_id, &fw_major, &fw_minor,
+				   NULL, &etrack);
 	memset(&dev_info, 0, sizeof(dev_info));
 	rte_eth_dev_info_get(port_id, &dev_info);
 
@@ -61,6 +67,12 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 		dev_info.driver_name);
 	snprintf(drvinfo->version, sizeof(drvinfo->version), "%s",
 		rte_version());
+	if (strcmp(drvinfo->driver, "net_ixgbe") == 0)
+		snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
+			 "0x%08x", etrack);
+	else
+		snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
+			 "%d.%02d 0x%08x", fw_major, fw_minor, etrack);
 	if (dev_info.pci_dev)
 		snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info),
 			"%04x:%02x:%02x.%x",
-- 
2.7.4

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

* [dpdk-dev] [PATCH v4] ethtool: dispaly bus information
  2016-12-27 13:06       ` [dpdk-dev] [PATCH v3] " Qiming Yang
  2017-01-04  7:51         ` Wu, Jingjing
@ 2017-01-04 12:18         ` Qiming Yang
  2017-01-04 14:49           ` Mcnamara, John
  2017-02-09 21:32           ` Thomas Monjalon
  1 sibling, 2 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-04 12:18 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, helin.zhang, remy.horton, Qiming Yang

This patch enhances the ethtool example to support to show
bus information, in the same way that the Linux kernel
ethtool does.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
v4 changes:
 * split bus info print from patch set ethdev: add firmware version get
---
---
 examples/ethtool/ethtool-app/ethapp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
index 85c31ac..35269ea 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -186,6 +186,7 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
 			id_port, info.driver, info.version
 		      );
 		printf("firmware-version: %s\n", info.fw_version);
+		printf("bus-info: %s\n", info.bus_info);
 	}
 }
 
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH v4 2/5] net/e1000: add firmware version get
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 2/5] net/e1000: " Qiming Yang
@ 2017-01-04 13:59           ` Ferruh Yigit
  2017-01-05  1:50             ` Yang, Qiming
  0 siblings, 1 reply; 128+ messages in thread
From: Ferruh Yigit @ 2017-01-04 13:59 UTC (permalink / raw)
  To: Qiming Yang, dev; +Cc: helin.zhang, remy.horton

On 1/4/2017 12:03 PM, Qiming Yang wrote:
> This patch adds a new function eth_igb_fw_version_get.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> ---
<...>
>  
>  static void
> +eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major, u32 *fw_minor,
> +			u32 *fw_patch, u32 *etrack_id)
> +{
<...>
> +	default:
> +		/* if option rom is valid, display its version too*/
> +		if (fw.or_valid) {
> +			*fw_major = fw.eep_major;
> +			*fw_minor = fw.eep_minor;
> +			*etrack_id = fw.etrack_id;
> +			*fw_patch = fw.or_patch;
> +		/* no option rom */
> +		} else {
> +			if (fw.etrack_id != 0X0000) {
> +			*fw_major = fw.eep_major;
> +			*fw_minor = fw.eep_minor;
> +			*etrack_id = fw.etrack_id;

indentation is wrong here. Also it looks like major, minor assignment is
common and can be moved from if statement.

> +			} else {
> +			*fw_major = fw.eep_major;
> +			*fw_minor = fw.eep_minor;
> +			}
> +		}
> +		break;
> +	}
> +}
<...>

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

* Re: [dpdk-dev] [PATCH v4 4/5] net/i40e: add firmware version get
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 4/5] net/i40e: " Qiming Yang
@ 2017-01-04 14:00           ` Ferruh Yigit
  0 siblings, 0 replies; 128+ messages in thread
From: Ferruh Yigit @ 2017-01-04 14:00 UTC (permalink / raw)
  To: Qiming Yang, dev; +Cc: helin.zhang, remy.horton

On 1/4/2017 12:03 PM, Qiming Yang wrote:
> This patch add a new function i40e_fw_version_get.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> ---
<...>
> 
> diff --git a/doc/guides/nics/features/i40e.ini b/doc/guides/nics/features/i40e.ini
> index 0d143bc..6dab9f7 100644
> --- a/doc/guides/nics/features/i40e.ini
> +++ b/doc/guides/nics/features/i40e.ini
> @@ -46,3 +46,4 @@ Linux VFIO           = Y
>  x86-32               = Y
>  x86-64               = Y
>  ARMv8                = Y
> +FW version           = Y

Please put same location with default.ini

<...>

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

* Re: [dpdk-dev] [PATCH v4 5/5] ethtool: dispaly firmware version
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 5/5] ethtool: dispaly firmware version Qiming Yang
@ 2017-01-04 14:00           ` Ferruh Yigit
  2017-01-05  1:31             ` Yang, Qiming
  0 siblings, 1 reply; 128+ messages in thread
From: Ferruh Yigit @ 2017-01-04 14:00 UTC (permalink / raw)
  To: Qiming Yang, dev; +Cc: helin.zhang, remy.horton

On 1/4/2017 12:03 PM, Qiming Yang wrote:
> This patch enhances the ethtool example to support to show
> firmware version, in the same way that the Linux kernel
> ethtool does.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
<...>
>  
> @@ -61,6 +67,12 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
>  		dev_info.driver_name);
>  	snprintf(drvinfo->version, sizeof(drvinfo->version), "%s",
>  		rte_version());
> +	if (strcmp(drvinfo->driver, "net_ixgbe") == 0)

Do you need this check. I think it is not good idea to add this kind of
checks into ethtool app. Why not just print "%d.%d.%d %#X, major, minor,
patch, etrack" for all cases ?

> +		snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
> +			 "0x%08x", etrack);
> +	else
> +		snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
> +			 "%d.%02d 0x%08x", fw_major, fw_minor, etrack);
>  	if (dev_info.pci_dev)
>  		snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info),
>  			"%04x:%02x:%02x.%x",
> 

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

* Re: [dpdk-dev] [PATCH v4] ethtool: dispaly bus information
  2017-01-04 12:18         ` [dpdk-dev] [PATCH v4] ethtool: dispaly bus information Qiming Yang
@ 2017-01-04 14:49           ` Mcnamara, John
  2017-01-05  1:51             ` Yang, Qiming
  2017-02-09 21:32           ` Thomas Monjalon
  1 sibling, 1 reply; 128+ messages in thread
From: Mcnamara, John @ 2017-01-04 14:49 UTC (permalink / raw)
  To: Yang, Qiming, dev; +Cc: Yigit, Ferruh, Zhang, Helin, Horton, Remy, Yang, Qiming



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Qiming Yang
> Sent: Wednesday, January 4, 2017 12:18 PM
> To: dev@dpdk.org
> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; Zhang, Helin
> <helin.zhang@intel.com>; Horton, Remy <remy.horton@intel.com>; Yang,
> Qiming <qiming.yang@intel.com>
> Subject: [dpdk-dev] [PATCH v4] ethtool: dispaly bus information


Typo: s/dispaly/display in this and other patches.

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

* Re: [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get
  2017-01-04  8:43                       ` Ferruh Yigit
@ 2017-01-05  1:04                         ` Wu, Jingjing
  0 siblings, 0 replies; 128+ messages in thread
From: Wu, Jingjing @ 2017-01-05  1:04 UTC (permalink / raw)
  To: Yigit, Ferruh, Yang, Qiming; +Cc: dev, Horton, Remy, Thomas Monjalon

> > Different HW may have different version format, so it is better to use string.
> >
> > And I prefer the API definition in your v2 patch like
> >
> > rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int
> > fw_length);
> 
> The problem with this is the format and content of the string is not defined, as
> you said different HW has different version format. This is no problem if you will
> only print the string.
> 
> But this is a public API, if an application wants to call this API and do something
> useful according the FW version information, it will need to parse the string, and
> it will not able to parse it because format of the string is not defined. By making
> API fill some defined variables, app won't need to parse them, and API output
> won't be HW dependent.
> 

As my understand, the firmware version is specific things to each HW. The format
cannot be generic at all, or at least we have no standard to follow. I think
the API should not be HW dependent, but about the output, application should know
What the string's meaning. Otherwise why we need to provide the firmware info?

Thanks
Jingjing

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

* Re: [dpdk-dev] [PATCH v4 5/5] ethtool: dispaly firmware version
  2017-01-04 14:00           ` Ferruh Yigit
@ 2017-01-05  1:31             ` Yang, Qiming
  2017-01-06 15:55               ` Remy Horton
  0 siblings, 1 reply; 128+ messages in thread
From: Yang, Qiming @ 2017-01-05  1:31 UTC (permalink / raw)
  To: Yigit, Ferruh, dev; +Cc: Zhang, Helin, Horton, Remy



-----Original Message-----
From: Yigit, Ferruh 
Sent: Wednesday, January 4, 2017 10:01 PM
To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org
Cc: Zhang, Helin <helin.zhang@intel.com>; Horton, Remy <remy.horton@intel.com>
Subject: Re: [PATCH v4 5/5] ethtool: dispaly firmware version

On 1/4/2017 12:03 PM, Qiming Yang wrote:
> This patch enhances the ethtool example to support to show firmware 
> version, in the same way that the Linux kernel ethtool does.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
<...>
>  
> @@ -61,6 +67,12 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
>  		dev_info.driver_name);
>  	snprintf(drvinfo->version, sizeof(drvinfo->version), "%s",
>  		rte_version());
> +	if (strcmp(drvinfo->driver, "net_ixgbe") == 0)

Do you need this check. I think it is not good idea to add this kind of checks into ethtool app. Why not just print "%d.%d.%d %#X, major, minor, patch, etrack" for all cases ?
Qiming: because I want to keep the format same with kernel version ethtool.

> +		snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
> +			 "0x%08x", etrack);
> +	else
> +		snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
> +			 "%d.%02d 0x%08x", fw_major, fw_minor, etrack);
>  	if (dev_info.pci_dev)
>  		snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info),
>  			"%04x:%02x:%02x.%x",
> 

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

* Re: [dpdk-dev] [PATCH v4 2/5] net/e1000: add firmware version get
  2017-01-04 13:59           ` Ferruh Yigit
@ 2017-01-05  1:50             ` Yang, Qiming
  0 siblings, 0 replies; 128+ messages in thread
From: Yang, Qiming @ 2017-01-05  1:50 UTC (permalink / raw)
  To: Yigit, Ferruh, dev; +Cc: Zhang, Helin, Horton, Remy



-----Original Message-----
From: Yigit, Ferruh 
Sent: Wednesday, January 4, 2017 10:00 PM
To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org
Cc: Zhang, Helin <helin.zhang@intel.com>; Horton, Remy <remy.horton@intel.com>
Subject: Re: [PATCH v4 2/5] net/e1000: add firmware version get

On 1/4/2017 12:03 PM, Qiming Yang wrote:
> This patch adds a new function eth_igb_fw_version_get.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> ---
<...>
>  
>  static void
> +eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major, u32 *fw_minor,
> +			u32 *fw_patch, u32 *etrack_id)
> +{
<...>
> +	default:
> +		/* if option rom is valid, display its version too*/
> +		if (fw.or_valid) {
> +			*fw_major = fw.eep_major;
> +			*fw_minor = fw.eep_minor;
> +			*etrack_id = fw.etrack_id;
> +			*fw_patch = fw.or_patch;
> +		/* no option rom */
> +		} else {
> +			if (fw.etrack_id != 0X0000) {
> +			*fw_major = fw.eep_major;
> +			*fw_minor = fw.eep_minor;
> +			*etrack_id = fw.etrack_id;

indentation is wrong here. Also it looks like major, minor assignment is common and can be moved from if statement.
Qiming: will correct them
> +			} else {
> +			*fw_major = fw.eep_major;
> +			*fw_minor = fw.eep_minor;
> +			}
> +		}
> +		break;
> +	}
> +}
<...>

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

* Re: [dpdk-dev] [PATCH v4] ethtool: dispaly bus information
  2017-01-04 14:49           ` Mcnamara, John
@ 2017-01-05  1:51             ` Yang, Qiming
  0 siblings, 0 replies; 128+ messages in thread
From: Yang, Qiming @ 2017-01-05  1:51 UTC (permalink / raw)
  To: Mcnamara, John, dev; +Cc: Yigit, Ferruh, Zhang, Helin, Horton, Remy


-----Original Message-----
From: Mcnamara, John 
Sent: Wednesday, January 4, 2017 10:49 PM
To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org
Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; Zhang, Helin <helin.zhang@intel.com>; Horton, Remy <remy.horton@intel.com>; Yang, Qiming <qiming.yang@intel.com>
Subject: RE: [dpdk-dev] [PATCH v4] ethtool: dispaly bus information



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Qiming Yang
> Sent: Wednesday, January 4, 2017 12:18 PM
> To: dev@dpdk.org
> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; Zhang, Helin 
> <helin.zhang@intel.com>; Horton, Remy <remy.horton@intel.com>; Yang, 
> Qiming <qiming.yang@intel.com>
> Subject: [dpdk-dev] [PATCH v4] ethtool: dispaly bus information


Typo: s/dispaly/display in this and other patches.
Qiming: Will correct them, thank you.

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

* Re: [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get
  2016-12-22 15:31               ` Thomas Monjalon
  2016-12-23 12:48                 ` Ferruh Yigit
@ 2017-01-05  3:04                 ` Zhang, Helin
  1 sibling, 0 replies; 128+ messages in thread
From: Zhang, Helin @ 2017-01-05  3:04 UTC (permalink / raw)
  To: Thomas Monjalon, Yigit, Ferruh; +Cc: Yang, Qiming, dev, Horton, Remy



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monjalon
> Sent: Thursday, December 22, 2016 11:31 PM
> To: Yigit, Ferruh
> Cc: Yang, Qiming; dev@dpdk.org; Horton, Remy
> Subject: Re: [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw
> version get
> 
> 2016-12-22 15:05, Ferruh Yigit:
> > On 12/22/2016 2:47 PM, Thomas Monjalon wrote:
> > > 2016-12-22 14:36, Ferruh Yigit:
> > >> On 12/22/2016 11:07 AM, Thomas Monjalon wrote:
> > >>> I think it is OK to add a new dev_ops and a new API function for
> > >>> firmware query. Generally speaking, it is a good thing to avoid
> > >>> putting all informations in the same structure (e.g. rte_eth_dev_info).
> > >>
> > >> OK.
> > >>
> > >>> However, there
> > >>> is a balance to find. Could we plan to add more info to this new query?
> > >>> Instead of
> > >>> 	rte_eth_dev_fwver_get(uint8_t port_id, char *fw_version, int
> > >>> fw_length)
> > > [...]
> > >>> could it fill a struct?
> > >>> 	rte_eth_dev_fw_info_get(uint8_t port_id, struct
> > >>> rte_eth_dev_fw_info *fw_info)
> > >>
> > >> I believe this is better. But the problem we are having with this
> > >> usage
> > >> is: ABI breakage.
> > >>
> > >> Since this struct will be a public structure, in the future if we
> > >> want to add a new field to the struct, it will break the ABI, and
> > >> just this change will cause a new version for whole ethdev library!
> > >>
> > >> When all required fields received via arguments, one by one,
> > >> instead of struct, at least ABI versioning can be done on the API
> > >> when new field added, and can be possible to escape from ABI
> > >> breakage. But this will be ugly when number of arguments increased.
> > >>
> > >> Or any other opinion on how to define API to reduce ABI breakage?
> > >
> > > You're right.
> > > But I don't think we should have a function per data. Just because
> > > it would be ugly :)
> >
> > I am no suggesting function per data, instead something like:
> >
> > rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t maj, uint32_t min);
> >
> > And in the future if we need etrack_id too, we can have both in
> > versioned manner:
> >
> > rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t maj, uint32_t min);
> >
> > rte_eth_dev_fw_info_get(uint8_t port_id, uint32_t maj, uint32_t min,
> > 	uint32_t etrack_id);
> 
> Oh I see. So it can be versioned with compat macros.
> 
> > So my concern was if the number of the arguments becomes too many by
> time.
> 
> It looks to be a good proposal. We should not have a dozen of arguments.

I'd suggest to do that the similar way of kernel driver/ethtool (Linux or FreeBSD) does,
which should be well discussed.
In addition, for future extention, and avoid breaking any ABI in a strcuture,
we can just pre-define a lot of bytes as reserved, e.g. 64 bytes. Inside DPDK,
there are several strucutres defined like this, e.g. mbuf.

Thanks,
Helin

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

* Re: [dpdk-dev] [PATCH v4 1/5] ethdev: add firmware version get
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 1/5] ethdev: add firmware version get Qiming Yang
@ 2017-01-05 13:44           ` Thomas Monjalon
  2017-01-08  3:09             ` Yang, Qiming
  0 siblings, 1 reply; 128+ messages in thread
From: Thomas Monjalon @ 2017-01-05 13:44 UTC (permalink / raw)
  To: Qiming Yang; +Cc: dev, ferruh.yigit, helin.zhang, remy.horton

2017-01-04 20:03, Qiming Yang:
> This patch adds a new API 'rte_eth_dev_fw_version_get' for
> fetching firmware version related information by a given device.
[...]
>  /**
> + * Retrieve the firmware version of a device.
> + *
> + * @param port_id
> + *   The port identifier of the device.
> + * @param fw_major
> + *   A pointer to store the major firmware version of a device.
> + * @param fw_minor
> + *   A pointer to store the minor firmware version of a device.
> + * @param fw_patch
> + *   A pointer to store the firmware patch number of a device.
> + * @param etrack_id
> + *   A pointer to store the nvm version of a device.
> + */
> +void rte_eth_dev_fw_version_get(uint8_t port_id, uint32_t *fw_major,
> +	uint32_t *fw_minor, uint32_t *fw_patch, uint32_t *etrack_id);

After reading few comments, I think it should just fill a string.
There is no way the firmware version can be generalized or standardized.
If the application wants to do some processing like number comparisons,
it has to be aware of the specific firmware version string format.
If you want to help the application to parse this string, it should be
a PMD specific API.

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

* Re: [dpdk-dev] [PATCH v4 5/5] ethtool: dispaly firmware version
  2017-01-05  1:31             ` Yang, Qiming
@ 2017-01-06 15:55               ` Remy Horton
  0 siblings, 0 replies; 128+ messages in thread
From: Remy Horton @ 2017-01-06 15:55 UTC (permalink / raw)
  To: Yang, Qiming, Yigit, Ferruh, dev; +Cc: Zhang, Helin


On 05/01/2017 01:31, Yang, Qiming wrote:
[..]
>> +	if (strcmp(drvinfo->driver, "net_ixgbe") == 0)
>
> Do you need this check. I think it is not good idea to add this kind
> of checks into ethtool app. Why not just print "%d.%d.%d %#X, major,
> minor, patch, etrack" for all cases ?
 > Qiming: because I want to keep the format same with kernel version 
ethtool.

My feeling is that if we're going to have driver-specific output, then 
the task of constructing the string should be pushed down into the PMDs. 
It would also solve the headache of trying to standardise, as Thomas has 
mentioned..

..Remy

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

* Re: [dpdk-dev] [PATCH v4 1/5] ethdev: add firmware version get
  2017-01-05 13:44           ` Thomas Monjalon
@ 2017-01-08  3:09             ` Yang, Qiming
  0 siblings, 0 replies; 128+ messages in thread
From: Yang, Qiming @ 2017-01-08  3:09 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Yigit, Ferruh, Zhang, Helin, Horton, Remy

-----Original Message-----
From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] 
Sent: Thursday, January 5, 2017 9:45 PM
To: Yang, Qiming <qiming.yang@intel.com>
Cc: dev@dpdk.org; Yigit, Ferruh <ferruh.yigit@intel.com>; Zhang, Helin <helin.zhang@intel.com>; Horton, Remy <remy.horton@intel.com>
Subject: Re: [dpdk-dev] [PATCH v4 1/5] ethdev: add firmware version get

2017-01-04 20:03, Qiming Yang:
> This patch adds a new API 'rte_eth_dev_fw_version_get' for fetching 
> firmware version related information by a given device.
[...]
>  /**
> + * Retrieve the firmware version of a device.
> + *
> + * @param port_id
> + *   The port identifier of the device.
> + * @param fw_major
> + *   A pointer to store the major firmware version of a device.
> + * @param fw_minor
> + *   A pointer to store the minor firmware version of a device.
> + * @param fw_patch
> + *   A pointer to store the firmware patch number of a device.
> + * @param etrack_id
> + *   A pointer to store the nvm version of a device.
> + */
> +void rte_eth_dev_fw_version_get(uint8_t port_id, uint32_t *fw_major,
> +	uint32_t *fw_minor, uint32_t *fw_patch, uint32_t *etrack_id);

After reading few comments, I think it should just fill a string.
There is no way the firmware version can be generalized or standardized.
If the application wants to do some processing like number comparisons, it has to be aware of the specific firmware version string format.
If you want to help the application to parse this string, it should be a PMD specific API.
Qiming: I agree with you.

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

* [dpdk-dev] [PATCH v5 0/5] new API 'rte_eth_dev_fw_version_get'
  2017-01-04 12:03       ` [dpdk-dev] [PATCH v4 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                           ` (4 preceding siblings ...)
  2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 5/5] ethtool: dispaly firmware version Qiming Yang
@ 2017-01-08  4:11         ` Qiming Yang
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 1/5] ethdev: add firmware version get Qiming Yang
                             ` (6 more replies)
  5 siblings, 7 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-08  4:11 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, helin.zhang, remy.horton, Qiming Yang

Now, the example ethtool can only show the driver information. From
customers' point of view, it should be better if we can have the same
way that the Linux kernel ethtool does to show firmware version.

These five patches added a new function ``rte_eth_dev_fw_version_get()``
to fetch firmware version related information and implement the
display in example ethtool.


Qiming Yang (5):
  ethdev: add firmware version get
  net/e1000: add firmware version get
  net/ixgbe: add firmware version get
  net/i40e: add firmware version get
  ethtool: display firmware version

 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/nics/features/i40e.ini      |  1 +
 doc/guides/nics/features/igb.ini       |  1 +
 doc/guides/nics/features/ixgbe.ini     |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ---
 doc/guides/rel_notes/release_17_02.rst |  3 +++
 drivers/net/e1000/igb_ethdev.c         | 46 ++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.c         | 15 +++++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c       | 18 +++++++++++++
 examples/ethtool/ethtool-app/ethapp.c  |  1 +
 examples/ethtool/lib/rte_ethtool.c     |  3 +++
 lib/librte_ether/rte_ethdev.c          | 12 +++++++++
 lib/librte_ether/rte_ethdev.h          | 20 +++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 14 files changed, 123 insertions(+), 4 deletions(-)

-- 
2.7.4

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

* [dpdk-dev] [PATCH v5 1/5] ethdev: add firmware version get
  2017-01-08  4:11         ` [dpdk-dev] [PATCH v5 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
@ 2017-01-08  4:11           ` Qiming Yang
  2017-01-08  6:38             ` Andrew Rybchenko
  2017-01-08 23:05             ` Stephen Hemminger
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 2/5] net/e1000: " Qiming Yang
                             ` (5 subsequent siblings)
  6 siblings, 2 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-08  4:11 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, helin.zhang, remy.horton, Qiming Yang

This patch adds a new API 'rte_eth_dev_fw_version_get' for
fetching firmware version by a given device.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
v2 changes:
* modified some comment statements.
v3 changes:
* change API, use rte_eth_dev_fw_info_get(uint8_t port_id,
  uint32_t *fw_major, uint32_t *fw_minor, uint32_t *fw_patch,
  uint32_t *etrack_id) instead of rte_eth_dev_fwver_get(uint8_t port_id,
  char *fw_version, int fw_length).
  Add statusment in /doc/guides/nics/features/default.ini and
  release_17_02.rst.
v4 changes:
* remove deprecation notice, rename API as rte_eth_dev_fw_version_get.
v5 changes:
* change API, use rte_eth_dev_fw_version_get(uint8_t port_id,
  char *fw_version, int fw_length).
---
---
 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ----
 doc/guides/rel_notes/release_17_02.rst |  3 +++
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++++++
 lib/librte_ether/rte_ethdev.h          | 20 ++++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 6 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
index f1bf9bf..ae40d57 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -50,6 +50,7 @@ Timesync             =
 Basic stats          =
 Extended stats       =
 Stats per queue      =
+FW version           =
 EEPROM dump          =
 Registers dump       =
 Multiprocess aware   =
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 1438c77..291e03d 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -30,10 +30,6 @@ Deprecation Notices
   ``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
   segments limit to be transmitted by device for TSO/non-TSO packets.
 
-* In 17.02 ABI change is planned: the ``rte_eth_dev_info`` structure
-  will be extended with a new member ``fw_version`` in order to store
-  the NIC firmware version.
-
 * ethdev: an API change is planned for 17.02 for the function
   ``_rte_eth_dev_callback_process``. In 17.02 the function will return an ``int``
   instead of ``void`` and a fourth parameter ``void *ret_param`` will be added.
diff --git a/doc/guides/rel_notes/release_17_02.rst b/doc/guides/rel_notes/release_17_02.rst
index 180af82..260033d 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,9 @@ New Features
   See the :ref:`Generic flow API <Generic_flow_API>` documentation for more
   information.
 
+* **Added firmware version get API.**
+ Added a new function ``rte_eth_dev_fw_version_get()`` to fetch firmware
+ version by a given device.
 
 Resolved Issues
 ---------------
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 280f0db..cb80476 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1586,6 +1586,18 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
 }
 
 void
+rte_eth_dev_fw_version_get(uint8_t port_id, char *fw_version, int fw_length)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
+	dev = &rte_eth_devices[port_id];
+
+	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->fw_version_get);
+	(*dev->dev_ops->fw_version_get)(dev, fw_version, fw_length);
+}
+
+void
 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 {
 	struct rte_eth_dev *dev;
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index fb51754..2be31d2 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1150,6 +1150,10 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
 /**< @internal Check DD bit of specific RX descriptor */
 
+typedef void (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
+				     char *fw_version, int fw_length);
+/**< @internal Get firmware information of an Ethernet device. */
+
 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
 	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
 
@@ -1455,6 +1459,7 @@ struct eth_dev_ops {
 	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
 	eth_rxq_info_get_t         rxq_info_get; /**< retrieve RX queue information. */
 	eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
+	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
 	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
 	/**< Get packet types supported and identified by device. */
 
@@ -2395,6 +2400,21 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
 void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
 
 /**
+ * Retrieve the firmware version of a device.
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param fw_version
+ *   A array pointer to store the firmware version of a device,
+ *   allocated by caller.
+ * @param fw_length
+ *   The size of the array pointed by fw_version, which should be
+ *   large enough to store firmware version of the device.
+ */
+void rte_eth_dev_fw_version_get(uint8_t port_id,
+				char *fw_version, int fw_length);
+
+/**
  * Retrieve the supported packet types of an Ethernet device.
  *
  * When a packet type is announced as supported, it *must* be recognized by
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index a021781..0cf94ed 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -151,6 +151,7 @@ DPDK_17.02 {
 	global:
 
 	_rte_eth_dev_reset;
+	rte_eth_dev_fw_version_get;
 	rte_flow_create;
 	rte_flow_destroy;
 	rte_flow_flush;
-- 
2.7.4

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

* [dpdk-dev] [PATCH v5 2/5] net/e1000: add firmware version get
  2017-01-08  4:11         ` [dpdk-dev] [PATCH v5 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 1/5] ethdev: add firmware version get Qiming Yang
@ 2017-01-08  4:11           ` Qiming Yang
  2017-01-08 23:03             ` Stephen Hemminger
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 3/5] net/ixgbe: " Qiming Yang
                             ` (4 subsequent siblings)
  6 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2017-01-08  4:11 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, helin.zhang, remy.horton, Qiming Yang

This patch adds a new function eth_igb_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
v3 changes:
 * use eth_igb_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
   u32 *fw_minor, u32 *fw_minor, u32 *fw_patch, u32 *etrack_id) instead
   of eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
   int fw_length). Add statusment in /doc/guides/nics/features/igb.ini.
v5 changes:
 * use the function interface in patch v2.
---
---
 doc/guides/nics/features/igb.ini |  1 +
 drivers/net/e1000/igb_ethdev.c   | 46 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/doc/guides/nics/features/igb.ini b/doc/guides/nics/features/igb.ini
index 9fafe72..26ae008 100644
--- a/doc/guides/nics/features/igb.ini
+++ b/doc/guides/nics/features/igb.ini
@@ -35,6 +35,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 BSD nic_uio          = Y
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 4a15447..2bdcf39 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -120,6 +120,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
 				    unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
+static void eth_igb_fw_version_get(struct rte_eth_dev *dev,
+				   char *fw_version, int fw_length);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static const uint32_t *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -389,6 +391,7 @@ static const struct eth_dev_ops eth_igb_ops = {
 	.xstats_get_names     = eth_igb_xstats_get_names,
 	.stats_reset          = eth_igb_stats_reset,
 	.xstats_reset         = eth_igb_xstats_reset,
+	.fw_version_get       = eth_igb_fw_version_get,
 	.dev_infos_get        = eth_igb_infos_get,
 	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
 	.mtu_set              = eth_igb_mtu_set,
@@ -1981,6 +1984,49 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
 }
 
 static void
+eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+		       int fw_length)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_fw_version fw;
+
+	e1000_get_fw_version(hw, &fw);
+
+	switch (hw->mac.type) {
+	case e1000_i210:
+	case e1000_i211:
+		if (!(e1000_get_flash_presence_i210(hw))) {
+			snprintf(fw_version, fw_length,
+				 "%2d.%2d-%d",
+				 fw.invm_major, fw.invm_minor,
+				 fw.invm_img_type);
+			break;
+		}
+		/* fall through */
+	default:
+		/* if option rom is valid, display its version too*/
+		if (fw.or_valid) {
+			snprintf(fw_version, fw_length,
+				 "%d.%d, 0x%08x, %d.%d.%d",
+				 fw.eep_major, fw.eep_minor, fw.etrack_id,
+				 fw.or_major, fw.or_build, fw.or_patch);
+		/* no option rom */
+		} else {
+			if (fw.etrack_id != 0X0000) {
+			snprintf(fw_version, fw_length,
+				 "%d.%d, 0x%08x",
+				 fw.eep_major, fw.eep_minor, fw.etrack_id);
+			} else {
+			snprintf(fw_version, fw_length,
+				 "%d.%d.%d",
+				 fw.eep_major, fw.eep_minor, fw.eep_build);
+			}
+		}
+		break;
+	}
+}
+
+static void
 eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH v5 3/5] net/ixgbe: add firmware version get
  2017-01-08  4:11         ` [dpdk-dev] [PATCH v5 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 1/5] ethdev: add firmware version get Qiming Yang
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 2/5] net/e1000: " Qiming Yang
@ 2017-01-08  4:11           ` Qiming Yang
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 4/5] net/i40e: " Qiming Yang
                             ` (3 subsequent siblings)
  6 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-08  4:11 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, helin.zhang, remy.horton, Qiming Yang

This patch adds a new function ixgbe_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
v3 changes:
 * use ixgbe_fw_version_get(struct rte_eth_dev *dev,
   __rte_unused u32 *fw_major, __rte_unused u32 *fw_minor,
   __rte_unused u32 *fw_patch, u32 *etrack_id) instead of
   ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
   int fw_length). Add statusment
   in /doc/guides/nics/features/ixgbe.ini.
v5 changes:
 * use the function interface in patch v2.
---
---
 doc/guides/nics/features/ixgbe.ini |  1 +
 drivers/net/ixgbe/ixgbe_ethdev.c   | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/doc/guides/nics/features/ixgbe.ini b/doc/guides/nics/features/ixgbe.ini
index 4a5667f..e7104c2 100644
--- a/doc/guides/nics/features/ixgbe.ini
+++ b/doc/guides/nics/features/ixgbe.ini
@@ -43,6 +43,7 @@ Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 Multiprocess aware   = Y
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index ec2edad..407f398 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -193,6 +193,8 @@ static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint16_t queue_id,
 					     uint8_t stat_idx,
 					     uint8_t is_rx);
+static void ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+				 int fw_length);
 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
 			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -538,6 +540,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.xstats_reset         = ixgbe_dev_xstats_reset,
 	.xstats_get_names     = ixgbe_dev_xstats_get_names,
 	.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
+	.fw_version_get       = ixgbe_fw_version_get,
 	.dev_infos_get        = ixgbe_dev_info_get,
 	.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
 	.mtu_set              = ixgbe_dev_mtu_set,
@@ -3029,6 +3032,21 @@ ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
 }
 
 static void
+ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, int fw_length)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u16 eeprom_verh, eeprom_verl;
+	u32 etrack_id;
+
+	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
+	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
+
+	etrack_id = (eeprom_verh << 16) | eeprom_verl;
+	snprintf(fw_version, fw_length,
+		 "0x%08x", etrack_id);
+}
+
+static void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
-- 
2.7.4

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

* [dpdk-dev] [PATCH v5 4/5] net/i40e: add firmware version get
  2017-01-08  4:11         ` [dpdk-dev] [PATCH v5 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                             ` (2 preceding siblings ...)
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 3/5] net/ixgbe: " Qiming Yang
@ 2017-01-08  4:11           ` Qiming Yang
  2017-01-08 23:08             ` Stephen Hemminger
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 5/5] ethtool: display firmware version Qiming Yang
                             ` (2 subsequent siblings)
  6 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2017-01-08  4:11 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, helin.zhang, remy.horton, Qiming Yang

This patch add a new function i40e_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
v3 changes:
 * use i40e_fw_version_get(struct rte_eth_dev *dev, u32 *fw_major,
   u32 *fw_minor, __rte_unused u32 *fw_patch, u32 *etrack_id)
   instead of i40e_fw_version_get(struct rte_eth_dev *dev,
   char *fw_version, int fw_length). Add statusment in
   /doc/guides/nics/features/i40e.ini.
v5 changes:
 * use the function interface in patch v2.
---
---
 doc/guides/nics/features/i40e.ini |  1 +
 drivers/net/i40e/i40e_ethdev.c    | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/doc/guides/nics/features/i40e.ini b/doc/guides/nics/features/i40e.ini
index 0d143bc..0dbc3c3 100644
--- a/doc/guides/nics/features/i40e.ini
+++ b/doc/guides/nics/features/i40e.ini
@@ -39,6 +39,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 Multiprocess aware   = Y
 BSD nic_uio          = Y
 Linux UIO            = Y
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 8f63044..ff6f106 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -324,6 +324,8 @@ static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
 					    uint16_t queue_id,
 					    uint8_t stat_idx,
 					    uint8_t is_rx);
+static void i40e_fw_version_get(struct rte_eth_dev *dev,
+				char *fw_version, int fw_length);
 static void i40e_dev_info_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static int i40e_vlan_filter_set(struct rte_eth_dev *dev,
@@ -503,6 +505,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.stats_reset                  = i40e_dev_stats_reset,
 	.xstats_reset                 = i40e_dev_stats_reset,
 	.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
+	.fw_version_get               = i40e_fw_version_get,
 	.dev_infos_get                = i40e_dev_info_get,
 	.dev_supported_ptypes_get     = i40e_dev_supported_ptypes_get,
 	.vlan_filter_set              = i40e_vlan_filter_set,
@@ -2590,6 +2593,18 @@ i40e_dev_queue_stats_mapping_set(__rte_unused struct rte_eth_dev *dev,
 }
 
 static void
+i40e_fw_version_get(struct rte_eth_dev *dev, char *fw_version, int fw_length)
+{
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	snprintf(fw_version, fw_length,
+		 "%d.%d%d 0x%08x",
+		 ((hw->nvm.version >> 12) & 0xf),
+		 ((hw->nvm.version >> 4) & 0xff),
+		 (hw->nvm.version & 0xf), hw->nvm.eetrack);
+}
+
+static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
-- 
2.7.4

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

* [dpdk-dev] [PATCH v5 5/5] ethtool: display firmware version
  2017-01-08  4:11         ` [dpdk-dev] [PATCH v5 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                             ` (3 preceding siblings ...)
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 4/5] net/i40e: " Qiming Yang
@ 2017-01-08  4:11           ` Qiming Yang
  2017-01-08 23:11             ` Stephen Hemminger
  2017-01-10  9:00           ` [dpdk-dev] [DPDK 1/5] ethdev: add firmware version get Qiming Yang
  2017-01-10  9:08           ` [dpdk-dev] [PATCH v6 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  6 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2017-01-08  4:11 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, helin.zhang, remy.horton, Qiming Yang

This patch enhances the ethtool example to support to show
firmware version, in the same way that the Linux kernel
ethtool does.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
v4 changes:
 * split bus info print from this patch set
---
---
 examples/ethtool/ethtool-app/ethapp.c | 1 +
 examples/ethtool/lib/rte_ethtool.c    | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
index 6aeaa06..85c31ac 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -185,6 +185,7 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
 		printf("Port %i driver: %s (ver: %s)\n",
 			id_port, info.driver, info.version
 		      );
+		printf("firmware-version: %s\n", info.fw_version);
 	}
 }
 
diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index 6f0ce84..36f4ae8 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -54,6 +54,9 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
+	rte_eth_dev_fw_version_get(port_id, drvinfo->fw_version,
+			      sizeof(drvinfo->fw_version));
+
 	memset(&dev_info, 0, sizeof(dev_info));
 	rte_eth_dev_info_get(port_id, &dev_info);
 
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH v5 1/5] ethdev: add firmware version get
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 1/5] ethdev: add firmware version get Qiming Yang
@ 2017-01-08  6:38             ` Andrew Rybchenko
  2017-01-08 23:05             ` Stephen Hemminger
  1 sibling, 0 replies; 128+ messages in thread
From: Andrew Rybchenko @ 2017-01-08  6:38 UTC (permalink / raw)
  To: Qiming Yang, dev; +Cc: ferruh.yigit, helin.zhang, remy.horton

On 01/08/2017 07:11 AM, Qiming Yang wrote:
> This patch adds a new API 'rte_eth_dev_fw_version_get' for
> fetching firmware version by a given device.
>
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> Acked-by: Remy Horton <remy.horton@intel.com>
> ---
> v2 changes:
> * modified some comment statements.
> v3 changes:
> * change API, use rte_eth_dev_fw_info_get(uint8_t port_id,
>    uint32_t *fw_major, uint32_t *fw_minor, uint32_t *fw_patch,
>    uint32_t *etrack_id) instead of rte_eth_dev_fwver_get(uint8_t port_id,
>    char *fw_version, int fw_length).
>    Add statusment in /doc/guides/nics/features/default.ini and
>    release_17_02.rst.
> v4 changes:
> * remove deprecation notice, rename API as rte_eth_dev_fw_version_get.
> v5 changes:
> * change API, use rte_eth_dev_fw_version_get(uint8_t port_id,
>    char *fw_version, int fw_length).
> ---
> ---
>   doc/guides/nics/features/default.ini   |  1 +
>   doc/guides/rel_notes/deprecation.rst   |  4 ----
>   doc/guides/rel_notes/release_17_02.rst |  3 +++
>   lib/librte_ether/rte_ethdev.c          | 12 ++++++++++++
>   lib/librte_ether/rte_ethdev.h          | 20 ++++++++++++++++++++
>   lib/librte_ether/rte_ether_version.map |  1 +
>   6 files changed, 37 insertions(+), 4 deletions(-)
>
> diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
> index f1bf9bf..ae40d57 100644
> --- a/doc/guides/nics/features/default.ini
> +++ b/doc/guides/nics/features/default.ini
> @@ -50,6 +50,7 @@ Timesync             =
>   Basic stats          =
>   Extended stats       =
>   Stats per queue      =
> +FW version           =
>   EEPROM dump          =
>   Registers dump       =
>   Multiprocess aware   =
> diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
> index 1438c77..291e03d 100644
> --- a/doc/guides/rel_notes/deprecation.rst
> +++ b/doc/guides/rel_notes/deprecation.rst
> @@ -30,10 +30,6 @@ Deprecation Notices
>     ``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
>     segments limit to be transmitted by device for TSO/non-TSO packets.
>   
> -* In 17.02 ABI change is planned: the ``rte_eth_dev_info`` structure
> -  will be extended with a new member ``fw_version`` in order to store
> -  the NIC firmware version.
> -
>   * ethdev: an API change is planned for 17.02 for the function
>     ``_rte_eth_dev_callback_process``. In 17.02 the function will return an ``int``
>     instead of ``void`` and a fourth parameter ``void *ret_param`` will be added.
> diff --git a/doc/guides/rel_notes/release_17_02.rst b/doc/guides/rel_notes/release_17_02.rst
> index 180af82..260033d 100644
> --- a/doc/guides/rel_notes/release_17_02.rst
> +++ b/doc/guides/rel_notes/release_17_02.rst
> @@ -52,6 +52,9 @@ New Features
>     See the :ref:`Generic flow API <Generic_flow_API>` documentation for more
>     information.
>   
> +* **Added firmware version get API.**
> + Added a new function ``rte_eth_dev_fw_version_get()`` to fetch firmware
> + version by a given device.
>   
>   Resolved Issues
>   ---------------
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index 280f0db..cb80476 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -1586,6 +1586,18 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
>   }
>   
>   void
> +rte_eth_dev_fw_version_get(uint8_t port_id, char *fw_version, int fw_length)

May be size_t should be used for fw_length? Corresponding argument of 
the snprintf()
has size_t type, sizeof(drvinfo.fw_version) is used as value of the 
parameter.

Also the prototype does not provide a way to communicate that fw_length 
is insufficient
to store firmware version. I'd suggest snprintf()-like return value. It 
is pretty easy for PMD
to provide and convenient for the API function caller to handle.

> +{
> +	struct rte_eth_dev *dev;
> +
> +	RTE_ETH_VALID_PORTID_OR_RET(port_id);
> +	dev = &rte_eth_devices[port_id];
> +
> +	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->fw_version_get);
> +	(*dev->dev_ops->fw_version_get)(dev, fw_version, fw_length);
> +}
> +
> +void
>   rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
>   {
>   	struct rte_eth_dev *dev;
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index fb51754..2be31d2 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -1150,6 +1150,10 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
>   typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
>   /**< @internal Check DD bit of specific RX descriptor */
>   
> +typedef void (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
> +				     char *fw_version, int fw_length);
> +/**< @internal Get firmware information of an Ethernet device. */
> +
>   typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
>   	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
>   
> @@ -1455,6 +1459,7 @@ struct eth_dev_ops {
>   	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
>   	eth_rxq_info_get_t         rxq_info_get; /**< retrieve RX queue information. */
>   	eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
> +	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
>   	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
>   	/**< Get packet types supported and identified by device. */
>   
> @@ -2395,6 +2400,21 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
>   void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
>   
>   /**
> + * Retrieve the firmware version of a device.
> + *
> + * @param port_id
> + *   The port identifier of the device.
> + * @param fw_version
> + *   A array pointer to store the firmware version of a device,
> + *   allocated by caller.
> + * @param fw_length
> + *   The size of the array pointed by fw_version, which should be
> + *   large enough to store firmware version of the device.
> + */
> +void rte_eth_dev_fw_version_get(uint8_t port_id,
> +				char *fw_version, int fw_length);
> +
> +/**
>    * Retrieve the supported packet types of an Ethernet device.
>    *
>    * When a packet type is announced as supported, it *must* be recognized by
> diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
> index a021781..0cf94ed 100644
> --- a/lib/librte_ether/rte_ether_version.map
> +++ b/lib/librte_ether/rte_ether_version.map
> @@ -151,6 +151,7 @@ DPDK_17.02 {
>   	global:
>   
>   	_rte_eth_dev_reset;
> +	rte_eth_dev_fw_version_get;
>   	rte_flow_create;
>   	rte_flow_destroy;
>   	rte_flow_flush;

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

* Re: [dpdk-dev] [PATCH v5 2/5] net/e1000: add firmware version get
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 2/5] net/e1000: " Qiming Yang
@ 2017-01-08 23:03             ` Stephen Hemminger
  2017-01-09  1:48               ` Yang, Qiming
  0 siblings, 1 reply; 128+ messages in thread
From: Stephen Hemminger @ 2017-01-08 23:03 UTC (permalink / raw)
  To: Qiming Yang; +Cc: dev, ferruh.yigit, helin.zhang, remy.horton

On Sun,  8 Jan 2017 12:11:32 +0800
Qiming Yang <qiming.yang@intel.com> wrote:

> +	switch (hw->mac.type) {
> +	case e1000_i210:
> +	case e1000_i211:
> +		if (!(e1000_get_flash_presence_i210(hw))) {
> +			snprintf(fw_version, fw_length,
> +				 "%2d.%2d-%d",
> +				 fw.invm_major, fw.invm_minor,
> +				 fw.invm_img_type);
> +			break;
> +		}
> +		/* fall through */
> +	default:
> +		/* if option rom is valid, display its version too*/
> +		if (fw.or_valid) {
> +			snprintf(fw_version, fw_length,
> +				 "%d.%d, 0x%08x, %d.%d.%d",
> +				 fw.eep_major, fw.eep_minor, fw.etrack_id,
> +				 fw.or_major, fw.or_build, fw.or_patch);
> +		/* no option rom */
> +		} else {
> +			if (fw.etrack_id != 0X0000) {
> +			snprintf(fw_version, fw_length,
> +				 "%d.%d, 0x%08x",
> +				 fw.eep_major, fw.eep_minor, fw.etrack_id);
> +			} else {
> +			snprintf(fw_version, fw_length,
> +				 "%d.%d.%d",
> +				 fw.eep_major, fw.eep_minor, fw.eep_build);

Indentation is incorrect here.

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

* Re: [dpdk-dev] [PATCH v5 1/5] ethdev: add firmware version get
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 1/5] ethdev: add firmware version get Qiming Yang
  2017-01-08  6:38             ` Andrew Rybchenko
@ 2017-01-08 23:05             ` Stephen Hemminger
  2017-01-09  7:16               ` Yang, Qiming
  1 sibling, 1 reply; 128+ messages in thread
From: Stephen Hemminger @ 2017-01-08 23:05 UTC (permalink / raw)
  To: Qiming Yang; +Cc: dev, ferruh.yigit, helin.zhang, remy.horton

On Sun,  8 Jan 2017 12:11:31 +0800
Qiming Yang <qiming.yang@intel.com> wrote:

>  void
> +rte_eth_dev_fw_version_get(uint8_t port_id, char *fw_version, int fw_length)
> +{
> +	struct rte_eth_dev *dev;
> +
> +	RTE_ETH_VALID_PORTID_OR_RET(port_id);
> +	dev = &rte_eth_devices[port_id];
> +
> +	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->fw_version_get);
> +	(*dev->dev_ops->fw_version_get)(dev, fw_version, fw_length);
> +}

Maybe dev argument to fw_version_get should be:
   const struct rte_eth_dev *dev

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

* Re: [dpdk-dev] [PATCH v5 4/5] net/i40e: add firmware version get
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 4/5] net/i40e: " Qiming Yang
@ 2017-01-08 23:08             ` Stephen Hemminger
  0 siblings, 0 replies; 128+ messages in thread
From: Stephen Hemminger @ 2017-01-08 23:08 UTC (permalink / raw)
  To: Qiming Yang; +Cc: dev, ferruh.yigit, helin.zhang, remy.horton

On Sun,  8 Jan 2017 12:11:34 +0800
Qiming Yang <qiming.yang@intel.com> wrote:

>  static void
> +i40e_fw_version_get(struct rte_eth_dev *dev, char *fw_version, int fw_length)
> +{
> +	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +
> +	snprintf(fw_version, fw_length,
> +		 "%d.%d%d 0x%08x",
> +		 ((hw->nvm.version >> 12) & 0xf),
> +		 ((hw->nvm.version >> 4) & 0xff),
> +		 (hw->nvm.version & 0xf), hw->nvm.eetrack);


It would be good to have same constants and format between Linux kernel
driver and DPDK.

Use %u as format specifier for unsigned values

static inline char *i40e_nvm_version_str(struct i40e_hw *hw)
{
	static char buf[32];
	u32 full_ver;
	u8 ver, patch;
	u16 build;

	full_ver = hw->nvm.oem_ver;
	ver = (u8)(full_ver >> I40E_OEM_VER_SHIFT);
	build = (u16)((full_ver >> I40E_OEM_VER_BUILD_SHIFT) &
		 I40E_OEM_VER_BUILD_MASK);
	patch = (u8)(full_ver & I40E_OEM_VER_PATCH_MASK);

	snprintf(buf, sizeof(buf),
		 "%x.%02x 0x%x %d.%d.%d",
		 (hw->nvm.version & I40E_NVM_VERSION_HI_MASK) >>
			I40E_NVM_VERSION_HI_SHIFT,
		 (hw->nvm.version & I40E_NVM_VERSION_LO_MASK) >>
			I40E_NVM_VERSION_LO_SHIFT,
		 hw->nvm.eetrack, ver, build, patch);

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

* Re: [dpdk-dev] [PATCH v5 5/5] ethtool: display firmware version
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 5/5] ethtool: display firmware version Qiming Yang
@ 2017-01-08 23:11             ` Stephen Hemminger
  0 siblings, 0 replies; 128+ messages in thread
From: Stephen Hemminger @ 2017-01-08 23:11 UTC (permalink / raw)
  To: Qiming Yang; +Cc: dev, ferruh.yigit, helin.zhang, remy.horton

On Sun,  8 Jan 2017 12:11:35 +0800
Qiming Yang <qiming.yang@intel.com> wrote:

> --- a/examples/ethtool/lib/rte_ethtool.c
> +++ b/examples/ethtool/lib/rte_ethtool.c
> @@ -54,6 +54,9 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
>  
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
>  
> +	rte_eth_dev_fw_version_get(port_id, drvinfo->fw_version,
> +			      sizeof(drvinfo->fw_version));
> +
>  	memset(&dev_info, 0, sizeof(dev_info));
>  	rte_eth_dev_info_get(port_id, &dev_info);

That memset is redundant since dev_info_get() does memset as first thing.

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

* Re: [dpdk-dev] [PATCH v5 2/5] net/e1000: add firmware version get
  2017-01-08 23:03             ` Stephen Hemminger
@ 2017-01-09  1:48               ` Yang, Qiming
  0 siblings, 0 replies; 128+ messages in thread
From: Yang, Qiming @ 2017-01-09  1:48 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Yigit, Ferruh, Zhang, Helin, Horton, Remy



-----Original Message-----
From: Stephen Hemminger [mailto:stephen@networkplumber.org] 
Sent: Monday, January 9, 2017 7:04 AM
To: Yang, Qiming <qiming.yang@intel.com>
Cc: dev@dpdk.org; Yigit, Ferruh <ferruh.yigit@intel.com>; Zhang, Helin <helin.zhang@intel.com>; Horton, Remy <remy.horton@intel.com>
Subject: Re: [dpdk-dev] [PATCH v5 2/5] net/e1000: add firmware version get

On Sun,  8 Jan 2017 12:11:32 +0800
Qiming Yang <qiming.yang@intel.com> wrote:

> +	switch (hw->mac.type) {
> +	case e1000_i210:
> +	case e1000_i211:
> +		if (!(e1000_get_flash_presence_i210(hw))) {
> +			snprintf(fw_version, fw_length,
> +				 "%2d.%2d-%d",
> +				 fw.invm_major, fw.invm_minor,
> +				 fw.invm_img_type);
> +			break;
> +		}
> +		/* fall through */
> +	default:
> +		/* if option rom is valid, display its version too*/
> +		if (fw.or_valid) {
> +			snprintf(fw_version, fw_length,
> +				 "%d.%d, 0x%08x, %d.%d.%d",
> +				 fw.eep_major, fw.eep_minor, fw.etrack_id,
> +				 fw.or_major, fw.or_build, fw.or_patch);
> +		/* no option rom */
> +		} else {
> +			if (fw.etrack_id != 0X0000) {
> +			snprintf(fw_version, fw_length,
> +				 "%d.%d, 0x%08x",
> +				 fw.eep_major, fw.eep_minor, fw.etrack_id);
> +			} else {
> +			snprintf(fw_version, fw_length,
> +				 "%d.%d.%d",
> +				 fw.eep_major, fw.eep_minor, fw.eep_build);

Indentation is incorrect here.
Qiming: my mistake.

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

* Re: [dpdk-dev] [PATCH v5 1/5] ethdev: add firmware version get
  2017-01-08 23:05             ` Stephen Hemminger
@ 2017-01-09  7:16               ` Yang, Qiming
  2017-01-09 10:01                 ` Remy Horton
  0 siblings, 1 reply; 128+ messages in thread
From: Yang, Qiming @ 2017-01-09  7:16 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Yigit, Ferruh, Zhang, Helin, Horton, Remy

-----Original Message-----
From: Stephen Hemminger [mailto:stephen@networkplumber.org] 
Sent: Monday, January 9, 2017 7:05 AM
To: Yang, Qiming <qiming.yang@intel.com>
Cc: dev@dpdk.org; Yigit, Ferruh <ferruh.yigit@intel.com>; Zhang, Helin <helin.zhang@intel.com>; Horton, Remy <remy.horton@intel.com>
Subject: Re: [dpdk-dev] [PATCH v5 1/5] ethdev: add firmware version get

On Sun,  8 Jan 2017 12:11:31 +0800
Qiming Yang <qiming.yang@intel.com> wrote:

>  void
> +rte_eth_dev_fw_version_get(uint8_t port_id, char *fw_version, int 
> +fw_length) {
> +	struct rte_eth_dev *dev;
> +
> +	RTE_ETH_VALID_PORTID_OR_RET(port_id);
> +	dev = &rte_eth_devices[port_id];
> +
> +	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->fw_version_get);
> +	(*dev->dev_ops->fw_version_get)(dev, fw_version, fw_length); }

Maybe dev argument to fw_version_get should be:
   const struct rte_eth_dev *dev
Qiming: do you means the argument to ops fw_version_get? 
why should add 'const'? both two are OK, but we usually use struct rte_eth_dev *dev.

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

* Re: [dpdk-dev] [PATCH v5 1/5] ethdev: add firmware version get
  2017-01-09  7:16               ` Yang, Qiming
@ 2017-01-09 10:01                 ` Remy Horton
  2017-01-09 17:23                   ` Stephen Hemminger
  0 siblings, 1 reply; 128+ messages in thread
From: Remy Horton @ 2017-01-09 10:01 UTC (permalink / raw)
  To: Yang, Qiming, Stephen Hemminger; +Cc: dev, Yigit, Ferruh, Zhang, Helin


On 09/01/2017 07:16, Yang, Qiming wrote:
> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
[..]
>>  void
>> +rte_eth_dev_fw_version_get(uint8_t port_id, char *fw_version, int
>> +fw_length) {
>> +	struct rte_eth_dev *dev;
>> +
>> +	RTE_ETH_VALID_PORTID_OR_RET(port_id);
>> +	dev = &rte_eth_devices[port_id];
>> +
>> +	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->fw_version_get);
>> +	(*dev->dev_ops->fw_version_get)(dev, fw_version, fw_length); }
>
> Maybe dev argument to fw_version_get should be:
>    const struct rte_eth_dev *dev
> Qiming: do you means the argument to ops fw_version_get?
> why should add 'const'? both two are OK, but we usually use struct rte_eth_dev *dev.

Does seem a bit odd to me as I don't think any of the other rte_dev_ops 
entrypoints use const. Maybe they should but if that's now policy (I've 
been under a rock recently) probably better to do them all in a seperate 
cleanup patchset..

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

* Re: [dpdk-dev] [PATCH v5 1/5] ethdev: add firmware version get
  2017-01-09 10:01                 ` Remy Horton
@ 2017-01-09 17:23                   ` Stephen Hemminger
  0 siblings, 0 replies; 128+ messages in thread
From: Stephen Hemminger @ 2017-01-09 17:23 UTC (permalink / raw)
  To: Remy Horton; +Cc: Yang, Qiming, dev, Yigit, Ferruh, Zhang, Helin

On Mon, 9 Jan 2017 10:01:40 +0000
Remy Horton <remy.horton@intel.com> wrote:

> On 09/01/2017 07:16, Yang, Qiming wrote:
> > -----Original Message-----
> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]  
> [..]
> >>  void
> >> +rte_eth_dev_fw_version_get(uint8_t port_id, char *fw_version, int
> >> +fw_length) {
> >> +	struct rte_eth_dev *dev;
> >> +
> >> +	RTE_ETH_VALID_PORTID_OR_RET(port_id);
> >> +	dev = &rte_eth_devices[port_id];
> >> +
> >> +	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->fw_version_get);
> >> +	(*dev->dev_ops->fw_version_get)(dev, fw_version, fw_length); }  
> >
> > Maybe dev argument to fw_version_get should be:
> >    const struct rte_eth_dev *dev
> > Qiming: do you means the argument to ops fw_version_get?
> > why should add 'const'? both two are OK, but we usually use struct rte_eth_dev *dev.  
> 
> Does seem a bit odd to me as I don't think any of the other rte_dev_ops 
> entrypoints use const. Maybe they should but if that's now policy (I've 
> been under a rock recently) probably better to do them all in a seperate 
> cleanup patchset..

DPDK is somewhat lazy about using const.

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

* [dpdk-dev] [DPDK 1/5] ethdev: add firmware version get
  2017-01-08  4:11         ` [dpdk-dev] [PATCH v5 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                             ` (4 preceding siblings ...)
  2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 5/5] ethtool: display firmware version Qiming Yang
@ 2017-01-10  9:00           ` Qiming Yang
  2017-01-10  9:00             ` [dpdk-dev] [DPDK 2/5] net/e1000: " Qiming Yang
  2017-01-10  9:00             ` [dpdk-dev] [DPDK 3/5] net/ixgbe: " Qiming Yang
  2017-01-10  9:08           ` [dpdk-dev] [PATCH v6 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  6 siblings, 2 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-10  9:00 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, ferruh.yigit, helin.zhang, Qiming Yang

This patch adds a new API 'rte_eth_dev_fw_version_get' for
fetching firmware version by a given device.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ----
 doc/guides/rel_notes/release_17_02.rst |  3 +++
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++++++
 lib/librte_ether/rte_ethdev.h          | 25 +++++++++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 6 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
index f1bf9bf..ae40d57 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -50,6 +50,7 @@ Timesync             =
 Basic stats          =
 Extended stats       =
 Stats per queue      =
+FW version           =
 EEPROM dump          =
 Registers dump       =
 Multiprocess aware   =
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 1438c77..291e03d 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -30,10 +30,6 @@ Deprecation Notices
   ``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
   segments limit to be transmitted by device for TSO/non-TSO packets.
 
-* In 17.02 ABI change is planned: the ``rte_eth_dev_info`` structure
-  will be extended with a new member ``fw_version`` in order to store
-  the NIC firmware version.
-
 * ethdev: an API change is planned for 17.02 for the function
   ``_rte_eth_dev_callback_process``. In 17.02 the function will return an ``int``
   instead of ``void`` and a fourth parameter ``void *ret_param`` will be added.
diff --git a/doc/guides/rel_notes/release_17_02.rst b/doc/guides/rel_notes/release_17_02.rst
index 180af82..260033d 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,9 @@ New Features
   See the :ref:`Generic flow API <Generic_flow_API>` documentation for more
   information.
 
+* **Added firmware version get API.**
+ Added a new function ``rte_eth_dev_fw_version_get()`` to fetch firmware
+ version by a given device.
 
 Resolved Issues
 ---------------
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 9dea1f1..49ca42d 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1588,6 +1588,18 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
 			STAT_QMAP_RX);
 }
 
+int
+rte_eth_dev_fw_version_get(uint8_t port_id, char *fw_version, size_t fw_size)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fw_version_get, -ENOTSUP);
+	return (*dev->dev_ops->fw_version_get)(dev, fw_version, fw_size);
+}
+
 void
 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 1c356c1..357612d 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1177,6 +1177,10 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
 /**< @internal Check DD bit of specific RX descriptor */
 
+typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
+				     char *fw_version, size_t fw_size);
+/**< @internal Get firmware information of an Ethernet device. */
+
 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
 	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
 
@@ -1487,6 +1491,7 @@ struct eth_dev_ops {
 	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
 	eth_rxq_info_get_t         rxq_info_get; /**< retrieve RX queue information. */
 	eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
+	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
 	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
 	/**< Get packet types supported and identified by device. */
 
@@ -2430,6 +2435,26 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
 void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
 
 /**
+ * Retrieve the firmware version of a device.
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param fw_version
+ *   A array pointer to store the firmware version of a device,
+ *   allocated by caller.
+ * @param fw_size
+ *   The size of the array pointed by fw_version, which should be
+ *   large enough to store firmware version of the device.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if operation is not supported.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EINVAL) if *fw_size* is not enough to store firmware version.
+ */
+int rte_eth_dev_fw_version_get(uint8_t port_id,
+			       char *fw_version, size_t fw_size);
+
+/**
  * Retrieve the supported packet types of an Ethernet device.
  *
  * When a packet type is announced as supported, it *must* be recognized by
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index a021781..0cf94ed 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -151,6 +151,7 @@ DPDK_17.02 {
 	global:
 
 	_rte_eth_dev_reset;
+	rte_eth_dev_fw_version_get;
 	rte_flow_create;
 	rte_flow_destroy;
 	rte_flow_flush;
-- 
2.7.4

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

* [dpdk-dev] [DPDK 2/5] net/e1000: add firmware version get
  2017-01-10  9:00           ` [dpdk-dev] [DPDK 1/5] ethdev: add firmware version get Qiming Yang
@ 2017-01-10  9:00             ` Qiming Yang
  2017-01-10  9:00             ` [dpdk-dev] [DPDK 3/5] net/ixgbe: " Qiming Yang
  1 sibling, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-10  9:00 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, ferruh.yigit, helin.zhang, Qiming Yang

This patch adds a new function eth_igb_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/igb.ini |  1 +
 drivers/net/e1000/igb_ethdev.c   | 54 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/doc/guides/nics/features/igb.ini b/doc/guides/nics/features/igb.ini
index 9fafe72..26ae008 100644
--- a/doc/guides/nics/features/igb.ini
+++ b/doc/guides/nics/features/igb.ini
@@ -35,6 +35,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 BSD nic_uio          = Y
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 2bb57f5..10519ad 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -120,6 +120,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
 				    unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
+static int eth_igb_fw_version_get(struct rte_eth_dev *dev,
+				   char *fw_version, size_t fw_size);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static const uint32_t *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -391,6 +393,7 @@ static const struct eth_dev_ops eth_igb_ops = {
 	.xstats_get_names     = eth_igb_xstats_get_names,
 	.stats_reset          = eth_igb_stats_reset,
 	.xstats_reset         = eth_igb_xstats_reset,
+	.fw_version_get       = eth_igb_fw_version_get,
 	.dev_infos_get        = eth_igb_infos_get,
 	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
 	.mtu_set              = eth_igb_mtu_set,
@@ -1984,6 +1987,57 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
 	       offsetof(struct e1000_vf_stats, gprc));
 }
 
+static int
+eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+		       size_t fw_size)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_fw_version fw;
+
+	if (fw_size < 16) {
+		PMD_DRV_LOG(WARNING, "Insufficient fw version buffer size");
+		return -EINVAL;
+	}
+
+	e1000_get_fw_version(hw, &fw);
+
+	switch (hw->mac.type) {
+	case e1000_i210:
+	case e1000_i211:
+		if (!(e1000_get_flash_presence_i210(hw))) {
+			snprintf(fw_version, fw_size,
+				 "%2d.%2d-%d",
+				 fw.invm_major, fw.invm_minor,
+				 fw.invm_img_type);
+			break;
+		}
+		/* fall through */
+	default:
+		/* if option rom is valid, display its version too*/
+		if (fw.or_valid) {
+			snprintf(fw_version, fw_size,
+				 "%d.%d, 0x%08x, %d.%d.%d",
+				 fw.eep_major, fw.eep_minor, fw.etrack_id,
+				 fw.or_major, fw.or_build, fw.or_patch);
+		/* no option rom */
+		} else {
+			if (fw.etrack_id != 0X0000) {
+				snprintf(fw_version, fw_size,
+					 "%d.%d, 0x%08x",
+					 fw.eep_major, fw.eep_minor,
+					 fw.etrack_id);
+			} else {
+				snprintf(fw_version, fw_size,
+					 "%d.%d.%d",
+					 fw.eep_major, fw.eep_minor,
+					 fw.eep_build);
+			}
+		}
+		break;
+	}
+	return 0;
+}
+
 static void
 eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [DPDK 3/5] net/ixgbe: add firmware version get
  2017-01-10  9:00           ` [dpdk-dev] [DPDK 1/5] ethdev: add firmware version get Qiming Yang
  2017-01-10  9:00             ` [dpdk-dev] [DPDK 2/5] net/e1000: " Qiming Yang
@ 2017-01-10  9:00             ` Qiming Yang
  1 sibling, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-10  9:00 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, ferruh.yigit, helin.zhang, Qiming Yang

This patch adds a new function ixgbe_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/ixgbe.ini |  1 +
 drivers/net/ixgbe/ixgbe_ethdev.c   | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/doc/guides/nics/features/ixgbe.ini b/doc/guides/nics/features/ixgbe.ini
index 4a5667f..e7104c2 100644
--- a/doc/guides/nics/features/ixgbe.ini
+++ b/doc/guides/nics/features/ixgbe.ini
@@ -43,6 +43,7 @@ Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 Multiprocess aware   = Y
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 060772d..a638936 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -193,6 +193,8 @@ static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint16_t queue_id,
 					     uint8_t stat_idx,
 					     uint8_t is_rx);
+static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+				 size_t fw_size);
 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
 			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -540,6 +542,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.xstats_reset         = ixgbe_dev_xstats_reset,
 	.xstats_get_names     = ixgbe_dev_xstats_get_names,
 	.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
+	.fw_version_get       = ixgbe_fw_version_get,
 	.dev_infos_get        = ixgbe_dev_info_get,
 	.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
 	.mtu_set              = ixgbe_dev_mtu_set,
@@ -3034,6 +3037,28 @@ ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
 	hw_stats->vfgotc = 0;
 }
 
+static int
+ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u16 eeprom_verh, eeprom_verl;
+	u32 etrack_id;
+
+	if (fw_size < 11) {
+		PMD_DRV_LOG(WARNING, "Insufficient fw version buffer size");
+		return -EINVAL;
+	}
+
+	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
+	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
+
+	etrack_id = (eeprom_verh << 16) | eeprom_verl;
+	snprintf(fw_version, fw_size,
+		 "0x%08x", etrack_id);
+
+	return 0;
+}
+
 static void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v6 0/5] new API 'rte_eth_dev_fw_version_get'
  2017-01-08  4:11         ` [dpdk-dev] [PATCH v5 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                             ` (5 preceding siblings ...)
  2017-01-10  9:00           ` [dpdk-dev] [DPDK 1/5] ethdev: add firmware version get Qiming Yang
@ 2017-01-10  9:08           ` Qiming Yang
  2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 1/5] ethdev: add firmware version get Qiming Yang
                               ` (4 more replies)
  6 siblings, 5 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-10  9:08 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, ferruh.yigit, helin.zhang, Qiming Yang

v6: - renamed fw_length -> fw_size
    - added return value for insufficient fw_size
    - fixed the indentation problem in e1000
    - added ver.build.patch in i40e, keep the same with Linux kernel driver

v5: - modified the API rte_eth_dev_fw_version_get(uint8_t port_id,
      char *fw_version, int fw_length).

v4: - removed deprecation notice
    - renamed API as rte_eth_dev_fw_version_get
    - splited bus info print from this patch set

v3: - changed API, use rte_eth_dev_fw_info_get(uint8_t port_id,
      uint32_t *fw_major, uint32_t *fw_minor, uint32_t *fw_patch,
      uint32_t *etrack_id)
    - added statusment in /doc/guides/nics/features/default.ini and
      release_17_02.rst

v2: - fixed commit log

Now, the example ethtool can only show the driver information. From
customers' point of view, it should be better if we can have the same
way that the Linux kernel ethtool does to show firmware version.

These five patches added a new function ``rte_eth_dev_fw_version_get()``
to fetch firmware version related information and implement the
display in example ethtool.

Qiming Yang (5):
  ethdev: add firmware version get
  net/e1000: add firmware version get
  net/ixgbe: add firmware version get
  net/i40e: add firmware version get
  ethtool: display firmware version

 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/nics/features/i40e.ini      |  1 +
 doc/guides/nics/features/igb.ini       |  1 +
 doc/guides/nics/features/ixgbe.ini     |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ---
 doc/guides/rel_notes/release_17_02.rst |  3 ++
 drivers/net/e1000/igb_ethdev.c         | 54 ++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.c         | 31 +++++++++++++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c       | 25 ++++++++++++++++
 examples/ethtool/ethtool-app/ethapp.c  |  1 +
 examples/ethtool/lib/rte_ethtool.c     |  6 ++++
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++
 lib/librte_ether/rte_ethdev.h          | 25 ++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 14 files changed, 162 insertions(+), 4 deletions(-)

-- 
2.7.4

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

* [dpdk-dev] [PATCH v6 1/5] ethdev: add firmware version get
  2017-01-10  9:08           ` [dpdk-dev] [PATCH v6 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
@ 2017-01-10  9:08             ` Qiming Yang
  2017-01-11  6:41               ` [dpdk-dev] [PATCH v7 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 2/5] net/e1000: add firmware version get Qiming Yang
                               ` (3 subsequent siblings)
  4 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2017-01-10  9:08 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, ferruh.yigit, helin.zhang, Qiming Yang

This patch adds a new API 'rte_eth_dev_fw_version_get' for
fetching firmware version by a given device.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ----
 doc/guides/rel_notes/release_17_02.rst |  3 +++
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++++++
 lib/librte_ether/rte_ethdev.h          | 25 +++++++++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 6 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
index f1bf9bf..ae40d57 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -50,6 +50,7 @@ Timesync             =
 Basic stats          =
 Extended stats       =
 Stats per queue      =
+FW version           =
 EEPROM dump          =
 Registers dump       =
 Multiprocess aware   =
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 1438c77..291e03d 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -30,10 +30,6 @@ Deprecation Notices
   ``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
   segments limit to be transmitted by device for TSO/non-TSO packets.
 
-* In 17.02 ABI change is planned: the ``rte_eth_dev_info`` structure
-  will be extended with a new member ``fw_version`` in order to store
-  the NIC firmware version.
-
 * ethdev: an API change is planned for 17.02 for the function
   ``_rte_eth_dev_callback_process``. In 17.02 the function will return an ``int``
   instead of ``void`` and a fourth parameter ``void *ret_param`` will be added.
diff --git a/doc/guides/rel_notes/release_17_02.rst b/doc/guides/rel_notes/release_17_02.rst
index 180af82..260033d 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,9 @@ New Features
   See the :ref:`Generic flow API <Generic_flow_API>` documentation for more
   information.
 
+* **Added firmware version get API.**
+ Added a new function ``rte_eth_dev_fw_version_get()`` to fetch firmware
+ version by a given device.
 
 Resolved Issues
 ---------------
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 9dea1f1..49ca42d 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1588,6 +1588,18 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
 			STAT_QMAP_RX);
 }
 
+int
+rte_eth_dev_fw_version_get(uint8_t port_id, char *fw_version, size_t fw_size)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fw_version_get, -ENOTSUP);
+	return (*dev->dev_ops->fw_version_get)(dev, fw_version, fw_size);
+}
+
 void
 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 1c356c1..357612d 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1177,6 +1177,10 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
 /**< @internal Check DD bit of specific RX descriptor */
 
+typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
+				     char *fw_version, size_t fw_size);
+/**< @internal Get firmware information of an Ethernet device. */
+
 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
 	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
 
@@ -1487,6 +1491,7 @@ struct eth_dev_ops {
 	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
 	eth_rxq_info_get_t         rxq_info_get; /**< retrieve RX queue information. */
 	eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
+	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
 	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
 	/**< Get packet types supported and identified by device. */
 
@@ -2430,6 +2435,26 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
 void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
 
 /**
+ * Retrieve the firmware version of a device.
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param fw_version
+ *   A array pointer to store the firmware version of a device,
+ *   allocated by caller.
+ * @param fw_size
+ *   The size of the array pointed by fw_version, which should be
+ *   large enough to store firmware version of the device.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if operation is not supported.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EINVAL) if *fw_size* is not enough to store firmware version.
+ */
+int rte_eth_dev_fw_version_get(uint8_t port_id,
+			       char *fw_version, size_t fw_size);
+
+/**
  * Retrieve the supported packet types of an Ethernet device.
  *
  * When a packet type is announced as supported, it *must* be recognized by
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index a021781..0cf94ed 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -151,6 +151,7 @@ DPDK_17.02 {
 	global:
 
 	_rte_eth_dev_reset;
+	rte_eth_dev_fw_version_get;
 	rte_flow_create;
 	rte_flow_destroy;
 	rte_flow_flush;
-- 
2.7.4

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

* [dpdk-dev] [PATCH v6 2/5] net/e1000: add firmware version get
  2017-01-10  9:08           ` [dpdk-dev] [PATCH v6 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 1/5] ethdev: add firmware version get Qiming Yang
@ 2017-01-10  9:08             ` Qiming Yang
  2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 3/5] net/ixgbe: " Qiming Yang
                               ` (2 subsequent siblings)
  4 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-10  9:08 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, ferruh.yigit, helin.zhang, Qiming Yang

This patch adds a new function eth_igb_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/igb.ini |  1 +
 drivers/net/e1000/igb_ethdev.c   | 54 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/doc/guides/nics/features/igb.ini b/doc/guides/nics/features/igb.ini
index 9fafe72..26ae008 100644
--- a/doc/guides/nics/features/igb.ini
+++ b/doc/guides/nics/features/igb.ini
@@ -35,6 +35,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 BSD nic_uio          = Y
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 2bb57f5..10519ad 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -120,6 +120,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
 				    unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
+static int eth_igb_fw_version_get(struct rte_eth_dev *dev,
+				   char *fw_version, size_t fw_size);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static const uint32_t *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -391,6 +393,7 @@ static const struct eth_dev_ops eth_igb_ops = {
 	.xstats_get_names     = eth_igb_xstats_get_names,
 	.stats_reset          = eth_igb_stats_reset,
 	.xstats_reset         = eth_igb_xstats_reset,
+	.fw_version_get       = eth_igb_fw_version_get,
 	.dev_infos_get        = eth_igb_infos_get,
 	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
 	.mtu_set              = eth_igb_mtu_set,
@@ -1984,6 +1987,57 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
 	       offsetof(struct e1000_vf_stats, gprc));
 }
 
+static int
+eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+		       size_t fw_size)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_fw_version fw;
+
+	if (fw_size < 16) {
+		PMD_DRV_LOG(WARNING, "Insufficient fw version buffer size");
+		return -EINVAL;
+	}
+
+	e1000_get_fw_version(hw, &fw);
+
+	switch (hw->mac.type) {
+	case e1000_i210:
+	case e1000_i211:
+		if (!(e1000_get_flash_presence_i210(hw))) {
+			snprintf(fw_version, fw_size,
+				 "%2d.%2d-%d",
+				 fw.invm_major, fw.invm_minor,
+				 fw.invm_img_type);
+			break;
+		}
+		/* fall through */
+	default:
+		/* if option rom is valid, display its version too*/
+		if (fw.or_valid) {
+			snprintf(fw_version, fw_size,
+				 "%d.%d, 0x%08x, %d.%d.%d",
+				 fw.eep_major, fw.eep_minor, fw.etrack_id,
+				 fw.or_major, fw.or_build, fw.or_patch);
+		/* no option rom */
+		} else {
+			if (fw.etrack_id != 0X0000) {
+				snprintf(fw_version, fw_size,
+					 "%d.%d, 0x%08x",
+					 fw.eep_major, fw.eep_minor,
+					 fw.etrack_id);
+			} else {
+				snprintf(fw_version, fw_size,
+					 "%d.%d.%d",
+					 fw.eep_major, fw.eep_minor,
+					 fw.eep_build);
+			}
+		}
+		break;
+	}
+	return 0;
+}
+
 static void
 eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v6 3/5] net/ixgbe: add firmware version get
  2017-01-10  9:08           ` [dpdk-dev] [PATCH v6 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 1/5] ethdev: add firmware version get Qiming Yang
  2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 2/5] net/e1000: add firmware version get Qiming Yang
@ 2017-01-10  9:08             ` Qiming Yang
  2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 4/5] net/i40e: " Qiming Yang
  2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 5/5] ethtool: display firmware version Qiming Yang
  4 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-10  9:08 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, ferruh.yigit, helin.zhang, Qiming Yang

This patch adds a new function ixgbe_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/ixgbe.ini |  1 +
 drivers/net/ixgbe/ixgbe_ethdev.c   | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/doc/guides/nics/features/ixgbe.ini b/doc/guides/nics/features/ixgbe.ini
index 4a5667f..e7104c2 100644
--- a/doc/guides/nics/features/ixgbe.ini
+++ b/doc/guides/nics/features/ixgbe.ini
@@ -43,6 +43,7 @@ Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 Multiprocess aware   = Y
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 060772d..a638936 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -193,6 +193,8 @@ static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint16_t queue_id,
 					     uint8_t stat_idx,
 					     uint8_t is_rx);
+static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+				 size_t fw_size);
 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
 			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -540,6 +542,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.xstats_reset         = ixgbe_dev_xstats_reset,
 	.xstats_get_names     = ixgbe_dev_xstats_get_names,
 	.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
+	.fw_version_get       = ixgbe_fw_version_get,
 	.dev_infos_get        = ixgbe_dev_info_get,
 	.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
 	.mtu_set              = ixgbe_dev_mtu_set,
@@ -3034,6 +3037,28 @@ ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
 	hw_stats->vfgotc = 0;
 }
 
+static int
+ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u16 eeprom_verh, eeprom_verl;
+	u32 etrack_id;
+
+	if (fw_size < 11) {
+		PMD_DRV_LOG(WARNING, "Insufficient fw version buffer size");
+		return -EINVAL;
+	}
+
+	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
+	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
+
+	etrack_id = (eeprom_verh << 16) | eeprom_verl;
+	snprintf(fw_version, fw_size,
+		 "0x%08x", etrack_id);
+
+	return 0;
+}
+
 static void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v6 4/5] net/i40e: add firmware version get
  2017-01-10  9:08           ` [dpdk-dev] [PATCH v6 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                               ` (2 preceding siblings ...)
  2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 3/5] net/ixgbe: " Qiming Yang
@ 2017-01-10  9:08             ` Qiming Yang
  2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 5/5] ethtool: display firmware version Qiming Yang
  4 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-10  9:08 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, ferruh.yigit, helin.zhang, Qiming Yang

This patch add a new function i40e_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/i40e.ini |  1 +
 drivers/net/i40e/i40e_ethdev.c    | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/doc/guides/nics/features/i40e.ini b/doc/guides/nics/features/i40e.ini
index 0d143bc..0dbc3c3 100644
--- a/doc/guides/nics/features/i40e.ini
+++ b/doc/guides/nics/features/i40e.ini
@@ -39,6 +39,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 Multiprocess aware   = Y
 BSD nic_uio          = Y
 Linux UIO            = Y
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 0eb4c99..3bf92d1 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -324,6 +324,8 @@ static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
 					    uint16_t queue_id,
 					    uint8_t stat_idx,
 					    uint8_t is_rx);
+static int i40e_fw_version_get(struct rte_eth_dev *dev,
+				char *fw_version, size_t fw_size);
 static void i40e_dev_info_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static int i40e_vlan_filter_set(struct rte_eth_dev *dev,
@@ -503,6 +505,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.stats_reset                  = i40e_dev_stats_reset,
 	.xstats_reset                 = i40e_dev_stats_reset,
 	.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
+	.fw_version_get               = i40e_fw_version_get,
 	.dev_infos_get                = i40e_dev_info_get,
 	.dev_supported_ptypes_get     = i40e_dev_supported_ptypes_get,
 	.vlan_filter_set              = i40e_vlan_filter_set,
@@ -2594,6 +2597,34 @@ i40e_dev_queue_stats_mapping_set(__rte_unused struct rte_eth_dev *dev,
 	return -ENOSYS;
 }
 
+static int
+i40e_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u32 full_ver;
+	u8 ver, patch;
+	u16 build;
+
+	if (fw_size < 16) {
+		PMD_DRV_LOG(WARNING, "Insufficient fw version buffer size");
+		return -EINVAL;
+	}
+
+	full_ver = hw->nvm.oem_ver;
+	ver = (u8)(full_ver >> 24);
+	build = (u16)((full_ver >> 8) & 0xffff);
+	patch = (u8)(full_ver & 0xff);
+
+	snprintf(fw_version, fw_size,
+		 "%d.%d%d 0x%08x %d.%d.%d",
+		 ((hw->nvm.version >> 12) & 0xf),
+		 ((hw->nvm.version >> 4) & 0xff),
+		 (hw->nvm.version & 0xf), hw->nvm.eetrack,
+		 ver, build, patch);
+
+	return 0;
+}
+
 static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v6 5/5] ethtool: display firmware version
  2017-01-10  9:08           ` [dpdk-dev] [PATCH v6 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                               ` (3 preceding siblings ...)
  2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 4/5] net/i40e: " Qiming Yang
@ 2017-01-10  9:08             ` Qiming Yang
  4 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-10  9:08 UTC (permalink / raw)
  To: dev; +Cc: remy.horton, ferruh.yigit, helin.zhang, Qiming Yang

This patch enhances the ethtool example to support to show
firmware version, in the same way that the Linux kernel
ethtool does.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 examples/ethtool/ethtool-app/ethapp.c | 1 +
 examples/ethtool/lib/rte_ethtool.c    | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
index 6aeaa06..85c31ac 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -185,6 +185,7 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
 		printf("Port %i driver: %s (ver: %s)\n",
 			id_port, info.driver, info.version
 		      );
+		printf("firmware-version: %s\n", info.fw_version);
 	}
 }
 
diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index 6f0ce84..ec7a143 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -48,12 +48,18 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 	struct rte_eth_dev_info dev_info;
 	struct rte_dev_reg_info reg_info;
 	int n;
+	int ret;
 
 	if (drvinfo == NULL)
 		return -EINVAL;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
+	ret = rte_eth_dev_fw_version_get(port_id, drvinfo->fw_version,
+			      sizeof(drvinfo->fw_version));
+	if (ret != 0)
+		printf("firmware version get error: (%s)\n", strerror(-ret));
+
 	memset(&dev_info, 0, sizeof(dev_info));
 	rte_eth_dev_info_get(port_id, &dev_info);
 
-- 
2.7.4

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

* [dpdk-dev] [PATCH v7 0/5] new API 'rte_eth_dev_fw_version_get'
  2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 1/5] ethdev: add firmware version get Qiming Yang
@ 2017-01-11  6:41               ` Qiming Yang
  2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 1/5] ethdev: add firmware version get Qiming Yang
                                   ` (5 more replies)
  0 siblings, 6 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-11  6:41 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, remy.horton, Qiming Yang

v7: - rebased

v6: - renamed fw_length -> fw_size
    - added return value for insufficient fw_size
    - fixed the indentation problem in e1000
    - added ver.build.patch in i40e, keep the same with Linux kernel driver

v5: - modified the API rte_eth_dev_fw_version_get(uint8_t port_id,
      char *fw_version, int fw_length).

v4: - removed deprecation notice
    - renamed API as rte_eth_dev_fw_version_get
    - splited bus info print from this patch set

v3: - changed API, use rte_eth_dev_fw_info_get(uint8_t port_id,
      uint32_t *fw_major, uint32_t *fw_minor, uint32_t *fw_patch,
      uint32_t *etrack_id)
    - added statusment in /doc/guides/nics/features/default.ini and
      release_17_02.rst

v2: - fixed commit log

Now, the example ethtool can only show the driver information. From
customers' point of view, it should be better if we can have the same
way that the Linux kernel ethtool does to show firmware version.

These five patches added a new function ``rte_eth_dev_fw_version_get()``
to fetch firmware version related information and implement the
display in example ethtool.

Qiming Yang (5):
  ethdev: add firmware version get
  net/e1000: add firmware version get
  net/ixgbe: add firmware version get
  net/i40e: add firmware version get
  ethtool: display firmware version

 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/nics/features/i40e.ini      |  1 +
 doc/guides/nics/features/igb.ini       |  1 +
 doc/guides/nics/features/ixgbe.ini     |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ---
 doc/guides/rel_notes/release_17_02.rst |  5 ++++
 drivers/net/e1000/igb_ethdev.c         | 54 ++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.c         | 31 +++++++++++++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c       | 25 ++++++++++++++++
 examples/ethtool/ethtool-app/ethapp.c  |  1 +
 examples/ethtool/lib/rte_ethtool.c     |  6 ++++
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++
 lib/librte_ether/rte_ethdev.h          | 25 ++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 14 files changed, 164 insertions(+), 4 deletions(-)

-- 
2.7.4

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

* [dpdk-dev] [PATCH v7 1/5] ethdev: add firmware version get
  2017-01-11  6:41               ` [dpdk-dev] [PATCH v7 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
@ 2017-01-11  6:41                 ` Qiming Yang
  2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 2/5] net/e1000: " Qiming Yang
                                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-11  6:41 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, remy.horton, Qiming Yang

This patch adds a new API 'rte_eth_dev_fw_version_get' for
fetching firmware version by a given device.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ----
 doc/guides/rel_notes/release_17_02.rst |  5 +++++
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++++++
 lib/librte_ether/rte_ethdev.h          | 25 +++++++++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 6 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
index f1bf9bf..ae40d57 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -50,6 +50,7 @@ Timesync             =
 Basic stats          =
 Extended stats       =
 Stats per queue      =
+FW version           =
 EEPROM dump          =
 Registers dump       =
 Multiprocess aware   =
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 054e2e7..755dc65 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -30,10 +30,6 @@ Deprecation Notices
   ``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
   segments limit to be transmitted by device for TSO/non-TSO packets.
 
-* In 17.02 ABI change is planned: the ``rte_eth_dev_info`` structure
-  will be extended with a new member ``fw_version`` in order to store
-  the NIC firmware version.
-
 * ethdev: an API change is planned for 17.02 for the function
   ``_rte_eth_dev_callback_process``. In 17.02 the function will return an ``int``
   instead of ``void`` and a fourth parameter ``void *ret_param`` will be added.
diff --git a/doc/guides/rel_notes/release_17_02.rst b/doc/guides/rel_notes/release_17_02.rst
index 5762d3f..f9134bb 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -66,6 +66,11 @@ New Features
   Support for Mellanox ConnectX-5 family of 10/25/40/50/100 Gbps adapters
   has been added to the existing mlx5 PMD.
 
+* **Added firmware version get API.**
+
+  Added a new function ``rte_eth_dev_fw_version_get()`` to fetch firmware
+  version by a given device.
+
 Resolved Issues
 ---------------
 
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 917557a..89cffcf 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1588,6 +1588,18 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
 			STAT_QMAP_RX);
 }
 
+int
+rte_eth_dev_fw_version_get(uint8_t port_id, char *fw_version, size_t fw_size)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fw_version_get, -ENOTSUP);
+	return (*dev->dev_ops->fw_version_get)(dev, fw_version, fw_size);
+}
+
 void
 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index ded43d7..a9b3686 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1177,6 +1177,10 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
 /**< @internal Check DD bit of specific RX descriptor */
 
+typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
+				     char *fw_version, size_t fw_size);
+/**< @internal Get firmware information of an Ethernet device. */
+
 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
 	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
 
@@ -1459,6 +1463,7 @@ struct eth_dev_ops {
 	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
 	eth_rxq_info_get_t         rxq_info_get; /**< retrieve RX queue information. */
 	eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
+	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
 	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
 	/**< Get packet types supported and identified by device. */
 
@@ -2396,6 +2401,26 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
 void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
 
 /**
+ * Retrieve the firmware version of a device.
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param fw_version
+ *   A array pointer to store the firmware version of a device,
+ *   allocated by caller.
+ * @param fw_size
+ *   The size of the array pointed by fw_version, which should be
+ *   large enough to store firmware version of the device.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if operation is not supported.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EINVAL) if *fw_size* is not enough to store firmware version.
+ */
+int rte_eth_dev_fw_version_get(uint8_t port_id,
+			       char *fw_version, size_t fw_size);
+
+/**
  * Retrieve the supported packet types of an Ethernet device.
  *
  * When a packet type is announced as supported, it *must* be recognized by
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index 0c2859e..c6c9d0d 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -146,6 +146,7 @@ DPDK_17.02 {
 	global:
 
 	_rte_eth_dev_reset;
+	rte_eth_dev_fw_version_get;
 	rte_flow_create;
 	rte_flow_destroy;
 	rte_flow_flush;
-- 
2.7.4

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

* [dpdk-dev] [PATCH v7 2/5] net/e1000: add firmware version get
  2017-01-11  6:41               ` [dpdk-dev] [PATCH v7 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 1/5] ethdev: add firmware version get Qiming Yang
@ 2017-01-11  6:41                 ` Qiming Yang
  2017-01-11 15:45                   ` Remy Horton
  2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 3/5] net/ixgbe: " Qiming Yang
                                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2017-01-11  6:41 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, remy.horton, Qiming Yang

This patch adds a new function eth_igb_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/igb.ini |  1 +
 drivers/net/e1000/igb_ethdev.c   | 54 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/doc/guides/nics/features/igb.ini b/doc/guides/nics/features/igb.ini
index 9fafe72..26ae008 100644
--- a/doc/guides/nics/features/igb.ini
+++ b/doc/guides/nics/features/igb.ini
@@ -35,6 +35,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 BSD nic_uio          = Y
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 2bb57f5..10519ad 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -120,6 +120,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
 				    unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
+static int eth_igb_fw_version_get(struct rte_eth_dev *dev,
+				   char *fw_version, size_t fw_size);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static const uint32_t *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -391,6 +393,7 @@ static const struct eth_dev_ops eth_igb_ops = {
 	.xstats_get_names     = eth_igb_xstats_get_names,
 	.stats_reset          = eth_igb_stats_reset,
 	.xstats_reset         = eth_igb_xstats_reset,
+	.fw_version_get       = eth_igb_fw_version_get,
 	.dev_infos_get        = eth_igb_infos_get,
 	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
 	.mtu_set              = eth_igb_mtu_set,
@@ -1984,6 +1987,57 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
 	       offsetof(struct e1000_vf_stats, gprc));
 }
 
+static int
+eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+		       size_t fw_size)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_fw_version fw;
+
+	if (fw_size < 16) {
+		PMD_DRV_LOG(WARNING, "Insufficient fw version buffer size");
+		return -EINVAL;
+	}
+
+	e1000_get_fw_version(hw, &fw);
+
+	switch (hw->mac.type) {
+	case e1000_i210:
+	case e1000_i211:
+		if (!(e1000_get_flash_presence_i210(hw))) {
+			snprintf(fw_version, fw_size,
+				 "%2d.%2d-%d",
+				 fw.invm_major, fw.invm_minor,
+				 fw.invm_img_type);
+			break;
+		}
+		/* fall through */
+	default:
+		/* if option rom is valid, display its version too*/
+		if (fw.or_valid) {
+			snprintf(fw_version, fw_size,
+				 "%d.%d, 0x%08x, %d.%d.%d",
+				 fw.eep_major, fw.eep_minor, fw.etrack_id,
+				 fw.or_major, fw.or_build, fw.or_patch);
+		/* no option rom */
+		} else {
+			if (fw.etrack_id != 0X0000) {
+				snprintf(fw_version, fw_size,
+					 "%d.%d, 0x%08x",
+					 fw.eep_major, fw.eep_minor,
+					 fw.etrack_id);
+			} else {
+				snprintf(fw_version, fw_size,
+					 "%d.%d.%d",
+					 fw.eep_major, fw.eep_minor,
+					 fw.eep_build);
+			}
+		}
+		break;
+	}
+	return 0;
+}
+
 static void
 eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v7 3/5] net/ixgbe: add firmware version get
  2017-01-11  6:41               ` [dpdk-dev] [PATCH v7 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 1/5] ethdev: add firmware version get Qiming Yang
  2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 2/5] net/e1000: " Qiming Yang
@ 2017-01-11  6:41                 ` Qiming Yang
  2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 4/5] net/i40e: " Qiming Yang
                                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-11  6:41 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, remy.horton, Qiming Yang

This patch adds a new function ixgbe_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/ixgbe.ini |  1 +
 drivers/net/ixgbe/ixgbe_ethdev.c   | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/doc/guides/nics/features/ixgbe.ini b/doc/guides/nics/features/ixgbe.ini
index 4a5667f..e7104c2 100644
--- a/doc/guides/nics/features/ixgbe.ini
+++ b/doc/guides/nics/features/ixgbe.ini
@@ -43,6 +43,7 @@ Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 Multiprocess aware   = Y
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index b7ddd4f..a09db78 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -193,6 +193,8 @@ static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint16_t queue_id,
 					     uint8_t stat_idx,
 					     uint8_t is_rx);
+static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+				 size_t fw_size);
 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
 			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -532,6 +534,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.xstats_reset         = ixgbe_dev_xstats_reset,
 	.xstats_get_names     = ixgbe_dev_xstats_get_names,
 	.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
+	.fw_version_get       = ixgbe_fw_version_get,
 	.dev_infos_get        = ixgbe_dev_info_get,
 	.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
 	.mtu_set              = ixgbe_dev_mtu_set,
@@ -3022,6 +3025,28 @@ ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
 	hw_stats->vfgotc = 0;
 }
 
+static int
+ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u16 eeprom_verh, eeprom_verl;
+	u32 etrack_id;
+
+	if (fw_size < 11) {
+		PMD_DRV_LOG(WARNING, "Insufficient fw version buffer size");
+		return -EINVAL;
+	}
+
+	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
+	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
+
+	etrack_id = (eeprom_verh << 16) | eeprom_verl;
+	snprintf(fw_version, fw_size,
+		 "0x%08x", etrack_id);
+
+	return 0;
+}
+
 static void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v7 4/5] net/i40e: add firmware version get
  2017-01-11  6:41               ` [dpdk-dev] [PATCH v7 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                                   ` (2 preceding siblings ...)
  2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 3/5] net/ixgbe: " Qiming Yang
@ 2017-01-11  6:41                 ` Qiming Yang
  2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 5/5] ethtool: display firmware version Qiming Yang
  2017-01-12  6:31                 ` [dpdk-dev] [PATCH v8 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  5 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-11  6:41 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, remy.horton, Qiming Yang

This patch add a new function i40e_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/i40e.ini |  1 +
 drivers/net/i40e/i40e_ethdev.c    | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/doc/guides/nics/features/i40e.ini b/doc/guides/nics/features/i40e.ini
index 0d143bc..0dbc3c3 100644
--- a/doc/guides/nics/features/i40e.ini
+++ b/doc/guides/nics/features/i40e.ini
@@ -39,6 +39,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 Multiprocess aware   = Y
 BSD nic_uio          = Y
 Linux UIO            = Y
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 46def56..713f653 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -266,6 +266,8 @@ static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
 					    uint16_t queue_id,
 					    uint8_t stat_idx,
 					    uint8_t is_rx);
+static int i40e_fw_version_get(struct rte_eth_dev *dev,
+				char *fw_version, size_t fw_size);
 static void i40e_dev_info_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static int i40e_vlan_filter_set(struct rte_eth_dev *dev,
@@ -458,6 +460,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.stats_reset                  = i40e_dev_stats_reset,
 	.xstats_reset                 = i40e_dev_stats_reset,
 	.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
+	.fw_version_get               = i40e_fw_version_get,
 	.dev_infos_get                = i40e_dev_info_get,
 	.dev_supported_ptypes_get     = i40e_dev_supported_ptypes_get,
 	.vlan_filter_set              = i40e_vlan_filter_set,
@@ -2770,6 +2773,34 @@ i40e_dev_queue_stats_mapping_set(__rte_unused struct rte_eth_dev *dev,
 	return -ENOSYS;
 }
 
+static int
+i40e_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u32 full_ver;
+	u8 ver, patch;
+	u16 build;
+
+	if (fw_size < 16) {
+		PMD_DRV_LOG(WARNING, "Insufficient fw version buffer size");
+		return -EINVAL;
+	}
+
+	full_ver = hw->nvm.oem_ver;
+	ver = (u8)(full_ver >> 24);
+	build = (u16)((full_ver >> 8) & 0xffff);
+	patch = (u8)(full_ver & 0xff);
+
+	snprintf(fw_version, fw_size,
+		 "%d.%d%d 0x%08x %d.%d.%d",
+		 ((hw->nvm.version >> 12) & 0xf),
+		 ((hw->nvm.version >> 4) & 0xff),
+		 (hw->nvm.version & 0xf), hw->nvm.eetrack,
+		 ver, build, patch);
+
+	return 0;
+}
+
 static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v7 5/5] ethtool: display firmware version
  2017-01-11  6:41               ` [dpdk-dev] [PATCH v7 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                                   ` (3 preceding siblings ...)
  2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 4/5] net/i40e: " Qiming Yang
@ 2017-01-11  6:41                 ` Qiming Yang
  2017-01-12  6:31                 ` [dpdk-dev] [PATCH v8 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  5 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-11  6:41 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, remy.horton, Qiming Yang

This patch enhances the ethtool example to support to show
firmware version, in the same way that the Linux kernel
ethtool does.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 examples/ethtool/ethtool-app/ethapp.c | 1 +
 examples/ethtool/lib/rte_ethtool.c    | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
index 6aeaa06..85c31ac 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -185,6 +185,7 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
 		printf("Port %i driver: %s (ver: %s)\n",
 			id_port, info.driver, info.version
 		      );
+		printf("firmware-version: %s\n", info.fw_version);
 	}
 }
 
diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index b1f159e..33d38a7 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -51,12 +51,18 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 	struct rte_eth_dev_info dev_info;
 	struct rte_dev_reg_info reg_info;
 	int n;
+	int ret;
 
 	if (drvinfo == NULL)
 		return -EINVAL;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
+	ret = rte_eth_dev_fw_version_get(port_id, drvinfo->fw_version,
+			      sizeof(drvinfo->fw_version));
+	if (ret != 0)
+		printf("firmware version get error: (%s)\n", strerror(-ret));
+
 	memset(&dev_info, 0, sizeof(dev_info));
 	rte_eth_dev_info_get(port_id, &dev_info);
 
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH v7 2/5] net/e1000: add firmware version get
  2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 2/5] net/e1000: " Qiming Yang
@ 2017-01-11 15:45                   ` Remy Horton
  2017-01-12  1:25                     ` Yang, Qiming
  0 siblings, 1 reply; 128+ messages in thread
From: Remy Horton @ 2017-01-11 15:45 UTC (permalink / raw)
  To: Qiming Yang, dev; +Cc: ferruh.yigit


On 11/01/2017 06:41, Qiming Yang wrote:
> This patch adds a new function eth_igb_fw_version_get.
>
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
[..]
> +static int
> +eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
> +		       size_t fw_size)
> +{
> +	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	struct e1000_fw_version fw;
> +
> +	if (fw_size < 16) {

Magic number. Ought to be #define value (or at least a comment 
explaining the choice of size)..

Otherwise looking good.. :)

..Remy

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

* Re: [dpdk-dev] [PATCH v7 2/5] net/e1000: add firmware version get
  2017-01-11 15:45                   ` Remy Horton
@ 2017-01-12  1:25                     ` Yang, Qiming
  0 siblings, 0 replies; 128+ messages in thread
From: Yang, Qiming @ 2017-01-12  1:25 UTC (permalink / raw)
  To: Horton, Remy, dev; +Cc: Yigit, Ferruh

-----Original Message-----
From: Horton, Remy 
Sent: Wednesday, January 11, 2017 11:45 PM
To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org
Cc: Yigit, Ferruh <ferruh.yigit@intel.com>
Subject: Re: [PATCH v7 2/5] net/e1000: add firmware version get


On 11/01/2017 06:41, Qiming Yang wrote:
> This patch adds a new function eth_igb_fw_version_get.
>
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
[..]
> +static int
> +eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
> +		       size_t fw_size)
> +{
> +	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	struct e1000_fw_version fw;
> +
> +	if (fw_size < 16) {

Magic number. Ought to be #define value (or at least a comment explaining the choice of size)..

Otherwise looking good.. :)

..Remy

Ok, I'll use a macro to define this number. Thanks~
Qiming 

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

* [dpdk-dev] [PATCH v8 0/5] new API 'rte_eth_dev_fw_version_get'
  2017-01-11  6:41               ` [dpdk-dev] [PATCH v7 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                                   ` (4 preceding siblings ...)
  2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 5/5] ethtool: display firmware version Qiming Yang
@ 2017-01-12  6:31                 ` Qiming Yang
  2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 1/5] ethdev: add firmware version get Qiming Yang
                                     ` (4 more replies)
  5 siblings, 5 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-12  6:31 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: remy.horton, Qiming Yang

v8: - defined the minimum fw version size as a macro.

v7: - rebased

v6: - renamed fw_length -> fw_size
    - added return value for insufficient fw_size
    - fixed the indentation problem in e1000
    - added ver.build.patch in i40e, keep the same with Linux kernel driver

v5: - modified the API rte_eth_dev_fw_version_get(uint8_t port_id,
      char *fw_version, int fw_length).

v4: - removed deprecation notice
    - renamed API as rte_eth_dev_fw_version_get
    - splited bus info print from this patch set

v3: - changed API, use rte_eth_dev_fw_info_get(uint8_t port_id,
      uint32_t *fw_major, uint32_t *fw_minor, uint32_t *fw_patch,
      uint32_t *etrack_id)
    - added statusment in /doc/guides/nics/features/default.ini and
      release_17_02.rst

v2: - fixed commit log

Now, the example ethtool can only show the driver information. From
customers' point of view, it should be better if we can have the same
way that the Linux kernel ethtool does to show firmware version.

These five patches added a new function ``rte_eth_dev_fw_version_get()``
to fetch firmware version related information and implement the
display in example ethtool.

Qiming Yang (5):
  ethdev: add firmware version get
  net/e1000: add firmware version get
  net/ixgbe: add firmware version get
  net/i40e: add firmware version get
  ethtool: display firmware version

 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/nics/features/i40e.ini      |  1 +
 doc/guides/nics/features/igb.ini       |  1 +
 doc/guides/nics/features/ixgbe.ini     |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ---
 doc/guides/rel_notes/release_17_02.rst |  5 +++
 drivers/net/e1000/igb_ethdev.c         | 56 ++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.c         | 33 ++++++++++++++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c       | 26 ++++++++++++++++
 examples/ethtool/ethtool-app/ethapp.c  |  1 +
 examples/ethtool/lib/rte_ethtool.c     |  6 ++++
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++
 lib/librte_ether/rte_ethdev.h          | 25 +++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 14 files changed, 169 insertions(+), 4 deletions(-)

-- 
2.7.4

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

* [dpdk-dev] [PATCH v8 1/5] ethdev: add firmware version get
  2017-01-12  6:31                 ` [dpdk-dev] [PATCH v8 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
@ 2017-01-12  6:31                   ` Qiming Yang
  2017-01-15 20:56                     ` Thomas Monjalon
  2017-01-16  5:44                     ` [dpdk-dev] [PATCH v9 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 2/5] net/e1000: add firmware version get Qiming Yang
                                     ` (3 subsequent siblings)
  4 siblings, 2 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-12  6:31 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: remy.horton, Qiming Yang

This patch adds a new API 'rte_eth_dev_fw_version_get' for
fetching firmware version by a given device.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ----
 doc/guides/rel_notes/release_17_02.rst |  5 +++++
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++++++
 lib/librte_ether/rte_ethdev.h          | 25 +++++++++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 6 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
index f1bf9bf..ae40d57 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -50,6 +50,7 @@ Timesync             =
 Basic stats          =
 Extended stats       =
 Stats per queue      =
+FW version           =
 EEPROM dump          =
 Registers dump       =
 Multiprocess aware   =
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 054e2e7..755dc65 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -30,10 +30,6 @@ Deprecation Notices
   ``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
   segments limit to be transmitted by device for TSO/non-TSO packets.
 
-* In 17.02 ABI change is planned: the ``rte_eth_dev_info`` structure
-  will be extended with a new member ``fw_version`` in order to store
-  the NIC firmware version.
-
 * ethdev: an API change is planned for 17.02 for the function
   ``_rte_eth_dev_callback_process``. In 17.02 the function will return an ``int``
   instead of ``void`` and a fourth parameter ``void *ret_param`` will be added.
diff --git a/doc/guides/rel_notes/release_17_02.rst b/doc/guides/rel_notes/release_17_02.rst
index 5762d3f..f9134bb 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -66,6 +66,11 @@ New Features
   Support for Mellanox ConnectX-5 family of 10/25/40/50/100 Gbps adapters
   has been added to the existing mlx5 PMD.
 
+* **Added firmware version get API.**
+
+  Added a new function ``rte_eth_dev_fw_version_get()`` to fetch firmware
+  version by a given device.
+
 Resolved Issues
 ---------------
 
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 917557a..89cffcf 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1588,6 +1588,18 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
 			STAT_QMAP_RX);
 }
 
+int
+rte_eth_dev_fw_version_get(uint8_t port_id, char *fw_version, size_t fw_size)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fw_version_get, -ENOTSUP);
+	return (*dev->dev_ops->fw_version_get)(dev, fw_version, fw_size);
+}
+
 void
 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index ded43d7..a9b3686 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1177,6 +1177,10 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
 /**< @internal Check DD bit of specific RX descriptor */
 
+typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
+				     char *fw_version, size_t fw_size);
+/**< @internal Get firmware information of an Ethernet device. */
+
 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
 	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
 
@@ -1459,6 +1463,7 @@ struct eth_dev_ops {
 	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
 	eth_rxq_info_get_t         rxq_info_get; /**< retrieve RX queue information. */
 	eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
+	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
 	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
 	/**< Get packet types supported and identified by device. */
 
@@ -2396,6 +2401,26 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
 void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
 
 /**
+ * Retrieve the firmware version of a device.
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param fw_version
+ *   A array pointer to store the firmware version of a device,
+ *   allocated by caller.
+ * @param fw_size
+ *   The size of the array pointed by fw_version, which should be
+ *   large enough to store firmware version of the device.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if operation is not supported.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EINVAL) if *fw_size* is not enough to store firmware version.
+ */
+int rte_eth_dev_fw_version_get(uint8_t port_id,
+			       char *fw_version, size_t fw_size);
+
+/**
  * Retrieve the supported packet types of an Ethernet device.
  *
  * When a packet type is announced as supported, it *must* be recognized by
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index 0c2859e..c6c9d0d 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -146,6 +146,7 @@ DPDK_17.02 {
 	global:
 
 	_rte_eth_dev_reset;
+	rte_eth_dev_fw_version_get;
 	rte_flow_create;
 	rte_flow_destroy;
 	rte_flow_flush;
-- 
2.7.4

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

* [dpdk-dev] [PATCH v8 2/5] net/e1000: add firmware version get
  2017-01-12  6:31                 ` [dpdk-dev] [PATCH v8 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 1/5] ethdev: add firmware version get Qiming Yang
@ 2017-01-12  6:31                   ` Qiming Yang
  2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 3/5] net/ixgbe: " Qiming Yang
                                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-12  6:31 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: remy.horton, Qiming Yang

This patch adds a new function eth_igb_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/igb.ini |  1 +
 drivers/net/e1000/igb_ethdev.c   | 56 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/doc/guides/nics/features/igb.ini b/doc/guides/nics/features/igb.ini
index 9fafe72..26ae008 100644
--- a/doc/guides/nics/features/igb.ini
+++ b/doc/guides/nics/features/igb.ini
@@ -35,6 +35,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 BSD nic_uio          = Y
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 2bb57f5..931992d 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -99,6 +99,8 @@
 #define E1000_VET_VET_EXT            0xFFFF0000
 #define E1000_VET_VET_EXT_SHIFT      16
 
+#define E1000_MIN_FW_VERSION_SIZE    16
+
 static int  eth_igb_configure(struct rte_eth_dev *dev);
 static int  eth_igb_start(struct rte_eth_dev *dev);
 static void eth_igb_stop(struct rte_eth_dev *dev);
@@ -120,6 +122,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
 				    unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
+static int eth_igb_fw_version_get(struct rte_eth_dev *dev,
+				   char *fw_version, size_t fw_size);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static const uint32_t *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -391,6 +395,7 @@ static const struct eth_dev_ops eth_igb_ops = {
 	.xstats_get_names     = eth_igb_xstats_get_names,
 	.stats_reset          = eth_igb_stats_reset,
 	.xstats_reset         = eth_igb_xstats_reset,
+	.fw_version_get       = eth_igb_fw_version_get,
 	.dev_infos_get        = eth_igb_infos_get,
 	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
 	.mtu_set              = eth_igb_mtu_set,
@@ -1984,6 +1989,57 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
 	       offsetof(struct e1000_vf_stats, gprc));
 }
 
+static int
+eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+		       size_t fw_size)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_fw_version fw;
+
+	if (fw_size < E1000_MIN_FW_VERSION_SIZE) {
+		PMD_DRV_LOG(WARNING, "Insufficient fw version buffer size");
+		return -EINVAL;
+	}
+
+	e1000_get_fw_version(hw, &fw);
+
+	switch (hw->mac.type) {
+	case e1000_i210:
+	case e1000_i211:
+		if (!(e1000_get_flash_presence_i210(hw))) {
+			snprintf(fw_version, fw_size,
+				 "%2d.%2d-%d",
+				 fw.invm_major, fw.invm_minor,
+				 fw.invm_img_type);
+			break;
+		}
+		/* fall through */
+	default:
+		/* if option rom is valid, display its version too*/
+		if (fw.or_valid) {
+			snprintf(fw_version, fw_size,
+				 "%d.%d, 0x%08x, %d.%d.%d",
+				 fw.eep_major, fw.eep_minor, fw.etrack_id,
+				 fw.or_major, fw.or_build, fw.or_patch);
+		/* no option rom */
+		} else {
+			if (fw.etrack_id != 0X0000) {
+				snprintf(fw_version, fw_size,
+					 "%d.%d, 0x%08x",
+					 fw.eep_major, fw.eep_minor,
+					 fw.etrack_id);
+			} else {
+				snprintf(fw_version, fw_size,
+					 "%d.%d.%d",
+					 fw.eep_major, fw.eep_minor,
+					 fw.eep_build);
+			}
+		}
+		break;
+	}
+	return 0;
+}
+
 static void
 eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v8 3/5] net/ixgbe: add firmware version get
  2017-01-12  6:31                 ` [dpdk-dev] [PATCH v8 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 1/5] ethdev: add firmware version get Qiming Yang
  2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 2/5] net/e1000: add firmware version get Qiming Yang
@ 2017-01-12  6:31                   ` Qiming Yang
  2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 4/5] net/i40e: " Qiming Yang
  2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 5/5] ethtool: display firmware version Qiming Yang
  4 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-12  6:31 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: remy.horton, Qiming Yang

This patch adds a new function ixgbe_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/ixgbe.ini |  1 +
 drivers/net/ixgbe/ixgbe_ethdev.c   | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/doc/guides/nics/features/ixgbe.ini b/doc/guides/nics/features/ixgbe.ini
index 4a5667f..e7104c2 100644
--- a/doc/guides/nics/features/ixgbe.ini
+++ b/doc/guides/nics/features/ixgbe.ini
@@ -43,6 +43,7 @@ Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 Multiprocess aware   = Y
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index b7ddd4f..2363eb4 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -163,6 +163,7 @@ enum ixgbevf_xcast_modes {
 #define IXGBE_EXVET_VET_EXT_SHIFT              16
 #define IXGBE_DMATXCTL_VT_MASK                 0xFFFF0000
 
+#define IXGBE_MIN_FW_VERSION_SIZE              11
 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
 static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
 static int  ixgbe_dev_configure(struct rte_eth_dev *dev);
@@ -193,6 +194,8 @@ static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint16_t queue_id,
 					     uint8_t stat_idx,
 					     uint8_t is_rx);
+static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+				 size_t fw_size);
 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
 			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -532,6 +535,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.xstats_reset         = ixgbe_dev_xstats_reset,
 	.xstats_get_names     = ixgbe_dev_xstats_get_names,
 	.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
+	.fw_version_get       = ixgbe_fw_version_get,
 	.dev_infos_get        = ixgbe_dev_info_get,
 	.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
 	.mtu_set              = ixgbe_dev_mtu_set,
@@ -3022,6 +3026,28 @@ ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
 	hw_stats->vfgotc = 0;
 }
 
+static int
+ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u16 eeprom_verh, eeprom_verl;
+	u32 etrack_id;
+
+	if (fw_size < IXGBE_MIN_FW_VERSION_SIZE) {
+		PMD_DRV_LOG(WARNING, "Insufficient fw version buffer size");
+		return -EINVAL;
+	}
+
+	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
+	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
+
+	etrack_id = (eeprom_verh << 16) | eeprom_verl;
+	snprintf(fw_version, fw_size,
+		 "0x%08x", etrack_id);
+
+	return 0;
+}
+
 static void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v8 4/5] net/i40e: add firmware version get
  2017-01-12  6:31                 ` [dpdk-dev] [PATCH v8 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                                     ` (2 preceding siblings ...)
  2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 3/5] net/ixgbe: " Qiming Yang
@ 2017-01-12  6:31                   ` Qiming Yang
  2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 5/5] ethtool: display firmware version Qiming Yang
  4 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-12  6:31 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: remy.horton, Qiming Yang

This patch add a new function i40e_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/i40e.ini |  1 +
 drivers/net/i40e/i40e_ethdev.c    | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/doc/guides/nics/features/i40e.ini b/doc/guides/nics/features/i40e.ini
index 0d143bc..0dbc3c3 100644
--- a/doc/guides/nics/features/i40e.ini
+++ b/doc/guides/nics/features/i40e.ini
@@ -39,6 +39,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 Multiprocess aware   = Y
 BSD nic_uio          = Y
 Linux UIO            = Y
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 46def56..81a9f1d 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -231,6 +231,8 @@
 #define I40E_INSET_IPV6_HOP_LIMIT_MASK  0x000CFF00UL
 #define I40E_INSET_IPV6_NEXT_HDR_MASK   0x000C00FFUL
 
+#define I40E_MIN_FW_VERSION_SIZE        16
+
 /* PCI offset for querying capability */
 #define PCI_DEV_CAP_REG            0xA4
 /* PCI offset for enabling/disabling Extended Tag */
@@ -266,6 +268,8 @@ static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
 					    uint16_t queue_id,
 					    uint8_t stat_idx,
 					    uint8_t is_rx);
+static int i40e_fw_version_get(struct rte_eth_dev *dev,
+				char *fw_version, size_t fw_size);
 static void i40e_dev_info_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static int i40e_vlan_filter_set(struct rte_eth_dev *dev,
@@ -458,6 +462,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.stats_reset                  = i40e_dev_stats_reset,
 	.xstats_reset                 = i40e_dev_stats_reset,
 	.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
+	.fw_version_get               = i40e_fw_version_get,
 	.dev_infos_get                = i40e_dev_info_get,
 	.dev_supported_ptypes_get     = i40e_dev_supported_ptypes_get,
 	.vlan_filter_set              = i40e_vlan_filter_set,
@@ -2770,6 +2775,34 @@ i40e_dev_queue_stats_mapping_set(__rte_unused struct rte_eth_dev *dev,
 	return -ENOSYS;
 }
 
+static int
+i40e_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u32 full_ver;
+	u8 ver, patch;
+	u16 build;
+
+	if (fw_size < I40E_MIN_FW_VERSION_SIZE) {
+		PMD_DRV_LOG(WARNING, "Insufficient fw version buffer size");
+		return -EINVAL;
+	}
+
+	full_ver = hw->nvm.oem_ver;
+	ver = (u8)(full_ver >> 24);
+	build = (u16)((full_ver >> 8) & 0xffff);
+	patch = (u8)(full_ver & 0xff);
+
+	snprintf(fw_version, fw_size,
+		 "%d.%d%d 0x%08x %d.%d.%d",
+		 ((hw->nvm.version >> 12) & 0xf),
+		 ((hw->nvm.version >> 4) & 0xff),
+		 (hw->nvm.version & 0xf), hw->nvm.eetrack,
+		 ver, build, patch);
+
+	return 0;
+}
+
 static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v8 5/5] ethtool: display firmware version
  2017-01-12  6:31                 ` [dpdk-dev] [PATCH v8 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                                     ` (3 preceding siblings ...)
  2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 4/5] net/i40e: " Qiming Yang
@ 2017-01-12  6:31                   ` Qiming Yang
  4 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-12  6:31 UTC (permalink / raw)
  To: dev, ferruh.yigit; +Cc: remy.horton, Qiming Yang

This patch enhances the ethtool example to support to show
firmware version, in the same way that the Linux kernel
ethtool does.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 examples/ethtool/ethtool-app/ethapp.c | 1 +
 examples/ethtool/lib/rte_ethtool.c    | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
index 6aeaa06..85c31ac 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -185,6 +185,7 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
 		printf("Port %i driver: %s (ver: %s)\n",
 			id_port, info.driver, info.version
 		      );
+		printf("firmware-version: %s\n", info.fw_version);
 	}
 }
 
diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index b1f159e..33d38a7 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -51,12 +51,18 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 	struct rte_eth_dev_info dev_info;
 	struct rte_dev_reg_info reg_info;
 	int n;
+	int ret;
 
 	if (drvinfo == NULL)
 		return -EINVAL;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
+	ret = rte_eth_dev_fw_version_get(port_id, drvinfo->fw_version,
+			      sizeof(drvinfo->fw_version));
+	if (ret != 0)
+		printf("firmware version get error: (%s)\n", strerror(-ret));
+
 	memset(&dev_info, 0, sizeof(dev_info));
 	rte_eth_dev_info_get(port_id, &dev_info);
 
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH v8 1/5] ethdev: add firmware version get
  2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 1/5] ethdev: add firmware version get Qiming Yang
@ 2017-01-15 20:56                     ` Thomas Monjalon
  2017-01-16  5:44                     ` [dpdk-dev] [PATCH v9 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  1 sibling, 0 replies; 128+ messages in thread
From: Thomas Monjalon @ 2017-01-15 20:56 UTC (permalink / raw)
  To: Qiming Yang; +Cc: dev, ferruh.yigit, remy.horton

2017-01-12 14:31, Qiming Yang:
> + * @param fw_size
> + *   The size of the array pointed by fw_version, which should be
> + *   large enough to store firmware version of the device.
> + * @return
> + *   - (0) if successful.
> + *   - (-ENOTSUP) if operation is not supported.
> + *   - (-ENODEV) if *port_id* invalid.
> + *   - (-EINVAL) if *fw_size* is not enough to store firmware version.
> + */
> +int rte_eth_dev_fw_version_get(uint8_t port_id,
> +                              char *fw_version, size_t fw_size);
> +

How to know the required size?
You should return the size of the non truncated string as snprintf does.
Note: Andrew Rybchenko already commented on it and you didn't reply.

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

* [dpdk-dev] [PATCH v9 0/5] new API 'rte_eth_dev_fw_version_get'
  2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 1/5] ethdev: add firmware version get Qiming Yang
  2017-01-15 20:56                     ` Thomas Monjalon
@ 2017-01-16  5:44                     ` Qiming Yang
  2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 1/5] ethdev: add firmware version get Qiming Yang
                                         ` (5 more replies)
  1 sibling, 6 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-16  5:44 UTC (permalink / raw)
  To: dev; +Cc: thomas.monjalon, ferruh.yigit, Qiming Yang

v9: - when fw_size is insufficient, return the size of the non truncated
      string as snprintf does.

v8: - defined the minimum fw version size as a macro.

v7: - rebased

v6: - renamed fw_length -> fw_size
    - added return value for insufficient fw_size
    - fixed the indentation problem in e1000
    - added ver.build.patch in i40e, keep the same with Linux kernel driver

v5: - modified the API rte_eth_dev_fw_version_get(uint8_t port_id,
      char *fw_version, int fw_length).

v4: - removed deprecation notice
    - renamed API as rte_eth_dev_fw_version_get
    - splited bus info print from this patch set

v3: - changed API, use rte_eth_dev_fw_info_get(uint8_t port_id,
      uint32_t *fw_major, uint32_t *fw_minor, uint32_t *fw_patch,
      uint32_t *etrack_id)
    - added statusment in /doc/guides/nics/features/default.ini and
      release_17_02.rst

v2: - fixed commit log

Now, the example ethtool can only show the driver information. From
customers' point of view, it should be better if we can have the same
way that the Linux kernel ethtool does to show firmware version.

These five patches added a new function ``rte_eth_dev_fw_version_get()``
to fetch firmware version related information and implement the
display in example ethtool.

Qiming Yang (5):
  ethdev: add firmware version get
  net/e1000: add firmware version get
  net/ixgbe: add firmware version get
  net/i40e: add firmware version get
  ethtool: display firmware version

 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/nics/features/i40e.ini      |  1 +
 doc/guides/nics/features/igb.ini       |  1 +
 doc/guides/nics/features/ixgbe.ini     |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ---
 doc/guides/rel_notes/release_17_02.rst |  5 +++
 drivers/net/e1000/igb_ethdev.c         | 56 ++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.c         | 32 +++++++++++++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c       | 25 +++++++++++++++
 examples/ethtool/ethtool-app/ethapp.c  |  1 +
 examples/ethtool/lib/rte_ethtool.c     |  9 ++++++
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++
 lib/librte_ether/rte_ethdev.h          | 26 ++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 14 files changed, 171 insertions(+), 4 deletions(-)

-- 
2.7.4

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

* [dpdk-dev] [PATCH v9 1/5] ethdev: add firmware version get
  2017-01-16  5:44                     ` [dpdk-dev] [PATCH v9 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
@ 2017-01-16  5:44                       ` Qiming Yang
  2017-01-16  7:05                         ` Andrew Rybchenko
  2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 2/5] net/e1000: " Qiming Yang
                                         ` (4 subsequent siblings)
  5 siblings, 1 reply; 128+ messages in thread
From: Qiming Yang @ 2017-01-16  5:44 UTC (permalink / raw)
  To: dev; +Cc: thomas.monjalon, ferruh.yigit, Qiming Yang

This patch adds a new API 'rte_eth_dev_fw_version_get' for
fetching firmware version by a given device.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ----
 doc/guides/rel_notes/release_17_02.rst |  5 +++++
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++++++
 lib/librte_ether/rte_ethdev.h          | 26 ++++++++++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 6 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
index f1bf9bf..ae40d57 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -50,6 +50,7 @@ Timesync             =
 Basic stats          =
 Extended stats       =
 Stats per queue      =
+FW version           =
 EEPROM dump          =
 Registers dump       =
 Multiprocess aware   =
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 054e2e7..755dc65 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -30,10 +30,6 @@ Deprecation Notices
   ``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
   segments limit to be transmitted by device for TSO/non-TSO packets.
 
-* In 17.02 ABI change is planned: the ``rte_eth_dev_info`` structure
-  will be extended with a new member ``fw_version`` in order to store
-  the NIC firmware version.
-
 * ethdev: an API change is planned for 17.02 for the function
   ``_rte_eth_dev_callback_process``. In 17.02 the function will return an ``int``
   instead of ``void`` and a fourth parameter ``void *ret_param`` will be added.
diff --git a/doc/guides/rel_notes/release_17_02.rst b/doc/guides/rel_notes/release_17_02.rst
index 5762d3f..f9134bb 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -66,6 +66,11 @@ New Features
   Support for Mellanox ConnectX-5 family of 10/25/40/50/100 Gbps adapters
   has been added to the existing mlx5 PMD.
 
+* **Added firmware version get API.**
+
+  Added a new function ``rte_eth_dev_fw_version_get()`` to fetch firmware
+  version by a given device.
+
 Resolved Issues
 ---------------
 
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 917557a..89cffcf 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1588,6 +1588,18 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
 			STAT_QMAP_RX);
 }
 
+int
+rte_eth_dev_fw_version_get(uint8_t port_id, char *fw_version, size_t fw_size)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fw_version_get, -ENOTSUP);
+	return (*dev->dev_ops->fw_version_get)(dev, fw_version, fw_size);
+}
+
 void
 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index ded43d7..37a55ef 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1177,6 +1177,10 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
 /**< @internal Check DD bit of specific RX descriptor */
 
+typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
+				     char *fw_version, size_t fw_size);
+/**< @internal Get firmware information of an Ethernet device. */
+
 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
 	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
 
@@ -1459,6 +1463,7 @@ struct eth_dev_ops {
 	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
 	eth_rxq_info_get_t         rxq_info_get; /**< retrieve RX queue information. */
 	eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
+	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
 	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
 	/**< Get packet types supported and identified by device. */
 
@@ -2396,6 +2401,27 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
 void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
 
 /**
+ * Retrieve the firmware version of a device.
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param fw_version
+ *   A array pointer to store the firmware version of a device,
+ *   allocated by caller.
+ * @param fw_size
+ *   The size of the array pointed by fw_version, which should be
+ *   large enough to store firmware version of the device.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if operation is not supported.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (>0) if *fw_size* is not enough to store firmware version, return
+ *          the size of the non truncated string.
+ */
+int rte_eth_dev_fw_version_get(uint8_t port_id,
+			       char *fw_version, size_t fw_size);
+
+/**
  * Retrieve the supported packet types of an Ethernet device.
  *
  * When a packet type is announced as supported, it *must* be recognized by
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index 0c2859e..c6c9d0d 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -146,6 +146,7 @@ DPDK_17.02 {
 	global:
 
 	_rte_eth_dev_reset;
+	rte_eth_dev_fw_version_get;
 	rte_flow_create;
 	rte_flow_destroy;
 	rte_flow_flush;
-- 
2.7.4

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

* [dpdk-dev] [PATCH v9 2/5] net/e1000: add firmware version get
  2017-01-16  5:44                     ` [dpdk-dev] [PATCH v9 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 1/5] ethdev: add firmware version get Qiming Yang
@ 2017-01-16  5:44                       ` Qiming Yang
  2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 3/5] net/ixgbe: " Qiming Yang
                                         ` (3 subsequent siblings)
  5 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-16  5:44 UTC (permalink / raw)
  To: dev; +Cc: thomas.monjalon, ferruh.yigit, Qiming Yang

This patch adds a new function eth_igb_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/igb.ini |  1 +
 drivers/net/e1000/igb_ethdev.c   | 56 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/doc/guides/nics/features/igb.ini b/doc/guides/nics/features/igb.ini
index 9fafe72..26ae008 100644
--- a/doc/guides/nics/features/igb.ini
+++ b/doc/guides/nics/features/igb.ini
@@ -35,6 +35,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 BSD nic_uio          = Y
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 2bb57f5..a96d562 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -120,6 +120,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
 				    unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
+static int eth_igb_fw_version_get(struct rte_eth_dev *dev,
+				   char *fw_version, size_t fw_size);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static const uint32_t *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -391,6 +393,7 @@ static const struct eth_dev_ops eth_igb_ops = {
 	.xstats_get_names     = eth_igb_xstats_get_names,
 	.stats_reset          = eth_igb_stats_reset,
 	.xstats_reset         = eth_igb_xstats_reset,
+	.fw_version_get       = eth_igb_fw_version_get,
 	.dev_infos_get        = eth_igb_infos_get,
 	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
 	.mtu_set              = eth_igb_mtu_set,
@@ -1984,6 +1987,59 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
 	       offsetof(struct e1000_vf_stats, gprc));
 }
 
+static int
+eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+		       size_t fw_size)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_fw_version fw;
+	int ret;
+
+	e1000_get_fw_version(hw, &fw);
+
+	switch (hw->mac.type) {
+	case e1000_i210:
+	case e1000_i211:
+		if (!(e1000_get_flash_presence_i210(hw))) {
+			ret = snprintf(fw_version, fw_size,
+				 "%2d.%2d-%d",
+				 fw.invm_major, fw.invm_minor,
+				 fw.invm_img_type);
+			break;
+		}
+		/* fall through */
+	default:
+		/* if option rom is valid, display its version too */
+		if (fw.or_valid) {
+			ret = snprintf(fw_version, fw_size,
+				 "%d.%d, 0x%08x, %d.%d.%d",
+				 fw.eep_major, fw.eep_minor, fw.etrack_id,
+				 fw.or_major, fw.or_build, fw.or_patch);
+		/* no option rom */
+		} else {
+			if (fw.etrack_id != 0X0000) {
+				ret = snprintf(fw_version, fw_size,
+					 "%d.%d, 0x%08x",
+					 fw.eep_major, fw.eep_minor,
+					 fw.etrack_id);
+			} else {
+				ret = snprintf(fw_version, fw_size,
+					 "%d.%d.%d",
+					 fw.eep_major, fw.eep_minor,
+					 fw.eep_build);
+			}
+		}
+		break;
+	}
+
+	ret += 1; /* add the size of '\0' */
+	if (fw_size < (u32)ret) {
+		PMD_DRV_LOG(WARNING, "Insufficient fw version buffer size");
+		return ret;
+	} else
+		return 0;
+}
+
 static void
 eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v9 3/5] net/ixgbe: add firmware version get
  2017-01-16  5:44                     ` [dpdk-dev] [PATCH v9 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 1/5] ethdev: add firmware version get Qiming Yang
  2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 2/5] net/e1000: " Qiming Yang
@ 2017-01-16  5:44                       ` Qiming Yang
  2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 4/5] net/i40e: " Qiming Yang
                                         ` (2 subsequent siblings)
  5 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-16  5:44 UTC (permalink / raw)
  To: dev; +Cc: thomas.monjalon, ferruh.yigit, Qiming Yang

This patch adds a new function ixgbe_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/ixgbe.ini |  1 +
 drivers/net/ixgbe/ixgbe_ethdev.c   | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/doc/guides/nics/features/ixgbe.ini b/doc/guides/nics/features/ixgbe.ini
index 4a5667f..e7104c2 100644
--- a/doc/guides/nics/features/ixgbe.ini
+++ b/doc/guides/nics/features/ixgbe.ini
@@ -43,6 +43,7 @@ Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 Multiprocess aware   = Y
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index b7ddd4f..fa8ae68 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -193,6 +193,8 @@ static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint16_t queue_id,
 					     uint8_t stat_idx,
 					     uint8_t is_rx);
+static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+				 size_t fw_size);
 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
 			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -532,6 +534,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.xstats_reset         = ixgbe_dev_xstats_reset,
 	.xstats_get_names     = ixgbe_dev_xstats_get_names,
 	.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
+	.fw_version_get       = ixgbe_fw_version_get,
 	.dev_infos_get        = ixgbe_dev_info_get,
 	.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
 	.mtu_set              = ixgbe_dev_mtu_set,
@@ -3022,6 +3025,28 @@ ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
 	hw_stats->vfgotc = 0;
 }
 
+static int
+ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u16 eeprom_verh, eeprom_verl;
+	u32 etrack_id;
+	int ret;
+
+	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
+	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
+
+	etrack_id = (eeprom_verh << 16) | eeprom_verl;
+	ret = snprintf(fw_version, fw_size, "0x%08x", etrack_id);
+
+	ret += 1; /* add the size of '\0' */
+	if (fw_size < (u32)ret) {
+		PMD_DRV_LOG(WARNING, "Insufficient fw version buffer size");
+		return ret;
+	} else
+		return 0;
+}
+
 static void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v9 4/5] net/i40e: add firmware version get
  2017-01-16  5:44                     ` [dpdk-dev] [PATCH v9 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                                         ` (2 preceding siblings ...)
  2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 3/5] net/ixgbe: " Qiming Yang
@ 2017-01-16  5:44                       ` Qiming Yang
  2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 5/5] ethtool: display firmware version Qiming Yang
  2017-01-16 10:48                       ` [dpdk-dev] [PATCH v10 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  5 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-16  5:44 UTC (permalink / raw)
  To: dev; +Cc: thomas.monjalon, ferruh.yigit, Qiming Yang

This patch add a new function i40e_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/i40e.ini |  1 +
 drivers/net/i40e/i40e_ethdev.c    | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/doc/guides/nics/features/i40e.ini b/doc/guides/nics/features/i40e.ini
index 0d143bc..0dbc3c3 100644
--- a/doc/guides/nics/features/i40e.ini
+++ b/doc/guides/nics/features/i40e.ini
@@ -39,6 +39,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 Multiprocess aware   = Y
 BSD nic_uio          = Y
 Linux UIO            = Y
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 46def56..d55d9d0 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -266,6 +266,8 @@ static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
 					    uint16_t queue_id,
 					    uint8_t stat_idx,
 					    uint8_t is_rx);
+static int i40e_fw_version_get(struct rte_eth_dev *dev,
+				char *fw_version, size_t fw_size);
 static void i40e_dev_info_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static int i40e_vlan_filter_set(struct rte_eth_dev *dev,
@@ -458,6 +460,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.stats_reset                  = i40e_dev_stats_reset,
 	.xstats_reset                 = i40e_dev_stats_reset,
 	.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
+	.fw_version_get               = i40e_fw_version_get,
 	.dev_infos_get                = i40e_dev_info_get,
 	.dev_supported_ptypes_get     = i40e_dev_supported_ptypes_get,
 	.vlan_filter_set              = i40e_vlan_filter_set,
@@ -2770,6 +2773,35 @@ i40e_dev_queue_stats_mapping_set(__rte_unused struct rte_eth_dev *dev,
 	return -ENOSYS;
 }
 
+static int
+i40e_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u32 full_ver;
+	u8 ver, patch;
+	u16 build;
+	int ret;
+
+	full_ver = hw->nvm.oem_ver;
+	ver = (u8)(full_ver >> 24);
+	build = (u16)((full_ver >> 8) & 0xffff);
+	patch = (u8)(full_ver & 0xff);
+
+	ret = snprintf(fw_version, fw_size,
+		 "%d.%d%d 0x%08x %d.%d.%d",
+		 ((hw->nvm.version >> 12) & 0xf),
+		 ((hw->nvm.version >> 4) & 0xff),
+		 (hw->nvm.version & 0xf), hw->nvm.eetrack,
+		 ver, build, patch);
+
+	ret += 1; /* add the size of '\0' */
+	if (fw_size < (u32)ret) {
+		PMD_DRV_LOG(WARNING, "Insufficient fw version buffer size");
+		return ret;
+	} else
+		return 0;
+}
+
 static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v9 5/5] ethtool: display firmware version
  2017-01-16  5:44                     ` [dpdk-dev] [PATCH v9 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                                         ` (3 preceding siblings ...)
  2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 4/5] net/i40e: " Qiming Yang
@ 2017-01-16  5:44                       ` Qiming Yang
  2017-01-16 10:48                       ` [dpdk-dev] [PATCH v10 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  5 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-16  5:44 UTC (permalink / raw)
  To: dev; +Cc: thomas.monjalon, ferruh.yigit, Qiming Yang

This patch enhances the ethtool example to support to show
firmware version, in the same way that the Linux kernel
ethtool does.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 examples/ethtool/ethtool-app/ethapp.c | 1 +
 examples/ethtool/lib/rte_ethtool.c    | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
index 6aeaa06..85c31ac 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -185,6 +185,7 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
 		printf("Port %i driver: %s (ver: %s)\n",
 			id_port, info.driver, info.version
 		      );
+		printf("firmware-version: %s\n", info.fw_version);
 	}
 }
 
diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index b1f159e..cd2f277 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -51,12 +51,21 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 	struct rte_eth_dev_info dev_info;
 	struct rte_dev_reg_info reg_info;
 	int n;
+	int ret;
 
 	if (drvinfo == NULL)
 		return -EINVAL;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
+	ret = rte_eth_dev_fw_version_get(port_id, drvinfo->fw_version,
+			      sizeof(drvinfo->fw_version));
+	if (ret < 0)
+		printf("firmware version get error: (%s)\n", strerror(-ret));
+	else if (ret > 0)
+		printf("Insufficient fw version buffer size, the minimun size"
+		       "should be %d\n", ret);
+
 	memset(&dev_info, 0, sizeof(dev_info));
 	rte_eth_dev_info_get(port_id, &dev_info);
 
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH v9 1/5] ethdev: add firmware version get
  2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 1/5] ethdev: add firmware version get Qiming Yang
@ 2017-01-16  7:05                         ` Andrew Rybchenko
  2017-01-16  8:51                           ` Yang, Qiming
  0 siblings, 1 reply; 128+ messages in thread
From: Andrew Rybchenko @ 2017-01-16  7:05 UTC (permalink / raw)
  To: Qiming Yang, dev; +Cc: thomas.monjalon, ferruh.yigit

On 01/16/2017 08:44 AM, Qiming Yang wrote:
> This patch adds a new API 'rte_eth_dev_fw_version_get' for
> fetching firmware version by a given device.
>
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> Acked-by: Remy Horton <remy.horton@intel.com>
> ---
>   doc/guides/nics/features/default.ini   |  1 +
>   doc/guides/rel_notes/deprecation.rst   |  4 ----
>   doc/guides/rel_notes/release_17_02.rst |  5 +++++
>   lib/librte_ether/rte_ethdev.c          | 12 ++++++++++++
>   lib/librte_ether/rte_ethdev.h          | 26 ++++++++++++++++++++++++++
>   lib/librte_ether/rte_ether_version.map |  1 +
>   6 files changed, 45 insertions(+), 4 deletions(-)
>
> diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
> index f1bf9bf..ae40d57 100644
> --- a/doc/guides/nics/features/default.ini
> +++ b/doc/guides/nics/features/default.ini
> @@ -50,6 +50,7 @@ Timesync             =
>   Basic stats          =
>   Extended stats       =
>   Stats per queue      =
> +FW version           =
>   EEPROM dump          =
>   Registers dump       =
>   Multiprocess aware   =
> diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
> index 054e2e7..755dc65 100644
> --- a/doc/guides/rel_notes/deprecation.rst
> +++ b/doc/guides/rel_notes/deprecation.rst
> @@ -30,10 +30,6 @@ Deprecation Notices
>     ``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
>     segments limit to be transmitted by device for TSO/non-TSO packets.
>   
> -* In 17.02 ABI change is planned: the ``rte_eth_dev_info`` structure
> -  will be extended with a new member ``fw_version`` in order to store
> -  the NIC firmware version.
> -
>   * ethdev: an API change is planned for 17.02 for the function
>     ``_rte_eth_dev_callback_process``. In 17.02 the function will return an ``int``
>     instead of ``void`` and a fourth parameter ``void *ret_param`` will be added.
> diff --git a/doc/guides/rel_notes/release_17_02.rst b/doc/guides/rel_notes/release_17_02.rst
> index 5762d3f..f9134bb 100644
> --- a/doc/guides/rel_notes/release_17_02.rst
> +++ b/doc/guides/rel_notes/release_17_02.rst
> @@ -66,6 +66,11 @@ New Features
>     Support for Mellanox ConnectX-5 family of 10/25/40/50/100 Gbps adapters
>     has been added to the existing mlx5 PMD.
>   
> +* **Added firmware version get API.**
> +
> +  Added a new function ``rte_eth_dev_fw_version_get()`` to fetch firmware
> +  version by a given device.
> +
>   Resolved Issues
>   ---------------
>   
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index 917557a..89cffcf 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -1588,6 +1588,18 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
>   			STAT_QMAP_RX);
>   }
>   
> +int
> +rte_eth_dev_fw_version_get(uint8_t port_id, char *fw_version, size_t fw_size)
> +{
> +	struct rte_eth_dev *dev;
> +
> +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
> +	dev = &rte_eth_devices[port_id];
> +
> +	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fw_version_get, -ENOTSUP);
> +	return (*dev->dev_ops->fw_version_get)(dev, fw_version, fw_size);

I think it would be good to handle difference from snprintf() behaviour 
here and specify
that fw_version_get callback has exactly snprintf()-like return value. 
It would allow to avoid
duplicated code in all drivers (adding 1 for terminating null, 
conversion of success value to 0).
Also I think warning about insufficient space is not required. It could 
be intentional to call
the first time with 0 (or some small) space to get required space to be 
(re)allocated.
May be debug level message would be useful.

> +}
> +
>   void
>   rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
>   {
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index ded43d7..37a55ef 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -1177,6 +1177,10 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
>   typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
>   /**< @internal Check DD bit of specific RX descriptor */
>   
> +typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
> +				     char *fw_version, size_t fw_size);
> +/**< @internal Get firmware information of an Ethernet device. */
> +

If we finally have different return value for 
rte_eth_dev_fw_version_get() and here,
it would be useful to highlight it here.

>   typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
>   	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
>   
> @@ -1459,6 +1463,7 @@ struct eth_dev_ops {
>   	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
>   	eth_rxq_info_get_t         rxq_info_get; /**< retrieve RX queue information. */
>   	eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
> +	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
>   	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
>   	/**< Get packet types supported and identified by device. */
>   
> @@ -2396,6 +2401,27 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
>   void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
>   
>   /**
> + * Retrieve the firmware version of a device.
> + *
> + * @param port_id
> + *   The port identifier of the device.
> + * @param fw_version
> + *   A array pointer to store the firmware version of a device,
> + *   allocated by caller.
> + * @param fw_size
> + *   The size of the array pointed by fw_version, which should be
> + *   large enough to store firmware version of the device.
> + * @return
> + *   - (0) if successful.
> + *   - (-ENOTSUP) if operation is not supported.
> + *   - (-ENODEV) if *port_id* invalid.
> + *   - (>0) if *fw_size* is not enough to store firmware version, return
> + *          the size of the non truncated string.

It is OK for me to keep 0 for success here and it is right in this case 
to include terminating null
iin the return value if size is insufficient (to cover corner case with 
empty FW version).
Please, highlight that terminating null is included here. It is the 
difference from snprintf() and
it should be 100% clear.

> + */
> +int rte_eth_dev_fw_version_get(uint8_t port_id,
> +			       char *fw_version, size_t fw_size);
> +
> +/**
>    * Retrieve the supported packet types of an Ethernet device.
>    *
>    * When a packet type is announced as supported, it *must* be recognized by
> diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
> index 0c2859e..c6c9d0d 100644
> --- a/lib/librte_ether/rte_ether_version.map
> +++ b/lib/librte_ether/rte_ether_version.map
> @@ -146,6 +146,7 @@ DPDK_17.02 {
>   	global:
>   
>   	_rte_eth_dev_reset;
> +	rte_eth_dev_fw_version_get;
>   	rte_flow_create;
>   	rte_flow_destroy;
>   	rte_flow_flush;

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

* Re: [dpdk-dev] [PATCH v9 1/5] ethdev: add firmware version get
  2017-01-16  7:05                         ` Andrew Rybchenko
@ 2017-01-16  8:51                           ` Yang, Qiming
  0 siblings, 0 replies; 128+ messages in thread
From: Yang, Qiming @ 2017-01-16  8:51 UTC (permalink / raw)
  To: Andrew Rybchenko, dev; +Cc: thomas.monjalon, Yigit, Ferruh

Hi, Andrew 
> > diff --git a/lib/librte_ether/rte_ethdev.c
> > b/lib/librte_ether/rte_ethdev.c index 917557a..89cffcf 100644
> > --- a/lib/librte_ether/rte_ethdev.c
> > +++ b/lib/librte_ether/rte_ethdev.c
> > @@ -1588,6 +1588,18 @@
> rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t
> rx_queue_id,
> >   			STAT_QMAP_RX);
> >   }
> >
> > +int
> > +rte_eth_dev_fw_version_get(uint8_t port_id, char *fw_version, size_t
> > +fw_size) {
> > +	struct rte_eth_dev *dev;
> > +
> > +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
> > +	dev = &rte_eth_devices[port_id];
> > +
> > +	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fw_version_get, -
> ENOTSUP);
> > +	return (*dev->dev_ops->fw_version_get)(dev, fw_version, fw_size);
> 
> I think it would be good to handle difference from snprintf() behaviour here
> and specify that fw_version_get callback has exactly snprintf()-like return
> value.
> It would allow to avoid
> duplicated code in all drivers (adding 1 for terminating null, conversion of
> success value to 0).

But I think it would be better to just keep the way it is. If I handle snpritf() behavior here,
may the function rte_eth_dev_fw_version_get and ops fw_version_get will have different 
definition of return value.

> Also I think warning about insufficient space is not required. It could be
> intentional to call the first time with 0 (or some small) space to get required
> space to be (re)allocated.
> May be debug level message would be useful.

Good advice, when call this function with 0, this function will become a API to get
firmware version size. I think we can remove the warning message here.

> 
> > +}
> > +
> >   void
> >   rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info
> *dev_info)
> >   {
> > diff --git a/lib/librte_ether/rte_ethdev.h
> > b/lib/librte_ether/rte_ethdev.h index ded43d7..37a55ef 100644
> > --- a/lib/librte_ether/rte_ethdev.h
> > +++ b/lib/librte_ether/rte_ethdev.h
> > @@ -1177,6 +1177,10 @@ typedef uint32_t
> (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
> >   typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
> >   /**< @internal Check DD bit of specific RX descriptor */
> >
> > +typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
> > +				     char *fw_version, size_t fw_size); /**<
> @internal Get
> > +firmware information of an Ethernet device. */
> > +
> 
> If we finally have different return value for
> rte_eth_dev_fw_version_get() and here,
> it would be useful to highlight it here.

If I keep the handle of snprintf() return value in drivers, they will not have different
return here, so the highlight is not necessary.

> >   typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
> >   	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
> >
> > @@ -1459,6 +1463,7 @@ struct eth_dev_ops {
> >   	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
> >   	eth_rxq_info_get_t         rxq_info_get; /**< retrieve RX queue
> information. */
> >   	eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue
> information. */
> > +	eth_fw_version_get_t       fw_version_get; /**< Get firmware
> version. */
> >   	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
> >   	/**< Get packet types supported and identified by device. */
> >
> > @@ -2396,6 +2401,27 @@ void rte_eth_macaddr_get(uint8_t port_id,
> struct ether_addr *mac_addr);
> >   void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info
> > *dev_info);
> >
> >   /**
> > + * Retrieve the firmware version of a device.
> > + *
> > + * @param port_id
> > + *   The port identifier of the device.
> > + * @param fw_version
> > + *   A array pointer to store the firmware version of a device,
> > + *   allocated by caller.
> > + * @param fw_size
> > + *   The size of the array pointed by fw_version, which should be
> > + *   large enough to store firmware version of the device.
> > + * @return
> > + *   - (0) if successful.
> > + *   - (-ENOTSUP) if operation is not supported.
> > + *   - (-ENODEV) if *port_id* invalid.
> > + *   - (>0) if *fw_size* is not enough to store firmware version, return
> > + *          the size of the non truncated string.
> 
> It is OK for me to keep 0 for success here and it is right in this case to include
> terminating null iin the return value if size is insufficient (to cover corner case
> with empty FW version).
> Please, highlight that terminating null is included here. It is the difference
> from snprintf() and it should be 100% clear.
> 
You are right, I'll highlight that the firmware version stored here is include '\0'.

> > + */
> > +int rte_eth_dev_fw_version_get(uint8_t port_id,
> > +			       char *fw_version, size_t fw_size);
> > +
> > +/**
> >    * Retrieve the supported packet types of an Ethernet device.
> >    *
> >    * When a packet type is announced as supported, it *must* be
> > recognized by diff --git a/lib/librte_ether/rte_ether_version.map
> > b/lib/librte_ether/rte_ether_version.map
> > index 0c2859e..c6c9d0d 100644
> > --- a/lib/librte_ether/rte_ether_version.map
> > +++ b/lib/librte_ether/rte_ether_version.map
> > @@ -146,6 +146,7 @@ DPDK_17.02 {
> >   	global:
> >
> >   	_rte_eth_dev_reset;
> > +	rte_eth_dev_fw_version_get;
> >   	rte_flow_create;
> >   	rte_flow_destroy;
> >   	rte_flow_flush;
> 

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

* [dpdk-dev] [PATCH v10 0/5]  new API 'rte_eth_dev_fw_version_get'
  2017-01-16  5:44                     ` [dpdk-dev] [PATCH v9 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                                         ` (4 preceding siblings ...)
  2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 5/5] ethtool: display firmware version Qiming Yang
@ 2017-01-16 10:48                       ` Qiming Yang
  2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 1/5] ethdev: add firmware version get Qiming Yang
                                           ` (5 more replies)
  5 siblings, 6 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-16 10:48 UTC (permalink / raw)
  To: dev; +Cc: arybchenko, thomas.monjalon, Qiming Yang

v10:- highlighted that terminating null is included in the output string array.
      removed the warning message in drivers.

v9: - when fw_size is insufficient, return the size of the non truncated
      string as snprintf does.

v8: - defined the minimum fw version size as a macro.

v7: - rebased

v6: - renamed fw_length -> fw_size
    - added return value for insufficient fw_size
    - fixed the indentation problem in e1000
    - added ver.build.patch in i40e, keep the same with Linux kernel driver

v5: - modified the API rte_eth_dev_fw_version_get(uint8_t port_id,
      char *fw_version, int fw_length).

v4: - removed deprecation notice
    - renamed API as rte_eth_dev_fw_version_get
    - splited bus info print from this patch set

v3: - changed API, use rte_eth_dev_fw_info_get(uint8_t port_id,
      uint32_t *fw_major, uint32_t *fw_minor, uint32_t *fw_patch,
      uint32_t *etrack_id)
    - added statusment in /doc/guides/nics/features/default.ini and
      release_17_02.rst

v2: - fixed commit log

Now, the example ethtool can only show the driver information. From
customers' point of view, it should be better if we can have the same
way that the Linux kernel ethtool does to show firmware version.

These five patches added a new function ``rte_eth_dev_fw_version_get()``
to fetch firmware version related information and implement the
display in example ethtool.

Qiming Yang (5):
  ethdev: add firmware version get
  net/e1000: add firmware version get
  net/ixgbe: add firmware version get
  net/i40e: add firmware version get
  ethtool: display firmware version

 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/nics/features/i40e.ini      |  1 +
 doc/guides/nics/features/igb.ini       |  1 +
 doc/guides/nics/features/ixgbe.ini     |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ---
 doc/guides/rel_notes/release_17_02.rst |  5 ++++
 drivers/net/e1000/igb_ethdev.c         | 55 ++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.c         | 31 +++++++++++++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c       | 24 +++++++++++++++
 examples/ethtool/ethtool-app/ethapp.c  |  1 +
 examples/ethtool/lib/rte_ethtool.c     |  9 ++++++
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++
 lib/librte_ether/rte_ethdev.h          | 26 ++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 14 files changed, 168 insertions(+), 4 deletions(-)

-- 
2.7.4

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

* [dpdk-dev] [PATCH v10 1/5] ethdev: add firmware version get
  2017-01-16 10:48                       ` [dpdk-dev] [PATCH v10 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
@ 2017-01-16 10:48                         ` Qiming Yang
  2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 2/5] net/e1000: " Qiming Yang
                                           ` (4 subsequent siblings)
  5 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-16 10:48 UTC (permalink / raw)
  To: dev; +Cc: arybchenko, thomas.monjalon, Qiming Yang

This patch adds a new API 'rte_eth_dev_fw_version_get' for
fetching firmware version by a given device.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/default.ini   |  1 +
 doc/guides/rel_notes/deprecation.rst   |  4 ----
 doc/guides/rel_notes/release_17_02.rst |  5 +++++
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++++++
 lib/librte_ether/rte_ethdev.h          | 26 ++++++++++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  1 +
 6 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
index f1bf9bf..ae40d57 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -50,6 +50,7 @@ Timesync             =
 Basic stats          =
 Extended stats       =
 Stats per queue      =
+FW version           =
 EEPROM dump          =
 Registers dump       =
 Multiprocess aware   =
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 054e2e7..755dc65 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -30,10 +30,6 @@ Deprecation Notices
   ``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
   segments limit to be transmitted by device for TSO/non-TSO packets.
 
-* In 17.02 ABI change is planned: the ``rte_eth_dev_info`` structure
-  will be extended with a new member ``fw_version`` in order to store
-  the NIC firmware version.
-
 * ethdev: an API change is planned for 17.02 for the function
   ``_rte_eth_dev_callback_process``. In 17.02 the function will return an ``int``
   instead of ``void`` and a fourth parameter ``void *ret_param`` will be added.
diff --git a/doc/guides/rel_notes/release_17_02.rst b/doc/guides/rel_notes/release_17_02.rst
index 5762d3f..f9134bb 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -66,6 +66,11 @@ New Features
   Support for Mellanox ConnectX-5 family of 10/25/40/50/100 Gbps adapters
   has been added to the existing mlx5 PMD.
 
+* **Added firmware version get API.**
+
+  Added a new function ``rte_eth_dev_fw_version_get()`` to fetch firmware
+  version by a given device.
+
 Resolved Issues
 ---------------
 
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 917557a..89cffcf 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1588,6 +1588,18 @@ rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
 			STAT_QMAP_RX);
 }
 
+int
+rte_eth_dev_fw_version_get(uint8_t port_id, char *fw_version, size_t fw_size)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fw_version_get, -ENOTSUP);
+	return (*dev->dev_ops->fw_version_get)(dev, fw_version, fw_size);
+}
+
 void
 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index ded43d7..768ca04 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1177,6 +1177,10 @@ typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
 /**< @internal Check DD bit of specific RX descriptor */
 
+typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
+				     char *fw_version, size_t fw_size);
+/**< @internal Get firmware information of an Ethernet device. */
+
 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
 	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
 
@@ -1459,6 +1463,7 @@ struct eth_dev_ops {
 	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
 	eth_rxq_info_get_t         rxq_info_get; /**< retrieve RX queue information. */
 	eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
+	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
 	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
 	/**< Get packet types supported and identified by device. */
 
@@ -2396,6 +2401,27 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr);
 void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info);
 
 /**
+ * Retrieve the firmware version of a device.
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param fw_version
+ *   A pointer to a string array storing the firmware version of a device,
+ *   the string includes terminating null. This pointer is allocated by caller.
+ * @param fw_size
+ *   The size of the string array pointed by fw_version, which should be
+ *   large enough to store firmware version of the device.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if operation is not supported.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (>0) if *fw_size* is not enough to store firmware version, return
+ *          the size of the non truncated string.
+ */
+int rte_eth_dev_fw_version_get(uint8_t port_id,
+			       char *fw_version, size_t fw_size);
+
+/**
  * Retrieve the supported packet types of an Ethernet device.
  *
  * When a packet type is announced as supported, it *must* be recognized by
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index 0c2859e..c6c9d0d 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -146,6 +146,7 @@ DPDK_17.02 {
 	global:
 
 	_rte_eth_dev_reset;
+	rte_eth_dev_fw_version_get;
 	rte_flow_create;
 	rte_flow_destroy;
 	rte_flow_flush;
-- 
2.7.4

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

* [dpdk-dev] [PATCH v10 2/5] net/e1000: add firmware version get
  2017-01-16 10:48                       ` [dpdk-dev] [PATCH v10 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 1/5] ethdev: add firmware version get Qiming Yang
@ 2017-01-16 10:48                         ` Qiming Yang
  2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 3/5] net/ixgbe: " Qiming Yang
                                           ` (3 subsequent siblings)
  5 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-16 10:48 UTC (permalink / raw)
  To: dev; +Cc: arybchenko, thomas.monjalon, Qiming Yang

This patch adds a new function eth_igb_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/igb.ini |  1 +
 drivers/net/e1000/igb_ethdev.c   | 55 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/doc/guides/nics/features/igb.ini b/doc/guides/nics/features/igb.ini
index 9fafe72..26ae008 100644
--- a/doc/guides/nics/features/igb.ini
+++ b/doc/guides/nics/features/igb.ini
@@ -35,6 +35,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 BSD nic_uio          = Y
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 2bb57f5..d58f582 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -120,6 +120,8 @@ static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
 				    unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
+static int eth_igb_fw_version_get(struct rte_eth_dev *dev,
+				   char *fw_version, size_t fw_size);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static const uint32_t *eth_igb_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -391,6 +393,7 @@ static const struct eth_dev_ops eth_igb_ops = {
 	.xstats_get_names     = eth_igb_xstats_get_names,
 	.stats_reset          = eth_igb_stats_reset,
 	.xstats_reset         = eth_igb_xstats_reset,
+	.fw_version_get       = eth_igb_fw_version_get,
 	.dev_infos_get        = eth_igb_infos_get,
 	.dev_supported_ptypes_get = eth_igb_supported_ptypes_get,
 	.mtu_set              = eth_igb_mtu_set,
@@ -1984,6 +1987,58 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
 	       offsetof(struct e1000_vf_stats, gprc));
 }
 
+static int
+eth_igb_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+		       size_t fw_size)
+{
+	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_fw_version fw;
+	int ret;
+
+	e1000_get_fw_version(hw, &fw);
+
+	switch (hw->mac.type) {
+	case e1000_i210:
+	case e1000_i211:
+		if (!(e1000_get_flash_presence_i210(hw))) {
+			ret = snprintf(fw_version, fw_size,
+				 "%2d.%2d-%d",
+				 fw.invm_major, fw.invm_minor,
+				 fw.invm_img_type);
+			break;
+		}
+		/* fall through */
+	default:
+		/* if option rom is valid, display its version too */
+		if (fw.or_valid) {
+			ret = snprintf(fw_version, fw_size,
+				 "%d.%d, 0x%08x, %d.%d.%d",
+				 fw.eep_major, fw.eep_minor, fw.etrack_id,
+				 fw.or_major, fw.or_build, fw.or_patch);
+		/* no option rom */
+		} else {
+			if (fw.etrack_id != 0X0000) {
+				ret = snprintf(fw_version, fw_size,
+					 "%d.%d, 0x%08x",
+					 fw.eep_major, fw.eep_minor,
+					 fw.etrack_id);
+			} else {
+				ret = snprintf(fw_version, fw_size,
+					 "%d.%d.%d",
+					 fw.eep_major, fw.eep_minor,
+					 fw.eep_build);
+			}
+		}
+		break;
+	}
+
+	ret += 1; /* add the size of '\0' */
+	if (fw_size < (u32)ret)
+		return ret;
+	else
+		return 0;
+}
+
 static void
 eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v10 3/5] net/ixgbe: add firmware version get
  2017-01-16 10:48                       ` [dpdk-dev] [PATCH v10 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
  2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 1/5] ethdev: add firmware version get Qiming Yang
  2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 2/5] net/e1000: " Qiming Yang
@ 2017-01-16 10:48                         ` Qiming Yang
  2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 4/5] net/i40e: " Qiming Yang
                                           ` (2 subsequent siblings)
  5 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-16 10:48 UTC (permalink / raw)
  To: dev; +Cc: arybchenko, thomas.monjalon, Qiming Yang

This patch adds a new function ixgbe_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/ixgbe.ini |  1 +
 drivers/net/ixgbe/ixgbe_ethdev.c   | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/doc/guides/nics/features/ixgbe.ini b/doc/guides/nics/features/ixgbe.ini
index 4a5667f..e7104c2 100644
--- a/doc/guides/nics/features/ixgbe.ini
+++ b/doc/guides/nics/features/ixgbe.ini
@@ -43,6 +43,7 @@ Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
+FW version           = Y
 EEPROM dump          = Y
 Registers dump       = Y
 Multiprocess aware   = Y
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index b7ddd4f..034504c 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -193,6 +193,8 @@ static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint16_t queue_id,
 					     uint8_t stat_idx,
 					     uint8_t is_rx);
+static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+				 size_t fw_size);
 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
 			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
@@ -532,6 +534,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.xstats_reset         = ixgbe_dev_xstats_reset,
 	.xstats_get_names     = ixgbe_dev_xstats_get_names,
 	.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
+	.fw_version_get       = ixgbe_fw_version_get,
 	.dev_infos_get        = ixgbe_dev_info_get,
 	.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
 	.mtu_set              = ixgbe_dev_mtu_set,
@@ -3022,6 +3025,27 @@ ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
 	hw_stats->vfgotc = 0;
 }
 
+static int
+ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u16 eeprom_verh, eeprom_verl;
+	u32 etrack_id;
+	int ret;
+
+	ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
+	ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
+
+	etrack_id = (eeprom_verh << 16) | eeprom_verl;
+	ret = snprintf(fw_version, fw_size, "0x%08x", etrack_id);
+
+	ret += 1; /* add the size of '\0' */
+	if (fw_size < (u32)ret)
+		return ret;
+	else
+		return 0;
+}
+
 static void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v10 4/5] net/i40e: add firmware version get
  2017-01-16 10:48                       ` [dpdk-dev] [PATCH v10 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                                           ` (2 preceding siblings ...)
  2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 3/5] net/ixgbe: " Qiming Yang
@ 2017-01-16 10:48                         ` Qiming Yang
  2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 5/5] ethtool: display firmware version Qiming Yang
  2017-01-17 21:35                         ` [dpdk-dev] [PATCH v10 0/5] new API 'rte_eth_dev_fw_version_get' Thomas Monjalon
  5 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-16 10:48 UTC (permalink / raw)
  To: dev; +Cc: arybchenko, thomas.monjalon, Qiming Yang

This patch add a new function i40e_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/nics/features/i40e.ini |  1 +
 drivers/net/i40e/i40e_ethdev.c    | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/doc/guides/nics/features/i40e.ini b/doc/guides/nics/features/i40e.ini
index 0d143bc..0dbc3c3 100644
--- a/doc/guides/nics/features/i40e.ini
+++ b/doc/guides/nics/features/i40e.ini
@@ -39,6 +39,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 Multiprocess aware   = Y
 BSD nic_uio          = Y
 Linux UIO            = Y
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 46def56..22442f8 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -266,6 +266,8 @@ static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
 					    uint16_t queue_id,
 					    uint8_t stat_idx,
 					    uint8_t is_rx);
+static int i40e_fw_version_get(struct rte_eth_dev *dev,
+				char *fw_version, size_t fw_size);
 static void i40e_dev_info_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static int i40e_vlan_filter_set(struct rte_eth_dev *dev,
@@ -458,6 +460,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.stats_reset                  = i40e_dev_stats_reset,
 	.xstats_reset                 = i40e_dev_stats_reset,
 	.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
+	.fw_version_get               = i40e_fw_version_get,
 	.dev_infos_get                = i40e_dev_info_get,
 	.dev_supported_ptypes_get     = i40e_dev_supported_ptypes_get,
 	.vlan_filter_set              = i40e_vlan_filter_set,
@@ -2770,6 +2773,34 @@ i40e_dev_queue_stats_mapping_set(__rte_unused struct rte_eth_dev *dev,
 	return -ENOSYS;
 }
 
+static int
+i40e_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u32 full_ver;
+	u8 ver, patch;
+	u16 build;
+	int ret;
+
+	full_ver = hw->nvm.oem_ver;
+	ver = (u8)(full_ver >> 24);
+	build = (u16)((full_ver >> 8) & 0xffff);
+	patch = (u8)(full_ver & 0xff);
+
+	ret = snprintf(fw_version, fw_size,
+		 "%d.%d%d 0x%08x %d.%d.%d",
+		 ((hw->nvm.version >> 12) & 0xf),
+		 ((hw->nvm.version >> 4) & 0xff),
+		 (hw->nvm.version & 0xf), hw->nvm.eetrack,
+		 ver, build, patch);
+
+	ret += 1; /* add the size of '\0' */
+	if (fw_size < (u32)ret)
+		return ret;
+	else
+		return 0;
+}
+
 static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-- 
2.7.4

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

* [dpdk-dev] [PATCH v10 5/5] ethtool: display firmware version
  2017-01-16 10:48                       ` [dpdk-dev] [PATCH v10 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                                           ` (3 preceding siblings ...)
  2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 4/5] net/i40e: " Qiming Yang
@ 2017-01-16 10:48                         ` Qiming Yang
  2017-01-17 21:35                         ` [dpdk-dev] [PATCH v10 0/5] new API 'rte_eth_dev_fw_version_get' Thomas Monjalon
  5 siblings, 0 replies; 128+ messages in thread
From: Qiming Yang @ 2017-01-16 10:48 UTC (permalink / raw)
  To: dev; +Cc: arybchenko, thomas.monjalon, Qiming Yang

This patch enhances the ethtool example to support to show
firmware version, in the same way that the Linux kernel
ethtool does.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 examples/ethtool/ethtool-app/ethapp.c | 1 +
 examples/ethtool/lib/rte_ethtool.c    | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
index 6aeaa06..85c31ac 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -185,6 +185,7 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
 		printf("Port %i driver: %s (ver: %s)\n",
 			id_port, info.driver, info.version
 		      );
+		printf("firmware-version: %s\n", info.fw_version);
 	}
 }
 
diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index b1f159e..cd2f277 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -51,12 +51,21 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 	struct rte_eth_dev_info dev_info;
 	struct rte_dev_reg_info reg_info;
 	int n;
+	int ret;
 
 	if (drvinfo == NULL)
 		return -EINVAL;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
+	ret = rte_eth_dev_fw_version_get(port_id, drvinfo->fw_version,
+			      sizeof(drvinfo->fw_version));
+	if (ret < 0)
+		printf("firmware version get error: (%s)\n", strerror(-ret));
+	else if (ret > 0)
+		printf("Insufficient fw version buffer size, the minimun size"
+		       "should be %d\n", ret);
+
 	memset(&dev_info, 0, sizeof(dev_info));
 	rte_eth_dev_info_get(port_id, &dev_info);
 
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH v10 0/5] new API 'rte_eth_dev_fw_version_get'
  2017-01-16 10:48                       ` [dpdk-dev] [PATCH v10 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
                                           ` (4 preceding siblings ...)
  2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 5/5] ethtool: display firmware version Qiming Yang
@ 2017-01-17 21:35                         ` Thomas Monjalon
  5 siblings, 0 replies; 128+ messages in thread
From: Thomas Monjalon @ 2017-01-17 21:35 UTC (permalink / raw)
  To: Qiming Yang; +Cc: dev, arybchenko

> Qiming Yang (5):
>   ethdev: add firmware version get
>   net/e1000: add firmware version get
>   net/ixgbe: add firmware version get
>   net/i40e: add firmware version get
>   ethtool: display firmware version

Applied, thanks

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

* Re: [dpdk-dev] [PATCH v4] ethtool: dispaly bus information
  2017-01-04 12:18         ` [dpdk-dev] [PATCH v4] ethtool: dispaly bus information Qiming Yang
  2017-01-04 14:49           ` Mcnamara, John
@ 2017-02-09 21:32           ` Thomas Monjalon
  1 sibling, 0 replies; 128+ messages in thread
From: Thomas Monjalon @ 2017-02-09 21:32 UTC (permalink / raw)
  To: Qiming Yang; +Cc: dev, ferruh.yigit, helin.zhang, remy.horton

2017-01-04 20:18, Qiming Yang:
> This patch enhances the ethtool example to support to show
> bus information, in the same way that the Linux kernel
> ethtool does.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> Acked-by: Remy Horton <remy.horton@intel.com>

Applied, thanks

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

end of thread, other threads:[~2017-02-09 21:32 UTC | newest]

Thread overview: 128+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-17  9:42 [dpdk-dev] [PATCH] e1000: add firmware version get Qiming Yang
2016-11-17  9:42 ` [dpdk-dev] [PATCH 1/5] ethdev: " Qiming Yang
2016-11-17 13:36   ` Thomas Monjalon
2016-11-18  2:10     ` Yang, Qiming
2016-11-18  1:09   ` Remy Horton
2016-11-18  2:18     ` Yang, Qiming
2016-12-06  7:16   ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw " Qiming Yang
2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 1/5] ethdev: add firmware " Qiming Yang
2016-12-08 11:07       ` Ferruh Yigit
2016-12-12  1:28         ` Yang, Qiming
2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 2/5] net/e1000: " Qiming Yang
2016-12-07  1:16       ` Lu, Wenzhuo
2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 3/5] net/ixgbe: " Qiming Yang
2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 4/5] net/i40e: " Qiming Yang
2016-12-06  7:16     ` [dpdk-dev] [PATCH v2 5/5] ethtool: dispaly bus info and firmware version Qiming Yang
2016-12-23 12:50       ` Ferruh Yigit
2016-12-27 13:06       ` [dpdk-dev] [PATCH v3] " Qiming Yang
2017-01-04  7:51         ` Wu, Jingjing
2017-01-04 12:18         ` [dpdk-dev] [PATCH v4] ethtool: dispaly bus information Qiming Yang
2017-01-04 14:49           ` Mcnamara, John
2017-01-05  1:51             ` Yang, Qiming
2017-02-09 21:32           ` Thomas Monjalon
2016-12-08  8:34     ` [dpdk-dev] [PATCH v2 0/5] example/ethtool: add bus info and fw version get Remy Horton
2016-12-12  1:43       ` Yang, Qiming
2016-12-22 11:07       ` Thomas Monjalon
2016-12-22 14:36         ` Ferruh Yigit
2016-12-22 14:47           ` Thomas Monjalon
2016-12-22 15:05             ` Ferruh Yigit
2016-12-22 15:31               ` Thomas Monjalon
2016-12-23 12:48                 ` Ferruh Yigit
2017-01-05  3:04                 ` Zhang, Helin
2016-12-27 12:30     ` [dpdk-dev] [PATCH v3 0/4] new API 'rte_eth_dev_fw_info_get' Qiming Yang
2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 1/4] ethdev: add firmware information get Qiming Yang
2017-01-02 15:38         ` Thomas Monjalon
     [not found]           ` <F5DF4F0E3AFEF648ADC1C3C33AD4DBF16EDC9515@SHSMSX101.ccr.corp.intel.com>
     [not found]             ` <10603884.vrshqR2O82@xps13>
2017-01-03  9:05               ` Yang, Qiming
2017-01-03 14:49                 ` Ferruh Yigit
2017-01-04  3:33                   ` Yang, Qiming
2017-01-04  7:48                     ` Wu, Jingjing
2017-01-04  8:43                       ` Ferruh Yigit
2017-01-05  1:04                         ` Wu, Jingjing
2017-01-03 14:58         ` Ferruh Yigit
2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 2/4] net/e1000: add firmware version get Qiming Yang
2017-01-03 15:02         ` Ferruh Yigit
2017-01-04  3:14           ` Yang, Qiming
2017-01-04  8:47             ` Ferruh Yigit
2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 3/4] net/ixgbe: " Qiming Yang
2017-01-03 15:04         ` Ferruh Yigit
2017-01-04  2:44           ` Yang, Qiming
2017-01-04  9:06             ` Ferruh Yigit
2017-01-04  9:48               ` Yang, Qiming
2017-01-04 12:01                 ` Ferruh Yigit
2016-12-27 12:30       ` [dpdk-dev] [PATCH v3 4/4] net/i40e: " Qiming Yang
2017-01-04 12:03       ` [dpdk-dev] [PATCH v4 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 1/5] ethdev: add firmware version get Qiming Yang
2017-01-05 13:44           ` Thomas Monjalon
2017-01-08  3:09             ` Yang, Qiming
2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 2/5] net/e1000: " Qiming Yang
2017-01-04 13:59           ` Ferruh Yigit
2017-01-05  1:50             ` Yang, Qiming
2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 3/5] net/ixgbe: " Qiming Yang
2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 4/5] net/i40e: " Qiming Yang
2017-01-04 14:00           ` Ferruh Yigit
2017-01-04 12:03         ` [dpdk-dev] [PATCH v4 5/5] ethtool: dispaly firmware version Qiming Yang
2017-01-04 14:00           ` Ferruh Yigit
2017-01-05  1:31             ` Yang, Qiming
2017-01-06 15:55               ` Remy Horton
2017-01-08  4:11         ` [dpdk-dev] [PATCH v5 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 1/5] ethdev: add firmware version get Qiming Yang
2017-01-08  6:38             ` Andrew Rybchenko
2017-01-08 23:05             ` Stephen Hemminger
2017-01-09  7:16               ` Yang, Qiming
2017-01-09 10:01                 ` Remy Horton
2017-01-09 17:23                   ` Stephen Hemminger
2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 2/5] net/e1000: " Qiming Yang
2017-01-08 23:03             ` Stephen Hemminger
2017-01-09  1:48               ` Yang, Qiming
2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 3/5] net/ixgbe: " Qiming Yang
2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 4/5] net/i40e: " Qiming Yang
2017-01-08 23:08             ` Stephen Hemminger
2017-01-08  4:11           ` [dpdk-dev] [PATCH v5 5/5] ethtool: display firmware version Qiming Yang
2017-01-08 23:11             ` Stephen Hemminger
2017-01-10  9:00           ` [dpdk-dev] [DPDK 1/5] ethdev: add firmware version get Qiming Yang
2017-01-10  9:00             ` [dpdk-dev] [DPDK 2/5] net/e1000: " Qiming Yang
2017-01-10  9:00             ` [dpdk-dev] [DPDK 3/5] net/ixgbe: " Qiming Yang
2017-01-10  9:08           ` [dpdk-dev] [PATCH v6 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 1/5] ethdev: add firmware version get Qiming Yang
2017-01-11  6:41               ` [dpdk-dev] [PATCH v7 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 1/5] ethdev: add firmware version get Qiming Yang
2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 2/5] net/e1000: " Qiming Yang
2017-01-11 15:45                   ` Remy Horton
2017-01-12  1:25                     ` Yang, Qiming
2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 3/5] net/ixgbe: " Qiming Yang
2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 4/5] net/i40e: " Qiming Yang
2017-01-11  6:41                 ` [dpdk-dev] [PATCH v7 5/5] ethtool: display firmware version Qiming Yang
2017-01-12  6:31                 ` [dpdk-dev] [PATCH v8 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 1/5] ethdev: add firmware version get Qiming Yang
2017-01-15 20:56                     ` Thomas Monjalon
2017-01-16  5:44                     ` [dpdk-dev] [PATCH v9 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 1/5] ethdev: add firmware version get Qiming Yang
2017-01-16  7:05                         ` Andrew Rybchenko
2017-01-16  8:51                           ` Yang, Qiming
2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 2/5] net/e1000: " Qiming Yang
2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 3/5] net/ixgbe: " Qiming Yang
2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 4/5] net/i40e: " Qiming Yang
2017-01-16  5:44                       ` [dpdk-dev] [PATCH v9 5/5] ethtool: display firmware version Qiming Yang
2017-01-16 10:48                       ` [dpdk-dev] [PATCH v10 0/5] new API 'rte_eth_dev_fw_version_get' Qiming Yang
2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 1/5] ethdev: add firmware version get Qiming Yang
2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 2/5] net/e1000: " Qiming Yang
2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 3/5] net/ixgbe: " Qiming Yang
2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 4/5] net/i40e: " Qiming Yang
2017-01-16 10:48                         ` [dpdk-dev] [PATCH v10 5/5] ethtool: display firmware version Qiming Yang
2017-01-17 21:35                         ` [dpdk-dev] [PATCH v10 0/5] new API 'rte_eth_dev_fw_version_get' Thomas Monjalon
2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 2/5] net/e1000: add firmware version get Qiming Yang
2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 3/5] net/ixgbe: " Qiming Yang
2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 4/5] net/i40e: " Qiming Yang
2017-01-12  6:31                   ` [dpdk-dev] [PATCH v8 5/5] ethtool: display firmware version Qiming Yang
2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 2/5] net/e1000: add firmware version get Qiming Yang
2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 3/5] net/ixgbe: " Qiming Yang
2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 4/5] net/i40e: " Qiming Yang
2017-01-10  9:08             ` [dpdk-dev] [PATCH v6 5/5] ethtool: display firmware version Qiming Yang
2016-11-17  9:42 ` [dpdk-dev] [PATCH] ethtool: dispaly bus info and " Qiming Yang
2016-11-17  9:42 ` [dpdk-dev] [PATCH] i40e: add firmware version get Qiming Yang
2016-11-17  9:42 ` [dpdk-dev] [PATCH] ixgbe: " Qiming Yang
2016-11-17  9:42 ` [dpdk-dev] [PATCH 2/5] e1000: " Qiming Yang
2016-11-17  9:42 ` [dpdk-dev] [PATCH 3/5] ixgbe: " Qiming Yang
2016-11-17  9:42 ` [dpdk-dev] [PATCH 4/5] i40e: " Qiming Yang
2016-11-17  9:42 ` [dpdk-dev] [PATCH 5/5] ethtool: dispaly bus info and firmware version Qiming Yang
2016-11-18  1:10   ` Remy Horton

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