aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_mbx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_mbx.c')
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c158
1 files changed, 136 insertions, 22 deletions
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index bce6cd47e3c3..2f3033228061 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -49,6 +49,14 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
49 if (ha->pdev->error_state > pci_channel_io_frozen) 49 if (ha->pdev->error_state > pci_channel_io_frozen)
50 return QLA_FUNCTION_TIMEOUT; 50 return QLA_FUNCTION_TIMEOUT;
51 51
52 if (vha->device_flags & DFLG_DEV_FAILED) {
53 DEBUG2_3_11(qla_printk(KERN_WARNING, ha,
54 "%s(%ld): Device in failed state, "
55 "timeout MBX Exiting.\n",
56 __func__, base_vha->host_no));
57 return QLA_FUNCTION_TIMEOUT;
58 }
59
52 reg = ha->iobase; 60 reg = ha->iobase;
53 io_lock_on = base_vha->flags.init_done; 61 io_lock_on = base_vha->flags.init_done;
54 62
@@ -85,7 +93,9 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
85 spin_lock_irqsave(&ha->hardware_lock, flags); 93 spin_lock_irqsave(&ha->hardware_lock, flags);
86 94
87 /* Load mailbox registers. */ 95 /* Load mailbox registers. */
88 if (IS_FWI2_CAPABLE(ha)) 96 if (IS_QLA82XX(ha))
97 optr = (uint16_t __iomem *)&reg->isp82.mailbox_in[0];
98 else if (IS_FWI2_CAPABLE(ha) && !IS_QLA82XX(ha))
89 optr = (uint16_t __iomem *)&reg->isp24.mailbox0; 99 optr = (uint16_t __iomem *)&reg->isp24.mailbox0;
90 else 100 else
91 optr = (uint16_t __iomem *)MAILBOX_REG(ha, &reg->isp, 0); 101 optr = (uint16_t __iomem *)MAILBOX_REG(ha, &reg->isp, 0);
@@ -133,7 +143,18 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
133 if ((!abort_active && io_lock_on) || IS_NOPOLLING_TYPE(ha)) { 143 if ((!abort_active && io_lock_on) || IS_NOPOLLING_TYPE(ha)) {
134 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); 144 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
135 145
136 if (IS_FWI2_CAPABLE(ha)) 146 if (IS_QLA82XX(ha)) {
147 if (RD_REG_DWORD(&reg->isp82.hint) &
148 HINT_MBX_INT_PENDING) {
149 spin_unlock_irqrestore(&ha->hardware_lock,
150 flags);
151 DEBUG2_3_11(printk(KERN_INFO
152 "%s(%ld): Pending Mailbox timeout. "
153 "Exiting.\n", __func__, base_vha->host_no));
154 return QLA_FUNCTION_TIMEOUT;
155 }
156 WRT_REG_DWORD(&reg->isp82.hint, HINT_MBX_INT_PENDING);
157 } else if (IS_FWI2_CAPABLE(ha))
137 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT); 158 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
138 else 159 else
139 WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT); 160 WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT);
@@ -147,7 +168,18 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
147 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__, 168 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__,
148 base_vha->host_no, command)); 169 base_vha->host_no, command));
149 170
150 if (IS_FWI2_CAPABLE(ha)) 171 if (IS_QLA82XX(ha)) {
172 if (RD_REG_DWORD(&reg->isp82.hint) &
173 HINT_MBX_INT_PENDING) {
174 spin_unlock_irqrestore(&ha->hardware_lock,
175 flags);
176 DEBUG2_3_11(printk(KERN_INFO
177 "%s(%ld): Pending Mailbox timeout. "
178 "Exiting.\n", __func__, base_vha->host_no));
179 return QLA_FUNCTION_TIMEOUT;
180 }
181 WRT_REG_DWORD(&reg->isp82.hint, HINT_MBX_INT_PENDING);
182 } else if (IS_FWI2_CAPABLE(ha))
151 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT); 183 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
152 else 184 else
153 WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT); 185 WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT);
@@ -264,7 +296,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
264 296
265 set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); 297 set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
266 clear_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); 298 clear_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
267 if (qla2x00_abort_isp(base_vha)) { 299 if (ha->isp_ops->abort_isp(base_vha)) {
268 /* Failed. retry later. */ 300 /* Failed. retry later. */
269 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); 301 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
270 } 302 }
@@ -952,7 +984,7 @@ qla2x00_get_adapter_id(scsi_qla_host_t *vha, uint16_t *id, uint8_t *al_pa,
952 mcp->mb[9] = vha->vp_idx; 984 mcp->mb[9] = vha->vp_idx;
953 mcp->out_mb = MBX_9|MBX_0; 985 mcp->out_mb = MBX_9|MBX_0;
954 mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 986 mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
955 if (IS_QLA81XX(vha->hw)) 987 if (IS_QLA8XXX_TYPE(vha->hw))
956 mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10; 988 mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10;
957 mcp->tov = MBX_TOV_SECONDS; 989 mcp->tov = MBX_TOV_SECONDS;
958 mcp->flags = 0; 990 mcp->flags = 0;
@@ -978,7 +1010,7 @@ qla2x00_get_adapter_id(scsi_qla_host_t *vha, uint16_t *id, uint8_t *al_pa,
978 DEBUG11(printk("qla2x00_get_adapter_id(%ld): done.\n", 1010 DEBUG11(printk("qla2x00_get_adapter_id(%ld): done.\n",
979 vha->host_no)); 1011 vha->host_no));
980 1012
981 if (IS_QLA81XX(vha->hw)) { 1013 if (IS_QLA8XXX_TYPE(vha->hw)) {
982 vha->fcoe_vlan_id = mcp->mb[9] & 0xfff; 1014 vha->fcoe_vlan_id = mcp->mb[9] & 0xfff;
983 vha->fcoe_fcf_idx = mcp->mb[10]; 1015 vha->fcoe_fcf_idx = mcp->mb[10];
984 vha->fcoe_vn_port_mac[5] = mcp->mb[11] >> 8; 1016 vha->fcoe_vn_port_mac[5] = mcp->mb[11] >> 8;
@@ -1076,6 +1108,10 @@ qla2x00_init_firmware(scsi_qla_host_t *vha, uint16_t size)
1076 DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n", 1108 DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n",
1077 vha->host_no)); 1109 vha->host_no));
1078 1110
1111 if (IS_QLA82XX(ha) && ql2xdbwr)
1112 qla82xx_wr_32(ha, ha->nxdb_wr_ptr,
1113 (0x04 | (ha->portnum << 5) | (0 << 8) | (0 << 16)));
1114
1079 if (ha->flags.npiv_supported) 1115 if (ha->flags.npiv_supported)
1080 mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE; 1116 mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE;
1081 else 1117 else
@@ -1408,7 +1444,7 @@ qla2x00_lip_reset(scsi_qla_host_t *vha)
1408 1444
1409 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 1445 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1410 1446
1411 if (IS_QLA81XX(vha->hw)) { 1447 if (IS_QLA8XXX_TYPE(vha->hw)) {
1412 /* Logout across all FCFs. */ 1448 /* Logout across all FCFs. */
1413 mcp->mb[0] = MBC_LIP_FULL_LOGIN; 1449 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
1414 mcp->mb[1] = BIT_1; 1450 mcp->mb[1] = BIT_1;
@@ -2797,7 +2833,7 @@ qla2x00_set_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id,
2797 mcp->mb[0] = MBC_PORT_PARAMS; 2833 mcp->mb[0] = MBC_PORT_PARAMS;
2798 mcp->mb[1] = loop_id; 2834 mcp->mb[1] = loop_id;
2799 mcp->mb[2] = BIT_0; 2835 mcp->mb[2] = BIT_0;
2800 if (IS_QLA81XX(vha->hw)) 2836 if (IS_QLA8XXX_TYPE(vha->hw))
2801 mcp->mb[3] = port_speed & (BIT_5|BIT_4|BIT_3|BIT_2|BIT_1|BIT_0); 2837 mcp->mb[3] = port_speed & (BIT_5|BIT_4|BIT_3|BIT_2|BIT_1|BIT_0);
2802 else 2838 else
2803 mcp->mb[3] = port_speed & (BIT_2|BIT_1|BIT_0); 2839 mcp->mb[3] = port_speed & (BIT_2|BIT_1|BIT_0);
@@ -3586,7 +3622,7 @@ qla2x00_get_xgmac_stats(scsi_qla_host_t *vha, dma_addr_t stats_dma,
3586 mbx_cmd_t mc; 3622 mbx_cmd_t mc;
3587 mbx_cmd_t *mcp = &mc; 3623 mbx_cmd_t *mcp = &mc;
3588 3624
3589 if (!IS_QLA81XX(vha->hw)) 3625 if (!IS_QLA8XXX_TYPE(vha->hw))
3590 return QLA_FUNCTION_FAILED; 3626 return QLA_FUNCTION_FAILED;
3591 3627
3592 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 3628 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
@@ -3624,7 +3660,7 @@ qla2x00_get_dcbx_params(scsi_qla_host_t *vha, dma_addr_t tlv_dma,
3624 mbx_cmd_t mc; 3660 mbx_cmd_t mc;
3625 mbx_cmd_t *mcp = &mc; 3661 mbx_cmd_t *mcp = &mc;
3626 3662
3627 if (!IS_QLA81XX(vha->hw)) 3663 if (!IS_QLA8XXX_TYPE(vha->hw))
3628 return QLA_FUNCTION_FAILED; 3664 return QLA_FUNCTION_FAILED;
3629 3665
3630 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 3666 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
@@ -3685,7 +3721,8 @@ qla2x00_read_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t *data)
3685} 3721}
3686 3722
3687int 3723int
3688qla2x00_loopback_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, uint16_t *mresp) 3724qla2x00_loopback_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq,
3725 uint16_t *mresp)
3689{ 3726{
3690 int rval; 3727 int rval;
3691 mbx_cmd_t mc; 3728 mbx_cmd_t mc;
@@ -3720,7 +3757,7 @@ qla2x00_loopback_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, uint16_t *
3720 3757
3721 mcp->out_mb = MBX_21|MBX_20|MBX_19|MBX_18|MBX_17|MBX_16|MBX_15| 3758 mcp->out_mb = MBX_21|MBX_20|MBX_19|MBX_18|MBX_17|MBX_16|MBX_15|
3722 MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_7|MBX_6|MBX_1|MBX_0; 3759 MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_7|MBX_6|MBX_1|MBX_0;
3723 if (IS_QLA81XX(vha->hw)) 3760 if (IS_QLA8XXX_TYPE(vha->hw))
3724 mcp->out_mb |= MBX_2; 3761 mcp->out_mb |= MBX_2;
3725 mcp->in_mb = MBX_19|MBX_18|MBX_3|MBX_2|MBX_1|MBX_0; 3762 mcp->in_mb = MBX_19|MBX_18|MBX_3|MBX_2|MBX_1|MBX_0;
3726 3763
@@ -3732,9 +3769,11 @@ qla2x00_loopback_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, uint16_t *
3732 3769
3733 if (rval != QLA_SUCCESS) { 3770 if (rval != QLA_SUCCESS) {
3734 DEBUG2(printk(KERN_WARNING 3771 DEBUG2(printk(KERN_WARNING
3735 "(%ld): failed=%x mb[0]=0x%x " 3772 "(%ld): failed=%x mb[0]=0x%x "
3736 "mb[1]=0x%x mb[2]=0x%x mb[3]=0x%x mb[18]=0x%x mb[19]=0x%x. \n", vha->host_no, rval, 3773 "mb[1]=0x%x mb[2]=0x%x mb[3]=0x%x mb[18]=0x%x "
3737 mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], mcp->mb[18], mcp->mb[19])); 3774 "mb[19]=0x%x.\n",
3775 vha->host_no, rval, mcp->mb[0], mcp->mb[1], mcp->mb[2],
3776 mcp->mb[3], mcp->mb[18], mcp->mb[19]));
3738 } else { 3777 } else {
3739 DEBUG2(printk(KERN_WARNING 3778 DEBUG2(printk(KERN_WARNING
3740 "scsi(%ld): done.\n", vha->host_no)); 3779 "scsi(%ld): done.\n", vha->host_no));
@@ -3748,7 +3787,8 @@ qla2x00_loopback_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, uint16_t *
3748} 3787}
3749 3788
3750int 3789int
3751qla2x00_echo_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, uint16_t *mresp) 3790qla2x00_echo_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq,
3791 uint16_t *mresp)
3752{ 3792{
3753 int rval; 3793 int rval;
3754 mbx_cmd_t mc; 3794 mbx_cmd_t mc;
@@ -3760,9 +3800,10 @@ qla2x00_echo_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, uint16_t *mres
3760 memset(mcp->mb, 0 , sizeof(mcp->mb)); 3800 memset(mcp->mb, 0 , sizeof(mcp->mb));
3761 mcp->mb[0] = MBC_DIAGNOSTIC_ECHO; 3801 mcp->mb[0] = MBC_DIAGNOSTIC_ECHO;
3762 mcp->mb[1] = mreq->options | BIT_6; /* BIT_6 specifies 64bit address */ 3802 mcp->mb[1] = mreq->options | BIT_6; /* BIT_6 specifies 64bit address */
3763 if (IS_QLA81XX(ha)) 3803 if (IS_QLA8XXX_TYPE(ha)) {
3764 mcp->mb[1] |= BIT_15; 3804 mcp->mb[1] |= BIT_15;
3765 mcp->mb[2] = IS_QLA81XX(ha) ? vha->fcoe_fcf_idx : 0; 3805 mcp->mb[2] = vha->fcoe_fcf_idx;
3806 }
3766 mcp->mb[16] = LSW(mreq->rcv_dma); 3807 mcp->mb[16] = LSW(mreq->rcv_dma);
3767 mcp->mb[17] = MSW(mreq->rcv_dma); 3808 mcp->mb[17] = MSW(mreq->rcv_dma);
3768 mcp->mb[6] = LSW(MSD(mreq->rcv_dma)); 3809 mcp->mb[6] = LSW(MSD(mreq->rcv_dma));
@@ -3777,13 +3818,13 @@ qla2x00_echo_test(scsi_qla_host_t *vha, struct msg_echo_lb *mreq, uint16_t *mres
3777 3818
3778 mcp->out_mb = MBX_21|MBX_20|MBX_17|MBX_16|MBX_15| 3819 mcp->out_mb = MBX_21|MBX_20|MBX_17|MBX_16|MBX_15|
3779 MBX_14|MBX_10|MBX_7|MBX_6|MBX_1|MBX_0; 3820 MBX_14|MBX_10|MBX_7|MBX_6|MBX_1|MBX_0;
3780 if (IS_QLA81XX(ha)) 3821 if (IS_QLA8XXX_TYPE(ha))
3781 mcp->out_mb |= MBX_2; 3822 mcp->out_mb |= MBX_2;
3782 3823
3783 mcp->in_mb = MBX_0; 3824 mcp->in_mb = MBX_0;
3784 if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha)) 3825 if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) || IS_QLA8XXX_TYPE(ha))
3785 mcp->in_mb |= MBX_1; 3826 mcp->in_mb |= MBX_1;
3786 if (IS_QLA81XX(ha)) 3827 if (IS_QLA8XXX_TYPE(ha))
3787 mcp->in_mb |= MBX_3; 3828 mcp->in_mb |= MBX_3;
3788 3829
3789 mcp->tov = MBX_TOV_SECONDS; 3830 mcp->tov = MBX_TOV_SECONDS;
@@ -3875,7 +3916,8 @@ qla2x00_get_data_rate(scsi_qla_host_t *vha)
3875 if (!IS_FWI2_CAPABLE(ha)) 3916 if (!IS_FWI2_CAPABLE(ha))
3876 return QLA_FUNCTION_FAILED; 3917 return QLA_FUNCTION_FAILED;
3877 3918
3878 DEBUG11(printk(KERN_INFO "%s(%ld): entered.\n", __func__, vha->host_no)); 3919 DEBUG11(qla_printk(KERN_INFO, ha,
3920 "%s(%ld): entered.\n", __func__, vha->host_no));
3879 3921
3880 mcp->mb[0] = MBC_DATA_RATE; 3922 mcp->mb[0] = MBC_DATA_RATE;
3881 mcp->mb[1] = 0; 3923 mcp->mb[1] = 0;
@@ -3943,3 +3985,75 @@ qla24xx_set_fcp_prio(scsi_qla_host_t *vha, uint16_t loop_id, uint16_t priority,
3943 3985
3944 return rval; 3986 return rval;
3945} 3987}
3988
3989int
3990qla82xx_mbx_intr_enable(scsi_qla_host_t *vha)
3991{
3992 int rval;
3993 struct qla_hw_data *ha = vha->hw;
3994 mbx_cmd_t mc;
3995 mbx_cmd_t *mcp = &mc;
3996
3997 if (!IS_FWI2_CAPABLE(ha))
3998 return QLA_FUNCTION_FAILED;
3999
4000 DEBUG11(qla_printk(KERN_INFO, ha,
4001 "%s(%ld): entered.\n", __func__, vha->host_no));
4002
4003 memset(mcp, 0, sizeof(mbx_cmd_t));
4004 mcp->mb[0] = MBC_TOGGLE_INTR;
4005 mcp->mb[1] = 1;
4006
4007 mcp->out_mb = MBX_1|MBX_0;
4008 mcp->in_mb = MBX_0;
4009 mcp->tov = 30;
4010 mcp->flags = 0;
4011
4012 rval = qla2x00_mailbox_command(vha, mcp);
4013 if (rval != QLA_SUCCESS) {
4014 DEBUG2_3_11(qla_printk(KERN_WARNING, ha,
4015 "%s(%ld): failed=%x mb[0]=%x.\n", __func__,
4016 vha->host_no, rval, mcp->mb[0]));
4017 } else {
4018 DEBUG11(qla_printk(KERN_INFO, ha,
4019 "%s(%ld): done.\n", __func__, vha->host_no));
4020 }
4021
4022 return rval;
4023}
4024
4025int
4026qla82xx_mbx_intr_disable(scsi_qla_host_t *vha)
4027{
4028 int rval;
4029 struct qla_hw_data *ha = vha->hw;
4030 mbx_cmd_t mc;
4031 mbx_cmd_t *mcp = &mc;
4032
4033 if (!IS_QLA82XX(ha))
4034 return QLA_FUNCTION_FAILED;
4035
4036 DEBUG11(qla_printk(KERN_INFO, ha,
4037 "%s(%ld): entered.\n", __func__, vha->host_no));
4038
4039 memset(mcp, 0, sizeof(mbx_cmd_t));
4040 mcp->mb[0] = MBC_TOGGLE_INTR;
4041 mcp->mb[1] = 0;
4042
4043 mcp->out_mb = MBX_1|MBX_0;
4044 mcp->in_mb = MBX_0;
4045 mcp->tov = 30;
4046 mcp->flags = 0;
4047
4048 rval = qla2x00_mailbox_command(vha, mcp);
4049 if (rval != QLA_SUCCESS) {
4050 DEBUG2_3_11(qla_printk(KERN_WARNING, ha,
4051 "%s(%ld): failed=%x mb[0]=%x.\n", __func__,
4052 vha->host_no, rval, mcp->mb[0]));
4053 } else {
4054 DEBUG11(qla_printk(KERN_INFO, ha,
4055 "%s(%ld): done.\n", __func__, vha->host_no));
4056 }
4057
4058 return rval;
4059}