From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D238C636D4 for ; Tue, 31 Jan 2023 03:13:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229542AbjAaDNF (ORCPT ); Mon, 30 Jan 2023 22:13:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230324AbjAaDMo (ORCPT ); Mon, 30 Jan 2023 22:12:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EB5938EBC for ; Mon, 30 Jan 2023 19:12:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5832D61381 for ; Tue, 31 Jan 2023 03:12:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9831C433D2; Tue, 31 Jan 2023 03:12:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675134740; bh=luS0tx8G7HuGM1jwx0YHas0NSy3Na3MNDqESCB0LL4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I5ieD52KSv/apWzPA5NumGMJmsn6/JvjaqQup++4Tj+s67kViDL1Fh157rTCI9uME 1uSZBDYXWj+SeYLuqgCggyKmp/KaxRTb22TFCVLZDCvWA+FelXBQ3SzPxk1jJmRD6C taG14SHs8H8+Lebk7MqLvL1fuVsw/YcbjLMSW1YbFhY1mYWOL5U9Dp896GLLjPiVUE oNqGpS1gWxLFHuNGKf5Y2LsXNPqcUiKdzIUew+pEEp2LAC7CYH5C6+2unm1eJ1o7jP X7cEWSShZjwa1PlgSTf+kZM1PwAnfWEN8R6yVcibdcMApuu5TIzI0EzxrRqCd65hX4 vKcrv8CAguJYw== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Jianbo Liu Subject: [net-next 14/15] net/mlx5: Keep only one bulk of full available DEKs Date: Mon, 30 Jan 2023 19:12:00 -0800 Message-Id: <20230131031201.35336-15-saeed@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230131031201.35336-1-saeed@kernel.org> References: <20230131031201.35336-1-saeed@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jianbo Liu One bulk with full available keys is left undestroyed, to service the possible requests from users quickly. Signed-off-by: Jianbo Liu Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- .../ethernet/mellanox/mlx5/core/lib/crypto.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/crypto.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/crypto.c index e078530ef37d..3a94b8f8031e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/crypto.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/crypto.c @@ -506,12 +506,19 @@ static void mlx5_crypto_dek_bulk_reset_synced(struct mlx5_crypto_dek_pool *pool, } } -static void mlx5_crypto_dek_bulk_handle_avail(struct mlx5_crypto_dek_pool *pool, +/* Return true if the bulk is reused, false if destroyed with delay */ +static bool mlx5_crypto_dek_bulk_handle_avail(struct mlx5_crypto_dek_pool *pool, struct mlx5_crypto_dek_bulk *bulk, struct list_head *destroy_list) { + if (list_empty(&pool->avail_list)) { + list_move(&bulk->entry, &pool->avail_list); + return true; + } + mlx5_crypto_dek_pool_remove_bulk(pool, bulk, true); list_add(&bulk->entry, destroy_list); + return false; } static void mlx5_crypto_dek_pool_splice_destroy_list(struct mlx5_crypto_dek_pool *pool, @@ -535,7 +542,7 @@ static void mlx5_crypto_dek_pool_free_wait_keys(struct mlx5_crypto_dek_pool *poo /* For all the bulks in each list, reset the bits while sync. * Move them to different lists according to the number of available DEKs. - * Destrory all the idle bulks for now. + * Destrory all the idle bulks, except one for quick service. * And free DEKs in the waiting list at the end of this func. */ static void mlx5_crypto_dek_pool_reset_synced(struct mlx5_crypto_dek_pool *pool) @@ -562,11 +569,12 @@ static void mlx5_crypto_dek_pool_reset_synced(struct mlx5_crypto_dek_pool *pool) } list_for_each_entry_safe(bulk, tmp, &pool->sync_list, entry) { - memset(bulk->need_sync, 0, BITS_TO_BYTES(bulk->num_deks)); - bulk->avail_start = 0; bulk->avail_deks = bulk->num_deks; pool->avail_deks += bulk->num_deks; - mlx5_crypto_dek_bulk_handle_avail(pool, bulk, &destroy_list); + if (mlx5_crypto_dek_bulk_handle_avail(pool, bulk, &destroy_list)) { + memset(bulk->need_sync, 0, BITS_TO_BYTES(bulk->num_deks)); + bulk->avail_start = 0; + } } mlx5_crypto_dek_pool_free_wait_keys(pool); -- 2.39.1