All of lore.kernel.org
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/testpmd: support meter color action in policy
@ 2021-04-28 14:10 Haifei Luo
  2021-04-30 12:50 ` Ferruh Yigit
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Haifei Luo @ 2021-04-28 14:10 UTC (permalink / raw)
  To: matan, orika, viacheslavo, ferruh.yigit, Wenzhuo Lu, Beilei Xing,
	Bernard Iremonger
  Cc: dev, thomas, rasland

Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
Add the CLI for this action in meter policy: color type (types)
There are three types: green, yellow and red.

Example for the new policy meter CLIs:
   add port meter policy 0 1 g_actions color type green / end y_actions
     color type yellow / end r_actions color type red / end

In the above command, the action type is RTE_FLOW_ACTION_TYPE_METER_COLOR,
the meter policy action list: green -> green, yellow -> yellow, red -> red.

Signed-off-by: Haifei Luo <haifeil@nvidia.com>
---
 app/test-pmd/cmdline_flow.c | 85 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 5947341..1c587bb 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -348,6 +348,11 @@ enum index {
 	ACTION_PORT_ID_ORIGINAL,
 	ACTION_PORT_ID_ID,
 	ACTION_METER,
+	ACTION_METER_COLOR,
+	ACTION_METER_COLOR_TYPE,
+	ACTION_METER_COLOR_GREEN,
+	ACTION_METER_COLOR_YELLOW,
+	ACTION_METER_COLOR_RED,
 	ACTION_METER_ID,
 	ACTION_OF_SET_MPLS_TTL,
 	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
@@ -1377,6 +1382,7 @@ struct parse_action_priv {
 	ACTION_PHY_PORT,
 	ACTION_PORT_ID,
 	ACTION_METER,
+	ACTION_METER_COLOR,
 	ACTION_OF_SET_MPLS_TTL,
 	ACTION_OF_DEC_MPLS_TTL,
 	ACTION_OF_SET_NW_TTL,
@@ -1486,6 +1492,12 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_meter_color[] = {
+	ACTION_METER_COLOR_TYPE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static const enum index action_of_set_mpls_ttl[] = {
 	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
 	ACTION_NEXT,
@@ -1723,6 +1735,10 @@ static int parse_vc_conf(struct context *, const struct token *,
 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
 				    const char *, unsigned int,
 				    void *, unsigned int);
+static int parse_vc_action_meter_color_type(struct context *,
+					const struct token *,
+					const char *, unsigned int, void *,
+					unsigned int);
 static int parse_vc_action_rss(struct context *, const struct token *,
 			       const char *, unsigned int, void *,
 			       unsigned int);
@@ -3801,6 +3817,37 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
 		.next = NEXT(action_meter),
 		.call = parse_vc,
 	},
+	[ACTION_METER_COLOR] = {
+		.name = "color",
+		.help = "meter color for the packets",
+		.priv = PRIV_ACTION(METER_COLOR,
+				sizeof(struct rte_flow_action_meter_color)),
+		.next = NEXT(action_meter_color),
+		.call = parse_vc,
+	},
+	[ACTION_METER_COLOR_TYPE] = {
+		.name = "type",
+		.help = "specific meter color",
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT),
+				NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
+					ACTION_METER_COLOR_YELLOW,
+					ACTION_METER_COLOR_RED)),
+	},
+	[ACTION_METER_COLOR_GREEN] = {
+		.name = "green",
+		.help = "meter color green",
+		.call = parse_vc_action_meter_color_type,
+	},
+	[ACTION_METER_COLOR_YELLOW] = {
+		.name = "yellow",
+		.help = "meter color yellow",
+		.call = parse_vc_action_meter_color_type,
+	},
+	[ACTION_METER_COLOR_RED] = {
+		.name = "red",
+		.help = "meter color red",
+		.call = parse_vc_action_meter_color_type,
+	},
 	[ACTION_METER_ID] = {
 		.name = "mtr_id",
 		.help = "meter id to use",
@@ -5318,6 +5365,44 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
 	return len;
 }
 
+/** Parse meter color action type. */
+static int
+parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
+				const char *str, unsigned int len,
+				void *buf, unsigned int size)
+{
+	struct rte_flow_action *action_data;
+	struct rte_flow_action_meter_color *conf;
+	enum rte_color color;
+
+	(void)buf;
+	(void)size;
+	/* Token name must match. */
+	if (parse_default(ctx, token, str, len, NULL, 0) < 0)
+		return -1;
+	switch (ctx->curr) {
+	case ACTION_METER_COLOR_GREEN:
+		color = RTE_COLOR_GREEN;
+	break;
+	case ACTION_METER_COLOR_YELLOW:
+		color = RTE_COLOR_YELLOW;
+	break;
+	case ACTION_METER_COLOR_RED:
+		color = RTE_COLOR_RED;
+	break;
+	default:
+		return -1;
+	}
+
+	if (!ctx->object)
+		return len;
+	action_data = ctx->object;
+	conf = (struct rte_flow_action_meter_color *)
+					(uintptr_t)(action_data->conf);
+	conf->color = color;
+	return len;
+}
+
 /** Parse RSS action. */
 static int
 parse_vc_action_rss(struct context *ctx, const struct token *token,
-- 
1.8.3.1


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

* Re: [dpdk-dev] [PATCH] app/testpmd: support meter color action in policy
  2021-04-28 14:10 [dpdk-dev] [PATCH] app/testpmd: support meter color action in policy Haifei Luo
@ 2021-04-30 12:50 ` Ferruh Yigit
  2021-05-03 12:11   ` Dumitrescu, Cristian
  2021-05-11  9:28 ` [dpdk-dev] [PATCH v2] app/testpmd: add CLI for action meter color Haifei Luo
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Ferruh Yigit @ 2021-04-30 12:50 UTC (permalink / raw)
  To: Haifei Luo, matan, orika, viacheslavo, Dumitrescu, Cristian
  Cc: dev, thomas, rasland, Bernard Iremonger, Beilei Xing, Wenzhuo Lu

On 4/28/2021 3:10 PM, Haifei Luo wrote:
> Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
> Add the CLI for this action in meter policy: color type (types)
> There are three types: green, yellow and red.
> 
> Example for the new policy meter CLIs:
>    add port meter policy 0 1 g_actions color type green / end y_actions
>      color type yellow / end r_actions color type red / end
> 
> In the above command, the action type is RTE_FLOW_ACTION_TYPE_METER_COLOR,
> the meter policy action list: green -> green, yellow -> yellow, red -> red.
> 

Ori can you please review this patch too?

+Cristian for meter.

> Signed-off-by: Haifei Luo <haifeil@nvidia.com>
> ---
>  app/test-pmd/cmdline_flow.c | 85 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 85 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 5947341..1c587bb 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -348,6 +348,11 @@ enum index {
>  	ACTION_PORT_ID_ORIGINAL,
>  	ACTION_PORT_ID_ID,
>  	ACTION_METER,
> +	ACTION_METER_COLOR,
> +	ACTION_METER_COLOR_TYPE,
> +	ACTION_METER_COLOR_GREEN,
> +	ACTION_METER_COLOR_YELLOW,
> +	ACTION_METER_COLOR_RED,
>  	ACTION_METER_ID,
>  	ACTION_OF_SET_MPLS_TTL,
>  	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
> @@ -1377,6 +1382,7 @@ struct parse_action_priv {
>  	ACTION_PHY_PORT,
>  	ACTION_PORT_ID,
>  	ACTION_METER,
> +	ACTION_METER_COLOR,
>  	ACTION_OF_SET_MPLS_TTL,
>  	ACTION_OF_DEC_MPLS_TTL,
>  	ACTION_OF_SET_NW_TTL,
> @@ -1486,6 +1492,12 @@ struct parse_action_priv {
>  	ZERO,
>  };
>  
> +static const enum index action_meter_color[] = {
> +	ACTION_METER_COLOR_TYPE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
>  static const enum index action_of_set_mpls_ttl[] = {
>  	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
>  	ACTION_NEXT,
> @@ -1723,6 +1735,10 @@ static int parse_vc_conf(struct context *, const struct token *,
>  static int parse_vc_item_ecpri_type(struct context *, const struct token *,
>  				    const char *, unsigned int,
>  				    void *, unsigned int);
> +static int parse_vc_action_meter_color_type(struct context *,
> +					const struct token *,
> +					const char *, unsigned int, void *,
> +					unsigned int);
>  static int parse_vc_action_rss(struct context *, const struct token *,
>  			       const char *, unsigned int, void *,
>  			       unsigned int);
> @@ -3801,6 +3817,37 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
>  		.next = NEXT(action_meter),
>  		.call = parse_vc,
>  	},
> +	[ACTION_METER_COLOR] = {
> +		.name = "color",
> +		.help = "meter color for the packets",
> +		.priv = PRIV_ACTION(METER_COLOR,
> +				sizeof(struct rte_flow_action_meter_color)),
> +		.next = NEXT(action_meter_color),
> +		.call = parse_vc,
> +	},
> +	[ACTION_METER_COLOR_TYPE] = {
> +		.name = "type",
> +		.help = "specific meter color",
> +		.next = NEXT(NEXT_ENTRY(ACTION_NEXT),
> +				NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
> +					ACTION_METER_COLOR_YELLOW,
> +					ACTION_METER_COLOR_RED)),
> +	},
> +	[ACTION_METER_COLOR_GREEN] = {
> +		.name = "green",
> +		.help = "meter color green",
> +		.call = parse_vc_action_meter_color_type,
> +	},
> +	[ACTION_METER_COLOR_YELLOW] = {
> +		.name = "yellow",
> +		.help = "meter color yellow",
> +		.call = parse_vc_action_meter_color_type,
> +	},
> +	[ACTION_METER_COLOR_RED] = {
> +		.name = "red",
> +		.help = "meter color red",
> +		.call = parse_vc_action_meter_color_type,
> +	},
>  	[ACTION_METER_ID] = {
>  		.name = "mtr_id",
>  		.help = "meter id to use",
> @@ -5318,6 +5365,44 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
>  	return len;
>  }
>  
> +/** Parse meter color action type. */
> +static int
> +parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
> +				const char *str, unsigned int len,
> +				void *buf, unsigned int size)
> +{
> +	struct rte_flow_action *action_data;
> +	struct rte_flow_action_meter_color *conf;
> +	enum rte_color color;
> +
> +	(void)buf;
> +	(void)size;
> +	/* Token name must match. */
> +	if (parse_default(ctx, token, str, len, NULL, 0) < 0)
> +		return -1;
> +	switch (ctx->curr) {
> +	case ACTION_METER_COLOR_GREEN:
> +		color = RTE_COLOR_GREEN;
> +	break;
> +	case ACTION_METER_COLOR_YELLOW:
> +		color = RTE_COLOR_YELLOW;
> +	break;
> +	case ACTION_METER_COLOR_RED:
> +		color = RTE_COLOR_RED;
> +	break;
> +	default:
> +		return -1;
> +	}
> +
> +	if (!ctx->object)
> +		return len;
> +	action_data = ctx->object;
> +	conf = (struct rte_flow_action_meter_color *)
> +					(uintptr_t)(action_data->conf);
> +	conf->color = color;
> +	return len;
> +}
> +
>  /** Parse RSS action. */
>  static int
>  parse_vc_action_rss(struct context *ctx, const struct token *token,
> 


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

* Re: [dpdk-dev] [PATCH] app/testpmd: support meter color action in policy
  2021-04-30 12:50 ` Ferruh Yigit
@ 2021-05-03 12:11   ` Dumitrescu, Cristian
  2021-05-05 15:42     ` Ori Kam
  0 siblings, 1 reply; 18+ messages in thread
From: Dumitrescu, Cristian @ 2021-05-03 12:11 UTC (permalink / raw)
  To: Yigit, Ferruh, Haifei Luo, matan, orika, viacheslavo, Singh, Jasvinder
  Cc: dev, thomas, rasland, Iremonger,  Bernard, Xing, Beilei, Lu, Wenzhuo



> -----Original Message-----
> From: Yigit, Ferruh <ferruh.yigit@intel.com>
> Sent: Friday, April 30, 2021 1:51 PM
> To: Haifei Luo <haifeil@nvidia.com>; matan@nvidia.com; orika@nvidia.com;
> viacheslavo@nvidia.com; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org; thomas@monjalon.net; rasland@nvidia.com; Iremonger,
> Bernard <bernard.iremonger@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Subject: Re: [PATCH] app/testpmd: support meter color action in policy
> 
> On 4/28/2021 3:10 PM, Haifei Luo wrote:
> > Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
> > Add the CLI for this action in meter policy: color type (types)
> > There are three types: green, yellow and red.
> >
> > Example for the new policy meter CLIs:
> >    add port meter policy 0 1 g_actions color type green / end y_actions
> >      color type yellow / end r_actions color type red / end
> >
> > In the above command, the action type is
> RTE_FLOW_ACTION_TYPE_METER_COLOR,
> > the meter policy action list: green -> green, yellow -> yellow, red -> red.
> >
> 
> Ori can you please review this patch too?
> 
> +Cristian for meter.
> 

Cc Jasvinder

> > Signed-off-by: Haifei Luo <haifeil@nvidia.com>
> > ---
> >  app/test-pmd/cmdline_flow.c | 85
> +++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 85 insertions(+)
> >
> > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> > index 5947341..1c587bb 100644
> > --- a/app/test-pmd/cmdline_flow.c
> > +++ b/app/test-pmd/cmdline_flow.c
> > @@ -348,6 +348,11 @@ enum index {
> >  	ACTION_PORT_ID_ORIGINAL,
> >  	ACTION_PORT_ID_ID,
> >  	ACTION_METER,
> > +	ACTION_METER_COLOR,
> > +	ACTION_METER_COLOR_TYPE,
> > +	ACTION_METER_COLOR_GREEN,
> > +	ACTION_METER_COLOR_YELLOW,
> > +	ACTION_METER_COLOR_RED,
> >  	ACTION_METER_ID,
> >  	ACTION_OF_SET_MPLS_TTL,
> >  	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
> > @@ -1377,6 +1382,7 @@ struct parse_action_priv {
> >  	ACTION_PHY_PORT,
> >  	ACTION_PORT_ID,
> >  	ACTION_METER,
> > +	ACTION_METER_COLOR,
> >  	ACTION_OF_SET_MPLS_TTL,
> >  	ACTION_OF_DEC_MPLS_TTL,
> >  	ACTION_OF_SET_NW_TTL,
> > @@ -1486,6 +1492,12 @@ struct parse_action_priv {
> >  	ZERO,
> >  };
> >
> > +static const enum index action_meter_color[] = {
> > +	ACTION_METER_COLOR_TYPE,
> > +	ACTION_NEXT,
> > +	ZERO,
> > +};
> > +
> >  static const enum index action_of_set_mpls_ttl[] = {
> >  	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
> >  	ACTION_NEXT,
> > @@ -1723,6 +1735,10 @@ static int parse_vc_conf(struct context *, const
> struct token *,
> >  static int parse_vc_item_ecpri_type(struct context *, const struct token *,
> >  				    const char *, unsigned int,
> >  				    void *, unsigned int);
> > +static int parse_vc_action_meter_color_type(struct context *,
> > +					const struct token *,
> > +					const char *, unsigned int, void *,
> > +					unsigned int);
> >  static int parse_vc_action_rss(struct context *, const struct token *,
> >  			       const char *, unsigned int, void *,
> >  			       unsigned int);
> > @@ -3801,6 +3817,37 @@ static int comp_set_modify_field_id(struct
> context *, const struct token *,
> >  		.next = NEXT(action_meter),
> >  		.call = parse_vc,
> >  	},
> > +	[ACTION_METER_COLOR] = {
> > +		.name = "color",
> > +		.help = "meter color for the packets",
> > +		.priv = PRIV_ACTION(METER_COLOR,
> > +				sizeof(struct rte_flow_action_meter_color)),
> > +		.next = NEXT(action_meter_color),
> > +		.call = parse_vc,
> > +	},
> > +	[ACTION_METER_COLOR_TYPE] = {
> > +		.name = "type",
> > +		.help = "specific meter color",
> > +		.next = NEXT(NEXT_ENTRY(ACTION_NEXT),
> > +
> 	NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
> > +					ACTION_METER_COLOR_YELLOW,
> > +					ACTION_METER_COLOR_RED)),
> > +	},
> > +	[ACTION_METER_COLOR_GREEN] = {
> > +		.name = "green",
> > +		.help = "meter color green",
> > +		.call = parse_vc_action_meter_color_type,
> > +	},
> > +	[ACTION_METER_COLOR_YELLOW] = {
> > +		.name = "yellow",
> > +		.help = "meter color yellow",
> > +		.call = parse_vc_action_meter_color_type,
> > +	},
> > +	[ACTION_METER_COLOR_RED] = {
> > +		.name = "red",
> > +		.help = "meter color red",
> > +		.call = parse_vc_action_meter_color_type,
> > +	},
> >  	[ACTION_METER_ID] = {
> >  		.name = "mtr_id",
> >  		.help = "meter id to use",
> > @@ -5318,6 +5365,44 @@ static int comp_set_modify_field_id(struct
> context *, const struct token *,
> >  	return len;
> >  }
> >
> > +/** Parse meter color action type. */
> > +static int
> > +parse_vc_action_meter_color_type(struct context *ctx, const struct
> token *token,
> > +				const char *str, unsigned int len,
> > +				void *buf, unsigned int size)
> > +{
> > +	struct rte_flow_action *action_data;
> > +	struct rte_flow_action_meter_color *conf;
> > +	enum rte_color color;
> > +
> > +	(void)buf;
> > +	(void)size;
> > +	/* Token name must match. */
> > +	if (parse_default(ctx, token, str, len, NULL, 0) < 0)
> > +		return -1;
> > +	switch (ctx->curr) {
> > +	case ACTION_METER_COLOR_GREEN:
> > +		color = RTE_COLOR_GREEN;
> > +	break;
> > +	case ACTION_METER_COLOR_YELLOW:
> > +		color = RTE_COLOR_YELLOW;
> > +	break;
> > +	case ACTION_METER_COLOR_RED:
> > +		color = RTE_COLOR_RED;
> > +	break;
> > +	default:
> > +		return -1;
> > +	}
> > +
> > +	if (!ctx->object)
> > +		return len;
> > +	action_data = ctx->object;
> > +	conf = (struct rte_flow_action_meter_color *)
> > +					(uintptr_t)(action_data->conf);
> > +	conf->color = color;
> > +	return len;
> > +}
> > +
> >  /** Parse RSS action. */
> >  static int
> >  parse_vc_action_rss(struct context *ctx, const struct token *token,
> >


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

* Re: [dpdk-dev] [PATCH] app/testpmd: support meter color action in policy
  2021-05-03 12:11   ` Dumitrescu, Cristian
@ 2021-05-05 15:42     ` Ori Kam
  0 siblings, 0 replies; 18+ messages in thread
From: Ori Kam @ 2021-05-05 15:42 UTC (permalink / raw)
  To: Dumitrescu, Cristian, Yigit, Ferruh, Haifei Luo, Matan Azrad,
	Slava Ovsiienko, Singh, Jasvinder
  Cc: dev, NBU-Contact-Thomas Monjalon, Raslan Darawsheh, Iremonger,
	Bernard, Xing, Beilei, Lu, Wenzhuo

HI Haifei,

> -----Original Message-----
> From: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Sent: Monday, May 3, 2021 3:11 PM
> Subject: RE: [PATCH] app/testpmd: support meter color action in policy
> 
> 
> 
> > -----Original Message-----
> > From: Yigit, Ferruh <ferruh.yigit@intel.com>
> > Sent: Friday, April 30, 2021 1:51 PM
> > To: Haifei Luo <haifeil@nvidia.com>; matan@nvidia.com;
> > orika@nvidia.com; viacheslavo@nvidia.com; Dumitrescu, Cristian
> > <cristian.dumitrescu@intel.com>
> > Cc: dev@dpdk.org; thomas@monjalon.net; rasland@nvidia.com;
> Iremonger,
> > Bernard <bernard.iremonger@intel.com>; Xing, Beilei
> > <beilei.xing@intel.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>
> > Subject: Re: [PATCH] app/testpmd: support meter color action in policy
> >
> > On 4/28/2021 3:10 PM, Haifei Luo wrote:
> > > Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
> > > Add the CLI for this action in meter policy: color type (types)
> > > There are three types: green, yellow and red.
> > >
> > > Example for the new policy meter CLIs:
> > >    add port meter policy 0 1 g_actions color type green / end y_actions
> > >      color type yellow / end r_actions color type red / end
> > >
> > > In the above command, the action type is
> > RTE_FLOW_ACTION_TYPE_METER_COLOR,
> > > the meter policy action list: green -> green, yellow -> yellow, red -> red.
> > >
> >
> > Ori can you please review this patch too?
> >
> > +Cristian for meter.
> >
> 
> Cc Jasvinder
> 
> > > Signed-off-by: Haifei Luo <haifeil@nvidia.com>
> > > ---
> > >  app/test-pmd/cmdline_flow.c | 85
> > +++++++++++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 85 insertions(+)
> > >
> > > diff --git a/app/test-pmd/cmdline_flow.c
> > > b/app/test-pmd/cmdline_flow.c index 5947341..1c587bb 100644
> > > --- a/app/test-pmd/cmdline_flow.c
> > > +++ b/app/test-pmd/cmdline_flow.c
> > > @@ -348,6 +348,11 @@ enum index {
> > >  	ACTION_PORT_ID_ORIGINAL,
> > >  	ACTION_PORT_ID_ID,
> > >  	ACTION_METER,
> > > +	ACTION_METER_COLOR,
> > > +	ACTION_METER_COLOR_TYPE,
> > > +	ACTION_METER_COLOR_GREEN,
> > > +	ACTION_METER_COLOR_YELLOW,
> > > +	ACTION_METER_COLOR_RED,
> > >  	ACTION_METER_ID,
> > >  	ACTION_OF_SET_MPLS_TTL,
> > >  	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
> > > @@ -1377,6 +1382,7 @@ struct parse_action_priv {
> > >  	ACTION_PHY_PORT,
> > >  	ACTION_PORT_ID,
> > >  	ACTION_METER,
> > > +	ACTION_METER_COLOR,
> > >  	ACTION_OF_SET_MPLS_TTL,
> > >  	ACTION_OF_DEC_MPLS_TTL,
> > >  	ACTION_OF_SET_NW_TTL,
> > > @@ -1486,6 +1492,12 @@ struct parse_action_priv {
> > >  	ZERO,
> > >  };
> > >
> > > +static const enum index action_meter_color[] = {
> > > +	ACTION_METER_COLOR_TYPE,
> > > +	ACTION_NEXT,
> > > +	ZERO,
> > > +};
> > > +
> > >  static const enum index action_of_set_mpls_ttl[] = {
> > >  	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
> > >  	ACTION_NEXT,
> > > @@ -1723,6 +1735,10 @@ static int parse_vc_conf(struct context *,
> > > const
> > struct token *,
> > >  static int parse_vc_item_ecpri_type(struct context *, const struct token
> *,
> > >  				    const char *, unsigned int,
> > >  				    void *, unsigned int);
> > > +static int parse_vc_action_meter_color_type(struct context *,
> > > +					const struct token *,
> > > +					const char *, unsigned int, void *,
> > > +					unsigned int);
> > >  static int parse_vc_action_rss(struct context *, const struct token *,
> > >  			       const char *, unsigned int, void *,
> > >  			       unsigned int);
> > > @@ -3801,6 +3817,37 @@ static int comp_set_modify_field_id(struct
> > context *, const struct token *,
> > >  		.next = NEXT(action_meter),
> > >  		.call = parse_vc,
> > >  	},
> > > +	[ACTION_METER_COLOR] = {
> > > +		.name = "color",
> > > +		.help = "meter color for the packets",
> > > +		.priv = PRIV_ACTION(METER_COLOR,
> > > +				sizeof(struct rte_flow_action_meter_color)),
> > > +		.next = NEXT(action_meter_color),
> > > +		.call = parse_vc,
> > > +	},
> > > +	[ACTION_METER_COLOR_TYPE] = {
> > > +		.name = "type",
> > > +		.help = "specific meter color",
> > > +		.next = NEXT(NEXT_ENTRY(ACTION_NEXT),
> > > +
> > 	NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
> > > +					ACTION_METER_COLOR_YELLOW,
> > > +					ACTION_METER_COLOR_RED)),
> > > +	},
> > > +	[ACTION_METER_COLOR_GREEN] = {
> > > +		.name = "green",
> > > +		.help = "meter color green",
> > > +		.call = parse_vc_action_meter_color_type,
> > > +	},
> > > +	[ACTION_METER_COLOR_YELLOW] = {
> > > +		.name = "yellow",
> > > +		.help = "meter color yellow",
> > > +		.call = parse_vc_action_meter_color_type,
> > > +	},
> > > +	[ACTION_METER_COLOR_RED] = {
> > > +		.name = "red",
> > > +		.help = "meter color red",
> > > +		.call = parse_vc_action_meter_color_type,
> > > +	},
> > >  	[ACTION_METER_ID] = {
> > >  		.name = "mtr_id",
> > >  		.help = "meter id to use",
> > > @@ -5318,6 +5365,44 @@ static int comp_set_modify_field_id(struct
> > context *, const struct token *,
> > >  	return len;
> > >  }
> > >
> > > +/** Parse meter color action type. */ static int
> > > +parse_vc_action_meter_color_type(struct context *ctx, const struct
> > token *token,
> > > +				const char *str, unsigned int len,
> > > +				void *buf, unsigned int size)
> > > +{
> > > +	struct rte_flow_action *action_data;
> > > +	struct rte_flow_action_meter_color *conf;
> > > +	enum rte_color color;
> > > +
> > > +	(void)buf;
> > > +	(void)size;
> > > +	/* Token name must match. */
> > > +	if (parse_default(ctx, token, str, len, NULL, 0) < 0)
> > > +		return -1;
> > > +	switch (ctx->curr) {
> > > +	case ACTION_METER_COLOR_GREEN:
> > > +		color = RTE_COLOR_GREEN;
> > > +	break;
> > > +	case ACTION_METER_COLOR_YELLOW:
> > > +		color = RTE_COLOR_YELLOW;
> > > +	break;
> > > +	case ACTION_METER_COLOR_RED:
> > > +		color = RTE_COLOR_RED;
> > > +	break;
> > > +	default:
> > > +		return -1;
> > > +	}
> > > +
> > > +	if (!ctx->object)
> > > +		return len;
> > > +	action_data = ctx->object;
> > > +	conf = (struct rte_flow_action_meter_color *)
> > > +					(uintptr_t)(action_data->conf);
> > > +	conf->color = color;
> > > +	return len;
> > > +}
> > > +
> > >  /** Parse RSS action. */
> > >  static int
> > >  parse_vc_action_rss(struct context *ctx, const struct token *token,
> > >

Acked-by: Ori Kam <orika@nvidia.com>
Best,
Ori


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

* [dpdk-dev] [PATCH v2] app/testpmd: add CLI for action meter color
  2021-04-28 14:10 [dpdk-dev] [PATCH] app/testpmd: support meter color action in policy Haifei Luo
  2021-04-30 12:50 ` Ferruh Yigit
@ 2021-05-11  9:28 ` Haifei Luo
  2021-05-11 11:35   ` Ferruh Yigit
  2021-05-11 19:22   ` Ferruh Yigit
  2021-05-12  7:02 ` [dpdk-dev] [PATCH v3] " Haifei Luo
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 18+ messages in thread
From: Haifei Luo @ 2021-05-11  9:28 UTC (permalink / raw)
  To: matan, orika, viacheslavo, ferruh.yigit, Xiaoyun Li; +Cc: dev, thomas, rasland

Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
Add the CLI for this action in meter policy: color type (types)
There are three types: green, yellow and red.

Example for the new policy meter CLIs:
   add port meter policy 0 1 g_actions color type green / end y_actions
        color type yellow / end r_actions color type red / end

In the above command, the action type is RTE_FLOW_ACTION_TYPE_METER_COLOR,
the meter policy action list: green -> green, yellow -> yellow, red -> red.

V2: rebase the latest code.

Signed-off-by: Haifei Luo <haifeil@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>

---
 app/test-pmd/cmdline_flow.c | 85 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 5947341..1c587bb 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -348,6 +348,11 @@ enum index {
 	ACTION_PORT_ID_ORIGINAL,
 	ACTION_PORT_ID_ID,
 	ACTION_METER,
+	ACTION_METER_COLOR,
+	ACTION_METER_COLOR_TYPE,
+	ACTION_METER_COLOR_GREEN,
+	ACTION_METER_COLOR_YELLOW,
+	ACTION_METER_COLOR_RED,
 	ACTION_METER_ID,
 	ACTION_OF_SET_MPLS_TTL,
 	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
@@ -1377,6 +1382,7 @@ struct parse_action_priv {
 	ACTION_PHY_PORT,
 	ACTION_PORT_ID,
 	ACTION_METER,
+	ACTION_METER_COLOR,
 	ACTION_OF_SET_MPLS_TTL,
 	ACTION_OF_DEC_MPLS_TTL,
 	ACTION_OF_SET_NW_TTL,
@@ -1486,6 +1492,12 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_meter_color[] = {
+	ACTION_METER_COLOR_TYPE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static const enum index action_of_set_mpls_ttl[] = {
 	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
 	ACTION_NEXT,
@@ -1723,6 +1735,10 @@ static int parse_vc_conf(struct context *, const struct token *,
 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
 				    const char *, unsigned int,
 				    void *, unsigned int);
+static int parse_vc_action_meter_color_type(struct context *,
+					const struct token *,
+					const char *, unsigned int, void *,
+					unsigned int);
 static int parse_vc_action_rss(struct context *, const struct token *,
 			       const char *, unsigned int, void *,
 			       unsigned int);
@@ -3801,6 +3817,37 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
 		.next = NEXT(action_meter),
 		.call = parse_vc,
 	},
+	[ACTION_METER_COLOR] = {
+		.name = "color",
+		.help = "meter color for the packets",
+		.priv = PRIV_ACTION(METER_COLOR,
+				sizeof(struct rte_flow_action_meter_color)),
+		.next = NEXT(action_meter_color),
+		.call = parse_vc,
+	},
+	[ACTION_METER_COLOR_TYPE] = {
+		.name = "type",
+		.help = "specific meter color",
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT),
+				NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
+					ACTION_METER_COLOR_YELLOW,
+					ACTION_METER_COLOR_RED)),
+	},
+	[ACTION_METER_COLOR_GREEN] = {
+		.name = "green",
+		.help = "meter color green",
+		.call = parse_vc_action_meter_color_type,
+	},
+	[ACTION_METER_COLOR_YELLOW] = {
+		.name = "yellow",
+		.help = "meter color yellow",
+		.call = parse_vc_action_meter_color_type,
+	},
+	[ACTION_METER_COLOR_RED] = {
+		.name = "red",
+		.help = "meter color red",
+		.call = parse_vc_action_meter_color_type,
+	},
 	[ACTION_METER_ID] = {
 		.name = "mtr_id",
 		.help = "meter id to use",
@@ -5318,6 +5365,44 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
 	return len;
 }
 
+/** Parse meter color action type. */
+static int
+parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
+				const char *str, unsigned int len,
+				void *buf, unsigned int size)
+{
+	struct rte_flow_action *action_data;
+	struct rte_flow_action_meter_color *conf;
+	enum rte_color color;
+
+	(void)buf;
+	(void)size;
+	/* Token name must match. */
+	if (parse_default(ctx, token, str, len, NULL, 0) < 0)
+		return -1;
+	switch (ctx->curr) {
+	case ACTION_METER_COLOR_GREEN:
+		color = RTE_COLOR_GREEN;
+	break;
+	case ACTION_METER_COLOR_YELLOW:
+		color = RTE_COLOR_YELLOW;
+	break;
+	case ACTION_METER_COLOR_RED:
+		color = RTE_COLOR_RED;
+	break;
+	default:
+		return -1;
+	}
+
+	if (!ctx->object)
+		return len;
+	action_data = ctx->object;
+	conf = (struct rte_flow_action_meter_color *)
+					(uintptr_t)(action_data->conf);
+	conf->color = color;
+	return len;
+}
+
 /** Parse RSS action. */
 static int
 parse_vc_action_rss(struct context *ctx, const struct token *token,
-- 
1.8.3.1


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

* Re: [dpdk-dev] [PATCH v2] app/testpmd: add CLI for action meter color
  2021-05-11  9:28 ` [dpdk-dev] [PATCH v2] app/testpmd: add CLI for action meter color Haifei Luo
@ 2021-05-11 11:35   ` Ferruh Yigit
  2021-05-11 12:34     ` Dumitrescu, Cristian
  2021-05-11 19:22   ` Ferruh Yigit
  1 sibling, 1 reply; 18+ messages in thread
From: Ferruh Yigit @ 2021-05-11 11:35 UTC (permalink / raw)
  To: Haifei Luo, matan, orika, viacheslavo, Xiaoyun Li
  Cc: dev, thomas, rasland, Singh, Jasvinder, Dumitrescu, Cristian

On 5/11/2021 10:28 AM, Haifei Luo wrote:
> Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
> Add the CLI for this action in meter policy: color type (types)
> There are three types: green, yellow and red.
> 
> Example for the new policy meter CLIs:
>    add port meter policy 0 1 g_actions color type green / end y_actions
>         color type yellow / end r_actions color type red / end
> 
> In the above command, the action type is RTE_FLOW_ACTION_TYPE_METER_COLOR,
> the meter policy action list: green -> green, yellow -> yellow, red -> red.
> 
> V2: rebase the latest code.
> 
> Signed-off-by: Haifei Luo <haifeil@nvidia.com>
> Acked-by: Ori Kam <orika@nvidia.com>


cc'ed Jasvinder & Cristian for review.

This patch is not a fix but adding support for testing new meter action type, so
I assume it can be postponed to next release if missing review from maintainers.

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

* Re: [dpdk-dev] [PATCH v2] app/testpmd: add CLI for action meter color
  2021-05-11 11:35   ` Ferruh Yigit
@ 2021-05-11 12:34     ` Dumitrescu, Cristian
  2021-05-11 13:20       ` Ferruh Yigit
  0 siblings, 1 reply; 18+ messages in thread
From: Dumitrescu, Cristian @ 2021-05-11 12:34 UTC (permalink / raw)
  To: Yigit, Ferruh, Haifei Luo, matan, orika, viacheslavo, Li, Xiaoyun
  Cc: dev, thomas, rasland, Singh, Jasvinder



> -----Original Message-----
> From: Yigit, Ferruh <ferruh.yigit@intel.com>
> Sent: Tuesday, May 11, 2021 12:35 PM
> To: Haifei Luo <haifeil@nvidia.com>; matan@nvidia.com; orika@nvidia.com;
> viacheslavo@nvidia.com; Li, Xiaoyun <xiaoyun.li@intel.com>
> Cc: dev@dpdk.org; thomas@monjalon.net; rasland@nvidia.com; Singh,
> Jasvinder <jasvinder.singh@intel.com>; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>
> Subject: Re: [PATCH v2] app/testpmd: add CLI for action meter color
> 
> On 5/11/2021 10:28 AM, Haifei Luo wrote:
> > Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
> > Add the CLI for this action in meter policy: color type (types)
> > There are three types: green, yellow and red.
> >
> > Example for the new policy meter CLIs:
> >    add port meter policy 0 1 g_actions color type green / end y_actions
> >         color type yellow / end r_actions color type red / end
> >
> > In the above command, the action type is
> RTE_FLOW_ACTION_TYPE_METER_COLOR,
> > the meter policy action list: green -> green, yellow -> yellow, red -> red.
> >
> > V2: rebase the latest code.
> >
> > Signed-off-by: Haifei Luo <haifeil@nvidia.com>
> > Acked-by: Ori Kam <orika@nvidia.com>
> 
> 
> cc'ed Jasvinder & Cristian for review.
> 
> This patch is not a fix but adding support for testing new meter action type,
> so
> I assume it can be postponed to next release if missing review from
> maintainers.

Hi Ferruh,

This patch looks good to me, but I think it should be reviewed and acked by Xiaoyun, the testpmd maintainer, who is already in the To: list?

Regards,
Cristian

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

* Re: [dpdk-dev] [PATCH v2] app/testpmd: add CLI for action meter color
  2021-05-11 12:34     ` Dumitrescu, Cristian
@ 2021-05-11 13:20       ` Ferruh Yigit
  2021-05-12 19:54         ` Dumitrescu, Cristian
  0 siblings, 1 reply; 18+ messages in thread
From: Ferruh Yigit @ 2021-05-11 13:20 UTC (permalink / raw)
  To: Dumitrescu, Cristian, Haifei Luo, matan, orika, viacheslavo, Li, Xiaoyun
  Cc: dev, thomas, rasland, Singh, Jasvinder

On 5/11/2021 1:34 PM, Dumitrescu, Cristian wrote:
> 
> 
>> -----Original Message-----
>> From: Yigit, Ferruh <ferruh.yigit@intel.com>
>> Sent: Tuesday, May 11, 2021 12:35 PM
>> To: Haifei Luo <haifeil@nvidia.com>; matan@nvidia.com; orika@nvidia.com;
>> viacheslavo@nvidia.com; Li, Xiaoyun <xiaoyun.li@intel.com>
>> Cc: dev@dpdk.org; thomas@monjalon.net; rasland@nvidia.com; Singh,
>> Jasvinder <jasvinder.singh@intel.com>; Dumitrescu, Cristian
>> <cristian.dumitrescu@intel.com>
>> Subject: Re: [PATCH v2] app/testpmd: add CLI for action meter color
>>
>> On 5/11/2021 10:28 AM, Haifei Luo wrote:
>>> Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
>>> Add the CLI for this action in meter policy: color type (types)
>>> There are three types: green, yellow and red.
>>>
>>> Example for the new policy meter CLIs:
>>>    add port meter policy 0 1 g_actions color type green / end y_actions
>>>         color type yellow / end r_actions color type red / end
>>>
>>> In the above command, the action type is
>> RTE_FLOW_ACTION_TYPE_METER_COLOR,
>>> the meter policy action list: green -> green, yellow -> yellow, red -> red.
>>>
>>> V2: rebase the latest code.
>>>
>>> Signed-off-by: Haifei Luo <haifeil@nvidia.com>
>>> Acked-by: Ori Kam <orika@nvidia.com>
>>
>>
>> cc'ed Jasvinder & Cristian for review.
>>
>> This patch is not a fix but adding support for testing new meter action type,
>> so
>> I assume it can be postponed to next release if missing review from
>> maintainers.
> 
> Hi Ferruh,
> 
> This patch looks good to me, but I think it should be reviewed and acked by Xiaoyun, the testpmd maintainer, who is already in the To: list?
> 

If so I will proceed with your explicit ack:
Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Xiaoyun is main maintainer but for some submodules we rely on the relevant
maintainer, like flow API related part to Ori or for meter/tm part to you etc..

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

* Re: [dpdk-dev] [PATCH v2] app/testpmd: add CLI for action meter color
  2021-05-11  9:28 ` [dpdk-dev] [PATCH v2] app/testpmd: add CLI for action meter color Haifei Luo
  2021-05-11 11:35   ` Ferruh Yigit
@ 2021-05-11 19:22   ` Ferruh Yigit
  2021-05-12  1:41     ` Haifei Luo
  1 sibling, 1 reply; 18+ messages in thread
From: Ferruh Yigit @ 2021-05-11 19:22 UTC (permalink / raw)
  To: Haifei Luo, matan, orika, viacheslavo, Xiaoyun Li; +Cc: dev, thomas, rasland

On 5/11/2021 10:28 AM, Haifei Luo wrote:
> Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
> Add the CLI for this action in meter policy: color type (types)
> There are three types: green, yellow and red.
> 
> Example for the new policy meter CLIs:
>    add port meter policy 0 1 g_actions color type green / end y_actions
>         color type yellow / end r_actions color type red / end
> 
> In the above command, the action type is RTE_FLOW_ACTION_TYPE_METER_COLOR,
> the meter policy action list: green -> green, yellow -> yellow, red -> red.
> 
> V2: rebase the latest code.

Hint: you can put the changelog as last thing in commit log after '---' marker,
than it will be taken as note and will automatically removed by "git am".

> 
> Signed-off-by: Haifei Luo <haifeil@nvidia.com>
> Acked-by: Ori Kam <orika@nvidia.com>
> 
> ---
>  app/test-pmd/cmdline_flow.c | 85 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 85 insertions(+)

Hi Haifei,

Can you please document new command in the testpmd documentation,
'testpmd_funcs.rst' has already "add port meter policy ..." command documented,
you can extend it unless there is no better place to document this new command.

Can you also update release notes too, there is already a block there listing
new commands, this can go into same place.



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

* Re: [dpdk-dev] [PATCH v2] app/testpmd: add CLI for action meter color
  2021-05-11 19:22   ` Ferruh Yigit
@ 2021-05-12  1:41     ` Haifei Luo
  2021-05-12  7:03       ` Haifei Luo
  0 siblings, 1 reply; 18+ messages in thread
From: Haifei Luo @ 2021-05-12  1:41 UTC (permalink / raw)
  To: Ferruh Yigit, Matan Azrad, Ori Kam, Slava Ovsiienko, Xiaoyun Li
  Cc: dev, NBU-Contact-Thomas Monjalon, Raslan Darawsheh

HI Ferruh,
     Will update the doc and send V3. Thank you.

-----Original Message-----
From: Ferruh Yigit <ferruh.yigit@intel.com> 
Sent: Wednesday, May 12, 2021 3:22 AM
To: Haifei Luo <haifeil@nvidia.com>; Matan Azrad <matan@nvidia.com>; Ori Kam <orika@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>; Xiaoyun Li <xiaoyun.li@intel.com>
Cc: dev@dpdk.org; NBU-Contact-Thomas Monjalon <thomas@monjalon.net>; Raslan Darawsheh <rasland@nvidia.com>
Subject: Re: [PATCH v2] app/testpmd: add CLI for action meter color

External email: Use caution opening links or attachments


On 5/11/2021 10:28 AM, Haifei Luo wrote:
> Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
> Add the CLI for this action in meter policy: color type (types) There 
> are three types: green, yellow and red.
>
> Example for the new policy meter CLIs:
>    add port meter policy 0 1 g_actions color type green / end y_actions
>         color type yellow / end r_actions color type red / end
>
> In the above command, the action type is 
> RTE_FLOW_ACTION_TYPE_METER_COLOR, the meter policy action list: green -> green, yellow -> yellow, red -> red.
>
> V2: rebase the latest code.

Hint: you can put the changelog as last thing in commit log after '---' marker, than it will be taken as note and will automatically removed by "git am".

>
> Signed-off-by: Haifei Luo <haifeil@nvidia.com>
> Acked-by: Ori Kam <orika@nvidia.com>
>
> ---
>  app/test-pmd/cmdline_flow.c | 85 
> +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 85 insertions(+)

Hi Haifei,

Can you please document new command in the testpmd documentation, 'testpmd_funcs.rst' has already "add port meter policy ..." command documented, you can extend it unless there is no better place to document this new command.

Can you also update release notes too, there is already a block there listing new commands, this can go into same place.



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

* [dpdk-dev] [PATCH v3] app/testpmd: add CLI for action meter color
  2021-04-28 14:10 [dpdk-dev] [PATCH] app/testpmd: support meter color action in policy Haifei Luo
  2021-04-30 12:50 ` Ferruh Yigit
  2021-05-11  9:28 ` [dpdk-dev] [PATCH v2] app/testpmd: add CLI for action meter color Haifei Luo
@ 2021-05-12  7:02 ` Haifei Luo
  2021-05-12  8:33   ` Ferruh Yigit
  2021-05-12 10:49 ` [dpdk-dev] [PATCH v4] " Haifei Luo
  2021-05-12 12:19 ` [dpdk-dev] [PATCH v5] " Haifei Luo
  4 siblings, 1 reply; 18+ messages in thread
From: Haifei Luo @ 2021-05-12  7:02 UTC (permalink / raw)
  To: matan, orika, viacheslavo, ferruh.yigit, Xiaoyun Li; +Cc: dev, thomas, rasland

Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
Add the CLI for this aciton:  color type (types)
There are three types: green, yellow and red.

Example for the new policy meter CLIs:
   add port meter policy 0 1 g_actions color type green / end y_actions
     color type yellow / end r_actions color type red / end

In the above command, the action type is RTE_FLOW_ACTION_TYPE_METER_COLOR,
the meter policy action list: green -> green, yellow -> yellow, red -> red.

V2: rebase the latest code.
V3: update the document.

Signed-off-by: Haifei Luo <haifeil@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
 app/test-pmd/cmdline_flow.c                 | 85 +++++++++++++++++++++++++++++
 doc/guides/rel_notes/release_21_05.rst      |  3 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  4 ++
 3 files changed, 92 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 5947341..1c587bb 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -348,6 +348,11 @@ enum index {
 	ACTION_PORT_ID_ORIGINAL,
 	ACTION_PORT_ID_ID,
 	ACTION_METER,
+	ACTION_METER_COLOR,
+	ACTION_METER_COLOR_TYPE,
+	ACTION_METER_COLOR_GREEN,
+	ACTION_METER_COLOR_YELLOW,
+	ACTION_METER_COLOR_RED,
 	ACTION_METER_ID,
 	ACTION_OF_SET_MPLS_TTL,
 	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
@@ -1377,6 +1382,7 @@ struct parse_action_priv {
 	ACTION_PHY_PORT,
 	ACTION_PORT_ID,
 	ACTION_METER,
+	ACTION_METER_COLOR,
 	ACTION_OF_SET_MPLS_TTL,
 	ACTION_OF_DEC_MPLS_TTL,
 	ACTION_OF_SET_NW_TTL,
@@ -1486,6 +1492,12 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_meter_color[] = {
+	ACTION_METER_COLOR_TYPE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static const enum index action_of_set_mpls_ttl[] = {
 	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
 	ACTION_NEXT,
@@ -1723,6 +1735,10 @@ static int parse_vc_conf(struct context *, const struct token *,
 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
 				    const char *, unsigned int,
 				    void *, unsigned int);
+static int parse_vc_action_meter_color_type(struct context *,
+					const struct token *,
+					const char *, unsigned int, void *,
+					unsigned int);
 static int parse_vc_action_rss(struct context *, const struct token *,
 			       const char *, unsigned int, void *,
 			       unsigned int);
@@ -3801,6 +3817,37 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
 		.next = NEXT(action_meter),
 		.call = parse_vc,
 	},
+	[ACTION_METER_COLOR] = {
+		.name = "color",
+		.help = "meter color for the packets",
+		.priv = PRIV_ACTION(METER_COLOR,
+				sizeof(struct rte_flow_action_meter_color)),
+		.next = NEXT(action_meter_color),
+		.call = parse_vc,
+	},
+	[ACTION_METER_COLOR_TYPE] = {
+		.name = "type",
+		.help = "specific meter color",
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT),
+				NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
+					ACTION_METER_COLOR_YELLOW,
+					ACTION_METER_COLOR_RED)),
+	},
+	[ACTION_METER_COLOR_GREEN] = {
+		.name = "green",
+		.help = "meter color green",
+		.call = parse_vc_action_meter_color_type,
+	},
+	[ACTION_METER_COLOR_YELLOW] = {
+		.name = "yellow",
+		.help = "meter color yellow",
+		.call = parse_vc_action_meter_color_type,
+	},
+	[ACTION_METER_COLOR_RED] = {
+		.name = "red",
+		.help = "meter color red",
+		.call = parse_vc_action_meter_color_type,
+	},
 	[ACTION_METER_ID] = {
 		.name = "mtr_id",
 		.help = "meter id to use",
@@ -5318,6 +5365,44 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
 	return len;
 }
 
+/** Parse meter color action type. */
+static int
+parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
+				const char *str, unsigned int len,
+				void *buf, unsigned int size)
+{
+	struct rte_flow_action *action_data;
+	struct rte_flow_action_meter_color *conf;
+	enum rte_color color;
+
+	(void)buf;
+	(void)size;
+	/* Token name must match. */
+	if (parse_default(ctx, token, str, len, NULL, 0) < 0)
+		return -1;
+	switch (ctx->curr) {
+	case ACTION_METER_COLOR_GREEN:
+		color = RTE_COLOR_GREEN;
+	break;
+	case ACTION_METER_COLOR_YELLOW:
+		color = RTE_COLOR_YELLOW;
+	break;
+	case ACTION_METER_COLOR_RED:
+		color = RTE_COLOR_RED;
+	break;
+	default:
+		return -1;
+	}
+
+	if (!ctx->object)
+		return len;
+	action_data = ctx->object;
+	conf = (struct rte_flow_action_meter_color *)
+					(uintptr_t)(action_data->conf);
+	conf->color = color;
+	return len;
+}
+
 /** Parse RSS action. */
 static int
 parse_vc_action_rss(struct context *ctx, const struct token *token,
diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst
index 30dec1c..8b4a1d8 100644
--- a/doc/guides/rel_notes/release_21_05.rst
+++ b/doc/guides/rel_notes/release_21_05.rst
@@ -269,6 +269,9 @@ New Features
   * Added commands to construct conntrack context and relevant indirect
     action handle creation, update for conntrack action as well as conntrack
     item matching.
+  * Added commands for action meter color to color the packet to reflect
+    the meter color result.
+    ``color type (green|yellow|red)``
 
 * **Added support for the FIB lookup method in the l3fwd example app.**
 
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 98a669b..88484e9 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -4089,6 +4089,10 @@ This section lists supported actions and their attributes, if any.
 
   - ``indirect_action_id {unsigned}``: Indirect action ID to use
 
+- ``color``: Color the packet to reflect the meter color result
+
+  - ``type {value}``: Set color type with specified value(green/yellow/red)
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
-- 
1.8.3.1


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

* Re: [dpdk-dev] [PATCH v2] app/testpmd: add CLI for action meter color
  2021-05-12  1:41     ` Haifei Luo
@ 2021-05-12  7:03       ` Haifei Luo
  0 siblings, 0 replies; 18+ messages in thread
From: Haifei Luo @ 2021-05-12  7:03 UTC (permalink / raw)
  To: Ferruh Yigit, Matan Azrad, Ori Kam, Slava Ovsiienko, Xiaoyun Li
  Cc: dev, NBU-Contact-Thomas Monjalon, Raslan Darawsheh

HI Ferruh,
    Added the docs in V3 and please kindly check. Thank you.

-----Original Message-----
From: Haifei Luo 
Sent: Wednesday, May 12, 2021 9:42 AM
To: Ferruh Yigit <ferruh.yigit@intel.com>; Matan Azrad <matan@nvidia.com>; Ori Kam <orika@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>; Xiaoyun Li <xiaoyun.li@intel.com>
Cc: dev@dpdk.org; NBU-Contact-Thomas Monjalon <thomas@monjalon.net>; Raslan Darawsheh <rasland@nvidia.com>
Subject: RE: [PATCH v2] app/testpmd: add CLI for action meter color

HI Ferruh,
     Will update the doc and send V3. Thank you.

-----Original Message-----
From: Ferruh Yigit <ferruh.yigit@intel.com>
Sent: Wednesday, May 12, 2021 3:22 AM
To: Haifei Luo <haifeil@nvidia.com>; Matan Azrad <matan@nvidia.com>; Ori Kam <orika@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>; Xiaoyun Li <xiaoyun.li@intel.com>
Cc: dev@dpdk.org; NBU-Contact-Thomas Monjalon <thomas@monjalon.net>; Raslan Darawsheh <rasland@nvidia.com>
Subject: Re: [PATCH v2] app/testpmd: add CLI for action meter color

External email: Use caution opening links or attachments


On 5/11/2021 10:28 AM, Haifei Luo wrote:
> Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
> Add the CLI for this action in meter policy: color type (types) There 
> are three types: green, yellow and red.
>
> Example for the new policy meter CLIs:
>    add port meter policy 0 1 g_actions color type green / end y_actions
>         color type yellow / end r_actions color type red / end
>
> In the above command, the action type is 
> RTE_FLOW_ACTION_TYPE_METER_COLOR, the meter policy action list: green -> green, yellow -> yellow, red -> red.
>
> V2: rebase the latest code.

Hint: you can put the changelog as last thing in commit log after '---' marker, than it will be taken as note and will automatically removed by "git am".

>
> Signed-off-by: Haifei Luo <haifeil@nvidia.com>
> Acked-by: Ori Kam <orika@nvidia.com>
>
> ---
>  app/test-pmd/cmdline_flow.c | 85
> +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 85 insertions(+)

Hi Haifei,

Can you please document new command in the testpmd documentation, 'testpmd_funcs.rst' has already "add port meter policy ..." command documented, you can extend it unless there is no better place to document this new command.

Can you also update release notes too, there is already a block there listing new commands, this can go into same place.



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

* Re: [dpdk-dev] [PATCH v3] app/testpmd: add CLI for action meter color
  2021-05-12  7:02 ` [dpdk-dev] [PATCH v3] " Haifei Luo
@ 2021-05-12  8:33   ` Ferruh Yigit
  0 siblings, 0 replies; 18+ messages in thread
From: Ferruh Yigit @ 2021-05-12  8:33 UTC (permalink / raw)
  To: Haifei Luo, matan, orika, viacheslavo, Xiaoyun Li; +Cc: dev, thomas, rasland

On 5/12/2021 8:02 AM, Haifei Luo wrote:
> Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
> Add the CLI for this aciton:  color type (types)
> There are three types: green, yellow and red.
> 
> Example for the new policy meter CLIs:
>    add port meter policy 0 1 g_actions color type green / end y_actions
>      color type yellow / end r_actions color type red / end
> 
> In the above command, the action type is RTE_FLOW_ACTION_TYPE_METER_COLOR,
> the meter policy action list: green -> green, yellow -> yellow, red -> red.
> 
> V2: rebase the latest code.
> V3: update the document.
> 
> Signed-off-by: Haifei Luo <haifeil@nvidia.com>
> Acked-by: Ori Kam <orika@nvidia.com>
> ---
>  app/test-pmd/cmdline_flow.c                 | 85 +++++++++++++++++++++++++++++
>  doc/guides/rel_notes/release_21_05.rst      |  3 +
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  4 ++
>  3 files changed, 92 insertions(+)

Thanks Haifei for the documentation update,

Can you also add a sample for the color in the 'testpmd_funcs.rst', in section
"Flow rules management"?

If you check through end of the section you will see same samples sub-sections
for various flow rules, since meter color action is new I think it would be
helpful to have the sample. You already have one in the commit log but may be
good to have it in the documentation too.



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

* [dpdk-dev] [PATCH v4] app/testpmd: add CLI for action meter color
  2021-04-28 14:10 [dpdk-dev] [PATCH] app/testpmd: support meter color action in policy Haifei Luo
                   ` (2 preceding siblings ...)
  2021-05-12  7:02 ` [dpdk-dev] [PATCH v3] " Haifei Luo
@ 2021-05-12 10:49 ` Haifei Luo
  2021-05-12 11:40   ` Ferruh Yigit
  2021-05-12 12:08   ` Ferruh Yigit
  2021-05-12 12:19 ` [dpdk-dev] [PATCH v5] " Haifei Luo
  4 siblings, 2 replies; 18+ messages in thread
From: Haifei Luo @ 2021-05-12 10:49 UTC (permalink / raw)
  To: matan, orika, viacheslavo, ferruh.yigit, Xiaoyun Li; +Cc: dev, thomas, rasland

Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
Add the CLI for this aciton:  color type (types)
There are three types: green, yellow and red.

Example for the new policy meter CLIs:
   add port meter policy 0 1 g_actions color type green / end y_actions
     color type yellow / end r_actions color type red / end

In the above command, the action type is RTE_FLOW_ACTION_TYPE_METER_COLOR,
the meter policy action list: green -> green, yellow -> yellow, red -> red.

V2: rebase the latest code.
V3: update the document.
V4: add sample in the document.

Signed-off-by: Haifei Luo <haifeil@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
 app/test-pmd/cmdline_flow.c                 | 85 +++++++++++++++++++++++++++++
 doc/guides/rel_notes/release_21_05.rst      |  3 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 23 ++++++++
 3 files changed, 111 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 5947341..1c587bb 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -348,6 +348,11 @@ enum index {
 	ACTION_PORT_ID_ORIGINAL,
 	ACTION_PORT_ID_ID,
 	ACTION_METER,
+	ACTION_METER_COLOR,
+	ACTION_METER_COLOR_TYPE,
+	ACTION_METER_COLOR_GREEN,
+	ACTION_METER_COLOR_YELLOW,
+	ACTION_METER_COLOR_RED,
 	ACTION_METER_ID,
 	ACTION_OF_SET_MPLS_TTL,
 	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
@@ -1377,6 +1382,7 @@ struct parse_action_priv {
 	ACTION_PHY_PORT,
 	ACTION_PORT_ID,
 	ACTION_METER,
+	ACTION_METER_COLOR,
 	ACTION_OF_SET_MPLS_TTL,
 	ACTION_OF_DEC_MPLS_TTL,
 	ACTION_OF_SET_NW_TTL,
@@ -1486,6 +1492,12 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_meter_color[] = {
+	ACTION_METER_COLOR_TYPE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static const enum index action_of_set_mpls_ttl[] = {
 	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
 	ACTION_NEXT,
@@ -1723,6 +1735,10 @@ static int parse_vc_conf(struct context *, const struct token *,
 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
 				    const char *, unsigned int,
 				    void *, unsigned int);
+static int parse_vc_action_meter_color_type(struct context *,
+					const struct token *,
+					const char *, unsigned int, void *,
+					unsigned int);
 static int parse_vc_action_rss(struct context *, const struct token *,
 			       const char *, unsigned int, void *,
 			       unsigned int);
@@ -3801,6 +3817,37 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
 		.next = NEXT(action_meter),
 		.call = parse_vc,
 	},
+	[ACTION_METER_COLOR] = {
+		.name = "color",
+		.help = "meter color for the packets",
+		.priv = PRIV_ACTION(METER_COLOR,
+				sizeof(struct rte_flow_action_meter_color)),
+		.next = NEXT(action_meter_color),
+		.call = parse_vc,
+	},
+	[ACTION_METER_COLOR_TYPE] = {
+		.name = "type",
+		.help = "specific meter color",
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT),
+				NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
+					ACTION_METER_COLOR_YELLOW,
+					ACTION_METER_COLOR_RED)),
+	},
+	[ACTION_METER_COLOR_GREEN] = {
+		.name = "green",
+		.help = "meter color green",
+		.call = parse_vc_action_meter_color_type,
+	},
+	[ACTION_METER_COLOR_YELLOW] = {
+		.name = "yellow",
+		.help = "meter color yellow",
+		.call = parse_vc_action_meter_color_type,
+	},
+	[ACTION_METER_COLOR_RED] = {
+		.name = "red",
+		.help = "meter color red",
+		.call = parse_vc_action_meter_color_type,
+	},
 	[ACTION_METER_ID] = {
 		.name = "mtr_id",
 		.help = "meter id to use",
@@ -5318,6 +5365,44 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
 	return len;
 }
 
+/** Parse meter color action type. */
+static int
+parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
+				const char *str, unsigned int len,
+				void *buf, unsigned int size)
+{
+	struct rte_flow_action *action_data;
+	struct rte_flow_action_meter_color *conf;
+	enum rte_color color;
+
+	(void)buf;
+	(void)size;
+	/* Token name must match. */
+	if (parse_default(ctx, token, str, len, NULL, 0) < 0)
+		return -1;
+	switch (ctx->curr) {
+	case ACTION_METER_COLOR_GREEN:
+		color = RTE_COLOR_GREEN;
+	break;
+	case ACTION_METER_COLOR_YELLOW:
+		color = RTE_COLOR_YELLOW;
+	break;
+	case ACTION_METER_COLOR_RED:
+		color = RTE_COLOR_RED;
+	break;
+	default:
+		return -1;
+	}
+
+	if (!ctx->object)
+		return len;
+	action_data = ctx->object;
+	conf = (struct rte_flow_action_meter_color *)
+					(uintptr_t)(action_data->conf);
+	conf->color = color;
+	return len;
+}
+
 /** Parse RSS action. */
 static int
 parse_vc_action_rss(struct context *ctx, const struct token *token,
diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst
index 30dec1c..8b4a1d8 100644
--- a/doc/guides/rel_notes/release_21_05.rst
+++ b/doc/guides/rel_notes/release_21_05.rst
@@ -269,6 +269,9 @@ New Features
   * Added commands to construct conntrack context and relevant indirect
     action handle creation, update for conntrack action as well as conntrack
     item matching.
+  * Added commands for action meter color to color the packet to reflect
+    the meter color result.
+    ``color type (green|yellow|red)``
 
 * **Added support for the FIB lookup method in the l3fwd example app.**
 
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 98a669b..227180e 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -4089,6 +4089,10 @@ This section lists supported actions and their attributes, if any.
 
   - ``indirect_action_id {unsigned}``: Indirect action ID to use
 
+- ``color``: Color the packet to reflect the meter color result
+
+  - ``type {value}``: Set color type with specified value(green/yellow/red)
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
@@ -5010,6 +5014,25 @@ rules like above for the peer port.
 
  testpmd> flow indirect_action 0 update 0 action conntrack_update dir / end
 
+Sample meter with policy rules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Meter with policy rules can be created by the following commands:
+
+Need to create policy first and actions are set for green/yellow/red colors.
+Create meter with policy id. Create flow with meter id.
+
+Example for policy with meter color action.The purpose is to color the packet
+to reflect the meter color result.The meter policy action list:
+green -> green, yellow -> yellow, red -> red.
+
+::
+testpmd> add port meter profile srtcm_rfc2697 0 13 21504 2688 0 0
+testpmd> add port meter policy 0 1 g_actions color type green / end y_actions color type yellow / end
+         r_actions color type red / end
+testpmd> create port meter 0 1 13 1 yes 0xffff 0 0
+testpmd> flow create 0 priority 0 ingress group 1 pattern eth / end actions meter mtr_id 1 / end
+
 BPF Functions
 --------------
 
-- 
1.8.3.1


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

* Re: [dpdk-dev] [PATCH v4] app/testpmd: add CLI for action meter color
  2021-05-12 10:49 ` [dpdk-dev] [PATCH v4] " Haifei Luo
@ 2021-05-12 11:40   ` Ferruh Yigit
  2021-05-12 12:08   ` Ferruh Yigit
  1 sibling, 0 replies; 18+ messages in thread
From: Ferruh Yigit @ 2021-05-12 11:40 UTC (permalink / raw)
  To: Haifei Luo, matan, orika, viacheslavo, Xiaoyun Li; +Cc: dev, thomas, rasland

On 5/12/2021 11:49 AM, Haifei Luo wrote:
> Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
> Add the CLI for this aciton:  color type (types)
> There are three types: green, yellow and red.
> 
> Example for the new policy meter CLIs:
>    add port meter policy 0 1 g_actions color type green / end y_actions
>      color type yellow / end r_actions color type red / end
> 
> In the above command, the action type is RTE_FLOW_ACTION_TYPE_METER_COLOR,
> the meter policy action list: green -> green, yellow -> yellow, red -> red.
> 
> V2: rebase the latest code.
> V3: update the document.
> V4: add sample in the document.
> 
> Signed-off-by: Haifei Luo <haifeil@nvidia.com>
> Acked-by: Ori Kam <orika@nvidia.com>
testpmd_funcs.rst:5033: WARNING: Block quote ends without a blank line;
unexpected unindent.

<...>

> @@ -5010,6 +5014,25 @@ rules like above for the peer port.
>  
>   testpmd> flow indirect_action 0 update 0 action conntrack_update dir / end
>  
> +Sample meter with policy rules
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +Meter with policy rules can be created by the following commands:
> +
> +Need to create policy first and actions are set for green/yellow/red colors.
> +Create meter with policy id. Create flow with meter id.
> +
> +Example for policy with meter color action.The purpose is to color the packet
> +to reflect the meter color result.The meter policy action list:

Space is missing between sentences.

> +green -> green, yellow -> yellow, red -> red.
> +
> +::
> +testpmd> add port meter profile srtcm_rfc2697 0 13 21504 2688 0 0
> +testpmd> add port meter policy 0 1 g_actions color type green / end y_actions color type yellow / end
> +         r_actions color type red / end
> +testpmd> create port meter 0 1 13 1 yes 0xffff 0 0
> +testpmd> flow create 0 priority 0 ingress group 1 pattern eth / end actions meter mtr_id 1 / end
> +

Gives build warning:
testpmd_funcs.rst:5032: WARNING: Unexpected indentation.
testpmd_funcs.rst:5033: WARNING: Block quote ends without a blank line;
unexpected unindent.

Will fix above issues while merging.

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

* Re: [dpdk-dev] [PATCH v4] app/testpmd: add CLI for action meter color
  2021-05-12 10:49 ` [dpdk-dev] [PATCH v4] " Haifei Luo
  2021-05-12 11:40   ` Ferruh Yigit
@ 2021-05-12 12:08   ` Ferruh Yigit
  1 sibling, 0 replies; 18+ messages in thread
From: Ferruh Yigit @ 2021-05-12 12:08 UTC (permalink / raw)
  To: Haifei Luo, matan, orika, viacheslavo, Xiaoyun Li; +Cc: dev, thomas, rasland

On 5/12/2021 11:49 AM, Haifei Luo wrote:
> Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
> Add the CLI for this aciton:  color type (types)
> There are three types: green, yellow and red.
> 
> Example for the new policy meter CLIs:
>    add port meter policy 0 1 g_actions color type green / end y_actions
>      color type yellow / end r_actions color type red / end
> 
> In the above command, the action type is RTE_FLOW_ACTION_TYPE_METER_COLOR,
> the meter policy action list: green -> green, yellow -> yellow, red -> red.
> 
> V2: rebase the latest code.
> V3: update the document.
> V4: add sample in the document.
> 
> Signed-off-by: Haifei Luo <haifeil@nvidia.com>
> Acked-by: Ori Kam <orika@nvidia.com>

Carried ack from previous version:
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/main, thanks.
(doc warnings fixed while merging)

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

* [dpdk-dev] [PATCH v5] app/testpmd: add CLI for action meter color
  2021-04-28 14:10 [dpdk-dev] [PATCH] app/testpmd: support meter color action in policy Haifei Luo
                   ` (3 preceding siblings ...)
  2021-05-12 10:49 ` [dpdk-dev] [PATCH v4] " Haifei Luo
@ 2021-05-12 12:19 ` Haifei Luo
  4 siblings, 0 replies; 18+ messages in thread
From: Haifei Luo @ 2021-05-12 12:19 UTC (permalink / raw)
  To: matan, orika, viacheslavo, ferruh.yigit, Xiaoyun Li; +Cc: dev, thomas, rasland

Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
Add the CLI for this aciton:  color type (types)
There are three types: green, yellow and red.

Example for the new policy meter CLIs:
   add port meter policy 0 1 g_actions color type green / end y_actions
     color type yellow / end r_actions color type red / end

In the above command, the action type is RTE_FLOW_ACTION_TYPE_METER_COLOR,
the meter policy action list: green -> green, yellow -> yellow, red -> red.

V2: rebase the latest code.
V3: update the document.
V4: add sample in the document.
V5: fix indentation warning.

Signed-off-by: Haifei Luo <haifeil@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
 app/test-pmd/cmdline_flow.c                 | 85 +++++++++++++++++++++++++++++
 doc/guides/rel_notes/release_21_05.rst      |  3 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 24 ++++++++
 3 files changed, 112 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 5947341..1c587bb 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -348,6 +348,11 @@ enum index {
 	ACTION_PORT_ID_ORIGINAL,
 	ACTION_PORT_ID_ID,
 	ACTION_METER,
+	ACTION_METER_COLOR,
+	ACTION_METER_COLOR_TYPE,
+	ACTION_METER_COLOR_GREEN,
+	ACTION_METER_COLOR_YELLOW,
+	ACTION_METER_COLOR_RED,
 	ACTION_METER_ID,
 	ACTION_OF_SET_MPLS_TTL,
 	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
@@ -1377,6 +1382,7 @@ struct parse_action_priv {
 	ACTION_PHY_PORT,
 	ACTION_PORT_ID,
 	ACTION_METER,
+	ACTION_METER_COLOR,
 	ACTION_OF_SET_MPLS_TTL,
 	ACTION_OF_DEC_MPLS_TTL,
 	ACTION_OF_SET_NW_TTL,
@@ -1486,6 +1492,12 @@ struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_meter_color[] = {
+	ACTION_METER_COLOR_TYPE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static const enum index action_of_set_mpls_ttl[] = {
 	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
 	ACTION_NEXT,
@@ -1723,6 +1735,10 @@ static int parse_vc_conf(struct context *, const struct token *,
 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
 				    const char *, unsigned int,
 				    void *, unsigned int);
+static int parse_vc_action_meter_color_type(struct context *,
+					const struct token *,
+					const char *, unsigned int, void *,
+					unsigned int);
 static int parse_vc_action_rss(struct context *, const struct token *,
 			       const char *, unsigned int, void *,
 			       unsigned int);
@@ -3801,6 +3817,37 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
 		.next = NEXT(action_meter),
 		.call = parse_vc,
 	},
+	[ACTION_METER_COLOR] = {
+		.name = "color",
+		.help = "meter color for the packets",
+		.priv = PRIV_ACTION(METER_COLOR,
+				sizeof(struct rte_flow_action_meter_color)),
+		.next = NEXT(action_meter_color),
+		.call = parse_vc,
+	},
+	[ACTION_METER_COLOR_TYPE] = {
+		.name = "type",
+		.help = "specific meter color",
+		.next = NEXT(NEXT_ENTRY(ACTION_NEXT),
+				NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
+					ACTION_METER_COLOR_YELLOW,
+					ACTION_METER_COLOR_RED)),
+	},
+	[ACTION_METER_COLOR_GREEN] = {
+		.name = "green",
+		.help = "meter color green",
+		.call = parse_vc_action_meter_color_type,
+	},
+	[ACTION_METER_COLOR_YELLOW] = {
+		.name = "yellow",
+		.help = "meter color yellow",
+		.call = parse_vc_action_meter_color_type,
+	},
+	[ACTION_METER_COLOR_RED] = {
+		.name = "red",
+		.help = "meter color red",
+		.call = parse_vc_action_meter_color_type,
+	},
 	[ACTION_METER_ID] = {
 		.name = "mtr_id",
 		.help = "meter id to use",
@@ -5318,6 +5365,44 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
 	return len;
 }
 
+/** Parse meter color action type. */
+static int
+parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
+				const char *str, unsigned int len,
+				void *buf, unsigned int size)
+{
+	struct rte_flow_action *action_data;
+	struct rte_flow_action_meter_color *conf;
+	enum rte_color color;
+
+	(void)buf;
+	(void)size;
+	/* Token name must match. */
+	if (parse_default(ctx, token, str, len, NULL, 0) < 0)
+		return -1;
+	switch (ctx->curr) {
+	case ACTION_METER_COLOR_GREEN:
+		color = RTE_COLOR_GREEN;
+	break;
+	case ACTION_METER_COLOR_YELLOW:
+		color = RTE_COLOR_YELLOW;
+	break;
+	case ACTION_METER_COLOR_RED:
+		color = RTE_COLOR_RED;
+	break;
+	default:
+		return -1;
+	}
+
+	if (!ctx->object)
+		return len;
+	action_data = ctx->object;
+	conf = (struct rte_flow_action_meter_color *)
+					(uintptr_t)(action_data->conf);
+	conf->color = color;
+	return len;
+}
+
 /** Parse RSS action. */
 static int
 parse_vc_action_rss(struct context *ctx, const struct token *token,
diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst
index 30dec1c..8b4a1d8 100644
--- a/doc/guides/rel_notes/release_21_05.rst
+++ b/doc/guides/rel_notes/release_21_05.rst
@@ -269,6 +269,9 @@ New Features
   * Added commands to construct conntrack context and relevant indirect
     action handle creation, update for conntrack action as well as conntrack
     item matching.
+  * Added commands for action meter color to color the packet to reflect
+    the meter color result.
+    ``color type (green|yellow|red)``
 
 * **Added support for the FIB lookup method in the l3fwd example app.**
 
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 98a669b..f0eeff6 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -4089,6 +4089,10 @@ This section lists supported actions and their attributes, if any.
 
   - ``indirect_action_id {unsigned}``: Indirect action ID to use
 
+- ``color``: Color the packet to reflect the meter color result
+
+  - ``type {value}``: Set color type with specified value(green/yellow/red)
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
@@ -5010,6 +5014,26 @@ rules like above for the peer port.
 
  testpmd> flow indirect_action 0 update 0 action conntrack_update dir / end
 
+Sample meter with policy rules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Meter with policy rules can be created by the following commands:
+
+Need to create policy first and actions are set for green/yellow/red colors.
+Create meter with policy id. Create flow with meter id.
+
+Example for policy with meter color action.The purpose is to color the packet
+to reflect the meter color result.The meter policy action list:
+green -> green, yellow -> yellow, red -> red.
+
+::
+
+ testpmd> add port meter profile srtcm_rfc2697 0 13 21504 2688 0 0
+ testpmd> add port meter policy 0 1 g_actions color type green / end y_actions color type yellow / end
+        r_actions color type red / end
+ testpmd> create port meter 0 1 13 1 yes 0xffff 0 0
+ testpmd> flow create 0 priority 0 ingress group 1 pattern eth / end actions meter mtr_id 1 / end
+
 BPF Functions
 --------------
 
-- 
1.8.3.1


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

* Re: [dpdk-dev] [PATCH v2] app/testpmd: add CLI for action meter color
  2021-05-11 13:20       ` Ferruh Yigit
@ 2021-05-12 19:54         ` Dumitrescu, Cristian
  0 siblings, 0 replies; 18+ messages in thread
From: Dumitrescu, Cristian @ 2021-05-12 19:54 UTC (permalink / raw)
  To: Yigit, Ferruh, Haifei Luo, matan, orika, viacheslavo, Li, Xiaoyun
  Cc: dev, thomas, rasland, Singh, Jasvinder



> -----Original Message-----
> From: Yigit, Ferruh <ferruh.yigit@intel.com>
> Sent: Tuesday, May 11, 2021 2:21 PM
> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Haifei Luo
> <haifeil@nvidia.com>; matan@nvidia.com; orika@nvidia.com;
> viacheslavo@nvidia.com; Li, Xiaoyun <xiaoyun.li@intel.com>
> Cc: dev@dpdk.org; thomas@monjalon.net; rasland@nvidia.com; Singh,
> Jasvinder <jasvinder.singh@intel.com>
> Subject: Re: [PATCH v2] app/testpmd: add CLI for action meter color
> 
> On 5/11/2021 1:34 PM, Dumitrescu, Cristian wrote:
> >
> >
> >> -----Original Message-----
> >> From: Yigit, Ferruh <ferruh.yigit@intel.com>
> >> Sent: Tuesday, May 11, 2021 12:35 PM
> >> To: Haifei Luo <haifeil@nvidia.com>; matan@nvidia.com;
> orika@nvidia.com;
> >> viacheslavo@nvidia.com; Li, Xiaoyun <xiaoyun.li@intel.com>
> >> Cc: dev@dpdk.org; thomas@monjalon.net; rasland@nvidia.com; Singh,
> >> Jasvinder <jasvinder.singh@intel.com>; Dumitrescu, Cristian
> >> <cristian.dumitrescu@intel.com>
> >> Subject: Re: [PATCH v2] app/testpmd: add CLI for action meter color
> >>
> >> On 5/11/2021 10:28 AM, Haifei Luo wrote:
> >>> Currently action RTE_FLOW_ACTION_TYPE_METER_COLOR is defined.
> >>> Add the CLI for this action in meter policy: color type (types)
> >>> There are three types: green, yellow and red.
> >>>
> >>> Example for the new policy meter CLIs:
> >>>    add port meter policy 0 1 g_actions color type green / end y_actions
> >>>         color type yellow / end r_actions color type red / end
> >>>
> >>> In the above command, the action type is
> >> RTE_FLOW_ACTION_TYPE_METER_COLOR,
> >>> the meter policy action list: green -> green, yellow -> yellow, red -> red.
> >>>
> >>> V2: rebase the latest code.
> >>>
> >>> Signed-off-by: Haifei Luo <haifeil@nvidia.com>
> >>> Acked-by: Ori Kam <orika@nvidia.com>
> >>
> >>
> >> cc'ed Jasvinder & Cristian for review.
> >>
> >> This patch is not a fix but adding support for testing new meter action
> type,
> >> so
> >> I assume it can be postponed to next release if missing review from
> >> maintainers.
> >
> > Hi Ferruh,
> >
> > This patch looks good to me, but I think it should be reviewed and acked by
> Xiaoyun, the testpmd maintainer, who is already in the To: list?
> >
> 
> If so I will proceed with your explicit ack:
> Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> 
> Xiaoyun is main maintainer but for some submodules we rely on the relevant
> maintainer, like flow API related part to Ori or for meter/tm part to you etc..

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>


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

end of thread, other threads:[~2021-05-12 19:55 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28 14:10 [dpdk-dev] [PATCH] app/testpmd: support meter color action in policy Haifei Luo
2021-04-30 12:50 ` Ferruh Yigit
2021-05-03 12:11   ` Dumitrescu, Cristian
2021-05-05 15:42     ` Ori Kam
2021-05-11  9:28 ` [dpdk-dev] [PATCH v2] app/testpmd: add CLI for action meter color Haifei Luo
2021-05-11 11:35   ` Ferruh Yigit
2021-05-11 12:34     ` Dumitrescu, Cristian
2021-05-11 13:20       ` Ferruh Yigit
2021-05-12 19:54         ` Dumitrescu, Cristian
2021-05-11 19:22   ` Ferruh Yigit
2021-05-12  1:41     ` Haifei Luo
2021-05-12  7:03       ` Haifei Luo
2021-05-12  7:02 ` [dpdk-dev] [PATCH v3] " Haifei Luo
2021-05-12  8:33   ` Ferruh Yigit
2021-05-12 10:49 ` [dpdk-dev] [PATCH v4] " Haifei Luo
2021-05-12 11:40   ` Ferruh Yigit
2021-05-12 12:08   ` Ferruh Yigit
2021-05-12 12:19 ` [dpdk-dev] [PATCH v5] " Haifei Luo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.