Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4689889rwb; Tue, 17 Jan 2023 04:22:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXspbmc/y91wNszUkmccQUBQB8Ho8pPknmGf6GXNFogWOOGU4zTLfSvu9h7sFONw+rc2WZL4 X-Received: by 2002:a05:6402:5018:b0:49c:8650:1a0b with SMTP id p24-20020a056402501800b0049c86501a0bmr3250533eda.6.1673958125075; Tue, 17 Jan 2023 04:22:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673958125; cv=none; d=google.com; s=arc-20160816; b=apZz3PI6l9BLFepVPkOpA9t5eqE08UPI/SG3mKts28n9Kt9W2Nou/c4bmVLLiedWS9 mU/DXfBFLw16wPJKhYUs+pCP79MI+yMJIliVJFjSHE52uT8vjof8XJ24UUoMYxZB1RlB CQZii/6WSY+pyvbfn9Q1nRTcKIs74uGPmzNZikU3DXc6oUC7xRkP5TqGsP46Cp/EVUCB 5Ze6xFbK2jai/c7YrwHWiA2q01vu6epMetpFuKEPMx5xsy0IOXDO9x8IVBUpRJDaRgzw y6xL/dPVR8V5lAJ+1CIoYaFgRDpwPuAqsLUPMgYhrpM/yPW8FJY0AnkSWUW5U6Ff2GeH ONPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zoPU2zmqSBzAJhZ6GmrG88Td4D4zD6pTuaYSAkF7Gzc=; b=d+kkKOKYZVTYldqhcY4wDfCnoqz/rTZCZH1CuVJYgcxY60VXT7+O+3Ef7qNhG3sJGB k1c9xDLUzVyrEtXUpVxU2XV957ydGx2gO+VKuTZ+sshPEcdcDBzJp+JwUdohPGrwCpwn vm5g8cIobVL9pEIQk80RmpIUgLwwgknbi56Kq8dR34c0N3TNCJQQmh5qZUGD+BErcnw2 R585fIoC97rVaaCBYqc+MWCAXmTbIXFvukbhBlP8kGQw1BiBH/rb2k8TYtF2O2/iodcd amhk4A5cCeXXLHatXuyY6cyChxLvAcWwBrxkavjazRpjxZaRza+yNM1HtBZOhMSzTWn2 5w5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CyEJUdpm; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e16-20020a056402191000b0049d11b2a297si11861798edz.598.2023.01.17.04.21.53; Tue, 17 Jan 2023 04:22:05 -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=CyEJUdpm; 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 S236402AbjAQL7p (ORCPT + 48 others); Tue, 17 Jan 2023 06:59:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236908AbjAQL7g (ORCPT ); Tue, 17 Jan 2023 06:59:36 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 281F636FDD; Tue, 17 Jan 2023 03:59:09 -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 8BEF4612CE; Tue, 17 Jan 2023 11:59:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 851B8C433EF; Tue, 17 Jan 2023 11:59:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673956749; bh=C4DWw1lnsfHjJvgG7EN7/MBLwzOtKiOqkpCYuIalGOc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CyEJUdpmNRp0vCg9aUxD6eG2NOon+Jg4hJ1Lxm49Daa37qaahNpu1+wK/c6EB1LZq r7a6oulLUJ3AhNnHB4x1yQ6L0miJkjQ8W6kW7j2jE2H+gjJcugdZu8QcnzE/HbZ4v1 HACJ5TUyBlN/IAZ0qHng1uVw9vSqWCZxAZXcbgkhwAwBrQncAzymslz5BL8QvKbcVv L+6DODA8TSGQnnK4oV9fioc7Ib8dAt6CfJYz5a1p7sT25RphdnZiB/jIT9wJIK8QMd moqGrsy8AWobu8dPl20BmSVBSU0UicFXjLLq+ItmOdmoK05h4GUGy1RQTVkSvHltlg s18hH9FMn0v8g== Date: Tue, 17 Jan 2023 13:59:05 +0200 From: Leon Romanovsky To: Chaitanya Kulkarni Cc: Israel Rukshin , Jason Gunthorpe , Bryan Tan , Christoph Hellwig , Eric Dumazet , Jakub Kicinski , Jens Axboe , Keith Busch , "linux-kernel@vger.kernel.org" , "linux-nvme@lists.infradead.org" , "linux-rdma@vger.kernel.org" , "linux-trace-kernel@vger.kernel.org" , Masami Hiramatsu , Max Gurtovoy , "netdev@vger.kernel.org" , Paolo Abeni , Saeed Mahameed , Sagi Grimberg , Selvin Xavier , Steven Rostedt , Vishnu Dasa , Yishai Hadas Subject: Re: [PATCH rdma-next 12/13] nvme: Add crypto profile at nvme controller Message-ID: References: <52fef455-fd7a-225f-c03f-b214907ce03b@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52fef455-fd7a-225f-c03f-b214907ce03b@nvidia.com> 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > #include > > #include > > +#include > > > > #include > > > > @@ -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 >