mlxsw: spectrum: Export RALUE pack helper and use it from IPIP
authorJiri Pirko <jiri@nvidia.com>
Tue, 10 Nov 2020 09:48:51 +0000 (11:48 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 12 Nov 2020 23:55:20 +0000 (15:55 -0800)
As the RALUE packing is going to be put into op, make the user from
IPIP code use the same helper as the router code does.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h

index f8b9b5b..0f00643 100644 (file)
@@ -188,22 +188,9 @@ mlxsw_sp_ipip_fib_entry_op_gre4_ralue(struct mlxsw_sp *mlxsw_sp,
                                      u32 tunnel_index)
 {
        char *ralue_pl = op_ctx->ralue_pl;
-       enum mlxsw_reg_ralue_op ralue_op;
-
-       switch (op) {
-       case MLXSW_SP_FIB_ENTRY_OP_WRITE:
-               ralue_op = MLXSW_REG_RALUE_OP_WRITE_WRITE;
-               break;
-       case MLXSW_SP_FIB_ENTRY_OP_DELETE:
-               ralue_op = MLXSW_REG_RALUE_OP_WRITE_DELETE;
-               break;
-       default:
-               WARN_ON_ONCE(1);
-               return -EINVAL;
-       }
 
-       mlxsw_reg_ralue_pack4(ralue_pl, MLXSW_REG_RALXX_PROTOCOL_IPV4, ralue_op,
-                             ul_vr_id, prefix_len, dip);
+       mlxsw_sp_fib_entry_ralue_pack(ralue_pl, MLXSW_SP_L3_PROTO_IPV4, op,
+                                     ul_vr_id, prefix_len, (unsigned char *) &dip);
        mlxsw_reg_ralue_act_ip2me_tun_pack(ralue_pl, tunnel_index);
        return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ralue), ralue_pl);
 }
index cf186f1..3ed9bd4 100644 (file)
@@ -4307,7 +4307,7 @@ mlxsw_sp_fib_entry_hw_flags_refresh(struct mlxsw_sp *mlxsw_sp,
        }
 }
 
-static void
+void
 mlxsw_sp_fib_entry_ralue_pack(char *ralue_pl, enum mlxsw_sp_l3proto proto,
                              enum mlxsw_sp_fib_entry_op op, u16 virtual_router,
                              u8 prefix_len, unsigned char *addr)
index 963825d..1b071f8 100644 (file)
@@ -173,4 +173,9 @@ static inline bool mlxsw_sp_l3addr_eq(const union mlxsw_sp_l3addr *addr1,
 int mlxsw_sp_ipip_ecn_encap_init(struct mlxsw_sp *mlxsw_sp);
 int mlxsw_sp_ipip_ecn_decap_init(struct mlxsw_sp *mlxsw_sp);
 
+void
+mlxsw_sp_fib_entry_ralue_pack(char *ralue_pl, enum mlxsw_sp_l3proto proto,
+                             enum mlxsw_sp_fib_entry_op op, u16 virtual_router,
+                             u8 prefix_len, unsigned char *addr);
+
 #endif /* _MLXSW_ROUTER_H_*/