chengshan / rpms / kernel

Forked from rpms/kernel 2 years ago
Clone
b312fc
From 88b3ac2949cb535c5213324f33e9745d769f7dad Mon Sep 17 00:00:00 2001
b312fc
From: Sasikumar Chandrasekaran <sasikumar.pc@broadcom.com>
b312fc
Date: Tue, 10 Jan 2017 18:20:48 -0500
b312fc
Subject: [PATCH 06/11] scsi: megaraid_sas: Dynamic Raid Map Changes for SAS3.5
b312fc
 Generic Megaraid Controllers
b312fc
b312fc
SAS3.5 Generic Megaraid Controllers FW will support new dynamic RaidMap to have different
b312fc
sizes for different number of supported VDs.
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.h        |   7 +
b312fc
 drivers/scsi/megaraid/megaraid_sas_base.c   |  60 ++++--
b312fc
 drivers/scsi/megaraid/megaraid_sas_fp.c     | 301 ++++++++++++++++++++++++----
b312fc
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 225 ++++++++++++++++-----
b312fc
 drivers/scsi/megaraid/megaraid_sas_fusion.h | 240 ++++++++++++++++++----
b312fc
 5 files changed, 695 insertions(+), 138 deletions(-)
b312fc
b312fc
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
b312fc
index 0b4d37b..d5205c4 100644
b312fc
--- a/drivers/scsi/megaraid/megaraid_sas.h
b312fc
+++ b/drivers/scsi/megaraid/megaraid_sas.h
b312fc
@@ -1434,6 +1434,12 @@ enum FW_BOOT_CONTEXT {
b312fc
 #define MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT    14
b312fc
 #define MR_MAX_MSIX_REG_ARRAY                   16
b312fc
 #define MR_RDPQ_MODE_OFFSET			0X00800000
b312fc
+
b312fc
+#define MR_MAX_RAID_MAP_SIZE_OFFSET_SHIFT	16
b312fc
+#define MR_MAX_RAID_MAP_SIZE_MASK		0x1FF
b312fc
+#define MR_MIN_MAP_SIZE				0x10000
b312fc
+/* 64k */
b312fc
+
b312fc
 #define MR_CAN_HANDLE_SYNC_CACHE_OFFSET		0X01000000
b312fc
 
b312fc
 /*
b312fc
@@ -2152,6 +2158,7 @@ struct megasas_instance {
b312fc
 	bool fw_sync_cache_support;
b312fc
 	bool is_ventura;
b312fc
 	bool msix_combined;
b312fc
+	u16 max_raid_mapsize;
b312fc
 };
b312fc
 struct MR_LD_VF_MAP {
b312fc
 	u32 size;
b312fc
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
b312fc
index 0722286..1d8cf03 100644
b312fc
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
b312fc
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
b312fc
@@ -4457,8 +4457,7 @@ megasas_ld_list_query(struct megasas_instance *instance, u8 query_type)
b312fc
 static void megasas_update_ext_vd_details(struct megasas_instance *instance)
b312fc
 {
b312fc
 	struct fusion_context *fusion;
b312fc
-	u32 old_map_sz;
b312fc
-	u32 new_map_sz;
b312fc
+	u32 ventura_map_sz = 0;
b312fc
 
b312fc
 	fusion = instance->ctrl_context;
b312fc
 	/* For MFI based controllers return dummy success */
b312fc
@@ -4488,21 +4487,38 @@ static void megasas_update_ext_vd_details(struct megasas_instance *instance)
b312fc
 		instance->supportmax256vd ? "Extended VD(240 VD)firmware" :
b312fc
 		"Legacy(64 VD) firmware");
b312fc
 
b312fc
-	old_map_sz = sizeof(struct MR_FW_RAID_MAP) +
b312fc
-				(sizeof(struct MR_LD_SPAN_MAP) *
b312fc
-				(instance->fw_supported_vd_count - 1));
b312fc
-	new_map_sz = sizeof(struct MR_FW_RAID_MAP_EXT);
b312fc
-	fusion->drv_map_sz = sizeof(struct MR_DRV_RAID_MAP) +
b312fc
-				(sizeof(struct MR_LD_SPAN_MAP) *
b312fc
-				(instance->drv_supported_vd_count - 1));
b312fc
-
b312fc
-	fusion->max_map_sz = max(old_map_sz, new_map_sz);
b312fc
+	if (instance->max_raid_mapsize) {
b312fc
+		ventura_map_sz = instance->max_raid_mapsize *
b312fc
+						MR_MIN_MAP_SIZE; /* 64k */
b312fc
+		fusion->current_map_sz = ventura_map_sz;
b312fc
+		fusion->max_map_sz = ventura_map_sz;
b312fc
+	} else {
b312fc
+		fusion->old_map_sz =  sizeof(struct MR_FW_RAID_MAP) +
b312fc
+					(sizeof(struct MR_LD_SPAN_MAP) *
b312fc
+					(instance->fw_supported_vd_count - 1));
b312fc
+		fusion->new_map_sz =  sizeof(struct MR_FW_RAID_MAP_EXT);
b312fc
 
b312fc
+		fusion->max_map_sz =
b312fc
+			max(fusion->old_map_sz, fusion->new_map_sz);
b312fc
 
b312fc
-	if (instance->supportmax256vd)
b312fc
-		fusion->current_map_sz = new_map_sz;
b312fc
-	else
b312fc
-		fusion->current_map_sz = old_map_sz;
b312fc
+		if (instance->supportmax256vd)
b312fc
+			fusion->current_map_sz = fusion->new_map_sz;
b312fc
+		else
b312fc
+			fusion->current_map_sz = fusion->old_map_sz;
b312fc
+	}
b312fc
+	/* irrespective of FW raid maps, driver raid map is constant */
b312fc
+	fusion->drv_map_sz = sizeof(struct MR_DRV_RAID_MAP_ALL);
b312fc
+
b312fc
+#if VD_EXT_DEBUG
b312fc
+	dev_info(&instance->pdev->dev, "instance->max_raid_mapsize 0x%x\n ",
b312fc
+		instance->max_raid_mapsize);
b312fc
+	dev_info(&instance->pdev->dev, "new_map_sz = 0x%x, old_map_sz = 0x%x\n",
b312fc
+		fusion->new_map_sz, fusion->old_map_sz);
b312fc
+	dev_info(&instance->pdev->dev, "ventura_map_sz = 0x%x, current_map_sz = 0x%x\n",
b312fc
+		ventura_map_sz, fusion->current_map_sz);
b312fc
+	dev_info(&instance->pdev->dev, "fusion->drv_map_sz =0x%x, size of driver raid map 0x%lx\n",
b312fc
+		fusion->drv_map_sz, sizeof(struct MR_DRV_RAID_MAP_ALL));
b312fc
+#endif
b312fc
 }
b312fc
 
b312fc
 /**
b312fc
@@ -5043,7 +5059,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
b312fc
 {
b312fc
 	u32 max_sectors_1;
b312fc
 	u32 max_sectors_2;
b312fc
-	u32 tmp_sectors, msix_enable, scratch_pad_2;
b312fc
+	u32 tmp_sectors, msix_enable, scratch_pad_2, scratch_pad_3;
b312fc
 	resource_size_t base_addr;
b312fc
 	struct megasas_register_set __iomem *reg_set;
b312fc
 	struct megasas_ctrl_info *ctrl_info = NULL;
b312fc
@@ -5119,7 +5135,17 @@ static int megasas_init_fw(struct megasas_instance *instance)
b312fc
 			goto fail_ready_state;
b312fc
 	}
b312fc
 
b312fc
-
b312fc
+	if (instance->is_ventura) {
b312fc
+		scratch_pad_3 =
b312fc
+			readl(&instance->reg_set->outbound_scratch_pad_3);
b312fc
+#if VD_EXT_DEBUG
b312fc
+		dev_info(&instance->pdev->dev, "scratch_pad3 0x%x\n",
b312fc
+			scratch_pad_3);
b312fc
+#endif
b312fc
+		instance->max_raid_mapsize = ((scratch_pad_3 >>
b312fc
+			MR_MAX_RAID_MAP_SIZE_OFFSET_SHIFT) &
b312fc
+			MR_MAX_RAID_MAP_SIZE_MASK);
b312fc
+	}
b312fc
 
b312fc
 	/* Check if MSI-X is supported while in ready state */
b312fc
 	msix_enable = (instance->instancet->read_fw_status_reg(reg_set) &
b312fc
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c
b312fc
index 3644dbc..e45affe 100644
b312fc
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
b312fc
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
b312fc
@@ -179,18 +179,204 @@ void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
b312fc
 	struct fusion_context *fusion = instance->ctrl_context;
b312fc
 	struct MR_FW_RAID_MAP_ALL     *fw_map_old    = NULL;
b312fc
 	struct MR_FW_RAID_MAP         *pFwRaidMap    = NULL;
b312fc
-	int i;
b312fc
+	int i, j;
b312fc
 	u16 ld_count;
b312fc
+	struct MR_FW_RAID_MAP_DYNAMIC *fw_map_dyn;
b312fc
+	struct MR_FW_RAID_MAP_EXT *fw_map_ext;
b312fc
+	struct MR_RAID_MAP_DESC_TABLE *desc_table;
b312fc
 
b312fc
 
b312fc
 	struct MR_DRV_RAID_MAP_ALL *drv_map =
b312fc
 			fusion->ld_drv_map[(instance->map_id & 1)];
b312fc
 	struct MR_DRV_RAID_MAP *pDrvRaidMap = &drv_map->raidMap;
b312fc
+	void *raid_map_data = NULL;
b312fc
+
b312fc
+	memset(drv_map, 0, fusion->drv_map_sz);
b312fc
+	memset(pDrvRaidMap->ldTgtIdToLd,
b312fc
+		0xff, (sizeof(u16) * MAX_LOGICAL_DRIVES_DYN));
b312fc
+
b312fc
+	if (instance->max_raid_mapsize) {
b312fc
+		fw_map_dyn = fusion->ld_map[(instance->map_id & 1)];
b312fc
+#if VD_EXT_DEBUG
b312fc
+		dev_dbg(&instance->pdev->dev, "raidMapSize 0x%x fw_map_dyn->descTableOffset 0x%x\n",
b312fc
+			le32_to_cpu(fw_map_dyn->raid_map_size),
b312fc
+			le32_to_cpu(fw_map_dyn->desc_table_offset));
b312fc
+		dev_dbg(&instance->pdev->dev, "descTableSize 0x%x descTableNumElements 0x%x\n",
b312fc
+			le32_to_cpu(fw_map_dyn->desc_table_size),
b312fc
+			le32_to_cpu(fw_map_dyn->desc_table_num_elements));
b312fc
+		dev_dbg(&instance->pdev->dev, "drv map %p ldCount %d\n",
b312fc
+			drv_map, fw_map_dyn->ld_count);
b312fc
+#endif
b312fc
+		desc_table =
b312fc
+		(struct MR_RAID_MAP_DESC_TABLE *)((void *)fw_map_dyn + le32_to_cpu(fw_map_dyn->desc_table_offset));
b312fc
+		if (desc_table != fw_map_dyn->raid_map_desc_table)
b312fc
+			dev_dbg(&instance->pdev->dev, "offsets of desc table are not matching desc %p original %p\n",
b312fc
+				desc_table, fw_map_dyn->raid_map_desc_table);
b312fc
+
b312fc
+		ld_count = (u16)le16_to_cpu(fw_map_dyn->ld_count);
b312fc
+		pDrvRaidMap->ldCount = (__le16)cpu_to_le16(ld_count);
b312fc
+		pDrvRaidMap->fpPdIoTimeoutSec =
b312fc
+			fw_map_dyn->fp_pd_io_timeout_sec;
b312fc
+		pDrvRaidMap->totalSize = sizeof(struct MR_DRV_RAID_MAP_ALL);
b312fc
+		/* point to actual data starting point*/
b312fc
+		raid_map_data = (void *)fw_map_dyn +
b312fc
+			le32_to_cpu(fw_map_dyn->desc_table_offset) +
b312fc
+			le32_to_cpu(fw_map_dyn->desc_table_size);
b312fc
+
b312fc
+		for (i = 0; i < le32_to_cpu(fw_map_dyn->desc_table_num_elements); ++i) {
b312fc
+
b312fc
+#if VD_EXT_DEBUG
b312fc
+			dev_dbg(&instance->pdev->dev, "desc table %p\n",
b312fc
+				desc_table);
b312fc
+			dev_dbg(&instance->pdev->dev, "raidmap type %d, raidmapOffset 0x%x\n",
b312fc
+				desc_table->raid_map_desc_type,
b312fc
+				desc_table->raid_map_desc_offset);
b312fc
+			dev_dbg(&instance->pdev->dev, "raid map number of elements 0%x, raidmapsize 0x%x\n",
b312fc
+				desc_table->raid_map_desc_elements,
b312fc
+				desc_table->raid_map_desc_buffer_size);
b312fc
+#endif
b312fc
+			switch (le32_to_cpu(desc_table->raid_map_desc_type)) {
b312fc
+			case RAID_MAP_DESC_TYPE_DEVHDL_INFO:
b312fc
+				fw_map_dyn->dev_hndl_info =
b312fc
+				(struct MR_DEV_HANDLE_INFO *)(raid_map_data + le32_to_cpu(desc_table->raid_map_desc_offset));
b312fc
+#if VD_EXT_DEBUG
b312fc
+				dev_dbg(&instance->pdev->dev, "devHndlInfo  address %p\n",
b312fc
+					fw_map_dyn->dev_hndl_info);
b312fc
+#endif
b312fc
+				memcpy(pDrvRaidMap->devHndlInfo,
b312fc
+				fw_map_dyn->dev_hndl_info,
b312fc
+				sizeof(struct MR_DEV_HANDLE_INFO) *
b312fc
+				le32_to_cpu(desc_table->raid_map_desc_elements));
b312fc
+			break;
b312fc
+			case RAID_MAP_DESC_TYPE_TGTID_INFO:
b312fc
+				fw_map_dyn->ld_tgt_id_to_ld =
b312fc
+				(u16 *) (raid_map_data +
b312fc
+				le32_to_cpu(desc_table->raid_map_desc_offset));
b312fc
+#if VD_EXT_DEBUG
b312fc
+			dev_dbg(&instance->pdev->dev, "ldTgtIdToLd  address %p\n",
b312fc
+				fw_map_dyn->ld_tgt_id_to_ld);
b312fc
+#endif
b312fc
+			for (j = 0; j < le32_to_cpu(desc_table->raid_map_desc_elements); j++) {
b312fc
+				pDrvRaidMap->ldTgtIdToLd[j] =
b312fc
+				fw_map_dyn->ld_tgt_id_to_ld[j];
b312fc
+#if VD_EXT_DEBUG
b312fc
+				dev_dbg(&instance->pdev->dev, " %d drv ldTgtIdToLd %d\n",
b312fc
+					j, pDrvRaidMap->ldTgtIdToLd[j]);
b312fc
+#endif
b312fc
+			}
b312fc
+			break;
b312fc
+			case RAID_MAP_DESC_TYPE_ARRAY_INFO:
b312fc
+				fw_map_dyn->ar_map_info =
b312fc
+				(struct MR_ARRAY_INFO *)
b312fc
+				(raid_map_data + le32_to_cpu(desc_table->raid_map_desc_offset));
b312fc
+#if VD_EXT_DEBUG
b312fc
+				dev_dbg(&instance->pdev->dev, "arMapInfo  address %p\n",
b312fc
+					fw_map_dyn->ar_map_info);
b312fc
+#endif
b312fc
+
b312fc
+				memcpy(pDrvRaidMap->arMapInfo,
b312fc
+				fw_map_dyn->ar_map_info,
b312fc
+				sizeof(struct MR_ARRAY_INFO) * le32_to_cpu(desc_table->raid_map_desc_elements));
b312fc
+			break;
b312fc
+			case RAID_MAP_DESC_TYPE_SPAN_INFO:
b312fc
+				fw_map_dyn->ld_span_map =
b312fc
+				(struct MR_LD_SPAN_MAP *)
b312fc
+				(raid_map_data + le32_to_cpu(desc_table->raid_map_desc_offset));
b312fc
+				memcpy(pDrvRaidMap->ldSpanMap,
b312fc
+				fw_map_dyn->ld_span_map,
b312fc
+				sizeof(struct MR_LD_SPAN_MAP) * le32_to_cpu(desc_table->raid_map_desc_elements));
b312fc
+#if VD_EXT_DEBUG
b312fc
+				dev_dbg(&instance->pdev->dev, "ldSpanMap  address %p\n",
b312fc
+					fw_map_dyn->ld_span_map);
b312fc
+				dev_dbg(&instance->pdev->dev, "MR_LD_SPAN_MAP size 0x%lx\n",
b312fc
+					sizeof(struct MR_LD_SPAN_MAP));
b312fc
+				for (j = 0; j < ld_count; j++) {
b312fc
+					dev_dbg(&instance->pdev->dev, "megaraid_sas(%d) : fw_map_dyn->ldSpanMap[%d].ldRaid.targetId 0x%x\n",
b312fc
+					j, j, fw_map_dyn->ld_span_map[j].ldRaid.targetId);
b312fc
+					dev_dbg(&instance->pdev->dev, "fw_map_dyn->ldSpanMap[%d].ldRaid.seqNum 0x%x\n",
b312fc
+					j, fw_map_dyn->ld_span_map[j].ldRaid.seqNum);
b312fc
+					dev_dbg(&instance->pdev->dev, "fw_map_dyn->ld_span_map[%d].ldRaid.rowSize 0x%x\n",
b312fc
+					j, (u32)fw_map_dyn->ld_span_map[j].ldRaid.rowSize);
b312fc
+
b312fc
+					dev_dbg(&instance->pdev->dev, "megaraid_sas(%d) :pDrvRaidMap->ldSpanMap[%d].ldRaid.targetId 0x%x\n",
b312fc
+					j, j, pDrvRaidMap->ldSpanMap[j].ldRaid.targetId);
b312fc
+					dev_dbg(&instance->pdev->dev, "DrvRaidMap->ldSpanMap[%d].ldRaid.seqNum 0x%x\n",
b312fc
+					j, pDrvRaidMap->ldSpanMap[j].ldRaid.seqNum);
b312fc
+					dev_dbg(&instance->pdev->dev, "pDrvRaidMap->ldSpanMap[%d].ldRaid.rowSize 0x%x\n",
b312fc
+					j, (u32)pDrvRaidMap->ldSpanMap[j].ldRaid.rowSize);
b312fc
+
b312fc
+					dev_dbg(&instance->pdev->dev, "megaraid_sas(%d) : drv raid map all %p\n",
b312fc
+					instance->unique_id, drv_map);
b312fc
+					dev_dbg(&instance->pdev->dev, "raid map %p LD RAID MAP %p/%p\n",
b312fc
+					pDrvRaidMap,
b312fc
+					&fw_map_dyn->ld_span_map[j].ldRaid,
b312fc
+					&pDrvRaidMap->ldSpanMap[j].ldRaid);
b312fc
+				}
b312fc
+#endif
b312fc
+			break;
b312fc
+			default:
b312fc
+				dev_dbg(&instance->pdev->dev, "wrong number of desctableElements %d\n",
b312fc
+					fw_map_dyn->desc_table_num_elements);
b312fc
+			}
b312fc
+			++desc_table;
b312fc
+		}
b312fc
+
b312fc
+	} else if (instance->supportmax256vd) {
b312fc
+		fw_map_ext =
b312fc
+		(struct MR_FW_RAID_MAP_EXT *) fusion->ld_map[(instance->map_id & 1)];
b312fc
+		ld_count = (u16)le16_to_cpu(fw_map_ext->ldCount);
b312fc
+		if (ld_count > MAX_LOGICAL_DRIVES_EXT) {
b312fc
+			dev_dbg(&instance->pdev->dev, "megaraid_sas: LD count exposed in RAID map in not valid\n");
b312fc
+			return;
b312fc
+		}
b312fc
+#if VD_EXT_DEBUG
b312fc
+		for (i = 0; i < ld_count; i++) {
b312fc
+			dev_dbg(&instance->pdev->dev, "megaraid_sas(%d) :Index 0x%x\n",
b312fc
+				instance->unique_id, i);
b312fc
+			dev_dbg(&instance->pdev->dev, "Target Id 0x%x\n",
b312fc
+				fw_map_ext->ldSpanMap[i].ldRaid.targetId);
b312fc
+			dev_dbg(&instance->pdev->dev, "Seq Num 0x%x Size 0/%llx\n",
b312fc
+				fw_map_ext->ldSpanMap[i].ldRaid.seqNum,
b312fc
+				fw_map_ext->ldSpanMap[i].ldRaid.size);
b312fc
+		}
b312fc
+#endif
b312fc
+
b312fc
+		pDrvRaidMap->ldCount = (__le16)cpu_to_le16(ld_count);
b312fc
+		pDrvRaidMap->fpPdIoTimeoutSec = fw_map_ext->fpPdIoTimeoutSec;
b312fc
+		for (i = 0; i < (MAX_LOGICAL_DRIVES_EXT); i++)
b312fc
+			pDrvRaidMap->ldTgtIdToLd[i] =
b312fc
+				(u16)fw_map_ext->ldTgtIdToLd[i];
b312fc
+		memcpy(pDrvRaidMap->ldSpanMap, fw_map_ext->ldSpanMap,
b312fc
+				sizeof(struct MR_LD_SPAN_MAP) * ld_count);
b312fc
+#if VD_EXT_DEBUG
b312fc
+		for (i = 0; i < ld_count; i++) {
b312fc
+			dev_dbg(&instance->pdev->dev, "megaraid_sas(%d) : fw_map_ext->ldSpanMap[%d].ldRaid.targetId 0x%x\n",
b312fc
+			i, i, fw_map_ext->ldSpanMap[i].ldRaid.targetId);
b312fc
+			dev_dbg(&instance->pdev->dev, "fw_map_ext->ldSpanMap[%d].ldRaid.seqNum 0x%x\n",
b312fc
+			i, fw_map_ext->ldSpanMap[i].ldRaid.seqNum);
b312fc
+			dev_dbg(&instance->pdev->dev, "fw_map_ext->ldSpanMap[%d].ldRaid.rowSize 0x%x\n",
b312fc
+			i, (u32)fw_map_ext->ldSpanMap[i].ldRaid.rowSize);
b312fc
+
b312fc
+			dev_dbg(&instance->pdev->dev, "megaraid_sas(%d) : pDrvRaidMap->ldSpanMap[%d].ldRaid.targetId 0x%x\n",
b312fc
+			i, i, pDrvRaidMap->ldSpanMap[i].ldRaid.targetId);
b312fc
+			dev_dbg(&instance->pdev->dev, "pDrvRaidMap->ldSpanMap[%d].ldRaid.seqNum 0x%x\n",
b312fc
+			i, pDrvRaidMap->ldSpanMap[i].ldRaid.seqNum);
b312fc
+			dev_dbg(&instance->pdev->dev, "pDrvRaidMap->ldSpanMap[%d].ldRaid.rowSize 0x%x\n",
b312fc
+			i, (u32)pDrvRaidMap->ldSpanMap[i].ldRaid.rowSize);
b312fc
+
b312fc
+			dev_dbg(&instance->pdev->dev, "megaraid_sas(%d) : drv raid map all %p\n",
b312fc
+			instance->unique_id, drv_map);
b312fc
+			dev_dbg(&instance->pdev->dev, "raid map %p LD RAID MAP %p %p\n",
b312fc
+			pDrvRaidMap, &fw_map_ext->ldSpanMap[i].ldRaid,
b312fc
+			&pDrvRaidMap->ldSpanMap[i].ldRaid);
b312fc
+		}
b312fc
+#endif
b312fc
+		memcpy(pDrvRaidMap->arMapInfo, fw_map_ext->arMapInfo,
b312fc
+			sizeof(struct MR_ARRAY_INFO) * MAX_API_ARRAYS_EXT);
b312fc
+		memcpy(pDrvRaidMap->devHndlInfo, fw_map_ext->devHndlInfo,
b312fc
+			sizeof(struct MR_DEV_HANDLE_INFO) *
b312fc
+					MAX_RAIDMAP_PHYSICAL_DEVICES);
b312fc
 
b312fc
-	if (instance->supportmax256vd) {
b312fc
-		memcpy(fusion->ld_drv_map[instance->map_id & 1],
b312fc
-			fusion->ld_map[instance->map_id & 1],
b312fc
-			fusion->current_map_sz);
b312fc
 		/* New Raid map will not set totalSize, so keep expected value
b312fc
 		 * for legacy code in ValidateMapInfo
b312fc
 		 */
b312fc
@@ -213,16 +399,12 @@ void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
b312fc
 		}
b312fc
 #endif
b312fc
 
b312fc
-		memset(drv_map, 0, fusion->drv_map_sz);
b312fc
 		pDrvRaidMap->totalSize = pFwRaidMap->totalSize;
b312fc
 		pDrvRaidMap->ldCount = (__le16)cpu_to_le16(ld_count);
b312fc
 		pDrvRaidMap->fpPdIoTimeoutSec = pFwRaidMap->fpPdIoTimeoutSec;
b312fc
 		for (i = 0; i < MAX_RAIDMAP_LOGICAL_DRIVES + MAX_RAIDMAP_VIEWS; i++)
b312fc
 			pDrvRaidMap->ldTgtIdToLd[i] =
b312fc
 				(u8)pFwRaidMap->ldTgtIdToLd[i];
b312fc
-		for (i = (MAX_RAIDMAP_LOGICAL_DRIVES + MAX_RAIDMAP_VIEWS);
b312fc
-			i < MAX_LOGICAL_DRIVES_EXT; i++)
b312fc
-			pDrvRaidMap->ldTgtIdToLd[i] = 0xff;
b312fc
 		for (i = 0; i < ld_count; i++) {
b312fc
 			pDrvRaidMap->ldSpanMap[i] = pFwRaidMap->ldSpanMap[i];
b312fc
 #if VD_EXT_DEBUG
b312fc
@@ -279,7 +461,9 @@ u8 MR_ValidateMapInfo(struct megasas_instance *instance)
b312fc
 	lbInfo = fusion->load_balance_info;
b312fc
 	ldSpanInfo = fusion->log_to_span;
b312fc
 
b312fc
-	if (instance->supportmax256vd)
b312fc
+	if (instance->max_raid_mapsize)
b312fc
+		expected_size = sizeof(struct MR_DRV_RAID_MAP_ALL);
b312fc
+	else if (instance->supportmax256vd)
b312fc
 		expected_size = sizeof(struct MR_FW_RAID_MAP_EXT);
b312fc
 	else
b312fc
 		expected_size =
b312fc
@@ -287,8 +471,10 @@ u8 MR_ValidateMapInfo(struct megasas_instance *instance)
b312fc
 			(sizeof(struct MR_LD_SPAN_MAP) * le16_to_cpu(pDrvRaidMap->ldCount)));
b312fc
 
b312fc
 	if (le32_to_cpu(pDrvRaidMap->totalSize) != expected_size) {
b312fc
-		dev_err(&instance->pdev->dev, "map info structure size 0x%x is not matching with ld count\n",
b312fc
-		       (unsigned int) expected_size);
b312fc
+		dev_dbg(&instance->pdev->dev, "megasas: map info structure size 0x%x",
b312fc
+			le32_to_cpu(pDrvRaidMap->totalSize));
b312fc
+		dev_dbg(&instance->pdev->dev, "is not matching expected size 0x%x\n",
b312fc
+			(unsigned int) expected_size);
b312fc
 		dev_err(&instance->pdev->dev, "megasas: span map %x, pDrvRaidMap->totalSize : %x\n",
b312fc
 			(unsigned int)sizeof(struct MR_LD_SPAN_MAP),
b312fc
 			le32_to_cpu(pDrvRaidMap->totalSize));
b312fc
@@ -787,7 +973,7 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld,
b312fc
 			((fusion->adapter_type == THUNDERBOLT_SERIES)  ||
b312fc
 			((fusion->adapter_type == INVADER_SERIES) &&
b312fc
 			(raid->regTypeReqOnRead != REGION_TYPE_UNUSED))))
b312fc
-			pRAID_Context->regLockFlags = REGION_TYPE_EXCLUSIVE;
b312fc
+			pRAID_Context->reg_lock_flags = REGION_TYPE_EXCLUSIVE;
b312fc
 		else if (raid->level == 1) {
b312fc
 			pd = MR_ArPdGet(arRef, physArm + 1, map);
b312fc
 			if (pd != MR_PD_INVALID)
b312fc
@@ -796,9 +982,16 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld,
b312fc
 	}
b312fc
 
b312fc
 	*pdBlock += stripRef + le64_to_cpu(MR_LdSpanPtrGet(ld, span, map)->startBlk);
b312fc
-	pRAID_Context->spanArm = (span << RAID_CTX_SPANARM_SPAN_SHIFT) |
b312fc
-					physArm;
b312fc
-	io_info->span_arm = pRAID_Context->spanArm;
b312fc
+	if (instance->is_ventura) {
b312fc
+		((struct RAID_CONTEXT_G35 *) pRAID_Context)->span_arm =
b312fc
+			(span << RAID_CTX_SPANARM_SPAN_SHIFT) | physArm;
b312fc
+		io_info->span_arm =
b312fc
+			(span << RAID_CTX_SPANARM_SPAN_SHIFT) | physArm;
b312fc
+	} else {
b312fc
+		pRAID_Context->span_arm =
b312fc
+			(span << RAID_CTX_SPANARM_SPAN_SHIFT) | physArm;
b312fc
+		io_info->span_arm = pRAID_Context->span_arm;
b312fc
+	}
b312fc
 	return retval;
b312fc
 }
b312fc
 
b312fc
@@ -890,7 +1083,7 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 ld, u64 stripRow,
b312fc
 			((fusion->adapter_type == THUNDERBOLT_SERIES)  ||
b312fc
 			((fusion->adapter_type == INVADER_SERIES) &&
b312fc
 			(raid->regTypeReqOnRead != REGION_TYPE_UNUSED))))
b312fc
-			pRAID_Context->regLockFlags = REGION_TYPE_EXCLUSIVE;
b312fc
+			pRAID_Context->reg_lock_flags = REGION_TYPE_EXCLUSIVE;
b312fc
 		else if (raid->level == 1) {
b312fc
 			/* Get alternate Pd. */
b312fc
 			pd = MR_ArPdGet(arRef, physArm + 1, map);
b312fc
@@ -901,9 +1094,16 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 ld, u64 stripRow,
b312fc
 	}
b312fc
 
b312fc
 	*pdBlock += stripRef + le64_to_cpu(MR_LdSpanPtrGet(ld, span, map)->startBlk);
b312fc
-	pRAID_Context->spanArm = (span << RAID_CTX_SPANARM_SPAN_SHIFT) |
b312fc
-		physArm;
b312fc
-	io_info->span_arm = pRAID_Context->spanArm;
b312fc
+	if (instance->is_ventura) {
b312fc
+		((struct RAID_CONTEXT_G35 *) pRAID_Context)->span_arm =
b312fc
+				(span << RAID_CTX_SPANARM_SPAN_SHIFT) | physArm;
b312fc
+		io_info->span_arm =
b312fc
+				(span << RAID_CTX_SPANARM_SPAN_SHIFT) | physArm;
b312fc
+	} else {
b312fc
+		pRAID_Context->span_arm =
b312fc
+			(span << RAID_CTX_SPANARM_SPAN_SHIFT) | physArm;
b312fc
+		io_info->span_arm = pRAID_Context->span_arm;
b312fc
+	}
b312fc
 	return retval;
b312fc
 }
b312fc
 
b312fc
@@ -1107,20 +1307,20 @@ MR_BuildRaidContext(struct megasas_instance *instance,
b312fc
 			regSize += stripSize;
b312fc
 	}
b312fc
 
b312fc
-	pRAID_Context->timeoutValue =
b312fc
+	pRAID_Context->timeout_value =
b312fc
 		cpu_to_le16(raid->fpIoTimeoutForLd ?
b312fc
 			    raid->fpIoTimeoutForLd :
b312fc
 			    map->raidMap.fpPdIoTimeoutSec);
b312fc
 	if (fusion->adapter_type == INVADER_SERIES)
b312fc
-		pRAID_Context->regLockFlags = (isRead) ?
b312fc
+		pRAID_Context->reg_lock_flags = (isRead) ?
b312fc
 			raid->regTypeReqOnRead : raid->regTypeReqOnWrite;
b312fc
-	else
b312fc
-		pRAID_Context->regLockFlags = (isRead) ?
b312fc
+	else if (!instance->is_ventura)
b312fc
+		pRAID_Context->reg_lock_flags = (isRead) ?
b312fc
 			REGION_TYPE_SHARED_READ : raid->regTypeReqOnWrite;
b312fc
-	pRAID_Context->VirtualDiskTgtId = raid->targetId;
b312fc
-	pRAID_Context->regLockRowLBA    = cpu_to_le64(regStart);
b312fc
-	pRAID_Context->regLockLength    = cpu_to_le32(regSize);
b312fc
-	pRAID_Context->configSeqNum	= raid->seqNum;
b312fc
+	pRAID_Context->virtual_disk_tgt_id = raid->targetId;
b312fc
+	pRAID_Context->reg_lock_row_lba    = cpu_to_le64(regStart);
b312fc
+	pRAID_Context->reg_lock_length    = cpu_to_le32(regSize);
b312fc
+	pRAID_Context->config_seq_num	= raid->seqNum;
b312fc
 	/* save pointer to raid->LUN array */
b312fc
 	*raidLUN = raid->LUN;
b312fc
 
b312fc
@@ -1138,6 +1338,13 @@ MR_BuildRaidContext(struct megasas_instance *instance,
b312fc
 		/* If IO on an invalid Pd, then FP is not possible.*/
b312fc
 		if (io_info->devHandle == cpu_to_le16(MR_PD_INVALID))
b312fc
 			io_info->fpOkForIo = FALSE;
b312fc
+		/* if FP possible, set the SLUD bit in
b312fc
+		 *  regLockFlags for ventura
b312fc
+		 */
b312fc
+		else if ((instance->is_ventura) && (!isRead) &&
b312fc
+			(raid->writeMode == MR_RL_WRITE_BACK_MODE) &&
b312fc
+			(raid->capability.fp_cache_bypass_capable))
b312fc
+			((struct RAID_CONTEXT_G35 *) pRAID_Context)->routing_flags.bits.sld = 1;
b312fc
 		/* set raid 1/10 fast path write capable bit in io_info */
b312fc
 		if (io_info->fpOkForIo &&
b312fc
 		    (io_info->r1_alt_dev_handle != MR_PD_INVALID) &&
b312fc
@@ -1317,6 +1524,7 @@ u8 megasas_get_best_arm_pd(struct megasas_instance *instance,
b312fc
 	struct fusion_context *fusion;
b312fc
 	struct MR_LD_RAID  *raid;
b312fc
 	struct MR_DRV_RAID_MAP_ALL *drv_map;
b312fc
+	u16	pd1_dev_handle;
b312fc
 	u16     pend0, pend1, ld;
b312fc
 	u64     diff0, diff1;
b312fc
 	u8      bestArm, pd0, pd1, span, arm;
b312fc
@@ -1342,23 +1550,36 @@ u8 megasas_get_best_arm_pd(struct megasas_instance *instance,
b312fc
 	pd1 = MR_ArPdGet(arRef, (arm + 1) >= span_row_size ?
b312fc
 		(arm + 1 - span_row_size) : arm + 1, drv_map);
b312fc
 
b312fc
-	/* get the pending cmds for the data and mirror arms */
b312fc
-	pend0 = atomic_read(&lbInfo->scsi_pending_cmds[pd0]);
b312fc
-	pend1 = atomic_read(&lbInfo->scsi_pending_cmds[pd1]);
b312fc
+	/* Get PD1 Dev Handle */
b312fc
+
b312fc
+	pd1_dev_handle = MR_PdDevHandleGet(pd1, drv_map);
b312fc
+
b312fc
+	if (pd1_dev_handle == MR_PD_INVALID) {
b312fc
+		bestArm = arm;
b312fc
+	} else {
b312fc
+		/* get the pending cmds for the data and mirror arms */
b312fc
+		pend0 = atomic_read(&lbInfo->scsi_pending_cmds[pd0]);
b312fc
+		pend1 = atomic_read(&lbInfo->scsi_pending_cmds[pd1]);
b312fc
 
b312fc
-	/* Determine the disk whose head is nearer to the req. block */
b312fc
-	diff0 = ABS_DIFF(block, lbInfo->last_accessed_block[pd0]);
b312fc
-	diff1 = ABS_DIFF(block, lbInfo->last_accessed_block[pd1]);
b312fc
-	bestArm = (diff0 <= diff1 ? arm : arm ^ 1);
b312fc
+		/* Determine the disk whose head is nearer to the req. block */
b312fc
+		diff0 = ABS_DIFF(block, lbInfo->last_accessed_block[pd0]);
b312fc
+		diff1 = ABS_DIFF(block, lbInfo->last_accessed_block[pd1]);
b312fc
+		bestArm = (diff0 <= diff1 ? arm : arm ^ 1);
b312fc
 
b312fc
-	if ((bestArm == arm && pend0 > pend1 + lb_pending_cmds)  ||
b312fc
+		/* Make balance count from 16 to 4 to
b312fc
+		 *  keep driver in sync with Firmware
b312fc
+		 */
b312fc
+		if ((bestArm == arm && pend0 > pend1 + lb_pending_cmds)  ||
b312fc
 			(bestArm != arm && pend1 > pend0 + lb_pending_cmds))
b312fc
-		bestArm ^= 1;
b312fc
+			bestArm ^= 1;
b312fc
+
b312fc
+		/* Update the last accessed block on the correct pd */
b312fc
+		io_info->span_arm =
b312fc
+			(span << RAID_CTX_SPANARM_SPAN_SHIFT) | bestArm;
b312fc
+		io_info->pd_after_lb = (bestArm == arm) ? pd0 : pd1;
b312fc
+	}
b312fc
 
b312fc
-	/* Update the last accessed block on the correct pd */
b312fc
-	io_info->pd_after_lb = (bestArm == arm) ? pd0 : pd1;
b312fc
 	lbInfo->last_accessed_block[io_info->pd_after_lb] = block + count - 1;
b312fc
-	io_info->span_arm = (span << RAID_CTX_SPANARM_SPAN_SHIFT) | bestArm;
b312fc
 #if SPAN_DEBUG
b312fc
 	if (arm != bestArm)
b312fc
 		dev_dbg(&instance->pdev->dev, "LSI Debug R1 Load balance "
b312fc
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
b312fc
index b146cd1..178f166 100644
b312fc
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
b312fc
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
b312fc
@@ -1829,7 +1829,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
b312fc
 			  struct megasas_cmd_fusion *cmd)
b312fc
 {
b312fc
 	u8 fp_possible;
b312fc
-	u32 start_lba_lo, start_lba_hi, device_id, datalength = 0;
b312fc
+	u32 start_lba_lo, start_lba_hi, device_id, datalength = 0, ld;
b312fc
 	struct MPI2_RAID_SCSI_IO_REQUEST *io_request;
b312fc
 	union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc;
b312fc
 	struct IO_REQUEST_INFO io_info;
b312fc
@@ -1837,16 +1837,18 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
b312fc
 	struct MR_DRV_RAID_MAP_ALL *local_map_ptr;
b312fc
 	u8 *raidLUN;
b312fc
 	unsigned long spinlock_flags;
b312fc
+	union RAID_CONTEXT_UNION *praid_context;
b312fc
+	struct MR_LD_RAID *raid;
b312fc
 
b312fc
 	device_id = MEGASAS_DEV_INDEX(scp);
b312fc
 
b312fc
 	fusion = instance->ctrl_context;
b312fc
 
b312fc
 	io_request = cmd->io_request;
b312fc
-	io_request->RaidContext.raid_context.VirtualDiskTgtId =
b312fc
+	io_request->RaidContext.raid_context.virtual_disk_tgt_id =
b312fc
 		cpu_to_le16(device_id);
b312fc
 	io_request->RaidContext.raid_context.status = 0;
b312fc
-	io_request->RaidContext.raid_context.exStatus = 0;
b312fc
+	io_request->RaidContext.raid_context.ex_status = 0;
b312fc
 
b312fc
 	req_desc = (union MEGASAS_REQUEST_DESCRIPTOR_UNION *)cmd->request_desc;
b312fc
 
b312fc
@@ -1915,10 +1917,12 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
b312fc
 		io_info.isRead = 1;
b312fc
 
b312fc
 	local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)];
b312fc
+	ld = MR_TargetIdToLdGet(device_id, local_map_ptr);
b312fc
+	raid = MR_LdRaidGet(ld, local_map_ptr);
b312fc
 
b312fc
 	if ((MR_TargetIdToLdGet(device_id, local_map_ptr) >=
b312fc
 		instance->fw_supported_vd_count) || (!fusion->fast_path_io)) {
b312fc
-		io_request->RaidContext.raid_context.regLockFlags  = 0;
b312fc
+		io_request->RaidContext.raid_context.reg_lock_flags  = 0;
b312fc
 		fp_possible = 0;
b312fc
 	} else {
b312fc
 		if (MR_BuildRaidContext(instance, &io_info,
b312fc
@@ -1945,6 +1949,8 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
b312fc
 			fp_possible = false;
b312fc
 	}
b312fc
 
b312fc
+	praid_context = &io_request->RaidContext;
b312fc
+
b312fc
 	if (fp_possible) {
b312fc
 		megasas_set_pd_lba(io_request, scp->cmd_len, &io_info, scp,
b312fc
 				   local_map_ptr, start_lba_lo);
b312fc
@@ -1953,18 +1959,25 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
b312fc
 			(MPI2_REQ_DESCRIPT_FLAGS_FP_IO
b312fc
 			 << MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
b312fc
 		if (fusion->adapter_type == INVADER_SERIES) {
b312fc
-			if (io_request->RaidContext.raid_context.regLockFlags ==
b312fc
+			if (io_request->RaidContext.raid_context.reg_lock_flags ==
b312fc
 			    REGION_TYPE_UNUSED)
b312fc
 				cmd->request_desc->SCSIIO.RequestFlags =
b312fc
 					(MEGASAS_REQ_DESCRIPT_FLAGS_NO_LOCK <<
b312fc
 					MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
b312fc
-			io_request->RaidContext.raid_context.Type
b312fc
+			io_request->RaidContext.raid_context.type
b312fc
 				= MPI2_TYPE_CUDA;
b312fc
 			io_request->RaidContext.raid_context.nseg = 0x1;
b312fc
 			io_request->IoFlags |= cpu_to_le16(MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH);
b312fc
-			io_request->RaidContext.raid_context.regLockFlags |=
b312fc
+			io_request->RaidContext.raid_context.reg_lock_flags |=
b312fc
 			  (MR_RL_FLAGS_GRANT_DESTINATION_CUDA |
b312fc
 			   MR_RL_FLAGS_SEQ_NUM_ENABLE);
b312fc
+		} else if (instance->is_ventura) {
b312fc
+			io_request->RaidContext.raid_context_g35.type
b312fc
+				= MPI2_TYPE_CUDA;
b312fc
+			io_request->RaidContext.raid_context_g35.nseg = 0x1;
b312fc
+			io_request->RaidContext.raid_context_g35.routing_flags.bits.sqn = 1;
b312fc
+			io_request->IoFlags |=
b312fc
+			cpu_to_le16(MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH);
b312fc
 		}
b312fc
 		if ((fusion->load_balance_info[device_id].loadBalanceFlag) &&
b312fc
 		    (io_info.isRead)) {
b312fc
@@ -1974,6 +1987,13 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
b312fc
 					&io_info);
b312fc
 			scp->SCp.Status |= MEGASAS_LOAD_BALANCE_FLAG;
b312fc
 			cmd->pd_r1_lb = io_info.pd_after_lb;
b312fc
+			if (instance->is_ventura)
b312fc
+				io_request->RaidContext.raid_context_g35.span_arm
b312fc
+					= io_info.span_arm;
b312fc
+			else
b312fc
+				io_request->RaidContext.raid_context.span_arm
b312fc
+					= io_info.span_arm;
b312fc
+
b312fc
 		} else
b312fc
 			scp->SCp.Status &= ~MEGASAS_LOAD_BALANCE_FLAG;
b312fc
 
b312fc
@@ -1992,28 +2012,98 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
b312fc
 		io_request->DevHandle = io_info.devHandle;
b312fc
 		/* populate the LUN field */
b312fc
 		memcpy(io_request->LUN, raidLUN, 8);
b312fc
+		if (instance->is_ventura) {
b312fc
+			if (io_info.isRead) {
b312fc
+				if ((raid->cpuAffinity.pdRead.cpu0) &&
b312fc
+					(raid->cpuAffinity.pdRead.cpu1))
b312fc
+					praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+					= MR_RAID_CTX_CPUSEL_FCFS;
b312fc
+				else if (raid->cpuAffinity.pdRead.cpu1)
b312fc
+					praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+					= MR_RAID_CTX_CPUSEL_1;
b312fc
+				else
b312fc
+					praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+					= MR_RAID_CTX_CPUSEL_0;
b312fc
+			} else {
b312fc
+			if ((raid->cpuAffinity.pdWrite.cpu0)
b312fc
+			&& (raid->cpuAffinity.pdWrite.cpu1))
b312fc
+				praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+					= MR_RAID_CTX_CPUSEL_FCFS;
b312fc
+				else if (raid->cpuAffinity.pdWrite.cpu1)
b312fc
+					praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+					= MR_RAID_CTX_CPUSEL_1;
b312fc
+				else
b312fc
+					praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+					= MR_RAID_CTX_CPUSEL_0;
b312fc
+				if (praid_context->raid_context_g35.routing_flags.bits.sld) {
b312fc
+					praid_context->raid_context_g35.raid_flags
b312fc
+					= (MR_RAID_FLAGS_IO_SUB_TYPE_CACHE_BYPASS
b312fc
+					<< MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT);
b312fc
+				}
b312fc
+			}
b312fc
+		}
b312fc
 	} else {
b312fc
-		io_request->RaidContext.raid_context.timeoutValue =
b312fc
+		io_request->RaidContext.raid_context.timeout_value =
b312fc
 			cpu_to_le16(local_map_ptr->raidMap.fpPdIoTimeoutSec);
b312fc
 		cmd->request_desc->SCSIIO.RequestFlags =
b312fc
 			(MEGASAS_REQ_DESCRIPT_FLAGS_LD_IO
b312fc
 			 << MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
b312fc
 		if (fusion->adapter_type == INVADER_SERIES) {
b312fc
 			if (io_info.do_fp_rlbypass ||
b312fc
-			(io_request->RaidContext.raid_context.regLockFlags
b312fc
+			(io_request->RaidContext.raid_context.reg_lock_flags
b312fc
 					== REGION_TYPE_UNUSED))
b312fc
 				cmd->request_desc->SCSIIO.RequestFlags =
b312fc
 					(MEGASAS_REQ_DESCRIPT_FLAGS_NO_LOCK <<
b312fc
 					MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
b312fc
-			io_request->RaidContext.raid_context.Type
b312fc
+			io_request->RaidContext.raid_context.type
b312fc
 				= MPI2_TYPE_CUDA;
b312fc
-			io_request->RaidContext.raid_context.regLockFlags |=
b312fc
+			io_request->RaidContext.raid_context.reg_lock_flags |=
b312fc
 				(MR_RL_FLAGS_GRANT_DESTINATION_CPU0 |
b312fc
 				 MR_RL_FLAGS_SEQ_NUM_ENABLE);
b312fc
 			io_request->RaidContext.raid_context.nseg = 0x1;
b312fc
+		} else if (instance->is_ventura) {
b312fc
+			io_request->RaidContext.raid_context_g35.type
b312fc
+				= MPI2_TYPE_CUDA;
b312fc
+			io_request->RaidContext.raid_context_g35.routing_flags.bits.sqn = 1;
b312fc
+			io_request->RaidContext.raid_context_g35.nseg = 0x1;
b312fc
 		}
b312fc
 		io_request->Function = MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST;
b312fc
 		io_request->DevHandle = cpu_to_le16(device_id);
b312fc
+
b312fc
+		if (instance->is_ventura) {
b312fc
+			if (io_info.isRead) {
b312fc
+				if ((raid->cpuAffinity.ldRead.cpu0)
b312fc
+				&& (raid->cpuAffinity.ldRead.cpu1))
b312fc
+					praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+					= MR_RAID_CTX_CPUSEL_FCFS;
b312fc
+				else if (raid->cpuAffinity.ldRead.cpu1)
b312fc
+					praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+						= MR_RAID_CTX_CPUSEL_1;
b312fc
+				else
b312fc
+					praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+						= MR_RAID_CTX_CPUSEL_0;
b312fc
+			} else {
b312fc
+				if ((raid->cpuAffinity.ldWrite.cpu0) &&
b312fc
+					(raid->cpuAffinity.ldWrite.cpu1))
b312fc
+					praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+						= MR_RAID_CTX_CPUSEL_FCFS;
b312fc
+				else if (raid->cpuAffinity.ldWrite.cpu1)
b312fc
+					praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+						= MR_RAID_CTX_CPUSEL_1;
b312fc
+				else
b312fc
+					praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+					= MR_RAID_CTX_CPUSEL_0;
b312fc
+
b312fc
+				if (io_request->RaidContext.raid_context_g35.stream_detected
b312fc
+					&& (raid->level == 5) &&
b312fc
+					(raid->writeMode == MR_RL_WRITE_THROUGH_MODE)) {
b312fc
+					if (praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+						== MR_RAID_CTX_CPUSEL_FCFS)
b312fc
+						praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+							= MR_RAID_CTX_CPUSEL_0;
b312fc
+				}
b312fc
+			}
b312fc
+		}
b312fc
 	} /* Not FP */
b312fc
 }
b312fc
 
b312fc
@@ -2048,9 +2138,9 @@ static void megasas_build_ld_nonrw_fusion(struct megasas_instance *instance,
b312fc
 	/* get RAID_Context pointer */
b312fc
 	pRAID_Context = &io_request->RaidContext.raid_context;
b312fc
 	/* Check with FW team */
b312fc
-	pRAID_Context->VirtualDiskTgtId = cpu_to_le16(device_id);
b312fc
-	pRAID_Context->regLockRowLBA    = 0;
b312fc
-	pRAID_Context->regLockLength    = 0;
b312fc
+	pRAID_Context->virtual_disk_tgt_id = cpu_to_le16(device_id);
b312fc
+	pRAID_Context->reg_lock_row_lba    = 0;
b312fc
+	pRAID_Context->reg_lock_length    = 0;
b312fc
 
b312fc
 	if (fusion->fast_path_io && (
b312fc
 		device_id < instance->fw_supported_vd_count)) {
b312fc
@@ -2069,7 +2159,7 @@ static void megasas_build_ld_nonrw_fusion(struct megasas_instance *instance,
b312fc
 		io_request->Function  = MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST;
b312fc
 		io_request->DevHandle = cpu_to_le16(device_id);
b312fc
 		io_request->LUN[1] = scmd->device->lun;
b312fc
-		pRAID_Context->timeoutValue =
b312fc
+		pRAID_Context->timeout_value =
b312fc
 			cpu_to_le16 (scmd->request->timeout / HZ);
b312fc
 		cmd->request_desc->SCSIIO.RequestFlags =
b312fc
 			(MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO <<
b312fc
@@ -2077,9 +2167,11 @@ static void megasas_build_ld_nonrw_fusion(struct megasas_instance *instance,
b312fc
 	} else {
b312fc
 
b312fc
 		/* set RAID context values */
b312fc
-		pRAID_Context->configSeqNum = raid->seqNum;
b312fc
-		pRAID_Context->regLockFlags = REGION_TYPE_SHARED_READ;
b312fc
-		pRAID_Context->timeoutValue = cpu_to_le16(raid->fpIoTimeoutForLd);
b312fc
+		pRAID_Context->config_seq_num = raid->seqNum;
b312fc
+		if (!instance->is_ventura)
b312fc
+			pRAID_Context->reg_lock_flags = REGION_TYPE_SHARED_READ;
b312fc
+		pRAID_Context->timeout_value =
b312fc
+			cpu_to_le16(raid->fpIoTimeoutForLd);
b312fc
 
b312fc
 		/* get the DevHandle for the PD (since this is
b312fc
 		   fpNonRWCapable, this is a single disk RAID0) */
b312fc
@@ -2134,12 +2226,12 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
b312fc
 	io_request = cmd->io_request;
b312fc
 	/* get RAID_Context pointer */
b312fc
 	pRAID_Context = &io_request->RaidContext.raid_context;
b312fc
-	pRAID_Context->regLockFlags = 0;
b312fc
-	pRAID_Context->regLockRowLBA = 0;
b312fc
-	pRAID_Context->regLockLength = 0;
b312fc
+	pRAID_Context->reg_lock_flags = 0;
b312fc
+	pRAID_Context->reg_lock_row_lba = 0;
b312fc
+	pRAID_Context->reg_lock_length = 0;
b312fc
 	io_request->DataLength = cpu_to_le32(scsi_bufflen(scmd));
b312fc
 	io_request->LUN[1] = scmd->device->lun;
b312fc
-	pRAID_Context->RAIDFlags = MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD
b312fc
+	pRAID_Context->raid_flags = MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD
b312fc
 		<< MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT;
b312fc
 
b312fc
 	/* If FW supports PD sequence number */
b312fc
@@ -2148,24 +2240,27 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
b312fc
 		/* TgtId must be incremented by 255 as jbod seq number is index
b312fc
 		 * below raid map
b312fc
 		 */
b312fc
-		pRAID_Context->VirtualDiskTgtId =
b312fc
+		pRAID_Context->virtual_disk_tgt_id =
b312fc
 			cpu_to_le16(device_id + (MAX_PHYSICAL_DEVICES - 1));
b312fc
-		pRAID_Context->configSeqNum = pd_sync->seq[pd_index].seqNum;
b312fc
+		pRAID_Context->config_seq_num = pd_sync->seq[pd_index].seqNum;
b312fc
 		io_request->DevHandle = pd_sync->seq[pd_index].devHandle;
b312fc
-		pRAID_Context->regLockFlags |=
b312fc
+		if (instance->is_ventura)
b312fc
+			io_request->RaidContext.raid_context_g35.routing_flags.bits.sqn = 1;
b312fc
+		else
b312fc
+		pRAID_Context->reg_lock_flags |=
b312fc
 			(MR_RL_FLAGS_SEQ_NUM_ENABLE|MR_RL_FLAGS_GRANT_DESTINATION_CUDA);
b312fc
-		pRAID_Context->Type = MPI2_TYPE_CUDA;
b312fc
+		pRAID_Context->type = MPI2_TYPE_CUDA;
b312fc
 		pRAID_Context->nseg = 0x1;
b312fc
 	} else if (fusion->fast_path_io) {
b312fc
-		pRAID_Context->VirtualDiskTgtId = cpu_to_le16(device_id);
b312fc
-		pRAID_Context->configSeqNum = 0;
b312fc
+		pRAID_Context->virtual_disk_tgt_id = cpu_to_le16(device_id);
b312fc
+		pRAID_Context->config_seq_num = 0;
b312fc
 		local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)];
b312fc
 		io_request->DevHandle =
b312fc
 			local_map_ptr->raidMap.devHndlInfo[device_id].curDevHdl;
b312fc
 	} else {
b312fc
 		/* Want to send all IO via FW path */
b312fc
-		pRAID_Context->VirtualDiskTgtId = cpu_to_le16(device_id);
b312fc
-		pRAID_Context->configSeqNum = 0;
b312fc
+		pRAID_Context->virtual_disk_tgt_id = cpu_to_le16(device_id);
b312fc
+		pRAID_Context->config_seq_num = 0;
b312fc
 		io_request->DevHandle = cpu_to_le16(0xFFFF);
b312fc
 	}
b312fc
 
b312fc
@@ -2181,14 +2276,14 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
b312fc
 		cmd->request_desc->SCSIIO.RequestFlags =
b312fc
 			(MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO <<
b312fc
 				MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
b312fc
-		pRAID_Context->timeoutValue = cpu_to_le16(os_timeout_value);
b312fc
-		pRAID_Context->VirtualDiskTgtId = cpu_to_le16(device_id);
b312fc
+		pRAID_Context->timeout_value = cpu_to_le16(os_timeout_value);
b312fc
+		pRAID_Context->virtual_disk_tgt_id = cpu_to_le16(device_id);
b312fc
 	} else {
b312fc
 		/* system pd Fast Path */
b312fc
 		io_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST;
b312fc
 		timeout_limit = (scmd->device->type == TYPE_DISK) ?
b312fc
 				255 : 0xFFFF;
b312fc
-		pRAID_Context->timeoutValue =
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
@@ -2227,8 +2322,8 @@ megasas_build_io_fusion(struct megasas_instance *instance,
b312fc
 	io_request->Control = 0;
b312fc
 	io_request->EEDPBlockSize = 0;
b312fc
 	io_request->ChainOffset = 0;
b312fc
-	io_request->RaidContext.raid_context.RAIDFlags = 0;
b312fc
-	io_request->RaidContext.raid_context.Type = 0;
b312fc
+	io_request->RaidContext.raid_context.raid_flags = 0;
b312fc
+	io_request->RaidContext.raid_context.type = 0;
b312fc
 	io_request->RaidContext.raid_context.nseg = 0;
b312fc
 
b312fc
 	memcpy(io_request->CDB.CDB32, scp->cmnd, scp->cmd_len);
b312fc
@@ -2273,11 +2368,16 @@ megasas_build_io_fusion(struct megasas_instance *instance,
b312fc
 		return 1;
b312fc
 	}
b312fc
 
b312fc
-	/* numSGE store lower 8 bit of sge_count.
b312fc
-	 * numSGEExt store higher 8 bit of sge_count
b312fc
-	 */
b312fc
-	io_request->RaidContext.raid_context.numSGE = sge_count;
b312fc
-	io_request->RaidContext.raid_context.numSGEExt = (u8)(sge_count >> 8);
b312fc
+	if (instance->is_ventura)
b312fc
+		io_request->RaidContext.raid_context_g35.num_sge = sge_count;
b312fc
+	else {
b312fc
+		/* numSGE store lower 8 bit of sge_count.
b312fc
+		 * numSGEExt store higher 8 bit of sge_count
b312fc
+		 */
b312fc
+		io_request->RaidContext.raid_context.num_sge = sge_count;
b312fc
+		io_request->RaidContext.raid_context.num_sge_ext =
b312fc
+			(u8)(sge_count >> 8);
b312fc
+	}
b312fc
 
b312fc
 	io_request->SGLFlags = cpu_to_le16(MPI2_SGE_FLAGS_64_BIT_ADDRESSING);
b312fc
 
b312fc
@@ -2326,6 +2426,10 @@ void megasas_fpio_to_ldio(struct megasas_instance *instance,
b312fc
 	struct megasas_cmd_fusion *cmd, struct scsi_cmnd *scmd)
b312fc
 {
b312fc
 	struct fusion_context *fusion;
b312fc
+	union RAID_CONTEXT_UNION *praid_context;
b312fc
+	struct MR_LD_RAID *raid;
b312fc
+	struct MR_DRV_RAID_MAP_ALL *local_map_ptr;
b312fc
+	u32 device_id, ld;
b312fc
 
b312fc
 	fusion = instance->ctrl_context;
b312fc
 	cmd->request_desc->SCSIIO.RequestFlags =
b312fc
@@ -2349,6 +2453,35 @@ void megasas_fpio_to_ldio(struct megasas_instance *instance,
b312fc
 	cmd->io_request->Control = 0;
b312fc
 	cmd->io_request->EEDPBlockSize = 0;
b312fc
 	cmd->is_raid_1_fp_write = 0;
b312fc
+
b312fc
+	device_id = MEGASAS_DEV_INDEX(cmd->scmd);
b312fc
+	local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)];
b312fc
+	ld = MR_TargetIdToLdGet(device_id, local_map_ptr);
b312fc
+	raid = MR_LdRaidGet(ld, local_map_ptr);
b312fc
+	praid_context = &cmd->io_request->RaidContext;
b312fc
+	if (cmd->scmd->sc_data_direction == PCI_DMA_FROMDEVICE) {
b312fc
+		if ((raid->cpuAffinity.ldRead.cpu0)
b312fc
+		&& (raid->cpuAffinity.ldRead.cpu1))
b312fc
+			praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+			= MR_RAID_CTX_CPUSEL_FCFS;
b312fc
+		else if (raid->cpuAffinity.ldRead.cpu1)
b312fc
+			praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+			= MR_RAID_CTX_CPUSEL_1;
b312fc
+		else
b312fc
+			praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+			= MR_RAID_CTX_CPUSEL_0;
b312fc
+	} else {
b312fc
+	if ((raid->cpuAffinity.ldWrite.cpu0)
b312fc
+		&& (raid->cpuAffinity.ldWrite.cpu1))
b312fc
+		praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+			= MR_RAID_CTX_CPUSEL_FCFS;
b312fc
+	else if (raid->cpuAffinity.ldWrite.cpu1)
b312fc
+		praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+			= MR_RAID_CTX_CPUSEL_1;
b312fc
+	else
b312fc
+		praid_context->raid_context_g35.routing_flags.bits.cpu_sel
b312fc
+		= MR_RAID_CTX_CPUSEL_0;
b312fc
+	}
b312fc
 }
b312fc
 
b312fc
 /* megasas_prepate_secondRaid1_IO
b312fc
@@ -2585,7 +2718,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex)
b312fc
 
b312fc
 		scmd_local = cmd_fusion->scmd;
b312fc
 		status = scsi_io_req->RaidContext.raid_context.status;
b312fc
-		extStatus = scsi_io_req->RaidContext.raid_context.exStatus;
b312fc
+		extStatus = scsi_io_req->RaidContext.raid_context.ex_status;
b312fc
 		sense = cmd_fusion->sense;
b312fc
 		data_length = scsi_io_req->DataLength;
b312fc
 
b312fc
@@ -2653,13 +2786,13 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex)
b312fc
 					status =
b312fc
 					r1_cmd->io_request->RaidContext.raid_context.status;
b312fc
 					extStatus =
b312fc
-					r1_cmd->io_request->RaidContext.raid_context.exStatus;
b312fc
+					r1_cmd->io_request->RaidContext.raid_context.ex_status;
b312fc
 					data_length =
b312fc
 						r1_cmd->io_request->DataLength;
b312fc
 					sense = r1_cmd->sense;
b312fc
 				}
b312fc
 				r1_cmd->io_request->RaidContext.raid_context.status = 0;
b312fc
-				r1_cmd->io_request->RaidContext.raid_context.exStatus = 0;
b312fc
+				r1_cmd->io_request->RaidContext.raid_context.ex_status = 0;
b312fc
 				cmd_fusion->is_raid_1_fp_write = 0;
b312fc
 				r1_cmd->is_raid_1_fp_write = 0;
b312fc
 				r1_cmd->cmd_completed = false;
b312fc
@@ -2669,10 +2802,8 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex)
b312fc
 			if (!cmd_fusion->is_raid_1_fp_write) {
b312fc
 				map_cmd_status(fusion, scmd_local, status,
b312fc
 					extStatus, data_length, sense);
b312fc
-				scsi_io_req->RaidContext.raid_context.status
b312fc
-				= 0;
b312fc
-				scsi_io_req->RaidContext.raid_context.exStatus
b312fc
-				= 0;
b312fc
+				scsi_io_req->RaidContext.raid_context.status = 0;
b312fc
+				scsi_io_req->RaidContext.raid_context.ex_status = 0;
b312fc
 				megasas_return_cmd_fusion(instance, cmd_fusion);
b312fc
 				scsi_dma_unmap(scmd_local);
b312fc
 				scmd_local->scsi_done(scmd_local);
b312fc
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h b/drivers/scsi/megaraid/megaraid_sas_fusion.h
b312fc
index 7a3c3d1..2de12b4 100644
b312fc
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
b312fc
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
b312fc
@@ -59,6 +59,8 @@
b312fc
 #define	MR_RL_FLAGS_GRANT_DESTINATION_CPU1	    0x10
b312fc
 #define	MR_RL_FLAGS_GRANT_DESTINATION_CUDA	    0x80
b312fc
 #define MR_RL_FLAGS_SEQ_NUM_ENABLE		    0x8
b312fc
+#define MR_RL_WRITE_THROUGH_MODE		    0x00
b312fc
+#define MR_RL_WRITE_BACK_MODE			    0x01
b312fc
 
b312fc
 /* T10 PI defines */
b312fc
 #define MR_PROT_INFO_TYPE_CONTROLLER                0x8
b312fc
@@ -81,6 +83,11 @@
b312fc
 enum MR_RAID_FLAGS_IO_SUB_TYPE {
b312fc
 	MR_RAID_FLAGS_IO_SUB_TYPE_NONE = 0,
b312fc
 	MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD = 1,
b312fc
+	MR_RAID_FLAGS_IO_SUB_TYPE_RMW_DATA     = 2,
b312fc
+	MR_RAID_FLAGS_IO_SUB_TYPE_RMW_P        = 3,
b312fc
+	MR_RAID_FLAGS_IO_SUB_TYPE_RMW_Q        = 4,
b312fc
+	MR_RAID_FLAGS_IO_SUB_TYPE_CACHE_BYPASS = 6,
b312fc
+	MR_RAID_FLAGS_IO_SUB_TYPE_LDIO_BW_LIMIT = 7
b312fc
 };
b312fc
 
b312fc
 /*
b312fc
@@ -109,29 +116,29 @@ enum MR_FUSION_ADAPTER_TYPE {
b312fc
 
b312fc
 struct RAID_CONTEXT {
b312fc
 #if   defined(__BIG_ENDIAN_BITFIELD)
b312fc
-	u8	nseg:4;
b312fc
-	u8	Type:4;
b312fc
+	u8 nseg:4;
b312fc
+	u8 type:4;
b312fc
 #else
b312fc
-	u8	Type:4;
b312fc
-	u8	nseg:4;
b312fc
+	u8 type:4;
b312fc
+	u8 nseg:4;
b312fc
 #endif
b312fc
-	u8	resvd0;
b312fc
-	__le16	timeoutValue;
b312fc
-	u8      regLockFlags;
b312fc
-	u8      resvd1;
b312fc
-	__le16	VirtualDiskTgtId;
b312fc
-	__le64	regLockRowLBA;
b312fc
-	__le32	regLockLength;
b312fc
-	__le16	nextLMId;
b312fc
-	u8      exStatus;
b312fc
-	u8      status;
b312fc
-	u8      RAIDFlags;
b312fc
-	u8      numSGE;
b312fc
-	__le16	configSeqNum;
b312fc
-	u8      spanArm;
b312fc
-	u8      priority;
b312fc
-	u8	numSGEExt;
b312fc
-	u8      resvd2;
b312fc
+	u8 resvd0;
b312fc
+	__le16 timeout_value;
b312fc
+	u8 reg_lock_flags;
b312fc
+	u8 resvd1;
b312fc
+	__le16 virtual_disk_tgt_id;
b312fc
+	__le64 reg_lock_row_lba;
b312fc
+	__le32 reg_lock_length;
b312fc
+	__le16 next_lmid;
b312fc
+	u8 ex_status;
b312fc
+	u8 status;
b312fc
+	u8 raid_flags;
b312fc
+	u8 num_sge;
b312fc
+	__le16 config_seq_num;
b312fc
+	u8 span_arm;
b312fc
+	u8 priority;
b312fc
+	u8 num_sge_ext;
b312fc
+	u8 resvd2;
b312fc
 };
b312fc
 
b312fc
 /*
b312fc
@@ -187,7 +194,7 @@ struct RAID_CONTEXT_G35 {
b312fc
 	} smid;
b312fc
 	u8 ex_status;       /* 0x16 : OUT */
b312fc
 	u8 status;          /* 0x17 status */
b312fc
-	u8 RAIDFlags;		/* 0x18 resvd[7:6], ioSubType[5:4],
b312fc
+	u8 raid_flags;		/* 0x18 resvd[7:6], ioSubType[5:4],
b312fc
 				 * resvd[3:1], preferredCpu[0]
b312fc
 				 */
b312fc
 	u8 span_arm;            /* 0x1C span[7:5], arm[4:0] */
b312fc
@@ -672,14 +679,17 @@ struct MPI2_IOC_INIT_REQUEST {
b312fc
 #define MAX_RAIDMAP_ROW_SIZE (MAX_ROW_SIZE)
b312fc
 #define MAX_LOGICAL_DRIVES 64
b312fc
 #define MAX_LOGICAL_DRIVES_EXT 256
b312fc
+#define MAX_LOGICAL_DRIVES_DYN 512
b312fc
 #define MAX_RAIDMAP_LOGICAL_DRIVES (MAX_LOGICAL_DRIVES)
b312fc
 #define MAX_RAIDMAP_VIEWS (MAX_LOGICAL_DRIVES)
b312fc
 #define MAX_ARRAYS 128
b312fc
 #define MAX_RAIDMAP_ARRAYS (MAX_ARRAYS)
b312fc
 #define MAX_ARRAYS_EXT	256
b312fc
 #define MAX_API_ARRAYS_EXT (MAX_ARRAYS_EXT)
b312fc
+#define MAX_API_ARRAYS_DYN 512
b312fc
 #define MAX_PHYSICAL_DEVICES 256
b312fc
 #define MAX_RAIDMAP_PHYSICAL_DEVICES (MAX_PHYSICAL_DEVICES)
b312fc
+#define MAX_RAIDMAP_PHYSICAL_DEVICES_DYN 512
b312fc
 #define MR_DCMD_LD_MAP_GET_INFO             0x0300e101
b312fc
 #define MR_DCMD_SYSTEM_PD_MAP_GET_INFO      0x0200e102
b312fc
 #define MR_DCMD_CTRL_SHARED_HOST_MEM_ALLOC  0x010e8485   /* SR-IOV HB alloc*/
b312fc
@@ -726,12 +736,56 @@ struct MR_SPAN_BLOCK_INFO {
b312fc
 	struct MR_SPAN_INFO block_span_info;
b312fc
 };
b312fc
 
b312fc
+#define MR_RAID_CTX_CPUSEL_0		0
b312fc
+#define MR_RAID_CTX_CPUSEL_1		1
b312fc
+#define MR_RAID_CTX_CPUSEL_2		2
b312fc
+#define MR_RAID_CTX_CPUSEL_3		3
b312fc
+#define MR_RAID_CTX_CPUSEL_FCFS		0xF
b312fc
+
b312fc
+struct MR_CPU_AFFINITY_MASK {
b312fc
+	union {
b312fc
+		struct {
b312fc
+#ifndef MFI_BIG_ENDIAN
b312fc
+		u8 hw_path:1;
b312fc
+		u8 cpu0:1;
b312fc
+		u8 cpu1:1;
b312fc
+		u8 cpu2:1;
b312fc
+		u8 cpu3:1;
b312fc
+		u8 reserved:3;
b312fc
+#else
b312fc
+		u8 reserved:3;
b312fc
+		u8 cpu3:1;
b312fc
+		u8 cpu2:1;
b312fc
+		u8 cpu1:1;
b312fc
+		u8 cpu0:1;
b312fc
+		u8 hw_path:1;
b312fc
+#endif
b312fc
+		};
b312fc
+		u8 core_mask;
b312fc
+	};
b312fc
+};
b312fc
+
b312fc
+struct MR_IO_AFFINITY {
b312fc
+	union {
b312fc
+		struct {
b312fc
+			struct MR_CPU_AFFINITY_MASK pdRead;
b312fc
+			struct MR_CPU_AFFINITY_MASK pdWrite;
b312fc
+			struct MR_CPU_AFFINITY_MASK ldRead;
b312fc
+			struct MR_CPU_AFFINITY_MASK ldWrite;
b312fc
+			};
b312fc
+		u32 word;
b312fc
+		};
b312fc
+	u8 maxCores;    /* Total cores + HW Path in ROC */
b312fc
+	u8 reserved[3];
b312fc
+};
b312fc
+
b312fc
 struct MR_LD_RAID {
b312fc
 	struct {
b312fc
 #if   defined(__BIG_ENDIAN_BITFIELD)
b312fc
-		u32     reserved4:3;
b312fc
-		u32     fp_cache_bypass_capable:1;
b312fc
-		u32     fp_rmw_capable:1;
b312fc
+		u32 reserved4:2;
b312fc
+		u32 fp_cache_bypass_capable:1;
b312fc
+		u32 fp_rmw_capable:1;
b312fc
+		u32 disable_coalescing:1;
b312fc
 		u32     fpBypassRegionLock:1;
b312fc
 		u32     tmCapable:1;
b312fc
 		u32	fpNonRWCapable:1;
b312fc
@@ -759,9 +813,10 @@ struct MR_LD_RAID {
b312fc
 		u32	fpNonRWCapable:1;
b312fc
 		u32     tmCapable:1;
b312fc
 		u32     fpBypassRegionLock:1;
b312fc
-		u32     fp_rmw_capable:1;
b312fc
-		u32     fp_cache_bypass_capable:1;
b312fc
-		u32     reserved4:3;
b312fc
+		u32 disable_coalescing:1;
b312fc
+		u32 fp_rmw_capable:1;
b312fc
+		u32 fp_cache_bypass_capable:1;
b312fc
+		u32 reserved4:2;
b312fc
 #endif
b312fc
 	} capability;
b312fc
 	__le32     reserved6;
b312fc
@@ -788,7 +843,36 @@ struct MR_LD_RAID {
b312fc
 
b312fc
 	u8	LUN[8]; /* 0x24 8 byte LUN field used for SCSI IO's */
b312fc
 	u8	fpIoTimeoutForLd;/*0x2C timeout value used by driver in FP IO*/
b312fc
-	u8      reserved3[0x80-0x2D]; /* 0x2D */
b312fc
+	/* Ox2D This LD accept priority boost of this type */
b312fc
+	u8 ld_accept_priority_type;
b312fc
+	u8 reserved2[2];	        /* 0x2E - 0x2F */
b312fc
+	/* 0x30 - 0x33, Logical block size for the LD */
b312fc
+	u32 logical_block_length;
b312fc
+	struct {
b312fc
+#ifndef MFI_BIG_ENDIAN
b312fc
+	/* 0x34, P_I_EXPONENT from READ CAPACITY 16 */
b312fc
+	u32 ld_pi_exp:4;
b312fc
+	/* 0x34, LOGICAL BLOCKS PER PHYSICAL
b312fc
+	 *  BLOCK EXPONENT from READ CAPACITY 16
b312fc
+	 */
b312fc
+	u32 ld_logical_block_exp:4;
b312fc
+	u32 reserved1:24;           /* 0x34 */
b312fc
+#else
b312fc
+	u32 reserved1:24;           /* 0x34 */
b312fc
+	/* 0x34, LOGICAL BLOCKS PER PHYSICAL
b312fc
+	 *  BLOCK EXPONENT from READ CAPACITY 16
b312fc
+	 */
b312fc
+	u32 ld_logical_block_exp:4;
b312fc
+	/* 0x34, P_I_EXPONENT from READ CAPACITY 16 */
b312fc
+	u32 ld_pi_exp:4;
b312fc
+#endif
b312fc
+	};                               /* 0x34 - 0x37 */
b312fc
+	 /* 0x38 - 0x3f, This will determine which
b312fc
+	  *  core will process LD IO and PD IO.
b312fc
+	  */
b312fc
+	struct MR_IO_AFFINITY cpuAffinity;
b312fc
+     /* Bit definiations are specified by MR_IO_AFFINITY */
b312fc
+	u8 reserved3[0x80-0x40];    /* 0x40 - 0x7f */
b312fc
 };
b312fc
 
b312fc
 struct MR_LD_SPAN_MAP {
b312fc
@@ -846,6 +930,91 @@ struct MR_LD_TARGET_SYNC {
b312fc
 	__le16 seqNum;
b312fc
 };
b312fc
 
b312fc
+/*
b312fc
+ * RAID Map descriptor Types.
b312fc
+ * Each element should uniquely idetify one data structure in the RAID map
b312fc
+ */
b312fc
+enum MR_RAID_MAP_DESC_TYPE {
b312fc
+	/* MR_DEV_HANDLE_INFO data */
b312fc
+	RAID_MAP_DESC_TYPE_DEVHDL_INFO    = 0x0,
b312fc
+	/* target to Ld num Index map */
b312fc
+	RAID_MAP_DESC_TYPE_TGTID_INFO     = 0x1,
b312fc
+	/* MR_ARRAY_INFO data */
b312fc
+	RAID_MAP_DESC_TYPE_ARRAY_INFO     = 0x2,
b312fc
+	/* MR_LD_SPAN_MAP data */
b312fc
+	RAID_MAP_DESC_TYPE_SPAN_INFO      = 0x3,
b312fc
+	RAID_MAP_DESC_TYPE_COUNT,
b312fc
+};
b312fc
+
b312fc
+/*
b312fc
+ * This table defines the offset, size and num elements  of each descriptor
b312fc
+ * type in the RAID Map buffer
b312fc
+ */
b312fc
+struct MR_RAID_MAP_DESC_TABLE {
b312fc
+	/* Raid map descriptor type */
b312fc
+	u32 raid_map_desc_type;
b312fc
+	/* Offset into the RAID map buffer where
b312fc
+	 *  descriptor data is saved
b312fc
+	 */
b312fc
+	u32 raid_map_desc_offset;
b312fc
+	/* total size of the
b312fc
+	 * descriptor buffer
b312fc
+	 */
b312fc
+	u32 raid_map_desc_buffer_size;
b312fc
+	/* Number of elements contained in the
b312fc
+	 *  descriptor buffer
b312fc
+	 */
b312fc
+	u32 raid_map_desc_elements;
b312fc
+};
b312fc
+
b312fc
+/*
b312fc
+ * Dynamic Raid Map Structure.
b312fc
+ */
b312fc
+struct MR_FW_RAID_MAP_DYNAMIC {
b312fc
+	u32 raid_map_size;   /* total size of RAID Map structure */
b312fc
+	u32 desc_table_offset;/* Offset of desc table into RAID map*/
b312fc
+	u32 desc_table_size;  /* Total Size of desc table */
b312fc
+	/* Total Number of elements in the desc table */
b312fc
+	u32 desc_table_num_elements;
b312fc
+	u64	reserved1;
b312fc
+	u32	reserved2[3];	/*future use */
b312fc
+	/* timeout value used by driver in FP IOs */
b312fc
+	u8 fp_pd_io_timeout_sec;
b312fc
+	u8 reserved3[3];
b312fc
+	/* when this seqNum increments, driver needs to
b312fc
+	 *  release RMW buffers asap
b312fc
+	 */
b312fc
+	u32 rmw_fp_seq_num;
b312fc
+	u16 ld_count;	/* count of lds. */
b312fc
+	u16 ar_count;   /* count of arrays */
b312fc
+	u16 span_count; /* count of spans */
b312fc
+	u16 reserved4[3];
b312fc
+/*
b312fc
+ * The below structure of pointers is only to be used by the driver.
b312fc
+ * This is added in the ,API to reduce the amount of code changes
b312fc
+ * needed in the driver to support dynamic RAID map Firmware should
b312fc
+ * not update these pointers while preparing the raid map
b312fc
+ */
b312fc
+	union {
b312fc
+		struct {
b312fc
+			struct MR_DEV_HANDLE_INFO  *dev_hndl_info;
b312fc
+			u16 *ld_tgt_id_to_ld;
b312fc
+			struct MR_ARRAY_INFO *ar_map_info;
b312fc
+			struct MR_LD_SPAN_MAP *ld_span_map;
b312fc
+			};
b312fc
+		u64 ptr_structure_size[RAID_MAP_DESC_TYPE_COUNT];
b312fc
+		};
b312fc
+/*
b312fc
+ * RAID Map descriptor table defines the layout of data in the RAID Map.
b312fc
+ * The size of the descriptor table itself could change.
b312fc
+ */
b312fc
+	/* Variable Size descriptor Table. */
b312fc
+	struct MR_RAID_MAP_DESC_TABLE
b312fc
+			raid_map_desc_table[RAID_MAP_DESC_TYPE_COUNT];
b312fc
+	/* Variable Size buffer containing all data */
b312fc
+	u32 raid_map_desc_data[1];
b312fc
+}; /* Dynamicaly sized RAID MAp structure */
b312fc
+
b312fc
 #define IEEE_SGE_FLAGS_ADDR_MASK            (0x03)
b312fc
 #define IEEE_SGE_FLAGS_SYSTEM_ADDR          (0x00)
b312fc
 #define IEEE_SGE_FLAGS_IOCDDR_ADDR          (0x01)
b312fc
@@ -955,9 +1124,10 @@ struct MR_DRV_RAID_MAP {
b312fc
 	__le16                 spanCount;
b312fc
 	__le16                 reserve3;
b312fc
 
b312fc
-	struct MR_DEV_HANDLE_INFO  devHndlInfo[MAX_RAIDMAP_PHYSICAL_DEVICES];
b312fc
-	u8                  ldTgtIdToLd[MAX_LOGICAL_DRIVES_EXT];
b312fc
-	struct MR_ARRAY_INFO       arMapInfo[MAX_API_ARRAYS_EXT];
b312fc
+	struct MR_DEV_HANDLE_INFO
b312fc
+		devHndlInfo[MAX_RAIDMAP_PHYSICAL_DEVICES_DYN];
b312fc
+	u16 ldTgtIdToLd[MAX_LOGICAL_DRIVES_DYN];
b312fc
+	struct MR_ARRAY_INFO arMapInfo[MAX_API_ARRAYS_DYN];
b312fc
 	struct MR_LD_SPAN_MAP      ldSpanMap[1];
b312fc
 
b312fc
 };
b312fc
@@ -969,7 +1139,7 @@ struct MR_DRV_RAID_MAP {
b312fc
 struct MR_DRV_RAID_MAP_ALL {
b312fc
 
b312fc
 	struct MR_DRV_RAID_MAP raidMap;
b312fc
-	struct MR_LD_SPAN_MAP      ldSpanMap[MAX_LOGICAL_DRIVES_EXT - 1];
b312fc
+	struct MR_LD_SPAN_MAP ldSpanMap[MAX_LOGICAL_DRIVES_DYN - 1];
b312fc
 } __packed;
b312fc
 
b312fc
 
b312fc
@@ -1088,7 +1258,7 @@ struct fusion_context {
b312fc
 	u8	chain_offset_io_request;
b312fc
 	u8	chain_offset_mfi_pthru;
b312fc
 
b312fc
-	struct MR_FW_RAID_MAP_ALL *ld_map[2];
b312fc
+	struct MR_FW_RAID_MAP_DYNAMIC *ld_map[2];
b312fc
 	dma_addr_t ld_map_phys[2];
b312fc
 
b312fc
 	/*Non dma-able memory. Driver local copy.*/
b312fc
@@ -1096,6 +1266,8 @@ struct fusion_context {
b312fc
 
b312fc
 	u32 max_map_sz;
b312fc
 	u32 current_map_sz;
b312fc
+	u32 old_map_sz;
b312fc
+	u32 new_map_sz;
b312fc
 	u32 drv_map_sz;
b312fc
 	u32 drv_map_pages;
b312fc
 	struct MR_PD_CFG_SEQ_NUM_SYNC	*pd_seq_sync[JBOD_MAPS_COUNT];
b312fc
-- 
b312fc
1.8.3.1
b312fc