mlxsw: spectrum_router: Reduce mlxsw_sp_ipip_fib_entry_op_gre4()
authorJiri Pirko <jiri@nvidia.com>
Sun, 6 Dec 2020 08:22:27 +0000 (10:22 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Dec 2020 03:22:14 +0000 (19:22 -0800)
Turned out that mlxsw_sp_ipip_fib_entry_op_gre4() does not need to
figure out the IP address and virtual router id. Those are exactly
the same as in the fib_entry it is called for. So just use that and
reduce mlxsw_sp_ipip_fib_entry_op_gre4() function to only call
mlxsw_sp_ipip_fib_entry_op_gre4_rtdp() make the ipip decap op
code similar to nve.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h

index 089d995..6ccca39 100644 (file)
@@ -142,9 +142,9 @@ mlxsw_sp_ipip_nexthop_update_gre4(struct mlxsw_sp *mlxsw_sp, u32 adj_index,
 }
 
 static int
-mlxsw_sp_ipip_fib_entry_op_gre4_rtdp(struct mlxsw_sp *mlxsw_sp,
-                                    u32 tunnel_index,
-                                    struct mlxsw_sp_ipip_entry *ipip_entry)
+mlxsw_sp_ipip_decap_config_gre4(struct mlxsw_sp *mlxsw_sp,
+                               struct mlxsw_sp_ipip_entry *ipip_entry,
+                               u32 tunnel_index)
 {
        u16 rif_index = mlxsw_sp_ipip_lb_rif_index(ipip_entry->ol_lb);
        u16 ul_rif_id = mlxsw_sp_ipip_lb_ul_rif_id(ipip_entry->ol_lb);
@@ -180,43 +180,6 @@ mlxsw_sp_ipip_fib_entry_op_gre4_rtdp(struct mlxsw_sp *mlxsw_sp,
        return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rtdp), rtdp_pl);
 }
 
-static int
-mlxsw_sp_ipip_fib_entry_op_gre4_do(struct mlxsw_sp *mlxsw_sp,
-                                  const struct mlxsw_sp_router_ll_ops *ll_ops,
-                                  struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
-                                  u32 dip, u8 prefix_len, u16 ul_vr_id,
-                                  enum mlxsw_sp_fib_entry_op op,
-                                  u32 tunnel_index,
-                                  struct mlxsw_sp_fib_entry_priv *priv)
-{
-       ll_ops->fib_entry_pack(op_ctx, MLXSW_SP_L3_PROTO_IPV4, op, ul_vr_id,
-                              prefix_len, (unsigned char *) &dip, priv);
-       ll_ops->fib_entry_act_ip2me_tun_pack(op_ctx, tunnel_index);
-       return mlxsw_sp_fib_entry_commit(mlxsw_sp, op_ctx, ll_ops);
-}
-
-static int mlxsw_sp_ipip_fib_entry_op_gre4(struct mlxsw_sp *mlxsw_sp,
-                                          const struct mlxsw_sp_router_ll_ops *ll_ops,
-                                          struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
-                                          struct mlxsw_sp_ipip_entry *ipip_entry,
-                                          enum mlxsw_sp_fib_entry_op op, u32 tunnel_index,
-                                          struct mlxsw_sp_fib_entry_priv *priv)
-{
-       u16 ul_vr_id = mlxsw_sp_ipip_lb_ul_vr_id(ipip_entry->ol_lb);
-       __be32 dip;
-       int err;
-
-       err = mlxsw_sp_ipip_fib_entry_op_gre4_rtdp(mlxsw_sp, tunnel_index,
-                                                  ipip_entry);
-       if (err)
-               return err;
-
-       dip = mlxsw_sp_ipip_netdev_saddr(MLXSW_SP_L3_PROTO_IPV4,
-                                        ipip_entry->ol_dev).addr4;
-       return mlxsw_sp_ipip_fib_entry_op_gre4_do(mlxsw_sp, ll_ops, op_ctx, be32_to_cpu(dip),
-                                                 32, ul_vr_id, op, tunnel_index, priv);
-}
-
 static bool mlxsw_sp_ipip_tunnel_complete(enum mlxsw_sp_l3proto proto,
                                          const struct net_device *ol_dev)
 {
@@ -332,7 +295,7 @@ static const struct mlxsw_sp_ipip_ops mlxsw_sp_ipip_gre4_ops = {
        .dev_type = ARPHRD_IPGRE,
        .ul_proto = MLXSW_SP_L3_PROTO_IPV4,
        .nexthop_update = mlxsw_sp_ipip_nexthop_update_gre4,
-       .fib_entry_op = mlxsw_sp_ipip_fib_entry_op_gre4,
+       .decap_config = mlxsw_sp_ipip_decap_config_gre4,
        .can_offload = mlxsw_sp_ipip_can_offload_gre4,
        .ol_loopback_config = mlxsw_sp_ipip_ol_loopback_config_gre4,
        .ol_netdev_change = mlxsw_sp_ipip_ol_netdev_change_gre4,
index d32702c..87bef98 100644 (file)
@@ -50,13 +50,9 @@ struct mlxsw_sp_ipip_ops {
        (*ol_loopback_config)(struct mlxsw_sp *mlxsw_sp,
                              const struct net_device *ol_dev);
 
-       int (*fib_entry_op)(struct mlxsw_sp *mlxsw_sp,
-                           const struct mlxsw_sp_router_ll_ops *ll_ops,
-                           struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
+       int (*decap_config)(struct mlxsw_sp *mlxsw_sp,
                            struct mlxsw_sp_ipip_entry *ipip_entry,
-                           enum mlxsw_sp_fib_entry_op op,
-                           u32 tunnel_index,
-                           struct mlxsw_sp_fib_entry_priv *priv);
+                           u32 tunnel_index);
 
        int (*ol_netdev_change)(struct mlxsw_sp *mlxsw_sp,
                                struct mlxsw_sp_ipip_entry *ipip_entry,
index 20b141f..d671d96 100644 (file)
@@ -5142,9 +5142,9 @@ static void mlxsw_sp_fib_entry_pack(struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
                                    fib_entry->priv);
 }
 
-int mlxsw_sp_fib_entry_commit(struct mlxsw_sp *mlxsw_sp,
-                             struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
-                             const struct mlxsw_sp_router_ll_ops *ll_ops)
+static int mlxsw_sp_fib_entry_commit(struct mlxsw_sp *mlxsw_sp,
+                                    struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
+                                    const struct mlxsw_sp_router_ll_ops *ll_ops)
 {
        bool postponed_for_bulk = false;
        int err;
@@ -5307,13 +5307,21 @@ mlxsw_sp_fib_entry_op_ipip_decap(struct mlxsw_sp *mlxsw_sp,
        const struct mlxsw_sp_router_ll_ops *ll_ops = fib_entry->fib_node->fib->ll_ops;
        struct mlxsw_sp_ipip_entry *ipip_entry = fib_entry->decap.ipip_entry;
        const struct mlxsw_sp_ipip_ops *ipip_ops;
+       int err;
 
        if (WARN_ON(!ipip_entry))
                return -EINVAL;
 
        ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt];
-       return ipip_ops->fib_entry_op(mlxsw_sp, ll_ops, op_ctx, ipip_entry, op,
-                                     fib_entry->decap.tunnel_index, fib_entry->priv);
+       err = ipip_ops->decap_config(mlxsw_sp, ipip_entry,
+                                    fib_entry->decap.tunnel_index);
+       if (err)
+               return err;
+
+       mlxsw_sp_fib_entry_pack(op_ctx, fib_entry, op);
+       ll_ops->fib_entry_act_ip2me_tun_pack(op_ctx,
+                                            fib_entry->decap.tunnel_index);
+       return mlxsw_sp_fib_entry_commit(mlxsw_sp, op_ctx, ll_ops);
 }
 
 static int mlxsw_sp_fib_entry_op_nve_decap(struct mlxsw_sp *mlxsw_sp,
index 96d8bf7..d8aed86 100644 (file)
@@ -118,10 +118,6 @@ struct mlxsw_sp_router_ll_ops {
        bool (*fib_entry_is_committed)(struct mlxsw_sp_fib_entry_priv *priv);
 };
 
-int mlxsw_sp_fib_entry_commit(struct mlxsw_sp *mlxsw_sp,
-                             struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
-                             const struct mlxsw_sp_router_ll_ops *ll_ops);
-
 struct mlxsw_sp_rif_ipip_lb;
 struct mlxsw_sp_rif_ipip_lb_config {
        enum mlxsw_reg_ritr_loopback_ipip_type lb_ipipt;