All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qi Zhang <qi.z.zhang@intel.com>
To: qiming.yang@intel.com
Cc: junfeng.guo@intel.com, dev@dpdk.org, Qi Zhang <qi.z.zhang@intel.com>
Subject: [dpdk-dev] [PATCH 18/20] net/ice/base: support double VLAN mode configure for parser
Date: Fri, 17 Sep 2021 19:02:40 +0800	[thread overview]
Message-ID: <20210917110242.3127658-19-qi.z.zhang@intel.com> (raw)
In-Reply-To: <20210917110242.3127658-1-qi.z.zhang@intel.com>

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>
---
 drivers/net/ice/base/ice_bst_tcam.c | 28 ++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_bst_tcam.h |  4 ++++
 drivers/net/ice/base/ice_parser.c   | 27 +++++++++++++++++++++++++++
 drivers/net/ice/base/ice_parser.h   |  1 +
 4 files changed, 60 insertions(+)

diff --git a/drivers/net/ice/base/ice_bst_tcam.c b/drivers/net/ice/base/ice_bst_tcam.c
index 76b3a5c551..306f62db2a 100644
--- a/drivers/net/ice/base/ice_bst_tcam.c
+++ b/drivers/net/ice/base/ice_bst_tcam.c
@@ -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;
+}
diff --git a/drivers/net/ice/base/ice_bst_tcam.h b/drivers/net/ice/base/ice_bst_tcam.h
index 3cba0bbf55..e4c96c439d 100644
--- a/drivers/net/ice/base/ice_bst_tcam.h
+++ b/drivers/net/ice/base/ice_bst_tcam.h
@@ -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_ */
diff --git a/drivers/net/ice/base/ice_parser.c b/drivers/net/ice/base/ice_parser.c
index a0c5c9989d..052bc67a4c 100644
--- a/drivers/net/ice/base/ice_parser.c
+++ b/drivers/net/ice/base/ice_parser.c
@@ -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);
+}
diff --git a/drivers/net/ice/base/ice_parser.h b/drivers/net/ice/base/ice_parser.h
index b2ab21728e..74d72c26df 100644
--- a/drivers/net/ice/base/ice_parser.h
+++ b/drivers/net/ice/base/ice_parser.h
@@ -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 */
-- 
2.26.2


  parent reply	other threads:[~2021-09-17 11:01 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-17 11:02 [dpdk-dev] [PATCH 00/20] ice/base: add parser module Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 01/20] net/ice/base: add parser create and destroy skeleton Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 02/20] net/ice/base: init imem table for parser Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 03/20] net/ice/base: init metainit " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 04/20] net/ice/base: init parse graph cam " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 05/20] net/ice/base: init boost TCAM " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 06/20] net/ice/base: init ptype marker " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 07/20] net/ice/base: init marker group " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 08/20] net/ice/base: init protocol " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 09/20] net/ice/base: init flag redirect " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 10/20] net/ice/base: init XLT key builder " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 11/20] net/ice/base: add parser runtime skeleton Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 12/20] net/ice/base: add helper function for boost TCAM match Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 13/20] net/ice/base: add helper functions for parse graph key matching Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 14/20] net/ice/base: add helper function for ptype markers match Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 15/20] net/ice/base: add helper function to redirect flags Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 16/20] net/ice/base: add helper function to aggregate flags Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 17/20] net/ice/base: add parser execution main loop Qi Zhang
2021-09-17 11:02 ` Qi Zhang [this message]
2021-09-17 11:02 ` [dpdk-dev] [PATCH 19/20] net/ice/base: add tunnel port support for parser Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 20/20] net/ice/base: add API for parser profile initialization Qi Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210917110242.3127658-19-qi.z.zhang@intel.com \
    --to=qi.z.zhang@intel.com \
    --cc=dev@dpdk.org \
    --cc=junfeng.guo@intel.com \
    --cc=qiming.yang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.