Lines Matching refs:ccb

284 	struct aha_ccb *ccb;
314 ccb = aha_ccb_phys_kv(sc, phystol(wmbi->ccb_addr));
315 if (!ccb) {
316 printf("%s: bad mbi ccb pointer; skipping\n",
322 AHA_CCB_OFF(ccb), sizeof(struct aha_ccb),
327 u_char *cp = ccb->scsi_cmd;
332 printf("ccb addr = %p\n", ccb);
339 if ((ccb->flags & CCB_ABORT) != 0) {
366 callout_stop(&ccb->xs->xs_callout);
367 aha_done(sc, ccb);
432 aha_reset_ccb(struct aha_softc *sc, struct aha_ccb *ccb)
435 ccb->flags = 0;
439 * A ccb is put onto the free list.
442 aha_free_ccb(struct aha_softc *sc, struct aha_ccb *ccb)
447 aha_reset_ccb(sc, ccb);
448 TAILQ_INSERT_HEAD(&sc->sc_free_ccb, ccb, chain);
453 aha_init_ccb(struct aha_softc *sc, struct aha_ccb *ccb)
462 0, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, &ccb->dmamap_xfer);
465 "unable to create ccb DMA map, error = %d\n",
474 ccb->hashkey = sc->sc_dmamap_control->dm_segs[0].ds_addr +
475 AHA_CCB_OFF(ccb);
476 hashnum = CCB_HASH(ccb->hashkey);
477 ccb->nexthash = sc->sc_ccbhash[hashnum];
478 sc->sc_ccbhash[hashnum] = ccb;
479 aha_reset_ccb(sc, ccb);
490 struct aha_ccb *ccb;
495 ccb = &ccbstore[i];
496 if ((error = aha_init_ccb(sc, ccb)) != 0) {
498 "unable to initialize ccb, error = %d\n",
502 TAILQ_INSERT_TAIL(&sc->sc_free_ccb, ccb, chain);
509 * Get a free ccb
517 struct aha_ccb *ccb;
521 ccb = TAILQ_FIRST(&sc->sc_free_ccb);
522 if (ccb != NULL) {
523 TAILQ_REMOVE(&sc->sc_free_ccb, ccb, chain);
524 ccb->flags |= CCB_ALLOC;
527 return (ccb);
531 * Given a physical address, find the ccb that it corresponds to.
537 struct aha_ccb *ccb = sc->sc_ccbhash[hashnum];
539 while (ccb) {
540 if (ccb->hashkey == ccb_phys)
542 ccb = ccb->nexthash;
544 return (ccb);
551 aha_queue_ccb(struct aha_softc *sc, struct aha_ccb *ccb)
554 TAILQ_INSERT_TAIL(&sc->sc_waiting_ccb, ccb, chain);
566 struct aha_ccb *ccb;
579 ccb = aha_ccb_phys_kv(sc, phystol(wmbo->ccb_addr));
580 ccb->flags &= ~CCB_SENDING;
599 struct aha_ccb *ccb;
603 while ((ccb = sc->sc_waiting_ccb.tqh_first) != NULL) {
618 TAILQ_REMOVE(&sc->sc_waiting_ccb, ccb, chain);
620 ccb->flags |= CCB_SENDING;
623 /* Link ccb to mbo. */
625 AHA_CCB_OFF(ccb), wmbo->ccb_addr);
626 if (ccb->flags & CCB_ABORT)
638 if ((ccb->xs->xs_control & XS_CTL_POLL) == 0)
639 callout_reset(&ccb->xs->xs_callout,
640 mstohz(ccb->timeout), aha_timeout, ccb);
650 * We have a ccb which has been processed by the
655 aha_done(struct aha_softc *sc, struct aha_ccb *ccb)
659 struct scsipi_xfer *xs = ccb->xs;
668 bus_dmamap_sync(dmat, ccb->dmamap_xfer, 0,
669 ccb->dmamap_xfer->dm_mapsize,
672 bus_dmamap_unload(dmat, ccb->dmamap_xfer);
680 if (ccb->flags & CCB_SENDING) {
681 printf("%s: exiting ccb still in transit!\n",
687 if ((ccb->flags & CCB_ALLOC) == 0) {
688 printf("%s: exiting ccb not allocated!\n",
694 if (ccb->host_stat != AHA_OK) {
695 switch (ccb->host_stat) {
701 device_xname(sc->sc_dev), ccb->host_stat);
705 } else if (ccb->target_stat != SCSI_OK) {
706 switch (ccb->target_stat) {
708 s1 = (struct scsi_sense_data *) (((char *) (&ccb->scsi_cmd)) +
709 ccb->scsi_cmd_length);
719 device_xname(sc->sc_dev), ccb->target_stat);
726 aha_free_ccb(sc, ccb);
1128 struct aha_ccb *ccb;
1141 ccb = aha_get_ccb(sc);
1147 if (ccb == NULL) {
1149 printf("unable to allocate ccb\n");
1154 ccb->xs = xs;
1155 ccb->timeout = xs->timeout;
1158 * Put all the arguments for the xfer in the ccb
1161 ccb->opcode = AHA_RESET_CCB;
1162 ccb->scsi_cmd_length = 0;
1165 if (xs->cmdlen > sizeof(ccb->scsi_cmd)) {
1171 ccb->opcode = (xs->datalen ? AHA_INIT_SCAT_GATH_CCB
1173 memcpy(&ccb->scsi_cmd, xs->cmd,
1174 ccb->scsi_cmd_length = xs->cmdlen);
1184 ccb->dmamap_xfer, (struct uio *)xs->data,
1193 ccb->dmamap_xfer, xs->data, xs->datalen,
1222 aha_free_ccb(sc, ccb);
1227 bus_dmamap_sync(dmat, ccb->dmamap_xfer, 0,
1228 ccb->dmamap_xfer->dm_mapsize,
1236 for (seg = 0; seg < ccb->dmamap_xfer->dm_nsegs; seg++) {
1237 ltophys(ccb->dmamap_xfer->dm_segs[seg].ds_addr,
1238 ccb->scat_gath[seg].seg_addr);
1239 ltophys(ccb->dmamap_xfer->dm_segs[seg].ds_len,
1240 ccb->scat_gath[seg].seg_len);
1244 AHA_CCB_OFF(ccb) +
1246 ccb->data_addr);
1247 ltophys(ccb->dmamap_xfer->dm_nsegs *
1248 sizeof(struct aha_scat_gath), ccb->data_length);
1253 ltophys(0, ccb->data_addr);
1254 ltophys(0, ccb->data_length);
1257 ccb->data_out = 0;
1258 ccb->data_in = 0;
1259 ccb->target = periph->periph_target;
1260 ccb->lun = periph->periph_lun;
1261 ccb->req_sense_length = sizeof(ccb->scsi_sense);
1262 ccb->host_stat = 0x00;
1263 ccb->target_stat = 0x00;
1264 ccb->link_id = 0;
1265 ltophys(0, ccb->link_addr);
1268 AHA_CCB_OFF(ccb), sizeof(struct aha_ccb),
1272 aha_queue_ccb(sc, ccb);
1280 if (aha_poll(sc, xs, ccb->timeout)) {
1281 aha_timeout(ccb);
1282 if (aha_poll(sc, xs, ccb->timeout))
1283 aha_timeout(ccb);
1330 struct aha_ccb *ccb = arg;
1331 struct scsipi_xfer *xs = ccb->xs;
1344 * If The ccb's mbx is not free, then the board has gone south?
1347 if (ccb->flags & CCB_SENDING) {
1358 if (ccb->flags & CCB_ABORT) {
1365 ccb->xs->error = XS_TIMEOUT;
1366 ccb->timeout = AHA_ABORT_TIMEOUT;
1367 ccb->flags |= CCB_ABORT;
1368 aha_queue_ccb(sc, ccb);