[SCSI] qla2xxx: Add missing FCP statistics to sysfs interface.
authorJoe Carnuccio <joe.carnuccio@qlogic.com>
Tue, 27 Aug 2013 05:37:40 +0000 (01:37 -0400)
committerJames Bottomley <JBottomley@Parallels.com>
Tue, 3 Sep 2013 14:28:04 +0000 (07:28 -0700)
Add the missing FCP statistics to sysfs.
Add reset FCP statistics functionality via sysfs.

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/qla2xxx/qla_attr.c
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_gs.c
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_iocb.c
drivers/scsi/qla2xxx/qla_isr.c

index 93f378325f45465d5085a5f9fa6cba11f85eb531..85aad4a0b2816aac6ffe0f1b07d73df4a719c7fc 100644 (file)
@@ -1732,11 +1732,21 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
                pfc_host_stat->lip_count = stats->lip_cnt;
                pfc_host_stat->tx_frames = stats->tx_frames;
                pfc_host_stat->rx_frames = stats->rx_frames;
-               pfc_host_stat->dumped_frames = stats->dumped_frames;
+               pfc_host_stat->dumped_frames = stats->discarded_frames;
                pfc_host_stat->nos_count = stats->nos_rcvd;
+               pfc_host_stat->error_frames =
+                       stats->dropped_frames + stats->discarded_frames;
+               pfc_host_stat->rx_words = vha->qla_stats.input_bytes;
+               pfc_host_stat->tx_words = vha->qla_stats.output_bytes;
        }
+       pfc_host_stat->fcp_control_requests = vha->qla_stats.control_requests;
+       pfc_host_stat->fcp_input_requests = vha->qla_stats.input_requests;
+       pfc_host_stat->fcp_output_requests = vha->qla_stats.output_requests;
        pfc_host_stat->fcp_input_megabytes = vha->qla_stats.input_bytes >> 20;
        pfc_host_stat->fcp_output_megabytes = vha->qla_stats.output_bytes >> 20;
+       pfc_host_stat->seconds_since_last_reset =
+               get_jiffies_64() - vha->qla_stats.jiffies_at_last_reset;
+       do_div(pfc_host_stat->seconds_since_last_reset, HZ);
 
 done_free:
         dma_pool_free(ha->s_dma_pool, stats, stats_dma);
@@ -1744,6 +1754,16 @@ done:
        return pfc_host_stat;
 }
 
+static void
+qla2x00_reset_host_stats(struct Scsi_Host *shost)
+{
+       scsi_qla_host_t *vha = shost_priv(shost);
+
+       memset(&vha->fc_host_stat, 0, sizeof(vha->fc_host_stat));
+
+       vha->qla_stats.jiffies_at_last_reset = get_jiffies_64();
+}
+
 static void
 qla2x00_get_host_symbolic_name(struct Scsi_Host *shost)
 {
@@ -2050,6 +2070,7 @@ struct fc_function_template qla2xxx_transport_functions = {
        .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk,
        .terminate_rport_io = qla2x00_terminate_rport_io,
        .get_fc_host_stats = qla2x00_get_fc_host_stats,
+       .reset_fc_host_stats = qla2x00_reset_host_stats,
 
        .vport_create = qla24xx_vport_create,
        .vport_disable = qla24xx_vport_disable,
@@ -2096,6 +2117,8 @@ struct fc_function_template qla2xxx_transport_vport_functions = {
        .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk,
        .terminate_rport_io = qla2x00_terminate_rport_io,
        .get_fc_host_stats = qla2x00_get_fc_host_stats,
+       .reset_fc_host_stats = qla2x00_reset_host_stats,
+
        .bsg_request = qla24xx_bsg_request,
        .bsg_timeout = qla24xx_bsg_timeout,
 };
index e5d3373e7aebe94eb04fff2ccf39bc809a814113..0aa1beaf1b97ab19ad7047bd3374ad02cacefabe 100644 (file)
@@ -1236,8 +1236,9 @@ struct link_statistics {
        uint32_t unused1[0x1a];
        uint32_t tx_frames;
        uint32_t rx_frames;
-       uint32_t dumped_frames;
-       uint32_t unused2[2];
+       uint32_t discarded_frames;
+       uint32_t dropped_frames;
+       uint32_t unused2[1];
        uint32_t nos_rcvd;
 };
 
@@ -2659,6 +2660,11 @@ struct qla_statistics {
        uint32_t total_isp_aborts;
        uint64_t input_bytes;
        uint64_t output_bytes;
+       uint64_t input_requests;
+       uint64_t output_requests;
+       uint32_t control_requests;
+
+       uint64_t jiffies_at_last_reset;
 };
 
 struct bidi_statistics {
index 84cce36b7a5f5a23b206782f5b6dfffc6532d1de..cd47f1b32d9ae4ab237debf52647fad210b98bee 100644 (file)
@@ -49,6 +49,8 @@ qla2x00_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size)
        ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
        ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount;
 
+       vha->qla_stats.control_requests++;
+
        return (ms_pkt);
 }
 
@@ -87,6 +89,8 @@ qla24xx_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size)
        ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
        ct_pkt->vp_index = vha->vp_idx;
 
+       vha->qla_stats.control_requests++;
+
        return (ct_pkt);
 }
 
@@ -723,6 +727,8 @@ qla2x00_prep_sns_cmd(scsi_qla_host_t *vha, uint16_t cmd, uint16_t scmd_len,
        wc = (data_size - 16) / 4;              /* Size in 32bit words. */
        sns_cmd->p.cmd.size = cpu_to_le16(wc);
 
+       vha->qla_stats.control_requests++;
+
        return (sns_cmd);
 }
 
index 91df7a58da3018f1ed47bffd45f00f713cd9c3aa..03f715e7591e75409a04c2a31d3bb015105d0bd1 100644 (file)
@@ -524,6 +524,7 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha)
        vha->flags.reset_active = 0;
        ha->flags.pci_channel_io_perm_failure = 0;
        ha->flags.eeh_busy = 0;
+       vha->qla_stats.jiffies_at_last_reset = get_jiffies_64();
        atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
        atomic_set(&vha->loop_state, LOOP_DOWN);
        vha->device_flags = DFLG_NO_CABLE;
index e2a7d2dbbc3f55c2fe3ad0989f2fd83fc04cf24b..46b9307e8be4f3b10ff05f0d864c6cbc1e3644e9 100644 (file)
@@ -32,9 +32,11 @@ qla2x00_get_cmd_direction(srb_t *sp)
        if (cmd->sc_data_direction == DMA_TO_DEVICE) {
                cflags = CF_WRITE;
                vha->qla_stats.output_bytes += scsi_bufflen(cmd);
+               vha->qla_stats.output_requests++;
        } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
                cflags = CF_READ;
                vha->qla_stats.input_bytes += scsi_bufflen(cmd);
+               vha->qla_stats.input_requests++;
        }
        return (cflags);
 }
@@ -642,10 +644,12 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt,
                cmd_pkt->control_flags =
                    __constant_cpu_to_le16(CF_WRITE_DATA);
                vha->qla_stats.output_bytes += scsi_bufflen(cmd);
+               vha->qla_stats.output_requests++;
        } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
                cmd_pkt->control_flags =
                    __constant_cpu_to_le16(CF_READ_DATA);
                vha->qla_stats.input_bytes += scsi_bufflen(cmd);
+               vha->qla_stats.input_requests++;
        }
 
        cur_seg = scsi_sglist(cmd);
@@ -758,10 +762,12 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
                cmd_pkt->task_mgmt_flags =
                    __constant_cpu_to_le16(TMF_WRITE_DATA);
                vha->qla_stats.output_bytes += scsi_bufflen(cmd);
+               vha->qla_stats.output_requests++;
        } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
                cmd_pkt->task_mgmt_flags =
                    __constant_cpu_to_le16(TMF_READ_DATA);
                vha->qla_stats.input_bytes += scsi_bufflen(cmd);
+               vha->qla_stats.input_requests++;
        }
 
        /* One DSD is available in the Command Type 3 IOCB */
@@ -2056,6 +2062,8 @@ qla24xx_els_iocb(srb_t *sp, struct els_entry_24xx *els_iocb)
             (bsg_job->reply_payload.sg_list)));
         els_iocb->rx_len = cpu_to_le32(sg_dma_len
             (bsg_job->reply_payload.sg_list));
+
+       sp->fcport->vha->qla_stats.control_requests++;
 }
 
 static void
@@ -2133,6 +2141,8 @@ qla2x00_ct_iocb(srb_t *sp, ms_iocb_entry_t *ct_iocb)
                avail_dsds--;
        }
        ct_iocb->entry_count = entry_count;
+
+       sp->fcport->vha->qla_stats.control_requests++;
 }
 
 static void
@@ -2685,6 +2695,9 @@ qla25xx_build_bidir_iocb(srb_t *sp, struct scsi_qla_host *vha,
        vha->bidi_stats.transfer_bytes += req_data_len;
        vha->bidi_stats.io_count++;
 
+       vha->qla_stats.output_bytes += req_data_len;
+       vha->qla_stats.output_requests++;
+
        /* Only one dsd is available for bidirectional IOCB, remaining dsds
         * are bundled in continuation iocb
         */
index 4a9782ce7d074d13fc77c754b002e45633d8bc6d..bbc24d3afc5baa208491de0c363a126535361f42 100644 (file)
@@ -1807,6 +1807,9 @@ qla25xx_process_bidir_status_iocb(scsi_qla_host_t *vha, void *pkt,
                if (scsi_status == 0) {
                        bsg_job->reply->reply_payload_rcv_len =
                                        bsg_job->reply_payload.payload_len;
+                       vha->qla_stats.input_bytes +=
+                               bsg_job->reply->reply_payload_rcv_len;
+                       vha->qla_stats.input_requests++;
                        rval = EXT_STATUS_OK;
                }
                goto done;