Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Sep 2017 22:02:36 +0000 (UTC)
From:      Scott Long <scottl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r323380 - in head/sys/dev: mpr mps
Message-ID:  <201709092202.v89M2a94044894@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: scottl
Date: Sat Sep  9 22:02:36 2017
New Revision: 323380
URL: https://svnweb.freebsd.org/changeset/base/323380

Log:
  Convert some in-line printing of diagnostic into tables.
  
  Sponsored by:	Netflix

Modified:
  head/sys/dev/mpr/mpr_sas.c
  head/sys/dev/mpr/mpr_table.c
  head/sys/dev/mpr/mpr_table.h
  head/sys/dev/mps/mps_sas.c
  head/sys/dev/mps/mps_table.c
  head/sys/dev/mps/mps_table.h

Modified: head/sys/dev/mpr/mpr_sas.c
==============================================================================
--- head/sys/dev/mpr/mpr_sas.c	Sat Sep  9 21:33:43 2017	(r323379)
+++ head/sys/dev/mpr/mpr_sas.c	Sat Sep  9 22:02:36 2017	(r323380)
@@ -2204,44 +2204,6 @@ mprsas_action_scsiio(struct mprsas_softc *sassc, union
 	return;
 }
 
-static void
-mpr_response_code(struct mpr_softc *sc, u8 response_code)
-{
-        char *desc;
- 
-        switch (response_code) {
-        case MPI2_SCSITASKMGMT_RSP_TM_COMPLETE:
-                desc = "task management request completed";
-                break;
-        case MPI2_SCSITASKMGMT_RSP_INVALID_FRAME:
-                desc = "invalid frame";
-                break;
-        case MPI2_SCSITASKMGMT_RSP_TM_NOT_SUPPORTED:
-                desc = "task management request not supported";
-                break;
-        case MPI2_SCSITASKMGMT_RSP_TM_FAILED:
-                desc = "task management request failed";
-                break;
-        case MPI2_SCSITASKMGMT_RSP_TM_SUCCEEDED:
-                desc = "task management request succeeded";
-                break;
-        case MPI2_SCSITASKMGMT_RSP_TM_INVALID_LUN:
-                desc = "invalid lun";
-                break;
-        case 0xA:
-                desc = "overlapped tag attempted";
-                break;
-        case MPI2_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC:
-                desc = "task queued, however not sent to target";
-                break;
-        default:
-                desc = "unknown";
-                break;
-        }
-	mpr_dprint(sc, MPR_XINFO, "response_code(0x%01x): %s\n", response_code,
-	    desc);
-}
-
 /**
  * mpr_sc_failed_io_info - translated non-succesfull SCSI_IO request
  */
@@ -2257,125 +2219,16 @@ mpr_sc_failed_io_info(struct mpr_softc *sc, struct ccb
 	u8 scsi_status = mpi_reply->SCSIStatus;
 	char *desc_ioc_state = NULL;
 	char *desc_scsi_status = NULL;
-	char *desc_scsi_state = NULL;
 	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;
-	case MPI2_IOCSTATUS_INSUFFICIENT_POWER:
-		desc_ioc_state = "insufficient power";
-		break;
-	default:
-		desc_ioc_state = "unknown";
-		break;
-	}
+	desc_ioc_state = mpr_describe_table(mpr_iocstatus_string,
+	     ioc_status);
+	desc_scsi_status = mpr_describe_table(mpr_scsi_status_string,
+	    scsi_status);
 
-	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";
-	if (!scsi_state)
-		desc_scsi_state = " ";
-	if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID)
-		desc_scsi_state = "response info ";
-	if (scsi_state & MPI2_SCSI_STATE_TERMINATED)
-		desc_scsi_state = "state terminated ";
-	if (scsi_state & MPI2_SCSI_STATE_NO_SCSI_STATUS)
-		desc_scsi_state = "no status ";
-	if (scsi_state & MPI2_SCSI_STATE_AUTOSENSE_FAILED)
-		desc_scsi_state = "autosense failed ";
-	if (scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID)
-		desc_scsi_state = "autosense valid ";
-
 	mpr_dprint(sc, MPR_XINFO, "\thandle(0x%04x), ioc_status(%s)(0x%04x)\n",
 	    le16toh(mpi_reply->DevHandle), desc_ioc_state, ioc_status);
 	if (targ->encl_level_valid) {
@@ -2383,12 +2236,15 @@ mpr_sc_failed_io_info(struct mpr_softc *sc, struct ccb
 		    "connector name (%4s)\n", targ->encl_level, targ->encl_slot,
 		    targ->connector_name);
 	}
-	/* We can add more detail about underflow data here
+	
+	/*
+	 * We can add more detail about underflow data here
 	 * TO-DO
-	 * */
+	 */
 	mpr_dprint(sc, MPR_XINFO, "\tscsi_status(%s)(0x%02x), "
-	    "scsi_state(%s)(0x%02x)\n", desc_scsi_status, scsi_status,
-	    desc_scsi_state, scsi_state);
+	    "scsi_state %b\n", desc_scsi_status, scsi_status,
+	    scsi_state, "\20" "\1AutosenseValid" "\2AutosenseFailed"
+	    "\3NoScsiStatus" "\4Terminated" "\5Response InfoValid");
 
 	if (sc->mpr_debug & MPR_XINFO &&
 	    scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID) {
@@ -2400,7 +2256,10 @@ mpr_sc_failed_io_info(struct mpr_softc *sc, struct ccb
 	if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID) {
 		response_info = le32toh(mpi_reply->ResponseInfo);
 		response_bytes = (u8 *)&response_info;
-		mpr_response_code(sc,response_bytes[0]);
+		mpr_dprint(sc, MPR_XINFO, "response code(0x%01x): %s\n",
+		    response_bytes[0],
+		    mpr_describe_table(mpr_scsi_taskmgmt_string,
+		    response_bytes[0]));
 	}
 }
 
@@ -2960,10 +2819,10 @@ mprsas_scsiio_complete(struct mpr_softc *sc, struct mp
 		 */
 		mprsas_set_ccbstatus(ccb, CAM_REQ_CMP_ERR);
 		mpr_dprint(sc, MPR_INFO,
-		    "Controller reported %s target %u SMID %u, loginfo %x\n",
-		    ((rep->IOCStatus & MPI2_IOCSTATUS_MASK) ==
-		    MPI2_IOCSTATUS_SCSI_IOC_TERMINATED) ? "IOC_TERMINATED" :
-		    "EXT_TERMINATED", target_id, cm->cm_desc.Default.SMID,
+		    "Controller reported %s tgt %u SMID %u loginfo %x\n",
+		    mpr_describe_table(mpr_iocstatus_string,
+		    le16toh(rep->IOCStatus) & MPI2_IOCSTATUS_MASK),
+		    target_id, cm->cm_desc.Default.SMID,
 		    le32toh(rep->IOCLogInfo));
 		mpr_dprint(sc, MPR_XINFO,
 		    "SCSIStatus %x SCSIState %x xfercount %u\n",

Modified: head/sys/dev/mpr/mpr_table.c
==============================================================================
--- head/sys/dev/mpr/mpr_table.c	Sat Sep  9 21:33:43 2017	(r323379)
+++ head/sys/dev/mpr/mpr_table.c	Sat Sep  9 22:02:36 2017	(r323380)
@@ -208,6 +208,57 @@ struct mpr_table_lookup mpr_pcie_linkrate_names[] = {
 	{"LinkRate Unknown",		0x00}
 };
 
+struct mpr_table_lookup mpr_iocstatus_string[] = {
+	{"success",			MPI2_IOCSTATUS_SUCCESS},
+	{"invalid function",		MPI2_IOCSTATUS_INVALID_FUNCTION},
+	{"scsi recovered error",	MPI2_IOCSTATUS_SCSI_RECOVERED_ERROR},
+	{"scsi invalid dev handle",	MPI2_IOCSTATUS_SCSI_INVALID_DEVHANDLE},
+	{"scsi device not there",	MPI2_IOCSTATUS_SCSI_DEVICE_NOT_THERE},
+	{"scsi data overrun",		MPI2_IOCSTATUS_SCSI_DATA_OVERRUN},
+	{"scsi data underrun",		MPI2_IOCSTATUS_SCSI_DATA_UNDERRUN},
+	{"scsi io data error",		MPI2_IOCSTATUS_SCSI_IO_DATA_ERROR},
+	{"scsi protocol error",		MPI2_IOCSTATUS_SCSI_PROTOCOL_ERROR},
+	{"scsi task terminated",	MPI2_IOCSTATUS_SCSI_TASK_TERMINATED},
+	{"scsi residual mismatch",	MPI2_IOCSTATUS_SCSI_RESIDUAL_MISMATCH},
+	{"scsi task mgmt failed",	MPI2_IOCSTATUS_SCSI_TASK_MGMT_FAILED},
+	{"scsi ioc terminated",		MPI2_IOCSTATUS_SCSI_IOC_TERMINATED},
+	{"scsi ext terminated",		MPI2_IOCSTATUS_SCSI_EXT_TERMINATED},
+	{"eedp guard error",		MPI2_IOCSTATUS_EEDP_GUARD_ERROR},
+	{"eedp ref tag error",		MPI2_IOCSTATUS_EEDP_REF_TAG_ERROR},
+	{"eedp app tag error",		MPI2_IOCSTATUS_EEDP_APP_TAG_ERROR},
+	{NULL, 0},
+	{"unknown",			0x00}
+};
+
+struct mpr_table_lookup mpr_scsi_status_string[] = {
+	{"good",			MPI2_SCSI_STATUS_GOOD},
+	{"check condition",		MPI2_SCSI_STATUS_CHECK_CONDITION},
+	{"condition met",		MPI2_SCSI_STATUS_CONDITION_MET},
+	{"busy",			MPI2_SCSI_STATUS_BUSY},
+	{"intermediate",		MPI2_SCSI_STATUS_INTERMEDIATE},
+	{"intermediate condmet",	MPI2_SCSI_STATUS_INTERMEDIATE_CONDMET},
+	{"reservation conflict",	MPI2_SCSI_STATUS_RESERVATION_CONFLICT},
+	{"command terminated",		MPI2_SCSI_STATUS_COMMAND_TERMINATED},
+	{"task set full",		MPI2_SCSI_STATUS_TASK_SET_FULL},
+	{"aca active",			MPI2_SCSI_STATUS_ACA_ACTIVE},
+	{"task aborted",		MPI2_SCSI_STATUS_TASK_ABORTED},
+	{NULL, 0},
+	{"unknown",			0x00}
+};
+
+struct mpr_table_lookup mpr_scsi_taskmgmt_string[] = {
+	{"task mgmt request completed",	MPI2_SCSITASKMGMT_RSP_TM_COMPLETE},
+	{"invalid frame",		MPI2_SCSITASKMGMT_RSP_INVALID_FRAME},
+	{"task mgmt request not supp",	MPI2_SCSITASKMGMT_RSP_TM_NOT_SUPPORTED},
+	{"task mgmt request failed",	MPI2_SCSITASKMGMT_RSP_TM_FAILED},
+	{"task mgmt request_succeeded",	MPI2_SCSITASKMGMT_RSP_TM_SUCCEEDED},
+	{"invalid lun",			MPI2_SCSITASKMGMT_RSP_TM_INVALID_LUN},
+	{"overlapped tag attempt",	0xA},
+	{"task queued on IOC",		MPI2_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC},
+	{NULL, 0},
+	{"unknown",			0x00}
+};
+
 void
 mpr_describe_devinfo(uint32_t devinfo, char *string, int len)
 {

Modified: head/sys/dev/mpr/mpr_table.h
==============================================================================
--- head/sys/dev/mpr/mpr_table.h	Sat Sep  9 21:33:43 2017	(r323379)
+++ head/sys/dev/mpr/mpr_table.h	Sat Sep  9 22:02:36 2017	(r323380)
@@ -41,6 +41,9 @@ extern struct mpr_table_lookup mpr_event_names[];
 extern struct mpr_table_lookup mpr_phystatus_names[];
 extern struct mpr_table_lookup mpr_linkrate_names[];
 extern struct mpr_table_lookup mpr_pcie_linkrate_names[];
+extern struct mpr_table_lookup mpr_iocstatus_string[];
+extern struct mpr_table_lookup mpr_scsi_status_string[];
+extern struct mpr_table_lookup mpr_scsi_taskmgmt_string[];
 
 void mpr_print_iocfacts(struct mpr_softc *, MPI2_IOC_FACTS_REPLY *);
 void mpr_print_portfacts(struct mpr_softc *, MPI2_PORT_FACTS_REPLY *);

Modified: head/sys/dev/mps/mps_sas.c
==============================================================================
--- head/sys/dev/mps/mps_sas.c	Sat Sep  9 21:33:43 2017	(r323379)
+++ head/sys/dev/mps/mps_sas.c	Sat Sep  9 22:02:36 2017	(r323380)
@@ -1935,43 +1935,6 @@ mpssas_action_scsiio(struct mpssas_softc *sassc, union
 	return;
 }
 
-static void
-mps_response_code(struct mps_softc *sc, u8 response_code)
-{
-        char *desc;
- 
-        switch (response_code) {
-        case MPI2_SCSITASKMGMT_RSP_TM_COMPLETE:
-                desc = "task management request completed";
-                break;
-        case MPI2_SCSITASKMGMT_RSP_INVALID_FRAME:
-                desc = "invalid frame";
-                break;
-        case MPI2_SCSITASKMGMT_RSP_TM_NOT_SUPPORTED:
-                desc = "task management request not supported";
-                break;
-        case MPI2_SCSITASKMGMT_RSP_TM_FAILED:
-                desc = "task management request failed";
-                break;
-        case MPI2_SCSITASKMGMT_RSP_TM_SUCCEEDED:
-                desc = "task management request succeeded";
-                break;
-        case MPI2_SCSITASKMGMT_RSP_TM_INVALID_LUN:
-                desc = "invalid lun";
-                break;
-        case 0xA:
-                desc = "overlapped tag attempted";
-                break;
-        case MPI2_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC:
-                desc = "task queued, however not sent to target";
-                break;
-        default:
-                desc = "unknown";
-                break;
-        }
-		mps_dprint(sc, MPS_XINFO, "response_code(0x%01x): %s\n",
-                response_code, desc);
-}
 /**
  * mps_sc_failed_io_info - translated non-succesfull SCSI_IO request
  */
@@ -1985,132 +1948,28 @@ mps_sc_failed_io_info(struct mps_softc *sc, struct ccb
 	    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 = NULL;
 	u32 log_info = le32toh(mpi_reply->IOCLogInfo);
+	const char *desc_ioc_state, *desc_scsi_status;
 	
 	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;
-	}
+	desc_ioc_state = mps_describe_table(mps_iocstatus_string,
+	    ioc_status);
+	desc_scsi_status = mps_describe_table(mps_scsi_status_string,
+	    scsi_status);
 
-	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";
-	if (!scsi_state)
-		desc_scsi_state = " ";
-	if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID)
-		desc_scsi_state = "response info ";
-	if (scsi_state & MPI2_SCSI_STATE_TERMINATED)
-		desc_scsi_state = "state terminated ";
-	if (scsi_state & MPI2_SCSI_STATE_NO_SCSI_STATUS)
-		desc_scsi_state = "no status ";
-	if (scsi_state & MPI2_SCSI_STATE_AUTOSENSE_FAILED)
-		desc_scsi_state = "autosense failed ";
-	if (scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID)
-		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);
-	/* We can add more detail about underflow data here
+
+	/*
+	 *We can add more detail about underflow data here
 	 * TO-DO
-	 * */
+	 */
 	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);
+	    "scsi_state %b\n", desc_scsi_status, scsi_status,
+	    scsi_state, "\20" "\1AutosenseValid" "\2AutosenseFailed"
+	    "\3NoScsiStatus" "\4Terminated" "\5Response InfoValid");
 
 	if (sc->mps_debug & MPS_XINFO &&
 		scsi_state & MPI2_SCSI_STATE_AUTOSENSE_VALID) {
@@ -2122,7 +1981,10 @@ mps_sc_failed_io_info(struct mps_softc *sc, struct ccb
 	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_dprint(sc, MPS_XINFO, "response code(0x%1x): %s\n",
+		    response_bytes[0],
+		    mps_describe_table(mps_scsi_taskmgmt_string,
+		    response_bytes[0]));
 	}
 }
 
@@ -2490,10 +2352,10 @@ mpssas_scsiio_complete(struct mps_softc *sc, struct mp
 		 */
 		mpssas_set_ccbstatus(ccb, CAM_REQ_CMP_ERR);
 		mps_dprint(sc, MPS_INFO,
-		    "Controller reported %s target %u SMID %u, loginfo %x\n",
-		    ((rep->IOCStatus & MPI2_IOCSTATUS_MASK) ==
-		    MPI2_IOCSTATUS_SCSI_IOC_TERMINATED) ? "IOC_TERMINATED" :
-		    "EXT_TERMINATED", target_id, cm->cm_desc.Default.SMID,
+		    "Controller reported %s tgt %u SMID %u loginfo %x\n",
+		    mps_describe_table(mps_iocstatus_string,
+		    le16toh(rep->IOCStatus) & MPI2_IOCSTATUS_MASK),
+		    target_id, cm->cm_desc.Default.SMID,
 		    le32toh(rep->IOCLogInfo));
 		mps_dprint(sc, MPS_XINFO,
 		    "SCSIStatus %x SCSIState %x xfercount %u\n",

Modified: head/sys/dev/mps/mps_table.c
==============================================================================
--- head/sys/dev/mps/mps_table.c	Sat Sep  9 21:33:43 2017	(r323379)
+++ head/sys/dev/mps/mps_table.c	Sat Sep  9 22:02:36 2017	(r323380)
@@ -185,6 +185,57 @@ struct mps_table_lookup mps_sasdev_reason[] = {
 	{"Unknown",			0x00}
 };
 
+struct mps_table_lookup mps_iocstatus_string[] = {
+	{"success",			MPI2_IOCSTATUS_SUCCESS},
+	{"invalid function",		MPI2_IOCSTATUS_INVALID_FUNCTION},
+	{"scsi recovered error",	MPI2_IOCSTATUS_SCSI_RECOVERED_ERROR},
+	{"scsi invalid dev handle",	MPI2_IOCSTATUS_SCSI_INVALID_DEVHANDLE},
+	{"scsi device not there",	MPI2_IOCSTATUS_SCSI_DEVICE_NOT_THERE},
+	{"scsi data overrun",		MPI2_IOCSTATUS_SCSI_DATA_OVERRUN},
+	{"scsi data underrun",		MPI2_IOCSTATUS_SCSI_DATA_UNDERRUN},
+	{"scsi io data error",		MPI2_IOCSTATUS_SCSI_IO_DATA_ERROR},
+	{"scsi protocol error",		MPI2_IOCSTATUS_SCSI_PROTOCOL_ERROR},
+	{"scsi task terminated",	MPI2_IOCSTATUS_SCSI_TASK_TERMINATED},
+	{"scsi residual mismatch",	MPI2_IOCSTATUS_SCSI_RESIDUAL_MISMATCH},
+	{"scsi task mgmt failed",	MPI2_IOCSTATUS_SCSI_TASK_MGMT_FAILED},
+	{"scsi ioc terminated",		MPI2_IOCSTATUS_SCSI_IOC_TERMINATED},
+	{"scsi ext terminated",		MPI2_IOCSTATUS_SCSI_EXT_TERMINATED},
+	{"eedp guard error",		MPI2_IOCSTATUS_EEDP_GUARD_ERROR},
+	{"eedp ref tag error",		MPI2_IOCSTATUS_EEDP_REF_TAG_ERROR},
+	{"eedp app tag error",		MPI2_IOCSTATUS_EEDP_APP_TAG_ERROR},
+	{NULL, 0},
+	{"unknown",			0x00}
+};
+
+struct mps_table_lookup mps_scsi_status_string[] = {
+	{"good",			MPI2_SCSI_STATUS_GOOD},
+	{"check condition",		MPI2_SCSI_STATUS_CHECK_CONDITION},
+	{"condition met",		MPI2_SCSI_STATUS_CONDITION_MET},
+	{"busy",			MPI2_SCSI_STATUS_BUSY},
+	{"intermediate",		MPI2_SCSI_STATUS_INTERMEDIATE},
+	{"intermediate condmet",	MPI2_SCSI_STATUS_INTERMEDIATE_CONDMET},
+	{"reservation conflict",	MPI2_SCSI_STATUS_RESERVATION_CONFLICT},
+	{"command terminated",		MPI2_SCSI_STATUS_COMMAND_TERMINATED},
+	{"task set full",		MPI2_SCSI_STATUS_TASK_SET_FULL},
+	{"aca active",			MPI2_SCSI_STATUS_ACA_ACTIVE},
+	{"task aborted",		MPI2_SCSI_STATUS_TASK_ABORTED},
+	{NULL, 0},
+	{"unknown",			0x00}
+};
+
+struct mps_table_lookup mps_scsi_taskmgmt_string[] = {
+	{"task mgmt request completed",	MPI2_SCSITASKMGMT_RSP_TM_COMPLETE},
+	{"invalid frame",		MPI2_SCSITASKMGMT_RSP_INVALID_FRAME},
+	{"task mgmt request not supp",	MPI2_SCSITASKMGMT_RSP_TM_NOT_SUPPORTED},
+	{"task mgmt request failed",	MPI2_SCSITASKMGMT_RSP_TM_FAILED},
+	{"task mgmt request_succeeded",	MPI2_SCSITASKMGMT_RSP_TM_SUCCEEDED},
+	{"invalid lun",			MPI2_SCSITASKMGMT_RSP_TM_INVALID_LUN},
+	{"overlapped tag attempt",	0xA},
+	{"task queued on IOC",		MPI2_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC},
+	{NULL, 0},
+	{"unknown",			0x00}
+};
+
 void
 mps_describe_devinfo(uint32_t devinfo, char *string, int len)
 {

Modified: head/sys/dev/mps/mps_table.h
==============================================================================
--- head/sys/dev/mps/mps_table.h	Sat Sep  9 21:33:43 2017	(r323379)
+++ head/sys/dev/mps/mps_table.h	Sat Sep  9 22:02:36 2017	(r323380)
@@ -40,6 +40,9 @@ void mps_describe_devinfo(uint32_t devinfo, char *stri
 extern struct mps_table_lookup mps_event_names[];
 extern struct mps_table_lookup mps_phystatus_names[];
 extern struct mps_table_lookup mps_linkrate_names[];
+extern struct mps_table_lookup mps_iocstatus_string[];
+extern struct mps_table_lookup mps_scsi_status_string[];
+extern struct mps_table_lookup mps_scsi_taskmgmt_string[];
 
 void mps_print_iocfacts(struct mps_softc *, MPI2_IOC_FACTS_REPLY *);
 void mps_print_portfacts(struct mps_softc *, MPI2_PORT_FACTS_REPLY *);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709092202.v89M2a94044894>