Improve residuals reporting in target mode.

MFC after:	2 weeks
This commit is contained in:
Alexander Motin 2017-03-10 13:39:16 +00:00
parent 4461a4a5ed
commit 501b16854f
2 changed files with 7 additions and 2 deletions

View File

@ -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

View File

@ -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;