qla2xxx: Properly reset firmware statistics.

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Joe Carnuccio 2016-07-06 11:14:24 -04:00 committed by Martin K. Petersen
parent fc90adaf05
commit c6dc99058e
5 changed files with 35 additions and 17 deletions

View File

@ -1828,17 +1828,17 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
goto done; goto done;
stats = dma_alloc_coherent(&ha->pdev->dev, stats = dma_alloc_coherent(&ha->pdev->dev,
sizeof(struct link_statistics), &stats_dma, GFP_KERNEL); sizeof(*stats), &stats_dma, GFP_KERNEL);
if (stats == NULL) { if (!stats) {
ql_log(ql_log_warn, vha, 0x707d, ql_log(ql_log_warn, vha, 0x707d,
"Failed to allocate memory for stats.\n"); "Failed to allocate memory for stats.\n");
goto done; goto done;
} }
memset(stats, 0, DMA_POOL_SIZE); memset(stats, 0, sizeof(*stats));
rval = QLA_FUNCTION_FAILED; rval = QLA_FUNCTION_FAILED;
if (IS_FWI2_CAPABLE(ha)) { if (IS_FWI2_CAPABLE(ha)) {
rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma); rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, 0);
} else if (atomic_read(&base_vha->loop_state) == LOOP_READY && } else if (atomic_read(&base_vha->loop_state) == LOOP_READY &&
!ha->dpc_active) { !ha->dpc_active) {
/* Must be in a 'READY' state for statistics retrieval. */ /* Must be in a 'READY' state for statistics retrieval. */
@ -1886,11 +1886,31 @@ static void
qla2x00_reset_host_stats(struct Scsi_Host *shost) qla2x00_reset_host_stats(struct Scsi_Host *shost)
{ {
scsi_qla_host_t *vha = shost_priv(shost); scsi_qla_host_t *vha = shost_priv(shost);
struct qla_hw_data *ha = vha->hw;
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
struct link_statistics *stats;
dma_addr_t stats_dma;
memset(&vha->qla_stats, 0, sizeof(vha->qla_stats)); memset(&vha->qla_stats, 0, sizeof(vha->qla_stats));
memset(&vha->fc_host_stat, 0, sizeof(vha->fc_host_stat)); memset(&vha->fc_host_stat, 0, sizeof(vha->fc_host_stat));
vha->qla_stats.jiffies_at_last_reset = get_jiffies_64(); vha->qla_stats.jiffies_at_last_reset = get_jiffies_64();
if (IS_FWI2_CAPABLE(ha)) {
stats = dma_alloc_coherent(&ha->pdev->dev,
sizeof(*stats), &stats_dma, GFP_KERNEL);
if (!stats) {
ql_log(ql_log_warn, vha, 0x70d7,
"Failed to allocate memory for stats.\n");
return;
}
/* reset firmware statistics */
qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0);
dma_free_coherent(&ha->pdev->dev, sizeof(*stats),
stats, stats_dma);
}
} }
static void static void

View File

@ -2270,7 +2270,7 @@ qla2x00_get_priv_stats(struct fc_bsg_job *bsg_job)
memset(stats, 0, sizeof(struct link_statistics)); memset(stats, 0, sizeof(struct link_statistics));
rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma); rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, 0);
if (rval != QLA_SUCCESS) if (rval != QLA_SUCCESS)
goto done_free; goto done_free;

View File

@ -41,7 +41,7 @@
* | | | 0x70ad-0x70ae | * | | | 0x70ad-0x70ae |
* | | | 0x70d0-0x70d6 | * | | | 0x70d0-0x70d6 |
* | | | 0x70d7-0x70db | * | | | 0x70d7-0x70db |
* | | | 0x70de-0x70df | * | | | 0x70db |
* | Task Management | 0x803d | 0x8000,0x800b | * | Task Management | 0x803d | 0x8000,0x800b |
* | | | 0x8019 | * | | | 0x8019 |
* | | | 0x8025,0x8026 | * | | | 0x8025,0x8026 |

View File

@ -344,7 +344,7 @@ qla2x00_get_link_status(scsi_qla_host_t *, uint16_t, struct link_statistics *,
extern int extern int
qla24xx_get_isp_stats(scsi_qla_host_t *, struct link_statistics *, qla24xx_get_isp_stats(scsi_qla_host_t *, struct link_statistics *,
dma_addr_t); dma_addr_t, uint);
extern int qla24xx_abort_command(srb_t *); extern int qla24xx_abort_command(srb_t *);
extern int qla24xx_async_abort_command(srb_t *); extern int qla24xx_async_abort_command(srb_t *);

View File

@ -2762,15 +2762,16 @@ qla2x00_get_link_status(scsi_qla_host_t *vha, uint16_t loop_id,
int rval; int rval;
mbx_cmd_t mc; mbx_cmd_t mc;
mbx_cmd_t *mcp = &mc; mbx_cmd_t *mcp = &mc;
uint32_t *iter, dwords; uint32_t *iter = (void *)stats;
ushort dwords = offsetof(typeof(*stats), link_up_cnt)/sizeof(*iter);
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1084, ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1084,
"Entered %s.\n", __func__); "Entered %s.\n", __func__);
mcp->mb[0] = MBC_GET_LINK_STATUS; mcp->mb[0] = MBC_GET_LINK_STATUS;
mcp->mb[2] = MSW(stats_dma); mcp->mb[2] = MSW(LSD(stats_dma));
mcp->mb[3] = LSW(stats_dma); mcp->mb[3] = LSW(LSD(stats_dma));
mcp->mb[6] = MSW(MSD(stats_dma)); mcp->mb[6] = MSW(MSD(stats_dma));
mcp->mb[7] = LSW(MSD(stats_dma)); mcp->mb[7] = LSW(MSD(stats_dma));
mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
@ -2799,12 +2800,9 @@ qla2x00_get_link_status(scsi_qla_host_t *vha, uint16_t loop_id,
"Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
rval = QLA_FUNCTION_FAILED; rval = QLA_FUNCTION_FAILED;
} else { } else {
/* Copy over data -- firmware data is LE. */ /* Re-endianize - firmware data is le32. */
ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1086, ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1086,
"Done %s.\n", __func__); "Done %s.\n", __func__);
dwords = offsetof(struct link_statistics,
link_up_cnt) / 4;
iter = &stats->link_fail_cnt;
for ( ; dwords--; iter++) for ( ; dwords--; iter++)
le32_to_cpus(iter); le32_to_cpus(iter);
} }
@ -2818,7 +2816,7 @@ qla2x00_get_link_status(scsi_qla_host_t *vha, uint16_t loop_id,
int int
qla24xx_get_isp_stats(scsi_qla_host_t *vha, struct link_statistics *stats, qla24xx_get_isp_stats(scsi_qla_host_t *vha, struct link_statistics *stats,
dma_addr_t stats_dma) dma_addr_t stats_dma, uint options)
{ {
int rval; int rval;
mbx_cmd_t mc; mbx_cmd_t mc;
@ -2835,7 +2833,7 @@ qla24xx_get_isp_stats(scsi_qla_host_t *vha, struct link_statistics *stats,
mcp->mb[7] = LSW(MSD(stats_dma)); mcp->mb[7] = LSW(MSD(stats_dma));
mcp->mb[8] = sizeof(struct link_statistics) / 4; mcp->mb[8] = sizeof(struct link_statistics) / 4;
mcp->mb[9] = vha->vp_idx; mcp->mb[9] = vha->vp_idx;
mcp->mb[10] = 0; mcp->mb[10] = options;
mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
mcp->in_mb = MBX_2|MBX_1|MBX_0; mcp->in_mb = MBX_2|MBX_1|MBX_0;
mcp->tov = MBX_TOV_SECONDS; mcp->tov = MBX_TOV_SECONDS;
@ -2850,7 +2848,7 @@ qla24xx_get_isp_stats(scsi_qla_host_t *vha, struct link_statistics *stats,
} else { } else {
ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108a, ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108a,
"Done %s.\n", __func__); "Done %s.\n", __func__);
/* Copy over data -- firmware data is LE. */ /* Re-endianize - firmware data is le32. */
dwords = sizeof(struct link_statistics) / 4; dwords = sizeof(struct link_statistics) / 4;
iter = &stats->link_fail_cnt; iter = &stats->link_fail_cnt;
for ( ; dwords--; iter++) for ( ; dwords--; iter++)