From owner-svn-src-head@freebsd.org Wed Dec 6 00:29:44 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CA0EDE88D23; Wed, 6 Dec 2017 00:29:44 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 95F527A89A; Wed, 6 Dec 2017 00:29:44 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vB60Th48094919; Wed, 6 Dec 2017 00:29:43 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vB60Thcn094918; Wed, 6 Dec 2017 00:29:43 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201712060029.vB60Thcn094918@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Wed, 6 Dec 2017 00:29:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326605 - head/sys/cam X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/cam X-SVN-Commit-Revision: 326605 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Dec 2017 00:29:44 -0000 Author: imp Date: Wed Dec 6 00:29:43 2017 New Revision: 326605 URL: https://svnweb.freebsd.org/changeset/base/326605 Log: 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 Modified: head/sys/cam/cam_periph.c Modified: head/sys/cam/cam_periph.c ============================================================================== --- head/sys/cam/cam_periph.c Wed Dec 6 00:00:37 2017 (r326604) +++ head/sys/cam/cam_periph.c Wed Dec 6 00:29:43 2017 (r326605) @@ -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);