diff mbox series

[1/2] qla2xxx: Add protection mask module parameters

Message ID 20181221173345.15606-2-hmadhani@marvell.com (mailing list archive)
State Accepted
Headers show
Series qla2xxx: Updates for driver | expand

Commit Message

Himanshu Madhani Dec. 21, 2018, 5:33 p.m. UTC
From: "Martin K. Petersen" <martin.petersen@oracle.com>

Allow user to selectively enable/disable DIF/DIX protection
capabilities mask.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
---
 drivers/scsi/qla2xxx/qla_os.c | 36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)

Comments

Christoph Hellwig Dec. 21, 2018, 8:17 p.m. UTC | #1
On Fri, Dec 21, 2018 at 09:33:44AM -0800, Himanshu Madhani wrote:
> From: "Martin K. Petersen" <martin.petersen@oracle.com>
> 
> Allow user to selectively enable/disable DIF/DIX protection
> capabilities mask.

I really hate having knows for this in various drivers.  Can't we have
a way to do this genericly?
Martin K. Petersen Jan. 4, 2019, 4:06 a.m. UTC | #2
Christoph,

>> Allow user to selectively enable/disable DIF/DIX protection
>> capabilities mask.
>
> I really hate having knows for this in various drivers.  Can't we have
> a way to do this genericly?

The module parameter is really just a debugging tool (I use it to force
DIX0 operation with T10 PI storage so I don't have to have keep
legacy-formatted disks available for testing). Normal users should use
read_verify and write_generate to enable/disable DIX.

If we make the prot mask a tunable, we'll have to shuffle the integrity
profile registration over to revalidate and remember the user
override. And then trigger an MD/DM restack. Certainly doable, but it
hasn't seemed worth the hassle to go there.
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index f0ffb0e5c113..deb923058d08 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -285,6 +285,20 @@  MODULE_PARM_DESC(qla2xuseresexchforels,
 		 "Reserve 1/2 of emergency exchanges for ELS.\n"
 		 " 0 (default): disabled");
 
+int ql2xprotmask;
+module_param(ql2xprotmask, int, 0644);
+MODULE_PARM_DESC(ql2xprotmask,
+    "Override DIF/DIX protection capabilities mask\n"
+    "Default is 0 which sets protection mask based on capabilities "
+    "reported by HBA firmware.\n");
+
+int ql2xprotguard;
+module_param(ql2xprotguard, int, 0644);
+MODULE_PARM_DESC(ql2xprotguard, "Override choice of DIX checksum\n"
+    "  0 -- Let HBA firmware decide\n"
+    "  1 -- Force T10 CRC\n"
+    "  2 -- Force IP checksum\n");
+
 /*
  * SCSI host template entry points
  */
@@ -3355,13 +3369,16 @@  qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 			    "Registering for DIF/DIX type 1 and 3 protection.\n");
 			if (ql2xenabledif == 1)
 				prot = SHOST_DIX_TYPE0_PROTECTION;
-			scsi_host_set_prot(host,
-			    prot | SHOST_DIF_TYPE1_PROTECTION
-			    | SHOST_DIF_TYPE2_PROTECTION
-			    | SHOST_DIF_TYPE3_PROTECTION
-			    | SHOST_DIX_TYPE1_PROTECTION
-			    | SHOST_DIX_TYPE2_PROTECTION
-			    | SHOST_DIX_TYPE3_PROTECTION);
+			if (ql2xprotmask)
+				scsi_host_set_prot(host, ql2xprotmask);
+			else
+				scsi_host_set_prot(host,
+				    prot | SHOST_DIF_TYPE1_PROTECTION
+				    | SHOST_DIF_TYPE2_PROTECTION
+				    | SHOST_DIF_TYPE3_PROTECTION
+				    | SHOST_DIX_TYPE1_PROTECTION
+				    | SHOST_DIX_TYPE2_PROTECTION
+				    | SHOST_DIX_TYPE3_PROTECTION);
 
 			guard = SHOST_DIX_GUARD_CRC;
 
@@ -3369,7 +3386,10 @@  qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 			    (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha)))
 				guard |= SHOST_DIX_GUARD_IP;
 
-			scsi_host_set_guard(host, guard);
+			if (ql2xprotguard)
+				scsi_host_set_guard(host, ql2xprotguard);
+			else
+				scsi_host_set_guard(host, guard);
 		} else
 			base_vha->flags.difdix_supported = 0;
 	}