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.c318
1 files changed, 238 insertions, 80 deletions
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index bb103580e1ba..7d0a8a4c7719 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * QLogic Fibre Channel HBA Driver 2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2005 QLogic Corporation 3 * Copyright (c) 2003-2008 QLogic Corporation
4 * 4 *
5 * See LICENSE.qla2xxx for copyright and licensing details. 5 * See LICENSE.qla2xxx for copyright and licensing details.
6 */ 6 */
@@ -310,7 +310,7 @@ qla2x00_load_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t risc_addr,
310 } 310 }
311 311
312 mcp->in_mb = MBX_0; 312 mcp->in_mb = MBX_0;
313 mcp->tov = 30; 313 mcp->tov = MBX_TOV_SECONDS;
314 mcp->flags = 0; 314 mcp->flags = 0;
315 rval = qla2x00_mailbox_command(ha, mcp); 315 rval = qla2x00_mailbox_command(ha, mcp);
316 316
@@ -367,7 +367,7 @@ qla2x00_execute_fw(scsi_qla_host_t *ha, uint32_t risc_addr)
367 } 367 }
368 } 368 }
369 369
370 mcp->tov = 30; 370 mcp->tov = MBX_TOV_SECONDS;
371 mcp->flags = 0; 371 mcp->flags = 0;
372 rval = qla2x00_mailbox_command(ha, mcp); 372 rval = qla2x00_mailbox_command(ha, mcp);
373 373
@@ -417,7 +417,7 @@ qla2x00_get_fw_version(scsi_qla_host_t *ha, uint16_t *major, uint16_t *minor,
417 mcp->out_mb = MBX_0; 417 mcp->out_mb = MBX_0;
418 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 418 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
419 mcp->flags = 0; 419 mcp->flags = 0;
420 mcp->tov = 30; 420 mcp->tov = MBX_TOV_SECONDS;
421 rval = qla2x00_mailbox_command(ha, mcp); 421 rval = qla2x00_mailbox_command(ha, mcp);
422 422
423 /* Return mailbox data. */ 423 /* Return mailbox data. */
@@ -466,7 +466,7 @@ qla2x00_get_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts)
466 mcp->mb[0] = MBC_GET_FIRMWARE_OPTION; 466 mcp->mb[0] = MBC_GET_FIRMWARE_OPTION;
467 mcp->out_mb = MBX_0; 467 mcp->out_mb = MBX_0;
468 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; 468 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
469 mcp->tov = 30; 469 mcp->tov = MBX_TOV_SECONDS;
470 mcp->flags = 0; 470 mcp->flags = 0;
471 rval = qla2x00_mailbox_command(ha, mcp); 471 rval = qla2x00_mailbox_command(ha, mcp);
472 472
@@ -524,7 +524,7 @@ qla2x00_set_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts)
524 mcp->mb[12] = 0; /* Undocumented, but used */ 524 mcp->mb[12] = 0; /* Undocumented, but used */
525 mcp->out_mb |= MBX_12|MBX_11|MBX_10; 525 mcp->out_mb |= MBX_12|MBX_11|MBX_10;
526 } 526 }
527 mcp->tov = 30; 527 mcp->tov = MBX_TOV_SECONDS;
528 mcp->flags = 0; 528 mcp->flags = 0;
529 rval = qla2x00_mailbox_command(ha, mcp); 529 rval = qla2x00_mailbox_command(ha, mcp);
530 530
@@ -576,7 +576,7 @@ qla2x00_mbx_reg_test(scsi_qla_host_t *ha)
576 mcp->mb[7] = 0x2525; 576 mcp->mb[7] = 0x2525;
577 mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 577 mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
578 mcp->in_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 578 mcp->in_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
579 mcp->tov = 30; 579 mcp->tov = MBX_TOV_SECONDS;
580 mcp->flags = 0; 580 mcp->flags = 0;
581 rval = qla2x00_mailbox_command(ha, mcp); 581 rval = qla2x00_mailbox_command(ha, mcp);
582 582
@@ -587,6 +587,14 @@ qla2x00_mbx_reg_test(scsi_qla_host_t *ha)
587 if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A || 587 if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A ||
588 mcp->mb[7] != 0x2525) 588 mcp->mb[7] != 0x2525)
589 rval = QLA_FUNCTION_FAILED; 589 rval = QLA_FUNCTION_FAILED;
590 if (rval == QLA_FUNCTION_FAILED) {
591 struct device_reg_24xx __iomem *reg =
592 &ha->iobase->isp24;
593
594 qla2xxx_hw_event_log(ha, HW_EVENT_ISP_ERR, 0,
595 LSW(RD_REG_DWORD(&reg->hccr)),
596 LSW(RD_REG_DWORD(&reg->istatus)));
597 }
590 } 598 }
591 599
592 if (rval != QLA_SUCCESS) { 600 if (rval != QLA_SUCCESS) {
@@ -640,7 +648,7 @@ qla2x00_verify_checksum(scsi_qla_host_t *ha, uint32_t risc_addr)
640 mcp->in_mb |= MBX_1; 648 mcp->in_mb |= MBX_1;
641 } 649 }
642 650
643 mcp->tov = 30; 651 mcp->tov = MBX_TOV_SECONDS;
644 mcp->flags = 0; 652 mcp->flags = 0;
645 rval = qla2x00_mailbox_command(ha, mcp); 653 rval = qla2x00_mailbox_command(ha, mcp);
646 654
@@ -674,8 +682,8 @@ qla2x00_verify_checksum(scsi_qla_host_t *ha, uint32_t risc_addr)
674 * Kernel context. 682 * Kernel context.
675 */ 683 */
676int 684int
677qla2x00_issue_iocb(scsi_qla_host_t *ha, void* buffer, dma_addr_t phys_addr, 685qla2x00_issue_iocb_timeout(scsi_qla_host_t *ha, void *buffer,
678 size_t size) 686 dma_addr_t phys_addr, size_t size, uint32_t tov)
679{ 687{
680 int rval; 688 int rval;
681 mbx_cmd_t mc; 689 mbx_cmd_t mc;
@@ -689,7 +697,7 @@ qla2x00_issue_iocb(scsi_qla_host_t *ha, void* buffer, dma_addr_t phys_addr,
689 mcp->mb[7] = LSW(MSD(phys_addr)); 697 mcp->mb[7] = LSW(MSD(phys_addr));
690 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 698 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
691 mcp->in_mb = MBX_2|MBX_0; 699 mcp->in_mb = MBX_2|MBX_0;
692 mcp->tov = 30; 700 mcp->tov = tov;
693 mcp->flags = 0; 701 mcp->flags = 0;
694 rval = qla2x00_mailbox_command(ha, mcp); 702 rval = qla2x00_mailbox_command(ha, mcp);
695 703
@@ -710,6 +718,14 @@ qla2x00_issue_iocb(scsi_qla_host_t *ha, void* buffer, dma_addr_t phys_addr,
710 return rval; 718 return rval;
711} 719}
712 720
721int
722qla2x00_issue_iocb(scsi_qla_host_t *ha, void *buffer, dma_addr_t phys_addr,
723 size_t size)
724{
725 return qla2x00_issue_iocb_timeout(ha, buffer, phys_addr, size,
726 MBX_TOV_SECONDS);
727}
728
713/* 729/*
714 * qla2x00_abort_command 730 * qla2x00_abort_command
715 * Abort command aborts a specified IOCB. 731 * Abort command aborts a specified IOCB.
@@ -760,7 +776,7 @@ qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp)
760 mcp->mb[6] = (uint16_t)sp->cmd->device->lun; 776 mcp->mb[6] = (uint16_t)sp->cmd->device->lun;
761 mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 777 mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
762 mcp->in_mb = MBX_0; 778 mcp->in_mb = MBX_0;
763 mcp->tov = 30; 779 mcp->tov = MBX_TOV_SECONDS;
764 mcp->flags = 0; 780 mcp->flags = 0;
765 rval = qla2x00_mailbox_command(ha, mcp); 781 rval = qla2x00_mailbox_command(ha, mcp);
766 782
@@ -776,36 +792,20 @@ qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp)
776 return rval; 792 return rval;
777} 793}
778 794
779#if USE_ABORT_TGT
780/*
781 * qla2x00_abort_target
782 * Issue abort target mailbox command.
783 *
784 * Input:
785 * ha = adapter block pointer.
786 *
787 * Returns:
788 * qla2x00 local function return status code.
789 *
790 * Context:
791 * Kernel context.
792 */
793int 795int
794qla2x00_abort_target(fc_port_t *fcport) 796qla2x00_abort_target(struct fc_port *fcport, unsigned int l)
795{ 797{
796 int rval; 798 int rval, rval2;
797 mbx_cmd_t mc; 799 mbx_cmd_t mc;
798 mbx_cmd_t *mcp = &mc; 800 mbx_cmd_t *mcp = &mc;
799 scsi_qla_host_t *ha; 801 scsi_qla_host_t *ha;
800 802
801 if (fcport == NULL)
802 return 0;
803
804 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no)); 803 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no));
805 804
805 l = l;
806 ha = fcport->ha; 806 ha = fcport->ha;
807 mcp->mb[0] = MBC_ABORT_TARGET; 807 mcp->mb[0] = MBC_ABORT_TARGET;
808 mcp->out_mb = MBX_2|MBX_1|MBX_0; 808 mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0;
809 if (HAS_EXTENDED_IDS(ha)) { 809 if (HAS_EXTENDED_IDS(ha)) {
810 mcp->mb[1] = fcport->loop_id; 810 mcp->mb[1] = fcport->loop_id;
811 mcp->mb[10] = 0; 811 mcp->mb[10] = 0;
@@ -814,27 +814,70 @@ qla2x00_abort_target(fc_port_t *fcport)
814 mcp->mb[1] = fcport->loop_id << 8; 814 mcp->mb[1] = fcport->loop_id << 8;
815 } 815 }
816 mcp->mb[2] = ha->loop_reset_delay; 816 mcp->mb[2] = ha->loop_reset_delay;
817 mcp->mb[9] = ha->vp_idx;
817 818
818 mcp->in_mb = MBX_0; 819 mcp->in_mb = MBX_0;
819 mcp->tov = 30; 820 mcp->tov = MBX_TOV_SECONDS;
820 mcp->flags = 0; 821 mcp->flags = 0;
821 rval = qla2x00_mailbox_command(ha, mcp); 822 rval = qla2x00_mailbox_command(ha, mcp);
823 if (rval != QLA_SUCCESS) {
824 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
825 ha->host_no, rval));
826 }
822 827
823 /* Issue marker command. */ 828 /* Issue marker IOCB. */
824 ha->marker_needed = 1; 829 rval2 = qla2x00_marker(ha, fcport->loop_id, 0, MK_SYNC_ID);
830 if (rval2 != QLA_SUCCESS) {
831 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
832 "(%x).\n", __func__, ha->host_no, rval2));
833 } else {
834 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
835 }
836
837 return rval;
838}
839
840int
841qla2x00_lun_reset(struct fc_port *fcport, unsigned int l)
842{
843 int rval, rval2;
844 mbx_cmd_t mc;
845 mbx_cmd_t *mcp = &mc;
846 scsi_qla_host_t *ha;
847
848 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no));
849
850 ha = fcport->ha;
851 mcp->mb[0] = MBC_LUN_RESET;
852 mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0;
853 if (HAS_EXTENDED_IDS(ha))
854 mcp->mb[1] = fcport->loop_id;
855 else
856 mcp->mb[1] = fcport->loop_id << 8;
857 mcp->mb[2] = l;
858 mcp->mb[3] = 0;
859 mcp->mb[9] = ha->vp_idx;
825 860
861 mcp->in_mb = MBX_0;
862 mcp->tov = MBX_TOV_SECONDS;
863 mcp->flags = 0;
864 rval = qla2x00_mailbox_command(ha, mcp);
826 if (rval != QLA_SUCCESS) { 865 if (rval != QLA_SUCCESS) {
827 DEBUG2_3_11(printk("qla2x00_abort_target(%ld): failed=%x.\n", 866 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
828 ha->host_no, rval)); 867 ha->host_no, rval));
868 }
869
870 /* Issue marker IOCB. */
871 rval2 = qla2x00_marker(ha, fcport->loop_id, l, MK_SYNC_ID_LUN);
872 if (rval2 != QLA_SUCCESS) {
873 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
874 "(%x).\n", __func__, ha->host_no, rval2));
829 } else { 875 } else {
830 /*EMPTY*/ 876 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
831 DEBUG11(printk("qla2x00_abort_target(%ld): done.\n",
832 ha->host_no));
833 } 877 }
834 878
835 return rval; 879 return rval;
836} 880}
837#endif
838 881
839/* 882/*
840 * qla2x00_get_adapter_id 883 * qla2x00_get_adapter_id
@@ -871,7 +914,7 @@ qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa,
871 mcp->mb[9] = ha->vp_idx; 914 mcp->mb[9] = ha->vp_idx;
872 mcp->out_mb = MBX_9|MBX_0; 915 mcp->out_mb = MBX_9|MBX_0;
873 mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 916 mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
874 mcp->tov = 30; 917 mcp->tov = MBX_TOV_SECONDS;
875 mcp->flags = 0; 918 mcp->flags = 0;
876 rval = qla2x00_mailbox_command(ha, mcp); 919 rval = qla2x00_mailbox_command(ha, mcp);
877 if (mcp->mb[0] == MBS_COMMAND_ERROR) 920 if (mcp->mb[0] == MBS_COMMAND_ERROR)
@@ -928,7 +971,7 @@ qla2x00_get_retry_cnt(scsi_qla_host_t *ha, uint8_t *retry_cnt, uint8_t *tov,
928 mcp->mb[0] = MBC_GET_RETRY_COUNT; 971 mcp->mb[0] = MBC_GET_RETRY_COUNT;
929 mcp->out_mb = MBX_0; 972 mcp->out_mb = MBX_0;
930 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; 973 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
931 mcp->tov = 30; 974 mcp->tov = MBX_TOV_SECONDS;
932 mcp->flags = 0; 975 mcp->flags = 0;
933 rval = qla2x00_mailbox_command(ha, mcp); 976 rval = qla2x00_mailbox_command(ha, mcp);
934 977
@@ -995,7 +1038,7 @@ qla2x00_init_firmware(scsi_qla_host_t *ha, uint16_t size)
995 mcp->in_mb = MBX_5|MBX_4|MBX_0; 1038 mcp->in_mb = MBX_5|MBX_4|MBX_0;
996 mcp->buf_size = size; 1039 mcp->buf_size = size;
997 mcp->flags = MBX_DMA_OUT; 1040 mcp->flags = MBX_DMA_OUT;
998 mcp->tov = 30; 1041 mcp->tov = MBX_TOV_SECONDS;
999 rval = qla2x00_mailbox_command(ha, mcp); 1042 rval = qla2x00_mailbox_command(ha, mcp);
1000 1043
1001 if (rval != QLA_SUCCESS) { 1044 if (rval != QLA_SUCCESS) {
@@ -1173,7 +1216,7 @@ gpd_error_out:
1173 * Kernel context. 1216 * Kernel context.
1174 */ 1217 */
1175int 1218int
1176qla2x00_get_firmware_state(scsi_qla_host_t *ha, uint16_t *dptr) 1219qla2x00_get_firmware_state(scsi_qla_host_t *ha, uint16_t *states)
1177{ 1220{
1178 int rval; 1221 int rval;
1179 mbx_cmd_t mc; 1222 mbx_cmd_t mc;
@@ -1184,13 +1227,15 @@ qla2x00_get_firmware_state(scsi_qla_host_t *ha, uint16_t *dptr)
1184 1227
1185 mcp->mb[0] = MBC_GET_FIRMWARE_STATE; 1228 mcp->mb[0] = MBC_GET_FIRMWARE_STATE;
1186 mcp->out_mb = MBX_0; 1229 mcp->out_mb = MBX_0;
1187 mcp->in_mb = MBX_2|MBX_1|MBX_0; 1230 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1188 mcp->tov = 30; 1231 mcp->tov = MBX_TOV_SECONDS;
1189 mcp->flags = 0; 1232 mcp->flags = 0;
1190 rval = qla2x00_mailbox_command(ha, mcp); 1233 rval = qla2x00_mailbox_command(ha, mcp);
1191 1234
1192 /* Return firmware state. */ 1235 /* Return firmware states. */
1193 *dptr = mcp->mb[1]; 1236 states[0] = mcp->mb[1];
1237 states[1] = mcp->mb[2];
1238 states[2] = mcp->mb[3];
1194 1239
1195 if (rval != QLA_SUCCESS) { 1240 if (rval != QLA_SUCCESS) {
1196 /*EMPTY*/ 1241 /*EMPTY*/
@@ -1246,7 +1291,7 @@ qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name,
1246 } 1291 }
1247 1292
1248 mcp->in_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 1293 mcp->in_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
1249 mcp->tov = 30; 1294 mcp->tov = MBX_TOV_SECONDS;
1250 mcp->flags = 0; 1295 mcp->flags = 0;
1251 rval = qla2x00_mailbox_command(ha, mcp); 1296 rval = qla2x00_mailbox_command(ha, mcp);
1252 1297
@@ -1318,7 +1363,7 @@ qla2x00_lip_reset(scsi_qla_host_t *ha)
1318 mcp->mb[3] = 0; 1363 mcp->mb[3] = 0;
1319 } 1364 }
1320 mcp->in_mb = MBX_0; 1365 mcp->in_mb = MBX_0;
1321 mcp->tov = 30; 1366 mcp->tov = MBX_TOV_SECONDS;
1322 mcp->flags = 0; 1367 mcp->flags = 0;
1323 rval = qla2x00_mailbox_command(ha, mcp); 1368 rval = qla2x00_mailbox_command(ha, mcp);
1324 1369
@@ -1743,7 +1788,7 @@ qla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1743 } 1788 }
1744 1789
1745 mcp->in_mb = MBX_1|MBX_0; 1790 mcp->in_mb = MBX_1|MBX_0;
1746 mcp->tov = 30; 1791 mcp->tov = MBX_TOV_SECONDS;
1747 mcp->flags = 0; 1792 mcp->flags = 0;
1748 rval = qla2x00_mailbox_command(ha, mcp); 1793 rval = qla2x00_mailbox_command(ha, mcp);
1749 1794
@@ -1791,7 +1836,7 @@ qla2x00_full_login_lip(scsi_qla_host_t *ha)
1791 mcp->mb[3] = 0; 1836 mcp->mb[3] = 0;
1792 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1837 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1793 mcp->in_mb = MBX_0; 1838 mcp->in_mb = MBX_0;
1794 mcp->tov = 30; 1839 mcp->tov = MBX_TOV_SECONDS;
1795 mcp->flags = 0; 1840 mcp->flags = 0;
1796 rval = qla2x00_mailbox_command(ha, mcp); 1841 rval = qla2x00_mailbox_command(ha, mcp);
1797 1842
@@ -1852,7 +1897,7 @@ qla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma,
1852 mcp->out_mb |= MBX_6|MBX_3|MBX_2|MBX_1; 1897 mcp->out_mb |= MBX_6|MBX_3|MBX_2|MBX_1;
1853 } 1898 }
1854 mcp->in_mb = MBX_1|MBX_0; 1899 mcp->in_mb = MBX_1|MBX_0;
1855 mcp->tov = 30; 1900 mcp->tov = MBX_TOV_SECONDS;
1856 mcp->flags = 0; 1901 mcp->flags = 0;
1857 rval = qla2x00_mailbox_command(ha, mcp); 1902 rval = qla2x00_mailbox_command(ha, mcp);
1858 1903
@@ -1896,7 +1941,7 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt,
1896 mcp->mb[0] = MBC_GET_RESOURCE_COUNTS; 1941 mcp->mb[0] = MBC_GET_RESOURCE_COUNTS;
1897 mcp->out_mb = MBX_0; 1942 mcp->out_mb = MBX_0;
1898 mcp->in_mb = MBX_11|MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 1943 mcp->in_mb = MBX_11|MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
1899 mcp->tov = 30; 1944 mcp->tov = MBX_TOV_SECONDS;
1900 mcp->flags = 0; 1945 mcp->flags = 0;
1901 rval = qla2x00_mailbox_command(ha, mcp); 1946 rval = qla2x00_mailbox_command(ha, mcp);
1902 1947
@@ -2036,7 +2081,7 @@ qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
2036 mcp->mb[1] = loop_id << 8; 2081 mcp->mb[1] = loop_id << 8;
2037 mcp->out_mb |= MBX_1; 2082 mcp->out_mb |= MBX_1;
2038 } 2083 }
2039 mcp->tov = 30; 2084 mcp->tov = MBX_TOV_SECONDS;
2040 mcp->flags = IOCTL_CMD; 2085 mcp->flags = IOCTL_CMD;
2041 rval = qla2x00_mailbox_command(ha, mcp); 2086 rval = qla2x00_mailbox_command(ha, mcp);
2042 2087
@@ -2082,7 +2127,7 @@ qla24xx_get_isp_stats(scsi_qla_host_t *ha, struct link_statistics *stats,
2082 mcp->mb[10] = 0; 2127 mcp->mb[10] = 0;
2083 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 2128 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
2084 mcp->in_mb = MBX_2|MBX_1|MBX_0; 2129 mcp->in_mb = MBX_2|MBX_1|MBX_0;
2085 mcp->tov = 30; 2130 mcp->tov = MBX_TOV_SECONDS;
2086 mcp->flags = IOCTL_CMD; 2131 mcp->flags = IOCTL_CMD;
2087 rval = qla2x00_mailbox_command(ha, mcp); 2132 rval = qla2x00_mailbox_command(ha, mcp);
2088 2133
@@ -2180,17 +2225,15 @@ struct tsk_mgmt_cmd {
2180 } p; 2225 } p;
2181}; 2226};
2182 2227
2183int 2228static int
2184qla24xx_abort_target(fc_port_t *fcport) 2229__qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport,
2230 unsigned int l)
2185{ 2231{
2186 int rval; 2232 int rval, rval2;
2187 struct tsk_mgmt_cmd *tsk; 2233 struct tsk_mgmt_cmd *tsk;
2188 dma_addr_t tsk_dma; 2234 dma_addr_t tsk_dma;
2189 scsi_qla_host_t *ha, *pha; 2235 scsi_qla_host_t *ha, *pha;
2190 2236
2191 if (fcport == NULL)
2192 return 0;
2193
2194 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no)); 2237 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no));
2195 2238
2196 ha = fcport->ha; 2239 ha = fcport->ha;
@@ -2207,47 +2250,61 @@ qla24xx_abort_target(fc_port_t *fcport)
2207 tsk->p.tsk.entry_count = 1; 2250 tsk->p.tsk.entry_count = 1;
2208 tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id); 2251 tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id);
2209 tsk->p.tsk.timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); 2252 tsk->p.tsk.timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
2210 tsk->p.tsk.control_flags = __constant_cpu_to_le32(TCF_TARGET_RESET); 2253 tsk->p.tsk.control_flags = cpu_to_le32(type);
2211 tsk->p.tsk.port_id[0] = fcport->d_id.b.al_pa; 2254 tsk->p.tsk.port_id[0] = fcport->d_id.b.al_pa;
2212 tsk->p.tsk.port_id[1] = fcport->d_id.b.area; 2255 tsk->p.tsk.port_id[1] = fcport->d_id.b.area;
2213 tsk->p.tsk.port_id[2] = fcport->d_id.b.domain; 2256 tsk->p.tsk.port_id[2] = fcport->d_id.b.domain;
2214 tsk->p.tsk.vp_index = fcport->vp_idx; 2257 tsk->p.tsk.vp_index = fcport->vp_idx;
2258 if (type == TCF_LUN_RESET) {
2259 int_to_scsilun(l, &tsk->p.tsk.lun);
2260 host_to_fcp_swap((uint8_t *)&tsk->p.tsk.lun,
2261 sizeof(tsk->p.tsk.lun));
2262 }
2215 2263
2216 rval = qla2x00_issue_iocb(ha, tsk, tsk_dma, 0); 2264 rval = qla2x00_issue_iocb(ha, tsk, tsk_dma, 0);
2217 if (rval != QLA_SUCCESS) { 2265 if (rval != QLA_SUCCESS) {
2218 DEBUG2_3_11(printk("%s(%ld): failed to issue Target Reset IOCB " 2266 DEBUG2_3_11(printk("%s(%ld): failed to issue %s Reset IOCB "
2219 "(%x).\n", __func__, ha->host_no, rval)); 2267 "(%x).\n", __func__, ha->host_no, name, rval));
2220 goto atarget_done;
2221 } else if (tsk->p.sts.entry_status != 0) { 2268 } else if (tsk->p.sts.entry_status != 0) {
2222 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2269 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2223 "-- error status (%x).\n", __func__, ha->host_no, 2270 "-- error status (%x).\n", __func__, ha->host_no,
2224 tsk->p.sts.entry_status)); 2271 tsk->p.sts.entry_status));
2225 rval = QLA_FUNCTION_FAILED; 2272 rval = QLA_FUNCTION_FAILED;
2226 goto atarget_done;
2227 } else if (tsk->p.sts.comp_status != 2273 } else if (tsk->p.sts.comp_status !=
2228 __constant_cpu_to_le16(CS_COMPLETE)) { 2274 __constant_cpu_to_le16(CS_COMPLETE)) {
2229 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2275 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2230 "-- completion status (%x).\n", __func__, 2276 "-- completion status (%x).\n", __func__,
2231 ha->host_no, le16_to_cpu(tsk->p.sts.comp_status))); 2277 ha->host_no, le16_to_cpu(tsk->p.sts.comp_status)));
2232 rval = QLA_FUNCTION_FAILED; 2278 rval = QLA_FUNCTION_FAILED;
2233 goto atarget_done;
2234 } 2279 }
2235 2280
2236 /* Issue marker IOCB. */ 2281 /* Issue marker IOCB. */
2237 rval = qla2x00_marker(ha, fcport->loop_id, 0, MK_SYNC_ID); 2282 rval2 = qla2x00_marker(ha, fcport->loop_id, l,
2238 if (rval != QLA_SUCCESS) { 2283 type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID);
2284 if (rval2 != QLA_SUCCESS) {
2239 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB " 2285 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
2240 "(%x).\n", __func__, ha->host_no, rval)); 2286 "(%x).\n", __func__, ha->host_no, rval2));
2241 } else { 2287 } else {
2242 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2288 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
2243 } 2289 }
2244 2290
2245atarget_done:
2246 dma_pool_free(pha->s_dma_pool, tsk, tsk_dma); 2291 dma_pool_free(pha->s_dma_pool, tsk, tsk_dma);
2247 2292
2248 return rval; 2293 return rval;
2249} 2294}
2250 2295
2296int
2297qla24xx_abort_target(struct fc_port *fcport, unsigned int l)
2298{
2299 return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET, fcport, l);
2300}
2301
2302int
2303qla24xx_lun_reset(struct fc_port *fcport, unsigned int l)
2304{
2305 return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l);
2306}
2307
2251#if 0 2308#if 0
2252 2309
2253int 2310int
@@ -2304,7 +2361,7 @@ qla2x00_set_serdes_params(scsi_qla_host_t *ha, uint16_t sw_em_1g,
2304 mcp->mb[4] = sw_em_4g | BIT_15; 2361 mcp->mb[4] = sw_em_4g | BIT_15;
2305 mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 2362 mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
2306 mcp->in_mb = MBX_0; 2363 mcp->in_mb = MBX_0;
2307 mcp->tov = 30; 2364 mcp->tov = MBX_TOV_SECONDS;
2308 mcp->flags = 0; 2365 mcp->flags = 0;
2309 rval = qla2x00_mailbox_command(ha, mcp); 2366 rval = qla2x00_mailbox_command(ha, mcp);
2310 2367
@@ -2372,7 +2429,7 @@ qla2x00_enable_eft_trace(scsi_qla_host_t *ha, dma_addr_t eft_dma,
2372 mcp->mb[7] = TC_AEN_DISABLE; 2429 mcp->mb[7] = TC_AEN_DISABLE;
2373 mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 2430 mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
2374 mcp->in_mb = MBX_1|MBX_0; 2431 mcp->in_mb = MBX_1|MBX_0;
2375 mcp->tov = 30; 2432 mcp->tov = MBX_TOV_SECONDS;
2376 mcp->flags = 0; 2433 mcp->flags = 0;
2377 rval = qla2x00_mailbox_command(ha, mcp); 2434 rval = qla2x00_mailbox_command(ha, mcp);
2378 if (rval != QLA_SUCCESS) { 2435 if (rval != QLA_SUCCESS) {
@@ -2401,7 +2458,7 @@ qla2x00_disable_eft_trace(scsi_qla_host_t *ha)
2401 mcp->mb[1] = TC_EFT_DISABLE; 2458 mcp->mb[1] = TC_EFT_DISABLE;
2402 mcp->out_mb = MBX_1|MBX_0; 2459 mcp->out_mb = MBX_1|MBX_0;
2403 mcp->in_mb = MBX_1|MBX_0; 2460 mcp->in_mb = MBX_1|MBX_0;
2404 mcp->tov = 30; 2461 mcp->tov = MBX_TOV_SECONDS;
2405 mcp->flags = 0; 2462 mcp->flags = 0;
2406 rval = qla2x00_mailbox_command(ha, mcp); 2463 rval = qla2x00_mailbox_command(ha, mcp);
2407 if (rval != QLA_SUCCESS) { 2464 if (rval != QLA_SUCCESS) {
@@ -2441,7 +2498,7 @@ qla2x00_enable_fce_trace(scsi_qla_host_t *ha, dma_addr_t fce_dma,
2441 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| 2498 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|
2442 MBX_1|MBX_0; 2499 MBX_1|MBX_0;
2443 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 2500 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
2444 mcp->tov = 30; 2501 mcp->tov = MBX_TOV_SECONDS;
2445 mcp->flags = 0; 2502 mcp->flags = 0;
2446 rval = qla2x00_mailbox_command(ha, mcp); 2503 rval = qla2x00_mailbox_command(ha, mcp);
2447 if (rval != QLA_SUCCESS) { 2504 if (rval != QLA_SUCCESS) {
@@ -2477,7 +2534,7 @@ qla2x00_disable_fce_trace(scsi_qla_host_t *ha, uint64_t *wr, uint64_t *rd)
2477 mcp->out_mb = MBX_2|MBX_1|MBX_0; 2534 mcp->out_mb = MBX_2|MBX_1|MBX_0;
2478 mcp->in_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2| 2535 mcp->in_mb = MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|
2479 MBX_1|MBX_0; 2536 MBX_1|MBX_0;
2480 mcp->tov = 30; 2537 mcp->tov = MBX_TOV_SECONDS;
2481 mcp->flags = 0; 2538 mcp->flags = 0;
2482 rval = qla2x00_mailbox_command(ha, mcp); 2539 rval = qla2x00_mailbox_command(ha, mcp);
2483 if (rval != QLA_SUCCESS) { 2540 if (rval != QLA_SUCCESS) {
@@ -2525,7 +2582,7 @@ qla2x00_read_sfp(scsi_qla_host_t *ha, dma_addr_t sfp_dma, uint16_t addr,
2525 mcp->mb[10] = 0; 2582 mcp->mb[10] = 0;
2526 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 2583 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
2527 mcp->in_mb = MBX_0; 2584 mcp->in_mb = MBX_0;
2528 mcp->tov = 30; 2585 mcp->tov = MBX_TOV_SECONDS;
2529 mcp->flags = 0; 2586 mcp->flags = 0;
2530 rval = qla2x00_mailbox_command(ha, mcp); 2587 rval = qla2x00_mailbox_command(ha, mcp);
2531 2588
@@ -2559,7 +2616,7 @@ qla2x00_set_idma_speed(scsi_qla_host_t *ha, uint16_t loop_id,
2559 mcp->mb[4] = mcp->mb[5] = 0; 2616 mcp->mb[4] = mcp->mb[5] = 0;
2560 mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 2617 mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
2561 mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_1|MBX_0; 2618 mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_1|MBX_0;
2562 mcp->tov = 30; 2619 mcp->tov = MBX_TOV_SECONDS;
2563 mcp->flags = 0; 2620 mcp->flags = 0;
2564 rval = qla2x00_mailbox_command(ha, mcp); 2621 rval = qla2x00_mailbox_command(ha, mcp);
2565 2622
@@ -2877,7 +2934,7 @@ qla2x00_dump_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t addr,
2877 } 2934 }
2878 2935
2879 mcp->in_mb = MBX_0; 2936 mcp->in_mb = MBX_0;
2880 mcp->tov = 30; 2937 mcp->tov = MBX_TOV_SECONDS;
2881 mcp->flags = 0; 2938 mcp->flags = 0;
2882 rval = qla2x00_mailbox_command(ha, mcp); 2939 rval = qla2x00_mailbox_command(ha, mcp);
2883 2940
@@ -2890,3 +2947,104 @@ qla2x00_dump_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t addr,
2890 2947
2891 return rval; 2948 return rval;
2892} 2949}
2950
2951/* 84XX Support **************************************************************/
2952
2953struct cs84xx_mgmt_cmd {
2954 union {
2955 struct verify_chip_entry_84xx req;
2956 struct verify_chip_rsp_84xx rsp;
2957 } p;
2958};
2959
2960int
2961qla84xx_verify_chip(struct scsi_qla_host *ha, uint16_t *status)
2962{
2963 int rval, retry;
2964 struct cs84xx_mgmt_cmd *mn;
2965 dma_addr_t mn_dma;
2966 uint16_t options;
2967 unsigned long flags;
2968
2969 DEBUG16(printk("%s(%ld): entered.\n", __func__, ha->host_no));
2970
2971 mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma);
2972 if (mn == NULL) {
2973 DEBUG2_3(printk("%s(%ld): failed to allocate Verify ISP84XX "
2974 "IOCB.\n", __func__, ha->host_no));
2975 return QLA_MEMORY_ALLOC_FAILED;
2976 }
2977
2978 /* Force Update? */
2979 options = ha->cs84xx->fw_update ? VCO_FORCE_UPDATE : 0;
2980 /* Diagnostic firmware? */
2981 /* options |= MENLO_DIAG_FW; */
2982 /* We update the firmware with only one data sequence. */
2983 options |= VCO_END_OF_DATA;
2984
2985 retry = 0;
2986 do {
2987 memset(mn, 0, sizeof(*mn));
2988 mn->p.req.entry_type = VERIFY_CHIP_IOCB_TYPE;
2989 mn->p.req.entry_count = 1;
2990 mn->p.req.options = cpu_to_le16(options);
2991
2992 DEBUG16(printk("%s(%ld): Dump of Verify Request.\n", __func__,
2993 ha->host_no));
2994 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn,
2995 sizeof(*mn)));
2996
2997 rval = qla2x00_issue_iocb_timeout(ha, mn, mn_dma, 0, 120);
2998 if (rval != QLA_SUCCESS) {
2999 DEBUG2_16(printk("%s(%ld): failed to issue Verify "
3000 "IOCB (%x).\n", __func__, ha->host_no, rval));
3001 goto verify_done;
3002 }
3003
3004 DEBUG16(printk("%s(%ld): Dump of Verify Response.\n", __func__,
3005 ha->host_no));
3006 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn,
3007 sizeof(*mn)));
3008
3009 status[0] = le16_to_cpu(mn->p.rsp.comp_status);
3010 status[1] = status[0] == CS_VCS_CHIP_FAILURE ?
3011 le16_to_cpu(mn->p.rsp.failure_code) : 0;
3012 DEBUG2_16(printk("%s(%ld): cs=%x fc=%x\n", __func__,
3013 ha->host_no, status[0], status[1]));
3014
3015 if (status[0] != CS_COMPLETE) {
3016 rval = QLA_FUNCTION_FAILED;
3017 if (!(options & VCO_DONT_UPDATE_FW)) {
3018 DEBUG2_16(printk("%s(%ld): Firmware update "
3019 "failed. Retrying without update "
3020 "firmware.\n", __func__, ha->host_no));
3021 options |= VCO_DONT_UPDATE_FW;
3022 options &= ~VCO_FORCE_UPDATE;
3023 retry = 1;
3024 }
3025 } else {
3026 DEBUG2_16(printk("%s(%ld): firmware updated to %x.\n",
3027 __func__, ha->host_no,
3028 le32_to_cpu(mn->p.rsp.fw_ver)));
3029
3030 /* NOTE: we only update OP firmware. */
3031 spin_lock_irqsave(&ha->cs84xx->access_lock, flags);
3032 ha->cs84xx->op_fw_version =
3033 le32_to_cpu(mn->p.rsp.fw_ver);
3034 spin_unlock_irqrestore(&ha->cs84xx->access_lock,
3035 flags);
3036 }
3037 } while (retry);
3038
3039verify_done:
3040 dma_pool_free(ha->s_dma_pool, mn, mn_dma);
3041
3042 if (rval != QLA_SUCCESS) {
3043 DEBUG2_16(printk("%s(%ld): failed=%x.\n", __func__,
3044 ha->host_no, rval));
3045 } else {
3046 DEBUG16(printk("%s(%ld): done.\n", __func__, ha->host_no));
3047 }
3048
3049 return rval;
3050}