.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * qla_target.c SCSI LLD infrastructure for QLogic 22xx/23xx/24xx/25xx |
---|
3 | 4 | * |
---|
.. | .. |
---|
11 | 12 | * Forward port and refactoring to modern qla2xxx and target/configfs |
---|
12 | 13 | * |
---|
13 | 14 | * Copyright (C) 2010-2013 Nicholas A. Bellinger <nab@kernel.org> |
---|
14 | | - * |
---|
15 | | - * This program is free software; you can redistribute it and/or |
---|
16 | | - * modify it under the terms of the GNU General Public License |
---|
17 | | - * as published by the Free Software Foundation, version 2 |
---|
18 | | - * of the License. |
---|
19 | | - * |
---|
20 | | - * This program is distributed in the hope that it will be useful, |
---|
21 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
22 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
23 | | - * GNU General Public License for more details. |
---|
24 | 15 | */ |
---|
25 | 16 | |
---|
26 | 17 | #include <linux/module.h> |
---|
.. | .. |
---|
36 | 27 | #include <scsi/scsi.h> |
---|
37 | 28 | #include <scsi/scsi_host.h> |
---|
38 | 29 | #include <scsi/scsi_tcq.h> |
---|
39 | | -#include <target/target_core_base.h> |
---|
40 | | -#include <target/target_core_fabric.h> |
---|
41 | 30 | |
---|
42 | 31 | #include "qla_def.h" |
---|
43 | 32 | #include "qla_target.h" |
---|
.. | .. |
---|
141 | 130 | struct abts_recv_from_24xx *); |
---|
142 | 131 | static void qlt_send_busy(struct qla_qpair *, struct atio_from_isp *, |
---|
143 | 132 | uint16_t); |
---|
| 133 | +static int qlt_check_reserve_free_req(struct qla_qpair *qpair, uint32_t); |
---|
| 134 | +static inline uint32_t qlt_make_handle(struct qla_qpair *); |
---|
144 | 135 | |
---|
145 | 136 | /* |
---|
146 | 137 | * Global Variables |
---|
.. | .. |
---|
182 | 173 | /* Send marker if required */ |
---|
183 | 174 | if (unlikely(vha->marker_needed != 0)) { |
---|
184 | 175 | int rc = qla2x00_issue_marker(vha, vha_locked); |
---|
| 176 | + |
---|
185 | 177 | if (rc != QLA_SUCCESS) { |
---|
186 | 178 | ql_dbg(ql_dbg_tgt, vha, 0xe03d, |
---|
187 | 179 | "qla_target(%d): issue_marker() failed\n", |
---|
.. | .. |
---|
194 | 186 | |
---|
195 | 187 | static inline |
---|
196 | 188 | struct scsi_qla_host *qlt_find_host_by_d_id(struct scsi_qla_host *vha, |
---|
197 | | - uint8_t *d_id) |
---|
| 189 | + be_id_t d_id) |
---|
198 | 190 | { |
---|
199 | 191 | struct scsi_qla_host *host; |
---|
200 | | - uint32_t key = 0; |
---|
| 192 | + uint32_t key; |
---|
201 | 193 | |
---|
202 | | - if ((vha->d_id.b.area == d_id[1]) && (vha->d_id.b.domain == d_id[0]) && |
---|
203 | | - (vha->d_id.b.al_pa == d_id[2])) |
---|
| 194 | + if (vha->d_id.b.area == d_id.area && |
---|
| 195 | + vha->d_id.b.domain == d_id.domain && |
---|
| 196 | + vha->d_id.b.al_pa == d_id.al_pa) |
---|
204 | 197 | return vha; |
---|
205 | 198 | |
---|
206 | | - key = (uint32_t)d_id[0] << 16; |
---|
207 | | - key |= (uint32_t)d_id[1] << 8; |
---|
208 | | - key |= (uint32_t)d_id[2]; |
---|
| 199 | + key = be_to_port_id(d_id).b24; |
---|
209 | 200 | |
---|
210 | 201 | host = btree_lookup32(&vha->hw->tgt.host_map, key); |
---|
211 | 202 | if (!host) |
---|
.. | .. |
---|
363 | 354 | ql_dbg(ql_dbg_tgt, vha, 0xe03e, |
---|
364 | 355 | "qla_target(%d): Received ATIO_TYPE7 " |
---|
365 | 356 | "with unknown d_id %x:%x:%x\n", vha->vp_idx, |
---|
366 | | - atio->u.isp24.fcp_hdr.d_id[0], |
---|
367 | | - atio->u.isp24.fcp_hdr.d_id[1], |
---|
368 | | - atio->u.isp24.fcp_hdr.d_id[2]); |
---|
| 357 | + atio->u.isp24.fcp_hdr.d_id.domain, |
---|
| 358 | + atio->u.isp24.fcp_hdr.d_id.area, |
---|
| 359 | + atio->u.isp24.fcp_hdr.d_id.al_pa); |
---|
369 | 360 | |
---|
370 | 361 | |
---|
371 | 362 | qlt_queue_unknown_atio(vha, atio, ha_locked); |
---|
.. | .. |
---|
387 | 378 | qlt_issue_marker(vha, ha_locked); |
---|
388 | 379 | |
---|
389 | 380 | if ((entry->u.isp24.vp_index != 0xFF) && |
---|
390 | | - (entry->u.isp24.nport_handle != 0xFFFF)) { |
---|
| 381 | + (entry->u.isp24.nport_handle != cpu_to_le16(0xFFFF))) { |
---|
391 | 382 | host = qlt_find_host_by_vp_idx(vha, |
---|
392 | 383 | entry->u.isp24.vp_index); |
---|
393 | 384 | if (unlikely(!host)) { |
---|
.. | .. |
---|
451 | 442 | ql_dbg(ql_dbg_tgt, vha, 0xe073, |
---|
452 | 443 | "qla_target(%d):%s: CRC2 Response pkt\n", |
---|
453 | 444 | vha->vp_idx, __func__); |
---|
454 | | - /* fall through */ |
---|
| 445 | + fallthrough; |
---|
455 | 446 | case CTIO_TYPE7: |
---|
456 | 447 | { |
---|
457 | 448 | struct ctio7_from_24xx *entry = (struct ctio7_from_24xx *)pkt; |
---|
.. | .. |
---|
470 | 461 | |
---|
471 | 462 | case IMMED_NOTIFY_TYPE: |
---|
472 | 463 | { |
---|
473 | | - struct scsi_qla_host *host = vha; |
---|
| 464 | + struct scsi_qla_host *host; |
---|
474 | 465 | struct imm_ntfy_from_isp *entry = |
---|
475 | 466 | (struct imm_ntfy_from_isp *)pkt; |
---|
476 | 467 | |
---|
.. | .. |
---|
541 | 532 | qlt_response_pkt(host, rsp, pkt); |
---|
542 | 533 | break; |
---|
543 | 534 | } |
---|
544 | | - |
---|
545 | 535 | default: |
---|
546 | 536 | qlt_response_pkt(vha, rsp, pkt); |
---|
547 | 537 | break; |
---|
.. | .. |
---|
556 | 546 | struct imm_ntfy_from_isp *ntfy, int type) |
---|
557 | 547 | { |
---|
558 | 548 | struct qla_work_evt *e; |
---|
| 549 | + |
---|
559 | 550 | e = qla2x00_alloc_work(vha, QLA_EVT_NACK); |
---|
560 | 551 | if (!e) |
---|
561 | 552 | return QLA_FUNCTION_FAILED; |
---|
.. | .. |
---|
566 | 557 | return qla2x00_post_work(vha, e); |
---|
567 | 558 | } |
---|
568 | 559 | |
---|
569 | | -static |
---|
570 | | -void qla2x00_async_nack_sp_done(void *s, int res) |
---|
| 560 | +static void qla2x00_async_nack_sp_done(srb_t *sp, int res) |
---|
571 | 561 | { |
---|
572 | | - struct srb *sp = (struct srb *)s; |
---|
573 | 562 | struct scsi_qla_host *vha = sp->vha; |
---|
574 | 563 | unsigned long flags; |
---|
575 | 564 | |
---|
.. | .. |
---|
605 | 594 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
---|
606 | 595 | } else { |
---|
607 | 596 | sp->fcport->login_retry = 0; |
---|
608 | | - sp->fcport->disc_state = DSC_LOGIN_COMPLETE; |
---|
| 597 | + qla2x00_set_fcport_disc_state(sp->fcport, |
---|
| 598 | + DSC_LOGIN_COMPLETE); |
---|
609 | 599 | sp->fcport->deleted = 0; |
---|
610 | 600 | sp->fcport->logout_on_delete = 1; |
---|
611 | 601 | } |
---|
.. | .. |
---|
659 | 649 | sp->u.iocb_cmd.u.nack.ntfy = ntfy; |
---|
660 | 650 | sp->done = qla2x00_async_nack_sp_done; |
---|
661 | 651 | |
---|
662 | | - rval = qla2x00_start_sp(sp); |
---|
663 | | - if (rval != QLA_SUCCESS) |
---|
664 | | - goto done_free_sp; |
---|
665 | | - |
---|
666 | 652 | ql_dbg(ql_dbg_disc, vha, 0x20f4, |
---|
667 | 653 | "Async-%s %8phC hndl %x %s\n", |
---|
668 | 654 | sp->name, fcport->port_name, sp->handle, c); |
---|
| 655 | + |
---|
| 656 | + rval = qla2x00_start_sp(sp); |
---|
| 657 | + if (rval != QLA_SUCCESS) |
---|
| 658 | + goto done_free_sp; |
---|
669 | 659 | |
---|
670 | 660 | return rval; |
---|
671 | 661 | |
---|
.. | .. |
---|
682 | 672 | |
---|
683 | 673 | switch (e->u.nack.type) { |
---|
684 | 674 | case SRB_NACK_PRLI: |
---|
| 675 | + t = e->u.nack.fcport; |
---|
| 676 | + flush_work(&t->del_work); |
---|
| 677 | + flush_work(&t->free_work); |
---|
685 | 678 | mutex_lock(&vha->vha_tgt.tgt_mutex); |
---|
686 | 679 | t = qlt_create_sess(vha, e->u.nack.fcport, 0); |
---|
687 | 680 | mutex_unlock(&vha->vha_tgt.tgt_mutex); |
---|
.. | .. |
---|
694 | 687 | break; |
---|
695 | 688 | } |
---|
696 | 689 | qla24xx_async_notify_ack(vha, e->u.nack.fcport, |
---|
697 | | - (struct imm_ntfy_from_isp*)e->u.nack.iocb, e->u.nack.type); |
---|
| 690 | + (struct imm_ntfy_from_isp *)e->u.nack.iocb, e->u.nack.type); |
---|
698 | 691 | } |
---|
699 | 692 | |
---|
700 | 693 | void qla24xx_delete_sess_fn(struct work_struct *work) |
---|
.. | .. |
---|
791 | 784 | struct imm_ntfy_from_isp *iocb) |
---|
792 | 785 | { |
---|
793 | 786 | struct qlt_plogi_ack_t *pla; |
---|
| 787 | + |
---|
| 788 | + lockdep_assert_held(&vha->hw->hardware_lock); |
---|
794 | 789 | |
---|
795 | 790 | list_for_each_entry(pla, &vha->plogi_ack_list, list) { |
---|
796 | 791 | if (pla->id.b24 == id->b24) { |
---|
.. | .. |
---|
957 | 952 | struct qla_hw_data *ha = vha->hw; |
---|
958 | 953 | unsigned long flags; |
---|
959 | 954 | bool logout_started = false; |
---|
960 | | - scsi_qla_host_t *base_vha; |
---|
| 955 | + scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
---|
961 | 956 | struct qlt_plogi_ack_t *own = |
---|
962 | 957 | sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN]; |
---|
963 | 958 | |
---|
964 | | - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf084, |
---|
| 959 | + ql_dbg(ql_dbg_disc, vha, 0xf084, |
---|
965 | 960 | "%s: se_sess %p / sess %p from port %8phC loop_id %#04x" |
---|
966 | 961 | " s_id %02x:%02x:%02x logout %d keep %d els_logo %d\n", |
---|
967 | 962 | __func__, sess->se_sess, sess, sess->port_name, sess->loop_id, |
---|
.. | .. |
---|
970 | 965 | sess->send_els_logo); |
---|
971 | 966 | |
---|
972 | 967 | if (!IS_SW_RESV_ADDR(sess->d_id)) { |
---|
973 | | - qla2x00_mark_device_lost(vha, sess, 0, 0); |
---|
| 968 | + qla2x00_mark_device_lost(vha, sess, 0); |
---|
974 | 969 | |
---|
975 | 970 | if (sess->send_els_logo) { |
---|
976 | 971 | qlt_port_logo_t logo; |
---|
.. | .. |
---|
1007 | 1002 | else |
---|
1008 | 1003 | logout_started = true; |
---|
1009 | 1004 | } |
---|
| 1005 | + } /* if sess->logout_on_delete */ |
---|
| 1006 | + |
---|
| 1007 | + if (sess->nvme_flag & NVME_FLAG_REGISTERED && |
---|
| 1008 | + !(sess->nvme_flag & NVME_FLAG_DELETING)) { |
---|
| 1009 | + sess->nvme_flag |= NVME_FLAG_DELETING; |
---|
| 1010 | + qla_nvme_unregister_remote_port(sess); |
---|
1010 | 1011 | } |
---|
1011 | 1012 | } |
---|
1012 | 1013 | |
---|
.. | .. |
---|
1022 | 1023 | |
---|
1023 | 1024 | while (!READ_ONCE(sess->logout_completed)) { |
---|
1024 | 1025 | if (!traced) { |
---|
1025 | | - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf086, |
---|
| 1026 | + ql_dbg(ql_dbg_disc, vha, 0xf086, |
---|
1026 | 1027 | "%s: waiting for sess %p logout\n", |
---|
1027 | 1028 | __func__, sess); |
---|
1028 | 1029 | traced = true; |
---|
.. | .. |
---|
1050 | 1051 | tgt->sess_count--; |
---|
1051 | 1052 | } |
---|
1052 | 1053 | |
---|
1053 | | - sess->disc_state = DSC_DELETED; |
---|
| 1054 | + qla2x00_set_fcport_disc_state(sess, DSC_DELETED); |
---|
1054 | 1055 | sess->fw_login_state = DSC_LS_PORT_UNAVAIL; |
---|
1055 | | - sess->deleted = QLA_SESS_DELETED; |
---|
1056 | 1056 | |
---|
1057 | 1057 | if (sess->login_succ && !IS_SW_RESV_ADDR(sess->d_id)) { |
---|
1058 | 1058 | vha->fcport_count--; |
---|
.. | .. |
---|
1072 | 1072 | struct qlt_plogi_ack_t *con = |
---|
1073 | 1073 | sess->plogi_link[QLT_PLOGI_LINK_CONFLICT]; |
---|
1074 | 1074 | struct imm_ntfy_from_isp *iocb; |
---|
| 1075 | + |
---|
1075 | 1076 | own = sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN]; |
---|
1076 | 1077 | |
---|
1077 | 1078 | if (con) { |
---|
.. | .. |
---|
1101 | 1102 | } |
---|
1102 | 1103 | } |
---|
1103 | 1104 | |
---|
| 1105 | + sess->explicit_logout = 0; |
---|
1104 | 1106 | spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); |
---|
1105 | 1107 | |
---|
1106 | | - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf001, |
---|
| 1108 | + qla2x00_dfs_remove_rport(vha, sess); |
---|
| 1109 | + |
---|
| 1110 | + spin_lock_irqsave(&vha->work_lock, flags); |
---|
| 1111 | + sess->flags &= ~FCF_ASYNC_SENT; |
---|
| 1112 | + sess->deleted = QLA_SESS_DELETED; |
---|
| 1113 | + sess->free_pending = 0; |
---|
| 1114 | + spin_unlock_irqrestore(&vha->work_lock, flags); |
---|
| 1115 | + |
---|
| 1116 | + ql_dbg(ql_dbg_disc, vha, 0xf001, |
---|
1107 | 1117 | "Unregistration of sess %p %8phC finished fcp_cnt %d\n", |
---|
1108 | 1118 | sess, sess->port_name, vha->fcport_count); |
---|
1109 | 1119 | |
---|
1110 | 1120 | if (tgt && (tgt->sess_count == 0)) |
---|
1111 | 1121 | wake_up_all(&tgt->waitQ); |
---|
1112 | 1122 | |
---|
1113 | | - if (vha->fcport_count == 0) |
---|
1114 | | - wake_up_all(&vha->fcport_waitQ); |
---|
1115 | | - |
---|
1116 | | - base_vha = pci_get_drvdata(ha->pdev); |
---|
1117 | | - |
---|
1118 | | - sess->free_pending = 0; |
---|
1119 | | - |
---|
1120 | | - if (test_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags)) |
---|
1121 | | - return; |
---|
1122 | | - |
---|
1123 | | - if ((!tgt || !tgt->tgt_stop) && !LOOP_TRANSITION(vha)) { |
---|
| 1123 | + if (!test_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags) && |
---|
| 1124 | + !(vha->vp_idx && test_bit(VPORT_DELETE, &vha->dpc_flags)) && |
---|
| 1125 | + (!tgt || !tgt->tgt_stop) && !LOOP_TRANSITION(vha)) { |
---|
1124 | 1126 | switch (vha->host->active_mode) { |
---|
1125 | 1127 | case MODE_INITIATOR: |
---|
1126 | 1128 | case MODE_DUAL: |
---|
.. | .. |
---|
1133 | 1135 | break; |
---|
1134 | 1136 | } |
---|
1135 | 1137 | } |
---|
| 1138 | + |
---|
| 1139 | + if (vha->fcport_count == 0) |
---|
| 1140 | + wake_up_all(&vha->fcport_waitQ); |
---|
1136 | 1141 | } |
---|
1137 | 1142 | |
---|
1138 | 1143 | /* ha->tgt.sess_lock supposed to be held on entry */ |
---|
.. | .. |
---|
1151 | 1156 | return; |
---|
1152 | 1157 | } |
---|
1153 | 1158 | sess->free_pending = 1; |
---|
| 1159 | + /* |
---|
| 1160 | + * Use FCF_ASYNC_SENT flag to block other cmds used in sess |
---|
| 1161 | + * management from being sent. |
---|
| 1162 | + */ |
---|
| 1163 | + sess->flags |= FCF_ASYNC_SENT; |
---|
| 1164 | + sess->deleted = QLA_SESS_DELETION_IN_PROGRESS; |
---|
1154 | 1165 | spin_unlock_irqrestore(&sess->vha->work_lock, flags); |
---|
1155 | 1166 | |
---|
1156 | 1167 | if (sess->se_sess) |
---|
1157 | 1168 | vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess); |
---|
1158 | 1169 | |
---|
1159 | | - sess->deleted = QLA_SESS_DELETION_IN_PROGRESS; |
---|
1160 | | - sess->disc_state = DSC_DELETE_PEND; |
---|
| 1170 | + qla2x00_set_fcport_disc_state(sess, DSC_DELETE_PEND); |
---|
1161 | 1171 | sess->last_rscn_gen = sess->rscn_gen; |
---|
1162 | 1172 | sess->last_login_gen = sess->login_gen; |
---|
1163 | 1173 | |
---|
1164 | | - if (sess->nvme_flag & NVME_FLAG_REGISTERED && |
---|
1165 | | - !(sess->nvme_flag & NVME_FLAG_DELETING)) { |
---|
1166 | | - sess->nvme_flag |= NVME_FLAG_DELETING; |
---|
1167 | | - schedule_work(&sess->nvme_del_work); |
---|
1168 | | - } else { |
---|
1169 | | - INIT_WORK(&sess->free_work, qlt_free_session_done); |
---|
1170 | | - schedule_work(&sess->free_work); |
---|
1171 | | - } |
---|
| 1174 | + queue_work(sess->vha->hw->wq, &sess->free_work); |
---|
1172 | 1175 | } |
---|
1173 | 1176 | EXPORT_SYMBOL(qlt_unreg_sess); |
---|
1174 | 1177 | |
---|
.. | .. |
---|
1257 | 1260 | break; |
---|
1258 | 1261 | } |
---|
1259 | 1262 | |
---|
1260 | | - if (sess->deleted == QLA_SESS_DELETED) |
---|
1261 | | - sess->logout_on_delete = 0; |
---|
1262 | | - |
---|
1263 | 1263 | spin_lock_irqsave(&sess->vha->work_lock, flags); |
---|
1264 | 1264 | if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) { |
---|
1265 | 1265 | spin_unlock_irqrestore(&sess->vha->work_lock, flags); |
---|
.. | .. |
---|
1268 | 1268 | sess->deleted = QLA_SESS_DELETION_IN_PROGRESS; |
---|
1269 | 1269 | spin_unlock_irqrestore(&sess->vha->work_lock, flags); |
---|
1270 | 1270 | |
---|
1271 | | - sess->disc_state = DSC_DELETE_PEND; |
---|
| 1271 | + sess->prli_pend_timer = 0; |
---|
| 1272 | + qla2x00_set_fcport_disc_state(sess, DSC_DELETE_PEND); |
---|
1272 | 1273 | |
---|
1273 | 1274 | qla24xx_chk_fcp_state(sess); |
---|
1274 | 1275 | |
---|
1275 | | - ql_dbg(ql_dbg_tgt, sess->vha, 0xe001, |
---|
| 1276 | + ql_dbg(ql_dbg_disc, sess->vha, 0xe001, |
---|
1276 | 1277 | "Scheduling sess %p for deletion %8phC\n", |
---|
1277 | 1278 | sess, sess->port_name); |
---|
1278 | 1279 | |
---|
.. | .. |
---|
1292 | 1293 | /* At this point tgt could be already dead */ |
---|
1293 | 1294 | } |
---|
1294 | 1295 | |
---|
1295 | | -static int qla24xx_get_loop_id(struct scsi_qla_host *vha, const uint8_t *s_id, |
---|
| 1296 | +static int qla24xx_get_loop_id(struct scsi_qla_host *vha, be_id_t s_id, |
---|
1296 | 1297 | uint16_t *loop_id) |
---|
1297 | 1298 | { |
---|
1298 | 1299 | struct qla_hw_data *ha = vha->hw; |
---|
1299 | 1300 | dma_addr_t gid_list_dma; |
---|
1300 | | - struct gid_list_info *gid_list; |
---|
1301 | | - char *id_iter; |
---|
| 1301 | + struct gid_list_info *gid_list, *gid; |
---|
1302 | 1302 | int res, rc, i; |
---|
1303 | 1303 | uint16_t entries; |
---|
1304 | 1304 | |
---|
.. | .. |
---|
1321 | 1321 | goto out_free_id_list; |
---|
1322 | 1322 | } |
---|
1323 | 1323 | |
---|
1324 | | - id_iter = (char *)gid_list; |
---|
| 1324 | + gid = gid_list; |
---|
1325 | 1325 | res = -ENOENT; |
---|
1326 | 1326 | for (i = 0; i < entries; i++) { |
---|
1327 | | - struct gid_list_info *gid = (struct gid_list_info *)id_iter; |
---|
1328 | | - if ((gid->al_pa == s_id[2]) && |
---|
1329 | | - (gid->area == s_id[1]) && |
---|
1330 | | - (gid->domain == s_id[0])) { |
---|
| 1327 | + if (gid->al_pa == s_id.al_pa && |
---|
| 1328 | + gid->area == s_id.area && |
---|
| 1329 | + gid->domain == s_id.domain) { |
---|
1331 | 1330 | *loop_id = le16_to_cpu(gid->loop_id); |
---|
1332 | 1331 | res = 0; |
---|
1333 | 1332 | break; |
---|
1334 | 1333 | } |
---|
1335 | | - id_iter += ha->gid_list_info_size; |
---|
| 1334 | + gid = (void *)gid + ha->gid_list_info_size; |
---|
1336 | 1335 | } |
---|
1337 | 1336 | |
---|
1338 | 1337 | out_free_id_list: |
---|
.. | .. |
---|
1491 | 1490 | struct qla_hw_data *ha = tgt->ha; |
---|
1492 | 1491 | unsigned long flags; |
---|
1493 | 1492 | |
---|
| 1493 | + mutex_lock(&ha->optrom_mutex); |
---|
1494 | 1494 | mutex_lock(&qla_tgt_mutex); |
---|
1495 | | - if (!vha->fc_vport) { |
---|
1496 | | - struct Scsi_Host *sh = vha->host; |
---|
1497 | | - struct fc_host_attrs *fc_host = shost_to_fc_host(sh); |
---|
1498 | | - bool npiv_vports; |
---|
1499 | 1495 | |
---|
1500 | | - spin_lock_irqsave(sh->host_lock, flags); |
---|
1501 | | - npiv_vports = (fc_host->npiv_vports_inuse); |
---|
1502 | | - spin_unlock_irqrestore(sh->host_lock, flags); |
---|
1503 | | - |
---|
1504 | | - if (npiv_vports) { |
---|
1505 | | - mutex_unlock(&qla_tgt_mutex); |
---|
1506 | | - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf021, |
---|
1507 | | - "NPIV is in use. Can not stop target\n"); |
---|
1508 | | - return -EPERM; |
---|
1509 | | - } |
---|
1510 | | - } |
---|
1511 | 1496 | if (tgt->tgt_stop || tgt->tgt_stopped) { |
---|
1512 | 1497 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf04e, |
---|
1513 | 1498 | "Already in tgt->tgt_stop or tgt_stopped state\n"); |
---|
1514 | 1499 | mutex_unlock(&qla_tgt_mutex); |
---|
| 1500 | + mutex_unlock(&ha->optrom_mutex); |
---|
1515 | 1501 | return -EPERM; |
---|
1516 | 1502 | } |
---|
1517 | 1503 | |
---|
.. | .. |
---|
1549 | 1535 | |
---|
1550 | 1536 | /* Wait for sessions to clear out (just in case) */ |
---|
1551 | 1537 | wait_event_timeout(tgt->waitQ, test_tgt_sess_count(tgt), 10*HZ); |
---|
| 1538 | + mutex_unlock(&ha->optrom_mutex); |
---|
| 1539 | + |
---|
1552 | 1540 | return 0; |
---|
1553 | 1541 | } |
---|
1554 | 1542 | EXPORT_SYMBOL(qlt_stop_phase1); |
---|
.. | .. |
---|
1580 | 1568 | |
---|
1581 | 1569 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf00c, "Stop of tgt %p finished\n", |
---|
1582 | 1570 | tgt); |
---|
| 1571 | + |
---|
| 1572 | + switch (vha->qlini_mode) { |
---|
| 1573 | + case QLA2XXX_INI_MODE_EXCLUSIVE: |
---|
| 1574 | + vha->flags.online = 1; |
---|
| 1575 | + set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
---|
| 1576 | + break; |
---|
| 1577 | + default: |
---|
| 1578 | + break; |
---|
| 1579 | + } |
---|
1583 | 1580 | } |
---|
1584 | 1581 | EXPORT_SYMBOL(qlt_stop_phase2); |
---|
1585 | 1582 | |
---|
.. | .. |
---|
1593 | 1590 | struct qla_qpair_hint *h; |
---|
1594 | 1591 | struct qla_hw_data *ha = vha->hw; |
---|
1595 | 1592 | |
---|
1596 | | - if ((vha->vha_tgt.qla_tgt != NULL) && !tgt->tgt_stop && |
---|
1597 | | - !tgt->tgt_stopped) |
---|
| 1593 | + if (!tgt->tgt_stop && !tgt->tgt_stopped) |
---|
1598 | 1594 | qlt_stop_phase1(tgt); |
---|
1599 | 1595 | |
---|
1600 | | - if ((vha->vha_tgt.qla_tgt != NULL) && !tgt->tgt_stopped) |
---|
| 1596 | + if (!tgt->tgt_stopped) |
---|
1601 | 1597 | qlt_stop_phase2(tgt); |
---|
1602 | 1598 | |
---|
1603 | 1599 | for (i = 0; i < vha->hw->max_qpairs + 1; i++) { |
---|
.. | .. |
---|
1706 | 1702 | nack->u.isp24.nport_handle = ntfy->u.isp24.nport_handle; |
---|
1707 | 1703 | if (le16_to_cpu(ntfy->u.isp24.status) == IMM_NTFY_ELS) { |
---|
1708 | 1704 | nack->u.isp24.flags = ntfy->u.isp24.flags & |
---|
1709 | | - cpu_to_le32(NOTIFY24XX_FLAGS_PUREX_IOCB); |
---|
| 1705 | + cpu_to_le16(NOTIFY24XX_FLAGS_PUREX_IOCB); |
---|
1710 | 1706 | } |
---|
1711 | 1707 | nack->u.isp24.srr_rx_id = ntfy->u.isp24.srr_rx_id; |
---|
1712 | 1708 | nack->u.isp24.status = ntfy->u.isp24.status; |
---|
.. | .. |
---|
1729 | 1725 | qla2x00_start_iocbs(vha, qpair->req); |
---|
1730 | 1726 | } |
---|
1731 | 1727 | |
---|
| 1728 | +static int qlt_build_abts_resp_iocb(struct qla_tgt_mgmt_cmd *mcmd) |
---|
| 1729 | +{ |
---|
| 1730 | + struct scsi_qla_host *vha = mcmd->vha; |
---|
| 1731 | + struct qla_hw_data *ha = vha->hw; |
---|
| 1732 | + struct abts_resp_to_24xx *resp; |
---|
| 1733 | + __le32 f_ctl; |
---|
| 1734 | + uint32_t h; |
---|
| 1735 | + uint8_t *p; |
---|
| 1736 | + int rc; |
---|
| 1737 | + struct abts_recv_from_24xx *abts = &mcmd->orig_iocb.abts; |
---|
| 1738 | + struct qla_qpair *qpair = mcmd->qpair; |
---|
| 1739 | + |
---|
| 1740 | + ql_dbg(ql_dbg_tgt, vha, 0xe006, |
---|
| 1741 | + "Sending task mgmt ABTS response (ha=%p, status=%x)\n", |
---|
| 1742 | + ha, mcmd->fc_tm_rsp); |
---|
| 1743 | + |
---|
| 1744 | + rc = qlt_check_reserve_free_req(qpair, 1); |
---|
| 1745 | + if (rc) { |
---|
| 1746 | + ql_dbg(ql_dbg_tgt, vha, 0xe04a, |
---|
| 1747 | + "qla_target(%d): %s failed: unable to allocate request packet\n", |
---|
| 1748 | + vha->vp_idx, __func__); |
---|
| 1749 | + return -EAGAIN; |
---|
| 1750 | + } |
---|
| 1751 | + |
---|
| 1752 | + resp = (struct abts_resp_to_24xx *)qpair->req->ring_ptr; |
---|
| 1753 | + memset(resp, 0, sizeof(*resp)); |
---|
| 1754 | + |
---|
| 1755 | + h = qlt_make_handle(qpair); |
---|
| 1756 | + if (unlikely(h == QLA_TGT_NULL_HANDLE)) { |
---|
| 1757 | + /* |
---|
| 1758 | + * CTIO type 7 from the firmware doesn't provide a way to |
---|
| 1759 | + * know the initiator's LOOP ID, hence we can't find |
---|
| 1760 | + * the session and, so, the command. |
---|
| 1761 | + */ |
---|
| 1762 | + return -EAGAIN; |
---|
| 1763 | + } else { |
---|
| 1764 | + qpair->req->outstanding_cmds[h] = (srb_t *)mcmd; |
---|
| 1765 | + } |
---|
| 1766 | + |
---|
| 1767 | + resp->handle = make_handle(qpair->req->id, h); |
---|
| 1768 | + resp->entry_type = ABTS_RESP_24XX; |
---|
| 1769 | + resp->entry_count = 1; |
---|
| 1770 | + resp->nport_handle = abts->nport_handle; |
---|
| 1771 | + resp->vp_index = vha->vp_idx; |
---|
| 1772 | + resp->sof_type = abts->sof_type; |
---|
| 1773 | + resp->exchange_address = abts->exchange_address; |
---|
| 1774 | + resp->fcp_hdr_le = abts->fcp_hdr_le; |
---|
| 1775 | + f_ctl = cpu_to_le32(F_CTL_EXCH_CONTEXT_RESP | |
---|
| 1776 | + F_CTL_LAST_SEQ | F_CTL_END_SEQ | |
---|
| 1777 | + F_CTL_SEQ_INITIATIVE); |
---|
| 1778 | + p = (uint8_t *)&f_ctl; |
---|
| 1779 | + resp->fcp_hdr_le.f_ctl[0] = *p++; |
---|
| 1780 | + resp->fcp_hdr_le.f_ctl[1] = *p++; |
---|
| 1781 | + resp->fcp_hdr_le.f_ctl[2] = *p; |
---|
| 1782 | + |
---|
| 1783 | + resp->fcp_hdr_le.d_id = abts->fcp_hdr_le.s_id; |
---|
| 1784 | + resp->fcp_hdr_le.s_id = abts->fcp_hdr_le.d_id; |
---|
| 1785 | + |
---|
| 1786 | + resp->exchange_addr_to_abort = abts->exchange_addr_to_abort; |
---|
| 1787 | + if (mcmd->fc_tm_rsp == FCP_TMF_CMPL) { |
---|
| 1788 | + resp->fcp_hdr_le.r_ctl = R_CTL_BASIC_LINK_SERV | R_CTL_B_ACC; |
---|
| 1789 | + resp->payload.ba_acct.seq_id_valid = SEQ_ID_INVALID; |
---|
| 1790 | + resp->payload.ba_acct.low_seq_cnt = 0x0000; |
---|
| 1791 | + resp->payload.ba_acct.high_seq_cnt = cpu_to_le16(0xFFFF); |
---|
| 1792 | + resp->payload.ba_acct.ox_id = abts->fcp_hdr_le.ox_id; |
---|
| 1793 | + resp->payload.ba_acct.rx_id = abts->fcp_hdr_le.rx_id; |
---|
| 1794 | + } else { |
---|
| 1795 | + resp->fcp_hdr_le.r_ctl = R_CTL_BASIC_LINK_SERV | R_CTL_B_RJT; |
---|
| 1796 | + resp->payload.ba_rjt.reason_code = |
---|
| 1797 | + BA_RJT_REASON_CODE_UNABLE_TO_PERFORM; |
---|
| 1798 | + /* Other bytes are zero */ |
---|
| 1799 | + } |
---|
| 1800 | + |
---|
| 1801 | + vha->vha_tgt.qla_tgt->abts_resp_expected++; |
---|
| 1802 | + |
---|
| 1803 | + /* Memory Barrier */ |
---|
| 1804 | + wmb(); |
---|
| 1805 | + if (qpair->reqq_start_iocbs) |
---|
| 1806 | + qpair->reqq_start_iocbs(qpair); |
---|
| 1807 | + else |
---|
| 1808 | + qla2x00_start_iocbs(vha, qpair->req); |
---|
| 1809 | + |
---|
| 1810 | + return rc; |
---|
| 1811 | +} |
---|
| 1812 | + |
---|
1732 | 1813 | /* |
---|
1733 | 1814 | * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire |
---|
1734 | 1815 | */ |
---|
.. | .. |
---|
1739 | 1820 | struct scsi_qla_host *vha = qpair->vha; |
---|
1740 | 1821 | struct qla_hw_data *ha = vha->hw; |
---|
1741 | 1822 | struct abts_resp_to_24xx *resp; |
---|
1742 | | - uint32_t f_ctl; |
---|
| 1823 | + __le32 f_ctl; |
---|
1743 | 1824 | uint8_t *p; |
---|
1744 | 1825 | |
---|
1745 | 1826 | ql_dbg(ql_dbg_tgt, vha, 0xe006, |
---|
.. | .. |
---|
1756 | 1837 | } |
---|
1757 | 1838 | |
---|
1758 | 1839 | resp->entry_type = ABTS_RESP_24XX; |
---|
| 1840 | + resp->handle = QLA_TGT_SKIP_HANDLE; |
---|
1759 | 1841 | resp->entry_count = 1; |
---|
1760 | 1842 | resp->nport_handle = abts->nport_handle; |
---|
1761 | 1843 | resp->vp_index = vha->vp_idx; |
---|
.. | .. |
---|
1770 | 1852 | resp->fcp_hdr_le.f_ctl[1] = *p++; |
---|
1771 | 1853 | resp->fcp_hdr_le.f_ctl[2] = *p; |
---|
1772 | 1854 | if (ids_reversed) { |
---|
1773 | | - resp->fcp_hdr_le.d_id[0] = abts->fcp_hdr_le.d_id[0]; |
---|
1774 | | - resp->fcp_hdr_le.d_id[1] = abts->fcp_hdr_le.d_id[1]; |
---|
1775 | | - resp->fcp_hdr_le.d_id[2] = abts->fcp_hdr_le.d_id[2]; |
---|
1776 | | - resp->fcp_hdr_le.s_id[0] = abts->fcp_hdr_le.s_id[0]; |
---|
1777 | | - resp->fcp_hdr_le.s_id[1] = abts->fcp_hdr_le.s_id[1]; |
---|
1778 | | - resp->fcp_hdr_le.s_id[2] = abts->fcp_hdr_le.s_id[2]; |
---|
| 1855 | + resp->fcp_hdr_le.d_id = abts->fcp_hdr_le.d_id; |
---|
| 1856 | + resp->fcp_hdr_le.s_id = abts->fcp_hdr_le.s_id; |
---|
1779 | 1857 | } else { |
---|
1780 | | - resp->fcp_hdr_le.d_id[0] = abts->fcp_hdr_le.s_id[0]; |
---|
1781 | | - resp->fcp_hdr_le.d_id[1] = abts->fcp_hdr_le.s_id[1]; |
---|
1782 | | - resp->fcp_hdr_le.d_id[2] = abts->fcp_hdr_le.s_id[2]; |
---|
1783 | | - resp->fcp_hdr_le.s_id[0] = abts->fcp_hdr_le.d_id[0]; |
---|
1784 | | - resp->fcp_hdr_le.s_id[1] = abts->fcp_hdr_le.d_id[1]; |
---|
1785 | | - resp->fcp_hdr_le.s_id[2] = abts->fcp_hdr_le.d_id[2]; |
---|
| 1858 | + resp->fcp_hdr_le.d_id = abts->fcp_hdr_le.s_id; |
---|
| 1859 | + resp->fcp_hdr_le.s_id = abts->fcp_hdr_le.d_id; |
---|
1786 | 1860 | } |
---|
1787 | 1861 | resp->exchange_addr_to_abort = abts->exchange_addr_to_abort; |
---|
1788 | 1862 | if (status == FCP_TMF_CMPL) { |
---|
1789 | 1863 | resp->fcp_hdr_le.r_ctl = R_CTL_BASIC_LINK_SERV | R_CTL_B_ACC; |
---|
1790 | 1864 | resp->payload.ba_acct.seq_id_valid = SEQ_ID_INVALID; |
---|
1791 | 1865 | resp->payload.ba_acct.low_seq_cnt = 0x0000; |
---|
1792 | | - resp->payload.ba_acct.high_seq_cnt = 0xFFFF; |
---|
| 1866 | + resp->payload.ba_acct.high_seq_cnt = cpu_to_le16(0xFFFF); |
---|
1793 | 1867 | resp->payload.ba_acct.ox_id = abts->fcp_hdr_le.ox_id; |
---|
1794 | 1868 | resp->payload.ba_acct.rx_id = abts->fcp_hdr_le.rx_id; |
---|
1795 | 1869 | } else { |
---|
.. | .. |
---|
1813 | 1887 | * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire |
---|
1814 | 1888 | */ |
---|
1815 | 1889 | static void qlt_24xx_retry_term_exchange(struct scsi_qla_host *vha, |
---|
1816 | | - struct abts_resp_from_24xx_fw *entry) |
---|
| 1890 | + struct qla_qpair *qpair, response_t *pkt, struct qla_tgt_mgmt_cmd *mcmd) |
---|
1817 | 1891 | { |
---|
1818 | 1892 | struct ctio7_to_24xx *ctio; |
---|
| 1893 | + u16 tmp; |
---|
| 1894 | + struct abts_recv_from_24xx *entry; |
---|
1819 | 1895 | |
---|
1820 | | - ql_dbg(ql_dbg_tgt, vha, 0xe007, |
---|
1821 | | - "Sending retry TERM EXCH CTIO7 (ha=%p)\n", vha->hw); |
---|
1822 | | - |
---|
1823 | | - ctio = (struct ctio7_to_24xx *)qla2x00_alloc_iocbs_ready( |
---|
1824 | | - vha->hw->base_qpair, NULL); |
---|
| 1896 | + ctio = (struct ctio7_to_24xx *)qla2x00_alloc_iocbs_ready(qpair, NULL); |
---|
1825 | 1897 | if (ctio == NULL) { |
---|
1826 | 1898 | ql_dbg(ql_dbg_tgt, vha, 0xe04b, |
---|
1827 | 1899 | "qla_target(%d): %s failed: unable to allocate " |
---|
1828 | 1900 | "request packet\n", vha->vp_idx, __func__); |
---|
1829 | 1901 | return; |
---|
1830 | 1902 | } |
---|
| 1903 | + |
---|
| 1904 | + if (mcmd) |
---|
| 1905 | + /* abts from remote port */ |
---|
| 1906 | + entry = &mcmd->orig_iocb.abts; |
---|
| 1907 | + else |
---|
| 1908 | + /* abts from this driver. */ |
---|
| 1909 | + entry = (struct abts_recv_from_24xx *)pkt; |
---|
1831 | 1910 | |
---|
1832 | 1911 | /* |
---|
1833 | 1912 | * We've got on entrance firmware's response on by us generated |
---|
.. | .. |
---|
1840 | 1919 | ctio->handle = QLA_TGT_SKIP_HANDLE | CTIO_COMPLETION_HANDLE_MARK; |
---|
1841 | 1920 | ctio->timeout = cpu_to_le16(QLA_TGT_TIMEOUT); |
---|
1842 | 1921 | ctio->vp_index = vha->vp_idx; |
---|
1843 | | - ctio->initiator_id[0] = entry->fcp_hdr_le.d_id[0]; |
---|
1844 | | - ctio->initiator_id[1] = entry->fcp_hdr_le.d_id[1]; |
---|
1845 | | - ctio->initiator_id[2] = entry->fcp_hdr_le.d_id[2]; |
---|
1846 | 1922 | ctio->exchange_addr = entry->exchange_addr_to_abort; |
---|
1847 | | - ctio->u.status1.flags = cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1 | |
---|
1848 | | - CTIO7_FLAGS_TERMINATE); |
---|
1849 | | - ctio->u.status1.ox_id = cpu_to_le16(entry->fcp_hdr_le.ox_id); |
---|
| 1923 | + tmp = (CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_TERMINATE); |
---|
| 1924 | + |
---|
| 1925 | + if (mcmd) { |
---|
| 1926 | + ctio->initiator_id = entry->fcp_hdr_le.s_id; |
---|
| 1927 | + |
---|
| 1928 | + if (mcmd->flags & QLA24XX_MGMT_ABORT_IO_ATTR_VALID) |
---|
| 1929 | + tmp |= (mcmd->abort_io_attr << 9); |
---|
| 1930 | + else if (qpair->retry_term_cnt & 1) |
---|
| 1931 | + tmp |= (0x4 << 9); |
---|
| 1932 | + } else { |
---|
| 1933 | + ctio->initiator_id = entry->fcp_hdr_le.d_id; |
---|
| 1934 | + |
---|
| 1935 | + if (qpair->retry_term_cnt & 1) |
---|
| 1936 | + tmp |= (0x4 << 9); |
---|
| 1937 | + } |
---|
| 1938 | + ctio->u.status1.flags = cpu_to_le16(tmp); |
---|
| 1939 | + ctio->u.status1.ox_id = entry->fcp_hdr_le.ox_id; |
---|
| 1940 | + |
---|
| 1941 | + ql_dbg(ql_dbg_tgt, vha, 0xe007, |
---|
| 1942 | + "Sending retry TERM EXCH CTIO7 flags %04xh oxid %04xh attr valid %x\n", |
---|
| 1943 | + le16_to_cpu(ctio->u.status1.flags), |
---|
| 1944 | + le16_to_cpu(ctio->u.status1.ox_id), |
---|
| 1945 | + (mcmd && mcmd->flags & QLA24XX_MGMT_ABORT_IO_ATTR_VALID) ? 1 : 0); |
---|
1850 | 1946 | |
---|
1851 | 1947 | /* Memory Barrier */ |
---|
1852 | 1948 | wmb(); |
---|
1853 | | - qla2x00_start_iocbs(vha, vha->req); |
---|
| 1949 | + if (qpair->reqq_start_iocbs) |
---|
| 1950 | + qpair->reqq_start_iocbs(qpair); |
---|
| 1951 | + else |
---|
| 1952 | + qla2x00_start_iocbs(vha, qpair->req); |
---|
1854 | 1953 | |
---|
1855 | | - qlt_24xx_send_abts_resp(vha->hw->base_qpair, |
---|
1856 | | - (struct abts_recv_from_24xx *)entry, |
---|
1857 | | - FCP_TMF_CMPL, true); |
---|
1858 | | -} |
---|
| 1954 | + if (mcmd) |
---|
| 1955 | + qlt_build_abts_resp_iocb(mcmd); |
---|
| 1956 | + else |
---|
| 1957 | + qlt_24xx_send_abts_resp(qpair, |
---|
| 1958 | + (struct abts_recv_from_24xx *)entry, FCP_TMF_CMPL, true); |
---|
1859 | 1959 | |
---|
1860 | | -static int abort_cmd_for_tag(struct scsi_qla_host *vha, uint32_t tag) |
---|
1861 | | -{ |
---|
1862 | | - struct qla_tgt_sess_op *op; |
---|
1863 | | - struct qla_tgt_cmd *cmd; |
---|
1864 | | - unsigned long flags; |
---|
1865 | | - |
---|
1866 | | - spin_lock_irqsave(&vha->cmd_list_lock, flags); |
---|
1867 | | - list_for_each_entry(op, &vha->qla_sess_op_cmd_list, cmd_list) { |
---|
1868 | | - if (tag == op->atio.u.isp24.exchange_addr) { |
---|
1869 | | - op->aborted = true; |
---|
1870 | | - spin_unlock_irqrestore(&vha->cmd_list_lock, flags); |
---|
1871 | | - return 1; |
---|
1872 | | - } |
---|
1873 | | - } |
---|
1874 | | - |
---|
1875 | | - list_for_each_entry(op, &vha->unknown_atio_list, cmd_list) { |
---|
1876 | | - if (tag == op->atio.u.isp24.exchange_addr) { |
---|
1877 | | - op->aborted = true; |
---|
1878 | | - spin_unlock_irqrestore(&vha->cmd_list_lock, flags); |
---|
1879 | | - return 1; |
---|
1880 | | - } |
---|
1881 | | - } |
---|
1882 | | - |
---|
1883 | | - list_for_each_entry(cmd, &vha->qla_cmd_list, cmd_list) { |
---|
1884 | | - if (tag == cmd->atio.u.isp24.exchange_addr) { |
---|
1885 | | - cmd->aborted = 1; |
---|
1886 | | - spin_unlock_irqrestore(&vha->cmd_list_lock, flags); |
---|
1887 | | - return 1; |
---|
1888 | | - } |
---|
1889 | | - } |
---|
1890 | | - spin_unlock_irqrestore(&vha->cmd_list_lock, flags); |
---|
1891 | | - |
---|
1892 | | - return 0; |
---|
1893 | 1960 | } |
---|
1894 | 1961 | |
---|
1895 | 1962 | /* drop cmds for the given lun |
---|
.. | .. |
---|
1897 | 1964 | * XXX does not go through the list of other port (which may have cmds |
---|
1898 | 1965 | * for the same lun) |
---|
1899 | 1966 | */ |
---|
1900 | | -static void abort_cmds_for_lun(struct scsi_qla_host *vha, |
---|
1901 | | - u64 lun, uint8_t *s_id) |
---|
| 1967 | +static void abort_cmds_for_lun(struct scsi_qla_host *vha, u64 lun, be_id_t s_id) |
---|
1902 | 1968 | { |
---|
1903 | 1969 | struct qla_tgt_sess_op *op; |
---|
1904 | 1970 | struct qla_tgt_cmd *cmd; |
---|
.. | .. |
---|
1964 | 2030 | struct qla_tgt_mgmt_cmd *mcmd = |
---|
1965 | 2031 | container_of(work, struct qla_tgt_mgmt_cmd, work); |
---|
1966 | 2032 | struct qla_hw_data *ha = mcmd->vha->hw; |
---|
1967 | | - int rc = EIO; |
---|
| 2033 | + int rc; |
---|
1968 | 2034 | uint32_t tag; |
---|
1969 | 2035 | unsigned long flags; |
---|
1970 | 2036 | |
---|
1971 | 2037 | switch (mcmd->tmr_func) { |
---|
1972 | 2038 | case QLA_TGT_ABTS: |
---|
1973 | | - tag = mcmd->orig_iocb.abts.exchange_addr_to_abort; |
---|
| 2039 | + tag = le32_to_cpu(mcmd->orig_iocb.abts.exchange_addr_to_abort); |
---|
1974 | 2040 | break; |
---|
1975 | 2041 | default: |
---|
1976 | 2042 | tag = 0; |
---|
.. | .. |
---|
1984 | 2050 | spin_lock_irqsave(mcmd->qpair->qp_lock_ptr, flags); |
---|
1985 | 2051 | switch (mcmd->tmr_func) { |
---|
1986 | 2052 | case QLA_TGT_ABTS: |
---|
1987 | | - qlt_24xx_send_abts_resp(mcmd->qpair, |
---|
1988 | | - &mcmd->orig_iocb.abts, |
---|
1989 | | - FCP_TMF_REJECTED, false); |
---|
| 2053 | + mcmd->fc_tm_rsp = FCP_TMF_REJECTED; |
---|
| 2054 | + qlt_build_abts_resp_iocb(mcmd); |
---|
1990 | 2055 | break; |
---|
1991 | 2056 | case QLA_TGT_LUN_RESET: |
---|
1992 | 2057 | case QLA_TGT_CLEAR_TS: |
---|
.. | .. |
---|
2021 | 2086 | struct qla_tgt_mgmt_cmd *mcmd; |
---|
2022 | 2087 | struct qla_qpair_hint *h = &vha->vha_tgt.qla_tgt->qphints[0]; |
---|
2023 | 2088 | |
---|
2024 | | - if (abort_cmd_for_tag(vha, abts->exchange_addr_to_abort)) { |
---|
2025 | | - /* send TASK_ABORT response immediately */ |
---|
2026 | | - qlt_24xx_send_abts_resp(ha->base_qpair, abts, FCP_TMF_CMPL, false); |
---|
2027 | | - return 0; |
---|
2028 | | - } |
---|
2029 | | - |
---|
2030 | 2089 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf00f, |
---|
2031 | 2090 | "qla_target(%d): task abort (tag=%d)\n", |
---|
2032 | 2091 | vha->vp_idx, abts->exchange_addr_to_abort); |
---|
.. | .. |
---|
2039 | 2098 | return -ENOMEM; |
---|
2040 | 2099 | } |
---|
2041 | 2100 | memset(mcmd, 0, sizeof(*mcmd)); |
---|
2042 | | - |
---|
| 2101 | + mcmd->cmd_type = TYPE_TGT_TMCMD; |
---|
2043 | 2102 | mcmd->sess = sess; |
---|
2044 | 2103 | memcpy(&mcmd->orig_iocb.abts, abts, sizeof(mcmd->orig_iocb.abts)); |
---|
2045 | 2104 | mcmd->reset_count = ha->base_qpair->chip_reset; |
---|
.. | .. |
---|
2057 | 2116 | struct qla_tgt_cmd *abort_cmd; |
---|
2058 | 2117 | |
---|
2059 | 2118 | abort_cmd = ha->tgt.tgt_ops->find_cmd_by_tag(sess, |
---|
2060 | | - abts->exchange_addr_to_abort); |
---|
| 2119 | + le32_to_cpu(abts->exchange_addr_to_abort)); |
---|
2061 | 2120 | if (abort_cmd && abort_cmd->qpair) { |
---|
2062 | 2121 | mcmd->qpair = abort_cmd->qpair; |
---|
2063 | 2122 | mcmd->se_cmd.cpuid = abort_cmd->se_cmd.cpuid; |
---|
| 2123 | + mcmd->abort_io_attr = abort_cmd->atio.u.isp24.attr; |
---|
| 2124 | + mcmd->flags = QLA24XX_MGMT_ABORT_IO_ATTR_VALID; |
---|
2064 | 2125 | } |
---|
2065 | 2126 | } |
---|
2066 | 2127 | |
---|
.. | .. |
---|
2078 | 2139 | { |
---|
2079 | 2140 | struct qla_hw_data *ha = vha->hw; |
---|
2080 | 2141 | struct fc_port *sess; |
---|
2081 | | - uint32_t tag = abts->exchange_addr_to_abort; |
---|
2082 | | - uint8_t s_id[3]; |
---|
| 2142 | + uint32_t tag = le32_to_cpu(abts->exchange_addr_to_abort); |
---|
| 2143 | + be_id_t s_id; |
---|
2083 | 2144 | int rc; |
---|
2084 | 2145 | unsigned long flags; |
---|
2085 | 2146 | |
---|
.. | .. |
---|
2103 | 2164 | |
---|
2104 | 2165 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf011, |
---|
2105 | 2166 | "qla_target(%d): task abort (s_id=%x:%x:%x, " |
---|
2106 | | - "tag=%d, param=%x)\n", vha->vp_idx, abts->fcp_hdr_le.s_id[2], |
---|
2107 | | - abts->fcp_hdr_le.s_id[1], abts->fcp_hdr_le.s_id[0], tag, |
---|
| 2167 | + "tag=%d, param=%x)\n", vha->vp_idx, abts->fcp_hdr_le.s_id.domain, |
---|
| 2168 | + abts->fcp_hdr_le.s_id.area, abts->fcp_hdr_le.s_id.al_pa, tag, |
---|
2108 | 2169 | le32_to_cpu(abts->fcp_hdr_le.parameter)); |
---|
2109 | 2170 | |
---|
2110 | | - s_id[0] = abts->fcp_hdr_le.s_id[2]; |
---|
2111 | | - s_id[1] = abts->fcp_hdr_le.s_id[1]; |
---|
2112 | | - s_id[2] = abts->fcp_hdr_le.s_id[0]; |
---|
| 2171 | + s_id = le_id_to_be(abts->fcp_hdr_le.s_id); |
---|
2113 | 2172 | |
---|
2114 | 2173 | spin_lock_irqsave(&ha->tgt.sess_lock, flags); |
---|
2115 | 2174 | sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, s_id); |
---|
.. | .. |
---|
2170 | 2229 | ctio->entry_type = CTIO_TYPE7; |
---|
2171 | 2230 | ctio->entry_count = 1; |
---|
2172 | 2231 | ctio->handle = QLA_TGT_SKIP_HANDLE | CTIO_COMPLETION_HANDLE_MARK; |
---|
2173 | | - ctio->nport_handle = mcmd->sess->loop_id; |
---|
| 2232 | + ctio->nport_handle = cpu_to_le16(mcmd->sess->loop_id); |
---|
2174 | 2233 | ctio->timeout = cpu_to_le16(QLA_TGT_TIMEOUT); |
---|
2175 | 2234 | ctio->vp_index = ha->vp_idx; |
---|
2176 | | - ctio->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2]; |
---|
2177 | | - ctio->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1]; |
---|
2178 | | - ctio->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0]; |
---|
| 2235 | + ctio->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id); |
---|
2179 | 2236 | ctio->exchange_addr = atio->u.isp24.exchange_addr; |
---|
2180 | 2237 | temp = (atio->u.isp24.attr << 9)| |
---|
2181 | 2238 | CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_SEND_STATUS; |
---|
.. | .. |
---|
2229 | 2286 | ctio->entry_type = CTIO_TYPE7; |
---|
2230 | 2287 | ctio->entry_count = 1; |
---|
2231 | 2288 | ctio->handle = QLA_TGT_SKIP_HANDLE; |
---|
2232 | | - ctio->nport_handle = cmd->sess->loop_id; |
---|
| 2289 | + ctio->nport_handle = cpu_to_le16(cmd->sess->loop_id); |
---|
2233 | 2290 | ctio->timeout = cpu_to_le16(QLA_TGT_TIMEOUT); |
---|
2234 | 2291 | ctio->vp_index = vha->vp_idx; |
---|
2235 | | - ctio->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2]; |
---|
2236 | | - ctio->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1]; |
---|
2237 | | - ctio->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0]; |
---|
| 2292 | + ctio->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id); |
---|
2238 | 2293 | ctio->exchange_addr = atio->u.isp24.exchange_addr; |
---|
2239 | 2294 | temp = (atio->u.isp24.attr << 9) | |
---|
2240 | 2295 | CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_SEND_STATUS; |
---|
.. | .. |
---|
2278 | 2333 | struct qla_hw_data *ha = vha->hw; |
---|
2279 | 2334 | unsigned long flags; |
---|
2280 | 2335 | struct qla_qpair *qpair = mcmd->qpair; |
---|
| 2336 | + bool free_mcmd = true; |
---|
2281 | 2337 | |
---|
2282 | 2338 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf013, |
---|
2283 | 2339 | "TM response mcmd (%p) status %#x state %#x", |
---|
.. | .. |
---|
2300 | 2356 | } |
---|
2301 | 2357 | |
---|
2302 | 2358 | if (mcmd->flags == QLA24XX_MGMT_SEND_NACK) { |
---|
2303 | | - if (mcmd->orig_iocb.imm_ntfy.u.isp24.status_subcode == |
---|
2304 | | - ELS_LOGO || |
---|
2305 | | - mcmd->orig_iocb.imm_ntfy.u.isp24.status_subcode == |
---|
2306 | | - ELS_PRLO || |
---|
2307 | | - mcmd->orig_iocb.imm_ntfy.u.isp24.status_subcode == |
---|
2308 | | - ELS_TPRLO) { |
---|
| 2359 | + switch (mcmd->orig_iocb.imm_ntfy.u.isp24.status_subcode) { |
---|
| 2360 | + case ELS_LOGO: |
---|
| 2361 | + case ELS_PRLO: |
---|
| 2362 | + case ELS_TPRLO: |
---|
2309 | 2363 | ql_dbg(ql_dbg_disc, vha, 0x2106, |
---|
2310 | 2364 | "TM response logo %8phC status %#x state %#x", |
---|
2311 | 2365 | mcmd->sess->port_name, mcmd->fc_tm_rsp, |
---|
2312 | 2366 | mcmd->flags); |
---|
2313 | 2367 | qlt_schedule_sess_for_deletion(mcmd->sess); |
---|
2314 | | - } else { |
---|
| 2368 | + break; |
---|
| 2369 | + default: |
---|
2315 | 2370 | qlt_send_notify_ack(vha->hw->base_qpair, |
---|
2316 | 2371 | &mcmd->orig_iocb.imm_ntfy, 0, 0, 0, 0, 0, 0); |
---|
| 2372 | + break; |
---|
2317 | 2373 | } |
---|
2318 | 2374 | } else { |
---|
2319 | | - if (mcmd->orig_iocb.atio.u.raw.entry_type == ABTS_RECV_24XX) |
---|
2320 | | - qlt_24xx_send_abts_resp(qpair, &mcmd->orig_iocb.abts, |
---|
2321 | | - mcmd->fc_tm_rsp, false); |
---|
2322 | | - else |
---|
| 2375 | + if (mcmd->orig_iocb.atio.u.raw.entry_type == ABTS_RECV_24XX) { |
---|
| 2376 | + qlt_build_abts_resp_iocb(mcmd); |
---|
| 2377 | + free_mcmd = false; |
---|
| 2378 | + } else |
---|
2323 | 2379 | qlt_24xx_send_task_mgmt_ctio(qpair, mcmd, |
---|
2324 | 2380 | mcmd->fc_tm_rsp); |
---|
2325 | 2381 | } |
---|
.. | .. |
---|
2331 | 2387 | * descriptor after TFO->queue_tm_rsp() -> tcm_qla2xxx_queue_tm_rsp() -> |
---|
2332 | 2388 | * qlt_xmit_tm_rsp() returns here.. |
---|
2333 | 2389 | */ |
---|
2334 | | - ha->tgt.tgt_ops->free_mcmd(mcmd); |
---|
| 2390 | + if (free_mcmd) |
---|
| 2391 | + ha->tgt.tgt_ops->free_mcmd(mcmd); |
---|
| 2392 | + |
---|
2335 | 2393 | spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); |
---|
2336 | 2394 | } |
---|
2337 | 2395 | EXPORT_SYMBOL(qlt_xmit_tm_rsp); |
---|
.. | .. |
---|
2344 | 2402 | BUG_ON(cmd->sg_cnt == 0); |
---|
2345 | 2403 | |
---|
2346 | 2404 | prm->sg = (struct scatterlist *)cmd->sg; |
---|
2347 | | - prm->seg_cnt = pci_map_sg(cmd->qpair->pdev, cmd->sg, |
---|
| 2405 | + prm->seg_cnt = dma_map_sg(&cmd->qpair->pdev->dev, cmd->sg, |
---|
2348 | 2406 | cmd->sg_cnt, cmd->dma_data_direction); |
---|
2349 | 2407 | if (unlikely(prm->seg_cnt == 0)) |
---|
2350 | 2408 | goto out_err; |
---|
.. | .. |
---|
2371 | 2429 | |
---|
2372 | 2430 | if (cmd->prot_sg_cnt) { |
---|
2373 | 2431 | prm->prot_sg = cmd->prot_sg; |
---|
2374 | | - prm->prot_seg_cnt = pci_map_sg(cmd->qpair->pdev, |
---|
| 2432 | + prm->prot_seg_cnt = dma_map_sg(&cmd->qpair->pdev->dev, |
---|
2375 | 2433 | cmd->prot_sg, cmd->prot_sg_cnt, |
---|
2376 | 2434 | cmd->dma_data_direction); |
---|
2377 | 2435 | if (unlikely(prm->prot_seg_cnt == 0)) |
---|
.. | .. |
---|
2401 | 2459 | { |
---|
2402 | 2460 | struct qla_hw_data *ha; |
---|
2403 | 2461 | struct qla_qpair *qpair; |
---|
| 2462 | + |
---|
2404 | 2463 | if (!cmd->sg_mapped) |
---|
2405 | 2464 | return; |
---|
2406 | 2465 | |
---|
2407 | 2466 | qpair = cmd->qpair; |
---|
2408 | 2467 | |
---|
2409 | | - pci_unmap_sg(qpair->pdev, cmd->sg, cmd->sg_cnt, |
---|
| 2468 | + dma_unmap_sg(&qpair->pdev->dev, cmd->sg, cmd->sg_cnt, |
---|
2410 | 2469 | cmd->dma_data_direction); |
---|
2411 | 2470 | cmd->sg_mapped = 0; |
---|
2412 | 2471 | |
---|
2413 | 2472 | if (cmd->prot_sg_cnt) |
---|
2414 | | - pci_unmap_sg(qpair->pdev, cmd->prot_sg, cmd->prot_sg_cnt, |
---|
| 2473 | + dma_unmap_sg(&qpair->pdev->dev, cmd->prot_sg, cmd->prot_sg_cnt, |
---|
2415 | 2474 | cmd->dma_data_direction); |
---|
2416 | 2475 | |
---|
2417 | 2476 | if (!cmd->ctx) |
---|
.. | .. |
---|
2431 | 2490 | |
---|
2432 | 2491 | if (req->cnt < (req_cnt + 2)) { |
---|
2433 | 2492 | cnt = (uint16_t)(qpair->use_shadow_reg ? *req->out_ptr : |
---|
2434 | | - RD_REG_DWORD_RELAXED(req->req_q_out)); |
---|
| 2493 | + rd_reg_dword_relaxed(req->req_q_out)); |
---|
2435 | 2494 | |
---|
2436 | 2495 | if (req->ring_index < cnt) |
---|
2437 | 2496 | req->cnt = cnt - req->ring_index; |
---|
.. | .. |
---|
2527 | 2586 | } else |
---|
2528 | 2587 | qpair->req->outstanding_cmds[h] = (srb_t *)prm->cmd; |
---|
2529 | 2588 | |
---|
2530 | | - pkt->handle = MAKE_HANDLE(qpair->req->id, h); |
---|
| 2589 | + pkt->handle = make_handle(qpair->req->id, h); |
---|
2531 | 2590 | pkt->handle |= CTIO_COMPLETION_HANDLE_MARK; |
---|
2532 | 2591 | pkt->nport_handle = cpu_to_le16(prm->cmd->loop_id); |
---|
2533 | 2592 | pkt->timeout = cpu_to_le16(QLA_TGT_TIMEOUT); |
---|
2534 | | - pkt->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2]; |
---|
2535 | | - pkt->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1]; |
---|
2536 | | - pkt->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0]; |
---|
| 2593 | + pkt->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id); |
---|
2537 | 2594 | pkt->exchange_addr = atio->u.isp24.exchange_addr; |
---|
2538 | 2595 | temp = atio->u.isp24.attr << 9; |
---|
2539 | 2596 | pkt->u.status0.flags |= cpu_to_le16(temp); |
---|
.. | .. |
---|
2551 | 2608 | static void qlt_load_cont_data_segments(struct qla_tgt_prm *prm) |
---|
2552 | 2609 | { |
---|
2553 | 2610 | int cnt; |
---|
2554 | | - uint32_t *dword_ptr; |
---|
| 2611 | + struct dsd64 *cur_dsd; |
---|
2555 | 2612 | |
---|
2556 | 2613 | /* Build continuation packets */ |
---|
2557 | 2614 | while (prm->seg_cnt > 0) { |
---|
.. | .. |
---|
2572 | 2629 | cont_pkt64->sys_define = 0; |
---|
2573 | 2630 | |
---|
2574 | 2631 | cont_pkt64->entry_type = CONTINUE_A64_TYPE; |
---|
2575 | | - dword_ptr = (uint32_t *)&cont_pkt64->dseg_0_address; |
---|
| 2632 | + cur_dsd = cont_pkt64->dsd; |
---|
2576 | 2633 | |
---|
2577 | 2634 | /* Load continuation entry data segments */ |
---|
2578 | 2635 | for (cnt = 0; |
---|
2579 | 2636 | cnt < QLA_TGT_DATASEGS_PER_CONT_24XX && prm->seg_cnt; |
---|
2580 | 2637 | cnt++, prm->seg_cnt--) { |
---|
2581 | | - *dword_ptr++ = |
---|
2582 | | - cpu_to_le32(pci_dma_lo32 |
---|
2583 | | - (sg_dma_address(prm->sg))); |
---|
2584 | | - *dword_ptr++ = cpu_to_le32(pci_dma_hi32 |
---|
2585 | | - (sg_dma_address(prm->sg))); |
---|
2586 | | - *dword_ptr++ = cpu_to_le32(sg_dma_len(prm->sg)); |
---|
2587 | | - |
---|
| 2638 | + append_dsd64(&cur_dsd, prm->sg); |
---|
2588 | 2639 | prm->sg = sg_next(prm->sg); |
---|
2589 | 2640 | } |
---|
2590 | 2641 | } |
---|
.. | .. |
---|
2597 | 2648 | static void qlt_load_data_segments(struct qla_tgt_prm *prm) |
---|
2598 | 2649 | { |
---|
2599 | 2650 | int cnt; |
---|
2600 | | - uint32_t *dword_ptr; |
---|
| 2651 | + struct dsd64 *cur_dsd; |
---|
2601 | 2652 | struct ctio7_to_24xx *pkt24 = (struct ctio7_to_24xx *)prm->pkt; |
---|
2602 | 2653 | |
---|
2603 | 2654 | pkt24->u.status0.transfer_length = cpu_to_le32(prm->cmd->bufflen); |
---|
2604 | 2655 | |
---|
2605 | 2656 | /* Setup packet address segment pointer */ |
---|
2606 | | - dword_ptr = pkt24->u.status0.dseg_0_address; |
---|
| 2657 | + cur_dsd = &pkt24->u.status0.dsd; |
---|
2607 | 2658 | |
---|
2608 | 2659 | /* Set total data segment count */ |
---|
2609 | 2660 | if (prm->seg_cnt) |
---|
.. | .. |
---|
2611 | 2662 | |
---|
2612 | 2663 | if (prm->seg_cnt == 0) { |
---|
2613 | 2664 | /* No data transfer */ |
---|
2614 | | - *dword_ptr++ = 0; |
---|
2615 | | - *dword_ptr = 0; |
---|
| 2665 | + cur_dsd->address = 0; |
---|
| 2666 | + cur_dsd->length = 0; |
---|
2616 | 2667 | return; |
---|
2617 | 2668 | } |
---|
2618 | 2669 | |
---|
.. | .. |
---|
2622 | 2673 | for (cnt = 0; |
---|
2623 | 2674 | (cnt < QLA_TGT_DATASEGS_PER_CMD_24XX) && prm->seg_cnt; |
---|
2624 | 2675 | cnt++, prm->seg_cnt--) { |
---|
2625 | | - *dword_ptr++ = |
---|
2626 | | - cpu_to_le32(pci_dma_lo32(sg_dma_address(prm->sg))); |
---|
2627 | | - |
---|
2628 | | - *dword_ptr++ = cpu_to_le32(pci_dma_hi32( |
---|
2629 | | - sg_dma_address(prm->sg))); |
---|
2630 | | - |
---|
2631 | | - *dword_ptr++ = cpu_to_le32(sg_dma_len(prm->sg)); |
---|
2632 | | - |
---|
| 2676 | + append_dsd64(&cur_dsd, prm->sg); |
---|
2633 | 2677 | prm->sg = sg_next(prm->sg); |
---|
2634 | 2678 | } |
---|
2635 | 2679 | |
---|
.. | .. |
---|
2802 | 2846 | cpu_to_le16(SS_SENSE_LEN_VALID); |
---|
2803 | 2847 | ctio->u.status1.sense_length = |
---|
2804 | 2848 | cpu_to_le16(prm->sense_buffer_len); |
---|
2805 | | - for (i = 0; i < prm->sense_buffer_len/4; i++) |
---|
2806 | | - ((uint32_t *)ctio->u.status1.sense_data)[i] = |
---|
2807 | | - cpu_to_be32(((uint32_t *)prm->sense_buffer)[i]); |
---|
| 2849 | + for (i = 0; i < prm->sense_buffer_len/4; i++) { |
---|
| 2850 | + uint32_t v; |
---|
2808 | 2851 | |
---|
| 2852 | + v = get_unaligned_be32( |
---|
| 2853 | + &((uint32_t *)prm->sense_buffer)[i]); |
---|
| 2854 | + put_unaligned_le32(v, |
---|
| 2855 | + &((uint32_t *)ctio->u.status1.sense_data)[i]); |
---|
| 2856 | + } |
---|
2809 | 2857 | qlt_print_dif_err(prm); |
---|
2810 | 2858 | |
---|
2811 | 2859 | } else { |
---|
.. | .. |
---|
2953 | 3001 | static inline int |
---|
2954 | 3002 | qlt_build_ctio_crc2_pkt(struct qla_qpair *qpair, struct qla_tgt_prm *prm) |
---|
2955 | 3003 | { |
---|
2956 | | - uint32_t *cur_dsd; |
---|
| 3004 | + struct dsd64 *cur_dsd; |
---|
2957 | 3005 | uint32_t transfer_length = 0; |
---|
2958 | 3006 | uint32_t data_bytes; |
---|
2959 | 3007 | uint32_t dif_bytes; |
---|
.. | .. |
---|
3055 | 3103 | } else |
---|
3056 | 3104 | qpair->req->outstanding_cmds[h] = (srb_t *)prm->cmd; |
---|
3057 | 3105 | |
---|
3058 | | - pkt->handle = MAKE_HANDLE(qpair->req->id, h); |
---|
| 3106 | + pkt->handle = make_handle(qpair->req->id, h); |
---|
3059 | 3107 | pkt->handle |= CTIO_COMPLETION_HANDLE_MARK; |
---|
3060 | 3108 | pkt->nport_handle = cpu_to_le16(prm->cmd->loop_id); |
---|
3061 | 3109 | pkt->timeout = cpu_to_le16(QLA_TGT_TIMEOUT); |
---|
3062 | | - pkt->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2]; |
---|
3063 | | - pkt->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1]; |
---|
3064 | | - pkt->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0]; |
---|
| 3110 | + pkt->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id); |
---|
3065 | 3111 | pkt->exchange_addr = atio->u.isp24.exchange_addr; |
---|
3066 | 3112 | |
---|
3067 | 3113 | /* silence compile warning */ |
---|
.. | .. |
---|
3078 | 3124 | else if (cmd->dma_data_direction == DMA_FROM_DEVICE) |
---|
3079 | 3125 | pkt->flags = cpu_to_le16(CTIO7_FLAGS_DATA_OUT); |
---|
3080 | 3126 | |
---|
3081 | | - pkt->dseg_count = prm->tot_dsds; |
---|
| 3127 | + pkt->dseg_count = cpu_to_le16(prm->tot_dsds); |
---|
3082 | 3128 | /* Fibre channel byte count */ |
---|
3083 | 3129 | pkt->transfer_length = cpu_to_le32(transfer_length); |
---|
3084 | 3130 | |
---|
.. | .. |
---|
3099 | 3145 | |
---|
3100 | 3146 | qla_tgt_set_dif_tags(cmd, crc_ctx_pkt, &fw_prot_opts); |
---|
3101 | 3147 | |
---|
3102 | | - pkt->crc_context_address[0] = cpu_to_le32(LSD(crc_ctx_dma)); |
---|
3103 | | - pkt->crc_context_address[1] = cpu_to_le32(MSD(crc_ctx_dma)); |
---|
3104 | | - pkt->crc_context_len = CRC_CONTEXT_LEN_FW; |
---|
| 3148 | + put_unaligned_le64(crc_ctx_dma, &pkt->crc_context_address); |
---|
| 3149 | + pkt->crc_context_len = cpu_to_le16(CRC_CONTEXT_LEN_FW); |
---|
3105 | 3150 | |
---|
3106 | 3151 | if (!bundling) { |
---|
3107 | | - cur_dsd = (uint32_t *) &crc_ctx_pkt->u.nobundling.data_address; |
---|
| 3152 | + cur_dsd = &crc_ctx_pkt->u.nobundling.data_dsd[0]; |
---|
3108 | 3153 | } else { |
---|
3109 | 3154 | /* |
---|
3110 | 3155 | * Configure Bundling if we need to fetch interlaving |
---|
.. | .. |
---|
3114 | 3159 | crc_ctx_pkt->u.bundling.dif_byte_count = cpu_to_le32(dif_bytes); |
---|
3115 | 3160 | crc_ctx_pkt->u.bundling.dseg_count = |
---|
3116 | 3161 | cpu_to_le16(prm->tot_dsds - prm->prot_seg_cnt); |
---|
3117 | | - cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.data_address; |
---|
| 3162 | + cur_dsd = &crc_ctx_pkt->u.bundling.data_dsd[0]; |
---|
3118 | 3163 | } |
---|
3119 | 3164 | |
---|
3120 | 3165 | /* Finish the common fields of CRC pkt */ |
---|
.. | .. |
---|
3147 | 3192 | /* Walks dif segments */ |
---|
3148 | 3193 | pkt->add_flags |= CTIO_CRC2_AF_DIF_DSD_ENA; |
---|
3149 | 3194 | |
---|
3150 | | - cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.dif_address; |
---|
| 3195 | + cur_dsd = &crc_ctx_pkt->u.bundling.dif_dsd; |
---|
3151 | 3196 | if (qla24xx_walk_and_build_prot_sglist(ha, NULL, cur_dsd, |
---|
3152 | | - prm->prot_seg_cnt, &tc)) |
---|
| 3197 | + prm->prot_seg_cnt, cmd)) |
---|
3153 | 3198 | goto crc_queuing_error; |
---|
3154 | 3199 | } |
---|
3155 | 3200 | return QLA_SUCCESS; |
---|
.. | .. |
---|
3176 | 3221 | unsigned long flags = 0; |
---|
3177 | 3222 | int res; |
---|
3178 | 3223 | |
---|
3179 | | - if (cmd->sess && cmd->sess->deleted) { |
---|
| 3224 | + if (!qpair->fw_started || (cmd->reset_count != qpair->chip_reset) || |
---|
| 3225 | + (cmd->sess && cmd->sess->deleted)) { |
---|
3180 | 3226 | cmd->state = QLA_TGT_STATE_PROCESSED; |
---|
3181 | | - if (cmd->sess->logout_completed) |
---|
3182 | | - /* no need to terminate. FW already freed exchange. */ |
---|
3183 | | - qlt_abort_cmd_on_host_reset(cmd->vha, cmd); |
---|
3184 | | - else |
---|
3185 | | - qlt_send_term_exchange(qpair, cmd, &cmd->atio, 0, 0); |
---|
3186 | 3227 | return 0; |
---|
3187 | 3228 | } |
---|
3188 | 3229 | |
---|
.. | .. |
---|
3211 | 3252 | * previous life, just abort the processing. |
---|
3212 | 3253 | */ |
---|
3213 | 3254 | cmd->state = QLA_TGT_STATE_PROCESSED; |
---|
3214 | | - qlt_abort_cmd_on_host_reset(cmd->vha, cmd); |
---|
3215 | 3255 | ql_dbg_qp(ql_dbg_async, qpair, 0xe101, |
---|
3216 | 3256 | "RESET-RSP online/active/old-count/new-count = %d/%d/%d/%d.\n", |
---|
3217 | 3257 | vha->flags.online, qla2x00_reset_active(vha), |
---|
3218 | 3258 | cmd->reset_count, qpair->chip_reset); |
---|
| 3259 | + res = 0; |
---|
3219 | 3260 | goto out_unmap_unlock; |
---|
3220 | 3261 | } |
---|
3221 | 3262 | |
---|
.. | .. |
---|
3303 | 3344 | |
---|
3304 | 3345 | cmd->state = QLA_TGT_STATE_PROCESSED; /* Mid-level is done processing */ |
---|
3305 | 3346 | cmd->cmd_sent_to_fw = 1; |
---|
| 3347 | + cmd->ctio_flags = le16_to_cpu(pkt->u.status0.flags); |
---|
3306 | 3348 | |
---|
3307 | 3349 | /* Memory Barrier */ |
---|
3308 | 3350 | wmb(); |
---|
.. | .. |
---|
3344 | 3386 | * Either the port is not online or this request was from |
---|
3345 | 3387 | * previous life, just abort the processing. |
---|
3346 | 3388 | */ |
---|
3347 | | - cmd->state = QLA_TGT_STATE_NEED_DATA; |
---|
3348 | | - qlt_abort_cmd_on_host_reset(cmd->vha, cmd); |
---|
| 3389 | + cmd->aborted = 1; |
---|
| 3390 | + cmd->write_data_transferred = 0; |
---|
| 3391 | + cmd->state = QLA_TGT_STATE_DATA_IN; |
---|
| 3392 | + vha->hw->tgt.tgt_ops->handle_data(cmd); |
---|
3349 | 3393 | ql_dbg_qp(ql_dbg_async, qpair, 0xe102, |
---|
3350 | 3394 | "RESET-XFR online/active/old-count/new-count = %d/%d/%d/%d.\n", |
---|
3351 | 3395 | vha->flags.online, qla2x00_reset_active(vha), |
---|
.. | .. |
---|
3381 | 3425 | |
---|
3382 | 3426 | cmd->state = QLA_TGT_STATE_NEED_DATA; |
---|
3383 | 3427 | cmd->cmd_sent_to_fw = 1; |
---|
| 3428 | + cmd->ctio_flags = le16_to_cpu(pkt->u.status0.flags); |
---|
3384 | 3429 | |
---|
3385 | 3430 | /* Memory Barrier */ |
---|
3386 | 3431 | wmb(); |
---|
.. | .. |
---|
3417 | 3462 | |
---|
3418 | 3463 | cmd->trc_flags |= TRC_DIF_ERR; |
---|
3419 | 3464 | |
---|
3420 | | - cmd->a_guard = be16_to_cpu(*(uint16_t *)(ap + 0)); |
---|
3421 | | - cmd->a_app_tag = be16_to_cpu(*(uint16_t *)(ap + 2)); |
---|
3422 | | - cmd->a_ref_tag = be32_to_cpu(*(uint32_t *)(ap + 4)); |
---|
| 3465 | + cmd->a_guard = get_unaligned_be16(ap + 0); |
---|
| 3466 | + cmd->a_app_tag = get_unaligned_be16(ap + 2); |
---|
| 3467 | + cmd->a_ref_tag = get_unaligned_be32(ap + 4); |
---|
3423 | 3468 | |
---|
3424 | | - cmd->e_guard = be16_to_cpu(*(uint16_t *)(ep + 0)); |
---|
3425 | | - cmd->e_app_tag = be16_to_cpu(*(uint16_t *)(ep + 2)); |
---|
3426 | | - cmd->e_ref_tag = be32_to_cpu(*(uint32_t *)(ep + 4)); |
---|
| 3469 | + cmd->e_guard = get_unaligned_be16(ep + 0); |
---|
| 3470 | + cmd->e_app_tag = get_unaligned_be16(ep + 2); |
---|
| 3471 | + cmd->e_ref_tag = get_unaligned_be32(ep + 4); |
---|
3427 | 3472 | |
---|
3428 | 3473 | ql_dbg(ql_dbg_tgt_dif, vha, 0xf075, |
---|
3429 | 3474 | "%s: aborted %d state %d\n", __func__, cmd->aborted, cmd->state); |
---|
.. | .. |
---|
3535 | 3580 | nack->u.isp24.nport_handle = ntfy->u.isp24.nport_handle; |
---|
3536 | 3581 | if (le16_to_cpu(ntfy->u.isp24.status) == IMM_NTFY_ELS) { |
---|
3537 | 3582 | nack->u.isp24.flags = ntfy->u.isp24.flags & |
---|
3538 | | - __constant_cpu_to_le32(NOTIFY24XX_FLAGS_PUREX_IOCB); |
---|
| 3583 | + cpu_to_le16(NOTIFY24XX_FLAGS_PUREX_IOCB); |
---|
3539 | 3584 | } |
---|
3540 | 3585 | |
---|
3541 | 3586 | /* terminate */ |
---|
.. | .. |
---|
3558 | 3603 | static void qlt_send_term_imm_notif(struct scsi_qla_host *vha, |
---|
3559 | 3604 | struct imm_ntfy_from_isp *imm, int ha_locked) |
---|
3560 | 3605 | { |
---|
3561 | | - unsigned long flags = 0; |
---|
3562 | 3606 | int rc; |
---|
3563 | 3607 | |
---|
3564 | | - if (ha_locked) { |
---|
3565 | | - rc = __qlt_send_term_imm_notif(vha, imm); |
---|
3566 | | - |
---|
3567 | | -#if 0 /* Todo */ |
---|
3568 | | - if (rc == -ENOMEM) |
---|
3569 | | - qlt_alloc_qfull_cmd(vha, imm, 0, 0); |
---|
3570 | | -#else |
---|
3571 | | - if (rc) { |
---|
3572 | | - } |
---|
3573 | | -#endif |
---|
3574 | | - goto done; |
---|
3575 | | - } |
---|
3576 | | - |
---|
3577 | | - spin_lock_irqsave(&vha->hw->hardware_lock, flags); |
---|
| 3608 | + WARN_ON_ONCE(!ha_locked); |
---|
3578 | 3609 | rc = __qlt_send_term_imm_notif(vha, imm); |
---|
3579 | | - |
---|
3580 | | -#if 0 /* Todo */ |
---|
3581 | | - if (rc == -ENOMEM) |
---|
3582 | | - qlt_alloc_qfull_cmd(vha, imm, 0, 0); |
---|
3583 | | -#endif |
---|
3584 | | - |
---|
3585 | | -done: |
---|
3586 | | - if (!ha_locked) |
---|
3587 | | - spin_unlock_irqrestore(&vha->hw->hardware_lock, flags); |
---|
| 3610 | + pr_debug("rc = %d\n", rc); |
---|
3588 | 3611 | } |
---|
3589 | 3612 | |
---|
3590 | 3613 | /* |
---|
.. | .. |
---|
3631 | 3654 | |
---|
3632 | 3655 | ctio24 = (struct ctio7_to_24xx *)pkt; |
---|
3633 | 3656 | ctio24->entry_type = CTIO_TYPE7; |
---|
3634 | | - ctio24->nport_handle = CTIO7_NHANDLE_UNRECOGNIZED; |
---|
| 3657 | + ctio24->nport_handle = cpu_to_le16(CTIO7_NHANDLE_UNRECOGNIZED); |
---|
3635 | 3658 | ctio24->timeout = cpu_to_le16(QLA_TGT_TIMEOUT); |
---|
3636 | 3659 | ctio24->vp_index = vha->vp_idx; |
---|
3637 | | - ctio24->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2]; |
---|
3638 | | - ctio24->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1]; |
---|
3639 | | - ctio24->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0]; |
---|
| 3660 | + ctio24->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id); |
---|
3640 | 3661 | ctio24->exchange_addr = atio->u.isp24.exchange_addr; |
---|
3641 | 3662 | temp = (atio->u.isp24.attr << 9) | CTIO7_FLAGS_STATUS_MODE_1 | |
---|
3642 | 3663 | CTIO7_FLAGS_TERMINATE; |
---|
.. | .. |
---|
3752 | 3773 | |
---|
3753 | 3774 | spin_lock_irqsave(&cmd->cmd_lock, flags); |
---|
3754 | 3775 | if (cmd->aborted) { |
---|
| 3776 | + if (cmd->sg_mapped) |
---|
| 3777 | + qlt_unmap_sg(vha, cmd); |
---|
| 3778 | + |
---|
3755 | 3779 | spin_unlock_irqrestore(&cmd->cmd_lock, flags); |
---|
3756 | 3780 | /* |
---|
3757 | 3781 | * It's normal to see 2 calls in this path: |
---|
.. | .. |
---|
3762 | 3786 | "multiple abort. %p transport_state %x, t_state %x, " |
---|
3763 | 3787 | "se_cmd_flags %x\n", cmd, cmd->se_cmd.transport_state, |
---|
3764 | 3788 | cmd->se_cmd.t_state, cmd->se_cmd.se_cmd_flags); |
---|
3765 | | - return EIO; |
---|
| 3789 | + return -EIO; |
---|
3766 | 3790 | } |
---|
3767 | 3791 | cmd->aborted = 1; |
---|
3768 | 3792 | cmd->trc_flags |= TRC_ABORT; |
---|
.. | .. |
---|
3797 | 3821 | return; |
---|
3798 | 3822 | } |
---|
3799 | 3823 | cmd->jiffies_at_free = get_jiffies_64(); |
---|
3800 | | - target_free_tag(sess->se_sess, &cmd->se_cmd); |
---|
| 3824 | + cmd->vha->hw->tgt.tgt_ops->rel_cmd(cmd); |
---|
3801 | 3825 | } |
---|
3802 | 3826 | EXPORT_SYMBOL(qlt_free_cmd); |
---|
3803 | 3827 | |
---|
.. | .. |
---|
3822 | 3846 | |
---|
3823 | 3847 | if (ctio != NULL) { |
---|
3824 | 3848 | struct ctio7_from_24xx *c = (struct ctio7_from_24xx *)ctio; |
---|
| 3849 | + |
---|
3825 | 3850 | term = !(c->flags & |
---|
3826 | 3851 | cpu_to_le16(OF_TERM_EXCH)); |
---|
3827 | 3852 | } else |
---|
.. | .. |
---|
3835 | 3860 | |
---|
3836 | 3861 | |
---|
3837 | 3862 | /* ha->hardware_lock supposed to be held on entry */ |
---|
3838 | | -static struct qla_tgt_cmd *qlt_ctio_to_cmd(struct scsi_qla_host *vha, |
---|
| 3863 | +static void *qlt_ctio_to_cmd(struct scsi_qla_host *vha, |
---|
3839 | 3864 | struct rsp_que *rsp, uint32_t handle, void *ctio) |
---|
3840 | 3865 | { |
---|
3841 | | - struct qla_tgt_cmd *cmd = NULL; |
---|
| 3866 | + void *cmd = NULL; |
---|
3842 | 3867 | struct req_que *req; |
---|
3843 | 3868 | int qid = GET_QID(handle); |
---|
3844 | 3869 | uint32_t h = handle & ~QLA_TGT_HANDLE_MASK; |
---|
.. | .. |
---|
3867 | 3892 | return NULL; |
---|
3868 | 3893 | } |
---|
3869 | 3894 | |
---|
3870 | | - cmd = (struct qla_tgt_cmd *)req->outstanding_cmds[h]; |
---|
| 3895 | + cmd = req->outstanding_cmds[h]; |
---|
3871 | 3896 | if (unlikely(cmd == NULL)) { |
---|
3872 | 3897 | ql_dbg(ql_dbg_async, vha, 0xe053, |
---|
3873 | 3898 | "qla_target(%d): Suspicious: unable to find the command with handle %x req->id %d rsp->id %d\n", |
---|
.. | .. |
---|
3884 | 3909 | } |
---|
3885 | 3910 | |
---|
3886 | 3911 | return cmd; |
---|
3887 | | -} |
---|
3888 | | - |
---|
3889 | | -/* hardware_lock should be held by caller. */ |
---|
3890 | | -void |
---|
3891 | | -qlt_abort_cmd_on_host_reset(struct scsi_qla_host *vha, struct qla_tgt_cmd *cmd) |
---|
3892 | | -{ |
---|
3893 | | - struct qla_hw_data *ha = vha->hw; |
---|
3894 | | - |
---|
3895 | | - if (cmd->sg_mapped) |
---|
3896 | | - qlt_unmap_sg(vha, cmd); |
---|
3897 | | - |
---|
3898 | | - /* TODO: fix debug message type and ids. */ |
---|
3899 | | - if (cmd->state == QLA_TGT_STATE_PROCESSED) { |
---|
3900 | | - ql_dbg(ql_dbg_io, vha, 0xff00, |
---|
3901 | | - "HOST-ABORT: state=PROCESSED.\n"); |
---|
3902 | | - } else if (cmd->state == QLA_TGT_STATE_NEED_DATA) { |
---|
3903 | | - cmd->write_data_transferred = 0; |
---|
3904 | | - cmd->state = QLA_TGT_STATE_DATA_IN; |
---|
3905 | | - |
---|
3906 | | - ql_dbg(ql_dbg_io, vha, 0xff01, |
---|
3907 | | - "HOST-ABORT: state=DATA_IN.\n"); |
---|
3908 | | - |
---|
3909 | | - ha->tgt.tgt_ops->handle_data(cmd); |
---|
3910 | | - return; |
---|
3911 | | - } else { |
---|
3912 | | - ql_dbg(ql_dbg_io, vha, 0xff03, |
---|
3913 | | - "HOST-ABORT: state=BAD(%d).\n", |
---|
3914 | | - cmd->state); |
---|
3915 | | - dump_stack(); |
---|
3916 | | - } |
---|
3917 | | - |
---|
3918 | | - cmd->trc_flags |= TRC_FLUSH; |
---|
3919 | | - ha->tgt.tgt_ops->free_cmd(cmd); |
---|
3920 | 3912 | } |
---|
3921 | 3913 | |
---|
3922 | 3914 | /* |
---|
.. | .. |
---|
3951 | 3943 | |
---|
3952 | 3944 | if (unlikely(status != CTIO_SUCCESS)) { |
---|
3953 | 3945 | switch (status & 0xFFFF) { |
---|
| 3946 | + case CTIO_INVALID_RX_ID: |
---|
| 3947 | + if (printk_ratelimit()) |
---|
| 3948 | + dev_info(&vha->hw->pdev->dev, |
---|
| 3949 | + "qla_target(%d): CTIO with INVALID_RX_ID ATIO attr %x CTIO Flags %x|%x\n", |
---|
| 3950 | + vha->vp_idx, cmd->atio.u.isp24.attr, |
---|
| 3951 | + ((cmd->ctio_flags >> 9) & 0xf), |
---|
| 3952 | + cmd->ctio_flags); |
---|
| 3953 | + |
---|
| 3954 | + break; |
---|
3954 | 3955 | case CTIO_LIP_RESET: |
---|
3955 | 3956 | case CTIO_TARGET_RESET: |
---|
3956 | 3957 | case CTIO_ABORTED: |
---|
3957 | 3958 | /* driver request abort via Terminate exchange */ |
---|
3958 | 3959 | case CTIO_TIMEOUT: |
---|
3959 | | - case CTIO_INVALID_RX_ID: |
---|
3960 | 3960 | /* They are OK */ |
---|
3961 | 3961 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf058, |
---|
3962 | 3962 | "qla_target(%d): CTIO with " |
---|
.. | .. |
---|
3983 | 3983 | * Session is already logged out, but we need |
---|
3984 | 3984 | * to notify initiator, who's not aware of this |
---|
3985 | 3985 | */ |
---|
3986 | | - cmd->sess->logout_on_delete = 0; |
---|
3987 | 3986 | cmd->sess->send_els_logo = 1; |
---|
3988 | 3987 | ql_dbg(ql_dbg_disc, vha, 0x20f8, |
---|
3989 | 3988 | "%s %d %8phC post del sess\n", |
---|
.. | .. |
---|
4091 | 4090 | return fcp_task_attr; |
---|
4092 | 4091 | } |
---|
4093 | 4092 | |
---|
4094 | | -static struct fc_port *qlt_make_local_sess(struct scsi_qla_host *, |
---|
4095 | | - uint8_t *); |
---|
4096 | 4093 | /* |
---|
4097 | 4094 | * Process context for I/O path into tcm_qla2xxx code |
---|
4098 | 4095 | */ |
---|
.. | .. |
---|
4120 | 4117 | |
---|
4121 | 4118 | spin_lock_init(&cmd->cmd_lock); |
---|
4122 | 4119 | cdb = &atio->u.isp24.fcp_cmnd.cdb[0]; |
---|
4123 | | - cmd->se_cmd.tag = atio->u.isp24.exchange_addr; |
---|
| 4120 | + cmd->se_cmd.tag = le32_to_cpu(atio->u.isp24.exchange_addr); |
---|
4124 | 4121 | |
---|
4125 | 4122 | if (atio->u.isp24.fcp_cmnd.rddata && |
---|
4126 | 4123 | atio->u.isp24.fcp_cmnd.wrdata) { |
---|
.. | .. |
---|
4142 | 4139 | if (ret != 0) |
---|
4143 | 4140 | goto out_term; |
---|
4144 | 4141 | /* |
---|
4145 | | - * Drop extra session reference from qla_tgt_handle_cmd_for_atio*( |
---|
| 4142 | + * Drop extra session reference from qlt_handle_cmd_for_atio(). |
---|
4146 | 4143 | */ |
---|
4147 | 4144 | ha->tgt.tgt_ops->put_sess(sess); |
---|
4148 | 4145 | return; |
---|
.. | .. |
---|
4158 | 4155 | qlt_send_term_exchange(qpair, NULL, &cmd->atio, 1, 0); |
---|
4159 | 4156 | |
---|
4160 | 4157 | qlt_decr_num_pend_cmds(vha); |
---|
4161 | | - target_free_tag(sess->se_sess, &cmd->se_cmd); |
---|
| 4158 | + cmd->vha->hw->tgt.tgt_ops->rel_cmd(cmd); |
---|
4162 | 4159 | spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); |
---|
4163 | 4160 | |
---|
4164 | 4161 | ha->tgt.tgt_ops->put_sess(sess); |
---|
.. | .. |
---|
4285 | 4282 | struct fc_port *sess, |
---|
4286 | 4283 | struct atio_from_isp *atio) |
---|
4287 | 4284 | { |
---|
4288 | | - struct se_session *se_sess = sess->se_sess; |
---|
4289 | 4285 | struct qla_tgt_cmd *cmd; |
---|
4290 | | - int tag, cpu; |
---|
4291 | 4286 | |
---|
4292 | | - tag = sbitmap_queue_get(&se_sess->sess_tag_pool, &cpu); |
---|
4293 | | - if (tag < 0) |
---|
| 4287 | + cmd = vha->hw->tgt.tgt_ops->get_cmd(sess); |
---|
| 4288 | + if (!cmd) |
---|
4294 | 4289 | return NULL; |
---|
4295 | 4290 | |
---|
4296 | | - cmd = &((struct qla_tgt_cmd *)se_sess->sess_cmd_map)[tag]; |
---|
4297 | | - memset(cmd, 0, sizeof(struct qla_tgt_cmd)); |
---|
4298 | 4291 | cmd->cmd_type = TYPE_TGT_CMD; |
---|
4299 | 4292 | memcpy(&cmd->atio, atio, sizeof(*atio)); |
---|
4300 | 4293 | cmd->state = QLA_TGT_STATE_NEW; |
---|
4301 | 4294 | cmd->tgt = vha->vha_tgt.qla_tgt; |
---|
4302 | 4295 | qlt_incr_num_pend_cmds(vha); |
---|
4303 | 4296 | cmd->vha = vha; |
---|
4304 | | - cmd->se_cmd.map_tag = tag; |
---|
4305 | | - cmd->se_cmd.map_cpu = cpu; |
---|
4306 | 4297 | cmd->sess = sess; |
---|
4307 | 4298 | cmd->loop_id = sess->loop_id; |
---|
4308 | 4299 | cmd->conf_compl_supported = sess->conf_compl_supported; |
---|
.. | .. |
---|
4336 | 4327 | return -ENODEV; |
---|
4337 | 4328 | } |
---|
4338 | 4329 | |
---|
4339 | | - id.b.al_pa = atio->u.isp24.fcp_hdr.s_id[2]; |
---|
4340 | | - id.b.area = atio->u.isp24.fcp_hdr.s_id[1]; |
---|
4341 | | - id.b.domain = atio->u.isp24.fcp_hdr.s_id[0]; |
---|
| 4330 | + id = be_to_port_id(atio->u.isp24.fcp_hdr.s_id); |
---|
4342 | 4331 | if (IS_SW_RESV_ADDR(id)) |
---|
4343 | 4332 | return -EBUSY; |
---|
4344 | 4333 | |
---|
.. | .. |
---|
4436 | 4425 | case QLA_TGT_CLEAR_TS: |
---|
4437 | 4426 | case QLA_TGT_ABORT_TS: |
---|
4438 | 4427 | abort_cmds_for_lun(vha, lun, a->u.isp24.fcp_hdr.s_id); |
---|
4439 | | - /* drop through */ |
---|
| 4428 | + fallthrough; |
---|
4440 | 4429 | case QLA_TGT_CLEAR_ACA: |
---|
4441 | 4430 | h = qlt_find_qphint(vha, mcmd->unpacked_lun); |
---|
4442 | 4431 | mcmd->qpair = h->qpair; |
---|
.. | .. |
---|
4600 | 4589 | /* find other sess with nport_id collision */ |
---|
4601 | 4590 | if (port_id.b24 == other_sess->d_id.b24) { |
---|
4602 | 4591 | if (loop_id != other_sess->loop_id) { |
---|
4603 | | - ql_dbg(ql_dbg_tgt_tmr, vha, 0x1000c, |
---|
| 4592 | + ql_dbg(ql_dbg_disc, vha, 0x1000c, |
---|
4604 | 4593 | "Invalidating sess %p loop_id %d wwn %llx.\n", |
---|
4605 | 4594 | other_sess, other_sess->loop_id, other_wwn); |
---|
4606 | 4595 | |
---|
.. | .. |
---|
4616 | 4605 | * Another wwn used to have our s_id/loop_id |
---|
4617 | 4606 | * kill the session, but don't free the loop_id |
---|
4618 | 4607 | */ |
---|
4619 | | - ql_dbg(ql_dbg_tgt_tmr, vha, 0xf01b, |
---|
| 4608 | + ql_dbg(ql_dbg_disc, vha, 0xf01b, |
---|
4620 | 4609 | "Invalidating sess %p loop_id %d wwn %llx.\n", |
---|
4621 | 4610 | other_sess, other_sess->loop_id, other_wwn); |
---|
4622 | 4611 | |
---|
.. | .. |
---|
4631 | 4620 | /* find other sess with nport handle collision */ |
---|
4632 | 4621 | if ((loop_id == other_sess->loop_id) && |
---|
4633 | 4622 | (loop_id != FC_NO_LOOP_ID)) { |
---|
4634 | | - ql_dbg(ql_dbg_tgt_tmr, vha, 0x1000d, |
---|
| 4623 | + ql_dbg(ql_dbg_disc, vha, 0x1000d, |
---|
4635 | 4624 | "Invalidating sess %p loop_id %d wwn %llx.\n", |
---|
4636 | 4625 | other_sess, other_sess->loop_id, other_wwn); |
---|
4637 | 4626 | |
---|
.. | .. |
---|
4669 | 4658 | |
---|
4670 | 4659 | list_for_each_entry(op, &vha->unknown_atio_list, cmd_list) { |
---|
4671 | 4660 | uint32_t op_key = sid_to_key(op->atio.u.isp24.fcp_hdr.s_id); |
---|
| 4661 | + |
---|
4672 | 4662 | if (op_key == key) { |
---|
4673 | 4663 | op->aborted = true; |
---|
4674 | 4664 | count++; |
---|
.. | .. |
---|
4677 | 4667 | |
---|
4678 | 4668 | list_for_each_entry(cmd, &vha->qla_cmd_list, cmd_list) { |
---|
4679 | 4669 | uint32_t cmd_key = sid_to_key(cmd->atio.u.isp24.fcp_hdr.s_id); |
---|
| 4670 | + |
---|
4680 | 4671 | if (cmd_key == key) { |
---|
4681 | 4672 | cmd->aborted = 1; |
---|
4682 | 4673 | count++; |
---|
.. | .. |
---|
4697 | 4688 | int res = 0; |
---|
4698 | 4689 | struct qlt_plogi_ack_t *pla; |
---|
4699 | 4690 | unsigned long flags; |
---|
| 4691 | + |
---|
| 4692 | + lockdep_assert_held(&vha->hw->hardware_lock); |
---|
4700 | 4693 | |
---|
4701 | 4694 | wwn = wwn_to_u64(iocb->u.isp24.port_name); |
---|
4702 | 4695 | |
---|
.. | .. |
---|
4753 | 4746 | qla24xx_post_newsess_work(vha, &port_id, |
---|
4754 | 4747 | iocb->u.isp24.port_name, |
---|
4755 | 4748 | iocb->u.isp24.u.plogi.node_name, |
---|
4756 | | - pla, FC4_TYPE_UNKNOWN); |
---|
| 4749 | + pla, 0); |
---|
4757 | 4750 | else |
---|
4758 | 4751 | qla24xx_post_newsess_work(vha, &port_id, |
---|
4759 | 4752 | iocb->u.isp24.port_name, NULL, |
---|
4760 | | - pla, FC4_TYPE_UNKNOWN); |
---|
| 4753 | + pla, 0); |
---|
4761 | 4754 | |
---|
4762 | 4755 | goto out; |
---|
4763 | 4756 | } |
---|
.. | .. |
---|
4781 | 4774 | __func__, sess->port_name, sec); |
---|
4782 | 4775 | } |
---|
4783 | 4776 | |
---|
4784 | | - if (!conflict_sess) |
---|
| 4777 | + if (!conflict_sess) { |
---|
| 4778 | + list_del(&pla->list); |
---|
4785 | 4779 | kmem_cache_free(qla_tgt_plogi_cachep, pla); |
---|
| 4780 | + } |
---|
4786 | 4781 | |
---|
4787 | 4782 | qlt_send_term_imm_notif(vha, iocb, 1); |
---|
4788 | 4783 | goto out; |
---|
.. | .. |
---|
4872 | 4867 | int res = 0; |
---|
4873 | 4868 | unsigned long flags; |
---|
4874 | 4869 | |
---|
| 4870 | + lockdep_assert_held(&ha->hardware_lock); |
---|
| 4871 | + |
---|
4875 | 4872 | wwn = wwn_to_u64(iocb->u.isp24.port_name); |
---|
4876 | 4873 | |
---|
4877 | 4874 | port_id.b.domain = iocb->u.isp24.port_id[2]; |
---|
.. | .. |
---|
4948 | 4945 | if (sess != NULL) { |
---|
4949 | 4946 | bool delete = false; |
---|
4950 | 4947 | int sec; |
---|
| 4948 | + |
---|
4951 | 4949 | spin_lock_irqsave(&tgt->ha->tgt.sess_lock, flags); |
---|
4952 | 4950 | switch (sess->fw_login_state) { |
---|
4953 | 4951 | case DSC_LS_PLOGI_PEND: |
---|
.. | .. |
---|
5061 | 5059 | res = 1; |
---|
5062 | 5060 | break; |
---|
5063 | 5061 | } |
---|
5064 | | - /* fall through */ |
---|
| 5062 | + fallthrough; |
---|
5065 | 5063 | case ELS_LOGO: |
---|
5066 | 5064 | case ELS_PRLO: |
---|
5067 | 5065 | spin_lock_irqsave(&ha->tgt.sess_lock, flags); |
---|
.. | .. |
---|
5100 | 5098 | case ELS_ADISC: |
---|
5101 | 5099 | { |
---|
5102 | 5100 | struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; |
---|
| 5101 | + |
---|
5103 | 5102 | if (tgt->link_reinit_iocb_pending) { |
---|
5104 | 5103 | qlt_send_notify_ack(ha->base_qpair, |
---|
5105 | 5104 | &tgt->link_reinit_iocb, 0, 0, 0, 0, 0, 0); |
---|
.. | .. |
---|
5146 | 5145 | int send_notify_ack = 1; |
---|
5147 | 5146 | uint16_t status; |
---|
5148 | 5147 | |
---|
| 5148 | + lockdep_assert_held(&ha->hardware_lock); |
---|
| 5149 | + |
---|
5149 | 5150 | status = le16_to_cpu(iocb->u.isp2x.status); |
---|
5150 | 5151 | switch (status) { |
---|
5151 | 5152 | case IMM_NTFY_LIP_RESET: |
---|
.. | .. |
---|
5163 | 5164 | case IMM_NTFY_LIP_LINK_REINIT: |
---|
5164 | 5165 | { |
---|
5165 | 5166 | struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; |
---|
| 5167 | + |
---|
5166 | 5168 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf033, |
---|
5167 | 5169 | "qla_target(%d): LINK REINIT (loop %#x, " |
---|
5168 | 5170 | "subcode %x)\n", vha->vp_idx, |
---|
.. | .. |
---|
5282 | 5284 | u16 temp; |
---|
5283 | 5285 | port_id_t id; |
---|
5284 | 5286 | |
---|
5285 | | - id.b.al_pa = atio->u.isp24.fcp_hdr.s_id[2]; |
---|
5286 | | - id.b.area = atio->u.isp24.fcp_hdr.s_id[1]; |
---|
5287 | | - id.b.domain = atio->u.isp24.fcp_hdr.s_id[0]; |
---|
5288 | | - id.b.rsvd_1 = 0; |
---|
| 5287 | + id = be_to_port_id(atio->u.isp24.fcp_hdr.s_id); |
---|
5289 | 5288 | |
---|
5290 | 5289 | spin_lock_irqsave(&ha->tgt.sess_lock, flags); |
---|
5291 | 5290 | sess = qla2x00_find_fcport_by_nportid(vha, &id, 1); |
---|
.. | .. |
---|
5310 | 5309 | |
---|
5311 | 5310 | ctio24 = (struct ctio7_to_24xx *)pkt; |
---|
5312 | 5311 | ctio24->entry_type = CTIO_TYPE7; |
---|
5313 | | - ctio24->nport_handle = sess->loop_id; |
---|
| 5312 | + ctio24->nport_handle = cpu_to_le16(sess->loop_id); |
---|
5314 | 5313 | ctio24->timeout = cpu_to_le16(QLA_TGT_TIMEOUT); |
---|
5315 | 5314 | ctio24->vp_index = vha->vp_idx; |
---|
5316 | | - ctio24->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2]; |
---|
5317 | | - ctio24->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1]; |
---|
5318 | | - ctio24->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0]; |
---|
| 5315 | + ctio24->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id); |
---|
5319 | 5316 | ctio24->exchange_addr = atio->u.isp24.exchange_addr; |
---|
5320 | 5317 | temp = (atio->u.isp24.attr << 9) | |
---|
5321 | 5318 | CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_SEND_STATUS | |
---|
.. | .. |
---|
5325 | 5322 | * CTIO from fw w/o se_cmd doesn't provide enough info to retry it, |
---|
5326 | 5323 | * if the explicit conformation is used. |
---|
5327 | 5324 | */ |
---|
5328 | | - ctio24->u.status1.ox_id = swab16(atio->u.isp24.fcp_hdr.ox_id); |
---|
| 5325 | + ctio24->u.status1.ox_id = |
---|
| 5326 | + cpu_to_le16(be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id)); |
---|
5329 | 5327 | ctio24->u.status1.scsi_status = cpu_to_le16(status); |
---|
5330 | 5328 | |
---|
5331 | | - ctio24->u.status1.residual = get_datalen_for_atio(atio); |
---|
| 5329 | + ctio24->u.status1.residual = cpu_to_le32(get_datalen_for_atio(atio)); |
---|
5332 | 5330 | |
---|
5333 | 5331 | if (ctio24->u.status1.residual != 0) |
---|
5334 | | - ctio24->u.status1.scsi_status |= SS_RESIDUAL_UNDER; |
---|
| 5332 | + ctio24->u.status1.scsi_status |= cpu_to_le16(SS_RESIDUAL_UNDER); |
---|
5335 | 5333 | |
---|
5336 | 5334 | /* Memory Barrier */ |
---|
5337 | 5335 | wmb(); |
---|
.. | .. |
---|
5354 | 5352 | struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; |
---|
5355 | 5353 | struct qla_hw_data *ha = vha->hw; |
---|
5356 | 5354 | struct fc_port *sess; |
---|
5357 | | - struct se_session *se_sess; |
---|
5358 | 5355 | struct qla_tgt_cmd *cmd; |
---|
5359 | | - int tag, cpu; |
---|
5360 | 5356 | unsigned long flags; |
---|
5361 | 5357 | |
---|
5362 | 5358 | if (unlikely(tgt->tgt_stop)) { |
---|
.. | .. |
---|
5386 | 5382 | if (!sess) |
---|
5387 | 5383 | return; |
---|
5388 | 5384 | |
---|
5389 | | - se_sess = sess->se_sess; |
---|
5390 | | - |
---|
5391 | | - tag = sbitmap_queue_get(&se_sess->sess_tag_pool, &cpu); |
---|
5392 | | - if (tag < 0) { |
---|
| 5385 | + cmd = ha->tgt.tgt_ops->get_cmd(sess); |
---|
| 5386 | + if (!cmd) { |
---|
5393 | 5387 | ql_dbg(ql_dbg_io, vha, 0x3009, |
---|
5394 | 5388 | "qla_target(%d): %s: Allocation of cmd failed\n", |
---|
5395 | 5389 | vha->vp_idx, __func__); |
---|
.. | .. |
---|
5404 | 5398 | return; |
---|
5405 | 5399 | } |
---|
5406 | 5400 | |
---|
5407 | | - cmd = &((struct qla_tgt_cmd *)se_sess->sess_cmd_map)[tag]; |
---|
5408 | | - memset(cmd, 0, sizeof(struct qla_tgt_cmd)); |
---|
5409 | | - |
---|
5410 | 5401 | qlt_incr_num_pend_cmds(vha); |
---|
5411 | 5402 | INIT_LIST_HEAD(&cmd->cmd_list); |
---|
5412 | 5403 | memcpy(&cmd->atio, atio, sizeof(*atio)); |
---|
.. | .. |
---|
5416 | 5407 | cmd->reset_count = ha->base_qpair->chip_reset; |
---|
5417 | 5408 | cmd->q_full = 1; |
---|
5418 | 5409 | cmd->qpair = ha->base_qpair; |
---|
5419 | | - cmd->se_cmd.map_cpu = cpu; |
---|
5420 | 5410 | |
---|
5421 | 5411 | if (qfull) { |
---|
5422 | 5412 | cmd->q_full = 1; |
---|
.. | .. |
---|
5568 | 5558 | switch (atio->u.raw.entry_type) { |
---|
5569 | 5559 | case ATIO_TYPE7: |
---|
5570 | 5560 | if (unlikely(atio->u.isp24.exchange_addr == |
---|
5571 | | - ATIO_EXCHANGE_ADDRESS_UNKNOWN)) { |
---|
| 5561 | + cpu_to_le32(ATIO_EXCHANGE_ADDRESS_UNKNOWN))) { |
---|
5572 | 5562 | ql_dbg(ql_dbg_io, vha, 0x3065, |
---|
5573 | 5563 | "qla_target(%d): ATIO_TYPE7 " |
---|
5574 | 5564 | "received with UNKNOWN exchange address, " |
---|
.. | .. |
---|
5658 | 5648 | tgt->atio_irq_cmd_count--; |
---|
5659 | 5649 | } |
---|
5660 | 5650 | |
---|
| 5651 | +/* |
---|
| 5652 | + * qpair lock is assume to be held |
---|
| 5653 | + * rc = 0 : send terminate & abts respond |
---|
| 5654 | + * rc != 0: do not send term & abts respond |
---|
| 5655 | + */ |
---|
| 5656 | +static int qlt_chk_unresolv_exchg(struct scsi_qla_host *vha, |
---|
| 5657 | + struct qla_qpair *qpair, struct abts_resp_from_24xx_fw *entry) |
---|
| 5658 | +{ |
---|
| 5659 | + struct qla_hw_data *ha = vha->hw; |
---|
| 5660 | + int rc = 0; |
---|
| 5661 | + |
---|
| 5662 | + /* |
---|
| 5663 | + * Detect unresolved exchange. If the same ABTS is unable |
---|
| 5664 | + * to terminate an existing command and the same ABTS loops |
---|
| 5665 | + * between FW & Driver, then force FW dump. Under 1 jiff, |
---|
| 5666 | + * we should see multiple loops. |
---|
| 5667 | + */ |
---|
| 5668 | + if (qpair->retry_term_exchg_addr == entry->exchange_addr_to_abort && |
---|
| 5669 | + qpair->retry_term_jiff == jiffies) { |
---|
| 5670 | + /* found existing exchange */ |
---|
| 5671 | + qpair->retry_term_cnt++; |
---|
| 5672 | + if (qpair->retry_term_cnt >= 5) { |
---|
| 5673 | + rc = -EIO; |
---|
| 5674 | + qpair->retry_term_cnt = 0; |
---|
| 5675 | + ql_log(ql_log_warn, vha, 0xffff, |
---|
| 5676 | + "Unable to send ABTS Respond. Dumping firmware.\n"); |
---|
| 5677 | + ql_dump_buffer(ql_dbg_tgt_mgt + ql_dbg_buffer, |
---|
| 5678 | + vha, 0xffff, (uint8_t *)entry, sizeof(*entry)); |
---|
| 5679 | + |
---|
| 5680 | + if (qpair == ha->base_qpair) |
---|
| 5681 | + ha->isp_ops->fw_dump(vha); |
---|
| 5682 | + else |
---|
| 5683 | + qla2xxx_dump_fw(vha); |
---|
| 5684 | + |
---|
| 5685 | + set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
---|
| 5686 | + qla2xxx_wake_dpc(vha); |
---|
| 5687 | + } |
---|
| 5688 | + } else if (qpair->retry_term_jiff != jiffies) { |
---|
| 5689 | + qpair->retry_term_exchg_addr = entry->exchange_addr_to_abort; |
---|
| 5690 | + qpair->retry_term_cnt = 0; |
---|
| 5691 | + qpair->retry_term_jiff = jiffies; |
---|
| 5692 | + } |
---|
| 5693 | + |
---|
| 5694 | + return rc; |
---|
| 5695 | +} |
---|
| 5696 | + |
---|
| 5697 | + |
---|
| 5698 | +static void qlt_handle_abts_completion(struct scsi_qla_host *vha, |
---|
| 5699 | + struct rsp_que *rsp, response_t *pkt) |
---|
| 5700 | +{ |
---|
| 5701 | + struct abts_resp_from_24xx_fw *entry = |
---|
| 5702 | + (struct abts_resp_from_24xx_fw *)pkt; |
---|
| 5703 | + u32 h = pkt->handle & ~QLA_TGT_HANDLE_MASK; |
---|
| 5704 | + struct qla_tgt_mgmt_cmd *mcmd; |
---|
| 5705 | + struct qla_hw_data *ha = vha->hw; |
---|
| 5706 | + |
---|
| 5707 | + mcmd = qlt_ctio_to_cmd(vha, rsp, pkt->handle, pkt); |
---|
| 5708 | + if (mcmd == NULL && h != QLA_TGT_SKIP_HANDLE) { |
---|
| 5709 | + ql_dbg(ql_dbg_async, vha, 0xe064, |
---|
| 5710 | + "qla_target(%d): ABTS Comp without mcmd\n", |
---|
| 5711 | + vha->vp_idx); |
---|
| 5712 | + return; |
---|
| 5713 | + } |
---|
| 5714 | + |
---|
| 5715 | + if (mcmd) |
---|
| 5716 | + vha = mcmd->vha; |
---|
| 5717 | + vha->vha_tgt.qla_tgt->abts_resp_expected--; |
---|
| 5718 | + |
---|
| 5719 | + ql_dbg(ql_dbg_tgt, vha, 0xe038, |
---|
| 5720 | + "ABTS_RESP_24XX: compl_status %x\n", |
---|
| 5721 | + entry->compl_status); |
---|
| 5722 | + |
---|
| 5723 | + if (le16_to_cpu(entry->compl_status) != ABTS_RESP_COMPL_SUCCESS) { |
---|
| 5724 | + if (le32_to_cpu(entry->error_subcode1) == 0x1E && |
---|
| 5725 | + le32_to_cpu(entry->error_subcode2) == 0) { |
---|
| 5726 | + if (qlt_chk_unresolv_exchg(vha, rsp->qpair, entry)) { |
---|
| 5727 | + ha->tgt.tgt_ops->free_mcmd(mcmd); |
---|
| 5728 | + return; |
---|
| 5729 | + } |
---|
| 5730 | + qlt_24xx_retry_term_exchange(vha, rsp->qpair, |
---|
| 5731 | + pkt, mcmd); |
---|
| 5732 | + } else { |
---|
| 5733 | + ql_dbg(ql_dbg_tgt, vha, 0xe063, |
---|
| 5734 | + "qla_target(%d): ABTS_RESP_24XX failed %x (subcode %x:%x)", |
---|
| 5735 | + vha->vp_idx, entry->compl_status, |
---|
| 5736 | + entry->error_subcode1, |
---|
| 5737 | + entry->error_subcode2); |
---|
| 5738 | + ha->tgt.tgt_ops->free_mcmd(mcmd); |
---|
| 5739 | + } |
---|
| 5740 | + } else if (mcmd) { |
---|
| 5741 | + ha->tgt.tgt_ops->free_mcmd(mcmd); |
---|
| 5742 | + } |
---|
| 5743 | +} |
---|
| 5744 | + |
---|
5661 | 5745 | /* ha->hardware_lock supposed to be held on entry */ |
---|
5662 | 5746 | /* called via callback from qla2xxx */ |
---|
5663 | 5747 | static void qlt_response_pkt(struct scsi_qla_host *vha, |
---|
.. | .. |
---|
5682 | 5766 | case CTIO_TYPE7: |
---|
5683 | 5767 | { |
---|
5684 | 5768 | struct ctio7_from_24xx *entry = (struct ctio7_from_24xx *)pkt; |
---|
| 5769 | + |
---|
5685 | 5770 | qlt_do_ctio_completion(vha, rsp, entry->handle, |
---|
5686 | 5771 | le16_to_cpu(entry->status)|(pkt->entry_status << 16), |
---|
5687 | 5772 | entry); |
---|
.. | .. |
---|
5692 | 5777 | { |
---|
5693 | 5778 | struct atio_from_isp *atio = (struct atio_from_isp *)pkt; |
---|
5694 | 5779 | int rc; |
---|
| 5780 | + |
---|
5695 | 5781 | if (atio->u.isp2x.status != |
---|
5696 | 5782 | cpu_to_le16(ATIO_CDB_VALID)) { |
---|
5697 | 5783 | ql_dbg(ql_dbg_tgt, vha, 0xe05e, |
---|
.. | .. |
---|
5740 | 5826 | case CONTINUE_TGT_IO_TYPE: |
---|
5741 | 5827 | { |
---|
5742 | 5828 | struct ctio_to_2xxx *entry = (struct ctio_to_2xxx *)pkt; |
---|
| 5829 | + |
---|
5743 | 5830 | qlt_do_ctio_completion(vha, rsp, entry->handle, |
---|
5744 | 5831 | le16_to_cpu(entry->status)|(pkt->entry_status << 16), |
---|
5745 | 5832 | entry); |
---|
.. | .. |
---|
5749 | 5836 | case CTIO_A64_TYPE: |
---|
5750 | 5837 | { |
---|
5751 | 5838 | struct ctio_to_2xxx *entry = (struct ctio_to_2xxx *)pkt; |
---|
| 5839 | + |
---|
5752 | 5840 | qlt_do_ctio_completion(vha, rsp, entry->handle, |
---|
5753 | 5841 | le16_to_cpu(entry->status)|(pkt->entry_status << 16), |
---|
5754 | 5842 | entry); |
---|
.. | .. |
---|
5763 | 5851 | case NOTIFY_ACK_TYPE: |
---|
5764 | 5852 | if (tgt->notify_ack_expected > 0) { |
---|
5765 | 5853 | struct nack_to_isp *entry = (struct nack_to_isp *)pkt; |
---|
| 5854 | + |
---|
5766 | 5855 | ql_dbg(ql_dbg_tgt, vha, 0xe036, |
---|
5767 | 5856 | "NOTIFY_ACK seq %08x status %x\n", |
---|
5768 | 5857 | le16_to_cpu(entry->u.isp2x.seq_id), |
---|
.. | .. |
---|
5790 | 5879 | |
---|
5791 | 5880 | case ABTS_RESP_24XX: |
---|
5792 | 5881 | if (tgt->abts_resp_expected > 0) { |
---|
5793 | | - struct abts_resp_from_24xx_fw *entry = |
---|
5794 | | - (struct abts_resp_from_24xx_fw *)pkt; |
---|
5795 | | - ql_dbg(ql_dbg_tgt, vha, 0xe038, |
---|
5796 | | - "ABTS_RESP_24XX: compl_status %x\n", |
---|
5797 | | - entry->compl_status); |
---|
5798 | | - tgt->abts_resp_expected--; |
---|
5799 | | - if (le16_to_cpu(entry->compl_status) != |
---|
5800 | | - ABTS_RESP_COMPL_SUCCESS) { |
---|
5801 | | - if ((entry->error_subcode1 == 0x1E) && |
---|
5802 | | - (entry->error_subcode2 == 0)) { |
---|
5803 | | - /* |
---|
5804 | | - * We've got a race here: aborted |
---|
5805 | | - * exchange not terminated, i.e. |
---|
5806 | | - * response for the aborted command was |
---|
5807 | | - * sent between the abort request was |
---|
5808 | | - * received and processed. |
---|
5809 | | - * Unfortunately, the firmware has a |
---|
5810 | | - * silly requirement that all aborted |
---|
5811 | | - * exchanges must be explicitely |
---|
5812 | | - * terminated, otherwise it refuses to |
---|
5813 | | - * send responses for the abort |
---|
5814 | | - * requests. So, we have to |
---|
5815 | | - * (re)terminate the exchange and retry |
---|
5816 | | - * the abort response. |
---|
5817 | | - */ |
---|
5818 | | - qlt_24xx_retry_term_exchange(vha, |
---|
5819 | | - entry); |
---|
5820 | | - } else |
---|
5821 | | - ql_dbg(ql_dbg_tgt, vha, 0xe063, |
---|
5822 | | - "qla_target(%d): ABTS_RESP_24XX " |
---|
5823 | | - "failed %x (subcode %x:%x)", |
---|
5824 | | - vha->vp_idx, entry->compl_status, |
---|
5825 | | - entry->error_subcode1, |
---|
5826 | | - entry->error_subcode2); |
---|
5827 | | - } |
---|
| 5882 | + qlt_handle_abts_completion(vha, rsp, pkt); |
---|
5828 | 5883 | } else { |
---|
5829 | 5884 | ql_dbg(ql_dbg_tgt, vha, 0xe064, |
---|
5830 | 5885 | "qla_target(%d): Unexpected ABTS_RESP_24XX " |
---|
.. | .. |
---|
5881 | 5936 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf03b, |
---|
5882 | 5937 | "qla_target(%d): Async LOOP_UP occurred " |
---|
5883 | 5938 | "(m[0]=%x, m[1]=%x, m[2]=%x, m[3]=%x)", vha->vp_idx, |
---|
5884 | | - le16_to_cpu(mailbox[0]), le16_to_cpu(mailbox[1]), |
---|
5885 | | - le16_to_cpu(mailbox[2]), le16_to_cpu(mailbox[3])); |
---|
| 5939 | + mailbox[0], mailbox[1], mailbox[2], mailbox[3]); |
---|
5886 | 5940 | if (tgt->link_reinit_iocb_pending) { |
---|
5887 | 5941 | qlt_send_notify_ack(ha->base_qpair, |
---|
5888 | | - (void *)&tgt->link_reinit_iocb, |
---|
| 5942 | + &tgt->link_reinit_iocb, |
---|
5889 | 5943 | 0, 0, 0, 0, 0, 0); |
---|
5890 | 5944 | tgt->link_reinit_iocb_pending = 0; |
---|
5891 | 5945 | } |
---|
.. | .. |
---|
5899 | 5953 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf03c, |
---|
5900 | 5954 | "qla_target(%d): Async event %#x occurred " |
---|
5901 | 5955 | "(m[0]=%x, m[1]=%x, m[2]=%x, m[3]=%x)", vha->vp_idx, code, |
---|
5902 | | - le16_to_cpu(mailbox[0]), le16_to_cpu(mailbox[1]), |
---|
5903 | | - le16_to_cpu(mailbox[2]), le16_to_cpu(mailbox[3])); |
---|
| 5956 | + mailbox[0], mailbox[1], mailbox[2], mailbox[3]); |
---|
5904 | 5957 | break; |
---|
5905 | 5958 | |
---|
5906 | 5959 | case MBA_REJECTED_FCP_CMD: |
---|
5907 | 5960 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf017, |
---|
5908 | 5961 | "qla_target(%d): Async event LS_REJECT occurred (m[0]=%x, m[1]=%x, m[2]=%x, m[3]=%x)", |
---|
5909 | 5962 | vha->vp_idx, |
---|
5910 | | - le16_to_cpu(mailbox[0]), le16_to_cpu(mailbox[1]), |
---|
5911 | | - le16_to_cpu(mailbox[2]), le16_to_cpu(mailbox[3])); |
---|
| 5963 | + mailbox[0], mailbox[1], mailbox[2], mailbox[3]); |
---|
5912 | 5964 | |
---|
5913 | | - if (le16_to_cpu(mailbox[3]) == 1) { |
---|
| 5965 | + if (mailbox[3] == 1) { |
---|
5914 | 5966 | /* exchange starvation. */ |
---|
5915 | 5967 | vha->hw->exch_starvation++; |
---|
5916 | 5968 | if (vha->hw->exch_starvation > 5) { |
---|
.. | .. |
---|
5934 | 5986 | "qla_target(%d): Port update async event %#x " |
---|
5935 | 5987 | "occurred: updating the ports database (m[0]=%x, m[1]=%x, " |
---|
5936 | 5988 | "m[2]=%x, m[3]=%x)", vha->vp_idx, code, |
---|
5937 | | - le16_to_cpu(mailbox[0]), le16_to_cpu(mailbox[1]), |
---|
5938 | | - le16_to_cpu(mailbox[2]), le16_to_cpu(mailbox[3])); |
---|
| 5989 | + mailbox[0], mailbox[1], mailbox[2], mailbox[3]); |
---|
5939 | 5990 | |
---|
5940 | | - login_code = le16_to_cpu(mailbox[2]); |
---|
| 5991 | + login_code = mailbox[2]; |
---|
5941 | 5992 | if (login_code == 0x4) { |
---|
5942 | 5993 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf03e, |
---|
5943 | 5994 | "Async MB 2: Got PLOGI Complete\n"); |
---|
.. | .. |
---|
6001 | 6052 | if (!IS_SW_RESV_ADDR(fcport->d_id)) |
---|
6002 | 6053 | vha->fcport_count++; |
---|
6003 | 6054 | fcport->login_gen++; |
---|
6004 | | - fcport->disc_state = DSC_LOGIN_COMPLETE; |
---|
| 6055 | + qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_COMPLETE); |
---|
6005 | 6056 | fcport->login_succ = 1; |
---|
6006 | 6057 | newfcport = 1; |
---|
6007 | 6058 | } |
---|
.. | .. |
---|
6036 | 6087 | |
---|
6037 | 6088 | /* Must be called under tgt_mutex */ |
---|
6038 | 6089 | static struct fc_port *qlt_make_local_sess(struct scsi_qla_host *vha, |
---|
6039 | | - uint8_t *s_id) |
---|
| 6090 | + be_id_t s_id) |
---|
6040 | 6091 | { |
---|
6041 | 6092 | struct fc_port *sess = NULL; |
---|
6042 | 6093 | fc_port_t *fcport = NULL; |
---|
6043 | 6094 | int rc, global_resets; |
---|
6044 | 6095 | uint16_t loop_id = 0; |
---|
6045 | 6096 | |
---|
6046 | | - if ((s_id[0] == 0xFF) && (s_id[1] == 0xFC)) { |
---|
| 6097 | + if (s_id.domain == 0xFF && s_id.area == 0xFC) { |
---|
6047 | 6098 | /* |
---|
6048 | 6099 | * This is Domain Controller, so it should be |
---|
6049 | 6100 | * OK to drop SCSI commands from it. |
---|
6050 | 6101 | */ |
---|
6051 | 6102 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf042, |
---|
6052 | 6103 | "Unable to find initiator with S_ID %x:%x:%x", |
---|
6053 | | - s_id[0], s_id[1], s_id[2]); |
---|
| 6104 | + s_id.domain, s_id.area, s_id.al_pa); |
---|
6054 | 6105 | return NULL; |
---|
6055 | 6106 | } |
---|
6056 | 6107 | |
---|
.. | .. |
---|
6067 | 6118 | ql_log(ql_log_info, vha, 0xf071, |
---|
6068 | 6119 | "qla_target(%d): Unable to find " |
---|
6069 | 6120 | "initiator with S_ID %x:%x:%x", |
---|
6070 | | - vha->vp_idx, s_id[0], s_id[1], |
---|
6071 | | - s_id[2]); |
---|
| 6121 | + vha->vp_idx, s_id.domain, s_id.area, s_id.al_pa); |
---|
6072 | 6122 | |
---|
6073 | 6123 | if (rc == -ENOENT) { |
---|
6074 | 6124 | qlt_port_logo_t logo; |
---|
6075 | | - sid_to_portid(s_id, &logo.id); |
---|
| 6125 | + |
---|
| 6126 | + logo.id = be_to_port_id(s_id); |
---|
6076 | 6127 | logo.cmd_count = 1; |
---|
6077 | 6128 | qlt_send_first_logo(vha, &logo); |
---|
6078 | 6129 | } |
---|
.. | .. |
---|
6111 | 6162 | struct qla_hw_data *ha = vha->hw; |
---|
6112 | 6163 | struct fc_port *sess = NULL; |
---|
6113 | 6164 | unsigned long flags = 0, flags2 = 0; |
---|
6114 | | - uint8_t s_id[3]; |
---|
| 6165 | + be_id_t s_id; |
---|
6115 | 6166 | int rc; |
---|
6116 | 6167 | |
---|
6117 | 6168 | spin_lock_irqsave(&ha->tgt.sess_lock, flags2); |
---|
.. | .. |
---|
6119 | 6170 | if (tgt->tgt_stop) |
---|
6120 | 6171 | goto out_term2; |
---|
6121 | 6172 | |
---|
6122 | | - s_id[0] = prm->abts.fcp_hdr_le.s_id[2]; |
---|
6123 | | - s_id[1] = prm->abts.fcp_hdr_le.s_id[1]; |
---|
6124 | | - s_id[2] = prm->abts.fcp_hdr_le.s_id[0]; |
---|
| 6173 | + s_id = le_id_to_be(prm->abts.fcp_hdr_le.s_id); |
---|
6125 | 6174 | |
---|
6126 | 6175 | sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, s_id); |
---|
6127 | 6176 | if (!sess) { |
---|
.. | .. |
---|
6160 | 6209 | out_term2: |
---|
6161 | 6210 | spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); |
---|
6162 | 6211 | |
---|
6163 | | - if (sess) |
---|
6164 | | - ha->tgt.tgt_ops->put_sess(sess); |
---|
6165 | | - |
---|
6166 | 6212 | out_term: |
---|
6167 | 6213 | spin_lock_irqsave(&ha->hardware_lock, flags); |
---|
6168 | 6214 | qlt_24xx_send_abts_resp(ha->base_qpair, &prm->abts, |
---|
.. | .. |
---|
6176 | 6222 | struct atio_from_isp *a = &prm->tm_iocb2; |
---|
6177 | 6223 | struct scsi_qla_host *vha = tgt->vha; |
---|
6178 | 6224 | struct qla_hw_data *ha = vha->hw; |
---|
6179 | | - struct fc_port *sess = NULL; |
---|
| 6225 | + struct fc_port *sess; |
---|
6180 | 6226 | unsigned long flags; |
---|
6181 | | - uint8_t *s_id = NULL; /* to hide compiler warnings */ |
---|
| 6227 | + be_id_t s_id; |
---|
6182 | 6228 | int rc; |
---|
6183 | 6229 | u64 unpacked_lun; |
---|
6184 | 6230 | int fn; |
---|
.. | .. |
---|
6202 | 6248 | goto out_term2; |
---|
6203 | 6249 | } else { |
---|
6204 | 6250 | if (sess->deleted) { |
---|
6205 | | - sess = NULL; |
---|
6206 | 6251 | goto out_term2; |
---|
6207 | 6252 | } |
---|
6208 | 6253 | |
---|
.. | .. |
---|
6210 | 6255 | ql_dbg(ql_dbg_tgt_tmr, vha, 0xf020, |
---|
6211 | 6256 | "%s: kref_get fail %8phC\n", |
---|
6212 | 6257 | __func__, sess->port_name); |
---|
6213 | | - sess = NULL; |
---|
6214 | 6258 | goto out_term2; |
---|
6215 | 6259 | } |
---|
6216 | 6260 | } |
---|
.. | .. |
---|
6230 | 6274 | return; |
---|
6231 | 6275 | |
---|
6232 | 6276 | out_term2: |
---|
6233 | | - if (sess) |
---|
6234 | | - ha->tgt.tgt_ops->put_sess(sess); |
---|
6235 | 6277 | spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); |
---|
6236 | 6278 | out_term: |
---|
6237 | 6279 | qlt_send_term_exchange(ha->base_qpair, NULL, &prm->tm_iocb2, 1, 0); |
---|
.. | .. |
---|
6337 | 6379 | unsigned long flags; |
---|
6338 | 6380 | |
---|
6339 | 6381 | struct qla_qpair *qpair = ha->queue_pair_map[i]; |
---|
| 6382 | + |
---|
6340 | 6383 | h = &tgt->qphints[i + 1]; |
---|
6341 | 6384 | INIT_LIST_HEAD(&h->hint_elem); |
---|
6342 | 6385 | if (qpair) { |
---|
.. | .. |
---|
6410 | 6453 | static void qlt_lport_dump(struct scsi_qla_host *vha, u64 wwpn, |
---|
6411 | 6454 | unsigned char *b) |
---|
6412 | 6455 | { |
---|
6413 | | - int i; |
---|
6414 | | - |
---|
6415 | | - pr_debug("qla2xxx HW vha->node_name: "); |
---|
6416 | | - for (i = 0; i < WWN_SIZE; i++) |
---|
6417 | | - pr_debug("%02x ", vha->node_name[i]); |
---|
6418 | | - pr_debug("\n"); |
---|
6419 | | - pr_debug("qla2xxx HW vha->port_name: "); |
---|
6420 | | - for (i = 0; i < WWN_SIZE; i++) |
---|
6421 | | - pr_debug("%02x ", vha->port_name[i]); |
---|
6422 | | - pr_debug("\n"); |
---|
6423 | | - |
---|
6424 | | - pr_debug("qla2xxx passed configfs WWPN: "); |
---|
| 6456 | + pr_debug("qla2xxx HW vha->node_name: %8phC\n", vha->node_name); |
---|
| 6457 | + pr_debug("qla2xxx HW vha->port_name: %8phC\n", vha->port_name); |
---|
6425 | 6458 | put_unaligned_be64(wwpn, b); |
---|
6426 | | - for (i = 0; i < WWN_SIZE; i++) |
---|
6427 | | - pr_debug("%02x ", b[i]); |
---|
6428 | | - pr_debug("\n"); |
---|
| 6459 | + pr_debug("qla2xxx passed configfs WWPN: %8phC\n", b); |
---|
6429 | 6460 | } |
---|
6430 | 6461 | |
---|
6431 | 6462 | /** |
---|
6432 | 6463 | * qla_tgt_lport_register - register lport with external module |
---|
6433 | 6464 | * |
---|
6434 | 6465 | * @target_lport_ptr: pointer for tcm_qla2xxx specific lport data |
---|
6435 | | - * @phys_wwpn: |
---|
6436 | | - * @npiv_wwpn: |
---|
6437 | | - * @npiv_wwnn: |
---|
| 6466 | + * @phys_wwpn: physical port WWPN |
---|
| 6467 | + * @npiv_wwpn: NPIV WWPN |
---|
| 6468 | + * @npiv_wwnn: NPIV WWNN |
---|
6438 | 6469 | * @callback: lport initialization callback for tcm_qla2xxx code |
---|
6439 | 6470 | */ |
---|
6440 | 6471 | int qlt_lport_register(void *target_lport_ptr, u64 phys_wwpn, |
---|
.. | .. |
---|
6459 | 6490 | continue; |
---|
6460 | 6491 | |
---|
6461 | 6492 | if (!(host->hostt->supported_mode & MODE_TARGET)) |
---|
| 6493 | + continue; |
---|
| 6494 | + |
---|
| 6495 | + if (vha->qlini_mode == QLA2XXX_INI_MODE_ENABLED) |
---|
6462 | 6496 | continue; |
---|
6463 | 6497 | |
---|
6464 | 6498 | spin_lock_irqsave(&ha->hardware_lock, flags); |
---|
.. | .. |
---|
6523 | 6557 | EXPORT_SYMBOL(qlt_lport_deregister); |
---|
6524 | 6558 | |
---|
6525 | 6559 | /* Must be called under HW lock */ |
---|
6526 | | -static void qlt_set_mode(struct scsi_qla_host *vha) |
---|
| 6560 | +void qlt_set_mode(struct scsi_qla_host *vha) |
---|
6527 | 6561 | { |
---|
6528 | | - switch (ql2x_ini_mode) { |
---|
| 6562 | + switch (vha->qlini_mode) { |
---|
6529 | 6563 | case QLA2XXX_INI_MODE_DISABLED: |
---|
6530 | 6564 | case QLA2XXX_INI_MODE_EXCLUSIVE: |
---|
6531 | 6565 | vha->host->active_mode = MODE_TARGET; |
---|
6532 | 6566 | break; |
---|
6533 | 6567 | case QLA2XXX_INI_MODE_ENABLED: |
---|
6534 | | - vha->host->active_mode = MODE_UNKNOWN; |
---|
| 6568 | + vha->host->active_mode = MODE_INITIATOR; |
---|
6535 | 6569 | break; |
---|
6536 | 6570 | case QLA2XXX_INI_MODE_DUAL: |
---|
6537 | 6571 | vha->host->active_mode = MODE_DUAL; |
---|
.. | .. |
---|
6544 | 6578 | /* Must be called under HW lock */ |
---|
6545 | 6579 | static void qlt_clear_mode(struct scsi_qla_host *vha) |
---|
6546 | 6580 | { |
---|
6547 | | - switch (ql2x_ini_mode) { |
---|
| 6581 | + switch (vha->qlini_mode) { |
---|
6548 | 6582 | case QLA2XXX_INI_MODE_DISABLED: |
---|
6549 | 6583 | vha->host->active_mode = MODE_UNKNOWN; |
---|
6550 | 6584 | break; |
---|
.. | .. |
---|
6580 | 6614 | dump_stack(); |
---|
6581 | 6615 | return; |
---|
6582 | 6616 | } |
---|
| 6617 | + if (vha->qlini_mode == QLA2XXX_INI_MODE_ENABLED) |
---|
| 6618 | + return; |
---|
6583 | 6619 | |
---|
| 6620 | + if (ha->tgt.num_act_qpairs > ha->max_qpairs) |
---|
| 6621 | + ha->tgt.num_act_qpairs = ha->max_qpairs; |
---|
6584 | 6622 | spin_lock_irqsave(&ha->hardware_lock, flags); |
---|
6585 | 6623 | tgt->tgt_stopped = 0; |
---|
6586 | 6624 | qlt_set_mode(vha); |
---|
6587 | 6625 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
---|
6588 | 6626 | |
---|
| 6627 | + mutex_lock(&ha->optrom_mutex); |
---|
| 6628 | + ql_dbg(ql_dbg_tgt_mgt, vha, 0xf021, |
---|
| 6629 | + "%s.\n", __func__); |
---|
6589 | 6630 | if (vha->vp_idx) { |
---|
6590 | 6631 | qla24xx_disable_vp(vha); |
---|
6591 | 6632 | qla24xx_enable_vp(vha); |
---|
.. | .. |
---|
6595 | 6636 | WARN_ON_ONCE(qla2x00_wait_for_hba_online(base_vha) != |
---|
6596 | 6637 | QLA_SUCCESS); |
---|
6597 | 6638 | } |
---|
| 6639 | + mutex_unlock(&ha->optrom_mutex); |
---|
6598 | 6640 | } |
---|
6599 | 6641 | EXPORT_SYMBOL(qlt_enable_vha); |
---|
6600 | 6642 | |
---|
.. | .. |
---|
6623 | 6665 | |
---|
6624 | 6666 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
---|
6625 | 6667 | qla2xxx_wake_dpc(vha); |
---|
| 6668 | + |
---|
| 6669 | + /* |
---|
| 6670 | + * We are expecting the offline state. |
---|
| 6671 | + * QLA_FUNCTION_FAILED means that adapter is offline. |
---|
| 6672 | + */ |
---|
6626 | 6673 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) |
---|
6627 | 6674 | ql_dbg(ql_dbg_tgt, vha, 0xe081, |
---|
6628 | | - "qla2x00_wait_for_hba_online() failed\n"); |
---|
| 6675 | + "adapter is offline\n"); |
---|
6629 | 6676 | } |
---|
6630 | 6677 | |
---|
6631 | 6678 | /* |
---|
.. | .. |
---|
6691 | 6738 | return; |
---|
6692 | 6739 | |
---|
6693 | 6740 | for (cnt = 0; cnt < ha->tgt.atio_q_length; cnt++) { |
---|
6694 | | - pkt->u.raw.signature = ATIO_PROCESSED; |
---|
| 6741 | + pkt->u.raw.signature = cpu_to_le32(ATIO_PROCESSED); |
---|
6695 | 6742 | pkt++; |
---|
6696 | 6743 | } |
---|
6697 | 6744 | |
---|
.. | .. |
---|
6724 | 6771 | */ |
---|
6725 | 6772 | ql_log(ql_log_warn, vha, 0xd03c, |
---|
6726 | 6773 | "corrupted fcp frame SID[%3phN] OXID[%04x] EXCG[%x] %64phN\n", |
---|
6727 | | - pkt->u.isp24.fcp_hdr.s_id, |
---|
| 6774 | + &pkt->u.isp24.fcp_hdr.s_id, |
---|
6728 | 6775 | be16_to_cpu(pkt->u.isp24.fcp_hdr.ox_id), |
---|
6729 | | - le32_to_cpu(pkt->u.isp24.exchange_addr), pkt); |
---|
| 6776 | + pkt->u.isp24.exchange_addr, pkt); |
---|
6730 | 6777 | |
---|
6731 | 6778 | adjust_corrupted_atio(pkt); |
---|
6732 | 6779 | qlt_send_term_exchange(ha->base_qpair, NULL, pkt, |
---|
.. | .. |
---|
6744 | 6791 | } else |
---|
6745 | 6792 | ha->tgt.atio_ring_ptr++; |
---|
6746 | 6793 | |
---|
6747 | | - pkt->u.raw.signature = ATIO_PROCESSED; |
---|
| 6794 | + pkt->u.raw.signature = cpu_to_le32(ATIO_PROCESSED); |
---|
6748 | 6795 | pkt = (struct atio_from_isp *)ha->tgt.atio_ring_ptr; |
---|
6749 | 6796 | } |
---|
6750 | 6797 | wmb(); |
---|
6751 | 6798 | } |
---|
6752 | 6799 | |
---|
6753 | 6800 | /* Adjust ring index */ |
---|
6754 | | - WRT_REG_DWORD(ISP_ATIO_Q_OUT(vha), ha->tgt.atio_ring_index); |
---|
| 6801 | + wrt_reg_dword(ISP_ATIO_Q_OUT(vha), ha->tgt.atio_ring_index); |
---|
6755 | 6802 | } |
---|
6756 | 6803 | |
---|
6757 | 6804 | void |
---|
.. | .. |
---|
6764 | 6811 | if (!QLA_TGT_MODE_ENABLED()) |
---|
6765 | 6812 | return; |
---|
6766 | 6813 | |
---|
6767 | | - WRT_REG_DWORD(ISP_ATIO_Q_IN(vha), 0); |
---|
6768 | | - WRT_REG_DWORD(ISP_ATIO_Q_OUT(vha), 0); |
---|
6769 | | - RD_REG_DWORD(ISP_ATIO_Q_OUT(vha)); |
---|
| 6814 | + wrt_reg_dword(ISP_ATIO_Q_IN(vha), 0); |
---|
| 6815 | + wrt_reg_dword(ISP_ATIO_Q_OUT(vha), 0); |
---|
| 6816 | + rd_reg_dword(ISP_ATIO_Q_OUT(vha)); |
---|
6770 | 6817 | |
---|
6771 | 6818 | if (ha->flags.msix_enabled) { |
---|
6772 | | - if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
---|
6773 | | - if (IS_QLA2071(ha)) { |
---|
6774 | | - /* 4 ports Baker: Enable Interrupt Handshake */ |
---|
6775 | | - icb->msix_atio = 0; |
---|
6776 | | - icb->firmware_options_2 |= BIT_26; |
---|
6777 | | - } else { |
---|
6778 | | - icb->msix_atio = cpu_to_le16(msix->entry); |
---|
6779 | | - icb->firmware_options_2 &= ~BIT_26; |
---|
6780 | | - } |
---|
| 6819 | + if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
---|
| 6820 | + icb->msix_atio = cpu_to_le16(msix->entry); |
---|
| 6821 | + icb->firmware_options_2 &= cpu_to_le32(~BIT_26); |
---|
6781 | 6822 | ql_dbg(ql_dbg_init, vha, 0xf072, |
---|
6782 | 6823 | "Registering ICB vector 0x%x for atio que.\n", |
---|
6783 | 6824 | msix->entry); |
---|
6784 | 6825 | } |
---|
6785 | 6826 | } else { |
---|
6786 | 6827 | /* INTx|MSI */ |
---|
6787 | | - if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
---|
| 6828 | + if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
---|
6788 | 6829 | icb->msix_atio = 0; |
---|
6789 | | - icb->firmware_options_2 |= BIT_26; |
---|
| 6830 | + icb->firmware_options_2 |= cpu_to_le32(BIT_26); |
---|
6790 | 6831 | ql_dbg(ql_dbg_init, vha, 0xf072, |
---|
6791 | 6832 | "%s: Use INTx for ATIOQ.\n", __func__); |
---|
6792 | 6833 | } |
---|
.. | .. |
---|
6818 | 6859 | if (qla_tgt_mode_enabled(vha)) |
---|
6819 | 6860 | nv->exchange_count = cpu_to_le16(0xFFFF); |
---|
6820 | 6861 | else /* dual */ |
---|
6821 | | - nv->exchange_count = cpu_to_le16(ql2xexchoffld); |
---|
| 6862 | + nv->exchange_count = cpu_to_le16(vha->ql2xexchoffld); |
---|
6822 | 6863 | |
---|
6823 | 6864 | /* Enable target mode */ |
---|
6824 | 6865 | nv->firmware_options_1 |= cpu_to_le32(BIT_4); |
---|
.. | .. |
---|
6897 | 6938 | memcpy(icb->node_name, ha->tgt.tgt_node_name, WWN_SIZE); |
---|
6898 | 6939 | icb->firmware_options_1 |= cpu_to_le32(BIT_14); |
---|
6899 | 6940 | } |
---|
6900 | | - |
---|
6901 | | - /* disable ZIO at start time. */ |
---|
6902 | | - if (!vha->flags.init_done) { |
---|
6903 | | - uint32_t tmp; |
---|
6904 | | - tmp = le32_to_cpu(icb->firmware_options_2); |
---|
6905 | | - tmp &= ~(BIT_3 | BIT_2 | BIT_1 | BIT_0); |
---|
6906 | | - icb->firmware_options_2 = cpu_to_le32(tmp); |
---|
6907 | | - } |
---|
6908 | 6941 | } |
---|
6909 | 6942 | |
---|
6910 | 6943 | void |
---|
.. | .. |
---|
6932 | 6965 | if (qla_tgt_mode_enabled(vha)) |
---|
6933 | 6966 | nv->exchange_count = cpu_to_le16(0xFFFF); |
---|
6934 | 6967 | else /* dual */ |
---|
6935 | | - nv->exchange_count = cpu_to_le16(ql2xexchoffld); |
---|
| 6968 | + nv->exchange_count = cpu_to_le16(vha->ql2xexchoffld); |
---|
6936 | 6969 | |
---|
6937 | 6970 | /* Enable target mode */ |
---|
6938 | 6971 | nv->firmware_options_1 |= cpu_to_le32(BIT_4); |
---|
.. | .. |
---|
7008 | 7041 | memcpy(icb->node_name, ha->tgt.tgt_node_name, WWN_SIZE); |
---|
7009 | 7042 | icb->firmware_options_1 |= cpu_to_le32(BIT_14); |
---|
7010 | 7043 | } |
---|
7011 | | - |
---|
7012 | | - /* disable ZIO at start time. */ |
---|
7013 | | - if (!vha->flags.init_done) { |
---|
7014 | | - uint32_t tmp; |
---|
7015 | | - tmp = le32_to_cpu(icb->firmware_options_2); |
---|
7016 | | - tmp &= ~(BIT_3 | BIT_2 | BIT_1 | BIT_0); |
---|
7017 | | - icb->firmware_options_2 = cpu_to_le32(tmp); |
---|
7018 | | - } |
---|
7019 | | - |
---|
7020 | 7044 | } |
---|
7021 | 7045 | |
---|
7022 | 7046 | void |
---|
.. | .. |
---|
7050 | 7074 | if (!QLA_TGT_MODE_ENABLED()) |
---|
7051 | 7075 | return; |
---|
7052 | 7076 | |
---|
7053 | | - if ((ql2xenablemsix == 0) || IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
---|
| 7077 | + if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
---|
7054 | 7078 | ISP_ATIO_Q_IN(base_vha) = &ha->mqiobase->isp25mq.atio_q_in; |
---|
7055 | 7079 | ISP_ATIO_Q_OUT(base_vha) = &ha->mqiobase->isp25mq.atio_q_out; |
---|
7056 | 7080 | } else { |
---|
.. | .. |
---|
7178 | 7202 | sizeof(struct atio_from_isp), ha->tgt.atio_ring, |
---|
7179 | 7203 | ha->tgt.atio_dma); |
---|
7180 | 7204 | } |
---|
| 7205 | + ha->tgt.atio_ring = NULL; |
---|
| 7206 | + ha->tgt.atio_dma = 0; |
---|
7181 | 7207 | kfree(ha->tgt.tgt_vp_map); |
---|
| 7208 | + ha->tgt.tgt_vp_map = NULL; |
---|
7182 | 7209 | } |
---|
7183 | 7210 | |
---|
7184 | 7211 | /* vport_slock to be held by the caller */ |
---|
.. | .. |
---|
7262 | 7289 | { |
---|
7263 | 7290 | int ret; |
---|
7264 | 7291 | |
---|
| 7292 | + BUILD_BUG_ON(sizeof(struct ctio7_to_24xx) != 64); |
---|
| 7293 | + BUILD_BUG_ON(sizeof(struct ctio_to_2xxx) != 64); |
---|
| 7294 | + |
---|
7265 | 7295 | if (!qlt_parse_ini_mode()) { |
---|
7266 | 7296 | ql_log(ql_log_fatal, NULL, 0xe06b, |
---|
7267 | 7297 | "qlt_parse_ini_mode() failed\n"); |
---|