Lines Matching refs:scb

154 					struct scb *scb);
158 struct scb *scb);
195 struct scb *scb);
203 struct scb *prev_scb,
204 struct scb *scb);
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)
369 sg_index = (sg_busaddr - scb->sg_list_phys)/sizeof(struct ahc_dma_seg);
373 return (&scb->sg_list[sg_index]);
377 ahc_sg_virt_to_bus(struct scb *scb, struct ahc_dma_seg *sg)
382 sg_index = sg - &scb->sg_list[1];
384 return (scb->sg_list_phys + (sg_index * sizeof(*scb->sg_list)));
395 ahc_sync_scb(struct ahc_softc *ahc, struct scb *scb, int op)
399 /*offset*/(scb->hscb - ahc->hscbs) * sizeof(*scb->hscb),
400 /*len*/sizeof(*scb->hscb), op);
404 ahc_sync_sglist(struct ahc_softc *ahc, struct scb *scb, int op)
406 if (scb->sg_count == 0)
409 ahc_dmamap_sync(ahc, ahc->scb_data->sg_dmat, scb->sg_map->sg_dmamap,
410 /*offset*/(scb->sg_list - scb->sg_map->sg_vaddr)
412 /*len*/sizeof(struct ahc_dma_seg) * scb->sg_count, op);
429 ahc_update_residual(struct ahc_softc *ahc, struct scb *scb)
433 sgptr = ahc_le32toh(scb->hscb->sgptr);
435 ahc_calc_residual(ahc, scb);
517 * Get a free scb. If there are none, see if we can allocate a new SCB.
519 struct scb *
522 struct scb *scb;
524 if ((scb = SLIST_FIRST(&ahc->scb_data->free_scbs)) == NULL) {
526 scb = SLIST_FIRST(&ahc->scb_data->free_scbs);
527 if (scb == NULL)
531 return (scb);
538 ahc_free_scb(struct ahc_softc *ahc, struct scb *scb)
542 hscb = scb->hscb;
545 scb->flags = SCB_FREE;
548 SLIST_INSERT_HEAD(&ahc->scb_data->free_scbs, scb, links.sle);
551 ahc_platform_scb_free(ahc, scb);
554 struct scb *
557 struct scb* scb;
559 scb = ahc->scb_data->scbindex[tag];
560 if (scb != NULL)
561 ahc_sync_scb(ahc, scb,
563 return (scb);
567 ahc_swap_with_next_hscb(struct ahc_softc *ahc, struct scb *scb)
577 * When we are called to queue "an arbitrary scb",
586 memcpy(q_hscb, scb->hscb, sizeof(*scb->hscb));
587 if ((scb->flags & SCB_CDB32_PTR) != 0) {
593 q_hscb->next = scb->hscb->tag;
596 ahc->next_queued_scb->hscb = scb->hscb;
597 scb->hscb = q_hscb;
600 ahc->scb_data->scbindex[scb->hscb->tag] = scb;
607 ahc_queue_scb(struct ahc_softc *ahc, struct scb *scb)
609 ahc_swap_with_next_hscb(ahc, scb);
611 if (scb->hscb->tag == SCB_LIST_NULL
612 || scb->hscb->next == SCB_LIST_NULL)
614 scb->hscb->tag, scb->hscb->next);
619 scb->hscb->lun &= LID;
620 if (ahc_get_transfer_length(scb) & 0x1)
621 scb->hscb->lun |= SCB_XFERLEN_ODD;
626 ahc->qinfifo[ahc->qinfifonext++] = scb->hscb->tag;
632 ahc_sync_scb(ahc, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
647 ahc_get_sense_buf(struct ahc_softc *ahc, struct scb *scb)
651 offset = scb - ahc->scb_data->scbarray;
656 ahc_get_sense_bufaddr(struct ahc_softc *ahc, struct scb *scb)
660 offset = scb - ahc->scb_data->scbarray;
878 struct scb *scb;
904 scb = ahc_lookup_scb(ahc, scb_index);
905 if (scb == NULL) {
906 printk("%s: WARNING no command for scb %d "
917 ahc_update_residual(ahc, scb);
918 ahc_done(ahc, scb);
934 struct scb *scb;
939 if ((scb = TAILQ_FIRST(queue)) != NULL
940 && (scb->flags & SCB_ACTIVE) == 0) {
941 scb->flags |= SCB_ACTIVE;
942 ahc_queue_scb(ahc, scb);
979 struct scb *scb;
1014 scb = ahc_lookup_scb(ahc, scb_index);
1015 if (scb == NULL) {
1017 printk("ahc_intr - referenced scb "
1018 "not valid during seqint 0x%x scb(%d)\n",
1025 hscb = scb->hscb;
1028 if ((scb->flags & SCB_SENSE) != 0) {
1034 scb->flags &= ~SCB_SENSE;
1035 ahc_set_transaction_status(scb, CAM_AUTOSENSE_FAIL);
1038 ahc_set_transaction_status(scb, CAM_SCSI_STATUS_ERROR);
1040 ahc_freeze_devq(ahc, scb);
1041 ahc_freeze_scb(scb);
1042 ahc_set_scsi_status(scb, hscb->shared_data.status.scsi_status);
1058 ahc_print_path(ahc, scb);
1060 scb->hscb->tag);
1064 if (ahc_perform_autosense(scb) == 0)
1073 sg = scb->sg_list;
1078 ahc_update_residual(ahc, scb);
1081 ahc_print_path(ahc, scb);
1085 sg->addr = ahc_get_sense_bufaddr(ahc, scb);
1086 sg->len = ahc_get_sense_bufsize(ahc, scb);
1096 && SCB_GET_LUN(scb) < 8)
1097 sc->byte2 = SCB_GET_LUN(scb) << 5;
1120 if (ahc_get_residual(scb)
1121 == ahc_get_transfer_length(scb)) {
1128 scb->flags &= ~SCB_NEGOTIATE;
1129 scb->flags |= SCB_AUTO_NEGOTIATE;
1134 hscb->sgptr = scb->sg_list_phys | SG_FULL_RESID;
1136 scb->sg_count = 1;
1137 scb->flags |= SCB_SENSE;
1138 ahc_qinfifo_requeue_tail(ahc, scb);
1144 ahc_scb_timer_reset(scb, 5 * 1000000);
1246 struct scb *scb;
1266 scb = ahc_lookup_scb(ahc, scb_index);
1269 if (scb == NULL)
1276 scb);
1292 scb);
1350 struct scb *scb;
1357 scb = ahc_lookup_scb(ahc, scb_index);
1358 if (scb != NULL)
1359 ahc_set_transaction_status(scb,
1384 scb = ahc_lookup_scb(ahc, scbindex);
1389 ahc_print_path(ahc, scb);
1393 scb->hscb->tag);
1394 ahc_print_path(ahc, scb);
1397 ahc_get_transfer_length(scb), scb->sg_count);
1398 if (scb->sg_count > 0) {
1399 for (i = 0; i < scb->sg_count; i++) {
1403 (ahc_le32toh(scb->sg_list[i].len) >> 24
1405 ahc_le32toh(scb->sg_list[i].addr),
1406 ahc_le32toh(scb->sg_list[i].len)
1414 ahc_freeze_devq(ahc, scb);
1415 if ((scb->flags & SCB_SENSE) == 0) {
1416 ahc_set_transaction_status(scb, CAM_DATA_RUN_ERR);
1418 scb->flags &= ~SCB_SENSE;
1419 ahc_set_transaction_status(scb, CAM_AUTOSENSE_FAIL);
1421 ahc_freeze_scb(scb);
1452 scb = ahc_lookup_scb(ahc, scbindex);
1453 if (scb != NULL
1454 && (scb->flags & SCB_RECOVERY_SCB) != 0)
1459 ahc_search_qinfifo(ahc, SCB_GET_TARGET(ahc, scb),
1460 SCB_GET_CHANNEL(ahc, scb),
1461 SCB_GET_LUN(scb), scb->hscb->tag,
1532 struct scb *scb;
1568 scb = ahc_lookup_scb(ahc, scb_index);
1569 if (scb != NULL
1571 scb = NULL;
1647 if (scb != NULL) {
1648 if (SCB_IS_SILENT(scb))
1651 ahc_print_path(ahc, scb);
1652 scb->flags |= SCB_TRANSMISSION_ERROR;
1739 scb = ahc_lookup_scb(ahc, scb_index);
1740 if (scb == NULL) {
1741 printk("%s: ahc_intr - referenced scb not "
1742 "valid during SELTO scb(%d, %d)\n",
1749 ahc_print_path(ahc, scb);
1754 ahc_scb_devinfo(ahc, &devinfo, scb);
1755 ahc_set_transaction_status(scb, CAM_SEL_TIMEOUT);
1756 ahc_freeze_devq(ahc, scb);
1824 tag = scb->hscb->tag;
1825 ahc_print_path(ahc, scb);
1827 scb->hscb->tag, tag == SCB_LIST_NULL ?
1864 ahc_qinfifo_requeue_tail(ahc, scb);
1876 ahc_qinfifo_requeue_tail(ahc, scb);
1890 ahc_qinfifo_requeue_tail(ahc, scb);
1897 if (scb != NULL) {
1900 if ((scb->hscb->control & TAG_ENB) != 0)
1901 tag = scb->hscb->tag;
1904 ahc_print_path(ahc, scb);
1906 SCB_GET_LUN(scb), tag,
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;
2818 struct scb *scb)
2823 our_id = SCSIID_OUR_ID(scb->hscb->scsiid);
2825 if ((scb->flags & SCB_TARGET_SCB) != 0)
2827 ahc_compile_devinfo(devinfo, our_id, SCB_GET_TARGET(ahc, scb),
2828 SCB_GET_LUN(scb), SCB_GET_CHANNEL(ahc, scb), role);
2852 struct scb *scb)
2862 if ((scb->flags & SCB_DEVICE_RESET) == 0
2866 identify_msg = MSG_IDENTIFYFLAG | SCB_GET_LUN(scb);
2867 if ((scb->hscb->control & DISCENB) != 0)
2872 if ((scb->hscb->control & TAG_ENB) != 0) {
2874 scb->hscb->control & (TAG_ENB|SCB_TAG_TYPE);
2875 ahc->msgout_buf[ahc->msgout_index++] = scb->hscb->tag;
2880 if (scb->flags & SCB_DEVICE_RESET) {
2883 ahc_print_path(ahc, scb);
2893 } else if ((scb->flags & SCB_ABORT) != 0) {
2894 if ((scb->hscb->control & TAG_ENB) != 0)
2899 ahc_print_path(ahc, scb);
2901 (scb->hscb->control & TAG_ENB) != 0 ? " Tag" : "");
2910 } else if ((scb->flags & (SCB_AUTO_NEGOTIATE|SCB_NEGOTIATE)) != 0) {
2915 printk("SCSIID = %x, target_mask = %x\n", scb->hscb->scsiid,
2918 "SCB flags = %x", scb->hscb->tag, scb->hscb->control,
2919 ahc_inb(ahc, MSG_OUT), scb->flags);
2927 scb->hscb->control &= ~MK_MESSAGE;
3116 struct scb *scb;
3125 scb = ahc_lookup_scb(ahc, scbid);
3139 scb = NULL;
3140 } else if (scb == NULL) {
3149 ahc_set_transaction_status(scb, CAM_SEQUENCE_FAIL);
3151 ahc_print_path(ahc, scb);
3161 ahc_print_path(ahc, scb);
3164 ahc_print_path(ahc, scb);
3191 if (scb == NULL) {
3198 ahc_print_path(ahc, scb);
3199 scb->flags |= SCB_ABORT;
3989 struct scb *scb;
3997 scb = ahc_lookup_scb(ahc, scb_index);
4058 } else if ((scb->hscb->control & SIMPLE_QUEUE_TAG) != 0) {
4062 tag_type = (scb->hscb->control & SIMPLE_QUEUE_TAG);
4068 ahc_set_tags(ahc, scb->io_ctx, devinfo, AHC_QUEUE_NONE);
4076 ahc_set_tags(ahc, scb->io_ctx, devinfo, AHC_QUEUE_BASIC);
4086 scb->hscb->control &= mask;
4087 ahc_set_transaction_tag(scb, /*enabled*/FALSE,
4101 TAILQ_INSERT_HEAD(untagged_q, scb, links.tqe);
4102 scb->flags |= SCB_UNTAGGEDQ;
4104 ahc_busy_tcl(ahc, BUILD_TCL(scb->hscb->scsiid, devinfo->lun),
4105 scb->hscb->tag);
4112 ahc_search_qinfifo(ahc, SCB_GET_TARGET(ahc, scb),
4113 SCB_GET_CHANNEL(ahc, scb),
4114 SCB_GET_LUN(scb), /*tag*/SCB_LIST_NULL,
4135 struct scb *scb;
4138 scb = ahc_lookup_scb(ahc, scb_index);
4144 || ahc_get_transfer_dir(scb) != CAM_DIR_IN) {
4193 sg = ahc_sg_bus_to_virt(scb, sgptr);
4201 if (sg != scb->sg_list
4219 sgptr = ahc_sg_virt_to_bus(scb, sg);
4243 struct scb *scb;
4251 scb = ahc_lookup_scb(ahc, scb_index);
4258 sg = ahc_sg_bus_to_virt(scb, sgptr);
4353 struct scb *scb)
4364 if (scb != NULL && (scb->flags & SCB_AUTO_NEGOTIATE) != 0)
4434 /* XXX The shared scb data stuff should be deprecated */
4741 scb_data->scbarray = kcalloc(AHC_SCB_MAX_ALLOC, sizeof(struct scb),
4764 /* DMA tag for our hardware scb structures */
4932 struct scb *next_scb;
4981 * The first entry is embedded in the scb.
5374 printk("%s: hardware scb %u bytes; kernel scb %u bytes; "
5378 (u_int)sizeof(struct scb),
5691 ahc_match_scb(struct ahc_softc *ahc, struct scb *scb, int target,
5694 int targ = SCB_GET_TARGET(ahc, scb);
5695 char chan = SCB_GET_CHANNEL(ahc, scb);
5696 int slun = SCB_GET_LUN(scb);
5708 group = XPT_FC_GROUP(scb->io_ctx->ccb_h.func_code);
5711 && ((tag == scb->hscb->tag)
5715 && ((tag == scb->io_ctx->csio.tag_id)
5719 match = ((tag == scb->hscb->tag) || (tag == SCB_LIST_NULL));
5727 ahc_freeze_devq(struct ahc_softc *ahc, struct scb *scb)
5733 target = SCB_GET_TARGET(ahc, scb);
5734 lun = SCB_GET_LUN(scb);
5735 channel = SCB_GET_CHANNEL(ahc, scb);
5741 ahc_platform_freeze_devq(ahc, scb);
5745 ahc_qinfifo_requeue_tail(struct ahc_softc *ahc, struct scb *scb)
5747 struct scb *prev_scb;
5758 ahc_qinfifo_requeue(ahc, prev_scb, scb);
5767 ahc_qinfifo_requeue(struct ahc_softc *ahc, struct scb *prev_scb,
5768 struct scb *scb)
5771 ahc_outb(ahc, NEXT_QUEUED_SCB, scb->hscb->tag);
5773 prev_scb->hscb->next = scb->hscb->tag;
5777 ahc->qinfifo[ahc->qinfifonext++] = scb->hscb->tag;
5778 scb->hscb->next = ahc->next_queued_scb->hscb->tag;
5779 ahc_sync_scb(ahc, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
5802 struct scb *scb;
5803 struct scb *prev_scb;
5840 scb = ahc_lookup_scb(ahc, ahc->qinfifo[qinpos]);
5841 if (scb == NULL) {
5847 if (ahc_match_scb(ahc, scb, target, channel, lun, tag, role)) {
5849 * We found an scb that needs to be acted on.
5858 ostat = ahc_get_transaction_status(scb);
5860 ahc_set_transaction_status(scb, status);
5861 cstat = ahc_get_transaction_status(scb);
5863 ahc_freeze_scb(scb);
5864 if ((scb->flags & SCB_ACTIVE) == 0)
5866 ahc_done(ahc, scb);
5872 ahc_qinfifo_requeue(ahc, prev_scb, scb);
5873 prev_scb = scb;
5877 ahc_qinfifo_requeue(ahc, prev_scb, scb);
5878 prev_scb = scb;
5904 scb = ahc_lookup_scb(ahc, ahc->qinfifo[qinstart]);
5906 if (scb == NULL) {
5917 next = scb->hscb->next;
5918 ahc->scb_data->scbindex[scb->hscb->tag] = NULL;
5919 ahc_swap_with_next_hscb(ahc, scb);
5920 scb->hscb->next = next;
5921 ahc->qinfifo[qinstart] = scb->hscb->tag;
5924 ahc_outb(ahc, NEXT_QUEUED_SCB, scb->hscb->tag);
5928 scb = ahc_lookup_scb(ahc, ahc->qinfifo[qintail]);
5929 scb->hscb->next = ahc->next_queued_scb->hscb->tag;
5951 scb = ahc_lookup_scb(ahc, scb_index);
5952 if (scb == NULL) {
5957 if (ahc_match_scb(ahc, scb, target, channel,
5960 * We found an scb that needs to be acted on.
5969 ostat = ahc_get_transaction_status(scb);
5971 ahc_set_transaction_status(scb,
5973 cstat = ahc_get_transaction_status(scb);
5975 ahc_freeze_scb(scb);
5976 if ((scb->flags & SCB_ACTIVE) == 0)
5978 ahc_done(ahc, scb);
6009 struct scb *scb;
6040 struct scb *next_scb;
6046 scb = next_scb;
6047 next_scb = TAILQ_NEXT(scb, links.tqe);
6058 if ((scb->flags & SCB_ACTIVE) != 0)
6061 if (ahc_match_scb(ahc, scb, target, channel, lun,
6063 || (ctx != NULL && ctx != scb->io_ctx))
6067 * We found an scb that needs to be acted on.
6076 ostat = ahc_get_transaction_status(scb);
6078 ahc_set_transaction_status(scb, status);
6079 cstat = ahc_get_transaction_status(scb);
6081 ahc_freeze_scb(scb);
6082 if ((scb->flags & SCB_ACTIVE) == 0)
6084 ahc_done(ahc, scb);
6088 scb->flags &= ~SCB_UNTAGGEDQ;
6089 TAILQ_REMOVE(untagged_q, scb, links.tqe);
6107 struct scb *scbp;
6212 * scb that follows the one that we remove.
6244 * Select the scb that pointed to us
6252 * Point us back at the original scb position.
6269 struct scb *scbp;
6270 struct scb *scbp_next;
6352 * bus free with the same scb queued for an abort). Don't hold this
6588 ahc_calc_residual(struct ahc_softc *ahc, struct scb *scb)
6612 hscb = scb->hscb;
6627 resid = ahc_get_transfer_length(scb);
6641 sg = ahc_sg_bus_to_virt(scb, resid_sgptr & SG_PTR_MASK);
6656 if ((scb->flags & SCB_SENSE) == 0)
6657 ahc_set_residual(scb, resid);
6659 ahc_set_sense_residual(scb, resid);
6663 ahc_print_path(ahc, scb);
6665 (scb->flags & SCB_SENSE) ? "Sense " : "", resid);
7102 struct scb *scb;
7233 LIST_FOREACH(scb, &ahc->pending_scbs, pending_links) {
7236 cur_col = printk("\n%3d ", scb->hscb->tag);
7237 ahc_scb_control_print(scb->hscb->control, &cur_col, 60);
7238 ahc_scb_scsiid_print(scb->hscb->scsiid, &cur_col, 60);
7239 ahc_scb_lun_print(scb->hscb->lun, &cur_col, 60);
7241 ahc_outb(ahc, SCBPTR, scb->hscb->tag);
7253 SLIST_FOREACH(scb, &ahc->scb_data->free_scbs, links.sle) {
7256 printk("%d ", scb->hscb->tag);
7267 TAILQ_FOREACH(scb, untagged_q, links.tqe) {
7270 printk("%d ", scb->hscb->tag);
7581 struct scb *scb;
7592 LIST_FOREACH(scb, &ahc->pending_scbs, pending_links) {
7595 ccbh = &scb->io_ctx->ccb_h;