DPDK patches and discussions
 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 v3 13/20] net/ice/base: add helper functions for parse graph key matching
Date: Tue, 21 Sep 2021 21:20:02 +0800	[thread overview]
Message-ID: <20210921132009.3461020-14-qi.z.zhang@intel.com> (raw)
In-Reply-To: <20210921132009.3461020-1-qi.z.zhang@intel.com>

Add below two internal helper functions for parse graph key matching
in cam table:

ice_pg_cam_match
ice_pg_nm_cam_match

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Junfeng Guo <junfeng.guo@intel.com>
---
 drivers/net/ice/base/ice_pg_cam.c | 76 +++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_pg_cam.h |  6 +++
 2 files changed, 82 insertions(+)

diff --git a/drivers/net/ice/base/ice_pg_cam.c b/drivers/net/ice/base/ice_pg_cam.c
index 03484d6a91..fe461ad849 100644
--- a/drivers/net/ice/base/ice_pg_cam.c
+++ b/drivers/net/ice/base/ice_pg_cam.c
@@ -296,3 +296,79 @@ struct ice_pg_nm_cam_item *ice_pg_nm_sp_cam_table_get(struct ice_hw *hw)
 					ice_parser_sect_item_get,
 					_pg_nm_sp_cam_parse_item, false);
 }
+
+static bool _pg_cam_match(struct ice_pg_cam_item *item,
+			  struct ice_pg_cam_key *key)
+{
+	if (!item->key.valid ||
+	    item->key.node_id != key->node_id ||
+	    item->key.flag0 != key->flag0 ||
+	    item->key.flag1 != key->flag1 ||
+	    item->key.flag2 != key->flag2 ||
+	    item->key.flag3 != key->flag3 ||
+	    item->key.boost_idx != key->boost_idx ||
+	    item->key.alu_reg != key->alu_reg ||
+	    item->key.next_proto != key->next_proto)
+		return false;
+
+	return true;
+}
+
+static bool _pg_nm_cam_match(struct ice_pg_nm_cam_item *item,
+			     struct ice_pg_cam_key *key)
+{
+	if (!item->key.valid ||
+	    item->key.node_id != key->node_id ||
+	    item->key.flag0 != key->flag0 ||
+	    item->key.flag1 != key->flag1 ||
+	    item->key.flag2 != key->flag2 ||
+	    item->key.flag3 != key->flag3 ||
+	    item->key.boost_idx != key->boost_idx ||
+	    item->key.alu_reg != key->alu_reg)
+		return false;
+
+	return true;
+}
+
+/**
+ * ice_pg_cam_match - search parse graph cam table by key
+ * @table: parse graph cam table to search
+ * @size: cam table size
+ * @key: search key
+ */
+struct ice_pg_cam_item *ice_pg_cam_match(struct ice_pg_cam_item *table,
+					 int size, struct ice_pg_cam_key *key)
+{
+	int i;
+
+	for (i = 0; i < size; i++) {
+		struct ice_pg_cam_item *item = &table[i];
+
+		if (_pg_cam_match(item, key))
+			return item;
+	}
+
+	return NULL;
+}
+
+/**
+ * ice_pg_nm_cam_match - search parse graph no match cam table by key
+ * @table: parse graph no match cam table to search
+ * @size: cam table size
+ * @key: search key
+ */
+struct ice_pg_nm_cam_item *
+ice_pg_nm_cam_match(struct ice_pg_nm_cam_item *table, int size,
+		    struct ice_pg_cam_key *key)
+{
+	int i;
+
+	for (i = 0; i < size; i++) {
+		struct ice_pg_nm_cam_item *item = &table[i];
+
+		if (_pg_nm_cam_match(item, key))
+			return item;
+	}
+
+	return NULL;
+}
diff --git a/drivers/net/ice/base/ice_pg_cam.h b/drivers/net/ice/base/ice_pg_cam.h
index fcb2e11e54..aeadc20a77 100644
--- a/drivers/net/ice/base/ice_pg_cam.h
+++ b/drivers/net/ice/base/ice_pg_cam.h
@@ -65,4 +65,10 @@ struct ice_pg_cam_item *ice_pg_sp_cam_table_get(struct ice_hw *hw);
 
 struct ice_pg_nm_cam_item *ice_pg_nm_cam_table_get(struct ice_hw *hw);
 struct ice_pg_nm_cam_item *ice_pg_nm_sp_cam_table_get(struct ice_hw *hw);
+
+struct ice_pg_cam_item *ice_pg_cam_match(struct ice_pg_cam_item *table,
+					 int size, struct ice_pg_cam_key *key);
+struct ice_pg_nm_cam_item *
+ice_pg_nm_cam_match(struct ice_pg_nm_cam_item *table, int size,
+		    struct ice_pg_cam_key *key);
 #endif /* _ICE_PG_CAM_H_ */
-- 
2.26.2


  parent reply	other threads:[~2021-09-21 13:18 UTC|newest]

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

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=20210921132009.3461020-14-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).