b312fc
From 1d7d67352bddfd44384bd8778f822da279ff78f8 Mon Sep 17 00:00:00 2001
b312fc
From: Sasikumar Chandrasekaran <sasikumar.pc@broadcom.com>
b312fc
Date: Tue, 10 Jan 2017 18:20:49 -0500
b312fc
Subject: [PATCH 07/11] scsi: megaraid_sas: Add the Support for SAS3.5 Generic
b312fc
 Megaraid Controllers Capabilities
b312fc
b312fc
The Megaraid driver has to support the SAS3.5 Generic Megaraid Controllers Firmware functionality.
b312fc
b312fc
Signed-off-by: Sasikumar Chandrasekaran <sasikumar.pc@broadcom.com>
b312fc
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
b312fc
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
b312fc
---
b312fc
 drivers/scsi/megaraid/megaraid_sas_base.c   | 53 ++++++++++++++---------------
b312fc
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 19 ++++++-----
b312fc
 drivers/scsi/megaraid/megaraid_sas_fusion.h |  1 +
b312fc
 3 files changed, 37 insertions(+), 36 deletions(-)
b312fc
b312fc
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
b312fc
index 1d8cf03..8b0c686 100644
b312fc
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
b312fc
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
b312fc
@@ -5089,34 +5089,29 @@ static int megasas_init_fw(struct megasas_instance *instance)
b312fc
 
b312fc
 	reg_set = instance->reg_set;
b312fc
 
b312fc
-	switch (instance->pdev->device) {
b312fc
-	case PCI_DEVICE_ID_LSI_FUSION:
b312fc
-	case PCI_DEVICE_ID_LSI_PLASMA:
b312fc
-	case PCI_DEVICE_ID_LSI_INVADER:
b312fc
-	case PCI_DEVICE_ID_LSI_FURY:
b312fc
-	case PCI_DEVICE_ID_LSI_INTRUDER:
b312fc
-	case PCI_DEVICE_ID_LSI_INTRUDER_24:
b312fc
-	case PCI_DEVICE_ID_LSI_CUTLASS_52:
b312fc
-	case PCI_DEVICE_ID_LSI_CUTLASS_53:
b312fc
+	if (fusion)
b312fc
 		instance->instancet = &megasas_instance_template_fusion;
b312fc
-		break;
b312fc
-	case PCI_DEVICE_ID_LSI_SAS1078R:
b312fc
-	case PCI_DEVICE_ID_LSI_SAS1078DE:
b312fc
-		instance->instancet = &megasas_instance_template_ppc;
b312fc
-		break;
b312fc
-	case PCI_DEVICE_ID_LSI_SAS1078GEN2:
b312fc
-	case PCI_DEVICE_ID_LSI_SAS0079GEN2:
b312fc
-		instance->instancet = &megasas_instance_template_gen2;
b312fc
-		break;
b312fc
-	case PCI_DEVICE_ID_LSI_SAS0073SKINNY:
b312fc
-	case PCI_DEVICE_ID_LSI_SAS0071SKINNY:
b312fc
-		instance->instancet = &megasas_instance_template_skinny;
b312fc
-		break;
b312fc
-	case PCI_DEVICE_ID_LSI_SAS1064R:
b312fc
-	case PCI_DEVICE_ID_DELL_PERC5:
b312fc
-	default:
b312fc
-		instance->instancet = &megasas_instance_template_xscale;
b312fc
-		break;
b312fc
+	else {
b312fc
+		switch (instance->pdev->device) {
b312fc
+		case PCI_DEVICE_ID_LSI_SAS1078R:
b312fc
+		case PCI_DEVICE_ID_LSI_SAS1078DE:
b312fc
+			instance->instancet = &megasas_instance_template_ppc;
b312fc
+			break;
b312fc
+		case PCI_DEVICE_ID_LSI_SAS1078GEN2:
b312fc
+		case PCI_DEVICE_ID_LSI_SAS0079GEN2:
b312fc
+			instance->instancet = &megasas_instance_template_gen2;
b312fc
+			break;
b312fc
+		case PCI_DEVICE_ID_LSI_SAS0073SKINNY:
b312fc
+		case PCI_DEVICE_ID_LSI_SAS0071SKINNY:
b312fc
+			instance->instancet = &megasas_instance_template_skinny;
b312fc
+			break;
b312fc
+		case PCI_DEVICE_ID_LSI_SAS1064R:
b312fc
+		case PCI_DEVICE_ID_DELL_PERC5:
b312fc
+		default:
b312fc
+			instance->instancet = &megasas_instance_template_xscale;
b312fc
+			instance->pd_list_not_supported = 1;
b312fc
+			break;
b312fc
+		}
b312fc
 	}
b312fc
 
b312fc
 	if (megasas_transition_to_ready(instance, 0)) {
b312fc
@@ -5869,7 +5864,9 @@ static int megasas_probe_one(struct pci_dev *pdev,
b312fc
 		if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
b312fc
 			(instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA))
b312fc
 			fusion->adapter_type = THUNDERBOLT_SERIES;
b312fc
-		else if (!instance->is_ventura)
b312fc
+		else if (instance->is_ventura)
b312fc
+			fusion->adapter_type = VENTURA_SERIES;
b312fc
+		else
b312fc
 			fusion->adapter_type = INVADER_SERIES;
b312fc
 	}
b312fc
 	break;
b312fc
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
b312fc
index 178f166..1802c57 100644
b312fc
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
b312fc
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
b312fc
@@ -244,7 +244,10 @@ megasas_fusion_update_can_queue(struct megasas_instance *instance, int fw_boot_c
b312fc
 
b312fc
 	reg_set = instance->reg_set;
b312fc
 
b312fc
-	cur_max_fw_cmds = readl(&instance->reg_set->outbound_scratch_pad_3) & 0x00FFFF;
b312fc
+	/* ventura FW does not fill outbound_scratch_pad_3 with queue depth */
b312fc
+	if (!instance->is_ventura)
b312fc
+		cur_max_fw_cmds =
b312fc
+		readl(&instance->reg_set->outbound_scratch_pad_3) & 0x00FFFF;
b312fc
 
b312fc
 	if (dual_qdepth_disable || !cur_max_fw_cmds)
b312fc
 		cur_max_fw_cmds = instance->instancet->read_fw_status_reg(reg_set) & 0x00FFFF;
b312fc
@@ -837,7 +840,7 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
b312fc
 	drv_ops = (MFI_CAPABILITIES *) &(init_frame->driver_operations);
b312fc
 
b312fc
 	/* driver support Extended MSIX */
b312fc
-	if (fusion->adapter_type == INVADER_SERIES)
b312fc
+	if (fusion->adapter_type >= INVADER_SERIES)
b312fc
 		drv_ops->mfi_capabilities.support_additional_msix = 1;
b312fc
 	/* driver supports HA / Remote LUN over Fast Path interface */
b312fc
 	drv_ops->mfi_capabilities.support_fp_remote_lun = 1;
b312fc
@@ -1491,7 +1494,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
b312fc
 
b312fc
 	fusion = instance->ctrl_context;
b312fc
 
b312fc
-	if (fusion->adapter_type == INVADER_SERIES) {
b312fc
+	if (fusion->adapter_type >= INVADER_SERIES) {
b312fc
 		struct MPI25_IEEE_SGE_CHAIN64 *sgl_ptr_end = sgl_ptr;
b312fc
 		sgl_ptr_end += fusion->max_sge_in_main_msg - 1;
b312fc
 		sgl_ptr_end->Flags = 0;
b312fc
@@ -1508,7 +1511,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
b312fc
 		sgl_ptr->Length = cpu_to_le32(sg_dma_len(os_sgl));
b312fc
 		sgl_ptr->Address = cpu_to_le64(sg_dma_address(os_sgl));
b312fc
 		sgl_ptr->Flags = 0;
b312fc
-		if (fusion->adapter_type == INVADER_SERIES)
b312fc
+		if (fusion->adapter_type >= INVADER_SERIES)
b312fc
 			if (i == sge_count - 1)
b312fc
 				sgl_ptr->Flags = IEEE_SGE_FLAGS_END_OF_LIST;
b312fc
 		sgl_ptr++;
b312fc
@@ -1519,7 +1522,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
b312fc
 		    (sge_count > fusion->max_sge_in_main_msg)) {
b312fc
 
b312fc
 			struct MPI25_IEEE_SGE_CHAIN64 *sg_chain;
b312fc
-			if (fusion->adapter_type == INVADER_SERIES) {
b312fc
+			if (fusion->adapter_type >= INVADER_SERIES) {
b312fc
 				if ((le16_to_cpu(cmd->io_request->IoFlags) &
b312fc
 					MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH) !=
b312fc
 					MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH)
b312fc
@@ -1535,7 +1538,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
b312fc
 			sg_chain = sgl_ptr;
b312fc
 			/* Prepare chain element */
b312fc
 			sg_chain->NextChainOffset = 0;
b312fc
-			if (fusion->adapter_type == INVADER_SERIES)
b312fc
+			if (fusion->adapter_type >= INVADER_SERIES)
b312fc
 				sg_chain->Flags = IEEE_SGE_FLAGS_CHAIN_ELEMENT;
b312fc
 			else
b312fc
 				sg_chain->Flags =
b312fc
@@ -2286,7 +2289,7 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
b312fc
 		pRAID_Context->timeout_value =
b312fc
 			cpu_to_le16((os_timeout_value > timeout_limit) ?
b312fc
 			timeout_limit : os_timeout_value);
b312fc
-		if (fusion->adapter_type == INVADER_SERIES)
b312fc
+		if (fusion->adapter_type >= INVADER_SERIES)
b312fc
 			io_request->IoFlags |=
b312fc
 				cpu_to_le16(MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH);
b312fc
 
b312fc
@@ -2995,7 +2998,7 @@ build_mpt_mfi_pass_thru(struct megasas_instance *instance,
b312fc
 
b312fc
 	io_req = cmd->io_request;
b312fc
 
b312fc
-	if (fusion->adapter_type == INVADER_SERIES) {
b312fc
+	if (fusion->adapter_type >= INVADER_SERIES) {
b312fc
 		struct MPI25_IEEE_SGE_CHAIN64 *sgl_ptr_end =
b312fc
 			(struct MPI25_IEEE_SGE_CHAIN64 *)&io_req->SGL;
b312fc
 		sgl_ptr_end += fusion->max_sge_in_main_msg - 1;
b312fc
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h b/drivers/scsi/megaraid/megaraid_sas_fusion.h
b312fc
index 2de12b4..b24262a 100644
b312fc
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
b312fc
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
b312fc
@@ -107,6 +107,7 @@ enum MR_RAID_FLAGS_IO_SUB_TYPE {
b312fc
 enum MR_FUSION_ADAPTER_TYPE {
b312fc
 	THUNDERBOLT_SERIES = 0,
b312fc
 	INVADER_SERIES = 1,
b312fc
+	VENTURA_SERIES = 2,
b312fc
 };
b312fc
 
b312fc
 /*
b312fc
-- 
b312fc
1.8.3.1
b312fc