FreeBSD/sys/dev/mrsas/mrsas.c
/*
 * mrsas_map_mpt_cmd_status:	Allocate DMAable memory.
 * input:						Adapter instance soft state
 *
 * This function is called from mrsas_complete_cmd(), for LD IO and FastPath IO.
 * It checks the command status and maps the appropriate CAM status for the
 * CCB.
 */


This function is called from mrsas_complete_cmd(), for LD IO and FastPath IO.
It checks the command status and maps the appropriate CAM status for the
CCB.
This function is called from mrsas_complete_cmd () for LD IO and FastPath IO . It checks the command status and maps the appropriate CAM status for the CCB .
void
mrsas_map_mpt_cmd_status(struct mrsas_mpt_cmd *cmd, u_int8_t status, u_int8_t extStatus)
{
	struct mrsas_softc *sc = cmd->sc;
	u_int8_t *sense_data;
	switch (status) {
	case MFI_STAT_OK:
		cmd->ccb_ptr->ccb_h.status = CAM_REQ_CMP;
		break;
	case MFI_STAT_SCSI_IO_FAILED:
	case MFI_STAT_SCSI_DONE_WITH_ERROR:
		cmd->ccb_ptr->ccb_h.status = CAM_SCSI_STATUS_ERROR;
		sense_data = (u_int8_t *)&cmd->ccb_ptr->csio.sense_data;
		if (sense_data) {
			memcpy(sense_data, cmd->sense, 18);
			cmd->ccb_ptr->csio.sense_len = 18;
			cmd->ccb_ptr->ccb_h.status |= CAM_AUTOSNS_VALID;
		}
		break;
	case MFI_STAT_LD_OFFLINE:
	case MFI_STAT_DEVICE_NOT_FOUND:
		if (cmd->ccb_ptr->ccb_h.target_lun)
			cmd->ccb_ptr->ccb_h.status |= CAM_LUN_INVALID;
		else
			cmd->ccb_ptr->ccb_h.status |= CAM_DEV_NOT_THERE;
		break;
	case MFI_STAT_CONFIG_SEQ_MISMATCH:
		cmd->ccb_ptr->ccb_h.status |= CAM_REQUEUE_REQ;
		break;
	default:
		device_printf(sc->mrsas_dev, "FW cmd complete status %x\n", status);
		cmd->ccb_ptr->ccb_h.status = CAM_REQ_CMP_ERR;
		cmd->ccb_ptr->csio.scsi_status = status;
	}
	return;
}
void mrsas_map_mpt_cmd_status ( struct mrsas_mpt_cmd * cmd , u_int8_t status , u_int8_t extStatus ) { struct mrsas_softc * sc = cmd -> sc ; u_int8_t * sense_data ; switch ( status ) { case MFI_STAT_OK : cmd -> ccb_ptr -> ccb_h . status = CAM_REQ_CMP ; break ; case MFI_STAT_SCSI_IO_FAILED : case MFI_STAT_SCSI_DONE_WITH_ERROR : cmd -> ccb_ptr -> ccb_h . status = CAM_SCSI_STATUS_ERROR ; sense_data = ( u_int8_t * ) & cmd -> ccb_ptr -> csio . sense_data ; if ( sense_data ) { memcpy ( sense_data , cmd -> sense , 18 ) ; cmd -> ccb_ptr -> csio . sense_len = 18 ; cmd -> ccb_ptr -> ccb_h . status |= CAM_AUTOSNS_VALID ; } break ; case MFI_STAT_LD_OFFLINE : case MFI_STAT_DEVICE_NOT_FOUND : if ( cmd -> ccb_ptr -> ccb_h . target_lun ) cmd -> ccb_ptr -> ccb_h . status |= CAM_LUN_INVALID ; else cmd -> ccb_ptr -> ccb_h . status |= CAM_DEV_NOT_THERE ; break ; case MFI_STAT_CONFIG_SEQ_MISMATCH : cmd -> ccb_ptr -> ccb_h . status |= CAM_REQUEUE_REQ ; break ; default : device_printf ( sc -> mrsas_dev , " \n " , status ) ; cmd -> ccb_ptr -> ccb_h . status = CAM_REQ_CMP_ERR ; cmd -> ccb_ptr -> csio . scsi_status = status ; } return ; }
mrsas_map_mpt_cmd_status:    Allocate DMAable memory.
mrsas_map_mpt_cmd_status : Allocate DMAable memory .
/* For now just copy 18 bytes back */