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 97F05A04BC; Fri, 9 Oct 2020 15:46:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9F93C1D630; Fri, 9 Oct 2020 15:46:11 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 9A6631D61F for ; Fri, 9 Oct 2020 15:46:08 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from jiaweiw@nvidia.com) with SMTP; 9 Oct 2020 16:46:06 +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 099Dk6sN011875; Fri, 9 Oct 2020 16:46:06 +0300 From: Jiawei Wang To: orika@nvidia.com, viacheslavo@nvidia.com, matan@nvidia.com, thomas@monjalon.net, ferruh.yigit@intel.com, marko.kovacevic@intel.com, arybchenko@solarflare.com Cc: dev@dpdk.org, rasland@nvidia.com, ian.stokes@intel.com, fbl@redhat.com, asafp@nvidia.com Date: Fri, 9 Oct 2020 16:46:06 +0300 Message-Id: <1602251166-269265-4-git-send-email-jiaweiw@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602251166-269265-1-git-send-email-jiaweiw@nvidia.com> References: <1601187539-112694-1-git-send-email-jiaweiw@nvidia.com> <1602251166-269265-1-git-send-email-jiaweiw@nvidia.com> Subject: [dpdk-dev] [PATCH v9 3/3] app/testpmd: add port and encap support for sample action 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" Use sample action with ratio is 1 for mirroring flow, add supports to set the different port or encap action for mirrored packets. The example of test-pmd command: 1. set sample_actions 1 port_id id 1 / end flow create 0 ... pattern eth / end actions sample ratio 1 index 1 / port_id id 2... The flow will result in all the matched ingress packets will be sent to port 2, and also mirrored the packets and sent to port 1. 2. set raw_encap 0 eth src.../ ipv4.../... set raw_encap 1 eth src.../ ipv4.../... set sample_actions 2 raw_encap index 0 / port_id id 0 / end flow create 0 ... pattern eth / end actions sample ratio 1 index 2 / raw_encap index 1 / port_id id 0... The flow will result in all the matched egress packets will be encapsulated and sent to wire, and also mirrored the packets and with the different encapsulated data and sent to wire. Signed-off-by: Jiawei Wang Acked-by: Viacheslav Ovsiienko --- app/test-pmd/cmdline_flow.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 5195a62..4f5c553 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -516,6 +516,8 @@ struct raw_sample_conf { struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM]; struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM]; struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM]; +struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM]; +struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM]; /** Maximum number of subsequent tokens and arguments on the stack. */ #define CTX_STACK_SIZE 16 @@ -1460,6 +1462,8 @@ struct parse_action_priv { ACTION_QUEUE, ACTION_MARK, ACTION_COUNT, + ACTION_PORT_ID, + ACTION_RAW_ENCAP, ACTION_NEXT, ZERO, }; @@ -7027,6 +7031,18 @@ static int comp_set_sample_index(struct context *, const struct token *, (const void *)action->conf, size); action->conf = &sample_queue[idx]; break; + case RTE_FLOW_ACTION_TYPE_RAW_ENCAP: + size = sizeof(struct rte_flow_action_raw_encap); + rte_memcpy(&sample_encap[idx], + (const void *)action->conf, size); + action->conf = &sample_encap[idx]; + break; + case RTE_FLOW_ACTION_TYPE_PORT_ID: + size = sizeof(struct rte_flow_action_port_id); + rte_memcpy(&sample_port_id[idx], + (const void *)action->conf, size); + action->conf = &sample_port_id[idx]; + break; default: printf("Error - Not supported action\n"); return; -- 1.8.3.1