From patchwork Wed May 12 10:49:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haifei Luo X-Patchwork-Id: 93207 X-Patchwork-Delegate: ferruh.yigit@amd.com 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 7802AA0C43; Wed, 12 May 2021 12:49:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 32DFD4003F; Wed, 12 May 2021 12:49:57 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2079.outbound.protection.outlook.com [40.107.243.79]) by mails.dpdk.org (Postfix) with ESMTP id 153C14003E for ; Wed, 12 May 2021 12:49:56 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SaichcaQJ27pu6pQaUuGyrl6GgFMMGzWdQGjzSjQxEvETk9OlybpwvLsflH5EDIM2WAdEP9NlG3ufbQwH4QSPTv6Ue/dLSf1XU1wZo0lLXYreNGSJi9EKEQpmIIN19dgFQ/Po/zvOb794oM9ptBTZ2SEFR6N4JoBBkAEDUPxUZs6oMxWmBBdlCb2zI8zAQ9sZqEoTY+qw3rAjA2UvmF34m0QkmITtRnxMGK5HnP5b+LQlHAsSbVKHCl7fmCjOexyRn/6NOFD83pdGkjYgcErTTwMgAklrI710PAoJKSe25WhH8/6K/2Xg+jTtNmdciJclNwldIpMqf9ZPYJZYYUL9w== 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=fSz9vmJXODzvEjCoF9mZhCWlgquY7/fk/zl4hEkAaTM=; b=P37u6T8Q2echDEI8I4RQ0DTraRGSF8JCEkLIrE34rcuaDgixhPSBQU1FhH8RYfdkFk2poNP4Wdg05rNuIDdHeMGrlo+rxrqeKiy7193PeV+OOP0hv5y965PsYG/kYL3ZzpKzLkJFFAdW+LnJtT31WSZf0Jb4CeR8PMshmIOm1qoovfJ5D6kXblZ6TRqjkoHBwvbE+iH/FdOd/ed6ivEVWwVAMtnHgta1J/poflN59Pa85cr9p3eQrlZPgD0SDYfa9Q9geInhcHsjsxTVSJ/rOphz/JA+t7L2rPfkYaX2ey0+7UozaLsNhSeqICcyuoi6QievBlYnHnkX5JcnaG0PWw== 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=fSz9vmJXODzvEjCoF9mZhCWlgquY7/fk/zl4hEkAaTM=; b=XRj/n0QjmT6Jj7MwwfDLBeR+Hc1Q1fzp3WiI6fEn+AlJV3jW5au03l/OuzoysUYIpOmI89oIcLkTBbet4XxocWw1ytuVeNEs3ma9TeOxAP4GmBox2MNvHGTcl7uC3Z4o1TQN491ySV+wPCbwMAARPtRXWBtmR4sOXzGPxMaky9/8S4QQWnx5inPaC/b01l1Bn+Qzx5xNBaXs/O9S0YIWKsCHcMlEeP833awC7NItE9QnObk+kZ5vsbJ6Yt6xXxngKVdvgv73BjDppkgdDRpFlY+hNjEkF38RPoCZ2niqVgO3fJ1XhmimkFy49u1VWswlNDfKuHCr0PiCmxqlnjj2vg== Received: from DS7PR03CA0126.namprd03.prod.outlook.com (2603:10b6:5:3b4::11) by BN9PR12MB5276.namprd12.prod.outlook.com (2603:10b6:408:101::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Wed, 12 May 2021 10:49:54 +0000 Received: from DM6NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b4:cafe::8f) by DS7PR03CA0126.outlook.office365.com (2603:10b6:5:3b4::11) 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 10:49:54 +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 DM6NAM11FT064.mail.protection.outlook.com (10.13.172.234) 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 10:49:53 +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 10:49:51 +0000 From: Haifei Luo To: , , , , Xiaoyun Li CC: , , Date: Wed, 12 May 2021 13:49:33 +0300 Message-ID: <20210512104933.27999-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 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: f8d861ac-6cc9-4295-23c2-08d91533acff X-MS-TrafficTypeDiagnostic: BN9PR12MB5276: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a+iTeNfiTnGw4KBMXzxu+jOMhdMCkUQfs1K+MLT5P1+oRWsYG6U5f6458ILDaOyD8a2P836u4dIHBvrEqamgfPyvvOfddJy0jZFukogeno9Vraoz3aWfc+PxvtxJwGKPqQM0abqzWdHyDmbzFQ0rSiB3n/nfoc9O7jajXEZWdRo+BkGVjX723fHwbNSFtXfP4kDZdwqivpRk9Ax1InN6BT2CLKLoSXEvhFacLC0/Wrivv06qym5gCCHv/fMGFe0Q5narFpHnMXI7qvphOOYNBQptOV2B1M4W7BSCkcl+8yQHOLfZjFvk1bLkOcDNiMITLWisp9wuoMYmhGoTuj/Zwn9XlAkiASpnYtNjR7kFEl3aWRWEUZrH2dsmp4Pp4Hij3W4AZrxX6LXdVkjlFVepTnGKgWD0mOlwmRH8n08RTjb4i33QkLgfN3BDq+HI4n5v3vPinoLkBfK+oYcpMgVddr5eALdwkoTA0ItHRJsKdqeGkE6bVXq2rQZMulWpa+OHt/NUV8jA8WC19ZdxI5NUIAoR05FhsIoLFuYbtZJDk4cA7ikOk3Hk6+zhfLc4UMZC9xGRZSCR59n8dkVbcjmDHihmckklzqQazThc1vVz65tkXXNPCIygkctXZKMwHpVSeUQTHAv08nsvn1w/cxzDcXg9qiU8caoeBSzLrDn0K+M= 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)(376002)(136003)(396003)(39860400002)(346002)(46966006)(36840700001)(36860700001)(6286002)(478600001)(6666004)(5660300002)(356005)(55016002)(8676002)(86362001)(7636003)(426003)(1076003)(54906003)(110136005)(336012)(4326008)(2616005)(26005)(82740400003)(107886003)(36906005)(7696005)(70206006)(70586007)(186003)(83380400001)(82310400003)(316002)(2906002)(47076005)(8936002)(36756003)(16526019); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 10:49:53.8423 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f8d861ac-6cc9-4295-23c2-08d91533acff 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: DM6NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5276 Subject: [dpdk-dev] [PATCH v4] 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. V4: add sample in the document. Signed-off-by: Haifei Luo Acked-by: Ori Kam Acked-by: Cristian Dumitrescu Acked-by: Ferruh Yigit --- app/test-pmd/cmdline_flow.c | 85 +++++++++++++++++++++++++++++ doc/guides/rel_notes/release_21_05.rst | 3 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 23 ++++++++ 3 files changed, 111 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..227180e 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 ~~~~~~~~~~~~~~~~~~~~~ @@ -5010,6 +5014,25 @@ rules like above for the peer port. testpmd> flow indirect_action 0 update 0 action conntrack_update dir / end +Sample meter with policy rules +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Meter with policy rules can be created by the following commands: + +Need to create policy first and actions are set for green/yellow/red colors. +Create meter with policy id. Create flow with meter id. + +Example for policy with meter color action.The purpose is to color the packet +to reflect the meter color result.The meter policy action list: +green -> green, yellow -> yellow, red -> red. + +:: +testpmd> add port meter profile srtcm_rfc2697 0 13 21504 2688 0 0 +testpmd> add port meter policy 0 1 g_actions color type green / end y_actions color type yellow / end + r_actions color type red / end +testpmd> create port meter 0 1 13 1 yes 0xffff 0 0 +testpmd> flow create 0 priority 0 ingress group 1 pattern eth / end actions meter mtr_id 1 / end + BPF Functions --------------