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 E217B43B05; Tue, 13 Feb 2024 10:51:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E8C0641156; Tue, 13 Feb 2024 10:51:14 +0100 (CET) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2085.outbound.protection.outlook.com [40.107.95.85]) by mails.dpdk.org (Postfix) with ESMTP id C80C44113C for ; Tue, 13 Feb 2024 10:51:13 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SoSYc4SBZAB+oc3IXRY9g/J+bCk884+WaqdrCsX1D6a6TYsUkUQ8xLzI4jsHuHfnWozWdx8KKGzkmUPjsP4KSaQuYToSeJsyBOhlIcLxDA02+oHDrI4vLBY7F2dQTelimYHgXYwABEnwVHacjWpbFM5mV53rdZnvb4jObxXH4qswYbOTkJqtIVuMrkc0/v60w2GoucidciXI7gQMfgCR8NGAAnOPKro6mjcM6P7xSiijnLo6w0UOc4sc2AhAJUz2h3J++Gp7J1gVIeLulIjU0jEH17uzSQ4HhTyGwua7RtRxDJ8xhdOMtRt82sABapnHXBtmpuYT+MVfmMlT9clwmg== 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=9iSz6FCadzi9LsjJa53nhzHVDO3LY0bdVDsSp/lwQko=; b=MU6QqM3NZgwGayERc4qEWI6Y24ug7AKVzjluhFA8FWMg1ekYlp3/PpO0lL7eufZENzBTRyNEU0IsX2+48s1FLBa49DoYjFS7IzsEN+Sj50Q4IkcVTdb2VWxKUxpdEgnTqCTlJTBYsJS3iMhBXe69vK5OGq3kzbMKi7XrCYEn2MllLDqbHs1zETkk3wsuY6MKa92pgJuVlhD6dvr5d+EmnHd9/c5E1asbKEnh3lzePK8W7/hUPkmtV0WghPeX7Wn0jci6ISpfllDOifYP868KmVzSqFywGmj1OCpSS7ecVceTF+IUYg1bxf8cDl1EZovYnbyhnZrNkq9dfA0aqnBy2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=monjalon.net 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=9iSz6FCadzi9LsjJa53nhzHVDO3LY0bdVDsSp/lwQko=; b=eYvFTsiLn/y4oD1Cr/fQvC2KTcJjt+WLjL9DPO763wzgL6qo4aLYDOTG0Wd63I/IrJ5WZ2wVqFQ9+KbVyLnuIqntVZlk23EESyxDRmvPQKZ3Sl1MsoNGaLqF0h54COSVT3+dZNBix86BcsGbsjU34j/70nCaq4/M28ZrSac/WOKln8HmL1y5Bksn3ObNZI1qrdQDqhgxPYBQPihaWQsEMeG+vscYm/mqFzIVCDtbddLJ97mqdTiHs4fb6fiJG1T/fW4CswR/aROsCLmxszsMMYZ/I4ZYUYwUjcdhlTFTtQoRp0fcKbCa0sqpoL/cI2g+U9iDder6ENUgDkLL84uEnw== Received: from BN9PR03CA0762.namprd03.prod.outlook.com (2603:10b6:408:13a::17) by DS7PR12MB6072.namprd12.prod.outlook.com (2603:10b6:8:9c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.24; Tue, 13 Feb 2024 09:51:11 +0000 Received: from BN2PEPF0000449E.namprd02.prod.outlook.com (2603:10b6:408:13a:cafe::39) by BN9PR03CA0762.outlook.office365.com (2603:10b6:408:13a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.39 via Frontend Transport; Tue, 13 Feb 2024 09:51:11 +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 BN2PEPF0000449E.mail.protection.outlook.com (10.167.243.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Tue, 13 Feb 2024 09:51:11 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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; Tue, 13 Feb 2024 01:51:00 -0800 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 13 Feb 2024 01:51:00 -0800 Received: from nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41 via Frontend Transport; Tue, 13 Feb 2024 01:50:57 -0800 From: Itamar Gozlan To: , , , , , , , Dariusz Sosnowski , Ori Kam , Matan Azrad CC: Subject: [PATCH 4/9] net/mlx5/hws: reordering the STE fields to improve hash Date: Tue, 13 Feb 2024 11:50:32 +0200 Message-ID: <20240213095038.451299-4-igozlan@nvidia.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240213095038.451299-1-igozlan@nvidia.com> References: <20240213095038.451299-1-igozlan@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: BN2PEPF0000449E:EE_|DS7PR12MB6072:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b9281ec-914d-43ef-4776-08dc2c794f5f 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: bBxYxuXaTY/rQ306gHFqTv5uKYXtO2/sPtJxdQjYr0CCopsWRm3x9hE1IxkZ4cgcj0T6enbk6jIoiyJ1Z6DDg8aZLTbAi16Pzr1zR3AhjScUhozkUfa2n0yfhIRfs/vP8BX+D3hQ73OS71Xvs9KSGGhRwWtxfjhhyiJt8v7SYMDzfVGSEvqnnXq0YIdsbUmv5oJQOnYXcMbdxqyepAMgjoJytGr306WSXS7EqT76iANxb8gjSY2dOzNaYa2Ch6CaHf7s3MpYkGbtNHwgOpzAJz9BiCKrK4Dmcb5jOs3bJxN2fJnn6jMBs/bZ3wn0MFu0W4C8q+o96+8v7LQxuDvIvYLhjDWRpeB3/iZNl1GmwqxHuFly3cLoXBdMrP4Y+txtwZ+03drvlD2ZR8q5X+g69N3Uz6Vdj5kDvHcqJ29v0Q/Bm4zR4d93Mw7Tcaf9EMmCpB7pGmUVMFboW9tMXsdywT0GkWVye3TmOE75f7QI1guF71zxiIcZzqgEkKVlhzZr2S/EfmdAX87Tj85F40ONsCA/jnuKEh6iGunIao/G4jv1+ou7mEczN0O8Avr3iWSPyNgQHCP4dqthksSE2h82Of+7Wj6CIUT9t0LfHrHKB7u0SSz5KLeXbDTdnQvCzC3AydbokbArQn9ldyi+tPTWzA== 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)(376002)(136003)(39860400002)(396003)(230922051799003)(1800799012)(82310400011)(64100799003)(186009)(451199024)(36840700001)(40470700004)(46966006)(8936002)(8676002)(41300700001)(2906002)(5660300002)(55016003)(4326008)(921011)(83380400001)(7636003)(86362001)(356005)(36756003)(2616005)(1076003)(426003)(7696005)(110136005)(70206006)(6666004)(6286002)(336012)(70586007)(316002)(82740400003)(6636002)(478600001)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2024 09:51:11.1889 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6b9281ec-914d-43ef-4776-08dc2c794f5f 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: BN2PEPF0000449E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6072 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 Inserting two rules with the same hash calculation result into the same matcher will cause collisions, which can cause degradation in PPS. Changing the order of some fields in the STE can change the hash result, and doing this for every value would give us a different hash distribution for the inputs. By using precomputed optimal DW locations, we can change the STE order for a limited set of the most common values to reduce the number of hash collisions and improve latency. Signed-off-by: Itamar Gozlan Acked-by: Matan Azrad --- drivers/net/mlx5/hws/mlx5dr_definer.c | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.c b/drivers/net/mlx5/hws/mlx5dr_definer.c index e564062313..eb788a772a 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.c +++ b/drivers/net/mlx5/hws/mlx5dr_definer.c @@ -100,6 +100,33 @@ __mlx5_dw_off(typ, fld))) >> __mlx5_dw_bit_off(typ, fld)) & \ __mlx5_mask(typ, fld)) +#define MAX_ROW_LOG 31 + +enum header_layout { + MLX5DR_HL_IPV4_SRC = 64, + MLX5DR_HL_IPV4_DST = 65, + MAX_HL_PRIO, +}; + +/* Each row (i) indicates a different matcher size, and each column (j) + * represents {DW5, DW4, DW3, DW2, DW1, DW0}. + * For values 0,..,2^i, and j (DW) 0,..,5: optimal_dist_dw[i][j] is 1 if the + * number of different hash results on these values equals 2^i, meaning this + * DW hash distribution is complete. + */ +int optimal_dist_dw[MAX_ROW_LOG][DW_SELECTORS_MATCH] = { + {1, 1, 1, 1, 1, 1}, {0, 1, 1, 0, 1, 0}, {0, 1, 1, 0, 1, 0}, + {1, 0, 1, 0, 1, 0}, {0, 0, 0, 1, 1, 0}, {0, 1, 1, 0, 1, 0}, + {0, 0, 0, 0, 1, 0}, {0, 1, 1, 0, 1, 0}, {0, 0, 0, 0, 0, 0}, + {1, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 1, 0, 1, 0, 0}, + {1, 0, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 1}, {1, 1, 1, 0, 0, 0}, + {1, 1, 1, 0, 1, 0}, {0, 0, 1, 1, 0, 0}, {0, 1, 1, 0, 0, 1}, + {0, 0, 1, 0, 0, 1}, {0, 0, 1, 0, 0, 0}, {1, 0, 1, 1, 0, 0}, + {1, 0, 1, 0, 0, 1}, {0, 0, 1, 1, 0, 1}, {1, 1, 1, 0, 0, 0}, + {0, 1, 0, 1, 0, 1}, {0, 0, 0, 0, 0, 1}, {0, 0, 0, 1, 1, 1}, + {0, 0, 1, 0, 0, 1}, {1, 1, 0, 1, 1, 0}, {0, 0, 0, 0, 1, 0}, + {0, 0, 0, 1, 1, 0}}; + struct mlx5dr_definer_sel_ctrl { uint8_t allowed_full_dw; /* Full DW selectors cover all offsets */ uint8_t allowed_lim_dw; /* Limited DW selectors cover offset < 64 */ @@ -3185,6 +3212,37 @@ mlx5dr_definer_find_best_range_fit(struct mlx5dr_definer *definer, return rte_errno; } +static void mlx5dr_definer_optimize_order(struct mlx5dr_definer *definer, int num_log) +{ + uint8_t hl_prio[MAX_HL_PRIO - 1] = {MLX5DR_HL_IPV4_SRC, + MLX5DR_HL_IPV4_DST, + MAX_HL_PRIO}; + int dw = 0, i = 0, j; + int *dw_flag; + uint8_t tmp; + + dw_flag = optimal_dist_dw[num_log]; + + while (hl_prio[i] != MAX_HL_PRIO) { + j = 0; + /* Finding a candidate to improve its hash distribution */ + while (j < DW_SELECTORS_MATCH && (hl_prio[i] != definer->dw_selector[j])) + j++; + + /* Finding a DW location with good hash distribution */ + while (dw < DW_SELECTORS_MATCH && dw_flag[dw] == 0) + dw++; + + if (dw < DW_SELECTORS_MATCH && j < DW_SELECTORS_MATCH) { + tmp = definer->dw_selector[dw]; + definer->dw_selector[dw] = definer->dw_selector[j]; + definer->dw_selector[j] = tmp; + dw++; + } + i++; + } +} + static int mlx5dr_definer_find_best_match_fit(struct mlx5dr_context *ctx, struct mlx5dr_definer *definer, @@ -3355,6 +3413,12 @@ mlx5dr_definer_calc_layout(struct mlx5dr_matcher *matcher, goto free_fc; } + if (!mlx5dr_definer_is_jumbo(match_definer) && + !mlx5dr_matcher_req_fw_wqe(matcher) && + !mlx5dr_matcher_is_resizable(matcher) && + !mlx5dr_matcher_is_insert_by_idx(matcher)) + mlx5dr_definer_optimize_order(match_definer, matcher->attr.rule.num_log); + /* Find the range definer layout for match templates fcrs */ ret = mlx5dr_definer_find_best_range_fit(range_definer, matcher); if (ret) { -- 2.39.3