Message ID | efc8dc5952baa096a14db1761f84a5ab2e76654a.1673873422.git.leon@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1183476wrn; Mon, 16 Jan 2023 05:11:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXvbMV8A9tIz9arTBMakq2SLLmarR9zq+93KYMynYiUx0ea5Dx+Yt0juNv7KauWlrXG/badK X-Received: by 2002:a05:6402:f01:b0:49e:1d59:7942 with SMTP id i1-20020a0564020f0100b0049e1d597942mr2165300eda.13.1673874703835; Mon, 16 Jan 2023 05:11:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673874703; cv=none; d=google.com; s=arc-20160816; b=vp9/bX8zQ7vMu2JlEcjlZKNGwFNEgtlo+W/kDoO4ND4tWvf8gfJome4kRcv9D7RJxF jkRiM+OIo7T7zIYZ/TUi3ZGipY3wypvUW8+RJisgnQ1g2xIIAmyGqHZTc0AsSpGi+1wF sHqry1zyA3qhO/H6OdNLaUYwLEgHkilUa8q2dLIJKpJuaLlxEMlgFvQEC0c29dPZH5QB LyqL/54TLRMiDZrHDXP2nUNe0KWyQ4aLy1RoMT1KqzWTgLUcGlWGpxAlgka+wm9CNVLQ IuGisLd7wnVCe2xqTJFaUiD2qCzqWbu0tQjovfmOeeRwcs2f4esdBnC9KXf0Xu4iRDJ2 FxcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GHboVp4/n8dg/1mTqeVNMq07d7i55rvCp5cMprWstb8=; b=09MaEvV9MULMrTYHrUcvfpPOeBe9lq19gE4kv6ntUfbC85BuKnsCp+o65mCytcrDxR fRwR43wFGq4xI8qRqCcTwFkgPj3X1ejbM7Y3bCKmvTbKhvZZ7HOqJ6b+8HgTWidP8Od6 mx2dNl2dDgX2M/3bDIPuelLr9nCAnqrtgsFFKasdw9KPY/tdPW9a3GvQ9XyxkhdgSKha eYRHMnYQGBKPhy/tOyc2bI9a+tzCoCednrWQRSEwo7xy58JbEsWh3a0JcA/SiFMBsf40 FNCvdWaRg0T3mp2H31Iw4D5m+FgLAYMUpAYsOxDKGqlkBYUW+GiTww3csTGmplmIGItN xK3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OPeQnGdM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v2-20020a056402348200b0049e29ce0a51si560279edc.17.2023.01.16.05.11.20; Mon, 16 Jan 2023 05:11:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OPeQnGdM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231518AbjAPNHg (ORCPT <rfc822;stefanalexe802@gmail.com> + 99 others); Mon, 16 Jan 2023 08:07:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231420AbjAPNHB (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 16 Jan 2023 08:07:01 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAA661710; Mon, 16 Jan 2023 05:07:00 -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 645F660F9B; Mon, 16 Jan 2023 13:07:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA0DFC433F1; Mon, 16 Jan 2023 13:06:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673874419; bh=Z9+KomyeN4vAjModCpaAbKOjkyqP4m8dRccCmgRLn8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OPeQnGdMKL0qvPIWYWzLqm//vIJ6xVrQ+zSrw9NRNMJnbSzuJa9VEEYupUejVnt06 HRNhIbjJVVOzzBSXSeoUjnDrYIDLqtF3CjSOmEgHFu37MIVWOwUbq/DFyGfdnJ++Yg BvhvBUhhKztQYlOb92vy7VS8Uiq44148kyxwVg4auh30C5QonsBIXdBs6dnWQlVAaH p/08idib6ImCyqQwz1xJ8CyMsMgn2pwOnLcSRdNel6waQkTHTGQTYUJsOWFJsf4Ywz ++JUX3bjsvRlVxxLqSrPNBs7farZKtwyKf2xjpumDEoLbmQvbxXcM2CM0TkhY3sduc 8JxubTZg4TsUw== From: Leon Romanovsky <leon@kernel.org> To: Jason Gunthorpe <jgg@nvidia.com> Cc: Israel Rukshin <israelr@nvidia.com>, Bryan Tan <bryantan@vmware.com>, Christoph Hellwig <hch@lst.de>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Jens Axboe <axboe@fb.com>, Keith Busch <kbusch@kernel.org>, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Masami Hiramatsu <mhiramat@kernel.org>, Max Gurtovoy <mgurtovoy@nvidia.com>, netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>, Saeed Mahameed <saeedm@nvidia.com>, Sagi Grimberg <sagi@grimberg.me>, Selvin Xavier <selvin.xavier@broadcom.com>, Steven Rostedt <rostedt@goodmis.org>, Vishnu Dasa <vdasa@vmware.com>, Yishai Hadas <yishaih@nvidia.com> Subject: [PATCH rdma-next 12/13] nvme: Add crypto profile at nvme controller Date: Mon, 16 Jan 2023 15:05:59 +0200 Message-Id: <efc8dc5952baa096a14db1761f84a5ab2e76654a.1673873422.git.leon@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <cover.1673873422.git.leon@kernel.org> References: <cover.1673873422.git.leon@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755184840958355766?= X-GMAIL-MSGID: =?utf-8?q?1755184840958355766?= |
Series |
Add RDMA inline crypto support
|
|
Commit Message
Leon Romanovsky
Jan. 16, 2023, 1:05 p.m. UTC
From: Israel Rukshin <israelr@nvidia.com> The crypto profile will be filled by the transport drivers. This is a preparation patch for adding support of inline encryption at nvme-rdma driver. Signed-off-by: Israel Rukshin <israelr@nvidia.com> Signed-off-by: Leon Romanovsky <leon@kernel.org> --- drivers/nvme/host/core.c | 3 +++ drivers/nvme/host/nvme.h | 4 ++++ 2 files changed, 7 insertions(+)
Comments
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > index 51a9880db6ce..f09e4e0216b3 100644 > --- a/drivers/nvme/host/core.c > +++ b/drivers/nvme/host/core.c > @@ -1928,6 +1928,9 @@ static void nvme_update_disk_info(struct gendisk *disk, > capacity = 0; > } > > + if (ctrl->crypto_enable) > + blk_crypto_register(&ctrl->crypto_profile, disk->queue); > + > set_capacity_and_notify(disk, capacity); > > nvme_config_discard(disk, ns); > diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h > index 424c8a467a0c..591380f53744 100644 > --- a/drivers/nvme/host/nvme.h > +++ b/drivers/nvme/host/nvme.h > @@ -16,6 +16,7 @@ > #include <linux/rcupdate.h> > #include <linux/wait.h> > #include <linux/t10-pi.h> > +#include <linux/blk-crypto-profile.h> > > #include <trace/events/block.h> > > @@ -374,6 +375,9 @@ struct nvme_ctrl { > > enum nvme_ctrl_type cntrltype; > enum nvme_dctype dctype; > + > + bool crypto_enable; why not decalre crypto_profile a pointer, allocate that at init controller and NULL check against that pointer instead of using an extra variable crypto_enable ? e.g. :- if (ctrl->crypto_profile) blk_crypto_register(ctrl->crypto_profile, disk->queue); > + struct blk_crypto_profile crypto_profile; you are increasing the size of struct nvme_ctrl unconditionally, why not guard above with CONFIG_BLK_INLINE_ENCRYPTION ? -ck
On Tue, Jan 17, 2023 at 12:31:22AM +0000, Chaitanya Kulkarni wrote: > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > > index 51a9880db6ce..f09e4e0216b3 100644 > > --- a/drivers/nvme/host/core.c > > +++ b/drivers/nvme/host/core.c > > @@ -1928,6 +1928,9 @@ static void nvme_update_disk_info(struct gendisk *disk, > > capacity = 0; > > } > > > > + if (ctrl->crypto_enable) > > + blk_crypto_register(&ctrl->crypto_profile, disk->queue); > > + > > set_capacity_and_notify(disk, capacity); > > > > nvme_config_discard(disk, ns); > > diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h > > index 424c8a467a0c..591380f53744 100644 > > --- a/drivers/nvme/host/nvme.h > > +++ b/drivers/nvme/host/nvme.h > > @@ -16,6 +16,7 @@ > > #include <linux/rcupdate.h> > > #include <linux/wait.h> > > #include <linux/t10-pi.h> > > +#include <linux/blk-crypto-profile.h> > > > > #include <trace/events/block.h> > > > > @@ -374,6 +375,9 @@ struct nvme_ctrl { > > > > enum nvme_ctrl_type cntrltype; > > enum nvme_dctype dctype; > > + > > + bool crypto_enable; > > why not decalre crypto_profile a pointer, allocate that at init > controller and NULL check against that pointer instead of using > an extra variable crypto_enable ? The embedded struct allows us to rely on container_of() macro. 377 static int nvme_rdma_crypto_keyslot_program(struct blk_crypto_profile *profile, 378 const struct blk_crypto_key *key, 379 unsigned int slot) 380 { 381 struct nvme_ctrl *nctrl = 382 container_of(profile, struct nvme_ctrl, crypto_profile); > > e.g. :- > > if (ctrl->crypto_profile) > blk_crypto_register(ctrl->crypto_profile, disk->queue); > > > + struct blk_crypto_profile crypto_profile; > > you are increasing the size of struct nvme_ctrl unconditionally, > why not guard above with CONFIG_BLK_INLINE_ENCRYPTION ? We can do it. Thanks > > -ck >
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 51a9880db6ce..f09e4e0216b3 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1928,6 +1928,9 @@ static void nvme_update_disk_info(struct gendisk *disk, capacity = 0; } + if (ctrl->crypto_enable) + blk_crypto_register(&ctrl->crypto_profile, disk->queue); + set_capacity_and_notify(disk, capacity); nvme_config_discard(disk, ns); diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 424c8a467a0c..591380f53744 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -16,6 +16,7 @@ #include <linux/rcupdate.h> #include <linux/wait.h> #include <linux/t10-pi.h> +#include <linux/blk-crypto-profile.h> #include <trace/events/block.h> @@ -374,6 +375,9 @@ struct nvme_ctrl { enum nvme_ctrl_type cntrltype; enum nvme_dctype dctype; + + bool crypto_enable; + struct blk_crypto_profile crypto_profile; }; enum nvme_iopolicy {