From: Alexander Kozyrev <akozyrev@nvidia.com>
To: <dev@dpdk.org>
Cc: <cristian.dumitrescu@intel.com>, <jerinjacobk@gmail.com>,
<orika@nvidia.com>, <thomas@monjalon.net>,
<ivan.malov@oktetlabs.ru>, <andrew.rybchenko@oktetlabs.ru>,
<ferruh.yigit@xilinx.com>, <mohammad.abdul.awal@intel.com>,
<qi.z.zhang@intel.com>, <jerinj@marvell.com>,
<ajit.khaparde@broadcom.com>, <bruce.richardson@intel.com>
Subject: [PATCH v5 7/7] app/testpmd: add meter color mark flow action
Date: Mon, 26 Sep 2022 17:57:45 +0300 [thread overview]
Message-ID: <20220926145745.3962600-8-akozyrev@nvidia.com> (raw)
In-Reply-To: <20220926145745.3962600-1-akozyrev@nvidia.com>
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 | 153 ++++++++++++++++++++
app/test-pmd/config.c | 45 +++++-
app/test-pmd/testpmd.h | 4 +
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 +
4 files changed, 209 insertions(+), 1 deletion(-)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 601df52f38..417655eca8 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -54,6 +54,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,
@@ -509,6 +510,14 @@ 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_METER_COLOR_MODE,
+ ACTION_METER_INIT_COLOR,
+ ACTION_METER_STATE,
ACTION_OF_SET_MPLS_TTL,
ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
ACTION_OF_DEC_MPLS_TTL,
@@ -1836,6 +1845,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,
@@ -1952,6 +1962,16 @@ static const enum index action_meter_color[] = {
ZERO,
};
+static const enum index action_meter_mark[] = {
+ ACTION_METER_PROFILE,
+ ACTION_METER_POLICY,
+ ACTION_METER_COLOR_MODE,
+ ACTION_METER_INIT_COLOR,
+ ACTION_METER_STATE,
+ ACTION_NEXT,
+ ZERO,
+};
+
static const enum index action_of_set_mpls_ttl[] = {
ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
ACTION_NEXT,
@@ -2387,6 +2407,14 @@ static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
static int parse_mp(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
+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 parse_meter_color(struct context *ctx, const struct token *token,
const char *str, unsigned int len, void *buf,
unsigned int size);
@@ -2551,6 +2579,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",
@@ -5429,6 +5464,62 @@ 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_METER_COLOR_MODE] = {
+ .name = "mtr_color_mode",
+ .help = "meter color awareness mode",
+ .next = NEXT(action_meter_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter_mark, color_mode)),
+ .call = parse_vc_conf,
+ },
+ [ACTION_METER_INIT_COLOR] = {
+ .name = "mtr_init_color",
+ .help = "meter initial color",
+ .next = NEXT(action_meter_mark, NEXT_ENTRY(ITEM_METER_COLOR_NAME)),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter_mark, init_color)),
+ },
+ [ACTION_METER_STATE] = {
+ .name = "mtr_state",
+ .help = "meter state",
+ .next = NEXT(action_meter_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter_mark, state)),
+ .call = parse_vc_conf,
+ },
[ACTION_OF_SET_MPLS_TTL] = {
.name = "of_set_mpls_ttl",
.help = "OpenFlow's OFPAT_SET_MPLS_TTL",
@@ -9748,6 +9839,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 = 0;
+ 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 = 0;
+ 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 568b0881d4..06d6dc3546 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2122,6 +2122,29 @@ port_meter_policy_add(portid_t port_id, uint32_t policy_id,
return ret;
}
+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;
+}
+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,
@@ -2709,6 +2732,9 @@ port_queue_action_handle_update(portid_t port_id,
struct rte_port *port;
struct rte_flow_error error;
struct rte_flow_action_handle *action_handle;
+ struct port_indirect_action *pia;
+ struct rte_flow_update_meter_mark mtr_update;
+ const void *update;
action_handle = port_action_handle_get_by_id(port_id, id);
if (!action_handle)
@@ -2720,8 +2746,25 @@ port_queue_action_handle_update(portid_t port_id,
return -EINVAL;
}
+ pia = action_get_by_id(port_id, id);
+ if (!pia)
+ return -EINVAL;
+
+ if (pia->type == RTE_FLOW_ACTION_TYPE_METER_MARK) {
+ rte_memcpy(&mtr_update.meter_mark, action->conf,
+ sizeof(struct rte_flow_action_meter_mark));
+ mtr_update.profile_valid = 1;
+ mtr_update.policy_valid = 1;
+ mtr_update.color_mode_valid = 1;
+ mtr_update.init_color_valid = 1;
+ mtr_update.state_valid = 1;
+ update = &mtr_update;
+ } else {
+ update = action;
+ }
+
if (rte_flow_async_action_handle_update(port_id, queue_id, &attr,
- action_handle, action, NULL, &error)) {
+ action_handle, update, NULL, &error)) {
return port_flow_complain(&error);
}
printf("Indirect action #%u update queued\n", id);
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 21c5632aec..e96f563674 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -938,6 +938,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 b586e92649..d1f536b6fe 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3986,6 +3986,14 @@ 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
+ - ``mtr_color_mode {unsigned}``: meter color-awareness mode (blind/aware)
+ - ``mtr_init_color {value}``: initial color value(green/yellow/red)
+ - ``mtr_state {unsigned}``: meter state (disabled/enabled)
+
Destroying flow rules
~~~~~~~~~~~~~~~~~~~~~
--
2.18.2
next prev parent reply other threads:[~2022-09-26 14:59 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
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 ` Alexander Kozyrev [this message]
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=20220926145745.3962600-8-akozyrev@nvidia.com \
--to=akozyrev@nvidia.com \
--cc=ajit.khaparde@broadcom.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=orika@nvidia.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).