From patchwork Wed Jun 1 03:44:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 112174 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 516EAA0552; Wed, 1 Jun 2022 05:45:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E431C42B81; Wed, 1 Jun 2022 05:44:48 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2054.outbound.protection.outlook.com [40.107.223.54]) by mails.dpdk.org (Postfix) with ESMTP id 10DF942B7C for ; Wed, 1 Jun 2022 05:44:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KxoRQiFmS7ipqFdBdjt6MBKwWuMCU56WQuCxXYC8uKq1UAfAPk7MHDVm9PdAsHBHFUnim2XAAnOL0UgxyZEacNsXRQBqo1vqYtGtQ1RRxoCbD2AmoyXMqrVmoMpECRG9dqWuNLBTvIOPqYG+AJJO/9ve4UkWNQAp1SCAyZ1gbZHU+2VY+rek4gzE0x6xRn9paB/vnlVSCp8DC2BaJHYO7cLlYk/zM359RnZAo6J0P68x3p4ciWBvX2R3NIAybpmrfUgcxTCXXDd3VF+shBzzg1w1+XOCU0/z/6iO3ThwcDLIQb31TXCK3VXS33raqoXJWlJbGh2tDvD4DAm/ChhfWQ== 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=UpYq83qG9AA2W2v8RMRxB1kKI8pkN7iTFWXNGsu1QbI=; b=PtAQBPM7ts+jkSZbWZPFXAfKgNEHIEdEtdc8Bzv9+F4h/R4N2+0Tj+eWmQhI16j8go8upM/sUJhdKKwAxdE28CUJSAcQ+IB7dXGbZPVeG6FqH8naA7anVbZfLlz6Dq1P8Y024AsKslmWeOzB1QGGg4/+9WSOsPGE/tS8lgYqMfIqIXDBluuYikaKklnqeeik9HCwcjIFi/RUxc46XoWIVnVCZp/5bzA9joL+tp1yGG2uzVEUCj57BhgqAXUabSneqyYcYnwJZQiLuAaH0dE7KGqSnFuIPNqBw8UgaDi+Zz34o2hEN3GriXQ7da1Ar/AX1LcTJ7UhZljddRIspv1sQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=intel.com 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=UpYq83qG9AA2W2v8RMRxB1kKI8pkN7iTFWXNGsu1QbI=; b=teqbTvV3ivywEZsiAIrYXSK7DZ18w2cR7HPKw6Pp9Lc9qOI6K64lcG0/Qq5xHO8y33IRPp1dXH9ymvWrSbCqbNiYIZr/f8Hj7rcErpXr4CFSv7XHp9SVqNYG2zknpZ7pyCY8qms0ij8gvqHXZ5Y3wZUqRMP6HB/uI0emmBPoK/A0IfyP19tczpQslMIWwUamo3zZUsRd72tJY6lCIMf8UbkA1hMsOhkF0mBczGpD99iv34FnHLN5SnH539Ml+95HcTsr2ZPQRaIhFkf9pkpJerMpTiaAxPIHEU63LliOE9/pUGo13j/LzfCkps1P2B2iAXD/eehLwxD5DaekDZyOuw== Received: from BN0PR04CA0058.namprd04.prod.outlook.com (2603:10b6:408:e8::33) by BL0PR12MB5507.namprd12.prod.outlook.com (2603:10b6:208:1c4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Wed, 1 Jun 2022 03:44:46 +0000 Received: from BN8NAM11FT053.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e8:cafe::d9) by BN0PR04CA0058.outlook.office365.com (2603:10b6:408:e8::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 1 Jun 2022 03:44:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) 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 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.235) by BN8NAM11FT053.mail.protection.outlook.com (10.13.177.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 03:44:45 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 1 Jun 2022 03:44:45 +0000 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.22; Tue, 31 May 2022 20:44:41 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v3 5/7] app/testpmd: add meter color flow matching item Date: Wed, 1 Jun 2022 06:44:06 +0300 Message-ID: <20220601034408.2579943-6-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220601034408.2579943-1-akozyrev@nvidia.com> References: <20220522105102.1692526-1-akozyrev@nvidia.com> <20220601034408.2579943-1-akozyrev@nvidia.com> MIME-Version: 1.0 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-Office365-Filtering-Correlation-Id: 99ad62bc-a158-4423-a6ed-08da4381122d X-MS-TrafficTypeDiagnostic: BL0PR12MB5507:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +4NCXM77wG09AC5nLwuuOsokEyPTBInf5syx53f8acIlg7iWHXhmLBNoxqFKccaoEfxv3oXrGsP5891hleJGJU4vp6gZk+D1o3MZbnDkVnGryIBiZRzyKAw29rwDmDa991fuoHeT8vQxsoZedbctkIiYwuXE9vrLRQyxjOy3oPxa0HuiJP7BeWjvhX3ujEkTJ+pgM71NiHyFUv2uP1GC6xOwEd9nfX8U635CW7JWRzG+GWGbIZqJn0NgDeZiVNDPBSaxx+VdFDVEVz/pjQe4EkX8TICnwyhfudSSW1/CuQP7NFabW8EzGh567JrGP6FTgAb6gxCDAz+zyzuNqzAPBwi1Q+5f8bmRoN297n9qeFENYutrdfWnMrZCZhz4pPE4xAh1E6AuD5G3TKzrTkPJzp8mSexr7G8hsayVIueATOASnKcXCa+Vg2N6zO9aOOSg7FjwDP7sZhiY7ygK2NCtFR27MkeQyYDwSb/lqTYdqZjrLvdjEuhmhIyZ2ER6NB8jKJQk4tyMzv6hLgSEIn6qNV4kdr1CrvYF3ZmkggWMhpdRC/jt8myMU2d+cw/ZPTTONy/8GwzcL+IOqpl/LiXAzBkK9316SGpnkQlMz+qVxJ0nfwjmBJ49tt+xPC6lGl1gb0g5m7cBYWw/Ru47Vur8PWmSo23dKxJnzmoKO61kqLAqnL6givKalapsZ7ZV9Bp+vZVp0v+eL746xgB4PvKeEA== X-Forefront-Antispam-Report: CIP:12.22.5.235; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(82310400005)(86362001)(70586007)(5660300002)(8676002)(8936002)(16526019)(4326008)(70206006)(7416002)(2616005)(186003)(1076003)(36860700001)(6666004)(508600001)(40460700003)(26005)(6916009)(81166007)(54906003)(2906002)(316002)(47076005)(426003)(336012)(83380400001)(36756003)(356005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2022 03:44:45.9295 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 99ad62bc-a158-4423-a6ed-08da4381122d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.235]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT053.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB5507 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 Acked-by: Ori Kam --- 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 e3269e278d..c66da76f25 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -458,6 +458,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, @@ -798,6 +801,10 @@ static const char *const modify_field_ids[] = { "tag", "mark", "meta", "pointer", "value", 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 @@ -1331,6 +1338,7 @@ static const enum index next_item[] = { ITEM_FLEX, ITEM_L2TPV2, ITEM_PPP, + ITEM_METER, END_SET, ZERO, }; @@ -1803,6 +1811,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, @@ -2371,6 +2385,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 *, @@ -2401,6 +2418,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[] = { @@ -5063,6 +5082,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", @@ -9866,6 +9908,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, @@ -10157,6 +10223,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; @@ -10772,6 +10852,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 1083c6d538..5e2f5ffb40 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -4164,6 +4164,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 ^^^^^^^^^^^^