From patchwork Mon Apr 20 12:32:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Saxena X-Patchwork-Id: 6241821 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B28339F313 for ; Mon, 20 Apr 2015 12:49:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2CC132034A for ; Mon, 20 Apr 2015 12:49:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8AD2620416 for ; Mon, 20 Apr 2015 12:49:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755301AbbDTMtg (ORCPT ); Mon, 20 Apr 2015 08:49:36 -0400 Received: from mail-bl2lp0207.outbound.protection.outlook.com ([207.46.163.207]:1858 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755277AbbDTMtf (ORCPT ); Mon, 20 Apr 2015 08:49:35 -0400 Received: from BLUPR07CA0107.namprd07.prod.outlook.com (10.255.223.178) by DM2PR0701MB1264.namprd07.prod.outlook.com (0.161.225.14) with Microsoft SMTP Server (TLS) id 15.1.136.25; Mon, 20 Apr 2015 12:33:39 +0000 Received: from BN1AFFO11OLC002.protection.gbl (2a01:111:f400:7c10::164) by BLUPR07CA0107.outlook.office365.com (2a01:111:e400:841::50) with Microsoft SMTP Server (TLS) id 15.1.136.25 via Frontend Transport; Mon, 20 Apr 2015 12:33:38 +0000 Authentication-Results: spf=softfail (sender IP is 192.19.192.197) smtp.mailfrom=avagotech.com; parallels.com; dkim=none (message not signed) header.d=none; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning avagotech.com discourages use of 192.19.192.197 as permitted sender) Received: from PALEXCH12.lsi.com (192.19.192.197) by BN1AFFO11OLC002.mail.protection.outlook.com (10.58.53.73) with Microsoft SMTP Server (TLS) id 15.1.148.11 via Frontend Transport; Mon, 20 Apr 2015 12:33:37 +0000 Received: from palmhbs0.lsi.com (128.94.222.181) by PALEXCH12-EXT.lsi.com (128.94.222.103) with Microsoft SMTP Server id 14.3.158.1; Mon, 20 Apr 2015 08:33:23 -0400 Received: from localhost (dhcp-135-24-192-138.lsi.com [135.24.192.138]) by palmhbs0.lsi.com (8.13.8/8.12.11) with ESMTP id t3KCZ2ZC016456; Mon, 20 Apr 2015 08:35:03 -0400 From: Message-ID: <201504201235.t3KCZ2ZC016456@palmhbs0.lsi.com> Date: Mon, 20 Apr 2015 18:02:50 +0530 To: Subject: [PATCH RESEND 3/18] megaraid_sas : Add separate functions for building sysPD IOs and non RW LDIOs CC: , , , , , User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.19.192.197; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; BMV:1; SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(110136001)(105596002)(6806004)(23726002)(229853001)(46102003)(92566002)(46406003)(16796002)(83506001)(50986999)(54356999)(86362001)(97756001)(77156002)(87936001)(4001350100001)(57986006)(2351001)(47776003)(86152002)(106466001)(2220100001)(62966003)(50466002)(19580395003)(76506005)(19580405001)(4001430100001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0701MB1264; H:PALEXCH12.lsi.com; FPR:; SPF:SoftFail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0701MB1264; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5002010)(5005006); SRVR:DM2PR0701MB1264; BCL:0; PCL:0; RULEID:; SRVR:DM2PR0701MB1264; X-Forefront-PRVS: 05529C6FDB X-OriginatorOrg: lsicorp.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2015 12:33:37.8112 (UTC) X-MS-Exchange-CrossTenant-Id: 33102e38-078a-4484-9fb5-731e8b59db69 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=33102e38-078a-4484-9fb5-731e8b59db69; Ip=[192.19.192.197]; Helo=[PALEXCH12.lsi.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0701MB1264 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch will create separate functions for sysPD IOs and non Read/Write LDIOs. Signed-off-by: Kashyap Desai Signed-off-by: Sumit Saxena --- drivers/scsi/megaraid/megaraid_sas.h | 10 +- drivers/scsi/megaraid/megaraid_sas_base.c | 4 +- drivers/scsi/megaraid/megaraid_sas_fusion.c | 227 +++++++++++++++------------ 3 files changed, 138 insertions(+), 103 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index 14e5c7c..bdcf2b6 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -1864,9 +1864,13 @@ struct megasas_instance_template { #define MEGASAS_IS_LOGICAL(scp) \ (scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1 -#define MEGASAS_DEV_INDEX(inst, scp) \ - ((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \ - scp->device->id +#define MEGASAS_DEV_INDEX(scp) \ + (((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \ + scp->device->id) + +#define MEGASAS_PD_INDEX(scp) \ + ((scp->device->channel * MEGASAS_MAX_DEV_PER_CHANNEL) + \ + scp->device->id) struct megasas_cmd { diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index bb68ba9..e6cb2bd 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -1196,7 +1196,7 @@ megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp, struct megasas_pthru_frame *pthru; is_logical = MEGASAS_IS_LOGICAL(scp); - device_id = MEGASAS_DEV_INDEX(instance, scp); + device_id = MEGASAS_DEV_INDEX(scp); pthru = (struct megasas_pthru_frame *)cmd->frame; if (scp->sc_data_direction == PCI_DMA_TODEVICE) @@ -1294,7 +1294,7 @@ megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp, u16 flags = 0; struct megasas_io_frame *ldio; - device_id = MEGASAS_DEV_INDEX(instance, scp); + device_id = MEGASAS_DEV_INDEX(scp); ldio = (struct megasas_io_frame *)cmd->frame; if (scp->sc_data_direction == PCI_DMA_TODEVICE) diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 6637bea..c5619f8 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -1497,7 +1497,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance, struct MR_DRV_RAID_MAP_ALL *local_map_ptr; u8 *raidLUN; - device_id = MEGASAS_DEV_INDEX(instance, scp); + device_id = MEGASAS_DEV_INDEX(scp); fusion = instance->ctrl_context; @@ -1650,23 +1650,19 @@ megasas_build_ldio_fusion(struct megasas_instance *instance, } /** - * megasas_build_dcdb_fusion - Prepares IOs to devices + * megasas_build_ld_nonrw_fusion - prepares non rw ios for virtual disk * @instance: Adapter soft state * @scp: SCSI command * @cmd: Command to be prepared * - * Prepares the io_request frame for non-io cmds + * Prepares the io_request frame for non-rw io cmds for vd. */ -static void -megasas_build_dcdb_fusion(struct megasas_instance *instance, - struct scsi_cmnd *scmd, - struct megasas_cmd_fusion *cmd) +static void megasas_build_ld_nonrw_fusion(struct megasas_instance *instance, + struct scsi_cmnd *scmd, struct megasas_cmd_fusion *cmd) { u32 device_id; struct MPI2_RAID_SCSI_IO_REQUEST *io_request; u16 pd_index = 0; - u16 os_timeout_value; - u16 timeout_limit; struct MR_DRV_RAID_MAP_ALL *local_map_ptr; struct fusion_context *fusion = instance->ctrl_context; u8 span, physArm; @@ -1674,94 +1670,48 @@ megasas_build_dcdb_fusion(struct megasas_instance *instance, u32 ld, arRef, pd; struct MR_LD_RAID *raid; struct RAID_CONTEXT *pRAID_Context; + u8 fp_possible = 1; io_request = cmd->io_request; - device_id = MEGASAS_DEV_INDEX(instance, scmd); - pd_index = (scmd->device->channel * MEGASAS_MAX_DEV_PER_CHANNEL) - +scmd->device->id; + device_id = MEGASAS_DEV_INDEX(scmd); + pd_index = MEGASAS_PD_INDEX(scmd); local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)]; - io_request->DataLength = cpu_to_le32(scsi_bufflen(scmd)); + /* get RAID_Context pointer */ + pRAID_Context = &io_request->RaidContext; + /* Check with FW team */ + pRAID_Context->VirtualDiskTgtId = cpu_to_le16(device_id); + pRAID_Context->regLockRowLBA = 0; + pRAID_Context->regLockLength = 0; - if (scmd->device->channel < MEGASAS_MAX_PD_CHANNELS && - instance->pd_list[pd_index].driveState == MR_PD_STATE_SYSTEM) { - if (fusion->fast_path_io) - io_request->DevHandle = - local_map_ptr->raidMap.devHndlInfo[device_id].curDevHdl; - io_request->RaidContext.RAIDFlags = - MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD - << MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT; - cmd->request_desc->SCSIIO.DevHandle = io_request->DevHandle; - cmd->request_desc->SCSIIO.MSIxIndex = - instance->msix_vectors ? smp_processor_id() % instance->msix_vectors : 0; - os_timeout_value = scmd->request->timeout / HZ; - - if (instance->secure_jbod_support && - (megasas_cmd_type(scmd) == NON_READ_WRITE_SYSPDIO)) { - /* system pd firmware path */ - io_request->Function = - MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST; - cmd->request_desc->SCSIIO.RequestFlags = - (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO << - MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); - io_request->RaidContext.timeoutValue = - cpu_to_le16(os_timeout_value); - } else { - /* system pd Fast Path */ - io_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; - io_request->RaidContext.regLockFlags = 0; - io_request->RaidContext.regLockRowLBA = 0; - io_request->RaidContext.regLockLength = 0; - timeout_limit = (scmd->device->type == TYPE_DISK) ? - 255 : 0xFFFF; - io_request->RaidContext.timeoutValue = - cpu_to_le16((os_timeout_value > timeout_limit) ? - timeout_limit : os_timeout_value); - if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || - (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) - io_request->IoFlags |= - cpu_to_le16(MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH); - - cmd->request_desc->SCSIIO.RequestFlags = - (MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY << - MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); - } - } else { - if (scmd->device->channel < MEGASAS_MAX_PD_CHANNELS) - goto NonFastPath; - - /* - * For older firmware, Driver should not access ldTgtIdToLd - * beyond index 127 and for Extended VD firmware, ldTgtIdToLd - * should not go beyond 255. - */ - - if ((!fusion->fast_path_io) || - (device_id >= instance->fw_supported_vd_count)) - goto NonFastPath; + if (fusion->fast_path_io && ( + device_id < instance->fw_supported_vd_count)) { ld = MR_TargetIdToLdGet(device_id, local_map_ptr); - if (ld >= instance->fw_supported_vd_count) - goto NonFastPath; + fp_possible = 0; raid = MR_LdRaidGet(ld, local_map_ptr); - - /* check if this LD is FP capable */ if (!(raid->capability.fpNonRWCapable)) - /* not FP capable, send as non-FP */ - goto NonFastPath; + fp_possible = 0; + } else + fp_possible = 0; - /* get RAID_Context pointer */ - pRAID_Context = &io_request->RaidContext; + if (!fp_possible) { + io_request->Function = MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST; + io_request->DevHandle = cpu_to_le16(device_id); + io_request->LUN[1] = scmd->device->lun; + pRAID_Context->timeoutValue = + cpu_to_le16 (scmd->request->timeout / HZ); + cmd->request_desc->SCSIIO.RequestFlags = + (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO << + MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); + } else { /* set RAID context values */ - pRAID_Context->regLockFlags = REGION_TYPE_SHARED_READ; - pRAID_Context->timeoutValue = cpu_to_le16(raid->fpIoTimeoutForLd); - pRAID_Context->VirtualDiskTgtId = cpu_to_le16(device_id); - pRAID_Context->regLockRowLBA = 0; - pRAID_Context->regLockLength = 0; - pRAID_Context->configSeqNum = raid->seqNum; + pRAID_Context->configSeqNum = raid->seqNum; + pRAID_Context->regLockFlags = REGION_TYPE_SHARED_READ; + pRAID_Context->timeoutValue = cpu_to_le16(raid->fpIoTimeoutForLd); /* get the DevHandle for the PD (since this is fpNonRWCapable, this is a single disk RAID0) */ @@ -1773,7 +1723,7 @@ megasas_build_dcdb_fusion(struct megasas_instance *instance, /* build request descriptor */ cmd->request_desc->SCSIIO.RequestFlags = (MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY << - MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); + MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); cmd->request_desc->SCSIIO.DevHandle = devHandle; /* populate the LUN field */ @@ -1782,18 +1732,87 @@ megasas_build_dcdb_fusion(struct megasas_instance *instance, /* build the raidScsiIO structure */ io_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; io_request->DevHandle = devHandle; + } +} - return; +/** + * megasas_build_syspd_fusion - prepares rw/non-rw ios for syspd + * @instance: Adapter soft state + * @scp: SCSI command + * @cmd: Command to be prepared + * @fp_possible: parameter to detect fast path or firmware path io. + * + * Prepares the io_request frame for rw/non-rw io cmds for syspds + */ +static void +megasas_build_syspd_fusion(struct megasas_instance *instance, + struct scsi_cmnd *scmd, struct megasas_cmd_fusion *cmd, u8 fp_possible) +{ + u32 device_id; + struct MPI2_RAID_SCSI_IO_REQUEST *io_request; + u16 pd_index = 0; + u16 os_timeout_value; + u16 timeout_limit; + struct MR_DRV_RAID_MAP_ALL *local_map_ptr; + struct RAID_CONTEXT *pRAID_Context; + struct fusion_context *fusion = instance->ctrl_context; + + device_id = MEGASAS_DEV_INDEX(scmd); + pd_index = MEGASAS_PD_INDEX(scmd); + os_timeout_value = scmd->request->timeout / HZ; -NonFastPath: + io_request = cmd->io_request; + /* get RAID_Context pointer */ + pRAID_Context = &io_request->RaidContext; + io_request->DataLength = cpu_to_le32(scsi_bufflen(scmd)); + io_request->LUN[1] = scmd->device->lun; + pRAID_Context->RAIDFlags = MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD + << MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT; + + pRAID_Context->VirtualDiskTgtId = cpu_to_le16(device_id); + pRAID_Context->configSeqNum = 0; + local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)]; + io_request->DevHandle = + local_map_ptr->raidMap.devHndlInfo[device_id].curDevHdl; + + cmd->request_desc->SCSIIO.DevHandle = io_request->DevHandle; + cmd->request_desc->SCSIIO.MSIxIndex = + instance->msix_vectors ? + (smp_processor_id() % instance->msix_vectors) : 0; + + + if (!fp_possible) { + /* system pd firmware path */ io_request->Function = MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST; - io_request->DevHandle = cpu_to_le16(device_id); cmd->request_desc->SCSIIO.RequestFlags = (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO << - MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); + MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); + pRAID_Context->timeoutValue = cpu_to_le16(os_timeout_value); + } else { + /* system pd Fast Path */ + io_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST; + pRAID_Context->regLockFlags = 0; + pRAID_Context->regLockRowLBA = 0; + pRAID_Context->regLockLength = 0; + timeout_limit = (scmd->device->type == TYPE_DISK) ? + 255 : 0xFFFF; + pRAID_Context->timeoutValue = + cpu_to_le16((os_timeout_value > timeout_limit) ? + timeout_limit : os_timeout_value); + if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || + (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) { + cmd->request_desc->SCSIIO.RequestFlags |= + (MEGASAS_REQ_DESCRIPT_FLAGS_NO_LOCK << + MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); + pRAID_Context->Type = MPI2_TYPE_CUDA; + pRAID_Context->nseg = 0x1; + io_request->IoFlags |= + cpu_to_le16(MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH); + } + cmd->request_desc->SCSIIO.RequestFlags = + (MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY << + MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); } - io_request->RaidContext.VirtualDiskTgtId = cpu_to_le16(device_id); - int_to_scsilun(scmd->device->lun, (struct scsi_lun *)io_request->LUN); } /** @@ -1810,11 +1829,10 @@ megasas_build_io_fusion(struct megasas_instance *instance, struct scsi_cmnd *scp, struct megasas_cmd_fusion *cmd) { - u32 device_id, sge_count; + u32 sge_count; + u8 cmd_type; struct MPI2_RAID_SCSI_IO_REQUEST *io_request = cmd->io_request; - device_id = MEGASAS_DEV_INDEX(instance, scp); - /* Zero out some fields so they don't get reused */ memset(io_request->LUN, 0x0, 8); io_request->CDB.EEDP32.PrimaryReferenceTag = 0; @@ -1834,10 +1852,24 @@ megasas_build_io_fusion(struct megasas_instance *instance, */ io_request->IoFlags = cpu_to_le16(scp->cmd_len); - if (megasas_cmd_type(scp) == READ_WRITE_LDIO) + switch (cmd_type = megasas_cmd_type(scp)) { + case READ_WRITE_LDIO: megasas_build_ldio_fusion(instance, scp, cmd); - else - megasas_build_dcdb_fusion(instance, scp, cmd); + break; + case NON_READ_WRITE_LDIO: + megasas_build_ld_nonrw_fusion(instance, scp, cmd); + break; + case READ_WRITE_SYSPDIO: + case NON_READ_WRITE_SYSPDIO: + if (instance->secure_jbod_support && + (cmd_type == NON_READ_WRITE_SYSPDIO)) + megasas_build_syspd_fusion(instance, scp, cmd, 0); + else + megasas_build_syspd_fusion(instance, scp, cmd, 1); + break; + default: + break; + } /* * Construct SGL @@ -2013,8 +2045,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex) switch (scsi_io_req->Function) { case MPI2_FUNCTION_SCSI_IO_REQUEST: /*Fast Path IO.*/ /* Update load balancing info */ - device_id = MEGASAS_DEV_INDEX(instance, - cmd_fusion->scmd); + device_id = MEGASAS_DEV_INDEX(cmd_fusion->scmd); lbinfo = &fusion->load_balance_info[device_id]; if (cmd_fusion->scmd->SCp.Status & MEGASAS_LOAD_BALANCE_FLAG) {