mlx5 fixes 2024-06-27
Subsystems (6)
Tariq Toukan
maintainerv2 cover mlx5 fixes 2024-06-27
Hi,
This patchset provides fixes from the team to the mlx5 core and EN drivers.
The first 3 patches by Daniel replace a buggy cap field with a newly introduced one.
Patch 4 by Chris de-couples ingress ACL creation from a specific flow, so it's invoked by other flows if needed.
Patch 5 by Jianbo fixes a possible missing cleanup of QoS objects.
Patches 6 and 7 by Leon fixes IPsec stats logic to better reflect the traffic.
Series generated against:
commit 02ea312055da ("octeontx2-pf: Fix coverity and klockwork issues in octeon PF driver")
Regards,
Tariq
V2:
Fixed wrong cited SHA in patch 6.
Chris Mi (1):
net/mlx5: E-switch, Create ingress ACL when needed
Daniel Jurgens (3):
net/mlx5: IFC updates for changing max EQs net/mlx5: Use max_num_eqs_24b capability if set net/mlx5: Use max_num_eqs_24b when setting max_io_eqs
Jianbo Liu (1):
net/mlx5e: Add mqprio_rl cleanup and free in mlx5e_priv_cleanup()
Leon Romanovsky (2):
net/mlx5e: Present succeeded IPsec SA bytes and packet net/mlx5e: Approximate IPsec per-SA payload data bytes count
.../mellanox/mlx5/core/en_accel/ipsec.c | 48 ++++++++++++++----- .../net/ethernet/mellanox/mlx5/core/en_main.c | 5 ++ drivers/net/ethernet/mellanox/mlx5/core/eq.c | 4 +- .../mellanox/mlx5/core/esw/acl/ingress_ofld.c | 37 ++++++++++---- .../mellanox/mlx5/core/eswitch_offloads.c | 22 +++++++-- .../ethernet/mellanox/mlx5/core/mlx5_core.h | 10 ++++ .../net/ethernet/mellanox/mlx5/core/pci_irq.c | 4 +- include/linux/mlx5/mlx5_ifc.h | 6 ++- 8 files changed, 103 insertions(+), 33 deletions(-)
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH v2 1/7 net/mlx5: IFC updates for changing max EQs
From: Daniel Jurgens <[email protected]>
Expose new capability to support changing the number of EQs available to other functions.
--- include/linux/mlx5/mlx5_ifc.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/linux/mlx5/mlx5_ifc.h +5 -1
@@ -2029,7 +2029,11 @@ struct mlx5_ifc_cmd_hca_cap_2_bits {u8 pcc_ifa2[0x1 ];u8 reserved_at_3f1[0xf ]; -u8 reserved_at_400[0x400 ]; +u8 reserved_at_400[0x40 ]; + +u8 reserved_at_440[0x8 ]; +u8 max_num_eqs_24b[0x18 ]; +u8 reserved_at_460[0x3a0 ]; };enum mlx5_ifc_flow_destination_type {
Signature · 1 line
2.31.1
Re: [PATCH net V2 1/7] net/mlx5: IFC updates for changing max EQs
Quoted 21 lines · Tariq Toukan
From: Daniel Jurgens <[email protected]>
Expose new capability to support changing the number of EQs available to other functions.
Fixes 93197c7c509d ("mlx5/core: Support max_io_eqs for a function")Signed-off-by Daniel Jurgens <[email protected]>Reviewed-by Parav Pandit <[email protected]>Reviewed-by William Tu <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- include/linux/mlx5/mlx5_ifc.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)include/linux/mlx5/mlx5_ifc.h +0
-0@@ -2029,7 +2029,11 @@ struct mlx5_ifc_cmd_hca_cap_2_bits {u8 pcc_ifa2[0x1 ];u8 reserved_at_3f1[0xf ];
include/linux/mlx5/mlx5_ifc.h struct mlx5_ifc_cmd_hca_cap_2_bits { · line 2039
Quoted 10 lines
include/linux/mlx5/mlx5_ifc.h +5
-1-u8 reserved_at_400[0x400 ]; +u8 reserved_at_400[0x40 ]; + +u8 reserved_at_440[0x8 ]; +u8 max_num_eqs_24b[0x18 ]; +u8 reserved_at_460[0x3a0 ]; };enum mlx5_ifc_flow_destination_type {
Hi,
Please note that this is expected to conflict with net-next commit:99be56171fa9 net/mlx5e: SHAMPO, Re-enable HW-GRO.
Resolution is
u8 reserved_at_400[0x1];
u8 min_mkey_log_entity_size_fixed_buffer_valid[0x1];
u8 reserved_at_402[0x1e]; u8 reserved_at_420[0x20];
u8 reserved_at_440[0x8];
u8 max_num_eqs_24b[0x18];
u8 reserved_at_460[0x3a0];Thanks,
Tariq
Tariq Toukan
maintainerPATCH v2 2/7 net/mlx5: Use max_num_eqs_24b capability if set
In reply to Tariq ToukanFrom: Daniel Jurgens <[email protected]>
A new capability with more bits is added. If it's set use that value as the maximum number of EQs available.
This cap is also writable by the vhca_resource_manager to allow limiting the number of EQs available to SFs and VFs.
--- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 4 +--- drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h | 10 ++++++++++ drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c | 4 +--- 3 files changed, 12 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eq.c +1 -3
@@ -1197,9 +1197,7 @@ static int get_num_eqs(struct mlx5_core_dev *dev)if (!mlx5_core_is_eth_enabled (dev) &&mlx5_eth_supported (dev))return 1 ; - max_dev_eqs =MLX5_CAP_GEN (dev, max_num_eqs) ? -MLX5_CAP_GEN (dev, max_num_eqs) : -1 <<MLX5_CAP_GEN (dev, log_max_eq); + max_dev_eqs =mlx5_max_eq_cap_get (dev); num_eqs =min_t (int,mlx5_irq_table_get_num_comp (eq_table->irq_table), max_dev_eqs -MLX5_MAX_ASYNC_EQS );
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +10 -0
@@ -383,4 +383,14 @@ static inline int mlx5_vport_to_func_id(const struct mlx5_core_dev *dev, u16 vpo : vport; } +static inline int mlx5_max_eq_cap_get (const struct mlx5_core_dev *dev) +{ +if (MLX5_CAP_GEN_2 (dev, max_num_eqs_24b)) +return MLX5_CAP_GEN_2 (dev, max_num_eqs_24b); + +if (MLX5_CAP_GEN (dev, max_num_eqs)) +return MLX5_CAP_GEN (dev, max_num_eqs); + +return 1 <<MLX5_CAP_GEN (dev, log_max_eq); +}#endif /* __MLX5_CORE_H__ */
drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c +1 -3
@@ -711,9 +711,7 @@ int mlx5_irq_table_get_num_comp(struct mlx5_irq_table *table)int mlx5_irq_table_create (struct mlx5_core_dev *dev) { -int num_eqs =MLX5_CAP_GEN (dev, max_num_eqs) ? -MLX5_CAP_GEN (dev, max_num_eqs) : -1 <<MLX5_CAP_GEN (dev, log_max_eq); +int num_eqs =mlx5_max_eq_cap_get (dev);int total_vec;int pcif_vec;int req_vec;
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH v2 3/7 net/mlx5: Use max_num_eqs_24b when setting max_io_eqs
In reply to Tariq ToukanFrom: Daniel Jurgens <[email protected]>
Due a bug in the device max_num_eqs doesn't always reflect a written value. As a result, setting max_io_eqs may not work but appear successful. Instead write max_num_eqs_24b, which reflects correct value.
--- .../mellanox/mlx5/core/eswitch_offloads.c | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +17 -5
@@ -4600,20 +4600,26 @@ mlx5_devlink_port_fn_max_io_eqs_get(struct devlink_port *port, u32 *max_io_eqs,return -EOPNOTSUPP ; } +if (!MLX5_CAP_GEN_2 (esw->dev, max_num_eqs_24b)) { +NL_SET_ERR_MSG_MOD (extack, +"Device doesn't support getting the max number of EQs" ); +return -EOPNOTSUPP ; + } + query_ctx =kzalloc (query_out_sz,GFP_KERNEL );if (!query_ctx)return -ENOMEM ;mutex_lock (&esw->state_lock); err =mlx5_vport_get_other_func_cap (esw->dev, vport_num, query_ctx, -MLX5_CAP_GENERAL ); +MLX5_CAP_GENERAL_2 );if (err) {NL_SET_ERR_MSG_MOD (extack,"Failed getting HCA caps" ); goto out; } hca_caps =MLX5_ADDR_OF (query_hca_cap_out, query_ctx, capability); - max_eqs =MLX5_GET (cmd_hca_cap, hca_caps, max_num_eqs); + max_eqs =MLX5_GET (cmd_hca_cap_2, hca_caps, max_num_eqs_24b);if (max_eqs <MLX5_ESW_MAX_CTRL_EQS ) *max_io_eqs =0 ;else
@@ -4644,6 +4650,12 @@ mlx5_devlink_port_fn_max_io_eqs_set(struct devlink_port *port, u32 max_io_eqs,return -EOPNOTSUPP ; } +if (!MLX5_CAP_GEN_2 (esw->dev, max_num_eqs_24b)) { +NL_SET_ERR_MSG_MOD (extack, +"Device doesn't support changing the max number of EQs" ); +return -EOPNOTSUPP ; + } +if (check_add_overflow (max_io_eqs,MLX5_ESW_MAX_CTRL_EQS , &max_eqs)) {NL_SET_ERR_MSG_MOD (extack,"Supplied value out of range" );return -EINVAL ;
@@ -4655,17 +4667,17 @@ mlx5_devlink_port_fn_max_io_eqs_set(struct devlink_port *port, u32 max_io_eqs,mutex_lock (&esw->state_lock); err =mlx5_vport_get_other_func_cap (esw->dev, vport_num, query_ctx, -MLX5_CAP_GENERAL ); +MLX5_CAP_GENERAL_2 );if (err) {NL_SET_ERR_MSG_MOD (extack,"Failed getting HCA caps" ); goto out; } hca_caps =MLX5_ADDR_OF (query_hca_cap_out, query_ctx, capability); -MLX5_SET (cmd_hca_cap, hca_caps, max_num_eqs, max_eqs); +MLX5_SET (cmd_hca_cap_2, hca_caps, max_num_eqs_24b, max_eqs); err =mlx5_vport_set_other_func_cap (esw->dev, hca_caps, vport_num, -MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE ); +MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE2 );if (err)NL_SET_ERR_MSG_MOD (extack,"Failed setting HCA caps" );
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH v2 4/7 net/mlx5: E-switch, Create ingress ACL when needed
In reply to Tariq ToukanFrom: Chris Mi <[email protected]>
Currently, ingress acl is used for three features. It is created only when vport metadata match and prio tag are enabled. But active-backup lag mode also uses it. It is independent of vport metadata match and prio tag. And vport metadata match can be disabled using the following devlink command:
# devlink dev param set pci/0000:08:00.0 name esw_port_metadata \ value false cmode runtime
If ingress acl is not created, will hit panic when creating drop rule for active-backup lag mode. If always create it, there will be about 5% performance degradation.
Fix it by creating ingress acl when needed. If esw_port_metadata is true, ingress acl exists, then create drop rule using existing ingress acl. If esw_port_metadata is false, create ingress acl and then create drop rule.
--- .../mellanox/mlx5/core/esw/acl/ingress_ofld.c | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_ofld.c +29 -8
@@ -6,6 +6,9 @@#include "helper.h" #include "ofld.h" +static int +acl_ingress_ofld_setup (struct mlx5_eswitch *esw,struct mlx5_vport *vport); +static bool esw_acl_ingress_prio_tag_enabled (struct mlx5_eswitch *esw,const struct mlx5_vport *vport)
@@ -123,18 +126,31 @@ static int esw_acl_ingress_src_port_drop_create(struct mlx5_eswitch *esw, {struct mlx5_flow_act flow_act = {};struct mlx5_flow_handle *flow_rule; +bool created = false;int err =0 ; +if (!vport->ingress.acl) { + err =acl_ingress_ofld_setup (esw, vport); +if (err) +return err; + created = true; + } + flow_act.action =MLX5_FLOW_CONTEXT_ACTION_DROP ; flow_act.fg = vport->ingress.offloads.drop_grp; flow_rule =mlx5_add_flow_rules (vport->ingress.acl,NULL , &flow_act,NULL ,0 );if (IS_ERR (flow_rule)) { err =PTR_ERR (flow_rule); - goto out; + goto err_out; } vport->ingress.offloads.drop_rule = flow_rule; -out: + +return 0 ; +err_out: +/* Only destroy ingress acl created in this function. */ +if (created) +esw_acl_ingress_ofld_cleanup (esw, vport);return err; }
@@ -299,16 +315,12 @@ static void esw_acl_ingress_ofld_groups_destroy(struct mlx5_vport *vport) } } -int esw_acl_ingress_ofld_setup (struct mlx5_eswitch *esw, -struct mlx5_vport *vport) +static int +acl_ingress_ofld_setup (struct mlx5_eswitch *esw,struct mlx5_vport *vport) {int num_ftes =0 ;int err; -if (!mlx5_eswitch_vport_match_metadata_enabled (esw) && - !esw_acl_ingress_prio_tag_enabled (esw, vport)) -return 0 ; -esw_acl_ingress_allow_rule_destroy (vport);if (mlx5_eswitch_vport_match_metadata_enabled (esw))
@@ -347,6 +359,15 @@ int esw_acl_ingress_ofld_setup(struct mlx5_eswitch *esw,return err; } +int esw_acl_ingress_ofld_setup (struct mlx5_eswitch *esw,struct mlx5_vport *vport) +{ +if (!mlx5_eswitch_vport_match_metadata_enabled (esw) && + !esw_acl_ingress_prio_tag_enabled (esw, vport)) +return 0 ; + +return acl_ingress_ofld_setup (esw, vport); +} +void esw_acl_ingress_ofld_cleanup (struct mlx5_eswitch *esw,struct mlx5_vport *vport) {
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH v2 5/7 net/mlx5e: Add mqprio_rl cleanup and free in mlx5e_priv_cleanup()
In reply to Tariq ToukanFrom: Jianbo Liu <[email protected]>
In the cited commit, mqprio_rl cleanup and free are mistakenly removed in mlx5e_priv_cleanup(), and it causes the leakage of host memory and firmware SCHEDULING_ELEMENT objects while changing eswitch mode. So, add them back.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +5 -0
@@ -5868,6 +5868,11 @@ void mlx5e_priv_cleanup(struct mlx5e_priv *priv)kfree (priv->htb_qos_sq_stats[i]);kvfree (priv->htb_qos_sq_stats); +if (priv->mqprio_rl) { +mlx5e_mqprio_rl_cleanup (priv->mqprio_rl); +mlx5e_mqprio_rl_free (priv->mqprio_rl); + } +memset (priv,0 ,sizeof (*priv)); }
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH v2 6/7 net/mlx5e: Present succeeded IPsec SA bytes and packet
In reply to Tariq ToukanFrom: Leon Romanovsky <[email protected]>
IPsec SA statistics presents successfully decrypted and encrypted packet and bytes, and not total handled by this SA. So update the calculation logic to take into account failures.
--- .../mellanox/mlx5/core/en_accel/ipsec.c | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +23 -13
@@ -989,6 +989,10 @@ static void mlx5e_xfrm_update_stats(struct xfrm_state *x)struct mlx5e_ipsec_sa_entry *sa_entry =to_ipsec_sa_entry (x);struct mlx5e_ipsec_rule *ipsec_rule = &sa_entry->ipsec_rule;struct net *net =dev_net (x->xso.dev); +u64 trailer_packets =0 , trailer_bytes =0 ; +u64 replay_packets =0 , replay_bytes =0 ; +u64 auth_packets =0 , auth_bytes =0 ; +u64 success_packets, success_bytes;u64 packets, bytes, lastuse; lockdep_assert(lockdep_is_held(&x->lock) ||
@@ -999,26 +1003,32 @@ static void mlx5e_xfrm_update_stats(struct xfrm_state *x)return ;if (sa_entry->attrs.dir ==XFRM_DEV_OFFLOAD_IN ) { -mlx5_fc_query_cached (ipsec_rule->auth.fc, &bytes, &packets, &lastuse); - x->stats.integrity_failed += packets; -XFRM_ADD_STATS (net,LINUX_MIB_XFRMINSTATEPROTOERROR , packets); - -mlx5_fc_query_cached (ipsec_rule->trailer.fc, &bytes, &packets, &lastuse); -XFRM_ADD_STATS (net,LINUX_MIB_XFRMINHDRERROR , packets); +mlx5_fc_query_cached (ipsec_rule->auth.fc, &auth_bytes, + &auth_packets, &lastuse); + x->stats.integrity_failed += auth_packets; +XFRM_ADD_STATS (net,LINUX_MIB_XFRMINSTATEPROTOERROR , auth_packets); + +mlx5_fc_query_cached (ipsec_rule->trailer.fc, &trailer_bytes, + &trailer_packets, &lastuse); +XFRM_ADD_STATS (net,LINUX_MIB_XFRMINHDRERROR , trailer_packets); }if (x->xso.type !=XFRM_DEV_OFFLOAD_PACKET )return ; -mlx5_fc_query_cached (ipsec_rule->fc, &bytes, &packets, &lastuse); - x->curlft.packets += packets; - x->curlft.bytes += bytes; -if (sa_entry->attrs.dir ==XFRM_DEV_OFFLOAD_IN ) { -mlx5_fc_query_cached (ipsec_rule->replay.fc, &bytes, &packets, &lastuse); - x->stats.replay += packets; -XFRM_ADD_STATS (net,LINUX_MIB_XFRMINSTATESEQERROR , packets); +mlx5_fc_query_cached (ipsec_rule->replay.fc, &replay_bytes, + &replay_packets, &lastuse); + x->stats.replay += replay_packets; +XFRM_ADD_STATS (net,LINUX_MIB_XFRMINSTATESEQERROR , replay_packets); } + +mlx5_fc_query_cached (ipsec_rule->fc, &bytes, &packets, &lastuse); + success_packets = packets - auth_packets - trailer_packets - replay_packets; + x->curlft.packets += success_packets; + + success_bytes = bytes - auth_bytes - trailer_bytes - replay_bytes; + x->curlft.bytes += success_bytes; } static int mlx5e_xfrm_validate_policy(struct mlx5_core_dev *mdev,
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH v2 7/7 net/mlx5e: Approximate IPsec per-SA payload data bytes count
In reply to Tariq ToukanFrom: Leon Romanovsky <[email protected]>
ConnectX devices lack ability to count payload data byte size which is needed for SA to return to libreswan for rekeying.
As a solution let's approximate that by decreasing headers size from total size counted by flow steering. The calculation doesn't take into account any other headers which can be in the packet (e.g. IP extensions).
--- .../ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +13 -1
@@ -994,6 +994,7 @@ static void mlx5e_xfrm_update_stats(struct xfrm_state *x)u64 auth_packets =0 , auth_bytes =0 ;u64 success_packets, success_bytes;u64 packets, bytes, lastuse; +size_t headers; lockdep_assert(lockdep_is_held(&x->lock) || lockdep_is_held(&dev_net(x->xso.real_dev)->xfrm.xfrm_cfg_mutex) ||
@@ -1026,9 +1027,20 @@ static void mlx5e_xfrm_update_stats(struct xfrm_state *x)mlx5_fc_query_cached (ipsec_rule->fc, &bytes, &packets, &lastuse); success_packets = packets - auth_packets - trailer_packets - replay_packets; x->curlft.packets += success_packets; +/* NIC counts all bytes passed through flow steering and doesn't have +* an ability to count payload data size which is needed for SA. +* +* To overcome HW limitestion, let's approximate the payload size +* by removing always available headers. +*/ + headers =sizeof (struct ethhdr ); +if (sa_entry->attrs.family ==AF_INET ) + headers +=sizeof (struct iphdr ); +else + headers +=sizeof (struct ipv6hdr ); success_bytes = bytes - auth_bytes - trailer_bytes - replay_bytes; - x->curlft.bytes += success_bytes; + x->curlft.bytes += success_bytes - headers * success_packets; } static int mlx5e_xfrm_validate_policy(struct mlx5_core_dev *mdev,
Signature · 1 line
2.31.1
This series was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 9 lines · On Thu, 27 Jun 2024 21:02:33 +0300 you wrote:
Hi,
This patchset provides fixes from the team to the mlx5 core and EN drivers.
The first 3 patches by Daniel replace a buggy cap field with a newly introduced one.
[...]
Here is the summary with links:
- [net,V2,1/7] net/mlx5: IFC updates for changing max EQs
https://git.kernel.org/netdev/net/c/048a403648fc - [net,V2,2/7] net/mlx5: Use max_num_eqs_24b capability if set https://git.kernel.org/netdev/net/c/29c6a562bf53 - [net,V2,3/7] net/mlx5: Use max_num_eqs_24b when setting max_io_eqs https://git.kernel.org/netdev/net/c/5dbf647367e8 - [net,V2,4/7] net/mlx5: E-switch, Create ingress ACL when needed https://git.kernel.org/netdev/net/c/b20c2fb45470 - [net,V2,5/7] net/mlx5e: Add mqprio_rl cleanup and free in mlx5e_priv_cleanup() https://git.kernel.org/netdev/net/c/1da839eab6db - [net,V2,6/7] net/mlx5e: Present succeeded IPsec SA bytes and packet https://git.kernel.org/netdev/net/c/2d9dac5559f8 - [net,V2,7/7] net/mlx5e: Approximate IPsec per-SA payload data bytes count https://git.kernel.org/netdev/net/c/e562f2d46d27
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html