Commit 69da40ac authored by David S. Miller's avatar David S. Miller

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 3db05776 f5136877
......@@ -96,8 +96,8 @@ struct mlxsw_sp_rif_subport {
struct mlxsw_sp_rif_ipip_lb {
struct mlxsw_sp_rif common;
struct mlxsw_sp_rif_ipip_lb_config lb_config;
u16 ul_vr_id; /* Reserved for Spectrum-2. */
u16 ul_rif_id; /* Reserved for Spectrum. */
u16 ul_vr_id; /* Spectrum-1. */
u16 ul_rif_id; /* Spectrum-2+. */
};
struct mlxsw_sp_rif_params_ipip_lb {
......@@ -748,10 +748,11 @@ static bool mlxsw_sp_vr_is_used(const struct mlxsw_sp_vr *vr)
static struct mlxsw_sp_vr *mlxsw_sp_vr_find_unused(struct mlxsw_sp *mlxsw_sp)
{
int max_vrs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS);
struct mlxsw_sp_vr *vr;
int i;
for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) {
for (i = 0; i < max_vrs; i++) {
vr = &mlxsw_sp->router->vrs[i];
if (!mlxsw_sp_vr_is_used(vr))
return vr;
......@@ -792,12 +793,13 @@ static u32 mlxsw_sp_fix_tb_id(u32 tb_id)
static struct mlxsw_sp_vr *mlxsw_sp_vr_find(struct mlxsw_sp *mlxsw_sp,
u32 tb_id)
{
int max_vrs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS);
struct mlxsw_sp_vr *vr;
int i;
tb_id = mlxsw_sp_fix_tb_id(tb_id);
for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) {
for (i = 0; i < max_vrs; i++) {
vr = &mlxsw_sp->router->vrs[i];
if (mlxsw_sp_vr_is_used(vr) && vr->tb_id == tb_id)
return vr;
......@@ -959,6 +961,7 @@ static int mlxsw_sp_vrs_lpm_tree_replace(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_fib *fib,
struct mlxsw_sp_lpm_tree *new_tree)
{
int max_vrs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS);
enum mlxsw_sp_l3proto proto = fib->proto;
struct mlxsw_sp_lpm_tree *old_tree;
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,
old_tree = mlxsw_sp->router->lpm.proto_trees[proto];
old_id = old_tree->id;
for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) {
for (i = 0; i < max_vrs; i++) {
vr = &mlxsw_sp->router->vrs[i];
if (!mlxsw_sp_vr_lpm_tree_should_replace(vr, proto, old_id))
continue;
......@@ -7298,9 +7301,10 @@ static void mlxsw_sp_vr_fib_flush(struct mlxsw_sp *mlxsw_sp,
static void mlxsw_sp_router_fib_flush(struct mlxsw_sp *mlxsw_sp)
{
int max_vrs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS);
int i, j;
for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) {
for (i = 0; i < max_vrs; i++) {
struct mlxsw_sp_vr *vr = &mlxsw_sp->router->vrs[i];
if (!mlxsw_sp_vr_is_used(vr))
......@@ -7699,9 +7703,10 @@ static struct mlxsw_sp_rif *
mlxsw_sp_rif_find_by_dev(const struct mlxsw_sp *mlxsw_sp,
const struct net_device *dev)
{
int max_rifs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS);
int i;
for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++)
for (i = 0; i < max_rifs; i++)
if (mlxsw_sp->router->rifs[i] &&
mlxsw_sp->router->rifs[i]->dev == dev)
return mlxsw_sp->router->rifs[i];
......@@ -9724,7 +9729,7 @@ mlxsw_sp1_rif_ipip_lb_configure(struct mlxsw_sp_rif *rif,
struct mlxsw_sp_vr *ul_vr;
int err;
ul_vr = mlxsw_sp_vr_get(mlxsw_sp, ul_tb_id, NULL);
ul_vr = mlxsw_sp_vr_get(mlxsw_sp, ul_tb_id, extack);
if (IS_ERR(ul_vr))
return PTR_ERR(ul_vr);
......@@ -9923,7 +9928,7 @@ mlxsw_sp2_rif_ipip_lb_configure(struct mlxsw_sp_rif *rif,
struct mlxsw_sp_rif *ul_rif;
int err;
ul_rif = mlxsw_sp_ul_rif_get(mlxsw_sp, ul_tb_id, NULL);
ul_rif = mlxsw_sp_ul_rif_get(mlxsw_sp, ul_tb_id, extack);
if (IS_ERR(ul_rif))
return PTR_ERR(ul_rif);
......@@ -10041,11 +10046,12 @@ static int mlxsw_sp_rifs_init(struct mlxsw_sp *mlxsw_sp)
static void mlxsw_sp_rifs_fini(struct mlxsw_sp *mlxsw_sp)
{
int max_rifs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS);
struct devlink *devlink = priv_to_devlink(mlxsw_sp->core);
int i;
WARN_ON_ONCE(atomic_read(&mlxsw_sp->router->rifs_count));
for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++)
for (i = 0; i < max_rifs; i++)
WARN_ON_ONCE(mlxsw_sp->router->rifs[i]);
devl_resource_occ_get_unregister(devlink, MLXSW_SP_RESOURCE_RIFS);
......
......@@ -16,10 +16,9 @@
# +----------------|--+ +--|-----------------+
# | |
# +----------------|-------------------------|-----------------+
# | SW | | |
# | SW $swp1 + + $swp2 |
# | | | |
# | +--------------|-------------------------|---------------+ |
# | | $swp1 + + $swp2 | |
# | | | | | |
# | | $swp1.10 + + $swp2.10 | |
# | | | |
# | | br0 | |
......
......@@ -15,10 +15,9 @@
# +----------------|--+ +--|-----------------+
# | |
# +----------------|-------------------------|-----------------+
# | SW | | |
# | SW $swp1 + + $swp2 |
# | | | |
# | +--------------|-------------------------|---------------+ |
# | | $swp1 + + $swp2 | |
# | | | | | |
# | | $swp1.10 + + $swp2.10 | |
# | | | |
# | | br0 | |
......
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# +------------------------+ +----------------------+
# | H1 (vrf) | | H2 (vrf) |
# | + $h1.555 | | + $h2 |
# | | 192.0.2.1/28 | | | 192.0.2.130/28 |
# | | 2001:db8:1::1/64 | | | 2001:db8:2::2/64 |
# | | | | | |
# | + $h1 | | | |
# +----|-------------------+ +--|-------------------+
# | |
# +----|--------------------------------------------------|-------------------+
# | SW | | |
# | +--|-------------------------------+ + $swp2 |
# | | + $swp1 | 192.0.2.129/28 |
# | | vid 555 | 2001:db8:2::1/64 |
# | | | |
# | | + BR1 (802.1q) | |
# | | vid 555 pvid untagged | |
# | | 192.0.2.2/28 | |
# | | 2001:db8:1::2/64 | |
# | +----------------------------------+ |
# +---------------------------------------------------------------------------+
ALL_TESTS="
ping_ipv4
ping_ipv6
......@@ -41,7 +63,7 @@ h2_destroy()
router_create()
{
ip link add name br1 type bridge vlan_filtering 1
ip link add name br1 type bridge vlan_filtering 1 vlan_default_pvid 0
ip link set dev br1 up
ip link set dev $swp1 master br1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment