From acdd7cbae42d884d82df7dc18601707ca8e20211 Mon Sep 17 00:00:00 2001 From: mav Date: Fri, 10 Mar 2017 13:39:16 +0000 Subject: [PATCH] Improve residuals reporting in target mode. MFC after: 2 weeks --- sys/dev/mpt/mpt.h | 2 +- sys/dev/mpt/mpt_cam.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/dev/mpt/mpt.h b/sys/dev/mpt/mpt.h index de7e6a89f9ad..5b9fd8216119 100644 --- a/sys/dev/mpt/mpt.h +++ b/sys/dev/mpt/mpt.h @@ -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 diff --git a/sys/dev/mpt/mpt_cam.c b/sys/dev/mpt/mpt_cam.c index 19befc2f1f0c..d4cd74ab7c6c 100644 --- a/sys/dev/mpt/mpt_cam.c +++ b/sys/dev/mpt/mpt_cam.c @@ -4430,6 +4430,7 @@ mpt_target_start_io(struct mpt_softc *mpt, union ccb *ccb) /* * 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 *mpt, union ccb *ccb, request_t *cmd_req, #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;