Skip to content

Commit

Permalink
Merge branch 'selftests-mlxsw-Add-scale-tests-for-Spectrum-2'
Browse files Browse the repository at this point in the history
Ido Schimmel says:

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

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.
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Oct 18, 2019
2 parents f86854a + fa57dd7 commit 3858a64
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 4 deletions.
51 changes: 49 additions & 2 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down
21 changes: 21 additions & 0 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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];

Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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="tc_flower 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"
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 3858a64

Please sign in to comment.