Skip to content

Commit

Permalink
mlxsw: spectrum_fid: Implement missing operations for rFID and dummy FID
Browse files Browse the repository at this point in the history
rFID and dummy FID do not support FID->VNI mapping. Currently, these
families do not implement the vni_{set, clear}() operations. Instead, there
is a check if these functions are implemented.

Similarly, 'SFMR.nve_tunnel_flood_ptr' is not relevant for rFID and dummy
FID, therefore, these families do not implement
nve_flood_index_{set, clear}().

Align the behavior to other unsupported operations, implement the functions
and just return an error or warn. Then, checks like '!ops->vni_set' can be
removed.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Amit Cohen authored and David S. Miller committed Jun 22, 2022
1 parent 784763e commit 048fcbb
Showing 1 changed file with 54 additions and 4 deletions.
58 changes: 54 additions & 4 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ int mlxsw_sp_fid_nve_flood_index_set(struct mlxsw_sp_fid *fid,
const struct mlxsw_sp_fid_ops *ops = fid_family->ops;
int err;

if (WARN_ON(!ops->nve_flood_index_set || fid->nve_flood_index_valid))
if (WARN_ON(fid->nve_flood_index_valid))
return -EINVAL;

err = ops->nve_flood_index_set(fid, nve_flood_index);
Expand All @@ -219,7 +219,7 @@ void mlxsw_sp_fid_nve_flood_index_clear(struct mlxsw_sp_fid *fid)
struct mlxsw_sp_fid_family *fid_family = fid->fid_family;
const struct mlxsw_sp_fid_ops *ops = fid_family->ops;

if (WARN_ON(!ops->nve_flood_index_clear || !fid->nve_flood_index_valid))
if (WARN_ON(!fid->nve_flood_index_valid))
return;

fid->nve_flood_index_valid = false;
Expand All @@ -239,7 +239,7 @@ int mlxsw_sp_fid_vni_set(struct mlxsw_sp_fid *fid, enum mlxsw_sp_nve_type type,
struct mlxsw_sp *mlxsw_sp = fid_family->mlxsw_sp;
int err;

if (WARN_ON(!ops->vni_set || fid->vni_valid))
if (WARN_ON(fid->vni_valid))
return -EINVAL;

fid->nve_type = type;
Expand Down Expand Up @@ -271,7 +271,7 @@ void mlxsw_sp_fid_vni_clear(struct mlxsw_sp_fid *fid)
const struct mlxsw_sp_fid_ops *ops = fid_family->ops;
struct mlxsw_sp *mlxsw_sp = fid_family->mlxsw_sp;

if (WARN_ON(!ops->vni_clear || !fid->vni_valid))
if (WARN_ON(!fid->vni_valid))
return;

fid->vni_valid = false;
Expand Down Expand Up @@ -820,6 +820,27 @@ mlxsw_sp_fid_rfid_port_vid_unmap(struct mlxsw_sp_fid *fid,
mlxsw_sp->fid_core->port_fid_mappings[local_port]--;
}

static int mlxsw_sp_fid_rfid_vni_set(struct mlxsw_sp_fid *fid, __be32 vni)
{
return -EOPNOTSUPP;
}

static void mlxsw_sp_fid_rfid_vni_clear(struct mlxsw_sp_fid *fid)
{
WARN_ON_ONCE(1);
}

static int mlxsw_sp_fid_rfid_nve_flood_index_set(struct mlxsw_sp_fid *fid,
u32 nve_flood_index)
{
return -EOPNOTSUPP;
}

static void mlxsw_sp_fid_rfid_nve_flood_index_clear(struct mlxsw_sp_fid *fid)
{
WARN_ON_ONCE(1);
}

static const struct mlxsw_sp_fid_ops mlxsw_sp_fid_rfid_ops = {
.setup = mlxsw_sp_fid_rfid_setup,
.configure = mlxsw_sp_fid_rfid_configure,
Expand All @@ -828,6 +849,10 @@ static const struct mlxsw_sp_fid_ops mlxsw_sp_fid_rfid_ops = {
.compare = mlxsw_sp_fid_rfid_compare,
.port_vid_map = mlxsw_sp_fid_rfid_port_vid_map,
.port_vid_unmap = mlxsw_sp_fid_rfid_port_vid_unmap,
.vni_set = mlxsw_sp_fid_rfid_vni_set,
.vni_clear = mlxsw_sp_fid_rfid_vni_clear,
.nve_flood_index_set = mlxsw_sp_fid_rfid_nve_flood_index_set,
.nve_flood_index_clear = mlxsw_sp_fid_rfid_nve_flood_index_clear,
};

#define MLXSW_SP_RFID_BASE (15 * 1024)
Expand Down Expand Up @@ -874,12 +899,37 @@ static bool mlxsw_sp_fid_dummy_compare(const struct mlxsw_sp_fid *fid,
return true;
}

static int mlxsw_sp_fid_dummy_vni_set(struct mlxsw_sp_fid *fid, __be32 vni)
{
return -EOPNOTSUPP;
}

static void mlxsw_sp_fid_dummy_vni_clear(struct mlxsw_sp_fid *fid)
{
WARN_ON_ONCE(1);
}

static int mlxsw_sp_fid_dummy_nve_flood_index_set(struct mlxsw_sp_fid *fid,
u32 nve_flood_index)
{
return -EOPNOTSUPP;
}

static void mlxsw_sp_fid_dummy_nve_flood_index_clear(struct mlxsw_sp_fid *fid)
{
WARN_ON_ONCE(1);
}

static const struct mlxsw_sp_fid_ops mlxsw_sp_fid_dummy_ops = {
.setup = mlxsw_sp_fid_dummy_setup,
.configure = mlxsw_sp_fid_dummy_configure,
.deconfigure = mlxsw_sp_fid_dummy_deconfigure,
.index_alloc = mlxsw_sp_fid_dummy_index_alloc,
.compare = mlxsw_sp_fid_dummy_compare,
.vni_set = mlxsw_sp_fid_dummy_vni_set,
.vni_clear = mlxsw_sp_fid_dummy_vni_clear,
.nve_flood_index_set = mlxsw_sp_fid_dummy_nve_flood_index_set,
.nve_flood_index_clear = mlxsw_sp_fid_dummy_nve_flood_index_clear,
};

static const struct mlxsw_sp_fid_family mlxsw_sp_fid_dummy_family = {
Expand Down

0 comments on commit 048fcbb

Please sign in to comment.