Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 2 | * QLogic Fibre Channel HBA Driver |
Andrew Vasquez | 07e264b | 2011-03-30 11:46:23 -0700 | [diff] [blame] | 3 | * Copyright (c) 2003-2011 QLogic Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | #include "qla_def.h" |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 8 | #include "qla_gbl.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
| 10 | #include <linux/delay.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 11 | #include <linux/slab.h> |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 12 | #include <linux/vmalloc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | #include "qla_devtbl.h" |
| 15 | |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 16 | #ifdef CONFIG_SPARC |
| 17 | #include <asm/prom.h> |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 18 | #endif |
| 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | /* |
| 21 | * QLogic ISP2x00 Hardware Support Function Prototypes. |
| 22 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | static int qla2x00_isp_firmware(scsi_qla_host_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | static int qla2x00_setup_chip(scsi_qla_host_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | static int qla2x00_init_rings(scsi_qla_host_t *); |
| 26 | static int qla2x00_fw_ready(scsi_qla_host_t *); |
| 27 | static int qla2x00_configure_hba(scsi_qla_host_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | static int qla2x00_configure_loop(scsi_qla_host_t *); |
| 29 | static int qla2x00_configure_local_loop(scsi_qla_host_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | static int qla2x00_configure_fabric(scsi_qla_host_t *); |
| 31 | static int qla2x00_find_all_fabric_devs(scsi_qla_host_t *, struct list_head *); |
| 32 | static int qla2x00_device_resync(scsi_qla_host_t *); |
| 33 | static int qla2x00_fabric_dev_login(scsi_qla_host_t *, fc_port_t *, |
| 34 | uint16_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
| 36 | static int qla2x00_restart_isp(scsi_qla_host_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 38 | static struct qla_chip_state_84xx *qla84xx_get_chip(struct scsi_qla_host *); |
| 39 | static int qla84xx_init_chip(scsi_qla_host_t *); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 40 | static int qla25xx_init_queues(struct qla_hw_data *); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 41 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 42 | /* SRB Extensions ---------------------------------------------------------- */ |
| 43 | |
| 44 | static void |
| 45 | qla2x00_ctx_sp_timeout(unsigned long __data) |
| 46 | { |
| 47 | srb_t *sp = (srb_t *)__data; |
| 48 | struct srb_ctx *ctx; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 49 | struct srb_iocb *iocb; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 50 | fc_port_t *fcport = sp->fcport; |
| 51 | struct qla_hw_data *ha = fcport->vha->hw; |
| 52 | struct req_que *req; |
| 53 | unsigned long flags; |
| 54 | |
| 55 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 56 | req = ha->req_q_map[0]; |
| 57 | req->outstanding_cmds[sp->handle] = NULL; |
| 58 | ctx = sp->ctx; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 59 | iocb = ctx->u.iocb_cmd; |
| 60 | iocb->timeout(sp); |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 61 | iocb->free(sp); |
Andrew Vasquez | 6ac5260 | 2010-05-28 15:08:19 -0700 | [diff] [blame] | 62 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 63 | } |
| 64 | |
Andrew Vasquez | 3dbe756 | 2010-07-23 15:28:37 +0500 | [diff] [blame] | 65 | static void |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 66 | qla2x00_ctx_sp_free(srb_t *sp) |
| 67 | { |
| 68 | struct srb_ctx *ctx = sp->ctx; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 69 | struct srb_iocb *iocb = ctx->u.iocb_cmd; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 70 | struct scsi_qla_host *vha = sp->fcport->vha; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 71 | |
Chad Dupuis | 4d97cc5 | 2010-10-15 11:27:41 -0700 | [diff] [blame] | 72 | del_timer(&iocb->timer); |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 73 | kfree(iocb); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 74 | kfree(ctx); |
| 75 | mempool_free(sp, sp->fcport->vha->hw->srb_mempool); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 76 | |
| 77 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | inline srb_t * |
| 81 | qla2x00_get_ctx_sp(scsi_qla_host_t *vha, fc_port_t *fcport, size_t size, |
| 82 | unsigned long tmo) |
| 83 | { |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 84 | srb_t *sp = NULL; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 85 | struct qla_hw_data *ha = vha->hw; |
| 86 | struct srb_ctx *ctx; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 87 | struct srb_iocb *iocb; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 88 | uint8_t bail; |
| 89 | |
| 90 | QLA_VHA_MARK_BUSY(vha, bail); |
| 91 | if (bail) |
| 92 | return NULL; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 93 | |
| 94 | sp = mempool_alloc(ha->srb_mempool, GFP_KERNEL); |
| 95 | if (!sp) |
| 96 | goto done; |
| 97 | ctx = kzalloc(size, GFP_KERNEL); |
| 98 | if (!ctx) { |
| 99 | mempool_free(sp, ha->srb_mempool); |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 100 | sp = NULL; |
| 101 | goto done; |
| 102 | } |
| 103 | iocb = kzalloc(sizeof(struct srb_iocb), GFP_KERNEL); |
| 104 | if (!iocb) { |
| 105 | mempool_free(sp, ha->srb_mempool); |
| 106 | sp = NULL; |
| 107 | kfree(ctx); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 108 | goto done; |
| 109 | } |
| 110 | |
| 111 | memset(sp, 0, sizeof(*sp)); |
| 112 | sp->fcport = fcport; |
| 113 | sp->ctx = ctx; |
Andrew Vasquez | 5780790 | 2011-11-18 09:03:20 -0800 | [diff] [blame] | 114 | ctx->iocbs = 1; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 115 | ctx->u.iocb_cmd = iocb; |
| 116 | iocb->free = qla2x00_ctx_sp_free; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 117 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 118 | init_timer(&iocb->timer); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 119 | if (!tmo) |
| 120 | goto done; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 121 | iocb->timer.expires = jiffies + tmo * HZ; |
| 122 | iocb->timer.data = (unsigned long)sp; |
| 123 | iocb->timer.function = qla2x00_ctx_sp_timeout; |
| 124 | add_timer(&iocb->timer); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 125 | done: |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 126 | if (!sp) |
| 127 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 128 | return sp; |
| 129 | } |
| 130 | |
| 131 | /* Asynchronous Login/Logout Routines -------------------------------------- */ |
| 132 | |
Andrew Vasquez | 5b91490 | 2010-05-28 15:08:30 -0700 | [diff] [blame] | 133 | static inline unsigned long |
| 134 | qla2x00_get_async_timeout(struct scsi_qla_host *vha) |
| 135 | { |
| 136 | unsigned long tmo; |
| 137 | struct qla_hw_data *ha = vha->hw; |
| 138 | |
| 139 | /* Firmware should use switch negotiated r_a_tov for timeout. */ |
| 140 | tmo = ha->r_a_tov / 10 * 2; |
| 141 | if (!IS_FWI2_CAPABLE(ha)) { |
| 142 | /* |
| 143 | * Except for earlier ISPs where the timeout is seeded from the |
| 144 | * initialization control block. |
| 145 | */ |
| 146 | tmo = ha->login_timeout; |
| 147 | } |
| 148 | return tmo; |
| 149 | } |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 150 | |
| 151 | static void |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 152 | qla2x00_async_iocb_timeout(srb_t *sp) |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 153 | { |
| 154 | fc_port_t *fcport = sp->fcport; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 155 | struct srb_ctx *ctx = sp->ctx; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 156 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 157 | ql_dbg(ql_dbg_disc, fcport->vha, 0x2071, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 158 | "Async-%s timeout - hdl=%x portid=%02x%02x%02x.\n", |
| 159 | ctx->name, sp->handle, fcport->d_id.b.domain, fcport->d_id.b.area, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 160 | fcport->d_id.b.al_pa); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 161 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 162 | fcport->flags &= ~FCF_ASYNC_SENT; |
Andrew Vasquez | 6ac5260 | 2010-05-28 15:08:19 -0700 | [diff] [blame] | 163 | if (ctx->type == SRB_LOGIN_CMD) { |
| 164 | struct srb_iocb *lio = ctx->u.iocb_cmd; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 165 | qla2x00_post_async_logout_work(fcport->vha, fcport, NULL); |
Andrew Vasquez | 6ac5260 | 2010-05-28 15:08:19 -0700 | [diff] [blame] | 166 | /* Retry as needed. */ |
| 167 | lio->u.logio.data[0] = MBS_COMMAND_ERROR; |
| 168 | lio->u.logio.data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? |
| 169 | QLA_LOGIO_LOGIN_RETRIED : 0; |
| 170 | qla2x00_post_async_login_done_work(fcport->vha, fcport, |
| 171 | lio->u.logio.data); |
| 172 | } |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 173 | } |
| 174 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 175 | static void |
| 176 | qla2x00_async_login_ctx_done(srb_t *sp) |
| 177 | { |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 178 | struct srb_ctx *ctx = sp->ctx; |
| 179 | struct srb_iocb *lio = ctx->u.iocb_cmd; |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 180 | |
| 181 | qla2x00_post_async_login_done_work(sp->fcport->vha, sp->fcport, |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 182 | lio->u.logio.data); |
| 183 | lio->free(sp); |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 184 | } |
| 185 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 186 | int |
| 187 | qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 188 | uint16_t *data) |
| 189 | { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 190 | srb_t *sp; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 191 | struct srb_ctx *ctx; |
| 192 | struct srb_iocb *lio; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 193 | int rval; |
| 194 | |
| 195 | rval = QLA_FUNCTION_FAILED; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 196 | sp = qla2x00_get_ctx_sp(vha, fcport, sizeof(struct srb_ctx), |
Andrew Vasquez | 5b91490 | 2010-05-28 15:08:30 -0700 | [diff] [blame] | 197 | qla2x00_get_async_timeout(vha) + 2); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 198 | if (!sp) |
| 199 | goto done; |
| 200 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 201 | ctx = sp->ctx; |
| 202 | ctx->type = SRB_LOGIN_CMD; |
| 203 | ctx->name = "login"; |
| 204 | lio = ctx->u.iocb_cmd; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 205 | lio->timeout = qla2x00_async_iocb_timeout; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 206 | lio->done = qla2x00_async_login_ctx_done; |
| 207 | lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 208 | if (data[1] & QLA_LOGIO_LOGIN_RETRIED) |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 209 | lio->u.logio.flags |= SRB_LOGIN_RETRIED; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 210 | rval = qla2x00_start_sp(sp); |
| 211 | if (rval != QLA_SUCCESS) |
| 212 | goto done_free_sp; |
| 213 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 214 | ql_dbg(ql_dbg_disc, vha, 0x2072, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 215 | "Async-login - hdl=%x, loopid=%x portid=%02x%02x%02x " |
| 216 | "retries=%d.\n", sp->handle, fcport->loop_id, |
| 217 | fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa, |
| 218 | fcport->login_retry); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 219 | return rval; |
| 220 | |
| 221 | done_free_sp: |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 222 | lio->free(sp); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 223 | done: |
| 224 | return rval; |
| 225 | } |
| 226 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 227 | static void |
| 228 | qla2x00_async_logout_ctx_done(srb_t *sp) |
| 229 | { |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 230 | struct srb_ctx *ctx = sp->ctx; |
| 231 | struct srb_iocb *lio = ctx->u.iocb_cmd; |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 232 | |
| 233 | qla2x00_post_async_logout_done_work(sp->fcport->vha, sp->fcport, |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 234 | lio->u.logio.data); |
| 235 | lio->free(sp); |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 236 | } |
| 237 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 238 | int |
| 239 | qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport) |
| 240 | { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 241 | srb_t *sp; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 242 | struct srb_ctx *ctx; |
| 243 | struct srb_iocb *lio; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 244 | int rval; |
| 245 | |
| 246 | rval = QLA_FUNCTION_FAILED; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 247 | sp = qla2x00_get_ctx_sp(vha, fcport, sizeof(struct srb_ctx), |
Andrew Vasquez | 5b91490 | 2010-05-28 15:08:30 -0700 | [diff] [blame] | 248 | qla2x00_get_async_timeout(vha) + 2); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 249 | if (!sp) |
| 250 | goto done; |
| 251 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 252 | ctx = sp->ctx; |
| 253 | ctx->type = SRB_LOGOUT_CMD; |
| 254 | ctx->name = "logout"; |
| 255 | lio = ctx->u.iocb_cmd; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 256 | lio->timeout = qla2x00_async_iocb_timeout; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 257 | lio->done = qla2x00_async_logout_ctx_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 258 | rval = qla2x00_start_sp(sp); |
| 259 | if (rval != QLA_SUCCESS) |
| 260 | goto done_free_sp; |
| 261 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 262 | ql_dbg(ql_dbg_disc, vha, 0x2070, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 263 | "Async-logout - hdl=%x loop-id=%x portid=%02x%02x%02x.\n", |
| 264 | sp->handle, fcport->loop_id, fcport->d_id.b.domain, |
| 265 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 266 | return rval; |
| 267 | |
| 268 | done_free_sp: |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 269 | lio->free(sp); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 270 | done: |
| 271 | return rval; |
| 272 | } |
| 273 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 274 | static void |
| 275 | qla2x00_async_adisc_ctx_done(srb_t *sp) |
| 276 | { |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 277 | struct srb_ctx *ctx = sp->ctx; |
| 278 | struct srb_iocb *lio = ctx->u.iocb_cmd; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 279 | |
| 280 | qla2x00_post_async_adisc_done_work(sp->fcport->vha, sp->fcport, |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 281 | lio->u.logio.data); |
| 282 | lio->free(sp); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | int |
| 286 | qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 287 | uint16_t *data) |
| 288 | { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 289 | srb_t *sp; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 290 | struct srb_ctx *ctx; |
| 291 | struct srb_iocb *lio; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 292 | int rval; |
| 293 | |
| 294 | rval = QLA_FUNCTION_FAILED; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 295 | sp = qla2x00_get_ctx_sp(vha, fcport, sizeof(struct srb_ctx), |
Andrew Vasquez | 5b91490 | 2010-05-28 15:08:30 -0700 | [diff] [blame] | 296 | qla2x00_get_async_timeout(vha) + 2); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 297 | if (!sp) |
| 298 | goto done; |
| 299 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 300 | ctx = sp->ctx; |
| 301 | ctx->type = SRB_ADISC_CMD; |
| 302 | ctx->name = "adisc"; |
| 303 | lio = ctx->u.iocb_cmd; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 304 | lio->timeout = qla2x00_async_iocb_timeout; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 305 | lio->done = qla2x00_async_adisc_ctx_done; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 306 | if (data[1] & QLA_LOGIO_LOGIN_RETRIED) |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 307 | lio->u.logio.flags |= SRB_LOGIN_RETRIED; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 308 | rval = qla2x00_start_sp(sp); |
| 309 | if (rval != QLA_SUCCESS) |
| 310 | goto done_free_sp; |
| 311 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 312 | ql_dbg(ql_dbg_disc, vha, 0x206f, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 313 | "Async-adisc - hdl=%x loopid=%x portid=%02x%02x%02x.\n", |
| 314 | sp->handle, fcport->loop_id, fcport->d_id.b.domain, |
| 315 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 316 | return rval; |
| 317 | |
| 318 | done_free_sp: |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 319 | lio->free(sp); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 320 | done: |
| 321 | return rval; |
| 322 | } |
| 323 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 324 | static void |
| 325 | qla2x00_async_tm_cmd_ctx_done(srb_t *sp) |
| 326 | { |
| 327 | struct srb_ctx *ctx = sp->ctx; |
| 328 | struct srb_iocb *iocb = (struct srb_iocb *)ctx->u.iocb_cmd; |
| 329 | |
| 330 | qla2x00_async_tm_cmd_done(sp->fcport->vha, sp->fcport, iocb); |
| 331 | iocb->free(sp); |
| 332 | } |
| 333 | |
| 334 | int |
| 335 | qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint32_t lun, |
| 336 | uint32_t tag) |
| 337 | { |
| 338 | struct scsi_qla_host *vha = fcport->vha; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 339 | srb_t *sp; |
| 340 | struct srb_ctx *ctx; |
| 341 | struct srb_iocb *tcf; |
| 342 | int rval; |
| 343 | |
| 344 | rval = QLA_FUNCTION_FAILED; |
| 345 | sp = qla2x00_get_ctx_sp(vha, fcport, sizeof(struct srb_ctx), |
Andrew Vasquez | 5b91490 | 2010-05-28 15:08:30 -0700 | [diff] [blame] | 346 | qla2x00_get_async_timeout(vha) + 2); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 347 | if (!sp) |
| 348 | goto done; |
| 349 | |
| 350 | ctx = sp->ctx; |
| 351 | ctx->type = SRB_TM_CMD; |
| 352 | ctx->name = "tmf"; |
| 353 | tcf = ctx->u.iocb_cmd; |
| 354 | tcf->u.tmf.flags = flags; |
| 355 | tcf->u.tmf.lun = lun; |
| 356 | tcf->u.tmf.data = tag; |
| 357 | tcf->timeout = qla2x00_async_iocb_timeout; |
| 358 | tcf->done = qla2x00_async_tm_cmd_ctx_done; |
| 359 | |
| 360 | rval = qla2x00_start_sp(sp); |
| 361 | if (rval != QLA_SUCCESS) |
| 362 | goto done_free_sp; |
| 363 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 364 | ql_dbg(ql_dbg_taskm, vha, 0x802f, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 365 | "Async-tmf hdl=%x loop-id=%x portid=%02x%02x%02x.\n", |
| 366 | sp->handle, fcport->loop_id, fcport->d_id.b.domain, |
| 367 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 368 | return rval; |
| 369 | |
| 370 | done_free_sp: |
| 371 | tcf->free(sp); |
| 372 | done: |
| 373 | return rval; |
| 374 | } |
| 375 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 376 | void |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 377 | qla2x00_async_login_done(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 378 | uint16_t *data) |
| 379 | { |
| 380 | int rval; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 381 | |
| 382 | switch (data[0]) { |
| 383 | case MBS_COMMAND_COMPLETE: |
Andrew Vasquez | a4f92a3 | 2011-03-30 11:46:31 -0700 | [diff] [blame] | 384 | /* |
| 385 | * Driver must validate login state - If PRLI not complete, |
| 386 | * force a relogin attempt via implicit LOGO, PLOGI, and PRLI |
| 387 | * requests. |
| 388 | */ |
| 389 | rval = qla2x00_get_port_database(vha, fcport, 0); |
| 390 | if (rval != QLA_SUCCESS) { |
| 391 | qla2x00_post_async_logout_work(vha, fcport, NULL); |
| 392 | qla2x00_post_async_login_work(vha, fcport, NULL); |
| 393 | break; |
| 394 | } |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 395 | if (fcport->flags & FCF_FCP2_DEVICE) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 396 | qla2x00_post_async_adisc_work(vha, fcport, data); |
| 397 | break; |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 398 | } |
| 399 | qla2x00_update_fcport(vha, fcport); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 400 | break; |
| 401 | case MBS_COMMAND_ERROR: |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 402 | fcport->flags &= ~FCF_ASYNC_SENT; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 403 | if (data[1] & QLA_LOGIO_LOGIN_RETRIED) |
| 404 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 405 | else |
Andrew Vasquez | 80d7944 | 2011-03-30 11:46:17 -0700 | [diff] [blame] | 406 | qla2x00_mark_device_lost(vha, fcport, 1, 0); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 407 | break; |
| 408 | case MBS_PORT_ID_USED: |
| 409 | fcport->loop_id = data[1]; |
Andrew Vasquez | 6ac5260 | 2010-05-28 15:08:19 -0700 | [diff] [blame] | 410 | qla2x00_post_async_logout_work(vha, fcport, NULL); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 411 | qla2x00_post_async_login_work(vha, fcport, NULL); |
| 412 | break; |
| 413 | case MBS_LOOP_ID_USED: |
| 414 | fcport->loop_id++; |
| 415 | rval = qla2x00_find_new_loop_id(vha, fcport); |
| 416 | if (rval != QLA_SUCCESS) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 417 | fcport->flags &= ~FCF_ASYNC_SENT; |
Andrew Vasquez | 80d7944 | 2011-03-30 11:46:17 -0700 | [diff] [blame] | 418 | qla2x00_mark_device_lost(vha, fcport, 1, 0); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 419 | break; |
| 420 | } |
| 421 | qla2x00_post_async_login_work(vha, fcport, NULL); |
| 422 | break; |
| 423 | } |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 424 | return; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 425 | } |
| 426 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 427 | void |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 428 | qla2x00_async_logout_done(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 429 | uint16_t *data) |
| 430 | { |
| 431 | qla2x00_mark_device_lost(vha, fcport, 1, 0); |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 432 | return; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 433 | } |
| 434 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 435 | void |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 436 | qla2x00_async_adisc_done(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 437 | uint16_t *data) |
| 438 | { |
| 439 | if (data[0] == MBS_COMMAND_COMPLETE) { |
| 440 | qla2x00_update_fcport(vha, fcport); |
| 441 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 442 | return; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | /* Retry login. */ |
| 446 | fcport->flags &= ~FCF_ASYNC_SENT; |
| 447 | if (data[1] & QLA_LOGIO_LOGIN_RETRIED) |
| 448 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 449 | else |
Andrew Vasquez | 80d7944 | 2011-03-30 11:46:17 -0700 | [diff] [blame] | 450 | qla2x00_mark_device_lost(vha, fcport, 1, 0); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 451 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 452 | return; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 453 | } |
| 454 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 455 | void |
| 456 | qla2x00_async_tm_cmd_done(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 457 | struct srb_iocb *iocb) |
| 458 | { |
| 459 | int rval; |
| 460 | uint32_t flags; |
| 461 | uint16_t lun; |
| 462 | |
| 463 | flags = iocb->u.tmf.flags; |
| 464 | lun = (uint16_t)iocb->u.tmf.lun; |
| 465 | |
| 466 | /* Issue Marker IOCB */ |
Giridhar Malavali | d94d10e | 2010-07-23 15:28:23 +0500 | [diff] [blame] | 467 | rval = qla2x00_marker(vha, vha->hw->req_q_map[0], |
| 468 | vha->hw->rsp_q_map[0], fcport->loop_id, lun, |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 469 | flags == TCF_LUN_RESET ? MK_SYNC_ID_LUN : MK_SYNC_ID); |
| 470 | |
| 471 | if ((rval != QLA_SUCCESS) || iocb->u.tmf.data) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 472 | ql_dbg(ql_dbg_taskm, vha, 0x8030, |
| 473 | "TM IOCB failed (%x).\n", rval); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | return; |
| 477 | } |
| 478 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | /****************************************************************************/ |
| 480 | /* QLogic ISP2x00 Hardware Support Functions. */ |
| 481 | /****************************************************************************/ |
| 482 | |
| 483 | /* |
| 484 | * qla2x00_initialize_adapter |
| 485 | * Initialize board. |
| 486 | * |
| 487 | * Input: |
| 488 | * ha = adapter block pointer. |
| 489 | * |
| 490 | * Returns: |
| 491 | * 0 = success |
| 492 | */ |
| 493 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 494 | qla2x00_initialize_adapter(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | { |
| 496 | int rval; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 497 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 498 | struct req_que *req = ha->req_q_map[0]; |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 499 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | /* Clear adapter flags. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 501 | vha->flags.online = 0; |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 502 | ha->flags.chip_reset_done = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 503 | vha->flags.reset_active = 0; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 504 | ha->flags.pci_channel_io_perm_failure = 0; |
| 505 | ha->flags.eeh_busy = 0; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 506 | ha->flags.thermal_supported = 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 507 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 508 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 509 | vha->device_flags = DFLG_NO_CABLE; |
| 510 | vha->dpc_flags = 0; |
| 511 | vha->flags.management_server_logged_in = 0; |
| 512 | vha->marker_needed = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | ha->isp_abort_cnt = 0; |
| 514 | ha->beacon_blink_led = 0; |
| 515 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 516 | set_bit(0, ha->req_qid_map); |
| 517 | set_bit(0, ha->rsp_qid_map); |
| 518 | |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 519 | ql_dbg(ql_dbg_init, vha, 0x0040, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 520 | "Configuring PCI space...\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 521 | rval = ha->isp_ops->pci_config(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 523 | ql_log(ql_log_warn, vha, 0x0044, |
| 524 | "Unable to configure PCI space.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | return (rval); |
| 526 | } |
| 527 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 528 | ha->isp_ops->reset_chip(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 530 | rval = qla2xxx_get_flash_info(vha); |
Andrew Vasquez | c00d899 | 2008-09-11 21:22:49 -0700 | [diff] [blame] | 531 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 532 | ql_log(ql_log_fatal, vha, 0x004f, |
| 533 | "Unable to validate FLASH data.\n"); |
Andrew Vasquez | c00d899 | 2008-09-11 21:22:49 -0700 | [diff] [blame] | 534 | return (rval); |
| 535 | } |
| 536 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 537 | ha->isp_ops->get_flash_version(vha, req->ring); |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 538 | ql_dbg(ql_dbg_init, vha, 0x0061, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 539 | "Configure NVRAM parameters...\n"); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 540 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 541 | ha->isp_ops->nvram_config(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | |
Andrew Vasquez | d4c760c | 2006-06-23 16:10:39 -0700 | [diff] [blame] | 543 | if (ha->flags.disable_serdes) { |
| 544 | /* Mask HBA via NVRAM settings? */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 545 | ql_log(ql_log_info, vha, 0x0077, |
| 546 | "Masking HBA WWPN " |
Andrew Vasquez | d4c760c | 2006-06-23 16:10:39 -0700 | [diff] [blame] | 547 | "%02x%02x%02x%02x%02x%02x%02x%02x (via NVRAM).\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 548 | vha->port_name[0], vha->port_name[1], |
| 549 | vha->port_name[2], vha->port_name[3], |
| 550 | vha->port_name[4], vha->port_name[5], |
| 551 | vha->port_name[6], vha->port_name[7]); |
Andrew Vasquez | d4c760c | 2006-06-23 16:10:39 -0700 | [diff] [blame] | 552 | return QLA_FUNCTION_FAILED; |
| 553 | } |
| 554 | |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 555 | ql_dbg(ql_dbg_init, vha, 0x0078, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 556 | "Verifying loaded RISC code...\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 558 | if (qla2x00_isp_firmware(vha) != QLA_SUCCESS) { |
| 559 | rval = ha->isp_ops->chip_diag(vha); |
Andrew Vasquez | d19044c | 2006-11-22 08:22:19 -0800 | [diff] [blame] | 560 | if (rval) |
| 561 | return (rval); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 562 | rval = qla2x00_setup_chip(vha); |
Andrew Vasquez | d19044c | 2006-11-22 08:22:19 -0800 | [diff] [blame] | 563 | if (rval) |
| 564 | return (rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 566 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 567 | if (IS_QLA84XX(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 568 | ha->cs84xx = qla84xx_get_chip(vha); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 569 | if (!ha->cs84xx) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 570 | ql_log(ql_log_warn, vha, 0x00d0, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 571 | "Unable to configure ISP84XX.\n"); |
| 572 | return QLA_FUNCTION_FAILED; |
| 573 | } |
| 574 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 575 | rval = qla2x00_init_rings(vha); |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 576 | ha->flags.chip_reset_done = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 578 | if (rval == QLA_SUCCESS && IS_QLA84XX(ha)) { |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 579 | /* Issue verify 84xx FW IOCB to complete 84xx initialization */ |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 580 | rval = qla84xx_init_chip(vha); |
| 581 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 582 | ql_log(ql_log_warn, vha, 0x00d4, |
| 583 | "Unable to initialize ISP84XX.\n"); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 584 | qla84xx_put_chip(vha); |
| 585 | } |
| 586 | } |
| 587 | |
Madhuranath Iyengar | 2f0f3f4 | 2010-07-23 15:28:24 +0500 | [diff] [blame] | 588 | if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha)) |
| 589 | qla24xx_read_fcp_prio_cfg(vha); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 590 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | return (rval); |
| 592 | } |
| 593 | |
| 594 | /** |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 595 | * qla2100_pci_config() - Setup ISP21xx PCI configuration registers. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | * @ha: HA context |
| 597 | * |
| 598 | * Returns 0 on success. |
| 599 | */ |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 600 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 601 | qla2100_pci_config(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | { |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 603 | uint16_t w; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 604 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 605 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 606 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | pci_set_master(ha->pdev); |
Andrew Vasquez | af6177d | 2007-07-19 15:06:02 -0700 | [diff] [blame] | 609 | pci_try_set_mwi(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | pci_read_config_word(ha->pdev, PCI_COMMAND, &w); |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 612 | w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | pci_write_config_word(ha->pdev, PCI_COMMAND, w); |
| 614 | |
Andrew Vasquez | 737faec | 2008-10-24 15:13:45 -0700 | [diff] [blame] | 615 | pci_disable_rom(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 617 | /* Get PCI bus information. */ |
| 618 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 619 | ha->pci_attr = RD_REG_WORD(®->ctrl_status); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 620 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 621 | |
| 622 | return QLA_SUCCESS; |
| 623 | } |
| 624 | |
| 625 | /** |
| 626 | * qla2300_pci_config() - Setup ISP23xx PCI configuration registers. |
| 627 | * @ha: HA context |
| 628 | * |
| 629 | * Returns 0 on success. |
| 630 | */ |
| 631 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 632 | qla2300_pci_config(scsi_qla_host_t *vha) |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 633 | { |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 634 | uint16_t w; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 635 | unsigned long flags = 0; |
| 636 | uint32_t cnt; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 637 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 638 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 639 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 640 | pci_set_master(ha->pdev); |
Andrew Vasquez | af6177d | 2007-07-19 15:06:02 -0700 | [diff] [blame] | 641 | pci_try_set_mwi(ha->pdev); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 642 | |
| 643 | pci_read_config_word(ha->pdev, PCI_COMMAND, &w); |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 644 | w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 645 | |
| 646 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 647 | w &= ~PCI_COMMAND_INTX_DISABLE; |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 648 | pci_write_config_word(ha->pdev, PCI_COMMAND, w); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 649 | |
| 650 | /* |
| 651 | * If this is a 2300 card and not 2312, reset the |
| 652 | * COMMAND_INVALIDATE due to a bug in the 2300. Unfortunately, |
| 653 | * the 2310 also reports itself as a 2300 so we need to get the |
| 654 | * fb revision level -- a 6 indicates it really is a 2300 and |
| 655 | * not a 2310. |
| 656 | */ |
| 657 | if (IS_QLA2300(ha)) { |
| 658 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 659 | |
| 660 | /* Pause RISC. */ |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 661 | WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 662 | for (cnt = 0; cnt < 30000; cnt++) { |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 663 | if ((RD_REG_WORD(®->hccr) & HCCR_RISC_PAUSE) != 0) |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 664 | break; |
| 665 | |
| 666 | udelay(10); |
| 667 | } |
| 668 | |
| 669 | /* Select FPM registers. */ |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 670 | WRT_REG_WORD(®->ctrl_status, 0x20); |
| 671 | RD_REG_WORD(®->ctrl_status); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 672 | |
| 673 | /* Get the fb rev level */ |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 674 | ha->fb_rev = RD_FB_CMD_REG(ha, reg); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 675 | |
| 676 | if (ha->fb_rev == FPM_2300) |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 677 | pci_clear_mwi(ha->pdev); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 678 | |
| 679 | /* Deselect FPM registers. */ |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 680 | WRT_REG_WORD(®->ctrl_status, 0x0); |
| 681 | RD_REG_WORD(®->ctrl_status); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 682 | |
| 683 | /* Release RISC module. */ |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 684 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 685 | for (cnt = 0; cnt < 30000; cnt++) { |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 686 | if ((RD_REG_WORD(®->hccr) & HCCR_RISC_PAUSE) == 0) |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 687 | break; |
| 688 | |
| 689 | udelay(10); |
| 690 | } |
| 691 | |
| 692 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 693 | } |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 694 | |
| 695 | pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); |
| 696 | |
Andrew Vasquez | 737faec | 2008-10-24 15:13:45 -0700 | [diff] [blame] | 697 | pci_disable_rom(ha->pdev); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 698 | |
| 699 | /* Get PCI bus information. */ |
| 700 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 701 | ha->pci_attr = RD_REG_WORD(®->ctrl_status); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 702 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 703 | |
| 704 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | /** |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 708 | * qla24xx_pci_config() - Setup ISP24xx PCI configuration registers. |
| 709 | * @ha: HA context |
| 710 | * |
| 711 | * Returns 0 on success. |
| 712 | */ |
| 713 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 714 | qla24xx_pci_config(scsi_qla_host_t *vha) |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 715 | { |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 716 | uint16_t w; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 717 | unsigned long flags = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 718 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 719 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 720 | |
| 721 | pci_set_master(ha->pdev); |
Andrew Vasquez | af6177d | 2007-07-19 15:06:02 -0700 | [diff] [blame] | 722 | pci_try_set_mwi(ha->pdev); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 723 | |
| 724 | pci_read_config_word(ha->pdev, PCI_COMMAND, &w); |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 725 | w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 726 | w &= ~PCI_COMMAND_INTX_DISABLE; |
| 727 | pci_write_config_word(ha->pdev, PCI_COMMAND, w); |
| 728 | |
| 729 | pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); |
| 730 | |
| 731 | /* PCI-X -- adjust Maximum Memory Read Byte Count (2048). */ |
Andrew Vasquez | f85ec18 | 2007-07-19 15:06:01 -0700 | [diff] [blame] | 732 | if (pci_find_capability(ha->pdev, PCI_CAP_ID_PCIX)) |
| 733 | pcix_set_mmrbc(ha->pdev, 2048); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 734 | |
| 735 | /* PCIe -- adjust Maximum Read Request Size (2048). */ |
Andrew Vasquez | f85ec18 | 2007-07-19 15:06:01 -0700 | [diff] [blame] | 736 | if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP)) |
| 737 | pcie_set_readrq(ha->pdev, 2048); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 738 | |
Andrew Vasquez | 737faec | 2008-10-24 15:13:45 -0700 | [diff] [blame] | 739 | pci_disable_rom(ha->pdev); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 740 | |
Auke Kok | 44c1013 | 2007-06-08 15:46:36 -0700 | [diff] [blame] | 741 | ha->chip_revision = ha->pdev->revision; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 742 | |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 743 | /* Get PCI bus information. */ |
| 744 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 745 | ha->pci_attr = RD_REG_DWORD(®->ctrl_status); |
| 746 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 747 | |
| 748 | return QLA_SUCCESS; |
| 749 | } |
| 750 | |
| 751 | /** |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 752 | * qla25xx_pci_config() - Setup ISP25xx PCI configuration registers. |
| 753 | * @ha: HA context |
| 754 | * |
| 755 | * Returns 0 on success. |
| 756 | */ |
| 757 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 758 | qla25xx_pci_config(scsi_qla_host_t *vha) |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 759 | { |
| 760 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 761 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 762 | |
| 763 | pci_set_master(ha->pdev); |
| 764 | pci_try_set_mwi(ha->pdev); |
| 765 | |
| 766 | pci_read_config_word(ha->pdev, PCI_COMMAND, &w); |
| 767 | w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); |
| 768 | w &= ~PCI_COMMAND_INTX_DISABLE; |
| 769 | pci_write_config_word(ha->pdev, PCI_COMMAND, w); |
| 770 | |
| 771 | /* PCIe -- adjust Maximum Read Request Size (2048). */ |
| 772 | if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP)) |
| 773 | pcie_set_readrq(ha->pdev, 2048); |
| 774 | |
Andrew Vasquez | 737faec | 2008-10-24 15:13:45 -0700 | [diff] [blame] | 775 | pci_disable_rom(ha->pdev); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 776 | |
| 777 | ha->chip_revision = ha->pdev->revision; |
| 778 | |
| 779 | return QLA_SUCCESS; |
| 780 | } |
| 781 | |
| 782 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | * qla2x00_isp_firmware() - Choose firmware image. |
| 784 | * @ha: HA context |
| 785 | * |
| 786 | * Returns 0 on success. |
| 787 | */ |
| 788 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 789 | qla2x00_isp_firmware(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | { |
| 791 | int rval; |
Andrew Vasquez | 42e421b | 2008-07-10 16:56:01 -0700 | [diff] [blame] | 792 | uint16_t loop_id, topo, sw_cap; |
| 793 | uint8_t domain, area, al_pa; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 794 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 795 | |
| 796 | /* Assume loading risc code */ |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 797 | rval = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 798 | |
| 799 | if (ha->flags.disable_risc_code_load) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 800 | ql_log(ql_log_info, vha, 0x0079, "RISC CODE NOT loaded.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | |
| 802 | /* Verify checksum of loaded RISC code. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 803 | rval = qla2x00_verify_checksum(vha, ha->fw_srisc_address); |
Andrew Vasquez | 42e421b | 2008-07-10 16:56:01 -0700 | [diff] [blame] | 804 | if (rval == QLA_SUCCESS) { |
| 805 | /* And, verify we are not in ROM code. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 806 | rval = qla2x00_get_adapter_id(vha, &loop_id, &al_pa, |
Andrew Vasquez | 42e421b | 2008-07-10 16:56:01 -0700 | [diff] [blame] | 807 | &area, &domain, &topo, &sw_cap); |
| 808 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | } |
| 810 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 811 | if (rval) |
| 812 | ql_dbg(ql_dbg_init, vha, 0x007a, |
| 813 | "**** Load RISC code ****.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 814 | |
| 815 | return (rval); |
| 816 | } |
| 817 | |
| 818 | /** |
| 819 | * qla2x00_reset_chip() - Reset ISP chip. |
| 820 | * @ha: HA context |
| 821 | * |
| 822 | * Returns 0 on success. |
| 823 | */ |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 824 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 825 | qla2x00_reset_chip(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | { |
| 827 | unsigned long flags = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 828 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 829 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | uint32_t cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | uint16_t cmd; |
| 832 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 833 | if (unlikely(pci_channel_offline(ha->pdev))) |
| 834 | return; |
| 835 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 836 | ha->isp_ops->disable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 837 | |
| 838 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 839 | |
| 840 | /* Turn off master enable */ |
| 841 | cmd = 0; |
| 842 | pci_read_config_word(ha->pdev, PCI_COMMAND, &cmd); |
| 843 | cmd &= ~PCI_COMMAND_MASTER; |
| 844 | pci_write_config_word(ha->pdev, PCI_COMMAND, cmd); |
| 845 | |
| 846 | if (!IS_QLA2100(ha)) { |
| 847 | /* Pause RISC. */ |
| 848 | WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC); |
| 849 | if (IS_QLA2200(ha) || IS_QLA2300(ha)) { |
| 850 | for (cnt = 0; cnt < 30000; cnt++) { |
| 851 | if ((RD_REG_WORD(®->hccr) & |
| 852 | HCCR_RISC_PAUSE) != 0) |
| 853 | break; |
| 854 | udelay(100); |
| 855 | } |
| 856 | } else { |
| 857 | RD_REG_WORD(®->hccr); /* PCI Posting. */ |
| 858 | udelay(10); |
| 859 | } |
| 860 | |
| 861 | /* Select FPM registers. */ |
| 862 | WRT_REG_WORD(®->ctrl_status, 0x20); |
| 863 | RD_REG_WORD(®->ctrl_status); /* PCI Posting. */ |
| 864 | |
| 865 | /* FPM Soft Reset. */ |
| 866 | WRT_REG_WORD(®->fpm_diag_config, 0x100); |
| 867 | RD_REG_WORD(®->fpm_diag_config); /* PCI Posting. */ |
| 868 | |
| 869 | /* Toggle Fpm Reset. */ |
| 870 | if (!IS_QLA2200(ha)) { |
| 871 | WRT_REG_WORD(®->fpm_diag_config, 0x0); |
| 872 | RD_REG_WORD(®->fpm_diag_config); /* PCI Posting. */ |
| 873 | } |
| 874 | |
| 875 | /* Select frame buffer registers. */ |
| 876 | WRT_REG_WORD(®->ctrl_status, 0x10); |
| 877 | RD_REG_WORD(®->ctrl_status); /* PCI Posting. */ |
| 878 | |
| 879 | /* Reset frame buffer FIFOs. */ |
| 880 | if (IS_QLA2200(ha)) { |
| 881 | WRT_FB_CMD_REG(ha, reg, 0xa000); |
| 882 | RD_FB_CMD_REG(ha, reg); /* PCI Posting. */ |
| 883 | } else { |
| 884 | WRT_FB_CMD_REG(ha, reg, 0x00fc); |
| 885 | |
| 886 | /* Read back fb_cmd until zero or 3 seconds max */ |
| 887 | for (cnt = 0; cnt < 3000; cnt++) { |
| 888 | if ((RD_FB_CMD_REG(ha, reg) & 0xff) == 0) |
| 889 | break; |
| 890 | udelay(100); |
| 891 | } |
| 892 | } |
| 893 | |
| 894 | /* Select RISC module registers. */ |
| 895 | WRT_REG_WORD(®->ctrl_status, 0); |
| 896 | RD_REG_WORD(®->ctrl_status); /* PCI Posting. */ |
| 897 | |
| 898 | /* Reset RISC processor. */ |
| 899 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 900 | RD_REG_WORD(®->hccr); /* PCI Posting. */ |
| 901 | |
| 902 | /* Release RISC processor. */ |
| 903 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
| 904 | RD_REG_WORD(®->hccr); /* PCI Posting. */ |
| 905 | } |
| 906 | |
| 907 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 908 | WRT_REG_WORD(®->hccr, HCCR_CLR_HOST_INT); |
| 909 | |
| 910 | /* Reset ISP chip. */ |
| 911 | WRT_REG_WORD(®->ctrl_status, CSR_ISP_SOFT_RESET); |
| 912 | |
| 913 | /* Wait for RISC to recover from reset. */ |
| 914 | if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) { |
| 915 | /* |
| 916 | * It is necessary to for a delay here since the card doesn't |
| 917 | * respond to PCI reads during a reset. On some architectures |
| 918 | * this will result in an MCA. |
| 919 | */ |
| 920 | udelay(20); |
| 921 | for (cnt = 30000; cnt; cnt--) { |
| 922 | if ((RD_REG_WORD(®->ctrl_status) & |
| 923 | CSR_ISP_SOFT_RESET) == 0) |
| 924 | break; |
| 925 | udelay(100); |
| 926 | } |
| 927 | } else |
| 928 | udelay(10); |
| 929 | |
| 930 | /* Reset RISC processor. */ |
| 931 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 932 | |
| 933 | WRT_REG_WORD(®->semaphore, 0); |
| 934 | |
| 935 | /* Release RISC processor. */ |
| 936 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
| 937 | RD_REG_WORD(®->hccr); /* PCI Posting. */ |
| 938 | |
| 939 | if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) { |
| 940 | for (cnt = 0; cnt < 30000; cnt++) { |
Andrew Vasquez | ffb39f0 | 2006-05-17 15:09:06 -0700 | [diff] [blame] | 941 | if (RD_MAILBOX_REG(ha, reg, 0) != MBS_BUSY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 942 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | |
| 944 | udelay(100); |
| 945 | } |
| 946 | } else |
| 947 | udelay(100); |
| 948 | |
| 949 | /* Turn on master enable */ |
| 950 | cmd |= PCI_COMMAND_MASTER; |
| 951 | pci_write_config_word(ha->pdev, PCI_COMMAND, cmd); |
| 952 | |
| 953 | /* Disable RISC pause on FPM parity error. */ |
| 954 | if (!IS_QLA2100(ha)) { |
| 955 | WRT_REG_WORD(®->hccr, HCCR_DISABLE_PARITY_PAUSE); |
| 956 | RD_REG_WORD(®->hccr); /* PCI Posting. */ |
| 957 | } |
| 958 | |
| 959 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 960 | } |
| 961 | |
| 962 | /** |
Madhuranath Iyengar | b1d4698 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 963 | * qla81xx_reset_mpi() - Reset's MPI FW via Write MPI Register MBC. |
| 964 | * |
| 965 | * Returns 0 on success. |
| 966 | */ |
| 967 | int |
| 968 | qla81xx_reset_mpi(scsi_qla_host_t *vha) |
| 969 | { |
| 970 | uint16_t mb[4] = {0x1010, 0, 1, 0}; |
| 971 | |
| 972 | return qla81xx_write_mpi_register(vha, mb); |
| 973 | } |
| 974 | |
| 975 | /** |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 976 | * qla24xx_reset_risc() - Perform full reset of ISP24xx RISC. |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 977 | * @ha: HA context |
| 978 | * |
| 979 | * Returns 0 on success. |
| 980 | */ |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 981 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 982 | qla24xx_reset_risc(scsi_qla_host_t *vha) |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 983 | { |
| 984 | unsigned long flags = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 985 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 986 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 987 | uint32_t cnt, d2; |
Andrew Vasquez | 335a1cc | 2005-11-08 14:37:48 -0800 | [diff] [blame] | 988 | uint16_t wd; |
Madhuranath Iyengar | b1d4698 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 989 | static int abts_cnt; /* ISP abort retry counts */ |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 990 | |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 991 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 992 | |
| 993 | /* Reset RISC. */ |
| 994 | WRT_REG_DWORD(®->ctrl_status, CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); |
| 995 | for (cnt = 0; cnt < 30000; cnt++) { |
| 996 | if ((RD_REG_DWORD(®->ctrl_status) & CSRX_DMA_ACTIVE) == 0) |
| 997 | break; |
| 998 | |
| 999 | udelay(10); |
| 1000 | } |
| 1001 | |
| 1002 | WRT_REG_DWORD(®->ctrl_status, |
| 1003 | CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); |
Andrew Vasquez | 335a1cc | 2005-11-08 14:37:48 -0800 | [diff] [blame] | 1004 | pci_read_config_word(ha->pdev, PCI_COMMAND, &wd); |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 1005 | |
Andrew Vasquez | 335a1cc | 2005-11-08 14:37:48 -0800 | [diff] [blame] | 1006 | udelay(100); |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 1007 | /* Wait for firmware to complete NVRAM accesses. */ |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 1008 | d2 = (uint32_t) RD_REG_WORD(®->mailbox0); |
| 1009 | for (cnt = 10000 ; cnt && d2; cnt--) { |
| 1010 | udelay(5); |
| 1011 | d2 = (uint32_t) RD_REG_WORD(®->mailbox0); |
| 1012 | barrier(); |
| 1013 | } |
| 1014 | |
Andrew Vasquez | 335a1cc | 2005-11-08 14:37:48 -0800 | [diff] [blame] | 1015 | /* Wait for soft-reset to complete. */ |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1016 | d2 = RD_REG_DWORD(®->ctrl_status); |
| 1017 | for (cnt = 6000000 ; cnt && (d2 & CSRX_ISP_SOFT_RESET); cnt--) { |
| 1018 | udelay(5); |
| 1019 | d2 = RD_REG_DWORD(®->ctrl_status); |
| 1020 | barrier(); |
| 1021 | } |
| 1022 | |
Madhuranath Iyengar | b1d4698 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 1023 | /* If required, do an MPI FW reset now */ |
| 1024 | if (test_and_clear_bit(MPI_RESET_NEEDED, &vha->dpc_flags)) { |
| 1025 | if (qla81xx_reset_mpi(vha) != QLA_SUCCESS) { |
| 1026 | if (++abts_cnt < 5) { |
| 1027 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 1028 | set_bit(MPI_RESET_NEEDED, &vha->dpc_flags); |
| 1029 | } else { |
| 1030 | /* |
| 1031 | * We exhausted the ISP abort retries. We have to |
| 1032 | * set the board offline. |
| 1033 | */ |
| 1034 | abts_cnt = 0; |
| 1035 | vha->flags.online = 0; |
| 1036 | } |
| 1037 | } |
| 1038 | } |
| 1039 | |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1040 | WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_RESET); |
| 1041 | RD_REG_DWORD(®->hccr); |
| 1042 | |
| 1043 | WRT_REG_DWORD(®->hccr, HCCRX_REL_RISC_PAUSE); |
| 1044 | RD_REG_DWORD(®->hccr); |
| 1045 | |
| 1046 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_RESET); |
| 1047 | RD_REG_DWORD(®->hccr); |
| 1048 | |
| 1049 | d2 = (uint32_t) RD_REG_WORD(®->mailbox0); |
| 1050 | for (cnt = 6000000 ; cnt && d2; cnt--) { |
| 1051 | udelay(5); |
| 1052 | d2 = (uint32_t) RD_REG_WORD(®->mailbox0); |
| 1053 | barrier(); |
| 1054 | } |
| 1055 | |
| 1056 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1057 | |
| 1058 | if (IS_NOPOLLING_TYPE(ha)) |
| 1059 | ha->isp_ops->enable_intrs(ha); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1060 | } |
| 1061 | |
| 1062 | /** |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 1063 | * qla24xx_reset_chip() - Reset ISP24xx chip. |
| 1064 | * @ha: HA context |
| 1065 | * |
| 1066 | * Returns 0 on success. |
| 1067 | */ |
| 1068 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1069 | qla24xx_reset_chip(scsi_qla_host_t *vha) |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 1070 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1071 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1072 | |
| 1073 | if (pci_channel_offline(ha->pdev) && |
| 1074 | ha->flags.pci_channel_io_perm_failure) { |
| 1075 | return; |
| 1076 | } |
| 1077 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1078 | ha->isp_ops->disable_intrs(ha); |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 1079 | |
| 1080 | /* Perform RISC reset. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1081 | qla24xx_reset_risc(vha); |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 1082 | } |
| 1083 | |
| 1084 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1085 | * qla2x00_chip_diag() - Test chip for proper operation. |
| 1086 | * @ha: HA context |
| 1087 | * |
| 1088 | * Returns 0 on success. |
| 1089 | */ |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1090 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1091 | qla2x00_chip_diag(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1092 | { |
| 1093 | int rval; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1094 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 1095 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1096 | unsigned long flags = 0; |
| 1097 | uint16_t data; |
| 1098 | uint32_t cnt; |
| 1099 | uint16_t mb[5]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1100 | struct req_que *req = ha->req_q_map[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1101 | |
| 1102 | /* Assume a failed state */ |
| 1103 | rval = QLA_FUNCTION_FAILED; |
| 1104 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1105 | ql_dbg(ql_dbg_init, vha, 0x007b, |
| 1106 | "Testing device at %lx.\n", (u_long)®->flash_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1107 | |
| 1108 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1109 | |
| 1110 | /* Reset ISP chip. */ |
| 1111 | WRT_REG_WORD(®->ctrl_status, CSR_ISP_SOFT_RESET); |
| 1112 | |
| 1113 | /* |
| 1114 | * We need to have a delay here since the card will not respond while |
| 1115 | * in reset causing an MCA on some architectures. |
| 1116 | */ |
| 1117 | udelay(20); |
| 1118 | data = qla2x00_debounce_register(®->ctrl_status); |
| 1119 | for (cnt = 6000000 ; cnt && (data & CSR_ISP_SOFT_RESET); cnt--) { |
| 1120 | udelay(5); |
| 1121 | data = RD_REG_WORD(®->ctrl_status); |
| 1122 | barrier(); |
| 1123 | } |
| 1124 | |
| 1125 | if (!cnt) |
| 1126 | goto chip_diag_failed; |
| 1127 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1128 | ql_dbg(ql_dbg_init, vha, 0x007c, |
| 1129 | "Reset register cleared by chip reset.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | |
| 1131 | /* Reset RISC processor. */ |
| 1132 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 1133 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
| 1134 | |
| 1135 | /* Workaround for QLA2312 PCI parity error */ |
| 1136 | if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) { |
| 1137 | data = qla2x00_debounce_register(MAILBOX_REG(ha, reg, 0)); |
| 1138 | for (cnt = 6000000; cnt && (data == MBS_BUSY); cnt--) { |
| 1139 | udelay(5); |
| 1140 | data = RD_MAILBOX_REG(ha, reg, 0); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1141 | barrier(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1142 | } |
| 1143 | } else |
| 1144 | udelay(10); |
| 1145 | |
| 1146 | if (!cnt) |
| 1147 | goto chip_diag_failed; |
| 1148 | |
| 1149 | /* Check product ID of chip */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1150 | ql_dbg(ql_dbg_init, vha, 0x007d, "Checking product Id of chip.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1151 | |
| 1152 | mb[1] = RD_MAILBOX_REG(ha, reg, 1); |
| 1153 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 1154 | mb[3] = RD_MAILBOX_REG(ha, reg, 3); |
| 1155 | mb[4] = qla2x00_debounce_register(MAILBOX_REG(ha, reg, 4)); |
| 1156 | if (mb[1] != PROD_ID_1 || (mb[2] != PROD_ID_2 && mb[2] != PROD_ID_2a) || |
| 1157 | mb[3] != PROD_ID_3) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1158 | ql_log(ql_log_warn, vha, 0x0062, |
| 1159 | "Wrong product ID = 0x%x,0x%x,0x%x.\n", |
| 1160 | mb[1], mb[2], mb[3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1161 | |
| 1162 | goto chip_diag_failed; |
| 1163 | } |
| 1164 | ha->product_id[0] = mb[1]; |
| 1165 | ha->product_id[1] = mb[2]; |
| 1166 | ha->product_id[2] = mb[3]; |
| 1167 | ha->product_id[3] = mb[4]; |
| 1168 | |
| 1169 | /* Adjust fw RISC transfer size */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1170 | if (req->length > 1024) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1171 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * 1024; |
| 1172 | else |
| 1173 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1174 | req->length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1175 | |
| 1176 | if (IS_QLA2200(ha) && |
| 1177 | RD_MAILBOX_REG(ha, reg, 7) == QLA2200A_RISC_ROM_VER) { |
| 1178 | /* Limit firmware transfer size with a 2200A */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1179 | ql_dbg(ql_dbg_init, vha, 0x007e, "Found QLA2200A Chip.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1180 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1181 | ha->device_type |= DT_ISP2200A; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1182 | ha->fw_transfer_size = 128; |
| 1183 | } |
| 1184 | |
| 1185 | /* Wrap Incoming Mailboxes Test. */ |
| 1186 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1187 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1188 | ql_dbg(ql_dbg_init, vha, 0x007f, "Checking mailboxes.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1189 | rval = qla2x00_mbx_reg_test(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1190 | if (rval) |
| 1191 | ql_log(ql_log_warn, vha, 0x0080, |
| 1192 | "Failed mailbox send register test.\n"); |
| 1193 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | /* Flag a successful rval */ |
| 1195 | rval = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1197 | |
| 1198 | chip_diag_failed: |
| 1199 | if (rval) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1200 | ql_log(ql_log_info, vha, 0x0081, |
| 1201 | "Chip diagnostics **** FAILED ****.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | |
| 1203 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1204 | |
| 1205 | return (rval); |
| 1206 | } |
| 1207 | |
| 1208 | /** |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1209 | * qla24xx_chip_diag() - Test ISP24xx for proper operation. |
| 1210 | * @ha: HA context |
| 1211 | * |
| 1212 | * Returns 0 on success. |
| 1213 | */ |
| 1214 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1215 | qla24xx_chip_diag(scsi_qla_host_t *vha) |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1216 | { |
| 1217 | int rval; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1218 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1219 | struct req_que *req = ha->req_q_map[0]; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1220 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1221 | if (IS_QLA82XX(ha)) |
| 1222 | return QLA_SUCCESS; |
| 1223 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1224 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * req->length; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1225 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1226 | rval = qla2x00_mbx_reg_test(vha); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1227 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1228 | ql_log(ql_log_warn, vha, 0x0082, |
| 1229 | "Failed mailbox send register test.\n"); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1230 | } else { |
| 1231 | /* Flag a successful rval */ |
| 1232 | rval = QLA_SUCCESS; |
| 1233 | } |
| 1234 | |
| 1235 | return rval; |
| 1236 | } |
| 1237 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1238 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1239 | qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1240 | { |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1241 | int rval; |
| 1242 | uint32_t dump_size, fixed_size, mem_size, req_q_size, rsp_q_size, |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1243 | eft_size, fce_size, mq_size; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 1244 | dma_addr_t tc_dma; |
| 1245 | void *tc; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1246 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1247 | struct req_que *req = ha->req_q_map[0]; |
| 1248 | struct rsp_que *rsp = ha->rsp_q_map[0]; |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 1249 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1250 | if (ha->fw_dump) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1251 | ql_dbg(ql_dbg_init, vha, 0x00bd, |
| 1252 | "Firmware dump already allocated.\n"); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1253 | return; |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 1254 | } |
| 1255 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1256 | ha->fw_dumped = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1257 | fixed_size = mem_size = eft_size = fce_size = mq_size = 0; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1258 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
| 1259 | fixed_size = sizeof(struct qla2100_fw_dump); |
| 1260 | } else if (IS_QLA23XX(ha)) { |
| 1261 | fixed_size = offsetof(struct qla2300_fw_dump, data_ram); |
| 1262 | mem_size = (ha->fw_memory_size - 0x11000 + 1) * |
| 1263 | sizeof(uint16_t); |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1264 | } else if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1265 | if (IS_QLA81XX(ha)) |
| 1266 | fixed_size = offsetof(struct qla81xx_fw_dump, ext_mem); |
| 1267 | else if (IS_QLA25XX(ha)) |
| 1268 | fixed_size = offsetof(struct qla25xx_fw_dump, ext_mem); |
| 1269 | else |
| 1270 | fixed_size = offsetof(struct qla24xx_fw_dump, ext_mem); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1271 | mem_size = (ha->fw_memory_size - 0x100000 + 1) * |
| 1272 | sizeof(uint32_t); |
Giridhar Malavali | 050c9bb | 2012-02-09 11:15:33 -0800 | [diff] [blame^] | 1273 | if (ha->mqenable) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1274 | mq_size = sizeof(struct qla2xxx_mq_chain); |
Giridhar Malavali | 050c9bb | 2012-02-09 11:15:33 -0800 | [diff] [blame^] | 1275 | /* |
| 1276 | * Allocate maximum buffer size for all queues. |
| 1277 | * Resizing must be done at end-of-dump processing. |
| 1278 | */ |
| 1279 | mq_size += ha->max_req_queues * |
| 1280 | (req->length * sizeof(request_t)); |
| 1281 | mq_size += ha->max_rsp_queues * |
| 1282 | (rsp->length * sizeof(response_t)); |
| 1283 | } |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1284 | /* Allocate memory for Fibre Channel Event Buffer. */ |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1285 | if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)) |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1286 | goto try_eft; |
| 1287 | |
| 1288 | tc = dma_alloc_coherent(&ha->pdev->dev, FCE_SIZE, &tc_dma, |
| 1289 | GFP_KERNEL); |
| 1290 | if (!tc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1291 | ql_log(ql_log_warn, vha, 0x00be, |
| 1292 | "Unable to allocate (%d KB) for FCE.\n", |
| 1293 | FCE_SIZE / 1024); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1294 | goto try_eft; |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1295 | } |
| 1296 | |
| 1297 | memset(tc, 0, FCE_SIZE); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1298 | rval = qla2x00_enable_fce_trace(vha, tc_dma, FCE_NUM_BUFFERS, |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1299 | ha->fce_mb, &ha->fce_bufs); |
| 1300 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1301 | ql_log(ql_log_warn, vha, 0x00bf, |
| 1302 | "Unable to initialize FCE (%d).\n", rval); |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1303 | dma_free_coherent(&ha->pdev->dev, FCE_SIZE, tc, |
| 1304 | tc_dma); |
| 1305 | ha->flags.fce_enabled = 0; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1306 | goto try_eft; |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1307 | } |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1308 | ql_dbg(ql_dbg_init, vha, 0x00c0, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1309 | "Allocate (%d KB) for FCE...\n", FCE_SIZE / 1024); |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1310 | |
Giridhar Malavali | 7d9dade | 2009-03-24 09:07:58 -0700 | [diff] [blame] | 1311 | fce_size = sizeof(struct qla2xxx_fce_chain) + FCE_SIZE; |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1312 | ha->flags.fce_enabled = 1; |
| 1313 | ha->fce_dma = tc_dma; |
| 1314 | ha->fce = tc; |
| 1315 | try_eft: |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1316 | /* Allocate memory for Extended Trace Buffer. */ |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 1317 | tc = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &tc_dma, |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1318 | GFP_KERNEL); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 1319 | if (!tc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1320 | ql_log(ql_log_warn, vha, 0x00c1, |
| 1321 | "Unable to allocate (%d KB) for EFT.\n", |
| 1322 | EFT_SIZE / 1024); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1323 | goto cont_alloc; |
| 1324 | } |
| 1325 | |
Andrew Vasquez | fc44765 | 2008-01-17 09:02:18 -0800 | [diff] [blame] | 1326 | memset(tc, 0, EFT_SIZE); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1327 | rval = qla2x00_enable_eft_trace(vha, tc_dma, EFT_NUM_BUFFERS); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1328 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1329 | ql_log(ql_log_warn, vha, 0x00c2, |
| 1330 | "Unable to initialize EFT (%d).\n", rval); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 1331 | dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc, |
| 1332 | tc_dma); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1333 | goto cont_alloc; |
| 1334 | } |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1335 | ql_dbg(ql_dbg_init, vha, 0x00c3, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1336 | "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1337 | |
| 1338 | eft_size = EFT_SIZE; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 1339 | ha->eft_dma = tc_dma; |
| 1340 | ha->eft = tc; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1341 | } |
| 1342 | cont_alloc: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1343 | req_q_size = req->length * sizeof(request_t); |
| 1344 | rsp_q_size = rsp->length * sizeof(response_t); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1345 | |
| 1346 | dump_size = offsetof(struct qla2xxx_fw_dump, isp); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1347 | dump_size += fixed_size + mem_size + req_q_size + rsp_q_size + eft_size; |
Andrew Vasquez | bb99de6 | 2009-01-05 11:18:08 -0800 | [diff] [blame] | 1348 | ha->chain_offset = dump_size; |
| 1349 | dump_size += mq_size + fce_size; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1350 | |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 1351 | ha->fw_dump = vmalloc(dump_size); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1352 | if (!ha->fw_dump) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1353 | ql_log(ql_log_warn, vha, 0x00c4, |
| 1354 | "Unable to allocate (%d KB) for firmware dump.\n", |
| 1355 | dump_size / 1024); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1356 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 1357 | if (ha->fce) { |
| 1358 | dma_free_coherent(&ha->pdev->dev, FCE_SIZE, ha->fce, |
| 1359 | ha->fce_dma); |
| 1360 | ha->fce = NULL; |
| 1361 | ha->fce_dma = 0; |
| 1362 | } |
| 1363 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1364 | if (ha->eft) { |
| 1365 | dma_free_coherent(&ha->pdev->dev, eft_size, ha->eft, |
| 1366 | ha->eft_dma); |
| 1367 | ha->eft = NULL; |
| 1368 | ha->eft_dma = 0; |
| 1369 | } |
| 1370 | return; |
| 1371 | } |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1372 | ql_dbg(ql_dbg_init, vha, 0x00c5, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1373 | "Allocated (%d KB) for firmware dump.\n", dump_size / 1024); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1374 | |
| 1375 | ha->fw_dump_len = dump_size; |
| 1376 | ha->fw_dump->signature[0] = 'Q'; |
| 1377 | ha->fw_dump->signature[1] = 'L'; |
| 1378 | ha->fw_dump->signature[2] = 'G'; |
| 1379 | ha->fw_dump->signature[3] = 'C'; |
| 1380 | ha->fw_dump->version = __constant_htonl(1); |
| 1381 | |
| 1382 | ha->fw_dump->fixed_size = htonl(fixed_size); |
| 1383 | ha->fw_dump->mem_size = htonl(mem_size); |
| 1384 | ha->fw_dump->req_q_size = htonl(req_q_size); |
| 1385 | ha->fw_dump->rsp_q_size = htonl(rsp_q_size); |
| 1386 | |
| 1387 | ha->fw_dump->eft_size = htonl(eft_size); |
| 1388 | ha->fw_dump->eft_addr_l = htonl(LSD(ha->eft_dma)); |
| 1389 | ha->fw_dump->eft_addr_h = htonl(MSD(ha->eft_dma)); |
| 1390 | |
| 1391 | ha->fw_dump->header_size = |
| 1392 | htonl(offsetof(struct qla2xxx_fw_dump, isp)); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1393 | } |
| 1394 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 1395 | static int |
| 1396 | qla81xx_mpi_sync(scsi_qla_host_t *vha) |
| 1397 | { |
| 1398 | #define MPS_MASK 0xe0 |
| 1399 | int rval; |
| 1400 | uint16_t dc; |
| 1401 | uint32_t dw; |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 1402 | |
| 1403 | if (!IS_QLA81XX(vha->hw)) |
| 1404 | return QLA_SUCCESS; |
| 1405 | |
| 1406 | rval = qla2x00_write_ram_word(vha, 0x7c00, 1); |
| 1407 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1408 | ql_log(ql_log_warn, vha, 0x0105, |
| 1409 | "Unable to acquire semaphore.\n"); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 1410 | goto done; |
| 1411 | } |
| 1412 | |
| 1413 | pci_read_config_word(vha->hw->pdev, 0x54, &dc); |
| 1414 | rval = qla2x00_read_ram_word(vha, 0x7a15, &dw); |
| 1415 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1416 | ql_log(ql_log_warn, vha, 0x0067, "Unable to read sync.\n"); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 1417 | goto done_release; |
| 1418 | } |
| 1419 | |
| 1420 | dc &= MPS_MASK; |
| 1421 | if (dc == (dw & MPS_MASK)) |
| 1422 | goto done_release; |
| 1423 | |
| 1424 | dw &= ~MPS_MASK; |
| 1425 | dw |= dc; |
| 1426 | rval = qla2x00_write_ram_word(vha, 0x7a15, dw); |
| 1427 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1428 | ql_log(ql_log_warn, vha, 0x0114, "Unable to gain sync.\n"); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 1429 | } |
| 1430 | |
| 1431 | done_release: |
| 1432 | rval = qla2x00_write_ram_word(vha, 0x7c00, 0); |
| 1433 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1434 | ql_log(ql_log_warn, vha, 0x006d, |
| 1435 | "Unable to release semaphore.\n"); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 1436 | } |
| 1437 | |
| 1438 | done: |
| 1439 | return rval; |
| 1440 | } |
| 1441 | |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1442 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1443 | * qla2x00_setup_chip() - Load and start RISC firmware. |
| 1444 | * @ha: HA context |
| 1445 | * |
| 1446 | * Returns 0 on success. |
| 1447 | */ |
| 1448 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1449 | qla2x00_setup_chip(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1450 | { |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1451 | int rval; |
| 1452 | uint32_t srisc_address = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1453 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3db0652 | 2008-01-31 12:33:49 -0800 | [diff] [blame] | 1454 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1455 | unsigned long flags; |
Andrew Vasquez | dda772e | 2009-03-24 09:08:00 -0700 | [diff] [blame] | 1456 | uint16_t fw_major_version; |
Andrew Vasquez | 3db0652 | 2008-01-31 12:33:49 -0800 | [diff] [blame] | 1457 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1458 | if (IS_QLA82XX(ha)) { |
| 1459 | rval = ha->isp_ops->load_risc(vha, &srisc_address); |
Andrew Vasquez | 14e303d | 2010-07-23 15:28:29 +0500 | [diff] [blame] | 1460 | if (rval == QLA_SUCCESS) { |
| 1461 | qla2x00_stop_firmware(vha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1462 | goto enable_82xx_npiv; |
Andrew Vasquez | 14e303d | 2010-07-23 15:28:29 +0500 | [diff] [blame] | 1463 | } else |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 1464 | goto failed; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1465 | } |
| 1466 | |
Andrew Vasquez | 3db0652 | 2008-01-31 12:33:49 -0800 | [diff] [blame] | 1467 | if (!IS_FWI2_CAPABLE(ha) && !IS_QLA2100(ha) && !IS_QLA2200(ha)) { |
| 1468 | /* Disable SRAM, Instruction RAM and GP RAM parity. */ |
| 1469 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1470 | WRT_REG_WORD(®->hccr, (HCCR_ENABLE_PARITY + 0x0)); |
| 1471 | RD_REG_WORD(®->hccr); |
| 1472 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1473 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1474 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 1475 | qla81xx_mpi_sync(vha); |
| 1476 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1477 | /* Load firmware sequences */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1478 | rval = ha->isp_ops->load_risc(vha, &srisc_address); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1479 | if (rval == QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1480 | ql_dbg(ql_dbg_init, vha, 0x00c9, |
| 1481 | "Verifying Checksum of loaded RISC code.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1482 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1483 | rval = qla2x00_verify_checksum(vha, srisc_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1484 | if (rval == QLA_SUCCESS) { |
| 1485 | /* Start firmware execution. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1486 | ql_dbg(ql_dbg_init, vha, 0x00ca, |
| 1487 | "Starting firmware.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1488 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1489 | rval = qla2x00_execute_fw(vha, srisc_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1490 | /* Retrieve firmware information. */ |
Andrew Vasquez | dda772e | 2009-03-24 09:08:00 -0700 | [diff] [blame] | 1491 | if (rval == QLA_SUCCESS) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1492 | enable_82xx_npiv: |
Andrew Vasquez | dda772e | 2009-03-24 09:08:00 -0700 | [diff] [blame] | 1493 | fw_major_version = ha->fw_major_version; |
Giridhar Malavali | 3173167 | 2011-08-16 11:31:54 -0700 | [diff] [blame] | 1494 | if (IS_QLA82XX(ha)) |
| 1495 | qla82xx_check_md_needed(vha); |
| 1496 | else { |
| 1497 | rval = qla2x00_get_fw_version(vha, |
| 1498 | &ha->fw_major_version, |
| 1499 | &ha->fw_minor_version, |
| 1500 | &ha->fw_subminor_version, |
| 1501 | &ha->fw_attributes, |
| 1502 | &ha->fw_memory_size, |
| 1503 | ha->mpi_version, |
| 1504 | &ha->mpi_capabilities, |
| 1505 | ha->phy_version); |
| 1506 | } |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1507 | if (rval != QLA_SUCCESS) |
| 1508 | goto failed; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1509 | ha->flags.npiv_supported = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1510 | if (IS_QLA2XXX_MIDTYPE(ha) && |
Mike Hernandez | 946fb89 | 2008-08-13 21:36:59 -0700 | [diff] [blame] | 1511 | (ha->fw_attributes & BIT_2)) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1512 | ha->flags.npiv_supported = 1; |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 1513 | if ((!ha->max_npiv_vports) || |
| 1514 | ((ha->max_npiv_vports + 1) % |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 1515 | MIN_MULTI_ID_FABRIC)) |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 1516 | ha->max_npiv_vports = |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 1517 | MIN_MULTI_ID_FABRIC - 1; |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 1518 | } |
Andrew Vasquez | 24a0813 | 2009-03-24 09:08:16 -0700 | [diff] [blame] | 1519 | qla2x00_get_resource_cnts(vha, NULL, |
| 1520 | &ha->fw_xcb_count, NULL, NULL, |
Andrew Vasquez | f3a0a77 | 2009-10-13 15:16:49 -0700 | [diff] [blame] | 1521 | &ha->max_npiv_vports, NULL); |
Andrew Vasquez | d743de6 | 2009-03-24 09:08:15 -0700 | [diff] [blame] | 1522 | |
Saurav Kashyap | be5ea3c | 2011-11-18 09:02:11 -0800 | [diff] [blame] | 1523 | if (!fw_major_version && ql2xallocfwdump |
| 1524 | && !IS_QLA82XX(ha)) |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 1525 | qla2x00_alloc_fw_dump(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1526 | } |
| 1527 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1528 | ql_log(ql_log_fatal, vha, 0x00cd, |
| 1529 | "ISP Firmware failed checksum.\n"); |
| 1530 | goto failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1531 | } |
| 1532 | } |
| 1533 | |
Andrew Vasquez | 3db0652 | 2008-01-31 12:33:49 -0800 | [diff] [blame] | 1534 | if (!IS_FWI2_CAPABLE(ha) && !IS_QLA2100(ha) && !IS_QLA2200(ha)) { |
| 1535 | /* Enable proper parity. */ |
| 1536 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1537 | if (IS_QLA2300(ha)) |
| 1538 | /* SRAM parity */ |
| 1539 | WRT_REG_WORD(®->hccr, HCCR_ENABLE_PARITY + 0x1); |
| 1540 | else |
| 1541 | /* SRAM, Instruction RAM and GP RAM parity */ |
| 1542 | WRT_REG_WORD(®->hccr, HCCR_ENABLE_PARITY + 0x7); |
| 1543 | RD_REG_WORD(®->hccr); |
| 1544 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1545 | } |
| 1546 | |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 1547 | if (rval == QLA_SUCCESS && IS_FAC_REQUIRED(ha)) { |
| 1548 | uint32_t size; |
| 1549 | |
| 1550 | rval = qla81xx_fac_get_sector_size(vha, &size); |
| 1551 | if (rval == QLA_SUCCESS) { |
| 1552 | ha->flags.fac_supported = 1; |
| 1553 | ha->fdt_block_size = size << 2; |
| 1554 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1555 | ql_log(ql_log_warn, vha, 0x00ce, |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 1556 | "Unsupported FAC firmware (%d.%02d.%02d).\n", |
| 1557 | ha->fw_major_version, ha->fw_minor_version, |
| 1558 | ha->fw_subminor_version); |
| 1559 | } |
| 1560 | } |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1561 | failed: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1562 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1563 | ql_log(ql_log_fatal, vha, 0x00cf, |
| 1564 | "Setup chip ****FAILED****.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1565 | } |
| 1566 | |
| 1567 | return (rval); |
| 1568 | } |
| 1569 | |
| 1570 | /** |
| 1571 | * qla2x00_init_response_q_entries() - Initializes response queue entries. |
| 1572 | * @ha: HA context |
| 1573 | * |
| 1574 | * Beginning of request ring has initialization control block already built |
| 1575 | * by nvram config routine. |
| 1576 | * |
| 1577 | * Returns 0 on success. |
| 1578 | */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1579 | void |
| 1580 | qla2x00_init_response_q_entries(struct rsp_que *rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1581 | { |
| 1582 | uint16_t cnt; |
| 1583 | response_t *pkt; |
| 1584 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1585 | rsp->ring_ptr = rsp->ring; |
| 1586 | rsp->ring_index = 0; |
| 1587 | rsp->status_srb = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1588 | pkt = rsp->ring_ptr; |
| 1589 | for (cnt = 0; cnt < rsp->length; cnt++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1590 | pkt->signature = RESPONSE_PROCESSED; |
| 1591 | pkt++; |
| 1592 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1593 | } |
| 1594 | |
| 1595 | /** |
| 1596 | * qla2x00_update_fw_options() - Read and process firmware options. |
| 1597 | * @ha: HA context |
| 1598 | * |
| 1599 | * Returns 0 on success. |
| 1600 | */ |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1601 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1602 | qla2x00_update_fw_options(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1603 | { |
| 1604 | uint16_t swing, emphasis, tx_sens, rx_sens; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1605 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1606 | |
| 1607 | memset(ha->fw_options, 0, sizeof(ha->fw_options)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1608 | qla2x00_get_fw_options(vha, ha->fw_options); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1609 | |
| 1610 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 1611 | return; |
| 1612 | |
| 1613 | /* Serial Link options. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1614 | ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x0115, |
| 1615 | "Serial link options.\n"); |
| 1616 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0109, |
| 1617 | (uint8_t *)&ha->fw_seriallink_options, |
| 1618 | sizeof(ha->fw_seriallink_options)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1619 | |
| 1620 | ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING; |
| 1621 | if (ha->fw_seriallink_options[3] & BIT_2) { |
| 1622 | ha->fw_options[1] |= FO1_SET_EMPHASIS_SWING; |
| 1623 | |
| 1624 | /* 1G settings */ |
| 1625 | swing = ha->fw_seriallink_options[2] & (BIT_2 | BIT_1 | BIT_0); |
| 1626 | emphasis = (ha->fw_seriallink_options[2] & |
| 1627 | (BIT_4 | BIT_3)) >> 3; |
| 1628 | tx_sens = ha->fw_seriallink_options[0] & |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1629 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1630 | rx_sens = (ha->fw_seriallink_options[0] & |
| 1631 | (BIT_7 | BIT_6 | BIT_5 | BIT_4)) >> 4; |
| 1632 | ha->fw_options[10] = (emphasis << 14) | (swing << 8); |
| 1633 | if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
| 1634 | if (rx_sens == 0x0) |
| 1635 | rx_sens = 0x3; |
| 1636 | ha->fw_options[10] |= (tx_sens << 4) | rx_sens; |
| 1637 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 1638 | ha->fw_options[10] |= BIT_5 | |
| 1639 | ((rx_sens & (BIT_1 | BIT_0)) << 2) | |
| 1640 | (tx_sens & (BIT_1 | BIT_0)); |
| 1641 | |
| 1642 | /* 2G settings */ |
| 1643 | swing = (ha->fw_seriallink_options[2] & |
| 1644 | (BIT_7 | BIT_6 | BIT_5)) >> 5; |
| 1645 | emphasis = ha->fw_seriallink_options[3] & (BIT_1 | BIT_0); |
| 1646 | tx_sens = ha->fw_seriallink_options[1] & |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1647 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1648 | rx_sens = (ha->fw_seriallink_options[1] & |
| 1649 | (BIT_7 | BIT_6 | BIT_5 | BIT_4)) >> 4; |
| 1650 | ha->fw_options[11] = (emphasis << 14) | (swing << 8); |
| 1651 | if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
| 1652 | if (rx_sens == 0x0) |
| 1653 | rx_sens = 0x3; |
| 1654 | ha->fw_options[11] |= (tx_sens << 4) | rx_sens; |
| 1655 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 1656 | ha->fw_options[11] |= BIT_5 | |
| 1657 | ((rx_sens & (BIT_1 | BIT_0)) << 2) | |
| 1658 | (tx_sens & (BIT_1 | BIT_0)); |
| 1659 | } |
| 1660 | |
| 1661 | /* FCP2 options. */ |
| 1662 | /* Return command IOCBs without waiting for an ABTS to complete. */ |
| 1663 | ha->fw_options[3] |= BIT_13; |
| 1664 | |
| 1665 | /* LED scheme. */ |
| 1666 | if (ha->flags.enable_led_scheme) |
| 1667 | ha->fw_options[2] |= BIT_12; |
| 1668 | |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 1669 | /* Detect ISP6312. */ |
| 1670 | if (IS_QLA6312(ha)) |
| 1671 | ha->fw_options[2] |= BIT_13; |
| 1672 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1673 | /* Update firmware options. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1674 | qla2x00_set_fw_options(vha, ha->fw_options); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1675 | } |
| 1676 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1677 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1678 | qla24xx_update_fw_options(scsi_qla_host_t *vha) |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1679 | { |
| 1680 | int rval; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1681 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1682 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1683 | if (IS_QLA82XX(ha)) |
| 1684 | return; |
| 1685 | |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1686 | /* Update Serial Link options. */ |
andrew.vasquez@qlogic.com | f94097e | 2006-01-13 17:05:32 -0800 | [diff] [blame] | 1687 | if ((le16_to_cpu(ha->fw_seriallink_options24[0]) & BIT_0) == 0) |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1688 | return; |
| 1689 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1690 | rval = qla2x00_set_serdes_params(vha, |
andrew.vasquez@qlogic.com | f94097e | 2006-01-13 17:05:32 -0800 | [diff] [blame] | 1691 | le16_to_cpu(ha->fw_seriallink_options24[1]), |
| 1692 | le16_to_cpu(ha->fw_seriallink_options24[2]), |
| 1693 | le16_to_cpu(ha->fw_seriallink_options24[3])); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1694 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1695 | ql_log(ql_log_warn, vha, 0x0104, |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1696 | "Unable to update Serial Link options (%x).\n", rval); |
| 1697 | } |
| 1698 | } |
| 1699 | |
| 1700 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1701 | qla2x00_config_rings(struct scsi_qla_host *vha) |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1702 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1703 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 1704 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1705 | struct req_que *req = ha->req_q_map[0]; |
| 1706 | struct rsp_que *rsp = ha->rsp_q_map[0]; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1707 | |
| 1708 | /* Setup ring parameters in initialization control block. */ |
| 1709 | ha->init_cb->request_q_outpointer = __constant_cpu_to_le16(0); |
| 1710 | ha->init_cb->response_q_inpointer = __constant_cpu_to_le16(0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1711 | ha->init_cb->request_q_length = cpu_to_le16(req->length); |
| 1712 | ha->init_cb->response_q_length = cpu_to_le16(rsp->length); |
| 1713 | ha->init_cb->request_q_address[0] = cpu_to_le32(LSD(req->dma)); |
| 1714 | ha->init_cb->request_q_address[1] = cpu_to_le32(MSD(req->dma)); |
| 1715 | ha->init_cb->response_q_address[0] = cpu_to_le32(LSD(rsp->dma)); |
| 1716 | ha->init_cb->response_q_address[1] = cpu_to_le32(MSD(rsp->dma)); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1717 | |
| 1718 | WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), 0); |
| 1719 | WRT_REG_WORD(ISP_REQ_Q_OUT(ha, reg), 0); |
| 1720 | WRT_REG_WORD(ISP_RSP_Q_IN(ha, reg), 0); |
| 1721 | WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), 0); |
| 1722 | RD_REG_WORD(ISP_RSP_Q_OUT(ha, reg)); /* PCI Posting. */ |
| 1723 | } |
| 1724 | |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1725 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1726 | qla24xx_config_rings(struct scsi_qla_host *vha) |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1727 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1728 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1729 | device_reg_t __iomem *reg = ISP_QUE_REG(ha, 0); |
| 1730 | struct device_reg_2xxx __iomem *ioreg = &ha->iobase->isp; |
| 1731 | struct qla_msix_entry *msix; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1732 | struct init_cb_24xx *icb; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1733 | uint16_t rid = 0; |
| 1734 | struct req_que *req = ha->req_q_map[0]; |
| 1735 | struct rsp_que *rsp = ha->rsp_q_map[0]; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1736 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1737 | /* Setup ring parameters in initialization control block. */ |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1738 | icb = (struct init_cb_24xx *)ha->init_cb; |
| 1739 | icb->request_q_outpointer = __constant_cpu_to_le16(0); |
| 1740 | icb->response_q_inpointer = __constant_cpu_to_le16(0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1741 | icb->request_q_length = cpu_to_le16(req->length); |
| 1742 | icb->response_q_length = cpu_to_le16(rsp->length); |
| 1743 | icb->request_q_address[0] = cpu_to_le32(LSD(req->dma)); |
| 1744 | icb->request_q_address[1] = cpu_to_le32(MSD(req->dma)); |
| 1745 | icb->response_q_address[0] = cpu_to_le32(LSD(rsp->dma)); |
| 1746 | icb->response_q_address[1] = cpu_to_le32(MSD(rsp->dma)); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1747 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1748 | if (ha->mqenable) { |
| 1749 | icb->qos = __constant_cpu_to_le16(QLA_DEFAULT_QUE_QOS); |
| 1750 | icb->rid = __constant_cpu_to_le16(rid); |
| 1751 | if (ha->flags.msix_enabled) { |
| 1752 | msix = &ha->msix_entries[1]; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1753 | ql_dbg(ql_dbg_init, vha, 0x00fd, |
| 1754 | "Registering vector 0x%x for base que.\n", |
| 1755 | msix->entry); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1756 | icb->msix = cpu_to_le16(msix->entry); |
| 1757 | } |
| 1758 | /* Use alternate PCI bus number */ |
| 1759 | if (MSB(rid)) |
| 1760 | icb->firmware_options_2 |= |
| 1761 | __constant_cpu_to_le32(BIT_19); |
| 1762 | /* Use alternate PCI devfn */ |
| 1763 | if (LSB(rid)) |
| 1764 | icb->firmware_options_2 |= |
| 1765 | __constant_cpu_to_le32(BIT_18); |
| 1766 | |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 1767 | /* Use Disable MSIX Handshake mode for capable adapters */ |
| 1768 | if (IS_MSIX_NACK_CAPABLE(ha)) { |
| 1769 | icb->firmware_options_2 &= |
| 1770 | __constant_cpu_to_le32(~BIT_22); |
| 1771 | ha->flags.disable_msix_handshake = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1772 | ql_dbg(ql_dbg_init, vha, 0x00fe, |
| 1773 | "MSIX Handshake Disable Mode turned on.\n"); |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 1774 | } else { |
| 1775 | icb->firmware_options_2 |= |
| 1776 | __constant_cpu_to_le32(BIT_22); |
| 1777 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1778 | icb->firmware_options_2 |= __constant_cpu_to_le32(BIT_23); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1779 | |
| 1780 | WRT_REG_DWORD(®->isp25mq.req_q_in, 0); |
| 1781 | WRT_REG_DWORD(®->isp25mq.req_q_out, 0); |
| 1782 | WRT_REG_DWORD(®->isp25mq.rsp_q_in, 0); |
| 1783 | WRT_REG_DWORD(®->isp25mq.rsp_q_out, 0); |
| 1784 | } else { |
| 1785 | WRT_REG_DWORD(®->isp24.req_q_in, 0); |
| 1786 | WRT_REG_DWORD(®->isp24.req_q_out, 0); |
| 1787 | WRT_REG_DWORD(®->isp24.rsp_q_in, 0); |
| 1788 | WRT_REG_DWORD(®->isp24.rsp_q_out, 0); |
| 1789 | } |
| 1790 | /* PCI posting */ |
| 1791 | RD_REG_DWORD(&ioreg->hccr); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1792 | } |
| 1793 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1794 | /** |
| 1795 | * qla2x00_init_rings() - Initializes firmware. |
| 1796 | * @ha: HA context |
| 1797 | * |
| 1798 | * Beginning of request ring has initialization control block already built |
| 1799 | * by nvram config routine. |
| 1800 | * |
| 1801 | * Returns 0 on success. |
| 1802 | */ |
| 1803 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1804 | qla2x00_init_rings(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1805 | { |
| 1806 | int rval; |
| 1807 | unsigned long flags = 0; |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1808 | int cnt, que; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1809 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1810 | struct req_que *req; |
| 1811 | struct rsp_que *rsp; |
| 1812 | struct scsi_qla_host *vp; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1813 | struct mid_init_cb_24xx *mid_init_cb = |
| 1814 | (struct mid_init_cb_24xx *) ha->init_cb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1815 | |
| 1816 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1817 | |
| 1818 | /* Clear outstanding commands array. */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1819 | for (que = 0; que < ha->max_req_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1820 | req = ha->req_q_map[que]; |
| 1821 | if (!req) |
| 1822 | continue; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1823 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1824 | req->outstanding_cmds[cnt] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1825 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1826 | req->current_outstanding_cmd = 1; |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1827 | |
| 1828 | /* Initialize firmware. */ |
| 1829 | req->ring_ptr = req->ring; |
| 1830 | req->ring_index = 0; |
| 1831 | req->cnt = req->length; |
| 1832 | } |
| 1833 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1834 | for (que = 0; que < ha->max_rsp_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1835 | rsp = ha->rsp_q_map[que]; |
| 1836 | if (!rsp) |
| 1837 | continue; |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1838 | /* Initialize response queue entries */ |
| 1839 | qla2x00_init_response_q_entries(rsp); |
| 1840 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1841 | |
Dan Carpenter | 542bce1 | 2010-10-15 11:27:38 -0700 | [diff] [blame] | 1842 | spin_lock(&ha->vport_slock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1843 | /* Clear RSCN queue. */ |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1844 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 1845 | vp->rscn_in_ptr = 0; |
| 1846 | vp->rscn_out_ptr = 0; |
| 1847 | } |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 1848 | |
Dan Carpenter | 542bce1 | 2010-10-15 11:27:38 -0700 | [diff] [blame] | 1849 | spin_unlock(&ha->vport_slock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 1850 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1851 | ha->isp_ops->config_rings(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1852 | |
| 1853 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1854 | |
| 1855 | /* Update any ISP specific firmware options before initialization. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1856 | ha->isp_ops->update_fw_options(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1857 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1858 | ql_dbg(ql_dbg_init, vha, 0x00d1, "Issue init firmware.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1859 | |
Lalit Chandivade | 605aa2b | 2009-03-05 11:07:01 -0800 | [diff] [blame] | 1860 | if (ha->flags.npiv_supported) { |
| 1861 | if (ha->operating_mode == LOOP) |
| 1862 | ha->max_npiv_vports = MIN_MULTI_ID_FABRIC - 1; |
Seokmann Ju | c48339d | 2008-01-17 09:02:19 -0800 | [diff] [blame] | 1863 | mid_init_cb->count = cpu_to_le16(ha->max_npiv_vports); |
Lalit Chandivade | 605aa2b | 2009-03-05 11:07:01 -0800 | [diff] [blame] | 1864 | } |
| 1865 | |
Andrew Vasquez | 24a0813 | 2009-03-24 09:08:16 -0700 | [diff] [blame] | 1866 | if (IS_FWI2_CAPABLE(ha)) { |
| 1867 | mid_init_cb->options = __constant_cpu_to_le16(BIT_1); |
| 1868 | mid_init_cb->init_cb.execution_throttle = |
| 1869 | cpu_to_le16(ha->fw_xcb_count); |
| 1870 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1871 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1872 | rval = qla2x00_init_firmware(vha, ha->init_cb_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1873 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1874 | ql_log(ql_log_fatal, vha, 0x00d2, |
| 1875 | "Init Firmware **** FAILED ****.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1876 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1877 | ql_dbg(ql_dbg_init, vha, 0x00d3, |
| 1878 | "Init Firmware -- success.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1879 | } |
| 1880 | |
| 1881 | return (rval); |
| 1882 | } |
| 1883 | |
| 1884 | /** |
| 1885 | * qla2x00_fw_ready() - Waits for firmware ready. |
| 1886 | * @ha: HA context |
| 1887 | * |
| 1888 | * Returns 0 on success. |
| 1889 | */ |
| 1890 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1891 | qla2x00_fw_ready(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1892 | { |
| 1893 | int rval; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1894 | unsigned long wtime, mtime, cs84xx_time; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1895 | uint16_t min_wait; /* Minimum wait time if loop is down */ |
| 1896 | uint16_t wait_time; /* Wait time if loop is coming ready */ |
Andrew Vasquez | 656e891 | 2009-06-03 09:55:29 -0700 | [diff] [blame] | 1897 | uint16_t state[5]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1898 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1899 | |
| 1900 | rval = QLA_SUCCESS; |
| 1901 | |
| 1902 | /* 20 seconds for loop down. */ |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1903 | min_wait = 20; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1904 | |
| 1905 | /* |
| 1906 | * Firmware should take at most one RATOV to login, plus 5 seconds for |
| 1907 | * our own processing. |
| 1908 | */ |
| 1909 | if ((wait_time = (ha->retry_count*ha->login_timeout) + 5) < min_wait) { |
| 1910 | wait_time = min_wait; |
| 1911 | } |
| 1912 | |
| 1913 | /* Min wait time if loop down */ |
| 1914 | mtime = jiffies + (min_wait * HZ); |
| 1915 | |
| 1916 | /* wait time before firmware ready */ |
| 1917 | wtime = jiffies + (wait_time * HZ); |
| 1918 | |
| 1919 | /* Wait for ISP to finish LIP */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1920 | if (!vha->flags.init_done) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1921 | ql_log(ql_log_info, vha, 0x801e, |
| 1922 | "Waiting for LIP to complete.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1923 | |
| 1924 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1925 | rval = qla2x00_get_firmware_state(vha, state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1926 | if (rval == QLA_SUCCESS) { |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1927 | if (state[0] < FSTATE_LOSS_OF_SYNC) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1928 | vha->device_flags &= ~DFLG_NO_CABLE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1929 | } |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1930 | if (IS_QLA84XX(ha) && state[0] != FSTATE_READY) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1931 | ql_dbg(ql_dbg_taskm, vha, 0x801f, |
| 1932 | "fw_state=%x 84xx=%x.\n", state[0], |
| 1933 | state[2]); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1934 | if ((state[2] & FSTATE_LOGGED_IN) && |
| 1935 | (state[2] & FSTATE_WAITING_FOR_VERIFY)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1936 | ql_dbg(ql_dbg_taskm, vha, 0x8028, |
| 1937 | "Sending verify iocb.\n"); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1938 | |
| 1939 | cs84xx_time = jiffies; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1940 | rval = qla84xx_init_chip(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1941 | if (rval != QLA_SUCCESS) { |
| 1942 | ql_log(ql_log_warn, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1943 | vha, 0x8007, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1944 | "Init chip failed.\n"); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1945 | break; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1946 | } |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1947 | |
| 1948 | /* Add time taken to initialize. */ |
| 1949 | cs84xx_time = jiffies - cs84xx_time; |
| 1950 | wtime += cs84xx_time; |
| 1951 | mtime += cs84xx_time; |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1952 | ql_dbg(ql_dbg_taskm, vha, 0x8008, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1953 | "Increasing wait time by %ld. " |
| 1954 | "New time %ld.\n", cs84xx_time, |
| 1955 | wtime); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1956 | } |
| 1957 | } else if (state[0] == FSTATE_READY) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1958 | ql_dbg(ql_dbg_taskm, vha, 0x8037, |
| 1959 | "F/W Ready - OK.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1960 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1961 | qla2x00_get_retry_cnt(vha, &ha->retry_count, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1962 | &ha->login_timeout, &ha->r_a_tov); |
| 1963 | |
| 1964 | rval = QLA_SUCCESS; |
| 1965 | break; |
| 1966 | } |
| 1967 | |
| 1968 | rval = QLA_FUNCTION_FAILED; |
| 1969 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1970 | if (atomic_read(&vha->loop_down_timer) && |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1971 | state[0] != FSTATE_READY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1972 | /* Loop down. Timeout on min_wait for states |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1973 | * other than Wait for Login. |
| 1974 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1975 | if (time_after_eq(jiffies, mtime)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1976 | ql_log(ql_log_info, vha, 0x8038, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1977 | "Cable is unplugged...\n"); |
| 1978 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1979 | vha->device_flags |= DFLG_NO_CABLE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1980 | break; |
| 1981 | } |
| 1982 | } |
| 1983 | } else { |
| 1984 | /* Mailbox cmd failed. Timeout on min_wait. */ |
Santosh Vernekar | cdbb0a4 | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 1985 | if (time_after_eq(jiffies, mtime) || |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 1986 | ha->flags.isp82xx_fw_hung) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1987 | break; |
| 1988 | } |
| 1989 | |
| 1990 | if (time_after_eq(jiffies, wtime)) |
| 1991 | break; |
| 1992 | |
| 1993 | /* Delay for a while */ |
| 1994 | msleep(500); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1995 | } while (1); |
| 1996 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1997 | ql_dbg(ql_dbg_taskm, vha, 0x803a, |
| 1998 | "fw_state=%x (%x, %x, %x, %x) " "curr time=%lx.\n", state[0], |
| 1999 | state[1], state[2], state[3], state[4], jiffies); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2000 | |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 2001 | if (rval && !(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2002 | ql_log(ql_log_warn, vha, 0x803b, |
| 2003 | "Firmware ready **** FAILED ****.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2004 | } |
| 2005 | |
| 2006 | return (rval); |
| 2007 | } |
| 2008 | |
| 2009 | /* |
| 2010 | * qla2x00_configure_hba |
| 2011 | * Setup adapter context. |
| 2012 | * |
| 2013 | * Input: |
| 2014 | * ha = adapter state pointer. |
| 2015 | * |
| 2016 | * Returns: |
| 2017 | * 0 = success |
| 2018 | * |
| 2019 | * Context: |
| 2020 | * Kernel context. |
| 2021 | */ |
| 2022 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2023 | qla2x00_configure_hba(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2024 | { |
| 2025 | int rval; |
| 2026 | uint16_t loop_id; |
| 2027 | uint16_t topo; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2028 | uint16_t sw_cap; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2029 | uint8_t al_pa; |
| 2030 | uint8_t area; |
| 2031 | uint8_t domain; |
| 2032 | char connect_type[22]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2033 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2034 | |
| 2035 | /* Get host addresses. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2036 | rval = qla2x00_get_adapter_id(vha, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2037 | &loop_id, &al_pa, &area, &domain, &topo, &sw_cap); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2038 | if (rval != QLA_SUCCESS) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2039 | if (LOOP_TRANSITION(vha) || atomic_read(&ha->loop_down_timer) || |
Andrew Vasquez | 7a44b86 | 2010-12-21 16:00:23 -0800 | [diff] [blame] | 2040 | IS_QLA8XXX_TYPE(ha) || |
Ravi Anand | 33135aa | 2005-11-08 14:37:20 -0800 | [diff] [blame] | 2041 | (rval == QLA_COMMAND_ERROR && loop_id == 0x7)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2042 | ql_dbg(ql_dbg_disc, vha, 0x2008, |
| 2043 | "Loop is in a transition state.\n"); |
Ravi Anand | 33135aa | 2005-11-08 14:37:20 -0800 | [diff] [blame] | 2044 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2045 | ql_log(ql_log_warn, vha, 0x2009, |
| 2046 | "Unable to get host loop ID.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2047 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Ravi Anand | 33135aa | 2005-11-08 14:37:20 -0800 | [diff] [blame] | 2048 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2049 | return (rval); |
| 2050 | } |
| 2051 | |
| 2052 | if (topo == 4) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2053 | ql_log(ql_log_info, vha, 0x200a, |
| 2054 | "Cannot get topology - retrying.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2055 | return (QLA_FUNCTION_FAILED); |
| 2056 | } |
| 2057 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2058 | vha->loop_id = loop_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2059 | |
| 2060 | /* initialize */ |
| 2061 | ha->min_external_loopid = SNS_FIRST_LOOP_ID; |
| 2062 | ha->operating_mode = LOOP; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2063 | ha->switch_cap = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2064 | |
| 2065 | switch (topo) { |
| 2066 | case 0: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2067 | ql_dbg(ql_dbg_disc, vha, 0x200b, "HBA in NL topology.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2068 | ha->current_topology = ISP_CFG_NL; |
| 2069 | strcpy(connect_type, "(Loop)"); |
| 2070 | break; |
| 2071 | |
| 2072 | case 1: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2073 | ql_dbg(ql_dbg_disc, vha, 0x200c, "HBA in FL topology.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2074 | ha->switch_cap = sw_cap; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2075 | ha->current_topology = ISP_CFG_FL; |
| 2076 | strcpy(connect_type, "(FL_Port)"); |
| 2077 | break; |
| 2078 | |
| 2079 | case 2: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2080 | ql_dbg(ql_dbg_disc, vha, 0x200d, "HBA in N P2P topology.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2081 | ha->operating_mode = P2P; |
| 2082 | ha->current_topology = ISP_CFG_N; |
| 2083 | strcpy(connect_type, "(N_Port-to-N_Port)"); |
| 2084 | break; |
| 2085 | |
| 2086 | case 3: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2087 | ql_dbg(ql_dbg_disc, vha, 0x200e, "HBA in F P2P topology.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2088 | ha->switch_cap = sw_cap; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2089 | ha->operating_mode = P2P; |
| 2090 | ha->current_topology = ISP_CFG_F; |
| 2091 | strcpy(connect_type, "(F_Port)"); |
| 2092 | break; |
| 2093 | |
| 2094 | default: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2095 | ql_dbg(ql_dbg_disc, vha, 0x200f, |
| 2096 | "HBA in unknown topology %x, using NL.\n", topo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2097 | ha->current_topology = ISP_CFG_NL; |
| 2098 | strcpy(connect_type, "(Loop)"); |
| 2099 | break; |
| 2100 | } |
| 2101 | |
| 2102 | /* Save Host port and loop ID. */ |
| 2103 | /* byte order - Big Endian */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2104 | vha->d_id.b.domain = domain; |
| 2105 | vha->d_id.b.area = area; |
| 2106 | vha->d_id.b.al_pa = al_pa; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2107 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2108 | if (!vha->flags.init_done) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2109 | ql_log(ql_log_info, vha, 0x2010, |
| 2110 | "Topology - %s, Host Loop address 0x%x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2111 | connect_type, vha->loop_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2112 | |
| 2113 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2114 | ql_log(ql_log_warn, vha, 0x2011, |
| 2115 | "%s FAILED\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2116 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2117 | ql_dbg(ql_dbg_disc, vha, 0x2012, |
| 2118 | "%s success\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2119 | } |
| 2120 | |
| 2121 | return(rval); |
| 2122 | } |
| 2123 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2124 | inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2125 | qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len, |
| 2126 | char *def) |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2127 | { |
| 2128 | char *st, *en; |
| 2129 | uint16_t index; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2130 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | ab67114 | 2009-08-25 11:36:17 -0700 | [diff] [blame] | 2131 | int use_tbl = !IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha) && |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2132 | !IS_QLA8XXX_TYPE(ha); |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2133 | |
| 2134 | if (memcmp(model, BINZERO, len) != 0) { |
| 2135 | strncpy(ha->model_number, model, len); |
| 2136 | st = en = ha->model_number; |
| 2137 | en += len - 1; |
| 2138 | while (en > st) { |
| 2139 | if (*en != 0x20 && *en != 0x00) |
| 2140 | break; |
| 2141 | *en-- = '\0'; |
| 2142 | } |
| 2143 | |
| 2144 | index = (ha->pdev->subsystem_device & 0xff); |
Andrew Vasquez | 7d0dba1 | 2009-04-06 22:33:45 -0700 | [diff] [blame] | 2145 | if (use_tbl && |
| 2146 | ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2147 | index < QLA_MODEL_NAMES) |
Joe Carnuccio | 1ee2714 | 2008-07-10 16:55:53 -0700 | [diff] [blame] | 2148 | strncpy(ha->model_desc, |
| 2149 | qla2x00_model_name[index * 2 + 1], |
| 2150 | sizeof(ha->model_desc) - 1); |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2151 | } else { |
| 2152 | index = (ha->pdev->subsystem_device & 0xff); |
Andrew Vasquez | 7d0dba1 | 2009-04-06 22:33:45 -0700 | [diff] [blame] | 2153 | if (use_tbl && |
| 2154 | ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2155 | index < QLA_MODEL_NAMES) { |
| 2156 | strcpy(ha->model_number, |
| 2157 | qla2x00_model_name[index * 2]); |
Joe Carnuccio | 1ee2714 | 2008-07-10 16:55:53 -0700 | [diff] [blame] | 2158 | strncpy(ha->model_desc, |
| 2159 | qla2x00_model_name[index * 2 + 1], |
| 2160 | sizeof(ha->model_desc) - 1); |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2161 | } else { |
| 2162 | strcpy(ha->model_number, def); |
| 2163 | } |
| 2164 | } |
Joe Carnuccio | 1ee2714 | 2008-07-10 16:55:53 -0700 | [diff] [blame] | 2165 | if (IS_FWI2_CAPABLE(ha)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2166 | qla2xxx_get_vpd_field(vha, "\x82", ha->model_desc, |
Joe Carnuccio | 1ee2714 | 2008-07-10 16:55:53 -0700 | [diff] [blame] | 2167 | sizeof(ha->model_desc)); |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2168 | } |
| 2169 | |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2170 | /* On sparc systems, obtain port and node WWN from firmware |
| 2171 | * properties. |
| 2172 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2173 | static void qla2xxx_nvram_wwn_from_ofw(scsi_qla_host_t *vha, nvram_t *nv) |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2174 | { |
| 2175 | #ifdef CONFIG_SPARC |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2176 | struct qla_hw_data *ha = vha->hw; |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2177 | struct pci_dev *pdev = ha->pdev; |
David S. Miller | 15576bc | 2007-05-08 00:36:49 -0700 | [diff] [blame] | 2178 | struct device_node *dp = pci_device_to_OF_node(pdev); |
| 2179 | const u8 *val; |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2180 | int len; |
| 2181 | |
| 2182 | val = of_get_property(dp, "port-wwn", &len); |
| 2183 | if (val && len >= WWN_SIZE) |
| 2184 | memcpy(nv->port_name, val, WWN_SIZE); |
| 2185 | |
| 2186 | val = of_get_property(dp, "node-wwn", &len); |
| 2187 | if (val && len >= WWN_SIZE) |
| 2188 | memcpy(nv->node_name, val, WWN_SIZE); |
| 2189 | #endif |
| 2190 | } |
| 2191 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2192 | /* |
| 2193 | * NVRAM configuration for ISP 2xxx |
| 2194 | * |
| 2195 | * Input: |
| 2196 | * ha = adapter block pointer. |
| 2197 | * |
| 2198 | * Output: |
| 2199 | * initialization control block in response_ring |
| 2200 | * host adapters parameters in host adapter block |
| 2201 | * |
| 2202 | * Returns: |
| 2203 | * 0 = success. |
| 2204 | */ |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2205 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2206 | qla2x00_nvram_config(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2207 | { |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2208 | int rval; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2209 | uint8_t chksum = 0; |
| 2210 | uint16_t cnt; |
| 2211 | uint8_t *dptr1, *dptr2; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2212 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2213 | init_cb_t *icb = ha->init_cb; |
Seokmann Ju | 281afe1 | 2007-07-26 13:43:34 -0700 | [diff] [blame] | 2214 | nvram_t *nv = ha->nvram; |
| 2215 | uint8_t *ptr = ha->nvram; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 2216 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2217 | |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2218 | rval = QLA_SUCCESS; |
| 2219 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2220 | /* Determine NVRAM starting address. */ |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2221 | ha->nvram_size = sizeof(nvram_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2222 | ha->nvram_base = 0; |
| 2223 | if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && !IS_QLA2300(ha)) |
| 2224 | if ((RD_REG_WORD(®->ctrl_status) >> 14) == 1) |
| 2225 | ha->nvram_base = 0x80; |
| 2226 | |
| 2227 | /* Get NVRAM data and calculate checksum. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2228 | ha->isp_ops->read_nvram(vha, ptr, ha->nvram_base, ha->nvram_size); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2229 | for (cnt = 0, chksum = 0; cnt < ha->nvram_size; cnt++) |
| 2230 | chksum += *ptr++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2231 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2232 | ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x010f, |
| 2233 | "Contents of NVRAM.\n"); |
| 2234 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0110, |
| 2235 | (uint8_t *)nv, ha->nvram_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2236 | |
| 2237 | /* Bad NVRAM data, set defaults parameters. */ |
| 2238 | if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || |
| 2239 | nv->id[2] != 'P' || nv->id[3] != ' ' || nv->nvram_version < 1) { |
| 2240 | /* Reset NVRAM data. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2241 | ql_log(ql_log_warn, vha, 0x0064, |
| 2242 | "Inconisistent NVRAM " |
| 2243 | "detected: checksum=0x%x id=%c version=0x%x.\n", |
| 2244 | chksum, nv->id[0], nv->nvram_version); |
| 2245 | ql_log(ql_log_warn, vha, 0x0065, |
| 2246 | "Falling back to " |
| 2247 | "functioning (yet invalid -- WWPN) defaults.\n"); |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2248 | |
| 2249 | /* |
| 2250 | * Set default initialization control block. |
| 2251 | */ |
| 2252 | memset(nv, 0, ha->nvram_size); |
| 2253 | nv->parameter_block_version = ICB_VERSION; |
| 2254 | |
| 2255 | if (IS_QLA23XX(ha)) { |
| 2256 | nv->firmware_options[0] = BIT_2 | BIT_1; |
| 2257 | nv->firmware_options[1] = BIT_7 | BIT_5; |
| 2258 | nv->add_firmware_options[0] = BIT_5; |
| 2259 | nv->add_firmware_options[1] = BIT_5 | BIT_4; |
| 2260 | nv->frame_payload_size = __constant_cpu_to_le16(2048); |
| 2261 | nv->special_options[1] = BIT_7; |
| 2262 | } else if (IS_QLA2200(ha)) { |
| 2263 | nv->firmware_options[0] = BIT_2 | BIT_1; |
| 2264 | nv->firmware_options[1] = BIT_7 | BIT_5; |
| 2265 | nv->add_firmware_options[0] = BIT_5; |
| 2266 | nv->add_firmware_options[1] = BIT_5 | BIT_4; |
| 2267 | nv->frame_payload_size = __constant_cpu_to_le16(1024); |
| 2268 | } else if (IS_QLA2100(ha)) { |
| 2269 | nv->firmware_options[0] = BIT_3 | BIT_1; |
| 2270 | nv->firmware_options[1] = BIT_5; |
| 2271 | nv->frame_payload_size = __constant_cpu_to_le16(1024); |
| 2272 | } |
| 2273 | |
| 2274 | nv->max_iocb_allocation = __constant_cpu_to_le16(256); |
| 2275 | nv->execution_throttle = __constant_cpu_to_le16(16); |
| 2276 | nv->retry_count = 8; |
| 2277 | nv->retry_delay = 1; |
| 2278 | |
| 2279 | nv->port_name[0] = 33; |
| 2280 | nv->port_name[3] = 224; |
| 2281 | nv->port_name[4] = 139; |
| 2282 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2283 | qla2xxx_nvram_wwn_from_ofw(vha, nv); |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2284 | |
| 2285 | nv->login_timeout = 4; |
| 2286 | |
| 2287 | /* |
| 2288 | * Set default host adapter parameters |
| 2289 | */ |
| 2290 | nv->host_p[1] = BIT_2; |
| 2291 | nv->reset_delay = 5; |
| 2292 | nv->port_down_retry_count = 8; |
| 2293 | nv->max_luns_per_target = __constant_cpu_to_le16(8); |
| 2294 | nv->link_down_timeout = 60; |
| 2295 | |
| 2296 | rval = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2297 | } |
| 2298 | |
| 2299 | #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) |
| 2300 | /* |
| 2301 | * The SN2 does not provide BIOS emulation which means you can't change |
| 2302 | * potentially bogus BIOS settings. Force the use of default settings |
| 2303 | * for link rate and frame size. Hope that the rest of the settings |
| 2304 | * are valid. |
| 2305 | */ |
| 2306 | if (ia64_platform_is("sn2")) { |
| 2307 | nv->frame_payload_size = __constant_cpu_to_le16(2048); |
| 2308 | if (IS_QLA23XX(ha)) |
| 2309 | nv->special_options[1] = BIT_7; |
| 2310 | } |
| 2311 | #endif |
| 2312 | |
| 2313 | /* Reset Initialization control block */ |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2314 | memset(icb, 0, ha->init_cb_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2315 | |
| 2316 | /* |
| 2317 | * Setup driver NVRAM options. |
| 2318 | */ |
| 2319 | nv->firmware_options[0] |= (BIT_6 | BIT_1); |
| 2320 | nv->firmware_options[0] &= ~(BIT_5 | BIT_4); |
| 2321 | nv->firmware_options[1] |= (BIT_5 | BIT_0); |
| 2322 | nv->firmware_options[1] &= ~BIT_4; |
| 2323 | |
| 2324 | if (IS_QLA23XX(ha)) { |
| 2325 | nv->firmware_options[0] |= BIT_2; |
| 2326 | nv->firmware_options[0] &= ~BIT_3; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 2327 | nv->firmware_options[0] &= ~BIT_6; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2328 | nv->add_firmware_options[1] |= BIT_5 | BIT_4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2329 | |
| 2330 | if (IS_QLA2300(ha)) { |
| 2331 | if (ha->fb_rev == FPM_2310) { |
| 2332 | strcpy(ha->model_number, "QLA2310"); |
| 2333 | } else { |
| 2334 | strcpy(ha->model_number, "QLA2300"); |
| 2335 | } |
| 2336 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2337 | qla2x00_set_model_info(vha, nv->model_number, |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2338 | sizeof(nv->model_number), "QLA23xx"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2339 | } |
| 2340 | } else if (IS_QLA2200(ha)) { |
| 2341 | nv->firmware_options[0] |= BIT_2; |
| 2342 | /* |
| 2343 | * 'Point-to-point preferred, else loop' is not a safe |
| 2344 | * connection mode setting. |
| 2345 | */ |
| 2346 | if ((nv->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) == |
| 2347 | (BIT_5 | BIT_4)) { |
| 2348 | /* Force 'loop preferred, else point-to-point'. */ |
| 2349 | nv->add_firmware_options[0] &= ~(BIT_6 | BIT_5 | BIT_4); |
| 2350 | nv->add_firmware_options[0] |= BIT_5; |
| 2351 | } |
| 2352 | strcpy(ha->model_number, "QLA22xx"); |
| 2353 | } else /*if (IS_QLA2100(ha))*/ { |
| 2354 | strcpy(ha->model_number, "QLA2100"); |
| 2355 | } |
| 2356 | |
| 2357 | /* |
| 2358 | * Copy over NVRAM RISC parameter block to initialization control block. |
| 2359 | */ |
| 2360 | dptr1 = (uint8_t *)icb; |
| 2361 | dptr2 = (uint8_t *)&nv->parameter_block_version; |
| 2362 | cnt = (uint8_t *)&icb->request_q_outpointer - (uint8_t *)&icb->version; |
| 2363 | while (cnt--) |
| 2364 | *dptr1++ = *dptr2++; |
| 2365 | |
| 2366 | /* Copy 2nd half. */ |
| 2367 | dptr1 = (uint8_t *)icb->add_firmware_options; |
| 2368 | cnt = (uint8_t *)icb->reserved_3 - (uint8_t *)icb->add_firmware_options; |
| 2369 | while (cnt--) |
| 2370 | *dptr1++ = *dptr2++; |
| 2371 | |
Andrew Vasquez | 5341e86 | 2006-05-17 15:09:16 -0700 | [diff] [blame] | 2372 | /* Use alternate WWN? */ |
| 2373 | if (nv->host_p[1] & BIT_7) { |
| 2374 | memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); |
| 2375 | memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); |
| 2376 | } |
| 2377 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2378 | /* Prepare nodename */ |
| 2379 | if ((icb->firmware_options[1] & BIT_6) == 0) { |
| 2380 | /* |
| 2381 | * Firmware will apply the following mask if the nodename was |
| 2382 | * not provided. |
| 2383 | */ |
| 2384 | memcpy(icb->node_name, icb->port_name, WWN_SIZE); |
| 2385 | icb->node_name[0] &= 0xF0; |
| 2386 | } |
| 2387 | |
| 2388 | /* |
| 2389 | * Set host adapter parameters. |
| 2390 | */ |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 2391 | |
| 2392 | /* |
| 2393 | * BIT_7 in the host-parameters section allows for modification to |
| 2394 | * internal driver logging. |
| 2395 | */ |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 2396 | if (nv->host_p[0] & BIT_7) |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 2397 | ql2xextended_error_logging = QL_DBG_DEFAULT1_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2398 | ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0); |
| 2399 | /* Always load RISC code on non ISP2[12]00 chips. */ |
| 2400 | if (!IS_QLA2100(ha) && !IS_QLA2200(ha)) |
| 2401 | ha->flags.disable_risc_code_load = 0; |
| 2402 | ha->flags.enable_lip_reset = ((nv->host_p[1] & BIT_1) ? 1 : 0); |
| 2403 | ha->flags.enable_lip_full_login = ((nv->host_p[1] & BIT_2) ? 1 : 0); |
| 2404 | ha->flags.enable_target_reset = ((nv->host_p[1] & BIT_3) ? 1 : 0); |
Andrew Vasquez | 06c22bd | 2005-08-26 19:09:00 -0700 | [diff] [blame] | 2405 | ha->flags.enable_led_scheme = (nv->special_options[1] & BIT_4) ? 1 : 0; |
Andrew Vasquez | d4c760c | 2006-06-23 16:10:39 -0700 | [diff] [blame] | 2406 | ha->flags.disable_serdes = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2407 | |
| 2408 | ha->operating_mode = |
| 2409 | (icb->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) >> 4; |
| 2410 | |
| 2411 | memcpy(ha->fw_seriallink_options, nv->seriallink_options, |
| 2412 | sizeof(ha->fw_seriallink_options)); |
| 2413 | |
| 2414 | /* save HBA serial number */ |
| 2415 | ha->serial0 = icb->port_name[5]; |
| 2416 | ha->serial1 = icb->port_name[6]; |
| 2417 | ha->serial2 = icb->port_name[7]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2418 | memcpy(vha->node_name, icb->node_name, WWN_SIZE); |
| 2419 | memcpy(vha->port_name, icb->port_name, WWN_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2420 | |
| 2421 | icb->execution_throttle = __constant_cpu_to_le16(0xFFFF); |
| 2422 | |
| 2423 | ha->retry_count = nv->retry_count; |
| 2424 | |
| 2425 | /* Set minimum login_timeout to 4 seconds. */ |
Andrew Vasquez | 5b91490 | 2010-05-28 15:08:30 -0700 | [diff] [blame] | 2426 | if (nv->login_timeout != ql2xlogintimeout) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2427 | nv->login_timeout = ql2xlogintimeout; |
| 2428 | if (nv->login_timeout < 4) |
| 2429 | nv->login_timeout = 4; |
| 2430 | ha->login_timeout = nv->login_timeout; |
| 2431 | icb->login_timeout = nv->login_timeout; |
| 2432 | |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 2433 | /* Set minimum RATOV to 100 tenths of a second. */ |
| 2434 | ha->r_a_tov = 100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2435 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2436 | ha->loop_reset_delay = nv->reset_delay; |
| 2437 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2438 | /* Link Down Timeout = 0: |
| 2439 | * |
| 2440 | * When Port Down timer expires we will start returning |
| 2441 | * I/O's to OS with "DID_NO_CONNECT". |
| 2442 | * |
| 2443 | * Link Down Timeout != 0: |
| 2444 | * |
| 2445 | * The driver waits for the link to come up after link down |
| 2446 | * before returning I/Os to OS with "DID_NO_CONNECT". |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2447 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2448 | if (nv->link_down_timeout == 0) { |
| 2449 | ha->loop_down_abort_time = |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 2450 | (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2451 | } else { |
| 2452 | ha->link_down_timeout = nv->link_down_timeout; |
| 2453 | ha->loop_down_abort_time = |
| 2454 | (LOOP_DOWN_TIME - ha->link_down_timeout); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2455 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2456 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2457 | /* |
| 2458 | * Need enough time to try and get the port back. |
| 2459 | */ |
| 2460 | ha->port_down_retry_count = nv->port_down_retry_count; |
| 2461 | if (qlport_down_retry) |
| 2462 | ha->port_down_retry_count = qlport_down_retry; |
| 2463 | /* Set login_retry_count */ |
| 2464 | ha->login_retry_count = nv->retry_count; |
| 2465 | if (ha->port_down_retry_count == nv->port_down_retry_count && |
| 2466 | ha->port_down_retry_count > 3) |
| 2467 | ha->login_retry_count = ha->port_down_retry_count; |
| 2468 | else if (ha->port_down_retry_count > (int)ha->login_retry_count) |
| 2469 | ha->login_retry_count = ha->port_down_retry_count; |
| 2470 | if (ql2xloginretrycount) |
| 2471 | ha->login_retry_count = ql2xloginretrycount; |
| 2472 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2473 | icb->lun_enables = __constant_cpu_to_le16(0); |
| 2474 | icb->command_resource_count = 0; |
| 2475 | icb->immediate_notify_resource_count = 0; |
| 2476 | icb->timeout = __constant_cpu_to_le16(0); |
| 2477 | |
| 2478 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
| 2479 | /* Enable RIO */ |
| 2480 | icb->firmware_options[0] &= ~BIT_3; |
| 2481 | icb->add_firmware_options[0] &= |
| 2482 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0); |
| 2483 | icb->add_firmware_options[0] |= BIT_2; |
| 2484 | icb->response_accumulation_timer = 3; |
| 2485 | icb->interrupt_delay_timer = 5; |
| 2486 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2487 | vha->flags.process_response_queue = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2488 | } else { |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 2489 | /* Enable ZIO. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2490 | if (!vha->flags.init_done) { |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 2491 | ha->zio_mode = icb->add_firmware_options[0] & |
| 2492 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
| 2493 | ha->zio_timer = icb->interrupt_delay_timer ? |
| 2494 | icb->interrupt_delay_timer: 2; |
| 2495 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2496 | icb->add_firmware_options[0] &= |
| 2497 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2498 | vha->flags.process_response_queue = 0; |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 2499 | if (ha->zio_mode != QLA_ZIO_DISABLED) { |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2500 | ha->zio_mode = QLA_ZIO_MODE_6; |
| 2501 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2502 | ql_log(ql_log_info, vha, 0x0068, |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 2503 | "ZIO mode %d enabled; timer delay (%d us).\n", |
| 2504 | ha->zio_mode, ha->zio_timer * 100); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2505 | |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 2506 | icb->add_firmware_options[0] |= (uint8_t)ha->zio_mode; |
| 2507 | icb->interrupt_delay_timer = (uint8_t)ha->zio_timer; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2508 | vha->flags.process_response_queue = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2509 | } |
| 2510 | } |
| 2511 | |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2512 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2513 | ql_log(ql_log_warn, vha, 0x0069, |
| 2514 | "NVRAM configuration failed.\n"); |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2515 | } |
| 2516 | return (rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2517 | } |
| 2518 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 2519 | static void |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 2520 | qla2x00_rport_del(void *data) |
| 2521 | { |
| 2522 | fc_port_t *fcport = data; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2523 | struct fc_rport *rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2524 | unsigned long flags; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 2525 | |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2526 | spin_lock_irqsave(fcport->vha->host->host_lock, flags); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 2527 | rport = fcport->drport ? fcport->drport: fcport->rport; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2528 | fcport->drport = NULL; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2529 | spin_unlock_irqrestore(fcport->vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2530 | if (rport) |
| 2531 | fc_remote_port_delete(rport); |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 2532 | } |
| 2533 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2534 | /** |
| 2535 | * qla2x00_alloc_fcport() - Allocate a generic fcport. |
| 2536 | * @ha: HA context |
| 2537 | * @flags: allocation flags |
| 2538 | * |
| 2539 | * Returns a pointer to the allocated fcport, or NULL, if none available. |
| 2540 | */ |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 2541 | fc_port_t * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2542 | qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2543 | { |
| 2544 | fc_port_t *fcport; |
| 2545 | |
Mariusz Kozlowski | bbfbbbc | 2007-08-11 10:13:24 +0200 | [diff] [blame] | 2546 | fcport = kzalloc(sizeof(fc_port_t), flags); |
| 2547 | if (!fcport) |
| 2548 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2549 | |
| 2550 | /* Setup fcport template structure. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2551 | fcport->vha = vha; |
| 2552 | fcport->vp_idx = vha->vp_idx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2553 | fcport->port_type = FCT_UNKNOWN; |
| 2554 | fcport->loop_id = FC_NO_LOOP_ID; |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 2555 | qla2x00_set_fcport_state(fcport, FCS_UNCONFIGURED); |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2556 | fcport->supported_classes = FC_COS_UNSPECIFIED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2557 | |
Mariusz Kozlowski | bbfbbbc | 2007-08-11 10:13:24 +0200 | [diff] [blame] | 2558 | return fcport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2559 | } |
| 2560 | |
| 2561 | /* |
| 2562 | * qla2x00_configure_loop |
| 2563 | * Updates Fibre Channel Device Database with what is actually on loop. |
| 2564 | * |
| 2565 | * Input: |
| 2566 | * ha = adapter block pointer. |
| 2567 | * |
| 2568 | * Returns: |
| 2569 | * 0 = success. |
| 2570 | * 1 = error. |
| 2571 | * 2 = database was full and device was not configured. |
| 2572 | */ |
| 2573 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2574 | qla2x00_configure_loop(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2575 | { |
| 2576 | int rval; |
| 2577 | unsigned long flags, save_flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2578 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2579 | rval = QLA_SUCCESS; |
| 2580 | |
| 2581 | /* Get Initiator ID */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2582 | if (test_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags)) { |
| 2583 | rval = qla2x00_configure_hba(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2584 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2585 | ql_dbg(ql_dbg_disc, vha, 0x2013, |
| 2586 | "Unable to configure HBA.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2587 | return (rval); |
| 2588 | } |
| 2589 | } |
| 2590 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2591 | save_flags = flags = vha->dpc_flags; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2592 | ql_dbg(ql_dbg_disc, vha, 0x2014, |
| 2593 | "Configure loop -- dpc flags = 0x%lx.\n", flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2594 | |
| 2595 | /* |
| 2596 | * If we have both an RSCN and PORT UPDATE pending then handle them |
| 2597 | * both at the same time. |
| 2598 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2599 | clear_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2600 | clear_bit(RSCN_UPDATE, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2601 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 2602 | qla2x00_get_data_rate(vha); |
| 2603 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2604 | /* Determine what we need to do */ |
| 2605 | if (ha->current_topology == ISP_CFG_FL && |
| 2606 | (test_bit(LOCAL_LOOP_UPDATE, &flags))) { |
| 2607 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2608 | vha->flags.rscn_queue_overflow = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2609 | set_bit(RSCN_UPDATE, &flags); |
| 2610 | |
| 2611 | } else if (ha->current_topology == ISP_CFG_F && |
| 2612 | (test_bit(LOCAL_LOOP_UPDATE, &flags))) { |
| 2613 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2614 | vha->flags.rscn_queue_overflow = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2615 | set_bit(RSCN_UPDATE, &flags); |
| 2616 | clear_bit(LOCAL_LOOP_UPDATE, &flags); |
| 2617 | |
Andrew Vasquez | 21333b4 | 2006-05-17 15:09:56 -0700 | [diff] [blame] | 2618 | } else if (ha->current_topology == ISP_CFG_N) { |
| 2619 | clear_bit(RSCN_UPDATE, &flags); |
| 2620 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2621 | } else if (!vha->flags.online || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2622 | (test_bit(ABORT_ISP_ACTIVE, &flags))) { |
| 2623 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2624 | vha->flags.rscn_queue_overflow = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2625 | set_bit(RSCN_UPDATE, &flags); |
| 2626 | set_bit(LOCAL_LOOP_UPDATE, &flags); |
| 2627 | } |
| 2628 | |
| 2629 | if (test_bit(LOCAL_LOOP_UPDATE, &flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2630 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { |
| 2631 | ql_dbg(ql_dbg_disc, vha, 0x2015, |
| 2632 | "Loop resync needed, failing.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2633 | rval = QLA_FUNCTION_FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2634 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2635 | else |
| 2636 | rval = qla2x00_configure_local_loop(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2637 | } |
| 2638 | |
| 2639 | if (rval == QLA_SUCCESS && test_bit(RSCN_UPDATE, &flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2640 | if (LOOP_TRANSITION(vha)) { |
| 2641 | ql_dbg(ql_dbg_disc, vha, 0x201e, |
| 2642 | "Needs RSCN update and loop transition.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2643 | rval = QLA_FUNCTION_FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2644 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2645 | else |
| 2646 | rval = qla2x00_configure_fabric(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2647 | } |
| 2648 | |
| 2649 | if (rval == QLA_SUCCESS) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2650 | if (atomic_read(&vha->loop_down_timer) || |
| 2651 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2652 | rval = QLA_FUNCTION_FAILED; |
| 2653 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2654 | atomic_set(&vha->loop_state, LOOP_READY); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2655 | ql_dbg(ql_dbg_disc, vha, 0x2069, |
| 2656 | "LOOP READY.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2657 | } |
| 2658 | } |
| 2659 | |
| 2660 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2661 | ql_dbg(ql_dbg_disc, vha, 0x206a, |
| 2662 | "%s *** FAILED ***.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2663 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2664 | ql_dbg(ql_dbg_disc, vha, 0x206b, |
| 2665 | "%s: exiting normally.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2666 | } |
| 2667 | |
Bjorn Helgaas | cc3ef7b | 2008-09-11 21:22:51 -0700 | [diff] [blame] | 2668 | /* Restore state if a resync event occurred during processing */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2669 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2670 | if (test_bit(LOCAL_LOOP_UPDATE, &save_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2671 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
Andrew Vasquez | f4658b6 | 2009-06-03 09:55:21 -0700 | [diff] [blame] | 2672 | if (test_bit(RSCN_UPDATE, &save_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2673 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
Giridhar Malavali | 3a6478d | 2010-05-28 15:08:20 -0700 | [diff] [blame] | 2674 | if (!IS_ALOGIO_CAPABLE(ha)) |
| 2675 | vha->flags.rscn_queue_overflow = 1; |
Andrew Vasquez | f4658b6 | 2009-06-03 09:55:21 -0700 | [diff] [blame] | 2676 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2677 | } |
| 2678 | |
| 2679 | return (rval); |
| 2680 | } |
| 2681 | |
| 2682 | |
| 2683 | |
| 2684 | /* |
| 2685 | * qla2x00_configure_local_loop |
| 2686 | * Updates Fibre Channel Device Database with local loop devices. |
| 2687 | * |
| 2688 | * Input: |
| 2689 | * ha = adapter block pointer. |
| 2690 | * |
| 2691 | * Returns: |
| 2692 | * 0 = success. |
| 2693 | */ |
| 2694 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2695 | qla2x00_configure_local_loop(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2696 | { |
| 2697 | int rval, rval2; |
| 2698 | int found_devs; |
| 2699 | int found; |
| 2700 | fc_port_t *fcport, *new_fcport; |
| 2701 | |
| 2702 | uint16_t index; |
| 2703 | uint16_t entries; |
| 2704 | char *id_iter; |
| 2705 | uint16_t loop_id; |
| 2706 | uint8_t domain, area, al_pa; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2707 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2708 | |
| 2709 | found_devs = 0; |
| 2710 | new_fcport = NULL; |
| 2711 | entries = MAX_FIBRE_DEVICES; |
| 2712 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2713 | ql_dbg(ql_dbg_disc, vha, 0x2016, |
| 2714 | "Getting FCAL position map.\n"); |
| 2715 | if (ql2xextended_error_logging & ql_dbg_disc) |
| 2716 | qla2x00_get_fcal_position_map(vha, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2717 | |
| 2718 | /* Get list of logged in devices. */ |
| 2719 | memset(ha->gid_list, 0, GID_LIST_SIZE); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2720 | rval = qla2x00_get_id_list(vha, ha->gid_list, ha->gid_list_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2721 | &entries); |
| 2722 | if (rval != QLA_SUCCESS) |
| 2723 | goto cleanup_allocation; |
| 2724 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2725 | ql_dbg(ql_dbg_disc, vha, 0x2017, |
| 2726 | "Entries in ID list (%d).\n", entries); |
| 2727 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2075, |
| 2728 | (uint8_t *)ha->gid_list, |
| 2729 | entries * sizeof(struct gid_list_info)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2730 | |
| 2731 | /* Allocate temporary fcport for any new fcports discovered. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2732 | new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2733 | if (new_fcport == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2734 | ql_log(ql_log_warn, vha, 0x2018, |
| 2735 | "Memory allocation failed for fcport.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2736 | rval = QLA_MEMORY_ALLOC_FAILED; |
| 2737 | goto cleanup_allocation; |
| 2738 | } |
| 2739 | new_fcport->flags &= ~FCF_FABRIC_DEVICE; |
| 2740 | |
| 2741 | /* |
| 2742 | * Mark local devices that were present with FCF_DEVICE_LOST for now. |
| 2743 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2744 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2745 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
| 2746 | fcport->port_type != FCT_BROADCAST && |
| 2747 | (fcport->flags & FCF_FABRIC_DEVICE) == 0) { |
| 2748 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2749 | ql_dbg(ql_dbg_disc, vha, 0x2019, |
| 2750 | "Marking port lost loop_id=0x%04x.\n", |
| 2751 | fcport->loop_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2752 | |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 2753 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2754 | } |
| 2755 | } |
| 2756 | |
| 2757 | /* Add devices to port list. */ |
| 2758 | id_iter = (char *)ha->gid_list; |
| 2759 | for (index = 0; index < entries; index++) { |
| 2760 | domain = ((struct gid_list_info *)id_iter)->domain; |
| 2761 | area = ((struct gid_list_info *)id_iter)->area; |
| 2762 | al_pa = ((struct gid_list_info *)id_iter)->al_pa; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2763 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2764 | loop_id = (uint16_t) |
| 2765 | ((struct gid_list_info *)id_iter)->loop_id_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2766 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2767 | loop_id = le16_to_cpu( |
| 2768 | ((struct gid_list_info *)id_iter)->loop_id); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2769 | id_iter += ha->gid_list_info_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2770 | |
| 2771 | /* Bypass reserved domain fields. */ |
| 2772 | if ((domain & 0xf0) == 0xf0) |
| 2773 | continue; |
| 2774 | |
| 2775 | /* Bypass if not same domain and area of adapter. */ |
Andrew Vasquez | f7d289f | 2005-08-26 19:08:40 -0700 | [diff] [blame] | 2776 | if (area && domain && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2777 | (area != vha->d_id.b.area || domain != vha->d_id.b.domain)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2778 | continue; |
| 2779 | |
| 2780 | /* Bypass invalid local loop ID. */ |
| 2781 | if (loop_id > LAST_LOCAL_LOOP_ID) |
| 2782 | continue; |
| 2783 | |
| 2784 | /* Fill in member data. */ |
| 2785 | new_fcport->d_id.b.domain = domain; |
| 2786 | new_fcport->d_id.b.area = area; |
| 2787 | new_fcport->d_id.b.al_pa = al_pa; |
| 2788 | new_fcport->loop_id = loop_id; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2789 | new_fcport->vp_idx = vha->vp_idx; |
| 2790 | rval2 = qla2x00_get_port_database(vha, new_fcport, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2791 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2792 | ql_dbg(ql_dbg_disc, vha, 0x201a, |
| 2793 | "Failed to retrieve fcport information " |
| 2794 | "-- get_port_database=%x, loop_id=0x%04x.\n", |
| 2795 | rval2, new_fcport->loop_id); |
| 2796 | ql_dbg(ql_dbg_disc, vha, 0x201b, |
| 2797 | "Scheduling resync.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2798 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2799 | continue; |
| 2800 | } |
| 2801 | |
| 2802 | /* Check for matching device in port list. */ |
| 2803 | found = 0; |
| 2804 | fcport = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2805 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2806 | if (memcmp(new_fcport->port_name, fcport->port_name, |
| 2807 | WWN_SIZE)) |
| 2808 | continue; |
| 2809 | |
Shyam Sundar | ddb9b12 | 2009-03-24 09:08:10 -0700 | [diff] [blame] | 2810 | fcport->flags &= ~FCF_FABRIC_DEVICE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2811 | fcport->loop_id = new_fcport->loop_id; |
| 2812 | fcport->port_type = new_fcport->port_type; |
| 2813 | fcport->d_id.b24 = new_fcport->d_id.b24; |
| 2814 | memcpy(fcport->node_name, new_fcport->node_name, |
| 2815 | WWN_SIZE); |
| 2816 | |
| 2817 | found++; |
| 2818 | break; |
| 2819 | } |
| 2820 | |
| 2821 | if (!found) { |
| 2822 | /* New device, add to fcports list. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2823 | if (vha->vp_idx) { |
| 2824 | new_fcport->vha = vha; |
| 2825 | new_fcport->vp_idx = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2826 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2827 | list_add_tail(&new_fcport->list, &vha->vp_fcports); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2828 | |
| 2829 | /* Allocate a new replacement fcport. */ |
| 2830 | fcport = new_fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2831 | new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2832 | if (new_fcport == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2833 | ql_log(ql_log_warn, vha, 0x201c, |
| 2834 | "Failed to allocate memory for fcport.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2835 | rval = QLA_MEMORY_ALLOC_FAILED; |
| 2836 | goto cleanup_allocation; |
| 2837 | } |
| 2838 | new_fcport->flags &= ~FCF_FABRIC_DEVICE; |
| 2839 | } |
| 2840 | |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2841 | /* Base iIDMA settings on HBA port speed. */ |
Andrew Vasquez | a3cbdfa | 2007-08-13 10:13:18 -0700 | [diff] [blame] | 2842 | fcport->fp_speed = ha->link_data_rate; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2843 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2844 | qla2x00_update_fcport(vha, fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2845 | |
| 2846 | found_devs++; |
| 2847 | } |
| 2848 | |
| 2849 | cleanup_allocation: |
Jesper Juhl | c9475cb | 2005-11-07 01:01:26 -0800 | [diff] [blame] | 2850 | kfree(new_fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2851 | |
| 2852 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2853 | ql_dbg(ql_dbg_disc, vha, 0x201d, |
| 2854 | "Configure local loop error exit: rval=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2855 | } |
| 2856 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2857 | return (rval); |
| 2858 | } |
| 2859 | |
| 2860 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2861 | qla2x00_iidma_fcport(scsi_qla_host_t *vha, fc_port_t *fcport) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2862 | { |
| 2863 | #define LS_UNKNOWN 2 |
Andrew Vasquez | 9f8fdde | 2009-06-03 09:55:22 -0700 | [diff] [blame] | 2864 | static char *link_speeds[] = { "1", "2", "?", "4", "8", "10" }; |
| 2865 | char *link_speed; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2866 | int rval; |
Harish Zunjarrao | 1bb3954 | 2009-06-17 10:30:29 -0700 | [diff] [blame] | 2867 | uint16_t mb[4]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2868 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2869 | |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2870 | if (!IS_IIDMA_CAPABLE(ha)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2871 | return; |
| 2872 | |
Giridhar Malavali | c9afb9a | 2010-09-03 15:20:48 -0700 | [diff] [blame] | 2873 | if (atomic_read(&fcport->state) != FCS_ONLINE) |
| 2874 | return; |
| 2875 | |
Andrew Vasquez | 39bd962 | 2007-09-20 14:07:34 -0700 | [diff] [blame] | 2876 | if (fcport->fp_speed == PORT_SPEED_UNKNOWN || |
| 2877 | fcport->fp_speed > ha->link_data_rate) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2878 | return; |
| 2879 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2880 | rval = qla2x00_set_idma_speed(vha, fcport->loop_id, fcport->fp_speed, |
Andrew Vasquez | a3cbdfa | 2007-08-13 10:13:18 -0700 | [diff] [blame] | 2881 | mb); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2882 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2883 | ql_dbg(ql_dbg_disc, vha, 0x2004, |
| 2884 | "Unable to adjust iIDMA " |
| 2885 | "%02x%02x%02x%02x%02x%02x%02x%02x -- %04x %x %04x " |
| 2886 | "%04x.\n", fcport->port_name[0], fcport->port_name[1], |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2887 | fcport->port_name[2], fcport->port_name[3], |
| 2888 | fcport->port_name[4], fcport->port_name[5], |
| 2889 | fcport->port_name[6], fcport->port_name[7], rval, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2890 | fcport->fp_speed, mb[0], mb[1]); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2891 | } else { |
Andrew Vasquez | 9f8fdde | 2009-06-03 09:55:22 -0700 | [diff] [blame] | 2892 | link_speed = link_speeds[LS_UNKNOWN]; |
| 2893 | if (fcport->fp_speed < 5) |
| 2894 | link_speed = link_speeds[fcport->fp_speed]; |
| 2895 | else if (fcport->fp_speed == 0x13) |
| 2896 | link_speed = link_speeds[5]; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2897 | ql_dbg(ql_dbg_disc, vha, 0x2005, |
| 2898 | "iIDMA adjusted to %s GB/s " |
| 2899 | "on %02x%02x%02x%02x%02x%02x%02x%02x.\n", link_speed, |
| 2900 | fcport->port_name[0], fcport->port_name[1], |
| 2901 | fcport->port_name[2], fcport->port_name[3], |
| 2902 | fcport->port_name[4], fcport->port_name[5], |
| 2903 | fcport->port_name[6], fcport->port_name[7]); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2904 | } |
| 2905 | } |
| 2906 | |
Adrian Bunk | 23be331 | 2006-11-24 02:46:01 +0100 | [diff] [blame] | 2907 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2908 | qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport) |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2909 | { |
| 2910 | struct fc_rport_identifiers rport_ids; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 2911 | struct fc_rport *rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2912 | unsigned long flags; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2913 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 2914 | qla2x00_rport_del(fcport); |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2915 | |
Andrew Vasquez | f8b02a8 | 2005-08-31 15:21:20 -0700 | [diff] [blame] | 2916 | rport_ids.node_name = wwn_to_u64(fcport->node_name); |
| 2917 | rport_ids.port_name = wwn_to_u64(fcport->port_name); |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2918 | rport_ids.port_id = fcport->d_id.b.domain << 16 | |
| 2919 | fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; |
| 2920 | rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2921 | fcport->rport = rport = fc_remote_port_add(vha->host, 0, &rport_ids); |
Andrew Vasquez | 77d7414 | 2005-07-08 18:00:36 -0700 | [diff] [blame] | 2922 | if (!rport) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2923 | ql_log(ql_log_warn, vha, 0x2006, |
| 2924 | "Unable to allocate fc remote port.\n"); |
Andrew Vasquez | 77d7414 | 2005-07-08 18:00:36 -0700 | [diff] [blame] | 2925 | return; |
| 2926 | } |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2927 | spin_lock_irqsave(fcport->vha->host->host_lock, flags); |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 2928 | *((fc_port_t **)rport->dd_data) = fcport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2929 | spin_unlock_irqrestore(fcport->vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2930 | |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2931 | rport->supported_classes = fcport->supported_classes; |
Andrew Vasquez | 77d7414 | 2005-07-08 18:00:36 -0700 | [diff] [blame] | 2932 | |
| 2933 | rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2934 | if (fcport->port_type == FCT_INITIATOR) |
| 2935 | rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR; |
| 2936 | if (fcport->port_type == FCT_TARGET) |
| 2937 | rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET; |
Andrew Vasquez | 77d7414 | 2005-07-08 18:00:36 -0700 | [diff] [blame] | 2938 | fc_remote_port_rolechg(rport, rport_ids.roles); |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2939 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2940 | |
| 2941 | /* |
Adrian Bunk | 23be331 | 2006-11-24 02:46:01 +0100 | [diff] [blame] | 2942 | * qla2x00_update_fcport |
| 2943 | * Updates device on list. |
| 2944 | * |
| 2945 | * Input: |
| 2946 | * ha = adapter block pointer. |
| 2947 | * fcport = port structure pointer. |
| 2948 | * |
| 2949 | * Return: |
| 2950 | * 0 - Success |
| 2951 | * BIT_0 - error |
| 2952 | * |
| 2953 | * Context: |
| 2954 | * Kernel context. |
| 2955 | */ |
| 2956 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2957 | qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport) |
Adrian Bunk | 23be331 | 2006-11-24 02:46:01 +0100 | [diff] [blame] | 2958 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2959 | fcport->vha = vha; |
Adrian Bunk | 23be331 | 2006-11-24 02:46:01 +0100 | [diff] [blame] | 2960 | fcport->login_retry = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 2961 | fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); |
Adrian Bunk | 23be331 | 2006-11-24 02:46:01 +0100 | [diff] [blame] | 2962 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2963 | qla2x00_iidma_fcport(vha, fcport); |
Madhuranath Iyengar | 21090cb | 2010-12-21 16:00:18 -0800 | [diff] [blame] | 2964 | qla24xx_update_fcport_fcp_prio(vha, fcport); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2965 | qla2x00_reg_remote_port(vha, fcport); |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 2966 | qla2x00_set_fcport_state(fcport, FCS_ONLINE); |
Adrian Bunk | 23be331 | 2006-11-24 02:46:01 +0100 | [diff] [blame] | 2967 | } |
| 2968 | |
| 2969 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2970 | * qla2x00_configure_fabric |
| 2971 | * Setup SNS devices with loop ID's. |
| 2972 | * |
| 2973 | * Input: |
| 2974 | * ha = adapter block pointer. |
| 2975 | * |
| 2976 | * Returns: |
| 2977 | * 0 = success. |
| 2978 | * BIT_0 = error |
| 2979 | */ |
| 2980 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2981 | qla2x00_configure_fabric(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2982 | { |
| 2983 | int rval, rval2; |
| 2984 | fc_port_t *fcport, *fcptemp; |
| 2985 | uint16_t next_loopid; |
| 2986 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2987 | uint16_t loop_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2988 | LIST_HEAD(new_fcports); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2989 | struct qla_hw_data *ha = vha->hw; |
| 2990 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2991 | |
| 2992 | /* If FL port exists, then SNS is present */ |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2993 | if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2994 | loop_id = NPH_F_PORT; |
| 2995 | else |
| 2996 | loop_id = SNS_FL_PORT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2997 | rval = qla2x00_get_port_name(vha, loop_id, vha->fabric_node_name, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2998 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2999 | ql_dbg(ql_dbg_disc, vha, 0x201f, |
| 3000 | "MBX_GET_PORT_NAME failed, No FL Port.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3001 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3002 | vha->device_flags &= ~SWITCH_FOUND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3003 | return (QLA_SUCCESS); |
| 3004 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3005 | vha->device_flags |= SWITCH_FOUND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3006 | |
| 3007 | /* Mark devices that need re-synchronization. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3008 | rval2 = qla2x00_device_resync(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3009 | if (rval2 == QLA_RSCNS_HANDLED) { |
| 3010 | /* No point doing the scan, just continue. */ |
| 3011 | return (QLA_SUCCESS); |
| 3012 | } |
| 3013 | do { |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 3014 | /* FDMI support. */ |
| 3015 | if (ql2xfdmienable && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3016 | test_and_clear_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags)) |
| 3017 | qla2x00_fdmi_register(vha); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 3018 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3019 | /* Ensure we are logged into the SNS. */ |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 3020 | if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 3021 | loop_id = NPH_SNS; |
| 3022 | else |
| 3023 | loop_id = SIMPLE_NAME_SERVER; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3024 | ha->isp_ops->fabric_login(vha, loop_id, 0xff, 0xff, |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 3025 | 0xfc, mb, BIT_1 | BIT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3026 | if (mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3027 | ql_dbg(ql_dbg_disc, vha, 0x2042, |
| 3028 | "Failed SNS login: loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x " |
| 3029 | "mb[6]=%x mb[7]=%x.\n", loop_id, mb[0], mb[1], |
| 3030 | mb[2], mb[6], mb[7]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3031 | return (QLA_SUCCESS); |
| 3032 | } |
| 3033 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3034 | if (test_and_clear_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags)) { |
| 3035 | if (qla2x00_rft_id(vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3036 | /* EMPTY */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3037 | ql_dbg(ql_dbg_disc, vha, 0x2045, |
| 3038 | "Register FC-4 TYPE failed.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3039 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3040 | if (qla2x00_rff_id(vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3041 | /* EMPTY */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3042 | ql_dbg(ql_dbg_disc, vha, 0x2049, |
| 3043 | "Register FC-4 Features failed.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3044 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3045 | if (qla2x00_rnn_id(vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3046 | /* EMPTY */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3047 | ql_dbg(ql_dbg_disc, vha, 0x204f, |
| 3048 | "Register Node Name failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3049 | } else if (qla2x00_rsnn_nn(vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3050 | /* EMPTY */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3051 | ql_dbg(ql_dbg_disc, vha, 0x2053, |
| 3052 | "Register Symobilic Node Name failed.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3053 | } |
| 3054 | } |
| 3055 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3056 | rval = qla2x00_find_all_fabric_devs(vha, &new_fcports); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3057 | if (rval != QLA_SUCCESS) |
| 3058 | break; |
| 3059 | |
| 3060 | /* |
| 3061 | * Logout all previous fabric devices marked lost, except |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3062 | * FCP2 devices. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3063 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3064 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 3065 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3066 | break; |
| 3067 | |
| 3068 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) |
| 3069 | continue; |
| 3070 | |
| 3071 | if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3072 | qla2x00_mark_device_lost(vha, fcport, |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3073 | ql2xplogiabsentdevice, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3074 | if (fcport->loop_id != FC_NO_LOOP_ID && |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3075 | (fcport->flags & FCF_FCP2_DEVICE) == 0 && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3076 | fcport->port_type != FCT_INITIATOR && |
| 3077 | fcport->port_type != FCT_BROADCAST) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3078 | ha->isp_ops->fabric_logout(vha, |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3079 | fcport->loop_id, |
| 3080 | fcport->d_id.b.domain, |
| 3081 | fcport->d_id.b.area, |
| 3082 | fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3083 | fcport->loop_id = FC_NO_LOOP_ID; |
| 3084 | } |
| 3085 | } |
| 3086 | } |
| 3087 | |
| 3088 | /* Starting free loop ID. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3089 | next_loopid = ha->min_external_loopid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3090 | |
| 3091 | /* |
| 3092 | * Scan through our port list and login entries that need to be |
| 3093 | * logged in. |
| 3094 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3095 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 3096 | if (atomic_read(&vha->loop_down_timer) || |
| 3097 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3098 | break; |
| 3099 | |
| 3100 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0 || |
| 3101 | (fcport->flags & FCF_LOGIN_NEEDED) == 0) |
| 3102 | continue; |
| 3103 | |
| 3104 | if (fcport->loop_id == FC_NO_LOOP_ID) { |
| 3105 | fcport->loop_id = next_loopid; |
Seokmann Ju | d4486fd | 2008-04-03 13:13:28 -0700 | [diff] [blame] | 3106 | rval = qla2x00_find_new_loop_id( |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3107 | base_vha, fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3108 | if (rval != QLA_SUCCESS) { |
| 3109 | /* Ran out of IDs to use */ |
| 3110 | break; |
| 3111 | } |
| 3112 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3113 | /* Login and update database */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3114 | qla2x00_fabric_dev_login(vha, fcport, &next_loopid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3115 | } |
| 3116 | |
| 3117 | /* Exit if out of loop IDs. */ |
| 3118 | if (rval != QLA_SUCCESS) { |
| 3119 | break; |
| 3120 | } |
| 3121 | |
| 3122 | /* |
| 3123 | * Login and add the new devices to our port list. |
| 3124 | */ |
| 3125 | list_for_each_entry_safe(fcport, fcptemp, &new_fcports, list) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3126 | if (atomic_read(&vha->loop_down_timer) || |
| 3127 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3128 | break; |
| 3129 | |
| 3130 | /* Find a new loop ID to use. */ |
| 3131 | fcport->loop_id = next_loopid; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3132 | rval = qla2x00_find_new_loop_id(base_vha, fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3133 | if (rval != QLA_SUCCESS) { |
| 3134 | /* Ran out of IDs to use */ |
| 3135 | break; |
| 3136 | } |
| 3137 | |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 3138 | /* Login and update database */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3139 | qla2x00_fabric_dev_login(vha, fcport, &next_loopid); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3140 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3141 | if (vha->vp_idx) { |
| 3142 | fcport->vha = vha; |
| 3143 | fcport->vp_idx = vha->vp_idx; |
| 3144 | } |
| 3145 | list_move_tail(&fcport->list, &vha->vp_fcports); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3146 | } |
| 3147 | } while (0); |
| 3148 | |
| 3149 | /* Free all new device structures not processed. */ |
| 3150 | list_for_each_entry_safe(fcport, fcptemp, &new_fcports, list) { |
| 3151 | list_del(&fcport->list); |
| 3152 | kfree(fcport); |
| 3153 | } |
| 3154 | |
| 3155 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3156 | ql_dbg(ql_dbg_disc, vha, 0x2068, |
| 3157 | "Configure fabric error exit rval=%d.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3158 | } |
| 3159 | |
| 3160 | return (rval); |
| 3161 | } |
| 3162 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3163 | /* |
| 3164 | * qla2x00_find_all_fabric_devs |
| 3165 | * |
| 3166 | * Input: |
| 3167 | * ha = adapter block pointer. |
| 3168 | * dev = database device entry pointer. |
| 3169 | * |
| 3170 | * Returns: |
| 3171 | * 0 = success. |
| 3172 | * |
| 3173 | * Context: |
| 3174 | * Kernel context. |
| 3175 | */ |
| 3176 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3177 | qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha, |
| 3178 | struct list_head *new_fcports) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3179 | { |
| 3180 | int rval; |
| 3181 | uint16_t loop_id; |
| 3182 | fc_port_t *fcport, *new_fcport, *fcptemp; |
| 3183 | int found; |
| 3184 | |
| 3185 | sw_info_t *swl; |
| 3186 | int swl_idx; |
| 3187 | int first_dev, last_dev; |
Mike Waychison | 1516ef4 | 2010-05-04 15:01:31 -0700 | [diff] [blame] | 3188 | port_id_t wrap = {}, nxt_d_id; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3189 | struct qla_hw_data *ha = vha->hw; |
| 3190 | struct scsi_qla_host *vp, *base_vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | ee546b6 | 2009-03-05 11:07:02 -0800 | [diff] [blame] | 3191 | struct scsi_qla_host *tvp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3192 | |
| 3193 | rval = QLA_SUCCESS; |
| 3194 | |
| 3195 | /* Try GID_PT to get device list, else GAN. */ |
Andrew Vasquez | 4b89258 | 2008-09-11 21:22:48 -0700 | [diff] [blame] | 3196 | swl = kcalloc(MAX_FIBRE_DEVICES, sizeof(sw_info_t), GFP_KERNEL); |
Mariusz Kozlowski | bbfbbbc | 2007-08-11 10:13:24 +0200 | [diff] [blame] | 3197 | if (!swl) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3198 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3199 | ql_dbg(ql_dbg_disc, vha, 0x2054, |
| 3200 | "GID_PT allocations failed, fallback on GA_NXT.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3201 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3202 | if (qla2x00_gid_pt(vha, swl) != QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3203 | kfree(swl); |
| 3204 | swl = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3205 | } else if (qla2x00_gpn_id(vha, swl) != QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3206 | kfree(swl); |
| 3207 | swl = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3208 | } else if (qla2x00_gnn_id(vha, swl) != QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3209 | kfree(swl); |
| 3210 | swl = NULL; |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 3211 | } else if (ql2xiidmaenable && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3212 | qla2x00_gfpn_id(vha, swl) == QLA_SUCCESS) { |
| 3213 | qla2x00_gpsc(vha, swl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3214 | } |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 3215 | |
| 3216 | /* If other queries succeeded probe for FC-4 type */ |
| 3217 | if (swl) |
| 3218 | qla2x00_gff_id(vha, swl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3219 | } |
| 3220 | swl_idx = 0; |
| 3221 | |
| 3222 | /* Allocate temporary fcport for any new fcports discovered. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3223 | new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3224 | if (new_fcport == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3225 | ql_log(ql_log_warn, vha, 0x205e, |
| 3226 | "Failed to allocate memory for fcport.\n"); |
Jesper Juhl | c9475cb | 2005-11-07 01:01:26 -0800 | [diff] [blame] | 3227 | kfree(swl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3228 | return (QLA_MEMORY_ALLOC_FAILED); |
| 3229 | } |
| 3230 | new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3231 | /* Set start port ID scan at adapter ID. */ |
| 3232 | first_dev = 1; |
| 3233 | last_dev = 0; |
| 3234 | |
| 3235 | /* Starting free loop ID. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3236 | loop_id = ha->min_external_loopid; |
| 3237 | for (; loop_id <= ha->max_loop_id; loop_id++) { |
| 3238 | if (qla2x00_is_reserved_id(vha, loop_id)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3239 | continue; |
| 3240 | |
Giridhar Malavali | 3a6478d | 2010-05-28 15:08:20 -0700 | [diff] [blame] | 3241 | if (ha->current_topology == ISP_CFG_FL && |
| 3242 | (atomic_read(&vha->loop_down_timer) || |
| 3243 | LOOP_TRANSITION(vha))) { |
Andrew Vasquez | bb2d52b | 2010-02-18 10:07:27 -0800 | [diff] [blame] | 3244 | atomic_set(&vha->loop_down_timer, 0); |
| 3245 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 3246 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3247 | break; |
Andrew Vasquez | bb2d52b | 2010-02-18 10:07:27 -0800 | [diff] [blame] | 3248 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3249 | |
| 3250 | if (swl != NULL) { |
| 3251 | if (last_dev) { |
| 3252 | wrap.b24 = new_fcport->d_id.b24; |
| 3253 | } else { |
| 3254 | new_fcport->d_id.b24 = swl[swl_idx].d_id.b24; |
| 3255 | memcpy(new_fcport->node_name, |
| 3256 | swl[swl_idx].node_name, WWN_SIZE); |
| 3257 | memcpy(new_fcport->port_name, |
| 3258 | swl[swl_idx].port_name, WWN_SIZE); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3259 | memcpy(new_fcport->fabric_port_name, |
| 3260 | swl[swl_idx].fabric_port_name, WWN_SIZE); |
| 3261 | new_fcport->fp_speed = swl[swl_idx].fp_speed; |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 3262 | new_fcport->fc4_type = swl[swl_idx].fc4_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3263 | |
| 3264 | if (swl[swl_idx].d_id.b.rsvd_1 != 0) { |
| 3265 | last_dev = 1; |
| 3266 | } |
| 3267 | swl_idx++; |
| 3268 | } |
| 3269 | } else { |
| 3270 | /* Send GA_NXT to the switch */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3271 | rval = qla2x00_ga_nxt(vha, new_fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3272 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3273 | ql_log(ql_log_warn, vha, 0x2064, |
| 3274 | "SNS scan failed -- assuming " |
| 3275 | "zero-entry result.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3276 | list_for_each_entry_safe(fcport, fcptemp, |
| 3277 | new_fcports, list) { |
| 3278 | list_del(&fcport->list); |
| 3279 | kfree(fcport); |
| 3280 | } |
| 3281 | rval = QLA_SUCCESS; |
| 3282 | break; |
| 3283 | } |
| 3284 | } |
| 3285 | |
| 3286 | /* If wrap on switch device list, exit. */ |
| 3287 | if (first_dev) { |
| 3288 | wrap.b24 = new_fcport->d_id.b24; |
| 3289 | first_dev = 0; |
| 3290 | } else if (new_fcport->d_id.b24 == wrap.b24) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3291 | ql_dbg(ql_dbg_disc, vha, 0x2065, |
| 3292 | "Device wrap (%02x%02x%02x).\n", |
| 3293 | new_fcport->d_id.b.domain, |
| 3294 | new_fcport->d_id.b.area, |
| 3295 | new_fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3296 | break; |
| 3297 | } |
| 3298 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3299 | /* Bypass if same physical adapter. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3300 | if (new_fcport->d_id.b24 == base_vha->d_id.b24) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3301 | continue; |
| 3302 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3303 | /* Bypass virtual ports of the same host. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3304 | found = 0; |
| 3305 | if (ha->num_vhosts) { |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3306 | unsigned long flags; |
| 3307 | |
| 3308 | spin_lock_irqsave(&ha->vport_slock, flags); |
Anirban Chakraborty | ee546b6 | 2009-03-05 11:07:02 -0800 | [diff] [blame] | 3309 | list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3310 | if (new_fcport->d_id.b24 == vp->d_id.b24) { |
| 3311 | found = 1; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3312 | break; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3313 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3314 | } |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3315 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3316 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3317 | if (found) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3318 | continue; |
| 3319 | } |
| 3320 | |
Andrew Vasquez | f7d289f | 2005-08-26 19:08:40 -0700 | [diff] [blame] | 3321 | /* Bypass if same domain and area of adapter. */ |
| 3322 | if (((new_fcport->d_id.b24 & 0xffff00) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3323 | (vha->d_id.b24 & 0xffff00)) && ha->current_topology == |
Andrew Vasquez | f7d289f | 2005-08-26 19:08:40 -0700 | [diff] [blame] | 3324 | ISP_CFG_FL) |
| 3325 | continue; |
| 3326 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3327 | /* Bypass reserved domain fields. */ |
| 3328 | if ((new_fcport->d_id.b.domain & 0xf0) == 0xf0) |
| 3329 | continue; |
| 3330 | |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 3331 | /* Bypass ports whose FCP-4 type is not FCP_SCSI */ |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 3332 | if (ql2xgffidenable && |
| 3333 | (new_fcport->fc4_type != FC4_TYPE_FCP_SCSI && |
| 3334 | new_fcport->fc4_type != FC4_TYPE_UNKNOWN)) |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 3335 | continue; |
| 3336 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3337 | /* Locate matching device in database. */ |
| 3338 | found = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3339 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3340 | if (memcmp(new_fcport->port_name, fcport->port_name, |
| 3341 | WWN_SIZE)) |
| 3342 | continue; |
| 3343 | |
| 3344 | found++; |
| 3345 | |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3346 | /* Update port state. */ |
| 3347 | memcpy(fcport->fabric_port_name, |
| 3348 | new_fcport->fabric_port_name, WWN_SIZE); |
| 3349 | fcport->fp_speed = new_fcport->fp_speed; |
| 3350 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3351 | /* |
| 3352 | * If address the same and state FCS_ONLINE, nothing |
| 3353 | * changed. |
| 3354 | */ |
| 3355 | if (fcport->d_id.b24 == new_fcport->d_id.b24 && |
| 3356 | atomic_read(&fcport->state) == FCS_ONLINE) { |
| 3357 | break; |
| 3358 | } |
| 3359 | |
| 3360 | /* |
| 3361 | * If device was not a fabric device before. |
| 3362 | */ |
| 3363 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) { |
| 3364 | fcport->d_id.b24 = new_fcport->d_id.b24; |
| 3365 | fcport->loop_id = FC_NO_LOOP_ID; |
| 3366 | fcport->flags |= (FCF_FABRIC_DEVICE | |
| 3367 | FCF_LOGIN_NEEDED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3368 | break; |
| 3369 | } |
| 3370 | |
| 3371 | /* |
| 3372 | * Port ID changed or device was marked to be updated; |
| 3373 | * Log it out if still logged in and mark it for |
| 3374 | * relogin later. |
| 3375 | */ |
| 3376 | fcport->d_id.b24 = new_fcport->d_id.b24; |
| 3377 | fcport->flags |= FCF_LOGIN_NEEDED; |
| 3378 | if (fcport->loop_id != FC_NO_LOOP_ID && |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3379 | (fcport->flags & FCF_FCP2_DEVICE) == 0 && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3380 | fcport->port_type != FCT_INITIATOR && |
| 3381 | fcport->port_type != FCT_BROADCAST) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3382 | ha->isp_ops->fabric_logout(vha, fcport->loop_id, |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3383 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 3384 | fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3385 | fcport->loop_id = FC_NO_LOOP_ID; |
| 3386 | } |
| 3387 | |
| 3388 | break; |
| 3389 | } |
| 3390 | |
| 3391 | if (found) |
| 3392 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3393 | /* If device was not in our fcports list, then add it. */ |
| 3394 | list_add_tail(&new_fcport->list, new_fcports); |
| 3395 | |
| 3396 | /* Allocate a new replacement fcport. */ |
| 3397 | nxt_d_id.b24 = new_fcport->d_id.b24; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3398 | new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3399 | if (new_fcport == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3400 | ql_log(ql_log_warn, vha, 0x2066, |
| 3401 | "Memory allocation failed for fcport.\n"); |
Jesper Juhl | c9475cb | 2005-11-07 01:01:26 -0800 | [diff] [blame] | 3402 | kfree(swl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3403 | return (QLA_MEMORY_ALLOC_FAILED); |
| 3404 | } |
| 3405 | new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); |
| 3406 | new_fcport->d_id.b24 = nxt_d_id.b24; |
| 3407 | } |
| 3408 | |
Jesper Juhl | c9475cb | 2005-11-07 01:01:26 -0800 | [diff] [blame] | 3409 | kfree(swl); |
| 3410 | kfree(new_fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3411 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3412 | return (rval); |
| 3413 | } |
| 3414 | |
| 3415 | /* |
| 3416 | * qla2x00_find_new_loop_id |
| 3417 | * Scan through our port list and find a new usable loop ID. |
| 3418 | * |
| 3419 | * Input: |
| 3420 | * ha: adapter state pointer. |
| 3421 | * dev: port structure pointer. |
| 3422 | * |
| 3423 | * Returns: |
| 3424 | * qla2x00 local function return status code. |
| 3425 | * |
| 3426 | * Context: |
| 3427 | * Kernel context. |
| 3428 | */ |
Joe Carnuccio | 03bcfb5 | 2011-03-30 11:46:27 -0700 | [diff] [blame] | 3429 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3430 | qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3431 | { |
| 3432 | int rval; |
| 3433 | int found; |
| 3434 | fc_port_t *fcport; |
| 3435 | uint16_t first_loop_id; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3436 | struct qla_hw_data *ha = vha->hw; |
| 3437 | struct scsi_qla_host *vp; |
Anirban Chakraborty | ee546b6 | 2009-03-05 11:07:02 -0800 | [diff] [blame] | 3438 | struct scsi_qla_host *tvp; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3439 | unsigned long flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3440 | |
| 3441 | rval = QLA_SUCCESS; |
| 3442 | |
| 3443 | /* Save starting loop ID. */ |
| 3444 | first_loop_id = dev->loop_id; |
| 3445 | |
| 3446 | for (;;) { |
| 3447 | /* Skip loop ID if already used by adapter. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3448 | if (dev->loop_id == vha->loop_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3449 | dev->loop_id++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3450 | |
| 3451 | /* Skip reserved loop IDs. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3452 | while (qla2x00_is_reserved_id(vha, dev->loop_id)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3453 | dev->loop_id++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3454 | |
| 3455 | /* Reset loop ID if passed the end. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3456 | if (dev->loop_id > ha->max_loop_id) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3457 | /* first loop ID. */ |
| 3458 | dev->loop_id = ha->min_external_loopid; |
| 3459 | } |
| 3460 | |
| 3461 | /* Check for loop ID being already in use. */ |
| 3462 | found = 0; |
| 3463 | fcport = NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3464 | |
| 3465 | spin_lock_irqsave(&ha->vport_slock, flags); |
Anirban Chakraborty | ee546b6 | 2009-03-05 11:07:02 -0800 | [diff] [blame] | 3466 | list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3467 | list_for_each_entry(fcport, &vp->vp_fcports, list) { |
| 3468 | if (fcport->loop_id == dev->loop_id && |
| 3469 | fcport != dev) { |
| 3470 | /* ID possibly in use */ |
| 3471 | found++; |
| 3472 | break; |
| 3473 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3474 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3475 | if (found) |
| 3476 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3477 | } |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3478 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3479 | |
| 3480 | /* If not in use then it is free to use. */ |
| 3481 | if (!found) { |
| 3482 | break; |
| 3483 | } |
| 3484 | |
| 3485 | /* ID in use. Try next value. */ |
| 3486 | dev->loop_id++; |
| 3487 | |
| 3488 | /* If wrap around. No free ID to use. */ |
| 3489 | if (dev->loop_id == first_loop_id) { |
| 3490 | dev->loop_id = FC_NO_LOOP_ID; |
| 3491 | rval = QLA_FUNCTION_FAILED; |
| 3492 | break; |
| 3493 | } |
| 3494 | } |
| 3495 | |
| 3496 | return (rval); |
| 3497 | } |
| 3498 | |
| 3499 | /* |
| 3500 | * qla2x00_device_resync |
| 3501 | * Marks devices in the database that needs resynchronization. |
| 3502 | * |
| 3503 | * Input: |
| 3504 | * ha = adapter block pointer. |
| 3505 | * |
| 3506 | * Context: |
| 3507 | * Kernel context. |
| 3508 | */ |
| 3509 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3510 | qla2x00_device_resync(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3511 | { |
| 3512 | int rval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3513 | uint32_t mask; |
| 3514 | fc_port_t *fcport; |
| 3515 | uint32_t rscn_entry; |
| 3516 | uint8_t rscn_out_iter; |
| 3517 | uint8_t format; |
Mike Waychison | 1516ef4 | 2010-05-04 15:01:31 -0700 | [diff] [blame] | 3518 | port_id_t d_id = {}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3519 | |
| 3520 | rval = QLA_RSCNS_HANDLED; |
| 3521 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3522 | while (vha->rscn_out_ptr != vha->rscn_in_ptr || |
| 3523 | vha->flags.rscn_queue_overflow) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3524 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3525 | rscn_entry = vha->rscn_queue[vha->rscn_out_ptr]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3526 | format = MSB(MSW(rscn_entry)); |
| 3527 | d_id.b.domain = LSB(MSW(rscn_entry)); |
| 3528 | d_id.b.area = MSB(LSW(rscn_entry)); |
| 3529 | d_id.b.al_pa = LSB(LSW(rscn_entry)); |
| 3530 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3531 | ql_dbg(ql_dbg_disc, vha, 0x2020, |
| 3532 | "RSCN queue entry[%d] = [%02x/%02x%02x%02x].\n", |
| 3533 | vha->rscn_out_ptr, format, d_id.b.domain, d_id.b.area, |
| 3534 | d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3535 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3536 | vha->rscn_out_ptr++; |
| 3537 | if (vha->rscn_out_ptr == MAX_RSCN_COUNT) |
| 3538 | vha->rscn_out_ptr = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3539 | |
| 3540 | /* Skip duplicate entries. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3541 | for (rscn_out_iter = vha->rscn_out_ptr; |
| 3542 | !vha->flags.rscn_queue_overflow && |
| 3543 | rscn_out_iter != vha->rscn_in_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3544 | rscn_out_iter = (rscn_out_iter == |
| 3545 | (MAX_RSCN_COUNT - 1)) ? 0: rscn_out_iter + 1) { |
| 3546 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3547 | if (rscn_entry != vha->rscn_queue[rscn_out_iter]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3548 | break; |
| 3549 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3550 | ql_dbg(ql_dbg_disc, vha, 0x2021, |
| 3551 | "Skipping duplicate RSCN queue entry found at " |
| 3552 | "[%d].\n", rscn_out_iter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3553 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3554 | vha->rscn_out_ptr = rscn_out_iter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3555 | } |
| 3556 | |
| 3557 | /* Queue overflow, set switch default case. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3558 | if (vha->flags.rscn_queue_overflow) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3559 | ql_dbg(ql_dbg_disc, vha, 0x2022, |
| 3560 | "device_resync: rscn overflow.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3561 | |
| 3562 | format = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3563 | vha->flags.rscn_queue_overflow = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3564 | } |
| 3565 | |
| 3566 | switch (format) { |
| 3567 | case 0: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3568 | mask = 0xffffff; |
| 3569 | break; |
| 3570 | case 1: |
| 3571 | mask = 0xffff00; |
| 3572 | break; |
| 3573 | case 2: |
| 3574 | mask = 0xff0000; |
| 3575 | break; |
| 3576 | default: |
| 3577 | mask = 0x0; |
| 3578 | d_id.b24 = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3579 | vha->rscn_out_ptr = vha->rscn_in_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3580 | break; |
| 3581 | } |
| 3582 | |
| 3583 | rval = QLA_SUCCESS; |
| 3584 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3585 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3586 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0 || |
| 3587 | (fcport->d_id.b24 & mask) != d_id.b24 || |
| 3588 | fcport->port_type == FCT_BROADCAST) |
| 3589 | continue; |
| 3590 | |
| 3591 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
| 3592 | if (format != 3 || |
| 3593 | fcport->port_type != FCT_INITIATOR) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3594 | qla2x00_mark_device_lost(vha, fcport, |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3595 | 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3596 | } |
| 3597 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3598 | } |
| 3599 | } |
| 3600 | return (rval); |
| 3601 | } |
| 3602 | |
| 3603 | /* |
| 3604 | * qla2x00_fabric_dev_login |
| 3605 | * Login fabric target device and update FC port database. |
| 3606 | * |
| 3607 | * Input: |
| 3608 | * ha: adapter state pointer. |
| 3609 | * fcport: port structure list pointer. |
| 3610 | * next_loopid: contains value of a new loop ID that can be used |
| 3611 | * by the next login attempt. |
| 3612 | * |
| 3613 | * Returns: |
| 3614 | * qla2x00 local function return status code. |
| 3615 | * |
| 3616 | * Context: |
| 3617 | * Kernel context. |
| 3618 | */ |
| 3619 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3620 | qla2x00_fabric_dev_login(scsi_qla_host_t *vha, fc_port_t *fcport, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3621 | uint16_t *next_loopid) |
| 3622 | { |
| 3623 | int rval; |
| 3624 | int retry; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 3625 | uint8_t opts; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3626 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3627 | |
| 3628 | rval = QLA_SUCCESS; |
| 3629 | retry = 0; |
| 3630 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3631 | if (IS_ALOGIO_CAPABLE(ha)) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3632 | if (fcport->flags & FCF_ASYNC_SENT) |
| 3633 | return rval; |
| 3634 | fcport->flags |= FCF_ASYNC_SENT; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3635 | rval = qla2x00_post_async_login_work(vha, fcport, NULL); |
| 3636 | if (!rval) |
| 3637 | return rval; |
| 3638 | } |
| 3639 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3640 | fcport->flags &= ~FCF_ASYNC_SENT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3641 | rval = qla2x00_fabric_login(vha, fcport, next_loopid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3642 | if (rval == QLA_SUCCESS) { |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3643 | /* Send an ADISC to FCP2 devices.*/ |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 3644 | opts = 0; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3645 | if (fcport->flags & FCF_FCP2_DEVICE) |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 3646 | opts |= BIT_1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3647 | rval = qla2x00_get_port_database(vha, fcport, opts); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3648 | if (rval != QLA_SUCCESS) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3649 | ha->isp_ops->fabric_logout(vha, fcport->loop_id, |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3650 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 3651 | fcport->d_id.b.al_pa); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3652 | qla2x00_mark_device_lost(vha, fcport, 1, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3653 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3654 | qla2x00_update_fcport(vha, fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3655 | } |
| 3656 | } |
| 3657 | |
| 3658 | return (rval); |
| 3659 | } |
| 3660 | |
| 3661 | /* |
| 3662 | * qla2x00_fabric_login |
| 3663 | * Issue fabric login command. |
| 3664 | * |
| 3665 | * Input: |
| 3666 | * ha = adapter block pointer. |
| 3667 | * device = pointer to FC device type structure. |
| 3668 | * |
| 3669 | * Returns: |
| 3670 | * 0 - Login successfully |
| 3671 | * 1 - Login failed |
| 3672 | * 2 - Initiator device |
| 3673 | * 3 - Fatal error |
| 3674 | */ |
| 3675 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3676 | qla2x00_fabric_login(scsi_qla_host_t *vha, fc_port_t *fcport, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3677 | uint16_t *next_loopid) |
| 3678 | { |
| 3679 | int rval; |
| 3680 | int retry; |
| 3681 | uint16_t tmp_loopid; |
| 3682 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3683 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3684 | |
| 3685 | retry = 0; |
| 3686 | tmp_loopid = 0; |
| 3687 | |
| 3688 | for (;;) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3689 | ql_dbg(ql_dbg_disc, vha, 0x2000, |
| 3690 | "Trying Fabric Login w/loop id 0x%04x for port " |
| 3691 | "%02x%02x%02x.\n", |
| 3692 | fcport->loop_id, fcport->d_id.b.domain, |
| 3693 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3694 | |
| 3695 | /* Login fcport on switch. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3696 | ha->isp_ops->fabric_login(vha, fcport->loop_id, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3697 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 3698 | fcport->d_id.b.al_pa, mb, BIT_0); |
| 3699 | if (mb[0] == MBS_PORT_ID_USED) { |
| 3700 | /* |
| 3701 | * Device has another loop ID. The firmware team |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 3702 | * recommends the driver perform an implicit login with |
| 3703 | * the specified ID again. The ID we just used is save |
| 3704 | * here so we return with an ID that can be tried by |
| 3705 | * the next login. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3706 | */ |
| 3707 | retry++; |
| 3708 | tmp_loopid = fcport->loop_id; |
| 3709 | fcport->loop_id = mb[1]; |
| 3710 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3711 | ql_dbg(ql_dbg_disc, vha, 0x2001, |
| 3712 | "Fabric Login: port in use - next loop " |
| 3713 | "id=0x%04x, port id= %02x%02x%02x.\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3714 | fcport->loop_id, fcport->d_id.b.domain, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3715 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3716 | |
| 3717 | } else if (mb[0] == MBS_COMMAND_COMPLETE) { |
| 3718 | /* |
| 3719 | * Login succeeded. |
| 3720 | */ |
| 3721 | if (retry) { |
| 3722 | /* A retry occurred before. */ |
| 3723 | *next_loopid = tmp_loopid; |
| 3724 | } else { |
| 3725 | /* |
| 3726 | * No retry occurred before. Just increment the |
| 3727 | * ID value for next login. |
| 3728 | */ |
| 3729 | *next_loopid = (fcport->loop_id + 1); |
| 3730 | } |
| 3731 | |
| 3732 | if (mb[1] & BIT_0) { |
| 3733 | fcport->port_type = FCT_INITIATOR; |
| 3734 | } else { |
| 3735 | fcport->port_type = FCT_TARGET; |
| 3736 | if (mb[1] & BIT_1) { |
Santosh Vernekar | 8474f3a | 2009-08-25 11:36:16 -0700 | [diff] [blame] | 3737 | fcport->flags |= FCF_FCP2_DEVICE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3738 | } |
| 3739 | } |
| 3740 | |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 3741 | if (mb[10] & BIT_0) |
| 3742 | fcport->supported_classes |= FC_COS_CLASS2; |
| 3743 | if (mb[10] & BIT_1) |
| 3744 | fcport->supported_classes |= FC_COS_CLASS3; |
| 3745 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3746 | rval = QLA_SUCCESS; |
| 3747 | break; |
| 3748 | } else if (mb[0] == MBS_LOOP_ID_USED) { |
| 3749 | /* |
| 3750 | * Loop ID already used, try next loop ID. |
| 3751 | */ |
| 3752 | fcport->loop_id++; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3753 | rval = qla2x00_find_new_loop_id(vha, fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3754 | if (rval != QLA_SUCCESS) { |
| 3755 | /* Ran out of loop IDs to use */ |
| 3756 | break; |
| 3757 | } |
| 3758 | } else if (mb[0] == MBS_COMMAND_ERROR) { |
| 3759 | /* |
| 3760 | * Firmware possibly timed out during login. If NO |
| 3761 | * retries are left to do then the device is declared |
| 3762 | * dead. |
| 3763 | */ |
| 3764 | *next_loopid = fcport->loop_id; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3765 | ha->isp_ops->fabric_logout(vha, fcport->loop_id, |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3766 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 3767 | fcport->d_id.b.al_pa); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3768 | qla2x00_mark_device_lost(vha, fcport, 1, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3769 | |
| 3770 | rval = 1; |
| 3771 | break; |
| 3772 | } else { |
| 3773 | /* |
| 3774 | * unrecoverable / not handled error |
| 3775 | */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3776 | ql_dbg(ql_dbg_disc, vha, 0x2002, |
| 3777 | "Failed=%x port_id=%02x%02x%02x loop_id=%x " |
| 3778 | "jiffies=%lx.\n", mb[0], fcport->d_id.b.domain, |
| 3779 | fcport->d_id.b.area, fcport->d_id.b.al_pa, |
| 3780 | fcport->loop_id, jiffies); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3781 | |
| 3782 | *next_loopid = fcport->loop_id; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3783 | ha->isp_ops->fabric_logout(vha, fcport->loop_id, |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3784 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 3785 | fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3786 | fcport->loop_id = FC_NO_LOOP_ID; |
Andrew Vasquez | 0eedfcf | 2005-10-27 11:09:38 -0700 | [diff] [blame] | 3787 | fcport->login_retry = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3788 | |
| 3789 | rval = 3; |
| 3790 | break; |
| 3791 | } |
| 3792 | } |
| 3793 | |
| 3794 | return (rval); |
| 3795 | } |
| 3796 | |
| 3797 | /* |
| 3798 | * qla2x00_local_device_login |
| 3799 | * Issue local device login command. |
| 3800 | * |
| 3801 | * Input: |
| 3802 | * ha = adapter block pointer. |
| 3803 | * loop_id = loop id of device to login to. |
| 3804 | * |
| 3805 | * Returns (Where's the #define!!!!): |
| 3806 | * 0 - Login successfully |
| 3807 | * 1 - Login failed |
| 3808 | * 3 - Fatal error |
| 3809 | */ |
| 3810 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3811 | qla2x00_local_device_login(scsi_qla_host_t *vha, fc_port_t *fcport) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3812 | { |
| 3813 | int rval; |
| 3814 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
| 3815 | |
| 3816 | memset(mb, 0, sizeof(mb)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3817 | rval = qla2x00_login_local_device(vha, fcport, mb, BIT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3818 | if (rval == QLA_SUCCESS) { |
| 3819 | /* Interrogate mailbox registers for any errors */ |
| 3820 | if (mb[0] == MBS_COMMAND_ERROR) |
| 3821 | rval = 1; |
| 3822 | else if (mb[0] == MBS_COMMAND_PARAMETER_ERROR) |
| 3823 | /* device not in PCB table */ |
| 3824 | rval = 3; |
| 3825 | } |
| 3826 | |
| 3827 | return (rval); |
| 3828 | } |
| 3829 | |
| 3830 | /* |
| 3831 | * qla2x00_loop_resync |
| 3832 | * Resync with fibre channel devices. |
| 3833 | * |
| 3834 | * Input: |
| 3835 | * ha = adapter block pointer. |
| 3836 | * |
| 3837 | * Returns: |
| 3838 | * 0 = success |
| 3839 | */ |
| 3840 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3841 | qla2x00_loop_resync(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3842 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3843 | int rval = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3844 | uint32_t wait_time; |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 3845 | struct req_que *req; |
| 3846 | struct rsp_que *rsp; |
| 3847 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 3848 | if (vha->hw->flags.cpu_affinity_enabled) |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 3849 | req = vha->hw->req_q_map[0]; |
| 3850 | else |
| 3851 | req = vha->req; |
| 3852 | rsp = req->rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3853 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3854 | clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
| 3855 | if (vha->flags.online) { |
| 3856 | if (!(rval = qla2x00_fw_ready(vha))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3857 | /* Wait at most MAX_TARGET RSCNs for a stable link. */ |
| 3858 | wait_time = 256; |
| 3859 | do { |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 3860 | /* Issue a marker after FW becomes ready. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3861 | qla2x00_marker(vha, req, rsp, 0, 0, |
| 3862 | MK_SYNC_ALL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3863 | vha->marker_needed = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3864 | |
| 3865 | /* Remap devices on Loop. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3866 | clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3867 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3868 | qla2x00_configure_loop(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3869 | wait_time--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3870 | } while (!atomic_read(&vha->loop_down_timer) && |
| 3871 | !(test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) |
| 3872 | && wait_time && (test_bit(LOOP_RESYNC_NEEDED, |
| 3873 | &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3874 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3875 | } |
| 3876 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3877 | if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3878 | return (QLA_FUNCTION_FAILED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3879 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3880 | if (rval) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3881 | ql_dbg(ql_dbg_disc, vha, 0x206c, |
| 3882 | "%s *** FAILED ***.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3883 | |
| 3884 | return (rval); |
| 3885 | } |
| 3886 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 3887 | /* |
| 3888 | * qla2x00_perform_loop_resync |
| 3889 | * Description: This function will set the appropriate flags and call |
| 3890 | * qla2x00_loop_resync. If successful loop will be resynced |
| 3891 | * Arguments : scsi_qla_host_t pointer |
| 3892 | * returm : Success or Failure |
| 3893 | */ |
| 3894 | |
| 3895 | int qla2x00_perform_loop_resync(scsi_qla_host_t *ha) |
| 3896 | { |
| 3897 | int32_t rval = 0; |
| 3898 | |
| 3899 | if (!test_and_set_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags)) { |
| 3900 | /*Configure the flags so that resync happens properly*/ |
| 3901 | atomic_set(&ha->loop_down_timer, 0); |
| 3902 | if (!(ha->device_flags & DFLG_NO_CABLE)) { |
| 3903 | atomic_set(&ha->loop_state, LOOP_UP); |
| 3904 | set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); |
| 3905 | set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags); |
| 3906 | set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); |
| 3907 | |
| 3908 | rval = qla2x00_loop_resync(ha); |
| 3909 | } else |
| 3910 | atomic_set(&ha->loop_state, LOOP_DEAD); |
| 3911 | |
| 3912 | clear_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags); |
| 3913 | } |
| 3914 | |
| 3915 | return rval; |
| 3916 | } |
| 3917 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3918 | void |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3919 | qla2x00_update_fcports(scsi_qla_host_t *base_vha) |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3920 | { |
| 3921 | fc_port_t *fcport; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3922 | struct scsi_qla_host *vha; |
| 3923 | struct qla_hw_data *ha = base_vha->hw; |
| 3924 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3925 | |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3926 | spin_lock_irqsave(&ha->vport_slock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3927 | /* Go with deferred removal of rport references. */ |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3928 | list_for_each_entry(vha, &base_vha->hw->vp_list, list) { |
| 3929 | atomic_inc(&vha->vref_count); |
| 3930 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Dan Carpenter | 8ae598d | 2010-12-21 16:00:15 -0800 | [diff] [blame] | 3931 | if (fcport->drport && |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3932 | atomic_read(&fcport->state) != FCS_UNCONFIGURED) { |
| 3933 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3934 | |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3935 | qla2x00_rport_del(fcport); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3936 | |
| 3937 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 3938 | } |
| 3939 | } |
| 3940 | atomic_dec(&vha->vref_count); |
| 3941 | } |
| 3942 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3943 | } |
| 3944 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 3945 | /* |
| 3946 | * qla82xx_quiescent_state_cleanup |
| 3947 | * Description: This function will block the new I/Os |
| 3948 | * Its not aborting any I/Os as context |
| 3949 | * is not destroyed during quiescence |
| 3950 | * Arguments: scsi_qla_host_t |
| 3951 | * return : void |
| 3952 | */ |
| 3953 | void |
| 3954 | qla82xx_quiescent_state_cleanup(scsi_qla_host_t *vha) |
| 3955 | { |
| 3956 | struct qla_hw_data *ha = vha->hw; |
| 3957 | struct scsi_qla_host *vp; |
| 3958 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3959 | ql_dbg(ql_dbg_p3p, vha, 0xb002, |
| 3960 | "Performing ISP error recovery - ha=%p.\n", ha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 3961 | |
| 3962 | atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); |
| 3963 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 3964 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 3965 | qla2x00_mark_all_devices_lost(vha, 0); |
| 3966 | list_for_each_entry(vp, &ha->vp_list, list) |
| 3967 | qla2x00_mark_all_devices_lost(vha, 0); |
| 3968 | } else { |
| 3969 | if (!atomic_read(&vha->loop_down_timer)) |
| 3970 | atomic_set(&vha->loop_down_timer, |
| 3971 | LOOP_DOWN_TIME); |
| 3972 | } |
| 3973 | /* Wait for pending cmds to complete */ |
| 3974 | qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST); |
| 3975 | } |
| 3976 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3977 | void |
| 3978 | qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha) |
| 3979 | { |
| 3980 | struct qla_hw_data *ha = vha->hw; |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 3981 | struct scsi_qla_host *vp; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3982 | unsigned long flags; |
Andrew Vasquez | 6aef87b | 2011-02-23 15:27:13 -0800 | [diff] [blame] | 3983 | fc_port_t *fcport; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3984 | |
Saurav Kashyap | e46ef00 | 2011-02-23 15:27:16 -0800 | [diff] [blame] | 3985 | /* For ISP82XX, driver waits for completion of the commands. |
| 3986 | * online flag should be set. |
| 3987 | */ |
| 3988 | if (!IS_QLA82XX(ha)) |
| 3989 | vha->flags.online = 0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3990 | ha->flags.chip_reset_done = 0; |
| 3991 | clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 3992 | ha->qla_stats.total_isp_aborts++; |
| 3993 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3994 | ql_log(ql_log_info, vha, 0x00af, |
| 3995 | "Performing ISP error recovery - ha=%p.\n", ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3996 | |
Saurav Kashyap | e46ef00 | 2011-02-23 15:27:16 -0800 | [diff] [blame] | 3997 | /* For ISP82XX, reset_chip is just disabling interrupts. |
| 3998 | * Driver waits for the completion of the commands. |
| 3999 | * the interrupts need to be enabled. |
| 4000 | */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4001 | if (!IS_QLA82XX(ha)) |
| 4002 | ha->isp_ops->reset_chip(vha); |
| 4003 | |
| 4004 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 4005 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 4006 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 4007 | qla2x00_mark_all_devices_lost(vha, 0); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4008 | |
| 4009 | spin_lock_irqsave(&ha->vport_slock, flags); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4010 | list_for_each_entry(vp, &ha->vp_list, list) { |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4011 | atomic_inc(&vp->vref_count); |
| 4012 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 4013 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4014 | qla2x00_mark_all_devices_lost(vp, 0); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4015 | |
| 4016 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 4017 | atomic_dec(&vp->vref_count); |
| 4018 | } |
| 4019 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4020 | } else { |
| 4021 | if (!atomic_read(&vha->loop_down_timer)) |
| 4022 | atomic_set(&vha->loop_down_timer, |
| 4023 | LOOP_DOWN_TIME); |
| 4024 | } |
| 4025 | |
Andrew Vasquez | 6aef87b | 2011-02-23 15:27:13 -0800 | [diff] [blame] | 4026 | /* Clear all async request states across all VPs. */ |
| 4027 | list_for_each_entry(fcport, &vha->vp_fcports, list) |
| 4028 | fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); |
| 4029 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 4030 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 4031 | atomic_inc(&vp->vref_count); |
| 4032 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 4033 | |
| 4034 | list_for_each_entry(fcport, &vp->vp_fcports, list) |
| 4035 | fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); |
| 4036 | |
| 4037 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 4038 | atomic_dec(&vp->vref_count); |
| 4039 | } |
| 4040 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 4041 | |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 4042 | if (!ha->flags.eeh_busy) { |
| 4043 | /* Make sure for ISP 82XX IO DMA is complete */ |
| 4044 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 4045 | qla82xx_chip_reset_cleanup(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4046 | ql_log(ql_log_info, vha, 0x00b4, |
| 4047 | "Done chip reset cleanup.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4048 | |
Saurav Kashyap | e46ef00 | 2011-02-23 15:27:16 -0800 | [diff] [blame] | 4049 | /* Done waiting for pending commands. |
| 4050 | * Reset the online flag. |
| 4051 | */ |
| 4052 | vha->flags.online = 0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4053 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4054 | |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 4055 | /* Requeue all commands in outstanding command list. */ |
| 4056 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
| 4057 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4058 | } |
| 4059 | |
| 4060 | /* |
| 4061 | * qla2x00_abort_isp |
| 4062 | * Resets ISP and aborts all outstanding commands. |
| 4063 | * |
| 4064 | * Input: |
| 4065 | * ha = adapter block pointer. |
| 4066 | * |
| 4067 | * Returns: |
| 4068 | * 0 = success |
| 4069 | */ |
| 4070 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4071 | qla2x00_abort_isp(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4072 | { |
Andrew Vasquez | 476e897 | 2006-08-23 14:54:55 -0700 | [diff] [blame] | 4073 | int rval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4074 | uint8_t status = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4075 | struct qla_hw_data *ha = vha->hw; |
| 4076 | struct scsi_qla_host *vp; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4077 | struct req_que *req = ha->req_q_map[0]; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4078 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4079 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4080 | if (vha->flags.online) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4081 | qla2x00_abort_isp_cleanup(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4082 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4083 | if (unlikely(pci_channel_offline(ha->pdev) && |
| 4084 | ha->flags.pci_channel_io_perm_failure)) { |
| 4085 | clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
| 4086 | status = 0; |
| 4087 | return status; |
| 4088 | } |
| 4089 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4090 | ha->isp_ops->get_flash_version(vha, req->ring); |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 4091 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4092 | ha->isp_ops->nvram_config(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4093 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4094 | if (!qla2x00_restart_isp(vha)) { |
| 4095 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4096 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4097 | if (!atomic_read(&vha->loop_down_timer)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4098 | /* |
| 4099 | * Issue marker command only when we are going |
| 4100 | * to start the I/O . |
| 4101 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4102 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4103 | } |
| 4104 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4105 | vha->flags.online = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4106 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 4107 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4108 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 4109 | ha->isp_abort_cnt = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4110 | clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
Andrew Vasquez | 476e897 | 2006-08-23 14:54:55 -0700 | [diff] [blame] | 4111 | |
Lalit Chandivade | 29c5397 | 2009-10-13 15:16:47 -0700 | [diff] [blame] | 4112 | if (IS_QLA81XX(ha)) |
| 4113 | qla2x00_get_fw_version(vha, |
| 4114 | &ha->fw_major_version, |
| 4115 | &ha->fw_minor_version, |
| 4116 | &ha->fw_subminor_version, |
| 4117 | &ha->fw_attributes, &ha->fw_memory_size, |
| 4118 | ha->mpi_version, &ha->mpi_capabilities, |
| 4119 | ha->phy_version); |
| 4120 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 4121 | if (ha->fce) { |
| 4122 | ha->flags.fce_enabled = 1; |
| 4123 | memset(ha->fce, 0, |
| 4124 | fce_calc_size(ha->fce_bufs)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4125 | rval = qla2x00_enable_fce_trace(vha, |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 4126 | ha->fce_dma, ha->fce_bufs, ha->fce_mb, |
| 4127 | &ha->fce_bufs); |
| 4128 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4129 | ql_log(ql_log_warn, vha, 0x8033, |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 4130 | "Unable to reinitialize FCE " |
| 4131 | "(%d).\n", rval); |
| 4132 | ha->flags.fce_enabled = 0; |
| 4133 | } |
| 4134 | } |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 4135 | |
| 4136 | if (ha->eft) { |
| 4137 | memset(ha->eft, 0, EFT_SIZE); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4138 | rval = qla2x00_enable_eft_trace(vha, |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 4139 | ha->eft_dma, EFT_NUM_BUFFERS); |
| 4140 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4141 | ql_log(ql_log_warn, vha, 0x8034, |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 4142 | "Unable to reinitialize EFT " |
| 4143 | "(%d).\n", rval); |
| 4144 | } |
| 4145 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4146 | } else { /* failed the ISP abort */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4147 | vha->flags.online = 1; |
| 4148 | if (test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4149 | if (ha->isp_abort_cnt == 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4150 | ql_log(ql_log_fatal, vha, 0x8035, |
| 4151 | "ISP error recover failed - " |
| 4152 | "board disabled.\n"); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 4153 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4154 | * The next call disables the board |
| 4155 | * completely. |
| 4156 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4157 | ha->isp_ops->reset_adapter(vha); |
| 4158 | vha->flags.online = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4159 | clear_bit(ISP_ABORT_RETRY, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4160 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4161 | status = 0; |
| 4162 | } else { /* schedule another ISP abort */ |
| 4163 | ha->isp_abort_cnt--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4164 | ql_dbg(ql_dbg_taskm, vha, 0x8020, |
| 4165 | "ISP abort - retry remaining %d.\n", |
| 4166 | ha->isp_abort_cnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4167 | status = 1; |
| 4168 | } |
| 4169 | } else { |
| 4170 | ha->isp_abort_cnt = MAX_RETRIES_OF_ISP_ABORT; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4171 | ql_dbg(ql_dbg_taskm, vha, 0x8021, |
| 4172 | "ISP error recovery - retrying (%d) " |
| 4173 | "more times.\n", ha->isp_abort_cnt); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4174 | set_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4175 | status = 1; |
| 4176 | } |
| 4177 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 4178 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4179 | } |
| 4180 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4181 | if (!status) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4182 | ql_dbg(ql_dbg_taskm, vha, 0x8022, "%s succeeded.\n", __func__); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4183 | |
| 4184 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 4185 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 4186 | if (vp->vp_idx) { |
| 4187 | atomic_inc(&vp->vref_count); |
| 4188 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 4189 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4190 | qla2x00_vp_abort_isp(vp); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4191 | |
| 4192 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 4193 | atomic_dec(&vp->vref_count); |
| 4194 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4195 | } |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4196 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 4197 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4198 | } else { |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 4199 | ql_log(ql_log_warn, vha, 0x8023, "%s **** FAILED ****.\n", |
| 4200 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4201 | } |
| 4202 | |
| 4203 | return(status); |
| 4204 | } |
| 4205 | |
| 4206 | /* |
| 4207 | * qla2x00_restart_isp |
| 4208 | * restarts the ISP after a reset |
| 4209 | * |
| 4210 | * Input: |
| 4211 | * ha = adapter block pointer. |
| 4212 | * |
| 4213 | * Returns: |
| 4214 | * 0 = success |
| 4215 | */ |
| 4216 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4217 | qla2x00_restart_isp(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4218 | { |
Andrew Vasquez | c6b2fca | 2009-03-05 11:07:03 -0800 | [diff] [blame] | 4219 | int status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4220 | uint32_t wait_time; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4221 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4222 | struct req_que *req = ha->req_q_map[0]; |
| 4223 | struct rsp_que *rsp = ha->rsp_q_map[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4224 | |
| 4225 | /* If firmware needs to be loaded */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4226 | if (qla2x00_isp_firmware(vha)) { |
| 4227 | vha->flags.online = 0; |
| 4228 | status = ha->isp_ops->chip_diag(vha); |
| 4229 | if (!status) |
| 4230 | status = qla2x00_setup_chip(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4231 | } |
| 4232 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4233 | if (!status && !(status = qla2x00_init_rings(vha))) { |
| 4234 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 4235 | ha->flags.chip_reset_done = 1; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4236 | /* Initialize the queues in use */ |
| 4237 | qla25xx_init_queues(ha); |
| 4238 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4239 | status = qla2x00_fw_ready(vha); |
| 4240 | if (!status) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4241 | ql_dbg(ql_dbg_taskm, vha, 0x8031, |
| 4242 | "Start configure loop status = %d.\n", status); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4243 | |
| 4244 | /* Issue a marker after FW becomes ready. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4245 | qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4246 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4247 | vha->flags.online = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4248 | /* Wait at most MAX_TARGET RSCNs for a stable link. */ |
| 4249 | wait_time = 256; |
| 4250 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4251 | clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 4252 | qla2x00_configure_loop(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4253 | wait_time--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4254 | } while (!atomic_read(&vha->loop_down_timer) && |
| 4255 | !(test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) |
| 4256 | && wait_time && (test_bit(LOOP_RESYNC_NEEDED, |
| 4257 | &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4258 | } |
| 4259 | |
| 4260 | /* if no cable then assume it's good */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4261 | if ((vha->device_flags & DFLG_NO_CABLE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4262 | status = 0; |
| 4263 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4264 | ql_dbg(ql_dbg_taskm, vha, 0x8032, |
| 4265 | "Configure loop done, status = 0x%x.\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4266 | } |
| 4267 | return (status); |
| 4268 | } |
| 4269 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4270 | static int |
| 4271 | qla25xx_init_queues(struct qla_hw_data *ha) |
| 4272 | { |
| 4273 | struct rsp_que *rsp = NULL; |
| 4274 | struct req_que *req = NULL; |
| 4275 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
| 4276 | int ret = -1; |
| 4277 | int i; |
| 4278 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 4279 | for (i = 1; i < ha->max_rsp_queues; i++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4280 | rsp = ha->rsp_q_map[i]; |
| 4281 | if (rsp) { |
| 4282 | rsp->options &= ~BIT_0; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4283 | ret = qla25xx_init_rsp_que(base_vha, rsp); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4284 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4285 | ql_dbg(ql_dbg_init, base_vha, 0x00ff, |
| 4286 | "%s Rsp que: %d init failed.\n", |
| 4287 | __func__, rsp->id); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4288 | else |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4289 | ql_dbg(ql_dbg_init, base_vha, 0x0100, |
| 4290 | "%s Rsp que: %d inited.\n", |
| 4291 | __func__, rsp->id); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4292 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 4293 | } |
| 4294 | for (i = 1; i < ha->max_req_queues; i++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4295 | req = ha->req_q_map[i]; |
| 4296 | if (req) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 4297 | /* Clear outstanding commands array. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4298 | req->options &= ~BIT_0; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4299 | ret = qla25xx_init_req_que(base_vha, req); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4300 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4301 | ql_dbg(ql_dbg_init, base_vha, 0x0101, |
| 4302 | "%s Req que: %d init failed.\n", |
| 4303 | __func__, req->id); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4304 | else |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4305 | ql_dbg(ql_dbg_init, base_vha, 0x0102, |
| 4306 | "%s Req que: %d inited.\n", |
| 4307 | __func__, req->id); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4308 | } |
| 4309 | } |
| 4310 | return ret; |
| 4311 | } |
| 4312 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4313 | /* |
| 4314 | * qla2x00_reset_adapter |
| 4315 | * Reset adapter. |
| 4316 | * |
| 4317 | * Input: |
| 4318 | * ha = adapter block pointer. |
| 4319 | */ |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 4320 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4321 | qla2x00_reset_adapter(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4322 | { |
| 4323 | unsigned long flags = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4324 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 4325 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4326 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4327 | vha->flags.online = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 4328 | ha->isp_ops->disable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4329 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4330 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 4331 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 4332 | RD_REG_WORD(®->hccr); /* PCI Posting. */ |
| 4333 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
| 4334 | RD_REG_WORD(®->hccr); /* PCI Posting. */ |
| 4335 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 4336 | } |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4337 | |
| 4338 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4339 | qla24xx_reset_adapter(scsi_qla_host_t *vha) |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4340 | { |
| 4341 | unsigned long flags = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4342 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4343 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 4344 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4345 | if (IS_QLA82XX(ha)) |
| 4346 | return; |
| 4347 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4348 | vha->flags.online = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 4349 | ha->isp_ops->disable_intrs(ha); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4350 | |
| 4351 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 4352 | WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_RESET); |
| 4353 | RD_REG_DWORD(®->hccr); |
| 4354 | WRT_REG_DWORD(®->hccr, HCCRX_REL_RISC_PAUSE); |
| 4355 | RD_REG_DWORD(®->hccr); |
| 4356 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 09ff36d | 2009-01-22 09:45:30 -0800 | [diff] [blame] | 4357 | |
| 4358 | if (IS_NOPOLLING_TYPE(ha)) |
| 4359 | ha->isp_ops->enable_intrs(ha); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4360 | } |
| 4361 | |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4362 | /* On sparc systems, obtain port and node WWN from firmware |
| 4363 | * properties. |
| 4364 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4365 | static void qla24xx_nvram_wwn_from_ofw(scsi_qla_host_t *vha, |
| 4366 | struct nvram_24xx *nv) |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4367 | { |
| 4368 | #ifdef CONFIG_SPARC |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4369 | struct qla_hw_data *ha = vha->hw; |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4370 | struct pci_dev *pdev = ha->pdev; |
David S. Miller | 15576bc | 2007-05-08 00:36:49 -0700 | [diff] [blame] | 4371 | struct device_node *dp = pci_device_to_OF_node(pdev); |
| 4372 | const u8 *val; |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4373 | int len; |
| 4374 | |
| 4375 | val = of_get_property(dp, "port-wwn", &len); |
| 4376 | if (val && len >= WWN_SIZE) |
| 4377 | memcpy(nv->port_name, val, WWN_SIZE); |
| 4378 | |
| 4379 | val = of_get_property(dp, "node-wwn", &len); |
| 4380 | if (val && len >= WWN_SIZE) |
| 4381 | memcpy(nv->node_name, val, WWN_SIZE); |
| 4382 | #endif |
| 4383 | } |
| 4384 | |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4385 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4386 | qla24xx_nvram_config(scsi_qla_host_t *vha) |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4387 | { |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4388 | int rval; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4389 | struct init_cb_24xx *icb; |
| 4390 | struct nvram_24xx *nv; |
| 4391 | uint32_t *dptr; |
| 4392 | uint8_t *dptr1, *dptr2; |
| 4393 | uint32_t chksum; |
| 4394 | uint16_t cnt; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4395 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4396 | |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4397 | rval = QLA_SUCCESS; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4398 | icb = (struct init_cb_24xx *)ha->init_cb; |
Seokmann Ju | 281afe1 | 2007-07-26 13:43:34 -0700 | [diff] [blame] | 4399 | nv = ha->nvram; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4400 | |
| 4401 | /* Determine NVRAM starting address. */ |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 4402 | if (ha->flags.port0) { |
| 4403 | ha->nvram_base = FA_NVRAM_FUNC0_ADDR; |
| 4404 | ha->vpd_base = FA_NVRAM_VPD0_ADDR; |
| 4405 | } else { |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4406 | ha->nvram_base = FA_NVRAM_FUNC1_ADDR; |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 4407 | ha->vpd_base = FA_NVRAM_VPD1_ADDR; |
| 4408 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 4409 | ha->nvram_size = sizeof(struct nvram_24xx); |
| 4410 | ha->vpd_size = FA_NVRAM_VPD_SIZE; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4411 | if (IS_QLA82XX(ha)) |
| 4412 | ha->vpd_size = FA_VPD_SIZE_82XX; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4413 | |
Seokmann Ju | 281afe1 | 2007-07-26 13:43:34 -0700 | [diff] [blame] | 4414 | /* Get VPD data into cache */ |
| 4415 | ha->vpd = ha->nvram + VPD_OFFSET; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4416 | ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, |
Seokmann Ju | 281afe1 | 2007-07-26 13:43:34 -0700 | [diff] [blame] | 4417 | ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4); |
| 4418 | |
| 4419 | /* Get NVRAM data into cache and calculate checksum. */ |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4420 | dptr = (uint32_t *)nv; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4421 | ha->isp_ops->read_nvram(vha, (uint8_t *)dptr, ha->nvram_base, |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4422 | ha->nvram_size); |
| 4423 | for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++) |
| 4424 | chksum += le32_to_cpu(*dptr++); |
| 4425 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4426 | ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x006a, |
| 4427 | "Contents of NVRAM\n"); |
| 4428 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x010d, |
| 4429 | (uint8_t *)nv, ha->nvram_size); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4430 | |
| 4431 | /* Bad NVRAM data, set defaults parameters. */ |
| 4432 | if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P' |
| 4433 | || nv->id[3] != ' ' || |
| 4434 | nv->nvram_version < __constant_cpu_to_le16(ICB_VERSION)) { |
| 4435 | /* Reset NVRAM data. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4436 | ql_log(ql_log_warn, vha, 0x006b, |
| 4437 | "Inconisistent NVRAM detected: checksum=0x%x id=%c " |
| 4438 | "version=0x%x.\n", chksum, nv->id[0], nv->nvram_version); |
| 4439 | ql_log(ql_log_warn, vha, 0x006c, |
| 4440 | "Falling back to functioning (yet invalid -- WWPN) " |
| 4441 | "defaults.\n"); |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4442 | |
| 4443 | /* |
| 4444 | * Set default initialization control block. |
| 4445 | */ |
| 4446 | memset(nv, 0, ha->nvram_size); |
| 4447 | nv->nvram_version = __constant_cpu_to_le16(ICB_VERSION); |
| 4448 | nv->version = __constant_cpu_to_le16(ICB_VERSION); |
| 4449 | nv->frame_payload_size = __constant_cpu_to_le16(2048); |
| 4450 | nv->execution_throttle = __constant_cpu_to_le16(0xFFFF); |
| 4451 | nv->exchange_count = __constant_cpu_to_le16(0); |
| 4452 | nv->hard_address = __constant_cpu_to_le16(124); |
| 4453 | nv->port_name[0] = 0x21; |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 4454 | nv->port_name[1] = 0x00 + ha->port_no; |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4455 | nv->port_name[2] = 0x00; |
| 4456 | nv->port_name[3] = 0xe0; |
| 4457 | nv->port_name[4] = 0x8b; |
| 4458 | nv->port_name[5] = 0x1c; |
| 4459 | nv->port_name[6] = 0x55; |
| 4460 | nv->port_name[7] = 0x86; |
| 4461 | nv->node_name[0] = 0x20; |
| 4462 | nv->node_name[1] = 0x00; |
| 4463 | nv->node_name[2] = 0x00; |
| 4464 | nv->node_name[3] = 0xe0; |
| 4465 | nv->node_name[4] = 0x8b; |
| 4466 | nv->node_name[5] = 0x1c; |
| 4467 | nv->node_name[6] = 0x55; |
| 4468 | nv->node_name[7] = 0x86; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4469 | qla24xx_nvram_wwn_from_ofw(vha, nv); |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4470 | nv->login_retry_count = __constant_cpu_to_le16(8); |
| 4471 | nv->interrupt_delay_timer = __constant_cpu_to_le16(0); |
| 4472 | nv->login_timeout = __constant_cpu_to_le16(0); |
| 4473 | nv->firmware_options_1 = |
| 4474 | __constant_cpu_to_le32(BIT_14|BIT_13|BIT_2|BIT_1); |
| 4475 | nv->firmware_options_2 = __constant_cpu_to_le32(2 << 4); |
| 4476 | nv->firmware_options_2 |= __constant_cpu_to_le32(BIT_12); |
| 4477 | nv->firmware_options_3 = __constant_cpu_to_le32(2 << 13); |
| 4478 | nv->host_p = __constant_cpu_to_le32(BIT_11|BIT_10); |
| 4479 | nv->efi_parameters = __constant_cpu_to_le32(0); |
| 4480 | nv->reset_delay = 5; |
| 4481 | nv->max_luns_per_target = __constant_cpu_to_le16(128); |
| 4482 | nv->port_down_retry_count = __constant_cpu_to_le16(30); |
| 4483 | nv->link_down_timeout = __constant_cpu_to_le16(30); |
| 4484 | |
| 4485 | rval = 1; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4486 | } |
| 4487 | |
| 4488 | /* Reset Initialization control block */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4489 | memset(icb, 0, ha->init_cb_size); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4490 | |
| 4491 | /* Copy 1st segment. */ |
| 4492 | dptr1 = (uint8_t *)icb; |
| 4493 | dptr2 = (uint8_t *)&nv->version; |
| 4494 | cnt = (uint8_t *)&icb->response_q_inpointer - (uint8_t *)&icb->version; |
| 4495 | while (cnt--) |
| 4496 | *dptr1++ = *dptr2++; |
| 4497 | |
| 4498 | icb->login_retry_count = nv->login_retry_count; |
Andrew Vasquez | 3ea66e2 | 2006-06-23 16:11:27 -0700 | [diff] [blame] | 4499 | icb->link_down_on_nos = nv->link_down_on_nos; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4500 | |
| 4501 | /* Copy 2nd segment. */ |
| 4502 | dptr1 = (uint8_t *)&icb->interrupt_delay_timer; |
| 4503 | dptr2 = (uint8_t *)&nv->interrupt_delay_timer; |
| 4504 | cnt = (uint8_t *)&icb->reserved_3 - |
| 4505 | (uint8_t *)&icb->interrupt_delay_timer; |
| 4506 | while (cnt--) |
| 4507 | *dptr1++ = *dptr2++; |
| 4508 | |
| 4509 | /* |
| 4510 | * Setup driver NVRAM options. |
| 4511 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4512 | qla2x00_set_model_info(vha, nv->model_name, sizeof(nv->model_name), |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 4513 | "QLA2462"); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4514 | |
Andrew Vasquez | 5341e86 | 2006-05-17 15:09:16 -0700 | [diff] [blame] | 4515 | /* Use alternate WWN? */ |
| 4516 | if (nv->host_p & __constant_cpu_to_le32(BIT_15)) { |
| 4517 | memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); |
| 4518 | memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); |
| 4519 | } |
| 4520 | |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4521 | /* Prepare nodename */ |
Andrew Vasquez | fd0e7e4 | 2006-05-17 15:09:11 -0700 | [diff] [blame] | 4522 | if ((icb->firmware_options_1 & __constant_cpu_to_le32(BIT_14)) == 0) { |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4523 | /* |
| 4524 | * Firmware will apply the following mask if the nodename was |
| 4525 | * not provided. |
| 4526 | */ |
| 4527 | memcpy(icb->node_name, icb->port_name, WWN_SIZE); |
| 4528 | icb->node_name[0] &= 0xF0; |
| 4529 | } |
| 4530 | |
| 4531 | /* Set host adapter parameters. */ |
| 4532 | ha->flags.disable_risc_code_load = 0; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 4533 | ha->flags.enable_lip_reset = 0; |
| 4534 | ha->flags.enable_lip_full_login = |
| 4535 | le32_to_cpu(nv->host_p) & BIT_10 ? 1: 0; |
| 4536 | ha->flags.enable_target_reset = |
| 4537 | le32_to_cpu(nv->host_p) & BIT_11 ? 1: 0; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4538 | ha->flags.enable_led_scheme = 0; |
Andrew Vasquez | d4c760c | 2006-06-23 16:10:39 -0700 | [diff] [blame] | 4539 | ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1: 0; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4540 | |
Andrew Vasquez | fd0e7e4 | 2006-05-17 15:09:11 -0700 | [diff] [blame] | 4541 | ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) & |
| 4542 | (BIT_6 | BIT_5 | BIT_4)) >> 4; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4543 | |
| 4544 | memcpy(ha->fw_seriallink_options24, nv->seriallink_options, |
| 4545 | sizeof(ha->fw_seriallink_options24)); |
| 4546 | |
| 4547 | /* save HBA serial number */ |
| 4548 | ha->serial0 = icb->port_name[5]; |
| 4549 | ha->serial1 = icb->port_name[6]; |
| 4550 | ha->serial2 = icb->port_name[7]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4551 | memcpy(vha->node_name, icb->node_name, WWN_SIZE); |
| 4552 | memcpy(vha->port_name, icb->port_name, WWN_SIZE); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4553 | |
andrew.vasquez@qlogic.com | bc8fb3c | 2006-01-13 17:05:42 -0800 | [diff] [blame] | 4554 | icb->execution_throttle = __constant_cpu_to_le16(0xFFFF); |
| 4555 | |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4556 | ha->retry_count = le16_to_cpu(nv->login_retry_count); |
| 4557 | |
| 4558 | /* Set minimum login_timeout to 4 seconds. */ |
| 4559 | if (le16_to_cpu(nv->login_timeout) < ql2xlogintimeout) |
| 4560 | nv->login_timeout = cpu_to_le16(ql2xlogintimeout); |
| 4561 | if (le16_to_cpu(nv->login_timeout) < 4) |
| 4562 | nv->login_timeout = __constant_cpu_to_le16(4); |
| 4563 | ha->login_timeout = le16_to_cpu(nv->login_timeout); |
Seokmann Ju | c6852c4 | 2008-04-24 15:21:29 -0700 | [diff] [blame] | 4564 | icb->login_timeout = nv->login_timeout; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4565 | |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 4566 | /* Set minimum RATOV to 100 tenths of a second. */ |
| 4567 | ha->r_a_tov = 100; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4568 | |
| 4569 | ha->loop_reset_delay = nv->reset_delay; |
| 4570 | |
| 4571 | /* Link Down Timeout = 0: |
| 4572 | * |
| 4573 | * When Port Down timer expires we will start returning |
| 4574 | * I/O's to OS with "DID_NO_CONNECT". |
| 4575 | * |
| 4576 | * Link Down Timeout != 0: |
| 4577 | * |
| 4578 | * The driver waits for the link to come up after link down |
| 4579 | * before returning I/Os to OS with "DID_NO_CONNECT". |
| 4580 | */ |
| 4581 | if (le16_to_cpu(nv->link_down_timeout) == 0) { |
| 4582 | ha->loop_down_abort_time = |
| 4583 | (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); |
| 4584 | } else { |
| 4585 | ha->link_down_timeout = le16_to_cpu(nv->link_down_timeout); |
| 4586 | ha->loop_down_abort_time = |
| 4587 | (LOOP_DOWN_TIME - ha->link_down_timeout); |
| 4588 | } |
| 4589 | |
| 4590 | /* Need enough time to try and get the port back. */ |
| 4591 | ha->port_down_retry_count = le16_to_cpu(nv->port_down_retry_count); |
| 4592 | if (qlport_down_retry) |
| 4593 | ha->port_down_retry_count = qlport_down_retry; |
| 4594 | |
| 4595 | /* Set login_retry_count */ |
| 4596 | ha->login_retry_count = le16_to_cpu(nv->login_retry_count); |
| 4597 | if (ha->port_down_retry_count == |
| 4598 | le16_to_cpu(nv->port_down_retry_count) && |
| 4599 | ha->port_down_retry_count > 3) |
| 4600 | ha->login_retry_count = ha->port_down_retry_count; |
| 4601 | else if (ha->port_down_retry_count > (int)ha->login_retry_count) |
| 4602 | ha->login_retry_count = ha->port_down_retry_count; |
| 4603 | if (ql2xloginretrycount) |
| 4604 | ha->login_retry_count = ql2xloginretrycount; |
| 4605 | |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 4606 | /* Enable ZIO. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4607 | if (!vha->flags.init_done) { |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 4608 | ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & |
| 4609 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
| 4610 | ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? |
| 4611 | le16_to_cpu(icb->interrupt_delay_timer): 2; |
| 4612 | } |
| 4613 | icb->firmware_options_2 &= __constant_cpu_to_le32( |
| 4614 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4615 | vha->flags.process_response_queue = 0; |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 4616 | if (ha->zio_mode != QLA_ZIO_DISABLED) { |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 4617 | ha->zio_mode = QLA_ZIO_MODE_6; |
| 4618 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4619 | ql_log(ql_log_info, vha, 0x006f, |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 4620 | "ZIO mode %d enabled; timer delay (%d us).\n", |
| 4621 | ha->zio_mode, ha->zio_timer * 100); |
| 4622 | |
| 4623 | icb->firmware_options_2 |= cpu_to_le32( |
| 4624 | (uint32_t)ha->zio_mode); |
| 4625 | icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4626 | vha->flags.process_response_queue = 1; |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 4627 | } |
| 4628 | |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4629 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4630 | ql_log(ql_log_warn, vha, 0x0070, |
| 4631 | "NVRAM configuration failed.\n"); |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4632 | } |
| 4633 | return (rval); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4634 | } |
| 4635 | |
Adrian Bunk | 413975a | 2006-06-30 02:33:06 -0700 | [diff] [blame] | 4636 | static int |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4637 | qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr, |
| 4638 | uint32_t faddr) |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4639 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4640 | int rval = QLA_SUCCESS; |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4641 | int segments, fragment; |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4642 | uint32_t *dcode, dlen; |
| 4643 | uint32_t risc_addr; |
| 4644 | uint32_t risc_size; |
| 4645 | uint32_t i; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4646 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4647 | struct req_que *req = ha->req_q_map[0]; |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4648 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4649 | ql_dbg(ql_dbg_init, vha, 0x008b, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 4650 | "FW: Loading firmware from flash (%x).\n", faddr); |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4651 | |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4652 | rval = QLA_SUCCESS; |
| 4653 | |
| 4654 | segments = FA_RISC_CODE_SEGMENTS; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4655 | dcode = (uint32_t *)req->ring; |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4656 | *srisc_addr = 0; |
| 4657 | |
| 4658 | /* Validate firmware image by checking version. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4659 | qla24xx_read_flash_data(vha, dcode, faddr + 4, 4); |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4660 | for (i = 0; i < 4; i++) |
| 4661 | dcode[i] = be32_to_cpu(dcode[i]); |
| 4662 | if ((dcode[0] == 0xffffffff && dcode[1] == 0xffffffff && |
| 4663 | dcode[2] == 0xffffffff && dcode[3] == 0xffffffff) || |
| 4664 | (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 && |
| 4665 | dcode[3] == 0)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4666 | ql_log(ql_log_fatal, vha, 0x008c, |
| 4667 | "Unable to verify the integrity of flash firmware " |
| 4668 | "image.\n"); |
| 4669 | ql_log(ql_log_fatal, vha, 0x008d, |
| 4670 | "Firmware data: %08x %08x %08x %08x.\n", |
| 4671 | dcode[0], dcode[1], dcode[2], dcode[3]); |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4672 | |
| 4673 | return QLA_FUNCTION_FAILED; |
| 4674 | } |
| 4675 | |
| 4676 | while (segments && rval == QLA_SUCCESS) { |
| 4677 | /* Read segment's load information. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4678 | qla24xx_read_flash_data(vha, dcode, faddr, 4); |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4679 | |
| 4680 | risc_addr = be32_to_cpu(dcode[2]); |
| 4681 | *srisc_addr = *srisc_addr == 0 ? risc_addr : *srisc_addr; |
| 4682 | risc_size = be32_to_cpu(dcode[3]); |
| 4683 | |
| 4684 | fragment = 0; |
| 4685 | while (risc_size > 0 && rval == QLA_SUCCESS) { |
| 4686 | dlen = (uint32_t)(ha->fw_transfer_size >> 2); |
| 4687 | if (dlen > risc_size) |
| 4688 | dlen = risc_size; |
| 4689 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4690 | ql_dbg(ql_dbg_init, vha, 0x008e, |
| 4691 | "Loading risc segment@ risc addr %x " |
| 4692 | "number of dwords 0x%x offset 0x%x.\n", |
| 4693 | risc_addr, dlen, faddr); |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4694 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4695 | qla24xx_read_flash_data(vha, dcode, faddr, dlen); |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4696 | for (i = 0; i < dlen; i++) |
| 4697 | dcode[i] = swab32(dcode[i]); |
| 4698 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4699 | rval = qla2x00_load_ram(vha, req->dma, risc_addr, |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4700 | dlen); |
| 4701 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4702 | ql_log(ql_log_fatal, vha, 0x008f, |
| 4703 | "Failed to load segment %d of firmware.\n", |
| 4704 | fragment); |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4705 | break; |
| 4706 | } |
| 4707 | |
| 4708 | faddr += dlen; |
| 4709 | risc_addr += dlen; |
| 4710 | risc_size -= dlen; |
| 4711 | fragment++; |
| 4712 | } |
| 4713 | |
| 4714 | /* Next segment. */ |
| 4715 | segments--; |
| 4716 | } |
| 4717 | |
| 4718 | return rval; |
| 4719 | } |
| 4720 | |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4721 | #define QLA_FW_URL "ftp://ftp.qlogic.com/outgoing/linux/firmware/" |
| 4722 | |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4723 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4724 | qla2x00_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4725 | { |
| 4726 | int rval; |
| 4727 | int i, fragment; |
| 4728 | uint16_t *wcode, *fwcode; |
| 4729 | uint32_t risc_addr, risc_size, fwclen, wlen, *seg; |
| 4730 | struct fw_blob *blob; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4731 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4732 | struct req_que *req = ha->req_q_map[0]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4733 | |
| 4734 | /* Load firmware blob. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4735 | blob = qla2x00_request_firmware(vha); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4736 | if (!blob) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4737 | ql_log(ql_log_info, vha, 0x0083, |
| 4738 | "Fimware image unavailable.\n"); |
| 4739 | ql_log(ql_log_info, vha, 0x0084, |
| 4740 | "Firmware images can be retrieved from: "QLA_FW_URL ".\n"); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4741 | return QLA_FUNCTION_FAILED; |
| 4742 | } |
| 4743 | |
| 4744 | rval = QLA_SUCCESS; |
| 4745 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4746 | wcode = (uint16_t *)req->ring; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4747 | *srisc_addr = 0; |
| 4748 | fwcode = (uint16_t *)blob->fw->data; |
| 4749 | fwclen = 0; |
| 4750 | |
| 4751 | /* Validate firmware image by checking version. */ |
| 4752 | if (blob->fw->size < 8 * sizeof(uint16_t)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4753 | ql_log(ql_log_fatal, vha, 0x0085, |
| 4754 | "Unable to verify integrity of firmware image (%Zd).\n", |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4755 | blob->fw->size); |
| 4756 | goto fail_fw_integrity; |
| 4757 | } |
| 4758 | for (i = 0; i < 4; i++) |
| 4759 | wcode[i] = be16_to_cpu(fwcode[i + 4]); |
| 4760 | if ((wcode[0] == 0xffff && wcode[1] == 0xffff && wcode[2] == 0xffff && |
| 4761 | wcode[3] == 0xffff) || (wcode[0] == 0 && wcode[1] == 0 && |
| 4762 | wcode[2] == 0 && wcode[3] == 0)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4763 | ql_log(ql_log_fatal, vha, 0x0086, |
| 4764 | "Unable to verify integrity of firmware image.\n"); |
| 4765 | ql_log(ql_log_fatal, vha, 0x0087, |
| 4766 | "Firmware data: %04x %04x %04x %04x.\n", |
| 4767 | wcode[0], wcode[1], wcode[2], wcode[3]); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4768 | goto fail_fw_integrity; |
| 4769 | } |
| 4770 | |
| 4771 | seg = blob->segs; |
| 4772 | while (*seg && rval == QLA_SUCCESS) { |
| 4773 | risc_addr = *seg; |
| 4774 | *srisc_addr = *srisc_addr == 0 ? *seg : *srisc_addr; |
| 4775 | risc_size = be16_to_cpu(fwcode[3]); |
| 4776 | |
| 4777 | /* Validate firmware image size. */ |
| 4778 | fwclen += risc_size * sizeof(uint16_t); |
| 4779 | if (blob->fw->size < fwclen) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4780 | ql_log(ql_log_fatal, vha, 0x0088, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4781 | "Unable to verify integrity of firmware image " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4782 | "(%Zd).\n", blob->fw->size); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4783 | goto fail_fw_integrity; |
| 4784 | } |
| 4785 | |
| 4786 | fragment = 0; |
| 4787 | while (risc_size > 0 && rval == QLA_SUCCESS) { |
| 4788 | wlen = (uint16_t)(ha->fw_transfer_size >> 1); |
| 4789 | if (wlen > risc_size) |
| 4790 | wlen = risc_size; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4791 | ql_dbg(ql_dbg_init, vha, 0x0089, |
| 4792 | "Loading risc segment@ risc addr %x number of " |
| 4793 | "words 0x%x.\n", risc_addr, wlen); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4794 | |
| 4795 | for (i = 0; i < wlen; i++) |
| 4796 | wcode[i] = swab16(fwcode[i]); |
| 4797 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4798 | rval = qla2x00_load_ram(vha, req->dma, risc_addr, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4799 | wlen); |
| 4800 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4801 | ql_log(ql_log_fatal, vha, 0x008a, |
| 4802 | "Failed to load segment %d of firmware.\n", |
| 4803 | fragment); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4804 | break; |
| 4805 | } |
| 4806 | |
| 4807 | fwcode += wlen; |
| 4808 | risc_addr += wlen; |
| 4809 | risc_size -= wlen; |
| 4810 | fragment++; |
| 4811 | } |
| 4812 | |
| 4813 | /* Next segment. */ |
| 4814 | seg++; |
| 4815 | } |
| 4816 | return rval; |
| 4817 | |
| 4818 | fail_fw_integrity: |
| 4819 | return QLA_FUNCTION_FAILED; |
| 4820 | } |
| 4821 | |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4822 | static int |
| 4823 | qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t *srisc_addr) |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4824 | { |
| 4825 | int rval; |
| 4826 | int segments, fragment; |
| 4827 | uint32_t *dcode, dlen; |
| 4828 | uint32_t risc_addr; |
| 4829 | uint32_t risc_size; |
| 4830 | uint32_t i; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4831 | struct fw_blob *blob; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4832 | uint32_t *fwcode, fwclen; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4833 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4834 | struct req_que *req = ha->req_q_map[0]; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4835 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4836 | /* Load firmware blob. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4837 | blob = qla2x00_request_firmware(vha); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4838 | if (!blob) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4839 | ql_log(ql_log_warn, vha, 0x0090, |
| 4840 | "Fimware image unavailable.\n"); |
| 4841 | ql_log(ql_log_warn, vha, 0x0091, |
| 4842 | "Firmware images can be retrieved from: " |
| 4843 | QLA_FW_URL ".\n"); |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4844 | |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4845 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4846 | } |
| 4847 | |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 4848 | ql_dbg(ql_dbg_init, vha, 0x0092, |
| 4849 | "FW: Loading via request-firmware.\n"); |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4850 | |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4851 | rval = QLA_SUCCESS; |
| 4852 | |
| 4853 | segments = FA_RISC_CODE_SEGMENTS; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4854 | dcode = (uint32_t *)req->ring; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4855 | *srisc_addr = 0; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4856 | fwcode = (uint32_t *)blob->fw->data; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4857 | fwclen = 0; |
| 4858 | |
| 4859 | /* Validate firmware image by checking version. */ |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4860 | if (blob->fw->size < 8 * sizeof(uint32_t)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4861 | ql_log(ql_log_fatal, vha, 0x0093, |
| 4862 | "Unable to verify integrity of firmware image (%Zd).\n", |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4863 | blob->fw->size); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4864 | goto fail_fw_integrity; |
| 4865 | } |
| 4866 | for (i = 0; i < 4; i++) |
| 4867 | dcode[i] = be32_to_cpu(fwcode[i + 4]); |
| 4868 | if ((dcode[0] == 0xffffffff && dcode[1] == 0xffffffff && |
| 4869 | dcode[2] == 0xffffffff && dcode[3] == 0xffffffff) || |
| 4870 | (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 && |
| 4871 | dcode[3] == 0)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4872 | ql_log(ql_log_fatal, vha, 0x0094, |
| 4873 | "Unable to verify integrity of firmware image (%Zd).\n", |
| 4874 | blob->fw->size); |
| 4875 | ql_log(ql_log_fatal, vha, 0x0095, |
| 4876 | "Firmware data: %08x %08x %08x %08x.\n", |
| 4877 | dcode[0], dcode[1], dcode[2], dcode[3]); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4878 | goto fail_fw_integrity; |
| 4879 | } |
| 4880 | |
| 4881 | while (segments && rval == QLA_SUCCESS) { |
| 4882 | risc_addr = be32_to_cpu(fwcode[2]); |
| 4883 | *srisc_addr = *srisc_addr == 0 ? risc_addr : *srisc_addr; |
| 4884 | risc_size = be32_to_cpu(fwcode[3]); |
| 4885 | |
| 4886 | /* Validate firmware image size. */ |
| 4887 | fwclen += risc_size * sizeof(uint32_t); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4888 | if (blob->fw->size < fwclen) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4889 | ql_log(ql_log_fatal, vha, 0x0096, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4890 | "Unable to verify integrity of firmware image " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4891 | "(%Zd).\n", blob->fw->size); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4892 | |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4893 | goto fail_fw_integrity; |
| 4894 | } |
| 4895 | |
| 4896 | fragment = 0; |
| 4897 | while (risc_size > 0 && rval == QLA_SUCCESS) { |
| 4898 | dlen = (uint32_t)(ha->fw_transfer_size >> 2); |
| 4899 | if (dlen > risc_size) |
| 4900 | dlen = risc_size; |
| 4901 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4902 | ql_dbg(ql_dbg_init, vha, 0x0097, |
| 4903 | "Loading risc segment@ risc addr %x " |
| 4904 | "number of dwords 0x%x.\n", risc_addr, dlen); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4905 | |
| 4906 | for (i = 0; i < dlen; i++) |
| 4907 | dcode[i] = swab32(fwcode[i]); |
| 4908 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4909 | rval = qla2x00_load_ram(vha, req->dma, risc_addr, |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 4910 | dlen); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4911 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4912 | ql_log(ql_log_fatal, vha, 0x0098, |
| 4913 | "Failed to load segment %d of firmware.\n", |
| 4914 | fragment); |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4915 | break; |
| 4916 | } |
| 4917 | |
| 4918 | fwcode += dlen; |
| 4919 | risc_addr += dlen; |
| 4920 | risc_size -= dlen; |
| 4921 | fragment++; |
| 4922 | } |
| 4923 | |
| 4924 | /* Next segment. */ |
| 4925 | segments--; |
| 4926 | } |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4927 | return rval; |
| 4928 | |
| 4929 | fail_fw_integrity: |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4930 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | 0107109 | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4931 | } |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 4932 | |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4933 | int |
| 4934 | qla24xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr) |
| 4935 | { |
| 4936 | int rval; |
| 4937 | |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 4938 | if (ql2xfwloadbin == 1) |
| 4939 | return qla81xx_load_risc(vha, srisc_addr); |
| 4940 | |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4941 | /* |
| 4942 | * FW Load priority: |
| 4943 | * 1) Firmware via request-firmware interface (.bin file). |
| 4944 | * 2) Firmware residing in flash. |
| 4945 | */ |
| 4946 | rval = qla24xx_load_risc_blob(vha, srisc_addr); |
| 4947 | if (rval == QLA_SUCCESS) |
| 4948 | return rval; |
| 4949 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4950 | return qla24xx_load_risc_flash(vha, srisc_addr, |
| 4951 | vha->hw->flt_region_fw); |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4952 | } |
| 4953 | |
| 4954 | int |
| 4955 | qla81xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr) |
| 4956 | { |
| 4957 | int rval; |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4958 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4959 | |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 4960 | if (ql2xfwloadbin == 2) |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4961 | goto try_blob_fw; |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 4962 | |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4963 | /* |
| 4964 | * FW Load priority: |
| 4965 | * 1) Firmware residing in flash. |
| 4966 | * 2) Firmware via request-firmware interface (.bin file). |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4967 | * 3) Golden-Firmware residing in flash -- limited operation. |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4968 | */ |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4969 | rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_fw); |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4970 | if (rval == QLA_SUCCESS) |
| 4971 | return rval; |
| 4972 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4973 | try_blob_fw: |
| 4974 | rval = qla24xx_load_risc_blob(vha, srisc_addr); |
| 4975 | if (rval == QLA_SUCCESS || !ha->flt_region_gold_fw) |
| 4976 | return rval; |
| 4977 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4978 | ql_log(ql_log_info, vha, 0x0099, |
| 4979 | "Attempting to fallback to golden firmware.\n"); |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4980 | rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_gold_fw); |
| 4981 | if (rval != QLA_SUCCESS) |
| 4982 | return rval; |
| 4983 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4984 | ql_log(ql_log_info, vha, 0x009a, "Update operational firmware.\n"); |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4985 | ha->flags.running_gold_fw = 1; |
| 4986 | |
| 4987 | return rval; |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4988 | } |
| 4989 | |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 4990 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4991 | qla2x00_try_to_stop_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 4992 | { |
| 4993 | int ret, retries; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4994 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 4995 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4996 | if (ha->flags.pci_channel_io_perm_failure) |
| 4997 | return; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 4998 | if (!IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 4999 | return; |
Andrew Vasquez | 75edf81 | 2007-05-07 07:43:00 -0700 | [diff] [blame] | 5000 | if (!ha->fw_major_version) |
| 5001 | return; |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 5002 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5003 | ret = qla2x00_stop_firmware(vha); |
Andrew Vasquez | 7c7f1f2 | 2008-02-28 14:06:09 -0800 | [diff] [blame] | 5004 | for (retries = 5; ret != QLA_SUCCESS && ret != QLA_FUNCTION_TIMEOUT && |
Andrew Vasquez | b469a7c | 2009-04-06 22:33:48 -0700 | [diff] [blame] | 5005 | ret != QLA_INVALID_COMMAND && retries ; retries--) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5006 | ha->isp_ops->reset_chip(vha); |
| 5007 | if (ha->isp_ops->chip_diag(vha) != QLA_SUCCESS) |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 5008 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5009 | if (qla2x00_setup_chip(vha) != QLA_SUCCESS) |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 5010 | continue; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5011 | ql_log(ql_log_info, vha, 0x8015, |
| 5012 | "Attempting retry of stop-firmware command.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5013 | ret = qla2x00_stop_firmware(vha); |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 5014 | } |
| 5015 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5016 | |
| 5017 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5018 | qla24xx_configure_vhba(scsi_qla_host_t *vha) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5019 | { |
| 5020 | int rval = QLA_SUCCESS; |
| 5021 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5022 | struct qla_hw_data *ha = vha->hw; |
| 5023 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 5024 | struct req_que *req; |
| 5025 | struct rsp_que *rsp; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5026 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5027 | if (!vha->vp_idx) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5028 | return -EINVAL; |
| 5029 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5030 | rval = qla2x00_fw_ready(base_vha); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 5031 | if (ha->flags.cpu_affinity_enabled) |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 5032 | req = ha->req_q_map[0]; |
| 5033 | else |
| 5034 | req = vha->req; |
| 5035 | rsp = req->rsp; |
| 5036 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5037 | if (rval == QLA_SUCCESS) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5038 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5039 | qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5040 | } |
| 5041 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5042 | vha->flags.management_server_logged_in = 0; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5043 | |
| 5044 | /* Login to SNS first */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5045 | ha->isp_ops->fabric_login(vha, NPH_SNS, 0xff, 0xff, 0xfc, mb, BIT_1); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5046 | if (mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5047 | ql_dbg(ql_dbg_init, vha, 0x0103, |
| 5048 | "Failed SNS login: loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x " |
| 5049 | "mb[6]=%x mb[7]=%x.\n", |
| 5050 | NPH_SNS, mb[0], mb[1], mb[2], mb[6], mb[7]); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5051 | return (QLA_FUNCTION_FAILED); |
| 5052 | } |
| 5053 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5054 | atomic_set(&vha->loop_down_timer, 0); |
| 5055 | atomic_set(&vha->loop_state, LOOP_UP); |
| 5056 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 5057 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 5058 | rval = qla2x00_loop_resync(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5059 | |
| 5060 | return rval; |
| 5061 | } |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5062 | |
| 5063 | /* 84XX Support **************************************************************/ |
| 5064 | |
| 5065 | static LIST_HEAD(qla_cs84xx_list); |
| 5066 | static DEFINE_MUTEX(qla_cs84xx_mutex); |
| 5067 | |
| 5068 | static struct qla_chip_state_84xx * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5069 | qla84xx_get_chip(struct scsi_qla_host *vha) |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5070 | { |
| 5071 | struct qla_chip_state_84xx *cs84xx; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5072 | struct qla_hw_data *ha = vha->hw; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5073 | |
| 5074 | mutex_lock(&qla_cs84xx_mutex); |
| 5075 | |
| 5076 | /* Find any shared 84xx chip. */ |
| 5077 | list_for_each_entry(cs84xx, &qla_cs84xx_list, list) { |
| 5078 | if (cs84xx->bus == ha->pdev->bus) { |
| 5079 | kref_get(&cs84xx->kref); |
| 5080 | goto done; |
| 5081 | } |
| 5082 | } |
| 5083 | |
| 5084 | cs84xx = kzalloc(sizeof(*cs84xx), GFP_KERNEL); |
| 5085 | if (!cs84xx) |
| 5086 | goto done; |
| 5087 | |
| 5088 | kref_init(&cs84xx->kref); |
| 5089 | spin_lock_init(&cs84xx->access_lock); |
| 5090 | mutex_init(&cs84xx->fw_update_mutex); |
| 5091 | cs84xx->bus = ha->pdev->bus; |
| 5092 | |
| 5093 | list_add_tail(&cs84xx->list, &qla_cs84xx_list); |
| 5094 | done: |
| 5095 | mutex_unlock(&qla_cs84xx_mutex); |
| 5096 | return cs84xx; |
| 5097 | } |
| 5098 | |
| 5099 | static void |
| 5100 | __qla84xx_chip_release(struct kref *kref) |
| 5101 | { |
| 5102 | struct qla_chip_state_84xx *cs84xx = |
| 5103 | container_of(kref, struct qla_chip_state_84xx, kref); |
| 5104 | |
| 5105 | mutex_lock(&qla_cs84xx_mutex); |
| 5106 | list_del(&cs84xx->list); |
| 5107 | mutex_unlock(&qla_cs84xx_mutex); |
| 5108 | kfree(cs84xx); |
| 5109 | } |
| 5110 | |
| 5111 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5112 | qla84xx_put_chip(struct scsi_qla_host *vha) |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5113 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5114 | struct qla_hw_data *ha = vha->hw; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5115 | if (ha->cs84xx) |
| 5116 | kref_put(&ha->cs84xx->kref, __qla84xx_chip_release); |
| 5117 | } |
| 5118 | |
| 5119 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5120 | qla84xx_init_chip(scsi_qla_host_t *vha) |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5121 | { |
| 5122 | int rval; |
| 5123 | uint16_t status[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5124 | struct qla_hw_data *ha = vha->hw; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5125 | |
| 5126 | mutex_lock(&ha->cs84xx->fw_update_mutex); |
| 5127 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5128 | rval = qla84xx_verify_chip(vha, status); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5129 | |
| 5130 | mutex_unlock(&ha->cs84xx->fw_update_mutex); |
| 5131 | |
| 5132 | return rval != QLA_SUCCESS || status[0] ? QLA_FUNCTION_FAILED: |
| 5133 | QLA_SUCCESS; |
| 5134 | } |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5135 | |
| 5136 | /* 81XX Support **************************************************************/ |
| 5137 | |
| 5138 | int |
| 5139 | qla81xx_nvram_config(scsi_qla_host_t *vha) |
| 5140 | { |
| 5141 | int rval; |
| 5142 | struct init_cb_81xx *icb; |
| 5143 | struct nvram_81xx *nv; |
| 5144 | uint32_t *dptr; |
| 5145 | uint8_t *dptr1, *dptr2; |
| 5146 | uint32_t chksum; |
| 5147 | uint16_t cnt; |
| 5148 | struct qla_hw_data *ha = vha->hw; |
| 5149 | |
| 5150 | rval = QLA_SUCCESS; |
| 5151 | icb = (struct init_cb_81xx *)ha->init_cb; |
| 5152 | nv = ha->nvram; |
| 5153 | |
| 5154 | /* Determine NVRAM starting address. */ |
| 5155 | ha->nvram_size = sizeof(struct nvram_81xx); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5156 | ha->vpd_size = FA_NVRAM_VPD_SIZE; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5157 | |
| 5158 | /* Get VPD data into cache */ |
| 5159 | ha->vpd = ha->nvram + VPD_OFFSET; |
Andrew Vasquez | 3d79038 | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 5160 | ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_vpd << 2, |
| 5161 | ha->vpd_size); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5162 | |
| 5163 | /* Get NVRAM data into cache and calculate checksum. */ |
Andrew Vasquez | 3d79038 | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 5164 | ha->isp_ops->read_optrom(vha, ha->nvram, ha->flt_region_nvram << 2, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5165 | ha->nvram_size); |
Andrew Vasquez | 3d79038 | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 5166 | dptr = (uint32_t *)nv; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5167 | for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++) |
| 5168 | chksum += le32_to_cpu(*dptr++); |
| 5169 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5170 | ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x0111, |
| 5171 | "Contents of NVRAM:\n"); |
| 5172 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0112, |
| 5173 | (uint8_t *)nv, ha->nvram_size); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5174 | |
| 5175 | /* Bad NVRAM data, set defaults parameters. */ |
| 5176 | if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P' |
| 5177 | || nv->id[3] != ' ' || |
| 5178 | nv->nvram_version < __constant_cpu_to_le16(ICB_VERSION)) { |
| 5179 | /* Reset NVRAM data. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5180 | ql_log(ql_log_info, vha, 0x0073, |
| 5181 | "Inconisistent NVRAM detected: checksum=0x%x id=%c " |
| 5182 | "version=0x%x.\n", chksum, nv->id[0], |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5183 | le16_to_cpu(nv->nvram_version)); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5184 | ql_log(ql_log_info, vha, 0x0074, |
| 5185 | "Falling back to functioning (yet invalid -- WWPN) " |
| 5186 | "defaults.\n"); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5187 | |
| 5188 | /* |
| 5189 | * Set default initialization control block. |
| 5190 | */ |
| 5191 | memset(nv, 0, ha->nvram_size); |
| 5192 | nv->nvram_version = __constant_cpu_to_le16(ICB_VERSION); |
| 5193 | nv->version = __constant_cpu_to_le16(ICB_VERSION); |
| 5194 | nv->frame_payload_size = __constant_cpu_to_le16(2048); |
| 5195 | nv->execution_throttle = __constant_cpu_to_le16(0xFFFF); |
| 5196 | nv->exchange_count = __constant_cpu_to_le16(0); |
| 5197 | nv->port_name[0] = 0x21; |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 5198 | nv->port_name[1] = 0x00 + ha->port_no; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5199 | nv->port_name[2] = 0x00; |
| 5200 | nv->port_name[3] = 0xe0; |
| 5201 | nv->port_name[4] = 0x8b; |
| 5202 | nv->port_name[5] = 0x1c; |
| 5203 | nv->port_name[6] = 0x55; |
| 5204 | nv->port_name[7] = 0x86; |
| 5205 | nv->node_name[0] = 0x20; |
| 5206 | nv->node_name[1] = 0x00; |
| 5207 | nv->node_name[2] = 0x00; |
| 5208 | nv->node_name[3] = 0xe0; |
| 5209 | nv->node_name[4] = 0x8b; |
| 5210 | nv->node_name[5] = 0x1c; |
| 5211 | nv->node_name[6] = 0x55; |
| 5212 | nv->node_name[7] = 0x86; |
| 5213 | nv->login_retry_count = __constant_cpu_to_le16(8); |
| 5214 | nv->interrupt_delay_timer = __constant_cpu_to_le16(0); |
| 5215 | nv->login_timeout = __constant_cpu_to_le16(0); |
| 5216 | nv->firmware_options_1 = |
| 5217 | __constant_cpu_to_le32(BIT_14|BIT_13|BIT_2|BIT_1); |
| 5218 | nv->firmware_options_2 = __constant_cpu_to_le32(2 << 4); |
| 5219 | nv->firmware_options_2 |= __constant_cpu_to_le32(BIT_12); |
| 5220 | nv->firmware_options_3 = __constant_cpu_to_le32(2 << 13); |
| 5221 | nv->host_p = __constant_cpu_to_le32(BIT_11|BIT_10); |
| 5222 | nv->efi_parameters = __constant_cpu_to_le32(0); |
| 5223 | nv->reset_delay = 5; |
| 5224 | nv->max_luns_per_target = __constant_cpu_to_le16(128); |
| 5225 | nv->port_down_retry_count = __constant_cpu_to_le16(30); |
| 5226 | nv->link_down_timeout = __constant_cpu_to_le16(30); |
Andrew Vasquez | eeebcc9 | 2009-06-03 09:55:24 -0700 | [diff] [blame] | 5227 | nv->enode_mac[0] = 0x00; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5228 | nv->enode_mac[1] = 0x02; |
| 5229 | nv->enode_mac[2] = 0x03; |
| 5230 | nv->enode_mac[3] = 0x04; |
| 5231 | nv->enode_mac[4] = 0x05; |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 5232 | nv->enode_mac[5] = 0x06 + ha->port_no; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5233 | |
| 5234 | rval = 1; |
| 5235 | } |
| 5236 | |
| 5237 | /* Reset Initialization control block */ |
Andrew Vasquez | 773120e | 2011-05-10 11:30:14 -0700 | [diff] [blame] | 5238 | memset(icb, 0, ha->init_cb_size); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5239 | |
| 5240 | /* Copy 1st segment. */ |
| 5241 | dptr1 = (uint8_t *)icb; |
| 5242 | dptr2 = (uint8_t *)&nv->version; |
| 5243 | cnt = (uint8_t *)&icb->response_q_inpointer - (uint8_t *)&icb->version; |
| 5244 | while (cnt--) |
| 5245 | *dptr1++ = *dptr2++; |
| 5246 | |
| 5247 | icb->login_retry_count = nv->login_retry_count; |
| 5248 | |
| 5249 | /* Copy 2nd segment. */ |
| 5250 | dptr1 = (uint8_t *)&icb->interrupt_delay_timer; |
| 5251 | dptr2 = (uint8_t *)&nv->interrupt_delay_timer; |
| 5252 | cnt = (uint8_t *)&icb->reserved_5 - |
| 5253 | (uint8_t *)&icb->interrupt_delay_timer; |
| 5254 | while (cnt--) |
| 5255 | *dptr1++ = *dptr2++; |
| 5256 | |
| 5257 | memcpy(icb->enode_mac, nv->enode_mac, sizeof(icb->enode_mac)); |
| 5258 | /* Some boards (with valid NVRAMs) still have NULL enode_mac!! */ |
| 5259 | if (!memcmp(icb->enode_mac, "\0\0\0\0\0\0", sizeof(icb->enode_mac))) { |
| 5260 | icb->enode_mac[0] = 0x01; |
| 5261 | icb->enode_mac[1] = 0x02; |
| 5262 | icb->enode_mac[2] = 0x03; |
| 5263 | icb->enode_mac[3] = 0x04; |
| 5264 | icb->enode_mac[4] = 0x05; |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 5265 | icb->enode_mac[5] = 0x06 + ha->port_no; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5266 | } |
| 5267 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 5268 | /* Use extended-initialization control block. */ |
| 5269 | memcpy(ha->ex_init_cb, &nv->ex_version, sizeof(*ha->ex_init_cb)); |
| 5270 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5271 | /* |
| 5272 | * Setup driver NVRAM options. |
| 5273 | */ |
| 5274 | qla2x00_set_model_info(vha, nv->model_name, sizeof(nv->model_name), |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5275 | "QLE8XXX"); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5276 | |
| 5277 | /* Use alternate WWN? */ |
| 5278 | if (nv->host_p & __constant_cpu_to_le32(BIT_15)) { |
| 5279 | memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); |
| 5280 | memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); |
| 5281 | } |
| 5282 | |
| 5283 | /* Prepare nodename */ |
| 5284 | if ((icb->firmware_options_1 & __constant_cpu_to_le32(BIT_14)) == 0) { |
| 5285 | /* |
| 5286 | * Firmware will apply the following mask if the nodename was |
| 5287 | * not provided. |
| 5288 | */ |
| 5289 | memcpy(icb->node_name, icb->port_name, WWN_SIZE); |
| 5290 | icb->node_name[0] &= 0xF0; |
| 5291 | } |
| 5292 | |
| 5293 | /* Set host adapter parameters. */ |
| 5294 | ha->flags.disable_risc_code_load = 0; |
| 5295 | ha->flags.enable_lip_reset = 0; |
| 5296 | ha->flags.enable_lip_full_login = |
| 5297 | le32_to_cpu(nv->host_p) & BIT_10 ? 1: 0; |
| 5298 | ha->flags.enable_target_reset = |
| 5299 | le32_to_cpu(nv->host_p) & BIT_11 ? 1: 0; |
| 5300 | ha->flags.enable_led_scheme = 0; |
| 5301 | ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1: 0; |
| 5302 | |
| 5303 | ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) & |
| 5304 | (BIT_6 | BIT_5 | BIT_4)) >> 4; |
| 5305 | |
| 5306 | /* save HBA serial number */ |
| 5307 | ha->serial0 = icb->port_name[5]; |
| 5308 | ha->serial1 = icb->port_name[6]; |
| 5309 | ha->serial2 = icb->port_name[7]; |
| 5310 | memcpy(vha->node_name, icb->node_name, WWN_SIZE); |
| 5311 | memcpy(vha->port_name, icb->port_name, WWN_SIZE); |
| 5312 | |
| 5313 | icb->execution_throttle = __constant_cpu_to_le16(0xFFFF); |
| 5314 | |
| 5315 | ha->retry_count = le16_to_cpu(nv->login_retry_count); |
| 5316 | |
| 5317 | /* Set minimum login_timeout to 4 seconds. */ |
| 5318 | if (le16_to_cpu(nv->login_timeout) < ql2xlogintimeout) |
| 5319 | nv->login_timeout = cpu_to_le16(ql2xlogintimeout); |
| 5320 | if (le16_to_cpu(nv->login_timeout) < 4) |
| 5321 | nv->login_timeout = __constant_cpu_to_le16(4); |
| 5322 | ha->login_timeout = le16_to_cpu(nv->login_timeout); |
| 5323 | icb->login_timeout = nv->login_timeout; |
| 5324 | |
| 5325 | /* Set minimum RATOV to 100 tenths of a second. */ |
| 5326 | ha->r_a_tov = 100; |
| 5327 | |
| 5328 | ha->loop_reset_delay = nv->reset_delay; |
| 5329 | |
| 5330 | /* Link Down Timeout = 0: |
| 5331 | * |
| 5332 | * When Port Down timer expires we will start returning |
| 5333 | * I/O's to OS with "DID_NO_CONNECT". |
| 5334 | * |
| 5335 | * Link Down Timeout != 0: |
| 5336 | * |
| 5337 | * The driver waits for the link to come up after link down |
| 5338 | * before returning I/Os to OS with "DID_NO_CONNECT". |
| 5339 | */ |
| 5340 | if (le16_to_cpu(nv->link_down_timeout) == 0) { |
| 5341 | ha->loop_down_abort_time = |
| 5342 | (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); |
| 5343 | } else { |
| 5344 | ha->link_down_timeout = le16_to_cpu(nv->link_down_timeout); |
| 5345 | ha->loop_down_abort_time = |
| 5346 | (LOOP_DOWN_TIME - ha->link_down_timeout); |
| 5347 | } |
| 5348 | |
| 5349 | /* Need enough time to try and get the port back. */ |
| 5350 | ha->port_down_retry_count = le16_to_cpu(nv->port_down_retry_count); |
| 5351 | if (qlport_down_retry) |
| 5352 | ha->port_down_retry_count = qlport_down_retry; |
| 5353 | |
| 5354 | /* Set login_retry_count */ |
| 5355 | ha->login_retry_count = le16_to_cpu(nv->login_retry_count); |
| 5356 | if (ha->port_down_retry_count == |
| 5357 | le16_to_cpu(nv->port_down_retry_count) && |
| 5358 | ha->port_down_retry_count > 3) |
| 5359 | ha->login_retry_count = ha->port_down_retry_count; |
| 5360 | else if (ha->port_down_retry_count > (int)ha->login_retry_count) |
| 5361 | ha->login_retry_count = ha->port_down_retry_count; |
| 5362 | if (ql2xloginretrycount) |
| 5363 | ha->login_retry_count = ql2xloginretrycount; |
| 5364 | |
| 5365 | /* Enable ZIO. */ |
| 5366 | if (!vha->flags.init_done) { |
| 5367 | ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & |
| 5368 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
| 5369 | ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? |
| 5370 | le16_to_cpu(icb->interrupt_delay_timer): 2; |
| 5371 | } |
| 5372 | icb->firmware_options_2 &= __constant_cpu_to_le32( |
| 5373 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0)); |
| 5374 | vha->flags.process_response_queue = 0; |
| 5375 | if (ha->zio_mode != QLA_ZIO_DISABLED) { |
| 5376 | ha->zio_mode = QLA_ZIO_MODE_6; |
| 5377 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5378 | ql_log(ql_log_info, vha, 0x0075, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5379 | "ZIO mode %d enabled; timer delay (%d us).\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5380 | ha->zio_mode, |
| 5381 | ha->zio_timer * 100); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5382 | |
| 5383 | icb->firmware_options_2 |= cpu_to_le32( |
| 5384 | (uint32_t)ha->zio_mode); |
| 5385 | icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer); |
| 5386 | vha->flags.process_response_queue = 1; |
| 5387 | } |
| 5388 | |
| 5389 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5390 | ql_log(ql_log_warn, vha, 0x0076, |
| 5391 | "NVRAM configuration failed.\n"); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5392 | } |
| 5393 | return (rval); |
| 5394 | } |
| 5395 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5396 | int |
| 5397 | qla82xx_restart_isp(scsi_qla_host_t *vha) |
| 5398 | { |
| 5399 | int status, rval; |
| 5400 | uint32_t wait_time; |
| 5401 | struct qla_hw_data *ha = vha->hw; |
| 5402 | struct req_que *req = ha->req_q_map[0]; |
| 5403 | struct rsp_que *rsp = ha->rsp_q_map[0]; |
| 5404 | struct scsi_qla_host *vp; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 5405 | unsigned long flags; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5406 | |
| 5407 | status = qla2x00_init_rings(vha); |
| 5408 | if (!status) { |
| 5409 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
| 5410 | ha->flags.chip_reset_done = 1; |
| 5411 | |
| 5412 | status = qla2x00_fw_ready(vha); |
| 5413 | if (!status) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5414 | ql_log(ql_log_info, vha, 0x803c, |
| 5415 | "Start configure loop, status =%d.\n", status); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5416 | |
| 5417 | /* Issue a marker after FW becomes ready. */ |
| 5418 | qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL); |
| 5419 | |
| 5420 | vha->flags.online = 1; |
| 5421 | /* Wait at most MAX_TARGET RSCNs for a stable link. */ |
| 5422 | wait_time = 256; |
| 5423 | do { |
| 5424 | clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 5425 | qla2x00_configure_loop(vha); |
| 5426 | wait_time--; |
| 5427 | } while (!atomic_read(&vha->loop_down_timer) && |
| 5428 | !(test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) && |
| 5429 | wait_time && |
| 5430 | (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))); |
| 5431 | } |
| 5432 | |
| 5433 | /* if no cable then assume it's good */ |
| 5434 | if ((vha->device_flags & DFLG_NO_CABLE)) |
| 5435 | status = 0; |
| 5436 | |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5437 | ql_log(ql_log_info, vha, 0x8000, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5438 | "Configure loop done, status = 0x%x.\n", status); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5439 | } |
| 5440 | |
| 5441 | if (!status) { |
| 5442 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
| 5443 | |
| 5444 | if (!atomic_read(&vha->loop_down_timer)) { |
| 5445 | /* |
| 5446 | * Issue marker command only when we are going |
| 5447 | * to start the I/O . |
| 5448 | */ |
| 5449 | vha->marker_needed = 1; |
| 5450 | } |
| 5451 | |
| 5452 | vha->flags.online = 1; |
| 5453 | |
| 5454 | ha->isp_ops->enable_intrs(ha); |
| 5455 | |
| 5456 | ha->isp_abort_cnt = 0; |
| 5457 | clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
| 5458 | |
Saurav Kashyap | 5329678 | 2011-05-10 11:30:06 -0700 | [diff] [blame] | 5459 | /* Update the firmware version */ |
Giridhar Malavali | 3173167 | 2011-08-16 11:31:54 -0700 | [diff] [blame] | 5460 | status = qla82xx_check_md_needed(vha); |
Saurav Kashyap | 5329678 | 2011-05-10 11:30:06 -0700 | [diff] [blame] | 5461 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5462 | if (ha->fce) { |
| 5463 | ha->flags.fce_enabled = 1; |
| 5464 | memset(ha->fce, 0, |
| 5465 | fce_calc_size(ha->fce_bufs)); |
| 5466 | rval = qla2x00_enable_fce_trace(vha, |
| 5467 | ha->fce_dma, ha->fce_bufs, ha->fce_mb, |
| 5468 | &ha->fce_bufs); |
| 5469 | if (rval) { |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5470 | ql_log(ql_log_warn, vha, 0x8001, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5471 | "Unable to reinitialize FCE (%d).\n", |
| 5472 | rval); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5473 | ha->flags.fce_enabled = 0; |
| 5474 | } |
| 5475 | } |
| 5476 | |
| 5477 | if (ha->eft) { |
| 5478 | memset(ha->eft, 0, EFT_SIZE); |
| 5479 | rval = qla2x00_enable_eft_trace(vha, |
| 5480 | ha->eft_dma, EFT_NUM_BUFFERS); |
| 5481 | if (rval) { |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5482 | ql_log(ql_log_warn, vha, 0x8010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5483 | "Unable to reinitialize EFT (%d).\n", |
| 5484 | rval); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5485 | } |
| 5486 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5487 | } |
| 5488 | |
| 5489 | if (!status) { |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5490 | ql_dbg(ql_dbg_taskm, vha, 0x8011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5491 | "qla82xx_restart_isp succeeded.\n"); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 5492 | |
| 5493 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 5494 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 5495 | if (vp->vp_idx) { |
| 5496 | atomic_inc(&vp->vref_count); |
| 5497 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 5498 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5499 | qla2x00_vp_abort_isp(vp); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 5500 | |
| 5501 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 5502 | atomic_dec(&vp->vref_count); |
| 5503 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5504 | } |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 5505 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 5506 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5507 | } else { |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5508 | ql_log(ql_log_warn, vha, 0x8016, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5509 | "qla82xx_restart_isp **** FAILED ****.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5510 | } |
| 5511 | |
| 5512 | return status; |
| 5513 | } |
| 5514 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5515 | void |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 5516 | qla81xx_update_fw_options(scsi_qla_host_t *vha) |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5517 | { |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 5518 | struct qla_hw_data *ha = vha->hw; |
| 5519 | |
| 5520 | if (!ql2xetsenable) |
| 5521 | return; |
| 5522 | |
| 5523 | /* Enable ETS Burst. */ |
| 5524 | memset(ha->fw_options, 0, sizeof(ha->fw_options)); |
| 5525 | ha->fw_options[2] |= BIT_9; |
| 5526 | qla2x00_set_fw_options(vha, ha->fw_options); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5527 | } |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5528 | |
| 5529 | /* |
| 5530 | * qla24xx_get_fcp_prio |
| 5531 | * Gets the fcp cmd priority value for the logged in port. |
| 5532 | * Looks for a match of the port descriptors within |
| 5533 | * each of the fcp prio config entries. If a match is found, |
| 5534 | * the tag (priority) value is returned. |
| 5535 | * |
| 5536 | * Input: |
Madhuranath Iyengar | 21090cb | 2010-12-21 16:00:18 -0800 | [diff] [blame] | 5537 | * vha = scsi host structure pointer. |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5538 | * fcport = port structure pointer. |
| 5539 | * |
| 5540 | * Return: |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 5541 | * non-zero (if found) |
Andrew Vasquez | f28a0a9 | 2011-03-30 11:46:18 -0700 | [diff] [blame] | 5542 | * -1 (if not found) |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5543 | * |
| 5544 | * Context: |
| 5545 | * Kernel context |
| 5546 | */ |
Andrew Vasquez | f28a0a9 | 2011-03-30 11:46:18 -0700 | [diff] [blame] | 5547 | static int |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5548 | qla24xx_get_fcp_prio(scsi_qla_host_t *vha, fc_port_t *fcport) |
| 5549 | { |
| 5550 | int i, entries; |
| 5551 | uint8_t pid_match, wwn_match; |
Andrew Vasquez | f28a0a9 | 2011-03-30 11:46:18 -0700 | [diff] [blame] | 5552 | int priority; |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5553 | uint32_t pid1, pid2; |
| 5554 | uint64_t wwn1, wwn2; |
| 5555 | struct qla_fcp_prio_entry *pri_entry; |
| 5556 | struct qla_hw_data *ha = vha->hw; |
| 5557 | |
| 5558 | if (!ha->fcp_prio_cfg || !ha->flags.fcp_prio_enabled) |
Andrew Vasquez | f28a0a9 | 2011-03-30 11:46:18 -0700 | [diff] [blame] | 5559 | return -1; |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5560 | |
Andrew Vasquez | f28a0a9 | 2011-03-30 11:46:18 -0700 | [diff] [blame] | 5561 | priority = -1; |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5562 | entries = ha->fcp_prio_cfg->num_entries; |
| 5563 | pri_entry = &ha->fcp_prio_cfg->entry[0]; |
| 5564 | |
| 5565 | for (i = 0; i < entries; i++) { |
| 5566 | pid_match = wwn_match = 0; |
| 5567 | |
| 5568 | if (!(pri_entry->flags & FCP_PRIO_ENTRY_VALID)) { |
| 5569 | pri_entry++; |
| 5570 | continue; |
| 5571 | } |
| 5572 | |
| 5573 | /* check source pid for a match */ |
| 5574 | if (pri_entry->flags & FCP_PRIO_ENTRY_SPID_VALID) { |
| 5575 | pid1 = pri_entry->src_pid & INVALID_PORT_ID; |
| 5576 | pid2 = vha->d_id.b24 & INVALID_PORT_ID; |
| 5577 | if (pid1 == INVALID_PORT_ID) |
| 5578 | pid_match++; |
| 5579 | else if (pid1 == pid2) |
| 5580 | pid_match++; |
| 5581 | } |
| 5582 | |
| 5583 | /* check destination pid for a match */ |
| 5584 | if (pri_entry->flags & FCP_PRIO_ENTRY_DPID_VALID) { |
| 5585 | pid1 = pri_entry->dst_pid & INVALID_PORT_ID; |
| 5586 | pid2 = fcport->d_id.b24 & INVALID_PORT_ID; |
| 5587 | if (pid1 == INVALID_PORT_ID) |
| 5588 | pid_match++; |
| 5589 | else if (pid1 == pid2) |
| 5590 | pid_match++; |
| 5591 | } |
| 5592 | |
| 5593 | /* check source WWN for a match */ |
| 5594 | if (pri_entry->flags & FCP_PRIO_ENTRY_SWWN_VALID) { |
| 5595 | wwn1 = wwn_to_u64(vha->port_name); |
| 5596 | wwn2 = wwn_to_u64(pri_entry->src_wwpn); |
| 5597 | if (wwn2 == (uint64_t)-1) |
| 5598 | wwn_match++; |
| 5599 | else if (wwn1 == wwn2) |
| 5600 | wwn_match++; |
| 5601 | } |
| 5602 | |
| 5603 | /* check destination WWN for a match */ |
| 5604 | if (pri_entry->flags & FCP_PRIO_ENTRY_DWWN_VALID) { |
| 5605 | wwn1 = wwn_to_u64(fcport->port_name); |
| 5606 | wwn2 = wwn_to_u64(pri_entry->dst_wwpn); |
| 5607 | if (wwn2 == (uint64_t)-1) |
| 5608 | wwn_match++; |
| 5609 | else if (wwn1 == wwn2) |
| 5610 | wwn_match++; |
| 5611 | } |
| 5612 | |
| 5613 | if (pid_match == 2 || wwn_match == 2) { |
| 5614 | /* Found a matching entry */ |
| 5615 | if (pri_entry->flags & FCP_PRIO_ENTRY_TAG_VALID) |
| 5616 | priority = pri_entry->tag; |
| 5617 | break; |
| 5618 | } |
| 5619 | |
| 5620 | pri_entry++; |
| 5621 | } |
| 5622 | |
| 5623 | return priority; |
| 5624 | } |
| 5625 | |
| 5626 | /* |
| 5627 | * qla24xx_update_fcport_fcp_prio |
| 5628 | * Activates fcp priority for the logged in fc port |
| 5629 | * |
| 5630 | * Input: |
Madhuranath Iyengar | 21090cb | 2010-12-21 16:00:18 -0800 | [diff] [blame] | 5631 | * vha = scsi host structure pointer. |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5632 | * fcp = port structure pointer. |
| 5633 | * |
| 5634 | * Return: |
| 5635 | * QLA_SUCCESS or QLA_FUNCTION_FAILED |
| 5636 | * |
| 5637 | * Context: |
| 5638 | * Kernel context. |
| 5639 | */ |
| 5640 | int |
Madhuranath Iyengar | 21090cb | 2010-12-21 16:00:18 -0800 | [diff] [blame] | 5641 | qla24xx_update_fcport_fcp_prio(scsi_qla_host_t *vha, fc_port_t *fcport) |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5642 | { |
| 5643 | int ret; |
Andrew Vasquez | f28a0a9 | 2011-03-30 11:46:18 -0700 | [diff] [blame] | 5644 | int priority; |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5645 | uint16_t mb[5]; |
| 5646 | |
Madhuranath Iyengar | 21090cb | 2010-12-21 16:00:18 -0800 | [diff] [blame] | 5647 | if (fcport->port_type != FCT_TARGET || |
| 5648 | fcport->loop_id == FC_NO_LOOP_ID) |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5649 | return QLA_FUNCTION_FAILED; |
| 5650 | |
Madhuranath Iyengar | 21090cb | 2010-12-21 16:00:18 -0800 | [diff] [blame] | 5651 | priority = qla24xx_get_fcp_prio(vha, fcport); |
Andrew Vasquez | f28a0a9 | 2011-03-30 11:46:18 -0700 | [diff] [blame] | 5652 | if (priority < 0) |
| 5653 | return QLA_FUNCTION_FAILED; |
| 5654 | |
Saurav Kashyap | a00f629 | 2011-11-18 09:03:19 -0800 | [diff] [blame] | 5655 | if (IS_QLA82XX(vha->hw)) { |
| 5656 | fcport->fcp_prio = priority & 0xf; |
| 5657 | return QLA_SUCCESS; |
| 5658 | } |
| 5659 | |
Madhuranath Iyengar | 21090cb | 2010-12-21 16:00:18 -0800 | [diff] [blame] | 5660 | ret = qla24xx_set_fcp_prio(vha, fcport->loop_id, priority, mb); |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5661 | if (ret == QLA_SUCCESS) { |
| 5662 | if (fcport->fcp_prio != priority) |
| 5663 | ql_dbg(ql_dbg_user, vha, 0x709e, |
| 5664 | "Updated FCP_CMND priority - value=%d loop_id=%d " |
| 5665 | "port_id=%02x%02x%02x.\n", priority, |
| 5666 | fcport->loop_id, fcport->d_id.b.domain, |
| 5667 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Saurav Kashyap | a00f629 | 2011-11-18 09:03:19 -0800 | [diff] [blame] | 5668 | fcport->fcp_prio = priority & 0xf; |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5669 | } else |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5670 | ql_dbg(ql_dbg_user, vha, 0x704f, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5671 | "Unable to update FCP_CMND priority - ret=0x%x for " |
| 5672 | "loop_id=%d port_id=%02x%02x%02x.\n", ret, fcport->loop_id, |
| 5673 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 5674 | fcport->d_id.b.al_pa); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5675 | return ret; |
| 5676 | } |
| 5677 | |
| 5678 | /* |
| 5679 | * qla24xx_update_all_fcp_prio |
| 5680 | * Activates fcp priority for all the logged in ports |
| 5681 | * |
| 5682 | * Input: |
| 5683 | * ha = adapter block pointer. |
| 5684 | * |
| 5685 | * Return: |
| 5686 | * QLA_SUCCESS or QLA_FUNCTION_FAILED |
| 5687 | * |
| 5688 | * Context: |
| 5689 | * Kernel context. |
| 5690 | */ |
| 5691 | int |
| 5692 | qla24xx_update_all_fcp_prio(scsi_qla_host_t *vha) |
| 5693 | { |
| 5694 | int ret; |
| 5695 | fc_port_t *fcport; |
| 5696 | |
| 5697 | ret = QLA_FUNCTION_FAILED; |
| 5698 | /* We need to set priority for all logged in ports */ |
| 5699 | list_for_each_entry(fcport, &vha->vp_fcports, list) |
| 5700 | ret = qla24xx_update_fcport_fcp_prio(vha, fcport); |
| 5701 | |
| 5702 | return ret; |
| 5703 | } |