mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-07 06:50:43 -04:00
mlxsw: Convert does-RIF-have-this-netdev queries to a dedicated helper
In a number of places, a netdevice underlying a RIF is obtained only to compare it to another pointer. In order to clean up the interface between the router and the other modules, add a new helper to specifically answer this question, and convert the relevant uses to this new interface. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Amit Cohen <amcohen@nvidia.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
0255f74845
commit
5374a50f2e
@@ -704,12 +704,12 @@ void mlxsw_sp_mr_vif_del(struct mlxsw_sp_mr_table *mr_table, vifi_t vif_index)
|
||||
|
||||
static struct mlxsw_sp_mr_vif *
|
||||
mlxsw_sp_mr_dev_vif_lookup(struct mlxsw_sp_mr_table *mr_table,
|
||||
const struct net_device *dev)
|
||||
const struct mlxsw_sp_rif *rif)
|
||||
{
|
||||
vifi_t vif_index;
|
||||
|
||||
for (vif_index = 0; vif_index < MAXVIFS; vif_index++)
|
||||
if (mr_table->vifs[vif_index].dev == dev)
|
||||
if (mlxsw_sp_rif_dev_is(rif, mr_table->vifs[vif_index].dev))
|
||||
return &mr_table->vifs[vif_index];
|
||||
return NULL;
|
||||
}
|
||||
@@ -717,13 +717,12 @@ mlxsw_sp_mr_dev_vif_lookup(struct mlxsw_sp_mr_table *mr_table,
|
||||
int mlxsw_sp_mr_rif_add(struct mlxsw_sp_mr_table *mr_table,
|
||||
const struct mlxsw_sp_rif *rif)
|
||||
{
|
||||
const struct net_device *rif_dev = mlxsw_sp_rif_dev(rif);
|
||||
struct mlxsw_sp_mr_vif *mr_vif;
|
||||
|
||||
if (!mlxsw_sp_rif_has_dev(rif))
|
||||
return 0;
|
||||
|
||||
mr_vif = mlxsw_sp_mr_dev_vif_lookup(mr_table, rif_dev);
|
||||
mr_vif = mlxsw_sp_mr_dev_vif_lookup(mr_table, rif);
|
||||
if (!mr_vif)
|
||||
return 0;
|
||||
return mlxsw_sp_mr_vif_resolve(mr_table, mr_vif->dev, mr_vif,
|
||||
@@ -733,13 +732,12 @@ int mlxsw_sp_mr_rif_add(struct mlxsw_sp_mr_table *mr_table,
|
||||
void mlxsw_sp_mr_rif_del(struct mlxsw_sp_mr_table *mr_table,
|
||||
const struct mlxsw_sp_rif *rif)
|
||||
{
|
||||
const struct net_device *rif_dev = mlxsw_sp_rif_dev(rif);
|
||||
struct mlxsw_sp_mr_vif *mr_vif;
|
||||
|
||||
if (!mlxsw_sp_rif_has_dev(rif))
|
||||
return;
|
||||
|
||||
mr_vif = mlxsw_sp_mr_dev_vif_lookup(mr_table, rif_dev);
|
||||
mr_vif = mlxsw_sp_mr_dev_vif_lookup(mr_table, rif);
|
||||
if (!mr_vif)
|
||||
return;
|
||||
mlxsw_sp_mr_vif_unresolve(mr_table, mr_vif->dev, mr_vif);
|
||||
@@ -748,7 +746,6 @@ void mlxsw_sp_mr_rif_del(struct mlxsw_sp_mr_table *mr_table,
|
||||
void mlxsw_sp_mr_rif_mtu_update(struct mlxsw_sp_mr_table *mr_table,
|
||||
const struct mlxsw_sp_rif *rif, int mtu)
|
||||
{
|
||||
const struct net_device *rif_dev = mlxsw_sp_rif_dev(rif);
|
||||
struct mlxsw_sp *mlxsw_sp = mr_table->mlxsw_sp;
|
||||
struct mlxsw_sp_mr_route_vif_entry *rve;
|
||||
struct mlxsw_sp_mr *mr = mlxsw_sp->mr;
|
||||
@@ -758,7 +755,7 @@ void mlxsw_sp_mr_rif_mtu_update(struct mlxsw_sp_mr_table *mr_table,
|
||||
return;
|
||||
|
||||
/* Search for a VIF that use that RIF */
|
||||
mr_vif = mlxsw_sp_mr_dev_vif_lookup(mr_table, rif_dev);
|
||||
mr_vif = mlxsw_sp_mr_dev_vif_lookup(mr_table, rif);
|
||||
if (!mr_vif)
|
||||
return;
|
||||
|
||||
|
||||
@@ -7705,7 +7705,7 @@ mlxsw_sp_rif_find_by_dev(const struct mlxsw_sp *mlxsw_sp,
|
||||
|
||||
for (i = 0; i < max_rifs; i++)
|
||||
if (mlxsw_sp->router->rifs[i] &&
|
||||
mlxsw_sp->router->rifs[i]->dev == dev)
|
||||
mlxsw_sp_rif_dev_is(mlxsw_sp->router->rifs[i], dev))
|
||||
return mlxsw_sp->router->rifs[i];
|
||||
|
||||
return NULL;
|
||||
@@ -8085,6 +8085,12 @@ bool mlxsw_sp_rif_has_dev(const struct mlxsw_sp_rif *rif)
|
||||
return !!mlxsw_sp_rif_dev(rif);
|
||||
}
|
||||
|
||||
bool mlxsw_sp_rif_dev_is(const struct mlxsw_sp_rif *rif,
|
||||
const struct net_device *dev)
|
||||
{
|
||||
return mlxsw_sp_rif_dev(rif) == dev;
|
||||
}
|
||||
|
||||
static void mlxsw_sp_rif_push_l3_stats(struct mlxsw_sp_rif *rif)
|
||||
{
|
||||
struct rtnl_hw_stats64 stats = {};
|
||||
|
||||
@@ -95,6 +95,8 @@ u32 mlxsw_sp_ipip_dev_ul_tb_id(const struct net_device *ol_dev);
|
||||
int mlxsw_sp_rif_dev_ifindex(const struct mlxsw_sp_rif *rif);
|
||||
const struct net_device *mlxsw_sp_rif_dev(const struct mlxsw_sp_rif *rif);
|
||||
bool mlxsw_sp_rif_has_dev(const struct mlxsw_sp_rif *rif);
|
||||
bool mlxsw_sp_rif_dev_is(const struct mlxsw_sp_rif *rif,
|
||||
const struct net_device *dev);
|
||||
int mlxsw_sp_rif_counter_value_get(struct mlxsw_sp *mlxsw_sp,
|
||||
struct mlxsw_sp_rif *rif,
|
||||
enum mlxsw_sp_rif_counter_dir dir,
|
||||
|
||||
Reference in New Issue
Block a user