All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/2] mlxsw: Add support for QSFP-DD transceiver type
@ 2020-07-28 10:20 Ido Schimmel
  2020-07-28 10:20 ` [PATCH net-next v2 1/2] mlxsw: core: Add ethtool support for QSFP-DD transceivers Ido Schimmel
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ido Schimmel @ 2020-07-28 10:20 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, jiri, vadimp, andrew, popadrian1996, mlxsw, Ido Schimmel

From: Ido Schimmel <idosch@mellanox.com>

This patch set from Vadim adds support for Quad Small Form Factor
Pluggable Double Density (QSFP-DD) modules in mlxsw.

Patch #1 enables dumping of QSFP-DD module information through ethtool.

Patch #2 enables reading of temperature thresholds from QSFP-DD modules
for hwmon and thermal zone purposes.

Changes since v1 [1]:

Only rebase on top of net-next. After discussing with Andrew and Adrian
we agreed that current approach is OK and that in the future we can
follow Andrew's suggestion to "make a new API where user space can
request any pages it want, and specify the size of the page". This
should allow us "to work around known issues when manufactures get their
EEPROM wrong".

[1] https://lore.kernel.org/netdev/20200626144724.224372-1-idosch@idosch.org/#t

Vadim Pasternak (2):
  mlxsw: core: Add ethtool support for QSFP-DD transceivers
  mlxsw: core: Add support for temperature thresholds reading for
    QSFP-DD transceivers

 .../net/ethernet/mellanox/mlxsw/core_env.c    | 53 ++++++++++++++-----
 drivers/net/ethernet/mellanox/mlxsw/reg.h     |  3 ++
 2 files changed, 44 insertions(+), 12 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 1/2] mlxsw: core: Add ethtool support for QSFP-DD transceivers
  2020-07-28 10:20 [PATCH net-next v2 0/2] mlxsw: Add support for QSFP-DD transceiver type Ido Schimmel
@ 2020-07-28 10:20 ` Ido Schimmel
  2020-07-28 14:04   ` Andrew Lunn
  2020-07-28 10:20 ` [PATCH net-next v2 2/2] mlxsw: core: Add support for temperature thresholds reading " Ido Schimmel
  2020-07-28 20:28 ` [PATCH net-next v2 0/2] mlxsw: Add support for QSFP-DD transceiver type David Miller
  2 siblings, 1 reply; 5+ messages in thread
From: Ido Schimmel @ 2020-07-28 10:20 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, jiri, vadimp, andrew, popadrian1996, mlxsw, Ido Schimmel

From: Vadim Pasternak <vadimp@mellanox.com>

The Quad Small Form Factor Pluggable Double Density (QSFP-DD) hardware
specification defines a form factor that supports up to 400 Gbps in
aggregate over an 8x50-Gbps electrical interface. The QSFP-DD supports
both optical and copper interfaces.

Implementation is based on Common Management Interface Specification;
Rev 4.0 May 8, 2019. Table 8-2 "Identifier and Status Summary (Lower
Page)" from this spec defines "Id and Status" fields located at offsets
00h - 02h. Bit 2 at offset 02h ("Flat_mem") specifies QSFP EEPROM memory
mode, which could be "upper memory flat" or "paged". Flat memory mode is
coded "1", and indicates that only page 00h is implemented in EEPROM.
Paged memory is coded "0" and indicates that pages 00h, 01h, 02h, 10h
and 11h are implemented. Pages 10h and 11h are currently not supported
by the driver.

"Flat" memory mode is used for the passive copper transceivers. For this
type only page 00h (256 bytes) is available. "Paged" memory is used for
the optical transceivers. For this type pages 00h (256 bytes), 01h (128
bytes) and 02h (128 bytes) are available. Upper page 01h contains static
advertising field, while upper page 02h contains the module-defined
thresholds and lane-specific monitors.

Extend enumerator 'mlxsw_reg_mcia_eeprom_module_info_id' with additional
field 'MLXSW_REG_MCIA_EEPROM_MODULE_INFO_TYPE_ID'. This field is used to
indicate for QSFP-DD transceiver type which memory mode is to be used.

Expose 256 bytes buffer for QSFP-DD passive copper transceiver and
512 bytes buffer for optical.

Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 .../net/ethernet/mellanox/mlxsw/core_env.c    | 21 +++++++++++++++++--
 drivers/net/ethernet/mellanox/mlxsw/reg.h     |  2 ++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
index a7d86df7123f..1828dc569524 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
@@ -70,8 +70,9 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module,
 		if (qsfp) {
 			/* When reading upper pages 1, 2 and 3 the offset
 			 * starts at 128. Please refer to "QSFP+ Memory Map"
-			 * figure in SFF-8436 specification for graphical
-			 * depiction.
+			 * figure in SFF-8436 specification and to "CMIS Module
+			 * Memory Map" figure in CMIS specification for
+			 * graphical depiction.
 			 */
 			page = MLXSW_REG_MCIA_PAGE_GET(offset);
 			offset -= MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH * page;
@@ -221,6 +222,22 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
 		else
 			modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN / 2;
 		break;
+	case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD:
+		/* Use SFF_8636 as base type. ethtool should recognize specific
+		 * type through the identifier value.
+		 */
+		modinfo->type       = ETH_MODULE_SFF_8636;
+		/* Verify if module EEPROM is a flat memory. In case of flat
+		 * memory only page 00h (0-255 bytes) can be read. Otherwise
+		 * upper pages 01h and 02h can also be read. Upper pages 10h
+		 * and 11h are currently not supported by the driver.
+		 */
+		if (module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_TYPE_ID] &
+		    MLXSW_REG_MCIA_EEPROM_CMIS_FLAT_MEMORY)
+			modinfo->eeprom_len = ETH_MODULE_SFF_8636_LEN;
+		else
+			modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
+		break;
 	default:
 		return -EINVAL;
 	}
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
index 3c5b25495751..0638dfb23b7e 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
@@ -8607,6 +8607,7 @@ MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
 #define MLXSW_REG_MCIA_TH_PAGE_NUM		3
 #define MLXSW_REG_MCIA_PAGE0_LO			0
 #define MLXSW_REG_MCIA_TH_PAGE_OFF		0x80
+#define MLXSW_REG_MCIA_EEPROM_CMIS_FLAT_MEMORY	BIT(7)
 
 enum mlxsw_reg_mcia_eeprom_module_info_rev_id {
 	MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_UNSPC	= 0x00,
@@ -8625,6 +8626,7 @@ enum mlxsw_reg_mcia_eeprom_module_info_id {
 enum mlxsw_reg_mcia_eeprom_module_info {
 	MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID,
 	MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID,
+	MLXSW_REG_MCIA_EEPROM_MODULE_INFO_TYPE_ID,
 	MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE,
 };
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 2/2] mlxsw: core: Add support for temperature thresholds reading for QSFP-DD transceivers
  2020-07-28 10:20 [PATCH net-next v2 0/2] mlxsw: Add support for QSFP-DD transceiver type Ido Schimmel
  2020-07-28 10:20 ` [PATCH net-next v2 1/2] mlxsw: core: Add ethtool support for QSFP-DD transceivers Ido Schimmel
@ 2020-07-28 10:20 ` Ido Schimmel
  2020-07-28 20:28 ` [PATCH net-next v2 0/2] mlxsw: Add support for QSFP-DD transceiver type David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Ido Schimmel @ 2020-07-28 10:20 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, jiri, vadimp, andrew, popadrian1996, mlxsw, Ido Schimmel

From: Vadim Pasternak <vadimp@mellanox.com>

Allow QSFP-DD transceivers temperature thresholds reading for hardware
monitoring and thermal control.

For this type, the thresholds are located in page 02h according to the
"Module and Lane Thresholds" description from Common Management
Interface Specification.

Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 .../net/ethernet/mellanox/mlxsw/core_env.c    | 32 +++++++++++++------
 drivers/net/ethernet/mellanox/mlxsw/reg.h     |  1 +
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
index 1828dc569524..44fa02cbb683 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
@@ -11,7 +11,7 @@
 #include "reg.h"
 
 static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
-					  bool *qsfp)
+					  bool *qsfp, bool *cmis)
 {
 	char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
 	char mcia_pl[MLXSW_REG_MCIA_LEN];
@@ -25,15 +25,19 @@ static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
 		return err;
 	mlxsw_reg_mcia_eeprom_memcpy_from(mcia_pl, eeprom_tmp);
 	ident = eeprom_tmp[0];
+	*cmis = false;
 	switch (ident) {
 	case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP:
 		*qsfp = false;
 		break;
 	case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP: /* fall-through */
 	case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS: /* fall-through */
-	case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28: /* fall-through */
+	case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28:
+		*qsfp = true;
+		break;
 	case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD:
 		*qsfp = true;
+		*cmis = true;
 		break;
 	default:
 		return -EINVAL;
@@ -117,7 +121,8 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
 	char mcia_pl[MLXSW_REG_MCIA_LEN] = {0};
 	char mtmp_pl[MLXSW_REG_MTMP_LEN];
 	unsigned int module_temp;
-	bool qsfp;
+	bool qsfp, cmis;
+	int page;
 	int err;
 
 	mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
@@ -141,21 +146,28 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
 	 */
 
 	/* Validate module identifier value. */
-	err = mlxsw_env_validate_cable_ident(core, module, &qsfp);
+	err = mlxsw_env_validate_cable_ident(core, module, &qsfp, &cmis);
 	if (err)
 		return err;
 
-	if (qsfp)
-		mlxsw_reg_mcia_pack(mcia_pl, module, 0,
-				    MLXSW_REG_MCIA_TH_PAGE_NUM,
+	if (qsfp) {
+		/* For QSFP/CMIS module-defined thresholds are located in page
+		 * 02h, otherwise in page 03h.
+		 */
+		if (cmis)
+			page = MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM;
+		else
+			page = MLXSW_REG_MCIA_TH_PAGE_NUM;
+		mlxsw_reg_mcia_pack(mcia_pl, module, 0, page,
 				    MLXSW_REG_MCIA_TH_PAGE_OFF + off,
 				    MLXSW_REG_MCIA_TH_ITEM_SIZE,
 				    MLXSW_REG_MCIA_I2C_ADDR_LOW);
-	else
+	} else {
 		mlxsw_reg_mcia_pack(mcia_pl, module, 0,
 				    MLXSW_REG_MCIA_PAGE0_LO,
 				    off, MLXSW_REG_MCIA_TH_ITEM_SIZE,
 				    MLXSW_REG_MCIA_I2C_ADDR_HIGH);
+	}
 
 	err = mlxsw_reg_query(core, MLXSW_REG(mcia), mcia_pl);
 	if (err)
@@ -252,8 +264,8 @@ int mlxsw_env_get_module_eeprom(struct net_device *netdev,
 {
 	int offset = ee->offset;
 	unsigned int read_size;
+	bool qsfp, cmis;
 	int i = 0;
-	bool qsfp;
 	int err;
 
 	if (!ee->len)
@@ -261,7 +273,7 @@ int mlxsw_env_get_module_eeprom(struct net_device *netdev,
 
 	memset(data, 0, ee->len);
 	/* Validate module identifier value. */
-	err = mlxsw_env_validate_cable_ident(mlxsw_core, module, &qsfp);
+	err = mlxsw_env_validate_cable_ident(mlxsw_core, module, &qsfp, &cmis);
 	if (err)
 		return err;
 
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
index 0638dfb23b7e..1d23ad70e83d 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
@@ -8605,6 +8605,7 @@ MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
 #define MLXSW_REG_MCIA_PAGE0_LO_OFF		0xa0
 #define MLXSW_REG_MCIA_TH_ITEM_SIZE		2
 #define MLXSW_REG_MCIA_TH_PAGE_NUM		3
+#define MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM		2
 #define MLXSW_REG_MCIA_PAGE0_LO			0
 #define MLXSW_REG_MCIA_TH_PAGE_OFF		0x80
 #define MLXSW_REG_MCIA_EEPROM_CMIS_FLAT_MEMORY	BIT(7)
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v2 1/2] mlxsw: core: Add ethtool support for QSFP-DD transceivers
  2020-07-28 10:20 ` [PATCH net-next v2 1/2] mlxsw: core: Add ethtool support for QSFP-DD transceivers Ido Schimmel
@ 2020-07-28 14:04   ` Andrew Lunn
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2020-07-28 14:04 UTC (permalink / raw)
  To: Ido Schimmel
  Cc: netdev, davem, kuba, jiri, vadimp, popadrian1996, mlxsw, Ido Schimmel

On Tue, Jul 28, 2020 at 01:20:15PM +0300, Ido Schimmel wrote:
> From: Vadim Pasternak <vadimp@mellanox.com>
> 
> The Quad Small Form Factor Pluggable Double Density (QSFP-DD) hardware
> specification defines a form factor that supports up to 400 Gbps in
> aggregate over an 8x50-Gbps electrical interface. The QSFP-DD supports
> both optical and copper interfaces.
> 
> Implementation is based on Common Management Interface Specification;
> Rev 4.0 May 8, 2019. Table 8-2 "Identifier and Status Summary (Lower
> Page)" from this spec defines "Id and Status" fields located at offsets
> 00h - 02h. Bit 2 at offset 02h ("Flat_mem") specifies QSFP EEPROM memory
> mode, which could be "upper memory flat" or "paged". Flat memory mode is
> coded "1", and indicates that only page 00h is implemented in EEPROM.
> Paged memory is coded "0" and indicates that pages 00h, 01h, 02h, 10h
> and 11h are implemented. Pages 10h and 11h are currently not supported
> by the driver.
> 
> "Flat" memory mode is used for the passive copper transceivers. For this
> type only page 00h (256 bytes) is available. "Paged" memory is used for
> the optical transceivers. For this type pages 00h (256 bytes), 01h (128
> bytes) and 02h (128 bytes) are available. Upper page 01h contains static
> advertising field, while upper page 02h contains the module-defined
> thresholds and lane-specific monitors.
> 
> Extend enumerator 'mlxsw_reg_mcia_eeprom_module_info_id' with additional
> field 'MLXSW_REG_MCIA_EEPROM_MODULE_INFO_TYPE_ID'. This field is used to
> indicate for QSFP-DD transceiver type which memory mode is to be used.
> 
> Expose 256 bytes buffer for QSFP-DD passive copper transceiver and
> 512 bytes buffer for optical.
> 
> Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v2 0/2] mlxsw: Add support for QSFP-DD transceiver type
  2020-07-28 10:20 [PATCH net-next v2 0/2] mlxsw: Add support for QSFP-DD transceiver type Ido Schimmel
  2020-07-28 10:20 ` [PATCH net-next v2 1/2] mlxsw: core: Add ethtool support for QSFP-DD transceivers Ido Schimmel
  2020-07-28 10:20 ` [PATCH net-next v2 2/2] mlxsw: core: Add support for temperature thresholds reading " Ido Schimmel
@ 2020-07-28 20:28 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2020-07-28 20:28 UTC (permalink / raw)
  To: idosch; +Cc: netdev, kuba, jiri, vadimp, andrew, popadrian1996, mlxsw, idosch

From: Ido Schimmel <idosch@idosch.org>
Date: Tue, 28 Jul 2020 13:20:14 +0300

> From: Ido Schimmel <idosch@mellanox.com>
> 
> This patch set from Vadim adds support for Quad Small Form Factor
> Pluggable Double Density (QSFP-DD) modules in mlxsw.
> 
> Patch #1 enables dumping of QSFP-DD module information through ethtool.
> 
> Patch #2 enables reading of temperature thresholds from QSFP-DD modules
> for hwmon and thermal zone purposes.
> 
> Changes since v1 [1]:
> 
> Only rebase on top of net-next. After discussing with Andrew and Adrian
> we agreed that current approach is OK and that in the future we can
> follow Andrew's suggestion to "make a new API where user space can
> request any pages it want, and specify the size of the page". This
> should allow us "to work around known issues when manufactures get their
> EEPROM wrong".
> 
> [1] https://lore.kernel.org/netdev/20200626144724.224372-1-idosch@idosch.org/#t

Series applied, thank you.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-28 20:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28 10:20 [PATCH net-next v2 0/2] mlxsw: Add support for QSFP-DD transceiver type Ido Schimmel
2020-07-28 10:20 ` [PATCH net-next v2 1/2] mlxsw: core: Add ethtool support for QSFP-DD transceivers Ido Schimmel
2020-07-28 14:04   ` Andrew Lunn
2020-07-28 10:20 ` [PATCH net-next v2 2/2] mlxsw: core: Add support for temperature thresholds reading " Ido Schimmel
2020-07-28 20:28 ` [PATCH net-next v2 0/2] mlxsw: Add support for QSFP-DD transceiver type David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.