net/ice/base: support double VLAN mode configure for parser
authorQi Zhang <qi.z.zhang@intel.com>
Fri, 17 Sep 2021 14:43:20 +0000 (22:43 +0800)
committerQi Zhang <qi.z.zhang@intel.com>
Tue, 21 Sep 2021 13:17:58 +0000 (15:17 +0200)
Add API ice_parser_dvm_set to support turn on/off parser's
double vlan mode.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Junfeng Guo <junfeng.guo@intel.com>
drivers/net/ice/base/ice_bst_tcam.c
drivers/net/ice/base/ice_bst_tcam.h
drivers/net/ice/base/ice_parser.c
drivers/net/ice/base/ice_parser.h

index 76b3a5c..306f62d 100644 (file)
@@ -261,3 +261,31 @@ ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat)
 
        return NULL;
 }
+
+static bool _start_with(const char *prefix, const char *string)
+{
+       int len1 = strlen(prefix);
+       int len2 = strlen(string);
+
+       if (len2 < len1)
+               return false;
+
+       return !memcmp(prefix, string, len1);
+}
+
+struct ice_bst_tcam_item *
+ice_bst_tcam_search(struct ice_bst_tcam_item *tcam_table,
+                   struct ice_lbl_item *lbl_table,
+                   const char *prefix, u16 *start)
+{
+       u16 i = *start;
+
+       for (; i < ICE_BST_TCAM_TABLE_SIZE; i++) {
+               if (_start_with(prefix, lbl_table[i].label)) {
+                       *start = i;
+                       return &tcam_table[lbl_table[i].idx];
+               }
+       }
+
+       return NULL;
+}
index 3cba0bb..e4c96c4 100644 (file)
@@ -28,4 +28,8 @@ struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw *hw);
 
 struct ice_bst_tcam_item *
 ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat);
+struct ice_bst_tcam_item *
+ice_bst_tcam_search(struct ice_bst_tcam_item *tcam_table,
+                   struct ice_lbl_item *lbl_table,
+                   const char *prefix, u16 *start);
 #endif /*_ICE_BST_TCAM_H_ */
index 8f42371..395ad22 100644 (file)
@@ -340,3 +340,30 @@ void ice_parser_result_dump(struct ice_hw *hw, struct ice_parser_result *rslt)
        ice_info(hw, "flags_fd = 0x%04x\n", rslt->flags_fd);
        ice_info(hw, "flags_rss = 0x%04x\n", rslt->flags_rss);
 }
+
+static void _bst_vm_set(struct ice_parser *psr, const char *prefix, bool on)
+{
+       struct ice_bst_tcam_item *item;
+       u16 i = 0;
+
+       while (true) {
+               item = ice_bst_tcam_search(psr->bst_tcam_table,
+                                          psr->bst_lbl_table,
+                                          prefix, &i);
+               if (!item)
+                       break;
+               item->key[0] = (u8)(on ? 0xff : 0xfe);
+               item->key_inv[0] = (u8)(on ? 0xff : 0xfe);
+               i++;
+       }
+}
+
+/**
+ * ice_parser_dvm_set - configure double vlan mode for parser
+ * @psr: pointer to a parser instance
+ */
+void ice_parser_dvm_set(struct ice_parser *psr, bool on)
+{
+       _bst_vm_set(psr, "BOOST_MAC_VLAN_DVM", on);
+       _bst_vm_set(psr, "BOOST_MAC_VLAN_SVM", !on);
+}
index 715158d..e310466 100644 (file)
@@ -57,6 +57,7 @@ struct ice_parser {
 
 enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
 void ice_parser_destroy(struct ice_parser *psr);
+void ice_parser_dvm_set(struct ice_parser *psr, bool on);
 
 struct ice_parser_proto_off {
        u8 proto_id; /* hardware protocol ID */