Lines Matching +full:aac +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Adaptec AAC series RAID controller driver
9 * Copyright (c) 2000-2010 Adaptec, Inc.
10 * 2010-2015 PMC-Sierra, Inc. (aacraid@pmc-sierra.com)
11 * 2016-2017 Microsemi Corp. (aacraid@microsemi.com)
41 #define INQD_PDT_DA 0x00 /* Direct-access (DISK) device */
144 /*------------------------------------------------------------------------------
146 *----------------------------------------------------------------------------*/
151 u8 inqd_ver; /* ISO version | ECMA version | ANSI-approved version */
153 u8 inqd_len; /* Additional length (n-4) */
154 u8 inqd_pad1[2];/* Reserved - must be zero */
237 static int nondasd = -1;
239 static int dacmode = -1;
241 int aac_commit = -1;
244 int aac_sync_mode; /* Only Sync. transfer - disabled */
245 static int aac_convert_sgl = 1; /* convert non-conformable s/g list - enabled */
248 MODULE_PARM_DESC(aac_sync_mode, "Force sync. transfer mode"
251 MODULE_PARM_DESC(aac_convert_sgl, "Convert non-conformable s/g list"
258 "\tbit 0 - Disable FUA in WRITE SCSI commands\n"
259 "\tbit 1 - Disable SYNCHRONIZE_CACHE SCSI command\n"
260 "\tbit 2 - Disable only if Battery is protecting Cache");
271 " 0=PIC(default), 1=MSI, 2=MSI-X)");
287 int numacb = -1;
293 static int acbsize = -1;
312 " adapter. a value of -1 forces the reset to adapters programmed to"
315 int expose_physicals = -1;
318 " -1=protect 0=off, 1=on");
327 "\t0 - Disable\n"
328 "\t1 - Array Meta Data Signature (default)\n"
329 "\t2 - Adapter Serial Number");
336 if (unlikely(!scsicmd || !scsicmd->scsi_done)) { in aac_valid_context()
341 scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL; in aac_valid_context()
342 device = scsicmd->device; in aac_valid_context()
352 * aac_get_config_status - check the adapter configuration
353 * @dev: aac driver data
364 return -ENOMEM; in aac_get_config_status()
371 dinfo->command = cpu_to_le32(VM_ContainerConfig); in aac_get_config_status()
372 dinfo->type = cpu_to_le32(CT_GET_CONFIG_STATUS); in aac_get_config_status()
373 dinfo->count = cpu_to_le32(sizeof(((struct aac_get_config_status_resp *)NULL)->data)); in aac_get_config_status()
389 le32_to_cpu(reply->response), in aac_get_config_status()
390 le32_to_cpu(reply->status), in aac_get_config_status()
391 le32_to_cpu(reply->data.action))); in aac_get_config_status()
392 if ((le32_to_cpu(reply->response) != ST_OK) || in aac_get_config_status()
393 (le32_to_cpu(reply->status) != CT_OK) || in aac_get_config_status()
394 (le32_to_cpu(reply->data.action) > CFACT_PAUSE)) { in aac_get_config_status()
396 status = -EINVAL; in aac_get_config_status()
410 dinfo->command = cpu_to_le32(VM_ContainerConfig); in aac_get_config_status()
411 dinfo->type = cpu_to_le32(CT_COMMIT_CONFIG); in aac_get_config_status()
429 if (status != -ERESTARTSYS) in aac_get_config_status()
445 * aac_get_containers - list containers
446 * @dev: aac driver data
461 return -ENOMEM; in aac_get_containers()
465 dinfo->command = cpu_to_le32(VM_ContainerConfig); in aac_get_containers()
466 dinfo->type = cpu_to_le32(CT_GET_CONTAINER_COUNT); in aac_get_containers()
476 maximum_num_containers = le32_to_cpu(dresp->ContainerSwitchEntries); in aac_get_containers()
477 if (fibptr->dev->supplement_adapter_info.supported_options2 & in aac_get_containers()
480 le32_to_cpu(dresp->MaxSimpleVolumes); in aac_get_containers()
485 if (status != -ERESTARTSYS) in aac_get_containers()
490 if (dev->fsa_dev == NULL || in aac_get_containers()
491 dev->maximum_num_containers != maximum_num_containers) { in aac_get_containers()
493 fsa_dev_ptr = dev->fsa_dev; in aac_get_containers()
495 dev->fsa_dev = kcalloc(maximum_num_containers, in aac_get_containers()
502 if (!dev->fsa_dev) in aac_get_containers()
503 return -ENOMEM; in aac_get_containers()
505 dev->maximum_num_containers = maximum_num_containers; in aac_get_containers()
507 for (index = 0; index < dev->maximum_num_containers; index++) { in aac_get_containers()
508 dev->fsa_dev[index].devname[0] = '\0'; in aac_get_containers()
509 dev->fsa_dev[index].valid = 0; in aac_get_containers()
536 if ((le32_to_cpu(get_name_reply->status) == CT_OK) in get_container_name_callback()
537 && (get_name_reply->data[0] != '\0')) { in get_container_name_callback()
538 char *sp = get_name_reply->data; in get_container_name_callback()
541 sp[data_size - 1] = '\0'; in get_container_name_callback()
546 char d[sizeof(((struct inquiry_data *)NULL)->inqd_pid)]; in get_container_name_callback()
551 } while (--count > 0); in get_container_name_callback()
559 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; in get_container_name_callback()
562 scsicmd->scsi_done(scsicmd); in get_container_name_callback()
566 * aac_get_container_name - get container name, none blocking.
576 dev = (struct aac_dev *)scsicmd->device->host->hostdata; in aac_get_container_name()
584 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; in aac_get_container_name()
586 dinfo->command = cpu_to_le32(VM_ContainerConfig); in aac_get_container_name()
587 dinfo->type = cpu_to_le32(CT_READ_NAME); in aac_get_container_name()
588 dinfo->cid = cpu_to_le32(scmd_id(scsicmd)); in aac_get_container_name()
589 dinfo->count = cpu_to_le32(data_size - 1); in aac_get_container_name()
602 if (status == -EINPROGRESS) in aac_get_container_name()
607 return -1; in aac_get_container_name()
612 struct fsa_dev_info *fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev; in aac_probe_container_callback2()
617 scsicmd->result = DID_NO_CONNECT << 16; in aac_probe_container_callback2()
618 scsicmd->scsi_done(scsicmd); in aac_probe_container_callback2()
633 scsicmd->SCp.Status = 0; in _aac_probe_container2()
634 fsa_dev_ptr = fibptr->dev->fsa_dev; in _aac_probe_container2()
641 fibptr->dev->supplement_adapter_info.supported_options2; in _aac_probe_container2()
643 if ((le32_to_cpu(dresp->status) == ST_OK) && in _aac_probe_container2()
644 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) && in _aac_probe_container2()
645 (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) { in _aac_probe_container2()
647 dresp->mnt[0].fileinfo.bdevinfo.block_size = 0x200; in _aac_probe_container2()
648 fsa_dev_ptr->block_size = 0x200; in _aac_probe_container2()
650 fsa_dev_ptr->block_size = in _aac_probe_container2()
651 le32_to_cpu(dresp->mnt[0].fileinfo.bdevinfo.block_size); in _aac_probe_container2()
654 fsa_dev_ptr->identifier[i] = in _aac_probe_container2()
655 dresp->mnt[0].fileinfo.bdevinfo in _aac_probe_container2()
657 fsa_dev_ptr->valid = 1; in _aac_probe_container2()
658 /* sense_key holds the current state of the spin-up */ in _aac_probe_container2()
659 if (dresp->mnt[0].state & cpu_to_le32(FSCS_NOT_READY)) in _aac_probe_container2()
660 fsa_dev_ptr->sense_data.sense_key = NOT_READY; in _aac_probe_container2()
661 else if (fsa_dev_ptr->sense_data.sense_key == NOT_READY) in _aac_probe_container2()
662 fsa_dev_ptr->sense_data.sense_key = NO_SENSE; in _aac_probe_container2()
663 fsa_dev_ptr->type = le32_to_cpu(dresp->mnt[0].vol); in _aac_probe_container2()
664 fsa_dev_ptr->size in _aac_probe_container2()
665 = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) + in _aac_probe_container2()
666 (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32); in _aac_probe_container2()
667 fsa_dev_ptr->ro = ((le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY) != 0); in _aac_probe_container2()
669 if ((fsa_dev_ptr->valid & 1) == 0) in _aac_probe_container2()
670 fsa_dev_ptr->valid = 0; in _aac_probe_container2()
671 scsicmd->SCp.Status = le32_to_cpu(dresp->count); in _aac_probe_container2()
675 callback = (int (*)(struct scsi_cmnd *))(scsicmd->SCp.ptr); in _aac_probe_container2()
676 scsicmd->SCp.ptr = NULL; in _aac_probe_container2()
689 if (!aac_supports_2T(fibptr->dev)) { in _aac_probe_container1()
690 dresp->mnt[0].capacityhigh = 0; in _aac_probe_container1()
691 if ((le32_to_cpu(dresp->status) == ST_OK) && in _aac_probe_container1()
692 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE)) { in _aac_probe_container1()
706 if (fibptr->dev->supplement_adapter_info.supported_options2 & in _aac_probe_container1()
708 dinfo->command = cpu_to_le32(VM_NameServeAllBlk); in _aac_probe_container1()
710 dinfo->command = cpu_to_le32(VM_NameServe64); in _aac_probe_container1()
712 dinfo->count = cpu_to_le32(scmd_id(scsicmd)); in _aac_probe_container1()
713 dinfo->type = cpu_to_le32(FT_FILESYS); in _aac_probe_container1()
714 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; in _aac_probe_container1()
726 if (status < 0 && status != -EINPROGRESS) { in _aac_probe_container1()
728 dresp->status = cpu_to_le32(ST_OK); in _aac_probe_container1()
736 int status = -ENOMEM; in _aac_probe_container()
738 if ((fibptr = aac_fib_alloc((struct aac_dev *)scsicmd->device->host->hostdata))) { in _aac_probe_container()
745 if (fibptr->dev->supplement_adapter_info.supported_options2 & in _aac_probe_container()
747 dinfo->command = cpu_to_le32(VM_NameServeAllBlk); in _aac_probe_container()
749 dinfo->command = cpu_to_le32(VM_NameServe); in _aac_probe_container()
751 dinfo->count = cpu_to_le32(scmd_id(scsicmd)); in _aac_probe_container()
752 dinfo->type = cpu_to_le32(FT_FILESYS); in _aac_probe_container()
753 scsicmd->SCp.ptr = (char *)callback; in _aac_probe_container()
754 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; in _aac_probe_container()
766 if (status == -EINPROGRESS) in _aac_probe_container()
770 scsicmd->SCp.ptr = NULL; in _aac_probe_container()
776 struct fsa_dev_info *fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev; in _aac_probe_container()
779 if ((fsa_dev_ptr->valid & 1) == 0) { in _aac_probe_container()
780 fsa_dev_ptr->valid = 0; in _aac_probe_container()
789 * aac_probe_container - query a logical volume
797 scsicmd->device = NULL; in aac_probe_container_callback1()
815 return -ENOMEM; in aac_probe_container()
817 scsicmd->scsi_done = aac_probe_container_scsi_done; in aac_probe_container()
819 scsicmd->device = scsidev; in aac_probe_container()
820 scsidev->sdev_state = 0; in aac_probe_container()
821 scsidev->id = cid; in aac_probe_container()
822 scsidev->host = dev->scsi_host_ptr; in aac_probe_container()
825 while (scsicmd->device == scsidev) in aac_probe_container()
828 status = scsicmd->SCp.Status; in aac_probe_container()
841 * InqStrCopy - string merge
869 "V-MIRRORS",
883 tindex = ARRAY_SIZE(container_types) - 1; in get_container_type()
901 sup_adap_info = &dev->supplement_adapter_info; in setinqstr()
905 if (sup_adap_info->adapter_type_text[0]) { in setinqstr()
908 char *cname = kmemdup(sup_adap_info->adapter_type_text, in setinqstr()
909 sizeof(sup_adap_info->adapter_type_text), in setinqstr()
916 inqstrcpy("SMC", str->vid); in setinqstr()
918 c = sizeof(str->vid); in setinqstr()
919 while (*cp && *cp != ' ' && --c) in setinqstr()
923 inqstrcpy(cname, str->vid); in setinqstr()
931 if (strlen(cp) > sizeof(str->pid)) in setinqstr()
932 cp[sizeof(str->pid)] = '\0'; in setinqstr()
933 inqstrcpy (cp, str->pid); in setinqstr()
937 struct aac_driver_ident *mp = aac_get_driver_ident(dev->cardtype); in setinqstr()
939 inqstrcpy (mp->vname, str->vid); in setinqstr()
941 inqstrcpy (mp->model, str->pid); in setinqstr()
945 char *findit = str->pid; in setinqstr()
949 if (memcmp(findit-4, "RAID", 4) == 0) in setinqstr()
950 *(findit -= 4) = ' '; in setinqstr()
951 if (((findit - str->pid) + strlen(container_types[tindex])) in setinqstr()
952 < (sizeof(str->pid) + sizeof(str->prl))) in setinqstr()
955 inqstrcpy ("V1.0", str->prl); in setinqstr()
963 vpdpage83data->type3.codeset = 1; in build_vpd83_type3()
964 vpdpage83data->type3.identifiertype = 3; in build_vpd83_type3()
965 vpdpage83data->type3.identifierlength = sizeof(vpdpage83data->type3) in build_vpd83_type3()
966 - 4; in build_vpd83_type3()
968 for (container = 0; container < dev->maximum_num_containers; in build_vpd83_type3()
972 memcpy(vpdpage83data->type3.Identifier, in build_vpd83_type3()
973 dev->fsa_dev[container].identifier, in build_vpd83_type3()
993 if (le32_to_cpu(get_serial_reply->status) == CT_OK) { in get_container_serial_callback()
995 if (scsicmd->cmnd[2] == 0x83) { in get_container_serial_callback()
996 /* vpd page 0x83 - Device Identification Page */ in get_container_serial_callback()
1001 dev = (struct aac_dev *)scsicmd->device->host->hostdata; in get_container_serial_callback()
1018 if (dev->sa_firmware) in get_container_serial_callback()
1028 sizeof(vpdpage83data.type1) - 4; in get_container_serial_callback()
1044 (u8)((get_serial_reply->uid >> ((7 - i) * 4)) & 0xF); in get_container_serial_callback()
1047 'A' + (temp - 0xA); in get_container_serial_callback()
1059 sizeof(vpdpage83data.type2) - 4; in get_container_serial_callback()
1066 get_serial_reply->uid; in get_container_serial_callback()
1073 if (dev->sa_firmware) { in get_container_serial_callback()
1086 sp[1] = scsicmd->cmnd[2]; in get_container_serial_callback()
1088 sp[3] = snprintf(sp+4, sizeof(sp)-4, "%08X", in get_container_serial_callback()
1089 le32_to_cpu(get_serial_reply->uid)); in get_container_serial_callback()
1095 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; in get_container_serial_callback()
1098 scsicmd->scsi_done(scsicmd); in get_container_serial_callback()
1102 * aac_get_container_serial - get container serial, none blocking.
1111 dev = (struct aac_dev *)scsicmd->device->host->hostdata; in aac_get_container_serial()
1118 dinfo->command = cpu_to_le32(VM_ContainerConfig); in aac_get_container_serial()
1119 dinfo->type = cpu_to_le32(CT_CID_TO_32BITS_UID); in aac_get_container_serial()
1120 dinfo->cid = cpu_to_le32(scmd_id(scsicmd)); in aac_get_container_serial()
1121 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; in aac_get_container_serial()
1134 if (status == -EINPROGRESS) in aac_get_container_serial()
1139 return -1; in aac_get_container_serial()
1149 * without docs it's quite hard to do it :-)
1158 return snprintf((char *)(data), sizeof(struct scsi_inq) - 4, "%08X%02X", in setinqserial()
1159 le32_to_cpu(dev->adapter_info.serial[0]), cid); in setinqserial()
1194 cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_bounds_32()
1196 set_sense(&dev->fsa_dev[cid].sense_data, in aac_bounds_32()
1199 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, in aac_bounds_32()
1200 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), in aac_bounds_32()
1202 cmd->scsi_done(cmd); in aac_bounds_32()
1217 struct aac_dev *dev = fib->dev; in aac_read_raw_io()
1222 if ((dev->comm_interface == AAC_COMM_MESSAGE_TYPE2 || in aac_read_raw_io()
1223 dev->comm_interface == AAC_COMM_MESSAGE_TYPE3) && in aac_read_raw_io()
1224 !dev->sync_mode) { in aac_read_raw_io()
1228 readcmd2->blockLow = cpu_to_le32((u32)(lba&0xffffffff)); in aac_read_raw_io()
1229 readcmd2->blockHigh = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32)); in aac_read_raw_io()
1230 readcmd2->byteCount = cpu_to_le32(count * in aac_read_raw_io()
1231 dev->fsa_dev[scmd_id(cmd)].block_size); in aac_read_raw_io()
1232 readcmd2->cid = cpu_to_le16(scmd_id(cmd)); in aac_read_raw_io()
1233 readcmd2->flags = cpu_to_le16(RIO2_IO_TYPE_READ); in aac_read_raw_io()
1235 dev->scsi_host_ptr->sg_tablesize); in aac_read_raw_io()
1240 ((le32_to_cpu(readcmd2->sgeCnt)-1) * sizeof(struct sge_ieee1212)); in aac_read_raw_io()
1244 readcmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff)); in aac_read_raw_io()
1245 readcmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32)); in aac_read_raw_io()
1246 readcmd->count = cpu_to_le32(count * in aac_read_raw_io()
1247 dev->fsa_dev[scmd_id(cmd)].block_size); in aac_read_raw_io()
1248 readcmd->cid = cpu_to_le16(scmd_id(cmd)); in aac_read_raw_io()
1249 readcmd->flags = cpu_to_le16(RIO_TYPE_READ); in aac_read_raw_io()
1250 readcmd->bpTotal = 0; in aac_read_raw_io()
1251 readcmd->bpComplete = 0; in aac_read_raw_io()
1252 ret = aac_build_sgraw(cmd, &readcmd->sg); in aac_read_raw_io()
1257 ((le32_to_cpu(readcmd->sg.count)-1) * sizeof(struct sgentryraw)); in aac_read_raw_io()
1260 BUG_ON(fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); in aac_read_raw_io()
1281 readcmd->command = cpu_to_le32(VM_CtHostRead64); in aac_read_block64()
1282 readcmd->cid = cpu_to_le16(scmd_id(cmd)); in aac_read_block64()
1283 readcmd->sector_count = cpu_to_le16(count); in aac_read_block64()
1284 readcmd->block = cpu_to_le32((u32)(lba&0xffffffff)); in aac_read_block64()
1285 readcmd->pad = 0; in aac_read_block64()
1286 readcmd->flags = 0; in aac_read_block64()
1288 ret = aac_build_sg64(cmd, &readcmd->sg); in aac_read_block64()
1292 ((le32_to_cpu(readcmd->sg.count) - 1) * in aac_read_block64()
1294 BUG_ON (fibsize > (fib->dev->max_fib_size - in aac_read_block64()
1312 struct aac_dev *dev = fib->dev; in aac_read_block()
1317 readcmd->command = cpu_to_le32(VM_CtBlockRead); in aac_read_block()
1318 readcmd->cid = cpu_to_le32(scmd_id(cmd)); in aac_read_block()
1319 readcmd->block = cpu_to_le32((u32)(lba&0xffffffff)); in aac_read_block()
1320 readcmd->count = cpu_to_le32(count * in aac_read_block()
1321 dev->fsa_dev[scmd_id(cmd)].block_size); in aac_read_block()
1323 ret = aac_build_sg(cmd, &readcmd->sg); in aac_read_block()
1327 ((le32_to_cpu(readcmd->sg.count) - 1) * in aac_read_block()
1329 BUG_ON (fibsize > (fib->dev->max_fib_size - in aac_read_block()
1345 struct aac_dev *dev = fib->dev; in aac_write_raw_io()
1350 if ((dev->comm_interface == AAC_COMM_MESSAGE_TYPE2 || in aac_write_raw_io()
1351 dev->comm_interface == AAC_COMM_MESSAGE_TYPE3) && in aac_write_raw_io()
1352 !dev->sync_mode) { in aac_write_raw_io()
1356 writecmd2->blockLow = cpu_to_le32((u32)(lba&0xffffffff)); in aac_write_raw_io()
1357 writecmd2->blockHigh = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32)); in aac_write_raw_io()
1358 writecmd2->byteCount = cpu_to_le32(count * in aac_write_raw_io()
1359 dev->fsa_dev[scmd_id(cmd)].block_size); in aac_write_raw_io()
1360 writecmd2->cid = cpu_to_le16(scmd_id(cmd)); in aac_write_raw_io()
1361 writecmd2->flags = (fua && ((aac_cache & 5) != 1) && in aac_write_raw_io()
1362 (((aac_cache & 5) != 5) || !fib->dev->cache_protected)) ? in aac_write_raw_io()
1366 dev->scsi_host_ptr->sg_tablesize); in aac_write_raw_io()
1371 ((le32_to_cpu(writecmd2->sgeCnt)-1) * sizeof(struct sge_ieee1212)); in aac_write_raw_io()
1375 writecmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff)); in aac_write_raw_io()
1376 writecmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32)); in aac_write_raw_io()
1377 writecmd->count = cpu_to_le32(count * in aac_write_raw_io()
1378 dev->fsa_dev[scmd_id(cmd)].block_size); in aac_write_raw_io()
1379 writecmd->cid = cpu_to_le16(scmd_id(cmd)); in aac_write_raw_io()
1380 writecmd->flags = (fua && ((aac_cache & 5) != 1) && in aac_write_raw_io()
1381 (((aac_cache & 5) != 5) || !fib->dev->cache_protected)) ? in aac_write_raw_io()
1384 writecmd->bpTotal = 0; in aac_write_raw_io()
1385 writecmd->bpComplete = 0; in aac_write_raw_io()
1386 ret = aac_build_sgraw(cmd, &writecmd->sg); in aac_write_raw_io()
1391 ((le32_to_cpu(writecmd->sg.count)-1) * sizeof (struct sgentryraw)); in aac_write_raw_io()
1394 BUG_ON(fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); in aac_write_raw_io()
1415 writecmd->command = cpu_to_le32(VM_CtHostWrite64); in aac_write_block64()
1416 writecmd->cid = cpu_to_le16(scmd_id(cmd)); in aac_write_block64()
1417 writecmd->sector_count = cpu_to_le16(count); in aac_write_block64()
1418 writecmd->block = cpu_to_le32((u32)(lba&0xffffffff)); in aac_write_block64()
1419 writecmd->pad = 0; in aac_write_block64()
1420 writecmd->flags = 0; in aac_write_block64()
1422 ret = aac_build_sg64(cmd, &writecmd->sg); in aac_write_block64()
1426 ((le32_to_cpu(writecmd->sg.count) - 1) * in aac_write_block64()
1428 BUG_ON (fibsize > (fib->dev->max_fib_size - in aac_write_block64()
1446 struct aac_dev *dev = fib->dev; in aac_write_block()
1451 writecmd->command = cpu_to_le32(VM_CtBlockWrite); in aac_write_block()
1452 writecmd->cid = cpu_to_le32(scmd_id(cmd)); in aac_write_block()
1453 writecmd->block = cpu_to_le32((u32)(lba&0xffffffff)); in aac_write_block()
1454 writecmd->count = cpu_to_le32(count * in aac_write_block()
1455 dev->fsa_dev[scmd_id(cmd)].block_size); in aac_write_block()
1456 writecmd->sg.count = cpu_to_le32(1); in aac_write_block()
1457 /* ->stable is not used - it did mean which type of write */ in aac_write_block()
1459 ret = aac_build_sg(cmd, &writecmd->sg); in aac_write_block()
1463 ((le32_to_cpu(writecmd->sg.count) - 1) * in aac_write_block()
1465 BUG_ON (fibsize > (fib->dev->max_fib_size - in aac_write_block()
1484 struct aac_dev *dev = fib->dev; in aac_scsi_common()
1487 switch(cmd->sc_data_direction){ in aac_scsi_common()
1504 srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); in aac_scsi_common()
1505 srbcmd->channel = cpu_to_le32(aac_logical_to_phys(scmd_channel(cmd))); in aac_scsi_common()
1506 srbcmd->id = cpu_to_le32(scmd_id(cmd)); in aac_scsi_common()
1507 srbcmd->lun = cpu_to_le32(cmd->device->lun); in aac_scsi_common()
1508 srbcmd->flags = cpu_to_le32(flag); in aac_scsi_common()
1509 timeout = cmd->request->timeout/HZ; in aac_scsi_common()
1511 timeout = (dev->sa_firmware ? AAC_SA_TIMEOUT : AAC_ARC_TIMEOUT); in aac_scsi_common()
1512 srbcmd->timeout = cpu_to_le32(timeout); // timeout in seconds in aac_scsi_common()
1513 srbcmd->retry_limit = 0; /* Obsolete parameter */ in aac_scsi_common()
1514 srbcmd->cdb_size = cpu_to_le32(cmd->cmd_len); in aac_scsi_common()
1526 dev = (struct aac_dev *)cmd->device->host->hostdata; in aac_construct_hbacmd()
1528 hbacmd = (struct aac_hba_cmd_req *)fib->hw_fib_va; in aac_construct_hbacmd()
1531 switch (cmd->sc_data_direction) { in aac_construct_hbacmd()
1533 hbacmd->byte1 = 2; in aac_construct_hbacmd()
1537 hbacmd->byte1 = 1; in aac_construct_hbacmd()
1543 hbacmd->lun[1] = cpu_to_le32(cmd->device->lun); in aac_construct_hbacmd()
1547 hbacmd->it_nexus = dev->hba_map[bus][target].rmw_nexus; in aac_construct_hbacmd()
1553 memcpy(hbacmd->cdb, cmd->cmnd, cmd->cmd_len); in aac_construct_hbacmd()
1554 hbacmd->data_length = cpu_to_le32(scsi_bufflen(cmd)); in aac_construct_hbacmd()
1556 address = (u64)fib->hw_error_pa; in aac_construct_hbacmd()
1557 hbacmd->error_ptr_hi = cpu_to_le32((u32)(address >> 32)); in aac_construct_hbacmd()
1558 hbacmd->error_ptr_lo = cpu_to_le32((u32)(address & 0xffffffff)); in aac_construct_hbacmd()
1559 hbacmd->error_length = cpu_to_le32(FW_ERROR_BUFFER_SIZE); in aac_construct_hbacmd()
1572 ret = aac_build_sg64(cmd, (struct sgmap64 *) &srbcmd->sg); in aac_scsi_64()
1575 srbcmd->count = cpu_to_le32(scsi_bufflen(cmd)); in aac_scsi_64()
1577 memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); in aac_scsi_64()
1578 memcpy(srbcmd->cdb, cmd->cmnd, cmd->cmd_len); in aac_scsi_64()
1582 fibsize = sizeof (struct aac_srb) - sizeof (struct sgentry) + in aac_scsi_64()
1583 ((le32_to_cpu(srbcmd->sg.count) & 0xff) * in aac_scsi_64()
1585 BUG_ON (fibsize > (fib->dev->max_fib_size - in aac_scsi_64()
1603 ret = aac_build_sg(cmd, (struct sgmap *)&srbcmd->sg); in aac_scsi_32()
1606 srbcmd->count = cpu_to_le32(scsi_bufflen(cmd)); in aac_scsi_32()
1608 memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); in aac_scsi_32()
1609 memcpy(srbcmd->cdb, cmd->cmnd, cmd->cmd_len); in aac_scsi_32()
1614 (((le32_to_cpu(srbcmd->sg.count) & 0xff) - 1) * in aac_scsi_32()
1616 BUG_ON (fibsize > (fib->dev->max_fib_size - in aac_scsi_32()
1628 if ((sizeof(dma_addr_t) > 4) && fib->dev->needs_dac && in aac_scsi_32_64()
1629 (fib->dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)) in aac_scsi_32_64()
1640 dev = (struct aac_dev *)cmd->device->host->hostdata; in aac_adapter_hba()
1643 dev->scsi_host_ptr->sg_tablesize, (u64)fib->hw_sgl_pa); in aac_adapter_hba()
1650 fib->hbacmd_size = 64 + le32_to_cpu(hbacmd->emb_data_desc_count) * in aac_adapter_hba()
1671 if (!dev->sa_firmware) in aac_send_safw_bmic_cmd()
1677 return -ENOMEM; in aac_send_safw_bmic_cmd()
1680 fibptr->hw_fib_va->header.XferState &= in aac_send_safw_bmic_cmd()
1683 fibsize = sizeof(struct aac_srb) - sizeof(struct sgentry) + in aac_send_safw_bmic_cmd()
1687 addr = dma_map_single(&dev->pdev->dev, xfer_buf, xfer_len, in aac_send_safw_bmic_cmd()
1689 if (dma_mapping_error(&dev->pdev->dev, addr)) { in aac_send_safw_bmic_cmd()
1690 rcode = -ENOMEM; in aac_send_safw_bmic_cmd()
1695 memcpy(srb, &srbu->srb, sizeof(struct aac_srb)); in aac_send_safw_bmic_cmd()
1698 dev->supplement_adapter_info.virt_device_bus); in aac_send_safw_bmic_cmd()
1700 dev->supplement_adapter_info.virt_device_target); in aac_send_safw_bmic_cmd()
1703 srb->channel = cpu_to_le32(vbus); in aac_send_safw_bmic_cmd()
1704 srb->id = cpu_to_le32(vid); in aac_send_safw_bmic_cmd()
1705 srb->lun = 0; in aac_send_safw_bmic_cmd()
1706 srb->function = cpu_to_le32(SRBF_ExecuteScsi); in aac_send_safw_bmic_cmd()
1707 srb->timeout = 0; in aac_send_safw_bmic_cmd()
1708 srb->retry_limit = 0; in aac_send_safw_bmic_cmd()
1709 srb->cdb_size = cpu_to_le32(16); in aac_send_safw_bmic_cmd()
1710 srb->count = cpu_to_le32(xfer_len); in aac_send_safw_bmic_cmd()
1712 sg64 = (struct sgmap64 *)&srb->sg; in aac_send_safw_bmic_cmd()
1713 sg64->count = cpu_to_le32(1); in aac_send_safw_bmic_cmd()
1714 sg64->sg[0].addr[1] = cpu_to_le32(upper_32_bits(addr)); in aac_send_safw_bmic_cmd()
1715 sg64->sg[0].addr[0] = cpu_to_le32(lower_32_bits(addr)); in aac_send_safw_bmic_cmd()
1716 sg64->sg[0].count = cpu_to_le32(xfer_len); in aac_send_safw_bmic_cmd()
1721 memcpy(&srbu->srb, srb, sizeof(struct aac_srb)); in aac_send_safw_bmic_cmd()
1727 if (rcode == -ERESTARTSYS) in aac_send_safw_bmic_cmd()
1728 rcode = -ERESTART; in aac_send_safw_bmic_cmd()
1734 memcpy(&srbu->srb_reply, srb_reply, sizeof(struct aac_srb_reply)); in aac_send_safw_bmic_cmd()
1737 dma_unmap_single(&dev->pdev->dev, addr, xfer_len, DMA_BIDIRECTIONAL); in aac_send_safw_bmic_cmd()
1749 if (dev->hba_map[bus][target].devtype != AAC_DEVTYPE_NATIVE_RAW) in aac_set_safw_target_qd()
1752 identify_resp = dev->hba_map[bus][target].safw_identify_resp; in aac_set_safw_target_qd()
1754 dev->hba_map[bus][target].qd_limit = 32; in aac_set_safw_target_qd()
1758 if (identify_resp->current_queue_depth_limit <= 0 || in aac_set_safw_target_qd()
1759 identify_resp->current_queue_depth_limit > 255) in aac_set_safw_target_qd()
1760 dev->hba_map[bus][target].qd_limit = 32; in aac_set_safw_target_qd()
1762 dev->hba_map[bus][target].qd_limit = in aac_set_safw_target_qd()
1763 identify_resp->current_queue_depth_limit; in aac_set_safw_target_qd()
1769 int rcode = -ENOMEM; in aac_issue_safw_bmic_identify()
1783 srbcmd->flags = cpu_to_le32(SRB_DataIn); in aac_issue_safw_bmic_identify()
1784 srbcmd->cdb[0] = 0x26; in aac_issue_safw_bmic_identify()
1785 srbcmd->cdb[2] = (u8)((AAC_MAX_LUN + target) & 0x00FF); in aac_issue_safw_bmic_identify()
1786 srbcmd->cdb[6] = CISS_IDENTIFY_PHYSICAL_DEVICE; in aac_issue_safw_bmic_identify()
1803 kfree(dev->safw_phys_luns); in aac_free_safw_ciss_luns()
1804 dev->safw_phys_luns = NULL; in aac_free_safw_ciss_luns()
1816 int rcode = -ENOMEM; in aac_get_safw_ciss_luns()
1823 (AAC_MAX_TARGETS - 1) * sizeof(struct _ciss_lun); in aac_get_safw_ciss_luns()
1831 srbcmd->flags = cpu_to_le32(SRB_DataIn); in aac_get_safw_ciss_luns()
1832 srbcmd->cdb[0] = CISS_REPORT_PHYSICAL_LUNS; in aac_get_safw_ciss_luns()
1833 srbcmd->cdb[1] = 2; /* extended reporting */ in aac_get_safw_ciss_luns()
1834 srbcmd->cdb[8] = (u8)(datasize >> 8); in aac_get_safw_ciss_luns()
1835 srbcmd->cdb[9] = (u8)(datasize); in aac_get_safw_ciss_luns()
1841 if (phys_luns->resp_flag != 2) { in aac_get_safw_ciss_luns()
1842 rcode = -ENOMSG; in aac_get_safw_ciss_luns()
1846 dev->safw_phys_luns = phys_luns; in aac_get_safw_ciss_luns()
1857 return get_unaligned_be32(&dev->safw_phys_luns->list_length[0])/24; in aac_get_safw_phys_lun_count()
1862 return dev->safw_phys_luns->lun[lun].level2[1] & 0x3f; in aac_get_safw_phys_bus()
1867 return dev->safw_phys_luns->lun[lun].level2[0]; in aac_get_safw_phys_target()
1872 return dev->safw_phys_luns->lun[lun].bus >> 6; in aac_get_safw_phys_expose_flag()
1877 return dev->safw_phys_luns->lun[lun].node_ident[9]; in aac_get_safw_phys_attribs()
1882 return *((u32 *)&dev->safw_phys_luns->lun[lun].node_ident[12]); in aac_get_safw_phys_nexus()
1887 return dev->safw_phys_luns->lun[lun].node_ident[8]; in aac_get_safw_phys_device_type()
1893 kfree(dev->hba_map[bus][target].safw_identify_resp); in aac_free_safw_identify_resp()
1894 dev->hba_map[bus][target].safw_identify_resp = NULL; in aac_free_safw_identify_resp()
1942 dev->hba_map[bus][target].safw_identify_resp = identify_resp; in aac_get_safw_attr_all_targets()
1953 * aac_set_safw_attr_all_targets- update current hba map with data from FW
1967 dev->scan_counter++; in aac_set_safw_attr_all_targets()
1981 dev->hba_map[bus][target].devtype = in aac_set_safw_attr_all_targets()
1987 dev->hba_map[bus][target].devtype = in aac_set_safw_attr_all_targets()
1989 dev->hba_map[bus][target].rmw_nexus = in aac_set_safw_attr_all_targets()
1992 dev->hba_map[bus][target].devtype = in aac_set_safw_attr_all_targets()
1995 dev->hba_map[bus][target].scan_counter = dev->scan_counter; in aac_set_safw_attr_all_targets()
2019 aac_free_safw_all_identify_resp(dev, -1); in aac_setup_safw_targets()
2041 return -ENOMEM; in aac_get_adapter_info()
2051 -1, 1, /* First `interrupt' command uses special wait */ in aac_get_adapter_info()
2058 if (rcode != -ERESTARTSYS) { in aac_get_adapter_info()
2064 memcpy(&dev->adapter_info, info, sizeof(*info)); in aac_get_adapter_info()
2066 dev->supplement_adapter_info.virt_device_bus = 0xffff; in aac_get_adapter_info()
2067 if (dev->adapter_info.options & AAC_OPT_SUPPLEMENT_ADAPTER_INFO) { in aac_get_adapter_info()
2085 memcpy(&dev->supplement_adapter_info, sinfo, sizeof(*sinfo)); in aac_get_adapter_info()
2086 if (rcode == -ERESTARTSYS) { in aac_get_adapter_info()
2089 return -ENOMEM; in aac_get_adapter_info()
2097 dev->hba_map[bus][target].devtype = 0; in aac_get_adapter_info()
2098 dev->hba_map[bus][target].qd_limit = 0; in aac_get_adapter_info()
2114 command->Command = cpu_to_le32(VM_Ioctl); in aac_get_adapter_info()
2115 command->ObjType = cpu_to_le32(FT_DRIVE); in aac_get_adapter_info()
2116 command->MethodId = cpu_to_le32(1); in aac_get_adapter_info()
2117 command->CtlCmd = cpu_to_le32(GetBusInfo); in aac_get_adapter_info()
2127 dev->maximum_num_physicals = 16; in aac_get_adapter_info()
2128 if (rcode >= 0 && le32_to_cpu(bus_info->Status) == ST_OK) { in aac_get_adapter_info()
2129 dev->maximum_num_physicals = le32_to_cpu(bus_info->TargetsPerBus); in aac_get_adapter_info()
2130 dev->maximum_num_channels = le32_to_cpu(bus_info->BusCount); in aac_get_adapter_info()
2133 if (!dev->in_reset) { in aac_get_adapter_info()
2135 tmp = le32_to_cpu(dev->adapter_info.kernelrev); in aac_get_adapter_info()
2136 printk(KERN_INFO "%s%d: kernel %d.%d-%d[%d] %.*s\n", in aac_get_adapter_info()
2137 dev->name, in aac_get_adapter_info()
2138 dev->id, in aac_get_adapter_info()
2142 le32_to_cpu(dev->adapter_info.kernelbuild), in aac_get_adapter_info()
2143 (int)sizeof(dev->supplement_adapter_info.build_date), in aac_get_adapter_info()
2144 dev->supplement_adapter_info.build_date); in aac_get_adapter_info()
2145 tmp = le32_to_cpu(dev->adapter_info.monitorrev); in aac_get_adapter_info()
2146 printk(KERN_INFO "%s%d: monitor %d.%d-%d[%d]\n", in aac_get_adapter_info()
2147 dev->name, dev->id, in aac_get_adapter_info()
2149 le32_to_cpu(dev->adapter_info.monitorbuild)); in aac_get_adapter_info()
2150 tmp = le32_to_cpu(dev->adapter_info.biosrev); in aac_get_adapter_info()
2151 printk(KERN_INFO "%s%d: bios %d.%d-%d[%d]\n", in aac_get_adapter_info()
2152 dev->name, dev->id, in aac_get_adapter_info()
2154 le32_to_cpu(dev->adapter_info.biosbuild)); in aac_get_adapter_info()
2157 shost_to_class(dev->scsi_host_ptr), buffer)) in aac_get_adapter_info()
2159 dev->name, dev->id, buffer); in aac_get_adapter_info()
2160 if (dev->supplement_adapter_info.vpd_info.tsid[0]) { in aac_get_adapter_info()
2162 dev->name, dev->id, in aac_get_adapter_info()
2163 (int)sizeof(dev->supplement_adapter_info in aac_get_adapter_info()
2165 dev->supplement_adapter_info.vpd_info.tsid); in aac_get_adapter_info()
2168 (dev->supplement_adapter_info.supported_options2 & in aac_get_adapter_info()
2171 dev->name, dev->id); in aac_get_adapter_info()
2175 dev->cache_protected = 0; in aac_get_adapter_info()
2176 dev->jbod = ((dev->supplement_adapter_info.feature_bits & in aac_get_adapter_info()
2178 dev->nondasd_support = 0; in aac_get_adapter_info()
2179 dev->raid_scsi_mode = 0; in aac_get_adapter_info()
2180 if(dev->adapter_info.options & AAC_OPT_NONDASD) in aac_get_adapter_info()
2181 dev->nondasd_support = 1; in aac_get_adapter_info()
2184 * If the firmware supports ROMB RAID/SCSI mode and we are currently in aac_get_adapter_info()
2185 * in RAID/SCSI mode, set the flag. For now if in this mode we will in aac_get_adapter_info()
2186 * force nondasd support on. If we decide to allow the non-dasd flag in aac_get_adapter_info()
2189 * changed to support the new dev->raid_scsi_mode flag instead of in aac_get_adapter_info()
2190 * leaching off of the dev->nondasd_support flag. Also in linit.c the in aac_get_adapter_info()
2192 * max number of channels based on the aac->nondasd_support flag only. in aac_get_adapter_info()
2194 if ((dev->adapter_info.options & AAC_OPT_SCSI_MANAGED) && in aac_get_adapter_info()
2195 (dev->adapter_info.options & AAC_OPT_RAID_SCSI_MODE)) { in aac_get_adapter_info()
2196 dev->nondasd_support = 1; in aac_get_adapter_info()
2197 dev->raid_scsi_mode = 1; in aac_get_adapter_info()
2199 if (dev->raid_scsi_mode != 0) in aac_get_adapter_info()
2200 printk(KERN_INFO "%s%d: ROMB RAID/SCSI mode enabled\n", in aac_get_adapter_info()
2201 dev->name, dev->id); in aac_get_adapter_info()
2203 if (nondasd != -1) in aac_get_adapter_info()
2204 dev->nondasd_support = (nondasd!=0); in aac_get_adapter_info()
2205 if (dev->nondasd_support && !dev->in_reset) in aac_get_adapter_info()
2206 printk(KERN_INFO "%s%d: Non-DASD support enabled.\n",dev->name, dev->id); in aac_get_adapter_info()
2208 if (dma_get_required_mask(&dev->pdev->dev) > DMA_BIT_MASK(32)) in aac_get_adapter_info()
2209 dev->needs_dac = 1; in aac_get_adapter_info()
2210 dev->dac_support = 0; in aac_get_adapter_info()
2211 if ((sizeof(dma_addr_t) > 4) && dev->needs_dac && in aac_get_adapter_info()
2212 (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)) { in aac_get_adapter_info()
2213 if (!dev->in_reset) in aac_get_adapter_info()
2215 dev->name, dev->id); in aac_get_adapter_info()
2216 dev->dac_support = 1; in aac_get_adapter_info()
2219 if(dacmode != -1) { in aac_get_adapter_info()
2220 dev->dac_support = (dacmode!=0); in aac_get_adapter_info()
2224 if (dev->dac_support && (aac_get_driver_ident(dev->cardtype)->quirks in aac_get_adapter_info()
2226 dev->nondasd_support = 0; in aac_get_adapter_info()
2227 dev->jbod = 0; in aac_get_adapter_info()
2231 if (dev->dac_support) { in aac_get_adapter_info()
2232 if (!dma_set_mask(&dev->pdev->dev, DMA_BIT_MASK(64))) { in aac_get_adapter_info()
2233 if (!dev->in_reset) in aac_get_adapter_info()
2234 dev_info(&dev->pdev->dev, "64 Bit DAC enabled\n"); in aac_get_adapter_info()
2235 } else if (!dma_set_mask(&dev->pdev->dev, DMA_BIT_MASK(32))) { in aac_get_adapter_info()
2236 dev_info(&dev->pdev->dev, "DMA mask set failed, 64 Bit DAC disabled\n"); in aac_get_adapter_info()
2237 dev->dac_support = 0; in aac_get_adapter_info()
2239 dev_info(&dev->pdev->dev, "No suitable DMA available\n"); in aac_get_adapter_info()
2240 rcode = -ENOMEM; in aac_get_adapter_info()
2247 dev->a_ops.adapter_scsi = (dev->dac_support) in aac_get_adapter_info()
2248 ? ((aac_get_driver_ident(dev->cardtype)->quirks & AAC_QUIRK_SCSI_32) in aac_get_adapter_info()
2252 if (dev->raw_io_interface) { in aac_get_adapter_info()
2253 dev->a_ops.adapter_bounds = (dev->raw_io_64) in aac_get_adapter_info()
2256 dev->a_ops.adapter_read = aac_read_raw_io; in aac_get_adapter_info()
2257 dev->a_ops.adapter_write = aac_write_raw_io; in aac_get_adapter_info()
2259 dev->a_ops.adapter_bounds = aac_bounds_32; in aac_get_adapter_info()
2260 dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size - in aac_get_adapter_info()
2261 sizeof(struct aac_fibhdr) - in aac_get_adapter_info()
2264 if (dev->dac_support) { in aac_get_adapter_info()
2265 dev->a_ops.adapter_read = aac_read_block64; in aac_get_adapter_info()
2266 dev->a_ops.adapter_write = aac_write_block64; in aac_get_adapter_info()
2270 dev->scsi_host_ptr->sg_tablesize = in aac_get_adapter_info()
2271 (dev->max_fib_size - in aac_get_adapter_info()
2272 sizeof(struct aac_fibhdr) - in aac_get_adapter_info()
2277 dev->a_ops.adapter_read = aac_read_block; in aac_get_adapter_info()
2278 dev->a_ops.adapter_write = aac_write_block; in aac_get_adapter_info()
2280 dev->scsi_host_ptr->max_sectors = AAC_MAX_32BIT_SGBCOUNT; in aac_get_adapter_info()
2281 if (!(dev->adapter_info.options & AAC_OPT_NEW_COMM)) { in aac_get_adapter_info()
2287 * (sg_tablesize-1) 4KB elements with one 64KB in aac_get_adapter_info()
2289 * 32bit -> 468 or 238KB 64bit -> 424 or 212KB in aac_get_adapter_info()
2291 dev->scsi_host_ptr->max_sectors = in aac_get_adapter_info()
2292 (dev->scsi_host_ptr->sg_tablesize * 8) + 112; in aac_get_adapter_info()
2295 if (!dev->sync_mode && dev->sa_firmware && in aac_get_adapter_info()
2296 dev->scsi_host_ptr->sg_tablesize > HBA_MAX_SG_SEPARATE) in aac_get_adapter_info()
2297 dev->scsi_host_ptr->sg_tablesize = dev->sg_tablesize = in aac_get_adapter_info()
2301 if (rcode != -ERESTARTSYS) { in aac_get_adapter_info()
2322 dev = fibptr->dev; in io_callback()
2327 switch (scsicmd->cmnd[0]) { in io_callback()
2330 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | in io_callback()
2331 (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; in io_callback()
2335 lba = ((u64)scsicmd->cmnd[2] << 56) | in io_callback()
2336 ((u64)scsicmd->cmnd[3] << 48) | in io_callback()
2337 ((u64)scsicmd->cmnd[4] << 40) | in io_callback()
2338 ((u64)scsicmd->cmnd[5] << 32) | in io_callback()
2339 ((u64)scsicmd->cmnd[6] << 24) | in io_callback()
2340 (scsicmd->cmnd[7] << 16) | in io_callback()
2341 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9]; in io_callback()
2345 lba = ((u64)scsicmd->cmnd[2] << 24) | in io_callback()
2346 (scsicmd->cmnd[3] << 16) | in io_callback()
2347 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; in io_callback()
2350 lba = ((u64)scsicmd->cmnd[2] << 24) | in io_callback()
2351 (scsicmd->cmnd[3] << 16) | in io_callback()
2352 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; in io_callback()
2365 switch (le32_to_cpu(readreply->status)) { in io_callback()
2367 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in io_callback()
2369 dev->fsa_dev[cid].sense_data.sense_key = NO_SENSE; in io_callback()
2372 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in io_callback()
2374 set_sense(&dev->fsa_dev[cid].sense_data, NOT_READY, in io_callback()
2376 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, in io_callback()
2377 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), in io_callback()
2381 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in io_callback()
2383 set_sense(&dev->fsa_dev[cid].sense_data, MEDIUM_ERROR, in io_callback()
2385 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, in io_callback()
2386 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), in io_callback()
2392 le32_to_cpu(readreply->status)); in io_callback()
2394 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in io_callback()
2396 set_sense(&dev->fsa_dev[cid].sense_data, in io_callback()
2399 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, in io_callback()
2400 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), in io_callback()
2406 scsicmd->scsi_done(scsicmd); in io_callback()
2418 dev = (struct aac_dev *)scsicmd->device->host->hostdata; in aac_read()
2422 switch (scsicmd->cmnd[0]) { in aac_read()
2426 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | in aac_read()
2427 (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; in aac_read()
2428 count = scsicmd->cmnd[4]; in aac_read()
2436 lba = ((u64)scsicmd->cmnd[2] << 56) | in aac_read()
2437 ((u64)scsicmd->cmnd[3] << 48) | in aac_read()
2438 ((u64)scsicmd->cmnd[4] << 40) | in aac_read()
2439 ((u64)scsicmd->cmnd[5] << 32) | in aac_read()
2440 ((u64)scsicmd->cmnd[6] << 24) | in aac_read()
2441 (scsicmd->cmnd[7] << 16) | in aac_read()
2442 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9]; in aac_read()
2443 count = (scsicmd->cmnd[10] << 24) | in aac_read()
2444 (scsicmd->cmnd[11] << 16) | in aac_read()
2445 (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13]; in aac_read()
2450 lba = ((u64)scsicmd->cmnd[2] << 24) | in aac_read()
2451 (scsicmd->cmnd[3] << 16) | in aac_read()
2452 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; in aac_read()
2453 count = (scsicmd->cmnd[6] << 24) | in aac_read()
2454 (scsicmd->cmnd[7] << 16) | in aac_read()
2455 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9]; in aac_read()
2460 lba = ((u64)scsicmd->cmnd[2] << 24) | in aac_read()
2461 (scsicmd->cmnd[3] << 16) | in aac_read()
2462 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; in aac_read()
2463 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; in aac_read()
2467 if ((lba + count) > (dev->fsa_dev[scmd_id(scsicmd)].size)) { in aac_read()
2470 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_read()
2472 set_sense(&dev->fsa_dev[cid].sense_data, in aac_read()
2475 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, in aac_read()
2476 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), in aac_read()
2478 scsicmd->scsi_done(scsicmd); in aac_read()
2490 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; in aac_read()
2496 if (status == -EINPROGRESS) in aac_read()
2503 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_TASK_SET_FULL; in aac_read()
2504 scsicmd->scsi_done(scsicmd); in aac_read()
2520 dev = (struct aac_dev *)scsicmd->device->host->hostdata; in aac_write()
2524 if (scsicmd->cmnd[0] == WRITE_6) /* 6 byte command */ in aac_write()
2526 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; in aac_write()
2527 count = scsicmd->cmnd[4]; in aac_write()
2531 } else if (scsicmd->cmnd[0] == WRITE_16) { /* 16 byte command */ in aac_write()
2534 lba = ((u64)scsicmd->cmnd[2] << 56) | in aac_write()
2535 ((u64)scsicmd->cmnd[3] << 48) | in aac_write()
2536 ((u64)scsicmd->cmnd[4] << 40) | in aac_write()
2537 ((u64)scsicmd->cmnd[5] << 32) | in aac_write()
2538 ((u64)scsicmd->cmnd[6] << 24) | in aac_write()
2539 (scsicmd->cmnd[7] << 16) | in aac_write()
2540 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9]; in aac_write()
2541 count = (scsicmd->cmnd[10] << 24) | (scsicmd->cmnd[11] << 16) | in aac_write()
2542 (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13]; in aac_write()
2543 fua = scsicmd->cmnd[1] & 0x8; in aac_write()
2544 } else if (scsicmd->cmnd[0] == WRITE_12) { /* 12 byte command */ in aac_write()
2547 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) in aac_write()
2548 | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; in aac_write()
2549 count = (scsicmd->cmnd[6] << 24) | (scsicmd->cmnd[7] << 16) in aac_write()
2550 | (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9]; in aac_write()
2551 fua = scsicmd->cmnd[1] & 0x8; in aac_write()
2554 …lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd… in aac_write()
2555 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; in aac_write()
2556 fua = scsicmd->cmnd[1] & 0x8; in aac_write()
2559 if ((lba + count) > (dev->fsa_dev[scmd_id(scsicmd)].size)) { in aac_write()
2562 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_write()
2564 set_sense(&dev->fsa_dev[cid].sense_data, in aac_write()
2567 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, in aac_write()
2568 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), in aac_write()
2570 scsicmd->scsi_done(scsicmd); in aac_write()
2582 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; in aac_write()
2588 if (status == -EINPROGRESS) in aac_write()
2595 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_TASK_SET_FULL; in aac_write()
2596 scsicmd->scsi_done(scsicmd); in aac_write()
2617 if (le32_to_cpu(synchronizereply->status) == CT_OK) in synchronize_callback()
2618 cmd->result = DID_OK << 16 | in synchronize_callback()
2621 struct scsi_device *sdev = cmd->device; in synchronize_callback()
2622 struct aac_dev *dev = fibptr->dev; in synchronize_callback()
2626 le32_to_cpu(synchronizereply->status)); in synchronize_callback()
2627 cmd->result = DID_OK << 16 | in synchronize_callback()
2629 set_sense(&dev->fsa_dev[cid].sense_data, in synchronize_callback()
2632 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, in synchronize_callback()
2633 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), in synchronize_callback()
2639 cmd->scsi_done(cmd); in synchronize_callback()
2647 struct scsi_device *sdev = scsicmd->device; in aac_synchronize()
2648 struct aac_dev *aac; in aac_synchronize() local
2650 aac = (struct aac_dev *)sdev->host->hostdata; in aac_synchronize()
2651 if (aac->in_reset) in aac_synchronize()
2657 cmd_fibcontext = aac_fib_alloc_tag(aac, scsicmd); in aac_synchronize()
2662 synchronizecmd->command = cpu_to_le32(VM_ContainerConfig); in aac_synchronize()
2663 synchronizecmd->type = cpu_to_le32(CT_FLUSH_CACHE); in aac_synchronize()
2664 synchronizecmd->cid = cpu_to_le32(scmd_id(scsicmd)); in aac_synchronize()
2665 synchronizecmd->count = in aac_synchronize()
2666 cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data)); in aac_synchronize()
2667 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; in aac_synchronize()
2683 if (status == -EINPROGRESS) in aac_synchronize()
2702 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; in aac_start_stop_callback()
2706 scsicmd->scsi_done(scsicmd); in aac_start_stop_callback()
2714 struct scsi_device *sdev = scsicmd->device; in aac_start_stop()
2715 struct aac_dev *aac = (struct aac_dev *)sdev->host->hostdata; in aac_start_stop() local
2717 if (!(aac->supplement_adapter_info.supported_options2 & in aac_start_stop()
2719 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_start_stop()
2721 scsicmd->scsi_done(scsicmd); in aac_start_stop()
2725 if (aac->in_reset) in aac_start_stop()
2731 cmd_fibcontext = aac_fib_alloc_tag(aac, scsicmd); in aac_start_stop()
2736 pmcmd->command = cpu_to_le32(VM_ContainerConfig); in aac_start_stop()
2737 pmcmd->type = cpu_to_le32(CT_POWER_MANAGEMENT); in aac_start_stop()
2739 pmcmd->sub = (scsicmd->cmnd[4] & 1) ? in aac_start_stop()
2741 pmcmd->cid = cpu_to_le32(sdev_id(sdev)); in aac_start_stop()
2742 pmcmd->parm = (scsicmd->cmnd[1] & 1) ? in aac_start_stop()
2744 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; in aac_start_stop()
2760 if (status == -EINPROGRESS) in aac_start_stop()
2769 * aac_scsi_cmd() - Process SCSI command
2779 struct Scsi_Host *host = scsicmd->device->host; in aac_scsi_cmd()
2780 struct aac_dev *dev = (struct aac_dev *)host->hostdata; in aac_scsi_cmd()
2781 struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev; in aac_scsi_cmd()
2784 return -1; in aac_scsi_cmd()
2791 if (cid != host->this_id) { in aac_scsi_cmd()
2793 if((cid >= dev->maximum_num_containers) || in aac_scsi_cmd()
2794 (scsicmd->device->lun != 0)) { in aac_scsi_cmd()
2795 scsicmd->result = DID_NO_CONNECT << 16; in aac_scsi_cmd()
2806 switch (scsicmd->cmnd[0]) { in aac_scsi_cmd()
2808 if (!(dev->raw_io_interface) || in aac_scsi_cmd()
2809 !(dev->raw_io_64) || in aac_scsi_cmd()
2810 ((scsicmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16)) in aac_scsi_cmd()
2816 if (dev->in_reset) in aac_scsi_cmd()
2817 return -1; in aac_scsi_cmd()
2824 } else { /* check for physical non-dasd devices */ in aac_scsi_cmd()
2828 dev->hba_map[bus][cid].devtype in aac_scsi_cmd()
2830 if (dev->in_reset) in aac_scsi_cmd()
2831 return -1; in aac_scsi_cmd()
2833 } else if (dev->nondasd_support || expose_physicals || in aac_scsi_cmd()
2834 dev->jbod) { in aac_scsi_cmd()
2835 if (dev->in_reset) in aac_scsi_cmd()
2836 return -1; in aac_scsi_cmd()
2839 scsicmd->result = DID_NO_CONNECT << 16; in aac_scsi_cmd()
2847 else if ((scsicmd->cmnd[0] != INQUIRY) && /* only INQUIRY & TUR cmnd supported for controller */ in aac_scsi_cmd()
2848 (scsicmd->cmnd[0] != TEST_UNIT_READY)) in aac_scsi_cmd()
2850 …_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0])); in aac_scsi_cmd()
2851 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; in aac_scsi_cmd()
2852 set_sense(&dev->fsa_dev[cid].sense_data, in aac_scsi_cmd()
2855 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, in aac_scsi_cmd()
2856 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), in aac_scsi_cmd()
2861 switch (scsicmd->cmnd[0]) { in aac_scsi_cmd()
2866 if (dev->in_reset) in aac_scsi_cmd()
2867 return -1; in aac_scsi_cmd()
2874 if (dev->in_reset) in aac_scsi_cmd()
2875 return -1; in aac_scsi_cmd()
2879 if (((aac_cache & 6) == 6) && dev->cache_protected) { in aac_scsi_cmd()
2880 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_scsi_cmd()
2895 if ((scsicmd->cmnd[1] & 0x1) && aac_wwn) { in aac_scsi_cmd()
2899 arr[0] = (scmd_id(scsicmd) == host->this_id) ? in aac_scsi_cmd()
2901 if (scsicmd->cmnd[2] == 0) { in aac_scsi_cmd()
2907 arr[1] = scsicmd->cmnd[2]; in aac_scsi_cmd()
2910 scsicmd->result = DID_OK << 16 | in aac_scsi_cmd()
2913 } else if (scsicmd->cmnd[2] == 0x80) { in aac_scsi_cmd()
2917 arr[1] = scsicmd->cmnd[2]; in aac_scsi_cmd()
2923 scsicmd->result = DID_OK << 16 | in aac_scsi_cmd()
2926 } else if (scsicmd->cmnd[2] == 0x83) { in aac_scsi_cmd()
2927 /* vpd page 0x83 - Device Identification Page */ in aac_scsi_cmd()
2934 scsicmd->result = DID_OK << 16 | in aac_scsi_cmd()
2939 scsicmd->result = DID_OK << 16 | in aac_scsi_cmd()
2942 set_sense(&dev->fsa_dev[cid].sense_data, in aac_scsi_cmd()
2945 memcpy(scsicmd->sense_buffer, in aac_scsi_cmd()
2946 &dev->fsa_dev[cid].sense_data, in aac_scsi_cmd()
2948 sizeof(dev->fsa_dev[cid].sense_data), in aac_scsi_cmd()
2953 inq_data.inqd_ver = 2; /* claim compliance to SCSI-2 */ in aac_scsi_cmd()
2954 …onse data format value of two indicates that the data shall be in the format specified in SCSI-2 */ in aac_scsi_cmd()
2960 * see: <vendor>.c i.e. aac.c in aac_scsi_cmd()
2962 if (cid == host->this_id) { in aac_scsi_cmd()
2967 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_scsi_cmd()
2971 if (dev->in_reset) in aac_scsi_cmd()
2972 return -1; in aac_scsi_cmd()
2979 if (!(dev->raw_io_interface) || in aac_scsi_cmd()
2980 !(dev->raw_io_64) || in aac_scsi_cmd()
2981 ((scsicmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16)) in aac_scsi_cmd()
2989 capacity = fsa_dev_ptr[cid].size - 1; in aac_scsi_cmd()
3004 alloc_len = ((scsicmd->cmnd[10] << 24) in aac_scsi_cmd()
3005 + (scsicmd->cmnd[11] << 16) in aac_scsi_cmd()
3006 + (scsicmd->cmnd[12] << 8) + scsicmd->cmnd[13]); in aac_scsi_cmd()
3012 scsi_bufflen(scsicmd) - alloc_len); in aac_scsi_cmd()
3015 scsicmd->device->removable = 1; in aac_scsi_cmd()
3017 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_scsi_cmd()
3029 capacity = fsa_dev_ptr[cid].size - 1; in aac_scsi_cmd()
3031 capacity = (u32)-1; in aac_scsi_cmd()
3043 scsicmd->device->removable = 1; in aac_scsi_cmd()
3044 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_scsi_cmd()
3056 capacity = fsa_dev_ptr[cid].size - 1; in aac_scsi_cmd()
3058 capacity = (u32)-1; in aac_scsi_cmd()
3060 dprintk((KERN_DEBUG "MODE SENSE command.\n")); in aac_scsi_cmd()
3063 /* Mode data length */ in aac_scsi_cmd()
3064 mpd.hd.data_length = sizeof(mpd.hd) - 1; in aac_scsi_cmd()
3065 /* Medium type - default */ in aac_scsi_cmd()
3067 /* Device-specific param, in aac_scsi_cmd()
3072 if (dev->raw_io_interface && ((aac_cache & 5) != 1)) in aac_scsi_cmd()
3074 if (scsicmd->cmnd[1] & 0x8) in aac_scsi_cmd()
3086 mpd.mpc_buf[0] = scsicmd->cmnd[2]; in aac_scsi_cmd()
3087 if (scsicmd->cmnd[2] == 0x1C) { in aac_scsi_cmd()
3090 /* Mode data length */ in aac_scsi_cmd()
3093 /* Mode data length */ in aac_scsi_cmd()
3107 if (((scsicmd->cmnd[2] & 0x3f) == 8) || in aac_scsi_cmd()
3108 ((scsicmd->cmnd[2] & 0x3f) == 0x3f)) { in aac_scsi_cmd()
3117 if (mode_buf_length > scsicmd->cmnd[4]) in aac_scsi_cmd()
3118 mode_buf_length = scsicmd->cmnd[4]; in aac_scsi_cmd()
3124 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_scsi_cmd()
3135 capacity = fsa_dev_ptr[cid].size - 1; in aac_scsi_cmd()
3137 capacity = (u32)-1; in aac_scsi_cmd()
3139 dprintk((KERN_DEBUG "MODE SENSE 10 byte command.\n")); in aac_scsi_cmd()
3141 /* Mode data length (MSB) */ in aac_scsi_cmd()
3143 /* Mode data length (LSB) */ in aac_scsi_cmd()
3144 mpd10.hd.data_length[1] = sizeof(mpd10.hd) - 1; in aac_scsi_cmd()
3145 /* Medium type - default */ in aac_scsi_cmd()
3147 /* Device-specific param, in aac_scsi_cmd()
3152 if (dev->raw_io_interface && ((aac_cache & 5) != 1)) in aac_scsi_cmd()
3156 if (scsicmd->cmnd[1] & 0x8) { in aac_scsi_cmd()
3187 if (((scsicmd->cmnd[2] & 0x3f) == 8) || in aac_scsi_cmd()
3188 ((scsicmd->cmnd[2] & 0x3f) == 0x3f)) { in aac_scsi_cmd()
3195 if (mode_buf_length > scsicmd->cmnd[8]) in aac_scsi_cmd()
3196 mode_buf_length = scsicmd->cmnd[8]; in aac_scsi_cmd()
3202 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_scsi_cmd()
3208 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, in aac_scsi_cmd()
3210 memset(&dev->fsa_dev[cid].sense_data, 0, in aac_scsi_cmd()
3212 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_scsi_cmd()
3218 if (scsicmd->cmnd[4]) in aac_scsi_cmd()
3223 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_scsi_cmd()
3227 * These commands are all No-Ops in aac_scsi_cmd()
3231 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_scsi_cmd()
3233 set_sense(&dev->fsa_dev[cid].sense_data, in aac_scsi_cmd()
3236 memcpy(scsicmd->sense_buffer, in aac_scsi_cmd()
3237 &dev->fsa_dev[cid].sense_data, in aac_scsi_cmd()
3239 sizeof(dev->fsa_dev[cid].sense_data), in aac_scsi_cmd()
3249 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_scsi_cmd()
3261 scsicmd->cmnd[0])); in aac_scsi_cmd()
3262 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | in aac_scsi_cmd()
3264 set_sense(&dev->fsa_dev[cid].sense_data, in aac_scsi_cmd()
3267 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, in aac_scsi_cmd()
3269 sizeof(dev->fsa_dev[cid].sense_data), in aac_scsi_cmd()
3275 scsicmd->scsi_done(scsicmd); in aac_scsi_cmd()
3284 fsa_dev_ptr = dev->fsa_dev; in query_disk()
3286 return -EBUSY; in query_disk()
3288 return -EFAULT; in query_disk()
3289 if (qd.cnum == -1) { in query_disk()
3290 if (qd.id < 0 || qd.id >= dev->maximum_num_containers) in query_disk()
3291 return -EINVAL; in query_disk()
3293 } else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1)) { in query_disk()
3294 if (qd.cnum < 0 || qd.cnum >= dev->maximum_num_containers) in query_disk()
3295 return -EINVAL; in query_disk()
3296 qd.instance = dev->scsi_host_ptr->host_no; in query_disk()
3301 else return -EINVAL; in query_disk()
3316 return -EFAULT; in query_disk()
3325 fsa_dev_ptr = dev->fsa_dev; in force_delete_disk()
3327 return -EBUSY; in force_delete_disk()
3330 return -EFAULT; in force_delete_disk()
3332 if (dd.cnum >= dev->maximum_num_containers) in force_delete_disk()
3333 return -EINVAL; in force_delete_disk()
3350 fsa_dev_ptr = dev->fsa_dev; in delete_disk()
3352 return -EBUSY; in delete_disk()
3355 return -EFAULT; in delete_disk()
3357 if (dd.cnum >= dev->maximum_num_containers) in delete_disk()
3358 return -EINVAL; in delete_disk()
3363 return -EBUSY; in delete_disk()
3386 return -ENOTTY; in aac_dev_ioctl()
3392 * @context: the context set in the fib - here it is scsi cmd
3411 scsicmd->sense_buffer[0] = '\0'; /* Initialize sense valid flag to false */ in aac_srb_callback()
3413 if (fibptr->flags & FIB_CONTEXT_FLAG_FASTRESP) { in aac_srb_callback()
3415 srbreply->srb_status = cpu_to_le32(SRB_STATUS_SUCCESS); in aac_srb_callback()
3416 srbreply->scsi_status = cpu_to_le32(SAM_STAT_GOOD); in aac_srb_callback()
3422 - le32_to_cpu(srbreply->data_xfer_length)); in aac_srb_callback()
3429 if (scsicmd->cmnd[0] == INQUIRY && !(scsicmd->cmnd[1] & 0x01) in aac_srb_callback()
3437 if (le32_to_cpu(srbreply->status) != ST_OK) { in aac_srb_callback()
3441 le32_to_cpu(srbreply->status)); in aac_srb_callback()
3442 len = min_t(u32, le32_to_cpu(srbreply->sense_data_size), in aac_srb_callback()
3444 scsicmd->result = DID_ERROR << 16 in aac_srb_callback()
3447 memcpy(scsicmd->sense_buffer, in aac_srb_callback()
3448 srbreply->sense_data, len); in aac_srb_callback()
3454 switch ((le32_to_cpu(srbreply->srb_status))&0x3f) { in aac_srb_callback()
3458 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
3461 switch (scsicmd->cmnd[0]) { in aac_srb_callback()
3470 if (le32_to_cpu(srbreply->data_xfer_length) in aac_srb_callback()
3471 < scsicmd->underflow) in aac_srb_callback()
3475 scsicmd->result = DID_ERROR << 16 in aac_srb_callback()
3479 scsicmd->result = DID_OK << 16 in aac_srb_callback()
3483 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
3488 scsicmd->result = DID_ABORT << 16 | ABORT << 8; in aac_srb_callback()
3492 * Not sure about this one - but assuming the in aac_srb_callback()
3495 scsicmd->result = DID_ERROR << 16 | ABORT << 8; in aac_srb_callback()
3498 scsicmd->result = DID_PARITY << 16 in aac_srb_callback()
3506 scsicmd->result = DID_NO_CONNECT << 16 in aac_srb_callback()
3512 scsicmd->result = DID_TIME_OUT << 16 in aac_srb_callback()
3517 scsicmd->result = DID_BUS_BUSY << 16 in aac_srb_callback()
3522 scsicmd->result = DID_RESET << 16 in aac_srb_callback()
3527 scsicmd->result = DID_ERROR << 16 in aac_srb_callback()
3546 pr_info("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x -scsi status 0x%x\n", in aac_srb_callback()
3547 le32_to_cpu(srbreply->srb_status) & 0x3F, in aac_srb_callback()
3549 le32_to_cpu(srbreply->srb_status) & 0x3F), in aac_srb_callback()
3550 scsicmd->cmnd[0], in aac_srb_callback()
3551 le32_to_cpu(srbreply->scsi_status)); in aac_srb_callback()
3560 if ((scsicmd->cmnd[0] == ATA_12) in aac_srb_callback()
3561 || (scsicmd->cmnd[0] == ATA_16)) { in aac_srb_callback()
3563 if (scsicmd->cmnd[2] & (0x01 << 5)) { in aac_srb_callback()
3564 scsicmd->result = DID_OK << 16 in aac_srb_callback()
3568 scsicmd->result = DID_ERROR << 16 in aac_srb_callback()
3573 scsicmd->result = DID_ERROR << 16 in aac_srb_callback()
3578 if (le32_to_cpu(srbreply->scsi_status) in aac_srb_callback()
3582 scsicmd->result |= SAM_STAT_CHECK_CONDITION; in aac_srb_callback()
3583 len = min_t(u32, le32_to_cpu(srbreply->sense_data_size), in aac_srb_callback()
3587 le32_to_cpu(srbreply->status), len); in aac_srb_callback()
3589 memcpy(scsicmd->sense_buffer, in aac_srb_callback()
3590 srbreply->sense_data, len); in aac_srb_callback()
3596 scsicmd->result |= le32_to_cpu(srbreply->scsi_status); in aac_srb_callback()
3599 scsicmd->scsi_done(scsicmd); in aac_srb_callback()
3606 scsicmd->result = err->status; in hba_resp_task_complete()
3608 scsi_set_resid(scsicmd, le32_to_cpu(err->residual_count)); in hba_resp_task_complete()
3610 switch (err->status) { in hba_resp_task_complete()
3612 scsicmd->result |= DID_OK << 16 | COMMAND_COMPLETE << 8; in hba_resp_task_complete()
3618 len = min_t(u8, err->sense_response_data_len, in hba_resp_task_complete()
3621 memcpy(scsicmd->sense_buffer, in hba_resp_task_complete()
3622 err->sense_response_buf, len); in hba_resp_task_complete()
3623 scsicmd->result |= DID_OK << 16 | COMMAND_COMPLETE << 8; in hba_resp_task_complete()
3627 scsicmd->result |= DID_BUS_BUSY << 16 | COMMAND_COMPLETE << 8; in hba_resp_task_complete()
3630 scsicmd->result |= DID_ABORT << 16 | ABORT << 8; in hba_resp_task_complete()
3635 scsicmd->result |= DID_ERROR << 16 | COMMAND_COMPLETE << 8; in hba_resp_task_complete()
3644 switch (err->status) { in hba_resp_task_failure()
3651 if (dev->hba_map[bus][cid].devtype == AAC_DEVTYPE_NATIVE_RAW) { in hba_resp_task_failure()
3652 dev->hba_map[bus][cid].devtype = AAC_DEVTYPE_ARC_RAW; in hba_resp_task_failure()
3653 dev->hba_map[bus][cid].rmw_nexus = 0xffffffff; in hba_resp_task_failure()
3655 scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8; in hba_resp_task_failure()
3660 scsicmd->result = DID_OK << 16 | in hba_resp_task_failure()
3664 scsicmd->result = DID_ABORT << 16 | ABORT << 8; in hba_resp_task_failure()
3667 scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8; in hba_resp_task_failure()
3671 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; in hba_resp_task_failure()
3675 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8; in hba_resp_task_failure()
3682 * @context: the context set in the fib - here it is scsi cmd
3693 &((struct aac_native_hba *)fibptr->hw_fib_va)->resp.err; in aac_hba_callback()
3701 dev = fibptr->dev; in aac_hba_callback()
3703 if (!(fibptr->flags & FIB_CONTEXT_FLAG_NATIVE_HBA_TMF)) in aac_hba_callback()
3706 if (fibptr->flags & FIB_CONTEXT_FLAG_FASTRESP) { in aac_hba_callback()
3708 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; in aac_hba_callback()
3712 switch (err->service_response) { in aac_hba_callback()
3720 scsicmd->result = DID_ERROR << 16 | MESSAGE_REJECT << 8; in aac_hba_callback()
3723 scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8; in aac_hba_callback()
3727 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; in aac_hba_callback()
3730 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8; in aac_hba_callback()
3737 if (fibptr->flags & FIB_CONTEXT_FLAG_NATIVE_HBA_TMF) in aac_hba_callback()
3738 scsicmd->SCp.sent_command = 1; in aac_hba_callback()
3740 scsicmd->scsi_done(scsicmd); in aac_hba_callback()
3756 dev = (struct aac_dev *)scsicmd->device->host->hostdata; in aac_send_srb_fib()
3757 if (scmd_id(scsicmd) >= dev->maximum_num_physicals || in aac_send_srb_fib()
3758 scsicmd->device->lun > 7) { in aac_send_srb_fib()
3759 scsicmd->result = DID_NO_CONNECT << 16; in aac_send_srb_fib()
3760 scsicmd->scsi_done(scsicmd); in aac_send_srb_fib()
3768 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; in aac_send_srb_fib()
3774 if (status == -EINPROGRESS) in aac_send_srb_fib()
3781 return -1; in aac_send_srb_fib()
3797 dev = shost_priv(scsicmd->device->host); in aac_send_hba_fib()
3798 if (scmd_id(scsicmd) >= dev->maximum_num_physicals || in aac_send_hba_fib()
3799 scsicmd->device->lun > AAC_MAX_LUN - 1) { in aac_send_hba_fib()
3800 scsicmd->result = DID_NO_CONNECT << 16; in aac_send_hba_fib()
3801 scsicmd->scsi_done(scsicmd); in aac_send_hba_fib()
3810 return -1; in aac_send_hba_fib()
3812 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; in aac_send_hba_fib()
3818 if (status == -EINPROGRESS) in aac_send_hba_fib()
3826 return -1; in aac_send_hba_fib()
3838 psg->count = 0; in aac_build_sg()
3839 psg->sg[0].addr = 0; in aac_build_sg()
3840 psg->sg[0].count = 0; in aac_build_sg()
3846 psg->count = cpu_to_le32(nseg); in aac_build_sg()
3849 psg->sg[i].addr = cpu_to_le32(sg_dma_address(sg)); in aac_build_sg()
3850 psg->sg[i].count = cpu_to_le32(sg_dma_len(sg)); in aac_build_sg()
3855 u32 temp = le32_to_cpu(psg->sg[i-1].count) - in aac_build_sg()
3856 (byte_count - scsi_bufflen(scsicmd)); in aac_build_sg()
3857 psg->sg[i-1].count = cpu_to_le32(temp); in aac_build_sg()
3861 if (scsicmd->underflow && (byte_count < scsicmd->underflow)) { in aac_build_sg()
3863 byte_count, scsicmd->underflow); in aac_build_sg()
3879 psg->count = 0; in aac_build_sg64()
3880 psg->sg[0].addr[0] = 0; in aac_build_sg64()
3881 psg->sg[0].addr[1] = 0; in aac_build_sg64()
3882 psg->sg[0].count = 0; in aac_build_sg64()
3891 psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff); in aac_build_sg64()
3892 psg->sg[i].addr[1] = cpu_to_le32(addr>>32); in aac_build_sg64()
3893 psg->sg[i].count = cpu_to_le32(count); in aac_build_sg64()
3896 psg->count = cpu_to_le32(nseg); in aac_build_sg64()
3899 u32 temp = le32_to_cpu(psg->sg[i-1].count) - in aac_build_sg64()
3900 (byte_count - scsi_bufflen(scsicmd)); in aac_build_sg64()
3901 psg->sg[i-1].count = cpu_to_le32(temp); in aac_build_sg64()
3905 if (scsicmd->underflow && (byte_count < scsicmd->underflow)) { in aac_build_sg64()
3907 byte_count, scsicmd->underflow); in aac_build_sg64()
3921 psg->count = 0; in aac_build_sgraw()
3922 psg->sg[0].next = 0; in aac_build_sgraw()
3923 psg->sg[0].prev = 0; in aac_build_sgraw()
3924 psg->sg[0].addr[0] = 0; in aac_build_sgraw()
3925 psg->sg[0].addr[1] = 0; in aac_build_sgraw()
3926 psg->sg[0].count = 0; in aac_build_sgraw()
3927 psg->sg[0].flags = 0; in aac_build_sgraw()
3936 psg->sg[i].next = 0; in aac_build_sgraw()
3937 psg->sg[i].prev = 0; in aac_build_sgraw()
3938 psg->sg[i].addr[1] = cpu_to_le32((u32)(addr>>32)); in aac_build_sgraw()
3939 psg->sg[i].addr[0] = cpu_to_le32((u32)(addr & 0xffffffff)); in aac_build_sgraw()
3940 psg->sg[i].count = cpu_to_le32(count); in aac_build_sgraw()
3941 psg->sg[i].flags = 0; in aac_build_sgraw()
3944 psg->count = cpu_to_le32(nseg); in aac_build_sgraw()
3947 u32 temp = le32_to_cpu(psg->sg[i-1].count) - in aac_build_sgraw()
3948 (byte_count - scsi_bufflen(scsicmd)); in aac_build_sgraw()
3949 psg->sg[i-1].count = cpu_to_le32(temp); in aac_build_sgraw()
3953 if (scsicmd->underflow && (byte_count < scsicmd->underflow)) { in aac_build_sgraw()
3955 byte_count, scsicmd->underflow); in aac_build_sgraw()
3979 rio2->sge[i].addrHigh = cpu_to_le32((u32)(addr>>32)); in aac_build_sgraw2()
3980 rio2->sge[i].addrLow = cpu_to_le32((u32)(addr & 0xffffffff)); in aac_build_sgraw2()
3982 rio2->sge[i].length = cur_size; in aac_build_sgraw2()
3983 rio2->sge[i].flags = 0; in aac_build_sgraw2()
3986 rio2->sgeFirstSize = cur_size; in aac_build_sgraw2()
3988 rio2->sgeNominalSize = cur_size; in aac_build_sgraw2()
3990 } else if ((i+1) < nseg && cur_size != rio2->sgeNominalSize) { in aac_build_sgraw2()
4000 u32 temp = le32_to_cpu(rio2->sge[i-1].length) - in aac_build_sgraw2()
4001 (byte_count - scsi_bufflen(scsicmd)); in aac_build_sgraw2()
4002 rio2->sge[i-1].length = cpu_to_le32(temp); in aac_build_sgraw2()
4006 rio2->sgeCnt = cpu_to_le32(nseg); in aac_build_sgraw2()
4007 rio2->flags |= cpu_to_le16(RIO2_SG_FORMAT_IEEE1212); in aac_build_sgraw2()
4011 for (i = min_size / PAGE_SIZE; i >= 1; --i) { in aac_build_sgraw2()
4014 for (j = 1; j < nseg - 1; ++j) { in aac_build_sgraw2()
4015 if (rio2->sge[j].length % (i*PAGE_SIZE)) { in aac_build_sgraw2()
4019 nseg_new += (rio2->sge[j].length / (i*PAGE_SIZE)); in aac_build_sgraw2()
4031 rio2->flags |= cpu_to_le16(RIO2_SGL_CONFORMANT); in aac_build_sgraw2()
4034 if (scsicmd->underflow && (byte_count < scsicmd->underflow)) { in aac_build_sgraw2()
4036 byte_count, scsicmd->underflow); in aac_build_sgraw2()
4053 return -ENOMEM; in aac_convert_sgraw2()
4055 for (i = 1, pos = 1; i < nseg-1; ++i) { in aac_convert_sgraw2()
4056 for (j = 0; j < rio2->sge[i].length / (pages * PAGE_SIZE); ++j) { in aac_convert_sgraw2()
4057 addr_low = rio2->sge[i].addrLow + j * pages * PAGE_SIZE; in aac_convert_sgraw2()
4059 sge[pos].addrHigh = rio2->sge[i].addrHigh; in aac_convert_sgraw2()
4060 if (addr_low < rio2->sge[i].addrLow) in aac_convert_sgraw2()
4067 sge[pos] = rio2->sge[nseg-1]; in aac_convert_sgraw2()
4068 memcpy(&rio2->sge[1], &sge[1], (nseg_new-1)*sizeof(struct sge_ieee1212)); in aac_convert_sgraw2()
4071 rio2->sgeCnt = cpu_to_le32(nseg_new); in aac_convert_sgraw2()
4072 rio2->flags |= cpu_to_le16(RIO2_SGL_CONFORMANT); in aac_convert_sgraw2()
4073 rio2->sgeNominalSize = pages * PAGE_SIZE; in aac_convert_sgraw2()
4096 sge = &hbacmd->sge[2]; in aac_build_sghba()
4098 sge = &hbacmd->sge[0]; in aac_build_sghba()
4105 sge->addr_hi = cpu_to_le32((u32)(addr>>32)); in aac_build_sghba()
4106 sge->addr_lo = cpu_to_le32((u32)(addr & 0xffffffff)); in aac_build_sghba()
4108 sge->len = cur_size; in aac_build_sghba()
4109 sge->flags = 0; in aac_build_sghba()
4114 sge--; in aac_build_sghba()
4119 temp = le32_to_cpu(sge->len) - byte_count in aac_build_sghba()
4120 - scsi_bufflen(scsicmd); in aac_build_sghba()
4121 sge->len = cpu_to_le32(temp); in aac_build_sghba()
4126 hbacmd->emb_data_desc_count = cpu_to_le32(nseg); in aac_build_sghba()
4127 sge->flags = cpu_to_le32(0x40000000); in aac_build_sghba()
4130 hbacmd->sge[0].flags = cpu_to_le32(0x80000000); in aac_build_sghba()
4131 hbacmd->emb_data_desc_count = (u8)cpu_to_le32(1); in aac_build_sghba()
4132 hbacmd->sge[0].addr_hi = (u32)cpu_to_le32(sg_address >> 32); in aac_build_sghba()
4133 hbacmd->sge[0].addr_lo = in aac_build_sghba()
4138 if (scsicmd->underflow && (byte_count < scsicmd->underflow)) { in aac_build_sghba()
4140 byte_count, scsicmd->underflow); in aac_build_sghba()