All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: John Garry <john.garry@huawei.com>
Cc: jejb@linux.vnet.ibm.com, martin.petersen@oracle.com,
	linuxarm@huawei.com, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org,
	Xiang Chen <chenxiang66@hisilicon.com>
Subject: Re: [PATCH v4 4/5] scsi: hisi_sas: Add support for DIF feature for v3 hw
Date: Wed, 12 Dec 2018 21:20:17 -0500	[thread overview]
Message-ID: <yq1o99qgobi.fsf@oracle.com> (raw)
In-Reply-To: <1544103284-100497-5-git-send-email-john.garry@huawei.com> (John Garry's message of "Thu, 6 Dec 2018 21:34:43 +0800")


John,

> +static void fill_prot_v3_hw(struct scsi_cmnd *scsi_cmnd,
> +			    struct hisi_sas_protect_iu_v3_hw *prot)
> +{
> +	u8 prot_type = scsi_get_prot_type(scsi_cmnd);
> +	u8 prot_op = scsi_get_prot_op(scsi_cmnd);
> +	unsigned int interval = scsi_prot_interval(scsi_cmnd);
> +	u32 lbrt_chk_val;
> +
> +	if (interval == 4096)
> +		lbrt_chk_val = (u32)(scsi_get_lba(scsi_cmnd) >> 3);
> +	else
> +		lbrt_chk_val = (u32)scsi_get_lba(scsi_cmnd);

lbrt_chk_val = t10_pi_ref_tag(scmd->request);

> +
> +	switch (prot_op) {
> +	case SCSI_PROT_READ_STRIP:
> +		prot->dw0 |= (T10_RMV_EN_MSK | T10_CHK_EN_MSK);
> +		prot->lbrtcv = lbrt_chk_val;
> +		if (prot_type == SCSI_PROT_DIF_TYPE1)
> +			prot->dw4 |= (0xc << 16);
> +		else if (prot_type == SCSI_PROT_DIF_TYPE3)
> +			prot->dw4 |= (0xfc << 16);

We're moving away from prot_type. You should use:

enum scsi_prot_flags {
        SCSI_PROT_TRANSFER_PI           = 1 << 0,
        SCSI_PROT_GUARD_CHECK           = 1 << 1,
        SCSI_PROT_REF_CHECK             = 1 << 2,
        SCSI_PROT_REF_INCREMENT         = 1 << 3,
        SCSI_PROT_IP_CHECKSUM           = 1 << 4,
};

to set your controller flags.

+		if (prot_op == SCSI_PROT_WRITE_INSERT) {
+			unsigned int interval = scsi_prot_interval(scsi_cmnd);
+			unsigned int ilog2_interval = ilog2(interval);
+
+			len = (task->total_xfer_len >> ilog2_interval) * 8;

scsi_transfer_length(struct scsi_cmnd *scmd)

> +	if (hisi_hba->enable_dif) {
> +		dev_info(dev, "Registering for DIF type 1/2/3 protection.\n");
> +		prot |=	SHOST_DIF_TYPE1_PROTECTION |
> +			SHOST_DIF_TYPE2_PROTECTION |
> +			SHOST_DIF_TYPE3_PROTECTION;
> +	}
> +
> +	scsi_host_set_prot(hisi_hba->shost, prot);

I'm not so keen on this enable_dif/enable_dix business in module
parameters. I suggest you just allow the user to specify the host
protection mask instead of having a layer of indirection.

-- 
Martin K. Petersen	Oracle Linux Engineering

WARNING: multiple messages have this Message-ID (diff)
From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: John Garry <john.garry@huawei.com>
Cc: <jejb@linux.vnet.ibm.com>, <martin.petersen@oracle.com>,
	<linuxarm@huawei.com>, <linux-kernel@vger.kernel.org>,
	<linux-scsi@vger.kernel.org>,
	Xiang Chen <chenxiang66@hisilicon.com>
Subject: Re: [PATCH v4 4/5] scsi: hisi_sas: Add support for DIF feature for v3 hw
Date: Wed, 12 Dec 2018 21:20:17 -0500	[thread overview]
Message-ID: <yq1o99qgobi.fsf@oracle.com> (raw)
In-Reply-To: <1544103284-100497-5-git-send-email-john.garry@huawei.com> (John Garry's message of "Thu, 6 Dec 2018 21:34:43 +0800")


John,

> +static void fill_prot_v3_hw(struct scsi_cmnd *scsi_cmnd,
> +			    struct hisi_sas_protect_iu_v3_hw *prot)
> +{
> +	u8 prot_type = scsi_get_prot_type(scsi_cmnd);
> +	u8 prot_op = scsi_get_prot_op(scsi_cmnd);
> +	unsigned int interval = scsi_prot_interval(scsi_cmnd);
> +	u32 lbrt_chk_val;
> +
> +	if (interval == 4096)
> +		lbrt_chk_val = (u32)(scsi_get_lba(scsi_cmnd) >> 3);
> +	else
> +		lbrt_chk_val = (u32)scsi_get_lba(scsi_cmnd);

lbrt_chk_val = t10_pi_ref_tag(scmd->request);

> +
> +	switch (prot_op) {
> +	case SCSI_PROT_READ_STRIP:
> +		prot->dw0 |= (T10_RMV_EN_MSK | T10_CHK_EN_MSK);
> +		prot->lbrtcv = lbrt_chk_val;
> +		if (prot_type == SCSI_PROT_DIF_TYPE1)
> +			prot->dw4 |= (0xc << 16);
> +		else if (prot_type == SCSI_PROT_DIF_TYPE3)
> +			prot->dw4 |= (0xfc << 16);

We're moving away from prot_type. You should use:

enum scsi_prot_flags {
        SCSI_PROT_TRANSFER_PI           = 1 << 0,
        SCSI_PROT_GUARD_CHECK           = 1 << 1,
        SCSI_PROT_REF_CHECK             = 1 << 2,
        SCSI_PROT_REF_INCREMENT         = 1 << 3,
        SCSI_PROT_IP_CHECKSUM           = 1 << 4,
};

to set your controller flags.

+		if (prot_op == SCSI_PROT_WRITE_INSERT) {
+			unsigned int interval = scsi_prot_interval(scsi_cmnd);
+			unsigned int ilog2_interval = ilog2(interval);
+
+			len = (task->total_xfer_len >> ilog2_interval) * 8;

scsi_transfer_length(struct scsi_cmnd *scmd)

> +	if (hisi_hba->enable_dif) {
> +		dev_info(dev, "Registering for DIF type 1/2/3 protection.\n");
> +		prot |=	SHOST_DIF_TYPE1_PROTECTION |
> +			SHOST_DIF_TYPE2_PROTECTION |
> +			SHOST_DIF_TYPE3_PROTECTION;
> +	}
> +
> +	scsi_host_set_prot(hisi_hba->shost, prot);

I'm not so keen on this enable_dif/enable_dix business in module
parameters. I suggest you just allow the user to specify the host
protection mask instead of having a layer of indirection.

-- 
Martin K. Petersen	Oracle Linux Engineering

  reply	other threads:[~2018-12-13  2:20 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-06 13:34 [PATCH v4 0/5] hisi_sas: DIF support John Garry
2018-12-06 13:34 ` John Garry
2018-12-06 13:34 ` [PATCH v4 1/5] scsi: hisi_sas: Fix warnings detected by sparse John Garry
2018-12-06 13:34   ` John Garry
2018-12-06 13:34 ` [PATCH v4 2/5] scsi: hisi_sas: Relocate some code to reduce complexity John Garry
2018-12-06 13:34   ` John Garry
2018-12-06 14:17   ` Johannes Thumshirn
2018-12-06 15:37     ` John Garry
2018-12-06 15:37       ` John Garry
2018-12-06 16:20       ` Johannes Thumshirn
2018-12-07 10:07         ` John Garry
2018-12-07 10:07           ` John Garry
2018-12-07 10:53           ` Johannes Thumshirn
2018-12-06 13:34 ` [PATCH v4 3/5] scsi: hisi_sas: Make sg_tablesize consistent value John Garry
2018-12-06 13:34   ` John Garry
2018-12-06 13:34 ` [PATCH v4 4/5] scsi: hisi_sas: Add support for DIF feature for v3 hw John Garry
2018-12-06 13:34   ` John Garry
2018-12-13  2:20   ` Martin K. Petersen [this message]
2018-12-13  2:20     ` Martin K. Petersen
2018-12-13 13:35     ` John Garry
2018-12-13 13:35       ` John Garry
2018-12-17 14:51       ` John Garry
2018-12-17 14:51         ` John Garry
2018-12-18  3:31         ` Martin K. Petersen
2018-12-18  3:31           ` Martin K. Petersen
2018-12-06 13:34 ` [RFC PATCH v4 5/5] scsi: hisi_sas: Add support for DIX feature for v3 hw as experimental John Garry
2018-12-06 13:34   ` John Garry
2018-12-13  2:23 ` [PATCH v4 0/5] hisi_sas: DIF support Martin K. Petersen
2018-12-13  2:23   ` 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=yq1o99qgobi.fsf@oracle.com \
    --to=martin.petersen@oracle.com \
    --cc=chenxiang66@hisilicon.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=john.garry@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linuxarm@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.