DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC] ethdev: add sanity packet checks
@ 2021-02-28 19:48 Ori Kam
  2021-02-28 20:14 ` Thomas Monjalon
  2021-03-09  9:01 ` Andrew Rybchenko
  0 siblings, 2 replies; 12+ messages in thread
From: Ori Kam @ 2021-02-28 19:48 UTC (permalink / raw)
  To: viacheslavo, ferruh.yigit, thomas, Andrew Rybchenko; +Cc: dev, orika

Currently, DPDK application can offload the checksum check,
and report it in the mbuf.

However, this approach doesn't work if the traffic
is offloaded and should not arrive to the application.

This commit introduces rte flow item that enables
matching on the checksum of the L3 and L4 layers,
in addition to other checks that can determine if
the packet is valid.
some of those tests can be packet len, data len,
unsupported flags, and so on.

The full check is HW dependent.

Signed-off-by: Ori Kam <orika@nvidia.com>
---
 lib/librte_ethdev/rte_flow.c |  1 +
 lib/librte_ethdev/rte_flow.h | 50 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)

diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index b07dbff..a8d7c7a 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -99,6 +99,7 @@ struct rte_flow_desc_data {
 	MK_FLOW_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
 	MK_FLOW_ITEM(GENEVE_OPT, sizeof(struct rte_flow_item_geneve_opt)),
 	MK_FLOW_ITEM(SFT, sizeof(struct rte_flow_item_sft)),
+	MK_FLOW_ITEM(SANITY_CHECKS, sizeof(struct rte_flow_item_sanity_checks)),
 };
 
 /** Generate flow_action[] entry. */
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index ad876dd..f948c5e 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -559,6 +559,15 @@ enum rte_flow_item_type {
 	 * See struct rte_flow_item_sft.
 	 */
 	RTE_FLOW_ITEM_TYPE_SFT,
+
+	/**
+	 * [META]
+	 *
+	 * Matches packet sanity checks.
+	 *
+	 * See struct rte_flow_item_sanity_checks.
+	 */
+	RTE_FLOW_ITEM_TYPE_SANITY_CHECKS,
 };
 
 /**
@@ -1709,6 +1718,47 @@ struct rte_flow_item_sft {
 };
 
 /**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_SANITY_CHECKS
+ *
+ * Enable matching on packet validity based on HW checks for the L3 and L4
+ * layers.
+ */
+struct rte_flow_item_sanity_checks {
+	uint32_t level;
+	/**< Packet encapsulation level the item should apply to.
+	 * @see rte_flow_action_rss
+	 */
+RTE_STD_C11
+	union {
+		struct {
+			uint32_t l3_ok:1;
+			/**< L3 layer is valid after passing all HW checking. */
+			uint32_t l4_ok:1;
+			/**< L4 layer is valid after passing all HW checking. */
+			uint32_t l3_ok_csum:1;
+			/**< L3 layer checksum is valid. */
+			uint32_t l4_ok_csum:1;
+			/**< L4 layer checksum is valid. */
+			uint32_t reserved:28;
+		};
+		uint32_t  value;
+	};
+};
+
+#ifndef __cplusplus
+static const struct rte_flow_item_sanity_checks
+	rte_flow_item_sanity_checks_mask = {
+	.l3_ok = 1,
+	.l4_ok = 1,
+	.l3_ok_csum = 1,
+	.l4_ok_csum = 1,
+};
+#endif
+
+/**
  * Matching pattern item definition.
  *
  * A pattern is formed by stacking items starting from the lowest protocol
-- 
1.8.3.1


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

end of thread, other threads:[~2021-03-09 19:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-28 19:48 [dpdk-dev] [RFC] ethdev: add sanity packet checks Ori Kam
2021-02-28 20:14 ` Thomas Monjalon
2021-03-04 10:00   ` Ori Kam
2021-03-04 10:46     ` Thomas Monjalon
2021-03-07 18:46       ` Ori Kam
2021-03-08 23:05         ` Ajit Khaparde
2021-03-09 19:21           ` Ori Kam
2021-03-09  9:01 ` Andrew Rybchenko
2021-03-09  9:11   ` Thomas Monjalon
2021-03-09 15:08     ` Ori Kam
2021-03-09 15:27       ` Andrew Rybchenko
2021-03-09 19:46         ` Ori Kam

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