summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua M. Clulow <jmc@joyent.com>2016-03-08 05:02:59 +0000
committerJoshua M. Clulow <jmc@joyent.com>2016-07-06 16:25:38 +0000
commit58a22015cccad123ffb9174ce63d40b769774cf0 (patch)
tree8a362f265f4ffb0228a6187520c024c21083a13e
parent41de9bb12a0c27968ea6b1d80a6930651b1f21cc (diff)
downloadillumos-joyent-58a22015cccad123ffb9174ce63d40b769774cf0.tar.gz
XXX add some stats, cleanup some polling, etc
-rw-r--r--usr/src/uts/common/io/cpqary3/cpqary3.h9
-rw-r--r--usr/src/uts/common/io/cpqary3/cpqary3_ciss.c8
-rw-r--r--usr/src/uts/common/io/cpqary3/cpqary3_hba.c40
3 files changed, 45 insertions, 12 deletions
diff --git a/usr/src/uts/common/io/cpqary3/cpqary3.h b/usr/src/uts/common/io/cpqary3/cpqary3.h
index 20dcc40bea..f36cc8353e 100644
--- a/usr/src/uts/common/io/cpqary3/cpqary3.h
+++ b/usr/src/uts/common/io/cpqary3/cpqary3.h
@@ -210,6 +210,14 @@ typedef enum cpqary3_controller_status {
CPQARY3_CTLR_STATUS_RESETTING = (0x1 << 3),
} cpqary3_controller_status_t;
+typedef struct cpqary3_stats {
+ uint64_t cpqs_tran_aborts;
+ uint64_t cpqs_tran_resets;
+ uint64_t cpqs_tran_starts;
+ uint64_t cpqs_ctlr_resets;
+ unsigned cpqs_max_inflight;
+} cpqary3_stats_t;
+
/*
* Per Controller Structure
*/
@@ -218,6 +226,7 @@ struct cpqary3 {
dev_info_t *dip;
int cpq_instance;
cpqary3_controller_status_t cpq_status;
+ cpqary3_stats_t cpq_stats;
/*
* Controller model-specific data.
diff --git a/usr/src/uts/common/io/cpqary3/cpqary3_ciss.c b/usr/src/uts/common/io/cpqary3/cpqary3_ciss.c
index 93e89e1022..d05f70092c 100644
--- a/usr/src/uts/common/io/cpqary3/cpqary3_ciss.c
+++ b/usr/src/uts/common/io/cpqary3/cpqary3_ciss.c
@@ -242,7 +242,7 @@ cpqary3_set_new_tag(cpqary3_t *cpq, cpqary3_command_t *cpcm)
/*
* Loop until we find a tag that is not in use. The tag space is
* very large (~30 bits) and the maximum number of inflight commands
- * is comparitively small (~1024 in current controllers).
+ * is comparatively small (~1024 in current controllers).
*/
for (;;) {
uint32_t new_tag = cpq->cpq_next_tag;
@@ -324,6 +324,11 @@ cpqary3_submit(cpqary3_t *cpq, cpqary3_command_t *cpcm)
cpcm->cpcm_tag);
}
avl_insert(&cpq->cpq_inflight, cpcm, where);
+ if (cpq->cpq_stats.cpqs_max_inflight <
+ avl_numnodes(&cpq->cpq_inflight)) {
+ cpq->cpq_stats.cpqs_max_inflight =
+ avl_numnodes(&cpq->cpq_inflight);
+ }
VERIFY(!(cpcm->cpcm_status & CPQARY3_CMD_STATUS_INFLIGHT));
cpcm->cpcm_status |= CPQARY3_CMD_STATUS_INFLIGHT;
@@ -947,6 +952,7 @@ cpqary3_ctlr_reset(cpqary3_t *cpq)
}
cpq->cpq_status |= CPQARY3_CTLR_STATUS_RESETTING;
cpq->cpq_last_reset_start = gethrtime();
+ cpq->cpq_stats.cpqs_ctlr_resets++;
mutex_exit(&cpq->cpq_mutex);
skip_check:
diff --git a/usr/src/uts/common/io/cpqary3/cpqary3_hba.c b/usr/src/uts/common/io/cpqary3/cpqary3_hba.c
index 53089a3f7c..f064133a47 100644
--- a/usr/src/uts/common/io/cpqary3/cpqary3_hba.c
+++ b/usr/src/uts/common/io/cpqary3/cpqary3_hba.c
@@ -375,6 +375,7 @@ cpqary3_tran_start(struct scsi_address *sa, struct scsi_pkt *pkt)
* Submit the command to the controller.
*/
mutex_enter(&cpq->cpq_mutex);
+ cpq->cpq_stats.cpqs_tran_starts++;
if ((r = cpqary3_submit(cpq, cpcm)) != 0) {
mutex_exit(&cpq->cpq_mutex);
@@ -433,6 +434,7 @@ again:
cpqary3_write_message_nop(cpcm, 15);
mutex_enter(&cpq->cpq_mutex);
+ cpq->cpq_stats.cpqs_tran_resets++;
if (ddi_in_panic()) {
goto skip_check;
}
@@ -459,9 +461,29 @@ skip_check:
return (0);
}
- if ((r = cpqary3_poll_for(cpq, cpcm)) == 0 &&
- !(cpcm->cpcm_status & CPQARY3_CMD_STATUS_ERROR) &&
- !(cpcm->cpcm_status & CPQARY3_CMD_STATUS_RESET_SENT)) {
+ if ((r = cpqary3_poll_for(cpq, cpcm)) != 0) {
+ VERIFY(r == ETIMEDOUT);
+ VERIFY0(cpcm->cpcm_status & CPQARY3_CMD_STATUS_POLL_COMPLETE);
+
+ /*
+ * The ping command timed out. Abandon it now.
+ */
+ cpcm->cpcm_status |= CPQARY3_CMD_STATUS_ABANDONED;
+ cpcm->cpcm_status &= ~CPQARY3_CMD_STATUS_POLLED;
+
+ } else if ((cpcm->cpcm_status & CPQARY3_CMD_STATUS_RESET_SENT) ||
+ (cpcm->cpcm_status & CPQARY3_CMD_STATUS_ERROR)) {
+ /*
+ * The command completed in error, or a controller reset
+ * was sent while we were trying to ping.
+ */
+ mutex_exit(&cpq->cpq_mutex);
+ cpqary3_command_free(cpcm);
+ mutex_enter(&cpq->cpq_mutex);
+
+ } else {
+ VERIFY(cpcm->cpcm_status & CPQARY3_CMD_STATUS_COMPLETE);
+
/*
* The controller is responsive, and a full soft reset would be
* extremely disruptive to the system. Given our spotty
@@ -475,14 +497,6 @@ skip_check:
return (1);
}
- if (!(cpcm->cpcm_status & CPQARY3_CMD_STATUS_POLL_COMPLETE)) {
- cpcm->cpcm_status |= CPQARY3_CMD_STATUS_ABANDONED;
- } else {
- mutex_exit(&cpq->cpq_mutex);
- cpqary3_command_free(cpcm);
- mutex_enter(&cpq->cpq_mutex);
- }
-
/*
* If a reset has been initiated in the last 90 seconds, try
* another ping.
@@ -530,6 +544,7 @@ cpqary3_tran_abort(struct scsi_address *sa, struct scsi_pkt *pkt)
}
mutex_enter(&cpq->cpq_mutex);
+ cpq->cpq_stats.cpqs_tran_aborts++;
if (pkt != NULL) {
/*
* The framework wants us to abort a specific SCSI packet.
@@ -660,11 +675,14 @@ cpqary3_hba_setup(cpqary3_t *cpq)
tran->tran_teardown_pkt = cpqary3_tran_teardown_pkt;
tran->tran_hba_len = sizeof (cpqary3_command_scsa_t);
+#if 0
/*
* XXX We should set "tran_interconnect_type" appropriately.
* e.g. to INTERCONNECT_SAS for SAS controllers. How to tell?
* Who knows.
*/
+ tran->tran_interconnect_type = INTERCONNECT_SAS;
+#endif
if (scsi_hba_attach_setup(cpq->dip, &cpq->cpq_dma_attr, tran,
SCSI_HBA_TRAN_CLONE) != DDI_SUCCESS) {