svn commit: r279273 - in stable/10/sys/cam: ctl scsi

Alexander Motin mav at FreeBSD.org
Wed Feb 25 09:21:05 UTC 2015


Author: mav
Date: Wed Feb 25 09:21:04 2015
New Revision: 279273
URL: https://svnweb.freebsd.org/changeset/base/279273

Log:
  MFC r278584: Add support for General Statistics and Performance log page.
  
  CTL already collects most of statistics reported there, so why not.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl.h
  stable/10/sys/cam/ctl/ctl_private.h
  stable/10/sys/cam/scsi/scsi_all.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl.c	Wed Feb 25 09:19:26 2015	(r279272)
+++ stable/10/sys/cam/ctl/ctl.c	Wed Feb 25 09:21:04 2015	(r279273)
@@ -4485,6 +4485,8 @@ ctl_init_log_page_index(struct ctl_lun *
 	lun->log_pages.index[1].page_len = k * 2;
 	lun->log_pages.index[2].page_data = &lun->log_pages.lbp_page[0];
 	lun->log_pages.index[2].page_len = 12*CTL_NUM_LBP_PARAMS;
+	lun->log_pages.index[3].page_data = (uint8_t *)&lun->log_pages.stat_page;
+	lun->log_pages.index[3].page_len = sizeof(lun->log_pages.stat_page);
 
 	return (CTL_RETVAL_COMPLETE);
 }
@@ -4722,6 +4724,9 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft
 		lun->serseq = CTL_LUN_SERSEQ_OFF;
 
 	lun->ctl_softc = ctl_softc;
+#ifdef CTL_TIME_IO
+	lun->last_busy = getsbinuptime();
+#endif
 	TAILQ_INIT(&lun->ooa_queue);
 	TAILQ_INIT(&lun->blocked_queue);
 	STAILQ_INIT(&lun->error_list);
@@ -7087,6 +7092,67 @@ ctl_lbp_log_sense_handler(struct ctl_scs
 }
 
 int
+ctl_sap_log_sense_handler(struct ctl_scsiio *ctsio,
+			       struct ctl_page_index *page_index,
+			       int pc)
+{
+	struct ctl_lun *lun;
+	struct stat_page *data;
+	uint64_t rn, wn, rb, wb;
+	struct bintime rt, wt;
+	int i;
+
+	lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
+	data = (struct stat_page *)page_index->page_data;
+
+	scsi_ulto2b(SLP_SAP, data->sap.hdr.param_code);
+	data->sap.hdr.param_control = SLP_LBIN;
+	data->sap.hdr.param_len = sizeof(struct scsi_log_stat_and_perf) -
+	    sizeof(struct scsi_log_param_header);
+	rn = wn = rb = wb = 0;
+	bintime_clear(&rt);
+	bintime_clear(&wt);
+	for (i = 0; i < CTL_MAX_PORTS; i++) {
+		rn += lun->stats.ports[i].operations[CTL_STATS_READ];
+		wn += lun->stats.ports[i].operations[CTL_STATS_WRITE];
+		rb += lun->stats.ports[i].bytes[CTL_STATS_READ];
+		wb += lun->stats.ports[i].bytes[CTL_STATS_WRITE];
+		bintime_add(&rt, &lun->stats.ports[i].time[CTL_STATS_READ]);
+		bintime_add(&wt, &lun->stats.ports[i].time[CTL_STATS_WRITE]);
+	}
+	scsi_u64to8b(rn, data->sap.read_num);
+	scsi_u64to8b(wn, data->sap.write_num);
+	if (lun->stats.blocksize > 0) {
+		scsi_u64to8b(wb / lun->stats.blocksize,
+		    data->sap.recvieved_lba);
+		scsi_u64to8b(rb / lun->stats.blocksize,
+		    data->sap.transmitted_lba);
+	}
+	scsi_u64to8b((uint64_t)rt.sec * 1000 + rt.frac / (UINT64_MAX / 1000),
+	    data->sap.read_int);
+	scsi_u64to8b((uint64_t)wt.sec * 1000 + wt.frac / (UINT64_MAX / 1000),
+	    data->sap.write_int);
+	scsi_u64to8b(0, data->sap.weighted_num);
+	scsi_u64to8b(0, data->sap.weighted_int);
+	scsi_ulto2b(SLP_IT, data->it.hdr.param_code);
+	data->it.hdr.param_control = SLP_LBIN;
+	data->it.hdr.param_len = sizeof(struct scsi_log_idle_time) -
+	    sizeof(struct scsi_log_param_header);
+#ifdef CTL_TIME_IO
+	scsi_u64to8b(lun->idle_time / SBT_1MS, data->it.idle_int);
+#endif
+	scsi_ulto2b(SLP_TI, data->ti.hdr.param_code);
+	data->it.hdr.param_control = SLP_LBIN;
+	data->ti.hdr.param_len = sizeof(struct scsi_log_time_interval) -
+	    sizeof(struct scsi_log_param_header);
+	scsi_ulto4b(3, data->ti.exponent);
+	scsi_ulto4b(1, data->ti.integer);
+
+	page_index->page_len = sizeof(*data);
+	return (0);
+}
+
+int
 ctl_log_sense(struct ctl_scsiio *ctsio)
 {
 	struct ctl_lun *lun;
@@ -11692,6 +11758,12 @@ ctl_scsiio_precheck(struct ctl_softc *so
 			 * Every I/O goes into the OOA queue for a
 			 * particular LUN, and stays there until completion.
 			 */
+#ifdef CTL_TIME_IO
+			if (TAILQ_EMPTY(&lun->ooa_queue)) {
+				lun->idle_time += getsbinuptime() -
+				    lun->last_busy;
+			}
+#endif
 			TAILQ_INSERT_TAIL(&lun->ooa_queue, &ctsio->io_hdr,
 			    ooa_links);
 		}
@@ -13738,6 +13810,10 @@ ctl_process_done(union ctl_io *io)
 	 * Remove this from the OOA queue.
 	 */
 	TAILQ_REMOVE(&lun->ooa_queue, &io->io_hdr, ooa_links);
+#ifdef CTL_TIME_IO
+	if (TAILQ_EMPTY(&lun->ooa_queue))
+		lun->last_busy = getsbinuptime();
+#endif
 
 	/*
 	 * Run through the blocked queue on this LUN and see if anything

Modified: stable/10/sys/cam/ctl/ctl.h
==============================================================================
--- stable/10/sys/cam/ctl/ctl.h	Wed Feb 25 09:19:26 2015	(r279272)
+++ stable/10/sys/cam/ctl/ctl.h	Wed Feb 25 09:21:04 2015	(r279273)
@@ -181,6 +181,9 @@ int ctl_debugconf_sp_select_handler(stru
 int ctl_lbp_log_sense_handler(struct ctl_scsiio *ctsio,
 				   struct ctl_page_index *page_index,
 				   int pc);
+int ctl_sap_log_sense_handler(struct ctl_scsiio *ctsio,
+				   struct ctl_page_index *page_index,
+				   int pc);
 int ctl_config_move_done(union ctl_io *io);
 void ctl_datamove(union ctl_io *io);
 void ctl_done(union ctl_io *io);

Modified: stable/10/sys/cam/ctl/ctl_private.h
==============================================================================
--- stable/10/sys/cam/ctl/ctl_private.h	Wed Feb 25 09:19:26 2015	(r279272)
+++ stable/10/sys/cam/ctl/ctl_private.h	Wed Feb 25 09:21:04 2015	(r279273)
@@ -342,6 +342,8 @@ static const struct ctl_page_index log_p
 	 CTL_PAGE_FLAG_NONE, NULL, NULL},
 	{SLS_LOGICAL_BLOCK_PROVISIONING, 0, 0, NULL,
 	 CTL_PAGE_FLAG_NONE, ctl_lbp_log_sense_handler, NULL},
+	{SLS_STAT_AND_PERF, 0, 0, NULL,
+	 CTL_PAGE_FLAG_NONE, ctl_sap_log_sense_handler, NULL},
 };
 
 #define	CTL_NUM_LOG_PAGES sizeof(log_page_index_template)/   \
@@ -351,6 +353,11 @@ struct ctl_log_pages {
 	uint8_t				pages_page[CTL_NUM_LOG_PAGES];
 	uint8_t				subpages_page[CTL_NUM_LOG_PAGES * 2];
 	uint8_t				lbp_page[12*CTL_NUM_LBP_PARAMS];
+	struct stat_page {
+		struct scsi_log_stat_and_perf sap;
+		struct scsi_log_idle_time it;
+		struct scsi_log_time_interval ti;
+	} stat_page;
 	struct ctl_page_index		index[CTL_NUM_LOG_PAGES];
 };
 
@@ -403,6 +410,10 @@ struct ctl_lun {
 	struct ctl_lun_delay_info	delay_info;
 	int				sync_interval;
 	int				sync_count;
+#ifdef CTL_TIME_IO
+	sbintime_t			idle_time;
+	sbintime_t			last_busy;
+#endif
 	TAILQ_HEAD(ctl_ooaq, ctl_io_hdr)  ooa_queue;
 	TAILQ_HEAD(ctl_blockq,ctl_io_hdr) blocked_queue;
 	STAILQ_ENTRY(ctl_lun)		links;

Modified: stable/10/sys/cam/scsi/scsi_all.h
==============================================================================
--- stable/10/sys/cam/scsi/scsi_all.h	Wed Feb 25 09:19:26 2015	(r279272)
+++ stable/10/sys/cam/scsi/scsi_all.h	Wed Feb 25 09:21:04 2015	(r279273)
@@ -561,6 +561,7 @@ struct scsi_log_sense
 #define	SLS_ERROR_LASTN_PAGE		0x07
 #define	SLS_LOGICAL_BLOCK_PROVISIONING	0x0c
 #define	SLS_SELF_TEST_PAGE		0x10
+#define	SLS_STAT_AND_PERF		0x19
 #define	SLS_IE_PAGE			0x2f
 #define	SLS_PAGE_CTRL_MASK		0xC0
 #define	SLS_PAGE_CTRL_THRESHOLD		0x00
@@ -619,6 +620,45 @@ struct scsi_log_param_header {
 	u_int8_t param_len;
 };
 
+struct scsi_log_stat_and_perf {
+	struct scsi_log_param_header hdr;
+#define	SLP_SAP				0x0001
+	uint8_t	read_num[8];
+	uint8_t	write_num[8];
+	uint8_t	recvieved_lba[8];
+	uint8_t	transmitted_lba[8];
+	uint8_t	read_int[8];
+	uint8_t	write_int[8];
+	uint8_t	weighted_num[8];
+	uint8_t	weighted_int[8];
+};
+
+struct scsi_log_idle_time {
+	struct scsi_log_param_header hdr;
+#define	SLP_IT				0x0002
+	uint8_t	idle_int[8];
+};
+
+struct scsi_log_time_interval {
+	struct scsi_log_param_header hdr;
+#define	SLP_TI				0x0003
+	uint8_t	exponent[4];
+	uint8_t	integer[4];
+};
+
+struct scsi_log_fua_stat_and_perf {
+	struct scsi_log_param_header hdr;
+#define	SLP_FUA_SAP			0x0004
+	uint8_t	fua_read_num[8];
+	uint8_t	fua_write_num[8];
+	uint8_t	fuanv_read_num[8];
+	uint8_t	fuanv_write_num[8];
+	uint8_t	fua_read_int[8];
+	uint8_t	fua_write_int[8];
+	uint8_t	fuanv_read_int[8];
+	uint8_t	fuanv_write_int[8];
+};
+
 struct scsi_control_page {
 	u_int8_t page_code;
 	u_int8_t page_length;


More information about the svn-src-all mailing list