Skip to content

Commit 43ef058

Browse files
avasquez01James Bottomley
authored andcommitted
[SCSI] qla2xxx: Retrieve additional HBA port statistics from recent ISPs.
HBAs supporting these additional counters include ISP24xx and ISP25xx type boards. Signed-off-by: Andrew Vasquez <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent 4733fcb commit 43ef058

File tree

4 files changed

+74
-98
lines changed

4 files changed

+74
-98
lines changed

drivers/scsi/qla2xxx/qla_attr.c

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -967,35 +967,51 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
967967
{
968968
scsi_qla_host_t *ha = shost_priv(shost);
969969
int rval;
970-
uint16_t mb_stat[1];
971-
link_stat_t stat_buf;
970+
struct link_statistics *stats;
971+
dma_addr_t stats_dma;
972972
struct fc_host_statistics *pfc_host_stat;
973973

974-
rval = QLA_FUNCTION_FAILED;
975974
pfc_host_stat = &ha->fc_host_stat;
976975
memset(pfc_host_stat, -1, sizeof(struct fc_host_statistics));
977976

977+
stats = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &stats_dma);
978+
if (stats == NULL) {
979+
DEBUG2_3_11(printk("%s(%ld): Failed to allocate memory.\n",
980+
__func__, ha->host_no));
981+
goto done;
982+
}
983+
memset(stats, 0, DMA_POOL_SIZE);
984+
985+
rval = QLA_FUNCTION_FAILED;
978986
if (IS_FWI2_CAPABLE(ha)) {
979-
rval = qla24xx_get_isp_stats(ha, (uint32_t *)&stat_buf,
980-
sizeof(stat_buf) / 4, mb_stat);
987+
rval = qla24xx_get_isp_stats(ha, stats, stats_dma);
981988
} else if (atomic_read(&ha->loop_state) == LOOP_READY &&
982989
!test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) &&
983990
!test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) &&
984991
!ha->dpc_active) {
985992
/* Must be in a 'READY' state for statistics retrieval. */
986-
rval = qla2x00_get_link_status(ha, ha->loop_id, &stat_buf,
987-
mb_stat);
993+
rval = qla2x00_get_link_status(ha, ha->loop_id, stats,
994+
stats_dma);
988995
}
989996

990997
if (rval != QLA_SUCCESS)
991-
goto done;
998+
goto done_free;
999+
1000+
pfc_host_stat->link_failure_count = stats->link_fail_cnt;
1001+
pfc_host_stat->loss_of_sync_count = stats->loss_sync_cnt;
1002+
pfc_host_stat->loss_of_signal_count = stats->loss_sig_cnt;
1003+
pfc_host_stat->prim_seq_protocol_err_count = stats->prim_seq_err_cnt;
1004+
pfc_host_stat->invalid_tx_word_count = stats->inval_xmit_word_cnt;
1005+
pfc_host_stat->invalid_crc_count = stats->inval_crc_cnt;
1006+
if (IS_FWI2_CAPABLE(ha)) {
1007+
pfc_host_stat->tx_frames = stats->tx_frames;
1008+
pfc_host_stat->rx_frames = stats->rx_frames;
1009+
pfc_host_stat->dumped_frames = stats->dumped_frames;
1010+
pfc_host_stat->nos_count = stats->nos_rcvd;
1011+
}
9921012

993-
pfc_host_stat->link_failure_count = stat_buf.link_fail_cnt;
994-
pfc_host_stat->loss_of_sync_count = stat_buf.loss_sync_cnt;
995-
pfc_host_stat->loss_of_signal_count = stat_buf.loss_sig_cnt;
996-
pfc_host_stat->prim_seq_protocol_err_count = stat_buf.prim_seq_err_cnt;
997-
pfc_host_stat->invalid_tx_word_count = stat_buf.inval_xmit_word_cnt;
998-
pfc_host_stat->invalid_crc_count = stat_buf.inval_crc_cnt;
1013+
done_free:
1014+
dma_pool_free(ha->s_dma_pool, stats, stats_dma);
9991015
done:
10001016
return pfc_host_stat;
10011017
}

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -862,14 +862,20 @@ typedef struct {
862862
#define GLSO_SEND_RPS BIT_0
863863
#define GLSO_USE_DID BIT_3
864864

865-
typedef struct {
866-
uint32_t link_fail_cnt;
867-
uint32_t loss_sync_cnt;
868-
uint32_t loss_sig_cnt;
869-
uint32_t prim_seq_err_cnt;
870-
uint32_t inval_xmit_word_cnt;
871-
uint32_t inval_crc_cnt;
872-
} link_stat_t;
865+
struct link_statistics {
866+
uint32_t link_fail_cnt;
867+
uint32_t loss_sync_cnt;
868+
uint32_t loss_sig_cnt;
869+
uint32_t prim_seq_err_cnt;
870+
uint32_t inval_xmit_word_cnt;
871+
uint32_t inval_crc_cnt;
872+
uint32_t unused1[0x1b];
873+
uint32_t tx_frames;
874+
uint32_t rx_frames;
875+
uint32_t dumped_frames;
876+
uint32_t unused2[2];
877+
uint32_t nos_rcvd;
878+
};
873879

874880
/*
875881
* NVRAM Command values.

drivers/scsi/qla2xxx/qla_gbl.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,12 @@ extern int
222222
qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map);
223223

224224
extern int
225-
qla2x00_get_link_status(scsi_qla_host_t *, uint16_t, link_stat_t *,
226-
uint16_t *);
225+
qla2x00_get_link_status(scsi_qla_host_t *, uint16_t, struct link_statistics *,
226+
dma_addr_t);
227227

228228
extern int
229-
qla24xx_get_isp_stats(scsi_qla_host_t *, uint32_t *, uint32_t, uint16_t *);
229+
qla24xx_get_isp_stats(scsi_qla_host_t *, struct link_statistics *,
230+
dma_addr_t);
230231

231232
extern int qla24xx_abort_command(scsi_qla_host_t *, srb_t *);
232233
extern int qla24xx_abort_target(fc_port_t *);

drivers/scsi/qla2xxx/qla_mbx.c

Lines changed: 26 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,29 +2042,20 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map)
20422042
*/
20432043
int
20442044
qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
2045-
link_stat_t *ret_buf, uint16_t *status)
2045+
struct link_statistics *stats, dma_addr_t stats_dma)
20462046
{
20472047
int rval;
20482048
mbx_cmd_t mc;
20492049
mbx_cmd_t *mcp = &mc;
2050-
link_stat_t *stat_buf;
2051-
dma_addr_t stat_buf_dma;
2050+
uint32_t *siter, *diter, dwords;
20522051

20532052
DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
20542053

2055-
stat_buf = dma_pool_alloc(ha->s_dma_pool, GFP_ATOMIC, &stat_buf_dma);
2056-
if (stat_buf == NULL) {
2057-
DEBUG2_3_11(printk("%s(%ld): Failed to allocate memory.\n",
2058-
__func__, ha->host_no));
2059-
return BIT_0;
2060-
}
2061-
memset(stat_buf, 0, sizeof(link_stat_t));
2062-
20632054
mcp->mb[0] = MBC_GET_LINK_STATUS;
2064-
mcp->mb[2] = MSW(stat_buf_dma);
2065-
mcp->mb[3] = LSW(stat_buf_dma);
2066-
mcp->mb[6] = MSW(MSD(stat_buf_dma));
2067-
mcp->mb[7] = LSW(MSD(stat_buf_dma));
2055+
mcp->mb[2] = MSW(stats_dma);
2056+
mcp->mb[3] = LSW(stats_dma);
2057+
mcp->mb[6] = MSW(MSD(stats_dma));
2058+
mcp->mb[7] = LSW(MSD(stats_dma));
20682059
mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
20692060
mcp->in_mb = MBX_0;
20702061
if (IS_FWI2_CAPABLE(ha)) {
@@ -2089,78 +2080,43 @@ qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
20892080
if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
20902081
DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
20912082
__func__, ha->host_no, mcp->mb[0]));
2092-
status[0] = mcp->mb[0];
2093-
rval = BIT_1;
2083+
rval = QLA_FUNCTION_FAILED;
20942084
} else {
2095-
/* copy over data -- firmware data is LE. */
2096-
ret_buf->link_fail_cnt =
2097-
le32_to_cpu(stat_buf->link_fail_cnt);
2098-
ret_buf->loss_sync_cnt =
2099-
le32_to_cpu(stat_buf->loss_sync_cnt);
2100-
ret_buf->loss_sig_cnt =
2101-
le32_to_cpu(stat_buf->loss_sig_cnt);
2102-
ret_buf->prim_seq_err_cnt =
2103-
le32_to_cpu(stat_buf->prim_seq_err_cnt);
2104-
ret_buf->inval_xmit_word_cnt =
2105-
le32_to_cpu(stat_buf->inval_xmit_word_cnt);
2106-
ret_buf->inval_crc_cnt =
2107-
le32_to_cpu(stat_buf->inval_crc_cnt);
2108-
2109-
DEBUG11(printk("%s(%ld): stat dump: fail_cnt=%d "
2110-
"loss_sync=%d loss_sig=%d seq_err=%d "
2111-
"inval_xmt_word=%d inval_crc=%d.\n", __func__,
2112-
ha->host_no, stat_buf->link_fail_cnt,
2113-
stat_buf->loss_sync_cnt, stat_buf->loss_sig_cnt,
2114-
stat_buf->prim_seq_err_cnt,
2115-
stat_buf->inval_xmit_word_cnt,
2116-
stat_buf->inval_crc_cnt));
2085+
/* Copy over data -- firmware data is LE. */
2086+
dwords = offsetof(struct link_statistics, unused1) / 4;
2087+
siter = diter = &stats->link_fail_cnt;
2088+
while (dwords--)
2089+
*diter++ = le32_to_cpu(*siter++);
21172090
}
21182091
} else {
21192092
/* Failed. */
21202093
DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
21212094
ha->host_no, rval));
2122-
rval = BIT_1;
21232095
}
21242096

2125-
dma_pool_free(ha->s_dma_pool, stat_buf, stat_buf_dma);
2126-
21272097
return rval;
21282098
}
21292099

21302100
int
2131-
qla24xx_get_isp_stats(scsi_qla_host_t *ha, uint32_t *dwbuf, uint32_t dwords,
2132-
uint16_t *status)
2101+
qla24xx_get_isp_stats(scsi_qla_host_t *ha, struct link_statistics *stats,
2102+
dma_addr_t stats_dma)
21332103
{
21342104
int rval;
21352105
mbx_cmd_t mc;
21362106
mbx_cmd_t *mcp = &mc;
2137-
uint32_t *sbuf, *siter;
2138-
dma_addr_t sbuf_dma;
2107+
uint32_t *siter, *diter, dwords;
21392108

21402109
DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
21412110

2142-
if (dwords > (DMA_POOL_SIZE / 4)) {
2143-
DEBUG2_3_11(printk("%s(%ld): Unabled to retrieve %d DWORDs "
2144-
"(max %d).\n", __func__, ha->host_no, dwords,
2145-
DMA_POOL_SIZE / 4));
2146-
return BIT_0;
2147-
}
2148-
sbuf = dma_pool_alloc(ha->s_dma_pool, GFP_ATOMIC, &sbuf_dma);
2149-
if (sbuf == NULL) {
2150-
DEBUG2_3_11(printk("%s(%ld): Failed to allocate memory.\n",
2151-
__func__, ha->host_no));
2152-
return BIT_0;
2153-
}
2154-
memset(sbuf, 0, DMA_POOL_SIZE);
2155-
21562111
mcp->mb[0] = MBC_GET_LINK_PRIV_STATS;
2157-
mcp->mb[2] = MSW(sbuf_dma);
2158-
mcp->mb[3] = LSW(sbuf_dma);
2159-
mcp->mb[6] = MSW(MSD(sbuf_dma));
2160-
mcp->mb[7] = LSW(MSD(sbuf_dma));
2161-
mcp->mb[8] = dwords;
2112+
mcp->mb[2] = MSW(stats_dma);
2113+
mcp->mb[3] = LSW(stats_dma);
2114+
mcp->mb[6] = MSW(MSD(stats_dma));
2115+
mcp->mb[7] = LSW(MSD(stats_dma));
2116+
mcp->mb[8] = sizeof(struct link_statistics) / 4;
2117+
mcp->mb[9] = ha->vp_idx;
21622118
mcp->mb[10] = 0;
2163-
mcp->out_mb = MBX_10|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
2119+
mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
21642120
mcp->in_mb = MBX_2|MBX_1|MBX_0;
21652121
mcp->tov = 30;
21662122
mcp->flags = IOCTL_CMD;
@@ -2170,23 +2126,20 @@ qla24xx_get_isp_stats(scsi_qla_host_t *ha, uint32_t *dwbuf, uint32_t dwords,
21702126
if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
21712127
DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
21722128
__func__, ha->host_no, mcp->mb[0]));
2173-
status[0] = mcp->mb[0];
2174-
rval = BIT_1;
2129+
rval = QLA_FUNCTION_FAILED;
21752130
} else {
21762131
/* Copy over data -- firmware data is LE. */
2177-
siter = sbuf;
2132+
dwords = sizeof(struct link_statistics) / 4;
2133+
siter = diter = &stats->link_fail_cnt;
21782134
while (dwords--)
2179-
*dwbuf++ = le32_to_cpu(*siter++);
2135+
*diter++ = le32_to_cpu(*siter++);
21802136
}
21812137
} else {
21822138
/* Failed. */
21832139
DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
21842140
ha->host_no, rval));
2185-
rval = BIT_1;
21862141
}
21872142

2188-
dma_pool_free(ha->s_dma_pool, sbuf, sbuf_dma);
2189-
21902143
return rval;
21912144
}
21922145

0 commit comments

Comments
 (0)