summaryrefslogtreecommitdiffstats
path: root/sys/cam
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-02-11 16:10:31 +0000
committermav <mav@FreeBSD.org>2015-02-11 16:10:31 +0000
commit8fa237e6324f89b9151d549ddb3c693c05d1552c (patch)
tree979f7da853691188977fd52fe7ac2575921c6617 /sys/cam
parent108c08deb16296382b7b594d253b61c4b29ab95f (diff)
downloadFreeBSD-src-8fa237e6324f89b9151d549ddb3c693c05d1552c.zip
FreeBSD-src-8fa237e6324f89b9151d549ddb3c693c05d1552c.tar.gz
Add support for General Statistics and Performance log page.
CTL already collects most of statistics reported there, so why not. MFC after: 2 weeks
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/ctl/ctl.c76
-rw-r--r--sys/cam/ctl/ctl.h3
-rw-r--r--sys/cam/ctl/ctl_private.h11
-rw-r--r--sys/cam/scsi/scsi_all.h40
4 files changed, 130 insertions, 0 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index d3d9177..defce21 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -4483,6 +4483,8 @@ ctl_init_log_page_index(struct ctl_lun *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);
}
@@ -4720,6 +4722,9 @@ ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *ctl_lun,
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);
@@ -7085,6 +7090,67 @@ ctl_lbp_log_sense_handler(struct ctl_scsiio *ctsio,
}
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;
@@ -11689,6 +11755,12 @@ ctl_scsiio_precheck(struct ctl_softc *softc, struct ctl_scsiio *ctsio)
* 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);
}
@@ -13735,6 +13807,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
diff --git a/sys/cam/ctl/ctl.h b/sys/cam/ctl/ctl.h
index 9cf967c..2693419 100644
--- a/sys/cam/ctl/ctl.h
+++ b/sys/cam/ctl/ctl.h
@@ -181,6 +181,9 @@ int ctl_debugconf_sp_select_handler(struct ctl_scsiio *ctsio,
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);
diff --git a/sys/cam/ctl/ctl_private.h b/sys/cam/ctl/ctl_private.h
index ffcb063..428142c 100644
--- a/sys/cam/ctl/ctl_private.h
+++ b/sys/cam/ctl/ctl_private.h
@@ -342,6 +342,8 @@ static const struct ctl_page_index log_page_index_template[] = {
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;
diff --git a/sys/cam/scsi/scsi_all.h b/sys/cam/scsi/scsi_all.h
index dfd0db0..46d0bfc 100644
--- a/sys/cam/scsi/scsi_all.h
+++ b/sys/cam/scsi/scsi_all.h
@@ -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;
OpenPOWER on IntegriCloud