netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: davem@davemloft.net, kuba@kernel.org
Cc: Sasha Neftin <sasha.neftin@intel.com>,
	netdev@vger.kernel.org, sassmann@redhat.com,
	anthony.l.nguyen@intel.com
Subject: [PATCH net-next 06/15] igc: Expose the gPHY firmware version
Date: Wed,  3 Feb 2021 16:42:50 -0800	[thread overview]
Message-ID: <20210204004259.3662059-7-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20210204004259.3662059-1-anthony.l.nguyen@intel.com>

From: Sasha Neftin <sasha.neftin@intel.com>

Extend reporting of NVM image version to include the gPHY (i225 PHY)
firmware version.

Signed-off-by: Sasha Neftin <sasha.neftin@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/igc/igc.h         |  2 +-
 drivers/net/ethernet/intel/igc/igc_ethtool.c |  9 +++++++--
 drivers/net/ethernet/intel/igc/igc_phy.c     | 18 ++++++++++++++++++
 drivers/net/ethernet/intel/igc/igc_phy.h     |  1 +
 drivers/net/ethernet/intel/igc/igc_regs.h    |  1 +
 5 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h
index 2d8b1716a20c..5d2809dfd06a 100644
--- a/drivers/net/ethernet/intel/igc/igc.h
+++ b/drivers/net/ethernet/intel/igc/igc.h
@@ -218,7 +218,7 @@ struct igc_adapter {
 	struct timespec64 prev_ptp_time; /* Pre-reset PTP clock */
 	ktime_t ptp_reset_start; /* Reset time in clock mono */
 
-	char fw_version[16];
+	char fw_version[32];
 };
 
 void igc_up(struct igc_adapter *adapter);
diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index 7dd1ca7f3ed5..a3811d7e59bc 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -131,16 +131,21 @@ static void igc_ethtool_get_drvinfo(struct net_device *netdev,
 	struct igc_adapter *adapter = netdev_priv(netdev);
 	struct igc_hw *hw = &adapter->hw;
 	u16 nvm_version = 0;
+	u16 gphy_version;
 
 	strscpy(drvinfo->driver, igc_driver_name, sizeof(drvinfo->driver));
 
 	/* NVM image version is reported as firmware version for i225 device */
 	hw->nvm.ops.read(hw, IGC_NVM_DEV_STARTER, 1, &nvm_version);
 
+	/* gPHY firmware version is reported as PHY FW version */
+	gphy_version = igc_read_phy_fw_version(hw);
+
 	scnprintf(adapter->fw_version,
 		  sizeof(adapter->fw_version),
-		  "%x",
-		  nvm_version);
+		  "%x:%x",
+		  nvm_version,
+		  gphy_version);
 
 	strscpy(drvinfo->fw_version, adapter->fw_version,
 		sizeof(drvinfo->fw_version));
diff --git a/drivers/net/ethernet/intel/igc/igc_phy.c b/drivers/net/ethernet/intel/igc/igc_phy.c
index 8e1799508edc..83aeb5e7076f 100644
--- a/drivers/net/ethernet/intel/igc/igc_phy.c
+++ b/drivers/net/ethernet/intel/igc/igc_phy.c
@@ -791,3 +791,21 @@ s32 igc_read_phy_reg_gpy(struct igc_hw *hw, u32 offset, u16 *data)
 
 	return ret_val;
 }
+
+/**
+ * igc_read_phy_fw_version - Read gPHY firmware version
+ * @hw: pointer to the HW structure
+ */
+u16 igc_read_phy_fw_version(struct igc_hw *hw)
+{
+	struct igc_phy_info *phy = &hw->phy;
+	u16 gphy_version = 0;
+	u16 ret_val;
+
+	/* NVM image version is reported as firmware version for i225 device */
+	ret_val = phy->ops.read_reg(hw, IGC_GPHY_VERSION, &gphy_version);
+	if (ret_val)
+		hw_dbg("igc_phy: read wrong gphy version\n");
+
+	return gphy_version;
+}
diff --git a/drivers/net/ethernet/intel/igc/igc_phy.h b/drivers/net/ethernet/intel/igc/igc_phy.h
index 25cba33de7e2..1b031372d206 100644
--- a/drivers/net/ethernet/intel/igc/igc_phy.h
+++ b/drivers/net/ethernet/intel/igc/igc_phy.h
@@ -17,5 +17,6 @@ void igc_power_up_phy_copper(struct igc_hw *hw);
 void igc_power_down_phy_copper(struct igc_hw *hw);
 s32 igc_write_phy_reg_gpy(struct igc_hw *hw, u32 offset, u16 data);
 s32 igc_read_phy_reg_gpy(struct igc_hw *hw, u32 offset, u16 *data);
+u16 igc_read_phy_fw_version(struct igc_hw *hw);
 
 #endif
diff --git a/drivers/net/ethernet/intel/igc/igc_regs.h b/drivers/net/ethernet/intel/igc/igc_regs.h
index b52dd9d737e8..3e5cb7aef9da 100644
--- a/drivers/net/ethernet/intel/igc/igc_regs.h
+++ b/drivers/net/ethernet/intel/igc/igc_regs.h
@@ -13,6 +13,7 @@
 #define IGC_MDICNFG		0x00E04  /* MDC/MDIO Configuration - RW */
 #define IGC_CONNSW		0x00034  /* Copper/Fiber switch control - RW */
 #define IGC_I225_PHPM		0x00E14  /* I225 PHY Power Management */
+#define IGC_GPHY_VERSION	0x0001E  /* I225 gPHY Firmware Version */
 
 /* Internal Packet Buffer Size Registers */
 #define IGC_RXPBS		0x02404  /* Rx Packet Buffer Size - RW */
-- 
2.26.2


  parent reply	other threads:[~2021-02-04  0:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04  0:42 [PATCH net-next 00/15][pull request] 1GbE Intel Wired LAN Driver Updates 2021-02-03 Tony Nguyen
2021-02-04  0:42 ` [PATCH net-next 01/15] igc: Clean up nvm_operations structure Tony Nguyen
2021-02-04  0:42 ` [PATCH net-next 02/15] igc: Remove igc_set_fw_version comment Tony Nguyen
2021-02-04  0:42 ` [PATCH net-next 03/15] igc: Remove MULR mask define Tony Nguyen
2021-02-04  0:42 ` [PATCH net-next 04/15] igc: Add Host Good Packets Transmitted Count Tony Nguyen
2021-02-04  0:42 ` [PATCH net-next 05/15] igc: Expose the NVM version Tony Nguyen
2021-02-04  0:42 ` Tony Nguyen [this message]
2021-02-04  0:42 ` [PATCH net-next 07/15] igc: Prefer strscpy over strlcpy Tony Nguyen
2021-02-04  0:42 ` [PATCH net-next 08/15] igc: Remove unused local receiver mask Tony Nguyen
2021-02-04  0:42 ` [PATCH net-next 09/15] igc: Remove unused FUNC_1 mask Tony Nguyen
2021-02-04  0:42 ` [PATCH net-next 10/15] igc: Fix TDBAL register show incorrect value Tony Nguyen
2021-02-04  0:42 ` [PATCH net-next 11/15] igb: fix " Tony Nguyen
2021-02-04  0:42 ` [PATCH net-next 12/15] igb: Enable RSS for Intel I211 Ethernet Controller Tony Nguyen
2021-02-04  0:42 ` [PATCH net-next 13/15] igb: remove h from printk format specifier Tony Nguyen
2021-02-04  0:42 ` [PATCH net-next 14/15] e1000e: remove the redundant value assignment in e1000_update_nvm_checksum_spt Tony Nguyen
2021-02-04  0:42 ` [PATCH net-next 15/15] e1000: drop unneeded assignment in e1000_set_itr() Tony Nguyen
2021-02-05  5:40 ` [PATCH net-next 00/15][pull request] 1GbE Intel Wired LAN Driver Updates 2021-02-03 patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210204004259.3662059-7-anthony.l.nguyen@intel.com \
    --to=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sasha.neftin@intel.com \
    --cc=sassmann@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).