net/ice/base: add profile validation on switch filter
[dpdk.git] / drivers / net / ice / base / ice_ptype_mk.c
index 33623dc..97c41cb 100644 (file)
@@ -52,3 +52,25 @@ struct ice_ptype_mk_tcam_item *ice_ptype_mk_tcam_table_get(struct ice_hw *hw)
                                        ice_parser_sect_item_get,
                                        _parse_ptype_mk_tcam_item, true);
 }
+
+/**
+ * ice_ptype_mk_tcam_match - match a pattern on a ptype marker tcam table
+ * @table: ptype marker tcam table to search
+ * @pat: pattern to match
+ * @len: length of the pattern
+ */
+struct ice_ptype_mk_tcam_item *
+ice_ptype_mk_tcam_match(struct ice_ptype_mk_tcam_item *table,
+                       u8 *pat, int len)
+{
+       int i;
+
+       for (i = 0; i < ICE_PTYPE_MK_TCAM_TABLE_SIZE; i++) {
+               struct ice_ptype_mk_tcam_item *item = &table[i];
+
+               if (ice_ternary_match(item->key, item->key_inv, pat, len))
+                       return item;
+       }
+
+       return NULL;
+}