Skip to content

Commit 28f9d1a

Browse files
committed
Merge branch 'mlxsw-spectrum_router-Add-GRE-tunnel-support-for-Spectrum-2'
Ido Schimmel says: ==================== mlxsw: spectrum_router: Add GRE tunnel support for Spectrum-2 Nir says: In Spectrum-2, HW implementation of layer 3 tunnels differs from Spectrum-1 when it comes to the underlay routing table selection. Spectrum-2 uses a dedicated RIF that points to the virtual router used for forwarding the encapsulated packets, while Spectrum-1 explicitly specifies the virtual router itself. Patches #1 and #2 add additional fields in RITR - Router interface table register and RTDP - Routing tunnel decap properties respectively, the fields are required for the new underlay RIF needed for Spectrum-2. Patches #3-4 allow different set of RIF operations per ASIC type. The first patch splits the operations and the following patch sets RIF ops according to ASIC type. Patches #5-9 introduce small changes to existing code to allow existence of a dedicated underlay RIF along with the underlay virtual router, and to support that new type of RIF that has no device. Patch #10 takes care of updating the tunnel decap properties egress underlay RIF required for Spectrum-2. Patch #11 adds the implementation of Spectrum-2 specific RIF operations and essentially enables layer 3 GRE tunnels on Spectrum-2. Finally patches #12-18 add tests for GRE IP-in-IP tunnels, both in flat and hierarchical topologies. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 4e15cbe + eb13fea commit 28f9d1a

File tree

14 files changed

+954
-30
lines changed

14 files changed

+954
-30
lines changed

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5666,6 +5666,8 @@ enum mlxsw_reg_ritr_loopback_protocol {
56665666
MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4,
56675667
/* IPinIP IPv6 underlay Unicast */
56685668
MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6,
5669+
/* IPinIP generic - used for Spectrum-2 underlay RIF */
5670+
MLXSW_REG_RITR_LOOPBACK_GENERIC,
56695671
};
56705672

56715673
/* reg_ritr_loopback_protocol
@@ -5706,6 +5708,13 @@ MLXSW_ITEM32(reg, ritr, loopback_ipip_options, 0x10, 20, 4);
57065708
*/
57075709
MLXSW_ITEM32(reg, ritr, loopback_ipip_uvr, 0x10, 0, 16);
57085710

5711+
/* reg_ritr_loopback_ipip_underlay_rif
5712+
* Underlay ingress router interface.
5713+
* Reserved for Spectrum.
5714+
* Access: RW
5715+
*/
5716+
MLXSW_ITEM32(reg, ritr, loopback_ipip_underlay_rif, 0x14, 0, 16);
5717+
57095718
/* reg_ritr_loopback_ipip_usip*
57105719
* Encapsulation Underlay source IP.
57115720
* Access: RW
@@ -5821,24 +5830,25 @@ static inline void
58215830
mlxsw_reg_ritr_loopback_ipip_common_pack(char *payload,
58225831
enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
58235832
enum mlxsw_reg_ritr_loopback_ipip_options options,
5824-
u16 uvr_id, u32 gre_key)
5833+
u16 uvr_id, u16 underlay_rif, u32 gre_key)
58255834
{
58265835
mlxsw_reg_ritr_loopback_ipip_type_set(payload, ipip_type);
58275836
mlxsw_reg_ritr_loopback_ipip_options_set(payload, options);
58285837
mlxsw_reg_ritr_loopback_ipip_uvr_set(payload, uvr_id);
5838+
mlxsw_reg_ritr_loopback_ipip_underlay_rif_set(payload, underlay_rif);
58295839
mlxsw_reg_ritr_loopback_ipip_gre_key_set(payload, gre_key);
58305840
}
58315841

58325842
static inline void
58335843
mlxsw_reg_ritr_loopback_ipip4_pack(char *payload,
58345844
enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
58355845
enum mlxsw_reg_ritr_loopback_ipip_options options,
5836-
u16 uvr_id, u32 usip, u32 gre_key)
5846+
u16 uvr_id, u16 underlay_rif, u32 usip, u32 gre_key)
58375847
{
58385848
mlxsw_reg_ritr_loopback_protocol_set(payload,
58395849
MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4);
58405850
mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
5841-
uvr_id, gre_key);
5851+
uvr_id, underlay_rif, gre_key);
58425852
mlxsw_reg_ritr_loopback_ipip_usip4_set(payload, usip);
58435853
}
58445854

@@ -7200,6 +7210,13 @@ MLXSW_ITEM32(reg, rtdp, type, 0x00, 28, 4);
72007210
*/
72017211
MLXSW_ITEM32(reg, rtdp, tunnel_index, 0x00, 0, 24);
72027212

7213+
/* reg_rtdp_egress_router_interface
7214+
* Underlay egress router interface.
7215+
* Valid range is from 0 to cap_max_router_interfaces - 1
7216+
* Access: RW
7217+
*/
7218+
MLXSW_ITEM32(reg, rtdp, egress_router_interface, 0x40, 0, 16);
7219+
72037220
/* IPinIP */
72047221

72057222
/* reg_rtdp_ipip_irif

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4094,6 +4094,7 @@ static int mlxsw_sp1_init(struct mlxsw_core *mlxsw_core,
40944094
mlxsw_sp->acl_tcam_ops = &mlxsw_sp1_acl_tcam_ops;
40954095
mlxsw_sp->nve_ops_arr = mlxsw_sp1_nve_ops_arr;
40964096
mlxsw_sp->mac_mask = mlxsw_sp1_mac_mask;
4097+
mlxsw_sp->rif_ops_arr = mlxsw_sp1_rif_ops_arr;
40974098

40984099
return mlxsw_sp_init(mlxsw_core, mlxsw_bus_info);
40994100
}
@@ -4110,6 +4111,7 @@ static int mlxsw_sp2_init(struct mlxsw_core *mlxsw_core,
41104111
mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops;
41114112
mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr;
41124113
mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask;
4114+
mlxsw_sp->rif_ops_arr = mlxsw_sp2_rif_ops_arr;
41134115

41144116
return mlxsw_sp_init(mlxsw_core, mlxsw_bus_info);
41154117
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ enum mlxsw_sp_rif_type {
7575
MLXSW_SP_RIF_TYPE_MAX,
7676
};
7777

78+
struct mlxsw_sp_rif_ops;
79+
80+
extern const struct mlxsw_sp_rif_ops *mlxsw_sp1_rif_ops_arr[];
81+
extern const struct mlxsw_sp_rif_ops *mlxsw_sp2_rif_ops_arr[];
82+
7883
enum mlxsw_sp_fid_type {
7984
MLXSW_SP_FID_TYPE_8021Q,
8085
MLXSW_SP_FID_TYPE_8021D,
@@ -161,6 +166,7 @@ struct mlxsw_sp {
161166
const struct mlxsw_sp_mr_tcam_ops *mr_tcam_ops;
162167
const struct mlxsw_sp_acl_tcam_ops *acl_tcam_ops;
163168
const struct mlxsw_sp_nve_ops **nve_ops_arr;
169+
const struct mlxsw_sp_rif_ops **rif_ops_arr;
164170
};
165171

166172
static inline struct mlxsw_sp_upper *

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ mlxsw_sp_dpipe_table_erif_entries_dump(void *priv, bool counters_enabled,
220220
for (; i < rif_count; i++) {
221221
struct mlxsw_sp_rif *rif = mlxsw_sp_rif_by_index(mlxsw_sp, i);
222222

223-
if (!rif)
223+
if (!rif || !mlxsw_sp_rif_dev(rif))
224224
continue;
225225
err = mlxsw_sp_erif_entry_get(mlxsw_sp, &entry, rif,
226226
counters_enabled);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ mlxsw_sp_ipip_fib_entry_op_gre4_rtdp(struct mlxsw_sp *mlxsw_sp,
145145
struct mlxsw_sp_ipip_entry *ipip_entry)
146146
{
147147
u16 rif_index = mlxsw_sp_ipip_lb_rif_index(ipip_entry->ol_lb);
148+
u16 ul_rif_id = mlxsw_sp_ipip_lb_ul_rif_id(ipip_entry->ol_lb);
148149
char rtdp_pl[MLXSW_REG_RTDP_LEN];
149150
struct ip_tunnel_parm parms;
150151
unsigned int type_check;
@@ -157,6 +158,7 @@ mlxsw_sp_ipip_fib_entry_op_gre4_rtdp(struct mlxsw_sp *mlxsw_sp,
157158
ikey = mlxsw_sp_ipip_parms4_ikey(parms);
158159

159160
mlxsw_reg_rtdp_pack(rtdp_pl, MLXSW_REG_RTDP_TYPE_IPIP, tunnel_index);
161+
mlxsw_reg_rtdp_egress_router_interface_set(rtdp_pl, ul_rif_id);
160162

161163
type_check = has_ikey ?
162164
MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE_KEY :

0 commit comments

Comments
 (0)