FreeBSD/sys/dev/mps/mps_sas.c
/**
 * mps_sc_failed_io_info - translated non-succesfull SCSI_IO request
 */
translated non-succesfull SCSI_IO request
translated non - succesfull SCSI_IO request
static void
mps_sc_failed_io_info(struct mps_softc *sc, struct ccb_scsiio *csio,
    Mpi2SCSIIOReply_t *mpi_reply)
{
	u32 response_info;
	u8 *response_bytes;
	u16 ioc_status = le16toh(mpi_reply->IOCStatus) &
	    MPI2_IOCSTATUS_MASK;
	u8 scsi_state = mpi_reply->SCSIState;
	u8 scsi_status = mpi_reply->SCSIStatus;
	char *desc_ioc_state = NULL;
	char *desc_scsi_status = NULL;
	char *desc_scsi_state = sc->tmp_string;
	u32 log_info = le32toh(mpi_reply->IOCLogInfo);
	if (log_info == 0x31170000)
		return;
	switch (ioc_status) {
	case MPI2_IOCSTATUS_SUCCESS:
		desc_ioc_state = "success";
		break;
	case MPI2_IOCSTATUS_INVALID_FUNCTION:
		desc_ioc_state = "invalid function";
		break;
	case MPI2_IOCSTATUS_SCSI_RECOVERED_ERROR:
		desc_ioc_state = "scsi recovered error";
		break;
	case MPI2_IOCSTATUS_SCSI_INVALID_DEVHANDLE:
		desc_ioc_state = "scsi invalid dev handle";
		break;
	case MPI2_IOCSTATUS_SCSI_DEVICE_NOT_THERE:
		desc_ioc_state = "scsi device not there";
		break;
	case MPI2_IOCSTATUS_SCSI_DATA_OVERRUN:
		desc_ioc_state = "scsi data overrun";
		break;
	case MPI2_IOCSTATUS_SCSI_DATA_UNDERRUN:
		desc_ioc_state = "scsi data underrun";
		break;
	case MPI2_IOCSTATUS_SCSI_IO_DATA_ERROR:
		desc_ioc_state = "scsi io data error";
		break;
	case MPI2_IOCSTATUS_SCSI_PROTOCOL_ERROR:
		desc_ioc_state = "scsi protocol error";
		break;
	case MPI2_IOCSTATUS_SCSI_TASK_TERMINATED:
		desc_ioc_state = "scsi task terminated";
		break;
	case MPI2_IOCSTATUS_SCSI_RESIDUAL_MISMATCH:
		desc_ioc_state = "scsi residual mismatch";
		break;
	case MPI2_IOCSTATUS_SCSI_TASK_MGMT_FAILED:
		desc_ioc_state = "scsi task mgmt failed";
		break;
	case MPI2_IOCSTATUS_SCSI_IOC_TERMINATED:
		desc_ioc_state = "scsi ioc terminated";
		break;
	case MPI2_IOCSTATUS_SCSI_EXT_TERMINATED:
		desc_ioc_state = "scsi ext terminated";
		break;
	case MPI2_IOCSTATUS_EEDP_GUARD_ERROR:
		desc_ioc_state = "eedp guard error";
		break;
	case MPI2_IOCSTATUS_EEDP_REF_TAG_ERROR:
		desc_ioc_state = "eedp ref tag error";
		break;
	case MPI2_IOCSTATUS_EEDP_APP_TAG_ERROR:
		desc_ioc_state = "eedp app tag error";
		break;
	default:
		desc_ioc_state = "unknown";
		break;
	}
	switch (scsi_status) {
	case MPI2_SCSI_STATUS_GOOD:
		desc_scsi_status = "good";
		break;
	case MPI2_SCSI_STATUS_CHECK_CONDITION:
		desc_scsi_status = "check condition";
		break;
	case MPI2_SCSI_STATUS_CONDITION_MET:
		desc_scsi_status = "condition met";
		break;
	case MPI2_SCSI_STATUS_BUSY:
		desc_scsi_status = "busy";
		break;
	case MPI2_SCSI_STATUS_INTERMEDIATE:
		desc_scsi_status = "intermediate";
		break;
	case MPI2_SCSI_STATUS_INTERMEDIATE_CONDMET:
		desc_scsi_status = "intermediate condmet";
		break;
	case MPI2_SCSI_STATUS_RESERVATION_CONFLICT:
		desc_scsi_status = "reservation conflict";
		break;
	case MPI2_SCSI_STATUS_COMMAND_TERMINATED:
		desc_scsi_status = "command terminated";
		break;
	case MPI2_SCSI_STATUS_TASK_SET_FULL:
		desc_scsi_status = "task set full";
		break;
	case MPI2_SCSI_STATUS_ACA_ACTIVE:
		desc_scsi_status = "aca active";
		break;
	case MPI2_SCSI_STATUS_TASK_ABORTED:
		desc_scsi_status = "task aborted";
		break;
	default:
		desc_scsi_status = "unknown";
		break;
	}
	desc_scsi_state[0] = '\0';
	if (!scsi_state)
		desc_scsi_state = " ";
	if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID)
		strcat(desc_scsi_state, "response info ");
	if (scsi_state & MPI2_SCSI_STATE_TERMINATED)
		strcat(desc_scsi_state, "state terminated ");
	if (scsi_state & MPI2_SCSI_STATE_NO_SCSI_STATUS)
		strcat(desc_scsi_state, "no status ");
	if (scsi_state & MPI2_SCSI_STATE_AUTOSENSE_FAILED)
		strcat(desc_scsi_state, "autosense failed ");
	if (scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID)
		strcat(desc_scsi_state, "autosense valid ");
	mps_dprint(sc, MPS_XINFO, "\thandle(0x%04x), ioc_status(%s)(0x%04x)\n",
	    le16toh(mpi_reply->DevHandle), desc_ioc_state, ioc_status);
	mps_dprint(sc, MPS_XINFO, "\tscsi_status(%s)(0x%02x), "
	    "scsi_state(%s)(0x%02x)\n", desc_scsi_status, scsi_status,
	    desc_scsi_state, scsi_state);
	if (sc->mps_debug & MPS_XINFO &&
		scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID) {
		mps_dprint(sc, MPS_XINFO, "-> Sense Buffer Data : Start :\n");
		scsi_sense_print(csio);
		mps_dprint(sc, MPS_XINFO, "-> Sense Buffer Data : End :\n");
	}
	if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID) {
		response_info = le32toh(mpi_reply->ResponseInfo);
		response_bytes = (u8 *)&response_info;
		mps_response_code(sc,response_bytes[0]);
	}
}
static void mps_sc_failed_io_info ( struct mps_softc * sc , struct ccb_scsiio * csio , Mpi2SCSIIOReply_t * mpi_reply ) { u32 response_info ; u8 * response_bytes ; u16 ioc_status = le16toh ( mpi_reply -> IOCStatus ) & MPI2_IOCSTATUS_MASK ; u8 scsi_state = mpi_reply -> SCSIState ; u8 scsi_status = mpi_reply -> SCSIStatus ; char * desc_ioc_state = NULL ; char * desc_scsi_status = NULL ; char * desc_scsi_state = sc -> tmp_string ; u32 log_info = le32toh ( mpi_reply -> IOCLogInfo ) ; if ( log_info == 0x31170000 ) return ; switch ( ioc_status ) { case MPI2_IOCSTATUS_SUCCESS : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_INVALID_FUNCTION : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_SCSI_RECOVERED_ERROR : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_SCSI_INVALID_DEVHANDLE : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_SCSI_DEVICE_NOT_THERE : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_SCSI_DATA_OVERRUN : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_SCSI_DATA_UNDERRUN : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_SCSI_IO_DATA_ERROR : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_SCSI_PROTOCOL_ERROR : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_SCSI_TASK_TERMINATED : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_SCSI_RESIDUAL_MISMATCH : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_SCSI_TASK_MGMT_FAILED : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_SCSI_IOC_TERMINATED : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_SCSI_EXT_TERMINATED : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_EEDP_GUARD_ERROR : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_EEDP_REF_TAG_ERROR : desc_ioc_state = " " ; break ; case MPI2_IOCSTATUS_EEDP_APP_TAG_ERROR : desc_ioc_state = " " ; break ; default : desc_ioc_state = " " ; break ; } switch ( scsi_status ) { case MPI2_SCSI_STATUS_GOOD : desc_scsi_status = " " ; break ; case MPI2_SCSI_STATUS_CHECK_CONDITION : desc_scsi_status = " " ; break ; case MPI2_SCSI_STATUS_CONDITION_MET : desc_scsi_status = " " ; break ; case MPI2_SCSI_STATUS_BUSY : desc_scsi_status = " " ; break ; case MPI2_SCSI_STATUS_INTERMEDIATE : desc_scsi_status = " " ; break ; case MPI2_SCSI_STATUS_INTERMEDIATE_CONDMET : desc_scsi_status = " " ; break ; case MPI2_SCSI_STATUS_RESERVATION_CONFLICT : desc_scsi_status = " " ; break ; case MPI2_SCSI_STATUS_COMMAND_TERMINATED : desc_scsi_status = " " ; break ; case MPI2_SCSI_STATUS_TASK_SET_FULL : desc_scsi_status = " " ; break ; case MPI2_SCSI_STATUS_ACA_ACTIVE : desc_scsi_status = " " ; break ; case MPI2_SCSI_STATUS_TASK_ABORTED : desc_scsi_status = " " ; break ; default : desc_scsi_status = " " ; break ; } desc_scsi_state [ 0 ] = ' \0 ' ; if ( ! scsi_state ) desc_scsi_state = " " ; if ( scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID ) strcat ( desc_scsi_state , " " ) ; if ( scsi_state & MPI2_SCSI_STATE_TERMINATED ) strcat ( desc_scsi_state , " " ) ; if ( scsi_state & MPI2_SCSI_STATE_NO_SCSI_STATUS ) strcat ( desc_scsi_state , " " ) ; if ( scsi_state & MPI2_SCSI_STATE_AUTOSENSE_FAILED ) strcat ( desc_scsi_state , " " ) ; if ( scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID ) strcat ( desc_scsi_state , " " ) ; mps_dprint ( sc , MPS_XINFO , " \t \n " , le16toh ( mpi_reply -> DevHandle ) , desc_ioc_state , ioc_status ) ; mps_dprint ( sc , MPS_XINFO , " \t " " \n " , desc_scsi_status , scsi_status , desc_scsi_state , scsi_state ) ; if ( sc -> mps_debug & MPS_XINFO && scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID ) { mps_dprint ( sc , MPS_XINFO , " \n " ) ; scsi_sense_print ( csio ) ; mps_dprint ( sc , MPS_XINFO , " \n " ) ; } if ( scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID ) { response_info = le32toh ( mpi_reply -> ResponseInfo ) ; response_bytes = ( u8 * ) & response_info ; mps_response_code ( sc , response_bytes [ 0 ] ) ; } }
mps_sc_failed_io_info - translated non-succesfull SCSI_IO request
mps_sc_failed_io_info - translated non - succesfull SCSI_IO request
/* We can add more detail about underflow data here
	 * TO-DO
	 * */