Lines Matching full:scb

147 static void initio_select_atn(struct initio_host * host, struct scsi_ctrl_blk * scb);
148 static void initio_select_atn3(struct initio_host * host, struct scsi_ctrl_blk * scb);
149 static void initio_select_atn_stop(struct initio_host * host, struct scsi_ctrl_blk * scb);
648 * initio_alloc_scb - Allocate an SCB
651 * Walk the SCB list for the controller and allocate a free SCB if
656 struct scsi_ctrl_blk *scb; in initio_alloc_scb() local
660 if ((scb = host->first_avail) != NULL) { in initio_alloc_scb()
662 printk("find scb at %p\n", scb); in initio_alloc_scb()
664 if ((host->first_avail = scb->next) == NULL) in initio_alloc_scb()
666 scb->next = NULL; in initio_alloc_scb()
667 scb->status = SCB_RENT; in initio_alloc_scb()
670 return scb; in initio_alloc_scb()
674 * initio_release_scb - Release an SCB
675 * @host: InitIO host that owns the SCB
676 * @cmnd: SCB command block being returned
678 * Return an allocated SCB to the host free list
686 printk("Release SCB %p; ", cmnd); in initio_release_scb()
707 printk("Append pend SCB %p; ", scbp); in initio_append_pend_scb()
725 printk("Push pend SCB %p; ", scbp); in initio_push_pend_scb()
763 static void initio_unlink_pend_scb(struct initio_host * host, struct scsi_ctrl_blk * scb) in initio_unlink_pend_scb() argument
768 printk("unlink pend SCB %p; ", scb); in initio_unlink_pend_scb()
773 if (scb == tmp) { /* Unlink this SCB */ in initio_unlink_pend_scb()
794 printk("append busy SCB %p; ", scbp); in initio_append_busy_scb()
827 printk("Pop busy SCB %p; ", tmp); in initio_pop_busy_scb()
833 static void initio_unlink_busy_scb(struct initio_host * host, struct scsi_ctrl_blk * scb) in initio_unlink_busy_scb() argument
838 printk("unlink busy SCB %p; ", scb); in initio_unlink_busy_scb()
843 if (scb == tmp) { /* Unlink this SCB */ in initio_unlink_busy_scb()
874 if (scbp_tarlun == tarlun) { /* Unlink this SCB */ in initio_find_busy_scb()
880 printk("find busy SCB %p; ", tmp); in initio_find_busy_scb()
888 printk("append done SCB %p; ", scbp); in initio_append_done_scb()
912 printk("find done SCB %p; ",tmp); in initio_find_done_scb()
1002 struct scsi_ctrl_blk *scb; in initio_bad_seq() local
1006 if ((scb = host->active) != NULL) { in initio_bad_seq()
1007 initio_unlink_busy_scb(host, scb); in initio_bad_seq()
1008 scb->hastat = HOST_BAD_PHAS; in initio_bad_seq()
1009 scb->tastat = 0; in initio_bad_seq()
1010 initio_append_done_scb(host, scb); in initio_bad_seq()
1019 static void initio_exec_scb(struct initio_host * host, struct scsi_ctrl_blk * scb) in initio_exec_scb() argument
1023 scb->mode = 0; in initio_exec_scb()
1025 scb->sgidx = 0; in initio_exec_scb()
1026 scb->sgmax = scb->sglen; in initio_exec_scb()
1030 initio_append_pend_scb(host, scb); /* Append this SCB to Pending queue */ in initio_exec_scb()
1070 struct scsi_ctrl_blk *scb; in tulip_main() local
1076 while ((scb = initio_find_done_scb(host)) != NULL) { /* find done entry */ in tulip_main()
1077 if (scb->tastat == INI_QUEUE_FULL) { in tulip_main()
1078 host->max_tags[scb->target] = in tulip_main()
1079 host->act_tags[scb->target] - 1; in tulip_main()
1080 scb->tastat = 0; in tulip_main()
1081 initio_append_pend_scb(host, scb); in tulip_main()
1084 if (!(scb->mode & SCM_RSENS)) { /* not in auto req. sense mode */ in tulip_main()
1085 if (scb->tastat == 2) { in tulip_main()
1089 if (scb->flags & SCF_SENSE) { in tulip_main()
1091 len = scb->senselen; in tulip_main()
1094 scb->buflen = scb->senselen; in tulip_main()
1095 scb->bufptr = scb->senseptr; in tulip_main()
1096 scb->flags &= ~(SCF_SG | SCF_DIR); /* for xfer_data_in */ in tulip_main()
1099 scb->mode = SCM_RSENS; in tulip_main()
1100 scb->ident &= 0xBF; /* Disable Disconnect */ in tulip_main()
1101 scb->tagmsg = 0; in tulip_main()
1102 scb->tastat = 0; in tulip_main()
1103 scb->cdblen = 6; in tulip_main()
1104 scb->cdb[0] = SCSICMD_RequestSense; in tulip_main()
1105 scb->cdb[1] = 0; in tulip_main()
1106 scb->cdb[2] = 0; in tulip_main()
1107 scb->cdb[3] = 0; in tulip_main()
1108 scb->cdb[4] = len; in tulip_main()
1109 scb->cdb[5] = 0; in tulip_main()
1110 initio_push_pend_scb(host, scb); in tulip_main()
1116 if (scb->tastat == 2) { /* check contition status again after sending in tulip_main()
1118 scb->hastat = HOST_BAD_PHAS; in tulip_main()
1120 scb->tastat = 2; in tulip_main()
1122 scb->flags |= SCF_DONE; in tulip_main()
1123 if (scb->flags & SCF_POST) { in tulip_main()
1125 (*scb->post) ((u8 *) host, (u8 *) scb); in tulip_main()
1133 /* Check pending SCB */ in tulip_main()
1142 struct scsi_ctrl_blk *scb; in tulip_scsi() local
1176 if ((scb = initio_find_first_pend_scb(host)) == NULL) in tulip_scsi()
1180 outb((host->scsi_id << 4) | (scb->target & 0x0F), in tulip_scsi()
1182 if (scb->opcode == ExecSCSI) { in tulip_scsi()
1183 active_tc = &host->targets[scb->target]; in tulip_scsi()
1185 if (scb->tagmsg) in tulip_scsi()
1192 initio_select_atn_stop(host, scb); in tulip_scsi()
1195 initio_select_atn_stop(host, scb); in tulip_scsi()
1197 if (scb->tagmsg) in tulip_scsi()
1198 initio_select_atn3(host, scb); in tulip_scsi()
1200 initio_select_atn(host, scb); in tulip_scsi()
1203 if (scb->flags & SCF_POLL) { in tulip_scsi()
1209 } else if (scb->opcode == BusDevRst) { in tulip_scsi()
1210 initio_select_atn_stop(host, scb); in tulip_scsi()
1211 scb->next_state = 8; in tulip_scsi()
1212 if (scb->flags & SCF_POLL) { in tulip_scsi()
1218 } else if (scb->opcode == AbortCmd) { in tulip_scsi()
1219 if (initio_abort_srb(host, scb->srb) != 0) { in tulip_scsi()
1220 initio_unlink_pend_scb(host, scb); in tulip_scsi()
1221 initio_release_scb(host, scb); in tulip_scsi()
1223 scb->opcode = BusDevRst; in tulip_scsi()
1224 initio_select_atn_stop(host, scb); in tulip_scsi()
1225 scb->next_state = 8; in tulip_scsi()
1228 initio_unlink_pend_scb(host, scb); in tulip_scsi()
1229 scb->hastat = 0x16; /* bad command */ in tulip_scsi()
1230 initio_append_done_scb(host, scb); in tulip_scsi()
1293 struct scsi_ctrl_blk *scb = host->active; in initio_state_1() local
1299 /* Move the SCB from pending to busy */ in initio_state_1()
1300 initio_unlink_pend_scb(host, scb); in initio_state_1()
1301 initio_append_busy_scb(host, scb); in initio_state_1()
1307 outb(scb->ident, host->addr + TUL_SFifo); in initio_state_1()
1309 if (scb->tagmsg) { in initio_state_1()
1310 outb(scb->tagmsg, host->addr + TUL_SFifo); in initio_state_1()
1311 outb(scb->tagid, host->addr + TUL_SFifo); in initio_state_1()
1348 struct scsi_ctrl_blk *scb = host->active; in initio_state_2() local
1354 initio_unlink_pend_scb(host, scb); in initio_state_2()
1355 initio_append_busy_scb(host, scb); in initio_state_2()
1377 struct scsi_ctrl_blk *scb = host->active; in initio_state_3() local
1387 for (i = 0; i < (int) scb->cdblen; i++) in initio_state_3()
1388 outb(scb->cdb[i], host->addr + TUL_SFifo); in initio_state_3()
1397 scb->next_state = 3; in initio_state_3()
1444 struct scsi_ctrl_blk *scb = host->active; in initio_state_4() local
1449 if ((scb->flags & SCF_DIR) == SCF_NO_XF) { in initio_state_4()
1453 if (scb->buflen == 0) in initio_state_4()
1459 if ((scb->flags & SCF_DIR) != 0) /* if direction bit set then report data underrun */ in initio_state_4()
1460 scb->hastat = HOST_DO_DU; in initio_state_4()
1466 scb->next_state = 0x4; in initio_state_4()
1473 scb->buflen = 0; in initio_state_4()
1474 scb->hastat = HOST_DO_DU; in initio_state_4()
1508 struct scsi_ctrl_blk *scb = host->active; in initio_state_5() local
1521 scb->hastat = HOST_DO_DU; in initio_state_5()
1554 scb->buflen = 0; in initio_state_5()
1558 xcnt = (long) scb->buflen - cnt; /* xcnt== bytes already xferred */ in initio_state_5()
1559 scb->buflen = (u32) cnt; /* cnt == bytes left to be xferred */ in initio_state_5()
1560 if (scb->flags & SCF_SG) { in initio_state_5()
1564 sgp = &scb->sglist[scb->sgidx]; in initio_state_5()
1565 for (i = scb->sgidx; i < scb->sgmax; sgp++, i++) { in initio_state_5()
1571 scb->bufptr += ((u32) (i - scb->sgidx) << 3); in initio_state_5()
1573 scb->sglen = (u8) (scb->sgmax - i); in initio_state_5()
1575 scb->sgidx = (u16) i; in initio_state_5()
1583 scb->bufptr += (u32) xcnt; in initio_state_5()
1597 struct scsi_ctrl_blk *scb = host->active; in initio_state_6() local
1610 scb->next_state = 6; in initio_state_6()
1672 struct scsi_ctrl_blk *scb = host->active; in initio_xfer_data_in() local
1674 if ((scb->flags & SCF_DIR) == SCF_DOUT) in initio_xfer_data_in()
1677 outl(scb->buflen, host->addr + TUL_SCnt0); in initio_xfer_data_in()
1680 if (scb->flags & SCF_SG) { /* S/G xfer */ in initio_xfer_data_in()
1681 outl(((u32) scb->sglen) << 3, host->addr + TUL_XCntH); in initio_xfer_data_in()
1682 outl(scb->bufptr, host->addr + TUL_XAddH); in initio_xfer_data_in()
1685 outl(scb->buflen, host->addr + TUL_XCntH); in initio_xfer_data_in()
1686 outl(scb->bufptr, host->addr + TUL_XAddH); in initio_xfer_data_in()
1689 scb->next_state = 0x5; in initio_xfer_data_in()
1704 struct scsi_ctrl_blk *scb = host->active; in initio_xfer_data_out() local
1706 if ((scb->flags & SCF_DIR) == SCF_DIN) in initio_xfer_data_out()
1709 outl(scb->buflen, host->addr + TUL_SCnt0); in initio_xfer_data_out()
1712 if (scb->flags & SCF_SG) { /* S/G xfer */ in initio_xfer_data_out()
1713 outl(((u32) scb->sglen) << 3, host->addr + TUL_XCntH); in initio_xfer_data_out()
1714 outl(scb->bufptr, host->addr + TUL_XAddH); in initio_xfer_data_out()
1717 outl(scb->buflen, host->addr + TUL_XCntH); in initio_xfer_data_out()
1718 outl(scb->bufptr, host->addr + TUL_XAddH); in initio_xfer_data_out()
1722 scb->next_state = 0x5; in initio_xfer_data_out()
1728 struct scsi_ctrl_blk *scb = host->active; in initio_xpad_in() local
1731 if ((scb->flags & SCF_DIR) != SCF_NO_DCHK) in initio_xpad_in()
1732 scb->hastat = HOST_DO_DU; /* over run */ in initio_xpad_in()
1752 struct scsi_ctrl_blk *scb = host->active; in initio_xpad_out() local
1755 if ((scb->flags & SCF_DIR) != SCF_NO_DCHK) in initio_xpad_out()
1756 scb->hastat = HOST_DO_DU; /* over run */ in initio_xpad_out()
1777 struct scsi_ctrl_blk *scb = host->active; in initio_status_msg() local
1785 scb->tastat = inb(host->addr + TUL_SFifo); in initio_status_msg()
1808 if ((scb->tastat & 0x18) == 0x10) /* No link support */ in initio_status_msg()
1817 if ((scb->tastat & 0x18) == 0x10) in initio_status_msg()
1828 struct scsi_ctrl_blk *scb = host->active; in int_initio_busfree() local
1830 if (scb != NULL) { in int_initio_busfree()
1831 if (scb->status & SCB_SELECT) { /* selection timeout */ in int_initio_busfree()
1832 initio_unlink_pend_scb(host, scb); in int_initio_busfree()
1833 scb->hastat = HOST_SEL_TOUT; in int_initio_busfree()
1834 initio_append_done_scb(host, scb); in int_initio_busfree()
1836 initio_unlink_busy_scb(host, scb); in int_initio_busfree()
1837 scb->hastat = HOST_BUS_FREE; in int_initio_busfree()
1838 initio_append_done_scb(host, scb); in int_initio_busfree()
1862 struct scsi_ctrl_blk *scb; in int_initio_scsi_rst() local
1873 /* Abort all active & disconnected scb */ in int_initio_scsi_rst()
1874 while ((scb = initio_pop_busy_scb(host)) != NULL) { in int_initio_scsi_rst()
1875 scb->hastat = HOST_BAD_PHAS; in int_initio_scsi_rst()
1876 initio_append_done_scb(host, scb); in int_initio_scsi_rst()
1898 struct scsi_ctrl_blk *scb; in int_initio_resel() local
1903 if ((scb = host->active) != NULL) { in int_initio_resel()
1905 if (scb->status & SCB_SELECT) /* if waiting for selection complete */ in int_initio_resel()
1906 scb->status &= ~SCB_SELECT; in int_initio_resel()
1946 scb = host->scb + tag; in int_initio_resel()
1947 if (scb->target != tar || scb->lun != lun) { in int_initio_resel()
1950 if (scb->status != SCB_BUSY) { /* 03/24/95 */ in int_initio_resel()
1953 host->active = scb; in int_initio_resel()
1958 if ((scb = initio_find_busy_scb(host, tar | (lun << 8))) == NULL) { in int_initio_resel()
1961 host->active = scb; in int_initio_resel()
1980 struct scsi_ctrl_blk *scb; in int_initio_bad_seq() local
1985 while ((scb = initio_pop_busy_scb(host)) != NULL) { in int_initio_bad_seq()
1986 scb->hastat = HOST_BAD_PHAS; in int_initio_bad_seq()
1987 initio_append_done_scb(host, scb); in int_initio_bad_seq()
1999 * Abort when the target/lun does not match or when our SCB is not
2022 * Abort when the target/lun does not match or when our SCB is not
2278 struct scsi_ctrl_blk *scb; in initio_post_scsi_rst() local
2286 while ((scb = initio_pop_busy_scb(host)) != NULL) { in initio_post_scsi_rst()
2287 scb->hastat = HOST_BAD_PHAS; in initio_post_scsi_rst()
2288 initio_append_done_scb(host, scb); in initio_post_scsi_rst()
2304 static void initio_select_atn_stop(struct initio_host * host, struct scsi_ctrl_blk * scb) in initio_select_atn_stop() argument
2306 scb->status |= SCB_SELECT; in initio_select_atn_stop()
2307 scb->next_state = 0x1; in initio_select_atn_stop()
2308 host->active = scb; in initio_select_atn_stop()
2309 host->active_tc = &host->targets[scb->target]; in initio_select_atn_stop()
2314 static void initio_select_atn(struct initio_host * host, struct scsi_ctrl_blk * scb) in initio_select_atn() argument
2318 scb->status |= SCB_SELECT; in initio_select_atn()
2319 scb->next_state = 0x2; in initio_select_atn()
2321 outb(scb->ident, host->addr + TUL_SFifo); in initio_select_atn()
2322 for (i = 0; i < (int) scb->cdblen; i++) in initio_select_atn()
2323 outb(scb->cdb[i], host->addr + TUL_SFifo); in initio_select_atn()
2324 host->active_tc = &host->targets[scb->target]; in initio_select_atn()
2325 host->active = scb; in initio_select_atn()
2329 static void initio_select_atn3(struct initio_host * host, struct scsi_ctrl_blk * scb) in initio_select_atn3() argument
2333 scb->status |= SCB_SELECT; in initio_select_atn3()
2334 scb->next_state = 0x2; in initio_select_atn3()
2336 outb(scb->ident, host->addr + TUL_SFifo); in initio_select_atn3()
2337 outb(scb->tagmsg, host->addr + TUL_SFifo); in initio_select_atn3()
2338 outb(scb->tagid, host->addr + TUL_SFifo); in initio_select_atn3()
2339 for (i = 0; i < scb->cdblen; i++) in initio_select_atn3()
2340 outb(scb->cdb[i], host->addr + TUL_SFifo); in initio_select_atn3()
2341 host->active_tc = &host->targets[scb->target]; in initio_select_atn3()
2342 host->active = scb; in initio_select_atn3()
2355 struct scsi_ctrl_blk *scb = host->active; in initio_bus_device_reset() local
2363 initio_unlink_pend_scb(host, scb); in initio_bus_device_reset()
2364 initio_release_scb(host, scb); in initio_bus_device_reset()
2367 tar = scb->target; /* target */ in initio_bus_device_reset()
2371 /* abort all SCB with same target */ in initio_bus_device_reset()
2521 * initio_build_scb - Build the mappings and SCB
2532 { /* Create corresponding SCB */ in initio_build_scb()
2742 initio_release_scb(host, cblk); /* Release SCB for current channel */ in i91uSCBPost()
2768 case 0x1a: /* SCB Aborted. 07/21/98 */ in i91uSCBPost()
2776 case 0x16: /* Invalid SCB Operation Code. */ in i91uSCBPost()
2787 initio_release_scb(host, cblk); /* Release SCB for current channel */ in i91uSCBPost()
2809 struct scsi_ctrl_blk *scb, *tmp, *prev = NULL /* silence gcc */; in initio_probe_one() local
2851 scb = kzalloc(i, GFP_KERNEL); in initio_probe_one()
2852 if (scb) in initio_probe_one()
2856 if (!scb) { in initio_probe_one()
2857 printk(KERN_WARNING "initio: Cannot allocate SCB array.\n"); in initio_probe_one()
2867 host->scb = scb; in initio_probe_one()
2868 host->next_pending = scb; in initio_probe_one()
2869 host->next_avail = scb; in initio_probe_one()
2870 for (i = 0, tmp = scb; i < num_scb; i++, tmp++) { in initio_probe_one()
2878 host->first_avail = scb; in initio_probe_one()
2913 kfree(host->scb); in initio_probe_one()