lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1664326724-1415-5-git-send-email-michael.chan@broadcom.com>
Date:   Tue, 27 Sep 2022 20:58:42 -0400
From:   Michael Chan <michael.chan@...adcom.com>
To:     davem@...emloft.net
Cc:     netdev@...r.kernel.org, kuba@...nel.org, edumazet@...gle.com,
        pabeni@...hat.com, gospo@...adcom.com, vikas.gupta@...adcom.com
Subject: [PATCH net-next 4/6] bnxt_en: Refactor bnxt_get_module_info()

From: Vikas Gupta <vikas.gupta@...adcom.com>

Add bnxt_module_status_check() helper to check if we can proceed to read
module eeprom data.  This helper will be used in the next patch when
adding get_module_eeprom_by_page().

Signed-off-by: Vikas Gupta <vikas.gupta@...adcom.com>
Signed-off-by: Michael Chan <michael.chan@...adcom.com>
---
 .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 23 +++++++++++++------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index 1c8a92fa2f2c..379afa670494 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -3184,25 +3184,34 @@ static int bnxt_read_sfp_module_eeprom_info(struct bnxt *bp, u16 i2c_addr,
 	return rc;
 }
 
-static int bnxt_get_module_info(struct net_device *dev,
-				struct ethtool_modinfo *modinfo)
+static int bnxt_module_status_check(struct bnxt *bp)
 {
-	u8 data[SFF_DIAG_SUPPORT_OFFSET + 1];
-	struct bnxt *bp = netdev_priv(dev);
-	int rc;
-
 	/* No point in going further if phy status indicates
 	 * module is not inserted or if it is powered down or
 	 * if it is of type 10GBase-T
 	 */
 	if (bp->link_info.module_status >
-		PORT_PHY_QCFG_RESP_MODULE_STATUS_WARNINGMSG)
+	    PORT_PHY_QCFG_RESP_MODULE_STATUS_WARNINGMSG)
 		return -EOPNOTSUPP;
 
 	/* This feature is not supported in older firmware versions */
 	if (bp->hwrm_spec_code < 0x10202)
 		return -EOPNOTSUPP;
 
+	return 0;
+}
+
+static int bnxt_get_module_info(struct net_device *dev,
+				struct ethtool_modinfo *modinfo)
+{
+	u8 data[SFF_DIAG_SUPPORT_OFFSET + 1];
+	struct bnxt *bp = netdev_priv(dev);
+	int rc;
+
+	rc = bnxt_module_status_check(bp);
+	if (rc)
+		return rc;
+
 	rc = bnxt_read_sfp_module_eeprom_info(bp, I2C_DEV_ADDR_A0, 0, 0, false,
 					      0, SFF_DIAG_SUPPORT_OFFSET + 1,
 					      data);
-- 
2.18.1


Download attachment "smime.p7s" of type "application/pkcs7-signature" (4209 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ