DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jiawen Wu <jiawenwu@trustnetic.com>
To: dev@dpdk.org
Cc: Jiawen Wu <jiawenwu@trustnetic.com>
Subject: [dpdk-dev] [PATCH v2 3/7] net/txgbe: move firmware version get function to base code
Date: Tue, 16 Mar 2021 18:51:45 +0800	[thread overview]
Message-ID: <20210316105149.110904-4-jiawenwu@trustnetic.com> (raw)
In-Reply-To: <20210316105149.110904-1-jiawenwu@trustnetic.com>

Move firmware version get function to base code,
and store firmware version in PHY info.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/txgbe/base/txgbe_dummy.h |  6 ++++++
 drivers/net/txgbe/base/txgbe_hw.c    |  4 ++++
 drivers/net/txgbe/base/txgbe_phy.c   | 12 ++++++++++++
 drivers/net/txgbe/base/txgbe_phy.h   |  1 +
 drivers/net/txgbe/base/txgbe_type.h  |  2 ++
 drivers/net/txgbe/txgbe_ethdev.c     |  5 +----
 6 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/net/txgbe/base/txgbe_dummy.h b/drivers/net/txgbe/base/txgbe_dummy.h
index c9f2e7893..b62501d65 100644
--- a/drivers/net/txgbe/base/txgbe_dummy.h
+++ b/drivers/net/txgbe/base/txgbe_dummy.h
@@ -424,6 +424,11 @@ static inline s32 txgbe_phy_check_link_dummy(struct txgbe_hw *TUP0, u32 *TUP1,
 {
 	return TXGBE_ERR_OPS_DUMMY;
 }
+static inline s32 txgbe_get_phy_fw_version_dummy(struct txgbe_hw *TUP0,
+					u32 *TUP1)
+{
+	return TXGBE_ERR_OPS_DUMMY;
+}
 static inline s32 txgbe_phy_read_i2c_byte_dummy(struct txgbe_hw *TUP0, u8 TUP1,
 					u8 TUP2, u8 *TUP3)
 {
@@ -628,6 +633,7 @@ static inline void txgbe_init_ops_dummy(struct txgbe_hw *hw)
 	hw->phy.setup_link = txgbe_phy_setup_link_dummy;
 	hw->phy.setup_link_speed = txgbe_phy_setup_link_speed_dummy;
 	hw->phy.check_link = txgbe_phy_check_link_dummy;
+	hw->phy.get_fw_version = txgbe_get_phy_fw_version_dummy;
 	hw->phy.read_i2c_byte = txgbe_phy_read_i2c_byte_dummy;
 	hw->phy.write_i2c_byte = txgbe_phy_write_i2c_byte_dummy;
 	hw->phy.read_i2c_sff8472 = txgbe_phy_read_i2c_sff8472_dummy;
diff --git a/drivers/net/txgbe/base/txgbe_hw.c b/drivers/net/txgbe/base/txgbe_hw.c
index 81efb6444..26562f50d 100644
--- a/drivers/net/txgbe/base/txgbe_hw.c
+++ b/drivers/net/txgbe/base/txgbe_hw.c
@@ -323,6 +323,9 @@ s32 txgbe_init_hw(struct txgbe_hw *hw)
 
 	DEBUGFUNC("txgbe_init_hw");
 
+	/* Get firmware version */
+	hw->phy.get_fw_version(hw, &hw->fw_version);
+
 	/* Reset the hardware */
 	status = hw->mac.reset_hw(hw);
 	if (status == 0 || status == TXGBE_ERR_SFP_NOT_PRESENT) {
@@ -2774,6 +2777,7 @@ s32 txgbe_init_ops_pf(struct txgbe_hw *hw)
 	phy->write_reg_mdi = txgbe_write_phy_reg_mdi;
 	phy->setup_link = txgbe_setup_phy_link;
 	phy->setup_link_speed = txgbe_setup_phy_link_speed;
+	phy->get_fw_version = txgbe_get_phy_fw_version;
 	phy->read_i2c_byte = txgbe_read_i2c_byte;
 	phy->write_i2c_byte = txgbe_write_i2c_byte;
 	phy->read_i2c_sff8472 = txgbe_read_i2c_sff8472;
diff --git a/drivers/net/txgbe/base/txgbe_phy.c b/drivers/net/txgbe/base/txgbe_phy.c
index 37c41099f..1ca6e35a4 100644
--- a/drivers/net/txgbe/base/txgbe_phy.c
+++ b/drivers/net/txgbe/base/txgbe_phy.c
@@ -558,6 +558,18 @@ s32 txgbe_setup_phy_link_speed(struct txgbe_hw *hw,
 	return 0;
 }
 
+s32 txgbe_get_phy_fw_version(struct txgbe_hw *hw, u32 *fw_version)
+{
+	u16 eeprom_verh, eeprom_verl;
+
+	hw->rom.readw_sw(hw, TXGBE_EEPROM_VERSION_H, &eeprom_verh);
+	hw->rom.readw_sw(hw, TXGBE_EEPROM_VERSION_L, &eeprom_verl);
+
+	*fw_version = (eeprom_verh << 16) | eeprom_verl;
+
+	return 0;
+}
+
 /**
  * txgbe_get_copper_speeds_supported - Get copper link speeds from phy
  * @hw: pointer to hardware structure
diff --git a/drivers/net/txgbe/base/txgbe_phy.h b/drivers/net/txgbe/base/txgbe_phy.h
index 5aec1d28f..4a5b90077 100644
--- a/drivers/net/txgbe/base/txgbe_phy.h
+++ b/drivers/net/txgbe/base/txgbe_phy.h
@@ -340,6 +340,7 @@ s32 txgbe_setup_phy_link(struct txgbe_hw *hw);
 s32 txgbe_setup_phy_link_speed(struct txgbe_hw *hw,
 				       u32 speed,
 				       bool autoneg_wait_to_complete);
+s32 txgbe_get_phy_fw_version(struct txgbe_hw *hw, u32 *fw_version);
 s32 txgbe_get_copper_link_capabilities(struct txgbe_hw *hw,
 					       u32 *speed,
 					       bool *autoneg);
diff --git a/drivers/net/txgbe/base/txgbe_type.h b/drivers/net/txgbe/base/txgbe_type.h
index 008fcb25b..89d68d81f 100644
--- a/drivers/net/txgbe/base/txgbe_type.h
+++ b/drivers/net/txgbe/base/txgbe_type.h
@@ -647,6 +647,7 @@ struct txgbe_phy_info {
 	s32 (*setup_link_speed)(struct txgbe_hw *hw, u32 speed,
 				bool autoneg_wait_to_complete);
 	s32 (*check_link)(struct txgbe_hw *hw, u32 *speed, bool *link_up);
+	s32 (*get_fw_version)(struct txgbe_hw *hw, u32 *fw_version);
 	s32 (*read_i2c_byte)(struct txgbe_hw *hw, u8 byte_offset,
 				u8 dev_addr, u8 *data);
 	s32 (*write_i2c_byte)(struct txgbe_hw *hw, u8 byte_offset,
@@ -783,6 +784,7 @@ struct txgbe_hw {
 	u16 nb_rx_queues;
 	u16 nb_tx_queues;
 
+	u32 fw_version;
 	u32 mode;
 	enum txgbe_link_status {
 		TXGBE_LINK_STATUS_NONE = 0,
diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index cc7270a1c..f951ecf4d 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -2570,14 +2570,11 @@ static int
 txgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
 {
 	struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
-	u16 eeprom_verh, eeprom_verl;
 	u32 etrack_id;
 	int ret;
 
-	hw->rom.readw_sw(hw, TXGBE_EEPROM_VERSION_H, &eeprom_verh);
-	hw->rom.readw_sw(hw, TXGBE_EEPROM_VERSION_L, &eeprom_verl);
+	hw->phy.get_fw_version(hw, &etrack_id);
 
-	etrack_id = (eeprom_verh << 16) | eeprom_verl;
 	ret = snprintf(fw_version, fw_size, "0x%08x", etrack_id);
 
 	ret += 1; /* add the size of '\0' */
-- 
2.27.0




  parent reply	other threads:[~2021-03-16 10:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-16 10:51 [dpdk-dev] [PATCH v2 0/7] txgbe backplane AN training Jiawen Wu
2021-03-16 10:51 ` [dpdk-dev] [PATCH v2 1/7] net/txgbe: update device ID Jiawen Wu
2021-03-16 10:51 ` [dpdk-dev] [PATCH v2 2/7] net/txgbe: add device arguments Jiawen Wu
2021-03-24 10:59   ` Ferruh Yigit
2021-03-24 11:01     ` Ferruh Yigit
2021-03-16 10:51 ` Jiawen Wu [this message]
2021-03-16 10:51 ` [dpdk-dev] [PATCH v2 4/7] net/txgbe: update link setup process of backplane NICs Jiawen Wu
2021-03-16 10:51 ` [dpdk-dev] [PATCH v2 5/7] net/txgbe/base: support to handle backplane AN73 flow Jiawen Wu
2021-03-16 10:51 ` [dpdk-dev] [PATCH v2 6/7] net/txgbe: handle AN interrupt and link update Jiawen Wu
2021-03-16 10:51 ` [dpdk-dev] [PATCH v2 7/7] net/txgbe: add FFE parameters for user debugging Jiawen Wu
2021-03-23 17:33 ` [dpdk-dev] [PATCH v2 0/7] txgbe backplane AN training Ferruh Yigit
2021-03-24  1:57   ` Jiawen Wu
2021-03-24 10:36     ` Ferruh Yigit

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=20210316105149.110904-4-jiawenwu@trustnetic.com \
    --to=jiawenwu@trustnetic.com \
    --cc=dev@dpdk.org \
    /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).