From d2f3208ddaa199c957a5a42a0a2cb81e02cb97f1 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Wed, 6 Dec 2017 00:29:43 +0000 Subject: [PATCH] Add NVME as a known device type for devstat processing. Also, reduce the amount of cut and pasted code a little since only two args are different in the devstat_end_transaction calls. Sponsored by: Netflix --- sys/cam/cam_periph.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index 5b1d305f85b3..c788d7fa7cc7 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -1171,8 +1171,10 @@ cam_periph_runccb(union ccb *ccb, * If the user has supplied a stats structure, and if we understand * this particular type of ccb, record the transaction start. */ - if ((ds != NULL) && (ccb->ccb_h.func_code == XPT_SCSI_IO || - ccb->ccb_h.func_code == XPT_ATA_IO)) { + if (ds != NULL && + (ccb->ccb_h.func_code == XPT_SCSI_IO || + ccb->ccb_h.func_code == XPT_ATA_IO || + ccb->ccb_h.func_code == XPT_NVME_IO)) { starttime = <ime; binuptime(starttime); devstat_start_transaction(ds, starttime); @@ -1203,25 +1205,27 @@ cam_periph_runccb(union ccb *ccb, } if (ds != NULL) { + uint32_t bytes; + devstat_tag_type tag; + bool valid = true; + if (ccb->ccb_h.func_code == XPT_SCSI_IO) { - devstat_end_transaction(ds, - ccb->csio.dxfer_len - ccb->csio.resid, - ccb->csio.tag_action & 0x3, - ((ccb->ccb_h.flags & CAM_DIR_MASK) == - CAM_DIR_NONE) ? DEVSTAT_NO_DATA : - (ccb->ccb_h.flags & CAM_DIR_OUT) ? - DEVSTAT_WRITE : - DEVSTAT_READ, NULL, starttime); + bytes = ccb->csio.dxfer_len - ccb->csio.resid; + tag = (devstat_tag_type)(ccb->csio.tag_action & 0x3); } else if (ccb->ccb_h.func_code == XPT_ATA_IO) { - devstat_end_transaction(ds, - ccb->ataio.dxfer_len - ccb->ataio.resid, - 0, /* Not used in ATA */ - ((ccb->ccb_h.flags & CAM_DIR_MASK) == - CAM_DIR_NONE) ? DEVSTAT_NO_DATA : - (ccb->ccb_h.flags & CAM_DIR_OUT) ? - DEVSTAT_WRITE : - DEVSTAT_READ, NULL, starttime); + bytes = ccb->ataio.dxfer_len - ccb->ataio.resid; + tag = (devstat_tag_type)0; + } else if (ccb->ccb_h.func_code == XPT_NVME_IO) { + bytes = ccb->nvmeio.dxfer_len; /* NB: resid no possible */ + tag = (devstat_tag_type)0; + } else { + valid = false; } + if (valid) + devstat_end_transaction(ds, bytes, tag, + ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE) ? + DEVSTAT_NO_DATA : (ccb->ccb_h.flags & CAM_DIR_OUT) ? + DEVSTAT_WRITE : DEVSTAT_READ, NULL, starttime); } return(error);