fanghuilin / rpms / kernel

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