DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] ethdev: add roughly match pattern
@ 2017-05-23 23:28 Qi Zhang
  2017-05-30 12:46 ` Adrien Mazarguil
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Qi Zhang @ 2017-05-23 23:28 UTC (permalink / raw)
  To: adrien.mazarguil; +Cc: dev, Qi Zhang

Add new meta pattern item RTE_FLOW_TYPE_ITEM_ROUGHLY.

This is for device that support no-perfect match option.
Usually a no-perfect match is fast but the cost is accuracy.
i.e. Signature Match only match pattern's hash value, but it is
possible two different patterns have the same hash value.

Matching accuracy level can be configure by subfield threshold.
Driver can divide the range of threshold and map to different
accuracy levels that device support.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 app/test-pmd/cmdline_flow.c                 | 24 ++++++++++++++
 app/test-pmd/config.c                       |  1 +
 doc/guides/prog_guide/rte_flow.rst          | 50 +++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 ++
 lib/librte_ether/rte_flow.h                 | 30 +++++++++++++++++
 5 files changed, 107 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 0fd69f9..18ffcff 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -107,6 +107,8 @@ enum index {
 	ITEM_END,
 	ITEM_VOID,
 	ITEM_INVERT,
+	ITEM_ROUGHLY,
+	ITEM_ROUGHLY_THRESHOLD,
 	ITEM_ANY,
 	ITEM_ANY_NUM,
 	ITEM_PF,
@@ -426,6 +428,7 @@ static const enum index next_item[] = {
 	ITEM_END,
 	ITEM_VOID,
 	ITEM_INVERT,
+	ITEM_ROUGHLY,
 	ITEM_ANY,
 	ITEM_PF,
 	ITEM_VF,
@@ -447,6 +450,12 @@ static const enum index next_item[] = {
 	ZERO,
 };
 
+static const enum index item_roughly[] = {
+	ITEM_ROUGHLY_THRESHOLD,
+	ITEM_NEXT,
+	ZERO,
+};
+
 static const enum index item_any[] = {
 	ITEM_ANY_NUM,
 	ITEM_NEXT,
@@ -954,6 +963,21 @@ static const struct token token_list[] = {
 		.next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
 		.call = parse_vc,
 	},
+	[ITEM_ROUGHLY] = {
+		.name = "roughly",
+		.help = "match the pattern roughly",
+		.priv = PRIV_ITEM(ROUGHLY,
+				sizeof(struct rte_flow_item_roughly)),
+		.next = NEXT(item_roughly),
+		.call = parse_vc,
+	},
+	[ITEM_ROUGHLY_THRESHOLD] = {
+		.name = "threshold",
+		.help = "match accuracy threshold",
+		.next = NEXT(item_roughly, NEXT_ENTRY(UNSIGNED), item_param),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_roughly,
+					threshold)),
+	},
 	[ITEM_ANY] = {
 		.name = "any",
 		.help = "match any protocol for the current layer",
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 4d873cd..5b0cd4d 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -954,6 +954,7 @@ static const struct {
 	MK_FLOW_ITEM(END, 0),
 	MK_FLOW_ITEM(VOID, 0),
 	MK_FLOW_ITEM(INVERT, 0),
+	MK_FLOW_ITEM(ROUGHLY, sizeof(struct rte_flow_item_roughly)),
 	MK_FLOW_ITEM(ANY, sizeof(struct rte_flow_item_any)),
 	MK_FLOW_ITEM(PF, 0),
 	MK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)),
diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index b587ba9..4cc1876 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -491,6 +491,7 @@ Usage example, matching non-TCPv4 packets only:
 
    +-------+----------+
    | Index | Item     |
+
    +=======+==========+
    | 0     | INVERT   |
    +-------+----------+
@@ -503,6 +504,55 @@ Usage example, matching non-TCPv4 packets only:
    | 4     | END      |
    +-------+----------+
 
+Item: ``ROUGHLY``
+^^^^^^^^^^^^^^^^^
+
+Roughly matching, not perfect match.
+
+This is for device that support no-perfect match option.
+Usually a no-perfect match is fast but the cost is accuracy.
+i.e. Signature Match only match pattern's hash value, but it is
+possible two different patterns have the same hash value.
+
+Matching accuracy level can be configure by threshold.
+Driver can divide the range of threshold and map to different
+accuracy levels that device support.
+
+.. _table_rte_flow_item_roughly:
+
+.. table:: ROUGHLY
+
+   +----------+---------------+--------------------------------------------------+
+   | Field    |   Subfield    | Value                                            |
+   +==========+===========+======================================================+
+   | ``spec`` | ``threshold`` | 0 as perfect match, 0xffffffff as roughest match |
+   +----------+---------------+--------------------------------------------------+
+   | ``last`` | ``threshold`` | ignored                                          |
+   +----------+-----------+------------------------------------------------------+
+   | ``mask`` | ``threshold`` | ignored                                          |
+   +----------+-----------+------------------------------------------------------+
+
+
+Usage example, roughly match a TCPv4 packets:
+
+.. _table_rte_flow_item_roughly_example:
+
+.. table:: Roughly matching
+
+   +-------+----------+
+   | Index | Item     |
+   +=======+==========+
+   | 0     | ROUGHLY  |
+   +-------+----------+
+   | 1     | Ethernet |
+   +-------+----------+
+   | 2     | IPv4     |
+   +-------+----------+
+   | 3     | TCP      |
+   +-------+----------+
+   | 4     | END      |
+   +-------+----------+
+
 Item: ``PF``
 ^^^^^^^^^^^^
 
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 0e50c10..08a88f8 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -2513,6 +2513,8 @@ This section lists supported pattern items and their attributes, if any.
 
 - ``invert``: perform actions when pattern does not match.
 
+- ``roughly``: pattern is matched roughly.
+
 - ``any``: match any protocol for the current layer.
 
   - ``num {unsigned}``: number of layers covered.
diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h
index c47edbc..4921858 100644
--- a/lib/librte_ether/rte_flow.h
+++ b/lib/librte_ether/rte_flow.h
@@ -148,6 +148,18 @@ enum rte_flow_item_type {
 	RTE_FLOW_ITEM_TYPE_INVERT,
 
 	/**
+	 * [META]
+	 *
+	 * Roughly matching, not perfect matching
+	 *
+	 * This is for device that support no-perfect matching option.
+	 * Usually a no-perfect matching is fast but the cost is accuracy.
+	 *
+	 * See struct rte_flow_item_roughly
+	 */
+	RTE_FLOW_ITEM_TYPE_ROUGHLY,
+
+	/**
 	 * Matches any protocol in place of the current layer, a single ANY
 	 * may also stand for several protocol layers.
 	 *
@@ -300,6 +312,24 @@ enum rte_flow_item_type {
 };
 
 /**
+ * RTE_FLOW_ITEM_TYPE_ROUGHLY
+ *
+ * Roughly matching, not perfect match.
+ *
+ * This is for device that support no-perfect match option.
+ * Usually a no-perfect match is fast but the cost is accuracy.
+ * i.e. Signature Match only match pattern's hash value, but it is
+ * possible two different patterns have the same hash value.
+ *
+ * Matching accuracy level can be configure by threshold.
+ * Driver can divide the range of threshold and map to different
+ * accuracy levels that device support.
+ */
+struct rte_flow_item_roughly {
+	uint32_t threshold; /**< accuracy threshold*/
+};
+
+/**
  * RTE_FLOW_ITEM_TYPE_ANY
  *
  * Matches any protocol in place of the current layer, a single ANY may also
-- 
2.7.4

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2017-07-05 17:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23 23:28 [dpdk-dev] [PATCH] ethdev: add roughly match pattern Qi Zhang
2017-05-30 12:46 ` Adrien Mazarguil
2017-05-31  7:51   ` Gaëtan Rivet
2017-06-01  1:44     ` Zhang, Qi Z
2017-06-01 14:44       ` Adrien Mazarguil
2017-06-07 22:21 ` [dpdk-dev] [PATCH v2] ethdev: add fuzzy " Qi Zhang
2017-06-08  7:19   ` Thomas Monjalon
2017-06-12 15:38     ` Adrien Mazarguil
2017-06-13  6:03       ` Zhang, Qi Z
2017-06-13  3:07 ` [dpdk-dev] [PATCH v3] ethdev: add fuzzy match in flow API Qi Zhang
2017-07-05 16:06   ` Ferruh Yigit
2017-07-05 17:55   ` Thomas Monjalon
2017-06-21 19:07 ` [dpdk-dev] [PATCH v3 0/3] net/ixgbe: enable signature match and ipv6 for consistent API Qi Zhang
2017-06-21 19:07   ` [dpdk-dev] [PATCH v3 1/3] net/ixgbe: replace macro with inline function Qi Zhang
2017-06-21 19:07   ` [dpdk-dev] [PATCH v3 2/3] net/ixgbe: enable signature match for consistent API Qi Zhang
2017-06-21 19:07   ` [dpdk-dev] [PATCH v3 3/3] net/ixgbe: enable IPv6 " Qi Zhang

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).