From patchwork Thu Jun 7 12:52:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 40767 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 150851B171; Thu, 7 Jun 2018 14:53:08 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 37D301B016 for ; Thu, 7 Jun 2018 14:53:06 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@mellanox.com) with ESMTPS (AES256-SHA encrypted); 7 Jun 2018 15:55:19 +0300 Received: from dev-r630-06.mtbc.labs.mlnx (dev-r630-06.mtbc.labs.mlnx [10.12.205.180]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w57Cr2jo024018; Thu, 7 Jun 2018 15:53:02 +0300 Received: from dev-r630-06.mtbc.labs.mlnx (localhost [127.0.0.1]) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7) with ESMTP id w57Cr1HJ017062; Thu, 7 Jun 2018 20:53:01 +0800 Received: (from xuemingl@localhost) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7/Submit) id w57CqrkB017061; Thu, 7 Jun 2018 20:52:53 +0800 From: Xueming Li To: Adrien Mazarguil Cc: Xueming Li , dev@dpdk.org, Shahaf Shuler , Thomas Monjalon , Olivier Matz Date: Thu, 7 Jun 2018 20:52:40 +0800 Message-Id: <20180607125240.17017-1-xuemingl@mellanox.com> X-Mailer: git-send-email 2.13.3 MIME-Version: 1.0 Subject: [dpdk-dev] [RFC v1] ethdev: add flow metadata X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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, rte_flow pattern only match packet header fields. This patch adds additional data to match the packet. For example, in egress direction, to do an action depending on the VM id, the application needs to configure rte_flow rule with the new metadata pattern: pattern meta data is {vm} / end action encap … Then the PMD will send VM id as metadata associated in mbuf to NIC, then egress flow on NIC match metadata as other regular packet headers, the appropriate encapsulation is done according to the VM id metadata. Metadata could be used on ingress as well to save useful info before flow modification (not defined yet) or decapsulation action. PMD is responsible to save metadata into mbuf field. The application must get metadata from the mbuf. This patch introduces metadata item type for rte_flow, and new metadata fields in mbuf to support metadata usage. They are two 32 bits metadata fields defined for HW that support multiple metadata fields. Cc: Thomas Monjalon Cc: Olivier Matz Cc: Shahaf Shuler Signed-off-by: Xueming Li --- doc/guides/prog_guide/rte_flow.rst | 7 +++++++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 28 ++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf.h | 4 ++++ 4 files changed, 40 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index b305a72a5..c2f01fc9f 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1191,6 +1191,13 @@ Normally preceded by any of: - `Item: ICMP6_ND_NS`_ - `Item: ICMP6_ND_OPT`_ +Item: ``META`` +^^^^^^^^^^^^^^ + +Matches an metadata variable. + +- ``data``: 32 bit value. + Actions ~~~~~~~ diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index b2afba089..54a07dd4a 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -66,6 +66,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)), MK_FLOW_ITEM(ICMP6_ND_OPT_TLA_ETH, sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)), + MK_FLOW_ITEM(META, sizeof(struct rte_flow_item_meta)), }; /** Generate flow_action[] entry. */ diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index f8ba71cdb..f74e0eaec 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -413,6 +413,18 @@ enum rte_flow_item_type { * See struct rte_flow_item_mark. */ RTE_FLOW_ITEM_TYPE_MARK, + + /** + * Matches a metadata variable. + * + * Possible sources of metadata: + * - mbuf port or metadata field on egress + * - egress metadata loopback to ingress + * - data copied from packet header + * + * See struct rte_flow_item_meta. + */ + RTE_FLOW_ITEM_TYPE_META, }; /** @@ -849,6 +861,22 @@ static const struct rte_flow_item_gre rte_flow_item_gre_mask = { #endif /** + * RTE_FLOW_ITEM_TYPE_META. + * + * Matches a meta data header. + */ +struct rte_flow_item_meta { + uint32_t data; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_META. */ +#ifndef __cplusplus +static const struct rte_flow_item_meta rte_flow_item_meta_mask = { + .data = RTE_BE32(UINT32_MAX), +}; +#endif + +/** * RTE_FLOW_ITEM_TYPE_FUZZY * * Fuzzy pattern match, expect faster than default. diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 8e6b4d292..a9e376b22 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -550,6 +550,10 @@ struct rte_mbuf { RTE_STD_C11 union { void *userdata; /**< Can be used for external metadata */ + struct { + uint32_t metadata0; /**< Metadata0 for rx/tx flow */ + uint32_t metadata1; /**< Metadata1 for rx/tx flow */ + }; uint64_t udata64; /**< Allow 8-byte userdata on 32-bit */ };