[SCSI] qla2xxx: Add missing FCP statistics to sysfs interface.
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / scsi / qla2xxx / qla_attr.c
index 93f3783..85aad4a 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);
@@ -1745,6 +1755,16 @@ done:
 }
 
 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)
 {
        scsi_qla_host_t *vha = shost_priv(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,
 };