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 860D6A0C42; Wed, 12 May 2021 09:02:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6DAC9410DE; Wed, 12 May 2021 09:02:52 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2074.outbound.protection.outlook.com [40.107.237.74]) by mails.dpdk.org (Postfix) with ESMTP id F1C5F4003E for ; Wed, 12 May 2021 09:02:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iHYiznnep7SJI+Wq6QvTdjyizdkEpJIqvAuBYKg1PWD6UzBvQnKItkDz6lCCtAKs/7NQ2OIldmVZx19UUQgMQbHCq5GJyw/+YqzNq6aAH9lQLXByLiD/0fPEuzbrcuy1DlT82SM9CBnKKmGEMvsUtcwzpCtiOd1jeciB7G46jZRG4sIonO0PCodPrSpdaLRG3sLkwTL9xOeSeQiIhwEwcaIahdirJEJ/sEqZDzy7TKXgmBIxSzP5YpSOTK6ndUtUIukdBa7bpoCcdO2HHXnOcVhjus1izWQevy66n5y4jlXkEgqYcUpNSqD9GFx1k5I1dDV0uvKXBJPUldMPyfvZ7g== 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=2CQqi/oQDxQwLTEYBE2QoJ1ifyJ71LZp1+VKKzOg0wg=; b=UhItJk5XgFxppxNV3sv/4FPr5XKnBYJJ3I045KNstUkzJJ0nQUJizyNw0Rpmu0QckSMI7pOuxKd8nB/ZjbLnTSMzmYkGa0GQvNMcytlG6A5tc4bIcqlNYlylvCwof8Bc+oBIxV7orPtHh030bIYXilcdwttI7lRtI1Y2O2QAcUb2D42QLu0fxOxcQ9OPu22EidP5DQqUQgyeVL8y8NWHUQ5K25BXturwYbHayGuU7YBNPYeHq9CxZAGvVfN8zcBKVE2TxSeXX+sr98+hU9uFjyrgTkQVghtm9n8vtUDdVBtrM6SFbhlOqx8jmF5xvWhuTZhjSHEdg7A1Xc3QFkwzkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org 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=2CQqi/oQDxQwLTEYBE2QoJ1ifyJ71LZp1+VKKzOg0wg=; b=kZbEnRrKzZU7EpzmmPwmO5zfrvfPpt98uuL3ikf5RkdJ7W7oRtW3wKIWPRF7NK87gZ8sn4eV9d6mKM1VpOfLRhqsQoyleDDj8Y6V+oX0wn2fqbjy9C5kylXqFTRzZBypJ9gy88J2GNgCKuTeU+8u3sqEe/nAbkoeip77T0DoYYj6yPt4QE3c4GtO+jqn+Cnq95lkyKqcuKpbIOFqMshX76ktwY5XljYPmy4rhF78nVwL4DW/BPlp9ZKvWJ9Gtw71fhL8wA6vGKujFfNu4bOzUZvfkXI8+9cqxN8OuKVpz0LA3lhVRI8vdnpQzyeiCBC6hyPJfXJodMVmqutEjjsQgA== Received: from BN8PR07CA0036.namprd07.prod.outlook.com (2603:10b6:408:ac::49) by BN6PR12MB1810.namprd12.prod.outlook.com (2603:10b6:404:107::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.29; Wed, 12 May 2021 07:02:47 +0000 Received: from BN8NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ac:cafe::e1) by BN8PR07CA0036.outlook.office365.com (2603:10b6:408:ac::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 12 May 2021 07:02:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; 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 BN8NAM11FT040.mail.protection.outlook.com (10.13.177.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4129.25 via Frontend Transport; Wed, 12 May 2021 07:02:47 +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, 12 May 2021 07:02:44 +0000 From: Haifei Luo To: , , , , Xiaoyun Li CC: , , Date: Wed, 12 May 2021 10:02:22 +0300 Message-ID: <20210512070222.22190-1-haifeil@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210428141015.25728-1-haifeil@nvidia.com> References: <20210428141015.25728-1-haifeil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 39ca8213-a3c8-4a59-4bca-08d91513f310 X-MS-TrafficTypeDiagnostic: BN6PR12MB1810: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2887; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2GutPYf69J7CQLQrV8fC0Dr+VYMsmoUIdrjxReCRuCir3d1EMu4kjxc2TTnBRk2qTz9YcXs/8r7qqw1HyXddo099c1B5lSXHuLiTF+BLS0wf++6aIsrUAISB8+cPXRnkF8FKaNrKSgSzhxh44cWGdA622zFJS2x8rEL6l7a7CN/ItHyjf5Vo8pXe8GeemrG16fi0O5oee9R8PkBCCvW93MS0QvIw0488kUK/RgNMKM/0rg5CWPMeXh2gvH0RPeTx5FGeGjlMIYwm11OeI4hbNWVxpboeJCcQBbz8DYLFoe6idwPuZkOpt5AdZBFkqorCeZvPzkLafxGc9QNECxcdMlvWaN5DA5bUb+4WSfEJ0rU1qiljUZA+QKjqX6fsqeznVyjuM4VcKEfALdhMOZ8O+Ps8UmPrukworKEqYiNPbssLgdrE3GTJGnqyGQ+kvdKaZG0wDH1fyHRcGROTuqdjkQxHQgrE3LC/1tFApc5cXlU2nwJ2DuXyNZUEx5BXR7ukT2IzCKO+/0ch/iyDC0uyuJWEHgq+eTp9ny7Qf67MFzd6OycDFq2Oqs4JPUEgJTsDBgWGdaGY6o5RJ8hihVPnvDyleNfWrhap8gSCkqBan9hfrLZyafrxwwzu0fTF5n1rik0zlRbVRMZ/3RU3o5TbIhur9MseWfsH1+ZYU2NL/Mo= 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)(46966006)(36840700001)(7636003)(356005)(6286002)(36906005)(47076005)(82310400003)(6666004)(7696005)(70206006)(36756003)(2906002)(498600001)(426003)(186003)(5660300002)(1076003)(110136005)(55016002)(83380400001)(26005)(107886003)(336012)(8676002)(70586007)(8936002)(16526019)(2616005)(86362001)(4326008)(54906003)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 07:02:47.4220 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39ca8213-a3c8-4a59-4bca-08d91513f310 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: BN8NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1810 Subject: [dpdk-dev] [PATCH v3] app/testpmd: add CLI for action meter color 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 aciton: 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. V2: rebase the latest code. V3: update the document. Signed-off-by: Haifei Luo Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 85 +++++++++++++++++++++++++++++ doc/guides/rel_notes/release_21_05.rst | 3 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 ++ 3 files changed, 92 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, diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst index 30dec1c..8b4a1d8 100644 --- a/doc/guides/rel_notes/release_21_05.rst +++ b/doc/guides/rel_notes/release_21_05.rst @@ -269,6 +269,9 @@ New Features * Added commands to construct conntrack context and relevant indirect action handle creation, update for conntrack action as well as conntrack item matching. + * Added commands for action meter color to color the packet to reflect + the meter color result. + ``color type (green|yellow|red)`` * **Added support for the FIB lookup method in the l3fwd example app.** diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 98a669b..88484e9 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -4089,6 +4089,10 @@ This section lists supported actions and their attributes, if any. - ``indirect_action_id {unsigned}``: Indirect action ID to use +- ``color``: Color the packet to reflect the meter color result + + - ``type {value}``: Set color type with specified value(green/yellow/red) + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ -- 1.8.3.1