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 4BEA8439C1; Thu, 25 Jan 2024 13:37:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2E9DA42DE7; Thu, 25 Jan 2024 13:37:36 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2043.outbound.protection.outlook.com [40.107.220.43]) by mails.dpdk.org (Postfix) with ESMTP id 85B0542DE3 for ; Thu, 25 Jan 2024 13:37:35 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AP+oVqQmTOUcJpJNmQQUy/3QZ5eJry7VF16/l0E/rdrtfTj/cxKQ3yF1Z2LDs8ax32suI9+6ofh8pMQlnxmtXMc8jeUaATib48xg8pjpqTYKfHSlYS9VJDpQ71p2Gfj2YI44psmWeWKYv5ytjf701tauV+5T2c1uMdWUGFFLCdwxkUjgf030uyCmc7A9fb7aKt9B3Sw+1WLwyXRGjJgso2cigqD28NmQ57outP3VS+KLr+1DSN7znqTX7vencYzeh6eT0gSRWdz5zqr0W4X0KEN7CDaKQDc2GxJPOS1Hyrylq2SMOMFDZO11K2ipqbedzO5ScLwvufpqaefVeZP6jg== 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=QL9H8hcxoBQ7JLNHUbL+y6q/0thKlfv1yyuAtw3/UF4=; b=HJKbwFk76sGvFR0BbIGyGDK3n2oFLYNDns1wKp8okeuZ2EbU5urtTyws8vbCaEoiqgLexZ1TCU9o7Y418Y6In7Jt6KUuiGhCT+EB//YYuWFQzqj/fqTsvvg1ZodfEYoNjWwZaHQD4vSOTvlcC/0OSXPdqYnSEBrtF+Vgl9jfEjSfAt2s8xEaZ44YlmyZIUzzt0itiUxWOiozTHxVni0rIZsgU6snqgfwEWo1PsRw4v4r/NnfN8gnn00SlO7OGO2V1wqdycNA3tm+KbwTo6ZFDkBhU5Tx646JbmnCs1yXHG411EP3pb5V8mdy209CnttCOQE7otsNRoEtYJpHLC4Pwg== 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 (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=QL9H8hcxoBQ7JLNHUbL+y6q/0thKlfv1yyuAtw3/UF4=; b=EI/EzbSsu5SXgUneHkmVFs5A98O6EzN6Xjyhn1x6qWPwLkPOwxosRAFs2SWksU6Umr5V6lkxhIPO7SYwg5BpOEzUye96AmQmDKDski0IoWJTYkG4Ur+axtvTahG0sCRUt62MzhkM584Z/KyC0vheBSUjE96AAcdAEnN//mkwAlVYuBUxtvQN8FzSj5bIqKel6F11nnB4r3TN4saomUV/ZwFJL5TuZRNcAr5VW7OXF3PDol9e0Y77tD8p1befxs/sS3s6n04lu7SP3DHXDVoImxXTHSBzDbmQ7w/4/YnY6mH/8DaSv8h9y/wUUOLveWR5y/RI9vHElzcEL5HcGpudnw== Received: from BYAPR07CA0001.namprd07.prod.outlook.com (2603:10b6:a02:bc::14) by BY5PR12MB4885.namprd12.prod.outlook.com (2603:10b6:a03:1de::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.26; Thu, 25 Jan 2024 12:37:32 +0000 Received: from SJ5PEPF000001CC.namprd05.prod.outlook.com (2603:10b6:a02:bc:cafe::50) by BYAPR07CA0001.outlook.office365.com (2603:10b6:a02:bc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22 via Frontend Transport; Thu, 25 Jan 2024 12:37:32 +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 SJ5PEPF000001CC.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.16 via Frontend Transport; Thu, 25 Jan 2024 12:37:32 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.41; Thu, 25 Jan 2024 04:37:18 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 25 Jan 2024 04:37:18 -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, 25 Jan 2024 04:37:16 -0800 From: Michael Baum To: CC: Matan Azrad , Dariusz Sosnowski , Raslan Darawsheh , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Erez Shitrit Subject: [PATCH v5 1/2] net/mlx5/hws: add support for random number match Date: Thu, 25 Jan 2024 14:37:07 +0200 Message-ID: <20240125123708.571526-2-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240125123708.571526-1-michaelba@nvidia.com> References: <20231225102435.2419716-1-michaelba@nvidia.com> <20240125123708.571526-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: SJ5PEPF000001CC:EE_|BY5PR12MB4885:EE_ X-MS-Office365-Filtering-Correlation-Id: a5e26840-744d-4b0a-b38d-08dc1da266eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +1rdLkYoqo1V5iW5LnFz2sBRGiRoYFhSPgWwl7HbhFk5qAErYU801jXiL91ZGu6hhFSUSN1GYAU6E4G5Ml/+9jF/JWQUGWe7YzDdES7EGG6KMMxVSLjd+qJBdsW6OJIU/VOXVNiJZRzsyiz3AnrdnZv+/1Q524xtsJfgVfcBNnyQayVg3nDL7T9mjUeaLlJ9suQpSYyd2+S4JtuBm4Lvv/3zDU3Aasj3IkkCf9HPqeZRC9SrHe6ucoY8JndSW+uBCzRZ4NY3/860voql39bnljp/TWprlG0EULj63PLcF23fgWBaharf1eaHXEqUPMSQOHUxPYIXgfgI/y6HfOvRa6fez4W+kuJccYopkF6+R7v39cbYZ9TtynqzwEZblvcCF8XAvfgkkgiCuIG9Xy8TtpxifmbpE9+IYThr7xgTcfIy5yYG5YyGjKNg7phYaVQr/oWO05/7VIZ+i9Wg8km/dcUAfuHBVbW5EoHWPJn0dkOBl0jXrvzDn8ou/8zJeE6NrSIPOpMkVA3VGuzoD5v8ujY42cSpkgWYdNoxk1eq6GbQTIcCODsyikn9HF8iS8s5mYn0BZvQNQJZKPMX7NLEg1eOpbcYR34YB0ZUjrcHV40jdssrjqzKietCMa/lQj1fQXV4UUq/NW+swnNfrGs55XlUQqFULdjqUaASZ/RiOMKaKPDMM56srH5TCkjlGyopv0T6gBv1PmulE235Rp8xrooJyYYniwawyctlgB1xXV4vRVFTnz5VgORzy4hbs4SX 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:(13230031)(4636009)(346002)(39860400002)(376002)(136003)(396003)(230922051799003)(186009)(451199024)(64100799003)(82310400011)(1800799012)(36840700001)(40470700004)(46966006)(7636003)(36860700001)(26005)(6286002)(336012)(426003)(41300700001)(83380400001)(47076005)(8936002)(4326008)(8676002)(478600001)(70586007)(86362001)(70206006)(54906003)(6916009)(316002)(5660300002)(2616005)(107886003)(1076003)(36756003)(2906002)(7696005)(6666004)(55016003)(356005)(82740400003)(40460700003)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 12:37:32.7148 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5e26840-744d-4b0a-b38d-08dc1da266eb 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: SJ5PEPF000001CC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4885 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 From: Erez Shitrit The HW adds a random number per each hash, this value can be used for statistic calculation over the packets, for example by setting one bit in the mask of that field we will get half of the traffic in the flow, and so on with the rest of the mask. Signed-off-by: Erez Shitrit Acked-by: Dariusz Sosnowski --- drivers/net/mlx5/hws/mlx5dr_definer.c | 33 +++++++++++++++++++++++++++ drivers/net/mlx5/hws/mlx5dr_definer.h | 8 ++++++- drivers/net/mlx5/mlx5_flow.h | 3 +++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.c b/drivers/net/mlx5/hws/mlx5dr_definer.c index af924b490c..750eb9c7c6 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.c +++ b/drivers/net/mlx5/hws/mlx5dr_definer.c @@ -187,6 +187,7 @@ struct mlx5dr_definer_conv_data { X(SET_BE32, ipsec_sequence_number, v->hdr.seq, rte_flow_item_esp) \ X(SET, ib_l4_udp_port, UDP_ROCEV2_PORT, rte_flow_item_ib_bth) \ X(SET, ib_l4_opcode, v->hdr.opcode, rte_flow_item_ib_bth) \ + X(SET, random_number, v->value, rte_flow_item_random) \ X(SET, ib_l4_bth_a, v->hdr.a, rte_flow_item_ib_bth) \ /* Item set function format */ @@ -2200,6 +2201,33 @@ mlx5dr_definer_conv_item_ipv6_routing_ext(struct mlx5dr_definer_conv_data *cd, return 0; } +static int +mlx5dr_definer_conv_item_random(struct mlx5dr_definer_conv_data *cd, + struct rte_flow_item *item, + int item_idx) +{ + const struct rte_flow_item_random *m = item->mask; + const struct rte_flow_item_random *l = item->last; + struct mlx5dr_definer_fc *fc; + + if (!m) + return 0; + + if (m->value != (m->value & UINT16_MAX)) { + DR_LOG(ERR, "Random value is 16 bits only"); + rte_errno = EINVAL; + return rte_errno; + } + + fc = &cd->fc[MLX5DR_DEFINER_FNAME_RANDOM_NUM]; + fc->item_idx = item_idx; + fc->tag_set = &mlx5dr_definer_random_number_set; + fc->is_range = l && l->value; + DR_CALC_SET_HDR(fc, random_number, random_number); + + return 0; +} + static int mlx5dr_definer_mt_set_fc(struct mlx5dr_match_template *mt, struct mlx5dr_definer_fc *fc, @@ -2251,6 +2279,7 @@ mlx5dr_definer_check_item_range_supp(struct rte_flow_item *item) case RTE_FLOW_ITEM_TYPE_TAG: case RTE_FLOW_ITEM_TYPE_META: case MLX5_RTE_FLOW_ITEM_TYPE_TAG: + case RTE_FLOW_ITEM_TYPE_RANDOM: return 0; default: DR_LOG(ERR, "Range not supported over item type %d", item->type); @@ -2645,6 +2674,10 @@ mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, ret = mlx5dr_definer_conv_item_ptype(&cd, items, i); item_flags |= MLX5_FLOW_ITEM_PTYPE; break; + case RTE_FLOW_ITEM_TYPE_RANDOM: + ret = mlx5dr_definer_conv_item_random(&cd, items, i); + item_flags |= MLX5_FLOW_ITEM_RANDOM; + break; case RTE_FLOW_ITEM_TYPE_VXLAN_GPE: ret = mlx5dr_definer_conv_item_vxlan_gpe(&cd, items, i); item_flags |= MLX5_FLOW_LAYER_VXLAN_GPE; diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.h b/drivers/net/mlx5/hws/mlx5dr_definer.h index 3dc5f4438d..7b7463fc91 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.h +++ b/drivers/net/mlx5/hws/mlx5dr_definer.h @@ -155,6 +155,7 @@ enum mlx5dr_definer_fname { MLX5DR_DEFINER_FNAME_PTYPE_TUNNEL, MLX5DR_DEFINER_FNAME_PTYPE_FRAG_O, MLX5DR_DEFINER_FNAME_PTYPE_FRAG_I, + MLX5DR_DEFINER_FNAME_RANDOM_NUM, MLX5DR_DEFINER_FNAME_MAX, }; @@ -412,6 +413,11 @@ struct mlx5_ifc_definer_hl_ipv4_src_dst_bits { u8 destination_address[0x20]; }; +struct mlx5_ifc_definer_hl_random_number_bits { + u8 random_number[0x10]; + u8 reserved[0x10]; +}; + struct mlx5_ifc_definer_hl_ipv6_addr_bits { u8 ipv6_address_127_96[0x20]; u8 ipv6_address_95_64[0x20]; @@ -521,7 +527,7 @@ struct mlx5_ifc_definer_hl_bits { struct mlx5_ifc_definer_hl_mpls_bits mpls_inner; u8 unsupported_config_headers_outer[0x80]; u8 unsupported_config_headers_inner[0x80]; - u8 unsupported_random_number[0x20]; + struct mlx5_ifc_definer_hl_random_number_bits random_number; struct mlx5_ifc_definer_hl_ipsec_bits ipsec; struct mlx5_ifc_definer_hl_metadata_bits metadata; u8 unsupported_utc_timestamp[0x40]; diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index fe4f46724b..6f720de14d 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -277,6 +277,9 @@ enum mlx5_feature_name { /* NSH ITEM */ #define MLX5_FLOW_ITEM_NSH (1ull << 53) +/* Random ITEM */ +#define MLX5_FLOW_ITEM_RANDOM (1ull << 54) + /* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6) -- 2.25.1