| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * QLogic Fibre Channel HBA Driver |
|---|
| 3 | 4 | * Copyright (c) 2003-2014 QLogic Corporation |
|---|
| 4 | | - * |
|---|
| 5 | | - * See LICENSE.qla2xxx for copyright and licensing details. |
|---|
| 6 | 5 | */ |
|---|
| 7 | 6 | #include "qla_def.h" |
|---|
| 8 | 7 | #include "qla_gbl.h" |
|---|
| .. | .. |
|---|
| 17 | 16 | #include <asm/prom.h> |
|---|
| 18 | 17 | #endif |
|---|
| 19 | 18 | |
|---|
| 20 | | -#include <target/target_core_base.h> |
|---|
| 21 | 19 | #include "qla_target.h" |
|---|
| 22 | 20 | |
|---|
| 23 | 21 | /* |
|---|
| .. | .. |
|---|
| 37 | 35 | static int qla84xx_init_chip(scsi_qla_host_t *); |
|---|
| 38 | 36 | static int qla25xx_init_queues(struct qla_hw_data *); |
|---|
| 39 | 37 | static int qla24xx_post_prli_work(struct scsi_qla_host*, fc_port_t *); |
|---|
| 40 | | -static void qla24xx_handle_plogi_done_event(struct scsi_qla_host *, |
|---|
| 41 | | - struct event_arg *); |
|---|
| 38 | +static void qla24xx_handle_gpdb_event(scsi_qla_host_t *vha, |
|---|
| 39 | + struct event_arg *ea); |
|---|
| 42 | 40 | static void qla24xx_handle_prli_done_event(struct scsi_qla_host *, |
|---|
| 43 | 41 | struct event_arg *); |
|---|
| 44 | 42 | static void __qla24xx_handle_gpdb_event(scsi_qla_host_t *, struct event_arg *); |
|---|
| .. | .. |
|---|
| 50 | 48 | { |
|---|
| 51 | 49 | srb_t *sp = from_timer(sp, t, u.iocb_cmd.timer); |
|---|
| 52 | 50 | struct srb_iocb *iocb; |
|---|
| 53 | | - struct req_que *req; |
|---|
| 54 | | - unsigned long flags; |
|---|
| 55 | | - struct qla_hw_data *ha = sp->vha->hw; |
|---|
| 56 | 51 | |
|---|
| 57 | | - WARN_ON_ONCE(irqs_disabled()); |
|---|
| 58 | | - spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 59 | | - req = sp->qpair->req; |
|---|
| 60 | | - req->outstanding_cmds[sp->handle] = NULL; |
|---|
| 52 | + WARN_ON(irqs_disabled()); |
|---|
| 61 | 53 | iocb = &sp->u.iocb_cmd; |
|---|
| 62 | | - spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 63 | 54 | iocb->timeout(sp); |
|---|
| 64 | 55 | } |
|---|
| 65 | 56 | |
|---|
| 66 | | -void |
|---|
| 67 | | -qla2x00_sp_free(void *ptr) |
|---|
| 57 | +void qla2x00_sp_free(srb_t *sp) |
|---|
| 68 | 58 | { |
|---|
| 69 | | - srb_t *sp = ptr; |
|---|
| 70 | 59 | struct srb_iocb *iocb = &sp->u.iocb_cmd; |
|---|
| 71 | 60 | |
|---|
| 72 | 61 | del_timer(&iocb->timer); |
|---|
| 73 | 62 | qla2x00_rel_sp(sp); |
|---|
| 63 | +} |
|---|
| 64 | + |
|---|
| 65 | +void qla2xxx_rel_done_warning(srb_t *sp, int res) |
|---|
| 66 | +{ |
|---|
| 67 | + WARN_ONCE(1, "Calling done() of an already freed srb %p object\n", sp); |
|---|
| 68 | +} |
|---|
| 69 | + |
|---|
| 70 | +void qla2xxx_rel_free_warning(srb_t *sp) |
|---|
| 71 | +{ |
|---|
| 72 | + WARN_ONCE(1, "Calling free() of an already freed srb %p object\n", sp); |
|---|
| 74 | 73 | } |
|---|
| 75 | 74 | |
|---|
| 76 | 75 | /* Asynchronous Login/Logout Routines -------------------------------------- */ |
|---|
| .. | .. |
|---|
| 93 | 92 | tmo = ha->login_timeout; |
|---|
| 94 | 93 | } |
|---|
| 95 | 94 | return tmo; |
|---|
| 95 | +} |
|---|
| 96 | + |
|---|
| 97 | +static void qla24xx_abort_iocb_timeout(void *data) |
|---|
| 98 | +{ |
|---|
| 99 | + srb_t *sp = data; |
|---|
| 100 | + struct srb_iocb *abt = &sp->u.iocb_cmd; |
|---|
| 101 | + struct qla_qpair *qpair = sp->qpair; |
|---|
| 102 | + u32 handle; |
|---|
| 103 | + unsigned long flags; |
|---|
| 104 | + |
|---|
| 105 | + if (sp->cmd_sp) |
|---|
| 106 | + ql_dbg(ql_dbg_async, sp->vha, 0x507c, |
|---|
| 107 | + "Abort timeout - cmd hdl=%x, cmd type=%x hdl=%x, type=%x\n", |
|---|
| 108 | + sp->cmd_sp->handle, sp->cmd_sp->type, |
|---|
| 109 | + sp->handle, sp->type); |
|---|
| 110 | + else |
|---|
| 111 | + ql_dbg(ql_dbg_async, sp->vha, 0x507c, |
|---|
| 112 | + "Abort timeout 2 - hdl=%x, type=%x\n", |
|---|
| 113 | + sp->handle, sp->type); |
|---|
| 114 | + |
|---|
| 115 | + spin_lock_irqsave(qpair->qp_lock_ptr, flags); |
|---|
| 116 | + for (handle = 1; handle < qpair->req->num_outstanding_cmds; handle++) { |
|---|
| 117 | + if (sp->cmd_sp && (qpair->req->outstanding_cmds[handle] == |
|---|
| 118 | + sp->cmd_sp)) |
|---|
| 119 | + qpair->req->outstanding_cmds[handle] = NULL; |
|---|
| 120 | + |
|---|
| 121 | + /* removing the abort */ |
|---|
| 122 | + if (qpair->req->outstanding_cmds[handle] == sp) { |
|---|
| 123 | + qpair->req->outstanding_cmds[handle] = NULL; |
|---|
| 124 | + break; |
|---|
| 125 | + } |
|---|
| 126 | + } |
|---|
| 127 | + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); |
|---|
| 128 | + |
|---|
| 129 | + if (sp->cmd_sp) |
|---|
| 130 | + sp->cmd_sp->done(sp->cmd_sp, QLA_OS_TIMER_EXPIRED); |
|---|
| 131 | + |
|---|
| 132 | + abt->u.abt.comp_status = cpu_to_le16(CS_TIMEOUT); |
|---|
| 133 | + sp->done(sp, QLA_OS_TIMER_EXPIRED); |
|---|
| 134 | +} |
|---|
| 135 | + |
|---|
| 136 | +static void qla24xx_abort_sp_done(srb_t *sp, int res) |
|---|
| 137 | +{ |
|---|
| 138 | + struct srb_iocb *abt = &sp->u.iocb_cmd; |
|---|
| 139 | + |
|---|
| 140 | + del_timer(&sp->u.iocb_cmd.timer); |
|---|
| 141 | + if (sp->flags & SRB_WAKEUP_ON_COMP) |
|---|
| 142 | + complete(&abt->u.abt.comp); |
|---|
| 143 | + else |
|---|
| 144 | + sp->free(sp); |
|---|
| 145 | +} |
|---|
| 146 | + |
|---|
| 147 | +int qla24xx_async_abort_cmd(srb_t *cmd_sp, bool wait) |
|---|
| 148 | +{ |
|---|
| 149 | + scsi_qla_host_t *vha = cmd_sp->vha; |
|---|
| 150 | + struct srb_iocb *abt_iocb; |
|---|
| 151 | + srb_t *sp; |
|---|
| 152 | + int rval = QLA_FUNCTION_FAILED; |
|---|
| 153 | + |
|---|
| 154 | + sp = qla2xxx_get_qpair_sp(cmd_sp->vha, cmd_sp->qpair, cmd_sp->fcport, |
|---|
| 155 | + GFP_ATOMIC); |
|---|
| 156 | + if (!sp) |
|---|
| 157 | + return rval; |
|---|
| 158 | + |
|---|
| 159 | + abt_iocb = &sp->u.iocb_cmd; |
|---|
| 160 | + sp->type = SRB_ABT_CMD; |
|---|
| 161 | + sp->name = "abort"; |
|---|
| 162 | + sp->qpair = cmd_sp->qpair; |
|---|
| 163 | + sp->cmd_sp = cmd_sp; |
|---|
| 164 | + if (wait) |
|---|
| 165 | + sp->flags = SRB_WAKEUP_ON_COMP; |
|---|
| 166 | + |
|---|
| 167 | + abt_iocb->timeout = qla24xx_abort_iocb_timeout; |
|---|
| 168 | + init_completion(&abt_iocb->u.abt.comp); |
|---|
| 169 | + /* FW can send 2 x ABTS's timeout/20s */ |
|---|
| 170 | + qla2x00_init_timer(sp, 42); |
|---|
| 171 | + |
|---|
| 172 | + abt_iocb->u.abt.cmd_hndl = cmd_sp->handle; |
|---|
| 173 | + abt_iocb->u.abt.req_que_no = cpu_to_le16(cmd_sp->qpair->req->id); |
|---|
| 174 | + |
|---|
| 175 | + sp->done = qla24xx_abort_sp_done; |
|---|
| 176 | + |
|---|
| 177 | + ql_dbg(ql_dbg_async, vha, 0x507c, |
|---|
| 178 | + "Abort command issued - hdl=%x, type=%x\n", cmd_sp->handle, |
|---|
| 179 | + cmd_sp->type); |
|---|
| 180 | + |
|---|
| 181 | + rval = qla2x00_start_sp(sp); |
|---|
| 182 | + if (rval != QLA_SUCCESS) { |
|---|
| 183 | + sp->free(sp); |
|---|
| 184 | + return rval; |
|---|
| 185 | + } |
|---|
| 186 | + |
|---|
| 187 | + if (wait) { |
|---|
| 188 | + wait_for_completion(&abt_iocb->u.abt.comp); |
|---|
| 189 | + rval = abt_iocb->u.abt.comp_status == CS_COMPLETE ? |
|---|
| 190 | + QLA_SUCCESS : QLA_FUNCTION_FAILED; |
|---|
| 191 | + sp->free(sp); |
|---|
| 192 | + } |
|---|
| 193 | + |
|---|
| 194 | + return rval; |
|---|
| 96 | 195 | } |
|---|
| 97 | 196 | |
|---|
| 98 | 197 | void |
|---|
| .. | .. |
|---|
| 145 | 244 | case SRB_NACK_PRLI: |
|---|
| 146 | 245 | case SRB_NACK_LOGO: |
|---|
| 147 | 246 | case SRB_CTRL_VP: |
|---|
| 247 | + default: |
|---|
| 148 | 248 | rc = qla24xx_async_abort_cmd(sp, false); |
|---|
| 149 | 249 | if (rc) { |
|---|
| 150 | 250 | spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); |
|---|
| .. | .. |
|---|
| 164 | 264 | } |
|---|
| 165 | 265 | } |
|---|
| 166 | 266 | |
|---|
| 167 | | -static void |
|---|
| 168 | | -qla2x00_async_login_sp_done(void *ptr, int res) |
|---|
| 267 | +static void qla2x00_async_login_sp_done(srb_t *sp, int res) |
|---|
| 169 | 268 | { |
|---|
| 170 | | - srb_t *sp = ptr; |
|---|
| 171 | 269 | struct scsi_qla_host *vha = sp->vha; |
|---|
| 172 | 270 | struct srb_iocb *lio = &sp->u.iocb_cmd; |
|---|
| 173 | 271 | struct event_arg ea; |
|---|
| .. | .. |
|---|
| 179 | 277 | |
|---|
| 180 | 278 | if (!test_bit(UNLOADING, &vha->dpc_flags)) { |
|---|
| 181 | 279 | memset(&ea, 0, sizeof(ea)); |
|---|
| 182 | | - ea.event = FCME_PLOGI_DONE; |
|---|
| 183 | 280 | ea.fcport = sp->fcport; |
|---|
| 184 | 281 | ea.data[0] = lio->u.logio.data[0]; |
|---|
| 185 | 282 | ea.data[1] = lio->u.logio.data[1]; |
|---|
| 186 | 283 | ea.iop[0] = lio->u.logio.iop[0]; |
|---|
| 187 | 284 | ea.iop[1] = lio->u.logio.iop[1]; |
|---|
| 188 | 285 | ea.sp = sp; |
|---|
| 189 | | - qla2x00_fcport_event_handler(vha, &ea); |
|---|
| 286 | + qla24xx_handle_plogi_done_event(vha, &ea); |
|---|
| 190 | 287 | } |
|---|
| 191 | 288 | |
|---|
| 192 | 289 | sp->free(sp); |
|---|
| .. | .. |
|---|
| 228 | 325 | if (!sp) |
|---|
| 229 | 326 | goto done; |
|---|
| 230 | 327 | |
|---|
| 328 | + qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_PEND); |
|---|
| 231 | 329 | fcport->flags |= FCF_ASYNC_SENT; |
|---|
| 232 | 330 | fcport->logout_completed = 0; |
|---|
| 233 | 331 | |
|---|
| 234 | | - fcport->disc_state = DSC_LOGIN_PEND; |
|---|
| 235 | 332 | sp->type = SRB_LOGIN_CMD; |
|---|
| 236 | 333 | sp->name = "login"; |
|---|
| 237 | 334 | sp->gen1 = fcport->rscn_gen; |
|---|
| .. | .. |
|---|
| 247 | 344 | else |
|---|
| 248 | 345 | lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI; |
|---|
| 249 | 346 | |
|---|
| 250 | | - if (fcport->fc4f_nvme) |
|---|
| 347 | + if (NVME_TARGET(vha->hw, fcport)) |
|---|
| 251 | 348 | lio->u.logio.flags |= SRB_LOGIN_SKIP_PRLI; |
|---|
| 252 | 349 | |
|---|
| 253 | 350 | ql_dbg(ql_dbg_disc, vha, 0x2072, |
|---|
| .. | .. |
|---|
| 273 | 370 | return rval; |
|---|
| 274 | 371 | } |
|---|
| 275 | 372 | |
|---|
| 276 | | -static void |
|---|
| 277 | | -qla2x00_async_logout_sp_done(void *ptr, int res) |
|---|
| 373 | +static void qla2x00_async_logout_sp_done(srb_t *sp, int res) |
|---|
| 278 | 374 | { |
|---|
| 279 | | - srb_t *sp = ptr; |
|---|
| 280 | | - |
|---|
| 281 | 375 | sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); |
|---|
| 282 | 376 | sp->fcport->login_gen++; |
|---|
| 283 | 377 | qlt_logo_completion_handler(sp->fcport, res); |
|---|
| .. | .. |
|---|
| 330 | 424 | fcport->flags &= ~FCF_ASYNC_ACTIVE; |
|---|
| 331 | 425 | /* Don't re-login in target mode */ |
|---|
| 332 | 426 | if (!fcport->tgt_session) |
|---|
| 333 | | - qla2x00_mark_device_lost(vha, fcport, 1, 0); |
|---|
| 427 | + qla2x00_mark_device_lost(vha, fcport, 1); |
|---|
| 334 | 428 | qlt_logo_completion_handler(fcport, data[0]); |
|---|
| 335 | 429 | } |
|---|
| 336 | 430 | |
|---|
| 337 | | -static void |
|---|
| 338 | | -qla2x00_async_prlo_sp_done(void *s, int res) |
|---|
| 431 | +static void qla2x00_async_prlo_sp_done(srb_t *sp, int res) |
|---|
| 339 | 432 | { |
|---|
| 340 | | - srb_t *sp = (srb_t *)s; |
|---|
| 341 | 433 | struct srb_iocb *lio = &sp->u.iocb_cmd; |
|---|
| 342 | 434 | struct scsi_qla_host *vha = sp->vha; |
|---|
| 343 | 435 | |
|---|
| .. | .. |
|---|
| 368 | 460 | qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); |
|---|
| 369 | 461 | |
|---|
| 370 | 462 | sp->done = qla2x00_async_prlo_sp_done; |
|---|
| 371 | | - rval = qla2x00_start_sp(sp); |
|---|
| 372 | | - if (rval != QLA_SUCCESS) |
|---|
| 373 | | - goto done_free_sp; |
|---|
| 374 | 463 | |
|---|
| 375 | 464 | ql_dbg(ql_dbg_disc, vha, 0x2070, |
|---|
| 376 | 465 | "Async-prlo - hdl=%x loop-id=%x portid=%02x%02x%02x.\n", |
|---|
| 377 | 466 | sp->handle, fcport->loop_id, fcport->d_id.b.domain, |
|---|
| 378 | 467 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
|---|
| 468 | + |
|---|
| 469 | + rval = qla2x00_start_sp(sp); |
|---|
| 470 | + if (rval != QLA_SUCCESS) |
|---|
| 471 | + goto done_free_sp; |
|---|
| 472 | + |
|---|
| 379 | 473 | return rval; |
|---|
| 380 | 474 | |
|---|
| 381 | 475 | done_free_sp: |
|---|
| .. | .. |
|---|
| 396 | 490 | fcport->fw_login_state, ea->rc, fcport->login_gen, ea->sp->gen2, |
|---|
| 397 | 491 | fcport->rscn_gen, ea->sp->gen1, fcport->loop_id); |
|---|
| 398 | 492 | |
|---|
| 493 | + WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n", |
|---|
| 494 | + ea->data[0]); |
|---|
| 495 | + |
|---|
| 399 | 496 | if (ea->data[0] != MBS_COMMAND_COMPLETE) { |
|---|
| 400 | 497 | ql_dbg(ql_dbg_disc, vha, 0x2066, |
|---|
| 401 | 498 | "%s %8phC: adisc fail: post delete\n", |
|---|
| 402 | 499 | __func__, ea->fcport->port_name); |
|---|
| 500 | + /* deleted = 0 & logout_on_delete = force fw cleanup */ |
|---|
| 501 | + fcport->deleted = 0; |
|---|
| 502 | + fcport->logout_on_delete = 1; |
|---|
| 403 | 503 | qlt_schedule_sess_for_deletion(ea->fcport); |
|---|
| 404 | 504 | return; |
|---|
| 405 | 505 | } |
|---|
| .. | .. |
|---|
| 414 | 514 | __func__, ea->fcport->port_name); |
|---|
| 415 | 515 | return; |
|---|
| 416 | 516 | } else if (ea->sp->gen1 != ea->fcport->rscn_gen) { |
|---|
| 417 | | - ql_dbg(ql_dbg_disc, vha, 0x20d4, "%s %d %8phC post gidpn\n", |
|---|
| 418 | | - __func__, __LINE__, ea->fcport->port_name); |
|---|
| 419 | | - qla24xx_post_gidpn_work(vha, ea->fcport); |
|---|
| 517 | + qla_rscn_replay(fcport); |
|---|
| 518 | + qlt_schedule_sess_for_deletion(fcport); |
|---|
| 420 | 519 | return; |
|---|
| 421 | 520 | } |
|---|
| 422 | 521 | |
|---|
| 423 | 522 | __qla24xx_handle_gpdb_event(vha, ea); |
|---|
| 424 | 523 | } |
|---|
| 425 | 524 | |
|---|
| 426 | | -int qla_post_els_plogi_work(struct scsi_qla_host *vha, fc_port_t *fcport) |
|---|
| 525 | +static int qla_post_els_plogi_work(struct scsi_qla_host *vha, fc_port_t *fcport) |
|---|
| 427 | 526 | { |
|---|
| 428 | 527 | struct qla_work_evt *e; |
|---|
| 429 | 528 | |
|---|
| .. | .. |
|---|
| 433 | 532 | |
|---|
| 434 | 533 | e->u.fcport.fcport = fcport; |
|---|
| 435 | 534 | fcport->flags |= FCF_ASYNC_ACTIVE; |
|---|
| 436 | | - fcport->disc_state = DSC_LOGIN_PEND; |
|---|
| 535 | + qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_PEND); |
|---|
| 437 | 536 | return qla2x00_post_work(vha, e); |
|---|
| 438 | 537 | } |
|---|
| 439 | 538 | |
|---|
| 440 | | -static void |
|---|
| 441 | | -qla2x00_async_adisc_sp_done(void *ptr, int res) |
|---|
| 539 | +static void qla2x00_async_adisc_sp_done(srb_t *sp, int res) |
|---|
| 442 | 540 | { |
|---|
| 443 | | - srb_t *sp = ptr; |
|---|
| 444 | 541 | struct scsi_qla_host *vha = sp->vha; |
|---|
| 445 | 542 | struct event_arg ea; |
|---|
| 446 | 543 | struct srb_iocb *lio = &sp->u.iocb_cmd; |
|---|
| .. | .. |
|---|
| 452 | 549 | sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); |
|---|
| 453 | 550 | |
|---|
| 454 | 551 | memset(&ea, 0, sizeof(ea)); |
|---|
| 455 | | - ea.event = FCME_ADISC_DONE; |
|---|
| 456 | 552 | ea.rc = res; |
|---|
| 457 | 553 | ea.data[0] = lio->u.logio.data[0]; |
|---|
| 458 | 554 | ea.data[1] = lio->u.logio.data[1]; |
|---|
| .. | .. |
|---|
| 461 | 557 | ea.fcport = sp->fcport; |
|---|
| 462 | 558 | ea.sp = sp; |
|---|
| 463 | 559 | |
|---|
| 464 | | - qla2x00_fcport_event_handler(vha, &ea); |
|---|
| 560 | + qla24xx_handle_adisc_event(vha, &ea); |
|---|
| 465 | 561 | |
|---|
| 466 | 562 | sp->free(sp); |
|---|
| 467 | 563 | } |
|---|
| .. | .. |
|---|
| 472 | 568 | { |
|---|
| 473 | 569 | srb_t *sp; |
|---|
| 474 | 570 | struct srb_iocb *lio; |
|---|
| 475 | | - int rval; |
|---|
| 571 | + int rval = QLA_FUNCTION_FAILED; |
|---|
| 476 | 572 | |
|---|
| 477 | | - rval = QLA_FUNCTION_FAILED; |
|---|
| 573 | + if (IS_SESSION_DELETED(fcport)) { |
|---|
| 574 | + ql_log(ql_log_warn, vha, 0xffff, |
|---|
| 575 | + "%s: %8phC is being delete - not sending command.\n", |
|---|
| 576 | + __func__, fcport->port_name); |
|---|
| 577 | + fcport->flags &= ~FCF_ASYNC_ACTIVE; |
|---|
| 578 | + return rval; |
|---|
| 579 | + } |
|---|
| 580 | + |
|---|
| 581 | + if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT)) |
|---|
| 582 | + return rval; |
|---|
| 583 | + |
|---|
| 478 | 584 | fcport->flags |= FCF_ASYNC_SENT; |
|---|
| 479 | 585 | sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); |
|---|
| 480 | 586 | if (!sp) |
|---|
| .. | .. |
|---|
| 511 | 617 | return rval; |
|---|
| 512 | 618 | } |
|---|
| 513 | 619 | |
|---|
| 620 | +static bool qla2x00_is_reserved_id(scsi_qla_host_t *vha, uint16_t loop_id) |
|---|
| 621 | +{ |
|---|
| 622 | + struct qla_hw_data *ha = vha->hw; |
|---|
| 623 | + |
|---|
| 624 | + if (IS_FWI2_CAPABLE(ha)) |
|---|
| 625 | + return loop_id > NPH_LAST_HANDLE; |
|---|
| 626 | + |
|---|
| 627 | + return (loop_id > ha->max_loop_id && loop_id < SNS_FIRST_LOOP_ID) || |
|---|
| 628 | + loop_id == MANAGEMENT_SERVER || loop_id == BROADCAST; |
|---|
| 629 | +} |
|---|
| 630 | + |
|---|
| 631 | +/** |
|---|
| 632 | + * qla2x00_find_new_loop_id - scan through our port list and find a new usable loop ID |
|---|
| 633 | + * @vha: adapter state pointer. |
|---|
| 634 | + * @dev: port structure pointer. |
|---|
| 635 | + * |
|---|
| 636 | + * Returns: |
|---|
| 637 | + * qla2x00 local function return status code. |
|---|
| 638 | + * |
|---|
| 639 | + * Context: |
|---|
| 640 | + * Kernel context. |
|---|
| 641 | + */ |
|---|
| 642 | +static int qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev) |
|---|
| 643 | +{ |
|---|
| 644 | + int rval; |
|---|
| 645 | + struct qla_hw_data *ha = vha->hw; |
|---|
| 646 | + unsigned long flags = 0; |
|---|
| 647 | + |
|---|
| 648 | + rval = QLA_SUCCESS; |
|---|
| 649 | + |
|---|
| 650 | + spin_lock_irqsave(&ha->vport_slock, flags); |
|---|
| 651 | + |
|---|
| 652 | + dev->loop_id = find_first_zero_bit(ha->loop_id_map, LOOPID_MAP_SIZE); |
|---|
| 653 | + if (dev->loop_id >= LOOPID_MAP_SIZE || |
|---|
| 654 | + qla2x00_is_reserved_id(vha, dev->loop_id)) { |
|---|
| 655 | + dev->loop_id = FC_NO_LOOP_ID; |
|---|
| 656 | + rval = QLA_FUNCTION_FAILED; |
|---|
| 657 | + } else { |
|---|
| 658 | + set_bit(dev->loop_id, ha->loop_id_map); |
|---|
| 659 | + } |
|---|
| 660 | + spin_unlock_irqrestore(&ha->vport_slock, flags); |
|---|
| 661 | + |
|---|
| 662 | + if (rval == QLA_SUCCESS) |
|---|
| 663 | + ql_dbg(ql_dbg_disc, dev->vha, 0x2086, |
|---|
| 664 | + "Assigning new loopid=%x, portid=%x.\n", |
|---|
| 665 | + dev->loop_id, dev->d_id.b24); |
|---|
| 666 | + else |
|---|
| 667 | + ql_log(ql_log_warn, dev->vha, 0x2087, |
|---|
| 668 | + "No loop_id's available, portid=%x.\n", |
|---|
| 669 | + dev->d_id.b24); |
|---|
| 670 | + |
|---|
| 671 | + return rval; |
|---|
| 672 | +} |
|---|
| 673 | + |
|---|
| 674 | +void qla2x00_clear_loop_id(fc_port_t *fcport) |
|---|
| 675 | +{ |
|---|
| 676 | + struct qla_hw_data *ha = fcport->vha->hw; |
|---|
| 677 | + |
|---|
| 678 | + if (fcport->loop_id == FC_NO_LOOP_ID || |
|---|
| 679 | + qla2x00_is_reserved_id(fcport->vha, fcport->loop_id)) |
|---|
| 680 | + return; |
|---|
| 681 | + |
|---|
| 682 | + clear_bit(fcport->loop_id, ha->loop_id_map); |
|---|
| 683 | + fcport->loop_id = FC_NO_LOOP_ID; |
|---|
| 684 | +} |
|---|
| 685 | + |
|---|
| 514 | 686 | static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha, |
|---|
| 515 | 687 | struct event_arg *ea) |
|---|
| 516 | 688 | { |
|---|
| .. | .. |
|---|
| 520 | 692 | port_id_t id; |
|---|
| 521 | 693 | u64 wwn; |
|---|
| 522 | 694 | u16 data[2]; |
|---|
| 523 | | - u8 current_login_state; |
|---|
| 695 | + u8 current_login_state, nvme_cls; |
|---|
| 524 | 696 | |
|---|
| 525 | 697 | fcport = ea->fcport; |
|---|
| 526 | 698 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
|---|
| .. | .. |
|---|
| 543 | 715 | } |
|---|
| 544 | 716 | |
|---|
| 545 | 717 | if (fcport->last_rscn_gen != fcport->rscn_gen) { |
|---|
| 546 | | - ql_dbg(ql_dbg_disc, vha, 0x20df, |
|---|
| 547 | | - "%s %8phC rscn gen changed rscn %d|%d \n", |
|---|
| 548 | | - __func__, fcport->port_name, |
|---|
| 549 | | - fcport->last_rscn_gen, fcport->rscn_gen); |
|---|
| 550 | | - qla24xx_post_gidpn_work(vha, fcport); |
|---|
| 718 | + qla_rscn_replay(fcport); |
|---|
| 719 | + qlt_schedule_sess_for_deletion(fcport); |
|---|
| 551 | 720 | return; |
|---|
| 552 | 721 | } else if (fcport->last_login_gen != fcport->login_gen) { |
|---|
| 553 | 722 | ql_dbg(ql_dbg_disc, vha, 0x20e0, |
|---|
| .. | .. |
|---|
| 582 | 751 | |
|---|
| 583 | 752 | loop_id = le16_to_cpu(e->nport_handle); |
|---|
| 584 | 753 | loop_id = (loop_id & 0x7fff); |
|---|
| 585 | | - if (fcport->fc4f_nvme) |
|---|
| 586 | | - current_login_state = e->current_login_state >> 4; |
|---|
| 587 | | - else |
|---|
| 588 | | - current_login_state = e->current_login_state & 0xf; |
|---|
| 754 | + nvme_cls = e->current_login_state >> 4; |
|---|
| 755 | + current_login_state = e->current_login_state & 0xf; |
|---|
| 589 | 756 | |
|---|
| 757 | + if (PRLI_PHASE(nvme_cls)) { |
|---|
| 758 | + current_login_state = nvme_cls; |
|---|
| 759 | + fcport->fc4_type &= ~FS_FC4TYPE_FCP; |
|---|
| 760 | + fcport->fc4_type |= FS_FC4TYPE_NVME; |
|---|
| 761 | + } else if (PRLI_PHASE(current_login_state)) { |
|---|
| 762 | + fcport->fc4_type |= FS_FC4TYPE_FCP; |
|---|
| 763 | + fcport->fc4_type &= ~FS_FC4TYPE_NVME; |
|---|
| 764 | + } |
|---|
| 590 | 765 | |
|---|
| 591 | 766 | ql_dbg(ql_dbg_disc, vha, 0x20e2, |
|---|
| 592 | | - "%s found %8phC CLS [%x|%x] nvme %d ID[%02x%02x%02x|%02x%02x%02x] lid[%d|%d]\n", |
|---|
| 767 | + "%s found %8phC CLS [%x|%x] fc4_type %d ID[%06x|%06x] lid[%d|%d]\n", |
|---|
| 593 | 768 | __func__, fcport->port_name, |
|---|
| 594 | 769 | e->current_login_state, fcport->fw_login_state, |
|---|
| 595 | | - fcport->fc4f_nvme, id.b.domain, id.b.area, id.b.al_pa, |
|---|
| 596 | | - fcport->d_id.b.domain, fcport->d_id.b.area, |
|---|
| 597 | | - fcport->d_id.b.al_pa, loop_id, fcport->loop_id); |
|---|
| 770 | + fcport->fc4_type, id.b24, fcport->d_id.b24, |
|---|
| 771 | + loop_id, fcport->loop_id); |
|---|
| 598 | 772 | |
|---|
| 599 | 773 | switch (fcport->disc_state) { |
|---|
| 600 | 774 | case DSC_DELETE_PEND: |
|---|
| .. | .. |
|---|
| 602 | 776 | break; |
|---|
| 603 | 777 | default: |
|---|
| 604 | 778 | if ((id.b24 != fcport->d_id.b24 && |
|---|
| 605 | | - fcport->d_id.b24) || |
|---|
| 779 | + fcport->d_id.b24 && |
|---|
| 780 | + fcport->loop_id != FC_NO_LOOP_ID) || |
|---|
| 606 | 781 | (fcport->loop_id != FC_NO_LOOP_ID && |
|---|
| 607 | 782 | fcport->loop_id != loop_id)) { |
|---|
| 608 | 783 | ql_dbg(ql_dbg_disc, vha, 0x20e3, |
|---|
| 609 | 784 | "%s %d %8phC post del sess\n", |
|---|
| 610 | 785 | __func__, __LINE__, fcport->port_name); |
|---|
| 786 | + if (fcport->n2n_flag) |
|---|
| 787 | + fcport->d_id.b24 = 0; |
|---|
| 611 | 788 | qlt_schedule_sess_for_deletion(fcport); |
|---|
| 612 | 789 | return; |
|---|
| 613 | 790 | } |
|---|
| .. | .. |
|---|
| 615 | 792 | } |
|---|
| 616 | 793 | |
|---|
| 617 | 794 | fcport->loop_id = loop_id; |
|---|
| 795 | + if (fcport->n2n_flag) |
|---|
| 796 | + fcport->d_id.b24 = id.b24; |
|---|
| 618 | 797 | |
|---|
| 619 | 798 | wwn = wwn_to_u64(fcport->port_name); |
|---|
| 620 | 799 | qlt_find_sess_invalidate_other(vha, wwn, |
|---|
| .. | .. |
|---|
| 664 | 843 | fcport->fw_login_state = current_login_state; |
|---|
| 665 | 844 | fcport->d_id = id; |
|---|
| 666 | 845 | switch (current_login_state) { |
|---|
| 846 | + case DSC_LS_PRLI_PEND: |
|---|
| 847 | + /* |
|---|
| 848 | + * In the middle of PRLI. Let it finish. |
|---|
| 849 | + * Allow relogin code to recheck state again |
|---|
| 850 | + * with GNL. Push disc_state back to DELETED |
|---|
| 851 | + * so GNL can go out again |
|---|
| 852 | + */ |
|---|
| 853 | + qla2x00_set_fcport_disc_state(fcport, |
|---|
| 854 | + DSC_DELETED); |
|---|
| 855 | + break; |
|---|
| 667 | 856 | case DSC_LS_PRLI_COMP: |
|---|
| 668 | 857 | if ((e->prli_svc_param_word_3[0] & BIT_4) == 0) |
|---|
| 669 | 858 | fcport->port_type = FCT_INITIATOR; |
|---|
| .. | .. |
|---|
| 685 | 874 | fcport); |
|---|
| 686 | 875 | break; |
|---|
| 687 | 876 | } |
|---|
| 688 | | - /* drop through */ |
|---|
| 877 | + fallthrough; |
|---|
| 689 | 878 | default: |
|---|
| 690 | 879 | if (fcport_is_smaller(fcport)) { |
|---|
| 691 | 880 | /* local adapter is bigger */ |
|---|
| .. | .. |
|---|
| 738 | 927 | qla24xx_fcport_handle_login(vha, fcport); |
|---|
| 739 | 928 | break; |
|---|
| 740 | 929 | case ISP_CFG_N: |
|---|
| 741 | | - fcport->disc_state = DSC_DELETED; |
|---|
| 930 | + qla2x00_set_fcport_disc_state(fcport, DSC_DELETED); |
|---|
| 742 | 931 | if (time_after_eq(jiffies, fcport->dm_login_expire)) { |
|---|
| 743 | 932 | if (fcport->n2n_link_reset_cnt < 2) { |
|---|
| 744 | 933 | fcport->n2n_link_reset_cnt++; |
|---|
| .. | .. |
|---|
| 772 | 961 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
|---|
| 773 | 962 | } |
|---|
| 774 | 963 | break; |
|---|
| 964 | + case ISP_CFG_NL: |
|---|
| 965 | + qla24xx_fcport_handle_login(vha, fcport); |
|---|
| 966 | + break; |
|---|
| 775 | 967 | default: |
|---|
| 776 | 968 | break; |
|---|
| 777 | 969 | } |
|---|
| 778 | 970 | } |
|---|
| 779 | 971 | } /* gnl_event */ |
|---|
| 780 | 972 | |
|---|
| 781 | | -static void |
|---|
| 782 | | -qla24xx_async_gnl_sp_done(void *s, int res) |
|---|
| 973 | +static void qla24xx_async_gnl_sp_done(srb_t *sp, int res) |
|---|
| 783 | 974 | { |
|---|
| 784 | | - struct srb *sp = s; |
|---|
| 785 | 975 | struct scsi_qla_host *vha = sp->vha; |
|---|
| 786 | 976 | unsigned long flags; |
|---|
| 787 | 977 | struct fc_port *fcport = NULL, *tf; |
|---|
| .. | .. |
|---|
| 802 | 992 | memset(&ea, 0, sizeof(ea)); |
|---|
| 803 | 993 | ea.sp = sp; |
|---|
| 804 | 994 | ea.rc = res; |
|---|
| 805 | | - ea.event = FCME_GNL_DONE; |
|---|
| 806 | 995 | |
|---|
| 807 | 996 | if (sp->u.iocb_cmd.u.mbx.in_mb[1] >= |
|---|
| 808 | 997 | sizeof(struct get_name_list_extended)) { |
|---|
| .. | .. |
|---|
| 819 | 1008 | set_bit(loop_id, vha->hw->loop_id_map); |
|---|
| 820 | 1009 | wwn = wwn_to_u64(e->port_name); |
|---|
| 821 | 1010 | |
|---|
| 822 | | - ql_dbg(ql_dbg_disc + ql_dbg_verbose, vha, 0x20e8, |
|---|
| 823 | | - "%s %8phC %02x:%02x:%02x state %d/%d lid %x \n", |
|---|
| 824 | | - __func__, (void *)&wwn, e->port_id[2], e->port_id[1], |
|---|
| 1011 | + ql_dbg(ql_dbg_disc, vha, 0x20e8, |
|---|
| 1012 | + "%s %8phC %02x:%02x:%02x CLS %x/%x lid %x \n", |
|---|
| 1013 | + __func__, &wwn, e->port_id[2], e->port_id[1], |
|---|
| 825 | 1014 | e->port_id[0], e->current_login_state, e->last_login_state, |
|---|
| 826 | 1015 | (loop_id & 0x7fff)); |
|---|
| 827 | 1016 | } |
|---|
| .. | .. |
|---|
| 841 | 1030 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
|---|
| 842 | 1031 | ea.fcport = fcport; |
|---|
| 843 | 1032 | |
|---|
| 844 | | - qla2x00_fcport_event_handler(vha, &ea); |
|---|
| 1033 | + qla24xx_handle_gnl_done_event(vha, &ea); |
|---|
| 845 | 1034 | } |
|---|
| 846 | 1035 | |
|---|
| 847 | 1036 | /* create new fcport if fw has knowledge of new sessions */ |
|---|
| .. | .. |
|---|
| 872 | 1061 | __func__, __LINE__, (u8 *)&wwn, id.b24); |
|---|
| 873 | 1062 | wwnn = wwn_to_u64(e->node_name); |
|---|
| 874 | 1063 | qla24xx_post_newsess_work(vha, &id, (u8 *)&wwn, |
|---|
| 875 | | - (u8 *)&wwnn, NULL, FC4_TYPE_UNKNOWN); |
|---|
| 1064 | + (u8 *)&wwnn, NULL, 0); |
|---|
| 876 | 1065 | } |
|---|
| 877 | 1066 | } |
|---|
| 878 | 1067 | |
|---|
| 879 | 1068 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
|---|
| 880 | 1069 | vha->gnl.sent = 0; |
|---|
| 1070 | + if (!list_empty(&vha->gnl.fcports)) { |
|---|
| 1071 | + /* retrigger gnl */ |
|---|
| 1072 | + list_for_each_entry_safe(fcport, tf, &vha->gnl.fcports, |
|---|
| 1073 | + gnl_entry) { |
|---|
| 1074 | + list_del_init(&fcport->gnl_entry); |
|---|
| 1075 | + fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); |
|---|
| 1076 | + if (qla24xx_post_gnl_work(vha, fcport) == QLA_SUCCESS) |
|---|
| 1077 | + break; |
|---|
| 1078 | + } |
|---|
| 1079 | + } |
|---|
| 881 | 1080 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
|---|
| 882 | 1081 | |
|---|
| 883 | 1082 | sp->free(sp); |
|---|
| .. | .. |
|---|
| 899 | 1098 | |
|---|
| 900 | 1099 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
|---|
| 901 | 1100 | fcport->flags |= FCF_ASYNC_SENT; |
|---|
| 902 | | - fcport->disc_state = DSC_GNL; |
|---|
| 1101 | + qla2x00_set_fcport_disc_state(fcport, DSC_GNL); |
|---|
| 903 | 1102 | fcport->last_rscn_gen = fcport->rscn_gen; |
|---|
| 904 | 1103 | fcport->last_login_gen = fcport->login_gen; |
|---|
| 905 | 1104 | |
|---|
| .. | .. |
|---|
| 936 | 1135 | |
|---|
| 937 | 1136 | sp->done = qla24xx_async_gnl_sp_done; |
|---|
| 938 | 1137 | |
|---|
| 939 | | - rval = qla2x00_start_sp(sp); |
|---|
| 940 | | - if (rval != QLA_SUCCESS) |
|---|
| 941 | | - goto done_free_sp; |
|---|
| 942 | | - |
|---|
| 943 | 1138 | ql_dbg(ql_dbg_disc, vha, 0x20da, |
|---|
| 944 | 1139 | "Async-%s - OUT WWPN %8phC hndl %x\n", |
|---|
| 945 | 1140 | sp->name, fcport->port_name, sp->handle); |
|---|
| 1141 | + |
|---|
| 1142 | + rval = qla2x00_start_sp(sp); |
|---|
| 1143 | + if (rval != QLA_SUCCESS) |
|---|
| 1144 | + goto done_free_sp; |
|---|
| 946 | 1145 | |
|---|
| 947 | 1146 | return rval; |
|---|
| 948 | 1147 | |
|---|
| 949 | 1148 | done_free_sp: |
|---|
| 950 | 1149 | sp->free(sp); |
|---|
| 951 | | - fcport->flags &= ~FCF_ASYNC_SENT; |
|---|
| 952 | 1150 | done: |
|---|
| 1151 | + fcport->flags &= ~(FCF_ASYNC_ACTIVE | FCF_ASYNC_SENT); |
|---|
| 953 | 1152 | return rval; |
|---|
| 954 | 1153 | } |
|---|
| 955 | 1154 | |
|---|
| .. | .. |
|---|
| 963 | 1162 | |
|---|
| 964 | 1163 | e->u.fcport.fcport = fcport; |
|---|
| 965 | 1164 | fcport->flags |= FCF_ASYNC_ACTIVE; |
|---|
| 966 | | - fcport->disc_state = DSC_LOGIN_PEND; |
|---|
| 967 | 1165 | return qla2x00_post_work(vha, e); |
|---|
| 968 | 1166 | } |
|---|
| 969 | 1167 | |
|---|
| 970 | | -static |
|---|
| 971 | | -void qla24xx_async_gpdb_sp_done(void *s, int res) |
|---|
| 1168 | +static void qla24xx_async_gpdb_sp_done(srb_t *sp, int res) |
|---|
| 972 | 1169 | { |
|---|
| 973 | | - struct srb *sp = s; |
|---|
| 974 | 1170 | struct scsi_qla_host *vha = sp->vha; |
|---|
| 975 | 1171 | struct qla_hw_data *ha = vha->hw; |
|---|
| 976 | 1172 | fc_port_t *fcport = sp->fcport; |
|---|
| .. | .. |
|---|
| 987 | 1183 | goto done; |
|---|
| 988 | 1184 | |
|---|
| 989 | 1185 | memset(&ea, 0, sizeof(ea)); |
|---|
| 990 | | - ea.event = FCME_GPDB_DONE; |
|---|
| 991 | 1186 | ea.fcport = fcport; |
|---|
| 992 | 1187 | ea.sp = sp; |
|---|
| 993 | 1188 | |
|---|
| 994 | | - qla2x00_fcport_event_handler(vha, &ea); |
|---|
| 1189 | + qla24xx_handle_gpdb_event(vha, &ea); |
|---|
| 995 | 1190 | |
|---|
| 996 | 1191 | done: |
|---|
| 997 | 1192 | dma_pool_free(ha->s_dma_pool, sp->u.iocb_cmd.u.mbx.in, |
|---|
| .. | .. |
|---|
| 1004 | 1199 | { |
|---|
| 1005 | 1200 | struct qla_work_evt *e; |
|---|
| 1006 | 1201 | |
|---|
| 1202 | + if (vha->host->active_mode == MODE_TARGET) |
|---|
| 1203 | + return QLA_FUNCTION_FAILED; |
|---|
| 1204 | + |
|---|
| 1007 | 1205 | e = qla2x00_alloc_work(vha, QLA_EVT_PRLI); |
|---|
| 1008 | 1206 | if (!e) |
|---|
| 1009 | 1207 | return QLA_FUNCTION_FAILED; |
|---|
| .. | .. |
|---|
| 1013 | 1211 | return qla2x00_post_work(vha, e); |
|---|
| 1014 | 1212 | } |
|---|
| 1015 | 1213 | |
|---|
| 1016 | | -static void |
|---|
| 1017 | | -qla2x00_async_prli_sp_done(void *ptr, int res) |
|---|
| 1214 | +static void qla2x00_async_prli_sp_done(srb_t *sp, int res) |
|---|
| 1018 | 1215 | { |
|---|
| 1019 | | - srb_t *sp = ptr; |
|---|
| 1020 | 1216 | struct scsi_qla_host *vha = sp->vha; |
|---|
| 1021 | 1217 | struct srb_iocb *lio = &sp->u.iocb_cmd; |
|---|
| 1022 | 1218 | struct event_arg ea; |
|---|
| .. | .. |
|---|
| 1029 | 1225 | |
|---|
| 1030 | 1226 | if (!test_bit(UNLOADING, &vha->dpc_flags)) { |
|---|
| 1031 | 1227 | memset(&ea, 0, sizeof(ea)); |
|---|
| 1032 | | - ea.event = FCME_PRLI_DONE; |
|---|
| 1033 | 1228 | ea.fcport = sp->fcport; |
|---|
| 1034 | 1229 | ea.data[0] = lio->u.logio.data[0]; |
|---|
| 1035 | 1230 | ea.data[1] = lio->u.logio.data[1]; |
|---|
| .. | .. |
|---|
| 1037 | 1232 | ea.iop[1] = lio->u.logio.iop[1]; |
|---|
| 1038 | 1233 | ea.sp = sp; |
|---|
| 1039 | 1234 | |
|---|
| 1040 | | - qla2x00_fcport_event_handler(vha, &ea); |
|---|
| 1235 | + qla24xx_handle_prli_done_event(vha, &ea); |
|---|
| 1041 | 1236 | } |
|---|
| 1042 | 1237 | |
|---|
| 1043 | 1238 | sp->free(sp); |
|---|
| .. | .. |
|---|
| 1050 | 1245 | struct srb_iocb *lio; |
|---|
| 1051 | 1246 | int rval = QLA_FUNCTION_FAILED; |
|---|
| 1052 | 1247 | |
|---|
| 1053 | | - if (!vha->flags.online) |
|---|
| 1248 | + if (!vha->flags.online) { |
|---|
| 1249 | + ql_dbg(ql_dbg_disc, vha, 0xffff, "%s %d %8phC exit\n", |
|---|
| 1250 | + __func__, __LINE__, fcport->port_name); |
|---|
| 1054 | 1251 | return rval; |
|---|
| 1252 | + } |
|---|
| 1055 | 1253 | |
|---|
| 1056 | | - if (fcport->fw_login_state == DSC_LS_PLOGI_PEND || |
|---|
| 1057 | | - fcport->fw_login_state == DSC_LS_PRLI_PEND) |
|---|
| 1254 | + if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND || |
|---|
| 1255 | + fcport->fw_login_state == DSC_LS_PRLI_PEND) && |
|---|
| 1256 | + qla_dual_mode_enabled(vha)) { |
|---|
| 1257 | + ql_dbg(ql_dbg_disc, vha, 0xffff, "%s %d %8phC exit\n", |
|---|
| 1258 | + __func__, __LINE__, fcport->port_name); |
|---|
| 1058 | 1259 | return rval; |
|---|
| 1260 | + } |
|---|
| 1059 | 1261 | |
|---|
| 1060 | 1262 | sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); |
|---|
| 1061 | 1263 | if (!sp) |
|---|
| .. | .. |
|---|
| 1074 | 1276 | sp->done = qla2x00_async_prli_sp_done; |
|---|
| 1075 | 1277 | lio->u.logio.flags = 0; |
|---|
| 1076 | 1278 | |
|---|
| 1077 | | - if (fcport->fc4f_nvme) |
|---|
| 1279 | + if (NVME_TARGET(vha->hw, fcport)) |
|---|
| 1078 | 1280 | lio->u.logio.flags |= SRB_LOGIN_NVME_PRLI; |
|---|
| 1281 | + |
|---|
| 1282 | + ql_dbg(ql_dbg_disc, vha, 0x211b, |
|---|
| 1283 | + "Async-prli - %8phC hdl=%x, loopid=%x portid=%06x retries=%d fc4type %x priority %x %s.\n", |
|---|
| 1284 | + fcport->port_name, sp->handle, fcport->loop_id, fcport->d_id.b24, |
|---|
| 1285 | + fcport->login_retry, fcport->fc4_type, vha->hw->fc4_type_priority, |
|---|
| 1286 | + NVME_TARGET(vha->hw, fcport) ? "nvme" : "fcp"); |
|---|
| 1079 | 1287 | |
|---|
| 1080 | 1288 | rval = qla2x00_start_sp(sp); |
|---|
| 1081 | 1289 | if (rval != QLA_SUCCESS) { |
|---|
| .. | .. |
|---|
| 1083 | 1291 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
|---|
| 1084 | 1292 | goto done_free_sp; |
|---|
| 1085 | 1293 | } |
|---|
| 1086 | | - |
|---|
| 1087 | | - ql_dbg(ql_dbg_disc, vha, 0x211b, |
|---|
| 1088 | | - "Async-prli - %8phC hdl=%x, loopid=%x portid=%06x retries=%d %s.\n", |
|---|
| 1089 | | - fcport->port_name, sp->handle, fcport->loop_id, fcport->d_id.b24, |
|---|
| 1090 | | - fcport->login_retry, fcport->fc4f_nvme ? "nvme" : "fc"); |
|---|
| 1091 | 1294 | |
|---|
| 1092 | 1295 | return rval; |
|---|
| 1093 | 1296 | |
|---|
| .. | .. |
|---|
| 1121 | 1324 | struct port_database_24xx *pd; |
|---|
| 1122 | 1325 | struct qla_hw_data *ha = vha->hw; |
|---|
| 1123 | 1326 | |
|---|
| 1124 | | - if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT) || |
|---|
| 1125 | | - fcport->loop_id == FC_NO_LOOP_ID) { |
|---|
| 1327 | + if (IS_SESSION_DELETED(fcport)) { |
|---|
| 1126 | 1328 | ql_log(ql_log_warn, vha, 0xffff, |
|---|
| 1127 | | - "%s: %8phC - not sending command.\n", |
|---|
| 1128 | | - __func__, fcport->port_name); |
|---|
| 1329 | + "%s: %8phC is being delete - not sending command.\n", |
|---|
| 1330 | + __func__, fcport->port_name); |
|---|
| 1331 | + fcport->flags &= ~FCF_ASYNC_ACTIVE; |
|---|
| 1129 | 1332 | return rval; |
|---|
| 1130 | 1333 | } |
|---|
| 1131 | 1334 | |
|---|
| 1132 | | - fcport->disc_state = DSC_GPDB; |
|---|
| 1335 | + if (!vha->flags.online || fcport->flags & FCF_ASYNC_SENT) { |
|---|
| 1336 | + ql_log(ql_log_warn, vha, 0xffff, |
|---|
| 1337 | + "%s: %8phC online %d flags %x - not sending command.\n", |
|---|
| 1338 | + __func__, fcport->port_name, vha->flags.online, fcport->flags); |
|---|
| 1339 | + goto done; |
|---|
| 1340 | + } |
|---|
| 1133 | 1341 | |
|---|
| 1134 | 1342 | sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); |
|---|
| 1135 | 1343 | if (!sp) |
|---|
| 1136 | 1344 | goto done; |
|---|
| 1345 | + |
|---|
| 1346 | + qla2x00_set_fcport_disc_state(fcport, DSC_GPDB); |
|---|
| 1137 | 1347 | |
|---|
| 1138 | 1348 | fcport->flags |= FCF_ASYNC_SENT; |
|---|
| 1139 | 1349 | sp->type = SRB_MB_IOCB; |
|---|
| .. | .. |
|---|
| 1162 | 1372 | mb[9] = vha->vp_idx; |
|---|
| 1163 | 1373 | mb[10] = opt; |
|---|
| 1164 | 1374 | |
|---|
| 1165 | | - mbx->u.mbx.in = (void *)pd; |
|---|
| 1375 | + mbx->u.mbx.in = pd; |
|---|
| 1166 | 1376 | mbx->u.mbx.in_dma = pd_dma; |
|---|
| 1167 | 1377 | |
|---|
| 1168 | 1378 | sp->done = qla24xx_async_gpdb_sp_done; |
|---|
| .. | .. |
|---|
| 1183 | 1393 | sp->free(sp); |
|---|
| 1184 | 1394 | fcport->flags &= ~FCF_ASYNC_SENT; |
|---|
| 1185 | 1395 | done: |
|---|
| 1396 | + fcport->flags &= ~FCF_ASYNC_ACTIVE; |
|---|
| 1186 | 1397 | qla24xx_post_gpdb_work(vha, fcport, opt); |
|---|
| 1187 | 1398 | return rval; |
|---|
| 1188 | 1399 | } |
|---|
| .. | .. |
|---|
| 1213 | 1424 | ql_dbg(ql_dbg_disc, vha, 0x20d6, |
|---|
| 1214 | 1425 | "%s %d %8phC session revalidate success\n", |
|---|
| 1215 | 1426 | __func__, __LINE__, ea->fcport->port_name); |
|---|
| 1216 | | - ea->fcport->disc_state = DSC_LOGIN_COMPLETE; |
|---|
| 1427 | + qla2x00_set_fcport_disc_state(ea->fcport, DSC_LOGIN_COMPLETE); |
|---|
| 1217 | 1428 | } |
|---|
| 1218 | 1429 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
|---|
| 1219 | 1430 | } |
|---|
| .. | .. |
|---|
| 1231 | 1442 | fcport->flags &= ~FCF_ASYNC_SENT; |
|---|
| 1232 | 1443 | |
|---|
| 1233 | 1444 | ql_dbg(ql_dbg_disc, vha, 0x20d2, |
|---|
| 1234 | | - "%s %8phC DS %d LS %d nvme %x rc %d\n", __func__, fcport->port_name, |
|---|
| 1235 | | - fcport->disc_state, pd->current_login_state, fcport->fc4f_nvme, |
|---|
| 1236 | | - ea->rc); |
|---|
| 1445 | + "%s %8phC DS %d LS %d fc4_type %x rc %d\n", __func__, |
|---|
| 1446 | + fcport->port_name, fcport->disc_state, pd->current_login_state, |
|---|
| 1447 | + fcport->fc4_type, ea->rc); |
|---|
| 1237 | 1448 | |
|---|
| 1238 | 1449 | if (fcport->disc_state == DSC_DELETE_PEND) |
|---|
| 1239 | 1450 | return; |
|---|
| 1240 | 1451 | |
|---|
| 1241 | | - if (fcport->fc4f_nvme) |
|---|
| 1452 | + if (NVME_TARGET(vha->hw, fcport)) |
|---|
| 1242 | 1453 | ls = pd->current_login_state >> 4; |
|---|
| 1243 | 1454 | else |
|---|
| 1244 | 1455 | ls = pd->current_login_state & 0xf; |
|---|
| 1456 | + |
|---|
| 1457 | + if (ea->sp->gen2 != fcport->login_gen) { |
|---|
| 1458 | + /* target side must have changed it. */ |
|---|
| 1459 | + |
|---|
| 1460 | + ql_dbg(ql_dbg_disc, vha, 0x20d3, |
|---|
| 1461 | + "%s %8phC generation changed\n", |
|---|
| 1462 | + __func__, fcport->port_name); |
|---|
| 1463 | + return; |
|---|
| 1464 | + } else if (ea->sp->gen1 != fcport->rscn_gen) { |
|---|
| 1465 | + qla_rscn_replay(fcport); |
|---|
| 1466 | + qlt_schedule_sess_for_deletion(fcport); |
|---|
| 1467 | + return; |
|---|
| 1468 | + } |
|---|
| 1245 | 1469 | |
|---|
| 1246 | 1470 | switch (ls) { |
|---|
| 1247 | 1471 | case PDS_PRLI_COMPLETE: |
|---|
| .. | .. |
|---|
| 1254 | 1478 | /* Set discovery state back to GNL to Relogin attempt */ |
|---|
| 1255 | 1479 | if (qla_dual_mode_enabled(vha) || |
|---|
| 1256 | 1480 | qla_ini_mode_enabled(vha)) { |
|---|
| 1257 | | - fcport->disc_state = DSC_GNL; |
|---|
| 1481 | + qla2x00_set_fcport_disc_state(fcport, DSC_GNL); |
|---|
| 1258 | 1482 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
|---|
| 1259 | 1483 | } |
|---|
| 1260 | 1484 | return; |
|---|
| .. | .. |
|---|
| 1273 | 1497 | { |
|---|
| 1274 | 1498 | u8 login = 0; |
|---|
| 1275 | 1499 | int rc; |
|---|
| 1500 | + |
|---|
| 1501 | + ql_dbg(ql_dbg_disc, vha, 0x307b, |
|---|
| 1502 | + "%s %8phC DS %d LS %d lid %d retries=%d\n", |
|---|
| 1503 | + __func__, fcport->port_name, fcport->disc_state, |
|---|
| 1504 | + fcport->fw_login_state, fcport->loop_id, fcport->login_retry); |
|---|
| 1276 | 1505 | |
|---|
| 1277 | 1506 | if (qla_tgt_mode_enabled(vha)) |
|---|
| 1278 | 1507 | return; |
|---|
| .. | .. |
|---|
| 1297 | 1526 | login = 1; |
|---|
| 1298 | 1527 | } |
|---|
| 1299 | 1528 | |
|---|
| 1300 | | - if (login) { |
|---|
| 1529 | + if (login && fcport->login_retry) { |
|---|
| 1530 | + fcport->login_retry--; |
|---|
| 1301 | 1531 | if (fcport->loop_id == FC_NO_LOOP_ID) { |
|---|
| 1302 | 1532 | fcport->fw_login_state = DSC_LS_PORT_UNAVAIL; |
|---|
| 1303 | 1533 | rc = qla2x00_find_new_loop_id(vha, fcport); |
|---|
| .. | .. |
|---|
| 1324 | 1554 | u16 sec; |
|---|
| 1325 | 1555 | |
|---|
| 1326 | 1556 | ql_dbg(ql_dbg_disc, vha, 0x20d8, |
|---|
| 1327 | | - "%s %8phC DS %d LS %d P %d fl %x confl %p rscn %d|%d login %d retry %d lid %d scan %d\n", |
|---|
| 1557 | + "%s %8phC DS %d LS %d P %d fl %x confl %p rscn %d|%d login %d lid %d scan %d\n", |
|---|
| 1328 | 1558 | __func__, fcport->port_name, fcport->disc_state, |
|---|
| 1329 | 1559 | fcport->fw_login_state, fcport->login_pause, fcport->flags, |
|---|
| 1330 | 1560 | fcport->conflict, fcport->last_rscn_gen, fcport->rscn_gen, |
|---|
| 1331 | | - fcport->login_gen, fcport->login_retry, |
|---|
| 1332 | | - fcport->loop_id, fcport->scan_state); |
|---|
| 1561 | + fcport->login_gen, fcport->loop_id, fcport->scan_state); |
|---|
| 1333 | 1562 | |
|---|
| 1334 | | - if (fcport->scan_state != QLA_FCPORT_FOUND) |
|---|
| 1563 | + if (fcport->scan_state != QLA_FCPORT_FOUND || |
|---|
| 1564 | + fcport->disc_state == DSC_DELETE_PEND) |
|---|
| 1335 | 1565 | return 0; |
|---|
| 1336 | 1566 | |
|---|
| 1337 | 1567 | if ((fcport->loop_id != FC_NO_LOOP_ID) && |
|---|
| 1568 | + qla_dual_mode_enabled(vha) && |
|---|
| 1338 | 1569 | ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) || |
|---|
| 1339 | 1570 | (fcport->fw_login_state == DSC_LS_PRLI_PEND))) |
|---|
| 1340 | 1571 | return 0; |
|---|
| 1341 | 1572 | |
|---|
| 1342 | | - if (fcport->fw_login_state == DSC_LS_PLOGI_COMP) { |
|---|
| 1573 | + if (fcport->fw_login_state == DSC_LS_PLOGI_COMP && |
|---|
| 1574 | + !N2N_TOPO(vha->hw)) { |
|---|
| 1343 | 1575 | if (time_before_eq(jiffies, fcport->plogi_nack_done_deadline)) { |
|---|
| 1344 | 1576 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
|---|
| 1345 | 1577 | return 0; |
|---|
| 1346 | 1578 | } |
|---|
| 1347 | 1579 | } |
|---|
| 1348 | 1580 | |
|---|
| 1349 | | - /* for pure Target Mode. Login will not be initiated */ |
|---|
| 1350 | | - if (vha->host->active_mode == MODE_TARGET) |
|---|
| 1581 | + /* Target won't initiate port login if fabric is present */ |
|---|
| 1582 | + if (vha->host->active_mode == MODE_TARGET && !N2N_TOPO(vha->hw)) |
|---|
| 1351 | 1583 | return 0; |
|---|
| 1352 | 1584 | |
|---|
| 1353 | | - if (fcport->flags & FCF_ASYNC_SENT) { |
|---|
| 1585 | + if (fcport->flags & (FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE)) { |
|---|
| 1354 | 1586 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
|---|
| 1355 | 1587 | return 0; |
|---|
| 1356 | 1588 | } |
|---|
| .. | .. |
|---|
| 1410 | 1642 | qla24xx_post_gpdb_work(vha, fcport, 0); |
|---|
| 1411 | 1643 | } else { |
|---|
| 1412 | 1644 | ql_dbg(ql_dbg_disc, vha, 0x2118, |
|---|
| 1413 | | - "%s %d %8phC post NVMe PRLI\n", |
|---|
| 1414 | | - __func__, __LINE__, fcport->port_name); |
|---|
| 1645 | + "%s %d %8phC post %s PRLI\n", |
|---|
| 1646 | + __func__, __LINE__, fcport->port_name, |
|---|
| 1647 | + NVME_TARGET(vha->hw, fcport) ? "NVME" : |
|---|
| 1648 | + "FC"); |
|---|
| 1415 | 1649 | qla24xx_post_prli_work(vha, fcport); |
|---|
| 1416 | 1650 | } |
|---|
| 1417 | 1651 | break; |
|---|
| 1418 | 1652 | default: |
|---|
| 1419 | 1653 | if (fcport->login_pause) { |
|---|
| 1654 | + ql_dbg(ql_dbg_disc, vha, 0x20d8, |
|---|
| 1655 | + "%s %d %8phC exit\n", |
|---|
| 1656 | + __func__, __LINE__, |
|---|
| 1657 | + fcport->port_name); |
|---|
| 1420 | 1658 | fcport->last_rscn_gen = fcport->rscn_gen; |
|---|
| 1421 | 1659 | fcport->last_login_gen = fcport->login_gen; |
|---|
| 1422 | 1660 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
|---|
| .. | .. |
|---|
| 1428 | 1666 | break; |
|---|
| 1429 | 1667 | |
|---|
| 1430 | 1668 | case DSC_LOGIN_FAILED: |
|---|
| 1431 | | - fcport->login_retry--; |
|---|
| 1432 | | - ql_dbg(ql_dbg_disc, vha, 0x20d0, |
|---|
| 1433 | | - "%s %d %8phC post gidpn\n", |
|---|
| 1434 | | - __func__, __LINE__, fcport->port_name); |
|---|
| 1435 | 1669 | if (N2N_TOPO(vha->hw)) |
|---|
| 1436 | 1670 | qla_chk_n2n_b4_login(vha, fcport); |
|---|
| 1437 | 1671 | else |
|---|
| 1438 | | - qla24xx_post_gidpn_work(vha, fcport); |
|---|
| 1672 | + qlt_schedule_sess_for_deletion(fcport); |
|---|
| 1439 | 1673 | break; |
|---|
| 1440 | 1674 | |
|---|
| 1441 | 1675 | case DSC_LOGIN_COMPLETE: |
|---|
| 1442 | 1676 | /* recheck login state */ |
|---|
| 1443 | | - ql_dbg(ql_dbg_disc, vha, 0x20d1, |
|---|
| 1444 | | - "%s %d %8phC post adisc\n", |
|---|
| 1445 | | - __func__, __LINE__, fcport->port_name); |
|---|
| 1446 | | - fcport->login_retry--; |
|---|
| 1447 | 1677 | data[0] = data[1] = 0; |
|---|
| 1448 | 1678 | qla2x00_post_async_adisc_work(vha, fcport, data); |
|---|
| 1449 | 1679 | break; |
|---|
| .. | .. |
|---|
| 1476 | 1706 | return 0; |
|---|
| 1477 | 1707 | } |
|---|
| 1478 | 1708 | |
|---|
| 1479 | | -static |
|---|
| 1480 | | -void qla24xx_handle_rscn_event(fc_port_t *fcport, struct event_arg *ea) |
|---|
| 1481 | | -{ |
|---|
| 1482 | | - fcport->rscn_gen++; |
|---|
| 1483 | | - |
|---|
| 1484 | | - ql_dbg(ql_dbg_disc, fcport->vha, 0x210c, |
|---|
| 1485 | | - "%s %8phC DS %d LS %d\n", |
|---|
| 1486 | | - __func__, fcport->port_name, fcport->disc_state, |
|---|
| 1487 | | - fcport->fw_login_state); |
|---|
| 1488 | | - |
|---|
| 1489 | | - if (fcport->flags & FCF_ASYNC_SENT) |
|---|
| 1490 | | - return; |
|---|
| 1491 | | - |
|---|
| 1492 | | - switch (fcport->disc_state) { |
|---|
| 1493 | | - case DSC_DELETED: |
|---|
| 1494 | | - case DSC_LOGIN_COMPLETE: |
|---|
| 1495 | | - qla24xx_post_gpnid_work(fcport->vha, &ea->id); |
|---|
| 1496 | | - break; |
|---|
| 1497 | | - default: |
|---|
| 1498 | | - break; |
|---|
| 1499 | | - } |
|---|
| 1500 | | -} |
|---|
| 1501 | | - |
|---|
| 1502 | 1709 | int qla24xx_post_newsess_work(struct scsi_qla_host *vha, port_id_t *id, |
|---|
| 1503 | 1710 | u8 *port_name, u8 *node_name, void *pla, u8 fc4_type) |
|---|
| 1504 | 1711 | { |
|---|
| 1505 | 1712 | struct qla_work_evt *e; |
|---|
| 1713 | + |
|---|
| 1506 | 1714 | e = qla2x00_alloc_work(vha, QLA_EVT_NEW_SESS); |
|---|
| 1507 | 1715 | if (!e) |
|---|
| 1508 | 1716 | return QLA_FUNCTION_FAILED; |
|---|
| .. | .. |
|---|
| 1517 | 1725 | return qla2x00_post_work(vha, e); |
|---|
| 1518 | 1726 | } |
|---|
| 1519 | 1727 | |
|---|
| 1520 | | -static |
|---|
| 1728 | +void qla2x00_handle_rscn(scsi_qla_host_t *vha, struct event_arg *ea) |
|---|
| 1729 | +{ |
|---|
| 1730 | + fc_port_t *fcport; |
|---|
| 1731 | + unsigned long flags; |
|---|
| 1732 | + |
|---|
| 1733 | + switch (ea->id.b.rsvd_1) { |
|---|
| 1734 | + case RSCN_PORT_ADDR: |
|---|
| 1735 | + fcport = qla2x00_find_fcport_by_nportid(vha, &ea->id, 1); |
|---|
| 1736 | + if (fcport) { |
|---|
| 1737 | + if (fcport->flags & FCF_FCP2_DEVICE && |
|---|
| 1738 | + atomic_read(&fcport->state) == FCS_ONLINE) { |
|---|
| 1739 | + ql_dbg(ql_dbg_disc, vha, 0x2115, |
|---|
| 1740 | + "Delaying session delete for FCP2 portid=%06x %8phC ", |
|---|
| 1741 | + fcport->d_id.b24, fcport->port_name); |
|---|
| 1742 | + return; |
|---|
| 1743 | + } |
|---|
| 1744 | + fcport->scan_needed = 1; |
|---|
| 1745 | + fcport->rscn_gen++; |
|---|
| 1746 | + } |
|---|
| 1747 | + break; |
|---|
| 1748 | + case RSCN_AREA_ADDR: |
|---|
| 1749 | + list_for_each_entry(fcport, &vha->vp_fcports, list) { |
|---|
| 1750 | + if (fcport->flags & FCF_FCP2_DEVICE && |
|---|
| 1751 | + atomic_read(&fcport->state) == FCS_ONLINE) |
|---|
| 1752 | + continue; |
|---|
| 1753 | + |
|---|
| 1754 | + if ((ea->id.b24 & 0xffff00) == (fcport->d_id.b24 & 0xffff00)) { |
|---|
| 1755 | + fcport->scan_needed = 1; |
|---|
| 1756 | + fcport->rscn_gen++; |
|---|
| 1757 | + } |
|---|
| 1758 | + } |
|---|
| 1759 | + break; |
|---|
| 1760 | + case RSCN_DOM_ADDR: |
|---|
| 1761 | + list_for_each_entry(fcport, &vha->vp_fcports, list) { |
|---|
| 1762 | + if (fcport->flags & FCF_FCP2_DEVICE && |
|---|
| 1763 | + atomic_read(&fcport->state) == FCS_ONLINE) |
|---|
| 1764 | + continue; |
|---|
| 1765 | + |
|---|
| 1766 | + if ((ea->id.b24 & 0xff0000) == (fcport->d_id.b24 & 0xff0000)) { |
|---|
| 1767 | + fcport->scan_needed = 1; |
|---|
| 1768 | + fcport->rscn_gen++; |
|---|
| 1769 | + } |
|---|
| 1770 | + } |
|---|
| 1771 | + break; |
|---|
| 1772 | + case RSCN_FAB_ADDR: |
|---|
| 1773 | + default: |
|---|
| 1774 | + list_for_each_entry(fcport, &vha->vp_fcports, list) { |
|---|
| 1775 | + if (fcport->flags & FCF_FCP2_DEVICE && |
|---|
| 1776 | + atomic_read(&fcport->state) == FCS_ONLINE) |
|---|
| 1777 | + continue; |
|---|
| 1778 | + |
|---|
| 1779 | + fcport->scan_needed = 1; |
|---|
| 1780 | + fcport->rscn_gen++; |
|---|
| 1781 | + } |
|---|
| 1782 | + break; |
|---|
| 1783 | + } |
|---|
| 1784 | + |
|---|
| 1785 | + spin_lock_irqsave(&vha->work_lock, flags); |
|---|
| 1786 | + if (vha->scan.scan_flags == 0) { |
|---|
| 1787 | + ql_dbg(ql_dbg_disc, vha, 0xffff, "%s: schedule\n", __func__); |
|---|
| 1788 | + vha->scan.scan_flags |= SF_QUEUED; |
|---|
| 1789 | + schedule_delayed_work(&vha->scan.scan_work, 5); |
|---|
| 1790 | + } |
|---|
| 1791 | + spin_unlock_irqrestore(&vha->work_lock, flags); |
|---|
| 1792 | +} |
|---|
| 1793 | + |
|---|
| 1521 | 1794 | void qla24xx_handle_relogin_event(scsi_qla_host_t *vha, |
|---|
| 1522 | 1795 | struct event_arg *ea) |
|---|
| 1523 | 1796 | { |
|---|
| 1524 | 1797 | fc_port_t *fcport = ea->fcport; |
|---|
| 1798 | + |
|---|
| 1799 | + if (test_bit(UNLOADING, &vha->dpc_flags)) |
|---|
| 1800 | + return; |
|---|
| 1525 | 1801 | |
|---|
| 1526 | 1802 | ql_dbg(ql_dbg_disc, vha, 0x2102, |
|---|
| 1527 | 1803 | "%s %8phC DS %d LS %d P %d del %d cnfl %p rscn %d|%d login %d|%d fl %x\n", |
|---|
| .. | .. |
|---|
| 1532 | 1808 | fcport->last_login_gen, fcport->login_gen, |
|---|
| 1533 | 1809 | fcport->flags); |
|---|
| 1534 | 1810 | |
|---|
| 1535 | | - if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) || |
|---|
| 1536 | | - (fcport->fw_login_state == DSC_LS_PRLI_PEND)) |
|---|
| 1537 | | - return; |
|---|
| 1538 | | - |
|---|
| 1539 | | - if (fcport->fw_login_state == DSC_LS_PLOGI_COMP) { |
|---|
| 1540 | | - if (time_before_eq(jiffies, fcport->plogi_nack_done_deadline)) { |
|---|
| 1541 | | - set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
|---|
| 1542 | | - return; |
|---|
| 1543 | | - } |
|---|
| 1544 | | - } |
|---|
| 1545 | | - |
|---|
| 1546 | 1811 | if (fcport->last_rscn_gen != fcport->rscn_gen) { |
|---|
| 1547 | | - ql_dbg(ql_dbg_disc, vha, 0x20e9, "%s %d %8phC post gidpn\n", |
|---|
| 1812 | + ql_dbg(ql_dbg_disc, vha, 0x20e9, "%s %d %8phC post gnl\n", |
|---|
| 1548 | 1813 | __func__, __LINE__, fcport->port_name); |
|---|
| 1549 | | - |
|---|
| 1550 | | - qla24xx_post_gidpn_work(vha, fcport); |
|---|
| 1814 | + qla24xx_post_gnl_work(vha, fcport); |
|---|
| 1551 | 1815 | return; |
|---|
| 1552 | 1816 | } |
|---|
| 1553 | 1817 | |
|---|
| 1554 | 1818 | qla24xx_fcport_handle_login(vha, fcport); |
|---|
| 1555 | 1819 | } |
|---|
| 1556 | 1820 | |
|---|
| 1557 | | - |
|---|
| 1558 | | -void qla_handle_els_plogi_done(scsi_qla_host_t *vha, struct event_arg *ea) |
|---|
| 1821 | +void qla_handle_els_plogi_done(scsi_qla_host_t *vha, |
|---|
| 1822 | + struct event_arg *ea) |
|---|
| 1559 | 1823 | { |
|---|
| 1824 | + /* for pure Target Mode, PRLI will not be initiated */ |
|---|
| 1825 | + if (vha->host->active_mode == MODE_TARGET) |
|---|
| 1826 | + return; |
|---|
| 1827 | + |
|---|
| 1560 | 1828 | ql_dbg(ql_dbg_disc, vha, 0x2118, |
|---|
| 1561 | 1829 | "%s %d %8phC post PRLI\n", |
|---|
| 1562 | 1830 | __func__, __LINE__, ea->fcport->port_name); |
|---|
| 1563 | 1831 | qla24xx_post_prli_work(vha, ea->fcport); |
|---|
| 1564 | 1832 | } |
|---|
| 1565 | 1833 | |
|---|
| 1566 | | -void qla2x00_fcport_event_handler(scsi_qla_host_t *vha, struct event_arg *ea) |
|---|
| 1834 | +/* |
|---|
| 1835 | + * RSCN(s) came in for this fcport, but the RSCN(s) was not able |
|---|
| 1836 | + * to be consumed by the fcport |
|---|
| 1837 | + */ |
|---|
| 1838 | +void qla_rscn_replay(fc_port_t *fcport) |
|---|
| 1567 | 1839 | { |
|---|
| 1568 | | - fc_port_t *f, *tf; |
|---|
| 1569 | | - uint32_t id = 0, mask, rid; |
|---|
| 1570 | | - unsigned long flags; |
|---|
| 1571 | | - fc_port_t *fcport; |
|---|
| 1840 | + struct event_arg ea; |
|---|
| 1572 | 1841 | |
|---|
| 1573 | | - switch (ea->event) { |
|---|
| 1574 | | - case FCME_RELOGIN: |
|---|
| 1575 | | - if (test_bit(UNLOADING, &vha->dpc_flags)) |
|---|
| 1576 | | - return; |
|---|
| 1577 | | - |
|---|
| 1578 | | - qla24xx_handle_relogin_event(vha, ea); |
|---|
| 1579 | | - break; |
|---|
| 1580 | | - case FCME_RSCN: |
|---|
| 1581 | | - if (test_bit(UNLOADING, &vha->dpc_flags)) |
|---|
| 1582 | | - return; |
|---|
| 1583 | | - switch (ea->id.b.rsvd_1) { |
|---|
| 1584 | | - case RSCN_PORT_ADDR: |
|---|
| 1585 | | - fcport = qla2x00_find_fcport_by_nportid |
|---|
| 1586 | | - (vha, &ea->id, 1); |
|---|
| 1587 | | - if (fcport) { |
|---|
| 1588 | | - fcport->scan_needed = 1; |
|---|
| 1589 | | - fcport->rscn_gen++; |
|---|
| 1590 | | - } |
|---|
| 1591 | | - |
|---|
| 1592 | | - spin_lock_irqsave(&vha->work_lock, flags); |
|---|
| 1593 | | - if (vha->scan.scan_flags == 0) { |
|---|
| 1594 | | - ql_dbg(ql_dbg_disc, vha, 0xffff, |
|---|
| 1595 | | - "%s: schedule\n", __func__); |
|---|
| 1596 | | - vha->scan.scan_flags |= SF_QUEUED; |
|---|
| 1597 | | - schedule_delayed_work(&vha->scan.scan_work, 5); |
|---|
| 1598 | | - } |
|---|
| 1599 | | - spin_unlock_irqrestore(&vha->work_lock, flags); |
|---|
| 1600 | | - |
|---|
| 1601 | | - break; |
|---|
| 1602 | | - case RSCN_AREA_ADDR: |
|---|
| 1603 | | - case RSCN_DOM_ADDR: |
|---|
| 1604 | | - if (ea->id.b.rsvd_1 == RSCN_AREA_ADDR) { |
|---|
| 1605 | | - mask = 0xffff00; |
|---|
| 1606 | | - ql_dbg(ql_dbg_async, vha, 0x5044, |
|---|
| 1607 | | - "RSCN: Area 0x%06x was affected\n", |
|---|
| 1608 | | - ea->id.b24); |
|---|
| 1609 | | - } else { |
|---|
| 1610 | | - mask = 0xff0000; |
|---|
| 1611 | | - ql_dbg(ql_dbg_async, vha, 0x507a, |
|---|
| 1612 | | - "RSCN: Domain 0x%06x was affected\n", |
|---|
| 1613 | | - ea->id.b24); |
|---|
| 1614 | | - } |
|---|
| 1615 | | - |
|---|
| 1616 | | - rid = ea->id.b24 & mask; |
|---|
| 1617 | | - list_for_each_entry_safe(f, tf, &vha->vp_fcports, |
|---|
| 1618 | | - list) { |
|---|
| 1619 | | - id = f->d_id.b24 & mask; |
|---|
| 1620 | | - if (rid == id) { |
|---|
| 1621 | | - ea->fcport = f; |
|---|
| 1622 | | - qla24xx_handle_rscn_event(f, ea); |
|---|
| 1623 | | - } |
|---|
| 1624 | | - } |
|---|
| 1625 | | - break; |
|---|
| 1626 | | - case RSCN_FAB_ADDR: |
|---|
| 1627 | | - default: |
|---|
| 1628 | | - ql_log(ql_log_warn, vha, 0xd045, |
|---|
| 1629 | | - "RSCN: Fabric was affected. Addr format %d\n", |
|---|
| 1630 | | - ea->id.b.rsvd_1); |
|---|
| 1631 | | - qla2x00_mark_all_devices_lost(vha, 1); |
|---|
| 1632 | | - set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
|---|
| 1633 | | - set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
|---|
| 1634 | | - } |
|---|
| 1635 | | - break; |
|---|
| 1636 | | - case FCME_GIDPN_DONE: |
|---|
| 1637 | | - qla24xx_handle_gidpn_event(vha, ea); |
|---|
| 1638 | | - break; |
|---|
| 1639 | | - case FCME_GNL_DONE: |
|---|
| 1640 | | - qla24xx_handle_gnl_done_event(vha, ea); |
|---|
| 1641 | | - break; |
|---|
| 1642 | | - case FCME_GPSC_DONE: |
|---|
| 1643 | | - qla24xx_handle_gpsc_event(vha, ea); |
|---|
| 1644 | | - break; |
|---|
| 1645 | | - case FCME_PLOGI_DONE: /* Initiator side sent LLIOCB */ |
|---|
| 1646 | | - qla24xx_handle_plogi_done_event(vha, ea); |
|---|
| 1647 | | - break; |
|---|
| 1648 | | - case FCME_PRLI_DONE: |
|---|
| 1649 | | - qla24xx_handle_prli_done_event(vha, ea); |
|---|
| 1650 | | - break; |
|---|
| 1651 | | - case FCME_GPDB_DONE: |
|---|
| 1652 | | - qla24xx_handle_gpdb_event(vha, ea); |
|---|
| 1653 | | - break; |
|---|
| 1654 | | - case FCME_GPNID_DONE: |
|---|
| 1655 | | - qla24xx_handle_gpnid_event(vha, ea); |
|---|
| 1656 | | - break; |
|---|
| 1657 | | - case FCME_GFFID_DONE: |
|---|
| 1658 | | - qla24xx_handle_gffid_event(vha, ea); |
|---|
| 1659 | | - break; |
|---|
| 1660 | | - case FCME_ADISC_DONE: |
|---|
| 1661 | | - qla24xx_handle_adisc_event(vha, ea); |
|---|
| 1662 | | - break; |
|---|
| 1663 | | - case FCME_GNNID_DONE: |
|---|
| 1664 | | - qla24xx_handle_gnnid_event(vha, ea); |
|---|
| 1665 | | - break; |
|---|
| 1666 | | - case FCME_GFPNID_DONE: |
|---|
| 1667 | | - qla24xx_handle_gfpnid_event(vha, ea); |
|---|
| 1668 | | - break; |
|---|
| 1669 | | - case FCME_ELS_PLOGI_DONE: |
|---|
| 1670 | | - qla_handle_els_plogi_done(vha, ea); |
|---|
| 1671 | | - break; |
|---|
| 1842 | + switch (fcport->disc_state) { |
|---|
| 1843 | + case DSC_DELETE_PEND: |
|---|
| 1844 | + return; |
|---|
| 1672 | 1845 | default: |
|---|
| 1673 | | - BUG_ON(1); |
|---|
| 1674 | 1846 | break; |
|---|
| 1847 | + } |
|---|
| 1848 | + |
|---|
| 1849 | + if (fcport->scan_needed) { |
|---|
| 1850 | + memset(&ea, 0, sizeof(ea)); |
|---|
| 1851 | + ea.id = fcport->d_id; |
|---|
| 1852 | + ea.id.b.rsvd_1 = RSCN_PORT_ADDR; |
|---|
| 1853 | + qla2x00_handle_rscn(fcport->vha, &ea); |
|---|
| 1675 | 1854 | } |
|---|
| 1676 | 1855 | } |
|---|
| 1677 | 1856 | |
|---|
| .. | .. |
|---|
| 1680 | 1859 | { |
|---|
| 1681 | 1860 | srb_t *sp = data; |
|---|
| 1682 | 1861 | struct srb_iocb *tmf = &sp->u.iocb_cmd; |
|---|
| 1862 | + int rc, h; |
|---|
| 1863 | + unsigned long flags; |
|---|
| 1683 | 1864 | |
|---|
| 1684 | | - tmf->u.tmf.comp_status = CS_TIMEOUT; |
|---|
| 1685 | | - complete(&tmf->u.tmf.comp); |
|---|
| 1865 | + rc = qla24xx_async_abort_cmd(sp, false); |
|---|
| 1866 | + if (rc) { |
|---|
| 1867 | + spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); |
|---|
| 1868 | + for (h = 1; h < sp->qpair->req->num_outstanding_cmds; h++) { |
|---|
| 1869 | + if (sp->qpair->req->outstanding_cmds[h] == sp) { |
|---|
| 1870 | + sp->qpair->req->outstanding_cmds[h] = NULL; |
|---|
| 1871 | + break; |
|---|
| 1872 | + } |
|---|
| 1873 | + } |
|---|
| 1874 | + spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); |
|---|
| 1875 | + tmf->u.tmf.comp_status = cpu_to_le16(CS_TIMEOUT); |
|---|
| 1876 | + tmf->u.tmf.data = QLA_FUNCTION_FAILED; |
|---|
| 1877 | + complete(&tmf->u.tmf.comp); |
|---|
| 1878 | + } |
|---|
| 1686 | 1879 | } |
|---|
| 1687 | 1880 | |
|---|
| 1688 | | -static void |
|---|
| 1689 | | -qla2x00_tmf_sp_done(void *ptr, int res) |
|---|
| 1881 | +static void qla2x00_tmf_sp_done(srb_t *sp, int res) |
|---|
| 1690 | 1882 | { |
|---|
| 1691 | | - srb_t *sp = ptr; |
|---|
| 1692 | 1883 | struct srb_iocb *tmf = &sp->u.iocb_cmd; |
|---|
| 1693 | 1884 | |
|---|
| 1694 | 1885 | complete(&tmf->u.tmf.comp); |
|---|
| .. | .. |
|---|
| 1742 | 1933 | lun = (uint16_t)tm_iocb->u.tmf.lun; |
|---|
| 1743 | 1934 | |
|---|
| 1744 | 1935 | /* Issue Marker IOCB */ |
|---|
| 1745 | | - qla2x00_marker(vha, vha->hw->req_q_map[0], |
|---|
| 1746 | | - vha->hw->rsp_q_map[0], fcport->loop_id, lun, |
|---|
| 1936 | + qla2x00_marker(vha, vha->hw->base_qpair, |
|---|
| 1937 | + fcport->loop_id, lun, |
|---|
| 1747 | 1938 | flags == TCF_LUN_RESET ? MK_SYNC_ID_LUN : MK_SYNC_ID); |
|---|
| 1748 | 1939 | } |
|---|
| 1749 | 1940 | |
|---|
| 1750 | 1941 | done_free_sp: |
|---|
| 1751 | 1942 | sp->free(sp); |
|---|
| 1752 | 1943 | fcport->flags &= ~FCF_ASYNC_SENT; |
|---|
| 1753 | | -done: |
|---|
| 1754 | | - return rval; |
|---|
| 1755 | | -} |
|---|
| 1756 | | - |
|---|
| 1757 | | -static void |
|---|
| 1758 | | -qla24xx_abort_iocb_timeout(void *data) |
|---|
| 1759 | | -{ |
|---|
| 1760 | | - srb_t *sp = data; |
|---|
| 1761 | | - struct srb_iocb *abt = &sp->u.iocb_cmd; |
|---|
| 1762 | | - |
|---|
| 1763 | | - abt->u.abt.comp_status = CS_TIMEOUT; |
|---|
| 1764 | | - sp->done(sp, QLA_FUNCTION_TIMEOUT); |
|---|
| 1765 | | -} |
|---|
| 1766 | | - |
|---|
| 1767 | | -static void |
|---|
| 1768 | | -qla24xx_abort_sp_done(void *ptr, int res) |
|---|
| 1769 | | -{ |
|---|
| 1770 | | - srb_t *sp = ptr; |
|---|
| 1771 | | - struct srb_iocb *abt = &sp->u.iocb_cmd; |
|---|
| 1772 | | - |
|---|
| 1773 | | - if (del_timer(&sp->u.iocb_cmd.timer)) { |
|---|
| 1774 | | - if (sp->flags & SRB_WAKEUP_ON_COMP) |
|---|
| 1775 | | - complete(&abt->u.abt.comp); |
|---|
| 1776 | | - else |
|---|
| 1777 | | - sp->free(sp); |
|---|
| 1778 | | - } |
|---|
| 1779 | | -} |
|---|
| 1780 | | - |
|---|
| 1781 | | -int |
|---|
| 1782 | | -qla24xx_async_abort_cmd(srb_t *cmd_sp, bool wait) |
|---|
| 1783 | | -{ |
|---|
| 1784 | | - scsi_qla_host_t *vha = cmd_sp->vha; |
|---|
| 1785 | | - struct srb_iocb *abt_iocb; |
|---|
| 1786 | | - srb_t *sp; |
|---|
| 1787 | | - int rval = QLA_FUNCTION_FAILED; |
|---|
| 1788 | | - |
|---|
| 1789 | | - sp = qla2xxx_get_qpair_sp(cmd_sp->qpair, cmd_sp->fcport, GFP_KERNEL); |
|---|
| 1790 | | - if (!sp) |
|---|
| 1791 | | - goto done; |
|---|
| 1792 | | - |
|---|
| 1793 | | - abt_iocb = &sp->u.iocb_cmd; |
|---|
| 1794 | | - sp->type = SRB_ABT_CMD; |
|---|
| 1795 | | - sp->name = "abort"; |
|---|
| 1796 | | - sp->qpair = cmd_sp->qpair; |
|---|
| 1797 | | - if (wait) |
|---|
| 1798 | | - sp->flags = SRB_WAKEUP_ON_COMP; |
|---|
| 1799 | | - |
|---|
| 1800 | | - abt_iocb->timeout = qla24xx_abort_iocb_timeout; |
|---|
| 1801 | | - init_completion(&abt_iocb->u.abt.comp); |
|---|
| 1802 | | - /* FW can send 2 x ABTS's timeout/20s */ |
|---|
| 1803 | | - qla2x00_init_timer(sp, 42); |
|---|
| 1804 | | - |
|---|
| 1805 | | - abt_iocb->u.abt.cmd_hndl = cmd_sp->handle; |
|---|
| 1806 | | - abt_iocb->u.abt.req_que_no = cpu_to_le16(cmd_sp->qpair->req->id); |
|---|
| 1807 | | - |
|---|
| 1808 | | - sp->done = qla24xx_abort_sp_done; |
|---|
| 1809 | | - |
|---|
| 1810 | | - ql_dbg(ql_dbg_async, vha, 0x507c, |
|---|
| 1811 | | - "Abort command issued - hdl=%x, type=%x\n", |
|---|
| 1812 | | - cmd_sp->handle, cmd_sp->type); |
|---|
| 1813 | | - |
|---|
| 1814 | | - rval = qla2x00_start_sp(sp); |
|---|
| 1815 | | - if (rval != QLA_SUCCESS) |
|---|
| 1816 | | - goto done_free_sp; |
|---|
| 1817 | | - |
|---|
| 1818 | | - if (wait) { |
|---|
| 1819 | | - wait_for_completion(&abt_iocb->u.abt.comp); |
|---|
| 1820 | | - rval = abt_iocb->u.abt.comp_status == CS_COMPLETE ? |
|---|
| 1821 | | - QLA_SUCCESS : QLA_FUNCTION_FAILED; |
|---|
| 1822 | | - } else { |
|---|
| 1823 | | - goto done; |
|---|
| 1824 | | - } |
|---|
| 1825 | | - |
|---|
| 1826 | | -done_free_sp: |
|---|
| 1827 | | - sp->free(sp); |
|---|
| 1828 | 1944 | done: |
|---|
| 1829 | 1945 | return rval; |
|---|
| 1830 | 1946 | } |
|---|
| .. | .. |
|---|
| 1836 | 1952 | |
|---|
| 1837 | 1953 | uint32_t handle; |
|---|
| 1838 | 1954 | fc_port_t *fcport = sp->fcport; |
|---|
| 1955 | + struct qla_qpair *qpair = sp->qpair; |
|---|
| 1839 | 1956 | struct scsi_qla_host *vha = fcport->vha; |
|---|
| 1840 | | - struct qla_hw_data *ha = vha->hw; |
|---|
| 1841 | | - struct req_que *req = vha->req; |
|---|
| 1957 | + struct req_que *req = qpair->req; |
|---|
| 1842 | 1958 | |
|---|
| 1843 | | - if (vha->flags.qpairs_available && sp->qpair) |
|---|
| 1844 | | - req = sp->qpair->req; |
|---|
| 1845 | | - |
|---|
| 1846 | | - spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 1959 | + spin_lock_irqsave(qpair->qp_lock_ptr, flags); |
|---|
| 1847 | 1960 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
|---|
| 1848 | 1961 | if (req->outstanding_cmds[handle] == sp) |
|---|
| 1849 | 1962 | break; |
|---|
| 1850 | 1963 | } |
|---|
| 1851 | | - spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 1964 | + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); |
|---|
| 1965 | + |
|---|
| 1852 | 1966 | if (handle == req->num_outstanding_cmds) { |
|---|
| 1853 | 1967 | /* Command not found. */ |
|---|
| 1854 | 1968 | return QLA_FUNCTION_FAILED; |
|---|
| .. | .. |
|---|
| 1863 | 1977 | static void |
|---|
| 1864 | 1978 | qla24xx_handle_prli_done_event(struct scsi_qla_host *vha, struct event_arg *ea) |
|---|
| 1865 | 1979 | { |
|---|
| 1980 | + WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n", |
|---|
| 1981 | + ea->data[0]); |
|---|
| 1982 | + |
|---|
| 1866 | 1983 | switch (ea->data[0]) { |
|---|
| 1867 | 1984 | case MBS_COMMAND_COMPLETE: |
|---|
| 1868 | 1985 | ql_dbg(ql_dbg_disc, vha, 0x2118, |
|---|
| .. | .. |
|---|
| 1871 | 1988 | |
|---|
| 1872 | 1989 | ea->fcport->chip_reset = vha->hw->base_qpair->chip_reset; |
|---|
| 1873 | 1990 | ea->fcport->logout_on_delete = 1; |
|---|
| 1991 | + ea->fcport->nvme_prli_service_param = ea->iop[0]; |
|---|
| 1992 | + if (ea->iop[0] & NVME_PRLI_SP_FIRST_BURST) |
|---|
| 1993 | + ea->fcport->nvme_first_burst_size = |
|---|
| 1994 | + (ea->iop[1] & 0xffff) * 512; |
|---|
| 1995 | + else |
|---|
| 1996 | + ea->fcport->nvme_first_burst_size = 0; |
|---|
| 1874 | 1997 | qla24xx_post_gpdb_work(vha, ea->fcport, 0); |
|---|
| 1875 | 1998 | break; |
|---|
| 1876 | 1999 | default: |
|---|
| .. | .. |
|---|
| 1881 | 2004 | break; |
|---|
| 1882 | 2005 | } |
|---|
| 1883 | 2006 | |
|---|
| 1884 | | - if (ea->fcport->n2n_flag) { |
|---|
| 1885 | | - ql_dbg(ql_dbg_disc, vha, 0x2118, |
|---|
| 1886 | | - "%s %d %8phC post fc4 prli\n", |
|---|
| 1887 | | - __func__, __LINE__, ea->fcport->port_name); |
|---|
| 1888 | | - ea->fcport->fc4f_nvme = 0; |
|---|
| 1889 | | - ea->fcport->n2n_flag = 0; |
|---|
| 1890 | | - qla24xx_post_prli_work(vha, ea->fcport); |
|---|
| 2007 | + ql_dbg(ql_dbg_disc, vha, 0x2118, |
|---|
| 2008 | + "%s %d %8phC priority %s, fc4type %x\n", |
|---|
| 2009 | + __func__, __LINE__, ea->fcport->port_name, |
|---|
| 2010 | + vha->hw->fc4_type_priority == FC4_PRIORITY_FCP ? |
|---|
| 2011 | + "FCP" : "NVMe", ea->fcport->fc4_type); |
|---|
| 2012 | + |
|---|
| 2013 | + if (N2N_TOPO(vha->hw)) { |
|---|
| 2014 | + if (vha->hw->fc4_type_priority == FC4_PRIORITY_NVME) { |
|---|
| 2015 | + ea->fcport->fc4_type &= ~FS_FC4TYPE_NVME; |
|---|
| 2016 | + ea->fcport->fc4_type |= FS_FC4TYPE_FCP; |
|---|
| 2017 | + } else { |
|---|
| 2018 | + ea->fcport->fc4_type &= ~FS_FC4TYPE_FCP; |
|---|
| 2019 | + ea->fcport->fc4_type |= FS_FC4TYPE_NVME; |
|---|
| 2020 | + } |
|---|
| 2021 | + |
|---|
| 2022 | + if (ea->fcport->n2n_link_reset_cnt < 3) { |
|---|
| 2023 | + ea->fcport->n2n_link_reset_cnt++; |
|---|
| 2024 | + vha->relogin_jif = jiffies + 2 * HZ; |
|---|
| 2025 | + /* |
|---|
| 2026 | + * PRLI failed. Reset link to kick start |
|---|
| 2027 | + * state machine |
|---|
| 2028 | + */ |
|---|
| 2029 | + set_bit(N2N_LINK_RESET, &vha->dpc_flags); |
|---|
| 2030 | + } else { |
|---|
| 2031 | + ql_log(ql_log_warn, vha, 0x2119, |
|---|
| 2032 | + "%s %d %8phC Unable to reconnect\n", |
|---|
| 2033 | + __func__, __LINE__, |
|---|
| 2034 | + ea->fcport->port_name); |
|---|
| 2035 | + } |
|---|
| 2036 | + } else { |
|---|
| 2037 | + /* |
|---|
| 2038 | + * switch connect. login failed. Take connection down |
|---|
| 2039 | + * and allow relogin to retrigger |
|---|
| 2040 | + */ |
|---|
| 2041 | + if (NVME_FCP_TARGET(ea->fcport)) { |
|---|
| 2042 | + ql_dbg(ql_dbg_disc, vha, 0x2118, |
|---|
| 2043 | + "%s %d %8phC post %s prli\n", |
|---|
| 2044 | + __func__, __LINE__, |
|---|
| 2045 | + ea->fcport->port_name, |
|---|
| 2046 | + (ea->fcport->fc4_type & FS_FC4TYPE_NVME) |
|---|
| 2047 | + ? "NVMe" : "FCP"); |
|---|
| 2048 | + if (vha->hw->fc4_type_priority == FC4_PRIORITY_NVME) |
|---|
| 2049 | + ea->fcport->fc4_type &= ~FS_FC4TYPE_NVME; |
|---|
| 2050 | + else |
|---|
| 2051 | + ea->fcport->fc4_type &= ~FS_FC4TYPE_FCP; |
|---|
| 2052 | + } |
|---|
| 2053 | + |
|---|
| 2054 | + ea->fcport->flags &= ~FCF_ASYNC_SENT; |
|---|
| 2055 | + ea->fcport->keep_nport_handle = 0; |
|---|
| 2056 | + ea->fcport->logout_on_delete = 1; |
|---|
| 2057 | + qlt_schedule_sess_for_deletion(ea->fcport); |
|---|
| 1891 | 2058 | } |
|---|
| 1892 | | - ql_dbg(ql_dbg_disc, vha, 0x2119, |
|---|
| 1893 | | - "%s %d %8phC unhandle event of %x\n", |
|---|
| 1894 | | - __func__, __LINE__, ea->fcport->port_name, ea->data[0]); |
|---|
| 1895 | 2059 | break; |
|---|
| 1896 | 2060 | } |
|---|
| 1897 | 2061 | } |
|---|
| 1898 | 2062 | |
|---|
| 1899 | | -static void |
|---|
| 2063 | +void |
|---|
| 1900 | 2064 | qla24xx_handle_plogi_done_event(struct scsi_qla_host *vha, struct event_arg *ea) |
|---|
| 1901 | 2065 | { |
|---|
| 1902 | 2066 | port_id_t cid; /* conflict Nport id */ |
|---|
| .. | .. |
|---|
| 1909 | 2073 | "%s %8phC DS %d LS %d rc %d login %d|%d rscn %d|%d data %x|%x iop %x|%x\n", |
|---|
| 1910 | 2074 | __func__, fcport->port_name, fcport->disc_state, |
|---|
| 1911 | 2075 | fcport->fw_login_state, ea->rc, ea->sp->gen2, fcport->login_gen, |
|---|
| 1912 | | - ea->sp->gen2, fcport->rscn_gen|ea->sp->gen1, |
|---|
| 2076 | + ea->sp->gen1, fcport->rscn_gen, |
|---|
| 1913 | 2077 | ea->data[0], ea->data[1], ea->iop[0], ea->iop[1]); |
|---|
| 1914 | 2078 | |
|---|
| 1915 | 2079 | if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) || |
|---|
| .. | .. |
|---|
| 1934 | 2098 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
|---|
| 1935 | 2099 | return; |
|---|
| 1936 | 2100 | } else if (ea->sp->gen1 != fcport->rscn_gen) { |
|---|
| 1937 | | - ql_dbg(ql_dbg_disc, vha, 0x20d4, "%s %d %8phC post gidpn\n", |
|---|
| 1938 | | - __func__, __LINE__, fcport->port_name); |
|---|
| 1939 | | - qla24xx_post_gidpn_work(vha, fcport); |
|---|
| 2101 | + ql_dbg(ql_dbg_disc, vha, 0x20d3, |
|---|
| 2102 | + "%s %8phC RSCN generation changed\n", |
|---|
| 2103 | + __func__, fcport->port_name); |
|---|
| 2104 | + qla_rscn_replay(fcport); |
|---|
| 2105 | + qlt_schedule_sess_for_deletion(fcport); |
|---|
| 1940 | 2106 | return; |
|---|
| 1941 | 2107 | } |
|---|
| 2108 | + |
|---|
| 2109 | + WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n", |
|---|
| 2110 | + ea->data[0]); |
|---|
| 1942 | 2111 | |
|---|
| 1943 | 2112 | switch (ea->data[0]) { |
|---|
| 1944 | 2113 | case MBS_COMMAND_COMPLETE: |
|---|
| .. | .. |
|---|
| 1947 | 2116 | * force a relogin attempt via implicit LOGO, PLOGI, and PRLI |
|---|
| 1948 | 2117 | * requests. |
|---|
| 1949 | 2118 | */ |
|---|
| 1950 | | - if (ea->fcport->fc4f_nvme) { |
|---|
| 2119 | + if (NVME_TARGET(vha->hw, ea->fcport)) { |
|---|
| 1951 | 2120 | ql_dbg(ql_dbg_disc, vha, 0x2117, |
|---|
| 1952 | 2121 | "%s %d %8phC post prli\n", |
|---|
| 1953 | 2122 | __func__, __LINE__, ea->fcport->port_name); |
|---|
| 1954 | 2123 | qla24xx_post_prli_work(vha, ea->fcport); |
|---|
| 1955 | 2124 | } else { |
|---|
| 1956 | 2125 | ql_dbg(ql_dbg_disc, vha, 0x20ea, |
|---|
| 1957 | | - "%s %d %8phC LoopID 0x%x in use with %06x. post gnl\n", |
|---|
| 2126 | + "%s %d %8phC LoopID 0x%x in use with %06x. post gpdb\n", |
|---|
| 1958 | 2127 | __func__, __LINE__, ea->fcport->port_name, |
|---|
| 1959 | 2128 | ea->fcport->loop_id, ea->fcport->d_id.b24); |
|---|
| 1960 | 2129 | |
|---|
| .. | .. |
|---|
| 1973 | 2142 | ql_dbg(ql_dbg_disc, vha, 0x20eb, "%s %d %8phC cmd error %x\n", |
|---|
| 1974 | 2143 | __func__, __LINE__, ea->fcport->port_name, ea->data[1]); |
|---|
| 1975 | 2144 | |
|---|
| 1976 | | - ea->fcport->flags &= ~FCF_ASYNC_SENT; |
|---|
| 1977 | | - ea->fcport->disc_state = DSC_LOGIN_FAILED; |
|---|
| 1978 | | - if (ea->data[1] & QLA_LOGIO_LOGIN_RETRIED) |
|---|
| 1979 | | - set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
|---|
| 1980 | | - else |
|---|
| 1981 | | - qla2x00_mark_device_lost(vha, ea->fcport, 1, 0); |
|---|
| 2145 | + qlt_schedule_sess_for_deletion(ea->fcport); |
|---|
| 1982 | 2146 | break; |
|---|
| 1983 | 2147 | case MBS_LOOP_ID_USED: |
|---|
| 1984 | 2148 | /* data[1] = IO PARAM 1 = nport ID */ |
|---|
| .. | .. |
|---|
| 2015 | 2179 | "%s %d %8phC NPortId %06x inuse with loopid 0x%x. post gidpn\n", |
|---|
| 2016 | 2180 | __func__, __LINE__, ea->fcport->port_name, |
|---|
| 2017 | 2181 | ea->fcport->d_id.b24, lid); |
|---|
| 2018 | | - qla2x00_clear_loop_id(ea->fcport); |
|---|
| 2019 | | - qla24xx_post_gidpn_work(vha, ea->fcport); |
|---|
| 2020 | 2182 | } else { |
|---|
| 2021 | 2183 | ql_dbg(ql_dbg_disc, vha, 0x20ed, |
|---|
| 2022 | 2184 | "%s %d %8phC NPortId %06x inuse with loopid 0x%x. sched delete\n", |
|---|
| .. | .. |
|---|
| 2027 | 2189 | set_bit(lid, vha->hw->loop_id_map); |
|---|
| 2028 | 2190 | ea->fcport->loop_id = lid; |
|---|
| 2029 | 2191 | ea->fcport->keep_nport_handle = 0; |
|---|
| 2192 | + ea->fcport->logout_on_delete = 1; |
|---|
| 2030 | 2193 | qlt_schedule_sess_for_deletion(ea->fcport); |
|---|
| 2031 | 2194 | } |
|---|
| 2032 | 2195 | break; |
|---|
| 2033 | 2196 | } |
|---|
| 2034 | | - return; |
|---|
| 2035 | | -} |
|---|
| 2036 | | - |
|---|
| 2037 | | -void |
|---|
| 2038 | | -qla2x00_async_logout_done(struct scsi_qla_host *vha, fc_port_t *fcport, |
|---|
| 2039 | | - uint16_t *data) |
|---|
| 2040 | | -{ |
|---|
| 2041 | | - qlt_logo_completion_handler(fcport, data[0]); |
|---|
| 2042 | | - fcport->login_gen++; |
|---|
| 2043 | | - fcport->flags &= ~FCF_ASYNC_ACTIVE; |
|---|
| 2044 | | - return; |
|---|
| 2045 | | -} |
|---|
| 2046 | | - |
|---|
| 2047 | | -void |
|---|
| 2048 | | -qla2x00_async_adisc_done(struct scsi_qla_host *vha, fc_port_t *fcport, |
|---|
| 2049 | | - uint16_t *data) |
|---|
| 2050 | | -{ |
|---|
| 2051 | | - fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); |
|---|
| 2052 | | - if (data[0] == MBS_COMMAND_COMPLETE) { |
|---|
| 2053 | | - qla2x00_update_fcport(vha, fcport); |
|---|
| 2054 | | - |
|---|
| 2055 | | - return; |
|---|
| 2056 | | - } |
|---|
| 2057 | | - |
|---|
| 2058 | | - /* Retry login. */ |
|---|
| 2059 | | - if (data[1] & QLA_LOGIO_LOGIN_RETRIED) |
|---|
| 2060 | | - set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
|---|
| 2061 | | - else |
|---|
| 2062 | | - qla2x00_mark_device_lost(vha, fcport, 1, 0); |
|---|
| 2063 | | - |
|---|
| 2064 | 2197 | return; |
|---|
| 2065 | 2198 | } |
|---|
| 2066 | 2199 | |
|---|
| .. | .. |
|---|
| 2157 | 2290 | int rval; |
|---|
| 2158 | 2291 | struct qla_hw_data *ha = vha->hw; |
|---|
| 2159 | 2292 | struct req_que *req = ha->req_q_map[0]; |
|---|
| 2293 | + struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
|---|
| 2160 | 2294 | |
|---|
| 2161 | 2295 | memset(&vha->qla_stats, 0, sizeof(vha->qla_stats)); |
|---|
| 2162 | 2296 | memset(&vha->fc_host_stat, 0, sizeof(vha->fc_host_stat)); |
|---|
| .. | .. |
|---|
| 2191 | 2325 | |
|---|
| 2192 | 2326 | ha->isp_ops->reset_chip(vha); |
|---|
| 2193 | 2327 | |
|---|
| 2328 | + /* Check for secure flash support */ |
|---|
| 2329 | + if (IS_QLA28XX(ha)) { |
|---|
| 2330 | + if (rd_reg_word(®->mailbox12) & BIT_0) |
|---|
| 2331 | + ha->flags.secure_adapter = 1; |
|---|
| 2332 | + ql_log(ql_log_info, vha, 0xffff, "Secure Adapter: %s\n", |
|---|
| 2333 | + (ha->flags.secure_adapter) ? "Yes" : "No"); |
|---|
| 2334 | + } |
|---|
| 2335 | + |
|---|
| 2336 | + |
|---|
| 2194 | 2337 | rval = qla2xxx_get_flash_info(vha); |
|---|
| 2195 | 2338 | if (rval) { |
|---|
| 2196 | 2339 | ql_log(ql_log_fatal, vha, 0x004f, |
|---|
| .. | .. |
|---|
| 2213 | 2356 | ql_dbg(ql_dbg_init, vha, 0x0061, |
|---|
| 2214 | 2357 | "Configure NVRAM parameters...\n"); |
|---|
| 2215 | 2358 | |
|---|
| 2359 | + /* Let priority default to FCP, can be overridden by nvram_config */ |
|---|
| 2360 | + ha->fc4_type_priority = FC4_PRIORITY_FCP; |
|---|
| 2361 | + |
|---|
| 2216 | 2362 | ha->isp_ops->nvram_config(vha); |
|---|
| 2363 | + |
|---|
| 2364 | + if (ha->fc4_type_priority != FC4_PRIORITY_FCP && |
|---|
| 2365 | + ha->fc4_type_priority != FC4_PRIORITY_NVME) |
|---|
| 2366 | + ha->fc4_type_priority = FC4_PRIORITY_FCP; |
|---|
| 2367 | + |
|---|
| 2368 | + ql_log(ql_log_info, vha, 0xffff, "FC4 priority set to %s\n", |
|---|
| 2369 | + ha->fc4_type_priority == FC4_PRIORITY_FCP ? "FCP" : "NVMe"); |
|---|
| 2217 | 2370 | |
|---|
| 2218 | 2371 | if (ha->flags.disable_serdes) { |
|---|
| 2219 | 2372 | /* Mask HBA via NVRAM settings? */ |
|---|
| .. | .. |
|---|
| 2224 | 2377 | |
|---|
| 2225 | 2378 | ql_dbg(ql_dbg_init, vha, 0x0078, |
|---|
| 2226 | 2379 | "Verifying loaded RISC code...\n"); |
|---|
| 2380 | + |
|---|
| 2381 | + /* If smartsan enabled then require fdmi and rdp enabled */ |
|---|
| 2382 | + if (ql2xsmartsan) { |
|---|
| 2383 | + ql2xfdmienable = 1; |
|---|
| 2384 | + ql2xrdpenable = 1; |
|---|
| 2385 | + } |
|---|
| 2227 | 2386 | |
|---|
| 2228 | 2387 | if (qla2x00_isp_firmware(vha) != QLA_SUCCESS) { |
|---|
| 2229 | 2388 | rval = ha->isp_ops->chip_diag(vha); |
|---|
| .. | .. |
|---|
| 2245 | 2404 | |
|---|
| 2246 | 2405 | if (qla_ini_mode_enabled(vha) || qla_dual_mode_enabled(vha)) |
|---|
| 2247 | 2406 | rval = qla2x00_init_rings(vha); |
|---|
| 2407 | + |
|---|
| 2408 | + /* No point in continuing if firmware initialization failed. */ |
|---|
| 2409 | + if (rval != QLA_SUCCESS) |
|---|
| 2410 | + return rval; |
|---|
| 2248 | 2411 | |
|---|
| 2249 | 2412 | ha->flags.chip_reset_done = 1; |
|---|
| 2250 | 2413 | |
|---|
| .. | .. |
|---|
| 2302 | 2465 | |
|---|
| 2303 | 2466 | /* Get PCI bus information. */ |
|---|
| 2304 | 2467 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 2305 | | - ha->pci_attr = RD_REG_WORD(®->ctrl_status); |
|---|
| 2468 | + ha->pci_attr = rd_reg_word(®->ctrl_status); |
|---|
| 2306 | 2469 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 2307 | 2470 | |
|---|
| 2308 | 2471 | return QLA_SUCCESS; |
|---|
| .. | .. |
|---|
| 2344 | 2507 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 2345 | 2508 | |
|---|
| 2346 | 2509 | /* Pause RISC. */ |
|---|
| 2347 | | - WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC); |
|---|
| 2510 | + wrt_reg_word(®->hccr, HCCR_PAUSE_RISC); |
|---|
| 2348 | 2511 | for (cnt = 0; cnt < 30000; cnt++) { |
|---|
| 2349 | | - if ((RD_REG_WORD(®->hccr) & HCCR_RISC_PAUSE) != 0) |
|---|
| 2512 | + if ((rd_reg_word(®->hccr) & HCCR_RISC_PAUSE) != 0) |
|---|
| 2350 | 2513 | break; |
|---|
| 2351 | 2514 | |
|---|
| 2352 | 2515 | udelay(10); |
|---|
| 2353 | 2516 | } |
|---|
| 2354 | 2517 | |
|---|
| 2355 | 2518 | /* Select FPM registers. */ |
|---|
| 2356 | | - WRT_REG_WORD(®->ctrl_status, 0x20); |
|---|
| 2357 | | - RD_REG_WORD(®->ctrl_status); |
|---|
| 2519 | + wrt_reg_word(®->ctrl_status, 0x20); |
|---|
| 2520 | + rd_reg_word(®->ctrl_status); |
|---|
| 2358 | 2521 | |
|---|
| 2359 | 2522 | /* Get the fb rev level */ |
|---|
| 2360 | 2523 | ha->fb_rev = RD_FB_CMD_REG(ha, reg); |
|---|
| .. | .. |
|---|
| 2363 | 2526 | pci_clear_mwi(ha->pdev); |
|---|
| 2364 | 2527 | |
|---|
| 2365 | 2528 | /* Deselect FPM registers. */ |
|---|
| 2366 | | - WRT_REG_WORD(®->ctrl_status, 0x0); |
|---|
| 2367 | | - RD_REG_WORD(®->ctrl_status); |
|---|
| 2529 | + wrt_reg_word(®->ctrl_status, 0x0); |
|---|
| 2530 | + rd_reg_word(®->ctrl_status); |
|---|
| 2368 | 2531 | |
|---|
| 2369 | 2532 | /* Release RISC module. */ |
|---|
| 2370 | | - WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
|---|
| 2533 | + wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); |
|---|
| 2371 | 2534 | for (cnt = 0; cnt < 30000; cnt++) { |
|---|
| 2372 | | - if ((RD_REG_WORD(®->hccr) & HCCR_RISC_PAUSE) == 0) |
|---|
| 2535 | + if ((rd_reg_word(®->hccr) & HCCR_RISC_PAUSE) == 0) |
|---|
| 2373 | 2536 | break; |
|---|
| 2374 | 2537 | |
|---|
| 2375 | 2538 | udelay(10); |
|---|
| .. | .. |
|---|
| 2384 | 2547 | |
|---|
| 2385 | 2548 | /* Get PCI bus information. */ |
|---|
| 2386 | 2549 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 2387 | | - ha->pci_attr = RD_REG_WORD(®->ctrl_status); |
|---|
| 2550 | + ha->pci_attr = rd_reg_word(®->ctrl_status); |
|---|
| 2388 | 2551 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 2389 | 2552 | |
|---|
| 2390 | 2553 | return QLA_SUCCESS; |
|---|
| .. | .. |
|---|
| 2428 | 2591 | |
|---|
| 2429 | 2592 | /* Get PCI bus information. */ |
|---|
| 2430 | 2593 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 2431 | | - ha->pci_attr = RD_REG_DWORD(®->ctrl_status); |
|---|
| 2594 | + ha->pci_attr = rd_reg_dword(®->ctrl_status); |
|---|
| 2432 | 2595 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 2433 | 2596 | |
|---|
| 2434 | 2597 | return QLA_SUCCESS; |
|---|
| .. | .. |
|---|
| 2507 | 2670 | * |
|---|
| 2508 | 2671 | * Returns 0 on success. |
|---|
| 2509 | 2672 | */ |
|---|
| 2510 | | -void |
|---|
| 2673 | +int |
|---|
| 2511 | 2674 | qla2x00_reset_chip(scsi_qla_host_t *vha) |
|---|
| 2512 | 2675 | { |
|---|
| 2513 | 2676 | unsigned long flags = 0; |
|---|
| .. | .. |
|---|
| 2515 | 2678 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
|---|
| 2516 | 2679 | uint32_t cnt; |
|---|
| 2517 | 2680 | uint16_t cmd; |
|---|
| 2681 | + int rval = QLA_FUNCTION_FAILED; |
|---|
| 2518 | 2682 | |
|---|
| 2519 | 2683 | if (unlikely(pci_channel_offline(ha->pdev))) |
|---|
| 2520 | | - return; |
|---|
| 2684 | + return rval; |
|---|
| 2521 | 2685 | |
|---|
| 2522 | 2686 | ha->isp_ops->disable_intrs(ha); |
|---|
| 2523 | 2687 | |
|---|
| .. | .. |
|---|
| 2531 | 2695 | |
|---|
| 2532 | 2696 | if (!IS_QLA2100(ha)) { |
|---|
| 2533 | 2697 | /* Pause RISC. */ |
|---|
| 2534 | | - WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC); |
|---|
| 2698 | + wrt_reg_word(®->hccr, HCCR_PAUSE_RISC); |
|---|
| 2535 | 2699 | if (IS_QLA2200(ha) || IS_QLA2300(ha)) { |
|---|
| 2536 | 2700 | for (cnt = 0; cnt < 30000; cnt++) { |
|---|
| 2537 | | - if ((RD_REG_WORD(®->hccr) & |
|---|
| 2701 | + if ((rd_reg_word(®->hccr) & |
|---|
| 2538 | 2702 | HCCR_RISC_PAUSE) != 0) |
|---|
| 2539 | 2703 | break; |
|---|
| 2540 | 2704 | udelay(100); |
|---|
| 2541 | 2705 | } |
|---|
| 2542 | 2706 | } else { |
|---|
| 2543 | | - RD_REG_WORD(®->hccr); /* PCI Posting. */ |
|---|
| 2707 | + rd_reg_word(®->hccr); /* PCI Posting. */ |
|---|
| 2544 | 2708 | udelay(10); |
|---|
| 2545 | 2709 | } |
|---|
| 2546 | 2710 | |
|---|
| 2547 | 2711 | /* Select FPM registers. */ |
|---|
| 2548 | | - WRT_REG_WORD(®->ctrl_status, 0x20); |
|---|
| 2549 | | - RD_REG_WORD(®->ctrl_status); /* PCI Posting. */ |
|---|
| 2712 | + wrt_reg_word(®->ctrl_status, 0x20); |
|---|
| 2713 | + rd_reg_word(®->ctrl_status); /* PCI Posting. */ |
|---|
| 2550 | 2714 | |
|---|
| 2551 | 2715 | /* FPM Soft Reset. */ |
|---|
| 2552 | | - WRT_REG_WORD(®->fpm_diag_config, 0x100); |
|---|
| 2553 | | - RD_REG_WORD(®->fpm_diag_config); /* PCI Posting. */ |
|---|
| 2716 | + wrt_reg_word(®->fpm_diag_config, 0x100); |
|---|
| 2717 | + rd_reg_word(®->fpm_diag_config); /* PCI Posting. */ |
|---|
| 2554 | 2718 | |
|---|
| 2555 | 2719 | /* Toggle Fpm Reset. */ |
|---|
| 2556 | 2720 | if (!IS_QLA2200(ha)) { |
|---|
| 2557 | | - WRT_REG_WORD(®->fpm_diag_config, 0x0); |
|---|
| 2558 | | - RD_REG_WORD(®->fpm_diag_config); /* PCI Posting. */ |
|---|
| 2721 | + wrt_reg_word(®->fpm_diag_config, 0x0); |
|---|
| 2722 | + rd_reg_word(®->fpm_diag_config); /* PCI Posting. */ |
|---|
| 2559 | 2723 | } |
|---|
| 2560 | 2724 | |
|---|
| 2561 | 2725 | /* Select frame buffer registers. */ |
|---|
| 2562 | | - WRT_REG_WORD(®->ctrl_status, 0x10); |
|---|
| 2563 | | - RD_REG_WORD(®->ctrl_status); /* PCI Posting. */ |
|---|
| 2726 | + wrt_reg_word(®->ctrl_status, 0x10); |
|---|
| 2727 | + rd_reg_word(®->ctrl_status); /* PCI Posting. */ |
|---|
| 2564 | 2728 | |
|---|
| 2565 | 2729 | /* Reset frame buffer FIFOs. */ |
|---|
| 2566 | 2730 | if (IS_QLA2200(ha)) { |
|---|
| .. | .. |
|---|
| 2578 | 2742 | } |
|---|
| 2579 | 2743 | |
|---|
| 2580 | 2744 | /* Select RISC module registers. */ |
|---|
| 2581 | | - WRT_REG_WORD(®->ctrl_status, 0); |
|---|
| 2582 | | - RD_REG_WORD(®->ctrl_status); /* PCI Posting. */ |
|---|
| 2745 | + wrt_reg_word(®->ctrl_status, 0); |
|---|
| 2746 | + rd_reg_word(®->ctrl_status); /* PCI Posting. */ |
|---|
| 2583 | 2747 | |
|---|
| 2584 | 2748 | /* Reset RISC processor. */ |
|---|
| 2585 | | - WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
|---|
| 2586 | | - RD_REG_WORD(®->hccr); /* PCI Posting. */ |
|---|
| 2749 | + wrt_reg_word(®->hccr, HCCR_RESET_RISC); |
|---|
| 2750 | + rd_reg_word(®->hccr); /* PCI Posting. */ |
|---|
| 2587 | 2751 | |
|---|
| 2588 | 2752 | /* Release RISC processor. */ |
|---|
| 2589 | | - WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
|---|
| 2590 | | - RD_REG_WORD(®->hccr); /* PCI Posting. */ |
|---|
| 2753 | + wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); |
|---|
| 2754 | + rd_reg_word(®->hccr); /* PCI Posting. */ |
|---|
| 2591 | 2755 | } |
|---|
| 2592 | 2756 | |
|---|
| 2593 | | - WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
|---|
| 2594 | | - WRT_REG_WORD(®->hccr, HCCR_CLR_HOST_INT); |
|---|
| 2757 | + wrt_reg_word(®->hccr, HCCR_CLR_RISC_INT); |
|---|
| 2758 | + wrt_reg_word(®->hccr, HCCR_CLR_HOST_INT); |
|---|
| 2595 | 2759 | |
|---|
| 2596 | 2760 | /* Reset ISP chip. */ |
|---|
| 2597 | | - WRT_REG_WORD(®->ctrl_status, CSR_ISP_SOFT_RESET); |
|---|
| 2761 | + wrt_reg_word(®->ctrl_status, CSR_ISP_SOFT_RESET); |
|---|
| 2598 | 2762 | |
|---|
| 2599 | 2763 | /* Wait for RISC to recover from reset. */ |
|---|
| 2600 | 2764 | if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) { |
|---|
| .. | .. |
|---|
| 2605 | 2769 | */ |
|---|
| 2606 | 2770 | udelay(20); |
|---|
| 2607 | 2771 | for (cnt = 30000; cnt; cnt--) { |
|---|
| 2608 | | - if ((RD_REG_WORD(®->ctrl_status) & |
|---|
| 2772 | + if ((rd_reg_word(®->ctrl_status) & |
|---|
| 2609 | 2773 | CSR_ISP_SOFT_RESET) == 0) |
|---|
| 2610 | 2774 | break; |
|---|
| 2611 | 2775 | udelay(100); |
|---|
| .. | .. |
|---|
| 2614 | 2778 | udelay(10); |
|---|
| 2615 | 2779 | |
|---|
| 2616 | 2780 | /* Reset RISC processor. */ |
|---|
| 2617 | | - WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
|---|
| 2781 | + wrt_reg_word(®->hccr, HCCR_RESET_RISC); |
|---|
| 2618 | 2782 | |
|---|
| 2619 | | - WRT_REG_WORD(®->semaphore, 0); |
|---|
| 2783 | + wrt_reg_word(®->semaphore, 0); |
|---|
| 2620 | 2784 | |
|---|
| 2621 | 2785 | /* Release RISC processor. */ |
|---|
| 2622 | | - WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
|---|
| 2623 | | - RD_REG_WORD(®->hccr); /* PCI Posting. */ |
|---|
| 2786 | + wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); |
|---|
| 2787 | + rd_reg_word(®->hccr); /* PCI Posting. */ |
|---|
| 2624 | 2788 | |
|---|
| 2625 | 2789 | if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) { |
|---|
| 2626 | 2790 | for (cnt = 0; cnt < 30000; cnt++) { |
|---|
| .. | .. |
|---|
| 2638 | 2802 | |
|---|
| 2639 | 2803 | /* Disable RISC pause on FPM parity error. */ |
|---|
| 2640 | 2804 | if (!IS_QLA2100(ha)) { |
|---|
| 2641 | | - WRT_REG_WORD(®->hccr, HCCR_DISABLE_PARITY_PAUSE); |
|---|
| 2642 | | - RD_REG_WORD(®->hccr); /* PCI Posting. */ |
|---|
| 2805 | + wrt_reg_word(®->hccr, HCCR_DISABLE_PARITY_PAUSE); |
|---|
| 2806 | + rd_reg_word(®->hccr); /* PCI Posting. */ |
|---|
| 2643 | 2807 | } |
|---|
| 2644 | 2808 | |
|---|
| 2645 | 2809 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 2810 | + |
|---|
| 2811 | + return QLA_SUCCESS; |
|---|
| 2646 | 2812 | } |
|---|
| 2647 | 2813 | |
|---|
| 2648 | 2814 | /** |
|---|
| .. | .. |
|---|
| 2682 | 2848 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 2683 | 2849 | |
|---|
| 2684 | 2850 | /* Reset RISC. */ |
|---|
| 2685 | | - WRT_REG_DWORD(®->ctrl_status, CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); |
|---|
| 2851 | + wrt_reg_dword(®->ctrl_status, CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); |
|---|
| 2686 | 2852 | for (cnt = 0; cnt < 30000; cnt++) { |
|---|
| 2687 | | - if ((RD_REG_DWORD(®->ctrl_status) & CSRX_DMA_ACTIVE) == 0) |
|---|
| 2853 | + if ((rd_reg_dword(®->ctrl_status) & CSRX_DMA_ACTIVE) == 0) |
|---|
| 2688 | 2854 | break; |
|---|
| 2689 | 2855 | |
|---|
| 2690 | 2856 | udelay(10); |
|---|
| 2691 | 2857 | } |
|---|
| 2692 | 2858 | |
|---|
| 2693 | | - if (!(RD_REG_DWORD(®->ctrl_status) & CSRX_DMA_ACTIVE)) |
|---|
| 2859 | + if (!(rd_reg_dword(®->ctrl_status) & CSRX_DMA_ACTIVE)) |
|---|
| 2694 | 2860 | set_bit(DMA_SHUTDOWN_CMPL, &ha->fw_dump_cap_flags); |
|---|
| 2695 | 2861 | |
|---|
| 2696 | 2862 | ql_dbg(ql_dbg_init + ql_dbg_verbose, vha, 0x017e, |
|---|
| 2697 | 2863 | "HCCR: 0x%x, Control Status %x, DMA active status:0x%x\n", |
|---|
| 2698 | | - RD_REG_DWORD(®->hccr), |
|---|
| 2699 | | - RD_REG_DWORD(®->ctrl_status), |
|---|
| 2700 | | - (RD_REG_DWORD(®->ctrl_status) & CSRX_DMA_ACTIVE)); |
|---|
| 2864 | + rd_reg_dword(®->hccr), |
|---|
| 2865 | + rd_reg_dword(®->ctrl_status), |
|---|
| 2866 | + (rd_reg_dword(®->ctrl_status) & CSRX_DMA_ACTIVE)); |
|---|
| 2701 | 2867 | |
|---|
| 2702 | | - WRT_REG_DWORD(®->ctrl_status, |
|---|
| 2868 | + wrt_reg_dword(®->ctrl_status, |
|---|
| 2703 | 2869 | CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); |
|---|
| 2704 | 2870 | pci_read_config_word(ha->pdev, PCI_COMMAND, &wd); |
|---|
| 2705 | 2871 | |
|---|
| 2706 | 2872 | udelay(100); |
|---|
| 2707 | 2873 | |
|---|
| 2708 | 2874 | /* Wait for firmware to complete NVRAM accesses. */ |
|---|
| 2709 | | - RD_REG_WORD(®->mailbox0); |
|---|
| 2710 | | - for (cnt = 10000; RD_REG_WORD(®->mailbox0) != 0 && |
|---|
| 2875 | + rd_reg_word(®->mailbox0); |
|---|
| 2876 | + for (cnt = 10000; rd_reg_word(®->mailbox0) != 0 && |
|---|
| 2711 | 2877 | rval == QLA_SUCCESS; cnt--) { |
|---|
| 2712 | 2878 | barrier(); |
|---|
| 2713 | 2879 | if (cnt) |
|---|
| .. | .. |
|---|
| 2721 | 2887 | |
|---|
| 2722 | 2888 | ql_dbg(ql_dbg_init + ql_dbg_verbose, vha, 0x017f, |
|---|
| 2723 | 2889 | "HCCR: 0x%x, MailBox0 Status 0x%x\n", |
|---|
| 2724 | | - RD_REG_DWORD(®->hccr), |
|---|
| 2725 | | - RD_REG_DWORD(®->mailbox0)); |
|---|
| 2890 | + rd_reg_dword(®->hccr), |
|---|
| 2891 | + rd_reg_word(®->mailbox0)); |
|---|
| 2726 | 2892 | |
|---|
| 2727 | 2893 | /* Wait for soft-reset to complete. */ |
|---|
| 2728 | | - RD_REG_DWORD(®->ctrl_status); |
|---|
| 2894 | + rd_reg_dword(®->ctrl_status); |
|---|
| 2729 | 2895 | for (cnt = 0; cnt < 60; cnt++) { |
|---|
| 2730 | 2896 | barrier(); |
|---|
| 2731 | | - if ((RD_REG_DWORD(®->ctrl_status) & |
|---|
| 2897 | + if ((rd_reg_dword(®->ctrl_status) & |
|---|
| 2732 | 2898 | CSRX_ISP_SOFT_RESET) == 0) |
|---|
| 2733 | 2899 | break; |
|---|
| 2734 | 2900 | |
|---|
| 2735 | 2901 | udelay(5); |
|---|
| 2736 | 2902 | } |
|---|
| 2737 | | - if (!(RD_REG_DWORD(®->ctrl_status) & CSRX_ISP_SOFT_RESET)) |
|---|
| 2903 | + if (!(rd_reg_dword(®->ctrl_status) & CSRX_ISP_SOFT_RESET)) |
|---|
| 2738 | 2904 | set_bit(ISP_SOFT_RESET_CMPL, &ha->fw_dump_cap_flags); |
|---|
| 2739 | 2905 | |
|---|
| 2740 | 2906 | ql_dbg(ql_dbg_init + ql_dbg_verbose, vha, 0x015d, |
|---|
| 2741 | 2907 | "HCCR: 0x%x, Soft Reset status: 0x%x\n", |
|---|
| 2742 | | - RD_REG_DWORD(®->hccr), |
|---|
| 2743 | | - RD_REG_DWORD(®->ctrl_status)); |
|---|
| 2908 | + rd_reg_dword(®->hccr), |
|---|
| 2909 | + rd_reg_dword(®->ctrl_status)); |
|---|
| 2744 | 2910 | |
|---|
| 2745 | 2911 | /* If required, do an MPI FW reset now */ |
|---|
| 2746 | 2912 | if (test_and_clear_bit(MPI_RESET_NEEDED, &vha->dpc_flags)) { |
|---|
| .. | .. |
|---|
| 2759 | 2925 | } |
|---|
| 2760 | 2926 | } |
|---|
| 2761 | 2927 | |
|---|
| 2762 | | - WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_RESET); |
|---|
| 2763 | | - RD_REG_DWORD(®->hccr); |
|---|
| 2928 | + wrt_reg_dword(®->hccr, HCCRX_SET_RISC_RESET); |
|---|
| 2929 | + rd_reg_dword(®->hccr); |
|---|
| 2764 | 2930 | |
|---|
| 2765 | | - WRT_REG_DWORD(®->hccr, HCCRX_REL_RISC_PAUSE); |
|---|
| 2766 | | - RD_REG_DWORD(®->hccr); |
|---|
| 2931 | + wrt_reg_dword(®->hccr, HCCRX_REL_RISC_PAUSE); |
|---|
| 2932 | + rd_reg_dword(®->hccr); |
|---|
| 2767 | 2933 | |
|---|
| 2768 | | - WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_RESET); |
|---|
| 2769 | | - RD_REG_DWORD(®->hccr); |
|---|
| 2934 | + wrt_reg_dword(®->hccr, HCCRX_CLR_RISC_RESET); |
|---|
| 2935 | + rd_reg_dword(®->hccr); |
|---|
| 2770 | 2936 | |
|---|
| 2771 | | - RD_REG_WORD(®->mailbox0); |
|---|
| 2772 | | - for (cnt = 60; RD_REG_WORD(®->mailbox0) != 0 && |
|---|
| 2937 | + rd_reg_word(®->mailbox0); |
|---|
| 2938 | + for (cnt = 60; rd_reg_word(®->mailbox0) != 0 && |
|---|
| 2773 | 2939 | rval == QLA_SUCCESS; cnt--) { |
|---|
| 2774 | 2940 | barrier(); |
|---|
| 2775 | 2941 | if (cnt) |
|---|
| .. | .. |
|---|
| 2782 | 2948 | |
|---|
| 2783 | 2949 | ql_dbg(ql_dbg_init + ql_dbg_verbose, vha, 0x015e, |
|---|
| 2784 | 2950 | "Host Risc 0x%x, mailbox0 0x%x\n", |
|---|
| 2785 | | - RD_REG_DWORD(®->hccr), |
|---|
| 2786 | | - RD_REG_WORD(®->mailbox0)); |
|---|
| 2951 | + rd_reg_dword(®->hccr), |
|---|
| 2952 | + rd_reg_word(®->mailbox0)); |
|---|
| 2787 | 2953 | |
|---|
| 2788 | 2954 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 2789 | 2955 | |
|---|
| .. | .. |
|---|
| 2802 | 2968 | { |
|---|
| 2803 | 2969 | struct device_reg_24xx __iomem *reg = &vha->hw->iobase->isp24; |
|---|
| 2804 | 2970 | |
|---|
| 2805 | | - WRT_REG_DWORD(®->iobase_addr, RISC_REGISTER_BASE_OFFSET); |
|---|
| 2806 | | - *data = RD_REG_DWORD(®->iobase_window + RISC_REGISTER_WINDOW_OFFET); |
|---|
| 2807 | | - |
|---|
| 2971 | + wrt_reg_dword(®->iobase_addr, RISC_REGISTER_BASE_OFFSET); |
|---|
| 2972 | + *data = rd_reg_dword(®->iobase_window + RISC_REGISTER_WINDOW_OFFSET); |
|---|
| 2808 | 2973 | } |
|---|
| 2809 | 2974 | |
|---|
| 2810 | 2975 | static void |
|---|
| .. | .. |
|---|
| 2812 | 2977 | { |
|---|
| 2813 | 2978 | struct device_reg_24xx __iomem *reg = &vha->hw->iobase->isp24; |
|---|
| 2814 | 2979 | |
|---|
| 2815 | | - WRT_REG_DWORD(®->iobase_addr, RISC_REGISTER_BASE_OFFSET); |
|---|
| 2816 | | - WRT_REG_DWORD(®->iobase_window + RISC_REGISTER_WINDOW_OFFET, data); |
|---|
| 2980 | + wrt_reg_dword(®->iobase_addr, RISC_REGISTER_BASE_OFFSET); |
|---|
| 2981 | + wrt_reg_dword(®->iobase_window + RISC_REGISTER_WINDOW_OFFSET, data); |
|---|
| 2817 | 2982 | } |
|---|
| 2818 | 2983 | |
|---|
| 2819 | 2984 | static void |
|---|
| .. | .. |
|---|
| 2829 | 2994 | vha->hw->pdev->subsystem_device != 0x0240) |
|---|
| 2830 | 2995 | return; |
|---|
| 2831 | 2996 | |
|---|
| 2832 | | - WRT_REG_DWORD(&vha->hw->iobase->isp24.hccr, HCCRX_SET_RISC_PAUSE); |
|---|
| 2997 | + wrt_reg_dword(&vha->hw->iobase->isp24.hccr, HCCRX_SET_RISC_PAUSE); |
|---|
| 2833 | 2998 | udelay(100); |
|---|
| 2834 | 2999 | |
|---|
| 2835 | 3000 | attempt: |
|---|
| .. | .. |
|---|
| 2883 | 3048 | * |
|---|
| 2884 | 3049 | * Returns 0 on success. |
|---|
| 2885 | 3050 | */ |
|---|
| 2886 | | -void |
|---|
| 3051 | +int |
|---|
| 2887 | 3052 | qla24xx_reset_chip(scsi_qla_host_t *vha) |
|---|
| 2888 | 3053 | { |
|---|
| 2889 | 3054 | struct qla_hw_data *ha = vha->hw; |
|---|
| 3055 | + int rval = QLA_FUNCTION_FAILED; |
|---|
| 2890 | 3056 | |
|---|
| 2891 | 3057 | if (pci_channel_offline(ha->pdev) && |
|---|
| 2892 | 3058 | ha->flags.pci_channel_io_perm_failure) { |
|---|
| 2893 | | - return; |
|---|
| 3059 | + return rval; |
|---|
| 2894 | 3060 | } |
|---|
| 2895 | 3061 | |
|---|
| 2896 | 3062 | ha->isp_ops->disable_intrs(ha); |
|---|
| .. | .. |
|---|
| 2898 | 3064 | qla25xx_manipulate_risc_semaphore(vha); |
|---|
| 2899 | 3065 | |
|---|
| 2900 | 3066 | /* Perform RISC reset. */ |
|---|
| 2901 | | - qla24xx_reset_risc(vha); |
|---|
| 3067 | + rval = qla24xx_reset_risc(vha); |
|---|
| 3068 | + |
|---|
| 3069 | + return rval; |
|---|
| 2902 | 3070 | } |
|---|
| 2903 | 3071 | |
|---|
| 2904 | 3072 | /** |
|---|
| .. | .. |
|---|
| 2928 | 3096 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 2929 | 3097 | |
|---|
| 2930 | 3098 | /* Reset ISP chip. */ |
|---|
| 2931 | | - WRT_REG_WORD(®->ctrl_status, CSR_ISP_SOFT_RESET); |
|---|
| 3099 | + wrt_reg_word(®->ctrl_status, CSR_ISP_SOFT_RESET); |
|---|
| 2932 | 3100 | |
|---|
| 2933 | 3101 | /* |
|---|
| 2934 | 3102 | * We need to have a delay here since the card will not respond while |
|---|
| .. | .. |
|---|
| 2938 | 3106 | data = qla2x00_debounce_register(®->ctrl_status); |
|---|
| 2939 | 3107 | for (cnt = 6000000 ; cnt && (data & CSR_ISP_SOFT_RESET); cnt--) { |
|---|
| 2940 | 3108 | udelay(5); |
|---|
| 2941 | | - data = RD_REG_WORD(®->ctrl_status); |
|---|
| 3109 | + data = rd_reg_word(®->ctrl_status); |
|---|
| 2942 | 3110 | barrier(); |
|---|
| 2943 | 3111 | } |
|---|
| 2944 | 3112 | |
|---|
| .. | .. |
|---|
| 2949 | 3117 | "Reset register cleared by chip reset.\n"); |
|---|
| 2950 | 3118 | |
|---|
| 2951 | 3119 | /* Reset RISC processor. */ |
|---|
| 2952 | | - WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
|---|
| 2953 | | - WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
|---|
| 3120 | + wrt_reg_word(®->hccr, HCCR_RESET_RISC); |
|---|
| 3121 | + wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); |
|---|
| 2954 | 3122 | |
|---|
| 2955 | 3123 | /* Workaround for QLA2312 PCI parity error */ |
|---|
| 2956 | 3124 | if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) { |
|---|
| .. | .. |
|---|
| 3056 | 3224 | } |
|---|
| 3057 | 3225 | |
|---|
| 3058 | 3226 | static void |
|---|
| 3059 | | -qla2x00_alloc_offload_mem(scsi_qla_host_t *vha) |
|---|
| 3227 | +qla2x00_init_fce_trace(scsi_qla_host_t *vha) |
|---|
| 3060 | 3228 | { |
|---|
| 3061 | 3229 | int rval; |
|---|
| 3062 | 3230 | dma_addr_t tc_dma; |
|---|
| 3063 | 3231 | void *tc; |
|---|
| 3064 | 3232 | struct qla_hw_data *ha = vha->hw; |
|---|
| 3065 | 3233 | |
|---|
| 3234 | + if (!IS_FWI2_CAPABLE(ha)) |
|---|
| 3235 | + return; |
|---|
| 3236 | + |
|---|
| 3237 | + if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha) && |
|---|
| 3238 | + !IS_QLA27XX(ha) && !IS_QLA28XX(ha)) |
|---|
| 3239 | + return; |
|---|
| 3240 | + |
|---|
| 3241 | + if (ha->fce) { |
|---|
| 3242 | + ql_dbg(ql_dbg_init, vha, 0x00bd, |
|---|
| 3243 | + "%s: FCE Mem is already allocated.\n", |
|---|
| 3244 | + __func__); |
|---|
| 3245 | + return; |
|---|
| 3246 | + } |
|---|
| 3247 | + |
|---|
| 3248 | + /* Allocate memory for Fibre Channel Event Buffer. */ |
|---|
| 3249 | + tc = dma_alloc_coherent(&ha->pdev->dev, FCE_SIZE, &tc_dma, |
|---|
| 3250 | + GFP_KERNEL); |
|---|
| 3251 | + if (!tc) { |
|---|
| 3252 | + ql_log(ql_log_warn, vha, 0x00be, |
|---|
| 3253 | + "Unable to allocate (%d KB) for FCE.\n", |
|---|
| 3254 | + FCE_SIZE / 1024); |
|---|
| 3255 | + return; |
|---|
| 3256 | + } |
|---|
| 3257 | + |
|---|
| 3258 | + rval = qla2x00_enable_fce_trace(vha, tc_dma, FCE_NUM_BUFFERS, |
|---|
| 3259 | + ha->fce_mb, &ha->fce_bufs); |
|---|
| 3260 | + if (rval) { |
|---|
| 3261 | + ql_log(ql_log_warn, vha, 0x00bf, |
|---|
| 3262 | + "Unable to initialize FCE (%d).\n", rval); |
|---|
| 3263 | + dma_free_coherent(&ha->pdev->dev, FCE_SIZE, tc, tc_dma); |
|---|
| 3264 | + return; |
|---|
| 3265 | + } |
|---|
| 3266 | + |
|---|
| 3267 | + ql_dbg(ql_dbg_init, vha, 0x00c0, |
|---|
| 3268 | + "Allocated (%d KB) for FCE...\n", FCE_SIZE / 1024); |
|---|
| 3269 | + |
|---|
| 3270 | + ha->flags.fce_enabled = 1; |
|---|
| 3271 | + ha->fce_dma = tc_dma; |
|---|
| 3272 | + ha->fce = tc; |
|---|
| 3273 | +} |
|---|
| 3274 | + |
|---|
| 3275 | +static void |
|---|
| 3276 | +qla2x00_init_eft_trace(scsi_qla_host_t *vha) |
|---|
| 3277 | +{ |
|---|
| 3278 | + int rval; |
|---|
| 3279 | + dma_addr_t tc_dma; |
|---|
| 3280 | + void *tc; |
|---|
| 3281 | + struct qla_hw_data *ha = vha->hw; |
|---|
| 3282 | + |
|---|
| 3283 | + if (!IS_FWI2_CAPABLE(ha)) |
|---|
| 3284 | + return; |
|---|
| 3285 | + |
|---|
| 3066 | 3286 | if (ha->eft) { |
|---|
| 3067 | 3287 | ql_dbg(ql_dbg_init, vha, 0x00bd, |
|---|
| 3068 | | - "%s: Offload Mem is already allocated.\n", |
|---|
| 3288 | + "%s: EFT Mem is already allocated.\n", |
|---|
| 3069 | 3289 | __func__); |
|---|
| 3070 | 3290 | return; |
|---|
| 3071 | 3291 | } |
|---|
| 3072 | 3292 | |
|---|
| 3073 | | - if (IS_FWI2_CAPABLE(ha)) { |
|---|
| 3074 | | - /* Allocate memory for Fibre Channel Event Buffer. */ |
|---|
| 3075 | | - if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha) && |
|---|
| 3076 | | - !IS_QLA27XX(ha)) |
|---|
| 3077 | | - goto try_eft; |
|---|
| 3078 | | - |
|---|
| 3079 | | - if (ha->fce) |
|---|
| 3080 | | - dma_free_coherent(&ha->pdev->dev, |
|---|
| 3081 | | - FCE_SIZE, ha->fce, ha->fce_dma); |
|---|
| 3082 | | - |
|---|
| 3083 | | - /* Allocate memory for Fibre Channel Event Buffer. */ |
|---|
| 3084 | | - tc = dma_zalloc_coherent(&ha->pdev->dev, FCE_SIZE, &tc_dma, |
|---|
| 3085 | | - GFP_KERNEL); |
|---|
| 3086 | | - if (!tc) { |
|---|
| 3087 | | - ql_log(ql_log_warn, vha, 0x00be, |
|---|
| 3088 | | - "Unable to allocate (%d KB) for FCE.\n", |
|---|
| 3089 | | - FCE_SIZE / 1024); |
|---|
| 3090 | | - goto try_eft; |
|---|
| 3091 | | - } |
|---|
| 3092 | | - |
|---|
| 3093 | | - rval = qla2x00_enable_fce_trace(vha, tc_dma, FCE_NUM_BUFFERS, |
|---|
| 3094 | | - ha->fce_mb, &ha->fce_bufs); |
|---|
| 3095 | | - if (rval) { |
|---|
| 3096 | | - ql_log(ql_log_warn, vha, 0x00bf, |
|---|
| 3097 | | - "Unable to initialize FCE (%d).\n", rval); |
|---|
| 3098 | | - dma_free_coherent(&ha->pdev->dev, FCE_SIZE, tc, |
|---|
| 3099 | | - tc_dma); |
|---|
| 3100 | | - ha->flags.fce_enabled = 0; |
|---|
| 3101 | | - goto try_eft; |
|---|
| 3102 | | - } |
|---|
| 3103 | | - ql_dbg(ql_dbg_init, vha, 0x00c0, |
|---|
| 3104 | | - "Allocate (%d KB) for FCE...\n", FCE_SIZE / 1024); |
|---|
| 3105 | | - |
|---|
| 3106 | | - ha->flags.fce_enabled = 1; |
|---|
| 3107 | | - ha->fce_dma = tc_dma; |
|---|
| 3108 | | - ha->fce = tc; |
|---|
| 3109 | | - |
|---|
| 3110 | | -try_eft: |
|---|
| 3111 | | - if (ha->eft) |
|---|
| 3112 | | - dma_free_coherent(&ha->pdev->dev, |
|---|
| 3113 | | - EFT_SIZE, ha->eft, ha->eft_dma); |
|---|
| 3114 | | - |
|---|
| 3115 | | - /* Allocate memory for Extended Trace Buffer. */ |
|---|
| 3116 | | - tc = dma_zalloc_coherent(&ha->pdev->dev, EFT_SIZE, &tc_dma, |
|---|
| 3117 | | - GFP_KERNEL); |
|---|
| 3118 | | - if (!tc) { |
|---|
| 3119 | | - ql_log(ql_log_warn, vha, 0x00c1, |
|---|
| 3120 | | - "Unable to allocate (%d KB) for EFT.\n", |
|---|
| 3121 | | - EFT_SIZE / 1024); |
|---|
| 3122 | | - goto eft_err; |
|---|
| 3123 | | - } |
|---|
| 3124 | | - |
|---|
| 3125 | | - rval = qla2x00_enable_eft_trace(vha, tc_dma, EFT_NUM_BUFFERS); |
|---|
| 3126 | | - if (rval) { |
|---|
| 3127 | | - ql_log(ql_log_warn, vha, 0x00c2, |
|---|
| 3128 | | - "Unable to initialize EFT (%d).\n", rval); |
|---|
| 3129 | | - dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc, |
|---|
| 3130 | | - tc_dma); |
|---|
| 3131 | | - goto eft_err; |
|---|
| 3132 | | - } |
|---|
| 3133 | | - ql_dbg(ql_dbg_init, vha, 0x00c3, |
|---|
| 3134 | | - "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024); |
|---|
| 3135 | | - |
|---|
| 3136 | | - ha->eft_dma = tc_dma; |
|---|
| 3137 | | - ha->eft = tc; |
|---|
| 3293 | + /* Allocate memory for Extended Trace Buffer. */ |
|---|
| 3294 | + tc = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &tc_dma, |
|---|
| 3295 | + GFP_KERNEL); |
|---|
| 3296 | + if (!tc) { |
|---|
| 3297 | + ql_log(ql_log_warn, vha, 0x00c1, |
|---|
| 3298 | + "Unable to allocate (%d KB) for EFT.\n", |
|---|
| 3299 | + EFT_SIZE / 1024); |
|---|
| 3300 | + return; |
|---|
| 3138 | 3301 | } |
|---|
| 3139 | 3302 | |
|---|
| 3140 | | -eft_err: |
|---|
| 3141 | | - return; |
|---|
| 3303 | + rval = qla2x00_enable_eft_trace(vha, tc_dma, EFT_NUM_BUFFERS); |
|---|
| 3304 | + if (rval) { |
|---|
| 3305 | + ql_log(ql_log_warn, vha, 0x00c2, |
|---|
| 3306 | + "Unable to initialize EFT (%d).\n", rval); |
|---|
| 3307 | + dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc, tc_dma); |
|---|
| 3308 | + return; |
|---|
| 3309 | + } |
|---|
| 3310 | + |
|---|
| 3311 | + ql_dbg(ql_dbg_init, vha, 0x00c3, |
|---|
| 3312 | + "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024); |
|---|
| 3313 | + |
|---|
| 3314 | + ha->eft_dma = tc_dma; |
|---|
| 3315 | + ha->eft = tc; |
|---|
| 3316 | +} |
|---|
| 3317 | + |
|---|
| 3318 | +static void |
|---|
| 3319 | +qla2x00_alloc_offload_mem(scsi_qla_host_t *vha) |
|---|
| 3320 | +{ |
|---|
| 3321 | + qla2x00_init_fce_trace(vha); |
|---|
| 3322 | + qla2x00_init_eft_trace(vha); |
|---|
| 3142 | 3323 | } |
|---|
| 3143 | 3324 | |
|---|
| 3144 | 3325 | void |
|---|
| .. | .. |
|---|
| 3151 | 3332 | struct rsp_que *rsp = ha->rsp_q_map[0]; |
|---|
| 3152 | 3333 | struct qla2xxx_fw_dump *fw_dump; |
|---|
| 3153 | 3334 | |
|---|
| 3335 | + if (ha->fw_dump) { |
|---|
| 3336 | + ql_dbg(ql_dbg_init, vha, 0x00bd, |
|---|
| 3337 | + "Firmware dump already allocated.\n"); |
|---|
| 3338 | + return; |
|---|
| 3339 | + } |
|---|
| 3340 | + |
|---|
| 3341 | + ha->fw_dumped = 0; |
|---|
| 3342 | + ha->fw_dump_cap_flags = 0; |
|---|
| 3154 | 3343 | dump_size = fixed_size = mem_size = eft_size = fce_size = mq_size = 0; |
|---|
| 3155 | 3344 | req_q_size = rsp_q_size = 0; |
|---|
| 3156 | 3345 | |
|---|
| .. | .. |
|---|
| 3161 | 3350 | mem_size = (ha->fw_memory_size - 0x11000 + 1) * |
|---|
| 3162 | 3351 | sizeof(uint16_t); |
|---|
| 3163 | 3352 | } else if (IS_FWI2_CAPABLE(ha)) { |
|---|
| 3164 | | - if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
|---|
| 3353 | + if (IS_QLA83XX(ha)) |
|---|
| 3165 | 3354 | fixed_size = offsetof(struct qla83xx_fw_dump, ext_mem); |
|---|
| 3166 | 3355 | else if (IS_QLA81XX(ha)) |
|---|
| 3167 | 3356 | fixed_size = offsetof(struct qla81xx_fw_dump, ext_mem); |
|---|
| .. | .. |
|---|
| 3173 | 3362 | mem_size = (ha->fw_memory_size - 0x100000 + 1) * |
|---|
| 3174 | 3363 | sizeof(uint32_t); |
|---|
| 3175 | 3364 | if (ha->mqenable) { |
|---|
| 3176 | | - if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) |
|---|
| 3365 | + if (!IS_QLA83XX(ha)) |
|---|
| 3177 | 3366 | mq_size = sizeof(struct qla2xxx_mq_chain); |
|---|
| 3178 | 3367 | /* |
|---|
| 3179 | | - * Allocate maximum buffer size for all queues. |
|---|
| 3368 | + * Allocate maximum buffer size for all queues - Q0. |
|---|
| 3180 | 3369 | * Resizing must be done at end-of-dump processing. |
|---|
| 3181 | 3370 | */ |
|---|
| 3182 | | - mq_size += ha->max_req_queues * |
|---|
| 3371 | + mq_size += (ha->max_req_queues - 1) * |
|---|
| 3183 | 3372 | (req->length * sizeof(request_t)); |
|---|
| 3184 | | - mq_size += ha->max_rsp_queues * |
|---|
| 3373 | + mq_size += (ha->max_rsp_queues - 1) * |
|---|
| 3185 | 3374 | (rsp->length * sizeof(response_t)); |
|---|
| 3186 | 3375 | } |
|---|
| 3187 | 3376 | if (ha->tgt.atio_ring) |
|---|
| 3188 | 3377 | mq_size += ha->tgt.atio_q_length * sizeof(request_t); |
|---|
| 3189 | | - /* Allocate memory for Fibre Channel Event Buffer. */ |
|---|
| 3190 | | - if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha) && |
|---|
| 3191 | | - !IS_QLA27XX(ha)) |
|---|
| 3192 | | - goto try_eft; |
|---|
| 3193 | 3378 | |
|---|
| 3194 | | - fce_size = sizeof(struct qla2xxx_fce_chain) + FCE_SIZE; |
|---|
| 3195 | | -try_eft: |
|---|
| 3196 | | - ql_dbg(ql_dbg_init, vha, 0x00c3, |
|---|
| 3197 | | - "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024); |
|---|
| 3198 | | - eft_size = EFT_SIZE; |
|---|
| 3379 | + qla2x00_init_fce_trace(vha); |
|---|
| 3380 | + if (ha->fce) |
|---|
| 3381 | + fce_size = sizeof(struct qla2xxx_fce_chain) + FCE_SIZE; |
|---|
| 3382 | + qla2x00_init_eft_trace(vha); |
|---|
| 3383 | + if (ha->eft) |
|---|
| 3384 | + eft_size = EFT_SIZE; |
|---|
| 3199 | 3385 | } |
|---|
| 3200 | 3386 | |
|---|
| 3201 | | - if (IS_QLA27XX(ha)) { |
|---|
| 3202 | | - if (!ha->fw_dump_template) { |
|---|
| 3203 | | - ql_log(ql_log_warn, vha, 0x00ba, |
|---|
| 3204 | | - "Failed missing fwdump template\n"); |
|---|
| 3205 | | - return; |
|---|
| 3387 | + if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
|---|
| 3388 | + struct fwdt *fwdt = ha->fwdt; |
|---|
| 3389 | + uint j; |
|---|
| 3390 | + |
|---|
| 3391 | + for (j = 0; j < 2; j++, fwdt++) { |
|---|
| 3392 | + if (!fwdt->template) { |
|---|
| 3393 | + ql_dbg(ql_dbg_init, vha, 0x00ba, |
|---|
| 3394 | + "-> fwdt%u no template\n", j); |
|---|
| 3395 | + continue; |
|---|
| 3396 | + } |
|---|
| 3397 | + ql_dbg(ql_dbg_init, vha, 0x00fa, |
|---|
| 3398 | + "-> fwdt%u calculating fwdump size...\n", j); |
|---|
| 3399 | + fwdt->dump_size = qla27xx_fwdt_calculate_dump_size( |
|---|
| 3400 | + vha, fwdt->template); |
|---|
| 3401 | + ql_dbg(ql_dbg_init, vha, 0x00fa, |
|---|
| 3402 | + "-> fwdt%u calculated fwdump size = %#lx bytes\n", |
|---|
| 3403 | + j, fwdt->dump_size); |
|---|
| 3404 | + dump_size += fwdt->dump_size; |
|---|
| 3206 | 3405 | } |
|---|
| 3207 | | - dump_size = qla27xx_fwdt_calculate_dump_size(vha); |
|---|
| 3208 | | - ql_dbg(ql_dbg_init, vha, 0x00fa, |
|---|
| 3209 | | - "-> allocating fwdump (%x bytes)...\n", dump_size); |
|---|
| 3210 | | - goto allocate; |
|---|
| 3406 | + /* Add space for spare MPI fw dump. */ |
|---|
| 3407 | + dump_size += ha->fwdt[1].dump_size; |
|---|
| 3408 | + } else { |
|---|
| 3409 | + req_q_size = req->length * sizeof(request_t); |
|---|
| 3410 | + rsp_q_size = rsp->length * sizeof(response_t); |
|---|
| 3411 | + dump_size = offsetof(struct qla2xxx_fw_dump, isp); |
|---|
| 3412 | + dump_size += fixed_size + mem_size + req_q_size + rsp_q_size |
|---|
| 3413 | + + eft_size; |
|---|
| 3414 | + ha->chain_offset = dump_size; |
|---|
| 3415 | + dump_size += mq_size + fce_size; |
|---|
| 3416 | + if (ha->exchoffld_buf) |
|---|
| 3417 | + dump_size += sizeof(struct qla2xxx_offld_chain) + |
|---|
| 3418 | + ha->exchoffld_size; |
|---|
| 3419 | + if (ha->exlogin_buf) |
|---|
| 3420 | + dump_size += sizeof(struct qla2xxx_offld_chain) + |
|---|
| 3421 | + ha->exlogin_size; |
|---|
| 3211 | 3422 | } |
|---|
| 3212 | 3423 | |
|---|
| 3213 | | - req_q_size = req->length * sizeof(request_t); |
|---|
| 3214 | | - rsp_q_size = rsp->length * sizeof(response_t); |
|---|
| 3215 | | - dump_size = offsetof(struct qla2xxx_fw_dump, isp); |
|---|
| 3216 | | - dump_size += fixed_size + mem_size + req_q_size + rsp_q_size + eft_size; |
|---|
| 3217 | | - ha->chain_offset = dump_size; |
|---|
| 3218 | | - dump_size += mq_size + fce_size; |
|---|
| 3424 | + if (!ha->fw_dump_len || dump_size > ha->fw_dump_alloc_len) { |
|---|
| 3219 | 3425 | |
|---|
| 3220 | | - if (ha->exchoffld_buf) |
|---|
| 3221 | | - dump_size += sizeof(struct qla2xxx_offld_chain) + |
|---|
| 3222 | | - ha->exchoffld_size; |
|---|
| 3223 | | - if (ha->exlogin_buf) |
|---|
| 3224 | | - dump_size += sizeof(struct qla2xxx_offld_chain) + |
|---|
| 3225 | | - ha->exlogin_size; |
|---|
| 3426 | + ql_dbg(ql_dbg_init, vha, 0x00c5, |
|---|
| 3427 | + "%s dump_size %d fw_dump_len %d fw_dump_alloc_len %d\n", |
|---|
| 3428 | + __func__, dump_size, ha->fw_dump_len, |
|---|
| 3429 | + ha->fw_dump_alloc_len); |
|---|
| 3226 | 3430 | |
|---|
| 3227 | | -allocate: |
|---|
| 3228 | | - if (!ha->fw_dump_len || dump_size != ha->fw_dump_len) { |
|---|
| 3229 | 3431 | fw_dump = vmalloc(dump_size); |
|---|
| 3230 | 3432 | if (!fw_dump) { |
|---|
| 3231 | 3433 | ql_log(ql_log_warn, vha, 0x00c4, |
|---|
| 3232 | 3434 | "Unable to allocate (%d KB) for firmware dump.\n", |
|---|
| 3233 | 3435 | dump_size / 1024); |
|---|
| 3234 | 3436 | } else { |
|---|
| 3235 | | - if (ha->fw_dump) |
|---|
| 3437 | + mutex_lock(&ha->optrom_mutex); |
|---|
| 3438 | + if (ha->fw_dumped) { |
|---|
| 3439 | + memcpy(fw_dump, ha->fw_dump, ha->fw_dump_len); |
|---|
| 3236 | 3440 | vfree(ha->fw_dump); |
|---|
| 3237 | | - ha->fw_dump = fw_dump; |
|---|
| 3441 | + ha->fw_dump = fw_dump; |
|---|
| 3442 | + ha->fw_dump_alloc_len = dump_size; |
|---|
| 3443 | + ql_dbg(ql_dbg_init, vha, 0x00c5, |
|---|
| 3444 | + "Re-Allocated (%d KB) and save firmware dump.\n", |
|---|
| 3445 | + dump_size / 1024); |
|---|
| 3446 | + } else { |
|---|
| 3447 | + if (ha->fw_dump) |
|---|
| 3448 | + vfree(ha->fw_dump); |
|---|
| 3449 | + ha->fw_dump = fw_dump; |
|---|
| 3238 | 3450 | |
|---|
| 3239 | | - ha->fw_dump_len = dump_size; |
|---|
| 3240 | | - ql_dbg(ql_dbg_init, vha, 0x00c5, |
|---|
| 3241 | | - "Allocated (%d KB) for firmware dump.\n", |
|---|
| 3242 | | - dump_size / 1024); |
|---|
| 3451 | + ha->fw_dump_len = ha->fw_dump_alloc_len = |
|---|
| 3452 | + dump_size; |
|---|
| 3453 | + ql_dbg(ql_dbg_init, vha, 0x00c5, |
|---|
| 3454 | + "Allocated (%d KB) for firmware dump.\n", |
|---|
| 3455 | + dump_size / 1024); |
|---|
| 3243 | 3456 | |
|---|
| 3244 | | - if (IS_QLA27XX(ha)) |
|---|
| 3245 | | - return; |
|---|
| 3457 | + if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
|---|
| 3458 | + ha->mpi_fw_dump = (char *)fw_dump + |
|---|
| 3459 | + ha->fwdt[1].dump_size; |
|---|
| 3460 | + mutex_unlock(&ha->optrom_mutex); |
|---|
| 3461 | + return; |
|---|
| 3462 | + } |
|---|
| 3246 | 3463 | |
|---|
| 3247 | | - ha->fw_dump->signature[0] = 'Q'; |
|---|
| 3248 | | - ha->fw_dump->signature[1] = 'L'; |
|---|
| 3249 | | - ha->fw_dump->signature[2] = 'G'; |
|---|
| 3250 | | - ha->fw_dump->signature[3] = 'C'; |
|---|
| 3251 | | - ha->fw_dump->version = htonl(1); |
|---|
| 3464 | + ha->fw_dump->signature[0] = 'Q'; |
|---|
| 3465 | + ha->fw_dump->signature[1] = 'L'; |
|---|
| 3466 | + ha->fw_dump->signature[2] = 'G'; |
|---|
| 3467 | + ha->fw_dump->signature[3] = 'C'; |
|---|
| 3468 | + ha->fw_dump->version = htonl(1); |
|---|
| 3252 | 3469 | |
|---|
| 3253 | | - ha->fw_dump->fixed_size = htonl(fixed_size); |
|---|
| 3254 | | - ha->fw_dump->mem_size = htonl(mem_size); |
|---|
| 3255 | | - ha->fw_dump->req_q_size = htonl(req_q_size); |
|---|
| 3256 | | - ha->fw_dump->rsp_q_size = htonl(rsp_q_size); |
|---|
| 3470 | + ha->fw_dump->fixed_size = htonl(fixed_size); |
|---|
| 3471 | + ha->fw_dump->mem_size = htonl(mem_size); |
|---|
| 3472 | + ha->fw_dump->req_q_size = htonl(req_q_size); |
|---|
| 3473 | + ha->fw_dump->rsp_q_size = htonl(rsp_q_size); |
|---|
| 3257 | 3474 | |
|---|
| 3258 | | - ha->fw_dump->eft_size = htonl(eft_size); |
|---|
| 3259 | | - ha->fw_dump->eft_addr_l = htonl(LSD(ha->eft_dma)); |
|---|
| 3260 | | - ha->fw_dump->eft_addr_h = htonl(MSD(ha->eft_dma)); |
|---|
| 3475 | + ha->fw_dump->eft_size = htonl(eft_size); |
|---|
| 3476 | + ha->fw_dump->eft_addr_l = |
|---|
| 3477 | + htonl(LSD(ha->eft_dma)); |
|---|
| 3478 | + ha->fw_dump->eft_addr_h = |
|---|
| 3479 | + htonl(MSD(ha->eft_dma)); |
|---|
| 3261 | 3480 | |
|---|
| 3262 | | - ha->fw_dump->header_size = |
|---|
| 3263 | | - htonl(offsetof(struct qla2xxx_fw_dump, isp)); |
|---|
| 3481 | + ha->fw_dump->header_size = |
|---|
| 3482 | + htonl(offsetof |
|---|
| 3483 | + (struct qla2xxx_fw_dump, isp)); |
|---|
| 3484 | + } |
|---|
| 3485 | + mutex_unlock(&ha->optrom_mutex); |
|---|
| 3264 | 3486 | } |
|---|
| 3265 | 3487 | } |
|---|
| 3266 | 3488 | } |
|---|
| .. | .. |
|---|
| 3446 | 3668 | } |
|---|
| 3447 | 3669 | |
|---|
| 3448 | 3670 | |
|---|
| 3449 | | -/* |
|---|
| 3450 | | - * Return Code: |
|---|
| 3451 | | - * QLA_SUCCESS: no action |
|---|
| 3452 | | - * QLA_INTERFACE_ERROR: SFP is not there. |
|---|
| 3453 | | - * QLA_FUNCTION_FAILED: detected New SFP |
|---|
| 3671 | +/** |
|---|
| 3672 | + * qla24xx_detect_sfp() |
|---|
| 3673 | + * |
|---|
| 3674 | + * @vha: adapter state pointer. |
|---|
| 3675 | + * |
|---|
| 3676 | + * @return |
|---|
| 3677 | + * 0 -- Configure firmware to use short-range settings -- normal |
|---|
| 3678 | + * buffer-to-buffer credits. |
|---|
| 3679 | + * |
|---|
| 3680 | + * 1 -- Configure firmware to use long-range settings -- extra |
|---|
| 3681 | + * buffer-to-buffer credits should be allocated with |
|---|
| 3682 | + * ha->lr_distance containing distance settings from NVRAM or SFP |
|---|
| 3683 | + * (if supported). |
|---|
| 3454 | 3684 | */ |
|---|
| 3455 | 3685 | int |
|---|
| 3456 | 3686 | qla24xx_detect_sfp(scsi_qla_host_t *vha) |
|---|
| 3457 | 3687 | { |
|---|
| 3458 | | - int rc = QLA_SUCCESS; |
|---|
| 3688 | + int rc, used_nvram; |
|---|
| 3459 | 3689 | struct sff_8247_a0 *a; |
|---|
| 3460 | 3690 | struct qla_hw_data *ha = vha->hw; |
|---|
| 3691 | + struct nvram_81xx *nv = ha->nvram; |
|---|
| 3692 | +#define LR_DISTANCE_UNKNOWN 2 |
|---|
| 3693 | + static const char * const types[] = { "Short", "Long" }; |
|---|
| 3694 | + static const char * const lengths[] = { "(10km)", "(5km)", "" }; |
|---|
| 3695 | + u8 ll = 0; |
|---|
| 3461 | 3696 | |
|---|
| 3462 | | - if (!AUTO_DETECT_SFP_SUPPORT(vha)) |
|---|
| 3697 | + /* Seed with NVRAM settings. */ |
|---|
| 3698 | + used_nvram = 0; |
|---|
| 3699 | + ha->flags.lr_detected = 0; |
|---|
| 3700 | + if (IS_BPM_RANGE_CAPABLE(ha) && |
|---|
| 3701 | + (nv->enhanced_features & NEF_LR_DIST_ENABLE)) { |
|---|
| 3702 | + used_nvram = 1; |
|---|
| 3703 | + ha->flags.lr_detected = 1; |
|---|
| 3704 | + ha->lr_distance = |
|---|
| 3705 | + (nv->enhanced_features >> LR_DIST_NV_POS) |
|---|
| 3706 | + & LR_DIST_NV_MASK; |
|---|
| 3707 | + } |
|---|
| 3708 | + |
|---|
| 3709 | + if (!IS_BPM_ENABLED(vha)) |
|---|
| 3463 | 3710 | goto out; |
|---|
| 3464 | | - |
|---|
| 3711 | + /* Determine SR/LR capabilities of SFP/Transceiver. */ |
|---|
| 3465 | 3712 | rc = qla2x00_read_sfp_dev(vha, NULL, 0); |
|---|
| 3466 | 3713 | if (rc) |
|---|
| 3467 | 3714 | goto out; |
|---|
| 3468 | 3715 | |
|---|
| 3716 | + used_nvram = 0; |
|---|
| 3469 | 3717 | a = (struct sff_8247_a0 *)vha->hw->sfp_data; |
|---|
| 3470 | 3718 | qla2xxx_print_sfp_info(vha); |
|---|
| 3471 | 3719 | |
|---|
| 3472 | | - if (a->fc_ll_cc7 & FC_LL_VL || a->fc_ll_cc7 & FC_LL_L) { |
|---|
| 3473 | | - /* long range */ |
|---|
| 3474 | | - ha->flags.detected_lr_sfp = 1; |
|---|
| 3720 | + ha->flags.lr_detected = 0; |
|---|
| 3721 | + ll = a->fc_ll_cc7; |
|---|
| 3722 | + if (ll & FC_LL_VL || ll & FC_LL_L) { |
|---|
| 3723 | + /* Long range, track length. */ |
|---|
| 3724 | + ha->flags.lr_detected = 1; |
|---|
| 3475 | 3725 | |
|---|
| 3476 | 3726 | if (a->length_km > 5 || a->length_100m > 50) |
|---|
| 3477 | | - ha->long_range_distance = LR_DISTANCE_10K; |
|---|
| 3727 | + ha->lr_distance = LR_DISTANCE_10K; |
|---|
| 3478 | 3728 | else |
|---|
| 3479 | | - ha->long_range_distance = LR_DISTANCE_5K; |
|---|
| 3480 | | - |
|---|
| 3481 | | - if (ha->flags.detected_lr_sfp != ha->flags.using_lr_setting) |
|---|
| 3482 | | - ql_dbg(ql_dbg_async, vha, 0x507b, |
|---|
| 3483 | | - "Detected Long Range SFP.\n"); |
|---|
| 3484 | | - } else { |
|---|
| 3485 | | - /* short range */ |
|---|
| 3486 | | - ha->flags.detected_lr_sfp = 0; |
|---|
| 3487 | | - if (ha->flags.using_lr_setting) |
|---|
| 3488 | | - ql_dbg(ql_dbg_async, vha, 0x5084, |
|---|
| 3489 | | - "Detected Short Range SFP.\n"); |
|---|
| 3729 | + ha->lr_distance = LR_DISTANCE_5K; |
|---|
| 3490 | 3730 | } |
|---|
| 3491 | 3731 | |
|---|
| 3492 | | - if (!vha->flags.init_done) |
|---|
| 3493 | | - rc = QLA_SUCCESS; |
|---|
| 3494 | 3732 | out: |
|---|
| 3495 | | - return rc; |
|---|
| 3733 | + ql_dbg(ql_dbg_async, vha, 0x507b, |
|---|
| 3734 | + "SFP detect: %s-Range SFP %s (nvr=%x ll=%x lr=%x lrd=%x).\n", |
|---|
| 3735 | + types[ha->flags.lr_detected], |
|---|
| 3736 | + ha->flags.lr_detected ? lengths[ha->lr_distance] : |
|---|
| 3737 | + lengths[LR_DISTANCE_UNKNOWN], |
|---|
| 3738 | + used_nvram, ll, ha->flags.lr_detected, ha->lr_distance); |
|---|
| 3739 | + return ha->flags.lr_detected; |
|---|
| 3740 | +} |
|---|
| 3741 | + |
|---|
| 3742 | +void qla_init_iocb_limit(scsi_qla_host_t *vha) |
|---|
| 3743 | +{ |
|---|
| 3744 | + u16 i, num_qps; |
|---|
| 3745 | + u32 limit; |
|---|
| 3746 | + struct qla_hw_data *ha = vha->hw; |
|---|
| 3747 | + |
|---|
| 3748 | + num_qps = ha->num_qpairs + 1; |
|---|
| 3749 | + limit = (ha->orig_fw_iocb_count * QLA_IOCB_PCT_LIMIT) / 100; |
|---|
| 3750 | + |
|---|
| 3751 | + ha->base_qpair->fwres.iocbs_total = ha->orig_fw_iocb_count; |
|---|
| 3752 | + ha->base_qpair->fwres.iocbs_limit = limit; |
|---|
| 3753 | + ha->base_qpair->fwres.iocbs_qp_limit = limit / num_qps; |
|---|
| 3754 | + ha->base_qpair->fwres.iocbs_used = 0; |
|---|
| 3755 | + for (i = 0; i < ha->max_qpairs; i++) { |
|---|
| 3756 | + if (ha->queue_pair_map[i]) { |
|---|
| 3757 | + ha->queue_pair_map[i]->fwres.iocbs_total = |
|---|
| 3758 | + ha->orig_fw_iocb_count; |
|---|
| 3759 | + ha->queue_pair_map[i]->fwres.iocbs_limit = limit; |
|---|
| 3760 | + ha->queue_pair_map[i]->fwres.iocbs_qp_limit = |
|---|
| 3761 | + limit / num_qps; |
|---|
| 3762 | + ha->queue_pair_map[i]->fwres.iocbs_used = 0; |
|---|
| 3763 | + } |
|---|
| 3764 | + } |
|---|
| 3496 | 3765 | } |
|---|
| 3497 | 3766 | |
|---|
| 3498 | 3767 | /** |
|---|
| .. | .. |
|---|
| 3510 | 3779 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
|---|
| 3511 | 3780 | unsigned long flags; |
|---|
| 3512 | 3781 | uint16_t fw_major_version; |
|---|
| 3782 | + int done_once = 0; |
|---|
| 3513 | 3783 | |
|---|
| 3514 | 3784 | if (IS_P3P_TYPE(ha)) { |
|---|
| 3515 | 3785 | rval = ha->isp_ops->load_risc(vha, &srisc_address); |
|---|
| .. | .. |
|---|
| 3523 | 3793 | if (!IS_FWI2_CAPABLE(ha) && !IS_QLA2100(ha) && !IS_QLA2200(ha)) { |
|---|
| 3524 | 3794 | /* Disable SRAM, Instruction RAM and GP RAM parity. */ |
|---|
| 3525 | 3795 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 3526 | | - WRT_REG_WORD(®->hccr, (HCCR_ENABLE_PARITY + 0x0)); |
|---|
| 3527 | | - RD_REG_WORD(®->hccr); |
|---|
| 3796 | + wrt_reg_word(®->hccr, (HCCR_ENABLE_PARITY + 0x0)); |
|---|
| 3797 | + rd_reg_word(®->hccr); |
|---|
| 3528 | 3798 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 3529 | 3799 | } |
|---|
| 3530 | 3800 | |
|---|
| 3531 | 3801 | qla81xx_mpi_sync(vha); |
|---|
| 3532 | 3802 | |
|---|
| 3803 | +execute_fw_with_lr: |
|---|
| 3533 | 3804 | /* Load firmware sequences */ |
|---|
| 3534 | 3805 | rval = ha->isp_ops->load_risc(vha, &srisc_address); |
|---|
| 3535 | 3806 | if (rval == QLA_SUCCESS) { |
|---|
| .. | .. |
|---|
| 3551 | 3822 | rval = qla2x00_execute_fw(vha, srisc_address); |
|---|
| 3552 | 3823 | /* Retrieve firmware information. */ |
|---|
| 3553 | 3824 | if (rval == QLA_SUCCESS) { |
|---|
| 3554 | | - qla24xx_detect_sfp(vha); |
|---|
| 3825 | + /* Enable BPM support? */ |
|---|
| 3826 | + if (!done_once++ && qla24xx_detect_sfp(vha)) { |
|---|
| 3827 | + ql_dbg(ql_dbg_init, vha, 0x00ca, |
|---|
| 3828 | + "Re-starting firmware -- BPM.\n"); |
|---|
| 3829 | + /* Best-effort - re-init. */ |
|---|
| 3830 | + ha->isp_ops->reset_chip(vha); |
|---|
| 3831 | + ha->isp_ops->chip_diag(vha); |
|---|
| 3832 | + goto execute_fw_with_lr; |
|---|
| 3833 | + } |
|---|
| 3834 | + |
|---|
| 3835 | + if (IS_ZIO_THRESHOLD_CAPABLE(ha)) |
|---|
| 3836 | + qla27xx_set_zio_threshold(vha, |
|---|
| 3837 | + ha->last_zio_threshold); |
|---|
| 3555 | 3838 | |
|---|
| 3556 | 3839 | rval = qla2x00_set_exlogins_buffer(vha); |
|---|
| 3557 | 3840 | if (rval != QLA_SUCCESS) |
|---|
| .. | .. |
|---|
| 3580 | 3863 | MIN_MULTI_ID_FABRIC - 1; |
|---|
| 3581 | 3864 | } |
|---|
| 3582 | 3865 | qla2x00_get_resource_cnts(vha); |
|---|
| 3866 | + qla_init_iocb_limit(vha); |
|---|
| 3583 | 3867 | |
|---|
| 3584 | 3868 | /* |
|---|
| 3585 | 3869 | * Allocate the array of outstanding commands |
|---|
| .. | .. |
|---|
| 3604 | 3888 | "ISP Firmware failed checksum.\n"); |
|---|
| 3605 | 3889 | goto failed; |
|---|
| 3606 | 3890 | } |
|---|
| 3891 | + |
|---|
| 3892 | + /* Enable PUREX PASSTHRU */ |
|---|
| 3893 | + if (ql2xrdpenable || ha->flags.scm_supported_f) |
|---|
| 3894 | + qla25xx_set_els_cmds_supported(vha); |
|---|
| 3607 | 3895 | } else |
|---|
| 3608 | 3896 | goto failed; |
|---|
| 3609 | 3897 | |
|---|
| .. | .. |
|---|
| 3612 | 3900 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 3613 | 3901 | if (IS_QLA2300(ha)) |
|---|
| 3614 | 3902 | /* SRAM parity */ |
|---|
| 3615 | | - WRT_REG_WORD(®->hccr, HCCR_ENABLE_PARITY + 0x1); |
|---|
| 3903 | + wrt_reg_word(®->hccr, HCCR_ENABLE_PARITY + 0x1); |
|---|
| 3616 | 3904 | else |
|---|
| 3617 | 3905 | /* SRAM, Instruction RAM and GP RAM parity */ |
|---|
| 3618 | | - WRT_REG_WORD(®->hccr, HCCR_ENABLE_PARITY + 0x7); |
|---|
| 3619 | | - RD_REG_WORD(®->hccr); |
|---|
| 3906 | + wrt_reg_word(®->hccr, HCCR_ENABLE_PARITY + 0x7); |
|---|
| 3907 | + rd_reg_word(®->hccr); |
|---|
| 3620 | 3908 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 3621 | 3909 | } |
|---|
| 3622 | 3910 | |
|---|
| 3623 | | - if (IS_QLA27XX(ha)) |
|---|
| 3911 | + if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) |
|---|
| 3624 | 3912 | ha->flags.fac_supported = 1; |
|---|
| 3625 | 3913 | else if (rval == QLA_SUCCESS && IS_FAC_REQUIRED(ha)) { |
|---|
| 3626 | 3914 | uint32_t size; |
|---|
| .. | .. |
|---|
| 3635 | 3923 | ha->fw_major_version, ha->fw_minor_version, |
|---|
| 3636 | 3924 | ha->fw_subminor_version); |
|---|
| 3637 | 3925 | |
|---|
| 3638 | | - if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
|---|
| 3926 | + if (IS_QLA83XX(ha)) { |
|---|
| 3639 | 3927 | ha->flags.fac_supported = 0; |
|---|
| 3640 | 3928 | rval = QLA_SUCCESS; |
|---|
| 3641 | 3929 | } |
|---|
| .. | .. |
|---|
| 3697 | 3985 | ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x0115, |
|---|
| 3698 | 3986 | "Serial link options.\n"); |
|---|
| 3699 | 3987 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0109, |
|---|
| 3700 | | - (uint8_t *)&ha->fw_seriallink_options, |
|---|
| 3701 | | - sizeof(ha->fw_seriallink_options)); |
|---|
| 3988 | + ha->fw_seriallink_options, sizeof(ha->fw_seriallink_options)); |
|---|
| 3702 | 3989 | |
|---|
| 3703 | 3990 | ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING; |
|---|
| 3704 | 3991 | if (ha->fw_seriallink_options[3] & BIT_2) { |
|---|
| .. | .. |
|---|
| 3788 | 4075 | |
|---|
| 3789 | 4076 | /* Move PUREX, ABTS RX & RIDA to ATIOQ */ |
|---|
| 3790 | 4077 | if (ql2xmvasynctoatio && |
|---|
| 3791 | | - (IS_QLA83XX(ha) || IS_QLA27XX(ha))) { |
|---|
| 4078 | + (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))) { |
|---|
| 3792 | 4079 | if (qla_tgt_mode_enabled(vha) || |
|---|
| 3793 | 4080 | qla_dual_mode_enabled(vha)) |
|---|
| 3794 | 4081 | ha->fw_options[2] |= BIT_11; |
|---|
| .. | .. |
|---|
| 3796 | 4083 | ha->fw_options[2] &= ~BIT_11; |
|---|
| 3797 | 4084 | } |
|---|
| 3798 | 4085 | |
|---|
| 3799 | | - if (IS_QLA25XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
|---|
| 4086 | + if (IS_QLA25XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha) || |
|---|
| 4087 | + IS_QLA28XX(ha)) { |
|---|
| 3800 | 4088 | /* |
|---|
| 3801 | 4089 | * Tell FW to track each exchange to prevent |
|---|
| 3802 | 4090 | * driver from using stale exchange. |
|---|
| .. | .. |
|---|
| 3813 | 4101 | else |
|---|
| 3814 | 4102 | ha->fw_options[2] &= ~BIT_8; |
|---|
| 3815 | 4103 | } |
|---|
| 4104 | + |
|---|
| 4105 | + if (ql2xrdpenable || ha->flags.scm_supported_f) |
|---|
| 4106 | + ha->fw_options[1] |= ADD_FO1_ENABLE_PUREX_IOCB; |
|---|
| 4107 | + |
|---|
| 4108 | + /* Enable Async 8130/8131 events -- transceiver insertion/removal */ |
|---|
| 4109 | + if (IS_BPM_RANGE_CAPABLE(ha)) |
|---|
| 4110 | + ha->fw_options[3] |= BIT_10; |
|---|
| 3816 | 4111 | |
|---|
| 3817 | 4112 | ql_dbg(ql_dbg_init, vha, 0x00e8, |
|---|
| 3818 | 4113 | "%s, add FW options 1-3 = 0x%04x 0x%04x 0x%04x mode %x\n", |
|---|
| .. | .. |
|---|
| 3849 | 4144 | ha->init_cb->response_q_inpointer = cpu_to_le16(0); |
|---|
| 3850 | 4145 | ha->init_cb->request_q_length = cpu_to_le16(req->length); |
|---|
| 3851 | 4146 | ha->init_cb->response_q_length = cpu_to_le16(rsp->length); |
|---|
| 3852 | | - ha->init_cb->request_q_address[0] = cpu_to_le32(LSD(req->dma)); |
|---|
| 3853 | | - ha->init_cb->request_q_address[1] = cpu_to_le32(MSD(req->dma)); |
|---|
| 3854 | | - ha->init_cb->response_q_address[0] = cpu_to_le32(LSD(rsp->dma)); |
|---|
| 3855 | | - ha->init_cb->response_q_address[1] = cpu_to_le32(MSD(rsp->dma)); |
|---|
| 4147 | + put_unaligned_le64(req->dma, &ha->init_cb->request_q_address); |
|---|
| 4148 | + put_unaligned_le64(rsp->dma, &ha->init_cb->response_q_address); |
|---|
| 3856 | 4149 | |
|---|
| 3857 | | - WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), 0); |
|---|
| 3858 | | - WRT_REG_WORD(ISP_REQ_Q_OUT(ha, reg), 0); |
|---|
| 3859 | | - WRT_REG_WORD(ISP_RSP_Q_IN(ha, reg), 0); |
|---|
| 3860 | | - WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), 0); |
|---|
| 3861 | | - RD_REG_WORD(ISP_RSP_Q_OUT(ha, reg)); /* PCI Posting. */ |
|---|
| 4150 | + wrt_reg_word(ISP_REQ_Q_IN(ha, reg), 0); |
|---|
| 4151 | + wrt_reg_word(ISP_REQ_Q_OUT(ha, reg), 0); |
|---|
| 4152 | + wrt_reg_word(ISP_RSP_Q_IN(ha, reg), 0); |
|---|
| 4153 | + wrt_reg_word(ISP_RSP_Q_OUT(ha, reg), 0); |
|---|
| 4154 | + rd_reg_word(ISP_RSP_Q_OUT(ha, reg)); /* PCI Posting. */ |
|---|
| 3862 | 4155 | } |
|---|
| 3863 | 4156 | |
|---|
| 3864 | 4157 | void |
|---|
| .. | .. |
|---|
| 3879 | 4172 | icb->response_q_inpointer = cpu_to_le16(0); |
|---|
| 3880 | 4173 | icb->request_q_length = cpu_to_le16(req->length); |
|---|
| 3881 | 4174 | icb->response_q_length = cpu_to_le16(rsp->length); |
|---|
| 3882 | | - icb->request_q_address[0] = cpu_to_le32(LSD(req->dma)); |
|---|
| 3883 | | - icb->request_q_address[1] = cpu_to_le32(MSD(req->dma)); |
|---|
| 3884 | | - icb->response_q_address[0] = cpu_to_le32(LSD(rsp->dma)); |
|---|
| 3885 | | - icb->response_q_address[1] = cpu_to_le32(MSD(rsp->dma)); |
|---|
| 4175 | + put_unaligned_le64(req->dma, &icb->request_q_address); |
|---|
| 4176 | + put_unaligned_le64(rsp->dma, &icb->response_q_address); |
|---|
| 3886 | 4177 | |
|---|
| 3887 | 4178 | /* Setup ATIO queue dma pointers for target mode */ |
|---|
| 3888 | 4179 | icb->atio_q_inpointer = cpu_to_le16(0); |
|---|
| 3889 | 4180 | icb->atio_q_length = cpu_to_le16(ha->tgt.atio_q_length); |
|---|
| 3890 | | - icb->atio_q_address[0] = cpu_to_le32(LSD(ha->tgt.atio_dma)); |
|---|
| 3891 | | - icb->atio_q_address[1] = cpu_to_le32(MSD(ha->tgt.atio_dma)); |
|---|
| 4181 | + put_unaligned_le64(ha->tgt.atio_dma, &icb->atio_q_address); |
|---|
| 3892 | 4182 | |
|---|
| 3893 | 4183 | if (IS_SHADOW_REG_CAPABLE(ha)) |
|---|
| 3894 | 4184 | icb->firmware_options_2 |= cpu_to_le32(BIT_30|BIT_29); |
|---|
| 3895 | 4185 | |
|---|
| 3896 | | - if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
|---|
| 4186 | + if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha) || |
|---|
| 4187 | + IS_QLA28XX(ha)) { |
|---|
| 3897 | 4188 | icb->qos = cpu_to_le16(QLA_DEFAULT_QUE_QOS); |
|---|
| 3898 | 4189 | icb->rid = cpu_to_le16(rid); |
|---|
| 3899 | 4190 | if (ha->flags.msix_enabled) { |
|---|
| .. | .. |
|---|
| 3922 | 4213 | } |
|---|
| 3923 | 4214 | icb->firmware_options_2 |= cpu_to_le32(BIT_23); |
|---|
| 3924 | 4215 | |
|---|
| 3925 | | - WRT_REG_DWORD(®->isp25mq.req_q_in, 0); |
|---|
| 3926 | | - WRT_REG_DWORD(®->isp25mq.req_q_out, 0); |
|---|
| 3927 | | - WRT_REG_DWORD(®->isp25mq.rsp_q_in, 0); |
|---|
| 3928 | | - WRT_REG_DWORD(®->isp25mq.rsp_q_out, 0); |
|---|
| 4216 | + wrt_reg_dword(®->isp25mq.req_q_in, 0); |
|---|
| 4217 | + wrt_reg_dword(®->isp25mq.req_q_out, 0); |
|---|
| 4218 | + wrt_reg_dword(®->isp25mq.rsp_q_in, 0); |
|---|
| 4219 | + wrt_reg_dword(®->isp25mq.rsp_q_out, 0); |
|---|
| 3929 | 4220 | } else { |
|---|
| 3930 | | - WRT_REG_DWORD(®->isp24.req_q_in, 0); |
|---|
| 3931 | | - WRT_REG_DWORD(®->isp24.req_q_out, 0); |
|---|
| 3932 | | - WRT_REG_DWORD(®->isp24.rsp_q_in, 0); |
|---|
| 3933 | | - WRT_REG_DWORD(®->isp24.rsp_q_out, 0); |
|---|
| 4221 | + wrt_reg_dword(®->isp24.req_q_in, 0); |
|---|
| 4222 | + wrt_reg_dword(®->isp24.req_q_out, 0); |
|---|
| 4223 | + wrt_reg_dword(®->isp24.rsp_q_in, 0); |
|---|
| 4224 | + wrt_reg_dword(®->isp24.rsp_q_out, 0); |
|---|
| 3934 | 4225 | } |
|---|
| 4226 | + |
|---|
| 3935 | 4227 | qlt_24xx_config_rings(vha); |
|---|
| 3936 | 4228 | |
|---|
| 4229 | + /* If the user has configured the speed, set it here */ |
|---|
| 4230 | + if (ha->set_data_rate) { |
|---|
| 4231 | + ql_dbg(ql_dbg_init, vha, 0x00fd, |
|---|
| 4232 | + "Speed set by user : %s Gbps \n", |
|---|
| 4233 | + qla2x00_get_link_speed_str(ha, ha->set_data_rate)); |
|---|
| 4234 | + icb->firmware_options_3 = cpu_to_le32(ha->set_data_rate << 13); |
|---|
| 4235 | + } |
|---|
| 4236 | + |
|---|
| 3937 | 4237 | /* PCI posting */ |
|---|
| 3938 | | - RD_REG_DWORD(&ioreg->hccr); |
|---|
| 4238 | + rd_reg_word(&ioreg->hccr); |
|---|
| 3939 | 4239 | } |
|---|
| 3940 | 4240 | |
|---|
| 3941 | 4241 | /** |
|---|
| .. | .. |
|---|
| 3966 | 4266 | req = ha->req_q_map[que]; |
|---|
| 3967 | 4267 | if (!req || !test_bit(que, ha->req_qid_map)) |
|---|
| 3968 | 4268 | continue; |
|---|
| 3969 | | - req->out_ptr = (void *)(req->ring + req->length); |
|---|
| 4269 | + req->out_ptr = (uint16_t *)(req->ring + req->length); |
|---|
| 3970 | 4270 | *req->out_ptr = 0; |
|---|
| 3971 | 4271 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) |
|---|
| 3972 | 4272 | req->outstanding_cmds[cnt] = NULL; |
|---|
| .. | .. |
|---|
| 3983 | 4283 | rsp = ha->rsp_q_map[que]; |
|---|
| 3984 | 4284 | if (!rsp || !test_bit(que, ha->rsp_qid_map)) |
|---|
| 3985 | 4285 | continue; |
|---|
| 3986 | | - rsp->in_ptr = (void *)(rsp->ring + rsp->length); |
|---|
| 4286 | + rsp->in_ptr = (uint16_t *)(rsp->ring + rsp->length); |
|---|
| 3987 | 4287 | *rsp->in_ptr = 0; |
|---|
| 3988 | 4288 | /* Initialize response queue entries */ |
|---|
| 3989 | 4289 | if (IS_QLAFX00(ha)) |
|---|
| .. | .. |
|---|
| 4022 | 4322 | mid_init_cb->init_cb.execution_throttle = |
|---|
| 4023 | 4323 | cpu_to_le16(ha->cur_fw_xcb_count); |
|---|
| 4024 | 4324 | ha->flags.dport_enabled = |
|---|
| 4025 | | - (mid_init_cb->init_cb.firmware_options_1 & BIT_7) != 0; |
|---|
| 4325 | + (le32_to_cpu(mid_init_cb->init_cb.firmware_options_1) & |
|---|
| 4326 | + BIT_7) != 0; |
|---|
| 4026 | 4327 | ql_dbg(ql_dbg_init, vha, 0x0191, "DPORT Support: %s.\n", |
|---|
| 4027 | 4328 | (ha->flags.dport_enabled) ? "enabled" : "disabled"); |
|---|
| 4028 | 4329 | /* FA-WWPN Status */ |
|---|
| 4029 | 4330 | ha->flags.fawwpn_enabled = |
|---|
| 4030 | | - (mid_init_cb->init_cb.firmware_options_1 & BIT_6) != 0; |
|---|
| 4331 | + (le32_to_cpu(mid_init_cb->init_cb.firmware_options_1) & |
|---|
| 4332 | + BIT_6) != 0; |
|---|
| 4031 | 4333 | ql_dbg(ql_dbg_init, vha, 0x00bc, "FA-WWPN Support: %s.\n", |
|---|
| 4032 | 4334 | (ha->flags.fawwpn_enabled) ? "enabled" : "disabled"); |
|---|
| 4335 | + /* Init_cb will be reused for other command(s). Save a backup copy of port_name */ |
|---|
| 4336 | + memcpy(ha->port_name, ha->init_cb->port_name, WWN_SIZE); |
|---|
| 4033 | 4337 | } |
|---|
| 4034 | 4338 | |
|---|
| 4035 | 4339 | rval = qla2x00_init_firmware(vha, ha->init_cb_size); |
|---|
| .. | .. |
|---|
| 4041 | 4345 | ql_dbg(ql_dbg_init, vha, 0x00d3, |
|---|
| 4042 | 4346 | "Init Firmware -- success.\n"); |
|---|
| 4043 | 4347 | QLA_FW_STARTED(ha); |
|---|
| 4348 | + vha->u_ql2xexchoffld = vha->u_ql2xiniexchg = 0; |
|---|
| 4044 | 4349 | } |
|---|
| 4045 | 4350 | |
|---|
| 4046 | 4351 | return (rval); |
|---|
| .. | .. |
|---|
| 4302 | 4607 | |
|---|
| 4303 | 4608 | inline void |
|---|
| 4304 | 4609 | qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len, |
|---|
| 4305 | | - char *def) |
|---|
| 4610 | + const char *def) |
|---|
| 4306 | 4611 | { |
|---|
| 4307 | 4612 | char *st, *en; |
|---|
| 4308 | 4613 | uint16_t index; |
|---|
| 4614 | + uint64_t zero[2] = { 0 }; |
|---|
| 4309 | 4615 | struct qla_hw_data *ha = vha->hw; |
|---|
| 4310 | 4616 | int use_tbl = !IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha) && |
|---|
| 4311 | 4617 | !IS_CNA_CAPABLE(ha) && !IS_QLA2031(ha); |
|---|
| 4312 | 4618 | |
|---|
| 4313 | | - if (memcmp(model, BINZERO, len) != 0) { |
|---|
| 4314 | | - strncpy(ha->model_number, model, len); |
|---|
| 4619 | + if (len > sizeof(zero)) |
|---|
| 4620 | + len = sizeof(zero); |
|---|
| 4621 | + if (memcmp(model, &zero, len) != 0) { |
|---|
| 4622 | + memcpy(ha->model_number, model, len); |
|---|
| 4315 | 4623 | st = en = ha->model_number; |
|---|
| 4316 | 4624 | en += len - 1; |
|---|
| 4317 | 4625 | while (en > st) { |
|---|
| .. | .. |
|---|
| 4324 | 4632 | if (use_tbl && |
|---|
| 4325 | 4633 | ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && |
|---|
| 4326 | 4634 | index < QLA_MODEL_NAMES) |
|---|
| 4327 | | - strncpy(ha->model_desc, |
|---|
| 4635 | + strlcpy(ha->model_desc, |
|---|
| 4328 | 4636 | qla2x00_model_name[index * 2 + 1], |
|---|
| 4329 | | - sizeof(ha->model_desc) - 1); |
|---|
| 4637 | + sizeof(ha->model_desc)); |
|---|
| 4330 | 4638 | } else { |
|---|
| 4331 | 4639 | index = (ha->pdev->subsystem_device & 0xff); |
|---|
| 4332 | 4640 | if (use_tbl && |
|---|
| 4333 | 4641 | ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && |
|---|
| 4334 | 4642 | index < QLA_MODEL_NAMES) { |
|---|
| 4335 | | - strcpy(ha->model_number, |
|---|
| 4336 | | - qla2x00_model_name[index * 2]); |
|---|
| 4337 | | - strncpy(ha->model_desc, |
|---|
| 4643 | + strlcpy(ha->model_number, |
|---|
| 4644 | + qla2x00_model_name[index * 2], |
|---|
| 4645 | + sizeof(ha->model_number)); |
|---|
| 4646 | + strlcpy(ha->model_desc, |
|---|
| 4338 | 4647 | qla2x00_model_name[index * 2 + 1], |
|---|
| 4339 | | - sizeof(ha->model_desc) - 1); |
|---|
| 4648 | + sizeof(ha->model_desc)); |
|---|
| 4340 | 4649 | } else { |
|---|
| 4341 | | - strcpy(ha->model_number, def); |
|---|
| 4650 | + strlcpy(ha->model_number, def, |
|---|
| 4651 | + sizeof(ha->model_number)); |
|---|
| 4342 | 4652 | } |
|---|
| 4343 | 4653 | } |
|---|
| 4344 | 4654 | if (IS_FWI2_CAPABLE(ha)) |
|---|
| .. | .. |
|---|
| 4397 | 4707 | rval = QLA_SUCCESS; |
|---|
| 4398 | 4708 | |
|---|
| 4399 | 4709 | /* Determine NVRAM starting address. */ |
|---|
| 4400 | | - ha->nvram_size = sizeof(nvram_t); |
|---|
| 4710 | + ha->nvram_size = sizeof(*nv); |
|---|
| 4401 | 4711 | ha->nvram_base = 0; |
|---|
| 4402 | 4712 | if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && !IS_QLA2300(ha)) |
|---|
| 4403 | | - if ((RD_REG_WORD(®->ctrl_status) >> 14) == 1) |
|---|
| 4713 | + if ((rd_reg_word(®->ctrl_status) >> 14) == 1) |
|---|
| 4404 | 4714 | ha->nvram_base = 0x80; |
|---|
| 4405 | 4715 | |
|---|
| 4406 | 4716 | /* Get NVRAM data and calculate checksum. */ |
|---|
| .. | .. |
|---|
| 4411 | 4721 | ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x010f, |
|---|
| 4412 | 4722 | "Contents of NVRAM.\n"); |
|---|
| 4413 | 4723 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0110, |
|---|
| 4414 | | - (uint8_t *)nv, ha->nvram_size); |
|---|
| 4724 | + nv, ha->nvram_size); |
|---|
| 4415 | 4725 | |
|---|
| 4416 | 4726 | /* Bad NVRAM data, set defaults parameters. */ |
|---|
| 4417 | | - if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || |
|---|
| 4418 | | - nv->id[2] != 'P' || nv->id[3] != ' ' || nv->nvram_version < 1) { |
|---|
| 4727 | + if (chksum || memcmp("ISP ", nv->id, sizeof(nv->id)) || |
|---|
| 4728 | + nv->nvram_version < 1) { |
|---|
| 4419 | 4729 | /* Reset NVRAM data. */ |
|---|
| 4420 | 4730 | ql_log(ql_log_warn, vha, 0x0064, |
|---|
| 4421 | | - "Inconsistent NVRAM " |
|---|
| 4422 | | - "detected: checksum=0x%x id=%c version=0x%x.\n", |
|---|
| 4423 | | - chksum, nv->id[0], nv->nvram_version); |
|---|
| 4731 | + "Inconsistent NVRAM detected: checksum=%#x id=%.4s version=%#x.\n", |
|---|
| 4732 | + chksum, nv->id, nv->nvram_version); |
|---|
| 4424 | 4733 | ql_log(ql_log_warn, vha, 0x0065, |
|---|
| 4425 | 4734 | "Falling back to " |
|---|
| 4426 | 4735 | "functioning (yet invalid -- WWPN) defaults.\n"); |
|---|
| .. | .. |
|---|
| 4436 | 4745 | nv->firmware_options[1] = BIT_7 | BIT_5; |
|---|
| 4437 | 4746 | nv->add_firmware_options[0] = BIT_5; |
|---|
| 4438 | 4747 | nv->add_firmware_options[1] = BIT_5 | BIT_4; |
|---|
| 4439 | | - nv->frame_payload_size = 2048; |
|---|
| 4748 | + nv->frame_payload_size = cpu_to_le16(2048); |
|---|
| 4440 | 4749 | nv->special_options[1] = BIT_7; |
|---|
| 4441 | 4750 | } else if (IS_QLA2200(ha)) { |
|---|
| 4442 | 4751 | nv->firmware_options[0] = BIT_2 | BIT_1; |
|---|
| 4443 | 4752 | nv->firmware_options[1] = BIT_7 | BIT_5; |
|---|
| 4444 | 4753 | nv->add_firmware_options[0] = BIT_5; |
|---|
| 4445 | 4754 | nv->add_firmware_options[1] = BIT_5 | BIT_4; |
|---|
| 4446 | | - nv->frame_payload_size = 1024; |
|---|
| 4755 | + nv->frame_payload_size = cpu_to_le16(1024); |
|---|
| 4447 | 4756 | } else if (IS_QLA2100(ha)) { |
|---|
| 4448 | 4757 | nv->firmware_options[0] = BIT_3 | BIT_1; |
|---|
| 4449 | 4758 | nv->firmware_options[1] = BIT_5; |
|---|
| 4450 | | - nv->frame_payload_size = 1024; |
|---|
| 4759 | + nv->frame_payload_size = cpu_to_le16(1024); |
|---|
| 4451 | 4760 | } |
|---|
| 4452 | 4761 | |
|---|
| 4453 | 4762 | nv->max_iocb_allocation = cpu_to_le16(256); |
|---|
| .. | .. |
|---|
| 4474 | 4783 | |
|---|
| 4475 | 4784 | rval = 1; |
|---|
| 4476 | 4785 | } |
|---|
| 4477 | | - |
|---|
| 4478 | | -#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) |
|---|
| 4479 | | - /* |
|---|
| 4480 | | - * The SN2 does not provide BIOS emulation which means you can't change |
|---|
| 4481 | | - * potentially bogus BIOS settings. Force the use of default settings |
|---|
| 4482 | | - * for link rate and frame size. Hope that the rest of the settings |
|---|
| 4483 | | - * are valid. |
|---|
| 4484 | | - */ |
|---|
| 4485 | | - if (ia64_platform_is("sn2")) { |
|---|
| 4486 | | - nv->frame_payload_size = 2048; |
|---|
| 4487 | | - if (IS_QLA23XX(ha)) |
|---|
| 4488 | | - nv->special_options[1] = BIT_7; |
|---|
| 4489 | | - } |
|---|
| 4490 | | -#endif |
|---|
| 4491 | 4786 | |
|---|
| 4492 | 4787 | /* Reset Initialization control block */ |
|---|
| 4493 | 4788 | memset(icb, 0, ha->init_cb_size); |
|---|
| .. | .. |
|---|
| 4669 | 4964 | ha->zio_mode = icb->add_firmware_options[0] & |
|---|
| 4670 | 4965 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
|---|
| 4671 | 4966 | ha->zio_timer = icb->interrupt_delay_timer ? |
|---|
| 4672 | | - icb->interrupt_delay_timer: 2; |
|---|
| 4967 | + icb->interrupt_delay_timer : 2; |
|---|
| 4673 | 4968 | } |
|---|
| 4674 | 4969 | icb->add_firmware_options[0] &= |
|---|
| 4675 | 4970 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0); |
|---|
| .. | .. |
|---|
| 4702 | 4997 | unsigned long flags; |
|---|
| 4703 | 4998 | |
|---|
| 4704 | 4999 | spin_lock_irqsave(fcport->vha->host->host_lock, flags); |
|---|
| 4705 | | - rport = fcport->drport ? fcport->drport: fcport->rport; |
|---|
| 5000 | + rport = fcport->drport ? fcport->drport : fcport->rport; |
|---|
| 4706 | 5001 | fcport->drport = NULL; |
|---|
| 4707 | 5002 | spin_unlock_irqrestore(fcport->vha->host->host_lock, flags); |
|---|
| 4708 | 5003 | if (rport) { |
|---|
| .. | .. |
|---|
| 4712 | 5007 | rport->roles); |
|---|
| 4713 | 5008 | |
|---|
| 4714 | 5009 | fc_remote_port_delete(rport); |
|---|
| 5010 | + } |
|---|
| 5011 | +} |
|---|
| 5012 | + |
|---|
| 5013 | +void qla2x00_set_fcport_state(fc_port_t *fcport, int state) |
|---|
| 5014 | +{ |
|---|
| 5015 | + int old_state; |
|---|
| 5016 | + |
|---|
| 5017 | + old_state = atomic_read(&fcport->state); |
|---|
| 5018 | + atomic_set(&fcport->state, state); |
|---|
| 5019 | + |
|---|
| 5020 | + /* Don't print state transitions during initial allocation of fcport */ |
|---|
| 5021 | + if (old_state && old_state != state) { |
|---|
| 5022 | + ql_dbg(ql_dbg_disc, fcport->vha, 0x207d, |
|---|
| 5023 | + "FCPort %8phC state transitioned from %s to %s - portid=%02x%02x%02x.\n", |
|---|
| 5024 | + fcport->port_name, port_state_str[old_state], |
|---|
| 5025 | + port_state_str[state], fcport->d_id.b.domain, |
|---|
| 5026 | + fcport->d_id.b.area, fcport->d_id.b.al_pa); |
|---|
| 4715 | 5027 | } |
|---|
| 4716 | 5028 | } |
|---|
| 4717 | 5029 | |
|---|
| .. | .. |
|---|
| 4731 | 5043 | if (!fcport) |
|---|
| 4732 | 5044 | return NULL; |
|---|
| 4733 | 5045 | |
|---|
| 5046 | + fcport->ct_desc.ct_sns = dma_alloc_coherent(&vha->hw->pdev->dev, |
|---|
| 5047 | + sizeof(struct ct_sns_pkt), &fcport->ct_desc.ct_sns_dma, |
|---|
| 5048 | + flags); |
|---|
| 5049 | + if (!fcport->ct_desc.ct_sns) { |
|---|
| 5050 | + ql_log(ql_log_warn, vha, 0xd049, |
|---|
| 5051 | + "Failed to allocate ct_sns request.\n"); |
|---|
| 5052 | + kfree(fcport); |
|---|
| 5053 | + return NULL; |
|---|
| 5054 | + } |
|---|
| 5055 | + |
|---|
| 4734 | 5056 | /* Setup fcport template structure. */ |
|---|
| 4735 | 5057 | fcport->vha = vha; |
|---|
| 4736 | 5058 | fcport->port_type = FCT_UNKNOWN; |
|---|
| .. | .. |
|---|
| 4739 | 5061 | fcport->supported_classes = FC_COS_UNSPECIFIED; |
|---|
| 4740 | 5062 | fcport->fp_speed = PORT_SPEED_UNKNOWN; |
|---|
| 4741 | 5063 | |
|---|
| 4742 | | - fcport->ct_desc.ct_sns = dma_alloc_coherent(&vha->hw->pdev->dev, |
|---|
| 4743 | | - sizeof(struct ct_sns_pkt), &fcport->ct_desc.ct_sns_dma, |
|---|
| 4744 | | - flags); |
|---|
| 4745 | 5064 | fcport->disc_state = DSC_DELETED; |
|---|
| 4746 | 5065 | fcport->fw_login_state = DSC_LS_PORT_UNAVAIL; |
|---|
| 4747 | 5066 | fcport->deleted = QLA_SESS_DELETED; |
|---|
| 4748 | 5067 | fcport->login_retry = vha->hw->login_retry_count; |
|---|
| 5068 | + fcport->chip_reset = vha->hw->base_qpair->chip_reset; |
|---|
| 4749 | 5069 | fcport->logout_on_delete = 1; |
|---|
| 4750 | 5070 | |
|---|
| 4751 | 5071 | if (!fcport->ct_desc.ct_sns) { |
|---|
| .. | .. |
|---|
| 4754 | 5074 | kfree(fcport); |
|---|
| 4755 | 5075 | return NULL; |
|---|
| 4756 | 5076 | } |
|---|
| 5077 | + |
|---|
| 4757 | 5078 | INIT_WORK(&fcport->del_work, qla24xx_delete_sess_fn); |
|---|
| 5079 | + INIT_WORK(&fcport->free_work, qlt_free_session_done); |
|---|
| 4758 | 5080 | INIT_WORK(&fcport->reg_work, qla_register_fcport_fn); |
|---|
| 4759 | 5081 | INIT_LIST_HEAD(&fcport->gnl_entry); |
|---|
| 4760 | 5082 | INIT_LIST_HEAD(&fcport->list); |
|---|
| .. | .. |
|---|
| 4772 | 5094 | |
|---|
| 4773 | 5095 | fcport->ct_desc.ct_sns = NULL; |
|---|
| 4774 | 5096 | } |
|---|
| 5097 | + list_del(&fcport->list); |
|---|
| 5098 | + qla2x00_clear_loop_id(fcport); |
|---|
| 4775 | 5099 | kfree(fcport); |
|---|
| 5100 | +} |
|---|
| 5101 | + |
|---|
| 5102 | +static void qla_get_login_template(scsi_qla_host_t *vha) |
|---|
| 5103 | +{ |
|---|
| 5104 | + struct qla_hw_data *ha = vha->hw; |
|---|
| 5105 | + int rval; |
|---|
| 5106 | + u32 *bp, sz; |
|---|
| 5107 | + __be32 *q; |
|---|
| 5108 | + |
|---|
| 5109 | + memset(ha->init_cb, 0, ha->init_cb_size); |
|---|
| 5110 | + sz = min_t(int, sizeof(struct fc_els_flogi), ha->init_cb_size); |
|---|
| 5111 | + rval = qla24xx_get_port_login_templ(vha, ha->init_cb_dma, |
|---|
| 5112 | + ha->init_cb, sz); |
|---|
| 5113 | + if (rval != QLA_SUCCESS) { |
|---|
| 5114 | + ql_dbg(ql_dbg_init, vha, 0x00d1, |
|---|
| 5115 | + "PLOGI ELS param read fail.\n"); |
|---|
| 5116 | + return; |
|---|
| 5117 | + } |
|---|
| 5118 | + q = (__be32 *)&ha->plogi_els_payld.fl_csp; |
|---|
| 5119 | + |
|---|
| 5120 | + bp = (uint32_t *)ha->init_cb; |
|---|
| 5121 | + cpu_to_be32_array(q, bp, sz / 4); |
|---|
| 5122 | + ha->flags.plogi_template_valid = 1; |
|---|
| 4776 | 5123 | } |
|---|
| 4777 | 5124 | |
|---|
| 4778 | 5125 | /* |
|---|
| .. | .. |
|---|
| 4793 | 5140 | int rval; |
|---|
| 4794 | 5141 | unsigned long flags, save_flags; |
|---|
| 4795 | 5142 | struct qla_hw_data *ha = vha->hw; |
|---|
| 5143 | + |
|---|
| 4796 | 5144 | rval = QLA_SUCCESS; |
|---|
| 4797 | 5145 | |
|---|
| 4798 | 5146 | /* Get Initiator ID */ |
|---|
| .. | .. |
|---|
| 4817 | 5165 | clear_bit(RSCN_UPDATE, &vha->dpc_flags); |
|---|
| 4818 | 5166 | |
|---|
| 4819 | 5167 | qla2x00_get_data_rate(vha); |
|---|
| 5168 | + qla_get_login_template(vha); |
|---|
| 4820 | 5169 | |
|---|
| 4821 | 5170 | /* Determine what we need to do */ |
|---|
| 4822 | | - if (ha->current_topology == ISP_CFG_FL && |
|---|
| 4823 | | - (test_bit(LOCAL_LOOP_UPDATE, &flags))) { |
|---|
| 4824 | | - |
|---|
| 4825 | | - set_bit(RSCN_UPDATE, &flags); |
|---|
| 4826 | | - |
|---|
| 4827 | | - } else if (ha->current_topology == ISP_CFG_F && |
|---|
| 5171 | + if ((ha->current_topology == ISP_CFG_FL || |
|---|
| 5172 | + ha->current_topology == ISP_CFG_F) && |
|---|
| 4828 | 5173 | (test_bit(LOCAL_LOOP_UPDATE, &flags))) { |
|---|
| 4829 | 5174 | |
|---|
| 4830 | 5175 | set_bit(RSCN_UPDATE, &flags); |
|---|
| .. | .. |
|---|
| 4903 | 5248 | return (rval); |
|---|
| 4904 | 5249 | } |
|---|
| 4905 | 5250 | |
|---|
| 5251 | +static int qla2x00_configure_n2n_loop(scsi_qla_host_t *vha) |
|---|
| 5252 | +{ |
|---|
| 5253 | + unsigned long flags; |
|---|
| 5254 | + fc_port_t *fcport; |
|---|
| 5255 | + |
|---|
| 5256 | + if (test_and_clear_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags)) |
|---|
| 5257 | + set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
|---|
| 5258 | + |
|---|
| 5259 | + list_for_each_entry(fcport, &vha->vp_fcports, list) { |
|---|
| 5260 | + if (fcport->n2n_flag) { |
|---|
| 5261 | + qla24xx_fcport_handle_login(vha, fcport); |
|---|
| 5262 | + return QLA_SUCCESS; |
|---|
| 5263 | + } |
|---|
| 5264 | + } |
|---|
| 5265 | + |
|---|
| 5266 | + spin_lock_irqsave(&vha->work_lock, flags); |
|---|
| 5267 | + vha->scan.scan_retry++; |
|---|
| 5268 | + spin_unlock_irqrestore(&vha->work_lock, flags); |
|---|
| 5269 | + |
|---|
| 5270 | + if (vha->scan.scan_retry < MAX_SCAN_RETRIES) { |
|---|
| 5271 | + set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
|---|
| 5272 | + set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
|---|
| 5273 | + } |
|---|
| 5274 | + return QLA_FUNCTION_FAILED; |
|---|
| 5275 | +} |
|---|
| 5276 | + |
|---|
| 5277 | +static void |
|---|
| 5278 | +qla_reinitialize_link(scsi_qla_host_t *vha) |
|---|
| 5279 | +{ |
|---|
| 5280 | + int rval; |
|---|
| 5281 | + |
|---|
| 5282 | + atomic_set(&vha->loop_state, LOOP_DOWN); |
|---|
| 5283 | + atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
|---|
| 5284 | + rval = qla2x00_full_login_lip(vha); |
|---|
| 5285 | + if (rval == QLA_SUCCESS) { |
|---|
| 5286 | + ql_dbg(ql_dbg_disc, vha, 0xd050, "Link reinitialized\n"); |
|---|
| 5287 | + } else { |
|---|
| 5288 | + ql_dbg(ql_dbg_disc, vha, 0xd051, |
|---|
| 5289 | + "Link reinitialization failed (%d)\n", rval); |
|---|
| 5290 | + } |
|---|
| 5291 | +} |
|---|
| 5292 | + |
|---|
| 4906 | 5293 | /* |
|---|
| 4907 | 5294 | * qla2x00_configure_local_loop |
|---|
| 4908 | 5295 | * Updates Fibre Channel Device Database with local loop devices. |
|---|
| .. | .. |
|---|
| 4920 | 5307 | int found_devs; |
|---|
| 4921 | 5308 | int found; |
|---|
| 4922 | 5309 | fc_port_t *fcport, *new_fcport; |
|---|
| 4923 | | - |
|---|
| 4924 | 5310 | uint16_t index; |
|---|
| 4925 | 5311 | uint16_t entries; |
|---|
| 4926 | | - char *id_iter; |
|---|
| 5312 | + struct gid_list_info *gid; |
|---|
| 4927 | 5313 | uint16_t loop_id; |
|---|
| 4928 | 5314 | uint8_t domain, area, al_pa; |
|---|
| 4929 | 5315 | struct qla_hw_data *ha = vha->hw; |
|---|
| 4930 | 5316 | unsigned long flags; |
|---|
| 4931 | 5317 | |
|---|
| 4932 | 5318 | /* Inititae N2N login. */ |
|---|
| 4933 | | - if (test_and_clear_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags)) { |
|---|
| 4934 | | - /* borrowing */ |
|---|
| 4935 | | - u32 *bp, i, sz; |
|---|
| 4936 | | - |
|---|
| 4937 | | - memset(ha->init_cb, 0, ha->init_cb_size); |
|---|
| 4938 | | - sz = min_t(int, sizeof(struct els_plogi_payload), |
|---|
| 4939 | | - ha->init_cb_size); |
|---|
| 4940 | | - rval = qla24xx_get_port_login_templ(vha, ha->init_cb_dma, |
|---|
| 4941 | | - (void *)ha->init_cb, sz); |
|---|
| 4942 | | - if (rval == QLA_SUCCESS) { |
|---|
| 4943 | | - bp = (uint32_t *)ha->init_cb; |
|---|
| 4944 | | - for (i = 0; i < sz/4 ; i++, bp++) |
|---|
| 4945 | | - *bp = cpu_to_be32(*bp); |
|---|
| 4946 | | - |
|---|
| 4947 | | - memcpy(&ha->plogi_els_payld.data, (void *)ha->init_cb, |
|---|
| 4948 | | - sizeof(ha->plogi_els_payld.data)); |
|---|
| 4949 | | - set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
|---|
| 4950 | | - } else { |
|---|
| 4951 | | - ql_dbg(ql_dbg_init, vha, 0x00d1, |
|---|
| 4952 | | - "PLOGI ELS param read fail.\n"); |
|---|
| 4953 | | - } |
|---|
| 4954 | | - return QLA_SUCCESS; |
|---|
| 4955 | | - } |
|---|
| 5319 | + if (N2N_TOPO(ha)) |
|---|
| 5320 | + return qla2x00_configure_n2n_loop(vha); |
|---|
| 4956 | 5321 | |
|---|
| 4957 | 5322 | found_devs = 0; |
|---|
| 4958 | 5323 | new_fcport = NULL; |
|---|
| .. | .. |
|---|
| 4963 | 5328 | rval = qla2x00_get_id_list(vha, ha->gid_list, ha->gid_list_dma, |
|---|
| 4964 | 5329 | &entries); |
|---|
| 4965 | 5330 | if (rval != QLA_SUCCESS) |
|---|
| 4966 | | - goto cleanup_allocation; |
|---|
| 5331 | + goto err; |
|---|
| 4967 | 5332 | |
|---|
| 4968 | 5333 | ql_dbg(ql_dbg_disc, vha, 0x2011, |
|---|
| 4969 | 5334 | "Entries in ID list (%d).\n", entries); |
|---|
| 4970 | 5335 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2075, |
|---|
| 4971 | | - (uint8_t *)ha->gid_list, |
|---|
| 4972 | | - entries * sizeof(struct gid_list_info)); |
|---|
| 5336 | + ha->gid_list, entries * sizeof(*ha->gid_list)); |
|---|
| 5337 | + |
|---|
| 5338 | + if (entries == 0) { |
|---|
| 5339 | + spin_lock_irqsave(&vha->work_lock, flags); |
|---|
| 5340 | + vha->scan.scan_retry++; |
|---|
| 5341 | + spin_unlock_irqrestore(&vha->work_lock, flags); |
|---|
| 5342 | + |
|---|
| 5343 | + if (vha->scan.scan_retry < MAX_SCAN_RETRIES) { |
|---|
| 5344 | + u8 loop_map_entries = 0; |
|---|
| 5345 | + int rc; |
|---|
| 5346 | + |
|---|
| 5347 | + rc = qla2x00_get_fcal_position_map(vha, NULL, |
|---|
| 5348 | + &loop_map_entries); |
|---|
| 5349 | + if (rc == QLA_SUCCESS && loop_map_entries > 1) { |
|---|
| 5350 | + /* |
|---|
| 5351 | + * There are devices that are still not logged |
|---|
| 5352 | + * in. Reinitialize to give them a chance. |
|---|
| 5353 | + */ |
|---|
| 5354 | + qla_reinitialize_link(vha); |
|---|
| 5355 | + return QLA_FUNCTION_FAILED; |
|---|
| 5356 | + } |
|---|
| 5357 | + set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
|---|
| 5358 | + set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
|---|
| 5359 | + } |
|---|
| 5360 | + } else { |
|---|
| 5361 | + vha->scan.scan_retry = 0; |
|---|
| 5362 | + } |
|---|
| 4973 | 5363 | |
|---|
| 4974 | 5364 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
|---|
| 4975 | 5365 | fcport->scan_state = QLA_FCPORT_SCAN; |
|---|
| .. | .. |
|---|
| 4981 | 5371 | ql_log(ql_log_warn, vha, 0x2012, |
|---|
| 4982 | 5372 | "Memory allocation failed for fcport.\n"); |
|---|
| 4983 | 5373 | rval = QLA_MEMORY_ALLOC_FAILED; |
|---|
| 4984 | | - goto cleanup_allocation; |
|---|
| 5374 | + goto err; |
|---|
| 4985 | 5375 | } |
|---|
| 4986 | 5376 | new_fcport->flags &= ~FCF_FABRIC_DEVICE; |
|---|
| 4987 | 5377 | |
|---|
| 4988 | 5378 | /* Add devices to port list. */ |
|---|
| 4989 | | - id_iter = (char *)ha->gid_list; |
|---|
| 5379 | + gid = ha->gid_list; |
|---|
| 4990 | 5380 | for (index = 0; index < entries; index++) { |
|---|
| 4991 | | - domain = ((struct gid_list_info *)id_iter)->domain; |
|---|
| 4992 | | - area = ((struct gid_list_info *)id_iter)->area; |
|---|
| 4993 | | - al_pa = ((struct gid_list_info *)id_iter)->al_pa; |
|---|
| 5381 | + domain = gid->domain; |
|---|
| 5382 | + area = gid->area; |
|---|
| 5383 | + al_pa = gid->al_pa; |
|---|
| 4994 | 5384 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
|---|
| 4995 | | - loop_id = (uint16_t) |
|---|
| 4996 | | - ((struct gid_list_info *)id_iter)->loop_id_2100; |
|---|
| 5385 | + loop_id = gid->loop_id_2100; |
|---|
| 4997 | 5386 | else |
|---|
| 4998 | | - loop_id = le16_to_cpu( |
|---|
| 4999 | | - ((struct gid_list_info *)id_iter)->loop_id); |
|---|
| 5000 | | - id_iter += ha->gid_list_info_size; |
|---|
| 5387 | + loop_id = le16_to_cpu(gid->loop_id); |
|---|
| 5388 | + gid = (void *)gid + ha->gid_list_info_size; |
|---|
| 5001 | 5389 | |
|---|
| 5002 | 5390 | /* Bypass reserved domain fields. */ |
|---|
| 5003 | 5391 | if ((domain & 0xf0) == 0xf0) |
|---|
| 5004 | 5392 | continue; |
|---|
| 5005 | 5393 | |
|---|
| 5006 | 5394 | /* Bypass if not same domain and area of adapter. */ |
|---|
| 5007 | | - if (area && domain && |
|---|
| 5008 | | - (area != vha->d_id.b.area || domain != vha->d_id.b.domain)) |
|---|
| 5395 | + if (area && domain && ((area != vha->d_id.b.area) || |
|---|
| 5396 | + (domain != vha->d_id.b.domain)) && |
|---|
| 5397 | + (ha->current_topology == ISP_CFG_NL)) |
|---|
| 5009 | 5398 | continue; |
|---|
| 5399 | + |
|---|
| 5010 | 5400 | |
|---|
| 5011 | 5401 | /* Bypass invalid local loop ID. */ |
|---|
| 5012 | 5402 | if (loop_id > LAST_LOCAL_LOOP_ID) |
|---|
| .. | .. |
|---|
| 5052 | 5442 | memcpy(fcport->node_name, new_fcport->node_name, |
|---|
| 5053 | 5443 | WWN_SIZE); |
|---|
| 5054 | 5444 | fcport->scan_state = QLA_FCPORT_FOUND; |
|---|
| 5445 | + if (fcport->login_retry == 0) { |
|---|
| 5446 | + fcport->login_retry = vha->hw->login_retry_count; |
|---|
| 5447 | + ql_dbg(ql_dbg_disc, vha, 0x2135, |
|---|
| 5448 | + "Port login retry %8phN, lid 0x%04x retry cnt=%d.\n", |
|---|
| 5449 | + fcport->port_name, fcport->loop_id, |
|---|
| 5450 | + fcport->login_retry); |
|---|
| 5451 | + } |
|---|
| 5055 | 5452 | found++; |
|---|
| 5056 | 5453 | break; |
|---|
| 5057 | 5454 | } |
|---|
| .. | .. |
|---|
| 5071 | 5468 | ql_log(ql_log_warn, vha, 0xd031, |
|---|
| 5072 | 5469 | "Failed to allocate memory for fcport.\n"); |
|---|
| 5073 | 5470 | rval = QLA_MEMORY_ALLOC_FAILED; |
|---|
| 5074 | | - goto cleanup_allocation; |
|---|
| 5471 | + goto err; |
|---|
| 5075 | 5472 | } |
|---|
| 5076 | 5473 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
|---|
| 5077 | 5474 | new_fcport->flags &= ~FCF_FABRIC_DEVICE; |
|---|
| .. | .. |
|---|
| 5094 | 5491 | qla_ini_mode_enabled(vha)) && |
|---|
| 5095 | 5492 | atomic_read(&fcport->state) == FCS_ONLINE) { |
|---|
| 5096 | 5493 | qla2x00_mark_device_lost(vha, fcport, |
|---|
| 5097 | | - ql2xplogiabsentdevice, 0); |
|---|
| 5494 | + ql2xplogiabsentdevice); |
|---|
| 5098 | 5495 | if (fcport->loop_id != FC_NO_LOOP_ID && |
|---|
| 5099 | 5496 | (fcport->flags & FCF_FCP2_DEVICE) == 0 && |
|---|
| 5100 | 5497 | fcport->port_type != FCT_INITIATOR && |
|---|
| .. | .. |
|---|
| 5114 | 5511 | qla24xx_fcport_handle_login(vha, fcport); |
|---|
| 5115 | 5512 | } |
|---|
| 5116 | 5513 | |
|---|
| 5117 | | -cleanup_allocation: |
|---|
| 5118 | | - kfree(new_fcport); |
|---|
| 5514 | + qla2x00_free_fcport(new_fcport); |
|---|
| 5119 | 5515 | |
|---|
| 5120 | | - if (rval != QLA_SUCCESS) { |
|---|
| 5121 | | - ql_dbg(ql_dbg_disc, vha, 0x2098, |
|---|
| 5122 | | - "Configure local loop error exit: rval=%x.\n", rval); |
|---|
| 5123 | | - } |
|---|
| 5516 | + return rval; |
|---|
| 5124 | 5517 | |
|---|
| 5125 | | - return (rval); |
|---|
| 5518 | +err: |
|---|
| 5519 | + ql_dbg(ql_dbg_disc, vha, 0x2098, |
|---|
| 5520 | + "Configure local loop error exit: rval=%x.\n", rval); |
|---|
| 5521 | + return rval; |
|---|
| 5126 | 5522 | } |
|---|
| 5127 | 5523 | |
|---|
| 5128 | 5524 | static void |
|---|
| .. | .. |
|---|
| 5204 | 5600 | |
|---|
| 5205 | 5601 | rport->supported_classes = fcport->supported_classes; |
|---|
| 5206 | 5602 | |
|---|
| 5207 | | - rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; |
|---|
| 5603 | + rport_ids.roles = FC_PORT_ROLE_UNKNOWN; |
|---|
| 5208 | 5604 | if (fcport->port_type == FCT_INITIATOR) |
|---|
| 5209 | | - rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR; |
|---|
| 5605 | + rport_ids.roles |= FC_PORT_ROLE_FCP_INITIATOR; |
|---|
| 5210 | 5606 | if (fcport->port_type == FCT_TARGET) |
|---|
| 5211 | | - rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET; |
|---|
| 5607 | + rport_ids.roles |= FC_PORT_ROLE_FCP_TARGET; |
|---|
| 5608 | + if (fcport->port_type & FCT_NVME_INITIATOR) |
|---|
| 5609 | + rport_ids.roles |= FC_PORT_ROLE_NVME_INITIATOR; |
|---|
| 5610 | + if (fcport->port_type & FCT_NVME_TARGET) |
|---|
| 5611 | + rport_ids.roles |= FC_PORT_ROLE_NVME_TARGET; |
|---|
| 5612 | + if (fcport->port_type & FCT_NVME_DISCOVERY) |
|---|
| 5613 | + rport_ids.roles |= FC_PORT_ROLE_NVME_DISCOVERY; |
|---|
| 5212 | 5614 | |
|---|
| 5213 | 5615 | ql_dbg(ql_dbg_disc, vha, 0x20ee, |
|---|
| 5214 | 5616 | "%s %8phN. rport %p is %s mode\n", |
|---|
| 5215 | 5617 | __func__, fcport->port_name, rport, |
|---|
| 5216 | | - (fcport->port_type == FCT_TARGET) ? "tgt" : "ini"); |
|---|
| 5618 | + (fcport->port_type == FCT_TARGET) ? "tgt" : |
|---|
| 5619 | + ((fcport->port_type & FCT_NVME) ? "nvme" : "ini")); |
|---|
| 5217 | 5620 | |
|---|
| 5218 | 5621 | fc_remote_port_rolechg(rport, rport_ids.roles); |
|---|
| 5219 | 5622 | } |
|---|
| .. | .. |
|---|
| 5242 | 5645 | ql_dbg(ql_dbg_disc, vha, 0x20ef, "%s %8phC\n", |
|---|
| 5243 | 5646 | __func__, fcport->port_name); |
|---|
| 5244 | 5647 | |
|---|
| 5245 | | - fcport->disc_state = DSC_UPD_FCPORT; |
|---|
| 5648 | + qla2x00_set_fcport_disc_state(fcport, DSC_UPD_FCPORT); |
|---|
| 5246 | 5649 | fcport->login_retry = vha->hw->login_retry_count; |
|---|
| 5247 | 5650 | fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); |
|---|
| 5248 | 5651 | fcport->deleted = 0; |
|---|
| 5249 | | - fcport->logout_on_delete = 1; |
|---|
| 5250 | | - fcport->login_retry = vha->hw->login_retry_count; |
|---|
| 5652 | + if (vha->hw->current_topology == ISP_CFG_NL) |
|---|
| 5653 | + fcport->logout_on_delete = 0; |
|---|
| 5654 | + else |
|---|
| 5655 | + fcport->logout_on_delete = 1; |
|---|
| 5251 | 5656 | fcport->n2n_chip_reset = fcport->n2n_link_reset_cnt = 0; |
|---|
| 5252 | | - |
|---|
| 5253 | | - qla2x00_iidma_fcport(vha, fcport); |
|---|
| 5254 | 5657 | |
|---|
| 5255 | 5658 | switch (vha->hw->current_topology) { |
|---|
| 5256 | 5659 | case ISP_CFG_N: |
|---|
| .. | .. |
|---|
| 5261 | 5664 | break; |
|---|
| 5262 | 5665 | } |
|---|
| 5263 | 5666 | |
|---|
| 5264 | | - if (fcport->fc4f_nvme) { |
|---|
| 5667 | + qla2x00_iidma_fcport(vha, fcport); |
|---|
| 5668 | + |
|---|
| 5669 | + qla2x00_dfs_create_rport(vha, fcport); |
|---|
| 5670 | + |
|---|
| 5671 | + if (NVME_TARGET(vha->hw, fcport)) { |
|---|
| 5265 | 5672 | qla_nvme_register_remote(vha, fcport); |
|---|
| 5266 | | - fcport->disc_state = DSC_LOGIN_COMPLETE; |
|---|
| 5673 | + qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_COMPLETE); |
|---|
| 5267 | 5674 | qla2x00_set_fcport_state(fcport, FCS_ONLINE); |
|---|
| 5268 | 5675 | return; |
|---|
| 5269 | 5676 | } |
|---|
| .. | .. |
|---|
| 5289 | 5696 | break; |
|---|
| 5290 | 5697 | } |
|---|
| 5291 | 5698 | |
|---|
| 5699 | + qla2x00_set_fcport_state(fcport, FCS_ONLINE); |
|---|
| 5700 | + |
|---|
| 5292 | 5701 | if (IS_IIDMA_CAPABLE(vha->hw) && vha->hw->flags.gpsc_supported) { |
|---|
| 5293 | 5702 | if (fcport->id_changed) { |
|---|
| 5294 | 5703 | fcport->id_changed = 0; |
|---|
| .. | .. |
|---|
| 5305 | 5714 | qla24xx_post_gpsc_work(vha, fcport); |
|---|
| 5306 | 5715 | } |
|---|
| 5307 | 5716 | } |
|---|
| 5308 | | - qla2x00_set_fcport_state(fcport, FCS_ONLINE); |
|---|
| 5309 | 5717 | |
|---|
| 5310 | | - fcport->disc_state = DSC_LOGIN_COMPLETE; |
|---|
| 5718 | + qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_COMPLETE); |
|---|
| 5311 | 5719 | } |
|---|
| 5312 | 5720 | |
|---|
| 5313 | 5721 | void qla_register_fcport_fn(struct work_struct *work) |
|---|
| .. | .. |
|---|
| 5375 | 5783 | } |
|---|
| 5376 | 5784 | vha->device_flags |= SWITCH_FOUND; |
|---|
| 5377 | 5785 | |
|---|
| 5786 | + rval = qla2x00_get_port_name(vha, loop_id, vha->fabric_port_name, 0); |
|---|
| 5787 | + if (rval != QLA_SUCCESS) |
|---|
| 5788 | + ql_dbg(ql_dbg_disc, vha, 0x20ff, |
|---|
| 5789 | + "Failed to get Fabric Port Name\n"); |
|---|
| 5378 | 5790 | |
|---|
| 5379 | 5791 | if (qla_tgt_mode_enabled(vha) || qla_dual_mode_enabled(vha)) { |
|---|
| 5380 | 5792 | rval = qla2x00_send_change_request(vha, 0x3, 0); |
|---|
| 5381 | 5793 | if (rval != QLA_SUCCESS) |
|---|
| 5382 | 5794 | ql_log(ql_log_warn, vha, 0x121, |
|---|
| 5383 | | - "Failed to enable receiving of RSCN requests: 0x%x.\n", |
|---|
| 5384 | | - rval); |
|---|
| 5795 | + "Failed to enable receiving of RSCN requests: 0x%x.\n", |
|---|
| 5796 | + rval); |
|---|
| 5385 | 5797 | } |
|---|
| 5386 | | - |
|---|
| 5387 | 5798 | |
|---|
| 5388 | 5799 | do { |
|---|
| 5389 | 5800 | qla2x00_mgmt_svr_login(vha); |
|---|
| 5390 | | - |
|---|
| 5391 | | - /* FDMI support. */ |
|---|
| 5392 | | - if (ql2xfdmienable && |
|---|
| 5393 | | - test_and_clear_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags)) |
|---|
| 5394 | | - qla2x00_fdmi_register(vha); |
|---|
| 5395 | 5801 | |
|---|
| 5396 | 5802 | /* Ensure we are logged into the SNS. */ |
|---|
| 5397 | 5803 | loop_id = NPH_SNS_LID(ha); |
|---|
| .. | .. |
|---|
| 5404 | 5810 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
|---|
| 5405 | 5811 | return rval; |
|---|
| 5406 | 5812 | } |
|---|
| 5813 | + |
|---|
| 5814 | + /* FDMI support. */ |
|---|
| 5815 | + if (ql2xfdmienable && |
|---|
| 5816 | + test_and_clear_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags)) |
|---|
| 5817 | + qla2x00_fdmi_register(vha); |
|---|
| 5818 | + |
|---|
| 5407 | 5819 | if (test_and_clear_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags)) { |
|---|
| 5408 | 5820 | if (qla2x00_rft_id(vha)) { |
|---|
| 5409 | 5821 | /* EMPTY */ |
|---|
| .. | .. |
|---|
| 5588 | 6000 | new_fcport->fc4_type = swl[swl_idx].fc4_type; |
|---|
| 5589 | 6001 | |
|---|
| 5590 | 6002 | new_fcport->nvme_flag = 0; |
|---|
| 5591 | | - new_fcport->fc4f_nvme = 0; |
|---|
| 5592 | 6003 | if (vha->flags.nvme_enabled && |
|---|
| 5593 | | - swl[swl_idx].fc4f_nvme) { |
|---|
| 5594 | | - new_fcport->fc4f_nvme = |
|---|
| 5595 | | - swl[swl_idx].fc4f_nvme; |
|---|
| 6004 | + swl[swl_idx].fc4_type & FS_FC4TYPE_NVME) { |
|---|
| 5596 | 6005 | ql_log(ql_log_info, vha, 0x2131, |
|---|
| 5597 | 6006 | "FOUND: NVME port %8phC as FC Type 28h\n", |
|---|
| 5598 | 6007 | new_fcport->port_name); |
|---|
| .. | .. |
|---|
| 5648 | 6057 | |
|---|
| 5649 | 6058 | /* Bypass ports whose FCP-4 type is not FCP_SCSI */ |
|---|
| 5650 | 6059 | if (ql2xgffidenable && |
|---|
| 5651 | | - (new_fcport->fc4_type != FC4_TYPE_FCP_SCSI && |
|---|
| 5652 | | - new_fcport->fc4_type != FC4_TYPE_UNKNOWN)) |
|---|
| 6060 | + (!(new_fcport->fc4_type & FS_FC4TYPE_FCP) && |
|---|
| 6061 | + new_fcport->fc4_type != 0)) |
|---|
| 5653 | 6062 | continue; |
|---|
| 5654 | 6063 | |
|---|
| 5655 | 6064 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
|---|
| .. | .. |
|---|
| 5717 | 6126 | break; |
|---|
| 5718 | 6127 | } |
|---|
| 5719 | 6128 | |
|---|
| 5720 | | - if (fcport->fc4f_nvme) { |
|---|
| 6129 | + if (found && NVME_TARGET(vha->hw, fcport)) { |
|---|
| 5721 | 6130 | if (fcport->disc_state == DSC_DELETE_PEND) { |
|---|
| 5722 | | - fcport->disc_state = DSC_GNL; |
|---|
| 6131 | + qla2x00_set_fcport_disc_state(fcport, DSC_GNL); |
|---|
| 5723 | 6132 | vha->fcport_count--; |
|---|
| 5724 | 6133 | fcport->login_succ = 0; |
|---|
| 5725 | 6134 | } |
|---|
| .. | .. |
|---|
| 5765 | 6174 | qla_ini_mode_enabled(vha)) && |
|---|
| 5766 | 6175 | atomic_read(&fcport->state) == FCS_ONLINE) { |
|---|
| 5767 | 6176 | qla2x00_mark_device_lost(vha, fcport, |
|---|
| 5768 | | - ql2xplogiabsentdevice, 0); |
|---|
| 6177 | + ql2xplogiabsentdevice); |
|---|
| 5769 | 6178 | if (fcport->loop_id != FC_NO_LOOP_ID && |
|---|
| 5770 | 6179 | (fcport->flags & FCF_FCP2_DEVICE) == 0 && |
|---|
| 5771 | 6180 | fcport->port_type != FCT_INITIATOR && |
|---|
| .. | .. |
|---|
| 5786 | 6195 | } |
|---|
| 5787 | 6196 | return (rval); |
|---|
| 5788 | 6197 | } |
|---|
| 5789 | | - |
|---|
| 5790 | | -/* |
|---|
| 5791 | | - * qla2x00_find_new_loop_id |
|---|
| 5792 | | - * Scan through our port list and find a new usable loop ID. |
|---|
| 5793 | | - * |
|---|
| 5794 | | - * Input: |
|---|
| 5795 | | - * ha: adapter state pointer. |
|---|
| 5796 | | - * dev: port structure pointer. |
|---|
| 5797 | | - * |
|---|
| 5798 | | - * Returns: |
|---|
| 5799 | | - * qla2x00 local function return status code. |
|---|
| 5800 | | - * |
|---|
| 5801 | | - * Context: |
|---|
| 5802 | | - * Kernel context. |
|---|
| 5803 | | - */ |
|---|
| 5804 | | -int |
|---|
| 5805 | | -qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev) |
|---|
| 5806 | | -{ |
|---|
| 5807 | | - int rval; |
|---|
| 5808 | | - struct qla_hw_data *ha = vha->hw; |
|---|
| 5809 | | - unsigned long flags = 0; |
|---|
| 5810 | | - |
|---|
| 5811 | | - rval = QLA_SUCCESS; |
|---|
| 5812 | | - |
|---|
| 5813 | | - spin_lock_irqsave(&ha->vport_slock, flags); |
|---|
| 5814 | | - |
|---|
| 5815 | | - dev->loop_id = find_first_zero_bit(ha->loop_id_map, |
|---|
| 5816 | | - LOOPID_MAP_SIZE); |
|---|
| 5817 | | - if (dev->loop_id >= LOOPID_MAP_SIZE || |
|---|
| 5818 | | - qla2x00_is_reserved_id(vha, dev->loop_id)) { |
|---|
| 5819 | | - dev->loop_id = FC_NO_LOOP_ID; |
|---|
| 5820 | | - rval = QLA_FUNCTION_FAILED; |
|---|
| 5821 | | - } else |
|---|
| 5822 | | - set_bit(dev->loop_id, ha->loop_id_map); |
|---|
| 5823 | | - |
|---|
| 5824 | | - spin_unlock_irqrestore(&ha->vport_slock, flags); |
|---|
| 5825 | | - |
|---|
| 5826 | | - if (rval == QLA_SUCCESS) |
|---|
| 5827 | | - ql_dbg(ql_dbg_disc, dev->vha, 0x2086, |
|---|
| 5828 | | - "Assigning new loopid=%x, portid=%x.\n", |
|---|
| 5829 | | - dev->loop_id, dev->d_id.b24); |
|---|
| 5830 | | - else |
|---|
| 5831 | | - ql_log(ql_log_warn, dev->vha, 0x2087, |
|---|
| 5832 | | - "No loop_id's available, portid=%x.\n", |
|---|
| 5833 | | - dev->d_id.b24); |
|---|
| 5834 | | - |
|---|
| 5835 | | - return (rval); |
|---|
| 5836 | | -} |
|---|
| 5837 | | - |
|---|
| 5838 | 6198 | |
|---|
| 5839 | 6199 | /* FW does not set aside Loop id for MGMT Server/FFFFFAh */ |
|---|
| 5840 | 6200 | int |
|---|
| .. | .. |
|---|
| 5980 | 6340 | ha->isp_ops->fabric_logout(vha, fcport->loop_id, |
|---|
| 5981 | 6341 | fcport->d_id.b.domain, fcport->d_id.b.area, |
|---|
| 5982 | 6342 | fcport->d_id.b.al_pa); |
|---|
| 5983 | | - qla2x00_mark_device_lost(vha, fcport, 1, 0); |
|---|
| 6343 | + qla2x00_mark_device_lost(vha, fcport, 1); |
|---|
| 5984 | 6344 | |
|---|
| 5985 | 6345 | rval = 1; |
|---|
| 5986 | 6346 | break; |
|---|
| .. | .. |
|---|
| 6057 | 6417 | { |
|---|
| 6058 | 6418 | int rval = QLA_SUCCESS; |
|---|
| 6059 | 6419 | uint32_t wait_time; |
|---|
| 6060 | | - struct req_que *req; |
|---|
| 6061 | | - struct rsp_que *rsp; |
|---|
| 6062 | | - |
|---|
| 6063 | | - req = vha->req; |
|---|
| 6064 | | - rsp = req->rsp; |
|---|
| 6065 | 6420 | |
|---|
| 6066 | 6421 | clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
|---|
| 6067 | 6422 | if (vha->flags.online) { |
|---|
| .. | .. |
|---|
| 6074 | 6429 | * Issue a marker after FW becomes |
|---|
| 6075 | 6430 | * ready. |
|---|
| 6076 | 6431 | */ |
|---|
| 6077 | | - qla2x00_marker(vha, req, rsp, 0, 0, |
|---|
| 6078 | | - MK_SYNC_ALL); |
|---|
| 6432 | + qla2x00_marker(vha, vha->hw->base_qpair, |
|---|
| 6433 | + 0, 0, MK_SYNC_ALL); |
|---|
| 6079 | 6434 | vha->marker_needed = 0; |
|---|
| 6080 | 6435 | } |
|---|
| 6081 | 6436 | |
|---|
| .. | .. |
|---|
| 6332 | 6687 | qla83xx_idc_audit(vha, IDC_AUDIT_TIMESTAMP); |
|---|
| 6333 | 6688 | } else { |
|---|
| 6334 | 6689 | const char *state = qla83xx_dev_state_to_string(dev_state); |
|---|
| 6690 | + |
|---|
| 6335 | 6691 | ql_log(ql_log_info, vha, 0xb057, "HW State: %s.\n", state); |
|---|
| 6336 | 6692 | |
|---|
| 6337 | 6693 | /* SV: XXX: Is timeout required here? */ |
|---|
| .. | .. |
|---|
| 6498 | 6854 | atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); |
|---|
| 6499 | 6855 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
|---|
| 6500 | 6856 | atomic_set(&vha->loop_state, LOOP_DOWN); |
|---|
| 6501 | | - qla2x00_mark_all_devices_lost(vha, 0); |
|---|
| 6857 | + qla2x00_mark_all_devices_lost(vha); |
|---|
| 6502 | 6858 | list_for_each_entry(vp, &ha->vp_list, list) |
|---|
| 6503 | | - qla2x00_mark_all_devices_lost(vp, 0); |
|---|
| 6859 | + qla2x00_mark_all_devices_lost(vp); |
|---|
| 6504 | 6860 | } else { |
|---|
| 6505 | 6861 | if (!atomic_read(&vha->loop_down_timer)) |
|---|
| 6506 | 6862 | atomic_set(&vha->loop_down_timer, |
|---|
| 6507 | 6863 | LOOP_DOWN_TIME); |
|---|
| 6508 | 6864 | } |
|---|
| 6509 | 6865 | /* Wait for pending cmds to complete */ |
|---|
| 6510 | | - qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST); |
|---|
| 6866 | + WARN_ON_ONCE(qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) |
|---|
| 6867 | + != QLA_SUCCESS); |
|---|
| 6511 | 6868 | } |
|---|
| 6512 | 6869 | |
|---|
| 6513 | 6870 | void |
|---|
| .. | .. |
|---|
| 6545 | 6902 | ha->flags.n2n_ae = 0; |
|---|
| 6546 | 6903 | ha->flags.lip_ae = 0; |
|---|
| 6547 | 6904 | ha->current_topology = 0; |
|---|
| 6548 | | - ha->flags.fw_started = 0; |
|---|
| 6905 | + QLA_FW_STOPPED(ha); |
|---|
| 6549 | 6906 | ha->flags.fw_init_done = 0; |
|---|
| 6550 | 6907 | ha->chip_reset++; |
|---|
| 6551 | 6908 | ha->base_qpair->chip_reset = ha->chip_reset; |
|---|
| .. | .. |
|---|
| 6575 | 6932 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
|---|
| 6576 | 6933 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
|---|
| 6577 | 6934 | atomic_set(&vha->loop_state, LOOP_DOWN); |
|---|
| 6578 | | - qla2x00_mark_all_devices_lost(vha, 0); |
|---|
| 6935 | + qla2x00_mark_all_devices_lost(vha); |
|---|
| 6579 | 6936 | |
|---|
| 6580 | 6937 | spin_lock_irqsave(&ha->vport_slock, flags); |
|---|
| 6581 | 6938 | list_for_each_entry(vp, &ha->vp_list, list) { |
|---|
| 6582 | 6939 | atomic_inc(&vp->vref_count); |
|---|
| 6583 | 6940 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
|---|
| 6584 | 6941 | |
|---|
| 6585 | | - qla2x00_mark_all_devices_lost(vp, 0); |
|---|
| 6942 | + qla2x00_mark_all_devices_lost(vp); |
|---|
| 6586 | 6943 | |
|---|
| 6587 | 6944 | spin_lock_irqsave(&ha->vport_slock, flags); |
|---|
| 6588 | 6945 | atomic_dec(&vp->vref_count); |
|---|
| .. | .. |
|---|
| 6655 | 7012 | if (vha->flags.online) { |
|---|
| 6656 | 7013 | qla2x00_abort_isp_cleanup(vha); |
|---|
| 6657 | 7014 | |
|---|
| 7015 | + if (test_and_clear_bit(ISP_ABORT_TO_ROM, &vha->dpc_flags)) { |
|---|
| 7016 | + ha->flags.chip_reset_done = 1; |
|---|
| 7017 | + vha->flags.online = 1; |
|---|
| 7018 | + status = 0; |
|---|
| 7019 | + clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
|---|
| 7020 | + return status; |
|---|
| 7021 | + } |
|---|
| 7022 | + |
|---|
| 6658 | 7023 | if (IS_QLA8031(ha)) { |
|---|
| 6659 | 7024 | ql_dbg(ql_dbg_p3p, vha, 0xb05c, |
|---|
| 6660 | 7025 | "Clearing fcoe driver presence.\n"); |
|---|
| .. | .. |
|---|
| 6668 | 7033 | clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
|---|
| 6669 | 7034 | status = 0; |
|---|
| 6670 | 7035 | return status; |
|---|
| 7036 | + } |
|---|
| 7037 | + |
|---|
| 7038 | + switch (vha->qlini_mode) { |
|---|
| 7039 | + case QLA2XXX_INI_MODE_DISABLED: |
|---|
| 7040 | + if (!qla_tgt_mode_enabled(vha)) |
|---|
| 7041 | + return 0; |
|---|
| 7042 | + break; |
|---|
| 7043 | + case QLA2XXX_INI_MODE_DUAL: |
|---|
| 7044 | + if (!qla_dual_mode_enabled(vha) && |
|---|
| 7045 | + !qla_ini_mode_enabled(vha)) |
|---|
| 7046 | + return 0; |
|---|
| 7047 | + break; |
|---|
| 7048 | + case QLA2XXX_INI_MODE_ENABLED: |
|---|
| 7049 | + default: |
|---|
| 7050 | + break; |
|---|
| 6671 | 7051 | } |
|---|
| 6672 | 7052 | |
|---|
| 6673 | 7053 | ha->isp_ops->get_flash_version(vha, req->ring); |
|---|
| .. | .. |
|---|
| 6799 | 7179 | static int |
|---|
| 6800 | 7180 | qla2x00_restart_isp(scsi_qla_host_t *vha) |
|---|
| 6801 | 7181 | { |
|---|
| 6802 | | - int status = 0; |
|---|
| 7182 | + int status; |
|---|
| 6803 | 7183 | struct qla_hw_data *ha = vha->hw; |
|---|
| 6804 | | - struct req_que *req = ha->req_q_map[0]; |
|---|
| 6805 | | - struct rsp_que *rsp = ha->rsp_q_map[0]; |
|---|
| 6806 | 7184 | |
|---|
| 6807 | 7185 | /* If firmware needs to be loaded */ |
|---|
| 6808 | 7186 | if (qla2x00_isp_firmware(vha)) { |
|---|
| 6809 | 7187 | vha->flags.online = 0; |
|---|
| 6810 | 7188 | status = ha->isp_ops->chip_diag(vha); |
|---|
| 6811 | | - if (!status) |
|---|
| 6812 | | - status = qla2x00_setup_chip(vha); |
|---|
| 7189 | + if (status) |
|---|
| 7190 | + return status; |
|---|
| 7191 | + status = qla2x00_setup_chip(vha); |
|---|
| 7192 | + if (status) |
|---|
| 7193 | + return status; |
|---|
| 6813 | 7194 | } |
|---|
| 6814 | 7195 | |
|---|
| 6815 | | - if (!status && !(status = qla2x00_init_rings(vha))) { |
|---|
| 6816 | | - clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
|---|
| 6817 | | - ha->flags.chip_reset_done = 1; |
|---|
| 7196 | + status = qla2x00_init_rings(vha); |
|---|
| 7197 | + if (status) |
|---|
| 7198 | + return status; |
|---|
| 6818 | 7199 | |
|---|
| 6819 | | - /* Initialize the queues in use */ |
|---|
| 6820 | | - qla25xx_init_queues(ha); |
|---|
| 7200 | + clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
|---|
| 7201 | + ha->flags.chip_reset_done = 1; |
|---|
| 6821 | 7202 | |
|---|
| 6822 | | - status = qla2x00_fw_ready(vha); |
|---|
| 6823 | | - if (!status) { |
|---|
| 6824 | | - /* Issue a marker after FW becomes ready. */ |
|---|
| 6825 | | - qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL); |
|---|
| 6826 | | - set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
|---|
| 6827 | | - } |
|---|
| 7203 | + /* Initialize the queues in use */ |
|---|
| 7204 | + qla25xx_init_queues(ha); |
|---|
| 6828 | 7205 | |
|---|
| 7206 | + status = qla2x00_fw_ready(vha); |
|---|
| 7207 | + if (status) { |
|---|
| 6829 | 7208 | /* if no cable then assume it's good */ |
|---|
| 6830 | | - if ((vha->device_flags & DFLG_NO_CABLE)) |
|---|
| 6831 | | - status = 0; |
|---|
| 7209 | + return vha->device_flags & DFLG_NO_CABLE ? 0 : status; |
|---|
| 6832 | 7210 | } |
|---|
| 6833 | | - return (status); |
|---|
| 7211 | + |
|---|
| 7212 | + /* Issue a marker after FW becomes ready. */ |
|---|
| 7213 | + qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL); |
|---|
| 7214 | + set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
|---|
| 7215 | + |
|---|
| 7216 | + return 0; |
|---|
| 6834 | 7217 | } |
|---|
| 6835 | 7218 | |
|---|
| 6836 | 7219 | static int |
|---|
| .. | .. |
|---|
| 6883 | 7266 | * Input: |
|---|
| 6884 | 7267 | * ha = adapter block pointer. |
|---|
| 6885 | 7268 | */ |
|---|
| 6886 | | -void |
|---|
| 7269 | +int |
|---|
| 6887 | 7270 | qla2x00_reset_adapter(scsi_qla_host_t *vha) |
|---|
| 6888 | 7271 | { |
|---|
| 6889 | 7272 | unsigned long flags = 0; |
|---|
| .. | .. |
|---|
| 6894 | 7277 | ha->isp_ops->disable_intrs(ha); |
|---|
| 6895 | 7278 | |
|---|
| 6896 | 7279 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 6897 | | - WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
|---|
| 6898 | | - RD_REG_WORD(®->hccr); /* PCI Posting. */ |
|---|
| 6899 | | - WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
|---|
| 6900 | | - RD_REG_WORD(®->hccr); /* PCI Posting. */ |
|---|
| 7280 | + wrt_reg_word(®->hccr, HCCR_RESET_RISC); |
|---|
| 7281 | + rd_reg_word(®->hccr); /* PCI Posting. */ |
|---|
| 7282 | + wrt_reg_word(®->hccr, HCCR_RELEASE_RISC); |
|---|
| 7283 | + rd_reg_word(®->hccr); /* PCI Posting. */ |
|---|
| 6901 | 7284 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 7285 | + |
|---|
| 7286 | + return QLA_SUCCESS; |
|---|
| 6902 | 7287 | } |
|---|
| 6903 | 7288 | |
|---|
| 6904 | | -void |
|---|
| 7289 | +int |
|---|
| 6905 | 7290 | qla24xx_reset_adapter(scsi_qla_host_t *vha) |
|---|
| 6906 | 7291 | { |
|---|
| 6907 | 7292 | unsigned long flags = 0; |
|---|
| .. | .. |
|---|
| 6909 | 7294 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
|---|
| 6910 | 7295 | |
|---|
| 6911 | 7296 | if (IS_P3P_TYPE(ha)) |
|---|
| 6912 | | - return; |
|---|
| 7297 | + return QLA_SUCCESS; |
|---|
| 6913 | 7298 | |
|---|
| 6914 | 7299 | vha->flags.online = 0; |
|---|
| 6915 | 7300 | ha->isp_ops->disable_intrs(ha); |
|---|
| 6916 | 7301 | |
|---|
| 6917 | 7302 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 6918 | | - WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_RESET); |
|---|
| 6919 | | - RD_REG_DWORD(®->hccr); |
|---|
| 6920 | | - WRT_REG_DWORD(®->hccr, HCCRX_REL_RISC_PAUSE); |
|---|
| 6921 | | - RD_REG_DWORD(®->hccr); |
|---|
| 7303 | + wrt_reg_dword(®->hccr, HCCRX_SET_RISC_RESET); |
|---|
| 7304 | + rd_reg_dword(®->hccr); |
|---|
| 7305 | + wrt_reg_dword(®->hccr, HCCRX_REL_RISC_PAUSE); |
|---|
| 7306 | + rd_reg_dword(®->hccr); |
|---|
| 6922 | 7307 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 6923 | 7308 | |
|---|
| 6924 | 7309 | if (IS_NOPOLLING_TYPE(ha)) |
|---|
| 6925 | 7310 | ha->isp_ops->enable_intrs(ha); |
|---|
| 7311 | + |
|---|
| 7312 | + return QLA_SUCCESS; |
|---|
| 6926 | 7313 | } |
|---|
| 6927 | 7314 | |
|---|
| 6928 | 7315 | /* On sparc systems, obtain port and node WWN from firmware |
|---|
| .. | .. |
|---|
| 6954 | 7341 | int rval; |
|---|
| 6955 | 7342 | struct init_cb_24xx *icb; |
|---|
| 6956 | 7343 | struct nvram_24xx *nv; |
|---|
| 6957 | | - uint32_t *dptr; |
|---|
| 7344 | + __le32 *dptr; |
|---|
| 6958 | 7345 | uint8_t *dptr1, *dptr2; |
|---|
| 6959 | 7346 | uint32_t chksum; |
|---|
| 6960 | 7347 | uint16_t cnt; |
|---|
| .. | .. |
|---|
| 6973 | 7360 | ha->vpd_base = FA_NVRAM_VPD1_ADDR; |
|---|
| 6974 | 7361 | } |
|---|
| 6975 | 7362 | |
|---|
| 6976 | | - ha->nvram_size = sizeof(struct nvram_24xx); |
|---|
| 7363 | + ha->nvram_size = sizeof(*nv); |
|---|
| 6977 | 7364 | ha->vpd_size = FA_NVRAM_VPD_SIZE; |
|---|
| 6978 | 7365 | |
|---|
| 6979 | 7366 | /* Get VPD data into cache */ |
|---|
| 6980 | 7367 | ha->vpd = ha->nvram + VPD_OFFSET; |
|---|
| 6981 | | - ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, |
|---|
| 7368 | + ha->isp_ops->read_nvram(vha, ha->vpd, |
|---|
| 6982 | 7369 | ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4); |
|---|
| 6983 | 7370 | |
|---|
| 6984 | 7371 | /* Get NVRAM data into cache and calculate checksum. */ |
|---|
| 6985 | | - dptr = (uint32_t *)nv; |
|---|
| 6986 | | - ha->isp_ops->read_nvram(vha, (uint8_t *)dptr, ha->nvram_base, |
|---|
| 6987 | | - ha->nvram_size); |
|---|
| 7372 | + dptr = (__force __le32 *)nv; |
|---|
| 7373 | + ha->isp_ops->read_nvram(vha, dptr, ha->nvram_base, ha->nvram_size); |
|---|
| 6988 | 7374 | for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++, dptr++) |
|---|
| 6989 | 7375 | chksum += le32_to_cpu(*dptr); |
|---|
| 6990 | 7376 | |
|---|
| 6991 | 7377 | ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x006a, |
|---|
| 6992 | 7378 | "Contents of NVRAM\n"); |
|---|
| 6993 | 7379 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x010d, |
|---|
| 6994 | | - (uint8_t *)nv, ha->nvram_size); |
|---|
| 7380 | + nv, ha->nvram_size); |
|---|
| 6995 | 7381 | |
|---|
| 6996 | 7382 | /* Bad NVRAM data, set defaults parameters. */ |
|---|
| 6997 | | - if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P' |
|---|
| 6998 | | - || nv->id[3] != ' ' || |
|---|
| 6999 | | - nv->nvram_version < cpu_to_le16(ICB_VERSION)) { |
|---|
| 7383 | + if (chksum || memcmp("ISP ", nv->id, sizeof(nv->id)) || |
|---|
| 7384 | + le16_to_cpu(nv->nvram_version) < ICB_VERSION) { |
|---|
| 7000 | 7385 | /* Reset NVRAM data. */ |
|---|
| 7001 | 7386 | ql_log(ql_log_warn, vha, 0x006b, |
|---|
| 7002 | | - "Inconsistent NVRAM detected: checksum=0x%x id=%c " |
|---|
| 7003 | | - "version=0x%x.\n", chksum, nv->id[0], nv->nvram_version); |
|---|
| 7387 | + "Inconsistent NVRAM checksum=%#x id=%.4s version=%#x.\n", |
|---|
| 7388 | + chksum, nv->id, nv->nvram_version); |
|---|
| 7389 | + ql_dump_buffer(ql_dbg_init, vha, 0x006b, nv, sizeof(*nv)); |
|---|
| 7004 | 7390 | ql_log(ql_log_warn, vha, 0x006c, |
|---|
| 7005 | 7391 | "Falling back to functioning (yet invalid -- WWPN) " |
|---|
| 7006 | 7392 | "defaults.\n"); |
|---|
| .. | .. |
|---|
| 7011 | 7397 | memset(nv, 0, ha->nvram_size); |
|---|
| 7012 | 7398 | nv->nvram_version = cpu_to_le16(ICB_VERSION); |
|---|
| 7013 | 7399 | nv->version = cpu_to_le16(ICB_VERSION); |
|---|
| 7014 | | - nv->frame_payload_size = 2048; |
|---|
| 7400 | + nv->frame_payload_size = cpu_to_le16(2048); |
|---|
| 7015 | 7401 | nv->execution_throttle = cpu_to_le16(0xFFFF); |
|---|
| 7016 | 7402 | nv->exchange_count = cpu_to_le16(0); |
|---|
| 7017 | 7403 | nv->hard_address = cpu_to_le16(124); |
|---|
| .. | .. |
|---|
| 7108 | 7494 | ha->flags.disable_risc_code_load = 0; |
|---|
| 7109 | 7495 | ha->flags.enable_lip_reset = 0; |
|---|
| 7110 | 7496 | ha->flags.enable_lip_full_login = |
|---|
| 7111 | | - le32_to_cpu(nv->host_p) & BIT_10 ? 1: 0; |
|---|
| 7497 | + le32_to_cpu(nv->host_p) & BIT_10 ? 1 : 0; |
|---|
| 7112 | 7498 | ha->flags.enable_target_reset = |
|---|
| 7113 | | - le32_to_cpu(nv->host_p) & BIT_11 ? 1: 0; |
|---|
| 7499 | + le32_to_cpu(nv->host_p) & BIT_11 ? 1 : 0; |
|---|
| 7114 | 7500 | ha->flags.enable_led_scheme = 0; |
|---|
| 7115 | | - ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1: 0; |
|---|
| 7501 | + ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1 : 0; |
|---|
| 7116 | 7502 | |
|---|
| 7117 | 7503 | ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) & |
|---|
| 7118 | 7504 | (BIT_6 | BIT_5 | BIT_4)) >> 4; |
|---|
| .. | .. |
|---|
| 7179 | 7565 | ha->login_retry_count = ql2xloginretrycount; |
|---|
| 7180 | 7566 | |
|---|
| 7181 | 7567 | /* N2N: driver will initiate Login instead of FW */ |
|---|
| 7182 | | - icb->firmware_options_3 |= BIT_8; |
|---|
| 7568 | + icb->firmware_options_3 |= cpu_to_le32(BIT_8); |
|---|
| 7183 | 7569 | |
|---|
| 7184 | 7570 | /* Enable ZIO. */ |
|---|
| 7185 | 7571 | if (!vha->flags.init_done) { |
|---|
| 7186 | 7572 | ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & |
|---|
| 7187 | 7573 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
|---|
| 7188 | 7574 | ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? |
|---|
| 7189 | | - le16_to_cpu(icb->interrupt_delay_timer): 2; |
|---|
| 7575 | + le16_to_cpu(icb->interrupt_delay_timer) : 2; |
|---|
| 7190 | 7576 | } |
|---|
| 7191 | 7577 | icb->firmware_options_2 &= cpu_to_le32( |
|---|
| 7192 | 7578 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0)); |
|---|
| .. | .. |
|---|
| 7209 | 7595 | return (rval); |
|---|
| 7210 | 7596 | } |
|---|
| 7211 | 7597 | |
|---|
| 7212 | | -uint8_t qla27xx_find_valid_image(struct scsi_qla_host *vha) |
|---|
| 7598 | +static void |
|---|
| 7599 | +qla27xx_print_image(struct scsi_qla_host *vha, char *name, |
|---|
| 7600 | + struct qla27xx_image_status *image_status) |
|---|
| 7213 | 7601 | { |
|---|
| 7214 | | - struct qla27xx_image_status pri_image_status, sec_image_status; |
|---|
| 7215 | | - uint8_t valid_pri_image, valid_sec_image; |
|---|
| 7216 | | - uint32_t *wptr; |
|---|
| 7217 | | - uint32_t cnt, chksum, size; |
|---|
| 7218 | | - struct qla_hw_data *ha = vha->hw; |
|---|
| 7602 | + ql_dbg(ql_dbg_init, vha, 0x018b, |
|---|
| 7603 | + "%s %s: mask=%#02x gen=%#04x ver=%u.%u map=%#01x sum=%#08x sig=%#08x\n", |
|---|
| 7604 | + name, "status", |
|---|
| 7605 | + image_status->image_status_mask, |
|---|
| 7606 | + le16_to_cpu(image_status->generation), |
|---|
| 7607 | + image_status->ver_major, |
|---|
| 7608 | + image_status->ver_minor, |
|---|
| 7609 | + image_status->bitmap, |
|---|
| 7610 | + le32_to_cpu(image_status->checksum), |
|---|
| 7611 | + le32_to_cpu(image_status->signature)); |
|---|
| 7612 | +} |
|---|
| 7219 | 7613 | |
|---|
| 7220 | | - valid_pri_image = valid_sec_image = 1; |
|---|
| 7221 | | - ha->active_image = 0; |
|---|
| 7222 | | - size = sizeof(struct qla27xx_image_status) / sizeof(uint32_t); |
|---|
| 7614 | +static bool |
|---|
| 7615 | +qla28xx_check_aux_image_status_signature( |
|---|
| 7616 | + struct qla27xx_image_status *image_status) |
|---|
| 7617 | +{ |
|---|
| 7618 | + ulong signature = le32_to_cpu(image_status->signature); |
|---|
| 7619 | + |
|---|
| 7620 | + return signature != QLA28XX_AUX_IMG_STATUS_SIGN; |
|---|
| 7621 | +} |
|---|
| 7622 | + |
|---|
| 7623 | +static bool |
|---|
| 7624 | +qla27xx_check_image_status_signature(struct qla27xx_image_status *image_status) |
|---|
| 7625 | +{ |
|---|
| 7626 | + ulong signature = le32_to_cpu(image_status->signature); |
|---|
| 7627 | + |
|---|
| 7628 | + return |
|---|
| 7629 | + signature != QLA27XX_IMG_STATUS_SIGN && |
|---|
| 7630 | + signature != QLA28XX_IMG_STATUS_SIGN; |
|---|
| 7631 | +} |
|---|
| 7632 | + |
|---|
| 7633 | +static ulong |
|---|
| 7634 | +qla27xx_image_status_checksum(struct qla27xx_image_status *image_status) |
|---|
| 7635 | +{ |
|---|
| 7636 | + __le32 *p = (__force __le32 *)image_status; |
|---|
| 7637 | + uint n = sizeof(*image_status) / sizeof(*p); |
|---|
| 7638 | + uint32_t sum = 0; |
|---|
| 7639 | + |
|---|
| 7640 | + for ( ; n--; p++) |
|---|
| 7641 | + sum += le32_to_cpup(p); |
|---|
| 7642 | + |
|---|
| 7643 | + return sum; |
|---|
| 7644 | +} |
|---|
| 7645 | + |
|---|
| 7646 | +static inline uint |
|---|
| 7647 | +qla28xx_component_bitmask(struct qla27xx_image_status *aux, uint bitmask) |
|---|
| 7648 | +{ |
|---|
| 7649 | + return aux->bitmap & bitmask ? |
|---|
| 7650 | + QLA27XX_SECONDARY_IMAGE : QLA27XX_PRIMARY_IMAGE; |
|---|
| 7651 | +} |
|---|
| 7652 | + |
|---|
| 7653 | +static void |
|---|
| 7654 | +qla28xx_component_status( |
|---|
| 7655 | + struct active_regions *active_regions, struct qla27xx_image_status *aux) |
|---|
| 7656 | +{ |
|---|
| 7657 | + active_regions->aux.board_config = |
|---|
| 7658 | + qla28xx_component_bitmask(aux, QLA28XX_AUX_IMG_BOARD_CONFIG); |
|---|
| 7659 | + |
|---|
| 7660 | + active_regions->aux.vpd_nvram = |
|---|
| 7661 | + qla28xx_component_bitmask(aux, QLA28XX_AUX_IMG_VPD_NVRAM); |
|---|
| 7662 | + |
|---|
| 7663 | + active_regions->aux.npiv_config_0_1 = |
|---|
| 7664 | + qla28xx_component_bitmask(aux, QLA28XX_AUX_IMG_NPIV_CONFIG_0_1); |
|---|
| 7665 | + |
|---|
| 7666 | + active_regions->aux.npiv_config_2_3 = |
|---|
| 7667 | + qla28xx_component_bitmask(aux, QLA28XX_AUX_IMG_NPIV_CONFIG_2_3); |
|---|
| 7668 | +} |
|---|
| 7669 | + |
|---|
| 7670 | +static int |
|---|
| 7671 | +qla27xx_compare_image_generation( |
|---|
| 7672 | + struct qla27xx_image_status *pri_image_status, |
|---|
| 7673 | + struct qla27xx_image_status *sec_image_status) |
|---|
| 7674 | +{ |
|---|
| 7675 | + /* calculate generation delta as uint16 (this accounts for wrap) */ |
|---|
| 7676 | + int16_t delta = |
|---|
| 7677 | + le16_to_cpu(pri_image_status->generation) - |
|---|
| 7678 | + le16_to_cpu(sec_image_status->generation); |
|---|
| 7679 | + |
|---|
| 7680 | + ql_dbg(ql_dbg_init, NULL, 0x0180, "generation delta = %d\n", delta); |
|---|
| 7681 | + |
|---|
| 7682 | + return delta; |
|---|
| 7683 | +} |
|---|
| 7684 | + |
|---|
| 7685 | +void |
|---|
| 7686 | +qla28xx_get_aux_images( |
|---|
| 7687 | + struct scsi_qla_host *vha, struct active_regions *active_regions) |
|---|
| 7688 | +{ |
|---|
| 7689 | + struct qla_hw_data *ha = vha->hw; |
|---|
| 7690 | + struct qla27xx_image_status pri_aux_image_status, sec_aux_image_status; |
|---|
| 7691 | + bool valid_pri_image = false, valid_sec_image = false; |
|---|
| 7692 | + bool active_pri_image = false, active_sec_image = false; |
|---|
| 7693 | + |
|---|
| 7694 | + if (!ha->flt_region_aux_img_status_pri) { |
|---|
| 7695 | + ql_dbg(ql_dbg_init, vha, 0x018a, "Primary aux image not addressed\n"); |
|---|
| 7696 | + goto check_sec_image; |
|---|
| 7697 | + } |
|---|
| 7698 | + |
|---|
| 7699 | + qla24xx_read_flash_data(vha, (uint32_t *)&pri_aux_image_status, |
|---|
| 7700 | + ha->flt_region_aux_img_status_pri, |
|---|
| 7701 | + sizeof(pri_aux_image_status) >> 2); |
|---|
| 7702 | + qla27xx_print_image(vha, "Primary aux image", &pri_aux_image_status); |
|---|
| 7703 | + |
|---|
| 7704 | + if (qla28xx_check_aux_image_status_signature(&pri_aux_image_status)) { |
|---|
| 7705 | + ql_dbg(ql_dbg_init, vha, 0x018b, |
|---|
| 7706 | + "Primary aux image signature (%#x) not valid\n", |
|---|
| 7707 | + le32_to_cpu(pri_aux_image_status.signature)); |
|---|
| 7708 | + goto check_sec_image; |
|---|
| 7709 | + } |
|---|
| 7710 | + |
|---|
| 7711 | + if (qla27xx_image_status_checksum(&pri_aux_image_status)) { |
|---|
| 7712 | + ql_dbg(ql_dbg_init, vha, 0x018c, |
|---|
| 7713 | + "Primary aux image checksum failed\n"); |
|---|
| 7714 | + goto check_sec_image; |
|---|
| 7715 | + } |
|---|
| 7716 | + |
|---|
| 7717 | + valid_pri_image = true; |
|---|
| 7718 | + |
|---|
| 7719 | + if (pri_aux_image_status.image_status_mask & 1) { |
|---|
| 7720 | + ql_dbg(ql_dbg_init, vha, 0x018d, |
|---|
| 7721 | + "Primary aux image is active\n"); |
|---|
| 7722 | + active_pri_image = true; |
|---|
| 7723 | + } |
|---|
| 7724 | + |
|---|
| 7725 | +check_sec_image: |
|---|
| 7726 | + if (!ha->flt_region_aux_img_status_sec) { |
|---|
| 7727 | + ql_dbg(ql_dbg_init, vha, 0x018a, |
|---|
| 7728 | + "Secondary aux image not addressed\n"); |
|---|
| 7729 | + goto check_valid_image; |
|---|
| 7730 | + } |
|---|
| 7731 | + |
|---|
| 7732 | + qla24xx_read_flash_data(vha, (uint32_t *)&sec_aux_image_status, |
|---|
| 7733 | + ha->flt_region_aux_img_status_sec, |
|---|
| 7734 | + sizeof(sec_aux_image_status) >> 2); |
|---|
| 7735 | + qla27xx_print_image(vha, "Secondary aux image", &sec_aux_image_status); |
|---|
| 7736 | + |
|---|
| 7737 | + if (qla28xx_check_aux_image_status_signature(&sec_aux_image_status)) { |
|---|
| 7738 | + ql_dbg(ql_dbg_init, vha, 0x018b, |
|---|
| 7739 | + "Secondary aux image signature (%#x) not valid\n", |
|---|
| 7740 | + le32_to_cpu(sec_aux_image_status.signature)); |
|---|
| 7741 | + goto check_valid_image; |
|---|
| 7742 | + } |
|---|
| 7743 | + |
|---|
| 7744 | + if (qla27xx_image_status_checksum(&sec_aux_image_status)) { |
|---|
| 7745 | + ql_dbg(ql_dbg_init, vha, 0x018c, |
|---|
| 7746 | + "Secondary aux image checksum failed\n"); |
|---|
| 7747 | + goto check_valid_image; |
|---|
| 7748 | + } |
|---|
| 7749 | + |
|---|
| 7750 | + valid_sec_image = true; |
|---|
| 7751 | + |
|---|
| 7752 | + if (sec_aux_image_status.image_status_mask & 1) { |
|---|
| 7753 | + ql_dbg(ql_dbg_init, vha, 0x018d, |
|---|
| 7754 | + "Secondary aux image is active\n"); |
|---|
| 7755 | + active_sec_image = true; |
|---|
| 7756 | + } |
|---|
| 7757 | + |
|---|
| 7758 | +check_valid_image: |
|---|
| 7759 | + if (valid_pri_image && active_pri_image && |
|---|
| 7760 | + valid_sec_image && active_sec_image) { |
|---|
| 7761 | + if (qla27xx_compare_image_generation(&pri_aux_image_status, |
|---|
| 7762 | + &sec_aux_image_status) >= 0) { |
|---|
| 7763 | + qla28xx_component_status(active_regions, |
|---|
| 7764 | + &pri_aux_image_status); |
|---|
| 7765 | + } else { |
|---|
| 7766 | + qla28xx_component_status(active_regions, |
|---|
| 7767 | + &sec_aux_image_status); |
|---|
| 7768 | + } |
|---|
| 7769 | + } else if (valid_pri_image && active_pri_image) { |
|---|
| 7770 | + qla28xx_component_status(active_regions, &pri_aux_image_status); |
|---|
| 7771 | + } else if (valid_sec_image && active_sec_image) { |
|---|
| 7772 | + qla28xx_component_status(active_regions, &sec_aux_image_status); |
|---|
| 7773 | + } |
|---|
| 7774 | + |
|---|
| 7775 | + ql_dbg(ql_dbg_init, vha, 0x018f, |
|---|
| 7776 | + "aux images active: BCFG=%u VPD/NVR=%u NPIV0/1=%u NPIV2/3=%u\n", |
|---|
| 7777 | + active_regions->aux.board_config, |
|---|
| 7778 | + active_regions->aux.vpd_nvram, |
|---|
| 7779 | + active_regions->aux.npiv_config_0_1, |
|---|
| 7780 | + active_regions->aux.npiv_config_2_3); |
|---|
| 7781 | +} |
|---|
| 7782 | + |
|---|
| 7783 | +void |
|---|
| 7784 | +qla27xx_get_active_image(struct scsi_qla_host *vha, |
|---|
| 7785 | + struct active_regions *active_regions) |
|---|
| 7786 | +{ |
|---|
| 7787 | + struct qla_hw_data *ha = vha->hw; |
|---|
| 7788 | + struct qla27xx_image_status pri_image_status, sec_image_status; |
|---|
| 7789 | + bool valid_pri_image = false, valid_sec_image = false; |
|---|
| 7790 | + bool active_pri_image = false, active_sec_image = false; |
|---|
| 7223 | 7791 | |
|---|
| 7224 | 7792 | if (!ha->flt_region_img_status_pri) { |
|---|
| 7225 | | - valid_pri_image = 0; |
|---|
| 7793 | + ql_dbg(ql_dbg_init, vha, 0x018a, "Primary image not addressed\n"); |
|---|
| 7226 | 7794 | goto check_sec_image; |
|---|
| 7227 | 7795 | } |
|---|
| 7228 | 7796 | |
|---|
| 7229 | | - qla24xx_read_flash_data(vha, (uint32_t *)(&pri_image_status), |
|---|
| 7230 | | - ha->flt_region_img_status_pri, size); |
|---|
| 7797 | + if (qla24xx_read_flash_data(vha, (uint32_t *)&pri_image_status, |
|---|
| 7798 | + ha->flt_region_img_status_pri, sizeof(pri_image_status) >> 2) != |
|---|
| 7799 | + QLA_SUCCESS) { |
|---|
| 7800 | + WARN_ON_ONCE(true); |
|---|
| 7801 | + goto check_sec_image; |
|---|
| 7802 | + } |
|---|
| 7803 | + qla27xx_print_image(vha, "Primary image", &pri_image_status); |
|---|
| 7231 | 7804 | |
|---|
| 7232 | | - if (pri_image_status.signature != QLA27XX_IMG_STATUS_SIGN) { |
|---|
| 7805 | + if (qla27xx_check_image_status_signature(&pri_image_status)) { |
|---|
| 7233 | 7806 | ql_dbg(ql_dbg_init, vha, 0x018b, |
|---|
| 7234 | | - "Primary image signature (0x%x) not valid\n", |
|---|
| 7235 | | - pri_image_status.signature); |
|---|
| 7236 | | - valid_pri_image = 0; |
|---|
| 7807 | + "Primary image signature (%#x) not valid\n", |
|---|
| 7808 | + le32_to_cpu(pri_image_status.signature)); |
|---|
| 7237 | 7809 | goto check_sec_image; |
|---|
| 7238 | 7810 | } |
|---|
| 7239 | 7811 | |
|---|
| 7240 | | - wptr = (uint32_t *)(&pri_image_status); |
|---|
| 7241 | | - cnt = size; |
|---|
| 7242 | | - |
|---|
| 7243 | | - for (chksum = 0; cnt--; wptr++) |
|---|
| 7244 | | - chksum += le32_to_cpu(*wptr); |
|---|
| 7245 | | - |
|---|
| 7246 | | - if (chksum) { |
|---|
| 7812 | + if (qla27xx_image_status_checksum(&pri_image_status)) { |
|---|
| 7247 | 7813 | ql_dbg(ql_dbg_init, vha, 0x018c, |
|---|
| 7248 | | - "Checksum validation failed for primary image (0x%x)\n", |
|---|
| 7249 | | - chksum); |
|---|
| 7250 | | - valid_pri_image = 0; |
|---|
| 7814 | + "Primary image checksum failed\n"); |
|---|
| 7815 | + goto check_sec_image; |
|---|
| 7816 | + } |
|---|
| 7817 | + |
|---|
| 7818 | + valid_pri_image = true; |
|---|
| 7819 | + |
|---|
| 7820 | + if (pri_image_status.image_status_mask & 1) { |
|---|
| 7821 | + ql_dbg(ql_dbg_init, vha, 0x018d, |
|---|
| 7822 | + "Primary image is active\n"); |
|---|
| 7823 | + active_pri_image = true; |
|---|
| 7251 | 7824 | } |
|---|
| 7252 | 7825 | |
|---|
| 7253 | 7826 | check_sec_image: |
|---|
| 7254 | 7827 | if (!ha->flt_region_img_status_sec) { |
|---|
| 7255 | | - valid_sec_image = 0; |
|---|
| 7828 | + ql_dbg(ql_dbg_init, vha, 0x018a, "Secondary image not addressed\n"); |
|---|
| 7256 | 7829 | goto check_valid_image; |
|---|
| 7257 | 7830 | } |
|---|
| 7258 | 7831 | |
|---|
| 7259 | 7832 | qla24xx_read_flash_data(vha, (uint32_t *)(&sec_image_status), |
|---|
| 7260 | | - ha->flt_region_img_status_sec, size); |
|---|
| 7833 | + ha->flt_region_img_status_sec, sizeof(sec_image_status) >> 2); |
|---|
| 7834 | + qla27xx_print_image(vha, "Secondary image", &sec_image_status); |
|---|
| 7261 | 7835 | |
|---|
| 7262 | | - if (sec_image_status.signature != QLA27XX_IMG_STATUS_SIGN) { |
|---|
| 7263 | | - ql_dbg(ql_dbg_init, vha, 0x018d, |
|---|
| 7264 | | - "Secondary image signature(0x%x) not valid\n", |
|---|
| 7265 | | - sec_image_status.signature); |
|---|
| 7266 | | - valid_sec_image = 0; |
|---|
| 7836 | + if (qla27xx_check_image_status_signature(&sec_image_status)) { |
|---|
| 7837 | + ql_dbg(ql_dbg_init, vha, 0x018b, |
|---|
| 7838 | + "Secondary image signature (%#x) not valid\n", |
|---|
| 7839 | + le32_to_cpu(sec_image_status.signature)); |
|---|
| 7267 | 7840 | goto check_valid_image; |
|---|
| 7268 | 7841 | } |
|---|
| 7269 | 7842 | |
|---|
| 7270 | | - wptr = (uint32_t *)(&sec_image_status); |
|---|
| 7271 | | - cnt = size; |
|---|
| 7272 | | - for (chksum = 0; cnt--; wptr++) |
|---|
| 7273 | | - chksum += le32_to_cpu(*wptr); |
|---|
| 7274 | | - if (chksum) { |
|---|
| 7275 | | - ql_dbg(ql_dbg_init, vha, 0x018e, |
|---|
| 7276 | | - "Checksum validation failed for secondary image (0x%x)\n", |
|---|
| 7277 | | - chksum); |
|---|
| 7278 | | - valid_sec_image = 0; |
|---|
| 7843 | + if (qla27xx_image_status_checksum(&sec_image_status)) { |
|---|
| 7844 | + ql_dbg(ql_dbg_init, vha, 0x018c, |
|---|
| 7845 | + "Secondary image checksum failed\n"); |
|---|
| 7846 | + goto check_valid_image; |
|---|
| 7847 | + } |
|---|
| 7848 | + |
|---|
| 7849 | + valid_sec_image = true; |
|---|
| 7850 | + |
|---|
| 7851 | + if (sec_image_status.image_status_mask & 1) { |
|---|
| 7852 | + ql_dbg(ql_dbg_init, vha, 0x018d, |
|---|
| 7853 | + "Secondary image is active\n"); |
|---|
| 7854 | + active_sec_image = true; |
|---|
| 7279 | 7855 | } |
|---|
| 7280 | 7856 | |
|---|
| 7281 | 7857 | check_valid_image: |
|---|
| 7282 | | - if (valid_pri_image && (pri_image_status.image_status_mask & 0x1)) |
|---|
| 7283 | | - ha->active_image = QLA27XX_PRIMARY_IMAGE; |
|---|
| 7284 | | - if (valid_sec_image && (sec_image_status.image_status_mask & 0x1)) { |
|---|
| 7285 | | - if (!ha->active_image || |
|---|
| 7286 | | - pri_image_status.generation_number < |
|---|
| 7287 | | - sec_image_status.generation_number) |
|---|
| 7288 | | - ha->active_image = QLA27XX_SECONDARY_IMAGE; |
|---|
| 7858 | + if (valid_pri_image && active_pri_image) |
|---|
| 7859 | + active_regions->global = QLA27XX_PRIMARY_IMAGE; |
|---|
| 7860 | + |
|---|
| 7861 | + if (valid_sec_image && active_sec_image) { |
|---|
| 7862 | + if (!active_regions->global || |
|---|
| 7863 | + qla27xx_compare_image_generation( |
|---|
| 7864 | + &pri_image_status, &sec_image_status) < 0) { |
|---|
| 7865 | + active_regions->global = QLA27XX_SECONDARY_IMAGE; |
|---|
| 7866 | + } |
|---|
| 7289 | 7867 | } |
|---|
| 7290 | 7868 | |
|---|
| 7291 | | - ql_dbg(ql_dbg_init + ql_dbg_verbose, vha, 0x018f, "%s image\n", |
|---|
| 7292 | | - ha->active_image == 0 ? "default bootld and fw" : |
|---|
| 7293 | | - ha->active_image == 1 ? "primary" : |
|---|
| 7294 | | - ha->active_image == 2 ? "secondary" : |
|---|
| 7295 | | - "Invalid"); |
|---|
| 7869 | + ql_dbg(ql_dbg_init, vha, 0x018f, "active image %s (%u)\n", |
|---|
| 7870 | + active_regions->global == QLA27XX_DEFAULT_IMAGE ? |
|---|
| 7871 | + "default (boot/fw)" : |
|---|
| 7872 | + active_regions->global == QLA27XX_PRIMARY_IMAGE ? |
|---|
| 7873 | + "primary" : |
|---|
| 7874 | + active_regions->global == QLA27XX_SECONDARY_IMAGE ? |
|---|
| 7875 | + "secondary" : "invalid", |
|---|
| 7876 | + active_regions->global); |
|---|
| 7877 | +} |
|---|
| 7296 | 7878 | |
|---|
| 7297 | | - return ha->active_image; |
|---|
| 7879 | +bool qla24xx_risc_firmware_invalid(uint32_t *dword) |
|---|
| 7880 | +{ |
|---|
| 7881 | + return |
|---|
| 7882 | + !(dword[4] | dword[5] | dword[6] | dword[7]) || |
|---|
| 7883 | + !(~dword[4] | ~dword[5] | ~dword[6] | ~dword[7]); |
|---|
| 7298 | 7884 | } |
|---|
| 7299 | 7885 | |
|---|
| 7300 | 7886 | static int |
|---|
| 7301 | 7887 | qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr, |
|---|
| 7302 | 7888 | uint32_t faddr) |
|---|
| 7303 | 7889 | { |
|---|
| 7304 | | - int rval = QLA_SUCCESS; |
|---|
| 7305 | | - int segments, fragment; |
|---|
| 7306 | | - uint32_t *dcode, dlen; |
|---|
| 7307 | | - uint32_t risc_addr; |
|---|
| 7308 | | - uint32_t risc_size; |
|---|
| 7309 | | - uint32_t i; |
|---|
| 7890 | + int rval; |
|---|
| 7891 | + uint templates, segments, fragment; |
|---|
| 7892 | + ulong i; |
|---|
| 7893 | + uint j; |
|---|
| 7894 | + ulong dlen; |
|---|
| 7895 | + uint32_t *dcode; |
|---|
| 7896 | + uint32_t risc_addr, risc_size, risc_attr = 0; |
|---|
| 7310 | 7897 | struct qla_hw_data *ha = vha->hw; |
|---|
| 7311 | 7898 | struct req_que *req = ha->req_q_map[0]; |
|---|
| 7899 | + struct fwdt *fwdt = ha->fwdt; |
|---|
| 7312 | 7900 | |
|---|
| 7313 | 7901 | ql_dbg(ql_dbg_init, vha, 0x008b, |
|---|
| 7314 | 7902 | "FW: Loading firmware from flash (%x).\n", faddr); |
|---|
| 7315 | 7903 | |
|---|
| 7316 | | - rval = QLA_SUCCESS; |
|---|
| 7317 | | - |
|---|
| 7318 | | - segments = FA_RISC_CODE_SEGMENTS; |
|---|
| 7319 | 7904 | dcode = (uint32_t *)req->ring; |
|---|
| 7320 | | - *srisc_addr = 0; |
|---|
| 7321 | | - |
|---|
| 7322 | | - if (IS_QLA27XX(ha) && |
|---|
| 7323 | | - qla27xx_find_valid_image(vha) == QLA27XX_SECONDARY_IMAGE) |
|---|
| 7324 | | - faddr = ha->flt_region_fw_sec; |
|---|
| 7325 | | - |
|---|
| 7326 | | - /* Validate firmware image by checking version. */ |
|---|
| 7327 | | - qla24xx_read_flash_data(vha, dcode, faddr + 4, 4); |
|---|
| 7328 | | - for (i = 0; i < 4; i++) |
|---|
| 7329 | | - dcode[i] = be32_to_cpu(dcode[i]); |
|---|
| 7330 | | - if ((dcode[0] == 0xffffffff && dcode[1] == 0xffffffff && |
|---|
| 7331 | | - dcode[2] == 0xffffffff && dcode[3] == 0xffffffff) || |
|---|
| 7332 | | - (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 && |
|---|
| 7333 | | - dcode[3] == 0)) { |
|---|
| 7905 | + qla24xx_read_flash_data(vha, dcode, faddr, 8); |
|---|
| 7906 | + if (qla24xx_risc_firmware_invalid(dcode)) { |
|---|
| 7334 | 7907 | ql_log(ql_log_fatal, vha, 0x008c, |
|---|
| 7335 | 7908 | "Unable to verify the integrity of flash firmware " |
|---|
| 7336 | 7909 | "image.\n"); |
|---|
| .. | .. |
|---|
| 7341 | 7914 | return QLA_FUNCTION_FAILED; |
|---|
| 7342 | 7915 | } |
|---|
| 7343 | 7916 | |
|---|
| 7344 | | - while (segments && rval == QLA_SUCCESS) { |
|---|
| 7345 | | - /* Read segment's load information. */ |
|---|
| 7346 | | - qla24xx_read_flash_data(vha, dcode, faddr, 4); |
|---|
| 7917 | + dcode = (uint32_t *)req->ring; |
|---|
| 7918 | + *srisc_addr = 0; |
|---|
| 7919 | + segments = FA_RISC_CODE_SEGMENTS; |
|---|
| 7920 | + for (j = 0; j < segments; j++) { |
|---|
| 7921 | + ql_dbg(ql_dbg_init, vha, 0x008d, |
|---|
| 7922 | + "-> Loading segment %u...\n", j); |
|---|
| 7923 | + qla24xx_read_flash_data(vha, dcode, faddr, 10); |
|---|
| 7924 | + risc_addr = be32_to_cpu((__force __be32)dcode[2]); |
|---|
| 7925 | + risc_size = be32_to_cpu((__force __be32)dcode[3]); |
|---|
| 7926 | + if (!*srisc_addr) { |
|---|
| 7927 | + *srisc_addr = risc_addr; |
|---|
| 7928 | + risc_attr = be32_to_cpu((__force __be32)dcode[9]); |
|---|
| 7929 | + } |
|---|
| 7347 | 7930 | |
|---|
| 7348 | | - risc_addr = be32_to_cpu(dcode[2]); |
|---|
| 7349 | | - *srisc_addr = *srisc_addr == 0 ? risc_addr : *srisc_addr; |
|---|
| 7350 | | - risc_size = be32_to_cpu(dcode[3]); |
|---|
| 7351 | | - |
|---|
| 7352 | | - fragment = 0; |
|---|
| 7353 | | - while (risc_size > 0 && rval == QLA_SUCCESS) { |
|---|
| 7354 | | - dlen = (uint32_t)(ha->fw_transfer_size >> 2); |
|---|
| 7931 | + dlen = ha->fw_transfer_size >> 2; |
|---|
| 7932 | + for (fragment = 0; risc_size; fragment++) { |
|---|
| 7355 | 7933 | if (dlen > risc_size) |
|---|
| 7356 | 7934 | dlen = risc_size; |
|---|
| 7357 | 7935 | |
|---|
| 7358 | 7936 | ql_dbg(ql_dbg_init, vha, 0x008e, |
|---|
| 7359 | | - "Loading risc segment@ risc addr %x " |
|---|
| 7360 | | - "number of dwords 0x%x offset 0x%x.\n", |
|---|
| 7361 | | - risc_addr, dlen, faddr); |
|---|
| 7362 | | - |
|---|
| 7937 | + "-> Loading fragment %u: %#x <- %#x (%#lx dwords)...\n", |
|---|
| 7938 | + fragment, risc_addr, faddr, dlen); |
|---|
| 7363 | 7939 | qla24xx_read_flash_data(vha, dcode, faddr, dlen); |
|---|
| 7364 | 7940 | for (i = 0; i < dlen; i++) |
|---|
| 7365 | 7941 | dcode[i] = swab32(dcode[i]); |
|---|
| 7366 | 7942 | |
|---|
| 7367 | | - rval = qla2x00_load_ram(vha, req->dma, risc_addr, |
|---|
| 7368 | | - dlen); |
|---|
| 7943 | + rval = qla2x00_load_ram(vha, req->dma, risc_addr, dlen); |
|---|
| 7369 | 7944 | if (rval) { |
|---|
| 7370 | 7945 | ql_log(ql_log_fatal, vha, 0x008f, |
|---|
| 7371 | | - "Failed to load segment %d of firmware.\n", |
|---|
| 7946 | + "-> Failed load firmware fragment %u.\n", |
|---|
| 7372 | 7947 | fragment); |
|---|
| 7373 | 7948 | return QLA_FUNCTION_FAILED; |
|---|
| 7374 | 7949 | } |
|---|
| .. | .. |
|---|
| 7376 | 7951 | faddr += dlen; |
|---|
| 7377 | 7952 | risc_addr += dlen; |
|---|
| 7378 | 7953 | risc_size -= dlen; |
|---|
| 7379 | | - fragment++; |
|---|
| 7954 | + } |
|---|
| 7955 | + } |
|---|
| 7956 | + |
|---|
| 7957 | + if (!IS_QLA27XX(ha) && !IS_QLA28XX(ha)) |
|---|
| 7958 | + return QLA_SUCCESS; |
|---|
| 7959 | + |
|---|
| 7960 | + templates = (risc_attr & BIT_9) ? 2 : 1; |
|---|
| 7961 | + ql_dbg(ql_dbg_init, vha, 0x0160, "-> templates = %u\n", templates); |
|---|
| 7962 | + for (j = 0; j < templates; j++, fwdt++) { |
|---|
| 7963 | + if (fwdt->template) |
|---|
| 7964 | + vfree(fwdt->template); |
|---|
| 7965 | + fwdt->template = NULL; |
|---|
| 7966 | + fwdt->length = 0; |
|---|
| 7967 | + |
|---|
| 7968 | + dcode = (uint32_t *)req->ring; |
|---|
| 7969 | + qla24xx_read_flash_data(vha, dcode, faddr, 7); |
|---|
| 7970 | + risc_size = be32_to_cpu((__force __be32)dcode[2]); |
|---|
| 7971 | + ql_dbg(ql_dbg_init, vha, 0x0161, |
|---|
| 7972 | + "-> fwdt%u template array at %#x (%#x dwords)\n", |
|---|
| 7973 | + j, faddr, risc_size); |
|---|
| 7974 | + if (!risc_size || !~risc_size) { |
|---|
| 7975 | + ql_dbg(ql_dbg_init, vha, 0x0162, |
|---|
| 7976 | + "-> fwdt%u failed to read array\n", j); |
|---|
| 7977 | + goto failed; |
|---|
| 7380 | 7978 | } |
|---|
| 7381 | 7979 | |
|---|
| 7382 | | - /* Next segment. */ |
|---|
| 7383 | | - segments--; |
|---|
| 7980 | + /* skip header and ignore checksum */ |
|---|
| 7981 | + faddr += 7; |
|---|
| 7982 | + risc_size -= 8; |
|---|
| 7983 | + |
|---|
| 7984 | + ql_dbg(ql_dbg_init, vha, 0x0163, |
|---|
| 7985 | + "-> fwdt%u template allocate template %#x words...\n", |
|---|
| 7986 | + j, risc_size); |
|---|
| 7987 | + fwdt->template = vmalloc(risc_size * sizeof(*dcode)); |
|---|
| 7988 | + if (!fwdt->template) { |
|---|
| 7989 | + ql_log(ql_log_warn, vha, 0x0164, |
|---|
| 7990 | + "-> fwdt%u failed allocate template.\n", j); |
|---|
| 7991 | + goto failed; |
|---|
| 7992 | + } |
|---|
| 7993 | + |
|---|
| 7994 | + dcode = fwdt->template; |
|---|
| 7995 | + qla24xx_read_flash_data(vha, dcode, faddr, risc_size); |
|---|
| 7996 | + |
|---|
| 7997 | + if (!qla27xx_fwdt_template_valid(dcode)) { |
|---|
| 7998 | + ql_log(ql_log_warn, vha, 0x0165, |
|---|
| 7999 | + "-> fwdt%u failed template validate\n", j); |
|---|
| 8000 | + goto failed; |
|---|
| 8001 | + } |
|---|
| 8002 | + |
|---|
| 8003 | + dlen = qla27xx_fwdt_template_size(dcode); |
|---|
| 8004 | + ql_dbg(ql_dbg_init, vha, 0x0166, |
|---|
| 8005 | + "-> fwdt%u template size %#lx bytes (%#lx words)\n", |
|---|
| 8006 | + j, dlen, dlen / sizeof(*dcode)); |
|---|
| 8007 | + if (dlen > risc_size * sizeof(*dcode)) { |
|---|
| 8008 | + ql_log(ql_log_warn, vha, 0x0167, |
|---|
| 8009 | + "-> fwdt%u template exceeds array (%-lu bytes)\n", |
|---|
| 8010 | + j, dlen - risc_size * sizeof(*dcode)); |
|---|
| 8011 | + goto failed; |
|---|
| 8012 | + } |
|---|
| 8013 | + |
|---|
| 8014 | + fwdt->length = dlen; |
|---|
| 8015 | + ql_dbg(ql_dbg_init, vha, 0x0168, |
|---|
| 8016 | + "-> fwdt%u loaded template ok\n", j); |
|---|
| 8017 | + |
|---|
| 8018 | + faddr += risc_size + 1; |
|---|
| 7384 | 8019 | } |
|---|
| 7385 | 8020 | |
|---|
| 7386 | | - if (!IS_QLA27XX(ha)) |
|---|
| 7387 | | - return rval; |
|---|
| 8021 | + return QLA_SUCCESS; |
|---|
| 7388 | 8022 | |
|---|
| 7389 | | - if (ha->fw_dump_template) |
|---|
| 7390 | | - vfree(ha->fw_dump_template); |
|---|
| 7391 | | - ha->fw_dump_template = NULL; |
|---|
| 7392 | | - ha->fw_dump_template_len = 0; |
|---|
| 8023 | +failed: |
|---|
| 8024 | + if (fwdt->template) |
|---|
| 8025 | + vfree(fwdt->template); |
|---|
| 8026 | + fwdt->template = NULL; |
|---|
| 8027 | + fwdt->length = 0; |
|---|
| 7393 | 8028 | |
|---|
| 7394 | | - ql_dbg(ql_dbg_init, vha, 0x0161, |
|---|
| 7395 | | - "Loading fwdump template from %x\n", faddr); |
|---|
| 7396 | | - qla24xx_read_flash_data(vha, dcode, faddr, 7); |
|---|
| 7397 | | - risc_size = be32_to_cpu(dcode[2]); |
|---|
| 7398 | | - ql_dbg(ql_dbg_init, vha, 0x0162, |
|---|
| 7399 | | - "-> array size %x dwords\n", risc_size); |
|---|
| 7400 | | - if (risc_size == 0 || risc_size == ~0) |
|---|
| 7401 | | - goto default_template; |
|---|
| 7402 | | - |
|---|
| 7403 | | - dlen = (risc_size - 8) * sizeof(*dcode); |
|---|
| 7404 | | - ql_dbg(ql_dbg_init, vha, 0x0163, |
|---|
| 7405 | | - "-> template allocating %x bytes...\n", dlen); |
|---|
| 7406 | | - ha->fw_dump_template = vmalloc(dlen); |
|---|
| 7407 | | - if (!ha->fw_dump_template) { |
|---|
| 7408 | | - ql_log(ql_log_warn, vha, 0x0164, |
|---|
| 7409 | | - "Failed fwdump template allocate %x bytes.\n", risc_size); |
|---|
| 7410 | | - goto default_template; |
|---|
| 7411 | | - } |
|---|
| 7412 | | - |
|---|
| 7413 | | - faddr += 7; |
|---|
| 7414 | | - risc_size -= 8; |
|---|
| 7415 | | - dcode = ha->fw_dump_template; |
|---|
| 7416 | | - qla24xx_read_flash_data(vha, dcode, faddr, risc_size); |
|---|
| 7417 | | - for (i = 0; i < risc_size; i++) |
|---|
| 7418 | | - dcode[i] = le32_to_cpu(dcode[i]); |
|---|
| 7419 | | - |
|---|
| 7420 | | - if (!qla27xx_fwdt_template_valid(dcode)) { |
|---|
| 7421 | | - ql_log(ql_log_warn, vha, 0x0165, |
|---|
| 7422 | | - "Failed fwdump template validate\n"); |
|---|
| 7423 | | - goto default_template; |
|---|
| 7424 | | - } |
|---|
| 7425 | | - |
|---|
| 7426 | | - dlen = qla27xx_fwdt_template_size(dcode); |
|---|
| 7427 | | - ql_dbg(ql_dbg_init, vha, 0x0166, |
|---|
| 7428 | | - "-> template size %x bytes\n", dlen); |
|---|
| 7429 | | - if (dlen > risc_size * sizeof(*dcode)) { |
|---|
| 7430 | | - ql_log(ql_log_warn, vha, 0x0167, |
|---|
| 7431 | | - "Failed fwdump template exceeds array by %zx bytes\n", |
|---|
| 7432 | | - (size_t)(dlen - risc_size * sizeof(*dcode))); |
|---|
| 7433 | | - goto default_template; |
|---|
| 7434 | | - } |
|---|
| 7435 | | - ha->fw_dump_template_len = dlen; |
|---|
| 7436 | | - return rval; |
|---|
| 7437 | | - |
|---|
| 7438 | | -default_template: |
|---|
| 7439 | | - ql_log(ql_log_warn, vha, 0x0168, "Using default fwdump template\n"); |
|---|
| 7440 | | - if (ha->fw_dump_template) |
|---|
| 7441 | | - vfree(ha->fw_dump_template); |
|---|
| 7442 | | - ha->fw_dump_template = NULL; |
|---|
| 7443 | | - ha->fw_dump_template_len = 0; |
|---|
| 7444 | | - |
|---|
| 7445 | | - dlen = qla27xx_fwdt_template_default_size(); |
|---|
| 7446 | | - ql_dbg(ql_dbg_init, vha, 0x0169, |
|---|
| 7447 | | - "-> template allocating %x bytes...\n", dlen); |
|---|
| 7448 | | - ha->fw_dump_template = vmalloc(dlen); |
|---|
| 7449 | | - if (!ha->fw_dump_template) { |
|---|
| 7450 | | - ql_log(ql_log_warn, vha, 0x016a, |
|---|
| 7451 | | - "Failed fwdump template allocate %x bytes.\n", risc_size); |
|---|
| 7452 | | - goto failed_template; |
|---|
| 7453 | | - } |
|---|
| 7454 | | - |
|---|
| 7455 | | - dcode = ha->fw_dump_template; |
|---|
| 7456 | | - risc_size = dlen / sizeof(*dcode); |
|---|
| 7457 | | - memcpy(dcode, qla27xx_fwdt_template_default(), dlen); |
|---|
| 7458 | | - for (i = 0; i < risc_size; i++) |
|---|
| 7459 | | - dcode[i] = be32_to_cpu(dcode[i]); |
|---|
| 7460 | | - |
|---|
| 7461 | | - if (!qla27xx_fwdt_template_valid(ha->fw_dump_template)) { |
|---|
| 7462 | | - ql_log(ql_log_warn, vha, 0x016b, |
|---|
| 7463 | | - "Failed fwdump template validate\n"); |
|---|
| 7464 | | - goto failed_template; |
|---|
| 7465 | | - } |
|---|
| 7466 | | - |
|---|
| 7467 | | - dlen = qla27xx_fwdt_template_size(ha->fw_dump_template); |
|---|
| 7468 | | - ql_dbg(ql_dbg_init, vha, 0x016c, |
|---|
| 7469 | | - "-> template size %x bytes\n", dlen); |
|---|
| 7470 | | - ha->fw_dump_template_len = dlen; |
|---|
| 7471 | | - return rval; |
|---|
| 7472 | | - |
|---|
| 7473 | | -failed_template: |
|---|
| 7474 | | - ql_log(ql_log_warn, vha, 0x016d, "Failed default fwdump template\n"); |
|---|
| 7475 | | - if (ha->fw_dump_template) |
|---|
| 7476 | | - vfree(ha->fw_dump_template); |
|---|
| 7477 | | - ha->fw_dump_template = NULL; |
|---|
| 7478 | | - ha->fw_dump_template_len = 0; |
|---|
| 7479 | | - return rval; |
|---|
| 8029 | + return QLA_SUCCESS; |
|---|
| 7480 | 8030 | } |
|---|
| 7481 | 8031 | |
|---|
| 7482 | 8032 | #define QLA_FW_URL "http://ldriver.qlogic.com/firmware/" |
|---|
| .. | .. |
|---|
| 7486 | 8036 | { |
|---|
| 7487 | 8037 | int rval; |
|---|
| 7488 | 8038 | int i, fragment; |
|---|
| 7489 | | - uint16_t *wcode, *fwcode; |
|---|
| 8039 | + uint16_t *wcode; |
|---|
| 8040 | + __be16 *fwcode; |
|---|
| 7490 | 8041 | uint32_t risc_addr, risc_size, fwclen, wlen, *seg; |
|---|
| 7491 | 8042 | struct fw_blob *blob; |
|---|
| 7492 | 8043 | struct qla_hw_data *ha = vha->hw; |
|---|
| .. | .. |
|---|
| 7506 | 8057 | |
|---|
| 7507 | 8058 | wcode = (uint16_t *)req->ring; |
|---|
| 7508 | 8059 | *srisc_addr = 0; |
|---|
| 7509 | | - fwcode = (uint16_t *)blob->fw->data; |
|---|
| 8060 | + fwcode = (__force __be16 *)blob->fw->data; |
|---|
| 7510 | 8061 | fwclen = 0; |
|---|
| 7511 | 8062 | |
|---|
| 7512 | 8063 | /* Validate firmware image by checking version. */ |
|---|
| .. | .. |
|---|
| 7554 | 8105 | "words 0x%x.\n", risc_addr, wlen); |
|---|
| 7555 | 8106 | |
|---|
| 7556 | 8107 | for (i = 0; i < wlen; i++) |
|---|
| 7557 | | - wcode[i] = swab16(fwcode[i]); |
|---|
| 8108 | + wcode[i] = swab16((__force u32)fwcode[i]); |
|---|
| 7558 | 8109 | |
|---|
| 7559 | 8110 | rval = qla2x00_load_ram(vha, req->dma, risc_addr, |
|---|
| 7560 | 8111 | wlen); |
|---|
| .. | .. |
|---|
| 7584 | 8135 | qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t *srisc_addr) |
|---|
| 7585 | 8136 | { |
|---|
| 7586 | 8137 | int rval; |
|---|
| 7587 | | - int segments, fragment; |
|---|
| 7588 | | - uint32_t *dcode, dlen; |
|---|
| 7589 | | - uint32_t risc_addr; |
|---|
| 7590 | | - uint32_t risc_size; |
|---|
| 7591 | | - uint32_t i; |
|---|
| 8138 | + uint templates, segments, fragment; |
|---|
| 8139 | + uint32_t *dcode; |
|---|
| 8140 | + ulong dlen; |
|---|
| 8141 | + uint32_t risc_addr, risc_size, risc_attr = 0; |
|---|
| 8142 | + ulong i; |
|---|
| 8143 | + uint j; |
|---|
| 7592 | 8144 | struct fw_blob *blob; |
|---|
| 7593 | | - const uint32_t *fwcode; |
|---|
| 7594 | | - uint32_t fwclen; |
|---|
| 8145 | + __be32 *fwcode; |
|---|
| 7595 | 8146 | struct qla_hw_data *ha = vha->hw; |
|---|
| 7596 | 8147 | struct req_que *req = ha->req_q_map[0]; |
|---|
| 8148 | + struct fwdt *fwdt = ha->fwdt; |
|---|
| 7597 | 8149 | |
|---|
| 7598 | | - /* Load firmware blob. */ |
|---|
| 8150 | + ql_dbg(ql_dbg_init, vha, 0x0090, |
|---|
| 8151 | + "-> FW: Loading via request-firmware.\n"); |
|---|
| 8152 | + |
|---|
| 7599 | 8153 | blob = qla2x00_request_firmware(vha); |
|---|
| 7600 | 8154 | if (!blob) { |
|---|
| 7601 | | - ql_log(ql_log_warn, vha, 0x0090, |
|---|
| 7602 | | - "Firmware image unavailable.\n"); |
|---|
| 7603 | | - ql_log(ql_log_warn, vha, 0x0091, |
|---|
| 7604 | | - "Firmware images can be retrieved from: " |
|---|
| 7605 | | - QLA_FW_URL ".\n"); |
|---|
| 8155 | + ql_log(ql_log_warn, vha, 0x0092, |
|---|
| 8156 | + "-> Firmware file not found.\n"); |
|---|
| 7606 | 8157 | |
|---|
| 7607 | 8158 | return QLA_FUNCTION_FAILED; |
|---|
| 7608 | 8159 | } |
|---|
| 7609 | 8160 | |
|---|
| 7610 | | - ql_dbg(ql_dbg_init, vha, 0x0092, |
|---|
| 7611 | | - "FW: Loading via request-firmware.\n"); |
|---|
| 7612 | | - |
|---|
| 7613 | | - rval = QLA_SUCCESS; |
|---|
| 7614 | | - |
|---|
| 7615 | | - segments = FA_RISC_CODE_SEGMENTS; |
|---|
| 7616 | | - dcode = (uint32_t *)req->ring; |
|---|
| 7617 | | - *srisc_addr = 0; |
|---|
| 7618 | | - fwcode = (uint32_t *)blob->fw->data; |
|---|
| 7619 | | - fwclen = 0; |
|---|
| 7620 | | - |
|---|
| 7621 | | - /* Validate firmware image by checking version. */ |
|---|
| 7622 | | - if (blob->fw->size < 8 * sizeof(uint32_t)) { |
|---|
| 8161 | + fwcode = (__force __be32 *)blob->fw->data; |
|---|
| 8162 | + dcode = (__force uint32_t *)fwcode; |
|---|
| 8163 | + if (qla24xx_risc_firmware_invalid(dcode)) { |
|---|
| 7623 | 8164 | ql_log(ql_log_fatal, vha, 0x0093, |
|---|
| 7624 | | - "Unable to verify integrity of firmware image (%zd).\n", |
|---|
| 7625 | | - blob->fw->size); |
|---|
| 7626 | | - return QLA_FUNCTION_FAILED; |
|---|
| 7627 | | - } |
|---|
| 7628 | | - for (i = 0; i < 4; i++) |
|---|
| 7629 | | - dcode[i] = be32_to_cpu(fwcode[i + 4]); |
|---|
| 7630 | | - if ((dcode[0] == 0xffffffff && dcode[1] == 0xffffffff && |
|---|
| 7631 | | - dcode[2] == 0xffffffff && dcode[3] == 0xffffffff) || |
|---|
| 7632 | | - (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 && |
|---|
| 7633 | | - dcode[3] == 0)) { |
|---|
| 7634 | | - ql_log(ql_log_fatal, vha, 0x0094, |
|---|
| 7635 | 8165 | "Unable to verify integrity of firmware image (%zd).\n", |
|---|
| 7636 | 8166 | blob->fw->size); |
|---|
| 7637 | 8167 | ql_log(ql_log_fatal, vha, 0x0095, |
|---|
| .. | .. |
|---|
| 7640 | 8170 | return QLA_FUNCTION_FAILED; |
|---|
| 7641 | 8171 | } |
|---|
| 7642 | 8172 | |
|---|
| 7643 | | - while (segments && rval == QLA_SUCCESS) { |
|---|
| 8173 | + dcode = (uint32_t *)req->ring; |
|---|
| 8174 | + *srisc_addr = 0; |
|---|
| 8175 | + segments = FA_RISC_CODE_SEGMENTS; |
|---|
| 8176 | + for (j = 0; j < segments; j++) { |
|---|
| 8177 | + ql_dbg(ql_dbg_init, vha, 0x0096, |
|---|
| 8178 | + "-> Loading segment %u...\n", j); |
|---|
| 7644 | 8179 | risc_addr = be32_to_cpu(fwcode[2]); |
|---|
| 7645 | | - *srisc_addr = *srisc_addr == 0 ? risc_addr : *srisc_addr; |
|---|
| 7646 | 8180 | risc_size = be32_to_cpu(fwcode[3]); |
|---|
| 7647 | 8181 | |
|---|
| 7648 | | - /* Validate firmware image size. */ |
|---|
| 7649 | | - fwclen += risc_size * sizeof(uint32_t); |
|---|
| 7650 | | - if (blob->fw->size < fwclen) { |
|---|
| 7651 | | - ql_log(ql_log_fatal, vha, 0x0096, |
|---|
| 7652 | | - "Unable to verify integrity of firmware image " |
|---|
| 7653 | | - "(%zd).\n", blob->fw->size); |
|---|
| 7654 | | - return QLA_FUNCTION_FAILED; |
|---|
| 8182 | + if (!*srisc_addr) { |
|---|
| 8183 | + *srisc_addr = risc_addr; |
|---|
| 8184 | + risc_attr = be32_to_cpu(fwcode[9]); |
|---|
| 7655 | 8185 | } |
|---|
| 7656 | 8186 | |
|---|
| 7657 | | - fragment = 0; |
|---|
| 7658 | | - while (risc_size > 0 && rval == QLA_SUCCESS) { |
|---|
| 7659 | | - dlen = (uint32_t)(ha->fw_transfer_size >> 2); |
|---|
| 8187 | + dlen = ha->fw_transfer_size >> 2; |
|---|
| 8188 | + for (fragment = 0; risc_size; fragment++) { |
|---|
| 7660 | 8189 | if (dlen > risc_size) |
|---|
| 7661 | 8190 | dlen = risc_size; |
|---|
| 7662 | 8191 | |
|---|
| 7663 | 8192 | ql_dbg(ql_dbg_init, vha, 0x0097, |
|---|
| 7664 | | - "Loading risc segment@ risc addr %x " |
|---|
| 7665 | | - "number of dwords 0x%x.\n", risc_addr, dlen); |
|---|
| 8193 | + "-> Loading fragment %u: %#x <- %#x (%#lx words)...\n", |
|---|
| 8194 | + fragment, risc_addr, |
|---|
| 8195 | + (uint32_t)(fwcode - (typeof(fwcode))blob->fw->data), |
|---|
| 8196 | + dlen); |
|---|
| 7666 | 8197 | |
|---|
| 7667 | 8198 | for (i = 0; i < dlen; i++) |
|---|
| 7668 | | - dcode[i] = swab32(fwcode[i]); |
|---|
| 8199 | + dcode[i] = swab32((__force u32)fwcode[i]); |
|---|
| 7669 | 8200 | |
|---|
| 7670 | | - rval = qla2x00_load_ram(vha, req->dma, risc_addr, |
|---|
| 7671 | | - dlen); |
|---|
| 8201 | + rval = qla2x00_load_ram(vha, req->dma, risc_addr, dlen); |
|---|
| 7672 | 8202 | if (rval) { |
|---|
| 7673 | 8203 | ql_log(ql_log_fatal, vha, 0x0098, |
|---|
| 7674 | | - "Failed to load segment %d of firmware.\n", |
|---|
| 8204 | + "-> Failed load firmware fragment %u.\n", |
|---|
| 7675 | 8205 | fragment); |
|---|
| 7676 | 8206 | return QLA_FUNCTION_FAILED; |
|---|
| 7677 | 8207 | } |
|---|
| .. | .. |
|---|
| 7679 | 8209 | fwcode += dlen; |
|---|
| 7680 | 8210 | risc_addr += dlen; |
|---|
| 7681 | 8211 | risc_size -= dlen; |
|---|
| 7682 | | - fragment++; |
|---|
| 8212 | + } |
|---|
| 8213 | + } |
|---|
| 8214 | + |
|---|
| 8215 | + if (!IS_QLA27XX(ha) && !IS_QLA28XX(ha)) |
|---|
| 8216 | + return QLA_SUCCESS; |
|---|
| 8217 | + |
|---|
| 8218 | + templates = (risc_attr & BIT_9) ? 2 : 1; |
|---|
| 8219 | + ql_dbg(ql_dbg_init, vha, 0x0170, "-> templates = %u\n", templates); |
|---|
| 8220 | + for (j = 0; j < templates; j++, fwdt++) { |
|---|
| 8221 | + if (fwdt->template) |
|---|
| 8222 | + vfree(fwdt->template); |
|---|
| 8223 | + fwdt->template = NULL; |
|---|
| 8224 | + fwdt->length = 0; |
|---|
| 8225 | + |
|---|
| 8226 | + risc_size = be32_to_cpu(fwcode[2]); |
|---|
| 8227 | + ql_dbg(ql_dbg_init, vha, 0x0171, |
|---|
| 8228 | + "-> fwdt%u template array at %#x (%#x dwords)\n", |
|---|
| 8229 | + j, (uint32_t)((void *)fwcode - (void *)blob->fw->data), |
|---|
| 8230 | + risc_size); |
|---|
| 8231 | + if (!risc_size || !~risc_size) { |
|---|
| 8232 | + ql_dbg(ql_dbg_init, vha, 0x0172, |
|---|
| 8233 | + "-> fwdt%u failed to read array\n", j); |
|---|
| 8234 | + goto failed; |
|---|
| 7683 | 8235 | } |
|---|
| 7684 | 8236 | |
|---|
| 7685 | | - /* Next segment. */ |
|---|
| 7686 | | - segments--; |
|---|
| 8237 | + /* skip header and ignore checksum */ |
|---|
| 8238 | + fwcode += 7; |
|---|
| 8239 | + risc_size -= 8; |
|---|
| 8240 | + |
|---|
| 8241 | + ql_dbg(ql_dbg_init, vha, 0x0173, |
|---|
| 8242 | + "-> fwdt%u template allocate template %#x words...\n", |
|---|
| 8243 | + j, risc_size); |
|---|
| 8244 | + fwdt->template = vmalloc(risc_size * sizeof(*dcode)); |
|---|
| 8245 | + if (!fwdt->template) { |
|---|
| 8246 | + ql_log(ql_log_warn, vha, 0x0174, |
|---|
| 8247 | + "-> fwdt%u failed allocate template.\n", j); |
|---|
| 8248 | + goto failed; |
|---|
| 8249 | + } |
|---|
| 8250 | + |
|---|
| 8251 | + dcode = fwdt->template; |
|---|
| 8252 | + for (i = 0; i < risc_size; i++) |
|---|
| 8253 | + dcode[i] = (__force u32)fwcode[i]; |
|---|
| 8254 | + |
|---|
| 8255 | + if (!qla27xx_fwdt_template_valid(dcode)) { |
|---|
| 8256 | + ql_log(ql_log_warn, vha, 0x0175, |
|---|
| 8257 | + "-> fwdt%u failed template validate\n", j); |
|---|
| 8258 | + goto failed; |
|---|
| 8259 | + } |
|---|
| 8260 | + |
|---|
| 8261 | + dlen = qla27xx_fwdt_template_size(dcode); |
|---|
| 8262 | + ql_dbg(ql_dbg_init, vha, 0x0176, |
|---|
| 8263 | + "-> fwdt%u template size %#lx bytes (%#lx words)\n", |
|---|
| 8264 | + j, dlen, dlen / sizeof(*dcode)); |
|---|
| 8265 | + if (dlen > risc_size * sizeof(*dcode)) { |
|---|
| 8266 | + ql_log(ql_log_warn, vha, 0x0177, |
|---|
| 8267 | + "-> fwdt%u template exceeds array (%-lu bytes)\n", |
|---|
| 8268 | + j, dlen - risc_size * sizeof(*dcode)); |
|---|
| 8269 | + goto failed; |
|---|
| 8270 | + } |
|---|
| 8271 | + |
|---|
| 8272 | + fwdt->length = dlen; |
|---|
| 8273 | + ql_dbg(ql_dbg_init, vha, 0x0178, |
|---|
| 8274 | + "-> fwdt%u loaded template ok\n", j); |
|---|
| 8275 | + |
|---|
| 8276 | + fwcode += risc_size + 1; |
|---|
| 7687 | 8277 | } |
|---|
| 7688 | 8278 | |
|---|
| 7689 | | - if (!IS_QLA27XX(ha)) |
|---|
| 7690 | | - return rval; |
|---|
| 8279 | + return QLA_SUCCESS; |
|---|
| 7691 | 8280 | |
|---|
| 7692 | | - if (ha->fw_dump_template) |
|---|
| 7693 | | - vfree(ha->fw_dump_template); |
|---|
| 7694 | | - ha->fw_dump_template = NULL; |
|---|
| 7695 | | - ha->fw_dump_template_len = 0; |
|---|
| 8281 | +failed: |
|---|
| 8282 | + if (fwdt->template) |
|---|
| 8283 | + vfree(fwdt->template); |
|---|
| 8284 | + fwdt->template = NULL; |
|---|
| 8285 | + fwdt->length = 0; |
|---|
| 7696 | 8286 | |
|---|
| 7697 | | - ql_dbg(ql_dbg_init, vha, 0x171, |
|---|
| 7698 | | - "Loading fwdump template from %x\n", |
|---|
| 7699 | | - (uint32_t)((void *)fwcode - (void *)blob->fw->data)); |
|---|
| 7700 | | - risc_size = be32_to_cpu(fwcode[2]); |
|---|
| 7701 | | - ql_dbg(ql_dbg_init, vha, 0x172, |
|---|
| 7702 | | - "-> array size %x dwords\n", risc_size); |
|---|
| 7703 | | - if (risc_size == 0 || risc_size == ~0) |
|---|
| 7704 | | - goto default_template; |
|---|
| 7705 | | - |
|---|
| 7706 | | - dlen = (risc_size - 8) * sizeof(*fwcode); |
|---|
| 7707 | | - ql_dbg(ql_dbg_init, vha, 0x0173, |
|---|
| 7708 | | - "-> template allocating %x bytes...\n", dlen); |
|---|
| 7709 | | - ha->fw_dump_template = vmalloc(dlen); |
|---|
| 7710 | | - if (!ha->fw_dump_template) { |
|---|
| 7711 | | - ql_log(ql_log_warn, vha, 0x0174, |
|---|
| 7712 | | - "Failed fwdump template allocate %x bytes.\n", risc_size); |
|---|
| 7713 | | - goto default_template; |
|---|
| 7714 | | - } |
|---|
| 7715 | | - |
|---|
| 7716 | | - fwcode += 7; |
|---|
| 7717 | | - risc_size -= 8; |
|---|
| 7718 | | - dcode = ha->fw_dump_template; |
|---|
| 7719 | | - for (i = 0; i < risc_size; i++) |
|---|
| 7720 | | - dcode[i] = le32_to_cpu(fwcode[i]); |
|---|
| 7721 | | - |
|---|
| 7722 | | - if (!qla27xx_fwdt_template_valid(dcode)) { |
|---|
| 7723 | | - ql_log(ql_log_warn, vha, 0x0175, |
|---|
| 7724 | | - "Failed fwdump template validate\n"); |
|---|
| 7725 | | - goto default_template; |
|---|
| 7726 | | - } |
|---|
| 7727 | | - |
|---|
| 7728 | | - dlen = qla27xx_fwdt_template_size(dcode); |
|---|
| 7729 | | - ql_dbg(ql_dbg_init, vha, 0x0176, |
|---|
| 7730 | | - "-> template size %x bytes\n", dlen); |
|---|
| 7731 | | - if (dlen > risc_size * sizeof(*fwcode)) { |
|---|
| 7732 | | - ql_log(ql_log_warn, vha, 0x0177, |
|---|
| 7733 | | - "Failed fwdump template exceeds array by %zx bytes\n", |
|---|
| 7734 | | - (size_t)(dlen - risc_size * sizeof(*fwcode))); |
|---|
| 7735 | | - goto default_template; |
|---|
| 7736 | | - } |
|---|
| 7737 | | - ha->fw_dump_template_len = dlen; |
|---|
| 7738 | | - return rval; |
|---|
| 7739 | | - |
|---|
| 7740 | | -default_template: |
|---|
| 7741 | | - ql_log(ql_log_warn, vha, 0x0178, "Using default fwdump template\n"); |
|---|
| 7742 | | - if (ha->fw_dump_template) |
|---|
| 7743 | | - vfree(ha->fw_dump_template); |
|---|
| 7744 | | - ha->fw_dump_template = NULL; |
|---|
| 7745 | | - ha->fw_dump_template_len = 0; |
|---|
| 7746 | | - |
|---|
| 7747 | | - dlen = qla27xx_fwdt_template_default_size(); |
|---|
| 7748 | | - ql_dbg(ql_dbg_init, vha, 0x0179, |
|---|
| 7749 | | - "-> template allocating %x bytes...\n", dlen); |
|---|
| 7750 | | - ha->fw_dump_template = vmalloc(dlen); |
|---|
| 7751 | | - if (!ha->fw_dump_template) { |
|---|
| 7752 | | - ql_log(ql_log_warn, vha, 0x017a, |
|---|
| 7753 | | - "Failed fwdump template allocate %x bytes.\n", risc_size); |
|---|
| 7754 | | - goto failed_template; |
|---|
| 7755 | | - } |
|---|
| 7756 | | - |
|---|
| 7757 | | - dcode = ha->fw_dump_template; |
|---|
| 7758 | | - risc_size = dlen / sizeof(*fwcode); |
|---|
| 7759 | | - fwcode = qla27xx_fwdt_template_default(); |
|---|
| 7760 | | - for (i = 0; i < risc_size; i++) |
|---|
| 7761 | | - dcode[i] = be32_to_cpu(fwcode[i]); |
|---|
| 7762 | | - |
|---|
| 7763 | | - if (!qla27xx_fwdt_template_valid(ha->fw_dump_template)) { |
|---|
| 7764 | | - ql_log(ql_log_warn, vha, 0x017b, |
|---|
| 7765 | | - "Failed fwdump template validate\n"); |
|---|
| 7766 | | - goto failed_template; |
|---|
| 7767 | | - } |
|---|
| 7768 | | - |
|---|
| 7769 | | - dlen = qla27xx_fwdt_template_size(ha->fw_dump_template); |
|---|
| 7770 | | - ql_dbg(ql_dbg_init, vha, 0x017c, |
|---|
| 7771 | | - "-> template size %x bytes\n", dlen); |
|---|
| 7772 | | - ha->fw_dump_template_len = dlen; |
|---|
| 7773 | | - return rval; |
|---|
| 7774 | | - |
|---|
| 7775 | | -failed_template: |
|---|
| 7776 | | - ql_log(ql_log_warn, vha, 0x017d, "Failed default fwdump template\n"); |
|---|
| 7777 | | - if (ha->fw_dump_template) |
|---|
| 7778 | | - vfree(ha->fw_dump_template); |
|---|
| 7779 | | - ha->fw_dump_template = NULL; |
|---|
| 7780 | | - ha->fw_dump_template_len = 0; |
|---|
| 7781 | | - return rval; |
|---|
| 8287 | + return QLA_SUCCESS; |
|---|
| 7782 | 8288 | } |
|---|
| 7783 | 8289 | |
|---|
| 7784 | 8290 | int |
|---|
| .. | .. |
|---|
| 7807 | 8313 | { |
|---|
| 7808 | 8314 | int rval; |
|---|
| 7809 | 8315 | struct qla_hw_data *ha = vha->hw; |
|---|
| 8316 | + struct active_regions active_regions = { }; |
|---|
| 7810 | 8317 | |
|---|
| 7811 | 8318 | if (ql2xfwloadbin == 2) |
|---|
| 7812 | 8319 | goto try_blob_fw; |
|---|
| 7813 | 8320 | |
|---|
| 7814 | | - /* |
|---|
| 7815 | | - * FW Load priority: |
|---|
| 8321 | + /* FW Load priority: |
|---|
| 7816 | 8322 | * 1) Firmware residing in flash. |
|---|
| 7817 | 8323 | * 2) Firmware via request-firmware interface (.bin file). |
|---|
| 7818 | | - * 3) Golden-Firmware residing in flash -- limited operation. |
|---|
| 8324 | + * 3) Golden-Firmware residing in flash -- (limited operation). |
|---|
| 7819 | 8325 | */ |
|---|
| 8326 | + |
|---|
| 8327 | + if (!IS_QLA27XX(ha) && !IS_QLA28XX(ha)) |
|---|
| 8328 | + goto try_primary_fw; |
|---|
| 8329 | + |
|---|
| 8330 | + qla27xx_get_active_image(vha, &active_regions); |
|---|
| 8331 | + |
|---|
| 8332 | + if (active_regions.global != QLA27XX_SECONDARY_IMAGE) |
|---|
| 8333 | + goto try_primary_fw; |
|---|
| 8334 | + |
|---|
| 8335 | + ql_dbg(ql_dbg_init, vha, 0x008b, |
|---|
| 8336 | + "Loading secondary firmware image.\n"); |
|---|
| 8337 | + rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_fw_sec); |
|---|
| 8338 | + if (!rval) |
|---|
| 8339 | + return rval; |
|---|
| 8340 | + |
|---|
| 8341 | +try_primary_fw: |
|---|
| 8342 | + ql_dbg(ql_dbg_init, vha, 0x008b, |
|---|
| 8343 | + "Loading primary firmware image.\n"); |
|---|
| 7820 | 8344 | rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_fw); |
|---|
| 7821 | | - if (rval == QLA_SUCCESS) |
|---|
| 8345 | + if (!rval) |
|---|
| 7822 | 8346 | return rval; |
|---|
| 7823 | 8347 | |
|---|
| 7824 | 8348 | try_blob_fw: |
|---|
| 7825 | 8349 | rval = qla24xx_load_risc_blob(vha, srisc_addr); |
|---|
| 7826 | | - if (rval == QLA_SUCCESS || !ha->flt_region_gold_fw) |
|---|
| 8350 | + if (!rval || !ha->flt_region_gold_fw) |
|---|
| 7827 | 8351 | return rval; |
|---|
| 7828 | 8352 | |
|---|
| 7829 | 8353 | ql_log(ql_log_info, vha, 0x0099, |
|---|
| 7830 | 8354 | "Attempting to fallback to golden firmware.\n"); |
|---|
| 7831 | 8355 | rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_gold_fw); |
|---|
| 7832 | | - if (rval != QLA_SUCCESS) |
|---|
| 8356 | + if (rval) |
|---|
| 7833 | 8357 | return rval; |
|---|
| 7834 | 8358 | |
|---|
| 7835 | | - ql_log(ql_log_info, vha, 0x009a, "Update operational firmware.\n"); |
|---|
| 8359 | + ql_log(ql_log_info, vha, 0x009a, "Need firmware flash update.\n"); |
|---|
| 7836 | 8360 | ha->flags.running_gold_fw = 1; |
|---|
| 7837 | 8361 | return rval; |
|---|
| 7838 | 8362 | } |
|---|
| .. | .. |
|---|
| 7877 | 8401 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
|---|
| 7878 | 8402 | struct qla_hw_data *ha = vha->hw; |
|---|
| 7879 | 8403 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
|---|
| 7880 | | - struct req_que *req; |
|---|
| 7881 | | - struct rsp_que *rsp; |
|---|
| 7882 | 8404 | |
|---|
| 7883 | 8405 | if (!vha->vp_idx) |
|---|
| 7884 | 8406 | return -EINVAL; |
|---|
| 7885 | 8407 | |
|---|
| 7886 | 8408 | rval = qla2x00_fw_ready(base_vha); |
|---|
| 7887 | | - if (vha->qpair) |
|---|
| 7888 | | - req = vha->qpair->req; |
|---|
| 7889 | | - else |
|---|
| 7890 | | - req = ha->req_q_map[0]; |
|---|
| 7891 | | - rsp = req->rsp; |
|---|
| 7892 | 8409 | |
|---|
| 7893 | 8410 | if (rval == QLA_SUCCESS) { |
|---|
| 7894 | 8411 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
|---|
| 7895 | | - qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL); |
|---|
| 8412 | + qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL); |
|---|
| 7896 | 8413 | } |
|---|
| 7897 | 8414 | |
|---|
| 7898 | 8415 | vha->flags.management_server_logged_in = 0; |
|---|
| .. | .. |
|---|
| 7974 | 8491 | qla84xx_put_chip(struct scsi_qla_host *vha) |
|---|
| 7975 | 8492 | { |
|---|
| 7976 | 8493 | struct qla_hw_data *ha = vha->hw; |
|---|
| 8494 | + |
|---|
| 7977 | 8495 | if (ha->cs84xx) |
|---|
| 7978 | 8496 | kref_put(&ha->cs84xx->kref, __qla84xx_chip_release); |
|---|
| 7979 | 8497 | } |
|---|
| .. | .. |
|---|
| 7991 | 8509 | |
|---|
| 7992 | 8510 | mutex_unlock(&ha->cs84xx->fw_update_mutex); |
|---|
| 7993 | 8511 | |
|---|
| 7994 | | - return rval != QLA_SUCCESS || status[0] ? QLA_FUNCTION_FAILED: |
|---|
| 8512 | + return rval != QLA_SUCCESS || status[0] ? QLA_FUNCTION_FAILED : |
|---|
| 7995 | 8513 | QLA_SUCCESS; |
|---|
| 7996 | 8514 | } |
|---|
| 7997 | 8515 | |
|---|
| .. | .. |
|---|
| 8003 | 8521 | int rval; |
|---|
| 8004 | 8522 | struct init_cb_81xx *icb; |
|---|
| 8005 | 8523 | struct nvram_81xx *nv; |
|---|
| 8006 | | - uint32_t *dptr; |
|---|
| 8524 | + __le32 *dptr; |
|---|
| 8007 | 8525 | uint8_t *dptr1, *dptr2; |
|---|
| 8008 | 8526 | uint32_t chksum; |
|---|
| 8009 | 8527 | uint16_t cnt; |
|---|
| 8010 | 8528 | struct qla_hw_data *ha = vha->hw; |
|---|
| 8529 | + uint32_t faddr; |
|---|
| 8530 | + struct active_regions active_regions = { }; |
|---|
| 8011 | 8531 | |
|---|
| 8012 | 8532 | rval = QLA_SUCCESS; |
|---|
| 8013 | 8533 | icb = (struct init_cb_81xx *)ha->init_cb; |
|---|
| 8014 | 8534 | nv = ha->nvram; |
|---|
| 8015 | 8535 | |
|---|
| 8016 | 8536 | /* Determine NVRAM starting address. */ |
|---|
| 8017 | | - ha->nvram_size = sizeof(struct nvram_81xx); |
|---|
| 8537 | + ha->nvram_size = sizeof(*nv); |
|---|
| 8018 | 8538 | ha->vpd_size = FA_NVRAM_VPD_SIZE; |
|---|
| 8019 | 8539 | if (IS_P3P_TYPE(ha) || IS_QLA8031(ha)) |
|---|
| 8020 | 8540 | ha->vpd_size = FA_VPD_SIZE_82XX; |
|---|
| 8021 | 8541 | |
|---|
| 8542 | + if (IS_QLA28XX(ha) || IS_QLA27XX(ha)) |
|---|
| 8543 | + qla28xx_get_aux_images(vha, &active_regions); |
|---|
| 8544 | + |
|---|
| 8022 | 8545 | /* Get VPD data into cache */ |
|---|
| 8023 | 8546 | ha->vpd = ha->nvram + VPD_OFFSET; |
|---|
| 8024 | | - ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_vpd << 2, |
|---|
| 8025 | | - ha->vpd_size); |
|---|
| 8547 | + |
|---|
| 8548 | + faddr = ha->flt_region_vpd; |
|---|
| 8549 | + if (IS_QLA28XX(ha)) { |
|---|
| 8550 | + if (active_regions.aux.vpd_nvram == QLA27XX_SECONDARY_IMAGE) |
|---|
| 8551 | + faddr = ha->flt_region_vpd_sec; |
|---|
| 8552 | + ql_dbg(ql_dbg_init, vha, 0x0110, |
|---|
| 8553 | + "Loading %s nvram image.\n", |
|---|
| 8554 | + active_regions.aux.vpd_nvram == QLA27XX_PRIMARY_IMAGE ? |
|---|
| 8555 | + "primary" : "secondary"); |
|---|
| 8556 | + } |
|---|
| 8557 | + ha->isp_ops->read_optrom(vha, ha->vpd, faddr << 2, ha->vpd_size); |
|---|
| 8026 | 8558 | |
|---|
| 8027 | 8559 | /* Get NVRAM data into cache and calculate checksum. */ |
|---|
| 8028 | | - ha->isp_ops->read_optrom(vha, ha->nvram, ha->flt_region_nvram << 2, |
|---|
| 8029 | | - ha->nvram_size); |
|---|
| 8030 | | - dptr = (uint32_t *)nv; |
|---|
| 8560 | + faddr = ha->flt_region_nvram; |
|---|
| 8561 | + if (IS_QLA28XX(ha)) { |
|---|
| 8562 | + if (active_regions.aux.vpd_nvram == QLA27XX_SECONDARY_IMAGE) |
|---|
| 8563 | + faddr = ha->flt_region_nvram_sec; |
|---|
| 8564 | + } |
|---|
| 8565 | + ql_dbg(ql_dbg_init, vha, 0x0110, |
|---|
| 8566 | + "Loading %s nvram image.\n", |
|---|
| 8567 | + active_regions.aux.vpd_nvram == QLA27XX_PRIMARY_IMAGE ? |
|---|
| 8568 | + "primary" : "secondary"); |
|---|
| 8569 | + ha->isp_ops->read_optrom(vha, ha->nvram, faddr << 2, ha->nvram_size); |
|---|
| 8570 | + |
|---|
| 8571 | + dptr = (__force __le32 *)nv; |
|---|
| 8031 | 8572 | for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++, dptr++) |
|---|
| 8032 | 8573 | chksum += le32_to_cpu(*dptr); |
|---|
| 8033 | 8574 | |
|---|
| 8034 | 8575 | ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x0111, |
|---|
| 8035 | 8576 | "Contents of NVRAM:\n"); |
|---|
| 8036 | 8577 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0112, |
|---|
| 8037 | | - (uint8_t *)nv, ha->nvram_size); |
|---|
| 8578 | + nv, ha->nvram_size); |
|---|
| 8038 | 8579 | |
|---|
| 8039 | 8580 | /* Bad NVRAM data, set defaults parameters. */ |
|---|
| 8040 | | - if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P' |
|---|
| 8041 | | - || nv->id[3] != ' ' || |
|---|
| 8042 | | - nv->nvram_version < cpu_to_le16(ICB_VERSION)) { |
|---|
| 8581 | + if (chksum || memcmp("ISP ", nv->id, sizeof(nv->id)) || |
|---|
| 8582 | + le16_to_cpu(nv->nvram_version) < ICB_VERSION) { |
|---|
| 8043 | 8583 | /* Reset NVRAM data. */ |
|---|
| 8044 | 8584 | ql_log(ql_log_info, vha, 0x0073, |
|---|
| 8045 | | - "Inconsistent NVRAM detected: checksum=0x%x id=%c " |
|---|
| 8046 | | - "version=0x%x.\n", chksum, nv->id[0], |
|---|
| 8047 | | - le16_to_cpu(nv->nvram_version)); |
|---|
| 8585 | + "Inconsistent NVRAM checksum=%#x id=%.4s version=%#x.\n", |
|---|
| 8586 | + chksum, nv->id, le16_to_cpu(nv->nvram_version)); |
|---|
| 8587 | + ql_dump_buffer(ql_dbg_init, vha, 0x0073, nv, sizeof(*nv)); |
|---|
| 8048 | 8588 | ql_log(ql_log_info, vha, 0x0074, |
|---|
| 8049 | 8589 | "Falling back to functioning (yet invalid -- WWPN) " |
|---|
| 8050 | 8590 | "defaults.\n"); |
|---|
| .. | .. |
|---|
| 8055 | 8595 | memset(nv, 0, ha->nvram_size); |
|---|
| 8056 | 8596 | nv->nvram_version = cpu_to_le16(ICB_VERSION); |
|---|
| 8057 | 8597 | nv->version = cpu_to_le16(ICB_VERSION); |
|---|
| 8058 | | - nv->frame_payload_size = 2048; |
|---|
| 8598 | + nv->frame_payload_size = cpu_to_le16(2048); |
|---|
| 8059 | 8599 | nv->execution_throttle = cpu_to_le16(0xFFFF); |
|---|
| 8060 | 8600 | nv->exchange_count = cpu_to_le16(0); |
|---|
| 8061 | 8601 | nv->port_name[0] = 0x21; |
|---|
| .. | .. |
|---|
| 8099 | 8639 | } |
|---|
| 8100 | 8640 | |
|---|
| 8101 | 8641 | if (IS_T10_PI_CAPABLE(ha)) |
|---|
| 8102 | | - nv->frame_payload_size &= ~7; |
|---|
| 8642 | + nv->frame_payload_size &= cpu_to_le16(~7); |
|---|
| 8103 | 8643 | |
|---|
| 8104 | 8644 | qlt_81xx_config_nvram_stage1(vha, nv); |
|---|
| 8105 | 8645 | |
|---|
| .. | .. |
|---|
| 8161 | 8701 | icb->node_name[0] &= 0xF0; |
|---|
| 8162 | 8702 | } |
|---|
| 8163 | 8703 | |
|---|
| 8704 | + if (IS_QLA28XX(ha) || IS_QLA27XX(ha)) { |
|---|
| 8705 | + if ((nv->enhanced_features & BIT_7) == 0) |
|---|
| 8706 | + ha->flags.scm_supported_a = 1; |
|---|
| 8707 | + } |
|---|
| 8708 | + |
|---|
| 8164 | 8709 | /* Set host adapter parameters. */ |
|---|
| 8165 | 8710 | ha->flags.disable_risc_code_load = 0; |
|---|
| 8166 | 8711 | ha->flags.enable_lip_reset = 0; |
|---|
| 8167 | 8712 | ha->flags.enable_lip_full_login = |
|---|
| 8168 | | - le32_to_cpu(nv->host_p) & BIT_10 ? 1: 0; |
|---|
| 8713 | + le32_to_cpu(nv->host_p) & BIT_10 ? 1 : 0; |
|---|
| 8169 | 8714 | ha->flags.enable_target_reset = |
|---|
| 8170 | | - le32_to_cpu(nv->host_p) & BIT_11 ? 1: 0; |
|---|
| 8715 | + le32_to_cpu(nv->host_p) & BIT_11 ? 1 : 0; |
|---|
| 8171 | 8716 | ha->flags.enable_led_scheme = 0; |
|---|
| 8172 | | - ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1: 0; |
|---|
| 8717 | + ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1 : 0; |
|---|
| 8173 | 8718 | |
|---|
| 8174 | 8719 | ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) & |
|---|
| 8175 | 8720 | (BIT_6 | BIT_5 | BIT_4)) >> 4; |
|---|
| .. | .. |
|---|
| 8233 | 8778 | ha->login_retry_count = ql2xloginretrycount; |
|---|
| 8234 | 8779 | |
|---|
| 8235 | 8780 | /* if not running MSI-X we need handshaking on interrupts */ |
|---|
| 8236 | | - if (!vha->hw->flags.msix_enabled && (IS_QLA83XX(ha) || IS_QLA27XX(ha))) |
|---|
| 8781 | + if (!vha->hw->flags.msix_enabled && |
|---|
| 8782 | + (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))) |
|---|
| 8237 | 8783 | icb->firmware_options_2 |= cpu_to_le32(BIT_22); |
|---|
| 8238 | 8784 | |
|---|
| 8239 | 8785 | /* Enable ZIO. */ |
|---|
| .. | .. |
|---|
| 8241 | 8787 | ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & |
|---|
| 8242 | 8788 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
|---|
| 8243 | 8789 | ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? |
|---|
| 8244 | | - le16_to_cpu(icb->interrupt_delay_timer): 2; |
|---|
| 8790 | + le16_to_cpu(icb->interrupt_delay_timer) : 2; |
|---|
| 8245 | 8791 | } |
|---|
| 8246 | 8792 | icb->firmware_options_2 &= cpu_to_le32( |
|---|
| 8247 | 8793 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0)); |
|---|
| .. | .. |
|---|
| 8261 | 8807 | } |
|---|
| 8262 | 8808 | |
|---|
| 8263 | 8809 | /* enable RIDA Format2 */ |
|---|
| 8264 | | - icb->firmware_options_3 |= BIT_0; |
|---|
| 8810 | + icb->firmware_options_3 |= cpu_to_le32(BIT_0); |
|---|
| 8265 | 8811 | |
|---|
| 8266 | 8812 | /* N2N: driver will initiate Login instead of FW */ |
|---|
| 8267 | | - icb->firmware_options_3 |= BIT_8; |
|---|
| 8813 | + icb->firmware_options_3 |= cpu_to_le32(BIT_8); |
|---|
| 8268 | 8814 | |
|---|
| 8269 | | - if (IS_QLA27XX(ha)) { |
|---|
| 8270 | | - icb->firmware_options_3 |= BIT_8; |
|---|
| 8271 | | - ql_dbg(ql_log_info, vha, 0x0075, |
|---|
| 8272 | | - "Enabling direct connection.\n"); |
|---|
| 8273 | | - } |
|---|
| 8815 | + /* Determine NVMe/FCP priority for target ports */ |
|---|
| 8816 | + ha->fc4_type_priority = qla2xxx_get_fc4_priority(vha); |
|---|
| 8274 | 8817 | |
|---|
| 8275 | 8818 | if (rval) { |
|---|
| 8276 | 8819 | ql_log(ql_log_warn, vha, 0x0076, |
|---|
| .. | .. |
|---|
| 8284 | 8827 | { |
|---|
| 8285 | 8828 | int status, rval; |
|---|
| 8286 | 8829 | struct qla_hw_data *ha = vha->hw; |
|---|
| 8287 | | - struct req_que *req = ha->req_q_map[0]; |
|---|
| 8288 | | - struct rsp_que *rsp = ha->rsp_q_map[0]; |
|---|
| 8289 | 8830 | struct scsi_qla_host *vp; |
|---|
| 8290 | 8831 | unsigned long flags; |
|---|
| 8291 | 8832 | |
|---|
| .. | .. |
|---|
| 8297 | 8838 | status = qla2x00_fw_ready(vha); |
|---|
| 8298 | 8839 | if (!status) { |
|---|
| 8299 | 8840 | /* Issue a marker after FW becomes ready. */ |
|---|
| 8300 | | - qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL); |
|---|
| 8841 | + qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL); |
|---|
| 8301 | 8842 | vha->flags.online = 1; |
|---|
| 8302 | 8843 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
|---|
| 8303 | 8844 | } |
|---|
| .. | .. |
|---|
| 8377 | 8918 | } |
|---|
| 8378 | 8919 | |
|---|
| 8379 | 8920 | return status; |
|---|
| 8380 | | -} |
|---|
| 8381 | | - |
|---|
| 8382 | | -void |
|---|
| 8383 | | -qla81xx_update_fw_options(scsi_qla_host_t *vha) |
|---|
| 8384 | | -{ |
|---|
| 8385 | | - struct qla_hw_data *ha = vha->hw; |
|---|
| 8386 | | - |
|---|
| 8387 | | - /* Hold status IOCBs until ABTS response received. */ |
|---|
| 8388 | | - if (ql2xfwholdabts) |
|---|
| 8389 | | - ha->fw_options[3] |= BIT_12; |
|---|
| 8390 | | - |
|---|
| 8391 | | - /* Set Retry FLOGI in case of P2P connection */ |
|---|
| 8392 | | - if (ha->operating_mode == P2P) { |
|---|
| 8393 | | - ha->fw_options[2] |= BIT_3; |
|---|
| 8394 | | - ql_dbg(ql_dbg_disc, vha, 0x2103, |
|---|
| 8395 | | - "(%s): Setting FLOGI retry BIT in fw_options[2]: 0x%x\n", |
|---|
| 8396 | | - __func__, ha->fw_options[2]); |
|---|
| 8397 | | - } |
|---|
| 8398 | | - |
|---|
| 8399 | | - /* Move PUREX, ABTS RX & RIDA to ATIOQ */ |
|---|
| 8400 | | - if (ql2xmvasynctoatio) { |
|---|
| 8401 | | - if (qla_tgt_mode_enabled(vha) || |
|---|
| 8402 | | - qla_dual_mode_enabled(vha)) |
|---|
| 8403 | | - ha->fw_options[2] |= BIT_11; |
|---|
| 8404 | | - else |
|---|
| 8405 | | - ha->fw_options[2] &= ~BIT_11; |
|---|
| 8406 | | - } |
|---|
| 8407 | | - |
|---|
| 8408 | | - if (qla_tgt_mode_enabled(vha) || |
|---|
| 8409 | | - qla_dual_mode_enabled(vha)) { |
|---|
| 8410 | | - /* FW auto send SCSI status during */ |
|---|
| 8411 | | - ha->fw_options[1] |= BIT_8; |
|---|
| 8412 | | - ha->fw_options[10] |= (u16)SAM_STAT_BUSY << 8; |
|---|
| 8413 | | - |
|---|
| 8414 | | - /* FW perform Exchange validation */ |
|---|
| 8415 | | - ha->fw_options[2] |= BIT_4; |
|---|
| 8416 | | - } else { |
|---|
| 8417 | | - ha->fw_options[1] &= ~BIT_8; |
|---|
| 8418 | | - ha->fw_options[10] &= 0x00ff; |
|---|
| 8419 | | - |
|---|
| 8420 | | - ha->fw_options[2] &= ~BIT_4; |
|---|
| 8421 | | - } |
|---|
| 8422 | | - |
|---|
| 8423 | | - if (ql2xetsenable) { |
|---|
| 8424 | | - /* Enable ETS Burst. */ |
|---|
| 8425 | | - memset(ha->fw_options, 0, sizeof(ha->fw_options)); |
|---|
| 8426 | | - ha->fw_options[2] |= BIT_9; |
|---|
| 8427 | | - } |
|---|
| 8428 | | - |
|---|
| 8429 | | - ql_dbg(ql_dbg_init, vha, 0x00e9, |
|---|
| 8430 | | - "%s, add FW options 1-3 = 0x%04x 0x%04x 0x%04x mode %x\n", |
|---|
| 8431 | | - __func__, ha->fw_options[1], ha->fw_options[2], |
|---|
| 8432 | | - ha->fw_options[3], vha->host->active_mode); |
|---|
| 8433 | | - |
|---|
| 8434 | | - qla2x00_set_fw_options(vha, ha->fw_options); |
|---|
| 8435 | 8921 | } |
|---|
| 8436 | 8922 | |
|---|
| 8437 | 8923 | /* |
|---|
| .. | .. |
|---|
| 8634 | 9120 | "Failed to allocate memory for queue pair.\n"); |
|---|
| 8635 | 9121 | return NULL; |
|---|
| 8636 | 9122 | } |
|---|
| 8637 | | - memset(qpair, 0, sizeof(struct qla_qpair)); |
|---|
| 8638 | 9123 | |
|---|
| 8639 | 9124 | qpair->hw = vha->hw; |
|---|
| 8640 | 9125 | qpair->vha = vha; |
|---|
| .. | .. |
|---|
| 8681 | 9166 | qpair->msix->in_use = 1; |
|---|
| 8682 | 9167 | list_add_tail(&qpair->qp_list_elem, &vha->qp_list); |
|---|
| 8683 | 9168 | qpair->pdev = ha->pdev; |
|---|
| 8684 | | - if (IS_QLA27XX(ha) || IS_QLA83XX(ha)) |
|---|
| 9169 | + if (IS_QLA27XX(ha) || IS_QLA83XX(ha) || IS_QLA28XX(ha)) |
|---|
| 8685 | 9170 | qpair->reqq_start_iocbs = qla_83xx_start_iocbs; |
|---|
| 8686 | 9171 | |
|---|
| 8687 | 9172 | mutex_unlock(&ha->mq_lock); |
|---|
| .. | .. |
|---|
| 8709 | 9194 | qpair->rsp->req = qpair->req; |
|---|
| 8710 | 9195 | qpair->rsp->qpair = qpair; |
|---|
| 8711 | 9196 | /* init qpair to this cpu. Will adjust at run time. */ |
|---|
| 8712 | | - qla_cpu_update(qpair, smp_processor_id()); |
|---|
| 9197 | + qla_cpu_update(qpair, raw_smp_processor_id()); |
|---|
| 8713 | 9198 | |
|---|
| 8714 | 9199 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
|---|
| 8715 | 9200 | if (ha->fw_attributes & BIT_4) |
|---|