Lines Matching refs:ccb
148 struct cac_ccb *ccb; in cac_init() local
186 ccb = (struct cac_ccb *)sc->sc_ccbs; in cac_init()
188 for (i = 0; i < CAC_MAX_CCBS; i++, ccb++) { in cac_init()
193 &ccb->ccb_dmamap_xfer); in cac_init()
201 ccb->ccb_paddr = sc->sc_ccbs_paddr + i * sizeof(struct cac_ccb); in cac_init()
203 SIMPLEQ_INSERT_TAIL(&sc->sc_ccb_free, ccb, ccb_chain); in cac_init()
291 struct cac_ccb *ccb; in cac_intr() local
298 while ((ccb = (*sc->sc_cl->cl_completed)(sc)) != NULL) { in cac_intr()
300 cac_ccb_done(sc, ccb); in cac_intr()
314 struct cac_ccb *ccb; in cac_cmd() local
324 ccb = xs->io; in cac_cmd()
329 ccb->ccb_flags = 0; in cac_cmd()
332 ccb = scsi_io_get(&sc->sc_iopool, SCSI_POLL | SCSI_NOSLEEP); in cac_cmd()
333 if (ccb == NULL) in cac_cmd()
338 bus_dmamap_load(sc->sc_dmat, ccb->ccb_dmamap_xfer, in cac_cmd()
341 bus_dmamap_sync(sc->sc_dmat, ccb->ccb_dmamap_xfer, 0, in cac_cmd()
342 ccb->ccb_dmamap_xfer->dm_mapsize, in cac_cmd()
346 sgb = ccb->ccb_seg; in cac_cmd()
347 nsegs = ccb->ccb_dmamap_xfer->dm_nsegs; in cac_cmd()
353 size += ccb->ccb_dmamap_xfer->dm_segs[i].ds_len; in cac_cmd()
355 htole32(ccb->ccb_dmamap_xfer->dm_segs[i].ds_len); in cac_cmd()
357 htole32(ccb->ccb_dmamap_xfer->dm_segs[i].ds_addr); in cac_cmd()
364 ccb->ccb_hdr.drive = drive; in cac_cmd()
365 ccb->ccb_hdr.priority = 0; in cac_cmd()
366 ccb->ccb_hdr.size = htole16((sizeof(struct cac_req) + in cac_cmd()
369 ccb->ccb_req.next = 0; in cac_cmd()
370 ccb->ccb_req.command = command; in cac_cmd()
371 ccb->ccb_req.error = 0; in cac_cmd()
372 ccb->ccb_req.blkno = htole32(blkno); in cac_cmd()
373 ccb->ccb_req.bcount = htole16(howmany(size, DEV_BSIZE)); in cac_cmd()
374 ccb->ccb_req.sgcount = nsegs; in cac_cmd()
375 ccb->ccb_req.reserved = 0; in cac_cmd()
377 ccb->ccb_flags = flags; in cac_cmd()
378 ccb->ccb_datasize = size; in cac_cmd()
379 ccb->ccb_xs = xs; in cac_cmd()
389 ccb->ccb_flags |= CAC_CCB_ACTIVE; in cac_cmd()
390 (*sc->sc_cl->cl_submit)(sc, ccb); in cac_cmd()
391 rv = cac_ccb_poll(sc, ccb, 2000); in cac_cmd()
394 rv = cac_ccb_start(sc, ccb); in cac_cmd()
397 scsi_io_put(&sc->sc_iopool, ccb); in cac_cmd()
408 struct cac_ccb *ccb; in cac_ccb_poll() local
414 if ((ccb = (*sc->sc_cl->cl_completed)(sc)) != NULL) in cac_ccb_poll()
420 cac_ccb_done(sc, ccb); in cac_ccb_poll()
421 } while (ccb != wantccb); in cac_ccb_poll()
431 cac_ccb_start(struct cac_softc *sc, struct cac_ccb *ccb) in cac_ccb_start() argument
433 if (ccb != NULL) { in cac_ccb_start()
435 SIMPLEQ_INSERT_TAIL(&sc->sc_ccb_queue, ccb, ccb_chain); in cac_ccb_start()
446 ccb = SIMPLEQ_FIRST(&sc->sc_ccb_queue); in cac_ccb_start()
450 ccb->ccb_flags |= CAC_CCB_ACTIVE; in cac_ccb_start()
451 (*sc->sc_cl->cl_submit)(sc, ccb); in cac_ccb_start()
461 cac_ccb_done(struct cac_softc *sc, struct cac_ccb *ccb) in cac_ccb_done() argument
463 struct scsi_xfer *xs = ccb->ccb_xs; in cac_ccb_done()
466 if ((ccb->ccb_flags & CAC_CCB_ACTIVE) == 0) { in cac_ccb_done()
475 if ((ccb->ccb_flags & (CAC_CCB_DATA_IN | CAC_CCB_DATA_OUT)) != 0) { in cac_ccb_done()
476 bus_dmamap_sync(sc->sc_dmat, ccb->ccb_dmamap_xfer, 0, in cac_ccb_done()
477 ccb->ccb_dmamap_xfer->dm_mapsize, in cac_ccb_done()
478 ccb->ccb_flags & CAC_CCB_DATA_IN ? in cac_ccb_done()
480 bus_dmamap_unload(sc->sc_dmat, ccb->ccb_dmamap_xfer); in cac_ccb_done()
483 if ((ccb->ccb_req.error & CAC_RET_SOFT_ERROR) != 0) in cac_ccb_done()
485 if ((ccb->ccb_req.error & CAC_RET_HARD_ERROR) != 0) { in cac_ccb_done()
489 if ((ccb->ccb_req.error & CAC_RET_CMD_REJECTED) != 0) { in cac_ccb_done()
511 struct cac_ccb *ccb = NULL; in cac_ccb_alloc() local
519 ccb = SIMPLEQ_FIRST(&sc->sc_ccb_free); in cac_ccb_alloc()
524 return (ccb); in cac_ccb_alloc()
534 struct cac_ccb *ccb = xccb; in cac_ccb_free() local
536 ccb->ccb_flags = 0; in cac_ccb_free()
539 SIMPLEQ_INSERT_HEAD(&sc->sc_ccb_free, ccb, ccb_chain); in cac_ccb_free()
725 cac_l0_submit(struct cac_softc *sc, struct cac_ccb *ccb) in cac_l0_submit() argument
728 printf("submit-%lx ", ccb->ccb_paddr); in cac_l0_submit()
733 cac_outl(sc, CAC_REG_CMD_FIFO, ccb->ccb_paddr); in cac_l0_submit()
739 struct cac_ccb *ccb; in cac_l0_completed() local
754 ccb = (struct cac_ccb *)(sc->sc_ccbs + off); in cac_l0_completed()
756 if (orig_off & 3 && ccb->ccb_req.error == 0) in cac_l0_completed()
757 ccb->ccb_req.error = CAC_RET_CMD_INVALID; in cac_l0_completed()
759 return (ccb); in cac_l0_completed()