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 2CE91A0C3F; Wed, 28 Apr 2021 16:11:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE2B240697; Wed, 28 Apr 2021 16:11:06 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2088.outbound.protection.outlook.com [40.107.236.88]) by mails.dpdk.org (Postfix) with ESMTP id B74B440147 for ; Wed, 28 Apr 2021 16:11:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ip5xv3ULABwzdmnU9rKlKEMk1liL1z3/OE5pmWr5S4WDCFRSWyqkG16KaiouoUkfznswMJ6WuU8lF9yJufOhnZysNLhqbguqSLhsgohxHj10PoF/Oy5B0zMGSo/fMuEOtqvOp7VSNIyR4yLm94JSnjfcGJOM201ZGslNAhQfJ/rBtiNdmFcq5XkDeuDiZMitD9NNSF+Gvu4NbwwrdMcVIQtYn/uEeIGIfcvEQQXgFanaBZMkuBSUVPP9ODyWg7eVY3xdncGRgjp0LoRS5ATPMLIC0SygvrOb4VT1bDZzCmu4DXo7v8A6VMRsFkA1TUir6gqR8KCjSoCoqaNfGQwNSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lSi4lXMxuADCTY5x0c10H96gq7TA4vLUYi3mn/IOmYY=; b=W37WtG39zHx3Tfu6CJ1s8e19Sc6jFDA+Y+j6yYK0/2Nu49I9YShLpGpqsO8eWrfWac6QzlaTQJ9jKQD0/QXPGORP1j/+xyeFzkvgtn++V1ojmJzkWRXFQvLSLDVfNm8d49RxeyYS78FooiN9jgR1/sHw10sGviPCwfdoFs7+y/vtAE0kTwHAKR7zdd1jaN6E0r7HzukeFk5G7V4dI0nzlhIKDsNVMxYv4ttimcOfjvH1zzPifPKENremJF2+eSwrSeIVpmmCpMDtyOnn9E+KQ+hma856iAwfAzAseh1Q7escLJNUHg+5w8WwpAugUA0UzG5VTLSKQhBqScvedR57PA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lSi4lXMxuADCTY5x0c10H96gq7TA4vLUYi3mn/IOmYY=; b=edSjlrJfDJSZ3EOB/tj8Za4sY1cEVp5dolryBzd+S+OkBAQ36/w5Lb1rz0tkKRbxyfcOhOUk80qGj4SkWEknakR8WQnVQ/1cIGX7bIEIW25n3mXSdhFJOscfNsnQYADpKe3jDTUhYcuUDETGHXWA/VCko420BFTI3BMSBImngzsyNZNgG8pBpZsO/irL0qkF2tZNEqdV7JP3kCScXEpKQAik8FKfDyjAWvobJ9WZg8Z99Rj2scVvzf0f8/JoxLQF6UXV85WdZZvQDFbYL/tKXC01jIhUj8kTIRQv4A4c7AgcEPh3yAZHmREr2HXIEzXzwZjuGT9ydSQ+860ZxYxI5g== Received: from DM6PR18CA0018.namprd18.prod.outlook.com (2603:10b6:5:15b::31) by BL0PR12MB4897.namprd12.prod.outlook.com (2603:10b6:208:17e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Wed, 28 Apr 2021 14:11:04 +0000 Received: from DM6NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b:cafe::c6) by DM6PR18CA0018.outlook.office365.com (2603:10b6:5:15b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.25 via Frontend Transport; Wed, 28 Apr 2021 14:11:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT068.mail.protection.outlook.com (10.13.173.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4065.21 via Frontend Transport; Wed, 28 Apr 2021 14:11:04 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 28 Apr 2021 14:11:01 +0000 From: Haifei Luo To: , , , , Wenzhuo Lu , Beilei Xing , Bernard Iremonger CC: , , Date: Wed, 28 Apr 2021 17:10:14 +0300 Message-ID: <20210428141015.25728-1-haifeil@nvidia.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6d8341d5-552b-4d35-21ec-08d90a4f75d3 X-MS-TrafficTypeDiagnostic: BL0PR12MB4897: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1443; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4H996NQx/5O+lDP4EdwHcv555PFqNKWvD6xAGLgjPt7LhFQsdUDkomGjIhAbuVY6xSjLVY8z9zElqBi6wjUMHn67FlTBW8gRh5v7fZl5GJcbe2sA26xNm5VcestYd3kKWaT1/gbfuVyahplfCgEIXbZ2oeXiyKdSl9hxuxZi6yelgpx6Wt5cpoxI1WqBOrY0Sa8Or4RLp6pZQQeYBvIVmORPMa3U2qXWzgED1ryyTYQ1DAvC8+IWnOEQ5OrGtiSjkOaBC1KFVUj5HtzodtEoDq8CNGpKRZTKOHALBJtgq8drOzG+INPHAG79JwQfpEsnrQmbvAS+yKWl/WeJyC5qN5dm2ETNzuNsy2L03Nj9POdp9KsaRLmjLmrSSkejS2qOntE9Mfuj4V7S26gZ8dSJ4seypoAn0yTQZGBPLOORdHoal5dXc6zj4w9PhuXiSnu022iUePoKHD/fPrLgfPQyipzgZSchxTNFfBu1TFgxzMaxBpH0zqsIaA8OGDqNljQI3ynUusDTQvBk518Q1Dro/HZHdssh8p3OLD1gpwu5zZ33hS01cKnYevi/NyZH+nErHShrhShfTX1c1iH0BKV2p0+tlpn6UnE3x8H274mJtY0bxQZBGdmq+Tfh8sPntUwseugSErZXy5H/W+Ui0PeFTA== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(346002)(136003)(396003)(376002)(39860400002)(46966006)(36840700001)(8936002)(82740400003)(7636003)(356005)(186003)(82310400003)(86362001)(336012)(16526019)(426003)(2616005)(70206006)(55016002)(70586007)(8676002)(26005)(5660300002)(107886003)(1076003)(4326008)(6286002)(6666004)(36756003)(36860700001)(110136005)(316002)(47076005)(478600001)(54906003)(36906005)(7696005)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2021 14:11:04.4031 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d8341d5-552b-4d35-21ec-08d90a4f75d3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4897 Subject: [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" 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 --- 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