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 12/20] net/ice/base: add helper function for boost TCAM match
Date: Fri, 17 Sep 2021 19:02:34 +0800 [thread overview]
Message-ID: <20210917110242.3127658-13-qi.z.zhang@intel.com> (raw)
In-Reply-To: <20210917110242.3127658-1-qi.z.zhang@intel.com>
Add internal helper function ice_bst_tcam_match to perform ternary
match on boost TCAM.
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
drivers/net/ice/base/ice_bst_tcam.c | 22 +++++++++++++++
drivers/net/ice/base/ice_bst_tcam.h | 3 ++
drivers/net/ice/base/ice_parser.h | 1 +
drivers/net/ice/base/ice_tmatch.h | 44 +++++++++++++++++++++++++++++
4 files changed, 70 insertions(+)
create mode 100644 drivers/net/ice/base/ice_tmatch.h
diff --git a/drivers/net/ice/base/ice_bst_tcam.c b/drivers/net/ice/base/ice_bst_tcam.c
index 1c82359681..76b3a5c551 100644
--- a/drivers/net/ice/base/ice_bst_tcam.c
+++ b/drivers/net/ice/base/ice_bst_tcam.c
@@ -239,3 +239,25 @@ struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw *hw)
ice_parser_sect_item_get,
_parse_lbl_item, true);
}
+
+/**
+ * ice_bst_tcam_match - match a pattern on the boost tcam table
+ * @tcam_table: boost tcam table to search
+ * @pat: pattern to match
+ */
+struct ice_bst_tcam_item *
+ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat)
+{
+ int i;
+
+ for (i = 0; i < ICE_BST_TCAM_TABLE_SIZE; i++) {
+ struct ice_bst_tcam_item *item = &tcam_table[i];
+
+ if (item->hit_idx_grp == 0)
+ continue;
+ if (ice_ternary_match(item->key, item->key_inv, pat, 20))
+ return item;
+ }
+
+ return NULL;
+}
diff --git a/drivers/net/ice/base/ice_bst_tcam.h b/drivers/net/ice/base/ice_bst_tcam.h
index a4ab40721f..3cba0bbf55 100644
--- a/drivers/net/ice/base/ice_bst_tcam.h
+++ b/drivers/net/ice/base/ice_bst_tcam.h
@@ -25,4 +25,7 @@ void ice_bst_tcam_dump(struct ice_hw *hw, struct ice_bst_tcam_item *item);
struct ice_bst_tcam_item *ice_bst_tcam_table_get(struct ice_hw *hw);
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);
#endif /*_ICE_BST_TCAM_H_ */
diff --git a/drivers/net/ice/base/ice_parser.h b/drivers/net/ice/base/ice_parser.h
index 3a307e0344..b2ab21728e 100644
--- a/drivers/net/ice/base/ice_parser.h
+++ b/drivers/net/ice/base/ice_parser.h
@@ -15,6 +15,7 @@
#include "ice_flg_rd.h"
#include "ice_xlt_kb.h"
#include "ice_parser_rt.h"
+#include "ice_tmatch.h"
struct ice_parser {
struct ice_hw *hw; /* pointer to the hardware structure */
diff --git a/drivers/net/ice/base/ice_tmatch.h b/drivers/net/ice/base/ice_tmatch.h
new file mode 100644
index 0000000000..178a084639
--- /dev/null
+++ b/drivers/net/ice/base/ice_tmatch.h
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#ifndef _ICE_TMATCH_H_
+#define _ICE_TMATCH_H_
+
+static inline
+bool ice_ternary_match_byte(u8 key, u8 key_inv, u8 pat)
+{
+ u8 k1, k2, v;
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ k1 = (u8)(key & (1 << i));
+ k2 = (u8)(key_inv & (1 << i));
+ v = (u8)(pat & (1 << i));
+
+ if (k1 != 0 && k2 != 0)
+ continue;
+ if (k1 == 0 && k2 == 0)
+ return false;
+
+ if (k1 == v)
+ return false;
+ }
+
+ return true;
+}
+
+static inline
+bool ice_ternary_match(const u8 *key, const u8 *key_inv,
+ const u8 *pat, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ if (!ice_ternary_match_byte(key[i], key_inv[i], pat[i]))
+ return false;
+
+ return true;
+}
+
+#endif /* _ICE_TMATCH_H_ */
--
2.26.2
next prev 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 ` Qi Zhang [this message]
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 ` [dpdk-dev] [PATCH 18/20] net/ice/base: support double VLAN mode configure for parser Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 19/20] net/ice/base: add tunnel port support " 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-13-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).