All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2 0/3] mlxsw: Fixes
@ 2024-04-18 13:46 Petr Machata
  2024-04-18 13:46 ` [PATCH net v2 1/3] mlxsw: core: Unregister EMAD trap using FORWARD action Petr Machata
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Petr Machata @ 2024-04-18 13:46 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: Ido Schimmel, Petr Machata, mlxsw

This patchset fixes the following issues:

- During driver de-initialization the driver unregisters the EMAD
  response trap by setting its action to DISCARD. However the manual
  only permits TRAP and FORWARD, and future firmware versions will
  enforce this.

  In patch #1, suppress the error message by aligning the driver to the
  manual and use a FORWARD (NOP) action when unregistering the trap.

- The driver queries the Management Capabilities Mask (MCAM) register
  during initialization to understand if certain features are supported.

  However, not all firmware versions support this register, leading to
  the driver failing to load.

  Patches #2 and #3 fix this issue by treating an error in the register
  query as an indication that the feature is not supported.

v2:
- Patch #2:
    - Make mlxsw_env_max_module_eeprom_len_query() void

Ido Schimmel (3):
  mlxsw: core: Unregister EMAD trap using FORWARD action
  mlxsw: core_env: Fix driver initialization with old firmware
  mlxsw: pci: Fix driver initialization with old firmware

 drivers/net/ethernet/mellanox/mlxsw/core.c    |  2 +-
 .../net/ethernet/mellanox/mlxsw/core_env.c    | 20 ++++++-------------
 drivers/net/ethernet/mellanox/mlxsw/pci.c     | 10 ++++------
 3 files changed, 11 insertions(+), 21 deletions(-)

-- 
2.43.0


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

* [PATCH net v2 1/3] mlxsw: core: Unregister EMAD trap using FORWARD action
  2024-04-18 13:46 [PATCH net v2 0/3] mlxsw: Fixes Petr Machata
@ 2024-04-18 13:46 ` Petr Machata
  2024-04-18 13:46 ` [PATCH net v2 2/3] mlxsw: core_env: Fix driver initialization with old firmware Petr Machata
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Petr Machata @ 2024-04-18 13:46 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: Ido Schimmel, Petr Machata, mlxsw, Jiri Pirko, Amit Cohen, Simon Horman

From: Ido Schimmel <idosch@nvidia.com>

The device's manual (PRM - Programmer's Reference Manual) classifies the
trap that is used to deliver EMAD responses as an "event trap". Among
other things, it means that the only actions that can be associated with
the trap are TRAP and FORWARD (NOP).

Currently, during driver de-initialization the driver unregisters the
trap by setting its action to DISCARD, which violates the above
guideline. Future firmware versions will prevent such misuses by
returning an error. This does not prevent the driver from working, but
an error will be printed to the kernel log during module removal /
devlink reload:

mlxsw_spectrum 0000:03:00.0: Reg cmd access status failed (status=7(bad parameter))
mlxsw_spectrum 0000:03:00.0: Reg cmd access failed (reg_id=7003(hpkt),type=write)

Suppress the error message by aligning the driver to the manual and use
a FORWARD (NOP) action when unregistering the trap.

Fixes: 4ec14b7634b2 ("mlxsw: Add interface to access registers and process events")
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: Amit Cohen <amcohen@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index e4d7739bd7c8..4a79c0d7e7ad 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -849,7 +849,7 @@ static void mlxsw_emad_rx_listener_func(struct sk_buff *skb, u16 local_port,
 
 static const struct mlxsw_listener mlxsw_emad_rx_listener =
 	MLXSW_RXL(mlxsw_emad_rx_listener_func, ETHEMAD, TRAP_TO_CPU, false,
-		  EMAD, DISCARD);
+		  EMAD, FORWARD);
 
 static int mlxsw_emad_tlv_enable(struct mlxsw_core *mlxsw_core)
 {
-- 
2.43.0


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

* [PATCH net v2 2/3] mlxsw: core_env: Fix driver initialization with old firmware
  2024-04-18 13:46 [PATCH net v2 0/3] mlxsw: Fixes Petr Machata
  2024-04-18 13:46 ` [PATCH net v2 1/3] mlxsw: core: Unregister EMAD trap using FORWARD action Petr Machata
@ 2024-04-18 13:46 ` Petr Machata
  2024-04-18 17:55   ` Simon Horman
  2024-04-18 13:46 ` [PATCH net v2 3/3] mlxsw: pci: " Petr Machata
  2024-04-20  3:50 ` [PATCH net v2 0/3] mlxsw: Fixes patchwork-bot+netdevbpf
  3 siblings, 1 reply; 6+ messages in thread
From: Petr Machata @ 2024-04-18 13:46 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: Ido Schimmel, Petr Machata, mlxsw, Simon Horman,
	Tim 'mithro' Ansell

From: Ido Schimmel <idosch@nvidia.com>

The driver queries the Management Capabilities Mask (MCAM) register
during initialization to understand if it can read up to 128 bytes from
transceiver modules.

However, not all firmware versions support this register, leading to the
driver failing to load.

Fix by treating an error in the register query as an indication that the
feature is not supported.

Fixes: 1f4aea1f72da ("mlxsw: core_env: Read transceiver module EEPROM in 128 bytes chunks")
Cc: Simon Horman <horms@kernel.org>
Reported-by: Tim 'mithro' Ansell <me@mith.ro>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---

Notes:
    v2:
    - Make mlxsw_env_max_module_eeprom_len_query() void

 .../net/ethernet/mellanox/mlxsw/core_env.c    | 20 ++++++-------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
index 53b150b7ae4e..6c06b0592760 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
@@ -1357,24 +1357,20 @@ static struct mlxsw_linecards_event_ops mlxsw_env_event_ops = {
 	.got_inactive = mlxsw_env_got_inactive,
 };
 
-static int mlxsw_env_max_module_eeprom_len_query(struct mlxsw_env *mlxsw_env)
+static void mlxsw_env_max_module_eeprom_len_query(struct mlxsw_env *mlxsw_env)
 {
 	char mcam_pl[MLXSW_REG_MCAM_LEN];
-	bool mcia_128b_supported;
+	bool mcia_128b_supported = false;
 	int err;
 
 	mlxsw_reg_mcam_pack(mcam_pl,
 			    MLXSW_REG_MCAM_FEATURE_GROUP_ENHANCED_FEATURES);
 	err = mlxsw_reg_query(mlxsw_env->core, MLXSW_REG(mcam), mcam_pl);
-	if (err)
-		return err;
-
-	mlxsw_reg_mcam_unpack(mcam_pl, MLXSW_REG_MCAM_MCIA_128B,
-			      &mcia_128b_supported);
+	if (!err)
+		mlxsw_reg_mcam_unpack(mcam_pl, MLXSW_REG_MCAM_MCIA_128B,
+				      &mcia_128b_supported);
 
 	mlxsw_env->max_eeprom_len = mcia_128b_supported ? 128 : 48;
-
-	return 0;
 }
 
 int mlxsw_env_init(struct mlxsw_core *mlxsw_core,
@@ -1445,15 +1441,11 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core,
 	if (err)
 		goto err_type_set;
 
-	err = mlxsw_env_max_module_eeprom_len_query(env);
-	if (err)
-		goto err_eeprom_len_query;
-
+	mlxsw_env_max_module_eeprom_len_query(env);
 	env->line_cards[0]->active = true;
 
 	return 0;
 
-err_eeprom_len_query:
 err_type_set:
 	mlxsw_env_module_event_disable(env, 0);
 err_mlxsw_env_module_event_enable:
-- 
2.43.0


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

* [PATCH net v2 3/3] mlxsw: pci: Fix driver initialization with old firmware
  2024-04-18 13:46 [PATCH net v2 0/3] mlxsw: Fixes Petr Machata
  2024-04-18 13:46 ` [PATCH net v2 1/3] mlxsw: core: Unregister EMAD trap using FORWARD action Petr Machata
  2024-04-18 13:46 ` [PATCH net v2 2/3] mlxsw: core_env: Fix driver initialization with old firmware Petr Machata
@ 2024-04-18 13:46 ` Petr Machata
  2024-04-20  3:50 ` [PATCH net v2 0/3] mlxsw: Fixes patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: Petr Machata @ 2024-04-18 13:46 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: Ido Schimmel, Petr Machata, mlxsw, Tim 'mithro' Ansell,
	Simon Horman, Kalesh AP

From: Ido Schimmel <idosch@nvidia.com>

The driver queries the Management Capabilities Mask (MCAM) register
during initialization to understand if a new and deeper reset flow is
supported.

However, not all firmware versions support this register, leading to the
driver failing to load.

Fix by treating an error in the register query as an indication that the
feature is not supported.

Fixes: f257c73e5356 ("mlxsw: pci: Add support for new reset flow")
Reported-by: Tim 'mithro' Ansell <me@mith.ro>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/pci.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c
index 4d617057af25..13fd067c39ed 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/pci.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c
@@ -1545,7 +1545,7 @@ mlxsw_pci_reset(struct mlxsw_pci *mlxsw_pci, const struct pci_device_id *id)
 {
 	struct pci_dev *pdev = mlxsw_pci->pdev;
 	char mcam_pl[MLXSW_REG_MCAM_LEN];
-	bool pci_reset_supported;
+	bool pci_reset_supported = false;
 	u32 sys_status;
 	int err;
 
@@ -1563,11 +1563,9 @@ mlxsw_pci_reset(struct mlxsw_pci *mlxsw_pci, const struct pci_device_id *id)
 	mlxsw_reg_mcam_pack(mcam_pl,
 			    MLXSW_REG_MCAM_FEATURE_GROUP_ENHANCED_FEATURES);
 	err = mlxsw_reg_query(mlxsw_pci->core, MLXSW_REG(mcam), mcam_pl);
-	if (err)
-		return err;
-
-	mlxsw_reg_mcam_unpack(mcam_pl, MLXSW_REG_MCAM_PCI_RESET,
-			      &pci_reset_supported);
+	if (!err)
+		mlxsw_reg_mcam_unpack(mcam_pl, MLXSW_REG_MCAM_PCI_RESET,
+				      &pci_reset_supported);
 
 	if (pci_reset_supported) {
 		pci_dbg(pdev, "Starting PCI reset flow\n");
-- 
2.43.0


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

* Re: [PATCH net v2 2/3] mlxsw: core_env: Fix driver initialization with old firmware
  2024-04-18 13:46 ` [PATCH net v2 2/3] mlxsw: core_env: Fix driver initialization with old firmware Petr Machata
@ 2024-04-18 17:55   ` Simon Horman
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2024-04-18 17:55 UTC (permalink / raw)
  To: Petr Machata
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev, Ido Schimmel, mlxsw, Tim 'mithro' Ansell

On Thu, Apr 18, 2024 at 03:46:07PM +0200, Petr Machata wrote:
> From: Ido Schimmel <idosch@nvidia.com>
> 
> The driver queries the Management Capabilities Mask (MCAM) register
> during initialization to understand if it can read up to 128 bytes from
> transceiver modules.
> 
> However, not all firmware versions support this register, leading to the
> driver failing to load.
> 
> Fix by treating an error in the register query as an indication that the
> feature is not supported.
> 
> Fixes: 1f4aea1f72da ("mlxsw: core_env: Read transceiver module EEPROM in 128 bytes chunks")
> Cc: Simon Horman <horms@kernel.org>
> Reported-by: Tim 'mithro' Ansell <me@mith.ro>
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
> Reviewed-by: Petr Machata <petrm@nvidia.com>
> Signed-off-by: Petr Machata <petrm@nvidia.com>
> ---
> 
> Notes:
>     v2:
>     - Make mlxsw_env_max_module_eeprom_len_query() void

Thanks for the update.

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net v2 0/3] mlxsw: Fixes
  2024-04-18 13:46 [PATCH net v2 0/3] mlxsw: Fixes Petr Machata
                   ` (2 preceding siblings ...)
  2024-04-18 13:46 ` [PATCH net v2 3/3] mlxsw: pci: " Petr Machata
@ 2024-04-20  3:50 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-04-20  3:50 UTC (permalink / raw)
  To: Petr Machata; +Cc: davem, edumazet, kuba, pabeni, netdev, idosch, mlxsw

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 18 Apr 2024 15:46:05 +0200 you wrote:
> This patchset fixes the following issues:
> 
> - During driver de-initialization the driver unregisters the EMAD
>   response trap by setting its action to DISCARD. However the manual
>   only permits TRAP and FORWARD, and future firmware versions will
>   enforce this.
> 
> [...]

Here is the summary with links:
  - [net,v2,1/3] mlxsw: core: Unregister EMAD trap using FORWARD action
    https://git.kernel.org/netdev/net/c/976c44af4814
  - [net,v2,2/3] mlxsw: core_env: Fix driver initialization with old firmware
    https://git.kernel.org/netdev/net/c/7e2050a83663
  - [net,v2,3/3] mlxsw: pci: Fix driver initialization with old firmware
    https://git.kernel.org/netdev/net/c/773501d01e6b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-04-20  3:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-18 13:46 [PATCH net v2 0/3] mlxsw: Fixes Petr Machata
2024-04-18 13:46 ` [PATCH net v2 1/3] mlxsw: core: Unregister EMAD trap using FORWARD action Petr Machata
2024-04-18 13:46 ` [PATCH net v2 2/3] mlxsw: core_env: Fix driver initialization with old firmware Petr Machata
2024-04-18 17:55   ` Simon Horman
2024-04-18 13:46 ` [PATCH net v2 3/3] mlxsw: pci: " Petr Machata
2024-04-20  3:50 ` [PATCH net v2 0/3] mlxsw: Fixes patchwork-bot+netdevbpf

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.