From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: linux-scsi@vger.kernel.org
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Subject: [PATCH 03/15] scsi: qla2xxx: Use the proper SCSI midlayer interfaces for PI
Date: Tue, 8 Jun 2021 23:39:17 -0400 [thread overview]
Message-ID: <20210609033929.3815-4-martin.petersen@oracle.com> (raw)
In-Reply-To: <20210609033929.3815-1-martin.petersen@oracle.com>
Use the SCSI midlayer interfaces to query protection interval,
reference tag, and per-command DIX flags.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
drivers/scsi/qla2xxx/qla_iocb.c | 84 ++++++---------------------------
1 file changed, 15 insertions(+), 69 deletions(-)
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 38b5bdde2405..42a6fbba7529 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -145,7 +145,6 @@ inline int
qla24xx_configure_prot_mode(srb_t *sp, uint16_t *fw_prot_opts)
{
struct scsi_cmnd *cmd = GET_CMD_SP(sp);
- uint8_t guard = scsi_host_get_guard(cmd->device->host);
/* We always use DIFF Bundling for best performance */
*fw_prot_opts = 0;
@@ -166,7 +165,7 @@ qla24xx_configure_prot_mode(srb_t *sp, uint16_t *fw_prot_opts)
break;
case SCSI_PROT_READ_PASS:
case SCSI_PROT_WRITE_PASS:
- if (guard & SHOST_DIX_GUARD_IP)
+ if (cmd->prot_flags & SCSI_PROT_IP_CHECKSUM)
*fw_prot_opts |= PO_MODE_DIF_TCP_CKSUM;
else
*fw_prot_opts |= PO_MODE_DIF_PASS;
@@ -176,6 +175,9 @@ qla24xx_configure_prot_mode(srb_t *sp, uint16_t *fw_prot_opts)
break;
}
+ if (!(cmd->prot_flags & SCSI_PROT_GUARD_CHECK))
+ *fw_prot_opts |= PO_DISABLE_GUARD_CHECK;
+
return scsi_prot_sg_count(cmd);
}
@@ -772,74 +774,18 @@ qla24xx_set_t10dif_tags(srb_t *sp, struct fw_dif_context *pkt,
{
struct scsi_cmnd *cmd = GET_CMD_SP(sp);
- switch (scsi_get_prot_type(cmd)) {
- case SCSI_PROT_DIF_TYPE0:
- /*
- * No check for ql2xenablehba_err_chk, as it would be an
- * I/O error if hba tag generation is not done.
- */
- pkt->ref_tag = cpu_to_le32((uint32_t)
- (0xffffffff & scsi_get_lba(cmd)));
-
- if (!qla2x00_hba_err_chk_enabled(sp))
- break;
-
- pkt->ref_tag_mask[0] = 0xff;
- pkt->ref_tag_mask[1] = 0xff;
- pkt->ref_tag_mask[2] = 0xff;
- pkt->ref_tag_mask[3] = 0xff;
- break;
-
- /*
- * For TYPE 2 protection: 16 bit GUARD + 32 bit REF tag has to
- * match LBA in CDB + N
- */
- case SCSI_PROT_DIF_TYPE2:
- pkt->app_tag = cpu_to_le16(0);
- pkt->app_tag_mask[0] = 0x0;
- pkt->app_tag_mask[1] = 0x0;
-
- pkt->ref_tag = cpu_to_le32((uint32_t)
- (0xffffffff & scsi_get_lba(cmd)));
+ pkt->ref_tag = cpu_to_le32(scsi_prot_ref_tag(cmd));
- if (!qla2x00_hba_err_chk_enabled(sp))
- break;
-
- /* enable ALL bytes of the ref tag */
- pkt->ref_tag_mask[0] = 0xff;
- pkt->ref_tag_mask[1] = 0xff;
- pkt->ref_tag_mask[2] = 0xff;
- pkt->ref_tag_mask[3] = 0xff;
- break;
-
- /* For Type 3 protection: 16 bit GUARD only */
- case SCSI_PROT_DIF_TYPE3:
- pkt->ref_tag_mask[0] = pkt->ref_tag_mask[1] =
- pkt->ref_tag_mask[2] = pkt->ref_tag_mask[3] =
- 0x00;
- break;
-
- /*
- * For TYpe 1 protection: 16 bit GUARD tag, 32 bit REF tag, and
- * 16 bit app tag.
- */
- case SCSI_PROT_DIF_TYPE1:
- pkt->ref_tag = cpu_to_le32((uint32_t)
- (0xffffffff & scsi_get_lba(cmd)));
- pkt->app_tag = cpu_to_le16(0);
- pkt->app_tag_mask[0] = 0x0;
- pkt->app_tag_mask[1] = 0x0;
-
- if (!qla2x00_hba_err_chk_enabled(sp))
- break;
-
- /* enable ALL bytes of the ref tag */
- pkt->ref_tag_mask[0] = 0xff;
- pkt->ref_tag_mask[1] = 0xff;
- pkt->ref_tag_mask[2] = 0xff;
- pkt->ref_tag_mask[3] = 0xff;
- break;
+ if (cmd->prot_flags & SCSI_PROT_REF_CHECK) {
+ pkt->ref_tag_mask[0] = 0xff;
+ pkt->ref_tag_mask[1] = 0xff;
+ pkt->ref_tag_mask[2] = 0xff;
+ pkt->ref_tag_mask[3] = 0xff;
}
+
+ pkt->app_tag = __constant_cpu_to_le16(0);
+ pkt->app_tag_mask[0] = 0x0;
+ pkt->app_tag_mask[1] = 0x0;
}
int
@@ -905,7 +851,7 @@ qla24xx_walk_and_build_sglist_no_difb(struct qla_hw_data *ha, srb_t *sp,
memset(&sgx, 0, sizeof(struct qla2_sgx));
if (sp) {
cmd = GET_CMD_SP(sp);
- prot_int = cmd->device->sector_size;
+ prot_int = scsi_prot_interval(cmd);
sgx.tot_bytes = scsi_bufflen(cmd);
sgx.cur_sg = scsi_sglist(cmd);
--
2.31.1
next prev parent reply other threads:[~2021-06-09 3:39 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-09 3:39 [PATCH 00/15] Subject: Protection information and block size cleanup Martin K. Petersen
2021-06-09 3:39 ` [PATCH 01/15] scsi: core: Add scsi_prot_ref_tag() helper Martin K. Petersen
2021-06-09 19:55 ` Bart Van Assche
2021-06-14 14:33 ` Benjamin Block
2021-06-09 3:39 ` [PATCH 02/15] scsi: lpfc: Use the proper SCSI midlayer interfaces for PI Martin K. Petersen
2021-06-09 3:39 ` Martin K. Petersen [this message]
2021-06-17 0:15 ` [PATCH 03/15] scsi: qla2xxx: " Arun Easi
2021-06-09 3:39 ` [PATCH 04/15] scsi: mpt3sas: " Martin K. Petersen
2021-06-09 3:39 ` [PATCH 05/15] scsi: mpi3mr: " Martin K. Petersen
2021-06-09 3:39 ` [PATCH 06/15] scsi: zfcp: " Martin K. Petersen
2021-06-14 14:33 ` Benjamin Block
2021-06-15 2:27 ` Martin K. Petersen
2021-06-15 9:31 ` Benjamin Block
2021-06-09 3:39 ` [PATCH 07/15] scsi: isci: " Martin K. Petersen
2021-06-09 3:39 ` [PATCH 08/15] scsi: scsi_debug: Remove dump_sector() Martin K. Petersen
2021-06-09 19:55 ` Bart Van Assche
2021-06-14 22:06 ` Douglas Gilbert
2021-06-09 3:39 ` [PATCH 09/15] scsi: scsi_debug: Improve RDPROTECT/WRPROTECT handling Martin K. Petersen
2021-06-14 22:07 ` Douglas Gilbert
2021-06-09 3:39 ` [PATCH 10/15] scsi: core: Introduce scsi_get_sector() Martin K. Petersen
2021-06-14 14:48 ` Benjamin Block
2021-06-15 2:28 ` Martin K. Petersen
2021-06-15 9:33 ` Benjamin Block
2021-06-09 3:39 ` [PATCH 11/15] scsi: iser: Use scsi_get_sector() instead of scsi_get_lba() Martin K. Petersen
2021-06-09 3:39 ` [PATCH 12/15] scsi: core: Make scsi_get_lba() return the LBA Martin K. Petersen
2021-06-09 19:57 ` Bart Van Assche
2021-06-14 14:50 ` Benjamin Block
2021-06-15 9:34 ` Benjamin Block
2021-06-09 3:39 ` [PATCH 13/15] scsi: core: Add helper to return number of logical blocks in a request Martin K. Petersen
2021-06-09 19:58 ` Bart Van Assche
2021-06-10 3:19 ` Martin K. Petersen
2021-06-10 3:40 ` Bart Van Assche
2021-06-09 3:39 ` [PATCH 14/15] scsi: lpfc: Switch to scsi_get_block_count() Martin K. Petersen
2021-06-09 3:39 ` [PATCH 15/15] scsi: ufs: core: Use scsi_get_lba() to get LBA Martin K. Petersen
2021-06-09 19:59 ` Bart Van Assche
2021-07-16 21:27 ` [PATCH 00/15] Subject: Protection information and block size cleanup Bart Van Assche
2021-07-19 1:43 ` Martin K. Petersen
2021-07-21 3:53 ` Bart Van Assche
2021-07-24 2:13 ` 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=20210609033929.3815-4-martin.petersen@oracle.com \
--to=martin.petersen@oracle.com \
--cc=linux-scsi@vger.kernel.org \
/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).