From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, kuba@kernel.org, edumazet@google.com,
pabeni@redhat.com, gospo@broadcom.com, vikas.gupta@broadcom.com
Subject: [PATCH net-next 4/6] bnxt_en: Refactor bnxt_get_module_info()
Date: Tue, 27 Sep 2022 20:58:42 -0400 [thread overview]
Message-ID: <1664326724-1415-5-git-send-email-michael.chan@broadcom.com> (raw)
In-Reply-To: <1664326724-1415-1-git-send-email-michael.chan@broadcom.com>
[-- Attachment #1: Type: text/plain, Size: 1940 bytes --]
From: Vikas Gupta <vikas.gupta@broadcom.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@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.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
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]
next prev parent reply other threads:[~2022-09-28 0:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-28 0:58 [PATCH net-next 0/6] bnxt_en: Driver updates Michael Chan
2022-09-28 0:58 ` [PATCH net-next 1/6] bnxt_en: Update firmware interface to 1.10.2.118 Michael Chan
2022-09-28 0:58 ` [PATCH net-next 2/6] bnxt_en: add support for QSFP optional EEPROM data Michael Chan
2022-09-28 0:58 ` [PATCH net-next 3/6] bnxt_en: Add bank parameter to bnxt_read_sfp_module_eeprom_info() Michael Chan
2022-09-28 0:58 ` Michael Chan [this message]
2022-09-28 0:58 ` [PATCH net-next 5/6] bnxt_en: add .get_module_eeprom_by_page() support Michael Chan
2022-09-28 9:34 ` Ido Schimmel
2022-09-29 5:35 ` Vikas Gupta
2022-09-29 7:32 ` Ido Schimmel
2022-09-30 10:05 ` Vikas Gupta
2022-09-28 0:58 ` [PATCH net-next 6/6] bnxt_en: check and resize NVRAM UPDATE entry before flashing Michael Chan
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=1664326724-1415-5-git-send-email-michael.chan@broadcom.com \
--to=michael.chan@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gospo@broadcom.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vikas.gupta@broadcom.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).