Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Junfeng Guo <junfeng.guo@intel.com>
To: intel-wired-lan@lists.osuosl.org
Cc: ivecera@redhat.com, netdev@vger.kernel.org, qi.z.zhang@intel.com,
	jesse.brandeburg@intel.com, edumazet@google.com,
	anthony.l.nguyen@intel.com, horms@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, davem@davemloft.net
Subject: [Intel-wired-lan] [PATCH iwl-next v9 13/15] ice: support double vlan mode configure for parser
Date: Mon,  4 Sep 2023 10:14:53 +0800	[thread overview]
Message-ID: <20230904021455.3944605-14-junfeng.guo@intel.com> (raw)
In-Reply-To: <20230904021455.3944605-1-junfeng.guo@intel.com>

Add API ice_parser_dvm_set to support turn on/off parser's
double vlan mode.

Signed-off-by: Junfeng Guo <junfeng.guo@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_bst_tcam.c | 17 +++++++++
 drivers/net/ethernet/intel/ice/ice_bst_tcam.h |  4 +++
 drivers/net/ethernet/intel/ice/ice_parser.c   | 36 +++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_parser.h   |  2 ++
 4 files changed, 59 insertions(+)

diff --git a/drivers/net/ethernet/intel/ice/ice_bst_tcam.c b/drivers/net/ethernet/intel/ice/ice_bst_tcam.c
index 99148f1cf4f1..8d7fda43b24c 100644
--- a/drivers/net/ethernet/intel/ice/ice_bst_tcam.c
+++ b/drivers/net/ethernet/intel/ice/ice_bst_tcam.c
@@ -334,3 +334,20 @@ ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat)
 
 	return NULL;
 }
+
+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 (strstarts(lbl_table[i].label, prefix)) {
+			*start = i;
+			return &tcam_table[lbl_table[i].idx];
+		}
+	}
+
+	return NULL;
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_bst_tcam.h b/drivers/net/ethernet/intel/ice/ice_bst_tcam.h
index 73a46dc56b29..c3ced00b4920 100644
--- a/drivers/net/ethernet/intel/ice/ice_bst_tcam.h
+++ b/drivers/net/ethernet/intel/ice/ice_bst_tcam.h
@@ -33,4 +33,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/ethernet/intel/ice/ice_parser.c b/drivers/net/ethernet/intel/ice/ice_parser.c
index 1bd1417e32c6..5ce98cd303e1 100644
--- a/drivers/net/ethernet/intel/ice/ice_parser.c
+++ b/drivers/net/ethernet/intel/ice/ice_parser.c
@@ -325,3 +325,39 @@ void ice_parser_result_dump(struct ice_hw *hw, struct ice_parser_result *rslt)
 	dev_info(ice_hw_to_dev(hw), "flags_fd = 0x%04x\n", rslt->flags_fd);
 	dev_info(ice_hw_to_dev(hw), "flags_rss = 0x%04x\n", rslt->flags_rss);
 }
+
+#define ICE_BT_VLD_KEY	0xFF
+#define ICE_BT_INV_KEY	0xFE
+
+static void _ice_bst_vm_set(struct ice_parser *psr, const char *prefix,
+			    bool on)
+{
+	u16 i = 0;
+
+	while (true) {
+		struct ice_bst_tcam_item *item;
+
+		item = ice_bst_tcam_search(psr->bst_tcam_table,
+					   psr->bst_lbl_table,
+					   prefix, &i);
+		if (!item)
+			break;
+
+		item->key[ICE_BT_VM_OFF] =
+			(u8)(on ? ICE_BT_VLD_KEY : ICE_BT_INV_KEY);
+		item->key_inv[ICE_BT_VM_OFF] =
+			(u8)(on ? ICE_BT_VLD_KEY : ICE_BT_INV_KEY);
+		i++;
+	}
+}
+
+/**
+ * ice_parser_dvm_set - configure double vlan mode for parser
+ * @psr: pointer to a parser instance
+ * @on: true to turn on; false to turn off
+ */
+void ice_parser_dvm_set(struct ice_parser *psr, bool on)
+{
+	_ice_bst_vm_set(psr, "BOOST_MAC_VLAN_DVM", on);
+	_ice_bst_vm_set(psr, "BOOST_MAC_VLAN_SVM", !on);
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_parser.h b/drivers/net/ethernet/intel/ice/ice_parser.h
index bfcef4f597bf..c9eee988ebb2 100644
--- a/drivers/net/ethernet/intel/ice/ice_parser.h
+++ b/drivers/net/ethernet/intel/ice/ice_parser.h
@@ -33,6 +33,7 @@
 #define ICE_SID_LBL_ENTRY_SIZE				66
 
 #define ICE_PARSER_PROTO_OFF_PAIR_SIZE			16
+#define ICE_BT_VM_OFF					0
 
 struct ice_parser {
 	struct ice_hw *hw; /* pointer to the hardware structure */
@@ -74,6 +75,7 @@ struct ice_parser {
 
 int 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.25.1

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

  parent reply	other threads:[~2023-09-04  2:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04  2:14 [Intel-wired-lan] [PATCH iwl-next v9 00/15] Introduce the Parser Library Junfeng Guo
2023-09-04  2:14 ` [Intel-wired-lan] [PATCH iwl-next v9 01/15] ice: add parser create and destroy skeleton Junfeng Guo
2023-09-06 10:49   ` Michal Schmidt
2023-09-04  2:14 ` [Intel-wired-lan] [PATCH iwl-next v9 02/15] ice: init imem table for parser Junfeng Guo
2023-09-06 10:50   ` Michal Schmidt
2023-09-04  2:14 ` [Intel-wired-lan] [PATCH iwl-next v9 03/15] ice: init metainit " Junfeng Guo
2023-09-04  2:14 ` [Intel-wired-lan] [PATCH iwl-next v9 04/15] ice: init parse graph cam tables " Junfeng Guo
2023-09-04  2:14 ` [Intel-wired-lan] [PATCH iwl-next v9 05/15] ice: init boost tcam and label " Junfeng Guo
2023-09-04  2:14 ` [Intel-wired-lan] [PATCH iwl-next v9 06/15] ice: init ptype marker tcam table " Junfeng Guo
2023-09-04  2:14 ` [Intel-wired-lan] [PATCH iwl-next v9 07/15] ice: init marker and protocol group tables " Junfeng Guo
2023-09-04  2:14 ` [Intel-wired-lan] [PATCH iwl-next v9 08/15] ice: init flag redirect table " Junfeng Guo
2023-09-04  2:14 ` [Intel-wired-lan] [PATCH iwl-next v9 09/15] ice: init XLT key builder " Junfeng Guo
2023-09-04  2:14 ` [Intel-wired-lan] [PATCH iwl-next v9 10/15] ice: add parser runtime skeleton Junfeng Guo
2023-09-04  2:14 ` [Intel-wired-lan] [PATCH iwl-next v9 11/15] ice: add internal help functions Junfeng Guo
2023-09-04  2:14 ` [Intel-wired-lan] [PATCH iwl-next v9 12/15] ice: add parser execution main loop Junfeng Guo
2023-09-04  2:14 ` Junfeng Guo [this message]
2023-09-04  2:14 ` [Intel-wired-lan] [PATCH iwl-next v9 14/15] ice: add tunnel port support for parser Junfeng Guo
2023-09-04  2:14 ` [Intel-wired-lan] [PATCH iwl-next v9 15/15] ice: add API for parser profile initialization Junfeng Guo
2023-09-05 22:37 ` [Intel-wired-lan] [PATCH iwl-next v9 00/15] Introduce the Parser Library Jakub Kicinski
2023-09-05 23:05   ` Tom Herbert
2023-09-07 19:10     ` Samudrala, Sridhar
2023-09-09 17:34       ` Tom Herbert
2023-09-12 20:37         ` Samudrala, Sridhar
2023-09-07 19:08   ` Samudrala, Sridhar
2023-09-07 19:38     ` Jakub Kicinski

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=20230904021455.3944605-14-junfeng.guo@intel.com \
    --to=junfeng.guo@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=ivecera@redhat.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=qi.z.zhang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox