mlx5 fixes 2020-11-03
Subsystems (5)
Saeed Mahameed
maintainerHi Jakub,
This series introduces some fixes to mlx5 driver.
v1->v2:
- Fix fixes line tag in patch #1
- Toss ktls refcount leak fix, Maxim will look further into the root cause.
- Toss eswitch chain 0 prio patch, until we determine if it is needed for -rc and net.
Please pull and let me know if there is any problem.
For -stable v5.1
('net/mlx5: Fix deletion of duplicate rules')
For -stable v5.4
('net/mlx5e: Fix modify header actions memory leak')
For -stable v5.8
('net/mlx5e: Protect encap route dev from concurrent release')
For -stable v5.9
('net/mlx5e: Fix VXLAN synchronization after function reload') ('net/mlx5e: Use spin_lock_bh for async_icosq_lock') ('net/mlx5e: Fix incorrect access of RCU-protected xdp_prog') ('net/mlx5: E-switch, Avoid extack error log for disabled vport')
Thanks,
Saeed.
---
The following changes since commit 9621618130bf7e83635367c13b9a6ee53935bb37:
sfp: Fix error handing in sfp_probe() (2020-11-02 17:19:59 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2020-11-03
for you to fetch changes up to 1a50cf9a67ff2241c2949d30bc11c8dd4280eef8:
net/mlx5e: Fix incorrect access of RCU-protected xdp_prog (2020-11-05 12:17:06 -0800)
----------------------------------------------------------------
mlx5-fixes-2020-11-03
----------------------------------------------------------------
Aya Levin (1):
net/mlx5e: Fix VXLAN synchronization after function reload
Maor Dickman (1):
net/mlx5e: Fix modify header actions memory leak
Maor Gottlieb (1):
net/mlx5: Fix deletion of duplicate rules
Maxim Mikityanskiy (2):
net/mlx5e: Use spin_lock_bh for async_icosq_lock net/mlx5e: Fix incorrect access of RCU-protected xdp_prog
Parav Pandit (1):
net/mlx5: E-switch, Avoid extack error log for disabled vport
Vlad Buslov (1):
net/mlx5e: Protect encap route dev from concurrent release
.../net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 6 +- .../net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 72 ++++++++++++++-------- .../net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 4 +- .../net/ethernet/mellanox/mlx5/core/en/xsk/tx.c | 4 +- .../ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 14 ++--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/en_rep.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 + drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 2 - drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 7 ++- .../net/ethernet/mellanox/mlx5/core/lib/vxlan.c | 23 +++++-- .../net/ethernet/mellanox/mlx5/core/lib/vxlan.h | 2 + 13 files changed, 90 insertions(+), 51 deletions(-)
Saeed Mahameed
maintainerPATCH v2 1/7 net/mlx5e: Fix modify header actions memory leak
From: Maor Dickman <[email protected]>
Modify header actions are allocated during parse tc actions and only freed during the flow creation, however, on error flow the allocated memory is wrongly unfreed.
Fix this by calling dealloc_mod_hdr_actions in __mlx5e_add_fdb_flow and mlx5e_add_nic_flow error flow.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +2 -0
@@ -4658,6 +4658,7 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv,return flow; err_free: +dealloc_mod_hdr_actions (&parse_attr->mod_hdr_acts);mlx5e_flow_put (priv, flow); out:return ERR_PTR (err);
@@ -4802,6 +4803,7 @@ mlx5e_add_nic_flow(struct mlx5e_priv *priv,return 0 ; err_free: +dealloc_mod_hdr_actions (&parse_attr->mod_hdr_acts);mlx5e_flow_put (priv, flow); out:return err;
Signature · 1 line
2.26.2
Re: [net v2 1/7] net/mlx5e: Fix modify header actions memory leak
This series was applied to netdev/net.git (refs/heads/master):
Hello:
This series was applied to netdev/net.git (refs/heads/master):
Quoted 10 lines · On Thu, 5 Nov 2020 12:21:23 -0800 you wrote:
From: Maor Dickman <[email protected]>
Modify header actions are allocated during parse tc actions and only freed during the flow creation, however, on error flow the allocated memory is wrongly unfreed.
Fix this by calling
dealloc_mod_hdr_actionsin__mlx5e_add_fdb_flowandmlx5e_add_nic_flowerror flow.[...]
Here is the summary with links:
- [net,v2,1/7] net/mlx5e: Fix modify header actions memory leak
https://git.kernel.org/netdev/net/c/e68e28b4a9d7 - [net,v2,2/7] net/mlx5e: Protect encap route dev from concurrent release https://git.kernel.org/netdev/net/c/78c906e430b1 - [net,v2,3/7] net/mlx5e: Use spin_lock_bh for async_icosq_lock https://git.kernel.org/netdev/net/c/f42139ba4979 - [net,v2,4/7] net/mlx5: Fix deletion of duplicate rules https://git.kernel.org/netdev/net/c/465e7baab6d9 - [net,v2,5/7] net/mlx5: E-switch, Avoid extack error log for disabled vport https://git.kernel.org/netdev/net/c/ae3585944560 - [net,v2,6/7] net/mlx5e: Fix VXLAN synchronization after function reload https://git.kernel.org/netdev/net/c/c5eb51adf06b - [net,v2,7/7] net/mlx5e: Fix incorrect access of RCU-protected xdp_prog https://git.kernel.org/netdev/net/c/1a50cf9a67ff
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Saeed Mahameed
maintainerPATCH v2 2/7 net/mlx5e: Protect encap route dev from concurrent release
In reply to Saeed MahameedFrom: Vlad Buslov <[email protected]>
In functions mlx5e_route_lookup_ipv{4|6}() route_dev can be arbitrary net device and not necessary mlx5 eswitch port representor. As such, in order to ensure that route_dev is not destroyed concurrent the code needs either explicitly take reference to the device before releasing reference to rtable instance or ensure that caller holds rtnl lock. First approach is chosen as a fix since rtnl lock dependency was intentionally removed from mlx5 TC layer.
To prevent unprotected usage of route_dev in encap code take a reference to the device before releasing rt. Don't save direct pointer to the device in mlx5_encap_entry structure and use ifindex instead. Modify users of route_dev pointer to properly obtain the net device instance from its ifindex.
--- .../ethernet/mellanox/mlx5/core/en/rep/tc.c | 6 +- .../ethernet/mellanox/mlx5/core/en/tc_tun.c | 72 ++++++++++++------- .../net/ethernet/mellanox/mlx5/core/en_rep.h | 2 +- 3 files changed, 52 insertions(+), 28 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +5 -1
@@ -107,12 +107,16 @@ void mlx5e_rep_update_flows(struct mlx5e_priv *priv,mlx5e_tc_encap_flows_del (priv, e, &flow_list);if (neigh_connected && !(e->flags &MLX5_ENCAP_ENTRY_VALID )) { +struct net_device *route_dev; +ether_addr_copy (e->h_dest, ha);ether_addr_copy (eth->h_dest, ha);/* Update the encap source mac, in case that we delete * the flows when encap source mac changed. */ -ether_addr_copy (eth->h_source, e->route_dev->dev_addr); + route_dev =__dev_get_by_index (dev_net (priv->netdev), e->route_dev_ifindex); +if (route_dev) +ether_addr_copy (eth->h_source, route_dev->dev_addr);mlx5e_tc_encap_flows_add (priv, e, &flow_list); }
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +46 -26
161 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +1 -1
@@ -186,7 +186,7 @@ struct mlx5e_encap_entry {unsigned char h_dest[ETH_ALEN ];/* destination eth addr */ struct net_device *out_dev; -struct net_device *route_dev; +int route_dev_ifindex;struct mlx5e_tc_tunnel *tunnel;int reformat_type;u8 flags;
Signature · 1 line
2.26.2
Saeed Mahameed
maintainerPATCH v2 3/7 net/mlx5e: Use spin_lock_bh for async_icosq_lock
In reply to Saeed MahameedFrom: Maxim Mikityanskiy <[email protected]>
async_icosq_lock may be taken from softirq and non-softirq contexts. It requires protection with spin_lock_bh, otherwise a softirq may be triggered in the middle of the critical section, and it may deadlock if it tries to take the same lock. This patch fixes such a scenario by using spin_lock_bh to disable softirqs on that CPU while inside the critical section.
--- .../net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 4 ++-- .../net/ethernet/mellanox/mlx5/core/en/xsk/tx.c | 4 ++-- .../ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c +2 -2
@@ -122,9 +122,9 @@ void mlx5e_activate_xsk(struct mlx5e_channel *c)set_bit (MLX5E_RQ_STATE_ENABLED , &c->xskrq.state);/* TX queue is created active. */ -spin_lock (&c->async_icosq_lock); +spin_lock_bh (&c->async_icosq_lock);mlx5e_trigger_irq (&c->async_icosq); -spin_unlock (&c->async_icosq_lock); +spin_unlock_bh (&c->async_icosq_lock); }void mlx5e_deactivate_xsk (struct mlx5e_channel *c)
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/tx.c +2 -2
@@ -36,9 +36,9 @@ int mlx5e_xsk_wakeup(struct net_device *dev, u32 qid, u32 flags)if (test_and_set_bit (MLX5E_SQ_STATE_PENDING_XSK_TX , &c->async_icosq.state))return 0 ; -spin_lock (&c->async_icosq_lock); +spin_lock_bh (&c->async_icosq_lock);mlx5e_trigger_irq (&c->async_icosq); -spin_unlock (&c->async_icosq_lock); +spin_unlock_bh (&c->async_icosq_lock); }return 0 ;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +7 -7
@@ -188,7 +188,7 @@ static int post_rx_param_wqes(struct mlx5e_channel *c, err =0 ; sq = &c->async_icosq; -spin_lock (&c->async_icosq_lock); +spin_lock_bh (&c->async_icosq_lock); cseg =post_static_params (sq, priv_rx);if (IS_ERR (cseg))
@@ -199,7 +199,7 @@ static int post_rx_param_wqes(struct mlx5e_channel *c,mlx5e_notify_hw (&sq->wq, sq->pc, sq->uar_map, cseg); unlock: -spin_unlock (&c->async_icosq_lock); +spin_unlock_bh (&c->async_icosq_lock);return err;
@@ -265,10 +265,10 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq,BUILD_BUG_ON (MLX5E_KTLS_GET_PROGRESS_WQEBBS !=1 ); -spin_lock (&sq->channel->async_icosq_lock); +spin_lock_bh (&sq->channel->async_icosq_lock);if (unlikely (!mlx5e_wqc_has_room_for (&sq->wq, sq->cc, sq->pc,1 ))) { -spin_unlock (&sq->channel->async_icosq_lock); +spin_unlock_bh (&sq->channel->async_icosq_lock); err = -ENOSPC ; goto err_dma_unmap; }
@@ -299,7 +299,7 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq,icosq_fill_wi (sq, pi, &wi); sq->pc++;mlx5e_notify_hw (&sq->wq, sq->pc, sq->uar_map, cseg); -spin_unlock (&sq->channel->async_icosq_lock); +spin_unlock_bh (&sq->channel->async_icosq_lock);return 0 ;
@@ -360,7 +360,7 @@ static int resync_handle_seq_match(struct mlx5e_ktls_offload_context_rx *priv_rx err =0 ; sq = &c->async_icosq; -spin_lock (&c->async_icosq_lock); +spin_lock_bh (&c->async_icosq_lock); cseg =post_static_params (sq, priv_rx);if (IS_ERR (cseg)) {
@@ -372,7 +372,7 @@ static int resync_handle_seq_match(struct mlx5e_ktls_offload_context_rx *priv_rxmlx5e_notify_hw (&sq->wq, sq->pc, sq->uar_map, cseg); priv_rx->stats->tls_resync_res_ok++; unlock: -spin_unlock (&c->async_icosq_lock); +spin_unlock_bh (&c->async_icosq_lock);return err; }
Signature · 1 line
2.26.2
Saeed Mahameed
maintainerPATCH v2 4/7 net/mlx5: Fix deletion of duplicate rules
In reply to Saeed MahameedFrom: Maor Gottlieb <[email protected]>
When a rule is duplicated, the refcount of the rule is increased so only the second deletion of the rule should cause destruction of the FTE. Currently, the FTE will be destroyed in the first deletion of rule since the modify_mask will be 0.
Fix it and call to destroy FTE only if all the rules (FTE's children) have been removed.
--- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +4 -3
@@ -2010,10 +2010,11 @@ void mlx5_del_flow_rules(struct mlx5_flow_handle *handle)down_write_ref_node (&fte->node, false);for (i = handle->num_rules -1 ; i >=0 ; i--)tree_remove_node (&handle->rule[i]->node, true); -if (fte->modify_mask && fte->dests_size) { -modify_fte (fte); +if (fte->dests_size) { +if (fte->modify_mask) +modify_fte (fte);up_write_ref_node (&fte->node, false); - }else { + }else if (list_empty (&fte->node.children)) {del_hw_fte (&fte->node);/* Avoid double call to del_hw_fte */ fte->node.del_hw_func =NULL ;
Signature · 1 line
2.26.2
Saeed Mahameed
maintainerPATCH v2 5/7 net/mlx5: E-switch, Avoid extack error log for disabled vport
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
When E-switch vport is disabled, querying its hardware address is unsupported.
Avoid setting extack error log message in such case.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +0 -2
@@ -1902,8 +1902,6 @@ int mlx5_devlink_port_function_hw_addr_get(struct devlink *devlink,ether_addr_copy (hw_addr, vport->info.mac); *hw_addr_len =ETH_ALEN ; err =0 ; - }else { -NL_SET_ERR_MSG_MOD (extack,"Eswitch vport is disabled" ); }mutex_unlock (&esw->state_lock);return err;
Signature · 1 line
2.26.2
Saeed Mahameed
maintainerPATCH v2 6/7 net/mlx5e: Fix VXLAN synchronization after function reload
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
During driver reload, perform firmware tear-down which results in firmware losing the configured VXLAN ports. These ports are still available in the driver's database. Fix this by cleaning up driver's VXLAN database in the nic unload flow, before firmware tear-down. With that, minimize mlx5_vxlan_destroy() to remove only what was added in mlx5_vxlan_create() and warn on leftover UDP ports.
--- .../net/ethernet/mellanox/mlx5/core/en_main.c | 1 + .../ethernet/mellanox/mlx5/core/lib/vxlan.c | 23 ++++++++++++++----- .../ethernet/mellanox/mlx5/core/lib/vxlan.h | 2 ++ 3 files changed, 20 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -0
@@ -5253,6 +5253,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)mlx5e_disable_async_events (priv);mlx5_lag_remove (mdev); +mlx5_vxlan_reset_to_default (mdev->vxlan); }int mlx5e_update_nic_rx (struct mlx5e_priv *priv)
drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c +17 -6
@@ -167,6 +167,17 @@ struct mlx5_vxlan *mlx5_vxlan_create(struct mlx5_core_dev *mdev) }void mlx5_vxlan_destroy (struct mlx5_vxlan *vxlan) +{ +if (!mlx5_vxlan_allowed (vxlan)) +return ; + +mlx5_vxlan_del_port (vxlan,IANA_VXLAN_UDP_PORT ); +WARN_ON (!hash_empty (vxlan->htable)); + +kfree (vxlan); +} + +void mlx5_vxlan_reset_to_default (struct mlx5_vxlan *vxlan) {struct mlx5_vxlan_port *vxlanp;struct hlist_node *tmp;
@@ -175,12 +186,12 @@ void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan)if (!mlx5_vxlan_allowed (vxlan))return ; -/* Lockless since we are the only hash table consumers*/ hash_for_each_safe (vxlan->htable, bkt, tmp, vxlanp, hlist) { -hash_del (&vxlanp->hlist); -mlx5_vxlan_core_del_port_cmd (vxlan->mdev, vxlanp->udp_port); -kfree (vxlanp); +/* Don't delete default UDP port added by the HW. +* Remove only user configured ports +*/ +if (vxlanp->udp_port ==IANA_VXLAN_UDP_PORT ) +continue ; +mlx5_vxlan_del_port (vxlan, vxlanp->udp_port); } - -kfree (vxlan); }
drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h +2 -0
@@ -56,6 +56,7 @@ void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan);int mlx5_vxlan_add_port (struct mlx5_vxlan *vxlan,u16 port);int mlx5_vxlan_del_port (struct mlx5_vxlan *vxlan,u16 port);bool mlx5_vxlan_lookup_port (struct mlx5_vxlan *vxlan,u16 port); +void mlx5_vxlan_reset_to_default (struct mlx5_vxlan *vxlan);#else static inline struct mlx5_vxlan *mlx5_vxlan_create (struct mlx5_core_dev *mdev) {return ERR_PTR (-EOPNOTSUPP ); }
@@ -63,6 +64,7 @@ static inline void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan) { return; }static inline int mlx5_vxlan_add_port (struct mlx5_vxlan *vxlan,u16 port) {return -EOPNOTSUPP ; }static inline int mlx5_vxlan_del_port (struct mlx5_vxlan *vxlan,u16 port) {return -EOPNOTSUPP ; }static inline bool mlx5_vxlan_lookup_port (struct mlx5_vxlan *vxlan,u16 port) {return false; } +static inline void mlx5_vxlan_reset_to_default (struct mlx5_vxlan *vxlan) {return ; }#endif #endif /* __MLX5_VXLAN_H__ */
Signature · 1 line
2.26.2
Saeed Mahameed
maintainerPATCH v2 7/7 net/mlx5e: Fix incorrect access of RCU-protected xdp_prog
In reply to Saeed MahameedFrom: Maxim Mikityanskiy <[email protected]>
rq->xdp_prog is RCU-protected and should be accessed only with rcu_access_pointer for the NULL check in mlx5e_poll_rx_cq.
rq->xdp_prog may change on the fly only from one non-NULL value to another non-NULL value, so the checks in mlx5e_xdp_handle and mlx5e_poll_rx_cq will have the same result during one NAPI cycle, meaning that no additional synchronization is needed.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 -1
@@ -1584,7 +1584,7 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget) }while ((++work_done < budget) && (cqe =mlx5_cqwq_get_cqe (cqwq))); out: -if (rq->xdp_prog) +if (rcu_access_pointer (rq->xdp_prog))mlx5e_xdp_rx_poll_complete (rq);mlx5_cqwq_update_db_record (cqwq);
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerQuoted 17 lines · On Thu, 5 Nov 2020 12:21:22 -0800 Saeed Mahameed wrote:
This series introduces some fixes to mlx5 driver.
v1->v2:
- Fix fixes line tag in patch #1
- Toss ktls refcount leak fix, Maxim will look further into the root cause.
- Toss eswitch chain 0 prio patch, until we determine if it is needed for -rc and net.Please pull and let me know if there is any problem.
For -stable v5.1
('net/mlx5: Fix deletion of duplicate rules')For -stable v5.4
('net/mlx5e: Fix modify header actions memory leak')
Quoted 8 lines
For -stable v5.8
('net/mlx5e: Protect encap route dev from concurrent release')For -stable v5.9
('net/mlx5e: Fix VXLAN synchronization after function reload') ('net/mlx5e: Usespin_lock_bhforasync_icosq_lock') ('net/mlx5e: Fix incorrect access of RCU-protectedxdp_prog') ('net/mlx5: E-switch, Avoid extack error log for disabled vport')
Pulled, thanks!