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 1906DA034C; Wed, 21 Sep 2022 04:13:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2630E42B81; Wed, 21 Sep 2022 04:12:45 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2083.outbound.protection.outlook.com [40.107.223.83]) by mails.dpdk.org (Postfix) with ESMTP id EBCA241181 for ; Wed, 21 Sep 2022 04:12:42 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mq+htiIGUl2pNjnSlzBfczlJyaTomsVrnB0Fvzvn8YQmKy8TPmFza0fufQoEPM8qCvWIN0lpm/lH4wJyQekSm9dQk9iYzyuEAPwD8CdCZLxT2zDUfXARvmV6ZiijQo/QYKqWxce29Hyp+mocjnJ3tTlmUm+44AVoRfvnxTXsFh+Ma0RSm+2enKsyo0+IlGRSvMxmFQVXlslE0tcJcVfb1ulbugxaIdYxv7xczE6xCWkqCk+IyM98xiE7WMpdvQ7WO8ii/L4hwqk35JiaD28AVUGliKCnQuYKM3nKuxozQnGm7e2WZ+vUoS0T6VkKxwbxxW3NVGB8S9ecQvD8r3n9eA== 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=Tlbwzg4b+mXnItlNGKHtW791O/l/0E+tzomDI+4xGdI=; b=FiFFMar6SC5GeH60tRzYuz++StUhwcBE/HIEf4bhCEs1xYIaj2VHnIJ32SYw3ODq4e4q6p4Btao4gPLqhSn95HwZp/nL2g8smIZFh6LdcFN6YLuW/B4b41v7ubYyIBXO8yh/fB/lzJUYimxh8ue8nWJ5Etqrhd2mHmdrlvi0QYOuO0Lyzdl3RwGhj7y8dq8SQZ1UdoXiaak0sS7LJpJyn6m+y+b4twIcpLKhXnJ4nyMvFo12ognEVpPkdVMqAiFYyP51Yui+zvdi59DH/qBK/NoXVqEF3OkAUBXSiiRVEHsD1xm4sj5CzAQI2Snj/SMIkjnuTZIwHieyFKDgpMpDaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=Tlbwzg4b+mXnItlNGKHtW791O/l/0E+tzomDI+4xGdI=; b=CRRDHeXgaNQRJzev0TsqM24DCscuyYgtRkJJ7gBZeG+4/aTt0gmsTgwG1jAKrlLD7+DApVS+2NXD0+qbrDE7DB/XHYyBobmiUGoz2AnHmhzHp8u7rmt+K7Cqe7FaDKFxx99HcZV3OgoOCu7xP1cbvj7KYEIg2+M2KHqZ7I+VIVF/p+BHAv8VVv8ywFzmnYvbvC6KfPq1f0LO9i8wCbc+Ay6zGlkVVnJPVaWXXAaIvMA1Nxd1PvdhpSa1Lau/pS/QQvh/B4cUjL7j6otPlsGAY5GEJ2ANi2NQZVlX4aIXXRtunt+lBe2l4OAejK2aq/qOdou3ta9YEuShZXTPwgSA7Q== Received: from MW2PR16CA0004.namprd16.prod.outlook.com (2603:10b6:907::17) by SA1PR12MB6917.namprd12.prod.outlook.com (2603:10b6:806:24c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14; Wed, 21 Sep 2022 02:12:41 +0000 Received: from CO1NAM11FT024.eop-nam11.prod.protection.outlook.com (2603:10b6:907:0:cafe::e8) by MW2PR16CA0004.outlook.office365.com (2603:10b6:907::17) 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:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT024.mail.protection.outlook.com (10.13.174.162) 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:40 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) 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:28 -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:24 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v4 7/7] app/testpmd: add meter color mark flow action Date: Wed, 21 Sep 2022 05:11:33 +0300 Message-ID: <20220921021133.2982954-8-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: CO1NAM11FT024:EE_|SA1PR12MB6917:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ff06b97-1585-43a5-389e-08da9b76c331 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: Nkdj41+Adt4tBZTIo8Btu/sDsHS/LAntV1NDH0aFjSNN4FnXgELtwvMixEB/J16BXEDsZvC/RIjRlfJdQJOv5a9s8A248qM+Bx2cdlz+XSm5b0emKYVd1ltSufVpWtBK2Xv39XPfybMWkadINTZ0MntPid2ai1muWNqgsLwQnXJRrk0drg5pReXvaLWrQ0d/fQbxsnQl9N8jxbf0GfSAf83cfBbCshAcZfUQJbkPlEHeibX1lJnhS5lU+zF3ekizlVpT9w+2FWOzjb/PniFN+qPMEdhAXpgQgT4AaRWhFAMOau5KnaXGAU1QIJ68DkYsMDaCC2i7lxZ5bG8bn+ryZYjc9p8L5besCOC/4zRzgbz9tccJcdwBfODS6i4R7SMHDkEHN9dxTXiZGxge5BbaRdMn5qPJwKnIPPMjEOGBkHjyrDKHZHZiTYdMVF2DevxNVJSIWuitFp6kWJ+Ra8xeXmcHAmDF05uHSAmi9LQalzo/Hq6le8pzSRaxGddJYBZTtrj39TAtWVC/Pw4bjtPyBVpCW5MT5o45IH7OBAA1H5vj1XsF3Ae+O6r4HLt6qn92acjgO2ILqWZUpRhz52Uwrv8gTM+eSqZd/LD2s5dUiS11tlIV4VZ9ev0JsxrGI6hp6tiWgARxUYLJxxrMP2ag10pt5oCTq9/bJ8EzQM4zqSjXYkM4BieHCyV5UFjOoCLPO7eCHWepFwVMlaUyMx6SRVXQt241CyvSIGZriecEneLVQWByPU+zSVih6/rY64IcCkgjr17vjPT/wA+azJ/MfQ== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(376002)(136003)(39860400002)(346002)(396003)(451199015)(36840700001)(46966006)(40470700004)(186003)(1076003)(47076005)(426003)(336012)(16526019)(2616005)(83380400001)(82310400005)(26005)(36860700001)(7416002)(6666004)(86362001)(4326008)(8676002)(40460700003)(70206006)(54906003)(6916009)(316002)(82740400003)(2906002)(5660300002)(478600001)(8936002)(70586007)(40480700001)(356005)(7636003)(36756003)(41300700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2022 02:12:40.8013 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ff06b97-1585-43a5-389e-08da9b76c331 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT024.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6917 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 for METER_MARK action: flow create ... actions meter_mark mtr_profile 20 / end Signed-off-by: Alexander Kozyrev --- app/test-pmd/cmdline_flow.c | 127 ++++++++++++++++++++ app/test-pmd/config.c | 26 ++++ app/test-pmd/testpmd.h | 4 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 + 4 files changed, 162 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index e6f4bdf3b2..dd837e27f7 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -53,6 +53,7 @@ enum index { COMMON_GROUP_ID, COMMON_PRIORITY_LEVEL, COMMON_INDIRECT_ACTION_ID, + COMMON_PROFILE_ID, COMMON_POLICY_ID, COMMON_FLEX_HANDLE, COMMON_FLEX_TOKEN, @@ -508,6 +509,11 @@ enum index { ACTION_METER_COLOR_YELLOW, ACTION_METER_COLOR_RED, ACTION_METER_ID, + ACTION_METER_MARK, + ACTION_METER_PROFILE, + ACTION_METER_PROFILE_ID2PTR, + ACTION_METER_POLICY, + ACTION_METER_POLICY_ID2PTR, ACTION_OF_SET_MPLS_TTL, ACTION_OF_SET_MPLS_TTL_MPLS_TTL, ACTION_OF_DEC_MPLS_TTL, @@ -1835,6 +1841,7 @@ static const enum index next_action[] = { ACTION_PORT_ID, ACTION_METER, ACTION_METER_COLOR, + ACTION_METER_MARK, ACTION_OF_SET_MPLS_TTL, ACTION_OF_DEC_MPLS_TTL, ACTION_OF_SET_NW_TTL, @@ -1951,6 +1958,13 @@ static const enum index action_meter_color[] = { ZERO, }; +static const enum index action_meter_mark[] = { + ACTION_METER_PROFILE, + ACTION_METER_POLICY, + ACTION_NEXT, + ZERO, +}; + static const enum index action_of_set_mpls_ttl[] = { ACTION_OF_SET_MPLS_TTL_MPLS_TTL, ACTION_NEXT, @@ -2389,6 +2403,14 @@ static int parse_mp(struct context *, const struct token *, 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 parse_meter_profile_id2ptr(struct context *ctx, + const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size); +static int parse_meter_policy_id2ptr(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 *, @@ -2550,6 +2572,13 @@ static const struct token token_list[] = { .call = parse_int, .comp = comp_none, }, + [COMMON_PROFILE_ID] = { + .name = "{profile_id}", + .type = "PROFILE_ID", + .help = "profile id", + .call = parse_int, + .comp = comp_none, + }, [COMMON_POLICY_ID] = { .name = "{policy_id}", .type = "POLICY_ID", @@ -5428,6 +5457,42 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)), .call = parse_vc_conf, }, + [ACTION_METER_MARK] = { + .name = "meter_mark", + .help = "meter the directed packets using profile and policy", + .priv = PRIV_ACTION(METER_MARK, + sizeof(struct rte_flow_action_meter_mark)), + .next = NEXT(action_meter_mark), + .call = parse_vc, + }, + [ACTION_METER_PROFILE] = { + .name = "mtr_profile", + .help = "meter profile id to use", + .next = NEXT(NEXT_ENTRY(ACTION_METER_PROFILE_ID2PTR)), + .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))), + }, + [ACTION_METER_PROFILE_ID2PTR] = { + .name = "{mtr_profile_id}", + .type = "PROFILE_ID", + .help = "meter profile id", + .next = NEXT(action_meter_mark), + .call = parse_meter_profile_id2ptr, + .comp = comp_none, + }, + [ACTION_METER_POLICY] = { + .name = "mtr_policy", + .help = "meter policy id to use", + .next = NEXT(NEXT_ENTRY(ACTION_METER_POLICY_ID2PTR)), + ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))), + }, + [ACTION_METER_POLICY_ID2PTR] = { + .name = "{mtr_policy_id}", + .type = "POLICY_ID", + .help = "meter policy id", + .next = NEXT(action_meter_mark), + .call = parse_meter_policy_id2ptr, + .comp = comp_none, + }, [ACTION_OF_SET_MPLS_TTL] = { .name = "of_set_mpls_ttl", .help = "OpenFlow's OFPAT_SET_MPLS_TTL", @@ -9747,6 +9812,68 @@ parse_ia_id2ptr(struct context *ctx, const struct token *token, return ret; } +static int +parse_meter_profile_id2ptr(struct context *ctx, const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size) +{ + struct rte_flow_action *action = ctx->object; + struct rte_flow_action_meter_mark *meter; + struct rte_flow_meter_profile *profile = NULL; + uint32_t id; + int ret; + + (void)buf; + (void)size; + ctx->objdata = 0; + ctx->object = &id; + ctx->objmask = NULL; + ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id)); + ctx->object = action; + if (ret != (int)len) + return ret; + /* set meter profile */ + if (action) { + meter = (struct rte_flow_action_meter_mark *) + (uintptr_t)(action->conf); + profile = port_meter_profile_get_by_id(ctx->port, id); + meter->profile = profile; + ret = (profile) ? ret : -1; + } + return ret; +} + +static int +parse_meter_policy_id2ptr(struct context *ctx, const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size) +{ + struct rte_flow_action *action = ctx->object; + struct rte_flow_action_meter_mark *meter; + struct rte_flow_meter_policy *policy = NULL; + uint32_t id; + int ret; + + (void)buf; + (void)size; + ctx->objdata = 0; + ctx->object = &id; + ctx->objmask = NULL; + ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id)); + ctx->object = action; + if (ret != (int)len) + return ret; + /* set meter policy */ + if (action) { + meter = (struct rte_flow_action_meter_mark *) + (uintptr_t)(action->conf); + policy = port_meter_policy_get_by_id(ctx->port, id); + meter->policy = policy; + ret = (policy) ? ret : -1; + } + return ret; +} + /** Parse set command, initialize output buffer for subsequent tokens. */ static int parse_set_raw_encap_decap(struct context *ctx, const struct token *token, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a2939867c4..6f82bd783c 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2316,6 +2316,32 @@ port_meter_policy_add(portid_t port_id, uint32_t policy_id, return ret; } +/** Get port meter profile */ +struct rte_flow_meter_profile * +port_meter_profile_get_by_id(portid_t port_id, uint32_t id) +{ + struct rte_mtr_error error; + struct rte_flow_meter_profile *profile; + + profile = rte_mtr_meter_profile_get(port_id, id, &error); + if (!profile) + print_mtr_err_msg(&error); + return profile; +} + +/** Get port meter policy */ +struct rte_flow_meter_policy * +port_meter_policy_get_by_id(portid_t port_id, uint32_t id) +{ + struct rte_mtr_error error; + struct rte_flow_meter_policy *policy; + + policy = rte_mtr_meter_policy_get(port_id, id, &error); + if (!policy) + print_mtr_err_msg(&error); + return policy; +} + /** Validate flow rule. */ int port_flow_validate(portid_t port_id, diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index fb2f5195d3..ac1e1b7d22 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -1013,6 +1013,10 @@ void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops *ops); int port_flow_isolate(portid_t port_id, int set); int port_meter_policy_add(portid_t port_id, uint32_t policy_id, const struct rte_flow_action *actions); +struct rte_flow_meter_profile *port_meter_profile_get_by_id(portid_t port_id, + uint32_t id); +struct rte_flow_meter_policy *port_meter_policy_get_by_id(portid_t port_id, + uint32_t id); void rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id); void tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id); diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 150cfc0664..cf09dc5aef 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -4193,6 +4193,11 @@ This section lists supported actions and their attributes, if any. - ``ethdev_port_id {unsigned}``: ethdev port ID +- ``meter_mark``: meter the directed packets using profile and policy + + - ``mtr_profile {unsigned}``: meter profile id to use + - ``mtr_policy {unsigned}``: meter policy id to use + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ -- 2.18.2