Skip to content

Commit 69da40a

Browse files
committed
Merge branch 'mlxsw-selftests-cleanups'
Petr Machata says: ==================== mlxsw, selftests: Cleanups This patchset consolidates a number of disparate items that can all be considered cleanups. They are all related to mlxsw in that they are directly in mlxsw code, or in selftests that mlxsw heavily uses. - patch #1 fixes a comment, patch #2 propagates an extack - patches #3 and #4 tweak several loops to query a resource once and cache in a local variable instead of querying on each iteration - patches #5 and #6 fix selftest diagrams, and #7 adds a missing diagram into an existing test - patch #8 disables a PVID on a bridge in a selftest that should not need said PVID ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 3db0577 + f513687 commit 69da40a

File tree

4 files changed

+43
-17
lines changed

4 files changed

+43
-17
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ struct mlxsw_sp_rif_subport {
9696
struct mlxsw_sp_rif_ipip_lb {
9797
struct mlxsw_sp_rif common;
9898
struct mlxsw_sp_rif_ipip_lb_config lb_config;
99-
u16 ul_vr_id; /* Reserved for Spectrum-2. */
100-
u16 ul_rif_id; /* Reserved for Spectrum. */
99+
u16 ul_vr_id; /* Spectrum-1. */
100+
u16 ul_rif_id; /* Spectrum-2+. */
101101
};
102102

103103
struct mlxsw_sp_rif_params_ipip_lb {
@@ -748,10 +748,11 @@ static bool mlxsw_sp_vr_is_used(const struct mlxsw_sp_vr *vr)
748748

749749
static struct mlxsw_sp_vr *mlxsw_sp_vr_find_unused(struct mlxsw_sp *mlxsw_sp)
750750
{
751+
int max_vrs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS);
751752
struct mlxsw_sp_vr *vr;
752753
int i;
753754

754-
for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) {
755+
for (i = 0; i < max_vrs; i++) {
755756
vr = &mlxsw_sp->router->vrs[i];
756757
if (!mlxsw_sp_vr_is_used(vr))
757758
return vr;
@@ -792,12 +793,13 @@ static u32 mlxsw_sp_fix_tb_id(u32 tb_id)
792793
static struct mlxsw_sp_vr *mlxsw_sp_vr_find(struct mlxsw_sp *mlxsw_sp,
793794
u32 tb_id)
794795
{
796+
int max_vrs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS);
795797
struct mlxsw_sp_vr *vr;
796798
int i;
797799

798800
tb_id = mlxsw_sp_fix_tb_id(tb_id);
799801

800-
for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) {
802+
for (i = 0; i < max_vrs; i++) {
801803
vr = &mlxsw_sp->router->vrs[i];
802804
if (mlxsw_sp_vr_is_used(vr) && vr->tb_id == tb_id)
803805
return vr;
@@ -959,6 +961,7 @@ static int mlxsw_sp_vrs_lpm_tree_replace(struct mlxsw_sp *mlxsw_sp,
959961
struct mlxsw_sp_fib *fib,
960962
struct mlxsw_sp_lpm_tree *new_tree)
961963
{
964+
int max_vrs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS);
962965
enum mlxsw_sp_l3proto proto = fib->proto;
963966
struct mlxsw_sp_lpm_tree *old_tree;
964967
u8 old_id, new_id = new_tree->id;
@@ -968,7 +971,7 @@ static int mlxsw_sp_vrs_lpm_tree_replace(struct mlxsw_sp *mlxsw_sp,
968971
old_tree = mlxsw_sp->router->lpm.proto_trees[proto];
969972
old_id = old_tree->id;
970973

971-
for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) {
974+
for (i = 0; i < max_vrs; i++) {
972975
vr = &mlxsw_sp->router->vrs[i];
973976
if (!mlxsw_sp_vr_lpm_tree_should_replace(vr, proto, old_id))
974977
continue;
@@ -7298,9 +7301,10 @@ static void mlxsw_sp_vr_fib_flush(struct mlxsw_sp *mlxsw_sp,
72987301

72997302
static void mlxsw_sp_router_fib_flush(struct mlxsw_sp *mlxsw_sp)
73007303
{
7304+
int max_vrs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS);
73017305
int i, j;
73027306

7303-
for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) {
7307+
for (i = 0; i < max_vrs; i++) {
73047308
struct mlxsw_sp_vr *vr = &mlxsw_sp->router->vrs[i];
73057309

73067310
if (!mlxsw_sp_vr_is_used(vr))
@@ -7699,9 +7703,10 @@ static struct mlxsw_sp_rif *
76997703
mlxsw_sp_rif_find_by_dev(const struct mlxsw_sp *mlxsw_sp,
77007704
const struct net_device *dev)
77017705
{
7706+
int max_rifs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS);
77027707
int i;
77037708

7704-
for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++)
7709+
for (i = 0; i < max_rifs; i++)
77057710
if (mlxsw_sp->router->rifs[i] &&
77067711
mlxsw_sp->router->rifs[i]->dev == dev)
77077712
return mlxsw_sp->router->rifs[i];
@@ -9724,7 +9729,7 @@ mlxsw_sp1_rif_ipip_lb_configure(struct mlxsw_sp_rif *rif,
97249729
struct mlxsw_sp_vr *ul_vr;
97259730
int err;
97269731

9727-
ul_vr = mlxsw_sp_vr_get(mlxsw_sp, ul_tb_id, NULL);
9732+
ul_vr = mlxsw_sp_vr_get(mlxsw_sp, ul_tb_id, extack);
97289733
if (IS_ERR(ul_vr))
97299734
return PTR_ERR(ul_vr);
97309735

@@ -9923,7 +9928,7 @@ mlxsw_sp2_rif_ipip_lb_configure(struct mlxsw_sp_rif *rif,
99239928
struct mlxsw_sp_rif *ul_rif;
99249929
int err;
99259930

9926-
ul_rif = mlxsw_sp_ul_rif_get(mlxsw_sp, ul_tb_id, NULL);
9931+
ul_rif = mlxsw_sp_ul_rif_get(mlxsw_sp, ul_tb_id, extack);
99279932
if (IS_ERR(ul_rif))
99289933
return PTR_ERR(ul_rif);
99299934

@@ -10041,11 +10046,12 @@ static int mlxsw_sp_rifs_init(struct mlxsw_sp *mlxsw_sp)
1004110046

1004210047
static void mlxsw_sp_rifs_fini(struct mlxsw_sp *mlxsw_sp)
1004310048
{
10049+
int max_rifs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS);
1004410050
struct devlink *devlink = priv_to_devlink(mlxsw_sp->core);
1004510051
int i;
1004610052

1004710053
WARN_ON_ONCE(atomic_read(&mlxsw_sp->router->rifs_count));
10048-
for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++)
10054+
for (i = 0; i < max_rifs; i++)
1004910055
WARN_ON_ONCE(mlxsw_sp->router->rifs[i]);
1005010056

1005110057
devl_resource_occ_get_unregister(devlink, MLXSW_SP_RESOURCE_RIFS);

tools/testing/selftests/drivers/net/mlxsw/egress_vid_classification.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
# +----------------|--+ +--|-----------------+
1717
# | |
1818
# +----------------|-------------------------|-----------------+
19-
# | SW | | |
19+
# | SW $swp1 + + $swp2 |
20+
# | | | |
2021
# | +--------------|-------------------------|---------------+ |
21-
# | | $swp1 + + $swp2 | |
22-
# | | | | | |
2322
# | | $swp1.10 + + $swp2.10 | |
2423
# | | | |
2524
# | | br0 | |

tools/testing/selftests/drivers/net/mlxsw/ingress_rif_conf_1d.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
# +----------------|--+ +--|-----------------+
1616
# | |
1717
# +----------------|-------------------------|-----------------+
18-
# | SW | | |
18+
# | SW $swp1 + + $swp2 |
19+
# | | | |
1920
# | +--------------|-------------------------|---------------+ |
20-
# | | $swp1 + + $swp2 | |
21-
# | | | | | |
2221
# | | $swp1.10 + + $swp2.10 | |
2322
# | | | |
2423
# | | br0 | |

tools/testing/selftests/net/forwarding/router_bridge_vlan.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4+
# +------------------------+ +----------------------+
5+
# | H1 (vrf) | | H2 (vrf) |
6+
# | + $h1.555 | | + $h2 |
7+
# | | 192.0.2.1/28 | | | 192.0.2.130/28 |
8+
# | | 2001:db8:1::1/64 | | | 2001:db8:2::2/64 |
9+
# | | | | | |
10+
# | + $h1 | | | |
11+
# +----|-------------------+ +--|-------------------+
12+
# | |
13+
# +----|--------------------------------------------------|-------------------+
14+
# | SW | | |
15+
# | +--|-------------------------------+ + $swp2 |
16+
# | | + $swp1 | 192.0.2.129/28 |
17+
# | | vid 555 | 2001:db8:2::1/64 |
18+
# | | | |
19+
# | | + BR1 (802.1q) | |
20+
# | | vid 555 pvid untagged | |
21+
# | | 192.0.2.2/28 | |
22+
# | | 2001:db8:1::2/64 | |
23+
# | +----------------------------------+ |
24+
# +---------------------------------------------------------------------------+
25+
426
ALL_TESTS="
527
ping_ipv4
628
ping_ipv6
@@ -41,7 +63,7 @@ h2_destroy()
4163

4264
router_create()
4365
{
44-
ip link add name br1 type bridge vlan_filtering 1
66+
ip link add name br1 type bridge vlan_filtering 1 vlan_default_pvid 0
4567
ip link set dev br1 up
4668

4769
ip link set dev $swp1 master br1

0 commit comments

Comments
 (0)