aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_isr.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_isr.c')
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c445
1 files changed, 181 insertions, 264 deletions
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 349843ea32f6..f79844ce7122 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -44,8 +44,8 @@ qla2100_intr_handler(int irq, void *dev_id)
44 44
45 rsp = (struct rsp_que *) dev_id; 45 rsp = (struct rsp_que *) dev_id;
46 if (!rsp) { 46 if (!rsp) {
47 printk(KERN_INFO 47 ql_log(ql_log_info, NULL, 0x505d,
48 "%s(): NULL response queue pointer.\n", __func__); 48 "%s: NULL response queue pointer.\n", __func__);
49 return (IRQ_NONE); 49 return (IRQ_NONE);
50 } 50 }
51 51
@@ -141,8 +141,8 @@ qla2300_intr_handler(int irq, void *dev_id)
141 141
142 rsp = (struct rsp_que *) dev_id; 142 rsp = (struct rsp_que *) dev_id;
143 if (!rsp) { 143 if (!rsp) {
144 printk(KERN_INFO 144 ql_log(ql_log_info, NULL, 0x5058,
145 "%s(): NULL response queue pointer.\n", __func__); 145 "%s: NULL response queue pointer.\n", __func__);
146 return (IRQ_NONE); 146 return (IRQ_NONE);
147 } 147 }
148 148
@@ -289,7 +289,7 @@ qla81xx_idc_event(scsi_qla_host_t *vha, uint16_t aen, uint16_t descr)
289 mb[cnt] = RD_REG_WORD(wptr); 289 mb[cnt] = RD_REG_WORD(wptr);
290 290
291 ql_dbg(ql_dbg_async, vha, 0x5021, 291 ql_dbg(ql_dbg_async, vha, 0x5021,
292 "Inter-Driver Commucation %s -- " 292 "Inter-Driver Communication %s -- "
293 "%04x %04x %04x %04x %04x %04x %04x.\n", 293 "%04x %04x %04x %04x %04x %04x %04x.\n",
294 event[aen & 0xff], mb[0], mb[1], mb[2], mb[3], 294 event[aen & 0xff], mb[0], mb[1], mb[2], mb[3],
295 mb[4], mb[5], mb[6]); 295 mb[4], mb[5], mb[6]);
@@ -318,7 +318,7 @@ void
318qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb) 318qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
319{ 319{
320#define LS_UNKNOWN 2 320#define LS_UNKNOWN 2
321 static char *link_speeds[] = { "1", "2", "?", "4", "8", "10" }; 321 static char *link_speeds[] = { "1", "2", "?", "4", "8", "16", "10" };
322 char *link_speed; 322 char *link_speed;
323 uint16_t handle_cnt; 323 uint16_t handle_cnt;
324 uint16_t cnt, mbx; 324 uint16_t cnt, mbx;
@@ -328,12 +328,11 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
328 struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; 328 struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24;
329 struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82; 329 struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82;
330 uint32_t rscn_entry, host_pid; 330 uint32_t rscn_entry, host_pid;
331 uint8_t rscn_queue_index;
332 unsigned long flags; 331 unsigned long flags;
333 332
334 /* Setup to process RIO completion. */ 333 /* Setup to process RIO completion. */
335 handle_cnt = 0; 334 handle_cnt = 0;
336 if (IS_QLA8XXX_TYPE(ha)) 335 if (IS_CNA_CAPABLE(ha))
337 goto skip_rio; 336 goto skip_rio;
338 switch (mb[0]) { 337 switch (mb[0]) {
339 case MBA_SCSI_COMPLETION: 338 case MBA_SCSI_COMPLETION:
@@ -405,7 +404,8 @@ skip_rio:
405 break; 404 break;
406 405
407 case MBA_SYSTEM_ERR: /* System Error */ 406 case MBA_SYSTEM_ERR: /* System Error */
408 mbx = IS_QLA81XX(ha) ? RD_REG_WORD(&reg24->mailbox7) : 0; 407 mbx = (IS_QLA81XX(ha) || IS_QLA83XX(ha)) ?
408 RD_REG_WORD(&reg24->mailbox7) : 0;
409 ql_log(ql_log_warn, vha, 0x5003, 409 ql_log(ql_log_warn, vha, 0x5003,
410 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh " 410 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh "
411 "mbx7=%xh.\n", mb[1], mb[2], mb[3], mbx); 411 "mbx7=%xh.\n", mb[1], mb[2], mb[3], mbx);
@@ -418,6 +418,7 @@ skip_rio:
418 "Unrecoverable Hardware Error: adapter " 418 "Unrecoverable Hardware Error: adapter "
419 "marked OFFLINE!\n"); 419 "marked OFFLINE!\n");
420 vha->flags.online = 0; 420 vha->flags.online = 0;
421 vha->device_flags |= DFLG_DEV_FAILED;
421 } else { 422 } else {
422 /* Check to see if MPI timeout occurred */ 423 /* Check to see if MPI timeout occurred */
423 if ((mbx & MBX_3) && (ha->flags.port0)) 424 if ((mbx & MBX_3) && (ha->flags.port0))
@@ -431,6 +432,7 @@ skip_rio:
431 "Unrecoverable Hardware Error: adapter marked " 432 "Unrecoverable Hardware Error: adapter marked "
432 "OFFLINE!\n"); 433 "OFFLINE!\n");
433 vha->flags.online = 0; 434 vha->flags.online = 0;
435 vha->device_flags |= DFLG_DEV_FAILED;
434 } else 436 } else
435 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); 437 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
436 break; 438 break;
@@ -482,10 +484,10 @@ skip_rio:
482 ha->link_data_rate = PORT_SPEED_1GB; 484 ha->link_data_rate = PORT_SPEED_1GB;
483 } else { 485 } else {
484 link_speed = link_speeds[LS_UNKNOWN]; 486 link_speed = link_speeds[LS_UNKNOWN];
485 if (mb[1] < 5) 487 if (mb[1] < 6)
486 link_speed = link_speeds[mb[1]]; 488 link_speed = link_speeds[mb[1]];
487 else if (mb[1] == 0x13) 489 else if (mb[1] == 0x13)
488 link_speed = link_speeds[5]; 490 link_speed = link_speeds[6];
489 ha->link_data_rate = mb[1]; 491 ha->link_data_rate = mb[1];
490 } 492 }
491 493
@@ -497,7 +499,8 @@ skip_rio:
497 break; 499 break;
498 500
499 case MBA_LOOP_DOWN: /* Loop Down Event */ 501 case MBA_LOOP_DOWN: /* Loop Down Event */
500 mbx = IS_QLA81XX(ha) ? RD_REG_WORD(&reg24->mailbox4) : 0; 502 mbx = (IS_QLA81XX(ha) || IS_QLA8031(ha))
503 ? RD_REG_WORD(&reg24->mailbox4) : 0;
501 mbx = IS_QLA82XX(ha) ? RD_REG_WORD(&reg82->mailbox_out[4]) : mbx; 504 mbx = IS_QLA82XX(ha) ? RD_REG_WORD(&reg82->mailbox_out[4]) : mbx;
502 ql_dbg(ql_dbg_async, vha, 0x500b, 505 ql_dbg(ql_dbg_async, vha, 0x500b,
503 "LOOP DOWN detected (%x %x %x %x).\n", 506 "LOOP DOWN detected (%x %x %x %x).\n",
@@ -547,7 +550,7 @@ skip_rio:
547 if (IS_QLA2100(ha)) 550 if (IS_QLA2100(ha))
548 break; 551 break;
549 552
550 if (IS_QLA8XXX_TYPE(ha)) { 553 if (IS_QLA81XX(ha) || IS_QLA82XX(ha) || IS_QLA8031(ha)) {
551 ql_dbg(ql_dbg_async, vha, 0x500d, 554 ql_dbg(ql_dbg_async, vha, 0x500d,
552 "DCBX Completed -- %04x %04x %04x.\n", 555 "DCBX Completed -- %04x %04x %04x.\n",
553 mb[1], mb[2], mb[3]); 556 mb[1], mb[2], mb[3]);
@@ -681,8 +684,6 @@ skip_rio:
681 684
682 qla2x00_mark_all_devices_lost(vha, 1); 685 qla2x00_mark_all_devices_lost(vha, 1);
683 686
684 vha->flags.rscn_queue_overflow = 1;
685
686 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); 687 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
687 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); 688 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
688 break; 689 break;
@@ -711,15 +712,6 @@ skip_rio:
711 712
712 /* Ignore reserved bits from RSCN-payload. */ 713 /* Ignore reserved bits from RSCN-payload. */
713 rscn_entry = ((mb[1] & 0x3ff) << 16) | mb[2]; 714 rscn_entry = ((mb[1] & 0x3ff) << 16) | mb[2];
714 rscn_queue_index = vha->rscn_in_ptr + 1;
715 if (rscn_queue_index == MAX_RSCN_COUNT)
716 rscn_queue_index = 0;
717 if (rscn_queue_index != vha->rscn_out_ptr) {
718 vha->rscn_queue[vha->rscn_in_ptr] = rscn_entry;
719 vha->rscn_in_ptr = rscn_queue_index;
720 } else {
721 vha->flags.rscn_queue_overflow = 1;
722 }
723 715
724 atomic_set(&vha->loop_down_timer, 0); 716 atomic_set(&vha->loop_down_timer, 0);
725 vha->flags.management_server_logged_in = 0; 717 vha->flags.management_server_logged_in = 0;
@@ -809,6 +801,10 @@ skip_rio:
809 case MBA_IDC_TIME_EXT: 801 case MBA_IDC_TIME_EXT:
810 qla81xx_idc_event(vha, mb[0], mb[1]); 802 qla81xx_idc_event(vha, mb[0], mb[1]);
811 break; 803 break;
804 default:
805 ql_dbg(ql_dbg_async, vha, 0x5057,
806 "Unknown AEN:%04x %04x %04x %04x\n",
807 mb[0], mb[1], mb[2], mb[3]);
812 } 808 }
813 809
814 if (!vha->vp_idx && ha->num_vhosts) 810 if (!vha->vp_idx && ha->num_vhosts)
@@ -845,8 +841,7 @@ qla2x00_process_completed_request(struct scsi_qla_host *vha,
845 req->outstanding_cmds[index] = NULL; 841 req->outstanding_cmds[index] = NULL;
846 842
847 /* Save ISP completion status */ 843 /* Save ISP completion status */
848 sp->cmd->result = DID_OK << 16; 844 sp->done(ha, sp, DID_OK << 16);
849 qla2x00_sp_compl(ha, sp);
850 } else { 845 } else {
851 ql_log(ql_log_warn, vha, 0x3016, "Invalid SCSI SRB.\n"); 846 ql_log(ql_log_warn, vha, 0x3016, "Invalid SCSI SRB.\n");
852 847
@@ -903,7 +898,6 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
903 fc_port_t *fcport; 898 fc_port_t *fcport;
904 srb_t *sp; 899 srb_t *sp;
905 struct srb_iocb *lio; 900 struct srb_iocb *lio;
906 struct srb_ctx *ctx;
907 uint16_t *data; 901 uint16_t *data;
908 uint16_t status; 902 uint16_t status;
909 903
@@ -911,9 +905,8 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
911 if (!sp) 905 if (!sp)
912 return; 906 return;
913 907
914 ctx = sp->ctx; 908 lio = &sp->u.iocb_cmd;
915 lio = ctx->u.iocb_cmd; 909 type = sp->name;
916 type = ctx->name;
917 fcport = sp->fcport; 910 fcport = sp->fcport;
918 data = lio->u.logio.data; 911 data = lio->u.logio.data;
919 912
@@ -937,7 +930,7 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
937 } 930 }
938 931
939 status = le16_to_cpu(mbx->status); 932 status = le16_to_cpu(mbx->status);
940 if (status == 0x30 && ctx->type == SRB_LOGIN_CMD && 933 if (status == 0x30 && sp->type == SRB_LOGIN_CMD &&
941 le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) 934 le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE)
942 status = 0; 935 status = 0;
943 if (!status && le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) { 936 if (!status && le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) {
@@ -948,7 +941,7 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
948 le16_to_cpu(mbx->mb1)); 941 le16_to_cpu(mbx->mb1));
949 942
950 data[0] = MBS_COMMAND_COMPLETE; 943 data[0] = MBS_COMMAND_COMPLETE;
951 if (ctx->type == SRB_LOGIN_CMD) { 944 if (sp->type == SRB_LOGIN_CMD) {
952 fcport->port_type = FCT_TARGET; 945 fcport->port_type = FCT_TARGET;
953 if (le16_to_cpu(mbx->mb1) & BIT_0) 946 if (le16_to_cpu(mbx->mb1) & BIT_0)
954 fcport->port_type = FCT_INITIATOR; 947 fcport->port_type = FCT_INITIATOR;
@@ -979,7 +972,7 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
979 le16_to_cpu(mbx->mb7)); 972 le16_to_cpu(mbx->mb7));
980 973
981logio_done: 974logio_done:
982 lio->done(sp); 975 sp->done(vha, sp, 0);
983} 976}
984 977
985static void 978static void
@@ -988,29 +981,18 @@ qla2x00_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
988{ 981{
989 const char func[] = "CT_IOCB"; 982 const char func[] = "CT_IOCB";
990 const char *type; 983 const char *type;
991 struct qla_hw_data *ha = vha->hw;
992 srb_t *sp; 984 srb_t *sp;
993 struct srb_ctx *sp_bsg;
994 struct fc_bsg_job *bsg_job; 985 struct fc_bsg_job *bsg_job;
995 uint16_t comp_status; 986 uint16_t comp_status;
987 int res;
996 988
997 sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); 989 sp = qla2x00_get_sp_from_handle(vha, func, req, pkt);
998 if (!sp) 990 if (!sp)
999 return; 991 return;
1000 992
1001 sp_bsg = sp->ctx; 993 bsg_job = sp->u.bsg_job;
1002 bsg_job = sp_bsg->u.bsg_job;
1003 994
1004 type = NULL; 995 type = "ct pass-through";
1005 switch (sp_bsg->type) {
1006 case SRB_CT_CMD:
1007 type = "ct pass-through";
1008 break;
1009 default:
1010 ql_log(ql_log_warn, vha, 0x5047,
1011 "Unrecognized SRB: (%p) type=%d.\n", sp, sp_bsg->type);
1012 return;
1013 }
1014 996
1015 comp_status = le16_to_cpu(pkt->comp_status); 997 comp_status = le16_to_cpu(pkt->comp_status);
1016 998
@@ -1022,7 +1004,7 @@ qla2x00_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
1022 1004
1023 if (comp_status != CS_COMPLETE) { 1005 if (comp_status != CS_COMPLETE) {
1024 if (comp_status == CS_DATA_UNDERRUN) { 1006 if (comp_status == CS_DATA_UNDERRUN) {
1025 bsg_job->reply->result = DID_OK << 16; 1007 res = DID_OK << 16;
1026 bsg_job->reply->reply_payload_rcv_len = 1008 bsg_job->reply->reply_payload_rcv_len =
1027 le16_to_cpu(((sts_entry_t *)pkt)->rsp_info_len); 1009 le16_to_cpu(((sts_entry_t *)pkt)->rsp_info_len);
1028 1010
@@ -1035,30 +1017,19 @@ qla2x00_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
1035 ql_log(ql_log_warn, vha, 0x5049, 1017 ql_log(ql_log_warn, vha, 0x5049,
1036 "CT pass-through-%s error " 1018 "CT pass-through-%s error "
1037 "comp_status-status=0x%x.\n", type, comp_status); 1019 "comp_status-status=0x%x.\n", type, comp_status);
1038 bsg_job->reply->result = DID_ERROR << 16; 1020 res = DID_ERROR << 16;
1039 bsg_job->reply->reply_payload_rcv_len = 0; 1021 bsg_job->reply->reply_payload_rcv_len = 0;
1040 } 1022 }
1041 ql_dump_buffer(ql_dbg_async + ql_dbg_buffer, vha, 0x5035, 1023 ql_dump_buffer(ql_dbg_async + ql_dbg_buffer, vha, 0x5035,
1042 (uint8_t *)pkt, sizeof(*pkt)); 1024 (uint8_t *)pkt, sizeof(*pkt));
1043 } else { 1025 } else {
1044 bsg_job->reply->result = DID_OK << 16; 1026 res = DID_OK << 16;
1045 bsg_job->reply->reply_payload_rcv_len = 1027 bsg_job->reply->reply_payload_rcv_len =
1046 bsg_job->reply_payload.payload_len; 1028 bsg_job->reply_payload.payload_len;
1047 bsg_job->reply_len = 0; 1029 bsg_job->reply_len = 0;
1048 } 1030 }
1049 1031
1050 dma_unmap_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list, 1032 sp->done(vha, sp, res);
1051 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
1052
1053 dma_unmap_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list,
1054 bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
1055
1056 if (sp_bsg->type == SRB_ELS_CMD_HST || sp_bsg->type == SRB_CT_CMD)
1057 kfree(sp->fcport);
1058
1059 kfree(sp->ctx);
1060 mempool_free(sp, ha->srb_mempool);
1061 bsg_job->job_done(bsg_job);
1062} 1033}
1063 1034
1064static void 1035static void
@@ -1067,22 +1038,20 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
1067{ 1038{
1068 const char func[] = "ELS_CT_IOCB"; 1039 const char func[] = "ELS_CT_IOCB";
1069 const char *type; 1040 const char *type;
1070 struct qla_hw_data *ha = vha->hw;
1071 srb_t *sp; 1041 srb_t *sp;
1072 struct srb_ctx *sp_bsg;
1073 struct fc_bsg_job *bsg_job; 1042 struct fc_bsg_job *bsg_job;
1074 uint16_t comp_status; 1043 uint16_t comp_status;
1075 uint32_t fw_status[3]; 1044 uint32_t fw_status[3];
1076 uint8_t* fw_sts_ptr; 1045 uint8_t* fw_sts_ptr;
1046 int res;
1077 1047
1078 sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); 1048 sp = qla2x00_get_sp_from_handle(vha, func, req, pkt);
1079 if (!sp) 1049 if (!sp)
1080 return; 1050 return;
1081 sp_bsg = sp->ctx; 1051 bsg_job = sp->u.bsg_job;
1082 bsg_job = sp_bsg->u.bsg_job;
1083 1052
1084 type = NULL; 1053 type = NULL;
1085 switch (sp_bsg->type) { 1054 switch (sp->type) {
1086 case SRB_ELS_CMD_RPT: 1055 case SRB_ELS_CMD_RPT:
1087 case SRB_ELS_CMD_HST: 1056 case SRB_ELS_CMD_HST:
1088 type = "els"; 1057 type = "els";
@@ -1091,8 +1060,8 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
1091 type = "ct pass-through"; 1060 type = "ct pass-through";
1092 break; 1061 break;
1093 default: 1062 default:
1094 ql_log(ql_log_warn, vha, 0x503e, 1063 ql_dbg(ql_dbg_user, vha, 0x503e,
1095 "Unrecognized SRB: (%p) type=%d.\n", sp, sp_bsg->type); 1064 "Unrecognized SRB: (%p) type=%d.\n", sp, sp->type);
1096 return; 1065 return;
1097 } 1066 }
1098 1067
@@ -1108,11 +1077,11 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
1108 1077
1109 if (comp_status != CS_COMPLETE) { 1078 if (comp_status != CS_COMPLETE) {
1110 if (comp_status == CS_DATA_UNDERRUN) { 1079 if (comp_status == CS_DATA_UNDERRUN) {
1111 bsg_job->reply->result = DID_OK << 16; 1080 res = DID_OK << 16;
1112 bsg_job->reply->reply_payload_rcv_len = 1081 bsg_job->reply->reply_payload_rcv_len =
1113 le16_to_cpu(((struct els_sts_entry_24xx*)pkt)->total_byte_count); 1082 le16_to_cpu(((struct els_sts_entry_24xx *)pkt)->total_byte_count);
1114 1083
1115 ql_log(ql_log_info, vha, 0x503f, 1084 ql_dbg(ql_dbg_user, vha, 0x503f,
1116 "ELS-CT pass-through-%s error hdl=%x comp_status-status=0x%x " 1085 "ELS-CT pass-through-%s error hdl=%x comp_status-status=0x%x "
1117 "error subcode 1=0x%x error subcode 2=0x%x total_byte = 0x%x.\n", 1086 "error subcode 1=0x%x error subcode 2=0x%x total_byte = 0x%x.\n",
1118 type, sp->handle, comp_status, fw_status[1], fw_status[2], 1087 type, sp->handle, comp_status, fw_status[1], fw_status[2],
@@ -1122,7 +1091,7 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
1122 memcpy( fw_sts_ptr, fw_status, sizeof(fw_status)); 1091 memcpy( fw_sts_ptr, fw_status, sizeof(fw_status));
1123 } 1092 }
1124 else { 1093 else {
1125 ql_log(ql_log_info, vha, 0x5040, 1094 ql_dbg(ql_dbg_user, vha, 0x5040,
1126 "ELS-CT pass-through-%s error hdl=%x comp_status-status=0x%x " 1095 "ELS-CT pass-through-%s error hdl=%x comp_status-status=0x%x "
1127 "error subcode 1=0x%x error subcode 2=0x%x.\n", 1096 "error subcode 1=0x%x error subcode 2=0x%x.\n",
1128 type, sp->handle, comp_status, 1097 type, sp->handle, comp_status,
@@ -1130,32 +1099,21 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
1130 pkt)->error_subcode_1), 1099 pkt)->error_subcode_1),
1131 le16_to_cpu(((struct els_sts_entry_24xx *) 1100 le16_to_cpu(((struct els_sts_entry_24xx *)
1132 pkt)->error_subcode_2)); 1101 pkt)->error_subcode_2));
1133 bsg_job->reply->result = DID_ERROR << 16; 1102 res = DID_ERROR << 16;
1134 bsg_job->reply->reply_payload_rcv_len = 0; 1103 bsg_job->reply->reply_payload_rcv_len = 0;
1135 fw_sts_ptr = ((uint8_t*)bsg_job->req->sense) + sizeof(struct fc_bsg_reply); 1104 fw_sts_ptr = ((uint8_t*)bsg_job->req->sense) + sizeof(struct fc_bsg_reply);
1136 memcpy( fw_sts_ptr, fw_status, sizeof(fw_status)); 1105 memcpy( fw_sts_ptr, fw_status, sizeof(fw_status));
1137 } 1106 }
1138 ql_dump_buffer(ql_dbg_async + ql_dbg_buffer, vha, 0x5056, 1107 ql_dump_buffer(ql_dbg_user + ql_dbg_buffer, vha, 0x5056,
1139 (uint8_t *)pkt, sizeof(*pkt)); 1108 (uint8_t *)pkt, sizeof(*pkt));
1140 } 1109 }
1141 else { 1110 else {
1142 bsg_job->reply->result = DID_OK << 16; 1111 res = DID_OK << 16;
1143 bsg_job->reply->reply_payload_rcv_len = bsg_job->reply_payload.payload_len; 1112 bsg_job->reply->reply_payload_rcv_len = bsg_job->reply_payload.payload_len;
1144 bsg_job->reply_len = 0; 1113 bsg_job->reply_len = 0;
1145 } 1114 }
1146 1115
1147 dma_unmap_sg(&ha->pdev->dev, 1116 sp->done(vha, sp, res);
1148 bsg_job->request_payload.sg_list,
1149 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
1150 dma_unmap_sg(&ha->pdev->dev,
1151 bsg_job->reply_payload.sg_list,
1152 bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
1153 if ((sp_bsg->type == SRB_ELS_CMD_HST) ||
1154 (sp_bsg->type == SRB_CT_CMD))
1155 kfree(sp->fcport);
1156 kfree(sp->ctx);
1157 mempool_free(sp, ha->srb_mempool);
1158 bsg_job->job_done(bsg_job);
1159} 1117}
1160 1118
1161static void 1119static void
@@ -1167,7 +1125,6 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
1167 fc_port_t *fcport; 1125 fc_port_t *fcport;
1168 srb_t *sp; 1126 srb_t *sp;
1169 struct srb_iocb *lio; 1127 struct srb_iocb *lio;
1170 struct srb_ctx *ctx;
1171 uint16_t *data; 1128 uint16_t *data;
1172 uint32_t iop[2]; 1129 uint32_t iop[2];
1173 1130
@@ -1175,9 +1132,8 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
1175 if (!sp) 1132 if (!sp)
1176 return; 1133 return;
1177 1134
1178 ctx = sp->ctx; 1135 lio = &sp->u.iocb_cmd;
1179 lio = ctx->u.iocb_cmd; 1136 type = sp->name;
1180 type = ctx->name;
1181 fcport = sp->fcport; 1137 fcport = sp->fcport;
1182 data = lio->u.logio.data; 1138 data = lio->u.logio.data;
1183 1139
@@ -1185,7 +1141,7 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
1185 data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? 1141 data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ?
1186 QLA_LOGIO_LOGIN_RETRIED : 0; 1142 QLA_LOGIO_LOGIN_RETRIED : 0;
1187 if (logio->entry_status) { 1143 if (logio->entry_status) {
1188 ql_log(ql_log_warn, vha, 0x5034, 1144 ql_log(ql_log_warn, fcport->vha, 0x5034,
1189 "Async-%s error entry - hdl=%x" 1145 "Async-%s error entry - hdl=%x"
1190 "portid=%02x%02x%02x entry-status=%x.\n", 1146 "portid=%02x%02x%02x entry-status=%x.\n",
1191 type, sp->handle, fcport->d_id.b.domain, 1147 type, sp->handle, fcport->d_id.b.domain,
@@ -1198,14 +1154,14 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
1198 } 1154 }
1199 1155
1200 if (le16_to_cpu(logio->comp_status) == CS_COMPLETE) { 1156 if (le16_to_cpu(logio->comp_status) == CS_COMPLETE) {
1201 ql_dbg(ql_dbg_async, vha, 0x5036, 1157 ql_dbg(ql_dbg_async, fcport->vha, 0x5036,
1202 "Async-%s complete - hdl=%x portid=%02x%02x%02x " 1158 "Async-%s complete - hdl=%x portid=%02x%02x%02x "
1203 "iop0=%x.\n", type, sp->handle, fcport->d_id.b.domain, 1159 "iop0=%x.\n", type, sp->handle, fcport->d_id.b.domain,
1204 fcport->d_id.b.area, fcport->d_id.b.al_pa, 1160 fcport->d_id.b.area, fcport->d_id.b.al_pa,
1205 le32_to_cpu(logio->io_parameter[0])); 1161 le32_to_cpu(logio->io_parameter[0]));
1206 1162
1207 data[0] = MBS_COMMAND_COMPLETE; 1163 data[0] = MBS_COMMAND_COMPLETE;
1208 if (ctx->type != SRB_LOGIN_CMD) 1164 if (sp->type != SRB_LOGIN_CMD)
1209 goto logio_done; 1165 goto logio_done;
1210 1166
1211 iop[0] = le32_to_cpu(logio->io_parameter[0]); 1167 iop[0] = le32_to_cpu(logio->io_parameter[0]);
@@ -1239,7 +1195,7 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
1239 break; 1195 break;
1240 } 1196 }
1241 1197
1242 ql_dbg(ql_dbg_async, vha, 0x5037, 1198 ql_dbg(ql_dbg_async, fcport->vha, 0x5037,
1243 "Async-%s failed - hdl=%x portid=%02x%02x%02x comp=%x " 1199 "Async-%s failed - hdl=%x portid=%02x%02x%02x comp=%x "
1244 "iop0=%x iop1=%x.\n", type, sp->handle, fcport->d_id.b.domain, 1200 "iop0=%x iop1=%x.\n", type, sp->handle, fcport->d_id.b.domain,
1245 fcport->d_id.b.area, fcport->d_id.b.al_pa, 1201 fcport->d_id.b.area, fcport->d_id.b.al_pa,
@@ -1248,7 +1204,7 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
1248 le32_to_cpu(logio->io_parameter[1])); 1204 le32_to_cpu(logio->io_parameter[1]));
1249 1205
1250logio_done: 1206logio_done:
1251 lio->done(sp); 1207 sp->done(vha, sp, 0);
1252} 1208}
1253 1209
1254static void 1210static void
@@ -1260,7 +1216,6 @@ qla24xx_tm_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
1260 fc_port_t *fcport; 1216 fc_port_t *fcport;
1261 srb_t *sp; 1217 srb_t *sp;
1262 struct srb_iocb *iocb; 1218 struct srb_iocb *iocb;
1263 struct srb_ctx *ctx;
1264 struct sts_entry_24xx *sts = (struct sts_entry_24xx *)tsk; 1219 struct sts_entry_24xx *sts = (struct sts_entry_24xx *)tsk;
1265 int error = 1; 1220 int error = 1;
1266 1221
@@ -1268,30 +1223,29 @@ qla24xx_tm_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
1268 if (!sp) 1223 if (!sp)
1269 return; 1224 return;
1270 1225
1271 ctx = sp->ctx; 1226 iocb = &sp->u.iocb_cmd;
1272 iocb = ctx->u.iocb_cmd; 1227 type = sp->name;
1273 type = ctx->name;
1274 fcport = sp->fcport; 1228 fcport = sp->fcport;
1275 1229
1276 if (sts->entry_status) { 1230 if (sts->entry_status) {
1277 ql_log(ql_log_warn, vha, 0x5038, 1231 ql_log(ql_log_warn, fcport->vha, 0x5038,
1278 "Async-%s error - hdl=%x entry-status(%x).\n", 1232 "Async-%s error - hdl=%x entry-status(%x).\n",
1279 type, sp->handle, sts->entry_status); 1233 type, sp->handle, sts->entry_status);
1280 } else if (sts->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { 1234 } else if (sts->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
1281 ql_log(ql_log_warn, vha, 0x5039, 1235 ql_log(ql_log_warn, fcport->vha, 0x5039,
1282 "Async-%s error - hdl=%x completion status(%x).\n", 1236 "Async-%s error - hdl=%x completion status(%x).\n",
1283 type, sp->handle, sts->comp_status); 1237 type, sp->handle, sts->comp_status);
1284 } else if (!(le16_to_cpu(sts->scsi_status) & 1238 } else if (!(le16_to_cpu(sts->scsi_status) &
1285 SS_RESPONSE_INFO_LEN_VALID)) { 1239 SS_RESPONSE_INFO_LEN_VALID)) {
1286 ql_log(ql_log_warn, vha, 0x503a, 1240 ql_log(ql_log_warn, fcport->vha, 0x503a,
1287 "Async-%s error - hdl=%x no response info(%x).\n", 1241 "Async-%s error - hdl=%x no response info(%x).\n",
1288 type, sp->handle, sts->scsi_status); 1242 type, sp->handle, sts->scsi_status);
1289 } else if (le32_to_cpu(sts->rsp_data_len) < 4) { 1243 } else if (le32_to_cpu(sts->rsp_data_len) < 4) {
1290 ql_log(ql_log_warn, vha, 0x503b, 1244 ql_log(ql_log_warn, fcport->vha, 0x503b,
1291 "Async-%s error - hdl=%x not enough response(%d).\n", 1245 "Async-%s error - hdl=%x not enough response(%d).\n",
1292 type, sp->handle, sts->rsp_data_len); 1246 type, sp->handle, sts->rsp_data_len);
1293 } else if (sts->data[3]) { 1247 } else if (sts->data[3]) {
1294 ql_log(ql_log_warn, vha, 0x503c, 1248 ql_log(ql_log_warn, fcport->vha, 0x503c,
1295 "Async-%s error - hdl=%x response(%x).\n", 1249 "Async-%s error - hdl=%x response(%x).\n",
1296 type, sp->handle, sts->data[3]); 1250 type, sp->handle, sts->data[3]);
1297 } else { 1251 } else {
@@ -1304,7 +1258,7 @@ qla24xx_tm_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
1304 (uint8_t *)sts, sizeof(*sts)); 1258 (uint8_t *)sts, sizeof(*sts));
1305 } 1259 }
1306 1260
1307 iocb->done(sp); 1261 sp->done(vha, sp, 0);
1308} 1262}
1309 1263
1310/** 1264/**
@@ -1390,25 +1344,32 @@ qla2x00_process_response_queue(struct rsp_que *rsp)
1390 1344
1391static inline void 1345static inline void
1392qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t par_sense_len, 1346qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t par_sense_len,
1393 uint32_t sense_len, struct rsp_que *rsp) 1347 uint32_t sense_len, struct rsp_que *rsp, int res)
1394{ 1348{
1395 struct scsi_qla_host *vha = sp->fcport->vha; 1349 struct scsi_qla_host *vha = sp->fcport->vha;
1396 struct scsi_cmnd *cp = sp->cmd; 1350 struct scsi_cmnd *cp = GET_CMD_SP(sp);
1351 uint32_t track_sense_len;
1397 1352
1398 if (sense_len >= SCSI_SENSE_BUFFERSIZE) 1353 if (sense_len >= SCSI_SENSE_BUFFERSIZE)
1399 sense_len = SCSI_SENSE_BUFFERSIZE; 1354 sense_len = SCSI_SENSE_BUFFERSIZE;
1400 1355
1401 sp->request_sense_length = sense_len; 1356 SET_CMD_SENSE_LEN(sp, sense_len);
1402 sp->request_sense_ptr = cp->sense_buffer; 1357 SET_CMD_SENSE_PTR(sp, cp->sense_buffer);
1403 if (sp->request_sense_length > par_sense_len) 1358 track_sense_len = sense_len;
1359
1360 if (sense_len > par_sense_len)
1404 sense_len = par_sense_len; 1361 sense_len = par_sense_len;
1405 1362
1406 memcpy(cp->sense_buffer, sense_data, sense_len); 1363 memcpy(cp->sense_buffer, sense_data, sense_len);
1407 1364
1408 sp->request_sense_ptr += sense_len; 1365 SET_CMD_SENSE_PTR(sp, cp->sense_buffer + sense_len);
1409 sp->request_sense_length -= sense_len; 1366 track_sense_len -= sense_len;
1410 if (sp->request_sense_length != 0) 1367 SET_CMD_SENSE_LEN(sp, track_sense_len);
1368
1369 if (track_sense_len != 0) {
1411 rsp->status_srb = sp; 1370 rsp->status_srb = sp;
1371 cp->result = res;
1372 }
1412 1373
1413 if (sense_len) { 1374 if (sense_len) {
1414 ql_dbg(ql_dbg_io + ql_dbg_buffer, vha, 0x301c, 1375 ql_dbg(ql_dbg_io + ql_dbg_buffer, vha, 0x301c,
@@ -1436,7 +1397,7 @@ static inline int
1436qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24) 1397qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)
1437{ 1398{
1438 struct scsi_qla_host *vha = sp->fcport->vha; 1399 struct scsi_qla_host *vha = sp->fcport->vha;
1439 struct scsi_cmnd *cmd = sp->cmd; 1400 struct scsi_cmnd *cmd = GET_CMD_SP(sp);
1440 uint8_t *ap = &sts24->data[12]; 1401 uint8_t *ap = &sts24->data[12];
1441 uint8_t *ep = &sts24->data[20]; 1402 uint8_t *ep = &sts24->data[20];
1442 uint32_t e_ref_tag, a_ref_tag; 1403 uint32_t e_ref_tag, a_ref_tag;
@@ -1580,6 +1541,7 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
1580 uint16_t que; 1541 uint16_t que;
1581 struct req_que *req; 1542 struct req_que *req;
1582 int logit = 1; 1543 int logit = 1;
1544 int res = 0;
1583 1545
1584 sts = (sts_entry_t *) pkt; 1546 sts = (sts_entry_t *) pkt;
1585 sts24 = (struct sts_entry_24xx *) pkt; 1547 sts24 = (struct sts_entry_24xx *) pkt;
@@ -1619,7 +1581,7 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
1619 qla2xxx_wake_dpc(vha); 1581 qla2xxx_wake_dpc(vha);
1620 return; 1582 return;
1621 } 1583 }
1622 cp = sp->cmd; 1584 cp = GET_CMD_SP(sp);
1623 if (cp == NULL) { 1585 if (cp == NULL) {
1624 ql_dbg(ql_dbg_io, vha, 0x3018, 1586 ql_dbg(ql_dbg_io, vha, 0x3018,
1625 "Command already returned (0x%x/%p).\n", 1587 "Command already returned (0x%x/%p).\n",
@@ -1668,11 +1630,11 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
1668 par_sense_len -= rsp_info_len; 1630 par_sense_len -= rsp_info_len;
1669 } 1631 }
1670 if (rsp_info_len > 3 && rsp_info[3]) { 1632 if (rsp_info_len > 3 && rsp_info[3]) {
1671 ql_dbg(ql_dbg_io, vha, 0x3019, 1633 ql_dbg(ql_dbg_io, fcport->vha, 0x3019,
1672 "FCP I/O protocol failure (0x%x/0x%x).\n", 1634 "FCP I/O protocol failure (0x%x/0x%x).\n",
1673 rsp_info_len, rsp_info[3]); 1635 rsp_info_len, rsp_info[3]);
1674 1636
1675 cp->result = DID_BUS_BUSY << 16; 1637 res = DID_BUS_BUSY << 16;
1676 goto out; 1638 goto out;
1677 } 1639 }
1678 } 1640 }
@@ -1689,7 +1651,7 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
1689 case CS_COMPLETE: 1651 case CS_COMPLETE:
1690 case CS_QUEUE_FULL: 1652 case CS_QUEUE_FULL:
1691 if (scsi_status == 0) { 1653 if (scsi_status == 0) {
1692 cp->result = DID_OK << 16; 1654 res = DID_OK << 16;
1693 break; 1655 break;
1694 } 1656 }
1695 if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) { 1657 if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) {
@@ -1699,19 +1661,19 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
1699 if (!lscsi_status && 1661 if (!lscsi_status &&
1700 ((unsigned)(scsi_bufflen(cp) - resid) < 1662 ((unsigned)(scsi_bufflen(cp) - resid) <
1701 cp->underflow)) { 1663 cp->underflow)) {
1702 ql_dbg(ql_dbg_io, vha, 0x301a, 1664 ql_dbg(ql_dbg_io, fcport->vha, 0x301a,
1703 "Mid-layer underflow " 1665 "Mid-layer underflow "
1704 "detected (0x%x of 0x%x bytes).\n", 1666 "detected (0x%x of 0x%x bytes).\n",
1705 resid, scsi_bufflen(cp)); 1667 resid, scsi_bufflen(cp));
1706 1668
1707 cp->result = DID_ERROR << 16; 1669 res = DID_ERROR << 16;
1708 break; 1670 break;
1709 } 1671 }
1710 } 1672 }
1711 cp->result = DID_OK << 16 | lscsi_status; 1673 res = DID_OK << 16 | lscsi_status;
1712 1674
1713 if (lscsi_status == SAM_STAT_TASK_SET_FULL) { 1675 if (lscsi_status == SAM_STAT_TASK_SET_FULL) {
1714 ql_dbg(ql_dbg_io, vha, 0x301b, 1676 ql_dbg(ql_dbg_io, fcport->vha, 0x301b,
1715 "QUEUE FULL detected.\n"); 1677 "QUEUE FULL detected.\n");
1716 break; 1678 break;
1717 } 1679 }
@@ -1724,7 +1686,7 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
1724 break; 1686 break;
1725 1687
1726 qla2x00_handle_sense(sp, sense_data, par_sense_len, sense_len, 1688 qla2x00_handle_sense(sp, sense_data, par_sense_len, sense_len,
1727 rsp); 1689 rsp, res);
1728 break; 1690 break;
1729 1691
1730 case CS_DATA_UNDERRUN: 1692 case CS_DATA_UNDERRUN:
@@ -1733,36 +1695,36 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
1733 scsi_set_resid(cp, resid); 1695 scsi_set_resid(cp, resid);
1734 if (scsi_status & SS_RESIDUAL_UNDER) { 1696 if (scsi_status & SS_RESIDUAL_UNDER) {
1735 if (IS_FWI2_CAPABLE(ha) && fw_resid_len != resid_len) { 1697 if (IS_FWI2_CAPABLE(ha) && fw_resid_len != resid_len) {
1736 ql_dbg(ql_dbg_io, vha, 0x301d, 1698 ql_dbg(ql_dbg_io, fcport->vha, 0x301d,
1737 "Dropped frame(s) detected " 1699 "Dropped frame(s) detected "
1738 "(0x%x of 0x%x bytes).\n", 1700 "(0x%x of 0x%x bytes).\n",
1739 resid, scsi_bufflen(cp)); 1701 resid, scsi_bufflen(cp));
1740 1702
1741 cp->result = DID_ERROR << 16 | lscsi_status; 1703 res = DID_ERROR << 16 | lscsi_status;
1742 goto check_scsi_status; 1704 goto check_scsi_status;
1743 } 1705 }
1744 1706
1745 if (!lscsi_status && 1707 if (!lscsi_status &&
1746 ((unsigned)(scsi_bufflen(cp) - resid) < 1708 ((unsigned)(scsi_bufflen(cp) - resid) <
1747 cp->underflow)) { 1709 cp->underflow)) {
1748 ql_dbg(ql_dbg_io, vha, 0x301e, 1710 ql_dbg(ql_dbg_io, fcport->vha, 0x301e,
1749 "Mid-layer underflow " 1711 "Mid-layer underflow "
1750 "detected (0x%x of 0x%x bytes).\n", 1712 "detected (0x%x of 0x%x bytes).\n",
1751 resid, scsi_bufflen(cp)); 1713 resid, scsi_bufflen(cp));
1752 1714
1753 cp->result = DID_ERROR << 16; 1715 res = DID_ERROR << 16;
1754 break; 1716 break;
1755 } 1717 }
1756 } else { 1718 } else {
1757 ql_dbg(ql_dbg_io, vha, 0x301f, 1719 ql_dbg(ql_dbg_io, fcport->vha, 0x301f,
1758 "Dropped frame(s) detected (0x%x " 1720 "Dropped frame(s) detected (0x%x "
1759 "of 0x%x bytes).\n", resid, scsi_bufflen(cp)); 1721 "of 0x%x bytes).\n", resid, scsi_bufflen(cp));
1760 1722
1761 cp->result = DID_ERROR << 16 | lscsi_status; 1723 res = DID_ERROR << 16 | lscsi_status;
1762 goto check_scsi_status; 1724 goto check_scsi_status;
1763 } 1725 }
1764 1726
1765 cp->result = DID_OK << 16 | lscsi_status; 1727 res = DID_OK << 16 | lscsi_status;
1766 logit = 0; 1728 logit = 0;
1767 1729
1768check_scsi_status: 1730check_scsi_status:
@@ -1772,7 +1734,7 @@ check_scsi_status:
1772 */ 1734 */
1773 if (lscsi_status != 0) { 1735 if (lscsi_status != 0) {
1774 if (lscsi_status == SAM_STAT_TASK_SET_FULL) { 1736 if (lscsi_status == SAM_STAT_TASK_SET_FULL) {
1775 ql_dbg(ql_dbg_io, vha, 0x3020, 1737 ql_dbg(ql_dbg_io, fcport->vha, 0x3020,
1776 "QUEUE FULL detected.\n"); 1738 "QUEUE FULL detected.\n");
1777 logit = 1; 1739 logit = 1;
1778 break; 1740 break;
@@ -1785,7 +1747,7 @@ check_scsi_status:
1785 break; 1747 break;
1786 1748
1787 qla2x00_handle_sense(sp, sense_data, par_sense_len, 1749 qla2x00_handle_sense(sp, sense_data, par_sense_len,
1788 sense_len, rsp); 1750 sense_len, rsp, res);
1789 } 1751 }
1790 break; 1752 break;
1791 1753
@@ -1802,7 +1764,7 @@ check_scsi_status:
1802 * while we try to recover so instruct the mid layer 1764 * while we try to recover so instruct the mid layer
1803 * to requeue until the class decides how to handle this. 1765 * to requeue until the class decides how to handle this.
1804 */ 1766 */
1805 cp->result = DID_TRANSPORT_DISRUPTED << 16; 1767 res = DID_TRANSPORT_DISRUPTED << 16;
1806 1768
1807 if (comp_status == CS_TIMEOUT) { 1769 if (comp_status == CS_TIMEOUT) {
1808 if (IS_FWI2_CAPABLE(ha)) 1770 if (IS_FWI2_CAPABLE(ha))
@@ -1812,7 +1774,7 @@ check_scsi_status:
1812 break; 1774 break;
1813 } 1775 }
1814 1776
1815 ql_dbg(ql_dbg_io, vha, 0x3021, 1777 ql_dbg(ql_dbg_io, fcport->vha, 0x3021,
1816 "Port down status: port-state=0x%x.\n", 1778 "Port down status: port-state=0x%x.\n",
1817 atomic_read(&fcport->state)); 1779 atomic_read(&fcport->state));
1818 1780
@@ -1821,25 +1783,25 @@ check_scsi_status:
1821 break; 1783 break;
1822 1784
1823 case CS_ABORTED: 1785 case CS_ABORTED:
1824 cp->result = DID_RESET << 16; 1786 res = DID_RESET << 16;
1825 break; 1787 break;
1826 1788
1827 case CS_DIF_ERROR: 1789 case CS_DIF_ERROR:
1828 logit = qla2x00_handle_dif_error(sp, sts24); 1790 logit = qla2x00_handle_dif_error(sp, sts24);
1829 break; 1791 break;
1830 default: 1792 default:
1831 cp->result = DID_ERROR << 16; 1793 res = DID_ERROR << 16;
1832 break; 1794 break;
1833 } 1795 }
1834 1796
1835out: 1797out:
1836 if (logit) 1798 if (logit)
1837 ql_dbg(ql_dbg_io, vha, 0x3022, 1799 ql_dbg(ql_dbg_io, fcport->vha, 0x3022,
1838 "FCP command status: 0x%x-0x%x (0x%x) " 1800 "FCP command status: 0x%x-0x%x (0x%x) "
1839 "nexus=%ld:%d:%d portid=%02x%02x%02x oxid=0x%x " 1801 "nexus=%ld:%d:%d portid=%02x%02x%02x oxid=0x%x "
1840 "cdb=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x len=0x%x " 1802 "cdb=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x len=0x%x "
1841 "rsp_info=0x%x resid=0x%x fw_resid=0x%x.\n", 1803 "rsp_info=0x%x resid=0x%x fw_resid=0x%x.\n",
1842 comp_status, scsi_status, cp->result, vha->host_no, 1804 comp_status, scsi_status, res, vha->host_no,
1843 cp->device->id, cp->device->lun, fcport->d_id.b.domain, 1805 cp->device->id, cp->device->lun, fcport->d_id.b.domain,
1844 fcport->d_id.b.area, fcport->d_id.b.al_pa, ox_id, 1806 fcport->d_id.b.area, fcport->d_id.b.al_pa, ox_id,
1845 cp->cmnd[0], cp->cmnd[1], cp->cmnd[2], cp->cmnd[3], 1807 cp->cmnd[0], cp->cmnd[1], cp->cmnd[2], cp->cmnd[3],
@@ -1848,7 +1810,7 @@ out:
1848 resid_len, fw_resid_len); 1810 resid_len, fw_resid_len);
1849 1811
1850 if (rsp->status_srb == NULL) 1812 if (rsp->status_srb == NULL)
1851 qla2x00_sp_compl(ha, sp); 1813 sp->done(ha, sp, res);
1852} 1814}
1853 1815
1854/** 1816/**
@@ -1861,84 +1823,52 @@ out:
1861static void 1823static void
1862qla2x00_status_cont_entry(struct rsp_que *rsp, sts_cont_entry_t *pkt) 1824qla2x00_status_cont_entry(struct rsp_que *rsp, sts_cont_entry_t *pkt)
1863{ 1825{
1864 uint8_t sense_sz = 0; 1826 uint8_t sense_sz = 0;
1865 struct qla_hw_data *ha = rsp->hw; 1827 struct qla_hw_data *ha = rsp->hw;
1866 struct scsi_qla_host *vha = pci_get_drvdata(ha->pdev); 1828 struct scsi_qla_host *vha = pci_get_drvdata(ha->pdev);
1867 srb_t *sp = rsp->status_srb; 1829 srb_t *sp = rsp->status_srb;
1868 struct scsi_cmnd *cp; 1830 struct scsi_cmnd *cp;
1831 uint32_t sense_len;
1832 uint8_t *sense_ptr;
1869 1833
1870 if (sp != NULL && sp->request_sense_length != 0) { 1834 if (!sp || !GET_CMD_SENSE_LEN(sp))
1871 cp = sp->cmd; 1835 return;
1872 if (cp == NULL) {
1873 ql_log(ql_log_warn, vha, 0x3025,
1874 "cmd is NULL: already returned to OS (sp=%p).\n",
1875 sp);
1876 1836
1877 rsp->status_srb = NULL; 1837 sense_len = GET_CMD_SENSE_LEN(sp);
1878 return; 1838 sense_ptr = GET_CMD_SENSE_PTR(sp);
1879 }
1880 1839
1881 if (sp->request_sense_length > sizeof(pkt->data)) { 1840 cp = GET_CMD_SP(sp);
1882 sense_sz = sizeof(pkt->data); 1841 if (cp == NULL) {
1883 } else { 1842 ql_log(ql_log_warn, vha, 0x3025,
1884 sense_sz = sp->request_sense_length; 1843 "cmd is NULL: already returned to OS (sp=%p).\n", sp);
1885 }
1886 1844
1887 /* Move sense data. */ 1845 rsp->status_srb = NULL;
1888 if (IS_FWI2_CAPABLE(ha)) 1846 return;
1889 host_to_fcp_swap(pkt->data, sizeof(pkt->data));
1890 memcpy(sp->request_sense_ptr, pkt->data, sense_sz);
1891 ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x302c,
1892 sp->request_sense_ptr, sense_sz);
1893
1894 sp->request_sense_ptr += sense_sz;
1895 sp->request_sense_length -= sense_sz;
1896
1897 /* Place command on done queue. */
1898 if (sp->request_sense_length == 0) {
1899 rsp->status_srb = NULL;
1900 qla2x00_sp_compl(ha, sp);
1901 }
1902 } 1847 }
1903}
1904 1848
1905static int 1849 if (sense_len > sizeof(pkt->data))
1906qla2x00_free_sp_ctx(scsi_qla_host_t *vha, srb_t *sp) 1850 sense_sz = sizeof(pkt->data);
1907{ 1851 else
1908 struct qla_hw_data *ha = vha->hw; 1852 sense_sz = sense_len;
1909 struct srb_ctx *ctx;
1910 1853
1911 if (!sp->ctx) 1854 /* Move sense data. */
1912 return 1; 1855 if (IS_FWI2_CAPABLE(ha))
1856 host_to_fcp_swap(pkt->data, sizeof(pkt->data));
1857 memcpy(sense_ptr, pkt->data, sense_sz);
1858 ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x302c,
1859 sense_ptr, sense_sz);
1913 1860
1914 ctx = sp->ctx; 1861 sense_len -= sense_sz;
1862 sense_ptr += sense_sz;
1915 1863
1916 if (ctx->type == SRB_LOGIN_CMD || 1864 SET_CMD_SENSE_PTR(sp, sense_ptr);
1917 ctx->type == SRB_LOGOUT_CMD || 1865 SET_CMD_SENSE_LEN(sp, sense_len);
1918 ctx->type == SRB_TM_CMD) { 1866
1919 ctx->u.iocb_cmd->done(sp); 1867 /* Place command on done queue. */
1920 return 0; 1868 if (sense_len == 0) {
1921 } else if (ctx->type == SRB_ADISC_CMD) { 1869 rsp->status_srb = NULL;
1922 ctx->u.iocb_cmd->free(sp); 1870 sp->done(ha, sp, cp->result);
1923 return 0;
1924 } else {
1925 struct fc_bsg_job *bsg_job;
1926
1927 bsg_job = ctx->u.bsg_job;
1928 if (ctx->type == SRB_ELS_CMD_HST ||
1929 ctx->type == SRB_CT_CMD)
1930 kfree(sp->fcport);
1931
1932 bsg_job->reply->reply_data.ctels_reply.status =
1933 FC_CTELS_STATUS_OK;
1934 bsg_job->reply->result = DID_ERROR << 16;
1935 bsg_job->reply->reply_payload_rcv_len = 0;
1936 kfree(sp->ctx);
1937 mempool_free(sp, ha->srb_mempool);
1938 bsg_job->job_done(bsg_job);
1939 return 0;
1940 } 1871 }
1941 return 1;
1942} 1872}
1943 1873
1944/** 1874/**
@@ -1953,53 +1883,34 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
1953 struct qla_hw_data *ha = vha->hw; 1883 struct qla_hw_data *ha = vha->hw;
1954 const char func[] = "ERROR-IOCB"; 1884 const char func[] = "ERROR-IOCB";
1955 uint16_t que = MSW(pkt->handle); 1885 uint16_t que = MSW(pkt->handle);
1956 struct req_que *req = ha->req_q_map[que]; 1886 struct req_que *req = NULL;
1957 1887 int res = DID_ERROR << 16;
1958 if (pkt->entry_status & RF_INV_E_ORDER) 1888
1959 ql_dbg(ql_dbg_async, vha, 0x502a, 1889 ql_dbg(ql_dbg_async, vha, 0x502a,
1960 "Invalid Entry Order.\n"); 1890 "type of error status in response: 0x%x\n", pkt->entry_status);
1961 else if (pkt->entry_status & RF_INV_E_COUNT) 1891
1962 ql_dbg(ql_dbg_async, vha, 0x502b, 1892 if (que >= ha->max_req_queues || !ha->req_q_map[que])
1963 "Invalid Entry Count.\n"); 1893 goto fatal;
1964 else if (pkt->entry_status & RF_INV_E_PARAM) 1894
1965 ql_dbg(ql_dbg_async, vha, 0x502c, 1895 req = ha->req_q_map[que];
1966 "Invalid Entry Parameter.\n"); 1896
1967 else if (pkt->entry_status & RF_INV_E_TYPE) 1897 if (pkt->entry_status & RF_BUSY)
1968 ql_dbg(ql_dbg_async, vha, 0x502d, 1898 res = DID_BUS_BUSY << 16;
1969 "Invalid Entry Type.\n");
1970 else if (pkt->entry_status & RF_BUSY)
1971 ql_dbg(ql_dbg_async, vha, 0x502e,
1972 "Busy.\n");
1973 else
1974 ql_dbg(ql_dbg_async, vha, 0x502f,
1975 "UNKNOWN flag error.\n");
1976 1899
1977 sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); 1900 sp = qla2x00_get_sp_from_handle(vha, func, req, pkt);
1978 if (sp) { 1901 if (sp) {
1979 if (qla2x00_free_sp_ctx(vha, sp)) { 1902 sp->done(ha, sp, res);
1980 if (pkt->entry_status & 1903 return;
1981 (RF_INV_E_ORDER | RF_INV_E_COUNT |
1982 RF_INV_E_PARAM | RF_INV_E_TYPE)) {
1983 sp->cmd->result = DID_ERROR << 16;
1984 } else if (pkt->entry_status & RF_BUSY) {
1985 sp->cmd->result = DID_BUS_BUSY << 16;
1986 } else {
1987 sp->cmd->result = DID_ERROR << 16;
1988 }
1989 qla2x00_sp_compl(ha, sp);
1990 }
1991 } else if (pkt->entry_type == COMMAND_A64_TYPE || pkt->entry_type ==
1992 COMMAND_TYPE || pkt->entry_type == COMMAND_TYPE_7
1993 || pkt->entry_type == COMMAND_TYPE_6) {
1994 ql_log(ql_log_warn, vha, 0x5030,
1995 "Error entry - invalid handle.\n");
1996
1997 if (IS_QLA82XX(ha))
1998 set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags);
1999 else
2000 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
2001 qla2xxx_wake_dpc(vha);
2002 } 1904 }
1905fatal:
1906 ql_log(ql_log_warn, vha, 0x5030,
1907 "Error entry - invalid handle/queue.\n");
1908
1909 if (IS_QLA82XX(ha))
1910 set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags);
1911 else
1912 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
1913 qla2xxx_wake_dpc(vha);
2003} 1914}
2004 1915
2005/** 1916/**
@@ -2127,7 +2038,7 @@ qla2xxx_check_risc_status(scsi_qla_host_t *vha)
2127 struct qla_hw_data *ha = vha->hw; 2038 struct qla_hw_data *ha = vha->hw;
2128 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 2039 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
2129 2040
2130 if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)) 2041 if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha))
2131 return; 2042 return;
2132 2043
2133 rval = QLA_SUCCESS; 2044 rval = QLA_SUCCESS;
@@ -2168,7 +2079,7 @@ done:
2168} 2079}
2169 2080
2170/** 2081/**
2171 * qla24xx_intr_handler() - Process interrupts for the ISP23xx and ISP63xx. 2082 * qla24xx_intr_handler() - Process interrupts for the ISP23xx and ISP24xx.
2172 * @irq: 2083 * @irq:
2173 * @dev_id: SCSI driver HA context 2084 * @dev_id: SCSI driver HA context
2174 * 2085 *
@@ -2192,8 +2103,8 @@ qla24xx_intr_handler(int irq, void *dev_id)
2192 2103
2193 rsp = (struct rsp_que *) dev_id; 2104 rsp = (struct rsp_que *) dev_id;
2194 if (!rsp) { 2105 if (!rsp) {
2195 printk(KERN_INFO 2106 ql_log(ql_log_info, NULL, 0x5059,
2196 "%s(): NULL response queue pointer.\n", __func__); 2107 "%s: NULL response queue pointer.\n", __func__);
2197 return IRQ_NONE; 2108 return IRQ_NONE;
2198 } 2109 }
2199 2110
@@ -2276,8 +2187,8 @@ qla24xx_msix_rsp_q(int irq, void *dev_id)
2276 2187
2277 rsp = (struct rsp_que *) dev_id; 2188 rsp = (struct rsp_que *) dev_id;
2278 if (!rsp) { 2189 if (!rsp) {
2279 printk(KERN_INFO 2190 ql_log(ql_log_info, NULL, 0x505a,
2280 "%s(): NULL response queue pointer.\n", __func__); 2191 "%s: NULL response queue pointer.\n", __func__);
2281 return IRQ_NONE; 2192 return IRQ_NONE;
2282 } 2193 }
2283 ha = rsp->hw; 2194 ha = rsp->hw;
@@ -2306,8 +2217,8 @@ qla25xx_msix_rsp_q(int irq, void *dev_id)
2306 2217
2307 rsp = (struct rsp_que *) dev_id; 2218 rsp = (struct rsp_que *) dev_id;
2308 if (!rsp) { 2219 if (!rsp) {
2309 printk(KERN_INFO 2220 ql_log(ql_log_info, NULL, 0x505b,
2310 "%s(): NULL response queue pointer.\n", __func__); 2221 "%s: NULL response queue pointer.\n", __func__);
2311 return IRQ_NONE; 2222 return IRQ_NONE;
2312 } 2223 }
2313 ha = rsp->hw; 2224 ha = rsp->hw;
@@ -2340,8 +2251,8 @@ qla24xx_msix_default(int irq, void *dev_id)
2340 2251
2341 rsp = (struct rsp_que *) dev_id; 2252 rsp = (struct rsp_que *) dev_id;
2342 if (!rsp) { 2253 if (!rsp) {
2343 printk(KERN_INFO 2254 ql_log(ql_log_info, NULL, 0x505c,
2344 "%s(): NULL response queue pointer.\n", __func__); 2255 "%s: NULL response queue pointer.\n", __func__);
2345 return IRQ_NONE; 2256 return IRQ_NONE;
2346 } 2257 }
2347 ha = rsp->hw; 2258 ha = rsp->hw;
@@ -2530,8 +2441,14 @@ msix_failed:
2530 } 2441 }
2531 2442
2532 /* Enable MSI-X vector for response queue update for queue 0 */ 2443 /* Enable MSI-X vector for response queue update for queue 0 */
2533 if (ha->mqiobase && (ha->max_rsp_queues > 1 || ha->max_req_queues > 1)) 2444 if (IS_QLA83XX(ha)) {
2534 ha->mqenable = 1; 2445 if (ha->msixbase && ha->mqiobase &&
2446 (ha->max_rsp_queues > 1 || ha->max_req_queues > 1))
2447 ha->mqenable = 1;
2448 } else
2449 if (ha->mqiobase
2450 && (ha->max_rsp_queues > 1 || ha->max_req_queues > 1))
2451 ha->mqenable = 1;
2535 ql_dbg(ql_dbg_multiq, vha, 0xc005, 2452 ql_dbg(ql_dbg_multiq, vha, 0xc005,
2536 "mqiobase=%p, max_rsp_queues=%d, max_req_queues=%d.\n", 2453 "mqiobase=%p, max_rsp_queues=%d, max_req_queues=%d.\n",
2537 ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues); 2454 ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues);
@@ -2552,8 +2469,8 @@ qla2x00_request_irqs(struct qla_hw_data *ha, struct rsp_que *rsp)
2552 scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); 2469 scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
2553 2470
2554 /* If possible, enable MSI-X. */ 2471 /* If possible, enable MSI-X. */
2555 if (!IS_QLA2432(ha) && !IS_QLA2532(ha) && 2472 if (!IS_QLA2432(ha) && !IS_QLA2532(ha) && !IS_QLA8432(ha) &&
2556 !IS_QLA8432(ha) && !IS_QLA8XXX_TYPE(ha)) 2473 !IS_CNA_CAPABLE(ha) && !IS_QLA2031(ha))
2557 goto skip_msi; 2474 goto skip_msi;
2558 2475
2559 if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP && 2476 if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP &&
@@ -2615,7 +2532,7 @@ clear_risc_ints:
2615 * FIXME: Noted that 8014s were being dropped during NK testing. 2532 * FIXME: Noted that 8014s were being dropped during NK testing.
2616 * Timing deltas during MSI-X/INTa transitions? 2533 * Timing deltas during MSI-X/INTa transitions?
2617 */ 2534 */
2618 if (IS_QLA81XX(ha) || IS_QLA82XX(ha)) 2535 if (IS_QLA81XX(ha) || IS_QLA82XX(ha) || IS_QLA83XX(ha))
2619 goto fail; 2536 goto fail;
2620 spin_lock_irq(&ha->hardware_lock); 2537 spin_lock_irq(&ha->hardware_lock);
2621 if (IS_FWI2_CAPABLE(ha)) { 2538 if (IS_FWI2_CAPABLE(ha)) {