[dpdk-dev,v5,2/5] net/e1000: add firmware version get

Message ID 1483848695-44643-3-git-send-email-qiming.yang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel compilation success Compilation OK

Commit Message

Qiming Yang Jan. 8, 2017, 4:11 a.m. UTC
  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(+)
  

Comments

Stephen Hemminger Jan. 8, 2017, 11:03 p.m. UTC | #1
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 Yang Jan. 9, 2017, 1:48 a.m. UTC | #2
-----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.
  

Patch

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