diff mbox series

[net-next,3/6] bnxt_en: Add bank parameter to bnxt_read_sfp_module_eeprom_info()

Message ID 1664326724-1415-4-git-send-email-michael.chan@broadcom.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series bnxt_en: Driver updates | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch warning WARNING: line length of 93 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Michael Chan Sept. 28, 2022, 12:58 a.m. UTC
From: Vikas Gupta <vikas.gupta@broadcom.com>

Newer firmware supports the bank number parameter in the
HWRM_PORT_PHY_I2C_READ command.  Modify the function to pass in
the optional bank number for eeprom.  Existing callers will not use the
new bank number.  It will be used in subsequent patches.

Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.h     |  1 +
 .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 24 ++++++++++++-------
 2 files changed, 16 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index c54f8c9ab3ad..0209f7caf490 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -2116,6 +2116,7 @@  struct bnxt {
 #define BNXT_PHY_FL_NO_FCS		PORT_PHY_QCAPS_RESP_FLAGS_NO_FCS
 #define BNXT_PHY_FL_NO_PAUSE		(PORT_PHY_QCAPS_RESP_FLAGS2_PAUSE_UNSUPPORTED << 8)
 #define BNXT_PHY_FL_NO_PFC		(PORT_PHY_QCAPS_RESP_FLAGS2_PFC_UNSUPPORTED << 8)
+#define BNXT_PHY_FL_BANK_SEL		(PORT_PHY_QCAPS_RESP_FLAGS2_BANK_ADDR_SUPPORTED << 8)
 
 	u8			num_tests;
 	struct bnxt_test_info	*test_info;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index 6596dca94c3d..1c8a92fa2f2c 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -3146,7 +3146,8 @@  static int bnxt_get_eee(struct net_device *dev, struct ethtool_eee *edata)
 }
 
 static int bnxt_read_sfp_module_eeprom_info(struct bnxt *bp, u16 i2c_addr,
-					    u16 page_number, u16 start_addr,
+					    u16 page_number, u8 bank,
+					    bool bank_sel_en, u16 start_addr,
 					    u16 data_length, u8 *buf)
 {
 	struct hwrm_port_phy_i2c_read_output *output;
@@ -3168,8 +3169,11 @@  static int bnxt_read_sfp_module_eeprom_info(struct bnxt *bp, u16 i2c_addr,
 		data_length -= xfer_size;
 		req->page_offset = cpu_to_le16(start_addr + byte_offset);
 		req->data_length = xfer_size;
-		req->enables = cpu_to_le32(start_addr + byte_offset ?
-				 PORT_PHY_I2C_READ_REQ_ENABLES_PAGE_OFFSET : 0);
+		req->bank_number = bank;
+		req->enables = cpu_to_le32((start_addr + byte_offset ?
+				PORT_PHY_I2C_READ_REQ_ENABLES_PAGE_OFFSET : 0) |
+				(bank_sel_en ?
+				PORT_PHY_I2C_READ_REQ_ENABLES_BANK_NUMBER : 0));
 		rc = hwrm_req_send(bp, req);
 		if (!rc)
 			memcpy(buf + byte_offset, output->data, xfer_size);
@@ -3199,8 +3203,8 @@  static int bnxt_get_module_info(struct net_device *dev,
 	if (bp->hwrm_spec_code < 0x10202)
 		return -EOPNOTSUPP;
 
-	rc = bnxt_read_sfp_module_eeprom_info(bp, I2C_DEV_ADDR_A0, 0, 0,
-					      SFF_DIAG_SUPPORT_OFFSET + 1,
+	rc = bnxt_read_sfp_module_eeprom_info(bp, I2C_DEV_ADDR_A0, 0, 0, false,
+					      0, SFF_DIAG_SUPPORT_OFFSET + 1,
 					      data);
 	if (!rc) {
 		u8 module_id = data[0];
@@ -3244,8 +3248,8 @@  static int bnxt_get_module_eeprom(struct net_device *dev,
 	u8 max_pages = 2;
 	int rc = 0;
 
-	rc = bnxt_read_sfp_module_eeprom_info(bp, I2C_DEV_ADDR_A0, 0, 0,
-					      SFF_DIAG_SUPPORT_OFFSET + 1,
+	rc = bnxt_read_sfp_module_eeprom_info(bp, I2C_DEV_ADDR_A0, 0, 0, false,
+					      0, SFF_DIAG_SUPPORT_OFFSET + 1,
 					      module_info);
 	if (rc)
 		return rc;
@@ -3261,7 +3265,8 @@  static int bnxt_get_module_eeprom(struct net_device *dev,
 	case SFF_MODULE_ID_QSFP28: {
 		u8 opt_pages;
 
-		rc = bnxt_read_sfp_module_eeprom_info(bp, I2C_DEV_ADDR_A0, 0,
+		rc = bnxt_read_sfp_module_eeprom_info(bp, I2C_DEV_ADDR_A0, 0, 0,
+						      false,
 						      SFF8636_OPT_PAGES_OFFSET,
 						      1, &opt_pages);
 		if (rc)
@@ -3330,7 +3335,8 @@  static int bnxt_get_module_eeprom(struct net_device *dev,
 
 		if (pg_addr[page]) {
 			rc = bnxt_read_sfp_module_eeprom_info(bp, pg_addr[page],
-							      raw_page, offset,
+							      raw_page, 0,
+							      false, offset,
 							      chunk, data);
 			if (rc)
 				return rc;