From patchwork Tue Aug 22 09:05:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 130631 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7DC35430CE; Tue, 22 Aug 2023 11:05:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5D8AB42D13; Tue, 22 Aug 2023 11:05:40 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2088.outbound.protection.outlook.com [40.107.94.88]) by mails.dpdk.org (Postfix) with ESMTP id 0F5D84021D for ; Tue, 22 Aug 2023 11:05:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kb7m4aZML0xfd/bmp5jzNVeaaAyGhTJ78zDgcAZTthpMoqU2gSsqvnAOzKzVJ5o91z/KMjfVSgJOuYo8TDOsQ4I1xhPVuyp1Bxy9FdN4eU6xtHXM0IGsYnTtiPZ6yuRe9nrIENqbr1wo+DtauZlC9WbQ3fOD6cYIuM2MwUAlyfQdRZ8SA1xQu7bZ8K+X18Bi1OnH8o6DVKTFpsT/2T0gu+zB0nAn/0uEMipbleq4CQXQWhZaNurrpxU+j/jh101W34E0Z6voPxK/c+7zyWFfJ5Ope/L+bzDETsS5d+WBGSRXAY0xSfRTYeljY5FP3iab5b9m3wvLG1Rw+eOD3Wb5TQ== 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=4Qh7CrLu6Uh/HjelxuIhI7/jne8K3mP6M2BrTG2z21Q=; b=AVXGwSregZFXQLsRSlQQENqzjrqZEVEh5GmGvtDIhmDw8+nwc6b16WZ1W8j4I/ptc+dSsFaM/sr1fArIf4/7ShY6rVLLJIqdQfrLnwlzmYS+IQlTfrPpDJ7UNawnLOdRKGi7kRv8Vs7x9j38ajyktD5YhDu2LechDVRaKlbg0+TLba/YchNpMtVgYfZF8mUO1Ch8YomVyoYbXcuxkFcKAQBUrjNPZUaWDnhmAWRKS49W8Bbc8MPwxc5gMLyW+MLlaFimPgouG9ONTLwlWaFdvKLODOufu2I4BhtGzmA3FvROB6NMYAN1447IVtFcG94ZFmc6V596thH7LLBPyv9ivA== 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 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=4Qh7CrLu6Uh/HjelxuIhI7/jne8K3mP6M2BrTG2z21Q=; b=c94iQUI4xi2IrsnGOfIn9/ZGUvjUUQd2ci8itr2w6GXXor06f+bnW1Bve8bmssAQdjEb31Rk7aG4apTaAFxmdFoHlGC+z/3E9uS+PaPOW9eI8oLpDMK9zi0V5OupGI4YKZLYd2Qw5PETQr5TnIzMlkoJrx7jodWT0HgeFTDpeE5kaRvR5T+oEDw3fOfGO6ThmFyuvwWPkN0HWOcQOuo15i0SSG0wnfjd3wFHXuyCXGRHV75Z2v7df8pYNszVDqznPoEaumN3+EjRdYb5kj+x3ddE8ldtLwayLvTUg7aIeoAzlwGCQvTf/zmx9e6ZK0JyIRK3zZt41ACPoD077x3CuQ== Received: from SN7PR04CA0038.namprd04.prod.outlook.com (2603:10b6:806:120::13) by CH0PR12MB5268.namprd12.prod.outlook.com (2603:10b6:610:d3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 09:05:36 +0000 Received: from SA2PEPF00001506.namprd04.prod.outlook.com (2603:10b6:806:120:cafe::c8) by SN7PR04CA0038.outlook.office365.com (2603:10b6:806:120::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24 via Frontend Transport; Tue, 22 Aug 2023 09:05:36 +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 SA2PEPF00001506.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.14 via Frontend Transport; Tue, 22 Aug 2023 09:05:36 +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.5; Tue, 22 Aug 2023 02:05:21 -0700 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.37; Tue, 22 Aug 2023 02:05:20 -0700 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.37 via Frontend Transport; Tue, 22 Aug 2023 02:05:18 -0700 From: Michael Baum To: CC: Ori Kam , Aman Singh , "Yuying Zhang" , Ferruh Yigit , "Thomas Monjalon" Subject: [PATCH v1 2/2] app/testpmd: add random item support Date: Tue, 22 Aug 2023 12:05:05 +0300 Message-ID: <20230822090505.3242455-3-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230822090505.3242455-1-michaelba@nvidia.com> References: <20230822090505.3242455-1-michaelba@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001506:EE_|CH0PR12MB5268:EE_ X-MS-Office365-Filtering-Correlation-Id: d523b736-3e34-4272-3bd7-08dba2eef2fe 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: zk4AWKi1KQB4cPwtSltIZDM7sv9vNqmt9PnkhpirZ6zMZFl4ZTWWyGpIC2CgGv/YKwFbRTyf7b4RQGu0UeUhQxOtvcegH9yi5A/rnX4MZMVPU/CeomnOWC7kQE1/2YcNegQZ0Ldr0g4UK+L+3b4mHZkcrYcb2H/2bPypaIPn5UtusHnFkMOCQrGKRnNfI10lsd7L4xJ1Xc9/aPGSrsLk12SFWFXTft8b3nYCyocO9JBGXkDvYM6mjhLjbF5J8SZHRm2luKWLkPkq4QimeRwAmCf8vdLaCoQRmO/7pqEniP4U/M3oOxxaz4mK5Wwv+s0RKEtE9bmwfVrUrrvIJ2JKRN22XD/fqgrrD5iikoTTs39pcj1J7WpVDXkXS9xh49hQaQDBkl7NHnGWU1W8yF9Q0+9yF5EWkMqbZQ1fy/HkhxOnpJPXD8rgm9syOrQ9Lvy/2/KI1gSKPDIajmjSmhdTN29VDPJuAGzBo/5a/zV+XrQNFOrEB929dFVrQEzibdl8VqiSnThsWjxqd3HWOKTqnhgol2iTikVpTDT1M7iaXI+8axmrD+zKAbh72r9oQARFuYdRmGi1UTv4+27oNA0f4Z64LtkjaFSUvPT1JOMVFq99Y6IFYyUh9RGZ491edU+vL7Pv6NXF8n3jDjqZPrs2fguC86020vOlLV4v1o2cyW7FkL5cn5n1od9TSUiF3GR734QzRi1E9dZt6Gvkz0Xn7MWCoG3Bl8Olgq3MNbBuaxowRcoPXPLlHrmXJW2Q+Mu1 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)(136003)(39860400002)(346002)(376002)(1800799009)(186009)(451199024)(82310400011)(46966006)(36840700001)(40470700004)(54906003)(6916009)(70206006)(70586007)(316002)(8676002)(8936002)(2616005)(4326008)(7636003)(40460700003)(36756003)(41300700001)(1076003)(82740400003)(356005)(478600001)(6666004)(55016003)(40480700001)(83380400001)(2906002)(86362001)(7696005)(47076005)(36860700001)(336012)(426003)(5660300002)(26005)(6286002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 09:05:36.4158 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d523b736-3e34-4272-3bd7-08dba2eef2fe 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: SA2PEPF00001506.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5268 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 --- app/test-pmd/cmdline_flow.c | 30 ++++++++++++++++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 94827bcc4a..55fb07ec91 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -417,6 +417,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, @@ -936,7 +938,8 @@ static const char *const modify_field_ids[] = { "ipv6_proto", "flex_item", "hash_result", - "geneve_opt_type", "geneve_opt_class", "geneve_opt_data", "mpls", + "geneve_opt_type", "geneve_opt_class", "geneve_opt_data", + "mpls", "random", NULL }; @@ -1535,6 +1538,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, @@ -1842,6 +1846,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, @@ -5063,6 +5073,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", @@ -12634,6 +12659,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 a182479ab2..0b27a6fd97 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3724,6 +3724,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.