mlx5 fixes 2021-01-07
Subsystems (6)
From: Saeed Mahameed <[email protected]>
Hi Dave, Jakub,
This series provides some fixes to mlx5 driver. Please pull and let me know if there is any problem.
For -stable v5.2
('net/mlx5: Use port_num 1 instead of 0 when delete a RoCE address')
For -stable v5.5
('net/mlx5e: ethtool, Fix restriction of autoneg with 56G')
For -stable v5.8
('net/mlx5e: In skb build skip setting mark in switchdev mode')
For -stable v5.10
('net/mlx5: Check if lag is supported before creating one') ('net/mlx5e: Fix SWP offsets when vlan inserted by driver')
Thanks,
Saeed.
---
The following changes since commit 5316a7c0130acf09bfc8bb0092407006010fcccc:
tools: selftests: add test for changing routes with PTMU exceptions (2021-01-07 12:03:36 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2021-01-07
for you to fetch changes up to 5b0bb12c58ac7d22e05b5bfdaa30a116c8c32e32:
net/mlx5e: Fix memleak in mlx5e_create_l2_table_groups (2021-01-07 12:22:51 -0800)
----------------------------------------------------------------
mlx5-fixes-2021-01-07
----------------------------------------------------------------
Alaa Hleihel (1):
net/mlx5: E-Switch, fix changing vf VLANID
Aya Levin (2):
net/mlx5e: Add missing capability check for uplink follow net/mlx5e: ethtool, Fix restriction of autoneg with 56G
Dinghao Liu (2):
net/mlx5e: Fix two double free cases net/mlx5e: Fix memleak in mlx5e_create_l2_table_groups
Leon Romanovsky (1):
net/mlx5: Release devlink object if adev fails
Maor Dickman (1):
net/mlx5e: In skb build skip setting mark in switchdev mode
Mark Zhang (2):
net/mlx5: Check if lag is supported before creating one net/mlx5: Use port_num 1 instead of 0 when delete a RoCE address
Moshe Shemesh (1):
net/mlx5e: Fix SWP offsets when vlan inserted by driver
Oz Shlomo (1):
net/mlx5e: CT: Use per flow counter when CT flow accounting is enabled
.../net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 5 ++ drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 77 ++++++++++++++-------- drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h | 9 +++ .../mellanox/mlx5/core/en_accel/en_accel.h | 8 ++- .../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 24 +++++-- drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 3 + drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 3 +- drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 9 +-- .../mellanox/mlx5/core/esw/acl/egress_lgcy.c | 27 ++++---- drivers/net/ethernet/mellanox/mlx5/core/lag.c | 11 ++-- drivers/net/ethernet/mellanox/mlx5/core/main.c | 7 +- drivers/net/ethernet/mellanox/mlx5/core/rdma.c | 2 +- include/linux/mlx5/mlx5_ifc.h | 3 +- 13 files changed, 122 insertions(+), 66 deletions(-)
PATCH 1/11 net/mlx5: Check if lag is supported before creating one
From: Mark Zhang <[email protected]>
This patch fixes a memleak issue by preventing to create a lag and add PFs if lag is not supported.
comm “python3”, pid 349349, jiffies 4296985507 (age 1446.976s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ……………. 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 …………….
backtrace:
[<000000005b216ae7>] mlx5_lag_add+0x1d5/0×3f0 [mlx5_core] [<000000000445aa55>] mlx5e_nic_enable+0x66/0×1b0 [mlx5_core] [<00000000c56734c3>] mlx5e_attach_netdev+0x16e/0×200 [mlx5_core] [<0000000030439d1f>] mlx5e_attach+0x5c/0×90 [mlx5_core] [<0000000018fd8615>] mlx5e_add+0x1a4/0×410 [mlx5_core] [<0000000068bc504b>] mlx5_add_device+0x72/0×120 [mlx5_core]
[<000000009fce51f9>] mlx5_register_device+0x77/0xb0 [mlx5_core] [<00000000d0d81ff3>] mlx5_load_one+0xc58/0×1eb0 [mlx5_core] [<0000000045077adc>] init_one+0x3ea/0×920 [mlx5_core] [<0000000043287674>] pci_device_probe+0xcd/0×150 [<00000000dafd3279>] really_probe+0x1c9/0×4b0 [<00000000f06bdd84>] driver_probe_device+0x5d/0×140 [<00000000e3d508b6>] device_driver_attach+0x4f/0×60 [<0000000084fba0f0>] bind_store+0xbf/0×120 [<00000000bf6622b3>] kernfs_fop_write+0x114/0×1b0
--- drivers/net/ethernet/mellanox/mlx5/core/lag.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lag.c +5 -6
@@ -564,7 +564,9 @@ void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev)struct mlx5_core_dev *tmp_dev;int i, err; -if (!MLX5_CAP_GEN (dev, vport_group_manager)) +if (!MLX5_CAP_GEN (dev, vport_group_manager) || + !MLX5_CAP_GEN (dev, lag_master) || +MLX5_CAP_GEN (dev, num_lag_ports) !=MLX5_MAX_PORTS )return ; tmp_dev =mlx5_get_next_phys_dev (dev);
@@ -582,12 +584,9 @@ void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev)if (mlx5_lag_dev_add_pf (ldev, dev, netdev) <0 )return ; -for (i =0 ; i <MLX5_MAX_PORTS ; i++) { - tmp_dev = ldev->pf[i].dev; -if (!tmp_dev || !MLX5_CAP_GEN (tmp_dev, lag_master) || -MLX5_CAP_GEN (tmp_dev, num_lag_ports) !=MLX5_MAX_PORTS ) +for (i =0 ; i <MLX5_MAX_PORTS ; i++) +if (!ldev->pf[i].dev)break ; - }if (i >=MLX5_MAX_PORTS ) ldev->flags |=MLX5_LAG_FLAG_READY ;
Signature · 1 line
2.26.2
PATCH 2/11 net/mlx5e: Add missing capability check for uplink follow
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Expose firmware indication that it supports setting eswitch uplink state to follow (follow the physical link). Condition setting the eswitch uplink admin-state with this capability bit. Older FW may not support the uplink state setting.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 3 ++- include/linux/mlx5/mlx5_ifc.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -1
@@ -3161,7 +3161,8 @@ static void mlx5e_modify_admin_state(struct mlx5_core_dev *mdev,mlx5_set_port_admin_status (mdev, state); -if (mlx5_eswitch_mode (mdev) !=MLX5_ESWITCH_LEGACY ) +if (mlx5_eswitch_mode (mdev) ==MLX5_ESWITCH_OFFLOADS || + !MLX5_CAP_GEN (mdev, uplink_follow))return ;if (state ==MLX5_PORT_UP )
include/linux/mlx5/mlx5_ifc.h +2 -1
@@ -1280,7 +1280,8 @@ struct mlx5_ifc_cmd_hca_cap_bits {u8 ece_support[0x1 ];u8 reserved_at_a4[0x7 ];u8 log_max_srq[0x5 ]; -u8 reserved_at_b0[0x2 ]; +u8 reserved_at_b0[0x1 ]; +u8 uplink_follow[0x1 ];u8 ts_cqe_to_dest_cqn[0x1 ];u8 reserved_at_b3[0xd ];
Signature · 1 line
2.26.2
PATCH 3/11 net/mlx5: Use port_num 1 instead of 0 when delete a RoCE address
In reply to Saeed MahameedFrom: Mark Zhang <[email protected]>
In multi-port mode, FW reports syndrome 0x2ea48 (invalid vhca_port_number) if the port_num is not 1 or 2.
--- drivers/net/ethernet/mellanox/mlx5/core/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/rdma.c +1 -1
@@ -116,7 +116,7 @@ static int mlx5_rdma_enable_roce_steering(struct mlx5_core_dev *dev)static void mlx5_rdma_del_roce_addr (struct mlx5_core_dev *dev) {mlx5_core_roce_gid_set (dev,0 ,0 ,0 , -NULL ,NULL , false,0 ,0 ); +NULL ,NULL , false,0 ,1 ); }static void mlx5_rdma_make_default_gid (struct mlx5_core_dev *dev,union ib_gid *gid)
Signature · 1 line
2.26.2
PATCH 4/11 net/mlx5e: CT: Use per flow counter when CT flow accounting is enabled
In reply to Saeed MahameedFrom: Oz Shlomo <[email protected]>
Connection counters may be shared for both directions when the counter is used for connection aging purposes. However, if TC flow accounting is enabled then a unique counter is required per direction.
Instantiate a unique counter per direction if the conntrack accounting extension is enabled. Use a shared counter when the connection accounting extension is disabled.
--- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 77 ++++++++++++------- 1 file changed, 49 insertions(+), 28 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +49 -28
@@ -118,16 +118,17 @@ struct mlx5_ct_tuple {u16 zone; }; -struct mlx5_ct_shared_counter { +struct mlx5_ct_counter {struct mlx5_fc *counter;refcount_t refcount; +bool is_shared; };struct mlx5_ct_entry {struct rhash_head node;struct rhash_head tuple_node;struct rhash_head tuple_nat_node; -struct mlx5_ct_shared_counter *shared_counter; +struct mlx5_ct_counter *counter;unsigned long cookie;unsigned long restore_cookie;struct mlx5_ct_tuple tuple;
@@ -394,13 +395,14 @@ mlx5_tc_ct_set_tuple_match(struct mlx5e_priv *priv, struct mlx5_flow_spec *spec, }static void -mlx5_tc_ct_shared_counter_put (struct mlx5_tc_ct_priv *ct_priv,struct mlx5_ct_entry *entry) +mlx5_tc_ct_counter_put (struct mlx5_tc_ct_priv *ct_priv,struct mlx5_ct_entry *entry) { -if (!refcount_dec_and_test (&entry->shared_counter->refcount)) +if (entry->counter->is_shared && + !refcount_dec_and_test (&entry->counter->refcount))return ; -mlx5_fc_destroy (ct_priv->dev, entry->shared_counter->counter); -kfree (entry->shared_counter); +mlx5_fc_destroy (ct_priv->dev, entry->counter->counter); +kfree (entry->counter); } static void
@@ -699,7 +701,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, attr->dest_ft = ct_priv->post_ct; attr->ft = nat ? ct_priv->ct_nat : ct_priv->ct; attr->outer_match_level =MLX5_MATCH_L4 ; - attr->counter = entry->shared_counter->counter; + attr->counter = entry->counter->counter; attr->flags |=MLX5_ESW_ATTR_FLAG_NO_IN_PORT ;mlx5_tc_ct_set_tuple_match (netdev_priv (ct_priv->netdev), spec, flow_rule);
@@ -732,13 +734,34 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,return err; } -static struct mlx5_ct_shared_counter * +static struct mlx5_ct_counter * +mlx5_tc_ct_counter_create (struct mlx5_tc_ct_priv *ct_priv) +{ +struct mlx5_ct_counter *counter; +int ret; + + counter =kzalloc (sizeof (*counter),GFP_KERNEL ); +if (!counter) +return ERR_PTR (-ENOMEM ); + + counter->is_shared = false; + counter->counter =mlx5_fc_create (ct_priv->dev, true); +if (IS_ERR (counter->counter)) { +ct_dbg ("Failed to create counter for ct entry" ); + ret =PTR_ERR (counter->counter); +kfree (counter); +return ERR_PTR (ret); + } + +return counter; +} + +static struct mlx5_ct_counter *mlx5_tc_ct_shared_counter_get (struct mlx5_tc_ct_priv *ct_priv,struct mlx5_ct_entry *entry) {struct mlx5_ct_tuple rev_tuple = entry->tuple; -struct mlx5_ct_shared_counter *shared_counter; -struct mlx5_core_dev *dev = ct_priv->dev; +struct mlx5_ct_counter *shared_counter;struct mlx5_ct_entry *rev_entry;__be16 tmp_port;int ret;
@@ -767,25 +790,20 @@ mlx5_tc_ct_shared_counter_get(struct mlx5_tc_ct_priv *ct_priv, rev_entry =rhashtable_lookup_fast (&ct_priv->ct_tuples_ht, &rev_tuple, tuples_ht_params);if (rev_entry) { -if (refcount_inc_not_zero (&rev_entry->shared_counter->refcount)) { +if (refcount_inc_not_zero (&rev_entry->counter->refcount)) {mutex_unlock (&ct_priv->shared_counter_lock); -return rev_entry->shared_counter; +return rev_entry->counter; } }mutex_unlock (&ct_priv->shared_counter_lock); - shared_counter =kzalloc (sizeof (*shared_counter),GFP_KERNEL ); -if (!shared_counter) -return ERR_PTR (-ENOMEM ); - - shared_counter->counter =mlx5_fc_create (dev, true); -if (IS_ERR (shared_counter->counter)) { -ct_dbg ("Failed to create counter for ct entry" ); - ret =PTR_ERR (shared_counter->counter); -kfree (shared_counter); + shared_counter =mlx5_tc_ct_counter_create (ct_priv); +if (IS_ERR (shared_counter)) { + ret =PTR_ERR (shared_counter);return ERR_PTR (ret); } + shared_counter->is_shared = true;refcount_set (&shared_counter->refcount,1 );return shared_counter; }
@@ -798,10 +816,13 @@ mlx5_tc_ct_entry_add_rules(struct mlx5_tc_ct_priv *ct_priv, {int err; - entry->shared_counter =mlx5_tc_ct_shared_counter_get (ct_priv, entry); -if (IS_ERR (entry->shared_counter)) { - err =PTR_ERR (entry->shared_counter); -ct_dbg ("Failed to create counter for ct entry" ); +if (nf_ct_acct_enabled (dev_net (ct_priv->netdev))) + entry->counter =mlx5_tc_ct_counter_create (ct_priv); +else + entry->counter =mlx5_tc_ct_shared_counter_get (ct_priv, entry); + +if (IS_ERR (entry->counter)) { + err =PTR_ERR (entry->counter);return err; }
@@ -820,7 +841,7 @@ mlx5_tc_ct_entry_add_rules(struct mlx5_tc_ct_priv *ct_priv, err_nat:mlx5_tc_ct_entry_del_rule (ct_priv, entry, false); err_orig: -mlx5_tc_ct_shared_counter_put (ct_priv, entry); +mlx5_tc_ct_counter_put (ct_priv, entry);return err; }
@@ -918,7 +939,7 @@ mlx5_tc_ct_del_ft_entry(struct mlx5_tc_ct_priv *ct_priv,rhashtable_remove_fast (&ct_priv->ct_tuples_ht, &entry->tuple_node, tuples_ht_params);mutex_unlock (&ct_priv->shared_counter_lock); -mlx5_tc_ct_shared_counter_put (ct_priv, entry); +mlx5_tc_ct_counter_put (ct_priv, entry); }
@@ -956,7 +977,7 @@ mlx5_tc_ct_block_flow_offload_stats(struct mlx5_ct_ft *ft,if (!entry)return -ENOENT ; -mlx5_fc_query_cached (entry->shared_counter->counter, &bytes, &packets, &lastuse); +mlx5_fc_query_cached (entry->counter->counter, &bytes, &packets, &lastuse);flow_stats_update (&f->stats, bytes, packets,0 , lastuse,FLOW_ACTION_HW_STATS_DELAYED );
Signature · 1 line
2.26.2
Re: [net 04/11] net/mlx5e: CT: Use per flow counter when CT flow accounting is enabled
Quoted 6 lines · Saeed Mahameed
From: Oz Shlomo <[email protected]>
Connection counters may be shared for both directions when the counter is used for connection aging purposes. However, if TC flow accounting is enabled then a unique counter is required per direction.
Quoted 7 lines
Instantiate a unique counter per direction if the conntrack accounting extension is enabled. Use a shared counter when the connection accounting extension is disabled.
Fixes 1edae2335adf ("net/mlx5e: CT: Use the same counter for both directions")Signed-off-by Oz Shlomo <[email protected]>Reported-by Marcelo Ricardo Leitner <[email protected]>
Thanks.
Quoted 3 lines
Reviewed-by Roi Dayan <[email protected]>Reviewed-by Paul Blakey <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>
Jakub Kicinski
maintainerRe: [net 04/11] net/mlx5e: CT: Use per flow counter when CT flow accounting is enabled
In reply to Saeed Mahameeddrivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, · line 753
Quoted 13 lines · On Thu, 7 Jan 2021 12:28:38 -0800 Saeed Mahameed wrote:
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +13
-0+int ret; + + counter =kzalloc (sizeof (*counter),GFP_KERNEL ); +if (!counter) +return ERR_PTR (-ENOMEM ); + + counter->is_shared = false; + counter->counter =mlx5_fc_create (ct_priv->dev, true); +if (IS_ERR (counter->counter)) { +ct_dbg ("Failed to create counter for ct entry" ); + ret =PTR_ERR (counter->counter); +kfree (counter); +return ERR_PTR (ret);
The err ptr -> ret -> err ptr conversion seems entirely pointless, no?
Re: [net 04/11] net/mlx5e: CT: Use per flow counter when CT flow accounting is enabled
Quoted 17 lines · Jakub Kicinski
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, · line 753
Quoted 13 lines · On Thu, 7 Jan 2021 12:28:38 -0800 Saeed Mahameed wrote:
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +13
-0+int ret; + + counter =kzalloc (sizeof (*counter),GFP_KERNEL ); +if (!counter) +return ERR_PTR (-ENOMEM ); + + counter->is_shared = false; + counter->counter =mlx5_fc_create (ct_priv->dev, true); +if (IS_ERR (counter->counter)) { +ct_dbg ("Failed to create counter for ct entry" ); + ret =PTR_ERR (counter->counter); +kfree (counter); +return ERR_PTR (ret);The err ptr -> ret -> err ptr conversion seems entirely pointless, no?
Indeed, will address this in a net-next patch
Re: [net 04/11] net/mlx5e: CT: Use per flow counter when CT flow accounting is enabled
Quoted 18 lines · Saeed Mahameed
Quoted 17 lines · Jakub Kicinski
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, · line 753
Quoted 13 lines · On Thu, 7 Jan 2021 12:28:38 -0800 Saeed Mahameed wrote:
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +13
-0+int ret; + + counter =kzalloc (sizeof (*counter),GFP_KERNEL ); +if (!counter) +return ERR_PTR (-ENOMEM ); + + counter->is_shared = false; + counter->counter =mlx5_fc_create (ct_priv->dev, true); +if (IS_ERR (counter->counter)) { +ct_dbg ("Failed to create counter for ct entry" ); + ret =PTR_ERR (counter->counter); +kfree (counter); +return ERR_PTR (ret);The err ptr -> ret -> err ptr conversion seems entirely pointless, no?
Quoted 2 lines
Indeed, will address this in a net-next patch
Actually no, because counter is being kfreed so we must return ERR_PTR(ret).
Jakub Kicinski
maintainerRe: [net 04/11] net/mlx5e: CT: Use per flow counter when CT flow accounting is enabled
Quoted 19 lines · On Thu, 07 Jan 2021 20:18:36 -0800 Saeed Mahameed wrote:
Quoted 18 lines · Saeed Mahameed
Quoted 17 lines · Jakub Kicinski
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, · line 753
Quoted 13 lines · On Thu, 7 Jan 2021 12:28:38 -0800 Saeed Mahameed wrote:
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +13
-0+int ret; + + counter =kzalloc (sizeof (*counter),GFP_KERNEL ); +if (!counter) +return ERR_PTR (-ENOMEM ); + + counter->is_shared = false; + counter->counter =mlx5_fc_create (ct_priv->dev, true); +if (IS_ERR (counter->counter)) { +ct_dbg ("Failed to create counter for ct entry" ); + ret =PTR_ERR (counter->counter); +kfree (counter); +return ERR_PTR (ret);The err ptr -> ret -> err ptr conversion seems entirely pointless, no?
Quoted 5 lines
Quoted 2 lines
Indeed, will address this in a net-next patch
Actually no, because counter is being kfreed so we must return
ERR_PTR(ret).
Ah, good point, just the other one then:
+ shared_counter = mlx5_tc_ct_counter_create(ct_priv);
+ if (IS_ERR(shared_counter)) {
+ ret = PTR_ERR(shared_counter);
return ERR_PTR(ret);
}
Re: [net 04/11] net/mlx5e: CT: Use per flow counter when CT flow accounting is enabled
Quoted 30 lines · Jakub Kicinski
Quoted 21 lines · On Thu, 07 Jan 2021 20:18:36 -0800 Saeed Mahameed wrote:
Quoted 20 lines · Saeed Mahameed
Quoted 19 lines · Jakub Kicinski
Quoted 11 lines · On Thu, 7 Jan 2021 12:28:38 -0800 Saeed Mahameed wrote:
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +10
-0+int ret; + + counter =kzalloc (sizeof (*counter),GFP_KERNEL ); +if (!counter) +return ERR_PTR (-ENOMEM ); + + counter->is_shared = false; + counter->counter =mlx5_fc_create (ct_priv->dev, true); +if (IS_ERR (counter->counter)) { + ct_dbg("Failed to create counter for ctentry");
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, · line 753
Quoted 3 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +3
-0+ ret =PTR_ERR (counter->counter); +kfree (counter); +return ERR_PTR (ret);The err ptr -> ret -> err ptr conversion seems entirely pointless,
no?Quoted 5 lines
Quoted 2 lines
Indeed, will address this in a net-next patch
Actually no, because counter is being kfreed so we must return
ERR_PTR(ret).Ah, good point, just the other one then:
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_shared_counter_get(struct mlx5_tc_ct_priv *ct_priv, · line 804
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +3
-0+ shared_counter =mlx5_tc_ct_counter_create (ct_priv); +if (IS_ERR (shared_counter)) { + ret =PTR_ERR (shared_counter);return ERR_PTR (ret); }
Done, will send to net-next once this is back merged.
Thanks.
PATCH 5/11 net/mlx5e: Fix SWP offsets when vlan inserted by driver
In reply to Saeed MahameedFrom: Moshe Shemesh <[email protected]>
In case WQE includes inline header the vlan is inserted by driver even if vlan offload is set. On geneve over vlan interface where software parser is used the SWP offsets should be updated according to the added vlan.
--- drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h | 9 +++++++++ .../net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h | 8 +++++--- drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 9 +++++---- 3 files changed, 19 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +9 -0
@@ -371,6 +371,15 @@ struct mlx5e_swp_spec {u8 tun_l4_proto; }; +static inline void mlx5e_eseg_swp_offsets_add_vlan (struct mlx5_wqe_eth_seg *eseg) +{ +/* SWP offsets are in 2-bytes words */ + eseg->swp_outer_l3_offset +=VLAN_HLEN /2 ; + eseg->swp_outer_l4_offset +=VLAN_HLEN /2 ; + eseg->swp_inner_l3_offset +=VLAN_HLEN /2 ; + eseg->swp_inner_l4_offset +=VLAN_HLEN /2 ; +} +static inline void mlx5e_set_eseg_swp (struct sk_buff *skb,struct mlx5_wqe_eth_seg *eseg,struct mlx5e_swp_spec *swp_spec)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +5 -3
@@ -51,7 +51,7 @@ static inline bool mlx5_geneve_tx_allowed(struct mlx5_core_dev *mdev) }static inline void -mlx5e_tx_tunnel_accel (struct sk_buff *skb,struct mlx5_wqe_eth_seg *eseg) +mlx5e_tx_tunnel_accel (struct sk_buff *skb,struct mlx5_wqe_eth_seg *eseg,u16 ihs) {struct mlx5e_swp_spec swp_spec = {};unsigned int offset =0 ;
@@ -85,6 +85,8 @@ mlx5e_tx_tunnel_accel(struct sk_buff *skb, struct mlx5_wqe_eth_seg *eseg) }mlx5e_set_eseg_swp (skb, eseg, &swp_spec); +if (skb_vlan_tag_present (skb) && ihs) +mlx5e_eseg_swp_offsets_add_vlan (eseg); }#else
@@ -163,7 +165,7 @@ static inline unsigned int mlx5e_accel_tx_ids_len(struct mlx5e_txqsq *sq,static inline bool mlx5e_accel_tx_eseg (struct mlx5e_priv *priv,struct sk_buff *skb, -struct mlx5_wqe_eth_seg *eseg) +struct mlx5_wqe_eth_seg *eseg,u16 ihs) {#ifdef CONFIG_MLX5_EN_IPSEC if (xfrm_offload (skb))
@@ -172,7 +174,7 @@ static inline bool mlx5e_accel_tx_eseg(struct mlx5e_priv *priv,#if IS_ENABLED (CONFIG_GENEVE )if (skb->encapsulation) -mlx5e_tx_tunnel_accel (skb, eseg); +mlx5e_tx_tunnel_accel (skb, eseg, ihs);#endif return true;
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +5 -4
@@ -682,9 +682,9 @@ void mlx5e_tx_mpwqe_ensure_complete(struct mlx5e_txqsq *sq)static bool mlx5e_txwqe_build_eseg (struct mlx5e_priv *priv,struct mlx5e_txqsq *sq,struct sk_buff *skb,struct mlx5e_accel_tx_state *accel, -struct mlx5_wqe_eth_seg *eseg) +struct mlx5_wqe_eth_seg *eseg,u16 ihs) { -if (unlikely (!mlx5e_accel_tx_eseg (priv, skb, eseg))) +if (unlikely (!mlx5e_accel_tx_eseg (priv, skb, eseg, ihs)))return false;mlx5e_txwqe_build_eseg_csum (sq, skb, accel, eseg);
@@ -714,7 +714,8 @@ netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev)if (mlx5e_tx_skb_supports_mpwqe (skb, &attr)) {struct mlx5_wqe_eth_seg eseg = {}; -if (unlikely (!mlx5e_txwqe_build_eseg (priv, sq, skb, &accel, &eseg))) +if (unlikely (!mlx5e_txwqe_build_eseg (priv, sq, skb, &accel, &eseg, + attr.ihs)))return NETDEV_TX_OK ;mlx5e_sq_xmit_mpwqe (sq, skb, &eseg,netdev_xmit_more ());
@@ -731,7 +732,7 @@ netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev)/* May update the WQE, but may not post other WQEs. */ mlx5e_accel_tx_finish (sq, wqe, &accel, (struct mlx5_wqe_inline_seg *)(wqe->data + wqe_attr.ds_cnt_inl)); -if (unlikely (!mlx5e_txwqe_build_eseg (priv, sq, skb, &accel, &wqe->eth))) +if (unlikely (!mlx5e_txwqe_build_eseg (priv, sq, skb, &accel, &wqe->eth, attr.ihs)))return NETDEV_TX_OK ;mlx5e_sq_xmit_wqe (sq, skb, &attr, &wqe_attr, wqe, pi,netdev_xmit_more ());
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerRe: [net 05/11] net/mlx5e: Fix SWP offsets when vlan inserted by driver
drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h mlx5e_tx_tunnel_accel(struct sk_buff *skb, struct mlx5_wqe_eth_seg *eseg) · line 88
Quoted 1 line · On Thu, 7 Jan 2021 12:28:39 -0800 Saeed Mahameed wrote:
drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +1
-0+if (skb_vlan_tag_present (skb) && ihs)
Double space.
Re: [net 05/11] net/mlx5e: Fix SWP offsets when vlan inserted by driver
Quoted 4 lines · Jakub Kicinski
drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h mlx5e_tx_tunnel_accel(struct sk_buff *skb, struct mlx5_wqe_eth_seg *eseg) · line 88
Quoted 1 line · On Thu, 7 Jan 2021 12:28:39 -0800 Saeed Mahameed wrote:
drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +1
-0+if (skb_vlan_tag_present (skb) && ihs)Double space.
Will address this in a net-next patch.
thanks!
PATCH 6/11 net/mlx5: E-Switch, fix changing vf VLANID
In reply to Saeed MahameedFrom: Alaa Hleihel <[email protected]>
Adding vf VLANID for the first time, or after having cleared previously defined VLANID works fine, however, attempting to change an existing vf VLANID clears the rules on the firmware, but does not add new rules for the new vf VLANID.
Fix this by changing the logic in function esw_acl_egress_lgcy_setup() so that it will always configure egress rules.
--- .../mellanox/mlx5/core/esw/acl/egress_lgcy.c | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/esw/acl/egress_lgcy.c +13 -14
@@ -95,22 +95,21 @@ int esw_acl_egress_lgcy_setup(struct mlx5_eswitch *esw,return 0 ; } -if (!IS_ERR_OR_NULL (vport->egress.acl)) -return 0 ; - - vport->egress.acl =esw_acl_table_create (esw, vport->vport, -MLX5_FLOW_NAMESPACE_ESW_EGRESS , - table_size); -if (IS_ERR (vport->egress.acl)) { - err =PTR_ERR (vport->egress.acl); - vport->egress.acl =NULL ; - goto out; +if (!vport->egress.acl) { + vport->egress.acl =esw_acl_table_create (esw, vport->vport, +MLX5_FLOW_NAMESPACE_ESW_EGRESS , + table_size); +if (IS_ERR (vport->egress.acl)) { + err =PTR_ERR (vport->egress.acl); + vport->egress.acl =NULL ; + goto out; + } + + err =esw_acl_egress_lgcy_groups_create (esw, vport); +if (err) + goto out; } - err =esw_acl_egress_lgcy_groups_create (esw, vport); -if (err) - goto out; -esw_debug (esw->dev,"vport[%d] configure egress rules, vlan(%d) qos(%d)\n" , vport->vport, vport->info.vlan, vport->info.qos);
Signature · 1 line
2.26.2
PATCH 7/11 net/mlx5e: In skb build skip setting mark in switchdev mode
In reply to Saeed MahameedFrom: Maor Dickman <[email protected]>
sop_drop_qpn field in the cqe is used by two features, in SWITCHDEV mode to restore the chain id in case of a miss and in LEGACY mode to support skbedit mark action. In build RX skb, the skb mark field is set regardless of the configured mode which cause a corruption of the mark field in case of switchdev mode.
Fix by overriding the mark value back to 0 in the representor tc update skb flow.
--- drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +5 -0
@@ -626,6 +626,11 @@ bool mlx5e_rep_tc_update_skb(struct mlx5_cqe64 *cqe,if (!reg_c0)return true; +/* If reg_c0 is not equal to the default flow tag then skb->mark +* is not supported and must be reset back to 0. +*/ + skb->mark =0 ; + priv =netdev_priv (skb->dev); esw = priv->mdev->priv.eswitch;
Signature · 1 line
2.26.2
PATCH 8/11 net/mlx5e: ethtool, Fix restriction of autoneg with 56G
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Prior to this patch, configuring speed to 50G with autoneg off over devices supporting 50G per lane failed.
Support for 50G per lane introduced a new set of link-modes, on which driver always performed a speed validation as if only legacy link-modes were configured. Fix driver speed validation to force setting autoneg over 56G only if in legacy link-mode.
--- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +18 -6
@@ -1010,6 +1010,22 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev,return mlx5e_ethtool_get_link_ksettings (priv, link_ksettings); } +static int mlx5e_speed_validate (struct net_device *netdev,bool ext, +const unsigned long link_modes,u8 autoneg) +{ +/* Extended link-mode has no speed limitations. */ +if (ext) +return 0 ; + +if ((link_modes &MLX5E_PROT_MASK (MLX5E_56GBASE_R4 )) && + autoneg !=AUTONEG_ENABLE ) { +netdev_err (netdev,"%s: 56G link speed requires autoneg enabled\n" , + __func__); +return -EINVAL ; + } +return 0 ; +} +static u32 mlx5e_ethtool2ptys_adver_link (const unsigned long *link_modes) {u32 i, ptys_modes =0 ;
@@ -1103,13 +1119,9 @@ int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv, link_modes = autoneg ==AUTONEG_ENABLE ?ethtool2ptys_adver_func (adver) :mlx5e_port_speed2linkmodes (mdev, speed, !ext); -if ((link_modes &MLX5E_PROT_MASK (MLX5E_56GBASE_R4 )) && - autoneg !=AUTONEG_ENABLE ) { -netdev_err (priv->netdev,"%s: 56G link speed requires autoneg enabled\n" , - __func__); - err = -EINVAL ; + err =mlx5e_speed_validate (priv->netdev, ext, link_modes, autoneg); +if (err) goto out; - } link_modes = link_modes & eproto.cap;if (!link_modes) {
Signature · 1 line
2.26.2
PATCH 9/11 net/mlx5: Release devlink object if adev fails
In reply to Saeed MahameedFrom: Leon Romanovsky <[email protected]>
Add missed freeing previously allocated devlink object.
--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +5 -2
@@ -1368,8 +1368,10 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *id) MLX5_COREDEV_VF :MLX5_COREDEV_PF ; dev->priv.adev_idx =mlx5_adev_idx_alloc (); -if (dev->priv.adev_idx <0 ) -return dev->priv.adev_idx; +if (dev->priv.adev_idx <0 ) { + err = dev->priv.adev_idx; + goto adev_init_err; + } err =mlx5_mdev_init (dev, prof_sel);if (err)
@@ -1403,6 +1405,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *id)mlx5_mdev_uninit (dev); mdev_init_err:mlx5_adev_idx_free (dev->priv.adev_idx); +adev_init_err:mlx5_devlink_free (devlink);return err;
Signature · 1 line
2.26.2
PATCH 10/11 net/mlx5e: Fix two double free cases
In reply to Saeed MahameedFrom: Dinghao Liu <[email protected]>
mlx5e_create_ttc_table_groups() frees ft->g on failure of kvzalloc(), but such failure will be caught by its caller in mlx5e_create_ttc_table() and ft->g will be freed again in mlx5e_destroy_flow_table(). The same issue also occurs in mlx5e_create_ttc_table_groups(). Set ft->g to NULL after kfree() to avoid double free.
--- drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +2 -0
@@ -942,6 +942,7 @@ static int mlx5e_create_ttc_table_groups(struct mlx5e_ttc_table *ttc, in =kvzalloc (inlen,GFP_KERNEL );if (!in) {kfree (ft->g); + ft->g =NULL ;return -ENOMEM ; }
@@ -1087,6 +1088,7 @@ static int mlx5e_create_inner_ttc_table_groups(struct mlx5e_ttc_table *ttc) in =kvzalloc (inlen,GFP_KERNEL );if (!in) {kfree (ft->g); + ft->g =NULL ;return -ENOMEM ; }
Signature · 1 line
2.26.2
PATCH 11/11 net/mlx5e: Fix memleak in mlx5e_create_l2_table_groups
In reply to Saeed MahameedFrom: Dinghao Liu <[email protected]>
When mlx5_create_flow_group() fails, ft->g should be freed just like when kvzalloc() fails. The caller of mlx5e_create_l2_table_groups() does not catch this issue on failure, which leads to memleak.
--- drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +1 -0
@@ -1392,6 +1392,7 @@ static int mlx5e_create_l2_table_groups(struct mlx5e_l2_table *l2_table) ft->g[ft->num_groups] =NULL ;mlx5e_destroy_groups (ft);kvfree (in); +kfree (ft->g);return err; }
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerQuoted 6 lines · On Thu, 7 Jan 2021 12:28:34 -0800 Saeed Mahameed wrote:
From: Saeed Mahameed <[email protected]>
Hi Dave, Jakub,
This series provides some fixes to mlx5 driver. Please pull and let me know if there is any problem.
Pulled, thanks!