Lines Matching defs:ccb

287 	struct aha_ccb *ccb;
317 ccb = aha_ccb_phys_kv(sc, phystol(wmbi->ccb_addr));
318 if (!ccb) {
319 printf("%s: bad mbi ccb pointer; skipping\n",
325 AHA_CCB_OFF(ccb), sizeof(struct aha_ccb),
330 u_char *cp = ccb->scsi_cmd;
335 printf("ccb addr = %p\n", ccb);
342 if ((ccb->flags & CCB_ABORT) != 0) {
369 callout_stop(&ccb->xs->xs_callout);
370 aha_done(sc, ccb);
435 aha_reset_ccb(struct aha_softc *sc, struct aha_ccb *ccb)
438 ccb->flags = 0;
442 * A ccb is put onto the free list.
445 aha_free_ccb(struct aha_softc *sc, struct aha_ccb *ccb)
450 aha_reset_ccb(sc, ccb);
451 TAILQ_INSERT_HEAD(&sc->sc_free_ccb, ccb, chain);
456 aha_init_ccb(struct aha_softc *sc, struct aha_ccb *ccb)
465 0, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, &ccb->dmamap_xfer);
468 "unable to create ccb DMA map, error = %d\n",
477 ccb->hashkey = sc->sc_dmamap_control->dm_segs[0].ds_addr +
478 AHA_CCB_OFF(ccb);
479 hashnum = CCB_HASH(ccb->hashkey);
480 ccb->nexthash = sc->sc_ccbhash[hashnum];
481 sc->sc_ccbhash[hashnum] = ccb;
482 aha_reset_ccb(sc, ccb);
493 struct aha_ccb *ccb;
498 ccb = &ccbstore[i];
499 if ((error = aha_init_ccb(sc, ccb)) != 0) {
501 "unable to initialize ccb, error = %d\n",
505 TAILQ_INSERT_TAIL(&sc->sc_free_ccb, ccb, chain);
512 * Get a free ccb
520 struct aha_ccb *ccb;
524 ccb = TAILQ_FIRST(&sc->sc_free_ccb);
525 if (ccb != NULL) {
526 TAILQ_REMOVE(&sc->sc_free_ccb, ccb, chain);
527 ccb->flags |= CCB_ALLOC;
530 return (ccb);
534 * Given a physical address, find the ccb that it corresponds to.
540 struct aha_ccb *ccb = sc->sc_ccbhash[hashnum];
542 while (ccb) {
543 if (ccb->hashkey == ccb_phys)
545 ccb = ccb->nexthash;
547 return (ccb);
554 aha_queue_ccb(struct aha_softc *sc, struct aha_ccb *ccb)
557 TAILQ_INSERT_TAIL(&sc->sc_waiting_ccb, ccb, chain);
569 struct aha_ccb *ccb;
582 ccb = aha_ccb_phys_kv(sc, phystol(wmbo->ccb_addr));
583 ccb->flags &= ~CCB_SENDING;
602 struct aha_ccb *ccb;
606 while ((ccb = sc->sc_waiting_ccb.tqh_first) != NULL) {
621 TAILQ_REMOVE(&sc->sc_waiting_ccb, ccb, chain);
623 ccb->flags |= CCB_SENDING;
626 /* Link ccb to mbo. */
628 AHA_CCB_OFF(ccb), wmbo->ccb_addr);
629 if (ccb->flags & CCB_ABORT)
641 if ((ccb->xs->xs_control & XS_CTL_POLL) == 0)
642 callout_reset(&ccb->xs->xs_callout,
643 mstohz(ccb->timeout), aha_timeout, ccb);
653 * We have a ccb which has been processed by the
658 aha_done(struct aha_softc *sc, struct aha_ccb *ccb)
662 struct scsipi_xfer *xs = ccb->xs;
671 bus_dmamap_sync(dmat, ccb->dmamap_xfer, 0,
672 ccb->dmamap_xfer->dm_mapsize,
675 bus_dmamap_unload(dmat, ccb->dmamap_xfer);
683 if (ccb->flags & CCB_SENDING) {
684 printf("%s: exiting ccb still in transit!\n",
690 if ((ccb->flags & CCB_ALLOC) == 0) {
691 printf("%s: exiting ccb not allocated!\n",
697 if (ccb->host_stat != AHA_OK) {
698 switch (ccb->host_stat) {
704 device_xname(sc->sc_dev), ccb->host_stat);
708 } else if (ccb->target_stat != SCSI_OK) {
709 switch (ccb->target_stat) {
712 (((char *)(&ccb->scsi_cmd)) +
713 ccb->scsi_cmd_length);
723 device_xname(sc->sc_dev), ccb->target_stat);
730 aha_free_ccb(sc, ccb);
1133 struct aha_ccb *ccb;
1146 ccb = aha_get_ccb(sc);
1152 if (ccb == NULL) {
1154 printf("unable to allocate ccb\n");
1159 ccb->xs = xs;
1160 ccb->timeout = xs->timeout;
1163 * Put all the arguments for the xfer in the ccb
1166 ccb->opcode = AHA_RESET_CCB;
1167 ccb->scsi_cmd_length = 0;
1170 if (xs->cmdlen > sizeof(ccb->scsi_cmd)) {
1176 ccb->opcode = (xs->datalen ? AHA_INIT_SCAT_GATH_CCB
1178 memcpy(&ccb->scsi_cmd, xs->cmd,
1179 ccb->scsi_cmd_length = xs->cmdlen);
1189 ccb->dmamap_xfer, (struct uio *)xs->data,
1198 ccb->dmamap_xfer, xs->data, xs->datalen,
1227 aha_free_ccb(sc, ccb);
1232 bus_dmamap_sync(dmat, ccb->dmamap_xfer, 0,
1233 ccb->dmamap_xfer->dm_mapsize,
1241 for (seg = 0; seg < ccb->dmamap_xfer->dm_nsegs; seg++) {
1242 ltophys(ccb->dmamap_xfer->dm_segs[seg].ds_addr,
1243 ccb->scat_gath[seg].seg_addr);
1244 ltophys(ccb->dmamap_xfer->dm_segs[seg].ds_len,
1245 ccb->scat_gath[seg].seg_len);
1249 AHA_CCB_OFF(ccb) +
1251 ccb->data_addr);
1252 ltophys(ccb->dmamap_xfer->dm_nsegs *
1253 sizeof(struct aha_scat_gath), ccb->data_length);
1258 ltophys(0, ccb->data_addr);
1259 ltophys(0, ccb->data_length);
1262 ccb->data_out = 0;
1263 ccb->data_in = 0;
1264 ccb->target = periph->periph_target;
1265 ccb->lun = periph->periph_lun;
1266 ccb->req_sense_length = sizeof(ccb->scsi_sense);
1267 ccb->host_stat = 0x00;
1268 ccb->target_stat = 0x00;
1269 ccb->link_id = 0;
1270 ltophys(0, ccb->link_addr);
1273 AHA_CCB_OFF(ccb), sizeof(struct aha_ccb),
1277 aha_queue_ccb(sc, ccb);
1285 if (aha_poll(sc, xs, ccb->timeout)) {
1286 aha_timeout(ccb);
1287 if (aha_poll(sc, xs, ccb->timeout))
1288 aha_timeout(ccb);
1336 struct aha_ccb *ccb = arg;
1337 struct scsipi_xfer *xs = ccb->xs;
1350 * If The ccb's mbx is not free, then the board has gone south?
1353 if (ccb->flags & CCB_SENDING) {
1364 if (ccb->flags & CCB_ABORT) {
1371 ccb->xs->error = XS_TIMEOUT;
1372 ccb->timeout = AHA_ABORT_TIMEOUT;
1373 ccb->flags |= CCB_ABORT;
1374 aha_queue_ccb(sc, ccb);