Lines Matching defs:scb
165 struct scb *scb);
168 struct scb *scb);
204 struct scb *scb);
211 struct scb * ahd_find_scb_by_tag(struct ahd_softc *, u_int);
217 struct scb *prev_scb,
218 struct scb *scb);
249 struct scb *scb);
251 struct scb *scb);
402 struct scb *scb;
421 scb = ahd_lookup_scb(ahd, scbid);
422 if (scb == NULL) {
439 if (ahd_scb_active_in_fifo(ahd, scb) == 0)
442 ahd_run_data_fifo(ahd, scb);
495 ahd_complete_scb(ahd, scb);
545 scb = ahd_lookup_scb(ahd, scbid);
546 if (scb == NULL) {
551 hscb_ptr = (uint8_t *)scb->hscb;
555 ahd_complete_scb(ahd, scb);
566 scb = ahd_lookup_scb(ahd, scbid);
567 if (scb == NULL) {
573 ahd_complete_scb(ahd, scb);
583 scb = ahd_lookup_scb(ahd, scbid);
584 if (scb == NULL) {
590 ahd_complete_scb(ahd, scb);
608 ahd_scb_active_in_fifo(struct ahd_softc *ahd, struct scb *scb)
617 if (ahd_get_scbptr(ahd) != SCB_GET_TAG(scb)
637 ahd_run_data_fifo(struct ahd_softc *ahd, struct scb *scb)
791 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
798 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
874 struct scb *scb;
888 scb = ahd_lookup_scb(ahd, scb_index);
889 if (scb == NULL) {
890 printf("%s: WARNING no command for scb %d "
896 ahd_handle_scb_status(ahd, scb);
898 ahd_done(ahd, scb);
971 struct scb *scb;
977 scb = ahd_lookup_scb(ahd, scbid);
978 if (scb == NULL) {
986 ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid);
987 ahd_outb(ahd, SAVED_LUN, scb->hscb->lun);
1017 struct scb *scb;
1021 scb = ahd_lookup_scb(ahd, scbid);
1022 if (scb != NULL)
1023 ahd_print_path(ahd, scb);
1033 struct scb *scb;
1037 scb = ahd_lookup_scb(ahd, scbid);
1038 if (scb == NULL) {
1043 ahd_outq(ahd, HADDR, scb->sense_busaddr);
1072 struct scb *scb;
1089 scb = ahd_lookup_scb(ahd, scbid);
1090 if (scb == NULL) {
1097 ahd_compile_devinfo(&devinfo, SCB_GET_OUR_ID(scb),
1098 SCB_GET_TARGET(ahd, scb),
1099 SCB_GET_LUN(scb),
1100 SCB_GET_CHANNEL(ahd, scb),
1119 scb->hscb->control &= ~(TAG_ENB|SCB_TAG_TYPE);
1120 scb->hscb->control |= MK_MESSAGE;
1121 ahd_outb(ahd, SCB_CONTROL, scb->hscb->control);
1123 ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid);
1131 scb->flags &= ~SCB_PACKETIZED;
1132 scb->flags |= SCB_ABORT|SCB_CMDPHASE_ABORT;
1133 ahd_freeze_devq(ahd, scb);
1134 aic_set_transaction_status(scb, CAM_REQUEUE_REQ);
1135 aic_freeze_scb(scb);
1148 ahd_print_path(ahd, scb);
1160 struct scb *scb;
1170 scb = ahd_lookup_scb(ahd, scb_index);
1171 if (scb == NULL) {
1227 struct scb *scb;
1247 scb = ahd_lookup_scb(ahd, scb_index);
1252 scb);
1269 scb);
1363 struct scb *scb;
1370 scb = ahd_lookup_scb(ahd, scbindex);
1374 ahd_print_path(ahd, scb);
1377 SCB_GET_TAG(scb));
1378 ahd_print_path(ahd, scb);
1383 aic_get_transfer_length(scb), scb->sg_count);
1384 ahd_dump_sglist(scb);
1392 ahd_freeze_devq(ahd, scb);
1393 aic_set_transaction_status(scb, CAM_DATA_RUN_ERR);
1394 aic_freeze_scb(scb);
1400 struct scb *scb;
1408 scb = ahd_lookup_scb(ahd, scbid);
1409 if (scb != NULL)
1414 ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
1415 SCB_GET_CHANNEL(ahd, scb),
1416 SCB_GET_LUN(scb), SCB_GET_TAG(scb),
1426 struct scb *scb;
1429 scb = ahd_lookup_scb(ahd, scbid);
1430 if (scb != NULL) {
1435 ahd_print_path(ahd, scb);
1437 scb->hscb->task_management);
1441 switch (scb->hscb->task_management) {
1443 tag = SCB_GET_TAG(scb);
1446 lun = scb->hscb->lun;
1448 ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb),
1453 lun = scb->hscb->lun;
1458 ahd_scb_devinfo(ahd, &devinfo, scb);
1478 struct scb *scb;
1485 scb = ahd_lookup_scb(ahd, scbid);
1486 if (scb != NULL) {
1491 ahd_print_path(ahd, scb);
1505 ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
1506 SCB_GET_CHANNEL(ahd, scb),
1507 SCB_GET_LUN(scb), SCB_GET_TAG(scb),
1541 struct scb *scb;
1568 scb = ahd_lookup_scb(ahd, scbid);
1569 if (scb != NULL
1571 scb = NULL;
1633 scb = ahd_lookup_scb(ahd, scbid);
1634 if (scb == NULL) {
1635 printf("%s: ahd_intr - referenced scb not "
1636 "valid during SELTO scb(0x%x)\n",
1643 ahd_print_path(ahd, scb);
1648 ahd_scb_devinfo(ahd, &devinfo, scb);
1649 aic_set_transaction_status(scb, CAM_SEL_TIMEOUT);
1650 ahd_freeze_devq(ahd, scb);
1722 scb = ahd_lookup_scb(ahd, scbid);
1723 if (scb == NULL) {
1729 packetized = (scb->flags & SCB_PACKETIZED) != 0;
1808 struct scb *scb;
1819 scb = NULL;
1858 scb = ahd_lookup_scb(ahd, scbid);
1859 if (scb != NULL && SCB_IS_SILENT(scb))
1954 if (scb == NULL) {
1985 if (scb != NULL && msg_out == MSG_INITIATOR_DET_ERR)
1986 scb->flags |= SCB_TRANSMISSION_ERROR;
2043 struct scb *scb;
2067 scb = ahd_lookup_scb(ahd, scbid);
2068 if (scb == NULL)
2109 if (scb->crc_retry_count < AHD_MAX_LQ_CRC_ERRORS) {
2110 if (SCB_IS_SILENT(scb) == FALSE) {
2111 ahd_print_path(ahd, scb);
2115 scb->crc_retry_count++;
2117 aic_set_transaction_status(scb, CAM_UNCOR_PARITY);
2118 aic_freeze_scb(scb);
2119 ahd_freeze_devq(ahd, scb);
2143 struct scb *scb;
2146 scb = ahd_lookup_scb(ahd, scbid);
2147 ahd_print_path(ahd, scb);
2150 ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), 'A',
2151 SCB_GET_LUN(scb), SCB_GET_TAG(scb),
2170 struct scb *scb;
2195 scb = ahd_lookup_scb(ahd, scbid);
2196 if (scb != NULL
2198 scb = NULL;
2210 if (scb == NULL) {
2218 ahd_print_path(ahd, scb);
2220 SCB_GET_TAG(scb),
2224 tag = SCB_GET_TAG(scb);
2226 if ((scb->flags & SCB_CMDPHASE_ABORT) != 0) {
2239 tag = SCB_GET_TAG(scb);
2240 saved_lun = scb->hscb->lun;
2254 if (scb != NULL
2255 && scb->io_ctx->ccb_h.func_code== XPT_RESET_DEV
2256 && ahd_match_scb(ahd, scb, target, 'A',
2259 aic_set_transaction_status(scb, CAM_REQ_CMP);
2311 ahd_freeze_devq(ahd, scb);
2312 ahd_qinfifo_requeue_tail(ahd, scb);
2334 ahd_freeze_devq(ahd, scb);
2335 ahd_qinfifo_requeue_tail(ahd, scb);
2357 ahd_freeze_devq(ahd, scb);
2358 ahd_qinfifo_requeue_tail(ahd, scb);
2389 && (scb != NULL)) {
2391 ahd_freeze_devq(ahd, scb);
2392 aic_set_transaction_status(scb, CAM_REQUEUE_REQ);
2393 aic_freeze_scb(scb);
2395 ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb),
2396 SCB_GET_CHANNEL(ahd, scb),
2397 SCB_GET_LUN(scb), SCB_LIST_NULL,
2404 ahd_done(ahd, scb);
2412 if (scb != NULL) {
2415 if ((scb->hscb->control & TAG_ENB) != 0)
2416 tag = SCB_GET_TAG(scb);
2419 ahd_print_path(ahd, scb);
2421 SCB_GET_LUN(scb), tag,
2448 struct scb *scb;
2457 scb = ahd_lookup_scb(ahd, scbid);
2471 scb = NULL;
2472 } else if (scb == NULL) {
2481 aic_set_transaction_status(scb, CAM_SEQUENCE_FAIL);
2483 ahd_print_path(ahd, scb);
2494 ahd_print_path(ahd, scb);
2497 ahd_print_path(ahd, scb);
2524 if (scb == NULL) {
2531 ahd_print_path(ahd, scb);
2532 scb->flags |= SCB_ABORT;
2720 ahd_print_scb(struct scb *scb)
2725 hscb = scb->hscb;
2726 printf("scb:%p control:0x%x scsiid:0x%x lun:%d cdb_len:%d\n",
2727 (void *)scb,
2740 SCB_GET_TAG(scb));
2741 ahd_dump_sglist(scb);
2745 ahd_dump_sglist(struct scb *scb)
2749 if (scb->sg_count > 0) {
2750 if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
2753 sg_list = (struct ahd_dma64_seg*)scb->sg_list;
2754 for (i = 0; i < scb->sg_count; i++) {
2771 sg_list = (struct ahd_dma_seg*)scb->sg_list;
2772 for (i = 0; i < scb->sg_count; i++) {
3379 struct scb *pending_scb;
3536 struct scb *scb)
3541 our_id = SCSIID_OUR_ID(scb->hscb->scsiid);
3543 if ((scb->hscb->control & TARGET_SCB) != 0)
3545 ahd_compile_devinfo(devinfo, our_id, SCB_GET_TARGET(ahd, scb),
3546 SCB_GET_LUN(scb), SCB_GET_CHANNEL(ahd, scb), role);
3559 struct scb *scb)
3582 } else if (scb == NULL) {
3591 if ((scb->flags & SCB_DEVICE_RESET) == 0
3592 && (scb->flags & SCB_PACKETIZED) == 0
3596 identify_msg = MSG_IDENTIFYFLAG | SCB_GET_LUN(scb);
3597 if ((scb->hscb->control & DISCENB) != 0)
3602 if ((scb->hscb->control & TAG_ENB) != 0) {
3604 scb->hscb->control & (TAG_ENB|SCB_TAG_TYPE);
3605 ahd->msgout_buf[ahd->msgout_index++] = SCB_GET_TAG(scb);
3610 if (scb->flags & SCB_DEVICE_RESET) {
3613 ahd_print_path(ahd, scb);
3623 } else if ((scb->flags & SCB_ABORT) != 0) {
3625 if ((scb->hscb->control & TAG_ENB) != 0) {
3631 ahd_print_path(ahd, scb);
3633 (scb->hscb->control & TAG_ENB) != 0 ? " Tag" : "");
3642 } else if ((scb->flags & (SCB_AUTO_NEGOTIATE|SCB_NEGOTIATE)) != 0) {
3655 printf("SCSIID = %x, target_mask = %x\n", scb->hscb->scsiid,
3658 "SCB flags = %x", SCB_GET_TAG(scb), scb->hscb->control,
3660 scb->flags);
3669 scb->hscb->control &= ~MK_MESSAGE;
4695 struct scb *scb;
4703 scb = ahd_lookup_scb(ahd, scb_index);
4783 } else if ((scb->hscb->control & MSG_SIMPLE_TASK) != 0) {
4787 tag_type = (scb->hscb->control & MSG_SIMPLE_TASK);
4811 scb->hscb->control &= mask;
4812 aic_set_transaction_tag(scb, /*enabled*/FALSE,
4816 ahd_busy_tcl(ahd, BUILD_TCL(scb->hscb->scsiid, devinfo->lun),
4817 SCB_GET_TAG(scb));
4824 ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
4825 SCB_GET_CHANNEL(ahd, scb),
4826 SCB_GET_LUN(scb), /*tag*/SCB_LIST_NULL,
4861 struct scb *scb;
4864 scb = ahd_lookup_scb(ahd, scb_index);
4870 || aic_get_transfer_dir(scb) != CAM_DIR_IN) {
4918 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
4926 if (sg != scb->sg_list
4945 sgptr = ahd_sg_virt_to_bus(ahd, scb,
4951 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
4959 if (sg != scb->sg_list
4978 sgptr = ahd_sg_virt_to_bus(ahd, scb,
5010 struct scb *scb;
5022 scb = ahd_lookup_scb(ahd, scb_index);
5033 ahd_print_path(ahd, scb);
5057 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
5069 sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
5158 struct scb *scb)
5169 if (scb != NULL && (scb->flags & SCB_AUTO_NEGOTIATE) != 0)
5272 printf("%s: scb size = 0x%x, hscb size = 0x%x\n",
5273 ahd_name(ahd), (u_int)sizeof(struct scb),
5653 struct scb *
5656 struct scb *scb;
5661 TAILQ_FOREACH(scb, &ahd->pending_scbs, next) {
5662 if (SCB_GET_TAG(scb) == tag)
5663 return (scb);
5669 TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, next) {
5670 if (SCB_GET_TAG(scb) == tag)
5671 return (scb);
5779 * Get a free scb. If there are none, see if we can allocate a new SCB.
5785 struct scb *scb;
5788 scb = TAILQ_FIRST(&ahd->scb_data.free_scbs);
5789 if (scb) {
5790 TAILQ_REMOVE(&ahd->scb_data.free_scbs, scb, next);
5791 scb->flags |= SCB_ACTIVE;
5795 return (scb);
5805 struct scb *scb = xscb;
5808 scb->flags = SCB_FLAG_NONE;
5809 scb->hscb->control = 0;
5810 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = NULL;
5813 TAILQ_INSERT_HEAD(&ahd->scb_data.free_scbs, scb, next);
5814 aic_platform_scb_free(ahd, scb);
5822 struct scb *next_scb;
5947 next_scb = (struct scb *)malloc(sizeof(*next_scb),
5966 * The first entry is embedded in the scb.
6944 ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, int target,
6947 int targ = SCB_GET_TARGET(ahd, scb);
6948 char chan = SCB_GET_CHANNEL(ahd, scb);
6949 int slun = SCB_GET_LUN(scb);
6961 group = XPT_FC_GROUP(scb->io_ctx->ccb_h.func_code);
6964 && ((tag == SCB_GET_TAG(scb))
6968 && ((tag == scb->io_ctx->csio.tag_id)
6972 match = ((tag == SCB_GET_TAG(scb)) || (tag == SCB_LIST_NULL));
6980 ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb)
6986 target = SCB_GET_TARGET(ahd, scb);
6987 lun = SCB_GET_LUN(scb);
6988 channel = SCB_GET_CHANNEL(ahd, scb);
6996 ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, struct scb *scb)
6998 struct scb *prev_scb;
7012 ahd_qinfifo_requeue(ahd, prev_scb, scb);
7018 ahd_qinfifo_requeue(struct ahd_softc *ahd, struct scb *prev_scb,
7019 struct scb *scb)
7024 busaddr = aic_le32toh(scb->hscb->hscb_busaddr);
7027 prev_scb->hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr;
7031 ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb);
7033 scb->hscb->next_hscb_busaddr = ahd->next_queued_hscb->hscb_busaddr;
7034 ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
7058 struct scb *scb;
7072 TAILQ_FOREACH(scb, &ahd->pending_scbs, next) {
7081 ahd_done_with_status(struct ahd_softc *ahd, struct scb *scb, uint32_t status)
7086 ostat = aic_get_transaction_status(scb);
7088 aic_set_transaction_status(scb, status);
7089 cstat = aic_get_transaction_status(scb);
7091 aic_freeze_scb(scb);
7092 ahd_done(ahd, scb);
7100 struct scb *scb;
7101 struct scb *mk_msg_scb;
7102 struct scb *prev_scb;
7152 scb = ahd_lookup_scb(ahd, ahd->qinfifo[qinpos]);
7153 if (scb == NULL) {
7159 if (ahd_match_scb(ahd, scb, target, channel, lun, tag, role)) {
7161 * We found an scb that needs to be acted on.
7166 if ((scb->flags & SCB_ACTIVE) == 0)
7168 ahd_done_with_status(ahd, scb, status);
7176 ahd_qinfifo_requeue(ahd, prev_scb, scb);
7177 prev_scb = scb;
7181 ahd_qinfifo_requeue(ahd, prev_scb, scb);
7182 prev_scb = scb;
7224 scb = ahd_lookup_scb(ahd, scbid);
7225 if (scb == NULL) {
7232 if (ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD,
7242 printf(" %d ( ", SCB_GET_TARGET(ahd, scb));
7247 SCB_GET_TARGET(ahd, scb));
7257 * We found an scb that needs to be acted on.
7270 printf("Removing MK_MSG scb\n");
7288 printf(" 0x%x", SCB_GET_TAG(scb));
7297 && ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD,
7302 * queue with a pending MK_MESSAGE scb, we
7303 * must queue the MK_MESSAGE scb.
7331 struct scb *scb;
7350 scb = ahd_lookup_scb(ahd, scbid);
7351 if (scb == NULL) {
7359 if (ahd_match_scb(ahd, scb, target, channel,
7367 if ((scb->flags & SCB_ACTIVE) == 0)
7369 ahd_done_with_status(ahd, scb, status);
7428 * scb that follows the one that we remove.
7485 struct scb *scbp;
7486 struct scb *scbp_next;
7844 ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
7846 if (scb->hscb->shared_data.istatus.scsi_status != 0) {
7847 ahd_handle_scsi_status(ahd, scb);
7849 ahd_calc_residual(ahd, scb);
7850 ahd_done(ahd, scb);
7855 ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
7869 hscb = scb->hscb;
7879 ahd_freeze_devq(ahd, scb);
7880 aic_freeze_scb(scb);
7888 if ((scb->flags & SCB_SENSE) != 0) {
7893 scb->flags &= ~SCB_SENSE;
7894 aic_set_transaction_status(scb, CAM_AUTOSENSE_FAIL);
7895 ahd_done(ahd, scb);
7898 aic_set_transaction_status(scb, CAM_SCSI_STATUS_ERROR);
7899 aic_set_scsi_status(scb, hscb->shared_data.istatus.scsi_status);
7905 ahd_sync_sense(ahd, scb, BUS_DMASYNC_POSTREAD);
7906 siu = (struct scsi_status_iu_header *)scb->sense_data;
7907 aic_set_scsi_status(scb, siu->status);
7910 ahd_print_path(ahd, scb);
7912 SCB_GET_TAG(scb), siu->status);
7920 ahd_print_path(ahd, scb);
7948 aic_set_transaction_status(scb,
7952 scb->flags |= SCB_PKT_SENSE;
7958 ahd_done(ahd, scb);
7972 ahd_print_path(ahd, scb);
7974 SCB_GET_TAG(scb));
7978 if (aic_perform_autosense(scb) == 0)
7981 ahd_compile_devinfo(&devinfo, SCB_GET_OUR_ID(scb),
7982 SCB_GET_TARGET(ahd, scb),
7983 SCB_GET_LUN(scb),
7984 SCB_GET_CHANNEL(ahd, scb),
7992 sg = scb->sg_list;
7997 ahd_update_residual(ahd, scb);
8000 ahd_print_path(ahd, scb);
8004 scb->sg_count = 0;
8005 sg = ahd_sg_setup(ahd, scb, sg, ahd_get_sense_bufaddr(ahd, scb),
8006 aic_get_sense_bufsize(ahd, scb),
8011 && SCB_GET_LUN(scb) < 8)
8012 sc->byte2 = SCB_GET_LUN(scb) << 5;
8015 sc->length = aic_get_sense_bufsize(ahd, scb);
8035 if (aic_get_residual(scb) == aic_get_transfer_length(scb)) {
8042 scb->flags &=
8044 scb->flags |= SCB_AUTO_NEGOTIATE;
8047 ahd_setup_data_scb(ahd, scb);
8048 scb->flags |= SCB_SENSE;
8049 ahd_queue_scb(ahd, scb);
8057 aic_scb_timer_reset(scb, 5 * 1000);
8065 ahd_done(ahd, scb);
8074 ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb)
8098 hscb = scb->hscb;
8119 resid = aic_get_transfer_length(scb);
8124 ahd_print_path(ahd, scb);
8126 SCB_GET_TAG(scb));
8127 ahd_freeze_devq(ahd, scb);
8128 aic_set_transaction_status(scb, CAM_DATA_RUN_ERR);
8129 aic_freeze_scb(scb);
8142 sg = ahd_sg_bus_to_virt(ahd, scb, resid_sgptr & SG_PTR_MASK);
8157 if ((scb->flags & SCB_SENSE) == 0)
8158 aic_set_residual(scb, resid);
8160 aic_set_sense_residual(scb, resid);
8164 ahd_print_path(ahd, scb);
8166 (scb->flags & SCB_SENSE) ? "Sense " : "", resid);
8674 struct scb *scb;
8757 TAILQ_FOREACH(scb, &ahd->pending_scbs, next) {
8760 cur_col = printf("\n%3d FIFO_USE[0x%x] ", SCB_GET_TAG(scb),
8762 ahd_set_scbptr(ahd, SCB_GET_TAG(scb));
8772 TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, next) {
8773 printf("%d ", SCB_GET_TAG(scb));
8820 struct scb *fifo_scb;
8953 struct scb *scb, *list_scb;
8962 scb = (struct scb *)arg;
8963 ahd = scb->ahd_softc;
8970 SCB_GET_TAG(scb), was_paused ? "" : "not ");
8976 if (scb->flags & SCB_ACTIVE) {
8977 aic_set_transaction_status(scb, CAM_CMD_TIMEOUT);
8987 channel = SCB_GET_CHANNEL(ahd, scb);
9506 struct scb *scb;
9517 TAILQ_FOREACH(scb, &ahd->pending_scbs, next) {
9520 ccbh = &scb->io_ctx->ccb_h;
10026 ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
10029 scb->sg_count++;
10050 ahd_setup_scb_common(struct ahd_softc *ahd, struct scb *scb)
10053 scb->crc_retry_count = 0;
10054 if ((scb->flags & SCB_PACKETIZED) != 0) {
10056 scb->hscb->task_attribute = scb->hscb->control & SCB_TAG_TYPE;
10058 if (aic_get_transfer_length(scb) & 0x01)
10059 scb->hscb->task_attribute = SCB_XFERLEN_ODD;
10061 scb->hscb->task_attribute = 0;
10064 if (scb->hscb->cdb_len <= MAX_CDB_LEN_WITH_SENSE_ADDR
10065 || (scb->hscb->cdb_len & SCB_CDB_LEN_PTR) != 0)
10066 scb->hscb->shared_data.idata.cdb_plus_saddr.sense_addr =
10067 aic_htole32(scb->sense_busaddr);
10071 ahd_setup_data_scb(struct ahd_softc *ahd, struct scb *scb)
10079 sg = (struct ahd_dma64_seg *)scb->sg_list;
10080 scb->hscb->dataptr = sg->addr;
10081 scb->hscb->datacnt = sg->len;
10086 sg = (struct ahd_dma_seg *)scb->sg_list;
10087 dataptr_words = (uint32_t*)&scb->hscb->dataptr;
10094 scb->hscb->dataptr |= aic_htole64(high_addr << 8);
10096 scb->hscb->datacnt = sg->len;
10104 scb->hscb->sgptr = aic_htole32(scb->sg_list_busaddr|SG_FULL_RESID);
10108 ahd_setup_noxfer_scb(struct ahd_softc *ahd, struct scb *scb)
10110 scb->hscb->sgptr = aic_htole32(SG_LIST_NULL);
10111 scb->hscb->dataptr = 0;
10112 scb->hscb->datacnt = 0;
10124 ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr)
10129 sg_offset = sg_busaddr - (scb->sg_list_busaddr - ahd_sg_size(ahd));
10130 return ((uint8_t *)scb->sg_list + sg_offset);
10134 ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg)
10139 sg_offset = ((uint8_t *)sg - (uint8_t *)scb->sg_list)
10142 return (scb->sg_list_busaddr + sg_offset);
10146 ahd_sync_scb(struct ahd_softc *ahd, struct scb *scb, int op)
10148 ahd_dmamap_sync(ahd, ahd->parent_dmat, scb->hscb_map->dmamap,
10149 /*offset*/(uint8_t*)scb->hscb - scb->hscb_map->vaddr,
10150 /*len*/sizeof(*scb->hscb), op);
10154 ahd_sync_sglist(struct ahd_softc *ahd, struct scb *scb, int op)
10156 if (scb->sg_count == 0)
10160 scb->sense_map->dmamap,
10161 /*offset*/scb->sg_list_busaddr - ahd_sg_size(ahd),
10162 /*len*/ahd_sg_size(ahd) * scb->sg_count, op);
10166 ahd_sync_sense(struct ahd_softc *ahd, struct scb *scb, int op)
10169 scb->sense_map->dmamap,
10170 /*offset*/scb->sense_busaddr,
10182 ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb)
10186 sgptr = aic_le32toh(scb->hscb->sgptr);
10188 ahd_handle_scb_status(ahd, scb);
10190 ahd_done(ahd, scb);
10198 ahd_update_residual(struct ahd_softc *ahd, struct scb *scb)
10202 sgptr = aic_le32toh(scb->hscb->sgptr);
10204 ahd_calc_residual(ahd, scb);
10433 struct scb *
10436 struct scb* scb;
10440 scb = ahd->scb_data.scbindex[tag];
10441 if (scb != NULL)
10442 ahd_sync_scb(ahd, scb,
10444 return (scb);
10448 ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb)
10459 * When we are called to queue "an arbitrary scb",
10469 memcpy(q_hscb, scb->hscb, sizeof(*scb->hscb));
10471 q_hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr;
10474 ahd->next_queued_hscb = scb->hscb;
10475 ahd->next_queued_hscb_map = scb->hscb_map;
10476 scb->hscb = q_hscb;
10477 scb->hscb_map = q_hscb_map;
10480 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = scb;
10487 ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb)
10489 ahd_swap_with_next_hscb(ahd, scb);
10491 if (SCBID_IS_NULL(SCB_GET_TAG(scb)))
10493 SCB_GET_TAG(scb));
10498 ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb);
10501 if (scb->sg_count != 0)
10502 ahd_setup_data_scb(ahd, scb);
10504 ahd_setup_noxfer_scb(ahd, scb);
10505 ahd_setup_scb_common(ahd, scb);
10511 ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
10517 host_dataptr = aic_le64toh(scb->hscb->dataptr);
10520 SCB_GET_TAG(scb), scb->hscb->scsiid,
10521 aic_le32toh(scb->hscb->hscb_busaddr),
10524 aic_le32toh(scb->hscb->datacnt));
10532 ahd_get_sense_buf(struct ahd_softc *ahd, struct scb *scb)
10534 return (scb->sense_data);
10538 ahd_get_sense_bufaddr(struct ahd_softc *ahd, struct scb *scb)
10540 return (scb->sense_busaddr);