DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ori Kam <orika@nvidia.com>
To: Alexander Kozyrev <akozyrev@nvidia.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "cristian.dumitrescu@intel.com" <cristian.dumitrescu@intel.com>,
	"jerinjacobk@gmail.com" <jerinjacobk@gmail.com>,
	"NBU-Contact-Thomas Monjalon (EXTERNAL)" <thomas@monjalon.net>,
	"ivan.malov@oktetlabs.ru" <ivan.malov@oktetlabs.ru>,
	"andrew.rybchenko@oktetlabs.ru" <andrew.rybchenko@oktetlabs.ru>,
	"ferruh.yigit@xilinx.com" <ferruh.yigit@xilinx.com>,
	"mohammad.abdul.awal@intel.com" <mohammad.abdul.awal@intel.com>,
	"qi.z.zhang@intel.com" <qi.z.zhang@intel.com>,
	"jerinj@marvell.com" <jerinj@marvell.com>,
	"ajit.khaparde@broadcom.com" <ajit.khaparde@broadcom.com>,
	"bruce.richardson@intel.com" <bruce.richardson@intel.com>
Subject: RE: [PATCH v3 7/7] app/testpmd: add meter color mark flow action
Date: Wed, 1 Jun 2022 09:01:02 +0000	[thread overview]
Message-ID: <MW2PR12MB466691318875BF4D79CE19EBD6DF9@MW2PR12MB4666.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20220601034408.2579943-8-akozyrev@nvidia.com>

Hi Alexander,

> -----Original Message-----
> From: Alexander Kozyrev <akozyrev@nvidia.com>
> Sent: Wednesday, June 1, 2022 6:44 AM
> Subject: [PATCH v3 7/7] app/testpmd: add meter color mark flow action
> 
> Add testpmd command line to match for METER_MARK action:
> 	flow create ... actions meter_mark mtr_profile 20 / end
> 
> Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
> ---
>  app/test-pmd/cmdline_flow.c                 | 127 ++++++++++++++++++++
>  app/test-pmd/config.c                       |  26 ++++
>  app/test-pmd/testpmd.h                      |   4 +
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |   5 +
>  4 files changed, 162 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 401922fc34..7261d6f52e 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -53,6 +53,7 @@ enum index {
>  	COMMON_GROUP_ID,
>  	COMMON_PRIORITY_LEVEL,
>  	COMMON_INDIRECT_ACTION_ID,
> +	COMMON_PROFILE_ID,
>  	COMMON_POLICY_ID,
>  	COMMON_FLEX_HANDLE,
>  	COMMON_FLEX_TOKEN,
> @@ -508,6 +509,11 @@ enum index {
>  	ACTION_METER_COLOR_YELLOW,
>  	ACTION_METER_COLOR_RED,
>  	ACTION_METER_ID,
> +	ACTION_METER_MARK,
> +	ACTION_METER_PROFILE,
> +	ACTION_METER_PROFILE_ID2PTR,
> +	ACTION_METER_POLICY,
> +	ACTION_METER_POLICY_ID2PTR,
>  	ACTION_OF_SET_MPLS_TTL,
>  	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
>  	ACTION_OF_DEC_MPLS_TTL,
> @@ -1835,6 +1841,7 @@ static const enum index next_action[] = {
>  	ACTION_PORT_ID,
>  	ACTION_METER,
>  	ACTION_METER_COLOR,
> +	ACTION_METER_MARK,
>  	ACTION_OF_SET_MPLS_TTL,
>  	ACTION_OF_DEC_MPLS_TTL,
>  	ACTION_OF_SET_NW_TTL,
> @@ -1951,6 +1958,13 @@ static const enum index action_meter_color[] = {
>  	ZERO,
>  };
> 
> +static const enum index action_meter_mark[] = {
> +	ACTION_METER_PROFILE,
> +	ACTION_METER_POLICY,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
>  static const enum index action_of_set_mpls_ttl[] = {
>  	ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
>  	ACTION_NEXT,
> @@ -2389,6 +2403,14 @@ static int parse_mp(struct context *, const struct token *,
>  static int parse_meter_color(struct context *ctx, const struct token *token,
>  			     const char *str, unsigned int len, void *buf,
>  			     unsigned int size);
> +static int parse_meter_profile_id2ptr(struct context *ctx,
> +				      const struct token *token,
> +				      const char *str, unsigned int len,
> +				      void *buf, unsigned int size);
> +static int parse_meter_policy_id2ptr(struct context *ctx,
> +				     const struct token *token,
> +				     const char *str, unsigned int len,
> +				     void *buf, unsigned int size);
>  static int comp_none(struct context *, const struct token *,
>  		     unsigned int, char *, unsigned int);
>  static int comp_boolean(struct context *, const struct token *,
> @@ -2550,6 +2572,13 @@ static const struct token token_list[] = {
>  		.call = parse_int,
>  		.comp = comp_none,
>  	},
> +	[COMMON_PROFILE_ID] = {
> +		.name = "{profile_id}",
> +		.type = "PROFILE_ID",
> +		.help = "profile id",
> +		.call = parse_int,
> +		.comp = comp_none,
> +	},
>  	[COMMON_POLICY_ID] = {
>  		.name = "{policy_id}",
>  		.type = "POLICY_ID",
> @@ -5428,6 +5457,42 @@ static const struct token token_list[] = {
>  		.args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
>  		.call = parse_vc_conf,
>  	},
> +	[ACTION_METER_MARK] = {
> +		.name = "meter_mark",
> +		.help = "meter the directed packets using profile and policy",
> +		.priv = PRIV_ACTION(METER_MARK,
> +				    sizeof(struct rte_flow_action_meter_mark)),
> +		.next = NEXT(action_meter_mark),
> +		.call = parse_vc,
> +	},
> +	[ACTION_METER_PROFILE] = {
> +		.name = "mtr_profile",
> +		.help = "meter profile id to use",
> +		.next = NEXT(NEXT_ENTRY(ACTION_METER_PROFILE_ID2PTR)),
> +		.args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
> +	},
> +	[ACTION_METER_PROFILE_ID2PTR] = {
> +		.name = "{mtr_profile_id}",
> +		.type = "PROFILE_ID",
> +		.help = "meter profile id",
> +		.next = NEXT(action_meter_mark),
> +		.call = parse_meter_profile_id2ptr,
> +		.comp = comp_none,
> +	},
> +	[ACTION_METER_POLICY] = {
> +		.name = "mtr_policy",
> +		.help = "meter policy id to use",
> +		.next = NEXT(NEXT_ENTRY(ACTION_METER_POLICY_ID2PTR)),
> +		ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
> +	},
> +	[ACTION_METER_POLICY_ID2PTR] = {
> +		.name = "{mtr_policy_id}",
> +		.type = "POLICY_ID",
> +		.help = "meter policy id",
> +		.next = NEXT(action_meter_mark),
> +		.call = parse_meter_policy_id2ptr,
> +		.comp = comp_none,
> +	},
>  	[ACTION_OF_SET_MPLS_TTL] = {
>  		.name = "of_set_mpls_ttl",
>  		.help = "OpenFlow's OFPAT_SET_MPLS_TTL",
> @@ -9747,6 +9812,68 @@ parse_ia_id2ptr(struct context *ctx, const struct token *token,
>  	return ret;
>  }
> 
> +static int
> +parse_meter_profile_id2ptr(struct context *ctx, const struct token *token,
> +			   const char *str, unsigned int len,
> +			   void *buf, unsigned int size)
> +{
> +	struct rte_flow_action *action = ctx->object;
> +	struct rte_flow_action_meter_mark *meter;
> +	struct rte_flow_meter_profile *profile = NULL;
> +	uint32_t id;
> +	int ret;
> +
> +	(void)buf;
> +	(void)size;
> +	ctx->objdata = 0;
> +	ctx->object = &id;
> +	ctx->objmask = NULL;
> +	ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
> +	ctx->object = action;
> +	if (ret != (int)len)
> +		return ret;
> +	/* set meter profile */
> +	if (action) {
> +		meter = (struct rte_flow_action_meter_mark *)
> +				(uintptr_t)(action->conf);
> +		profile = port_meter_profile_get_by_id(ctx->port, id);
> +		meter->profile = profile;
> +		ret = (profile) ? ret : -1;
> +	}
> +	return ret;
> +}
> +
> +static int
> +parse_meter_policy_id2ptr(struct context *ctx, const struct token *token,
> +			  const char *str, unsigned int len,
> +			  void *buf, unsigned int size)
> +{
> +	struct rte_flow_action *action = ctx->object;
> +	struct rte_flow_action_meter_mark *meter;
> +	struct rte_flow_meter_policy *policy = NULL;
> +	uint32_t id;
> +	int ret;
> +
> +	(void)buf;
> +	(void)size;
> +	ctx->objdata = 0;
> +	ctx->object = &id;
> +	ctx->objmask = NULL;
> +	ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
> +	ctx->object = action;
> +	if (ret != (int)len)
> +		return ret;
> +	/* set meter policy */
> +	if (action) {
> +		meter = (struct rte_flow_action_meter_mark *)
> +				(uintptr_t)(action->conf);
> +		policy = port_meter_policy_get_by_id(ctx->port, id);
> +		meter->policy = policy;
> +		ret = (policy) ? ret : -1;
> +	}
> +	return ret;
> +}
> +
>  /** Parse set command, initialize output buffer for subsequent tokens. */
>  static int
>  parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index 1b1e738f83..413dcb6e9d 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -2184,6 +2184,32 @@ port_meter_policy_add(portid_t port_id, uint32_t policy_id,
>  	return ret;
>  }
> 
> +/** Get port meter profile */
> +struct rte_flow_meter_profile *
> +port_meter_profile_get_by_id(portid_t port_id, uint32_t id)
> +{
> +	struct rte_mtr_error error;
> +	struct rte_flow_meter_profile *profile;
> +
> +	profile = rte_mtr_meter_profile_get(port_id, id, &error);
> +	if (!profile)
> +		print_mtr_err_msg(&error);
> +	return profile;
> +}
> +
> +/** Get port meter policy */
> +struct rte_flow_meter_policy *
> +port_meter_policy_get_by_id(portid_t port_id, uint32_t id)
> +{
> +	struct rte_mtr_error error;
> +	struct rte_flow_meter_policy *policy;
> +
> +	policy = rte_mtr_meter_policy_get(port_id, id, &error);
> +	if (!policy)
> +		print_mtr_err_msg(&error);
> +	return policy;
> +}
> +
>  /** Validate flow rule. */
>  int
>  port_flow_validate(portid_t port_id,
> diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
> index f04a9a11b4..5fed46ae17 100644
> --- a/app/test-pmd/testpmd.h
> +++ b/app/test-pmd/testpmd.h
> @@ -985,6 +985,10 @@ void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops
> *ops);
>  int port_flow_isolate(portid_t port_id, int set);
>  int port_meter_policy_add(portid_t port_id, uint32_t policy_id,
>  		const struct rte_flow_action *actions);
> +struct rte_flow_meter_profile *port_meter_profile_get_by_id(portid_t port_id,
> +							    uint32_t id);
> +struct rte_flow_meter_policy *port_meter_policy_get_by_id(portid_t port_id,
> +							  uint32_t id);
> 
>  void rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id);
>  void tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id);
> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index 5e2f5ffb40..fd5a05dbad 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -4453,6 +4453,11 @@ This section lists supported actions and their attributes, if any.
> 
>    - ``ethdev_port_id {unsigned}``: ethdev port ID
> 
> +- ``meter_mark``:  meter the directed packets using profile and policy
> +
> +  - ``mtr_profile {unsigned}``: meter profile id to use
> +  - ``mtr_policy {unsigned}``: meter policy id to use
> +
>  Destroying flow rules
>  ~~~~~~~~~~~~~~~~~~~~~
> 
> --
> 2.18.2


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

  reply	other threads:[~2022-06-01  9:01 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08  2:46 [RFC] ethdev: datapath-focused meter actions Alexander Kozyrev
2022-04-08  8:21 ` Jerin Jacob
2022-04-26 13:43   ` Dumitrescu, Cristian
2022-04-26 13:45     ` Dumitrescu, Cristian
2022-05-02 19:12     ` Alexander Kozyrev
2022-05-02 20:02 ` [PATCH v2 0/3] " Alexander Kozyrev
2022-05-02 20:04 ` [RFC " Alexander Kozyrev
2022-05-02 20:04   ` [PATCH v2 1/3] ethdev: add meter color matching to Flow API Alexander Kozyrev
2022-05-02 20:04   ` [PATCH v2 2/3] ethdev: allow meter color modification Alexander Kozyrev
2022-05-02 20:04   ` [PATCH v2 3/3] ethdev: add extended meter action to Flow API Alexander Kozyrev
2022-05-18  4:34   ` [PATCH 0/4] ethdev: separate metering and marking from policing Alexander Kozyrev
2022-05-18  4:34     ` [PATCH 1/4] ethdev: add meter color flow matching item Alexander Kozyrev
2022-05-19 14:44       ` Dumitrescu, Cristian
2022-05-18  4:34     ` [PATCH 2/4] ethdev: allow meter color marker modification Alexander Kozyrev
2022-05-19 14:49       ` Dumitrescu, Cristian
2022-05-24 12:19         ` Alexander Kozyrev
2022-05-18  4:34     ` [PATCH 3/4] ethdev: add meter profile config calculation Alexander Kozyrev
2022-05-19 14:55       ` Dumitrescu, Cristian
2022-05-24 12:36         ` Alexander Kozyrev
2022-05-18  4:34     ` [PATCH 4/4] ethdev: add meter color mark flow action Alexander Kozyrev
2022-05-22 10:50     ` [PATCH v2 0/4] ethdev: separate metering and marking from policing Alexander Kozyrev
2022-05-22 10:50       ` [PATCH v2 1/4] ethdev: add meter color flow matching item Alexander Kozyrev
2022-05-26 12:16         ` Ori Kam
2022-05-22 10:51       ` [PATCH v2 2/4] ethdev: allow meter color marker modification Alexander Kozyrev
2022-05-26 12:21         ` Ori Kam
2022-05-22 10:51       ` [PATCH v2 3/4] ethdev: get meter profile/policy objects Alexander Kozyrev
2022-05-26 12:27         ` Ori Kam
2022-06-01  3:33           ` Alexander Kozyrev
2022-05-22 10:51       ` [PATCH v2 4/4] ethdev: add meter color mark flow action Alexander Kozyrev
2022-05-26 12:33         ` Ori Kam
2022-06-01  3:35           ` Alexander Kozyrev
2022-05-26 12:35       ` [PATCH v2 0/4] ethdev: separate metering and marking from policing Ori Kam
2022-05-26 13:21       ` Jerin Jacob
2022-05-26 13:22         ` Jerin Jacob
2022-06-01  3:19           ` Alexander Kozyrev
2022-06-01  3:44       ` [PATCH v3 0/7] " Alexander Kozyrev
2022-06-01  3:44         ` [PATCH v3 1/7] ethdev: add meter color flow matching item Alexander Kozyrev
2022-06-01  8:44           ` Ori Kam
2022-06-09 12:18           ` Andrew Rybchenko
2022-06-01  3:44         ` [PATCH v3 2/7] ethdev: allow meter color marker modification Alexander Kozyrev
2022-06-01  8:45           ` Ori Kam
2022-06-09 12:18           ` Andrew Rybchenko
2022-06-01  3:44         ` [PATCH v3 3/7] ethdev: get meter profile/policy objects Alexander Kozyrev
2022-06-01  8:51           ` Ori Kam
2022-06-09 12:18           ` Andrew Rybchenko
2022-06-01  3:44         ` [PATCH v3 4/7] ethdev: add meter color mark flow action Alexander Kozyrev
2022-06-01  8:55           ` Ori Kam
2022-06-09 12:19           ` Andrew Rybchenko
2022-06-01  3:44         ` [PATCH v3 5/7] app/testpmd: add meter color flow matching item Alexander Kozyrev
2022-06-01  8:59           ` Ori Kam
2022-06-01  3:44         ` [PATCH v3 6/7] app/testpmd: allow meter color marker modification Alexander Kozyrev
2022-06-01  8:59           ` Ori Kam
2022-06-01  3:44         ` [PATCH v3 7/7] app/testpmd: add meter color mark flow action Alexander Kozyrev
2022-06-01  9:01           ` Ori Kam [this message]
2022-06-08 11:41         ` [PATCH v3 0/7] ethdev: separate metering and marking from policing Dumitrescu, Cristian
2022-09-21  2:11         ` [PATCH v4 " Alexander Kozyrev
2022-09-21  2:11           ` [PATCH v4 1/7] ethdev: add meter color flow matching item Alexander Kozyrev
2022-09-21 12:54             ` Ori Kam
2022-09-21  2:11           ` [PATCH v4 2/7] ethdev: allow meter color marker modification Alexander Kozyrev
2022-09-21  2:11           ` [PATCH v4 3/7] ethdev: get meter profile/policy objects Alexander Kozyrev
2022-09-21  2:11           ` [PATCH v4 4/7] ethdev: add meter color mark flow action Alexander Kozyrev
2022-09-21  2:11           ` [PATCH v4 5/7] app/test-pmd: add meter color flow matching item Alexander Kozyrev
2022-09-21  2:11           ` [PATCH v4 6/7] app/test-pmd: allow meter color marker modification Alexander Kozyrev
2022-09-21  2:11           ` [PATCH v4 7/7] app/testpmd: add meter color mark flow action Alexander Kozyrev
2022-09-26 14:57           ` [PATCH v5 0/7] ethdev: separate metering and marking from policing Alexander Kozyrev
2022-09-26 14:57             ` [PATCH v5 1/7] ethdev: add meter color flow matching item Alexander Kozyrev
2022-09-26 14:57             ` [PATCH v5 2/7] ethdev: allow meter color marker modification Alexander Kozyrev
2022-09-26 14:57             ` [PATCH v5 3/7] ethdev: get meter profile/policy objects Alexander Kozyrev
2022-09-26 14:57             ` [PATCH v5 4/7] ethdev: add meter color mark flow action Alexander Kozyrev
2022-09-26 14:57             ` [PATCH v5 5/7] app/testpmd: add meter color flow matching item Alexander Kozyrev
2022-09-26 14:57             ` [PATCH v5 6/7] app/testpmd: allow meter color marker modification Alexander Kozyrev
2022-09-26 14:57             ` [PATCH v5 7/7] app/testpmd: add meter color mark flow action Alexander Kozyrev
2022-09-27 11:56             ` [PATCH v5 0/7] ethdev: separate metering and marking from policing Dumitrescu, Cristian
2022-09-28  6:45               ` Ori Kam
2022-09-28 16:38                 ` Ajit Khaparde
2022-09-29  7:51                   ` Andrew Rybchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MW2PR12MB466691318875BF4D79CE19EBD6DF9@MW2PR12MB4666.namprd12.prod.outlook.com \
    --to=orika@nvidia.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=akozyrev@nvidia.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=bruce.richardson@intel.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@xilinx.com \
    --cc=ivan.malov@oktetlabs.ru \
    --cc=jerinj@marvell.com \
    --cc=jerinjacobk@gmail.com \
    --cc=mohammad.abdul.awal@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).