Skip to contentSkip to conversation

mlx5 misc enhancements 2025-02-19

PATCH Applied Tariq Toukan 2 participants 7 messages Feb 19, 2025 – Feb 21, 2025

Subsystems (5)
lore
Share & tools
lore

Tariq Toukan

author maintainer
#0 lore raw

cover mlx5 misc enhancements 2025-02-19

Hi,

This small series enhances the mlx5 ethtool link speed code (no functional change), in addition to a Kconfig description enhancement.

Regards,
Tariq

Cosmin Ratiu (1):
net/mlx5: Bridge, correct config option description

Shahar Shitrit (4):
net/mlx5e: Refactor ptys2ethtool_adver_link()
net/mlx5e: Introduce ptys2ethtool_process_link() net/mlx5e: Change eth_proto parameter naming
net/mlx5e: Separate extended link modes request from link modes type
selection

 .../net/ethernet/mellanox/mlx5/core/Kconfig   |  4 +-
 .../ethernet/mellanox/mlx5/core/en_ethtool.c  | 62 ++++++-------------
 2 files changed, 21 insertions(+), 45 deletions(-)

base-commit: aefd232de5eb2e77e3fc58c56486c7fe7426a228

Signature · 1 line
2.45.0
author maintainer
#1 lore raw

PATCH 1/5 net/mlx5: Bridge, correct config option description

From: Cosmin Ratiu <[email protected]>

The implication of the previous help text was that without this option enabled, representor devices couldn't be added to a bridge device, while in fact that was possible, just that rules didn't get offloaded to hw.

This commit clarifies the help text.

---
 drivers/net/ethernet/mellanox/mlx5/core/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/Kconfig +2 -2
index ea6070180c96..bf4015a12b41 100644
@@ -80,8 +80,8 @@ config MLX5_BRIDGE
 	default y
 	help
 	  mlx5 ConnectX offloads support for Ethernet Bridging (BRIDGE).
-	  Enable adding representors of mlx5 uplink and VF ports to Bridge and
-	  offloading rules for traffic between such ports. Supports VLANs (trunk and
+	  Enable offloading FDB rules from a bridge device containing
+	  representors of mlx5 uplink and VF ports. Supports VLANs (trunk and
 	  access modes).
 
 config MLX5_CLS_ACT
Signature · 1 line
2.45.0
author maintainer
#2 lore raw

PATCH 2/5 net/mlx5e: Refactor ptys2ethtool_adver_link()

In reply to Tariq Toukan

From: Shahar Shitrit <[email protected]>

The function ptys2ethtool_adver_link() contains duplicated code that is found in mlx5e_ethtool_get_speed_arr().

To eliminate this redundancy, we update mlx5e_ethtool_get_speed_arr() to select the appropriate table based on the ext argument passed by the caller, rather than querying the supported mode locally.

This allows us to replace the current logic in ptys2ethtool_adver_link() with a call to mlx5e_ethtool_get_speed_arr().

This adjustment aligns with the ptys2ethtool_supported_link() function and prepares for an upcoming patch that reduces code duplication.

---
 .../ethernet/mellanox/mlx5/core/en_ethtool.c  | 20 ++++++++-----------
 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +8 -12
index f9113cb13a0c..a24bc546e270 100644
@@ -260,12 +260,10 @@ void mlx5e_build_ptys2ethtool_map(void)
 				       ETHTOOL_LINK_MODE_800000baseVR4_Full_BIT);
 }
 
-static void mlx5e_ethtool_get_speed_arr(struct mlx5_core_dev *mdev,
+static void mlx5e_ethtool_get_speed_arr(bool ext,
 					struct ptys2ethtool_config **arr,
 					u32 *size)
 {
-	bool ext = mlx5_ptys_ext_supported(mdev);
-
 	*arr = ext ? ptys2ext_ethtool_table : ptys2legacy_ethtool_table;
 	*size = ext ? ARRAY_SIZE(ptys2ext_ethtool_table) :
 		      ARRAY_SIZE(ptys2legacy_ethtool_table);
@@ -912,16 +910,15 @@ int mlx5e_set_per_queue_coalesce(struct net_device *dev, u32 queue,
 	return mlx5e_ethtool_set_per_queue_coalesce(priv, queue, coal);
 }
 
-static void ptys2ethtool_supported_link(struct mlx5_core_dev *mdev,
-					unsigned long *supported_modes,
-					u32 eth_proto_cap)
+static void ptys2ethtool_supported_link(unsigned long *supported_modes,
+					u32 eth_proto_cap, bool ext)
 {
 	unsigned long proto_cap = eth_proto_cap;
 	struct ptys2ethtool_config *table;
 	u32 max_size;
 	int proto;
 
-	mlx5e_ethtool_get_speed_arr(mdev, &table, &max_size);
+	mlx5e_ethtool_get_speed_arr(ext, &table, &max_size);
 	for_each_set_bit(proto, &proto_cap, max_size)
 		bitmap_or(supported_modes, supported_modes,
 			  table[proto].supported,
@@ -936,10 +933,7 @@ static void ptys2ethtool_adver_link(unsigned long *advertising_modes,
 	u32 max_size;
 	int proto;
 
-	table = ext ? ptys2ext_ethtool_table : ptys2legacy_ethtool_table;
-	max_size = ext ? ARRAY_SIZE(ptys2ext_ethtool_table) :
-			 ARRAY_SIZE(ptys2legacy_ethtool_table);
-
+	mlx5e_ethtool_get_speed_arr(ext, &table, &max_size);
 	for_each_set_bit(proto, &proto_cap, max_size)
 		bitmap_or(advertising_modes, advertising_modes,
 			  table[proto].advertised,
@@ -1128,7 +1122,9 @@ static void get_supported(struct mlx5_core_dev *mdev, u32 eth_proto_cap,
 			  struct ethtool_link_ksettings *link_ksettings)
 {
 	unsigned long *supported = link_ksettings->link_modes.supported;
-	ptys2ethtool_supported_link(mdev, supported, eth_proto_cap);
+	bool ext = mlx5_ptys_ext_supported(mdev);
+
+	ptys2ethtool_supported_link(supported, eth_proto_cap, ext);
 
 	ethtool_link_ksettings_add_link_mode(link_ksettings, supported, Pause);
 }
Signature · 1 line
2.45.0
author maintainer
#3 lore raw

PATCH 3/5 net/mlx5e: Introduce ptys2ethtool_process_link()

In reply to Tariq Toukan

From: Shahar Shitrit <[email protected]>

The functions ptys2ethtool_supported_link(), ptys2ethtool_adver_link() share the same code, thus, in order to remove code duplication we introduce a new function ptys2ethtool_process_link() to handle the processing of both supported and advertised link modes.

---
 .../ethernet/mellanox/mlx5/core/en_ethtool.c  | 35 ++++++-------------
 1 file changed, 10 insertions(+), 25 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +10 -25
index a24bc546e270..6dab58ab50ac 100644
@@ -910,33 +910,19 @@ int mlx5e_set_per_queue_coalesce(struct net_device *dev, u32 queue,
 	return mlx5e_ethtool_set_per_queue_coalesce(priv, queue, coal);
 }
 
-static void ptys2ethtool_supported_link(unsigned long *supported_modes,
-					u32 eth_proto_cap, bool ext)
+static void ptys2ethtool_process_link(u32 eth_eproto, bool ext, bool advertised,
+				      unsigned long *modes)
 {
-	unsigned long proto_cap = eth_proto_cap;
+	unsigned long eproto = eth_eproto;
 	struct ptys2ethtool_config *table;
 	u32 max_size;
 	int proto;
 
 	mlx5e_ethtool_get_speed_arr(ext, &table, &max_size);
-	for_each_set_bit(proto, &proto_cap, max_size)
-		bitmap_or(supported_modes, supported_modes,
-			  table[proto].supported,
-			  __ETHTOOL_LINK_MODE_MASK_NBITS);
-}
-
-static void ptys2ethtool_adver_link(unsigned long *advertising_modes,
-				    u32 eth_proto_cap, bool ext)
-{
-	unsigned long proto_cap = eth_proto_cap;
-	struct ptys2ethtool_config *table;
-	u32 max_size;
-	int proto;
-
-	mlx5e_ethtool_get_speed_arr(ext, &table, &max_size);
-	for_each_set_bit(proto, &proto_cap, max_size)
-		bitmap_or(advertising_modes, advertising_modes,
-			  table[proto].advertised,
+	for_each_set_bit(proto, &eproto, max_size)
+		bitmap_or(modes, modes,
+			  advertised ?
+			  table[proto].advertised : table[proto].supported,
 			  __ETHTOOL_LINK_MODE_MASK_NBITS);
 }
 
@@ -1124,7 +1110,7 @@ static void get_supported(struct mlx5_core_dev *mdev, u32 eth_proto_cap,
 	unsigned long *supported = link_ksettings->link_modes.supported;
 	bool ext = mlx5_ptys_ext_supported(mdev);
 
-	ptys2ethtool_supported_link(supported, eth_proto_cap, ext);
+	ptys2ethtool_process_link(eth_proto_cap, ext, false, supported);
 
 	ethtool_link_ksettings_add_link_mode(link_ksettings, supported, Pause);
 }
@@ -1134,8 +1120,7 @@ static void get_advertising(u32 eth_proto_cap, u8 tx_pause, u8 rx_pause,
 			    bool ext)
 {
 	unsigned long *advertising = link_ksettings->link_modes.advertising;
-	ptys2ethtool_adver_link(advertising, eth_proto_cap, ext);
-
+	ptys2ethtool_process_link(eth_proto_cap, ext, true, advertising);
 	if (rx_pause)
 		ethtool_link_ksettings_add_link_mode(link_ksettings, advertising, Pause);
 	if (tx_pause ^ rx_pause)
@@ -1191,7 +1176,7 @@ static void get_lp_advertising(struct mlx5_core_dev *mdev, u32 eth_proto_lp,
 	unsigned long *lp_advertising = link_ksettings->link_modes.lp_advertising;
 	bool ext = mlx5_ptys_ext_supported(mdev);
 
-	ptys2ethtool_adver_link(lp_advertising, eth_proto_lp, ext);
+	ptys2ethtool_process_link(eth_proto_lp, ext, true, lp_advertising);
 }
 
 static int mlx5e_ethtool_get_link_ksettings(struct mlx5e_priv *priv,
Signature · 1 line
2.45.0
author maintainer
#4 lore raw

PATCH 4/5 net/mlx5e: Change eth_proto parameter naming

In reply to Tariq Toukan

From: Shahar Shitrit <[email protected]>

eth_proto_cap parameter represents the supported link modes, while eth_proto_admin refers to the configured ones.

The function get_advertising() retrieves the configured link modes, thus we update its parameter name to eth_proto_admin.

---
 drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +2 -2
index 6dab58ab50ac..712171dd07c7 100644
@@ -1115,12 +1115,12 @@ static void get_supported(struct mlx5_core_dev *mdev, u32 eth_proto_cap,
 	ethtool_link_ksettings_add_link_mode(link_ksettings, supported, Pause);
 }
 
-static void get_advertising(u32 eth_proto_cap, u8 tx_pause, u8 rx_pause,
+static void get_advertising(u32 eth_proto_admin, u8 tx_pause, u8 rx_pause,
 			    struct ethtool_link_ksettings *link_ksettings,
 			    bool ext)
 {
 	unsigned long *advertising = link_ksettings->link_modes.advertising;
-	ptys2ethtool_process_link(eth_proto_cap, ext, true, advertising);
+	ptys2ethtool_process_link(eth_proto_admin, ext, true, advertising);
 	if (rx_pause)
 		ethtool_link_ksettings_add_link_mode(link_ksettings, advertising, Pause);
 	if (tx_pause ^ rx_pause)
Signature · 1 line
2.45.0
author maintainer
#5 lore raw

PATCH 5/5 net/mlx5e: Separate extended link modes request from link modes type selection

In reply to Tariq Toukan

From: Shahar Shitrit <[email protected]>

The function ext_requested() serves two distinct purposes: it checks if extended link modes were requested, and it selects whether to use extended or legacy link modes.

This change separates these two purposes. Now, ext_link_mode_requested() is used directly for checking if extended link modes are requested, while the selection of extended modes is handled independently based on the autonegotiation status.

By making this distinction, the logic for determining whether to select extended or legacy link modes is clearer.

---
 .../net/ethernet/mellanox/mlx5/core/en_ethtool.c    | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +4 -9
index 712171dd07c7..1bf2212a0bb6 100644
@@ -1344,13 +1344,6 @@ static bool ext_link_mode_requested(const unsigned long *adver)
 	return bitmap_intersects(modes, adver, __ETHTOOL_LINK_MODE_MASK_NBITS);
 }
 
-static bool ext_requested(u8 autoneg, const unsigned long *adver, bool ext_supported)
-{
-	bool ext_link_mode = ext_link_mode_requested(adver);
-
-	return  autoneg == AUTONEG_ENABLE ? ext_link_mode : ext_supported;
-}
-
 static int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv,
 					    const struct ethtool_link_ksettings *link_ksettings)
 {
@@ -1360,6 +1353,7 @@ static int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv,
 	bool an_changes = false;
 	u8 an_disable_admin;
 	bool ext_supported;
+	bool ext_requested;
 	u8 an_disable_cap;
 	bool an_disable;
 	u32 link_modes;
@@ -1376,10 +1370,11 @@ static int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv,
 	speed = link_ksettings->base.speed;
 
 	ext_supported = mlx5_ptys_ext_supported(mdev);
-	ext = ext_requested(autoneg, adver, ext_supported);
-	if (!ext_supported && ext)
+	ext_requested = ext_link_mode_requested(adver);
+	if (!ext_supported && ext_requested)
 		return -EOPNOTSUPP;
 
+	ext = autoneg == AUTONEG_ENABLE ? ext_requested : ext_supported;
 	ethtool2ptys_adver_func = ext ? mlx5e_ethtool2ptys_ext_adver_link :
 				  mlx5e_ethtool2ptys_adver_link;
 	err = mlx5_port_query_eth_proto(mdev, 1, ext, &eproto);
Signature · 1 line
2.45.0
#6 lore raw
In reply to Tariq Toukan
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Wed, 19 Feb 2025 13:41:07 +0200 you wrote:

Hi,

This small series enhances the mlx5 ethtool link speed code (no functional change), in addition to a Kconfig description enhancement.

Regards,
Tariq

[...]

Here is the summary with links:
- [net-next,1/5] net/mlx5: Bridge, correct config option description

    https://git.kernel.org/netdev/net-next/c/3fe090ad0250
  - [net-next,2/5] net/mlx5e: Refactor ptys2ethtool_adver_link()
    https://git.kernel.org/netdev/net-next/c/5246fd3fc232
  - [net-next,3/5] net/mlx5e: Introduce ptys2ethtool_process_link()
    https://git.kernel.org/netdev/net-next/c/64d97f891961
  - [net-next,4/5] net/mlx5e: Change eth_proto parameter naming
    https://git.kernel.org/netdev/net-next/c/9ca3bf013a0e
  - [net-next,5/5] net/mlx5e: Separate extended link modes request from link modes type selection
    https://git.kernel.org/netdev/net-next/c/9c362aafda8b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html