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 F03FA436F1; Thu, 14 Dec 2023 16:13:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 52F094326C; Thu, 14 Dec 2023 16:13:22 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2050.outbound.protection.outlook.com [40.107.94.50]) by mails.dpdk.org (Postfix) with ESMTP id 20236402C2 for ; Thu, 14 Dec 2023 16:13:21 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QjqSu1ghHbuByjTwHmoErOaShKckTAfxsgZCCRSSKCX03Z2bYTrCbSYFpA1EVn0cEc+0uACuLvFb8I3dscRHbt4lnmo/B5C89mXs/qB7aXuj1WaUU+JWhESlYrvUPy0GCHW/CKN42GMCvxHsjFSld+ORKUto19Up4UKTtnDVjjrld3mVkINDuU0czF3lHZYtmJWJUR/8fehktDqV9yW44g8mitqIrde0lX3ylGZZxFiTslVHPYkCqC5j0Ayba03qSsQSQkI8q9WsK42nzNEj06k345LtcISqnRjJvyImHfawVhcVe2WK4e9e1ID7GHcP1WGmq59hPMiBaZ9v3kKejQ== 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=PiuZChT4H7BFg3DPfoHN1zrzwCrIuqCkbeRjbhYpxkY=; b=oDn11vNbbPYZbl3724LIzRQZOZela12lp3HmQhcGWo6sG8nsHItCibOA3QcICj5z396dWWb1yubwLqxPHWty5RaSVVur4g6ZeegoHdiFuVrp1rp1PKubGpzDmh72psyCocryAKzbI1mbzwluJHQhFUpZws9pxzFzE2nZ3f1jvE0tKRx8zIO+H4H27ieawbdg0vTdxm7T5Xg9/ADBI/Dw6bFCF9ZWgq7dKzAqofE9YjSVCXfOpPGO0K9zyW6BILdVeRarpesqAty6EuKprTZzfNcnahk9ljv0NvJX31N5ikXlUTSW9UpZc/oxRYcBpUu39iyhcdB0Jrxc+hdBX1bv9g== 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=PiuZChT4H7BFg3DPfoHN1zrzwCrIuqCkbeRjbhYpxkY=; b=pYmARLNpGpPSorZlsxyvtiAhSo2PQKla4nkeDFHWUrVRf9/Y7r/bkqI1rZgT1WeKzHM6d6ITSwFOHZkXiucPW7PMcNSg7m3sZsx7PX0KgbEl4cyKygZfz9tKxWfPK49OcDM7mFuEGveGWlGQsgiIjGGk8syzNK37qAAqhAHjG9bJXG/4uWMmShtscM+qd3toZTUCSjSaWciwDjOXQ/hgn9epzi/jp3EUZ4ucI+VUUmP6mMSO4zmgpchpwu+nAqdvtY5NemXCDKZmBpquuTG/aORYd4aiTaHCf8deCl+zk6TckREjUHdLAOrAI+EIfWQkEugbzjyohjtTCNv+2oTq0g== Received: from BLAPR03CA0138.namprd03.prod.outlook.com (2603:10b6:208:32e::23) by DS0PR12MB7679.namprd12.prod.outlook.com (2603:10b6:8:134::5) 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 15:13:18 +0000 Received: from BL6PEPF0001AB4B.namprd04.prod.outlook.com (2603:10b6:208:32e:cafe::b3) by BLAPR03CA0138.outlook.office365.com (2603:10b6:208:32e::23) 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 15:13:18 +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 BL6PEPF0001AB4B.mail.protection.outlook.com (10.167.242.69) 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 15:13:17 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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, 14 Dec 2023 07:13:02 -0800 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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 07:13:02 -0800 Received: from nvidia.com (10.127.8.13) by mail.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 via Frontend Transport; Thu, 14 Dec 2023 07:13:00 -0800 From: Michael Baum To: CC: Matan Azrad , Dariusz Sosnowski , Raslan Darawsheh , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Erez Shitrit Subject: [PATCH v3 1/2] net/mlx5/hws: add support for random number match Date: Thu, 14 Dec 2023 17:12:47 +0200 Message-ID: <20231214151248.1654878-2-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214151248.1654878-1-michaelba@nvidia.com> References: <20231130164001.666702-1-michaelba@nvidia.com> <20231214151248.1654878-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: BL6PEPF0001AB4B:EE_|DS0PR12MB7679:EE_ X-MS-Office365-Filtering-Correlation-Id: feb3b6a5-d111-45bf-de25-08dbfcb7339b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p72FPqfVqDuuF0zaBtHVjrFjm0W50pVfaKxNgFsL9pAaImg2VGnTEpKWug3cAlGotR4lasMEwMlNEF0VbDZZ7owKFekTS0ln72SKsua0v52tPEqyke7GpEwcuAwTE9Z2NTpH7UqSjFBLwRoGQHhnmJGYK66YRfWfoWUgA/yFBIx2XwlktnuYPDScIYNAfBOnSOluDmEddEFpfVty7SSWhJ0pFJcJGCisT9dNYkp8c6YYOS4dYVm7DAfFXl+UhrrP9avOjVkxImLTMVIPO51SwCHIPy75g1Hp/yuLT6oDBmcbh5TZg3s9EBwmSWXifFw+o9tDQn8cMvULEi7N2e5zTFeKxtjAAhVmvBFeGyQl8yALMWNyciAD1pUyp/F7E4250sxqWR3t+NkzyGc/NrnQ+vlWM3m6ibw6UKNXjRSnHGnZ4AgIMaN2JotpB40l+nB6AIm5KCdJ+vKuPxTDQH1hDWxCJvv8cG9woLNl2Av768l9Meam4HobGoQRrEbmb3VcyeXwp64zj3R8zFuIkHBzWNnTzI0BaleYIcf6JL3P6C8NQDHAJVk87eWLno23auOPPSGSvMR8p+nqkqRcPcP5tKCmeDjaFMAKDL6IQow9IkmA78DPWeusnwE/GECaU6jJJFmqJWXceVqbbmllgo3ugRM8KBDLsw4wkOmAkDYMlF6av07SKrSZV8d/HmdzWGWZZJUwEPhpdt+LUQDij0jQJDStwiHksFmOCWX13HufgfWD2c25G87F8f1pLURBJSyV 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)(136003)(396003)(376002)(39860400002)(230922051799003)(186009)(1800799012)(64100799003)(82310400011)(451199024)(36840700001)(46966006)(40470700004)(40460700003)(7636003)(356005)(47076005)(86362001)(40480700001)(8936002)(8676002)(2906002)(5660300002)(4326008)(82740400003)(107886003)(83380400001)(36860700001)(55016003)(426003)(316002)(26005)(1076003)(2616005)(6286002)(336012)(6916009)(54906003)(70206006)(70586007)(36756003)(41300700001)(7696005)(478600001)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2023 15:13:17.6093 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: feb3b6a5-d111-45bf-de25-08dbfcb7339b 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: BL6PEPF0001AB4B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7679 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 --- 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 0b60479406..005733372a 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.c +++ b/drivers/net/mlx5/hws/mlx5dr_definer.c @@ -182,6 +182,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 */ @@ -2173,6 +2174,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, @@ -2224,6 +2252,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); @@ -2537,6 +2566,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; default: DR_LOG(ERR, "Unsupported item type %d", items->type); rte_errno = ENOTSUP; diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.h b/drivers/net/mlx5/hws/mlx5dr_definer.h index 6f1c99e37a..18591ef853 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.h +++ b/drivers/net/mlx5/hws/mlx5dr_definer.h @@ -150,6 +150,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, }; @@ -407,6 +408,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]; @@ -516,7 +522,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 6dde9de688..14311eff10 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 << 53) + /* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6) -- 2.25.1