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 4D676438CD; Mon, 15 Jan 2024 10:14:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8065E406A2; Mon, 15 Jan 2024 10:14:07 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by mails.dpdk.org (Postfix) with ESMTP id DE80640649 for ; Mon, 15 Jan 2024 10:14:04 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WIPvTKPA0ovD7YVNqpLGpjC7kJfD/jEL+/Eod1BcMazKaHLJvODJpZco8hnIg0LI+MA1livsYp4PAdkd9aUvQe9LffXTpmw9Hv1B/wbCyAFllH9+w8nN2bWg37ZW4Pp1Ul1xon0vYdklwW51ITr4NspaHGsY9IoeC1KeaQ50Pk7NKms9uHt8F1G5Rx9U37EWFPuwvyPJHM0nhpBRHiIYlGallPGGBFgnKR059wqFSEz0zp81k08f64NCvmnXlvM3ZegV8XmM6MByBBbrbNoPvlbJ6rML4g0UOpMbwYoMRz7mTy0yIsiS1WiieN/QcSIDWv+dYX+NUxi1/O2DLUm5nw== 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=lgRFqKAILlax1fAuz05CZF2YfcnqTCB3faasAC+8zKs=; b=bWIVk+5CjQEnKpRi1f+PgcjlAeJnU9fybzknx10xhiYTVL81jk1Qyeyl/UzRwD5qtHACPivbs0N1E5his21OEB48pDx8TIaO5hJwXtZ9+hl3IjDq5zEhh3tV0HvgLxNtQkZWq6Wiu1I0fCyWbFxD+7QDEzsiPyx4fPaw8vGJnP+BPYLKRfSeltlhd4xZtKYJrP6ZlL1BkWHywk4VmX/0Sql81x5ICk99o5nRQF6NpFluIwM9Wx9yvmaDsWV0sumD+sPj7PRgkaWVtUOh1aF83ZPQlw9yOet4khMc9BKKUcgsRUaRQgEmsxVNqQ2UbwemXRJBmvb1aP/yyH+Eykw4vA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=intel.com 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 (0) 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=lgRFqKAILlax1fAuz05CZF2YfcnqTCB3faasAC+8zKs=; b=rPd4g7HuhvnCsaMw4G+mhP5tSv0TsIFFruL80+XO1m+kiX9tjvajFpV8SWE0L580btvib0BOg8euzo6nSzqqHKXVjmI5v1DC/84px2LCNd1qADaVO+Y7BtezkkbTRW2dRdZlNRR5DD3WEBwSEXuvkhJM13F2FESTX2PB22dhUtGFVpYKm2f2yT3+PUWQWGvQq15m7NBlh+0uosup1p73/ZPRYgfZkz04wndwyUhg4CKtql7M/QVE4sdBfDYmB2K+oG8OJjM8WxJg3MEz3k4aN+Ip1YJ5ddVUSwYiISZCUh5iUc75BJg6vgroetk8TX/lJRjz56/UDvT8EYJa5PfoVg== Received: from SJ0PR03CA0204.namprd03.prod.outlook.com (2603:10b6:a03:2ef::29) by IA0PR12MB8373.namprd12.prod.outlook.com (2603:10b6:208:40d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.23; Mon, 15 Jan 2024 09:13:58 +0000 Received: from SJ1PEPF00001CE5.namprd03.prod.outlook.com (2603:10b6:a03:2ef:cafe::5f) by SJ0PR03CA0204.outlook.office365.com (2603:10b6:a03:2ef::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.26 via Frontend Transport; Mon, 15 Jan 2024 09:13:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF00001CE5.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Mon, 15 Jan 2024 09:13:57 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 15 Jan 2024 01:13:44 -0800 Received: from nvidia.com (10.126.230.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.41; Mon, 15 Jan 2024 01:13:40 -0800 From: Suanming Mou To: , Aman Singh , Yuying Zhang , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: Subject: [PATCH v3 2/3] ethdev: add compare item Date: Mon, 15 Jan 2024 17:13:17 +0800 Message-ID: <20240115091318.1053433-3-suanmingm@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240115091318.1053433-1-suanmingm@nvidia.com> References: <20231219013337.531548-1-suanmingm@nvidia.com> <20240115091318.1053433-1-suanmingm@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] 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: SJ1PEPF00001CE5:EE_|IA0PR12MB8373:EE_ X-MS-Office365-Filtering-Correlation-Id: 298f75a1-af71-48d0-60fa-08dc15aa4e04 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: Wv+iB0LZE0vBrzbkvCkc8iB9JX5Fdw5YwJwKaiQOXZl4PE2U8fE8X1MB5tFxoqlBiOudi/RhYv8zFmBOCoB7Nw7ptC4XGRNL4/TDr5sWFXoMPvn0aDLLXJOyLnL/9JUVmtdSZSsl0D0QKjRG/beZc8CuDE9m+H63EiUgtn5P1UGNVYaBYVV7Dw1qKq/+enI7atIs2dB+livV/IVpjLDs2/nbz1Zs7V1mAgERrdin+zcIHS25de3sBrxC03lpROO1DwTdidT/HsmHTu6Z4K8h48xrWD1h6bVqn8B8xSHC7XwnW8n7zIE0fG2kD4OBM3lHGs5PUwAz3x8/d76uROlVDhK2rDyO3Y31rSX7Z1+8dcYhdpGWIAsFjSMKDWs54W8bVcngSE1Y6hc7srnSygJKu5dPg35bnCUOnwt8lAE244jSQNNmooEaRS1A5Wn68/Ju4d62cnW1cPJ2IpyAl7I1CBfhzIW58f0UUgSxsEilHFTgJA5qc0VQKL12DpFN7YBoBxe/qEIu+yUi/8Fw9UsiUxkAaBB3ZKlqUjWpqAYoEi56JOjAWKJ5F0xMF54l6s1Kv27hMrDWtXeottnb+PowchBiuwL4lj2bPz7jW9HSYURGhagHJCYDiiYfwDWn8mSkSo75QdLw4awYQIkVpnxcbtU7aJABE7hvSphTAk7+tnm3NFvUqYE032dwXx9gMKs0uC0FtAZ63b4/iKn5TZBrENjHMN9Nw0jCcVoYMA5bdvQGF0NxvI0V47wlTVLYQl4E16uGP19iONPUjvgJ4QVOlT6oNAdb1ygeZR+VBqGOgFT+gHk61/Yd/iSDUjmiKYr1 X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(396003)(376002)(346002)(39860400002)(136003)(230273577357003)(230173577357003)(230922051799003)(451199024)(64100799003)(186009)(82310400011)(1800799012)(36840700001)(40470700004)(46966006)(40480700001)(55016003)(40460700003)(83380400001)(426003)(336012)(41300700001)(70206006)(70586007)(86362001)(316002)(7636003)(356005)(36756003)(82740400003)(36860700001)(5660300002)(47076005)(7696005)(1076003)(2616005)(110136005)(6286002)(478600001)(26005)(16526019)(30864003)(2906002)(8676002)(4326008)(6666004)(8936002)(21314003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2024 09:13:57.6051 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 298f75a1-af71-48d0-60fa-08dc15aa4e04 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.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CE5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8373 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 The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value. e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not. The supported operations can be as below: - RTE_FLOW_ITEM_COMPARE_EQ (equal) - RTE_FLOW_ITEM_COMPARE_NE (not equal) - RTE_FLOW_ITEM_COMPARE_LT (less than) - RTE_FLOW_ITEM_COMPARE_LE (less than or equal) - RTE_FLOW_ITEM_COMPARE_GT (great than) - RTE_FLOW_ITEM_COMPARE_GE (great than or equal) Signed-off-by: Suanming Mou Acked-by: Ori Kam Acked-by: Andrew Rybchenko --- app/test-pmd/cmdline_flow.c | 414 +++++++++++++++++++- doc/guides/nics/features/default.ini | 1 + doc/guides/prog_guide/rte_flow.rst | 7 + doc/guides/rel_notes/release_24_03.rst | 5 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 + lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 322 ++++++++------- 7 files changed, 603 insertions(+), 154 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 3725e955c7..4f448ff8ec 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -543,6 +543,28 @@ enum index { ITEM_PTYPE, ITEM_PTYPE_VALUE, ITEM_NSH, + ITEM_COMPARE, + ITEM_COMPARE_OP, + ITEM_COMPARE_OP_VALUE, + ITEM_COMPARE_FIELD_A_TYPE, + ITEM_COMPARE_FIELD_A_TYPE_VALUE, + ITEM_COMPARE_FIELD_A_LEVEL, + ITEM_COMPARE_FIELD_A_LEVEL_VALUE, + ITEM_COMPARE_FIELD_A_TAG_INDEX, + ITEM_COMPARE_FIELD_A_TYPE_ID, + ITEM_COMPARE_FIELD_A_CLASS_ID, + ITEM_COMPARE_FIELD_A_OFFSET, + ITEM_COMPARE_FIELD_B_TYPE, + ITEM_COMPARE_FIELD_B_TYPE_VALUE, + ITEM_COMPARE_FIELD_B_LEVEL, + ITEM_COMPARE_FIELD_B_LEVEL_VALUE, + ITEM_COMPARE_FIELD_B_TAG_INDEX, + ITEM_COMPARE_FIELD_B_TYPE_ID, + ITEM_COMPARE_FIELD_B_CLASS_ID, + ITEM_COMPARE_FIELD_B_OFFSET, + ITEM_COMPARE_FIELD_B_VALUE, + ITEM_COMPARE_FIELD_B_POINTER, + ITEM_COMPARE_FIELD_WIDTH, /* Validate/create actions. */ ACTIONS, @@ -740,13 +762,17 @@ enum index { #define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) +static const char *const compare_ops[] = { + "eq", "ne", "lt", "le", "gt", "ge", NULL +}; + /** Maximum size for external pattern in struct rte_flow_field_data. */ -#define ACTION_MODIFY_PATTERN_SIZE 32 +#define FLOW_FIELD_PATTERN_SIZE 32 /** Storage size for struct rte_flow_action_modify_field including pattern. */ #define ACTION_MODIFY_SIZE \ (sizeof(struct rte_flow_action_modify_field) + \ - ACTION_MODIFY_PATTERN_SIZE) + FLOW_FIELD_PATTERN_SIZE) /** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 128 @@ -940,7 +966,7 @@ static const char *const modify_field_ops[] = { "set", "add", "sub", NULL }; -static const char *const modify_field_ids[] = { +static const char *const flow_field_ids[] = { "start", "mac_dst", "mac_src", "vlan_type", "vlan_id", "mac_type", "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst", @@ -1590,6 +1616,7 @@ static const enum index next_item[] = { ITEM_IB_BTH, ITEM_PTYPE, ITEM_NSH, + ITEM_COMPARE, END_SET, ZERO, }; @@ -2121,6 +2148,38 @@ static const enum index item_nsh[] = { ZERO, }; +static const enum index item_compare_field[] = { + ITEM_COMPARE_OP, + ITEM_COMPARE_FIELD_A_TYPE, + ITEM_COMPARE_FIELD_B_TYPE, + ITEM_NEXT, + ZERO, +}; + +static const enum index compare_field_a[] = { + ITEM_COMPARE_FIELD_A_TYPE, + ITEM_COMPARE_FIELD_A_LEVEL, + ITEM_COMPARE_FIELD_A_TAG_INDEX, + ITEM_COMPARE_FIELD_A_TYPE_ID, + ITEM_COMPARE_FIELD_A_CLASS_ID, + ITEM_COMPARE_FIELD_A_OFFSET, + ITEM_COMPARE_FIELD_B_TYPE, + ZERO, +}; + +static const enum index compare_field_b[] = { + ITEM_COMPARE_FIELD_B_TYPE, + ITEM_COMPARE_FIELD_B_LEVEL, + ITEM_COMPARE_FIELD_B_TAG_INDEX, + ITEM_COMPARE_FIELD_B_TYPE_ID, + ITEM_COMPARE_FIELD_B_CLASS_ID, + ITEM_COMPARE_FIELD_B_OFFSET, + ITEM_COMPARE_FIELD_B_VALUE, + ITEM_COMPARE_FIELD_B_POINTER, + ITEM_COMPARE_FIELD_WIDTH, + ZERO, +}; + static const enum index next_action[] = { ACTION_END, ACTION_VOID, @@ -2863,6 +2922,24 @@ comp_quota_update_name(struct context *ctx, const struct token *token, static int comp_qu_mode_name(struct context *ctx, const struct token *token, unsigned int ent, char *buf, unsigned int size); +static int +comp_set_compare_field_id(struct context *ctx, const struct token *token, + unsigned int ent, char *buf, unsigned int size); +static int +comp_set_compare_op(struct context *ctx, const struct token *token, + unsigned int ent, char *buf, unsigned int size); +static int +parse_vc_compare_op(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size); +static int +parse_vc_compare_field_id(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size); +static int +parse_vc_compare_field_level(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size); struct indlst_conf { uint32_t id; @@ -5982,6 +6059,174 @@ static const struct token token_list[] = { .next = NEXT(item_nsh), .call = parse_vc, }, + [ITEM_COMPARE] = { + .name = "compare", + .help = "match with the comparison result", + .priv = PRIV_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), + .next = NEXT(NEXT_ENTRY(ITEM_COMPARE_OP)), + .call = parse_vc, + }, + [ITEM_COMPARE_OP] = { + .name = "op", + .help = "operation type", + .next = NEXT(item_compare_field, + NEXT_ENTRY(ITEM_COMPARE_OP_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, operation)), + }, + [ITEM_COMPARE_OP_VALUE] = { + .name = "{operation}", + .help = "operation type value", + .call = parse_vc_compare_op, + .comp = comp_set_compare_op, + }, + [ITEM_COMPARE_FIELD_A_TYPE] = { + .name = "a_type", + .help = "compared field type", + .next = NEXT(compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.field)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_VALUE] = { + .name = "{a_type}", + .help = "compared field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_A_LEVEL] = { + .name = "a_level", + .help = "compared field level", + .next = NEXT(compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.level)), + }, + [ITEM_COMPARE_FIELD_A_LEVEL_VALUE] = { + .name = "{a_level}", + .help = "compared field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_A_TAG_INDEX] = { + .name = "a_tag_index", + .help = "compared field tag array", + .next = NEXT(compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.tag_index)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_ID] = { + .name = "a_type_id", + .help = "compared field type ID", + .next = NEXT(compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.type)), + }, + [ITEM_COMPARE_FIELD_A_CLASS_ID] = { + .name = "a_class", + .help = "compared field class ID", + .next = NEXT(compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + a.class_id)), + }, + [ITEM_COMPARE_FIELD_A_OFFSET] = { + .name = "a_offset", + .help = "compared field bit offset", + .next = NEXT(compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.offset)), + }, + [ITEM_COMPARE_FIELD_B_TYPE] = { + .name = "b_type", + .help = "comparator field type", + .next = NEXT(compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.field)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_VALUE] = { + .name = "{b_type}", + .help = "comparator field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_B_LEVEL] = { + .name = "b_level", + .help = "comparator field level", + .next = NEXT(compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.level)), + }, + [ITEM_COMPARE_FIELD_B_LEVEL_VALUE] = { + .name = "{b_level}", + .help = "comparator field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_B_TAG_INDEX] = { + .name = "b_tag_index", + .help = "comparator field tag array", + .next = NEXT(compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.tag_index)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_ID] = { + .name = "b_type_id", + .help = "comparator field type ID", + .next = NEXT(compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.type)), + }, + [ITEM_COMPARE_FIELD_B_CLASS_ID] = { + .name = "b_class", + .help = "comparator field class ID", + .next = NEXT(compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + b.class_id)), + }, + [ITEM_COMPARE_FIELD_B_OFFSET] = { + .name = "b_offset", + .help = "comparator field bit offset", + .next = NEXT(compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.offset)), + }, + [ITEM_COMPARE_FIELD_B_VALUE] = { + .name = "b_value", + .help = "comparator immediate value", + .next = NEXT(compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args = ARGS(ARGS_ENTRY_ARB(0, 0), + ARGS_ENTRY_ARB(0, 0), + ARGS_ENTRY(struct rte_flow_item_compare, + b.value)), + }, + [ITEM_COMPARE_FIELD_B_POINTER] = { + .name = "b_ptr", + .help = "pointer to comparator immediate value", + .next = NEXT(compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.pvalue), + ARGS_ENTRY_ARB(0, 0), + ARGS_ENTRY_ARB + (sizeof(struct rte_flow_item_compare), + FLOW_FIELD_PATTERN_SIZE)), + }, + [ITEM_COMPARE_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to compare", + .next = NEXT(item_compare_field, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + width)), + }, /* Validate/create actions. */ [ACTIONS] = { @@ -6961,7 +7206,7 @@ static const struct token token_list[] = { ARGS_ENTRY_ARB(0, 0), ARGS_ENTRY_ARB (sizeof(struct rte_flow_action_modify_field), - ACTION_MODIFY_PATTERN_SIZE)), + FLOW_FIELD_PATTERN_SIZE)), .call = parse_vc_conf, }, [ACTION_MODIFY_FIELD_WIDTH] = { @@ -8404,6 +8649,122 @@ parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token, return len; } +/** Parse operation for compare match item. */ +static int +parse_vc_compare_op(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size) +{ + struct rte_flow_item_compare *compare_item; + unsigned int i; + + (void)token; + (void)buf; + (void)size; + if (ctx->curr != ITEM_COMPARE_OP_VALUE) + return -1; + for (i = 0; compare_ops[i]; ++i) + if (!strcmp_partial(compare_ops[i], str, len)) + break; + if (!compare_ops[i]) + return -1; + if (!ctx->object) + return len; + compare_item = ctx->object; + compare_item->operation = (enum rte_flow_item_compare_op)i; + return len; +} + +/** Parse id for compare match item. */ +static int +parse_vc_compare_field_id(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size) +{ + struct rte_flow_item_compare *compare_item; + unsigned int i; + + (void)token; + (void)buf; + (void)size; + if (ctx->curr != ITEM_COMPARE_FIELD_A_TYPE_VALUE && + ctx->curr != ITEM_COMPARE_FIELD_B_TYPE_VALUE) + return -1; + for (i = 0; flow_field_ids[i]; ++i) + if (!strcmp_partial(flow_field_ids[i], str, len)) + break; + if (!flow_field_ids[i]) + return -1; + if (!ctx->object) + return len; + compare_item = ctx->object; + if (ctx->curr == ITEM_COMPARE_FIELD_A_TYPE_VALUE) + compare_item->a.field = (enum rte_flow_field_id)i; + else + compare_item->b.field = (enum rte_flow_field_id)i; + return len; +} + +/** Parse level for compare match item. */ +static int +parse_vc_compare_field_level(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size) +{ + struct rte_flow_item_compare *compare_item; + struct flex_item *fp = NULL; + uint32_t val; + struct buffer *out = buf; + char *end; + + (void)token; + (void)size; + if (ctx->curr != ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + ctx->curr != ITEM_COMPARE_FIELD_B_LEVEL_VALUE) + return -1; + if (!ctx->object) + return len; + compare_item = ctx->object; + errno = 0; + val = strtoumax(str, &end, 0); + if (errno || (size_t)(end - str) != len) + return -1; + /* No need to validate action template mask value */ + if (out->args.vc.masks) { + if (ctx->curr == ITEM_COMPARE_FIELD_A_LEVEL_VALUE) + compare_item->a.level = val; + else + compare_item->b.level = val; + return len; + } + if ((ctx->curr == ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + compare_item->a.field == RTE_FLOW_FIELD_FLEX_ITEM) || + (ctx->curr == ITEM_COMPARE_FIELD_B_LEVEL_VALUE && + compare_item->b.field == RTE_FLOW_FIELD_FLEX_ITEM)) { + if (val >= FLEX_MAX_PARSERS_NUM) { + printf("Bad flex item handle\n"); + return -1; + } + fp = flex_items[ctx->port][val]; + if (!fp) { + printf("Bad flex item handle\n"); + return -1; + } + } + if (ctx->curr == ITEM_COMPARE_FIELD_A_LEVEL_VALUE) { + if (compare_item->a.field != RTE_FLOW_FIELD_FLEX_ITEM) + compare_item->a.level = val; + else + compare_item->a.flex_handle = fp->flex_handle; + } else if (ctx->curr == ITEM_COMPARE_FIELD_B_LEVEL_VALUE) { + if (compare_item->b.field != RTE_FLOW_FIELD_FLEX_ITEM) + compare_item->b.level = val; + else + compare_item->b.flex_handle = fp->flex_handle; + } + return len; +} + /** Parse meter color action type. */ static int parse_vc_action_meter_color_type(struct context *ctx, const struct token *token, @@ -9773,10 +10134,10 @@ parse_vc_modify_field_id(struct context *ctx, const struct token *token, if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE && ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE) return -1; - for (i = 0; modify_field_ids[i]; ++i) - if (!strcmp_partial(modify_field_ids[i], str, len)) + for (i = 0; flow_field_ids[i]; ++i) + if (!strcmp_partial(flow_field_ids[i], str, len)) break; - if (!modify_field_ids[i]) + if (!flow_field_ids[i]) return -1; if (!ctx->object) return len; @@ -11890,6 +12251,39 @@ comp_rule_id(struct context *ctx, const struct token *token, return i; } +/** Complete operation for compare match item. */ +static int +comp_set_compare_op(struct context *ctx, const struct token *token, + unsigned int ent, char *buf, unsigned int size) +{ + RTE_SET_USED(ctx); + RTE_SET_USED(token); + if (!buf) + return RTE_DIM(compare_ops); + if (ent < RTE_DIM(compare_ops) - 1) + return strlcpy(buf, compare_ops[ent], size); + return -1; +} + +/** Complete field id for compare match item. */ +static int +comp_set_compare_field_id(struct context *ctx, const struct token *token, + unsigned int ent, char *buf, unsigned int size) +{ + const char *name; + + RTE_SET_USED(token); + if (!buf) + return RTE_DIM(flow_field_ids); + if (ent >= RTE_DIM(flow_field_ids) - 1) + return -1; + name = flow_field_ids[ent]; + if (ctx->curr == ITEM_COMPARE_FIELD_B_TYPE || + (strcmp(name, "pointer") && strcmp(name, "value"))) + return strlcpy(buf, name, size); + return -1; +} + /** Complete type field for RSS action. */ static int comp_vc_action_rss_type(struct context *ctx, const struct token *token, @@ -12003,10 +12397,10 @@ comp_set_modify_field_id(struct context *ctx, const struct token *token, RTE_SET_USED(token); if (!buf) - return RTE_DIM(modify_field_ids); - if (ent >= RTE_DIM(modify_field_ids) - 1) + return RTE_DIM(flow_field_ids); + if (ent >= RTE_DIM(flow_field_ids) - 1) return -1; - name = modify_field_ids[ent]; + name = flow_field_ids[ent]; if (ctx->curr == ACTION_MODIFY_FIELD_SRC_TYPE || (strcmp(name, "pointer") && strcmp(name, "value"))) return strlcpy(buf, name, size); diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini index 806cb033ff..565338731f 100644 --- a/doc/guides/nics/features/default.ini +++ b/doc/guides/nics/features/default.ini @@ -87,6 +87,7 @@ aggr_affinity = ah = any = arp_eth_ipv4 = +compare = conntrack = ecpri = esp = diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index bf25c849fb..b720157d18 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1573,6 +1573,13 @@ Matches the packet type as defined in rte_mbuf_ptype. - ``packet_type``: L2/L3/L4 and tunnel information. +Item: ``COMPARE`` +^^^^^^^^^^^^^^^^^ + +Matches the comparison result between packet fields or value. + +- ``compare``: Comparison information. + Actions ~~~~~~~ diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst index a691e794f4..8c8c661218 100644 --- a/doc/guides/rel_notes/release_24_03.rst +++ b/doc/guides/rel_notes/release_24_03.rst @@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added compare flow matching criteria.** + + Added ``RTE_FLOW_ITEM_TYPE_COMPARE`` to allow matching on compare + result between the packet fields or value. + * **Updated NVIDIA mlx5 driver.** * Added support for accumulating from src field to dst field. diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 447e28e694..2d96deae75 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3841,6 +3841,13 @@ This section lists supported pattern items and their attributes, if any. - ``packet_type {unsigned}``: packet type. +- ``compare``: match the comparison result between packet fields or value. + + - ``op {string}``: comparison operation type. + - ``a_type {string}``: compared field. + - ``b_type {string}``: comparator field. + - ``width {unsigned}``: comparison width. + Actions list ^^^^^^^^^^^^ diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 549e329558..88cf003b2b 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -167,6 +167,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(TX_QUEUE, sizeof(struct rte_flow_item_tx_queue)), MK_FLOW_ITEM(IB_BTH, sizeof(struct rte_flow_item_ib_bth)), MK_FLOW_ITEM(PTYPE, sizeof(struct rte_flow_item_ptype)), + MK_FLOW_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), }; /** Generate flow_action[] entry. */ diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 40f6dcaacd..8506184a76 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -704,6 +704,13 @@ enum rte_flow_item_type { * */ RTE_FLOW_ITEM_TYPE_PTYPE, + + /** + * Matches the packet with compare result. + * + * See struct rte_flow_item_compare. + */ + RTE_FLOW_ITEM_TYPE_COMPARE, }; /** @@ -2336,6 +2343,177 @@ static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { }; #endif +/** + * Field IDs for packet field. + */ +enum rte_flow_field_id { + RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */ + RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */ + RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */ + RTE_FLOW_FIELD_VLAN_TYPE, /**< VLAN Tag Identifier. */ + RTE_FLOW_FIELD_VLAN_ID, /**< VLAN Identifier. */ + RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */ + RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */ + RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */ + RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */ + RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */ + RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */ + RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */ + RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */ + RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */ + RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */ + RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */ + RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */ + RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */ + RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */ + RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */ + RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */ + RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */ + RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */ + RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */ + RTE_FLOW_FIELD_TAG, /**< Tag value. */ + RTE_FLOW_FIELD_MARK, /**< Mark value. */ + RTE_FLOW_FIELD_META, /**< Metadata value. */ + RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */ + RTE_FLOW_FIELD_VALUE, /**< Immediate value. */ + RTE_FLOW_FIELD_IPV4_ECN, /**< IPv4 ECN. */ + RTE_FLOW_FIELD_IPV6_ECN, /**< IPv6 ECN. */ + RTE_FLOW_FIELD_GTP_PSC_QFI, /**< GTP QFI. */ + RTE_FLOW_FIELD_METER_COLOR, /**< Meter color marker. */ + RTE_FLOW_FIELD_IPV6_PROTO, /**< IPv6 next header. */ + RTE_FLOW_FIELD_FLEX_ITEM, /**< Flex item. */ + RTE_FLOW_FIELD_HASH_RESULT, /**< Hash result. */ + RTE_FLOW_FIELD_GENEVE_OPT_TYPE, /**< GENEVE option type. */ + RTE_FLOW_FIELD_GENEVE_OPT_CLASS,/**< GENEVE option class. */ + RTE_FLOW_FIELD_GENEVE_OPT_DATA, /**< GENEVE option data. */ + RTE_FLOW_FIELD_MPLS, /**< MPLS header. */ + RTE_FLOW_FIELD_TCP_DATA_OFFSET, /**< TCP data offset. */ + RTE_FLOW_FIELD_IPV4_IHL, /**< IPv4 IHL. */ + RTE_FLOW_FIELD_IPV4_TOTAL_LEN, /**< IPv4 total length. */ + RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN /**< IPv6 payload length. */ +}; + +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * Field description for packet field. + */ +struct rte_flow_field_data { + enum rte_flow_field_id field; /**< Field or memory type ID. */ + union { + struct { + /** Encapsulation level and tag index or flex item handle. */ + union { + struct { + /** + * Packet encapsulation level containing + * the field to modify. + * + * - @p 0 requests the default behavior. + * Depending on the packet type, it + * can mean outermost, innermost or + * anything in between. + * + * It basically stands for the + * innermost encapsulation level. + * Modification can be performed + * according to PMD and device + * capabilities. + * + * - @p 1 requests modification to be + * performed on the outermost packet + * encapsulation level. + * + * - @p 2 and subsequent values request + * modification to be performed on + * the specified inner packet + * encapsulation level, from + * outermost to innermost (lower to + * higher values). + * + * Values other than @p 0 are not + * necessarily supported. + * + * @note that for MPLS field, + * encapsulation level also include + * tunnel since MPLS may appear in + * outer, inner or tunnel. + */ + uint8_t level; + union { + /** + * Tag index array inside + * encapsulation level. + * Used for VLAN, MPLS or TAG types. + */ + uint8_t tag_index; + /** + * Geneve option identifier. + * Relevant only for + * RTE_FLOW_FIELD_GENEVE_OPT_XXXX + * modification type. + */ + struct { + /** + * Geneve option type. + */ + uint8_t type; + /** + * Geneve option class. + */ + rte_be16_t class_id; + }; + }; + }; + struct rte_flow_item_flex_handle *flex_handle; + }; + /** Number of bits to skip from a field. */ + uint32_t offset; + }; + /** + * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the + * same byte order and length as in relevant rte_flow_item_xxx. + * The immediate source bitfield offset is inherited from + * the destination's one. + */ + uint8_t value[16]; + /** + * Memory address for RTE_FLOW_FIELD_POINTER, memory layout + * should be the same as for relevant field in the + * rte_flow_item_xxx structure. + */ + void *pvalue; + }; +}; + +/** + * Expected operation types for compare item. + */ +enum rte_flow_item_compare_op { + RTE_FLOW_ITEM_COMPARE_EQ, /* Compare result equal. */ + RTE_FLOW_ITEM_COMPARE_NE, /* Compare result not equal. */ + RTE_FLOW_ITEM_COMPARE_LT, /* Compare result less than. */ + RTE_FLOW_ITEM_COMPARE_LE, /* Compare result less than or equal. */ + RTE_FLOW_ITEM_COMPARE_GT, /* Compare result great than. */ + RTE_FLOW_ITEM_COMPARE_GE, /* Compare result great than or equal. */ +}; + +/** + * + * RTE_FLOW_ITEM_TYPE_COMPARE + * + * Matches the packet with compare result. + * + * The operation means a compare with b result. + */ +struct rte_flow_item_compare { + enum rte_flow_item_compare_op operation; /* The compare operation. */ + struct rte_flow_field_data a; /* Field be compared. */ + struct rte_flow_field_data b; /* Field as comparator. */ + uint32_t width; /* Compare width. */ +}; + /** * Action types. * @@ -3856,150 +4034,6 @@ struct rte_flow_action_ethdev { uint16_t port_id; /**< ethdev port ID */ }; -/** - * Field IDs for MODIFY_FIELD action. - */ -enum rte_flow_field_id { - RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */ - RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */ - RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */ - RTE_FLOW_FIELD_VLAN_TYPE, /**< VLAN Tag Identifier. */ - RTE_FLOW_FIELD_VLAN_ID, /**< VLAN Identifier. */ - RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */ - RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */ - RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */ - RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */ - RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */ - RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */ - RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */ - RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */ - RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */ - RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */ - RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */ - RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */ - RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */ - RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */ - RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */ - RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */ - RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */ - RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */ - RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */ - RTE_FLOW_FIELD_TAG, /**< Tag value. */ - RTE_FLOW_FIELD_MARK, /**< Mark value. */ - RTE_FLOW_FIELD_META, /**< Metadata value. */ - RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */ - RTE_FLOW_FIELD_VALUE, /**< Immediate value. */ - RTE_FLOW_FIELD_IPV4_ECN, /**< IPv4 ECN. */ - RTE_FLOW_FIELD_IPV6_ECN, /**< IPv6 ECN. */ - RTE_FLOW_FIELD_GTP_PSC_QFI, /**< GTP QFI. */ - RTE_FLOW_FIELD_METER_COLOR, /**< Meter color marker. */ - RTE_FLOW_FIELD_IPV6_PROTO, /**< IPv6 next header. */ - RTE_FLOW_FIELD_FLEX_ITEM, /**< Flex item. */ - RTE_FLOW_FIELD_HASH_RESULT, /**< Hash result. */ - RTE_FLOW_FIELD_GENEVE_OPT_TYPE, /**< GENEVE option type. */ - RTE_FLOW_FIELD_GENEVE_OPT_CLASS,/**< GENEVE option class. */ - RTE_FLOW_FIELD_GENEVE_OPT_DATA, /**< GENEVE option data. */ - RTE_FLOW_FIELD_MPLS, /**< MPLS header. */ - RTE_FLOW_FIELD_TCP_DATA_OFFSET, /**< TCP data offset. */ - RTE_FLOW_FIELD_IPV4_IHL, /**< IPv4 IHL. */ - RTE_FLOW_FIELD_IPV4_TOTAL_LEN, /**< IPv4 total length. */ - RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN /**< IPv6 payload length. */ -}; - -/** - * @warning - * @b EXPERIMENTAL: this structure may change without prior notice - * - * Field description for packet field. - */ -struct rte_flow_field_data { - enum rte_flow_field_id field; /**< Field or memory type ID. */ - union { - struct { - /** Encapsulation level and tag index or flex item handle. */ - union { - struct { - /** - * Packet encapsulation level containing - * the field to modify. - * - * - @p 0 requests the default behavior. - * Depending on the packet type, it - * can mean outermost, innermost or - * anything in between. - * - * It basically stands for the - * innermost encapsulation level. - * Modification can be performed - * according to PMD and device - * capabilities. - * - * - @p 1 requests modification to be - * performed on the outermost packet - * encapsulation level. - * - * - @p 2 and subsequent values request - * modification to be performed on - * the specified inner packet - * encapsulation level, from - * outermost to innermost (lower to - * higher values). - * - * Values other than @p 0 are not - * necessarily supported. - * - * @note that for MPLS field, - * encapsulation level also include - * tunnel since MPLS may appear in - * outer, inner or tunnel. - */ - uint8_t level; - union { - /** - * Tag index array inside - * encapsulation level. - * Used for VLAN, MPLS or TAG types. - */ - uint8_t tag_index; - /** - * Geneve option identifier. - * Relevant only for - * RTE_FLOW_FIELD_GENEVE_OPT_XXXX - * modification type. - */ - struct { - /** - * Geneve option type. - */ - uint8_t type; - /** - * Geneve option class. - */ - rte_be16_t class_id; - }; - }; - }; - struct rte_flow_item_flex_handle *flex_handle; - }; - /** Number of bits to skip from a field. */ - uint32_t offset; - }; - /** - * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the - * same byte order and length as in relevant rte_flow_item_xxx. - * The immediate source bitfield offset is inherited from - * the destination's one. - */ - uint8_t value[16]; - /** - * Memory address for RTE_FLOW_FIELD_POINTER, memory layout - * should be the same as for relevant field in the - * rte_flow_item_xxx structure. - */ - void *pvalue; - }; -}; - /** * Operation types for MODIFY_FIELD action. */ -- 2.34.1