From: Jeff Guo Date: Tue, 13 Apr 2021 10:06:29 +0000 (+0800) Subject: net/ice: support RSS hash for IP fragment X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f1ea76eb63944a65e9e0bbc32244bc7c8b4fbd1d;p=dpdk.git net/ice: support RSS hash for IP fragment New pattern and RSS hash flow parsing are added to handle fragmented IPv4/IPv6 packet. Signed-off-by: Jeff Guo Acked-by: Qi Zhang --- diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c index 261f0b78e4..12c43e0295 100644 --- a/drivers/net/ice/ice_generic_flow.c +++ b/drivers/net/ice/ice_generic_flow.c @@ -212,6 +212,27 @@ enum rte_flow_item_type pattern_eth_qinq_ipv6[] = { RTE_FLOW_ITEM_TYPE_IPV6, RTE_FLOW_ITEM_TYPE_END, }; +enum rte_flow_item_type pattern_eth_ipv6_frag_ext[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT, + RTE_FLOW_ITEM_TYPE_END, +}; +enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_VLAN, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT, + RTE_FLOW_ITEM_TYPE_END, +}; +enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_VLAN, + RTE_FLOW_ITEM_TYPE_VLAN, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT, + RTE_FLOW_ITEM_TYPE_END, +}; enum rte_flow_item_type pattern_eth_ipv6_udp[] = { RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV6, diff --git a/drivers/net/ice/ice_generic_flow.h b/drivers/net/ice/ice_generic_flow.h index b7634b9662..0bd38d82d1 100644 --- a/drivers/net/ice/ice_generic_flow.h +++ b/drivers/net/ice/ice_generic_flow.h @@ -52,6 +52,7 @@ #define ICE_L2TPV3OIP_SESSION_ID BIT_ULL(43) #define ICE_PFCP_SEID BIT_ULL(42) #define ICE_PFCP_S_FIELD BIT_ULL(41) +#define ICE_IP_PK_ID BIT_ULL(40) /* input set */ @@ -69,11 +70,13 @@ #define ICE_INSET_IPV4_TOS (ICE_PROT_IPV4 | ICE_IP_TOS) #define ICE_INSET_IPV4_PROTO (ICE_PROT_IPV4 | ICE_IP_PROTO) #define ICE_INSET_IPV4_TTL (ICE_PROT_IPV4 | ICE_IP_TTL) +#define ICE_INSET_IPV4_PKID (ICE_PROT_IPV4 | ICE_IP_PK_ID) #define ICE_INSET_IPV6_SRC (ICE_PROT_IPV6 | ICE_IP_SRC) #define ICE_INSET_IPV6_DST (ICE_PROT_IPV6 | ICE_IP_DST) #define ICE_INSET_IPV6_NEXT_HDR (ICE_PROT_IPV6 | ICE_IP_PROTO) #define ICE_INSET_IPV6_HOP_LIMIT (ICE_PROT_IPV6 | ICE_IP_TTL) #define ICE_INSET_IPV6_TC (ICE_PROT_IPV6 | ICE_IP_TOS) +#define ICE_INSET_IPV6_PKID (ICE_PROT_IPV6 | ICE_IP_PK_ID) #define ICE_INSET_TCP_SRC_PORT (ICE_PROT_TCP | ICE_SPORT) #define ICE_INSET_TCP_DST_PORT (ICE_PROT_TCP | ICE_DPORT) @@ -147,6 +150,9 @@ extern enum rte_flow_item_type pattern_eth_qinq_ipv4_icmp[]; extern enum rte_flow_item_type pattern_eth_ipv6[]; extern enum rte_flow_item_type pattern_eth_vlan_ipv6[]; extern enum rte_flow_item_type pattern_eth_qinq_ipv6[]; +extern enum rte_flow_item_type pattern_eth_ipv6_frag_ext[]; +extern enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[]; +extern enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[]; extern enum rte_flow_item_type pattern_eth_ipv6_udp[]; extern enum rte_flow_item_type pattern_eth_vlan_ipv6_udp[]; extern enum rte_flow_item_type pattern_eth_qinq_ipv6_udp[]; diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c index f2b17197be..2bf8983f5a 100644 --- a/drivers/net/ice/ice_hash.c +++ b/drivers/net/ice/ice_hash.c @@ -47,8 +47,10 @@ ETH_RSS_NONFRAG_IPV6_TCP | \ ETH_RSS_NONFRAG_IPV6_SCTP) -#define VALID_RSS_IPV4 (ETH_RSS_IPV4 | VALID_RSS_IPV4_L4) -#define VALID_RSS_IPV6 (ETH_RSS_IPV6 | VALID_RSS_IPV6_L4) +#define VALID_RSS_IPV4 (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | \ + VALID_RSS_IPV4_L4) +#define VALID_RSS_IPV6 (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | \ + VALID_RSS_IPV6_L4) #define VALID_RSS_L3 (VALID_RSS_IPV4 | VALID_RSS_IPV6) #define VALID_RSS_L4 (VALID_RSS_IPV4_L4 | VALID_RSS_IPV6_L4) @@ -109,6 +111,7 @@ ice_hash_parse_pattern_action(struct ice_adapter *ad, /* Rss configuration template */ struct ice_rss_hash_cfg ipv4_tmplt = { ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV4 | + ICE_FLOW_SEG_HDR_IPV_FRAG | ICE_FLOW_SEG_HDR_IPV_OTHER, ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV4, ICE_RSS_OUTER_HEADERS, @@ -147,6 +150,15 @@ struct ice_rss_hash_cfg ipv6_tmplt = { 0 }; +struct ice_rss_hash_cfg ipv6_frag_tmplt = { + ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 | + ICE_FLOW_SEG_HDR_IPV_FRAG | + ICE_FLOW_SEG_HDR_IPV_OTHER, + ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV6, + ICE_RSS_ANY_HEADERS, + 0 +}; + struct ice_rss_hash_cfg ipv6_udp_tmplt = { ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER | ICE_FLOW_SEG_HDR_UDP, @@ -199,6 +211,7 @@ struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_tmplt = { ICE_RSS_INNER_HEADERS_W_OUTER_IPV6, 0 }; + struct ice_rss_hash_cfg outer_ipv6_inner_ipv4_udp_tmplt = { ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER | ICE_FLOW_SEG_HDR_UDP, @@ -221,6 +234,7 @@ struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_tmplt = { ICE_RSS_INNER_HEADERS_W_OUTER_IPV4, 0 }; + struct ice_rss_hash_cfg outer_ipv4_inner_ipv6_udp_tmplt = { ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER | ICE_FLOW_SEG_HDR_UDP, @@ -354,7 +368,8 @@ struct ice_rss_hash_cfg empty_tmplt = { }; /* IPv4 */ -#define ICE_RSS_TYPE_ETH_IPV4 (ETH_RSS_ETH | ETH_RSS_IPV4) +#define ICE_RSS_TYPE_ETH_IPV4 (ETH_RSS_ETH | ETH_RSS_IPV4 | \ + ETH_RSS_FRAG_IPV4) #define ICE_RSS_TYPE_ETH_IPV4_UDP (ICE_RSS_TYPE_ETH_IPV4 | \ ETH_RSS_NONFRAG_IPV4_UDP) #define ICE_RSS_TYPE_ETH_IPV4_TCP (ICE_RSS_TYPE_ETH_IPV4 | \ @@ -371,6 +386,8 @@ struct ice_rss_hash_cfg empty_tmplt = { /* IPv6 */ #define ICE_RSS_TYPE_ETH_IPV6 (ETH_RSS_ETH | ETH_RSS_IPV6) +#define ICE_RSS_TYPE_ETH_IPV6_FRAG (ETH_RSS_ETH | ETH_RSS_IPV6 | \ + ETH_RSS_FRAG_IPV6) #define ICE_RSS_TYPE_ETH_IPV6_UDP (ICE_RSS_TYPE_ETH_IPV6 | \ ETH_RSS_NONFRAG_IPV6_UDP) #define ICE_RSS_TYPE_ETH_IPV6_TCP (ICE_RSS_TYPE_ETH_IPV6 | \ @@ -387,7 +404,8 @@ struct ice_rss_hash_cfg empty_tmplt = { /* VLAN IPV4 */ #define ICE_RSS_TYPE_VLAN_IPV4 (ICE_RSS_TYPE_IPV4 | \ - ETH_RSS_S_VLAN | ETH_RSS_C_VLAN) + ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \ + ETH_RSS_FRAG_IPV4) #define ICE_RSS_TYPE_VLAN_IPV4_UDP (ICE_RSS_TYPE_IPV4_UDP | \ ETH_RSS_S_VLAN | ETH_RSS_C_VLAN) #define ICE_RSS_TYPE_VLAN_IPV4_TCP (ICE_RSS_TYPE_IPV4_TCP | \ @@ -397,6 +415,9 @@ struct ice_rss_hash_cfg empty_tmplt = { /* VLAN IPv6 */ #define ICE_RSS_TYPE_VLAN_IPV6 (ICE_RSS_TYPE_IPV6 | \ ETH_RSS_S_VLAN | ETH_RSS_C_VLAN) +#define ICE_RSS_TYPE_VLAN_IPV6_FRAG (ICE_RSS_TYPE_IPV6 | \ + ETH_RSS_S_VLAN | ETH_RSS_C_VLAN | \ + ETH_RSS_FRAG_IPV6) #define ICE_RSS_TYPE_VLAN_IPV6_UDP (ICE_RSS_TYPE_IPV6_UDP | \ ETH_RSS_S_VLAN | ETH_RSS_C_VLAN) #define ICE_RSS_TYPE_VLAN_IPV6_TCP (ICE_RSS_TYPE_IPV6_TCP | \ @@ -486,10 +507,12 @@ static struct ice_pattern_match_item ice_hash_pattern_list[] = { {pattern_eth_ipv4_pfcp, ICE_RSS_TYPE_IPV4_PFCP, ICE_INSET_NONE, ð_ipv4_pfcp_tmplt}, /* IPV6 */ {pattern_eth_ipv6, ICE_RSS_TYPE_ETH_IPV6, ICE_INSET_NONE, &ipv6_tmplt}, + {pattern_eth_ipv6_frag_ext, ICE_RSS_TYPE_ETH_IPV6_FRAG, ICE_INSET_NONE, &ipv6_frag_tmplt}, {pattern_eth_ipv6_udp, ICE_RSS_TYPE_ETH_IPV6_UDP, ICE_INSET_NONE, &ipv6_udp_tmplt}, {pattern_eth_ipv6_tcp, ICE_RSS_TYPE_ETH_IPV6_TCP, ICE_INSET_NONE, &ipv6_tcp_tmplt}, {pattern_eth_ipv6_sctp, ICE_RSS_TYPE_ETH_IPV6_SCTP, ICE_INSET_NONE, &ipv6_sctp_tmplt}, {pattern_eth_vlan_ipv6, ICE_RSS_TYPE_VLAN_IPV6, ICE_INSET_NONE, &ipv6_tmplt}, + {pattern_eth_vlan_ipv6_frag_ext, ICE_RSS_TYPE_VLAN_IPV6_FRAG, ICE_INSET_NONE, &ipv6_frag_tmplt}, {pattern_eth_vlan_ipv6_udp, ICE_RSS_TYPE_VLAN_IPV6_UDP, ICE_INSET_NONE, &ipv6_udp_tmplt}, {pattern_eth_vlan_ipv6_tcp, ICE_RSS_TYPE_VLAN_IPV6_TCP, ICE_INSET_NONE, &ipv6_tcp_tmplt}, {pattern_eth_vlan_ipv6_sctp, ICE_RSS_TYPE_VLAN_IPV6_SCTP, ICE_INSET_NONE, &ipv6_sctp_tmplt}, @@ -630,11 +653,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg, if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV4) { if (rss_type & - (ETH_RSS_IPV4 | + (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV4_SCTP)) { - if (rss_type & ETH_RSS_L3_SRC_ONLY) + if (rss_type & ETH_RSS_FRAG_IPV4) + *hash_flds &= + ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_ID)); + else if (rss_type & ETH_RSS_L3_SRC_ONLY) *hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA)); else if (rss_type & ETH_RSS_L3_DST_ONLY) *hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA)); @@ -649,11 +675,14 @@ ice_refine_hash_cfg_l234(struct ice_rss_hash_cfg *hash_cfg, if (*addl_hdrs & ICE_FLOW_SEG_HDR_IPV6) { if (rss_type & - (ETH_RSS_IPV6 | + (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_NONFRAG_IPV6_SCTP)) { - if (rss_type & ETH_RSS_L3_SRC_ONLY) + if (rss_type & ETH_RSS_FRAG_IPV6) + *hash_flds &= + ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_ID)); + else if (rss_type & ETH_RSS_L3_SRC_ONLY) *hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA)); else if (rss_type & ETH_RSS_L3_DST_ONLY) *hash_flds &= ~(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA)); @@ -868,6 +897,7 @@ ice_any_invalid_rss_type(enum rte_eth_hash_function rss_func, if (!(rss_type & (ETH_RSS_IPV4 | ETH_RSS_IPV6 | + ETH_RSS_FRAG_IPV4 | ETH_RSS_FRAG_IPV6 | ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_NONFRAG_IPV6_SCTP)))