Skip to contentSkip to conversation

mlx5 updates 2021-09-30

GIT PULL Applied Saeed Mahameed 2 participants 17 messages Sep 30, 2021 – Oct 1, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

From: Saeed Mahameed <[email protected]>

Hi Dave, Jakub,

This series provides misc mlx5 updates.
For more information please see tag log below.

Please pull and let me know if there is any problem.

Thanks,
Saeed.

---
The following changes since commit dd9a887b35b01d7027f974f5e7936f1410ab51ca:

Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net (2021-09-30 14:49:21 -0700)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2021-09-30

for you to fetch changes up to 51984c9ee01e784ff578e583678958709b18f7b7:

net/mlx5e: Use array_size() helper (2021-09-30 16:19:02 -0700)

----------------------------------------------------------------
mlx5-updates-2021-09-30

Misc mlx5 updates:

1) SW steering, Vports handling and SFs support

From Yevgeny Kliteynik
======================
This patch series deals with vport handling in SW steering.

For every vport, SW steering queries FW for this vport's properties, such as RX/TX ICM addresses to be able to add this vport as dest action. The following patches rework vport capabilities managements and add support for Scalable Functions (SFs).

- Patch 1 fixes the vport number data type all over the DR code to 16 bits in accordance with HW spec.
- Patch 2 replaces local SW steering WIRE_PORT macro with the existing mlx5 define.
- Patch 3 adds missing query for vport 0 and and handles eswitch manager capabilities for ECPF (BlueField in embedded CPU mode).
- Patch 4 fixes error messages for failure to obtain vport caps from different locations in the code to have the same verbosity level and similar wording.
- Patch 5 adds support for csum recalculation flow tables on SFs: it implements these FTs management in XArray instead of the fixed size array, thus adding support for csum recalculation table for any valid vport.
- Patch 6 is the main patch of this whole series: it refactors vports capabilities handling and adds SFs support.

======================

2) Minor and trivial updates and cleanups

----------------------------------------------------------------
Aya Levin (1):
net/mlx5: Tolerate failures in debug features while driver load

Gustavo A. R. Silva (3):
net/mlx5: Use kvcalloc() instead of kvzalloc() net/mlx5: Use struct_size() helper in kvzalloc() net/mlx5e: Use array_size() helper

Lama Kayal (1):
net/mlx5: Warn for devlink reload when there are VFs alive

Yevgeny Kliteynik (10):
net/mlx5: DR, Fix vport number data type to u16
net/mlx5: DR, Replace local WIRE_PORT macro with the existing MLX5_VPORT_UPLINK net/mlx5: DR, Add missing query for vport 0
net/mlx5: DR, Align error messages for failure to obtain vport caps net/mlx5: DR, Support csum recalculation flow table on SFs net/mlx5: DR, Add support for SF vports
net/mlx5: DR, Increase supported num of actions to 32
net/mlx5: DR, Fix typo 'offeset' to 'offset'
net/mlx5: DR, init_next_match only if needed
net/mlx5: DR, Add missing string for action type SAMPLER

 drivers/net/ethernet/mellanox/mlx5/core/cmd.c      |   2 +-
 drivers/net/ethernet/mellanox/mlx5/core/devlink.c  |   5 +
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |  10 +-
 .../ethernet/mellanox/mlx5/core/eswitch_offloads.c |   4 +-
 .../net/ethernet/mellanox/mlx5/core/fs_counters.c  |   3 +-
 drivers/net/ethernet/mellanox/mlx5/core/main.c     |  12 +-
 .../mellanox/mlx5/core/steering/dr_action.c        |  19 +-
 .../ethernet/mellanox/mlx5/core/steering/dr_cmd.c  |   6 +-
 .../mellanox/mlx5/core/steering/dr_domain.c        | 212 ++++++++++++++-------
 .../ethernet/mellanox/mlx5/core/steering/dr_fw.c   |   2 +-
 .../ethernet/mellanox/mlx5/core/steering/dr_rule.c |   4 +-
 .../mellanox/mlx5/core/steering/dr_ste_v0.c        |  13 +-
 .../mellanox/mlx5/core/steering/dr_ste_v1.c        |  18 +-
 .../mellanox/mlx5/core/steering/dr_types.h         |  47 ++---
 .../ethernet/mellanox/mlx5/core/steering/fs_dr.c   |   2 +-
 .../ethernet/mellanox/mlx5/core/steering/mlx5dr.h  |   2 +-
 16 files changed, 215 insertions(+), 146 deletions(-)
#1 lore raw

PATCH 1/15 net/mlx5: DR, Fix vport number data type to u16

From: Yevgeny Kliteynik <[email protected]>

According to the HW spec, vport number is a 16-bit value. Fix vport usage all over the code to u16 data type.

---
 .../ethernet/mellanox/mlx5/core/steering/dr_action.c   |  2 +-
 .../net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c  |  4 ++--
 .../ethernet/mellanox/mlx5/core/steering/dr_domain.c   |  2 +-
 .../net/ethernet/mellanox/mlx5/core/steering/dr_fw.c   |  2 +-
 .../ethernet/mellanox/mlx5/core/steering/dr_types.h    | 10 +++++-----
 .../net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h  |  2 +-
 6 files changed, 11 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +1 -1
index a5b9f65db23c..032b4a2546d3 100644
@@ -1747,7 +1747,7 @@ mlx5dr_action_create_modify_header(struct mlx5dr_domain *dmn,
 
 struct mlx5dr_action *
 mlx5dr_action_create_dest_vport(struct mlx5dr_domain *dmn,
-				u32 vport, u8 vhca_id_valid,
+				u16 vport, u8 vhca_id_valid,
 				u16 vhca_id)
 {
 	struct mlx5dr_cmd_vport_cap *vport_cap;
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c +2 -2
index 56307283bf9b..0f69321b3269 100644
@@ -272,7 +272,7 @@ int mlx5dr_cmd_set_fte_modify_and_vport(struct mlx5_core_dev *mdev,
 					u32 table_id,
 					u32 group_id,
 					u32 modify_header_id,
-					u32 vport_id)
+					u16 vport)
 {
 	u32 out[MLX5_ST_SZ_DW(set_fte_out)] = {};
 	void *in_flow_context;
@@ -303,7 +303,7 @@ int mlx5dr_cmd_set_fte_modify_and_vport(struct mlx5_core_dev *mdev,
 	in_dests = MLX5_ADDR_OF(flow_context, in_flow_context, destination);
 	MLX5_SET(dest_format_struct, in_dests, destination_type,
 		 MLX5_FLOW_DESTINATION_TYPE_VPORT);
-	MLX5_SET(dest_format_struct, in_dests, destination_id, vport_id);
+	MLX5_SET(dest_format_struct, in_dests, destination_id, vport);
 
 	err = mlx5_cmd_exec(mdev, in, inlen, out, sizeof(out));
 	kvfree(in);
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c +1 -1
index 0fe159809ba1..ca299d480579 100644
@@ -38,7 +38,7 @@ static void dr_domain_uninit_cache(struct mlx5dr_domain *dmn)
 }
 
 int mlx5dr_domain_cache_get_recalc_cs_ft_addr(struct mlx5dr_domain *dmn,
-					      u32 vport_num,
+					      u16 vport_num,
 					      u64 *rx_icm_addr)
 {
 	struct mlx5dr_fw_recalc_cs_ft *recalc_cs_ft;
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_fw.c +1 -1
index 0d6f86eb248b..68a4c32d5f34 100644
@@ -5,7 +5,7 @@
 #include "dr_types.h"
 
 struct mlx5dr_fw_recalc_cs_ft *
-mlx5dr_fw_create_recalc_cs_ft(struct mlx5dr_domain *dmn, u32 vport_num)
+mlx5dr_fw_create_recalc_cs_ft(struct mlx5dr_domain *dmn, u16 vport_num)
 {
 	struct mlx5dr_cmd_create_flow_table_attr ft_attr = {};
 	struct mlx5dr_fw_recalc_cs_ft *recalc_cs_ft;
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +5 -5
index b20e8aabb861..441c03e645db 100644
@@ -752,9 +752,9 @@ struct mlx5dr_esw_caps {
 struct mlx5dr_cmd_vport_cap {
 	u16 vport_gvmi;
 	u16 vhca_gvmi;
+	u16 num;
 	u64 icm_address_rx;
 	u64 icm_address_tx;
-	u32 num;
 };
 
 struct mlx5dr_roce_cap {
@@ -1103,7 +1103,7 @@ mlx5dr_ste_htbl_may_grow(struct mlx5dr_ste_htbl *htbl)
 }
 
 static inline struct mlx5dr_cmd_vport_cap *
-mlx5dr_get_vport_cap(struct mlx5dr_cmd_caps *caps, u32 vport)
+mlx5dr_get_vport_cap(struct mlx5dr_cmd_caps *caps, u16 vport)
 {
 	if (!caps->vports_caps ||
 	    (vport >= caps->num_vports && vport != WIRE_PORT))
@@ -1154,7 +1154,7 @@ int mlx5dr_cmd_set_fte_modify_and_vport(struct mlx5_core_dev *mdev,
 					u32 table_id,
 					u32 group_id,
 					u32 modify_header_id,
-					u32 vport_id);
+					u16 vport_id);
 int mlx5dr_cmd_del_flow_table_entry(struct mlx5_core_dev *mdev,
 				    u32 table_type,
 				    u32 table_id);
@@ -1372,11 +1372,11 @@ struct mlx5dr_fw_recalc_cs_ft {
 };
 
 struct mlx5dr_fw_recalc_cs_ft *
-mlx5dr_fw_create_recalc_cs_ft(struct mlx5dr_domain *dmn, u32 vport_num);
+mlx5dr_fw_create_recalc_cs_ft(struct mlx5dr_domain *dmn, u16 vport_num);
 void mlx5dr_fw_destroy_recalc_cs_ft(struct mlx5dr_domain *dmn,
 				    struct mlx5dr_fw_recalc_cs_ft *recalc_cs_ft);
 int mlx5dr_domain_cache_get_recalc_cs_ft_addr(struct mlx5dr_domain *dmn,
-					      u32 vport_num,
+					      u16 vport_num,
 					      u64 *rx_icm_addr);
 int mlx5dr_fw_create_md_tbl(struct mlx5dr_domain *dmn,
 			    struct mlx5dr_cmd_flow_destination_hw_info *dest,
drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h +1 -1
index c5a8b1601999..c7c93131b762 100644
@@ -89,7 +89,7 @@ mlx5dr_action_create_dest_flow_fw_table(struct mlx5dr_domain *domain,
 
 struct mlx5dr_action *
 mlx5dr_action_create_dest_vport(struct mlx5dr_domain *domain,
-				u32 vport, u8 vhca_id_valid,
+				u16 vport, u8 vhca_id_valid,
 				u16 vhca_id);
 
 struct mlx5dr_action *
Signature · 1 line
2.31.1
#3 lore raw

PATCH 2/15 net/mlx5: DR, Replace local WIRE_PORT macro with the existing MLX5_VPORT_UPLINK

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

SW steering defines its own macro for uplink vport number. Replace this macro with an already existing mlx5 macro.

---
 .../net/ethernet/mellanox/mlx5/core/steering/dr_action.c   | 2 +-
 .../net/ethernet/mellanox/mlx5/core/steering/dr_domain.c   | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c | 4 ++--
 .../net/ethernet/mellanox/mlx5/core/steering/dr_types.h    | 7 +++----
 4 files changed, 7 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +1 -1
index 032b4a2546d3..8ca8fb804798 100644
@@ -669,7 +669,7 @@ int mlx5dr_actions_build_ste_arr(struct mlx5dr_matcher *matcher,
 			attr.hit_gvmi = action->vport->caps->vhca_gvmi;
 			dest_action = action;
 			if (rx_rule) {
-				if (action->vport->caps->num == WIRE_PORT) {
+				if (action->vport->caps->num == MLX5_VPORT_UPLINK) {
 					mlx5dr_dbg(dmn, "Device doesn't support Loopback on WIRE vport\n");
 					return -EOPNOTSUPP;
 				}
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c +1 -1
index ca299d480579..73646322c7bc 100644
@@ -170,7 +170,7 @@ static int dr_domain_query_vports(struct mlx5dr_domain *dmn)
 
 	/* Last vport is the wire port */
 	wire_vport = &dmn->info.caps.vports_caps[vport];
-	wire_vport->num = WIRE_PORT;
+	wire_vport->num = MLX5_VPORT_UPLINK;
 	wire_vport->icm_address_rx = esw_caps->uplink_icm_address_rx;
 	wire_vport->icm_address_tx = esw_caps->uplink_icm_address_tx;
 	wire_vport->vport_gvmi = 0;
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c +2 -2
index aca80efc28fa..323ea138ad99 100644
@@ -1042,10 +1042,10 @@ static bool dr_rule_skip(enum mlx5dr_domain_type domain,
 		return false;
 
 	if (mask->misc.source_port) {
-		if (rx && value->misc.source_port != WIRE_PORT)
+		if (rx && value->misc.source_port != MLX5_VPORT_UPLINK)
 			return true;
 
-		if (!rx && value->misc.source_port == WIRE_PORT)
+		if (!rx && value->misc.source_port == MLX5_VPORT_UPLINK)
 			return true;
 	}
 
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +3 -4
index 441c03e645db..8e171a6d3a9d 100644
@@ -4,7 +4,7 @@
 #ifndef	_DR_TYPES_
 #define	_DR_TYPES_
 
-#include <linux/mlx5/driver.h>
+#include <linux/mlx5/vport.h>
 #include <linux/refcount.h>
 #include "fs_core.h"
 #include "wq.h"
@@ -14,7 +14,6 @@
 
 #define DR_RULE_MAX_STES 18
 #define DR_ACTION_MAX_STES 5
-#define WIRE_PORT 0xFFFF
 #define DR_STE_SVLAN 0x1
 #define DR_STE_CVLAN 0x2
 #define DR_SZ_MATCH_PARAM (MLX5_ST_SZ_DW_MATCH_PARAM * 4)
@@ -1106,10 +1105,10 @@ static inline struct mlx5dr_cmd_vport_cap *
 mlx5dr_get_vport_cap(struct mlx5dr_cmd_caps *caps, u16 vport)
 {
 	if (!caps->vports_caps ||
-	    (vport >= caps->num_vports && vport != WIRE_PORT))
+	    (vport >= caps->num_vports && vport != MLX5_VPORT_UPLINK))
 		return NULL;
 
-	if (vport == WIRE_PORT)
+	if (vport == MLX5_VPORT_UPLINK)
 		vport = caps->num_vports;
 
 	return &caps->vports_caps[vport];
Signature · 1 line
2.31.1
#4 lore raw

PATCH 3/15 net/mlx5: DR, Add missing query for vport 0

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

Currently, vport 0 capabilities are not set.
To fix this, we now querying both eswitch manager and vport 0. Eswitch manager has an access to all the vports - for eswitch manager PF, all vports can be referred as other vports. The exception is embedded CPU mode, where there is vport 0 of ECPF and the PF vport 0.

Here is how vport are queried:

For Connect-X5/6:
PF vport (0) and vports 1..n: vport number, other = true esw_manager is vport 0 (PF)
For BlueField (in embedded CPU mode):
ECPF vport: vport = 0, other = false
PF vport (0) and 1..n: vport number, other = true esw_manager = vport 0 (ECPF)

Also, note that there's no need for other_vport function parameter in dr_domain_query_vport - this value is now deduced locally in the function.

---
 .../mellanox/mlx5/core/steering/dr_cmd.c      |  2 +
 .../mellanox/mlx5/core/steering/dr_domain.c   | 37 +++++++++++++------
 .../mellanox/mlx5/core/steering/dr_types.h    |  5 +++
 3 files changed, 32 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c +2 -0
index 0f69321b3269..1d8febed0d76 100644
@@ -195,6 +195,8 @@ int mlx5dr_cmd_query_device(struct mlx5_core_dev *mdev,
 
 	caps->roce_min_src_udp = MLX5_CAP_ROCE(mdev, r_roce_min_src_udp_port);
 
+	caps->is_ecpf = mlx5_core_is_ecpf_esw_manager(mdev);
+
 	return 0;
 }
 
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c +25 -12
index 73646322c7bc..b61c5a8ba305 100644
@@ -125,17 +125,21 @@ static void dr_domain_uninit_resources(struct mlx5dr_domain *dmn)
 }
 
 static int dr_domain_query_vport(struct mlx5dr_domain *dmn,
-				 bool other_vport,
-				 u16 vport_number)
+				 u16 vport_number,
+				 struct mlx5dr_cmd_vport_cap *vport_caps)
 {
-	struct mlx5dr_cmd_vport_cap *vport_caps;
+	u16 cmd_vport = vport_number;
+	bool other_vport = true;
 	int ret;
 
-	vport_caps = &dmn->info.caps.vports_caps[vport_number];
+	if (dmn->info.caps.is_ecpf && vport_number == MLX5_VPORT_ECPF) {
+		other_vport = false;
+		cmd_vport = 0;
+	}
 
 	ret = mlx5dr_cmd_query_esw_vport_context(dmn->mdev,
 						 other_vport,
-						 vport_number,
+						 cmd_vport,
 						 &vport_caps->icm_address_rx,
 						 &vport_caps->icm_address_tx);
 	if (ret)
@@ -143,7 +147,7 @@ static int dr_domain_query_vport(struct mlx5dr_domain *dmn,
 
 	ret = mlx5dr_cmd_query_gvmi(dmn->mdev,
 				    other_vport,
-				    vport_number,
+				    cmd_vport,
 				    &vport_caps->vport_gvmi);
 	if (ret)
 		return ret;
@@ -154,6 +158,13 @@ static int dr_domain_query_vport(struct mlx5dr_domain *dmn,
 	return 0;
 }
 
+static int dr_domain_query_esw_mngr(struct mlx5dr_domain *dmn)
+{
+	return dr_domain_query_vport(dmn,
+				     dmn->info.caps.is_ecpf ? MLX5_VPORT_ECPF : 0,
+				     &dmn->info.caps.esw_manager_vport_caps);
+}
+
 static int dr_domain_query_vports(struct mlx5dr_domain *dmn)
 {
 	struct mlx5dr_esw_caps *esw_caps = &dmn->info.caps.esw_caps;
@@ -161,9 +172,15 @@ static int dr_domain_query_vports(struct mlx5dr_domain *dmn)
 	int vport;
 	int ret;
 
+	ret = dr_domain_query_esw_mngr(dmn);
+	if (ret)
+		return ret;
+
 	/* Query vports (except wire vport) */
 	for (vport = 0; vport < dmn->info.caps.num_esw_ports - 1; vport++) {
-		ret = dr_domain_query_vport(dmn, !!vport, vport);
+		ret = dr_domain_query_vport(dmn,
+					    vport,
+					    &dmn->info.caps.vports_caps[vport]);
 		if (ret)
 			return ret;
 	}
@@ -267,11 +284,7 @@ static int dr_domain_caps_init(struct mlx5_core_dev *mdev,
 
 		dmn->info.rx.type = DR_DOMAIN_NIC_TYPE_RX;
 		dmn->info.tx.type = DR_DOMAIN_NIC_TYPE_TX;
-		vport_cap = mlx5dr_get_vport_cap(&dmn->info.caps, 0);
-		if (!vport_cap) {
-			mlx5dr_err(dmn, "Failed to get esw manager vport\n");
-			return -ENOENT;
-		}
+		vport_cap = &dmn->info.caps.esw_manager_vport_caps;
 
 		dmn->info.supp_sw_steering = true;
 		dmn->info.tx.default_icm_addr = vport_cap->icm_address_tx;
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +5 -0
index 8e171a6d3a9d..4bf8156f0a87 100644
@@ -797,8 +797,10 @@ struct mlx5dr_cmd_caps {
 	u32 num_vports;
 	struct mlx5dr_esw_caps esw_caps;
 	struct mlx5dr_cmd_vport_cap *vports_caps;
+	struct mlx5dr_cmd_vport_cap esw_manager_vport_caps;
 	bool prio_tag_required;
 	struct mlx5dr_roce_cap roce_caps;
+	u8 is_ecpf:1;
 	u8 isolate_vl_tc:1;
 };
 
@@ -1104,6 +1106,9 @@ mlx5dr_ste_htbl_may_grow(struct mlx5dr_ste_htbl *htbl)
 static inline struct mlx5dr_cmd_vport_cap *
 mlx5dr_get_vport_cap(struct mlx5dr_cmd_caps *caps, u16 vport)
 {
+	if (caps->is_ecpf && vport == MLX5_VPORT_ECPF)
+		return &caps->esw_manager_vport_caps;
+
 	if (!caps->vports_caps ||
 	    (vport >= caps->num_vports && vport != MLX5_VPORT_UPLINK))
 		return NULL;
Signature · 1 line
2.31.1
#5 lore raw

PATCH 4/15 net/mlx5: DR, Align error messages for failure to obtain vport caps

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

Print similar error messages when an invalid vport number is provided during action creation and during STEv0/1 creation.

---
 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c | 4 +++-
 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +3 -1
index 8ca8fb804798..d09e99afc171 100644
@@ -1769,7 +1769,9 @@ mlx5dr_action_create_dest_vport(struct mlx5dr_domain *dmn,
 
 	vport_cap = mlx5dr_get_vport_cap(&vport_dmn->info.caps, vport);
 	if (!vport_cap) {
-		mlx5dr_dbg(dmn, "Failed to get vport %d caps\n", vport);
+		mlx5dr_err(dmn,
+			   "Failed to get vport 0x%x caps - vport is disabled or invalid\n",
+			   vport);
 		return NULL;
 	}
 
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c +1 -1
index 9c704bce3c12..507719322af8 100644
@@ -1670,7 +1670,7 @@ dr_ste_v0_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value,
 	if (source_gvmi_set) {
 		vport_cap = mlx5dr_get_vport_cap(caps, misc->source_port);
 		if (!vport_cap) {
-			mlx5dr_err(dmn, "Vport 0x%x is invalid\n",
+			mlx5dr_err(dmn, "Vport 0x%x is disabled or invalid\n",
 				   misc->source_port);
 			return -EINVAL;
 		}
Signature · 1 line
2.31.1
#6 lore raw

PATCH 5/15 net/mlx5: DR, Support csum recalculation flow table on SFs

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

Implement csum recalculation flow tables in XAarray instead of a fixed array, thus adding support for csum recalc table on any valid vport number, which enables this support for SFs.

---
 .../mellanox/mlx5/core/steering/dr_action.c   |  6 +--
 .../mellanox/mlx5/core/steering/dr_domain.c   | 53 ++++++++-----------
 .../mellanox/mlx5/core/steering/dr_types.h    | 12 ++---
 3 files changed, 29 insertions(+), 42 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +3 -3
index d09e99afc171..a41fac349981 100644
@@ -513,9 +513,9 @@ static int dr_action_handle_cs_recalc(struct mlx5dr_domain *dmn,
 		/* If destination is vport we will get the FW flow table
 		 * that recalculates the CS and forwards to the vport.
 		 */
-		ret = mlx5dr_domain_cache_get_recalc_cs_ft_addr(dest_action->vport->dmn,
-								dest_action->vport->caps->num,
-								final_icm_addr);
+		ret = mlx5dr_domain_get_recalc_cs_ft_addr(dest_action->vport->dmn,
+							  dest_action->vport->caps->num,
+							  final_icm_addr);
 		if (ret) {
 			mlx5dr_err(dmn, "Failed to get FW cs recalc flow table\n");
 			return ret;
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c +22 -31

93 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +4 -8
index 4bf8156f0a87..a9cf4f55cacf 100644
@@ -827,10 +827,6 @@ struct mlx5dr_domain_info {
 	struct mlx5dr_cmd_caps caps;
 };
 
-struct mlx5dr_domain_cache {
-	struct mlx5dr_fw_recalc_cs_ft **recalc_cs_ft;
-};
-
 struct mlx5dr_domain {
 	struct mlx5dr_domain *peer_dmn;
 	struct mlx5_core_dev *mdev;
@@ -842,7 +838,7 @@ struct mlx5dr_domain {
 	struct mlx5dr_icm_pool *action_icm_pool;
 	struct mlx5dr_send_ring *send_ring;
 	struct mlx5dr_domain_info info;
-	struct mlx5dr_domain_cache cache;
+	struct xarray csum_fts_xa;
 	struct mlx5dr_ste_ctx *ste_ctx;
 };
 
@@ -1379,9 +1375,9 @@ struct mlx5dr_fw_recalc_cs_ft *
 mlx5dr_fw_create_recalc_cs_ft(struct mlx5dr_domain *dmn, u16 vport_num);
 void mlx5dr_fw_destroy_recalc_cs_ft(struct mlx5dr_domain *dmn,
 				    struct mlx5dr_fw_recalc_cs_ft *recalc_cs_ft);
-int mlx5dr_domain_cache_get_recalc_cs_ft_addr(struct mlx5dr_domain *dmn,
-					      u16 vport_num,
-					      u64 *rx_icm_addr);
+int mlx5dr_domain_get_recalc_cs_ft_addr(struct mlx5dr_domain *dmn,
+					u16 vport_num,
+					u64 *rx_icm_addr);
 int mlx5dr_fw_create_md_tbl(struct mlx5dr_domain *dmn,
 			    struct mlx5dr_cmd_flow_destination_hw_info *dest,
 			    int num_dest,
Signature · 1 line
2.31.1
#7 lore raw

PATCH 6/15 net/mlx5: DR, Add support for SF vports

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

Move all the vport capabilities to a separate struct and store vport caps in XArray: SFs vport numbers will not come in the same range as VF vports, so the existing implementation of vport capabilities as a fixed size array is not suitable here.

XArray is a perfect fit: it is efficient when the indices used are densely clustered. In addition to being a perfect fit as a dynamic data structure, XArray also provides locking - it uses RCU and an internal spinlock to synchronise access, so no additional protection needed.

Now except for the eswitch manager vport, all other vports (including the uplink vport) are handled in the same way: when a new go-to-vport action is added, this vport's caps are loaded from the xarray. If it is the first time for this particular vport number, then its capabilities are queried from FW and filled in into the appropriate entry.

---
 .../mellanox/mlx5/core/steering/dr_action.c   |   2 +-
 .../mellanox/mlx5/core/steering/dr_domain.c   | 138 +++++++++++++-----
 .../mellanox/mlx5/core/steering/dr_ste_v0.c   |  11 +-
 .../mellanox/mlx5/core/steering/dr_ste_v1.c   |  10 +-
 .../mellanox/mlx5/core/steering/dr_types.h    |  27 +---
 5 files changed, 120 insertions(+), 68 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +1 -1
index a41fac349981..0179d386ee48 100644
@@ -1767,7 +1767,7 @@ mlx5dr_action_create_dest_vport(struct mlx5dr_domain *dmn,
 		return NULL;
 	}
 
-	vport_cap = mlx5dr_get_vport_cap(&vport_dmn->info.caps, vport);
+	vport_cap = mlx5dr_domain_get_vport_cap(vport_dmn, vport);
 	if (!vport_cap) {
 		mlx5dr_err(dmn,
 			   "Failed to get vport 0x%x caps - vport is disabled or invalid\n",
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c +100 -38

195 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c +6 -5
index 507719322af8..b0649c2877dd 100644
@@ -1645,7 +1645,7 @@ dr_ste_v0_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value,
 	struct mlx5dr_match_misc *misc = &value->misc;
 	struct mlx5dr_cmd_vport_cap *vport_cap;
 	struct mlx5dr_domain *dmn = sb->dmn;
-	struct mlx5dr_cmd_caps *caps;
+	struct mlx5dr_domain *vport_dmn;
 	u8 *bit_mask = sb->bit_mask;
 	bool source_gvmi_set;
 
@@ -1654,21 +1654,22 @@ dr_ste_v0_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value,
 	if (sb->vhca_id_valid) {
 		/* Find port GVMI based on the eswitch_owner_vhca_id */
 		if (misc->source_eswitch_owner_vhca_id == dmn->info.caps.gvmi)
-			caps = &dmn->info.caps;
+			vport_dmn = dmn;
 		else if (dmn->peer_dmn && (misc->source_eswitch_owner_vhca_id ==
 					   dmn->peer_dmn->info.caps.gvmi))
-			caps = &dmn->peer_dmn->info.caps;
+			vport_dmn = dmn->peer_dmn;
 		else
 			return -EINVAL;
 
 		misc->source_eswitch_owner_vhca_id = 0;
 	} else {
-		caps = &dmn->info.caps;
+		vport_dmn = dmn;
 	}
 
 	source_gvmi_set = MLX5_GET(ste_src_gvmi_qp, bit_mask, source_gvmi);
 	if (source_gvmi_set) {
-		vport_cap = mlx5dr_get_vport_cap(caps, misc->source_port);
+		vport_cap = mlx5dr_domain_get_vport_cap(vport_dmn,
+							misc->source_port);
 		if (!vport_cap) {
 			mlx5dr_err(dmn, "Vport 0x%x is disabled or invalid\n",
 				   misc->source_port);
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c +5 -5
index 33e6299026f7..3497c2cf3118 100644
@@ -1776,7 +1776,7 @@ static int dr_ste_v1_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value,
 	struct mlx5dr_match_misc *misc = &value->misc;
 	struct mlx5dr_cmd_vport_cap *vport_cap;
 	struct mlx5dr_domain *dmn = sb->dmn;
-	struct mlx5dr_cmd_caps *caps;
+	struct mlx5dr_domain *vport_dmn;
 	u8 *bit_mask = sb->bit_mask;
 
 	DR_STE_SET_TAG(src_gvmi_qp_v1, tag, source_qp, misc, source_sqn);
@@ -1784,22 +1784,22 @@ static int dr_ste_v1_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value,
 	if (sb->vhca_id_valid) {
 		/* Find port GVMI based on the eswitch_owner_vhca_id */
 		if (misc->source_eswitch_owner_vhca_id == dmn->info.caps.gvmi)
-			caps = &dmn->info.caps;
+			vport_dmn = dmn;
 		else if (dmn->peer_dmn && (misc->source_eswitch_owner_vhca_id ==
 					   dmn->peer_dmn->info.caps.gvmi))
-			caps = &dmn->peer_dmn->info.caps;
+			vport_dmn = dmn->peer_dmn;
 		else
 			return -EINVAL;
 
 		misc->source_eswitch_owner_vhca_id = 0;
 	} else {
-		caps = &dmn->info.caps;
+		vport_dmn = dmn;
 	}
 
 	if (!MLX5_GET(ste_src_gvmi_qp_v1, bit_mask, source_gvmi))
 		return 0;
 
-	vport_cap = mlx5dr_get_vport_cap(caps, misc->source_port);
+	vport_cap = mlx5dr_domain_get_vport_cap(vport_dmn, misc->source_port);
 	if (!vport_cap) {
 		mlx5dr_err(dmn, "Vport 0x%x is disabled or invalid\n",
 			   misc->source_port);
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +8 -19
index a9cf4f55cacf..01787b9d5a57 100644
@@ -762,6 +762,11 @@ struct mlx5dr_roce_cap {
 	u8 fl_rc_qp_when_roce_enabled:1;
 };
 
+struct mlx5dr_vports {
+	struct mlx5dr_cmd_vport_cap esw_manager_caps;
+	struct xarray vports_caps_xa;
+};
+
 struct mlx5dr_cmd_caps {
 	u16 gvmi;
 	u64 nic_rx_drop_address;
@@ -785,7 +790,6 @@ struct mlx5dr_cmd_caps {
 	u8 flex_parser_id_gtpu_first_ext_dw_0;
 	u8 max_ft_level;
 	u16 roce_min_src_udp;
-	u8 num_esw_ports;
 	u8 sw_format_ver;
 	bool eswitch_manager;
 	bool rx_sw_owner;
@@ -794,10 +798,8 @@ struct mlx5dr_cmd_caps {
 	u8 rx_sw_owner_v2:1;
 	u8 tx_sw_owner_v2:1;
 	u8 fdb_sw_owner_v2:1;
-	u32 num_vports;
 	struct mlx5dr_esw_caps esw_caps;
-	struct mlx5dr_cmd_vport_cap *vports_caps;
-	struct mlx5dr_cmd_vport_cap esw_manager_vport_caps;
+	struct mlx5dr_vports vports;
 	bool prio_tag_required;
 	struct mlx5dr_roce_cap roce_caps;
 	u8 is_ecpf:1;
@@ -1099,21 +1101,8 @@ mlx5dr_ste_htbl_may_grow(struct mlx5dr_ste_htbl *htbl)
 	return true;
 }
 
-static inline struct mlx5dr_cmd_vport_cap *
-mlx5dr_get_vport_cap(struct mlx5dr_cmd_caps *caps, u16 vport)
-{
-	if (caps->is_ecpf && vport == MLX5_VPORT_ECPF)
-		return &caps->esw_manager_vport_caps;
-
-	if (!caps->vports_caps ||
-	    (vport >= caps->num_vports && vport != MLX5_VPORT_UPLINK))
-		return NULL;
-
-	if (vport == MLX5_VPORT_UPLINK)
-		vport = caps->num_vports;
-
-	return &caps->vports_caps[vport];
-}
+struct mlx5dr_cmd_vport_cap *
+mlx5dr_domain_get_vport_cap(struct mlx5dr_domain *dmn, u16 vport);
 
 struct mlx5dr_cmd_query_flow_table_details {
 	u8 status;
Signature · 1 line
2.31.1
#8 lore raw

PATCH 7/15 net/mlx5: DR, Increase supported num of actions to 32

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

Increase max supported number of actions in the same rule.

---
 drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c +1 -1
index 7e58f4e594b7..230e920e3845 100644
@@ -222,7 +222,7 @@ static bool contain_vport_reformat_action(struct mlx5_flow_rule *dst)
 		dst->dest_attr.vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID;
 }
 
-#define MLX5_FLOW_CONTEXT_ACTION_MAX  20
+#define MLX5_FLOW_CONTEXT_ACTION_MAX  32
 static int mlx5_cmd_dr_create_fte(struct mlx5_flow_root_namespace *ns,
 				  struct mlx5_flow_table *ft,
 				  struct mlx5_flow_group *group,
Signature · 1 line
2.31.1
#10 lore raw

PATCH 9/15 net/mlx5: DR, init_next_match only if needed

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

Allocate next steering table entry only if the remaining space requires to.

---
 .../net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c  | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c +5 -3
index 3497c2cf3118..cb9cf67b0a02 100644
@@ -586,9 +586,11 @@ static void dr_ste_v1_set_actions_tx(struct mlx5dr_domain *dmn,
 	} else if (action_type_set[DR_ACTION_TYP_L2_TO_TNL_L3]) {
 		u8 *d_action;
 
-		dr_ste_v1_arr_init_next_match(&last_ste, added_stes, attr->gvmi);
-		action = MLX5_ADDR_OF(ste_mask_and_match_v1, last_ste, action);
-		action_sz = DR_STE_ACTION_TRIPLE_SZ;
+		if (action_sz < DR_STE_ACTION_TRIPLE_SZ) {
+			dr_ste_v1_arr_init_next_match(&last_ste, added_stes, attr->gvmi);
+			action = MLX5_ADDR_OF(ste_mask_and_match_v1, last_ste, action);
+			action_sz = DR_STE_ACTION_TRIPLE_SZ;
+		}
 		d_action = action + DR_STE_ACTION_SINGLE_SZ;
 
 		dr_ste_v1_set_encap_l3(last_ste,
Signature · 1 line
2.31.1
#9 lore raw

PATCH 8/15 net/mlx5: DR, Fix typo 'offeset' to 'offset'

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

---
 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +1 -1
index 0179d386ee48..00199b3eae6a 100644
@@ -632,7 +632,7 @@ int mlx5dr_actions_build_ste_arr(struct mlx5dr_matcher *matcher,
 			return -EOPNOTSUPP;
 		case DR_ACTION_TYP_CTR:
 			attr.ctr_id = action->ctr->ctr_id +
-				action->ctr->offeset;
+				action->ctr->offset;
 			break;
 		case DR_ACTION_TYP_TAG:
 			attr.flow_tag = action->flow_tag->flow_tag;
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +1 -1
index 01787b9d5a57..73fed94af09a 100644
@@ -941,7 +941,7 @@ struct mlx5dr_action_dest_tbl {
 
 struct mlx5dr_action_ctr {
 	u32 ctr_id;
-	u32 offeset;
+	u32 offset;
 };
 
 struct mlx5dr_action_vport {
Signature · 1 line
2.31.1
#11 lore raw

PATCH 10/15 net/mlx5: DR, Add missing string for action type SAMPLER

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

Add missing string value for DR_ACTION_TYP_SAMPLER action type

---
 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c +1 -0
index 00199b3eae6a..50630112c8ff 100644
@@ -39,6 +39,7 @@ static const char * const action_type_to_str[] = {
 	[DR_ACTION_TYP_VPORT] = "DR_ACTION_TYP_VPORT",
 	[DR_ACTION_TYP_POP_VLAN] = "DR_ACTION_TYP_POP_VLAN",
 	[DR_ACTION_TYP_PUSH_VLAN] = "DR_ACTION_TYP_PUSH_VLAN",
+	[DR_ACTION_TYP_SAMPLER] = "DR_ACTION_TYP_SAMPLER",
 	[DR_ACTION_TYP_INSERT_HDR] = "DR_ACTION_TYP_INSERT_HDR",
 	[DR_ACTION_TYP_REMOVE_HDR] = "DR_ACTION_TYP_REMOVE_HDR",
 	[DR_ACTION_TYP_MAX] = "DR_ACTION_UNKNOWN",
Signature · 1 line
2.31.1
#12 lore raw

PATCH 11/15 net/mlx5: Warn for devlink reload when there are VFs alive

In reply to Saeed Mahameed

From: Lama Kayal <[email protected]>

When performing PF reload, VF can't communicate with FW until it recovers and reloads as well.

Add a warning message when performing devlink reload while VFs are still present. Thus, giving a notice of an unfavorable behavior that might occur as a result of a consequential reloads and cause interruption of VF recovery.

---
 drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +5 -0
index d7576b6fa43b..b9a6cea03951 100644
@@ -136,6 +136,7 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,
 				    struct netlink_ext_ack *extack)
 {
 	struct mlx5_core_dev *dev = devlink_priv(devlink);
+	struct pci_dev *pdev = dev->pdev;
 	bool sf_dev_allocated;
 
 	sf_dev_allocated = mlx5_sf_dev_allocated(dev);
@@ -153,6 +154,10 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,
 		return -EOPNOTSUPP;
 	}
 
+	if (pci_num_vf(pdev)) {
+		NL_SET_ERR_MSG_MOD(extack, "reload while VFs are present is unfavorable");
+	}
+
 	switch (action) {
 	case DEVLINK_RELOAD_ACTION_DRIVER_REINIT:
 		mlx5_unload_one(dev);
Signature · 1 line
2.31.1
#13 lore raw

PATCH 12/15 net/mlx5: Tolerate failures in debug features while driver load

In reply to Saeed Mahameed

From: Aya Levin <[email protected]>

FW tracer and resource dump are debug features. Although failing to initialize them may indicate an error, don't let this stop device loading.

---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +6 -6
index 92b08fa07efa..5893fdd5aedb 100644
@@ -1112,8 +1112,9 @@ static int mlx5_load(struct mlx5_core_dev *dev)
 
 	err = mlx5_fw_tracer_init(dev->tracer);
 	if (err) {
-		mlx5_core_err(dev, "Failed to init FW tracer\n");
-		goto err_fw_tracer;
+		mlx5_core_err(dev, "Failed to init FW tracer %d\n", err);
+		mlx5_fw_tracer_destroy(dev->tracer);
+		dev->tracer = NULL;
 	}
 
 	mlx5_fw_reset_events_start(dev);
@@ -1121,8 +1122,9 @@ static int mlx5_load(struct mlx5_core_dev *dev)
 
 	err = mlx5_rsc_dump_init(dev);
 	if (err) {
-		mlx5_core_err(dev, "Failed to init Resource dump\n");
-		goto err_rsc_dump;
+		mlx5_core_err(dev, "Failed to init Resource dump %d\n", err);
+		mlx5_rsc_dump_destroy(dev);
+		dev->rsc_dump = NULL;
 	}
 
 	err = mlx5_fpga_device_start(dev);
@@ -1192,11 +1194,9 @@ static int mlx5_load(struct mlx5_core_dev *dev)
 	mlx5_fpga_device_stop(dev);
 err_fpga_start:
 	mlx5_rsc_dump_cleanup(dev);
-err_rsc_dump:
 	mlx5_hv_vhca_cleanup(dev->hv_vhca);
 	mlx5_fw_reset_events_stop(dev);
 	mlx5_fw_tracer_cleanup(dev->tracer);
-err_fw_tracer:
 	mlx5_eq_table_destroy(dev);
 err_eq_table:
 	mlx5_irq_table_destroy(dev);
Signature · 1 line
2.31.1
#15 lore raw

PATCH 14/15 net/mlx5: Use struct_size() helper in kvzalloc()

In reply to Saeed Mahameed

From: "Gustavo A. R. Silva" <[email protected]>

Make use of the struct_size() helper instead of an open-coded version, in order to avoid any potential type mistakes or integer overflows that, in the worse scenario, could lead to heap overflows.

---
 drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c +1 -2
index 18e5aec14641..f542a36be62c 100644
@@ -497,8 +497,7 @@ static struct mlx5_fc_bulk *mlx5_fc_bulk_create(struct mlx5_core_dev *dev)
 	alloc_bitmask = MLX5_CAP_GEN(dev, flow_counter_bulk_alloc);
 	bulk_len = alloc_bitmask > 0 ? MLX5_FC_BULK_NUM_FCS(alloc_bitmask) : 1;
 
-	bulk = kvzalloc(sizeof(*bulk) + bulk_len * sizeof(struct mlx5_fc),
-			GFP_KERNEL);
+	bulk = kvzalloc(struct_size(bulk, fcs, bulk_len), GFP_KERNEL);
 	if (!bulk)
 		goto err_alloc_bulk;
 
Signature · 1 line
2.31.1
#14 lore raw

PATCH 13/15 net/mlx5: Use kvcalloc() instead of kvzalloc()

In reply to Saeed Mahameed

From: "Gustavo A. R. Silva" <[email protected]>

Use 2-factor argument form kvcalloc() instead of kvzalloc().

---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c              | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +1 -1
index db5dfff585c9..4dc3a822907a 100644
@@ -2058,7 +2058,7 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
 		return -EINVAL;
 	}
 
-	cmd->stats = kvzalloc(MLX5_CMD_OP_MAX * sizeof(*cmd->stats), GFP_KERNEL);
+	cmd->stats = kvcalloc(MLX5_CMD_OP_MAX, sizeof(*cmd->stats), GFP_KERNEL);
 	if (!cmd->stats)
 		return -ENOMEM;
 
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -2
index 0d461e38add3..4e1628f25265 100644
@@ -1009,7 +1009,7 @@ mlx5_eswitch_add_send_to_vport_meta_rules(struct mlx5_eswitch *esw)
 	u16 vport_num;
 
 	num_vfs = esw->esw_funcs.num_vfs;
-	flows = kvzalloc(num_vfs * sizeof(*flows), GFP_KERNEL);
+	flows = kvcalloc(num_vfs, sizeof(*flows), GFP_KERNEL);
 	if (!flows)
 		return -ENOMEM;
 
@@ -1188,7 +1188,7 @@ static int esw_add_fdb_peer_miss_rules(struct mlx5_eswitch *esw,
 
 	peer_miss_rules_setup(esw, peer_dev, spec, &dest);
 
-	flows = kvzalloc(nvports * sizeof(*flows), GFP_KERNEL);
+	flows = kvcalloc(nvports, sizeof(*flows), GFP_KERNEL);
 	if (!flows) {
 		err = -ENOMEM;
 		goto alloc_flows_err;
Signature · 1 line
2.31.1
#16 lore raw

PATCH 15/15 net/mlx5e: Use array_size() helper

In reply to Saeed Mahameed

From: "Gustavo A. R. Silva" <[email protected]>

Use array_size() helper to aid in 2-factor allocation instances.

---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +6 -4
index 3fd515e7bf30..3ab5929ff131 100644
@@ -930,9 +930,10 @@ static int mlx5e_alloc_xdpsq_fifo(struct mlx5e_xdpsq *sq, int numa)
 	struct mlx5e_xdp_info_fifo *xdpi_fifo = &sq->db.xdpi_fifo;
 	int wq_sz        = mlx5_wq_cyc_get_size(&sq->wq);
 	int dsegs_per_wq = wq_sz * MLX5_SEND_WQEBB_NUM_DS;
+	size_t size;
 
-	xdpi_fifo->xi = kvzalloc_node(sizeof(*xdpi_fifo->xi) * dsegs_per_wq,
-				      GFP_KERNEL, numa);
+	size = array_size(sizeof(*xdpi_fifo->xi), dsegs_per_wq);
+	xdpi_fifo->xi = kvzalloc_node(size, GFP_KERNEL, numa);
 	if (!xdpi_fifo->xi)
 		return -ENOMEM;
 
@@ -946,10 +947,11 @@ static int mlx5e_alloc_xdpsq_fifo(struct mlx5e_xdpsq *sq, int numa)
 static int mlx5e_alloc_xdpsq_db(struct mlx5e_xdpsq *sq, int numa)
 {
 	int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
+	size_t size;
 	int err;
 
-	sq->db.wqe_info = kvzalloc_node(sizeof(*sq->db.wqe_info) * wq_sz,
-					GFP_KERNEL, numa);
+	size = array_size(sizeof(*sq->db.wqe_info), wq_sz);
+	sq->db.wqe_info = kvzalloc_node(size, GFP_KERNEL, numa);
 	if (!sq->db.wqe_info)
 		return -ENOMEM;
 
Signature · 1 line
2.31.1
#2 lore raw

Re: [net-next 01/15] net/mlx5: DR, Fix vport number data type to u16

In reply to Saeed Mahameed
This series was applied to netdev/net-next.git (refs/heads/master):

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

Quoted 10 lines · On Thu, 30 Sep 2021 16:20:36 -0700 you wrote:

From: Yevgeny Kliteynik <[email protected]>

According to the HW spec, vport number is a 16-bit value. Fix vport usage all over the code to u16 data type.

[...]

Here is the summary with links:
- [net-next,01/15] net/mlx5: DR, Fix vport number data type to u16

    https://git.kernel.org/netdev/net-next/c/f9f93bd55ca6
  - [net-next,02/15] net/mlx5: DR, Replace local WIRE_PORT macro with the existing MLX5_VPORT_UPLINK
    https://git.kernel.org/netdev/net-next/c/7ae8ac9a5820
  - [net-next,03/15] net/mlx5: DR, Add missing query for vport 0
    https://git.kernel.org/netdev/net-next/c/dd4acb2a0954
  - [net-next,04/15] net/mlx5: DR, Align error messages for failure to obtain vport caps
    https://git.kernel.org/netdev/net-next/c/ee1887fb7cdd
  - [net-next,05/15] net/mlx5: DR, Support csum recalculation flow table on SFs
    https://git.kernel.org/netdev/net-next/c/c0e90fc2ccaa
  - [net-next,06/15] net/mlx5: DR, Add support for SF vports
    https://git.kernel.org/netdev/net-next/c/11a45def2e19
  - [net-next,07/15] net/mlx5: DR, Increase supported num of actions to 32
    https://git.kernel.org/netdev/net-next/c/1ffd498901c1
  - [net-next,08/15] net/mlx5: DR, Fix typo 'offeset' to 'offset'
    https://git.kernel.org/netdev/net-next/c/5dde00a73048
  - [net-next,09/15] net/mlx5: DR, init_next_match only if needed
    https://git.kernel.org/netdev/net-next/c/515ce2ffa621
  - [net-next,10/15] net/mlx5: DR, Add missing string for action type SAMPLER
    https://git.kernel.org/netdev/net-next/c/98576013bf28
  - [net-next,11/15] net/mlx5: Warn for devlink reload when there are VFs alive
    https://git.kernel.org/netdev/net-next/c/2b0247e22097
  - [net-next,12/15] net/mlx5: Tolerate failures in debug features while driver load
    https://git.kernel.org/netdev/net-next/c/f62eb932d857
  - [net-next,13/15] net/mlx5: Use kvcalloc() instead of kvzalloc()
    https://git.kernel.org/netdev/net-next/c/806bf340e180
  - [net-next,14/15] net/mlx5: Use struct_size() helper in kvzalloc()
    https://git.kernel.org/netdev/net-next/c/ab9ace34158f
  - [net-next,15/15] net/mlx5e: Use array_size() helper
    https://git.kernel.org/netdev/net-next/c/51984c9ee01e

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