diff mbox series

[net-next] octeontx2-pf: Add support to read eeprom information

Message ID 20240125112133.8483-1-hkelam@marvell.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next] octeontx2-pf: Add support to read eeprom information | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 0 of 0 maintainers
netdev/build_clang success Errors and warnings before: 1095 this patch: 1095
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
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: 1095 this patch: 1095
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 45 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-01-26--00-00 (tests: 518)

Commit Message

Hariprasad Kelam Jan. 25, 2024, 11:21 a.m. UTC
Add support to read/decode EEPROM module information using ethtool.

Usage: ethtool -m <interface>

Signed-off-by: Christina Jacob <cjacob@marvell.com>
Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
---
 .../marvell/octeontx2/nic/otx2_ethtool.c      | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)

Comments

Andrew Lunn Jan. 26, 2024, 2:38 a.m. UTC | #1
On Thu, Jan 25, 2024 at 04:51:33PM +0530, Hariprasad Kelam wrote:
> Add support to read/decode EEPROM module information using ethtool.

It looks like you have a very primitive firmware here, which can only
return the first page of the SFPs EEPROM. What are your plans to make
this fully featured? Ideally you should not be using this API, but the
newer API which indicates what page you would like to read.

> Signed-off-by: Christina Jacob <cjacob@marvell.com>
> Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
> Signed-off-by: Sunil Goutham <sgoutham@marvell.com>

These seem to be in the wrong order.

      Andrew
Hariprasad Kelam Jan. 31, 2024, 11:37 a.m. UTC | #2
> On Thu, Jan 25, 2024 at 04:51:33PM +0530, Hariprasad Kelam wrote:
> > Add support to read/decode EEPROM module information using ethtool.
> 
> It looks like you have a very primitive firmware here, which can only return the
> first page of the SFPs EEPROM. What are your plans to make this fully
> featured? Ideally you should not be using this API, but the newer API which
> indicates what page you would like to read.
> 
 Our firmware currently supports reading only first page.  
Will submit V2 which uses new API considering the len/offset fields.

> > Signed-off-by: Christina Jacob <cjacob@marvell.com>
> > Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
> > Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
> 
> These seem to be in the wrong order.
> 
     I will fix in next version.
Thanks,
Hariprasad k
>       Andrew
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
index 2928898c7f8d..8e4e22a2817b 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
@@ -1185,6 +1185,37 @@  static void otx2_get_link_mode_info(u64 link_mode_bmap,
 			      otx2_link_modes);
 }
 
+static int otx2_get_module_info(struct net_device *netdev,
+				struct ethtool_modinfo *modinfo)
+{
+	struct otx2_nic *pfvf = netdev_priv(netdev);
+	struct cgx_fw_data *rsp;
+
+	rsp = otx2_get_fwdata(pfvf);
+	if (IS_ERR(rsp))
+		return PTR_ERR(rsp);
+
+	modinfo->type = rsp->fwdata.sfp_eeprom.sff_id;
+	modinfo->eeprom_len = SFP_EEPROM_SIZE;
+	return 0;
+}
+
+static int otx2_get_module_eeprom(struct net_device *netdev,
+				  struct ethtool_eeprom *ee,
+				  u8 *data)
+{
+	struct otx2_nic *pfvf = netdev_priv(netdev);
+	struct cgx_fw_data *rsp;
+
+	rsp = otx2_get_fwdata(pfvf);
+	if (IS_ERR(rsp))
+		return PTR_ERR(rsp);
+
+	memcpy(data, &rsp->fwdata.sfp_eeprom.buf, ee->len);
+
+	return 0;
+}
+
 static int otx2_get_link_ksettings(struct net_device *netdev,
 				   struct ethtool_link_ksettings *cmd)
 {
@@ -1343,6 +1374,8 @@  static const struct ethtool_ops otx2_ethtool_ops = {
 	.set_fecparam		= otx2_set_fecparam,
 	.get_link_ksettings     = otx2_get_link_ksettings,
 	.set_link_ksettings     = otx2_set_link_ksettings,
+	.get_module_info	= otx2_get_module_info,
+	.get_module_eeprom	= otx2_get_module_eeprom,
 };
 
 void otx2_set_ethtool_ops(struct net_device *netdev)