Skip to content

Commit acde33b

Browse files
Jiri Pirkodavem330
authored andcommitted
mlxsw: spectrum_router: Reduce mlxsw_sp_ipip_fib_entry_op_gre4()
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 <[email protected]> Reviewed-by: Petr Machata <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f54d3c8 commit acde33b

File tree

4 files changed

+19
-56
lines changed

4 files changed

+19
-56
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ mlxsw_sp_ipip_nexthop_update_gre4(struct mlxsw_sp *mlxsw_sp, u32 adj_index,
142142
}
143143

144144
static int
145-
mlxsw_sp_ipip_fib_entry_op_gre4_rtdp(struct mlxsw_sp *mlxsw_sp,
146-
u32 tunnel_index,
147-
struct mlxsw_sp_ipip_entry *ipip_entry)
145+
mlxsw_sp_ipip_decap_config_gre4(struct mlxsw_sp *mlxsw_sp,
146+
struct mlxsw_sp_ipip_entry *ipip_entry,
147+
u32 tunnel_index)
148148
{
149149
u16 rif_index = mlxsw_sp_ipip_lb_rif_index(ipip_entry->ol_lb);
150150
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,
180180
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rtdp), rtdp_pl);
181181
}
182182

183-
static int
184-
mlxsw_sp_ipip_fib_entry_op_gre4_do(struct mlxsw_sp *mlxsw_sp,
185-
const struct mlxsw_sp_router_ll_ops *ll_ops,
186-
struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
187-
u32 dip, u8 prefix_len, u16 ul_vr_id,
188-
enum mlxsw_sp_fib_entry_op op,
189-
u32 tunnel_index,
190-
struct mlxsw_sp_fib_entry_priv *priv)
191-
{
192-
ll_ops->fib_entry_pack(op_ctx, MLXSW_SP_L3_PROTO_IPV4, op, ul_vr_id,
193-
prefix_len, (unsigned char *) &dip, priv);
194-
ll_ops->fib_entry_act_ip2me_tun_pack(op_ctx, tunnel_index);
195-
return mlxsw_sp_fib_entry_commit(mlxsw_sp, op_ctx, ll_ops);
196-
}
197-
198-
static int mlxsw_sp_ipip_fib_entry_op_gre4(struct mlxsw_sp *mlxsw_sp,
199-
const struct mlxsw_sp_router_ll_ops *ll_ops,
200-
struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
201-
struct mlxsw_sp_ipip_entry *ipip_entry,
202-
enum mlxsw_sp_fib_entry_op op, u32 tunnel_index,
203-
struct mlxsw_sp_fib_entry_priv *priv)
204-
{
205-
u16 ul_vr_id = mlxsw_sp_ipip_lb_ul_vr_id(ipip_entry->ol_lb);
206-
__be32 dip;
207-
int err;
208-
209-
err = mlxsw_sp_ipip_fib_entry_op_gre4_rtdp(mlxsw_sp, tunnel_index,
210-
ipip_entry);
211-
if (err)
212-
return err;
213-
214-
dip = mlxsw_sp_ipip_netdev_saddr(MLXSW_SP_L3_PROTO_IPV4,
215-
ipip_entry->ol_dev).addr4;
216-
return mlxsw_sp_ipip_fib_entry_op_gre4_do(mlxsw_sp, ll_ops, op_ctx, be32_to_cpu(dip),
217-
32, ul_vr_id, op, tunnel_index, priv);
218-
}
219-
220183
static bool mlxsw_sp_ipip_tunnel_complete(enum mlxsw_sp_l3proto proto,
221184
const struct net_device *ol_dev)
222185
{
@@ -332,7 +295,7 @@ static const struct mlxsw_sp_ipip_ops mlxsw_sp_ipip_gre4_ops = {
332295
.dev_type = ARPHRD_IPGRE,
333296
.ul_proto = MLXSW_SP_L3_PROTO_IPV4,
334297
.nexthop_update = mlxsw_sp_ipip_nexthop_update_gre4,
335-
.fib_entry_op = mlxsw_sp_ipip_fib_entry_op_gre4,
298+
.decap_config = mlxsw_sp_ipip_decap_config_gre4,
336299
.can_offload = mlxsw_sp_ipip_can_offload_gre4,
337300
.ol_loopback_config = mlxsw_sp_ipip_ol_loopback_config_gre4,
338301
.ol_netdev_change = mlxsw_sp_ipip_ol_netdev_change_gre4,

drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,9 @@ struct mlxsw_sp_ipip_ops {
5050
(*ol_loopback_config)(struct mlxsw_sp *mlxsw_sp,
5151
const struct net_device *ol_dev);
5252

53-
int (*fib_entry_op)(struct mlxsw_sp *mlxsw_sp,
54-
const struct mlxsw_sp_router_ll_ops *ll_ops,
55-
struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
53+
int (*decap_config)(struct mlxsw_sp *mlxsw_sp,
5654
struct mlxsw_sp_ipip_entry *ipip_entry,
57-
enum mlxsw_sp_fib_entry_op op,
58-
u32 tunnel_index,
59-
struct mlxsw_sp_fib_entry_priv *priv);
55+
u32 tunnel_index);
6056

6157
int (*ol_netdev_change)(struct mlxsw_sp *mlxsw_sp,
6258
struct mlxsw_sp_ipip_entry *ipip_entry,

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5142,9 +5142,9 @@ static void mlxsw_sp_fib_entry_pack(struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
51425142
fib_entry->priv);
51435143
}
51445144

5145-
int mlxsw_sp_fib_entry_commit(struct mlxsw_sp *mlxsw_sp,
5146-
struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
5147-
const struct mlxsw_sp_router_ll_ops *ll_ops)
5145+
static int mlxsw_sp_fib_entry_commit(struct mlxsw_sp *mlxsw_sp,
5146+
struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
5147+
const struct mlxsw_sp_router_ll_ops *ll_ops)
51485148
{
51495149
bool postponed_for_bulk = false;
51505150
int err;
@@ -5307,13 +5307,21 @@ mlxsw_sp_fib_entry_op_ipip_decap(struct mlxsw_sp *mlxsw_sp,
53075307
const struct mlxsw_sp_router_ll_ops *ll_ops = fib_entry->fib_node->fib->ll_ops;
53085308
struct mlxsw_sp_ipip_entry *ipip_entry = fib_entry->decap.ipip_entry;
53095309
const struct mlxsw_sp_ipip_ops *ipip_ops;
5310+
int err;
53105311

53115312
if (WARN_ON(!ipip_entry))
53125313
return -EINVAL;
53135314

53145315
ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt];
5315-
return ipip_ops->fib_entry_op(mlxsw_sp, ll_ops, op_ctx, ipip_entry, op,
5316-
fib_entry->decap.tunnel_index, fib_entry->priv);
5316+
err = ipip_ops->decap_config(mlxsw_sp, ipip_entry,
5317+
fib_entry->decap.tunnel_index);
5318+
if (err)
5319+
return err;
5320+
5321+
mlxsw_sp_fib_entry_pack(op_ctx, fib_entry, op);
5322+
ll_ops->fib_entry_act_ip2me_tun_pack(op_ctx,
5323+
fib_entry->decap.tunnel_index);
5324+
return mlxsw_sp_fib_entry_commit(mlxsw_sp, op_ctx, ll_ops);
53175325
}
53185326

53195327
static int mlxsw_sp_fib_entry_op_nve_decap(struct mlxsw_sp *mlxsw_sp,

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ struct mlxsw_sp_router_ll_ops {
118118
bool (*fib_entry_is_committed)(struct mlxsw_sp_fib_entry_priv *priv);
119119
};
120120

121-
int mlxsw_sp_fib_entry_commit(struct mlxsw_sp *mlxsw_sp,
122-
struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
123-
const struct mlxsw_sp_router_ll_ops *ll_ops);
124-
125121
struct mlxsw_sp_rif_ipip_lb;
126122
struct mlxsw_sp_rif_ipip_lb_config {
127123
enum mlxsw_reg_ritr_loopback_ipip_type lb_ipipt;

0 commit comments

Comments
 (0)