DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC] ethdev: introduce sample action for rte flow
@ 2020-06-11 13:19 Jiawei Wang
  2020-06-24 17:07 ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Jiawei Wang @ 2020-06-11 13:19 UTC (permalink / raw)
  To: orika, viacheslavo, matan; +Cc: dev, thomas, rasland

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.

The examples for the sample flow use case and result as below:
1. pattern eth / actions decap / sample (ratio=2, actions=mark 8, queue 2) / jump
This flow will result in all the matched ingress packets will be
decapsulated and jumped to next flow table, and the each second packet
will also be decapsulated, marked and sent to queue 2 of the control
application.

2. pattern eth / actions sample (ratio=1, actions=port 1) / port 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.

3. pattern eth / actions sample (ratio=1, actions=encap, port 0) / encap / port 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.

Add a new testpmd command 'set sample_actions' that supports the multiple
sample actions list configuration by using the index:
set sample_actions <index> <actions list>

The examples for the test-pmd command that according the above sample
flow case:
1. set sample_actions 0 mark id 0x8 / queue index 2 / end
   flow create...pattern eth / end actions raw_decap / sample ratio 2 index 0 / jump group 2 / end

2. set sample_actions 1 port_id id 1 / end
   flow create...pattern eth / end actions sample ratio 1 index 1 / port_id id 2 / end

3. 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...pattern eth / end actions sample ratio 1 index 2 / raw_encap index 1 / port_id id 0 / end

Signed-off-by: Jiawei Wang <jiaweiw@mellanox.com>
---
 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 1685be5f73..733871de63 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -173,6 +173,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
 	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 b0e4199192..71dd82c64f 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,
 };
 
 /**
@@ -2708,6 +2715,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.
  *
-- 
2.21.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [RFC] ethdev: introduce sample action for rte flow
  2020-06-11 13:19 [dpdk-dev] [RFC] ethdev: introduce sample action for rte flow Jiawei Wang
@ 2020-06-24 17:07 ` Thomas Monjalon
  2020-06-24 18:09   ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2020-06-24 17:07 UTC (permalink / raw)
  To: dev; +Cc: orika, viacheslavo, matan, rasland, Jiawei Wang, ian.stokes, fbl

Ping for review

11/06/2020 15:19, Jiawei Wang:
> 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.
> 
> The examples for the sample flow use case and result as below:
> 1. pattern eth / actions decap / sample (ratio=2, actions=mark 8, queue 2) / jump
> This flow will result in all the matched ingress packets will be
> decapsulated and jumped to next flow table, and the each second packet
> will also be decapsulated, marked and sent to queue 2 of the control
> application.
> 
> 2. pattern eth / actions sample (ratio=1, actions=port 1) / port 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.
> 
> 3. pattern eth / actions sample (ratio=1, actions=encap, port 0) / encap / port 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.
> 
> Add a new testpmd command 'set sample_actions' that supports the multiple
> sample actions list configuration by using the index:
> set sample_actions <index> <actions list>
> 
> The examples for the test-pmd command that according the above sample
> flow case:
> 1. set sample_actions 0 mark id 0x8 / queue index 2 / end
>    flow create...pattern eth / end actions raw_decap / sample ratio 2 index 0 / jump group 2 / end
> 
> 2. set sample_actions 1 port_id id 1 / end
>    flow create...pattern eth / end actions sample ratio 1 index 1 / port_id id 2 / end
> 
> 3. 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...pattern eth / end actions sample ratio 1 index 2 / raw_encap index 1 / port_id id 0 / end
> 
> Signed-off-by: Jiawei Wang <jiaweiw@mellanox.com>
> ---
>  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 1685be5f73..733871de63 100644
> --- a/lib/librte_ethdev/rte_flow.c
> +++ b/lib/librte_ethdev/rte_flow.c
> @@ -173,6 +173,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
>  	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 b0e4199192..71dd82c64f 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,
>  };
>  
>  /**
> @@ -2708,6 +2715,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.
>   *




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [RFC] ethdev: introduce sample action for rte flow
  2020-06-24 17:07 ` Thomas Monjalon
@ 2020-06-24 18:09   ` Stephen Hemminger
  2020-06-24 19:14     ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2020-06-24 18:09 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, orika, viacheslavo, matan, rasland, Jiawei Wang, ian.stokes, fbl

On Wed, 24 Jun 2020 19:07:49 +0200
Thomas Monjalon <thomas@monjalon.net> wrote:

> >  
> > +/**
> > + * @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;
> > +};

Putting const on the ratio value is not necessary.
Other flow_actions don't do that.

Note: rte_flow action structures seem to have lots of holes.
The value of those holes is undefined. You may want to swap the fields.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [RFC] ethdev: introduce sample action for rte flow
  2020-06-24 18:09   ` Stephen Hemminger
@ 2020-06-24 19:14     ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2020-06-24 19:14 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: dev, orika, viacheslavo, matan, rasland, Jiawei Wang, ian.stokes, fbl

24/06/2020 20:09, Stephen Hemminger:
> > > +/**
> > > + * @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;
> > > +};
> 
> Putting const on the ratio value is not necessary.
> Other flow_actions don't do that.
> 
> Note: rte_flow action structures seem to have lots of holes.
> The value of those holes is undefined. You may want to swap the fields.

Why is it a problem to have holes with undefined value?
If swapping, the hole will be at the end, right?



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-24 19:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-11 13:19 [dpdk-dev] [RFC] ethdev: introduce sample action for rte flow Jiawei Wang
2020-06-24 17:07 ` Thomas Monjalon
2020-06-24 18:09   ` Stephen Hemminger
2020-06-24 19:14     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).