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 50A5BA04BC; Sat, 10 Oct 2020 00:08:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E9C971D61B; Sat, 10 Oct 2020 00:07:28 +0200 (CEST) Received: from mail-oi1-f196.google.com (mail-oi1-f196.google.com [209.85.167.196]) by dpdk.org (Postfix) with ESMTP id CE12C1BD4B for ; Sat, 10 Oct 2020 00:07:26 +0200 (CEST) Received: by mail-oi1-f196.google.com with SMTP id 16so11706896oix.9 for ; Fri, 09 Oct 2020 15:07:26 -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=a1KYFe0v4gIk0UEiu6KFxZzCt5/sb9rP13X6b+mPppM=; b=JrPcwI7EuFSPFl4AyR3qSZzxuvYoonyl0t8t/jTOswv+qEyFh2nU3u7foOmSj6Cu6D uo2UPpl5+8DzQch5XDrF/lWeiu3USYz8LzdGUcYsktqvNid+gDKNQri5XVUkC4NCDEog Hc2d0AakbX/3nCbU3FzBj573fLT5BDIRz/z3Y= 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=a1KYFe0v4gIk0UEiu6KFxZzCt5/sb9rP13X6b+mPppM=; b=cLXbyvugIdrkF3t86Fm8f0zQSAR2+c/B3TaFgDcqcgegtxioDi0Cuw5CqnEC+nZqAJ qU/bHUEvbjlF5wjB1GjEZRugOti7ag2HDmkwEMl0TzL4DNP9Fy9Gql3fN8AKEDmtW0TO pon/A8ZVcFENe9YGj7qiKheX9+HAtPIWI+rH2CHwKvNn8JyUTcM05lAJhgeC7CTexkCE 5Yedimhli3bos14DU7AygrBH/4wk7RWhsSJJJB1hedUX0ayIC9po6VDp9rVk9DYeJAH5 Sk80mn6uY0fHiCaHU9kYiazd1rBgcM7Z7PTElxxx++dCodADX1Qb8i+sIUk0oouVev1S TCzw== X-Gm-Message-State: AOAM5339zUjAoLMRWUFlXw92v5g0NMGUyXFxXaBoGLfhoRMSdIgHyDOM McqNdEMyLt+wqtgo/vrqTFFn9KKj+tnshWhvwdwb/A== X-Google-Smtp-Source: ABdhPJyXXwgJzkDn0ASOiO+9Ayl/1osCy5AicARqpGA4V0pOyrGgFxSJyEiAZl1pexZ67CGrVwTZB2pDFegjJin5usg= X-Received: by 2002:aca:ab46:: with SMTP id u67mr2406941oie.27.1602281244837; Fri, 09 Oct 2020 15:07:24 -0700 (PDT) MIME-Version: 1.0 References: <1601187539-112694-1-git-send-email-jiaweiw@nvidia.com> <1602251166-269265-1-git-send-email-jiaweiw@nvidia.com> <1602251166-269265-2-git-send-email-jiaweiw@nvidia.com> In-Reply-To: <1602251166-269265-2-git-send-email-jiaweiw@nvidia.com> From: Ajit Khaparde Date: Fri, 9 Oct 2020 15:07:08 -0700 Message-ID: To: Jiawei Wang Cc: Ori Kam , Slava Ovsiienko , Matan Azrad , Thomas Monjalon , Ferruh Yigit , Marko Kovacevic , Andrew Rybchenko , dpdk-dev , Raslan Darawsheh , ian.stokes@intel.com, fbl@redhat.com, asafp@nvidia.com Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v9 1/3] 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" On Fri, Oct 9, 2020 at 6:47 AM Jiawei Wang wrote: > > When using full offload, all traffic will be handled by the HW, and > forwarded to the requested VF or wire and the control application does > not see this traffic anymore. So there's a need for an action that > enables the control application some forwarded traffic visibility. > > The solution introduces 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', the ratio value set to 1 > means that the packets will 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 > Acked-by: Viacheslav Ovsiienko Acked-by: Ajit Khaparde > --- > doc/guides/prog_guide/rte_flow.rst | 25 +++++++++++++++++++++++++ > doc/guides/rel_notes/release_20_11.rst | 6 ++++++ > lib/librte_ethdev/rte_flow.c | 1 + > lib/librte_ethdev/rte_flow.h | 30 ++++++++++++++++++++++++++++++ > 4 files changed, 62 insertions(+) > > diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst > index 119b128..a0046a2 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -2666,6 +2666,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/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst > index b063764..f3aef67 100644 > --- a/doc/guides/rel_notes/release_20_11.rst > +++ b/doc/guides/rel_notes/release_20_11.rst > @@ -118,6 +118,12 @@ New Features > * Extern objects and functions can be plugged into the pipeline. > * Transaction-oriented table updates. > > +* **Added flow-based traffic sampling support.** > + > + Added new action: ``RTE_FLOW_ACTION_TYPE_SAMPLE`` to duplicate the matching > + packets with specified ratio, and apply with own set of actions with a fate > + action. When the ratio is set to 1 then the packets will be 100% mirrored. > + > > Removed Items > ------------- > diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c > index 8d1b279..0a8a7a2 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 >