From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EDC88A0548; Sun, 28 Feb 2021 20:49:04 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 92C1C22A240; Sun, 28 Feb 2021 20:49:03 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 30A6222A23D for ; Sun, 28 Feb 2021 20:49:02 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from orika@nvidia.com) with SMTP; 28 Feb 2021 21:48:57 +0200 Received: from pegasus04.mtr.labs.mlnx. (pegasus04.mtr.labs.mlnx [10.210.16.126]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 11SJmvN8025533; Sun, 28 Feb 2021 21:48:57 +0200 From: Ori Kam To: viacheslavo@nvidia.com, ferruh.yigit@intel.com, thomas@monjalon.net, Andrew Rybchenko Cc: dev@dpdk.org, orika@nvidia.com Date: Sun, 28 Feb 2021 19:48:19 +0000 Message-Id: <1614541699-99345-1-git-send-email-orika@nvidia.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [RFC] ethdev: add sanity packet checks X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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