Lines Matching refs:scsicmd

221 static unsigned long aac_build_sg(Scsi_Cmnd* scsicmd, struct sgmap* sgmap);
222 static unsigned long aac_build_sg64(Scsi_Cmnd* scsicmd, struct sgmap64* psg);
223 static int aac_send_srb_fib(Scsi_Cmnd* scsicmd);
538 static void aac_io_done(Scsi_Cmnd * scsicmd) in aac_io_done() argument
542 scsicmd->scsi_done(scsicmd); in aac_io_done()
546 static void __aac_io_done(Scsi_Cmnd * scsicmd) in __aac_io_done() argument
548 scsicmd->scsi_done(scsicmd); in __aac_io_done()
652 Scsi_Cmnd *scsicmd; in read_callback() local
656 scsicmd = (Scsi_Cmnd *) context; in read_callback()
658 dev = (struct aac_dev *)scsicmd->host->hostdata; in read_callback()
659 cid =TARGET_LUN_TO_CONTAINER(scsicmd->target, scsicmd->lun); in read_callback()
661 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; in read_callback()
667 if(scsicmd->use_sg) in read_callback()
669 (struct scatterlist *)scsicmd->buffer, in read_callback()
670 scsicmd->use_sg, in read_callback()
671 scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); in read_callback()
672 else if(scsicmd->request_bufflen) in read_callback()
673 pci_unmap_single(dev->pdev, (dma_addr_t)(unsigned long)scsicmd->SCp.ptr, in read_callback()
674 scsicmd->request_bufflen, in read_callback()
675 scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); in read_callback()
678 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; in read_callback()
681 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | CHECK_CONDITION; in read_callback()
691 aac_io_done(scsicmd); in read_callback()
698 Scsi_Cmnd *scsicmd; in write_callback() local
702 scsicmd = (Scsi_Cmnd *) context; in write_callback()
703 dev = (struct aac_dev *)scsicmd->host->hostdata; in write_callback()
704 cid = TARGET_LUN_TO_CONTAINER(scsicmd->target, scsicmd->lun); in write_callback()
706 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; in write_callback()
711 if(scsicmd->use_sg) in write_callback()
713 (struct scatterlist *)scsicmd->buffer, in write_callback()
714 scsicmd->use_sg, in write_callback()
715 scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); in write_callback()
716 else if(scsicmd->request_bufflen) in write_callback()
717 pci_unmap_single(dev->pdev, (dma_addr_t)(unsigned long)scsicmd->SCp.ptr, in write_callback()
718 scsicmd->request_bufflen, in write_callback()
719 scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); in write_callback()
723 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; in write_callback()
726 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | CHECK_CONDITION; in write_callback()
736 aac_io_done(scsicmd); in write_callback()
739 int aac_read(Scsi_Cmnd * scsicmd, int cid) in aac_read() argument
749 dev = (struct aac_dev *)scsicmd->host->hostdata; in aac_read()
753 if (scsicmd->cmnd[0] == SS_READ) /* 6 byte command */ in aac_read()
757 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; in aac_read()
758 count = scsicmd->cmnd[4]; in aac_read()
765 …lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmn… in aac_read()
766 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; in aac_read()
773 scsicmd->result = DID_ERROR << 16; in aac_read()
774 aac_io_done(scsicmd); in aac_read()
790 aac_build_sg64(scsicmd, &readcmd->sg); in aac_read()
803 (void *) scsicmd); in aac_read()
815 aac_build_sg(scsicmd, &readcmd->sg); in aac_read()
828 (void *) scsicmd); in aac_read()
842 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | QUEUE_FULL; in aac_read()
843 aac_io_done(scsicmd); in aac_read()
849 static int aac_write(Scsi_Cmnd * scsicmd, int cid) in aac_write() argument
858 dev = (struct aac_dev *)scsicmd->host->hostdata; in aac_write()
862 if (scsicmd->cmnd[0] == SS_WRITE) /* 6 byte command */ in aac_write()
864 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; in aac_write()
865 count = scsicmd->cmnd[4]; in aac_write()
870 …lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmn… in aac_write()
871 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; in aac_write()
878 scsicmd->result = DID_ERROR << 16; in aac_write()
879 aac_io_done(scsicmd); in aac_write()
895 aac_build_sg64(scsicmd, &writecmd->sg); in aac_write()
908 (void *) scsicmd); in aac_write()
923 aac_build_sg(scsicmd, &writecmd->sg); in aac_write()
936 (void *) scsicmd); in aac_write()
949 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | QUEUE_FULL; in aac_write()
950 aac_io_done(scsicmd); in aac_write()
967 int aac_scsi_cmd(Scsi_Cmnd * scsicmd) in aac_scsi_cmd() argument
973 struct aac_dev *dev = (struct aac_dev *)scsicmd->host->hostdata; in aac_scsi_cmd()
977 fsa_dev_ptr = fsa_dev[scsicmd->host->unique_id]; in aac_scsi_cmd()
984 if (scsicmd->target != scsicmd->host->this_id) { in aac_scsi_cmd()
985 if ((scsicmd->channel == 0) ){ in aac_scsi_cmd()
986 if( (scsicmd->target >= AAC_MAX_TARGET) || (scsicmd->lun != 0)){ in aac_scsi_cmd()
987 scsicmd->result = DID_NO_CONNECT << 16; in aac_scsi_cmd()
988 __aac_io_done(scsicmd); in aac_scsi_cmd()
991 cid = TARGET_LUN_TO_CONTAINER(scsicmd->target, scsicmd->lun); in aac_scsi_cmd()
998 switch (scsicmd->cmnd[0]) { in aac_scsi_cmd()
1006 scsicmd->result = DID_NO_CONNECT << 16; in aac_scsi_cmd()
1007 __aac_io_done(scsicmd); in aac_scsi_cmd()
1019 scsicmd->result = DID_BAD_TARGET << 16; in aac_scsi_cmd()
1020 __aac_io_done(scsicmd); in aac_scsi_cmd()
1025 return aac_send_srb_fib(scsicmd); in aac_scsi_cmd()
1027 scsicmd->result = DID_NO_CONNECT << 16; in aac_scsi_cmd()
1028 __aac_io_done(scsicmd); in aac_scsi_cmd()
1036 else if ((scsicmd->cmnd[0] != SS_INQUIR) && /* only INQUIRY & TUR cmnd supported for controller */ in aac_scsi_cmd()
1037 (scsicmd->cmnd[0] != SS_TEST)) in aac_scsi_cmd()
1039 …_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0])); in aac_scsi_cmd()
1040 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | CHECK_CONDITION; in aac_scsi_cmd()
1045 __aac_io_done(scsicmd); in aac_scsi_cmd()
1051 switch (scsicmd->cmnd[0]) { in aac_scsi_cmd()
1056 dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", scsicmd->target)); in aac_scsi_cmd()
1057 inq_data_ptr = (struct inquiry_data *)scsicmd->request_buffer; in aac_scsi_cmd()
1069 if (scsicmd->target == scsicmd->host->this_id) { in aac_scsi_cmd()
1077 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; in aac_scsi_cmd()
1078 __aac_io_done(scsicmd); in aac_scsi_cmd()
1088 cp = scsicmd->request_buffer; in aac_scsi_cmd()
1098 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; in aac_scsi_cmd()
1099 __aac_io_done(scsicmd); in aac_scsi_cmd()
1109 mode_buf = scsicmd->request_buffer; in aac_scsi_cmd()
1119 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; in aac_scsi_cmd()
1120 __aac_io_done(scsicmd); in aac_scsi_cmd()
1126 memcpy(scsicmd->sense_buffer, &sense_data[cid], sizeof (struct sense_data)); in aac_scsi_cmd()
1128 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; in aac_scsi_cmd()
1129 __aac_io_done(scsicmd); in aac_scsi_cmd()
1134 if (scsicmd->cmnd[4]) in aac_scsi_cmd()
1139 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; in aac_scsi_cmd()
1140 __aac_io_done(scsicmd); in aac_scsi_cmd()
1152 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | GOOD; in aac_scsi_cmd()
1153 __aac_io_done(scsicmd); in aac_scsi_cmd()
1157 switch (scsicmd->cmnd[0]) in aac_scsi_cmd()
1168 fsa_dev_ptr->devno[cid] = DEVICE_NR(scsicmd->request.rq_dev); in aac_scsi_cmd()
1169 ret = aac_read(scsicmd, cid); in aac_scsi_cmd()
1176 ret = aac_write(scsicmd, cid); in aac_scsi_cmd()
1183 printk(KERN_WARNING "Unhandled SCSI Command: 0x%x.\n", scsicmd->cmnd[0]); in aac_scsi_cmd()
1184 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | CHECK_CONDITION; in aac_scsi_cmd()
1188 __aac_io_done(scsicmd); in aac_scsi_cmd()
1332 Scsi_Cmnd *scsicmd; in aac_srb_callback() local
1334 scsicmd = (Scsi_Cmnd *) context; in aac_srb_callback()
1335 dev = (struct aac_dev *)scsicmd->host->hostdata; in aac_srb_callback()
1342 scsicmd->sense_buffer[0] = '\0'; // initialize sense valid flag to false in aac_srb_callback()
1344 scsicmd->resid = scsicmd->request_bufflen - srbreply->data_xfer_length; in aac_srb_callback()
1346 if(scsicmd->use_sg) in aac_srb_callback()
1348 (struct scatterlist *)scsicmd->buffer, in aac_srb_callback()
1349 scsicmd->use_sg, in aac_srb_callback()
1350 scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); in aac_srb_callback()
1351 else if(scsicmd->request_bufflen) in aac_srb_callback()
1352 pci_unmap_single(dev->pdev, (ulong)scsicmd->SCp.ptr, scsicmd->request_bufflen, in aac_srb_callback()
1353 scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); in aac_srb_callback()
1362 len = (srbreply->sense_data_size > sizeof(scsicmd->sense_buffer))? in aac_srb_callback()
1363 sizeof(scsicmd->sense_buffer):srbreply->sense_data_size; in aac_srb_callback()
1364 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8 | CHECK_CONDITION; in aac_srb_callback()
1365 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len); in aac_srb_callback()
1375 if(scsicmd->cmnd[0] == INQUIRY ){ in aac_srb_callback()
1382 b = (*(u8*)scsicmd->buffer)&0x1f; in aac_srb_callback()
1383 b1 = ((u8*)scsicmd->buffer)[1]; in aac_srb_callback()
1386 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
1391 } else if((dev->raid_scsi_mode)&&(scsicmd->channel == 2)){ in aac_srb_callback()
1392 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
1394 scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
1397 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
1401 switch(scsicmd->cmnd[0]){ in aac_srb_callback()
1408 if(le32_to_cpu(srbreply->data_xfer_length) < scsicmd->underflow ) { in aac_srb_callback()
1413 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
1421 b = (*(u8*)scsicmd->buffer)&0x0f; in aac_srb_callback()
1422 b1 = ((u8*)scsicmd->buffer)[1]; in aac_srb_callback()
1425 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
1430 } else if((dev->raid_scsi_mode)&&(scsicmd->channel == 2)){ in aac_srb_callback()
1431 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
1433 scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
1438 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
1443 scsicmd->result = DID_ABORT << 16 | ABORT << 8; in aac_srb_callback()
1447 scsicmd->result = DID_ERROR << 16 | ABORT << 8; in aac_srb_callback()
1450 scsicmd->result = DID_PARITY << 16 | MSG_PARITY_ERROR << 8; in aac_srb_callback()
1457 scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
1462 scsicmd->result = DID_TIME_OUT << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
1466 scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
1470 scsicmd->result = DID_RESET << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
1474 scsicmd->result = DID_ERROR << 16 | MESSAGE_REJECT << 8; in aac_srb_callback()
1491 …b_status&0x3f),aac_get_status_string(le32_to_cpu(srbreply->srb_status)), scsicmd->cmnd[0], le32_to… in aac_srb_callback()
1492 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8; in aac_srb_callback()
1497 scsicmd->result |= CHECK_CONDITION; in aac_srb_callback()
1498 len = (srbreply->sense_data_size > sizeof(scsicmd->sense_buffer))? in aac_srb_callback()
1499 sizeof(scsicmd->sense_buffer):srbreply->sense_data_size; in aac_srb_callback()
1501 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len); in aac_srb_callback()
1506 scsicmd->result |= le32_to_cpu(srbreply->scsi_status); in aac_srb_callback()
1510 aac_io_done(scsicmd); in aac_srb_callback()
1522 static int aac_send_srb_fib(Scsi_Cmnd* scsicmd) in aac_send_srb_fib() argument
1532 if( scsicmd->target > 15 || scsicmd->lun > 7) { in aac_send_srb_fib()
1533 scsicmd->result = DID_NO_CONNECT << 16; in aac_send_srb_fib()
1534 __aac_io_done(scsicmd); in aac_send_srb_fib()
1538 dev = (struct aac_dev *)scsicmd->host->hostdata; in aac_send_srb_fib()
1539 switch(scsicmd->sc_data_direction){ in aac_send_srb_fib()
1560 scsicmd->result = DID_ERROR << 16; in aac_send_srb_fib()
1561 __aac_io_done(scsicmd); in aac_send_srb_fib()
1568 srbcmd->channel = cpu_to_le32(aac_logical_to_phys(scsicmd->channel)); in aac_send_srb_fib()
1569 srbcmd->target = cpu_to_le32(scsicmd->target); in aac_send_srb_fib()
1570 srbcmd->lun = cpu_to_le32(scsicmd->lun); in aac_send_srb_fib()
1572 timeout = (scsicmd->timeout-jiffies)/HZ; in aac_send_srb_fib()
1578 srbcmd->cdb_size = cpu_to_le32(scsicmd->cmd_len); in aac_send_srb_fib()
1581 aac_build_sg64(scsicmd, (struct sgmap64*) &srbcmd->sg); in aac_send_srb_fib()
1582 srbcmd->count = cpu_to_le32(scsicmd->request_bufflen); in aac_send_srb_fib()
1585 memcpy(srbcmd->cdb, scsicmd->cmnd, scsicmd->cmd_len); in aac_send_srb_fib()
1595 (fib_callback) aac_srb_callback, (void *) scsicmd); in aac_send_srb_fib()
1597 aac_build_sg(scsicmd, (struct sgmap*)&srbcmd->sg); in aac_send_srb_fib()
1598 srbcmd->count = cpu_to_le32(scsicmd->request_bufflen); in aac_send_srb_fib()
1601 memcpy(srbcmd->cdb, scsicmd->cmnd, scsicmd->cmd_len); in aac_send_srb_fib()
1611 (fib_callback) aac_srb_callback, (void *) scsicmd); in aac_send_srb_fib()
1624 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | QUEUE_FULL; in aac_send_srb_fib()
1625 __aac_io_done(scsicmd); in aac_send_srb_fib()
1633 static unsigned long aac_build_sg(Scsi_Cmnd* scsicmd, struct sgmap* psg) in aac_build_sg() argument
1638 dev = (struct aac_dev *)scsicmd->host->hostdata; in aac_build_sg()
1643 if (scsicmd->use_sg) { in aac_build_sg()
1647 sg = (struct scatterlist *) scsicmd->request_buffer; in aac_build_sg()
1649 sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg, in aac_build_sg()
1650 scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); in aac_build_sg()
1662 if(byte_count > scsicmd->request_bufflen){ in aac_build_sg()
1663 psg->sg[i-1].count -= (byte_count - scsicmd->request_bufflen); in aac_build_sg()
1664 byte_count = scsicmd->request_bufflen; in aac_build_sg()
1667 if(scsicmd->underflow && (byte_count < scsicmd->underflow)){ in aac_build_sg()
1669 byte_count, scsicmd->underflow); in aac_build_sg()
1672 else if(scsicmd->request_bufflen) { in aac_build_sg()
1675 scsicmd->request_buffer, in aac_build_sg()
1676 scsicmd->request_bufflen, in aac_build_sg()
1677 scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); in aac_build_sg()
1680 psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen); in aac_build_sg()
1682 scsicmd->SCp.ptr = (void *)addr; in aac_build_sg()
1683 byte_count = scsicmd->request_bufflen; in aac_build_sg()
1689 static unsigned long aac_build_sg64(Scsi_Cmnd* scsicmd, struct sgmap64* psg) in aac_build_sg64() argument
1695 dev = (struct aac_dev *)scsicmd->host->hostdata; in aac_build_sg64()
1701 if (scsicmd->use_sg) { in aac_build_sg64()
1705 sg = (struct scatterlist *) scsicmd->request_buffer; in aac_build_sg64()
1707 sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg, in aac_build_sg64()
1708 scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); in aac_build_sg64()
1722 if(byte_count > scsicmd->request_bufflen){ in aac_build_sg64()
1723 psg->sg[i-1].count -= (byte_count - scsicmd->request_bufflen); in aac_build_sg64()
1724 byte_count = scsicmd->request_bufflen; in aac_build_sg64()
1727 if(scsicmd->underflow && (byte_count < scsicmd->underflow)){ in aac_build_sg64()
1729 byte_count, scsicmd->underflow); in aac_build_sg64()
1732 else if(scsicmd->request_bufflen) { in aac_build_sg64()
1735 scsicmd->request_buffer, in aac_build_sg64()
1736 scsicmd->request_bufflen, in aac_build_sg64()
1737 scsi_to_pci_dma_dir(scsicmd->sc_data_direction)); in aac_build_sg64()
1742 psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen); in aac_build_sg64()
1744 scsicmd->SCp.ptr = (void *)addr; in aac_build_sg64()
1745 byte_count = scsicmd->request_bufflen; in aac_build_sg64()