Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Dec 2018 06:14:32 +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: r342388 - in head/sys/dev: mpr mps
Message-ID:  <201812240614.wBO6EWKs052018@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: scottl
Date: Mon Dec 24 06:14:32 2018
New Revision: 342388
URL: https://svnweb.freebsd.org/changeset/base/342388

Log:
  Further refactoring for task management commands.  Also fix a related
  typo from the previous commit.

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

Modified: head/sys/dev/mpr/mpr_sas.c
==============================================================================
--- head/sys/dev/mpr/mpr_sas.c	Mon Dec 24 05:54:36 2018	(r342387)
+++ head/sys/dev/mpr/mpr_sas.c	Mon Dec 24 06:14:32 2018	(r342388)
@@ -239,10 +239,16 @@ mprsas_startup_decrement(struct mprsas_softc *sassc)
 struct mpr_command *
 mprsas_alloc_tm(struct mpr_softc *sc)
 {
+	MPI2_SCSI_TASK_MANAGE_REQUEST *req;
 	struct mpr_command *tm;
 
 	MPR_FUNCTRACE(sc);
 	tm = mpr_alloc_high_priority_command(sc);
+	if (tm == NULL)
+		return (NULL);
+
+	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)tm->cm_req;
+	req->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
 	return tm;
 }
 
@@ -462,7 +468,6 @@ mprsas_prepare_volume_remove(struct mprsas_softc *sass
 
 	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)cm->cm_req;
 	req->DevHandle = targ->handle;
-	req->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
 	req->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET;
 
 	/* SAS Hard Link Reset / SATA Link Reset */
@@ -494,7 +499,7 @@ mprsas_prepare_remove(struct mprsas_softc *sassc, uint
 {
 	MPI2_SCSI_TASK_MANAGE_REQUEST *req;
 	struct mpr_softc *sc;
-	struct mpr_command *cm;
+	struct mpr_command *tm;
 	struct mprsas_target *targ = NULL;
 
 	MPR_FUNCTRACE(sassc->sc);
@@ -512,8 +517,8 @@ mprsas_prepare_remove(struct mprsas_softc *sassc, uint
 
 	targ->flags |= MPRSAS_TARGET_INREMOVAL;
 
-	cm = mprsas_alloc_tm(sc);
-	if (cm == NULL) {
+	tm = mprsas_alloc_tm(sc);
+	if (tm == NULL) {
 		mpr_dprint(sc, MPR_ERROR, "%s: command alloc failure\n",
 		    __func__);
 		return;
@@ -521,25 +526,24 @@ mprsas_prepare_remove(struct mprsas_softc *sassc, uint
 
 	mprsas_rescan_target(sc, targ);
 
-	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)cm->cm_req;
+	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)tm->cm_req;
 	memset(req, 0, sizeof(*req));
 	req->DevHandle = htole16(targ->handle);
-	req->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
 	req->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET;
 
 	/* SAS Hard Link Reset / SATA Link Reset */
 	req->MsgFlags = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET;
 
-	cm->cm_targ = targ;
-	cm->cm_data = NULL;
-	cm->cm_complete = mprsas_remove_device;
-	cm->cm_complete_data = (void *)(uintptr_t)handle;
+	tm->cm_targ = targ;
+	tm->cm_data = NULL;
+	tm->cm_complete = mprsas_remove_device;
+	tm->cm_complete_data = (void *)(uintptr_t)handle;
 
 	mpr_dprint(sc, MPR_INFO, "%s: Sending reset for target ID %d\n",
 	    __func__, targ->tid);
-	mprsas_prepare_for_tm(sc, cm, targ, CAM_LUN_WILDCARD);
+	mprsas_prepare_for_tm(sc, tm, targ, CAM_LUN_WILDCARD);
 
-	mpr_map_command(sc, cm);
+	mpr_map_command(sc, tm);
 }
 
 static void
@@ -1456,7 +1460,6 @@ mprsas_send_reset(struct mpr_softc *sc, struct mpr_com
 
 	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)tm->cm_req;
 	req->DevHandle = htole16(target->handle);
-	req->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
 	req->TaskType = type;
 
 	if (type == MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET) {
@@ -1611,7 +1614,6 @@ mprsas_send_abort(struct mpr_softc *sc, struct mpr_com
 
 	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)tm->cm_req;
 	req->DevHandle = htole16(targ->handle);
-	req->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
 	req->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK;
 
 	/* XXX Need to handle invalid LUNs */
@@ -3324,7 +3326,6 @@ mprsas_action_resetdev(struct mprsas_softc *sassc, uni
 	targ = &sassc->targets[ccb->ccb_h.target_id];
 	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)tm->cm_req;
 	req->DevHandle = htole16(targ->handle);
-	req->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
 	req->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET;
 
 	/* SAS Hard Link Reset / SATA Link Reset */
@@ -3338,7 +3339,7 @@ mprsas_action_resetdev(struct mprsas_softc *sassc, uni
 	    __func__, targ->tid);
 	tm->cm_targ = targ;
 
-	mprsas_prepare_for_tm(sc, cm, targ, CAM_LUN_WILDCARD);
+	mprsas_prepare_for_tm(sc, tm, targ, CAM_LUN_WILDCARD);
 	mpr_map_command(sc, tm);
 }
 

Modified: head/sys/dev/mps/mps_sas.c
==============================================================================
--- head/sys/dev/mps/mps_sas.c	Mon Dec 24 05:54:36 2018	(r342387)
+++ head/sys/dev/mps/mps_sas.c	Mon Dec 24 06:14:32 2018	(r342388)
@@ -236,9 +236,15 @@ mpssas_startup_decrement(struct mpssas_softc *sassc)
 struct mps_command *
 mpssas_alloc_tm(struct mps_softc *sc)
 {
+	MPI2_SCSI_TASK_MANAGE_REQUEST *req;
 	struct mps_command *tm;
 
 	tm = mps_alloc_high_priority_command(sc);
+	if (tm == NULL)
+		return (NULL);
+
+	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)tm->cm_req;
+	req->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
 	return tm;
 }
 
@@ -426,7 +432,7 @@ mpssas_prepare_volume_remove(struct mpssas_softc *sass
 {
 	MPI2_SCSI_TASK_MANAGE_REQUEST *req;
 	struct mps_softc *sc;
-	struct mps_command *cm;
+	struct mps_command *tm;
 	struct mpssas_target *targ = NULL;
 
 	MPS_FUNCTRACE(sassc->sc);
@@ -455,8 +461,8 @@ mpssas_prepare_volume_remove(struct mpssas_softc *sass
 
 	targ->flags |= MPSSAS_TARGET_INREMOVAL;
 
-	cm = mpssas_alloc_tm(sc);
-	if (cm == NULL) {
+	tm = mpssas_alloc_tm(sc);
+	if (tm == NULL) {
 		mps_dprint(sc, MPS_ERROR,
 		    "%s: command alloc failure\n", __func__);
 		return;
@@ -464,24 +470,23 @@ mpssas_prepare_volume_remove(struct mpssas_softc *sass
 
 	mpssas_rescan_target(sc, targ);
 
-	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)cm->cm_req;
+	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)tm->cm_req;
 	req->DevHandle = targ->handle;
-	req->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
 	req->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET;
 
 	/* SAS Hard Link Reset / SATA Link Reset */
 	req->MsgFlags = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET;
 
-	cm->cm_targ = targ;
-	cm->cm_data = NULL;
-	cm->cm_complete = mpssas_remove_volume;
-	cm->cm_complete_data = (void *)(uintptr_t)handle;
+	tm->cm_targ = targ;
+	tm->cm_data = NULL;
+	tm->cm_complete = mpssas_remove_volume;
+	tm->cm_complete_data = (void *)(uintptr_t)handle;
 
 	mps_dprint(sc, MPS_INFO, "%s: Sending reset for target ID %d\n",
 	    __func__, targ->tid);
-	mpssas_prepare_for_tm(sc, cm, targ, CAM_LUN_WILDCARD);
+	mpssas_prepare_for_tm(sc, tm, targ, CAM_LUN_WILDCARD);
 
-	mps_map_command(sc, cm);
+	mps_map_command(sc, tm);
 }
 
 /*
@@ -528,7 +533,6 @@ mpssas_prepare_remove(struct mpssas_softc *sassc, uint
 	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)cm->cm_req;
 	memset(req, 0, sizeof(*req));
 	req->DevHandle = htole16(targ->handle);
-	req->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
 	req->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET;
 
 	/* SAS Hard Link Reset / SATA Link Reset */
@@ -1398,7 +1402,6 @@ mpssas_send_reset(struct mps_softc *sc, struct mps_com
 
 	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)tm->cm_req;
 	req->DevHandle = htole16(target->handle);
-	req->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
 	req->TaskType = type;
 
 	if (type == MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET) {
@@ -1546,7 +1549,6 @@ mpssas_send_abort(struct mps_softc *sc, struct mps_com
 
 	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)tm->cm_req;
 	req->DevHandle = htole16(targ->handle);
-	req->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
 	req->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK;
 
 	/* XXX Need to handle invalid LUNs */
@@ -3069,7 +3071,6 @@ mpssas_action_resetdev(struct mpssas_softc *sassc, uni
 	targ = &sassc->targets[ccb->ccb_h.target_id];
 	req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)tm->cm_req;
 	req->DevHandle = htole16(targ->handle);
-	req->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
 	req->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET;
 
 	/* SAS Hard Link Reset / SATA Link Reset */



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