diff mbox series

[v6,11/12] app/testpmd: add port and encap support for sample action

Message ID 1599634114-148013-12-git-send-email-jiaweiw@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series support the flow-based traffic sampling | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Jiawei Wang Sept. 9, 2020, 6:48 a.m. UTC
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.

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(+)

Comments

Ajit Khaparde Sept. 21, 2020, 10:27 p.m. UTC | #1
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
>
Jiawei Wang Sept. 22, 2020, 12:32 p.m. UTC | #2
Yes, Nice catch.

I will fix it.

Thanks.
B.R.
Jonny

> -----Original Message-----
> From: Ajit Khaparde <ajit.khaparde@broadcom.com>
> Sent: Tuesday, September 22, 2020 6:28 AM
> To: Jiawei(Jonny) Wang <jiaweiw@nvidia.com>
> Cc: Ori Kam <orika@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>;
> Matan Azrad <matan@nvidia.com>; NBU-Contact-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>; Raslan
> Darawsheh <rasland@nvidia.com>; ian.stokes@intel.com; fbl@redhat.com;
> Asaf Penso <asafp@nvidia.com>
> Subject: Re: [dpdk-dev] [PATCH v6 11/12] app/testpmd: add port and encap
> support for sample action
> 
> 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
> >
diff mbox series

Patch

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;