From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 62519A04B1; Wed, 26 Aug 2020 18:02:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B82881C0B0; Wed, 26 Aug 2020 18:02:14 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id F14541BFE3 for ; Wed, 26 Aug 2020 18:02:10 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from jiaweiw@nvidia.com) with SMTP; 26 Aug 2020 19:02:05 +0300 Received: from nvidia.com (gen-l-vrt-280.mtl.labs.mlnx [10.237.45.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 07QG253L017365; Wed, 26 Aug 2020 19:02:05 +0300 From: Jiawei Wang To: orika@nvidia.com, viacheslavo@nvidia.com, matan@nvidia.com Cc: dev@dpdk.org, thomas@monjalon.net, rasland@nvidia.com, ian.stokes@intel.com, fbl@redhat.com, jiaweiw@nvidia.com Date: Wed, 26 Aug 2020 19:01:59 +0300 Message-Id: <1598457725-396788-2-git-send-email-jiaweiw@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1598457725-396788-1-git-send-email-jiaweiw@nvidia.com> References: <1594057868-18724-1-git-send-email-jiaweiw@mellanox.com> <1598457725-396788-1-git-send-email-jiaweiw@nvidia.com> Subject: [dpdk-dev] [PATCH v4 1/7] ethdev: introduce sample action for rte flow 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" When using full offload, all traffic will be handled by the HW, and directed to the requested VF or wire, the control application loses visibility on the traffic. So there's a need for an action that will enable the control application some visibility. The solution is introduced a new action that will sample the incoming traffic and send a duplicated traffic with the specified ratio to the application, while the original packet will continue to the target destination. The packets sampled equals is '1/ratio', if the ratio value be set to 1, means that the packets would be completely mirrored. The sample packet can be assigned with different set of actions from the original packet. In order to support the sample packet in rte_flow, new rte_flow action definition RTE_FLOW_ACTION_TYPE_SAMPLE and structure rte_flow_action_sample will be introduced. Signed-off-by: Jiawei Wang Acked-by: Ori Kam Acked-by: Jerin Jacob Acked-by: Andrew Rybchenko --- doc/guides/prog_guide/rte_flow.rst | 25 +++++++++++++++++++++++++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 3e5cd1e..f8f3f51 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2653,6 +2653,31 @@ timeout passed without any matching on the flow. | ``context`` | user input flow context | +--------------+---------------------------------+ +Action: ``SAMPLE`` +^^^^^^^^^^^^^^^^^^ + +Adds a sample action to a matched flow. + +The matching packets will be duplicated with the specified ``ratio`` and +applied with own set of actions with a fate action, the packets sampled +equals is '1/ratio'. All the packets continue to the target destination. + +When the ``ratio`` is set to 1 then the packets will be 100% mirrored. +``actions`` represent the different set of actions for the sampled or mirrored +packets, and must have a fate action. + +.. _table_rte_flow_action_sample: + +.. table:: SAMPLE + + +--------------+---------------------------------+ + | Field | Value | + +==============+=================================+ + | ``ratio`` | 32 bits sample ratio value | + +--------------+---------------------------------+ + | ``actions`` | sub-action list for sampling | + +--------------+---------------------------------+ + Negative types ~~~~~~~~~~~~~~ diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index f8fdd68..035671d 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -174,6 +174,7 @@ struct rte_flow_desc_data { MK_FLOW_ACTION(SET_IPV4_DSCP, sizeof(struct rte_flow_action_set_dscp)), MK_FLOW_ACTION(SET_IPV6_DSCP, sizeof(struct rte_flow_action_set_dscp)), MK_FLOW_ACTION(AGE, sizeof(struct rte_flow_action_age)), + MK_FLOW_ACTION(SAMPLE, sizeof(struct rte_flow_action_sample)), }; int diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index da8bfa5..fa70d40 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -2132,6 +2132,14 @@ enum rte_flow_action_type { * see enum RTE_ETH_EVENT_FLOW_AGED */ RTE_FLOW_ACTION_TYPE_AGE, + + /** + * The matching packets will be duplicated with specified ratio and + * applied with own set of actions with a fate action. + * + * See struct rte_flow_action_sample. + */ + RTE_FLOW_ACTION_TYPE_SAMPLE, }; /** @@ -2742,6 +2750,28 @@ struct rte_flow_action { struct rte_flow; /** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ACTION_TYPE_SAMPLE + * + * Adds a sample action to a matched flow. + * + * The matching packets will be duplicated with specified ratio and applied + * with own set of actions with a fate action, the sampled packet could be + * redirected to queue or port. All the packets continue processing on the + * default flow path. + * + * When the sample ratio is set to 1 then the packets will be 100% mirrored. + * Additional action list be supported to add for sampled or mirrored packets. + */ +struct rte_flow_action_sample { + uint32_t ratio; /**< packets sampled equals to '1/ratio'. */ + const struct rte_flow_action *actions; + /**< sub-action list specific for the sampling hit cases. */ +}; + +/** * Verbose error types. * * Most of them provide the type of the object referenced by struct -- 1.8.3.1