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