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 1E2B0A00C2; Mon, 26 Sep 2022 16:59:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 986ED42B7E; Mon, 26 Sep 2022 16:58:47 +0200 (CEST) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2061.outbound.protection.outlook.com [40.107.102.61]) by mails.dpdk.org (Postfix) with ESMTP id 0CCE14069B for ; Mon, 26 Sep 2022 16:58:46 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LT0BVx96sqs8rGggQh0IndssfAqDjS09Lae+aOKDcv9h8M3epYr96DMpEVppfNSXa7LZWHttmATHWJKfMda0UL9mlIjjOc6tRcPmyYdRvr4lSobuqM6QaxZ0GZ+nrpjpXbk8WGWFXELSxZ3PUwS7wq5m/63pHnxOVbzgBhWRxF7ZHLz0a4vBMw9ACIisbpbL3/+B7xuONSqGzyMEhMoHSJpq8iyaNYCXhgwKkF+fTsKcfGMKy+0q3YatoKGePLdXqJr0JvJhUVPPIi3hBvMT23CZjmTF3CcvUypB3C7fTn6XFZ6li3IMCxcPgWfBr9rbGjxGFIDnRuYmlvdJ0Wl8Hg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OSc012QTAAPCpca/QiKV7658B37NEdHsKBx7sQuRA0k=; b=OnNsrOVB73paGJUXFhQ8BcHEUeJNTHOh3f3ouI0v5sNJeT2se1rI5QgeArUf4HxIcNPVDIGBUech1G/OoCw6xknWtNnUfwkJGd44cyWRcHCHal/j8dXJFqQXqzanbeYzGJO1VjmeNm8eOg9AZnnCgkd1ps0SaFhfk1ByH0erOcb/sRf9K8AqfHacypxFtTPfGoLznUsYT6ZJHV0/ncdKnW+ERiPyG+lBqH+gZ2rcd0LGPU2LaK5Eik56SS2DwGL9+EnDEbWw4/Oc6KnQoxUpKKhyRwlveF///h+H/ZdNNv5GnDQazVSn9+nNkT6gc4Q9LLKswHYYChU03URDbfv/7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=OSc012QTAAPCpca/QiKV7658B37NEdHsKBx7sQuRA0k=; b=HiZp54dxHSOAmRwllzBhP8qSpB2hVHp1nKH95ZrvqXNKGrTUDECBpaDxmU0fpLowqpF1Jb0O0wI/BfYHXUhoe6yTM44TSXWZpr/I8E4DKE9sBXE9xWbnRiftDwp4rWu57vC/rmLeKY0r3xBt+KRlil96j8iGIeefbwB/xAl1V3abD/hhAzVzM4k2dB1wPDKfPtPx9fliCPv1KA/EL37AxTcsK6pRzhzLFb6PlHudZwBUCwRxJOUquxZAZ3k/KK3prxsAVesnJuQGXp4d531Db4G1SnItHlW/4toDOmkkz71iq/knw0uDxitesrQ7YKi7MCpFNKqr5sts/07vlcQRow== Received: from BN0PR02CA0047.namprd02.prod.outlook.com (2603:10b6:408:e5::22) by SA0PR12MB4461.namprd12.prod.outlook.com (2603:10b6:806:9c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.26; Mon, 26 Sep 2022 14:58:42 +0000 Received: from BN8NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e5:cafe::34) by BN0PR02CA0047.outlook.office365.com (2603:10b6:408:e5::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25 via Frontend Transport; Mon, 26 Sep 2022 14:58:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT028.mail.protection.outlook.com (10.13.176.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Mon, 26 Sep 2022 14:58:42 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Mon, 26 Sep 2022 07:58:32 -0700 Received: from pegasus01.mtr.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Mon, 26 Sep 2022 07:58:28 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v5 5/7] app/testpmd: add meter color flow matching item Date: Mon, 26 Sep 2022 17:57:43 +0300 Message-ID: <20220926145745.3962600-6-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220926145745.3962600-1-akozyrev@nvidia.com> References: <20220921021133.2982954-1-akozyrev@nvidia.com> <20220926145745.3962600-1-akozyrev@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT028:EE_|SA0PR12MB4461:EE_ X-MS-Office365-Filtering-Correlation-Id: 920a4c72-84ae-4bb4-72ac-08da9fcf9a8d X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /LSP2TYTqDyzLJ0KSz3KHXbhZ0OB4io9wCaxHz5UvY3lemQPMQSheT9b6yg/DHGfeoBIq1jC6gES2ucweQKrIiVIUFfACxQA1oseSV7yaHo147+zigznDSfFBnWqzYEWK2kEJiNZWYQATLUC48Xhlfxd9bph9TBoyofFte33gq9h4SNrLnbMd3VmgIeMr21uNXc1loZV4mIQskv5aJTG4D+1319CB+QdLrYOYkdinAAzTQ8lfpdF747Ou9Cma7D6Luy2wqTgNOQgoKWbkBJBt5iN9TT5AjyPVeCgELBm0HNlPafOurtk31mBrnXdjrVaUFA5Nf/bL0nMMQGkcpWrwmsdY6TRneEmmjIgDy8e8n1ICqE99MRk6xI03dklLhYYbyEv1azR6M6zhuy2vhhEZnA5ZVe9YMqIKswMhPx8xxYERAL98/GqcsIoJ0KQD4uA2NDalF7UTxgLHIHc3g93SOvpKqZSfkSOIoaDAIRAZOiRNnKu3MbPwS+naGEbJdsHZemYF1lTJ/DTBDW5Ow8UDjK9yR5X8PIdfmXcNlxEEllGxZGGSpAam/GRhMdAyqWYm1RW3uh4RYPA6LxDHZJJGRrKInj2sT8WMbHc9N72aXkCs5PNbZW57IxwhWpvAytvMxJcvsjr5agNG1frzfDpsV/Rg+iZr0F2oQiFoLoss7JDFApAomSohthRzTLIpLkdIk3+dZsJ01U6PCmjlwUEnP6TjGySOei9I++foh0I+dHoa4Q3iM9pUVoXiszSVqLnjZP59D7shgDll404ccLeMQ== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(136003)(396003)(346002)(376002)(451199015)(40470700004)(46966006)(36840700001)(83380400001)(426003)(1076003)(186003)(16526019)(336012)(356005)(7636003)(82310400005)(82740400003)(36756003)(40460700003)(47076005)(86362001)(40480700001)(36860700001)(70206006)(70586007)(8676002)(4326008)(6666004)(41300700001)(54906003)(478600001)(316002)(6916009)(8936002)(26005)(2906002)(2616005)(7416002)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2022 14:58:42.4323 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 920a4c72-84ae-4bb4-72ac-08da9fcf9a8d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4461 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 Add testpmd command line to match on a meter color: flow create 0 ingress group 0 pattern meter color is green / end Signed-off-by: Alexander Kozyrev --- app/test-pmd/cmdline_flow.c | 83 +++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 + 2 files changed, 87 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index d97be6fe98..57fc30d13b 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -459,6 +459,9 @@ enum index { ITEM_PPP_ADDR, ITEM_PPP_CTRL, ITEM_PPP_PROTO_ID, + ITEM_METER, + ITEM_METER_COLOR, + ITEM_METER_COLOR_NAME, /* Validate/create actions. */ ACTIONS, @@ -800,6 +803,10 @@ static const char *const modify_field_ids[] = { "ipv4_ecn", "ipv6_ecn", NULL }; +static const char *const meter_colors[] = { + "green", "yellow", "red", "all", NULL +}; + /** Maximum number of subsequent tokens and arguments on the stack. */ #define CTX_STACK_SIZE 16 @@ -1333,6 +1340,7 @@ static const enum index next_item[] = { ITEM_FLEX, ITEM_L2TPV2, ITEM_PPP, + ITEM_METER, END_SET, ZERO, }; @@ -1805,6 +1813,12 @@ static const enum index item_ppp[] = { ZERO, }; +static const enum index item_meter[] = { + ITEM_METER_COLOR, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] = { ACTION_END, ACTION_VOID, @@ -2373,6 +2387,9 @@ 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_color(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 *, @@ -2403,6 +2420,8 @@ static int comp_table_id(struct context *, const struct token *, unsigned int, char *, unsigned int); static int comp_queue_id(struct context *, const struct token *, unsigned int, char *, unsigned int); +static int comp_meter_color(struct context *, const struct token *, + unsigned int, char *, unsigned int); /** Token definitions. */ static const struct token token_list[] = { @@ -5065,6 +5084,29 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.proto_id)), }, + [ITEM_METER] = { + .name = "meter", + .help = "match meter color", + .priv = PRIV_ITEM(METER_COLOR, + sizeof(struct rte_flow_item_meter_color)), + .next = NEXT(item_meter), + .call = parse_vc, + }, + [ITEM_METER_COLOR] = { + .name = "color", + .help = "meter color", + .next = NEXT(item_meter, + NEXT_ENTRY(ITEM_METER_COLOR_NAME), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_meter_color, + color)), + }, + [ITEM_METER_COLOR_NAME] = { + .name = "color_name", + .help = "meter color name", + .call = parse_meter_color, + .comp = comp_meter_color, + }, /* Validate/create actions. */ [ACTIONS] = { .name = "actions", @@ -9868,6 +9910,30 @@ parse_flex_handle(struct context *ctx, const struct token *token, return ret; } +/** Parse Meter color name */ +static int +parse_meter_color(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size) +{ + struct rte_flow_item_meter_color *meter_color; + unsigned int i; + + (void)token; + (void)buf; + (void)size; + for (i = 0; meter_colors[i]; ++i) + if (!strcmp_partial(meter_colors[i], str, len)) + break; + if (!meter_colors[i]) + return -1; + if (!ctx->object) + return len; + meter_color = ctx->object; + meter_color->color = (enum rte_color)i; + return len; +} + /** No completion. */ static int comp_none(struct context *ctx, const struct token *token, @@ -10159,6 +10225,20 @@ comp_queue_id(struct context *ctx, const struct token *token, return i; } +/** Complete available Meter colors. */ +static int +comp_meter_color(struct context *ctx, const struct token *token, + unsigned int ent, char *buf, unsigned int size) +{ + RTE_SET_USED(ctx); + RTE_SET_USED(token); + if (!buf) + return RTE_DIM(meter_colors); + if (ent < RTE_DIM(meter_colors) - 1) + return strlcpy(buf, meter_colors[ent], size); + return -1; +} + /** Internal context. */ static struct context cmd_flow_context; @@ -10774,6 +10854,9 @@ flow_item_default_mask(const struct rte_flow_item *item) case RTE_FLOW_ITEM_TYPE_PPP: mask = &rte_flow_item_ppp_mask; break; + case RTE_FLOW_ITEM_TYPE_METER_COLOR: + mask = &rte_flow_item_meter_color_mask; + break; default: break; } diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 5fbec06c35..b586e92649 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3697,6 +3697,10 @@ This section lists supported pattern items and their attributes, if any. - ``ctrl {unsigned}``: PPP control. - ``proto_id {unsigned}``: PPP protocol identifier. +- ``meter``: match Meter color. + + - ``color {value}``: Meter color value(green/yellow/red). + Actions list ^^^^^^^^^^^^ -- 2.18.2