@@ -1484,9 +1484,12 @@ static void tx_ft_put_policy(struct mlx5e_ipsec *ipsec, u32 prio, int type)
14841484 mutex_unlock (& tx -> ft .mutex );
14851485}
14861486
1487- static void setup_fte_addr4 (struct mlx5_flow_spec * spec , __be32 * saddr ,
1488- __be32 * daddr )
1487+ static void setup_fte_addr4 (struct mlx5_flow_spec * spec ,
1488+ struct mlx5e_ipsec_addr * addrs )
14891489{
1490+ __be32 * saddr = & addrs -> saddr .a4 ;
1491+ __be32 * daddr = & addrs -> daddr .a4 ;
1492+
14901493 if (!* saddr && !* daddr )
14911494 return ;
14921495
@@ -1510,9 +1513,12 @@ static void setup_fte_addr4(struct mlx5_flow_spec *spec, __be32 *saddr,
15101513 }
15111514}
15121515
1513- static void setup_fte_addr6 (struct mlx5_flow_spec * spec , __be32 * saddr ,
1514- __be32 * daddr )
1516+ static void setup_fte_addr6 (struct mlx5_flow_spec * spec ,
1517+ struct mlx5e_ipsec_addr * addrs )
15151518{
1519+ __be32 * saddr = addrs -> saddr .a6 ;
1520+ __be32 * daddr = addrs -> daddr .a6 ;
1521+
15161522 if (addr6_all_zero (saddr ) && addr6_all_zero (daddr ))
15171523 return ;
15181524
@@ -1722,7 +1728,7 @@ setup_pkt_tunnel_reformat(struct mlx5_core_dev *mdev,
17221728 if (attrs -> dir == XFRM_DEV_OFFLOAD_OUT ) {
17231729 bfflen += sizeof (* esp_hdr ) + 8 ;
17241730
1725- switch (attrs -> family ) {
1731+ switch (attrs -> addrs . family ) {
17261732 case AF_INET :
17271733 bfflen += sizeof (* iphdr );
17281734 break ;
@@ -1739,7 +1745,7 @@ setup_pkt_tunnel_reformat(struct mlx5_core_dev *mdev,
17391745 return - ENOMEM ;
17401746
17411747 eth_hdr = (struct ethhdr * )reformatbf ;
1742- switch (attrs -> family ) {
1748+ switch (attrs -> addrs . family ) {
17431749 case AF_INET :
17441750 eth_hdr -> h_proto = htons (ETH_P_IP );
17451751 break ;
@@ -1762,11 +1768,11 @@ setup_pkt_tunnel_reformat(struct mlx5_core_dev *mdev,
17621768 reformat_params -> param_0 = attrs -> authsize ;
17631769
17641770 hdr = reformatbf + sizeof (* eth_hdr );
1765- switch (attrs -> family ) {
1771+ switch (attrs -> addrs . family ) {
17661772 case AF_INET :
17671773 iphdr = (struct iphdr * )hdr ;
1768- memcpy (& iphdr -> saddr , & attrs -> saddr .a4 , 4 );
1769- memcpy (& iphdr -> daddr , & attrs -> daddr .a4 , 4 );
1774+ memcpy (& iphdr -> saddr , & attrs -> addrs . saddr .a4 , 4 );
1775+ memcpy (& iphdr -> daddr , & attrs -> addrs . daddr .a4 , 4 );
17701776 iphdr -> version = 4 ;
17711777 iphdr -> ihl = 5 ;
17721778 iphdr -> ttl = IPSEC_TUNNEL_DEFAULT_TTL ;
@@ -1775,8 +1781,8 @@ setup_pkt_tunnel_reformat(struct mlx5_core_dev *mdev,
17751781 break ;
17761782 case AF_INET6 :
17771783 ipv6hdr = (struct ipv6hdr * )hdr ;
1778- memcpy (& ipv6hdr -> saddr , & attrs -> saddr .a6 , 16 );
1779- memcpy (& ipv6hdr -> daddr , & attrs -> daddr .a6 , 16 );
1784+ memcpy (& ipv6hdr -> saddr , & attrs -> addrs . saddr .a6 , 16 );
1785+ memcpy (& ipv6hdr -> daddr , & attrs -> addrs . daddr .a6 , 16 );
17801786 ipv6hdr -> nexthdr = IPPROTO_ESP ;
17811787 ipv6hdr -> version = 6 ;
17821788 ipv6hdr -> hop_limit = IPSEC_TUNNEL_DEFAULT_TTL ;
@@ -1810,7 +1816,7 @@ static int get_reformat_type(struct mlx5_accel_esp_xfrm_attrs *attrs)
18101816 return MLX5_REFORMAT_TYPE_DEL_ESP_TRANSPORT_OVER_UDP ;
18111817 return MLX5_REFORMAT_TYPE_DEL_ESP_TRANSPORT ;
18121818 case XFRM_DEV_OFFLOAD_OUT :
1813- if (attrs -> family == AF_INET ) {
1819+ if (attrs -> addrs . family == AF_INET ) {
18141820 if (attrs -> encap )
18151821 return MLX5_REFORMAT_TYPE_ADD_ESP_TRANSPORT_OVER_UDPV4 ;
18161822 return MLX5_REFORMAT_TYPE_ADD_ESP_TRANSPORT_OVER_IPV4 ;
@@ -2003,7 +2009,7 @@ static int rx_add_rule(struct mlx5e_ipsec_sa_entry *sa_entry)
20032009 struct mlx5_fc * counter ;
20042010 int err = 0 ;
20052011
2006- rx = rx_ft_get (mdev , ipsec , attrs -> family , attrs -> type );
2012+ rx = rx_ft_get (mdev , ipsec , attrs -> addrs . family , attrs -> type );
20072013 if (IS_ERR (rx ))
20082014 return PTR_ERR (rx );
20092015
@@ -2013,10 +2019,10 @@ static int rx_add_rule(struct mlx5e_ipsec_sa_entry *sa_entry)
20132019 goto err_alloc ;
20142020 }
20152021
2016- if (attrs -> family == AF_INET )
2017- setup_fte_addr4 (spec , & attrs -> saddr . a4 , & attrs -> daddr . a4 );
2022+ if (attrs -> addrs . family == AF_INET )
2023+ setup_fte_addr4 (spec , & attrs -> addrs );
20182024 else
2019- setup_fte_addr6 (spec , attrs -> saddr . a6 , attrs -> daddr . a6 );
2025+ setup_fte_addr6 (spec , & attrs -> addrs );
20202026
20212027 setup_fte_spi (spec , attrs -> spi , attrs -> encap );
20222028 if (!attrs -> encap )
@@ -2116,7 +2122,7 @@ static int rx_add_rule(struct mlx5e_ipsec_sa_entry *sa_entry)
21162122err_mod_header :
21172123 kvfree (spec );
21182124err_alloc :
2119- rx_ft_put (ipsec , attrs -> family , attrs -> type );
2125+ rx_ft_put (ipsec , attrs -> addrs . family , attrs -> type );
21202126 return err ;
21212127}
21222128
@@ -2148,10 +2154,10 @@ static int tx_add_rule(struct mlx5e_ipsec_sa_entry *sa_entry)
21482154
21492155 switch (attrs -> type ) {
21502156 case XFRM_DEV_OFFLOAD_CRYPTO :
2151- if (attrs -> family == AF_INET )
2152- setup_fte_addr4 (spec , & attrs -> saddr . a4 , & attrs -> daddr . a4 );
2157+ if (attrs -> addrs . family == AF_INET )
2158+ setup_fte_addr4 (spec , & attrs -> addrs );
21532159 else
2154- setup_fte_addr6 (spec , attrs -> saddr . a6 , attrs -> daddr . a6 );
2160+ setup_fte_addr6 (spec , & attrs -> addrs );
21552161 setup_fte_spi (spec , attrs -> spi , false);
21562162 setup_fte_esp (spec );
21572163 setup_fte_reg_a (spec );
@@ -2235,10 +2241,10 @@ static int tx_add_policy(struct mlx5e_ipsec_pol_entry *pol_entry)
22352241 }
22362242
22372243 tx = ipsec_tx (ipsec , attrs -> type );
2238- if (attrs -> family == AF_INET )
2239- setup_fte_addr4 (spec , & attrs -> saddr . a4 , & attrs -> daddr . a4 );
2244+ if (attrs -> addrs . family == AF_INET )
2245+ setup_fte_addr4 (spec , & attrs -> addrs );
22402246 else
2241- setup_fte_addr6 (spec , attrs -> saddr . a6 , attrs -> daddr . a6 );
2247+ setup_fte_addr6 (spec , & attrs -> addrs );
22422248
22432249 setup_fte_no_frags (spec );
22442250 setup_fte_upper_proto_match (spec , & attrs -> upspec );
@@ -2308,23 +2314,23 @@ static int rx_add_policy(struct mlx5e_ipsec_pol_entry *pol_entry)
23082314 struct mlx5e_ipsec_rx * rx ;
23092315 int err , dstn = 0 ;
23102316
2311- ft = rx_ft_get_policy (mdev , pol_entry -> ipsec , attrs -> family , attrs -> prio ,
2312- attrs -> type );
2317+ ft = rx_ft_get_policy (mdev , pol_entry -> ipsec , attrs -> addrs . family ,
2318+ attrs -> prio , attrs -> type );
23132319 if (IS_ERR (ft ))
23142320 return PTR_ERR (ft );
23152321
2316- rx = ipsec_rx (pol_entry -> ipsec , attrs -> family , attrs -> type );
2322+ rx = ipsec_rx (pol_entry -> ipsec , attrs -> addrs . family , attrs -> type );
23172323
23182324 spec = kvzalloc (sizeof (* spec ), GFP_KERNEL );
23192325 if (!spec ) {
23202326 err = - ENOMEM ;
23212327 goto err_alloc ;
23222328 }
23232329
2324- if (attrs -> family == AF_INET )
2325- setup_fte_addr4 (spec , & attrs -> saddr . a4 , & attrs -> daddr . a4 );
2330+ if (attrs -> addrs . family == AF_INET )
2331+ setup_fte_addr4 (spec , & attrs -> addrs );
23262332 else
2327- setup_fte_addr6 (spec , attrs -> saddr . a6 , attrs -> daddr . a6 );
2333+ setup_fte_addr6 (spec , & attrs -> addrs );
23282334
23292335 setup_fte_no_frags (spec );
23302336 setup_fte_upper_proto_match (spec , & attrs -> upspec );
@@ -2364,7 +2370,8 @@ static int rx_add_policy(struct mlx5e_ipsec_pol_entry *pol_entry)
23642370err_action :
23652371 kvfree (spec );
23662372err_alloc :
2367- rx_ft_put_policy (pol_entry -> ipsec , attrs -> family , attrs -> prio , attrs -> type );
2373+ rx_ft_put_policy (pol_entry -> ipsec , attrs -> addrs .family , attrs -> prio ,
2374+ attrs -> type );
23682375 return err ;
23692376}
23702377
@@ -2638,7 +2645,8 @@ void mlx5e_accel_ipsec_fs_del_rule(struct mlx5e_ipsec_sa_entry *sa_entry)
26382645 mlx5_fc_destroy (mdev , ipsec_rule -> replay .fc );
26392646 }
26402647 mlx5_esw_ipsec_rx_id_mapping_remove (sa_entry );
2641- rx_ft_put (sa_entry -> ipsec , sa_entry -> attrs .family , sa_entry -> attrs .type );
2648+ rx_ft_put (sa_entry -> ipsec , sa_entry -> attrs .addrs .family ,
2649+ sa_entry -> attrs .type );
26422650}
26432651
26442652int mlx5e_accel_ipsec_fs_add_pol (struct mlx5e_ipsec_pol_entry * pol_entry )
@@ -2674,7 +2682,8 @@ void mlx5e_accel_ipsec_fs_del_pol(struct mlx5e_ipsec_pol_entry *pol_entry)
26742682 mlx5e_ipsec_unblock_tc_offload (pol_entry -> ipsec -> mdev );
26752683
26762684 if (pol_entry -> attrs .dir == XFRM_DEV_OFFLOAD_IN ) {
2677- rx_ft_put_policy (pol_entry -> ipsec , pol_entry -> attrs .family ,
2685+ rx_ft_put_policy (pol_entry -> ipsec ,
2686+ pol_entry -> attrs .addrs .family ,
26782687 pol_entry -> attrs .prio , pol_entry -> attrs .type );
26792688 return ;
26802689 }
@@ -2814,7 +2823,7 @@ bool mlx5e_ipsec_fs_tunnel_enabled(struct mlx5e_ipsec_sa_entry *sa_entry)
28142823 struct mlx5e_ipsec_rx * rx ;
28152824 struct mlx5e_ipsec_tx * tx ;
28162825
2817- rx = ipsec_rx (sa_entry -> ipsec , attrs -> family , attrs -> type );
2826+ rx = ipsec_rx (sa_entry -> ipsec , attrs -> addrs . family , attrs -> type );
28182827 tx = ipsec_tx (sa_entry -> ipsec , attrs -> type );
28192828 if (sa_entry -> attrs .dir == XFRM_DEV_OFFLOAD_OUT )
28202829 return tx -> allow_tunnel_mode ;
0 commit comments