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 85D60A034C; Wed, 21 Sep 2022 04:12:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5CE3D42B72; Wed, 21 Sep 2022 04:12:39 +0200 (CEST) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2046.outbound.protection.outlook.com [40.107.102.46]) by mails.dpdk.org (Postfix) with ESMTP id D5B2C42B7D for ; Wed, 21 Sep 2022 04:12:37 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kj29sRIlskYwsTpt6+4evd1zQEq7ggxabtvC+lXNiM2SZFciTxQU7tkE1XSZ5WGQ7qVmk5WK0Buesy2CPyEgwAU/WT6+kro0SrjTm1nXBbz4vvQ4CuXoYMV3fYHTy6XBa0zfD0FBOL4wR4Y47p5Y2W7OlkZQBLw0mnA3GjuR9ET3bjoYDokjAz85onmgMk+4Peey4nByL+UeSBAPgJMhfdgwxG49pmjAfwc8dExZjZWQmg4eweeEmb7ouNtSH5IfOW6uExGCZ5QtUJmhd7iohif0m5jbvxFd9e5JXPagV1lsmZxKwwt6UC9eKsRlk54cE0ruKGZYRBmQUkh5vBhYnw== 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=PyUtvVNznTwha86iOsUDuQMNl29XkTR9eU26vrBKerU=; b=NsZJPKEqY3yhcX6Z2QJAjcsOtAWCt1B1hc9nFD5LhdxN8naN9LW3woAUv0sh05HnN6W2/jp3zDAy4mT5rTxEIpwdbA1gsSBbnMQ0PPwH/7gfJfQsC416q15TjHhFtf0B5YCWUBhCwDKnnXcKXpmVgeXzk2ltXqz7v8DH7mi/0Uqp8iCWUflUmtammgytWzp+6Ey+FQ6eI2jLvWUAF/Cmplc/gP/MNBa966O9x29a7+upfjpMXU9QVkyGEFJK/SiCtxxFwikBFMc89aHkhdeQw5EDbynnN1cQ3c4MUt/sPjAIDcMSGv0oV0bDI9GIG59OjzyklPOGMoRtUNc8nCJ6NQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=PyUtvVNznTwha86iOsUDuQMNl29XkTR9eU26vrBKerU=; b=MZXe5SNKEadC8Ywczu2fSIPRzuI/+9CHhX/rrS6bDaYaQKUnmI3nniKcjDI9pj1fWajv28mT4IvkS7E1ALG9oqp7pTpxxonxrC6jRMTn6pB8YqWaRLwiTtTKVN6sHA4LTBHsn5sakI/TIB+U1R5DaAquLNrvjX7NWyp6PBsByrI0YmlUtmDBk/hXYQkNJnY/5iIK6+Ck4KXwKv5xyLVUMs7i4lOuLNiN3Kh2v6FmpJgQPnuxmL3jr/BFcb/umOU8Rizv3LpZgC9eR7fwJhMQxpsJVVaGMJzk84DNxPaKJeEqEv9Q4gYO68QUNadto/eKU5ZyX1RCLICFxpYQVaBkeQ== Received: from BN9PR03CA0809.namprd03.prod.outlook.com (2603:10b6:408:13f::34) by BL0PR12MB4930.namprd12.prod.outlook.com (2603:10b6:208:1c8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.19; Wed, 21 Sep 2022 02:12:35 +0000 Received: from BN8NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13f:cafe::ac) by BN9PR03CA0809.outlook.office365.com (2603:10b6:408:13f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.16 via Frontend Transport; Wed, 21 Sep 2022 02:12:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT031.mail.protection.outlook.com (10.13.177.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Wed, 21 Sep 2022 02:12:35 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 20 Sep 2022 19:12:20 -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; Tue, 20 Sep 2022 19:12:17 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v4 5/7] app/test-pmd: add meter color flow matching item Date: Wed, 21 Sep 2022 05:11:31 +0300 Message-ID: <20220921021133.2982954-6-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220921021133.2982954-1-akozyrev@nvidia.com> References: <20220601034408.2579943-1-akozyrev@nvidia.com> <20220921021133.2982954-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: BN8NAM11FT031:EE_|BL0PR12MB4930:EE_ X-MS-Office365-Filtering-Correlation-Id: dc37ae97-2460-4ad2-2f4e-08da9b76c021 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: 1OHmJuyQA7ABGXqgtKySV2S66EoTlAYJLGCH88FGTcSe/5rOpfWqnBVtQHVZxeEenzaRCt4sWYGgamDhEjN5BBfr74rEv66BCZ6Cv8fSbADsGWBjoTrQ/22QbraD3YoN7r43gzYbagy1Olrq81oZfa8IQmpv21LYiHoAmVVzXE3d+cn9SndrULRu+Ta0/5BbApPW+wTcV6iPy1foyptPr2Az0DZr73M4kCxI4YofvRoShxWn8seENSpdH3wfOGBtYWI8igqcvHA+pNAD8HgbhGXouRQ4Z9D0DBYNlHSYrDoEygSKHgvN5hjP7Euwoe5WA0Vr38McukJ584GHgoiwnp1HIg/RFI/rATSRpe5kLVBujnFAYyM4AXsNnMDW+nJV5xrGktvolE2rc414HjaqvwyJ1746rEaGn/eaj9QHxo3Cyo2/pbEEdtsIgbYS8YsiVaxHygDKvG3d7ZA3UtbupMDbbskHFLt6W/xcDNBgmlnSamWUi0XObVvDA0YWY5gUx8XQBCc41OpAl4U0/yW6I+6ooNJAziTZcwe+WxyzNnW1QAhF5YmqZbC+HZS+pOsFhVyPd2r5C2wlTQ4ZPU7b0tQT57ILiC3MlUdlE+ZamXhNKlEWMKmSBJ5Rqok6GIotbmDmC19ECXpuuQYwMja91w1VVaZ8D+1q8BDI30U8Mow4OlxR+smwT+U2ubVPSCYaX68jYfktiaECqZxRclC4+h759IohAGPGhi0J7/O7U5+fNnMIppVltMQg3aVOUjXfkIUnm0jAV3V5z/ZCGoNnDg== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(376002)(396003)(346002)(136003)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(36860700001)(7416002)(5660300002)(47076005)(82740400003)(83380400001)(6916009)(40480700001)(54906003)(478600001)(316002)(40460700003)(356005)(336012)(1076003)(70586007)(26005)(41300700001)(426003)(7636003)(2906002)(2616005)(16526019)(82310400005)(186003)(86362001)(8936002)(70206006)(36756003)(8676002)(6666004)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2022 02:12:35.6318 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc37ae97-2460-4ad2-2f4e-08da9b76c021 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.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4930 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 7f50028eb7..b8c92efb1d 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, @@ -799,6 +802,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 @@ -1332,6 +1339,7 @@ static const enum index next_item[] = { ITEM_FLEX, ITEM_L2TPV2, ITEM_PPP, + ITEM_METER, END_SET, ZERO, }; @@ -1804,6 +1812,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, @@ -2372,6 +2386,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 *, @@ -2402,6 +2419,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[] = { @@ -5064,6 +5083,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", @@ -9867,6 +9909,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, @@ -10158,6 +10224,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; @@ -10773,6 +10853,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 330e34427d..150cfc0664 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3904,6 +3904,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