Lines Matching full:scb

79 	{ MPARERR,	"Scratch or SCB Memory Parity Error" },
154 struct scb *scb);
158 struct scb *scb);
195 struct scb *scb);
203 struct scb *prev_scb,
204 struct scb *scb);
238 /************************** SCB and SCB queue management **********************/
260 static void ahc_freeze_devq(struct ahc_softc *ahc, struct scb *scb);
265 struct scb *scb);
304 * manual pause while accessing scb ram, accesses to certain registers
365 ahc_sg_bus_to_virt(struct scb *scb, uint32_t sg_busaddr) in ahc_sg_bus_to_virt() argument
369 sg_index = (sg_busaddr - scb->sg_list_phys)/sizeof(struct ahc_dma_seg); in ahc_sg_bus_to_virt()
373 return (&scb->sg_list[sg_index]); in ahc_sg_bus_to_virt()
377 ahc_sg_virt_to_bus(struct scb *scb, struct ahc_dma_seg *sg) in ahc_sg_virt_to_bus() argument
382 sg_index = sg - &scb->sg_list[1]; in ahc_sg_virt_to_bus()
384 return (scb->sg_list_phys + (sg_index * sizeof(*scb->sg_list))); in ahc_sg_virt_to_bus()
395 ahc_sync_scb(struct ahc_softc *ahc, struct scb *scb, int op) in ahc_sync_scb() argument
399 /*offset*/(scb->hscb - ahc->hscbs) * sizeof(*scb->hscb), in ahc_sync_scb()
400 /*len*/sizeof(*scb->hscb), op); in ahc_sync_scb()
404 ahc_sync_sglist(struct ahc_softc *ahc, struct scb *scb, int op) in ahc_sync_sglist() argument
406 if (scb->sg_count == 0) in ahc_sync_sglist()
409 ahc_dmamap_sync(ahc, ahc->scb_data->sg_dmat, scb->sg_map->sg_dmamap, in ahc_sync_sglist()
410 /*offset*/(scb->sg_list - scb->sg_map->sg_vaddr) in ahc_sync_sglist()
412 /*len*/sizeof(struct ahc_dma_seg) * scb->sg_count, op); in ahc_sync_sglist()
426 * for this SCB/transaction.
429 ahc_update_residual(struct ahc_softc *ahc, struct scb *scb) in ahc_update_residual() argument
433 sgptr = ahc_le32toh(scb->hscb->sgptr); in ahc_update_residual()
435 ahc_calc_residual(ahc, scb); in ahc_update_residual()
517 * Get a free scb. If there are none, see if we can allocate a new SCB.
519 struct scb *
522 struct scb *scb; in ahc_get_scb() local
524 if ((scb = SLIST_FIRST(&ahc->scb_data->free_scbs)) == NULL) { in ahc_get_scb()
526 scb = SLIST_FIRST(&ahc->scb_data->free_scbs); in ahc_get_scb()
527 if (scb == NULL) in ahc_get_scb()
531 return (scb); in ahc_get_scb()
535 * Return an SCB resource to the free list.
538 ahc_free_scb(struct ahc_softc *ahc, struct scb *scb) in ahc_free_scb() argument
542 hscb = scb->hscb; in ahc_free_scb()
545 scb->flags = SCB_FREE; in ahc_free_scb()
548 SLIST_INSERT_HEAD(&ahc->scb_data->free_scbs, scb, links.sle); in ahc_free_scb()
551 ahc_platform_scb_free(ahc, scb); in ahc_free_scb()
554 struct scb *
557 struct scb* scb; in ahc_lookup_scb() local
559 scb = ahc->scb_data->scbindex[tag]; in ahc_lookup_scb()
560 if (scb != NULL) in ahc_lookup_scb()
561 ahc_sync_scb(ahc, scb, in ahc_lookup_scb()
563 return (scb); in ahc_lookup_scb()
567 ahc_swap_with_next_hscb(struct ahc_softc *ahc, struct scb *scb) in ahc_swap_with_next_hscb() argument
576 * SCB to download is saved off in ahc->next_queued_scb. in ahc_swap_with_next_hscb()
577 * When we are called to queue "an arbitrary scb", in ahc_swap_with_next_hscb()
580 * finally assign the SCB to the tag indexed location in ahc_swap_with_next_hscb()
582 * locate the correct SCB by SCB_TAG. in ahc_swap_with_next_hscb()
586 memcpy(q_hscb, scb->hscb, sizeof(*scb->hscb)); in ahc_swap_with_next_hscb()
587 if ((scb->flags & SCB_CDB32_PTR) != 0) { in ahc_swap_with_next_hscb()
593 q_hscb->next = scb->hscb->tag; in ahc_swap_with_next_hscb()
596 ahc->next_queued_scb->hscb = scb->hscb; in ahc_swap_with_next_hscb()
597 scb->hscb = q_hscb; in ahc_swap_with_next_hscb()
599 /* Now define the mapping from tag to SCB in the scbindex */ in ahc_swap_with_next_hscb()
600 ahc->scb_data->scbindex[scb->hscb->tag] = scb; in ahc_swap_with_next_hscb()
607 ahc_queue_scb(struct ahc_softc *ahc, struct scb *scb) in ahc_queue_scb() argument
609 ahc_swap_with_next_hscb(ahc, scb); in ahc_queue_scb()
611 if (scb->hscb->tag == SCB_LIST_NULL in ahc_queue_scb()
612 || scb->hscb->next == SCB_LIST_NULL) in ahc_queue_scb()
613 panic("Attempt to queue invalid SCB tag %x:%x\n", in ahc_queue_scb()
614 scb->hscb->tag, scb->hscb->next); in ahc_queue_scb()
619 scb->hscb->lun &= LID; in ahc_queue_scb()
620 if (ahc_get_transfer_length(scb) & 0x1) in ahc_queue_scb()
621 scb->hscb->lun |= SCB_XFERLEN_ODD; in ahc_queue_scb()
626 ahc->qinfifo[ahc->qinfifonext++] = scb->hscb->tag; in ahc_queue_scb()
632 ahc_sync_scb(ahc, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); in ahc_queue_scb()
634 /* Tell the adapter about the newly queued SCB */ in ahc_queue_scb()
647 ahc_get_sense_buf(struct ahc_softc *ahc, struct scb *scb) in ahc_get_sense_buf() argument
651 offset = scb - ahc->scb_data->scbarray; in ahc_get_sense_buf()
656 ahc_get_sense_bufaddr(struct ahc_softc *ahc, struct scb *scb) in ahc_get_sense_bufaddr() argument
660 offset = scb - ahc->scb_data->scbarray; in ahc_get_sense_bufaddr()
843 * If we were in the process of DMA'ing SCB data into in ahc_restart()
844 * an SCB, replace that SCB on the free list. This prevents in ahc_restart()
845 * an SCB leak. in ahc_restart()
878 struct scb *scb; in ahc_run_qoutfifo() local
904 scb = ahc_lookup_scb(ahc, scb_index); in ahc_run_qoutfifo()
905 if (scb == NULL) { in ahc_run_qoutfifo()
906 printk("%s: WARNING no command for scb %d " in ahc_run_qoutfifo()
917 ahc_update_residual(ahc, scb); in ahc_run_qoutfifo()
918 ahc_done(ahc, scb); in ahc_run_qoutfifo()
934 struct scb *scb; in ahc_run_untagged_queue() local
939 if ((scb = TAILQ_FIRST(queue)) != NULL in ahc_run_untagged_queue()
940 && (scb->flags & SCB_ACTIVE) == 0) { in ahc_run_untagged_queue()
941 scb->flags |= SCB_ACTIVE; in ahc_run_untagged_queue()
942 ahc_queue_scb(ahc, scb); in ahc_run_untagged_queue()
979 struct scb *scb; in ahc_handle_seqint() local
1010 * dma'd the SCB back up to us, so we can reference in ahc_handle_seqint()
1014 scb = ahc_lookup_scb(ahc, scb_index); in ahc_handle_seqint()
1015 if (scb == NULL) { in ahc_handle_seqint()
1017 printk("ahc_intr - referenced scb " in ahc_handle_seqint()
1018 "not valid during seqint 0x%x scb(%d)\n", in ahc_handle_seqint()
1025 hscb = scb->hscb; in ahc_handle_seqint()
1028 if ((scb->flags & SCB_SENSE) != 0) { in ahc_handle_seqint()
1034 scb->flags &= ~SCB_SENSE; in ahc_handle_seqint()
1035 ahc_set_transaction_status(scb, CAM_AUTOSENSE_FAIL); in ahc_handle_seqint()
1038 ahc_set_transaction_status(scb, CAM_SCSI_STATUS_ERROR); in ahc_handle_seqint()
1040 ahc_freeze_devq(ahc, scb); in ahc_handle_seqint()
1041 ahc_freeze_scb(scb); in ahc_handle_seqint()
1042 ahc_set_scsi_status(scb, hscb->shared_data.status.scsi_status); in ahc_handle_seqint()
1058 ahc_print_path(ahc, scb); in ahc_handle_seqint()
1059 printk("SCB %d: requests Check Status\n", in ahc_handle_seqint()
1060 scb->hscb->tag); in ahc_handle_seqint()
1064 if (ahc_perform_autosense(scb) == 0) in ahc_handle_seqint()
1073 sg = scb->sg_list; in ahc_handle_seqint()
1078 ahc_update_residual(ahc, scb); in ahc_handle_seqint()
1081 ahc_print_path(ahc, scb); in ahc_handle_seqint()
1085 sg->addr = ahc_get_sense_bufaddr(ahc, scb); in ahc_handle_seqint()
1086 sg->len = ahc_get_sense_bufsize(ahc, scb); in ahc_handle_seqint()
1096 && SCB_GET_LUN(scb) < 8) in ahc_handle_seqint()
1097 sc->byte2 = SCB_GET_LUN(scb) << 5; in ahc_handle_seqint()
1120 if (ahc_get_residual(scb) in ahc_handle_seqint()
1121 == ahc_get_transfer_length(scb)) { in ahc_handle_seqint()
1128 scb->flags &= ~SCB_NEGOTIATE; in ahc_handle_seqint()
1129 scb->flags |= SCB_AUTO_NEGOTIATE; in ahc_handle_seqint()
1134 hscb->sgptr = scb->sg_list_phys | SG_FULL_RESID; in ahc_handle_seqint()
1136 scb->sg_count = 1; in ahc_handle_seqint()
1137 scb->flags |= SCB_SENSE; in ahc_handle_seqint()
1138 ahc_qinfifo_requeue_tail(ahc, scb); in ahc_handle_seqint()
1144 ahc_scb_timer_reset(scb, 5 * 1000000); in ahc_handle_seqint()
1158 printk("%s:%c:%d: no active SCB for reconnecting " in ahc_handle_seqint()
1246 struct scb *scb; in ahc_handle_seqint() local
1266 scb = ahc_lookup_scb(ahc, scb_index); in ahc_handle_seqint()
1269 if (scb == NULL) in ahc_handle_seqint()
1271 "invalid SCB %x\n", in ahc_handle_seqint()
1276 scb); in ahc_handle_seqint()
1292 scb); in ahc_handle_seqint()
1350 struct scb *scb; in ahc_handle_seqint() local
1357 scb = ahc_lookup_scb(ahc, scb_index); in ahc_handle_seqint()
1358 if (scb != NULL) in ahc_handle_seqint()
1359 ahc_set_transaction_status(scb, in ahc_handle_seqint()
1384 scb = ahc_lookup_scb(ahc, scbindex); in ahc_handle_seqint()
1389 ahc_print_path(ahc, scb); in ahc_handle_seqint()
1393 scb->hscb->tag); in ahc_handle_seqint()
1394 ahc_print_path(ahc, scb); in ahc_handle_seqint()
1397 ahc_get_transfer_length(scb), scb->sg_count); in ahc_handle_seqint()
1398 if (scb->sg_count > 0) { in ahc_handle_seqint()
1399 for (i = 0; i < scb->sg_count; i++) { in ahc_handle_seqint()
1403 (ahc_le32toh(scb->sg_list[i].len) >> 24 in ahc_handle_seqint()
1405 ahc_le32toh(scb->sg_list[i].addr), in ahc_handle_seqint()
1406 ahc_le32toh(scb->sg_list[i].len) in ahc_handle_seqint()
1414 ahc_freeze_devq(ahc, scb); in ahc_handle_seqint()
1415 if ((scb->flags & SCB_SENSE) == 0) { in ahc_handle_seqint()
1416 ahc_set_transaction_status(scb, CAM_DATA_RUN_ERR); in ahc_handle_seqint()
1418 scb->flags &= ~SCB_SENSE; in ahc_handle_seqint()
1419 ahc_set_transaction_status(scb, CAM_AUTOSENSE_FAIL); in ahc_handle_seqint()
1421 ahc_freeze_scb(scb); in ahc_handle_seqint()
1452 scb = ahc_lookup_scb(ahc, scbindex); in ahc_handle_seqint()
1453 if (scb != NULL in ahc_handle_seqint()
1454 && (scb->flags & SCB_RECOVERY_SCB) != 0) in ahc_handle_seqint()
1457 * SCB into the QINFIFO. in ahc_handle_seqint()
1459 ahc_search_qinfifo(ahc, SCB_GET_TARGET(ahc, scb), in ahc_handle_seqint()
1460 SCB_GET_CHANNEL(ahc, scb), in ahc_handle_seqint()
1461 SCB_GET_LUN(scb), scb->hscb->tag, in ahc_handle_seqint()
1532 struct scb *scb; in ahc_handle_scsiint() local
1568 scb = ahc_lookup_scb(ahc, scb_index); in ahc_handle_scsiint()
1569 if (scb != NULL in ahc_handle_scsiint()
1571 scb = NULL; in ahc_handle_scsiint()
1647 if (scb != NULL) { in ahc_handle_scsiint()
1648 if (SCB_IS_SILENT(scb)) in ahc_handle_scsiint()
1651 ahc_print_path(ahc, scb); in ahc_handle_scsiint()
1652 scb->flags |= SCB_TRANSMISSION_ERROR; in ahc_handle_scsiint()
1739 scb = ahc_lookup_scb(ahc, scb_index); in ahc_handle_scsiint()
1740 if (scb == NULL) { in ahc_handle_scsiint()
1741 printk("%s: ahc_intr - referenced scb not " in ahc_handle_scsiint()
1742 "valid during SELTO scb(%d, %d)\n", in ahc_handle_scsiint()
1749 ahc_print_path(ahc, scb); in ahc_handle_scsiint()
1750 printk("Saw Selection Timeout for SCB 0x%x\n", in ahc_handle_scsiint()
1754 ahc_scb_devinfo(ahc, &devinfo, scb); in ahc_handle_scsiint()
1755 ahc_set_transaction_status(scb, CAM_SEL_TIMEOUT); in ahc_handle_scsiint()
1756 ahc_freeze_devq(ahc, scb); in ahc_handle_scsiint()
1824 tag = scb->hscb->tag; in ahc_handle_scsiint()
1825 ahc_print_path(ahc, scb); in ahc_handle_scsiint()
1826 printk("SCB %d - Abort%s Completed.\n", in ahc_handle_scsiint()
1827 scb->hscb->tag, tag == SCB_LIST_NULL ? in ahc_handle_scsiint()
1864 ahc_qinfifo_requeue_tail(ahc, scb); in ahc_handle_scsiint()
1876 ahc_qinfifo_requeue_tail(ahc, scb); in ahc_handle_scsiint()
1890 ahc_qinfifo_requeue_tail(ahc, scb); in ahc_handle_scsiint()
1897 if (scb != NULL) { in ahc_handle_scsiint()
1900 if ((scb->hscb->control & TAG_ENB) != 0) in ahc_handle_scsiint()
1901 tag = scb->hscb->tag; in ahc_handle_scsiint()
1904 ahc_print_path(ahc, scb); in ahc_handle_scsiint()
1906 SCB_GET_LUN(scb), tag, in ahc_handle_scsiint()
2077 ahc_print_scb(struct scb *scb)
2081 struct hardware_scb *hscb = scb->hscb;
2083 printk("scb:%p control:0x%x scsiid:0x%x lun:%d cdb_len:%d\n",
2084 (void *)scb,
2097 if (scb->sg_count > 0) {
2098 for (i = 0; i < scb->sg_count; i++) {
2101 (ahc_le32toh(scb->sg_list[i].len) >> 24
2103 ahc_le32toh(scb->sg_list[i].addr),
2104 ahc_le32toh(scb->sg_list[i].len));
2669 struct scb *pending_scb; in ahc_update_pending_scbs()
2676 * Traverse the pending SCB list and ensure that all of the in ahc_update_pending_scbs()
2818 struct scb *scb) in ahc_scb_devinfo() argument
2823 our_id = SCSIID_OUR_ID(scb->hscb->scsiid); in ahc_scb_devinfo()
2825 if ((scb->flags & SCB_TARGET_SCB) != 0) in ahc_scb_devinfo()
2827 ahc_compile_devinfo(devinfo, our_id, SCB_GET_TARGET(ahc, scb), in ahc_scb_devinfo()
2828 SCB_GET_LUN(scb), SCB_GET_CHANNEL(ahc, scb), role); in ahc_scb_devinfo()
2852 struct scb *scb) in ahc_setup_initiator_msgout() argument
2862 if ((scb->flags & SCB_DEVICE_RESET) == 0 in ahc_setup_initiator_msgout()
2866 identify_msg = MSG_IDENTIFYFLAG | SCB_GET_LUN(scb); in ahc_setup_initiator_msgout()
2867 if ((scb->hscb->control & DISCENB) != 0) in ahc_setup_initiator_msgout()
2872 if ((scb->hscb->control & TAG_ENB) != 0) { in ahc_setup_initiator_msgout()
2874 scb->hscb->control & (TAG_ENB|SCB_TAG_TYPE); in ahc_setup_initiator_msgout()
2875 ahc->msgout_buf[ahc->msgout_index++] = scb->hscb->tag; in ahc_setup_initiator_msgout()
2880 if (scb->flags & SCB_DEVICE_RESET) { in ahc_setup_initiator_msgout()
2883 ahc_print_path(ahc, scb); in ahc_setup_initiator_msgout()
2893 } else if ((scb->flags & SCB_ABORT) != 0) { in ahc_setup_initiator_msgout()
2894 if ((scb->hscb->control & TAG_ENB) != 0) in ahc_setup_initiator_msgout()
2899 ahc_print_path(ahc, scb); in ahc_setup_initiator_msgout()
2901 (scb->hscb->control & TAG_ENB) != 0 ? " Tag" : ""); in ahc_setup_initiator_msgout()
2910 } else if ((scb->flags & (SCB_AUTO_NEGOTIATE|SCB_NEGOTIATE)) != 0) { in ahc_setup_initiator_msgout()
2913 printk("ahc_intr: AWAITING_MSG for an SCB that " in ahc_setup_initiator_msgout()
2915 printk("SCSIID = %x, target_mask = %x\n", scb->hscb->scsiid, in ahc_setup_initiator_msgout()
2917 panic("SCB = %d, SCB Control = %x, MSG_OUT = %x " in ahc_setup_initiator_msgout()
2918 "SCB flags = %x", scb->hscb->tag, scb->hscb->control, in ahc_setup_initiator_msgout()
2919 ahc_inb(ahc, MSG_OUT), scb->flags); in ahc_setup_initiator_msgout()
2923 * Clear the MK_MESSAGE flag from the SCB so we aren't in ahc_setup_initiator_msgout()
2927 scb->hscb->control &= ~MK_MESSAGE; in ahc_setup_initiator_msgout()
3116 struct scb *scb; in ahc_handle_proto_violation() local
3125 scb = ahc_lookup_scb(ahc, scbid); in ahc_handle_proto_violation()
3133 * identify message, or did, but we didn't find an SCB in ahc_handle_proto_violation()
3139 scb = NULL; in ahc_handle_proto_violation()
3140 } else if (scb == NULL) { in ahc_handle_proto_violation()
3142 * We don't seem to have an SCB active for this in ahc_handle_proto_violation()
3146 printk("No SCB found during protocol violation\n"); in ahc_handle_proto_violation()
3149 ahc_set_transaction_status(scb, CAM_SEQUENCE_FAIL); in ahc_handle_proto_violation()
3151 ahc_print_path(ahc, scb); in ahc_handle_proto_violation()
3161 ahc_print_path(ahc, scb); in ahc_handle_proto_violation()
3164 ahc_print_path(ahc, scb); in ahc_handle_proto_violation()
3191 if (scb == NULL) { in ahc_handle_proto_violation()
3198 ahc_print_path(ahc, scb); in ahc_handle_proto_violation()
3199 scb->flags |= SCB_ABORT; in ahc_handle_proto_violation()
3989 struct scb *scb; in ahc_handle_msg_reject() local
3997 scb = ahc_lookup_scb(ahc, scb_index); in ahc_handle_msg_reject()
4058 } else if ((scb->hscb->control & SIMPLE_QUEUE_TAG) != 0) { in ahc_handle_msg_reject()
4062 tag_type = (scb->hscb->control & SIMPLE_QUEUE_TAG); in ahc_handle_msg_reject()
4068 ahc_set_tags(ahc, scb->io_ctx, devinfo, AHC_QUEUE_NONE); in ahc_handle_msg_reject()
4076 ahc_set_tags(ahc, scb->io_ctx, devinfo, AHC_QUEUE_BASIC); in ahc_handle_msg_reject()
4086 scb->hscb->control &= mask; in ahc_handle_msg_reject()
4087 ahc_set_transaction_tag(scb, /*enabled*/FALSE, in ahc_handle_msg_reject()
4101 TAILQ_INSERT_HEAD(untagged_q, scb, links.tqe); in ahc_handle_msg_reject()
4102 scb->flags |= SCB_UNTAGGEDQ; in ahc_handle_msg_reject()
4104 ahc_busy_tcl(ahc, BUILD_TCL(scb->hscb->scsiid, devinfo->lun), in ahc_handle_msg_reject()
4105 scb->hscb->tag); in ahc_handle_msg_reject()
4112 ahc_search_qinfifo(ahc, SCB_GET_TARGET(ahc, scb), in ahc_handle_msg_reject()
4113 SCB_GET_CHANNEL(ahc, scb), in ahc_handle_msg_reject()
4114 SCB_GET_LUN(scb), /*tag*/SCB_LIST_NULL, in ahc_handle_msg_reject()
4135 struct scb *scb; in ahc_handle_ign_wide_residue() local
4138 scb = ahc_lookup_scb(ahc, scb_index); in ahc_handle_ign_wide_residue()
4144 || ahc_get_transfer_dir(scb) != CAM_DIR_IN) { in ahc_handle_ign_wide_residue()
4193 sg = ahc_sg_bus_to_virt(scb, sgptr); in ahc_handle_ign_wide_residue()
4201 if (sg != scb->sg_list in ahc_handle_ign_wide_residue()
4219 sgptr = ahc_sg_virt_to_bus(scb, sg); in ahc_handle_ign_wide_residue()
4243 struct scb *scb; in ahc_reinitialize_dataptrs() local
4251 scb = ahc_lookup_scb(ahc, scb_index); in ahc_reinitialize_dataptrs()
4258 sg = ahc_sg_bus_to_virt(scb, sgptr); in ahc_reinitialize_dataptrs()
4353 struct scb *scb) in ahc_setup_target_msgin() argument
4364 if (scb != NULL && (scb->flags & SCB_AUTO_NEGOTIATE) != 0) in ahc_setup_target_msgin()
4434 /* XXX The shared scb data stuff should be deprecated */ in ahc_softc_init()
4696 * Touch all SCB bytes to avoid parity errors in ahc_build_free_scb_list()
4719 /* SCB 0 heads the free list. */ in ahc_build_free_scb_list()
4726 /* Make sure that the last SCB terminates the free list */ in ahc_build_free_scb_list()
4740 /* Allocate SCB resources */ in ahc_init_scbdata()
4741 scb_data->scbarray = kcalloc(AHC_SCB_MAX_ALLOC, sizeof(struct scb), in ahc_init_scbdata()
4750 printk("%s: No SCB space found\n", ahc_name(ahc)); in ahc_init_scbdata()
4764 /* DMA tag for our hardware scb structures */ in ahc_init_scbdata()
4855 * Reserve the next queued SCB. in ahc_init_scbdata()
4932 struct scb *next_scb; in ahc_alloc_scbs()
4981 * The first entry is embedded in the scb. in ahc_alloc_scbs()
5092 * The SCB based BTT allows an entry per in ahc_chip_init()
5187 * Tell the sequencer which SCB will be the next one it receives. in ahc_chip_init()
5342 /* Allocate SCB data now that buffer_dmat is initialized */ in ahc_init()
5374 printk("%s: hardware scb %u bytes; kernel scb %u bytes; " in ahc_init()
5378 (u_int)sizeof(struct scb), in ahc_init()
5689 /************************** SCB and SCB queue management **********************/
5691 ahc_match_scb(struct ahc_softc *ahc, struct scb *scb, int target, in ahc_match_scb() argument
5694 int targ = SCB_GET_TARGET(ahc, scb); in ahc_match_scb()
5695 char chan = SCB_GET_CHANNEL(ahc, scb); in ahc_match_scb()
5696 int slun = SCB_GET_LUN(scb); in ahc_match_scb()
5708 group = XPT_FC_GROUP(scb->io_ctx->ccb_h.func_code); in ahc_match_scb()
5711 && ((tag == scb->hscb->tag) in ahc_match_scb()
5715 && ((tag == scb->io_ctx->csio.tag_id) in ahc_match_scb()
5719 match = ((tag == scb->hscb->tag) || (tag == SCB_LIST_NULL)); in ahc_match_scb()
5727 ahc_freeze_devq(struct ahc_softc *ahc, struct scb *scb) in ahc_freeze_devq() argument
5733 target = SCB_GET_TARGET(ahc, scb); in ahc_freeze_devq()
5734 lun = SCB_GET_LUN(scb); in ahc_freeze_devq()
5735 channel = SCB_GET_CHANNEL(ahc, scb); in ahc_freeze_devq()
5741 ahc_platform_freeze_devq(ahc, scb); in ahc_freeze_devq()
5745 ahc_qinfifo_requeue_tail(struct ahc_softc *ahc, struct scb *scb) in ahc_qinfifo_requeue_tail() argument
5747 struct scb *prev_scb; in ahc_qinfifo_requeue_tail()
5758 ahc_qinfifo_requeue(ahc, prev_scb, scb); in ahc_qinfifo_requeue_tail()
5767 ahc_qinfifo_requeue(struct ahc_softc *ahc, struct scb *prev_scb, in ahc_qinfifo_requeue()
5768 struct scb *scb) in ahc_qinfifo_requeue() argument
5771 ahc_outb(ahc, NEXT_QUEUED_SCB, scb->hscb->tag); in ahc_qinfifo_requeue()
5773 prev_scb->hscb->next = scb->hscb->tag; in ahc_qinfifo_requeue()
5777 ahc->qinfifo[ahc->qinfifonext++] = scb->hscb->tag; in ahc_qinfifo_requeue()
5778 scb->hscb->next = ahc->next_queued_scb->hscb->tag; in ahc_qinfifo_requeue()
5779 ahc_sync_scb(ahc, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); in ahc_qinfifo_requeue()
5802 struct scb *scb; in ahc_search_qinfifo() local
5803 struct scb *prev_scb; in ahc_search_qinfifo()
5840 scb = ahc_lookup_scb(ahc, ahc->qinfifo[qinpos]); in ahc_search_qinfifo()
5841 if (scb == NULL) { in ahc_search_qinfifo()
5842 printk("qinpos = %d, SCB index = %d\n", in ahc_search_qinfifo()
5847 if (ahc_match_scb(ahc, scb, target, channel, lun, tag, role)) { in ahc_search_qinfifo()
5849 * We found an scb that needs to be acted on. in ahc_search_qinfifo()
5858 ostat = ahc_get_transaction_status(scb); in ahc_search_qinfifo()
5860 ahc_set_transaction_status(scb, status); in ahc_search_qinfifo()
5861 cstat = ahc_get_transaction_status(scb); in ahc_search_qinfifo()
5863 ahc_freeze_scb(scb); in ahc_search_qinfifo()
5864 if ((scb->flags & SCB_ACTIVE) == 0) in ahc_search_qinfifo()
5865 printk("Inactive SCB in qinfifo\n"); in ahc_search_qinfifo()
5866 ahc_done(ahc, scb); in ahc_search_qinfifo()
5872 ahc_qinfifo_requeue(ahc, prev_scb, scb); in ahc_search_qinfifo()
5873 prev_scb = scb; in ahc_search_qinfifo()
5877 ahc_qinfifo_requeue(ahc, prev_scb, scb); in ahc_search_qinfifo()
5878 prev_scb = scb; in ahc_search_qinfifo()
5894 * down the SCB at the beginning of the queue. in ahc_search_qinfifo()
5896 * or the second SCB is removed from the queue in ahc_search_qinfifo()
5897 * (the first SCB includes a pointer to the "next" in ahc_search_qinfifo()
5898 * SCB to dma). If we have removed any entries, swap in ahc_search_qinfifo()
5904 scb = ahc_lookup_scb(ahc, ahc->qinfifo[qinstart]); in ahc_search_qinfifo()
5906 if (scb == NULL) { in ahc_search_qinfifo()
5913 * point to the reserved SCB for future commands. Save in ahc_search_qinfifo()
5917 next = scb->hscb->next; in ahc_search_qinfifo()
5918 ahc->scb_data->scbindex[scb->hscb->tag] = NULL; in ahc_search_qinfifo()
5919 ahc_swap_with_next_hscb(ahc, scb); in ahc_search_qinfifo()
5920 scb->hscb->next = next; in ahc_search_qinfifo()
5921 ahc->qinfifo[qinstart] = scb->hscb->tag; in ahc_search_qinfifo()
5924 ahc_outb(ahc, NEXT_QUEUED_SCB, scb->hscb->tag); in ahc_search_qinfifo()
5928 scb = ahc_lookup_scb(ahc, ahc->qinfifo[qintail]); in ahc_search_qinfifo()
5929 scb->hscb->next = ahc->next_queued_scb->hscb->tag; in ahc_search_qinfifo()
5946 "SCB index == %d, yet numscbs == %d.", in ahc_search_qinfifo()
5951 scb = ahc_lookup_scb(ahc, scb_index); in ahc_search_qinfifo()
5952 if (scb == NULL) { in ahc_search_qinfifo()
5957 if (ahc_match_scb(ahc, scb, target, channel, in ahc_search_qinfifo()
5960 * We found an scb that needs to be acted on. in ahc_search_qinfifo()
5969 ostat = ahc_get_transaction_status(scb); in ahc_search_qinfifo()
5971 ahc_set_transaction_status(scb, in ahc_search_qinfifo()
5973 cstat = ahc_get_transaction_status(scb); in ahc_search_qinfifo()
5975 ahc_freeze_scb(scb); in ahc_search_qinfifo()
5976 if ((scb->flags & SCB_ACTIVE) == 0) in ahc_search_qinfifo()
5977 printk("Inactive SCB in Waiting List\n"); in ahc_search_qinfifo()
5978 ahc_done(ahc, scb); in ahc_search_qinfifo()
6009 struct scb *scb; in ahc_search_untagged_queues() local
6040 struct scb *next_scb; in ahc_search_untagged_queues()
6046 scb = next_scb; in ahc_search_untagged_queues()
6047 next_scb = TAILQ_NEXT(scb, links.tqe); in ahc_search_untagged_queues()
6058 if ((scb->flags & SCB_ACTIVE) != 0) in ahc_search_untagged_queues()
6061 if (ahc_match_scb(ahc, scb, target, channel, lun, in ahc_search_untagged_queues()
6063 || (ctx != NULL && ctx != scb->io_ctx)) in ahc_search_untagged_queues()
6067 * We found an scb that needs to be acted on. in ahc_search_untagged_queues()
6076 ostat = ahc_get_transaction_status(scb); in ahc_search_untagged_queues()
6078 ahc_set_transaction_status(scb, status); in ahc_search_untagged_queues()
6079 cstat = ahc_get_transaction_status(scb); in ahc_search_untagged_queues()
6081 ahc_freeze_scb(scb); in ahc_search_untagged_queues()
6082 if ((scb->flags & SCB_ACTIVE) == 0) in ahc_search_untagged_queues()
6083 printk("Inactive SCB in untaggedQ\n"); in ahc_search_untagged_queues()
6084 ahc_done(ahc, scb); in ahc_search_untagged_queues()
6088 scb->flags &= ~SCB_UNTAGGEDQ; in ahc_search_untagged_queues()
6089 TAILQ_REMOVE(untagged_q, scb, links.tqe); in ahc_search_untagged_queues()
6107 struct scb *scbp; in ahc_search_disc_list()
6131 "SCB index == %d, yet numscbs == %d.", in ahc_search_disc_list()
6166 * Remove an SCB from the on chip list of disconnected transactions.
6167 * This is empty/unused if we are not performing SCB paging.
6191 * Add the SCB as selected by SCBPTR onto the on chip list of
6193 * performing SCB paging.
6212 * scb that follows the one that we remove.
6220 * Select the SCB we want to abort and in ahc_rem_wscb()
6244 * Select the scb that pointed to us in ahc_rem_wscb()
6252 * Point us back at the original scb position. in ahc_rem_wscb()
6269 struct scb *scbp; in ahc_abort_scbs()
6270 struct scb *scbp_next; in ahc_abort_scbs()
6306 * Unless we are using an SCB based in ahc_abort_scbs()
6340 * We save the active SCB and restore it ourselves, so there in ahc_abort_scbs()
6349 * Go through the hardware SCB array looking for commands that in ahc_abort_scbs()
6352 * bus free with the same scb queued for an abort). Don't hold this in ahc_abort_scbs()
6386 printk("Inactive SCB on pending list\n"); in ahc_abort_scbs()
6585 * Calculate the residual for a just completed SCB.
6588 ahc_calc_residual(struct ahc_softc *ahc, struct scb *scb) in ahc_calc_residual() argument
6612 hscb = scb->hscb; in ahc_calc_residual()
6627 resid = ahc_get_transfer_length(scb); in ahc_calc_residual()
6641 sg = ahc_sg_bus_to_virt(scb, resid_sgptr & SG_PTR_MASK); in ahc_calc_residual()
6656 if ((scb->flags & SCB_SENSE) == 0) in ahc_calc_residual()
6657 ahc_set_residual(scb, resid); in ahc_calc_residual()
6659 ahc_set_sense_residual(scb, resid); in ahc_calc_residual()
6663 ahc_print_path(ahc, scb); in ahc_calc_residual()
6665 (scb->flags & SCB_SENSE) ? "Sense " : "", resid); in ahc_calc_residual()
7102 struct scb *scb; in ahc_dump_card_state() local
7209 printk("Sequencer Free SCB List: "); in ahc_dump_card_state()
7219 printk("Sequencer SCB Info: "); in ahc_dump_card_state()
7233 LIST_FOREACH(scb, &ahc->pending_scbs, pending_links) { in ahc_dump_card_state()
7236 cur_col = printk("\n%3d ", scb->hscb->tag); in ahc_dump_card_state()
7237 ahc_scb_control_print(scb->hscb->control, &cur_col, 60); in ahc_dump_card_state()
7238 ahc_scb_scsiid_print(scb->hscb->scsiid, &cur_col, 60); in ahc_dump_card_state()
7239 ahc_scb_lun_print(scb->hscb->lun, &cur_col, 60); in ahc_dump_card_state()
7241 ahc_outb(ahc, SCBPTR, scb->hscb->tag); in ahc_dump_card_state()
7251 printk("Kernel Free SCB list: "); in ahc_dump_card_state()
7253 SLIST_FOREACH(scb, &ahc->scb_data->free_scbs, links.sle) { in ahc_dump_card_state()
7256 printk("%d ", scb->hscb->tag); in ahc_dump_card_state()
7267 TAILQ_FOREACH(scb, untagged_q, links.tqe) { in ahc_dump_card_state()
7270 printk("%d ", scb->hscb->tag); in ahc_dump_card_state()
7581 struct scb *scb; in ahc_handle_en_lun() local
7592 LIST_FOREACH(scb, &ahc->pending_scbs, pending_links) { in ahc_handle_en_lun()
7595 ccbh = &scb->io_ctx->ccb_h; in ahc_handle_en_lun()