From cf1f21572897ffc85789fbb1792603967297f6fc Mon Sep 17 00:00:00 2001 From: Andrew Gallatin Date: Sun, 5 Apr 2026 15:58:10 -0400 Subject: net: Add SIOCGI2CPB ioctl & add page/bank fields to ifi2creq This commit adds page & bank fields to ifi2creq in preparation for adding CMIS support for 400g optics to ifconfig. The new ioctl SIOCGI2CPB is added, so that drivers can distinguish between callers asking for page/bank selection and legacy callers that simply failed to zero out all ifi2creq fields. The mlx5en(4) driver and iflib(4) driver frameork have been updated to use this new SIOCGI2CPB ioctl and support page/bank operations. A follow-on patchset will add support to ifconfig for reporting data from CMIS optics. This has been tested on Nvidia ConnectX-7 and Broadcom Thor2 (using out of tree driver) based NICs. Differential Revision: https://reviews.freebsd.org/D55912 Sponsored by: Netflix Inc. Reviewed by: kib --- sys/dev/mlx5/mlx5_en/mlx5_en_main.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c index 0baeab31b100..fb8b79c8f787 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c @@ -3728,6 +3728,8 @@ out: break; case SIOCGI2C: + /* fallthru */ + case SIOCGI2CPB: ifr = (struct ifreq *)data; /* @@ -3737,6 +3739,9 @@ out: error = copyin(ifr_data_get_ptr(ifr), &i2c, sizeof(i2c)); if (error) break; + /* ensure page and bank are 0 for legacy SIOCGI2C ioctls */ + if (command == SIOCGI2C) + i2c.page = i2c.bank = 0; if (i2c.len > sizeof(i2c.data)) { error = EINVAL; @@ -3778,8 +3783,17 @@ out: error = EINVAL; goto err_i2c; } + + if (i2c.bank != 0) { + mlx5_en_err(ifp, + "Query eeprom failed, Invalid Bank: %X\n", + i2c.bank); + error = EINVAL; + goto err_i2c; + } + error = mlx5_query_eeprom(priv->mdev, - read_addr, MLX5_EEPROM_LOW_PAGE, + read_addr, i2c.page, (uint32_t)i2c.offset, (uint32_t)i2c.len, module_num, (uint32_t *)i2c.data, &size_read); if (error) { @@ -3791,7 +3805,7 @@ out: if (i2c.len > MLX5_EEPROM_MAX_BYTES) { error = mlx5_query_eeprom(priv->mdev, - read_addr, MLX5_EEPROM_LOW_PAGE, + read_addr, i2c.page, (uint32_t)(i2c.offset + size_read), (uint32_t)(i2c.len - size_read), module_num, (uint32_t *)(i2c.data + size_read), &size_read); -- cgit v1.3