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 0060D41BAE; Thu, 2 Feb 2023 12:19:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8CD2F406A2; Thu, 2 Feb 2023 12:19:58 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2083.outbound.protection.outlook.com [40.107.220.83]) by mails.dpdk.org (Postfix) with ESMTP id 8ECC240689 for ; Thu, 2 Feb 2023 12:19:56 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ln2qTN2fxCOHifnCep2qh0tX9ACkHOABdBOSlxu+WVj/6nJOQc38uPg5u+Kc4Ncq6t9M7Fiy0sl3/hC5F9e33pl0djNnFxp+jHPQtroZyLiB020imPXm1yg6gdlXtqF5bR7v2W6MT0utvuROu32o/fWgaSUINCrfl2DSkPWaeRf+ZY2VtSvlJMNsfxHI3U71AJwzA8gPSkpAG+zlNhv++mCZLbL11gAJBP0z822fsco8CJGcxx7RhjjDPdvDxFH7nUvYb+o8IcgPZkwNCyAIjU9ThgU5ou4PK/HDLlk4tRNl7XHwNfkFmr0CQnft41sbqkq27/jYigvNfxkUEutcdA== 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=s/FIv1uuhu6MyeJrzZmAjNEKbmslkt8ue0EINPF7aAg=; b=NDfNFQZSgJ1vj3iKU4yRkPv3ur59BghYHtfG1btPXHsLDNNgw29lBkcogpz//zkV1KdrOux30vuxvoWWI2rG9BAYUFjQljalbTDb31ffb9dlhGOlIzOSZxNcPI1Ze7LIQIwLb3OgThFxqFLzDVEIfg74b2pMo8EqhRxe4kPi3PbXKXAcgxNFPH3Q/4iW7ETfvn0k/gqWr6ObRDGrPhO8ZCVkPnw3ZaZ9Z+m6YCEombZdV04Exo/RB+9YuZuZjbGhtnNmczGXKiRV9obRgu3896JqLS+tO/dxuLN4tGrtGCMzmIsWezV1KsYPPrF5jmGi2m65kaTg6+WmWRh9nfugbw== 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=s/FIv1uuhu6MyeJrzZmAjNEKbmslkt8ue0EINPF7aAg=; b=rb9pojh1lzZAYYIQKo6zaQHsmltI76dMoaYEufD2vJKj+afig1r6peN0nj6/hD1CHs9KIsPqu7Uc+eE2Gtxr3me57yKVJemq0AMXNB41t4Mn3kz99hhf+pnEKbg269wZ1euJI95q9VSdLPT4V9etfPTp99rseHEoOBi1SjxibZlTnd18xbPV1OWXnshgb3XIgXJwhc6p7BE7Q9RCKiZih+5WHTFjRzcYSLiy2u1p+7h0tOKTl9neySQn94zI11E9h08EAANRlDHwNQys6riu6ITRQQyiXB2uj3xbOnD/R1lDPP2ax7GySEiWZjz/xbJXdCYPoW/TKqlq9hshACojJQ== Received: from MW4PR03CA0348.namprd03.prod.outlook.com (2603:10b6:303:dc::23) by MN6PR12MB8567.namprd12.prod.outlook.com (2603:10b6:208:478::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 11:19:54 +0000 Received: from CO1NAM11FT065.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::f2) by MW4PR03CA0348.outlook.office365.com (2603:10b6:303:dc::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27 via Frontend Transport; Thu, 2 Feb 2023 11:19:54 +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 CO1NAM11FT065.mail.protection.outlook.com (10.13.174.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27 via Frontend Transport; Thu, 2 Feb 2023 11:19:53 +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.36; Thu, 2 Feb 2023 03:19:43 -0800 Received: from nvidia.com (10.126.230.37) 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.36; Thu, 2 Feb 2023 03:19:40 -0800 From: Rongwei Liu To: , , , , CC: , Aman Singh , Yuying Zhang , Ferruh Yigit , "Andrew Rybchenko" Subject: [PATCH v8] ethdev: add optimization hints in flow template table Date: Thu, 2 Feb 2023 13:19:27 +0200 Message-ID: <20230202111927.2450863-1-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221114115946.1074787-1-rongweil@nvidia.com> References: <20221114115946.1074787-1-rongweil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT065:EE_|MN6PR12MB8567:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f49c2ad-48b5-443d-6a1d-08db050f689f 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: l4FmK3NM4cXIhHfmmB1hzWxLI/PBLZwxSqvyyYy8TS1IJydrOYC0mjMxhJjM32H3vrN+mu3cKf1hsvHAKSJzKdvO1yl8m7RL3g6qPeQVUJqc94WbCNQH56lrV4A5qeBQxmWj03m1jBWv2y9ZaX2eyNNQe+i0seJUXNhDX4y6OzvT4hTPElGiijyStnmSGG+jAIuE7B9+kfxsI5a/ok1Z0yI9rOW1P9oV9Q3+oZ0RzzNQRtITY4hTURm10/H+261+LOA2LIYWHWI4LiOfKekDMs5CB94FCkxFCSiAr0JFWW6/eIk8iww7WJXIVFYw7M8A8z33zHGqx5QxdX2J6SXwZoJ84AcnfOWKRTk/CMXAaopG/cZqCjWt3oV3X3Y9YUqSwVK3m6QJ7nj9uRdIhHOnJFgMZ28veTosgK12ELEDY8xiWqzAAXVU7v9sMyLIP7Qo8Bo32nD+NinR4dQI4QRotsSz2Q03ULDGXrIVIYwCdkwdHQIUuN2XPif6SbugEdkV06YSkA2Fx9xwpcLIzKo8mZDVxRmBeF1zbK3Ls5aLZdbiAFJaYIETKv9AZOgAxYIpe8al4v84IuqE8X+GshAokLBEZYX6atw4PYnZ5eHVv0ZS5dGYGJF81wiAyUmUDndhV5p1VGgowCyPky1mW9l8dOtPKE3N1LtfvDaKWPhh9Z1q1ma31jas52GIuxx4ZGbECT0lg8AvDn3F1SXXMUywjw== 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:(13230025)(4636009)(136003)(376002)(396003)(39860400002)(346002)(451199018)(36840700001)(46966006)(40470700004)(2906002)(36756003)(336012)(82310400005)(54906003)(83380400001)(426003)(6666004)(316002)(47076005)(66899018)(1076003)(186003)(7696005)(478600001)(40460700003)(26005)(6286002)(70206006)(70586007)(356005)(55016003)(8936002)(4326008)(8676002)(41300700001)(40480700001)(86362001)(36860700001)(5660300002)(16526019)(82740400003)(7636003)(110136005)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 11:19:53.9577 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f49c2ad-48b5-443d-6a1d-08db050f689f 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: CO1NAM11FT065.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8567 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 In case flow rules match only one kind of traffic in a flow table, then optimization can be done via allocation of this table. Such optimization is possible only if the application gives a hint about its usage of the table during initial configuration. The transfer domain rules may process traffic from wire or vport, which may correspond to two kinds of underlayer resources. That's why the first two hints introduced in this patch are about wire and vport traffic specialization. Wire means traffic arrives from the uplink port while vport means traffic initiated from VF/SF. There are two possible approaches for providing the hints. Using IPv4 as an example: 1. Use pattern item in both flow template table and rules. template table 3 = transfer pattern ANY_VPORT / eth / ipv4 src is 255.255.255.255 / end flow rule = template_table 3 pattern ANY_VPORT / eth / ipv4 src is 1.1.1.1 / end The pattern template 3 will be used only to match flows coming from vports. ANY_VPORT needs to be present in each flow rule. ANY_VPORT matching is redundant with IP src 1.1.1.1 because the user knows 1.1.1.1 is the IP of a vport. 2. Add specialization flag into flow template table attribute: template table 3 = transfer VPORT_ORIG pattern eth / ipv4 src is 255.255.255.255 / end flow rule = template_table 3 pattern eth / ipv4 src is 1.1.1.1 / end The pattern template 3 can be used only to match flows coming from vports. Approach 1 needs to specify the hint in each flow rule that wastes memory and is not user friendly. This patch takes the 2nd approach and introduces one new member "specialize" into rte_flow_table_attr to indicate possible flow table optimization. By default, there is no hint, so nothing change. There is no guarantee that the hints will be effective in the driver. The application functionality must not rely on the hints. Signed-off-by: Rongwei Liu Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 26 ++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 17 +++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 3 +- lib/ethdev/rte_flow.h | 33 +++++++++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 88108498e0..62197f2618 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -184,6 +184,8 @@ enum index { TABLE_INGRESS, TABLE_EGRESS, TABLE_TRANSFER, + TABLE_TRANSFER_WIRE_ORIG, + TABLE_TRANSFER_VPORT_ORIG, TABLE_RULES_NUMBER, TABLE_PATTERN_TEMPLATE, TABLE_ACTIONS_TEMPLATE, @@ -1158,6 +1160,8 @@ static const enum index next_table_attr[] = { TABLE_INGRESS, TABLE_EGRESS, TABLE_TRANSFER, + TABLE_TRANSFER_WIRE_ORIG, + TABLE_TRANSFER_VPORT_ORIG, TABLE_RULES_NUMBER, TABLE_PATTERN_TEMPLATE, TABLE_ACTIONS_TEMPLATE, @@ -2933,6 +2937,18 @@ static const struct token token_list[] = { .next = NEXT(next_table_attr), .call = parse_table, }, + [TABLE_TRANSFER_WIRE_ORIG] = { + .name = "wire_orig", + .help = "affect rule direction to transfer", + .next = NEXT(next_table_attr), + .call = parse_table, + }, + [TABLE_TRANSFER_VPORT_ORIG] = { + .name = "vport_orig", + .help = "affect rule direction to transfer", + .next = NEXT(next_table_attr), + .call = parse_table, + }, [TABLE_RULES_NUMBER] = { .name = "rules_number", .help = "number of rules in table", @@ -8993,6 +9009,16 @@ parse_table(struct context *ctx, const struct token *token, case TABLE_TRANSFER: out->args.table.attr.flow_attr.transfer = 1; return len; + case TABLE_TRANSFER_WIRE_ORIG: + if (!out->args.table.attr.flow_attr.transfer) + return -1; + out->args.table.attr.specialize = RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG; + return len; + case TABLE_TRANSFER_VPORT_ORIG: + if (!out->args.table.attr.flow_attr.transfer) + return -1; + out->args.table.attr.specialize = RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG; + return len; default: return -1; } diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 3e6242803d..b4338c216e 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -3605,6 +3605,23 @@ and pattern and actions templates are created. &actions_templates, nb_actions_templ, &error); +Table Attribute: Specialize +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Application can help optimizing underlayer resources and insertion rate +by specializing template table. +Specialization is done by providing hints +in the template table attribute ``specialize``. + +This attribute is not mandatory for driver to implement. +If a hint is not supported, it will be silently ignored, +and no special optimization is done. + +If a table is specialized, the application should make sure the rules +comply with the table attribute. +The application functionality must not rely on the hints, +they are not replacing the matching criteria of flow rules. + Asynchronous operations ----------------------- diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 0037506a79..bf75df73ed 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3146,7 +3146,8 @@ It is bound to ``rte_flow_template_table_create()``:: flow template_table {port_id} create [table_id {id}] [group {group_id}] - [priority {level}] [ingress] [egress] [transfer] + [priority {level}] [ingress] [egress] + [transfer [vport_orig] [wire_orig]] rules_number {number} pattern_template {pattern_template_id} actions_template {actions_template_id} diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index b60987db4b..cb6c5b159d 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -5187,6 +5187,30 @@ rte_flow_actions_template_destroy(uint16_t port_id, */ struct rte_flow_template_table; +/**@{@name Flags for template table attribute. + * Each bit is an optional hint for table specialization, + * offering a potential optimization at driver layer. + * The driver can ignore the hints silently. + * The hints do not replace any matching criteria. + */ +/** + * Specialize table for transfer flows which come only from wire. + * It allows PMD not to allocate resources for non-wire originated traffic. + * This bit is not a matching criteria, just an optimization hint. + * Flow rules which match non-wire originated traffic will be missed + * if the hint is supported. + */ +#define RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG RTE_BIT32(0) +/** + * Specialize table for transfer flows which come only from vport (e.g. VF, SF). + * It allows PMD not to allocate resources for non-vport originated traffic. + * This bit is not a matching criteria, just an optimization hint. + * Flow rules which match non-vport originated traffic will be missed + * if the hint is supported. + */ +#define RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG RTE_BIT32(1) +/**@}*/ + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice. @@ -5202,6 +5226,15 @@ struct rte_flow_template_table_attr { * Maximum number of flow rules that this table holds. */ uint32_t nb_flows; + /** + * Optional hint flags for driver optimization. + * The effect may vary in the different drivers. + * The functionality must not rely on the hints. + * Value is composed with RTE_FLOW_TABLE_SPECIALIZE_* based on application + * design choices. + * Misused hints may mislead the driver, it may result in an undefined behavior. + */ + uint32_t specialize; }; /** -- 2.27.0