Home | History | Annotate | Download | only in ic

Lines Matching defs:ccb

218 	struct dpt_ccb *ccb;
222 ccb = SLIST_FIRST(&sc->sc_ccb_free);
226 return (ccb);
230 dpt_ccb_free(struct dpt_softc *sc, struct dpt_ccb *ccb)
234 ccb->ccb_flg = 0;
235 ccb->ccb_savesp = NULL;
237 SLIST_INSERT_HEAD(&sc->sc_ccb_free, ccb, ccb_chain);
248 struct dpt_ccb *ccb;
284 /* Make sure CCB ID from status packet is realistic. */
286 printf("%s: bogus status (returned CCB id %d)\n",
296 ccb = sc->sc_ccbs + sp->sp_ccbid;
298 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, CCB_OFF(sc, ccb),
301 ccb->ccb_hba_status = sp->sp_hba_status & 0x7f;
302 ccb->ccb_scsi_status = sp->sp_scsi_status;
303 if (ccb->ccb_savesp != NULL)
304 memcpy(ccb->ccb_savesp, sp, sizeof(*sp));
307 * Ack the interrupt and process the CCB. If this
308 * is a private CCB it's up to dpt_ccb_poll() to
312 ccb->ccb_flg |= CCB_INTR;
314 if ((ccb->ccb_flg & CCB_PRIVATE) == 0)
315 dpt_ccb_done(sc, ccb);
316 else if ((ccb->ccb_flg & CCB_WAIT) != 0)
317 wakeup(ccb);
336 struct dpt_ccb *ccb;
346 * Allocate the CCB/status packet/scratch DMA map and load.
370 aprint_error_dev(sc->sc_dev, "unable to create CCB DMA map, rv = %d\n", rv);
376 aprint_error_dev(sc->sc_dev, "unable to load CCB DMA map, rv = %d\n", rv);
392 for (i = 0, ccb = sc->sc_ccbs; i < sc->sc_nccbs; i++, ccb++) {
396 &ccb->ccb_dmamap_xfer);
398 aprint_error_dev(sc->sc_dev, "can't create ccb dmamap (%d)\n", rv);
402 ccb->ccb_id = i;
403 ccb->ccb_ccbpa = sc->sc_dmamap->dm_segs[0].ds_addr +
404 CCB_OFF(sc, ccb);
405 SLIST_INSERT_HEAD(&sc->sc_ccb_free, ccb, ccb_chain);
639 dpt_cmd(struct dpt_softc *sc, struct dpt_ccb *ccb, int eatacmd, int icmd)
656 pa = (ccb != NULL ? ccb->ccb_ccbpa : 0);
688 * Spin waiting for a command to finish. The timeout value from the CCB is
689 * used. The CCB must be marked with CCB_PRIVATE, otherwise it'll will get
693 dpt_ccb_poll(struct dpt_softc *sc, struct dpt_ccb *ccb)
698 if ((ccb->ccb_flg & CCB_PRIVATE) == 0)
704 if ((ccb->ccb_flg & CCB_INTR) != 0) {
709 for (i = ccb->ccb_timeout * 20; i != 0; i--) {
712 if ((ccb->ccb_flg & CCB_INTR) != 0)
727 dpt_ccb_done(struct dpt_softc *sc, struct dpt_ccb *ccb)
731 xs = ccb->ccb_xs;
740 dpt_ccb_unmap(sc, ccb);
743 if (ccb->ccb_hba_status != SP_HBA_NO_ERROR) {
744 switch (ccb->ccb_hba_status) {
753 device_xname(sc->sc_dev), ccb->ccb_hba_status);
757 } else if (ccb->ccb_scsi_status != SCSI_OK) {
758 switch (ccb->ccb_scsi_status) {
760 memcpy(&xs->sense.scsi_sense, &ccb->ccb_sense,
771 ccb->ccb_scsi_status);
778 xs->status = ccb->ccb_scsi_status;
781 /* Free up the CCB and mark the command as done. */
782 dpt_ccb_free(sc, ccb);
787 * Specified CCB has timed out, abort it.
790 dpt_ccb_abort(struct dpt_softc *sc, struct dpt_ccb *ccb)
796 xs = ccb->ccb_xs;
805 if ((ccb->ccb_flg & CCB_ABORT) != 0) {
814 ccb->ccb_timeout = DPT_ABORT_TIMEOUT;
815 ccb->ccb_flg |= CCB_ABORT;
817 if (dpt_cmd(sc, ccb, CP_IMMEDIATE, CPI_SPEC_ABORT))
828 dpt_ccb_map(struct dpt_softc *sc, struct dpt_ccb *ccb)
837 xs = ccb->ccb_xs;
838 xfer = ccb->ccb_dmamap_xfer;
839 cp = &ccb->ccb_eata_cp;
860 dpt_ccb_free(sc, ccb);
878 sg = ccb->ccb_sg;
884 cp->cp_dataaddr = htobe32(CCB_OFF(sc, ccb) +
898 dpt_ccb_unmap(struct dpt_softc *sc, struct dpt_ccb *ccb)
901 bus_dmamap_sync(sc->sc_dmat, ccb->ccb_dmamap_xfer, 0,
902 ccb->ccb_dmamap_xfer->dm_mapsize,
903 (ccb->ccb_eata_cp.cp_ctl0 & CP_C0_DATA_IN) != 0 ?
905 bus_dmamap_unload(sc->sc_dmat, ccb->ccb_dmamap_xfer);
931 struct dpt_ccb *ccb;
961 * Get a CCB and fill it.
963 ccb = dpt_ccb_alloc(sc);
964 ccb->ccb_xs = xs;
965 ccb->ccb_timeout = xs->timeout;
967 cp = &ccb->ccb_eata_cp;
969 cp->cp_ccbid = ccb->ccb_id;
970 cp->cp_senselen = sizeof(ccb->ccb_sense);
994 CCB_OFF(sc, ccb) + offsetof(struct dpt_ccb, ccb_sense));
997 if (dpt_ccb_map(sc, ccb))
1004 /* Sync up CCB and status packet. */
1006 CCB_OFF(sc, ccb), sizeof(struct dpt_ccb),
1015 ccb->ccb_flg |= CCB_PRIVATE;
1017 if (dpt_cmd(sc, ccb, CP_DMA_CMD, 0)) {
1021 dpt_ccb_unmap(sc, ccb);
1022 dpt_ccb_free(sc, ccb);
1029 if (dpt_ccb_poll(sc, ccb)) {
1030 dpt_ccb_abort(sc, ccb);
1032 if (dpt_ccb_poll(sc, ccb))
1033 dpt_ccb_abort(sc, ccb);
1036 dpt_ccb_done(sc, ccb);
1061 struct dpt_ccb *ccb;
1066 /* Get a CCB and mark as private */
1067 ccb = dpt_ccb_alloc(sc);
1068 ccb->ccb_flg |= CCB_PRIVATE;
1069 ccb->ccb_timeout = 200;
1071 /* Put all the arguments into the CCB. */
1072 cp = &ccb->ccb_eata_cp;
1073 cp->cp_ccbid = ccb->ccb_id;
1074 cp->cp_senselen = sizeof(ccb->ccb_sense);
1090 /* Sync up CCB, status packet and scratch area. */
1091 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, CCB_OFF(sc, ccb),
1099 if (dpt_cmd(sc, ccb, CP_DMA_CMD, 0))
1102 if (dpt_ccb_poll(sc, ccb))
1105 if (ccb->ccb_hba_status != SP_HBA_NO_ERROR ||
1106 ccb->ccb_scsi_status != SCSI_OK)
1108 device_xname(sc->sc_dev), ccb->ccb_hba_status,
1109 ccb->ccb_scsi_status);
1111 /* Sync up the DMA map and free CCB, returning. */
1114 dpt_ccb_free(sc, ccb);
1278 struct dpt_ccb *ccb;
1287 * Get a CCB and fill.
1289 ccb = dpt_ccb_alloc(sc);
1290 ccb->ccb_flg |= CCB_PRIVATE | CCB_WAIT;
1291 ccb->ccb_timeout = 0;
1292 ccb->ccb_savesp = &sp;
1294 cp = &ccb->ccb_eata_cp;
1297 cp->cp_ccbid = ccb->ccb_id;
1298 cp->cp_senselen = sizeof(ccb->ccb_sense);
1300 CCB_OFF(sc, ccb) + offsetof(struct dpt_ccb, ccb_sense));
1307 xfer = ccb->ccb_dmamap_xfer;
1312 dpt_ccb_free(sc, ccb);
1322 dpt_ccb_free(sc, ccb);
1329 sg = ccb->ccb_sg;
1335 cp->cp_dataaddr = htobe32(CCB_OFF(sc, ccb) +
1348 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, CCB_OFF(sc, ccb),
1353 if (dpt_cmd(sc, ccb, CP_DMA_CMD, 0))
1355 tsleep(ccb, PWAIT, "dptucmd", 0);
1361 bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, CCB_OFF(sc, ccb),
1378 i = uimin(uslen, sizeof(ccb->ccb_sense));
1379 rv = copyout(&ccb->ccb_sense, ucp->ucp_senseaddr, i);
1386 ucp->ucp_hstatus = (u_int8_t)ccb->ccb_hba_status;
1387 ucp->ucp_tstatus = (u_int8_t)ccb->ccb_scsi_status;
1388 dpt_ccb_free(sc, ccb);