Skip to contentSkip to conversation

selftests: mlxsw: Add scale tests for Spectrum-2

PATCH In review Ido Schimmel 2 participants 7 messages Oct 17, 2019 – Oct 18, 2019

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

cover selftests: mlxsw: Add scale tests for Spectrum-2

From: Ido Schimmel <[email protected]>

This series from Danielle adds two scale tests for the Spectrum-2 ASIC.

The first scale test (patches #1-#4) validates the number of mirroring sessions (using tc-mirred) that can be supported by the device. As a preparatory step, patch #1 exposes the maximum number and current usage of mirroring agents via devlink-resource. This allows us to avoid hard-coding the limits later in the test.

The second scale test (patch #5) validates the number of tc-flower filters that can be supported by the device.

Danielle Ratson (5):
mlxsw: spectrum: Register switched port analyzers (SPAN) as resource
selftests: mlxsw: Generalize the parameters of mirror_gre test
selftests: mlxsw: Add Spectrum-2 mirror-to-gretap target scale test
selftests: mlxsw: Add a resource scale test for Spectrum-2
selftests: mlxsw: Add Spectrum-2 target scale for tc flower scale test

 .../net/ethernet/mellanox/mlxsw/spectrum.c    | 51 ++++++++++++++++++-
 .../net/ethernet/mellanox/mlxsw/spectrum.h    |  3 ++
 .../ethernet/mellanox/mlxsw/spectrum_span.c   | 21 ++++++++
 .../net/mlxsw/spectrum-2/mirror_gre_scale.sh  | 16 ++++++
 .../net/mlxsw/spectrum-2/resource_scale.sh    | 46 +++++++++++++++++
 .../net/mlxsw/spectrum-2/tc_flower_scale.sh   | 20 ++++++++
 .../net/mlxsw/spectrum/mirror_gre_scale.sh    |  7 ++-
 7 files changed, 160 insertions(+), 4 deletions(-)
 create mode 100644 tools/testing/selftests/drivers/net/mlxsw/spectrum-2/mirror_gre_scale.sh
 create mode 100755 tools/testing/selftests/drivers/net/mlxsw/spectrum-2/resource_scale.sh
 create mode 100644 tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower_scale.sh
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/5 mlxsw: spectrum: Register switched port analyzers (SPAN) as resource

From: Danielle Ratson <[email protected]>

The switch supports an enhanced switched port analyzer that enables selecting network traffic for analysis by a network analyzer.

SPAN agents are configured and consumed whenever a tc filter is added with a mirror action to a new destination. The destination can either be a physical port (e.g., swp1), a VLAN device or a gretap.

Expose the maximum number of SPAN agents and their current usage to the user.

---
 .../net/ethernet/mellanox/mlxsw/spectrum.c    | 51 ++++++++++++++++++-
 .../net/ethernet/mellanox/mlxsw/spectrum.h    |  3 ++
 .../ethernet/mellanox/mlxsw/spectrum_span.c   | 21 ++++++++
 3 files changed, 73 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +49 -2
index ae3c4da11520..1275d21e8fbd 100644
@@ -5202,14 +5202,61 @@ static int mlxsw_sp2_resources_kvd_register(struct mlxsw_core *mlxsw_core)
 					 &kvd_size_params);
 }
 
+static int mlxsw_sp_resources_span_register(struct mlxsw_core *mlxsw_core)
+{
+	struct devlink *devlink = priv_to_devlink(mlxsw_core);
+	struct devlink_resource_size_params span_size_params;
+	u32 max_span;
+
+	if (!MLXSW_CORE_RES_VALID(mlxsw_core, MAX_SPAN))
+		return -EIO;
+
+	max_span = MLXSW_CORE_RES_GET(mlxsw_core, MAX_SPAN);
+	devlink_resource_size_params_init(&span_size_params, max_span, max_span,
+					  1, DEVLINK_RESOURCE_UNIT_ENTRY);
+
+	return devlink_resource_register(devlink, MLXSW_SP_RESOURCE_NAME_SPAN,
+					 max_span, MLXSW_SP_RESOURCE_SPAN,
+					 DEVLINK_RESOURCE_ID_PARENT_TOP,
+					 &span_size_params);
+}
+
 static int mlxsw_sp1_resources_register(struct mlxsw_core *mlxsw_core)
 {
-	return mlxsw_sp1_resources_kvd_register(mlxsw_core);
+	int err;
+
+	err = mlxsw_sp1_resources_kvd_register(mlxsw_core);
+	if (err)
+		return err;
+
+	err = mlxsw_sp_resources_span_register(mlxsw_core);
+	if (err)
+		goto err_resources_span_register;
+
+	return 0;
+
+err_resources_span_register:
+	devlink_resources_unregister(priv_to_devlink(mlxsw_core), NULL);
+	return err;
 }
 
 static int mlxsw_sp2_resources_register(struct mlxsw_core *mlxsw_core)
 {
-	return mlxsw_sp2_resources_kvd_register(mlxsw_core);
+	int err;
+
+	err = mlxsw_sp2_resources_kvd_register(mlxsw_core);
+	if (err)
+		return err;
+
+	err = mlxsw_sp_resources_span_register(mlxsw_core);
+	if (err)
+		goto err_resources_span_register;
+
+	return 0;
+
+err_resources_span_register:
+	devlink_resources_unregister(priv_to_devlink(mlxsw_core), NULL);
+	return err;
 }
 
 static int mlxsw_sp_kvd_sizes_get(struct mlxsw_core *mlxsw_core,
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +3 -0
index 8f99d70d6b8b..a5fdd84b4ca7 100644
@@ -48,6 +48,8 @@
 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_CHUNKS "chunks"
 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_LARGE_CHUNKS "large_chunks"
 
+#define MLXSW_SP_RESOURCE_NAME_SPAN "span_agents"
+
 enum mlxsw_sp_resource_id {
 	MLXSW_SP_RESOURCE_KVD = 1,
 	MLXSW_SP_RESOURCE_KVD_LINEAR,
@@ -56,6 +58,7 @@ enum mlxsw_sp_resource_id {
 	MLXSW_SP_RESOURCE_KVD_LINEAR_SINGLE,
 	MLXSW_SP_RESOURCE_KVD_LINEAR_CHUNKS,
 	MLXSW_SP_RESOURCE_KVD_LINEAR_LARGE_CHUNKS,
+	MLXSW_SP_RESOURCE_SPAN,
 };
 
 struct mlxsw_sp_port;
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c +21 -0
index 560a60e522f9..200d324e6d99 100644
@@ -14,8 +14,23 @@
 #include "spectrum_span.h"
 #include "spectrum_switchdev.h"
 
+static u64 mlxsw_sp_span_occ_get(void *priv)
+{
+	const struct mlxsw_sp *mlxsw_sp = priv;
+	u64 occ = 0;
+	int i;
+
+	for (i = 0; i < mlxsw_sp->span.entries_count; i++) {
+		if (mlxsw_sp->span.entries[i].ref_count)
+			occ++;
+	}
+
+	return occ;
+}
+
 int mlxsw_sp_span_init(struct mlxsw_sp *mlxsw_sp)
 {
+	struct devlink *devlink = priv_to_devlink(mlxsw_sp->core);
 	int i;
 
 	if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_SPAN))
@@ -36,13 +51,19 @@ int mlxsw_sp_span_init(struct mlxsw_sp *mlxsw_sp)
 		curr->id = i;
 	}
 
+	devlink_resource_occ_get_register(devlink, MLXSW_SP_RESOURCE_SPAN,
+					  mlxsw_sp_span_occ_get, mlxsw_sp);
+
 	return 0;
 }
 
 void mlxsw_sp_span_fini(struct mlxsw_sp *mlxsw_sp)
 {
+	struct devlink *devlink = priv_to_devlink(mlxsw_sp->core);
 	int i;
 
+	devlink_resource_occ_get_unregister(devlink, MLXSW_SP_RESOURCE_SPAN);
+
 	for (i = 0; i < mlxsw_sp->span.entries_count; i++) {
 		struct mlxsw_sp_span_entry *curr = &mlxsw_sp->span.entries[i];
 
Signature · 1 line
2.21.0
#2 lore raw

PATCH 2/5 selftests: mlxsw: Generalize the parameters of mirror_gre test

In reply to Ido Schimmel

From: Danielle Ratson <[email protected]>

Use the number of analyzers taken from the devlink command, instead of hard-coded value, in order to make the test more generic.

---
 .../drivers/net/mlxsw/spectrum/mirror_gre_scale.sh         | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
tools/testing/selftests/drivers/net/mlxsw/spectrum/mirror_gre_scale.sh +5 -2
index 8d2186c7c62b..f7c168decd1e 100644
@@ -4,10 +4,13 @@ source ../mirror_gre_scale.sh
 mirror_gre_get_target()
 {
 	local should_fail=$1; shift
+	local target
+
+	target=$(devlink_resource_size_get span_agents)
 
 	if ((! should_fail)); then
-		echo 3
+		echo $target
 	else
-		echo 4
+		echo $((target + 1))
 	fi
 }
Signature · 1 line
2.21.0
#3 lore raw

PATCH 3/5 selftests: mlxsw: Add Spectrum-2 mirror-to-gretap target scale test

In reply to Ido Schimmel

From: Danielle Ratson <[email protected]>

Like in Spectrum, use the number of analyzers taken from the devlink command.

---
 .../net/mlxsw/spectrum-2/mirror_gre_scale.sh     | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 tools/testing/selftests/drivers/net/mlxsw/spectrum-2/mirror_gre_scale.sh
tools/testing/selftests/drivers/net/mlxsw/spectrum-2/mirror_gre_scale.sh new file +16 -0
new file mode 100644
index 000000000000..f7c168decd1e
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0
+source ../mirror_gre_scale.sh
+
+mirror_gre_get_target()
+{
+	local should_fail=$1; shift
+	local target
+
+	target=$(devlink_resource_size_get span_agents)
+
+	if ((! should_fail)); then
+		echo $target
+	else
+		echo $((target + 1))
+	fi
+}
Signature · 1 line
2.21.0
#4 lore raw

PATCH 4/5 selftests: mlxsw: Add a resource scale test for Spectrum-2

In reply to Ido Schimmel

From: Danielle Ratson <[email protected]>

Add resource_scale test suitable for Spectrum-2.

Invoke the mirror_gre test and check that the advertised scale numbers are indeed supported.

---
 .../net/mlxsw/spectrum-2/resource_scale.sh    | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100755 tools/testing/selftests/drivers/net/mlxsw/spectrum-2/resource_scale.sh
tools/testing/selftests/drivers/net/mlxsw/spectrum-2/resource_scale.sh new file +46 -0
new file mode 100755
index 000000000000..3bb9147890fa
@@ -0,0 +1,46 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+lib_dir=$(dirname $0)/../../../../net/forwarding
+
+NUM_NETIFS=6
+source $lib_dir/lib.sh
+source $lib_dir/tc_common.sh
+source $lib_dir/devlink_lib.sh
+
+current_test=""
+
+cleanup()
+{
+	pre_cleanup
+	if [ ! -z $current_test ]; then
+		${current_test}_cleanup
+	fi
+}
+
+trap cleanup EXIT
+
+ALL_TESTS="mirror_gre"
+for current_test in ${TESTS:-$ALL_TESTS}; do
+	source ${current_test}_scale.sh
+
+	num_netifs_var=${current_test^^}_NUM_NETIFS
+	num_netifs=${!num_netifs_var:-$NUM_NETIFS}
+
+	for should_fail in 0 1; do
+		RET=0
+		target=$(${current_test}_get_target "$should_fail")
+		${current_test}_setup_prepare
+		setup_wait $num_netifs
+		${current_test}_test "$target" "$should_fail"
+		${current_test}_cleanup
+		if [[ "$should_fail" -eq 0 ]]; then
+			log_test "'$current_test' $target"
+		else
+			log_test "'$current_test' overflow $target"
+		fi
+	done
+done
+current_test=""
+
+exit "$RET"
Signature · 1 line
2.21.0
#5 lore raw

PATCH 5/5 selftests: mlxsw: Add Spectrum-2 target scale for tc flower scale test

In reply to Ido Schimmel

From: Danielle Ratson <[email protected]>

Return the maximum number of tc flower filters that can be offloaded. Currently, this value corresponds to the number of counters supported by the driver.

---
 .../net/mlxsw/spectrum-2/resource_scale.sh    |  2 +-
 .../net/mlxsw/spectrum-2/tc_flower_scale.sh   | 20 +++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower_scale.sh
tools/testing/selftests/drivers/net/mlxsw/spectrum-2/resource_scale.sh +1 -1
index 3bb9147890fa..2b5f4f7cc905 100755
@@ -20,7 +20,7 @@ cleanup()
 
 trap cleanup EXIT
 
-ALL_TESTS="mirror_gre"
+ALL_TESTS="tc_flower mirror_gre"
 for current_test in ${TESTS:-$ALL_TESTS}; do
 	source ${current_test}_scale.sh
 
tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower_scale.sh new file +20 -0
new file mode 100644
index 000000000000..a0795227216e
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0
+source ../tc_flower_scale.sh
+
+tc_flower_get_target()
+{
+	local should_fail=$1; shift
+
+	# The driver associates a counter with each tc filter, which means the
+	# number of supported filters is bounded by the number of available
+	# counters.
+	# Currently, the driver supports 12K (12,288) flow counters and six of
+	# these are used for multicast routing.
+	local target=12282
+
+	if ((! should_fail)); then
+		echo $target
+	else
+		echo $((target + 1))
+	fi
+}
Signature · 1 line
2.21.0
maintainer
#6 lore raw
In reply to Ido Schimmel

From: Ido Schimmel <[email protected]>
Date: Thu, 17 Oct 2019 09:55:13 +0300

Quoted 4 lines

From: Ido Schimmel <[email protected]>

This series from Danielle adds two scale tests for the Spectrum-2 ASIC.

Quoted 8 lines

The first scale test (patches #1-#4) validates the number of mirroring sessions (using tc-mirred) that can be supported by the device. As a preparatory step, patch #1 exposes the maximum number and current usage of mirroring agents via devlink-resource. This allows us to avoid hard-coding the limits later in the test.

The second scale test (patch #5) validates the number of tc-flower filters that can be supported by the device.

Series applied, thanks Ido.