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
44 /* SRB Extensions ---------------------------------------------------------- */
49 srb_t *sp = from_timer(sp, t, u.iocb_cmd.timer); in qla2x00_sp_timeout() local
53 iocb = &sp->u.iocb_cmd; in qla2x00_sp_timeout()
54 iocb->timeout(sp); in qla2x00_sp_timeout()
57 void qla2x00_sp_free(srb_t *sp) in qla2x00_sp_free() argument
59 struct srb_iocb *iocb = &sp->u.iocb_cmd; in qla2x00_sp_free()
61 del_timer(&iocb->timer); in qla2x00_sp_free()
62 qla2x00_rel_sp(sp); in qla2x00_sp_free()
65 void qla2xxx_rel_done_warning(srb_t *sp, int res) in qla2xxx_rel_done_warning() argument
67 WARN_ONCE(1, "Calling done() of an already freed srb %p object\n", sp); in qla2xxx_rel_done_warning()
70 void qla2xxx_rel_free_warning(srb_t *sp) in qla2xxx_rel_free_warning() argument
72 WARN_ONCE(1, "Calling free() of an already freed srb %p object\n", sp); in qla2xxx_rel_free_warning()
75 /* Asynchronous Login/Logout Routines -------------------------------------- */
81 struct qla_hw_data *ha = vha->hw; in qla2x00_get_async_timeout()
84 tmo = ha->r_a_tov / 10 * 2; in qla2x00_get_async_timeout()
92 tmo = ha->login_timeout; in qla2x00_get_async_timeout()
99 srb_t *sp = data; in qla24xx_abort_iocb_timeout() local
100 struct srb_iocb *abt = &sp->u.iocb_cmd; in qla24xx_abort_iocb_timeout()
101 struct qla_qpair *qpair = sp->qpair; in qla24xx_abort_iocb_timeout()
105 if (sp->cmd_sp) in qla24xx_abort_iocb_timeout()
106 ql_dbg(ql_dbg_async, sp->vha, 0x507c, in qla24xx_abort_iocb_timeout()
107 "Abort timeout - cmd hdl=%x, cmd type=%x hdl=%x, type=%x\n", in qla24xx_abort_iocb_timeout()
108 sp->cmd_sp->handle, sp->cmd_sp->type, in qla24xx_abort_iocb_timeout()
109 sp->handle, sp->type); in qla24xx_abort_iocb_timeout()
111 ql_dbg(ql_dbg_async, sp->vha, 0x507c, in qla24xx_abort_iocb_timeout()
112 "Abort timeout 2 - hdl=%x, type=%x\n", in qla24xx_abort_iocb_timeout()
113 sp->handle, sp->type); in qla24xx_abort_iocb_timeout()
115 spin_lock_irqsave(qpair->qp_lock_ptr, flags); in qla24xx_abort_iocb_timeout()
116 for (handle = 1; handle < qpair->req->num_outstanding_cmds; handle++) { in qla24xx_abort_iocb_timeout()
117 if (sp->cmd_sp && (qpair->req->outstanding_cmds[handle] == in qla24xx_abort_iocb_timeout()
118 sp->cmd_sp)) in qla24xx_abort_iocb_timeout()
119 qpair->req->outstanding_cmds[handle] = NULL; in qla24xx_abort_iocb_timeout()
122 if (qpair->req->outstanding_cmds[handle] == sp) { in qla24xx_abort_iocb_timeout()
123 qpair->req->outstanding_cmds[handle] = NULL; in qla24xx_abort_iocb_timeout()
127 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qla24xx_abort_iocb_timeout()
129 if (sp->cmd_sp) in qla24xx_abort_iocb_timeout()
130 sp->cmd_sp->done(sp->cmd_sp, QLA_OS_TIMER_EXPIRED); in qla24xx_abort_iocb_timeout()
132 abt->u.abt.comp_status = cpu_to_le16(CS_TIMEOUT); in qla24xx_abort_iocb_timeout()
133 sp->done(sp, QLA_OS_TIMER_EXPIRED); in qla24xx_abort_iocb_timeout()
136 static void qla24xx_abort_sp_done(srb_t *sp, int res) in qla24xx_abort_sp_done() argument
138 struct srb_iocb *abt = &sp->u.iocb_cmd; in qla24xx_abort_sp_done()
140 del_timer(&sp->u.iocb_cmd.timer); in qla24xx_abort_sp_done()
141 if (sp->flags & SRB_WAKEUP_ON_COMP) in qla24xx_abort_sp_done()
142 complete(&abt->u.abt.comp); in qla24xx_abort_sp_done()
144 sp->free(sp); in qla24xx_abort_sp_done()
149 scsi_qla_host_t *vha = cmd_sp->vha; in qla24xx_async_abort_cmd()
151 srb_t *sp; in qla24xx_async_abort_cmd() local
154 sp = qla2xxx_get_qpair_sp(cmd_sp->vha, cmd_sp->qpair, cmd_sp->fcport, in qla24xx_async_abort_cmd()
156 if (!sp) in qla24xx_async_abort_cmd()
159 abt_iocb = &sp->u.iocb_cmd; in qla24xx_async_abort_cmd()
160 sp->type = SRB_ABT_CMD; in qla24xx_async_abort_cmd()
161 sp->name = "abort"; in qla24xx_async_abort_cmd()
162 sp->qpair = cmd_sp->qpair; in qla24xx_async_abort_cmd()
163 sp->cmd_sp = cmd_sp; in qla24xx_async_abort_cmd()
165 sp->flags = SRB_WAKEUP_ON_COMP; in qla24xx_async_abort_cmd()
167 abt_iocb->timeout = qla24xx_abort_iocb_timeout; in qla24xx_async_abort_cmd()
168 init_completion(&abt_iocb->u.abt.comp); in qla24xx_async_abort_cmd()
170 qla2x00_init_timer(sp, 42); in qla24xx_async_abort_cmd()
172 abt_iocb->u.abt.cmd_hndl = cmd_sp->handle; in qla24xx_async_abort_cmd()
173 abt_iocb->u.abt.req_que_no = cpu_to_le16(cmd_sp->qpair->req->id); in qla24xx_async_abort_cmd()
175 sp->done = qla24xx_abort_sp_done; in qla24xx_async_abort_cmd()
178 "Abort command issued - hdl=%x, type=%x\n", cmd_sp->handle, in qla24xx_async_abort_cmd()
179 cmd_sp->type); in qla24xx_async_abort_cmd()
181 rval = qla2x00_start_sp(sp); in qla24xx_async_abort_cmd()
183 sp->free(sp); in qla24xx_async_abort_cmd()
188 wait_for_completion(&abt_iocb->u.abt.comp); in qla24xx_async_abort_cmd()
189 rval = abt_iocb->u.abt.comp_status == CS_COMPLETE ? in qla24xx_async_abort_cmd()
191 sp->free(sp); in qla24xx_async_abort_cmd()
200 srb_t *sp = data; in qla2x00_async_iocb_timeout() local
201 fc_port_t *fcport = sp->fcport; in qla2x00_async_iocb_timeout()
202 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_iocb_timeout()
207 ql_dbg(ql_dbg_disc, fcport->vha, 0x2071, in qla2x00_async_iocb_timeout()
208 "Async-%s timeout - hdl=%x portid=%06x %8phC.\n", in qla2x00_async_iocb_timeout()
209 sp->name, sp->handle, fcport->d_id.b24, fcport->port_name); in qla2x00_async_iocb_timeout()
211 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_iocb_timeout()
213 pr_info("Async-%s timeout - hdl=%x.\n", in qla2x00_async_iocb_timeout()
214 sp->name, sp->handle); in qla2x00_async_iocb_timeout()
217 switch (sp->type) { in qla2x00_async_iocb_timeout()
219 rc = qla24xx_async_abort_cmd(sp, false); in qla2x00_async_iocb_timeout()
222 lio->u.logio.data[0] = MBS_COMMAND_ERROR; in qla2x00_async_iocb_timeout()
223 lio->u.logio.data[1] = in qla2x00_async_iocb_timeout()
224 lio->u.logio.flags & SRB_LOGIN_RETRIED ? in qla2x00_async_iocb_timeout()
226 spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); in qla2x00_async_iocb_timeout()
227 for (h = 1; h < sp->qpair->req->num_outstanding_cmds; in qla2x00_async_iocb_timeout()
229 if (sp->qpair->req->outstanding_cmds[h] == in qla2x00_async_iocb_timeout()
230 sp) { in qla2x00_async_iocb_timeout()
231 sp->qpair->req->outstanding_cmds[h] = in qla2x00_async_iocb_timeout()
236 spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); in qla2x00_async_iocb_timeout()
237 sp->done(sp, QLA_FUNCTION_TIMEOUT); in qla2x00_async_iocb_timeout()
248 rc = qla24xx_async_abort_cmd(sp, false); in qla2x00_async_iocb_timeout()
250 spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); in qla2x00_async_iocb_timeout()
251 for (h = 1; h < sp->qpair->req->num_outstanding_cmds; in qla2x00_async_iocb_timeout()
253 if (sp->qpair->req->outstanding_cmds[h] == in qla2x00_async_iocb_timeout()
254 sp) { in qla2x00_async_iocb_timeout()
255 sp->qpair->req->outstanding_cmds[h] = in qla2x00_async_iocb_timeout()
260 spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); in qla2x00_async_iocb_timeout()
261 sp->done(sp, QLA_FUNCTION_TIMEOUT); in qla2x00_async_iocb_timeout()
267 static void qla2x00_async_login_sp_done(srb_t *sp, int res) in qla2x00_async_login_sp_done() argument
269 struct scsi_qla_host *vha = sp->vha; in qla2x00_async_login_sp_done()
270 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_login_sp_done()
274 "%s %8phC res %d \n", __func__, sp->fcport->port_name, res); in qla2x00_async_login_sp_done()
276 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_login_sp_done()
278 if (!test_bit(UNLOADING, &vha->dpc_flags)) { in qla2x00_async_login_sp_done()
280 ea.fcport = sp->fcport; in qla2x00_async_login_sp_done()
281 ea.data[0] = lio->u.logio.data[0]; in qla2x00_async_login_sp_done()
282 ea.data[1] = lio->u.logio.data[1]; in qla2x00_async_login_sp_done()
283 ea.iop[0] = lio->u.logio.iop[0]; in qla2x00_async_login_sp_done()
284 ea.iop[1] = lio->u.logio.iop[1]; in qla2x00_async_login_sp_done()
285 ea.sp = sp; in qla2x00_async_login_sp_done()
289 sp->free(sp); in qla2x00_async_login_sp_done()
295 if (wwn_to_u64(fcport->port_name) < in fcport_is_smaller()
296 wwn_to_u64(fcport->vha->port_name)) in fcport_is_smaller()
312 srb_t *sp; in qla2x00_async_login() local
316 if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT) || in qla2x00_async_login()
317 fcport->loop_id == FC_NO_LOOP_ID) { in qla2x00_async_login()
319 "%s: %8phC - not sending command.\n", in qla2x00_async_login()
320 __func__, fcport->port_name); in qla2x00_async_login()
324 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla2x00_async_login()
325 if (!sp) in qla2x00_async_login()
329 fcport->flags |= FCF_ASYNC_SENT; in qla2x00_async_login()
330 fcport->logout_completed = 0; in qla2x00_async_login()
332 sp->type = SRB_LOGIN_CMD; in qla2x00_async_login()
333 sp->name = "login"; in qla2x00_async_login()
334 sp->gen1 = fcport->rscn_gen; in qla2x00_async_login()
335 sp->gen2 = fcport->login_gen; in qla2x00_async_login()
337 lio = &sp->u.iocb_cmd; in qla2x00_async_login()
338 lio->timeout = qla2x00_async_iocb_timeout; in qla2x00_async_login()
339 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); in qla2x00_async_login()
341 sp->done = qla2x00_async_login_sp_done; in qla2x00_async_login()
342 if (N2N_TOPO(fcport->vha->hw) && fcport_is_bigger(fcport)) in qla2x00_async_login()
343 lio->u.logio.flags |= SRB_LOGIN_PRLI_ONLY; in qla2x00_async_login()
345 lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI; in qla2x00_async_login()
347 if (NVME_TARGET(vha->hw, fcport)) in qla2x00_async_login()
348 lio->u.logio.flags |= SRB_LOGIN_SKIP_PRLI; in qla2x00_async_login()
351 "Async-login - %8phC hdl=%x, loopid=%x portid=%02x%02x%02x " in qla2x00_async_login()
352 "retries=%d.\n", fcport->port_name, sp->handle, fcport->loop_id, in qla2x00_async_login()
353 fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa, in qla2x00_async_login()
354 fcport->login_retry); in qla2x00_async_login()
356 rval = qla2x00_start_sp(sp); in qla2x00_async_login()
358 fcport->flags |= FCF_LOGIN_NEEDED; in qla2x00_async_login()
359 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla2x00_async_login()
366 sp->free(sp); in qla2x00_async_login()
367 fcport->flags &= ~FCF_ASYNC_SENT; in qla2x00_async_login()
369 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla2x00_async_login()
373 static void qla2x00_async_logout_sp_done(srb_t *sp, int res) in qla2x00_async_logout_sp_done() argument
375 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_logout_sp_done()
376 sp->fcport->login_gen++; in qla2x00_async_logout_sp_done()
377 qlt_logo_completion_handler(sp->fcport, res); in qla2x00_async_logout_sp_done()
378 sp->free(sp); in qla2x00_async_logout_sp_done()
384 srb_t *sp; in qla2x00_async_logout() local
388 fcport->flags |= FCF_ASYNC_SENT; in qla2x00_async_logout()
389 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla2x00_async_logout()
390 if (!sp) in qla2x00_async_logout()
393 sp->type = SRB_LOGOUT_CMD; in qla2x00_async_logout()
394 sp->name = "logout"; in qla2x00_async_logout()
396 lio = &sp->u.iocb_cmd; in qla2x00_async_logout()
397 lio->timeout = qla2x00_async_iocb_timeout; in qla2x00_async_logout()
398 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); in qla2x00_async_logout()
400 sp->done = qla2x00_async_logout_sp_done; in qla2x00_async_logout()
403 "Async-logout - hdl=%x loop-id=%x portid=%02x%02x%02x %8phC.\n", in qla2x00_async_logout()
404 sp->handle, fcport->loop_id, fcport->d_id.b.domain, in qla2x00_async_logout()
405 fcport->d_id.b.area, fcport->d_id.b.al_pa, in qla2x00_async_logout()
406 fcport->port_name); in qla2x00_async_logout()
408 rval = qla2x00_start_sp(sp); in qla2x00_async_logout()
414 sp->free(sp); in qla2x00_async_logout()
416 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_logout()
424 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla2x00_async_prlo_done()
425 /* Don't re-login in target mode */ in qla2x00_async_prlo_done()
426 if (!fcport->tgt_session) in qla2x00_async_prlo_done()
431 static void qla2x00_async_prlo_sp_done(srb_t *sp, int res) in qla2x00_async_prlo_sp_done() argument
433 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_prlo_sp_done()
434 struct scsi_qla_host *vha = sp->vha; in qla2x00_async_prlo_sp_done()
436 sp->fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla2x00_async_prlo_sp_done()
437 if (!test_bit(UNLOADING, &vha->dpc_flags)) in qla2x00_async_prlo_sp_done()
438 qla2x00_post_async_prlo_done_work(sp->fcport->vha, sp->fcport, in qla2x00_async_prlo_sp_done()
439 lio->u.logio.data); in qla2x00_async_prlo_sp_done()
440 sp->free(sp); in qla2x00_async_prlo_sp_done()
446 srb_t *sp; in qla2x00_async_prlo() local
451 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla2x00_async_prlo()
452 if (!sp) in qla2x00_async_prlo()
455 sp->type = SRB_PRLO_CMD; in qla2x00_async_prlo()
456 sp->name = "prlo"; in qla2x00_async_prlo()
458 lio = &sp->u.iocb_cmd; in qla2x00_async_prlo()
459 lio->timeout = qla2x00_async_iocb_timeout; in qla2x00_async_prlo()
460 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); in qla2x00_async_prlo()
462 sp->done = qla2x00_async_prlo_sp_done; in qla2x00_async_prlo()
465 "Async-prlo - hdl=%x loop-id=%x portid=%02x%02x%02x.\n", in qla2x00_async_prlo()
466 sp->handle, fcport->loop_id, fcport->d_id.b.domain, in qla2x00_async_prlo()
467 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_async_prlo()
469 rval = qla2x00_start_sp(sp); in qla2x00_async_prlo()
476 sp->free(sp); in qla2x00_async_prlo()
478 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla2x00_async_prlo()
485 struct fc_port *fcport = ea->fcport; in qla24xx_handle_adisc_event()
489 __func__, fcport->port_name, fcport->disc_state, in qla24xx_handle_adisc_event()
490 fcport->fw_login_state, ea->rc, fcport->login_gen, ea->sp->gen2, in qla24xx_handle_adisc_event()
491 fcport->rscn_gen, ea->sp->gen1, fcport->loop_id); in qla24xx_handle_adisc_event()
493 WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n", in qla24xx_handle_adisc_event()
494 ea->data[0]); in qla24xx_handle_adisc_event()
496 if (ea->data[0] != MBS_COMMAND_COMPLETE) { in qla24xx_handle_adisc_event()
499 __func__, ea->fcport->port_name); in qla24xx_handle_adisc_event()
501 fcport->deleted = 0; in qla24xx_handle_adisc_event()
502 fcport->logout_on_delete = 1; in qla24xx_handle_adisc_event()
503 qlt_schedule_sess_for_deletion(ea->fcport); in qla24xx_handle_adisc_event()
507 if (ea->fcport->disc_state == DSC_DELETE_PEND) in qla24xx_handle_adisc_event()
510 if (ea->sp->gen2 != ea->fcport->login_gen) { in qla24xx_handle_adisc_event()
514 __func__, ea->fcport->port_name); in qla24xx_handle_adisc_event()
516 } else if (ea->sp->gen1 != ea->fcport->rscn_gen) { in qla24xx_handle_adisc_event()
533 e->u.fcport.fcport = fcport; in qla_post_els_plogi_work()
534 fcport->flags |= FCF_ASYNC_ACTIVE; in qla_post_els_plogi_work()
539 static void qla2x00_async_adisc_sp_done(srb_t *sp, int res) in qla2x00_async_adisc_sp_done() argument
541 struct scsi_qla_host *vha = sp->vha; in qla2x00_async_adisc_sp_done()
543 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_adisc_sp_done()
546 "Async done-%s res %x %8phC\n", in qla2x00_async_adisc_sp_done()
547 sp->name, res, sp->fcport->port_name); in qla2x00_async_adisc_sp_done()
549 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_adisc_sp_done()
553 ea.data[0] = lio->u.logio.data[0]; in qla2x00_async_adisc_sp_done()
554 ea.data[1] = lio->u.logio.data[1]; in qla2x00_async_adisc_sp_done()
555 ea.iop[0] = lio->u.logio.iop[0]; in qla2x00_async_adisc_sp_done()
556 ea.iop[1] = lio->u.logio.iop[1]; in qla2x00_async_adisc_sp_done()
557 ea.fcport = sp->fcport; in qla2x00_async_adisc_sp_done()
558 ea.sp = sp; in qla2x00_async_adisc_sp_done()
562 sp->free(sp); in qla2x00_async_adisc_sp_done()
569 srb_t *sp; in qla2x00_async_adisc() local
573 if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT)) in qla2x00_async_adisc()
576 fcport->flags |= FCF_ASYNC_SENT; in qla2x00_async_adisc()
577 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla2x00_async_adisc()
578 if (!sp) in qla2x00_async_adisc()
581 sp->type = SRB_ADISC_CMD; in qla2x00_async_adisc()
582 sp->name = "adisc"; in qla2x00_async_adisc()
584 lio = &sp->u.iocb_cmd; in qla2x00_async_adisc()
585 lio->timeout = qla2x00_async_iocb_timeout; in qla2x00_async_adisc()
586 sp->gen1 = fcport->rscn_gen; in qla2x00_async_adisc()
587 sp->gen2 = fcport->login_gen; in qla2x00_async_adisc()
588 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); in qla2x00_async_adisc()
590 sp->done = qla2x00_async_adisc_sp_done; in qla2x00_async_adisc()
592 lio->u.logio.flags |= SRB_LOGIN_RETRIED; in qla2x00_async_adisc()
595 "Async-adisc - hdl=%x loopid=%x portid=%06x %8phC.\n", in qla2x00_async_adisc()
596 sp->handle, fcport->loop_id, fcport->d_id.b24, fcport->port_name); in qla2x00_async_adisc()
598 rval = qla2x00_start_sp(sp); in qla2x00_async_adisc()
605 sp->free(sp); in qla2x00_async_adisc()
607 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla2x00_async_adisc()
614 struct qla_hw_data *ha = vha->hw; in qla2x00_is_reserved_id()
619 return (loop_id > ha->max_loop_id && loop_id < SNS_FIRST_LOOP_ID) || in qla2x00_is_reserved_id()
624 * qla2x00_find_new_loop_id - scan through our port list and find a new usable loop ID
637 struct qla_hw_data *ha = vha->hw; in qla2x00_find_new_loop_id()
642 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_find_new_loop_id()
644 dev->loop_id = find_first_zero_bit(ha->loop_id_map, LOOPID_MAP_SIZE); in qla2x00_find_new_loop_id()
645 if (dev->loop_id >= LOOPID_MAP_SIZE || in qla2x00_find_new_loop_id()
646 qla2x00_is_reserved_id(vha, dev->loop_id)) { in qla2x00_find_new_loop_id()
647 dev->loop_id = FC_NO_LOOP_ID; in qla2x00_find_new_loop_id()
650 set_bit(dev->loop_id, ha->loop_id_map); in qla2x00_find_new_loop_id()
652 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_find_new_loop_id()
655 ql_dbg(ql_dbg_disc, dev->vha, 0x2086, in qla2x00_find_new_loop_id()
657 dev->loop_id, dev->d_id.b24); in qla2x00_find_new_loop_id()
659 ql_log(ql_log_warn, dev->vha, 0x2087, in qla2x00_find_new_loop_id()
661 dev->d_id.b24); in qla2x00_find_new_loop_id()
668 struct qla_hw_data *ha = fcport->vha->hw; in qla2x00_clear_loop_id()
670 if (fcport->loop_id == FC_NO_LOOP_ID || in qla2x00_clear_loop_id()
671 qla2x00_is_reserved_id(fcport->vha, fcport->loop_id)) in qla2x00_clear_loop_id()
674 clear_bit(fcport->loop_id, ha->loop_id_map); in qla2x00_clear_loop_id()
675 fcport->loop_id = FC_NO_LOOP_ID; in qla2x00_clear_loop_id()
689 fcport = ea->fcport; in qla24xx_handle_gnl_done_event()
692 __func__, fcport->port_name, fcport->disc_state, in qla24xx_handle_gnl_done_event()
693 fcport->fw_login_state, ea->rc, in qla24xx_handle_gnl_done_event()
694 fcport->login_gen, fcport->last_login_gen, in qla24xx_handle_gnl_done_event()
695 fcport->rscn_gen, fcport->last_rscn_gen, vha->loop_id); in qla24xx_handle_gnl_done_event()
697 if (fcport->disc_state == DSC_DELETE_PEND) in qla24xx_handle_gnl_done_event()
700 if (ea->rc) { /* rval */ in qla24xx_handle_gnl_done_event()
701 if (fcport->login_retry == 0) { in qla24xx_handle_gnl_done_event()
704 fcport->port_name, fcport->login_retry); in qla24xx_handle_gnl_done_event()
709 if (fcport->last_rscn_gen != fcport->rscn_gen) { in qla24xx_handle_gnl_done_event()
713 } else if (fcport->last_login_gen != fcport->login_gen) { in qla24xx_handle_gnl_done_event()
716 __func__, fcport->port_name); in qla24xx_handle_gnl_done_event()
720 n = ea->data[0] / sizeof(struct get_name_list_extended); in qla24xx_handle_gnl_done_event()
724 __func__, __LINE__, fcport->port_name, n, in qla24xx_handle_gnl_done_event()
725 fcport->d_id.b.domain, fcport->d_id.b.area, in qla24xx_handle_gnl_done_event()
726 fcport->d_id.b.al_pa, fcport->loop_id); in qla24xx_handle_gnl_done_event()
729 e = &vha->gnl.l[i]; in qla24xx_handle_gnl_done_event()
730 wwn = wwn_to_u64(e->port_name); in qla24xx_handle_gnl_done_event()
731 id.b.domain = e->port_id[2]; in qla24xx_handle_gnl_done_event()
732 id.b.area = e->port_id[1]; in qla24xx_handle_gnl_done_event()
733 id.b.al_pa = e->port_id[0]; in qla24xx_handle_gnl_done_event()
736 if (memcmp((u8 *)&wwn, fcport->port_name, WWN_SIZE)) in qla24xx_handle_gnl_done_event()
744 loop_id = le16_to_cpu(e->nport_handle); in qla24xx_handle_gnl_done_event()
746 nvme_cls = e->current_login_state >> 4; in qla24xx_handle_gnl_done_event()
747 current_login_state = e->current_login_state & 0xf; in qla24xx_handle_gnl_done_event()
751 fcport->fc4_type &= ~FS_FC4TYPE_FCP; in qla24xx_handle_gnl_done_event()
752 fcport->fc4_type |= FS_FC4TYPE_NVME; in qla24xx_handle_gnl_done_event()
754 fcport->fc4_type |= FS_FC4TYPE_FCP; in qla24xx_handle_gnl_done_event()
755 fcport->fc4_type &= ~FS_FC4TYPE_NVME; in qla24xx_handle_gnl_done_event()
760 __func__, fcport->port_name, in qla24xx_handle_gnl_done_event()
761 e->current_login_state, fcport->fw_login_state, in qla24xx_handle_gnl_done_event()
762 fcport->fc4_type, id.b24, fcport->d_id.b24, in qla24xx_handle_gnl_done_event()
763 loop_id, fcport->loop_id); in qla24xx_handle_gnl_done_event()
765 switch (fcport->disc_state) { in qla24xx_handle_gnl_done_event()
770 if ((id.b24 != fcport->d_id.b24 && in qla24xx_handle_gnl_done_event()
771 fcport->d_id.b24 && in qla24xx_handle_gnl_done_event()
772 fcport->loop_id != FC_NO_LOOP_ID) || in qla24xx_handle_gnl_done_event()
773 (fcport->loop_id != FC_NO_LOOP_ID && in qla24xx_handle_gnl_done_event()
774 fcport->loop_id != loop_id)) { in qla24xx_handle_gnl_done_event()
777 __func__, __LINE__, fcport->port_name); in qla24xx_handle_gnl_done_event()
778 if (fcport->n2n_flag) in qla24xx_handle_gnl_done_event()
779 fcport->d_id.b24 = 0; in qla24xx_handle_gnl_done_event()
786 fcport->loop_id = loop_id; in qla24xx_handle_gnl_done_event()
787 if (fcport->n2n_flag) in qla24xx_handle_gnl_done_event()
788 fcport->d_id.b24 = id.b24; in qla24xx_handle_gnl_done_event()
790 wwn = wwn_to_u64(fcport->port_name); in qla24xx_handle_gnl_done_event()
800 conflict_fcport->conflict = fcport; in qla24xx_handle_gnl_done_event()
801 fcport->login_pause = 1; in qla24xx_handle_gnl_done_event()
804 switch (vha->hw->current_topology) { in qla24xx_handle_gnl_done_event()
810 __func__, __LINE__, fcport->port_name); in qla24xx_handle_gnl_done_event()
812 if ((e->prli_svc_param_word_3[0] & BIT_4) == 0) in qla24xx_handle_gnl_done_event()
813 fcport->port_type = FCT_INITIATOR; in qla24xx_handle_gnl_done_event()
815 fcport->port_type = FCT_TARGET; in qla24xx_handle_gnl_done_event()
822 if (fcport->loop_id == FC_NO_LOOP_ID) { in qla24xx_handle_gnl_done_event()
824 fcport->fw_login_state = in qla24xx_handle_gnl_done_event()
829 fcport->port_name); in qla24xx_handle_gnl_done_event()
835 fcport->fw_login_state = current_login_state; in qla24xx_handle_gnl_done_event()
836 fcport->d_id = id; in qla24xx_handle_gnl_done_event()
849 if ((e->prli_svc_param_word_3[0] & BIT_4) == 0) in qla24xx_handle_gnl_done_event()
850 fcport->port_type = FCT_INITIATOR; in qla24xx_handle_gnl_done_event()
852 fcport->port_type = FCT_TARGET; in qla24xx_handle_gnl_done_event()
861 if (fcport->loop_id != FC_NO_LOOP_ID) in qla24xx_handle_gnl_done_event()
864 fcport->loop_id = loop_id; in qla24xx_handle_gnl_done_event()
873 if (fcport->loop_id != FC_NO_LOOP_ID) in qla24xx_handle_gnl_done_event()
876 fcport->loop_id = loop_id; in qla24xx_handle_gnl_done_event()
883 } /* switch (ha->current_topology) */ in qla24xx_handle_gnl_done_event()
887 switch (vha->hw->current_topology) { in qla24xx_handle_gnl_done_event()
891 e = &vha->gnl.l[i]; in qla24xx_handle_gnl_done_event()
892 id.b.domain = e->port_id[0]; in qla24xx_handle_gnl_done_event()
893 id.b.area = e->port_id[1]; in qla24xx_handle_gnl_done_event()
894 id.b.al_pa = e->port_id[2]; in qla24xx_handle_gnl_done_event()
896 loop_id = le16_to_cpu(e->nport_handle); in qla24xx_handle_gnl_done_event()
898 if (fcport->d_id.b24 == id.b24) { in qla24xx_handle_gnl_done_event()
901 e->port_name, 0); in qla24xx_handle_gnl_done_event()
907 conflict_fcport->port_name); in qla24xx_handle_gnl_done_event()
916 if (fcport->loop_id == loop_id) in qla24xx_handle_gnl_done_event()
917 fcport->loop_id = FC_NO_LOOP_ID; in qla24xx_handle_gnl_done_event()
923 if (time_after_eq(jiffies, fcport->dm_login_expire)) { in qla24xx_handle_gnl_done_event()
924 if (fcport->n2n_link_reset_cnt < 2) { in qla24xx_handle_gnl_done_event()
925 fcport->n2n_link_reset_cnt++; in qla24xx_handle_gnl_done_event()
932 &vha->dpc_flags); in qla24xx_handle_gnl_done_event()
934 if (fcport->n2n_chip_reset < 1) { in qla24xx_handle_gnl_done_event()
938 &vha->dpc_flags); in qla24xx_handle_gnl_done_event()
939 fcport->n2n_chip_reset++; in qla24xx_handle_gnl_done_event()
943 fcport->port_name); in qla24xx_handle_gnl_done_event()
944 fcport->scan_state = 0; in qla24xx_handle_gnl_done_event()
953 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_gnl_done_event()
962 static void qla24xx_async_gnl_sp_done(srb_t *sp, int res) in qla24xx_async_gnl_sp_done() argument
964 struct scsi_qla_host *vha = sp->vha; in qla24xx_async_gnl_sp_done()
975 "Async done-%s res %x mb[1]=%x mb[2]=%x \n", in qla24xx_async_gnl_sp_done()
976 sp->name, res, sp->u.iocb_cmd.u.mbx.in_mb[1], in qla24xx_async_gnl_sp_done()
977 sp->u.iocb_cmd.u.mbx.in_mb[2]); in qla24xx_async_gnl_sp_done()
982 sp->fcport->flags &= ~(FCF_ASYNC_SENT|FCF_ASYNC_ACTIVE); in qla24xx_async_gnl_sp_done()
984 ea.sp = sp; in qla24xx_async_gnl_sp_done()
987 if (sp->u.iocb_cmd.u.mbx.in_mb[1] >= in qla24xx_async_gnl_sp_done()
989 n = sp->u.iocb_cmd.u.mbx.in_mb[1] / in qla24xx_async_gnl_sp_done()
991 ea.data[0] = sp->u.iocb_cmd.u.mbx.in_mb[1]; /* amnt xfered */ in qla24xx_async_gnl_sp_done()
995 e = &vha->gnl.l[i]; in qla24xx_async_gnl_sp_done()
996 loop_id = le16_to_cpu(e->nport_handle); in qla24xx_async_gnl_sp_done()
999 set_bit(loop_id, vha->hw->loop_id_map); in qla24xx_async_gnl_sp_done()
1000 wwn = wwn_to_u64(e->port_name); in qla24xx_async_gnl_sp_done()
1004 __func__, &wwn, e->port_id[2], e->port_id[1], in qla24xx_async_gnl_sp_done()
1005 e->port_id[0], e->current_login_state, e->last_login_state, in qla24xx_async_gnl_sp_done()
1009 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1013 if (!list_empty(&vha->gnl.fcports)) in qla24xx_async_gnl_sp_done()
1014 list_splice_init(&vha->gnl.fcports, &h); in qla24xx_async_gnl_sp_done()
1015 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1018 list_del_init(&fcport->gnl_entry); in qla24xx_async_gnl_sp_done()
1019 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1020 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla24xx_async_gnl_sp_done()
1021 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1032 e = &vha->gnl.l[i]; in qla24xx_async_gnl_sp_done()
1033 wwn = wwn_to_u64(e->port_name); in qla24xx_async_gnl_sp_done()
1036 list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list) { in qla24xx_async_gnl_sp_done()
1037 if (!memcmp((u8 *)&wwn, fcport->port_name, in qla24xx_async_gnl_sp_done()
1044 id.b.domain = e->port_id[2]; in qla24xx_async_gnl_sp_done()
1045 id.b.area = e->port_id[1]; in qla24xx_async_gnl_sp_done()
1046 id.b.al_pa = e->port_id[0]; in qla24xx_async_gnl_sp_done()
1053 wwnn = wwn_to_u64(e->node_name); in qla24xx_async_gnl_sp_done()
1059 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1060 vha->gnl.sent = 0; in qla24xx_async_gnl_sp_done()
1061 if (!list_empty(&vha->gnl.fcports)) { in qla24xx_async_gnl_sp_done()
1063 list_for_each_entry_safe(fcport, tf, &vha->gnl.fcports, in qla24xx_async_gnl_sp_done()
1065 list_del_init(&fcport->gnl_entry); in qla24xx_async_gnl_sp_done()
1066 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla24xx_async_gnl_sp_done()
1071 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl_sp_done()
1073 sp->free(sp); in qla24xx_async_gnl_sp_done()
1078 srb_t *sp; in qla24xx_async_gnl() local
1084 if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT)) in qla24xx_async_gnl()
1088 "Async-gnlist WWPN %8phC \n", fcport->port_name); in qla24xx_async_gnl()
1090 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl()
1091 fcport->flags |= FCF_ASYNC_SENT; in qla24xx_async_gnl()
1093 fcport->last_rscn_gen = fcport->rscn_gen; in qla24xx_async_gnl()
1094 fcport->last_login_gen = fcport->login_gen; in qla24xx_async_gnl()
1096 list_add_tail(&fcport->gnl_entry, &vha->gnl.fcports); in qla24xx_async_gnl()
1097 if (vha->gnl.sent) { in qla24xx_async_gnl()
1098 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl()
1101 vha->gnl.sent = 1; in qla24xx_async_gnl()
1102 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_async_gnl()
1104 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla24xx_async_gnl()
1105 if (!sp) in qla24xx_async_gnl()
1108 sp->type = SRB_MB_IOCB; in qla24xx_async_gnl()
1109 sp->name = "gnlist"; in qla24xx_async_gnl()
1110 sp->gen1 = fcport->rscn_gen; in qla24xx_async_gnl()
1111 sp->gen2 = fcport->login_gen; in qla24xx_async_gnl()
1113 mbx = &sp->u.iocb_cmd; in qla24xx_async_gnl()
1114 mbx->timeout = qla2x00_async_iocb_timeout; in qla24xx_async_gnl()
1115 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha)+2); in qla24xx_async_gnl()
1117 mb = sp->u.iocb_cmd.u.mbx.out_mb; in qla24xx_async_gnl()
1120 mb[2] = MSW(vha->gnl.ldma); in qla24xx_async_gnl()
1121 mb[3] = LSW(vha->gnl.ldma); in qla24xx_async_gnl()
1122 mb[6] = MSW(MSD(vha->gnl.ldma)); in qla24xx_async_gnl()
1123 mb[7] = LSW(MSD(vha->gnl.ldma)); in qla24xx_async_gnl()
1124 mb[8] = vha->gnl.size; in qla24xx_async_gnl()
1125 mb[9] = vha->vp_idx; in qla24xx_async_gnl()
1127 sp->done = qla24xx_async_gnl_sp_done; in qla24xx_async_gnl()
1130 "Async-%s - OUT WWPN %8phC hndl %x\n", in qla24xx_async_gnl()
1131 sp->name, fcport->port_name, sp->handle); in qla24xx_async_gnl()
1133 rval = qla2x00_start_sp(sp); in qla24xx_async_gnl()
1140 sp->free(sp); in qla24xx_async_gnl()
1142 fcport->flags &= ~(FCF_ASYNC_ACTIVE | FCF_ASYNC_SENT); in qla24xx_async_gnl()
1154 e->u.fcport.fcport = fcport; in qla24xx_post_gnl_work()
1155 fcport->flags |= FCF_ASYNC_ACTIVE; in qla24xx_post_gnl_work()
1159 static void qla24xx_async_gpdb_sp_done(srb_t *sp, int res) in qla24xx_async_gpdb_sp_done() argument
1161 struct scsi_qla_host *vha = sp->vha; in qla24xx_async_gpdb_sp_done()
1162 struct qla_hw_data *ha = vha->hw; in qla24xx_async_gpdb_sp_done()
1163 fc_port_t *fcport = sp->fcport; in qla24xx_async_gpdb_sp_done()
1164 u16 *mb = sp->u.iocb_cmd.u.mbx.in_mb; in qla24xx_async_gpdb_sp_done()
1168 "Async done-%s res %x, WWPN %8phC mb[1]=%x mb[2]=%x \n", in qla24xx_async_gpdb_sp_done()
1169 sp->name, res, fcport->port_name, mb[1], mb[2]); in qla24xx_async_gpdb_sp_done()
1171 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla24xx_async_gpdb_sp_done()
1178 ea.sp = sp; in qla24xx_async_gpdb_sp_done()
1183 dma_pool_free(ha->s_dma_pool, sp->u.iocb_cmd.u.mbx.in, in qla24xx_async_gpdb_sp_done()
1184 sp->u.iocb_cmd.u.mbx.in_dma); in qla24xx_async_gpdb_sp_done()
1186 sp->free(sp); in qla24xx_async_gpdb_sp_done()
1197 e->u.fcport.fcport = fcport; in qla24xx_post_prli_work()
1202 static void qla2x00_async_prli_sp_done(srb_t *sp, int res) in qla2x00_async_prli_sp_done() argument
1204 struct scsi_qla_host *vha = sp->vha; in qla2x00_async_prli_sp_done()
1205 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_async_prli_sp_done()
1210 sp->fcport->port_name, res); in qla2x00_async_prli_sp_done()
1212 sp->fcport->flags &= ~FCF_ASYNC_SENT; in qla2x00_async_prli_sp_done()
1214 if (!test_bit(UNLOADING, &vha->dpc_flags)) { in qla2x00_async_prli_sp_done()
1216 ea.fcport = sp->fcport; in qla2x00_async_prli_sp_done()
1217 ea.data[0] = lio->u.logio.data[0]; in qla2x00_async_prli_sp_done()
1218 ea.data[1] = lio->u.logio.data[1]; in qla2x00_async_prli_sp_done()
1219 ea.iop[0] = lio->u.logio.iop[0]; in qla2x00_async_prli_sp_done()
1220 ea.iop[1] = lio->u.logio.iop[1]; in qla2x00_async_prli_sp_done()
1221 ea.sp = sp; in qla2x00_async_prli_sp_done()
1226 sp->free(sp); in qla2x00_async_prli_sp_done()
1232 srb_t *sp; in qla24xx_async_prli() local
1236 if (!vha->flags.online) { in qla24xx_async_prli()
1238 __func__, __LINE__, fcport->port_name); in qla24xx_async_prli()
1242 if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND || in qla24xx_async_prli()
1243 fcport->fw_login_state == DSC_LS_PRLI_PEND) && in qla24xx_async_prli()
1246 __func__, __LINE__, fcport->port_name); in qla24xx_async_prli()
1250 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla24xx_async_prli()
1251 if (!sp) in qla24xx_async_prli()
1254 fcport->flags |= FCF_ASYNC_SENT; in qla24xx_async_prli()
1255 fcport->logout_completed = 0; in qla24xx_async_prli()
1257 sp->type = SRB_PRLI_CMD; in qla24xx_async_prli()
1258 sp->name = "prli"; in qla24xx_async_prli()
1260 lio = &sp->u.iocb_cmd; in qla24xx_async_prli()
1261 lio->timeout = qla2x00_async_iocb_timeout; in qla24xx_async_prli()
1262 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); in qla24xx_async_prli()
1264 sp->done = qla2x00_async_prli_sp_done; in qla24xx_async_prli()
1265 lio->u.logio.flags = 0; in qla24xx_async_prli()
1267 if (NVME_TARGET(vha->hw, fcport)) in qla24xx_async_prli()
1268 lio->u.logio.flags |= SRB_LOGIN_NVME_PRLI; in qla24xx_async_prli()
1271 "Async-prli - %8phC hdl=%x, loopid=%x portid=%06x retries=%d %s.\n", in qla24xx_async_prli()
1272 fcport->port_name, sp->handle, fcport->loop_id, fcport->d_id.b24, in qla24xx_async_prli()
1273 fcport->login_retry, NVME_TARGET(vha->hw, fcport) ? "nvme" : "fc"); in qla24xx_async_prli()
1275 rval = qla2x00_start_sp(sp); in qla24xx_async_prli()
1277 fcport->flags |= FCF_LOGIN_NEEDED; in qla24xx_async_prli()
1278 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_async_prli()
1285 sp->free(sp); in qla24xx_async_prli()
1286 fcport->flags &= ~FCF_ASYNC_SENT; in qla24xx_async_prli()
1298 e->u.fcport.fcport = fcport; in qla24xx_post_gpdb_work()
1299 e->u.fcport.opt = opt; in qla24xx_post_gpdb_work()
1300 fcport->flags |= FCF_ASYNC_ACTIVE; in qla24xx_post_gpdb_work()
1306 srb_t *sp; in qla24xx_async_gpdb() local
1312 struct qla_hw_data *ha = vha->hw; in qla24xx_async_gpdb()
1314 if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT) || in qla24xx_async_gpdb()
1315 fcport->loop_id == FC_NO_LOOP_ID) { in qla24xx_async_gpdb()
1317 "%s: %8phC - not sending command.\n", in qla24xx_async_gpdb()
1318 __func__, fcport->port_name); in qla24xx_async_gpdb()
1322 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla24xx_async_gpdb()
1323 if (!sp) in qla24xx_async_gpdb()
1328 fcport->flags |= FCF_ASYNC_SENT; in qla24xx_async_gpdb()
1329 sp->type = SRB_MB_IOCB; in qla24xx_async_gpdb()
1330 sp->name = "gpdb"; in qla24xx_async_gpdb()
1331 sp->gen1 = fcport->rscn_gen; in qla24xx_async_gpdb()
1332 sp->gen2 = fcport->login_gen; in qla24xx_async_gpdb()
1334 mbx = &sp->u.iocb_cmd; in qla24xx_async_gpdb()
1335 mbx->timeout = qla2x00_async_iocb_timeout; in qla24xx_async_gpdb()
1336 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); in qla24xx_async_gpdb()
1338 pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); in qla24xx_async_gpdb()
1345 mb = sp->u.iocb_cmd.u.mbx.out_mb; in qla24xx_async_gpdb()
1347 mb[1] = fcport->loop_id; in qla24xx_async_gpdb()
1352 mb[9] = vha->vp_idx; in qla24xx_async_gpdb()
1355 mbx->u.mbx.in = pd; in qla24xx_async_gpdb()
1356 mbx->u.mbx.in_dma = pd_dma; in qla24xx_async_gpdb()
1358 sp->done = qla24xx_async_gpdb_sp_done; in qla24xx_async_gpdb()
1361 "Async-%s %8phC hndl %x opt %x\n", in qla24xx_async_gpdb()
1362 sp->name, fcport->port_name, sp->handle, opt); in qla24xx_async_gpdb()
1364 rval = qla2x00_start_sp(sp); in qla24xx_async_gpdb()
1371 dma_pool_free(ha->s_dma_pool, pd, pd_dma); in qla24xx_async_gpdb()
1373 sp->free(sp); in qla24xx_async_gpdb()
1374 fcport->flags &= ~FCF_ASYNC_SENT; in qla24xx_async_gpdb()
1376 fcport->flags &= ~FCF_ASYNC_ACTIVE; in qla24xx_async_gpdb()
1386 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in __qla24xx_handle_gpdb_event()
1387 ea->fcport->login_gen++; in __qla24xx_handle_gpdb_event()
1388 ea->fcport->deleted = 0; in __qla24xx_handle_gpdb_event()
1389 ea->fcport->logout_on_delete = 1; in __qla24xx_handle_gpdb_event()
1391 if (!ea->fcport->login_succ && !IS_SW_RESV_ADDR(ea->fcport->d_id)) { in __qla24xx_handle_gpdb_event()
1392 vha->fcport_count++; in __qla24xx_handle_gpdb_event()
1393 ea->fcport->login_succ = 1; in __qla24xx_handle_gpdb_event()
1395 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in __qla24xx_handle_gpdb_event()
1396 qla24xx_sched_upd_fcport(ea->fcport); in __qla24xx_handle_gpdb_event()
1397 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in __qla24xx_handle_gpdb_event()
1398 } else if (ea->fcport->login_succ) { in __qla24xx_handle_gpdb_event()
1401 * must have triggered the session to be re-validate. in __qla24xx_handle_gpdb_event()
1406 __func__, __LINE__, ea->fcport->port_name); in __qla24xx_handle_gpdb_event()
1407 qla2x00_set_fcport_disc_state(ea->fcport, DSC_LOGIN_COMPLETE); in __qla24xx_handle_gpdb_event()
1409 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in __qla24xx_handle_gpdb_event()
1415 fc_port_t *fcport = ea->fcport; in qla24xx_handle_gpdb_event()
1417 struct srb *sp = ea->sp; in qla24xx_handle_gpdb_event() local
1420 pd = (struct port_database_24xx *)sp->u.iocb_cmd.u.mbx.in; in qla24xx_handle_gpdb_event()
1422 fcport->flags &= ~FCF_ASYNC_SENT; in qla24xx_handle_gpdb_event()
1426 fcport->port_name, fcport->disc_state, pd->current_login_state, in qla24xx_handle_gpdb_event()
1427 fcport->fc4_type, ea->rc); in qla24xx_handle_gpdb_event()
1429 if (fcport->disc_state == DSC_DELETE_PEND) in qla24xx_handle_gpdb_event()
1432 if (NVME_TARGET(vha->hw, fcport)) in qla24xx_handle_gpdb_event()
1433 ls = pd->current_login_state >> 4; in qla24xx_handle_gpdb_event()
1435 ls = pd->current_login_state & 0xf; in qla24xx_handle_gpdb_event()
1437 if (ea->sp->gen2 != fcport->login_gen) { in qla24xx_handle_gpdb_event()
1442 __func__, fcport->port_name); in qla24xx_handle_gpdb_event()
1444 } else if (ea->sp->gen1 != fcport->rscn_gen) { in qla24xx_handle_gpdb_event()
1462 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_gpdb_event()
1469 __func__, __LINE__, fcport->port_name); in qla24xx_handle_gpdb_event()
1485 if (N2N_TOPO(vha->hw)) { in qla_chk_n2n_b4_login()
1488 mywwn = wwn_to_u64(vha->port_name); in qla_chk_n2n_b4_login()
1489 wwn = wwn_to_u64(fcport->port_name); in qla_chk_n2n_b4_login()
1492 else if ((fcport->fw_login_state == DSC_LS_PLOGI_COMP) in qla_chk_n2n_b4_login()
1494 fcport->plogi_nack_done_deadline)) in qla_chk_n2n_b4_login()
1504 if (login && fcport->login_retry) { in qla_chk_n2n_b4_login()
1505 fcport->login_retry--; in qla_chk_n2n_b4_login()
1506 if (fcport->loop_id == FC_NO_LOOP_ID) { in qla_chk_n2n_b4_login()
1507 fcport->fw_login_state = DSC_LS_PORT_UNAVAIL; in qla_chk_n2n_b4_login()
1511 "%s %d %8phC post del sess - out of loopid\n", in qla_chk_n2n_b4_login()
1512 __func__, __LINE__, fcport->port_name); in qla_chk_n2n_b4_login()
1513 fcport->scan_state = 0; in qla_chk_n2n_b4_login()
1520 __func__, __LINE__, fcport->port_name); in qla_chk_n2n_b4_login()
1533 __func__, fcport->port_name, fcport->disc_state, in qla24xx_fcport_handle_login()
1534 fcport->fw_login_state, fcport->login_pause, fcport->flags, in qla24xx_fcport_handle_login()
1535 fcport->conflict, fcport->last_rscn_gen, fcport->rscn_gen, in qla24xx_fcport_handle_login()
1536 fcport->login_gen, fcport->loop_id, fcport->scan_state); in qla24xx_fcport_handle_login()
1538 if (fcport->scan_state != QLA_FCPORT_FOUND) in qla24xx_fcport_handle_login()
1541 if ((fcport->loop_id != FC_NO_LOOP_ID) && in qla24xx_fcport_handle_login()
1543 ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) || in qla24xx_fcport_handle_login()
1544 (fcport->fw_login_state == DSC_LS_PRLI_PEND))) in qla24xx_fcport_handle_login()
1547 if (fcport->fw_login_state == DSC_LS_PLOGI_COMP && in qla24xx_fcport_handle_login()
1548 !N2N_TOPO(vha->hw)) { in qla24xx_fcport_handle_login()
1549 if (time_before_eq(jiffies, fcport->plogi_nack_done_deadline)) { in qla24xx_fcport_handle_login()
1550 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_fcport_handle_login()
1556 if (vha->host->active_mode == MODE_TARGET && !N2N_TOPO(vha->hw)) in qla24xx_fcport_handle_login()
1559 if (fcport->flags & FCF_ASYNC_SENT) { in qla24xx_fcport_handle_login()
1560 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_fcport_handle_login()
1564 switch (fcport->disc_state) { in qla24xx_fcport_handle_login()
1566 wwn = wwn_to_u64(fcport->node_name); in qla24xx_fcport_handle_login()
1567 switch (vha->hw->current_topology) { in qla24xx_fcport_handle_login()
1571 if (fcport->login_retry) { in qla24xx_fcport_handle_login()
1572 if (fcport->loop_id == FC_NO_LOOP_ID) { in qla24xx_fcport_handle_login()
1575 fcport->fw_login_state = in qla24xx_fcport_handle_login()
1578 fcport->login_retry--; in qla24xx_fcport_handle_login()
1583 fcport->port_name); in qla24xx_fcport_handle_login()
1593 __func__, __LINE__, fcport->port_name); in qla24xx_fcport_handle_login()
1595 } else if (fcport->loop_id == FC_NO_LOOP_ID) { in qla24xx_fcport_handle_login()
1598 __func__, __LINE__, fcport->port_name); in qla24xx_fcport_handle_login()
1608 switch (vha->hw->current_topology) { in qla24xx_fcport_handle_login()
1610 if ((fcport->current_login_state & 0xf) == 0x6) { in qla24xx_fcport_handle_login()
1613 __func__, __LINE__, fcport->port_name); in qla24xx_fcport_handle_login()
1614 fcport->chip_reset = in qla24xx_fcport_handle_login()
1615 vha->hw->base_qpair->chip_reset; in qla24xx_fcport_handle_login()
1620 __func__, __LINE__, fcport->port_name, in qla24xx_fcport_handle_login()
1621 NVME_TARGET(vha->hw, fcport) ? "NVME" : in qla24xx_fcport_handle_login()
1627 if (fcport->login_pause) { in qla24xx_fcport_handle_login()
1631 fcport->port_name); in qla24xx_fcport_handle_login()
1632 fcport->last_rscn_gen = fcport->rscn_gen; in qla24xx_fcport_handle_login()
1633 fcport->last_login_gen = fcport->login_gen; in qla24xx_fcport_handle_login()
1634 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_fcport_handle_login()
1643 if (N2N_TOPO(vha->hw)) in qla24xx_fcport_handle_login()
1656 if (fcport->fw_login_state == DSC_LS_PLOGI_COMP) in qla24xx_fcport_handle_login()
1661 sec = jiffies_to_msecs(jiffies - in qla24xx_fcport_handle_login()
1662 fcport->jiffies_at_registration)/1000; in qla24xx_fcport_handle_login()
1663 if (fcport->sec_since_registration < sec && sec && in qla24xx_fcport_handle_login()
1665 fcport->sec_since_registration = sec; in qla24xx_fcport_handle_login()
1666 ql_dbg(ql_dbg_disc, fcport->vha, 0xffff, in qla24xx_fcport_handle_login()
1667 "%s %8phC - Slow Rport registration(%d Sec)\n", in qla24xx_fcport_handle_login()
1668 __func__, fcport->port_name, sec); in qla24xx_fcport_handle_login()
1671 if (fcport->next_disc_state != DSC_DELETE_PEND) in qla24xx_fcport_handle_login()
1672 fcport->next_disc_state = DSC_ADISC; in qla24xx_fcport_handle_login()
1673 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_fcport_handle_login()
1692 e->u.new_sess.id = *id; in qla24xx_post_newsess_work()
1693 e->u.new_sess.pla = pla; in qla24xx_post_newsess_work()
1694 e->u.new_sess.fc4_type = fc4_type; in qla24xx_post_newsess_work()
1695 memcpy(e->u.new_sess.port_name, port_name, WWN_SIZE); in qla24xx_post_newsess_work()
1697 memcpy(e->u.new_sess.node_name, node_name, WWN_SIZE); in qla24xx_post_newsess_work()
1707 fcport = qla2x00_find_fcport_by_nportid(vha, &ea->id, 1); in qla2x00_handle_rscn()
1709 fcport->scan_needed = 1; in qla2x00_handle_rscn()
1710 fcport->rscn_gen++; in qla2x00_handle_rscn()
1713 spin_lock_irqsave(&vha->work_lock, flags); in qla2x00_handle_rscn()
1714 if (vha->scan.scan_flags == 0) { in qla2x00_handle_rscn()
1716 vha->scan.scan_flags |= SF_QUEUED; in qla2x00_handle_rscn()
1717 schedule_delayed_work(&vha->scan.scan_work, 5); in qla2x00_handle_rscn()
1719 spin_unlock_irqrestore(&vha->work_lock, flags); in qla2x00_handle_rscn()
1725 fc_port_t *fcport = ea->fcport; in qla24xx_handle_relogin_event()
1727 if (test_bit(UNLOADING, &vha->dpc_flags)) in qla24xx_handle_relogin_event()
1732 __func__, fcport->port_name, fcport->disc_state, in qla24xx_handle_relogin_event()
1733 fcport->fw_login_state, fcport->login_pause, in qla24xx_handle_relogin_event()
1734 fcport->deleted, fcport->conflict, in qla24xx_handle_relogin_event()
1735 fcport->last_rscn_gen, fcport->rscn_gen, in qla24xx_handle_relogin_event()
1736 fcport->last_login_gen, fcport->login_gen, in qla24xx_handle_relogin_event()
1737 fcport->flags); in qla24xx_handle_relogin_event()
1739 if (fcport->last_rscn_gen != fcport->rscn_gen) { in qla24xx_handle_relogin_event()
1741 __func__, __LINE__, fcport->port_name); in qla24xx_handle_relogin_event()
1753 if (vha->host->active_mode == MODE_TARGET) in qla_handle_els_plogi_done()
1758 __func__, __LINE__, ea->fcport->port_name); in qla_handle_els_plogi_done()
1759 qla24xx_post_prli_work(vha, ea->fcport); in qla_handle_els_plogi_done()
1770 switch (fcport->disc_state) { in qla_rscn_replay()
1777 if (fcport->scan_needed) { in qla_rscn_replay()
1779 ea.id = fcport->d_id; in qla_rscn_replay()
1781 qla2x00_handle_rscn(fcport->vha, &ea); in qla_rscn_replay()
1788 srb_t *sp = data; in qla2x00_tmf_iocb_timeout() local
1789 struct srb_iocb *tmf = &sp->u.iocb_cmd; in qla2x00_tmf_iocb_timeout()
1793 rc = qla24xx_async_abort_cmd(sp, false); in qla2x00_tmf_iocb_timeout()
1795 spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); in qla2x00_tmf_iocb_timeout()
1796 for (h = 1; h < sp->qpair->req->num_outstanding_cmds; h++) { in qla2x00_tmf_iocb_timeout()
1797 if (sp->qpair->req->outstanding_cmds[h] == sp) { in qla2x00_tmf_iocb_timeout()
1798 sp->qpair->req->outstanding_cmds[h] = NULL; in qla2x00_tmf_iocb_timeout()
1802 spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); in qla2x00_tmf_iocb_timeout()
1803 tmf->u.tmf.comp_status = cpu_to_le16(CS_TIMEOUT); in qla2x00_tmf_iocb_timeout()
1804 tmf->u.tmf.data = QLA_FUNCTION_FAILED; in qla2x00_tmf_iocb_timeout()
1805 complete(&tmf->u.tmf.comp); in qla2x00_tmf_iocb_timeout()
1809 static void qla2x00_tmf_sp_done(srb_t *sp, int res) in qla2x00_tmf_sp_done() argument
1811 struct srb_iocb *tmf = &sp->u.iocb_cmd; in qla2x00_tmf_sp_done()
1813 complete(&tmf->u.tmf.comp); in qla2x00_tmf_sp_done()
1820 struct scsi_qla_host *vha = fcport->vha; in qla2x00_async_tm_cmd()
1822 srb_t *sp; in qla2x00_async_tm_cmd() local
1825 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); in qla2x00_async_tm_cmd()
1826 if (!sp) in qla2x00_async_tm_cmd()
1829 tm_iocb = &sp->u.iocb_cmd; in qla2x00_async_tm_cmd()
1830 sp->type = SRB_TM_CMD; in qla2x00_async_tm_cmd()
1831 sp->name = "tmf"; in qla2x00_async_tm_cmd()
1833 tm_iocb->timeout = qla2x00_tmf_iocb_timeout; in qla2x00_async_tm_cmd()
1834 init_completion(&tm_iocb->u.tmf.comp); in qla2x00_async_tm_cmd()
1835 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha)); in qla2x00_async_tm_cmd()
1837 tm_iocb->u.tmf.flags = flags; in qla2x00_async_tm_cmd()
1838 tm_iocb->u.tmf.lun = lun; in qla2x00_async_tm_cmd()
1839 tm_iocb->u.tmf.data = tag; in qla2x00_async_tm_cmd()
1840 sp->done = qla2x00_tmf_sp_done; in qla2x00_async_tm_cmd()
1843 "Async-tmf hdl=%x loop-id=%x portid=%02x%02x%02x.\n", in qla2x00_async_tm_cmd()
1844 sp->handle, fcport->loop_id, fcport->d_id.b.domain, in qla2x00_async_tm_cmd()
1845 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_async_tm_cmd()
1847 rval = qla2x00_start_sp(sp); in qla2x00_async_tm_cmd()
1850 wait_for_completion(&tm_iocb->u.tmf.comp); in qla2x00_async_tm_cmd()
1852 rval = tm_iocb->u.tmf.data; in qla2x00_async_tm_cmd()
1859 if (!test_bit(UNLOADING, &vha->dpc_flags) && !IS_QLAFX00(vha->hw)) { in qla2x00_async_tm_cmd()
1860 flags = tm_iocb->u.tmf.flags; in qla2x00_async_tm_cmd()
1861 lun = (uint16_t)tm_iocb->u.tmf.lun; in qla2x00_async_tm_cmd()
1864 qla2x00_marker(vha, vha->hw->base_qpair, in qla2x00_async_tm_cmd()
1865 fcport->loop_id, lun, in qla2x00_async_tm_cmd()
1870 sp->free(sp); in qla2x00_async_tm_cmd()
1871 fcport->flags &= ~FCF_ASYNC_SENT; in qla2x00_async_tm_cmd()
1877 qla24xx_async_abort_command(srb_t *sp) in qla24xx_async_abort_command() argument
1882 fc_port_t *fcport = sp->fcport; in qla24xx_async_abort_command()
1883 struct qla_qpair *qpair = sp->qpair; in qla24xx_async_abort_command()
1884 struct scsi_qla_host *vha = fcport->vha; in qla24xx_async_abort_command()
1885 struct req_que *req = qpair->req; in qla24xx_async_abort_command()
1887 spin_lock_irqsave(qpair->qp_lock_ptr, flags); in qla24xx_async_abort_command()
1888 for (handle = 1; handle < req->num_outstanding_cmds; handle++) { in qla24xx_async_abort_command()
1889 if (req->outstanding_cmds[handle] == sp) in qla24xx_async_abort_command()
1892 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qla24xx_async_abort_command()
1894 if (handle == req->num_outstanding_cmds) { in qla24xx_async_abort_command()
1898 if (sp->type == SRB_FXIOCB_DCMD) in qla24xx_async_abort_command()
1899 return qlafx00_fx_disc(vha, &vha->hw->mr.fcport, in qla24xx_async_abort_command()
1902 return qla24xx_async_abort_cmd(sp, true); in qla24xx_async_abort_command()
1908 WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n", in qla24xx_handle_prli_done_event()
1909 ea->data[0]); in qla24xx_handle_prli_done_event()
1911 switch (ea->data[0]) { in qla24xx_handle_prli_done_event()
1915 __func__, __LINE__, ea->fcport->port_name); in qla24xx_handle_prli_done_event()
1917 ea->fcport->chip_reset = vha->hw->base_qpair->chip_reset; in qla24xx_handle_prli_done_event()
1918 ea->fcport->logout_on_delete = 1; in qla24xx_handle_prli_done_event()
1919 ea->fcport->nvme_prli_service_param = ea->iop[0]; in qla24xx_handle_prli_done_event()
1920 if (ea->iop[0] & NVME_PRLI_SP_FIRST_BURST) in qla24xx_handle_prli_done_event()
1921 ea->fcport->nvme_first_burst_size = in qla24xx_handle_prli_done_event()
1922 (ea->iop[1] & 0xffff) * 512; in qla24xx_handle_prli_done_event()
1924 ea->fcport->nvme_first_burst_size = 0; in qla24xx_handle_prli_done_event()
1925 qla24xx_post_gpdb_work(vha, ea->fcport, 0); in qla24xx_handle_prli_done_event()
1928 if ((ea->iop[0] == LSC_SCODE_ELS_REJECT) && in qla24xx_handle_prli_done_event()
1929 (ea->iop[1] == 0x50000)) { /* reson 5=busy expl:0x0 */ in qla24xx_handle_prli_done_event()
1930 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_prli_done_event()
1931 ea->fcport->fw_login_state = DSC_LS_PLOGI_COMP; in qla24xx_handle_prli_done_event()
1936 * Retry PRLI with other FC-4 type if failure occurred on dual in qla24xx_handle_prli_done_event()
1939 if (NVME_FCP_TARGET(ea->fcport)) { in qla24xx_handle_prli_done_event()
1942 __func__, __LINE__, ea->fcport->port_name, in qla24xx_handle_prli_done_event()
1943 (ea->fcport->fc4_type & FS_FC4TYPE_NVME) ? in qla24xx_handle_prli_done_event()
1945 if (vha->hw->fc4_type_priority == FC4_PRIORITY_NVME) in qla24xx_handle_prli_done_event()
1946 ea->fcport->fc4_type &= ~FS_FC4TYPE_NVME; in qla24xx_handle_prli_done_event()
1948 ea->fcport->fc4_type &= ~FS_FC4TYPE_FCP; in qla24xx_handle_prli_done_event()
1951 ea->fcport->flags &= ~FCF_ASYNC_SENT; in qla24xx_handle_prli_done_event()
1952 ea->fcport->keep_nport_handle = 0; in qla24xx_handle_prli_done_event()
1953 ea->fcport->logout_on_delete = 1; in qla24xx_handle_prli_done_event()
1954 qlt_schedule_sess_for_deletion(ea->fcport); in qla24xx_handle_prli_done_event()
1966 struct fc_port *fcport = ea->fcport; in qla24xx_handle_plogi_done_event()
1970 __func__, fcport->port_name, fcport->disc_state, in qla24xx_handle_plogi_done_event()
1971 fcport->fw_login_state, ea->rc, ea->sp->gen2, fcport->login_gen, in qla24xx_handle_plogi_done_event()
1972 ea->sp->gen1, fcport->rscn_gen, in qla24xx_handle_plogi_done_event()
1973 ea->data[0], ea->data[1], ea->iop[0], ea->iop[1]); in qla24xx_handle_plogi_done_event()
1975 if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) || in qla24xx_handle_plogi_done_event()
1976 (fcport->fw_login_state == DSC_LS_PRLI_PEND)) { in qla24xx_handle_plogi_done_event()
1979 __func__, __LINE__, fcport->port_name); in qla24xx_handle_plogi_done_event()
1983 if ((fcport->disc_state == DSC_DELETE_PEND) || in qla24xx_handle_plogi_done_event()
1984 (fcport->disc_state == DSC_DELETED)) { in qla24xx_handle_plogi_done_event()
1985 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_plogi_done_event()
1989 if (ea->sp->gen2 != fcport->login_gen) { in qla24xx_handle_plogi_done_event()
1993 __func__, fcport->port_name); in qla24xx_handle_plogi_done_event()
1994 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_plogi_done_event()
1996 } else if (ea->sp->gen1 != fcport->rscn_gen) { in qla24xx_handle_plogi_done_event()
1999 __func__, fcport->port_name); in qla24xx_handle_plogi_done_event()
2005 WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n", in qla24xx_handle_plogi_done_event()
2006 ea->data[0]); in qla24xx_handle_plogi_done_event()
2008 switch (ea->data[0]) { in qla24xx_handle_plogi_done_event()
2011 * Driver must validate login state - If PRLI not complete, in qla24xx_handle_plogi_done_event()
2015 if (NVME_TARGET(vha->hw, ea->fcport)) { in qla24xx_handle_plogi_done_event()
2018 __func__, __LINE__, ea->fcport->port_name); in qla24xx_handle_plogi_done_event()
2019 qla24xx_post_prli_work(vha, ea->fcport); in qla24xx_handle_plogi_done_event()
2023 __func__, __LINE__, ea->fcport->port_name, in qla24xx_handle_plogi_done_event()
2024 ea->fcport->loop_id, ea->fcport->d_id.b24); in qla24xx_handle_plogi_done_event()
2026 set_bit(ea->fcport->loop_id, vha->hw->loop_id_map); in qla24xx_handle_plogi_done_event()
2027 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla24xx_handle_plogi_done_event()
2028 ea->fcport->chip_reset = vha->hw->base_qpair->chip_reset; in qla24xx_handle_plogi_done_event()
2029 ea->fcport->logout_on_delete = 1; in qla24xx_handle_plogi_done_event()
2030 ea->fcport->send_els_logo = 0; in qla24xx_handle_plogi_done_event()
2031 ea->fcport->fw_login_state = DSC_LS_PRLI_COMP; in qla24xx_handle_plogi_done_event()
2032 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla24xx_handle_plogi_done_event()
2034 qla24xx_post_gpdb_work(vha, ea->fcport, 0); in qla24xx_handle_plogi_done_event()
2039 __func__, __LINE__, ea->fcport->port_name, ea->data[1]); in qla24xx_handle_plogi_done_event()
2041 ea->fcport->flags &= ~FCF_ASYNC_SENT; in qla24xx_handle_plogi_done_event()
2042 qla2x00_set_fcport_disc_state(ea->fcport, DSC_LOGIN_FAILED); in qla24xx_handle_plogi_done_event()
2043 if (ea->data[1] & QLA_LOGIO_LOGIN_RETRIED) in qla24xx_handle_plogi_done_event()
2044 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_handle_plogi_done_event()
2046 qla2x00_mark_device_lost(vha, ea->fcport, 1); in qla24xx_handle_plogi_done_event()
2050 cid.b.domain = (ea->iop[1] >> 16) & 0xff; in qla24xx_handle_plogi_done_event()
2051 cid.b.area = (ea->iop[1] >> 8) & 0xff; in qla24xx_handle_plogi_done_event()
2052 cid.b.al_pa = ea->iop[1] & 0xff; in qla24xx_handle_plogi_done_event()
2057 __func__, __LINE__, ea->fcport->port_name, in qla24xx_handle_plogi_done_event()
2058 ea->fcport->loop_id, cid.b24); in qla24xx_handle_plogi_done_event()
2060 set_bit(ea->fcport->loop_id, vha->hw->loop_id_map); in qla24xx_handle_plogi_done_event()
2061 ea->fcport->loop_id = FC_NO_LOOP_ID; in qla24xx_handle_plogi_done_event()
2062 qla24xx_post_gnl_work(vha, ea->fcport); in qla24xx_handle_plogi_done_event()
2065 lid = ea->iop[1] & 0xffff; in qla24xx_handle_plogi_done_event()
2067 wwn_to_u64(ea->fcport->port_name), in qla24xx_handle_plogi_done_event()
2068 ea->fcport->d_id, lid, &conflict_fcport); in qla24xx_handle_plogi_done_event()
2076 conflict_fcport->conflict = ea->fcport; in qla24xx_handle_plogi_done_event()
2077 ea->fcport->login_pause = 1; in qla24xx_handle_plogi_done_event()
2081 __func__, __LINE__, ea->fcport->port_name, in qla24xx_handle_plogi_done_event()
2082 ea->fcport->d_id.b24, lid); in qla24xx_handle_plogi_done_event()
2085 "%s %d %8phC NPortId %06x inuse with loopid 0x%x. sched delete\n", in qla24xx_handle_plogi_done_event()
2086 __func__, __LINE__, ea->fcport->port_name, in qla24xx_handle_plogi_done_event()
2087 ea->fcport->d_id.b24, lid); in qla24xx_handle_plogi_done_event()
2089 qla2x00_clear_loop_id(ea->fcport); in qla24xx_handle_plogi_done_event()
2090 set_bit(lid, vha->hw->loop_id_map); in qla24xx_handle_plogi_done_event()
2091 ea->fcport->loop_id = lid; in qla24xx_handle_plogi_done_event()
2092 ea->fcport->keep_nport_handle = 0; in qla24xx_handle_plogi_done_event()
2093 ea->fcport->logout_on_delete = 1; in qla24xx_handle_plogi_done_event()
2094 qlt_schedule_sess_for_deletion(ea->fcport); in qla24xx_handle_plogi_done_event()
2109 struct qla_hw_data *ha = vha->hw; in qla83xx_nic_core_fw_load()
2116 * flash-info / other param in qla83xx_nic_core_fw_load()
2118 ha->fcoe_dev_init_timeout = QLA83XX_IDC_INITIALIZATION_TIMEOUT; in qla83xx_nic_core_fw_load()
2119 ha->fcoe_reset_timeout = QLA83XX_IDC_RESET_ACK_TIMEOUT; in qla83xx_nic_core_fw_load()
2124 "Error while setting DRV-Presence.\n"); in qla83xx_nic_core_fw_load()
2134 * Init-Owner: Set IDC-Major-Version and Clear IDC-Lock-Recovery in qla83xx_nic_core_fw_load()
2139 if (ha->flags.nic_core_reset_owner) { in qla83xx_nic_core_fw_load()
2144 /* Clearing IDC-Lock-Recovery register */ in qla83xx_nic_core_fw_load()
2160 idc_minor_ver |= (QLA83XX_SUPP_IDC_MINOR_VERSION << (ha->portnum * 2)); in qla83xx_nic_core_fw_load()
2163 if (ha->flags.nic_core_reset_owner) { in qla83xx_nic_core_fw_load()
2192 struct qla_hw_data *ha = vha->hw; in qla2x00_initialize_adapter()
2193 struct req_que *req = ha->req_q_map[0]; in qla2x00_initialize_adapter()
2194 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla2x00_initialize_adapter()
2196 memset(&vha->qla_stats, 0, sizeof(vha->qla_stats)); in qla2x00_initialize_adapter()
2197 memset(&vha->fc_host_stat, 0, sizeof(vha->fc_host_stat)); in qla2x00_initialize_adapter()
2200 vha->flags.online = 0; in qla2x00_initialize_adapter()
2201 ha->flags.chip_reset_done = 0; in qla2x00_initialize_adapter()
2202 vha->flags.reset_active = 0; in qla2x00_initialize_adapter()
2203 ha->flags.pci_channel_io_perm_failure = 0; in qla2x00_initialize_adapter()
2204 ha->flags.eeh_busy = 0; in qla2x00_initialize_adapter()
2205 vha->qla_stats.jiffies_at_last_reset = get_jiffies_64(); in qla2x00_initialize_adapter()
2206 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); in qla2x00_initialize_adapter()
2207 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_initialize_adapter()
2208 vha->device_flags = DFLG_NO_CABLE; in qla2x00_initialize_adapter()
2209 vha->dpc_flags = 0; in qla2x00_initialize_adapter()
2210 vha->flags.management_server_logged_in = 0; in qla2x00_initialize_adapter()
2211 vha->marker_needed = 0; in qla2x00_initialize_adapter()
2212 ha->isp_abort_cnt = 0; in qla2x00_initialize_adapter()
2213 ha->beacon_blink_led = 0; in qla2x00_initialize_adapter()
2215 set_bit(0, ha->req_qid_map); in qla2x00_initialize_adapter()
2216 set_bit(0, ha->rsp_qid_map); in qla2x00_initialize_adapter()
2220 rval = ha->isp_ops->pci_config(vha); in qla2x00_initialize_adapter()
2227 ha->isp_ops->reset_chip(vha); in qla2x00_initialize_adapter()
2231 if (rd_reg_word(®->mailbox12) & BIT_0) in qla2x00_initialize_adapter()
2232 ha->flags.secure_adapter = 1; in qla2x00_initialize_adapter()
2234 (ha->flags.secure_adapter) ? "Yes" : "No"); in qla2x00_initialize_adapter()
2256 ha->isp_ops->get_flash_version(vha, req->ring); in qla2x00_initialize_adapter()
2261 ha->fc4_type_priority = FC4_PRIORITY_FCP; in qla2x00_initialize_adapter()
2263 ha->isp_ops->nvram_config(vha); in qla2x00_initialize_adapter()
2265 if (ha->fc4_type_priority != FC4_PRIORITY_FCP && in qla2x00_initialize_adapter()
2266 ha->fc4_type_priority != FC4_PRIORITY_NVME) in qla2x00_initialize_adapter()
2267 ha->fc4_type_priority = FC4_PRIORITY_FCP; in qla2x00_initialize_adapter()
2270 ha->fc4_type_priority == FC4_PRIORITY_FCP ? "FCP" : "NVMe"); in qla2x00_initialize_adapter()
2272 if (ha->flags.disable_serdes) { in qla2x00_initialize_adapter()
2275 "Masking HBA WWPN %8phN (via NVRAM).\n", vha->port_name); in qla2x00_initialize_adapter()
2289 rval = ha->isp_ops->chip_diag(vha); in qla2x00_initialize_adapter()
2298 ha->cs84xx = qla84xx_get_chip(vha); in qla2x00_initialize_adapter()
2299 if (!ha->cs84xx) { in qla2x00_initialize_adapter()
2313 ha->flags.chip_reset_done = 1; in qla2x00_initialize_adapter()
2345 * qla2100_pci_config() - Setup ISP21xx PCI configuration registers.
2355 struct qla_hw_data *ha = vha->hw; in qla2100_pci_config()
2356 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2100_pci_config()
2358 pci_set_master(ha->pdev); in qla2100_pci_config()
2359 pci_try_set_mwi(ha->pdev); in qla2100_pci_config()
2361 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); in qla2100_pci_config()
2363 pci_write_config_word(ha->pdev, PCI_COMMAND, w); in qla2100_pci_config()
2365 pci_disable_rom(ha->pdev); in qla2100_pci_config()
2368 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2100_pci_config()
2369 ha->pci_attr = rd_reg_word(®->ctrl_status); in qla2100_pci_config()
2370 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2100_pci_config()
2376 * qla2300_pci_config() - Setup ISP23xx PCI configuration registers.
2387 struct qla_hw_data *ha = vha->hw; in qla2300_pci_config()
2388 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2300_pci_config()
2390 pci_set_master(ha->pdev); in qla2300_pci_config()
2391 pci_try_set_mwi(ha->pdev); in qla2300_pci_config()
2393 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); in qla2300_pci_config()
2398 pci_write_config_word(ha->pdev, PCI_COMMAND, w); in qla2300_pci_config()
2404 * fb revision level -- a 6 indicates it really is a 2300 and in qla2300_pci_config()
2408 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2300_pci_config()
2411 wrt_reg_word(®->hccr, HCCR_PAUSE_RISC); in qla2300_pci_config()
2413 if ((rd_reg_word(®->hccr) & HCCR_RISC_PAUSE) != 0) in qla2300_pci_config()
2420 wrt_reg_word(®->ctrl_status, 0x20); in qla2300_pci_config()
2421 rd_reg_word(®->ctrl_status); in qla2300_pci_config()
2424 ha->fb_rev = RD_FB_CMD_REG(ha, reg); in qla2300_pci_config()
2426 if (ha->fb_rev == FPM_2300) in qla2300_pci_config()
2427 pci_clear_mwi(ha->pdev); in qla2300_pci_config()
2430 wrt_reg_word(®->ctrl_status, 0x0); in qla2300_pci_config()
2431 rd_reg_word(®->ctrl_status); in qla2300_pci_config()
2434 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2300_pci_config()
2436 if ((rd_reg_word(®->hccr) & HCCR_RISC_PAUSE) == 0) in qla2300_pci_config()
2442 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2300_pci_config()
2445 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); in qla2300_pci_config()
2447 pci_disable_rom(ha->pdev); in qla2300_pci_config()
2450 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2300_pci_config()
2451 ha->pci_attr = rd_reg_word(®->ctrl_status); in qla2300_pci_config()
2452 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2300_pci_config()
2458 * qla24xx_pci_config() - Setup ISP24xx PCI configuration registers.
2468 struct qla_hw_data *ha = vha->hw; in qla24xx_pci_config()
2469 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla24xx_pci_config()
2471 pci_set_master(ha->pdev); in qla24xx_pci_config()
2472 pci_try_set_mwi(ha->pdev); in qla24xx_pci_config()
2474 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); in qla24xx_pci_config()
2477 pci_write_config_word(ha->pdev, PCI_COMMAND, w); in qla24xx_pci_config()
2479 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); in qla24xx_pci_config()
2481 /* PCI-X -- adjust Maximum Memory Read Byte Count (2048). */ in qla24xx_pci_config()
2482 if (pci_find_capability(ha->pdev, PCI_CAP_ID_PCIX)) in qla24xx_pci_config()
2483 pcix_set_mmrbc(ha->pdev, 2048); in qla24xx_pci_config()
2485 /* PCIe -- adjust Maximum Read Request Size (2048). */ in qla24xx_pci_config()
2486 if (pci_is_pcie(ha->pdev)) in qla24xx_pci_config()
2487 pcie_set_readrq(ha->pdev, 4096); in qla24xx_pci_config()
2489 pci_disable_rom(ha->pdev); in qla24xx_pci_config()
2491 ha->chip_revision = ha->pdev->revision; in qla24xx_pci_config()
2494 spin_lock_irqsave(&ha->hardware_lock, flags); in qla24xx_pci_config()
2495 ha->pci_attr = rd_reg_dword(®->ctrl_status); in qla24xx_pci_config()
2496 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_pci_config()
2502 * qla25xx_pci_config() - Setup ISP25xx PCI configuration registers.
2511 struct qla_hw_data *ha = vha->hw; in qla25xx_pci_config()
2513 pci_set_master(ha->pdev); in qla25xx_pci_config()
2514 pci_try_set_mwi(ha->pdev); in qla25xx_pci_config()
2516 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); in qla25xx_pci_config()
2519 pci_write_config_word(ha->pdev, PCI_COMMAND, w); in qla25xx_pci_config()
2521 /* PCIe -- adjust Maximum Read Request Size (2048). */ in qla25xx_pci_config()
2522 if (pci_is_pcie(ha->pdev)) in qla25xx_pci_config()
2523 pcie_set_readrq(ha->pdev, 4096); in qla25xx_pci_config()
2525 pci_disable_rom(ha->pdev); in qla25xx_pci_config()
2527 ha->chip_revision = ha->pdev->revision; in qla25xx_pci_config()
2533 * qla2x00_isp_firmware() - Choose firmware image.
2544 struct qla_hw_data *ha = vha->hw; in qla2x00_isp_firmware()
2549 if (ha->flags.disable_risc_code_load) { in qla2x00_isp_firmware()
2553 rval = qla2x00_verify_checksum(vha, ha->fw_srisc_address); in qla2x00_isp_firmware()
2569 * qla2x00_reset_chip() - Reset ISP chip.
2578 struct qla_hw_data *ha = vha->hw; in qla2x00_reset_chip()
2579 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_reset_chip()
2584 if (unlikely(pci_channel_offline(ha->pdev))) in qla2x00_reset_chip()
2587 ha->isp_ops->disable_intrs(ha); in qla2x00_reset_chip()
2589 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_reset_chip()
2593 pci_read_config_word(ha->pdev, PCI_COMMAND, &cmd); in qla2x00_reset_chip()
2595 pci_write_config_word(ha->pdev, PCI_COMMAND, cmd); in qla2x00_reset_chip()
2599 wrt_reg_word(®->hccr, HCCR_PAUSE_RISC); in qla2x00_reset_chip()
2602 if ((rd_reg_word(®->hccr) & in qla2x00_reset_chip()
2608 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2613 wrt_reg_word(®->ctrl_status, 0x20); in qla2x00_reset_chip()
2614 rd_reg_word(®->ctrl_status); /* PCI Posting. */ in qla2x00_reset_chip()
2617 wrt_reg_word(®->fpm_diag_config, 0x100); in qla2x00_reset_chip()
2618 rd_reg_word(®->fpm_diag_config); /* PCI Posting. */ in qla2x00_reset_chip()
2622 wrt_reg_word(®->fpm_diag_config, 0x0); in qla2x00_reset_chip()
2623 rd_reg_word(®->fpm_diag_config); /* PCI Posting. */ in qla2x00_reset_chip()
2627 wrt_reg_word(®->ctrl_status, 0x10); in qla2x00_reset_chip()
2628 rd_reg_word(®->ctrl_status); /* PCI Posting. */ in qla2x00_reset_chip()
2646 wrt_reg_word(®->ctrl_status, 0); in qla2x00_reset_chip()
2647 rd_reg_word(®->ctrl_status); /* PCI Posting. */ in qla2x00_reset_chip()
2650 wrt_reg_word(®->hccr, HCCR_RESET_RISC); in qla2x00_reset_chip()
2651 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2654 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2x00_reset_chip()
2655 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2658 wrt_reg_word(®->hccr, HCCR_CLR_RISC_INT); in qla2x00_reset_chip()
2659 wrt_reg_word(®->hccr, HCCR_CLR_HOST_INT); in qla2x00_reset_chip()
2662 wrt_reg_word(®->ctrl_status, CSR_ISP_SOFT_RESET); in qla2x00_reset_chip()
2672 for (cnt = 30000; cnt; cnt--) { in qla2x00_reset_chip()
2673 if ((rd_reg_word(®->ctrl_status) & in qla2x00_reset_chip()
2682 wrt_reg_word(®->hccr, HCCR_RESET_RISC); in qla2x00_reset_chip()
2684 wrt_reg_word(®->semaphore, 0); in qla2x00_reset_chip()
2687 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2x00_reset_chip()
2688 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2702 pci_write_config_word(ha->pdev, PCI_COMMAND, cmd); in qla2x00_reset_chip()
2706 wrt_reg_word(®->hccr, HCCR_DISABLE_PARITY_PAUSE); in qla2x00_reset_chip()
2707 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_chip()
2710 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_reset_chip()
2716 * qla81xx_reset_mpi() - Reset's MPI FW via Write MPI Register MBC.
2726 if (!IS_QLA81XX(vha->hw)) in qla81xx_reset_mpi()
2733 * qla24xx_reset_risc() - Perform full reset of ISP24xx RISC.
2742 struct qla_hw_data *ha = vha->hw; in qla24xx_reset_risc()
2743 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla24xx_reset_risc()
2749 spin_lock_irqsave(&ha->hardware_lock, flags); in qla24xx_reset_risc()
2752 wrt_reg_dword(®->ctrl_status, CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); in qla24xx_reset_risc()
2754 if ((rd_reg_dword(®->ctrl_status) & CSRX_DMA_ACTIVE) == 0) in qla24xx_reset_risc()
2760 if (!(rd_reg_dword(®->ctrl_status) & CSRX_DMA_ACTIVE)) in qla24xx_reset_risc()
2761 set_bit(DMA_SHUTDOWN_CMPL, &ha->fw_dump_cap_flags); in qla24xx_reset_risc()
2765 rd_reg_dword(®->hccr), in qla24xx_reset_risc()
2766 rd_reg_dword(®->ctrl_status), in qla24xx_reset_risc()
2767 (rd_reg_dword(®->ctrl_status) & CSRX_DMA_ACTIVE)); in qla24xx_reset_risc()
2769 wrt_reg_dword(®->ctrl_status, in qla24xx_reset_risc()
2771 pci_read_config_word(ha->pdev, PCI_COMMAND, &wd); in qla24xx_reset_risc()
2776 rd_reg_word(®->mailbox0); in qla24xx_reset_risc()
2777 for (cnt = 10000; rd_reg_word(®->mailbox0) != 0 && in qla24xx_reset_risc()
2778 rval == QLA_SUCCESS; cnt--) { in qla24xx_reset_risc()
2787 set_bit(ISP_MBX_RDY, &ha->fw_dump_cap_flags); in qla24xx_reset_risc()
2791 rd_reg_dword(®->hccr), in qla24xx_reset_risc()
2792 rd_reg_word(®->mailbox0)); in qla24xx_reset_risc()
2794 /* Wait for soft-reset to complete. */ in qla24xx_reset_risc()
2795 rd_reg_dword(®->ctrl_status); in qla24xx_reset_risc()
2798 if ((rd_reg_dword(®->ctrl_status) & in qla24xx_reset_risc()
2804 if (!(rd_reg_dword(®->ctrl_status) & CSRX_ISP_SOFT_RESET)) in qla24xx_reset_risc()
2805 set_bit(ISP_SOFT_RESET_CMPL, &ha->fw_dump_cap_flags); in qla24xx_reset_risc()
2809 rd_reg_dword(®->hccr), in qla24xx_reset_risc()
2810 rd_reg_dword(®->ctrl_status)); in qla24xx_reset_risc()
2813 if (test_and_clear_bit(MPI_RESET_NEEDED, &vha->dpc_flags)) { in qla24xx_reset_risc()
2816 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla24xx_reset_risc()
2817 set_bit(MPI_RESET_NEEDED, &vha->dpc_flags); in qla24xx_reset_risc()
2824 vha->flags.online = 0; in qla24xx_reset_risc()
2829 wrt_reg_dword(®->hccr, HCCRX_SET_RISC_RESET); in qla24xx_reset_risc()
2830 rd_reg_dword(®->hccr); in qla24xx_reset_risc()
2832 wrt_reg_dword(®->hccr, HCCRX_REL_RISC_PAUSE); in qla24xx_reset_risc()
2833 rd_reg_dword(®->hccr); in qla24xx_reset_risc()
2835 wrt_reg_dword(®->hccr, HCCRX_CLR_RISC_RESET); in qla24xx_reset_risc()
2836 rd_reg_dword(®->hccr); in qla24xx_reset_risc()
2838 rd_reg_word(®->mailbox0); in qla24xx_reset_risc()
2839 for (cnt = 60; rd_reg_word(®->mailbox0) != 0 && in qla24xx_reset_risc()
2840 rval == QLA_SUCCESS; cnt--) { in qla24xx_reset_risc()
2848 set_bit(RISC_RDY_AFT_RESET, &ha->fw_dump_cap_flags); in qla24xx_reset_risc()
2852 rd_reg_dword(®->hccr), in qla24xx_reset_risc()
2853 rd_reg_word(®->mailbox0)); in qla24xx_reset_risc()
2855 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_reset_risc()
2862 ha->isp_ops->enable_intrs(ha); in qla24xx_reset_risc()
2870 struct device_reg_24xx __iomem *reg = &vha->hw->iobase->isp24; in qla25xx_read_risc_sema_reg()
2872 wrt_reg_dword(®->iobase_addr, RISC_REGISTER_BASE_OFFSET); in qla25xx_read_risc_sema_reg()
2873 *data = rd_reg_dword(®->iobase_window + RISC_REGISTER_WINDOW_OFFSET); in qla25xx_read_risc_sema_reg()
2879 struct device_reg_24xx __iomem *reg = &vha->hw->iobase->isp24; in qla25xx_write_risc_sema_reg()
2881 wrt_reg_dword(®->iobase_addr, RISC_REGISTER_BASE_OFFSET); in qla25xx_write_risc_sema_reg()
2882 wrt_reg_dword(®->iobase_window + RISC_REGISTER_WINDOW_OFFSET, data); in qla25xx_write_risc_sema_reg()
2894 if (vha->hw->pdev->subsystem_device != 0x0175 && in qla25xx_manipulate_risc_semaphore()
2895 vha->hw->pdev->subsystem_device != 0x0240) in qla25xx_manipulate_risc_semaphore()
2898 wrt_reg_dword(&vha->hw->iobase->isp24.hccr, HCCRX_SET_RISC_PAUSE); in qla25xx_manipulate_risc_semaphore()
2904 while (n--) { in qla25xx_manipulate_risc_semaphore()
2924 while (n--) { in qla25xx_manipulate_risc_semaphore()
2947 * qla24xx_reset_chip() - Reset ISP24xx chip.
2955 struct qla_hw_data *ha = vha->hw; in qla24xx_reset_chip()
2958 if (pci_channel_offline(ha->pdev) && in qla24xx_reset_chip()
2959 ha->flags.pci_channel_io_perm_failure) { in qla24xx_reset_chip()
2963 ha->isp_ops->disable_intrs(ha); in qla24xx_reset_chip()
2974 * qla2x00_chip_diag() - Test chip for proper operation.
2983 struct qla_hw_data *ha = vha->hw; in qla2x00_chip_diag()
2984 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_chip_diag()
2989 struct req_que *req = ha->req_q_map[0]; in qla2x00_chip_diag()
2995 ®->flash_address); in qla2x00_chip_diag()
2997 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_chip_diag()
3000 wrt_reg_word(®->ctrl_status, CSR_ISP_SOFT_RESET); in qla2x00_chip_diag()
3007 data = qla2x00_debounce_register(®->ctrl_status); in qla2x00_chip_diag()
3008 for (cnt = 6000000 ; cnt && (data & CSR_ISP_SOFT_RESET); cnt--) { in qla2x00_chip_diag()
3010 data = rd_reg_word(®->ctrl_status); in qla2x00_chip_diag()
3021 wrt_reg_word(®->hccr, HCCR_RESET_RISC); in qla2x00_chip_diag()
3022 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2x00_chip_diag()
3027 for (cnt = 6000000; cnt && (data == MBS_BUSY); cnt--) { in qla2x00_chip_diag()
3053 ha->product_id[0] = mb[1]; in qla2x00_chip_diag()
3054 ha->product_id[1] = mb[2]; in qla2x00_chip_diag()
3055 ha->product_id[2] = mb[3]; in qla2x00_chip_diag()
3056 ha->product_id[3] = mb[4]; in qla2x00_chip_diag()
3059 if (req->length > 1024) in qla2x00_chip_diag()
3060 ha->fw_transfer_size = REQUEST_ENTRY_SIZE * 1024; in qla2x00_chip_diag()
3062 ha->fw_transfer_size = REQUEST_ENTRY_SIZE * in qla2x00_chip_diag()
3063 req->length; in qla2x00_chip_diag()
3070 ha->device_type |= DT_ISP2200A; in qla2x00_chip_diag()
3071 ha->fw_transfer_size = 128; in qla2x00_chip_diag()
3075 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_chip_diag()
3085 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_chip_diag()
3092 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_chip_diag()
3098 * qla24xx_chip_diag() - Test ISP24xx for proper operation.
3107 struct qla_hw_data *ha = vha->hw; in qla24xx_chip_diag()
3108 struct req_que *req = ha->req_q_map[0]; in qla24xx_chip_diag()
3113 ha->fw_transfer_size = REQUEST_ENTRY_SIZE * req->length; in qla24xx_chip_diag()
3133 struct qla_hw_data *ha = vha->hw; in qla2x00_init_fce_trace()
3142 if (ha->fce) { in qla2x00_init_fce_trace()
3150 tc = dma_alloc_coherent(&ha->pdev->dev, FCE_SIZE, &tc_dma, in qla2x00_init_fce_trace()
3160 ha->fce_mb, &ha->fce_bufs); in qla2x00_init_fce_trace()
3164 dma_free_coherent(&ha->pdev->dev, FCE_SIZE, tc, tc_dma); in qla2x00_init_fce_trace()
3171 ha->flags.fce_enabled = 1; in qla2x00_init_fce_trace()
3172 ha->fce_dma = tc_dma; in qla2x00_init_fce_trace()
3173 ha->fce = tc; in qla2x00_init_fce_trace()
3182 struct qla_hw_data *ha = vha->hw; in qla2x00_init_eft_trace()
3187 if (ha->eft) { in qla2x00_init_eft_trace()
3195 tc = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &tc_dma, in qla2x00_init_eft_trace()
3208 dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc, tc_dma); in qla2x00_init_eft_trace()
3215 ha->eft_dma = tc_dma; in qla2x00_init_eft_trace()
3216 ha->eft = tc; in qla2x00_init_eft_trace()
3231 struct qla_hw_data *ha = vha->hw; in qla2x00_alloc_fw_dump()
3232 struct req_que *req = ha->req_q_map[0]; in qla2x00_alloc_fw_dump()
3233 struct rsp_que *rsp = ha->rsp_q_map[0]; in qla2x00_alloc_fw_dump()
3243 mem_size = (ha->fw_memory_size - 0x11000 + 1) * in qla2x00_alloc_fw_dump()
3255 mem_size = (ha->fw_memory_size - 0x100000 + 1) * in qla2x00_alloc_fw_dump()
3257 if (ha->mqenable) { in qla2x00_alloc_fw_dump()
3262 * Allocate maximum buffer size for all queues - Q0. in qla2x00_alloc_fw_dump()
3263 * Resizing must be done at end-of-dump processing. in qla2x00_alloc_fw_dump()
3265 mq_size += (ha->max_req_queues - 1) * in qla2x00_alloc_fw_dump()
3266 (req->length * sizeof(request_t)); in qla2x00_alloc_fw_dump()
3267 mq_size += (ha->max_rsp_queues - 1) * in qla2x00_alloc_fw_dump()
3268 (rsp->length * sizeof(response_t)); in qla2x00_alloc_fw_dump()
3270 if (ha->tgt.atio_ring) in qla2x00_alloc_fw_dump()
3271 mq_size += ha->tgt.atio_q_length * sizeof(request_t); in qla2x00_alloc_fw_dump()
3274 if (ha->fce) in qla2x00_alloc_fw_dump()
3277 if (ha->eft) in qla2x00_alloc_fw_dump()
3282 struct fwdt *fwdt = ha->fwdt; in qla2x00_alloc_fw_dump()
3286 if (!fwdt->template) { in qla2x00_alloc_fw_dump()
3288 "-> fwdt%u no template\n", j); in qla2x00_alloc_fw_dump()
3292 "-> fwdt%u calculating fwdump size...\n", j); in qla2x00_alloc_fw_dump()
3293 fwdt->dump_size = qla27xx_fwdt_calculate_dump_size( in qla2x00_alloc_fw_dump()
3294 vha, fwdt->template); in qla2x00_alloc_fw_dump()
3296 "-> fwdt%u calculated fwdump size = %#lx bytes\n", in qla2x00_alloc_fw_dump()
3297 j, fwdt->dump_size); in qla2x00_alloc_fw_dump()
3298 dump_size += fwdt->dump_size; in qla2x00_alloc_fw_dump()
3301 dump_size += ha->fwdt[1].dump_size; in qla2x00_alloc_fw_dump()
3303 req_q_size = req->length * sizeof(request_t); in qla2x00_alloc_fw_dump()
3304 rsp_q_size = rsp->length * sizeof(response_t); in qla2x00_alloc_fw_dump()
3308 ha->chain_offset = dump_size; in qla2x00_alloc_fw_dump()
3310 if (ha->exchoffld_buf) in qla2x00_alloc_fw_dump()
3312 ha->exchoffld_size; in qla2x00_alloc_fw_dump()
3313 if (ha->exlogin_buf) in qla2x00_alloc_fw_dump()
3315 ha->exlogin_size; in qla2x00_alloc_fw_dump()
3318 if (!ha->fw_dump_len || dump_size > ha->fw_dump_alloc_len) { in qla2x00_alloc_fw_dump()
3322 __func__, dump_size, ha->fw_dump_len, in qla2x00_alloc_fw_dump()
3323 ha->fw_dump_alloc_len); in qla2x00_alloc_fw_dump()
3331 mutex_lock(&ha->optrom_mutex); in qla2x00_alloc_fw_dump()
3332 if (ha->fw_dumped) { in qla2x00_alloc_fw_dump()
3333 memcpy(fw_dump, ha->fw_dump, ha->fw_dump_len); in qla2x00_alloc_fw_dump()
3334 vfree(ha->fw_dump); in qla2x00_alloc_fw_dump()
3335 ha->fw_dump = fw_dump; in qla2x00_alloc_fw_dump()
3336 ha->fw_dump_alloc_len = dump_size; in qla2x00_alloc_fw_dump()
3338 "Re-Allocated (%d KB) and save firmware dump.\n", in qla2x00_alloc_fw_dump()
3341 if (ha->fw_dump) in qla2x00_alloc_fw_dump()
3342 vfree(ha->fw_dump); in qla2x00_alloc_fw_dump()
3343 ha->fw_dump = fw_dump; in qla2x00_alloc_fw_dump()
3345 ha->fw_dump_len = ha->fw_dump_alloc_len = in qla2x00_alloc_fw_dump()
3352 ha->mpi_fw_dump = (char *)fw_dump + in qla2x00_alloc_fw_dump()
3353 ha->fwdt[1].dump_size; in qla2x00_alloc_fw_dump()
3354 mutex_unlock(&ha->optrom_mutex); in qla2x00_alloc_fw_dump()
3358 ha->fw_dump->signature[0] = 'Q'; in qla2x00_alloc_fw_dump()
3359 ha->fw_dump->signature[1] = 'L'; in qla2x00_alloc_fw_dump()
3360 ha->fw_dump->signature[2] = 'G'; in qla2x00_alloc_fw_dump()
3361 ha->fw_dump->signature[3] = 'C'; in qla2x00_alloc_fw_dump()
3362 ha->fw_dump->version = htonl(1); in qla2x00_alloc_fw_dump()
3364 ha->fw_dump->fixed_size = htonl(fixed_size); in qla2x00_alloc_fw_dump()
3365 ha->fw_dump->mem_size = htonl(mem_size); in qla2x00_alloc_fw_dump()
3366 ha->fw_dump->req_q_size = htonl(req_q_size); in qla2x00_alloc_fw_dump()
3367 ha->fw_dump->rsp_q_size = htonl(rsp_q_size); in qla2x00_alloc_fw_dump()
3369 ha->fw_dump->eft_size = htonl(eft_size); in qla2x00_alloc_fw_dump()
3370 ha->fw_dump->eft_addr_l = in qla2x00_alloc_fw_dump()
3371 htonl(LSD(ha->eft_dma)); in qla2x00_alloc_fw_dump()
3372 ha->fw_dump->eft_addr_h = in qla2x00_alloc_fw_dump()
3373 htonl(MSD(ha->eft_dma)); in qla2x00_alloc_fw_dump()
3375 ha->fw_dump->header_size = in qla2x00_alloc_fw_dump()
3379 mutex_unlock(&ha->optrom_mutex); in qla2x00_alloc_fw_dump()
3392 if (!IS_QLA81XX(vha->hw)) in qla81xx_mpi_sync()
3402 pci_read_config_word(vha->hw->pdev, 0x54, &dc); in qla81xx_mpi_sync()
3435 if (req->outstanding_cmds) in qla2x00_alloc_outstanding_cmds()
3439 req->num_outstanding_cmds = DEFAULT_OUTSTANDING_COMMANDS; in qla2x00_alloc_outstanding_cmds()
3441 if (ha->cur_fw_xcb_count <= ha->cur_fw_iocb_count) in qla2x00_alloc_outstanding_cmds()
3442 req->num_outstanding_cmds = ha->cur_fw_xcb_count; in qla2x00_alloc_outstanding_cmds()
3444 req->num_outstanding_cmds = ha->cur_fw_iocb_count; in qla2x00_alloc_outstanding_cmds()
3447 req->outstanding_cmds = kcalloc(req->num_outstanding_cmds, in qla2x00_alloc_outstanding_cmds()
3451 if (!req->outstanding_cmds) { in qla2x00_alloc_outstanding_cmds()
3456 req->num_outstanding_cmds = MIN_OUTSTANDING_COMMANDS; in qla2x00_alloc_outstanding_cmds()
3457 req->outstanding_cmds = kcalloc(req->num_outstanding_cmds, in qla2x00_alloc_outstanding_cmds()
3461 if (!req->outstanding_cmds) { in qla2x00_alloc_outstanding_cmds()
3465 req->num_outstanding_cmds = 0; in qla2x00_alloc_outstanding_cmds()
3474 if (a0->_field & _flag) {\
3478 leftover--;\
3482 leftover -= len;\
3490 struct sff_8247_a0 *a0 = (struct sff_8247_a0 *)vha->hw->sfp_data; in qla2xxx_print_sfp_info()
3495 snprintf(str, SFF_VEN_NAME_LEN+1, a0->vendor_name); in qla2xxx_print_sfp_info()
3500 snprintf(str, SFF_PART_NAME_LEN+1, a0->vendor_pn); in qla2xxx_print_sfp_info()
3544 if (a0->length_km) in qla2xxx_print_sfp_info()
3546 "SFP Distant: %d km\n", a0->length_km); in qla2xxx_print_sfp_info()
3547 if (a0->length_100m) in qla2xxx_print_sfp_info()
3549 "SFP Distant: %d m\n", a0->length_100m*100); in qla2xxx_print_sfp_info()
3550 if (a0->length_50um_10m) in qla2xxx_print_sfp_info()
3552 "SFP Distant (WL=50um): %d m\n", a0->length_50um_10m * 10); in qla2xxx_print_sfp_info()
3553 if (a0->length_62um_10m) in qla2xxx_print_sfp_info()
3555 "SFP Distant (WL=62.5um): %d m\n", a0->length_62um_10m * 10); in qla2xxx_print_sfp_info()
3556 if (a0->length_om4_10m) in qla2xxx_print_sfp_info()
3558 "SFP Distant (OM4): %d m\n", a0->length_om4_10m * 10); in qla2xxx_print_sfp_info()
3559 if (a0->length_om3_10m) in qla2xxx_print_sfp_info()
3561 "SFP Distant (OM3): %d m\n", a0->length_om3_10m * 10); in qla2xxx_print_sfp_info()
3571 * 0 -- Configure firmware to use short-range settings -- normal
3572 * buffer-to-buffer credits.
3574 * 1 -- Configure firmware to use long-range settings -- extra
3575 * buffer-to-buffer credits should be allocated with
3576 * ha->lr_distance containing distance settings from NVRAM or SFP
3584 struct qla_hw_data *ha = vha->hw; in qla24xx_detect_sfp()
3585 struct nvram_81xx *nv = ha->nvram; in qla24xx_detect_sfp()
3593 ha->flags.lr_detected = 0; in qla24xx_detect_sfp()
3595 (nv->enhanced_features & NEF_LR_DIST_ENABLE)) { in qla24xx_detect_sfp()
3597 ha->flags.lr_detected = 1; in qla24xx_detect_sfp()
3598 ha->lr_distance = in qla24xx_detect_sfp()
3599 (nv->enhanced_features >> LR_DIST_NV_POS) in qla24xx_detect_sfp()
3611 a = (struct sff_8247_a0 *)vha->hw->sfp_data; in qla24xx_detect_sfp()
3614 ha->flags.lr_detected = 0; in qla24xx_detect_sfp()
3615 ll = a->fc_ll_cc7; in qla24xx_detect_sfp()
3618 ha->flags.lr_detected = 1; in qla24xx_detect_sfp()
3620 if (a->length_km > 5 || a->length_100m > 50) in qla24xx_detect_sfp()
3621 ha->lr_distance = LR_DISTANCE_10K; in qla24xx_detect_sfp()
3623 ha->lr_distance = LR_DISTANCE_5K; in qla24xx_detect_sfp()
3628 "SFP detect: %s-Range SFP %s (nvr=%x ll=%x lr=%x lrd=%x).\n", in qla24xx_detect_sfp()
3629 types[ha->flags.lr_detected], in qla24xx_detect_sfp()
3630 ha->flags.lr_detected ? lengths[ha->lr_distance] : in qla24xx_detect_sfp()
3632 used_nvram, ll, ha->flags.lr_detected, ha->lr_distance); in qla24xx_detect_sfp()
3633 return ha->flags.lr_detected; in qla24xx_detect_sfp()
3640 struct qla_hw_data *ha = vha->hw; in qla_init_iocb_limit()
3642 num_qps = ha->num_qpairs + 1; in qla_init_iocb_limit()
3643 limit = (ha->orig_fw_iocb_count * QLA_IOCB_PCT_LIMIT) / 100; in qla_init_iocb_limit()
3645 ha->base_qpair->fwres.iocbs_total = ha->orig_fw_iocb_count; in qla_init_iocb_limit()
3646 ha->base_qpair->fwres.iocbs_limit = limit; in qla_init_iocb_limit()
3647 ha->base_qpair->fwres.iocbs_qp_limit = limit / num_qps; in qla_init_iocb_limit()
3648 ha->base_qpair->fwres.iocbs_used = 0; in qla_init_iocb_limit()
3649 for (i = 0; i < ha->max_qpairs; i++) { in qla_init_iocb_limit()
3650 if (ha->queue_pair_map[i]) { in qla_init_iocb_limit()
3651 ha->queue_pair_map[i]->fwres.iocbs_total = in qla_init_iocb_limit()
3652 ha->orig_fw_iocb_count; in qla_init_iocb_limit()
3653 ha->queue_pair_map[i]->fwres.iocbs_limit = limit; in qla_init_iocb_limit()
3654 ha->queue_pair_map[i]->fwres.iocbs_qp_limit = in qla_init_iocb_limit()
3656 ha->queue_pair_map[i]->fwres.iocbs_used = 0; in qla_init_iocb_limit()
3662 * qla2x00_setup_chip() - Load and start RISC firmware.
3672 struct qla_hw_data *ha = vha->hw; in qla2x00_setup_chip()
3673 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_setup_chip()
3679 rval = ha->isp_ops->load_risc(vha, &srisc_address); in qla2x00_setup_chip()
3689 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_setup_chip()
3690 wrt_reg_word(®->hccr, (HCCR_ENABLE_PARITY + 0x0)); in qla2x00_setup_chip()
3691 rd_reg_word(®->hccr); in qla2x00_setup_chip()
3692 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_setup_chip()
3699 rval = ha->isp_ops->load_risc(vha, &srisc_address); in qla2x00_setup_chip()
3711 ha->flags.exlogins_enabled = 1; in qla2x00_setup_chip()
3714 ha->flags.exchoffld_enabled = 1; in qla2x00_setup_chip()
3722 "Re-starting firmware -- BPM.\n"); in qla2x00_setup_chip()
3723 /* Best-effort - re-init. */ in qla2x00_setup_chip()
3724 ha->isp_ops->reset_chip(vha); in qla2x00_setup_chip()
3725 ha->isp_ops->chip_diag(vha); in qla2x00_setup_chip()
3731 ha->last_zio_threshold); in qla2x00_setup_chip()
3742 fw_major_version = ha->fw_major_version; in qla2x00_setup_chip()
3749 ha->flags.npiv_supported = 0; in qla2x00_setup_chip()
3751 (ha->fw_attributes & BIT_2)) { in qla2x00_setup_chip()
3752 ha->flags.npiv_supported = 1; in qla2x00_setup_chip()
3753 if ((!ha->max_npiv_vports) || in qla2x00_setup_chip()
3754 ((ha->max_npiv_vports + 1) % in qla2x00_setup_chip()
3756 ha->max_npiv_vports = in qla2x00_setup_chip()
3757 MIN_MULTI_ID_FABRIC - 1; in qla2x00_setup_chip()
3767 vha->req); in qla2x00_setup_chip()
3787 if (ql2xrdpenable || ha->flags.scm_supported_f) in qla2x00_setup_chip()
3794 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_setup_chip()
3797 wrt_reg_word(®->hccr, HCCR_ENABLE_PARITY + 0x1); in qla2x00_setup_chip()
3800 wrt_reg_word(®->hccr, HCCR_ENABLE_PARITY + 0x7); in qla2x00_setup_chip()
3801 rd_reg_word(®->hccr); in qla2x00_setup_chip()
3802 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_setup_chip()
3806 ha->flags.fac_supported = 1; in qla2x00_setup_chip()
3812 ha->flags.fac_supported = 1; in qla2x00_setup_chip()
3813 ha->fdt_block_size = size << 2; in qla2x00_setup_chip()
3817 ha->fw_major_version, ha->fw_minor_version, in qla2x00_setup_chip()
3818 ha->fw_subminor_version); in qla2x00_setup_chip()
3822 ha->flags.fac_supported = 0; in qla2x00_setup_chip()
3837 * qla2x00_init_response_q_entries() - Initializes response queue entries.
3851 rsp->ring_ptr = rsp->ring; in qla2x00_init_response_q_entries()
3852 rsp->ring_index = 0; in qla2x00_init_response_q_entries()
3853 rsp->status_srb = NULL; in qla2x00_init_response_q_entries()
3854 pkt = rsp->ring_ptr; in qla2x00_init_response_q_entries()
3855 for (cnt = 0; cnt < rsp->length; cnt++) { in qla2x00_init_response_q_entries()
3856 pkt->signature = RESPONSE_PROCESSED; in qla2x00_init_response_q_entries()
3862 * qla2x00_update_fw_options() - Read and process firmware options.
3871 struct qla_hw_data *ha = vha->hw; in qla2x00_update_fw_options()
3873 memset(ha->fw_options, 0, sizeof(ha->fw_options)); in qla2x00_update_fw_options()
3874 qla2x00_get_fw_options(vha, ha->fw_options); in qla2x00_update_fw_options()
3883 ha->fw_seriallink_options, sizeof(ha->fw_seriallink_options)); in qla2x00_update_fw_options()
3885 ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING; in qla2x00_update_fw_options()
3886 if (ha->fw_seriallink_options[3] & BIT_2) { in qla2x00_update_fw_options()
3887 ha->fw_options[1] |= FO1_SET_EMPHASIS_SWING; in qla2x00_update_fw_options()
3890 swing = ha->fw_seriallink_options[2] & (BIT_2 | BIT_1 | BIT_0); in qla2x00_update_fw_options()
3891 emphasis = (ha->fw_seriallink_options[2] & in qla2x00_update_fw_options()
3893 tx_sens = ha->fw_seriallink_options[0] & in qla2x00_update_fw_options()
3895 rx_sens = (ha->fw_seriallink_options[0] & in qla2x00_update_fw_options()
3897 ha->fw_options[10] = (emphasis << 14) | (swing << 8); in qla2x00_update_fw_options()
3901 ha->fw_options[10] |= (tx_sens << 4) | rx_sens; in qla2x00_update_fw_options()
3903 ha->fw_options[10] |= BIT_5 | in qla2x00_update_fw_options()
3908 swing = (ha->fw_seriallink_options[2] & in qla2x00_update_fw_options()
3910 emphasis = ha->fw_seriallink_options[3] & (BIT_1 | BIT_0); in qla2x00_update_fw_options()
3911 tx_sens = ha->fw_seriallink_options[1] & in qla2x00_update_fw_options()
3913 rx_sens = (ha->fw_seriallink_options[1] & in qla2x00_update_fw_options()
3915 ha->fw_options[11] = (emphasis << 14) | (swing << 8); in qla2x00_update_fw_options()
3919 ha->fw_options[11] |= (tx_sens << 4) | rx_sens; in qla2x00_update_fw_options()
3921 ha->fw_options[11] |= BIT_5 | in qla2x00_update_fw_options()
3928 ha->fw_options[3] |= BIT_13; in qla2x00_update_fw_options()
3931 if (ha->flags.enable_led_scheme) in qla2x00_update_fw_options()
3932 ha->fw_options[2] |= BIT_12; in qla2x00_update_fw_options()
3936 ha->fw_options[2] |= BIT_13; in qla2x00_update_fw_options()
3939 if (ha->operating_mode == P2P) { in qla2x00_update_fw_options()
3940 ha->fw_options[2] |= BIT_3; in qla2x00_update_fw_options()
3943 __func__, ha->fw_options[2]); in qla2x00_update_fw_options()
3947 qla2x00_set_fw_options(vha, ha->fw_options); in qla2x00_update_fw_options()
3954 struct qla_hw_data *ha = vha->hw; in qla24xx_update_fw_options()
3961 ha->fw_options[3] |= BIT_12; in qla24xx_update_fw_options()
3964 if (ha->operating_mode == P2P) { in qla24xx_update_fw_options()
3965 ha->fw_options[2] |= BIT_3; in qla24xx_update_fw_options()
3968 __func__, ha->fw_options[2]); in qla24xx_update_fw_options()
3971 /* Move PUREX, ABTS RX & RIDA to ATIOQ */ in qla24xx_update_fw_options()
3976 ha->fw_options[2] |= BIT_11; in qla24xx_update_fw_options()
3978 ha->fw_options[2] &= ~BIT_11; in qla24xx_update_fw_options()
3989 ha->fw_options[2] |= BIT_4; in qla24xx_update_fw_options()
3991 ha->fw_options[2] &= ~BIT_4; in qla24xx_update_fw_options()
3995 ha->fw_options[2] |= BIT_8; in qla24xx_update_fw_options()
3997 ha->fw_options[2] &= ~BIT_8; in qla24xx_update_fw_options()
4000 if (ql2xrdpenable || ha->flags.scm_supported_f) in qla24xx_update_fw_options()
4001 ha->fw_options[1] |= ADD_FO1_ENABLE_PUREX_IOCB; in qla24xx_update_fw_options()
4003 /* Enable Async 8130/8131 events -- transceiver insertion/removal */ in qla24xx_update_fw_options()
4005 ha->fw_options[3] |= BIT_10; in qla24xx_update_fw_options()
4008 "%s, add FW options 1-3 = 0x%04x 0x%04x 0x%04x mode %x\n", in qla24xx_update_fw_options()
4009 __func__, ha->fw_options[1], ha->fw_options[2], in qla24xx_update_fw_options()
4010 ha->fw_options[3], vha->host->active_mode); in qla24xx_update_fw_options()
4012 if (ha->fw_options[1] || ha->fw_options[2] || ha->fw_options[3]) in qla24xx_update_fw_options()
4013 qla2x00_set_fw_options(vha, ha->fw_options); in qla24xx_update_fw_options()
4016 if ((le16_to_cpu(ha->fw_seriallink_options24[0]) & BIT_0) == 0) in qla24xx_update_fw_options()
4020 le16_to_cpu(ha->fw_seriallink_options24[1]), in qla24xx_update_fw_options()
4021 le16_to_cpu(ha->fw_seriallink_options24[2]), in qla24xx_update_fw_options()
4022 le16_to_cpu(ha->fw_seriallink_options24[3])); in qla24xx_update_fw_options()
4032 struct qla_hw_data *ha = vha->hw; in qla2x00_config_rings()
4033 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_config_rings()
4034 struct req_que *req = ha->req_q_map[0]; in qla2x00_config_rings()
4035 struct rsp_que *rsp = ha->rsp_q_map[0]; in qla2x00_config_rings()
4038 ha->init_cb->request_q_outpointer = cpu_to_le16(0); in qla2x00_config_rings()
4039 ha->init_cb->response_q_inpointer = cpu_to_le16(0); in qla2x00_config_rings()
4040 ha->init_cb->request_q_length = cpu_to_le16(req->length); in qla2x00_config_rings()
4041 ha->init_cb->response_q_length = cpu_to_le16(rsp->length); in qla2x00_config_rings()
4042 put_unaligned_le64(req->dma, &ha->init_cb->request_q_address); in qla2x00_config_rings()
4043 put_unaligned_le64(rsp->dma, &ha->init_cb->response_q_address); in qla2x00_config_rings()
4055 struct qla_hw_data *ha = vha->hw; in qla24xx_config_rings()
4057 struct device_reg_2xxx __iomem *ioreg = &ha->iobase->isp; in qla24xx_config_rings()
4061 struct req_que *req = ha->req_q_map[0]; in qla24xx_config_rings()
4062 struct rsp_que *rsp = ha->rsp_q_map[0]; in qla24xx_config_rings()
4065 icb = (struct init_cb_24xx *)ha->init_cb; in qla24xx_config_rings()
4066 icb->request_q_outpointer = cpu_to_le16(0); in qla24xx_config_rings()
4067 icb->response_q_inpointer = cpu_to_le16(0); in qla24xx_config_rings()
4068 icb->request_q_length = cpu_to_le16(req->length); in qla24xx_config_rings()
4069 icb->response_q_length = cpu_to_le16(rsp->length); in qla24xx_config_rings()
4070 put_unaligned_le64(req->dma, &icb->request_q_address); in qla24xx_config_rings()
4071 put_unaligned_le64(rsp->dma, &icb->response_q_address); in qla24xx_config_rings()
4074 icb->atio_q_inpointer = cpu_to_le16(0); in qla24xx_config_rings()
4075 icb->atio_q_length = cpu_to_le16(ha->tgt.atio_q_length); in qla24xx_config_rings()
4076 put_unaligned_le64(ha->tgt.atio_dma, &icb->atio_q_address); in qla24xx_config_rings()
4079 icb->firmware_options_2 |= cpu_to_le32(BIT_30|BIT_29); in qla24xx_config_rings()
4081 if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha) || in qla24xx_config_rings()
4083 icb->qos = cpu_to_le16(QLA_DEFAULT_QUE_QOS); in qla24xx_config_rings()
4084 icb->rid = cpu_to_le16(rid); in qla24xx_config_rings()
4085 if (ha->flags.msix_enabled) { in qla24xx_config_rings()
4086 msix = &ha->msix_entries[1]; in qla24xx_config_rings()
4089 msix->entry); in qla24xx_config_rings()
4090 icb->msix = cpu_to_le16(msix->entry); in qla24xx_config_rings()
4094 icb->firmware_options_2 |= cpu_to_le32(BIT_19); in qla24xx_config_rings()
4097 icb->firmware_options_2 |= cpu_to_le32(BIT_18); in qla24xx_config_rings()
4100 if ((ha->fw_attributes & BIT_6) && (IS_MSIX_NACK_CAPABLE(ha)) && in qla24xx_config_rings()
4101 (ha->flags.msix_enabled)) { in qla24xx_config_rings()
4102 icb->firmware_options_2 &= cpu_to_le32(~BIT_22); in qla24xx_config_rings()
4103 ha->flags.disable_msix_handshake = 1; in qla24xx_config_rings()
4107 icb->firmware_options_2 |= cpu_to_le32(BIT_22); in qla24xx_config_rings()
4109 icb->firmware_options_2 |= cpu_to_le32(BIT_23); in qla24xx_config_rings()
4111 wrt_reg_dword(®->isp25mq.req_q_in, 0); in qla24xx_config_rings()
4112 wrt_reg_dword(®->isp25mq.req_q_out, 0); in qla24xx_config_rings()
4113 wrt_reg_dword(®->isp25mq.rsp_q_in, 0); in qla24xx_config_rings()
4114 wrt_reg_dword(®->isp25mq.rsp_q_out, 0); in qla24xx_config_rings()
4116 wrt_reg_dword(®->isp24.req_q_in, 0); in qla24xx_config_rings()
4117 wrt_reg_dword(®->isp24.req_q_out, 0); in qla24xx_config_rings()
4118 wrt_reg_dword(®->isp24.rsp_q_in, 0); in qla24xx_config_rings()
4119 wrt_reg_dword(®->isp24.rsp_q_out, 0); in qla24xx_config_rings()
4125 if (ha->set_data_rate) { in qla24xx_config_rings()
4128 qla2x00_get_link_speed_str(ha, ha->set_data_rate)); in qla24xx_config_rings()
4129 icb->firmware_options_3 = cpu_to_le32(ha->set_data_rate << 13); in qla24xx_config_rings()
4133 rd_reg_word(&ioreg->hccr); in qla24xx_config_rings()
4137 * qla2x00_init_rings() - Initializes firmware.
4151 struct qla_hw_data *ha = vha->hw; in qla2x00_init_rings()
4155 (struct mid_init_cb_24xx *) ha->init_cb; in qla2x00_init_rings()
4157 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_init_rings()
4160 for (que = 0; que < ha->max_req_queues; que++) { in qla2x00_init_rings()
4161 req = ha->req_q_map[que]; in qla2x00_init_rings()
4162 if (!req || !test_bit(que, ha->req_qid_map)) in qla2x00_init_rings()
4164 req->out_ptr = (uint16_t *)(req->ring + req->length); in qla2x00_init_rings()
4165 *req->out_ptr = 0; in qla2x00_init_rings()
4166 for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) in qla2x00_init_rings()
4167 req->outstanding_cmds[cnt] = NULL; in qla2x00_init_rings()
4169 req->current_outstanding_cmd = 1; in qla2x00_init_rings()
4172 req->ring_ptr = req->ring; in qla2x00_init_rings()
4173 req->ring_index = 0; in qla2x00_init_rings()
4174 req->cnt = req->length; in qla2x00_init_rings()
4177 for (que = 0; que < ha->max_rsp_queues; que++) { in qla2x00_init_rings()
4178 rsp = ha->rsp_q_map[que]; in qla2x00_init_rings()
4179 if (!rsp || !test_bit(que, ha->rsp_qid_map)) in qla2x00_init_rings()
4181 rsp->in_ptr = (uint16_t *)(rsp->ring + rsp->length); in qla2x00_init_rings()
4182 *rsp->in_ptr = 0; in qla2x00_init_rings()
4190 ha->tgt.atio_ring_ptr = ha->tgt.atio_ring; in qla2x00_init_rings()
4191 ha->tgt.atio_ring_index = 0; in qla2x00_init_rings()
4195 ha->isp_ops->config_rings(vha); in qla2x00_init_rings()
4197 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_init_rings()
4202 rval = qlafx00_init_firmware(vha, ha->init_cb_size); in qla2x00_init_rings()
4207 ha->isp_ops->update_fw_options(vha); in qla2x00_init_rings()
4209 if (ha->flags.npiv_supported) { in qla2x00_init_rings()
4210 if (ha->operating_mode == LOOP && !IS_CNA_CAPABLE(ha)) in qla2x00_init_rings()
4211 ha->max_npiv_vports = MIN_MULTI_ID_FABRIC - 1; in qla2x00_init_rings()
4212 mid_init_cb->count = cpu_to_le16(ha->max_npiv_vports); in qla2x00_init_rings()
4216 mid_init_cb->options = cpu_to_le16(BIT_1); in qla2x00_init_rings()
4217 mid_init_cb->init_cb.execution_throttle = in qla2x00_init_rings()
4218 cpu_to_le16(ha->cur_fw_xcb_count); in qla2x00_init_rings()
4219 ha->flags.dport_enabled = in qla2x00_init_rings()
4220 (le32_to_cpu(mid_init_cb->init_cb.firmware_options_1) & in qla2x00_init_rings()
4223 (ha->flags.dport_enabled) ? "enabled" : "disabled"); in qla2x00_init_rings()
4224 /* FA-WWPN Status */ in qla2x00_init_rings()
4225 ha->flags.fawwpn_enabled = in qla2x00_init_rings()
4226 (le32_to_cpu(mid_init_cb->init_cb.firmware_options_1) & in qla2x00_init_rings()
4228 ql_dbg(ql_dbg_init, vha, 0x00bc, "FA-WWPN Support: %s.\n", in qla2x00_init_rings()
4229 (ha->flags.fawwpn_enabled) ? "enabled" : "disabled"); in qla2x00_init_rings()
4232 rval = qla2x00_init_firmware(vha, ha->init_cb_size); in qla2x00_init_rings()
4239 "Init Firmware -- success.\n"); in qla2x00_init_rings()
4241 vha->u_ql2xexchoffld = vha->u_ql2xiniexchg = 0; in qla2x00_init_rings()
4248 * qla2x00_fw_ready() - Waits for firmware ready.
4261 struct qla_hw_data *ha = vha->hw; in qla2x00_fw_ready()
4263 if (IS_QLAFX00(vha->hw)) in qla2x00_fw_ready()
4278 if ((wait_time = (ha->retry_count*ha->login_timeout) + 5) < min_wait) { in qla2x00_fw_ready()
4289 if (!vha->flags.init_done) in qla2x00_fw_ready()
4294 memset(state, -1, sizeof(state)); in qla2x00_fw_ready()
4298 vha->device_flags &= ~DFLG_NO_CABLE; in qla2x00_fw_ready()
4319 cs84xx_time = jiffies - cs84xx_time; in qla2x00_fw_ready()
4329 "F/W Ready - OK.\n"); in qla2x00_fw_ready()
4331 qla2x00_get_retry_cnt(vha, &ha->retry_count, in qla2x00_fw_ready()
4332 &ha->login_timeout, &ha->r_a_tov); in qla2x00_fw_ready()
4340 if (atomic_read(&vha->loop_down_timer) && in qla2x00_fw_ready()
4349 vha->device_flags |= DFLG_NO_CABLE; in qla2x00_fw_ready()
4356 ha->flags.isp82xx_fw_hung) in qla2x00_fw_ready()
4371 if (rval && !(vha->device_flags & DFLG_NO_CABLE)) { in qla2x00_fw_ready()
4403 struct qla_hw_data *ha = vha->hw; in qla2x00_configure_hba()
4404 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); in qla2x00_configure_hba()
4412 if (LOOP_TRANSITION(vha) || atomic_read(&ha->loop_down_timer) || in qla2x00_configure_hba()
4427 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_configure_hba()
4434 "Cannot get topology - retrying.\n"); in qla2x00_configure_hba()
4438 vha->loop_id = loop_id; in qla2x00_configure_hba()
4441 ha->min_external_loopid = SNS_FIRST_LOOP_ID; in qla2x00_configure_hba()
4442 ha->operating_mode = LOOP; in qla2x00_configure_hba()
4443 ha->switch_cap = 0; in qla2x00_configure_hba()
4448 ha->current_topology = ISP_CFG_NL; in qla2x00_configure_hba()
4454 ha->switch_cap = sw_cap; in qla2x00_configure_hba()
4455 ha->current_topology = ISP_CFG_FL; in qla2x00_configure_hba()
4461 ha->operating_mode = P2P; in qla2x00_configure_hba()
4462 ha->current_topology = ISP_CFG_N; in qla2x00_configure_hba()
4463 strcpy(connect_type, "(N_Port-to-N_Port)"); in qla2x00_configure_hba()
4468 ha->switch_cap = sw_cap; in qla2x00_configure_hba()
4469 ha->operating_mode = P2P; in qla2x00_configure_hba()
4470 ha->current_topology = ISP_CFG_F; in qla2x00_configure_hba()
4477 ha->current_topology = ISP_CFG_NL; in qla2x00_configure_hba()
4483 /* byte order - Big Endian */ in qla2x00_configure_hba()
4488 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_configure_hba()
4489 if (!(topo == 2 && ha->flags.n2n_bigger)) in qla2x00_configure_hba()
4491 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_configure_hba()
4493 if (!vha->flags.init_done) in qla2x00_configure_hba()
4495 "Topology - %s, Host Loop address 0x%x.\n", in qla2x00_configure_hba()
4496 connect_type, vha->loop_id); in qla2x00_configure_hba()
4508 struct qla_hw_data *ha = vha->hw; in qla2x00_set_model_info()
4515 memcpy(ha->model_number, model, len); in qla2x00_set_model_info()
4516 st = en = ha->model_number; in qla2x00_set_model_info()
4517 en += len - 1; in qla2x00_set_model_info()
4521 *en-- = '\0'; in qla2x00_set_model_info()
4524 index = (ha->pdev->subsystem_device & 0xff); in qla2x00_set_model_info()
4526 ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && in qla2x00_set_model_info()
4528 strlcpy(ha->model_desc, in qla2x00_set_model_info()
4530 sizeof(ha->model_desc)); in qla2x00_set_model_info()
4532 index = (ha->pdev->subsystem_device & 0xff); in qla2x00_set_model_info()
4534 ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && in qla2x00_set_model_info()
4536 strlcpy(ha->model_number, in qla2x00_set_model_info()
4538 sizeof(ha->model_number)); in qla2x00_set_model_info()
4539 strlcpy(ha->model_desc, in qla2x00_set_model_info()
4541 sizeof(ha->model_desc)); in qla2x00_set_model_info()
4543 strlcpy(ha->model_number, def, in qla2x00_set_model_info()
4544 sizeof(ha->model_number)); in qla2x00_set_model_info()
4548 qla2xxx_get_vpd_field(vha, "\x82", ha->model_desc, in qla2x00_set_model_info()
4549 sizeof(ha->model_desc)); in qla2x00_set_model_info()
4558 struct qla_hw_data *ha = vha->hw; in qla2xxx_nvram_wwn_from_ofw()
4559 struct pci_dev *pdev = ha->pdev; in qla2xxx_nvram_wwn_from_ofw()
4564 val = of_get_property(dp, "port-wwn", &len); in qla2xxx_nvram_wwn_from_ofw()
4566 memcpy(nv->port_name, val, WWN_SIZE); in qla2xxx_nvram_wwn_from_ofw()
4568 val = of_get_property(dp, "node-wwn", &len); in qla2xxx_nvram_wwn_from_ofw()
4570 memcpy(nv->node_name, val, WWN_SIZE); in qla2xxx_nvram_wwn_from_ofw()
4594 struct qla_hw_data *ha = vha->hw; in qla2x00_nvram_config()
4595 init_cb_t *icb = ha->init_cb; in qla2x00_nvram_config()
4596 nvram_t *nv = ha->nvram; in qla2x00_nvram_config()
4597 uint8_t *ptr = ha->nvram; in qla2x00_nvram_config()
4598 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_nvram_config()
4603 ha->nvram_size = sizeof(*nv); in qla2x00_nvram_config()
4604 ha->nvram_base = 0; in qla2x00_nvram_config()
4606 if ((rd_reg_word(®->ctrl_status) >> 14) == 1) in qla2x00_nvram_config()
4607 ha->nvram_base = 0x80; in qla2x00_nvram_config()
4610 ha->isp_ops->read_nvram(vha, ptr, ha->nvram_base, ha->nvram_size); in qla2x00_nvram_config()
4611 for (cnt = 0, chksum = 0; cnt < ha->nvram_size; cnt++) in qla2x00_nvram_config()
4617 nv, ha->nvram_size); in qla2x00_nvram_config()
4620 if (chksum || memcmp("ISP ", nv->id, sizeof(nv->id)) || in qla2x00_nvram_config()
4621 nv->nvram_version < 1) { in qla2x00_nvram_config()
4625 chksum, nv->id, nv->nvram_version); in qla2x00_nvram_config()
4628 "functioning (yet invalid -- WWPN) defaults.\n"); in qla2x00_nvram_config()
4633 memset(nv, 0, ha->nvram_size); in qla2x00_nvram_config()
4634 nv->parameter_block_version = ICB_VERSION; in qla2x00_nvram_config()
4637 nv->firmware_options[0] = BIT_2 | BIT_1; in qla2x00_nvram_config()
4638 nv->firmware_options[1] = BIT_7 | BIT_5; in qla2x00_nvram_config()
4639 nv->add_firmware_options[0] = BIT_5; in qla2x00_nvram_config()
4640 nv->add_firmware_options[1] = BIT_5 | BIT_4; in qla2x00_nvram_config()
4641 nv->frame_payload_size = cpu_to_le16(2048); in qla2x00_nvram_config()
4642 nv->special_options[1] = BIT_7; in qla2x00_nvram_config()
4644 nv->firmware_options[0] = BIT_2 | BIT_1; in qla2x00_nvram_config()
4645 nv->firmware_options[1] = BIT_7 | BIT_5; in qla2x00_nvram_config()
4646 nv->add_firmware_options[0] = BIT_5; in qla2x00_nvram_config()
4647 nv->add_firmware_options[1] = BIT_5 | BIT_4; in qla2x00_nvram_config()
4648 nv->frame_payload_size = cpu_to_le16(1024); in qla2x00_nvram_config()
4650 nv->firmware_options[0] = BIT_3 | BIT_1; in qla2x00_nvram_config()
4651 nv->firmware_options[1] = BIT_5; in qla2x00_nvram_config()
4652 nv->frame_payload_size = cpu_to_le16(1024); in qla2x00_nvram_config()
4655 nv->max_iocb_allocation = cpu_to_le16(256); in qla2x00_nvram_config()
4656 nv->execution_throttle = cpu_to_le16(16); in qla2x00_nvram_config()
4657 nv->retry_count = 8; in qla2x00_nvram_config()
4658 nv->retry_delay = 1; in qla2x00_nvram_config()
4660 nv->port_name[0] = 33; in qla2x00_nvram_config()
4661 nv->port_name[3] = 224; in qla2x00_nvram_config()
4662 nv->port_name[4] = 139; in qla2x00_nvram_config()
4666 nv->login_timeout = 4; in qla2x00_nvram_config()
4671 nv->host_p[1] = BIT_2; in qla2x00_nvram_config()
4672 nv->reset_delay = 5; in qla2x00_nvram_config()
4673 nv->port_down_retry_count = 8; in qla2x00_nvram_config()
4674 nv->max_luns_per_target = cpu_to_le16(8); in qla2x00_nvram_config()
4675 nv->link_down_timeout = 60; in qla2x00_nvram_config()
4681 memset(icb, 0, ha->init_cb_size); in qla2x00_nvram_config()
4686 nv->firmware_options[0] |= (BIT_6 | BIT_1); in qla2x00_nvram_config()
4687 nv->firmware_options[0] &= ~(BIT_5 | BIT_4); in qla2x00_nvram_config()
4688 nv->firmware_options[1] |= (BIT_5 | BIT_0); in qla2x00_nvram_config()
4689 nv->firmware_options[1] &= ~BIT_4; in qla2x00_nvram_config()
4692 nv->firmware_options[0] |= BIT_2; in qla2x00_nvram_config()
4693 nv->firmware_options[0] &= ~BIT_3; in qla2x00_nvram_config()
4694 nv->special_options[0] &= ~BIT_6; in qla2x00_nvram_config()
4695 nv->add_firmware_options[1] |= BIT_5 | BIT_4; in qla2x00_nvram_config()
4698 if (ha->fb_rev == FPM_2310) { in qla2x00_nvram_config()
4699 strcpy(ha->model_number, "QLA2310"); in qla2x00_nvram_config()
4701 strcpy(ha->model_number, "QLA2300"); in qla2x00_nvram_config()
4704 qla2x00_set_model_info(vha, nv->model_number, in qla2x00_nvram_config()
4705 sizeof(nv->model_number), "QLA23xx"); in qla2x00_nvram_config()
4708 nv->firmware_options[0] |= BIT_2; in qla2x00_nvram_config()
4710 * 'Point-to-point preferred, else loop' is not a safe in qla2x00_nvram_config()
4713 if ((nv->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) == in qla2x00_nvram_config()
4715 /* Force 'loop preferred, else point-to-point'. */ in qla2x00_nvram_config()
4716 nv->add_firmware_options[0] &= ~(BIT_6 | BIT_5 | BIT_4); in qla2x00_nvram_config()
4717 nv->add_firmware_options[0] |= BIT_5; in qla2x00_nvram_config()
4719 strcpy(ha->model_number, "QLA22xx"); in qla2x00_nvram_config()
4721 strcpy(ha->model_number, "QLA2100"); in qla2x00_nvram_config()
4728 dptr2 = (uint8_t *)&nv->parameter_block_version; in qla2x00_nvram_config()
4729 cnt = (uint8_t *)&icb->request_q_outpointer - (uint8_t *)&icb->version; in qla2x00_nvram_config()
4730 while (cnt--) in qla2x00_nvram_config()
4734 dptr1 = (uint8_t *)icb->add_firmware_options; in qla2x00_nvram_config()
4735 cnt = (uint8_t *)icb->reserved_3 - (uint8_t *)icb->add_firmware_options; in qla2x00_nvram_config()
4736 while (cnt--) in qla2x00_nvram_config()
4738 ha->frame_payload_size = le16_to_cpu(icb->frame_payload_size); in qla2x00_nvram_config()
4740 if (nv->host_p[1] & BIT_7) { in qla2x00_nvram_config()
4741 memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); in qla2x00_nvram_config()
4742 memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); in qla2x00_nvram_config()
4746 if ((icb->firmware_options[1] & BIT_6) == 0) { in qla2x00_nvram_config()
4751 memcpy(icb->node_name, icb->port_name, WWN_SIZE); in qla2x00_nvram_config()
4752 icb->node_name[0] &= 0xF0; in qla2x00_nvram_config()
4760 * BIT_7 in the host-parameters section allows for modification to in qla2x00_nvram_config()
4763 if (nv->host_p[0] & BIT_7) in qla2x00_nvram_config()
4765 ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0); in qla2x00_nvram_config()
4768 ha->flags.disable_risc_code_load = 0; in qla2x00_nvram_config()
4769 ha->flags.enable_lip_reset = ((nv->host_p[1] & BIT_1) ? 1 : 0); in qla2x00_nvram_config()
4770 ha->flags.enable_lip_full_login = ((nv->host_p[1] & BIT_2) ? 1 : 0); in qla2x00_nvram_config()
4771 ha->flags.enable_target_reset = ((nv->host_p[1] & BIT_3) ? 1 : 0); in qla2x00_nvram_config()
4772 ha->flags.enable_led_scheme = (nv->special_options[1] & BIT_4) ? 1 : 0; in qla2x00_nvram_config()
4773 ha->flags.disable_serdes = 0; in qla2x00_nvram_config()
4775 ha->operating_mode = in qla2x00_nvram_config()
4776 (icb->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) >> 4; in qla2x00_nvram_config()
4778 memcpy(ha->fw_seriallink_options, nv->seriallink_options, in qla2x00_nvram_config()
4779 sizeof(ha->fw_seriallink_options)); in qla2x00_nvram_config()
4782 ha->serial0 = icb->port_name[5]; in qla2x00_nvram_config()
4783 ha->serial1 = icb->port_name[6]; in qla2x00_nvram_config()
4784 ha->serial2 = icb->port_name[7]; in qla2x00_nvram_config()
4785 memcpy(vha->node_name, icb->node_name, WWN_SIZE); in qla2x00_nvram_config()
4786 memcpy(vha->port_name, icb->port_name, WWN_SIZE); in qla2x00_nvram_config()
4788 icb->execution_throttle = cpu_to_le16(0xFFFF); in qla2x00_nvram_config()
4790 ha->retry_count = nv->retry_count; in qla2x00_nvram_config()
4793 if (nv->login_timeout != ql2xlogintimeout) in qla2x00_nvram_config()
4794 nv->login_timeout = ql2xlogintimeout; in qla2x00_nvram_config()
4795 if (nv->login_timeout < 4) in qla2x00_nvram_config()
4796 nv->login_timeout = 4; in qla2x00_nvram_config()
4797 ha->login_timeout = nv->login_timeout; in qla2x00_nvram_config()
4800 ha->r_a_tov = 100; in qla2x00_nvram_config()
4802 ha->loop_reset_delay = nv->reset_delay; in qla2x00_nvram_config()
4814 if (nv->link_down_timeout == 0) { in qla2x00_nvram_config()
4815 ha->loop_down_abort_time = in qla2x00_nvram_config()
4816 (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); in qla2x00_nvram_config()
4818 ha->link_down_timeout = nv->link_down_timeout; in qla2x00_nvram_config()
4819 ha->loop_down_abort_time = in qla2x00_nvram_config()
4820 (LOOP_DOWN_TIME - ha->link_down_timeout); in qla2x00_nvram_config()
4826 ha->port_down_retry_count = nv->port_down_retry_count; in qla2x00_nvram_config()
4828 ha->port_down_retry_count = qlport_down_retry; in qla2x00_nvram_config()
4830 ha->login_retry_count = nv->retry_count; in qla2x00_nvram_config()
4831 if (ha->port_down_retry_count == nv->port_down_retry_count && in qla2x00_nvram_config()
4832 ha->port_down_retry_count > 3) in qla2x00_nvram_config()
4833 ha->login_retry_count = ha->port_down_retry_count; in qla2x00_nvram_config()
4834 else if (ha->port_down_retry_count > (int)ha->login_retry_count) in qla2x00_nvram_config()
4835 ha->login_retry_count = ha->port_down_retry_count; in qla2x00_nvram_config()
4837 ha->login_retry_count = ql2xloginretrycount; in qla2x00_nvram_config()
4839 icb->lun_enables = cpu_to_le16(0); in qla2x00_nvram_config()
4840 icb->command_resource_count = 0; in qla2x00_nvram_config()
4841 icb->immediate_notify_resource_count = 0; in qla2x00_nvram_config()
4842 icb->timeout = cpu_to_le16(0); in qla2x00_nvram_config()
4846 icb->firmware_options[0] &= ~BIT_3; in qla2x00_nvram_config()
4847 icb->add_firmware_options[0] &= in qla2x00_nvram_config()
4849 icb->add_firmware_options[0] |= BIT_2; in qla2x00_nvram_config()
4850 icb->response_accumulation_timer = 3; in qla2x00_nvram_config()
4851 icb->interrupt_delay_timer = 5; in qla2x00_nvram_config()
4853 vha->flags.process_response_queue = 1; in qla2x00_nvram_config()
4856 if (!vha->flags.init_done) { in qla2x00_nvram_config()
4857 ha->zio_mode = icb->add_firmware_options[0] & in qla2x00_nvram_config()
4859 ha->zio_timer = icb->interrupt_delay_timer ? in qla2x00_nvram_config()
4860 icb->interrupt_delay_timer : 2; in qla2x00_nvram_config()
4862 icb->add_firmware_options[0] &= in qla2x00_nvram_config()
4864 vha->flags.process_response_queue = 0; in qla2x00_nvram_config()
4865 if (ha->zio_mode != QLA_ZIO_DISABLED) { in qla2x00_nvram_config()
4866 ha->zio_mode = QLA_ZIO_MODE_6; in qla2x00_nvram_config()
4870 ha->zio_mode, ha->zio_timer * 100); in qla2x00_nvram_config()
4872 icb->add_firmware_options[0] |= (uint8_t)ha->zio_mode; in qla2x00_nvram_config()
4873 icb->interrupt_delay_timer = (uint8_t)ha->zio_timer; in qla2x00_nvram_config()
4874 vha->flags.process_response_queue = 1; in qla2x00_nvram_config()
4892 spin_lock_irqsave(fcport->vha->host->host_lock, flags); in qla2x00_rport_del()
4893 rport = fcport->drport ? fcport->drport : fcport->rport; in qla2x00_rport_del()
4894 fcport->drport = NULL; in qla2x00_rport_del()
4895 spin_unlock_irqrestore(fcport->vha->host->host_lock, flags); in qla2x00_rport_del()
4897 ql_dbg(ql_dbg_disc, fcport->vha, 0x210b, in qla2x00_rport_del()
4899 __func__, fcport->port_name, rport, in qla2x00_rport_del()
4900 rport->roles); in qla2x00_rport_del()
4910 old_state = atomic_read(&fcport->state); in qla2x00_set_fcport_state()
4911 atomic_set(&fcport->state, state); in qla2x00_set_fcport_state()
4915 ql_dbg(ql_dbg_disc, fcport->vha, 0x207d, in qla2x00_set_fcport_state()
4916 "FCPort %8phC state transitioned from %s to %s - portid=%02x%02x%02x.\n", in qla2x00_set_fcport_state()
4917 fcport->port_name, port_state_str[old_state], in qla2x00_set_fcport_state()
4918 port_state_str[state], fcport->d_id.b.domain, in qla2x00_set_fcport_state()
4919 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_set_fcport_state()
4924 * qla2x00_alloc_fcport() - Allocate a generic fcport.
4939 fcport->ct_desc.ct_sns = dma_alloc_coherent(&vha->hw->pdev->dev, in qla2x00_alloc_fcport()
4940 sizeof(struct ct_sns_pkt), &fcport->ct_desc.ct_sns_dma, in qla2x00_alloc_fcport()
4942 if (!fcport->ct_desc.ct_sns) { in qla2x00_alloc_fcport()
4950 fcport->vha = vha; in qla2x00_alloc_fcport()
4951 fcport->port_type = FCT_UNKNOWN; in qla2x00_alloc_fcport()
4952 fcport->loop_id = FC_NO_LOOP_ID; in qla2x00_alloc_fcport()
4954 fcport->supported_classes = FC_COS_UNSPECIFIED; in qla2x00_alloc_fcport()
4955 fcport->fp_speed = PORT_SPEED_UNKNOWN; in qla2x00_alloc_fcport()
4957 fcport->disc_state = DSC_DELETED; in qla2x00_alloc_fcport()
4958 fcport->fw_login_state = DSC_LS_PORT_UNAVAIL; in qla2x00_alloc_fcport()
4959 fcport->deleted = QLA_SESS_DELETED; in qla2x00_alloc_fcport()
4960 fcport->login_retry = vha->hw->login_retry_count; in qla2x00_alloc_fcport()
4961 fcport->chip_reset = vha->hw->base_qpair->chip_reset; in qla2x00_alloc_fcport()
4962 fcport->logout_on_delete = 1; in qla2x00_alloc_fcport()
4964 if (!fcport->ct_desc.ct_sns) { in qla2x00_alloc_fcport()
4971 INIT_WORK(&fcport->del_work, qla24xx_delete_sess_fn); in qla2x00_alloc_fcport()
4972 INIT_WORK(&fcport->free_work, qlt_free_session_done); in qla2x00_alloc_fcport()
4973 INIT_WORK(&fcport->reg_work, qla_register_fcport_fn); in qla2x00_alloc_fcport()
4974 INIT_LIST_HEAD(&fcport->gnl_entry); in qla2x00_alloc_fcport()
4975 INIT_LIST_HEAD(&fcport->list); in qla2x00_alloc_fcport()
4983 if (fcport->ct_desc.ct_sns) { in qla2x00_free_fcport()
4984 dma_free_coherent(&fcport->vha->hw->pdev->dev, in qla2x00_free_fcport()
4985 sizeof(struct ct_sns_pkt), fcport->ct_desc.ct_sns, in qla2x00_free_fcport()
4986 fcport->ct_desc.ct_sns_dma); in qla2x00_free_fcport()
4988 fcport->ct_desc.ct_sns = NULL; in qla2x00_free_fcport()
4990 list_del(&fcport->list); in qla2x00_free_fcport()
4997 struct qla_hw_data *ha = vha->hw; in qla_get_login_template()
5002 memset(ha->init_cb, 0, ha->init_cb_size); in qla_get_login_template()
5003 sz = min_t(int, sizeof(struct fc_els_flogi), ha->init_cb_size); in qla_get_login_template()
5004 rval = qla24xx_get_port_login_templ(vha, ha->init_cb_dma, in qla_get_login_template()
5005 ha->init_cb, sz); in qla_get_login_template()
5011 q = (__be32 *)&ha->plogi_els_payld.fl_csp; in qla_get_login_template()
5013 bp = (uint32_t *)ha->init_cb; in qla_get_login_template()
5015 ha->flags.plogi_template_valid = 1; in qla_get_login_template()
5035 struct qla_hw_data *ha = vha->hw; in qla2x00_configure_loop()
5040 if (test_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags)) { in qla2x00_configure_loop()
5049 save_flags = flags = vha->dpc_flags; in qla2x00_configure_loop()
5051 "Configure loop -- dpc flags = 0x%lx.\n", flags); in qla2x00_configure_loop()
5057 clear_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_configure_loop()
5058 clear_bit(RSCN_UPDATE, &vha->dpc_flags); in qla2x00_configure_loop()
5064 if ((ha->current_topology == ISP_CFG_FL || in qla2x00_configure_loop()
5065 ha->current_topology == ISP_CFG_F) && in qla2x00_configure_loop()
5071 } else if (ha->current_topology == ISP_CFG_NL || in qla2x00_configure_loop()
5072 ha->current_topology == ISP_CFG_N) { in qla2x00_configure_loop()
5075 } else if (!vha->flags.online || in qla2x00_configure_loop()
5082 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { in qla2x00_configure_loop()
5101 if (atomic_read(&vha->loop_down_timer) || in qla2x00_configure_loop()
5102 test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { in qla2x00_configure_loop()
5105 atomic_set(&vha->loop_state, LOOP_READY); in qla2x00_configure_loop()
5108 ha->flags.fw_init_done = 1; in qla2x00_configure_loop()
5116 spin_lock_irqsave(&ha->tgt.atio_lock, flags); in qla2x00_configure_loop()
5118 spin_unlock_irqrestore(&ha->tgt.atio_lock, in qla2x00_configure_loop()
5133 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { in qla2x00_configure_loop()
5135 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_configure_loop()
5137 set_bit(RSCN_UPDATE, &vha->dpc_flags); in qla2x00_configure_loop()
5149 if (test_and_clear_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags)) in qla2x00_configure_n2n_loop()
5150 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla2x00_configure_n2n_loop()
5152 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_configure_n2n_loop()
5153 if (fcport->n2n_flag) { in qla2x00_configure_n2n_loop()
5159 spin_lock_irqsave(&vha->work_lock, flags); in qla2x00_configure_n2n_loop()
5160 vha->scan.scan_retry++; in qla2x00_configure_n2n_loop()
5161 spin_unlock_irqrestore(&vha->work_lock, flags); in qla2x00_configure_n2n_loop()
5163 if (vha->scan.scan_retry < MAX_SCAN_RETRIES) { in qla2x00_configure_n2n_loop()
5164 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_configure_n2n_loop()
5165 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_n2n_loop()
5192 struct qla_hw_data *ha = vha->hw; in qla2x00_configure_local_loop()
5204 memset(ha->gid_list, 0, qla2x00_gid_list_size(ha)); in qla2x00_configure_local_loop()
5205 rval = qla2x00_get_id_list(vha, ha->gid_list, ha->gid_list_dma, in qla2x00_configure_local_loop()
5213 ha->gid_list, entries * sizeof(*ha->gid_list)); in qla2x00_configure_local_loop()
5216 spin_lock_irqsave(&vha->work_lock, flags); in qla2x00_configure_local_loop()
5217 vha->scan.scan_retry++; in qla2x00_configure_local_loop()
5218 spin_unlock_irqrestore(&vha->work_lock, flags); in qla2x00_configure_local_loop()
5220 if (vha->scan.scan_retry < MAX_SCAN_RETRIES) { in qla2x00_configure_local_loop()
5221 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_configure_local_loop()
5222 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_local_loop()
5225 vha->scan.scan_retry = 0; in qla2x00_configure_local_loop()
5228 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_configure_local_loop()
5229 fcport->scan_state = QLA_FCPORT_SCAN; in qla2x00_configure_local_loop()
5240 new_fcport->flags &= ~FCF_FABRIC_DEVICE; in qla2x00_configure_local_loop()
5243 gid = ha->gid_list; in qla2x00_configure_local_loop()
5245 domain = gid->domain; in qla2x00_configure_local_loop()
5246 area = gid->area; in qla2x00_configure_local_loop()
5247 al_pa = gid->al_pa; in qla2x00_configure_local_loop()
5249 loop_id = gid->loop_id_2100; in qla2x00_configure_local_loop()
5251 loop_id = le16_to_cpu(gid->loop_id); in qla2x00_configure_local_loop()
5252 gid = (void *)gid + ha->gid_list_info_size; in qla2x00_configure_local_loop()
5259 if (area && domain && ((area != vha->d_id.b.area) || in qla2x00_configure_local_loop()
5260 (domain != vha->d_id.b.domain)) && in qla2x00_configure_local_loop()
5261 (ha->current_topology == ISP_CFG_NL)) in qla2x00_configure_local_loop()
5269 memset(new_fcport->port_name, 0, WWN_SIZE); in qla2x00_configure_local_loop()
5272 new_fcport->d_id.b.domain = domain; in qla2x00_configure_local_loop()
5273 new_fcport->d_id.b.area = area; in qla2x00_configure_local_loop()
5274 new_fcport->d_id.b.al_pa = al_pa; in qla2x00_configure_local_loop()
5275 new_fcport->loop_id = loop_id; in qla2x00_configure_local_loop()
5276 new_fcport->scan_state = QLA_FCPORT_FOUND; in qla2x00_configure_local_loop()
5282 "-- get_port_database=%x, loop_id=0x%04x.\n", in qla2x00_configure_local_loop()
5283 rval2, new_fcport->loop_id); in qla2x00_configure_local_loop()
5285 if (ha->current_topology != ISP_CFG_N) { in qla2x00_configure_local_loop()
5288 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_local_loop()
5293 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla2x00_configure_local_loop()
5297 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_configure_local_loop()
5298 if (memcmp(new_fcport->port_name, fcport->port_name, in qla2x00_configure_local_loop()
5302 fcport->flags &= ~FCF_FABRIC_DEVICE; in qla2x00_configure_local_loop()
5303 fcport->loop_id = new_fcport->loop_id; in qla2x00_configure_local_loop()
5304 fcport->port_type = new_fcport->port_type; in qla2x00_configure_local_loop()
5305 fcport->d_id.b24 = new_fcport->d_id.b24; in qla2x00_configure_local_loop()
5306 memcpy(fcport->node_name, new_fcport->node_name, in qla2x00_configure_local_loop()
5308 fcport->scan_state = QLA_FCPORT_FOUND; in qla2x00_configure_local_loop()
5315 list_add_tail(&new_fcport->list, &vha->vp_fcports); in qla2x00_configure_local_loop()
5320 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla2x00_configure_local_loop()
5330 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla2x00_configure_local_loop()
5331 new_fcport->flags &= ~FCF_FABRIC_DEVICE; in qla2x00_configure_local_loop()
5334 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla2x00_configure_local_loop()
5337 fcport->fp_speed = ha->link_data_rate; in qla2x00_configure_local_loop()
5342 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_configure_local_loop()
5343 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_configure_local_loop()
5346 if (fcport->scan_state == QLA_FCPORT_SCAN) { in qla2x00_configure_local_loop()
5349 atomic_read(&fcport->state) == FCS_ONLINE) { in qla2x00_configure_local_loop()
5352 if (fcport->loop_id != FC_NO_LOOP_ID && in qla2x00_configure_local_loop()
5353 (fcport->flags & FCF_FCP2_DEVICE) == 0 && in qla2x00_configure_local_loop()
5354 fcport->port_type != FCT_INITIATOR && in qla2x00_configure_local_loop()
5355 fcport->port_type != FCT_BROADCAST) { in qla2x00_configure_local_loop()
5359 fcport->port_name); in qla2x00_configure_local_loop()
5367 if (fcport->scan_state == QLA_FCPORT_FOUND) in qla2x00_configure_local_loop()
5386 struct qla_hw_data *ha = vha->hw; in qla2x00_iidma_fcport()
5391 if (atomic_read(&fcport->state) != FCS_ONLINE) in qla2x00_iidma_fcport()
5394 if (fcport->fp_speed == PORT_SPEED_UNKNOWN || in qla2x00_iidma_fcport()
5395 fcport->fp_speed > ha->link_data_rate || in qla2x00_iidma_fcport()
5396 !ha->flags.gpsc_supported) in qla2x00_iidma_fcport()
5399 rval = qla2x00_set_idma_speed(vha, fcport->loop_id, fcport->fp_speed, in qla2x00_iidma_fcport()
5403 "Unable to adjust iIDMA %8phN -- %04x %x %04x %04x.\n", in qla2x00_iidma_fcport()
5404 fcport->port_name, rval, fcport->fp_speed, mb[0], mb[1]); in qla2x00_iidma_fcport()
5408 qla2x00_get_link_speed_str(ha, fcport->fp_speed), in qla2x00_iidma_fcport()
5409 fcport->fp_speed, fcport->port_name); in qla2x00_iidma_fcport()
5427 e->u.fcport.fcport = fcport; in qla_post_iidma_work()
5439 if (atomic_read(&fcport->state) == FCS_ONLINE) in qla2x00_reg_remote_port()
5442 rport_ids.node_name = wwn_to_u64(fcport->node_name); in qla2x00_reg_remote_port()
5443 rport_ids.port_name = wwn_to_u64(fcport->port_name); in qla2x00_reg_remote_port()
5444 rport_ids.port_id = fcport->d_id.b.domain << 16 | in qla2x00_reg_remote_port()
5445 fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; in qla2x00_reg_remote_port()
5447 fcport->rport = rport = fc_remote_port_add(vha->host, 0, &rport_ids); in qla2x00_reg_remote_port()
5454 spin_lock_irqsave(fcport->vha->host->host_lock, flags); in qla2x00_reg_remote_port()
5455 *((fc_port_t **)rport->dd_data) = fcport; in qla2x00_reg_remote_port()
5456 spin_unlock_irqrestore(fcport->vha->host->host_lock, flags); in qla2x00_reg_remote_port()
5458 rport->supported_classes = fcport->supported_classes; in qla2x00_reg_remote_port()
5461 if (fcport->port_type == FCT_INITIATOR) in qla2x00_reg_remote_port()
5463 if (fcport->port_type == FCT_TARGET) in qla2x00_reg_remote_port()
5465 if (fcport->port_type & FCT_NVME_INITIATOR) in qla2x00_reg_remote_port()
5467 if (fcport->port_type & FCT_NVME_TARGET) in qla2x00_reg_remote_port()
5469 if (fcport->port_type & FCT_NVME_DISCOVERY) in qla2x00_reg_remote_port()
5474 __func__, fcport->port_name, rport, in qla2x00_reg_remote_port()
5475 (fcport->port_type == FCT_TARGET) ? "tgt" : in qla2x00_reg_remote_port()
5476 ((fcport->port_type & FCT_NVME) ? "nvme" : "ini")); in qla2x00_reg_remote_port()
5490 * 0 - Success
5491 * BIT_0 - error
5499 if (IS_SW_RESV_ADDR(fcport->d_id)) in qla2x00_update_fcport()
5503 __func__, fcport->port_name); in qla2x00_update_fcport()
5506 fcport->login_retry = vha->hw->login_retry_count; in qla2x00_update_fcport()
5507 fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); in qla2x00_update_fcport()
5508 fcport->deleted = 0; in qla2x00_update_fcport()
5509 if (vha->hw->current_topology == ISP_CFG_NL) in qla2x00_update_fcport()
5510 fcport->logout_on_delete = 0; in qla2x00_update_fcport()
5512 fcport->logout_on_delete = 1; in qla2x00_update_fcport()
5513 fcport->n2n_chip_reset = fcport->n2n_link_reset_cnt = 0; in qla2x00_update_fcport()
5515 switch (vha->hw->current_topology) { in qla2x00_update_fcport()
5518 fcport->keep_nport_handle = 1; in qla2x00_update_fcport()
5528 if (NVME_TARGET(vha->hw, fcport)) { in qla2x00_update_fcport()
5537 switch (vha->host->active_mode) { in qla2x00_update_fcport()
5542 if (!vha->vha_tgt.qla_tgt->tgt_stop && in qla2x00_update_fcport()
5543 !vha->vha_tgt.qla_tgt->tgt_stopped) in qla2x00_update_fcport()
5548 if (!vha->vha_tgt.qla_tgt->tgt_stop && in qla2x00_update_fcport()
5549 !vha->vha_tgt.qla_tgt->tgt_stopped) in qla2x00_update_fcport()
5558 if (IS_IIDMA_CAPABLE(vha->hw) && vha->hw->flags.gpsc_supported) { in qla2x00_update_fcport()
5559 if (fcport->id_changed) { in qla2x00_update_fcport()
5560 fcport->id_changed = 0; in qla2x00_update_fcport()
5563 __func__, __LINE__, fcport->port_name, in qla2x00_update_fcport()
5564 vha->fcport_count); in qla2x00_update_fcport()
5569 __func__, __LINE__, fcport->port_name, in qla2x00_update_fcport()
5570 vha->fcport_count); in qla2x00_update_fcport()
5581 u32 rscn_gen = fcport->rscn_gen; in qla_register_fcport_fn()
5584 if (IS_SW_RESV_ADDR(fcport->d_id)) in qla_register_fcport_fn()
5587 qla2x00_update_fcport(fcport->vha, fcport); in qla_register_fcport_fn()
5589 if (rscn_gen != fcport->rscn_gen) { in qla_register_fcport_fn()
5591 switch (fcport->next_disc_state) { in qla_register_fcport_fn()
5597 qla2x00_post_async_adisc_work(fcport->vha, fcport, in qla_register_fcport_fn()
5625 struct qla_hw_data *ha = vha->hw; in qla2x00_configure_fabric()
5633 rval = qla2x00_get_port_name(vha, loop_id, vha->fabric_node_name, 1); in qla2x00_configure_fabric()
5638 vha->device_flags &= ~SWITCH_FOUND; in qla2x00_configure_fabric()
5641 vha->device_flags |= SWITCH_FOUND; in qla2x00_configure_fabric()
5643 rval = qla2x00_get_port_name(vha, loop_id, vha->fabric_port_name, 0); in qla2x00_configure_fabric()
5661 rval = ha->isp_ops->fabric_login(vha, loop_id, 0xff, 0xff, in qla2x00_configure_fabric()
5667 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_fabric()
5673 test_and_clear_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags)) in qla2x00_configure_fabric()
5676 if (test_and_clear_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags)) { in qla2x00_configure_fabric()
5680 "Register FC-4 TYPE failed.\n"); in qla2x00_configure_fabric()
5682 &vha->dpc_flags)) in qla2x00_configure_fabric()
5688 "Register FC-4 Features failed.\n"); in qla2x00_configure_fabric()
5690 &vha->dpc_flags)) in qla2x00_configure_fabric()
5693 if (vha->flags.nvme_enabled) { in qla2x00_configure_fabric()
5704 &vha->dpc_flags)) in qla2x00_configure_fabric()
5710 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_configure_fabric()
5719 * disconnected port might have re-connected and a brand new in qla2x00_configure_fabric()
5728 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_configure_fabric()
5730 list_for_each_entry(fcport, &vha->vp_fcports, list) in qla2x00_configure_fabric()
5731 fcport->scan_state = QLA_FCPORT_SCAN; in qla2x00_configure_fabric()
5739 if (!vha->nvme_local_port && vha->flags.nvme_enabled) in qla2x00_configure_fabric()
5774 struct qla_hw_data *ha = vha->hw; in qla2x00_find_all_fabric_devs()
5775 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); in qla2x00_find_all_fabric_devs()
5781 if (!ha->swl) in qla2x00_find_all_fabric_devs()
5782 ha->swl = kcalloc(ha->max_fibre_devices, sizeof(sw_info_t), in qla2x00_find_all_fabric_devs()
5784 swl = ha->swl; in qla2x00_find_all_fabric_devs()
5790 memset(swl, 0, ha->max_fibre_devices * sizeof(sw_info_t)); in qla2x00_find_all_fabric_devs()
5793 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
5797 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
5801 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
5805 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
5809 /* If other queries succeeded probe for FC-4 type */ in qla2x00_find_all_fabric_devs()
5812 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
5825 new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); in qla2x00_find_all_fabric_devs()
5831 loop_id = ha->min_external_loopid; in qla2x00_find_all_fabric_devs()
5832 for (; loop_id <= ha->max_loop_id; loop_id++) { in qla2x00_find_all_fabric_devs()
5836 if (ha->current_topology == ISP_CFG_FL && in qla2x00_find_all_fabric_devs()
5837 (atomic_read(&vha->loop_down_timer) || in qla2x00_find_all_fabric_devs()
5839 atomic_set(&vha->loop_down_timer, 0); in qla2x00_find_all_fabric_devs()
5840 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_find_all_fabric_devs()
5841 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_find_all_fabric_devs()
5847 wrap.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
5849 new_fcport->d_id.b24 = swl[swl_idx].d_id.b24; in qla2x00_find_all_fabric_devs()
5850 memcpy(new_fcport->node_name, in qla2x00_find_all_fabric_devs()
5852 memcpy(new_fcport->port_name, in qla2x00_find_all_fabric_devs()
5854 memcpy(new_fcport->fabric_port_name, in qla2x00_find_all_fabric_devs()
5856 new_fcport->fp_speed = swl[swl_idx].fp_speed; in qla2x00_find_all_fabric_devs()
5857 new_fcport->fc4_type = swl[swl_idx].fc4_type; in qla2x00_find_all_fabric_devs()
5859 new_fcport->nvme_flag = 0; in qla2x00_find_all_fabric_devs()
5860 if (vha->flags.nvme_enabled && in qla2x00_find_all_fabric_devs()
5864 new_fcport->port_name); in qla2x00_find_all_fabric_devs()
5877 "SNS scan failed -- assuming " in qla2x00_find_all_fabric_devs()
5878 "zero-entry result.\n"); in qla2x00_find_all_fabric_devs()
5886 wrap.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
5888 } else if (new_fcport->d_id.b24 == wrap.b24) { in qla2x00_find_all_fabric_devs()
5891 new_fcport->d_id.b.domain, in qla2x00_find_all_fabric_devs()
5892 new_fcport->d_id.b.area, in qla2x00_find_all_fabric_devs()
5893 new_fcport->d_id.b.al_pa); in qla2x00_find_all_fabric_devs()
5898 if (new_fcport->d_id.b24 == base_vha->d_id.b24) in qla2x00_find_all_fabric_devs()
5902 if (qla2x00_is_a_vp_did(vha, new_fcport->d_id.b24)) in qla2x00_find_all_fabric_devs()
5906 if (((new_fcport->d_id.b24 & 0xffff00) == in qla2x00_find_all_fabric_devs()
5907 (vha->d_id.b24 & 0xffff00)) && ha->current_topology == in qla2x00_find_all_fabric_devs()
5912 if ((new_fcport->d_id.b.domain & 0xf0) == 0xf0) in qla2x00_find_all_fabric_devs()
5915 /* Bypass ports whose FCP-4 type is not FCP_SCSI */ in qla2x00_find_all_fabric_devs()
5917 (!(new_fcport->fc4_type & FS_FC4TYPE_FCP) && in qla2x00_find_all_fabric_devs()
5918 new_fcport->fc4_type != 0)) in qla2x00_find_all_fabric_devs()
5921 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla2x00_find_all_fabric_devs()
5925 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_find_all_fabric_devs()
5926 if (memcmp(new_fcport->port_name, fcport->port_name, in qla2x00_find_all_fabric_devs()
5930 fcport->scan_state = QLA_FCPORT_FOUND; in qla2x00_find_all_fabric_devs()
5935 memcpy(fcport->fabric_port_name, in qla2x00_find_all_fabric_devs()
5936 new_fcport->fabric_port_name, WWN_SIZE); in qla2x00_find_all_fabric_devs()
5937 fcport->fp_speed = new_fcport->fp_speed; in qla2x00_find_all_fabric_devs()
5943 if (fcport->d_id.b24 == new_fcport->d_id.b24 && in qla2x00_find_all_fabric_devs()
5944 (atomic_read(&fcport->state) == FCS_ONLINE || in qla2x00_find_all_fabric_devs()
5945 (vha->host->active_mode == MODE_TARGET))) { in qla2x00_find_all_fabric_devs()
5952 if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) { in qla2x00_find_all_fabric_devs()
5953 fcport->d_id.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
5955 fcport->flags |= (FCF_FABRIC_DEVICE | in qla2x00_find_all_fabric_devs()
5968 " old %x:%x:%x (loop_id 0x%04x)-> new %x:%x:%x\n", in qla2x00_find_all_fabric_devs()
5969 fcport->port_name, in qla2x00_find_all_fabric_devs()
5970 fcport->d_id.b.domain, in qla2x00_find_all_fabric_devs()
5971 fcport->d_id.b.area, in qla2x00_find_all_fabric_devs()
5972 fcport->d_id.b.al_pa, in qla2x00_find_all_fabric_devs()
5973 fcport->loop_id, in qla2x00_find_all_fabric_devs()
5974 new_fcport->d_id.b.domain, in qla2x00_find_all_fabric_devs()
5975 new_fcport->d_id.b.area, in qla2x00_find_all_fabric_devs()
5976 new_fcport->d_id.b.al_pa); in qla2x00_find_all_fabric_devs()
5977 fcport->d_id.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
5981 fcport->d_id.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
5982 fcport->flags |= FCF_LOGIN_NEEDED; in qla2x00_find_all_fabric_devs()
5986 if (found && NVME_TARGET(vha->hw, fcport)) { in qla2x00_find_all_fabric_devs()
5987 if (fcport->disc_state == DSC_DELETE_PEND) { in qla2x00_find_all_fabric_devs()
5989 vha->fcport_count--; in qla2x00_find_all_fabric_devs()
5990 fcport->login_succ = 0; in qla2x00_find_all_fabric_devs()
5995 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla2x00_find_all_fabric_devs()
5999 new_fcport->scan_state = QLA_FCPORT_FOUND; in qla2x00_find_all_fabric_devs()
6000 list_add_tail(&new_fcport->list, &vha->vp_fcports); in qla2x00_find_all_fabric_devs()
6002 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla2x00_find_all_fabric_devs()
6006 nxt_d_id.b24 = new_fcport->d_id.b24; in qla2x00_find_all_fabric_devs()
6013 new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); in qla2x00_find_all_fabric_devs()
6014 new_fcport->d_id.b24 = nxt_d_id.b24; in qla2x00_find_all_fabric_devs()
6022 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_find_all_fabric_devs()
6023 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qla2x00_find_all_fabric_devs()
6026 if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) in qla2x00_find_all_fabric_devs()
6029 if (fcport->scan_state == QLA_FCPORT_SCAN) { in qla2x00_find_all_fabric_devs()
6032 atomic_read(&fcport->state) == FCS_ONLINE) { in qla2x00_find_all_fabric_devs()
6035 if (fcport->loop_id != FC_NO_LOOP_ID && in qla2x00_find_all_fabric_devs()
6036 (fcport->flags & FCF_FCP2_DEVICE) == 0 && in qla2x00_find_all_fabric_devs()
6037 fcport->port_type != FCT_INITIATOR && in qla2x00_find_all_fabric_devs()
6038 fcport->port_type != FCT_BROADCAST) { in qla2x00_find_all_fabric_devs()
6042 fcport->port_name); in qla2x00_find_all_fabric_devs()
6049 if (fcport->scan_state == QLA_FCPORT_FOUND && in qla2x00_find_all_fabric_devs()
6050 (fcport->flags & FCF_LOGIN_NEEDED) != 0) in qla2x00_find_all_fabric_devs()
6061 int lid = NPH_MGMT_SERVER - vha->vp_idx; in qla2x00_reserve_mgmt_server_loop_id()
6063 struct qla_hw_data *ha = vha->hw; in qla2x00_reserve_mgmt_server_loop_id()
6065 if (vha->vp_idx == 0) { in qla2x00_reserve_mgmt_server_loop_id()
6066 set_bit(NPH_MGMT_SERVER, ha->loop_id_map); in qla2x00_reserve_mgmt_server_loop_id()
6071 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_reserve_mgmt_server_loop_id()
6072 for (; lid > 0; lid--) { in qla2x00_reserve_mgmt_server_loop_id()
6073 if (!test_bit(lid, vha->hw->loop_id_map)) { in qla2x00_reserve_mgmt_server_loop_id()
6074 set_bit(lid, vha->hw->loop_id_map); in qla2x00_reserve_mgmt_server_loop_id()
6079 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_reserve_mgmt_server_loop_id()
6093 * 0 - Login successfully
6094 * 1 - Login failed
6095 * 2 - Initiator device
6096 * 3 - Fatal error
6106 struct qla_hw_data *ha = vha->hw; in qla2x00_fabric_login()
6115 fcport->loop_id, fcport->d_id.b.domain, in qla2x00_fabric_login()
6116 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_fabric_login()
6119 rval = ha->isp_ops->fabric_login(vha, fcport->loop_id, in qla2x00_fabric_login()
6120 fcport->d_id.b.domain, fcport->d_id.b.area, in qla2x00_fabric_login()
6121 fcport->d_id.b.al_pa, mb, BIT_0); in qla2x00_fabric_login()
6134 tmp_loopid = fcport->loop_id; in qla2x00_fabric_login()
6135 fcport->loop_id = mb[1]; in qla2x00_fabric_login()
6138 "Fabric Login: port in use - next loop " in qla2x00_fabric_login()
6140 fcport->loop_id, fcport->d_id.b.domain, in qla2x00_fabric_login()
6141 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_fabric_login()
6155 *next_loopid = (fcport->loop_id + 1); in qla2x00_fabric_login()
6159 fcport->port_type = FCT_INITIATOR; in qla2x00_fabric_login()
6161 fcport->port_type = FCT_TARGET; in qla2x00_fabric_login()
6163 fcport->flags |= FCF_FCP2_DEVICE; in qla2x00_fabric_login()
6168 fcport->supported_classes |= FC_COS_CLASS2; in qla2x00_fabric_login()
6170 fcport->supported_classes |= FC_COS_CLASS3; in qla2x00_fabric_login()
6174 fcport->flags |= in qla2x00_fabric_login()
6184 fcport->loop_id++; in qla2x00_fabric_login()
6196 *next_loopid = fcport->loop_id; in qla2x00_fabric_login()
6197 ha->isp_ops->fabric_logout(vha, fcport->loop_id, in qla2x00_fabric_login()
6198 fcport->d_id.b.domain, fcport->d_id.b.area, in qla2x00_fabric_login()
6199 fcport->d_id.b.al_pa); in qla2x00_fabric_login()
6210 "jiffies=%lx.\n", mb[0], fcport->d_id.b.domain, in qla2x00_fabric_login()
6211 fcport->d_id.b.area, fcport->d_id.b.al_pa, in qla2x00_fabric_login()
6212 fcport->loop_id, jiffies); in qla2x00_fabric_login()
6214 *next_loopid = fcport->loop_id; in qla2x00_fabric_login()
6215 ha->isp_ops->fabric_logout(vha, fcport->loop_id, in qla2x00_fabric_login()
6216 fcport->d_id.b.domain, fcport->d_id.b.area, in qla2x00_fabric_login()
6217 fcport->d_id.b.al_pa); in qla2x00_fabric_login()
6219 fcport->login_retry = 0; in qla2x00_fabric_login()
6238 * 0 - Login successfully
6239 * 1 - Login failed
6240 * 3 - Fatal error
6278 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_loop_resync()
6279 if (vha->flags.online) { in qla2x00_loop_resync()
6284 if (!IS_QLAFX00(vha->hw)) { in qla2x00_loop_resync()
6289 qla2x00_marker(vha, vha->hw->base_qpair, in qla2x00_loop_resync()
6291 vha->marker_needed = 0; in qla2x00_loop_resync()
6295 clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_loop_resync()
6297 if (IS_QLAFX00(vha->hw)) in qla2x00_loop_resync()
6302 wait_time--; in qla2x00_loop_resync()
6303 } while (!atomic_read(&vha->loop_down_timer) && in qla2x00_loop_resync()
6304 !(test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) in qla2x00_loop_resync()
6306 &vha->dpc_flags))); in qla2x00_loop_resync()
6310 if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) in qla2x00_loop_resync()
6332 if (!test_and_set_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags)) { in qla2x00_perform_loop_resync()
6334 atomic_set(&ha->loop_down_timer, 0); in qla2x00_perform_loop_resync()
6335 if (!(ha->device_flags & DFLG_NO_CABLE)) { in qla2x00_perform_loop_resync()
6336 atomic_set(&ha->loop_state, LOOP_UP); in qla2x00_perform_loop_resync()
6337 set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); in qla2x00_perform_loop_resync()
6338 set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags); in qla2x00_perform_loop_resync()
6339 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); in qla2x00_perform_loop_resync()
6343 atomic_set(&ha->loop_state, LOOP_DEAD); in qla2x00_perform_loop_resync()
6345 clear_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags); in qla2x00_perform_loop_resync()
6356 struct qla_hw_data *ha = base_vha->hw; in qla2x00_update_fcports()
6359 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_update_fcports()
6361 list_for_each_entry(vha, &base_vha->hw->vp_list, list) { in qla2x00_update_fcports()
6362 atomic_inc(&vha->vref_count); in qla2x00_update_fcports()
6363 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_update_fcports()
6364 if (fcport->drport && in qla2x00_update_fcports()
6365 atomic_read(&fcport->state) != FCS_UNCONFIGURED) { in qla2x00_update_fcports()
6366 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_update_fcports()
6369 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_update_fcports()
6372 atomic_dec(&vha->vref_count); in qla2x00_update_fcports()
6373 wake_up(&vha->vref_waitq); in qla2x00_update_fcports()
6375 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_update_fcports()
6382 struct qla_hw_data *ha = vha->hw; in qla83xx_reset_ownership()
6403 (i != ha->portnum)) { in qla83xx_reset_ownership()
6413 ((i + 8) != ha->portnum)) { in qla83xx_reset_ownership()
6420 * Prepare drv-presence mask based on fcoe functions present. in qla83xx_reset_ownership()
6421 * However consider only valid physical fcoe function numbers (0-15). in qla83xx_reset_ownership()
6423 drv_presence_mask = ~((1 << (ha->portnum)) | in qla83xx_reset_ownership()
6428 * - No other protocol drivers present. in qla83xx_reset_ownership()
6429 * - This is the lowest among fcoe functions. */ in qla83xx_reset_ownership()
6431 (ha->portnum < fcoe_other_function)) { in qla83xx_reset_ownership()
6434 ha->flags.nic_core_reset_owner = 1; in qla83xx_reset_ownership()
6442 struct qla_hw_data *ha = vha->hw; in __qla83xx_set_drv_ack()
6447 drv_ack |= (1 << ha->portnum); in __qla83xx_set_drv_ack()
6458 struct qla_hw_data *ha = vha->hw; in __qla83xx_clear_drv_ack()
6463 drv_ack &= ~(1 << ha->portnum); in __qla83xx_clear_drv_ack()
6475 return "COLD/RE-INIT"; in qla83xx_dev_state_to_string()
6493 /* Assumes idc-lock always held on entry */
6497 struct qla_hw_data *ha = vha->hw; in qla83xx_idc_audit()
6502 ha->idc_audit_ts = (jiffies_to_msecs(jiffies) / 1000); in qla83xx_idc_audit()
6503 idc_audit_reg = (ha->portnum) | in qla83xx_idc_audit()
6504 (IDC_AUDIT_TIMESTAMP << 7) | (ha->idc_audit_ts << 8); in qla83xx_idc_audit()
6509 duration_secs = ((jiffies_to_msecs(jiffies) - in qla83xx_idc_audit()
6510 jiffies_to_msecs(ha->idc_audit_ts)) / 1000); in qla83xx_idc_audit()
6511 idc_audit_reg = (ha->portnum) | in qla83xx_idc_audit()
6527 struct qla_hw_data *ha = vha->hw; in qla83xx_initiating_reset()
6533 "NIC Core reset has been disabled. idc-control=0x%x\n", in qla83xx_initiating_reset()
6538 /* Set NEED-RESET iff in READY state and we are the reset-owner */ in qla83xx_initiating_reset()
6540 if (ha->flags.nic_core_reset_owner && dev_state == QLA8XXX_DEV_READY) { in qla83xx_initiating_reset()
6551 /* Wait for IDC state change READY -> NEED_RESET */ in qla83xx_initiating_reset()
6560 /* Send IDC ack by writing to drv-ack register */ in qla83xx_initiating_reset()
6582 struct qla_hw_data *ha = vha->hw; in qla83xx_check_driver_presence()
6585 if (drv_presence & (1 << ha->portnum)) in qla83xx_check_driver_presence()
6595 struct qla_hw_data *ha = vha->hw; in qla83xx_nic_core_reset()
6600 if (vha->device_flags & DFLG_DEV_FAILED) { in qla83xx_nic_core_reset()
6611 ha->portnum); in qla83xx_nic_core_reset()
6621 * Perform reset if we are the reset-owner, in qla83xx_nic_core_reset()
6628 ha->flags.nic_core_hung = 0; in qla83xx_nic_core_reset()
6643 struct qla_hw_data *ha = vha->hw; in qla2xxx_mctp_dump()
6653 if (!ha->mctp_dump) { in qla2xxx_mctp_dump()
6654 ha->mctp_dump = dma_alloc_coherent(&ha->pdev->dev, in qla2xxx_mctp_dump()
6655 MCTP_DUMP_SIZE, &ha->mctp_dump_dma, GFP_KERNEL); in qla2xxx_mctp_dump()
6657 if (!ha->mctp_dump) { in qla2xxx_mctp_dump()
6665 rval = qla2x00_dump_mctp_data(vha, ha->mctp_dump_dma, in qla2xxx_mctp_dump()
6673 vha->host_no, ha->mctp_dump); in qla2xxx_mctp_dump()
6674 ha->mctp_dumped = 1; in qla2xxx_mctp_dump()
6677 if (!ha->flags.nic_core_reset_hdlr_active && !ha->portnum) { in qla2xxx_mctp_dump()
6678 ha->flags.nic_core_reset_hdlr_active = 1; in qla2xxx_mctp_dump()
6687 ha->flags.nic_core_reset_hdlr_active = 0; in qla2xxx_mctp_dump()
6705 struct qla_hw_data *ha = vha->hw; in qla2x00_quiesce_io()
6709 "Quiescing I/O - ha=%p.\n", ha); in qla2x00_quiesce_io()
6711 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); in qla2x00_quiesce_io()
6712 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { in qla2x00_quiesce_io()
6713 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_quiesce_io()
6715 list_for_each_entry(vp, &ha->vp_list, list) in qla2x00_quiesce_io()
6718 if (!atomic_read(&vha->loop_down_timer)) in qla2x00_quiesce_io()
6719 atomic_set(&vha->loop_down_timer, in qla2x00_quiesce_io()
6730 struct qla_hw_data *ha = vha->hw; in qla2x00_abort_isp_cleanup()
6740 vha->flags.online = 0; in qla2x00_abort_isp_cleanup()
6741 ha->flags.chip_reset_done = 0; in qla2x00_abort_isp_cleanup()
6742 clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_abort_isp_cleanup()
6743 vha->qla_stats.total_isp_aborts++; in qla2x00_abort_isp_cleanup()
6746 "Performing ISP error recovery - ha=%p.\n", ha); in qla2x00_abort_isp_cleanup()
6748 ha->flags.purge_mbox = 1; in qla2x00_abort_isp_cleanup()
6754 ha->isp_ops->reset_chip(vha); in qla2x00_abort_isp_cleanup()
6756 ha->link_data_rate = PORT_SPEED_UNKNOWN; in qla2x00_abort_isp_cleanup()
6758 ha->flags.rida_fmt2 = 0; in qla2x00_abort_isp_cleanup()
6759 ha->flags.n2n_ae = 0; in qla2x00_abort_isp_cleanup()
6760 ha->flags.lip_ae = 0; in qla2x00_abort_isp_cleanup()
6761 ha->current_topology = 0; in qla2x00_abort_isp_cleanup()
6763 ha->flags.fw_init_done = 0; in qla2x00_abort_isp_cleanup()
6764 ha->chip_reset++; in qla2x00_abort_isp_cleanup()
6765 ha->base_qpair->chip_reset = ha->chip_reset; in qla2x00_abort_isp_cleanup()
6766 for (i = 0; i < ha->max_qpairs; i++) { in qla2x00_abort_isp_cleanup()
6767 if (ha->queue_pair_map[i]) in qla2x00_abort_isp_cleanup()
6768 ha->queue_pair_map[i]->chip_reset = in qla2x00_abort_isp_cleanup()
6769 ha->base_qpair->chip_reset; in qla2x00_abort_isp_cleanup()
6773 if (atomic_read(&ha->num_pend_mbx_stage3)) { in qla2x00_abort_isp_cleanup()
6774 clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); in qla2x00_abort_isp_cleanup()
6775 complete(&ha->mbx_intr_comp); in qla2x00_abort_isp_cleanup()
6779 while (atomic_read(&ha->num_pend_mbx_stage3) || in qla2x00_abort_isp_cleanup()
6780 atomic_read(&ha->num_pend_mbx_stage2) || in qla2x00_abort_isp_cleanup()
6781 atomic_read(&ha->num_pend_mbx_stage1)) { in qla2x00_abort_isp_cleanup()
6787 ha->flags.purge_mbox = 0; in qla2x00_abort_isp_cleanup()
6789 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); in qla2x00_abort_isp_cleanup()
6790 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { in qla2x00_abort_isp_cleanup()
6791 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_abort_isp_cleanup()
6794 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6795 list_for_each_entry(vp, &ha->vp_list, list) { in qla2x00_abort_isp_cleanup()
6796 atomic_inc(&vp->vref_count); in qla2x00_abort_isp_cleanup()
6797 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6801 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6802 atomic_dec(&vp->vref_count); in qla2x00_abort_isp_cleanup()
6804 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6806 if (!atomic_read(&vha->loop_down_timer)) in qla2x00_abort_isp_cleanup()
6807 atomic_set(&vha->loop_down_timer, in qla2x00_abort_isp_cleanup()
6812 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qla2x00_abort_isp_cleanup()
6813 fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); in qla2x00_abort_isp_cleanup()
6814 fcport->scan_state = 0; in qla2x00_abort_isp_cleanup()
6816 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6817 list_for_each_entry(vp, &ha->vp_list, list) { in qla2x00_abort_isp_cleanup()
6818 atomic_inc(&vp->vref_count); in qla2x00_abort_isp_cleanup()
6819 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6821 list_for_each_entry(fcport, &vp->vp_fcports, list) in qla2x00_abort_isp_cleanup()
6822 fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); in qla2x00_abort_isp_cleanup()
6824 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6825 atomic_dec(&vp->vref_count); in qla2x00_abort_isp_cleanup()
6827 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp_cleanup()
6829 if (!ha->flags.eeh_busy) { in qla2x00_abort_isp_cleanup()
6839 vha->flags.online = 0; in qla2x00_abort_isp_cleanup()
6864 struct qla_hw_data *ha = vha->hw; in qla2x00_abort_isp()
6866 struct req_que *req = ha->req_q_map[0]; in qla2x00_abort_isp()
6869 if (vha->flags.online) { in qla2x00_abort_isp()
6872 if (test_and_clear_bit(ISP_ABORT_TO_ROM, &vha->dpc_flags)) { in qla2x00_abort_isp()
6873 ha->flags.chip_reset_done = 1; in qla2x00_abort_isp()
6874 vha->flags.online = 1; in qla2x00_abort_isp()
6876 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_abort_isp()
6885 "Error while clearing DRV-Presence.\n"); in qla2x00_abort_isp()
6888 if (unlikely(pci_channel_offline(ha->pdev) && in qla2x00_abort_isp()
6889 ha->flags.pci_channel_io_perm_failure)) { in qla2x00_abort_isp()
6890 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_abort_isp()
6895 switch (vha->qlini_mode) { in qla2x00_abort_isp()
6909 ha->isp_ops->get_flash_version(vha, req->ring); in qla2x00_abort_isp()
6911 ha->isp_ops->nvram_config(vha); in qla2x00_abort_isp()
6914 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla2x00_abort_isp()
6916 if (!atomic_read(&vha->loop_down_timer)) { in qla2x00_abort_isp()
6921 vha->marker_needed = 1; in qla2x00_abort_isp()
6924 vha->flags.online = 1; in qla2x00_abort_isp()
6926 ha->isp_ops->enable_intrs(ha); in qla2x00_abort_isp()
6928 ha->isp_abort_cnt = 0; in qla2x00_abort_isp()
6929 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_abort_isp()
6933 if (ha->fce) { in qla2x00_abort_isp()
6934 ha->flags.fce_enabled = 1; in qla2x00_abort_isp()
6935 memset(ha->fce, 0, in qla2x00_abort_isp()
6936 fce_calc_size(ha->fce_bufs)); in qla2x00_abort_isp()
6938 ha->fce_dma, ha->fce_bufs, ha->fce_mb, in qla2x00_abort_isp()
6939 &ha->fce_bufs); in qla2x00_abort_isp()
6944 ha->flags.fce_enabled = 0; in qla2x00_abort_isp()
6948 if (ha->eft) { in qla2x00_abort_isp()
6949 memset(ha->eft, 0, EFT_SIZE); in qla2x00_abort_isp()
6951 ha->eft_dma, EFT_NUM_BUFFERS); in qla2x00_abort_isp()
6959 vha->flags.online = 1; in qla2x00_abort_isp()
6960 if (test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { in qla2x00_abort_isp()
6961 if (ha->isp_abort_cnt == 0) { in qla2x00_abort_isp()
6963 "ISP error recover failed - " in qla2x00_abort_isp()
6970 vha->flags.online = 0; in qla2x00_abort_isp()
6972 &vha->dpc_flags); in qla2x00_abort_isp()
6975 ha->isp_abort_cnt--; in qla2x00_abort_isp()
6977 "ISP abort - retry remaining %d.\n", in qla2x00_abort_isp()
6978 ha->isp_abort_cnt); in qla2x00_abort_isp()
6982 ha->isp_abort_cnt = MAX_RETRIES_OF_ISP_ABORT; in qla2x00_abort_isp()
6984 "ISP error recovery - retrying (%d) " in qla2x00_abort_isp()
6985 "more times.\n", ha->isp_abort_cnt); in qla2x00_abort_isp()
6986 set_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla2x00_abort_isp()
6996 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp()
6997 list_for_each_entry(vp, &ha->vp_list, list) { in qla2x00_abort_isp()
6998 if (vp->vp_idx) { in qla2x00_abort_isp()
6999 atomic_inc(&vp->vref_count); in qla2x00_abort_isp()
7000 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp()
7004 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_abort_isp()
7005 atomic_dec(&vp->vref_count); in qla2x00_abort_isp()
7008 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_abort_isp()
7015 "Error while setting DRV-Presence.\n"); in qla2x00_abort_isp()
7039 struct qla_hw_data *ha = vha->hw; in qla2x00_restart_isp()
7043 vha->flags.online = 0; in qla2x00_restart_isp()
7044 status = ha->isp_ops->chip_diag(vha); in qla2x00_restart_isp()
7056 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla2x00_restart_isp()
7057 ha->flags.chip_reset_done = 1; in qla2x00_restart_isp()
7065 return vha->device_flags & DFLG_NO_CABLE ? 0 : status; in qla2x00_restart_isp()
7069 qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL); in qla2x00_restart_isp()
7070 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_restart_isp()
7080 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); in qla25xx_init_queues()
7081 int ret = -1; in qla25xx_init_queues()
7084 for (i = 1; i < ha->max_rsp_queues; i++) { in qla25xx_init_queues()
7085 rsp = ha->rsp_q_map[i]; in qla25xx_init_queues()
7086 if (rsp && test_bit(i, ha->rsp_qid_map)) { in qla25xx_init_queues()
7087 rsp->options &= ~BIT_0; in qla25xx_init_queues()
7092 __func__, rsp->id); in qla25xx_init_queues()
7096 __func__, rsp->id); in qla25xx_init_queues()
7099 for (i = 1; i < ha->max_req_queues; i++) { in qla25xx_init_queues()
7100 req = ha->req_q_map[i]; in qla25xx_init_queues()
7101 if (req && test_bit(i, ha->req_qid_map)) { in qla25xx_init_queues()
7103 req->options &= ~BIT_0; in qla25xx_init_queues()
7108 __func__, req->id); in qla25xx_init_queues()
7112 __func__, req->id); in qla25xx_init_queues()
7129 struct qla_hw_data *ha = vha->hw; in qla2x00_reset_adapter()
7130 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_reset_adapter()
7132 vha->flags.online = 0; in qla2x00_reset_adapter()
7133 ha->isp_ops->disable_intrs(ha); in qla2x00_reset_adapter()
7135 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_reset_adapter()
7136 wrt_reg_word(®->hccr, HCCR_RESET_RISC); in qla2x00_reset_adapter()
7137 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_adapter()
7138 wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); in qla2x00_reset_adapter()
7139 rd_reg_word(®->hccr); /* PCI Posting. */ in qla2x00_reset_adapter()
7140 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_reset_adapter()
7149 struct qla_hw_data *ha = vha->hw; in qla24xx_reset_adapter()
7150 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla24xx_reset_adapter()
7155 vha->flags.online = 0; in qla24xx_reset_adapter()
7156 ha->isp_ops->disable_intrs(ha); in qla24xx_reset_adapter()
7158 spin_lock_irqsave(&ha->hardware_lock, flags); in qla24xx_reset_adapter()
7159 wrt_reg_dword(®->hccr, HCCRX_SET_RISC_RESET); in qla24xx_reset_adapter()
7160 rd_reg_dword(®->hccr); in qla24xx_reset_adapter()
7161 wrt_reg_dword(®->hccr, HCCRX_REL_RISC_PAUSE); in qla24xx_reset_adapter()
7162 rd_reg_dword(®->hccr); in qla24xx_reset_adapter()
7163 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_reset_adapter()
7166 ha->isp_ops->enable_intrs(ha); in qla24xx_reset_adapter()
7178 struct qla_hw_data *ha = vha->hw; in qla24xx_nvram_wwn_from_ofw()
7179 struct pci_dev *pdev = ha->pdev; in qla24xx_nvram_wwn_from_ofw()
7184 val = of_get_property(dp, "port-wwn", &len); in qla24xx_nvram_wwn_from_ofw()
7186 memcpy(nv->port_name, val, WWN_SIZE); in qla24xx_nvram_wwn_from_ofw()
7188 val = of_get_property(dp, "node-wwn", &len); in qla24xx_nvram_wwn_from_ofw()
7190 memcpy(nv->node_name, val, WWN_SIZE); in qla24xx_nvram_wwn_from_ofw()
7204 struct qla_hw_data *ha = vha->hw; in qla24xx_nvram_config()
7207 icb = (struct init_cb_24xx *)ha->init_cb; in qla24xx_nvram_config()
7208 nv = ha->nvram; in qla24xx_nvram_config()
7211 if (ha->port_no == 0) { in qla24xx_nvram_config()
7212 ha->nvram_base = FA_NVRAM_FUNC0_ADDR; in qla24xx_nvram_config()
7213 ha->vpd_base = FA_NVRAM_VPD0_ADDR; in qla24xx_nvram_config()
7215 ha->nvram_base = FA_NVRAM_FUNC1_ADDR; in qla24xx_nvram_config()
7216 ha->vpd_base = FA_NVRAM_VPD1_ADDR; in qla24xx_nvram_config()
7219 ha->nvram_size = sizeof(*nv); in qla24xx_nvram_config()
7220 ha->vpd_size = FA_NVRAM_VPD_SIZE; in qla24xx_nvram_config()
7223 ha->vpd = ha->nvram + VPD_OFFSET; in qla24xx_nvram_config()
7224 ha->isp_ops->read_nvram(vha, ha->vpd, in qla24xx_nvram_config()
7225 ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4); in qla24xx_nvram_config()
7229 ha->isp_ops->read_nvram(vha, dptr, ha->nvram_base, ha->nvram_size); in qla24xx_nvram_config()
7230 for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++, dptr++) in qla24xx_nvram_config()
7236 nv, ha->nvram_size); in qla24xx_nvram_config()
7239 if (chksum || memcmp("ISP ", nv->id, sizeof(nv->id)) || in qla24xx_nvram_config()
7240 le16_to_cpu(nv->nvram_version) < ICB_VERSION) { in qla24xx_nvram_config()
7244 chksum, nv->id, nv->nvram_version); in qla24xx_nvram_config()
7247 "Falling back to functioning (yet invalid -- WWPN) " in qla24xx_nvram_config()
7253 memset(nv, 0, ha->nvram_size); in qla24xx_nvram_config()
7254 nv->nvram_version = cpu_to_le16(ICB_VERSION); in qla24xx_nvram_config()
7255 nv->version = cpu_to_le16(ICB_VERSION); in qla24xx_nvram_config()
7256 nv->frame_payload_size = cpu_to_le16(2048); in qla24xx_nvram_config()
7257 nv->execution_throttle = cpu_to_le16(0xFFFF); in qla24xx_nvram_config()
7258 nv->exchange_count = cpu_to_le16(0); in qla24xx_nvram_config()
7259 nv->hard_address = cpu_to_le16(124); in qla24xx_nvram_config()
7260 nv->port_name[0] = 0x21; in qla24xx_nvram_config()
7261 nv->port_name[1] = 0x00 + ha->port_no + 1; in qla24xx_nvram_config()
7262 nv->port_name[2] = 0x00; in qla24xx_nvram_config()
7263 nv->port_name[3] = 0xe0; in qla24xx_nvram_config()
7264 nv->port_name[4] = 0x8b; in qla24xx_nvram_config()
7265 nv->port_name[5] = 0x1c; in qla24xx_nvram_config()
7266 nv->port_name[6] = 0x55; in qla24xx_nvram_config()
7267 nv->port_name[7] = 0x86; in qla24xx_nvram_config()
7268 nv->node_name[0] = 0x20; in qla24xx_nvram_config()
7269 nv->node_name[1] = 0x00; in qla24xx_nvram_config()
7270 nv->node_name[2] = 0x00; in qla24xx_nvram_config()
7271 nv->node_name[3] = 0xe0; in qla24xx_nvram_config()
7272 nv->node_name[4] = 0x8b; in qla24xx_nvram_config()
7273 nv->node_name[5] = 0x1c; in qla24xx_nvram_config()
7274 nv->node_name[6] = 0x55; in qla24xx_nvram_config()
7275 nv->node_name[7] = 0x86; in qla24xx_nvram_config()
7277 nv->login_retry_count = cpu_to_le16(8); in qla24xx_nvram_config()
7278 nv->interrupt_delay_timer = cpu_to_le16(0); in qla24xx_nvram_config()
7279 nv->login_timeout = cpu_to_le16(0); in qla24xx_nvram_config()
7280 nv->firmware_options_1 = in qla24xx_nvram_config()
7282 nv->firmware_options_2 = cpu_to_le32(2 << 4); in qla24xx_nvram_config()
7283 nv->firmware_options_2 |= cpu_to_le32(BIT_12); in qla24xx_nvram_config()
7284 nv->firmware_options_3 = cpu_to_le32(2 << 13); in qla24xx_nvram_config()
7285 nv->host_p = cpu_to_le32(BIT_11|BIT_10); in qla24xx_nvram_config()
7286 nv->efi_parameters = cpu_to_le32(0); in qla24xx_nvram_config()
7287 nv->reset_delay = 5; in qla24xx_nvram_config()
7288 nv->max_luns_per_target = cpu_to_le16(128); in qla24xx_nvram_config()
7289 nv->port_down_retry_count = cpu_to_le16(30); in qla24xx_nvram_config()
7290 nv->link_down_timeout = cpu_to_le16(30); in qla24xx_nvram_config()
7297 nv->firmware_options_1 &= cpu_to_le32(~BIT_13); in qla24xx_nvram_config()
7299 nv->host_p &= cpu_to_le32(~BIT_10); in qla24xx_nvram_config()
7305 memset(icb, 0, ha->init_cb_size); in qla24xx_nvram_config()
7309 dptr2 = (uint8_t *)&nv->version; in qla24xx_nvram_config()
7310 cnt = (uint8_t *)&icb->response_q_inpointer - (uint8_t *)&icb->version; in qla24xx_nvram_config()
7311 while (cnt--) in qla24xx_nvram_config()
7314 icb->login_retry_count = nv->login_retry_count; in qla24xx_nvram_config()
7315 icb->link_down_on_nos = nv->link_down_on_nos; in qla24xx_nvram_config()
7318 dptr1 = (uint8_t *)&icb->interrupt_delay_timer; in qla24xx_nvram_config()
7319 dptr2 = (uint8_t *)&nv->interrupt_delay_timer; in qla24xx_nvram_config()
7320 cnt = (uint8_t *)&icb->reserved_3 - in qla24xx_nvram_config()
7321 (uint8_t *)&icb->interrupt_delay_timer; in qla24xx_nvram_config()
7322 while (cnt--) in qla24xx_nvram_config()
7324 ha->frame_payload_size = le16_to_cpu(icb->frame_payload_size); in qla24xx_nvram_config()
7328 qla2x00_set_model_info(vha, nv->model_name, sizeof(nv->model_name), in qla24xx_nvram_config()
7333 if (nv->host_p & cpu_to_le32(BIT_15)) { in qla24xx_nvram_config()
7335 memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); in qla24xx_nvram_config()
7336 memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); in qla24xx_nvram_config()
7340 if ((icb->firmware_options_1 & cpu_to_le32(BIT_14)) == 0) { in qla24xx_nvram_config()
7345 memcpy(icb->node_name, icb->port_name, WWN_SIZE); in qla24xx_nvram_config()
7346 icb->node_name[0] &= 0xF0; in qla24xx_nvram_config()
7350 ha->flags.disable_risc_code_load = 0; in qla24xx_nvram_config()
7351 ha->flags.enable_lip_reset = 0; in qla24xx_nvram_config()
7352 ha->flags.enable_lip_full_login = in qla24xx_nvram_config()
7353 le32_to_cpu(nv->host_p) & BIT_10 ? 1 : 0; in qla24xx_nvram_config()
7354 ha->flags.enable_target_reset = in qla24xx_nvram_config()
7355 le32_to_cpu(nv->host_p) & BIT_11 ? 1 : 0; in qla24xx_nvram_config()
7356 ha->flags.enable_led_scheme = 0; in qla24xx_nvram_config()
7357 ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1 : 0; in qla24xx_nvram_config()
7359 ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) & in qla24xx_nvram_config()
7362 memcpy(ha->fw_seriallink_options24, nv->seriallink_options, in qla24xx_nvram_config()
7363 sizeof(ha->fw_seriallink_options24)); in qla24xx_nvram_config()
7366 ha->serial0 = icb->port_name[5]; in qla24xx_nvram_config()
7367 ha->serial1 = icb->port_name[6]; in qla24xx_nvram_config()
7368 ha->serial2 = icb->port_name[7]; in qla24xx_nvram_config()
7369 memcpy(vha->node_name, icb->node_name, WWN_SIZE); in qla24xx_nvram_config()
7370 memcpy(vha->port_name, icb->port_name, WWN_SIZE); in qla24xx_nvram_config()
7372 icb->execution_throttle = cpu_to_le16(0xFFFF); in qla24xx_nvram_config()
7374 ha->retry_count = le16_to_cpu(nv->login_retry_count); in qla24xx_nvram_config()
7377 if (le16_to_cpu(nv->login_timeout) < ql2xlogintimeout) in qla24xx_nvram_config()
7378 nv->login_timeout = cpu_to_le16(ql2xlogintimeout); in qla24xx_nvram_config()
7379 if (le16_to_cpu(nv->login_timeout) < 4) in qla24xx_nvram_config()
7380 nv->login_timeout = cpu_to_le16(4); in qla24xx_nvram_config()
7381 ha->login_timeout = le16_to_cpu(nv->login_timeout); in qla24xx_nvram_config()
7384 ha->r_a_tov = 100; in qla24xx_nvram_config()
7386 ha->loop_reset_delay = nv->reset_delay; in qla24xx_nvram_config()
7398 if (le16_to_cpu(nv->link_down_timeout) == 0) { in qla24xx_nvram_config()
7399 ha->loop_down_abort_time = in qla24xx_nvram_config()
7400 (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); in qla24xx_nvram_config()
7402 ha->link_down_timeout = le16_to_cpu(nv->link_down_timeout); in qla24xx_nvram_config()
7403 ha->loop_down_abort_time = in qla24xx_nvram_config()
7404 (LOOP_DOWN_TIME - ha->link_down_timeout); in qla24xx_nvram_config()
7408 ha->port_down_retry_count = le16_to_cpu(nv->port_down_retry_count); in qla24xx_nvram_config()
7410 ha->port_down_retry_count = qlport_down_retry; in qla24xx_nvram_config()
7413 ha->login_retry_count = le16_to_cpu(nv->login_retry_count); in qla24xx_nvram_config()
7414 if (ha->port_down_retry_count == in qla24xx_nvram_config()
7415 le16_to_cpu(nv->port_down_retry_count) && in qla24xx_nvram_config()
7416 ha->port_down_retry_count > 3) in qla24xx_nvram_config()
7417 ha->login_retry_count = ha->port_down_retry_count; in qla24xx_nvram_config()
7418 else if (ha->port_down_retry_count > (int)ha->login_retry_count) in qla24xx_nvram_config()
7419 ha->login_retry_count = ha->port_down_retry_count; in qla24xx_nvram_config()
7421 ha->login_retry_count = ql2xloginretrycount; in qla24xx_nvram_config()
7424 icb->firmware_options_3 |= cpu_to_le32(BIT_8); in qla24xx_nvram_config()
7427 if (!vha->flags.init_done) { in qla24xx_nvram_config()
7428 ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & in qla24xx_nvram_config()
7430 ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? in qla24xx_nvram_config()
7431 le16_to_cpu(icb->interrupt_delay_timer) : 2; in qla24xx_nvram_config()
7433 icb->firmware_options_2 &= cpu_to_le32( in qla24xx_nvram_config()
7435 if (ha->zio_mode != QLA_ZIO_DISABLED) { in qla24xx_nvram_config()
7436 ha->zio_mode = QLA_ZIO_MODE_6; in qla24xx_nvram_config()
7440 ha->zio_mode, ha->zio_timer * 100); in qla24xx_nvram_config()
7442 icb->firmware_options_2 |= cpu_to_le32( in qla24xx_nvram_config()
7443 (uint32_t)ha->zio_mode); in qla24xx_nvram_config()
7444 icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer); in qla24xx_nvram_config()
7461 image_status->image_status_mask, in qla27xx_print_image()
7462 le16_to_cpu(image_status->generation), in qla27xx_print_image()
7463 image_status->ver_major, in qla27xx_print_image()
7464 image_status->ver_minor, in qla27xx_print_image()
7465 image_status->bitmap, in qla27xx_print_image()
7466 le32_to_cpu(image_status->checksum), in qla27xx_print_image()
7467 le32_to_cpu(image_status->signature)); in qla27xx_print_image()
7474 ulong signature = le32_to_cpu(image_status->signature); in qla28xx_check_aux_image_status_signature()
7482 ulong signature = le32_to_cpu(image_status->signature); in qla27xx_check_image_status_signature()
7496 for ( ; n--; p++) in qla27xx_image_status_checksum()
7505 return aux->bitmap & bitmask ? in qla28xx_component_bitmask()
7513 active_regions->aux.board_config = in qla28xx_component_status()
7516 active_regions->aux.vpd_nvram = in qla28xx_component_status()
7519 active_regions->aux.npiv_config_0_1 = in qla28xx_component_status()
7522 active_regions->aux.npiv_config_2_3 = in qla28xx_component_status()
7533 le16_to_cpu(pri_image_status->generation) - in qla27xx_compare_image_generation()
7534 le16_to_cpu(sec_image_status->generation); in qla27xx_compare_image_generation()
7545 struct qla_hw_data *ha = vha->hw; in qla28xx_get_aux_images()
7550 if (!ha->flt_region_aux_img_status_pri) { in qla28xx_get_aux_images()
7556 ha->flt_region_aux_img_status_pri, in qla28xx_get_aux_images()
7582 if (!ha->flt_region_aux_img_status_sec) { in qla28xx_get_aux_images()
7589 ha->flt_region_aux_img_status_sec, in qla28xx_get_aux_images()
7633 active_regions->aux.board_config, in qla28xx_get_aux_images()
7634 active_regions->aux.vpd_nvram, in qla28xx_get_aux_images()
7635 active_regions->aux.npiv_config_0_1, in qla28xx_get_aux_images()
7636 active_regions->aux.npiv_config_2_3); in qla28xx_get_aux_images()
7643 struct qla_hw_data *ha = vha->hw; in qla27xx_get_active_image()
7648 if (!ha->flt_region_img_status_pri) { in qla27xx_get_active_image()
7654 ha->flt_region_img_status_pri, sizeof(pri_image_status) >> 2) != in qla27xx_get_active_image()
7683 if (!ha->flt_region_img_status_sec) { in qla27xx_get_active_image()
7689 ha->flt_region_img_status_sec, sizeof(sec_image_status) >> 2); in qla27xx_get_active_image()
7715 active_regions->global = QLA27XX_PRIMARY_IMAGE; in qla27xx_get_active_image()
7718 if (!active_regions->global || in qla27xx_get_active_image()
7721 active_regions->global = QLA27XX_SECONDARY_IMAGE; in qla27xx_get_active_image()
7726 active_regions->global == QLA27XX_DEFAULT_IMAGE ? in qla27xx_get_active_image()
7728 active_regions->global == QLA27XX_PRIMARY_IMAGE ? in qla27xx_get_active_image()
7730 active_regions->global == QLA27XX_SECONDARY_IMAGE ? in qla27xx_get_active_image()
7732 active_regions->global); in qla27xx_get_active_image()
7753 struct qla_hw_data *ha = vha->hw; in qla24xx_load_risc_flash()
7754 struct req_que *req = ha->req_q_map[0]; in qla24xx_load_risc_flash()
7755 struct fwdt *fwdt = ha->fwdt; in qla24xx_load_risc_flash()
7760 dcode = (uint32_t *)req->ring; in qla24xx_load_risc_flash()
7773 dcode = (uint32_t *)req->ring; in qla24xx_load_risc_flash()
7778 "-> Loading segment %u...\n", j); in qla24xx_load_risc_flash()
7787 dlen = ha->fw_transfer_size >> 2; in qla24xx_load_risc_flash()
7793 "-> Loading fragment %u: %#x <- %#x (%#lx dwords)...\n", in qla24xx_load_risc_flash()
7799 rval = qla2x00_load_ram(vha, req->dma, risc_addr, dlen); in qla24xx_load_risc_flash()
7802 "-> Failed load firmware fragment %u.\n", in qla24xx_load_risc_flash()
7809 risc_size -= dlen; in qla24xx_load_risc_flash()
7817 ql_dbg(ql_dbg_init, vha, 0x0160, "-> templates = %u\n", templates); in qla24xx_load_risc_flash()
7819 if (fwdt->template) in qla24xx_load_risc_flash()
7820 vfree(fwdt->template); in qla24xx_load_risc_flash()
7821 fwdt->template = NULL; in qla24xx_load_risc_flash()
7822 fwdt->length = 0; in qla24xx_load_risc_flash()
7824 dcode = (uint32_t *)req->ring; in qla24xx_load_risc_flash()
7828 "-> fwdt%u template array at %#x (%#x dwords)\n", in qla24xx_load_risc_flash()
7832 "-> fwdt%u failed to read array\n", j); in qla24xx_load_risc_flash()
7838 risc_size -= 8; in qla24xx_load_risc_flash()
7841 "-> fwdt%u template allocate template %#x words...\n", in qla24xx_load_risc_flash()
7843 fwdt->template = vmalloc(risc_size * sizeof(*dcode)); in qla24xx_load_risc_flash()
7844 if (!fwdt->template) { in qla24xx_load_risc_flash()
7846 "-> fwdt%u failed allocate template.\n", j); in qla24xx_load_risc_flash()
7850 dcode = fwdt->template; in qla24xx_load_risc_flash()
7855 "-> fwdt%u failed template validate\n", j); in qla24xx_load_risc_flash()
7861 "-> fwdt%u template size %#lx bytes (%#lx words)\n", in qla24xx_load_risc_flash()
7865 "-> fwdt%u template exceeds array (%-lu bytes)\n", in qla24xx_load_risc_flash()
7866 j, dlen - risc_size * sizeof(*dcode)); in qla24xx_load_risc_flash()
7870 fwdt->length = dlen; in qla24xx_load_risc_flash()
7872 "-> fwdt%u loaded template ok\n", j); in qla24xx_load_risc_flash()
7880 if (fwdt->template) in qla24xx_load_risc_flash()
7881 vfree(fwdt->template); in qla24xx_load_risc_flash()
7882 fwdt->template = NULL; in qla24xx_load_risc_flash()
7883 fwdt->length = 0; in qla24xx_load_risc_flash()
7899 struct qla_hw_data *ha = vha->hw; in qla2x00_load_risc()
7900 struct req_que *req = ha->req_q_map[0]; in qla2x00_load_risc()
7914 wcode = (uint16_t *)req->ring; in qla2x00_load_risc()
7916 fwcode = (__force __be16 *)blob->fw->data; in qla2x00_load_risc()
7920 if (blob->fw->size < 8 * sizeof(uint16_t)) { in qla2x00_load_risc()
7923 blob->fw->size); in qla2x00_load_risc()
7939 seg = blob->segs; in qla2x00_load_risc()
7947 if (blob->fw->size < fwclen) { in qla2x00_load_risc()
7950 "(%zd).\n", blob->fw->size); in qla2x00_load_risc()
7956 wlen = (uint16_t)(ha->fw_transfer_size >> 1); in qla2x00_load_risc()
7966 rval = qla2x00_load_ram(vha, req->dma, risc_addr, in qla2x00_load_risc()
7977 risc_size -= wlen; in qla2x00_load_risc()
8002 struct qla_hw_data *ha = vha->hw; in qla24xx_load_risc_blob()
8003 struct req_que *req = ha->req_q_map[0]; in qla24xx_load_risc_blob()
8004 struct fwdt *fwdt = ha->fwdt; in qla24xx_load_risc_blob()
8007 "-> FW: Loading via request-firmware.\n"); in qla24xx_load_risc_blob()
8012 "-> Firmware file not found.\n"); in qla24xx_load_risc_blob()
8017 fwcode = (__force __be32 *)blob->fw->data; in qla24xx_load_risc_blob()
8022 blob->fw->size); in qla24xx_load_risc_blob()
8029 dcode = (uint32_t *)req->ring; in qla24xx_load_risc_blob()
8034 "-> Loading segment %u...\n", j); in qla24xx_load_risc_blob()
8043 dlen = ha->fw_transfer_size >> 2; in qla24xx_load_risc_blob()
8049 "-> Loading fragment %u: %#x <- %#x (%#lx words)...\n", in qla24xx_load_risc_blob()
8051 (uint32_t)(fwcode - (typeof(fwcode))blob->fw->data), in qla24xx_load_risc_blob()
8057 rval = qla2x00_load_ram(vha, req->dma, risc_addr, dlen); in qla24xx_load_risc_blob()
8060 "-> Failed load firmware fragment %u.\n", in qla24xx_load_risc_blob()
8067 risc_size -= dlen; in qla24xx_load_risc_blob()
8075 ql_dbg(ql_dbg_init, vha, 0x0170, "-> templates = %u\n", templates); in qla24xx_load_risc_blob()
8077 if (fwdt->template) in qla24xx_load_risc_blob()
8078 vfree(fwdt->template); in qla24xx_load_risc_blob()
8079 fwdt->template = NULL; in qla24xx_load_risc_blob()
8080 fwdt->length = 0; in qla24xx_load_risc_blob()
8084 "-> fwdt%u template array at %#x (%#x dwords)\n", in qla24xx_load_risc_blob()
8085 j, (uint32_t)((void *)fwcode - (void *)blob->fw->data), in qla24xx_load_risc_blob()
8089 "-> fwdt%u failed to read array\n", j); in qla24xx_load_risc_blob()
8095 risc_size -= 8; in qla24xx_load_risc_blob()
8098 "-> fwdt%u template allocate template %#x words...\n", in qla24xx_load_risc_blob()
8100 fwdt->template = vmalloc(risc_size * sizeof(*dcode)); in qla24xx_load_risc_blob()
8101 if (!fwdt->template) { in qla24xx_load_risc_blob()
8103 "-> fwdt%u failed allocate template.\n", j); in qla24xx_load_risc_blob()
8107 dcode = fwdt->template; in qla24xx_load_risc_blob()
8113 "-> fwdt%u failed template validate\n", j); in qla24xx_load_risc_blob()
8119 "-> fwdt%u template size %#lx bytes (%#lx words)\n", in qla24xx_load_risc_blob()
8123 "-> fwdt%u template exceeds array (%-lu bytes)\n", in qla24xx_load_risc_blob()
8124 j, dlen - risc_size * sizeof(*dcode)); in qla24xx_load_risc_blob()
8128 fwdt->length = dlen; in qla24xx_load_risc_blob()
8130 "-> fwdt%u loaded template ok\n", j); in qla24xx_load_risc_blob()
8138 if (fwdt->template) in qla24xx_load_risc_blob()
8139 vfree(fwdt->template); in qla24xx_load_risc_blob()
8140 fwdt->template = NULL; in qla24xx_load_risc_blob()
8141 fwdt->length = 0; in qla24xx_load_risc_blob()
8156 * 1) Firmware via request-firmware interface (.bin file). in qla24xx_load_risc()
8164 vha->hw->flt_region_fw); in qla24xx_load_risc()
8171 struct qla_hw_data *ha = vha->hw; in qla81xx_load_risc()
8179 * 2) Firmware via request-firmware interface (.bin file). in qla81xx_load_risc()
8180 * 3) Golden-Firmware residing in flash -- (limited operation). in qla81xx_load_risc()
8193 rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_fw_sec); in qla81xx_load_risc()
8200 rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_fw); in qla81xx_load_risc()
8206 if (!rval || !ha->flt_region_gold_fw) in qla81xx_load_risc()
8211 rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_gold_fw); in qla81xx_load_risc()
8216 ha->flags.running_gold_fw = 1; in qla81xx_load_risc()
8224 struct qla_hw_data *ha = vha->hw; in qla2x00_try_to_stop_firmware()
8226 if (ha->flags.pci_channel_io_perm_failure) in qla2x00_try_to_stop_firmware()
8230 if (!ha->fw_major_version) in qla2x00_try_to_stop_firmware()
8232 if (!ha->flags.fw_started) in qla2x00_try_to_stop_firmware()
8237 ret != QLA_INVALID_COMMAND && retries ; retries--) { in qla2x00_try_to_stop_firmware()
8238 ha->isp_ops->reset_chip(vha); in qla2x00_try_to_stop_firmware()
8239 if (ha->isp_ops->chip_diag(vha) != QLA_SUCCESS) in qla2x00_try_to_stop_firmware()
8244 "Attempting retry of stop-firmware command.\n"); in qla2x00_try_to_stop_firmware()
8249 ha->flags.fw_init_done = 0; in qla2x00_try_to_stop_firmware()
8258 struct qla_hw_data *ha = vha->hw; in qla24xx_configure_vhba()
8259 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); in qla24xx_configure_vhba()
8261 if (!vha->vp_idx) in qla24xx_configure_vhba()
8262 return -EINVAL; in qla24xx_configure_vhba()
8267 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla24xx_configure_vhba()
8268 qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL); in qla24xx_configure_vhba()
8271 vha->flags.management_server_logged_in = 0; in qla24xx_configure_vhba()
8274 rval2 = ha->isp_ops->fabric_login(vha, NPH_SNS, 0xff, 0xff, 0xfc, mb, in qla24xx_configure_vhba()
8289 atomic_set(&vha->loop_down_timer, 0); in qla24xx_configure_vhba()
8290 atomic_set(&vha->loop_state, LOOP_UP); in qla24xx_configure_vhba()
8291 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla24xx_configure_vhba()
8292 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla24xx_configure_vhba()
8307 struct qla_hw_data *ha = vha->hw; in qla84xx_get_chip()
8313 if (cs84xx->bus == ha->pdev->bus) { in qla84xx_get_chip()
8314 kref_get(&cs84xx->kref); in qla84xx_get_chip()
8323 kref_init(&cs84xx->kref); in qla84xx_get_chip()
8324 spin_lock_init(&cs84xx->access_lock); in qla84xx_get_chip()
8325 mutex_init(&cs84xx->fw_update_mutex); in qla84xx_get_chip()
8326 cs84xx->bus = ha->pdev->bus; in qla84xx_get_chip()
8328 list_add_tail(&cs84xx->list, &qla_cs84xx_list); in qla84xx_get_chip()
8341 list_del(&cs84xx->list); in __qla84xx_chip_release()
8349 struct qla_hw_data *ha = vha->hw; in qla84xx_put_chip()
8351 if (ha->cs84xx) in qla84xx_put_chip()
8352 kref_put(&ha->cs84xx->kref, __qla84xx_chip_release); in qla84xx_put_chip()
8360 struct qla_hw_data *ha = vha->hw; in qla84xx_init_chip()
8362 mutex_lock(&ha->cs84xx->fw_update_mutex); in qla84xx_init_chip()
8366 mutex_unlock(&ha->cs84xx->fw_update_mutex); in qla84xx_init_chip()
8384 struct qla_hw_data *ha = vha->hw; in qla81xx_nvram_config()
8389 icb = (struct init_cb_81xx *)ha->init_cb; in qla81xx_nvram_config()
8390 nv = ha->nvram; in qla81xx_nvram_config()
8393 ha->nvram_size = sizeof(*nv); in qla81xx_nvram_config()
8394 ha->vpd_size = FA_NVRAM_VPD_SIZE; in qla81xx_nvram_config()
8396 ha->vpd_size = FA_VPD_SIZE_82XX; in qla81xx_nvram_config()
8402 ha->vpd = ha->nvram + VPD_OFFSET; in qla81xx_nvram_config()
8404 faddr = ha->flt_region_vpd; in qla81xx_nvram_config()
8407 faddr = ha->flt_region_vpd_sec; in qla81xx_nvram_config()
8413 ha->isp_ops->read_optrom(vha, ha->vpd, faddr << 2, ha->vpd_size); in qla81xx_nvram_config()
8416 faddr = ha->flt_region_nvram; in qla81xx_nvram_config()
8419 faddr = ha->flt_region_nvram_sec; in qla81xx_nvram_config()
8425 ha->isp_ops->read_optrom(vha, ha->nvram, faddr << 2, ha->nvram_size); in qla81xx_nvram_config()
8428 for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++, dptr++) in qla81xx_nvram_config()
8434 nv, ha->nvram_size); in qla81xx_nvram_config()
8437 if (chksum || memcmp("ISP ", nv->id, sizeof(nv->id)) || in qla81xx_nvram_config()
8438 le16_to_cpu(nv->nvram_version) < ICB_VERSION) { in qla81xx_nvram_config()
8442 chksum, nv->id, le16_to_cpu(nv->nvram_version)); in qla81xx_nvram_config()
8445 "Falling back to functioning (yet invalid -- WWPN) " in qla81xx_nvram_config()
8451 memset(nv, 0, ha->nvram_size); in qla81xx_nvram_config()
8452 nv->nvram_version = cpu_to_le16(ICB_VERSION); in qla81xx_nvram_config()
8453 nv->version = cpu_to_le16(ICB_VERSION); in qla81xx_nvram_config()
8454 nv->frame_payload_size = cpu_to_le16(2048); in qla81xx_nvram_config()
8455 nv->execution_throttle = cpu_to_le16(0xFFFF); in qla81xx_nvram_config()
8456 nv->exchange_count = cpu_to_le16(0); in qla81xx_nvram_config()
8457 nv->port_name[0] = 0x21; in qla81xx_nvram_config()
8458 nv->port_name[1] = 0x00 + ha->port_no + 1; in qla81xx_nvram_config()
8459 nv->port_name[2] = 0x00; in qla81xx_nvram_config()
8460 nv->port_name[3] = 0xe0; in qla81xx_nvram_config()
8461 nv->port_name[4] = 0x8b; in qla81xx_nvram_config()
8462 nv->port_name[5] = 0x1c; in qla81xx_nvram_config()
8463 nv->port_name[6] = 0x55; in qla81xx_nvram_config()
8464 nv->port_name[7] = 0x86; in qla81xx_nvram_config()
8465 nv->node_name[0] = 0x20; in qla81xx_nvram_config()
8466 nv->node_name[1] = 0x00; in qla81xx_nvram_config()
8467 nv->node_name[2] = 0x00; in qla81xx_nvram_config()
8468 nv->node_name[3] = 0xe0; in qla81xx_nvram_config()
8469 nv->node_name[4] = 0x8b; in qla81xx_nvram_config()
8470 nv->node_name[5] = 0x1c; in qla81xx_nvram_config()
8471 nv->node_name[6] = 0x55; in qla81xx_nvram_config()
8472 nv->node_name[7] = 0x86; in qla81xx_nvram_config()
8473 nv->login_retry_count = cpu_to_le16(8); in qla81xx_nvram_config()
8474 nv->interrupt_delay_timer = cpu_to_le16(0); in qla81xx_nvram_config()
8475 nv->login_timeout = cpu_to_le16(0); in qla81xx_nvram_config()
8476 nv->firmware_options_1 = in qla81xx_nvram_config()
8478 nv->firmware_options_2 = cpu_to_le32(2 << 4); in qla81xx_nvram_config()
8479 nv->firmware_options_2 |= cpu_to_le32(BIT_12); in qla81xx_nvram_config()
8480 nv->firmware_options_3 = cpu_to_le32(2 << 13); in qla81xx_nvram_config()
8481 nv->host_p = cpu_to_le32(BIT_11|BIT_10); in qla81xx_nvram_config()
8482 nv->efi_parameters = cpu_to_le32(0); in qla81xx_nvram_config()
8483 nv->reset_delay = 5; in qla81xx_nvram_config()
8484 nv->max_luns_per_target = cpu_to_le16(128); in qla81xx_nvram_config()
8485 nv->port_down_retry_count = cpu_to_le16(30); in qla81xx_nvram_config()
8486 nv->link_down_timeout = cpu_to_le16(180); in qla81xx_nvram_config()
8487 nv->enode_mac[0] = 0x00; in qla81xx_nvram_config()
8488 nv->enode_mac[1] = 0xC0; in qla81xx_nvram_config()
8489 nv->enode_mac[2] = 0xDD; in qla81xx_nvram_config()
8490 nv->enode_mac[3] = 0x04; in qla81xx_nvram_config()
8491 nv->enode_mac[4] = 0x05; in qla81xx_nvram_config()
8492 nv->enode_mac[5] = 0x06 + ha->port_no + 1; in qla81xx_nvram_config()
8498 nv->frame_payload_size &= cpu_to_le16(~7); in qla81xx_nvram_config()
8503 memset(icb, 0, ha->init_cb_size); in qla81xx_nvram_config()
8507 dptr2 = (uint8_t *)&nv->version; in qla81xx_nvram_config()
8508 cnt = (uint8_t *)&icb->response_q_inpointer - (uint8_t *)&icb->version; in qla81xx_nvram_config()
8509 while (cnt--) in qla81xx_nvram_config()
8512 icb->login_retry_count = nv->login_retry_count; in qla81xx_nvram_config()
8515 dptr1 = (uint8_t *)&icb->interrupt_delay_timer; in qla81xx_nvram_config()
8516 dptr2 = (uint8_t *)&nv->interrupt_delay_timer; in qla81xx_nvram_config()
8517 cnt = (uint8_t *)&icb->reserved_5 - in qla81xx_nvram_config()
8518 (uint8_t *)&icb->interrupt_delay_timer; in qla81xx_nvram_config()
8519 while (cnt--) in qla81xx_nvram_config()
8522 memcpy(icb->enode_mac, nv->enode_mac, sizeof(icb->enode_mac)); in qla81xx_nvram_config()
8524 if (!memcmp(icb->enode_mac, "\0\0\0\0\0\0", sizeof(icb->enode_mac))) { in qla81xx_nvram_config()
8525 icb->enode_mac[0] = 0x00; in qla81xx_nvram_config()
8526 icb->enode_mac[1] = 0xC0; in qla81xx_nvram_config()
8527 icb->enode_mac[2] = 0xDD; in qla81xx_nvram_config()
8528 icb->enode_mac[3] = 0x04; in qla81xx_nvram_config()
8529 icb->enode_mac[4] = 0x05; in qla81xx_nvram_config()
8530 icb->enode_mac[5] = 0x06 + ha->port_no + 1; in qla81xx_nvram_config()
8533 /* Use extended-initialization control block. */ in qla81xx_nvram_config()
8534 memcpy(ha->ex_init_cb, &nv->ex_version, sizeof(*ha->ex_init_cb)); in qla81xx_nvram_config()
8535 ha->frame_payload_size = le16_to_cpu(icb->frame_payload_size); in qla81xx_nvram_config()
8539 qla2x00_set_model_info(vha, nv->model_name, sizeof(nv->model_name), in qla81xx_nvram_config()
8545 if (nv->host_p & cpu_to_le32(BIT_15)) { in qla81xx_nvram_config()
8546 memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); in qla81xx_nvram_config()
8547 memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); in qla81xx_nvram_config()
8551 if ((icb->firmware_options_1 & cpu_to_le32(BIT_14)) == 0) { in qla81xx_nvram_config()
8556 memcpy(icb->node_name, icb->port_name, WWN_SIZE); in qla81xx_nvram_config()
8557 icb->node_name[0] &= 0xF0; in qla81xx_nvram_config()
8561 if ((nv->enhanced_features & BIT_7) == 0) in qla81xx_nvram_config()
8562 ha->flags.scm_supported_a = 1; in qla81xx_nvram_config()
8566 ha->flags.disable_risc_code_load = 0; in qla81xx_nvram_config()
8567 ha->flags.enable_lip_reset = 0; in qla81xx_nvram_config()
8568 ha->flags.enable_lip_full_login = in qla81xx_nvram_config()
8569 le32_to_cpu(nv->host_p) & BIT_10 ? 1 : 0; in qla81xx_nvram_config()
8570 ha->flags.enable_target_reset = in qla81xx_nvram_config()
8571 le32_to_cpu(nv->host_p) & BIT_11 ? 1 : 0; in qla81xx_nvram_config()
8572 ha->flags.enable_led_scheme = 0; in qla81xx_nvram_config()
8573 ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1 : 0; in qla81xx_nvram_config()
8575 ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) & in qla81xx_nvram_config()
8579 ha->serial0 = icb->port_name[5]; in qla81xx_nvram_config()
8580 ha->serial1 = icb->port_name[6]; in qla81xx_nvram_config()
8581 ha->serial2 = icb->port_name[7]; in qla81xx_nvram_config()
8582 memcpy(vha->node_name, icb->node_name, WWN_SIZE); in qla81xx_nvram_config()
8583 memcpy(vha->port_name, icb->port_name, WWN_SIZE); in qla81xx_nvram_config()
8585 icb->execution_throttle = cpu_to_le16(0xFFFF); in qla81xx_nvram_config()
8587 ha->retry_count = le16_to_cpu(nv->login_retry_count); in qla81xx_nvram_config()
8590 if (le16_to_cpu(nv->login_timeout) < ql2xlogintimeout) in qla81xx_nvram_config()
8591 nv->login_timeout = cpu_to_le16(ql2xlogintimeout); in qla81xx_nvram_config()
8592 if (le16_to_cpu(nv->login_timeout) < 4) in qla81xx_nvram_config()
8593 nv->login_timeout = cpu_to_le16(4); in qla81xx_nvram_config()
8594 ha->login_timeout = le16_to_cpu(nv->login_timeout); in qla81xx_nvram_config()
8597 ha->r_a_tov = 100; in qla81xx_nvram_config()
8599 ha->loop_reset_delay = nv->reset_delay; in qla81xx_nvram_config()
8611 if (le16_to_cpu(nv->link_down_timeout) == 0) { in qla81xx_nvram_config()
8612 ha->loop_down_abort_time = in qla81xx_nvram_config()
8613 (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); in qla81xx_nvram_config()
8615 ha->link_down_timeout = le16_to_cpu(nv->link_down_timeout); in qla81xx_nvram_config()
8616 ha->loop_down_abort_time = in qla81xx_nvram_config()
8617 (LOOP_DOWN_TIME - ha->link_down_timeout); in qla81xx_nvram_config()
8621 ha->port_down_retry_count = le16_to_cpu(nv->port_down_retry_count); in qla81xx_nvram_config()
8623 ha->port_down_retry_count = qlport_down_retry; in qla81xx_nvram_config()
8626 ha->login_retry_count = le16_to_cpu(nv->login_retry_count); in qla81xx_nvram_config()
8627 if (ha->port_down_retry_count == in qla81xx_nvram_config()
8628 le16_to_cpu(nv->port_down_retry_count) && in qla81xx_nvram_config()
8629 ha->port_down_retry_count > 3) in qla81xx_nvram_config()
8630 ha->login_retry_count = ha->port_down_retry_count; in qla81xx_nvram_config()
8631 else if (ha->port_down_retry_count > (int)ha->login_retry_count) in qla81xx_nvram_config()
8632 ha->login_retry_count = ha->port_down_retry_count; in qla81xx_nvram_config()
8634 ha->login_retry_count = ql2xloginretrycount; in qla81xx_nvram_config()
8636 /* if not running MSI-X we need handshaking on interrupts */ in qla81xx_nvram_config()
8637 if (!vha->hw->flags.msix_enabled && in qla81xx_nvram_config()
8639 icb->firmware_options_2 |= cpu_to_le32(BIT_22); in qla81xx_nvram_config()
8642 if (!vha->flags.init_done) { in qla81xx_nvram_config()
8643 ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & in qla81xx_nvram_config()
8645 ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? in qla81xx_nvram_config()
8646 le16_to_cpu(icb->interrupt_delay_timer) : 2; in qla81xx_nvram_config()
8648 icb->firmware_options_2 &= cpu_to_le32( in qla81xx_nvram_config()
8650 vha->flags.process_response_queue = 0; in qla81xx_nvram_config()
8651 if (ha->zio_mode != QLA_ZIO_DISABLED) { in qla81xx_nvram_config()
8652 ha->zio_mode = QLA_ZIO_MODE_6; in qla81xx_nvram_config()
8656 ha->zio_mode, in qla81xx_nvram_config()
8657 ha->zio_timer * 100); in qla81xx_nvram_config()
8659 icb->firmware_options_2 |= cpu_to_le32( in qla81xx_nvram_config()
8660 (uint32_t)ha->zio_mode); in qla81xx_nvram_config()
8661 icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer); in qla81xx_nvram_config()
8662 vha->flags.process_response_queue = 1; in qla81xx_nvram_config()
8666 icb->firmware_options_3 |= cpu_to_le32(BIT_0); in qla81xx_nvram_config()
8669 icb->firmware_options_3 |= cpu_to_le32(BIT_8); in qla81xx_nvram_config()
8672 ha->fc4_type_priority = qla2xxx_get_fc4_priority(vha); in qla81xx_nvram_config()
8685 struct qla_hw_data *ha = vha->hw; in qla82xx_restart_isp()
8691 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla82xx_restart_isp()
8692 ha->flags.chip_reset_done = 1; in qla82xx_restart_isp()
8697 qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL); in qla82xx_restart_isp()
8698 vha->flags.online = 1; in qla82xx_restart_isp()
8699 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla82xx_restart_isp()
8703 if ((vha->device_flags & DFLG_NO_CABLE)) in qla82xx_restart_isp()
8708 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla82xx_restart_isp()
8710 if (!atomic_read(&vha->loop_down_timer)) { in qla82xx_restart_isp()
8715 vha->marker_needed = 1; in qla82xx_restart_isp()
8718 ha->isp_ops->enable_intrs(ha); in qla82xx_restart_isp()
8720 ha->isp_abort_cnt = 0; in qla82xx_restart_isp()
8721 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qla82xx_restart_isp()
8726 if (ha->fce) { in qla82xx_restart_isp()
8727 ha->flags.fce_enabled = 1; in qla82xx_restart_isp()
8728 memset(ha->fce, 0, in qla82xx_restart_isp()
8729 fce_calc_size(ha->fce_bufs)); in qla82xx_restart_isp()
8731 ha->fce_dma, ha->fce_bufs, ha->fce_mb, in qla82xx_restart_isp()
8732 &ha->fce_bufs); in qla82xx_restart_isp()
8737 ha->flags.fce_enabled = 0; in qla82xx_restart_isp()
8741 if (ha->eft) { in qla82xx_restart_isp()
8742 memset(ha->eft, 0, EFT_SIZE); in qla82xx_restart_isp()
8744 ha->eft_dma, EFT_NUM_BUFFERS); in qla82xx_restart_isp()
8757 spin_lock_irqsave(&ha->vport_slock, flags); in qla82xx_restart_isp()
8758 list_for_each_entry(vp, &ha->vp_list, list) { in qla82xx_restart_isp()
8759 if (vp->vp_idx) { in qla82xx_restart_isp()
8760 atomic_inc(&vp->vref_count); in qla82xx_restart_isp()
8761 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla82xx_restart_isp()
8765 spin_lock_irqsave(&ha->vport_slock, flags); in qla82xx_restart_isp()
8766 atomic_dec(&vp->vref_count); in qla82xx_restart_isp()
8769 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla82xx_restart_isp()
8791 * non-zero (if found)
8792 * -1 (if not found)
8806 struct qla_hw_data *ha = vha->hw; in qla24xx_get_fcp_prio()
8808 if (!ha->fcp_prio_cfg || !ha->flags.fcp_prio_enabled) in qla24xx_get_fcp_prio()
8809 return -1; in qla24xx_get_fcp_prio()
8811 priority = -1; in qla24xx_get_fcp_prio()
8812 entries = ha->fcp_prio_cfg->num_entries; in qla24xx_get_fcp_prio()
8813 pri_entry = &ha->fcp_prio_cfg->entry[0]; in qla24xx_get_fcp_prio()
8818 if (!(pri_entry->flags & FCP_PRIO_ENTRY_VALID)) { in qla24xx_get_fcp_prio()
8824 if (pri_entry->flags & FCP_PRIO_ENTRY_SPID_VALID) { in qla24xx_get_fcp_prio()
8825 pid1 = pri_entry->src_pid & INVALID_PORT_ID; in qla24xx_get_fcp_prio()
8826 pid2 = vha->d_id.b24 & INVALID_PORT_ID; in qla24xx_get_fcp_prio()
8834 if (pri_entry->flags & FCP_PRIO_ENTRY_DPID_VALID) { in qla24xx_get_fcp_prio()
8835 pid1 = pri_entry->dst_pid & INVALID_PORT_ID; in qla24xx_get_fcp_prio()
8836 pid2 = fcport->d_id.b24 & INVALID_PORT_ID; in qla24xx_get_fcp_prio()
8844 if (pri_entry->flags & FCP_PRIO_ENTRY_SWWN_VALID) { in qla24xx_get_fcp_prio()
8845 wwn1 = wwn_to_u64(vha->port_name); in qla24xx_get_fcp_prio()
8846 wwn2 = wwn_to_u64(pri_entry->src_wwpn); in qla24xx_get_fcp_prio()
8847 if (wwn2 == (uint64_t)-1) in qla24xx_get_fcp_prio()
8854 if (pri_entry->flags & FCP_PRIO_ENTRY_DWWN_VALID) { in qla24xx_get_fcp_prio()
8855 wwn1 = wwn_to_u64(fcport->port_name); in qla24xx_get_fcp_prio()
8856 wwn2 = wwn_to_u64(pri_entry->dst_wwpn); in qla24xx_get_fcp_prio()
8857 if (wwn2 == (uint64_t)-1) in qla24xx_get_fcp_prio()
8865 if (pri_entry->flags & FCP_PRIO_ENTRY_TAG_VALID) in qla24xx_get_fcp_prio()
8866 priority = pri_entry->tag; in qla24xx_get_fcp_prio()
8897 if (fcport->port_type != FCT_TARGET || in qla24xx_update_fcport_fcp_prio()
8898 fcport->loop_id == FC_NO_LOOP_ID) in qla24xx_update_fcport_fcp_prio()
8905 if (IS_P3P_TYPE(vha->hw)) { in qla24xx_update_fcport_fcp_prio()
8906 fcport->fcp_prio = priority & 0xf; in qla24xx_update_fcport_fcp_prio()
8910 ret = qla24xx_set_fcp_prio(vha, fcport->loop_id, priority, mb); in qla24xx_update_fcport_fcp_prio()
8912 if (fcport->fcp_prio != priority) in qla24xx_update_fcport_fcp_prio()
8914 "Updated FCP_CMND priority - value=%d loop_id=%d " in qla24xx_update_fcport_fcp_prio()
8916 fcport->loop_id, fcport->d_id.b.domain, in qla24xx_update_fcport_fcp_prio()
8917 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla24xx_update_fcport_fcp_prio()
8918 fcport->fcp_prio = priority & 0xf; in qla24xx_update_fcport_fcp_prio()
8921 "Unable to update FCP_CMND priority - ret=0x%x for " in qla24xx_update_fcport_fcp_prio()
8922 "loop_id=%d port_id=%02x%02x%02x.\n", ret, fcport->loop_id, in qla24xx_update_fcport_fcp_prio()
8923 fcport->d_id.b.domain, fcport->d_id.b.area, in qla24xx_update_fcport_fcp_prio()
8924 fcport->d_id.b.al_pa); in qla24xx_update_fcport_fcp_prio()
8949 list_for_each_entry(fcport, &vha->vp_fcports, list) in qla24xx_update_all_fcp_prio()
8961 struct qla_hw_data *ha = vha->hw; in qla2xxx_create_qpair()
8966 if (!(ha->fw_attributes & BIT_6) || !ha->flags.msix_enabled) { in qla2xxx_create_qpair()
8968 "FW/Driver is not multi-queue capable.\n"); in qla2xxx_create_qpair()
8980 qpair->hw = vha->hw; in qla2xxx_create_qpair()
8981 qpair->vha = vha; in qla2xxx_create_qpair()
8982 qpair->qp_lock_ptr = &qpair->qp_lock; in qla2xxx_create_qpair()
8983 spin_lock_init(&qpair->qp_lock); in qla2xxx_create_qpair()
8984 qpair->use_shadow_reg = IS_SHADOW_REG_CAPABLE(ha) ? 1 : 0; in qla2xxx_create_qpair()
8987 mutex_lock(&ha->mq_lock); in qla2xxx_create_qpair()
8988 qpair_id = find_first_zero_bit(ha->qpair_qid_map, ha->max_qpairs); in qla2xxx_create_qpair()
8989 if (ha->num_qpairs >= ha->max_qpairs) { in qla2xxx_create_qpair()
8990 mutex_unlock(&ha->mq_lock); in qla2xxx_create_qpair()
8995 ha->num_qpairs++; in qla2xxx_create_qpair()
8996 set_bit(qpair_id, ha->qpair_qid_map); in qla2xxx_create_qpair()
8997 ha->queue_pair_map[qpair_id] = qpair; in qla2xxx_create_qpair()
8998 qpair->id = qpair_id; in qla2xxx_create_qpair()
8999 qpair->vp_idx = vp_idx; in qla2xxx_create_qpair()
9000 qpair->fw_started = ha->flags.fw_started; in qla2xxx_create_qpair()
9001 INIT_LIST_HEAD(&qpair->hints_list); in qla2xxx_create_qpair()
9002 qpair->chip_reset = ha->base_qpair->chip_reset; in qla2xxx_create_qpair()
9003 qpair->enable_class_2 = ha->base_qpair->enable_class_2; in qla2xxx_create_qpair()
9004 qpair->enable_explicit_conf = in qla2xxx_create_qpair()
9005 ha->base_qpair->enable_explicit_conf; in qla2xxx_create_qpair()
9007 for (i = 0; i < ha->msix_count; i++) { in qla2xxx_create_qpair()
9008 msix = &ha->msix_entries[i]; in qla2xxx_create_qpair()
9009 if (msix->in_use) in qla2xxx_create_qpair()
9011 qpair->msix = msix; in qla2xxx_create_qpair()
9013 "Vector %x selected for qpair\n", msix->vector); in qla2xxx_create_qpair()
9016 if (!qpair->msix) { in qla2xxx_create_qpair()
9018 "Out of MSI-X vectors!.\n"); in qla2xxx_create_qpair()
9022 qpair->msix->in_use = 1; in qla2xxx_create_qpair()
9023 list_add_tail(&qpair->qp_list_elem, &vha->qp_list); in qla2xxx_create_qpair()
9024 qpair->pdev = ha->pdev; in qla2xxx_create_qpair()
9026 qpair->reqq_start_iocbs = qla_83xx_start_iocbs; in qla2xxx_create_qpair()
9028 mutex_unlock(&ha->mq_lock); in qla2xxx_create_qpair()
9038 qpair->rsp = ha->rsp_q_map[rsp_id]; in qla2xxx_create_qpair()
9049 qpair->req = ha->req_q_map[req_id]; in qla2xxx_create_qpair()
9050 qpair->rsp->req = qpair->req; in qla2xxx_create_qpair()
9051 qpair->rsp->qpair = qpair; in qla2xxx_create_qpair()
9056 if (ha->fw_attributes & BIT_4) in qla2xxx_create_qpair()
9057 qpair->difdix_supported = 1; in qla2xxx_create_qpair()
9060 qpair->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); in qla2xxx_create_qpair()
9061 if (!qpair->srb_mempool) { in qla2xxx_create_qpair()
9064 qpair->id); in qla2xxx_create_qpair()
9069 qpair->online = 1; in qla2xxx_create_qpair()
9071 if (!vha->flags.qpairs_available) in qla2xxx_create_qpair()
9072 vha->flags.qpairs_available = 1; in qla2xxx_create_qpair()
9076 qpair->id); in qla2xxx_create_qpair()
9079 qpair->id); in qla2xxx_create_qpair()
9085 qla25xx_delete_rsp_que(vha, qpair->rsp); in qla2xxx_create_qpair()
9087 mutex_lock(&ha->mq_lock); in qla2xxx_create_qpair()
9088 qpair->msix->in_use = 0; in qla2xxx_create_qpair()
9089 list_del(&qpair->qp_list_elem); in qla2xxx_create_qpair()
9090 if (list_empty(&vha->qp_list)) in qla2xxx_create_qpair()
9091 vha->flags.qpairs_available = 0; in qla2xxx_create_qpair()
9093 ha->queue_pair_map[qpair_id] = NULL; in qla2xxx_create_qpair()
9094 clear_bit(qpair_id, ha->qpair_qid_map); in qla2xxx_create_qpair()
9095 ha->num_qpairs--; in qla2xxx_create_qpair()
9096 mutex_unlock(&ha->mq_lock); in qla2xxx_create_qpair()
9105 struct qla_hw_data *ha = qpair->hw; in qla2xxx_delete_qpair()
9107 qpair->delete_in_progress = 1; in qla2xxx_delete_qpair()
9109 ret = qla25xx_delete_req_que(vha, qpair->req); in qla2xxx_delete_qpair()
9113 ret = qla25xx_delete_rsp_que(vha, qpair->rsp); in qla2xxx_delete_qpair()
9117 mutex_lock(&ha->mq_lock); in qla2xxx_delete_qpair()
9118 ha->queue_pair_map[qpair->id] = NULL; in qla2xxx_delete_qpair()
9119 clear_bit(qpair->id, ha->qpair_qid_map); in qla2xxx_delete_qpair()
9120 ha->num_qpairs--; in qla2xxx_delete_qpair()
9121 list_del(&qpair->qp_list_elem); in qla2xxx_delete_qpair()
9122 if (list_empty(&vha->qp_list)) { in qla2xxx_delete_qpair()
9123 vha->flags.qpairs_available = 0; in qla2xxx_delete_qpair()
9124 vha->flags.qpairs_req_created = 0; in qla2xxx_delete_qpair()
9125 vha->flags.qpairs_rsp_created = 0; in qla2xxx_delete_qpair()
9127 mempool_destroy(qpair->srb_mempool); in qla2xxx_delete_qpair()
9129 mutex_unlock(&ha->mq_lock); in qla2xxx_delete_qpair()