diff options
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_mbx.c')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_mbx.c | 105 |
1 files changed, 102 insertions, 3 deletions
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 3099b379de9d..49ce197876b4 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c | |||
@@ -7,7 +7,6 @@ | |||
7 | #include "qla_def.h" | 7 | #include "qla_def.h" |
8 | 8 | ||
9 | #include <linux/delay.h> | 9 | #include <linux/delay.h> |
10 | #include <scsi/scsi_transport_fc.h> | ||
11 | 10 | ||
12 | static void | 11 | static void |
13 | qla2x00_mbx_sem_timeout(unsigned long data) | 12 | qla2x00_mbx_sem_timeout(unsigned long data) |
@@ -2017,8 +2016,109 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map) | |||
2017 | 2016 | ||
2018 | return rval; | 2017 | return rval; |
2019 | } | 2018 | } |
2019 | #endif | ||
2020 | |||
2021 | /* | ||
2022 | * qla2x00_get_link_status | ||
2023 | * | ||
2024 | * Input: | ||
2025 | * ha = adapter block pointer. | ||
2026 | * loop_id = device loop ID. | ||
2027 | * ret_buf = pointer to link status return buffer. | ||
2028 | * | ||
2029 | * Returns: | ||
2030 | * 0 = success. | ||
2031 | * BIT_0 = mem alloc error. | ||
2032 | * BIT_1 = mailbox error. | ||
2033 | */ | ||
2034 | int | ||
2035 | qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id, | ||
2036 | link_stat_t *ret_buf, uint16_t *status) | ||
2037 | { | ||
2038 | int rval; | ||
2039 | mbx_cmd_t mc; | ||
2040 | mbx_cmd_t *mcp = &mc; | ||
2041 | link_stat_t *stat_buf; | ||
2042 | dma_addr_t stat_buf_dma; | ||
2043 | |||
2044 | DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);) | ||
2045 | |||
2046 | stat_buf = dma_pool_alloc(ha->s_dma_pool, GFP_ATOMIC, &stat_buf_dma); | ||
2047 | if (stat_buf == NULL) { | ||
2048 | DEBUG2_3_11(printk("%s(%ld): Failed to allocate memory.\n", | ||
2049 | __func__, ha->host_no)); | ||
2050 | return BIT_0; | ||
2051 | } | ||
2052 | memset(stat_buf, 0, sizeof(link_stat_t)); | ||
2053 | |||
2054 | mcp->mb[0] = MBC_GET_LINK_STATUS; | ||
2055 | mcp->mb[2] = MSW(stat_buf_dma); | ||
2056 | mcp->mb[3] = LSW(stat_buf_dma); | ||
2057 | mcp->mb[6] = MSW(MSD(stat_buf_dma)); | ||
2058 | mcp->mb[7] = LSW(MSD(stat_buf_dma)); | ||
2059 | mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; | ||
2060 | mcp->in_mb = MBX_0; | ||
2061 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) { | ||
2062 | mcp->mb[1] = loop_id; | ||
2063 | mcp->mb[4] = 0; | ||
2064 | mcp->mb[10] = 0; | ||
2065 | mcp->out_mb |= MBX_10|MBX_4|MBX_1; | ||
2066 | mcp->in_mb |= MBX_1; | ||
2067 | } else if (HAS_EXTENDED_IDS(ha)) { | ||
2068 | mcp->mb[1] = loop_id; | ||
2069 | mcp->mb[10] = 0; | ||
2070 | mcp->out_mb |= MBX_10|MBX_1; | ||
2071 | } else { | ||
2072 | mcp->mb[1] = loop_id << 8; | ||
2073 | mcp->out_mb |= MBX_1; | ||
2074 | } | ||
2075 | mcp->tov = 30; | ||
2076 | mcp->flags = IOCTL_CMD; | ||
2077 | rval = qla2x00_mailbox_command(ha, mcp); | ||
2078 | |||
2079 | if (rval == QLA_SUCCESS) { | ||
2080 | if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { | ||
2081 | DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n", | ||
2082 | __func__, ha->host_no, mcp->mb[0]);) | ||
2083 | status[0] = mcp->mb[0]; | ||
2084 | rval = BIT_1; | ||
2085 | } else { | ||
2086 | /* copy over data -- firmware data is LE. */ | ||
2087 | ret_buf->link_fail_cnt = | ||
2088 | le32_to_cpu(stat_buf->link_fail_cnt); | ||
2089 | ret_buf->loss_sync_cnt = | ||
2090 | le32_to_cpu(stat_buf->loss_sync_cnt); | ||
2091 | ret_buf->loss_sig_cnt = | ||
2092 | le32_to_cpu(stat_buf->loss_sig_cnt); | ||
2093 | ret_buf->prim_seq_err_cnt = | ||
2094 | le32_to_cpu(stat_buf->prim_seq_err_cnt); | ||
2095 | ret_buf->inval_xmit_word_cnt = | ||
2096 | le32_to_cpu(stat_buf->inval_xmit_word_cnt); | ||
2097 | ret_buf->inval_crc_cnt = | ||
2098 | le32_to_cpu(stat_buf->inval_crc_cnt); | ||
2099 | |||
2100 | DEBUG11(printk("%s(%ld): stat dump: fail_cnt=%d " | ||
2101 | "loss_sync=%d loss_sig=%d seq_err=%d " | ||
2102 | "inval_xmt_word=%d inval_crc=%d.\n", __func__, | ||
2103 | ha->host_no, stat_buf->link_fail_cnt, | ||
2104 | stat_buf->loss_sync_cnt, stat_buf->loss_sig_cnt, | ||
2105 | stat_buf->prim_seq_err_cnt, | ||
2106 | stat_buf->inval_xmit_word_cnt, | ||
2107 | stat_buf->inval_crc_cnt);) | ||
2108 | } | ||
2109 | } else { | ||
2110 | /* Failed. */ | ||
2111 | DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, | ||
2112 | ha->host_no, rval);) | ||
2113 | rval = BIT_1; | ||
2114 | } | ||
2115 | |||
2116 | dma_pool_free(ha->s_dma_pool, stat_buf, stat_buf_dma); | ||
2020 | 2117 | ||
2021 | uint8_t | 2118 | return rval; |
2119 | } | ||
2120 | |||
2121 | int | ||
2022 | qla24xx_get_isp_stats(scsi_qla_host_t *ha, uint32_t *dwbuf, uint32_t dwords, | 2122 | qla24xx_get_isp_stats(scsi_qla_host_t *ha, uint32_t *dwbuf, uint32_t dwords, |
2023 | uint16_t *status) | 2123 | uint16_t *status) |
2024 | { | 2124 | { |
@@ -2080,7 +2180,6 @@ qla24xx_get_isp_stats(scsi_qla_host_t *ha, uint32_t *dwbuf, uint32_t dwords, | |||
2080 | 2180 | ||
2081 | return rval; | 2181 | return rval; |
2082 | } | 2182 | } |
2083 | #endif | ||
2084 | 2183 | ||
2085 | int | 2184 | int |
2086 | qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp) | 2185 | qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp) |