From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E96F3A0546; Fri, 30 Apr 2021 14:50:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 95BD64014F; Fri, 30 Apr 2021 14:50:43 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 62AB64013F for ; Fri, 30 Apr 2021 14:50:41 +0200 (CEST) IronPort-SDR: FOKjps/DTZK3q8OXdUDYFRn/6R6kGT4dLs3ce/GUuEpaBOko1WWglpHKLZJ6JPfzVAaooqhdat FOjgHItiKgbQ== X-IronPort-AV: E=McAfee;i="6200,9189,9969"; a="195162842" X-IronPort-AV: E=Sophos;i="5.82,262,1613462400"; d="scan'208";a="195162842" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Apr 2021 05:50:40 -0700 IronPort-SDR: sKS5z5PAPBWEOwx8snwGdqPAn8i0I5ppxsGmJKIn8EB/ZjmOkr2IStmcqKFTZgWDVLbT8ORZUZ jHkr+KBvJomA== X-IronPort-AV: E=Sophos;i="5.82,262,1613462400"; d="scan'208";a="404588070" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.242.68]) ([10.213.242.68]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Apr 2021 05:50:37 -0700 To: Haifei Luo , matan@nvidia.com, orika@nvidia.com, viacheslavo@nvidia.com, "Dumitrescu, Cristian" Cc: dev@dpdk.org, thomas@monjalon.net, rasland@nvidia.com, Bernard Iremonger , Beilei Xing , Wenzhuo Lu References: <20210428141015.25728-1-haifeil@nvidia.com> From: Ferruh Yigit X-User: ferruhy Message-ID: <5de085c3-3ce0-c437-eadc-3c13e53d8854@intel.com> Date: Fri, 30 Apr 2021 13:50:33 +0100 MIME-Version: 1.0 In-Reply-To: <20210428141015.25728-1-haifeil@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] app/testpmd: support meter color action in policy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 > --- > 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, >