From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 15F2EA04DE;
	Tue, 22 Sep 2020 00:27:56 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 9A4901D70C;
	Tue, 22 Sep 2020 00:27:55 +0200 (CEST)
Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com
 [209.85.210.66]) by dpdk.org (Postfix) with ESMTP id 0C3D71D6FB
 for <dev@dpdk.org>; Tue, 22 Sep 2020 00:27:55 +0200 (CEST)
Received: by mail-ot1-f66.google.com with SMTP id h17so13883441otr.1
 for <dev@dpdk.org>; Mon, 21 Sep 2020 15:27:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=tpoVprCEmS7rRLFmBbS0sU+SP/7vc6piagyW5/ZlQ9E=;
 b=Z/CiD+OoNdRKAkcId8jlhjABrW8SIUVR5aD1x89XhJvP2C6XNPRon3yG0MBZ4CIeQF
 XcV9+81R9uMqsnURUebxqjWM3r2xPU4d6O2yr6qHmkVn5nCq1lCdagFN/JRaD1ACTSJi
 KFFX8IXIIZgJEAd/Y0eraV8mcDYd3zYEybhF8=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=tpoVprCEmS7rRLFmBbS0sU+SP/7vc6piagyW5/ZlQ9E=;
 b=TcAqES+4DJyhXg7KYVdGCDPQCgrbfyY/Aw3RpsznvplIMrpt3CubRIflSwq6wOaSxn
 XIgG9tFXQVkjNuamaBs8rYfLLYIcmDzDXzSkh9zVwOPi/7S6CioKaXdJwl7NHtZdCKO4
 q2q9pkXOrsruQ3Xmh9ZBfOAs5gnM3Nbt40lDEPyy47VRlLOW+0A+Mr5+tVvQ0Y6rUQoK
 pZEdMkkvGk+Qt9IZXbWvFuJgR+3VmoOh+MHVraPIKJBrwPk1z6kNfxnqyRt76Gr1zt+S
 CZByKzGGqTELHMe4Vf0tDM57MY9VofU29lARqwGUU5lLMApj3jvF7wzohunfweiKwGsg
 ykdg==
X-Gm-Message-State: AOAM531e1lYyNwmFVntqyst5++JYWQZjg2oo9M2rzUCKPIEgMAq9TJlD
 zmuD7QzcC0hwDADyN8c22ttZI4YAeyP7j/malUNM2A==
X-Google-Smtp-Source: ABdhPJzf/V5uVdZWJQHyG1dB3WsEDzAFleHWG42Kybu/gbnwpnkTYpa2QgXCuRF57HMjN96iYC1GhUTUW23c2+0bVSo=
X-Received: by 2002:a9d:5e4:: with SMTP id 91mr921433otd.95.1600727274157;
 Mon, 21 Sep 2020 15:27:54 -0700 (PDT)
MIME-Version: 1.0
References: <1598540492-406340-1-git-send-email-jiaweiw@nvidia.com>
 <1599634114-148013-1-git-send-email-jiaweiw@nvidia.com>
 <1599634114-148013-12-git-send-email-jiaweiw@nvidia.com>
In-Reply-To: <1599634114-148013-12-git-send-email-jiaweiw@nvidia.com>
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
Date: Mon, 21 Sep 2020 15:27:38 -0700
Message-ID: <CACZ4nhvu0082mK7TKYEQfXLSHJdGweqZvmODRCcYDCC1YbFesQ@mail.gmail.com>
To: Jiawei Wang <jiaweiw@nvidia.com>
Cc: Ori Kam <orika@nvidia.com>, Slava Ovsiienko <viacheslavo@nvidia.com>,
 matan@nvidia.com, 
 Thomas Monjalon <thomas@monjalon.net>, Ferruh Yigit <ferruh.yigit@intel.com>, 
 Marko Kovacevic <marko.kovacevic@intel.com>,
 Andrew Rybchenko <arybchenko@solarflare.com>, 
 dpdk-dev <dev@dpdk.org>, rasland@nvidia.com, ian.stokes@intel.com,
 fbl@redhat.com, asafp@nvidia.com
Content-Type: text/plain; charset="UTF-8"
Subject: Re: [dpdk-dev] [PATCH v6 11/12] 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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

On Tue, Sep 8, 2020 at 11:50 PM Jiawei Wang <jiaweiw@nvidia.com> wrote:
>
> 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 2.

                  ^

You probably meant "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 <jiaweiw@nvidia.com>
> ---
>  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 27fa294..1860657 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -514,6 +514,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
> @@ -1456,6 +1458,8 @@ struct parse_action_priv {
>         ACTION_QUEUE,
>         ACTION_MARK,
>         ACTION_COUNT,
> +       ACTION_PORT_ID,
> +       ACTION_RAW_ENCAP,
>         ACTION_NEXT,
>         ZERO,
>  };
> @@ -7009,6 +7013,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
>