[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210322155855.3164151-10-idosch@idosch.org>
Date: Mon, 22 Mar 2021 17:58:50 +0200
From: Ido Schimmel <idosch@...sch.org>
To: netdev@...r.kernel.org
Cc: davem@...emloft.net, kuba@...nel.org, jiri@...dia.com,
petrm@...dia.com, dsahern@...il.com, mlxsw@...dia.com,
Ido Schimmel <idosch@...dia.com>
Subject: [PATCH net-next 09/14] mlxsw: spectrum_router: Encapsulate nexthop update in a function
From: Ido Schimmel <idosch@...dia.com>
Encapsulate this functionality in a separate function, so that it could
be invoked by follow-up patches, when replacing a nexthop bucket that is
part of a resilient nexthop group.
Signed-off-by: Ido Schimmel <idosch@...dia.com>
Reviewed-by: Petr Machata <petrm@...dia.com>
---
.../ethernet/mellanox/mlxsw/spectrum_router.c | 28 ++++++++++---------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 1f1f8af63ef7..6be225ec1997 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -3491,6 +3491,20 @@ static int mlxsw_sp_nexthop_ipip_update(struct mlxsw_sp *mlxsw_sp,
return 0;
}
+static int mlxsw_sp_nexthop_update(struct mlxsw_sp *mlxsw_sp, u32 adj_index,
+ struct mlxsw_sp_nexthop *nh)
+{
+ /* When action is discard or trap, the nexthop must be
+ * programmed as an Ethernet nexthop.
+ */
+ if (nh->type == MLXSW_SP_NEXTHOP_TYPE_ETH ||
+ nh->action == MLXSW_SP_NEXTHOP_ACTION_DISCARD ||
+ nh->action == MLXSW_SP_NEXTHOP_ACTION_TRAP)
+ return mlxsw_sp_nexthop_eth_update(mlxsw_sp, adj_index, nh);
+ else
+ return mlxsw_sp_nexthop_ipip_update(mlxsw_sp, adj_index, nh);
+}
+
static int
mlxsw_sp_nexthop_group_update(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_nexthop_group_info *nhgi,
@@ -3511,19 +3525,7 @@ mlxsw_sp_nexthop_group_update(struct mlxsw_sp *mlxsw_sp,
if (nh->update || reallocate) {
int err = 0;
- /* When action is discard or trap, the nexthop must be
- * programmed as an Ethernet nexthop.
- */
- if (nh->type == MLXSW_SP_NEXTHOP_TYPE_ETH ||
- nh->action == MLXSW_SP_NEXTHOP_ACTION_DISCARD ||
- nh->action == MLXSW_SP_NEXTHOP_ACTION_TRAP)
- err = mlxsw_sp_nexthop_eth_update(mlxsw_sp,
- adj_index,
- nh);
- else
- err = mlxsw_sp_nexthop_ipip_update(mlxsw_sp,
- adj_index,
- nh);
+ err = mlxsw_sp_nexthop_update(mlxsw_sp, adj_index, nh);
if (err)
return err;
nh->update = 0;
--
2.29.2
Powered by blists - more mailing lists