FreeBSD/sys/dev/firewire/sbp_targ.c
/*
 * Invoked as a callback handler from fwmem_read/write_block
 *
 * Process read/write of initiator address space
 * completion and pass status onto the backend target.
 * If this is a partial read/write for a CCB then
 * we decrement the orbi's refcount to indicate
 * the status of the read/write is complete
 */
Invoked as a callback handler from fwmem_read/write_block
Process read/write of initiator address space
completion and pass status onto the backend target.
If this is a partial read/write for a CCB then
we decrement the orbi's refcount to indicate
the status of the read/write is complete
Invoked as a callback handler from fwmem_read / write_block Process read / write of initiator address space completion and pass status onto the backend target . If this is a partial read / write for a CCB then we decrement the orbi ' s refcount to indicate the status of the read / write is complete
static void
sbp_targ_cam_done(struct fw_xfer *xfer)
{
	struct orb_info *orbi;
	union ccb *ccb;
	orbi = (struct orb_info *)xfer->sc;
	if (debug)
		printf("%s: resp=%d refcount=%d\n", __func__,
			xfer->resp, orbi->refcount);
	if (xfer->resp != 0) {
		printf("%s: xfer->resp = %d\n", __func__, xfer->resp);
		orbi->status.resp = SBP_TRANS_FAIL;
		orbi->status.status = OBJ_DATA | SBE_TIMEOUT;
		orbi->status.dead = 1;
		sbp_targ_abort(orbi->sc, STAILQ_NEXT(orbi, link));
	}
	orbi->refcount--;
	ccb = orbi->ccb;
	if (orbi->refcount == 0) {
		orbi->ccb = NULL;
		if (orbi->state == ORBI_STATUS_ABORTED) {
			if (debug)
				printf("%s: orbi aborted\n", __func__);
			sbp_targ_remove_orb_info(orbi->login, orbi);
			if (orbi->page_table != NULL) {
				if (debug)
					printf("%s: free orbi->page_table %p\n",
						__func__, orbi->page_table);
				free(orbi->page_table, M_SBP_TARG);
			}
			if (debug)
				printf("%s: free orbi %p\n", __func__, orbi);
			free(orbi, M_SBP_TARG);
			orbi = NULL;
		} else if (orbi->status.resp == ORBI_STATUS_NONE) {
			if ((ccb->ccb_h.flags & CAM_SEND_STATUS) != 0) {
				if (debug) 
					printf("%s: CAM_SEND_STATUS set %0x\n", __func__, ccb->ccb_h.flags);
				sbp_targ_send_status(orbi, ccb);
			} else {
				if (debug)
					printf("%s: CAM_SEND_STATUS not set %0x\n", __func__, ccb->ccb_h.flags);
				ccb->ccb_h.status = CAM_REQ_CMP;
			}
			SBP_LOCK(orbi->sc);
			xpt_done(ccb);
			SBP_UNLOCK(orbi->sc);
		} else {
			orbi->status.len = 1;
			sbp_targ_status_FIFO(orbi,
		    	    orbi->login->fifo_hi, orbi->login->fifo_lo,
			    1);
			ccb->ccb_h.status = CAM_REQ_ABORTED;
			SBP_LOCK(orbi->sc);
			xpt_done(ccb);
			SBP_UNLOCK(orbi->sc);
		}
	}
	fw_xfer_free(xfer);
}
static void sbp_targ_cam_done ( struct fw_xfer * xfer ) { struct orb_info * orbi ; union ccb * ccb ; orbi = ( struct orb_info * ) xfer -> sc ; if ( debug ) printf ( " \n " , __func__ , xfer -> resp , orbi -> refcount ) ; if ( xfer -> resp != 0 ) { printf ( " \n " , __func__ , xfer -> resp ) ; orbi -> status . resp = SBP_TRANS_FAIL ; orbi -> status . status = OBJ_DATA | SBE_TIMEOUT ; orbi -> status . dead = 1 ; sbp_targ_abort ( orbi -> sc , STAILQ_NEXT ( orbi , link ) ) ; } orbi -> refcount -- ; ccb = orbi -> ccb ; if ( orbi -> refcount == 0 ) { orbi -> ccb = NULL ; if ( orbi -> state == ORBI_STATUS_ABORTED ) { if ( debug ) printf ( " \n " , __func__ ) ; sbp_targ_remove_orb_info ( orbi -> login , orbi ) ; if ( orbi -> page_table != NULL ) { if ( debug ) printf ( " \n " , __func__ , orbi -> page_table ) ; free ( orbi -> page_table , M_SBP_TARG ) ; } if ( debug ) printf ( " \n " , __func__ , orbi ) ; free ( orbi , M_SBP_TARG ) ; orbi = NULL ; } else if ( orbi -> status . resp == ORBI_STATUS_NONE ) { if ( ( ccb -> ccb_h . flags & CAM_SEND_STATUS ) != 0 ) { if ( debug ) printf ( " \n " , __func__ , ccb -> ccb_h . flags ) ; sbp_targ_send_status ( orbi , ccb ) ; } else { if ( debug ) printf ( " \n " , __func__ , ccb -> ccb_h . flags ) ; ccb -> ccb_h . status = CAM_REQ_CMP ; } SBP_LOCK ( orbi -> sc ) ; xpt_done ( ccb ) ; SBP_UNLOCK ( orbi -> sc ) ; } else { orbi -> status . len = 1 ; sbp_targ_status_FIFO ( orbi , orbi -> login -> fifo_hi , orbi -> login -> fifo_lo , 1 ) ; ccb -> ccb_h . status = CAM_REQ_ABORTED ; SBP_LOCK ( orbi -> sc ) ; xpt_done ( ccb ) ; SBP_UNLOCK ( orbi -> sc ) ; } } fw_xfer_free ( xfer ) ; }
Invoked as a callback handler from fwmem_read/write_block
 Process read/write of initiator address space
 completion and pass status onto the backend target.
Invoked as a callback handler from fwmem_read / write_block Process read / write of initiator address space completion and pass status onto the backend target .
/*XXX*/ /*dequeue*/