public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: "Björn Töpel" <bjorn@kernel.org>
To: netdev@vger.kernel.org, Donald Hunter <donald.hunter@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Tariq Toukan <tariqt@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>
Cc: "Björn Töpel" <bjorn@kernel.org>,
	"Maxime Chevallier" <maxime.chevallier@bootlin.com>,
	"Andrew Lunn" <andrew@lunn.ch>,
	"Michael Chan" <michael.chan@broadcom.com>,
	"Hariprasad Kelam" <hkelam@marvell.com>,
	"Ido Schimmel" <idosch@nvidia.com>,
	"Danielle Ratson" <danieller@nvidia.com>,
	linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org
Subject: [RFC net-next 3/4] ethtool: module: refactor fw flash init to reuse CMIS helpers
Date: Thu, 19 Feb 2026 14:00:44 +0100	[thread overview]
Message-ID: <20260219130050.2390226-4-bjorn@kernel.org> (raw)
In-Reply-To: <20260219130050.2390226-1-bjorn@kernel.org>

Simplify module_flash_fw_work_init() by reusing the module_is_cmis()
helper and ethtool_cmis_page_init() introduced in the loopback support
commit, replacing the open-coded CMIS type switch and manual EEPROM
page setup.

Remove the now-duplicate MODULE_EEPROM_PHYS_ID_I2C_ADDR define from
the firmware flash section since ethtool_cmis_page_init() sets the I2C
address internally.

Signed-off-by: Björn Töpel <bjorn@kernel.org>
---
 net/ethtool/module.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/net/ethtool/module.c b/net/ethtool/module.c
index 21d2f59985af..76e35dae1db2 100644
--- a/net/ethtool/module.c
+++ b/net/ethtool/module.c
@@ -486,7 +486,6 @@ static void module_flash_fw_work(struct work_struct *work)
 }
 
 #define MODULE_EEPROM_PHYS_ID_PAGE	0
-#define MODULE_EEPROM_PHYS_ID_I2C_ADDR	0x50
 
 static int module_flash_fw_work_init(struct ethtool_module_fw_flash *module_fw,
 				     struct net_device *dev,
@@ -501,31 +500,20 @@ static int module_flash_fw_work_init(struct ethtool_module_fw_flash *module_fw,
 	 * is located at I2C address 0x50, byte 0. See section 4.1 in SFF-8024,
 	 * revision 4.9.
 	 */
-	page_data.page = MODULE_EEPROM_PHYS_ID_PAGE;
-	page_data.offset = SFP_PHYS_ID;
-	page_data.length = sizeof(phys_id);
-	page_data.i2c_address = MODULE_EEPROM_PHYS_ID_I2C_ADDR;
+	ethtool_cmis_page_init(&page_data, MODULE_EEPROM_PHYS_ID_PAGE,
+			       SFP_PHYS_ID, sizeof(phys_id));
 	page_data.data = &phys_id;
 
 	err = ops->get_module_eeprom_by_page(dev, &page_data, extack);
 	if (err < 0)
 		return err;
 
-	switch (phys_id) {
-	case SFF8024_ID_QSFP_DD:
-	case SFF8024_ID_OSFP:
-	case SFF8024_ID_DSFP:
-	case SFF8024_ID_QSFP_PLUS_CMIS:
-	case SFF8024_ID_SFP_DD_CMIS:
-	case SFF8024_ID_SFP_PLUS_CMIS:
-		INIT_WORK(&module_fw->work, module_flash_fw_work);
-		break;
-	default:
-		NL_SET_ERR_MSG(extack,
-			       "Module type does not support firmware flashing");
+	if (!module_is_cmis(phys_id)) {
+		NL_SET_ERR_MSG(extack, "Module type does not support firmware flashing");
 		return -EOPNOTSUPP;
 	}
 
+	INIT_WORK(&module_fw->work, module_flash_fw_work);
 	return 0;
 }
 
-- 
2.53.0


  parent reply	other threads:[~2026-02-19 13:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-19 13:00 [RFC net-next 0/4] ethtool: CMIS module diagnostic loopback support Björn Töpel
2026-02-19 13:00 ` [RFC net-next 1/4] ethtool: module: Define CMIS loopback YAML spec and UAPI Björn Töpel
2026-02-19 13:00 ` [RFC net-next 2/4] ethtool: module: Add CMIS loopback GET/SET support Björn Töpel
2026-02-19 15:59   ` Andrew Lunn
2026-02-19 13:00 ` Björn Töpel [this message]
2026-02-19 13:00 ` [RFC net-next 4/4] net/mlx5e: Implement set_module_eeprom_by_page ethtool callback Björn Töpel
2026-02-19 13:16 ` [RFC net-next 0/4] ethtool: CMIS module diagnostic loopback support Björn Töpel
2026-02-19 15:51 ` Andrew Lunn
2026-02-20  0:05   ` Jakub Kicinski
2026-02-20 14:18     ` Andrew Lunn
2026-02-20 21:12       ` Jakub Kicinski
2026-02-22 19:58         ` Björn Töpel
2026-02-23 14:30           ` Andrew Lunn
2026-02-23 14:41             ` Björn Töpel
2026-02-23 23:04           ` Jakub Kicinski
2026-02-24 10:28             ` Björn Töpel
2026-02-25  4:04               ` Andrew Lunn
2026-02-25  8:39                 ` Björn Töpel
2026-02-25 13:14                   ` Andrew Lunn
2026-03-02  9:00                     ` Maxime Chevallier
2026-03-04 15:52                       ` Björn Töpel
2026-03-04 16:09                         ` Maxime Chevallier
2026-02-25 10:22           ` Maxime Chevallier
2026-02-25 11:20             ` Björn Töpel
2026-02-20  8:11   ` Björn Töpel

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=20260219130050.2390226-4-bjorn@kernel.org \
    --to=bjorn@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=danieller@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=hkelam@marvell.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=maxime.chevallier@bootlin.com \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.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