Skip to content

Commit ce87a95

Browse files
committed
Merge branch 'mlxsw-add-spectrum-1-ip6gre-support'
Petr Machata says: ==================== mlxsw: Add Spectrum-1 ip6gre support Ido Schimmel writes: Currently, mlxsw only supports ip6gre offload on Spectrum-2 and newer ASICs. Spectrum-1 can also offload ip6gre tunnels, but it needs double entry router interfaces (RIFs) for the RIFs representing these tunnels. In addition, the RIF index needs to be even. This is handled in patches #1-#3. The implementation can otherwise be shared between all Spectrum generations. This is handled in patches #4-#5. Patch gregkh#6 moves a mlxsw ip6gre selftest to a shared directory, as ip6gre is no longer only supported on Spectrum-2 and newer ASICs. This work is motivated by users that require multiple GRE tunnels that all share the same underlay VRF. Currently, mlxsw only supports decapsulation based on the underlay destination IP (i.e., not taking the GRE key into account), so users need to configure these tunnels with different source IPs and IPv6 addresses are easier to spare than IPv4. Tested using existing ip6gre forwarding selftests. ==================== Link: https://lore.kernel.org/r/cover.1670414573.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 837e8ac + db40187 commit ce87a95

File tree

5 files changed

+138
-131
lines changed

5 files changed

+138
-131
lines changed

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

Lines changed: 47 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -363,93 +363,7 @@ static const struct mlxsw_sp_ipip_ops mlxsw_sp_ipip_gre4_ops = {
363363
};
364364

365365
static struct mlxsw_sp_ipip_parms
366-
mlxsw_sp1_ipip_netdev_parms_init_gre6(const struct net_device *ol_dev)
367-
{
368-
struct mlxsw_sp_ipip_parms parms = {0};
369-
370-
WARN_ON_ONCE(1);
371-
return parms;
372-
}
373-
374-
static int
375-
mlxsw_sp1_ipip_nexthop_update_gre6(struct mlxsw_sp *mlxsw_sp, u32 adj_index,
376-
struct mlxsw_sp_ipip_entry *ipip_entry,
377-
bool force, char *ratr_pl)
378-
{
379-
WARN_ON_ONCE(1);
380-
return -EINVAL;
381-
}
382-
383-
static int
384-
mlxsw_sp1_ipip_decap_config_gre6(struct mlxsw_sp *mlxsw_sp,
385-
struct mlxsw_sp_ipip_entry *ipip_entry,
386-
u32 tunnel_index)
387-
{
388-
WARN_ON_ONCE(1);
389-
return -EINVAL;
390-
}
391-
392-
static bool mlxsw_sp1_ipip_can_offload_gre6(const struct mlxsw_sp *mlxsw_sp,
393-
const struct net_device *ol_dev)
394-
{
395-
return false;
396-
}
397-
398-
static struct mlxsw_sp_rif_ipip_lb_config
399-
mlxsw_sp1_ipip_ol_loopback_config_gre6(struct mlxsw_sp *mlxsw_sp,
400-
const struct net_device *ol_dev)
401-
{
402-
struct mlxsw_sp_rif_ipip_lb_config config = {0};
403-
404-
WARN_ON_ONCE(1);
405-
return config;
406-
}
407-
408-
static int
409-
mlxsw_sp1_ipip_ol_netdev_change_gre6(struct mlxsw_sp *mlxsw_sp,
410-
struct mlxsw_sp_ipip_entry *ipip_entry,
411-
struct netlink_ext_ack *extack)
412-
{
413-
WARN_ON_ONCE(1);
414-
return -EINVAL;
415-
}
416-
417-
static int
418-
mlxsw_sp1_ipip_rem_addr_set_gre6(struct mlxsw_sp *mlxsw_sp,
419-
struct mlxsw_sp_ipip_entry *ipip_entry)
420-
{
421-
WARN_ON_ONCE(1);
422-
return -EINVAL;
423-
}
424-
425-
static void
426-
mlxsw_sp1_ipip_rem_addr_unset_gre6(struct mlxsw_sp *mlxsw_sp,
427-
const struct mlxsw_sp_ipip_entry *ipip_entry)
428-
{
429-
WARN_ON_ONCE(1);
430-
}
431-
432-
static const struct mlxsw_sp_ipip_ops mlxsw_sp1_ipip_gre6_ops = {
433-
.dev_type = ARPHRD_IP6GRE,
434-
.ul_proto = MLXSW_SP_L3_PROTO_IPV6,
435-
.inc_parsing_depth = true,
436-
.parms_init = mlxsw_sp1_ipip_netdev_parms_init_gre6,
437-
.nexthop_update = mlxsw_sp1_ipip_nexthop_update_gre6,
438-
.decap_config = mlxsw_sp1_ipip_decap_config_gre6,
439-
.can_offload = mlxsw_sp1_ipip_can_offload_gre6,
440-
.ol_loopback_config = mlxsw_sp1_ipip_ol_loopback_config_gre6,
441-
.ol_netdev_change = mlxsw_sp1_ipip_ol_netdev_change_gre6,
442-
.rem_ip_addr_set = mlxsw_sp1_ipip_rem_addr_set_gre6,
443-
.rem_ip_addr_unset = mlxsw_sp1_ipip_rem_addr_unset_gre6,
444-
};
445-
446-
const struct mlxsw_sp_ipip_ops *mlxsw_sp1_ipip_ops_arr[] = {
447-
[MLXSW_SP_IPIP_TYPE_GRE4] = &mlxsw_sp_ipip_gre4_ops,
448-
[MLXSW_SP_IPIP_TYPE_GRE6] = &mlxsw_sp1_ipip_gre6_ops,
449-
};
450-
451-
static struct mlxsw_sp_ipip_parms
452-
mlxsw_sp2_ipip_netdev_parms_init_gre6(const struct net_device *ol_dev)
366+
mlxsw_sp_ipip_netdev_parms_init_gre6(const struct net_device *ol_dev)
453367
{
454368
struct __ip6_tnl_parm parms = mlxsw_sp_ipip_netdev_parms6(ol_dev);
455369

@@ -464,9 +378,9 @@ mlxsw_sp2_ipip_netdev_parms_init_gre6(const struct net_device *ol_dev)
464378
}
465379

466380
static int
467-
mlxsw_sp2_ipip_nexthop_update_gre6(struct mlxsw_sp *mlxsw_sp, u32 adj_index,
468-
struct mlxsw_sp_ipip_entry *ipip_entry,
469-
bool force, char *ratr_pl)
381+
mlxsw_sp_ipip_nexthop_update_gre6(struct mlxsw_sp *mlxsw_sp, u32 adj_index,
382+
struct mlxsw_sp_ipip_entry *ipip_entry,
383+
bool force, char *ratr_pl)
470384
{
471385
u16 rif_index = mlxsw_sp_ipip_lb_rif_index(ipip_entry->ol_lb);
472386
enum mlxsw_reg_ratr_op op;
@@ -482,9 +396,9 @@ mlxsw_sp2_ipip_nexthop_update_gre6(struct mlxsw_sp *mlxsw_sp, u32 adj_index,
482396
}
483397

484398
static int
485-
mlxsw_sp2_ipip_decap_config_gre6(struct mlxsw_sp *mlxsw_sp,
486-
struct mlxsw_sp_ipip_entry *ipip_entry,
487-
u32 tunnel_index)
399+
mlxsw_sp_ipip_decap_config_gre6(struct mlxsw_sp *mlxsw_sp,
400+
struct mlxsw_sp_ipip_entry *ipip_entry,
401+
u32 tunnel_index)
488402
{
489403
u16 rif_index = mlxsw_sp_ipip_lb_rif_index(ipip_entry->ol_lb);
490404
u16 ul_rif_id = mlxsw_sp_ipip_lb_ul_rif_id(ipip_entry->ol_lb);
@@ -519,8 +433,8 @@ mlxsw_sp2_ipip_decap_config_gre6(struct mlxsw_sp *mlxsw_sp,
519433
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rtdp), rtdp_pl);
520434
}
521435

522-
static bool mlxsw_sp2_ipip_can_offload_gre6(const struct mlxsw_sp *mlxsw_sp,
523-
const struct net_device *ol_dev)
436+
static bool mlxsw_sp_ipip_can_offload_gre6(const struct mlxsw_sp *mlxsw_sp,
437+
const struct net_device *ol_dev)
524438
{
525439
struct __ip6_tnl_parm tparm = mlxsw_sp_ipip_netdev_parms6(ol_dev);
526440
bool inherit_tos = tparm.flags & IP6_TNL_F_USE_ORIG_TCLASS;
@@ -534,8 +448,8 @@ static bool mlxsw_sp2_ipip_can_offload_gre6(const struct mlxsw_sp *mlxsw_sp,
534448
}
535449

536450
static struct mlxsw_sp_rif_ipip_lb_config
537-
mlxsw_sp2_ipip_ol_loopback_config_gre6(struct mlxsw_sp *mlxsw_sp,
538-
const struct net_device *ol_dev)
451+
mlxsw_sp_ipip_ol_loopback_config_gre6(struct mlxsw_sp *mlxsw_sp,
452+
const struct net_device *ol_dev)
539453
{
540454
struct __ip6_tnl_parm parms = mlxsw_sp_ipip_netdev_parms6(ol_dev);
541455
enum mlxsw_reg_ritr_loopback_ipip_type lb_ipipt;
@@ -553,45 +467,65 @@ mlxsw_sp2_ipip_ol_loopback_config_gre6(struct mlxsw_sp *mlxsw_sp,
553467
}
554468

555469
static int
556-
mlxsw_sp2_ipip_ol_netdev_change_gre6(struct mlxsw_sp *mlxsw_sp,
557-
struct mlxsw_sp_ipip_entry *ipip_entry,
558-
struct netlink_ext_ack *extack)
470+
mlxsw_sp_ipip_ol_netdev_change_gre6(struct mlxsw_sp *mlxsw_sp,
471+
struct mlxsw_sp_ipip_entry *ipip_entry,
472+
struct netlink_ext_ack *extack)
559473
{
560474
struct mlxsw_sp_ipip_parms new_parms;
561475

562-
new_parms = mlxsw_sp2_ipip_netdev_parms_init_gre6(ipip_entry->ol_dev);
476+
new_parms = mlxsw_sp_ipip_netdev_parms_init_gre6(ipip_entry->ol_dev);
563477
return mlxsw_sp_ipip_ol_netdev_change_gre(mlxsw_sp, ipip_entry,
564478
&new_parms, extack);
565479
}
566480

567481
static int
568-
mlxsw_sp2_ipip_rem_addr_set_gre6(struct mlxsw_sp *mlxsw_sp,
569-
struct mlxsw_sp_ipip_entry *ipip_entry)
482+
mlxsw_sp_ipip_rem_addr_set_gre6(struct mlxsw_sp *mlxsw_sp,
483+
struct mlxsw_sp_ipip_entry *ipip_entry)
570484
{
571485
return mlxsw_sp_ipv6_addr_kvdl_index_get(mlxsw_sp,
572486
&ipip_entry->parms.daddr.addr6,
573487
&ipip_entry->dip_kvdl_index);
574488
}
575489

576490
static void
577-
mlxsw_sp2_ipip_rem_addr_unset_gre6(struct mlxsw_sp *mlxsw_sp,
578-
const struct mlxsw_sp_ipip_entry *ipip_entry)
491+
mlxsw_sp_ipip_rem_addr_unset_gre6(struct mlxsw_sp *mlxsw_sp,
492+
const struct mlxsw_sp_ipip_entry *ipip_entry)
579493
{
580494
mlxsw_sp_ipv6_addr_put(mlxsw_sp, &ipip_entry->parms.daddr.addr6);
581495
}
582496

497+
static const struct mlxsw_sp_ipip_ops mlxsw_sp1_ipip_gre6_ops = {
498+
.dev_type = ARPHRD_IP6GRE,
499+
.ul_proto = MLXSW_SP_L3_PROTO_IPV6,
500+
.inc_parsing_depth = true,
501+
.double_rif_entry = true,
502+
.parms_init = mlxsw_sp_ipip_netdev_parms_init_gre6,
503+
.nexthop_update = mlxsw_sp_ipip_nexthop_update_gre6,
504+
.decap_config = mlxsw_sp_ipip_decap_config_gre6,
505+
.can_offload = mlxsw_sp_ipip_can_offload_gre6,
506+
.ol_loopback_config = mlxsw_sp_ipip_ol_loopback_config_gre6,
507+
.ol_netdev_change = mlxsw_sp_ipip_ol_netdev_change_gre6,
508+
.rem_ip_addr_set = mlxsw_sp_ipip_rem_addr_set_gre6,
509+
.rem_ip_addr_unset = mlxsw_sp_ipip_rem_addr_unset_gre6,
510+
};
511+
512+
const struct mlxsw_sp_ipip_ops *mlxsw_sp1_ipip_ops_arr[] = {
513+
[MLXSW_SP_IPIP_TYPE_GRE4] = &mlxsw_sp_ipip_gre4_ops,
514+
[MLXSW_SP_IPIP_TYPE_GRE6] = &mlxsw_sp1_ipip_gre6_ops,
515+
};
516+
583517
static const struct mlxsw_sp_ipip_ops mlxsw_sp2_ipip_gre6_ops = {
584518
.dev_type = ARPHRD_IP6GRE,
585519
.ul_proto = MLXSW_SP_L3_PROTO_IPV6,
586520
.inc_parsing_depth = true,
587-
.parms_init = mlxsw_sp2_ipip_netdev_parms_init_gre6,
588-
.nexthop_update = mlxsw_sp2_ipip_nexthop_update_gre6,
589-
.decap_config = mlxsw_sp2_ipip_decap_config_gre6,
590-
.can_offload = mlxsw_sp2_ipip_can_offload_gre6,
591-
.ol_loopback_config = mlxsw_sp2_ipip_ol_loopback_config_gre6,
592-
.ol_netdev_change = mlxsw_sp2_ipip_ol_netdev_change_gre6,
593-
.rem_ip_addr_set = mlxsw_sp2_ipip_rem_addr_set_gre6,
594-
.rem_ip_addr_unset = mlxsw_sp2_ipip_rem_addr_unset_gre6,
521+
.parms_init = mlxsw_sp_ipip_netdev_parms_init_gre6,
522+
.nexthop_update = mlxsw_sp_ipip_nexthop_update_gre6,
523+
.decap_config = mlxsw_sp_ipip_decap_config_gre6,
524+
.can_offload = mlxsw_sp_ipip_can_offload_gre6,
525+
.ol_loopback_config = mlxsw_sp_ipip_ol_loopback_config_gre6,
526+
.ol_netdev_change = mlxsw_sp_ipip_ol_netdev_change_gre6,
527+
.rem_ip_addr_set = mlxsw_sp_ipip_rem_addr_set_gre6,
528+
.rem_ip_addr_unset = mlxsw_sp_ipip_rem_addr_unset_gre6,
595529
};
596530

597531
const struct mlxsw_sp_ipip_ops *mlxsw_sp2_ipip_ops_arr[] = {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct mlxsw_sp_ipip_ops {
4949
int dev_type;
5050
enum mlxsw_sp_l3proto ul_proto; /* Underlay. */
5151
bool inc_parsing_depth;
52+
bool double_rif_entry;
5253

5354
struct mlxsw_sp_ipip_parms
5455
(*parms_init)(const struct net_device *ol_dev);

0 commit comments

Comments
 (0)