net/ice: fix GTPU TEID hash
[dpdk.git] / drivers / net / ice / ice_hash.c
index 2845ca0..60183bb 100644 (file)
@@ -479,6 +479,8 @@ struct ice_hash_match_type ice_hash_type_list[] = {
                BIT_ULL(ICE_FLOW_FIELD_IDX_L2TPV3_SESS_ID)},
        {ETH_RSS_PFCP,
                BIT_ULL(ICE_FLOW_FIELD_IDX_PFCP_SEID)},
+       {ETH_RSS_GTPU,
+               BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_IP_TEID)},
        /* IPV4 */
        {ETH_RSS_IPV4 | ETH_RSS_L3_SRC_ONLY,
                BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA)},
@@ -1012,6 +1014,7 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_match_item,
        enum rte_flow_action_type action_type;
        const struct rte_flow_action_rss *rss;
        const struct rte_flow_action *action;
+       bool hash_map_found = false;
        uint64_t rss_attr_src_dst;
        uint64_t rss_attr_l3_pre;
        uint64_t rss_attr_symm;
@@ -1125,10 +1128,18 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_match_item,
                                if (rss_type == ht_map->hash_type) {
                                        hash_meta->hash_flds =
                                                        ht_map->hash_flds;
+                                       hash_map_found = true;
                                        break;
                                }
                        }
 
+                       if (pattern_match_item->pattern_list !=
+                           pattern_empty && !hash_map_found) {
+                               return rte_flow_error_set(error, ENOTSUP,
+                                       RTE_FLOW_ERROR_TYPE_ACTION, action,
+                                       "Not supported flow");
+                       }
+
                        /* update hash field for nat-t esp. */
                        if (rss_type == ETH_RSS_ESP &&
                            (m->eth_rss_hint & ETH_RSS_NONFRAG_IPV4_UDP ||
@@ -1139,21 +1150,25 @@ ice_hash_parse_action(struct ice_pattern_match_item *pattern_match_item,
                                BIT_ULL(ICE_FLOW_FIELD_IDX_NAT_T_ESP_SPI);
                        }
 
-                       /* update hash field for gtpu-ip and gtpu-eh. */
-                       if (rss_type != ETH_RSS_GTPU)
-                               break;
-                       else if (hash_meta->pkt_hdr & ICE_FLOW_SEG_HDR_GTPU_IP)
-                               hash_meta->hash_flds |=
-                               BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_IP_TEID);
-                       else if (hash_meta->pkt_hdr & ICE_FLOW_SEG_HDR_GTPU_EH)
+                       /* update hash field for gtpu eh/gtpu dwn/gtpu up. */
+                       if (hash_meta->pkt_hdr & ICE_FLOW_SEG_HDR_GTPU_EH) {
+                               hash_meta->hash_flds &=
+                               ~(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_IP_TEID));
                                hash_meta->hash_flds |=
                                BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_EH_TEID);
-                       else if (hash_meta->pkt_hdr & ICE_FLOW_SEG_HDR_GTPU_DWN)
+                       } else if (hash_meta->pkt_hdr &
+                                  ICE_FLOW_SEG_HDR_GTPU_DWN) {
+                               hash_meta->hash_flds &=
+                               ~(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_IP_TEID));
                                hash_meta->hash_flds |=
                                BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_DWN_TEID);
-                       else if (hash_meta->pkt_hdr & ICE_FLOW_SEG_HDR_GTPU_UP)
+                       } else if (hash_meta->pkt_hdr &
+                                  ICE_FLOW_SEG_HDR_GTPU_UP) {
+                               hash_meta->hash_flds &=
+                               ~(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_IP_TEID));
                                hash_meta->hash_flds |=
                                BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_UP_TEID);
+                       }
 
                        break;