netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [pull request][net 00/16] mlx5 fixes 2023-01-09
@ 2023-01-10  6:11 Saeed Mahameed
  2023-01-10  6:11 ` [net 01/16] net/mlx5: DR, Fix 'stack frame size exceeds limit' error in dr_rule Saeed Mahameed
                   ` (16 more replies)
  0 siblings, 17 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan

From: Saeed Mahameed <saeedm@nvidia.com>

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 2ea26b4de6f42b74a5f1701de41efa6bc9f12666:

  Revert "r8169: disable detection of chip version 36" (2023-01-09 20:40:28 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2023-01-09

for you to fetch changes up to 9828994ac492e8e7de47fe66097b7e665328f348:

  net/mlx5e: Fix macsec possible null dereference when updating MAC security entity (SecY) (2023-01-09 22:08:37 -0800)

----------------------------------------------------------------
mlx5-fixes-2023-01-09

----------------------------------------------------------------
Ariel Levkovich (2):
      net/mlx5: check attr pointer validity before dereferencing it
      net/mlx5e: TC, Keep mod hdr actions after mod hdr alloc

Aya Levin (1):
      net/mlx5e: Fix memory leak on updating vport counters

Dragos Tatulea (3):
      net/mlx5e: IPoIB, Block queue count configuration when sub interfaces are present
      net/mlx5e: IPoIB, Block PKEY interfaces with less rx queues than parent
      net/mlx5e: IPoIB, Fix child PKEY interface stats on rx path

Emeel Hakim (2):
      net/mlx5e: Fix macsec ssci attribute handling in offload path
      net/mlx5e: Fix macsec possible null dereference when updating MAC security entity (SecY)

Gavin Li (1):
      net/mlx5e: Don't support encap rules with gbp option

Moshe Shemesh (1):
      net/mlx5: Fix command stats access after free

Oz Shlomo (2):
      net/mlx5e: TC, ignore match level for post meter rules
      net/mlx5e: TC, Restore pkt rate policing support

Rahul Rameshbabu (1):
      net/mlx5: Fix ptp max frequency adjustment range

Roy Novich (1):
      net/mlx5e: Verify dev is present for fix features ndo

Shay Drory (1):
      net/mlx5: E-switch, Coverity: overlapping copy

Yevgeny Kliteynik (1):
      net/mlx5: DR, Fix 'stack frame size exceeds limit' error in dr_rule

 drivers/net/ethernet/mellanox/mlx5/core/cmd.c      | 13 ++------
 .../ethernet/mellanox/mlx5/core/en/tc/act/police.c |  6 ----
 .../ethernet/mellanox/mlx5/core/en/tc/post_meter.c |  1 +
 .../ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c  |  2 ++
 .../ethernet/mellanox/mlx5/core/en_accel/macsec.c  | 19 +++++------
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |  3 ++
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c   |  3 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c    |  2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c    |  5 +--
 .../ethernet/mellanox/mlx5/core/eswitch_offloads.c |  6 +---
 .../ethernet/mellanox/mlx5/core/ipoib/ethtool.c    | 16 +++++++--
 .../net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c  | 38 ++++++++++++++++++++++
 .../net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h  |  6 ++++
 .../ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c | 18 +++++++---
 .../net/ethernet/mellanox/mlx5/core/lib/clock.c    |  2 +-
 .../ethernet/mellanox/mlx5/core/steering/dr_rule.c | 11 ++++---
 include/linux/mlx5/driver.h                        |  2 +-
 17 files changed, 104 insertions(+), 49 deletions(-)

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [net 01/16] net/mlx5: DR, Fix 'stack frame size exceeds limit' error in dr_rule
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-11 13:00   ` patchwork-bot+netdevbpf
  2023-01-10  6:11 ` [net 02/16] net/mlx5: check attr pointer validity before dereferencing it Saeed Mahameed
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Yevgeny Kliteynik,
	kernel test robot

From: Yevgeny Kliteynik <kliteyn@nvidia.com>

If the kernel configuration asks the compiler to check frame limit of 1K,
dr_rule_create_rule_nic exceed this limit:
    "stack frame size (1184) exceeds limit (1024)"

Fixing this issue by checking configured frame limit and using the
optimization STE array only for cases with the usual 2K (or larger)
stack size warning.

Fixes: b9b81e1e9382 ("net/mlx5: DR, For short chains of STEs, avoid allocating ste_arr dynamically")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../ethernet/mellanox/mlx5/core/steering/dr_rule.c    | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c
index 74cbe53ee9db..b851141e03de 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c
@@ -3,7 +3,12 @@
 
 #include "dr_types.h"
 
+#if defined(CONFIG_FRAME_WARN) && (CONFIG_FRAME_WARN < 2048)
+/* don't try to optimize STE allocation if the stack is too constaraining */
+#define DR_RULE_MAX_STES_OPTIMIZED 0
+#else
 #define DR_RULE_MAX_STES_OPTIMIZED 5
+#endif
 #define DR_RULE_MAX_STE_CHAIN_OPTIMIZED (DR_RULE_MAX_STES_OPTIMIZED + DR_ACTION_MAX_STES)
 
 static int dr_rule_append_to_miss_list(struct mlx5dr_domain *dmn,
@@ -1218,10 +1223,7 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
 
 	mlx5dr_domain_nic_unlock(nic_dmn);
 
-	if (unlikely(!hw_ste_arr_is_opt))
-		kfree(hw_ste_arr);
-
-	return 0;
+	goto out;
 
 free_rule:
 	dr_rule_clean_rule_members(rule, nic_rule);
@@ -1238,6 +1240,7 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
 free_hw_ste:
 	mlx5dr_domain_nic_unlock(nic_dmn);
 
+out:
 	if (unlikely(!hw_ste_arr_is_opt))
 		kfree(hw_ste_arr);
 
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 02/16] net/mlx5: check attr pointer validity before dereferencing it
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
  2023-01-10  6:11 ` [net 01/16] net/mlx5: DR, Fix 'stack frame size exceeds limit' error in dr_rule Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-10  6:11 ` [net 03/16] net/mlx5e: TC, Keep mod hdr actions after mod hdr alloc Saeed Mahameed
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Ariel Levkovich,
	kernel test robot, Dan Carpenter

From: Ariel Levkovich <lariel@nvidia.com>

Fix attr pointer validity checks after it was already
dereferenced.

Fixes: cb0d54cbf948 ("net/mlx5e: Fix wrong source vport matching on tunnel rule")
Signed-off-by: Ariel Levkovich <lariel@nvidia.com>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index e455b215c708..75b77dd2392b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -143,7 +143,7 @@ mlx5_eswitch_set_rule_source_port(struct mlx5_eswitch *esw,
 		if (mlx5_esw_indir_table_decap_vport(attr))
 			vport = mlx5_esw_indir_table_decap_vport(attr);
 
-		if (attr && !attr->chain && esw_attr->int_port)
+		if (!attr->chain && esw_attr && esw_attr->int_port)
 			metadata =
 				mlx5e_tc_int_port_get_metadata_for_match(esw_attr->int_port);
 		else
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 03/16] net/mlx5e: TC, Keep mod hdr actions after mod hdr alloc
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
  2023-01-10  6:11 ` [net 01/16] net/mlx5: DR, Fix 'stack frame size exceeds limit' error in dr_rule Saeed Mahameed
  2023-01-10  6:11 ` [net 02/16] net/mlx5: check attr pointer validity before dereferencing it Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-10  6:11 ` [net 04/16] net/mlx5: Fix command stats access after free Saeed Mahameed
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Ariel Levkovich

From: Ariel Levkovich <lariel@nvidia.com>

When offloading TC NIC rule which has mod_hdr action, the
mod_hdr actions list is freed upon mod_hdr allocation.

In the new format of handling multi table actions and CT in
particular, the mod_hdr actions list is still relevant when
setting the pre and post rules and therefore, freeing the list
may cause adding rules which don't set the FTE_ID.

Therefore, the mod_hdr actions list needs to be kept for the
pre/post flows as well and should be left for these handler to
be freed.

Fixes: 8300f225268b ("net/mlx5e: Create new flow attr for multi table actions")
Signed-off-by: Ariel Levkovich <lariel@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 9af2aa2922f5..dbadaf166487 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1301,7 +1301,6 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
 
 	if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) {
 		err = mlx5e_attach_mod_hdr(priv, flow, parse_attr);
-		mlx5e_mod_hdr_dealloc(&parse_attr->mod_hdr_acts);
 		if (err)
 			return err;
 	}
@@ -1359,8 +1358,10 @@ static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,
 	}
 	mutex_unlock(&tc->t_lock);
 
-	if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
+	if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) {
+		mlx5e_mod_hdr_dealloc(&attr->parse_attr->mod_hdr_acts);
 		mlx5e_detach_mod_hdr(priv, flow);
+	}
 
 	if (attr->action & MLX5_FLOW_CONTEXT_ACTION_COUNT)
 		mlx5_fc_destroy(priv->mdev, attr->counter);
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 04/16] net/mlx5: Fix command stats access after free
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
                   ` (2 preceding siblings ...)
  2023-01-10  6:11 ` [net 03/16] net/mlx5e: TC, Keep mod hdr actions after mod hdr alloc Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-10  6:11 ` [net 05/16] net/mlx5e: Verify dev is present for fix features ndo Saeed Mahameed
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Moshe Shemesh, Shay Drory

From: Moshe Shemesh <moshe@nvidia.com>

Command may fail while driver is reloading and can't accept FW commands
till command interface is reinitialized. Such command failure is being
logged to command stats. This results in NULL pointer access as command
stats structure is being freed and reallocated during mlx5 devlink
reload (see kernel log below).

Fix it by making command stats statically allocated on driver probe.

Kernel log:
[ 2394.808802] BUG: unable to handle kernel paging request at 000000000002a9c0
[ 2394.810610] PGD 0 P4D 0
[ 2394.811811] Oops: 0002 [#1] SMP NOPTI
...
[ 2394.815482] RIP: 0010:native_queued_spin_lock_slowpath+0x183/0x1d0
...
[ 2394.829505] Call Trace:
[ 2394.830667]  _raw_spin_lock_irq+0x23/0x26
[ 2394.831858]  cmd_status_err+0x55/0x110 [mlx5_core]
[ 2394.833020]  mlx5_access_reg+0xe7/0x150 [mlx5_core]
[ 2394.834175]  mlx5_query_port_ptys+0x78/0xa0 [mlx5_core]
[ 2394.835337]  mlx5e_ethtool_get_link_ksettings+0x74/0x590 [mlx5_core]
[ 2394.836454]  ? kmem_cache_alloc_trace+0x140/0x1c0
[ 2394.837562]  __rh_call_get_link_ksettings+0x33/0x100
[ 2394.838663]  ? __rtnl_unlock+0x25/0x50
[ 2394.839755]  __ethtool_get_link_ksettings+0x72/0x150
[ 2394.840862]  duplex_show+0x6e/0xc0
[ 2394.841963]  dev_attr_show+0x1c/0x40
[ 2394.843048]  sysfs_kf_seq_show+0x9b/0x100
[ 2394.844123]  seq_read+0x153/0x410
[ 2394.845187]  vfs_read+0x91/0x140
[ 2394.846226]  ksys_read+0x4f/0xb0
[ 2394.847234]  do_syscall_64+0x5b/0x1a0
[ 2394.848228]  entry_SYSCALL_64_after_hwframe+0x65/0xca

Fixes: 34f46ae0d4b3 ("net/mlx5: Add command failures data to debugfs")
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Shay Drory <shayd@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 13 ++-----------
 include/linux/mlx5/driver.h                   |  2 +-
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index d3ca745d107d..c837103a9ee3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -2176,15 +2176,9 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
 		return -EINVAL;
 	}
 
-	cmd->stats = kvcalloc(MLX5_CMD_OP_MAX, sizeof(*cmd->stats), GFP_KERNEL);
-	if (!cmd->stats)
-		return -ENOMEM;
-
 	cmd->pool = dma_pool_create("mlx5_cmd", mlx5_core_dma_dev(dev), size, align, 0);
-	if (!cmd->pool) {
-		err = -ENOMEM;
-		goto dma_pool_err;
-	}
+	if (!cmd->pool)
+		return -ENOMEM;
 
 	err = alloc_cmd_page(dev, cmd);
 	if (err)
@@ -2268,8 +2262,6 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
 
 err_free_pool:
 	dma_pool_destroy(cmd->pool);
-dma_pool_err:
-	kvfree(cmd->stats);
 	return err;
 }
 
@@ -2282,7 +2274,6 @@ void mlx5_cmd_cleanup(struct mlx5_core_dev *dev)
 	destroy_msg_cache(dev);
 	free_cmd_page(dev, cmd);
 	dma_pool_destroy(cmd->pool);
-	kvfree(cmd->stats);
 }
 
 void mlx5_cmd_set_state(struct mlx5_core_dev *dev,
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index d476255c9a3f..76ef2e4fde38 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -315,7 +315,7 @@ struct mlx5_cmd {
 	struct mlx5_cmd_debug dbg;
 	struct cmd_msg_cache cache[MLX5_NUM_COMMAND_CACHES];
 	int checksum_disabled;
-	struct mlx5_cmd_stats *stats;
+	struct mlx5_cmd_stats stats[MLX5_CMD_OP_MAX];
 };
 
 struct mlx5_cmd_mailbox {
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 05/16] net/mlx5e: Verify dev is present for fix features ndo
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
                   ` (3 preceding siblings ...)
  2023-01-10  6:11 ` [net 04/16] net/mlx5: Fix command stats access after free Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-10  6:11 ` [net 06/16] net/mlx5e: IPoIB, Block queue count configuration when sub interfaces are present Saeed Mahameed
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Roy Novich, Roi Dayan

From: Roy Novich <royno@nvidia.com>

The native NIC port net device instance is being used as Uplink
representor.  While changing profiles private resources are not
available, fix features ndo does not check if the netdev is present.
Add driver protection to verify private resources are ready.

Fixes: 7a9fb35e8c3a ("net/mlx5e: Do not reload ethernet ports when changing eswitch mode")
Signed-off-by: Roy Novich <royno@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index cff5f2e29e1e..abcc614b6191 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -4084,6 +4084,9 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev,
 	struct mlx5e_vlan_table *vlan;
 	struct mlx5e_params *params;
 
+	if (!netif_device_present(netdev))
+		return features;
+
 	vlan = mlx5e_fs_get_vlan(priv->fs);
 	mutex_lock(&priv->state_lock);
 	params = &priv->channels.params;
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 06/16] net/mlx5e: IPoIB, Block queue count configuration when sub interfaces are present
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
                   ` (4 preceding siblings ...)
  2023-01-10  6:11 ` [net 05/16] net/mlx5e: Verify dev is present for fix features ndo Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-10  6:11 ` [net 07/16] net/mlx5e: IPoIB, Block PKEY interfaces with less rx queues than parent Saeed Mahameed
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Dragos Tatulea

From: Dragos Tatulea <dtatulea@nvidia.com>

PKEY sub interfaces share the receive queues with the parent interface.
While setting the sub interface queue count is not supported, it is
currently possible to change the number of queues of the parent interface.
Thus we can end up with inconsistent queue sizes between the parent and its
sub interfaces.

This change disallows setting the queue count on the parent interface when
sub interfaces are present.

This is achieved by introducing an explicit reference to the parent netdev
in the mlx5i_priv of the child interface. An additional counter is also
required on the parent side to detect when sub interfaces are attached and
for proper cleanup.

The rtnl lock is taken during the ethtool op and the sub interface
ndo_init/uninit ops. There is no race here around counting the sub
interfaces, reading the sub interfaces and setting the number of
channels. The ASSERT_RTNL was added to document that.

Fixes: be98737a4faa ("net/mlx5e: Use dynamic per-channel allocations in stats")
Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../mellanox/mlx5/core/ipoib/ethtool.c        | 16 +++++++-
 .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 38 +++++++++++++++++++
 .../ethernet/mellanox/mlx5/core/ipoib/ipoib.h |  6 +++
 .../mellanox/mlx5/core/ipoib/ipoib_vlan.c     |  9 ++---
 4 files changed, 62 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c
index c247cca154e9..eff92dc0927c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c
@@ -90,9 +90,21 @@ static void mlx5i_get_ringparam(struct net_device *dev,
 static int mlx5i_set_channels(struct net_device *dev,
 			      struct ethtool_channels *ch)
 {
-	struct mlx5e_priv *priv = mlx5i_epriv(dev);
+	struct mlx5i_priv *ipriv = netdev_priv(dev);
+	struct mlx5e_priv *epriv = mlx5i_epriv(dev);
+
+	/* rtnl lock protects from race between this ethtool op and sub
+	 * interface ndo_init/uninit.
+	 */
+	ASSERT_RTNL();
+	if (ipriv->num_sub_interfaces > 0) {
+		mlx5_core_warn(epriv->mdev,
+			       "can't change number of channels for interfaces with sub interfaces (%u)\n",
+			       ipriv->num_sub_interfaces);
+		return -EINVAL;
+	}
 
-	return mlx5e_ethtool_set_channels(priv, ch);
+	return mlx5e_ethtool_set_channels(epriv, ch);
 }
 
 static void mlx5i_get_channels(struct net_device *dev,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
index 2c73c8445e63..911cf4d23964 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
@@ -160,6 +160,44 @@ void mlx5i_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
 	stats->tx_dropped = sstats->tx_queue_dropped;
 }
 
+struct net_device *mlx5i_parent_get(struct net_device *netdev)
+{
+	struct mlx5e_priv *priv = mlx5i_epriv(netdev);
+	struct mlx5i_priv *ipriv, *parent_ipriv;
+	struct net_device *parent_dev;
+	int parent_ifindex;
+
+	ipriv = priv->ppriv;
+
+	parent_ifindex = netdev->netdev_ops->ndo_get_iflink(netdev);
+	parent_dev = dev_get_by_index(dev_net(netdev), parent_ifindex);
+	if (!parent_dev)
+		return NULL;
+
+	parent_ipriv = netdev_priv(parent_dev);
+
+	ASSERT_RTNL();
+	parent_ipriv->num_sub_interfaces++;
+
+	ipriv->parent_dev = parent_dev;
+
+	return parent_dev;
+}
+
+void mlx5i_parent_put(struct net_device *netdev)
+{
+	struct mlx5e_priv *priv = mlx5i_epriv(netdev);
+	struct mlx5i_priv *ipriv, *parent_ipriv;
+
+	ipriv = priv->ppriv;
+	parent_ipriv = netdev_priv(ipriv->parent_dev);
+
+	ASSERT_RTNL();
+	parent_ipriv->num_sub_interfaces--;
+
+	dev_put(ipriv->parent_dev);
+}
+
 int mlx5i_init_underlay_qp(struct mlx5e_priv *priv)
 {
 	struct mlx5_core_dev *mdev = priv->mdev;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
index 99d46fda9f82..f3f2af972020 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
@@ -54,9 +54,11 @@ struct mlx5i_priv {
 	struct rdma_netdev rn; /* keep this first */
 	u32 qpn;
 	bool   sub_interface;
+	u32    num_sub_interfaces;
 	u32    qkey;
 	u16    pkey_index;
 	struct mlx5i_pkey_qpn_ht *qpn_htbl;
+	struct net_device *parent_dev;
 	char  *mlx5e_priv[];
 };
 
@@ -117,5 +119,9 @@ void mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
 		   struct mlx5_av *av, u32 dqpn, u32 dqkey, bool xmit_more);
 void mlx5i_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats);
 
+/* Reference management for child to parent interfaces. */
+struct net_device *mlx5i_parent_get(struct net_device *netdev);
+void mlx5i_parent_put(struct net_device *netdev);
+
 #endif /* CONFIG_MLX5_CORE_IPOIB */
 #endif /* __MLX5E_IPOB_H__ */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
index 4d9c9e49645c..28795fb6bccc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
@@ -158,21 +158,19 @@ static int mlx5i_pkey_dev_init(struct net_device *dev)
 	struct mlx5e_priv *priv = mlx5i_epriv(dev);
 	struct mlx5i_priv *ipriv, *parent_ipriv;
 	struct net_device *parent_dev;
-	int parent_ifindex;
 
 	ipriv = priv->ppriv;
 
-	/* Get QPN to netdevice hash table from parent */
-	parent_ifindex = dev->netdev_ops->ndo_get_iflink(dev);
-	parent_dev = dev_get_by_index(dev_net(dev), parent_ifindex);
+	/* Link to parent */
+	parent_dev = mlx5i_parent_get(dev);
 	if (!parent_dev) {
 		mlx5_core_warn(priv->mdev, "failed to get parent device\n");
 		return -EINVAL;
 	}
 
+	/* Get QPN to netdevice hash table from parent */
 	parent_ipriv = netdev_priv(parent_dev);
 	ipriv->qpn_htbl = parent_ipriv->qpn_htbl;
-	dev_put(parent_dev);
 
 	return mlx5i_dev_init(dev);
 }
@@ -184,6 +182,7 @@ static int mlx5i_pkey_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 
 static void mlx5i_pkey_dev_cleanup(struct net_device *netdev)
 {
+	mlx5i_parent_put(netdev);
 	return mlx5i_dev_cleanup(netdev);
 }
 
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 07/16] net/mlx5e: IPoIB, Block PKEY interfaces with less rx queues than parent
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
                   ` (5 preceding siblings ...)
  2023-01-10  6:11 ` [net 06/16] net/mlx5e: IPoIB, Block queue count configuration when sub interfaces are present Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-10  6:11 ` [net 08/16] net/mlx5e: IPoIB, Fix child PKEY interface stats on rx path Saeed Mahameed
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Dragos Tatulea

From: Dragos Tatulea <dtatulea@nvidia.com>

A user is able to configure an arbitrary number of rx queues when
creating an interface via netlink. This doesn't work for child PKEY
interfaces because the child interface uses the parent receive channels.

Although the child shares the parent's receive channels, the number of
rx queues is important for the channel_stats array: the parent's rx
channel index is used to access the child's channel_stats. So the array
has to be at least as large as the parent's rx queue size for the
counting to work correctly and to prevent out of bound accesses.

This patch checks for the mentioned scenario and returns an error when
trying to create the interface. The error is propagated to the user.

Fixes: be98737a4faa ("net/mlx5e: Use dynamic per-channel allocations in stats")
Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c   | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
index 28795fb6bccc..03e681297937 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
@@ -168,6 +168,15 @@ static int mlx5i_pkey_dev_init(struct net_device *dev)
 		return -EINVAL;
 	}
 
+	if (dev->num_rx_queues < parent_dev->real_num_rx_queues) {
+		mlx5_core_warn(priv->mdev,
+			       "failed to create child device with rx queues [%d] less than parent's [%d]\n",
+			       dev->num_rx_queues,
+			       parent_dev->real_num_rx_queues);
+		mlx5i_parent_put(dev);
+		return -EINVAL;
+	}
+
 	/* Get QPN to netdevice hash table from parent */
 	parent_ipriv = netdev_priv(parent_dev);
 	ipriv->qpn_htbl = parent_ipriv->qpn_htbl;
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 08/16] net/mlx5e: IPoIB, Fix child PKEY interface stats on rx path
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
                   ` (6 preceding siblings ...)
  2023-01-10  6:11 ` [net 07/16] net/mlx5e: IPoIB, Block PKEY interfaces with less rx queues than parent Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-10  6:11 ` [net 09/16] net/mlx5e: TC, ignore match level for post meter rules Saeed Mahameed
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Dragos Tatulea

From: Dragos Tatulea <dtatulea@nvidia.com>

The current code always does the accounting using the
stats from the parent interface (linked in the rq). This
doesn't work when there are child interfaces configured.

Fix this behavior by always using the stats from the child
interface priv. This will also work for parent only
interfaces: the child (netdev) and parent netdev (rq->netdev)
will point to the same thing.

Fixes: be98737a4faa ("net/mlx5e: Use dynamic per-channel allocations in stats")
Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index c8820ab22169..3df455f6b168 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -2419,7 +2419,7 @@ static inline void mlx5i_complete_rx_cqe(struct mlx5e_rq *rq,
 
 	priv = mlx5i_epriv(netdev);
 	tstamp = &priv->tstamp;
-	stats = rq->stats;
+	stats = &priv->channel_stats[rq->ix]->rq;
 
 	flags_rqpn = be32_to_cpu(cqe->flags_rqpn);
 	g = (flags_rqpn >> 28) & 3;
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 09/16] net/mlx5e: TC, ignore match level for post meter rules
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
                   ` (7 preceding siblings ...)
  2023-01-10  6:11 ` [net 08/16] net/mlx5e: IPoIB, Fix child PKEY interface stats on rx path Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-10  6:11 ` [net 10/16] net/mlx5e: TC, Restore pkt rate policing support Saeed Mahameed
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Oz Shlomo, Roi Dayan

From: Oz Shlomo <ozsh@nvidia.com>

The post meter table only matches on reg_c5. As such, the inner/outer
match levels are irrelevant for the match critieria. The cited patch only
sets the outer criteria to none, thus setting the inner match level for
encapsulated packets. This caused rules with police action on tunnel
devices to not find an existing flow group for the match criteria, thus
failing to offload the rule.

Set both the inner and outer match levels to none for post_meter rules.

Fixes: 0d8c38d44f33 ("net/mlx5e: TC, init post meter rules with branching attributes")
Signed-off-by: Oz Shlomo <ozsh@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_meter.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_meter.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_meter.c
index 8d7d761482d2..50b60fd00946 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_meter.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_meter.c
@@ -127,6 +127,7 @@ mlx5e_post_meter_add_rule(struct mlx5e_priv *priv,
 		attr->counter = act_counter;
 
 	attr->flags |= MLX5_ATTR_FLAG_NO_IN_PORT;
+	attr->inner_match_level = MLX5_MATCH_NONE;
 	attr->outer_match_level = MLX5_MATCH_NONE;
 	attr->chain = 0;
 	attr->prio = 0;
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 10/16] net/mlx5e: TC, Restore pkt rate policing support
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
                   ` (8 preceding siblings ...)
  2023-01-10  6:11 ` [net 09/16] net/mlx5e: TC, ignore match level for post meter rules Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-10  6:11 ` [net 11/16] net/mlx5e: Fix memory leak on updating vport counters Saeed Mahameed
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Oz Shlomo, Roi Dayan

From: Oz Shlomo <ozsh@nvidia.com>

The offending commit removed the support for all packet rate metering.
Restore the pkt rate metering support by removing the restriction.

Fixes: 3603f26633e7 ("net/mlx5e: TC, allow meter jump control action")
Signed-off-by: Oz Shlomo <ozsh@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
index 512d43148922..c4378afdec09 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
@@ -34,12 +34,6 @@ static int police_act_validate(const struct flow_action_entry *act,
 		return -EOPNOTSUPP;
 	}
 
-	if (act->police.rate_pkt_ps) {
-		NL_SET_ERR_MSG_MOD(extack,
-				   "QoS offload not support packets per second");
-		return -EOPNOTSUPP;
-	}
-
 	return 0;
 }
 
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 11/16] net/mlx5e: Fix memory leak on updating vport counters
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
                   ` (9 preceding siblings ...)
  2023-01-10  6:11 ` [net 10/16] net/mlx5e: TC, Restore pkt rate policing support Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-10  6:11 ` [net 12/16] net/mlx5: Fix ptp max frequency adjustment range Saeed Mahameed
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Aya Levin, Maor Dickman

From: Aya Levin <ayal@nvidia.com>

When updating statistics driver queries the vport's counters. On fail,
add error path releasing the allocated buffer avoiding memory leak.

Fixes: 64b68e369649 ("net/mlx5: Refactor and expand rep vport stat group")
Signed-off-by: Aya Levin <ayal@nvidia.com>
Reviewed-by: Maor Dickman <maord@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 75b9e1528fd2..7d90e5b72854 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -191,7 +191,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(vport_rep)
 	if (err) {
 		netdev_warn(priv->netdev, "vport %d error %d reading stats\n",
 			    rep->vport, err);
-		return;
+		goto out;
 	}
 
 	#define MLX5_GET_CTR(p, x) \
@@ -241,6 +241,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(vport_rep)
 	rep_stats->tx_vport_rdma_multicast_bytes =
 		MLX5_GET_CTR(out, received_ib_multicast.octets);
 
+out:
 	kvfree(out);
 }
 
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 12/16] net/mlx5: Fix ptp max frequency adjustment range
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
                   ` (10 preceding siblings ...)
  2023-01-10  6:11 ` [net 11/16] net/mlx5e: Fix memory leak on updating vport counters Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-10  6:11 ` [net 13/16] net/mlx5e: Don't support encap rules with gbp option Saeed Mahameed
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Rahul Rameshbabu, Gal Pressman

From: Rahul Rameshbabu <rrameshbabu@nvidia.com>

.max_adj of ptp_clock_info acts as an absolute value for the amount in ppb
that can be set for a single call of .adjfine. This means that a single
call to .getfine cannot be greater than .max_adj or less than -(.max_adj).
Provides correct value for max frequency adjustment value supported by
devices.

Fixes: 3d8c38af1493 ("net/mlx5e: Add PTP Hardware Clock (PHC) support")
Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index 69cfe60c558a..69318b143268 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -681,7 +681,7 @@ static int mlx5_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin,
 static const struct ptp_clock_info mlx5_ptp_clock_info = {
 	.owner		= THIS_MODULE,
 	.name		= "mlx5_ptp",
-	.max_adj	= 100000000,
+	.max_adj	= 50000000,
 	.n_alarm	= 0,
 	.n_ext_ts	= 0,
 	.n_per_out	= 0,
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 13/16] net/mlx5e: Don't support encap rules with gbp option
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
                   ` (11 preceding siblings ...)
  2023-01-10  6:11 ` [net 12/16] net/mlx5: Fix ptp max frequency adjustment range Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-10  6:11 ` [net 14/16] net/mlx5: E-switch, Coverity: overlapping copy Saeed Mahameed
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Gavin Li, Maor Dickman

From: Gavin Li <gavinl@nvidia.com>

Previously, encap rules with gbp option would be offloaded by mistake but
driver does not support gbp option offload.

To fix this issue, check if the encap rule has gbp option and don't
offload the rule

Fixes: d8f9dfae49ce ("net: sched: allow flower to match vxlan options")
Signed-off-by: Gavin Li <gavinl@nvidia.com>
Reviewed-by: Maor Dickman <maord@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
index fd07c4cbfd1d..1f62c702b625 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
@@ -88,6 +88,8 @@ static int mlx5e_gen_ip_tunnel_header_vxlan(char buf[],
 	struct udphdr *udp = (struct udphdr *)(buf);
 	struct vxlanhdr *vxh;
 
+	if (tun_key->tun_flags & TUNNEL_VXLAN_OPT)
+		return -EOPNOTSUPP;
 	vxh = (struct vxlanhdr *)((char *)udp + sizeof(struct udphdr));
 	*ip_proto = IPPROTO_UDP;
 
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 14/16] net/mlx5: E-switch, Coverity: overlapping copy
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
                   ` (12 preceding siblings ...)
  2023-01-10  6:11 ` [net 13/16] net/mlx5e: Don't support encap rules with gbp option Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-10  6:11 ` [net 15/16] net/mlx5e: Fix macsec ssci attribute handling in offload path Saeed Mahameed
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Shay Drory, Mark Bloch

From: Shay Drory <shayd@nvidia.com>

When a capability is set via port function caps callbacks, a memcpy() is
performed in which the source and the target are the same address, e.g.:
the copy is redundant. Hence, Remove it.
Discovered by Coverity.

Fixes: 7db98396ef45 ("net/mlx5: E-Switch, Implement devlink port function cmds to control RoCE")
Fixes: e5b9642a33be ("net/mlx5: E-Switch, Implement devlink port function cmds to control migratable")
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 75b77dd2392b..c981fa77f439 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -4143,8 +4143,6 @@ int mlx5_devlink_port_fn_migratable_set(struct devlink_port *port, bool enable,
 	}
 
 	hca_caps = MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability);
-	memcpy(hca_caps, MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability),
-	       MLX5_UN_SZ_BYTES(hca_cap_union));
 	MLX5_SET(cmd_hca_cap_2, hca_caps, migratable, 1);
 
 	err = mlx5_vport_set_other_func_cap(esw->dev, hca_caps, vport->vport,
@@ -4236,8 +4234,6 @@ int mlx5_devlink_port_fn_roce_set(struct devlink_port *port, bool enable,
 	}
 
 	hca_caps = MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability);
-	memcpy(hca_caps, MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability),
-	       MLX5_UN_SZ_BYTES(hca_cap_union));
 	MLX5_SET(cmd_hca_cap, hca_caps, roce, enable);
 
 	err = mlx5_vport_set_other_func_cap(esw->dev, hca_caps, vport_num,
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 15/16] net/mlx5e: Fix macsec ssci attribute handling in offload path
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
                   ` (13 preceding siblings ...)
  2023-01-10  6:11 ` [net 14/16] net/mlx5: E-switch, Coverity: overlapping copy Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-10  6:11 ` [net 16/16] net/mlx5e: Fix macsec possible null dereference when updating MAC security entity (SecY) Saeed Mahameed
  2023-01-11  2:01 ` [pull request][net 00/16] mlx5 fixes 2023-01-09 Jakub Kicinski
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Emeel Hakim, Raed Salem

From: Emeel Hakim <ehakim@nvidia.com>

Currently when macsec offload is set with extended packet number (epn)
enabled, the driver wrongly deduce the short secure channel identifier
(ssci) from the salt instead of the stand alone ssci attribute as it
should, consequently creating a mismatch between the kernel and driver's
ssci values.
Fix by using the ssci value from the relevant attribute.

Fixes: 4411a6c0abd3 ("net/mlx5e: Support MACsec offload extended packet number (EPN)")
Signed-off-by: Emeel Hakim <ehakim@nvidia.com>
Reviewed-by: Raed Salem <raeds@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../net/ethernet/mellanox/mlx5/core/en_accel/macsec.c  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
index 9369a580743e..cf7b3bb54c86 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
@@ -62,6 +62,7 @@ struct mlx5e_macsec_sa {
 	u32 enc_key_id;
 	u32 next_pn;
 	sci_t sci;
+	ssci_t ssci;
 	salt_t salt;
 
 	struct rhash_head hash;
@@ -499,10 +500,11 @@ mlx5e_macsec_get_macsec_device_context(const struct mlx5e_macsec *macsec,
 }
 
 static void update_macsec_epn(struct mlx5e_macsec_sa *sa, const struct macsec_key *key,
-			      const pn_t *next_pn_halves)
+			      const pn_t *next_pn_halves, ssci_t ssci)
 {
 	struct mlx5e_macsec_epn_state *epn_state = &sa->epn_state;
 
+	sa->ssci = ssci;
 	sa->salt = key->salt;
 	epn_state->epn_enabled = 1;
 	epn_state->epn_msb = next_pn_halves->upper;
@@ -550,7 +552,8 @@ static int mlx5e_macsec_add_txsa(struct macsec_context *ctx)
 	tx_sa->assoc_num = assoc_num;
 
 	if (secy->xpn)
-		update_macsec_epn(tx_sa, &ctx_tx_sa->key, &ctx_tx_sa->next_pn_halves);
+		update_macsec_epn(tx_sa, &ctx_tx_sa->key, &ctx_tx_sa->next_pn_halves,
+				  ctx_tx_sa->ssci);
 
 	err = mlx5_create_encryption_key(mdev, ctx->sa.key, secy->key_len,
 					 MLX5_ACCEL_OBJ_MACSEC_KEY,
@@ -945,7 +948,8 @@ static int mlx5e_macsec_add_rxsa(struct macsec_context *ctx)
 	rx_sa->fs_id = rx_sc->sc_xarray_element->fs_id;
 
 	if (ctx->secy->xpn)
-		update_macsec_epn(rx_sa, &ctx_rx_sa->key, &ctx_rx_sa->next_pn_halves);
+		update_macsec_epn(rx_sa, &ctx_rx_sa->key, &ctx_rx_sa->next_pn_halves,
+				  ctx_rx_sa->ssci);
 
 	err = mlx5_create_encryption_key(mdev, ctx->sa.key, ctx->secy->key_len,
 					 MLX5_ACCEL_OBJ_MACSEC_KEY,
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [net 16/16] net/mlx5e: Fix macsec possible null dereference when updating MAC security entity (SecY)
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
                   ` (14 preceding siblings ...)
  2023-01-10  6:11 ` [net 15/16] net/mlx5e: Fix macsec ssci attribute handling in offload path Saeed Mahameed
@ 2023-01-10  6:11 ` Saeed Mahameed
  2023-01-11  2:01 ` [pull request][net 00/16] mlx5 fixes 2023-01-09 Jakub Kicinski
  16 siblings, 0 replies; 19+ messages in thread
From: Saeed Mahameed @ 2023-01-10  6:11 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: Saeed Mahameed, netdev, Tariq Toukan, Emeel Hakim, Raed Salem

From: Emeel Hakim <ehakim@nvidia.com>

Upon updating MAC security entity (SecY) in hw offload path, the macsec
security association (SA) initialization routine is called. In case of
extended packet number (epn) is enabled the salt and ssci attributes are
retrieved using the MACsec driver rx_sa context which is unavailable when
updating a SecY property such as encoding-sa hence the null dereference.
Fix by using the provided SA to set those attributes.

Fixes: 4411a6c0abd3 ("net/mlx5e: Support MACsec offload extended packet number (EPN)")
Signed-off-by: Emeel Hakim <ehakim@nvidia.com>
Reviewed-by: Raed Salem <raeds@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../net/ethernet/mellanox/mlx5/core/en_accel/macsec.c    | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
index cf7b3bb54c86..7f6b940830b3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
@@ -359,7 +359,6 @@ static int mlx5e_macsec_init_sa(struct macsec_context *ctx,
 	struct mlx5_core_dev *mdev = priv->mdev;
 	struct mlx5_macsec_obj_attrs obj_attrs;
 	union mlx5e_macsec_rule *macsec_rule;
-	struct macsec_key *key;
 	int err;
 
 	obj_attrs.next_pn = sa->next_pn;
@@ -369,13 +368,9 @@ static int mlx5e_macsec_init_sa(struct macsec_context *ctx,
 	obj_attrs.aso_pdn = macsec->aso.pdn;
 	obj_attrs.epn_state = sa->epn_state;
 
-	key = (is_tx) ? &ctx->sa.tx_sa->key : &ctx->sa.rx_sa->key;
-
 	if (sa->epn_state.epn_enabled) {
-		obj_attrs.ssci = (is_tx) ? cpu_to_be32((__force u32)ctx->sa.tx_sa->ssci) :
-					   cpu_to_be32((__force u32)ctx->sa.rx_sa->ssci);
-
-		memcpy(&obj_attrs.salt, &key->salt, sizeof(key->salt));
+		obj_attrs.ssci = cpu_to_be32((__force u32)sa->ssci);
+		memcpy(&obj_attrs.salt, &sa->salt, sizeof(sa->salt));
 	}
 
 	obj_attrs.replay_window = ctx->secy->replay_window;
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [pull request][net 00/16] mlx5 fixes 2023-01-09
  2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
                   ` (15 preceding siblings ...)
  2023-01-10  6:11 ` [net 16/16] net/mlx5e: Fix macsec possible null dereference when updating MAC security entity (SecY) Saeed Mahameed
@ 2023-01-11  2:01 ` Jakub Kicinski
  16 siblings, 0 replies; 19+ messages in thread
From: Jakub Kicinski @ 2023-01-11  2:01 UTC (permalink / raw)
  To: Saeed Mahameed
  Cc: David S. Miller, Paolo Abeni, Eric Dumazet, Saeed Mahameed,
	netdev, Tariq Toukan

On Mon,  9 Jan 2023 22:11:07 -0800 Saeed Mahameed wrote:
> From: Saeed Mahameed <saeedm@nvidia.com>
> 
> This series provides bug fixes to mlx5 driver.
> Please pull and let me know if there is any problem.

Posted too late in the day for me to pull so FWIW:

Acked-by: Jakub Kicinski <kuba@kernel.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [net 01/16] net/mlx5: DR, Fix 'stack frame size exceeds limit' error in dr_rule
  2023-01-10  6:11 ` [net 01/16] net/mlx5: DR, Fix 'stack frame size exceeds limit' error in dr_rule Saeed Mahameed
@ 2023-01-11 13:00   ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 19+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-01-11 13:00 UTC (permalink / raw)
  To: Saeed Mahameed
  Cc: davem, kuba, pabeni, edumazet, saeedm, netdev, tariqt, kliteyn, lkp

Hello:

This series was applied to netdev/net.git (master)
by Saeed Mahameed <saeedm@nvidia.com>:

On Mon,  9 Jan 2023 22:11:08 -0800 you wrote:
> From: Yevgeny Kliteynik <kliteyn@nvidia.com>
> 
> If the kernel configuration asks the compiler to check frame limit of 1K,
> dr_rule_create_rule_nic exceed this limit:
>     "stack frame size (1184) exceeds limit (1024)"
> 
> Fixing this issue by checking configured frame limit and using the
> optimization STE array only for cases with the usual 2K (or larger)
> stack size warning.
> 
> [...]

Here is the summary with links:
  - [net,01/16] net/mlx5: DR, Fix 'stack frame size exceeds limit' error in dr_rule
    https://git.kernel.org/netdev/net/c/17b3222e9437
  - [net,02/16] net/mlx5: check attr pointer validity before dereferencing it
    https://git.kernel.org/netdev/net/c/e0bf81bf0d3d
  - [net,03/16] net/mlx5e: TC, Keep mod hdr actions after mod hdr alloc
    https://git.kernel.org/netdev/net/c/5e72f3f1c558
  - [net,04/16] net/mlx5: Fix command stats access after free
    https://git.kernel.org/netdev/net/c/da2e552b469a
  - [net,05/16] net/mlx5e: Verify dev is present for fix features ndo
    https://git.kernel.org/netdev/net/c/ab4b01bfdaa6
  - [net,06/16] net/mlx5e: IPoIB, Block queue count configuration when sub interfaces are present
    https://git.kernel.org/netdev/net/c/806a8df7126a
  - [net,07/16] net/mlx5e: IPoIB, Block PKEY interfaces with less rx queues than parent
    https://git.kernel.org/netdev/net/c/31c70bfe58ef
  - [net,08/16] net/mlx5e: IPoIB, Fix child PKEY interface stats on rx path
    https://git.kernel.org/netdev/net/c/b5e23931c45a
  - [net,09/16] net/mlx5e: TC, ignore match level for post meter rules
    https://git.kernel.org/netdev/net/c/2414c9b7a29d
  - [net,10/16] net/mlx5e: TC, Restore pkt rate policing support
    https://git.kernel.org/netdev/net/c/c09502d54dc1
  - [net,11/16] net/mlx5e: Fix memory leak on updating vport counters
    https://git.kernel.org/netdev/net/c/3099d2e62f90
  - [net,12/16] net/mlx5: Fix ptp max frequency adjustment range
    https://git.kernel.org/netdev/net/c/fe91d57277ee
  - [net,13/16] net/mlx5e: Don't support encap rules with gbp option
    https://git.kernel.org/netdev/net/c/d515d63cae2c
  - [net,14/16] net/mlx5: E-switch, Coverity: overlapping copy
    https://git.kernel.org/netdev/net/c/cd4f186dc110
  - [net,15/16] net/mlx5e: Fix macsec ssci attribute handling in offload path
    https://git.kernel.org/netdev/net/c/f5e1ed04aa2e
  - [net,16/16] net/mlx5e: Fix macsec possible null dereference when updating MAC security entity (SecY)
    https://git.kernel.org/netdev/net/c/9828994ac492

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2023-01-11 13:01 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
2023-01-10  6:11 ` [net 01/16] net/mlx5: DR, Fix 'stack frame size exceeds limit' error in dr_rule Saeed Mahameed
2023-01-11 13:00   ` patchwork-bot+netdevbpf
2023-01-10  6:11 ` [net 02/16] net/mlx5: check attr pointer validity before dereferencing it Saeed Mahameed
2023-01-10  6:11 ` [net 03/16] net/mlx5e: TC, Keep mod hdr actions after mod hdr alloc Saeed Mahameed
2023-01-10  6:11 ` [net 04/16] net/mlx5: Fix command stats access after free Saeed Mahameed
2023-01-10  6:11 ` [net 05/16] net/mlx5e: Verify dev is present for fix features ndo Saeed Mahameed
2023-01-10  6:11 ` [net 06/16] net/mlx5e: IPoIB, Block queue count configuration when sub interfaces are present Saeed Mahameed
2023-01-10  6:11 ` [net 07/16] net/mlx5e: IPoIB, Block PKEY interfaces with less rx queues than parent Saeed Mahameed
2023-01-10  6:11 ` [net 08/16] net/mlx5e: IPoIB, Fix child PKEY interface stats on rx path Saeed Mahameed
2023-01-10  6:11 ` [net 09/16] net/mlx5e: TC, ignore match level for post meter rules Saeed Mahameed
2023-01-10  6:11 ` [net 10/16] net/mlx5e: TC, Restore pkt rate policing support Saeed Mahameed
2023-01-10  6:11 ` [net 11/16] net/mlx5e: Fix memory leak on updating vport counters Saeed Mahameed
2023-01-10  6:11 ` [net 12/16] net/mlx5: Fix ptp max frequency adjustment range Saeed Mahameed
2023-01-10  6:11 ` [net 13/16] net/mlx5e: Don't support encap rules with gbp option Saeed Mahameed
2023-01-10  6:11 ` [net 14/16] net/mlx5: E-switch, Coverity: overlapping copy Saeed Mahameed
2023-01-10  6:11 ` [net 15/16] net/mlx5e: Fix macsec ssci attribute handling in offload path Saeed Mahameed
2023-01-10  6:11 ` [net 16/16] net/mlx5e: Fix macsec possible null dereference when updating MAC security entity (SecY) Saeed Mahameed
2023-01-11  2:01 ` [pull request][net 00/16] mlx5 fixes 2023-01-09 Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).