aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_mbx.c
diff options
context:
space:
mode:
authorAndrew Vasquez <andrew.vasquez@qlogic.com>2008-01-17 12:02:08 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-01-23 12:29:29 -0500
commit43ef058010c79a967195539bbcdeee8c5b24219d (patch)
treeb0d13f3b2a79777a306d9c84adbfec3499c97af0 /drivers/scsi/qla2xxx/qla_mbx.c
parent4733fcb1fe4d64402a8bd18cec766e8b8ad25eee (diff)
[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 <andrew.vasquez@qlogic.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_mbx.c')
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c99
1 files changed, 26 insertions, 73 deletions
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 031f269149b1..0fc165288f88 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -2042,29 +2042,20 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map)
2042 */ 2042 */
2043int 2043int
2044qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id, 2044qla2x00_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)
2046{ 2046{
2047 int rval; 2047 int rval;
2048 mbx_cmd_t mc; 2048 mbx_cmd_t mc;
2049 mbx_cmd_t *mcp = &mc; 2049 mbx_cmd_t *mcp = &mc;
2050 link_stat_t *stat_buf; 2050 uint32_t *siter, *diter, dwords;
2051 dma_addr_t stat_buf_dma;
2052 2051
2053 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2052 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
2054 2053
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
2063 mcp->mb[0] = MBC_GET_LINK_STATUS; 2054 mcp->mb[0] = MBC_GET_LINK_STATUS;
2064 mcp->mb[2] = MSW(stat_buf_dma); 2055 mcp->mb[2] = MSW(stats_dma);
2065 mcp->mb[3] = LSW(stat_buf_dma); 2056 mcp->mb[3] = LSW(stats_dma);
2066 mcp->mb[6] = MSW(MSD(stat_buf_dma)); 2057 mcp->mb[6] = MSW(MSD(stats_dma));
2067 mcp->mb[7] = LSW(MSD(stat_buf_dma)); 2058 mcp->mb[7] = LSW(MSD(stats_dma));
2068 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 2059 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
2069 mcp->in_mb = MBX_0; 2060 mcp->in_mb = MBX_0;
2070 if (IS_FWI2_CAPABLE(ha)) { 2061 if (IS_FWI2_CAPABLE(ha)) {
@@ -2089,78 +2080,43 @@ qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
2089 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { 2080 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
2090 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n", 2081 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2091 __func__, ha->host_no, mcp->mb[0])); 2082 __func__, ha->host_no, mcp->mb[0]));
2092 status[0] = mcp->mb[0]; 2083 rval = QLA_FUNCTION_FAILED;
2093 rval = BIT_1;
2094 } else { 2084 } else {
2095 /* copy over data -- firmware data is LE. */ 2085 /* Copy over data -- firmware data is LE. */
2096 ret_buf->link_fail_cnt = 2086 dwords = offsetof(struct link_statistics, unused1) / 4;
2097 le32_to_cpu(stat_buf->link_fail_cnt); 2087 siter = diter = &stats->link_fail_cnt;
2098 ret_buf->loss_sync_cnt = 2088 while (dwords--)
2099 le32_to_cpu(stat_buf->loss_sync_cnt); 2089 *diter++ = le32_to_cpu(*siter++);
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));
2117 } 2090 }
2118 } else { 2091 } else {
2119 /* Failed. */ 2092 /* Failed. */
2120 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2093 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2121 ha->host_no, rval)); 2094 ha->host_no, rval));
2122 rval = BIT_1;
2123 } 2095 }
2124 2096
2125 dma_pool_free(ha->s_dma_pool, stat_buf, stat_buf_dma);
2126
2127 return rval; 2097 return rval;
2128} 2098}
2129 2099
2130int 2100int
2131qla24xx_get_isp_stats(scsi_qla_host_t *ha, uint32_t *dwbuf, uint32_t dwords, 2101qla24xx_get_isp_stats(scsi_qla_host_t *ha, struct link_statistics *stats,
2132 uint16_t *status) 2102 dma_addr_t stats_dma)
2133{ 2103{
2134 int rval; 2104 int rval;
2135 mbx_cmd_t mc; 2105 mbx_cmd_t mc;
2136 mbx_cmd_t *mcp = &mc; 2106 mbx_cmd_t *mcp = &mc;
2137 uint32_t *sbuf, *siter; 2107 uint32_t *siter, *diter, dwords;
2138 dma_addr_t sbuf_dma;
2139 2108
2140 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2109 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
2141 2110
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
2156 mcp->mb[0] = MBC_GET_LINK_PRIV_STATS; 2111 mcp->mb[0] = MBC_GET_LINK_PRIV_STATS;
2157 mcp->mb[2] = MSW(sbuf_dma); 2112 mcp->mb[2] = MSW(stats_dma);
2158 mcp->mb[3] = LSW(sbuf_dma); 2113 mcp->mb[3] = LSW(stats_dma);
2159 mcp->mb[6] = MSW(MSD(sbuf_dma)); 2114 mcp->mb[6] = MSW(MSD(stats_dma));
2160 mcp->mb[7] = LSW(MSD(sbuf_dma)); 2115 mcp->mb[7] = LSW(MSD(stats_dma));
2161 mcp->mb[8] = dwords; 2116 mcp->mb[8] = sizeof(struct link_statistics) / 4;
2117 mcp->mb[9] = ha->vp_idx;
2162 mcp->mb[10] = 0; 2118 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;
2164 mcp->in_mb = MBX_2|MBX_1|MBX_0; 2120 mcp->in_mb = MBX_2|MBX_1|MBX_0;
2165 mcp->tov = 30; 2121 mcp->tov = 30;
2166 mcp->flags = IOCTL_CMD; 2122 mcp->flags = IOCTL_CMD;
@@ -2170,23 +2126,20 @@ qla24xx_get_isp_stats(scsi_qla_host_t *ha, uint32_t *dwbuf, uint32_t dwords,
2170 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { 2126 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
2171 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n", 2127 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2172 __func__, ha->host_no, mcp->mb[0])); 2128 __func__, ha->host_no, mcp->mb[0]));
2173 status[0] = mcp->mb[0]; 2129 rval = QLA_FUNCTION_FAILED;
2174 rval = BIT_1;
2175 } else { 2130 } else {
2176 /* Copy over data -- firmware data is LE. */ 2131 /* Copy over data -- firmware data is LE. */
2177 siter = sbuf; 2132 dwords = sizeof(struct link_statistics) / 4;
2133 siter = diter = &stats->link_fail_cnt;
2178 while (dwords--) 2134 while (dwords--)
2179 *dwbuf++ = le32_to_cpu(*siter++); 2135 *diter++ = le32_to_cpu(*siter++);
2180 } 2136 }
2181 } else { 2137 } else {
2182 /* Failed. */ 2138 /* Failed. */
2183 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2139 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2184 ha->host_no, rval)); 2140 ha->host_no, rval));
2185 rval = BIT_1;
2186 } 2141 }
2187 2142
2188 dma_pool_free(ha->s_dma_pool, sbuf, sbuf_dma);
2189
2190 return rval; 2143 return rval;
2191} 2144}
2192 2145