jianhai / rpms / kernel

Forked from rpms/kernel 3 years ago
Clone
a8a466
From dffd1263c440568ca20d97ff01aea74b1f20223c Mon Sep 17 00:00:00 2001
a8a466
From: Sasikumar Chandrasekaran <sasikumar.pc@broadcom.com>
a8a466
Date: Tue, 10 Jan 2017 18:20:52 -0500
a8a466
Subject: [PATCH 10/11] scsi: megaraid_sas: Implement the PD Map support for
a8a466
 SAS3.5 Generic Megaraid Controllers
a8a466
a8a466
Update Linux driver to use new pdTargetId field for JBOD target ID
a8a466
a8a466
Signed-off-by: Sasikumar Chandrasekaran <sasikumar.pc@broadcom.com>
a8a466
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
a8a466
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
a8a466
---
a8a466
 drivers/scsi/megaraid/megaraid_sas.h        | 105 +++++++++++++++++++++-------
a8a466
 drivers/scsi/megaraid/megaraid_sas_base.c   |   3 +
a8a466
 drivers/scsi/megaraid/megaraid_sas_fusion.c |   6 ++
a8a466
 drivers/scsi/megaraid/megaraid_sas_fusion.h |   3 +-
a8a466
 4 files changed, 89 insertions(+), 28 deletions(-)
a8a466
a8a466
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
a8a466
index f6ac1b2..a38dbe5 100644
a8a466
--- a/drivers/scsi/megaraid/megaraid_sas.h
a8a466
+++ b/drivers/scsi/megaraid/megaraid_sas.h
a8a466
@@ -1317,7 +1317,55 @@ struct megasas_ctrl_info {
a8a466
 #endif
a8a466
 	} adapterOperations3;
a8a466
 
a8a466
-	u8          pad[0x800-0x7EC];
a8a466
+	struct {
a8a466
+#if defined(__BIG_ENDIAN_BITFIELD)
a8a466
+	u8 reserved:7;
a8a466
+	/* Indicates whether the CPLD image is part of
a8a466
+	 *  the package and stored in flash
a8a466
+	 */
a8a466
+	u8 cpld_in_flash:1;
a8a466
+#else
a8a466
+	u8 cpld_in_flash:1;
a8a466
+	u8 reserved:7;
a8a466
+#endif
a8a466
+	u8 reserved1[3];
a8a466
+	/* Null terminated string. Has the version
a8a466
+	 *  information if cpld_in_flash = FALSE
a8a466
+	 */
a8a466
+	u8 userCodeDefinition[12];
a8a466
+	} cpld;  /* Valid only if upgradableCPLD is TRUE */
a8a466
+
a8a466
+	struct {
a8a466
+	#if defined(__BIG_ENDIAN_BITFIELD)
a8a466
+		u16 reserved:8;
a8a466
+		u16 fw_swaps_bbu_vpd_info:1;
a8a466
+		u16 support_pd_map_target_id:1;
a8a466
+		u16 support_ses_ctrl_in_multipathcfg:1;
a8a466
+		u16 image_upload_supported:1;
a8a466
+		u16 support_encrypted_mfc:1;
a8a466
+		u16 supported_enc_algo:1;
a8a466
+		u16 support_ibutton_less:1;
a8a466
+		u16 ctrl_info_ext_supported:1;
a8a466
+	#else
a8a466
+
a8a466
+		u16 ctrl_info_ext_supported:1;
a8a466
+		u16 support_ibutton_less:1;
a8a466
+		u16 supported_enc_algo:1;
a8a466
+		u16 support_encrypted_mfc:1;
a8a466
+		u16 image_upload_supported:1;
a8a466
+		/* FW supports LUN based association and target port based */
a8a466
+		u16 support_ses_ctrl_in_multipathcfg:1;
a8a466
+		/* association for the SES device connected in multipath mode */
a8a466
+		/* FW defines Jbod target Id within MR_PD_CFG_SEQ */
a8a466
+		u16 support_pd_map_target_id:1;
a8a466
+		/* FW swaps relevant fields in MR_BBU_VPD_INFO_FIXED to
a8a466
+		 *  provide the data in little endian order
a8a466
+		 */
a8a466
+		u16 fw_swaps_bbu_vpd_info:1;
a8a466
+		u16 reserved:8;
a8a466
+	#endif
a8a466
+		} adapter_operations4;
a8a466
+	u8 pad[0x800-0x7FE]; /* 0x7FE pad to 2K for expansion */
a8a466
 } __packed;
a8a466
 
a8a466
 /*
a8a466
@@ -1557,33 +1605,35 @@ union megasas_sgl_frame {
a8a466
 typedef union _MFI_CAPABILITIES {
a8a466
 	struct {
a8a466
 #if   defined(__BIG_ENDIAN_BITFIELD)
a8a466
-		u32     reserved:20;
a8a466
-		u32     support_qd_throttling:1;
a8a466
-		u32     support_fp_rlbypass:1;
a8a466
-		u32     support_vfid_in_ioframe:1;
a8a466
-		u32     support_ext_io_size:1;
a8a466
-		u32	support_ext_queue_depth:1;
a8a466
-		u32     security_protocol_cmds_fw:1;
a8a466
-		u32     support_core_affinity:1;
a8a466
-		u32     support_ndrive_r1_lb:1;
a8a466
-		u32	support_max_255lds:1;
a8a466
-		u32	support_fastpath_wb:1;
a8a466
-		u32     support_additional_msix:1;
a8a466
-		u32     support_fp_remote_lun:1;
a8a466
+	u32     reserved:19;
a8a466
+	u32 support_pd_map_target_id:1;
a8a466
+	u32     support_qd_throttling:1;
a8a466
+	u32     support_fp_rlbypass:1;
a8a466
+	u32     support_vfid_in_ioframe:1;
a8a466
+	u32     support_ext_io_size:1;
a8a466
+	u32		support_ext_queue_depth:1;
a8a466
+	u32     security_protocol_cmds_fw:1;
a8a466
+	u32     support_core_affinity:1;
a8a466
+	u32     support_ndrive_r1_lb:1;
a8a466
+	u32		support_max_255lds:1;
a8a466
+	u32		support_fastpath_wb:1;
a8a466
+	u32     support_additional_msix:1;
a8a466
+	u32     support_fp_remote_lun:1;
a8a466
 #else
a8a466
-		u32     support_fp_remote_lun:1;
a8a466
-		u32     support_additional_msix:1;
a8a466
-		u32	support_fastpath_wb:1;
a8a466
-		u32	support_max_255lds:1;
a8a466
-		u32     support_ndrive_r1_lb:1;
a8a466
-		u32     support_core_affinity:1;
a8a466
-		u32     security_protocol_cmds_fw:1;
a8a466
-		u32	support_ext_queue_depth:1;
a8a466
-		u32     support_ext_io_size:1;
a8a466
-		u32     support_vfid_in_ioframe:1;
a8a466
-		u32     support_fp_rlbypass:1;
a8a466
-		u32     support_qd_throttling:1;
a8a466
-		u32     reserved:20;
a8a466
+	u32     support_fp_remote_lun:1;
a8a466
+	u32     support_additional_msix:1;
a8a466
+	u32		support_fastpath_wb:1;
a8a466
+	u32		support_max_255lds:1;
a8a466
+	u32     support_ndrive_r1_lb:1;
a8a466
+	u32     support_core_affinity:1;
a8a466
+	u32     security_protocol_cmds_fw:1;
a8a466
+	u32		support_ext_queue_depth:1;
a8a466
+	u32     support_ext_io_size:1;
a8a466
+	u32     support_vfid_in_ioframe:1;
a8a466
+	u32     support_fp_rlbypass:1;
a8a466
+	u32     support_qd_throttling:1;
a8a466
+	u32	support_pd_map_target_id:1;
a8a466
+	u32     reserved:19;
a8a466
 #endif
a8a466
 	} mfi_capabilities;
a8a466
 	__le32		reg;
a8a466
@@ -2052,6 +2102,7 @@ struct megasas_instance {
a8a466
 	u32 crash_dump_drv_support;
a8a466
 	u32 crash_dump_app_support;
a8a466
 	u32 secure_jbod_support;
a8a466
+	u32 support_morethan256jbod; /* FW support for more than 256 PD/JBOD */
a8a466
 	bool use_seqnum_jbod_fp;   /* Added for PD sequence */
a8a466
 	spinlock_t crashdump_lock;
a8a466
 
a8a466
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
a8a466
index cab3be8..e7249f9 100644
a8a466
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
a8a466
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
a8a466
@@ -4609,6 +4609,7 @@ megasas_get_ctrl_info(struct megasas_instance *instance)
a8a466
 		le32_to_cpus((u32 *)&ctrl_info->properties.OnOffProperties);
a8a466
 		le32_to_cpus((u32 *)&ctrl_info->adapterOperations2);
a8a466
 		le32_to_cpus((u32 *)&ctrl_info->adapterOperations3);
a8a466
+		le16_to_cpus((u16 *)&ctrl_info->adapter_operations4);
a8a466
 
a8a466
 		/* Update the latest Ext VD info.
a8a466
 		 * From Init path, store current firmware details.
a8a466
@@ -4618,6 +4619,8 @@ megasas_get_ctrl_info(struct megasas_instance *instance)
a8a466
 		megasas_update_ext_vd_details(instance);
a8a466
 		instance->use_seqnum_jbod_fp =
a8a466
 			ctrl_info->adapterOperations3.useSeqNumJbodFP;
a8a466
+		instance->support_morethan256jbod =
a8a466
+			ctrl_info->adapter_operations4.support_pd_map_target_id;
a8a466
 
a8a466
 		/*Check whether controller is iMR or MR */
a8a466
 		instance->is_imr = (ctrl_info->memory_size ? 0 : 1);
a8a466
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
a8a466
index 82dd2da..85f0af6 100644
a8a466
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
a8a466
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
a8a466
@@ -858,6 +858,7 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
a8a466
 		drv_ops->mfi_capabilities.support_ext_queue_depth = 1;
a8a466
 
a8a466
 	drv_ops->mfi_capabilities.support_qd_throttling = 1;
a8a466
+	drv_ops->mfi_capabilities.support_pd_map_target_id = 1;
a8a466
 	/* Convert capability to LE32 */
a8a466
 	cpu_to_le32s((u32 *)&init_frame->driver_operations.mfi_capabilities);
a8a466
 
a8a466
@@ -2244,6 +2245,11 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
a8a466
 		/* TgtId must be incremented by 255 as jbod seq number is index
a8a466
 		 * below raid map
a8a466
 		 */
a8a466
+		 /* More than 256 PD/JBOD support for Ventura */
a8a466
+		if (instance->support_morethan256jbod)
a8a466
+			pRAID_Context->virtual_disk_tgt_id =
a8a466
+				pd_sync->seq[pd_index].pd_target_id;
a8a466
+		else
a8a466
 		pRAID_Context->virtual_disk_tgt_id =
a8a466
 			cpu_to_le16(device_id + (MAX_PHYSICAL_DEVICES - 1));
a8a466
 		pRAID_Context->config_seq_num = pd_sync->seq[pd_index].seqNum;
a8a466
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h b/drivers/scsi/megaraid/megaraid_sas_fusion.h
a8a466
index f7384c1..ad68a85 100644
a8a466
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
a8a466
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
a8a466
@@ -1189,7 +1189,8 @@ struct MR_PD_CFG_SEQ {
a8a466
 		u8     reserved:7;
a8a466
 #endif
a8a466
 	} capability;
a8a466
-	u8  reserved[3];
a8a466
+	u8  reserved;
a8a466
+	u16 pd_target_id;
a8a466
 } __packed;
a8a466
 
a8a466
 struct MR_PD_CFG_SEQ_NUM_SYNC {
a8a466
-- 
a8a466
1.8.3.1
a8a466