summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c
diff options
context:
space:
mode:
authorIdo Schimmel2017-05-26 08:37:40 +0200
committerDavid S. Miller2017-05-26 21:18:49 +0200
commite4f3c1c17b6d101af5474e8c72b38aa0baaf719d (patch)
tree1b20a78bccedf560b444a2c5b3c78b970e7cc20d /drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c
parentmlxsw: spectrum: Implement common FID core (diff)
downloadkernel-qcow2-linux-e4f3c1c17b6d101af5474e8c72b38aa0baaf719d.tar.gz
kernel-qcow2-linux-e4f3c1c17b6d101af5474e8c72b38aa0baaf719d.tar.xz
kernel-qcow2-linux-e4f3c1c17b6d101af5474e8c72b38aa0baaf719d.zip
mlxsw: spectrum_router: Implement common RIF core
The mlxsw driver currently implements three types of RIFs. VLAN and FID RIFs for L3 interfaces on top of VLAN-aware and VLAN-unaware bridges (respectively) and Subport RIFs for all other L3 interfaces. All the RIF types follow a common configuration procedure, which only differs in the type-specific bits. The patch exploits this fact and consolidates the common code paths, thereby simplifying the code and making it more extensible. This work also prepares the driver for use with future ASICs, where the range of the Subport RIFs will be extended and their configuration modified accordingly. By merely implementing a new RIF operations and selecting it during initialization, the same driver could be re-used. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c')
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c
index 379bbe001dd9..c7590aea1aee 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c
@@ -205,12 +205,26 @@ void mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif)
fid->rif = rif;
}
+enum mlxsw_sp_rif_type
+mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp,
+ enum mlxsw_sp_fid_type type)
+{
+ struct mlxsw_sp_fid_core *fid_core = mlxsw_sp->fid_core;
+
+ return fid_core->fid_family_arr[type]->rif_type;
+}
+
static struct mlxsw_sp_fid_8021q *
mlxsw_sp_fid_8021q_fid(const struct mlxsw_sp_fid *fid)
{
return container_of(fid, struct mlxsw_sp_fid_8021q, common);
}
+u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid)
+{
+ return mlxsw_sp_fid_8021q_fid(fid)->vid;
+}
+
static void mlxsw_sp_fid_8021q_setup(struct mlxsw_sp_fid *fid, const void *arg)
{
u16 vid = *(u16 *) arg;
@@ -780,7 +794,7 @@ void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid)
/* Destroy the associated RIF and let it drop the last
* reference on the FID.
*/
- return mlxsw_sp_rif_destroy(fid_family->mlxsw_sp, fid->rif);
+ return mlxsw_sp_rif_destroy(fid->rif);
} else if (fid->ref_count == 0) {
list_del(&fid->list);
fid->fid_family->ops->deconfigure(fid);