From: Shannon Nelson <snelson@pensando.io>
To: netdev@vger.kernel.org, davem@davemloft.net
Cc: Shannon Nelson <snelson@pensando.io>
Subject: [PATCH net-next 4/5] ionic: return error for unknown xcvr type
Date: Sun, 15 Mar 2020 19:14:27 -0700 [thread overview]
Message-ID: <20200316021428.48919-5-snelson@pensando.io> (raw)
In-Reply-To: <20200316021428.48919-1-snelson@pensando.io>
If we don't recognize the transceiver type, return an error
so that ethtool doesn't try dumping bogus eeprom contents.
Signed-off-by: Shannon Nelson <snelson@pensando.io>
---
.../net/ethernet/pensando/ionic/ionic_ethtool.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
index a233716eac29..3f92f301a020 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
@@ -694,7 +694,7 @@ static int ionic_get_module_info(struct net_device *netdev,
default:
netdev_info(netdev, "unknown xcvr type 0x%02x\n",
xcvr->sprom[0]);
- break;
+ return -EINVAL;
}
return 0;
@@ -714,7 +714,19 @@ static int ionic_get_module_eeprom(struct net_device *netdev,
/* The NIC keeps the module prom up-to-date in the DMA space
* so we can simply copy the module bytes into the data buffer.
*/
+
xcvr = &idev->port_info->status.xcvr;
+ switch (xcvr->sprom[0]) {
+ case 0x03: /* SFP */
+ case 0x0D: /* QSFP */
+ case 0x11: /* QSFP28 */
+ break;
+ default:
+ netdev_info(netdev, "unknown xcvr type 0x%02x\n",
+ xcvr->sprom[0]);
+ return -EINVAL;
+ }
+
len = min_t(u32, sizeof(xcvr->sprom), ee->len);
do {
--
2.17.1
next prev parent reply other threads:[~2020-03-16 2:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-16 2:14 [PATCH net-next 0/5] ionic bits and bytes Shannon Nelson
2020-03-16 2:14 ` [PATCH net-next 1/5] ionic: don't register mgmt device as devlink port Shannon Nelson
2020-03-16 2:14 ` [PATCH net-next 2/5] ionic: deinit rss only if selected Shannon Nelson
2020-03-16 2:14 ` [PATCH net-next 3/5] ionic: remove adminq napi instance Shannon Nelson
2020-03-16 6:52 ` Leon Romanovsky
2020-03-16 18:01 ` Shannon Nelson
2020-03-16 2:14 ` Shannon Nelson [this message]
2020-03-16 2:14 ` [PATCH net-next 5/5] ionic: add decode for IONIC_RC_ENOSUPP Shannon Nelson
2020-03-16 6:49 ` Leon Romanovsky
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=20200316021428.48919-5-snelson@pensando.io \
--to=snelson@pensando.io \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.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).