net/ice: refactor packet type parsing
[dpdk.git] / drivers / net / ice / ice_hash.c
index c3ab4a0..3940438 100644 (file)
@@ -397,25 +397,7 @@ struct ice_rss_hash_cfg empty_tmplt = {
  * the second member is input set mask,
  * the third member is ice_rss_hash_cfg template.
  */
-
-/* Supported pattern for os default package. */
-static struct ice_pattern_match_item ice_hash_pattern_list_os[] = {
-       /* IPV4 */
-       {pattern_eth_ipv4,                      ICE_RSS_TYPE_OUTER_IPV4,        &ipv4_tmplt},
-       {pattern_eth_ipv4_udp,                  ICE_RSS_TYPE_OUTER_IPV4_UDP,    &ipv4_udp_tmplt},
-       {pattern_eth_ipv4_tcp,                  ICE_RSS_TYPE_OUTER_IPV4_TCP,    &ipv4_tcp_tmplt},
-       {pattern_eth_ipv4_sctp,                 ICE_RSS_TYPE_OUTER_IPV4_SCTP,   &ipv4_sctp_tmplt},
-       /* IPV6 */
-       {pattern_eth_ipv6,                      ICE_RSS_TYPE_OUTER_IPV6,        &ipv6_tmplt},
-       {pattern_eth_ipv6_udp,                  ICE_RSS_TYPE_OUTER_IPV6_UDP,    &ipv6_udp_tmplt},
-       {pattern_eth_ipv6_tcp,                  ICE_RSS_TYPE_OUTER_IPV6_TCP,    &ipv6_tcp_tmplt},
-       {pattern_eth_ipv6_sctp,                 ICE_RSS_TYPE_OUTER_IPV6_SCTP,   &ipv6_sctp_tmplt},
-       /* EMPTY */
-       {pattern_empty,                         ICE_RSS_TYPE_EMPTY,             &empty_tmplt},
-};
-
-/* Supported pattern for comms package. */
-static struct ice_pattern_match_item ice_hash_pattern_list_comms[] = {
+static struct ice_pattern_match_item ice_hash_pattern_list[] = {
        /* IPV4 */
        {pattern_eth_ipv4,                      ICE_RSS_TYPE_OUTER_IPV4,        &ipv4_tmplt},
        {pattern_eth_ipv4_udp,                  ICE_RSS_TYPE_OUTER_IPV4_UDP,    &ipv4_udp_tmplt},
@@ -490,19 +472,10 @@ static struct ice_flow_engine ice_hash_engine = {
 };
 
 /* Register parser for os package. */
-static struct ice_flow_parser ice_hash_parser_os = {
-       .engine = &ice_hash_engine,
-       .array = ice_hash_pattern_list_os,
-       .array_len = RTE_DIM(ice_hash_pattern_list_os),
-       .parse_pattern_action = ice_hash_parse_pattern_action,
-       .stage = ICE_FLOW_STAGE_RSS,
-};
-
-/* Register parser for comms package. */
-static struct ice_flow_parser ice_hash_parser_comms = {
+static struct ice_flow_parser ice_hash_parser = {
        .engine = &ice_hash_engine,
-       .array = ice_hash_pattern_list_comms,
-       .array_len = RTE_DIM(ice_hash_pattern_list_comms),
+       .array = ice_hash_pattern_list,
+       .array_len = RTE_DIM(ice_hash_pattern_list),
        .parse_pattern_action = ice_hash_parse_pattern_action,
        .stage = ICE_FLOW_STAGE_RSS,
 };
@@ -521,12 +494,7 @@ ice_hash_init(struct ice_adapter *ad)
        if (ad->hw.dcf_enabled)
                return 0;
 
-       if (ad->active_pkg_type == ICE_PKG_TYPE_OS_DEFAULT)
-               parser = &ice_hash_parser_os;
-       else if (ad->active_pkg_type == ICE_PKG_TYPE_COMMS)
-               parser = &ice_hash_parser_comms;
-       else
-               return -EINVAL;
+       parser = &ice_hash_parser;
 
        return ice_register_parser(parser, ad);
 }
@@ -970,8 +938,8 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
        }
 
        /* Check rss supported pattern and find matched pattern. */
-       pattern_match_item = ice_search_pattern_match_item(pattern,
-                                       array, array_len, error);
+       pattern_match_item = ice_search_pattern_match_item(ad, pattern, array,
+                                                          array_len, error);
        if (!pattern_match_item) {
                ret = -rte_errno;
                goto error;
@@ -1103,10 +1071,7 @@ ice_hash_uninit(struct ice_adapter *ad)
        if (ad->hw.dcf_enabled)
                return;
 
-       if (ad->active_pkg_type == ICE_PKG_TYPE_OS_DEFAULT)
-               ice_unregister_parser(&ice_hash_parser_os, ad);
-       else if (ad->active_pkg_type == ICE_PKG_TYPE_COMMS)
-               ice_unregister_parser(&ice_hash_parser_comms, ad);
+       ice_unregister_parser(&ice_hash_parser, ad);
 }
 
 static void