Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c365178f authored by Shivasharan S's avatar Shivasharan S Committed by Martin K. Petersen
Browse files

scsi: megaraid_sas: use adapter_type for all gen controllers



No functional change.
Refactor adapter_type to set for all generation controllers, not
just for fusion controllers.

Signed-off-by: default avatarKashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: default avatarShivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent c9edcb2e
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -1504,6 +1504,13 @@ enum FW_BOOT_CONTEXT {


#define MR_CAN_HANDLE_SYNC_CACHE_OFFSET		0X01000000
#define MR_CAN_HANDLE_SYNC_CACHE_OFFSET		0X01000000


enum MR_ADAPTER_TYPE {
	MFI_SERIES = 1,
	THUNDERBOLT_SERIES = 2,
	INVADER_SERIES = 3,
	VENTURA_SERIES = 4,
};

/*
/*
* register set for both 1068 and 1078 controllers
* register set for both 1068 and 1078 controllers
* structure extended for 1078 registers
* structure extended for 1078 registers
@@ -2242,6 +2249,7 @@ struct megasas_instance {
	/* preffered count to send as LDIO irrspective of FP capable.*/
	/* preffered count to send as LDIO irrspective of FP capable.*/
	u8  r1_ldio_hint_default;
	u8  r1_ldio_hint_default;
	u32 nvme_page_size;
	u32 nvme_page_size;
	u8 adapter_type;
};
};
struct MR_LD_VF_MAP {
struct MR_LD_VF_MAP {
	u32 size;
	u32 size;
+54 −34
Original line number Original line Diff line number Diff line
@@ -5229,7 +5229,8 @@ static int megasas_init_fw(struct megasas_instance *instance)
			(&instance->reg_set->outbound_scratch_pad_2);
			(&instance->reg_set->outbound_scratch_pad_2);
		/* Check max MSI-X vectors */
		/* Check max MSI-X vectors */
		if (fusion) {
		if (fusion) {
			if (fusion->adapter_type == THUNDERBOLT_SERIES) { /* Thunderbolt Series*/
			if (instance->adapter_type == THUNDERBOLT_SERIES) {
				/* Thunderbolt Series*/
				instance->msix_vectors = (scratch_pad_2
				instance->msix_vectors = (scratch_pad_2
					& MR_MAX_REPLY_QUEUES_OFFSET) + 1;
					& MR_MAX_REPLY_QUEUES_OFFSET) + 1;
				fw_msix_count = instance->msix_vectors;
				fw_msix_count = instance->msix_vectors;
@@ -5965,6 +5966,46 @@ megasas_set_dma_mask(struct pci_dev *pdev)
	return 1;
	return 1;
}
}


/*
 * megasas_set_adapter_type -	Set adapter type.
 *				Supported controllers can be divided in
 *				4 categories-  enum MR_ADAPTER_TYPE {
 *							MFI_SERIES = 1,
 *							THUNDERBOLT_SERIES = 2,
 *							INVADER_SERIES = 3,
 *							VENTURA_SERIES = 4,
 *						};
 * @instance:			Adapter soft state
 * return:			void
 */
static inline void megasas_set_adapter_type(struct megasas_instance *instance)
{
	switch (instance->pdev->device) {
	case PCI_DEVICE_ID_LSI_VENTURA:
	case PCI_DEVICE_ID_LSI_HARPOON:
	case PCI_DEVICE_ID_LSI_TOMCAT:
	case PCI_DEVICE_ID_LSI_VENTURA_4PORT:
	case PCI_DEVICE_ID_LSI_CRUSADER_4PORT:
		instance->adapter_type = VENTURA_SERIES;
		break;
	case PCI_DEVICE_ID_LSI_FUSION:
	case PCI_DEVICE_ID_LSI_PLASMA:
		instance->adapter_type = THUNDERBOLT_SERIES;
		break;
	case PCI_DEVICE_ID_LSI_INVADER:
	case PCI_DEVICE_ID_LSI_INTRUDER:
	case PCI_DEVICE_ID_LSI_INTRUDER_24:
	case PCI_DEVICE_ID_LSI_CUTLASS_52:
	case PCI_DEVICE_ID_LSI_CUTLASS_53:
	case PCI_DEVICE_ID_LSI_FURY:
		instance->adapter_type = INVADER_SERIES;
		break;
	default: /* For all other supported controllers */
		instance->adapter_type = MFI_SERIES;
		break;
	}
}

/**
/**
 * megasas_probe_one -	PCI hotplug entry point
 * megasas_probe_one -	PCI hotplug entry point
 * @pdev:		PCI device structure
 * @pdev:		PCI device structure
@@ -5977,7 +6018,6 @@ static int megasas_probe_one(struct pci_dev *pdev,
	struct Scsi_Host *host;
	struct Scsi_Host *host;
	struct megasas_instance *instance;
	struct megasas_instance *instance;
	u16 control = 0;
	u16 control = 0;
	struct fusion_context *fusion = NULL;


	/* Reset MSI-X in the kdump kernel */
	/* Reset MSI-X in the kdump kernel */
	if (reset_devices) {
	if (reset_devices) {
@@ -6022,39 +6062,10 @@ static int megasas_probe_one(struct pci_dev *pdev,
	atomic_set(&instance->fw_reset_no_pci_access, 0);
	atomic_set(&instance->fw_reset_no_pci_access, 0);
	instance->pdev = pdev;
	instance->pdev = pdev;


	switch (instance->pdev->device) {
	megasas_set_adapter_type(instance);
	case PCI_DEVICE_ID_LSI_VENTURA:
	case PCI_DEVICE_ID_LSI_HARPOON:
	case PCI_DEVICE_ID_LSI_TOMCAT:
	case PCI_DEVICE_ID_LSI_VENTURA_4PORT:
	case PCI_DEVICE_ID_LSI_CRUSADER_4PORT:
	     instance->is_ventura = true;
	case PCI_DEVICE_ID_LSI_FUSION:
	case PCI_DEVICE_ID_LSI_PLASMA:
	case PCI_DEVICE_ID_LSI_INVADER:
	case PCI_DEVICE_ID_LSI_FURY:
	case PCI_DEVICE_ID_LSI_INTRUDER:
	case PCI_DEVICE_ID_LSI_INTRUDER_24:
	case PCI_DEVICE_ID_LSI_CUTLASS_52:
	case PCI_DEVICE_ID_LSI_CUTLASS_53:
	{
		if (megasas_alloc_fusion_context(instance)) {
			megasas_free_fusion_context(instance);
			goto fail_alloc_dma_buf;
		}
		fusion = instance->ctrl_context;

		if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
			(instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA))
			fusion->adapter_type = THUNDERBOLT_SERIES;
		else if (instance->is_ventura)
			fusion->adapter_type = VENTURA_SERIES;
		else
			fusion->adapter_type = INVADER_SERIES;
	}
	break;
	default: /* For all other supported controllers */


	switch (instance->adapter_type) {
	case MFI_SERIES:
		instance->producer =
		instance->producer =
			pci_alloc_consistent(pdev, sizeof(u32),
			pci_alloc_consistent(pdev, sizeof(u32),
					     &instance->producer_h);
					     &instance->producer_h);
@@ -6070,7 +6081,16 @@ static int megasas_probe_one(struct pci_dev *pdev,


		*instance->producer = 0;
		*instance->producer = 0;
		*instance->consumer = 0;
		*instance->consumer = 0;

		break;
		break;
	case VENTURA_SERIES:
		instance->is_ventura = 1;
	case THUNDERBOLT_SERIES:
	case INVADER_SERIES:
		if (megasas_alloc_fusion_context(instance)) {
			megasas_free_fusion_context(instance);
			goto fail_alloc_dma_buf;
		}
	}
	}


	/* Crash dump feature related initialisation*/
	/* Crash dump feature related initialisation*/
+5 −5
Original line number Original line Diff line number Diff line
@@ -747,8 +747,8 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld,
		}
		}
	} else {
	} else {
		if ((raid->level >= 5) &&
		if ((raid->level >= 5) &&
			((fusion->adapter_type == THUNDERBOLT_SERIES)  ||
			((instance->adapter_type == THUNDERBOLT_SERIES)  ||
			((fusion->adapter_type == INVADER_SERIES) &&
			((instance->adapter_type == INVADER_SERIES) &&
			(raid->regTypeReqOnRead != REGION_TYPE_UNUSED))))
			(raid->regTypeReqOnRead != REGION_TYPE_UNUSED))))
			pRAID_Context->reg_lock_flags = REGION_TYPE_EXCLUSIVE;
			pRAID_Context->reg_lock_flags = REGION_TYPE_EXCLUSIVE;
		else if (raid->level == 1) {
		else if (raid->level == 1) {
@@ -863,8 +863,8 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 ld, u64 stripRow,
		}
		}
	} else {
	} else {
		if ((raid->level >= 5) &&
		if ((raid->level >= 5) &&
			((fusion->adapter_type == THUNDERBOLT_SERIES)  ||
			((instance->adapter_type == THUNDERBOLT_SERIES)  ||
			((fusion->adapter_type == INVADER_SERIES) &&
			((instance->adapter_type == INVADER_SERIES) &&
			(raid->regTypeReqOnRead != REGION_TYPE_UNUSED))))
			(raid->regTypeReqOnRead != REGION_TYPE_UNUSED))))
			pRAID_Context->reg_lock_flags = REGION_TYPE_EXCLUSIVE;
			pRAID_Context->reg_lock_flags = REGION_TYPE_EXCLUSIVE;
		else if (raid->level == 1) {
		else if (raid->level == 1) {
@@ -1088,7 +1088,7 @@ MR_BuildRaidContext(struct megasas_instance *instance,
		cpu_to_le16(raid->fpIoTimeoutForLd ?
		cpu_to_le16(raid->fpIoTimeoutForLd ?
			    raid->fpIoTimeoutForLd :
			    raid->fpIoTimeoutForLd :
			    map->raidMap.fpPdIoTimeoutSec);
			    map->raidMap.fpPdIoTimeoutSec);
	if (fusion->adapter_type == INVADER_SERIES)
	if (instance->adapter_type == INVADER_SERIES)
		pRAID_Context->reg_lock_flags = (isRead) ?
		pRAID_Context->reg_lock_flags = (isRead) ?
			raid->regTypeReqOnRead : raid->regTypeReqOnWrite;
			raid->regTypeReqOnRead : raid->regTypeReqOnWrite;
	else if (!instance->is_ventura)
	else if (!instance->is_ventura)
+9 −9
Original line number Original line Diff line number Diff line
@@ -845,7 +845,7 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
	drv_ops = (MFI_CAPABILITIES *) &(init_frame->driver_operations);
	drv_ops = (MFI_CAPABILITIES *) &(init_frame->driver_operations);


	/* driver support Extended MSIX */
	/* driver support Extended MSIX */
	if (fusion->adapter_type >= INVADER_SERIES)
	if (instance->adapter_type >= INVADER_SERIES)
		drv_ops->mfi_capabilities.support_additional_msix = 1;
		drv_ops->mfi_capabilities.support_additional_msix = 1;
	/* driver supports HA / Remote LUN over Fast Path interface */
	/* driver supports HA / Remote LUN over Fast Path interface */
	drv_ops->mfi_capabilities.support_fp_remote_lun = 1;
	drv_ops->mfi_capabilities.support_fp_remote_lun = 1;
@@ -1803,7 +1803,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,


	fusion = instance->ctrl_context;
	fusion = instance->ctrl_context;


	if (fusion->adapter_type >= INVADER_SERIES) {
	if (instance->adapter_type >= INVADER_SERIES) {
		struct MPI25_IEEE_SGE_CHAIN64 *sgl_ptr_end = sgl_ptr;
		struct MPI25_IEEE_SGE_CHAIN64 *sgl_ptr_end = sgl_ptr;
		sgl_ptr_end += fusion->max_sge_in_main_msg - 1;
		sgl_ptr_end += fusion->max_sge_in_main_msg - 1;
		sgl_ptr_end->Flags = 0;
		sgl_ptr_end->Flags = 0;
@@ -1813,7 +1813,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
		sgl_ptr->Length = cpu_to_le32(sg_dma_len(os_sgl));
		sgl_ptr->Length = cpu_to_le32(sg_dma_len(os_sgl));
		sgl_ptr->Address = cpu_to_le64(sg_dma_address(os_sgl));
		sgl_ptr->Address = cpu_to_le64(sg_dma_address(os_sgl));
		sgl_ptr->Flags = 0;
		sgl_ptr->Flags = 0;
		if (fusion->adapter_type >= INVADER_SERIES)
		if (instance->adapter_type >= INVADER_SERIES)
			if (i == sge_count - 1)
			if (i == sge_count - 1)
				sgl_ptr->Flags = IEEE_SGE_FLAGS_END_OF_LIST;
				sgl_ptr->Flags = IEEE_SGE_FLAGS_END_OF_LIST;
		sgl_ptr++;
		sgl_ptr++;
@@ -1823,7 +1823,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
		    (sge_count > fusion->max_sge_in_main_msg)) {
		    (sge_count > fusion->max_sge_in_main_msg)) {


			struct MPI25_IEEE_SGE_CHAIN64 *sg_chain;
			struct MPI25_IEEE_SGE_CHAIN64 *sg_chain;
			if (fusion->adapter_type >= INVADER_SERIES) {
			if (instance->adapter_type >= INVADER_SERIES) {
				if ((le16_to_cpu(cmd->io_request->IoFlags) &
				if ((le16_to_cpu(cmd->io_request->IoFlags) &
					MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH) !=
					MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH) !=
					MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH)
					MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH)
@@ -1839,7 +1839,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
			sg_chain = sgl_ptr;
			sg_chain = sgl_ptr;
			/* Prepare chain element */
			/* Prepare chain element */
			sg_chain->NextChainOffset = 0;
			sg_chain->NextChainOffset = 0;
			if (fusion->adapter_type >= INVADER_SERIES)
			if (instance->adapter_type >= INVADER_SERIES)
				sg_chain->Flags = IEEE_SGE_FLAGS_CHAIN_ELEMENT;
				sg_chain->Flags = IEEE_SGE_FLAGS_CHAIN_ELEMENT;
			else
			else
				sg_chain->Flags =
				sg_chain->Flags =
@@ -2416,7 +2416,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
		cmd->request_desc->SCSIIO.RequestFlags =
		cmd->request_desc->SCSIIO.RequestFlags =
			(MPI2_REQ_DESCRIPT_FLAGS_FP_IO
			(MPI2_REQ_DESCRIPT_FLAGS_FP_IO
			 << MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
			 << MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
		if (fusion->adapter_type == INVADER_SERIES) {
		if (instance->adapter_type == INVADER_SERIES) {
			if (io_request->RaidContext.raid_context.reg_lock_flags ==
			if (io_request->RaidContext.raid_context.reg_lock_flags ==
			    REGION_TYPE_UNUSED)
			    REGION_TYPE_UNUSED)
				cmd->request_desc->SCSIIO.RequestFlags =
				cmd->request_desc->SCSIIO.RequestFlags =
@@ -2481,7 +2481,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
		cmd->request_desc->SCSIIO.RequestFlags =
		cmd->request_desc->SCSIIO.RequestFlags =
			(MEGASAS_REQ_DESCRIPT_FLAGS_LD_IO
			(MEGASAS_REQ_DESCRIPT_FLAGS_LD_IO
			 << MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
			 << MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
		if (fusion->adapter_type == INVADER_SERIES) {
		if (instance->adapter_type == INVADER_SERIES) {
			if (io_info.do_fp_rlbypass ||
			if (io_info.do_fp_rlbypass ||
			(io_request->RaidContext.raid_context.reg_lock_flags
			(io_request->RaidContext.raid_context.reg_lock_flags
					== REGION_TYPE_UNUSED))
					== REGION_TYPE_UNUSED))
@@ -2702,7 +2702,7 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
		pRAID_Context->timeout_value =
		pRAID_Context->timeout_value =
			cpu_to_le16((os_timeout_value > timeout_limit) ?
			cpu_to_le16((os_timeout_value > timeout_limit) ?
			timeout_limit : os_timeout_value);
			timeout_limit : os_timeout_value);
		if (fusion->adapter_type >= INVADER_SERIES)
		if (instance->adapter_type >= INVADER_SERIES)
			io_request->IoFlags |=
			io_request->IoFlags |=
				cpu_to_le16(MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH);
				cpu_to_le16(MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH);


@@ -3315,7 +3315,7 @@ build_mpt_mfi_pass_thru(struct megasas_instance *instance,


	io_req = cmd->io_request;
	io_req = cmd->io_request;


	if (fusion->adapter_type >= INVADER_SERIES) {
	if (instance->adapter_type >= INVADER_SERIES) {
		struct MPI25_IEEE_SGE_CHAIN64 *sgl_ptr_end =
		struct MPI25_IEEE_SGE_CHAIN64 *sgl_ptr_end =
			(struct MPI25_IEEE_SGE_CHAIN64 *)&io_req->SGL;
			(struct MPI25_IEEE_SGE_CHAIN64 *)&io_req->SGL;
		sgl_ptr_end += fusion->max_sge_in_main_msg - 1;
		sgl_ptr_end += fusion->max_sge_in_main_msg - 1;
+0 −7
Original line number Original line Diff line number Diff line
@@ -104,12 +104,6 @@ enum MR_RAID_FLAGS_IO_SUB_TYPE {
#define RAID_1_PEER_CMDS 2
#define RAID_1_PEER_CMDS 2
#define JBOD_MAPS_COUNT	2
#define JBOD_MAPS_COUNT	2


enum MR_FUSION_ADAPTER_TYPE {
	THUNDERBOLT_SERIES = 0,
	INVADER_SERIES = 1,
	VENTURA_SERIES = 2,
};

/*
/*
 * Raid Context structure which describes MegaRAID specific IO Parameters
 * Raid Context structure which describes MegaRAID specific IO Parameters
 * This resides at offset 0x60 where the SGL normally starts in MPT IO Frames
 * This resides at offset 0x60 where the SGL normally starts in MPT IO Frames
@@ -1319,7 +1313,6 @@ struct fusion_context {
	struct LD_LOAD_BALANCE_INFO *load_balance_info;
	struct LD_LOAD_BALANCE_INFO *load_balance_info;
	u32 load_balance_info_pages;
	u32 load_balance_info_pages;
	LD_SPAN_INFO log_to_span[MAX_LOGICAL_DRIVES_EXT];
	LD_SPAN_INFO log_to_span[MAX_LOGICAL_DRIVES_EXT];
	u8 adapter_type;
	struct LD_STREAM_DETECT **stream_detect_by_ld;
	struct LD_STREAM_DETECT **stream_detect_by_ld;
};
};