Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Mar 2017 13:39:16 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r315002 - head/sys/dev/mpt
Message-ID:  <201703101339.v2ADdGKC061030@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Fri Mar 10 13:39:16 2017
New Revision: 315002
URL: https://svnweb.freebsd.org/changeset/base/315002

Log:
  Improve residuals reporting in target mode.
  
  MFC after:	2 weeks

Modified:
  head/sys/dev/mpt/mpt.h
  head/sys/dev/mpt/mpt_cam.c

Modified: head/sys/dev/mpt/mpt.h
==============================================================================
--- head/sys/dev/mpt/mpt.h	Fri Mar 10 13:14:06 2017	(r315001)
+++ head/sys/dev/mpt/mpt.h	Fri Mar 10 13:39:16 2017	(r315002)
@@ -331,8 +331,8 @@ typedef struct mpt_config_params {
 /**************************** MPI Target State Info ***************************/
 typedef struct {
 	uint32_t reply_desc;	/* current reply descriptor */
-	uint32_t resid;		/* current data residual */
 	uint32_t bytes_xfered;	/* current relative offset */
+	int resid;		/* current data residual */
 	union ccb *ccb;		/* pointer to currently active ccb */
 	request_t *req;		/* pointer to currently active assist request */
 	uint32_t

Modified: head/sys/dev/mpt/mpt_cam.c
==============================================================================
--- head/sys/dev/mpt/mpt_cam.c	Fri Mar 10 13:14:06 2017	(r315001)
+++ head/sys/dev/mpt/mpt_cam.c	Fri Mar 10 13:39:16 2017	(r315002)
@@ -4430,6 +4430,7 @@ mpt_target_start_io(struct mpt_softc *mp
 		/*
 		 * XXX Should be done after data transfer completes?
 		 */
+		csio->resid = csio->dxfer_len - ta->DataLength;
 		tgt->resid -= csio->dxfer_len;
 		tgt->bytes_xfered += csio->dxfer_len;
 
@@ -4732,7 +4733,11 @@ mpt_scsi_tgt_status(struct mpt_softc *mp
 #ifndef	WE_TRUST_AUTO_GOOD_STATUS
 		resplen = MIN_FCP_RESPONSE_SIZE;
 #endif
-		if (tgt->resid) {
+		if (tgt->resid < 0) {
+			rsp[2] |= htobe32(0x400); /* XXXX NEED MNEMONIC!!!! */
+			rsp[3] = htobe32(-tgt->resid);
+			resplen = MIN_FCP_RESPONSE_SIZE;
+		} else if (tgt->resid > 0) {
 			rsp[2] |= htobe32(0x800); /* XXXX NEED MNEMONIC!!!! */
 			rsp[3] = htobe32(tgt->resid);
 			resplen = MIN_FCP_RESPONSE_SIZE;



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