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 67816A0C44; Wed, 12 May 2021 14:20:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F29CA4003F; Wed, 12 May 2021 14:20:13 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2040.outbound.protection.outlook.com [40.107.92.40]) by mails.dpdk.org (Postfix) with ESMTP id 1453A4003E for ; Wed, 12 May 2021 14:20:13 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=afrD9Dhbr+gDk5yWlsU5VMqKLmFAF0db8fTSivU0CsTtHsxIEJJNBLyuMZKF3M415m10DAXtjsKMJL1BnmnsNh8u/S6GC4D3qJ5tG1HR20AKswWkSK/lmfzjU+vHWbi4zETSzTXGdfxpsOsuXiAk0DwTCOs63gIBoU7gmwPTlS85wiQfCwbr2V+8qpVbPDZtJr2L06aLE7VcXOGcO7nlL/q0ExnNvRqVPOdiA3u4DHiWKuFYStv20W96nuYn7xHbt/ReRepS74yJEikTeE9FFScuqmSxOQErpJ2wxtysvRwPKJzFeJ0DMKeQNrH1+aQcoJcWF+/LUw/gdhF7+mJItg== 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=Ol8bT3ZzAPz65hBXh2m0f7aMA2m1TTriZBBvwQYJrgU=; b=WgtwWwdTzdLvwiBiV9X2VhXHTWqhjg7yqJvjKOfHrzcDHk4yCMj66bYRqo3e3QITxt+k+kkJI7ImJdAOpFeZUD5wtk9LrTdmv8PTFXwbLfKONkdQRaxSuR6SLn/KCvtf5Cg46Y1ZbV8cBBqN6ot//5k7opkrvn25ECHOzWBq00gkzEpTjYWlei84k0kyDaN8m4d/r26pey1CLF1OIaTZtvQwvydws0jRmi/virsnOfiB3lxiOmaupzhOCy0JOxxi59X4VeobZGUiqUmlpsSqj56JKjsh1jPYUYtpcwbwxOYHkQpYMZDC1Fl1brYuuG/9oY1msM5Z4tD9SAamGD4Jeg== 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=Ol8bT3ZzAPz65hBXh2m0f7aMA2m1TTriZBBvwQYJrgU=; b=Eipqi7cI34jPKTjP/tXa8cVvn9x+TUhPGtLh3D2pm9GzKL09hWoGeP95uIkMP0InflDCQTOjpILRcJm9+PaO8qRvDPJJNyc1bKUlQg6RUNm1UOTHUEpJ797wRAD1br6Nx92PW0KpviXrNe6c//7V7NSZhjwu5SPlqG+Fg/7s9IUGKNNsIIH12/3iommmPe5Q9aFC/6uphxoyYsOWiwyL36pFYP+BRSus702TWHFDKWCPOM3i5rdax25ZP+Gv7GyOb8wsL7O/SX+A6qWyZ1wvWy2h56o2JvHIaXlh5RMQLsNwEYUG50NGaS9lKN0Ly/ptkazsYmusR2kcDkzgR1xX6A== Received: from BN9PR03CA0150.namprd03.prod.outlook.com (2603:10b6:408:fe::35) by DM6PR12MB5520.namprd12.prod.outlook.com (2603:10b6:5:208::9) 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 12:20:12 +0000 Received: from BN8NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fe:cafe::cf) by BN9PR03CA0150.outlook.office365.com (2603:10b6:408:fe::35) 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 12:20:11 +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 BN8NAM11FT054.mail.protection.outlook.com (10.13.177.102) 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 12:20:11 +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 12:20:08 +0000 From: Haifei Luo To: , , , , Xiaoyun Li CC: , , Date: Wed, 12 May 2021 15:19:50 +0300 Message-ID: <20210512121950.30446-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: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f452dc2a-5070-4c7a-61cb-08d915404a54 X-MS-TrafficTypeDiagnostic: DM6PR12MB5520: 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: NJ9yKlyBYE6GoRLViLtkGDlP4mqC0uaqj4/8nlYQp8Iu3Y4b7u9honM6YTKyZmCms31dyxlyY+qh5ZNkC0imNK1lLq5OxPiRL7DuMsQsn+lYjCSHJLrrvOmIRq1McPTUmQdU4dQ4GkxzEN3Vuf48nFKdTy7rqB0t79bQAuz2fKXymSbP9ykU7AnBZMelreml+3g84ElI527dYre3bIfgNCMZUpdOtJ4oQpWTAGE7S9SAc0AnAlontKAOb/Ne1jYag9Ohg9W7Grio1gjdfhgplE3WtNr75LoX+xCEN4d/W5BYNWyWJfuG0o7OtbZaJAyrXeEmEym+/e+kbKa65BbNQDjvBS0aiW+Aas0EyDlVP+cAlJ7UfjVMzCGTZn0Yd8UERVdCJEzkCU7OrLaymCvCNtEA8W0H0UljI/EpoGKePLbIe7eK6B5NRYKrJtJ86SocEHaTYWMca7IgDDLrbsz7rqNq1QeSfmuYjioeOBCg6FIskLyV7/nlB1EvdTAqm1IxXvjH2hDzUKZvrpR2/8asZu5gDn3Ea8RiIR0SYSOFeyVPxm7T20sRmb3/cromvxEqYzDlJCwNysFPhS3LSP3KDg7i0RPS1Nuh0Mbe9TnfgEb9KQ4azUhcftUCAgioxRw4aTtx01/0kbKlw/WOCbLQ2nHoKbF/IRGZOMeuXv29bgI= 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)(346002)(396003)(136003)(376002)(39860400002)(46966006)(36840700001)(478600001)(1076003)(26005)(356005)(8936002)(82740400003)(70586007)(83380400001)(7696005)(70206006)(47076005)(82310400003)(7636003)(8676002)(336012)(110136005)(5660300002)(54906003)(2906002)(107886003)(426003)(6286002)(6666004)(186003)(86362001)(4326008)(36756003)(16526019)(36906005)(36860700001)(316002)(2616005)(55016002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 12:20:11.6931 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f452dc2a-5070-4c7a-61cb-08d915404a54 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: BN8NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB5520 Subject: [dpdk-dev] [PATCH v5] 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. V5: fix indentation warning. 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 | 24 ++++++++ 3 files changed, 112 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..f0eeff6 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,26 @@ 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 -------------- -- 1.8.3.1