mlx5 fixes 2021-05-18
Subsystems (8)
From: Saeed Mahameed <[email protected]>
Hi Dave, Jakub,
This series introduces some fixes to mlx5 driver.
Please pull and let me know if there is any problem.
Thanks,
Saeed.
---
The following changes since commit c9fd37a9450b23804868d7a5b0d038b32ba466be:
Merge branch 'hns3-fixes' (2021-05-18 13:41:04 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2021-05-18
for you to fetch changes up to e63052a5dd3ce7979bff727a8f4bb6d6b3d1317b:
mlx5e: add add missing BH locking around napi_schdule() (2021-05-18 23:01:55 -0700)
----------------------------------------------------------------
mlx5-fixes-2021-05-18
----------------------------------------------------------------
Ariel Levkovich (1):
net/mlx5: Set term table as an unmanaged flow table
Aya Levin (1):
net/mlx5e: Fix error path of updating netdev queues
Dima Chumak (3):
net/mlx5e: Fix nullptr in add_vlan_push_action() net/mlx5e: Fix nullptr in mlx5e_tc_add_fdb_flow() net/mlx5e: Fix multipath lag activation
Eli Cohen (1):
{net,vdpa}/mlx5: Configure interface MAC into mpfs L2 table
Jakub Kicinski (1):
mlx5e: add add missing BH locking around napi_schdule()
Jianbo Liu (1):
net/mlx5: Set reformat action when needed for termination rules
Leon Romanovsky (1):
net/mlx5: Don't overwrite HCA capabilities when setting MSI-X count
Maor Gottlieb (1):
{net, RDMA}/mlx5: Fix override of log_max_qp by other device
Parav Pandit (1):
net/mlx5: SF, Fix show state inactive when its inactivated
Roi Dayan (3):
net/mlx5: Fix err prints and return when creating termination table net/mlx5e: Fix null deref accessing lag dev
net/mlx5e: Make sure fib dev exists in fib event
Saeed Mahameed (1):
net/mlx5e: reset XPS on error flow if netdev isn't registered yet
Vlad Buslov (1):
net/mlx5e: Reject mirroring on source port change encap rules
drivers/infiniband/hw/mlx5/mr.c | 4 +- .../net/ethernet/mellanox/mlx5/core/en/rep/bond.c | 2 + .../ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 16 ++++-- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 26 +++++++-- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 1 + .../mellanox/mlx5/core/eswitch_offloads_termtbl.c | 61 +++++++++------------- drivers/net/ethernet/mellanox/mlx5/core/lag_mp.c | 6 +++ drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.c | 3 ++ drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.h | 5 +- drivers/net/ethernet/mellanox/mlx5/core/main.c | 11 ++-- drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c | 22 ++++++-- .../net/ethernet/mellanox/mlx5/core/sf/devlink.c | 18 ++++--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 19 ++++++- include/linux/mlx5/driver.h | 44 ++++++++-------- include/linux/mlx5/mpfs.h | 18 +++++++ 17 files changed, 168 insertions(+), 91 deletions(-) create mode 100644 include/linux/mlx5/mpfs.h
PATCH 1/16 {net, RDMA}/mlx5: Fix override of log_max_qp by other device
From: Maor Gottlieb <[email protected]>
mlx5_core_dev holds pointer to static profile, hence when the log_max_qp of the profile is override by some device, then it effect all other mlx5 devices that share the same profile. Fix it by having a profile instance for every mlx5 device.
--- drivers/infiniband/hw/mlx5/mr.c | 4 +- .../net/ethernet/mellanox/mlx5/core/main.c | 11 +++-- include/linux/mlx5/driver.h | 44 +++++++++---------- 3 files changed, 29 insertions(+), 30 deletions(-)
drivers/infiniband/hw/mlx5/mr.c +2 -2
@@ -743,10 +743,10 @@ int mlx5_mr_cache_init(struct mlx5_ib_dev *dev) ent->xlt = (1 << ent->order) *sizeof (struct mlx5_mtt ) /MLX5_IB_UMR_OCTOWORD ; ent->access_mode =MLX5_MKC_ACCESS_MODE_MTT ; -if ((dev->mdev->profile->mask &MLX5_PROF_MASK_MR_CACHE ) && +if ((dev->mdev->profile.mask &MLX5_PROF_MASK_MR_CACHE ) && !dev->is_rep &&mlx5_core_is_pf (dev->mdev) &&mlx5_ib_can_load_pas_with_umr (dev,0 )) - ent->limit = dev->mdev->profile->mr_cache[i].limit; + ent->limit = dev->mdev->profile.mr_cache[i].limit;else ent->limit =0 ;spin_lock_irq (&ent->lock);
drivers/net/ethernet/mellanox/mlx5/core/main.c +5 -6
@@ -503,7 +503,7 @@ static int handle_hca_cap_odp(struct mlx5_core_dev *dev, void *set_ctx)static int handle_hca_cap (struct mlx5_core_dev *dev,void *set_ctx) { -struct mlx5_profile *prof = dev->profile; +struct mlx5_profile *prof = &dev->profile;void *set_hca_cap;int err;
@@ -524,11 +524,11 @@ static int handle_hca_cap(struct mlx5_core_dev *dev, void *set_ctx) to_fw_pkey_sz(dev, 128));/* Check log_max_qp from HCA caps to set in current profile */ -if (MLX5_CAP_GEN_MAX (dev, log_max_qp) < profile[prof_sel].log_max_qp) { +if (MLX5_CAP_GEN_MAX (dev, log_max_qp) < prof->log_max_qp) {mlx5_core_warn (dev,"log_max_qp value in current profile is %d, changing it to HCA capability limit (%d)\n" , - profile[prof_sel].log_max_qp, + prof->log_max_qp,MLX5_CAP_GEN_MAX (dev, log_max_qp)); - profile[prof_sel].log_max_qp =MLX5_CAP_GEN_MAX (dev, log_max_qp); + prof->log_max_qp =MLX5_CAP_GEN_MAX (dev, log_max_qp); }if (prof->mask &MLX5_PROF_MASK_QP_SIZE ) MLX5_SET(cmd_hca_cap, set_hca_cap, log_max_qp,
@@ -1381,8 +1381,7 @@ int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)struct mlx5_priv *priv = &dev->priv;int err; - dev->profile = &profile[profile_idx]; - +memcpy (&dev->profile, &profile[profile_idx],sizeof (dev->profile));INIT_LIST_HEAD (&priv->ctx_list);spin_lock_init (&priv->ctx_lock);mutex_init (&dev->intf_state_mutex);
include/linux/mlx5/driver.h +22 -22
68 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [net 01/16] {net, RDMA}/mlx5: Fix override of log_max_qp by other device
This series was applied to netdev/net.git (refs/heads/master):
Hello:
This series was applied to netdev/net.git (refs/heads/master):
Quoted 8 lines · On Tue, 18 May 2021 23:05:08 -0700 you wrote:
From: Maor Gottlieb <[email protected]>
mlx5_core_devholds pointer to static profile, hence when thelog_max_qpof the profile is override by some device, then it effect all other mlx5 devices that share the same profile. Fix it by having a profile instance for every mlx5 device.[...]
Here is the summary with links:
- [net,01/16] {net, RDMA}/mlx5: Fix override of log_max_qp by other device
https://git.kernel.org/netdev/net/c/3410fbcd47dc - [net,02/16] net/mlx5e: Fix nullptr in add_vlan_push_action() https://git.kernel.org/netdev/net/c/dca59f4a7919 - [net,03/16] net/mlx5: Set reformat action when needed for termination rules https://git.kernel.org/netdev/net/c/442b3d7b671b - [net,04/16] net/mlx5: Fix err prints and return when creating termination table https://git.kernel.org/netdev/net/c/fca086617af8 - [net,05/16] net/mlx5: SF, Fix show state inactive when its inactivated https://git.kernel.org/netdev/net/c/82041634d96e - [net,06/16] net/mlx5e: Fix nullptr in mlx5e_tc_add_fdb_flow() https://git.kernel.org/netdev/net/c/fe7738eb3ca3 - [net,07/16] net/mlx5e: Fix null deref accessing lag dev https://git.kernel.org/netdev/net/c/83026d83186b - [net,08/16] net/mlx5e: Make sure fib dev exists in fib event https://git.kernel.org/netdev/net/c/eb96cc15926f - [net,09/16] net/mlx5e: reset XPS on error flow if netdev isn't registered yet https://git.kernel.org/netdev/net/c/77ecd10d0a8a - [net,10/16] net/mlx5e: Fix multipath lag activation https://git.kernel.org/netdev/net/c/97817fcc684e - [net,11/16] net/mlx5e: Reject mirroring on source port change encap rules https://git.kernel.org/netdev/net/c/7d1a3d08c8a6 - [net,12/16] net/mlx5e: Fix error path of updating netdev queues https://git.kernel.org/netdev/net/c/5e7923acbd86 - [net,13/16] {net,vdpa}/mlx5: Configure interface MAC into mpfs L2 table https://git.kernel.org/netdev/net/c/7c9f131f366a - [net,14/16] net/mlx5: Don't overwrite HCA capabilities when setting MSI-X count https://git.kernel.org/netdev/net/c/75e8564e919f - [net,15/16] net/mlx5: Set term table as an unmanaged flow table https://git.kernel.org/netdev/net/c/6ff51ab8aa8f - [net,16/16] mlx5e: add add missing BH locking around napi_schdule() https://git.kernel.org/netdev/net/c/e63052a5dd3c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
PATCH 2/16 net/mlx5e: Fix nullptr in add_vlan_push_action()
In reply to Saeed MahameedFrom: Dima Chumak <[email protected]>
The result of dev_get_by_index_rcu() is not checked for NULL and then gets dereferenced immediately.
Also, the RCU lock must be held by the caller of dev_get_by_index_rcu(), which isn't satisfied by the call stack.
Fix by handling nullptr return value when iflink device is not found. Add RCU locking around dev_get_by_index_rcu() to avoid possible adverse effects while iterating over the net_device's hlist.
It is safe not to increment reference count of the net_device pointer in case of a successful lookup, because it's already handled by VLAN code during VLAN device registration (see register_vlan_dev and netdev_upper_dev_link).
Addresses-Coverity: ("Dereference null return value")
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +6 -2
@@ -3526,8 +3526,12 @@ static int add_vlan_push_action(struct mlx5e_priv *priv,if (err)return err; - *out_dev =dev_get_by_index_rcu (dev_net (vlan_dev), -dev_get_iflink (vlan_dev)); +rcu_read_lock (); + *out_dev =dev_get_by_index_rcu (dev_net (vlan_dev),dev_get_iflink (vlan_dev)); +rcu_read_unlock (); +if (!*out_dev) +return -ENODEV ; +if (is_vlan_dev (*out_dev)) err =add_vlan_push_action (priv, attr, out_dev, action);
Signature · 1 line
2.31.1
PATCH 3/16 net/mlx5: Set reformat action when needed for termination rules
In reply to Saeed MahameedFrom: Jianbo Liu <[email protected]>
For remote mirroring, after the tunnel packets are received, they are decapsulated and sent to representor, then re-encapsulated and sent out over another tunnel. So reformat action is set only when the destination is required to do encapsulation.
--- .../mlx5/core/eswitch_offloads_termtbl.c | 31 ++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c +10 -21
@@ -172,19 +172,6 @@ mlx5_eswitch_termtbl_put(struct mlx5_eswitch *esw, } } -static bool mlx5_eswitch_termtbl_is_encap_reformat (struct mlx5_pkt_reformat *rt) -{ -switch (rt->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 : -return true; -default : -return false; - } -} -static void mlx5_eswitch_termtbl_actions_move (struct mlx5_flow_act *src,struct mlx5_flow_act *dst)
@@ -202,14 +189,6 @@ mlx5_eswitch_termtbl_actions_move(struct mlx5_flow_act *src,memset (&src->vlan[1 ],0 ,sizeof (src->vlan[1 ])); } } - -if (src->action &MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT && -mlx5_eswitch_termtbl_is_encap_reformat (src->pkt_reformat)) { - src->action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT ; - dst->action |=MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT ; - dst->pkt_reformat = src->pkt_reformat; - src->pkt_reformat =NULL ; - } } static bool mlx5_eswitch_offload_is_uplink_port(const struct mlx5_eswitch *esw,
@@ -279,6 +258,14 @@ mlx5_eswitch_add_termtbl_rule(struct mlx5_eswitch *esw,if (dest[i].type !=MLX5_FLOW_DESTINATION_TYPE_VPORT )continue ; +if (attr->dests[num_vport_dests].flags &MLX5_ESW_DEST_ENCAP ) { + term_tbl_act.action |=MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT ; + term_tbl_act.pkt_reformat = attr->dests[num_vport_dests].pkt_reformat; + }else { + term_tbl_act.action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT ; + term_tbl_act.pkt_reformat =NULL ; + } +/* get the terminating table for the action list */ tt =mlx5_eswitch_termtbl_get_create (esw, &term_tbl_act, &dest[i], attr);
@@ -301,6 +288,8 @@ mlx5_eswitch_add_termtbl_rule(struct mlx5_eswitch *esw, goto revert_changes;/* create the FTE */ + flow_act->action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT ; + flow_act->pkt_reformat =NULL ; rule =mlx5_add_flow_rules (fdb, spec, flow_act, dest, num_dest);if (IS_ERR (rule)) goto revert_changes;
Signature · 1 line
2.31.1
PATCH 4/16 net/mlx5: Fix err prints and return when creating termination table
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Fix print to print correct error code and not using IS_ERR() which will just result in always printing 1.
Also return real err instead of always -EOPNOTSUPP.
--- .../mlx5/core/eswitch_offloads_termtbl.c | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c +11 -12
@@ -65,7 +65,7 @@ mlx5_eswitch_termtbl_create(struct mlx5_core_dev *dev, {struct mlx5_flow_table_attr ft_attr = {};struct mlx5_flow_namespace *root_ns; -int err; +int err, err2; root_ns =mlx5_get_flow_namespace (dev,MLX5_FLOW_NAMESPACE_FDB );if (!root_ns) {
@@ -83,26 +83,26 @@ mlx5_eswitch_termtbl_create(struct mlx5_core_dev *dev, ft_attr.autogroup.max_num_groups =1 ; tt->termtbl =mlx5_create_auto_grouped_flow_table (root_ns, &ft_attr);if (IS_ERR (tt->termtbl)) { -esw_warn (dev,"Failed to create termination table (error %d)\n" , -IS_ERR (tt->termtbl)); -return -EOPNOTSUPP ; + err =PTR_ERR (tt->termtbl); +esw_warn (dev,"Failed to create termination table, err %pe\n" , tt->termtbl); +return err; } tt->rule =mlx5_add_flow_rules (tt->termtbl,NULL , flow_act, &tt->dest,1 );if (IS_ERR (tt->rule)) { -esw_warn (dev,"Failed to create termination table rule (error %d)\n" , -IS_ERR (tt->rule)); + err =PTR_ERR (tt->rule); +esw_warn (dev,"Failed to create termination table rule, err %pe\n" , tt->rule); goto add_flow_err; }return 0 ; add_flow_err: - err =mlx5_destroy_flow_table (tt->termtbl); -if (err) -esw_warn (dev,"Failed to destroy termination table\n" ); + err2 =mlx5_destroy_flow_table (tt->termtbl); +if (err2) +esw_warn (dev,"Failed to destroy termination table, err %d\n" , err2); -return -EOPNOTSUPP ; +return err; } static struct mlx5_termtbl_handle *
@@ -270,8 +270,7 @@ mlx5_eswitch_add_termtbl_rule(struct mlx5_eswitch *esw, tt =mlx5_eswitch_termtbl_get_create (esw, &term_tbl_act, &dest[i], attr);if (IS_ERR (tt)) { -esw_warn (esw->dev,"Failed to get termination table (error %d)\n" , -IS_ERR (tt)); +esw_warn (esw->dev,"Failed to get termination table, err %pe\n" , tt); goto revert_changes; } attr->dests[num_vport_dests].termtbl = tt;
Signature · 1 line
2.31.1
PATCH 5/16 net/mlx5: SF, Fix show state inactive when its inactivated
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
When a SF is inactivated and when it is in a TEARDOWN_REQUEST state, driver still returns its state as active. This is incorrect. Fix it by treating TEARDOWN_REQEUST as inactive state. When a SF is still attached to the driver, on user request to reactivate EINVAL error is returned. Inform user about it with better code EBUSY and informative error message.
--- .../ethernet/mellanox/mlx5/core/sf/devlink.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c +11 -7
@@ -136,10 +136,10 @@ static enum devlink_port_fn_state mlx5_sf_to_devlink_state(u8 hw_state)switch (hw_state) {case MLX5_VHCA_STATE_ACTIVE :case MLX5_VHCA_STATE_IN_USE : -case MLX5_VHCA_STATE_TEARDOWN_REQUEST :return DEVLINK_PORT_FN_STATE_ACTIVE ;case MLX5_VHCA_STATE_INVALID :case MLX5_VHCA_STATE_ALLOCATED : +case MLX5_VHCA_STATE_TEARDOWN_REQUEST :default :return DEVLINK_PORT_FN_STATE_INACTIVE ; }
@@ -192,14 +192,17 @@ int mlx5_devlink_sf_port_fn_state_get(struct devlink *devlink, struct devlink_poreturn err; } -static int mlx5_sf_activate (struct mlx5_core_dev *dev,struct mlx5_sf *sf) +static int mlx5_sf_activate (struct mlx5_core_dev *dev,struct mlx5_sf *sf, +struct netlink_ext_ack *extack) {int err;if (mlx5_sf_is_active (sf))return 0 ; -if (sf->hw_state !=MLX5_VHCA_STATE_ALLOCATED ) -return -EINVAL ; +if (sf->hw_state !=MLX5_VHCA_STATE_ALLOCATED ) { +NL_SET_ERR_MSG_MOD (extack,"SF is inactivated but it is still attached" ); +return -EBUSY ; + } err =mlx5_cmd_sf_enable_hca (dev, sf->hw_fn_id);if (err)
@@ -226,7 +229,8 @@ static int mlx5_sf_deactivate(struct mlx5_core_dev *dev, struct mlx5_sf *sf)static int mlx5_sf_state_set (struct mlx5_core_dev *dev,struct mlx5_sf_table *table,struct mlx5_sf *sf, -enum devlink_port_fn_state state) +enum devlink_port_fn_state state, +struct netlink_ext_ack *extack) {int err =0 ;
@@ -234,7 +238,7 @@ static int mlx5_sf_state_set(struct mlx5_core_dev *dev, struct mlx5_sf_table *taif (state ==mlx5_sf_to_devlink_state (sf->hw_state)) goto out;if (state ==DEVLINK_PORT_FN_STATE_ACTIVE ) - err =mlx5_sf_activate (dev, sf); + err =mlx5_sf_activate (dev, sf, extack);else if (state ==DEVLINK_PORT_FN_STATE_INACTIVE ) err =mlx5_sf_deactivate (dev, sf);else
@@ -265,7 +269,7 @@ int mlx5_devlink_sf_port_fn_state_set(struct devlink *devlink, struct devlink_po goto out; } - err =mlx5_sf_state_set (dev, table, sf, state); + err =mlx5_sf_state_set (dev, table, sf, state, extack); out:mlx5_sf_table_put (table);return err;
Signature · 1 line
2.31.1
PATCH 6/16 net/mlx5e: Fix nullptr in mlx5e_tc_add_fdb_flow()
In reply to Saeed MahameedFrom: Dima Chumak <[email protected]>
The result of __dev_get_by_index() is not checked for NULL, which then passed to mlx5e_attach_encap() and gets dereferenced.
Also, in case of a successful lookup, the net_device reference count is not incremented, which may result in net_device pointer becoming invalid at any time during mlx5e_attach_encap() execution.
Fix by using dev_get_by_index(), which does proper reference counting on the net_device pointer. Also, handle nullptr return value when mirred device is not found.
It's safe to call dev_put() on the mirred net_device pointer, right after mlx5e_attach_encap() call, because it's not being saved/copied down the call chain.
Addresses-Coverity: ("Dereference null return value")
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +9 -3
@@ -1322,10 +1322,10 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, struct netlink_ext_ack *extack) {struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; -struct net_device *out_dev, *encap_dev =NULL ;struct mlx5e_tc_flow_parse_attr *parse_attr;struct mlx5_flow_attr *attr = flow->attr;bool vf_tun = false, encap_valid = true; +struct net_device *encap_dev =NULL ;struct mlx5_esw_flow_attr *esw_attr;struct mlx5_fc *counter =NULL ;struct mlx5e_rep_priv *rpriv;
@@ -1371,16 +1371,22 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, esw_attr = attr->esw_attr;for (out_index =0 ; out_index <MLX5_MAX_FLOW_FWD_VPORTS ; out_index++) { +struct net_device *out_dev;int mirred_ifindex;if (!(esw_attr->dests[out_index].flags &MLX5_ESW_DEST_ENCAP ))continue ; mirred_ifindex = parse_attr->mirred_ifindex[out_index]; - out_dev =__dev_get_by_index (dev_net (priv->netdev), - mirred_ifindex); + out_dev =dev_get_by_index (dev_net (priv->netdev), mirred_ifindex); +if (!out_dev) { +NL_SET_ERR_MSG_MOD (extack,"Requested mirred device not found" ); + err = -ENODEV ; + goto err_out; + } err =mlx5e_attach_encap (priv, flow, out_dev, out_index, extack, &encap_dev, &encap_valid); +dev_put (out_dev);if (err) goto err_out;
Signature · 1 line
2.31.1
PATCH 7/16 net/mlx5e: Fix null deref accessing lag dev
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
It could be the lag dev is null so stop processing the event. In bond_enslave() the active/backup slave being set before setting the upper dev so first event is without an upper dev.
After setting the upper dev with bond_master_upper_dev_link() there is a second event and in that event we have an upper dev.
--- drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c +2 -0
@@ -223,6 +223,8 @@ static void mlx5e_rep_changelowerstate_event(struct net_device *netdev, void *pt rpriv = priv->ppriv; fwd_vport_num = rpriv->rep->vport; lag_dev =netdev_master_upper_dev_get (netdev); +if (!lag_dev) +return ;netdev_dbg (netdev,"lag_dev(%s)'s slave vport(%d) is txable(%d)\n" , lag_dev->name, fwd_vport_num,net_lag_port_dev_txable (netdev));
Signature · 1 line
2.31.1
PATCH 8/16 net/mlx5e: Make sure fib dev exists in fib event
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
For unreachable route entry the fib dev does not exists.
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +1 -1
@@ -1505,7 +1505,7 @@ mlx5e_init_fib_work_ipv4(struct mlx5e_priv *priv, fen_info = container_of(info, struct fib_entry_notifier_info, info); fib_dev =fib_info_nh (fen_info->fi,0 )->fib_nh_dev; -if (fib_dev->netdev_ops != &mlx5e_netdev_ops || +if (!fib_dev || fib_dev->netdev_ops != &mlx5e_netdev_ops || fen_info->dst_len !=32 )return NULL ;
Signature · 1 line
2.31.1
PATCH 9/16 net/mlx5e: reset XPS on error flow if netdev isn't registered yet
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
mlx5e_attach_netdev can be called prior to registering the netdevice:
Example stack:
ipoib_new_child_link ->
ipoib_intf_init->
rdma_init_netdev->
mlx5_rdma_setup_rn->
mlx5e_attach_netdev->mlx5e_num_channels_changed ->mlx5e_set_default_xps_cpumasks ->netif_set_xps_queue ->__netif_set_xps_queue -> kmalloc
If any later stage fails at any point after mlx5e_num_channels_changed() returns, XPS allocated maps will never be freed as they
are only freed during netdev unregistration, which will never happen for yet to be registered netdevs.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +7 -0
@@ -5229,6 +5229,11 @@ static void mlx5e_update_features(struct net_device *netdev)rtnl_unlock (); } +static void mlx5e_reset_channels (struct net_device *netdev) +{ +netdev_reset_tc (netdev); +} +int mlx5e_attach_netdev (struct mlx5e_priv *priv) {const bool take_rtnl = priv->netdev->reg_state ==NETREG_REGISTERED ;
@@ -5283,6 +5288,7 @@ int mlx5e_attach_netdev(struct mlx5e_priv *priv) profile->cleanup_tx (priv); out: +mlx5e_reset_channels (priv->netdev);set_bit (MLX5E_STATE_DESTROYING , &priv->state);cancel_work_sync (&priv->update_stats_work);return err;
@@ -5300,6 +5306,7 @@ void mlx5e_detach_netdev(struct mlx5e_priv *priv) profile->cleanup_rx (priv); profile->cleanup_tx (priv); +mlx5e_reset_channels (priv->netdev);cancel_work_sync (&priv->update_stats_work); }
Signature · 1 line
2.31.1
PATCH 10/16 net/mlx5e: Fix multipath lag activation
In reply to Saeed MahameedFrom: Dima Chumak <[email protected]>
When handling FIB_EVENT_ENTRY_REPLACE event for a new multipath route, lag activation can be missed if a stale (struct lag_mp)->mfi pointer exists, which was associated with an older multipath route that had been removed.
Normally, when a route is removed, it triggers mlx5_lag_fib_event(), which handles FIB_EVENT_ENTRY_DEL and clears mfi pointer. But, if mlx5_lag_check_prereq() condition isn't met, for example when eswitch is in legacy mode, the fib event is skipped and mfi pointer becomes stale.
Fix by resetting mfi pointer to NULL every time mlx5_lag_mp_init() is called.
--- drivers/net/ethernet/mellanox/mlx5/core/lag_mp.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/lag_mp.c +6 -0
@@ -307,6 +307,11 @@ int mlx5_lag_mp_init(struct mlx5_lag *ldev)struct lag_mp *mp = &ldev->lag_mp;int err; +/* always clear mfi, as it might become stale when a route delete event +* has been missed +*/ + mp->mfi =NULL ; +if (mp->fib_nb.notifier_call)return 0 ;
@@ -335,4 +340,5 @@ void mlx5_lag_mp_cleanup(struct mlx5_lag *ldev)unregister_fib_notifier (&init_net, &mp->fib_nb);destroy_workqueue (mp->wq); mp->fib_nb.notifier_call =NULL ; + mp->mfi =NULL ; }
Signature · 1 line
2.31.1
PATCH 11/16 net/mlx5e: Reject mirroring on source port change encap rules
In reply to Saeed MahameedFrom: Vlad Buslov <[email protected]>
Rules with MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE dest flag are translated to destination FT in eswitch. Currently it is not possible to mirror such rules because firmware doesn't support mixing FT and Vport destinations in single rule when one of them adds encapsulation. Since the only use case for MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE destination is support for tunnel endpoints on VF and trying to offload such rule with mirror action causes either crash in fs_core or firmware error with syndrome 0xff6a1d, reject all such rules in mlx5 TC layer.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +6 -0
@@ -1399,6 +1399,12 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, esw_attr->dests[out_index].mdev = out_priv->mdev; } +if (vf_tun && esw_attr->out_count >1 ) { +NL_SET_ERR_MSG_MOD (extack,"VF tunnel encap with mirroring is not supported" ); + err = -EOPNOTSUPP ; + goto err_out; + } + err =mlx5_eswitch_add_vlan_action (esw, attr);if (err) goto err_out;
Signature · 1 line
2.31.1
PATCH 12/16 net/mlx5e: Fix error path of updating netdev queues
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Avoid division by zero in the error flow. In the driver TC number can be either 1 or 8. When TC count is set to 1, driver zero netdev->num_tc. Hence, need to convert it back from 0 to 1 in the error flow.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -1
@@ -2697,7 +2697,7 @@ static int mlx5e_update_netdev_queues(struct mlx5e_priv *priv)int err; old_num_txqs = netdev->real_num_tx_queues; - old_ntc = netdev->num_tc; + old_ntc = netdev->num_tc ? :1 ; nch = priv->channels.params.num_channels; ntc = priv->channels.params.num_tc;
Signature · 1 line
2.31.1
PATCH 13/16 {net,vdpa}/mlx5: Configure interface MAC into mpfs L2 table
In reply to Saeed MahameedFrom: Eli Cohen <[email protected]>
net/mlx5: Expose MPFS configuration API
MPFS is the multi physical function switch that bridges traffic between the physical port and any physical functions associated with it. The driver is required to add or remove MAC entries to properly forward incoming traffic to the correct physical function.
We export the API to control MPFS so that other drivers, such as mlx5_vdpa are able to add MAC addresses of their network interfaces.
The MAC address of the vdpa interface must be configured into the MPFS L2 address. Failing to do so could cause, in some NIC configurations, failure to forward packets to the vdpa network device instance.
Fix this by adding calls to update the MPFS table.
--- .../net/ethernet/mellanox/mlx5/core/en_fs.c | 1 + .../net/ethernet/mellanox/mlx5/core/eswitch.c | 1 + .../ethernet/mellanox/mlx5/core/lib/mpfs.c | 3 +++ .../ethernet/mellanox/mlx5/core/lib/mpfs.h | 5 +---- drivers/vdpa/mlx5/net/mlx5_vnet.c | 19 ++++++++++++++++++- include/linux/mlx5/mpfs.h | 18 ++++++++++++++++++ 6 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 include/linux/mlx5/mpfs.h
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +1 -0
@@ -35,6 +35,7 @@#include <linux/ipv6.h> #include <linux/tcp.h> #include <linux/mlx5/fs.h> +#include <linux/mlx5/mpfs.h> #include "en.h" #include "en_rep.h" #include "lib/mpfs.h"
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +1 -0
@@ -35,6 +35,7 @@#include <linux/mlx5/mlx5_ifc.h> #include <linux/mlx5/vport.h> #include <linux/mlx5/fs.h> +#include <linux/mlx5/mpfs.h> #include "esw/acl/lgcy.h" #include "esw/legacy.h" #include "mlx5_core.h"
drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.c +3 -0
@@ -33,6 +33,7 @@#include <linux/etherdevice.h> #include <linux/mlx5/driver.h> #include <linux/mlx5/mlx5_ifc.h> +#include <linux/mlx5/mpfs.h> #include <linux/mlx5/eswitch.h> #include "mlx5_core.h" #include "lib/mpfs.h"
@@ -175,6 +176,7 @@ int mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u8 *mac)mutex_unlock (&mpfs->lock);return err; } +EXPORT_SYMBOL (mlx5_mpfs_add_mac);int mlx5_mpfs_del_mac (struct mlx5_core_dev *dev,u8 *mac) {
@@ -206,3 +208,4 @@ int mlx5_mpfs_del_mac(struct mlx5_core_dev *dev, u8 *mac)mutex_unlock (&mpfs->lock);return err; } +EXPORT_SYMBOL (mlx5_mpfs_del_mac);
drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.h +1 -4
@@ -84,12 +84,9 @@ struct l2addr_node {#ifdef CONFIG_MLX5_MPFS int mlx5_mpfs_init (struct mlx5_core_dev *dev);void mlx5_mpfs_cleanup (struct mlx5_core_dev *dev); -int mlx5_mpfs_add_mac (struct mlx5_core_dev *dev,u8 *mac); -int mlx5_mpfs_del_mac (struct mlx5_core_dev *dev,u8 *mac);#else /* #ifndef CONFIG_MLX5_MPFS */ static inline int mlx5_mpfs_init (struct mlx5_core_dev *dev) {return 0 ; }static inline void mlx5_mpfs_cleanup (struct mlx5_core_dev *dev) {} -static inline int mlx5_mpfs_add_mac (struct mlx5_core_dev *dev,u8 *mac) {return 0 ; } -static inline int mlx5_mpfs_del_mac (struct mlx5_core_dev *dev,u8 *mac) {return 0 ; }#endif +#endif
drivers/vdpa/mlx5/net/mlx5_vnet.c +18 -1
@@ -15,6 +15,7 @@#include <linux/mlx5/vport.h> #include <linux/mlx5/fs.h> #include <linux/mlx5/mlx5_ifc_vdpa.h> +#include <linux/mlx5/mpfs.h> #include "mlx5_vdpa.h" MODULE_AUTHOR ("Eli Cohen <[email protected]>" );
@@ -1859,11 +1860,16 @@ static int mlx5_vdpa_set_map(struct vdpa_device *vdev, struct vhost_iotlb *iotlbstatic void mlx5_vdpa_free (struct vdpa_device *vdev) {struct mlx5_vdpa_dev *mvdev =to_mvdev (vdev); +struct mlx5_core_dev *pfmdev;struct mlx5_vdpa_net *ndev; ndev =to_mlx5_vdpa_ndev (mvdev);free_resources (ndev); +if (!is_zero_ether_addr (ndev->config.mac)) { + pfmdev =pci_get_drvdata (pci_physfn (mvdev->mdev->pdev)); +mlx5_mpfs_del_mac (pfmdev, ndev->config.mac); + }mlx5_vdpa_free_resources (&ndev->mvdev);mutex_destroy (&ndev->reslock); }
@@ -1990,6 +1996,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name) { struct mlx5_vdpa_mgmtdev *mgtdev = container_of(v_mdev, struct mlx5_vdpa_mgmtdev, mgtdev);struct virtio_net_config *config; +struct mlx5_core_dev *pfmdev;struct mlx5_vdpa_dev *mvdev;struct mlx5_vdpa_net *ndev;struct mlx5_core_dev *mdev;
@@ -2023,10 +2030,17 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name)if (err) goto err_mtu; +if (!is_zero_ether_addr (config->mac)) { + pfmdev =pci_get_drvdata (pci_physfn (mdev->pdev)); + err =mlx5_mpfs_add_mac (pfmdev, config->mac); +if (err) + goto err_mtu; + } + mvdev->vdev.dma_dev = mdev->device; err =mlx5_vdpa_alloc_resources (&ndev->mvdev);if (err) - goto err_mtu; + goto err_mpfs; err =alloc_resources (ndev);if (err)
@@ -2044,6 +2058,9 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name)free_resources (ndev); err_res:mlx5_vdpa_free_resources (&ndev->mvdev); +err_mpfs: +if (!is_zero_ether_addr (config->mac)) +mlx5_mpfs_del_mac (pfmdev, config->mac); err_mtu:mutex_destroy (&ndev->reslock);put_device (&mvdev->vdev.dev);
include/linux/mlx5/mpfs.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +* Copyright (c) 2021 Mellanox Technologies Ltd. +*/ + +#ifndef _MLX5_MPFS_ +#define _MLX5_MPFS_ + +struct mlx5_core_dev ; + +#ifdef CONFIG_MLX5_MPFS +int mlx5_mpfs_add_mac (struct mlx5_core_dev *dev,u8 *mac); +int mlx5_mpfs_del_mac (struct mlx5_core_dev *dev,u8 *mac); +#else /* #ifndef CONFIG_MLX5_MPFS */ +static inline int mlx5_mpfs_add_mac (struct mlx5_core_dev *dev,u8 *mac) {return 0 ; } +static inline int mlx5_mpfs_del_mac (struct mlx5_core_dev *dev,u8 *mac) {return 0 ; } +#endif + +#endif
Signature · 1 line
2.31.1
PATCH 14/16 net/mlx5: Don't overwrite HCA capabilities when setting MSI-X count
In reply to Saeed MahameedFrom: Leon Romanovsky <[email protected]>
During driver probe of device that has dynamic MSI-X feature enabled, the following error is printed in some FW flavour (not released yet).
mlx5_core 0000:06:00.0: firmware version: 4.7.4387
mlx5_core 0000:06:00.0: 126.016 Gb/s available PCIe bandwidth (8.0 GT/s PCIe x16 link)
mlx5_core 0000:06:00.0: mlx5_cmd_check:777:(pid 70599): SET_HCA_CAP(0x109) op_mod(0x0) failed, status bad parameter(0x3), syndrome (0x0) mlx5_core 0000:06:00.0: set_hca_cap:622:(pid 70599): handle_hca_cap failed
mlx5_core 0000:06:00.0: mlx5_function_setup:1045:(pid 70599): set_hca_cap failed
mlx5_core 0000:06:00.0: probe_one:1465:(pid 70599): mlx5_init_one failed with error code -22
mlx5_core: probe of 0000:06:00.0 failed with error -22
In order to make the setting capability of MSI-X future proof, let's query the current capabilities first.
--- .../net/ethernet/mellanox/mlx5/core/pci_irq.c | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c +17 -5
@@ -95,9 +95,10 @@ int mlx5_get_default_msix_vec_count(struct mlx5_core_dev *dev, int num_vfs)int mlx5_set_msix_vec_count (struct mlx5_core_dev *dev,int function_id,int msix_vec_count) { -int sz =MLX5_ST_SZ_BYTES (set_hca_cap_in); +int query_sz =MLX5_ST_SZ_BYTES (query_hca_cap_out); +int set_sz =MLX5_ST_SZ_BYTES (set_hca_cap_in); +void *hca_cap =NULL , *query_cap =NULL , *cap;int num_vf_msix, min_msix, max_msix; -void *hca_cap, *cap;int ret; num_vf_msix =MLX5_CAP_GEN_MAX (dev, num_total_dynamic_vf_msix);
@@ -116,11 +117,20 @@ int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int function_id,if (msix_vec_count > max_msix)return -EOVERFLOW ; - hca_cap =kzalloc (sz,GFP_KERNEL ); -if (!hca_cap) -return -ENOMEM ; + query_cap =kzalloc (query_sz,GFP_KERNEL ); + hca_cap =kzalloc (set_sz,GFP_KERNEL ); +if (!hca_cap || !query_cap) { + ret = -ENOMEM ; + goto out; + } + + ret =mlx5_vport_get_other_func_cap (dev, function_id, query_cap); +if (ret) + goto out; cap =MLX5_ADDR_OF (set_hca_cap_in, hca_cap, capability); +memcpy (cap,MLX5_ADDR_OF (query_hca_cap_out, query_cap, capability), +MLX5_UN_SZ_BYTES (hca_cap_union));MLX5_SET (cmd_hca_cap, cap, dynamic_msix_table_size, msix_vec_count);MLX5_SET (set_hca_cap_in, hca_cap, opcode,MLX5_CMD_OP_SET_HCA_CAP );
@@ -130,7 +140,9 @@ int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int function_id,MLX5_SET (set_hca_cap_in, hca_cap, op_mod,MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE <<1 ); ret =mlx5_cmd_exec_in (dev, set_hca_cap, hca_cap); +out:kfree (hca_cap); +kfree (query_cap);return ret; }
Signature · 1 line
2.31.1
PATCH 15/16 net/mlx5: Set term table as an unmanaged flow table
In reply to Saeed MahameedFrom: Ariel Levkovich <[email protected]>
Termination tables are restricted to have the default miss action and cannot be set to forward to another table in case of a miss. If the fs prio of the termination table is not the last one in the list, fs_core will attempt to attach it to another table.
Set the unmanaged ft flag when creating the termination table ft and select the tc offload prio for it to prevent fs_core from selecting the forwarding to next ft miss action and use the default one.
In addition, set the flow that forwards to the termination table to ignore ft level restrictions since the ft level is not set by fs_core for unamanged fts.
--- .../ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c +5 -2
@@ -76,10 +76,11 @@ mlx5_eswitch_termtbl_create(struct mlx5_core_dev *dev,/* As this is the terminating action then the termination table is the * same prio as the slow path */ - ft_attr.flags =MLX5_FLOW_TABLE_TERMINATION | + ft_attr.flags =MLX5_FLOW_TABLE_TERMINATION |MLX5_FLOW_TABLE_UNMANAGED |MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT ; - ft_attr.prio =FDB_SLOW_PATH ; + ft_attr.prio =FDB_TC_OFFLOAD ; ft_attr.max_fte =1 ; + ft_attr.level =1 ; ft_attr.autogroup.max_num_groups =1 ; tt->termtbl =mlx5_create_auto_grouped_flow_table (root_ns, &ft_attr);if (IS_ERR (tt->termtbl)) {
@@ -217,6 +218,7 @@ mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw,int i;if (!MLX5_CAP_ESW_FLOWTABLE_FDB (esw->dev, termination_table) || + !MLX5_CAP_ESW_FLOWTABLE_FDB (esw->dev, ignore_flow_level) || attr->flags &MLX5_ESW_ATTR_FLAG_SLOW_PATH || !mlx5_eswitch_offload_is_uplink_port (esw, spec))return false;
@@ -289,6 +291,7 @@ mlx5_eswitch_add_termtbl_rule(struct mlx5_eswitch *esw,/* create the FTE */ flow_act->action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT ; flow_act->pkt_reformat =NULL ; + flow_act->flags |=FLOW_ACT_IGNORE_FLOW_LEVEL ; rule =mlx5_add_flow_rules (fdb, spec, flow_act, dest, num_dest);if (IS_ERR (rule)) goto revert_changes;
Signature · 1 line
2.31.1
PATCH 16/16 mlx5e: add add missing BH locking around napi_schdule()
In reply to Saeed MahameedFrom: Jakub Kicinski <[email protected]>
It's not correct to call napi_schedule() in pure process context. Because we use __raise_softirq_irqoff() we require callers to be in a context which will eventually lead to softirq handling (hardirq, bh disabled, etc.).
With code as is users will see:
NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!!
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +5 -2
@@ -889,10 +889,13 @@ int mlx5e_open_rq(struct mlx5e_params *params, struct mlx5e_rq_param *param,void mlx5e_activate_rq (struct mlx5e_rq *rq) {set_bit (MLX5E_RQ_STATE_ENABLED , &rq->state); -if (rq->icosq) +if (rq->icosq) {mlx5e_trigger_irq (rq->icosq); -else + }else { +local_bh_disable ();napi_schedule (rq->cq.napi); +local_bh_enable (); + } }void mlx5e_deactivate_rq (struct mlx5e_rq *rq)
Signature · 1 line
2.31.1