Lines Matching +full:twisted +full:- +full:pair
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (c) 2003-2014 QLogic Corporation
44 /* SRB Extensions ---------------------------------------------------------- */
53 iocb = &sp->u.iocb_cmd; in qla2x00_sp_timeout()
54 iocb->timeout(sp); in qla2x00_sp_timeout()
59 struct srb_iocb *iocb = &sp->u.iocb_cmd; in qla2x00_sp_free()
61 del_timer(&iocb->timer); in qla2x00_sp_free()
75 /* Asynchronous Login/Logout Routines -------------------------------------- */
81 struct qla_hw_data *ha = vha->hw; in qla2x00_get_async_timeout()
84 tmo = ha->r_a_tov / 10 * 2; in qla2x00_get_async_timeout()
92 tmo = ha->login_timeout; in qla2x00_get_async_timeout()
100 struct srb_iocb *abt = &sp->u.iocb_cmd; in qla24xx_abort_iocb_timeout()
101 struct qla_qpair *qpair = sp->qpair; in qla24xx_abort_iocb_timeout()
105 if (sp->cmd_sp) in qla24xx_abort_iocb_timeout()
106 ql_dbg(ql_dbg_async, sp->vha, 0x507c, in qla24xx_abort_iocb_timeout()
107 "Abort timeout - cmd hdl=%x, cmd type=%x hdl=%x, type=%x\n", in qla24xx_abort_iocb_timeout()
108 sp->cmd_sp->handle, sp->cmd_sp->type, in qla24xx_abort_iocb_timeout()
109 sp->handle, sp->type); in qla24xx_abort_iocb_timeout()
111 ql_dbg(ql_dbg_async, sp->vha, 0x507c, in qla24xx_abort_iocb_timeout()
112 "Abort timeout 2 - hdl=%x, type=%x\n", in qla24xx_abort_iocb_timeout()
113 sp->handle, sp->type); in qla24xx_abort_iocb_timeout()
115 spin_lock_irqsave(qpair->qp_lock_ptr, flags); in qla24xx_abort_iocb_timeout()
116 for (handle = 1; handle < qpair->req->num_outstanding_cmds; handle++) { in qla24xx_abort_iocb_timeout()
117 if (sp->cmd_sp && (qpair->req->outstanding_cmds[handle] == in qla24xx_abort_iocb_timeout()
118 sp->cmd_sp)) in qla24xx_abort_iocb_timeout()
119 qpair->req->outstanding_cmds[handle] = NULL; in qla24xx_abort_iocb_timeout()
122 if (qpair->req->outstanding_cmds[handle] == sp) { in qla24xx_abort_iocb_timeout()
123 qpair->req->outstanding_cmds[handle] = NULL; in qla24xx_abort_iocb_timeout()
127 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qla24xx_abort_iocb_timeout()
129 if (sp->cmd_sp) in qla24xx_abort_iocb_timeout()
130 sp->cmd_sp->done(sp->cmd_sp, QLA_OS_TIMER_EXPIRED); in qla24xx_abort_iocb_timeout()
132 abt->u.abt.comp_status = cpu_to_le16(CS_TIMEOUT); in qla24xx_abort_iocb_timeout()
133 sp->done(sp, QLA_OS_TIMER_EXPIRED); in qla24xx_abort_iocb_timeout()
138 struct srb_iocb *abt = &sp->u.iocb_cmd; in qla24xx_abort_sp_done()
140 del_timer(&sp->u.iocb_cmd.timer); in qla24xx_abort_sp_done()
141 if (sp->flags & SRB_WAKEUP_ON_COMP) in qla24xx_abort_sp_done()
142 complete(&abt->u.abt.comp); in qla24xx_abort_sp_done()
144 sp->free(sp); in qla24xx_abort_sp_done()
149 scsi_qla_host_t *vha = cmd_sp->vha; in qla24xx_async_abort_cmd()
154 sp = qla2xxx_get_qpair_sp(cmd_sp->vha, cmd_sp->qpair, cmd_sp->fcport, in qla24xx_async_abort_cmd()
159 abt_iocb = &sp->u.iocb_cmd; in qla24xx_async_abort_cmd()
160 sp->type = SRB_ABT_CMD; in qla24xx_async_abort_cmd()
161 sp->name = "abort"; in qla24xx_async_abort_cmd()
162 sp->qpair = cmd_sp->qpair; in qla24xx_async_abort_cmd()
163 sp->cmd_sp = cmd_sp; in qla24xx_async_abort_cmd()
165 sp->flags = SRB_WAKEUP_ON_COMP; in qla24xx_async_abort_cmd()
167 abt_iocb->timeout = qla24xx_abort_iocb_timeout; in qla24xx_async_abort_cmd()
168 init_completion(&abt_iocb->u.abt.comp); in qla24xx_async_abort_cmd()
172 abt_iocb->u.abt.cmd_hndl = cmd_sp->handle; in qla24xx_async_abort_cmd()
173 abt_iocb->u.abt.req_que_no = cpu_to_le16(cmd_sp->qpair->req->id); in qla24xx_async_abort_cmd()
175 sp->done = qla24xx_abort_sp_done; in qla24xx_async_abort_cmd()
178 "Abort command issued - hdl=%x, type=%x\n", cmd_sp->handle, in qla24xx_async_abort_cmd()
179 cmd_sp->type); in qla24xx_async_abort_cmd()
183 sp->free(sp); in qla24xx_async_abort_cmd()
188 wait_for_completion(&abt_iocb->u.abt.comp); in qla24xx_async_abort_cmd()
189 rval = abt_iocb->u.abt.comp_status == CS_COMPLETE ? in qla24xx_async_abort_cmd()
191 sp->free(sp); in qla24xx_async_abort_cmd()
201 fc_port_t *fcport = sp->fcport; in qla2x00_async_iocb_timeout()
202 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_iocb_timeout()
207 ql_dbg(ql_dbg_disc, fcport->vha, 0x2071, in qla2x00_async_iocb_timeout()
208 "Async-%s timeout - hdl=%x portid=%06x %8phC.\n", in qla2x00_async_iocb_timeout()
209 sp->name, sp->handle, fcport->d_id.b24, fcport->port_name); in qla2x00_async_iocb_timeout()
211 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_iocb_timeout()
213 pr_info("Async-%s timeout - hdl=%x.\n", in qla2x00_async_iocb_timeout()
214 sp->name, sp->handle); in qla2x00_async_iocb_timeout()
217 switch (sp->type) { in qla2x00_async_iocb_timeout()
222 lio->u.logio.data[0] = MBS_COMMAND_ERROR; in qla2x00_async_iocb_timeout()
223 lio->u.logio.data[1] = in qla2x00_async_iocb_timeout()
224 lio->u.logio.flags & SRB_LOGIN_RETRIED ? in qla2x00_async_iocb_timeout()
226 spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); in qla2x00_async_iocb_timeout()
227 for (h = 1; h < sp->qpair->req->num_outstanding_cmds; in qla2x00_async_iocb_timeout()
229 if (sp->qpair->req->outstanding_cmds[h] == in qla2x00_async_iocb_timeout()
231 sp->qpair->req->outstanding_cmds[h] = in qla2x00_async_iocb_timeout()
236 spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); in qla2x00_async_iocb_timeout()
237 sp->done(sp, QLA_FUNCTION_TIMEOUT); in qla2x00_async_iocb_timeout()
250 spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); in qla2x00_async_iocb_timeout()
251 for (h = 1; h < sp->qpair->req->num_outstanding_cmds; in qla2x00_async_iocb_timeout()
253 if (sp->qpair->req->outstanding_cmds[h] == in qla2x00_async_iocb_timeout()
255 sp->qpair->req->outstanding_cmds[h] = in qla2x00_async_iocb_timeout()
260 spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); in qla2x00_async_iocb_timeout()
261 sp->done(sp, QLA_FUNCTION_TIMEOUT); in qla2x00_async_iocb_timeout()
269 struct scsi_qla_host *vha = sp->vha; in qla2x00_async_login_sp_done()
270 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_login_sp_done()
274 "%s %8phC res %d \n", __func__, sp->fcport->port_name, res); in qla2x00_async_login_sp_done()
276 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_login_sp_done()
278 if (!test_bit(UNLOADING, &vha->dpc_flags)) { in qla2x00_async_login_sp_done()
280 ea.fcport = sp->fcport; in qla2x00_async_login_sp_done()
281 ea.data[0] = lio->u.logio.data[0]; in qla2x00_async_login_sp_done()
282 ea.data[1] = lio->u.logio.data[1]; in qla2x00_async_login_sp_done()
283 ea.iop[0] = lio->u.logio.iop[0]; in qla2x00_async_login_sp_done()
284 ea.iop[1] = lio->u.logio.iop[1]; in qla2x00_async_login_sp_done()
289 sp->free(sp); in qla2x00_async_login_sp_done()
295 if (wwn_to_u64(fcport->port_name) < in fcport_is_smaller()
296 wwn_to_u64(fcport->vha->port_name)) in fcport_is_smaller()
316 if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT) || in qla2x00_async_login()
317 fcport->loop_id == FC_NO_LOOP_ID) { in qla2x00_async_login()
319 "%s: %8phC - not sending command.\n", in qla2x00_async_login()
320 __func__, fcport->port_name); in qla2x00_async_login()
329 fcport->flags |= FCF_ASYNC_SENT; in qla2x00_async_login()
330 fcport->logout_completed = 0; in qla2x00_async_login()
332 sp->type = SRB_LOGIN_CMD; in qla2x00_async_login()
333 sp->name = "login"; in qla2x00_async_login()
334 sp->gen1 = fcport->rscn_gen; in qla2x00_async_login()
335 sp->gen2 = fcport->login_gen; in qla2x00_async_login()
337 lio = &sp->u.iocb_cmd; in qla2x00_async_login()
338 lio->timeout = qla2x00_async_iocb_timeout; in qla2x00_async_login()
341 sp->done = qla2x00_async_login_sp_done; in qla2x00_async_login()
342 if (N2N_TOPO(fcport->vha->hw) && fcport_is_bigger(fcport)) in qla2x00_async_login()
343 lio->u.logio.flags |= SRB_LOGIN_PRLI_ONLY; in qla2x00_async_login()
345 lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI; in qla2x00_async_login()
347 if (NVME_TARGET(vha->hw, fcport)) in qla2x00_async_login()
348 lio->u.logio.flags |= SRB_LOGIN_SKIP_PRLI; in qla2x00_async_login()
351 "Async-login - %8phC hdl=%x, loopid=%x portid=%02x%02x%02x " in qla2x00_async_login()
352 "retries=%d.\n", fcport->port_name, sp->handle, fcport->loop_id, in qla2x00_async_login()
353 fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa, in qla2x00_async_login()
354 fcport->login_retry); in qla2x00_async_login()
358 fcport->flags |= FCF_LOGIN_NEEDED; in qla2x00_async_login()
359 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla2x00_async_login()
366 sp->free(sp); in qla2x00_async_login()
367 fcport->flags &= ~FCF_ASYNC_SENT; in qla2x00_async_login()
369 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla2x00_async_login()
375 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_logout_sp_done()
376 sp->fcport->login_gen++; in qla2x00_async_logout_sp_done()
377 qlt_logo_completion_handler(sp->fcport, res); in qla2x00_async_logout_sp_done()
378 sp->free(sp); in qla2x00_async_logout_sp_done()
388 fcport->flags |= FCF_ASYNC_SENT; in qla2x00_async_logout()
393 sp->type = SRB_LOGOUT_CMD; in qla2x00_async_logout()
394 sp->name = "logout"; in qla2x00_async_logout()
396 lio = &sp->u.iocb_cmd; in qla2x00_async_logout()
397 lio->timeout = qla2x00_async_iocb_timeout; in qla2x00_async_logout()
400 sp->done = qla2x00_async_logout_sp_done; in qla2x00_async_logout()
403 "Async-logout - hdl=%x loop-id=%x portid=%02x%02x%02x %8phC.\n", in qla2x00_async_logout()
404 sp->handle, fcport->loop_id, fcport->d_id.b.domain, in qla2x00_async_logout()
405 fcport->d_id.b.area, fcport->d_id.b.al_pa, in qla2x00_async_logout()
406 fcport->port_name); in qla2x00_async_logout()
414 sp->free(sp); in qla2x00_async_logout()
416 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_logout()
424 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla2x00_async_prlo_done()
425 /* Don't re-login in target mode */ in qla2x00_async_prlo_done()
426 if (!fcport->tgt_session) in qla2x00_async_prlo_done()
433 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_prlo_sp_done()
434 struct scsi_qla_host *vha = sp->vha; in qla2x00_async_prlo_sp_done()
436 sp->fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla2x00_async_prlo_sp_done()
437 if (!test_bit(UNLOADING, &vha->dpc_flags)) in qla2x00_async_prlo_sp_done()
438 qla2x00_post_async_prlo_done_work(sp->fcport->vha, sp->fcport, in qla2x00_async_prlo_sp_done()
439 lio->u.logio.data); in qla2x00_async_prlo_sp_done()
440 sp->free(sp); in qla2x00_async_prlo_sp_done()
455 sp->type = SRB_PRLO_CMD; in qla2x00_async_prlo()
456 sp->name = "prlo"; in qla2x00_async_prlo()
458 lio = &sp->u.iocb_cmd; in qla2x00_async_prlo()
459 lio->timeout = qla2x00_async_iocb_timeout; in qla2x00_async_prlo()
462 sp->done = qla2x00_async_prlo_sp_done; in qla2x00_async_prlo()
465 "Async-prlo - hdl=%x loop-id=%x portid=%02x%02x%02x.\n", in qla2x00_async_prlo()
466 sp->handle, fcport->loop_id, fcport->d_id.b.domain, in qla2x00_async_prlo()
467 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_async_prlo()
476 sp->free(sp); in qla2x00_async_prlo()
478 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla2x00_async_prlo()
485 struct fc_port *fcport = ea->fcport; in qla24xx_handle_adisc_event()
489 __func__, fcport->port_name, fcport->disc_state, in qla24xx_handle_adisc_event()
490 fcport->fw_login_state, ea->rc, fcport->login_gen, ea->sp->gen2, in qla24xx_handle_adisc_event()
491 fcport->rscn_gen, ea->sp->gen1, fcport->loop_id); in qla24xx_handle_adisc_event()
493 WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n", in qla24xx_handle_adisc_event()
494 ea->data[0]); in qla24xx_handle_adisc_event()
496 if (ea->data[0] != MBS_COMMAND_COMPLETE) { in qla24xx_handle_adisc_event()
499 __func__, ea->fcport->port_name); in qla24xx_handle_adisc_event()
501 fcport->deleted = 0; in qla24xx_handle_adisc_event()
502 fcport->logout_on_delete = 1; in qla24xx_handle_adisc_event()
503 qlt_schedule_sess_for_deletion(ea->fcport); in qla24xx_handle_adisc_event()
507 if (ea->fcport->disc_state == DSC_DELETE_PEND) in qla24xx_handle_adisc_event()
510 if (ea->sp->gen2 != ea->fcport->login_gen) { in qla24xx_handle_adisc_event()
514 __func__, ea->fcport->port_name); in qla24xx_handle_adisc_event()
516 } else if (ea->sp->gen1 != ea->fcport->rscn_gen) { in qla24xx_handle_adisc_event()
533 e->u.fcport.fcport = fcport; in qla_post_els_plogi_work()
534 fcport->flags |= FCF_ASYNC_ACTIVE; in qla_post_els_plogi_work()
541 struct scsi_qla_host *vha = sp->vha; in qla2x00_async_adisc_sp_done()
543 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_adisc_sp_done()
546 "Async done-%s res %x %8phC\n", in qla2x00_async_adisc_sp_done()
547 sp->name, res, sp->fcport->port_name); in qla2x00_async_adisc_sp_done()
549 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_adisc_sp_done()
553 ea.data[0] = lio->u.logio.data[0]; in qla2x00_async_adisc_sp_done()
554 ea.data[1] = lio->u.logio.data[1]; in qla2x00_async_adisc_sp_done()
555 ea.iop[0] = lio->u.logio.iop[0]; in qla2x00_async_adisc_sp_done()
556 ea.iop[1] = lio->u.logio.iop[1]; in qla2x00_async_adisc_sp_done()
557 ea.fcport = sp->fcport; in qla2x00_async_adisc_sp_done()
562 sp->free(sp); in qla2x00_async_adisc_sp_done()
575 "%s: %8phC is being delete - not sending command.\n", in qla2x00_async_adisc()
576 __func__, fcport->port_name); in qla2x00_async_adisc()
577 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla2x00_async_adisc()
581 if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT)) in qla2x00_async_adisc()
584 fcport->flags |= FCF_ASYNC_SENT; in qla2x00_async_adisc()
589 sp->type = SRB_ADISC_CMD; in qla2x00_async_adisc()
590 sp->name = "adisc"; in qla2x00_async_adisc()
592 lio = &sp->u.iocb_cmd; in qla2x00_async_adisc()
593 lio->timeout = qla2x00_async_iocb_timeout; in qla2x00_async_adisc()
594 sp->gen1 = fcport->rscn_gen; in qla2x00_async_adisc()
595 sp->gen2 = fcport->login_gen; in qla2x00_async_adisc()
598 sp->done = qla2x00_async_adisc_sp_done; in qla2x00_async_adisc()
600 lio->u.logio.flags |= SRB_LOGIN_RETRIED; in qla2x00_async_adisc()
603 "Async-adisc - hdl=%x loopid=%x portid=%06x %8phC.\n", in qla2x00_async_adisc()
604 sp->handle, fcport->loop_id, fcport->d_id.b24, fcport->port_name); in qla2x00_async_adisc()
613 sp->free(sp); in qla2x00_async_adisc()
615 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_adisc()
622 struct qla_hw_data *ha = vha->hw; in qla2x00_is_reserved_id()
627 return (loop_id > ha->max_loop_id && loop_id < SNS_FIRST_LOOP_ID) || in qla2x00_is_reserved_id()
632 * qla2x00_find_new_loop_id - scan through our port list and find a new usable loop ID
645 struct qla_hw_data *ha = vha->hw; in qla2x00_find_new_loop_id()
650 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_find_new_loop_id()
652 dev->loop_id = find_first_zero_bit(ha->loop_id_map, LOOPID_MAP_SIZE); in qla2x00_find_new_loop_id()
653 if (dev->loop_id >= LOOPID_MAP_SIZE || in qla2x00_find_new_loop_id()
654 qla2x00_is_reserved_id(vha, dev->loop_id)) { in qla2x00_find_new_loop_id()
655 dev->loop_id = FC_NO_LOOP_ID; in qla2x00_find_new_loop_id()
658 set_bit(dev->loop_id, ha->loop_id_map); in qla2x00_find_new_loop_id()
660 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_find_new_loop_id()
663 ql_dbg(ql_dbg_disc, dev->vha, 0x2086, in qla2x00_find_new_loop_id()
665 dev->loop_id, dev->d_id.b24); in qla2x00_find_new_loop_id()
667 ql_log(ql_log_warn, dev->vha, 0x2087, in qla2x00_find_new_loop_id()
669 dev->d_id.b24); in qla2x00_find_new_loop_id()
676 struct qla_hw_data *ha = fcport->vha->hw; in qla2x00_clear_loop_id()
678 if (fcport->loop_id == FC_NO_LOOP_ID || in qla2x00_clear_loop_id()
679 qla2x00_is_reserved_id(fcport->vha, fcport->loop_id)) in qla2x00_clear_loop_id()
682 clear_bit(fcport->loop_id, ha->loop_id_map); in qla2x00_clear_loop_id()
683 fcport->loop_id = FC_NO_LOOP_ID; in qla2x00_clear_loop_id()
697 fcport = ea->fcport; in qla24xx_handle_gnl_done_event()
700 __func__, fcport->port_name, fcport->disc_state, in qla24xx_handle_gnl_done_event()
701 fcport->fw_login_state, ea->rc, in qla24xx_handle_gnl_done_event()
702 fcport->login_gen, fcport->last_login_gen, in qla24xx_handle_gnl_done_event()
703 fcport->rscn_gen, fcport->last_rscn_gen, vha->loop_id); in qla24xx_handle_gnl_done_event()
705 if (fcport->disc_state == DSC_DELETE_PEND) in qla24xx_handle_gnl_done_event()
708 if (ea->rc) { /* rval */ in qla24xx_handle_gnl_done_event()
709 if (fcport->login_retry == 0) { in qla24xx_handle_gnl_done_event()
712 fcport->port_name, fcport->login_retry); in qla24xx_handle_gnl_done_event()
717 if (fcport->last_rscn_gen != fcport->rscn_gen) { in qla24xx_handle_gnl_done_event()
721 } else if (fcport->last_login_gen != fcport->login_gen) { in qla24xx_handle_gnl_done_event()
724 __func__, fcport->port_name); in qla24xx_handle_gnl_done_event()
728 n = ea->data[0] / sizeof(struct get_name_list_extended); in qla24xx_handle_gnl_done_event()
732 __func__, __LINE__, fcport->port_name, n, in qla24xx_handle_gnl_done_event()
733 fcport->d_id.b.domain, fcport->d_id.b.area, in qla24xx_handle_gnl_done_event()
734 fcport->d_id.b.al_pa, fcport->loop_id); in qla24xx_handle_gnl_done_event()
737 e = &vha->gnl.l[i]; in qla24xx_handle_gnl_done_event()
738 wwn = wwn_to_u64(e->port_name); in qla24xx_handle_gnl_done_event()
739 id.b.domain = e->port_id[2]; in qla24xx_handle_gnl_done_event()
740 id.b.area = e->port_id[1]; in qla24xx_handle_gnl_done_event()
741 id.b.al_pa = e->port_id[0]; in qla24xx_handle_gnl_done_event()
744 if (memcmp((u8 *)&wwn, fcport->port_name, WWN_SIZE)) in qla24xx_handle_gnl_done_event()
752 loop_id = le16_to_cpu(e->nport_handle); in qla24xx_handle_gnl_done_event()
754 nvme_cls = e->current_login_state >> 4; in qla24xx_handle_gnl_done_event()
755 current_login_state = e->current_login_state & 0xf; in qla24xx_handle_gnl_done_event()
759 fcport->fc4_type &= ~FS_FC4TYPE_FCP; in qla24xx_handle_gnl_done_event()
760 fcport->fc4_type |= FS_FC4TYPE_NVME; in qla24xx_handle_gnl_done_event()
762 fcport->fc4_type |= FS_FC4TYPE_FCP; in qla24xx_handle_gnl_done_event()
763 fcport->fc4_type &= ~FS_FC4TYPE_NVME; in qla24xx_handle_gnl_done_event()
768 __func__, fcport->port_name, in qla24xx_handle_gnl_done_event()
769 e->current_login_state, fcport->fw_login_state, in qla24xx_handle_gnl_done_event()
770 fcport->fc4_type, id.b24, fcport->d_id.b24, in qla24xx_handle_gnl_done_event()
771 loop_id, fcport->loop_id); in qla24xx_handle_gnl_done_event()
773 switch (fcport->disc_state) { in qla24xx_handle_gnl_done_event()
778 if ((id.b24 != fcport->d_id.b24 && in qla24xx_handle_gnl_done_event()
779 fcport->d_id.b24 && in qla24xx_handle_gnl_done_event()
780 fcport->loop_id != FC_NO_LOOP_ID) || in qla24xx_handle_gnl_done_event()
781 (fcport->loop_id != FC_NO_LOOP_ID && in qla24xx_handle_gnl_done_event()
782 fcport->loop_id != loop_id)) { in qla24xx_handle_gnl_done_event()
785 __func__, __LINE__, fcport->port_name); in qla24xx_handle_gnl_done_event()
786 if (fcport->n2n_flag) in qla24xx_handle_gnl_done_event()
787 fcport->d_id.b24 = 0; in qla24xx_handle_gnl_done_event()
794 fcport->loop_id = loop_id; in qla24xx_handle_gnl_done_event()
795 if (fcport->n2n_flag) in qla24xx_handle_gnl_done_event()
796 fcport->d_id.b24 = id.b24; in qla24xx_handle_gnl_done_event()
798 wwn = wwn_to_u64(fcport->port_name); in qla24xx_handle_gnl_done_event()
808 conflict_fcport->conflict = fcport; in qla24xx_handle_gnl_done_event()
809 fcport->login_pause = 1; in qla24xx_handle_gnl_done_event()
812 switch (vha->hw->current_topology) { in qla24xx_handle_gnl_done_event()
818 __func__, __LINE__, fcport->port_name); in qla24xx_handle_gnl_done_event()
820 if ((e->prli_svc_param_word_3[0] & BIT_4) == 0) in qla24xx_handle_gnl_done_event()
821 fcport->port_type = FCT_INITIATOR; in qla24xx_handle_gnl_done_event()
823 fcport->port_type = FCT_TARGET; in qla24xx_handle_gnl_done_event()
830 if (fcport->loop_id == FC_NO_LOOP_ID) { in qla24xx_handle_gnl_done_event()
832 fcport->fw_login_state = in qla24xx_handle_gnl_done_event()
837 fcport->port_name); in qla24xx_handle_gnl_done_event()
843 fcport->fw_login_state = current_login_state; in qla24xx_handle_gnl_done_event()
844 fcport->d_id = id; in qla24xx_handle_gnl_done_event()
857 if ((e->prli_svc_param_word_3[0] & BIT_4) == 0) in qla24xx_handle_gnl_done_event()
858 fcport->port_type = FCT_INITIATOR; in qla24xx_handle_gnl_done_event()
860 fcport->port_type = FCT_TARGET; in qla24xx_handle_gnl_done_event()
869 if (fcport->loop_id != FC_NO_LOOP_ID) in qla24xx_handle_gnl_done_event()
872 fcport->loop_id = loop_id; in qla24xx_handle_gnl_done_event()
881 if (fcport->loop_id != FC_NO_LOOP_ID) in qla24xx_handle_gnl_done_event()
884 fcport->loop_id = loop_id; in qla24xx_handle_gnl_done_event()
891 } /* switch (ha->current_topology) */ in qla24xx_handle_gnl_done_event()
895 switch (vha->hw->current_topology) { in qla24xx_handle_gnl_done_event()
899 e = &vha->gnl.l[i]; in qla24xx_handle_gnl_done_event()
900 id.b.domain = e->port_id[0]; in qla24xx_handle_gnl_done_event()
901 id.b.area = e->port_id[1]; in qla24xx_handle_gnl_done_event()
902 id.b.al_pa = e->port_id[2]; in qla24xx_handle_gnl_done_event()
904 loop_id = le16_to_cpu(e->nport_handle); in qla24xx_handle_gnl_done_event()
906 if (fcport->d_id.b24 == id.b24) { in qla24xx_handle_gnl_done_event()
909 e->port_name, 0); in qla24xx_handle_gnl_done_event()
915 conflict_fcport->port_name); in qla24xx_handle_gnl_done_event()
924 if (fcport->loop_id == loop_id) in qla24xx_handle_gnl_done_event()
925 fcport->loop_id = FC_NO_LOOP_ID; in qla24xx_handle_gnl_done_event()
931 if (time_after_eq(jiffies, fcport->dm_login_expire)) { in qla24xx_handle_gnl_done_event()
932 if (fcport->n2n_link_reset_cnt < 2) { in qla24xx_handle_gnl_done_event()
933 fcport->n2n_link_reset_cnt++; in qla24xx_handle_gnl_done_event()
940 &vha->dpc_flags); in qla24xx_handle_gnl_done_event()
942 if (fcport->n2n_chip_reset < 1) { in qla24xx_handle_gnl_done_event()
946 &vha->dpc_flags); in qla24xx_handle_gnl_done_event()
947 fcport->n2n_chip_reset++; in qla24xx_handle_gnl_done_event()
951 fcport->port_name); in qla24xx_handle_gnl_done_event()
952 fcport->scan_state = 0; in qla24xx_handle_gnl_done_event()
961 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_gnl_done_event()
975 struct scsi_qla_host *vha = sp->vha; in qla24xx_async_gnl_sp_done()
986 "Async done-%s res %x mb[1]=%x mb[2]=%x \n", in qla24xx_async_gnl_sp_done()
987 sp->name, res, sp->u.iocb_cmd.u.mbx.in_mb[1], in qla24xx_async_gnl_sp_done()
988 sp->u.iocb_cmd.u.mbx.in_mb[2]); in qla24xx_async_gnl_sp_done()
991 sp->fcport->flags &= ~(FCF_ASYNC_SENT|FCF_ASYNC_ACTIVE); in qla24xx_async_gnl_sp_done()
996 if (sp->u.iocb_cmd.u.mbx.in_mb[1] >= in qla24xx_async_gnl_sp_done()
998 n = sp->u.iocb_cmd.u.mbx.in_mb[1] / in qla24xx_async_gnl_sp_done()
1000 ea.data[0] = sp->u.iocb_cmd.u.mbx.in_mb[1]; /* amnt xfered */ in qla24xx_async_gnl_sp_done()
1004 e = &vha->gnl.l[i]; in qla24xx_async_gnl_sp_done()
1005 loop_id = le16_to_cpu(e->nport_handle); in qla24xx_async_gnl_sp_done()
1008 set_bit(loop_id, vha->hw->loop_id_map); in qla24xx_async_gnl_sp_done()
1009 wwn = wwn_to_u64(e->port_name); in qla24xx_async_gnl_sp_done()
1013 __func__, &wwn, e->port_id[2], e->port_id[1], in qla24xx_async_gnl_sp_done()
1014 e->port_id[0], e->current_login_state, e->last_login_state, in qla24xx_async_gnl_sp_done()
1018 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1022 if (!list_empty(&vha->gnl.fcports)) in qla24xx_async_gnl_sp_done()
1023 list_splice_init(&vha->gnl.fcports, &h); in qla24xx_async_gnl_sp_done()
1024 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1027 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1028 list_del_init(&fcport->gnl_entry); in qla24xx_async_gnl_sp_done()
1029 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla24xx_async_gnl_sp_done()
1030 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1041 e = &vha->gnl.l[i]; in qla24xx_async_gnl_sp_done()
1042 wwn = wwn_to_u64(e->port_name); in qla24xx_async_gnl_sp_done()
1045 list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list) { in qla24xx_async_gnl_sp_done()
1046 if (!memcmp((u8 *)&wwn, fcport->port_name, in qla24xx_async_gnl_sp_done()
1053 id.b.domain = e->port_id[2]; in qla24xx_async_gnl_sp_done()
1054 id.b.area = e->port_id[1]; in qla24xx_async_gnl_sp_done()
1055 id.b.al_pa = e->port_id[0]; in qla24xx_async_gnl_sp_done()
1062 wwnn = wwn_to_u64(e->node_name); in qla24xx_async_gnl_sp_done()
1068 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1069 vha->gnl.sent = 0; in qla24xx_async_gnl_sp_done()
1070 if (!list_empty(&vha->gnl.fcports)) { in qla24xx_async_gnl_sp_done()
1072 list_for_each_entry_safe(fcport, tf, &vha->gnl.fcports, in qla24xx_async_gnl_sp_done()
1074 list_del_init(&fcport->gnl_entry); in qla24xx_async_gnl_sp_done()
1075 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla24xx_async_gnl_sp_done()
1080 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1082 sp->free(sp); in qla24xx_async_gnl_sp_done()
1093 if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT)) in qla24xx_async_gnl()
1097 "Async-gnlist WWPN %8phC \n", fcport->port_name); in qla24xx_async_gnl()
1099 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl()
1100 fcport->flags |= FCF_ASYNC_SENT; in qla24xx_async_gnl()
1102 fcport->last_rscn_gen = fcport->rscn_gen; in qla24xx_async_gnl()
1103 fcport->last_login_gen = fcport->login_gen; in qla24xx_async_gnl()
1105 list_add_tail(&fcport->gnl_entry, &vha->gnl.fcports); in qla24xx_async_gnl()
1106 if (vha->gnl.sent) { in qla24xx_async_gnl()
1107 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl()
1110 vha->gnl.sent = 1; in qla24xx_async_gnl()
1111 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl()
1117 sp->type = SRB_MB_IOCB; in qla24xx_async_gnl()
1118 sp->name = "gnlist"; in qla24xx_async_gnl()
1119 sp->gen1 = fcport->rscn_gen; in qla24xx_async_gnl()
1120 sp->gen2 = fcport->login_gen; in qla24xx_async_gnl()
1122 mbx = &sp->u.iocb_cmd; in qla24xx_async_gnl()
1123 mbx->timeout = qla2x00_async_iocb_timeout; in qla24xx_async_gnl()
1126 mb = sp->u.iocb_cmd.u.mbx.out_mb; in qla24xx_async_gnl()
1129 mb[2] = MSW(vha->gnl.ldma); in qla24xx_async_gnl()
1130 mb[3] = LSW(vha->gnl.ldma); in qla24xx_async_gnl()
1131 mb[6] = MSW(MSD(vha->gnl.ldma)); in qla24xx_async_gnl()
1132 mb[7] = LSW(MSD(vha->gnl.ldma)); in qla24xx_async_gnl()
1133 mb[8] = vha->gnl.size; in qla24xx_async_gnl()
1134 mb[9] = vha->vp_idx; in qla24xx_async_gnl()
1136 sp->done = qla24xx_async_gnl_sp_done; in qla24xx_async_gnl()
1139 "Async-%s - OUT WWPN %8phC hndl %x\n", in qla24xx_async_gnl()
1140 sp->name, fcport->port_name, sp->handle); in qla24xx_async_gnl()
1149 sp->free(sp); in qla24xx_async_gnl()
1151 fcport->flags &= ~(FCF_ASYNC_ACTIVE | FCF_ASYNC_SENT); in qla24xx_async_gnl()
1163 e->u.fcport.fcport = fcport; in qla24xx_post_gnl_work()
1164 fcport->flags |= FCF_ASYNC_ACTIVE; in qla24xx_post_gnl_work()
1170 struct scsi_qla_host *vha = sp->vha; in qla24xx_async_gpdb_sp_done()
1171 struct qla_hw_data *ha = vha->hw; in qla24xx_async_gpdb_sp_done()
1172 fc_port_t *fcport = sp->fcport; in qla24xx_async_gpdb_sp_done()
1173 u16 *mb = sp->u.iocb_cmd.u.mbx.in_mb; in qla24xx_async_gpdb_sp_done()
1177 "Async done-%s res %x, WWPN %8phC mb[1]=%x mb[2]=%x \n", in qla24xx_async_gpdb_sp_done()
1178 sp->name, res, fcport->port_name, mb[1], mb[2]); in qla24xx_async_gpdb_sp_done()
1180 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla24xx_async_gpdb_sp_done()
1192 dma_pool_free(ha->s_dma_pool, sp->u.iocb_cmd.u.mbx.in, in qla24xx_async_gpdb_sp_done()
1193 sp->u.iocb_cmd.u.mbx.in_dma); in qla24xx_async_gpdb_sp_done()
1195 sp->free(sp); in qla24xx_async_gpdb_sp_done()
1202 if (vha->host->active_mode == MODE_TARGET) in qla24xx_post_prli_work()
1209 e->u.fcport.fcport = fcport; in qla24xx_post_prli_work()
1216 struct scsi_qla_host *vha = sp->vha; in qla2x00_async_prli_sp_done()
1217 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_prli_sp_done()
1222 sp->fcport->port_name, res); in qla2x00_async_prli_sp_done()
1224 sp->fcport->flags &= ~FCF_ASYNC_SENT; in qla2x00_async_prli_sp_done()
1226 if (!test_bit(UNLOADING, &vha->dpc_flags)) { in qla2x00_async_prli_sp_done()
1228 ea.fcport = sp->fcport; in qla2x00_async_prli_sp_done()
1229 ea.data[0] = lio->u.logio.data[0]; in qla2x00_async_prli_sp_done()
1230 ea.data[1] = lio->u.logio.data[1]; in qla2x00_async_prli_sp_done()
1231 ea.iop[0] = lio->u.logio.iop[0]; in qla2x00_async_prli_sp_done()
1232 ea.iop[1] = lio->u.logio.iop[1]; in qla2x00_async_prli_sp_done()
1238 sp->free(sp); in qla2x00_async_prli_sp_done()
1248 if (!vha->flags.online) { in qla24xx_async_prli()
1250 __func__, __LINE__, fcport->port_name); in qla24xx_async_prli()
1254 if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND || in qla24xx_async_prli()
1255 fcport->fw_login_state == DSC_LS_PRLI_PEND) && in qla24xx_async_prli()
1258 __func__, __LINE__, fcport->port_name); in qla24xx_async_prli()
1266 fcport->flags |= FCF_ASYNC_SENT; in qla24xx_async_prli()
1267 fcport->logout_completed = 0; in qla24xx_async_prli()
1269 sp->type = SRB_PRLI_CMD; in qla24xx_async_prli()
1270 sp->name = "prli"; in qla24xx_async_prli()
1272 lio = &sp->u.iocb_cmd; in qla24xx_async_prli()
1273 lio->timeout = qla2x00_async_iocb_timeout; in qla24xx_async_prli()
1276 sp->done = qla2x00_async_prli_sp_done; in qla24xx_async_prli()
1277 lio->u.logio.flags = 0; in qla24xx_async_prli()
1279 if (NVME_TARGET(vha->hw, fcport)) in qla24xx_async_prli()
1280 lio->u.logio.flags |= SRB_LOGIN_NVME_PRLI; in qla24xx_async_prli()
1283 "Async-prli - %8phC hdl=%x, loopid=%x portid=%06x retries=%d fc4type %x priority %x %s.\n", in qla24xx_async_prli()
1284 fcport->port_name, sp->handle, fcport->loop_id, fcport->d_id.b24, in qla24xx_async_prli()
1285 fcport->login_retry, fcport->fc4_type, vha->hw->fc4_type_priority, in qla24xx_async_prli()
1286 NVME_TARGET(vha->hw, fcport) ? "nvme" : "fcp"); in qla24xx_async_prli()
1290 fcport->flags |= FCF_LOGIN_NEEDED; in qla24xx_async_prli()
1291 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_async_prli()
1298 sp->free(sp); in qla24xx_async_prli()
1299 fcport->flags &= ~FCF_ASYNC_SENT; in qla24xx_async_prli()
1311 e->u.fcport.fcport = fcport; in qla24xx_post_gpdb_work()
1312 e->u.fcport.opt = opt; in qla24xx_post_gpdb_work()
1313 fcport->flags |= FCF_ASYNC_ACTIVE; in qla24xx_post_gpdb_work()
1325 struct qla_hw_data *ha = vha->hw; in qla24xx_async_gpdb()
1329 "%s: %8phC is being delete - not sending command.\n", in qla24xx_async_gpdb()
1330 __func__, fcport->port_name); in qla24xx_async_gpdb()
1331 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla24xx_async_gpdb()
1335 if (!vha->flags.online || fcport->flags & FCF_ASYNC_SENT) { in qla24xx_async_gpdb()
1337 "%s: %8phC online %d flags %x - not sending command.\n", in qla24xx_async_gpdb()
1338 __func__, fcport->port_name, vha->flags.online, fcport->flags); in qla24xx_async_gpdb()
1348 fcport->flags |= FCF_ASYNC_SENT; in qla24xx_async_gpdb()
1349 sp->type = SRB_MB_IOCB; in qla24xx_async_gpdb()
1350 sp->name = "gpdb"; in qla24xx_async_gpdb()
1351 sp->gen1 = fcport->rscn_gen; in qla24xx_async_gpdb()
1352 sp->gen2 = fcport->login_gen; in qla24xx_async_gpdb()
1354 mbx = &sp->u.iocb_cmd; in qla24xx_async_gpdb()
1355 mbx->timeout = qla2x00_async_iocb_timeout; in qla24xx_async_gpdb()
1358 pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); in qla24xx_async_gpdb()
1365 mb = sp->u.iocb_cmd.u.mbx.out_mb; in qla24xx_async_gpdb()
1367 mb[1] = fcport->loop_id; in qla24xx_async_gpdb()
1372 mb[9] = vha->vp_idx; in qla24xx_async_gpdb()
1375 mbx->u.mbx.in = pd; in qla24xx_async_gpdb()
1376 mbx->u.mbx.in_dma = pd_dma; in qla24xx_async_gpdb()
1378 sp->done = qla24xx_async_gpdb_sp_done; in qla24xx_async_gpdb()
1381 "Async-%s %8phC hndl %x opt %x\n", in qla24xx_async_gpdb()
1382 sp->name, fcport->port_name, sp->handle, opt); in qla24xx_async_gpdb()
1391 dma_pool_free(ha->s_dma_pool, pd, pd_dma); in qla24xx_async_gpdb()
1393 sp->free(sp); in qla24xx_async_gpdb()
1394 fcport->flags &= ~FCF_ASYNC_SENT; in qla24xx_async_gpdb()
1396 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla24xx_async_gpdb()
1406 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in __qla24xx_handle_gpdb_event()
1407 ea->fcport->login_gen++; in __qla24xx_handle_gpdb_event()
1408 ea->fcport->deleted = 0; in __qla24xx_handle_gpdb_event()
1409 ea->fcport->logout_on_delete = 1; in __qla24xx_handle_gpdb_event()
1411 if (!ea->fcport->login_succ && !IS_SW_RESV_ADDR(ea->fcport->d_id)) { in __qla24xx_handle_gpdb_event()
1412 vha->fcport_count++; in __qla24xx_handle_gpdb_event()
1413 ea->fcport->login_succ = 1; in __qla24xx_handle_gpdb_event()
1415 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in __qla24xx_handle_gpdb_event()
1416 qla24xx_sched_upd_fcport(ea->fcport); in __qla24xx_handle_gpdb_event()
1417 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in __qla24xx_handle_gpdb_event()
1418 } else if (ea->fcport->login_succ) { in __qla24xx_handle_gpdb_event()
1421 * must have triggered the session to be re-validate. in __qla24xx_handle_gpdb_event()
1426 __func__, __LINE__, ea->fcport->port_name); in __qla24xx_handle_gpdb_event()
1427 qla2x00_set_fcport_disc_state(ea->fcport, DSC_LOGIN_COMPLETE); in __qla24xx_handle_gpdb_event()
1429 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in __qla24xx_handle_gpdb_event()
1435 fc_port_t *fcport = ea->fcport; in qla24xx_handle_gpdb_event()
1437 struct srb *sp = ea->sp; in qla24xx_handle_gpdb_event()
1440 pd = (struct port_database_24xx *)sp->u.iocb_cmd.u.mbx.in; in qla24xx_handle_gpdb_event()
1442 fcport->flags &= ~FCF_ASYNC_SENT; in qla24xx_handle_gpdb_event()
1446 fcport->port_name, fcport->disc_state, pd->current_login_state, in qla24xx_handle_gpdb_event()
1447 fcport->fc4_type, ea->rc); in qla24xx_handle_gpdb_event()
1449 if (fcport->disc_state == DSC_DELETE_PEND) in qla24xx_handle_gpdb_event()
1452 if (NVME_TARGET(vha->hw, fcport)) in qla24xx_handle_gpdb_event()
1453 ls = pd->current_login_state >> 4; in qla24xx_handle_gpdb_event()
1455 ls = pd->current_login_state & 0xf; in qla24xx_handle_gpdb_event()
1457 if (ea->sp->gen2 != fcport->login_gen) { in qla24xx_handle_gpdb_event()
1462 __func__, fcport->port_name); in qla24xx_handle_gpdb_event()
1464 } else if (ea->sp->gen1 != fcport->rscn_gen) { in qla24xx_handle_gpdb_event()
1482 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_gpdb_event()
1489 __func__, __LINE__, fcport->port_name); in qla24xx_handle_gpdb_event()
1503 __func__, fcport->port_name, fcport->disc_state, in qla_chk_n2n_b4_login()
1504 fcport->fw_login_state, fcport->loop_id, fcport->login_retry); in qla_chk_n2n_b4_login()
1510 if (N2N_TOPO(vha->hw)) { in qla_chk_n2n_b4_login()
1513 mywwn = wwn_to_u64(vha->port_name); in qla_chk_n2n_b4_login()
1514 wwn = wwn_to_u64(fcport->port_name); in qla_chk_n2n_b4_login()
1517 else if ((fcport->fw_login_state == DSC_LS_PLOGI_COMP) in qla_chk_n2n_b4_login()
1519 fcport->plogi_nack_done_deadline)) in qla_chk_n2n_b4_login()
1529 if (login && fcport->login_retry) { in qla_chk_n2n_b4_login()
1530 fcport->login_retry--; in qla_chk_n2n_b4_login()
1531 if (fcport->loop_id == FC_NO_LOOP_ID) { in qla_chk_n2n_b4_login()
1532 fcport->fw_login_state = DSC_LS_PORT_UNAVAIL; in qla_chk_n2n_b4_login()
1536 "%s %d %8phC post del sess - out of loopid\n", in qla_chk_n2n_b4_login()
1537 __func__, __LINE__, fcport->port_name); in qla_chk_n2n_b4_login()
1538 fcport->scan_state = 0; in qla_chk_n2n_b4_login()
1545 __func__, __LINE__, fcport->port_name); in qla_chk_n2n_b4_login()
1558 __func__, fcport->port_name, fcport->disc_state, in qla24xx_fcport_handle_login()
1559 fcport->fw_login_state, fcport->login_pause, fcport->flags, in qla24xx_fcport_handle_login()
1560 fcport->conflict, fcport->last_rscn_gen, fcport->rscn_gen, in qla24xx_fcport_handle_login()
1561 fcport->login_gen, fcport->loop_id, fcport->scan_state); in qla24xx_fcport_handle_login()
1563 if (fcport->scan_state != QLA_FCPORT_FOUND || in qla24xx_fcport_handle_login()
1564 fcport->disc_state == DSC_DELETE_PEND) in qla24xx_fcport_handle_login()
1567 if ((fcport->loop_id != FC_NO_LOOP_ID) && in qla24xx_fcport_handle_login()
1569 ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) || in qla24xx_fcport_handle_login()
1570 (fcport->fw_login_state == DSC_LS_PRLI_PEND))) in qla24xx_fcport_handle_login()
1573 if (fcport->fw_login_state == DSC_LS_PLOGI_COMP && in qla24xx_fcport_handle_login()
1574 !N2N_TOPO(vha->hw)) { in qla24xx_fcport_handle_login()
1575 if (time_before_eq(jiffies, fcport->plogi_nack_done_deadline)) { in qla24xx_fcport_handle_login()
1576 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_fcport_handle_login()
1582 if (vha->host->active_mode == MODE_TARGET && !N2N_TOPO(vha->hw)) in qla24xx_fcport_handle_login()
1585 if (fcport->flags & (FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE)) { in qla24xx_fcport_handle_login()
1586 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_fcport_handle_login()
1590 switch (fcport->disc_state) { in qla24xx_fcport_handle_login()
1592 wwn = wwn_to_u64(fcport->node_name); in qla24xx_fcport_handle_login()
1593 switch (vha->hw->current_topology) { in qla24xx_fcport_handle_login()
1597 if (fcport->login_retry) { in qla24xx_fcport_handle_login()
1598 if (fcport->loop_id == FC_NO_LOOP_ID) { in qla24xx_fcport_handle_login()
1601 fcport->fw_login_state = in qla24xx_fcport_handle_login()
1604 fcport->login_retry--; in qla24xx_fcport_handle_login()
1609 fcport->port_name); in qla24xx_fcport_handle_login()
1619 __func__, __LINE__, fcport->port_name); in qla24xx_fcport_handle_login()
1621 } else if (fcport->loop_id == FC_NO_LOOP_ID) { in qla24xx_fcport_handle_login()
1624 __func__, __LINE__, fcport->port_name); in qla24xx_fcport_handle_login()
1634 switch (vha->hw->current_topology) { in qla24xx_fcport_handle_login()
1636 if ((fcport->current_login_state & 0xf) == 0x6) { in qla24xx_fcport_handle_login()
1639 __func__, __LINE__, fcport->port_name); in qla24xx_fcport_handle_login()
1640 fcport->chip_reset = in qla24xx_fcport_handle_login()
1641 vha->hw->base_qpair->chip_reset; in qla24xx_fcport_handle_login()
1646 __func__, __LINE__, fcport->port_name, in qla24xx_fcport_handle_login()
1647 NVME_TARGET(vha->hw, fcport) ? "NVME" : in qla24xx_fcport_handle_login()
1653 if (fcport->login_pause) { in qla24xx_fcport_handle_login()
1657 fcport->port_name); in qla24xx_fcport_handle_login()
1658 fcport->last_rscn_gen = fcport->rscn_gen; in qla24xx_fcport_handle_login()
1659 fcport->last_login_gen = fcport->login_gen; in qla24xx_fcport_handle_login()
1660 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_fcport_handle_login()
1669 if (N2N_TOPO(vha->hw)) in qla24xx_fcport_handle_login()
1682 if (fcport->fw_login_state == DSC_LS_PLOGI_COMP) in qla24xx_fcport_handle_login()
1687 sec = jiffies_to_msecs(jiffies - in qla24xx_fcport_handle_login()
1688 fcport->jiffies_at_registration)/1000; in qla24xx_fcport_handle_login()
1689 if (fcport->sec_since_registration < sec && sec && in qla24xx_fcport_handle_login()
1691 fcport->sec_since_registration = sec; in qla24xx_fcport_handle_login()
1692 ql_dbg(ql_dbg_disc, fcport->vha, 0xffff, in qla24xx_fcport_handle_login()
1693 "%s %8phC - Slow Rport registration(%d Sec)\n", in qla24xx_fcport_handle_login()
1694 __func__, fcport->port_name, sec); in qla24xx_fcport_handle_login()
1697 if (fcport->next_disc_state != DSC_DELETE_PEND) in qla24xx_fcport_handle_login()
1698 fcport->next_disc_state = DSC_ADISC; in qla24xx_fcport_handle_login()
1699 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_fcport_handle_login()
1718 e->u.new_sess.id = *id; in qla24xx_post_newsess_work()
1719 e->u.new_sess.pla = pla; in qla24xx_post_newsess_work()
1720 e->u.new_sess.fc4_type = fc4_type; in qla24xx_post_newsess_work()
1721 memcpy(e->u.new_sess.port_name, port_name, WWN_SIZE); in qla24xx_post_newsess_work()
1723 memcpy(e->u.new_sess.node_name, node_name, WWN_SIZE); in qla24xx_post_newsess_work()
1733 switch (ea->id.b.rsvd_1) { in qla2x00_handle_rscn()
1735 fcport = qla2x00_find_fcport_by_nportid(vha, &ea->id, 1); in qla2x00_handle_rscn()
1737 if (fcport->flags & FCF_FCP2_DEVICE && in qla2x00_handle_rscn()
1738 atomic_read(&fcport->state) == FCS_ONLINE) { in qla2x00_handle_rscn()
1741 fcport->d_id.b24, fcport->port_name); in qla2x00_handle_rscn()
1744 fcport->scan_needed = 1; in qla2x00_handle_rscn()
1745 fcport->rscn_gen++; in qla2x00_handle_rscn()
1749 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_handle_rscn()
1750 if (fcport->flags & FCF_FCP2_DEVICE && in qla2x00_handle_rscn()
1751 atomic_read(&fcport->state) == FCS_ONLINE) in qla2x00_handle_rscn()
1754 if ((ea->id.b24 & 0xffff00) == (fcport->d_id.b24 & 0xffff00)) { in qla2x00_handle_rscn()
1755 fcport->scan_needed = 1; in qla2x00_handle_rscn()
1756 fcport->rscn_gen++; in qla2x00_handle_rscn()
1761 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_handle_rscn()
1762 if (fcport->flags & FCF_FCP2_DEVICE && in qla2x00_handle_rscn()
1763 atomic_read(&fcport->state) == FCS_ONLINE) in qla2x00_handle_rscn()
1766 if ((ea->id.b24 & 0xff0000) == (fcport->d_id.b24 & 0xff0000)) { in qla2x00_handle_rscn()
1767 fcport->scan_needed = 1; in qla2x00_handle_rscn()
1768 fcport->rscn_gen++; in qla2x00_handle_rscn()
1774 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_handle_rscn()
1775 if (fcport->flags & FCF_FCP2_DEVICE && in qla2x00_handle_rscn()
1776 atomic_read(&fcport->state) == FCS_ONLINE) in qla2x00_handle_rscn()
1779 fcport->scan_needed = 1; in qla2x00_handle_rscn()
1780 fcport->rscn_gen++; in qla2x00_handle_rscn()
1785 spin_lock_irqsave(&vha->work_lock, flags); in qla2x00_handle_rscn()
1786 if (vha->scan.scan_flags == 0) { in qla2x00_handle_rscn()
1788 vha->scan.scan_flags |= SF_QUEUED; in qla2x00_handle_rscn()
1789 schedule_delayed_work(&vha->scan.scan_work, 5); in qla2x00_handle_rscn()
1791 spin_unlock_irqrestore(&vha->work_lock, flags); in qla2x00_handle_rscn()
1797 fc_port_t *fcport = ea->fcport; in qla24xx_handle_relogin_event()
1799 if (test_bit(UNLOADING, &vha->dpc_flags)) in qla24xx_handle_relogin_event()
1804 __func__, fcport->port_name, fcport->disc_state, in qla24xx_handle_relogin_event()
1805 fcport->fw_login_state, fcport->login_pause, in qla24xx_handle_relogin_event()
1806 fcport->deleted, fcport->conflict, in qla24xx_handle_relogin_event()
1807 fcport->last_rscn_gen, fcport->rscn_gen, in qla24xx_handle_relogin_event()
1808 fcport->last_login_gen, fcport->login_gen, in qla24xx_handle_relogin_event()
1809 fcport->flags); in qla24xx_handle_relogin_event()
1811 if (fcport->last_rscn_gen != fcport->rscn_gen) { in qla24xx_handle_relogin_event()
1813 __func__, __LINE__, fcport->port_name); in qla24xx_handle_relogin_event()
1825 if (vha->host->active_mode == MODE_TARGET) in qla_handle_els_plogi_done()
1830 __func__, __LINE__, ea->fcport->port_name); in qla_handle_els_plogi_done()
1831 qla24xx_post_prli_work(vha, ea->fcport); in qla_handle_els_plogi_done()
1842 switch (fcport->disc_state) { in qla_rscn_replay()
1849 if (fcport->scan_needed) { in qla_rscn_replay()
1851 ea.id = fcport->d_id; in qla_rscn_replay()
1853 qla2x00_handle_rscn(fcport->vha, &ea); in qla_rscn_replay()
1861 struct srb_iocb *tmf = &sp->u.iocb_cmd; in qla2x00_tmf_iocb_timeout()
1867 spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); in qla2x00_tmf_iocb_timeout()
1868 for (h = 1; h < sp->qpair->req->num_outstanding_cmds; h++) { in qla2x00_tmf_iocb_timeout()
1869 if (sp->qpair->req->outstanding_cmds[h] == sp) { in qla2x00_tmf_iocb_timeout()
1870 sp->qpair->req->outstanding_cmds[h] = NULL; in qla2x00_tmf_iocb_timeout()
1874 spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); in qla2x00_tmf_iocb_timeout()
1875 tmf->u.tmf.comp_status = cpu_to_le16(CS_TIMEOUT); in qla2x00_tmf_iocb_timeout()
1876 tmf->u.tmf.data = QLA_FUNCTION_FAILED; in qla2x00_tmf_iocb_timeout()
1877 complete(&tmf->u.tmf.comp); in qla2x00_tmf_iocb_timeout()
1883 struct srb_iocb *tmf = &sp->u.iocb_cmd; in qla2x00_tmf_sp_done()
1885 complete(&tmf->u.tmf.comp); in qla2x00_tmf_sp_done()
1892 struct scsi_qla_host *vha = fcport->vha; in qla2x00_async_tm_cmd()
1901 tm_iocb = &sp->u.iocb_cmd; in qla2x00_async_tm_cmd()
1902 sp->type = SRB_TM_CMD; in qla2x00_async_tm_cmd()
1903 sp->name = "tmf"; in qla2x00_async_tm_cmd()
1905 tm_iocb->timeout = qla2x00_tmf_iocb_timeout; in qla2x00_async_tm_cmd()
1906 init_completion(&tm_iocb->u.tmf.comp); in qla2x00_async_tm_cmd()
1909 tm_iocb->u.tmf.flags = flags; in qla2x00_async_tm_cmd()
1910 tm_iocb->u.tmf.lun = lun; in qla2x00_async_tm_cmd()
1911 tm_iocb->u.tmf.data = tag; in qla2x00_async_tm_cmd()
1912 sp->done = qla2x00_tmf_sp_done; in qla2x00_async_tm_cmd()
1915 "Async-tmf hdl=%x loop-id=%x portid=%02x%02x%02x.\n", in qla2x00_async_tm_cmd()
1916 sp->handle, fcport->loop_id, fcport->d_id.b.domain, in qla2x00_async_tm_cmd()
1917 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_async_tm_cmd()
1922 wait_for_completion(&tm_iocb->u.tmf.comp); in qla2x00_async_tm_cmd()
1924 rval = tm_iocb->u.tmf.data; in qla2x00_async_tm_cmd()
1931 if (!test_bit(UNLOADING, &vha->dpc_flags) && !IS_QLAFX00(vha->hw)) { in qla2x00_async_tm_cmd()
1932 flags = tm_iocb->u.tmf.flags; in qla2x00_async_tm_cmd()
1933 lun = (uint16_t)tm_iocb->u.tmf.lun; in qla2x00_async_tm_cmd()
1936 qla2x00_marker(vha, vha->hw->base_qpair, in qla2x00_async_tm_cmd()
1937 fcport->loop_id, lun, in qla2x00_async_tm_cmd()
1942 sp->free(sp); in qla2x00_async_tm_cmd()
1943 fcport->flags &= ~FCF_ASYNC_SENT; in qla2x00_async_tm_cmd()
1954 fc_port_t *fcport = sp->fcport; in qla24xx_async_abort_command()
1955 struct qla_qpair *qpair = sp->qpair; in qla24xx_async_abort_command()
1956 struct scsi_qla_host *vha = fcport->vha; in qla24xx_async_abort_command()
1957 struct req_que *req = qpair->req; in qla24xx_async_abort_command()
1959 spin_lock_irqsave(qpair->qp_lock_ptr, flags); in qla24xx_async_abort_command()
1960 for (handle = 1; handle < req->num_outstanding_cmds; handle++) { in qla24xx_async_abort_command()
1961 if (req->outstanding_cmds[handle] == sp) in qla24xx_async_abort_command()
1964 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qla24xx_async_abort_command()
1966 if (handle == req->num_outstanding_cmds) { in qla24xx_async_abort_command()
1970 if (sp->type == SRB_FXIOCB_DCMD) in qla24xx_async_abort_command()
1971 return qlafx00_fx_disc(vha, &vha->hw->mr.fcport, in qla24xx_async_abort_command()
1980 WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n", in qla24xx_handle_prli_done_event()
1981 ea->data[0]); in qla24xx_handle_prli_done_event()
1983 switch (ea->data[0]) { in qla24xx_handle_prli_done_event()
1987 __func__, __LINE__, ea->fcport->port_name); in qla24xx_handle_prli_done_event()
1989 ea->fcport->chip_reset = vha->hw->base_qpair->chip_reset; in qla24xx_handle_prli_done_event()
1990 ea->fcport->logout_on_delete = 1; in qla24xx_handle_prli_done_event()
1991 ea->fcport->nvme_prli_service_param = ea->iop[0]; in qla24xx_handle_prli_done_event()
1992 if (ea->iop[0] & NVME_PRLI_SP_FIRST_BURST) in qla24xx_handle_prli_done_event()
1993 ea->fcport->nvme_first_burst_size = in qla24xx_handle_prli_done_event()
1994 (ea->iop[1] & 0xffff) * 512; in qla24xx_handle_prli_done_event()
1996 ea->fcport->nvme_first_burst_size = 0; in qla24xx_handle_prli_done_event()
1997 qla24xx_post_gpdb_work(vha, ea->fcport, 0); in qla24xx_handle_prli_done_event()
2000 if ((ea->iop[0] == LSC_SCODE_ELS_REJECT) && in qla24xx_handle_prli_done_event()
2001 (ea->iop[1] == 0x50000)) { /* reson 5=busy expl:0x0 */ in qla24xx_handle_prli_done_event()
2002 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_prli_done_event()
2003 ea->fcport->fw_login_state = DSC_LS_PLOGI_COMP; in qla24xx_handle_prli_done_event()
2009 __func__, __LINE__, ea->fcport->port_name, in qla24xx_handle_prli_done_event()
2010 vha->hw->fc4_type_priority == FC4_PRIORITY_FCP ? in qla24xx_handle_prli_done_event()
2011 "FCP" : "NVMe", ea->fcport->fc4_type); in qla24xx_handle_prli_done_event()
2013 if (N2N_TOPO(vha->hw)) { in qla24xx_handle_prli_done_event()
2014 if (vha->hw->fc4_type_priority == FC4_PRIORITY_NVME) { in qla24xx_handle_prli_done_event()
2015 ea->fcport->fc4_type &= ~FS_FC4TYPE_NVME; in qla24xx_handle_prli_done_event()
2016 ea->fcport->fc4_type |= FS_FC4TYPE_FCP; in qla24xx_handle_prli_done_event()
2018 ea->fcport->fc4_type &= ~FS_FC4TYPE_FCP; in qla24xx_handle_prli_done_event()
2019 ea->fcport->fc4_type |= FS_FC4TYPE_NVME; in qla24xx_handle_prli_done_event()
2022 if (ea->fcport->n2n_link_reset_cnt < 3) { in qla24xx_handle_prli_done_event()
2023 ea->fcport->n2n_link_reset_cnt++; in qla24xx_handle_prli_done_event()
2024 vha->relogin_jif = jiffies + 2 * HZ; in qla24xx_handle_prli_done_event()
2029 set_bit(N2N_LINK_RESET, &vha->dpc_flags); in qla24xx_handle_prli_done_event()
2034 ea->fcport->port_name); in qla24xx_handle_prli_done_event()
2041 if (NVME_FCP_TARGET(ea->fcport)) { in qla24xx_handle_prli_done_event()
2045 ea->fcport->port_name, in qla24xx_handle_prli_done_event()
2046 (ea->fcport->fc4_type & FS_FC4TYPE_NVME) in qla24xx_handle_prli_done_event()
2048 if (vha->hw->fc4_type_priority == FC4_PRIORITY_NVME) in qla24xx_handle_prli_done_event()
2049 ea->fcport->fc4_type &= ~FS_FC4TYPE_NVME; in qla24xx_handle_prli_done_event()
2051 ea->fcport->fc4_type &= ~FS_FC4TYPE_FCP; in qla24xx_handle_prli_done_event()
2054 ea->fcport->flags &= ~FCF_ASYNC_SENT; in qla24xx_handle_prli_done_event()
2055 ea->fcport->keep_nport_handle = 0; in qla24xx_handle_prli_done_event()
2056 ea->fcport->logout_on_delete = 1; in qla24xx_handle_prli_done_event()
2057 qlt_schedule_sess_for_deletion(ea->fcport); in qla24xx_handle_prli_done_event()
2070 struct fc_port *fcport = ea->fcport; in qla24xx_handle_plogi_done_event()
2074 __func__, fcport->port_name, fcport->disc_state, in qla24xx_handle_plogi_done_event()
2075 fcport->fw_login_state, ea->rc, ea->sp->gen2, fcport->login_gen, in qla24xx_handle_plogi_done_event()
2076 ea->sp->gen1, fcport->rscn_gen, in qla24xx_handle_plogi_done_event()
2077 ea->data[0], ea->data[1], ea->iop[0], ea->iop[1]); in qla24xx_handle_plogi_done_event()
2079 if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) || in qla24xx_handle_plogi_done_event()
2080 (fcport->fw_login_state == DSC_LS_PRLI_PEND)) { in qla24xx_handle_plogi_done_event()
2083 __func__, __LINE__, fcport->port_name); in qla24xx_handle_plogi_done_event()
2087 if ((fcport->disc_state == DSC_DELETE_PEND) || in qla24xx_handle_plogi_done_event()
2088 (fcport->disc_state == DSC_DELETED)) { in qla24xx_handle_plogi_done_event()
2089 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_plogi_done_event()
2093 if (ea->sp->gen2 != fcport->login_gen) { in qla24xx_handle_plogi_done_event()
2097 __func__, fcport->port_name); in qla24xx_handle_plogi_done_event()
2098 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_plogi_done_event()
2100 } else if (ea->sp->gen1 != fcport->rscn_gen) { in qla24xx_handle_plogi_done_event()
2103 __func__, fcport->port_name); in qla24xx_handle_plogi_done_event()
2109 WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n", in qla24xx_handle_plogi_done_event()
2110 ea->data[0]); in qla24xx_handle_plogi_done_event()
2112 switch (ea->data[0]) { in qla24xx_handle_plogi_done_event()
2115 * Driver must validate login state - If PRLI not complete, in qla24xx_handle_plogi_done_event()
2119 if (NVME_TARGET(vha->hw, ea->fcport)) { in qla24xx_handle_plogi_done_event()
2122 __func__, __LINE__, ea->fcport->port_name); in qla24xx_handle_plogi_done_event()
2123 qla24xx_post_prli_work(vha, ea->fcport); in qla24xx_handle_plogi_done_event()
2127 __func__, __LINE__, ea->fcport->port_name, in qla24xx_handle_plogi_done_event()
2128 ea->fcport->loop_id, ea->fcport->d_id.b24); in qla24xx_handle_plogi_done_event()
2130 set_bit(ea->fcport->loop_id, vha->hw->loop_id_map); in qla24xx_handle_plogi_done_event()
2131 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_handle_plogi_done_event()
2132 ea->fcport->chip_reset = vha->hw->base_qpair->chip_reset; in qla24xx_handle_plogi_done_event()
2133 ea->fcport->logout_on_delete = 1; in qla24xx_handle_plogi_done_event()
2134 ea->fcport->send_els_logo = 0; in qla24xx_handle_plogi_done_event()
2135 ea->fcport->fw_login_state = DSC_LS_PRLI_COMP; in qla24xx_handle_plogi_done_event()
2136 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_handle_plogi_done_event()
2138 qla24xx_post_gpdb_work(vha, ea->fcport, 0); in qla24xx_handle_plogi_done_event()
2143 __func__, __LINE__, ea->fcport->port_name, ea->data[1]); in qla24xx_handle_plogi_done_event()
2145 qlt_schedule_sess_for_deletion(ea->fcport); in qla24xx_handle_plogi_done_event()
2149 cid.b.domain = (ea->iop[1] >> 16) & 0xff; in qla24xx_handle_plogi_done_event()
2150 cid.b.area = (ea->iop[1] >> 8) & 0xff; in qla24xx_handle_plogi_done_event()
2151 cid.b.al_pa = ea->iop[1] & 0xff; in qla24xx_handle_plogi_done_event()
2156 __func__, __LINE__, ea->fcport->port_name, in qla24xx_handle_plogi_done_event()
2157 ea->fcport->loop_id, cid.b24); in qla24xx_handle_plogi_done_event()
2159 set_bit(ea->fcport->loop_id, vha->hw->loop_id_map); in qla24xx_handle_plogi_done_event()
2160 ea->fcport->loop_id = FC_NO_LOOP_ID; in qla24xx_handle_plogi_done_event()
2161 qla24xx_post_gnl_work(vha, ea->fcport); in qla24xx_handle_plogi_done_event()
2164 lid = ea->iop[1] & 0xffff; in qla24xx_handle_plogi_done_event()
2166 wwn_to_u64(ea->fcport->port_name), in qla24xx_handle_plogi_done_event()
2167 ea->fcport->d_id, lid, &conflict_fcport); in qla24xx_handle_plogi_done_event()
2175 conflict_fcport->conflict = ea->fcport; in qla24xx_handle_plogi_done_event()
2176 ea->fcport->login_pause = 1; in qla24xx_handle_plogi_done_event()
2180 __func__, __LINE__, ea->fcport->port_name, in qla24xx_handle_plogi_done_event()
2181 ea->fcport->d_id.b24, lid); in qla24xx_handle_plogi_done_event()
2185 __func__, __LINE__, ea->fcport->port_name, in qla24xx_handle_plogi_done_event()
2186 ea->fcport->d_id.b24, lid); in qla24xx_handle_plogi_done_event()
2188 qla2x00_clear_loop_id(ea->fcport); in qla24xx_handle_plogi_done_event()
2189 set_bit(lid, vha->hw->loop_id_map); in qla24xx_handle_plogi_done_event()
2190 ea->fcport->loop_id = lid; in qla24xx_handle_plogi_done_event()
2191 ea->fcport->keep_nport_handle = 0; in qla24xx_handle_plogi_done_event()
2192 ea->fcport->logout_on_delete = 1; in qla24xx_handle_plogi_done_event()
2193 qlt_schedule_sess_for_deletion(ea->fcport); in qla24xx_handle_plogi_done_event()
2208 struct qla_hw_data *ha = vha->hw; in qla83xx_nic_core_fw_load()
2215 * flash-info / other param in qla83xx_nic_core_fw_load()
2217 ha->fcoe_dev_init_timeout = QLA83XX_IDC_INITIALIZATION_TIMEOUT; in qla83xx_nic_core_fw_load()
2218 ha->fcoe_reset_timeout = QLA83XX_IDC_RESET_ACK_TIMEOUT; in qla83xx_nic_core_fw_load()
2223 "Error while setting DRV-Presence.\n"); in qla83xx_nic_core_fw_load()
2233 * Init-Owner: Set IDC-Major-Version and Clear IDC-Lock-Recovery in qla83xx_nic_core_fw_load()
2238 if (ha->flags.nic_core_reset_owner) { in qla83xx_nic_core_fw_load()
2243 /* Clearing IDC-Lock-Recovery register */ in qla83xx_nic_core_fw_load()
2259 idc_minor_ver |= (QLA83XX_SUPP_IDC_MINOR_VERSION << (ha->portnum * 2)); in qla83xx_nic_core_fw_load()
2262 if (ha->flags.nic_core_reset_owner) { in qla83xx_nic_core_fw_load()
2291 struct qla_hw_data *ha = vha->hw; in qla2x00_initialize_adapter()
2292 struct req_que *req = ha->req_q_map[0]; in qla2x00_initialize_adapter()
2293 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla2x00_initialize_adapter()
2295 memset(&vha->qla_stats, 0, sizeof(vha->qla_stats)); in qla2x00_initialize_adapter()
2296 memset(&vha->fc_host_stat, 0, sizeof(vha->fc_host_stat)); in qla2x00_initialize_adapter()
2299 vha->flags.online = 0; in qla2x00_initialize_adapter()
2300 ha->flags.chip_reset_done = 0; in qla2x00_initialize_adapter()
2301 vha->flags.reset_active = 0; in qla2x00_initialize_adapter()
2302 ha->flags.pci_channel_io_perm_failure = 0; in qla2x00_initialize_adapter()
2303 ha->flags.eeh_busy = 0; in qla2x00_initialize_adapter()
2304 vha->qla_stats.jiffies_at_last_reset = get_jiffies_64(); in qla2x00_initialize_adapter()
2305 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); in qla2x00_initialize_adapter()
2306 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_initialize_adapter()
2307 vha->device_flags = DFLG_NO_CABLE; in qla2x00_initialize_adapter()
2308 vha->dpc_flags = 0; in qla2x00_initialize_adapter()
2309 vha->flags.management_server_logged_in = 0; in qla2x00_initialize_adapter()
2310 vha->marker_needed = 0; in qla2x00_initialize_adapter()
2311 ha->isp_abort_cnt = 0; in qla2x00_initialize_adapter()
2312 ha->beacon_blink_led = 0; in qla2x00_initialize_adapter()
2314 set_bit(0, ha->req_qid_map); in qla2x00_initialize_adapter()
2315 set_bit(0, ha->rsp_qid_map); in qla2x00_initialize_adapter()
2319 rval = ha->isp_ops->pci_config(vha); in qla2x00_initialize_adapter()
2326 ha->isp_ops->reset_chip(vha); in qla2x00_initialize_adapter()
2330 if (rd_reg_word(®->mailbox12) & BIT_0) in qla2x00_initialize_adapter()
2331 ha->flags.secure_adapter = 1; in qla2x00_initialize_adapter()
2333 (ha->flags.secure_adapter) ? "Yes" : "No"); in qla2x00_initialize_adapter()
2355 ha->isp_ops->get_flash_version(vha, req->ring); in qla2x00_initialize_adapter()
2360 ha->fc4_type_priority = FC4_PRIORITY_FCP; in qla2x00_initialize_adapter()
2362 ha->isp_ops->nvram_config(vha); in qla2x00_initialize_adapter()
2364 if (ha->fc4_type_priority != FC4_PRIORITY_FCP && in qla2x00_initialize_adapter()
2365 ha->fc4_type_priority != FC4_PRIORITY_NVME) in qla2x00_initialize_adapter()
2366 ha->fc4_type_priority = FC4_PRIORITY_FCP; in qla2x00_initialize_adapter()
2369 ha->fc4_type_priority == FC4_PRIORITY_FCP ? "FCP" : "NVMe"); in qla2x00_initialize_adapter()
2371 if (ha->flags.disable_serdes) { in qla2x00_initialize_adapter()
2374 "Masking HBA WWPN %8phN (via NVRAM).\n", vha->port_name); in qla2x00_initialize_adapter()
2388 rval = ha->isp_ops->chip_diag(vha); in qla2x00_initialize_adapter()
2397 ha->cs84xx = qla84xx_get_chip(vha); in qla2x00_initialize_adapter()
2398 if (!ha->cs84xx) { in qla2x00_initialize_adapter()
2412 ha->flags.chip_reset_done = 1; in qla2x00_initialize_adapter()
2444 * qla2100_pci_config() - Setup ISP21xx PCI configuration registers.
2454 struct qla_hw_data *ha = vha->hw; in qla2100_pci_config()
2455 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2100_pci_config()
2457 pci_set_master(ha->pdev); in qla2100_pci_config()
2458 pci_try_set_mwi(ha->pdev); in qla2100_pci_config()
2460 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); in qla2100_pci_config()
2462 pci_write_config_word(ha->pdev, PCI_COMMAND, w); in qla2100_pci_config()
2464 pci_disable_rom(ha->pdev); in qla2100_pci_config()
2467 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2100_pci_config()
2468 ha->pci_attr = rd_reg_word(®->ctrl_status); in qla2100_pci_config()
2469 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2100_pci_config()
2475 * qla2300_pci_config() - Setup ISP23xx PCI configuration registers.
2486 struct qla_hw_data *ha = vha->hw; in qla2300_pci_config()
2487 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2300_pci_config()
2489 pci_set_master(ha->pdev); in qla2300_pci_config()
2490 pci_try_set_mwi(ha->pdev); in qla2300_pci_config()
2492 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); in qla2300_pci_config()
2497 pci_write_config_word(ha->pdev, PCI_COMMAND, w); in qla2300_pci_config()
2503 * fb revision level -- a 6 indicates it really is a 2300 and in qla2300_pci_config()
2507 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2300_pci_config()
2510 wrt_reg_word(®->hccr, HCCR_PAUSE_RISC); in qla2300_pci_config()
2512 if ((rd_reg_word(®->hccr) & HCCR_RISC_PAUSE) != 0) in qla2300_pci_config()
2519 wrt_reg_word(®->ctrl_status, 0x20); in qla2300_pci_config()
2520 rd_reg_word(®->ctrl_status); in qla2300_pci_config()
2523 ha->fb_rev = RD_FB_CMD_REG(ha, reg); in qla2300_pci_config()
2525 if (ha->fb_rev == FPM_2300) in qla2300_pci_config()
2526 pci_clear_mwi(ha->pdev); in qla2300_pci_config()
2529 wrt_reg_word(®->ctrl_status, 0x0); in qla2300_pci_config()
2530 rd_reg_word(®->ctrl_status); in qla2300_pci_config()
2533 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2300_pci_config()
2535 if ((rd_reg_word(®->hccr) & HCCR_RISC_PAUSE) == 0) in qla2300_pci_config()
2541 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2300_pci_config()
2544 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); in qla2300_pci_config()
2546 pci_disable_rom(ha->pdev); in qla2300_pci_config()
2549 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2300_pci_config()
2550 ha->pci_attr = rd_reg_word(®->ctrl_status); in qla2300_pci_config()
2551 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2300_pci_config()
2557 * qla24xx_pci_config() - Setup ISP24xx PCI configuration registers.
2567 struct qla_hw_data *ha = vha->hw; in qla24xx_pci_config()
2568 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla24xx_pci_config()
2570 pci_set_master(ha->pdev); in qla24xx_pci_config()
2571 pci_try_set_mwi(ha->pdev); in qla24xx_pci_config()
2573 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); in qla24xx_pci_config()
2576 pci_write_config_word(ha->pdev, PCI_COMMAND, w); in qla24xx_pci_config()
2578 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); in qla24xx_pci_config()
2580 /* PCI-X -- adjust Maximum Memory Read Byte Count (2048). */ in qla24xx_pci_config()
2581 if (pci_find_capability(ha->pdev, PCI_CAP_ID_PCIX)) in qla24xx_pci_config()
2582 pcix_set_mmrbc(ha->pdev, 2048); in qla24xx_pci_config()
2584 /* PCIe -- adjust Maximum Read Request Size (2048). */ in qla24xx_pci_config()
2585 if (pci_is_pcie(ha->pdev)) in qla24xx_pci_config()
2586 pcie_set_readrq(ha->pdev, 4096); in qla24xx_pci_config()
2588 pci_disable_rom(ha->pdev); in qla24xx_pci_config()
2590 ha->chip_revision = ha->pdev->revision; in qla24xx_pci_config()
2593 spin_lock_irqsave(&ha->hardware_lock, flags); in qla24xx_pci_config()
2594 ha->pci_attr = rd_reg_dword(®->ctrl_status); in qla24xx_pci_config()
2595 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_pci_config()
2601 * qla25xx_pci_config() - Setup ISP25xx PCI configuration registers.
2610 struct qla_hw_data *ha = vha->hw; in qla25xx_pci_config()
2612 pci_set_master(ha->pdev); in qla25xx_pci_config()
2613 pci_try_set_mwi(ha->pdev); in qla25xx_pci_config()
2615 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); in qla25xx_pci_config()
2618 pci_write_config_word(ha->pdev, PCI_COMMAND, w); in qla25xx_pci_config()
2620 /* PCIe -- adjust Maximum Read Request Size (2048). */ in qla25xx_pci_config()
2621 if (pci_is_pcie(ha->pdev)) in qla25xx_pci_config()
2622 pcie_set_readrq(ha->pdev, 4096); in qla25xx_pci_config()
2624 pci_disable_rom(ha->pdev); in qla25xx_pci_config()
2626 ha->chip_revision = ha->pdev->revision; in qla25xx_pci_config()
2632 * qla2x00_isp_firmware() - Choose firmware image.
2643 struct qla_hw_data *ha = vha->hw; in qla2x00_isp_firmware()
2648 if (ha->flags.disable_risc_code_load) { in qla2x00_isp_firmware()
2652 rval = qla2x00_verify_checksum(vha, ha->fw_srisc_address); in qla2x00_isp_firmware()
2668 * qla2x00_reset_chip() - Reset ISP chip.
2677 struct qla_hw_data *ha = vha->hw; in qla2x00_reset_chip()
2678 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_reset_chip()
2683 if (unlikely(pci_channel_offline(ha->pdev))) in qla2x00_reset_chip()
2686 ha->isp_ops->disable_intrs(ha); in qla2x00_reset_chip()
2688 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_reset_chip()
2692 pci_read_config_word(ha->pdev, PCI_COMMAND, &cmd); in qla2x00_reset_chip()
2694 pci_write_config_word(ha->pdev, PCI_COMMAND, cmd); in qla2x00_reset_chip()
2698 wrt_reg_word(®->hccr, HCCR_PAUSE_RISC); in qla2x00_reset_chip()
2701 if ((rd_reg_word(®->hccr) & in qla2x00_reset_chip()
2707 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2712 wrt_reg_word(®->ctrl_status, 0x20); in qla2x00_reset_chip()
2713 rd_reg_word(®->ctrl_status); /* PCI Posting. */ in qla2x00_reset_chip()
2716 wrt_reg_word(®->fpm_diag_config, 0x100); in qla2x00_reset_chip()
2717 rd_reg_word(®->fpm_diag_config); /* PCI Posting. */ in qla2x00_reset_chip()
2721 wrt_reg_word(®->fpm_diag_config, 0x0); in qla2x00_reset_chip()
2722 rd_reg_word(®->fpm_diag_config); /* PCI Posting. */ in qla2x00_reset_chip()
2726 wrt_reg_word(®->ctrl_status, 0x10); in qla2x00_reset_chip()
2727 rd_reg_word(®->ctrl_status); /* PCI Posting. */ in qla2x00_reset_chip()
2745 wrt_reg_word(®->ctrl_status, 0); in qla2x00_reset_chip()
2746 rd_reg_word(®->ctrl_status); /* PCI Posting. */ in qla2x00_reset_chip()
2749 wrt_reg_word(®->hccr, HCCR_RESET_RISC); in qla2x00_reset_chip()
2750 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2753 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2x00_reset_chip()
2754 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2757 wrt_reg_word(®->hccr, HCCR_CLR_RISC_INT); in qla2x00_reset_chip()
2758 wrt_reg_word(®->hccr, HCCR_CLR_HOST_INT); in qla2x00_reset_chip()
2761 wrt_reg_word(®->ctrl_status, CSR_ISP_SOFT_RESET); in qla2x00_reset_chip()
2771 for (cnt = 30000; cnt; cnt--) { in qla2x00_reset_chip()
2772 if ((rd_reg_word(®->ctrl_status) & in qla2x00_reset_chip()
2781 wrt_reg_word(®->hccr, HCCR_RESET_RISC); in qla2x00_reset_chip()
2783 wrt_reg_word(®->semaphore, 0); in qla2x00_reset_chip()
2786 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2x00_reset_chip()
2787 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2801 pci_write_config_word(ha->pdev, PCI_COMMAND, cmd); in qla2x00_reset_chip()
2805 wrt_reg_word(®->hccr, HCCR_DISABLE_PARITY_PAUSE); in qla2x00_reset_chip()
2806 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2809 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_reset_chip()
2815 * qla81xx_reset_mpi() - Reset's MPI FW via Write MPI Register MBC.
2825 if (!IS_QLA81XX(vha->hw)) in qla81xx_reset_mpi()
2832 * qla24xx_reset_risc() - Perform full reset of ISP24xx RISC.
2841 struct qla_hw_data *ha = vha->hw; in qla24xx_reset_risc()
2842 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla24xx_reset_risc()
2848 spin_lock_irqsave(&ha->hardware_lock, flags); in qla24xx_reset_risc()
2851 wrt_reg_dword(®->ctrl_status, CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); in qla24xx_reset_risc()
2853 if ((rd_reg_dword(®->ctrl_status) & CSRX_DMA_ACTIVE) == 0) in qla24xx_reset_risc()
2859 if (!(rd_reg_dword(®->ctrl_status) & CSRX_DMA_ACTIVE)) in qla24xx_reset_risc()
2860 set_bit(DMA_SHUTDOWN_CMPL, &ha->fw_dump_cap_flags); in qla24xx_reset_risc()
2864 rd_reg_dword(®->hccr), in qla24xx_reset_risc()
2865 rd_reg_dword(®->ctrl_status), in qla24xx_reset_risc()
2866 (rd_reg_dword(®->ctrl_status) & CSRX_DMA_ACTIVE)); in qla24xx_reset_risc()
2868 wrt_reg_dword(®->ctrl_status, in qla24xx_reset_risc()
2870 pci_read_config_word(ha->pdev, PCI_COMMAND, &wd); in qla24xx_reset_risc()
2875 rd_reg_word(®->mailbox0); in qla24xx_reset_risc()
2876 for (cnt = 10000; rd_reg_word(®->mailbox0) != 0 && in qla24xx_reset_risc()
2877 rval == QLA_SUCCESS; cnt--) { in qla24xx_reset_risc()
2886 set_bit(ISP_MBX_RDY, &ha->fw_dump_cap_flags); in qla24xx_reset_risc()
2890 rd_reg_dword(®->hccr), in qla24xx_reset_risc()
2891 rd_reg_word(®->mailbox0)); in qla24xx_reset_risc()
2893 /* Wait for soft-reset to complete. */ in qla24xx_reset_risc()
2894 rd_reg_dword(®->ctrl_status); in qla24xx_reset_risc()
2897 if ((rd_reg_dword(®->ctrl_status) & in qla24xx_reset_risc()
2903 if (!(rd_reg_dword(®->ctrl_status) & CSRX_ISP_SOFT_RESET)) in qla24xx_reset_risc()
2904 set_bit(ISP_SOFT_RESET_CMPL, &ha->fw_dump_cap_flags); in qla24xx_reset_risc()
2908 rd_reg_dword(®->hccr), in qla24xx_reset_risc()
2909 rd_reg_dword(®->ctrl_status)); in qla24xx_reset_risc()
2912 if (test_and_clear_bit(MPI_RESET_NEEDED, &vha->dpc_flags)) { in qla24xx_reset_risc()
2915 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla24xx_reset_risc()
2916 set_bit(MPI_RESET_NEEDED, &vha->dpc_flags); in qla24xx_reset_risc()
2923 vha->flags.online = 0; in qla24xx_reset_risc()
2928 wrt_reg_dword(®->hccr, HCCRX_SET_RISC_RESET); in qla24xx_reset_risc()
2929 rd_reg_dword(®->hccr); in qla24xx_reset_risc()
2931 wrt_reg_dword(®->hccr, HCCRX_REL_RISC_PAUSE); in qla24xx_reset_risc()
2932 rd_reg_dword(®->hccr); in qla24xx_reset_risc()
2934 wrt_reg_dword(®->hccr, HCCRX_CLR_RISC_RESET); in qla24xx_reset_risc()
2935 rd_reg_dword(®->hccr); in qla24xx_reset_risc()
2937 rd_reg_word(®->mailbox0); in qla24xx_reset_risc()
2938 for (cnt = 60; rd_reg_word(®->mailbox0) != 0 && in qla24xx_reset_risc()
2939 rval == QLA_SUCCESS; cnt--) { in qla24xx_reset_risc()
2947 set_bit(RISC_RDY_AFT_RESET, &ha->fw_dump_cap_flags); in qla24xx_reset_risc()
2951 rd_reg_dword(®->hccr), in qla24xx_reset_risc()
2952 rd_reg_word(®->mailbox0)); in qla24xx_reset_risc()
2954 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_reset_risc()
2961 ha->isp_ops->enable_intrs(ha); in qla24xx_reset_risc()
2969 struct device_reg_24xx __iomem *reg = &vha->hw->iobase->isp24; in qla25xx_read_risc_sema_reg()
2971 wrt_reg_dword(®->iobase_addr, RISC_REGISTER_BASE_OFFSET); in qla25xx_read_risc_sema_reg()
2972 *data = rd_reg_dword(®->iobase_window + RISC_REGISTER_WINDOW_OFFSET); in qla25xx_read_risc_sema_reg()
2978 struct device_reg_24xx __iomem *reg = &vha->hw->iobase->isp24; in qla25xx_write_risc_sema_reg()
2980 wrt_reg_dword(®->iobase_addr, RISC_REGISTER_BASE_OFFSET); in qla25xx_write_risc_sema_reg()
2981 wrt_reg_dword(®->iobase_window + RISC_REGISTER_WINDOW_OFFSET, data); in qla25xx_write_risc_sema_reg()
2993 if (vha->hw->pdev->subsystem_device != 0x0175 && in qla25xx_manipulate_risc_semaphore()
2994 vha->hw->pdev->subsystem_device != 0x0240) in qla25xx_manipulate_risc_semaphore()
2997 wrt_reg_dword(&vha->hw->iobase->isp24.hccr, HCCRX_SET_RISC_PAUSE); in qla25xx_manipulate_risc_semaphore()
3003 while (n--) { in qla25xx_manipulate_risc_semaphore()
3023 while (n--) { in qla25xx_manipulate_risc_semaphore()
3046 * qla24xx_reset_chip() - Reset ISP24xx chip.
3054 struct qla_hw_data *ha = vha->hw; in qla24xx_reset_chip()
3057 if (pci_channel_offline(ha->pdev) && in qla24xx_reset_chip()
3058 ha->flags.pci_channel_io_perm_failure) { in qla24xx_reset_chip()
3062 ha->isp_ops->disable_intrs(ha); in qla24xx_reset_chip()
3073 * qla2x00_chip_diag() - Test chip for proper operation.
3082 struct qla_hw_data *ha = vha->hw; in qla2x00_chip_diag()
3083 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_chip_diag()
3088 struct req_que *req = ha->req_q_map[0]; in qla2x00_chip_diag()
3094 ®->flash_address); in qla2x00_chip_diag()
3096 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_chip_diag()
3099 wrt_reg_word(®->ctrl_status, CSR_ISP_SOFT_RESET); in qla2x00_chip_diag()
3106 data = qla2x00_debounce_register(®->ctrl_status); in qla2x00_chip_diag()
3107 for (cnt = 6000000 ; cnt && (data & CSR_ISP_SOFT_RESET); cnt--) { in qla2x00_chip_diag()
3109 data = rd_reg_word(®->ctrl_status); in qla2x00_chip_diag()
3120 wrt_reg_word(®->hccr, HCCR_RESET_RISC); in qla2x00_chip_diag()
3121 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2x00_chip_diag()
3126 for (cnt = 6000000; cnt && (data == MBS_BUSY); cnt--) { in qla2x00_chip_diag()
3152 ha->product_id[0] = mb[1]; in qla2x00_chip_diag()
3153 ha->product_id[1] = mb[2]; in qla2x00_chip_diag()
3154 ha->product_id[2] = mb[3]; in qla2x00_chip_diag()
3155 ha->product_id[3] = mb[4]; in qla2x00_chip_diag()
3158 if (req->length > 1024) in qla2x00_chip_diag()
3159 ha->fw_transfer_size = REQUEST_ENTRY_SIZE * 1024; in qla2x00_chip_diag()
3161 ha->fw_transfer_size = REQUEST_ENTRY_SIZE * in qla2x00_chip_diag()
3162 req->length; in qla2x00_chip_diag()
3169 ha->device_type |= DT_ISP2200A; in qla2x00_chip_diag()
3170 ha->fw_transfer_size = 128; in qla2x00_chip_diag()
3174 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_chip_diag()
3184 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_chip_diag()
3191 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_chip_diag()
3197 * qla24xx_chip_diag() - Test ISP24xx for proper operation.
3206 struct qla_hw_data *ha = vha->hw; in qla24xx_chip_diag()
3207 struct req_que *req = ha->req_q_map[0]; in qla24xx_chip_diag()
3212 ha->fw_transfer_size = REQUEST_ENTRY_SIZE * req->length; in qla24xx_chip_diag()
3232 struct qla_hw_data *ha = vha->hw; in qla2x00_init_fce_trace()
3241 if (ha->fce) { in qla2x00_init_fce_trace()
3249 tc = dma_alloc_coherent(&ha->pdev->dev, FCE_SIZE, &tc_dma, in qla2x00_init_fce_trace()
3259 ha->fce_mb, &ha->fce_bufs); in qla2x00_init_fce_trace()
3263 dma_free_coherent(&ha->pdev->dev, FCE_SIZE, tc, tc_dma); in qla2x00_init_fce_trace()
3270 ha->flags.fce_enabled = 1; in qla2x00_init_fce_trace()
3271 ha->fce_dma = tc_dma; in qla2x00_init_fce_trace()
3272 ha->fce = tc; in qla2x00_init_fce_trace()
3281 struct qla_hw_data *ha = vha->hw; in qla2x00_init_eft_trace()
3286 if (ha->eft) { in qla2x00_init_eft_trace()
3294 tc = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &tc_dma, in qla2x00_init_eft_trace()
3307 dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc, tc_dma); in qla2x00_init_eft_trace()
3314 ha->eft_dma = tc_dma; in qla2x00_init_eft_trace()
3315 ha->eft = tc; in qla2x00_init_eft_trace()
3330 struct qla_hw_data *ha = vha->hw; in qla2x00_alloc_fw_dump()
3331 struct req_que *req = ha->req_q_map[0]; in qla2x00_alloc_fw_dump()
3332 struct rsp_que *rsp = ha->rsp_q_map[0]; in qla2x00_alloc_fw_dump()
3335 if (ha->fw_dump) { in qla2x00_alloc_fw_dump()
3341 ha->fw_dumped = 0; in qla2x00_alloc_fw_dump()
3342 ha->fw_dump_cap_flags = 0; in qla2x00_alloc_fw_dump()
3350 mem_size = (ha->fw_memory_size - 0x11000 + 1) * in qla2x00_alloc_fw_dump()
3362 mem_size = (ha->fw_memory_size - 0x100000 + 1) * in qla2x00_alloc_fw_dump()
3364 if (ha->mqenable) { in qla2x00_alloc_fw_dump()
3368 * Allocate maximum buffer size for all queues - Q0. in qla2x00_alloc_fw_dump()
3369 * Resizing must be done at end-of-dump processing. in qla2x00_alloc_fw_dump()
3371 mq_size += (ha->max_req_queues - 1) * in qla2x00_alloc_fw_dump()
3372 (req->length * sizeof(request_t)); in qla2x00_alloc_fw_dump()
3373 mq_size += (ha->max_rsp_queues - 1) * in qla2x00_alloc_fw_dump()
3374 (rsp->length * sizeof(response_t)); in qla2x00_alloc_fw_dump()
3376 if (ha->tgt.atio_ring) in qla2x00_alloc_fw_dump()
3377 mq_size += ha->tgt.atio_q_length * sizeof(request_t); in qla2x00_alloc_fw_dump()
3380 if (ha->fce) in qla2x00_alloc_fw_dump()
3383 if (ha->eft) in qla2x00_alloc_fw_dump()
3388 struct fwdt *fwdt = ha->fwdt; in qla2x00_alloc_fw_dump()
3392 if (!fwdt->template) { in qla2x00_alloc_fw_dump()
3394 "-> fwdt%u no template\n", j); in qla2x00_alloc_fw_dump()
3398 "-> fwdt%u calculating fwdump size...\n", j); in qla2x00_alloc_fw_dump()
3399 fwdt->dump_size = qla27xx_fwdt_calculate_dump_size( in qla2x00_alloc_fw_dump()
3400 vha, fwdt->template); in qla2x00_alloc_fw_dump()
3402 "-> fwdt%u calculated fwdump size = %#lx bytes\n", in qla2x00_alloc_fw_dump()
3403 j, fwdt->dump_size); in qla2x00_alloc_fw_dump()
3404 dump_size += fwdt->dump_size; in qla2x00_alloc_fw_dump()
3407 dump_size += ha->fwdt[1].dump_size; in qla2x00_alloc_fw_dump()
3409 req_q_size = req->length * sizeof(request_t); in qla2x00_alloc_fw_dump()
3410 rsp_q_size = rsp->length * sizeof(response_t); in qla2x00_alloc_fw_dump()
3414 ha->chain_offset = dump_size; in qla2x00_alloc_fw_dump()
3416 if (ha->exchoffld_buf) in qla2x00_alloc_fw_dump()
3418 ha->exchoffld_size; in qla2x00_alloc_fw_dump()
3419 if (ha->exlogin_buf) in qla2x00_alloc_fw_dump()
3421 ha->exlogin_size; in qla2x00_alloc_fw_dump()
3424 if (!ha->fw_dump_len || dump_size > ha->fw_dump_alloc_len) { in qla2x00_alloc_fw_dump()
3428 __func__, dump_size, ha->fw_dump_len, in qla2x00_alloc_fw_dump()
3429 ha->fw_dump_alloc_len); in qla2x00_alloc_fw_dump()
3437 mutex_lock(&ha->optrom_mutex); in qla2x00_alloc_fw_dump()
3438 if (ha->fw_dumped) { in qla2x00_alloc_fw_dump()
3439 memcpy(fw_dump, ha->fw_dump, ha->fw_dump_len); in qla2x00_alloc_fw_dump()
3440 vfree(ha->fw_dump); in qla2x00_alloc_fw_dump()
3441 ha->fw_dump = fw_dump; in qla2x00_alloc_fw_dump()
3442 ha->fw_dump_alloc_len = dump_size; in qla2x00_alloc_fw_dump()
3444 "Re-Allocated (%d KB) and save firmware dump.\n", in qla2x00_alloc_fw_dump()
3447 if (ha->fw_dump) in qla2x00_alloc_fw_dump()
3448 vfree(ha->fw_dump); in qla2x00_alloc_fw_dump()
3449 ha->fw_dump = fw_dump; in qla2x00_alloc_fw_dump()
3451 ha->fw_dump_len = ha->fw_dump_alloc_len = in qla2x00_alloc_fw_dump()
3458 ha->mpi_fw_dump = (char *)fw_dump + in qla2x00_alloc_fw_dump()
3459 ha->fwdt[1].dump_size; in qla2x00_alloc_fw_dump()
3460 mutex_unlock(&ha->optrom_mutex); in qla2x00_alloc_fw_dump()
3464 ha->fw_dump->signature[0] = 'Q'; in qla2x00_alloc_fw_dump()
3465 ha->fw_dump->signature[1] = 'L'; in qla2x00_alloc_fw_dump()
3466 ha->fw_dump->signature[2] = 'G'; in qla2x00_alloc_fw_dump()
3467 ha->fw_dump->signature[3] = 'C'; in qla2x00_alloc_fw_dump()
3468 ha->fw_dump->version = htonl(1); in qla2x00_alloc_fw_dump()
3470 ha->fw_dump->fixed_size = htonl(fixed_size); in qla2x00_alloc_fw_dump()
3471 ha->fw_dump->mem_size = htonl(mem_size); in qla2x00_alloc_fw_dump()
3472 ha->fw_dump->req_q_size = htonl(req_q_size); in qla2x00_alloc_fw_dump()
3473 ha->fw_dump->rsp_q_size = htonl(rsp_q_size); in qla2x00_alloc_fw_dump()
3475 ha->fw_dump->eft_size = htonl(eft_size); in qla2x00_alloc_fw_dump()
3476 ha->fw_dump->eft_addr_l = in qla2x00_alloc_fw_dump()
3477 htonl(LSD(ha->eft_dma)); in qla2x00_alloc_fw_dump()
3478 ha->fw_dump->eft_addr_h = in qla2x00_alloc_fw_dump()
3479 htonl(MSD(ha->eft_dma)); in qla2x00_alloc_fw_dump()
3481 ha->fw_dump->header_size = in qla2x00_alloc_fw_dump()
3485 mutex_unlock(&ha->optrom_mutex); in qla2x00_alloc_fw_dump()
3498 if (!IS_QLA81XX(vha->hw)) in qla81xx_mpi_sync()
3508 pci_read_config_word(vha->hw->pdev, 0x54, &dc); in qla81xx_mpi_sync()
3541 if (req->outstanding_cmds) in qla2x00_alloc_outstanding_cmds()
3545 req->num_outstanding_cmds = DEFAULT_OUTSTANDING_COMMANDS; in qla2x00_alloc_outstanding_cmds()
3547 if (ha->cur_fw_xcb_count <= ha->cur_fw_iocb_count) in qla2x00_alloc_outstanding_cmds()
3548 req->num_outstanding_cmds = ha->cur_fw_xcb_count; in qla2x00_alloc_outstanding_cmds()
3550 req->num_outstanding_cmds = ha->cur_fw_iocb_count; in qla2x00_alloc_outstanding_cmds()
3553 req->outstanding_cmds = kcalloc(req->num_outstanding_cmds, in qla2x00_alloc_outstanding_cmds()
3557 if (!req->outstanding_cmds) { in qla2x00_alloc_outstanding_cmds()
3562 req->num_outstanding_cmds = MIN_OUTSTANDING_COMMANDS; in qla2x00_alloc_outstanding_cmds()
3563 req->outstanding_cmds = kcalloc(req->num_outstanding_cmds, in qla2x00_alloc_outstanding_cmds()
3567 if (!req->outstanding_cmds) { in qla2x00_alloc_outstanding_cmds()
3571 req->num_outstanding_cmds = 0; in qla2x00_alloc_outstanding_cmds()
3580 if (a0->_field & _flag) {\
3584 leftover--;\
3588 leftover -= len;\
3596 struct sff_8247_a0 *a0 = (struct sff_8247_a0 *)vha->hw->sfp_data; in qla2xxx_print_sfp_info()
3601 snprintf(str, SFF_VEN_NAME_LEN+1, a0->vendor_name); in qla2xxx_print_sfp_info()
3606 snprintf(str, SFF_PART_NAME_LEN+1, a0->vendor_pn); in qla2xxx_print_sfp_info()
3616 PRINT_FIELD(fc_med_cc9, FC_MED_TP, "Twisted Pair"); in qla2xxx_print_sfp_info()
3650 if (a0->length_km) in qla2xxx_print_sfp_info()
3652 "SFP Distant: %d km\n", a0->length_km); in qla2xxx_print_sfp_info()
3653 if (a0->length_100m) in qla2xxx_print_sfp_info()
3655 "SFP Distant: %d m\n", a0->length_100m*100); in qla2xxx_print_sfp_info()
3656 if (a0->length_50um_10m) in qla2xxx_print_sfp_info()
3658 "SFP Distant (WL=50um): %d m\n", a0->length_50um_10m * 10); in qla2xxx_print_sfp_info()
3659 if (a0->length_62um_10m) in qla2xxx_print_sfp_info()
3661 "SFP Distant (WL=62.5um): %d m\n", a0->length_62um_10m * 10); in qla2xxx_print_sfp_info()
3662 if (a0->length_om4_10m) in qla2xxx_print_sfp_info()
3664 "SFP Distant (OM4): %d m\n", a0->length_om4_10m * 10); in qla2xxx_print_sfp_info()
3665 if (a0->length_om3_10m) in qla2xxx_print_sfp_info()
3667 "SFP Distant (OM3): %d m\n", a0->length_om3_10m * 10); in qla2xxx_print_sfp_info()
3677 * 0 -- Configure firmware to use short-range settings -- normal
3678 * buffer-to-buffer credits.
3680 * 1 -- Configure firmware to use long-range settings -- extra
3681 * buffer-to-buffer credits should be allocated with
3682 * ha->lr_distance containing distance settings from NVRAM or SFP
3690 struct qla_hw_data *ha = vha->hw; in qla24xx_detect_sfp()
3691 struct nvram_81xx *nv = ha->nvram; in qla24xx_detect_sfp()
3699 ha->flags.lr_detected = 0; in qla24xx_detect_sfp()
3701 (nv->enhanced_features & NEF_LR_DIST_ENABLE)) { in qla24xx_detect_sfp()
3703 ha->flags.lr_detected = 1; in qla24xx_detect_sfp()
3704 ha->lr_distance = in qla24xx_detect_sfp()
3705 (nv->enhanced_features >> LR_DIST_NV_POS) in qla24xx_detect_sfp()
3717 a = (struct sff_8247_a0 *)vha->hw->sfp_data; in qla24xx_detect_sfp()
3720 ha->flags.lr_detected = 0; in qla24xx_detect_sfp()
3721 ll = a->fc_ll_cc7; in qla24xx_detect_sfp()
3724 ha->flags.lr_detected = 1; in qla24xx_detect_sfp()
3726 if (a->length_km > 5 || a->length_100m > 50) in qla24xx_detect_sfp()
3727 ha->lr_distance = LR_DISTANCE_10K; in qla24xx_detect_sfp()
3729 ha->lr_distance = LR_DISTANCE_5K; in qla24xx_detect_sfp()
3734 "SFP detect: %s-Range SFP %s (nvr=%x ll=%x lr=%x lrd=%x).\n", in qla24xx_detect_sfp()
3735 types[ha->flags.lr_detected], in qla24xx_detect_sfp()
3736 ha->flags.lr_detected ? lengths[ha->lr_distance] : in qla24xx_detect_sfp()
3738 used_nvram, ll, ha->flags.lr_detected, ha->lr_distance); in qla24xx_detect_sfp()
3739 return ha->flags.lr_detected; in qla24xx_detect_sfp()
3746 struct qla_hw_data *ha = vha->hw; in qla_init_iocb_limit()
3748 num_qps = ha->num_qpairs + 1; in qla_init_iocb_limit()
3749 limit = (ha->orig_fw_iocb_count * QLA_IOCB_PCT_LIMIT) / 100; in qla_init_iocb_limit()
3751 ha->base_qpair->fwres.iocbs_total = ha->orig_fw_iocb_count; in qla_init_iocb_limit()
3752 ha->base_qpair->fwres.iocbs_limit = limit; in qla_init_iocb_limit()
3753 ha->base_qpair->fwres.iocbs_qp_limit = limit / num_qps; in qla_init_iocb_limit()
3754 ha->base_qpair->fwres.iocbs_used = 0; in qla_init_iocb_limit()
3755 for (i = 0; i < ha->max_qpairs; i++) { in qla_init_iocb_limit()
3756 if (ha->queue_pair_map[i]) { in qla_init_iocb_limit()
3757 ha->queue_pair_map[i]->fwres.iocbs_total = in qla_init_iocb_limit()
3758 ha->orig_fw_iocb_count; in qla_init_iocb_limit()
3759 ha->queue_pair_map[i]->fwres.iocbs_limit = limit; in qla_init_iocb_limit()
3760 ha->queue_pair_map[i]->fwres.iocbs_qp_limit = in qla_init_iocb_limit()
3762 ha->queue_pair_map[i]->fwres.iocbs_used = 0; in qla_init_iocb_limit()
3768 * qla2x00_setup_chip() - Load and start RISC firmware.
3778 struct qla_hw_data *ha = vha->hw; in qla2x00_setup_chip()
3779 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_setup_chip()
3785 rval = ha->isp_ops->load_risc(vha, &srisc_address); in qla2x00_setup_chip()
3795 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_setup_chip()
3796 wrt_reg_word(®->hccr, (HCCR_ENABLE_PARITY + 0x0)); in qla2x00_setup_chip()
3797 rd_reg_word(®->hccr); in qla2x00_setup_chip()
3798 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_setup_chip()
3805 rval = ha->isp_ops->load_risc(vha, &srisc_address); in qla2x00_setup_chip()
3817 ha->flags.exlogins_enabled = 1; in qla2x00_setup_chip()
3820 ha->flags.exchoffld_enabled = 1; in qla2x00_setup_chip()
3828 "Re-starting firmware -- BPM.\n"); in qla2x00_setup_chip()
3829 /* Best-effort - re-init. */ in qla2x00_setup_chip()
3830 ha->isp_ops->reset_chip(vha); in qla2x00_setup_chip()
3831 ha->isp_ops->chip_diag(vha); in qla2x00_setup_chip()
3837 ha->last_zio_threshold); in qla2x00_setup_chip()
3848 fw_major_version = ha->fw_major_version; in qla2x00_setup_chip()
3855 ha->flags.npiv_supported = 0; in qla2x00_setup_chip()
3857 (ha->fw_attributes & BIT_2)) { in qla2x00_setup_chip()
3858 ha->flags.npiv_supported = 1; in qla2x00_setup_chip()
3859 if ((!ha->max_npiv_vports) || in qla2x00_setup_chip()
3860 ((ha->max_npiv_vports + 1) % in qla2x00_setup_chip()
3862 ha->max_npiv_vports = in qla2x00_setup_chip()
3863 MIN_MULTI_ID_FABRIC - 1; in qla2x00_setup_chip()
3873 vha->req); in qla2x00_setup_chip()
3893 if (ql2xrdpenable || ha->flags.scm_supported_f) in qla2x00_setup_chip()
3900 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_setup_chip()
3903 wrt_reg_word(®->hccr, HCCR_ENABLE_PARITY + 0x1); in qla2x00_setup_chip()
3906 wrt_reg_word(®->hccr, HCCR_ENABLE_PARITY + 0x7); in qla2x00_setup_chip()
3907 rd_reg_word(®->hccr); in qla2x00_setup_chip()
3908 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_setup_chip()
3912 ha->flags.fac_supported = 1; in qla2x00_setup_chip()
3918 ha->flags.fac_supported = 1; in qla2x00_setup_chip()
3919 ha->fdt_block_size = size << 2; in qla2x00_setup_chip()
3923 ha->fw_major_version, ha->fw_minor_version, in qla2x00_setup_chip()
3924 ha->fw_subminor_version); in qla2x00_setup_chip()
3927 ha->flags.fac_supported = 0; in qla2x00_setup_chip()
3942 * qla2x00_init_response_q_entries() - Initializes response queue entries.
3956 rsp->ring_ptr = rsp->ring; in qla2x00_init_response_q_entries()
3957 rsp->ring_index = 0; in qla2x00_init_response_q_entries()
3958 rsp->status_srb = NULL; in qla2x00_init_response_q_entries()
3959 pkt = rsp->ring_ptr; in qla2x00_init_response_q_entries()
3960 for (cnt = 0; cnt < rsp->length; cnt++) { in qla2x00_init_response_q_entries()
3961 pkt->signature = RESPONSE_PROCESSED; in qla2x00_init_response_q_entries()
3967 * qla2x00_update_fw_options() - Read and process firmware options.
3976 struct qla_hw_data *ha = vha->hw; in qla2x00_update_fw_options()
3978 memset(ha->fw_options, 0, sizeof(ha->fw_options)); in qla2x00_update_fw_options()
3979 qla2x00_get_fw_options(vha, ha->fw_options); in qla2x00_update_fw_options()
3988 ha->fw_seriallink_options, sizeof(ha->fw_seriallink_options)); in qla2x00_update_fw_options()
3990 ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING; in qla2x00_update_fw_options()
3991 if (ha->fw_seriallink_options[3] & BIT_2) { in qla2x00_update_fw_options()
3992 ha->fw_options[1] |= FO1_SET_EMPHASIS_SWING; in qla2x00_update_fw_options()
3995 swing = ha->fw_seriallink_options[2] & (BIT_2 | BIT_1 | BIT_0); in qla2x00_update_fw_options()
3996 emphasis = (ha->fw_seriallink_options[2] & in qla2x00_update_fw_options()
3998 tx_sens = ha->fw_seriallink_options[0] & in qla2x00_update_fw_options()
4000 rx_sens = (ha->fw_seriallink_options[0] & in qla2x00_update_fw_options()
4002 ha->fw_options[10] = (emphasis << 14) | (swing << 8); in qla2x00_update_fw_options()
4006 ha->fw_options[10] |= (tx_sens << 4) | rx_sens; in qla2x00_update_fw_options()
4008 ha->fw_options[10] |= BIT_5 | in qla2x00_update_fw_options()
4013 swing = (ha->fw_seriallink_options[2] & in qla2x00_update_fw_options()
4015 emphasis = ha->fw_seriallink_options[3] & (BIT_1 | BIT_0); in qla2x00_update_fw_options()
4016 tx_sens = ha->fw_seriallink_options[1] & in qla2x00_update_fw_options()
4018 rx_sens = (ha->fw_seriallink_options[1] & in qla2x00_update_fw_options()
4020 ha->fw_options[11] = (emphasis << 14) | (swing << 8); in qla2x00_update_fw_options()
4024 ha->fw_options[11] |= (tx_sens << 4) | rx_sens; in qla2x00_update_fw_options()
4026 ha->fw_options[11] |= BIT_5 | in qla2x00_update_fw_options()
4033 ha->fw_options[3] |= BIT_13; in qla2x00_update_fw_options()
4036 if (ha->flags.enable_led_scheme) in qla2x00_update_fw_options()
4037 ha->fw_options[2] |= BIT_12; in qla2x00_update_fw_options()
4041 ha->fw_options[2] |= BIT_13; in qla2x00_update_fw_options()
4044 if (ha->operating_mode == P2P) { in qla2x00_update_fw_options()
4045 ha->fw_options[2] |= BIT_3; in qla2x00_update_fw_options()
4048 __func__, ha->fw_options[2]); in qla2x00_update_fw_options()
4052 qla2x00_set_fw_options(vha, ha->fw_options); in qla2x00_update_fw_options()
4059 struct qla_hw_data *ha = vha->hw; in qla24xx_update_fw_options()
4066 ha->fw_options[3] |= BIT_12; in qla24xx_update_fw_options()
4069 if (ha->operating_mode == P2P) { in qla24xx_update_fw_options()
4070 ha->fw_options[2] |= BIT_3; in qla24xx_update_fw_options()
4073 __func__, ha->fw_options[2]); in qla24xx_update_fw_options()
4081 ha->fw_options[2] |= BIT_11; in qla24xx_update_fw_options()
4083 ha->fw_options[2] &= ~BIT_11; in qla24xx_update_fw_options()
4094 ha->fw_options[2] |= BIT_4; in qla24xx_update_fw_options()
4096 ha->fw_options[2] &= ~BIT_4; in qla24xx_update_fw_options()
4100 ha->fw_options[2] |= BIT_8; in qla24xx_update_fw_options()
4102 ha->fw_options[2] &= ~BIT_8; in qla24xx_update_fw_options()
4105 if (ql2xrdpenable || ha->flags.scm_supported_f) in qla24xx_update_fw_options()
4106 ha->fw_options[1] |= ADD_FO1_ENABLE_PUREX_IOCB; in qla24xx_update_fw_options()
4108 /* Enable Async 8130/8131 events -- transceiver insertion/removal */ in qla24xx_update_fw_options()
4110 ha->fw_options[3] |= BIT_10; in qla24xx_update_fw_options()
4113 "%s, add FW options 1-3 = 0x%04x 0x%04x 0x%04x mode %x\n", in qla24xx_update_fw_options()
4114 __func__, ha->fw_options[1], ha->fw_options[2], in qla24xx_update_fw_options()
4115 ha->fw_options[3], vha->host->active_mode); in qla24xx_update_fw_options()
4117 if (ha->fw_options[1] || ha->fw_options[2] || ha->fw_options[3]) in qla24xx_update_fw_options()
4118 qla2x00_set_fw_options(vha, ha->fw_options); in qla24xx_update_fw_options()
4121 if ((le16_to_cpu(ha->fw_seriallink_options24[0]) & BIT_0) == 0) in qla24xx_update_fw_options()
4125 le16_to_cpu(ha->fw_seriallink_options24[1]), in qla24xx_update_fw_options()
4126 le16_to_cpu(ha->fw_seriallink_options24[2]), in qla24xx_update_fw_options()
4127 le16_to_cpu(ha->fw_seriallink_options24[3])); in qla24xx_update_fw_options()
4137 struct qla_hw_data *ha = vha->hw; in qla2x00_config_rings()
4138 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_config_rings()
4139 struct req_que *req = ha->req_q_map[0]; in qla2x00_config_rings()
4140 struct rsp_que *rsp = ha->rsp_q_map[0]; in qla2x00_config_rings()
4143 ha->init_cb->request_q_outpointer = cpu_to_le16(0); in qla2x00_config_rings()
4144 ha->init_cb->response_q_inpointer = cpu_to_le16(0); in qla2x00_config_rings()
4145 ha->init_cb->request_q_length = cpu_to_le16(req->length); in qla2x00_config_rings()
4146 ha->init_cb->response_q_length = cpu_to_le16(rsp->length); in qla2x00_config_rings()
4147 put_unaligned_le64(req->dma, &ha->init_cb->request_q_address); in qla2x00_config_rings()
4148 put_unaligned_le64(rsp->dma, &ha->init_cb->response_q_address); in qla2x00_config_rings()
4160 struct qla_hw_data *ha = vha->hw; in qla24xx_config_rings()
4162 struct device_reg_2xxx __iomem *ioreg = &ha->iobase->isp; in qla24xx_config_rings()
4166 struct req_que *req = ha->req_q_map[0]; in qla24xx_config_rings()
4167 struct rsp_que *rsp = ha->rsp_q_map[0]; in qla24xx_config_rings()
4170 icb = (struct init_cb_24xx *)ha->init_cb; in qla24xx_config_rings()
4171 icb->request_q_outpointer = cpu_to_le16(0); in qla24xx_config_rings()
4172 icb->response_q_inpointer = cpu_to_le16(0); in qla24xx_config_rings()
4173 icb->request_q_length = cpu_to_le16(req->length); in qla24xx_config_rings()
4174 icb->response_q_length = cpu_to_le16(rsp->length); in qla24xx_config_rings()
4175 put_unaligned_le64(req->dma, &icb->request_q_address); in qla24xx_config_rings()
4176 put_unaligned_le64(rsp->dma, &icb->response_q_address); in qla24xx_config_rings()
4179 icb->atio_q_inpointer = cpu_to_le16(0); in qla24xx_config_rings()
4180 icb->atio_q_length = cpu_to_le16(ha->tgt.atio_q_length); in qla24xx_config_rings()
4181 put_unaligned_le64(ha->tgt.atio_dma, &icb->atio_q_address); in qla24xx_config_rings()
4184 icb->firmware_options_2 |= cpu_to_le32(BIT_30|BIT_29); in qla24xx_config_rings()
4186 if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha) || in qla24xx_config_rings()
4188 icb->qos = cpu_to_le16(QLA_DEFAULT_QUE_QOS); in qla24xx_config_rings()
4189 icb->rid = cpu_to_le16(rid); in qla24xx_config_rings()
4190 if (ha->flags.msix_enabled) { in qla24xx_config_rings()
4191 msix = &ha->msix_entries[1]; in qla24xx_config_rings()
4194 msix->entry); in qla24xx_config_rings()
4195 icb->msix = cpu_to_le16(msix->entry); in qla24xx_config_rings()
4199 icb->firmware_options_2 |= cpu_to_le32(BIT_19); in qla24xx_config_rings()
4202 icb->firmware_options_2 |= cpu_to_le32(BIT_18); in qla24xx_config_rings()
4205 if ((ha->fw_attributes & BIT_6) && (IS_MSIX_NACK_CAPABLE(ha)) && in qla24xx_config_rings()
4206 (ha->flags.msix_enabled)) { in qla24xx_config_rings()
4207 icb->firmware_options_2 &= cpu_to_le32(~BIT_22); in qla24xx_config_rings()
4208 ha->flags.disable_msix_handshake = 1; in qla24xx_config_rings()
4212 icb->firmware_options_2 |= cpu_to_le32(BIT_22); in qla24xx_config_rings()
4214 icb->firmware_options_2 |= cpu_to_le32(BIT_23); in qla24xx_config_rings()
4216 wrt_reg_dword(®->isp25mq.req_q_in, 0); in qla24xx_config_rings()
4217 wrt_reg_dword(®->isp25mq.req_q_out, 0); in qla24xx_config_rings()
4218 wrt_reg_dword(®->isp25mq.rsp_q_in, 0); in qla24xx_config_rings()
4219 wrt_reg_dword(®->isp25mq.rsp_q_out, 0); in qla24xx_config_rings()
4221 wrt_reg_dword(®->isp24.req_q_in, 0); in qla24xx_config_rings()
4222 wrt_reg_dword(®->isp24.req_q_out, 0); in qla24xx_config_rings()
4223 wrt_reg_dword(®->isp24.rsp_q_in, 0); in qla24xx_config_rings()
4224 wrt_reg_dword(®->isp24.rsp_q_out, 0); in qla24xx_config_rings()
4230 if (ha->set_data_rate) { in qla24xx_config_rings()
4233 qla2x00_get_link_speed_str(ha, ha->set_data_rate)); in qla24xx_config_rings()
4234 icb->firmware_options_3 = cpu_to_le32(ha->set_data_rate << 13); in qla24xx_config_rings()
4238 rd_reg_word(&ioreg->hccr); in qla24xx_config_rings()
4242 * qla2x00_init_rings() - Initializes firmware.
4256 struct qla_hw_data *ha = vha->hw; in qla2x00_init_rings()
4260 (struct mid_init_cb_24xx *) ha->init_cb; in qla2x00_init_rings()
4262 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_init_rings()
4265 for (que = 0; que < ha->max_req_queues; que++) { in qla2x00_init_rings()
4266 req = ha->req_q_map[que]; in qla2x00_init_rings()
4267 if (!req || !test_bit(que, ha->req_qid_map)) in qla2x00_init_rings()
4269 req->out_ptr = (uint16_t *)(req->ring + req->length); in qla2x00_init_rings()
4270 *req->out_ptr = 0; in qla2x00_init_rings()
4271 for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) in qla2x00_init_rings()
4272 req->outstanding_cmds[cnt] = NULL; in qla2x00_init_rings()
4274 req->current_outstanding_cmd = 1; in qla2x00_init_rings()
4277 req->ring_ptr = req->ring; in qla2x00_init_rings()
4278 req->ring_index = 0; in qla2x00_init_rings()
4279 req->cnt = req->length; in qla2x00_init_rings()
4282 for (que = 0; que < ha->max_rsp_queues; que++) { in qla2x00_init_rings()
4283 rsp = ha->rsp_q_map[que]; in qla2x00_init_rings()
4284 if (!rsp || !test_bit(que, ha->rsp_qid_map)) in qla2x00_init_rings()
4286 rsp->in_ptr = (uint16_t *)(rsp->ring + rsp->length); in qla2x00_init_rings()
4287 *rsp->in_ptr = 0; in qla2x00_init_rings()
4295 ha->tgt.atio_ring_ptr = ha->tgt.atio_ring; in qla2x00_init_rings()
4296 ha->tgt.atio_ring_index = 0; in qla2x00_init_rings()
4300 ha->isp_ops->config_rings(vha); in qla2x00_init_rings()
4302 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_init_rings()
4307 rval = qlafx00_init_firmware(vha, ha->init_cb_size); in qla2x00_init_rings()
4312 ha->isp_ops->update_fw_options(vha); in qla2x00_init_rings()
4314 if (ha->flags.npiv_supported) { in qla2x00_init_rings()
4315 if (ha->operating_mode == LOOP && !IS_CNA_CAPABLE(ha)) in qla2x00_init_rings()
4316 ha->max_npiv_vports = MIN_MULTI_ID_FABRIC - 1; in qla2x00_init_rings()
4317 mid_init_cb->count = cpu_to_le16(ha->max_npiv_vports); in qla2x00_init_rings()
4321 mid_init_cb->options = cpu_to_le16(BIT_1); in qla2x00_init_rings()
4322 mid_init_cb->init_cb.execution_throttle = in qla2x00_init_rings()
4323 cpu_to_le16(ha->cur_fw_xcb_count); in qla2x00_init_rings()
4324 ha->flags.dport_enabled = in qla2x00_init_rings()
4325 (le32_to_cpu(mid_init_cb->init_cb.firmware_options_1) & in qla2x00_init_rings()
4328 (ha->flags.dport_enabled) ? "enabled" : "disabled"); in qla2x00_init_rings()
4329 /* FA-WWPN Status */ in qla2x00_init_rings()
4330 ha->flags.fawwpn_enabled = in qla2x00_init_rings()
4331 (le32_to_cpu(mid_init_cb->init_cb.firmware_options_1) & in qla2x00_init_rings()
4333 ql_dbg(ql_dbg_init, vha, 0x00bc, "FA-WWPN Support: %s.\n", in qla2x00_init_rings()
4334 (ha->flags.fawwpn_enabled) ? "enabled" : "disabled"); in qla2x00_init_rings()
4336 memcpy(ha->port_name, ha->init_cb->port_name, WWN_SIZE); in qla2x00_init_rings()
4339 rval = qla2x00_init_firmware(vha, ha->init_cb_size); in qla2x00_init_rings()
4346 "Init Firmware -- success.\n"); in qla2x00_init_rings()
4348 vha->u_ql2xexchoffld = vha->u_ql2xiniexchg = 0; in qla2x00_init_rings()
4355 * qla2x00_fw_ready() - Waits for firmware ready.
4368 struct qla_hw_data *ha = vha->hw; in qla2x00_fw_ready()
4370 if (IS_QLAFX00(vha->hw)) in qla2x00_fw_ready()
4385 if ((wait_time = (ha->retry_count*ha->login_timeout) + 5) < min_wait) { in qla2x00_fw_ready()
4396 if (!vha->flags.init_done) in qla2x00_fw_ready()
4401 memset(state, -1, sizeof(state)); in qla2x00_fw_ready()
4405 vha->device_flags &= ~DFLG_NO_CABLE; in qla2x00_fw_ready()
4426 cs84xx_time = jiffies - cs84xx_time; in qla2x00_fw_ready()
4436 "F/W Ready - OK.\n"); in qla2x00_fw_ready()
4438 qla2x00_get_retry_cnt(vha, &ha->retry_count, in qla2x00_fw_ready()
4439 &ha->login_timeout, &ha->r_a_tov); in qla2x00_fw_ready()
4447 if (atomic_read(&vha->loop_down_timer) && in qla2x00_fw_ready()
4456 vha->device_flags |= DFLG_NO_CABLE; in qla2x00_fw_ready()
4463 ha->flags.isp82xx_fw_hung) in qla2x00_fw_ready()
4478 if (rval && !(vha->device_flags & DFLG_NO_CABLE)) { in qla2x00_fw_ready()
4510 struct qla_hw_data *ha = vha->hw; in qla2x00_configure_hba()
4511 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); in qla2x00_configure_hba()
4519 if (LOOP_TRANSITION(vha) || atomic_read(&ha->loop_down_timer) || in qla2x00_configure_hba()
4534 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_configure_hba()
4541 "Cannot get topology - retrying.\n"); in qla2x00_configure_hba()
4545 vha->loop_id = loop_id; in qla2x00_configure_hba()
4548 ha->min_external_loopid = SNS_FIRST_LOOP_ID; in qla2x00_configure_hba()
4549 ha->operating_mode = LOOP; in qla2x00_configure_hba()
4550 ha->switch_cap = 0; in qla2x00_configure_hba()
4555 ha->current_topology = ISP_CFG_NL; in qla2x00_configure_hba()
4561 ha->switch_cap = sw_cap; in qla2x00_configure_hba()
4562 ha->current_topology = ISP_CFG_FL; in qla2x00_configure_hba()
4568 ha->operating_mode = P2P; in qla2x00_configure_hba()
4569 ha->current_topology = ISP_CFG_N; in qla2x00_configure_hba()
4570 strcpy(connect_type, "(N_Port-to-N_Port)"); in qla2x00_configure_hba()
4575 ha->switch_cap = sw_cap; in qla2x00_configure_hba()
4576 ha->operating_mode = P2P; in qla2x00_configure_hba()
4577 ha->current_topology = ISP_CFG_F; in qla2x00_configure_hba()
4584 ha->current_topology = ISP_CFG_NL; in qla2x00_configure_hba()
4590 /* byte order - Big Endian */ in qla2x00_configure_hba()
4595 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_configure_hba()
4596 if (!(topo == 2 && ha->flags.n2n_bigger)) in qla2x00_configure_hba()
4598 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_configure_hba()
4600 if (!vha->flags.init_done) in qla2x00_configure_hba()
4602 "Topology - %s, Host Loop address 0x%x.\n", in qla2x00_configure_hba()
4603 connect_type, vha->loop_id); in qla2x00_configure_hba()
4615 struct qla_hw_data *ha = vha->hw; in qla2x00_set_model_info()
4622 memcpy(ha->model_number, model, len); in qla2x00_set_model_info()
4623 st = en = ha->model_number; in qla2x00_set_model_info()
4624 en += len - 1; in qla2x00_set_model_info()
4628 *en-- = '\0'; in qla2x00_set_model_info()
4631 index = (ha->pdev->subsystem_device & 0xff); in qla2x00_set_model_info()
4633 ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && in qla2x00_set_model_info()
4635 strlcpy(ha->model_desc, in qla2x00_set_model_info()
4637 sizeof(ha->model_desc)); in qla2x00_set_model_info()
4639 index = (ha->pdev->subsystem_device & 0xff); in qla2x00_set_model_info()
4641 ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && in qla2x00_set_model_info()
4643 strlcpy(ha->model_number, in qla2x00_set_model_info()
4645 sizeof(ha->model_number)); in qla2x00_set_model_info()
4646 strlcpy(ha->model_desc, in qla2x00_set_model_info()
4648 sizeof(ha->model_desc)); in qla2x00_set_model_info()
4650 strlcpy(ha->model_number, def, in qla2x00_set_model_info()
4651 sizeof(ha->model_number)); in qla2x00_set_model_info()
4655 qla2xxx_get_vpd_field(vha, "\x82", ha->model_desc, in qla2x00_set_model_info()
4656 sizeof(ha->model_desc)); in qla2x00_set_model_info()
4665 struct qla_hw_data *ha = vha->hw; in qla2xxx_nvram_wwn_from_ofw()
4666 struct pci_dev *pdev = ha->pdev; in qla2xxx_nvram_wwn_from_ofw()
4671 val = of_get_property(dp, "port-wwn", &len); in qla2xxx_nvram_wwn_from_ofw()
4673 memcpy(nv->port_name, val, WWN_SIZE); in qla2xxx_nvram_wwn_from_ofw()
4675 val = of_get_property(dp, "node-wwn", &len); in qla2xxx_nvram_wwn_from_ofw()
4677 memcpy(nv->node_name, val, WWN_SIZE); in qla2xxx_nvram_wwn_from_ofw()
4701 struct qla_hw_data *ha = vha->hw; in qla2x00_nvram_config()
4702 init_cb_t *icb = ha->init_cb; in qla2x00_nvram_config()
4703 nvram_t *nv = ha->nvram; in qla2x00_nvram_config()
4704 uint8_t *ptr = ha->nvram; in qla2x00_nvram_config()
4705 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_nvram_config()
4710 ha->nvram_size = sizeof(*nv); in qla2x00_nvram_config()
4711 ha->nvram_base = 0; in qla2x00_nvram_config()
4713 if ((rd_reg_word(®->ctrl_status) >> 14) == 1) in qla2x00_nvram_config()
4714 ha->nvram_base = 0x80; in qla2x00_nvram_config()
4717 ha->isp_ops->read_nvram(vha, ptr, ha->nvram_base, ha->nvram_size); in qla2x00_nvram_config()
4718 for (cnt = 0, chksum = 0; cnt < ha->nvram_size; cnt++) in qla2x00_nvram_config()
4724 nv, ha->nvram_size); in qla2x00_nvram_config()
4727 if (chksum || memcmp("ISP ", nv->id, sizeof(nv->id)) || in qla2x00_nvram_config()
4728 nv->nvram_version < 1) { in qla2x00_nvram_config()
4732 chksum, nv->id, nv->nvram_version); in qla2x00_nvram_config()
4735 "functioning (yet invalid -- WWPN) defaults.\n"); in qla2x00_nvram_config()
4740 memset(nv, 0, ha->nvram_size); in qla2x00_nvram_config()
4741 nv->parameter_block_version = ICB_VERSION; in qla2x00_nvram_config()
4744 nv->firmware_options[0] = BIT_2 | BIT_1; in qla2x00_nvram_config()
4745 nv->firmware_options[1] = BIT_7 | BIT_5; in qla2x00_nvram_config()
4746 nv->add_firmware_options[0] = BIT_5; in qla2x00_nvram_config()
4747 nv->add_firmware_options[1] = BIT_5 | BIT_4; in qla2x00_nvram_config()
4748 nv->frame_payload_size = cpu_to_le16(2048); in qla2x00_nvram_config()
4749 nv->special_options[1] = BIT_7; in qla2x00_nvram_config()
4751 nv->firmware_options[0] = BIT_2 | BIT_1; in qla2x00_nvram_config()
4752 nv->firmware_options[1] = BIT_7 | BIT_5; in qla2x00_nvram_config()
4753 nv->add_firmware_options[0] = BIT_5; in qla2x00_nvram_config()
4754 nv->add_firmware_options[1] = BIT_5 | BIT_4; in qla2x00_nvram_config()
4755 nv->frame_payload_size = cpu_to_le16(1024); in qla2x00_nvram_config()
4757 nv->firmware_options[0] = BIT_3 | BIT_1; in qla2x00_nvram_config()
4758 nv->firmware_options[1] = BIT_5; in qla2x00_nvram_config()
4759 nv->frame_payload_size = cpu_to_le16(1024); in qla2x00_nvram_config()
4762 nv->max_iocb_allocation = cpu_to_le16(256); in qla2x00_nvram_config()
4763 nv->execution_throttle = cpu_to_le16(16); in qla2x00_nvram_config()
4764 nv->retry_count = 8; in qla2x00_nvram_config()
4765 nv->retry_delay = 1; in qla2x00_nvram_config()
4767 nv->port_name[0] = 33; in qla2x00_nvram_config()
4768 nv->port_name[3] = 224; in qla2x00_nvram_config()
4769 nv->port_name[4] = 139; in qla2x00_nvram_config()
4773 nv->login_timeout = 4; in qla2x00_nvram_config()
4778 nv->host_p[1] = BIT_2; in qla2x00_nvram_config()
4779 nv->reset_delay = 5; in qla2x00_nvram_config()
4780 nv->port_down_retry_count = 8; in qla2x00_nvram_config()
4781 nv->max_luns_per_target = cpu_to_le16(8); in qla2x00_nvram_config()
4782 nv->link_down_timeout = 60; in qla2x00_nvram_config()
4788 memset(icb, 0, ha->init_cb_size); in qla2x00_nvram_config()
4793 nv->firmware_options[0] |= (BIT_6 | BIT_1); in qla2x00_nvram_config()
4794 nv->firmware_options[0] &= ~(BIT_5 | BIT_4); in qla2x00_nvram_config()
4795 nv->firmware_options[1] |= (BIT_5 | BIT_0); in qla2x00_nvram_config()
4796 nv->firmware_options[1] &= ~BIT_4; in qla2x00_nvram_config()
4799 nv->firmware_options[0] |= BIT_2; in qla2x00_nvram_config()
4800 nv->firmware_options[0] &= ~BIT_3; in qla2x00_nvram_config()
4801 nv->special_options[0] &= ~BIT_6; in qla2x00_nvram_config()
4802 nv->add_firmware_options[1] |= BIT_5 | BIT_4; in qla2x00_nvram_config()
4805 if (ha->fb_rev == FPM_2310) { in qla2x00_nvram_config()
4806 strcpy(ha->model_number, "QLA2310"); in qla2x00_nvram_config()
4808 strcpy(ha->model_number, "QLA2300"); in qla2x00_nvram_config()
4811 qla2x00_set_model_info(vha, nv->model_number, in qla2x00_nvram_config()
4812 sizeof(nv->model_number), "QLA23xx"); in qla2x00_nvram_config()
4815 nv->firmware_options[0] |= BIT_2; in qla2x00_nvram_config()
4817 * 'Point-to-point preferred, else loop' is not a safe in qla2x00_nvram_config()
4820 if ((nv->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) == in qla2x00_nvram_config()
4822 /* Force 'loop preferred, else point-to-point'. */ in qla2x00_nvram_config()
4823 nv->add_firmware_options[0] &= ~(BIT_6 | BIT_5 | BIT_4); in qla2x00_nvram_config()
4824 nv->add_firmware_options[0] |= BIT_5; in qla2x00_nvram_config()
4826 strcpy(ha->model_number, "QLA22xx"); in qla2x00_nvram_config()
4828 strcpy(ha->model_number, "QLA2100"); in qla2x00_nvram_config()
4835 dptr2 = (uint8_t *)&nv->parameter_block_version; in qla2x00_nvram_config()
4836 cnt = (uint8_t *)&icb->request_q_outpointer - (uint8_t *)&icb->version; in qla2x00_nvram_config()
4837 while (cnt--) in qla2x00_nvram_config()
4841 dptr1 = (uint8_t *)icb->add_firmware_options; in qla2x00_nvram_config()
4842 cnt = (uint8_t *)icb->reserved_3 - (uint8_t *)icb->add_firmware_options; in qla2x00_nvram_config()
4843 while (cnt--) in qla2x00_nvram_config()
4845 ha->frame_payload_size = le16_to_cpu(icb->frame_payload_size); in qla2x00_nvram_config()
4847 if (nv->host_p[1] & BIT_7) { in qla2x00_nvram_config()
4848 memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); in qla2x00_nvram_config()
4849 memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); in qla2x00_nvram_config()
4853 if ((icb->firmware_options[1] & BIT_6) == 0) { in qla2x00_nvram_config()
4858 memcpy(icb->node_name, icb->port_name, WWN_SIZE); in qla2x00_nvram_config()
4859 icb->node_name[0] &= 0xF0; in qla2x00_nvram_config()
4867 * BIT_7 in the host-parameters section allows for modification to in qla2x00_nvram_config()
4870 if (nv->host_p[0] & BIT_7) in qla2x00_nvram_config()
4872 ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0); in qla2x00_nvram_config()
4875 ha->flags.disable_risc_code_load = 0; in qla2x00_nvram_config()
4876 ha->flags.enable_lip_reset = ((nv->host_p[1] & BIT_1) ? 1 : 0); in qla2x00_nvram_config()
4877 ha->flags.enable_lip_full_login = ((nv->host_p[1] & BIT_2) ? 1 : 0); in qla2x00_nvram_config()
4878 ha->flags.enable_target_reset = ((nv->host_p[1] & BIT_3) ? 1 : 0); in qla2x00_nvram_config()
4879 ha->flags.enable_led_scheme = (nv->special_options[1] & BIT_4) ? 1 : 0; in qla2x00_nvram_config()
4880 ha->flags.disable_serdes = 0; in qla2x00_nvram_config()
4882 ha->operating_mode = in qla2x00_nvram_config()
4883 (icb->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) >> 4; in qla2x00_nvram_config()
4885 memcpy(ha->fw_seriallink_options, nv->seriallink_options, in qla2x00_nvram_config()
4886 sizeof(ha->fw_seriallink_options)); in qla2x00_nvram_config()
4889 ha->serial0 = icb->port_name[5]; in qla2x00_nvram_config()
4890 ha->serial1 = icb->port_name[6]; in qla2x00_nvram_config()
4891 ha->serial2 = icb->port_name[7]; in qla2x00_nvram_config()
4892 memcpy(vha->node_name, icb->node_name, WWN_SIZE); in qla2x00_nvram_config()
4893 memcpy(vha->port_name, icb->port_name, WWN_SIZE); in qla2x00_nvram_config()
4895 icb->execution_throttle = cpu_to_le16(0xFFFF); in qla2x00_nvram_config()
4897 ha->retry_count = nv->retry_count; in qla2x00_nvram_config()
4900 if (nv->login_timeout != ql2xlogintimeout) in qla2x00_nvram_config()
4901 nv->login_timeout = ql2xlogintimeout; in qla2x00_nvram_config()
4902 if (nv->login_timeout < 4) in qla2x00_nvram_config()
4903 nv->login_timeout = 4; in qla2x00_nvram_config()
4904 ha->login_timeout = nv->login_timeout; in qla2x00_nvram_config()
4907 ha->r_a_tov = 100; in qla2x00_nvram_config()
4909 ha->loop_reset_delay = nv->reset_delay; in qla2x00_nvram_config()
4921 if (nv->link_down_timeout == 0) { in qla2x00_nvram_config()
4922 ha->loop_down_abort_time = in qla2x00_nvram_config()
4923 (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); in qla2x00_nvram_config()
4925 ha->link_down_timeout = nv->link_down_timeout; in qla2x00_nvram_config()
4926 ha->loop_down_abort_time = in qla2x00_nvram_config()
4927 (LOOP_DOWN_TIME - ha->link_down_timeout); in qla2x00_nvram_config()
4933 ha->port_down_retry_count = nv->port_down_retry_count; in qla2x00_nvram_config()
4935 ha->port_down_retry_count = qlport_down_retry; in qla2x00_nvram_config()
4937 ha->login_retry_count = nv->retry_count; in qla2x00_nvram_config()
4938 if (ha->port_down_retry_count == nv->port_down_retry_count && in qla2x00_nvram_config()
4939 ha->port_down_retry_count > 3) in qla2x00_nvram_config()
4940 ha->login_retry_count = ha->port_down_retry_count; in qla2x00_nvram_config()
4941 else if (ha->port_down_retry_count > (int)ha->login_retry_count) in qla2x00_nvram_config()
4942 ha->login_retry_count = ha->port_down_retry_count; in qla2x00_nvram_config()
4944 ha->login_retry_count = ql2xloginretrycount; in qla2x00_nvram_config()
4946 icb->lun_enables = cpu_to_le16(0); in qla2x00_nvram_config()
4947 icb->command_resource_count = 0; in qla2x00_nvram_config()
4948 icb->immediate_notify_resource_count = 0; in qla2x00_nvram_config()
4949 icb->timeout = cpu_to_le16(0); in qla2x00_nvram_config()
4953 icb->firmware_options[0] &= ~BIT_3; in qla2x00_nvram_config()
4954 icb->add_firmware_options[0] &= in qla2x00_nvram_config()
4956 icb->add_firmware_options[0] |= BIT_2; in qla2x00_nvram_config()
4957 icb->response_accumulation_timer = 3; in qla2x00_nvram_config()
4958 icb->interrupt_delay_timer = 5; in qla2x00_nvram_config()
4960 vha->flags.process_response_queue = 1; in qla2x00_nvram_config()
4963 if (!vha->flags.init_done) { in qla2x00_nvram_config()
4964 ha->zio_mode = icb->add_firmware_options[0] & in qla2x00_nvram_config()
4966 ha->zio_timer = icb->interrupt_delay_timer ? in qla2x00_nvram_config()
4967 icb->interrupt_delay_timer : 2; in qla2x00_nvram_config()
4969 icb->add_firmware_options[0] &= in qla2x00_nvram_config()
4971 vha->flags.process_response_queue = 0; in qla2x00_nvram_config()
4972 if (ha->zio_mode != QLA_ZIO_DISABLED) { in qla2x00_nvram_config()
4973 ha->zio_mode = QLA_ZIO_MODE_6; in qla2x00_nvram_config()
4977 ha->zio_mode, ha->zio_timer * 100); in qla2x00_nvram_config()
4979 icb->add_firmware_options[0] |= (uint8_t)ha->zio_mode; in qla2x00_nvram_config()
4980 icb->interrupt_delay_timer = (uint8_t)ha->zio_timer; in qla2x00_nvram_config()
4981 vha->flags.process_response_queue = 1; in qla2x00_nvram_config()
4999 spin_lock_irqsave(fcport->vha->host->host_lock, flags); in qla2x00_rport_del()
5000 rport = fcport->drport ? fcport->drport : fcport->rport; in qla2x00_rport_del()
5001 fcport->drport = NULL; in qla2x00_rport_del()
5002 spin_unlock_irqrestore(fcport->vha->host->host_lock, flags); in qla2x00_rport_del()
5004 ql_dbg(ql_dbg_disc, fcport->vha, 0x210b, in qla2x00_rport_del()
5006 __func__, fcport->port_name, rport, in qla2x00_rport_del()
5007 rport->roles); in qla2x00_rport_del()
5017 old_state = atomic_read(&fcport->state); in qla2x00_set_fcport_state()
5018 atomic_set(&fcport->state, state); in qla2x00_set_fcport_state()
5022 ql_dbg(ql_dbg_disc, fcport->vha, 0x207d, in qla2x00_set_fcport_state()
5023 "FCPort %8phC state transitioned from %s to %s - portid=%02x%02x%02x.\n", in qla2x00_set_fcport_state()
5024 fcport->port_name, port_state_str[old_state], in qla2x00_set_fcport_state()
5025 port_state_str[state], fcport->d_id.b.domain, in qla2x00_set_fcport_state()
5026 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_set_fcport_state()
5031 * qla2x00_alloc_fcport() - Allocate a generic fcport.
5046 fcport->ct_desc.ct_sns = dma_alloc_coherent(&vha->hw->pdev->dev, in qla2x00_alloc_fcport()
5047 sizeof(struct ct_sns_pkt), &fcport->ct_desc.ct_sns_dma, in qla2x00_alloc_fcport()
5049 if (!fcport->ct_desc.ct_sns) { in qla2x00_alloc_fcport()
5057 fcport->vha = vha; in qla2x00_alloc_fcport()
5058 fcport->port_type = FCT_UNKNOWN; in qla2x00_alloc_fcport()
5059 fcport->loop_id = FC_NO_LOOP_ID; in qla2x00_alloc_fcport()
5061 fcport->supported_classes = FC_COS_UNSPECIFIED; in qla2x00_alloc_fcport()
5062 fcport->fp_speed = PORT_SPEED_UNKNOWN; in qla2x00_alloc_fcport()
5064 fcport->disc_state = DSC_DELETED; in qla2x00_alloc_fcport()
5065 fcport->fw_login_state = DSC_LS_PORT_UNAVAIL; in qla2x00_alloc_fcport()
5066 fcport->deleted = QLA_SESS_DELETED; in qla2x00_alloc_fcport()
5067 fcport->login_retry = vha->hw->login_retry_count; in qla2x00_alloc_fcport()
5068 fcport->chip_reset = vha->hw->base_qpair->chip_reset; in qla2x00_alloc_fcport()
5069 fcport->logout_on_delete = 1; in qla2x00_alloc_fcport()
5071 if (!fcport->ct_desc.ct_sns) { in qla2x00_alloc_fcport()
5078 INIT_WORK(&fcport->del_work, qla24xx_delete_sess_fn); in qla2x00_alloc_fcport()
5079 INIT_WORK(&fcport->free_work, qlt_free_session_done); in qla2x00_alloc_fcport()
5080 INIT_WORK(&fcport->reg_work, qla_register_fcport_fn); in qla2x00_alloc_fcport()
5081 INIT_LIST_HEAD(&fcport->gnl_entry); in qla2x00_alloc_fcport()
5082 INIT_LIST_HEAD(&fcport->list); in qla2x00_alloc_fcport()
5090 if (fcport->ct_desc.ct_sns) { in qla2x00_free_fcport()
5091 dma_free_coherent(&fcport->vha->hw->pdev->dev, in qla2x00_free_fcport()
5092 sizeof(struct ct_sns_pkt), fcport->ct_desc.ct_sns, in qla2x00_free_fcport()
5093 fcport->ct_desc.ct_sns_dma); in qla2x00_free_fcport()
5095 fcport->ct_desc.ct_sns = NULL; in qla2x00_free_fcport()
5097 list_del(&fcport->list); in qla2x00_free_fcport()
5104 struct qla_hw_data *ha = vha->hw; in qla_get_login_template()
5109 memset(ha->init_cb, 0, ha->init_cb_size); in qla_get_login_template()
5110 sz = min_t(int, sizeof(struct fc_els_flogi), ha->init_cb_size); in qla_get_login_template()
5111 rval = qla24xx_get_port_login_templ(vha, ha->init_cb_dma, in qla_get_login_template()
5112 ha->init_cb, sz); in qla_get_login_template()
5118 q = (__be32 *)&ha->plogi_els_payld.fl_csp; in qla_get_login_template()
5120 bp = (uint32_t *)ha->init_cb; in qla_get_login_template()
5122 ha->flags.plogi_template_valid = 1; in qla_get_login_template()
5142 struct qla_hw_data *ha = vha->hw; in qla2x00_configure_loop()
5147 if (test_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags)) { in qla2x00_configure_loop()
5156 save_flags = flags = vha->dpc_flags; in qla2x00_configure_loop()
5158 "Configure loop -- dpc flags = 0x%lx.\n", flags); in qla2x00_configure_loop()
5164 clear_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_configure_loop()
5165 clear_bit(RSCN_UPDATE, &vha->dpc_flags); in qla2x00_configure_loop()
5171 if ((ha->current_topology == ISP_CFG_FL || in qla2x00_configure_loop()
5172 ha->current_topology == ISP_CFG_F) && in qla2x00_configure_loop()
5178 } else if (ha->current_topology == ISP_CFG_NL || in qla2x00_configure_loop()
5179 ha->current_topology == ISP_CFG_N) { in qla2x00_configure_loop()
5182 } else if (!vha->flags.online || in qla2x00_configure_loop()
5189 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { in qla2x00_configure_loop()
5208 if (atomic_read(&vha->loop_down_timer) || in qla2x00_configure_loop()
5209 test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { in qla2x00_configure_loop()
5212 atomic_set(&vha->loop_state, LOOP_READY); in qla2x00_configure_loop()
5215 ha->flags.fw_init_done = 1; in qla2x00_configure_loop()
5223 spin_lock_irqsave(&ha->tgt.atio_lock, flags); in qla2x00_configure_loop()
5225 spin_unlock_irqrestore(&ha->tgt.atio_lock, in qla2x00_configure_loop()
5240 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { in qla2x00_configure_loop()
5242 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_configure_loop()
5244 set_bit(RSCN_UPDATE, &vha->dpc_flags); in qla2x00_configure_loop()
5256 if (test_and_clear_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags)) in qla2x00_configure_n2n_loop()
5257 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla2x00_configure_n2n_loop()
5259 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_configure_n2n_loop()
5260 if (fcport->n2n_flag) { in qla2x00_configure_n2n_loop()
5266 spin_lock_irqsave(&vha->work_lock, flags); in qla2x00_configure_n2n_loop()
5267 vha->scan.scan_retry++; in qla2x00_configure_n2n_loop()
5268 spin_unlock_irqrestore(&vha->work_lock, flags); in qla2x00_configure_n2n_loop()
5270 if (vha->scan.scan_retry < MAX_SCAN_RETRIES) { in qla2x00_configure_n2n_loop()
5271 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_configure_n2n_loop()
5272 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_n2n_loop()
5282 atomic_set(&vha->loop_state, LOOP_DOWN); in qla_reinitialize_link()
5283 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); in qla_reinitialize_link()
5315 struct qla_hw_data *ha = vha->hw; in qla2x00_configure_local_loop()
5327 memset(ha->gid_list, 0, qla2x00_gid_list_size(ha)); in qla2x00_configure_local_loop()
5328 rval = qla2x00_get_id_list(vha, ha->gid_list, ha->gid_list_dma, in qla2x00_configure_local_loop()
5336 ha->gid_list, entries * sizeof(*ha->gid_list)); in qla2x00_configure_local_loop()
5339 spin_lock_irqsave(&vha->work_lock, flags); in qla2x00_configure_local_loop()
5340 vha->scan.scan_retry++; in qla2x00_configure_local_loop()
5341 spin_unlock_irqrestore(&vha->work_lock, flags); in qla2x00_configure_local_loop()
5343 if (vha->scan.scan_retry < MAX_SCAN_RETRIES) { in qla2x00_configure_local_loop()
5357 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_configure_local_loop()
5358 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_local_loop()
5361 vha->scan.scan_retry = 0; in qla2x00_configure_local_loop()
5364 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_configure_local_loop()
5365 fcport->scan_state = QLA_FCPORT_SCAN; in qla2x00_configure_local_loop()
5376 new_fcport->flags &= ~FCF_FABRIC_DEVICE; in qla2x00_configure_local_loop()
5379 gid = ha->gid_list; in qla2x00_configure_local_loop()
5381 domain = gid->domain; in qla2x00_configure_local_loop()
5382 area = gid->area; in qla2x00_configure_local_loop()
5383 al_pa = gid->al_pa; in qla2x00_configure_local_loop()
5385 loop_id = gid->loop_id_2100; in qla2x00_configure_local_loop()
5387 loop_id = le16_to_cpu(gid->loop_id); in qla2x00_configure_local_loop()
5388 gid = (void *)gid + ha->gid_list_info_size; in qla2x00_configure_local_loop()
5395 if (area && domain && ((area != vha->d_id.b.area) || in qla2x00_configure_local_loop()
5396 (domain != vha->d_id.b.domain)) && in qla2x00_configure_local_loop()
5397 (ha->current_topology == ISP_CFG_NL)) in qla2x00_configure_local_loop()
5405 memset(new_fcport->port_name, 0, WWN_SIZE); in qla2x00_configure_local_loop()
5408 new_fcport->d_id.b.domain = domain; in qla2x00_configure_local_loop()
5409 new_fcport->d_id.b.area = area; in qla2x00_configure_local_loop()
5410 new_fcport->d_id.b.al_pa = al_pa; in qla2x00_configure_local_loop()
5411 new_fcport->loop_id = loop_id; in qla2x00_configure_local_loop()
5412 new_fcport->scan_state = QLA_FCPORT_FOUND; in qla2x00_configure_local_loop()
5418 "-- get_port_database=%x, loop_id=0x%04x.\n", in qla2x00_configure_local_loop()
5419 rval2, new_fcport->loop_id); in qla2x00_configure_local_loop()
5421 if (ha->current_topology != ISP_CFG_N) { in qla2x00_configure_local_loop()
5424 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_local_loop()
5429 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla2x00_configure_local_loop()
5433 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_configure_local_loop()
5434 if (memcmp(new_fcport->port_name, fcport->port_name, in qla2x00_configure_local_loop()
5438 fcport->flags &= ~FCF_FABRIC_DEVICE; in qla2x00_configure_local_loop()
5439 fcport->loop_id = new_fcport->loop_id; in qla2x00_configure_local_loop()
5440 fcport->port_type = new_fcport->port_type; in qla2x00_configure_local_loop()
5441 fcport->d_id.b24 = new_fcport->d_id.b24; in qla2x00_configure_local_loop()
5442 memcpy(fcport->node_name, new_fcport->node_name, in qla2x00_configure_local_loop()
5444 fcport->scan_state = QLA_FCPORT_FOUND; in qla2x00_configure_local_loop()
5445 if (fcport->login_retry == 0) { in qla2x00_configure_local_loop()
5446 fcport->login_retry = vha->hw->login_retry_count; in qla2x00_configure_local_loop()
5449 fcport->port_name, fcport->loop_id, in qla2x00_configure_local_loop()
5450 fcport->login_retry); in qla2x00_configure_local_loop()
5458 list_add_tail(&new_fcport->list, &vha->vp_fcports); in qla2x00_configure_local_loop()
5463 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla2x00_configure_local_loop()
5473 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla2x00_configure_local_loop()
5474 new_fcport->flags &= ~FCF_FABRIC_DEVICE; in qla2x00_configure_local_loop()
5477 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla2x00_configure_local_loop()
5480 fcport->fp_speed = ha->link_data_rate; in qla2x00_configure_local_loop()
5485 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_configure_local_loop()
5486 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_configure_local_loop()
5489 if (fcport->scan_state == QLA_FCPORT_SCAN) { in qla2x00_configure_local_loop()
5492 atomic_read(&fcport->state) == FCS_ONLINE) { in qla2x00_configure_local_loop()
5495 if (fcport->loop_id != FC_NO_LOOP_ID && in qla2x00_configure_local_loop()
5496 (fcport->flags & FCF_FCP2_DEVICE) == 0 && in qla2x00_configure_local_loop()
5497 fcport->port_type != FCT_INITIATOR && in qla2x00_configure_local_loop()
5498 fcport->port_type != FCT_BROADCAST) { in qla2x00_configure_local_loop()
5502 fcport->port_name); in qla2x00_configure_local_loop()
5510 if (fcport->scan_state == QLA_FCPORT_FOUND) in qla2x00_configure_local_loop()
5529 struct qla_hw_data *ha = vha->hw; in qla2x00_iidma_fcport()
5534 if (atomic_read(&fcport->state) != FCS_ONLINE) in qla2x00_iidma_fcport()
5537 if (fcport->fp_speed == PORT_SPEED_UNKNOWN || in qla2x00_iidma_fcport()
5538 fcport->fp_speed > ha->link_data_rate || in qla2x00_iidma_fcport()
5539 !ha->flags.gpsc_supported) in qla2x00_iidma_fcport()
5542 rval = qla2x00_set_idma_speed(vha, fcport->loop_id, fcport->fp_speed, in qla2x00_iidma_fcport()
5546 "Unable to adjust iIDMA %8phN -- %04x %x %04x %04x.\n", in qla2x00_iidma_fcport()
5547 fcport->port_name, rval, fcport->fp_speed, mb[0], mb[1]); in qla2x00_iidma_fcport()
5551 qla2x00_get_link_speed_str(ha, fcport->fp_speed), in qla2x00_iidma_fcport()
5552 fcport->fp_speed, fcport->port_name); in qla2x00_iidma_fcport()
5570 e->u.fcport.fcport = fcport; in qla_post_iidma_work()
5582 if (atomic_read(&fcport->state) == FCS_ONLINE) in qla2x00_reg_remote_port()
5585 rport_ids.node_name = wwn_to_u64(fcport->node_name); in qla2x00_reg_remote_port()
5586 rport_ids.port_name = wwn_to_u64(fcport->port_name); in qla2x00_reg_remote_port()
5587 rport_ids.port_id = fcport->d_id.b.domain << 16 | in qla2x00_reg_remote_port()
5588 fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; in qla2x00_reg_remote_port()
5590 fcport->rport = rport = fc_remote_port_add(vha->host, 0, &rport_ids); in qla2x00_reg_remote_port()
5597 spin_lock_irqsave(fcport->vha->host->host_lock, flags); in qla2x00_reg_remote_port()
5598 *((fc_port_t **)rport->dd_data) = fcport; in qla2x00_reg_remote_port()
5599 spin_unlock_irqrestore(fcport->vha->host->host_lock, flags); in qla2x00_reg_remote_port()
5601 rport->supported_classes = fcport->supported_classes; in qla2x00_reg_remote_port()
5604 if (fcport->port_type == FCT_INITIATOR) in qla2x00_reg_remote_port()
5606 if (fcport->port_type == FCT_TARGET) in qla2x00_reg_remote_port()
5608 if (fcport->port_type & FCT_NVME_INITIATOR) in qla2x00_reg_remote_port()
5610 if (fcport->port_type & FCT_NVME_TARGET) in qla2x00_reg_remote_port()
5612 if (fcport->port_type & FCT_NVME_DISCOVERY) in qla2x00_reg_remote_port()
5617 __func__, fcport->port_name, rport, in qla2x00_reg_remote_port()
5618 (fcport->port_type == FCT_TARGET) ? "tgt" : in qla2x00_reg_remote_port()
5619 ((fcport->port_type & FCT_NVME) ? "nvme" : "ini")); in qla2x00_reg_remote_port()
5633 * 0 - Success
5634 * BIT_0 - error
5642 if (IS_SW_RESV_ADDR(fcport->d_id)) in qla2x00_update_fcport()
5646 __func__, fcport->port_name); in qla2x00_update_fcport()
5649 fcport->login_retry = vha->hw->login_retry_count; in qla2x00_update_fcport()
5650 fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); in qla2x00_update_fcport()
5651 fcport->deleted = 0; in qla2x00_update_fcport()
5652 if (vha->hw->current_topology == ISP_CFG_NL) in qla2x00_update_fcport()
5653 fcport->logout_on_delete = 0; in qla2x00_update_fcport()
5655 fcport->logout_on_delete = 1; in qla2x00_update_fcport()
5656 fcport->n2n_chip_reset = fcport->n2n_link_reset_cnt = 0; in qla2x00_update_fcport()
5658 switch (vha->hw->current_topology) { in qla2x00_update_fcport()
5661 fcport->keep_nport_handle = 1; in qla2x00_update_fcport()
5671 if (NVME_TARGET(vha->hw, fcport)) { in qla2x00_update_fcport()
5680 switch (vha->host->active_mode) { in qla2x00_update_fcport()
5685 if (!vha->vha_tgt.qla_tgt->tgt_stop && in qla2x00_update_fcport()
5686 !vha->vha_tgt.qla_tgt->tgt_stopped) in qla2x00_update_fcport()
5691 if (!vha->vha_tgt.qla_tgt->tgt_stop && in qla2x00_update_fcport()
5692 !vha->vha_tgt.qla_tgt->tgt_stopped) in qla2x00_update_fcport()
5701 if (IS_IIDMA_CAPABLE(vha->hw) && vha->hw->flags.gpsc_supported) { in qla2x00_update_fcport()
5702 if (fcport->id_changed) { in qla2x00_update_fcport()
5703 fcport->id_changed = 0; in qla2x00_update_fcport()
5706 __func__, __LINE__, fcport->port_name, in qla2x00_update_fcport()
5707 vha->fcport_count); in qla2x00_update_fcport()
5712 __func__, __LINE__, fcport->port_name, in qla2x00_update_fcport()
5713 vha->fcport_count); in qla2x00_update_fcport()
5724 u32 rscn_gen = fcport->rscn_gen; in qla_register_fcport_fn()
5727 if (IS_SW_RESV_ADDR(fcport->d_id)) in qla_register_fcport_fn()
5730 qla2x00_update_fcport(fcport->vha, fcport); in qla_register_fcport_fn()
5732 if (rscn_gen != fcport->rscn_gen) { in qla_register_fcport_fn()
5734 switch (fcport->next_disc_state) { in qla_register_fcport_fn()
5740 qla2x00_post_async_adisc_work(fcport->vha, fcport, in qla_register_fcport_fn()
5768 struct qla_hw_data *ha = vha->hw; in qla2x00_configure_fabric()
5776 rval = qla2x00_get_port_name(vha, loop_id, vha->fabric_node_name, 1); in qla2x00_configure_fabric()
5781 vha->device_flags &= ~SWITCH_FOUND; in qla2x00_configure_fabric()
5784 vha->device_flags |= SWITCH_FOUND; in qla2x00_configure_fabric()
5786 rval = qla2x00_get_port_name(vha, loop_id, vha->fabric_port_name, 0); in qla2x00_configure_fabric()
5804 rval = ha->isp_ops->fabric_login(vha, loop_id, 0xff, 0xff, in qla2x00_configure_fabric()
5810 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_fabric()
5816 test_and_clear_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags)) in qla2x00_configure_fabric()
5819 if (test_and_clear_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags)) { in qla2x00_configure_fabric()
5823 "Register FC-4 TYPE failed.\n"); in qla2x00_configure_fabric()
5825 &vha->dpc_flags)) in qla2x00_configure_fabric()
5831 "Register FC-4 Features failed.\n"); in qla2x00_configure_fabric()
5833 &vha->dpc_flags)) in qla2x00_configure_fabric()
5836 if (vha->flags.nvme_enabled) { in qla2x00_configure_fabric()
5847 &vha->dpc_flags)) in qla2x00_configure_fabric()
5853 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_configure_fabric()
5862 * disconnected port might have re-connected and a brand new in qla2x00_configure_fabric()
5871 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_fabric()
5873 list_for_each_entry(fcport, &vha->vp_fcports, list) in qla2x00_configure_fabric()
5874 fcport->scan_state = QLA_FCPORT_SCAN; in qla2x00_configure_fabric()
5882 if (!vha->nvme_local_port && vha->flags.nvme_enabled) in qla2x00_configure_fabric()
5917 struct qla_hw_data *ha = vha->hw; in qla2x00_find_all_fabric_devs()
5918 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); in qla2x00_find_all_fabric_devs()
5924 if (!ha->swl) in qla2x00_find_all_fabric_devs()
5925 ha->swl = kcalloc(ha->max_fibre_devices, sizeof(sw_info_t), in qla2x00_find_all_fabric_devs()
5927 swl = ha->swl; in qla2x00_find_all_fabric_devs()
5933 memset(swl, 0, ha->max_fibre_devices * sizeof(sw_info_t)); in qla2x00_find_all_fabric_devs()
5936 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
5940 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
5944 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
5948 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
5952 /* If other queries succeeded probe for FC-4 type */ in qla2x00_find_all_fabric_devs()
5955 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
5968 new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); in qla2x00_find_all_fabric_devs()
5974 loop_id = ha->min_external_loopid; in qla2x00_find_all_fabric_devs()
5975 for (; loop_id <= ha->max_loop_id; loop_id++) { in qla2x00_find_all_fabric_devs()
5979 if (ha->current_topology == ISP_CFG_FL && in qla2x00_find_all_fabric_devs()
5980 (atomic_read(&vha->loop_down_timer) || in qla2x00_find_all_fabric_devs()
5982 atomic_set(&vha->loop_down_timer, 0); in qla2x00_find_all_fabric_devs()
5983 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_find_all_fabric_devs()
5984 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_find_all_fabric_devs()
5990 wrap.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
5992 new_fcport->d_id.b24 = swl[swl_idx].d_id.b24; in qla2x00_find_all_fabric_devs()
5993 memcpy(new_fcport->node_name, in qla2x00_find_all_fabric_devs()
5995 memcpy(new_fcport->port_name, in qla2x00_find_all_fabric_devs()
5997 memcpy(new_fcport->fabric_port_name, in qla2x00_find_all_fabric_devs()
5999 new_fcport->fp_speed = swl[swl_idx].fp_speed; in qla2x00_find_all_fabric_devs()
6000 new_fcport->fc4_type = swl[swl_idx].fc4_type; in qla2x00_find_all_fabric_devs()
6002 new_fcport->nvme_flag = 0; in qla2x00_find_all_fabric_devs()
6003 if (vha->flags.nvme_enabled && in qla2x00_find_all_fabric_devs()
6007 new_fcport->port_name); in qla2x00_find_all_fabric_devs()
6020 "SNS scan failed -- assuming " in qla2x00_find_all_fabric_devs()
6021 "zero-entry result.\n"); in qla2x00_find_all_fabric_devs()
6029 wrap.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
6031 } else if (new_fcport->d_id.b24 == wrap.b24) { in qla2x00_find_all_fabric_devs()
6034 new_fcport->d_id.b.domain, in qla2x00_find_all_fabric_devs()
6035 new_fcport->d_id.b.area, in qla2x00_find_all_fabric_devs()
6036 new_fcport->d_id.b.al_pa); in qla2x00_find_all_fabric_devs()
6041 if (new_fcport->d_id.b24 == base_vha->d_id.b24) in qla2x00_find_all_fabric_devs()
6045 if (qla2x00_is_a_vp_did(vha, new_fcport->d_id.b24)) in qla2x00_find_all_fabric_devs()
6049 if (((new_fcport->d_id.b24 & 0xffff00) == in qla2x00_find_all_fabric_devs()
6050 (vha->d_id.b24 & 0xffff00)) && ha->current_topology == in qla2x00_find_all_fabric_devs()
6055 if ((new_fcport->d_id.b.domain & 0xf0) == 0xf0) in qla2x00_find_all_fabric_devs()
6058 /* Bypass ports whose FCP-4 type is not FCP_SCSI */ in qla2x00_find_all_fabric_devs()
6060 (!(new_fcport->fc4_type & FS_FC4TYPE_FCP) && in qla2x00_find_all_fabric_devs()
6061 new_fcport->fc4_type != 0)) in qla2x00_find_all_fabric_devs()
6064 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla2x00_find_all_fabric_devs()
6068 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_find_all_fabric_devs()
6069 if (memcmp(new_fcport->port_name, fcport->port_name, in qla2x00_find_all_fabric_devs()
6073 fcport->scan_state = QLA_FCPORT_FOUND; in qla2x00_find_all_fabric_devs()
6078 memcpy(fcport->fabric_port_name, in qla2x00_find_all_fabric_devs()
6079 new_fcport->fabric_port_name, WWN_SIZE); in qla2x00_find_all_fabric_devs()
6080 fcport->fp_speed = new_fcport->fp_speed; in qla2x00_find_all_fabric_devs()
6086 if (fcport->d_id.b24 == new_fcport->d_id.b24 && in qla2x00_find_all_fabric_devs()
6087 (atomic_read(&fcport->state) == FCS_ONLINE || in qla2x00_find_all_fabric_devs()
6088 (vha->host->active_mode == MODE_TARGET))) { in qla2x00_find_all_fabric_devs()
6095 if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) { in qla2x00_find_all_fabric_devs()
6096 fcport->d_id.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
6098 fcport->flags |= (FCF_FABRIC_DEVICE | in qla2x00_find_all_fabric_devs()
6111 " old %x:%x:%x (loop_id 0x%04x)-> new %x:%x:%x\n", in qla2x00_find_all_fabric_devs()
6112 fcport->port_name, in qla2x00_find_all_fabric_devs()
6113 fcport->d_id.b.domain, in qla2x00_find_all_fabric_devs()
6114 fcport->d_id.b.area, in qla2x00_find_all_fabric_devs()
6115 fcport->d_id.b.al_pa, in qla2x00_find_all_fabric_devs()
6116 fcport->loop_id, in qla2x00_find_all_fabric_devs()
6117 new_fcport->d_id.b.domain, in qla2x00_find_all_fabric_devs()
6118 new_fcport->d_id.b.area, in qla2x00_find_all_fabric_devs()
6119 new_fcport->d_id.b.al_pa); in qla2x00_find_all_fabric_devs()
6120 fcport->d_id.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
6124 fcport->d_id.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
6125 fcport->flags |= FCF_LOGIN_NEEDED; in qla2x00_find_all_fabric_devs()
6129 if (found && NVME_TARGET(vha->hw, fcport)) { in qla2x00_find_all_fabric_devs()
6130 if (fcport->disc_state == DSC_DELETE_PEND) { in qla2x00_find_all_fabric_devs()
6132 vha->fcport_count--; in qla2x00_find_all_fabric_devs()
6133 fcport->login_succ = 0; in qla2x00_find_all_fabric_devs()
6138 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla2x00_find_all_fabric_devs()
6142 new_fcport->scan_state = QLA_FCPORT_FOUND; in qla2x00_find_all_fabric_devs()
6143 list_add_tail(&new_fcport->list, &vha->vp_fcports); in qla2x00_find_all_fabric_devs()
6145 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla2x00_find_all_fabric_devs()
6149 nxt_d_id.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
6156 new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); in qla2x00_find_all_fabric_devs()
6157 new_fcport->d_id.b24 = nxt_d_id.b24; in qla2x00_find_all_fabric_devs()
6165 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_find_all_fabric_devs()
6166 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
6169 if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) in qla2x00_find_all_fabric_devs()
6172 if (fcport->scan_state == QLA_FCPORT_SCAN) { in qla2x00_find_all_fabric_devs()
6175 atomic_read(&fcport->state) == FCS_ONLINE) { in qla2x00_find_all_fabric_devs()
6178 if (fcport->loop_id != FC_NO_LOOP_ID && in qla2x00_find_all_fabric_devs()
6179 (fcport->flags & FCF_FCP2_DEVICE) == 0 && in qla2x00_find_all_fabric_devs()
6180 fcport->port_type != FCT_INITIATOR && in qla2x00_find_all_fabric_devs()
6181 fcport->port_type != FCT_BROADCAST) { in qla2x00_find_all_fabric_devs()
6185 fcport->port_name); in qla2x00_find_all_fabric_devs()
6192 if (fcport->scan_state == QLA_FCPORT_FOUND && in qla2x00_find_all_fabric_devs()
6193 (fcport->flags & FCF_LOGIN_NEEDED) != 0) in qla2x00_find_all_fabric_devs()
6204 int lid = NPH_MGMT_SERVER - vha->vp_idx; in qla2x00_reserve_mgmt_server_loop_id()
6206 struct qla_hw_data *ha = vha->hw; in qla2x00_reserve_mgmt_server_loop_id()
6208 if (vha->vp_idx == 0) { in qla2x00_reserve_mgmt_server_loop_id()
6209 set_bit(NPH_MGMT_SERVER, ha->loop_id_map); in qla2x00_reserve_mgmt_server_loop_id()
6214 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_reserve_mgmt_server_loop_id()
6215 for (; lid > 0; lid--) { in qla2x00_reserve_mgmt_server_loop_id()
6216 if (!test_bit(lid, vha->hw->loop_id_map)) { in qla2x00_reserve_mgmt_server_loop_id()
6217 set_bit(lid, vha->hw->loop_id_map); in qla2x00_reserve_mgmt_server_loop_id()
6222 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_reserve_mgmt_server_loop_id()
6236 * 0 - Login successfully
6237 * 1 - Login failed
6238 * 2 - Initiator device
6239 * 3 - Fatal error
6249 struct qla_hw_data *ha = vha->hw; in qla2x00_fabric_login()
6258 fcport->loop_id, fcport->d_id.b.domain, in qla2x00_fabric_login()
6259 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_fabric_login()
6262 rval = ha->isp_ops->fabric_login(vha, fcport->loop_id, in qla2x00_fabric_login()
6263 fcport->d_id.b.domain, fcport->d_id.b.area, in qla2x00_fabric_login()
6264 fcport->d_id.b.al_pa, mb, BIT_0); in qla2x00_fabric_login()
6277 tmp_loopid = fcport->loop_id; in qla2x00_fabric_login()
6278 fcport->loop_id = mb[1]; in qla2x00_fabric_login()
6281 "Fabric Login: port in use - next loop " in qla2x00_fabric_login()
6283 fcport->loop_id, fcport->d_id.b.domain, in qla2x00_fabric_login()
6284 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_fabric_login()
6298 *next_loopid = (fcport->loop_id + 1); in qla2x00_fabric_login()
6302 fcport->port_type = FCT_INITIATOR; in qla2x00_fabric_login()
6304 fcport->port_type = FCT_TARGET; in qla2x00_fabric_login()
6306 fcport->flags |= FCF_FCP2_DEVICE; in qla2x00_fabric_login()
6311 fcport->supported_classes |= FC_COS_CLASS2; in qla2x00_fabric_login()
6313 fcport->supported_classes |= FC_COS_CLASS3; in qla2x00_fabric_login()
6317 fcport->flags |= in qla2x00_fabric_login()
6327 fcport->loop_id++; in qla2x00_fabric_login()
6339 *next_loopid = fcport->loop_id; in qla2x00_fabric_login()
6340 ha->isp_ops->fabric_logout(vha, fcport->loop_id, in qla2x00_fabric_login()
6341 fcport->d_id.b.domain, fcport->d_id.b.area, in qla2x00_fabric_login()
6342 fcport->d_id.b.al_pa); in qla2x00_fabric_login()
6353 "jiffies=%lx.\n", mb[0], fcport->d_id.b.domain, in qla2x00_fabric_login()
6354 fcport->d_id.b.area, fcport->d_id.b.al_pa, in qla2x00_fabric_login()
6355 fcport->loop_id, jiffies); in qla2x00_fabric_login()
6357 *next_loopid = fcport->loop_id; in qla2x00_fabric_login()
6358 ha->isp_ops->fabric_logout(vha, fcport->loop_id, in qla2x00_fabric_login()
6359 fcport->d_id.b.domain, fcport->d_id.b.area, in qla2x00_fabric_login()
6360 fcport->d_id.b.al_pa); in qla2x00_fabric_login()
6362 fcport->login_retry = 0; in qla2x00_fabric_login()
6381 * 0 - Login successfully
6382 * 1 - Login failed
6383 * 3 - Fatal error
6421 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_loop_resync()
6422 if (vha->flags.online) { in qla2x00_loop_resync()
6427 if (!IS_QLAFX00(vha->hw)) { in qla2x00_loop_resync()
6432 qla2x00_marker(vha, vha->hw->base_qpair, in qla2x00_loop_resync()
6434 vha->marker_needed = 0; in qla2x00_loop_resync()
6438 clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_loop_resync()
6440 if (IS_QLAFX00(vha->hw)) in qla2x00_loop_resync()
6445 wait_time--; in qla2x00_loop_resync()
6446 } while (!atomic_read(&vha->loop_down_timer) && in qla2x00_loop_resync()
6447 !(test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) in qla2x00_loop_resync()
6449 &vha->dpc_flags))); in qla2x00_loop_resync()
6453 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) in qla2x00_loop_resync()
6475 if (!test_and_set_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags)) { in qla2x00_perform_loop_resync()
6477 atomic_set(&ha->loop_down_timer, 0); in qla2x00_perform_loop_resync()
6478 if (!(ha->device_flags & DFLG_NO_CABLE)) { in qla2x00_perform_loop_resync()
6479 atomic_set(&ha->loop_state, LOOP_UP); in qla2x00_perform_loop_resync()
6480 set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); in qla2x00_perform_loop_resync()
6481 set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags); in qla2x00_perform_loop_resync()
6482 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); in qla2x00_perform_loop_resync()
6486 atomic_set(&ha->loop_state, LOOP_DEAD); in qla2x00_perform_loop_resync()
6488 clear_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags); in qla2x00_perform_loop_resync()
6499 struct qla_hw_data *ha = base_vha->hw; in qla2x00_update_fcports()
6502 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_update_fcports()
6504 list_for_each_entry(vha, &base_vha->hw->vp_list, list) { in qla2x00_update_fcports()
6505 atomic_inc(&vha->vref_count); in qla2x00_update_fcports()
6506 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_update_fcports()
6507 if (fcport->drport && in qla2x00_update_fcports()
6508 atomic_read(&fcport->state) != FCS_UNCONFIGURED) { in qla2x00_update_fcports()
6509 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_update_fcports()
6512 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_update_fcports()
6515 atomic_dec(&vha->vref_count); in qla2x00_update_fcports()
6516 wake_up(&vha->vref_waitq); in qla2x00_update_fcports()
6518 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_update_fcports()
6525 struct qla_hw_data *ha = vha->hw; in qla83xx_reset_ownership()
6546 (i != ha->portnum)) { in qla83xx_reset_ownership()
6556 ((i + 8) != ha->portnum)) { in qla83xx_reset_ownership()
6563 * Prepare drv-presence mask based on fcoe functions present. in qla83xx_reset_ownership()
6564 * However consider only valid physical fcoe function numbers (0-15). in qla83xx_reset_ownership()
6566 drv_presence_mask = ~((1 << (ha->portnum)) | in qla83xx_reset_ownership()
6571 * - No other protocol drivers present. in qla83xx_reset_ownership()
6572 * - This is the lowest among fcoe functions. */ in qla83xx_reset_ownership()
6574 (ha->portnum < fcoe_other_function)) { in qla83xx_reset_ownership()
6577 ha->flags.nic_core_reset_owner = 1; in qla83xx_reset_ownership()
6585 struct qla_hw_data *ha = vha->hw; in __qla83xx_set_drv_ack()
6590 drv_ack |= (1 << ha->portnum); in __qla83xx_set_drv_ack()
6601 struct qla_hw_data *ha = vha->hw; in __qla83xx_clear_drv_ack()
6606 drv_ack &= ~(1 << ha->portnum); in __qla83xx_clear_drv_ack()
6618 return "COLD/RE-INIT"; in qla83xx_dev_state_to_string()
6636 /* Assumes idc-lock always held on entry */
6640 struct qla_hw_data *ha = vha->hw; in qla83xx_idc_audit()
6645 ha->idc_audit_ts = (jiffies_to_msecs(jiffies) / 1000); in qla83xx_idc_audit()
6646 idc_audit_reg = (ha->portnum) | in qla83xx_idc_audit()
6647 (IDC_AUDIT_TIMESTAMP << 7) | (ha->idc_audit_ts << 8); in qla83xx_idc_audit()
6652 duration_secs = ((jiffies_to_msecs(jiffies) - in qla83xx_idc_audit()
6653 jiffies_to_msecs(ha->idc_audit_ts)) / 1000); in qla83xx_idc_audit()
6654 idc_audit_reg = (ha->portnum) | in qla83xx_idc_audit()
6670 struct qla_hw_data *ha = vha->hw; in qla83xx_initiating_reset()
6676 "NIC Core reset has been disabled. idc-control=0x%x\n", in qla83xx_initiating_reset()
6681 /* Set NEED-RESET iff in READY state and we are the reset-owner */ in qla83xx_initiating_reset()
6683 if (ha->flags.nic_core_reset_owner && dev_state == QLA8XXX_DEV_READY) { in qla83xx_initiating_reset()
6694 /* Wait for IDC state change READY -> NEED_RESET */ in qla83xx_initiating_reset()
6703 /* Send IDC ack by writing to drv-ack register */ in qla83xx_initiating_reset()
6725 struct qla_hw_data *ha = vha->hw; in qla83xx_check_driver_presence()
6728 if (drv_presence & (1 << ha->portnum)) in qla83xx_check_driver_presence()
6738 struct qla_hw_data *ha = vha->hw; in qla83xx_nic_core_reset()
6743 if (vha->device_flags & DFLG_DEV_FAILED) { in qla83xx_nic_core_reset()
6754 ha->portnum); in qla83xx_nic_core_reset()
6764 * Perform reset if we are the reset-owner, in qla83xx_nic_core_reset()
6771 ha->flags.nic_core_hung = 0; in qla83xx_nic_core_reset()
6786 struct qla_hw_data *ha = vha->hw; in qla2xxx_mctp_dump()
6796 if (!ha->mctp_dump) { in qla2xxx_mctp_dump()
6797 ha->mctp_dump = dma_alloc_coherent(&ha->pdev->dev, in qla2xxx_mctp_dump()
6798 MCTP_DUMP_SIZE, &ha->mctp_dump_dma, GFP_KERNEL); in qla2xxx_mctp_dump()
6800 if (!ha->mctp_dump) { in qla2xxx_mctp_dump()
6808 rval = qla2x00_dump_mctp_data(vha, ha->mctp_dump_dma, in qla2xxx_mctp_dump()
6816 vha->host_no, ha->mctp_dump); in qla2xxx_mctp_dump()
6817 ha->mctp_dumped = 1; in qla2xxx_mctp_dump()
6820 if (!ha->flags.nic_core_reset_hdlr_active && !ha->portnum) { in qla2xxx_mctp_dump()
6821 ha->flags.nic_core_reset_hdlr_active = 1; in qla2xxx_mctp_dump()
6830 ha->flags.nic_core_reset_hdlr_active = 0; in qla2xxx_mctp_dump()
6848 struct qla_hw_data *ha = vha->hw; in qla2x00_quiesce_io()
6852 "Quiescing I/O - ha=%p.\n", ha); in qla2x00_quiesce_io()
6854 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); in qla2x00_quiesce_io()
6855 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { in qla2x00_quiesce_io()
6856 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_quiesce_io()
6858 list_for_each_entry(vp, &ha->vp_list, list) in qla2x00_quiesce_io()
6861 if (!atomic_read(&vha->loop_down_timer)) in qla2x00_quiesce_io()
6862 atomic_set(&vha->loop_down_timer, in qla2x00_quiesce_io()
6873 struct qla_hw_data *ha = vha->hw; in qla2x00_abort_isp_cleanup()
6883 vha->flags.online = 0; in qla2x00_abort_isp_cleanup()
6884 ha->flags.chip_reset_done = 0; in qla2x00_abort_isp_cleanup()
6885 clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_abort_isp_cleanup()
6886 vha->qla_stats.total_isp_aborts++; in qla2x00_abort_isp_cleanup()
6889 "Performing ISP error recovery - ha=%p.\n", ha); in qla2x00_abort_isp_cleanup()
6891 ha->flags.purge_mbox = 1; in qla2x00_abort_isp_cleanup()
6897 ha->isp_ops->reset_chip(vha); in qla2x00_abort_isp_cleanup()
6899 ha->link_data_rate = PORT_SPEED_UNKNOWN; in qla2x00_abort_isp_cleanup()
6901 ha->flags.rida_fmt2 = 0; in qla2x00_abort_isp_cleanup()
6902 ha->flags.n2n_ae = 0; in qla2x00_abort_isp_cleanup()
6903 ha->flags.lip_ae = 0; in qla2x00_abort_isp_cleanup()
6904 ha->current_topology = 0; in qla2x00_abort_isp_cleanup()
6906 ha->flags.fw_init_done = 0; in qla2x00_abort_isp_cleanup()
6907 ha->chip_reset++; in qla2x00_abort_isp_cleanup()
6908 ha->base_qpair->chip_reset = ha->chip_reset; in qla2x00_abort_isp_cleanup()
6909 for (i = 0; i < ha->max_qpairs; i++) { in qla2x00_abort_isp_cleanup()
6910 if (ha->queue_pair_map[i]) in qla2x00_abort_isp_cleanup()
6911 ha->queue_pair_map[i]->chip_reset = in qla2x00_abort_isp_cleanup()
6912 ha->base_qpair->chip_reset; in qla2x00_abort_isp_cleanup()
6916 if (atomic_read(&ha->num_pend_mbx_stage3)) { in qla2x00_abort_isp_cleanup()
6917 clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); in qla2x00_abort_isp_cleanup()
6918 complete(&ha->mbx_intr_comp); in qla2x00_abort_isp_cleanup()
6922 while (atomic_read(&ha->num_pend_mbx_stage3) || in qla2x00_abort_isp_cleanup()
6923 atomic_read(&ha->num_pend_mbx_stage2) || in qla2x00_abort_isp_cleanup()
6924 atomic_read(&ha->num_pend_mbx_stage1)) { in qla2x00_abort_isp_cleanup()
6930 ha->flags.purge_mbox = 0; in qla2x00_abort_isp_cleanup()
6932 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); in qla2x00_abort_isp_cleanup()
6933 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { in qla2x00_abort_isp_cleanup()
6934 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_abort_isp_cleanup()
6937 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6938 list_for_each_entry(vp, &ha->vp_list, list) { in qla2x00_abort_isp_cleanup()
6939 atomic_inc(&vp->vref_count); in qla2x00_abort_isp_cleanup()
6940 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6944 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6945 atomic_dec(&vp->vref_count); in qla2x00_abort_isp_cleanup()
6947 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6949 if (!atomic_read(&vha->loop_down_timer)) in qla2x00_abort_isp_cleanup()
6950 atomic_set(&vha->loop_down_timer, in qla2x00_abort_isp_cleanup()
6955 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_abort_isp_cleanup()
6956 fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); in qla2x00_abort_isp_cleanup()
6957 fcport->scan_state = 0; in qla2x00_abort_isp_cleanup()
6959 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6960 list_for_each_entry(vp, &ha->vp_list, list) { in qla2x00_abort_isp_cleanup()
6961 atomic_inc(&vp->vref_count); in qla2x00_abort_isp_cleanup()
6962 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6964 list_for_each_entry(fcport, &vp->vp_fcports, list) in qla2x00_abort_isp_cleanup()
6965 fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); in qla2x00_abort_isp_cleanup()
6967 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6968 atomic_dec(&vp->vref_count); in qla2x00_abort_isp_cleanup()
6970 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6972 if (!ha->flags.eeh_busy) { in qla2x00_abort_isp_cleanup()
6982 vha->flags.online = 0; in qla2x00_abort_isp_cleanup()
7007 struct qla_hw_data *ha = vha->hw; in qla2x00_abort_isp()
7009 struct req_que *req = ha->req_q_map[0]; in qla2x00_abort_isp()
7012 if (vha->flags.online) { in qla2x00_abort_isp()
7015 if (test_and_clear_bit(ISP_ABORT_TO_ROM, &vha->dpc_flags)) { in qla2x00_abort_isp()
7016 ha->flags.chip_reset_done = 1; in qla2x00_abort_isp()
7017 vha->flags.online = 1; in qla2x00_abort_isp()
7019 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_abort_isp()
7028 "Error while clearing DRV-Presence.\n"); in qla2x00_abort_isp()
7031 if (unlikely(pci_channel_offline(ha->pdev) && in qla2x00_abort_isp()
7032 ha->flags.pci_channel_io_perm_failure)) { in qla2x00_abort_isp()
7033 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_abort_isp()
7038 switch (vha->qlini_mode) { in qla2x00_abort_isp()
7053 ha->isp_ops->get_flash_version(vha, req->ring); in qla2x00_abort_isp()
7055 ha->isp_ops->nvram_config(vha); in qla2x00_abort_isp()
7058 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla2x00_abort_isp()
7060 if (!atomic_read(&vha->loop_down_timer)) { in qla2x00_abort_isp()
7065 vha->marker_needed = 1; in qla2x00_abort_isp()
7068 vha->flags.online = 1; in qla2x00_abort_isp()
7070 ha->isp_ops->enable_intrs(ha); in qla2x00_abort_isp()
7072 ha->isp_abort_cnt = 0; in qla2x00_abort_isp()
7073 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_abort_isp()
7077 if (ha->fce) { in qla2x00_abort_isp()
7078 ha->flags.fce_enabled = 1; in qla2x00_abort_isp()
7079 memset(ha->fce, 0, in qla2x00_abort_isp()
7080 fce_calc_size(ha->fce_bufs)); in qla2x00_abort_isp()
7082 ha->fce_dma, ha->fce_bufs, ha->fce_mb, in qla2x00_abort_isp()
7083 &ha->fce_bufs); in qla2x00_abort_isp()
7088 ha->flags.fce_enabled = 0; in qla2x00_abort_isp()
7092 if (ha->eft) { in qla2x00_abort_isp()
7093 memset(ha->eft, 0, EFT_SIZE); in qla2x00_abort_isp()
7095 ha->eft_dma, EFT_NUM_BUFFERS); in qla2x00_abort_isp()
7103 vha->flags.online = 1; in qla2x00_abort_isp()
7104 if (test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { in qla2x00_abort_isp()
7105 if (ha->isp_abort_cnt == 0) { in qla2x00_abort_isp()
7107 "ISP error recover failed - " in qla2x00_abort_isp()
7114 vha->flags.online = 0; in qla2x00_abort_isp()
7116 &vha->dpc_flags); in qla2x00_abort_isp()
7119 ha->isp_abort_cnt--; in qla2x00_abort_isp()
7121 "ISP abort - retry remaining %d.\n", in qla2x00_abort_isp()
7122 ha->isp_abort_cnt); in qla2x00_abort_isp()
7126 ha->isp_abort_cnt = MAX_RETRIES_OF_ISP_ABORT; in qla2x00_abort_isp()
7128 "ISP error recovery - retrying (%d) " in qla2x00_abort_isp()
7129 "more times.\n", ha->isp_abort_cnt); in qla2x00_abort_isp()
7130 set_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_abort_isp()
7140 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp()
7141 list_for_each_entry(vp, &ha->vp_list, list) { in qla2x00_abort_isp()
7142 if (vp->vp_idx) { in qla2x00_abort_isp()
7143 atomic_inc(&vp->vref_count); in qla2x00_abort_isp()
7144 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp()
7148 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp()
7149 atomic_dec(&vp->vref_count); in qla2x00_abort_isp()
7152 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp()
7159 "Error while setting DRV-Presence.\n"); in qla2x00_abort_isp()
7183 struct qla_hw_data *ha = vha->hw; in qla2x00_restart_isp()
7187 vha->flags.online = 0; in qla2x00_restart_isp()
7188 status = ha->isp_ops->chip_diag(vha); in qla2x00_restart_isp()
7200 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla2x00_restart_isp()
7201 ha->flags.chip_reset_done = 1; in qla2x00_restart_isp()
7209 return vha->device_flags & DFLG_NO_CABLE ? 0 : status; in qla2x00_restart_isp()
7213 qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL); in qla2x00_restart_isp()
7214 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_restart_isp()
7224 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); in qla25xx_init_queues()
7225 int ret = -1; in qla25xx_init_queues()
7228 for (i = 1; i < ha->max_rsp_queues; i++) { in qla25xx_init_queues()
7229 rsp = ha->rsp_q_map[i]; in qla25xx_init_queues()
7230 if (rsp && test_bit(i, ha->rsp_qid_map)) { in qla25xx_init_queues()
7231 rsp->options &= ~BIT_0; in qla25xx_init_queues()
7236 __func__, rsp->id); in qla25xx_init_queues()
7240 __func__, rsp->id); in qla25xx_init_queues()
7243 for (i = 1; i < ha->max_req_queues; i++) { in qla25xx_init_queues()
7244 req = ha->req_q_map[i]; in qla25xx_init_queues()
7245 if (req && test_bit(i, ha->req_qid_map)) { in qla25xx_init_queues()
7247 req->options &= ~BIT_0; in qla25xx_init_queues()
7252 __func__, req->id); in qla25xx_init_queues()
7256 __func__, req->id); in qla25xx_init_queues()
7273 struct qla_hw_data *ha = vha->hw; in qla2x00_reset_adapter()
7274 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_reset_adapter()
7276 vha->flags.online = 0; in qla2x00_reset_adapter()
7277 ha->isp_ops->disable_intrs(ha); in qla2x00_reset_adapter()
7279 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_reset_adapter()
7280 wrt_reg_word(®->hccr, HCCR_RESET_RISC); in qla2x00_reset_adapter()
7281 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_adapter()
7282 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2x00_reset_adapter()
7283 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_adapter()
7284 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_reset_adapter()
7293 struct qla_hw_data *ha = vha->hw; in qla24xx_reset_adapter()
7294 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla24xx_reset_adapter()
7299 vha->flags.online = 0; in qla24xx_reset_adapter()
7300 ha->isp_ops->disable_intrs(ha); in qla24xx_reset_adapter()
7302 spin_lock_irqsave(&ha->hardware_lock, flags); in qla24xx_reset_adapter()
7303 wrt_reg_dword(®->hccr, HCCRX_SET_RISC_RESET); in qla24xx_reset_adapter()
7304 rd_reg_dword(®->hccr); in qla24xx_reset_adapter()
7305 wrt_reg_dword(®->hccr, HCCRX_REL_RISC_PAUSE); in qla24xx_reset_adapter()
7306 rd_reg_dword(®->hccr); in qla24xx_reset_adapter()
7307 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_reset_adapter()
7310 ha->isp_ops->enable_intrs(ha); in qla24xx_reset_adapter()
7322 struct qla_hw_data *ha = vha->hw; in qla24xx_nvram_wwn_from_ofw()
7323 struct pci_dev *pdev = ha->pdev; in qla24xx_nvram_wwn_from_ofw()
7328 val = of_get_property(dp, "port-wwn", &len); in qla24xx_nvram_wwn_from_ofw()
7330 memcpy(nv->port_name, val, WWN_SIZE); in qla24xx_nvram_wwn_from_ofw()
7332 val = of_get_property(dp, "node-wwn", &len); in qla24xx_nvram_wwn_from_ofw()
7334 memcpy(nv->node_name, val, WWN_SIZE); in qla24xx_nvram_wwn_from_ofw()
7348 struct qla_hw_data *ha = vha->hw; in qla24xx_nvram_config()
7351 icb = (struct init_cb_24xx *)ha->init_cb; in qla24xx_nvram_config()
7352 nv = ha->nvram; in qla24xx_nvram_config()
7355 if (ha->port_no == 0) { in qla24xx_nvram_config()
7356 ha->nvram_base = FA_NVRAM_FUNC0_ADDR; in qla24xx_nvram_config()
7357 ha->vpd_base = FA_NVRAM_VPD0_ADDR; in qla24xx_nvram_config()
7359 ha->nvram_base = FA_NVRAM_FUNC1_ADDR; in qla24xx_nvram_config()
7360 ha->vpd_base = FA_NVRAM_VPD1_ADDR; in qla24xx_nvram_config()
7363 ha->nvram_size = sizeof(*nv); in qla24xx_nvram_config()
7364 ha->vpd_size = FA_NVRAM_VPD_SIZE; in qla24xx_nvram_config()
7367 ha->vpd = ha->nvram + VPD_OFFSET; in qla24xx_nvram_config()
7368 ha->isp_ops->read_nvram(vha, ha->vpd, in qla24xx_nvram_config()
7369 ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4); in qla24xx_nvram_config()
7373 ha->isp_ops->read_nvram(vha, dptr, ha->nvram_base, ha->nvram_size); in qla24xx_nvram_config()
7374 for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++, dptr++) in qla24xx_nvram_config()
7380 nv, ha->nvram_size); in qla24xx_nvram_config()
7383 if (chksum || memcmp("ISP ", nv->id, sizeof(nv->id)) || in qla24xx_nvram_config()
7384 le16_to_cpu(nv->nvram_version) < ICB_VERSION) { in qla24xx_nvram_config()
7388 chksum, nv->id, nv->nvram_version); in qla24xx_nvram_config()
7391 "Falling back to functioning (yet invalid -- WWPN) " in qla24xx_nvram_config()
7397 memset(nv, 0, ha->nvram_size); in qla24xx_nvram_config()
7398 nv->nvram_version = cpu_to_le16(ICB_VERSION); in qla24xx_nvram_config()
7399 nv->version = cpu_to_le16(ICB_VERSION); in qla24xx_nvram_config()
7400 nv->frame_payload_size = cpu_to_le16(2048); in qla24xx_nvram_config()
7401 nv->execution_throttle = cpu_to_le16(0xFFFF); in qla24xx_nvram_config()
7402 nv->exchange_count = cpu_to_le16(0); in qla24xx_nvram_config()
7403 nv->hard_address = cpu_to_le16(124); in qla24xx_nvram_config()
7404 nv->port_name[0] = 0x21; in qla24xx_nvram_config()
7405 nv->port_name[1] = 0x00 + ha->port_no + 1; in qla24xx_nvram_config()
7406 nv->port_name[2] = 0x00; in qla24xx_nvram_config()
7407 nv->port_name[3] = 0xe0; in qla24xx_nvram_config()
7408 nv->port_name[4] = 0x8b; in qla24xx_nvram_config()
7409 nv->port_name[5] = 0x1c; in qla24xx_nvram_config()
7410 nv->port_name[6] = 0x55; in qla24xx_nvram_config()
7411 nv->port_name[7] = 0x86; in qla24xx_nvram_config()
7412 nv->node_name[0] = 0x20; in qla24xx_nvram_config()
7413 nv->node_name[1] = 0x00; in qla24xx_nvram_config()
7414 nv->node_name[2] = 0x00; in qla24xx_nvram_config()
7415 nv->node_name[3] = 0xe0; in qla24xx_nvram_config()
7416 nv->node_name[4] = 0x8b; in qla24xx_nvram_config()
7417 nv->node_name[5] = 0x1c; in qla24xx_nvram_config()
7418 nv->node_name[6] = 0x55; in qla24xx_nvram_config()
7419 nv->node_name[7] = 0x86; in qla24xx_nvram_config()
7421 nv->login_retry_count = cpu_to_le16(8); in qla24xx_nvram_config()
7422 nv->interrupt_delay_timer = cpu_to_le16(0); in qla24xx_nvram_config()
7423 nv->login_timeout = cpu_to_le16(0); in qla24xx_nvram_config()
7424 nv->firmware_options_1 = in qla24xx_nvram_config()
7426 nv->firmware_options_2 = cpu_to_le32(2 << 4); in qla24xx_nvram_config()
7427 nv->firmware_options_2 |= cpu_to_le32(BIT_12); in qla24xx_nvram_config()
7428 nv->firmware_options_3 = cpu_to_le32(2 << 13); in qla24xx_nvram_config()
7429 nv->host_p = cpu_to_le32(BIT_11|BIT_10); in qla24xx_nvram_config()
7430 nv->efi_parameters = cpu_to_le32(0); in qla24xx_nvram_config()
7431 nv->reset_delay = 5; in qla24xx_nvram_config()
7432 nv->max_luns_per_target = cpu_to_le16(128); in qla24xx_nvram_config()
7433 nv->port_down_retry_count = cpu_to_le16(30); in qla24xx_nvram_config()
7434 nv->link_down_timeout = cpu_to_le16(30); in qla24xx_nvram_config()
7441 nv->firmware_options_1 &= cpu_to_le32(~BIT_13); in qla24xx_nvram_config()
7443 nv->host_p &= cpu_to_le32(~BIT_10); in qla24xx_nvram_config()
7449 memset(icb, 0, ha->init_cb_size); in qla24xx_nvram_config()
7453 dptr2 = (uint8_t *)&nv->version; in qla24xx_nvram_config()
7454 cnt = (uint8_t *)&icb->response_q_inpointer - (uint8_t *)&icb->version; in qla24xx_nvram_config()
7455 while (cnt--) in qla24xx_nvram_config()
7458 icb->login_retry_count = nv->login_retry_count; in qla24xx_nvram_config()
7459 icb->link_down_on_nos = nv->link_down_on_nos; in qla24xx_nvram_config()
7462 dptr1 = (uint8_t *)&icb->interrupt_delay_timer; in qla24xx_nvram_config()
7463 dptr2 = (uint8_t *)&nv->interrupt_delay_timer; in qla24xx_nvram_config()
7464 cnt = (uint8_t *)&icb->reserved_3 - in qla24xx_nvram_config()
7465 (uint8_t *)&icb->interrupt_delay_timer; in qla24xx_nvram_config()
7466 while (cnt--) in qla24xx_nvram_config()
7468 ha->frame_payload_size = le16_to_cpu(icb->frame_payload_size); in qla24xx_nvram_config()
7472 qla2x00_set_model_info(vha, nv->model_name, sizeof(nv->model_name), in qla24xx_nvram_config()
7477 if (nv->host_p & cpu_to_le32(BIT_15)) { in qla24xx_nvram_config()
7479 memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); in qla24xx_nvram_config()
7480 memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); in qla24xx_nvram_config()
7484 if ((icb->firmware_options_1 & cpu_to_le32(BIT_14)) == 0) { in qla24xx_nvram_config()
7489 memcpy(icb->node_name, icb->port_name, WWN_SIZE); in qla24xx_nvram_config()
7490 icb->node_name[0] &= 0xF0; in qla24xx_nvram_config()
7494 ha->flags.disable_risc_code_load = 0; in qla24xx_nvram_config()
7495 ha->flags.enable_lip_reset = 0; in qla24xx_nvram_config()
7496 ha->flags.enable_lip_full_login = in qla24xx_nvram_config()
7497 le32_to_cpu(nv->host_p) & BIT_10 ? 1 : 0; in qla24xx_nvram_config()
7498 ha->flags.enable_target_reset = in qla24xx_nvram_config()
7499 le32_to_cpu(nv->host_p) & BIT_11 ? 1 : 0; in qla24xx_nvram_config()
7500 ha->flags.enable_led_scheme = 0; in qla24xx_nvram_config()
7501 ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1 : 0; in qla24xx_nvram_config()
7503 ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) & in qla24xx_nvram_config()
7506 memcpy(ha->fw_seriallink_options24, nv->seriallink_options, in qla24xx_nvram_config()
7507 sizeof(ha->fw_seriallink_options24)); in qla24xx_nvram_config()
7510 ha->serial0 = icb->port_name[5]; in qla24xx_nvram_config()
7511 ha->serial1 = icb->port_name[6]; in qla24xx_nvram_config()
7512 ha->serial2 = icb->port_name[7]; in qla24xx_nvram_config()
7513 memcpy(vha->node_name, icb->node_name, WWN_SIZE); in qla24xx_nvram_config()
7514 memcpy(vha->port_name, icb->port_name, WWN_SIZE); in qla24xx_nvram_config()
7516 icb->execution_throttle = cpu_to_le16(0xFFFF); in qla24xx_nvram_config()
7518 ha->retry_count = le16_to_cpu(nv->login_retry_count); in qla24xx_nvram_config()
7521 if (le16_to_cpu(nv->login_timeout) < ql2xlogintimeout) in qla24xx_nvram_config()
7522 nv->login_timeout = cpu_to_le16(ql2xlogintimeout); in qla24xx_nvram_config()
7523 if (le16_to_cpu(nv->login_timeout) < 4) in qla24xx_nvram_config()
7524 nv->login_timeout = cpu_to_le16(4); in qla24xx_nvram_config()
7525 ha->login_timeout = le16_to_cpu(nv->login_timeout); in qla24xx_nvram_config()
7528 ha->r_a_tov = 100; in qla24xx_nvram_config()
7530 ha->loop_reset_delay = nv->reset_delay; in qla24xx_nvram_config()
7542 if (le16_to_cpu(nv->link_down_timeout) == 0) { in qla24xx_nvram_config()
7543 ha->loop_down_abort_time = in qla24xx_nvram_config()
7544 (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); in qla24xx_nvram_config()
7546 ha->link_down_timeout = le16_to_cpu(nv->link_down_timeout); in qla24xx_nvram_config()
7547 ha->loop_down_abort_time = in qla24xx_nvram_config()
7548 (LOOP_DOWN_TIME - ha->link_down_timeout); in qla24xx_nvram_config()
7552 ha->port_down_retry_count = le16_to_cpu(nv->port_down_retry_count); in qla24xx_nvram_config()
7554 ha->port_down_retry_count = qlport_down_retry; in qla24xx_nvram_config()
7557 ha->login_retry_count = le16_to_cpu(nv->login_retry_count); in qla24xx_nvram_config()
7558 if (ha->port_down_retry_count == in qla24xx_nvram_config()
7559 le16_to_cpu(nv->port_down_retry_count) && in qla24xx_nvram_config()
7560 ha->port_down_retry_count > 3) in qla24xx_nvram_config()
7561 ha->login_retry_count = ha->port_down_retry_count; in qla24xx_nvram_config()
7562 else if (ha->port_down_retry_count > (int)ha->login_retry_count) in qla24xx_nvram_config()
7563 ha->login_retry_count = ha->port_down_retry_count; in qla24xx_nvram_config()
7565 ha->login_retry_count = ql2xloginretrycount; in qla24xx_nvram_config()
7568 icb->firmware_options_3 |= cpu_to_le32(BIT_8); in qla24xx_nvram_config()
7571 if (!vha->flags.init_done) { in qla24xx_nvram_config()
7572 ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & in qla24xx_nvram_config()
7574 ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? in qla24xx_nvram_config()
7575 le16_to_cpu(icb->interrupt_delay_timer) : 2; in qla24xx_nvram_config()
7577 icb->firmware_options_2 &= cpu_to_le32( in qla24xx_nvram_config()
7579 if (ha->zio_mode != QLA_ZIO_DISABLED) { in qla24xx_nvram_config()
7580 ha->zio_mode = QLA_ZIO_MODE_6; in qla24xx_nvram_config()
7584 ha->zio_mode, ha->zio_timer * 100); in qla24xx_nvram_config()
7586 icb->firmware_options_2 |= cpu_to_le32( in qla24xx_nvram_config()
7587 (uint32_t)ha->zio_mode); in qla24xx_nvram_config()
7588 icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer); in qla24xx_nvram_config()
7605 image_status->image_status_mask, in qla27xx_print_image()
7606 le16_to_cpu(image_status->generation), in qla27xx_print_image()
7607 image_status->ver_major, in qla27xx_print_image()
7608 image_status->ver_minor, in qla27xx_print_image()
7609 image_status->bitmap, in qla27xx_print_image()
7610 le32_to_cpu(image_status->checksum), in qla27xx_print_image()
7611 le32_to_cpu(image_status->signature)); in qla27xx_print_image()
7618 ulong signature = le32_to_cpu(image_status->signature); in qla28xx_check_aux_image_status_signature()
7626 ulong signature = le32_to_cpu(image_status->signature); in qla27xx_check_image_status_signature()
7640 for ( ; n--; p++) in qla27xx_image_status_checksum()
7649 return aux->bitmap & bitmask ? in qla28xx_component_bitmask()
7657 active_regions->aux.board_config = in qla28xx_component_status()
7660 active_regions->aux.vpd_nvram = in qla28xx_component_status()
7663 active_regions->aux.npiv_config_0_1 = in qla28xx_component_status()
7666 active_regions->aux.npiv_config_2_3 = in qla28xx_component_status()
7677 le16_to_cpu(pri_image_status->generation) - in qla27xx_compare_image_generation()
7678 le16_to_cpu(sec_image_status->generation); in qla27xx_compare_image_generation()
7689 struct qla_hw_data *ha = vha->hw; in qla28xx_get_aux_images()
7694 if (!ha->flt_region_aux_img_status_pri) { in qla28xx_get_aux_images()
7700 ha->flt_region_aux_img_status_pri, in qla28xx_get_aux_images()
7726 if (!ha->flt_region_aux_img_status_sec) { in qla28xx_get_aux_images()
7733 ha->flt_region_aux_img_status_sec, in qla28xx_get_aux_images()
7777 active_regions->aux.board_config, in qla28xx_get_aux_images()
7778 active_regions->aux.vpd_nvram, in qla28xx_get_aux_images()
7779 active_regions->aux.npiv_config_0_1, in qla28xx_get_aux_images()
7780 active_regions->aux.npiv_config_2_3); in qla28xx_get_aux_images()
7787 struct qla_hw_data *ha = vha->hw; in qla27xx_get_active_image()
7792 if (!ha->flt_region_img_status_pri) { in qla27xx_get_active_image()
7798 ha->flt_region_img_status_pri, sizeof(pri_image_status) >> 2) != in qla27xx_get_active_image()
7827 if (!ha->flt_region_img_status_sec) { in qla27xx_get_active_image()
7833 ha->flt_region_img_status_sec, sizeof(sec_image_status) >> 2); in qla27xx_get_active_image()
7859 active_regions->global = QLA27XX_PRIMARY_IMAGE; in qla27xx_get_active_image()
7862 if (!active_regions->global || in qla27xx_get_active_image()
7865 active_regions->global = QLA27XX_SECONDARY_IMAGE; in qla27xx_get_active_image()
7870 active_regions->global == QLA27XX_DEFAULT_IMAGE ? in qla27xx_get_active_image()
7872 active_regions->global == QLA27XX_PRIMARY_IMAGE ? in qla27xx_get_active_image()
7874 active_regions->global == QLA27XX_SECONDARY_IMAGE ? in qla27xx_get_active_image()
7876 active_regions->global); in qla27xx_get_active_image()
7897 struct qla_hw_data *ha = vha->hw; in qla24xx_load_risc_flash()
7898 struct req_que *req = ha->req_q_map[0]; in qla24xx_load_risc_flash()
7899 struct fwdt *fwdt = ha->fwdt; in qla24xx_load_risc_flash()
7904 dcode = (uint32_t *)req->ring; in qla24xx_load_risc_flash()
7917 dcode = (uint32_t *)req->ring; in qla24xx_load_risc_flash()
7922 "-> Loading segment %u...\n", j); in qla24xx_load_risc_flash()
7931 dlen = ha->fw_transfer_size >> 2; in qla24xx_load_risc_flash()
7937 "-> Loading fragment %u: %#x <- %#x (%#lx dwords)...\n", in qla24xx_load_risc_flash()
7943 rval = qla2x00_load_ram(vha, req->dma, risc_addr, dlen); in qla24xx_load_risc_flash()
7946 "-> Failed load firmware fragment %u.\n", in qla24xx_load_risc_flash()
7953 risc_size -= dlen; in qla24xx_load_risc_flash()
7961 ql_dbg(ql_dbg_init, vha, 0x0160, "-> templates = %u\n", templates); in qla24xx_load_risc_flash()
7963 if (fwdt->template) in qla24xx_load_risc_flash()
7964 vfree(fwdt->template); in qla24xx_load_risc_flash()
7965 fwdt->template = NULL; in qla24xx_load_risc_flash()
7966 fwdt->length = 0; in qla24xx_load_risc_flash()
7968 dcode = (uint32_t *)req->ring; in qla24xx_load_risc_flash()
7972 "-> fwdt%u template array at %#x (%#x dwords)\n", in qla24xx_load_risc_flash()
7976 "-> fwdt%u failed to read array\n", j); in qla24xx_load_risc_flash()
7982 risc_size -= 8; in qla24xx_load_risc_flash()
7985 "-> fwdt%u template allocate template %#x words...\n", in qla24xx_load_risc_flash()
7987 fwdt->template = vmalloc(risc_size * sizeof(*dcode)); in qla24xx_load_risc_flash()
7988 if (!fwdt->template) { in qla24xx_load_risc_flash()
7990 "-> fwdt%u failed allocate template.\n", j); in qla24xx_load_risc_flash()
7994 dcode = fwdt->template; in qla24xx_load_risc_flash()
7999 "-> fwdt%u failed template validate\n", j); in qla24xx_load_risc_flash()
8005 "-> fwdt%u template size %#lx bytes (%#lx words)\n", in qla24xx_load_risc_flash()
8009 "-> fwdt%u template exceeds array (%-lu bytes)\n", in qla24xx_load_risc_flash()
8010 j, dlen - risc_size * sizeof(*dcode)); in qla24xx_load_risc_flash()
8014 fwdt->length = dlen; in qla24xx_load_risc_flash()
8016 "-> fwdt%u loaded template ok\n", j); in qla24xx_load_risc_flash()
8024 if (fwdt->template) in qla24xx_load_risc_flash()
8025 vfree(fwdt->template); in qla24xx_load_risc_flash()
8026 fwdt->template = NULL; in qla24xx_load_risc_flash()
8027 fwdt->length = 0; in qla24xx_load_risc_flash()
8043 struct qla_hw_data *ha = vha->hw; in qla2x00_load_risc()
8044 struct req_que *req = ha->req_q_map[0]; in qla2x00_load_risc()
8058 wcode = (uint16_t *)req->ring; in qla2x00_load_risc()
8060 fwcode = (__force __be16 *)blob->fw->data; in qla2x00_load_risc()
8064 if (blob->fw->size < 8 * sizeof(uint16_t)) { in qla2x00_load_risc()
8067 blob->fw->size); in qla2x00_load_risc()
8083 seg = blob->segs; in qla2x00_load_risc()
8091 if (blob->fw->size < fwclen) { in qla2x00_load_risc()
8094 "(%zd).\n", blob->fw->size); in qla2x00_load_risc()
8100 wlen = (uint16_t)(ha->fw_transfer_size >> 1); in qla2x00_load_risc()
8110 rval = qla2x00_load_ram(vha, req->dma, risc_addr, in qla2x00_load_risc()
8121 risc_size -= wlen; in qla2x00_load_risc()
8146 struct qla_hw_data *ha = vha->hw; in qla24xx_load_risc_blob()
8147 struct req_que *req = ha->req_q_map[0]; in qla24xx_load_risc_blob()
8148 struct fwdt *fwdt = ha->fwdt; in qla24xx_load_risc_blob()
8151 "-> FW: Loading via request-firmware.\n"); in qla24xx_load_risc_blob()
8156 "-> Firmware file not found.\n"); in qla24xx_load_risc_blob()
8161 fwcode = (__force __be32 *)blob->fw->data; in qla24xx_load_risc_blob()
8166 blob->fw->size); in qla24xx_load_risc_blob()
8173 dcode = (uint32_t *)req->ring; in qla24xx_load_risc_blob()
8178 "-> Loading segment %u...\n", j); in qla24xx_load_risc_blob()
8187 dlen = ha->fw_transfer_size >> 2; in qla24xx_load_risc_blob()
8193 "-> Loading fragment %u: %#x <- %#x (%#lx words)...\n", in qla24xx_load_risc_blob()
8195 (uint32_t)(fwcode - (typeof(fwcode))blob->fw->data), in qla24xx_load_risc_blob()
8201 rval = qla2x00_load_ram(vha, req->dma, risc_addr, dlen); in qla24xx_load_risc_blob()
8204 "-> Failed load firmware fragment %u.\n", in qla24xx_load_risc_blob()
8211 risc_size -= dlen; in qla24xx_load_risc_blob()
8219 ql_dbg(ql_dbg_init, vha, 0x0170, "-> templates = %u\n", templates); in qla24xx_load_risc_blob()
8221 if (fwdt->template) in qla24xx_load_risc_blob()
8222 vfree(fwdt->template); in qla24xx_load_risc_blob()
8223 fwdt->template = NULL; in qla24xx_load_risc_blob()
8224 fwdt->length = 0; in qla24xx_load_risc_blob()
8228 "-> fwdt%u template array at %#x (%#x dwords)\n", in qla24xx_load_risc_blob()
8229 j, (uint32_t)((void *)fwcode - (void *)blob->fw->data), in qla24xx_load_risc_blob()
8233 "-> fwdt%u failed to read array\n", j); in qla24xx_load_risc_blob()
8239 risc_size -= 8; in qla24xx_load_risc_blob()
8242 "-> fwdt%u template allocate template %#x words...\n", in qla24xx_load_risc_blob()
8244 fwdt->template = vmalloc(risc_size * sizeof(*dcode)); in qla24xx_load_risc_blob()
8245 if (!fwdt->template) { in qla24xx_load_risc_blob()
8247 "-> fwdt%u failed allocate template.\n", j); in qla24xx_load_risc_blob()
8251 dcode = fwdt->template; in qla24xx_load_risc_blob()
8257 "-> fwdt%u failed template validate\n", j); in qla24xx_load_risc_blob()
8263 "-> fwdt%u template size %#lx bytes (%#lx words)\n", in qla24xx_load_risc_blob()
8267 "-> fwdt%u template exceeds array (%-lu bytes)\n", in qla24xx_load_risc_blob()
8268 j, dlen - risc_size * sizeof(*dcode)); in qla24xx_load_risc_blob()
8272 fwdt->length = dlen; in qla24xx_load_risc_blob()
8274 "-> fwdt%u loaded template ok\n", j); in qla24xx_load_risc_blob()
8282 if (fwdt->template) in qla24xx_load_risc_blob()
8283 vfree(fwdt->template); in qla24xx_load_risc_blob()
8284 fwdt->template = NULL; in qla24xx_load_risc_blob()
8285 fwdt->length = 0; in qla24xx_load_risc_blob()
8300 * 1) Firmware via request-firmware interface (.bin file). in qla24xx_load_risc()
8308 vha->hw->flt_region_fw); in qla24xx_load_risc()
8315 struct qla_hw_data *ha = vha->hw; in qla81xx_load_risc()
8323 * 2) Firmware via request-firmware interface (.bin file). in qla81xx_load_risc()
8324 * 3) Golden-Firmware residing in flash -- (limited operation). in qla81xx_load_risc()
8337 rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_fw_sec); in qla81xx_load_risc()
8344 rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_fw); in qla81xx_load_risc()
8350 if (!rval || !ha->flt_region_gold_fw) in qla81xx_load_risc()
8355 rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_gold_fw); in qla81xx_load_risc()
8360 ha->flags.running_gold_fw = 1; in qla81xx_load_risc()
8368 struct qla_hw_data *ha = vha->hw; in qla2x00_try_to_stop_firmware()
8370 if (ha->flags.pci_channel_io_perm_failure) in qla2x00_try_to_stop_firmware()
8374 if (!ha->fw_major_version) in qla2x00_try_to_stop_firmware()
8376 if (!ha->flags.fw_started) in qla2x00_try_to_stop_firmware()
8381 ret != QLA_INVALID_COMMAND && retries ; retries--) { in qla2x00_try_to_stop_firmware()
8382 ha->isp_ops->reset_chip(vha); in qla2x00_try_to_stop_firmware()
8383 if (ha->isp_ops->chip_diag(vha) != QLA_SUCCESS) in qla2x00_try_to_stop_firmware()
8388 "Attempting retry of stop-firmware command.\n"); in qla2x00_try_to_stop_firmware()
8393 ha->flags.fw_init_done = 0; in qla2x00_try_to_stop_firmware()
8402 struct qla_hw_data *ha = vha->hw; in qla24xx_configure_vhba()
8403 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); in qla24xx_configure_vhba()
8405 if (!vha->vp_idx) in qla24xx_configure_vhba()
8406 return -EINVAL; in qla24xx_configure_vhba()
8411 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla24xx_configure_vhba()
8412 qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL); in qla24xx_configure_vhba()
8415 vha->flags.management_server_logged_in = 0; in qla24xx_configure_vhba()
8418 rval2 = ha->isp_ops->fabric_login(vha, NPH_SNS, 0xff, 0xff, 0xfc, mb, in qla24xx_configure_vhba()
8433 atomic_set(&vha->loop_down_timer, 0); in qla24xx_configure_vhba()
8434 atomic_set(&vha->loop_state, LOOP_UP); in qla24xx_configure_vhba()
8435 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla24xx_configure_vhba()
8436 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla24xx_configure_vhba()
8451 struct qla_hw_data *ha = vha->hw; in qla84xx_get_chip()
8457 if (cs84xx->bus == ha->pdev->bus) { in qla84xx_get_chip()
8458 kref_get(&cs84xx->kref); in qla84xx_get_chip()
8467 kref_init(&cs84xx->kref); in qla84xx_get_chip()
8468 spin_lock_init(&cs84xx->access_lock); in qla84xx_get_chip()
8469 mutex_init(&cs84xx->fw_update_mutex); in qla84xx_get_chip()
8470 cs84xx->bus = ha->pdev->bus; in qla84xx_get_chip()
8472 list_add_tail(&cs84xx->list, &qla_cs84xx_list); in qla84xx_get_chip()
8485 list_del(&cs84xx->list); in __qla84xx_chip_release()
8493 struct qla_hw_data *ha = vha->hw; in qla84xx_put_chip()
8495 if (ha->cs84xx) in qla84xx_put_chip()
8496 kref_put(&ha->cs84xx->kref, __qla84xx_chip_release); in qla84xx_put_chip()
8504 struct qla_hw_data *ha = vha->hw; in qla84xx_init_chip()
8506 mutex_lock(&ha->cs84xx->fw_update_mutex); in qla84xx_init_chip()
8510 mutex_unlock(&ha->cs84xx->fw_update_mutex); in qla84xx_init_chip()
8528 struct qla_hw_data *ha = vha->hw; in qla81xx_nvram_config()
8533 icb = (struct init_cb_81xx *)ha->init_cb; in qla81xx_nvram_config()
8534 nv = ha->nvram; in qla81xx_nvram_config()
8537 ha->nvram_size = sizeof(*nv); in qla81xx_nvram_config()
8538 ha->vpd_size = FA_NVRAM_VPD_SIZE; in qla81xx_nvram_config()
8540 ha->vpd_size = FA_VPD_SIZE_82XX; in qla81xx_nvram_config()
8546 ha->vpd = ha->nvram + VPD_OFFSET; in qla81xx_nvram_config()
8548 faddr = ha->flt_region_vpd; in qla81xx_nvram_config()
8551 faddr = ha->flt_region_vpd_sec; in qla81xx_nvram_config()
8557 ha->isp_ops->read_optrom(vha, ha->vpd, faddr << 2, ha->vpd_size); in qla81xx_nvram_config()
8560 faddr = ha->flt_region_nvram; in qla81xx_nvram_config()
8563 faddr = ha->flt_region_nvram_sec; in qla81xx_nvram_config()
8569 ha->isp_ops->read_optrom(vha, ha->nvram, faddr << 2, ha->nvram_size); in qla81xx_nvram_config()
8572 for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++, dptr++) in qla81xx_nvram_config()
8578 nv, ha->nvram_size); in qla81xx_nvram_config()
8581 if (chksum || memcmp("ISP ", nv->id, sizeof(nv->id)) || in qla81xx_nvram_config()
8582 le16_to_cpu(nv->nvram_version) < ICB_VERSION) { in qla81xx_nvram_config()
8586 chksum, nv->id, le16_to_cpu(nv->nvram_version)); in qla81xx_nvram_config()
8589 "Falling back to functioning (yet invalid -- WWPN) " in qla81xx_nvram_config()
8595 memset(nv, 0, ha->nvram_size); in qla81xx_nvram_config()
8596 nv->nvram_version = cpu_to_le16(ICB_VERSION); in qla81xx_nvram_config()
8597 nv->version = cpu_to_le16(ICB_VERSION); in qla81xx_nvram_config()
8598 nv->frame_payload_size = cpu_to_le16(2048); in qla81xx_nvram_config()
8599 nv->execution_throttle = cpu_to_le16(0xFFFF); in qla81xx_nvram_config()
8600 nv->exchange_count = cpu_to_le16(0); in qla81xx_nvram_config()
8601 nv->port_name[0] = 0x21; in qla81xx_nvram_config()
8602 nv->port_name[1] = 0x00 + ha->port_no + 1; in qla81xx_nvram_config()
8603 nv->port_name[2] = 0x00; in qla81xx_nvram_config()
8604 nv->port_name[3] = 0xe0; in qla81xx_nvram_config()
8605 nv->port_name[4] = 0x8b; in qla81xx_nvram_config()
8606 nv->port_name[5] = 0x1c; in qla81xx_nvram_config()
8607 nv->port_name[6] = 0x55; in qla81xx_nvram_config()
8608 nv->port_name[7] = 0x86; in qla81xx_nvram_config()
8609 nv->node_name[0] = 0x20; in qla81xx_nvram_config()
8610 nv->node_name[1] = 0x00; in qla81xx_nvram_config()
8611 nv->node_name[2] = 0x00; in qla81xx_nvram_config()
8612 nv->node_name[3] = 0xe0; in qla81xx_nvram_config()
8613 nv->node_name[4] = 0x8b; in qla81xx_nvram_config()
8614 nv->node_name[5] = 0x1c; in qla81xx_nvram_config()
8615 nv->node_name[6] = 0x55; in qla81xx_nvram_config()
8616 nv->node_name[7] = 0x86; in qla81xx_nvram_config()
8617 nv->login_retry_count = cpu_to_le16(8); in qla81xx_nvram_config()
8618 nv->interrupt_delay_timer = cpu_to_le16(0); in qla81xx_nvram_config()
8619 nv->login_timeout = cpu_to_le16(0); in qla81xx_nvram_config()
8620 nv->firmware_options_1 = in qla81xx_nvram_config()
8622 nv->firmware_options_2 = cpu_to_le32(2 << 4); in qla81xx_nvram_config()
8623 nv->firmware_options_2 |= cpu_to_le32(BIT_12); in qla81xx_nvram_config()
8624 nv->firmware_options_3 = cpu_to_le32(2 << 13); in qla81xx_nvram_config()
8625 nv->host_p = cpu_to_le32(BIT_11|BIT_10); in qla81xx_nvram_config()
8626 nv->efi_parameters = cpu_to_le32(0); in qla81xx_nvram_config()
8627 nv->reset_delay = 5; in qla81xx_nvram_config()
8628 nv->max_luns_per_target = cpu_to_le16(128); in qla81xx_nvram_config()
8629 nv->port_down_retry_count = cpu_to_le16(30); in qla81xx_nvram_config()
8630 nv->link_down_timeout = cpu_to_le16(180); in qla81xx_nvram_config()
8631 nv->enode_mac[0] = 0x00; in qla81xx_nvram_config()
8632 nv->enode_mac[1] = 0xC0; in qla81xx_nvram_config()
8633 nv->enode_mac[2] = 0xDD; in qla81xx_nvram_config()
8634 nv->enode_mac[3] = 0x04; in qla81xx_nvram_config()
8635 nv->enode_mac[4] = 0x05; in qla81xx_nvram_config()
8636 nv->enode_mac[5] = 0x06 + ha->port_no + 1; in qla81xx_nvram_config()
8642 nv->frame_payload_size &= cpu_to_le16(~7); in qla81xx_nvram_config()
8647 memset(icb, 0, ha->init_cb_size); in qla81xx_nvram_config()
8651 dptr2 = (uint8_t *)&nv->version; in qla81xx_nvram_config()
8652 cnt = (uint8_t *)&icb->response_q_inpointer - (uint8_t *)&icb->version; in qla81xx_nvram_config()
8653 while (cnt--) in qla81xx_nvram_config()
8656 icb->login_retry_count = nv->login_retry_count; in qla81xx_nvram_config()
8659 dptr1 = (uint8_t *)&icb->interrupt_delay_timer; in qla81xx_nvram_config()
8660 dptr2 = (uint8_t *)&nv->interrupt_delay_timer; in qla81xx_nvram_config()
8661 cnt = (uint8_t *)&icb->reserved_5 - in qla81xx_nvram_config()
8662 (uint8_t *)&icb->interrupt_delay_timer; in qla81xx_nvram_config()
8663 while (cnt--) in qla81xx_nvram_config()
8666 memcpy(icb->enode_mac, nv->enode_mac, sizeof(icb->enode_mac)); in qla81xx_nvram_config()
8668 if (!memcmp(icb->enode_mac, "\0\0\0\0\0\0", sizeof(icb->enode_mac))) { in qla81xx_nvram_config()
8669 icb->enode_mac[0] = 0x00; in qla81xx_nvram_config()
8670 icb->enode_mac[1] = 0xC0; in qla81xx_nvram_config()
8671 icb->enode_mac[2] = 0xDD; in qla81xx_nvram_config()
8672 icb->enode_mac[3] = 0x04; in qla81xx_nvram_config()
8673 icb->enode_mac[4] = 0x05; in qla81xx_nvram_config()
8674 icb->enode_mac[5] = 0x06 + ha->port_no + 1; in qla81xx_nvram_config()
8677 /* Use extended-initialization control block. */ in qla81xx_nvram_config()
8678 memcpy(ha->ex_init_cb, &nv->ex_version, sizeof(*ha->ex_init_cb)); in qla81xx_nvram_config()
8679 ha->frame_payload_size = le16_to_cpu(icb->frame_payload_size); in qla81xx_nvram_config()
8683 qla2x00_set_model_info(vha, nv->model_name, sizeof(nv->model_name), in qla81xx_nvram_config()
8689 if (nv->host_p & cpu_to_le32(BIT_15)) { in qla81xx_nvram_config()
8690 memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); in qla81xx_nvram_config()
8691 memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); in qla81xx_nvram_config()
8695 if ((icb->firmware_options_1 & cpu_to_le32(BIT_14)) == 0) { in qla81xx_nvram_config()
8700 memcpy(icb->node_name, icb->port_name, WWN_SIZE); in qla81xx_nvram_config()
8701 icb->node_name[0] &= 0xF0; in qla81xx_nvram_config()
8705 if ((nv->enhanced_features & BIT_7) == 0) in qla81xx_nvram_config()
8706 ha->flags.scm_supported_a = 1; in qla81xx_nvram_config()
8710 ha->flags.disable_risc_code_load = 0; in qla81xx_nvram_config()
8711 ha->flags.enable_lip_reset = 0; in qla81xx_nvram_config()
8712 ha->flags.enable_lip_full_login = in qla81xx_nvram_config()
8713 le32_to_cpu(nv->host_p) & BIT_10 ? 1 : 0; in qla81xx_nvram_config()
8714 ha->flags.enable_target_reset = in qla81xx_nvram_config()
8715 le32_to_cpu(nv->host_p) & BIT_11 ? 1 : 0; in qla81xx_nvram_config()
8716 ha->flags.enable_led_scheme = 0; in qla81xx_nvram_config()
8717 ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1 : 0; in qla81xx_nvram_config()
8719 ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) & in qla81xx_nvram_config()
8723 ha->serial0 = icb->port_name[5]; in qla81xx_nvram_config()
8724 ha->serial1 = icb->port_name[6]; in qla81xx_nvram_config()
8725 ha->serial2 = icb->port_name[7]; in qla81xx_nvram_config()
8726 memcpy(vha->node_name, icb->node_name, WWN_SIZE); in qla81xx_nvram_config()
8727 memcpy(vha->port_name, icb->port_name, WWN_SIZE); in qla81xx_nvram_config()
8729 icb->execution_throttle = cpu_to_le16(0xFFFF); in qla81xx_nvram_config()
8731 ha->retry_count = le16_to_cpu(nv->login_retry_count); in qla81xx_nvram_config()
8734 if (le16_to_cpu(nv->login_timeout) < ql2xlogintimeout) in qla81xx_nvram_config()
8735 nv->login_timeout = cpu_to_le16(ql2xlogintimeout); in qla81xx_nvram_config()
8736 if (le16_to_cpu(nv->login_timeout) < 4) in qla81xx_nvram_config()
8737 nv->login_timeout = cpu_to_le16(4); in qla81xx_nvram_config()
8738 ha->login_timeout = le16_to_cpu(nv->login_timeout); in qla81xx_nvram_config()
8741 ha->r_a_tov = 100; in qla81xx_nvram_config()
8743 ha->loop_reset_delay = nv->reset_delay; in qla81xx_nvram_config()
8755 if (le16_to_cpu(nv->link_down_timeout) == 0) { in qla81xx_nvram_config()
8756 ha->loop_down_abort_time = in qla81xx_nvram_config()
8757 (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); in qla81xx_nvram_config()
8759 ha->link_down_timeout = le16_to_cpu(nv->link_down_timeout); in qla81xx_nvram_config()
8760 ha->loop_down_abort_time = in qla81xx_nvram_config()
8761 (LOOP_DOWN_TIME - ha->link_down_timeout); in qla81xx_nvram_config()
8765 ha->port_down_retry_count = le16_to_cpu(nv->port_down_retry_count); in qla81xx_nvram_config()
8767 ha->port_down_retry_count = qlport_down_retry; in qla81xx_nvram_config()
8770 ha->login_retry_count = le16_to_cpu(nv->login_retry_count); in qla81xx_nvram_config()
8771 if (ha->port_down_retry_count == in qla81xx_nvram_config()
8772 le16_to_cpu(nv->port_down_retry_count) && in qla81xx_nvram_config()
8773 ha->port_down_retry_count > 3) in qla81xx_nvram_config()
8774 ha->login_retry_count = ha->port_down_retry_count; in qla81xx_nvram_config()
8775 else if (ha->port_down_retry_count > (int)ha->login_retry_count) in qla81xx_nvram_config()
8776 ha->login_retry_count = ha->port_down_retry_count; in qla81xx_nvram_config()
8778 ha->login_retry_count = ql2xloginretrycount; in qla81xx_nvram_config()
8780 /* if not running MSI-X we need handshaking on interrupts */ in qla81xx_nvram_config()
8781 if (!vha->hw->flags.msix_enabled && in qla81xx_nvram_config()
8783 icb->firmware_options_2 |= cpu_to_le32(BIT_22); in qla81xx_nvram_config()
8786 if (!vha->flags.init_done) { in qla81xx_nvram_config()
8787 ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & in qla81xx_nvram_config()
8789 ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? in qla81xx_nvram_config()
8790 le16_to_cpu(icb->interrupt_delay_timer) : 2; in qla81xx_nvram_config()
8792 icb->firmware_options_2 &= cpu_to_le32( in qla81xx_nvram_config()
8794 vha->flags.process_response_queue = 0; in qla81xx_nvram_config()
8795 if (ha->zio_mode != QLA_ZIO_DISABLED) { in qla81xx_nvram_config()
8796 ha->zio_mode = QLA_ZIO_MODE_6; in qla81xx_nvram_config()
8800 ha->zio_mode, in qla81xx_nvram_config()
8801 ha->zio_timer * 100); in qla81xx_nvram_config()
8803 icb->firmware_options_2 |= cpu_to_le32( in qla81xx_nvram_config()
8804 (uint32_t)ha->zio_mode); in qla81xx_nvram_config()
8805 icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer); in qla81xx_nvram_config()
8806 vha->flags.process_response_queue = 1; in qla81xx_nvram_config()
8810 icb->firmware_options_3 |= cpu_to_le32(BIT_0); in qla81xx_nvram_config()
8813 icb->firmware_options_3 |= cpu_to_le32(BIT_8); in qla81xx_nvram_config()
8816 ha->fc4_type_priority = qla2xxx_get_fc4_priority(vha); in qla81xx_nvram_config()
8829 struct qla_hw_data *ha = vha->hw; in qla82xx_restart_isp()
8835 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla82xx_restart_isp()
8836 ha->flags.chip_reset_done = 1; in qla82xx_restart_isp()
8841 qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL); in qla82xx_restart_isp()
8842 vha->flags.online = 1; in qla82xx_restart_isp()
8843 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla82xx_restart_isp()
8847 if ((vha->device_flags & DFLG_NO_CABLE)) in qla82xx_restart_isp()
8852 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla82xx_restart_isp()
8854 if (!atomic_read(&vha->loop_down_timer)) { in qla82xx_restart_isp()
8859 vha->marker_needed = 1; in qla82xx_restart_isp()
8862 ha->isp_ops->enable_intrs(ha); in qla82xx_restart_isp()
8864 ha->isp_abort_cnt = 0; in qla82xx_restart_isp()
8865 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla82xx_restart_isp()
8870 if (ha->fce) { in qla82xx_restart_isp()
8871 ha->flags.fce_enabled = 1; in qla82xx_restart_isp()
8872 memset(ha->fce, 0, in qla82xx_restart_isp()
8873 fce_calc_size(ha->fce_bufs)); in qla82xx_restart_isp()
8875 ha->fce_dma, ha->fce_bufs, ha->fce_mb, in qla82xx_restart_isp()
8876 &ha->fce_bufs); in qla82xx_restart_isp()
8881 ha->flags.fce_enabled = 0; in qla82xx_restart_isp()
8885 if (ha->eft) { in qla82xx_restart_isp()
8886 memset(ha->eft, 0, EFT_SIZE); in qla82xx_restart_isp()
8888 ha->eft_dma, EFT_NUM_BUFFERS); in qla82xx_restart_isp()
8901 spin_lock_irqsave(&ha->vport_slock, flags); in qla82xx_restart_isp()
8902 list_for_each_entry(vp, &ha->vp_list, list) { in qla82xx_restart_isp()
8903 if (vp->vp_idx) { in qla82xx_restart_isp()
8904 atomic_inc(&vp->vref_count); in qla82xx_restart_isp()
8905 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla82xx_restart_isp()
8909 spin_lock_irqsave(&ha->vport_slock, flags); in qla82xx_restart_isp()
8910 atomic_dec(&vp->vref_count); in qla82xx_restart_isp()
8913 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla82xx_restart_isp()
8935 * non-zero (if found)
8936 * -1 (if not found)
8950 struct qla_hw_data *ha = vha->hw; in qla24xx_get_fcp_prio()
8952 if (!ha->fcp_prio_cfg || !ha->flags.fcp_prio_enabled) in qla24xx_get_fcp_prio()
8953 return -1; in qla24xx_get_fcp_prio()
8955 priority = -1; in qla24xx_get_fcp_prio()
8956 entries = ha->fcp_prio_cfg->num_entries; in qla24xx_get_fcp_prio()
8957 pri_entry = &ha->fcp_prio_cfg->entry[0]; in qla24xx_get_fcp_prio()
8962 if (!(pri_entry->flags & FCP_PRIO_ENTRY_VALID)) { in qla24xx_get_fcp_prio()
8968 if (pri_entry->flags & FCP_PRIO_ENTRY_SPID_VALID) { in qla24xx_get_fcp_prio()
8969 pid1 = pri_entry->src_pid & INVALID_PORT_ID; in qla24xx_get_fcp_prio()
8970 pid2 = vha->d_id.b24 & INVALID_PORT_ID; in qla24xx_get_fcp_prio()
8978 if (pri_entry->flags & FCP_PRIO_ENTRY_DPID_VALID) { in qla24xx_get_fcp_prio()
8979 pid1 = pri_entry->dst_pid & INVALID_PORT_ID; in qla24xx_get_fcp_prio()
8980 pid2 = fcport->d_id.b24 & INVALID_PORT_ID; in qla24xx_get_fcp_prio()
8988 if (pri_entry->flags & FCP_PRIO_ENTRY_SWWN_VALID) { in qla24xx_get_fcp_prio()
8989 wwn1 = wwn_to_u64(vha->port_name); in qla24xx_get_fcp_prio()
8990 wwn2 = wwn_to_u64(pri_entry->src_wwpn); in qla24xx_get_fcp_prio()
8991 if (wwn2 == (uint64_t)-1) in qla24xx_get_fcp_prio()
8998 if (pri_entry->flags & FCP_PRIO_ENTRY_DWWN_VALID) { in qla24xx_get_fcp_prio()
8999 wwn1 = wwn_to_u64(fcport->port_name); in qla24xx_get_fcp_prio()
9000 wwn2 = wwn_to_u64(pri_entry->dst_wwpn); in qla24xx_get_fcp_prio()
9001 if (wwn2 == (uint64_t)-1) in qla24xx_get_fcp_prio()
9009 if (pri_entry->flags & FCP_PRIO_ENTRY_TAG_VALID) in qla24xx_get_fcp_prio()
9010 priority = pri_entry->tag; in qla24xx_get_fcp_prio()
9041 if (fcport->port_type != FCT_TARGET || in qla24xx_update_fcport_fcp_prio()
9042 fcport->loop_id == FC_NO_LOOP_ID) in qla24xx_update_fcport_fcp_prio()
9049 if (IS_P3P_TYPE(vha->hw)) { in qla24xx_update_fcport_fcp_prio()
9050 fcport->fcp_prio = priority & 0xf; in qla24xx_update_fcport_fcp_prio()
9054 ret = qla24xx_set_fcp_prio(vha, fcport->loop_id, priority, mb); in qla24xx_update_fcport_fcp_prio()
9056 if (fcport->fcp_prio != priority) in qla24xx_update_fcport_fcp_prio()
9058 "Updated FCP_CMND priority - value=%d loop_id=%d " in qla24xx_update_fcport_fcp_prio()
9060 fcport->loop_id, fcport->d_id.b.domain, in qla24xx_update_fcport_fcp_prio()
9061 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla24xx_update_fcport_fcp_prio()
9062 fcport->fcp_prio = priority & 0xf; in qla24xx_update_fcport_fcp_prio()
9065 "Unable to update FCP_CMND priority - ret=0x%x for " in qla24xx_update_fcport_fcp_prio()
9066 "loop_id=%d port_id=%02x%02x%02x.\n", ret, fcport->loop_id, in qla24xx_update_fcport_fcp_prio()
9067 fcport->d_id.b.domain, fcport->d_id.b.area, in qla24xx_update_fcport_fcp_prio()
9068 fcport->d_id.b.al_pa); in qla24xx_update_fcport_fcp_prio()
9093 list_for_each_entry(fcport, &vha->vp_fcports, list) in qla24xx_update_all_fcp_prio()
9105 struct qla_hw_data *ha = vha->hw; in qla2xxx_create_qpair()
9110 if (!(ha->fw_attributes & BIT_6) || !ha->flags.msix_enabled) { in qla2xxx_create_qpair()
9112 "FW/Driver is not multi-queue capable.\n"); in qla2xxx_create_qpair()
9120 "Failed to allocate memory for queue pair.\n"); in qla2xxx_create_qpair()
9124 qpair->hw = vha->hw; in qla2xxx_create_qpair()
9125 qpair->vha = vha; in qla2xxx_create_qpair()
9126 qpair->qp_lock_ptr = &qpair->qp_lock; in qla2xxx_create_qpair()
9127 spin_lock_init(&qpair->qp_lock); in qla2xxx_create_qpair()
9128 qpair->use_shadow_reg = IS_SHADOW_REG_CAPABLE(ha) ? 1 : 0; in qla2xxx_create_qpair()
9130 /* Assign available que pair id */ in qla2xxx_create_qpair()
9131 mutex_lock(&ha->mq_lock); in qla2xxx_create_qpair()
9132 qpair_id = find_first_zero_bit(ha->qpair_qid_map, ha->max_qpairs); in qla2xxx_create_qpair()
9133 if (ha->num_qpairs >= ha->max_qpairs) { in qla2xxx_create_qpair()
9134 mutex_unlock(&ha->mq_lock); in qla2xxx_create_qpair()
9136 "No resources to create additional q pair.\n"); in qla2xxx_create_qpair()
9139 ha->num_qpairs++; in qla2xxx_create_qpair()
9140 set_bit(qpair_id, ha->qpair_qid_map); in qla2xxx_create_qpair()
9141 ha->queue_pair_map[qpair_id] = qpair; in qla2xxx_create_qpair()
9142 qpair->id = qpair_id; in qla2xxx_create_qpair()
9143 qpair->vp_idx = vp_idx; in qla2xxx_create_qpair()
9144 qpair->fw_started = ha->flags.fw_started; in qla2xxx_create_qpair()
9145 INIT_LIST_HEAD(&qpair->hints_list); in qla2xxx_create_qpair()
9146 qpair->chip_reset = ha->base_qpair->chip_reset; in qla2xxx_create_qpair()
9147 qpair->enable_class_2 = ha->base_qpair->enable_class_2; in qla2xxx_create_qpair()
9148 qpair->enable_explicit_conf = in qla2xxx_create_qpair()
9149 ha->base_qpair->enable_explicit_conf; in qla2xxx_create_qpair()
9151 for (i = 0; i < ha->msix_count; i++) { in qla2xxx_create_qpair()
9152 msix = &ha->msix_entries[i]; in qla2xxx_create_qpair()
9153 if (msix->in_use) in qla2xxx_create_qpair()
9155 qpair->msix = msix; in qla2xxx_create_qpair()
9157 "Vector %x selected for qpair\n", msix->vector); in qla2xxx_create_qpair()
9160 if (!qpair->msix) { in qla2xxx_create_qpair()
9162 "Out of MSI-X vectors!.\n"); in qla2xxx_create_qpair()
9166 qpair->msix->in_use = 1; in qla2xxx_create_qpair()
9167 list_add_tail(&qpair->qp_list_elem, &vha->qp_list); in qla2xxx_create_qpair()
9168 qpair->pdev = ha->pdev; in qla2xxx_create_qpair()
9170 qpair->reqq_start_iocbs = qla_83xx_start_iocbs; in qla2xxx_create_qpair()
9172 mutex_unlock(&ha->mq_lock); in qla2xxx_create_qpair()
9182 qpair->rsp = ha->rsp_q_map[rsp_id]; in qla2xxx_create_qpair()
9193 qpair->req = ha->req_q_map[req_id]; in qla2xxx_create_qpair()
9194 qpair->rsp->req = qpair->req; in qla2xxx_create_qpair()
9195 qpair->rsp->qpair = qpair; in qla2xxx_create_qpair()
9200 if (ha->fw_attributes & BIT_4) in qla2xxx_create_qpair()
9201 qpair->difdix_supported = 1; in qla2xxx_create_qpair()
9204 qpair->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); in qla2xxx_create_qpair()
9205 if (!qpair->srb_mempool) { in qla2xxx_create_qpair()
9208 qpair->id); in qla2xxx_create_qpair()
9213 qpair->online = 1; in qla2xxx_create_qpair()
9215 if (!vha->flags.qpairs_available) in qla2xxx_create_qpair()
9216 vha->flags.qpairs_available = 1; in qla2xxx_create_qpair()
9219 "Request/Response queue pair created, id %d\n", in qla2xxx_create_qpair()
9220 qpair->id); in qla2xxx_create_qpair()
9222 "Request/Response queue pair created, id %d\n", in qla2xxx_create_qpair()
9223 qpair->id); in qla2xxx_create_qpair()
9229 qla25xx_delete_rsp_que(vha, qpair->rsp); in qla2xxx_create_qpair()
9231 mutex_lock(&ha->mq_lock); in qla2xxx_create_qpair()
9232 qpair->msix->in_use = 0; in qla2xxx_create_qpair()
9233 list_del(&qpair->qp_list_elem); in qla2xxx_create_qpair()
9234 if (list_empty(&vha->qp_list)) in qla2xxx_create_qpair()
9235 vha->flags.qpairs_available = 0; in qla2xxx_create_qpair()
9237 ha->queue_pair_map[qpair_id] = NULL; in qla2xxx_create_qpair()
9238 clear_bit(qpair_id, ha->qpair_qid_map); in qla2xxx_create_qpair()
9239 ha->num_qpairs--; in qla2xxx_create_qpair()
9240 mutex_unlock(&ha->mq_lock); in qla2xxx_create_qpair()
9249 struct qla_hw_data *ha = qpair->hw; in qla2xxx_delete_qpair()
9251 qpair->delete_in_progress = 1; in qla2xxx_delete_qpair()
9253 ret = qla25xx_delete_req_que(vha, qpair->req); in qla2xxx_delete_qpair()
9257 ret = qla25xx_delete_rsp_que(vha, qpair->rsp); in qla2xxx_delete_qpair()
9261 mutex_lock(&ha->mq_lock); in qla2xxx_delete_qpair()
9262 ha->queue_pair_map[qpair->id] = NULL; in qla2xxx_delete_qpair()
9263 clear_bit(qpair->id, ha->qpair_qid_map); in qla2xxx_delete_qpair()
9264 ha->num_qpairs--; in qla2xxx_delete_qpair()
9265 list_del(&qpair->qp_list_elem); in qla2xxx_delete_qpair()
9266 if (list_empty(&vha->qp_list)) { in qla2xxx_delete_qpair()
9267 vha->flags.qpairs_available = 0; in qla2xxx_delete_qpair()
9268 vha->flags.qpairs_req_created = 0; in qla2xxx_delete_qpair()
9269 vha->flags.qpairs_rsp_created = 0; in qla2xxx_delete_qpair()
9271 mempool_destroy(qpair->srb_mempool); in qla2xxx_delete_qpair()
9273 mutex_unlock(&ha->mq_lock); in qla2xxx_delete_qpair()