Lines Matching refs:scb
136 struct scb *scb);
139 struct scb *scb);
175 struct scb *scb);
188 struct scb *scb, u_int col_idx);
190 struct scb *scb);
193 struct scb *prev_scb,
194 struct scb *scb);
224 struct scb *scb);
226 struct scb *scb);
247 struct scb *scb);
254 struct scb *scb);
256 struct scb *scb);
265 static int ahd_match_scb(struct ahd_softc *ahd, struct scb *scb,
414 ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb, in ahd_sg_setup() argument
417 scb->sg_count++; in ahd_sg_setup()
438 ahd_setup_scb_common(struct ahd_softc *ahd, struct scb *scb) in ahd_setup_scb_common() argument
441 scb->crc_retry_count = 0; in ahd_setup_scb_common()
442 if ((scb->flags & SCB_PACKETIZED) != 0) { in ahd_setup_scb_common()
444 scb->hscb->task_attribute = scb->hscb->control & SCB_TAG_TYPE; in ahd_setup_scb_common()
446 if (ahd_get_transfer_length(scb) & 0x01) in ahd_setup_scb_common()
447 scb->hscb->task_attribute = SCB_XFERLEN_ODD; in ahd_setup_scb_common()
449 scb->hscb->task_attribute = 0; in ahd_setup_scb_common()
452 if (scb->hscb->cdb_len <= MAX_CDB_LEN_WITH_SENSE_ADDR in ahd_setup_scb_common()
453 || (scb->hscb->cdb_len & SCB_CDB_LEN_PTR) != 0) in ahd_setup_scb_common()
454 scb->hscb->shared_data.idata.cdb_plus_saddr.sense_addr = in ahd_setup_scb_common()
455 ahd_htole32(scb->sense_busaddr); in ahd_setup_scb_common()
459 ahd_setup_data_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_setup_data_scb() argument
467 sg = (struct ahd_dma64_seg *)scb->sg_list; in ahd_setup_data_scb()
468 scb->hscb->dataptr = sg->addr; in ahd_setup_data_scb()
469 scb->hscb->datacnt = sg->len; in ahd_setup_data_scb()
474 sg = (struct ahd_dma_seg *)scb->sg_list; in ahd_setup_data_scb()
475 dataptr_words = (uint32_t*)&scb->hscb->dataptr; in ahd_setup_data_scb()
482 scb->hscb->dataptr |= ahd_htole64(high_addr << 8); in ahd_setup_data_scb()
484 scb->hscb->datacnt = sg->len; in ahd_setup_data_scb()
492 scb->hscb->sgptr = ahd_htole32(scb->sg_list_busaddr|SG_FULL_RESID); in ahd_setup_data_scb()
496 ahd_setup_noxfer_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_setup_noxfer_scb() argument
498 scb->hscb->sgptr = ahd_htole32(SG_LIST_NULL); in ahd_setup_noxfer_scb()
499 scb->hscb->dataptr = 0; in ahd_setup_noxfer_scb()
500 scb->hscb->datacnt = 0; in ahd_setup_noxfer_scb()
505 ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr) in ahd_sg_bus_to_virt() argument
510 sg_offset = sg_busaddr - (scb->sg_list_busaddr - ahd_sg_size(ahd)); in ahd_sg_bus_to_virt()
511 return ((uint8_t *)scb->sg_list + sg_offset); in ahd_sg_bus_to_virt()
515 ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg) in ahd_sg_virt_to_bus() argument
520 sg_offset = ((uint8_t *)sg - (uint8_t *)scb->sg_list) in ahd_sg_virt_to_bus()
523 return (scb->sg_list_busaddr + sg_offset); in ahd_sg_virt_to_bus()
527 ahd_sync_scb(struct ahd_softc *ahd, struct scb *scb, int op) in ahd_sync_scb() argument
530 scb->hscb_map->dmamap, in ahd_sync_scb()
531 /*offset*/(uint8_t*)scb->hscb - scb->hscb_map->vaddr, in ahd_sync_scb()
532 /*len*/sizeof(*scb->hscb), op); in ahd_sync_scb()
536 ahd_sync_sglist(struct ahd_softc *ahd, struct scb *scb, int op) in ahd_sync_sglist() argument
538 if (scb->sg_count == 0) in ahd_sync_sglist()
542 scb->sg_map->dmamap, in ahd_sync_sglist()
543 /*offset*/scb->sg_list_busaddr - ahd_sg_size(ahd), in ahd_sync_sglist()
544 /*len*/ahd_sg_size(ahd) * scb->sg_count, op); in ahd_sync_sglist()
548 ahd_sync_sense(struct ahd_softc *ahd, struct scb *scb, int op) in ahd_sync_sense() argument
551 scb->sense_map->dmamap, in ahd_sync_sense()
552 /*offset*/scb->sense_busaddr, in ahd_sync_sense()
795 struct scb *
798 struct scb* scb; in ahd_lookup_scb() local
802 scb = ahd->scb_data.scbindex[tag]; in ahd_lookup_scb()
803 if (scb != NULL) in ahd_lookup_scb()
804 ahd_sync_scb(ahd, scb, in ahd_lookup_scb()
806 return (scb); in ahd_lookup_scb()
810 ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb) in ahd_swap_with_next_hscb() argument
831 memcpy(q_hscb, scb->hscb, sizeof(*scb->hscb)); in ahd_swap_with_next_hscb()
833 q_hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr; in ahd_swap_with_next_hscb()
836 ahd->next_queued_hscb = scb->hscb; in ahd_swap_with_next_hscb()
837 ahd->next_queued_hscb_map = scb->hscb_map; in ahd_swap_with_next_hscb()
838 scb->hscb = q_hscb; in ahd_swap_with_next_hscb()
839 scb->hscb_map = q_hscb_map; in ahd_swap_with_next_hscb()
842 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = scb; in ahd_swap_with_next_hscb()
849 ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_queue_scb() argument
851 ahd_swap_with_next_hscb(ahd, scb); in ahd_queue_scb()
853 if (SCBID_IS_NULL(SCB_GET_TAG(scb))) in ahd_queue_scb()
855 SCB_GET_TAG(scb)); in ahd_queue_scb()
860 ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb); in ahd_queue_scb()
863 if (scb->sg_count != 0) in ahd_queue_scb()
864 ahd_setup_data_scb(ahd, scb); in ahd_queue_scb()
866 ahd_setup_noxfer_scb(ahd, scb); in ahd_queue_scb()
867 ahd_setup_scb_common(ahd, scb); in ahd_queue_scb()
873 ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); in ahd_queue_scb()
879 host_dataptr = ahd_le64toh(scb->hscb->dataptr); in ahd_queue_scb()
882 SCB_GET_TAG(scb), scb->hscb->scsiid, in ahd_queue_scb()
883 ahd_le32toh(scb->hscb->hscb_busaddr), in ahd_queue_scb()
886 ahd_le32toh(scb->hscb->datacnt)); in ahd_queue_scb()
1100 ahd_update_residual(struct ahd_softc *ahd, struct scb *scb) in ahd_update_residual() argument
1104 sgptr = ahd_le32toh(scb->hscb->sgptr); in ahd_update_residual()
1106 ahd_calc_residual(ahd, scb); in ahd_update_residual()
1110 ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_complete_scb() argument
1114 sgptr = ahd_le32toh(scb->hscb->sgptr); in ahd_complete_scb()
1116 ahd_handle_scb_status(ahd, scb); in ahd_complete_scb()
1118 ahd_done(ahd, scb); in ahd_complete_scb()
1197 struct scb *scb; in ahd_flush_qoutfifo() local
1216 scb = ahd_lookup_scb(ahd, scbid); in ahd_flush_qoutfifo()
1217 if (scb == NULL) { in ahd_flush_qoutfifo()
1234 if (ahd_scb_active_in_fifo(ahd, scb) == 0) in ahd_flush_qoutfifo()
1237 ahd_run_data_fifo(ahd, scb); in ahd_flush_qoutfifo()
1290 ahd_complete_scb(ahd, scb); in ahd_flush_qoutfifo()
1340 scb = ahd_lookup_scb(ahd, scbid); in ahd_flush_qoutfifo()
1341 if (scb == NULL) { in ahd_flush_qoutfifo()
1346 hscb_ptr = (uint8_t *)scb->hscb; in ahd_flush_qoutfifo()
1350 ahd_complete_scb(ahd, scb); in ahd_flush_qoutfifo()
1361 scb = ahd_lookup_scb(ahd, scbid); in ahd_flush_qoutfifo()
1362 if (scb == NULL) { in ahd_flush_qoutfifo()
1368 ahd_complete_scb(ahd, scb); in ahd_flush_qoutfifo()
1378 scb = ahd_lookup_scb(ahd, scbid); in ahd_flush_qoutfifo()
1379 if (scb == NULL) { in ahd_flush_qoutfifo()
1385 ahd_complete_scb(ahd, scb); in ahd_flush_qoutfifo()
1403 ahd_scb_active_in_fifo(struct ahd_softc *ahd, struct scb *scb) in ahd_scb_active_in_fifo() argument
1412 if (ahd_get_scbptr(ahd) != SCB_GET_TAG(scb) in ahd_scb_active_in_fifo()
1432 ahd_run_data_fifo(struct ahd_softc *ahd, struct scb *scb) in ahd_run_data_fifo() argument
1586 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_run_data_fifo()
1593 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_run_data_fifo()
1669 struct scb *scb; in ahd_run_qoutfifo() local
1683 scb = ahd_lookup_scb(ahd, scb_index); in ahd_run_qoutfifo()
1684 if (scb == NULL) { in ahd_run_qoutfifo()
1691 ahd_handle_scb_status(ahd, scb); in ahd_run_qoutfifo()
1693 ahd_done(ahd, scb); in ahd_run_qoutfifo()
1735 ahd_dump_sglist(struct scb *scb) in ahd_dump_sglist() argument
1739 if (scb->sg_count > 0) { in ahd_dump_sglist()
1740 if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) { in ahd_dump_sglist()
1743 sg_list = (struct ahd_dma64_seg*)scb->sg_list; in ahd_dump_sglist()
1744 for (i = 0; i < scb->sg_count; i++) { in ahd_dump_sglist()
1761 sg_list = (struct ahd_dma_seg*)scb->sg_list; in ahd_dump_sglist()
1762 for (i = 0; i < scb->sg_count; i++) { in ahd_dump_sglist()
1811 struct scb *scb; in ahd_handle_seqint() local
1817 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
1818 if (scb == NULL) { in ahd_handle_seqint()
1826 ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid); in ahd_handle_seqint()
1827 ahd_outb(ahd, SAVED_LUN, scb->hscb->lun); in ahd_handle_seqint()
1861 struct scb *scb; in ahd_handle_seqint() local
1865 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
1866 if (scb != NULL) in ahd_handle_seqint()
1867 ahd_print_path(ahd, scb); in ahd_handle_seqint()
1877 struct scb *scb; in ahd_handle_seqint() local
1881 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
1882 if (scb == NULL) { in ahd_handle_seqint()
1887 ahd_outq(ahd, HADDR, scb->sense_busaddr); in ahd_handle_seqint()
1916 struct scb *scb; in ahd_handle_seqint() local
1934 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
1935 if (scb == NULL) { in ahd_handle_seqint()
1942 ahd_compile_devinfo(&devinfo, SCB_GET_OUR_ID(scb), in ahd_handle_seqint()
1943 SCB_GET_TARGET(ahd, scb), in ahd_handle_seqint()
1944 SCB_GET_LUN(scb), in ahd_handle_seqint()
1945 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_seqint()
1966 scb->hscb->control &= ~(TAG_ENB|SCB_TAG_TYPE); in ahd_handle_seqint()
1967 scb->hscb->control |= MK_MESSAGE; in ahd_handle_seqint()
1968 ahd_outb(ahd, SCB_CONTROL, scb->hscb->control); in ahd_handle_seqint()
1970 ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid); in ahd_handle_seqint()
1978 scb->flags &= ~SCB_PACKETIZED; in ahd_handle_seqint()
1979 scb->flags |= SCB_ABORT|SCB_EXTERNAL_RESET; in ahd_handle_seqint()
1980 ahd_freeze_devq(ahd, scb); in ahd_handle_seqint()
1981 ahd_set_transaction_status(scb, CAM_REQUEUE_REQ); in ahd_handle_seqint()
1982 ahd_freeze_scb(scb); in ahd_handle_seqint()
1999 ahd_print_path(ahd, scb); in ahd_handle_seqint()
2011 struct scb *scb; in ahd_handle_seqint() local
2021 scb = ahd_lookup_scb(ahd, scb_index); in ahd_handle_seqint()
2022 if (scb == NULL) { in ahd_handle_seqint()
2078 struct scb *scb; in ahd_handle_seqint() local
2098 scb = ahd_lookup_scb(ahd, scb_index); in ahd_handle_seqint()
2103 scb); in ahd_handle_seqint()
2120 scb); in ahd_handle_seqint()
2214 struct scb *scb; in ahd_handle_seqint() local
2221 scb = ahd_lookup_scb(ahd, scbindex); in ahd_handle_seqint()
2225 ahd_print_path(ahd, scb); in ahd_handle_seqint()
2228 SCB_GET_TAG(scb)); in ahd_handle_seqint()
2229 ahd_print_path(ahd, scb); in ahd_handle_seqint()
2234 ahd_get_transfer_length(scb), scb->sg_count); in ahd_handle_seqint()
2235 ahd_dump_sglist(scb); in ahd_handle_seqint()
2243 ahd_freeze_devq(ahd, scb); in ahd_handle_seqint()
2244 ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR); in ahd_handle_seqint()
2245 ahd_freeze_scb(scb); in ahd_handle_seqint()
2251 struct scb *scb; in ahd_handle_seqint() local
2259 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
2260 if (scb != NULL in ahd_handle_seqint()
2261 && (scb->flags & SCB_RECOVERY_SCB) != 0) in ahd_handle_seqint()
2266 ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_seqint()
2267 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_seqint()
2268 SCB_GET_LUN(scb), SCB_GET_TAG(scb), in ahd_handle_seqint()
2278 struct scb *scb; in ahd_handle_seqint() local
2281 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
2282 if (scb != NULL) { in ahd_handle_seqint()
2287 ahd_print_path(ahd, scb); in ahd_handle_seqint()
2289 scb->hscb->task_management); in ahd_handle_seqint()
2293 switch (scb->hscb->task_management) { in ahd_handle_seqint()
2295 tag = SCB_GET_TAG(scb); in ahd_handle_seqint()
2298 lun = scb->hscb->lun; in ahd_handle_seqint()
2300 ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_seqint()
2305 lun = scb->hscb->lun; in ahd_handle_seqint()
2310 ahd_scb_devinfo(ahd, &devinfo, scb); in ahd_handle_seqint()
2330 struct scb *scb; in ahd_handle_seqint() local
2337 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_seqint()
2338 if (scb != NULL) { in ahd_handle_seqint()
2343 ahd_print_path(ahd, scb); in ahd_handle_seqint()
2357 ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_seqint()
2358 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_seqint()
2359 SCB_GET_LUN(scb), SCB_GET_TAG(scb), in ahd_handle_seqint()
2393 struct scb *scb; in ahd_handle_scsiint() local
2434 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_scsiint()
2435 if (scb != NULL in ahd_handle_scsiint()
2437 scb = NULL; in ahd_handle_scsiint()
2498 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_scsiint()
2499 if (scb == NULL) { in ahd_handle_scsiint()
2508 ahd_print_path(ahd, scb); in ahd_handle_scsiint()
2513 ahd_scb_devinfo(ahd, &devinfo, scb); in ahd_handle_scsiint()
2514 ahd_set_transaction_status(scb, CAM_SEL_TIMEOUT); in ahd_handle_scsiint()
2515 ahd_freeze_devq(ahd, scb); in ahd_handle_scsiint()
2588 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_scsiint()
2589 if (scb == NULL) { in ahd_handle_scsiint()
2595 packetized = (scb->flags & SCB_PACKETIZED) != 0; in ahd_handle_scsiint()
2675 struct scb *scb; in ahd_handle_transmission_error() local
2686 scb = NULL; in ahd_handle_transmission_error()
2725 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_transmission_error()
2726 if (scb != NULL && SCB_IS_SILENT(scb)) in ahd_handle_transmission_error()
2821 if (scb == NULL) { in ahd_handle_transmission_error()
2852 if (scb != NULL && msg_out == MSG_INITIATOR_DET_ERR) in ahd_handle_transmission_error()
2853 scb->flags |= SCB_TRANSMISSION_ERROR; in ahd_handle_transmission_error()
2910 struct scb *scb; in ahd_handle_pkt_busfree() local
2934 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_pkt_busfree()
2935 if (scb == NULL) in ahd_handle_pkt_busfree()
2976 if (scb->crc_retry_count < AHD_MAX_LQ_CRC_ERRORS) { in ahd_handle_pkt_busfree()
2977 if (SCB_IS_SILENT(scb) == FALSE) { in ahd_handle_pkt_busfree()
2978 ahd_print_path(ahd, scb); in ahd_handle_pkt_busfree()
2982 scb->crc_retry_count++; in ahd_handle_pkt_busfree()
2984 ahd_set_transaction_status(scb, CAM_UNCOR_PARITY); in ahd_handle_pkt_busfree()
2985 ahd_freeze_scb(scb); in ahd_handle_pkt_busfree()
2986 ahd_freeze_devq(ahd, scb); in ahd_handle_pkt_busfree()
3010 struct scb *scb; in ahd_handle_pkt_busfree() local
3013 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_pkt_busfree()
3014 ahd_print_path(ahd, scb); in ahd_handle_pkt_busfree()
3017 ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), 'A', in ahd_handle_pkt_busfree()
3018 SCB_GET_LUN(scb), SCB_GET_TAG(scb), in ahd_handle_pkt_busfree()
3037 struct scb *scb; in ahd_handle_nonpkt_busfree() local
3062 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_nonpkt_busfree()
3063 if (scb != NULL in ahd_handle_nonpkt_busfree()
3065 scb = NULL; in ahd_handle_nonpkt_busfree()
3077 if (scb == NULL) { in ahd_handle_nonpkt_busfree()
3085 ahd_print_path(ahd, scb); in ahd_handle_nonpkt_busfree()
3087 SCB_GET_TAG(scb), in ahd_handle_nonpkt_busfree()
3091 tag = SCB_GET_TAG(scb); in ahd_handle_nonpkt_busfree()
3093 if ((scb->flags & SCB_EXTERNAL_RESET) != 0) { in ahd_handle_nonpkt_busfree()
3106 tag = SCB_GET_TAG(scb); in ahd_handle_nonpkt_busfree()
3107 saved_lun = scb->hscb->lun; in ahd_handle_nonpkt_busfree()
3122 if (scb != NULL in ahd_handle_nonpkt_busfree()
3123 && scb->io_ctx->ccb_h.func_code== XPT_RESET_DEV in ahd_handle_nonpkt_busfree()
3124 && ahd_match_scb(ahd, scb, target, 'A', in ahd_handle_nonpkt_busfree()
3127 ahd_set_transaction_status(scb, CAM_REQ_CMP); in ahd_handle_nonpkt_busfree()
3174 if (scb != NULL) { in ahd_handle_nonpkt_busfree()
3181 ahd_freeze_devq(ahd, scb); in ahd_handle_nonpkt_busfree()
3182 ahd_qinfifo_requeue_tail(ahd, scb); in ahd_handle_nonpkt_busfree()
3200 if (scb != NULL) { in ahd_handle_nonpkt_busfree()
3207 ahd_freeze_devq(ahd, scb); in ahd_handle_nonpkt_busfree()
3208 ahd_qinfifo_requeue_tail(ahd, scb); in ahd_handle_nonpkt_busfree()
3226 if (scb != NULL) { in ahd_handle_nonpkt_busfree()
3233 ahd_freeze_devq(ahd, scb); in ahd_handle_nonpkt_busfree()
3234 ahd_qinfifo_requeue_tail(ahd, scb); in ahd_handle_nonpkt_busfree()
3263 if (scb != NULL && printerror != 0 in ahd_handle_nonpkt_busfree()
3267 ahd_freeze_devq(ahd, scb); in ahd_handle_nonpkt_busfree()
3268 ahd_set_transaction_status(scb, CAM_REQUEUE_REQ); in ahd_handle_nonpkt_busfree()
3269 ahd_freeze_scb(scb); in ahd_handle_nonpkt_busfree()
3271 ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_nonpkt_busfree()
3272 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_nonpkt_busfree()
3273 SCB_GET_LUN(scb), SCB_LIST_NULL, in ahd_handle_nonpkt_busfree()
3280 ahd_done(ahd, scb); in ahd_handle_nonpkt_busfree()
3288 if (scb != NULL) { in ahd_handle_nonpkt_busfree()
3291 if ((scb->hscb->control & TAG_ENB) != 0) in ahd_handle_nonpkt_busfree()
3292 tag = SCB_GET_TAG(scb); in ahd_handle_nonpkt_busfree()
3295 ahd_print_path(ahd, scb); in ahd_handle_nonpkt_busfree()
3297 SCB_GET_LUN(scb), tag, in ahd_handle_nonpkt_busfree()
3324 struct scb *scb; in ahd_handle_proto_violation() local
3333 scb = ahd_lookup_scb(ahd, scbid); in ahd_handle_proto_violation()
3347 scb = NULL; in ahd_handle_proto_violation()
3348 } else if (scb == NULL) { in ahd_handle_proto_violation()
3357 ahd_set_transaction_status(scb, CAM_SEQUENCE_FAIL); in ahd_handle_proto_violation()
3359 ahd_print_path(ahd, scb); in ahd_handle_proto_violation()
3370 ahd_print_path(ahd, scb); in ahd_handle_proto_violation()
3373 ahd_print_path(ahd, scb); in ahd_handle_proto_violation()
3400 if (scb == NULL) { in ahd_handle_proto_violation()
3407 ahd_print_path(ahd, scb); in ahd_handle_proto_violation()
3408 scb->flags |= SCB_ABORT; in ahd_handle_proto_violation()
3598 ahd_print_scb(struct scb *scb)
3603 hscb = scb->hscb;
3605 (void *)scb,
3618 SCB_GET_TAG(scb));
3619 ahd_dump_sglist(scb);
4222 struct scb *pending_scb; in ahd_update_pending_scbs()
4379 struct scb *scb) in ahd_scb_devinfo() argument
4384 our_id = SCSIID_OUR_ID(scb->hscb->scsiid); in ahd_scb_devinfo()
4386 if ((scb->hscb->control & TARGET_SCB) != 0) in ahd_scb_devinfo()
4388 ahd_compile_devinfo(devinfo, our_id, SCB_GET_TARGET(ahd, scb), in ahd_scb_devinfo()
4389 SCB_GET_LUN(scb), SCB_GET_CHANNEL(ahd, scb), role); in ahd_scb_devinfo()
4402 struct scb *scb) in ahd_setup_initiator_msgout() argument
4425 } else if (scb == NULL) { in ahd_setup_initiator_msgout()
4434 if ((scb->flags & SCB_DEVICE_RESET) == 0 in ahd_setup_initiator_msgout()
4435 && (scb->flags & SCB_PACKETIZED) == 0 in ahd_setup_initiator_msgout()
4439 identify_msg = MSG_IDENTIFYFLAG | SCB_GET_LUN(scb); in ahd_setup_initiator_msgout()
4440 if ((scb->hscb->control & DISCENB) != 0) in ahd_setup_initiator_msgout()
4445 if ((scb->hscb->control & TAG_ENB) != 0) { in ahd_setup_initiator_msgout()
4447 scb->hscb->control & (TAG_ENB|SCB_TAG_TYPE); in ahd_setup_initiator_msgout()
4448 ahd->msgout_buf[ahd->msgout_index++] = SCB_GET_TAG(scb); in ahd_setup_initiator_msgout()
4453 if (scb->flags & SCB_DEVICE_RESET) { in ahd_setup_initiator_msgout()
4456 ahd_print_path(ahd, scb); in ahd_setup_initiator_msgout()
4466 } else if ((scb->flags & SCB_ABORT) != 0) { in ahd_setup_initiator_msgout()
4468 if ((scb->hscb->control & TAG_ENB) != 0) { in ahd_setup_initiator_msgout()
4474 ahd_print_path(ahd, scb); in ahd_setup_initiator_msgout()
4476 (scb->hscb->control & TAG_ENB) != 0 ? " Tag" : ""); in ahd_setup_initiator_msgout()
4485 } else if ((scb->flags & (SCB_AUTO_NEGOTIATE|SCB_NEGOTIATE)) != 0) { in ahd_setup_initiator_msgout()
4498 printk("SCSIID = %x, target_mask = %x\n", scb->hscb->scsiid, in ahd_setup_initiator_msgout()
4501 "SCB flags = %x", SCB_GET_TAG(scb), scb->hscb->control, in ahd_setup_initiator_msgout()
4503 scb->flags); in ahd_setup_initiator_msgout()
4512 scb->hscb->control &= ~MK_MESSAGE; in ahd_setup_initiator_msgout()
5528 struct scb *scb; in ahd_handle_msg_reject() local
5536 scb = ahd_lookup_scb(ahd, scb_index); in ahd_handle_msg_reject()
5616 } else if ((scb->hscb->control & MSG_SIMPLE_TASK) != 0) { in ahd_handle_msg_reject()
5620 tag_type = (scb->hscb->control & MSG_SIMPLE_TASK); in ahd_handle_msg_reject()
5626 ahd_set_tags(ahd, scb->io_ctx, devinfo, AHD_QUEUE_NONE); in ahd_handle_msg_reject()
5634 ahd_set_tags(ahd, scb->io_ctx, devinfo, AHD_QUEUE_BASIC); in ahd_handle_msg_reject()
5644 scb->hscb->control &= mask; in ahd_handle_msg_reject()
5645 ahd_set_transaction_tag(scb, /*enabled*/FALSE, in ahd_handle_msg_reject()
5649 ahd_busy_tcl(ahd, BUILD_TCL(scb->hscb->scsiid, devinfo->lun), in ahd_handle_msg_reject()
5650 SCB_GET_TAG(scb)); in ahd_handle_msg_reject()
5657 ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb), in ahd_handle_msg_reject()
5658 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_msg_reject()
5659 SCB_GET_LUN(scb), /*tag*/SCB_LIST_NULL, in ahd_handle_msg_reject()
5694 struct scb *scb; in ahd_handle_ign_wide_residue() local
5697 scb = ahd_lookup_scb(ahd, scb_index); in ahd_handle_ign_wide_residue()
5703 || ahd_get_transfer_dir(scb) != CAM_DIR_IN) { in ahd_handle_ign_wide_residue()
5751 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_handle_ign_wide_residue()
5759 if (sg != scb->sg_list in ahd_handle_ign_wide_residue()
5778 sgptr = ahd_sg_virt_to_bus(ahd, scb, in ahd_handle_ign_wide_residue()
5784 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_handle_ign_wide_residue()
5792 if (sg != scb->sg_list in ahd_handle_ign_wide_residue()
5811 sgptr = ahd_sg_virt_to_bus(ahd, scb, in ahd_handle_ign_wide_residue()
5843 struct scb *scb; in ahd_reinitialize_dataptrs() local
5855 scb = ahd_lookup_scb(ahd, scb_index); in ahd_reinitialize_dataptrs()
5866 ahd_print_path(ahd, scb); in ahd_reinitialize_dataptrs()
5890 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_reinitialize_dataptrs()
5902 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr); in ahd_reinitialize_dataptrs()
5988 struct scb *scb) in ahd_setup_target_msgin() argument
5999 if (scb != NULL && (scb->flags & SCB_AUTO_NEGOTIATE) != 0) in ahd_setup_target_msgin()
6123 ahd_name(ahd), (u_int)sizeof(struct scb), in ahd_alloc()
6507 static struct scb *
6510 struct scb *scb; in ahd_find_scb_by_tag() local
6515 LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) { in ahd_find_scb_by_tag()
6516 if (SCB_GET_TAG(scb) == tag) in ahd_find_scb_by_tag()
6517 return (scb); in ahd_find_scb_by_tag()
6523 TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) { in ahd_find_scb_by_tag()
6524 struct scb *list_scb; in ahd_find_scb_by_tag()
6526 list_scb = scb; in ahd_find_scb_by_tag()
6537 LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) { in ahd_find_scb_by_tag()
6538 if (SCB_GET_TAG(scb) == tag) in ahd_find_scb_by_tag()
6539 return (scb); in ahd_find_scb_by_tag()
6664 ahd_add_col_list(struct ahd_softc *ahd, struct scb *scb, u_int col_idx) in ahd_add_col_list() argument
6668 struct scb *first_scb; in ahd_add_col_list()
6670 scb->flags |= SCB_ON_COL_LIST; in ahd_add_col_list()
6671 AHD_SET_SCB_COL_IDX(scb, col_idx); in ahd_add_col_list()
6676 LIST_INSERT_AFTER(first_scb, scb, collision_links); in ahd_add_col_list()
6678 LIST_INSERT_HEAD(free_list, scb, collision_links); in ahd_add_col_list()
6679 TAILQ_INSERT_TAIL(free_tailq, scb, links.tqe); in ahd_add_col_list()
6684 ahd_rem_col_list(struct ahd_softc *ahd, struct scb *scb) in ahd_rem_col_list() argument
6688 struct scb *first_scb; in ahd_rem_col_list()
6691 scb->flags &= ~SCB_ON_COL_LIST; in ahd_rem_col_list()
6692 col_idx = AHD_GET_SCB_COL_IDX(ahd, scb); in ahd_rem_col_list()
6696 if (first_scb == scb) { in ahd_rem_col_list()
6697 struct scb *next_scb; in ahd_rem_col_list()
6704 next_scb = LIST_NEXT(scb, collision_links); in ahd_rem_col_list()
6706 TAILQ_INSERT_AFTER(free_tailq, scb, in ahd_rem_col_list()
6709 TAILQ_REMOVE(free_tailq, scb, links.tqe); in ahd_rem_col_list()
6711 LIST_REMOVE(scb, collision_links); in ahd_rem_col_list()
6717 struct scb *
6720 struct scb *scb; in ahd_get_scb() local
6725 TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) { in ahd_get_scb()
6726 if (AHD_GET_SCB_COL_IDX(ahd, scb) != col_idx) { in ahd_get_scb()
6727 ahd_rem_col_list(ahd, scb); in ahd_get_scb()
6731 if ((scb = LIST_FIRST(&ahd->scb_data.any_dev_free_scb_list)) == NULL) { in ahd_get_scb()
6738 LIST_REMOVE(scb, links.le); in ahd_get_scb()
6740 && (scb->col_scb != NULL) in ahd_get_scb()
6741 && (scb->col_scb->flags & SCB_ACTIVE) == 0) { in ahd_get_scb()
6742 LIST_REMOVE(scb->col_scb, links.le); in ahd_get_scb()
6743 ahd_add_col_list(ahd, scb->col_scb, col_idx); in ahd_get_scb()
6746 scb->flags |= SCB_ACTIVE; in ahd_get_scb()
6747 return (scb); in ahd_get_scb()
6754 ahd_free_scb(struct ahd_softc *ahd, struct scb *scb) in ahd_free_scb() argument
6757 scb->flags = SCB_FLAG_NONE; in ahd_free_scb()
6758 scb->hscb->control = 0; in ahd_free_scb()
6759 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = NULL; in ahd_free_scb()
6761 if (scb->col_scb == NULL) { in ahd_free_scb()
6767 scb, links.le); in ahd_free_scb()
6768 } else if ((scb->col_scb->flags & SCB_ON_COL_LIST) != 0) { in ahd_free_scb()
6775 ahd_rem_col_list(ahd, scb->col_scb); in ahd_free_scb()
6777 scb, links.le); in ahd_free_scb()
6779 scb->col_scb, links.le); in ahd_free_scb()
6780 } else if ((scb->col_scb->flags in ahd_free_scb()
6782 && (scb->col_scb->hscb->control & TAG_ENB) != 0) { in ahd_free_scb()
6789 ahd_add_col_list(ahd, scb, in ahd_free_scb()
6790 AHD_GET_SCB_COL_IDX(ahd, scb->col_scb)); in ahd_free_scb()
6799 scb, links.le); in ahd_free_scb()
6802 ahd_platform_scb_free(ahd, scb); in ahd_free_scb()
6809 struct scb *next_scb; in ahd_alloc_scbs()
8043 ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, int target, in ahd_match_scb() argument
8046 int targ = SCB_GET_TARGET(ahd, scb); in ahd_match_scb()
8047 char chan = SCB_GET_CHANNEL(ahd, scb); in ahd_match_scb()
8048 int slun = SCB_GET_LUN(scb); in ahd_match_scb()
8060 group = XPT_FC_GROUP(scb->io_ctx->ccb_h.func_code); in ahd_match_scb()
8063 && ((tag == SCB_GET_TAG(scb)) in ahd_match_scb()
8067 && ((tag == scb->io_ctx->csio.tag_id) in ahd_match_scb()
8071 match = ((tag == SCB_GET_TAG(scb)) || (tag == SCB_LIST_NULL)); in ahd_match_scb()
8079 ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb) in ahd_freeze_devq() argument
8085 target = SCB_GET_TARGET(ahd, scb); in ahd_freeze_devq()
8086 lun = SCB_GET_LUN(scb); in ahd_freeze_devq()
8087 channel = SCB_GET_CHANNEL(ahd, scb); in ahd_freeze_devq()
8093 ahd_platform_freeze_devq(ahd, scb); in ahd_freeze_devq()
8097 ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, struct scb *scb) in ahd_qinfifo_requeue_tail() argument
8099 struct scb *prev_scb; in ahd_qinfifo_requeue_tail()
8113 ahd_qinfifo_requeue(ahd, prev_scb, scb); in ahd_qinfifo_requeue_tail()
8119 ahd_qinfifo_requeue(struct ahd_softc *ahd, struct scb *prev_scb, in ahd_qinfifo_requeue()
8120 struct scb *scb) in ahd_qinfifo_requeue() argument
8125 busaddr = ahd_le32toh(scb->hscb->hscb_busaddr); in ahd_qinfifo_requeue()
8128 prev_scb->hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr; in ahd_qinfifo_requeue()
8132 ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb); in ahd_qinfifo_requeue()
8134 scb->hscb->next_hscb_busaddr = ahd->next_queued_hscb->hscb_busaddr; in ahd_qinfifo_requeue()
8135 ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); in ahd_qinfifo_requeue()
8159 struct scb *scb; in ahd_reset_cmds_pending() local
8173 LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) { in ahd_reset_cmds_pending()
8182 ahd_done_with_status(struct ahd_softc *ahd, struct scb *scb, uint32_t status) in ahd_done_with_status() argument
8187 ostat = ahd_get_transaction_status(scb); in ahd_done_with_status()
8189 ahd_set_transaction_status(scb, status); in ahd_done_with_status()
8190 cstat = ahd_get_transaction_status(scb); in ahd_done_with_status()
8192 ahd_freeze_scb(scb); in ahd_done_with_status()
8193 ahd_done(ahd, scb); in ahd_done_with_status()
8201 struct scb *scb; in ahd_search_qinfifo() local
8202 struct scb *mk_msg_scb; in ahd_search_qinfifo()
8203 struct scb *prev_scb; in ahd_search_qinfifo()
8253 scb = ahd_lookup_scb(ahd, ahd->qinfifo[qinpos]); in ahd_search_qinfifo()
8254 if (scb == NULL) { in ahd_search_qinfifo()
8260 if (ahd_match_scb(ahd, scb, target, channel, lun, tag, role)) { in ahd_search_qinfifo()
8267 if ((scb->flags & SCB_ACTIVE) == 0) in ahd_search_qinfifo()
8269 ahd_done_with_status(ahd, scb, status); in ahd_search_qinfifo()
8277 ahd_qinfifo_requeue(ahd, prev_scb, scb); in ahd_search_qinfifo()
8278 prev_scb = scb; in ahd_search_qinfifo()
8282 ahd_qinfifo_requeue(ahd, prev_scb, scb); in ahd_search_qinfifo()
8283 prev_scb = scb; in ahd_search_qinfifo()
8325 scb = ahd_lookup_scb(ahd, scbid); in ahd_search_qinfifo()
8326 if (scb == NULL) { in ahd_search_qinfifo()
8333 if (ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD, in ahd_search_qinfifo()
8343 printk(" %d ( ", SCB_GET_TARGET(ahd, scb)); in ahd_search_qinfifo()
8348 SCB_GET_TARGET(ahd, scb)); in ahd_search_qinfifo()
8389 printk(" 0x%x", SCB_GET_TAG(scb)); in ahd_search_qinfifo()
8398 && ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD, in ahd_search_qinfifo()
8432 struct scb *scb; in ahd_search_scb_list() local
8451 scb = ahd_lookup_scb(ahd, scbid); in ahd_search_scb_list()
8452 if (scb == NULL) { in ahd_search_scb_list()
8460 if (ahd_match_scb(ahd, scb, target, channel, in ahd_search_scb_list()
8468 if ((scb->flags & SCB_ACTIVE) == 0) in ahd_search_scb_list()
8470 ahd_done_with_status(ahd, scb, status); in ahd_search_scb_list()
8586 struct scb *scbp; in ahd_abort_scbs()
8587 struct scb *scbp_next; in ahd_abort_scbs()
8918 ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb) in ahd_handle_scsi_status() argument
8932 hscb = scb->hscb; in ahd_handle_scsi_status()
8942 ahd_freeze_devq(ahd, scb); in ahd_handle_scsi_status()
8943 ahd_freeze_scb(scb); in ahd_handle_scsi_status()
8951 if ((scb->flags & SCB_SENSE) != 0) { in ahd_handle_scsi_status()
8956 scb->flags &= ~SCB_SENSE; in ahd_handle_scsi_status()
8957 ahd_set_transaction_status(scb, CAM_AUTOSENSE_FAIL); in ahd_handle_scsi_status()
8958 ahd_done(ahd, scb); in ahd_handle_scsi_status()
8961 ahd_set_transaction_status(scb, CAM_SCSI_STATUS_ERROR); in ahd_handle_scsi_status()
8962 ahd_set_scsi_status(scb, hscb->shared_data.istatus.scsi_status); in ahd_handle_scsi_status()
8968 ahd_sync_sense(ahd, scb, BUS_DMASYNC_POSTREAD); in ahd_handle_scsi_status()
8969 siu = (struct scsi_status_iu_header *)scb->sense_data; in ahd_handle_scsi_status()
8970 ahd_set_scsi_status(scb, siu->status); in ahd_handle_scsi_status()
8973 ahd_print_path(ahd, scb); in ahd_handle_scsi_status()
8975 SCB_GET_TAG(scb), siu->status); in ahd_handle_scsi_status()
8983 ahd_print_path(ahd, scb); in ahd_handle_scsi_status()
9011 ahd_set_transaction_status(scb, in ahd_handle_scsi_status()
9015 scb->flags |= SCB_PKT_SENSE; in ahd_handle_scsi_status()
9021 ahd_done(ahd, scb); in ahd_handle_scsi_status()
9035 ahd_print_path(ahd, scb); in ahd_handle_scsi_status()
9037 SCB_GET_TAG(scb)); in ahd_handle_scsi_status()
9041 if (ahd_perform_autosense(scb) == 0) in ahd_handle_scsi_status()
9044 ahd_compile_devinfo(&devinfo, SCB_GET_OUR_ID(scb), in ahd_handle_scsi_status()
9045 SCB_GET_TARGET(ahd, scb), in ahd_handle_scsi_status()
9046 SCB_GET_LUN(scb), in ahd_handle_scsi_status()
9047 SCB_GET_CHANNEL(ahd, scb), in ahd_handle_scsi_status()
9055 sg = scb->sg_list; in ahd_handle_scsi_status()
9060 ahd_update_residual(ahd, scb); in ahd_handle_scsi_status()
9063 ahd_print_path(ahd, scb); in ahd_handle_scsi_status()
9067 scb->sg_count = 0; in ahd_handle_scsi_status()
9068 sg = ahd_sg_setup(ahd, scb, sg, ahd_get_sense_bufaddr(ahd, scb), in ahd_handle_scsi_status()
9069 ahd_get_sense_bufsize(ahd, scb), in ahd_handle_scsi_status()
9074 && SCB_GET_LUN(scb) < 8) in ahd_handle_scsi_status()
9075 sc->byte2 = SCB_GET_LUN(scb) << 5; in ahd_handle_scsi_status()
9078 sc->length = ahd_get_sense_bufsize(ahd, scb); in ahd_handle_scsi_status()
9098 if (ahd_get_residual(scb) == ahd_get_transfer_length(scb)) { in ahd_handle_scsi_status()
9105 scb->flags &= in ahd_handle_scsi_status()
9107 scb->flags |= SCB_AUTO_NEGOTIATE; in ahd_handle_scsi_status()
9110 ahd_setup_data_scb(ahd, scb); in ahd_handle_scsi_status()
9111 scb->flags |= SCB_SENSE; in ahd_handle_scsi_status()
9112 ahd_queue_scb(ahd, scb); in ahd_handle_scsi_status()
9120 ahd_done(ahd, scb); in ahd_handle_scsi_status()
9126 ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb) in ahd_handle_scb_status() argument
9128 if (scb->hscb->shared_data.istatus.scsi_status != 0) { in ahd_handle_scb_status()
9129 ahd_handle_scsi_status(ahd, scb); in ahd_handle_scb_status()
9131 ahd_calc_residual(ahd, scb); in ahd_handle_scb_status()
9132 ahd_done(ahd, scb); in ahd_handle_scb_status()
9140 ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb) in ahd_calc_residual() argument
9164 hscb = scb->hscb; in ahd_calc_residual()
9185 resid = ahd_get_transfer_length(scb); in ahd_calc_residual()
9190 ahd_print_path(ahd, scb); in ahd_calc_residual()
9192 SCB_GET_TAG(scb)); in ahd_calc_residual()
9193 ahd_freeze_devq(ahd, scb); in ahd_calc_residual()
9194 ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR); in ahd_calc_residual()
9195 ahd_freeze_scb(scb); in ahd_calc_residual()
9208 sg = ahd_sg_bus_to_virt(ahd, scb, resid_sgptr & SG_PTR_MASK); in ahd_calc_residual()
9223 if ((scb->flags & SCB_SENSE) == 0) in ahd_calc_residual()
9224 ahd_set_residual(scb, resid); in ahd_calc_residual()
9226 ahd_set_sense_residual(scb, resid); in ahd_calc_residual()
9230 ahd_print_path(ahd, scb); in ahd_calc_residual()
9232 (scb->flags & SCB_SENSE) ? "Sense " : "", resid); in ahd_calc_residual()
9731 struct scb *scb; in ahd_dump_card_state() local
9814 LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) { in ahd_dump_card_state()
9817 cur_col = printk("\n%3d FIFO_USE[0x%x] ", SCB_GET_TAG(scb), in ahd_dump_card_state()
9819 ahd_set_scbptr(ahd, SCB_GET_TAG(scb)); in ahd_dump_card_state()
9829 TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) { in ahd_dump_card_state()
9830 struct scb *list_scb; in ahd_dump_card_state()
9832 list_scb = scb; in ahd_dump_card_state()
9839 LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) { in ahd_dump_card_state()
9842 printk("%d ", SCB_GET_TAG(scb)); in ahd_dump_card_state()
9889 struct scb *fifo_scb; in ahd_dump_card_state()
10524 struct scb *scb; in ahd_handle_en_lun() local
10535 LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) { in ahd_handle_en_lun()
10538 ccbh = &scb->io_ctx->ccb_h; in ahd_handle_en_lun()