linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Avri Altman <Avri.Altman@wdc.com>
To: Satya Tangirala <satyat@google.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	Alim Akhtar <alim.akhtar@samsung.com>
Cc: Barani Muthukumaran <bmuthuku@qti.qualcomm.com>,
	Kuohong Wang <kuohong.wang@mediatek.com>,
	Kim Boojin <boojin.kim@samsung.com>,
	Eric Biggers <ebiggers@google.com>,
	Stanley Chu <stanley.chu@mediatek.com>
Subject: RE: [PATCH v4 2/3] scsi: ufs: UFS crypto API
Date: Wed, 8 Jul 2020 07:44:28 +0000	[thread overview]
Message-ID: <SN6PR04MB4640E8B9BB10FD5A5C2740D1FC670@SN6PR04MB4640.namprd04.prod.outlook.com> (raw)
In-Reply-To: <20200706200414.2027450-3-satyat@google.com>

> +
> +static enum blk_crypto_mode_num
> +ufshcd_find_blk_crypto_mode(union ufs_crypto_cap_entry cap)
> +{
> +       int i;
> +
> +       for (i = 0; i < ARRAY_SIZE(ufs_crypto_algs); i++) {
> +               BUILD_BUG_ON(UFS_CRYPTO_KEY_SIZE_INVALID != 0);
> +               if (ufs_crypto_algs[i].ufs_alg == cap.algorithm_id &&
> +                   ufs_crypto_algs[i].ufs_key_size == cap.key_size) {
> +                       return i;
> +               }
> +       }
> +       return BLK_ENCRYPTION_MODE_INVALID;
BLK_ENCRYPTION_MODE_INVALID is 0, but 0 is a valid mode num?

> +}
> +
> +/**
> + * ufshcd_hba_init_crypto_capabilities - Read crypto capabilities, init crypto
> + *                                      fields in hba
> + * @hba: Per adapter instance
> + *
> + * Return: 0 if crypto was initialized or is not supported, else a -errno value.
> + */
> +int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba)
> +{
> +       int cap_idx;
> +       int err = 0;
> +       enum blk_crypto_mode_num blk_mode_num;
> +
> +       /*
> +        * Don't use crypto if either the hardware doesn't advertise the
> +        * standard crypto capability bit *or* if the vendor specific driver
> +        * hasn't advertised that crypto is supported.
> +        */
> +       if (!(hba->capabilities & MASK_CRYPTO_SUPPORT) ||
> +           !(hba->caps & UFSHCD_CAP_CRYPTO))
> +               goto out;
> +
> +       hba->crypto_capabilities.reg_val =
> +                       cpu_to_le32(ufshcd_readl(hba, REG_UFS_CCAP));
> +       hba->crypto_cfg_register =
> +               (u32)hba->crypto_capabilities.config_array_ptr * 0x100;
This deserve a comment, e.g. 
UFSHCI says:
The address for entry x of the x-CRYPTOCFG array is calculated as follows:
ADDR (x-CRYPTOCFG) = UFS_HCI_BASE + CFGPTR*100h + x*80h


  reply	other threads:[~2020-07-08  7:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200706200432epcas5p1d276cdebadfecc3984de37a80c4b19f2@epcas5p1.samsung.com>
2020-07-06 20:04 ` [PATCH v4 0/3] Inline Encryption Support for UFS Satya Tangirala
2020-07-06 20:04   ` [PATCH v4 1/3] scsi: ufs: UFS driver v2.1 spec crypto additions Satya Tangirala
2020-07-06 20:04   ` [PATCH v4 2/3] scsi: ufs: UFS crypto API Satya Tangirala
2020-07-08  7:44     ` Avri Altman [this message]
2020-07-08 16:00       ` Eric Biggers
2020-07-06 20:04   ` [PATCH v4 3/3] scsi: ufs: Add inline encryption support to UFS Satya Tangirala
2020-07-07  0:13   ` [PATCH v4 0/3] Inline Encryption Support for UFS Eric Biggers
2020-07-08  7:46     ` Avri Altman
2020-07-07 17:36   ` Alim Akhtar
2020-07-07 17:59     ` Eric Biggers
2020-07-08  6:06   ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SN6PR04MB4640E8B9BB10FD5A5C2740D1FC670@SN6PR04MB4640.namprd04.prod.outlook.com \
    --to=avri.altman@wdc.com \
    --cc=alim.akhtar@samsung.com \
    --cc=bmuthuku@qti.qualcomm.com \
    --cc=boojin.kim@samsung.com \
    --cc=ebiggers@google.com \
    --cc=kuohong.wang@mediatek.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=satyat@google.com \
    --cc=stanley.chu@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).