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 A01EB436EE; Thu, 14 Dec 2023 11:59:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 02AEB43260; Thu, 14 Dec 2023 11:59:11 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2042.outbound.protection.outlook.com [40.107.223.42]) by mails.dpdk.org (Postfix) with ESMTP id 8E4DB40697 for ; Thu, 14 Dec 2023 11:59:09 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c1GszKCMXcJ09WXlp5uMTtqdboXixkWHOjLBQFXqHpI1PYiQ0UtsRoE0alyP79ox2exmKawl9FQLq7vM/ZC0U6Pz0+XQVfV/ENGdYMpcMW2Ty7FiwyevJ3bQV3LN44H5DtheuqX0EWTzwufyRWT8tbxJ/lMNa3B+3mJGzVzshmg2+d+W1Kxwk6h/ex7kkPoiXtDDGLNpffqX+P/n1bMzZuACPpBK59jk9Aet+INjJMRjgZ1ykmWbY+FazK6yiGiWSNQceymAyqcL/+8G1l8V5WC2B3xCkG3FrI19kMUm6XcKax5XqXPPm59YOTj0ES44hIRY9o4V/qeWcEiKBeOCZQ== 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=bbq7shFjgt4PSu3PM+X1HLgePubRXYA7Xqun/SmtL2w=; b=VqANMKr921qdTHgOzjhn14Oq1GieBbl5WrrduR8qvJ/TmCSqF3HFIQ95vAHXzZCpjQGW4u0CXLLbe082UR1at0Z4j5WJ5VL4Y7L7zXwmulOz+djQR2cnSbYE0hThU19jzQWnTZz+cXh/Ynn/OvvegQg3f4uEiNd0xkRSOH91ZenI7mtmmJuW+Em2xUaDo9dMFGCSBcC2/23VsgBkBn1H9/KSloMmMBUK/Qi6fS7SWh+vRNbOEeAucWPs2gVhKAVF5ra3SjJ12tzdCu3kw4GP+GNK7bAEZhLrBD62fJ6z5GellresCqA2qXlUmX5JlEqg1UBVWnifbwtM6/vEeYA2tw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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 (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=bbq7shFjgt4PSu3PM+X1HLgePubRXYA7Xqun/SmtL2w=; b=BjGkt48Bw/a4YPXWyCXf9yd0x+Z3WJEgThqUpT0+gAW2LbSetIs3WHgJjX+YrGtATSIJxouFxmMiUxdOJxPkpzVGEIPTzN6NO4pCCjSuphS3UWXnH1NZDOm9rdye3sbVcpzA5b3wUJ0+6hSo5PQjeo89HZX0NnX/e0qBUwWxN0iLokewN7a2Tt5ze8daOl5N51W7pnwfqp0IzjIiR/TQRvy1EJ9RPCi38DJCFTMmETBJONH2qY4d3Gt5/WmKe7BvlK5o1LCp/+6XYzdajKFy6YMm9/OZ47dfsRdtJIAifp4LqWVvScg3peoKgzZBa2AsMy/97JY1j5LA1yX0uj7g3w== Received: from DS7PR03CA0119.namprd03.prod.outlook.com (2603:10b6:5:3b7::34) by BL3PR12MB6618.namprd12.prod.outlook.com (2603:10b6:208:38d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.28; Thu, 14 Dec 2023 10:59:07 +0000 Received: from DS2PEPF0000343A.namprd02.prod.outlook.com (2603:10b6:5:3b7:cafe::b6) by DS7PR03CA0119.outlook.office365.com (2603:10b6:5:3b7::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.28 via Frontend Transport; Thu, 14 Dec 2023 10:59:07 +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 DS2PEPF0000343A.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.26 via Frontend Transport; Thu, 14 Dec 2023 10:59:06 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Thu, 14 Dec 2023 02:58:56 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 14 Dec 2023 02:58:56 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41 via Frontend Transport; Thu, 14 Dec 2023 02:58:54 -0800 From: Michael Baum To: CC: Ori Kam , Dariusz Sosnowski , Aman Singh , Yuying Zhang , Ferruh Yigit , "Thomas Monjalon" Subject: [PATCH v4 2/2] app/testpmd: add random item support Date: Thu, 14 Dec 2023 12:58:44 +0200 Message-ID: <20231214105844.1640764-3-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214105844.1640764-1-michaelba@nvidia.com> References: <20231130163215.666239-1-michaelba@nvidia.com> <20231214105844.1640764-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343A:EE_|BL3PR12MB6618:EE_ X-MS-Office365-Filtering-Correlation-Id: 9349be30-04f1-4983-a07d-08dbfc93b156 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: 9miF6P6cslkwgU74l40unjtDWeMRgAWCR5wAaEybJMZqTecKbz0s/d+EsjKEYYdE46Mnn89L24Ie7yhdJ0yc7k1LS5TyML2s5ZEHxa9oWtFuIv2dsN0yXvqNGK3jIc5HXkl7VXP7djnK78SPgevfeskDnnwiC/ynR69CZ53AvNN3hpArtNrWGWiq4mUNrISQyEZr0dImyvXpqNd3prjLjwTIa0h46kOaGVrqgTzdPOGQm0fESrOLXS/hNJZLnsdKXVmj7v+u3LC/OLAfZYeAJa0ogOEe4HIzz/UOXEbzxw1k5PoVuYMoF1rIz9vjnZqmzeMQaOP8cfmi3sIEonuQR5bv4OjSFJmrA3+U7o24GCHP0xMksupxEmPdnGsEmjn9ZasTEr9AX5sFprrcn07XaXZPotBk6S7GZtpD+bZRWLppG27c+7oc2u1O/YLo/08jspBrgglJ+O6BDe3lrCJg8dcXEEb7PWHbrpL/+T1fYyMnK2X6uP/9DA5/dMFAq6mZgMdFAPJQxSbIqas/yxaRmxg19cySkOPl4ew2G+tDxzajZd8yPPhKFtgQYbj5vKWvdE2emwePeMn9ECXIODiC2s9i8xEkGlRDwFR9kII7eB3k9yHfYtJ6VTuVK2ZPJNYhSZm1fmep7DlutP8HMakyoOAiHMwO4QKYRG0K2GN1bNzZj+K3z/dWxhSBINpgu7tkUIMj9sbnVXyiHdldoj2XGcUu0+UpRCGpRq+K8x7ygPYFGP9QFFSQ0uj5ihIBO4Li 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)(136003)(39860400002)(396003)(376002)(346002)(230922051799003)(82310400011)(1800799012)(64100799003)(186009)(451199024)(46966006)(40470700004)(36840700001)(356005)(86362001)(36860700001)(82740400003)(7636003)(36756003)(55016003)(40460700003)(40480700001)(478600001)(7696005)(6666004)(426003)(1076003)(26005)(54906003)(70586007)(6916009)(70206006)(336012)(6286002)(47076005)(316002)(2616005)(4326008)(8936002)(8676002)(41300700001)(5660300002)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2023 10:59:06.7287 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9349be30-04f1-4983-a07d-08dbfc93b156 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: DS2PEPF0000343A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6618 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 support for random item, usage example: pattern random spec value 0x1 mask value 0x3 / eth / end Flow rule with above pattern matching 25% of the traffic, it hits only when random value suffix is "01" and miss the others ("00", "10", "11"). Signed-off-by: Michael Baum Reviewed-by: Dariusz Sosnowski Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 28 +++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++ 2 files changed, 32 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index ce71818705..359c187b3c 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -433,6 +433,8 @@ enum index { ITEM_ICMP6_ND_OPT_TLA_ETH_TLA, ITEM_META, ITEM_META_DATA, + ITEM_RANDOM, + ITEM_RANDOM_VALUE, ITEM_GRE_KEY, ITEM_GRE_KEY_VALUE, ITEM_GRE_OPTION, @@ -956,6 +958,7 @@ static const char *const modify_field_ids[] = { "hash_result", "geneve_opt_type", "geneve_opt_class", "geneve_opt_data", "mpls", "tcp_data_off", "ipv4_ihl", "ipv4_total_len", "ipv6_payload_len", + "random", NULL }; @@ -1562,6 +1565,7 @@ static const enum index next_item[] = { ITEM_ICMP6_ND_OPT_SLA_ETH, ITEM_ICMP6_ND_OPT_TLA_ETH, ITEM_META, + ITEM_RANDOM, ITEM_GRE_KEY, ITEM_GRE_OPTION, ITEM_GTP_PSC, @@ -1873,6 +1877,12 @@ static const enum index item_meta[] = { ZERO, }; +static const enum index item_random[] = { + ITEM_RANDOM_VALUE, + ITEM_NEXT, + ZERO, +}; + static const enum index item_gtp_psc[] = { ITEM_GTP_PSC_QFI, ITEM_GTP_PSC_PDU_T, @@ -5195,6 +5205,21 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta, data, "\xff\xff\xff\xff")), }, + [ITEM_RANDOM] = { + .name = "random", + .help = "match random value", + .priv = PRIV_ITEM(RANDOM, sizeof(struct rte_flow_item_random)), + .next = NEXT(item_random), + .call = parse_vc, + }, + [ITEM_RANDOM_VALUE] = { + .name = "value", + .help = "random value", + .next = NEXT(item_random, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_random, + value, "\xff\xff")), + }, [ITEM_GRE_KEY] = { .name = "gre_key", .help = "match GRE key", @@ -12883,6 +12908,9 @@ flow_item_default_mask(const struct rte_flow_item *item) case RTE_FLOW_ITEM_TYPE_META: mask = &rte_flow_item_meta_mask; break; + case RTE_FLOW_ITEM_TYPE_RANDOM: + mask = &rte_flow_item_random_mask; + break; case RTE_FLOW_ITEM_TYPE_FUZZY: mask = &rte_flow_item_fuzzy_mask; break; diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 447e28e694..0cd1615d9e 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3756,6 +3756,10 @@ This section lists supported pattern items and their attributes, if any. - ``data {unsigned}``: metadata value. +- ``random``: match application specific random value. + + - ``value {unsigned}``: random value. + - ``gtp_psc``: match GTP PDU extension header with type 0x85. - ``pdu_type {unsigned}``: PDU type. -- 2.25.1