mlx5 fixes 2023-06-16
Subsystems (5)
From: Saeed Mahameed <[email protected]>
This series provides bug fixes to mlx5 driver. Please pull and let me know if there is any problem.
Thanks,
Saeed.
The following changes since commit d4e067287b41b9eba278533d32afda35b25fbdd5:
Merge branch 'check-if-fips-mode-is-enabled-when-running-selftests' (2023-06-15 22:24:03 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2023-06-16
for you to fetch changes up to a128f9d4c1227dfcf7f2328070760cb7ed1ec08d:
net/mlx5e: Fix scheduling of IPsec ASO query while in atomic (2023-06-16 12:59:20 -0700)
----------------------------------------------------------------
mlx5-fixes-2023-06-16
----------------------------------------------------------------
Chris Mi (2):
net/mlx5e: TC, Add null pointer check for hardware miss support net/mlx5e: TC, Cleanup ct resources for nic flow
Eli Cohen (1):
net/mlx5: Fix driver load with single msix vector
Leon Romanovsky (3):
net/mlx5e: Don't delay release of hardware objects net/mlx5e: Drop XFRM state lock when modifying flow steering net/mlx5e: Fix scheduling of IPsec ASO query while in atomic
Maxim Mikityanskiy (2):
net/mlx5e: XDP, Allow growing tail for XDP multi buffer net/mlx5e: xsk: Set napi_id to support busy polling on XSK RQ
Patrisious Haddad (1):
net/mlx5e: Fix ESN update kernel panic
Saeed Mahameed (1):
net/mlx5: Free IRQ rmap and notifier on kernel shutdown
Yevgeny Kliteynik (2):
net/mlx5: DR, Support SW created encap actions for FW table net/mlx5: DR, Fix wrong action data allocation in decap action
.../net/ethernet/mellanox/mlx5/core/en/params.c | 8 +++- .../net/ethernet/mellanox/mlx5/core/en/params.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 2 + .../net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 2 +- .../ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 22 +++++++--- .../mellanox/mlx5/core/en_accel/ipsec_offload.c | 17 ++++++-- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 7 +-- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 50 ++++++++++++++++------ drivers/net/ethernet/mellanox/mlx5/core/fs_core.h | 7 +++ drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c | 33 +++++++++++--- .../mellanox/mlx5/core/steering/dr_action.c | 13 +++++- .../ethernet/mellanox/mlx5/core/steering/fs_dr.c | 27 +++++++++++- .../ethernet/mellanox/mlx5/core/steering/fs_dr.h | 7 +++ .../ethernet/mellanox/mlx5/core/steering/mlx5dr.h | 2 + 15 files changed, 163 insertions(+), 36 deletions(-)
PATCH 1/12 net/mlx5e: XDP, Allow growing tail for XDP multi buffer
From: Maxim Mikityanskiy <[email protected]>
The cited commits missed passing frag_size to __xdp_rxq_info_reg, which is required by bpf_xdp_adjust_tail to support growing the tail pointer in fragmented packets. Pass the missing parameter when the current RQ mode allows XDP multi buffer.
--- drivers/net/ethernet/mellanox/mlx5/core/en/params.c | 8 ++++++-- drivers/net/ethernet/mellanox/mlx5/core/en/params.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 7 ++++--- 3 files changed, 11 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +6 -2
@@ -732,7 +732,8 @@ static void mlx5e_rx_compute_wqe_bulk_params(struct mlx5e_params *params,static int mlx5e_build_rq_frags_info (struct mlx5_core_dev *mdev,struct mlx5e_params *params,struct mlx5e_xsk_param *xsk, -struct mlx5e_rq_frags_info *info) +struct mlx5e_rq_frags_info *info, +u32 *xdp_frag_size) {u32 byte_count =MLX5E_SW2HW_MTU (params, params->sw_mtu);int frag_size_max =DEFAULT_FRAG_SIZE ;
@@ -845,6 +846,8 @@ static int mlx5e_build_rq_frags_info(struct mlx5_core_dev *mdev, info->log_num_frags =order_base_2 (info->num_frags); + *xdp_frag_size = info->num_frags >1 && params->xdp_prog ?PAGE_SIZE :0 ; +return 0 ; }
@@ -989,7 +992,8 @@ int mlx5e_build_rq_param(struct mlx5_core_dev *mdev, }default :/* MLX5_WQ_TYPE_CYCLIC */ MLX5_SET (wq, wq, log_wq_sz, params->log_rq_mtu_frames); - err =mlx5e_build_rq_frags_info (mdev, params, xsk, ¶m->frags_info); + err =mlx5e_build_rq_frags_info (mdev, params, xsk, ¶m->frags_info, + ¶m->xdp_frag_size);if (err)return err; ndsegs = param->frags_info.num_frags;
drivers/net/ethernet/mellanox/mlx5/core/en/params.h +1 -0
@@ -24,6 +24,7 @@ struct mlx5e_rq_param {u32 rqc[MLX5_ST_SZ_DW (rqc)];struct mlx5_wq_param wq;struct mlx5e_rq_frags_info frags_info; +u32 xdp_frag_size; };struct mlx5e_sq_param {
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +4 -3
@@ -641,7 +641,7 @@ static void mlx5e_free_mpwqe_rq_drop_page(struct mlx5e_rq *rq) }static int mlx5e_init_rxq_rq (struct mlx5e_channel *c,struct mlx5e_params *params, -struct mlx5e_rq *rq) +u32 xdp_frag_size,struct mlx5e_rq *rq) {struct mlx5_core_dev *mdev = c->mdev;int err;
@@ -665,7 +665,8 @@ static int mlx5e_init_rxq_rq(struct mlx5e_channel *c, struct mlx5e_params *paramif (err)return err; -return xdp_rxq_info_reg (&rq->xdp_rxq, rq->netdev, rq->ix, c->napi.napi_id); +return __xdp_rxq_info_reg (&rq->xdp_rxq, rq->netdev, rq->ix, c->napi.napi_id, + xdp_frag_size); } static int mlx5_rq_shampo_alloc(struct mlx5_core_dev *mdev,
@@ -2240,7 +2241,7 @@ static int mlx5e_open_rxq_rq(struct mlx5e_channel *c, struct mlx5e_params *param {int err; - err =mlx5e_init_rxq_rq (c, params, &c->rq); + err =mlx5e_init_rxq_rq (c, params, rq_params->xdp_frag_size, &c->rq);if (err)return err;
Signature · 1 line
2.40.1
Re: [net 01/12] net/mlx5e: XDP, Allow growing tail for XDP multi buffer
This series was applied to netdev/net.git (main) by Saeed Mahameed <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Saeed Mahameed <[email protected]>:
Quoted 8 lines · On Fri, 16 Jun 2023 13:01:08 -0700 you wrote:
From: Maxim Mikityanskiy <[email protected]>
The cited commits missed passing
frag_sizeto__xdp_rxq_info_reg, which is required bybpf_xdp_adjust_tailto support growing the tail pointer in fragmented packets. Pass the missing parameter when the current RQ mode allows XDP multi buffer.[...]
Here is the summary with links:
- [net,01/12] net/mlx5e: XDP, Allow growing tail for XDP multi buffer
https://git.kernel.org/netdev/net/c/4e7401fc8c8d - [net,02/12] net/mlx5e: xsk: Set napi_id to support busy polling on XSK RQ https://git.kernel.org/netdev/net/c/62a522d3354d - [net,03/12] net/mlx5: Fix driver load with single msix vector https://git.kernel.org/netdev/net/c/0ab999d4a1bf - [net,04/12] net/mlx5e: TC, Add null pointer check for hardware miss support https://git.kernel.org/netdev/net/c/b100573ab76e - [net,05/12] net/mlx5e: TC, Cleanup ct resources for nic flow https://git.kernel.org/netdev/net/c/fb7be476ab7e - [net,06/12] net/mlx5: DR, Support SW created encap actions for FW table https://git.kernel.org/netdev/net/c/87cd0649176c - [net,07/12] net/mlx5: DR, Fix wrong action data allocation in decap action https://git.kernel.org/netdev/net/c/ef4c5afc783d - [net,08/12] net/mlx5: Free IRQ rmap and notifier on kernel shutdown https://git.kernel.org/netdev/net/c/314ded538e5f - [net,09/12] net/mlx5e: Don't delay release of hardware objects https://git.kernel.org/netdev/net/c/cf5bb02320d4 - [net,10/12] net/mlx5e: Fix ESN update kernel panic https://git.kernel.org/netdev/net/c/fef06678931f - [net,11/12] net/mlx5e: Drop XFRM state lock when modifying flow steering https://git.kernel.org/netdev/net/c/c75b94255aaa - [net,12/12] net/mlx5e: Fix scheduling of IPsec ASO query while in atomic https://git.kernel.org/netdev/net/c/a128f9d4c122
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
PATCH 2/12 net/mlx5e: xsk: Set napi_id to support busy polling on XSK RQ
In reply to Saeed MahameedFrom: Maxim Mikityanskiy <[email protected]>
The cited commit missed setting napi_id on XSK RQs, it only affected regular RQs. Add the missing part to support socket busy polling on XSK RQs.
--- drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c +1 -1
@@ -86,7 +86,7 @@ static int mlx5e_init_xsk_rq(struct mlx5e_channel *c,if (err)return err; -return xdp_rxq_info_reg (&rq->xdp_rxq, rq->netdev, rq_xdp_ix,0 ); +return xdp_rxq_info_reg (&rq->xdp_rxq, rq->netdev, rq_xdp_ix, c->napi.napi_id); } static int mlx5e_open_xsk_rq(struct mlx5e_channel *c, struct mlx5e_params *params,
Signature · 1 line
2.40.1
PATCH 3/12 net/mlx5: Fix driver load with single msix vector
In reply to Saeed MahameedFrom: Eli Cohen <[email protected]>
When a PCI device has just one msix vector available, we want to share this vector between async and completion events. Current code fails to do that assuming it will always have at least one dedicated vector for completion events. Fix this by detecting when the pool contains just a single vector.
--- drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c +7 -1
@@ -565,15 +565,21 @@ void mlx5_irqs_release_vectors(struct mlx5_irq **irqs, int nirqs)int mlx5_irqs_request_vectors (struct mlx5_core_dev *dev,u16 *cpus,int nirqs,struct mlx5_irq **irqs,struct cpu_rmap **rmap) { +struct mlx5_irq_table *table =mlx5_irq_table_get (dev); +struct mlx5_irq_pool *pool = table->pcif_pool;struct irq_affinity_desc af_desc;struct mlx5_irq *irq; +int offset =1 ;int i; +if (!pool->xa_num_irqs.max) + offset =0 ; + af_desc.is_managed = false;for (i =0 ; i < nirqs; i++) {cpumask_clear (&af_desc.mask);cpumask_set_cpu (cpus[i], &af_desc.mask); - irq =mlx5_irq_request (dev, i +1 , &af_desc, rmap); + irq =mlx5_irq_request (dev, i + offset, &af_desc, rmap);if (IS_ERR (irq))break ; irqs[i] = irq;
Signature · 1 line
2.40.1
PATCH 4/12 net/mlx5e: TC, Add null pointer check for hardware miss support
In reply to Saeed MahameedFrom: Chris Mi <[email protected]>
The cited commits add hardware miss support to tc action. But if the rules can't be offloaded, the pointers are null and system will panic when accessing them.
Fix it by checking null pointer.
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +2 -0
@@ -2021,6 +2021,8 @@ void mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv, struct mlx5_flow_attr *attr) { +if (!attr->ct_attr.ft)/* no ct action, return */ +return ;if (!attr->ct_attr.nf_ft)/* means only ct clear action, and not ct_clear,ct() */ return ;
Signature · 1 line
2.40.1
PATCH 5/12 net/mlx5e: TC, Cleanup ct resources for nic flow
In reply to Saeed MahameedFrom: Chris Mi <[email protected]>
The cited commit removes special handling of CT action. But it removes too much. Pre ct/ct_nat tables and some other resources are not destroyed due to the cited commit.
Fix it by adding it back.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1 -0
@@ -1439,6 +1439,7 @@ static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,mlx5e_hairpin_flow_del (priv, flow);free_flow_post_acts (flow); +mlx5_tc_ct_delete_flow (get_ct_priv (flow->priv), attr);kvfree (attr->parse_attr);kfree (flow->attr);
Signature · 1 line
2.40.1
PATCH 6/12 net/mlx5: DR, Support SW created encap actions for FW table
In reply to Saeed MahameedFrom: Yevgeny Kliteynik <[email protected]>
In some cases, steering might need to use SW-created action in FW table, which results in wrong packet reformat being used:
mlx5_core 0000:81:00.1: mlx5_cmd_check:756:(pid 1154):
SET_FLOW_TABLE_ENTRY(0×936) op_mod(0×0) failed,
status bad resource(0×5), syndrome (0xf2ff71)This patch adds support for usage of SW-created packet reformat (encap) actions in FW tables, and adds clear error flow for attempt to use SW-created modify header on FW tables.
--- .../net/ethernet/mellanox/mlx5/core/fs_cmd.c | 50 ++++++++++++++----- .../net/ethernet/mellanox/mlx5/core/fs_core.h | 7 +++ .../mellanox/mlx5/core/steering/dr_action.c | 5 ++ .../mellanox/mlx5/core/steering/fs_dr.c | 27 +++++++++- .../mellanox/mlx5/core/steering/fs_dr.h | 7 +++ .../mellanox/mlx5/core/steering/mlx5dr.h | 2 + 6 files changed, 83 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +37 -13
@@ -511,10 +511,11 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,struct mlx5_flow_rule *dst;void *in_flow_context, *vlan;void *in_match_value; +int reformat_id =0 ;unsigned int inlen;int dst_cnt_size; +u32 *in, action;void *in_dests; -u32 *in;int err;if (mlx5_set_extended_dest (dev, fte, &extended_dest))
@@ -553,22 +554,42 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,MLX5_SET (flow_context, in_flow_context, extended_destination, extended_dest); -if (extended_dest) { -u32 action; - action = fte->action.action & - ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT ; -MLX5_SET (flow_context, in_flow_context, action, action); - }else { -MLX5_SET (flow_context, in_flow_context, action, - fte->action.action); -if (fte->action.pkt_reformat) -MLX5_SET (flow_context, in_flow_context, packet_reformat_id, - fte->action.pkt_reformat->id); + action = fte->action.action; +if (extended_dest) + action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT ; + +MLX5_SET (flow_context, in_flow_context, action, action); + +if (!extended_dest && fte->action.pkt_reformat) { +struct mlx5_pkt_reformat *pkt_reformat = fte->action.pkt_reformat; + +if (pkt_reformat->owner ==MLX5_FLOW_RESOURCE_OWNER_SW ) { + reformat_id =mlx5_fs_dr_action_get_pkt_reformat_id (pkt_reformat); +if (reformat_id <0 ) { +mlx5_core_err (dev, +"Unsupported SW-owned pkt_reformat type (%d) in FW-owned table\n" , + pkt_reformat->reformat_type); + err = reformat_id; + goto err_out; + } + }else { + reformat_id = fte->action.pkt_reformat->id; + } } -if (fte->action.modify_hdr) + +MLX5_SET (flow_context, in_flow_context, packet_reformat_id, (u32 )reformat_id); + +if (fte->action.modify_hdr) { +if (fte->action.modify_hdr->owner ==MLX5_FLOW_RESOURCE_OWNER_SW ) { +mlx5_core_err (dev,"Can't use SW-owned modify_hdr in FW-owned table\n" ); + err = -EOPNOTSUPP ; + goto err_out; + } +MLX5_SET (flow_context, in_flow_context, modify_header_id, fte->action.modify_hdr->id); + }MLX5_SET (flow_context, in_flow_context, encrypt_decrypt_type, fte->action.crypto.type);
@@ -885,6 +906,8 @@ static int mlx5_cmd_packet_reformat_alloc(struct mlx5_flow_root_namespace *ns, pkt_reformat->id =MLX5_GET (alloc_packet_reformat_context_out, out, packet_reformat_id); + pkt_reformat->owner =MLX5_FLOW_RESOURCE_OWNER_FW ; +kfree (in);return err; }
@@ -969,6 +992,7 @@ static int mlx5_cmd_modify_header_alloc(struct mlx5_flow_root_namespace *ns, err =mlx5_cmd_exec (dev, in, inlen, out,sizeof (out)); modify_hdr->id =MLX5_GET (alloc_modify_header_context_out, out, modify_header_id); + modify_hdr->owner =MLX5_FLOW_RESOURCE_OWNER_FW ;kfree (in);return err; }
drivers/net/ethernet/mellanox/mlx5/core/fs_core.h +7 -0
@@ -54,8 +54,14 @@ struct mlx5_flow_definer {u32 id; }; +enum mlx5_flow_resource_owner { +MLX5_FLOW_RESOURCE_OWNER_FW , +MLX5_FLOW_RESOURCE_OWNER_SW , +}; +struct mlx5_modify_hdr {enum mlx5_flow_namespace_type ns_type; +enum mlx5_flow_resource_owner owner;union {struct mlx5_fs_dr_action action;u32 id;
@@ -65,6 +71,7 @@ struct mlx5_modify_hdr {struct mlx5_pkt_reformat {enum mlx5_flow_namespace_type ns_type;int reformat_type;/* from mlx5_ifc */ +enum mlx5_flow_resource_owner owner;union {struct mlx5_fs_dr_action action;u32 id;
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +5 -0
@@ -2129,6 +2129,11 @@ mlx5dr_action_create_aso(struct mlx5dr_domain *dmn, u32 obj_id,return action; } +u32 mlx5dr_action_get_pkt_reformat_id (struct mlx5dr_action *action) +{ +return action->reformat->id; +} +int mlx5dr_action_destroy (struct mlx5dr_action *action) {if (WARN_ON_ONCE (refcount_read (&action->refcount) >1 ))
drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c +25 -2
@@ -331,8 +331,16 @@ static int mlx5_cmd_dr_create_fte(struct mlx5_flow_root_namespace *ns, }if (fte->action.action &MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT ) { -bool is_decap = fte->action.pkt_reformat->reformat_type == -MLX5_REFORMAT_TYPE_L3_TUNNEL_TO_L2 ; +bool is_decap; + +if (fte->action.pkt_reformat->owner ==MLX5_FLOW_RESOURCE_OWNER_FW ) { + err = -EINVAL ; +mlx5dr_err (domain,"FW-owned reformat can't be used in SW rule\n" ); + goto free_actions; + } + + is_decap = fte->action.pkt_reformat->reformat_type == +MLX5_REFORMAT_TYPE_L3_TUNNEL_TO_L2 ;if (is_decap) actions[num_actions++] =
@@ -661,6 +669,7 @@ static int mlx5_cmd_dr_packet_reformat_alloc(struct mlx5_flow_root_namespace *nsreturn -EINVAL ; } + pkt_reformat->owner =MLX5_FLOW_RESOURCE_OWNER_SW ; pkt_reformat->action.dr_action = action;return 0 ;
@@ -691,6 +700,7 @@ static int mlx5_cmd_dr_modify_header_alloc(struct mlx5_flow_root_namespace *ns,return -EINVAL ; } + modify_hdr->owner =MLX5_FLOW_RESOURCE_OWNER_SW ; modify_hdr->action.dr_action = action;return 0 ;
@@ -816,6 +826,19 @@ static u32 mlx5_cmd_dr_get_capabilities(struct mlx5_flow_root_namespace *ns,return steering_caps; } +int mlx5_fs_dr_action_get_pkt_reformat_id (struct mlx5_pkt_reformat *pkt_reformat) +{ +switch (pkt_reformat->reformat_type) { +case MLX5_REFORMAT_TYPE_L2_TO_VXLAN : +case MLX5_REFORMAT_TYPE_L2_TO_NVGRE : +case MLX5_REFORMAT_TYPE_L2_TO_L2_TUNNEL : +case MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL : +case MLX5_REFORMAT_TYPE_INSERT_HDR : +return mlx5dr_action_get_pkt_reformat_id (pkt_reformat->action.dr_action); + } +return -EOPNOTSUPP ; +} +bool mlx5_fs_dr_is_supported (struct mlx5_core_dev *dev) {return mlx5dr_is_supported (dev);
drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.h +7 -0
@@ -38,6 +38,8 @@ struct mlx5_fs_dr_table {bool mlx5_fs_dr_is_supported (struct mlx5_core_dev *dev); +int mlx5_fs_dr_action_get_pkt_reformat_id (struct mlx5_pkt_reformat *pkt_reformat); +const struct mlx5_flow_cmds *mlx5_fs_cmd_get_dr_cmds (void );#else
@@ -47,6 +49,11 @@ static inline const struct mlx5_flow_cmds *mlx5_fs_cmd_get_dr_cmds(void)return NULL ; } +static inline u32 mlx5_fs_dr_action_get_pkt_reformat_id (struct mlx5_pkt_reformat *pkt_reformat) +{ +return 0 ; +} +static inline bool mlx5_fs_dr_is_supported (struct mlx5_core_dev *dev) {return false;
drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h +2 -0
@@ -150,6 +150,8 @@ mlx5dr_action_create_dest_match_range(struct mlx5dr_domain *dmn,int mlx5dr_action_destroy (struct mlx5dr_action *action); +u32 mlx5dr_action_get_pkt_reformat_id (struct mlx5dr_action *action); +int mlx5dr_definer_get (struct mlx5dr_domain *dmn,u16 format_id,u8 *dw_selectors,u8 *byte_selectors,u8 *match_mask,u32 *definer_id);
Signature · 1 line
2.40.1
PATCH 7/12 net/mlx5: DR, Fix wrong action data allocation in decap action
In reply to Saeed MahameedFrom: Yevgeny Kliteynik <[email protected]>
When TUNNEL_L3_TO_L2 decap action was created, a pointer to a local variable was passed as its HW action data, resulting in attempt to free invalid address:
BUG: KASAN: invalid-free in mlx5dr_action_destroy+0x318/0x410 [mlx5_core]
--- .../net/ethernet/mellanox/mlx5/core/steering/dr_action.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +7 -1
@@ -1421,9 +1421,13 @@ dr_action_create_reformat_action(struct mlx5dr_domain *dmn, }case DR_ACTION_TYP_TNL_L3_TO_L2 : { -u8 hw_actions[DR_ACTION_CACHE_LINE_SIZE ] = {}; +u8 *hw_actions;int ret; + hw_actions =kzalloc (DR_ACTION_CACHE_LINE_SIZE ,GFP_KERNEL ); +if (!hw_actions) +return -ENOMEM ; + ret = mlx5dr_ste_set_action_decap_l3_list(dmn->ste_ctx, data, data_sz, hw_actions,
@@ -1431,6 +1435,7 @@ dr_action_create_reformat_action(struct mlx5dr_domain *dmn, &action->rewrite->num_of_actions);if (ret) {mlx5dr_dbg (dmn,"Failed creating decap l3 action list\n" ); +kfree (hw_actions);return ret; }
@@ -1440,6 +1445,7 @@ dr_action_create_reformat_action(struct mlx5dr_domain *dmn, ret =mlx5dr_ste_alloc_modify_hdr (action);if (ret) {mlx5dr_dbg (dmn,"Failed preparing reformat data\n" ); +kfree (hw_actions);return ret; }return 0 ;
Signature · 1 line
2.40.1
PATCH 8/12 net/mlx5: Free IRQ rmap and notifier on kernel shutdown
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
The kernel IRQ system needs the irq affinity notifier to be clear before attempting to free the irq, see WARN_ON log below.
On a normal driver unload we don't have this issue since we do the complete cleanup of the irq resources.
To fix this, put the important resources cleanup in a helper function and use it in both normal driver unload and shutdown flows.
[ 4497.498434] ------------[ cut here ]------------ [ 4497.498726] WARNING: CPU: 0 PID: 9 at kernel/irq/manage.c:2034 free_irq+0x295/0x340 [ 4497.499193] Modules linked in: [ 4497.499386] CPU: 0 PID: 9 Comm: kworker/0:1 Tainted: G W 6.4.0-rc4+ #10 [ 4497.499876] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc38 04/01/2014 [ 4497.500518] Workqueue: events do_poweroff [ 4497.500849] RIP: 0010:free_irq+0x295/0x340 [ 4497.501132] Code: 85 c0 0f 84 1d ff ff ff 48 89 ef ff d0 0f 1f 00 e9 10 ff ff ff 0f 0b e9 72 ff ff ff 49 8d 7f 28 ff d0 0f 1f 00 e9 df fd ff ff <0f> 0b 48 c7 80 c0 008 [ 4497.502269] RSP: 0018:ffffc90000053da0 EFLAGS: 00010282 [ 4497.502589] RAX: ffff888100949600 RBX: ffff88810330b948 RCX: 0000000000000000 [ 4497.503035] RDX: ffff888100949600 RSI: ffff888100400490 RDI: 0000000000000023 [ 4497.503472] RBP: ffff88810330c7e0 R08: ffff8881004005d0 R09: ffffffff8273a260 [ 4497.503923] R10: 0000000000000000 R11: 0000000000000000 R12: ffff8881009ae000 [ 4497.504359] R13: ffff8881009ae148 R14: 0000000000000000 R15: ffff888100949600 [ 4497.504804] FS: 0000000000000000(0000) GS:ffff88813bc00000(0000) knlGS:0000000000000000 [ 4497.505302] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 4497.505671] CR2: 00007fce98806298 CR3: 000000000262e005 CR4: 0000000000370ef0 [ 4497.506104] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 4497.506540] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 4497.507002] Call Trace: [ 4497.507158] <TASK> [ 4497.507299] ? free_irq+0x295/0x340 [ 4497.507522] ? __warn+0x7c/0x130 [ 4497.507740] ? free_irq+0x295/0x340 [ 4497.507963] ? report_bug+0x171/0x1a0 [ 4497.508197] ? handle_bug+0x3c/0x70 [ 4497.508417] ? exc_invalid_op+0x17/0x70 [ 4497.508662] ? asm_exc_invalid_op+0x1a/0x20 [ 4497.508926] ? free_irq+0x295/0x340 [ 4497.509146] mlx5_irq_pool_free_irqs+0x48/0x90 [ 4497.509421] mlx5_irq_table_free_irqs+0x38/0x50 [ 4497.509714] mlx5_core_eq_free_irqs+0x27/0x40 [ 4497.509984] shutdown+0x7b/0x100 [ 4497.510184] pci_device_shutdown+0x30/0x60 [ 4497.510440] device_shutdown+0x14d/0x240 [ 4497.510698] kernel_power_off+0x30/0x70 [ 4497.510938] process_one_work+0x1e6/0x3e0 [ 4497.511183] worker_thread+0x49/0x3b0 [ 4497.511407] ? __pfx_worker_thread+0x10/0x10 [ 4497.511679] kthread+0xe0/0x110 [ 4497.511879] ? __pfx_kthread+0x10/0x10 [ 4497.512114] ret_from_fork+0x29/0x50 [ 4497.512342] </TASK>
--- .../net/ethernet/mellanox/mlx5/core/pci_irq.c | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c +21 -4
@@ -126,14 +126,22 @@ int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int function_id,return ret; } -static void irq_release (struct mlx5_irq *irq) +/* mlx5_system_free_irq - Free an IRQ +* @irq: IRQ to free +* +* Free the IRQ and other resources such as rmap from the system. +* BUT doesn't free or remove reference from mlx5. +* This function is very important for the shutdown flow, where we need to +* cleanup system resoruces but keep mlx5 objects alive, +* see mlx5_irq_table_free_irqs(). +*/ +static void mlx5_system_free_irq (struct mlx5_irq *irq) {struct mlx5_irq_pool *pool = irq->pool;#ifdef CONFIG_RFS_ACCEL struct cpu_rmap *rmap;#endif -xa_erase (&pool->irqs, irq->pool_index);/* free_irq requires that affinity_hint and rmap will be cleared before * calling it. To satisfy this requirement, we call * irq_cpu_rmap_remove() to remove the notifier
@@ -145,10 +153,18 @@ static void irq_release(struct mlx5_irq *irq)irq_cpu_rmap_remove (rmap, irq->map.virq);#endif -free_cpumask_var (irq->mask);free_irq (irq->map.virq, &irq->nh);if (irq->map.index &&pci_msix_can_alloc_dyn (pool->dev->pdev))pci_msix_free_irq (pool->dev->pdev, irq->map); +} + +static void irq_release (struct mlx5_irq *irq) +{ +struct mlx5_irq_pool *pool = irq->pool; + +xa_erase (&pool->irqs, irq->pool_index); +mlx5_system_free_irq (irq); +free_cpumask_var (irq->mask);kfree (irq); }
@@ -705,7 +721,8 @@ static void mlx5_irq_pool_free_irqs(struct mlx5_irq_pool *pool)unsigned long index;xa_for_each (&pool->irqs, index, irq) -free_irq (irq->map.virq, &irq->nh); +mlx5_system_free_irq (irq); + }static void mlx5_irq_pools_free_irqs (struct mlx5_irq_table *table)
Signature · 1 line
2.40.1
PATCH 9/12 net/mlx5e: Don't delay release of hardware objects
In reply to Saeed MahameedFrom: Leon Romanovsky <[email protected]>
XFRM core provides two callbacks to release resources, one is .xdo_dev_policy_delete() and another is .xdo_dev_policy_free(). This separation allows delayed release so "ip xfrm policy free" commands won't starve. Unfortunately, mlx5 command interface can't run in .xdo_dev_policy_free() callbacks as the latter runs in ATOMIC context.
BUG: scheduling while atomic: swapper/7/0/0x00000100 Modules linked in: act_mirred act_tunnel_key cls_flower sch_ingress vxlan mlx5_vdpa vringh vhost_iotlb vdpa rpcrdma rdma_ucm ib_iser libiscsi ib_umad scsi_transport_iscsi rdma_cm ib_ipoib iw_cm ib_cm mlx5_ib ib_uverbs ib_core xt_conntrack xt_MASQUERADE nf_conntrack_netlink nfnetlink xt_addrtype iptable_nat nf_nat br_netfilter rpcsec_gss_krb5 auth_rpcgss oid_registry overlay mlx5_core zram zsmalloc fuse CPU: 7 PID: 0 Comm: swapper/7 Not tainted 6.3.0+ #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 Call Trace: <IRQ> dump_stack_lvl+0x33/0x50 __schedule_bug+0x4e/0x60 __schedule+0x5d5/0x780 ? __mod_timer+0x286/0x3d0 schedule+0x50/0x90 schedule_timeout+0x7c/0xf0 ? __bpf_trace_tick_stop+0x10/0x10 __wait_for_common+0x88/0x190 ? usleep_range_state+0x90/0x90 cmd_exec+0x42e/0xb40 [mlx5_core] mlx5_cmd_do+0x1e/0x40 [mlx5_core] mlx5_cmd_exec+0x18/0x30 [mlx5_core] mlx5_cmd_delete_fte+0xa8/0xd0 [mlx5_core] del_hw_fte+0x60/0x120 [mlx5_core] mlx5_del_flow_rules+0xec/0x270 [mlx5_core] ? default_send_IPI_single_phys+0x26/0x30 mlx5e_accel_ipsec_fs_del_pol+0x1a/0x60 [mlx5_core] mlx5e_xfrm_free_policy+0x15/0x20 [mlx5_core] xfrm_policy_destroy+0x5a/0xb0 xfrm4_dst_destroy+0x7b/0x100 dst_destroy+0x37/0x120 rcu_core+0x2d6/0x540 __do_softirq+0xcd/0x273 irq_exit_rcu+0x82/0xb0 sysvec_apic_timer_interrupt+0x72/0x90 </IRQ> <TASK> asm_sysvec_apic_timer_interrupt+0x16/0x20 RIP: 0010:default_idle+0x13/0x20 Code: c0 08 00 00 00 4d 29 c8 4c 01 c7 4c 29 c2 e9 72 ff ff ff cc cc cc cc 8b 05 7a 4d ee 00 85 c0 7e 07 0f 00 2d 2f 98 2e 00 fb f4 <fa> c3 66 66 2e 0f 1f 84 00 00 00 00 00 65 48 8b 04 25 40 b4 02 00 RSP: 0018:ffff888100843ee0 EFLAGS: 00000242 RAX: 0000000000000001 RBX: ffff888100812b00 RCX: 4000000000000000 RDX: 0000000000000001 RSI: 0000000000000083 RDI: 000000000002d2ec RBP: 0000000000000007 R08: 00000021daeded59 R09: 0000000000000001 R10: 0000000000000000 R11: 000000000000000f R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 default_idle_call+0x30/0xb0 do_idle+0x1c1/0x1d0 cpu_startup_entry+0x19/0x20 start_secondary+0xfe/0x120 secondary_startup_64_no_verify+0xf3/0xfb </TASK> bad: scheduling from the idle thread!
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +8 -1
@@ -1040,11 +1040,17 @@ static int mlx5e_xfrm_add_policy(struct xfrm_policy *x,return err; } -static void mlx5e_xfrm_free_policy (struct xfrm_policy *x) +static void mlx5e_xfrm_del_policy (struct xfrm_policy *x) {struct mlx5e_ipsec_pol_entry *pol_entry =to_ipsec_pol_entry (x);mlx5e_accel_ipsec_fs_del_pol (pol_entry); +} + +static void mlx5e_xfrm_free_policy (struct xfrm_policy *x) +{ +struct mlx5e_ipsec_pol_entry *pol_entry =to_ipsec_pol_entry (x); +kfree (pol_entry); }
@@ -1065,6 +1071,7 @@ static const struct xfrmdev_ops mlx5e_ipsec_packet_xfrmdev_ops = { .xdo_dev_state_update_curlft = mlx5e_xfrm_update_curlft, .xdo_dev_policy_add = mlx5e_xfrm_add_policy, + .xdo_dev_policy_delete = mlx5e_xfrm_del_policy, .xdo_dev_policy_free = mlx5e_xfrm_free_policy, };
Signature · 1 line
2.40.1
PATCH 10/12 net/mlx5e: Fix ESN update kernel panic
In reply to Saeed MahameedFrom: Patrisious Haddad <[email protected]>
Previously during mlx5e_ipsec_handle_event the driver tried to execute an operation that could sleep, while holding a spinlock, which caused the kernel panic mentioned below.
Move the function call that can sleep outside of the spinlock context.
Call Trace: <TASK> dump_stack_lvl+0x49/0x6c __schedule_bug.cold+0x42/0x4e schedule_debug.constprop.0+0xe0/0x118 __schedule+0x59/0x58a ? __mod_timer+0x2a1/0x3ef schedule+0x5e/0xd4 schedule_timeout+0x99/0x164 ? __pfx_process_timeout+0x10/0x10 __wait_for_common+0x90/0x1da ? __pfx_schedule_timeout+0x10/0x10 wait_func+0x34/0x142 [mlx5_core] mlx5_cmd_invoke+0x1f3/0x313 [mlx5_core] cmd_exec+0x1fe/0x325 [mlx5_core] mlx5_cmd_do+0x22/0x50 [mlx5_core] mlx5_cmd_exec+0x1c/0x40 [mlx5_core] mlx5_modify_ipsec_obj+0xb2/0x17f [mlx5_core] mlx5e_ipsec_update_esn_state+0x69/0xf0 [mlx5_core] ? wake_affine+0x62/0x1f8 mlx5e_ipsec_handle_event+0xb1/0xc0 [mlx5_core] process_one_work+0x1e2/0x3e6 ? __pfx_worker_thread+0x10/0x10 worker_thread+0x54/0x3ad ? __pfx_worker_thread+0x10/0x10 kthread+0xda/0x101 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x29/0x37 </TASK> BUG: workqueue leaked lock or atomic: kworker/u256:4/0x7fffffff/189754#012 last function: mlx5e_ipsec_handle_event [mlx5_core] CPU: 66 PID: 189754 Comm: kworker/u256:4 Kdump: loaded Tainted: G W 6.2.0-2596.20230309201517_5.el8uek.rc1.x86_64 #2 Hardware name: Oracle Corporation ORACLE SERVER X9-2/ASMMBX9-2, BIOS 61070300 08/17/2022 Workqueue: mlx5e_ipsec: eth%d mlx5e_ipsec_handle_event [mlx5_core] Call Trace: <TASK> dump_stack_lvl+0x49/0x6c process_one_work.cold+0x2b/0x3c ? __pfx_worker_thread+0x10/0x10 worker_thread+0x54/0x3ad ? __pfx_worker_thread+0x10/0x10 kthread+0xda/0x101 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x29/0x37 </TASK> BUG: scheduling while atomic: kworker/u256:4/189754/0x00000000
--- .../mellanox/mlx5/core/en_accel/ipsec_offload.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c +12 -2
@@ -305,7 +305,17 @@ static void mlx5e_ipsec_update_esn_state(struct mlx5e_ipsec_sa_entry *sa_entry, }mlx5e_ipsec_build_accel_xfrm_attrs (sa_entry, &attrs); + +/* It is safe to execute the modify below unlocked since the only flows +* that could affect this HW object, are create, destroy and this work. +* +* Creation flow can't co-exist with this modify work, the destruction +* flow would cancel this work, and this work is a single entity that +* can't conflict with it self. +*/ +spin_unlock_bh (&sa_entry->x->lock);mlx5_accel_esp_modify_xfrm (sa_entry, &attrs); +spin_lock_bh (&sa_entry->x->lock); data.data_offset_condition_operand =MLX5_IPSEC_ASO_REMOVE_FLOW_PKT_CNT_OFFSET ;
@@ -431,7 +441,7 @@ static void mlx5e_ipsec_handle_event(struct work_struct *_work) aso = sa_entry->ipsec->aso; attrs = &sa_entry->attrs; -spin_lock (&sa_entry->x->lock); +spin_lock_bh (&sa_entry->x->lock); ret =mlx5e_ipsec_aso_query (sa_entry,NULL );if (ret) goto unlock;
@@ -447,7 +457,7 @@ static void mlx5e_ipsec_handle_event(struct work_struct *_work)mlx5e_ipsec_handle_limits (sa_entry); unlock: -spin_unlock (&sa_entry->x->lock); +spin_unlock_bh (&sa_entry->x->lock);kfree (work); }
Signature · 1 line
2.40.1
PATCH 11/12 net/mlx5e: Drop XFRM state lock when modifying flow steering
In reply to Saeed MahameedFrom: Leon Romanovsky <[email protected]>
XFRM state which is changed to be XFRM_STATE_EXPIRED doesn't really need to hold lock while modifying flow steering rules to drop traffic.
That state can be deleted only and as such mlx5e_ipsec_handle_tx_limit() work will be canceled anyway and won't run in parallel.
--- .../ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +8 -5
@@ -61,16 +61,19 @@ static void mlx5e_ipsec_handle_tx_limit(struct work_struct *_work)struct mlx5e_ipsec_sa_entry *sa_entry = dwork->sa_entry;struct xfrm_state *x = sa_entry->x; -spin_lock (&x->lock); +if (sa_entry->attrs.drop) +return ; + +spin_lock_bh (&x->lock);xfrm_state_check_expire (x);if (x->km.state ==XFRM_STATE_EXPIRED ) { sa_entry->attrs.drop = true; -mlx5e_accel_ipsec_fs_modify (sa_entry); - } -spin_unlock (&x->lock); +spin_unlock_bh (&x->lock); -if (sa_entry->attrs.drop) +mlx5e_accel_ipsec_fs_modify (sa_entry);return ; + } +spin_unlock_bh (&x->lock);queue_delayed_work (sa_entry->ipsec->wq, &dwork->dwork,MLX5_IPSEC_RESCHED );
Signature · 1 line
2.40.1
PATCH 12/12 net/mlx5e: Fix scheduling of IPsec ASO query while in atomic
In reply to Saeed MahameedFrom: Leon Romanovsky <[email protected]>
ASO query can be scheduled in atomic context as such it can't use usleep. Use udelay as recommended in Documentation/timers/timers-howto.rst.
--- .../net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c +2 -1
@@ -606,7 +606,8 @@ int mlx5e_ipsec_aso_query(struct mlx5e_ipsec_sa_entry *sa_entry,do { ret =mlx5_aso_poll_cq (aso->aso, false);if (ret) -usleep_range (2 ,10 ); +/* We are in atomic context */ +udelay (10 ); }while (ret &&time_is_after_jiffies (expires));spin_unlock_bh (&aso->lock);return ret;
Signature · 1 line
2.40.1