mlxsw: spectrum_router: Add support for ipv6 hash policy update
authorDavid Ahern <dsahern@gmail.com>
Fri, 2 Mar 2018 16:32:19 +0000 (08:32 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 4 Mar 2018 18:04:23 +0000 (13:04 -0500)
Similar to 28678f07f127d ("mlxsw: spectrum_router: Update multipath hash
parameters upon netevents") for IPv4, make sure the kernel and asic are
using the same hash algorithm for path selection.

Signed-off-by: David Ahern <dsahern@gmail.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Tested-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index 93d48c1b2bf832f03fa826557f21fdeb33689096..a8a578610a7bf7f7787711802cba6add891c6511 100644 (file)
@@ -2431,6 +2431,7 @@ static int mlxsw_sp_router_netevent_event(struct notifier_block *nb,
                mlxsw_sp_port_dev_put(mlxsw_sp_port);
                break;
        case NETEVENT_IPV4_MPATH_HASH_UPDATE:
+       case NETEVENT_IPV6_MPATH_HASH_UPDATE:
                net = ptr;
 
                if (!net_eq(net, &init_net))
@@ -7030,13 +7031,25 @@ static void mlxsw_sp_mp4_hash_init(char *recr2_pl)
 
 static void mlxsw_sp_mp6_hash_init(char *recr2_pl)
 {
+       bool only_l3 = !init_net.ipv6.sysctl.multipath_hash_policy;
+
        mlxsw_sp_mp_hash_header_set(recr2_pl,
                                    MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP);
        mlxsw_sp_mp_hash_header_set(recr2_pl, MLXSW_REG_RECR2_IPV6_EN_TCP_UDP);
        mlxsw_reg_recr2_ipv6_sip_enable(recr2_pl);
        mlxsw_reg_recr2_ipv6_dip_enable(recr2_pl);
-       mlxsw_sp_mp_hash_field_set(recr2_pl, MLXSW_REG_RECR2_IPV6_FLOW_LABEL);
        mlxsw_sp_mp_hash_field_set(recr2_pl, MLXSW_REG_RECR2_IPV6_NEXT_HEADER);
+       if (only_l3) {
+               mlxsw_sp_mp_hash_field_set(recr2_pl,
+                                          MLXSW_REG_RECR2_IPV6_FLOW_LABEL);
+       } else {
+               mlxsw_sp_mp_hash_header_set(recr2_pl,
+                                           MLXSW_REG_RECR2_TCP_UDP_EN_IPV6);
+               mlxsw_sp_mp_hash_field_set(recr2_pl,
+                                          MLXSW_REG_RECR2_TCP_UDP_SPORT);
+               mlxsw_sp_mp_hash_field_set(recr2_pl,
+                                          MLXSW_REG_RECR2_TCP_UDP_DPORT);
+       }
 }
 
 static int mlxsw_sp_mp_hash_init(struct mlxsw_sp *mlxsw_sp)