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 2327DA0519; Thu, 25 Jun 2020 18:50:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E8B104F9C; Thu, 25 Jun 2020 18:50:42 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 818872A66 for ; Thu, 25 Jun 2020 18:50:38 +0200 (CEST) From: Jiawei Wang To: orika@mellanox.com, viacheslavo@mellanox.com, matan@mellanox.com Cc: dev@dpdk.org, thomas@monjalon.net, rasland@mellanox.com, ian.stokes@intel.com, fbl@redhat.com, jiaweiw@mellanox.com Date: Thu, 25 Jun 2020 19:26:12 +0300 Message-Id: <1593102379-400132-2-git-send-email-jiaweiw@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1593102379-400132-1-git-send-email-jiaweiw@mellanox.com> References: <1593102379-400132-1-git-send-email-jiaweiw@mellanox.com> Subject: [dpdk-dev] [PATCH 1/8] 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 in some predefined 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 --- lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index 1685be5..733871d 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -173,6 +173,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 b0e4199..71dd82c 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -2099,6 +2099,13 @@ enum rte_flow_action_type { * see enum RTE_ETH_EVENT_FLOW_AGED */ RTE_FLOW_ACTION_TYPE_AGE, + + /** + * Redirects specific ratio of packets to vport or queue. + * + * See struct rte_flow_action_sample. + */ + RTE_FLOW_ACTION_TYPE_SAMPLE, }; /** @@ -2709,6 +2716,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 to a special queue or vport + * in the predefined probabiilty, All the packets continues 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 { + /* packets sampled equals to '1/ratio' */ + const uint32_t ratio; + /* sub-action list specific for the sampling hit cases */ + const struct rte_flow_action *actions; +}; + +/** * Verbose error types. * * Most of them provide the type of the object referenced by struct -- 1.8.3.1