Lines Matching refs:ccb

107 	struct cac_ccb *ccb;  in cac_init()  local
151 ccb = (struct cac_ccb *)sc->sc_ccbs; in cac_init()
153 for (i = 0; i < CAC_MAX_CCBS; i++, ccb++) { in cac_init()
158 &ccb->ccb_dmamap_xfer); in cac_init()
166 ccb->ccb_flags = 0; in cac_init()
167 ccb->ccb_paddr = sc->sc_ccbs_paddr + i * sizeof(struct cac_ccb); in cac_init()
168 SIMPLEQ_INSERT_TAIL(&sc->sc_ccb_free, ccb, ccb_chain); in cac_init()
287 struct cac_ccb *ccb; in cac_intr() local
295 while ((ccb = (*sc->sc_cl.cl_completed)(sc)) != NULL) { in cac_intr()
296 cac_ccb_done(sc, ccb); in cac_intr()
315 struct cac_ccb *ccb; in cac_cmd() local
321 if ((ccb = cac_ccb_alloc(sc, 1)) == NULL) { in cac_cmd()
327 bus_dmamap_load(sc->sc_dmat, ccb->ccb_dmamap_xfer, in cac_cmd()
332 bus_dmamap_sync(sc->sc_dmat, ccb->ccb_dmamap_xfer, 0, datasize, in cac_cmd()
336 sgb = ccb->ccb_seg; in cac_cmd()
337 nsegs = uimin(ccb->ccb_dmamap_xfer->dm_nsegs, CAC_SG_SIZE); in cac_cmd()
340 size += ccb->ccb_dmamap_xfer->dm_segs[i].ds_len; in cac_cmd()
342 htole32(ccb->ccb_dmamap_xfer->dm_segs[i].ds_len); in cac_cmd()
344 htole32(ccb->ccb_dmamap_xfer->dm_segs[i].ds_addr); in cac_cmd()
351 ccb->ccb_hdr.drive = drive; in cac_cmd()
352 ccb->ccb_hdr.priority = 0; in cac_cmd()
353 ccb->ccb_hdr.size = htole16((sizeof(struct cac_req) + in cac_cmd()
356 ccb->ccb_req.next = 0; in cac_cmd()
357 ccb->ccb_req.error = 0; in cac_cmd()
358 ccb->ccb_req.reserved = 0; in cac_cmd()
359 ccb->ccb_req.bcount = htole16(howmany(size, DEV_BSIZE)); in cac_cmd()
360 ccb->ccb_req.command = command; in cac_cmd()
361 ccb->ccb_req.sgcount = nsegs; in cac_cmd()
362 ccb->ccb_req.blkno = htole32(blkno); in cac_cmd()
364 ccb->ccb_flags = flags; in cac_cmd()
365 ccb->ccb_datasize = size; in cac_cmd()
370 memset(&ccb->ccb_context, 0, sizeof(struct cac_context)); in cac_cmd()
374 cac_ccb_free(sc, ccb); in cac_cmd()
378 ccb->ccb_flags |= CAC_CCB_ACTIVE; in cac_cmd()
380 (*sc->sc_cl.cl_submit)(sc, ccb); in cac_cmd()
381 rv = cac_ccb_poll(sc, ccb, 2000); in cac_cmd()
382 cac_ccb_free(sc, ccb); in cac_cmd()
385 memcpy(&ccb->ccb_context, context, sizeof(struct cac_context)); in cac_cmd()
386 (void)cac_ccb_start(sc, ccb); in cac_cmd()
400 struct cac_ccb *ccb; in cac_ccb_poll() local
408 ccb = (*sc->sc_cl.cl_completed)(sc); in cac_ccb_poll()
409 if (ccb != NULL) in cac_ccb_poll()
418 cac_ccb_done(sc, ccb); in cac_ccb_poll()
419 } while (ccb != wantccb); in cac_ccb_poll()
429 cac_ccb_start(struct cac_softc *sc, struct cac_ccb *ccb) in cac_ccb_start() argument
434 if (ccb != NULL) in cac_ccb_start()
435 SIMPLEQ_INSERT_TAIL(&sc->sc_ccb_queue, ccb, ccb_chain); in cac_ccb_start()
437 while ((ccb = SIMPLEQ_FIRST(&sc->sc_ccb_queue)) != NULL) { in cac_ccb_start()
442 ccb->ccb_flags |= CAC_CCB_ACTIVE; in cac_ccb_start()
444 (*sc->sc_cl.cl_submit)(sc, ccb); in cac_ccb_start()
454 cac_ccb_done(struct cac_softc *sc, struct cac_ccb *ccb) in cac_ccb_done() argument
465 if ((ccb->ccb_flags & CAC_CCB_ACTIVE) == 0) in cac_ccb_done()
467 ccb->ccb_flags &= ~CAC_CCB_ACTIVE; in cac_ccb_done()
470 if ((ccb->ccb_flags & (CAC_CCB_DATA_IN | CAC_CCB_DATA_OUT)) != 0) { in cac_ccb_done()
471 bus_dmamap_sync(sc->sc_dmat, ccb->ccb_dmamap_xfer, 0, in cac_ccb_done()
472 ccb->ccb_datasize, ccb->ccb_flags & CAC_CCB_DATA_IN ? in cac_ccb_done()
474 bus_dmamap_unload(sc->sc_dmat, ccb->ccb_dmamap_xfer); in cac_ccb_done()
477 error = ccb->ccb_req.error; in cac_ccb_done()
478 if (ccb->ccb_context.cc_handler != NULL) { in cac_ccb_done()
479 dv = ccb->ccb_context.cc_dv; in cac_ccb_done()
480 context = ccb->ccb_context.cc_context; in cac_ccb_done()
481 cac_ccb_free(sc, ccb); in cac_ccb_done()
482 (*ccb->ccb_context.cc_handler)(dv, context, error); in cac_ccb_done()
501 struct cac_ccb *ccb; in cac_ccb_alloc() local
506 if ((ccb = SIMPLEQ_FIRST(&sc->sc_ccb_free)) != NULL) { in cac_ccb_alloc()
511 ccb = NULL; in cac_ccb_alloc()
518 return (ccb); in cac_ccb_alloc()
525 cac_ccb_free(struct cac_softc *sc, struct cac_ccb *ccb) in cac_ccb_free() argument
530 ccb->ccb_flags = 0; in cac_ccb_free()
533 SIMPLEQ_INSERT_HEAD(&sc->sc_ccb_free, ccb, ccb_chain); in cac_ccb_free()
550 cac_l0_submit(struct cac_softc *sc, struct cac_ccb *ccb) in cac_l0_submit() argument
556 (char *)ccb - (char *)sc->sc_ccbs, in cac_l0_submit()
558 cac_outl(sc, CAC_REG_CMD_FIFO, ccb->ccb_paddr); in cac_l0_submit()
564 struct cac_ccb *ccb; in cac_l0_completed() local
577 ccb = (struct cac_ccb *)((char *)sc->sc_ccbs + off); in cac_l0_completed()
582 if ((off & 3) != 0 && ccb->ccb_req.error == 0) in cac_l0_completed()
583 ccb->ccb_req.error = CAC_RET_CMD_REJECTED; in cac_l0_completed()
585 return (ccb); in cac_l0_completed()