aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libfc
diff options
context:
space:
mode:
authorJoe Eykholt <jeykholt@cisco.com>2010-11-30 19:20:18 -0500
committerJames Bottomley <James.Bottomley@suse.de>2010-12-21 13:24:34 -0500
commit5f0e385fdafb7d6c8ded6464fa6421c735d96caf (patch)
treef589124e9cf33dc10deb6084456e68245f6dbea5 /drivers/scsi/libfc
parentba9cd5d095b42271588c20ccd6ddd561d0e4cc1e (diff)
[SCSI] libfc: fix statistics for FCP input/output megabytes
The statistics for InputMegabytes and OutputMegabytes are misnamed. They're accumulating bytes, not megabytes. The statistic returned via /sys must be in megabytes, however, which is what the HBA-API wants. The FCP code needs to accumulate it in bytes and then divide by 1,000,000 (not 2^20) before it presented via sysfs. This affects fcoe.ko only, not fnic. The fnic driver correctly by accumulating bytes and then converts to megabytes. I checked that libhbalinux is using the /sys file directly without conversion. BTW, qla2xxx does divide by 2^20, which I'm not fixing here. Signed-off-by: Joe Eykholt <jeykholt@cisco.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/libfc')
-rw-r--r--drivers/scsi/libfc/fc_fcp.c4
-rw-r--r--drivers/scsi/libfc/fc_lport.c8
2 files changed, 8 insertions, 4 deletions
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index a8e0c0acc736..cdc06cda76e5 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -1860,11 +1860,11 @@ static int fc_queuecommand_lck(struct scsi_cmnd *sc_cmd, void (*done)(struct scs
1860 if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) { 1860 if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) {
1861 fsp->req_flags = FC_SRB_READ; 1861 fsp->req_flags = FC_SRB_READ;
1862 stats->InputRequests++; 1862 stats->InputRequests++;
1863 stats->InputMegabytes += fsp->data_len; 1863 stats->InputBytes += fsp->data_len;
1864 } else if (sc_cmd->sc_data_direction == DMA_TO_DEVICE) { 1864 } else if (sc_cmd->sc_data_direction == DMA_TO_DEVICE) {
1865 fsp->req_flags = FC_SRB_WRITE; 1865 fsp->req_flags = FC_SRB_WRITE;
1866 stats->OutputRequests++; 1866 stats->OutputRequests++;
1867 stats->OutputMegabytes += fsp->data_len; 1867 stats->OutputBytes += fsp->data_len;
1868 } else { 1868 } else {
1869 fsp->req_flags = 0; 1869 fsp->req_flags = 0;
1870 stats->ControlRequests++; 1870 stats->ControlRequests++;
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index b91a11e4fa06..c5a10f94f845 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -288,6 +288,8 @@ struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost)
288 struct fc_lport *lport = shost_priv(shost); 288 struct fc_lport *lport = shost_priv(shost);
289 struct timespec v0, v1; 289 struct timespec v0, v1;
290 unsigned int cpu; 290 unsigned int cpu;
291 u64 fcp_in_bytes = 0;
292 u64 fcp_out_bytes = 0;
291 293
292 fcoe_stats = &lport->host_stats; 294 fcoe_stats = &lport->host_stats;
293 memset(fcoe_stats, 0, sizeof(struct fc_host_statistics)); 295 memset(fcoe_stats, 0, sizeof(struct fc_host_statistics));
@@ -310,10 +312,12 @@ struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost)
310 fcoe_stats->fcp_input_requests += stats->InputRequests; 312 fcoe_stats->fcp_input_requests += stats->InputRequests;
311 fcoe_stats->fcp_output_requests += stats->OutputRequests; 313 fcoe_stats->fcp_output_requests += stats->OutputRequests;
312 fcoe_stats->fcp_control_requests += stats->ControlRequests; 314 fcoe_stats->fcp_control_requests += stats->ControlRequests;
313 fcoe_stats->fcp_input_megabytes += stats->InputMegabytes; 315 fcp_in_bytes += stats->InputBytes;
314 fcoe_stats->fcp_output_megabytes += stats->OutputMegabytes; 316 fcp_out_bytes += stats->OutputBytes;
315 fcoe_stats->link_failure_count += stats->LinkFailureCount; 317 fcoe_stats->link_failure_count += stats->LinkFailureCount;
316 } 318 }
319 fcoe_stats->fcp_input_megabytes = div_u64(fcp_in_bytes, 1000000);
320 fcoe_stats->fcp_output_megabytes = div_u64(fcp_out_bytes, 1000000);
317 fcoe_stats->lip_count = -1; 321 fcoe_stats->lip_count = -1;
318 fcoe_stats->nos_count = -1; 322 fcoe_stats->nos_count = -1;
319 fcoe_stats->loss_of_sync_count = -1; 323 fcoe_stats->loss_of_sync_count = -1;