Lines Matching +full:rx +full:- +full:sched +full:- +full:sp
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (c) 2003-2014 QLogic Corporation
43 /* SRB Extensions ---------------------------------------------------------- */
48 srb_t *sp = from_timer(sp, t, u.iocb_cmd.timer); in qla2x00_sp_timeout() local
50 scsi_qla_host_t *vha = sp->vha; in qla2x00_sp_timeout()
53 iocb = &sp->u.iocb_cmd; in qla2x00_sp_timeout()
54 iocb->timeout(sp); in qla2x00_sp_timeout()
57 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla2x00_sp_timeout()
59 if (vha && qla2x00_isp_reg_stat(vha->hw)) { in qla2x00_sp_timeout()
66 void qla2x00_sp_free(srb_t *sp) in qla2x00_sp_free() argument
68 struct srb_iocb *iocb = &sp->u.iocb_cmd; in qla2x00_sp_free()
70 del_timer(&iocb->timer); in qla2x00_sp_free()
71 qla2x00_rel_sp(sp); in qla2x00_sp_free()
74 void qla2xxx_rel_done_warning(srb_t *sp, int res) in qla2xxx_rel_done_warning() argument
76 WARN_ONCE(1, "Calling done() of an already freed srb %p object\n", sp); in qla2xxx_rel_done_warning()
79 void qla2xxx_rel_free_warning(srb_t *sp) in qla2xxx_rel_free_warning() argument
81 WARN_ONCE(1, "Calling free() of an already freed srb %p object\n", sp); in qla2xxx_rel_free_warning()
84 /* Asynchronous Login/Logout Routines -------------------------------------- */
90 struct qla_hw_data *ha = vha->hw; in qla2x00_get_async_timeout()
93 tmo = ha->r_a_tov / 10 * 2; in qla2x00_get_async_timeout()
101 tmo = ha->login_timeout; in qla2x00_get_async_timeout()
108 srb_t *sp = data; in qla24xx_abort_iocb_timeout() local
109 struct srb_iocb *abt = &sp->u.iocb_cmd; in qla24xx_abort_iocb_timeout()
110 struct qla_qpair *qpair = sp->qpair; in qla24xx_abort_iocb_timeout()
114 if (sp->cmd_sp) in qla24xx_abort_iocb_timeout()
115 ql_dbg(ql_dbg_async, sp->vha, 0x507c, in qla24xx_abort_iocb_timeout()
116 "Abort timeout - cmd hdl=%x, cmd type=%x hdl=%x, type=%x\n", in qla24xx_abort_iocb_timeout()
117 sp->cmd_sp->handle, sp->cmd_sp->type, in qla24xx_abort_iocb_timeout()
118 sp->handle, sp->type); in qla24xx_abort_iocb_timeout()
120 ql_dbg(ql_dbg_async, sp->vha, 0x507c, in qla24xx_abort_iocb_timeout()
121 "Abort timeout 2 - hdl=%x, type=%x\n", in qla24xx_abort_iocb_timeout()
122 sp->handle, sp->type); in qla24xx_abort_iocb_timeout()
124 spin_lock_irqsave(qpair->qp_lock_ptr, flags); in qla24xx_abort_iocb_timeout()
125 for (handle = 1; handle < qpair->req->num_outstanding_cmds; handle++) { in qla24xx_abort_iocb_timeout()
126 if (sp->cmd_sp && (qpair->req->outstanding_cmds[handle] == in qla24xx_abort_iocb_timeout()
127 sp->cmd_sp)) in qla24xx_abort_iocb_timeout()
128 qpair->req->outstanding_cmds[handle] = NULL; in qla24xx_abort_iocb_timeout()
131 if (qpair->req->outstanding_cmds[handle] == sp) { in qla24xx_abort_iocb_timeout()
132 qpair->req->outstanding_cmds[handle] = NULL; in qla24xx_abort_iocb_timeout()
136 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qla24xx_abort_iocb_timeout()
138 if (sp->cmd_sp) { in qla24xx_abort_iocb_timeout()
143 sp->cmd_sp->done(sp->cmd_sp, QLA_OS_TIMER_EXPIRED); in qla24xx_abort_iocb_timeout()
146 abt->u.abt.comp_status = cpu_to_le16(CS_TIMEOUT); in qla24xx_abort_iocb_timeout()
147 sp->done(sp, QLA_OS_TIMER_EXPIRED); in qla24xx_abort_iocb_timeout()
150 static void qla24xx_abort_sp_done(srb_t *sp, int res) in qla24xx_abort_sp_done() argument
152 struct srb_iocb *abt = &sp->u.iocb_cmd; in qla24xx_abort_sp_done()
153 srb_t *orig_sp = sp->cmd_sp; in qla24xx_abort_sp_done()
158 if (sp->flags & SRB_WAKEUP_ON_COMP) in qla24xx_abort_sp_done()
159 complete(&abt->u.abt.comp); in qla24xx_abort_sp_done()
162 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla24xx_abort_sp_done()
167 scsi_qla_host_t *vha = cmd_sp->vha; in qla24xx_async_abort_cmd()
169 srb_t *sp; in qla24xx_async_abort_cmd() local
174 sp = qla2xxx_get_qpair_sp(cmd_sp->vha, cmd_sp->qpair, cmd_sp->fcport, in qla24xx_async_abort_cmd()
176 if (!sp) in qla24xx_async_abort_cmd()
180 abt_iocb = &sp->u.iocb_cmd; in qla24xx_async_abort_cmd()
181 sp->type = SRB_ABT_CMD; in qla24xx_async_abort_cmd()
182 sp->name = "abort"; in qla24xx_async_abort_cmd()
183 sp->qpair = cmd_sp->qpair; in qla24xx_async_abort_cmd()
184 sp->cmd_sp = cmd_sp; in qla24xx_async_abort_cmd()
186 sp->flags = SRB_WAKEUP_ON_COMP; in qla24xx_async_abort_cmd()
188 init_completion(&abt_iocb->u.abt.comp); in qla24xx_async_abort_cmd()
190 qla2x00_init_async_sp(sp, 42, qla24xx_abort_sp_done); in qla24xx_async_abort_cmd()
191 sp->u.iocb_cmd.timeout = qla24xx_abort_iocb_timeout; in qla24xx_async_abort_cmd()
193 abt_iocb->u.abt.cmd_hndl = cmd_sp->handle; in qla24xx_async_abort_cmd()
194 abt_iocb->u.abt.req_que_no = cpu_to_le16(cmd_sp->qpair->req->id); in qla24xx_async_abort_cmd()
197 "Abort command issued - hdl=%x, type=%x\n", cmd_sp->handle, in qla24xx_async_abort_cmd()
198 cmd_sp->type); in qla24xx_async_abort_cmd()
200 rval = qla2x00_start_sp(sp); in qla24xx_async_abort_cmd()
203 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla24xx_async_abort_cmd()
208 wait_for_completion(&abt_iocb->u.abt.comp); in qla24xx_async_abort_cmd()
209 rval = abt_iocb->u.abt.comp_status == CS_COMPLETE ? in qla24xx_async_abort_cmd()
212 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla24xx_async_abort_cmd()
221 srb_t *sp = data; in qla2x00_async_iocb_timeout() local
222 fc_port_t *fcport = sp->fcport; in qla2x00_async_iocb_timeout()
223 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_iocb_timeout()
228 ql_dbg(ql_dbg_disc, fcport->vha, 0x2071, in qla2x00_async_iocb_timeout()
229 "Async-%s timeout - hdl=%x portid=%06x %8phC.\n", in qla2x00_async_iocb_timeout()
230 sp->name, sp->handle, fcport->d_id.b24, fcport->port_name); in qla2x00_async_iocb_timeout()
232 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_iocb_timeout()
234 pr_info("Async-%s timeout - hdl=%x.\n", in qla2x00_async_iocb_timeout()
235 sp->name, sp->handle); in qla2x00_async_iocb_timeout()
238 switch (sp->type) { in qla2x00_async_iocb_timeout()
240 rc = qla24xx_async_abort_cmd(sp, false); in qla2x00_async_iocb_timeout()
243 lio->u.logio.data[0] = MBS_COMMAND_ERROR; in qla2x00_async_iocb_timeout()
244 lio->u.logio.data[1] = in qla2x00_async_iocb_timeout()
245 lio->u.logio.flags & SRB_LOGIN_RETRIED ? in qla2x00_async_iocb_timeout()
247 spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); in qla2x00_async_iocb_timeout()
248 for (h = 1; h < sp->qpair->req->num_outstanding_cmds; in qla2x00_async_iocb_timeout()
250 if (sp->qpair->req->outstanding_cmds[h] == in qla2x00_async_iocb_timeout()
251 sp) { in qla2x00_async_iocb_timeout()
252 sp->qpair->req->outstanding_cmds[h] = in qla2x00_async_iocb_timeout()
257 spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); in qla2x00_async_iocb_timeout()
258 sp->done(sp, QLA_FUNCTION_TIMEOUT); in qla2x00_async_iocb_timeout()
269 rc = qla24xx_async_abort_cmd(sp, false); in qla2x00_async_iocb_timeout()
271 spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); in qla2x00_async_iocb_timeout()
272 for (h = 1; h < sp->qpair->req->num_outstanding_cmds; in qla2x00_async_iocb_timeout()
274 if (sp->qpair->req->outstanding_cmds[h] == in qla2x00_async_iocb_timeout()
275 sp) { in qla2x00_async_iocb_timeout()
276 sp->qpair->req->outstanding_cmds[h] = in qla2x00_async_iocb_timeout()
281 spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); in qla2x00_async_iocb_timeout()
282 sp->done(sp, QLA_FUNCTION_TIMEOUT); in qla2x00_async_iocb_timeout()
288 static void qla2x00_async_login_sp_done(srb_t *sp, int res) in qla2x00_async_login_sp_done() argument
290 struct scsi_qla_host *vha = sp->vha; in qla2x00_async_login_sp_done()
291 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_login_sp_done()
295 "%s %8phC res %d \n", __func__, sp->fcport->port_name, res); in qla2x00_async_login_sp_done()
297 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_login_sp_done()
299 if (!test_bit(UNLOADING, &vha->dpc_flags)) { in qla2x00_async_login_sp_done()
301 ea.fcport = sp->fcport; in qla2x00_async_login_sp_done()
302 ea.data[0] = lio->u.logio.data[0]; in qla2x00_async_login_sp_done()
303 ea.data[1] = lio->u.logio.data[1]; in qla2x00_async_login_sp_done()
304 ea.iop[0] = lio->u.logio.iop[0]; in qla2x00_async_login_sp_done()
305 ea.iop[1] = lio->u.logio.iop[1]; in qla2x00_async_login_sp_done()
306 ea.sp = sp; in qla2x00_async_login_sp_done()
313 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla2x00_async_login_sp_done()
320 srb_t *sp; in qla2x00_async_login() local
324 if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT) || in qla2x00_async_login()
325 fcport->loop_id == FC_NO_LOOP_ID) { in qla2x00_async_login()
327 "%s: %8phC - not sending command.\n", in qla2x00_async_login()
328 __func__, fcport->port_name); in qla2x00_async_login()
333 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla2x00_async_login()
334 if (!sp) in qla2x00_async_login()
338 fcport->flags |= FCF_ASYNC_SENT; in qla2x00_async_login()
339 fcport->logout_completed = 0; in qla2x00_async_login()
341 sp->type = SRB_LOGIN_CMD; in qla2x00_async_login()
342 sp->name = "login"; in qla2x00_async_login()
343 sp->gen1 = fcport->rscn_gen; in qla2x00_async_login()
344 sp->gen2 = fcport->login_gen; in qla2x00_async_login()
345 qla2x00_init_async_sp(sp, qla2x00_get_async_timeout(vha) + 2, in qla2x00_async_login()
348 lio = &sp->u.iocb_cmd; in qla2x00_async_login()
349 if (N2N_TOPO(fcport->vha->hw) && fcport_is_bigger(fcport)) { in qla2x00_async_login()
350 lio->u.logio.flags |= SRB_LOGIN_PRLI_ONLY; in qla2x00_async_login()
352 if (vha->hw->flags.edif_enabled && in qla2x00_async_login()
354 lio->u.logio.flags |= in qla2x00_async_login()
357 lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI; in qla2x00_async_login()
361 if (NVME_TARGET(vha->hw, fcport)) in qla2x00_async_login()
362 lio->u.logio.flags |= SRB_LOGIN_SKIP_PRLI; in qla2x00_async_login()
364 rval = qla2x00_start_sp(sp); in qla2x00_async_login()
367 "Async-login - %8phC hdl=%x, loopid=%x portid=%06x retries=%d %s.\n", in qla2x00_async_login()
368 fcport->port_name, sp->handle, fcport->loop_id, in qla2x00_async_login()
369 fcport->d_id.b24, fcport->login_retry, in qla2x00_async_login()
370 lio->u.logio.flags & SRB_LOGIN_FCSP ? "FCSP" : ""); in qla2x00_async_login()
373 fcport->flags |= FCF_LOGIN_NEEDED; in qla2x00_async_login()
374 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla2x00_async_login()
382 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla2x00_async_login()
383 fcport->flags &= ~FCF_ASYNC_SENT; in qla2x00_async_login()
385 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla2x00_async_login()
389 static void qla2x00_async_logout_sp_done(srb_t *sp, int res) in qla2x00_async_logout_sp_done() argument
391 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_logout_sp_done()
392 sp->fcport->login_gen++; in qla2x00_async_logout_sp_done()
393 qlt_logo_completion_handler(sp->fcport, sp->u.iocb_cmd.u.logio.data[0]); in qla2x00_async_logout_sp_done()
395 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla2x00_async_logout_sp_done()
401 srb_t *sp; in qla2x00_async_logout() local
404 fcport->flags |= FCF_ASYNC_SENT; in qla2x00_async_logout()
406 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla2x00_async_logout()
407 if (!sp) in qla2x00_async_logout()
410 sp->type = SRB_LOGOUT_CMD; in qla2x00_async_logout()
411 sp->name = "logout"; in qla2x00_async_logout()
412 qla2x00_init_async_sp(sp, qla2x00_get_async_timeout(vha) + 2, in qla2x00_async_logout()
416 "Async-logout - hdl=%x loop-id=%x portid=%02x%02x%02x %8phC explicit %d.\n", in qla2x00_async_logout()
417 sp->handle, fcport->loop_id, fcport->d_id.b.domain, in qla2x00_async_logout()
418 fcport->d_id.b.area, fcport->d_id.b.al_pa, in qla2x00_async_logout()
419 fcport->port_name, fcport->explicit_logout); in qla2x00_async_logout()
421 rval = qla2x00_start_sp(sp); in qla2x00_async_logout()
428 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla2x00_async_logout()
430 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_logout()
438 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla2x00_async_prlo_done()
439 /* Don't re-login in target mode */ in qla2x00_async_prlo_done()
440 if (!fcport->tgt_session) in qla2x00_async_prlo_done()
445 static void qla2x00_async_prlo_sp_done(srb_t *sp, int res) in qla2x00_async_prlo_sp_done() argument
447 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_prlo_sp_done()
448 struct scsi_qla_host *vha = sp->vha; in qla2x00_async_prlo_sp_done()
450 sp->fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla2x00_async_prlo_sp_done()
451 if (!test_bit(UNLOADING, &vha->dpc_flags)) in qla2x00_async_prlo_sp_done()
452 qla2x00_post_async_prlo_done_work(sp->fcport->vha, sp->fcport, in qla2x00_async_prlo_sp_done()
453 lio->u.logio.data); in qla2x00_async_prlo_sp_done()
455 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla2x00_async_prlo_sp_done()
461 srb_t *sp; in qla2x00_async_prlo() local
466 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla2x00_async_prlo()
467 if (!sp) in qla2x00_async_prlo()
470 sp->type = SRB_PRLO_CMD; in qla2x00_async_prlo()
471 sp->name = "prlo"; in qla2x00_async_prlo()
472 qla2x00_init_async_sp(sp, qla2x00_get_async_timeout(vha) + 2, in qla2x00_async_prlo()
476 "Async-prlo - hdl=%x loop-id=%x portid=%02x%02x%02x.\n", in qla2x00_async_prlo()
477 sp->handle, fcport->loop_id, fcport->d_id.b.domain, in qla2x00_async_prlo()
478 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_async_prlo()
480 rval = qla2x00_start_sp(sp); in qla2x00_async_prlo()
488 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla2x00_async_prlo()
490 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla2x00_async_prlo()
497 struct fc_port *fcport = ea->fcport; in qla24xx_handle_adisc_event()
501 __func__, fcport->port_name, fcport->disc_state, in qla24xx_handle_adisc_event()
502 fcport->fw_login_state, ea->rc, fcport->login_gen, ea->sp->gen2, in qla24xx_handle_adisc_event()
503 fcport->rscn_gen, ea->sp->gen1, fcport->loop_id); in qla24xx_handle_adisc_event()
505 WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n", in qla24xx_handle_adisc_event()
506 ea->data[0]); in qla24xx_handle_adisc_event()
508 if (ea->data[0] != MBS_COMMAND_COMPLETE) { in qla24xx_handle_adisc_event()
511 __func__, ea->fcport->port_name); in qla24xx_handle_adisc_event()
513 fcport->deleted = 0; in qla24xx_handle_adisc_event()
514 fcport->logout_on_delete = 1; in qla24xx_handle_adisc_event()
515 qlt_schedule_sess_for_deletion(ea->fcport); in qla24xx_handle_adisc_event()
519 if (ea->fcport->disc_state == DSC_DELETE_PEND) in qla24xx_handle_adisc_event()
522 if (ea->sp->gen2 != ea->fcport->login_gen) { in qla24xx_handle_adisc_event()
526 __func__, ea->fcport->port_name); in qla24xx_handle_adisc_event()
528 } else if (ea->sp->gen1 != ea->fcport->rscn_gen) { in qla24xx_handle_adisc_event()
545 e->u.fcport.fcport = fcport; in qla_post_els_plogi_work()
546 fcport->flags |= FCF_ASYNC_ACTIVE; in qla_post_els_plogi_work()
551 static void qla2x00_async_adisc_sp_done(srb_t *sp, int res) in qla2x00_async_adisc_sp_done() argument
553 struct scsi_qla_host *vha = sp->vha; in qla2x00_async_adisc_sp_done()
555 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_adisc_sp_done()
558 "Async done-%s res %x %8phC\n", in qla2x00_async_adisc_sp_done()
559 sp->name, res, sp->fcport->port_name); in qla2x00_async_adisc_sp_done()
561 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_adisc_sp_done()
565 ea.data[0] = lio->u.logio.data[0]; in qla2x00_async_adisc_sp_done()
566 ea.data[1] = lio->u.logio.data[1]; in qla2x00_async_adisc_sp_done()
567 ea.iop[0] = lio->u.logio.iop[0]; in qla2x00_async_adisc_sp_done()
568 ea.iop[1] = lio->u.logio.iop[1]; in qla2x00_async_adisc_sp_done()
569 ea.fcport = sp->fcport; in qla2x00_async_adisc_sp_done()
570 ea.sp = sp; in qla2x00_async_adisc_sp_done()
576 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla2x00_async_adisc_sp_done()
583 srb_t *sp; in qla2x00_async_adisc() local
589 "%s: %8phC is being delete - not sending command.\n", in qla2x00_async_adisc()
590 __func__, fcport->port_name); in qla2x00_async_adisc()
591 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla2x00_async_adisc()
595 if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT)) in qla2x00_async_adisc()
598 fcport->flags |= FCF_ASYNC_SENT; in qla2x00_async_adisc()
600 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla2x00_async_adisc()
601 if (!sp) in qla2x00_async_adisc()
604 sp->type = SRB_ADISC_CMD; in qla2x00_async_adisc()
605 sp->name = "adisc"; in qla2x00_async_adisc()
606 sp->gen1 = fcport->rscn_gen; in qla2x00_async_adisc()
607 sp->gen2 = fcport->login_gen; in qla2x00_async_adisc()
608 qla2x00_init_async_sp(sp, qla2x00_get_async_timeout(vha) + 2, in qla2x00_async_adisc()
612 lio = &sp->u.iocb_cmd; in qla2x00_async_adisc()
613 lio->u.logio.flags |= SRB_LOGIN_RETRIED; in qla2x00_async_adisc()
617 "Async-adisc - hdl=%x loopid=%x portid=%06x %8phC.\n", in qla2x00_async_adisc()
618 sp->handle, fcport->loop_id, fcport->d_id.b24, fcport->port_name); in qla2x00_async_adisc()
620 rval = qla2x00_start_sp(sp); in qla2x00_async_adisc()
628 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla2x00_async_adisc()
630 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_adisc()
637 struct qla_hw_data *ha = vha->hw; in qla2x00_is_reserved_id()
642 return (loop_id > ha->max_loop_id && loop_id < SNS_FIRST_LOOP_ID) || in qla2x00_is_reserved_id()
647 * qla2x00_find_new_loop_id - scan through our port list and find a new usable loop ID
660 struct qla_hw_data *ha = vha->hw; in qla2x00_find_new_loop_id()
665 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_find_new_loop_id()
667 dev->loop_id = find_first_zero_bit(ha->loop_id_map, LOOPID_MAP_SIZE); in qla2x00_find_new_loop_id()
668 if (dev->loop_id >= LOOPID_MAP_SIZE || in qla2x00_find_new_loop_id()
669 qla2x00_is_reserved_id(vha, dev->loop_id)) { in qla2x00_find_new_loop_id()
670 dev->loop_id = FC_NO_LOOP_ID; in qla2x00_find_new_loop_id()
673 set_bit(dev->loop_id, ha->loop_id_map); in qla2x00_find_new_loop_id()
675 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_find_new_loop_id()
678 ql_dbg(ql_dbg_disc, dev->vha, 0x2086, in qla2x00_find_new_loop_id()
680 dev->loop_id, dev->d_id.b24); in qla2x00_find_new_loop_id()
682 ql_log(ql_log_warn, dev->vha, 0x2087, in qla2x00_find_new_loop_id()
684 dev->d_id.b24); in qla2x00_find_new_loop_id()
691 struct qla_hw_data *ha = fcport->vha->hw; in qla2x00_clear_loop_id()
693 if (fcport->loop_id == FC_NO_LOOP_ID || in qla2x00_clear_loop_id()
694 qla2x00_is_reserved_id(fcport->vha, fcport->loop_id)) in qla2x00_clear_loop_id()
697 clear_bit(fcport->loop_id, ha->loop_id_map); in qla2x00_clear_loop_id()
698 fcport->loop_id = FC_NO_LOOP_ID; in qla2x00_clear_loop_id()
712 fcport = ea->fcport; in qla24xx_handle_gnl_done_event()
715 __func__, fcport->port_name, fcport->disc_state, in qla24xx_handle_gnl_done_event()
716 fcport->fw_login_state, ea->rc, in qla24xx_handle_gnl_done_event()
717 fcport->login_gen, fcport->last_login_gen, in qla24xx_handle_gnl_done_event()
718 fcport->rscn_gen, fcport->last_rscn_gen, vha->loop_id, fcport->edif.enable); in qla24xx_handle_gnl_done_event()
720 if (fcport->disc_state == DSC_DELETE_PEND) in qla24xx_handle_gnl_done_event()
723 if (ea->rc) { /* rval */ in qla24xx_handle_gnl_done_event()
724 if (fcport->login_retry == 0) { in qla24xx_handle_gnl_done_event()
727 fcport->port_name, fcport->login_retry); in qla24xx_handle_gnl_done_event()
732 if (fcport->last_rscn_gen != fcport->rscn_gen) { in qla24xx_handle_gnl_done_event()
736 } else if (fcport->last_login_gen != fcport->login_gen) { in qla24xx_handle_gnl_done_event()
739 __func__, fcport->port_name); in qla24xx_handle_gnl_done_event()
740 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_gnl_done_event()
744 n = ea->data[0] / sizeof(struct get_name_list_extended); in qla24xx_handle_gnl_done_event()
748 __func__, __LINE__, fcport->port_name, n, in qla24xx_handle_gnl_done_event()
749 fcport->d_id.b.domain, fcport->d_id.b.area, in qla24xx_handle_gnl_done_event()
750 fcport->d_id.b.al_pa, fcport->loop_id); in qla24xx_handle_gnl_done_event()
753 e = &vha->gnl.l[i]; in qla24xx_handle_gnl_done_event()
754 wwn = wwn_to_u64(e->port_name); in qla24xx_handle_gnl_done_event()
755 id.b.domain = e->port_id[2]; in qla24xx_handle_gnl_done_event()
756 id.b.area = e->port_id[1]; in qla24xx_handle_gnl_done_event()
757 id.b.al_pa = e->port_id[0]; in qla24xx_handle_gnl_done_event()
760 if (memcmp((u8 *)&wwn, fcport->port_name, WWN_SIZE)) in qla24xx_handle_gnl_done_event()
768 loop_id = le16_to_cpu(e->nport_handle); in qla24xx_handle_gnl_done_event()
770 nvme_cls = e->current_login_state >> 4; in qla24xx_handle_gnl_done_event()
771 current_login_state = e->current_login_state & 0xf; in qla24xx_handle_gnl_done_event()
775 fcport->fc4_type &= ~FS_FC4TYPE_FCP; in qla24xx_handle_gnl_done_event()
776 fcport->fc4_type |= FS_FC4TYPE_NVME; in qla24xx_handle_gnl_done_event()
778 fcport->fc4_type |= FS_FC4TYPE_FCP; in qla24xx_handle_gnl_done_event()
779 fcport->fc4_type &= ~FS_FC4TYPE_NVME; in qla24xx_handle_gnl_done_event()
784 __func__, fcport->port_name, in qla24xx_handle_gnl_done_event()
785 e->current_login_state, fcport->fw_login_state, in qla24xx_handle_gnl_done_event()
786 fcport->fc4_type, id.b24, fcport->d_id.b24, in qla24xx_handle_gnl_done_event()
787 loop_id, fcport->loop_id); in qla24xx_handle_gnl_done_event()
789 switch (fcport->disc_state) { in qla24xx_handle_gnl_done_event()
794 if ((id.b24 != fcport->d_id.b24 && in qla24xx_handle_gnl_done_event()
795 fcport->d_id.b24 && in qla24xx_handle_gnl_done_event()
796 fcport->loop_id != FC_NO_LOOP_ID) || in qla24xx_handle_gnl_done_event()
797 (fcport->loop_id != FC_NO_LOOP_ID && in qla24xx_handle_gnl_done_event()
798 fcport->loop_id != loop_id)) { in qla24xx_handle_gnl_done_event()
801 __func__, __LINE__, fcport->port_name); in qla24xx_handle_gnl_done_event()
802 if (fcport->n2n_flag) in qla24xx_handle_gnl_done_event()
803 fcport->d_id.b24 = 0; in qla24xx_handle_gnl_done_event()
810 fcport->loop_id = loop_id; in qla24xx_handle_gnl_done_event()
811 if (fcport->n2n_flag) in qla24xx_handle_gnl_done_event()
812 fcport->d_id.b24 = id.b24; in qla24xx_handle_gnl_done_event()
814 wwn = wwn_to_u64(fcport->port_name); in qla24xx_handle_gnl_done_event()
824 conflict_fcport->conflict = fcport; in qla24xx_handle_gnl_done_event()
825 fcport->login_pause = 1; in qla24xx_handle_gnl_done_event()
828 switch (vha->hw->current_topology) { in qla24xx_handle_gnl_done_event()
834 __func__, __LINE__, fcport->port_name); in qla24xx_handle_gnl_done_event()
836 if ((e->prli_svc_param_word_3[0] & BIT_4) == 0) in qla24xx_handle_gnl_done_event()
837 fcport->port_type = FCT_INITIATOR; in qla24xx_handle_gnl_done_event()
839 fcport->port_type = FCT_TARGET; in qla24xx_handle_gnl_done_event()
845 if (vha->hw->flags.edif_enabled) { in qla24xx_handle_gnl_done_event()
853 if (fcport->loop_id == FC_NO_LOOP_ID) { in qla24xx_handle_gnl_done_event()
855 fcport->fw_login_state = in qla24xx_handle_gnl_done_event()
860 fcport->port_name); in qla24xx_handle_gnl_done_event()
866 fcport->fw_login_state = current_login_state; in qla24xx_handle_gnl_done_event()
867 fcport->d_id = id; in qla24xx_handle_gnl_done_event()
878 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_gnl_done_event()
881 if ((e->prli_svc_param_word_3[0] & BIT_4) == 0) in qla24xx_handle_gnl_done_event()
882 fcport->port_type = FCT_INITIATOR; in qla24xx_handle_gnl_done_event()
884 fcport->port_type = FCT_TARGET; in qla24xx_handle_gnl_done_event()
891 if (vha->hw->flags.edif_enabled && in qla24xx_handle_gnl_done_event()
899 if (fcport->loop_id != FC_NO_LOOP_ID) in qla24xx_handle_gnl_done_event()
902 fcport->loop_id = loop_id; in qla24xx_handle_gnl_done_event()
911 if (fcport->loop_id != FC_NO_LOOP_ID) in qla24xx_handle_gnl_done_event()
914 fcport->loop_id = loop_id; in qla24xx_handle_gnl_done_event()
921 } /* switch (ha->current_topology) */ in qla24xx_handle_gnl_done_event()
925 switch (vha->hw->current_topology) { in qla24xx_handle_gnl_done_event()
929 e = &vha->gnl.l[i]; in qla24xx_handle_gnl_done_event()
930 id.b.domain = e->port_id[0]; in qla24xx_handle_gnl_done_event()
931 id.b.area = e->port_id[1]; in qla24xx_handle_gnl_done_event()
932 id.b.al_pa = e->port_id[2]; in qla24xx_handle_gnl_done_event()
934 loop_id = le16_to_cpu(e->nport_handle); in qla24xx_handle_gnl_done_event()
936 if (fcport->d_id.b24 == id.b24) { in qla24xx_handle_gnl_done_event()
939 e->port_name, 0); in qla24xx_handle_gnl_done_event()
945 conflict_fcport->port_name); in qla24xx_handle_gnl_done_event()
954 if (fcport->loop_id == loop_id) in qla24xx_handle_gnl_done_event()
955 fcport->loop_id = FC_NO_LOOP_ID; in qla24xx_handle_gnl_done_event()
961 if (time_after_eq(jiffies, fcport->dm_login_expire)) { in qla24xx_handle_gnl_done_event()
962 if (fcport->n2n_link_reset_cnt < 2) { in qla24xx_handle_gnl_done_event()
963 fcport->n2n_link_reset_cnt++; in qla24xx_handle_gnl_done_event()
970 &vha->dpc_flags); in qla24xx_handle_gnl_done_event()
972 if (fcport->n2n_chip_reset < 1) { in qla24xx_handle_gnl_done_event()
976 &vha->dpc_flags); in qla24xx_handle_gnl_done_event()
977 fcport->n2n_chip_reset++; in qla24xx_handle_gnl_done_event()
981 fcport->port_name); in qla24xx_handle_gnl_done_event()
982 fcport->scan_state = 0; in qla24xx_handle_gnl_done_event()
991 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_gnl_done_event()
1003 static void qla24xx_async_gnl_sp_done(srb_t *sp, int res) in qla24xx_async_gnl_sp_done() argument
1005 struct scsi_qla_host *vha = sp->vha; in qla24xx_async_gnl_sp_done()
1016 "Async done-%s res %x mb[1]=%x mb[2]=%x \n", in qla24xx_async_gnl_sp_done()
1017 sp->name, res, sp->u.iocb_cmd.u.mbx.in_mb[1], in qla24xx_async_gnl_sp_done()
1018 sp->u.iocb_cmd.u.mbx.in_mb[2]); in qla24xx_async_gnl_sp_done()
1021 sp->fcport->flags &= ~(FCF_ASYNC_SENT|FCF_ASYNC_ACTIVE); in qla24xx_async_gnl_sp_done()
1023 ea.sp = sp; in qla24xx_async_gnl_sp_done()
1026 if (sp->u.iocb_cmd.u.mbx.in_mb[1] >= in qla24xx_async_gnl_sp_done()
1028 n = sp->u.iocb_cmd.u.mbx.in_mb[1] / in qla24xx_async_gnl_sp_done()
1030 ea.data[0] = sp->u.iocb_cmd.u.mbx.in_mb[1]; /* amnt xfered */ in qla24xx_async_gnl_sp_done()
1034 e = &vha->gnl.l[i]; in qla24xx_async_gnl_sp_done()
1035 loop_id = le16_to_cpu(e->nport_handle); in qla24xx_async_gnl_sp_done()
1038 set_bit(loop_id, vha->hw->loop_id_map); in qla24xx_async_gnl_sp_done()
1039 wwn = wwn_to_u64(e->port_name); in qla24xx_async_gnl_sp_done()
1043 __func__, &wwn, e->port_id[2], e->port_id[1], in qla24xx_async_gnl_sp_done()
1044 e->port_id[0], e->current_login_state, e->last_login_state, in qla24xx_async_gnl_sp_done()
1048 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1052 if (!list_empty(&vha->gnl.fcports)) in qla24xx_async_gnl_sp_done()
1053 list_splice_init(&vha->gnl.fcports, &h); in qla24xx_async_gnl_sp_done()
1054 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1057 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1058 list_del_init(&fcport->gnl_entry); in qla24xx_async_gnl_sp_done()
1059 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla24xx_async_gnl_sp_done()
1060 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1071 e = &vha->gnl.l[i]; in qla24xx_async_gnl_sp_done()
1072 wwn = wwn_to_u64(e->port_name); in qla24xx_async_gnl_sp_done()
1075 list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list) { in qla24xx_async_gnl_sp_done()
1076 if (!memcmp((u8 *)&wwn, fcport->port_name, in qla24xx_async_gnl_sp_done()
1083 id.b.domain = e->port_id[2]; in qla24xx_async_gnl_sp_done()
1084 id.b.area = e->port_id[1]; in qla24xx_async_gnl_sp_done()
1085 id.b.al_pa = e->port_id[0]; in qla24xx_async_gnl_sp_done()
1092 wwnn = wwn_to_u64(e->node_name); in qla24xx_async_gnl_sp_done()
1098 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1099 vha->gnl.sent = 0; in qla24xx_async_gnl_sp_done()
1100 if (!list_empty(&vha->gnl.fcports)) { in qla24xx_async_gnl_sp_done()
1102 list_for_each_entry_safe(fcport, tf, &vha->gnl.fcports, in qla24xx_async_gnl_sp_done()
1104 list_del_init(&fcport->gnl_entry); in qla24xx_async_gnl_sp_done()
1105 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla24xx_async_gnl_sp_done()
1110 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1113 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla24xx_async_gnl_sp_done()
1118 srb_t *sp; in qla24xx_async_gnl() local
1123 if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT)) in qla24xx_async_gnl()
1127 "Async-gnlist WWPN %8phC \n", fcport->port_name); in qla24xx_async_gnl()
1129 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl()
1130 fcport->flags |= FCF_ASYNC_SENT; in qla24xx_async_gnl()
1132 fcport->last_rscn_gen = fcport->rscn_gen; in qla24xx_async_gnl()
1133 fcport->last_login_gen = fcport->login_gen; in qla24xx_async_gnl()
1135 list_add_tail(&fcport->gnl_entry, &vha->gnl.fcports); in qla24xx_async_gnl()
1136 if (vha->gnl.sent) { in qla24xx_async_gnl()
1137 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl()
1140 vha->gnl.sent = 1; in qla24xx_async_gnl()
1141 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl()
1144 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla24xx_async_gnl()
1145 if (!sp) in qla24xx_async_gnl()
1148 sp->type = SRB_MB_IOCB; in qla24xx_async_gnl()
1149 sp->name = "gnlist"; in qla24xx_async_gnl()
1150 sp->gen1 = fcport->rscn_gen; in qla24xx_async_gnl()
1151 sp->gen2 = fcport->login_gen; in qla24xx_async_gnl()
1152 qla2x00_init_async_sp(sp, qla2x00_get_async_timeout(vha) + 2, in qla24xx_async_gnl()
1155 mb = sp->u.iocb_cmd.u.mbx.out_mb; in qla24xx_async_gnl()
1158 mb[2] = MSW(vha->gnl.ldma); in qla24xx_async_gnl()
1159 mb[3] = LSW(vha->gnl.ldma); in qla24xx_async_gnl()
1160 mb[6] = MSW(MSD(vha->gnl.ldma)); in qla24xx_async_gnl()
1161 mb[7] = LSW(MSD(vha->gnl.ldma)); in qla24xx_async_gnl()
1162 mb[8] = vha->gnl.size; in qla24xx_async_gnl()
1163 mb[9] = vha->vp_idx; in qla24xx_async_gnl()
1166 "Async-%s - OUT WWPN %8phC hndl %x\n", in qla24xx_async_gnl()
1167 sp->name, fcport->port_name, sp->handle); in qla24xx_async_gnl()
1169 rval = qla2x00_start_sp(sp); in qla24xx_async_gnl()
1177 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla24xx_async_gnl()
1179 fcport->flags &= ~(FCF_ASYNC_ACTIVE | FCF_ASYNC_SENT); in qla24xx_async_gnl()
1191 e->u.fcport.fcport = fcport; in qla24xx_post_gnl_work()
1192 fcport->flags |= FCF_ASYNC_ACTIVE; in qla24xx_post_gnl_work()
1196 static void qla24xx_async_gpdb_sp_done(srb_t *sp, int res) in qla24xx_async_gpdb_sp_done() argument
1198 struct scsi_qla_host *vha = sp->vha; in qla24xx_async_gpdb_sp_done()
1199 struct qla_hw_data *ha = vha->hw; in qla24xx_async_gpdb_sp_done()
1200 fc_port_t *fcport = sp->fcport; in qla24xx_async_gpdb_sp_done()
1201 u16 *mb = sp->u.iocb_cmd.u.mbx.in_mb; in qla24xx_async_gpdb_sp_done()
1205 "Async done-%s res %x, WWPN %8phC mb[1]=%x mb[2]=%x \n", in qla24xx_async_gpdb_sp_done()
1206 sp->name, res, fcport->port_name, mb[1], mb[2]); in qla24xx_async_gpdb_sp_done()
1208 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla24xx_async_gpdb_sp_done()
1215 ea.sp = sp; in qla24xx_async_gpdb_sp_done()
1220 dma_pool_free(ha->s_dma_pool, sp->u.iocb_cmd.u.mbx.in, in qla24xx_async_gpdb_sp_done()
1221 sp->u.iocb_cmd.u.mbx.in_dma); in qla24xx_async_gpdb_sp_done()
1223 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla24xx_async_gpdb_sp_done()
1230 if (vha->host->active_mode == MODE_TARGET) in qla24xx_post_prli_work()
1237 e->u.fcport.fcport = fcport; in qla24xx_post_prli_work()
1242 static void qla2x00_async_prli_sp_done(srb_t *sp, int res) in qla2x00_async_prli_sp_done() argument
1244 struct scsi_qla_host *vha = sp->vha; in qla2x00_async_prli_sp_done()
1245 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_prli_sp_done()
1250 sp->fcport->port_name, res); in qla2x00_async_prli_sp_done()
1252 sp->fcport->flags &= ~FCF_ASYNC_SENT; in qla2x00_async_prli_sp_done()
1254 if (!test_bit(UNLOADING, &vha->dpc_flags)) { in qla2x00_async_prli_sp_done()
1256 ea.fcport = sp->fcport; in qla2x00_async_prli_sp_done()
1257 ea.data[0] = lio->u.logio.data[0]; in qla2x00_async_prli_sp_done()
1258 ea.data[1] = lio->u.logio.data[1]; in qla2x00_async_prli_sp_done()
1259 ea.iop[0] = lio->u.logio.iop[0]; in qla2x00_async_prli_sp_done()
1260 ea.iop[1] = lio->u.logio.iop[1]; in qla2x00_async_prli_sp_done()
1261 ea.sp = sp; in qla2x00_async_prli_sp_done()
1270 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla2x00_async_prli_sp_done()
1276 srb_t *sp; in qla24xx_async_prli() local
1280 if (!vha->flags.online) { in qla24xx_async_prli()
1282 __func__, __LINE__, fcport->port_name); in qla24xx_async_prli()
1286 if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND || in qla24xx_async_prli()
1287 fcport->fw_login_state == DSC_LS_PRLI_PEND) && in qla24xx_async_prli()
1290 __func__, __LINE__, fcport->port_name); in qla24xx_async_prli()
1294 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla24xx_async_prli()
1295 if (!sp) in qla24xx_async_prli()
1298 fcport->flags |= FCF_ASYNC_SENT; in qla24xx_async_prli()
1299 fcport->logout_completed = 0; in qla24xx_async_prli()
1301 sp->type = SRB_PRLI_CMD; in qla24xx_async_prli()
1302 sp->name = "prli"; in qla24xx_async_prli()
1303 qla2x00_init_async_sp(sp, qla2x00_get_async_timeout(vha) + 2, in qla24xx_async_prli()
1306 lio = &sp->u.iocb_cmd; in qla24xx_async_prli()
1307 lio->u.logio.flags = 0; in qla24xx_async_prli()
1309 if (NVME_TARGET(vha->hw, fcport)) in qla24xx_async_prli()
1310 lio->u.logio.flags |= SRB_LOGIN_NVME_PRLI; in qla24xx_async_prli()
1313 "Async-prli - %8phC hdl=%x, loopid=%x portid=%06x retries=%d fc4type %x priority %x %s.\n", in qla24xx_async_prli()
1314 fcport->port_name, sp->handle, fcport->loop_id, fcport->d_id.b24, in qla24xx_async_prli()
1315 fcport->login_retry, fcport->fc4_type, vha->hw->fc4_type_priority, in qla24xx_async_prli()
1316 NVME_TARGET(vha->hw, fcport) ? "nvme" : "fcp"); in qla24xx_async_prli()
1318 rval = qla2x00_start_sp(sp); in qla24xx_async_prli()
1320 fcport->flags |= FCF_LOGIN_NEEDED; in qla24xx_async_prli()
1321 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_async_prli()
1329 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla24xx_async_prli()
1330 fcport->flags &= ~FCF_ASYNC_SENT; in qla24xx_async_prli()
1342 e->u.fcport.fcport = fcport; in qla24xx_post_gpdb_work()
1343 e->u.fcport.opt = opt; in qla24xx_post_gpdb_work()
1344 fcport->flags |= FCF_ASYNC_ACTIVE; in qla24xx_post_gpdb_work()
1350 srb_t *sp; in qla24xx_async_gpdb() local
1356 struct qla_hw_data *ha = vha->hw; in qla24xx_async_gpdb()
1360 "%s: %8phC is being delete - not sending command.\n", in qla24xx_async_gpdb()
1361 __func__, fcport->port_name); in qla24xx_async_gpdb()
1362 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla24xx_async_gpdb()
1366 if (!vha->flags.online || fcport->flags & FCF_ASYNC_SENT) { in qla24xx_async_gpdb()
1368 "%s: %8phC online %d flags %x - not sending command.\n", in qla24xx_async_gpdb()
1369 __func__, fcport->port_name, vha->flags.online, fcport->flags); in qla24xx_async_gpdb()
1373 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla24xx_async_gpdb()
1374 if (!sp) in qla24xx_async_gpdb()
1379 fcport->flags |= FCF_ASYNC_SENT; in qla24xx_async_gpdb()
1380 sp->type = SRB_MB_IOCB; in qla24xx_async_gpdb()
1381 sp->name = "gpdb"; in qla24xx_async_gpdb()
1382 sp->gen1 = fcport->rscn_gen; in qla24xx_async_gpdb()
1383 sp->gen2 = fcport->login_gen; in qla24xx_async_gpdb()
1384 qla2x00_init_async_sp(sp, qla2x00_get_async_timeout(vha) + 2, in qla24xx_async_gpdb()
1387 pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); in qla24xx_async_gpdb()
1394 mb = sp->u.iocb_cmd.u.mbx.out_mb; in qla24xx_async_gpdb()
1396 mb[1] = fcport->loop_id; in qla24xx_async_gpdb()
1401 mb[9] = vha->vp_idx; in qla24xx_async_gpdb()
1404 mbx = &sp->u.iocb_cmd; in qla24xx_async_gpdb()
1405 mbx->u.mbx.in = (void *)pd; in qla24xx_async_gpdb()
1406 mbx->u.mbx.in_dma = pd_dma; in qla24xx_async_gpdb()
1409 "Async-%s %8phC hndl %x opt %x\n", in qla24xx_async_gpdb()
1410 sp->name, fcport->port_name, sp->handle, opt); in qla24xx_async_gpdb()
1412 rval = qla2x00_start_sp(sp); in qla24xx_async_gpdb()
1419 dma_pool_free(ha->s_dma_pool, pd, pd_dma); in qla24xx_async_gpdb()
1421 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla24xx_async_gpdb()
1422 fcport->flags &= ~FCF_ASYNC_SENT; in qla24xx_async_gpdb()
1424 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla24xx_async_gpdb()
1434 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in __qla24xx_handle_gpdb_event()
1435 ea->fcport->login_gen++; in __qla24xx_handle_gpdb_event()
1436 ea->fcport->deleted = 0; in __qla24xx_handle_gpdb_event()
1437 ea->fcport->logout_on_delete = 1; in __qla24xx_handle_gpdb_event()
1439 if (!ea->fcport->login_succ && !IS_SW_RESV_ADDR(ea->fcport->d_id)) { in __qla24xx_handle_gpdb_event()
1440 vha->fcport_count++; in __qla24xx_handle_gpdb_event()
1441 ea->fcport->login_succ = 1; in __qla24xx_handle_gpdb_event()
1443 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in __qla24xx_handle_gpdb_event()
1444 qla24xx_sched_upd_fcport(ea->fcport); in __qla24xx_handle_gpdb_event()
1445 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in __qla24xx_handle_gpdb_event()
1446 } else if (ea->fcport->login_succ) { in __qla24xx_handle_gpdb_event()
1449 * must have triggered the session to be re-validate. in __qla24xx_handle_gpdb_event()
1454 __func__, __LINE__, ea->fcport->port_name); in __qla24xx_handle_gpdb_event()
1455 qla2x00_set_fcport_disc_state(ea->fcport, DSC_LOGIN_COMPLETE); in __qla24xx_handle_gpdb_event()
1457 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in __qla24xx_handle_gpdb_event()
1465 if (pd->secure_login) { in qla_chk_secure_login()
1468 fcport->port_name); in qla_chk_secure_login()
1469 fcport->flags |= FCF_FCSP_DEVICE; in qla_chk_secure_login()
1472 "non-Secure Login %8phC", in qla_chk_secure_login()
1473 fcport->port_name); in qla_chk_secure_login()
1474 fcport->flags &= ~FCF_FCSP_DEVICE; in qla_chk_secure_login()
1476 if (vha->hw->flags.edif_enabled) { in qla_chk_secure_login()
1477 if (fcport->flags & FCF_FCSP_DEVICE) { in qla_chk_secure_login()
1480 fcport->edif.rx_sa_set = 0; in qla_chk_secure_login()
1481 fcport->edif.tx_sa_set = 0; in qla_chk_secure_login()
1482 fcport->edif.rx_sa_pending = 0; in qla_chk_secure_login()
1483 fcport->edif.tx_sa_pending = 0; in qla_chk_secure_login()
1486 fcport->d_id.b24); in qla_chk_secure_login()
1491 __func__, __LINE__, fcport->port_name); in qla_chk_secure_login()
1492 fcport->edif.app_sess_online = 1; in qla_chk_secure_login()
1495 fcport->d_id.b24, 0, fcport); in qla_chk_secure_login()
1502 __func__, __LINE__, fcport->port_name); in qla_chk_secure_login()
1513 fc_port_t *fcport = ea->fcport; in qla24xx_handle_gpdb_event()
1515 struct srb *sp = ea->sp; in qla24xx_handle_gpdb_event() local
1518 pd = (struct port_database_24xx *)sp->u.iocb_cmd.u.mbx.in; in qla24xx_handle_gpdb_event()
1520 fcport->flags &= ~FCF_ASYNC_SENT; in qla24xx_handle_gpdb_event()
1524 fcport->port_name, fcport->disc_state, pd->current_login_state, in qla24xx_handle_gpdb_event()
1525 fcport->fc4_type, ea->rc); in qla24xx_handle_gpdb_event()
1527 if (fcport->disc_state == DSC_DELETE_PEND) { in qla24xx_handle_gpdb_event()
1529 __func__, __LINE__, fcport->port_name); in qla24xx_handle_gpdb_event()
1533 if (NVME_TARGET(vha->hw, fcport)) in qla24xx_handle_gpdb_event()
1534 ls = pd->current_login_state >> 4; in qla24xx_handle_gpdb_event()
1536 ls = pd->current_login_state & 0xf; in qla24xx_handle_gpdb_event()
1538 if (ea->sp->gen2 != fcport->login_gen) { in qla24xx_handle_gpdb_event()
1543 __func__, fcport->port_name); in qla24xx_handle_gpdb_event()
1545 } else if (ea->sp->gen1 != fcport->rscn_gen) { in qla24xx_handle_gpdb_event()
1549 __func__, __LINE__, fcport->port_name, ls); in qla24xx_handle_gpdb_event()
1560 __func__, __LINE__, fcport->port_name, ls); in qla24xx_handle_gpdb_event()
1571 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_gpdb_event()
1574 __func__, __LINE__, fcport->port_name, ls); in qla24xx_handle_gpdb_event()
1580 __func__, __LINE__, fcport->port_name); in qla24xx_handle_gpdb_event()
1594 __func__, fcport->port_name, fcport->disc_state, in qla_chk_n2n_b4_login()
1595 fcport->fw_login_state, fcport->loop_id, fcport->login_retry); in qla_chk_n2n_b4_login()
1601 if (N2N_TOPO(vha->hw)) { in qla_chk_n2n_b4_login()
1604 mywwn = wwn_to_u64(vha->port_name); in qla_chk_n2n_b4_login()
1605 wwn = wwn_to_u64(fcport->port_name); in qla_chk_n2n_b4_login()
1608 else if ((fcport->fw_login_state == DSC_LS_PLOGI_COMP) in qla_chk_n2n_b4_login()
1610 fcport->plogi_nack_done_deadline)) in qla_chk_n2n_b4_login()
1620 if (login && fcport->login_retry) { in qla_chk_n2n_b4_login()
1621 fcport->login_retry--; in qla_chk_n2n_b4_login()
1622 if (fcport->loop_id == FC_NO_LOOP_ID) { in qla_chk_n2n_b4_login()
1623 fcport->fw_login_state = DSC_LS_PORT_UNAVAIL; in qla_chk_n2n_b4_login()
1627 "%s %d %8phC post del sess - out of loopid\n", in qla_chk_n2n_b4_login()
1628 __func__, __LINE__, fcport->port_name); in qla_chk_n2n_b4_login()
1629 fcport->scan_state = 0; in qla_chk_n2n_b4_login()
1636 __func__, __LINE__, fcport->port_name); in qla_chk_n2n_b4_login()
1649 __func__, fcport->port_name, fcport->disc_state, in qla24xx_fcport_handle_login()
1650 fcport->fw_login_state, fcport->login_pause, fcport->flags, in qla24xx_fcport_handle_login()
1651 fcport->conflict, fcport->last_rscn_gen, fcport->rscn_gen, in qla24xx_fcport_handle_login()
1652 fcport->login_gen, fcport->loop_id, fcport->scan_state, in qla24xx_fcport_handle_login()
1653 fcport->fc4_type); in qla24xx_fcport_handle_login()
1655 if (fcport->scan_state != QLA_FCPORT_FOUND || in qla24xx_fcport_handle_login()
1656 fcport->disc_state == DSC_DELETE_PEND) in qla24xx_fcport_handle_login()
1659 if ((fcport->loop_id != FC_NO_LOOP_ID) && in qla24xx_fcport_handle_login()
1661 ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) || in qla24xx_fcport_handle_login()
1662 (fcport->fw_login_state == DSC_LS_PRLI_PEND))) in qla24xx_fcport_handle_login()
1665 if (fcport->fw_login_state == DSC_LS_PLOGI_COMP && in qla24xx_fcport_handle_login()
1666 !N2N_TOPO(vha->hw)) { in qla24xx_fcport_handle_login()
1667 if (time_before_eq(jiffies, fcport->plogi_nack_done_deadline)) { in qla24xx_fcport_handle_login()
1668 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_fcport_handle_login()
1674 if (vha->host->active_mode == MODE_TARGET && !N2N_TOPO(vha->hw)) in qla24xx_fcport_handle_login()
1677 if (fcport->flags & (FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE)) { in qla24xx_fcport_handle_login()
1678 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_fcport_handle_login()
1682 switch (fcport->disc_state) { in qla24xx_fcport_handle_login()
1684 wwn = wwn_to_u64(fcport->node_name); in qla24xx_fcport_handle_login()
1685 switch (vha->hw->current_topology) { in qla24xx_fcport_handle_login()
1689 if (fcport->login_retry) { in qla24xx_fcport_handle_login()
1690 if (fcport->loop_id == FC_NO_LOOP_ID) { in qla24xx_fcport_handle_login()
1693 fcport->fw_login_state = in qla24xx_fcport_handle_login()
1696 fcport->login_retry--; in qla24xx_fcport_handle_login()
1701 fcport->port_name); in qla24xx_fcport_handle_login()
1711 __func__, __LINE__, fcport->port_name); in qla24xx_fcport_handle_login()
1713 } else if (fcport->loop_id == FC_NO_LOOP_ID) { in qla24xx_fcport_handle_login()
1716 __func__, __LINE__, fcport->port_name); in qla24xx_fcport_handle_login()
1726 switch (vha->hw->current_topology) { in qla24xx_fcport_handle_login()
1728 if ((fcport->current_login_state & 0xf) == 0x6) { in qla24xx_fcport_handle_login()
1731 __func__, __LINE__, fcport->port_name); in qla24xx_fcport_handle_login()
1732 fcport->chip_reset = in qla24xx_fcport_handle_login()
1733 vha->hw->base_qpair->chip_reset; in qla24xx_fcport_handle_login()
1738 __func__, __LINE__, fcport->port_name, in qla24xx_fcport_handle_login()
1739 NVME_TARGET(vha->hw, fcport) ? "NVME" : in qla24xx_fcport_handle_login()
1745 if (fcport->login_pause) { in qla24xx_fcport_handle_login()
1749 fcport->port_name); in qla24xx_fcport_handle_login()
1750 fcport->last_rscn_gen = fcport->rscn_gen; in qla24xx_fcport_handle_login()
1751 fcport->last_login_gen = fcport->login_gen; in qla24xx_fcport_handle_login()
1752 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_fcport_handle_login()
1761 if (N2N_TOPO(vha->hw)) in qla24xx_fcport_handle_login()
1774 if (vha->hw->flags.edif_enabled) in qla24xx_fcport_handle_login()
1777 if (fcport->fw_login_state == DSC_LS_PLOGI_COMP) { in qla24xx_fcport_handle_login()
1780 __func__, __LINE__, fcport->port_name, in qla24xx_fcport_handle_login()
1781 NVME_TARGET(vha->hw, fcport) ? "NVME" : "FC"); in qla24xx_fcport_handle_login()
1787 sec = jiffies_to_msecs(jiffies - in qla24xx_fcport_handle_login()
1788 fcport->jiffies_at_registration)/1000; in qla24xx_fcport_handle_login()
1789 if (fcport->sec_since_registration < sec && sec && in qla24xx_fcport_handle_login()
1791 fcport->sec_since_registration = sec; in qla24xx_fcport_handle_login()
1792 ql_dbg(ql_dbg_disc, fcport->vha, 0xffff, in qla24xx_fcport_handle_login()
1793 "%s %8phC - Slow Rport registration(%d Sec)\n", in qla24xx_fcport_handle_login()
1794 __func__, fcport->port_name, sec); in qla24xx_fcport_handle_login()
1797 if (fcport->next_disc_state != DSC_DELETE_PEND) in qla24xx_fcport_handle_login()
1798 fcport->next_disc_state = DSC_ADISC; in qla24xx_fcport_handle_login()
1799 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_fcport_handle_login()
1818 e->u.new_sess.id = *id; in qla24xx_post_newsess_work()
1819 e->u.new_sess.pla = pla; in qla24xx_post_newsess_work()
1820 e->u.new_sess.fc4_type = fc4_type; in qla24xx_post_newsess_work()
1821 memcpy(e->u.new_sess.port_name, port_name, WWN_SIZE); in qla24xx_post_newsess_work()
1823 memcpy(e->u.new_sess.node_name, node_name, WWN_SIZE); in qla24xx_post_newsess_work()
1833 switch (ea->id.b.rsvd_1) { in qla2x00_handle_rscn()
1835 fcport = qla2x00_find_fcport_by_nportid(vha, &ea->id, 1); in qla2x00_handle_rscn()
1837 if (fcport->flags & FCF_FCP2_DEVICE && in qla2x00_handle_rscn()
1838 atomic_read(&fcport->state) == FCS_ONLINE) { in qla2x00_handle_rscn()
1841 fcport->d_id.b24, fcport->port_name); in qla2x00_handle_rscn()
1845 if (vha->hw->flags.edif_enabled && DBELL_ACTIVE(vha)) { in qla2x00_handle_rscn()
1854 if (atomic_read(&fcport->state) == FCS_ONLINE) { in qla2x00_handle_rscn()
1859 fcport->scan_needed = 1; in qla2x00_handle_rscn()
1860 fcport->rscn_gen++; in qla2x00_handle_rscn()
1863 fcport->scan_needed = 1; in qla2x00_handle_rscn()
1864 fcport->rscn_gen++; in qla2x00_handle_rscn()
1869 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_handle_rscn()
1870 if (fcport->flags & FCF_FCP2_DEVICE && in qla2x00_handle_rscn()
1871 atomic_read(&fcport->state) == FCS_ONLINE) in qla2x00_handle_rscn()
1874 if ((ea->id.b24 & 0xffff00) == (fcport->d_id.b24 & 0xffff00)) { in qla2x00_handle_rscn()
1875 fcport->scan_needed = 1; in qla2x00_handle_rscn()
1876 fcport->rscn_gen++; in qla2x00_handle_rscn()
1881 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_handle_rscn()
1882 if (fcport->flags & FCF_FCP2_DEVICE && in qla2x00_handle_rscn()
1883 atomic_read(&fcport->state) == FCS_ONLINE) in qla2x00_handle_rscn()
1886 if ((ea->id.b24 & 0xff0000) == (fcport->d_id.b24 & 0xff0000)) { in qla2x00_handle_rscn()
1887 fcport->scan_needed = 1; in qla2x00_handle_rscn()
1888 fcport->rscn_gen++; in qla2x00_handle_rscn()
1894 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_handle_rscn()
1895 if (fcport->flags & FCF_FCP2_DEVICE && in qla2x00_handle_rscn()
1896 atomic_read(&fcport->state) == FCS_ONLINE) in qla2x00_handle_rscn()
1899 fcport->scan_needed = 1; in qla2x00_handle_rscn()
1900 fcport->rscn_gen++; in qla2x00_handle_rscn()
1905 spin_lock_irqsave(&vha->work_lock, flags); in qla2x00_handle_rscn()
1906 if (vha->scan.scan_flags == 0) { in qla2x00_handle_rscn()
1908 vha->scan.scan_flags |= SF_QUEUED; in qla2x00_handle_rscn()
1909 schedule_delayed_work(&vha->scan.scan_work, 5); in qla2x00_handle_rscn()
1911 spin_unlock_irqrestore(&vha->work_lock, flags); in qla2x00_handle_rscn()
1917 fc_port_t *fcport = ea->fcport; in qla24xx_handle_relogin_event()
1919 if (test_bit(UNLOADING, &vha->dpc_flags)) in qla24xx_handle_relogin_event()
1924 __func__, fcport->port_name, fcport->disc_state, in qla24xx_handle_relogin_event()
1925 fcport->fw_login_state, fcport->login_pause, in qla24xx_handle_relogin_event()
1926 fcport->deleted, fcport->conflict, in qla24xx_handle_relogin_event()
1927 fcport->last_rscn_gen, fcport->rscn_gen, in qla24xx_handle_relogin_event()
1928 fcport->last_login_gen, fcport->login_gen, in qla24xx_handle_relogin_event()
1929 fcport->flags); in qla24xx_handle_relogin_event()
1931 if (fcport->last_rscn_gen != fcport->rscn_gen) { in qla24xx_handle_relogin_event()
1933 __func__, __LINE__, fcport->port_name); in qla24xx_handle_relogin_event()
1944 if (N2N_TOPO(vha->hw) && fcport_is_smaller(ea->fcport) && in qla_handle_els_plogi_done()
1945 vha->hw->flags.edif_enabled) { in qla_handle_els_plogi_done()
1947 qla24xx_post_gpdb_work(vha, ea->fcport, 0); in qla_handle_els_plogi_done()
1952 if (vha->host->active_mode == MODE_TARGET) in qla_handle_els_plogi_done()
1957 __func__, __LINE__, ea->fcport->port_name); in qla_handle_els_plogi_done()
1958 qla24xx_post_prli_work(vha, ea->fcport); in qla_handle_els_plogi_done()
1969 switch (fcport->disc_state) { in qla_rscn_replay()
1976 if (fcport->scan_needed) { in qla_rscn_replay()
1978 ea.id = fcport->d_id; in qla_rscn_replay()
1980 qla2x00_handle_rscn(fcport->vha, &ea); in qla_rscn_replay()
1987 srb_t *sp = data; in qla2x00_tmf_iocb_timeout() local
1988 struct srb_iocb *tmf = &sp->u.iocb_cmd; in qla2x00_tmf_iocb_timeout()
1992 rc = qla24xx_async_abort_cmd(sp, false); in qla2x00_tmf_iocb_timeout()
1994 spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); in qla2x00_tmf_iocb_timeout()
1995 for (h = 1; h < sp->qpair->req->num_outstanding_cmds; h++) { in qla2x00_tmf_iocb_timeout()
1996 if (sp->qpair->req->outstanding_cmds[h] == sp) { in qla2x00_tmf_iocb_timeout()
1997 sp->qpair->req->outstanding_cmds[h] = NULL; in qla2x00_tmf_iocb_timeout()
2001 spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); in qla2x00_tmf_iocb_timeout()
2002 tmf->u.tmf.comp_status = cpu_to_le16(CS_TIMEOUT); in qla2x00_tmf_iocb_timeout()
2003 tmf->u.tmf.data = QLA_FUNCTION_FAILED; in qla2x00_tmf_iocb_timeout()
2004 complete(&tmf->u.tmf.comp); in qla2x00_tmf_iocb_timeout()
2008 static void qla2x00_tmf_sp_done(srb_t *sp, int res) in qla2x00_tmf_sp_done() argument
2010 struct srb_iocb *tmf = &sp->u.iocb_cmd; in qla2x00_tmf_sp_done()
2012 complete(&tmf->u.tmf.comp); in qla2x00_tmf_sp_done()
2019 struct scsi_qla_host *vha = fcport->vha; in qla2x00_async_tm_cmd()
2021 srb_t *sp; in qla2x00_async_tm_cmd() local
2026 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla2x00_async_tm_cmd()
2027 if (!sp) in qla2x00_async_tm_cmd()
2031 sp->type = SRB_TM_CMD; in qla2x00_async_tm_cmd()
2032 sp->name = "tmf"; in qla2x00_async_tm_cmd()
2033 qla2x00_init_async_sp(sp, qla2x00_get_async_timeout(vha), in qla2x00_async_tm_cmd()
2035 sp->u.iocb_cmd.timeout = qla2x00_tmf_iocb_timeout; in qla2x00_async_tm_cmd()
2037 tm_iocb = &sp->u.iocb_cmd; in qla2x00_async_tm_cmd()
2038 init_completion(&tm_iocb->u.tmf.comp); in qla2x00_async_tm_cmd()
2039 tm_iocb->u.tmf.flags = flags; in qla2x00_async_tm_cmd()
2040 tm_iocb->u.tmf.lun = lun; in qla2x00_async_tm_cmd()
2043 "Async-tmf hdl=%x loop-id=%x portid=%02x%02x%02x.\n", in qla2x00_async_tm_cmd()
2044 sp->handle, fcport->loop_id, fcport->d_id.b.domain, in qla2x00_async_tm_cmd()
2045 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_async_tm_cmd()
2047 rval = qla2x00_start_sp(sp); in qla2x00_async_tm_cmd()
2050 wait_for_completion(&tm_iocb->u.tmf.comp); in qla2x00_async_tm_cmd()
2052 rval = tm_iocb->u.tmf.data; in qla2x00_async_tm_cmd()
2059 if (!test_bit(UNLOADING, &vha->dpc_flags) && !IS_QLAFX00(vha->hw)) { in qla2x00_async_tm_cmd()
2060 flags = tm_iocb->u.tmf.flags; in qla2x00_async_tm_cmd()
2061 lun = (uint16_t)tm_iocb->u.tmf.lun; in qla2x00_async_tm_cmd()
2064 qla2x00_marker(vha, vha->hw->base_qpair, in qla2x00_async_tm_cmd()
2065 fcport->loop_id, lun, in qla2x00_async_tm_cmd()
2071 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla2x00_async_tm_cmd()
2072 fcport->flags &= ~FCF_ASYNC_SENT; in qla2x00_async_tm_cmd()
2078 qla24xx_async_abort_command(srb_t *sp) in qla24xx_async_abort_command() argument
2083 fc_port_t *fcport = sp->fcport; in qla24xx_async_abort_command()
2084 struct qla_qpair *qpair = sp->qpair; in qla24xx_async_abort_command()
2085 struct scsi_qla_host *vha = fcport->vha; in qla24xx_async_abort_command()
2086 struct req_que *req = qpair->req; in qla24xx_async_abort_command()
2088 spin_lock_irqsave(qpair->qp_lock_ptr, flags); in qla24xx_async_abort_command()
2089 for (handle = 1; handle < req->num_outstanding_cmds; handle++) { in qla24xx_async_abort_command()
2090 if (req->outstanding_cmds[handle] == sp) in qla24xx_async_abort_command()
2093 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qla24xx_async_abort_command()
2095 if (handle == req->num_outstanding_cmds) { in qla24xx_async_abort_command()
2099 if (sp->type == SRB_FXIOCB_DCMD) in qla24xx_async_abort_command()
2100 return qlafx00_fx_disc(vha, &vha->hw->mr.fcport, in qla24xx_async_abort_command()
2103 return qla24xx_async_abort_cmd(sp, true); in qla24xx_async_abort_command()
2109 struct srb *sp; in qla24xx_handle_prli_done_event() local
2110 WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n", in qla24xx_handle_prli_done_event()
2111 ea->data[0]); in qla24xx_handle_prli_done_event()
2113 switch (ea->data[0]) { in qla24xx_handle_prli_done_event()
2117 __func__, __LINE__, ea->fcport->port_name); in qla24xx_handle_prli_done_event()
2119 ea->fcport->chip_reset = vha->hw->base_qpair->chip_reset; in qla24xx_handle_prli_done_event()
2120 ea->fcport->logout_on_delete = 1; in qla24xx_handle_prli_done_event()
2121 ea->fcport->nvme_prli_service_param = ea->iop[0]; in qla24xx_handle_prli_done_event()
2122 if (ea->iop[0] & NVME_PRLI_SP_FIRST_BURST) in qla24xx_handle_prli_done_event()
2123 ea->fcport->nvme_first_burst_size = in qla24xx_handle_prli_done_event()
2124 (ea->iop[1] & 0xffff) * 512; in qla24xx_handle_prli_done_event()
2126 ea->fcport->nvme_first_burst_size = 0; in qla24xx_handle_prli_done_event()
2127 qla24xx_post_gpdb_work(vha, ea->fcport, 0); in qla24xx_handle_prli_done_event()
2130 sp = ea->sp; in qla24xx_handle_prli_done_event()
2133 __func__, __LINE__, ea->fcport->port_name, in qla24xx_handle_prli_done_event()
2134 vha->hw->fc4_type_priority == FC4_PRIORITY_FCP ? in qla24xx_handle_prli_done_event()
2135 "FCP" : "NVMe", ea->fcport->fc4_type, in qla24xx_handle_prli_done_event()
2136 (sp->u.iocb_cmd.u.logio.flags & SRB_LOGIN_NVME_PRLI) ? in qla24xx_handle_prli_done_event()
2139 if (NVME_FCP_TARGET(ea->fcport)) { in qla24xx_handle_prli_done_event()
2140 if (sp->u.iocb_cmd.u.logio.flags & SRB_LOGIN_NVME_PRLI) in qla24xx_handle_prli_done_event()
2141 ea->fcport->do_prli_nvme = 0; in qla24xx_handle_prli_done_event()
2143 ea->fcport->do_prli_nvme = 1; in qla24xx_handle_prli_done_event()
2145 ea->fcport->do_prli_nvme = 0; in qla24xx_handle_prli_done_event()
2148 if (N2N_TOPO(vha->hw)) { in qla24xx_handle_prli_done_event()
2149 if (ea->fcport->n2n_link_reset_cnt == in qla24xx_handle_prli_done_event()
2150 vha->hw->login_retry_count && in qla24xx_handle_prli_done_event()
2151 ea->fcport->flags & FCF_FCSP_DEVICE) { in qla24xx_handle_prli_done_event()
2153 ea->fcport->n2n_link_reset_cnt = 0; in qla24xx_handle_prli_done_event()
2156 if (ea->fcport->n2n_link_reset_cnt < in qla24xx_handle_prli_done_event()
2157 vha->hw->login_retry_count) { in qla24xx_handle_prli_done_event()
2158 ea->fcport->n2n_link_reset_cnt++; in qla24xx_handle_prli_done_event()
2159 vha->relogin_jif = jiffies + 2 * HZ; in qla24xx_handle_prli_done_event()
2164 set_bit(N2N_LINK_RESET, &vha->dpc_flags); in qla24xx_handle_prli_done_event()
2170 ea->fcport->port_name); in qla24xx_handle_prli_done_event()
2177 ea->fcport->flags &= ~FCF_ASYNC_SENT; in qla24xx_handle_prli_done_event()
2178 ea->fcport->keep_nport_handle = 0; in qla24xx_handle_prli_done_event()
2179 ea->fcport->logout_on_delete = 1; in qla24xx_handle_prli_done_event()
2180 qlt_schedule_sess_for_deletion(ea->fcport); in qla24xx_handle_prli_done_event()
2193 struct fc_port *fcport = ea->fcport; in qla24xx_handle_plogi_done_event()
2197 __func__, fcport->port_name, fcport->disc_state, in qla24xx_handle_plogi_done_event()
2198 fcport->fw_login_state, ea->rc, ea->sp->gen2, fcport->login_gen, in qla24xx_handle_plogi_done_event()
2199 ea->sp->gen1, fcport->rscn_gen, in qla24xx_handle_plogi_done_event()
2200 ea->data[0], ea->data[1], ea->iop[0], ea->iop[1]); in qla24xx_handle_plogi_done_event()
2202 if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) || in qla24xx_handle_plogi_done_event()
2203 (fcport->fw_login_state == DSC_LS_PRLI_PEND)) { in qla24xx_handle_plogi_done_event()
2206 __func__, __LINE__, fcport->port_name); in qla24xx_handle_plogi_done_event()
2210 if ((fcport->disc_state == DSC_DELETE_PEND) || in qla24xx_handle_plogi_done_event()
2211 (fcport->disc_state == DSC_DELETED)) { in qla24xx_handle_plogi_done_event()
2212 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_plogi_done_event()
2216 if (ea->sp->gen2 != fcport->login_gen) { in qla24xx_handle_plogi_done_event()
2220 __func__, fcport->port_name); in qla24xx_handle_plogi_done_event()
2221 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_plogi_done_event()
2223 } else if (ea->sp->gen1 != fcport->rscn_gen) { in qla24xx_handle_plogi_done_event()
2226 __func__, fcport->port_name); in qla24xx_handle_plogi_done_event()
2232 WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n", in qla24xx_handle_plogi_done_event()
2233 ea->data[0]); in qla24xx_handle_plogi_done_event()
2235 switch (ea->data[0]) { in qla24xx_handle_plogi_done_event()
2238 * Driver must validate login state - If PRLI not complete, in qla24xx_handle_plogi_done_event()
2242 if (vha->hw->flags.edif_enabled) { in qla24xx_handle_plogi_done_event()
2243 set_bit(ea->fcport->loop_id, vha->hw->loop_id_map); in qla24xx_handle_plogi_done_event()
2244 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_handle_plogi_done_event()
2245 ea->fcport->chip_reset = vha->hw->base_qpair->chip_reset; in qla24xx_handle_plogi_done_event()
2246 ea->fcport->logout_on_delete = 1; in qla24xx_handle_plogi_done_event()
2247 ea->fcport->send_els_logo = 0; in qla24xx_handle_plogi_done_event()
2248 ea->fcport->fw_login_state = DSC_LS_PLOGI_COMP; in qla24xx_handle_plogi_done_event()
2249 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_handle_plogi_done_event()
2251 qla24xx_post_gpdb_work(vha, ea->fcport, 0); in qla24xx_handle_plogi_done_event()
2253 if (NVME_TARGET(vha->hw, fcport)) { in qla24xx_handle_plogi_done_event()
2256 __func__, __LINE__, fcport->port_name); in qla24xx_handle_plogi_done_event()
2261 __func__, __LINE__, fcport->port_name, in qla24xx_handle_plogi_done_event()
2262 fcport->loop_id, fcport->d_id.b24); in qla24xx_handle_plogi_done_event()
2264 set_bit(fcport->loop_id, vha->hw->loop_id_map); in qla24xx_handle_plogi_done_event()
2265 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_handle_plogi_done_event()
2266 fcport->chip_reset = vha->hw->base_qpair->chip_reset; in qla24xx_handle_plogi_done_event()
2267 fcport->logout_on_delete = 1; in qla24xx_handle_plogi_done_event()
2268 fcport->send_els_logo = 0; in qla24xx_handle_plogi_done_event()
2269 fcport->fw_login_state = DSC_LS_PRLI_COMP; in qla24xx_handle_plogi_done_event()
2270 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_handle_plogi_done_event()
2278 __func__, __LINE__, ea->fcport->port_name, ea->data[1]); in qla24xx_handle_plogi_done_event()
2280 qlt_schedule_sess_for_deletion(ea->fcport); in qla24xx_handle_plogi_done_event()
2284 cid.b.domain = (ea->iop[1] >> 16) & 0xff; in qla24xx_handle_plogi_done_event()
2285 cid.b.area = (ea->iop[1] >> 8) & 0xff; in qla24xx_handle_plogi_done_event()
2286 cid.b.al_pa = ea->iop[1] & 0xff; in qla24xx_handle_plogi_done_event()
2291 __func__, __LINE__, ea->fcport->port_name, in qla24xx_handle_plogi_done_event()
2292 ea->fcport->loop_id, cid.b24); in qla24xx_handle_plogi_done_event()
2294 set_bit(ea->fcport->loop_id, vha->hw->loop_id_map); in qla24xx_handle_plogi_done_event()
2295 ea->fcport->loop_id = FC_NO_LOOP_ID; in qla24xx_handle_plogi_done_event()
2296 qla24xx_post_gnl_work(vha, ea->fcport); in qla24xx_handle_plogi_done_event()
2299 lid = ea->iop[1] & 0xffff; in qla24xx_handle_plogi_done_event()
2301 wwn_to_u64(ea->fcport->port_name), in qla24xx_handle_plogi_done_event()
2302 ea->fcport->d_id, lid, &conflict_fcport); in qla24xx_handle_plogi_done_event()
2310 conflict_fcport->conflict = ea->fcport; in qla24xx_handle_plogi_done_event()
2311 ea->fcport->login_pause = 1; in qla24xx_handle_plogi_done_event()
2315 __func__, __LINE__, ea->fcport->port_name, in qla24xx_handle_plogi_done_event()
2316 ea->fcport->d_id.b24, lid); in qla24xx_handle_plogi_done_event()
2319 "%s %d %8phC NPortId %06x inuse with loopid 0x%x. sched delete\n", in qla24xx_handle_plogi_done_event()
2320 __func__, __LINE__, ea->fcport->port_name, in qla24xx_handle_plogi_done_event()
2321 ea->fcport->d_id.b24, lid); in qla24xx_handle_plogi_done_event()
2323 qla2x00_clear_loop_id(ea->fcport); in qla24xx_handle_plogi_done_event()
2324 set_bit(lid, vha->hw->loop_id_map); in qla24xx_handle_plogi_done_event()
2325 ea->fcport->loop_id = lid; in qla24xx_handle_plogi_done_event()
2326 ea->fcport->keep_nport_handle = 0; in qla24xx_handle_plogi_done_event()
2327 ea->fcport->logout_on_delete = 1; in qla24xx_handle_plogi_done_event()
2328 qlt_schedule_sess_for_deletion(ea->fcport); in qla24xx_handle_plogi_done_event()
2343 struct qla_hw_data *ha = vha->hw; in qla83xx_nic_core_fw_load()
2350 * flash-info / other param in qla83xx_nic_core_fw_load()
2352 ha->fcoe_dev_init_timeout = QLA83XX_IDC_INITIALIZATION_TIMEOUT; in qla83xx_nic_core_fw_load()
2353 ha->fcoe_reset_timeout = QLA83XX_IDC_RESET_ACK_TIMEOUT; in qla83xx_nic_core_fw_load()
2358 "Error while setting DRV-Presence.\n"); in qla83xx_nic_core_fw_load()
2368 * Init-Owner: Set IDC-Major-Version and Clear IDC-Lock-Recovery in qla83xx_nic_core_fw_load()
2373 if (ha->flags.nic_core_reset_owner) { in qla83xx_nic_core_fw_load()
2378 /* Clearing IDC-Lock-Recovery register */ in qla83xx_nic_core_fw_load()
2394 idc_minor_ver |= (QLA83XX_SUPP_IDC_MINOR_VERSION << (ha->portnum * 2)); in qla83xx_nic_core_fw_load()
2397 if (ha->flags.nic_core_reset_owner) { in qla83xx_nic_core_fw_load()
2426 struct qla_hw_data *ha = vha->hw; in qla2x00_initialize_adapter()
2427 struct req_que *req = ha->req_q_map[0]; in qla2x00_initialize_adapter()
2428 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla2x00_initialize_adapter()
2430 memset(&vha->qla_stats, 0, sizeof(vha->qla_stats)); in qla2x00_initialize_adapter()
2431 memset(&vha->fc_host_stat, 0, sizeof(vha->fc_host_stat)); in qla2x00_initialize_adapter()
2434 vha->flags.online = 0; in qla2x00_initialize_adapter()
2435 ha->flags.chip_reset_done = 0; in qla2x00_initialize_adapter()
2436 vha->flags.reset_active = 0; in qla2x00_initialize_adapter()
2437 ha->flags.pci_channel_io_perm_failure = 0; in qla2x00_initialize_adapter()
2438 ha->flags.eeh_busy = 0; in qla2x00_initialize_adapter()
2439 vha->qla_stats.jiffies_at_last_reset = get_jiffies_64(); in qla2x00_initialize_adapter()
2440 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); in qla2x00_initialize_adapter()
2441 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_initialize_adapter()
2442 vha->device_flags = DFLG_NO_CABLE; in qla2x00_initialize_adapter()
2443 vha->dpc_flags = 0; in qla2x00_initialize_adapter()
2444 vha->flags.management_server_logged_in = 0; in qla2x00_initialize_adapter()
2445 vha->marker_needed = 0; in qla2x00_initialize_adapter()
2446 ha->isp_abort_cnt = 0; in qla2x00_initialize_adapter()
2447 ha->beacon_blink_led = 0; in qla2x00_initialize_adapter()
2449 set_bit(0, ha->req_qid_map); in qla2x00_initialize_adapter()
2450 set_bit(0, ha->rsp_qid_map); in qla2x00_initialize_adapter()
2454 rval = ha->isp_ops->pci_config(vha); in qla2x00_initialize_adapter()
2461 ha->isp_ops->reset_chip(vha); in qla2x00_initialize_adapter()
2465 if (rd_reg_word(®->mailbox12) & BIT_0) in qla2x00_initialize_adapter()
2466 ha->flags.secure_adapter = 1; in qla2x00_initialize_adapter()
2468 (ha->flags.secure_adapter) ? "Yes" : "No"); in qla2x00_initialize_adapter()
2490 ha->isp_ops->get_flash_version(vha, req->ring); in qla2x00_initialize_adapter()
2495 ha->fc4_type_priority = FC4_PRIORITY_FCP; in qla2x00_initialize_adapter()
2497 ha->isp_ops->nvram_config(vha); in qla2x00_initialize_adapter()
2499 if (ha->fc4_type_priority != FC4_PRIORITY_FCP && in qla2x00_initialize_adapter()
2500 ha->fc4_type_priority != FC4_PRIORITY_NVME) in qla2x00_initialize_adapter()
2501 ha->fc4_type_priority = FC4_PRIORITY_FCP; in qla2x00_initialize_adapter()
2504 ha->fc4_type_priority == FC4_PRIORITY_FCP ? "FCP" : "NVMe"); in qla2x00_initialize_adapter()
2506 if (ha->flags.disable_serdes) { in qla2x00_initialize_adapter()
2509 "Masking HBA WWPN %8phN (via NVRAM).\n", vha->port_name); in qla2x00_initialize_adapter()
2523 rval = ha->isp_ops->chip_diag(vha); in qla2x00_initialize_adapter()
2532 ha->cs84xx = qla84xx_get_chip(vha); in qla2x00_initialize_adapter()
2533 if (!ha->cs84xx) { in qla2x00_initialize_adapter()
2547 ha->flags.chip_reset_done = 1; in qla2x00_initialize_adapter()
2579 * qla2100_pci_config() - Setup ISP21xx PCI configuration registers.
2589 struct qla_hw_data *ha = vha->hw; in qla2100_pci_config()
2590 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2100_pci_config()
2592 pci_set_master(ha->pdev); in qla2100_pci_config()
2593 pci_try_set_mwi(ha->pdev); in qla2100_pci_config()
2595 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); in qla2100_pci_config()
2597 pci_write_config_word(ha->pdev, PCI_COMMAND, w); in qla2100_pci_config()
2599 pci_disable_rom(ha->pdev); in qla2100_pci_config()
2602 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2100_pci_config()
2603 ha->pci_attr = rd_reg_word(®->ctrl_status); in qla2100_pci_config()
2604 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2100_pci_config()
2610 * qla2300_pci_config() - Setup ISP23xx PCI configuration registers.
2621 struct qla_hw_data *ha = vha->hw; in qla2300_pci_config()
2622 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2300_pci_config()
2624 pci_set_master(ha->pdev); in qla2300_pci_config()
2625 pci_try_set_mwi(ha->pdev); in qla2300_pci_config()
2627 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); in qla2300_pci_config()
2632 pci_write_config_word(ha->pdev, PCI_COMMAND, w); in qla2300_pci_config()
2638 * fb revision level -- a 6 indicates it really is a 2300 and in qla2300_pci_config()
2642 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2300_pci_config()
2645 wrt_reg_word(®->hccr, HCCR_PAUSE_RISC); in qla2300_pci_config()
2647 if ((rd_reg_word(®->hccr) & HCCR_RISC_PAUSE) != 0) in qla2300_pci_config()
2654 wrt_reg_word(®->ctrl_status, 0x20); in qla2300_pci_config()
2655 rd_reg_word(®->ctrl_status); in qla2300_pci_config()
2658 ha->fb_rev = RD_FB_CMD_REG(ha, reg); in qla2300_pci_config()
2660 if (ha->fb_rev == FPM_2300) in qla2300_pci_config()
2661 pci_clear_mwi(ha->pdev); in qla2300_pci_config()
2664 wrt_reg_word(®->ctrl_status, 0x0); in qla2300_pci_config()
2665 rd_reg_word(®->ctrl_status); in qla2300_pci_config()
2668 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2300_pci_config()
2670 if ((rd_reg_word(®->hccr) & HCCR_RISC_PAUSE) == 0) in qla2300_pci_config()
2676 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2300_pci_config()
2679 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); in qla2300_pci_config()
2681 pci_disable_rom(ha->pdev); in qla2300_pci_config()
2684 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2300_pci_config()
2685 ha->pci_attr = rd_reg_word(®->ctrl_status); in qla2300_pci_config()
2686 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2300_pci_config()
2692 * qla24xx_pci_config() - Setup ISP24xx PCI configuration registers.
2702 struct qla_hw_data *ha = vha->hw; in qla24xx_pci_config()
2703 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla24xx_pci_config()
2705 pci_set_master(ha->pdev); in qla24xx_pci_config()
2706 pci_try_set_mwi(ha->pdev); in qla24xx_pci_config()
2708 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); in qla24xx_pci_config()
2711 pci_write_config_word(ha->pdev, PCI_COMMAND, w); in qla24xx_pci_config()
2713 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); in qla24xx_pci_config()
2715 /* PCI-X -- adjust Maximum Memory Read Byte Count (2048). */ in qla24xx_pci_config()
2716 if (pci_find_capability(ha->pdev, PCI_CAP_ID_PCIX)) in qla24xx_pci_config()
2717 pcix_set_mmrbc(ha->pdev, 2048); in qla24xx_pci_config()
2719 /* PCIe -- adjust Maximum Read Request Size (2048). */ in qla24xx_pci_config()
2720 if (pci_is_pcie(ha->pdev)) in qla24xx_pci_config()
2721 pcie_set_readrq(ha->pdev, 4096); in qla24xx_pci_config()
2723 pci_disable_rom(ha->pdev); in qla24xx_pci_config()
2725 ha->chip_revision = ha->pdev->revision; in qla24xx_pci_config()
2728 spin_lock_irqsave(&ha->hardware_lock, flags); in qla24xx_pci_config()
2729 ha->pci_attr = rd_reg_dword(®->ctrl_status); in qla24xx_pci_config()
2730 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_pci_config()
2736 * qla25xx_pci_config() - Setup ISP25xx PCI configuration registers.
2745 struct qla_hw_data *ha = vha->hw; in qla25xx_pci_config()
2747 pci_set_master(ha->pdev); in qla25xx_pci_config()
2748 pci_try_set_mwi(ha->pdev); in qla25xx_pci_config()
2750 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); in qla25xx_pci_config()
2753 pci_write_config_word(ha->pdev, PCI_COMMAND, w); in qla25xx_pci_config()
2755 /* PCIe -- adjust Maximum Read Request Size (2048). */ in qla25xx_pci_config()
2756 if (pci_is_pcie(ha->pdev)) in qla25xx_pci_config()
2757 pcie_set_readrq(ha->pdev, 4096); in qla25xx_pci_config()
2759 pci_disable_rom(ha->pdev); in qla25xx_pci_config()
2761 ha->chip_revision = ha->pdev->revision; in qla25xx_pci_config()
2767 * qla2x00_isp_firmware() - Choose firmware image.
2778 struct qla_hw_data *ha = vha->hw; in qla2x00_isp_firmware()
2783 if (ha->flags.disable_risc_code_load) { in qla2x00_isp_firmware()
2787 rval = qla2x00_verify_checksum(vha, ha->fw_srisc_address); in qla2x00_isp_firmware()
2803 * qla2x00_reset_chip() - Reset ISP chip.
2812 struct qla_hw_data *ha = vha->hw; in qla2x00_reset_chip()
2813 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_reset_chip()
2818 if (unlikely(pci_channel_offline(ha->pdev))) in qla2x00_reset_chip()
2821 ha->isp_ops->disable_intrs(ha); in qla2x00_reset_chip()
2823 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_reset_chip()
2827 pci_read_config_word(ha->pdev, PCI_COMMAND, &cmd); in qla2x00_reset_chip()
2829 pci_write_config_word(ha->pdev, PCI_COMMAND, cmd); in qla2x00_reset_chip()
2833 wrt_reg_word(®->hccr, HCCR_PAUSE_RISC); in qla2x00_reset_chip()
2836 if ((rd_reg_word(®->hccr) & in qla2x00_reset_chip()
2842 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2847 wrt_reg_word(®->ctrl_status, 0x20); in qla2x00_reset_chip()
2848 rd_reg_word(®->ctrl_status); /* PCI Posting. */ in qla2x00_reset_chip()
2851 wrt_reg_word(®->fpm_diag_config, 0x100); in qla2x00_reset_chip()
2852 rd_reg_word(®->fpm_diag_config); /* PCI Posting. */ in qla2x00_reset_chip()
2856 wrt_reg_word(®->fpm_diag_config, 0x0); in qla2x00_reset_chip()
2857 rd_reg_word(®->fpm_diag_config); /* PCI Posting. */ in qla2x00_reset_chip()
2861 wrt_reg_word(®->ctrl_status, 0x10); in qla2x00_reset_chip()
2862 rd_reg_word(®->ctrl_status); /* PCI Posting. */ in qla2x00_reset_chip()
2880 wrt_reg_word(®->ctrl_status, 0); in qla2x00_reset_chip()
2881 rd_reg_word(®->ctrl_status); /* PCI Posting. */ in qla2x00_reset_chip()
2884 wrt_reg_word(®->hccr, HCCR_RESET_RISC); in qla2x00_reset_chip()
2885 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2888 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2x00_reset_chip()
2889 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2892 wrt_reg_word(®->hccr, HCCR_CLR_RISC_INT); in qla2x00_reset_chip()
2893 wrt_reg_word(®->hccr, HCCR_CLR_HOST_INT); in qla2x00_reset_chip()
2896 wrt_reg_word(®->ctrl_status, CSR_ISP_SOFT_RESET); in qla2x00_reset_chip()
2906 for (cnt = 30000; cnt; cnt--) { in qla2x00_reset_chip()
2907 if ((rd_reg_word(®->ctrl_status) & in qla2x00_reset_chip()
2916 wrt_reg_word(®->hccr, HCCR_RESET_RISC); in qla2x00_reset_chip()
2918 wrt_reg_word(®->semaphore, 0); in qla2x00_reset_chip()
2921 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2x00_reset_chip()
2922 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2936 pci_write_config_word(ha->pdev, PCI_COMMAND, cmd); in qla2x00_reset_chip()
2940 wrt_reg_word(®->hccr, HCCR_DISABLE_PARITY_PAUSE); in qla2x00_reset_chip()
2941 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2944 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_reset_chip()
2950 * qla81xx_reset_mpi() - Reset's MPI FW via Write MPI Register MBC.
2960 if (!IS_QLA81XX(vha->hw)) in qla81xx_reset_mpi()
2969 struct qla_hw_data *ha = vha->hw; in qla_chk_risc_recovery()
2970 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla_chk_risc_recovery()
2971 __le16 __iomem *mbptr = ®->mailbox0; in qla_chk_risc_recovery()
2991 "RISC reset failed. mb[0-7] %04xh %04xh %04xh %04xh %04xh %04xh %04xh %04xh\n", in qla_chk_risc_recovery()
2994 "RISC reset failed. mb[8-15] %04xh %04xh %04xh %04xh %04xh %04xh %04xh %04xh\n", in qla_chk_risc_recovery()
2998 "RISC reset failed. mb[16-23] %04xh %04xh %04xh %04xh %04xh %04xh %04xh %04xh\n", in qla_chk_risc_recovery()
3002 "RISC reset failed. mb[24-31] %04xh %04xh %04xh %04xh %04xh %04xh %04xh %04xh\n", in qla_chk_risc_recovery()
3010 * qla24xx_reset_risc() - Perform full reset of ISP24xx RISC.
3019 struct qla_hw_data *ha = vha->hw; in qla24xx_reset_risc()
3020 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla24xx_reset_risc()
3027 spin_lock_irqsave(&ha->hardware_lock, flags); in qla24xx_reset_risc()
3030 wrt_reg_dword(®->ctrl_status, CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); in qla24xx_reset_risc()
3032 if ((rd_reg_dword(®->ctrl_status) & CSRX_DMA_ACTIVE) == 0) in qla24xx_reset_risc()
3038 if (!(rd_reg_dword(®->ctrl_status) & CSRX_DMA_ACTIVE)) in qla24xx_reset_risc()
3039 set_bit(DMA_SHUTDOWN_CMPL, &ha->fw_dump_cap_flags); in qla24xx_reset_risc()
3043 rd_reg_dword(®->hccr), in qla24xx_reset_risc()
3044 rd_reg_dword(®->ctrl_status), in qla24xx_reset_risc()
3045 (rd_reg_dword(®->ctrl_status) & CSRX_DMA_ACTIVE)); in qla24xx_reset_risc()
3047 wrt_reg_dword(®->ctrl_status, in qla24xx_reset_risc()
3049 pci_read_config_word(ha->pdev, PCI_COMMAND, &wd); in qla24xx_reset_risc()
3054 rd_reg_word(®->mailbox0); in qla24xx_reset_risc()
3055 for (cnt = 10000; rd_reg_word(®->mailbox0) != 0 && in qla24xx_reset_risc()
3056 rval == QLA_SUCCESS; cnt--) { in qla24xx_reset_risc()
3065 set_bit(ISP_MBX_RDY, &ha->fw_dump_cap_flags); in qla24xx_reset_risc()
3069 rd_reg_dword(®->hccr), in qla24xx_reset_risc()
3070 rd_reg_word(®->mailbox0)); in qla24xx_reset_risc()
3072 /* Wait for soft-reset to complete. */ in qla24xx_reset_risc()
3073 rd_reg_dword(®->ctrl_status); in qla24xx_reset_risc()
3076 if ((rd_reg_dword(®->ctrl_status) & in qla24xx_reset_risc()
3082 if (!(rd_reg_dword(®->ctrl_status) & CSRX_ISP_SOFT_RESET)) in qla24xx_reset_risc()
3083 set_bit(ISP_SOFT_RESET_CMPL, &ha->fw_dump_cap_flags); in qla24xx_reset_risc()
3087 rd_reg_dword(®->hccr), in qla24xx_reset_risc()
3088 rd_reg_dword(®->ctrl_status)); in qla24xx_reset_risc()
3091 if (test_and_clear_bit(MPI_RESET_NEEDED, &vha->dpc_flags)) { in qla24xx_reset_risc()
3094 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla24xx_reset_risc()
3095 set_bit(MPI_RESET_NEEDED, &vha->dpc_flags); in qla24xx_reset_risc()
3102 vha->flags.online = 0; in qla24xx_reset_risc()
3107 wrt_reg_dword(®->hccr, HCCRX_SET_RISC_RESET); in qla24xx_reset_risc()
3108 rd_reg_dword(®->hccr); in qla24xx_reset_risc()
3110 wrt_reg_dword(®->hccr, HCCRX_REL_RISC_PAUSE); in qla24xx_reset_risc()
3111 rd_reg_dword(®->hccr); in qla24xx_reset_risc()
3113 wrt_reg_dword(®->hccr, HCCRX_CLR_RISC_RESET); in qla24xx_reset_risc()
3115 rd_reg_dword(®->hccr); in qla24xx_reset_risc()
3117 wd = rd_reg_word(®->mailbox0); in qla24xx_reset_risc()
3118 for (cnt = 300; wd != 0 && rval == QLA_SUCCESS; cnt--) { in qla24xx_reset_risc()
3125 wd = rd_reg_word(®->mailbox0); in qla24xx_reset_risc()
3135 set_bit(RISC_RDY_AFT_RESET, &ha->fw_dump_cap_flags); in qla24xx_reset_risc()
3139 rd_reg_dword(®->hccr), in qla24xx_reset_risc()
3140 rd_reg_word(®->mailbox0)); in qla24xx_reset_risc()
3142 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_reset_risc()
3149 ha->isp_ops->enable_intrs(ha); in qla24xx_reset_risc()
3157 struct device_reg_24xx __iomem *reg = &vha->hw->iobase->isp24; in qla25xx_read_risc_sema_reg()
3159 wrt_reg_dword(®->iobase_addr, RISC_REGISTER_BASE_OFFSET); in qla25xx_read_risc_sema_reg()
3160 *data = rd_reg_dword(®->iobase_window + RISC_REGISTER_WINDOW_OFFSET); in qla25xx_read_risc_sema_reg()
3166 struct device_reg_24xx __iomem *reg = &vha->hw->iobase->isp24; in qla25xx_write_risc_sema_reg()
3168 wrt_reg_dword(®->iobase_addr, RISC_REGISTER_BASE_OFFSET); in qla25xx_write_risc_sema_reg()
3169 wrt_reg_dword(®->iobase_window + RISC_REGISTER_WINDOW_OFFSET, data); in qla25xx_write_risc_sema_reg()
3181 if (vha->hw->pdev->subsystem_device != 0x0175 && in qla25xx_manipulate_risc_semaphore()
3182 vha->hw->pdev->subsystem_device != 0x0240) in qla25xx_manipulate_risc_semaphore()
3185 wrt_reg_dword(&vha->hw->iobase->isp24.hccr, HCCRX_SET_RISC_PAUSE); in qla25xx_manipulate_risc_semaphore()
3191 while (n--) { in qla25xx_manipulate_risc_semaphore()
3211 while (n--) { in qla25xx_manipulate_risc_semaphore()
3234 * qla24xx_reset_chip() - Reset ISP24xx chip.
3242 struct qla_hw_data *ha = vha->hw; in qla24xx_reset_chip()
3245 if (pci_channel_offline(ha->pdev) && in qla24xx_reset_chip()
3246 ha->flags.pci_channel_io_perm_failure) { in qla24xx_reset_chip()
3250 ha->isp_ops->disable_intrs(ha); in qla24xx_reset_chip()
3261 * qla2x00_chip_diag() - Test chip for proper operation.
3270 struct qla_hw_data *ha = vha->hw; in qla2x00_chip_diag()
3271 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_chip_diag()
3276 struct req_que *req = ha->req_q_map[0]; in qla2x00_chip_diag()
3282 ®->flash_address); in qla2x00_chip_diag()
3284 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_chip_diag()
3287 wrt_reg_word(®->ctrl_status, CSR_ISP_SOFT_RESET); in qla2x00_chip_diag()
3294 data = qla2x00_debounce_register(®->ctrl_status); in qla2x00_chip_diag()
3295 for (cnt = 6000000 ; cnt && (data & CSR_ISP_SOFT_RESET); cnt--) { in qla2x00_chip_diag()
3297 data = rd_reg_word(®->ctrl_status); in qla2x00_chip_diag()
3308 wrt_reg_word(®->hccr, HCCR_RESET_RISC); in qla2x00_chip_diag()
3309 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2x00_chip_diag()
3314 for (cnt = 6000000; cnt && (data == MBS_BUSY); cnt--) { in qla2x00_chip_diag()
3340 ha->product_id[0] = mb[1]; in qla2x00_chip_diag()
3341 ha->product_id[1] = mb[2]; in qla2x00_chip_diag()
3342 ha->product_id[2] = mb[3]; in qla2x00_chip_diag()
3343 ha->product_id[3] = mb[4]; in qla2x00_chip_diag()
3346 if (req->length > 1024) in qla2x00_chip_diag()
3347 ha->fw_transfer_size = REQUEST_ENTRY_SIZE * 1024; in qla2x00_chip_diag()
3349 ha->fw_transfer_size = REQUEST_ENTRY_SIZE * in qla2x00_chip_diag()
3350 req->length; in qla2x00_chip_diag()
3357 ha->device_type |= DT_ISP2200A; in qla2x00_chip_diag()
3358 ha->fw_transfer_size = 128; in qla2x00_chip_diag()
3362 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_chip_diag()
3372 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_chip_diag()
3379 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_chip_diag()
3385 * qla24xx_chip_diag() - Test ISP24xx for proper operation.
3394 struct qla_hw_data *ha = vha->hw; in qla24xx_chip_diag()
3395 struct req_que *req = ha->req_q_map[0]; in qla24xx_chip_diag()
3400 ha->fw_transfer_size = REQUEST_ENTRY_SIZE * req->length; in qla24xx_chip_diag()
3420 struct qla_hw_data *ha = vha->hw; in qla2x00_init_fce_trace()
3429 if (ha->fce) { in qla2x00_init_fce_trace()
3437 tc = dma_alloc_coherent(&ha->pdev->dev, FCE_SIZE, &tc_dma, in qla2x00_init_fce_trace()
3447 ha->fce_mb, &ha->fce_bufs); in qla2x00_init_fce_trace()
3451 dma_free_coherent(&ha->pdev->dev, FCE_SIZE, tc, tc_dma); in qla2x00_init_fce_trace()
3458 ha->flags.fce_enabled = 1; in qla2x00_init_fce_trace()
3459 ha->fce_dma = tc_dma; in qla2x00_init_fce_trace()
3460 ha->fce = tc; in qla2x00_init_fce_trace()
3469 struct qla_hw_data *ha = vha->hw; in qla2x00_init_eft_trace()
3474 if (ha->eft) { in qla2x00_init_eft_trace()
3482 tc = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &tc_dma, in qla2x00_init_eft_trace()
3495 dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc, tc_dma); in qla2x00_init_eft_trace()
3502 ha->eft_dma = tc_dma; in qla2x00_init_eft_trace()
3503 ha->eft = tc; in qla2x00_init_eft_trace()
3518 struct qla_hw_data *ha = vha->hw; in qla2x00_alloc_fw_dump()
3519 struct req_que *req = ha->req_q_map[0]; in qla2x00_alloc_fw_dump()
3520 struct rsp_que *rsp = ha->rsp_q_map[0]; in qla2x00_alloc_fw_dump()
3523 if (ha->fw_dump) { in qla2x00_alloc_fw_dump()
3529 ha->fw_dumped = 0; in qla2x00_alloc_fw_dump()
3530 ha->fw_dump_cap_flags = 0; in qla2x00_alloc_fw_dump()
3538 mem_size = (ha->fw_memory_size - 0x11000 + 1) * in qla2x00_alloc_fw_dump()
3550 mem_size = (ha->fw_memory_size - 0x100000 + 1) * in qla2x00_alloc_fw_dump()
3552 if (ha->mqenable) { in qla2x00_alloc_fw_dump()
3556 * Allocate maximum buffer size for all queues - Q0. in qla2x00_alloc_fw_dump()
3557 * Resizing must be done at end-of-dump processing. in qla2x00_alloc_fw_dump()
3559 mq_size += (ha->max_req_queues - 1) * in qla2x00_alloc_fw_dump()
3560 (req->length * sizeof(request_t)); in qla2x00_alloc_fw_dump()
3561 mq_size += (ha->max_rsp_queues - 1) * in qla2x00_alloc_fw_dump()
3562 (rsp->length * sizeof(response_t)); in qla2x00_alloc_fw_dump()
3564 if (ha->tgt.atio_ring) in qla2x00_alloc_fw_dump()
3565 mq_size += ha->tgt.atio_q_length * sizeof(request_t); in qla2x00_alloc_fw_dump()
3568 if (ha->fce) in qla2x00_alloc_fw_dump()
3571 if (ha->eft) in qla2x00_alloc_fw_dump()
3576 struct fwdt *fwdt = ha->fwdt; in qla2x00_alloc_fw_dump()
3580 if (!fwdt->template) { in qla2x00_alloc_fw_dump()
3582 "-> fwdt%u no template\n", j); in qla2x00_alloc_fw_dump()
3586 "-> fwdt%u calculating fwdump size...\n", j); in qla2x00_alloc_fw_dump()
3587 fwdt->dump_size = qla27xx_fwdt_calculate_dump_size( in qla2x00_alloc_fw_dump()
3588 vha, fwdt->template); in qla2x00_alloc_fw_dump()
3590 "-> fwdt%u calculated fwdump size = %#lx bytes\n", in qla2x00_alloc_fw_dump()
3591 j, fwdt->dump_size); in qla2x00_alloc_fw_dump()
3592 dump_size += fwdt->dump_size; in qla2x00_alloc_fw_dump()
3595 dump_size += ha->fwdt[1].dump_size; in qla2x00_alloc_fw_dump()
3597 req_q_size = req->length * sizeof(request_t); in qla2x00_alloc_fw_dump()
3598 rsp_q_size = rsp->length * sizeof(response_t); in qla2x00_alloc_fw_dump()
3602 ha->chain_offset = dump_size; in qla2x00_alloc_fw_dump()
3604 if (ha->exchoffld_buf) in qla2x00_alloc_fw_dump()
3606 ha->exchoffld_size; in qla2x00_alloc_fw_dump()
3607 if (ha->exlogin_buf) in qla2x00_alloc_fw_dump()
3609 ha->exlogin_size; in qla2x00_alloc_fw_dump()
3612 if (!ha->fw_dump_len || dump_size > ha->fw_dump_alloc_len) { in qla2x00_alloc_fw_dump()
3616 __func__, dump_size, ha->fw_dump_len, in qla2x00_alloc_fw_dump()
3617 ha->fw_dump_alloc_len); in qla2x00_alloc_fw_dump()
3625 mutex_lock(&ha->optrom_mutex); in qla2x00_alloc_fw_dump()
3626 if (ha->fw_dumped) { in qla2x00_alloc_fw_dump()
3627 memcpy(fw_dump, ha->fw_dump, ha->fw_dump_len); in qla2x00_alloc_fw_dump()
3628 vfree(ha->fw_dump); in qla2x00_alloc_fw_dump()
3629 ha->fw_dump = fw_dump; in qla2x00_alloc_fw_dump()
3630 ha->fw_dump_alloc_len = dump_size; in qla2x00_alloc_fw_dump()
3632 "Re-Allocated (%d KB) and save firmware dump.\n", in qla2x00_alloc_fw_dump()
3635 vfree(ha->fw_dump); in qla2x00_alloc_fw_dump()
3636 ha->fw_dump = fw_dump; in qla2x00_alloc_fw_dump()
3638 ha->fw_dump_len = ha->fw_dump_alloc_len = in qla2x00_alloc_fw_dump()
3645 ha->mpi_fw_dump = (char *)fw_dump + in qla2x00_alloc_fw_dump()
3646 ha->fwdt[1].dump_size; in qla2x00_alloc_fw_dump()
3647 mutex_unlock(&ha->optrom_mutex); in qla2x00_alloc_fw_dump()
3651 ha->fw_dump->signature[0] = 'Q'; in qla2x00_alloc_fw_dump()
3652 ha->fw_dump->signature[1] = 'L'; in qla2x00_alloc_fw_dump()
3653 ha->fw_dump->signature[2] = 'G'; in qla2x00_alloc_fw_dump()
3654 ha->fw_dump->signature[3] = 'C'; in qla2x00_alloc_fw_dump()
3655 ha->fw_dump->version = htonl(1); in qla2x00_alloc_fw_dump()
3657 ha->fw_dump->fixed_size = htonl(fixed_size); in qla2x00_alloc_fw_dump()
3658 ha->fw_dump->mem_size = htonl(mem_size); in qla2x00_alloc_fw_dump()
3659 ha->fw_dump->req_q_size = htonl(req_q_size); in qla2x00_alloc_fw_dump()
3660 ha->fw_dump->rsp_q_size = htonl(rsp_q_size); in qla2x00_alloc_fw_dump()
3662 ha->fw_dump->eft_size = htonl(eft_size); in qla2x00_alloc_fw_dump()
3663 ha->fw_dump->eft_addr_l = in qla2x00_alloc_fw_dump()
3664 htonl(LSD(ha->eft_dma)); in qla2x00_alloc_fw_dump()
3665 ha->fw_dump->eft_addr_h = in qla2x00_alloc_fw_dump()
3666 htonl(MSD(ha->eft_dma)); in qla2x00_alloc_fw_dump()
3668 ha->fw_dump->header_size = in qla2x00_alloc_fw_dump()
3672 mutex_unlock(&ha->optrom_mutex); in qla2x00_alloc_fw_dump()
3685 if (!IS_QLA81XX(vha->hw)) in qla81xx_mpi_sync()
3695 pci_read_config_word(vha->hw->pdev, 0x54, &dc); in qla81xx_mpi_sync()
3728 if (req->outstanding_cmds) in qla2x00_alloc_outstanding_cmds()
3732 req->num_outstanding_cmds = DEFAULT_OUTSTANDING_COMMANDS; in qla2x00_alloc_outstanding_cmds()
3734 if (ha->cur_fw_xcb_count <= ha->cur_fw_iocb_count) in qla2x00_alloc_outstanding_cmds()
3735 req->num_outstanding_cmds = ha->cur_fw_xcb_count; in qla2x00_alloc_outstanding_cmds()
3737 req->num_outstanding_cmds = ha->cur_fw_iocb_count; in qla2x00_alloc_outstanding_cmds()
3740 req->outstanding_cmds = kcalloc(req->num_outstanding_cmds, in qla2x00_alloc_outstanding_cmds()
3744 if (!req->outstanding_cmds) { in qla2x00_alloc_outstanding_cmds()
3749 req->num_outstanding_cmds = MIN_OUTSTANDING_COMMANDS; in qla2x00_alloc_outstanding_cmds()
3750 req->outstanding_cmds = kcalloc(req->num_outstanding_cmds, in qla2x00_alloc_outstanding_cmds()
3754 if (!req->outstanding_cmds) { in qla2x00_alloc_outstanding_cmds()
3758 req->num_outstanding_cmds = 0; in qla2x00_alloc_outstanding_cmds()
3767 if (a0->_field & _flag) {\
3771 leftover--;\
3775 leftover -= len;\
3783 struct sff_8247_a0 *a0 = (struct sff_8247_a0 *)vha->hw->sfp_data; in qla2xxx_print_sfp_info()
3788 snprintf(str, SFF_VEN_NAME_LEN+1, a0->vendor_name); in qla2xxx_print_sfp_info()
3793 snprintf(str, SFF_PART_NAME_LEN+1, a0->vendor_pn); in qla2xxx_print_sfp_info()
3837 if (a0->length_km) in qla2xxx_print_sfp_info()
3839 "SFP Distant: %d km\n", a0->length_km); in qla2xxx_print_sfp_info()
3840 if (a0->length_100m) in qla2xxx_print_sfp_info()
3842 "SFP Distant: %d m\n", a0->length_100m*100); in qla2xxx_print_sfp_info()
3843 if (a0->length_50um_10m) in qla2xxx_print_sfp_info()
3845 "SFP Distant (WL=50um): %d m\n", a0->length_50um_10m * 10); in qla2xxx_print_sfp_info()
3846 if (a0->length_62um_10m) in qla2xxx_print_sfp_info()
3848 "SFP Distant (WL=62.5um): %d m\n", a0->length_62um_10m * 10); in qla2xxx_print_sfp_info()
3849 if (a0->length_om4_10m) in qla2xxx_print_sfp_info()
3851 "SFP Distant (OM4): %d m\n", a0->length_om4_10m * 10); in qla2xxx_print_sfp_info()
3852 if (a0->length_om3_10m) in qla2xxx_print_sfp_info()
3854 "SFP Distant (OM3): %d m\n", a0->length_om3_10m * 10); in qla2xxx_print_sfp_info()
3864 * 0 -- Configure firmware to use short-range settings -- normal
3865 * buffer-to-buffer credits.
3867 * 1 -- Configure firmware to use long-range settings -- extra
3868 * buffer-to-buffer credits should be allocated with
3869 * ha->lr_distance containing distance settings from NVRAM or SFP
3877 struct qla_hw_data *ha = vha->hw; in qla24xx_detect_sfp()
3878 struct nvram_81xx *nv = ha->nvram; in qla24xx_detect_sfp()
3886 ha->flags.lr_detected = 0; in qla24xx_detect_sfp()
3888 (nv->enhanced_features & NEF_LR_DIST_ENABLE)) { in qla24xx_detect_sfp()
3890 ha->flags.lr_detected = 1; in qla24xx_detect_sfp()
3891 ha->lr_distance = in qla24xx_detect_sfp()
3892 (nv->enhanced_features >> LR_DIST_NV_POS) in qla24xx_detect_sfp()
3904 a = (struct sff_8247_a0 *)vha->hw->sfp_data; in qla24xx_detect_sfp()
3907 ha->flags.lr_detected = 0; in qla24xx_detect_sfp()
3908 ll = a->fc_ll_cc7; in qla24xx_detect_sfp()
3911 ha->flags.lr_detected = 1; in qla24xx_detect_sfp()
3913 if (a->length_km > 5 || a->length_100m > 50) in qla24xx_detect_sfp()
3914 ha->lr_distance = LR_DISTANCE_10K; in qla24xx_detect_sfp()
3916 ha->lr_distance = LR_DISTANCE_5K; in qla24xx_detect_sfp()
3921 "SFP detect: %s-Range SFP %s (nvr=%x ll=%x lr=%x lrd=%x).\n", in qla24xx_detect_sfp()
3922 types[ha->flags.lr_detected], in qla24xx_detect_sfp()
3923 ha->flags.lr_detected ? lengths[ha->lr_distance] : in qla24xx_detect_sfp()
3925 used_nvram, ll, ha->flags.lr_detected, ha->lr_distance); in qla24xx_detect_sfp()
3926 return ha->flags.lr_detected; in qla24xx_detect_sfp()
3933 struct qla_hw_data *ha = vha->hw; in qla_init_iocb_limit()
3935 num_qps = ha->num_qpairs + 1; in qla_init_iocb_limit()
3936 limit = (ha->orig_fw_iocb_count * QLA_IOCB_PCT_LIMIT) / 100; in qla_init_iocb_limit()
3938 ha->base_qpair->fwres.iocbs_total = ha->orig_fw_iocb_count; in qla_init_iocb_limit()
3939 ha->base_qpair->fwres.iocbs_limit = limit; in qla_init_iocb_limit()
3940 ha->base_qpair->fwres.iocbs_qp_limit = limit / num_qps; in qla_init_iocb_limit()
3941 ha->base_qpair->fwres.iocbs_used = 0; in qla_init_iocb_limit()
3942 for (i = 0; i < ha->max_qpairs; i++) { in qla_init_iocb_limit()
3943 if (ha->queue_pair_map[i]) { in qla_init_iocb_limit()
3944 ha->queue_pair_map[i]->fwres.iocbs_total = in qla_init_iocb_limit()
3945 ha->orig_fw_iocb_count; in qla_init_iocb_limit()
3946 ha->queue_pair_map[i]->fwres.iocbs_limit = limit; in qla_init_iocb_limit()
3947 ha->queue_pair_map[i]->fwres.iocbs_qp_limit = in qla_init_iocb_limit()
3949 ha->queue_pair_map[i]->fwres.iocbs_used = 0; in qla_init_iocb_limit()
3955 * qla2x00_setup_chip() - Load and start RISC firmware.
3965 struct qla_hw_data *ha = vha->hw; in qla2x00_setup_chip()
3966 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_setup_chip()
3972 rval = ha->isp_ops->load_risc(vha, &srisc_address); in qla2x00_setup_chip()
3982 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_setup_chip()
3983 wrt_reg_word(®->hccr, (HCCR_ENABLE_PARITY + 0x0)); in qla2x00_setup_chip()
3984 rd_reg_word(®->hccr); in qla2x00_setup_chip()
3985 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_setup_chip()
3992 rval = ha->isp_ops->load_risc(vha, &srisc_address); in qla2x00_setup_chip()
4004 ha->flags.exlogins_enabled = 1; in qla2x00_setup_chip()
4007 ha->flags.exchoffld_enabled = 1; in qla2x00_setup_chip()
4015 "Re-starting firmware -- BPM.\n"); in qla2x00_setup_chip()
4016 /* Best-effort - re-init. */ in qla2x00_setup_chip()
4017 ha->isp_ops->reset_chip(vha); in qla2x00_setup_chip()
4018 ha->isp_ops->chip_diag(vha); in qla2x00_setup_chip()
4024 ha->last_zio_threshold); in qla2x00_setup_chip()
4035 fw_major_version = ha->fw_major_version; in qla2x00_setup_chip()
4042 ha->flags.npiv_supported = 0; in qla2x00_setup_chip()
4044 (ha->fw_attributes & BIT_2)) { in qla2x00_setup_chip()
4045 ha->flags.npiv_supported = 1; in qla2x00_setup_chip()
4046 if ((!ha->max_npiv_vports) || in qla2x00_setup_chip()
4047 ((ha->max_npiv_vports + 1) % in qla2x00_setup_chip()
4049 ha->max_npiv_vports = in qla2x00_setup_chip()
4050 MIN_MULTI_ID_FABRIC - 1; in qla2x00_setup_chip()
4060 vha->req); in qla2x00_setup_chip()
4080 if (ql2xrdpenable || ha->flags.scm_supported_f || in qla2x00_setup_chip()
4081 ha->flags.edif_enabled) in qla2x00_setup_chip()
4088 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_setup_chip()
4091 wrt_reg_word(®->hccr, HCCR_ENABLE_PARITY + 0x1); in qla2x00_setup_chip()
4094 wrt_reg_word(®->hccr, HCCR_ENABLE_PARITY + 0x7); in qla2x00_setup_chip()
4095 rd_reg_word(®->hccr); in qla2x00_setup_chip()
4096 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_setup_chip()
4100 ha->flags.fac_supported = 1; in qla2x00_setup_chip()
4106 ha->flags.fac_supported = 1; in qla2x00_setup_chip()
4107 ha->fdt_block_size = size << 2; in qla2x00_setup_chip()
4111 ha->fw_major_version, ha->fw_minor_version, in qla2x00_setup_chip()
4112 ha->fw_subminor_version); in qla2x00_setup_chip()
4115 ha->flags.fac_supported = 0; in qla2x00_setup_chip()
4130 * qla2x00_init_response_q_entries() - Initializes response queue entries.
4144 rsp->ring_ptr = rsp->ring; in qla2x00_init_response_q_entries()
4145 rsp->ring_index = 0; in qla2x00_init_response_q_entries()
4146 rsp->status_srb = NULL; in qla2x00_init_response_q_entries()
4147 pkt = rsp->ring_ptr; in qla2x00_init_response_q_entries()
4148 for (cnt = 0; cnt < rsp->length; cnt++) { in qla2x00_init_response_q_entries()
4149 pkt->signature = RESPONSE_PROCESSED; in qla2x00_init_response_q_entries()
4155 * qla2x00_update_fw_options() - Read and process firmware options.
4164 struct qla_hw_data *ha = vha->hw; in qla2x00_update_fw_options()
4166 memset(ha->fw_options, 0, sizeof(ha->fw_options)); in qla2x00_update_fw_options()
4167 qla2x00_get_fw_options(vha, ha->fw_options); in qla2x00_update_fw_options()
4176 ha->fw_seriallink_options, sizeof(ha->fw_seriallink_options)); in qla2x00_update_fw_options()
4178 ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING; in qla2x00_update_fw_options()
4179 if (ha->fw_seriallink_options[3] & BIT_2) { in qla2x00_update_fw_options()
4180 ha->fw_options[1] |= FO1_SET_EMPHASIS_SWING; in qla2x00_update_fw_options()
4183 swing = ha->fw_seriallink_options[2] & (BIT_2 | BIT_1 | BIT_0); in qla2x00_update_fw_options()
4184 emphasis = (ha->fw_seriallink_options[2] & in qla2x00_update_fw_options()
4186 tx_sens = ha->fw_seriallink_options[0] & in qla2x00_update_fw_options()
4188 rx_sens = (ha->fw_seriallink_options[0] & in qla2x00_update_fw_options()
4190 ha->fw_options[10] = (emphasis << 14) | (swing << 8); in qla2x00_update_fw_options()
4194 ha->fw_options[10] |= (tx_sens << 4) | rx_sens; in qla2x00_update_fw_options()
4196 ha->fw_options[10] |= BIT_5 | in qla2x00_update_fw_options()
4201 swing = (ha->fw_seriallink_options[2] & in qla2x00_update_fw_options()
4203 emphasis = ha->fw_seriallink_options[3] & (BIT_1 | BIT_0); in qla2x00_update_fw_options()
4204 tx_sens = ha->fw_seriallink_options[1] & in qla2x00_update_fw_options()
4206 rx_sens = (ha->fw_seriallink_options[1] & in qla2x00_update_fw_options()
4208 ha->fw_options[11] = (emphasis << 14) | (swing << 8); in qla2x00_update_fw_options()
4212 ha->fw_options[11] |= (tx_sens << 4) | rx_sens; in qla2x00_update_fw_options()
4214 ha->fw_options[11] |= BIT_5 | in qla2x00_update_fw_options()
4221 ha->fw_options[3] |= BIT_13; in qla2x00_update_fw_options()
4224 if (ha->flags.enable_led_scheme) in qla2x00_update_fw_options()
4225 ha->fw_options[2] |= BIT_12; in qla2x00_update_fw_options()
4229 ha->fw_options[2] |= BIT_13; in qla2x00_update_fw_options()
4232 if (ha->operating_mode == P2P) { in qla2x00_update_fw_options()
4233 ha->fw_options[2] |= BIT_3; in qla2x00_update_fw_options()
4236 __func__, ha->fw_options[2]); in qla2x00_update_fw_options()
4240 qla2x00_set_fw_options(vha, ha->fw_options); in qla2x00_update_fw_options()
4247 struct qla_hw_data *ha = vha->hw; in qla24xx_update_fw_options()
4254 ha->fw_options[3] |= BIT_12; in qla24xx_update_fw_options()
4257 if (ha->operating_mode == P2P) { in qla24xx_update_fw_options()
4258 ha->fw_options[2] |= BIT_3; in qla24xx_update_fw_options()
4261 __func__, ha->fw_options[2]); in qla24xx_update_fw_options()
4264 /* Move PUREX, ABTS RX & RIDA to ATIOQ */ in qla24xx_update_fw_options()
4265 if (ql2xmvasynctoatio && !ha->flags.edif_enabled && in qla24xx_update_fw_options()
4269 ha->fw_options[2] |= BIT_11; in qla24xx_update_fw_options()
4271 ha->fw_options[2] &= ~BIT_11; in qla24xx_update_fw_options()
4282 ha->fw_options[2] |= BIT_4; in qla24xx_update_fw_options()
4284 ha->fw_options[2] &= ~(BIT_4); in qla24xx_update_fw_options()
4288 ha->fw_options[2] |= BIT_8; in qla24xx_update_fw_options()
4290 ha->fw_options[2] &= ~BIT_8; in qla24xx_update_fw_options()
4296 if (ha->flags.edif_enabled && in qla24xx_update_fw_options()
4298 ha->fw_options[3] |= BIT_15; in qla24xx_update_fw_options()
4299 ha->flags.n2n_fw_acc_sec = 1; in qla24xx_update_fw_options()
4301 ha->fw_options[3] &= ~BIT_15; in qla24xx_update_fw_options()
4302 ha->flags.n2n_fw_acc_sec = 0; in qla24xx_update_fw_options()
4306 if (ql2xrdpenable || ha->flags.scm_supported_f || in qla24xx_update_fw_options()
4307 ha->flags.edif_enabled) in qla24xx_update_fw_options()
4308 ha->fw_options[1] |= ADD_FO1_ENABLE_PUREX_IOCB; in qla24xx_update_fw_options()
4310 /* Enable Async 8130/8131 events -- transceiver insertion/removal */ in qla24xx_update_fw_options()
4312 ha->fw_options[3] |= BIT_10; in qla24xx_update_fw_options()
4315 "%s, add FW options 1-3 = 0x%04x 0x%04x 0x%04x mode %x\n", in qla24xx_update_fw_options()
4316 __func__, ha->fw_options[1], ha->fw_options[2], in qla24xx_update_fw_options()
4317 ha->fw_options[3], vha->host->active_mode); in qla24xx_update_fw_options()
4319 if (ha->fw_options[1] || ha->fw_options[2] || ha->fw_options[3]) in qla24xx_update_fw_options()
4320 qla2x00_set_fw_options(vha, ha->fw_options); in qla24xx_update_fw_options()
4323 if ((le16_to_cpu(ha->fw_seriallink_options24[0]) & BIT_0) == 0) in qla24xx_update_fw_options()
4327 le16_to_cpu(ha->fw_seriallink_options24[1]), in qla24xx_update_fw_options()
4328 le16_to_cpu(ha->fw_seriallink_options24[2]), in qla24xx_update_fw_options()
4329 le16_to_cpu(ha->fw_seriallink_options24[3])); in qla24xx_update_fw_options()
4339 struct qla_hw_data *ha = vha->hw; in qla2x00_config_rings()
4340 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_config_rings()
4341 struct req_que *req = ha->req_q_map[0]; in qla2x00_config_rings()
4342 struct rsp_que *rsp = ha->rsp_q_map[0]; in qla2x00_config_rings()
4345 ha->init_cb->request_q_outpointer = cpu_to_le16(0); in qla2x00_config_rings()
4346 ha->init_cb->response_q_inpointer = cpu_to_le16(0); in qla2x00_config_rings()
4347 ha->init_cb->request_q_length = cpu_to_le16(req->length); in qla2x00_config_rings()
4348 ha->init_cb->response_q_length = cpu_to_le16(rsp->length); in qla2x00_config_rings()
4349 put_unaligned_le64(req->dma, &ha->init_cb->request_q_address); in qla2x00_config_rings()
4350 put_unaligned_le64(rsp->dma, &ha->init_cb->response_q_address); in qla2x00_config_rings()
4362 struct qla_hw_data *ha = vha->hw; in qla24xx_config_rings()
4364 struct device_reg_2xxx __iomem *ioreg = &ha->iobase->isp; in qla24xx_config_rings()
4368 struct req_que *req = ha->req_q_map[0]; in qla24xx_config_rings()
4369 struct rsp_que *rsp = ha->rsp_q_map[0]; in qla24xx_config_rings()
4372 icb = (struct init_cb_24xx *)ha->init_cb; in qla24xx_config_rings()
4373 icb->request_q_outpointer = cpu_to_le16(0); in qla24xx_config_rings()
4374 icb->response_q_inpointer = cpu_to_le16(0); in qla24xx_config_rings()
4375 icb->request_q_length = cpu_to_le16(req->length); in qla24xx_config_rings()
4376 icb->response_q_length = cpu_to_le16(rsp->length); in qla24xx_config_rings()
4377 put_unaligned_le64(req->dma, &icb->request_q_address); in qla24xx_config_rings()
4378 put_unaligned_le64(rsp->dma, &icb->response_q_address); in qla24xx_config_rings()
4381 icb->atio_q_inpointer = cpu_to_le16(0); in qla24xx_config_rings()
4382 icb->atio_q_length = cpu_to_le16(ha->tgt.atio_q_length); in qla24xx_config_rings()
4383 put_unaligned_le64(ha->tgt.atio_dma, &icb->atio_q_address); in qla24xx_config_rings()
4386 icb->firmware_options_2 |= cpu_to_le32(BIT_30|BIT_29); in qla24xx_config_rings()
4388 if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha) || in qla24xx_config_rings()
4390 icb->qos = cpu_to_le16(QLA_DEFAULT_QUE_QOS); in qla24xx_config_rings()
4391 icb->rid = cpu_to_le16(rid); in qla24xx_config_rings()
4392 if (ha->flags.msix_enabled) { in qla24xx_config_rings()
4393 msix = &ha->msix_entries[1]; in qla24xx_config_rings()
4396 msix->entry); in qla24xx_config_rings()
4397 icb->msix = cpu_to_le16(msix->entry); in qla24xx_config_rings()
4401 icb->firmware_options_2 |= cpu_to_le32(BIT_19); in qla24xx_config_rings()
4404 icb->firmware_options_2 |= cpu_to_le32(BIT_18); in qla24xx_config_rings()
4407 if ((ha->fw_attributes & BIT_6) && (IS_MSIX_NACK_CAPABLE(ha)) && in qla24xx_config_rings()
4408 (ha->flags.msix_enabled)) { in qla24xx_config_rings()
4409 icb->firmware_options_2 &= cpu_to_le32(~BIT_22); in qla24xx_config_rings()
4410 ha->flags.disable_msix_handshake = 1; in qla24xx_config_rings()
4414 icb->firmware_options_2 |= cpu_to_le32(BIT_22); in qla24xx_config_rings()
4416 icb->firmware_options_2 |= cpu_to_le32(BIT_23); in qla24xx_config_rings()
4418 wrt_reg_dword(®->isp25mq.req_q_in, 0); in qla24xx_config_rings()
4419 wrt_reg_dword(®->isp25mq.req_q_out, 0); in qla24xx_config_rings()
4420 wrt_reg_dword(®->isp25mq.rsp_q_in, 0); in qla24xx_config_rings()
4421 wrt_reg_dword(®->isp25mq.rsp_q_out, 0); in qla24xx_config_rings()
4423 wrt_reg_dword(®->isp24.req_q_in, 0); in qla24xx_config_rings()
4424 wrt_reg_dword(®->isp24.req_q_out, 0); in qla24xx_config_rings()
4425 wrt_reg_dword(®->isp24.rsp_q_in, 0); in qla24xx_config_rings()
4426 wrt_reg_dword(®->isp24.rsp_q_out, 0); in qla24xx_config_rings()
4432 if (ha->set_data_rate) { in qla24xx_config_rings()
4435 qla2x00_get_link_speed_str(ha, ha->set_data_rate)); in qla24xx_config_rings()
4436 icb->firmware_options_3 = cpu_to_le32(ha->set_data_rate << 13); in qla24xx_config_rings()
4440 rd_reg_word(&ioreg->hccr); in qla24xx_config_rings()
4444 * qla2x00_init_rings() - Initializes firmware.
4458 struct qla_hw_data *ha = vha->hw; in qla2x00_init_rings()
4462 (struct mid_init_cb_24xx *) ha->init_cb; in qla2x00_init_rings()
4464 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_init_rings()
4467 for (que = 0; que < ha->max_req_queues; que++) { in qla2x00_init_rings()
4468 req = ha->req_q_map[que]; in qla2x00_init_rings()
4469 if (!req || !test_bit(que, ha->req_qid_map)) in qla2x00_init_rings()
4471 req->out_ptr = (uint16_t *)(req->ring + req->length); in qla2x00_init_rings()
4472 *req->out_ptr = 0; in qla2x00_init_rings()
4473 for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) in qla2x00_init_rings()
4474 req->outstanding_cmds[cnt] = NULL; in qla2x00_init_rings()
4476 req->current_outstanding_cmd = 1; in qla2x00_init_rings()
4479 req->ring_ptr = req->ring; in qla2x00_init_rings()
4480 req->ring_index = 0; in qla2x00_init_rings()
4481 req->cnt = req->length; in qla2x00_init_rings()
4484 for (que = 0; que < ha->max_rsp_queues; que++) { in qla2x00_init_rings()
4485 rsp = ha->rsp_q_map[que]; in qla2x00_init_rings()
4486 if (!rsp || !test_bit(que, ha->rsp_qid_map)) in qla2x00_init_rings()
4488 rsp->in_ptr = (uint16_t *)(rsp->ring + rsp->length); in qla2x00_init_rings()
4489 *rsp->in_ptr = 0; in qla2x00_init_rings()
4497 ha->tgt.atio_ring_ptr = ha->tgt.atio_ring; in qla2x00_init_rings()
4498 ha->tgt.atio_ring_index = 0; in qla2x00_init_rings()
4502 ha->isp_ops->config_rings(vha); in qla2x00_init_rings()
4504 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_init_rings()
4507 rval = qlafx00_init_firmware(vha, ha->init_cb_size); in qla2x00_init_rings()
4512 ha->isp_ops->update_fw_options(vha); in qla2x00_init_rings()
4515 "Issue init firmware FW opt 1-3= %08x %08x %08x.\n", in qla2x00_init_rings()
4516 le32_to_cpu(mid_init_cb->init_cb.firmware_options_1), in qla2x00_init_rings()
4517 le32_to_cpu(mid_init_cb->init_cb.firmware_options_2), in qla2x00_init_rings()
4518 le32_to_cpu(mid_init_cb->init_cb.firmware_options_3)); in qla2x00_init_rings()
4520 if (ha->flags.npiv_supported) { in qla2x00_init_rings()
4521 if (ha->operating_mode == LOOP && !IS_CNA_CAPABLE(ha)) in qla2x00_init_rings()
4522 ha->max_npiv_vports = MIN_MULTI_ID_FABRIC - 1; in qla2x00_init_rings()
4523 mid_init_cb->count = cpu_to_le16(ha->max_npiv_vports); in qla2x00_init_rings()
4527 mid_init_cb->options = cpu_to_le16(BIT_1); in qla2x00_init_rings()
4528 mid_init_cb->init_cb.execution_throttle = in qla2x00_init_rings()
4529 cpu_to_le16(ha->cur_fw_xcb_count); in qla2x00_init_rings()
4530 ha->flags.dport_enabled = in qla2x00_init_rings()
4531 (le32_to_cpu(mid_init_cb->init_cb.firmware_options_1) & in qla2x00_init_rings()
4534 (ha->flags.dport_enabled) ? "enabled" : "disabled"); in qla2x00_init_rings()
4535 /* FA-WWPN Status */ in qla2x00_init_rings()
4536 ha->flags.fawwpn_enabled = in qla2x00_init_rings()
4537 (le32_to_cpu(mid_init_cb->init_cb.firmware_options_1) & in qla2x00_init_rings()
4539 ql_dbg(ql_dbg_init, vha, 0x00bc, "FA-WWPN Support: %s.\n", in qla2x00_init_rings()
4540 (ha->flags.fawwpn_enabled) ? "enabled" : "disabled"); in qla2x00_init_rings()
4542 memcpy(ha->port_name, ha->init_cb->port_name, WWN_SIZE); in qla2x00_init_rings()
4546 if (ha->flags.edif_enabled) in qla2x00_init_rings()
4547 mid_init_cb->init_cb.frame_payload_size = cpu_to_le16(ELS_MAX_PAYLOAD); in qla2x00_init_rings()
4549 rval = qla2x00_init_firmware(vha, ha->init_cb_size); in qla2x00_init_rings()
4556 "Init Firmware -- success.\n"); in qla2x00_init_rings()
4558 vha->u_ql2xexchoffld = vha->u_ql2xiniexchg = 0; in qla2x00_init_rings()
4565 * qla2x00_fw_ready() - Waits for firmware ready.
4578 struct qla_hw_data *ha = vha->hw; in qla2x00_fw_ready()
4580 if (IS_QLAFX00(vha->hw)) in qla2x00_fw_ready()
4593 if ((wait_time = (ha->retry_count*ha->login_timeout) + 5) < min_wait) { in qla2x00_fw_ready()
4604 if (!vha->flags.init_done) in qla2x00_fw_ready()
4609 memset(state, -1, sizeof(state)); in qla2x00_fw_ready()
4613 vha->device_flags &= ~DFLG_NO_CABLE; in qla2x00_fw_ready()
4634 cs84xx_time = jiffies - cs84xx_time; in qla2x00_fw_ready()
4644 "F/W Ready - OK.\n"); in qla2x00_fw_ready()
4646 qla2x00_get_retry_cnt(vha, &ha->retry_count, in qla2x00_fw_ready()
4647 &ha->login_timeout, &ha->r_a_tov); in qla2x00_fw_ready()
4655 if (atomic_read(&vha->loop_down_timer) && in qla2x00_fw_ready()
4664 vha->device_flags |= DFLG_NO_CABLE; in qla2x00_fw_ready()
4671 ha->flags.isp82xx_fw_hung) in qla2x00_fw_ready()
4686 if (rval && !(vha->device_flags & DFLG_NO_CABLE)) { in qla2x00_fw_ready()
4718 struct qla_hw_data *ha = vha->hw; in qla2x00_configure_hba()
4719 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); in qla2x00_configure_hba()
4727 if (LOOP_TRANSITION(vha) || atomic_read(&ha->loop_down_timer) || in qla2x00_configure_hba()
4742 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_configure_hba()
4749 "Cannot get topology - retrying.\n"); in qla2x00_configure_hba()
4753 vha->loop_id = loop_id; in qla2x00_configure_hba()
4756 ha->min_external_loopid = SNS_FIRST_LOOP_ID; in qla2x00_configure_hba()
4757 ha->operating_mode = LOOP; in qla2x00_configure_hba()
4762 ha->switch_cap = 0; in qla2x00_configure_hba()
4763 ha->current_topology = ISP_CFG_NL; in qla2x00_configure_hba()
4769 ha->switch_cap = sw_cap; in qla2x00_configure_hba()
4770 ha->current_topology = ISP_CFG_FL; in qla2x00_configure_hba()
4776 ha->switch_cap = 0; in qla2x00_configure_hba()
4777 ha->operating_mode = P2P; in qla2x00_configure_hba()
4778 ha->current_topology = ISP_CFG_N; in qla2x00_configure_hba()
4779 strcpy(connect_type, "(N_Port-to-N_Port)"); in qla2x00_configure_hba()
4784 ha->switch_cap = sw_cap; in qla2x00_configure_hba()
4785 ha->operating_mode = P2P; in qla2x00_configure_hba()
4786 ha->current_topology = ISP_CFG_F; in qla2x00_configure_hba()
4793 ha->switch_cap = 0; in qla2x00_configure_hba()
4794 ha->current_topology = ISP_CFG_NL; in qla2x00_configure_hba()
4800 /* byte order - Big Endian */ in qla2x00_configure_hba()
4805 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_configure_hba()
4806 if (vha->hw->flags.edif_enabled) { in qla2x00_configure_hba()
4809 } else if (!(topo == 2 && ha->flags.n2n_bigger)) in qla2x00_configure_hba()
4811 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_configure_hba()
4813 if (!vha->flags.init_done) in qla2x00_configure_hba()
4815 "Topology - %s, Host Loop address 0x%x.\n", in qla2x00_configure_hba()
4816 connect_type, vha->loop_id); in qla2x00_configure_hba()
4828 struct qla_hw_data *ha = vha->hw; in qla2x00_set_model_info()
4835 memcpy(ha->model_number, model, len); in qla2x00_set_model_info()
4836 st = en = ha->model_number; in qla2x00_set_model_info()
4837 en += len - 1; in qla2x00_set_model_info()
4841 *en-- = '\0'; in qla2x00_set_model_info()
4844 index = (ha->pdev->subsystem_device & 0xff); in qla2x00_set_model_info()
4846 ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && in qla2x00_set_model_info()
4848 strlcpy(ha->model_desc, in qla2x00_set_model_info()
4850 sizeof(ha->model_desc)); in qla2x00_set_model_info()
4852 index = (ha->pdev->subsystem_device & 0xff); in qla2x00_set_model_info()
4854 ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && in qla2x00_set_model_info()
4856 strlcpy(ha->model_number, in qla2x00_set_model_info()
4858 sizeof(ha->model_number)); in qla2x00_set_model_info()
4859 strlcpy(ha->model_desc, in qla2x00_set_model_info()
4861 sizeof(ha->model_desc)); in qla2x00_set_model_info()
4863 strlcpy(ha->model_number, def, in qla2x00_set_model_info()
4864 sizeof(ha->model_number)); in qla2x00_set_model_info()
4868 qla2xxx_get_vpd_field(vha, "\x82", ha->model_desc, in qla2x00_set_model_info()
4869 sizeof(ha->model_desc)); in qla2x00_set_model_info()
4878 struct qla_hw_data *ha = vha->hw; in qla2xxx_nvram_wwn_from_ofw()
4879 struct pci_dev *pdev = ha->pdev; in qla2xxx_nvram_wwn_from_ofw()
4884 val = of_get_property(dp, "port-wwn", &len); in qla2xxx_nvram_wwn_from_ofw()
4886 memcpy(nv->port_name, val, WWN_SIZE); in qla2xxx_nvram_wwn_from_ofw()
4888 val = of_get_property(dp, "node-wwn", &len); in qla2xxx_nvram_wwn_from_ofw()
4890 memcpy(nv->node_name, val, WWN_SIZE); in qla2xxx_nvram_wwn_from_ofw()
4914 struct qla_hw_data *ha = vha->hw; in qla2x00_nvram_config()
4915 init_cb_t *icb = ha->init_cb; in qla2x00_nvram_config()
4916 nvram_t *nv = ha->nvram; in qla2x00_nvram_config()
4917 uint8_t *ptr = ha->nvram; in qla2x00_nvram_config()
4918 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_nvram_config()
4923 ha->nvram_size = sizeof(*nv); in qla2x00_nvram_config()
4924 ha->nvram_base = 0; in qla2x00_nvram_config()
4926 if ((rd_reg_word(®->ctrl_status) >> 14) == 1) in qla2x00_nvram_config()
4927 ha->nvram_base = 0x80; in qla2x00_nvram_config()
4930 ha->isp_ops->read_nvram(vha, ptr, ha->nvram_base, ha->nvram_size); in qla2x00_nvram_config()
4931 for (cnt = 0, chksum = 0; cnt < ha->nvram_size; cnt++) in qla2x00_nvram_config()
4937 nv, ha->nvram_size); in qla2x00_nvram_config()
4940 if (chksum || memcmp("ISP ", nv->id, sizeof(nv->id)) || in qla2x00_nvram_config()
4941 nv->nvram_version < 1) { in qla2x00_nvram_config()
4945 chksum, nv->id, nv->nvram_version); in qla2x00_nvram_config()
4948 "functioning (yet invalid -- WWPN) defaults.\n"); in qla2x00_nvram_config()
4953 memset(nv, 0, ha->nvram_size); in qla2x00_nvram_config()
4954 nv->parameter_block_version = ICB_VERSION; in qla2x00_nvram_config()
4957 nv->firmware_options[0] = BIT_2 | BIT_1; in qla2x00_nvram_config()
4958 nv->firmware_options[1] = BIT_7 | BIT_5; in qla2x00_nvram_config()
4959 nv->add_firmware_options[0] = BIT_5; in qla2x00_nvram_config()
4960 nv->add_firmware_options[1] = BIT_5 | BIT_4; in qla2x00_nvram_config()
4961 nv->frame_payload_size = cpu_to_le16(2048); in qla2x00_nvram_config()
4962 nv->special_options[1] = BIT_7; in qla2x00_nvram_config()
4964 nv->firmware_options[0] = BIT_2 | BIT_1; in qla2x00_nvram_config()
4965 nv->firmware_options[1] = BIT_7 | BIT_5; in qla2x00_nvram_config()
4966 nv->add_firmware_options[0] = BIT_5; in qla2x00_nvram_config()
4967 nv->add_firmware_options[1] = BIT_5 | BIT_4; in qla2x00_nvram_config()
4968 nv->frame_payload_size = cpu_to_le16(1024); in qla2x00_nvram_config()
4970 nv->firmware_options[0] = BIT_3 | BIT_1; in qla2x00_nvram_config()
4971 nv->firmware_options[1] = BIT_5; in qla2x00_nvram_config()
4972 nv->frame_payload_size = cpu_to_le16(1024); in qla2x00_nvram_config()
4975 nv->max_iocb_allocation = cpu_to_le16(256); in qla2x00_nvram_config()
4976 nv->execution_throttle = cpu_to_le16(16); in qla2x00_nvram_config()
4977 nv->retry_count = 8; in qla2x00_nvram_config()
4978 nv->retry_delay = 1; in qla2x00_nvram_config()
4980 nv->port_name[0] = 33; in qla2x00_nvram_config()
4981 nv->port_name[3] = 224; in qla2x00_nvram_config()
4982 nv->port_name[4] = 139; in qla2x00_nvram_config()
4986 nv->login_timeout = 4; in qla2x00_nvram_config()
4991 nv->host_p[1] = BIT_2; in qla2x00_nvram_config()
4992 nv->reset_delay = 5; in qla2x00_nvram_config()
4993 nv->port_down_retry_count = 8; in qla2x00_nvram_config()
4994 nv->max_luns_per_target = cpu_to_le16(8); in qla2x00_nvram_config()
4995 nv->link_down_timeout = 60; in qla2x00_nvram_config()
5001 memset(icb, 0, ha->init_cb_size); in qla2x00_nvram_config()
5006 nv->firmware_options[0] |= (BIT_6 | BIT_1); in qla2x00_nvram_config()
5007 nv->firmware_options[0] &= ~(BIT_5 | BIT_4); in qla2x00_nvram_config()
5008 nv->firmware_options[1] |= (BIT_5 | BIT_0); in qla2x00_nvram_config()
5009 nv->firmware_options[1] &= ~BIT_4; in qla2x00_nvram_config()
5012 nv->firmware_options[0] |= BIT_2; in qla2x00_nvram_config()
5013 nv->firmware_options[0] &= ~BIT_3; in qla2x00_nvram_config()
5014 nv->special_options[0] &= ~BIT_6; in qla2x00_nvram_config()
5015 nv->add_firmware_options[1] |= BIT_5 | BIT_4; in qla2x00_nvram_config()
5018 if (ha->fb_rev == FPM_2310) { in qla2x00_nvram_config()
5019 strcpy(ha->model_number, "QLA2310"); in qla2x00_nvram_config()
5021 strcpy(ha->model_number, "QLA2300"); in qla2x00_nvram_config()
5024 qla2x00_set_model_info(vha, nv->model_number, in qla2x00_nvram_config()
5025 sizeof(nv->model_number), "QLA23xx"); in qla2x00_nvram_config()
5028 nv->firmware_options[0] |= BIT_2; in qla2x00_nvram_config()
5030 * 'Point-to-point preferred, else loop' is not a safe in qla2x00_nvram_config()
5033 if ((nv->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) == in qla2x00_nvram_config()
5035 /* Force 'loop preferred, else point-to-point'. */ in qla2x00_nvram_config()
5036 nv->add_firmware_options[0] &= ~(BIT_6 | BIT_5 | BIT_4); in qla2x00_nvram_config()
5037 nv->add_firmware_options[0] |= BIT_5; in qla2x00_nvram_config()
5039 strcpy(ha->model_number, "QLA22xx"); in qla2x00_nvram_config()
5041 strcpy(ha->model_number, "QLA2100"); in qla2x00_nvram_config()
5048 dptr2 = (uint8_t *)&nv->parameter_block_version; in qla2x00_nvram_config()
5049 cnt = (uint8_t *)&icb->request_q_outpointer - (uint8_t *)&icb->version; in qla2x00_nvram_config()
5050 while (cnt--) in qla2x00_nvram_config()
5054 dptr1 = (uint8_t *)icb->add_firmware_options; in qla2x00_nvram_config()
5055 cnt = (uint8_t *)icb->reserved_3 - (uint8_t *)icb->add_firmware_options; in qla2x00_nvram_config()
5056 while (cnt--) in qla2x00_nvram_config()
5058 ha->frame_payload_size = le16_to_cpu(icb->frame_payload_size); in qla2x00_nvram_config()
5060 if (nv->host_p[1] & BIT_7) { in qla2x00_nvram_config()
5061 memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); in qla2x00_nvram_config()
5062 memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); in qla2x00_nvram_config()
5066 if ((icb->firmware_options[1] & BIT_6) == 0) { in qla2x00_nvram_config()
5071 memcpy(icb->node_name, icb->port_name, WWN_SIZE); in qla2x00_nvram_config()
5072 icb->node_name[0] &= 0xF0; in qla2x00_nvram_config()
5080 * BIT_7 in the host-parameters section allows for modification to in qla2x00_nvram_config()
5083 if (nv->host_p[0] & BIT_7) in qla2x00_nvram_config()
5085 ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0); in qla2x00_nvram_config()
5088 ha->flags.disable_risc_code_load = 0; in qla2x00_nvram_config()
5089 ha->flags.enable_lip_reset = ((nv->host_p[1] & BIT_1) ? 1 : 0); in qla2x00_nvram_config()
5090 ha->flags.enable_lip_full_login = ((nv->host_p[1] & BIT_2) ? 1 : 0); in qla2x00_nvram_config()
5091 ha->flags.enable_target_reset = ((nv->host_p[1] & BIT_3) ? 1 : 0); in qla2x00_nvram_config()
5092 ha->flags.enable_led_scheme = (nv->special_options[1] & BIT_4) ? 1 : 0; in qla2x00_nvram_config()
5093 ha->flags.disable_serdes = 0; in qla2x00_nvram_config()
5095 ha->operating_mode = in qla2x00_nvram_config()
5096 (icb->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) >> 4; in qla2x00_nvram_config()
5098 memcpy(ha->fw_seriallink_options, nv->seriallink_options, in qla2x00_nvram_config()
5099 sizeof(ha->fw_seriallink_options)); in qla2x00_nvram_config()
5102 ha->serial0 = icb->port_name[5]; in qla2x00_nvram_config()
5103 ha->serial1 = icb->port_name[6]; in qla2x00_nvram_config()
5104 ha->serial2 = icb->port_name[7]; in qla2x00_nvram_config()
5105 memcpy(vha->node_name, icb->node_name, WWN_SIZE); in qla2x00_nvram_config()
5106 memcpy(vha->port_name, icb->port_name, WWN_SIZE); in qla2x00_nvram_config()
5108 icb->execution_throttle = cpu_to_le16(0xFFFF); in qla2x00_nvram_config()
5110 ha->retry_count = nv->retry_count; in qla2x00_nvram_config()
5113 if (nv->login_timeout != ql2xlogintimeout) in qla2x00_nvram_config()
5114 nv->login_timeout = ql2xlogintimeout; in qla2x00_nvram_config()
5115 if (nv->login_timeout < 4) in qla2x00_nvram_config()
5116 nv->login_timeout = 4; in qla2x00_nvram_config()
5117 ha->login_timeout = nv->login_timeout; in qla2x00_nvram_config()
5120 ha->r_a_tov = 100; in qla2x00_nvram_config()
5122 ha->loop_reset_delay = nv->reset_delay; in qla2x00_nvram_config()
5134 if (nv->link_down_timeout == 0) { in qla2x00_nvram_config()
5135 ha->loop_down_abort_time = in qla2x00_nvram_config()
5136 (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); in qla2x00_nvram_config()
5138 ha->link_down_timeout = nv->link_down_timeout; in qla2x00_nvram_config()
5139 ha->loop_down_abort_time = in qla2x00_nvram_config()
5140 (LOOP_DOWN_TIME - ha->link_down_timeout); in qla2x00_nvram_config()
5146 ha->port_down_retry_count = nv->port_down_retry_count; in qla2x00_nvram_config()
5148 ha->port_down_retry_count = qlport_down_retry; in qla2x00_nvram_config()
5150 ha->login_retry_count = nv->retry_count; in qla2x00_nvram_config()
5151 if (ha->port_down_retry_count == nv->port_down_retry_count && in qla2x00_nvram_config()
5152 ha->port_down_retry_count > 3) in qla2x00_nvram_config()
5153 ha->login_retry_count = ha->port_down_retry_count; in qla2x00_nvram_config()
5154 else if (ha->port_down_retry_count > (int)ha->login_retry_count) in qla2x00_nvram_config()
5155 ha->login_retry_count = ha->port_down_retry_count; in qla2x00_nvram_config()
5157 ha->login_retry_count = ql2xloginretrycount; in qla2x00_nvram_config()
5159 icb->lun_enables = cpu_to_le16(0); in qla2x00_nvram_config()
5160 icb->command_resource_count = 0; in qla2x00_nvram_config()
5161 icb->immediate_notify_resource_count = 0; in qla2x00_nvram_config()
5162 icb->timeout = cpu_to_le16(0); in qla2x00_nvram_config()
5166 icb->firmware_options[0] &= ~BIT_3; in qla2x00_nvram_config()
5167 icb->add_firmware_options[0] &= in qla2x00_nvram_config()
5169 icb->add_firmware_options[0] |= BIT_2; in qla2x00_nvram_config()
5170 icb->response_accumulation_timer = 3; in qla2x00_nvram_config()
5171 icb->interrupt_delay_timer = 5; in qla2x00_nvram_config()
5173 vha->flags.process_response_queue = 1; in qla2x00_nvram_config()
5176 if (!vha->flags.init_done) { in qla2x00_nvram_config()
5177 ha->zio_mode = icb->add_firmware_options[0] & in qla2x00_nvram_config()
5179 ha->zio_timer = icb->interrupt_delay_timer ? in qla2x00_nvram_config()
5180 icb->interrupt_delay_timer : 2; in qla2x00_nvram_config()
5182 icb->add_firmware_options[0] &= in qla2x00_nvram_config()
5184 vha->flags.process_response_queue = 0; in qla2x00_nvram_config()
5185 if (ha->zio_mode != QLA_ZIO_DISABLED) { in qla2x00_nvram_config()
5186 ha->zio_mode = QLA_ZIO_MODE_6; in qla2x00_nvram_config()
5190 ha->zio_mode, ha->zio_timer * 100); in qla2x00_nvram_config()
5192 icb->add_firmware_options[0] |= (uint8_t)ha->zio_mode; in qla2x00_nvram_config()
5193 icb->interrupt_delay_timer = (uint8_t)ha->zio_timer; in qla2x00_nvram_config()
5194 vha->flags.process_response_queue = 1; in qla2x00_nvram_config()
5212 spin_lock_irqsave(fcport->vha->host->host_lock, flags); in qla2x00_rport_del()
5213 rport = fcport->drport ? fcport->drport : fcport->rport; in qla2x00_rport_del()
5214 fcport->drport = NULL; in qla2x00_rport_del()
5215 spin_unlock_irqrestore(fcport->vha->host->host_lock, flags); in qla2x00_rport_del()
5217 ql_dbg(ql_dbg_disc, fcport->vha, 0x210b, in qla2x00_rport_del()
5219 __func__, fcport->port_name, rport, in qla2x00_rport_del()
5220 rport->roles); in qla2x00_rport_del()
5230 old_state = atomic_read(&fcport->state); in qla2x00_set_fcport_state()
5231 atomic_set(&fcport->state, state); in qla2x00_set_fcport_state()
5235 ql_dbg(ql_dbg_disc, fcport->vha, 0x207d, in qla2x00_set_fcport_state()
5236 "FCPort %8phC state transitioned from %s to %s - portid=%02x%02x%02x.\n", in qla2x00_set_fcport_state()
5237 fcport->port_name, port_state_str[old_state], in qla2x00_set_fcport_state()
5238 port_state_str[state], fcport->d_id.b.domain, in qla2x00_set_fcport_state()
5239 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_set_fcport_state()
5244 * qla2x00_alloc_fcport() - Allocate a generic fcport.
5259 fcport->ct_desc.ct_sns = dma_alloc_coherent(&vha->hw->pdev->dev, in qla2x00_alloc_fcport()
5260 sizeof(struct ct_sns_pkt), &fcport->ct_desc.ct_sns_dma, in qla2x00_alloc_fcport()
5262 if (!fcport->ct_desc.ct_sns) { in qla2x00_alloc_fcport()
5270 fcport->vha = vha; in qla2x00_alloc_fcport()
5271 fcport->port_type = FCT_UNKNOWN; in qla2x00_alloc_fcport()
5272 fcport->loop_id = FC_NO_LOOP_ID; in qla2x00_alloc_fcport()
5274 fcport->supported_classes = FC_COS_UNSPECIFIED; in qla2x00_alloc_fcport()
5275 fcport->fp_speed = PORT_SPEED_UNKNOWN; in qla2x00_alloc_fcport()
5277 fcport->disc_state = DSC_DELETED; in qla2x00_alloc_fcport()
5278 fcport->fw_login_state = DSC_LS_PORT_UNAVAIL; in qla2x00_alloc_fcport()
5279 fcport->deleted = QLA_SESS_DELETED; in qla2x00_alloc_fcport()
5280 fcport->login_retry = vha->hw->login_retry_count; in qla2x00_alloc_fcport()
5281 fcport->chip_reset = vha->hw->base_qpair->chip_reset; in qla2x00_alloc_fcport()
5282 fcport->logout_on_delete = 1; in qla2x00_alloc_fcport()
5283 fcport->tgt_link_down_time = QLA2XX_MAX_LINK_DOWN_TIME; in qla2x00_alloc_fcport()
5284 fcport->tgt_short_link_down_cnt = 0; in qla2x00_alloc_fcport()
5285 fcport->dev_loss_tmo = 0; in qla2x00_alloc_fcport()
5287 if (!fcport->ct_desc.ct_sns) { in qla2x00_alloc_fcport()
5294 INIT_WORK(&fcport->del_work, qla24xx_delete_sess_fn); in qla2x00_alloc_fcport()
5295 INIT_WORK(&fcport->free_work, qlt_free_session_done); in qla2x00_alloc_fcport()
5296 INIT_WORK(&fcport->reg_work, qla_register_fcport_fn); in qla2x00_alloc_fcport()
5297 INIT_LIST_HEAD(&fcport->gnl_entry); in qla2x00_alloc_fcport()
5298 INIT_LIST_HEAD(&fcport->list); in qla2x00_alloc_fcport()
5300 INIT_LIST_HEAD(&fcport->sess_cmd_list); in qla2x00_alloc_fcport()
5301 spin_lock_init(&fcport->sess_cmd_lock); in qla2x00_alloc_fcport()
5303 spin_lock_init(&fcport->edif.sa_list_lock); in qla2x00_alloc_fcport()
5304 INIT_LIST_HEAD(&fcport->edif.tx_sa_list); in qla2x00_alloc_fcport()
5305 INIT_LIST_HEAD(&fcport->edif.rx_sa_list); in qla2x00_alloc_fcport()
5307 spin_lock_init(&fcport->edif.indx_list_lock); in qla2x00_alloc_fcport()
5308 INIT_LIST_HEAD(&fcport->edif.edif_indx_list); in qla2x00_alloc_fcport()
5316 if (fcport->ct_desc.ct_sns) { in qla2x00_free_fcport()
5317 dma_free_coherent(&fcport->vha->hw->pdev->dev, in qla2x00_free_fcport()
5318 sizeof(struct ct_sns_pkt), fcport->ct_desc.ct_sns, in qla2x00_free_fcport()
5319 fcport->ct_desc.ct_sns_dma); in qla2x00_free_fcport()
5321 fcport->ct_desc.ct_sns = NULL; in qla2x00_free_fcport()
5325 list_del(&fcport->list); in qla2x00_free_fcport()
5335 struct qla_hw_data *ha = vha->hw; in qla_get_login_template()
5340 memset(ha->init_cb, 0, ha->init_cb_size); in qla_get_login_template()
5341 sz = min_t(int, sizeof(struct fc_els_flogi), ha->init_cb_size); in qla_get_login_template()
5342 rval = qla24xx_get_port_login_templ(vha, ha->init_cb_dma, in qla_get_login_template()
5343 ha->init_cb, sz); in qla_get_login_template()
5349 q = (__be32 *)&ha->plogi_els_payld.fl_csp; in qla_get_login_template()
5351 bp = (uint32_t *)ha->init_cb; in qla_get_login_template()
5353 ha->flags.plogi_template_valid = 1; in qla_get_login_template()
5373 struct qla_hw_data *ha = vha->hw; in qla2x00_configure_loop()
5378 if (test_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags)) { in qla2x00_configure_loop()
5387 save_flags = flags = vha->dpc_flags; in qla2x00_configure_loop()
5389 "Configure loop -- dpc flags = 0x%lx.\n", flags); in qla2x00_configure_loop()
5395 clear_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_configure_loop()
5396 clear_bit(RSCN_UPDATE, &vha->dpc_flags); in qla2x00_configure_loop()
5402 if ((ha->current_topology == ISP_CFG_FL || in qla2x00_configure_loop()
5403 ha->current_topology == ISP_CFG_F) && in qla2x00_configure_loop()
5409 } else if (ha->current_topology == ISP_CFG_NL || in qla2x00_configure_loop()
5410 ha->current_topology == ISP_CFG_N) { in qla2x00_configure_loop()
5413 } else if (!vha->flags.online || in qla2x00_configure_loop()
5420 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { in qla2x00_configure_loop()
5439 if (atomic_read(&vha->loop_down_timer) || in qla2x00_configure_loop()
5440 test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { in qla2x00_configure_loop()
5443 atomic_set(&vha->loop_state, LOOP_READY); in qla2x00_configure_loop()
5446 ha->flags.fw_init_done = 1; in qla2x00_configure_loop()
5452 if (ha->flags.edif_enabled && DBELL_INACTIVE(vha)) in qla2x00_configure_loop()
5454 ha->link_data_rate); in qla2x00_configure_loop()
5462 spin_lock_irqsave(&ha->tgt.atio_lock, flags); in qla2x00_configure_loop()
5464 spin_unlock_irqrestore(&ha->tgt.atio_lock, in qla2x00_configure_loop()
5476 __func__, vha->port_name, vha->d_id.b24); in qla2x00_configure_loop()
5480 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { in qla2x00_configure_loop()
5482 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_configure_loop()
5484 set_bit(RSCN_UPDATE, &vha->dpc_flags); in qla2x00_configure_loop()
5498 if (test_and_clear_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags)) in qla2x00_configure_n2n_loop()
5499 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla2x00_configure_n2n_loop()
5501 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_configure_n2n_loop()
5502 if (fcport->n2n_flag) { in qla2x00_configure_n2n_loop()
5508 spin_lock_irqsave(&vha->work_lock, flags); in qla2x00_configure_n2n_loop()
5509 vha->scan.scan_retry++; in qla2x00_configure_n2n_loop()
5510 spin_unlock_irqrestore(&vha->work_lock, flags); in qla2x00_configure_n2n_loop()
5512 if (vha->scan.scan_retry < MAX_SCAN_RETRIES) { in qla2x00_configure_n2n_loop()
5513 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_configure_n2n_loop()
5514 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_n2n_loop()
5524 atomic_set(&vha->loop_state, LOOP_DOWN); in qla_reinitialize_link()
5525 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); in qla_reinitialize_link()
5557 struct qla_hw_data *ha = vha->hw; in qla2x00_configure_local_loop()
5569 memset(ha->gid_list, 0, qla2x00_gid_list_size(ha)); in qla2x00_configure_local_loop()
5570 rval = qla2x00_get_id_list(vha, ha->gid_list, ha->gid_list_dma, in qla2x00_configure_local_loop()
5578 ha->gid_list, entries * sizeof(*ha->gid_list)); in qla2x00_configure_local_loop()
5581 spin_lock_irqsave(&vha->work_lock, flags); in qla2x00_configure_local_loop()
5582 vha->scan.scan_retry++; in qla2x00_configure_local_loop()
5583 spin_unlock_irqrestore(&vha->work_lock, flags); in qla2x00_configure_local_loop()
5585 if (vha->scan.scan_retry < MAX_SCAN_RETRIES) { in qla2x00_configure_local_loop()
5599 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_configure_local_loop()
5600 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_local_loop()
5603 vha->scan.scan_retry = 0; in qla2x00_configure_local_loop()
5606 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_configure_local_loop()
5607 fcport->scan_state = QLA_FCPORT_SCAN; in qla2x00_configure_local_loop()
5618 new_fcport->flags &= ~FCF_FABRIC_DEVICE; in qla2x00_configure_local_loop()
5621 gid = ha->gid_list; in qla2x00_configure_local_loop()
5623 domain = gid->domain; in qla2x00_configure_local_loop()
5624 area = gid->area; in qla2x00_configure_local_loop()
5625 al_pa = gid->al_pa; in qla2x00_configure_local_loop()
5627 loop_id = gid->loop_id_2100; in qla2x00_configure_local_loop()
5629 loop_id = le16_to_cpu(gid->loop_id); in qla2x00_configure_local_loop()
5630 gid = (void *)gid + ha->gid_list_info_size; in qla2x00_configure_local_loop()
5637 if (area && domain && ((area != vha->d_id.b.area) || in qla2x00_configure_local_loop()
5638 (domain != vha->d_id.b.domain)) && in qla2x00_configure_local_loop()
5639 (ha->current_topology == ISP_CFG_NL)) in qla2x00_configure_local_loop()
5647 memset(new_fcport->port_name, 0, WWN_SIZE); in qla2x00_configure_local_loop()
5650 new_fcport->d_id.b.domain = domain; in qla2x00_configure_local_loop()
5651 new_fcport->d_id.b.area = area; in qla2x00_configure_local_loop()
5652 new_fcport->d_id.b.al_pa = al_pa; in qla2x00_configure_local_loop()
5653 new_fcport->loop_id = loop_id; in qla2x00_configure_local_loop()
5654 new_fcport->scan_state = QLA_FCPORT_FOUND; in qla2x00_configure_local_loop()
5660 "-- get_port_database=%x, loop_id=0x%04x.\n", in qla2x00_configure_local_loop()
5661 rval2, new_fcport->loop_id); in qla2x00_configure_local_loop()
5663 if (ha->current_topology != ISP_CFG_N) { in qla2x00_configure_local_loop()
5666 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_local_loop()
5671 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla2x00_configure_local_loop()
5675 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_configure_local_loop()
5676 if (memcmp(new_fcport->port_name, fcport->port_name, in qla2x00_configure_local_loop()
5680 fcport->flags &= ~FCF_FABRIC_DEVICE; in qla2x00_configure_local_loop()
5681 fcport->loop_id = new_fcport->loop_id; in qla2x00_configure_local_loop()
5682 fcport->port_type = new_fcport->port_type; in qla2x00_configure_local_loop()
5683 fcport->d_id.b24 = new_fcport->d_id.b24; in qla2x00_configure_local_loop()
5684 memcpy(fcport->node_name, new_fcport->node_name, in qla2x00_configure_local_loop()
5686 fcport->scan_state = QLA_FCPORT_FOUND; in qla2x00_configure_local_loop()
5687 if (fcport->login_retry == 0) { in qla2x00_configure_local_loop()
5688 fcport->login_retry = vha->hw->login_retry_count; in qla2x00_configure_local_loop()
5691 fcport->port_name, fcport->loop_id, in qla2x00_configure_local_loop()
5692 fcport->login_retry); in qla2x00_configure_local_loop()
5700 list_add_tail(&new_fcport->list, &vha->vp_fcports); in qla2x00_configure_local_loop()
5705 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla2x00_configure_local_loop()
5715 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla2x00_configure_local_loop()
5716 new_fcport->flags &= ~FCF_FABRIC_DEVICE; in qla2x00_configure_local_loop()
5719 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla2x00_configure_local_loop()
5722 fcport->fp_speed = ha->link_data_rate; in qla2x00_configure_local_loop()
5727 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_configure_local_loop()
5728 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_configure_local_loop()
5731 if (fcport->scan_state == QLA_FCPORT_SCAN) { in qla2x00_configure_local_loop()
5734 atomic_read(&fcport->state) == FCS_ONLINE) { in qla2x00_configure_local_loop()
5737 if (fcport->loop_id != FC_NO_LOOP_ID && in qla2x00_configure_local_loop()
5738 (fcport->flags & FCF_FCP2_DEVICE) == 0 && in qla2x00_configure_local_loop()
5739 fcport->port_type != FCT_INITIATOR && in qla2x00_configure_local_loop()
5740 fcport->port_type != FCT_BROADCAST) { in qla2x00_configure_local_loop()
5744 fcport->port_name); in qla2x00_configure_local_loop()
5752 if (fcport->scan_state == QLA_FCPORT_FOUND) in qla2x00_configure_local_loop()
5771 struct qla_hw_data *ha = vha->hw; in qla2x00_iidma_fcport()
5776 if (atomic_read(&fcport->state) != FCS_ONLINE) in qla2x00_iidma_fcport()
5779 if (fcport->fp_speed == PORT_SPEED_UNKNOWN || in qla2x00_iidma_fcport()
5780 fcport->fp_speed > ha->link_data_rate || in qla2x00_iidma_fcport()
5781 !ha->flags.gpsc_supported) in qla2x00_iidma_fcport()
5784 rval = qla2x00_set_idma_speed(vha, fcport->loop_id, fcport->fp_speed, in qla2x00_iidma_fcport()
5788 "Unable to adjust iIDMA %8phN -- %04x %x %04x %04x.\n", in qla2x00_iidma_fcport()
5789 fcport->port_name, rval, fcport->fp_speed, mb[0], mb[1]); in qla2x00_iidma_fcport()
5793 qla2x00_get_link_speed_str(ha, fcport->fp_speed), in qla2x00_iidma_fcport()
5794 fcport->fp_speed, fcport->port_name); in qla2x00_iidma_fcport()
5812 e->u.fcport.fcport = fcport; in qla_post_iidma_work()
5824 if (atomic_read(&fcport->state) == FCS_ONLINE) in qla2x00_reg_remote_port()
5827 rport_ids.node_name = wwn_to_u64(fcport->node_name); in qla2x00_reg_remote_port()
5828 rport_ids.port_name = wwn_to_u64(fcport->port_name); in qla2x00_reg_remote_port()
5829 rport_ids.port_id = fcport->d_id.b.domain << 16 | in qla2x00_reg_remote_port()
5830 fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; in qla2x00_reg_remote_port()
5832 fcport->rport = rport = fc_remote_port_add(vha->host, 0, &rport_ids); in qla2x00_reg_remote_port()
5839 spin_lock_irqsave(fcport->vha->host->host_lock, flags); in qla2x00_reg_remote_port()
5840 *((fc_port_t **)rport->dd_data) = fcport; in qla2x00_reg_remote_port()
5841 spin_unlock_irqrestore(fcport->vha->host->host_lock, flags); in qla2x00_reg_remote_port()
5842 fcport->dev_loss_tmo = rport->dev_loss_tmo; in qla2x00_reg_remote_port()
5844 rport->supported_classes = fcport->supported_classes; in qla2x00_reg_remote_port()
5847 if (fcport->port_type == FCT_INITIATOR) in qla2x00_reg_remote_port()
5849 if (fcport->port_type == FCT_TARGET) in qla2x00_reg_remote_port()
5851 if (fcport->port_type & FCT_NVME_INITIATOR) in qla2x00_reg_remote_port()
5853 if (fcport->port_type & FCT_NVME_TARGET) in qla2x00_reg_remote_port()
5855 if (fcport->port_type & FCT_NVME_DISCOVERY) in qla2x00_reg_remote_port()
5862 __func__, fcport->port_name, vha->host_no, in qla2x00_reg_remote_port()
5863 rport->scsi_target_id, rport, in qla2x00_reg_remote_port()
5864 (fcport->port_type == FCT_TARGET) ? "tgt" : in qla2x00_reg_remote_port()
5865 ((fcport->port_type & FCT_NVME) ? "nvme" : "ini")); in qla2x00_reg_remote_port()
5877 * 0 - Success
5878 * BIT_0 - error
5886 if (IS_SW_RESV_ADDR(fcport->d_id)) in qla2x00_update_fcport()
5890 __func__, fcport->port_name); in qla2x00_update_fcport()
5893 fcport->login_retry = vha->hw->login_retry_count; in qla2x00_update_fcport()
5894 fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); in qla2x00_update_fcport()
5895 fcport->deleted = 0; in qla2x00_update_fcport()
5896 if (vha->hw->current_topology == ISP_CFG_NL) in qla2x00_update_fcport()
5897 fcport->logout_on_delete = 0; in qla2x00_update_fcport()
5899 fcport->logout_on_delete = 1; in qla2x00_update_fcport()
5900 fcport->n2n_chip_reset = fcport->n2n_link_reset_cnt = 0; in qla2x00_update_fcport()
5902 if (fcport->tgt_link_down_time < fcport->dev_loss_tmo) { in qla2x00_update_fcport()
5903 fcport->tgt_short_link_down_cnt++; in qla2x00_update_fcport()
5904 fcport->tgt_link_down_time = QLA2XX_MAX_LINK_DOWN_TIME; in qla2x00_update_fcport()
5907 switch (vha->hw->current_topology) { in qla2x00_update_fcport()
5910 fcport->keep_nport_handle = 1; in qla2x00_update_fcport()
5922 switch (vha->host->active_mode) { in qla2x00_update_fcport()
5927 if (!vha->vha_tgt.qla_tgt->tgt_stop && in qla2x00_update_fcport()
5928 !vha->vha_tgt.qla_tgt->tgt_stopped) in qla2x00_update_fcport()
5933 if (!vha->vha_tgt.qla_tgt->tgt_stop && in qla2x00_update_fcport()
5934 !vha->vha_tgt.qla_tgt->tgt_stopped) in qla2x00_update_fcport()
5941 if (NVME_TARGET(vha->hw, fcport)) in qla2x00_update_fcport()
5946 if (IS_IIDMA_CAPABLE(vha->hw) && vha->hw->flags.gpsc_supported) { in qla2x00_update_fcport()
5947 if (fcport->id_changed) { in qla2x00_update_fcport()
5948 fcport->id_changed = 0; in qla2x00_update_fcport()
5951 __func__, __LINE__, fcport->port_name, in qla2x00_update_fcport()
5952 vha->fcport_count); in qla2x00_update_fcport()
5957 __func__, __LINE__, fcport->port_name, in qla2x00_update_fcport()
5958 vha->fcport_count); in qla2x00_update_fcport()
5969 u32 rscn_gen = fcport->rscn_gen; in qla_register_fcport_fn()
5972 if (IS_SW_RESV_ADDR(fcport->d_id)) in qla_register_fcport_fn()
5975 qla2x00_update_fcport(fcport->vha, fcport); in qla_register_fcport_fn()
5977 ql_dbg(ql_dbg_disc, fcport->vha, 0x911e, in qla_register_fcport_fn()
5979 rscn_gen, fcport->rscn_gen, fcport->next_disc_state); in qla_register_fcport_fn()
5981 if (rscn_gen != fcport->rscn_gen) { in qla_register_fcport_fn()
5983 switch (fcport->next_disc_state) { in qla_register_fcport_fn()
5989 qla2x00_post_async_adisc_work(fcport->vha, fcport, in qla_register_fcport_fn()
6017 struct qla_hw_data *ha = vha->hw; in qla2x00_configure_fabric()
6025 rval = qla2x00_get_port_name(vha, loop_id, vha->fabric_node_name, 1); in qla2x00_configure_fabric()
6030 vha->device_flags &= ~SWITCH_FOUND; in qla2x00_configure_fabric()
6033 vha->device_flags |= SWITCH_FOUND; in qla2x00_configure_fabric()
6035 rval = qla2x00_get_port_name(vha, loop_id, vha->fabric_port_name, 0); in qla2x00_configure_fabric()
6053 rval = ha->isp_ops->fabric_login(vha, loop_id, 0xff, 0xff, in qla2x00_configure_fabric()
6059 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_fabric()
6065 test_and_clear_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags)) in qla2x00_configure_fabric()
6068 if (test_and_clear_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags)) { in qla2x00_configure_fabric()
6072 "Register FC-4 TYPE failed.\n"); in qla2x00_configure_fabric()
6074 &vha->dpc_flags)) in qla2x00_configure_fabric()
6080 "Register FC-4 Features failed.\n"); in qla2x00_configure_fabric()
6082 &vha->dpc_flags)) in qla2x00_configure_fabric()
6085 if (vha->flags.nvme_enabled) { in qla2x00_configure_fabric()
6096 &vha->dpc_flags)) in qla2x00_configure_fabric()
6102 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_configure_fabric()
6111 * disconnected port might have re-connected and a brand new in qla2x00_configure_fabric()
6120 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_fabric()
6122 list_for_each_entry(fcport, &vha->vp_fcports, list) in qla2x00_configure_fabric()
6123 fcport->scan_state = QLA_FCPORT_SCAN; in qla2x00_configure_fabric()
6131 if (!vha->nvme_local_port && vha->flags.nvme_enabled) in qla2x00_configure_fabric()
6166 struct qla_hw_data *ha = vha->hw; in qla2x00_find_all_fabric_devs()
6167 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); in qla2x00_find_all_fabric_devs()
6173 if (!ha->swl) in qla2x00_find_all_fabric_devs()
6174 ha->swl = kcalloc(ha->max_fibre_devices, sizeof(sw_info_t), in qla2x00_find_all_fabric_devs()
6176 swl = ha->swl; in qla2x00_find_all_fabric_devs()
6182 memset(swl, 0, ha->max_fibre_devices * sizeof(sw_info_t)); in qla2x00_find_all_fabric_devs()
6185 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
6189 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
6193 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
6197 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
6201 /* If other queries succeeded probe for FC-4 type */ in qla2x00_find_all_fabric_devs()
6204 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
6217 new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); in qla2x00_find_all_fabric_devs()
6223 loop_id = ha->min_external_loopid; in qla2x00_find_all_fabric_devs()
6224 for (; loop_id <= ha->max_loop_id; loop_id++) { in qla2x00_find_all_fabric_devs()
6228 if (ha->current_topology == ISP_CFG_FL && in qla2x00_find_all_fabric_devs()
6229 (atomic_read(&vha->loop_down_timer) || in qla2x00_find_all_fabric_devs()
6231 atomic_set(&vha->loop_down_timer, 0); in qla2x00_find_all_fabric_devs()
6232 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_find_all_fabric_devs()
6233 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_find_all_fabric_devs()
6239 wrap.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
6241 new_fcport->d_id.b24 = swl[swl_idx].d_id.b24; in qla2x00_find_all_fabric_devs()
6242 memcpy(new_fcport->node_name, in qla2x00_find_all_fabric_devs()
6244 memcpy(new_fcport->port_name, in qla2x00_find_all_fabric_devs()
6246 memcpy(new_fcport->fabric_port_name, in qla2x00_find_all_fabric_devs()
6248 new_fcport->fp_speed = swl[swl_idx].fp_speed; in qla2x00_find_all_fabric_devs()
6249 new_fcport->fc4_type = swl[swl_idx].fc4_type; in qla2x00_find_all_fabric_devs()
6251 new_fcport->nvme_flag = 0; in qla2x00_find_all_fabric_devs()
6252 if (vha->flags.nvme_enabled && in qla2x00_find_all_fabric_devs()
6256 new_fcport->port_name); in qla2x00_find_all_fabric_devs()
6269 "SNS scan failed -- assuming " in qla2x00_find_all_fabric_devs()
6270 "zero-entry result.\n"); in qla2x00_find_all_fabric_devs()
6278 wrap.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
6280 } else if (new_fcport->d_id.b24 == wrap.b24) { in qla2x00_find_all_fabric_devs()
6283 new_fcport->d_id.b.domain, in qla2x00_find_all_fabric_devs()
6284 new_fcport->d_id.b.area, in qla2x00_find_all_fabric_devs()
6285 new_fcport->d_id.b.al_pa); in qla2x00_find_all_fabric_devs()
6290 if (new_fcport->d_id.b24 == base_vha->d_id.b24) in qla2x00_find_all_fabric_devs()
6294 if (qla2x00_is_a_vp_did(vha, new_fcport->d_id.b24)) in qla2x00_find_all_fabric_devs()
6298 if (((new_fcport->d_id.b24 & 0xffff00) == in qla2x00_find_all_fabric_devs()
6299 (vha->d_id.b24 & 0xffff00)) && ha->current_topology == in qla2x00_find_all_fabric_devs()
6304 if ((new_fcport->d_id.b.domain & 0xf0) == 0xf0) in qla2x00_find_all_fabric_devs()
6307 /* Bypass ports whose FCP-4 type is not FCP_SCSI */ in qla2x00_find_all_fabric_devs()
6309 (!(new_fcport->fc4_type & FS_FC4TYPE_FCP) && in qla2x00_find_all_fabric_devs()
6310 new_fcport->fc4_type != 0)) in qla2x00_find_all_fabric_devs()
6313 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla2x00_find_all_fabric_devs()
6317 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_find_all_fabric_devs()
6318 if (memcmp(new_fcport->port_name, fcport->port_name, in qla2x00_find_all_fabric_devs()
6322 fcport->scan_state = QLA_FCPORT_FOUND; in qla2x00_find_all_fabric_devs()
6327 memcpy(fcport->fabric_port_name, in qla2x00_find_all_fabric_devs()
6328 new_fcport->fabric_port_name, WWN_SIZE); in qla2x00_find_all_fabric_devs()
6329 fcport->fp_speed = new_fcport->fp_speed; in qla2x00_find_all_fabric_devs()
6335 if (fcport->d_id.b24 == new_fcport->d_id.b24 && in qla2x00_find_all_fabric_devs()
6336 (atomic_read(&fcport->state) == FCS_ONLINE || in qla2x00_find_all_fabric_devs()
6337 (vha->host->active_mode == MODE_TARGET))) { in qla2x00_find_all_fabric_devs()
6341 if (fcport->login_retry == 0) in qla2x00_find_all_fabric_devs()
6342 fcport->login_retry = in qla2x00_find_all_fabric_devs()
6343 vha->hw->login_retry_count; in qla2x00_find_all_fabric_devs()
6347 if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) { in qla2x00_find_all_fabric_devs()
6348 fcport->d_id.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
6350 fcport->flags |= (FCF_FABRIC_DEVICE | in qla2x00_find_all_fabric_devs()
6363 " old %x:%x:%x (loop_id 0x%04x)-> new %x:%x:%x\n", in qla2x00_find_all_fabric_devs()
6364 fcport->port_name, in qla2x00_find_all_fabric_devs()
6365 fcport->d_id.b.domain, in qla2x00_find_all_fabric_devs()
6366 fcport->d_id.b.area, in qla2x00_find_all_fabric_devs()
6367 fcport->d_id.b.al_pa, in qla2x00_find_all_fabric_devs()
6368 fcport->loop_id, in qla2x00_find_all_fabric_devs()
6369 new_fcport->d_id.b.domain, in qla2x00_find_all_fabric_devs()
6370 new_fcport->d_id.b.area, in qla2x00_find_all_fabric_devs()
6371 new_fcport->d_id.b.al_pa); in qla2x00_find_all_fabric_devs()
6372 fcport->d_id.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
6376 fcport->d_id.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
6377 fcport->flags |= FCF_LOGIN_NEEDED; in qla2x00_find_all_fabric_devs()
6381 if (found && NVME_TARGET(vha->hw, fcport)) { in qla2x00_find_all_fabric_devs()
6382 if (fcport->disc_state == DSC_DELETE_PEND) { in qla2x00_find_all_fabric_devs()
6384 vha->fcport_count--; in qla2x00_find_all_fabric_devs()
6385 fcport->login_succ = 0; in qla2x00_find_all_fabric_devs()
6390 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla2x00_find_all_fabric_devs()
6394 new_fcport->scan_state = QLA_FCPORT_FOUND; in qla2x00_find_all_fabric_devs()
6395 list_add_tail(&new_fcport->list, &vha->vp_fcports); in qla2x00_find_all_fabric_devs()
6397 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla2x00_find_all_fabric_devs()
6401 nxt_d_id.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
6408 new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); in qla2x00_find_all_fabric_devs()
6409 new_fcport->d_id.b24 = nxt_d_id.b24; in qla2x00_find_all_fabric_devs()
6417 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_find_all_fabric_devs()
6418 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
6421 if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) in qla2x00_find_all_fabric_devs()
6424 if (fcport->scan_state == QLA_FCPORT_SCAN) { in qla2x00_find_all_fabric_devs()
6427 atomic_read(&fcport->state) == FCS_ONLINE) { in qla2x00_find_all_fabric_devs()
6430 if (fcport->loop_id != FC_NO_LOOP_ID && in qla2x00_find_all_fabric_devs()
6431 (fcport->flags & FCF_FCP2_DEVICE) == 0 && in qla2x00_find_all_fabric_devs()
6432 fcport->port_type != FCT_INITIATOR && in qla2x00_find_all_fabric_devs()
6433 fcport->port_type != FCT_BROADCAST) { in qla2x00_find_all_fabric_devs()
6437 fcport->port_name); in qla2x00_find_all_fabric_devs()
6444 if (fcport->scan_state == QLA_FCPORT_FOUND && in qla2x00_find_all_fabric_devs()
6445 (fcport->flags & FCF_LOGIN_NEEDED) != 0) in qla2x00_find_all_fabric_devs()
6456 int lid = NPH_MGMT_SERVER - vha->vp_idx; in qla2x00_reserve_mgmt_server_loop_id()
6458 struct qla_hw_data *ha = vha->hw; in qla2x00_reserve_mgmt_server_loop_id()
6460 if (vha->vp_idx == 0) { in qla2x00_reserve_mgmt_server_loop_id()
6461 set_bit(NPH_MGMT_SERVER, ha->loop_id_map); in qla2x00_reserve_mgmt_server_loop_id()
6466 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_reserve_mgmt_server_loop_id()
6467 for (; lid > 0; lid--) { in qla2x00_reserve_mgmt_server_loop_id()
6468 if (!test_bit(lid, vha->hw->loop_id_map)) { in qla2x00_reserve_mgmt_server_loop_id()
6469 set_bit(lid, vha->hw->loop_id_map); in qla2x00_reserve_mgmt_server_loop_id()
6474 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_reserve_mgmt_server_loop_id()
6488 * 0 - Login successfully
6489 * 1 - Login failed
6490 * 2 - Initiator device
6491 * 3 - Fatal error
6501 struct qla_hw_data *ha = vha->hw; in qla2x00_fabric_login()
6510 fcport->loop_id, fcport->d_id.b.domain, in qla2x00_fabric_login()
6511 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_fabric_login()
6514 rval = ha->isp_ops->fabric_login(vha, fcport->loop_id, in qla2x00_fabric_login()
6515 fcport->d_id.b.domain, fcport->d_id.b.area, in qla2x00_fabric_login()
6516 fcport->d_id.b.al_pa, mb, BIT_0); in qla2x00_fabric_login()
6529 tmp_loopid = fcport->loop_id; in qla2x00_fabric_login()
6530 fcport->loop_id = mb[1]; in qla2x00_fabric_login()
6533 "Fabric Login: port in use - next loop " in qla2x00_fabric_login()
6535 fcport->loop_id, fcport->d_id.b.domain, in qla2x00_fabric_login()
6536 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_fabric_login()
6550 *next_loopid = (fcport->loop_id + 1); in qla2x00_fabric_login()
6554 fcport->port_type = FCT_INITIATOR; in qla2x00_fabric_login()
6556 fcport->port_type = FCT_TARGET; in qla2x00_fabric_login()
6558 fcport->flags |= FCF_FCP2_DEVICE; in qla2x00_fabric_login()
6563 fcport->supported_classes |= FC_COS_CLASS2; in qla2x00_fabric_login()
6565 fcport->supported_classes |= FC_COS_CLASS3; in qla2x00_fabric_login()
6569 fcport->flags |= in qla2x00_fabric_login()
6579 fcport->loop_id++; in qla2x00_fabric_login()
6591 *next_loopid = fcport->loop_id; in qla2x00_fabric_login()
6592 ha->isp_ops->fabric_logout(vha, fcport->loop_id, in qla2x00_fabric_login()
6593 fcport->d_id.b.domain, fcport->d_id.b.area, in qla2x00_fabric_login()
6594 fcport->d_id.b.al_pa); in qla2x00_fabric_login()
6605 "jiffies=%lx.\n", mb[0], fcport->d_id.b.domain, in qla2x00_fabric_login()
6606 fcport->d_id.b.area, fcport->d_id.b.al_pa, in qla2x00_fabric_login()
6607 fcport->loop_id, jiffies); in qla2x00_fabric_login()
6609 *next_loopid = fcport->loop_id; in qla2x00_fabric_login()
6610 ha->isp_ops->fabric_logout(vha, fcport->loop_id, in qla2x00_fabric_login()
6611 fcport->d_id.b.domain, fcport->d_id.b.area, in qla2x00_fabric_login()
6612 fcport->d_id.b.al_pa); in qla2x00_fabric_login()
6614 fcport->login_retry = 0; in qla2x00_fabric_login()
6633 * 0 - Login successfully
6634 * 1 - Login failed
6635 * 3 - Fatal error
6673 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_loop_resync()
6674 if (vha->flags.online) { in qla2x00_loop_resync()
6679 if (!IS_QLAFX00(vha->hw)) { in qla2x00_loop_resync()
6684 qla2x00_marker(vha, vha->hw->base_qpair, in qla2x00_loop_resync()
6686 vha->marker_needed = 0; in qla2x00_loop_resync()
6690 clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_loop_resync()
6692 if (IS_QLAFX00(vha->hw)) in qla2x00_loop_resync()
6697 wait_time--; in qla2x00_loop_resync()
6698 } while (!atomic_read(&vha->loop_down_timer) && in qla2x00_loop_resync()
6699 !(test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) in qla2x00_loop_resync()
6701 &vha->dpc_flags))); in qla2x00_loop_resync()
6705 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) in qla2x00_loop_resync()
6727 if (!test_and_set_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags)) { in qla2x00_perform_loop_resync()
6729 atomic_set(&ha->loop_down_timer, 0); in qla2x00_perform_loop_resync()
6730 if (!(ha->device_flags & DFLG_NO_CABLE)) { in qla2x00_perform_loop_resync()
6731 atomic_set(&ha->loop_state, LOOP_UP); in qla2x00_perform_loop_resync()
6732 set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); in qla2x00_perform_loop_resync()
6733 set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags); in qla2x00_perform_loop_resync()
6734 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); in qla2x00_perform_loop_resync()
6738 atomic_set(&ha->loop_state, LOOP_DEAD); in qla2x00_perform_loop_resync()
6740 clear_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags); in qla2x00_perform_loop_resync()
6751 struct qla_hw_data *ha = base_vha->hw; in qla2x00_update_fcports()
6754 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_update_fcports()
6756 list_for_each_entry_safe(vha, tvp, &base_vha->hw->vp_list, list) { in qla2x00_update_fcports()
6757 atomic_inc(&vha->vref_count); in qla2x00_update_fcports()
6758 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_update_fcports()
6759 if (fcport->drport && in qla2x00_update_fcports()
6760 atomic_read(&fcport->state) != FCS_UNCONFIGURED) { in qla2x00_update_fcports()
6761 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_update_fcports()
6764 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_update_fcports()
6767 atomic_dec(&vha->vref_count); in qla2x00_update_fcports()
6768 wake_up(&vha->vref_waitq); in qla2x00_update_fcports()
6770 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_update_fcports()
6777 struct qla_hw_data *ha = vha->hw; in qla83xx_reset_ownership()
6798 (i != ha->portnum)) { in qla83xx_reset_ownership()
6808 ((i + 8) != ha->portnum)) { in qla83xx_reset_ownership()
6815 * Prepare drv-presence mask based on fcoe functions present. in qla83xx_reset_ownership()
6816 * However consider only valid physical fcoe function numbers (0-15). in qla83xx_reset_ownership()
6818 drv_presence_mask = ~((1 << (ha->portnum)) | in qla83xx_reset_ownership()
6823 * - No other protocol drivers present. in qla83xx_reset_ownership()
6824 * - This is the lowest among fcoe functions. */ in qla83xx_reset_ownership()
6826 (ha->portnum < fcoe_other_function)) { in qla83xx_reset_ownership()
6829 ha->flags.nic_core_reset_owner = 1; in qla83xx_reset_ownership()
6837 struct qla_hw_data *ha = vha->hw; in __qla83xx_set_drv_ack()
6842 drv_ack |= (1 << ha->portnum); in __qla83xx_set_drv_ack()
6853 struct qla_hw_data *ha = vha->hw; in __qla83xx_clear_drv_ack()
6858 drv_ack &= ~(1 << ha->portnum); in __qla83xx_clear_drv_ack()
6865 /* Assumes idc-lock always held on entry */
6869 struct qla_hw_data *ha = vha->hw; in qla83xx_idc_audit()
6874 ha->idc_audit_ts = (jiffies_to_msecs(jiffies) / 1000); in qla83xx_idc_audit()
6875 idc_audit_reg = (ha->portnum) | in qla83xx_idc_audit()
6876 (IDC_AUDIT_TIMESTAMP << 7) | (ha->idc_audit_ts << 8); in qla83xx_idc_audit()
6881 duration_secs = ((jiffies_to_msecs(jiffies) - in qla83xx_idc_audit()
6882 jiffies_to_msecs(ha->idc_audit_ts)) / 1000); in qla83xx_idc_audit()
6883 idc_audit_reg = (ha->portnum) | in qla83xx_idc_audit()
6899 struct qla_hw_data *ha = vha->hw; in qla83xx_initiating_reset()
6905 "NIC Core reset has been disabled. idc-control=0x%x\n", in qla83xx_initiating_reset()
6910 /* Set NEED-RESET iff in READY state and we are the reset-owner */ in qla83xx_initiating_reset()
6912 if (ha->flags.nic_core_reset_owner && dev_state == QLA8XXX_DEV_READY) { in qla83xx_initiating_reset()
6922 /* Wait for IDC state change READY -> NEED_RESET */ in qla83xx_initiating_reset()
6931 /* Send IDC ack by writing to drv-ack register */ in qla83xx_initiating_reset()
6953 struct qla_hw_data *ha = vha->hw; in qla83xx_check_driver_presence()
6956 if (drv_presence & (1 << ha->portnum)) in qla83xx_check_driver_presence()
6966 struct qla_hw_data *ha = vha->hw; in qla83xx_nic_core_reset()
6971 if (vha->device_flags & DFLG_DEV_FAILED) { in qla83xx_nic_core_reset()
6982 ha->portnum); in qla83xx_nic_core_reset()
6992 * Perform reset if we are the reset-owner, in qla83xx_nic_core_reset()
6999 ha->flags.nic_core_hung = 0; in qla83xx_nic_core_reset()
7014 struct qla_hw_data *ha = vha->hw; in qla2xxx_mctp_dump()
7024 if (!ha->mctp_dump) { in qla2xxx_mctp_dump()
7025 ha->mctp_dump = dma_alloc_coherent(&ha->pdev->dev, in qla2xxx_mctp_dump()
7026 MCTP_DUMP_SIZE, &ha->mctp_dump_dma, GFP_KERNEL); in qla2xxx_mctp_dump()
7028 if (!ha->mctp_dump) { in qla2xxx_mctp_dump()
7036 rval = qla2x00_dump_mctp_data(vha, ha->mctp_dump_dma, in qla2xxx_mctp_dump()
7044 vha->host_no, ha->mctp_dump); in qla2xxx_mctp_dump()
7045 ha->mctp_dumped = 1; in qla2xxx_mctp_dump()
7048 if (!ha->flags.nic_core_reset_hdlr_active && !ha->portnum) { in qla2xxx_mctp_dump()
7049 ha->flags.nic_core_reset_hdlr_active = 1; in qla2xxx_mctp_dump()
7058 ha->flags.nic_core_reset_hdlr_active = 0; in qla2xxx_mctp_dump()
7076 struct qla_hw_data *ha = vha->hw; in qla2x00_quiesce_io()
7081 "Quiescing I/O - ha=%p.\n", ha); in qla2x00_quiesce_io()
7083 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); in qla2x00_quiesce_io()
7084 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { in qla2x00_quiesce_io()
7085 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_quiesce_io()
7088 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_quiesce_io()
7089 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) { in qla2x00_quiesce_io()
7090 atomic_inc(&vp->vref_count); in qla2x00_quiesce_io()
7091 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_quiesce_io()
7095 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_quiesce_io()
7096 atomic_dec(&vp->vref_count); in qla2x00_quiesce_io()
7098 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_quiesce_io()
7100 if (!atomic_read(&vha->loop_down_timer)) in qla2x00_quiesce_io()
7101 atomic_set(&vha->loop_down_timer, in qla2x00_quiesce_io()
7112 struct qla_hw_data *ha = vha->hw; in qla2x00_abort_isp_cleanup()
7122 vha->flags.online = 0; in qla2x00_abort_isp_cleanup()
7123 ha->flags.chip_reset_done = 0; in qla2x00_abort_isp_cleanup()
7124 clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_abort_isp_cleanup()
7125 vha->qla_stats.total_isp_aborts++; in qla2x00_abort_isp_cleanup()
7128 "Performing ISP error recovery - ha=%p.\n", ha); in qla2x00_abort_isp_cleanup()
7130 ha->flags.purge_mbox = 1; in qla2x00_abort_isp_cleanup()
7136 ha->isp_ops->reset_chip(vha); in qla2x00_abort_isp_cleanup()
7138 ha->link_data_rate = PORT_SPEED_UNKNOWN; in qla2x00_abort_isp_cleanup()
7140 ha->flags.rida_fmt2 = 0; in qla2x00_abort_isp_cleanup()
7141 ha->flags.n2n_ae = 0; in qla2x00_abort_isp_cleanup()
7142 ha->flags.lip_ae = 0; in qla2x00_abort_isp_cleanup()
7143 ha->current_topology = 0; in qla2x00_abort_isp_cleanup()
7145 ha->flags.fw_init_done = 0; in qla2x00_abort_isp_cleanup()
7146 ha->chip_reset++; in qla2x00_abort_isp_cleanup()
7147 ha->base_qpair->chip_reset = ha->chip_reset; in qla2x00_abort_isp_cleanup()
7148 ha->base_qpair->cmd_cnt = ha->base_qpair->cmd_completion_cnt = 0; in qla2x00_abort_isp_cleanup()
7149 ha->base_qpair->prev_completion_cnt = 0; in qla2x00_abort_isp_cleanup()
7150 for (i = 0; i < ha->max_qpairs; i++) { in qla2x00_abort_isp_cleanup()
7151 if (ha->queue_pair_map[i]) { in qla2x00_abort_isp_cleanup()
7152 ha->queue_pair_map[i]->chip_reset = in qla2x00_abort_isp_cleanup()
7153 ha->base_qpair->chip_reset; in qla2x00_abort_isp_cleanup()
7154 ha->queue_pair_map[i]->cmd_cnt = in qla2x00_abort_isp_cleanup()
7155 ha->queue_pair_map[i]->cmd_completion_cnt = 0; in qla2x00_abort_isp_cleanup()
7156 ha->base_qpair->prev_completion_cnt = 0; in qla2x00_abort_isp_cleanup()
7161 if (atomic_read(&ha->num_pend_mbx_stage3)) { in qla2x00_abort_isp_cleanup()
7162 clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); in qla2x00_abort_isp_cleanup()
7163 complete(&ha->mbx_intr_comp); in qla2x00_abort_isp_cleanup()
7167 while (atomic_read(&ha->num_pend_mbx_stage3) || in qla2x00_abort_isp_cleanup()
7168 atomic_read(&ha->num_pend_mbx_stage2) || in qla2x00_abort_isp_cleanup()
7169 atomic_read(&ha->num_pend_mbx_stage1)) { in qla2x00_abort_isp_cleanup()
7175 ha->flags.purge_mbox = 0; in qla2x00_abort_isp_cleanup()
7177 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); in qla2x00_abort_isp_cleanup()
7178 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { in qla2x00_abort_isp_cleanup()
7179 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_abort_isp_cleanup()
7182 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
7183 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) { in qla2x00_abort_isp_cleanup()
7184 atomic_inc(&vp->vref_count); in qla2x00_abort_isp_cleanup()
7185 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
7189 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
7190 atomic_dec(&vp->vref_count); in qla2x00_abort_isp_cleanup()
7192 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
7194 if (!atomic_read(&vha->loop_down_timer)) in qla2x00_abort_isp_cleanup()
7195 atomic_set(&vha->loop_down_timer, in qla2x00_abort_isp_cleanup()
7200 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_abort_isp_cleanup()
7201 fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); in qla2x00_abort_isp_cleanup()
7202 fcport->scan_state = 0; in qla2x00_abort_isp_cleanup()
7204 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
7205 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) { in qla2x00_abort_isp_cleanup()
7206 atomic_inc(&vp->vref_count); in qla2x00_abort_isp_cleanup()
7207 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
7209 list_for_each_entry(fcport, &vp->vp_fcports, list) in qla2x00_abort_isp_cleanup()
7210 fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); in qla2x00_abort_isp_cleanup()
7212 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
7213 atomic_dec(&vp->vref_count); in qla2x00_abort_isp_cleanup()
7215 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
7224 vha->flags.online = 0; in qla2x00_abort_isp_cleanup()
7248 struct qla_hw_data *ha = vha->hw; in qla2x00_abort_isp()
7250 struct req_que *req = ha->req_q_map[0]; in qla2x00_abort_isp()
7253 if (vha->flags.online) { in qla2x00_abort_isp()
7256 vha->dport_status |= DPORT_DIAG_CHIP_RESET_IN_PROGRESS; in qla2x00_abort_isp()
7257 vha->dport_status &= ~DPORT_DIAG_IN_PROGRESS; in qla2x00_abort_isp()
7259 if (vha->hw->flags.port_isolated) in qla2x00_abort_isp()
7264 "ISP Abort - ISP reg disconnect, exiting.\n"); in qla2x00_abort_isp()
7268 if (test_and_clear_bit(ISP_ABORT_TO_ROM, &vha->dpc_flags)) { in qla2x00_abort_isp()
7269 ha->flags.chip_reset_done = 1; in qla2x00_abort_isp()
7270 vha->flags.online = 1; in qla2x00_abort_isp()
7272 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_abort_isp()
7281 "Error while clearing DRV-Presence.\n"); in qla2x00_abort_isp()
7284 if (unlikely(pci_channel_offline(ha->pdev) && in qla2x00_abort_isp()
7285 ha->flags.pci_channel_io_perm_failure)) { in qla2x00_abort_isp()
7286 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_abort_isp()
7291 switch (vha->qlini_mode) { in qla2x00_abort_isp()
7306 ha->isp_ops->get_flash_version(vha, req->ring); in qla2x00_abort_isp()
7310 "ISP Abort - ISP reg disconnect pre nvram config, exiting.\n"); in qla2x00_abort_isp()
7313 ha->isp_ops->nvram_config(vha); in qla2x00_abort_isp()
7317 "ISP Abort - ISP reg disconnect post nvmram config, exiting.\n"); in qla2x00_abort_isp()
7321 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla2x00_abort_isp()
7323 if (!atomic_read(&vha->loop_down_timer)) { in qla2x00_abort_isp()
7328 vha->marker_needed = 1; in qla2x00_abort_isp()
7331 vha->flags.online = 1; in qla2x00_abort_isp()
7333 ha->isp_ops->enable_intrs(ha); in qla2x00_abort_isp()
7335 ha->isp_abort_cnt = 0; in qla2x00_abort_isp()
7336 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_abort_isp()
7340 if (ha->fce) { in qla2x00_abort_isp()
7341 ha->flags.fce_enabled = 1; in qla2x00_abort_isp()
7342 memset(ha->fce, 0, in qla2x00_abort_isp()
7343 fce_calc_size(ha->fce_bufs)); in qla2x00_abort_isp()
7345 ha->fce_dma, ha->fce_bufs, ha->fce_mb, in qla2x00_abort_isp()
7346 &ha->fce_bufs); in qla2x00_abort_isp()
7351 ha->flags.fce_enabled = 0; in qla2x00_abort_isp()
7355 if (ha->eft) { in qla2x00_abort_isp()
7356 memset(ha->eft, 0, EFT_SIZE); in qla2x00_abort_isp()
7358 ha->eft_dma, EFT_NUM_BUFFERS); in qla2x00_abort_isp()
7366 vha->flags.online = 1; in qla2x00_abort_isp()
7367 if (test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { in qla2x00_abort_isp()
7368 if (ha->isp_abort_cnt == 0) { in qla2x00_abort_isp()
7370 "ISP error recover failed - " in qla2x00_abort_isp()
7377 vha->flags.online = 0; in qla2x00_abort_isp()
7379 &vha->dpc_flags); in qla2x00_abort_isp()
7382 ha->isp_abort_cnt--; in qla2x00_abort_isp()
7384 "ISP abort - retry remaining %d.\n", in qla2x00_abort_isp()
7385 ha->isp_abort_cnt); in qla2x00_abort_isp()
7389 ha->isp_abort_cnt = MAX_RETRIES_OF_ISP_ABORT; in qla2x00_abort_isp()
7391 "ISP error recovery - retrying (%d) " in qla2x00_abort_isp()
7392 "more times.\n", ha->isp_abort_cnt); in qla2x00_abort_isp()
7393 set_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_abort_isp()
7400 if (vha->hw->flags.port_isolated) { in qla2x00_abort_isp()
7408 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp()
7409 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) { in qla2x00_abort_isp()
7410 if (vp->vp_idx) { in qla2x00_abort_isp()
7411 atomic_inc(&vp->vref_count); in qla2x00_abort_isp()
7412 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp()
7416 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp()
7417 atomic_dec(&vp->vref_count); in qla2x00_abort_isp()
7420 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp()
7427 "Error while setting DRV-Presence.\n"); in qla2x00_abort_isp()
7451 struct qla_hw_data *ha = vha->hw; in qla2x00_restart_isp()
7455 vha->flags.online = 0; in qla2x00_restart_isp()
7456 status = ha->isp_ops->chip_diag(vha); in qla2x00_restart_isp()
7468 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla2x00_restart_isp()
7469 ha->flags.chip_reset_done = 1; in qla2x00_restart_isp()
7477 return vha->device_flags & DFLG_NO_CABLE ? 0 : status; in qla2x00_restart_isp()
7481 qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL); in qla2x00_restart_isp()
7482 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_restart_isp()
7492 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); in qla25xx_init_queues()
7493 int ret = -1; in qla25xx_init_queues()
7496 for (i = 1; i < ha->max_rsp_queues; i++) { in qla25xx_init_queues()
7497 rsp = ha->rsp_q_map[i]; in qla25xx_init_queues()
7498 if (rsp && test_bit(i, ha->rsp_qid_map)) { in qla25xx_init_queues()
7499 rsp->options &= ~BIT_0; in qla25xx_init_queues()
7504 __func__, rsp->id); in qla25xx_init_queues()
7508 __func__, rsp->id); in qla25xx_init_queues()
7511 for (i = 1; i < ha->max_req_queues; i++) { in qla25xx_init_queues()
7512 req = ha->req_q_map[i]; in qla25xx_init_queues()
7513 if (req && test_bit(i, ha->req_qid_map)) { in qla25xx_init_queues()
7515 req->options &= ~BIT_0; in qla25xx_init_queues()
7520 __func__, req->id); in qla25xx_init_queues()
7524 __func__, req->id); in qla25xx_init_queues()
7541 struct qla_hw_data *ha = vha->hw; in qla2x00_reset_adapter()
7542 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_reset_adapter()
7544 vha->flags.online = 0; in qla2x00_reset_adapter()
7545 ha->isp_ops->disable_intrs(ha); in qla2x00_reset_adapter()
7547 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_reset_adapter()
7548 wrt_reg_word(®->hccr, HCCR_RESET_RISC); in qla2x00_reset_adapter()
7549 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_adapter()
7550 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2x00_reset_adapter()
7551 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_adapter()
7552 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_reset_adapter()
7561 struct qla_hw_data *ha = vha->hw; in qla24xx_reset_adapter()
7562 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla24xx_reset_adapter()
7567 vha->flags.online = 0; in qla24xx_reset_adapter()
7568 ha->isp_ops->disable_intrs(ha); in qla24xx_reset_adapter()
7570 spin_lock_irqsave(&ha->hardware_lock, flags); in qla24xx_reset_adapter()
7571 wrt_reg_dword(®->hccr, HCCRX_SET_RISC_RESET); in qla24xx_reset_adapter()
7572 rd_reg_dword(®->hccr); in qla24xx_reset_adapter()
7573 wrt_reg_dword(®->hccr, HCCRX_REL_RISC_PAUSE); in qla24xx_reset_adapter()
7574 rd_reg_dword(®->hccr); in qla24xx_reset_adapter()
7575 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_reset_adapter()
7578 ha->isp_ops->enable_intrs(ha); in qla24xx_reset_adapter()
7590 struct qla_hw_data *ha = vha->hw; in qla24xx_nvram_wwn_from_ofw()
7591 struct pci_dev *pdev = ha->pdev; in qla24xx_nvram_wwn_from_ofw()
7596 val = of_get_property(dp, "port-wwn", &len); in qla24xx_nvram_wwn_from_ofw()
7598 memcpy(nv->port_name, val, WWN_SIZE); in qla24xx_nvram_wwn_from_ofw()
7600 val = of_get_property(dp, "node-wwn", &len); in qla24xx_nvram_wwn_from_ofw()
7602 memcpy(nv->node_name, val, WWN_SIZE); in qla24xx_nvram_wwn_from_ofw()
7616 struct qla_hw_data *ha = vha->hw; in qla24xx_nvram_config()
7619 icb = (struct init_cb_24xx *)ha->init_cb; in qla24xx_nvram_config()
7620 nv = ha->nvram; in qla24xx_nvram_config()
7623 if (ha->port_no == 0) { in qla24xx_nvram_config()
7624 ha->nvram_base = FA_NVRAM_FUNC0_ADDR; in qla24xx_nvram_config()
7625 ha->vpd_base = FA_NVRAM_VPD0_ADDR; in qla24xx_nvram_config()
7627 ha->nvram_base = FA_NVRAM_FUNC1_ADDR; in qla24xx_nvram_config()
7628 ha->vpd_base = FA_NVRAM_VPD1_ADDR; in qla24xx_nvram_config()
7631 ha->nvram_size = sizeof(*nv); in qla24xx_nvram_config()
7632 ha->vpd_size = FA_NVRAM_VPD_SIZE; in qla24xx_nvram_config()
7635 ha->vpd = ha->nvram + VPD_OFFSET; in qla24xx_nvram_config()
7636 ha->isp_ops->read_nvram(vha, ha->vpd, in qla24xx_nvram_config()
7637 ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4); in qla24xx_nvram_config()
7641 ha->isp_ops->read_nvram(vha, dptr, ha->nvram_base, ha->nvram_size); in qla24xx_nvram_config()
7642 for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++, dptr++) in qla24xx_nvram_config()
7648 nv, ha->nvram_size); in qla24xx_nvram_config()
7651 if (chksum || memcmp("ISP ", nv->id, sizeof(nv->id)) || in qla24xx_nvram_config()
7652 le16_to_cpu(nv->nvram_version) < ICB_VERSION) { in qla24xx_nvram_config()
7656 chksum, nv->id, nv->nvram_version); in qla24xx_nvram_config()
7659 "Falling back to functioning (yet invalid -- WWPN) " in qla24xx_nvram_config()
7665 memset(nv, 0, ha->nvram_size); in qla24xx_nvram_config()
7666 nv->nvram_version = cpu_to_le16(ICB_VERSION); in qla24xx_nvram_config()
7667 nv->version = cpu_to_le16(ICB_VERSION); in qla24xx_nvram_config()
7668 nv->frame_payload_size = cpu_to_le16(2048); in qla24xx_nvram_config()
7669 nv->execution_throttle = cpu_to_le16(0xFFFF); in qla24xx_nvram_config()
7670 nv->exchange_count = cpu_to_le16(0); in qla24xx_nvram_config()
7671 nv->hard_address = cpu_to_le16(124); in qla24xx_nvram_config()
7672 nv->port_name[0] = 0x21; in qla24xx_nvram_config()
7673 nv->port_name[1] = 0x00 + ha->port_no + 1; in qla24xx_nvram_config()
7674 nv->port_name[2] = 0x00; in qla24xx_nvram_config()
7675 nv->port_name[3] = 0xe0; in qla24xx_nvram_config()
7676 nv->port_name[4] = 0x8b; in qla24xx_nvram_config()
7677 nv->port_name[5] = 0x1c; in qla24xx_nvram_config()
7678 nv->port_name[6] = 0x55; in qla24xx_nvram_config()
7679 nv->port_name[7] = 0x86; in qla24xx_nvram_config()
7680 nv->node_name[0] = 0x20; in qla24xx_nvram_config()
7681 nv->node_name[1] = 0x00; in qla24xx_nvram_config()
7682 nv->node_name[2] = 0x00; in qla24xx_nvram_config()
7683 nv->node_name[3] = 0xe0; in qla24xx_nvram_config()
7684 nv->node_name[4] = 0x8b; in qla24xx_nvram_config()
7685 nv->node_name[5] = 0x1c; in qla24xx_nvram_config()
7686 nv->node_name[6] = 0x55; in qla24xx_nvram_config()
7687 nv->node_name[7] = 0x86; in qla24xx_nvram_config()
7689 nv->login_retry_count = cpu_to_le16(8); in qla24xx_nvram_config()
7690 nv->interrupt_delay_timer = cpu_to_le16(0); in qla24xx_nvram_config()
7691 nv->login_timeout = cpu_to_le16(0); in qla24xx_nvram_config()
7692 nv->firmware_options_1 = in qla24xx_nvram_config()
7694 nv->firmware_options_2 = cpu_to_le32(2 << 4); in qla24xx_nvram_config()
7695 nv->firmware_options_2 |= cpu_to_le32(BIT_12); in qla24xx_nvram_config()
7696 nv->firmware_options_3 = cpu_to_le32(2 << 13); in qla24xx_nvram_config()
7697 nv->host_p = cpu_to_le32(BIT_11|BIT_10); in qla24xx_nvram_config()
7698 nv->efi_parameters = cpu_to_le32(0); in qla24xx_nvram_config()
7699 nv->reset_delay = 5; in qla24xx_nvram_config()
7700 nv->max_luns_per_target = cpu_to_le16(128); in qla24xx_nvram_config()
7701 nv->port_down_retry_count = cpu_to_le16(30); in qla24xx_nvram_config()
7702 nv->link_down_timeout = cpu_to_le16(30); in qla24xx_nvram_config()
7709 nv->firmware_options_1 &= cpu_to_le32(~BIT_13); in qla24xx_nvram_config()
7711 nv->host_p &= cpu_to_le32(~BIT_10); in qla24xx_nvram_config()
7717 memset(icb, 0, ha->init_cb_size); in qla24xx_nvram_config()
7721 dptr2 = (uint8_t *)&nv->version; in qla24xx_nvram_config()
7722 cnt = (uint8_t *)&icb->response_q_inpointer - (uint8_t *)&icb->version; in qla24xx_nvram_config()
7723 while (cnt--) in qla24xx_nvram_config()
7726 icb->login_retry_count = nv->login_retry_count; in qla24xx_nvram_config()
7727 icb->link_down_on_nos = nv->link_down_on_nos; in qla24xx_nvram_config()
7730 dptr1 = (uint8_t *)&icb->interrupt_delay_timer; in qla24xx_nvram_config()
7731 dptr2 = (uint8_t *)&nv->interrupt_delay_timer; in qla24xx_nvram_config()
7732 cnt = (uint8_t *)&icb->reserved_3 - in qla24xx_nvram_config()
7733 (uint8_t *)&icb->interrupt_delay_timer; in qla24xx_nvram_config()
7734 while (cnt--) in qla24xx_nvram_config()
7736 ha->frame_payload_size = le16_to_cpu(icb->frame_payload_size); in qla24xx_nvram_config()
7740 qla2x00_set_model_info(vha, nv->model_name, sizeof(nv->model_name), in qla24xx_nvram_config()
7745 if (nv->host_p & cpu_to_le32(BIT_15)) { in qla24xx_nvram_config()
7747 memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); in qla24xx_nvram_config()
7748 memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); in qla24xx_nvram_config()
7752 if ((icb->firmware_options_1 & cpu_to_le32(BIT_14)) == 0) { in qla24xx_nvram_config()
7757 memcpy(icb->node_name, icb->port_name, WWN_SIZE); in qla24xx_nvram_config()
7758 icb->node_name[0] &= 0xF0; in qla24xx_nvram_config()
7762 ha->flags.disable_risc_code_load = 0; in qla24xx_nvram_config()
7763 ha->flags.enable_lip_reset = 0; in qla24xx_nvram_config()
7764 ha->flags.enable_lip_full_login = in qla24xx_nvram_config()
7765 le32_to_cpu(nv->host_p) & BIT_10 ? 1 : 0; in qla24xx_nvram_config()
7766 ha->flags.enable_target_reset = in qla24xx_nvram_config()
7767 le32_to_cpu(nv->host_p) & BIT_11 ? 1 : 0; in qla24xx_nvram_config()
7768 ha->flags.enable_led_scheme = 0; in qla24xx_nvram_config()
7769 ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1 : 0; in qla24xx_nvram_config()
7771 ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) & in qla24xx_nvram_config()
7774 memcpy(ha->fw_seriallink_options24, nv->seriallink_options, in qla24xx_nvram_config()
7775 sizeof(ha->fw_seriallink_options24)); in qla24xx_nvram_config()
7778 ha->serial0 = icb->port_name[5]; in qla24xx_nvram_config()
7779 ha->serial1 = icb->port_name[6]; in qla24xx_nvram_config()
7780 ha->serial2 = icb->port_name[7]; in qla24xx_nvram_config()
7781 memcpy(vha->node_name, icb->node_name, WWN_SIZE); in qla24xx_nvram_config()
7782 memcpy(vha->port_name, icb->port_name, WWN_SIZE); in qla24xx_nvram_config()
7784 icb->execution_throttle = cpu_to_le16(0xFFFF); in qla24xx_nvram_config()
7786 ha->retry_count = le16_to_cpu(nv->login_retry_count); in qla24xx_nvram_config()
7789 if (le16_to_cpu(nv->login_timeout) < ql2xlogintimeout) in qla24xx_nvram_config()
7790 nv->login_timeout = cpu_to_le16(ql2xlogintimeout); in qla24xx_nvram_config()
7791 if (le16_to_cpu(nv->login_timeout) < 4) in qla24xx_nvram_config()
7792 nv->login_timeout = cpu_to_le16(4); in qla24xx_nvram_config()
7793 ha->login_timeout = le16_to_cpu(nv->login_timeout); in qla24xx_nvram_config()
7796 ha->r_a_tov = 100; in qla24xx_nvram_config()
7798 ha->loop_reset_delay = nv->reset_delay; in qla24xx_nvram_config()
7810 if (le16_to_cpu(nv->link_down_timeout) == 0) { in qla24xx_nvram_config()
7811 ha->loop_down_abort_time = in qla24xx_nvram_config()
7812 (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); in qla24xx_nvram_config()
7814 ha->link_down_timeout = le16_to_cpu(nv->link_down_timeout); in qla24xx_nvram_config()
7815 ha->loop_down_abort_time = in qla24xx_nvram_config()
7816 (LOOP_DOWN_TIME - ha->link_down_timeout); in qla24xx_nvram_config()
7820 ha->port_down_retry_count = le16_to_cpu(nv->port_down_retry_count); in qla24xx_nvram_config()
7822 ha->port_down_retry_count = qlport_down_retry; in qla24xx_nvram_config()
7825 ha->login_retry_count = le16_to_cpu(nv->login_retry_count); in qla24xx_nvram_config()
7826 if (ha->port_down_retry_count == in qla24xx_nvram_config()
7827 le16_to_cpu(nv->port_down_retry_count) && in qla24xx_nvram_config()
7828 ha->port_down_retry_count > 3) in qla24xx_nvram_config()
7829 ha->login_retry_count = ha->port_down_retry_count; in qla24xx_nvram_config()
7830 else if (ha->port_down_retry_count > (int)ha->login_retry_count) in qla24xx_nvram_config()
7831 ha->login_retry_count = ha->port_down_retry_count; in qla24xx_nvram_config()
7833 ha->login_retry_count = ql2xloginretrycount; in qla24xx_nvram_config()
7836 icb->firmware_options_3 |= cpu_to_le32(BIT_8); in qla24xx_nvram_config()
7839 if (!vha->flags.init_done) { in qla24xx_nvram_config()
7840 ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & in qla24xx_nvram_config()
7842 ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? in qla24xx_nvram_config()
7843 le16_to_cpu(icb->interrupt_delay_timer) : 2; in qla24xx_nvram_config()
7845 icb->firmware_options_2 &= cpu_to_le32( in qla24xx_nvram_config()
7847 if (ha->zio_mode != QLA_ZIO_DISABLED) { in qla24xx_nvram_config()
7848 ha->zio_mode = QLA_ZIO_MODE_6; in qla24xx_nvram_config()
7852 ha->zio_mode, ha->zio_timer * 100); in qla24xx_nvram_config()
7854 icb->firmware_options_2 |= cpu_to_le32( in qla24xx_nvram_config()
7855 (uint32_t)ha->zio_mode); in qla24xx_nvram_config()
7856 icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer); in qla24xx_nvram_config()
7873 image_status->image_status_mask, in qla27xx_print_image()
7874 le16_to_cpu(image_status->generation), in qla27xx_print_image()
7875 image_status->ver_major, in qla27xx_print_image()
7876 image_status->ver_minor, in qla27xx_print_image()
7877 image_status->bitmap, in qla27xx_print_image()
7878 le32_to_cpu(image_status->checksum), in qla27xx_print_image()
7879 le32_to_cpu(image_status->signature)); in qla27xx_print_image()
7886 ulong signature = le32_to_cpu(image_status->signature); in qla28xx_check_aux_image_status_signature()
7894 ulong signature = le32_to_cpu(image_status->signature); in qla27xx_check_image_status_signature()
7908 for ( ; n--; p++) in qla27xx_image_status_checksum()
7917 return aux->bitmap & bitmask ? in qla28xx_component_bitmask()
7925 active_regions->aux.board_config = in qla28xx_component_status()
7928 active_regions->aux.vpd_nvram = in qla28xx_component_status()
7931 active_regions->aux.npiv_config_0_1 = in qla28xx_component_status()
7934 active_regions->aux.npiv_config_2_3 = in qla28xx_component_status()
7937 active_regions->aux.nvme_params = in qla28xx_component_status()
7948 le16_to_cpu(pri_image_status->generation) - in qla27xx_compare_image_generation()
7949 le16_to_cpu(sec_image_status->generation); in qla27xx_compare_image_generation()
7960 struct qla_hw_data *ha = vha->hw; in qla28xx_get_aux_images()
7965 if (!ha->flt_region_aux_img_status_pri) { in qla28xx_get_aux_images()
7971 ha->flt_region_aux_img_status_pri, in qla28xx_get_aux_images()
7997 if (!ha->flt_region_aux_img_status_sec) { in qla28xx_get_aux_images()
8004 ha->flt_region_aux_img_status_sec, in qla28xx_get_aux_images()
8048 active_regions->aux.board_config, in qla28xx_get_aux_images()
8049 active_regions->aux.vpd_nvram, in qla28xx_get_aux_images()
8050 active_regions->aux.npiv_config_0_1, in qla28xx_get_aux_images()
8051 active_regions->aux.npiv_config_2_3, in qla28xx_get_aux_images()
8052 active_regions->aux.nvme_params); in qla28xx_get_aux_images()
8059 struct qla_hw_data *ha = vha->hw; in qla27xx_get_active_image()
8064 if (!ha->flt_region_img_status_pri) { in qla27xx_get_active_image()
8070 ha->flt_region_img_status_pri, sizeof(pri_image_status) >> 2) != in qla27xx_get_active_image()
8099 if (!ha->flt_region_img_status_sec) { in qla27xx_get_active_image()
8105 ha->flt_region_img_status_sec, sizeof(sec_image_status) >> 2); in qla27xx_get_active_image()
8131 active_regions->global = QLA27XX_PRIMARY_IMAGE; in qla27xx_get_active_image()
8134 if (!active_regions->global || in qla27xx_get_active_image()
8137 active_regions->global = QLA27XX_SECONDARY_IMAGE; in qla27xx_get_active_image()
8142 active_regions->global == QLA27XX_DEFAULT_IMAGE ? in qla27xx_get_active_image()
8144 active_regions->global == QLA27XX_PRIMARY_IMAGE ? in qla27xx_get_active_image()
8146 active_regions->global == QLA27XX_SECONDARY_IMAGE ? in qla27xx_get_active_image()
8148 active_regions->global); in qla27xx_get_active_image()
8169 struct qla_hw_data *ha = vha->hw; in qla24xx_load_risc_flash()
8170 struct req_que *req = ha->req_q_map[0]; in qla24xx_load_risc_flash()
8171 struct fwdt *fwdt = ha->fwdt; in qla24xx_load_risc_flash()
8176 dcode = (uint32_t *)req->ring; in qla24xx_load_risc_flash()
8189 dcode = (uint32_t *)req->ring; in qla24xx_load_risc_flash()
8194 "-> Loading segment %u...\n", j); in qla24xx_load_risc_flash()
8203 dlen = ha->fw_transfer_size >> 2; in qla24xx_load_risc_flash()
8209 "-> Loading fragment %u: %#x <- %#x (%#lx dwords)...\n", in qla24xx_load_risc_flash()
8215 rval = qla2x00_load_ram(vha, req->dma, risc_addr, dlen); in qla24xx_load_risc_flash()
8218 "-> Failed load firmware fragment %u.\n", in qla24xx_load_risc_flash()
8225 risc_size -= dlen; in qla24xx_load_risc_flash()
8233 ql_dbg(ql_dbg_init, vha, 0x0160, "-> templates = %u\n", templates); in qla24xx_load_risc_flash()
8235 vfree(fwdt->template); in qla24xx_load_risc_flash()
8236 fwdt->template = NULL; in qla24xx_load_risc_flash()
8237 fwdt->length = 0; in qla24xx_load_risc_flash()
8239 dcode = (uint32_t *)req->ring; in qla24xx_load_risc_flash()
8243 "-> fwdt%u template array at %#x (%#x dwords)\n", in qla24xx_load_risc_flash()
8247 "-> fwdt%u failed to read array\n", j); in qla24xx_load_risc_flash()
8253 risc_size -= 8; in qla24xx_load_risc_flash()
8256 "-> fwdt%u template allocate template %#x words...\n", in qla24xx_load_risc_flash()
8258 fwdt->template = vmalloc(risc_size * sizeof(*dcode)); in qla24xx_load_risc_flash()
8259 if (!fwdt->template) { in qla24xx_load_risc_flash()
8261 "-> fwdt%u failed allocate template.\n", j); in qla24xx_load_risc_flash()
8265 dcode = fwdt->template; in qla24xx_load_risc_flash()
8270 "-> fwdt%u failed template validate\n", j); in qla24xx_load_risc_flash()
8276 "-> fwdt%u template size %#lx bytes (%#lx words)\n", in qla24xx_load_risc_flash()
8280 "-> fwdt%u template exceeds array (%-lu bytes)\n", in qla24xx_load_risc_flash()
8281 j, dlen - risc_size * sizeof(*dcode)); in qla24xx_load_risc_flash()
8285 fwdt->length = dlen; in qla24xx_load_risc_flash()
8287 "-> fwdt%u loaded template ok\n", j); in qla24xx_load_risc_flash()
8295 vfree(fwdt->template); in qla24xx_load_risc_flash()
8296 fwdt->template = NULL; in qla24xx_load_risc_flash()
8297 fwdt->length = 0; in qla24xx_load_risc_flash()
8313 struct qla_hw_data *ha = vha->hw; in qla2x00_load_risc()
8314 struct req_que *req = ha->req_q_map[0]; in qla2x00_load_risc()
8328 wcode = (uint16_t *)req->ring; in qla2x00_load_risc()
8330 fwcode = (__force __be16 *)blob->fw->data; in qla2x00_load_risc()
8334 if (blob->fw->size < 8 * sizeof(uint16_t)) { in qla2x00_load_risc()
8337 blob->fw->size); in qla2x00_load_risc()
8353 seg = blob->segs; in qla2x00_load_risc()
8361 if (blob->fw->size < fwclen) { in qla2x00_load_risc()
8364 "(%zd).\n", blob->fw->size); in qla2x00_load_risc()
8370 wlen = (uint16_t)(ha->fw_transfer_size >> 1); in qla2x00_load_risc()
8380 rval = qla2x00_load_ram(vha, req->dma, risc_addr, in qla2x00_load_risc()
8391 risc_size -= wlen; in qla2x00_load_risc()
8416 struct qla_hw_data *ha = vha->hw; in qla24xx_load_risc_blob()
8417 struct req_que *req = ha->req_q_map[0]; in qla24xx_load_risc_blob()
8418 struct fwdt *fwdt = ha->fwdt; in qla24xx_load_risc_blob()
8421 "-> FW: Loading via request-firmware.\n"); in qla24xx_load_risc_blob()
8426 "-> Firmware file not found.\n"); in qla24xx_load_risc_blob()
8431 fwcode = (__force __be32 *)blob->fw->data; in qla24xx_load_risc_blob()
8436 blob->fw->size); in qla24xx_load_risc_blob()
8443 dcode = (uint32_t *)req->ring; in qla24xx_load_risc_blob()
8448 "-> Loading segment %u...\n", j); in qla24xx_load_risc_blob()
8457 dlen = ha->fw_transfer_size >> 2; in qla24xx_load_risc_blob()
8463 "-> Loading fragment %u: %#x <- %#x (%#lx words)...\n", in qla24xx_load_risc_blob()
8465 (uint32_t)(fwcode - (typeof(fwcode))blob->fw->data), in qla24xx_load_risc_blob()
8471 rval = qla2x00_load_ram(vha, req->dma, risc_addr, dlen); in qla24xx_load_risc_blob()
8474 "-> Failed load firmware fragment %u.\n", in qla24xx_load_risc_blob()
8481 risc_size -= dlen; in qla24xx_load_risc_blob()
8489 ql_dbg(ql_dbg_init, vha, 0x0170, "-> templates = %u\n", templates); in qla24xx_load_risc_blob()
8491 vfree(fwdt->template); in qla24xx_load_risc_blob()
8492 fwdt->template = NULL; in qla24xx_load_risc_blob()
8493 fwdt->length = 0; in qla24xx_load_risc_blob()
8497 "-> fwdt%u template array at %#x (%#x dwords)\n", in qla24xx_load_risc_blob()
8498 j, (uint32_t)((void *)fwcode - (void *)blob->fw->data), in qla24xx_load_risc_blob()
8502 "-> fwdt%u failed to read array\n", j); in qla24xx_load_risc_blob()
8508 risc_size -= 8; in qla24xx_load_risc_blob()
8511 "-> fwdt%u template allocate template %#x words...\n", in qla24xx_load_risc_blob()
8513 fwdt->template = vmalloc(risc_size * sizeof(*dcode)); in qla24xx_load_risc_blob()
8514 if (!fwdt->template) { in qla24xx_load_risc_blob()
8516 "-> fwdt%u failed allocate template.\n", j); in qla24xx_load_risc_blob()
8520 dcode = fwdt->template; in qla24xx_load_risc_blob()
8526 "-> fwdt%u failed template validate\n", j); in qla24xx_load_risc_blob()
8532 "-> fwdt%u template size %#lx bytes (%#lx words)\n", in qla24xx_load_risc_blob()
8536 "-> fwdt%u template exceeds array (%-lu bytes)\n", in qla24xx_load_risc_blob()
8537 j, dlen - risc_size * sizeof(*dcode)); in qla24xx_load_risc_blob()
8541 fwdt->length = dlen; in qla24xx_load_risc_blob()
8543 "-> fwdt%u loaded template ok\n", j); in qla24xx_load_risc_blob()
8551 vfree(fwdt->template); in qla24xx_load_risc_blob()
8552 fwdt->template = NULL; in qla24xx_load_risc_blob()
8553 fwdt->length = 0; in qla24xx_load_risc_blob()
8568 * 1) Firmware via request-firmware interface (.bin file). in qla24xx_load_risc()
8576 vha->hw->flt_region_fw); in qla24xx_load_risc()
8583 struct qla_hw_data *ha = vha->hw; in qla81xx_load_risc()
8591 * 2) Firmware via request-firmware interface (.bin file). in qla81xx_load_risc()
8592 * 3) Golden-Firmware residing in flash -- (limited operation). in qla81xx_load_risc()
8605 rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_fw_sec); in qla81xx_load_risc()
8612 rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_fw); in qla81xx_load_risc()
8618 if (!rval || !ha->flt_region_gold_fw) in qla81xx_load_risc()
8623 rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_gold_fw); in qla81xx_load_risc()
8628 ha->flags.running_gold_fw = 1; in qla81xx_load_risc()
8636 struct qla_hw_data *ha = vha->hw; in qla2x00_try_to_stop_firmware()
8638 if (ha->flags.pci_channel_io_perm_failure) in qla2x00_try_to_stop_firmware()
8642 if (!ha->fw_major_version) in qla2x00_try_to_stop_firmware()
8644 if (!ha->flags.fw_started) in qla2x00_try_to_stop_firmware()
8649 ret != QLA_INVALID_COMMAND && retries ; retries--) { in qla2x00_try_to_stop_firmware()
8650 ha->isp_ops->reset_chip(vha); in qla2x00_try_to_stop_firmware()
8651 if (ha->isp_ops->chip_diag(vha) != QLA_SUCCESS) in qla2x00_try_to_stop_firmware()
8656 "Attempting retry of stop-firmware command.\n"); in qla2x00_try_to_stop_firmware()
8661 ha->flags.fw_init_done = 0; in qla2x00_try_to_stop_firmware()
8670 struct qla_hw_data *ha = vha->hw; in qla24xx_configure_vhba()
8671 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); in qla24xx_configure_vhba()
8673 if (!vha->vp_idx) in qla24xx_configure_vhba()
8674 return -EINVAL; in qla24xx_configure_vhba()
8679 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla24xx_configure_vhba()
8680 qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL); in qla24xx_configure_vhba()
8683 vha->flags.management_server_logged_in = 0; in qla24xx_configure_vhba()
8686 rval2 = ha->isp_ops->fabric_login(vha, NPH_SNS, 0xff, 0xff, 0xfc, mb, in qla24xx_configure_vhba()
8701 atomic_set(&vha->loop_down_timer, 0); in qla24xx_configure_vhba()
8702 atomic_set(&vha->loop_state, LOOP_UP); in qla24xx_configure_vhba()
8703 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla24xx_configure_vhba()
8704 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla24xx_configure_vhba()
8719 struct qla_hw_data *ha = vha->hw; in qla84xx_get_chip()
8725 if (cs84xx->bus == ha->pdev->bus) { in qla84xx_get_chip()
8726 kref_get(&cs84xx->kref); in qla84xx_get_chip()
8735 kref_init(&cs84xx->kref); in qla84xx_get_chip()
8736 spin_lock_init(&cs84xx->access_lock); in qla84xx_get_chip()
8737 mutex_init(&cs84xx->fw_update_mutex); in qla84xx_get_chip()
8738 cs84xx->bus = ha->pdev->bus; in qla84xx_get_chip()
8740 list_add_tail(&cs84xx->list, &qla_cs84xx_list); in qla84xx_get_chip()
8753 list_del(&cs84xx->list); in __qla84xx_chip_release()
8761 struct qla_hw_data *ha = vha->hw; in qla84xx_put_chip()
8763 if (ha->cs84xx) in qla84xx_put_chip()
8764 kref_put(&ha->cs84xx->kref, __qla84xx_chip_release); in qla84xx_put_chip()
8772 struct qla_hw_data *ha = vha->hw; in qla84xx_init_chip()
8774 mutex_lock(&ha->cs84xx->fw_update_mutex); in qla84xx_init_chip()
8778 mutex_unlock(&ha->cs84xx->fw_update_mutex); in qla84xx_init_chip()
8796 struct qla_hw_data *ha = vha->hw; in qla81xx_nvram_config()
8801 icb = (struct init_cb_81xx *)ha->init_cb; in qla81xx_nvram_config()
8802 nv = ha->nvram; in qla81xx_nvram_config()
8805 ha->nvram_size = sizeof(*nv); in qla81xx_nvram_config()
8806 ha->vpd_size = FA_NVRAM_VPD_SIZE; in qla81xx_nvram_config()
8808 ha->vpd_size = FA_VPD_SIZE_82XX; in qla81xx_nvram_config()
8814 ha->vpd = ha->nvram + VPD_OFFSET; in qla81xx_nvram_config()
8816 faddr = ha->flt_region_vpd; in qla81xx_nvram_config()
8819 faddr = ha->flt_region_vpd_sec; in qla81xx_nvram_config()
8825 ha->isp_ops->read_optrom(vha, ha->vpd, faddr << 2, ha->vpd_size); in qla81xx_nvram_config()
8828 faddr = ha->flt_region_nvram; in qla81xx_nvram_config()
8831 faddr = ha->flt_region_nvram_sec; in qla81xx_nvram_config()
8837 ha->isp_ops->read_optrom(vha, ha->nvram, faddr << 2, ha->nvram_size); in qla81xx_nvram_config()
8840 for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++, dptr++) in qla81xx_nvram_config()
8846 nv, ha->nvram_size); in qla81xx_nvram_config()
8849 if (chksum || memcmp("ISP ", nv->id, sizeof(nv->id)) || in qla81xx_nvram_config()
8850 le16_to_cpu(nv->nvram_version) < ICB_VERSION) { in qla81xx_nvram_config()
8854 chksum, nv->id, le16_to_cpu(nv->nvram_version)); in qla81xx_nvram_config()
8857 "Falling back to functioning (yet invalid -- WWPN) " in qla81xx_nvram_config()
8863 memset(nv, 0, ha->nvram_size); in qla81xx_nvram_config()
8864 nv->nvram_version = cpu_to_le16(ICB_VERSION); in qla81xx_nvram_config()
8865 nv->version = cpu_to_le16(ICB_VERSION); in qla81xx_nvram_config()
8866 nv->frame_payload_size = cpu_to_le16(2048); in qla81xx_nvram_config()
8867 nv->execution_throttle = cpu_to_le16(0xFFFF); in qla81xx_nvram_config()
8868 nv->exchange_count = cpu_to_le16(0); in qla81xx_nvram_config()
8869 nv->port_name[0] = 0x21; in qla81xx_nvram_config()
8870 nv->port_name[1] = 0x00 + ha->port_no + 1; in qla81xx_nvram_config()
8871 nv->port_name[2] = 0x00; in qla81xx_nvram_config()
8872 nv->port_name[3] = 0xe0; in qla81xx_nvram_config()
8873 nv->port_name[4] = 0x8b; in qla81xx_nvram_config()
8874 nv->port_name[5] = 0x1c; in qla81xx_nvram_config()
8875 nv->port_name[6] = 0x55; in qla81xx_nvram_config()
8876 nv->port_name[7] = 0x86; in qla81xx_nvram_config()
8877 nv->node_name[0] = 0x20; in qla81xx_nvram_config()
8878 nv->node_name[1] = 0x00; in qla81xx_nvram_config()
8879 nv->node_name[2] = 0x00; in qla81xx_nvram_config()
8880 nv->node_name[3] = 0xe0; in qla81xx_nvram_config()
8881 nv->node_name[4] = 0x8b; in qla81xx_nvram_config()
8882 nv->node_name[5] = 0x1c; in qla81xx_nvram_config()
8883 nv->node_name[6] = 0x55; in qla81xx_nvram_config()
8884 nv->node_name[7] = 0x86; in qla81xx_nvram_config()
8885 nv->login_retry_count = cpu_to_le16(8); in qla81xx_nvram_config()
8886 nv->interrupt_delay_timer = cpu_to_le16(0); in qla81xx_nvram_config()
8887 nv->login_timeout = cpu_to_le16(0); in qla81xx_nvram_config()
8888 nv->firmware_options_1 = in qla81xx_nvram_config()
8890 nv->firmware_options_2 = cpu_to_le32(2 << 4); in qla81xx_nvram_config()
8891 nv->firmware_options_2 |= cpu_to_le32(BIT_12); in qla81xx_nvram_config()
8892 nv->firmware_options_3 = cpu_to_le32(2 << 13); in qla81xx_nvram_config()
8893 nv->host_p = cpu_to_le32(BIT_11|BIT_10); in qla81xx_nvram_config()
8894 nv->efi_parameters = cpu_to_le32(0); in qla81xx_nvram_config()
8895 nv->reset_delay = 5; in qla81xx_nvram_config()
8896 nv->max_luns_per_target = cpu_to_le16(128); in qla81xx_nvram_config()
8897 nv->port_down_retry_count = cpu_to_le16(30); in qla81xx_nvram_config()
8898 nv->link_down_timeout = cpu_to_le16(180); in qla81xx_nvram_config()
8899 nv->enode_mac[0] = 0x00; in qla81xx_nvram_config()
8900 nv->enode_mac[1] = 0xC0; in qla81xx_nvram_config()
8901 nv->enode_mac[2] = 0xDD; in qla81xx_nvram_config()
8902 nv->enode_mac[3] = 0x04; in qla81xx_nvram_config()
8903 nv->enode_mac[4] = 0x05; in qla81xx_nvram_config()
8904 nv->enode_mac[5] = 0x06 + ha->port_no + 1; in qla81xx_nvram_config()
8910 nv->frame_payload_size &= cpu_to_le16(~7); in qla81xx_nvram_config()
8915 memset(icb, 0, ha->init_cb_size); in qla81xx_nvram_config()
8919 dptr2 = (uint8_t *)&nv->version; in qla81xx_nvram_config()
8920 cnt = (uint8_t *)&icb->response_q_inpointer - (uint8_t *)&icb->version; in qla81xx_nvram_config()
8921 while (cnt--) in qla81xx_nvram_config()
8924 icb->login_retry_count = nv->login_retry_count; in qla81xx_nvram_config()
8927 dptr1 = (uint8_t *)&icb->interrupt_delay_timer; in qla81xx_nvram_config()
8928 dptr2 = (uint8_t *)&nv->interrupt_delay_timer; in qla81xx_nvram_config()
8929 cnt = (uint8_t *)&icb->reserved_5 - in qla81xx_nvram_config()
8930 (uint8_t *)&icb->interrupt_delay_timer; in qla81xx_nvram_config()
8931 while (cnt--) in qla81xx_nvram_config()
8934 memcpy(icb->enode_mac, nv->enode_mac, sizeof(icb->enode_mac)); in qla81xx_nvram_config()
8936 if (!memcmp(icb->enode_mac, "\0\0\0\0\0\0", sizeof(icb->enode_mac))) { in qla81xx_nvram_config()
8937 icb->enode_mac[0] = 0x00; in qla81xx_nvram_config()
8938 icb->enode_mac[1] = 0xC0; in qla81xx_nvram_config()
8939 icb->enode_mac[2] = 0xDD; in qla81xx_nvram_config()
8940 icb->enode_mac[3] = 0x04; in qla81xx_nvram_config()
8941 icb->enode_mac[4] = 0x05; in qla81xx_nvram_config()
8942 icb->enode_mac[5] = 0x06 + ha->port_no + 1; in qla81xx_nvram_config()
8945 /* Use extended-initialization control block. */ in qla81xx_nvram_config()
8946 memcpy(ha->ex_init_cb, &nv->ex_version, sizeof(*ha->ex_init_cb)); in qla81xx_nvram_config()
8947 ha->frame_payload_size = le16_to_cpu(icb->frame_payload_size); in qla81xx_nvram_config()
8951 qla2x00_set_model_info(vha, nv->model_name, sizeof(nv->model_name), in qla81xx_nvram_config()
8957 if (nv->host_p & cpu_to_le32(BIT_15)) { in qla81xx_nvram_config()
8958 memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); in qla81xx_nvram_config()
8959 memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); in qla81xx_nvram_config()
8963 if ((icb->firmware_options_1 & cpu_to_le32(BIT_14)) == 0) { in qla81xx_nvram_config()
8968 memcpy(icb->node_name, icb->port_name, WWN_SIZE); in qla81xx_nvram_config()
8969 icb->node_name[0] &= 0xF0; in qla81xx_nvram_config()
8973 if ((nv->enhanced_features & BIT_7) == 0) in qla81xx_nvram_config()
8974 ha->flags.scm_supported_a = 1; in qla81xx_nvram_config()
8978 ha->flags.disable_risc_code_load = 0; in qla81xx_nvram_config()
8979 ha->flags.enable_lip_reset = 0; in qla81xx_nvram_config()
8980 ha->flags.enable_lip_full_login = in qla81xx_nvram_config()
8981 le32_to_cpu(nv->host_p) & BIT_10 ? 1 : 0; in qla81xx_nvram_config()
8982 ha->flags.enable_target_reset = in qla81xx_nvram_config()
8983 le32_to_cpu(nv->host_p) & BIT_11 ? 1 : 0; in qla81xx_nvram_config()
8984 ha->flags.enable_led_scheme = 0; in qla81xx_nvram_config()
8985 ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1 : 0; in qla81xx_nvram_config()
8987 ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) & in qla81xx_nvram_config()
8991 ha->serial0 = icb->port_name[5]; in qla81xx_nvram_config()
8992 ha->serial1 = icb->port_name[6]; in qla81xx_nvram_config()
8993 ha->serial2 = icb->port_name[7]; in qla81xx_nvram_config()
8994 memcpy(vha->node_name, icb->node_name, WWN_SIZE); in qla81xx_nvram_config()
8995 memcpy(vha->port_name, icb->port_name, WWN_SIZE); in qla81xx_nvram_config()
8997 icb->execution_throttle = cpu_to_le16(0xFFFF); in qla81xx_nvram_config()
8999 ha->retry_count = le16_to_cpu(nv->login_retry_count); in qla81xx_nvram_config()
9002 if (le16_to_cpu(nv->login_timeout) < ql2xlogintimeout) in qla81xx_nvram_config()
9003 nv->login_timeout = cpu_to_le16(ql2xlogintimeout); in qla81xx_nvram_config()
9004 if (le16_to_cpu(nv->login_timeout) < 4) in qla81xx_nvram_config()
9005 nv->login_timeout = cpu_to_le16(4); in qla81xx_nvram_config()
9006 ha->login_timeout = le16_to_cpu(nv->login_timeout); in qla81xx_nvram_config()
9009 ha->r_a_tov = 100; in qla81xx_nvram_config()
9011 ha->loop_reset_delay = nv->reset_delay; in qla81xx_nvram_config()
9023 if (le16_to_cpu(nv->link_down_timeout) == 0) { in qla81xx_nvram_config()
9024 ha->loop_down_abort_time = in qla81xx_nvram_config()
9025 (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); in qla81xx_nvram_config()
9027 ha->link_down_timeout = le16_to_cpu(nv->link_down_timeout); in qla81xx_nvram_config()
9028 ha->loop_down_abort_time = in qla81xx_nvram_config()
9029 (LOOP_DOWN_TIME - ha->link_down_timeout); in qla81xx_nvram_config()
9033 ha->port_down_retry_count = le16_to_cpu(nv->port_down_retry_count); in qla81xx_nvram_config()
9035 ha->port_down_retry_count = qlport_down_retry; in qla81xx_nvram_config()
9038 ha->login_retry_count = le16_to_cpu(nv->login_retry_count); in qla81xx_nvram_config()
9039 if (ha->port_down_retry_count == in qla81xx_nvram_config()
9040 le16_to_cpu(nv->port_down_retry_count) && in qla81xx_nvram_config()
9041 ha->port_down_retry_count > 3) in qla81xx_nvram_config()
9042 ha->login_retry_count = ha->port_down_retry_count; in qla81xx_nvram_config()
9043 else if (ha->port_down_retry_count > (int)ha->login_retry_count) in qla81xx_nvram_config()
9044 ha->login_retry_count = ha->port_down_retry_count; in qla81xx_nvram_config()
9046 ha->login_retry_count = ql2xloginretrycount; in qla81xx_nvram_config()
9048 /* if not running MSI-X we need handshaking on interrupts */ in qla81xx_nvram_config()
9049 if (!vha->hw->flags.msix_enabled && in qla81xx_nvram_config()
9051 icb->firmware_options_2 |= cpu_to_le32(BIT_22); in qla81xx_nvram_config()
9054 if (!vha->flags.init_done) { in qla81xx_nvram_config()
9055 ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & in qla81xx_nvram_config()
9057 ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? in qla81xx_nvram_config()
9058 le16_to_cpu(icb->interrupt_delay_timer) : 2; in qla81xx_nvram_config()
9060 icb->firmware_options_2 &= cpu_to_le32( in qla81xx_nvram_config()
9062 vha->flags.process_response_queue = 0; in qla81xx_nvram_config()
9063 if (ha->zio_mode != QLA_ZIO_DISABLED) { in qla81xx_nvram_config()
9064 ha->zio_mode = QLA_ZIO_MODE_6; in qla81xx_nvram_config()
9068 ha->zio_mode, in qla81xx_nvram_config()
9069 ha->zio_timer * 100); in qla81xx_nvram_config()
9071 icb->firmware_options_2 |= cpu_to_le32( in qla81xx_nvram_config()
9072 (uint32_t)ha->zio_mode); in qla81xx_nvram_config()
9073 icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer); in qla81xx_nvram_config()
9074 vha->flags.process_response_queue = 1; in qla81xx_nvram_config()
9078 icb->firmware_options_3 |= cpu_to_le32(BIT_0); in qla81xx_nvram_config()
9081 icb->firmware_options_3 |= cpu_to_le32(BIT_8); in qla81xx_nvram_config()
9084 ha->fc4_type_priority = qla2xxx_get_fc4_priority(vha); in qla81xx_nvram_config()
9097 struct qla_hw_data *ha = vha->hw; in qla82xx_restart_isp()
9103 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla82xx_restart_isp()
9104 ha->flags.chip_reset_done = 1; in qla82xx_restart_isp()
9109 qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL); in qla82xx_restart_isp()
9110 vha->flags.online = 1; in qla82xx_restart_isp()
9111 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla82xx_restart_isp()
9115 if ((vha->device_flags & DFLG_NO_CABLE)) in qla82xx_restart_isp()
9120 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla82xx_restart_isp()
9122 if (!atomic_read(&vha->loop_down_timer)) { in qla82xx_restart_isp()
9127 vha->marker_needed = 1; in qla82xx_restart_isp()
9130 ha->isp_ops->enable_intrs(ha); in qla82xx_restart_isp()
9132 ha->isp_abort_cnt = 0; in qla82xx_restart_isp()
9133 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla82xx_restart_isp()
9138 if (ha->fce) { in qla82xx_restart_isp()
9139 ha->flags.fce_enabled = 1; in qla82xx_restart_isp()
9140 memset(ha->fce, 0, in qla82xx_restart_isp()
9141 fce_calc_size(ha->fce_bufs)); in qla82xx_restart_isp()
9143 ha->fce_dma, ha->fce_bufs, ha->fce_mb, in qla82xx_restart_isp()
9144 &ha->fce_bufs); in qla82xx_restart_isp()
9149 ha->flags.fce_enabled = 0; in qla82xx_restart_isp()
9153 if (ha->eft) { in qla82xx_restart_isp()
9154 memset(ha->eft, 0, EFT_SIZE); in qla82xx_restart_isp()
9156 ha->eft_dma, EFT_NUM_BUFFERS); in qla82xx_restart_isp()
9169 spin_lock_irqsave(&ha->vport_slock, flags); in qla82xx_restart_isp()
9170 list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) { in qla82xx_restart_isp()
9171 if (vp->vp_idx) { in qla82xx_restart_isp()
9172 atomic_inc(&vp->vref_count); in qla82xx_restart_isp()
9173 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla82xx_restart_isp()
9177 spin_lock_irqsave(&ha->vport_slock, flags); in qla82xx_restart_isp()
9178 atomic_dec(&vp->vref_count); in qla82xx_restart_isp()
9181 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla82xx_restart_isp()
9203 * non-zero (if found)
9204 * -1 (if not found)
9218 struct qla_hw_data *ha = vha->hw; in qla24xx_get_fcp_prio()
9220 if (!ha->fcp_prio_cfg || !ha->flags.fcp_prio_enabled) in qla24xx_get_fcp_prio()
9221 return -1; in qla24xx_get_fcp_prio()
9223 priority = -1; in qla24xx_get_fcp_prio()
9224 entries = ha->fcp_prio_cfg->num_entries; in qla24xx_get_fcp_prio()
9225 pri_entry = &ha->fcp_prio_cfg->entry[0]; in qla24xx_get_fcp_prio()
9230 if (!(pri_entry->flags & FCP_PRIO_ENTRY_VALID)) { in qla24xx_get_fcp_prio()
9236 if (pri_entry->flags & FCP_PRIO_ENTRY_SPID_VALID) { in qla24xx_get_fcp_prio()
9237 pid1 = pri_entry->src_pid & INVALID_PORT_ID; in qla24xx_get_fcp_prio()
9238 pid2 = vha->d_id.b24 & INVALID_PORT_ID; in qla24xx_get_fcp_prio()
9246 if (pri_entry->flags & FCP_PRIO_ENTRY_DPID_VALID) { in qla24xx_get_fcp_prio()
9247 pid1 = pri_entry->dst_pid & INVALID_PORT_ID; in qla24xx_get_fcp_prio()
9248 pid2 = fcport->d_id.b24 & INVALID_PORT_ID; in qla24xx_get_fcp_prio()
9256 if (pri_entry->flags & FCP_PRIO_ENTRY_SWWN_VALID) { in qla24xx_get_fcp_prio()
9257 wwn1 = wwn_to_u64(vha->port_name); in qla24xx_get_fcp_prio()
9258 wwn2 = wwn_to_u64(pri_entry->src_wwpn); in qla24xx_get_fcp_prio()
9259 if (wwn2 == (uint64_t)-1) in qla24xx_get_fcp_prio()
9266 if (pri_entry->flags & FCP_PRIO_ENTRY_DWWN_VALID) { in qla24xx_get_fcp_prio()
9267 wwn1 = wwn_to_u64(fcport->port_name); in qla24xx_get_fcp_prio()
9268 wwn2 = wwn_to_u64(pri_entry->dst_wwpn); in qla24xx_get_fcp_prio()
9269 if (wwn2 == (uint64_t)-1) in qla24xx_get_fcp_prio()
9277 if (pri_entry->flags & FCP_PRIO_ENTRY_TAG_VALID) in qla24xx_get_fcp_prio()
9278 priority = pri_entry->tag; in qla24xx_get_fcp_prio()
9309 if (fcport->port_type != FCT_TARGET || in qla24xx_update_fcport_fcp_prio()
9310 fcport->loop_id == FC_NO_LOOP_ID) in qla24xx_update_fcport_fcp_prio()
9317 if (IS_P3P_TYPE(vha->hw)) { in qla24xx_update_fcport_fcp_prio()
9318 fcport->fcp_prio = priority & 0xf; in qla24xx_update_fcport_fcp_prio()
9322 ret = qla24xx_set_fcp_prio(vha, fcport->loop_id, priority, mb); in qla24xx_update_fcport_fcp_prio()
9324 if (fcport->fcp_prio != priority) in qla24xx_update_fcport_fcp_prio()
9326 "Updated FCP_CMND priority - value=%d loop_id=%d " in qla24xx_update_fcport_fcp_prio()
9328 fcport->loop_id, fcport->d_id.b.domain, in qla24xx_update_fcport_fcp_prio()
9329 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla24xx_update_fcport_fcp_prio()
9330 fcport->fcp_prio = priority & 0xf; in qla24xx_update_fcport_fcp_prio()
9333 "Unable to update FCP_CMND priority - ret=0x%x for " in qla24xx_update_fcport_fcp_prio()
9334 "loop_id=%d port_id=%02x%02x%02x.\n", ret, fcport->loop_id, in qla24xx_update_fcport_fcp_prio()
9335 fcport->d_id.b.domain, fcport->d_id.b.area, in qla24xx_update_fcport_fcp_prio()
9336 fcport->d_id.b.al_pa); in qla24xx_update_fcport_fcp_prio()
9361 list_for_each_entry(fcport, &vha->vp_fcports, list) in qla24xx_update_all_fcp_prio()
9373 struct qla_hw_data *ha = vha->hw; in qla2xxx_create_qpair()
9378 if (!(ha->fw_attributes & BIT_6) || !ha->flags.msix_enabled) { in qla2xxx_create_qpair()
9380 "FW/Driver is not multi-queue capable.\n"); in qla2xxx_create_qpair()
9392 qpair->hw = vha->hw; in qla2xxx_create_qpair()
9393 qpair->vha = vha; in qla2xxx_create_qpair()
9394 qpair->qp_lock_ptr = &qpair->qp_lock; in qla2xxx_create_qpair()
9395 spin_lock_init(&qpair->qp_lock); in qla2xxx_create_qpair()
9396 qpair->use_shadow_reg = IS_SHADOW_REG_CAPABLE(ha) ? 1 : 0; in qla2xxx_create_qpair()
9399 mutex_lock(&ha->mq_lock); in qla2xxx_create_qpair()
9400 qpair_id = find_first_zero_bit(ha->qpair_qid_map, ha->max_qpairs); in qla2xxx_create_qpair()
9401 if (ha->num_qpairs >= ha->max_qpairs) { in qla2xxx_create_qpair()
9402 mutex_unlock(&ha->mq_lock); in qla2xxx_create_qpair()
9407 ha->num_qpairs++; in qla2xxx_create_qpair()
9408 set_bit(qpair_id, ha->qpair_qid_map); in qla2xxx_create_qpair()
9409 ha->queue_pair_map[qpair_id] = qpair; in qla2xxx_create_qpair()
9410 qpair->id = qpair_id; in qla2xxx_create_qpair()
9411 qpair->vp_idx = vp_idx; in qla2xxx_create_qpair()
9412 qpair->fw_started = ha->flags.fw_started; in qla2xxx_create_qpair()
9413 INIT_LIST_HEAD(&qpair->hints_list); in qla2xxx_create_qpair()
9414 qpair->chip_reset = ha->base_qpair->chip_reset; in qla2xxx_create_qpair()
9415 qpair->enable_class_2 = ha->base_qpair->enable_class_2; in qla2xxx_create_qpair()
9416 qpair->enable_explicit_conf = in qla2xxx_create_qpair()
9417 ha->base_qpair->enable_explicit_conf; in qla2xxx_create_qpair()
9419 for (i = 0; i < ha->msix_count; i++) { in qla2xxx_create_qpair()
9420 msix = &ha->msix_entries[i]; in qla2xxx_create_qpair()
9421 if (msix->in_use) in qla2xxx_create_qpair()
9423 qpair->msix = msix; in qla2xxx_create_qpair()
9425 "Vector %x selected for qpair\n", msix->vector); in qla2xxx_create_qpair()
9428 if (!qpair->msix) { in qla2xxx_create_qpair()
9430 "Out of MSI-X vectors!.\n"); in qla2xxx_create_qpair()
9434 qpair->msix->in_use = 1; in qla2xxx_create_qpair()
9435 list_add_tail(&qpair->qp_list_elem, &vha->qp_list); in qla2xxx_create_qpair()
9436 qpair->pdev = ha->pdev; in qla2xxx_create_qpair()
9438 qpair->reqq_start_iocbs = qla_83xx_start_iocbs; in qla2xxx_create_qpair()
9440 mutex_unlock(&ha->mq_lock); in qla2xxx_create_qpair()
9450 qpair->rsp = ha->rsp_q_map[rsp_id]; in qla2xxx_create_qpair()
9461 qpair->req = ha->req_q_map[req_id]; in qla2xxx_create_qpair()
9462 qpair->rsp->req = qpair->req; in qla2xxx_create_qpair()
9463 qpair->rsp->qpair = qpair; in qla2xxx_create_qpair()
9468 if (ha->fw_attributes & BIT_4) in qla2xxx_create_qpair()
9469 qpair->difdix_supported = 1; in qla2xxx_create_qpair()
9472 qpair->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); in qla2xxx_create_qpair()
9473 if (!qpair->srb_mempool) { in qla2xxx_create_qpair()
9476 qpair->id); in qla2xxx_create_qpair()
9481 qpair->online = 1; in qla2xxx_create_qpair()
9483 if (!vha->flags.qpairs_available) in qla2xxx_create_qpair()
9484 vha->flags.qpairs_available = 1; in qla2xxx_create_qpair()
9488 qpair->id); in qla2xxx_create_qpair()
9491 qpair->id); in qla2xxx_create_qpair()
9497 qla25xx_delete_rsp_que(vha, qpair->rsp); in qla2xxx_create_qpair()
9499 mutex_lock(&ha->mq_lock); in qla2xxx_create_qpair()
9500 qpair->msix->in_use = 0; in qla2xxx_create_qpair()
9501 list_del(&qpair->qp_list_elem); in qla2xxx_create_qpair()
9502 if (list_empty(&vha->qp_list)) in qla2xxx_create_qpair()
9503 vha->flags.qpairs_available = 0; in qla2xxx_create_qpair()
9505 ha->queue_pair_map[qpair_id] = NULL; in qla2xxx_create_qpair()
9506 clear_bit(qpair_id, ha->qpair_qid_map); in qla2xxx_create_qpair()
9507 ha->num_qpairs--; in qla2xxx_create_qpair()
9508 mutex_unlock(&ha->mq_lock); in qla2xxx_create_qpair()
9517 struct qla_hw_data *ha = qpair->hw; in qla2xxx_delete_qpair()
9519 qpair->delete_in_progress = 1; in qla2xxx_delete_qpair()
9521 ret = qla25xx_delete_req_que(vha, qpair->req); in qla2xxx_delete_qpair()
9525 ret = qla25xx_delete_rsp_que(vha, qpair->rsp); in qla2xxx_delete_qpair()
9529 mutex_lock(&ha->mq_lock); in qla2xxx_delete_qpair()
9530 ha->queue_pair_map[qpair->id] = NULL; in qla2xxx_delete_qpair()
9531 clear_bit(qpair->id, ha->qpair_qid_map); in qla2xxx_delete_qpair()
9532 ha->num_qpairs--; in qla2xxx_delete_qpair()
9533 list_del(&qpair->qp_list_elem); in qla2xxx_delete_qpair()
9534 if (list_empty(&vha->qp_list)) { in qla2xxx_delete_qpair()
9535 vha->flags.qpairs_available = 0; in qla2xxx_delete_qpair()
9536 vha->flags.qpairs_req_created = 0; in qla2xxx_delete_qpair()
9537 vha->flags.qpairs_rsp_created = 0; in qla2xxx_delete_qpair()
9539 mempool_destroy(qpair->srb_mempool); in qla2xxx_delete_qpair()
9541 mutex_unlock(&ha->mq_lock); in qla2xxx_delete_qpair()
9555 num &= (num - 1); in qla2x00_count_set_bits()
9570 list_for_each_entry_safe(f, tf, &vha->vp_fcports, list) { in qla2x00_get_num_tgts()
9571 if (f->port_type != FCT_TARGET) in qla2x00_get_num_tgts()
9585 vha->hw_err_cnt = 0; in qla2xxx_reset_stats()
9587 vha->short_link_down_cnt = 0; in qla2xxx_reset_stats()
9589 vha->interface_err_cnt = 0; in qla2xxx_reset_stats()
9591 vha->cmd_timeout_cnt = 0; in qla2xxx_reset_stats()
9593 vha->reset_cmd_err_cnt = 0; in qla2xxx_reset_stats()
9595 spin_lock_irqsave(&vha->hw->tgt.sess_lock, int_flags); in qla2xxx_reset_stats()
9596 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2xxx_reset_stats()
9597 fcport->tgt_short_link_down_cnt = 0; in qla2xxx_reset_stats()
9598 fcport->tgt_link_down_time = QLA2XX_MAX_LINK_DOWN_TIME; in qla2xxx_reset_stats()
9600 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, int_flags); in qla2xxx_reset_stats()
9602 vha->link_down_time = QLA2XX_MAX_LINK_DOWN_TIME; in qla2xxx_reset_stats()
9621 struct ql_vnd_stats *rsp_data = &resp->stats; in qla2xxx_get_ini_stats()
9642 rsp_data->entry_count = entry_count; in qla2xxx_get_ini_stats()
9646 rsp_data->entry[i].stat_type = QLA2XX_HW_ERROR; in qla2xxx_get_ini_stats()
9647 rsp_data->entry[i].tgt_num = 0x0; in qla2xxx_get_ini_stats()
9648 rsp_data->entry[i].cnt = vha->hw_err_cnt; in qla2xxx_get_ini_stats()
9653 rsp_data->entry[i].stat_type = QLA2XX_SHT_LNK_DWN; in qla2xxx_get_ini_stats()
9654 rsp_data->entry[i].tgt_num = 0x0; in qla2xxx_get_ini_stats()
9655 rsp_data->entry[i].cnt = vha->short_link_down_cnt; in qla2xxx_get_ini_stats()
9660 rsp_data->entry[i].stat_type = QLA2XX_INT_ERR; in qla2xxx_get_ini_stats()
9661 rsp_data->entry[i].tgt_num = 0x0; in qla2xxx_get_ini_stats()
9662 rsp_data->entry[i].cnt = vha->interface_err_cnt; in qla2xxx_get_ini_stats()
9667 rsp_data->entry[i].stat_type = QLA2XX_CMD_TIMEOUT; in qla2xxx_get_ini_stats()
9668 rsp_data->entry[i].tgt_num = 0x0; in qla2xxx_get_ini_stats()
9669 rsp_data->entry[i].cnt = vha->cmd_timeout_cnt; in qla2xxx_get_ini_stats()
9674 rsp_data->entry[i].stat_type = QLA2XX_RESET_CMD_ERR; in qla2xxx_get_ini_stats()
9675 rsp_data->entry[i].tgt_num = 0x0; in qla2xxx_get_ini_stats()
9676 rsp_data->entry[i].cnt = vha->reset_cmd_err_cnt; in qla2xxx_get_ini_stats()
9684 spin_lock_irqsave(&vha->hw->tgt.sess_lock, int_flags); in qla2xxx_get_ini_stats()
9685 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2xxx_get_ini_stats()
9686 if (fcport->port_type != FCT_TARGET) in qla2xxx_get_ini_stats()
9688 if (!fcport->rport) in qla2xxx_get_ini_stats()
9690 rsp_data->entry[i].stat_type = QLA2XX_TGT_SHT_LNK_DOWN; in qla2xxx_get_ini_stats()
9691 rsp_data->entry[i].tgt_num = fcport->rport->number; in qla2xxx_get_ini_stats()
9692 rsp_data->entry[i].cnt = fcport->tgt_short_link_down_cnt; in qla2xxx_get_ini_stats()
9695 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, int_flags); in qla2xxx_get_ini_stats()
9697 resp->status = EXT_STATUS_OK; in qla2xxx_get_ini_stats()
9706 fc_port_t *fcport = *(fc_port_t **)rport->dd_data; in qla2xxx_get_tgt_stats()
9708 tgt_data->status = 0; in qla2xxx_get_tgt_stats()
9709 tgt_data->stats.entry_count = 1; in qla2xxx_get_tgt_stats()
9710 tgt_data->stats.entry[0].stat_type = flags; in qla2xxx_get_tgt_stats()
9711 tgt_data->stats.entry[0].tgt_num = rport->number; in qla2xxx_get_tgt_stats()
9712 tgt_data->stats.entry[0].cnt = fcport->tgt_short_link_down_cnt; in qla2xxx_get_tgt_stats()
9721 vha->hw->flags.port_isolated = 1; in qla2xxx_disable_port()
9723 if (qla2x00_isp_reg_stat(vha->hw)) { in qla2xxx_disable_port()
9732 if (vha->flags.online) { in qla2xxx_disable_port()
9744 if (qla2x00_isp_reg_stat(vha->hw)) { in qla2xxx_enable_port()
9751 vha->hw->flags.port_isolated = 0; in qla2xxx_enable_port()
9753 vha->flags.online = 1; in qla2xxx_enable_port()
9754 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2xxx_enable_port()