mlx5 misc enhancements 2025-03-04
Subsystems (7)
Tariq Toukan
maintainerv2 cover mlx5 misc enhancements 2025-03-04
Hi,
This is V2.
Find initial version here:
https://lore.kernel.org/lkml/[email protected]/
This series introduces enhancements to the mlx5 core and Eth drivers.
Patches 1-3 by Shahar introduce support for configuring lanes alongside speed when autonegotiation is disabled. The combination of speed and the number of lanes corresponds to a specific link mode (in the extended mask typically used in newer hardware), allowing the user to select a precise link mode when autonegotiation is off, instead of just choosing the speed.
Patch 4 by Amir extends the multi-port LAG support.
Patches 5-6 by Leon enhance IPsec matching logic.
Regards,
Tariq
V2:
- Added Reviewed-by tags.
- Addressed comments on patch #3 (Jakub).
Amir Tzin (1):
net/mlx5: Lag, Enable Multiport E-Switch offloads on 8 ports LAG
Leon Romanovsky (2):
net/mlx5e: Separate address related variables to be in struct net/mlx5e: Properly match IPsec subnet addresses
Shahar Shitrit (3):
net/mlx5: Relocate function declarations from port.h to mlx5_core.h net/mlx5: Refactor link speed handling with mlx5_link_info struct net/mlx5e: Enable lanes configuration when auto-negotiation is off
.../net/ethernet/mellanox/mlx5/core/en/port.c | 9 +- .../mellanox/mlx5/core/en_accel/ipsec.c | 81 +++++++-- .../mellanox/mlx5/core/en_accel/ipsec.h | 35 ++-- .../mellanox/mlx5/core/en_accel/ipsec_fs.c | 95 +++++----- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 47 ++--- .../ethernet/mellanox/mlx5/core/lag/mpesw.c | 4 - .../ethernet/mellanox/mlx5/core/mlx5_core.h | 92 ++++++++++ .../net/ethernet/mellanox/mlx5/core/port.c | 168 ++++++++---------- include/linux/mlx5/port.h | 85 +-------- 9 files changed, 342 insertions(+), 274 deletions(-)
base-commit: 05ec5c085eb7ae044d49e04a3cff194a0b2a3251
Signature · 1 line
2.45.0
Tariq Toukan
maintainerPATCH v2 1/6 net/mlx5: Relocate function declarations from port.h to mlx5_core.h
From: Shahar Shitrit <[email protected]>
The port header is a general file under include, yet it contains declarations for functions that are either not exported or exported but not used outside the mlx5_core driver.
To enhance code organization, we move these declarations to mlx5_core.h, where they are more appropriately scoped.
This refactor removes unnecessary exported symbols and prevents unexported functions from being inadvertently referenced outside of the mlx5_core driver.
--- .../ethernet/mellanox/mlx5/core/mlx5_core.h | 85 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/port.c | 20 ----- include/linux/mlx5/port.h | 85 +------------------ 3 files changed, 86 insertions(+), 104 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +85 -0
@@ -114,6 +114,21 @@ struct mlx5_cmd_alias_obj_create_attr {u8 access_key[ACCESS_KEY_LEN ]; }; +struct mlx5_port_eth_proto { +u32 cap; +u32 admin; +u32 oper; +}; + +struct mlx5_module_eeprom_query_params { +u16 size; +u16 offset; +u16 i2c_address; +u32 page; +u32 bank; +u32 module_number; +}; +static inline void mlx5_printk (struct mlx5_core_dev *dev,int level,const char *format, ...) {struct device *device = dev->device;
@@ -280,6 +295,76 @@ int mlx5_set_mtppse(struct mlx5_core_dev *mdev, u8 pin, u8 arm, u8 mode);struct mlx5_dm *mlx5_dm_create (struct mlx5_core_dev *dev);void mlx5_dm_cleanup (struct mlx5_core_dev *dev); +void mlx5_toggle_port_link (struct mlx5_core_dev *dev); +int mlx5_set_port_admin_status (struct mlx5_core_dev *dev, +enum mlx5_port_status status); +int mlx5_query_port_admin_status (struct mlx5_core_dev *dev, +enum mlx5_port_status *status); +int mlx5_set_port_beacon (struct mlx5_core_dev *dev,u16 beacon_duration); + +int mlx5_set_port_mtu (struct mlx5_core_dev *dev,u16 mtu,u8 port); +int mlx5_set_port_pause (struct mlx5_core_dev *dev,u32 rx_pause,u32 tx_pause); +int mlx5_query_port_pause (struct mlx5_core_dev *dev, +u32 *rx_pause,u32 *tx_pause); + +int mlx5_set_port_pfc (struct mlx5_core_dev *dev,u8 pfc_en_tx,u8 pfc_en_rx); +int mlx5_query_port_pfc (struct mlx5_core_dev *dev,u8 *pfc_en_tx, +u8 *pfc_en_rx); + +int mlx5_set_port_stall_watermark (struct mlx5_core_dev *dev, +u16 stall_critical_watermark, +u16 stall_minor_watermark); +int mlx5_query_port_stall_watermark (struct mlx5_core_dev *dev, +u16 *stall_critical_watermark, +u16 *stall_minor_watermark); + +int mlx5_max_tc (struct mlx5_core_dev *mdev); +int mlx5_set_port_prio_tc (struct mlx5_core_dev *mdev,u8 *prio_tc); +int mlx5_query_port_prio_tc (struct mlx5_core_dev *mdev, +u8 prio,u8 *tc); +int mlx5_set_port_tc_group (struct mlx5_core_dev *mdev,u8 *tc_group); +int mlx5_query_port_tc_group (struct mlx5_core_dev *mdev, +u8 tc,u8 *tc_group); +int mlx5_set_port_tc_bw_alloc (struct mlx5_core_dev *mdev,u8 *tc_bw); +int mlx5_query_port_tc_bw_alloc (struct mlx5_core_dev *mdev, +u8 tc,u8 *bw_pct); +int mlx5_modify_port_ets_rate_limit (struct mlx5_core_dev *mdev, +u8 *max_bw_value, +u8 *max_bw_unit); +int mlx5_query_port_ets_rate_limit (struct mlx5_core_dev *mdev, +u8 *max_bw_value, +u8 *max_bw_unit); +int mlx5_set_port_wol (struct mlx5_core_dev *mdev,u8 wol_mode); +int mlx5_query_port_wol (struct mlx5_core_dev *mdev,u8 *wol_mode); + +int mlx5_query_ports_check (struct mlx5_core_dev *mdev,u32 *out,int outlen); +int mlx5_set_ports_check (struct mlx5_core_dev *mdev,u32 *in,int inlen); +int mlx5_set_port_fcs (struct mlx5_core_dev *mdev,u8 enable); +void mlx5_query_port_fcs (struct mlx5_core_dev *mdev,bool *supported, +bool *enabled); +int mlx5_query_module_eeprom (struct mlx5_core_dev *dev, +u16 offset,u16 size,u8 *data); +int +mlx5_query_module_eeprom_by_page (struct mlx5_core_dev *dev, +struct mlx5_module_eeprom_query_params *params, +u8 *data); + +int mlx5_query_port_dcbx_param (struct mlx5_core_dev *mdev,u32 *out); +int mlx5_set_port_dcbx_param (struct mlx5_core_dev *mdev,u32 *in); +int mlx5_set_trust_state (struct mlx5_core_dev *mdev,u8 trust_state); +int mlx5_query_trust_state (struct mlx5_core_dev *mdev,u8 *trust_state); +int mlx5_set_dscp2prio (struct mlx5_core_dev *mdev,u8 dscp,u8 prio); +int mlx5_query_dscp2prio (struct mlx5_core_dev *mdev,u8 *dscp2prio); + +int mlx5_port_query_eth_proto (struct mlx5_core_dev *dev,u8 port,bool ext, +struct mlx5_port_eth_proto *eproto); +bool mlx5_ptys_ext_supported (struct mlx5_core_dev *mdev); +u32 mlx5_port_ptys2speed (struct mlx5_core_dev *mdev,u32 eth_proto_oper, +bool force_legacy); +u32 mlx5_port_speed2linkmodes (struct mlx5_core_dev *mdev,u32 speed, +bool force_legacy); +int mlx5_port_max_linkspeed (struct mlx5_core_dev *mdev,u32 *speed); +#define MLX5_PPS_CAP (mdev) (MLX5_CAP_GEN((mdev), pps) && \ MLX5_CAP_GEN((mdev), pps_modify) && \ MLX5_CAP_MCAM_FEATURE((mdev), mtpps_fs) && \
drivers/net/ethernet/mellanox/mlx5/core/port.c +0 -20
@@ -196,7 +196,6 @@ void mlx5_toggle_port_link(struct mlx5_core_dev *dev)if (ps ==MLX5_PORT_UP )mlx5_set_port_admin_status (dev,MLX5_PORT_UP ); } -EXPORT_SYMBOL_GPL (mlx5_toggle_port_link);int mlx5_set_port_admin_status (struct mlx5_core_dev *dev,enum mlx5_port_status status)
@@ -210,7 +209,6 @@ int mlx5_set_port_admin_status(struct mlx5_core_dev *dev,return mlx5_core_access_reg (dev, in,sizeof (in), out,sizeof (out),MLX5_REG_PAOS ,0 ,1 ); } -EXPORT_SYMBOL_GPL (mlx5_set_port_admin_status);int mlx5_query_port_admin_status (struct mlx5_core_dev *dev,enum mlx5_port_status *status)
@@ -227,7 +225,6 @@ int mlx5_query_port_admin_status(struct mlx5_core_dev *dev, *status =MLX5_GET (paos_reg, out, admin_status);return 0 ; } -EXPORT_SYMBOL_GPL (mlx5_query_port_admin_status);static void mlx5_query_port_mtu (struct mlx5_core_dev *dev,u16 *admin_mtu,u16 *max_mtu,u16 *oper_mtu,u8 port)
@@ -257,7 +254,6 @@ int mlx5_set_port_mtu(struct mlx5_core_dev *dev, u16 mtu, u8 port)return mlx5_core_access_reg (dev, in,sizeof (in), out,sizeof (out),MLX5_REG_PMTU ,0 ,1 ); } -EXPORT_SYMBOL_GPL (mlx5_set_port_mtu);void mlx5_query_port_max_mtu (struct mlx5_core_dev *dev,u16 *max_mtu,u8 port)
@@ -447,7 +443,6 @@ int mlx5_query_module_eeprom(struct mlx5_core_dev *dev,return mlx5_query_mcia (dev, &query, data); } -EXPORT_SYMBOL_GPL (mlx5_query_module_eeprom); int mlx5_query_module_eeprom_by_page(struct mlx5_core_dev *dev, struct mlx5_module_eeprom_query_params *params,
@@ -467,7 +462,6 @@ int mlx5_query_module_eeprom_by_page(struct mlx5_core_dev *dev,return mlx5_query_mcia (dev, params, data); } -EXPORT_SYMBOL_GPL (mlx5_query_module_eeprom_by_page);static int mlx5_query_port_pvlc (struct mlx5_core_dev *dev,u32 *pvlc,int pvlc_size,u8 local_port)
@@ -518,7 +512,6 @@ int mlx5_set_port_pause(struct mlx5_core_dev *dev, u32 rx_pause, u32 tx_pause)return mlx5_core_access_reg (dev, in,sizeof (in), out,sizeof (out),MLX5_REG_PFCC ,0 ,1 ); } -EXPORT_SYMBOL_GPL (mlx5_set_port_pause);int mlx5_query_port_pause (struct mlx5_core_dev *dev,u32 *rx_pause,u32 *tx_pause)
@@ -538,7 +531,6 @@ int mlx5_query_port_pause(struct mlx5_core_dev *dev,return 0 ; } -EXPORT_SYMBOL_GPL (mlx5_query_port_pause); int mlx5_set_port_stall_watermark(struct mlx5_core_dev *dev, u16 stall_critical_watermark,
@@ -597,7 +589,6 @@ int mlx5_set_port_pfc(struct mlx5_core_dev *dev, u8 pfc_en_tx, u8 pfc_en_rx)return mlx5_core_access_reg (dev, in,sizeof (in), out,sizeof (out),MLX5_REG_PFCC ,0 ,1 ); } -EXPORT_SYMBOL_GPL (mlx5_set_port_pfc);int mlx5_query_port_pfc (struct mlx5_core_dev *dev,u8 *pfc_en_tx,u8 *pfc_en_rx) {
@@ -616,7 +607,6 @@ int mlx5_query_port_pfc(struct mlx5_core_dev *dev, u8 *pfc_en_tx, u8 *pfc_en_rx)return 0 ; } -EXPORT_SYMBOL_GPL (mlx5_query_port_pfc);int mlx5_max_tc (struct mlx5_core_dev *mdev) {
@@ -667,7 +657,6 @@ int mlx5_set_port_prio_tc(struct mlx5_core_dev *mdev, u8 *prio_tc)return 0 ; } -EXPORT_SYMBOL_GPL (mlx5_set_port_prio_tc);int mlx5_query_port_prio_tc (struct mlx5_core_dev *mdev,u8 prio,u8 *tc)
@@ -689,7 +678,6 @@ int mlx5_query_port_prio_tc(struct mlx5_core_dev *mdev,return err; } -EXPORT_SYMBOL_GPL (mlx5_query_port_prio_tc);static int mlx5_set_port_qetcr_reg (struct mlx5_core_dev *mdev,u32 *in,int inlen)
@@ -728,7 +716,6 @@ int mlx5_set_port_tc_group(struct mlx5_core_dev *mdev, u8 *tc_group)return mlx5_set_port_qetcr_reg (mdev, in,sizeof (in)); } -EXPORT_SYMBOL_GPL (mlx5_set_port_tc_group);int mlx5_query_port_tc_group (struct mlx5_core_dev *mdev,u8 tc,u8 *tc_group)
@@ -749,7 +736,6 @@ int mlx5_query_port_tc_group(struct mlx5_core_dev *mdev,return 0 ; } -EXPORT_SYMBOL_GPL (mlx5_query_port_tc_group);int mlx5_set_port_tc_bw_alloc (struct mlx5_core_dev *mdev,u8 *tc_bw) {
@@ -763,7 +749,6 @@ int mlx5_set_port_tc_bw_alloc(struct mlx5_core_dev *mdev, u8 *tc_bw)return mlx5_set_port_qetcr_reg (mdev, in,sizeof (in)); } -EXPORT_SYMBOL_GPL (mlx5_set_port_tc_bw_alloc);int mlx5_query_port_tc_bw_alloc (struct mlx5_core_dev *mdev,u8 tc,u8 *bw_pct)
@@ -784,7 +769,6 @@ int mlx5_query_port_tc_bw_alloc(struct mlx5_core_dev *mdev,return 0 ; } -EXPORT_SYMBOL_GPL (mlx5_query_port_tc_bw_alloc); int mlx5_modify_port_ets_rate_limit(struct mlx5_core_dev *mdev, u8 *max_bw_value,
@@ -808,7 +792,6 @@ int mlx5_modify_port_ets_rate_limit(struct mlx5_core_dev *mdev,return mlx5_set_port_qetcr_reg (mdev, in,sizeof (in)); } -EXPORT_SYMBOL_GPL (mlx5_modify_port_ets_rate_limit); int mlx5_query_port_ets_rate_limit(struct mlx5_core_dev *mdev, u8 *max_bw_value,
@@ -834,7 +817,6 @@ int mlx5_query_port_ets_rate_limit(struct mlx5_core_dev *mdev,return 0 ; } -EXPORT_SYMBOL_GPL (mlx5_query_port_ets_rate_limit);int mlx5_set_port_wol (struct mlx5_core_dev *mdev,u8 wol_mode) {
@@ -845,7 +827,6 @@ int mlx5_set_port_wol(struct mlx5_core_dev *mdev, u8 wol_mode)MLX5_SET (set_wol_rol_in, in, wol_mode, wol_mode);return mlx5_cmd_exec_in (mdev, set_wol_rol, in); } -EXPORT_SYMBOL_GPL (mlx5_set_port_wol);int mlx5_query_port_wol (struct mlx5_core_dev *mdev,u8 *wol_mode) {
@@ -860,7 +841,6 @@ int mlx5_query_port_wol(struct mlx5_core_dev *mdev, u8 *wol_mode)return err; } -EXPORT_SYMBOL_GPL (mlx5_query_port_wol);int mlx5_query_ports_check (struct mlx5_core_dev *mdev,u32 *out,int outlen) {
include/linux/mlx5/port.h +1 -84
107 lines not on this page · raw message
Signature · 1 line
2.45.0
Tariq Toukan
maintainerPATCH v2 2/6 net/mlx5: Refactor link speed handling with mlx5_link_info struct
In reply to Tariq ToukanFrom: Shahar Shitrit <[email protected]>
Introduce struct mlx5_link_info with a speed field and change the types of mlx5e_link_speed and mlx5e_ext_link_speed from arrays of u32 to arrays of struct mlx5_link_info. These arrays are renamed to mlx5e_link_info and mlx5e_ext_link_info, respectively.
This change prepares for a future patch that will introduce a lanes field in struct mlx5_link_info and add lanes mapping alongside the speed for each link mode in the two arrays.
Additionally, rename function mlx5_port_speed2linkmodes() to mlx5_port_info2linkmodes() and function mlx5_port_ptys2speed() to mlx5_port_ptys2info() and update the speed parameter/return type to struct mlx5_link_info, in preparation for the upcoming patch where these functions will also utilize the lanes field.
--- .../net/ethernet/mellanox/mlx5/core/en/port.c | 9 +- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 24 ++- .../ethernet/mellanox/mlx5/core/mlx5_core.h | 14 +- .../net/ethernet/mellanox/mlx5/core/port.c | 144 +++++++++--------- 4 files changed, 103 insertions(+), 88 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/port.c +7 -2
@@ -80,6 +80,7 @@ int mlx5_port_set_eth_ptys(struct mlx5_core_dev *dev, bool an_disable,int mlx5e_port_linkspeed (struct mlx5_core_dev *mdev,u32 *speed) {struct mlx5_port_eth_proto eproto; +const struct mlx5_link_info *info;bool force_legacy = false;bool ext;int err;
@@ -94,9 +95,13 @@ int mlx5e_port_linkspeed(struct mlx5_core_dev *mdev, u32 *speed)if (err) goto out; } - *speed =mlx5_port_ptys2speed (mdev, eproto.oper, force_legacy); -if (!(*speed)) + info =mlx5_port_ptys2info (mdev, eproto.oper, force_legacy); +if (!info) { + *speed =SPEED_UNKNOWN ; err = -EINVAL ; + goto out; + } + *speed = info->speed; out:return err;
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +11 -13
@@ -1082,23 +1082,21 @@ static void get_speed_duplex(struct net_device *netdev, struct ethtool_link_ksettings *link_ksettings) {struct mlx5e_priv *priv =netdev_priv (netdev); -u32 speed =SPEED_UNKNOWN ; +const struct mlx5_link_info *info;u8 duplex =DUPLEX_UNKNOWN ; +u32 speed =SPEED_UNKNOWN ;if (!netif_carrier_ok (netdev)) goto out; - speed =mlx5_port_ptys2speed (priv->mdev, eth_proto_oper, force_legacy); -if (!speed) { -if (data_rate_oper) - speed =100 * data_rate_oper; -else - speed =SPEED_UNKNOWN ; - goto out; + info =mlx5_port_ptys2info (priv->mdev, eth_proto_oper, force_legacy); +if (info) { + speed = info->speed; + duplex =DUPLEX_FULL ; + }else if (data_rate_oper) { + speed =100 * data_rate_oper; } - duplex =DUPLEX_FULL ; - out: link_ksettings->base.speed = speed; link_ksettings->base.duplex = duplex;
@@ -1349,6 +1347,7 @@ static int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv, {struct mlx5_core_dev *mdev = priv->mdev;struct mlx5_port_eth_proto eproto; +struct mlx5_link_info info = {};const unsigned long *adver;bool an_changes = false;u8 an_disable_admin;
@@ -1359,7 +1358,6 @@ static int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv,u32 link_modes;u8 an_status;u8 autoneg; -u32 speed;bool ext;int err;
@@ -1367,7 +1365,7 @@ static int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv, adver = link_ksettings->link_modes.advertising; autoneg = link_ksettings->base.autoneg; - speed = link_ksettings->base.speed; + info.speed = link_ksettings->base.speed; ext_supported =mlx5_ptys_ext_supported (mdev); ext_requested =ext_link_mode_requested (adver);
@@ -1384,7 +1382,7 @@ static int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv, goto out; } link_modes = autoneg ==AUTONEG_ENABLE ?ethtool2ptys_adver_func (adver) : -mlx5_port_speed2linkmodes (mdev, speed, !ext); +mlx5_port_info2linkmodes (mdev, &info, !ext); err =mlx5e_speed_validate (priv->netdev, ext, link_modes, autoneg);if (err)
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +10 -4
@@ -129,6 +129,10 @@ struct mlx5_module_eeprom_query_params {u32 module_number; }; +struct mlx5_link_info { +u32 speed; +}; +static inline void mlx5_printk (struct mlx5_core_dev *dev,int level,const char *format, ...) {struct device *device = dev->device;
@@ -359,10 +363,12 @@ int mlx5_query_dscp2prio(struct mlx5_core_dev *mdev, u8 *dscp2prio);int mlx5_port_query_eth_proto (struct mlx5_core_dev *dev,u8 port,bool ext,struct mlx5_port_eth_proto *eproto);bool mlx5_ptys_ext_supported (struct mlx5_core_dev *mdev); -u32 mlx5_port_ptys2speed (struct mlx5_core_dev *mdev,u32 eth_proto_oper, -bool force_legacy); -u32 mlx5_port_speed2linkmodes (struct mlx5_core_dev *mdev,u32 speed, -bool force_legacy); +const struct mlx5_link_info *mlx5_port_ptys2info (struct mlx5_core_dev *mdev, +u32 eth_proto_oper, +bool force_legacy); +u32 mlx5_port_info2linkmodes (struct mlx5_core_dev *mdev, +struct mlx5_link_info *info, +bool force_legacy);int mlx5_port_max_linkspeed (struct mlx5_core_dev *mdev,u32 *speed);#define MLX5_PPS_CAP (mdev) (MLX5_CAP_GEN((mdev), pps) && \
drivers/net/ethernet/mellanox/mlx5/core/port.c +75 -69
194 lines not on this page · raw message
Signature · 1 line
2.45.0
Tariq Toukan
maintainerPATCH v2 3/6 net/mlx5e: Enable lanes configuration when auto-negotiation is off
In reply to Tariq ToukanFrom: Shahar Shitrit <[email protected]>
Currently, when auto-negotiation is disabled, the driver retrieves the speed and converts it into all link modes that correspond to that speed. With this patch, we add the ability to set the number of lanes, so that the combination of speed and lanes corresponds to exactly one specific link mode for the extended bit map.
For the legacy bit map the driver sets all link modes correspond to speed and lanes.
This change provides users with the option to set a specific link mode, rather than enabling all link modes associated with a given speed when auto-negotiation is off.
--- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 23 +++-- .../ethernet/mellanox/mlx5/core/mlx5_core.h | 1 + .../net/ethernet/mellanox/mlx5/core/port.c | 98 ++++++++++--------- 3 files changed, 67 insertions(+), 55 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +16 -7
@@ -42,6 +42,9 @@#include "lib/clock.h" #include "en/fs_ethtool.h" +#define LANES_UNKNOWN 0 +#define MAX_LANES 8 +void mlx5e_ethtool_get_drvinfo (struct mlx5e_priv *priv,struct ethtool_drvinfo *drvinfo) {
@@ -1076,15 +1079,16 @@ static void ptys2ethtool_supported_advertised_port(struct mlx5_core_dev *mdev, } } -static void get_speed_duplex (struct net_device *netdev, -u32 eth_proto_oper,bool force_legacy, -u16 data_rate_oper, -struct ethtool_link_ksettings *link_ksettings) +static void get_link_properties (struct net_device *netdev, +u32 eth_proto_oper,bool force_legacy, +u16 data_rate_oper, +struct ethtool_link_ksettings *link_ksettings) {struct mlx5e_priv *priv =netdev_priv (netdev);const struct mlx5_link_info *info;u8 duplex =DUPLEX_UNKNOWN ;u32 speed =SPEED_UNKNOWN ; +u32 lanes =LANES_UNKNOWN ;if (!netif_carrier_ok (netdev)) goto out;
@@ -1092,14 +1096,17 @@ static void get_speed_duplex(struct net_device *netdev, info =mlx5_port_ptys2info (priv->mdev, eth_proto_oper, force_legacy);if (info) { speed = info->speed; + lanes = info->lanes; duplex =DUPLEX_FULL ; }else if (data_rate_oper) { speed =100 * data_rate_oper; + lanes =MAX_LANES ; } out: - link_ksettings->base.speed = speed; link_ksettings->base.duplex = duplex; + link_ksettings->base.speed = speed; + link_ksettings->lanes = lanes; } static void get_supported(struct mlx5_core_dev *mdev, u32 eth_proto_cap,
@@ -1236,8 +1243,8 @@ static int mlx5e_ethtool_get_link_ksettings(struct mlx5e_priv *priv,get_supported (mdev, eth_proto_cap, link_ksettings);get_advertising (eth_proto_admin, tx_pause, rx_pause, link_ksettings, admin_ext); -get_speed_duplex (priv->netdev, eth_proto_oper, !admin_ext, - data_rate_oper, link_ksettings); +get_link_properties (priv->netdev, eth_proto_oper, !admin_ext, + data_rate_oper, link_ksettings); eth_proto_oper = eth_proto_oper ? eth_proto_oper : eth_proto_cap; connector_type = connector_type < MLX5E_CONNECTOR_TYPE_NUMBER ?
@@ -1366,6 +1373,7 @@ static int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv, adver = link_ksettings->link_modes.advertising; autoneg = link_ksettings->base.autoneg; info.speed = link_ksettings->base.speed; + info.lanes = link_ksettings->lanes; ext_supported =mlx5_ptys_ext_supported (mdev); ext_requested =ext_link_mode_requested (adver);
@@ -2613,6 +2621,7 @@ static void mlx5e_get_ts_stats(struct net_device *netdev, }const struct ethtool_ops mlx5e_ethtool_ops = { + .cap_link_lanes_supported = true, .cap_rss_ctx_supported = true, .rxfh_per_ctx_key = true, .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +1 -0
@@ -131,6 +131,7 @@ struct mlx5_module_eeprom_query_params {struct mlx5_link_info {u32 speed; +u32 lanes; };static inline void mlx5_printk (struct mlx5_core_dev *dev,int level,const char *format, ...)
drivers/net/ethernet/mellanox/mlx5/core/port.c +50 -48
114 lines not on this page · raw message
Signature · 1 line
2.45.0
Tariq Toukan
maintainerPATCH v2 4/6 net/mlx5: Lag, Enable Multiport E-Switch offloads on 8 ports LAG
In reply to Tariq ToukanFrom: Amir Tzin <[email protected]>
Patch [1] added mlx5 driver support for 8 ports HCAs which are available since ConnectX-8. Now that Multiport E-Switch is tested, we can enable it by removing flag MLX5_LAG_MPESW_OFFLOADS_SUPPORTED_PORTS.
[1]
commit e0e6adfe8c20 ("net/mlx5: Enable 8 ports LAG")
--- drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c +0 -4
@@ -65,7 +65,6 @@ static int mlx5_mpesw_metadata_set(struct mlx5_lag *ldev)return err; } -#define MLX5_LAG_MPESW_OFFLOADS_SUPPORTED_PORTS 4static int enable_mpesw (struct mlx5_lag *ldev) {int idx =mlx5_lag_get_dev_index_by_seq (ldev,MLX5_LAG_P1 );
@@ -77,9 +76,6 @@ static int enable_mpesw(struct mlx5_lag *ldev)return -EINVAL ; dev0 = ldev->pf[idx].dev; -if (ldev->ports >MLX5_LAG_MPESW_OFFLOADS_SUPPORTED_PORTS ) -return -EOPNOTSUPP ; - if (mlx5_eswitch_mode(dev0) != MLX5_ESWITCH_OFFLOADS || !MLX5_CAP_PORT_SELECTION(dev0, port_select_flow_table) || !MLX5_CAP_GEN(dev0, create_lag_when_not_master_up) ||
Signature · 1 line
2.45.0
Tariq Toukan
maintainerPATCH v2 5/6 net/mlx5e: Separate address related variables to be in struct
In reply to Tariq ToukanFrom: Leon Romanovsky <[email protected]>
Prepare the code to addition of prefix handling logic which is needed to support matching logic based on source and/or destination network prefixes.
--- .../mellanox/mlx5/core/en_accel/ipsec.c | 32 ++++---- .../mellanox/mlx5/core/en_accel/ipsec.h | 26 +++---- .../mellanox/mlx5/core/en_accel/ipsec_fs.c | 75 +++++++++++-------- 3 files changed, 68 insertions(+), 65 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +17 -15
@@ -277,12 +277,12 @@ static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry,case XFRM_DEV_OFFLOAD_IN : src = attrs->dmac; dst = attrs->smac; - pkey = &attrs->saddr.a4; + pkey = &attrs->addrs.saddr.a4;break ;case XFRM_DEV_OFFLOAD_OUT : src = attrs->smac; dst = attrs->dmac; - pkey = &attrs->daddr.a4; + pkey = &attrs->addrs.daddr.a4;break ;default :return ;
@@ -374,9 +374,10 @@ void mlx5e_ipsec_build_accel_xfrm_attrs(struct mlx5e_ipsec_sa_entry *sa_entry, attrs->spi =be32_to_cpu (x->id.spi);/* source , destination ips */ -memcpy (&attrs->saddr, x->props.saddr.a6,sizeof (attrs->saddr)); -memcpy (&attrs->daddr, x->id.daddr.a6,sizeof (attrs->daddr)); - attrs->family = x->props.family; +memcpy (&attrs->addrs.saddr, x->props.saddr.a6, +sizeof (attrs->addrs.saddr)); +memcpy (&attrs->addrs.daddr, x->id.daddr.a6,sizeof (attrs->addrs.daddr)); + attrs->addrs.family = x->props.family; attrs->type = x->xso.type; attrs->reqid = x->props.reqid; attrs->upspec.dport =ntohs (x->sel.dport);
@@ -428,7 +429,8 @@ static int mlx5e_xfrm_validate_state(struct mlx5_core_dev *mdev, }if (x->encap) {if (!(mlx5_ipsec_device_caps (mdev) &MLX5_IPSEC_CAP_ESPINUDP )) { -NL_SET_ERR_MSG_MOD (extack,"Encapsulation is not supported" ); +NL_SET_ERR_MSG_MOD (extack, +"Encapsulation is not supported" );return -EINVAL ; }
@@ -853,13 +855,13 @@ static int mlx5e_ipsec_netevent_event(struct notifier_block *nb,xa_for_each_marked (&ipsec->sadb, idx, sa_entry,MLX5E_IPSEC_TUNNEL_SA ) { attrs = &sa_entry->attrs; -if (attrs->family ==AF_INET ) { -if (!neigh_key_eq32 (n, &attrs->saddr.a4) && - !neigh_key_eq32 (n, &attrs->daddr.a4)) +if (attrs->addrs.family ==AF_INET ) { +if (!neigh_key_eq32 (n, &attrs->addrs.saddr.a4) && + !neigh_key_eq32 (n, &attrs->addrs.daddr.a4))continue ; }else { -if (!neigh_key_eq128 (n, &attrs->saddr.a4) && - !neigh_key_eq128 (n, &attrs->daddr.a4)) +if (!neigh_key_eq128 (n, &attrs->addrs.saddr.a4) && + !neigh_key_eq128 (n, &attrs->addrs.daddr.a4))continue ; }
@@ -1035,7 +1037,7 @@ static void mlx5e_xfrm_update_stats(struct xfrm_state *x)* by removing always available headers. */ headers =sizeof (struct ethhdr ); -if (sa_entry->attrs.family ==AF_INET ) +if (sa_entry->attrs.addrs.family ==AF_INET ) headers +=sizeof (struct iphdr );else headers +=sizeof (struct ipv6hdr );
@@ -1116,9 +1118,9 @@ mlx5e_ipsec_build_accel_pol_attrs(struct mlx5e_ipsec_pol_entry *pol_entry, sel = &x->selector;memset (attrs,0 ,sizeof (*attrs)); -memcpy (&attrs->saddr, sel->saddr.a6,sizeof (attrs->saddr)); -memcpy (&attrs->daddr, sel->daddr.a6,sizeof (attrs->daddr)); - attrs->family = sel->family; +memcpy (&attrs->addrs.saddr, sel->saddr.a6,sizeof (attrs->addrs.saddr)); +memcpy (&attrs->addrs.daddr, sel->daddr.a6,sizeof (attrs->addrs.daddr)); + attrs->addrs.family = sel->family; attrs->dir = x->xdo.dir; attrs->action = x->action; attrs->type =XFRM_DEV_OFFLOAD_PACKET ;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h +9 -17
@@ -76,11 +76,7 @@ struct mlx5_replay_esn { u8 trigger : 1; }; -struct mlx5_accel_esp_xfrm_attrs { -u32 spi; -u32 mode; -struct aes_gcm_keymat aes_gcm; - +struct mlx5e_ipsec_addr {union {__be32 a4;__be32 a6[4 ];
@@ -90,13 +86,19 @@ struct mlx5_accel_esp_xfrm_attrs {__be32 a4;__be32 a6[4 ]; } daddr; +u8 family; +}; +struct mlx5_accel_esp_xfrm_attrs { +u32 spi; +u32 mode; +struct aes_gcm_keymat aes_gcm; +struct mlx5e_ipsec_addr addrs;struct upspec upspec;u8 dir :2 ;u8 type :2 ;u8 drop :1 ;u8 encap :1 ; -u8 family;struct mlx5_replay_esn replay_esn;u32 authsize;u32 reqid;
@@ -279,18 +281,8 @@ struct mlx5e_ipsec_sa_entry { };struct mlx5_accel_pol_xfrm_attrs { -union { -__be32 a4; -__be32 a6[4 ]; - } saddr; - -union { -__be32 a4; -__be32 a6[4 ]; - } daddr; - +struct mlx5e_ipsec_addr addrs;struct upspec upspec; -u8 family;u8 action;u8 type :2 ;u8 dir :2 ;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c +42 -33
194 lines not on this page · raw message
Signature · 1 line
2.45.0
Tariq Toukan
maintainerPATCH v2 6/6 net/mlx5e: Properly match IPsec subnet addresses
In reply to Tariq ToukanFrom: Leon Romanovsky <[email protected]>
Existing match criteria didn't allow to match whole subnet and only by specific addresses only. This caused to tunnel mode do not forward such traffic through relevant SA.
In tunnel mode, policies look like this:
src 192.169.0.0/16 dst 192.169.0.0/16
dir out priority 383615 ptype main
tmpl src 192.169.101.2 dst 192.169.101.1
proto esp spi 0xc5141c18 reqid 1 mode tunnel
crypto offload parameters: dev eth2 mode packet
In this case, the XFRM core code handled all subnet calculations and forwarded network address to the drivers e.g. 192.169.0.0.
For mlx5 devices, there is a need to set relevant prefix e.g. 0xFFFF00 to perform flow steering match operation.
--- .../mellanox/mlx5/core/en_accel/ipsec.c | 49 +++++++++++++++++++ .../mellanox/mlx5/core/en_accel/ipsec.h | 9 +++- .../mellanox/mlx5/core/en_accel/ipsec_fs.c | 20 +++++--- 3 files changed, 69 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +49 -0
@@ -303,6 +303,16 @@ static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry,neigh_release (n); } +static void mlx5e_ipsec_state_mask (struct mlx5e_ipsec_addr *addrs) +{ +/* +* State doesn't have subnet prefixes in outer headers. +* The match is performed for exaxt source/destination addresses. +*/ +memset (addrs->smask.m6,0xFF ,sizeof (__be32) *4 ); +memset (addrs->dmask.m6,0xFF ,sizeof (__be32) *4 ); +} +void mlx5e_ipsec_build_accel_xfrm_attrs (struct mlx5e_ipsec_sa_entry *sa_entry,struct mlx5_accel_esp_xfrm_attrs *attrs) {
@@ -378,6 +388,7 @@ void mlx5e_ipsec_build_accel_xfrm_attrs(struct mlx5e_ipsec_sa_entry *sa_entry, sizeof(attrs->addrs.saddr));memcpy (&attrs->addrs.daddr, x->id.daddr.a6,sizeof (attrs->addrs.daddr)); attrs->addrs.family = x->props.family; +mlx5e_ipsec_state_mask (&attrs->addrs); attrs->type = x->xso.type; attrs->reqid = x->props.reqid; attrs->upspec.dport =ntohs (x->sel.dport);
@@ -1046,6 +1057,43 @@ static void mlx5e_xfrm_update_stats(struct xfrm_state *x) x->curlft.bytes += success_bytes - headers * success_packets; } +static __be32 word_to_mask (int prefix) +{ +if (prefix <0 ) +return 0 ; + +if (!prefix || prefix >31 ) +return cpu_to_be32 (0xFFFFFFFF ); + +return cpu_to_be32 (((1U << prefix) -1 ) << (32 - prefix)); +} + +static void mlx5e_ipsec_policy_mask (struct mlx5e_ipsec_addr *addrs, +struct xfrm_selector *sel) +{ +int i; + +if (addrs->family ==AF_INET ) { + addrs->smask.m4 =word_to_mask (sel->prefixlen_s); + addrs->saddr.a4 &= addrs->smask.m4; + addrs->dmask.m4 =word_to_mask (sel->prefixlen_d); + addrs->daddr.a4 &= addrs->dmask.m4; +return ; + } + +for (i =0 ; i <4 ; i++) { +if (sel->prefixlen_s !=32 * i) + addrs->smask.m6[i] = +word_to_mask (sel->prefixlen_s -32 * i); + addrs->saddr.a6[i] &= addrs->smask.m6[i]; + +if (sel->prefixlen_d !=32 * i) + addrs->dmask.m6[i] = +word_to_mask (sel->prefixlen_d -32 * i); + addrs->daddr.a6[i] &= addrs->dmask.m6[i]; + } +} +static int mlx5e_xfrm_validate_policy (struct mlx5_core_dev *mdev,struct xfrm_policy *x,struct netlink_ext_ack *extack)
@@ -1121,6 +1169,7 @@ mlx5e_ipsec_build_accel_pol_attrs(struct mlx5e_ipsec_pol_entry *pol_entry,memcpy (&attrs->addrs.saddr, sel->saddr.a6,sizeof (attrs->addrs.saddr));memcpy (&attrs->addrs.daddr, sel->daddr.a6,sizeof (attrs->addrs.daddr)); attrs->addrs.family = sel->family; +mlx5e_ipsec_policy_mask (&attrs->addrs, sel); attrs->dir = x->xdo.dir; attrs->action = x->action; attrs->type =XFRM_DEV_OFFLOAD_PACKET ;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h +8 -1
@@ -81,11 +81,18 @@ struct mlx5e_ipsec_addr {__be32 a4;__be32 a6[4 ]; } saddr; - +union { +__be32 m4; +__be32 m6[4 ]; + } smask;union {__be32 a4;__be32 a6[4 ]; } daddr; +union { +__be32 m4; +__be32 m6[4 ]; + } dmask;u8 family; };
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c +12 -8
@@ -1488,7 +1488,9 @@ static void setup_fte_addr4(struct mlx5_flow_spec *spec, struct mlx5e_ipsec_addr *addrs) {__be32 *saddr = &addrs->saddr.a4; +__be32 *smask = &addrs->smask.m4;__be32 *daddr = &addrs->daddr.a4; +__be32 *dmask = &addrs->dmask.m4;if (!*saddr && !*daddr)return ;
@@ -1501,15 +1503,15 @@ static void setup_fte_addr4(struct mlx5_flow_spec *spec,if (*saddr) {memcpy (MLX5_ADDR_OF (fte_match_param, spec->match_value, outer_headers.src_ipv4_src_ipv6.ipv4_layout.ipv4), saddr,4 ); -MLX5_SET_TO_ONES (fte_match_param, spec->match_criteria, - outer_headers.src_ipv4_src_ipv6.ipv4_layout.ipv4); +memcpy (MLX5_ADDR_OF (fte_match_param, spec->match_criteria, + outer_headers.src_ipv4_src_ipv6.ipv4_layout.ipv4), smask,4 ); }if (*daddr) {memcpy (MLX5_ADDR_OF (fte_match_param, spec->match_value, outer_headers.dst_ipv4_dst_ipv6.ipv4_layout.ipv4), daddr,4 ); -MLX5_SET_TO_ONES (fte_match_param, spec->match_criteria, - outer_headers.dst_ipv4_dst_ipv6.ipv4_layout.ipv4); +memcpy (MLX5_ADDR_OF (fte_match_param, spec->match_criteria, + outer_headers.dst_ipv4_dst_ipv6.ipv4_layout.ipv4), dmask,4 ); } }
@@ -1517,7 +1519,9 @@ static void setup_fte_addr6(struct mlx5_flow_spec *spec, struct mlx5e_ipsec_addr *addrs) {__be32 *saddr = addrs->saddr.a6; +__be32 *smask = addrs->smask.m6;__be32 *daddr = addrs->daddr.a6; +__be32 *dmask = addrs->dmask.m6;if (addr6_all_zero (saddr) &&addr6_all_zero (daddr))return ;
@@ -1530,15 +1534,15 @@ static void setup_fte_addr6(struct mlx5_flow_spec *spec,if (!addr6_all_zero (saddr)) {memcpy (MLX5_ADDR_OF (fte_match_param, spec->match_value, outer_headers.src_ipv4_src_ipv6.ipv6_layout.ipv6), saddr,16 ); -memset (MLX5_ADDR_OF (fte_match_param, spec->match_criteria, - outer_headers.src_ipv4_src_ipv6.ipv6_layout.ipv6),0xff ,16 ); +memcpy (MLX5_ADDR_OF (fte_match_param, spec->match_criteria, + outer_headers.src_ipv4_src_ipv6.ipv6_layout.ipv6), dmask,16 ); }if (!addr6_all_zero (daddr)) {memcpy (MLX5_ADDR_OF (fte_match_param, spec->match_value, outer_headers.dst_ipv4_dst_ipv6.ipv6_layout.ipv6), daddr,16 ); -memset (MLX5_ADDR_OF (fte_match_param, spec->match_criteria, - outer_headers.dst_ipv4_dst_ipv6.ipv6_layout.ipv6),0xff ,16 ); +memcpy (MLX5_ADDR_OF (fte_match_param, spec->match_criteria, + outer_headers.dst_ipv4_dst_ipv6.ipv6_layout.ipv6), smask,16 ); } }
Signature · 1 line
2.45.0
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 Tue, 4 Mar 2025 18:06:14 +0200 you wrote:
Hi,
This is V2.
Find initial version here:
https://lore.kernel.org/lkml/[email protected]/This series introduces enhancements to the mlx5 core and Eth drivers.
[...]
Here is the summary with links:
- [net-next,V2,1/6] net/mlx5: Relocate function declarations from port.h to mlx5_core.h
https://git.kernel.org/netdev/net-next/c/a2f61f1db855 - [net-next,V2,2/6] net/mlx5: Refactor link speed handling with mlx5_link_info struct https://git.kernel.org/netdev/net-next/c/65a5d3557184 - [net-next,V2,3/6] net/mlx5e: Enable lanes configuration when auto-negotiation is off https://git.kernel.org/netdev/net-next/c/7e959797f021 - [net-next,V2,4/6] net/mlx5: Lag, Enable Multiport E-Switch offloads on 8 ports LAG https://git.kernel.org/netdev/net-next/c/5aa2e6de86d5 - [net-next,V2,5/6] net/mlx5e: Separate address related variables to be in struct https://git.kernel.org/netdev/net-next/c/348ed4b20546 - [net-next,V2,6/6] net/mlx5e: Properly match IPsec subnet addresses https://git.kernel.org/netdev/net-next/c/ca7992f52c2c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html