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 | 0107109e | 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 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 44 | void |
| 45 | qla2x00_sp_timeout(unsigned long __data) |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 46 | { |
| 47 | srb_t *sp = (srb_t *)__data; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 48 | struct srb_iocb *iocb; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 49 | fc_port_t *fcport = sp->fcport; |
| 50 | struct qla_hw_data *ha = fcport->vha->hw; |
| 51 | struct req_que *req; |
| 52 | unsigned long flags; |
| 53 | |
| 54 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 55 | req = ha->req_q_map[0]; |
| 56 | req->outstanding_cmds[sp->handle] = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 57 | iocb = &sp->u.iocb_cmd; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 58 | iocb->timeout(sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 59 | sp->free(fcport->vha, sp); |
Andrew Vasquez | 6ac5260 | 2010-05-28 15:08:19 -0700 | [diff] [blame] | 60 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 61 | } |
| 62 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 63 | void |
| 64 | qla2x00_sp_free(void *data, void *ptr) |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 65 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 66 | srb_t *sp = (srb_t *)ptr; |
| 67 | struct srb_iocb *iocb = &sp->u.iocb_cmd; |
| 68 | struct scsi_qla_host *vha = (scsi_qla_host_t *)data; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 69 | |
Chad Dupuis | 4d97cc5 | 2010-10-15 11:27:41 -0700 | [diff] [blame] | 70 | del_timer(&iocb->timer); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 71 | mempool_free(sp, vha->hw->srb_mempool); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 72 | |
| 73 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 74 | } |
| 75 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 76 | /* Asynchronous Login/Logout Routines -------------------------------------- */ |
| 77 | |
Andrew Vasquez | 5b91490 | 2010-05-28 15:08:30 -0700 | [diff] [blame] | 78 | static inline unsigned long |
| 79 | qla2x00_get_async_timeout(struct scsi_qla_host *vha) |
| 80 | { |
| 81 | unsigned long tmo; |
| 82 | struct qla_hw_data *ha = vha->hw; |
| 83 | |
| 84 | /* Firmware should use switch negotiated r_a_tov for timeout. */ |
| 85 | tmo = ha->r_a_tov / 10 * 2; |
| 86 | if (!IS_FWI2_CAPABLE(ha)) { |
| 87 | /* |
| 88 | * Except for earlier ISPs where the timeout is seeded from the |
| 89 | * initialization control block. |
| 90 | */ |
| 91 | tmo = ha->login_timeout; |
| 92 | } |
| 93 | return tmo; |
| 94 | } |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 95 | |
| 96 | static void |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 97 | qla2x00_async_iocb_timeout(void *data) |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 98 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 99 | srb_t *sp = (srb_t *)data; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 100 | fc_port_t *fcport = sp->fcport; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 101 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 102 | ql_dbg(ql_dbg_disc, fcport->vha, 0x2071, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 103 | "Async-%s timeout - hdl=%x portid=%02x%02x%02x.\n", |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 104 | sp->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] | 105 | fcport->d_id.b.al_pa); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 106 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 107 | fcport->flags &= ~FCF_ASYNC_SENT; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 108 | if (sp->type == SRB_LOGIN_CMD) { |
| 109 | struct srb_iocb *lio = &sp->u.iocb_cmd; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 110 | qla2x00_post_async_logout_work(fcport->vha, fcport, NULL); |
Andrew Vasquez | 6ac5260 | 2010-05-28 15:08:19 -0700 | [diff] [blame] | 111 | /* Retry as needed. */ |
| 112 | lio->u.logio.data[0] = MBS_COMMAND_ERROR; |
| 113 | lio->u.logio.data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? |
| 114 | QLA_LOGIO_LOGIN_RETRIED : 0; |
| 115 | qla2x00_post_async_login_done_work(fcport->vha, fcport, |
| 116 | lio->u.logio.data); |
| 117 | } |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 118 | } |
| 119 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 120 | static void |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 121 | qla2x00_async_login_sp_done(void *data, void *ptr, int res) |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 122 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 123 | srb_t *sp = (srb_t *)ptr; |
| 124 | struct srb_iocb *lio = &sp->u.iocb_cmd; |
| 125 | struct scsi_qla_host *vha = (scsi_qla_host_t *)data; |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 126 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 127 | if (!test_bit(UNLOADING, &vha->dpc_flags)) |
| 128 | qla2x00_post_async_login_done_work(sp->fcport->vha, sp->fcport, |
| 129 | lio->u.logio.data); |
| 130 | sp->free(sp->fcport->vha, sp); |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 133 | int |
| 134 | qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 135 | uint16_t *data) |
| 136 | { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 137 | srb_t *sp; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 138 | struct srb_iocb *lio; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 139 | int rval; |
| 140 | |
| 141 | rval = QLA_FUNCTION_FAILED; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 142 | sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 143 | if (!sp) |
| 144 | goto done; |
| 145 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 146 | sp->type = SRB_LOGIN_CMD; |
| 147 | sp->name = "login"; |
| 148 | qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); |
| 149 | |
| 150 | lio = &sp->u.iocb_cmd; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 151 | lio->timeout = qla2x00_async_iocb_timeout; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 152 | sp->done = qla2x00_async_login_sp_done; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 153 | lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 154 | if (data[1] & QLA_LOGIO_LOGIN_RETRIED) |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 155 | lio->u.logio.flags |= SRB_LOGIN_RETRIED; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 156 | rval = qla2x00_start_sp(sp); |
| 157 | if (rval != QLA_SUCCESS) |
| 158 | goto done_free_sp; |
| 159 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 160 | ql_dbg(ql_dbg_disc, vha, 0x2072, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 161 | "Async-login - hdl=%x, loopid=%x portid=%02x%02x%02x " |
| 162 | "retries=%d.\n", sp->handle, fcport->loop_id, |
| 163 | fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa, |
| 164 | fcport->login_retry); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 165 | return rval; |
| 166 | |
| 167 | done_free_sp: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 168 | sp->free(fcport->vha, sp); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 169 | done: |
| 170 | return rval; |
| 171 | } |
| 172 | |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 173 | static void |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 174 | qla2x00_async_logout_sp_done(void *data, void *ptr, int res) |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 175 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 176 | srb_t *sp = (srb_t *)ptr; |
| 177 | struct srb_iocb *lio = &sp->u.iocb_cmd; |
| 178 | struct scsi_qla_host *vha = (scsi_qla_host_t *)data; |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 179 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 180 | if (!test_bit(UNLOADING, &vha->dpc_flags)) |
| 181 | qla2x00_post_async_logout_done_work(sp->fcport->vha, sp->fcport, |
| 182 | lio->u.logio.data); |
| 183 | sp->free(sp->fcport->vha, 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_logout(struct scsi_qla_host *vha, fc_port_t *fcport) |
| 188 | { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 189 | srb_t *sp; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 190 | struct srb_iocb *lio; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 191 | int rval; |
| 192 | |
| 193 | rval = QLA_FUNCTION_FAILED; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 194 | sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 195 | if (!sp) |
| 196 | goto done; |
| 197 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 198 | sp->type = SRB_LOGOUT_CMD; |
| 199 | sp->name = "logout"; |
| 200 | qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); |
| 201 | |
| 202 | lio = &sp->u.iocb_cmd; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 203 | lio->timeout = qla2x00_async_iocb_timeout; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 204 | sp->done = qla2x00_async_logout_sp_done; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 205 | rval = qla2x00_start_sp(sp); |
| 206 | if (rval != QLA_SUCCESS) |
| 207 | goto done_free_sp; |
| 208 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 209 | ql_dbg(ql_dbg_disc, vha, 0x2070, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 210 | "Async-logout - hdl=%x loop-id=%x portid=%02x%02x%02x.\n", |
| 211 | sp->handle, fcport->loop_id, fcport->d_id.b.domain, |
| 212 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 213 | return rval; |
| 214 | |
| 215 | done_free_sp: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 216 | sp->free(fcport->vha, sp); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 217 | done: |
| 218 | return rval; |
| 219 | } |
| 220 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 221 | static void |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 222 | qla2x00_async_adisc_sp_done(void *data, void *ptr, int res) |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 223 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 224 | srb_t *sp = (srb_t *)ptr; |
| 225 | struct srb_iocb *lio = &sp->u.iocb_cmd; |
| 226 | struct scsi_qla_host *vha = (scsi_qla_host_t *)data; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 227 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 228 | if (!test_bit(UNLOADING, &vha->dpc_flags)) |
| 229 | qla2x00_post_async_adisc_done_work(sp->fcport->vha, sp->fcport, |
| 230 | lio->u.logio.data); |
| 231 | sp->free(sp->fcport->vha, sp); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | int |
| 235 | qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 236 | uint16_t *data) |
| 237 | { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 238 | srb_t *sp; |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 239 | struct srb_iocb *lio; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 240 | int rval; |
| 241 | |
| 242 | rval = QLA_FUNCTION_FAILED; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 243 | sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 244 | if (!sp) |
| 245 | goto done; |
| 246 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 247 | sp->type = SRB_ADISC_CMD; |
| 248 | sp->name = "adisc"; |
| 249 | qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); |
| 250 | |
| 251 | lio = &sp->u.iocb_cmd; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 252 | lio->timeout = qla2x00_async_iocb_timeout; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 253 | sp->done = qla2x00_async_adisc_sp_done; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 254 | if (data[1] & QLA_LOGIO_LOGIN_RETRIED) |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 255 | lio->u.logio.flags |= SRB_LOGIN_RETRIED; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 256 | rval = qla2x00_start_sp(sp); |
| 257 | if (rval != QLA_SUCCESS) |
| 258 | goto done_free_sp; |
| 259 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 260 | ql_dbg(ql_dbg_disc, vha, 0x206f, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 261 | "Async-adisc - hdl=%x loopid=%x portid=%02x%02x%02x.\n", |
| 262 | sp->handle, fcport->loop_id, fcport->d_id.b.domain, |
| 263 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 264 | return rval; |
| 265 | |
| 266 | done_free_sp: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 267 | sp->free(fcport->vha, sp); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 268 | done: |
| 269 | return rval; |
| 270 | } |
| 271 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 272 | static void |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 273 | qla2x00_async_tm_cmd_done(void *data, void *ptr, int res) |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 274 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 275 | srb_t *sp = (srb_t *)ptr; |
| 276 | struct srb_iocb *iocb = &sp->u.iocb_cmd; |
| 277 | struct scsi_qla_host *vha = (scsi_qla_host_t *)data; |
| 278 | uint32_t flags; |
| 279 | uint16_t lun; |
| 280 | int rval; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 281 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 282 | if (!test_bit(UNLOADING, &vha->dpc_flags)) { |
| 283 | flags = iocb->u.tmf.flags; |
| 284 | lun = (uint16_t)iocb->u.tmf.lun; |
| 285 | |
| 286 | /* Issue Marker IOCB */ |
| 287 | rval = qla2x00_marker(vha, vha->hw->req_q_map[0], |
| 288 | vha->hw->rsp_q_map[0], sp->fcport->loop_id, lun, |
| 289 | flags == TCF_LUN_RESET ? MK_SYNC_ID_LUN : MK_SYNC_ID); |
| 290 | |
| 291 | if ((rval != QLA_SUCCESS) || iocb->u.tmf.data) { |
| 292 | ql_dbg(ql_dbg_taskm, vha, 0x8030, |
| 293 | "TM IOCB failed (%x).\n", rval); |
| 294 | } |
| 295 | } |
| 296 | sp->free(sp->fcport->vha, sp); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | int |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 300 | qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t tm_flags, uint32_t lun, |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 301 | uint32_t tag) |
| 302 | { |
| 303 | struct scsi_qla_host *vha = fcport->vha; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 304 | srb_t *sp; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 305 | struct srb_iocb *tcf; |
| 306 | int rval; |
| 307 | |
| 308 | rval = QLA_FUNCTION_FAILED; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 309 | sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 310 | if (!sp) |
| 311 | goto done; |
| 312 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 313 | sp->type = SRB_TM_CMD; |
| 314 | sp->name = "tmf"; |
| 315 | qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); |
| 316 | |
| 317 | tcf = &sp->u.iocb_cmd; |
| 318 | tcf->u.tmf.flags = tm_flags; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 319 | tcf->u.tmf.lun = lun; |
| 320 | tcf->u.tmf.data = tag; |
| 321 | tcf->timeout = qla2x00_async_iocb_timeout; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 322 | sp->done = qla2x00_async_tm_cmd_done; |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 323 | |
| 324 | rval = qla2x00_start_sp(sp); |
| 325 | if (rval != QLA_SUCCESS) |
| 326 | goto done_free_sp; |
| 327 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 328 | ql_dbg(ql_dbg_taskm, vha, 0x802f, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 329 | "Async-tmf hdl=%x loop-id=%x portid=%02x%02x%02x.\n", |
| 330 | sp->handle, fcport->loop_id, fcport->d_id.b.domain, |
| 331 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 332 | return rval; |
| 333 | |
| 334 | done_free_sp: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame^] | 335 | sp->free(fcport->vha, sp); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 336 | done: |
| 337 | return rval; |
| 338 | } |
| 339 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 340 | void |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 341 | qla2x00_async_login_done(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 342 | uint16_t *data) |
| 343 | { |
| 344 | int rval; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 345 | |
| 346 | switch (data[0]) { |
| 347 | case MBS_COMMAND_COMPLETE: |
Andrew Vasquez | a4f92a3 | 2011-03-30 11:46:31 -0700 | [diff] [blame] | 348 | /* |
| 349 | * Driver must validate login state - If PRLI not complete, |
| 350 | * force a relogin attempt via implicit LOGO, PLOGI, and PRLI |
| 351 | * requests. |
| 352 | */ |
| 353 | rval = qla2x00_get_port_database(vha, fcport, 0); |
| 354 | if (rval != QLA_SUCCESS) { |
| 355 | qla2x00_post_async_logout_work(vha, fcport, NULL); |
| 356 | qla2x00_post_async_login_work(vha, fcport, NULL); |
| 357 | break; |
| 358 | } |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 359 | if (fcport->flags & FCF_FCP2_DEVICE) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 360 | qla2x00_post_async_adisc_work(vha, fcport, data); |
| 361 | break; |
Andrew Vasquez | 99b0bec | 2010-05-04 15:01:25 -0700 | [diff] [blame] | 362 | } |
| 363 | qla2x00_update_fcport(vha, fcport); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 364 | break; |
| 365 | case MBS_COMMAND_ERROR: |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 366 | fcport->flags &= ~FCF_ASYNC_SENT; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 367 | if (data[1] & QLA_LOGIO_LOGIN_RETRIED) |
| 368 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 369 | else |
Andrew Vasquez | 80d7944 | 2011-03-30 11:46:17 -0700 | [diff] [blame] | 370 | qla2x00_mark_device_lost(vha, fcport, 1, 0); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 371 | break; |
| 372 | case MBS_PORT_ID_USED: |
| 373 | fcport->loop_id = data[1]; |
Andrew Vasquez | 6ac5260 | 2010-05-28 15:08:19 -0700 | [diff] [blame] | 374 | qla2x00_post_async_logout_work(vha, fcport, NULL); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 375 | qla2x00_post_async_login_work(vha, fcport, NULL); |
| 376 | break; |
| 377 | case MBS_LOOP_ID_USED: |
| 378 | fcport->loop_id++; |
| 379 | rval = qla2x00_find_new_loop_id(vha, fcport); |
| 380 | if (rval != QLA_SUCCESS) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 381 | fcport->flags &= ~FCF_ASYNC_SENT; |
Andrew Vasquez | 80d7944 | 2011-03-30 11:46:17 -0700 | [diff] [blame] | 382 | qla2x00_mark_device_lost(vha, fcport, 1, 0); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 383 | break; |
| 384 | } |
| 385 | qla2x00_post_async_login_work(vha, fcport, NULL); |
| 386 | break; |
| 387 | } |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 388 | return; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 389 | } |
| 390 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 391 | void |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 392 | qla2x00_async_logout_done(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 393 | uint16_t *data) |
| 394 | { |
| 395 | qla2x00_mark_device_lost(vha, fcport, 1, 0); |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 396 | return; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 397 | } |
| 398 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 399 | void |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 400 | qla2x00_async_adisc_done(struct scsi_qla_host *vha, fc_port_t *fcport, |
| 401 | uint16_t *data) |
| 402 | { |
| 403 | if (data[0] == MBS_COMMAND_COMPLETE) { |
| 404 | qla2x00_update_fcport(vha, fcport); |
| 405 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 406 | return; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | /* Retry login. */ |
| 410 | fcport->flags &= ~FCF_ASYNC_SENT; |
| 411 | if (data[1] & QLA_LOGIO_LOGIN_RETRIED) |
| 412 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 413 | else |
Andrew Vasquez | 80d7944 | 2011-03-30 11:46:17 -0700 | [diff] [blame] | 414 | qla2x00_mark_device_lost(vha, fcport, 1, 0); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 415 | |
Madhuranath Iyengar | 4916392 | 2010-05-04 15:01:28 -0700 | [diff] [blame] | 416 | return; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 417 | } |
| 418 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | /****************************************************************************/ |
| 420 | /* QLogic ISP2x00 Hardware Support Functions. */ |
| 421 | /****************************************************************************/ |
| 422 | |
| 423 | /* |
| 424 | * qla2x00_initialize_adapter |
| 425 | * Initialize board. |
| 426 | * |
| 427 | * Input: |
| 428 | * ha = adapter block pointer. |
| 429 | * |
| 430 | * Returns: |
| 431 | * 0 = success |
| 432 | */ |
| 433 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 434 | qla2x00_initialize_adapter(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | { |
| 436 | int rval; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 437 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 438 | struct req_que *req = ha->req_q_map[0]; |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 439 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | /* Clear adapter flags. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 441 | vha->flags.online = 0; |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 442 | ha->flags.chip_reset_done = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 443 | vha->flags.reset_active = 0; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 444 | ha->flags.pci_channel_io_perm_failure = 0; |
| 445 | ha->flags.eeh_busy = 0; |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 446 | ha->flags.thermal_supported = 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 447 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 448 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 449 | vha->device_flags = DFLG_NO_CABLE; |
| 450 | vha->dpc_flags = 0; |
| 451 | vha->flags.management_server_logged_in = 0; |
| 452 | vha->marker_needed = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | ha->isp_abort_cnt = 0; |
| 454 | ha->beacon_blink_led = 0; |
| 455 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 456 | set_bit(0, ha->req_qid_map); |
| 457 | set_bit(0, ha->rsp_qid_map); |
| 458 | |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 459 | ql_dbg(ql_dbg_init, vha, 0x0040, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 460 | "Configuring PCI space...\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 461 | rval = ha->isp_ops->pci_config(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 463 | ql_log(ql_log_warn, vha, 0x0044, |
| 464 | "Unable to configure PCI space.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | return (rval); |
| 466 | } |
| 467 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 468 | ha->isp_ops->reset_chip(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 470 | rval = qla2xxx_get_flash_info(vha); |
Andrew Vasquez | c00d899 | 2008-09-11 21:22:49 -0700 | [diff] [blame] | 471 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 472 | ql_log(ql_log_fatal, vha, 0x004f, |
| 473 | "Unable to validate FLASH data.\n"); |
Andrew Vasquez | c00d899 | 2008-09-11 21:22:49 -0700 | [diff] [blame] | 474 | return (rval); |
| 475 | } |
| 476 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 477 | ha->isp_ops->get_flash_version(vha, req->ring); |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 478 | ql_dbg(ql_dbg_init, vha, 0x0061, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 479 | "Configure NVRAM parameters...\n"); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 480 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 481 | ha->isp_ops->nvram_config(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | |
Andrew Vasquez | d4c760c | 2006-06-23 16:10:39 -0700 | [diff] [blame] | 483 | if (ha->flags.disable_serdes) { |
| 484 | /* Mask HBA via NVRAM settings? */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 485 | ql_log(ql_log_info, vha, 0x0077, |
| 486 | "Masking HBA WWPN " |
Andrew Vasquez | d4c760c | 2006-06-23 16:10:39 -0700 | [diff] [blame] | 487 | "%02x%02x%02x%02x%02x%02x%02x%02x (via NVRAM).\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 488 | vha->port_name[0], vha->port_name[1], |
| 489 | vha->port_name[2], vha->port_name[3], |
| 490 | vha->port_name[4], vha->port_name[5], |
| 491 | vha->port_name[6], vha->port_name[7]); |
Andrew Vasquez | d4c760c | 2006-06-23 16:10:39 -0700 | [diff] [blame] | 492 | return QLA_FUNCTION_FAILED; |
| 493 | } |
| 494 | |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 495 | ql_dbg(ql_dbg_init, vha, 0x0078, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 496 | "Verifying loaded RISC code...\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 498 | if (qla2x00_isp_firmware(vha) != QLA_SUCCESS) { |
| 499 | rval = ha->isp_ops->chip_diag(vha); |
Andrew Vasquez | d19044c | 2006-11-22 08:22:19 -0800 | [diff] [blame] | 500 | if (rval) |
| 501 | return (rval); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 502 | rval = qla2x00_setup_chip(vha); |
Andrew Vasquez | d19044c | 2006-11-22 08:22:19 -0800 | [diff] [blame] | 503 | if (rval) |
| 504 | return (rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 506 | |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 507 | if (IS_QLA84XX(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 508 | ha->cs84xx = qla84xx_get_chip(vha); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 509 | if (!ha->cs84xx) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 510 | ql_log(ql_log_warn, vha, 0x00d0, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 511 | "Unable to configure ISP84XX.\n"); |
| 512 | return QLA_FUNCTION_FAILED; |
| 513 | } |
| 514 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 515 | rval = qla2x00_init_rings(vha); |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 516 | ha->flags.chip_reset_done = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 518 | if (rval == QLA_SUCCESS && IS_QLA84XX(ha)) { |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 519 | /* Issue verify 84xx FW IOCB to complete 84xx initialization */ |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 520 | rval = qla84xx_init_chip(vha); |
| 521 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 522 | ql_log(ql_log_warn, vha, 0x00d4, |
| 523 | "Unable to initialize ISP84XX.\n"); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 524 | qla84xx_put_chip(vha); |
| 525 | } |
| 526 | } |
| 527 | |
Madhuranath Iyengar | 2f0f3f4 | 2010-07-23 15:28:24 +0500 | [diff] [blame] | 528 | if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha)) |
| 529 | qla24xx_read_fcp_prio_cfg(vha); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 530 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | return (rval); |
| 532 | } |
| 533 | |
| 534 | /** |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 535 | * qla2100_pci_config() - Setup ISP21xx PCI configuration registers. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | * @ha: HA context |
| 537 | * |
| 538 | * Returns 0 on success. |
| 539 | */ |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 540 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 541 | qla2100_pci_config(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | { |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 543 | uint16_t w; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 544 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 545 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 546 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | pci_set_master(ha->pdev); |
Andrew Vasquez | af6177d | 2007-07-19 15:06:02 -0700 | [diff] [blame] | 549 | pci_try_set_mwi(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | pci_read_config_word(ha->pdev, PCI_COMMAND, &w); |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 552 | w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | pci_write_config_word(ha->pdev, PCI_COMMAND, w); |
| 554 | |
Andrew Vasquez | 737faec | 2008-10-24 15:13:45 -0700 | [diff] [blame] | 555 | pci_disable_rom(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 557 | /* Get PCI bus information. */ |
| 558 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 559 | ha->pci_attr = RD_REG_WORD(®->ctrl_status); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 560 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 561 | |
| 562 | return QLA_SUCCESS; |
| 563 | } |
| 564 | |
| 565 | /** |
| 566 | * qla2300_pci_config() - Setup ISP23xx PCI configuration registers. |
| 567 | * @ha: HA context |
| 568 | * |
| 569 | * Returns 0 on success. |
| 570 | */ |
| 571 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 572 | qla2300_pci_config(scsi_qla_host_t *vha) |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 573 | { |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 574 | uint16_t w; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 575 | unsigned long flags = 0; |
| 576 | uint32_t cnt; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 577 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 578 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 579 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 580 | pci_set_master(ha->pdev); |
Andrew Vasquez | af6177d | 2007-07-19 15:06:02 -0700 | [diff] [blame] | 581 | pci_try_set_mwi(ha->pdev); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 582 | |
| 583 | pci_read_config_word(ha->pdev, PCI_COMMAND, &w); |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 584 | w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 585 | |
| 586 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 587 | w &= ~PCI_COMMAND_INTX_DISABLE; |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 588 | pci_write_config_word(ha->pdev, PCI_COMMAND, w); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 589 | |
| 590 | /* |
| 591 | * If this is a 2300 card and not 2312, reset the |
| 592 | * COMMAND_INVALIDATE due to a bug in the 2300. Unfortunately, |
| 593 | * the 2310 also reports itself as a 2300 so we need to get the |
| 594 | * fb revision level -- a 6 indicates it really is a 2300 and |
| 595 | * not a 2310. |
| 596 | */ |
| 597 | if (IS_QLA2300(ha)) { |
| 598 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 599 | |
| 600 | /* Pause RISC. */ |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 601 | WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 602 | for (cnt = 0; cnt < 30000; cnt++) { |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 603 | if ((RD_REG_WORD(®->hccr) & HCCR_RISC_PAUSE) != 0) |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 604 | break; |
| 605 | |
| 606 | udelay(10); |
| 607 | } |
| 608 | |
| 609 | /* Select FPM registers. */ |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 610 | WRT_REG_WORD(®->ctrl_status, 0x20); |
| 611 | RD_REG_WORD(®->ctrl_status); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 612 | |
| 613 | /* Get the fb rev level */ |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 614 | ha->fb_rev = RD_FB_CMD_REG(ha, reg); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 615 | |
| 616 | if (ha->fb_rev == FPM_2300) |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 617 | pci_clear_mwi(ha->pdev); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 618 | |
| 619 | /* Deselect FPM registers. */ |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 620 | WRT_REG_WORD(®->ctrl_status, 0x0); |
| 621 | RD_REG_WORD(®->ctrl_status); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 622 | |
| 623 | /* Release RISC module. */ |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 624 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 625 | for (cnt = 0; cnt < 30000; cnt++) { |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 626 | if ((RD_REG_WORD(®->hccr) & HCCR_RISC_PAUSE) == 0) |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 627 | break; |
| 628 | |
| 629 | udelay(10); |
| 630 | } |
| 631 | |
| 632 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 633 | } |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 634 | |
| 635 | pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); |
| 636 | |
Andrew Vasquez | 737faec | 2008-10-24 15:13:45 -0700 | [diff] [blame] | 637 | pci_disable_rom(ha->pdev); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 638 | |
| 639 | /* Get PCI bus information. */ |
| 640 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 641 | ha->pci_attr = RD_REG_WORD(®->ctrl_status); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 642 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 643 | |
| 644 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | /** |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 648 | * qla24xx_pci_config() - Setup ISP24xx PCI configuration registers. |
| 649 | * @ha: HA context |
| 650 | * |
| 651 | * Returns 0 on success. |
| 652 | */ |
| 653 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 654 | qla24xx_pci_config(scsi_qla_host_t *vha) |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 655 | { |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 656 | uint16_t w; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 657 | unsigned long flags = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 658 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 659 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 660 | |
| 661 | pci_set_master(ha->pdev); |
Andrew Vasquez | af6177d | 2007-07-19 15:06:02 -0700 | [diff] [blame] | 662 | pci_try_set_mwi(ha->pdev); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 663 | |
| 664 | pci_read_config_word(ha->pdev, PCI_COMMAND, &w); |
Andrew Vasquez | a157b10 | 2007-05-07 07:43:01 -0700 | [diff] [blame] | 665 | w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 666 | w &= ~PCI_COMMAND_INTX_DISABLE; |
| 667 | pci_write_config_word(ha->pdev, PCI_COMMAND, w); |
| 668 | |
| 669 | pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); |
| 670 | |
| 671 | /* PCI-X -- adjust Maximum Memory Read Byte Count (2048). */ |
Andrew Vasquez | f85ec18 | 2007-07-19 15:06:01 -0700 | [diff] [blame] | 672 | if (pci_find_capability(ha->pdev, PCI_CAP_ID_PCIX)) |
| 673 | pcix_set_mmrbc(ha->pdev, 2048); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 674 | |
| 675 | /* PCIe -- adjust Maximum Read Request Size (2048). */ |
Andrew Vasquez | f85ec18 | 2007-07-19 15:06:01 -0700 | [diff] [blame] | 676 | if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP)) |
| 677 | pcie_set_readrq(ha->pdev, 2048); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 678 | |
Andrew Vasquez | 737faec | 2008-10-24 15:13:45 -0700 | [diff] [blame] | 679 | pci_disable_rom(ha->pdev); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 680 | |
Auke Kok | 44c1013 | 2007-06-08 15:46:36 -0700 | [diff] [blame] | 681 | ha->chip_revision = ha->pdev->revision; |
Andrew Vasquez | a8488ab | 2007-01-29 10:22:19 -0800 | [diff] [blame] | 682 | |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 683 | /* Get PCI bus information. */ |
| 684 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 685 | ha->pci_attr = RD_REG_DWORD(®->ctrl_status); |
| 686 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 687 | |
| 688 | return QLA_SUCCESS; |
| 689 | } |
| 690 | |
| 691 | /** |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 692 | * qla25xx_pci_config() - Setup ISP25xx PCI configuration registers. |
| 693 | * @ha: HA context |
| 694 | * |
| 695 | * Returns 0 on success. |
| 696 | */ |
| 697 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 698 | qla25xx_pci_config(scsi_qla_host_t *vha) |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 699 | { |
| 700 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 701 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 702 | |
| 703 | pci_set_master(ha->pdev); |
| 704 | pci_try_set_mwi(ha->pdev); |
| 705 | |
| 706 | pci_read_config_word(ha->pdev, PCI_COMMAND, &w); |
| 707 | w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); |
| 708 | w &= ~PCI_COMMAND_INTX_DISABLE; |
| 709 | pci_write_config_word(ha->pdev, PCI_COMMAND, w); |
| 710 | |
| 711 | /* PCIe -- adjust Maximum Read Request Size (2048). */ |
| 712 | if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP)) |
| 713 | pcie_set_readrq(ha->pdev, 2048); |
| 714 | |
Andrew Vasquez | 737faec | 2008-10-24 15:13:45 -0700 | [diff] [blame] | 715 | pci_disable_rom(ha->pdev); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 716 | |
| 717 | ha->chip_revision = ha->pdev->revision; |
| 718 | |
| 719 | return QLA_SUCCESS; |
| 720 | } |
| 721 | |
| 722 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | * qla2x00_isp_firmware() - Choose firmware image. |
| 724 | * @ha: HA context |
| 725 | * |
| 726 | * Returns 0 on success. |
| 727 | */ |
| 728 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 729 | qla2x00_isp_firmware(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | { |
| 731 | int rval; |
Andrew Vasquez | 42e421b | 2008-07-10 16:56:01 -0700 | [diff] [blame] | 732 | uint16_t loop_id, topo, sw_cap; |
| 733 | uint8_t domain, area, al_pa; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 734 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 735 | |
| 736 | /* Assume loading risc code */ |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 737 | rval = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | |
| 739 | if (ha->flags.disable_risc_code_load) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 740 | ql_log(ql_log_info, vha, 0x0079, "RISC CODE NOT loaded.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 741 | |
| 742 | /* Verify checksum of loaded RISC code. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 743 | rval = qla2x00_verify_checksum(vha, ha->fw_srisc_address); |
Andrew Vasquez | 42e421b | 2008-07-10 16:56:01 -0700 | [diff] [blame] | 744 | if (rval == QLA_SUCCESS) { |
| 745 | /* And, verify we are not in ROM code. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 746 | rval = qla2x00_get_adapter_id(vha, &loop_id, &al_pa, |
Andrew Vasquez | 42e421b | 2008-07-10 16:56:01 -0700 | [diff] [blame] | 747 | &area, &domain, &topo, &sw_cap); |
| 748 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | } |
| 750 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 751 | if (rval) |
| 752 | ql_dbg(ql_dbg_init, vha, 0x007a, |
| 753 | "**** Load RISC code ****.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | |
| 755 | return (rval); |
| 756 | } |
| 757 | |
| 758 | /** |
| 759 | * qla2x00_reset_chip() - Reset ISP chip. |
| 760 | * @ha: HA context |
| 761 | * |
| 762 | * Returns 0 on success. |
| 763 | */ |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 764 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 765 | qla2x00_reset_chip(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | { |
| 767 | unsigned long flags = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 768 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 769 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | uint32_t cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | uint16_t cmd; |
| 772 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 773 | if (unlikely(pci_channel_offline(ha->pdev))) |
| 774 | return; |
| 775 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 776 | ha->isp_ops->disable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | |
| 778 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 779 | |
| 780 | /* Turn off master enable */ |
| 781 | cmd = 0; |
| 782 | pci_read_config_word(ha->pdev, PCI_COMMAND, &cmd); |
| 783 | cmd &= ~PCI_COMMAND_MASTER; |
| 784 | pci_write_config_word(ha->pdev, PCI_COMMAND, cmd); |
| 785 | |
| 786 | if (!IS_QLA2100(ha)) { |
| 787 | /* Pause RISC. */ |
| 788 | WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC); |
| 789 | if (IS_QLA2200(ha) || IS_QLA2300(ha)) { |
| 790 | for (cnt = 0; cnt < 30000; cnt++) { |
| 791 | if ((RD_REG_WORD(®->hccr) & |
| 792 | HCCR_RISC_PAUSE) != 0) |
| 793 | break; |
| 794 | udelay(100); |
| 795 | } |
| 796 | } else { |
| 797 | RD_REG_WORD(®->hccr); /* PCI Posting. */ |
| 798 | udelay(10); |
| 799 | } |
| 800 | |
| 801 | /* Select FPM registers. */ |
| 802 | WRT_REG_WORD(®->ctrl_status, 0x20); |
| 803 | RD_REG_WORD(®->ctrl_status); /* PCI Posting. */ |
| 804 | |
| 805 | /* FPM Soft Reset. */ |
| 806 | WRT_REG_WORD(®->fpm_diag_config, 0x100); |
| 807 | RD_REG_WORD(®->fpm_diag_config); /* PCI Posting. */ |
| 808 | |
| 809 | /* Toggle Fpm Reset. */ |
| 810 | if (!IS_QLA2200(ha)) { |
| 811 | WRT_REG_WORD(®->fpm_diag_config, 0x0); |
| 812 | RD_REG_WORD(®->fpm_diag_config); /* PCI Posting. */ |
| 813 | } |
| 814 | |
| 815 | /* Select frame buffer registers. */ |
| 816 | WRT_REG_WORD(®->ctrl_status, 0x10); |
| 817 | RD_REG_WORD(®->ctrl_status); /* PCI Posting. */ |
| 818 | |
| 819 | /* Reset frame buffer FIFOs. */ |
| 820 | if (IS_QLA2200(ha)) { |
| 821 | WRT_FB_CMD_REG(ha, reg, 0xa000); |
| 822 | RD_FB_CMD_REG(ha, reg); /* PCI Posting. */ |
| 823 | } else { |
| 824 | WRT_FB_CMD_REG(ha, reg, 0x00fc); |
| 825 | |
| 826 | /* Read back fb_cmd until zero or 3 seconds max */ |
| 827 | for (cnt = 0; cnt < 3000; cnt++) { |
| 828 | if ((RD_FB_CMD_REG(ha, reg) & 0xff) == 0) |
| 829 | break; |
| 830 | udelay(100); |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | /* Select RISC module registers. */ |
| 835 | WRT_REG_WORD(®->ctrl_status, 0); |
| 836 | RD_REG_WORD(®->ctrl_status); /* PCI Posting. */ |
| 837 | |
| 838 | /* Reset RISC processor. */ |
| 839 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 840 | RD_REG_WORD(®->hccr); /* PCI Posting. */ |
| 841 | |
| 842 | /* Release RISC processor. */ |
| 843 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
| 844 | RD_REG_WORD(®->hccr); /* PCI Posting. */ |
| 845 | } |
| 846 | |
| 847 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); |
| 848 | WRT_REG_WORD(®->hccr, HCCR_CLR_HOST_INT); |
| 849 | |
| 850 | /* Reset ISP chip. */ |
| 851 | WRT_REG_WORD(®->ctrl_status, CSR_ISP_SOFT_RESET); |
| 852 | |
| 853 | /* Wait for RISC to recover from reset. */ |
| 854 | if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) { |
| 855 | /* |
| 856 | * It is necessary to for a delay here since the card doesn't |
| 857 | * respond to PCI reads during a reset. On some architectures |
| 858 | * this will result in an MCA. |
| 859 | */ |
| 860 | udelay(20); |
| 861 | for (cnt = 30000; cnt; cnt--) { |
| 862 | if ((RD_REG_WORD(®->ctrl_status) & |
| 863 | CSR_ISP_SOFT_RESET) == 0) |
| 864 | break; |
| 865 | udelay(100); |
| 866 | } |
| 867 | } else |
| 868 | udelay(10); |
| 869 | |
| 870 | /* Reset RISC processor. */ |
| 871 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 872 | |
| 873 | WRT_REG_WORD(®->semaphore, 0); |
| 874 | |
| 875 | /* Release RISC processor. */ |
| 876 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
| 877 | RD_REG_WORD(®->hccr); /* PCI Posting. */ |
| 878 | |
| 879 | if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) { |
| 880 | for (cnt = 0; cnt < 30000; cnt++) { |
Andrew Vasquez | ffb39f0 | 2006-05-17 15:09:06 -0700 | [diff] [blame] | 881 | if (RD_MAILBOX_REG(ha, reg, 0) != MBS_BUSY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | |
| 884 | udelay(100); |
| 885 | } |
| 886 | } else |
| 887 | udelay(100); |
| 888 | |
| 889 | /* Turn on master enable */ |
| 890 | cmd |= PCI_COMMAND_MASTER; |
| 891 | pci_write_config_word(ha->pdev, PCI_COMMAND, cmd); |
| 892 | |
| 893 | /* Disable RISC pause on FPM parity error. */ |
| 894 | if (!IS_QLA2100(ha)) { |
| 895 | WRT_REG_WORD(®->hccr, HCCR_DISABLE_PARITY_PAUSE); |
| 896 | RD_REG_WORD(®->hccr); /* PCI Posting. */ |
| 897 | } |
| 898 | |
| 899 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 900 | } |
| 901 | |
| 902 | /** |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 903 | * qla81xx_reset_mpi() - Reset's MPI FW via Write MPI Register MBC. |
| 904 | * |
| 905 | * Returns 0 on success. |
| 906 | */ |
| 907 | int |
| 908 | qla81xx_reset_mpi(scsi_qla_host_t *vha) |
| 909 | { |
| 910 | uint16_t mb[4] = {0x1010, 0, 1, 0}; |
| 911 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 912 | if (!IS_QLA81XX(vha->hw)) |
| 913 | return QLA_SUCCESS; |
| 914 | |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 915 | return qla81xx_write_mpi_register(vha, mb); |
| 916 | } |
| 917 | |
| 918 | /** |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 919 | * qla24xx_reset_risc() - Perform full reset of ISP24xx RISC. |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 920 | * @ha: HA context |
| 921 | * |
| 922 | * Returns 0 on success. |
| 923 | */ |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 924 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 925 | qla24xx_reset_risc(scsi_qla_host_t *vha) |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 926 | { |
| 927 | unsigned long flags = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 928 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 929 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 930 | uint32_t cnt, d2; |
Andrew Vasquez | 335a1cc | 2005-11-08 14:37:48 -0800 | [diff] [blame] | 931 | uint16_t wd; |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 932 | static int abts_cnt; /* ISP abort retry counts */ |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 933 | |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 934 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 935 | |
| 936 | /* Reset RISC. */ |
| 937 | WRT_REG_DWORD(®->ctrl_status, CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); |
| 938 | for (cnt = 0; cnt < 30000; cnt++) { |
| 939 | if ((RD_REG_DWORD(®->ctrl_status) & CSRX_DMA_ACTIVE) == 0) |
| 940 | break; |
| 941 | |
| 942 | udelay(10); |
| 943 | } |
| 944 | |
| 945 | WRT_REG_DWORD(®->ctrl_status, |
| 946 | CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); |
Andrew Vasquez | 335a1cc | 2005-11-08 14:37:48 -0800 | [diff] [blame] | 947 | pci_read_config_word(ha->pdev, PCI_COMMAND, &wd); |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 948 | |
Andrew Vasquez | 335a1cc | 2005-11-08 14:37:48 -0800 | [diff] [blame] | 949 | udelay(100); |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 950 | /* Wait for firmware to complete NVRAM accesses. */ |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 951 | d2 = (uint32_t) RD_REG_WORD(®->mailbox0); |
| 952 | for (cnt = 10000 ; cnt && d2; cnt--) { |
| 953 | udelay(5); |
| 954 | d2 = (uint32_t) RD_REG_WORD(®->mailbox0); |
| 955 | barrier(); |
| 956 | } |
| 957 | |
Andrew Vasquez | 335a1cc | 2005-11-08 14:37:48 -0800 | [diff] [blame] | 958 | /* Wait for soft-reset to complete. */ |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 959 | d2 = RD_REG_DWORD(®->ctrl_status); |
| 960 | for (cnt = 6000000 ; cnt && (d2 & CSRX_ISP_SOFT_RESET); cnt--) { |
| 961 | udelay(5); |
| 962 | d2 = RD_REG_DWORD(®->ctrl_status); |
| 963 | barrier(); |
| 964 | } |
| 965 | |
Madhuranath Iyengar | b1d46989 | 2010-09-03 15:20:54 -0700 | [diff] [blame] | 966 | /* If required, do an MPI FW reset now */ |
| 967 | if (test_and_clear_bit(MPI_RESET_NEEDED, &vha->dpc_flags)) { |
| 968 | if (qla81xx_reset_mpi(vha) != QLA_SUCCESS) { |
| 969 | if (++abts_cnt < 5) { |
| 970 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 971 | set_bit(MPI_RESET_NEEDED, &vha->dpc_flags); |
| 972 | } else { |
| 973 | /* |
| 974 | * We exhausted the ISP abort retries. We have to |
| 975 | * set the board offline. |
| 976 | */ |
| 977 | abts_cnt = 0; |
| 978 | vha->flags.online = 0; |
| 979 | } |
| 980 | } |
| 981 | } |
| 982 | |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 983 | WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_RESET); |
| 984 | RD_REG_DWORD(®->hccr); |
| 985 | |
| 986 | WRT_REG_DWORD(®->hccr, HCCRX_REL_RISC_PAUSE); |
| 987 | RD_REG_DWORD(®->hccr); |
| 988 | |
| 989 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_RESET); |
| 990 | RD_REG_DWORD(®->hccr); |
| 991 | |
| 992 | d2 = (uint32_t) RD_REG_WORD(®->mailbox0); |
| 993 | for (cnt = 6000000 ; cnt && d2; cnt--) { |
| 994 | udelay(5); |
| 995 | d2 = (uint32_t) RD_REG_WORD(®->mailbox0); |
| 996 | barrier(); |
| 997 | } |
| 998 | |
| 999 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1000 | |
| 1001 | if (IS_NOPOLLING_TYPE(ha)) |
| 1002 | ha->isp_ops->enable_intrs(ha); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1003 | } |
| 1004 | |
| 1005 | /** |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 1006 | * qla24xx_reset_chip() - Reset ISP24xx chip. |
| 1007 | * @ha: HA context |
| 1008 | * |
| 1009 | * Returns 0 on success. |
| 1010 | */ |
| 1011 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1012 | qla24xx_reset_chip(scsi_qla_host_t *vha) |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 1013 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1014 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1015 | |
| 1016 | if (pci_channel_offline(ha->pdev) && |
| 1017 | ha->flags.pci_channel_io_perm_failure) { |
| 1018 | return; |
| 1019 | } |
| 1020 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1021 | ha->isp_ops->disable_intrs(ha); |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 1022 | |
| 1023 | /* Perform RISC reset. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1024 | qla24xx_reset_risc(vha); |
Andrew Vasquez | 88c2666 | 2005-07-08 17:59:26 -0700 | [diff] [blame] | 1025 | } |
| 1026 | |
| 1027 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1028 | * qla2x00_chip_diag() - Test chip for proper operation. |
| 1029 | * @ha: HA context |
| 1030 | * |
| 1031 | * Returns 0 on success. |
| 1032 | */ |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1033 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1034 | qla2x00_chip_diag(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1035 | { |
| 1036 | int rval; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1037 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 1038 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1039 | unsigned long flags = 0; |
| 1040 | uint16_t data; |
| 1041 | uint32_t cnt; |
| 1042 | uint16_t mb[5]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1043 | struct req_que *req = ha->req_q_map[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1044 | |
| 1045 | /* Assume a failed state */ |
| 1046 | rval = QLA_FUNCTION_FAILED; |
| 1047 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1048 | ql_dbg(ql_dbg_init, vha, 0x007b, |
| 1049 | "Testing device at %lx.\n", (u_long)®->flash_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | |
| 1051 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1052 | |
| 1053 | /* Reset ISP chip. */ |
| 1054 | WRT_REG_WORD(®->ctrl_status, CSR_ISP_SOFT_RESET); |
| 1055 | |
| 1056 | /* |
| 1057 | * We need to have a delay here since the card will not respond while |
| 1058 | * in reset causing an MCA on some architectures. |
| 1059 | */ |
| 1060 | udelay(20); |
| 1061 | data = qla2x00_debounce_register(®->ctrl_status); |
| 1062 | for (cnt = 6000000 ; cnt && (data & CSR_ISP_SOFT_RESET); cnt--) { |
| 1063 | udelay(5); |
| 1064 | data = RD_REG_WORD(®->ctrl_status); |
| 1065 | barrier(); |
| 1066 | } |
| 1067 | |
| 1068 | if (!cnt) |
| 1069 | goto chip_diag_failed; |
| 1070 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1071 | ql_dbg(ql_dbg_init, vha, 0x007c, |
| 1072 | "Reset register cleared by chip reset.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | |
| 1074 | /* Reset RISC processor. */ |
| 1075 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 1076 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
| 1077 | |
| 1078 | /* Workaround for QLA2312 PCI parity error */ |
| 1079 | if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) { |
| 1080 | data = qla2x00_debounce_register(MAILBOX_REG(ha, reg, 0)); |
| 1081 | for (cnt = 6000000; cnt && (data == MBS_BUSY); cnt--) { |
| 1082 | udelay(5); |
| 1083 | data = RD_MAILBOX_REG(ha, reg, 0); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1084 | barrier(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1085 | } |
| 1086 | } else |
| 1087 | udelay(10); |
| 1088 | |
| 1089 | if (!cnt) |
| 1090 | goto chip_diag_failed; |
| 1091 | |
| 1092 | /* Check product ID of chip */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1093 | 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] | 1094 | |
| 1095 | mb[1] = RD_MAILBOX_REG(ha, reg, 1); |
| 1096 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); |
| 1097 | mb[3] = RD_MAILBOX_REG(ha, reg, 3); |
| 1098 | mb[4] = qla2x00_debounce_register(MAILBOX_REG(ha, reg, 4)); |
| 1099 | if (mb[1] != PROD_ID_1 || (mb[2] != PROD_ID_2 && mb[2] != PROD_ID_2a) || |
| 1100 | mb[3] != PROD_ID_3) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1101 | ql_log(ql_log_warn, vha, 0x0062, |
| 1102 | "Wrong product ID = 0x%x,0x%x,0x%x.\n", |
| 1103 | mb[1], mb[2], mb[3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1104 | |
| 1105 | goto chip_diag_failed; |
| 1106 | } |
| 1107 | ha->product_id[0] = mb[1]; |
| 1108 | ha->product_id[1] = mb[2]; |
| 1109 | ha->product_id[2] = mb[3]; |
| 1110 | ha->product_id[3] = mb[4]; |
| 1111 | |
| 1112 | /* Adjust fw RISC transfer size */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1113 | if (req->length > 1024) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * 1024; |
| 1115 | else |
| 1116 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1117 | req->length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1118 | |
| 1119 | if (IS_QLA2200(ha) && |
| 1120 | RD_MAILBOX_REG(ha, reg, 7) == QLA2200A_RISC_ROM_VER) { |
| 1121 | /* Limit firmware transfer size with a 2200A */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1122 | ql_dbg(ql_dbg_init, vha, 0x007e, "Found QLA2200A Chip.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1123 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1124 | ha->device_type |= DT_ISP2200A; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | ha->fw_transfer_size = 128; |
| 1126 | } |
| 1127 | |
| 1128 | /* Wrap Incoming Mailboxes Test. */ |
| 1129 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1130 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1131 | ql_dbg(ql_dbg_init, vha, 0x007f, "Checking mailboxes.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1132 | rval = qla2x00_mbx_reg_test(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1133 | if (rval) |
| 1134 | ql_log(ql_log_warn, vha, 0x0080, |
| 1135 | "Failed mailbox send register test.\n"); |
| 1136 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1137 | /* Flag a successful rval */ |
| 1138 | rval = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1139 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1140 | |
| 1141 | chip_diag_failed: |
| 1142 | if (rval) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1143 | ql_log(ql_log_info, vha, 0x0081, |
| 1144 | "Chip diagnostics **** FAILED ****.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1145 | |
| 1146 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1147 | |
| 1148 | return (rval); |
| 1149 | } |
| 1150 | |
| 1151 | /** |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1152 | * qla24xx_chip_diag() - Test ISP24xx for proper operation. |
| 1153 | * @ha: HA context |
| 1154 | * |
| 1155 | * Returns 0 on success. |
| 1156 | */ |
| 1157 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1158 | qla24xx_chip_diag(scsi_qla_host_t *vha) |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1159 | { |
| 1160 | int rval; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1161 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1162 | struct req_que *req = ha->req_q_map[0]; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1163 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1164 | if (IS_QLA82XX(ha)) |
| 1165 | return QLA_SUCCESS; |
| 1166 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1167 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * req->length; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1168 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1169 | rval = qla2x00_mbx_reg_test(vha); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1170 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1171 | ql_log(ql_log_warn, vha, 0x0082, |
| 1172 | "Failed mailbox send register test.\n"); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1173 | } else { |
| 1174 | /* Flag a successful rval */ |
| 1175 | rval = QLA_SUCCESS; |
| 1176 | } |
| 1177 | |
| 1178 | return rval; |
| 1179 | } |
| 1180 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1181 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1182 | qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1183 | { |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1184 | int rval; |
| 1185 | 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] | 1186 | eft_size, fce_size, mq_size; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 1187 | dma_addr_t tc_dma; |
| 1188 | void *tc; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1189 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1190 | struct req_que *req = ha->req_q_map[0]; |
| 1191 | struct rsp_que *rsp = ha->rsp_q_map[0]; |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 1192 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1193 | if (ha->fw_dump) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1194 | ql_dbg(ql_dbg_init, vha, 0x00bd, |
| 1195 | "Firmware dump already allocated.\n"); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1196 | return; |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 1197 | } |
| 1198 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1199 | ha->fw_dumped = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1200 | fixed_size = mem_size = eft_size = fce_size = mq_size = 0; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1201 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
| 1202 | fixed_size = sizeof(struct qla2100_fw_dump); |
| 1203 | } else if (IS_QLA23XX(ha)) { |
| 1204 | fixed_size = offsetof(struct qla2300_fw_dump, data_ram); |
| 1205 | mem_size = (ha->fw_memory_size - 0x11000 + 1) * |
| 1206 | sizeof(uint16_t); |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1207 | } else if (IS_FWI2_CAPABLE(ha)) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1208 | if (IS_QLA83XX(ha)) |
| 1209 | fixed_size = offsetof(struct qla83xx_fw_dump, ext_mem); |
| 1210 | else if (IS_QLA81XX(ha)) |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1211 | fixed_size = offsetof(struct qla81xx_fw_dump, ext_mem); |
| 1212 | else if (IS_QLA25XX(ha)) |
| 1213 | fixed_size = offsetof(struct qla25xx_fw_dump, ext_mem); |
| 1214 | else |
| 1215 | fixed_size = offsetof(struct qla24xx_fw_dump, ext_mem); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1216 | mem_size = (ha->fw_memory_size - 0x100000 + 1) * |
| 1217 | sizeof(uint32_t); |
Giridhar Malavali | 050c9bb | 2012-02-09 11:15:33 -0800 | [diff] [blame] | 1218 | if (ha->mqenable) { |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1219 | if (!IS_QLA83XX(ha)) |
| 1220 | mq_size = sizeof(struct qla2xxx_mq_chain); |
Giridhar Malavali | 050c9bb | 2012-02-09 11:15:33 -0800 | [diff] [blame] | 1221 | /* |
| 1222 | * Allocate maximum buffer size for all queues. |
| 1223 | * Resizing must be done at end-of-dump processing. |
| 1224 | */ |
| 1225 | mq_size += ha->max_req_queues * |
| 1226 | (req->length * sizeof(request_t)); |
| 1227 | mq_size += ha->max_rsp_queues * |
| 1228 | (rsp->length * sizeof(response_t)); |
| 1229 | } |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1230 | /* Allocate memory for Fibre Channel Event Buffer. */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1231 | if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha)) |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1232 | goto try_eft; |
| 1233 | |
| 1234 | tc = dma_alloc_coherent(&ha->pdev->dev, FCE_SIZE, &tc_dma, |
| 1235 | GFP_KERNEL); |
| 1236 | if (!tc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1237 | ql_log(ql_log_warn, vha, 0x00be, |
| 1238 | "Unable to allocate (%d KB) for FCE.\n", |
| 1239 | FCE_SIZE / 1024); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1240 | goto try_eft; |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1241 | } |
| 1242 | |
| 1243 | memset(tc, 0, FCE_SIZE); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1244 | rval = qla2x00_enable_fce_trace(vha, tc_dma, FCE_NUM_BUFFERS, |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1245 | ha->fce_mb, &ha->fce_bufs); |
| 1246 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1247 | ql_log(ql_log_warn, vha, 0x00bf, |
| 1248 | "Unable to initialize FCE (%d).\n", rval); |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1249 | dma_free_coherent(&ha->pdev->dev, FCE_SIZE, tc, |
| 1250 | tc_dma); |
| 1251 | ha->flags.fce_enabled = 0; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1252 | goto try_eft; |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1253 | } |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1254 | ql_dbg(ql_dbg_init, vha, 0x00c0, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1255 | "Allocate (%d KB) for FCE...\n", FCE_SIZE / 1024); |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1256 | |
Giridhar Malavali | 7d9dade | 2009-03-24 09:07:58 -0700 | [diff] [blame] | 1257 | fce_size = sizeof(struct qla2xxx_fce_chain) + FCE_SIZE; |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 1258 | ha->flags.fce_enabled = 1; |
| 1259 | ha->fce_dma = tc_dma; |
| 1260 | ha->fce = tc; |
| 1261 | try_eft: |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1262 | /* Allocate memory for Extended Trace Buffer. */ |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 1263 | tc = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &tc_dma, |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1264 | GFP_KERNEL); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 1265 | if (!tc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1266 | ql_log(ql_log_warn, vha, 0x00c1, |
| 1267 | "Unable to allocate (%d KB) for EFT.\n", |
| 1268 | EFT_SIZE / 1024); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1269 | goto cont_alloc; |
| 1270 | } |
| 1271 | |
Andrew Vasquez | fc44765 | 2008-01-17 09:02:18 -0800 | [diff] [blame] | 1272 | memset(tc, 0, EFT_SIZE); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1273 | rval = qla2x00_enable_eft_trace(vha, tc_dma, EFT_NUM_BUFFERS); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1274 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1275 | ql_log(ql_log_warn, vha, 0x00c2, |
| 1276 | "Unable to initialize EFT (%d).\n", rval); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 1277 | dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc, |
| 1278 | tc_dma); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1279 | goto cont_alloc; |
| 1280 | } |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1281 | ql_dbg(ql_dbg_init, vha, 0x00c3, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1282 | "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1283 | |
| 1284 | eft_size = EFT_SIZE; |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 1285 | ha->eft_dma = tc_dma; |
| 1286 | ha->eft = tc; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1287 | } |
| 1288 | cont_alloc: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1289 | req_q_size = req->length * sizeof(request_t); |
| 1290 | rsp_q_size = rsp->length * sizeof(response_t); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1291 | |
| 1292 | dump_size = offsetof(struct qla2xxx_fw_dump, isp); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1293 | 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] | 1294 | ha->chain_offset = dump_size; |
| 1295 | dump_size += mq_size + fce_size; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1296 | |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 1297 | ha->fw_dump = vmalloc(dump_size); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1298 | if (!ha->fw_dump) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1299 | ql_log(ql_log_warn, vha, 0x00c4, |
| 1300 | "Unable to allocate (%d KB) for firmware dump.\n", |
| 1301 | dump_size / 1024); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1302 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 1303 | if (ha->fce) { |
| 1304 | dma_free_coherent(&ha->pdev->dev, FCE_SIZE, ha->fce, |
| 1305 | ha->fce_dma); |
| 1306 | ha->fce = NULL; |
| 1307 | ha->fce_dma = 0; |
| 1308 | } |
| 1309 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1310 | if (ha->eft) { |
| 1311 | dma_free_coherent(&ha->pdev->dev, eft_size, ha->eft, |
| 1312 | ha->eft_dma); |
| 1313 | ha->eft = NULL; |
| 1314 | ha->eft_dma = 0; |
| 1315 | } |
| 1316 | return; |
| 1317 | } |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1318 | ql_dbg(ql_dbg_init, vha, 0x00c5, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1319 | "Allocated (%d KB) for firmware dump.\n", dump_size / 1024); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 1320 | |
| 1321 | ha->fw_dump_len = dump_size; |
| 1322 | ha->fw_dump->signature[0] = 'Q'; |
| 1323 | ha->fw_dump->signature[1] = 'L'; |
| 1324 | ha->fw_dump->signature[2] = 'G'; |
| 1325 | ha->fw_dump->signature[3] = 'C'; |
| 1326 | ha->fw_dump->version = __constant_htonl(1); |
| 1327 | |
| 1328 | ha->fw_dump->fixed_size = htonl(fixed_size); |
| 1329 | ha->fw_dump->mem_size = htonl(mem_size); |
| 1330 | ha->fw_dump->req_q_size = htonl(req_q_size); |
| 1331 | ha->fw_dump->rsp_q_size = htonl(rsp_q_size); |
| 1332 | |
| 1333 | ha->fw_dump->eft_size = htonl(eft_size); |
| 1334 | ha->fw_dump->eft_addr_l = htonl(LSD(ha->eft_dma)); |
| 1335 | ha->fw_dump->eft_addr_h = htonl(MSD(ha->eft_dma)); |
| 1336 | |
| 1337 | ha->fw_dump->header_size = |
| 1338 | htonl(offsetof(struct qla2xxx_fw_dump, isp)); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1339 | } |
| 1340 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 1341 | static int |
| 1342 | qla81xx_mpi_sync(scsi_qla_host_t *vha) |
| 1343 | { |
| 1344 | #define MPS_MASK 0xe0 |
| 1345 | int rval; |
| 1346 | uint16_t dc; |
| 1347 | uint32_t dw; |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 1348 | |
| 1349 | if (!IS_QLA81XX(vha->hw)) |
| 1350 | return QLA_SUCCESS; |
| 1351 | |
| 1352 | rval = qla2x00_write_ram_word(vha, 0x7c00, 1); |
| 1353 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1354 | ql_log(ql_log_warn, vha, 0x0105, |
| 1355 | "Unable to acquire semaphore.\n"); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 1356 | goto done; |
| 1357 | } |
| 1358 | |
| 1359 | pci_read_config_word(vha->hw->pdev, 0x54, &dc); |
| 1360 | rval = qla2x00_read_ram_word(vha, 0x7a15, &dw); |
| 1361 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1362 | ql_log(ql_log_warn, vha, 0x0067, "Unable to read sync.\n"); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 1363 | goto done_release; |
| 1364 | } |
| 1365 | |
| 1366 | dc &= MPS_MASK; |
| 1367 | if (dc == (dw & MPS_MASK)) |
| 1368 | goto done_release; |
| 1369 | |
| 1370 | dw &= ~MPS_MASK; |
| 1371 | dw |= dc; |
| 1372 | rval = qla2x00_write_ram_word(vha, 0x7a15, dw); |
| 1373 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1374 | ql_log(ql_log_warn, vha, 0x0114, "Unable to gain sync.\n"); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 1375 | } |
| 1376 | |
| 1377 | done_release: |
| 1378 | rval = qla2x00_write_ram_word(vha, 0x7c00, 0); |
| 1379 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1380 | ql_log(ql_log_warn, vha, 0x006d, |
| 1381 | "Unable to release semaphore.\n"); |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 1382 | } |
| 1383 | |
| 1384 | done: |
| 1385 | return rval; |
| 1386 | } |
| 1387 | |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1388 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1389 | * qla2x00_setup_chip() - Load and start RISC firmware. |
| 1390 | * @ha: HA context |
| 1391 | * |
| 1392 | * Returns 0 on success. |
| 1393 | */ |
| 1394 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1395 | qla2x00_setup_chip(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1396 | { |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1397 | int rval; |
| 1398 | uint32_t srisc_address = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1399 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3db0652 | 2008-01-31 12:33:49 -0800 | [diff] [blame] | 1400 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1401 | unsigned long flags; |
Andrew Vasquez | dda772e | 2009-03-24 09:08:00 -0700 | [diff] [blame] | 1402 | uint16_t fw_major_version; |
Andrew Vasquez | 3db0652 | 2008-01-31 12:33:49 -0800 | [diff] [blame] | 1403 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1404 | if (IS_QLA82XX(ha)) { |
| 1405 | rval = ha->isp_ops->load_risc(vha, &srisc_address); |
Andrew Vasquez | 14e303d | 2010-07-23 15:28:29 +0500 | [diff] [blame] | 1406 | if (rval == QLA_SUCCESS) { |
| 1407 | qla2x00_stop_firmware(vha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1408 | goto enable_82xx_npiv; |
Andrew Vasquez | 14e303d | 2010-07-23 15:28:29 +0500 | [diff] [blame] | 1409 | } else |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 1410 | goto failed; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1411 | } |
| 1412 | |
Andrew Vasquez | 3db0652 | 2008-01-31 12:33:49 -0800 | [diff] [blame] | 1413 | if (!IS_FWI2_CAPABLE(ha) && !IS_QLA2100(ha) && !IS_QLA2200(ha)) { |
| 1414 | /* Disable SRAM, Instruction RAM and GP RAM parity. */ |
| 1415 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1416 | WRT_REG_WORD(®->hccr, (HCCR_ENABLE_PARITY + 0x0)); |
| 1417 | RD_REG_WORD(®->hccr); |
| 1418 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1419 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | |
Andrew Vasquez | 18e7555 | 2009-06-03 09:55:30 -0700 | [diff] [blame] | 1421 | qla81xx_mpi_sync(vha); |
| 1422 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | /* Load firmware sequences */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1424 | rval = ha->isp_ops->load_risc(vha, &srisc_address); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1425 | if (rval == QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1426 | ql_dbg(ql_dbg_init, vha, 0x00c9, |
| 1427 | "Verifying Checksum of loaded RISC code.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1429 | rval = qla2x00_verify_checksum(vha, srisc_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1430 | if (rval == QLA_SUCCESS) { |
| 1431 | /* Start firmware execution. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1432 | ql_dbg(ql_dbg_init, vha, 0x00ca, |
| 1433 | "Starting firmware.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1434 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1435 | rval = qla2x00_execute_fw(vha, srisc_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1436 | /* Retrieve firmware information. */ |
Andrew Vasquez | dda772e | 2009-03-24 09:08:00 -0700 | [diff] [blame] | 1437 | if (rval == QLA_SUCCESS) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1438 | enable_82xx_npiv: |
Andrew Vasquez | dda772e | 2009-03-24 09:08:00 -0700 | [diff] [blame] | 1439 | fw_major_version = ha->fw_major_version; |
Giridhar Malavali | 3173167 | 2011-08-16 11:31:54 -0700 | [diff] [blame] | 1440 | if (IS_QLA82XX(ha)) |
| 1441 | qla82xx_check_md_needed(vha); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1442 | else |
| 1443 | rval = qla2x00_get_fw_version(vha); |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1444 | if (rval != QLA_SUCCESS) |
| 1445 | goto failed; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1446 | ha->flags.npiv_supported = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1447 | if (IS_QLA2XXX_MIDTYPE(ha) && |
Mike Hernandez | 946fb89 | 2008-08-13 21:36:59 -0700 | [diff] [blame] | 1448 | (ha->fw_attributes & BIT_2)) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1449 | ha->flags.npiv_supported = 1; |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 1450 | if ((!ha->max_npiv_vports) || |
| 1451 | ((ha->max_npiv_vports + 1) % |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 1452 | MIN_MULTI_ID_FABRIC)) |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 1453 | ha->max_npiv_vports = |
Andrew Vasquez | eb66dc6 | 2007-11-12 10:30:58 -0800 | [diff] [blame] | 1454 | MIN_MULTI_ID_FABRIC - 1; |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 1455 | } |
Andrew Vasquez | 24a0813 | 2009-03-24 09:08:16 -0700 | [diff] [blame] | 1456 | qla2x00_get_resource_cnts(vha, NULL, |
| 1457 | &ha->fw_xcb_count, NULL, NULL, |
Andrew Vasquez | f3a0a77 | 2009-10-13 15:16:49 -0700 | [diff] [blame] | 1458 | &ha->max_npiv_vports, NULL); |
Andrew Vasquez | d743de6 | 2009-03-24 09:08:15 -0700 | [diff] [blame] | 1459 | |
Saurav Kashyap | be5ea3c | 2011-11-18 09:02:11 -0800 | [diff] [blame] | 1460 | if (!fw_major_version && ql2xallocfwdump |
| 1461 | && !IS_QLA82XX(ha)) |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 1462 | qla2x00_alloc_fw_dump(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1463 | } |
| 1464 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1465 | ql_log(ql_log_fatal, vha, 0x00cd, |
| 1466 | "ISP Firmware failed checksum.\n"); |
| 1467 | goto failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | } |
| 1469 | } |
| 1470 | |
Andrew Vasquez | 3db0652 | 2008-01-31 12:33:49 -0800 | [diff] [blame] | 1471 | if (!IS_FWI2_CAPABLE(ha) && !IS_QLA2100(ha) && !IS_QLA2200(ha)) { |
| 1472 | /* Enable proper parity. */ |
| 1473 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1474 | if (IS_QLA2300(ha)) |
| 1475 | /* SRAM parity */ |
| 1476 | WRT_REG_WORD(®->hccr, HCCR_ENABLE_PARITY + 0x1); |
| 1477 | else |
| 1478 | /* SRAM, Instruction RAM and GP RAM parity */ |
| 1479 | WRT_REG_WORD(®->hccr, HCCR_ENABLE_PARITY + 0x7); |
| 1480 | RD_REG_WORD(®->hccr); |
| 1481 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1482 | } |
| 1483 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1484 | if (IS_QLA83XX(ha)) |
| 1485 | goto skip_fac_check; |
| 1486 | |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 1487 | if (rval == QLA_SUCCESS && IS_FAC_REQUIRED(ha)) { |
| 1488 | uint32_t size; |
| 1489 | |
| 1490 | rval = qla81xx_fac_get_sector_size(vha, &size); |
| 1491 | if (rval == QLA_SUCCESS) { |
| 1492 | ha->flags.fac_supported = 1; |
| 1493 | ha->fdt_block_size = size << 2; |
| 1494 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1495 | ql_log(ql_log_warn, vha, 0x00ce, |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 1496 | "Unsupported FAC firmware (%d.%02d.%02d).\n", |
| 1497 | ha->fw_major_version, ha->fw_minor_version, |
| 1498 | ha->fw_subminor_version); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1499 | skip_fac_check: |
| 1500 | if (IS_QLA83XX(ha)) { |
| 1501 | ha->flags.fac_supported = 0; |
| 1502 | rval = QLA_SUCCESS; |
| 1503 | } |
Joe Carnuccio | 1d2874d | 2009-03-24 09:08:06 -0700 | [diff] [blame] | 1504 | } |
| 1505 | } |
Andrew Vasquez | ca9e9c3 | 2009-06-03 09:55:20 -0700 | [diff] [blame] | 1506 | failed: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1507 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1508 | ql_log(ql_log_fatal, vha, 0x00cf, |
| 1509 | "Setup chip ****FAILED****.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1510 | } |
| 1511 | |
| 1512 | return (rval); |
| 1513 | } |
| 1514 | |
| 1515 | /** |
| 1516 | * qla2x00_init_response_q_entries() - Initializes response queue entries. |
| 1517 | * @ha: HA context |
| 1518 | * |
| 1519 | * Beginning of request ring has initialization control block already built |
| 1520 | * by nvram config routine. |
| 1521 | * |
| 1522 | * Returns 0 on success. |
| 1523 | */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1524 | void |
| 1525 | qla2x00_init_response_q_entries(struct rsp_que *rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1526 | { |
| 1527 | uint16_t cnt; |
| 1528 | response_t *pkt; |
| 1529 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1530 | rsp->ring_ptr = rsp->ring; |
| 1531 | rsp->ring_index = 0; |
| 1532 | rsp->status_srb = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1533 | pkt = rsp->ring_ptr; |
| 1534 | for (cnt = 0; cnt < rsp->length; cnt++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1535 | pkt->signature = RESPONSE_PROCESSED; |
| 1536 | pkt++; |
| 1537 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1538 | } |
| 1539 | |
| 1540 | /** |
| 1541 | * qla2x00_update_fw_options() - Read and process firmware options. |
| 1542 | * @ha: HA context |
| 1543 | * |
| 1544 | * Returns 0 on success. |
| 1545 | */ |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1546 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1547 | qla2x00_update_fw_options(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1548 | { |
| 1549 | uint16_t swing, emphasis, tx_sens, rx_sens; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1550 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1551 | |
| 1552 | memset(ha->fw_options, 0, sizeof(ha->fw_options)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1553 | qla2x00_get_fw_options(vha, ha->fw_options); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1554 | |
| 1555 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 1556 | return; |
| 1557 | |
| 1558 | /* Serial Link options. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1559 | ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x0115, |
| 1560 | "Serial link options.\n"); |
| 1561 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0109, |
| 1562 | (uint8_t *)&ha->fw_seriallink_options, |
| 1563 | sizeof(ha->fw_seriallink_options)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1564 | |
| 1565 | ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING; |
| 1566 | if (ha->fw_seriallink_options[3] & BIT_2) { |
| 1567 | ha->fw_options[1] |= FO1_SET_EMPHASIS_SWING; |
| 1568 | |
| 1569 | /* 1G settings */ |
| 1570 | swing = ha->fw_seriallink_options[2] & (BIT_2 | BIT_1 | BIT_0); |
| 1571 | emphasis = (ha->fw_seriallink_options[2] & |
| 1572 | (BIT_4 | BIT_3)) >> 3; |
| 1573 | tx_sens = ha->fw_seriallink_options[0] & |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1574 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1575 | rx_sens = (ha->fw_seriallink_options[0] & |
| 1576 | (BIT_7 | BIT_6 | BIT_5 | BIT_4)) >> 4; |
| 1577 | ha->fw_options[10] = (emphasis << 14) | (swing << 8); |
| 1578 | if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
| 1579 | if (rx_sens == 0x0) |
| 1580 | rx_sens = 0x3; |
| 1581 | ha->fw_options[10] |= (tx_sens << 4) | rx_sens; |
| 1582 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 1583 | ha->fw_options[10] |= BIT_5 | |
| 1584 | ((rx_sens & (BIT_1 | BIT_0)) << 2) | |
| 1585 | (tx_sens & (BIT_1 | BIT_0)); |
| 1586 | |
| 1587 | /* 2G settings */ |
| 1588 | swing = (ha->fw_seriallink_options[2] & |
| 1589 | (BIT_7 | BIT_6 | BIT_5)) >> 5; |
| 1590 | emphasis = ha->fw_seriallink_options[3] & (BIT_1 | BIT_0); |
| 1591 | tx_sens = ha->fw_seriallink_options[1] & |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1592 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1593 | rx_sens = (ha->fw_seriallink_options[1] & |
| 1594 | (BIT_7 | BIT_6 | BIT_5 | BIT_4)) >> 4; |
| 1595 | ha->fw_options[11] = (emphasis << 14) | (swing << 8); |
| 1596 | if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
| 1597 | if (rx_sens == 0x0) |
| 1598 | rx_sens = 0x3; |
| 1599 | ha->fw_options[11] |= (tx_sens << 4) | rx_sens; |
| 1600 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 1601 | ha->fw_options[11] |= BIT_5 | |
| 1602 | ((rx_sens & (BIT_1 | BIT_0)) << 2) | |
| 1603 | (tx_sens & (BIT_1 | BIT_0)); |
| 1604 | } |
| 1605 | |
| 1606 | /* FCP2 options. */ |
| 1607 | /* Return command IOCBs without waiting for an ABTS to complete. */ |
| 1608 | ha->fw_options[3] |= BIT_13; |
| 1609 | |
| 1610 | /* LED scheme. */ |
| 1611 | if (ha->flags.enable_led_scheme) |
| 1612 | ha->fw_options[2] |= BIT_12; |
| 1613 | |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 1614 | /* Detect ISP6312. */ |
| 1615 | if (IS_QLA6312(ha)) |
| 1616 | ha->fw_options[2] |= BIT_13; |
| 1617 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1618 | /* Update firmware options. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1619 | qla2x00_set_fw_options(vha, ha->fw_options); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1620 | } |
| 1621 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1622 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1623 | qla24xx_update_fw_options(scsi_qla_host_t *vha) |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1624 | { |
| 1625 | int rval; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1626 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1627 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1628 | if (IS_QLA82XX(ha)) |
| 1629 | return; |
| 1630 | |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1631 | /* Update Serial Link options. */ |
andrew.vasquez@qlogic.com | f94097e | 2006-01-13 17:05:32 -0800 | [diff] [blame] | 1632 | if ((le16_to_cpu(ha->fw_seriallink_options24[0]) & BIT_0) == 0) |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1633 | return; |
| 1634 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1635 | rval = qla2x00_set_serdes_params(vha, |
andrew.vasquez@qlogic.com | f94097e | 2006-01-13 17:05:32 -0800 | [diff] [blame] | 1636 | le16_to_cpu(ha->fw_seriallink_options24[1]), |
| 1637 | le16_to_cpu(ha->fw_seriallink_options24[2]), |
| 1638 | le16_to_cpu(ha->fw_seriallink_options24[3])); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1639 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1640 | ql_log(ql_log_warn, vha, 0x0104, |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1641 | "Unable to update Serial Link options (%x).\n", rval); |
| 1642 | } |
| 1643 | } |
| 1644 | |
| 1645 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1646 | qla2x00_config_rings(struct scsi_qla_host *vha) |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1647 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1648 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 1649 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1650 | struct req_que *req = ha->req_q_map[0]; |
| 1651 | struct rsp_que *rsp = ha->rsp_q_map[0]; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1652 | |
| 1653 | /* Setup ring parameters in initialization control block. */ |
| 1654 | ha->init_cb->request_q_outpointer = __constant_cpu_to_le16(0); |
| 1655 | ha->init_cb->response_q_inpointer = __constant_cpu_to_le16(0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1656 | ha->init_cb->request_q_length = cpu_to_le16(req->length); |
| 1657 | ha->init_cb->response_q_length = cpu_to_le16(rsp->length); |
| 1658 | ha->init_cb->request_q_address[0] = cpu_to_le32(LSD(req->dma)); |
| 1659 | ha->init_cb->request_q_address[1] = cpu_to_le32(MSD(req->dma)); |
| 1660 | ha->init_cb->response_q_address[0] = cpu_to_le32(LSD(rsp->dma)); |
| 1661 | 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] | 1662 | |
| 1663 | WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), 0); |
| 1664 | WRT_REG_WORD(ISP_REQ_Q_OUT(ha, reg), 0); |
| 1665 | WRT_REG_WORD(ISP_RSP_Q_IN(ha, reg), 0); |
| 1666 | WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), 0); |
| 1667 | RD_REG_WORD(ISP_RSP_Q_OUT(ha, reg)); /* PCI Posting. */ |
| 1668 | } |
| 1669 | |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1670 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1671 | qla24xx_config_rings(struct scsi_qla_host *vha) |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1672 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1673 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1674 | device_reg_t __iomem *reg = ISP_QUE_REG(ha, 0); |
| 1675 | struct device_reg_2xxx __iomem *ioreg = &ha->iobase->isp; |
| 1676 | struct qla_msix_entry *msix; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1677 | struct init_cb_24xx *icb; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1678 | uint16_t rid = 0; |
| 1679 | struct req_que *req = ha->req_q_map[0]; |
| 1680 | struct rsp_que *rsp = ha->rsp_q_map[0]; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1681 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1682 | /* Setup ring parameters in initialization control block. */ |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1683 | icb = (struct init_cb_24xx *)ha->init_cb; |
| 1684 | icb->request_q_outpointer = __constant_cpu_to_le16(0); |
| 1685 | icb->response_q_inpointer = __constant_cpu_to_le16(0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1686 | icb->request_q_length = cpu_to_le16(req->length); |
| 1687 | icb->response_q_length = cpu_to_le16(rsp->length); |
| 1688 | icb->request_q_address[0] = cpu_to_le32(LSD(req->dma)); |
| 1689 | icb->request_q_address[1] = cpu_to_le32(MSD(req->dma)); |
| 1690 | icb->response_q_address[0] = cpu_to_le32(LSD(rsp->dma)); |
| 1691 | icb->response_q_address[1] = cpu_to_le32(MSD(rsp->dma)); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1692 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1693 | if (ha->mqenable || IS_QLA83XX(ha)) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1694 | icb->qos = __constant_cpu_to_le16(QLA_DEFAULT_QUE_QOS); |
| 1695 | icb->rid = __constant_cpu_to_le16(rid); |
| 1696 | if (ha->flags.msix_enabled) { |
| 1697 | msix = &ha->msix_entries[1]; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1698 | ql_dbg(ql_dbg_init, vha, 0x00fd, |
| 1699 | "Registering vector 0x%x for base que.\n", |
| 1700 | msix->entry); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1701 | icb->msix = cpu_to_le16(msix->entry); |
| 1702 | } |
| 1703 | /* Use alternate PCI bus number */ |
| 1704 | if (MSB(rid)) |
| 1705 | icb->firmware_options_2 |= |
| 1706 | __constant_cpu_to_le32(BIT_19); |
| 1707 | /* Use alternate PCI devfn */ |
| 1708 | if (LSB(rid)) |
| 1709 | icb->firmware_options_2 |= |
| 1710 | __constant_cpu_to_le32(BIT_18); |
| 1711 | |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 1712 | /* Use Disable MSIX Handshake mode for capable adapters */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1713 | if ((ha->fw_attributes & BIT_6) && (IS_MSIX_NACK_CAPABLE(ha)) && |
| 1714 | (ha->flags.msix_enabled)) { |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 1715 | icb->firmware_options_2 &= |
| 1716 | __constant_cpu_to_le32(~BIT_22); |
| 1717 | ha->flags.disable_msix_handshake = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1718 | ql_dbg(ql_dbg_init, vha, 0x00fe, |
| 1719 | "MSIX Handshake Disable Mode turned on.\n"); |
Anirban Chakraborty | 3155754 | 2009-12-02 10:36:55 -0800 | [diff] [blame] | 1720 | } else { |
| 1721 | icb->firmware_options_2 |= |
| 1722 | __constant_cpu_to_le32(BIT_22); |
| 1723 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1724 | icb->firmware_options_2 |= __constant_cpu_to_le32(BIT_23); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1725 | |
| 1726 | WRT_REG_DWORD(®->isp25mq.req_q_in, 0); |
| 1727 | WRT_REG_DWORD(®->isp25mq.req_q_out, 0); |
| 1728 | WRT_REG_DWORD(®->isp25mq.rsp_q_in, 0); |
| 1729 | WRT_REG_DWORD(®->isp25mq.rsp_q_out, 0); |
| 1730 | } else { |
| 1731 | WRT_REG_DWORD(®->isp24.req_q_in, 0); |
| 1732 | WRT_REG_DWORD(®->isp24.req_q_out, 0); |
| 1733 | WRT_REG_DWORD(®->isp24.rsp_q_in, 0); |
| 1734 | WRT_REG_DWORD(®->isp24.rsp_q_out, 0); |
| 1735 | } |
| 1736 | /* PCI posting */ |
| 1737 | RD_REG_DWORD(&ioreg->hccr); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 1738 | } |
| 1739 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1740 | /** |
| 1741 | * qla2x00_init_rings() - Initializes firmware. |
| 1742 | * @ha: HA context |
| 1743 | * |
| 1744 | * Beginning of request ring has initialization control block already built |
| 1745 | * by nvram config routine. |
| 1746 | * |
| 1747 | * Returns 0 on success. |
| 1748 | */ |
| 1749 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1750 | qla2x00_init_rings(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1751 | { |
| 1752 | int rval; |
| 1753 | unsigned long flags = 0; |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1754 | int cnt, que; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1755 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1756 | struct req_que *req; |
| 1757 | struct rsp_que *rsp; |
| 1758 | struct scsi_qla_host *vp; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1759 | struct mid_init_cb_24xx *mid_init_cb = |
| 1760 | (struct mid_init_cb_24xx *) ha->init_cb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1761 | |
| 1762 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1763 | |
| 1764 | /* Clear outstanding commands array. */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1765 | for (que = 0; que < ha->max_req_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1766 | req = ha->req_q_map[que]; |
| 1767 | if (!req) |
| 1768 | continue; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1769 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1770 | req->outstanding_cmds[cnt] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1771 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1772 | req->current_outstanding_cmd = 1; |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1773 | |
| 1774 | /* Initialize firmware. */ |
| 1775 | req->ring_ptr = req->ring; |
| 1776 | req->ring_index = 0; |
| 1777 | req->cnt = req->length; |
| 1778 | } |
| 1779 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1780 | for (que = 0; que < ha->max_rsp_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1781 | rsp = ha->rsp_q_map[que]; |
| 1782 | if (!rsp) |
| 1783 | continue; |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1784 | /* Initialize response queue entries */ |
| 1785 | qla2x00_init_response_q_entries(rsp); |
| 1786 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1787 | |
Dan Carpenter | 542bce1 | 2010-10-15 11:27:38 -0700 | [diff] [blame] | 1788 | spin_lock(&ha->vport_slock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1789 | /* Clear RSCN queue. */ |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1790 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 1791 | vp->rscn_in_ptr = 0; |
| 1792 | vp->rscn_out_ptr = 0; |
| 1793 | } |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 1794 | |
Dan Carpenter | 542bce1 | 2010-10-15 11:27:38 -0700 | [diff] [blame] | 1795 | spin_unlock(&ha->vport_slock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 1796 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1797 | ha->isp_ops->config_rings(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1798 | |
| 1799 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1800 | |
| 1801 | /* Update any ISP specific firmware options before initialization. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1802 | ha->isp_ops->update_fw_options(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1803 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1804 | ql_dbg(ql_dbg_init, vha, 0x00d1, "Issue init firmware.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1805 | |
Lalit Chandivade | 605aa2b | 2009-03-05 11:07:01 -0800 | [diff] [blame] | 1806 | if (ha->flags.npiv_supported) { |
| 1807 | if (ha->operating_mode == LOOP) |
| 1808 | ha->max_npiv_vports = MIN_MULTI_ID_FABRIC - 1; |
Seokmann Ju | c48339d | 2008-01-17 09:02:19 -0800 | [diff] [blame] | 1809 | mid_init_cb->count = cpu_to_le16(ha->max_npiv_vports); |
Lalit Chandivade | 605aa2b | 2009-03-05 11:07:01 -0800 | [diff] [blame] | 1810 | } |
| 1811 | |
Andrew Vasquez | 24a0813 | 2009-03-24 09:08:16 -0700 | [diff] [blame] | 1812 | if (IS_FWI2_CAPABLE(ha)) { |
| 1813 | mid_init_cb->options = __constant_cpu_to_le16(BIT_1); |
| 1814 | mid_init_cb->init_cb.execution_throttle = |
| 1815 | cpu_to_le16(ha->fw_xcb_count); |
| 1816 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1817 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1818 | rval = qla2x00_init_firmware(vha, ha->init_cb_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1819 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1820 | ql_log(ql_log_fatal, vha, 0x00d2, |
| 1821 | "Init Firmware **** FAILED ****.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1822 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1823 | ql_dbg(ql_dbg_init, vha, 0x00d3, |
| 1824 | "Init Firmware -- success.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1825 | } |
| 1826 | |
| 1827 | return (rval); |
| 1828 | } |
| 1829 | |
| 1830 | /** |
| 1831 | * qla2x00_fw_ready() - Waits for firmware ready. |
| 1832 | * @ha: HA context |
| 1833 | * |
| 1834 | * Returns 0 on success. |
| 1835 | */ |
| 1836 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1837 | qla2x00_fw_ready(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1838 | { |
| 1839 | int rval; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1840 | unsigned long wtime, mtime, cs84xx_time; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1841 | uint16_t min_wait; /* Minimum wait time if loop is down */ |
| 1842 | uint16_t wait_time; /* Wait time if loop is coming ready */ |
Andrew Vasquez | 656e891 | 2009-06-03 09:55:29 -0700 | [diff] [blame] | 1843 | uint16_t state[5]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1844 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1845 | |
| 1846 | rval = QLA_SUCCESS; |
| 1847 | |
| 1848 | /* 20 seconds for loop down. */ |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1849 | min_wait = 20; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1850 | |
| 1851 | /* |
| 1852 | * Firmware should take at most one RATOV to login, plus 5 seconds for |
| 1853 | * our own processing. |
| 1854 | */ |
| 1855 | if ((wait_time = (ha->retry_count*ha->login_timeout) + 5) < min_wait) { |
| 1856 | wait_time = min_wait; |
| 1857 | } |
| 1858 | |
| 1859 | /* Min wait time if loop down */ |
| 1860 | mtime = jiffies + (min_wait * HZ); |
| 1861 | |
| 1862 | /* wait time before firmware ready */ |
| 1863 | wtime = jiffies + (wait_time * HZ); |
| 1864 | |
| 1865 | /* Wait for ISP to finish LIP */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1866 | if (!vha->flags.init_done) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1867 | ql_log(ql_log_info, vha, 0x801e, |
| 1868 | "Waiting for LIP to complete.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1869 | |
| 1870 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1871 | rval = qla2x00_get_firmware_state(vha, state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1872 | if (rval == QLA_SUCCESS) { |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1873 | if (state[0] < FSTATE_LOSS_OF_SYNC) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1874 | vha->device_flags &= ~DFLG_NO_CABLE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1875 | } |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1876 | if (IS_QLA84XX(ha) && state[0] != FSTATE_READY) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1877 | ql_dbg(ql_dbg_taskm, vha, 0x801f, |
| 1878 | "fw_state=%x 84xx=%x.\n", state[0], |
| 1879 | state[2]); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1880 | if ((state[2] & FSTATE_LOGGED_IN) && |
| 1881 | (state[2] & FSTATE_WAITING_FOR_VERIFY)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1882 | ql_dbg(ql_dbg_taskm, vha, 0x8028, |
| 1883 | "Sending verify iocb.\n"); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1884 | |
| 1885 | cs84xx_time = jiffies; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1886 | rval = qla84xx_init_chip(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1887 | if (rval != QLA_SUCCESS) { |
| 1888 | ql_log(ql_log_warn, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1889 | vha, 0x8007, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1890 | "Init chip failed.\n"); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1891 | break; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1892 | } |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1893 | |
| 1894 | /* Add time taken to initialize. */ |
| 1895 | cs84xx_time = jiffies - cs84xx_time; |
| 1896 | wtime += cs84xx_time; |
| 1897 | mtime += cs84xx_time; |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1898 | ql_dbg(ql_dbg_taskm, vha, 0x8008, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1899 | "Increasing wait time by %ld. " |
| 1900 | "New time %ld.\n", cs84xx_time, |
| 1901 | wtime); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1902 | } |
| 1903 | } else if (state[0] == FSTATE_READY) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1904 | ql_dbg(ql_dbg_taskm, vha, 0x8037, |
| 1905 | "F/W Ready - OK.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1906 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1907 | qla2x00_get_retry_cnt(vha, &ha->retry_count, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1908 | &ha->login_timeout, &ha->r_a_tov); |
| 1909 | |
| 1910 | rval = QLA_SUCCESS; |
| 1911 | break; |
| 1912 | } |
| 1913 | |
| 1914 | rval = QLA_FUNCTION_FAILED; |
| 1915 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1916 | if (atomic_read(&vha->loop_down_timer) && |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1917 | state[0] != FSTATE_READY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1918 | /* Loop down. Timeout on min_wait for states |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1919 | * other than Wait for Login. |
| 1920 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1921 | if (time_after_eq(jiffies, mtime)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1922 | ql_log(ql_log_info, vha, 0x8038, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1923 | "Cable is unplugged...\n"); |
| 1924 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1925 | vha->device_flags |= DFLG_NO_CABLE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1926 | break; |
| 1927 | } |
| 1928 | } |
| 1929 | } else { |
| 1930 | /* Mailbox cmd failed. Timeout on min_wait. */ |
Santosh Vernekar | cdbb0a4f | 2010-05-28 15:08:25 -0700 | [diff] [blame] | 1931 | if (time_after_eq(jiffies, mtime) || |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 1932 | ha->flags.isp82xx_fw_hung) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1933 | break; |
| 1934 | } |
| 1935 | |
| 1936 | if (time_after_eq(jiffies, wtime)) |
| 1937 | break; |
| 1938 | |
| 1939 | /* Delay for a while */ |
| 1940 | msleep(500); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1941 | } while (1); |
| 1942 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1943 | ql_dbg(ql_dbg_taskm, vha, 0x803a, |
| 1944 | "fw_state=%x (%x, %x, %x, %x) " "curr time=%lx.\n", state[0], |
| 1945 | state[1], state[2], state[3], state[4], jiffies); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1946 | |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1947 | if (rval && !(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1948 | ql_log(ql_log_warn, vha, 0x803b, |
| 1949 | "Firmware ready **** FAILED ****.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1950 | } |
| 1951 | |
| 1952 | return (rval); |
| 1953 | } |
| 1954 | |
| 1955 | /* |
| 1956 | * qla2x00_configure_hba |
| 1957 | * Setup adapter context. |
| 1958 | * |
| 1959 | * Input: |
| 1960 | * ha = adapter state pointer. |
| 1961 | * |
| 1962 | * Returns: |
| 1963 | * 0 = success |
| 1964 | * |
| 1965 | * Context: |
| 1966 | * Kernel context. |
| 1967 | */ |
| 1968 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1969 | qla2x00_configure_hba(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1970 | { |
| 1971 | int rval; |
| 1972 | uint16_t loop_id; |
| 1973 | uint16_t topo; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1974 | uint16_t sw_cap; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1975 | uint8_t al_pa; |
| 1976 | uint8_t area; |
| 1977 | uint8_t domain; |
| 1978 | char connect_type[22]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1979 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1980 | |
| 1981 | /* Get host addresses. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1982 | rval = qla2x00_get_adapter_id(vha, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1983 | &loop_id, &al_pa, &area, &domain, &topo, &sw_cap); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1984 | if (rval != QLA_SUCCESS) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1985 | if (LOOP_TRANSITION(vha) || atomic_read(&ha->loop_down_timer) || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1986 | IS_CNA_CAPABLE(ha) || |
Ravi Anand | 33135aa | 2005-11-08 14:37:20 -0800 | [diff] [blame] | 1987 | (rval == QLA_COMMAND_ERROR && loop_id == 0x7)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1988 | ql_dbg(ql_dbg_disc, vha, 0x2008, |
| 1989 | "Loop is in a transition state.\n"); |
Ravi Anand | 33135aa | 2005-11-08 14:37:20 -0800 | [diff] [blame] | 1990 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1991 | ql_log(ql_log_warn, vha, 0x2009, |
| 1992 | "Unable to get host loop ID.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1993 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Ravi Anand | 33135aa | 2005-11-08 14:37:20 -0800 | [diff] [blame] | 1994 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1995 | return (rval); |
| 1996 | } |
| 1997 | |
| 1998 | if (topo == 4) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1999 | ql_log(ql_log_info, vha, 0x200a, |
| 2000 | "Cannot get topology - retrying.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2001 | return (QLA_FUNCTION_FAILED); |
| 2002 | } |
| 2003 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2004 | vha->loop_id = loop_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2005 | |
| 2006 | /* initialize */ |
| 2007 | ha->min_external_loopid = SNS_FIRST_LOOP_ID; |
| 2008 | ha->operating_mode = LOOP; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2009 | ha->switch_cap = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2010 | |
| 2011 | switch (topo) { |
| 2012 | case 0: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2013 | ql_dbg(ql_dbg_disc, vha, 0x200b, "HBA in NL topology.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2014 | ha->current_topology = ISP_CFG_NL; |
| 2015 | strcpy(connect_type, "(Loop)"); |
| 2016 | break; |
| 2017 | |
| 2018 | case 1: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2019 | ql_dbg(ql_dbg_disc, vha, 0x200c, "HBA in FL topology.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2020 | ha->switch_cap = sw_cap; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2021 | ha->current_topology = ISP_CFG_FL; |
| 2022 | strcpy(connect_type, "(FL_Port)"); |
| 2023 | break; |
| 2024 | |
| 2025 | case 2: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2026 | 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] | 2027 | ha->operating_mode = P2P; |
| 2028 | ha->current_topology = ISP_CFG_N; |
| 2029 | strcpy(connect_type, "(N_Port-to-N_Port)"); |
| 2030 | break; |
| 2031 | |
| 2032 | case 3: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2033 | 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] | 2034 | ha->switch_cap = sw_cap; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2035 | ha->operating_mode = P2P; |
| 2036 | ha->current_topology = ISP_CFG_F; |
| 2037 | strcpy(connect_type, "(F_Port)"); |
| 2038 | break; |
| 2039 | |
| 2040 | default: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2041 | ql_dbg(ql_dbg_disc, vha, 0x200f, |
| 2042 | "HBA in unknown topology %x, using NL.\n", topo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2043 | ha->current_topology = ISP_CFG_NL; |
| 2044 | strcpy(connect_type, "(Loop)"); |
| 2045 | break; |
| 2046 | } |
| 2047 | |
| 2048 | /* Save Host port and loop ID. */ |
| 2049 | /* byte order - Big Endian */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2050 | vha->d_id.b.domain = domain; |
| 2051 | vha->d_id.b.area = area; |
| 2052 | vha->d_id.b.al_pa = al_pa; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2053 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2054 | if (!vha->flags.init_done) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2055 | ql_log(ql_log_info, vha, 0x2010, |
| 2056 | "Topology - %s, Host Loop address 0x%x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2057 | connect_type, vha->loop_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2058 | |
| 2059 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2060 | ql_log(ql_log_warn, vha, 0x2011, |
| 2061 | "%s FAILED\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2062 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2063 | ql_dbg(ql_dbg_disc, vha, 0x2012, |
| 2064 | "%s success\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2065 | } |
| 2066 | |
| 2067 | return(rval); |
| 2068 | } |
| 2069 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2070 | inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2071 | qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len, |
| 2072 | char *def) |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2073 | { |
| 2074 | char *st, *en; |
| 2075 | uint16_t index; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2076 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | ab67114 | 2009-08-25 11:36:17 -0700 | [diff] [blame] | 2077 | int use_tbl = !IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha) && |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2078 | !IS_CNA_CAPABLE(ha) && !IS_QLA2031(ha); |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2079 | |
| 2080 | if (memcmp(model, BINZERO, len) != 0) { |
| 2081 | strncpy(ha->model_number, model, len); |
| 2082 | st = en = ha->model_number; |
| 2083 | en += len - 1; |
| 2084 | while (en > st) { |
| 2085 | if (*en != 0x20 && *en != 0x00) |
| 2086 | break; |
| 2087 | *en-- = '\0'; |
| 2088 | } |
| 2089 | |
| 2090 | index = (ha->pdev->subsystem_device & 0xff); |
Andrew Vasquez | 7d0dba1 | 2009-04-06 22:33:45 -0700 | [diff] [blame] | 2091 | if (use_tbl && |
| 2092 | ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2093 | index < QLA_MODEL_NAMES) |
Joe Carnuccio | 1ee2714 | 2008-07-10 16:55:53 -0700 | [diff] [blame] | 2094 | strncpy(ha->model_desc, |
| 2095 | qla2x00_model_name[index * 2 + 1], |
| 2096 | sizeof(ha->model_desc) - 1); |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2097 | } else { |
| 2098 | index = (ha->pdev->subsystem_device & 0xff); |
Andrew Vasquez | 7d0dba1 | 2009-04-06 22:33:45 -0700 | [diff] [blame] | 2099 | if (use_tbl && |
| 2100 | ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2101 | index < QLA_MODEL_NAMES) { |
| 2102 | strcpy(ha->model_number, |
| 2103 | qla2x00_model_name[index * 2]); |
Joe Carnuccio | 1ee2714 | 2008-07-10 16:55:53 -0700 | [diff] [blame] | 2104 | strncpy(ha->model_desc, |
| 2105 | qla2x00_model_name[index * 2 + 1], |
| 2106 | sizeof(ha->model_desc) - 1); |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2107 | } else { |
| 2108 | strcpy(ha->model_number, def); |
| 2109 | } |
| 2110 | } |
Joe Carnuccio | 1ee2714 | 2008-07-10 16:55:53 -0700 | [diff] [blame] | 2111 | if (IS_FWI2_CAPABLE(ha)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2112 | qla2xxx_get_vpd_field(vha, "\x82", ha->model_desc, |
Joe Carnuccio | 1ee2714 | 2008-07-10 16:55:53 -0700 | [diff] [blame] | 2113 | sizeof(ha->model_desc)); |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2114 | } |
| 2115 | |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2116 | /* On sparc systems, obtain port and node WWN from firmware |
| 2117 | * properties. |
| 2118 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2119 | 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] | 2120 | { |
| 2121 | #ifdef CONFIG_SPARC |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2122 | struct qla_hw_data *ha = vha->hw; |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2123 | struct pci_dev *pdev = ha->pdev; |
David S. Miller | 15576bc | 2007-05-08 00:36:49 -0700 | [diff] [blame] | 2124 | struct device_node *dp = pci_device_to_OF_node(pdev); |
| 2125 | const u8 *val; |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2126 | int len; |
| 2127 | |
| 2128 | val = of_get_property(dp, "port-wwn", &len); |
| 2129 | if (val && len >= WWN_SIZE) |
| 2130 | memcpy(nv->port_name, val, WWN_SIZE); |
| 2131 | |
| 2132 | val = of_get_property(dp, "node-wwn", &len); |
| 2133 | if (val && len >= WWN_SIZE) |
| 2134 | memcpy(nv->node_name, val, WWN_SIZE); |
| 2135 | #endif |
| 2136 | } |
| 2137 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2138 | /* |
| 2139 | * NVRAM configuration for ISP 2xxx |
| 2140 | * |
| 2141 | * Input: |
| 2142 | * ha = adapter block pointer. |
| 2143 | * |
| 2144 | * Output: |
| 2145 | * initialization control block in response_ring |
| 2146 | * host adapters parameters in host adapter block |
| 2147 | * |
| 2148 | * Returns: |
| 2149 | * 0 = success. |
| 2150 | */ |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2151 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2152 | qla2x00_nvram_config(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2153 | { |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2154 | int rval; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2155 | uint8_t chksum = 0; |
| 2156 | uint16_t cnt; |
| 2157 | uint8_t *dptr1, *dptr2; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2158 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2159 | init_cb_t *icb = ha->init_cb; |
Seokmann Ju | 281afe1 | 2007-07-26 13:43:34 -0700 | [diff] [blame] | 2160 | nvram_t *nv = ha->nvram; |
| 2161 | uint8_t *ptr = ha->nvram; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 2162 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2163 | |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2164 | rval = QLA_SUCCESS; |
| 2165 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2166 | /* Determine NVRAM starting address. */ |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2167 | ha->nvram_size = sizeof(nvram_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2168 | ha->nvram_base = 0; |
| 2169 | if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && !IS_QLA2300(ha)) |
| 2170 | if ((RD_REG_WORD(®->ctrl_status) >> 14) == 1) |
| 2171 | ha->nvram_base = 0x80; |
| 2172 | |
| 2173 | /* Get NVRAM data and calculate checksum. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2174 | ha->isp_ops->read_nvram(vha, ptr, ha->nvram_base, ha->nvram_size); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2175 | for (cnt = 0, chksum = 0; cnt < ha->nvram_size; cnt++) |
| 2176 | chksum += *ptr++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2177 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2178 | ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x010f, |
| 2179 | "Contents of NVRAM.\n"); |
| 2180 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0110, |
| 2181 | (uint8_t *)nv, ha->nvram_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2182 | |
| 2183 | /* Bad NVRAM data, set defaults parameters. */ |
| 2184 | if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || |
| 2185 | nv->id[2] != 'P' || nv->id[3] != ' ' || nv->nvram_version < 1) { |
| 2186 | /* Reset NVRAM data. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2187 | ql_log(ql_log_warn, vha, 0x0064, |
| 2188 | "Inconisistent NVRAM " |
| 2189 | "detected: checksum=0x%x id=%c version=0x%x.\n", |
| 2190 | chksum, nv->id[0], nv->nvram_version); |
| 2191 | ql_log(ql_log_warn, vha, 0x0065, |
| 2192 | "Falling back to " |
| 2193 | "functioning (yet invalid -- WWPN) defaults.\n"); |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2194 | |
| 2195 | /* |
| 2196 | * Set default initialization control block. |
| 2197 | */ |
| 2198 | memset(nv, 0, ha->nvram_size); |
| 2199 | nv->parameter_block_version = ICB_VERSION; |
| 2200 | |
| 2201 | if (IS_QLA23XX(ha)) { |
| 2202 | nv->firmware_options[0] = BIT_2 | BIT_1; |
| 2203 | nv->firmware_options[1] = BIT_7 | BIT_5; |
| 2204 | nv->add_firmware_options[0] = BIT_5; |
| 2205 | nv->add_firmware_options[1] = BIT_5 | BIT_4; |
| 2206 | nv->frame_payload_size = __constant_cpu_to_le16(2048); |
| 2207 | nv->special_options[1] = BIT_7; |
| 2208 | } else if (IS_QLA2200(ha)) { |
| 2209 | nv->firmware_options[0] = BIT_2 | BIT_1; |
| 2210 | nv->firmware_options[1] = BIT_7 | BIT_5; |
| 2211 | nv->add_firmware_options[0] = BIT_5; |
| 2212 | nv->add_firmware_options[1] = BIT_5 | BIT_4; |
| 2213 | nv->frame_payload_size = __constant_cpu_to_le16(1024); |
| 2214 | } else if (IS_QLA2100(ha)) { |
| 2215 | nv->firmware_options[0] = BIT_3 | BIT_1; |
| 2216 | nv->firmware_options[1] = BIT_5; |
| 2217 | nv->frame_payload_size = __constant_cpu_to_le16(1024); |
| 2218 | } |
| 2219 | |
| 2220 | nv->max_iocb_allocation = __constant_cpu_to_le16(256); |
| 2221 | nv->execution_throttle = __constant_cpu_to_le16(16); |
| 2222 | nv->retry_count = 8; |
| 2223 | nv->retry_delay = 1; |
| 2224 | |
| 2225 | nv->port_name[0] = 33; |
| 2226 | nv->port_name[3] = 224; |
| 2227 | nv->port_name[4] = 139; |
| 2228 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2229 | qla2xxx_nvram_wwn_from_ofw(vha, nv); |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2230 | |
| 2231 | nv->login_timeout = 4; |
| 2232 | |
| 2233 | /* |
| 2234 | * Set default host adapter parameters |
| 2235 | */ |
| 2236 | nv->host_p[1] = BIT_2; |
| 2237 | nv->reset_delay = 5; |
| 2238 | nv->port_down_retry_count = 8; |
| 2239 | nv->max_luns_per_target = __constant_cpu_to_le16(8); |
| 2240 | nv->link_down_timeout = 60; |
| 2241 | |
| 2242 | rval = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2243 | } |
| 2244 | |
| 2245 | #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) |
| 2246 | /* |
| 2247 | * The SN2 does not provide BIOS emulation which means you can't change |
| 2248 | * potentially bogus BIOS settings. Force the use of default settings |
| 2249 | * for link rate and frame size. Hope that the rest of the settings |
| 2250 | * are valid. |
| 2251 | */ |
| 2252 | if (ia64_platform_is("sn2")) { |
| 2253 | nv->frame_payload_size = __constant_cpu_to_le16(2048); |
| 2254 | if (IS_QLA23XX(ha)) |
| 2255 | nv->special_options[1] = BIT_7; |
| 2256 | } |
| 2257 | #endif |
| 2258 | |
| 2259 | /* Reset Initialization control block */ |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2260 | memset(icb, 0, ha->init_cb_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2261 | |
| 2262 | /* |
| 2263 | * Setup driver NVRAM options. |
| 2264 | */ |
| 2265 | nv->firmware_options[0] |= (BIT_6 | BIT_1); |
| 2266 | nv->firmware_options[0] &= ~(BIT_5 | BIT_4); |
| 2267 | nv->firmware_options[1] |= (BIT_5 | BIT_0); |
| 2268 | nv->firmware_options[1] &= ~BIT_4; |
| 2269 | |
| 2270 | if (IS_QLA23XX(ha)) { |
| 2271 | nv->firmware_options[0] |= BIT_2; |
| 2272 | nv->firmware_options[0] &= ~BIT_3; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 2273 | nv->firmware_options[0] &= ~BIT_6; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2274 | nv->add_firmware_options[1] |= BIT_5 | BIT_4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2275 | |
| 2276 | if (IS_QLA2300(ha)) { |
| 2277 | if (ha->fb_rev == FPM_2310) { |
| 2278 | strcpy(ha->model_number, "QLA2310"); |
| 2279 | } else { |
| 2280 | strcpy(ha->model_number, "QLA2300"); |
| 2281 | } |
| 2282 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2283 | qla2x00_set_model_info(vha, nv->model_number, |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 2284 | sizeof(nv->model_number), "QLA23xx"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2285 | } |
| 2286 | } else if (IS_QLA2200(ha)) { |
| 2287 | nv->firmware_options[0] |= BIT_2; |
| 2288 | /* |
| 2289 | * 'Point-to-point preferred, else loop' is not a safe |
| 2290 | * connection mode setting. |
| 2291 | */ |
| 2292 | if ((nv->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) == |
| 2293 | (BIT_5 | BIT_4)) { |
| 2294 | /* Force 'loop preferred, else point-to-point'. */ |
| 2295 | nv->add_firmware_options[0] &= ~(BIT_6 | BIT_5 | BIT_4); |
| 2296 | nv->add_firmware_options[0] |= BIT_5; |
| 2297 | } |
| 2298 | strcpy(ha->model_number, "QLA22xx"); |
| 2299 | } else /*if (IS_QLA2100(ha))*/ { |
| 2300 | strcpy(ha->model_number, "QLA2100"); |
| 2301 | } |
| 2302 | |
| 2303 | /* |
| 2304 | * Copy over NVRAM RISC parameter block to initialization control block. |
| 2305 | */ |
| 2306 | dptr1 = (uint8_t *)icb; |
| 2307 | dptr2 = (uint8_t *)&nv->parameter_block_version; |
| 2308 | cnt = (uint8_t *)&icb->request_q_outpointer - (uint8_t *)&icb->version; |
| 2309 | while (cnt--) |
| 2310 | *dptr1++ = *dptr2++; |
| 2311 | |
| 2312 | /* Copy 2nd half. */ |
| 2313 | dptr1 = (uint8_t *)icb->add_firmware_options; |
| 2314 | cnt = (uint8_t *)icb->reserved_3 - (uint8_t *)icb->add_firmware_options; |
| 2315 | while (cnt--) |
| 2316 | *dptr1++ = *dptr2++; |
| 2317 | |
Andrew Vasquez | 5341e86 | 2006-05-17 15:09:16 -0700 | [diff] [blame] | 2318 | /* Use alternate WWN? */ |
| 2319 | if (nv->host_p[1] & BIT_7) { |
| 2320 | memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); |
| 2321 | memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); |
| 2322 | } |
| 2323 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2324 | /* Prepare nodename */ |
| 2325 | if ((icb->firmware_options[1] & BIT_6) == 0) { |
| 2326 | /* |
| 2327 | * Firmware will apply the following mask if the nodename was |
| 2328 | * not provided. |
| 2329 | */ |
| 2330 | memcpy(icb->node_name, icb->port_name, WWN_SIZE); |
| 2331 | icb->node_name[0] &= 0xF0; |
| 2332 | } |
| 2333 | |
| 2334 | /* |
| 2335 | * Set host adapter parameters. |
| 2336 | */ |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 2337 | |
| 2338 | /* |
| 2339 | * BIT_7 in the host-parameters section allows for modification to |
| 2340 | * internal driver logging. |
| 2341 | */ |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 2342 | if (nv->host_p[0] & BIT_7) |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 2343 | ql2xextended_error_logging = QL_DBG_DEFAULT1_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2344 | ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0); |
| 2345 | /* Always load RISC code on non ISP2[12]00 chips. */ |
| 2346 | if (!IS_QLA2100(ha) && !IS_QLA2200(ha)) |
| 2347 | ha->flags.disable_risc_code_load = 0; |
| 2348 | ha->flags.enable_lip_reset = ((nv->host_p[1] & BIT_1) ? 1 : 0); |
| 2349 | ha->flags.enable_lip_full_login = ((nv->host_p[1] & BIT_2) ? 1 : 0); |
| 2350 | 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] | 2351 | 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] | 2352 | ha->flags.disable_serdes = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2353 | |
| 2354 | ha->operating_mode = |
| 2355 | (icb->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) >> 4; |
| 2356 | |
| 2357 | memcpy(ha->fw_seriallink_options, nv->seriallink_options, |
| 2358 | sizeof(ha->fw_seriallink_options)); |
| 2359 | |
| 2360 | /* save HBA serial number */ |
| 2361 | ha->serial0 = icb->port_name[5]; |
| 2362 | ha->serial1 = icb->port_name[6]; |
| 2363 | ha->serial2 = icb->port_name[7]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2364 | memcpy(vha->node_name, icb->node_name, WWN_SIZE); |
| 2365 | memcpy(vha->port_name, icb->port_name, WWN_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2366 | |
| 2367 | icb->execution_throttle = __constant_cpu_to_le16(0xFFFF); |
| 2368 | |
| 2369 | ha->retry_count = nv->retry_count; |
| 2370 | |
| 2371 | /* Set minimum login_timeout to 4 seconds. */ |
Andrew Vasquez | 5b91490 | 2010-05-28 15:08:30 -0700 | [diff] [blame] | 2372 | if (nv->login_timeout != ql2xlogintimeout) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2373 | nv->login_timeout = ql2xlogintimeout; |
| 2374 | if (nv->login_timeout < 4) |
| 2375 | nv->login_timeout = 4; |
| 2376 | ha->login_timeout = nv->login_timeout; |
| 2377 | icb->login_timeout = nv->login_timeout; |
| 2378 | |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 2379 | /* Set minimum RATOV to 100 tenths of a second. */ |
| 2380 | ha->r_a_tov = 100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2381 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2382 | ha->loop_reset_delay = nv->reset_delay; |
| 2383 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2384 | /* Link Down Timeout = 0: |
| 2385 | * |
| 2386 | * When Port Down timer expires we will start returning |
| 2387 | * I/O's to OS with "DID_NO_CONNECT". |
| 2388 | * |
| 2389 | * Link Down Timeout != 0: |
| 2390 | * |
| 2391 | * The driver waits for the link to come up after link down |
| 2392 | * before returning I/Os to OS with "DID_NO_CONNECT". |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2393 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2394 | if (nv->link_down_timeout == 0) { |
| 2395 | ha->loop_down_abort_time = |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 2396 | (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2397 | } else { |
| 2398 | ha->link_down_timeout = nv->link_down_timeout; |
| 2399 | ha->loop_down_abort_time = |
| 2400 | (LOOP_DOWN_TIME - ha->link_down_timeout); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2401 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2402 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2403 | /* |
| 2404 | * Need enough time to try and get the port back. |
| 2405 | */ |
| 2406 | ha->port_down_retry_count = nv->port_down_retry_count; |
| 2407 | if (qlport_down_retry) |
| 2408 | ha->port_down_retry_count = qlport_down_retry; |
| 2409 | /* Set login_retry_count */ |
| 2410 | ha->login_retry_count = nv->retry_count; |
| 2411 | if (ha->port_down_retry_count == nv->port_down_retry_count && |
| 2412 | ha->port_down_retry_count > 3) |
| 2413 | ha->login_retry_count = ha->port_down_retry_count; |
| 2414 | else if (ha->port_down_retry_count > (int)ha->login_retry_count) |
| 2415 | ha->login_retry_count = ha->port_down_retry_count; |
| 2416 | if (ql2xloginretrycount) |
| 2417 | ha->login_retry_count = ql2xloginretrycount; |
| 2418 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2419 | icb->lun_enables = __constant_cpu_to_le16(0); |
| 2420 | icb->command_resource_count = 0; |
| 2421 | icb->immediate_notify_resource_count = 0; |
| 2422 | icb->timeout = __constant_cpu_to_le16(0); |
| 2423 | |
| 2424 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
| 2425 | /* Enable RIO */ |
| 2426 | icb->firmware_options[0] &= ~BIT_3; |
| 2427 | icb->add_firmware_options[0] &= |
| 2428 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0); |
| 2429 | icb->add_firmware_options[0] |= BIT_2; |
| 2430 | icb->response_accumulation_timer = 3; |
| 2431 | icb->interrupt_delay_timer = 5; |
| 2432 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2433 | vha->flags.process_response_queue = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2434 | } else { |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 2435 | /* Enable ZIO. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2436 | if (!vha->flags.init_done) { |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 2437 | ha->zio_mode = icb->add_firmware_options[0] & |
| 2438 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
| 2439 | ha->zio_timer = icb->interrupt_delay_timer ? |
| 2440 | icb->interrupt_delay_timer: 2; |
| 2441 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2442 | icb->add_firmware_options[0] &= |
| 2443 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2444 | vha->flags.process_response_queue = 0; |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 2445 | if (ha->zio_mode != QLA_ZIO_DISABLED) { |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2446 | ha->zio_mode = QLA_ZIO_MODE_6; |
| 2447 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2448 | ql_log(ql_log_info, vha, 0x0068, |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 2449 | "ZIO mode %d enabled; timer delay (%d us).\n", |
| 2450 | ha->zio_mode, ha->zio_timer * 100); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2451 | |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 2452 | icb->add_firmware_options[0] |= (uint8_t)ha->zio_mode; |
| 2453 | icb->interrupt_delay_timer = (uint8_t)ha->zio_timer; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2454 | vha->flags.process_response_queue = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2455 | } |
| 2456 | } |
| 2457 | |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2458 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2459 | ql_log(ql_log_warn, vha, 0x0069, |
| 2460 | "NVRAM configuration failed.\n"); |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 2461 | } |
| 2462 | return (rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2463 | } |
| 2464 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 2465 | static void |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 2466 | qla2x00_rport_del(void *data) |
| 2467 | { |
| 2468 | fc_port_t *fcport = data; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2469 | struct fc_rport *rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2470 | unsigned long flags; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 2471 | |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2472 | spin_lock_irqsave(fcport->vha->host->host_lock, flags); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 2473 | rport = fcport->drport ? fcport->drport: fcport->rport; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2474 | fcport->drport = NULL; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2475 | spin_unlock_irqrestore(fcport->vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2476 | if (rport) |
| 2477 | fc_remote_port_delete(rport); |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 2478 | } |
| 2479 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2480 | /** |
| 2481 | * qla2x00_alloc_fcport() - Allocate a generic fcport. |
| 2482 | * @ha: HA context |
| 2483 | * @flags: allocation flags |
| 2484 | * |
| 2485 | * Returns a pointer to the allocated fcport, or NULL, if none available. |
| 2486 | */ |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 2487 | fc_port_t * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2488 | qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2489 | { |
| 2490 | fc_port_t *fcport; |
| 2491 | |
Mariusz Kozlowski | bbfbbbc | 2007-08-11 10:13:24 +0200 | [diff] [blame] | 2492 | fcport = kzalloc(sizeof(fc_port_t), flags); |
| 2493 | if (!fcport) |
| 2494 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2495 | |
| 2496 | /* Setup fcport template structure. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2497 | fcport->vha = vha; |
| 2498 | fcport->vp_idx = vha->vp_idx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2499 | fcport->port_type = FCT_UNKNOWN; |
| 2500 | fcport->loop_id = FC_NO_LOOP_ID; |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 2501 | qla2x00_set_fcport_state(fcport, FCS_UNCONFIGURED); |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2502 | fcport->supported_classes = FC_COS_UNSPECIFIED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2503 | |
Mariusz Kozlowski | bbfbbbc | 2007-08-11 10:13:24 +0200 | [diff] [blame] | 2504 | return fcport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2505 | } |
| 2506 | |
| 2507 | /* |
| 2508 | * qla2x00_configure_loop |
| 2509 | * Updates Fibre Channel Device Database with what is actually on loop. |
| 2510 | * |
| 2511 | * Input: |
| 2512 | * ha = adapter block pointer. |
| 2513 | * |
| 2514 | * Returns: |
| 2515 | * 0 = success. |
| 2516 | * 1 = error. |
| 2517 | * 2 = database was full and device was not configured. |
| 2518 | */ |
| 2519 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2520 | qla2x00_configure_loop(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2521 | { |
| 2522 | int rval; |
| 2523 | unsigned long flags, save_flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2524 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2525 | rval = QLA_SUCCESS; |
| 2526 | |
| 2527 | /* Get Initiator ID */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2528 | if (test_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags)) { |
| 2529 | rval = qla2x00_configure_hba(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2530 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2531 | ql_dbg(ql_dbg_disc, vha, 0x2013, |
| 2532 | "Unable to configure HBA.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2533 | return (rval); |
| 2534 | } |
| 2535 | } |
| 2536 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2537 | save_flags = flags = vha->dpc_flags; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2538 | ql_dbg(ql_dbg_disc, vha, 0x2014, |
| 2539 | "Configure loop -- dpc flags = 0x%lx.\n", flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2540 | |
| 2541 | /* |
| 2542 | * If we have both an RSCN and PORT UPDATE pending then handle them |
| 2543 | * both at the same time. |
| 2544 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2545 | clear_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2546 | clear_bit(RSCN_UPDATE, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2547 | |
Michael Hernandez | 3064ff3 | 2009-12-15 21:29:44 -0800 | [diff] [blame] | 2548 | qla2x00_get_data_rate(vha); |
| 2549 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2550 | /* Determine what we need to do */ |
| 2551 | if (ha->current_topology == ISP_CFG_FL && |
| 2552 | (test_bit(LOCAL_LOOP_UPDATE, &flags))) { |
| 2553 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2554 | vha->flags.rscn_queue_overflow = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2555 | set_bit(RSCN_UPDATE, &flags); |
| 2556 | |
| 2557 | } else if (ha->current_topology == ISP_CFG_F && |
| 2558 | (test_bit(LOCAL_LOOP_UPDATE, &flags))) { |
| 2559 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2560 | vha->flags.rscn_queue_overflow = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2561 | set_bit(RSCN_UPDATE, &flags); |
| 2562 | clear_bit(LOCAL_LOOP_UPDATE, &flags); |
| 2563 | |
Andrew Vasquez | 21333b4 | 2006-05-17 15:09:56 -0700 | [diff] [blame] | 2564 | } else if (ha->current_topology == ISP_CFG_N) { |
| 2565 | clear_bit(RSCN_UPDATE, &flags); |
| 2566 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2567 | } else if (!vha->flags.online || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2568 | (test_bit(ABORT_ISP_ACTIVE, &flags))) { |
| 2569 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2570 | vha->flags.rscn_queue_overflow = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2571 | set_bit(RSCN_UPDATE, &flags); |
| 2572 | set_bit(LOCAL_LOOP_UPDATE, &flags); |
| 2573 | } |
| 2574 | |
| 2575 | if (test_bit(LOCAL_LOOP_UPDATE, &flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2576 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { |
| 2577 | ql_dbg(ql_dbg_disc, vha, 0x2015, |
| 2578 | "Loop resync needed, failing.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2579 | rval = QLA_FUNCTION_FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2580 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2581 | else |
| 2582 | rval = qla2x00_configure_local_loop(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2583 | } |
| 2584 | |
| 2585 | if (rval == QLA_SUCCESS && test_bit(RSCN_UPDATE, &flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2586 | if (LOOP_TRANSITION(vha)) { |
| 2587 | ql_dbg(ql_dbg_disc, vha, 0x201e, |
| 2588 | "Needs RSCN update and loop transition.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2589 | rval = QLA_FUNCTION_FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2590 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2591 | else |
| 2592 | rval = qla2x00_configure_fabric(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2593 | } |
| 2594 | |
| 2595 | if (rval == QLA_SUCCESS) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2596 | if (atomic_read(&vha->loop_down_timer) || |
| 2597 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2598 | rval = QLA_FUNCTION_FAILED; |
| 2599 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2600 | atomic_set(&vha->loop_state, LOOP_READY); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2601 | ql_dbg(ql_dbg_disc, vha, 0x2069, |
| 2602 | "LOOP READY.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2603 | } |
| 2604 | } |
| 2605 | |
| 2606 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2607 | ql_dbg(ql_dbg_disc, vha, 0x206a, |
| 2608 | "%s *** FAILED ***.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2609 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2610 | ql_dbg(ql_dbg_disc, vha, 0x206b, |
| 2611 | "%s: exiting normally.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2612 | } |
| 2613 | |
Bjorn Helgaas | cc3ef7b | 2008-09-11 21:22:51 -0700 | [diff] [blame] | 2614 | /* Restore state if a resync event occurred during processing */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2615 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2616 | if (test_bit(LOCAL_LOOP_UPDATE, &save_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2617 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
Andrew Vasquez | f4658b6 | 2009-06-03 09:55:21 -0700 | [diff] [blame] | 2618 | if (test_bit(RSCN_UPDATE, &save_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2619 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
Giridhar Malavali | 3a6478d | 2010-05-28 15:08:20 -0700 | [diff] [blame] | 2620 | if (!IS_ALOGIO_CAPABLE(ha)) |
| 2621 | vha->flags.rscn_queue_overflow = 1; |
Andrew Vasquez | f4658b6 | 2009-06-03 09:55:21 -0700 | [diff] [blame] | 2622 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2623 | } |
| 2624 | |
| 2625 | return (rval); |
| 2626 | } |
| 2627 | |
| 2628 | |
| 2629 | |
| 2630 | /* |
| 2631 | * qla2x00_configure_local_loop |
| 2632 | * Updates Fibre Channel Device Database with local loop devices. |
| 2633 | * |
| 2634 | * Input: |
| 2635 | * ha = adapter block pointer. |
| 2636 | * |
| 2637 | * Returns: |
| 2638 | * 0 = success. |
| 2639 | */ |
| 2640 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2641 | qla2x00_configure_local_loop(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2642 | { |
| 2643 | int rval, rval2; |
| 2644 | int found_devs; |
| 2645 | int found; |
| 2646 | fc_port_t *fcport, *new_fcport; |
| 2647 | |
| 2648 | uint16_t index; |
| 2649 | uint16_t entries; |
| 2650 | char *id_iter; |
| 2651 | uint16_t loop_id; |
| 2652 | uint8_t domain, area, al_pa; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2653 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2654 | |
| 2655 | found_devs = 0; |
| 2656 | new_fcport = NULL; |
| 2657 | entries = MAX_FIBRE_DEVICES; |
| 2658 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2659 | ql_dbg(ql_dbg_disc, vha, 0x2016, |
| 2660 | "Getting FCAL position map.\n"); |
| 2661 | if (ql2xextended_error_logging & ql_dbg_disc) |
| 2662 | qla2x00_get_fcal_position_map(vha, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2663 | |
| 2664 | /* Get list of logged in devices. */ |
| 2665 | memset(ha->gid_list, 0, GID_LIST_SIZE); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2666 | 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] | 2667 | &entries); |
| 2668 | if (rval != QLA_SUCCESS) |
| 2669 | goto cleanup_allocation; |
| 2670 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2671 | ql_dbg(ql_dbg_disc, vha, 0x2017, |
| 2672 | "Entries in ID list (%d).\n", entries); |
| 2673 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2075, |
| 2674 | (uint8_t *)ha->gid_list, |
| 2675 | entries * sizeof(struct gid_list_info)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2676 | |
| 2677 | /* Allocate temporary fcport for any new fcports discovered. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2678 | new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2679 | if (new_fcport == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2680 | ql_log(ql_log_warn, vha, 0x2018, |
| 2681 | "Memory allocation failed for fcport.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2682 | rval = QLA_MEMORY_ALLOC_FAILED; |
| 2683 | goto cleanup_allocation; |
| 2684 | } |
| 2685 | new_fcport->flags &= ~FCF_FABRIC_DEVICE; |
| 2686 | |
| 2687 | /* |
| 2688 | * Mark local devices that were present with FCF_DEVICE_LOST for now. |
| 2689 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2690 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2691 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
| 2692 | fcport->port_type != FCT_BROADCAST && |
| 2693 | (fcport->flags & FCF_FABRIC_DEVICE) == 0) { |
| 2694 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2695 | ql_dbg(ql_dbg_disc, vha, 0x2019, |
| 2696 | "Marking port lost loop_id=0x%04x.\n", |
| 2697 | fcport->loop_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2698 | |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 2699 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2700 | } |
| 2701 | } |
| 2702 | |
| 2703 | /* Add devices to port list. */ |
| 2704 | id_iter = (char *)ha->gid_list; |
| 2705 | for (index = 0; index < entries; index++) { |
| 2706 | domain = ((struct gid_list_info *)id_iter)->domain; |
| 2707 | area = ((struct gid_list_info *)id_iter)->area; |
| 2708 | al_pa = ((struct gid_list_info *)id_iter)->al_pa; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2709 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2710 | loop_id = (uint16_t) |
| 2711 | ((struct gid_list_info *)id_iter)->loop_id_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2712 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2713 | loop_id = le16_to_cpu( |
| 2714 | ((struct gid_list_info *)id_iter)->loop_id); |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2715 | id_iter += ha->gid_list_info_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2716 | |
| 2717 | /* Bypass reserved domain fields. */ |
| 2718 | if ((domain & 0xf0) == 0xf0) |
| 2719 | continue; |
| 2720 | |
| 2721 | /* Bypass if not same domain and area of adapter. */ |
Andrew Vasquez | f7d289f | 2005-08-26 19:08:40 -0700 | [diff] [blame] | 2722 | if (area && domain && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2723 | (area != vha->d_id.b.area || domain != vha->d_id.b.domain)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2724 | continue; |
| 2725 | |
| 2726 | /* Bypass invalid local loop ID. */ |
| 2727 | if (loop_id > LAST_LOCAL_LOOP_ID) |
| 2728 | continue; |
| 2729 | |
| 2730 | /* Fill in member data. */ |
| 2731 | new_fcport->d_id.b.domain = domain; |
| 2732 | new_fcport->d_id.b.area = area; |
| 2733 | new_fcport->d_id.b.al_pa = al_pa; |
| 2734 | new_fcport->loop_id = loop_id; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2735 | new_fcport->vp_idx = vha->vp_idx; |
| 2736 | rval2 = qla2x00_get_port_database(vha, new_fcport, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2737 | if (rval2 != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2738 | ql_dbg(ql_dbg_disc, vha, 0x201a, |
| 2739 | "Failed to retrieve fcport information " |
| 2740 | "-- get_port_database=%x, loop_id=0x%04x.\n", |
| 2741 | rval2, new_fcport->loop_id); |
| 2742 | ql_dbg(ql_dbg_disc, vha, 0x201b, |
| 2743 | "Scheduling resync.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2744 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2745 | continue; |
| 2746 | } |
| 2747 | |
| 2748 | /* Check for matching device in port list. */ |
| 2749 | found = 0; |
| 2750 | fcport = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2751 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2752 | if (memcmp(new_fcport->port_name, fcport->port_name, |
| 2753 | WWN_SIZE)) |
| 2754 | continue; |
| 2755 | |
Shyam Sundar | ddb9b12 | 2009-03-24 09:08:10 -0700 | [diff] [blame] | 2756 | fcport->flags &= ~FCF_FABRIC_DEVICE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2757 | fcport->loop_id = new_fcport->loop_id; |
| 2758 | fcport->port_type = new_fcport->port_type; |
| 2759 | fcport->d_id.b24 = new_fcport->d_id.b24; |
| 2760 | memcpy(fcport->node_name, new_fcport->node_name, |
| 2761 | WWN_SIZE); |
| 2762 | |
| 2763 | found++; |
| 2764 | break; |
| 2765 | } |
| 2766 | |
| 2767 | if (!found) { |
| 2768 | /* New device, add to fcports list. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2769 | if (vha->vp_idx) { |
| 2770 | new_fcport->vha = vha; |
| 2771 | new_fcport->vp_idx = vha->vp_idx; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2772 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2773 | list_add_tail(&new_fcport->list, &vha->vp_fcports); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2774 | |
| 2775 | /* Allocate a new replacement fcport. */ |
| 2776 | fcport = new_fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2777 | new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2778 | if (new_fcport == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2779 | ql_log(ql_log_warn, vha, 0x201c, |
| 2780 | "Failed to allocate memory for fcport.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2781 | rval = QLA_MEMORY_ALLOC_FAILED; |
| 2782 | goto cleanup_allocation; |
| 2783 | } |
| 2784 | new_fcport->flags &= ~FCF_FABRIC_DEVICE; |
| 2785 | } |
| 2786 | |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2787 | /* Base iIDMA settings on HBA port speed. */ |
Andrew Vasquez | a3cbdfa | 2007-08-13 10:13:18 -0700 | [diff] [blame] | 2788 | fcport->fp_speed = ha->link_data_rate; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2789 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2790 | qla2x00_update_fcport(vha, fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2791 | |
| 2792 | found_devs++; |
| 2793 | } |
| 2794 | |
| 2795 | cleanup_allocation: |
Jesper Juhl | c9475cb | 2005-11-07 01:01:26 -0800 | [diff] [blame] | 2796 | kfree(new_fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2797 | |
| 2798 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2799 | ql_dbg(ql_dbg_disc, vha, 0x201d, |
| 2800 | "Configure local loop error exit: rval=%x.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2801 | } |
| 2802 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2803 | return (rval); |
| 2804 | } |
| 2805 | |
| 2806 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2807 | qla2x00_iidma_fcport(scsi_qla_host_t *vha, fc_port_t *fcport) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2808 | { |
| 2809 | #define LS_UNKNOWN 2 |
Andrew Vasquez | 9f8fdde | 2009-06-03 09:55:22 -0700 | [diff] [blame] | 2810 | static char *link_speeds[] = { "1", "2", "?", "4", "8", "10" }; |
| 2811 | char *link_speed; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2812 | int rval; |
Harish Zunjarrao | 1bb3954 | 2009-06-17 10:30:29 -0700 | [diff] [blame] | 2813 | uint16_t mb[4]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2814 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2815 | |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2816 | if (!IS_IIDMA_CAPABLE(ha)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2817 | return; |
| 2818 | |
Giridhar Malavali | c9afb9a | 2010-09-03 15:20:48 -0700 | [diff] [blame] | 2819 | if (atomic_read(&fcport->state) != FCS_ONLINE) |
| 2820 | return; |
| 2821 | |
Andrew Vasquez | 39bd962 | 2007-09-20 14:07:34 -0700 | [diff] [blame] | 2822 | if (fcport->fp_speed == PORT_SPEED_UNKNOWN || |
| 2823 | fcport->fp_speed > ha->link_data_rate) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2824 | return; |
| 2825 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2826 | rval = qla2x00_set_idma_speed(vha, fcport->loop_id, fcport->fp_speed, |
Andrew Vasquez | a3cbdfa | 2007-08-13 10:13:18 -0700 | [diff] [blame] | 2827 | mb); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2828 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2829 | ql_dbg(ql_dbg_disc, vha, 0x2004, |
| 2830 | "Unable to adjust iIDMA " |
| 2831 | "%02x%02x%02x%02x%02x%02x%02x%02x -- %04x %x %04x " |
| 2832 | "%04x.\n", fcport->port_name[0], fcport->port_name[1], |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2833 | fcport->port_name[2], fcport->port_name[3], |
| 2834 | fcport->port_name[4], fcport->port_name[5], |
| 2835 | fcport->port_name[6], fcport->port_name[7], rval, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2836 | fcport->fp_speed, mb[0], mb[1]); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2837 | } else { |
Andrew Vasquez | 9f8fdde | 2009-06-03 09:55:22 -0700 | [diff] [blame] | 2838 | link_speed = link_speeds[LS_UNKNOWN]; |
| 2839 | if (fcport->fp_speed < 5) |
| 2840 | link_speed = link_speeds[fcport->fp_speed]; |
| 2841 | else if (fcport->fp_speed == 0x13) |
| 2842 | link_speed = link_speeds[5]; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2843 | ql_dbg(ql_dbg_disc, vha, 0x2005, |
| 2844 | "iIDMA adjusted to %s GB/s " |
| 2845 | "on %02x%02x%02x%02x%02x%02x%02x%02x.\n", link_speed, |
| 2846 | fcport->port_name[0], fcport->port_name[1], |
| 2847 | fcport->port_name[2], fcport->port_name[3], |
| 2848 | fcport->port_name[4], fcport->port_name[5], |
| 2849 | fcport->port_name[6], fcport->port_name[7]); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2850 | } |
| 2851 | } |
| 2852 | |
Adrian Bunk | 23be331 | 2006-11-24 02:46:01 +0100 | [diff] [blame] | 2853 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2854 | qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport) |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2855 | { |
| 2856 | struct fc_rport_identifiers rport_ids; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 2857 | struct fc_rport *rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2858 | unsigned long flags; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2859 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 2860 | qla2x00_rport_del(fcport); |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2861 | |
Andrew Vasquez | f8b02a8 | 2005-08-31 15:21:20 -0700 | [diff] [blame] | 2862 | rport_ids.node_name = wwn_to_u64(fcport->node_name); |
| 2863 | rport_ids.port_name = wwn_to_u64(fcport->port_name); |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2864 | rport_ids.port_id = fcport->d_id.b.domain << 16 | |
| 2865 | fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; |
| 2866 | rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2867 | fcport->rport = rport = fc_remote_port_add(vha->host, 0, &rport_ids); |
Andrew Vasquez | 77d7414 | 2005-07-08 18:00:36 -0700 | [diff] [blame] | 2868 | if (!rport) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2869 | ql_log(ql_log_warn, vha, 0x2006, |
| 2870 | "Unable to allocate fc remote port.\n"); |
Andrew Vasquez | 77d7414 | 2005-07-08 18:00:36 -0700 | [diff] [blame] | 2871 | return; |
| 2872 | } |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2873 | spin_lock_irqsave(fcport->vha->host->host_lock, flags); |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 2874 | *((fc_port_t **)rport->dd_data) = fcport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2875 | spin_unlock_irqrestore(fcport->vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2876 | |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 2877 | rport->supported_classes = fcport->supported_classes; |
Andrew Vasquez | 77d7414 | 2005-07-08 18:00:36 -0700 | [diff] [blame] | 2878 | |
| 2879 | rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2880 | if (fcport->port_type == FCT_INITIATOR) |
| 2881 | rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR; |
| 2882 | if (fcport->port_type == FCT_TARGET) |
| 2883 | rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET; |
Andrew Vasquez | 77d7414 | 2005-07-08 18:00:36 -0700 | [diff] [blame] | 2884 | fc_remote_port_rolechg(rport, rport_ids.roles); |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2885 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2886 | |
| 2887 | /* |
Adrian Bunk | 23be331 | 2006-11-24 02:46:01 +0100 | [diff] [blame] | 2888 | * qla2x00_update_fcport |
| 2889 | * Updates device on list. |
| 2890 | * |
| 2891 | * Input: |
| 2892 | * ha = adapter block pointer. |
| 2893 | * fcport = port structure pointer. |
| 2894 | * |
| 2895 | * Return: |
| 2896 | * 0 - Success |
| 2897 | * BIT_0 - error |
| 2898 | * |
| 2899 | * Context: |
| 2900 | * Kernel context. |
| 2901 | */ |
| 2902 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2903 | qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport) |
Adrian Bunk | 23be331 | 2006-11-24 02:46:01 +0100 | [diff] [blame] | 2904 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2905 | fcport->vha = vha; |
Adrian Bunk | 23be331 | 2006-11-24 02:46:01 +0100 | [diff] [blame] | 2906 | fcport->login_retry = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 2907 | fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); |
Adrian Bunk | 23be331 | 2006-11-24 02:46:01 +0100 | [diff] [blame] | 2908 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2909 | qla2x00_iidma_fcport(vha, fcport); |
Madhuranath Iyengar | 21090cb | 2010-12-21 16:00:18 -0800 | [diff] [blame] | 2910 | qla24xx_update_fcport_fcp_prio(vha, fcport); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2911 | qla2x00_reg_remote_port(vha, fcport); |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 2912 | qla2x00_set_fcport_state(fcport, FCS_ONLINE); |
Adrian Bunk | 23be331 | 2006-11-24 02:46:01 +0100 | [diff] [blame] | 2913 | } |
| 2914 | |
| 2915 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2916 | * qla2x00_configure_fabric |
| 2917 | * Setup SNS devices with loop ID's. |
| 2918 | * |
| 2919 | * Input: |
| 2920 | * ha = adapter block pointer. |
| 2921 | * |
| 2922 | * Returns: |
| 2923 | * 0 = success. |
| 2924 | * BIT_0 = error |
| 2925 | */ |
| 2926 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2927 | qla2x00_configure_fabric(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2928 | { |
| 2929 | int rval, rval2; |
| 2930 | fc_port_t *fcport, *fcptemp; |
| 2931 | uint16_t next_loopid; |
| 2932 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2933 | uint16_t loop_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2934 | LIST_HEAD(new_fcports); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2935 | struct qla_hw_data *ha = vha->hw; |
| 2936 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2937 | |
| 2938 | /* If FL port exists, then SNS is present */ |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2939 | if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2940 | loop_id = NPH_F_PORT; |
| 2941 | else |
| 2942 | loop_id = SNS_FL_PORT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2943 | 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] | 2944 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2945 | ql_dbg(ql_dbg_disc, vha, 0x201f, |
| 2946 | "MBX_GET_PORT_NAME failed, No FL Port.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2947 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2948 | vha->device_flags &= ~SWITCH_FOUND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2949 | return (QLA_SUCCESS); |
| 2950 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2951 | vha->device_flags |= SWITCH_FOUND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2952 | |
| 2953 | /* Mark devices that need re-synchronization. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2954 | rval2 = qla2x00_device_resync(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2955 | if (rval2 == QLA_RSCNS_HANDLED) { |
| 2956 | /* No point doing the scan, just continue. */ |
| 2957 | return (QLA_SUCCESS); |
| 2958 | } |
| 2959 | do { |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2960 | /* FDMI support. */ |
| 2961 | if (ql2xfdmienable && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2962 | test_and_clear_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags)) |
| 2963 | qla2x00_fdmi_register(vha); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2964 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2965 | /* Ensure we are logged into the SNS. */ |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2966 | if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 2967 | loop_id = NPH_SNS; |
| 2968 | else |
| 2969 | loop_id = SIMPLE_NAME_SERVER; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2970 | ha->isp_ops->fabric_login(vha, loop_id, 0xff, 0xff, |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2971 | 0xfc, mb, BIT_1 | BIT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2972 | if (mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2973 | ql_dbg(ql_dbg_disc, vha, 0x2042, |
| 2974 | "Failed SNS login: loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x " |
| 2975 | "mb[6]=%x mb[7]=%x.\n", loop_id, mb[0], mb[1], |
| 2976 | mb[2], mb[6], mb[7]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2977 | return (QLA_SUCCESS); |
| 2978 | } |
| 2979 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2980 | if (test_and_clear_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags)) { |
| 2981 | if (qla2x00_rft_id(vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2982 | /* EMPTY */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2983 | ql_dbg(ql_dbg_disc, vha, 0x2045, |
| 2984 | "Register FC-4 TYPE failed.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2985 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2986 | if (qla2x00_rff_id(vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2987 | /* EMPTY */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2988 | ql_dbg(ql_dbg_disc, vha, 0x2049, |
| 2989 | "Register FC-4 Features failed.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2990 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2991 | if (qla2x00_rnn_id(vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2992 | /* EMPTY */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2993 | ql_dbg(ql_dbg_disc, vha, 0x204f, |
| 2994 | "Register Node Name failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2995 | } else if (qla2x00_rsnn_nn(vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2996 | /* EMPTY */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2997 | ql_dbg(ql_dbg_disc, vha, 0x2053, |
| 2998 | "Register Symobilic Node Name failed.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2999 | } |
| 3000 | } |
| 3001 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3002 | rval = qla2x00_find_all_fabric_devs(vha, &new_fcports); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3003 | if (rval != QLA_SUCCESS) |
| 3004 | break; |
| 3005 | |
| 3006 | /* |
| 3007 | * Logout all previous fabric devices marked lost, except |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3008 | * FCP2 devices. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3009 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3010 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 3011 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3012 | break; |
| 3013 | |
| 3014 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) |
| 3015 | continue; |
| 3016 | |
| 3017 | if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3018 | qla2x00_mark_device_lost(vha, fcport, |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3019 | ql2xplogiabsentdevice, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3020 | if (fcport->loop_id != FC_NO_LOOP_ID && |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3021 | (fcport->flags & FCF_FCP2_DEVICE) == 0 && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3022 | fcport->port_type != FCT_INITIATOR && |
| 3023 | fcport->port_type != FCT_BROADCAST) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3024 | ha->isp_ops->fabric_logout(vha, |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3025 | fcport->loop_id, |
| 3026 | fcport->d_id.b.domain, |
| 3027 | fcport->d_id.b.area, |
| 3028 | fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3029 | fcport->loop_id = FC_NO_LOOP_ID; |
| 3030 | } |
| 3031 | } |
| 3032 | } |
| 3033 | |
| 3034 | /* Starting free loop ID. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3035 | next_loopid = ha->min_external_loopid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3036 | |
| 3037 | /* |
| 3038 | * Scan through our port list and login entries that need to be |
| 3039 | * logged in. |
| 3040 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3041 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 3042 | if (atomic_read(&vha->loop_down_timer) || |
| 3043 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3044 | break; |
| 3045 | |
| 3046 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0 || |
| 3047 | (fcport->flags & FCF_LOGIN_NEEDED) == 0) |
| 3048 | continue; |
| 3049 | |
| 3050 | if (fcport->loop_id == FC_NO_LOOP_ID) { |
| 3051 | fcport->loop_id = next_loopid; |
Seokmann Ju | d4486fd6 | 2008-04-03 13:13:28 -0700 | [diff] [blame] | 3052 | rval = qla2x00_find_new_loop_id( |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3053 | base_vha, fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3054 | if (rval != QLA_SUCCESS) { |
| 3055 | /* Ran out of IDs to use */ |
| 3056 | break; |
| 3057 | } |
| 3058 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3059 | /* Login and update database */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3060 | qla2x00_fabric_dev_login(vha, fcport, &next_loopid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3061 | } |
| 3062 | |
| 3063 | /* Exit if out of loop IDs. */ |
| 3064 | if (rval != QLA_SUCCESS) { |
| 3065 | break; |
| 3066 | } |
| 3067 | |
| 3068 | /* |
| 3069 | * Login and add the new devices to our port list. |
| 3070 | */ |
| 3071 | list_for_each_entry_safe(fcport, fcptemp, &new_fcports, list) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3072 | if (atomic_read(&vha->loop_down_timer) || |
| 3073 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3074 | break; |
| 3075 | |
| 3076 | /* Find a new loop ID to use. */ |
| 3077 | fcport->loop_id = next_loopid; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3078 | rval = qla2x00_find_new_loop_id(base_vha, fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3079 | if (rval != QLA_SUCCESS) { |
| 3080 | /* Ran out of IDs to use */ |
| 3081 | break; |
| 3082 | } |
| 3083 | |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 3084 | /* Login and update database */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3085 | qla2x00_fabric_dev_login(vha, fcport, &next_loopid); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3086 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3087 | if (vha->vp_idx) { |
| 3088 | fcport->vha = vha; |
| 3089 | fcport->vp_idx = vha->vp_idx; |
| 3090 | } |
| 3091 | list_move_tail(&fcport->list, &vha->vp_fcports); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3092 | } |
| 3093 | } while (0); |
| 3094 | |
| 3095 | /* Free all new device structures not processed. */ |
| 3096 | list_for_each_entry_safe(fcport, fcptemp, &new_fcports, list) { |
| 3097 | list_del(&fcport->list); |
| 3098 | kfree(fcport); |
| 3099 | } |
| 3100 | |
| 3101 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3102 | ql_dbg(ql_dbg_disc, vha, 0x2068, |
| 3103 | "Configure fabric error exit rval=%d.\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3104 | } |
| 3105 | |
| 3106 | return (rval); |
| 3107 | } |
| 3108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3109 | /* |
| 3110 | * qla2x00_find_all_fabric_devs |
| 3111 | * |
| 3112 | * Input: |
| 3113 | * ha = adapter block pointer. |
| 3114 | * dev = database device entry pointer. |
| 3115 | * |
| 3116 | * Returns: |
| 3117 | * 0 = success. |
| 3118 | * |
| 3119 | * Context: |
| 3120 | * Kernel context. |
| 3121 | */ |
| 3122 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3123 | qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha, |
| 3124 | struct list_head *new_fcports) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3125 | { |
| 3126 | int rval; |
| 3127 | uint16_t loop_id; |
| 3128 | fc_port_t *fcport, *new_fcport, *fcptemp; |
| 3129 | int found; |
| 3130 | |
| 3131 | sw_info_t *swl; |
| 3132 | int swl_idx; |
| 3133 | int first_dev, last_dev; |
Mike Waychison | 1516ef4 | 2010-05-04 15:01:31 -0700 | [diff] [blame] | 3134 | port_id_t wrap = {}, nxt_d_id; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3135 | struct qla_hw_data *ha = vha->hw; |
| 3136 | struct scsi_qla_host *vp, *base_vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | ee546b6 | 2009-03-05 11:07:02 -0800 | [diff] [blame] | 3137 | struct scsi_qla_host *tvp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3138 | |
| 3139 | rval = QLA_SUCCESS; |
| 3140 | |
| 3141 | /* Try GID_PT to get device list, else GAN. */ |
Andrew Vasquez | 4b89258 | 2008-09-11 21:22:48 -0700 | [diff] [blame] | 3142 | swl = kcalloc(MAX_FIBRE_DEVICES, sizeof(sw_info_t), GFP_KERNEL); |
Mariusz Kozlowski | bbfbbbc | 2007-08-11 10:13:24 +0200 | [diff] [blame] | 3143 | if (!swl) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3144 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3145 | ql_dbg(ql_dbg_disc, vha, 0x2054, |
| 3146 | "GID_PT allocations failed, fallback on GA_NXT.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3147 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3148 | if (qla2x00_gid_pt(vha, swl) != QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3149 | kfree(swl); |
| 3150 | swl = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3151 | } else if (qla2x00_gpn_id(vha, swl) != QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3152 | kfree(swl); |
| 3153 | swl = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3154 | } else if (qla2x00_gnn_id(vha, swl) != QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3155 | kfree(swl); |
| 3156 | swl = NULL; |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 3157 | } else if (ql2xiidmaenable && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3158 | qla2x00_gfpn_id(vha, swl) == QLA_SUCCESS) { |
| 3159 | qla2x00_gpsc(vha, swl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3160 | } |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 3161 | |
| 3162 | /* If other queries succeeded probe for FC-4 type */ |
| 3163 | if (swl) |
| 3164 | qla2x00_gff_id(vha, swl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3165 | } |
| 3166 | swl_idx = 0; |
| 3167 | |
| 3168 | /* Allocate temporary fcport for any new fcports discovered. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3169 | new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3170 | if (new_fcport == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3171 | ql_log(ql_log_warn, vha, 0x205e, |
| 3172 | "Failed to allocate memory for fcport.\n"); |
Jesper Juhl | c9475cb | 2005-11-07 01:01:26 -0800 | [diff] [blame] | 3173 | kfree(swl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3174 | return (QLA_MEMORY_ALLOC_FAILED); |
| 3175 | } |
| 3176 | new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3177 | /* Set start port ID scan at adapter ID. */ |
| 3178 | first_dev = 1; |
| 3179 | last_dev = 0; |
| 3180 | |
| 3181 | /* Starting free loop ID. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3182 | loop_id = ha->min_external_loopid; |
| 3183 | for (; loop_id <= ha->max_loop_id; loop_id++) { |
| 3184 | if (qla2x00_is_reserved_id(vha, loop_id)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3185 | continue; |
| 3186 | |
Giridhar Malavali | 3a6478d | 2010-05-28 15:08:20 -0700 | [diff] [blame] | 3187 | if (ha->current_topology == ISP_CFG_FL && |
| 3188 | (atomic_read(&vha->loop_down_timer) || |
| 3189 | LOOP_TRANSITION(vha))) { |
Andrew Vasquez | bb2d52b | 2010-02-18 10:07:27 -0800 | [diff] [blame] | 3190 | atomic_set(&vha->loop_down_timer, 0); |
| 3191 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 3192 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3193 | break; |
Andrew Vasquez | bb2d52b | 2010-02-18 10:07:27 -0800 | [diff] [blame] | 3194 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3195 | |
| 3196 | if (swl != NULL) { |
| 3197 | if (last_dev) { |
| 3198 | wrap.b24 = new_fcport->d_id.b24; |
| 3199 | } else { |
| 3200 | new_fcport->d_id.b24 = swl[swl_idx].d_id.b24; |
| 3201 | memcpy(new_fcport->node_name, |
| 3202 | swl[swl_idx].node_name, WWN_SIZE); |
| 3203 | memcpy(new_fcport->port_name, |
| 3204 | swl[swl_idx].port_name, WWN_SIZE); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3205 | memcpy(new_fcport->fabric_port_name, |
| 3206 | swl[swl_idx].fabric_port_name, WWN_SIZE); |
| 3207 | new_fcport->fp_speed = swl[swl_idx].fp_speed; |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 3208 | new_fcport->fc4_type = swl[swl_idx].fc4_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3209 | |
| 3210 | if (swl[swl_idx].d_id.b.rsvd_1 != 0) { |
| 3211 | last_dev = 1; |
| 3212 | } |
| 3213 | swl_idx++; |
| 3214 | } |
| 3215 | } else { |
| 3216 | /* Send GA_NXT to the switch */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3217 | rval = qla2x00_ga_nxt(vha, new_fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3218 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3219 | ql_log(ql_log_warn, vha, 0x2064, |
| 3220 | "SNS scan failed -- assuming " |
| 3221 | "zero-entry result.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3222 | list_for_each_entry_safe(fcport, fcptemp, |
| 3223 | new_fcports, list) { |
| 3224 | list_del(&fcport->list); |
| 3225 | kfree(fcport); |
| 3226 | } |
| 3227 | rval = QLA_SUCCESS; |
| 3228 | break; |
| 3229 | } |
| 3230 | } |
| 3231 | |
| 3232 | /* If wrap on switch device list, exit. */ |
| 3233 | if (first_dev) { |
| 3234 | wrap.b24 = new_fcport->d_id.b24; |
| 3235 | first_dev = 0; |
| 3236 | } else if (new_fcport->d_id.b24 == wrap.b24) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3237 | ql_dbg(ql_dbg_disc, vha, 0x2065, |
| 3238 | "Device wrap (%02x%02x%02x).\n", |
| 3239 | new_fcport->d_id.b.domain, |
| 3240 | new_fcport->d_id.b.area, |
| 3241 | new_fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3242 | break; |
| 3243 | } |
| 3244 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3245 | /* Bypass if same physical adapter. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3246 | if (new_fcport->d_id.b24 == base_vha->d_id.b24) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3247 | continue; |
| 3248 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3249 | /* Bypass virtual ports of the same host. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3250 | found = 0; |
| 3251 | if (ha->num_vhosts) { |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3252 | unsigned long flags; |
| 3253 | |
| 3254 | spin_lock_irqsave(&ha->vport_slock, flags); |
Anirban Chakraborty | ee546b6 | 2009-03-05 11:07:02 -0800 | [diff] [blame] | 3255 | list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3256 | if (new_fcport->d_id.b24 == vp->d_id.b24) { |
| 3257 | found = 1; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3258 | break; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3259 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3260 | } |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3261 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3262 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3263 | if (found) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3264 | continue; |
| 3265 | } |
| 3266 | |
Andrew Vasquez | f7d289f | 2005-08-26 19:08:40 -0700 | [diff] [blame] | 3267 | /* Bypass if same domain and area of adapter. */ |
| 3268 | if (((new_fcport->d_id.b24 & 0xffff00) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3269 | (vha->d_id.b24 & 0xffff00)) && ha->current_topology == |
Andrew Vasquez | f7d289f | 2005-08-26 19:08:40 -0700 | [diff] [blame] | 3270 | ISP_CFG_FL) |
| 3271 | continue; |
| 3272 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3273 | /* Bypass reserved domain fields. */ |
| 3274 | if ((new_fcport->d_id.b.domain & 0xf0) == 0xf0) |
| 3275 | continue; |
| 3276 | |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 3277 | /* Bypass ports whose FCP-4 type is not FCP_SCSI */ |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 3278 | if (ql2xgffidenable && |
| 3279 | (new_fcport->fc4_type != FC4_TYPE_FCP_SCSI && |
| 3280 | new_fcport->fc4_type != FC4_TYPE_UNKNOWN)) |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 3281 | continue; |
| 3282 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3283 | /* Locate matching device in database. */ |
| 3284 | found = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3285 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3286 | if (memcmp(new_fcport->port_name, fcport->port_name, |
| 3287 | WWN_SIZE)) |
| 3288 | continue; |
| 3289 | |
| 3290 | found++; |
| 3291 | |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 3292 | /* Update port state. */ |
| 3293 | memcpy(fcport->fabric_port_name, |
| 3294 | new_fcport->fabric_port_name, WWN_SIZE); |
| 3295 | fcport->fp_speed = new_fcport->fp_speed; |
| 3296 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3297 | /* |
| 3298 | * If address the same and state FCS_ONLINE, nothing |
| 3299 | * changed. |
| 3300 | */ |
| 3301 | if (fcport->d_id.b24 == new_fcport->d_id.b24 && |
| 3302 | atomic_read(&fcport->state) == FCS_ONLINE) { |
| 3303 | break; |
| 3304 | } |
| 3305 | |
| 3306 | /* |
| 3307 | * If device was not a fabric device before. |
| 3308 | */ |
| 3309 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) { |
| 3310 | fcport->d_id.b24 = new_fcport->d_id.b24; |
| 3311 | fcport->loop_id = FC_NO_LOOP_ID; |
| 3312 | fcport->flags |= (FCF_FABRIC_DEVICE | |
| 3313 | FCF_LOGIN_NEEDED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3314 | break; |
| 3315 | } |
| 3316 | |
| 3317 | /* |
| 3318 | * Port ID changed or device was marked to be updated; |
| 3319 | * Log it out if still logged in and mark it for |
| 3320 | * relogin later. |
| 3321 | */ |
| 3322 | fcport->d_id.b24 = new_fcport->d_id.b24; |
| 3323 | fcport->flags |= FCF_LOGIN_NEEDED; |
| 3324 | if (fcport->loop_id != FC_NO_LOOP_ID && |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3325 | (fcport->flags & FCF_FCP2_DEVICE) == 0 && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3326 | fcport->port_type != FCT_INITIATOR && |
| 3327 | fcport->port_type != FCT_BROADCAST) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3328 | ha->isp_ops->fabric_logout(vha, fcport->loop_id, |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3329 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 3330 | fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3331 | fcport->loop_id = FC_NO_LOOP_ID; |
| 3332 | } |
| 3333 | |
| 3334 | break; |
| 3335 | } |
| 3336 | |
| 3337 | if (found) |
| 3338 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3339 | /* If device was not in our fcports list, then add it. */ |
| 3340 | list_add_tail(&new_fcport->list, new_fcports); |
| 3341 | |
| 3342 | /* Allocate a new replacement fcport. */ |
| 3343 | nxt_d_id.b24 = new_fcport->d_id.b24; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3344 | new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3345 | if (new_fcport == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3346 | ql_log(ql_log_warn, vha, 0x2066, |
| 3347 | "Memory allocation failed for fcport.\n"); |
Jesper Juhl | c9475cb | 2005-11-07 01:01:26 -0800 | [diff] [blame] | 3348 | kfree(swl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3349 | return (QLA_MEMORY_ALLOC_FAILED); |
| 3350 | } |
| 3351 | new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); |
| 3352 | new_fcport->d_id.b24 = nxt_d_id.b24; |
| 3353 | } |
| 3354 | |
Jesper Juhl | c9475cb | 2005-11-07 01:01:26 -0800 | [diff] [blame] | 3355 | kfree(swl); |
| 3356 | kfree(new_fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3357 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3358 | return (rval); |
| 3359 | } |
| 3360 | |
| 3361 | /* |
| 3362 | * qla2x00_find_new_loop_id |
| 3363 | * Scan through our port list and find a new usable loop ID. |
| 3364 | * |
| 3365 | * Input: |
| 3366 | * ha: adapter state pointer. |
| 3367 | * dev: port structure pointer. |
| 3368 | * |
| 3369 | * Returns: |
| 3370 | * qla2x00 local function return status code. |
| 3371 | * |
| 3372 | * Context: |
| 3373 | * Kernel context. |
| 3374 | */ |
Joe Carnuccio | 03bcfb5 | 2011-03-30 11:46:27 -0700 | [diff] [blame] | 3375 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3376 | 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] | 3377 | { |
| 3378 | int rval; |
| 3379 | int found; |
| 3380 | fc_port_t *fcport; |
| 3381 | uint16_t first_loop_id; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3382 | struct qla_hw_data *ha = vha->hw; |
| 3383 | struct scsi_qla_host *vp; |
Anirban Chakraborty | ee546b6 | 2009-03-05 11:07:02 -0800 | [diff] [blame] | 3384 | struct scsi_qla_host *tvp; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3385 | unsigned long flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3386 | |
| 3387 | rval = QLA_SUCCESS; |
| 3388 | |
| 3389 | /* Save starting loop ID. */ |
| 3390 | first_loop_id = dev->loop_id; |
| 3391 | |
| 3392 | for (;;) { |
| 3393 | /* Skip loop ID if already used by adapter. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3394 | if (dev->loop_id == vha->loop_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3395 | dev->loop_id++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3396 | |
| 3397 | /* Skip reserved loop IDs. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3398 | while (qla2x00_is_reserved_id(vha, dev->loop_id)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3399 | dev->loop_id++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3400 | |
| 3401 | /* Reset loop ID if passed the end. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3402 | if (dev->loop_id > ha->max_loop_id) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3403 | /* first loop ID. */ |
| 3404 | dev->loop_id = ha->min_external_loopid; |
| 3405 | } |
| 3406 | |
| 3407 | /* Check for loop ID being already in use. */ |
| 3408 | found = 0; |
| 3409 | fcport = NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3410 | |
| 3411 | spin_lock_irqsave(&ha->vport_slock, flags); |
Anirban Chakraborty | ee546b6 | 2009-03-05 11:07:02 -0800 | [diff] [blame] | 3412 | list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3413 | list_for_each_entry(fcport, &vp->vp_fcports, list) { |
| 3414 | if (fcport->loop_id == dev->loop_id && |
| 3415 | fcport != dev) { |
| 3416 | /* ID possibly in use */ |
| 3417 | found++; |
| 3418 | break; |
| 3419 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3420 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3421 | if (found) |
| 3422 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3423 | } |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3424 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3425 | |
| 3426 | /* If not in use then it is free to use. */ |
| 3427 | if (!found) { |
| 3428 | break; |
| 3429 | } |
| 3430 | |
| 3431 | /* ID in use. Try next value. */ |
| 3432 | dev->loop_id++; |
| 3433 | |
| 3434 | /* If wrap around. No free ID to use. */ |
| 3435 | if (dev->loop_id == first_loop_id) { |
| 3436 | dev->loop_id = FC_NO_LOOP_ID; |
| 3437 | rval = QLA_FUNCTION_FAILED; |
| 3438 | break; |
| 3439 | } |
| 3440 | } |
| 3441 | |
| 3442 | return (rval); |
| 3443 | } |
| 3444 | |
| 3445 | /* |
| 3446 | * qla2x00_device_resync |
| 3447 | * Marks devices in the database that needs resynchronization. |
| 3448 | * |
| 3449 | * Input: |
| 3450 | * ha = adapter block pointer. |
| 3451 | * |
| 3452 | * Context: |
| 3453 | * Kernel context. |
| 3454 | */ |
| 3455 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3456 | qla2x00_device_resync(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3457 | { |
| 3458 | int rval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3459 | uint32_t mask; |
| 3460 | fc_port_t *fcport; |
| 3461 | uint32_t rscn_entry; |
| 3462 | uint8_t rscn_out_iter; |
| 3463 | uint8_t format; |
Mike Waychison | 1516ef4 | 2010-05-04 15:01:31 -0700 | [diff] [blame] | 3464 | port_id_t d_id = {}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3465 | |
| 3466 | rval = QLA_RSCNS_HANDLED; |
| 3467 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3468 | while (vha->rscn_out_ptr != vha->rscn_in_ptr || |
| 3469 | vha->flags.rscn_queue_overflow) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3470 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3471 | rscn_entry = vha->rscn_queue[vha->rscn_out_ptr]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3472 | format = MSB(MSW(rscn_entry)); |
| 3473 | d_id.b.domain = LSB(MSW(rscn_entry)); |
| 3474 | d_id.b.area = MSB(LSW(rscn_entry)); |
| 3475 | d_id.b.al_pa = LSB(LSW(rscn_entry)); |
| 3476 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3477 | ql_dbg(ql_dbg_disc, vha, 0x2020, |
| 3478 | "RSCN queue entry[%d] = [%02x/%02x%02x%02x].\n", |
| 3479 | vha->rscn_out_ptr, format, d_id.b.domain, d_id.b.area, |
| 3480 | d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3481 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3482 | vha->rscn_out_ptr++; |
| 3483 | if (vha->rscn_out_ptr == MAX_RSCN_COUNT) |
| 3484 | vha->rscn_out_ptr = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3485 | |
| 3486 | /* Skip duplicate entries. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3487 | for (rscn_out_iter = vha->rscn_out_ptr; |
| 3488 | !vha->flags.rscn_queue_overflow && |
| 3489 | rscn_out_iter != vha->rscn_in_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3490 | rscn_out_iter = (rscn_out_iter == |
| 3491 | (MAX_RSCN_COUNT - 1)) ? 0: rscn_out_iter + 1) { |
| 3492 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3493 | if (rscn_entry != vha->rscn_queue[rscn_out_iter]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3494 | break; |
| 3495 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3496 | ql_dbg(ql_dbg_disc, vha, 0x2021, |
| 3497 | "Skipping duplicate RSCN queue entry found at " |
| 3498 | "[%d].\n", rscn_out_iter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3499 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3500 | vha->rscn_out_ptr = rscn_out_iter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3501 | } |
| 3502 | |
| 3503 | /* Queue overflow, set switch default case. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3504 | if (vha->flags.rscn_queue_overflow) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3505 | ql_dbg(ql_dbg_disc, vha, 0x2022, |
| 3506 | "device_resync: rscn overflow.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3507 | |
| 3508 | format = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3509 | vha->flags.rscn_queue_overflow = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3510 | } |
| 3511 | |
| 3512 | switch (format) { |
| 3513 | case 0: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3514 | mask = 0xffffff; |
| 3515 | break; |
| 3516 | case 1: |
| 3517 | mask = 0xffff00; |
| 3518 | break; |
| 3519 | case 2: |
| 3520 | mask = 0xff0000; |
| 3521 | break; |
| 3522 | default: |
| 3523 | mask = 0x0; |
| 3524 | d_id.b24 = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3525 | vha->rscn_out_ptr = vha->rscn_in_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3526 | break; |
| 3527 | } |
| 3528 | |
| 3529 | rval = QLA_SUCCESS; |
| 3530 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3531 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3532 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0 || |
| 3533 | (fcport->d_id.b24 & mask) != d_id.b24 || |
| 3534 | fcport->port_type == FCT_BROADCAST) |
| 3535 | continue; |
| 3536 | |
| 3537 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
| 3538 | if (format != 3 || |
| 3539 | fcport->port_type != FCT_INITIATOR) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3540 | qla2x00_mark_device_lost(vha, fcport, |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3541 | 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3542 | } |
| 3543 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3544 | } |
| 3545 | } |
| 3546 | return (rval); |
| 3547 | } |
| 3548 | |
| 3549 | /* |
| 3550 | * qla2x00_fabric_dev_login |
| 3551 | * Login fabric target device and update FC port database. |
| 3552 | * |
| 3553 | * Input: |
| 3554 | * ha: adapter state pointer. |
| 3555 | * fcport: port structure list pointer. |
| 3556 | * next_loopid: contains value of a new loop ID that can be used |
| 3557 | * by the next login attempt. |
| 3558 | * |
| 3559 | * Returns: |
| 3560 | * qla2x00 local function return status code. |
| 3561 | * |
| 3562 | * Context: |
| 3563 | * Kernel context. |
| 3564 | */ |
| 3565 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3566 | 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] | 3567 | uint16_t *next_loopid) |
| 3568 | { |
| 3569 | int rval; |
| 3570 | int retry; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 3571 | uint8_t opts; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3572 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3573 | |
| 3574 | rval = QLA_SUCCESS; |
| 3575 | retry = 0; |
| 3576 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3577 | if (IS_ALOGIO_CAPABLE(ha)) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3578 | if (fcport->flags & FCF_ASYNC_SENT) |
| 3579 | return rval; |
| 3580 | fcport->flags |= FCF_ASYNC_SENT; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3581 | rval = qla2x00_post_async_login_work(vha, fcport, NULL); |
| 3582 | if (!rval) |
| 3583 | return rval; |
| 3584 | } |
| 3585 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3586 | fcport->flags &= ~FCF_ASYNC_SENT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3587 | rval = qla2x00_fabric_login(vha, fcport, next_loopid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3588 | if (rval == QLA_SUCCESS) { |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3589 | /* Send an ADISC to FCP2 devices.*/ |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 3590 | opts = 0; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3591 | if (fcport->flags & FCF_FCP2_DEVICE) |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 3592 | opts |= BIT_1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3593 | rval = qla2x00_get_port_database(vha, fcport, opts); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3594 | if (rval != QLA_SUCCESS) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3595 | ha->isp_ops->fabric_logout(vha, fcport->loop_id, |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3596 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 3597 | fcport->d_id.b.al_pa); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3598 | qla2x00_mark_device_lost(vha, fcport, 1, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3599 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3600 | qla2x00_update_fcport(vha, fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3601 | } |
| 3602 | } |
| 3603 | |
| 3604 | return (rval); |
| 3605 | } |
| 3606 | |
| 3607 | /* |
| 3608 | * qla2x00_fabric_login |
| 3609 | * Issue fabric login command. |
| 3610 | * |
| 3611 | * Input: |
| 3612 | * ha = adapter block pointer. |
| 3613 | * device = pointer to FC device type structure. |
| 3614 | * |
| 3615 | * Returns: |
| 3616 | * 0 - Login successfully |
| 3617 | * 1 - Login failed |
| 3618 | * 2 - Initiator device |
| 3619 | * 3 - Fatal error |
| 3620 | */ |
| 3621 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3622 | qla2x00_fabric_login(scsi_qla_host_t *vha, fc_port_t *fcport, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3623 | uint16_t *next_loopid) |
| 3624 | { |
| 3625 | int rval; |
| 3626 | int retry; |
| 3627 | uint16_t tmp_loopid; |
| 3628 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3629 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3630 | |
| 3631 | retry = 0; |
| 3632 | tmp_loopid = 0; |
| 3633 | |
| 3634 | for (;;) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3635 | ql_dbg(ql_dbg_disc, vha, 0x2000, |
| 3636 | "Trying Fabric Login w/loop id 0x%04x for port " |
| 3637 | "%02x%02x%02x.\n", |
| 3638 | fcport->loop_id, fcport->d_id.b.domain, |
| 3639 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3640 | |
| 3641 | /* Login fcport on switch. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3642 | ha->isp_ops->fabric_login(vha, fcport->loop_id, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3643 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 3644 | fcport->d_id.b.al_pa, mb, BIT_0); |
| 3645 | if (mb[0] == MBS_PORT_ID_USED) { |
| 3646 | /* |
| 3647 | * Device has another loop ID. The firmware team |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 3648 | * recommends the driver perform an implicit login with |
| 3649 | * the specified ID again. The ID we just used is save |
| 3650 | * here so we return with an ID that can be tried by |
| 3651 | * the next login. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3652 | */ |
| 3653 | retry++; |
| 3654 | tmp_loopid = fcport->loop_id; |
| 3655 | fcport->loop_id = mb[1]; |
| 3656 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3657 | ql_dbg(ql_dbg_disc, vha, 0x2001, |
| 3658 | "Fabric Login: port in use - next loop " |
| 3659 | "id=0x%04x, port id= %02x%02x%02x.\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3660 | fcport->loop_id, fcport->d_id.b.domain, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3661 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3662 | |
| 3663 | } else if (mb[0] == MBS_COMMAND_COMPLETE) { |
| 3664 | /* |
| 3665 | * Login succeeded. |
| 3666 | */ |
| 3667 | if (retry) { |
| 3668 | /* A retry occurred before. */ |
| 3669 | *next_loopid = tmp_loopid; |
| 3670 | } else { |
| 3671 | /* |
| 3672 | * No retry occurred before. Just increment the |
| 3673 | * ID value for next login. |
| 3674 | */ |
| 3675 | *next_loopid = (fcport->loop_id + 1); |
| 3676 | } |
| 3677 | |
| 3678 | if (mb[1] & BIT_0) { |
| 3679 | fcport->port_type = FCT_INITIATOR; |
| 3680 | } else { |
| 3681 | fcport->port_type = FCT_TARGET; |
| 3682 | if (mb[1] & BIT_1) { |
Santosh Vernekar | 8474f3a | 2009-08-25 11:36:16 -0700 | [diff] [blame] | 3683 | fcport->flags |= FCF_FCP2_DEVICE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3684 | } |
| 3685 | } |
| 3686 | |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 3687 | if (mb[10] & BIT_0) |
| 3688 | fcport->supported_classes |= FC_COS_CLASS2; |
| 3689 | if (mb[10] & BIT_1) |
| 3690 | fcport->supported_classes |= FC_COS_CLASS3; |
| 3691 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3692 | rval = QLA_SUCCESS; |
| 3693 | break; |
| 3694 | } else if (mb[0] == MBS_LOOP_ID_USED) { |
| 3695 | /* |
| 3696 | * Loop ID already used, try next loop ID. |
| 3697 | */ |
| 3698 | fcport->loop_id++; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3699 | rval = qla2x00_find_new_loop_id(vha, fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3700 | if (rval != QLA_SUCCESS) { |
| 3701 | /* Ran out of loop IDs to use */ |
| 3702 | break; |
| 3703 | } |
| 3704 | } else if (mb[0] == MBS_COMMAND_ERROR) { |
| 3705 | /* |
| 3706 | * Firmware possibly timed out during login. If NO |
| 3707 | * retries are left to do then the device is declared |
| 3708 | * dead. |
| 3709 | */ |
| 3710 | *next_loopid = fcport->loop_id; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3711 | ha->isp_ops->fabric_logout(vha, fcport->loop_id, |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3712 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 3713 | fcport->d_id.b.al_pa); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3714 | qla2x00_mark_device_lost(vha, fcport, 1, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3715 | |
| 3716 | rval = 1; |
| 3717 | break; |
| 3718 | } else { |
| 3719 | /* |
| 3720 | * unrecoverable / not handled error |
| 3721 | */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3722 | ql_dbg(ql_dbg_disc, vha, 0x2002, |
| 3723 | "Failed=%x port_id=%02x%02x%02x loop_id=%x " |
| 3724 | "jiffies=%lx.\n", mb[0], fcport->d_id.b.domain, |
| 3725 | fcport->d_id.b.area, fcport->d_id.b.al_pa, |
| 3726 | fcport->loop_id, jiffies); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3727 | |
| 3728 | *next_loopid = fcport->loop_id; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3729 | ha->isp_ops->fabric_logout(vha, fcport->loop_id, |
Andrew Vasquez | 1c7c635 | 2005-07-06 10:30:57 -0700 | [diff] [blame] | 3730 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 3731 | fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3732 | fcport->loop_id = FC_NO_LOOP_ID; |
Andrew Vasquez | 0eedfcf | 2005-10-27 11:09:38 -0700 | [diff] [blame] | 3733 | fcport->login_retry = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3734 | |
| 3735 | rval = 3; |
| 3736 | break; |
| 3737 | } |
| 3738 | } |
| 3739 | |
| 3740 | return (rval); |
| 3741 | } |
| 3742 | |
| 3743 | /* |
| 3744 | * qla2x00_local_device_login |
| 3745 | * Issue local device login command. |
| 3746 | * |
| 3747 | * Input: |
| 3748 | * ha = adapter block pointer. |
| 3749 | * loop_id = loop id of device to login to. |
| 3750 | * |
| 3751 | * Returns (Where's the #define!!!!): |
| 3752 | * 0 - Login successfully |
| 3753 | * 1 - Login failed |
| 3754 | * 3 - Fatal error |
| 3755 | */ |
| 3756 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3757 | 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] | 3758 | { |
| 3759 | int rval; |
| 3760 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
| 3761 | |
| 3762 | memset(mb, 0, sizeof(mb)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3763 | rval = qla2x00_login_local_device(vha, fcport, mb, BIT_0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3764 | if (rval == QLA_SUCCESS) { |
| 3765 | /* Interrogate mailbox registers for any errors */ |
| 3766 | if (mb[0] == MBS_COMMAND_ERROR) |
| 3767 | rval = 1; |
| 3768 | else if (mb[0] == MBS_COMMAND_PARAMETER_ERROR) |
| 3769 | /* device not in PCB table */ |
| 3770 | rval = 3; |
| 3771 | } |
| 3772 | |
| 3773 | return (rval); |
| 3774 | } |
| 3775 | |
| 3776 | /* |
| 3777 | * qla2x00_loop_resync |
| 3778 | * Resync with fibre channel devices. |
| 3779 | * |
| 3780 | * Input: |
| 3781 | * ha = adapter block pointer. |
| 3782 | * |
| 3783 | * Returns: |
| 3784 | * 0 = success |
| 3785 | */ |
| 3786 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3787 | qla2x00_loop_resync(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3788 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3789 | int rval = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3790 | uint32_t wait_time; |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 3791 | struct req_que *req; |
| 3792 | struct rsp_que *rsp; |
| 3793 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 3794 | if (vha->hw->flags.cpu_affinity_enabled) |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 3795 | req = vha->hw->req_q_map[0]; |
| 3796 | else |
| 3797 | req = vha->req; |
| 3798 | rsp = req->rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3799 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3800 | clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
| 3801 | if (vha->flags.online) { |
| 3802 | if (!(rval = qla2x00_fw_ready(vha))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3803 | /* Wait at most MAX_TARGET RSCNs for a stable link. */ |
| 3804 | wait_time = 256; |
| 3805 | do { |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 3806 | /* Issue a marker after FW becomes ready. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3807 | qla2x00_marker(vha, req, rsp, 0, 0, |
| 3808 | MK_SYNC_ALL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3809 | vha->marker_needed = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3810 | |
| 3811 | /* Remap devices on Loop. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3812 | clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3813 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3814 | qla2x00_configure_loop(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3815 | wait_time--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3816 | } while (!atomic_read(&vha->loop_down_timer) && |
| 3817 | !(test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) |
| 3818 | && wait_time && (test_bit(LOOP_RESYNC_NEEDED, |
| 3819 | &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3820 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3821 | } |
| 3822 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3823 | if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3824 | return (QLA_FUNCTION_FAILED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3825 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3826 | if (rval) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3827 | ql_dbg(ql_dbg_disc, vha, 0x206c, |
| 3828 | "%s *** FAILED ***.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3829 | |
| 3830 | return (rval); |
| 3831 | } |
| 3832 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 3833 | /* |
| 3834 | * qla2x00_perform_loop_resync |
| 3835 | * Description: This function will set the appropriate flags and call |
| 3836 | * qla2x00_loop_resync. If successful loop will be resynced |
| 3837 | * Arguments : scsi_qla_host_t pointer |
| 3838 | * returm : Success or Failure |
| 3839 | */ |
| 3840 | |
| 3841 | int qla2x00_perform_loop_resync(scsi_qla_host_t *ha) |
| 3842 | { |
| 3843 | int32_t rval = 0; |
| 3844 | |
| 3845 | if (!test_and_set_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags)) { |
| 3846 | /*Configure the flags so that resync happens properly*/ |
| 3847 | atomic_set(&ha->loop_down_timer, 0); |
| 3848 | if (!(ha->device_flags & DFLG_NO_CABLE)) { |
| 3849 | atomic_set(&ha->loop_state, LOOP_UP); |
| 3850 | set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); |
| 3851 | set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags); |
| 3852 | set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); |
| 3853 | |
| 3854 | rval = qla2x00_loop_resync(ha); |
| 3855 | } else |
| 3856 | atomic_set(&ha->loop_state, LOOP_DEAD); |
| 3857 | |
| 3858 | clear_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags); |
| 3859 | } |
| 3860 | |
| 3861 | return rval; |
| 3862 | } |
| 3863 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3864 | void |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3865 | qla2x00_update_fcports(scsi_qla_host_t *base_vha) |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3866 | { |
| 3867 | fc_port_t *fcport; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3868 | struct scsi_qla_host *vha; |
| 3869 | struct qla_hw_data *ha = base_vha->hw; |
| 3870 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3871 | |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3872 | spin_lock_irqsave(&ha->vport_slock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3873 | /* Go with deferred removal of rport references. */ |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3874 | list_for_each_entry(vha, &base_vha->hw->vp_list, list) { |
| 3875 | atomic_inc(&vha->vref_count); |
| 3876 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Dan Carpenter | 8ae598d | 2010-12-21 16:00:15 -0800 | [diff] [blame] | 3877 | if (fcport->drport && |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3878 | atomic_read(&fcport->state) != FCS_UNCONFIGURED) { |
| 3879 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3880 | |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3881 | qla2x00_rport_del(fcport); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3882 | |
| 3883 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 3884 | } |
| 3885 | } |
| 3886 | atomic_dec(&vha->vref_count); |
| 3887 | } |
| 3888 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3889 | } |
| 3890 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 3891 | /* |
| 3892 | * qla82xx_quiescent_state_cleanup |
| 3893 | * Description: This function will block the new I/Os |
| 3894 | * Its not aborting any I/Os as context |
| 3895 | * is not destroyed during quiescence |
| 3896 | * Arguments: scsi_qla_host_t |
| 3897 | * return : void |
| 3898 | */ |
| 3899 | void |
| 3900 | qla82xx_quiescent_state_cleanup(scsi_qla_host_t *vha) |
| 3901 | { |
| 3902 | struct qla_hw_data *ha = vha->hw; |
| 3903 | struct scsi_qla_host *vp; |
| 3904 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3905 | ql_dbg(ql_dbg_p3p, vha, 0xb002, |
| 3906 | "Performing ISP error recovery - ha=%p.\n", ha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 3907 | |
| 3908 | atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); |
| 3909 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 3910 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 3911 | qla2x00_mark_all_devices_lost(vha, 0); |
| 3912 | list_for_each_entry(vp, &ha->vp_list, list) |
| 3913 | qla2x00_mark_all_devices_lost(vha, 0); |
| 3914 | } else { |
| 3915 | if (!atomic_read(&vha->loop_down_timer)) |
| 3916 | atomic_set(&vha->loop_down_timer, |
| 3917 | LOOP_DOWN_TIME); |
| 3918 | } |
| 3919 | /* Wait for pending cmds to complete */ |
| 3920 | qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST); |
| 3921 | } |
| 3922 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3923 | void |
| 3924 | qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha) |
| 3925 | { |
| 3926 | struct qla_hw_data *ha = vha->hw; |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 3927 | struct scsi_qla_host *vp; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3928 | unsigned long flags; |
Andrew Vasquez | 6aef87b | 2011-02-23 15:27:13 -0800 | [diff] [blame] | 3929 | fc_port_t *fcport; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3930 | |
Saurav Kashyap | e46ef00 | 2011-02-23 15:27:16 -0800 | [diff] [blame] | 3931 | /* For ISP82XX, driver waits for completion of the commands. |
| 3932 | * online flag should be set. |
| 3933 | */ |
| 3934 | if (!IS_QLA82XX(ha)) |
| 3935 | vha->flags.online = 0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3936 | ha->flags.chip_reset_done = 0; |
| 3937 | clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
| 3938 | ha->qla_stats.total_isp_aborts++; |
| 3939 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3940 | ql_log(ql_log_info, vha, 0x00af, |
| 3941 | "Performing ISP error recovery - ha=%p.\n", ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3942 | |
Saurav Kashyap | e46ef00 | 2011-02-23 15:27:16 -0800 | [diff] [blame] | 3943 | /* For ISP82XX, reset_chip is just disabling interrupts. |
| 3944 | * Driver waits for the completion of the commands. |
| 3945 | * the interrupts need to be enabled. |
| 3946 | */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3947 | if (!IS_QLA82XX(ha)) |
| 3948 | ha->isp_ops->reset_chip(vha); |
| 3949 | |
| 3950 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 3951 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
| 3952 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 3953 | qla2x00_mark_all_devices_lost(vha, 0); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3954 | |
| 3955 | spin_lock_irqsave(&ha->vport_slock, flags); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 3956 | list_for_each_entry(vp, &ha->vp_list, list) { |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3957 | atomic_inc(&vp->vref_count); |
| 3958 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3959 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3960 | qla2x00_mark_all_devices_lost(vp, 0); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3961 | |
| 3962 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 3963 | atomic_dec(&vp->vref_count); |
| 3964 | } |
| 3965 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3966 | } else { |
| 3967 | if (!atomic_read(&vha->loop_down_timer)) |
| 3968 | atomic_set(&vha->loop_down_timer, |
| 3969 | LOOP_DOWN_TIME); |
| 3970 | } |
| 3971 | |
Andrew Vasquez | 6aef87b | 2011-02-23 15:27:13 -0800 | [diff] [blame] | 3972 | /* Clear all async request states across all VPs. */ |
| 3973 | list_for_each_entry(fcport, &vha->vp_fcports, list) |
| 3974 | fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); |
| 3975 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 3976 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 3977 | atomic_inc(&vp->vref_count); |
| 3978 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3979 | |
| 3980 | list_for_each_entry(fcport, &vp->vp_fcports, list) |
| 3981 | fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); |
| 3982 | |
| 3983 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 3984 | atomic_dec(&vp->vref_count); |
| 3985 | } |
| 3986 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3987 | |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 3988 | if (!ha->flags.eeh_busy) { |
| 3989 | /* Make sure for ISP 82XX IO DMA is complete */ |
| 3990 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 3991 | qla82xx_chip_reset_cleanup(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3992 | ql_log(ql_log_info, vha, 0x00b4, |
| 3993 | "Done chip reset cleanup.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3994 | |
Saurav Kashyap | e46ef00 | 2011-02-23 15:27:16 -0800 | [diff] [blame] | 3995 | /* Done waiting for pending commands. |
| 3996 | * Reset the online flag. |
| 3997 | */ |
| 3998 | vha->flags.online = 0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3999 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4000 | |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 4001 | /* Requeue all commands in outstanding command list. */ |
| 4002 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
| 4003 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4004 | } |
| 4005 | |
| 4006 | /* |
| 4007 | * qla2x00_abort_isp |
| 4008 | * Resets ISP and aborts all outstanding commands. |
| 4009 | * |
| 4010 | * Input: |
| 4011 | * ha = adapter block pointer. |
| 4012 | * |
| 4013 | * Returns: |
| 4014 | * 0 = success |
| 4015 | */ |
| 4016 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4017 | qla2x00_abort_isp(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4018 | { |
Andrew Vasquez | 476e897 | 2006-08-23 14:54:55 -0700 | [diff] [blame] | 4019 | int rval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4020 | uint8_t status = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4021 | struct qla_hw_data *ha = vha->hw; |
| 4022 | struct scsi_qla_host *vp; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4023 | struct req_que *req = ha->req_q_map[0]; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4024 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4025 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4026 | if (vha->flags.online) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4027 | qla2x00_abort_isp_cleanup(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4028 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4029 | if (unlikely(pci_channel_offline(ha->pdev) && |
| 4030 | ha->flags.pci_channel_io_perm_failure)) { |
| 4031 | clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
| 4032 | status = 0; |
| 4033 | return status; |
| 4034 | } |
| 4035 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4036 | ha->isp_ops->get_flash_version(vha, req->ring); |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 4037 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4038 | ha->isp_ops->nvram_config(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4039 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4040 | if (!qla2x00_restart_isp(vha)) { |
| 4041 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4042 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4043 | if (!atomic_read(&vha->loop_down_timer)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4044 | /* |
| 4045 | * Issue marker command only when we are going |
| 4046 | * to start the I/O . |
| 4047 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4048 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4049 | } |
| 4050 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4051 | vha->flags.online = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4052 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 4053 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4054 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 4055 | ha->isp_abort_cnt = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4056 | clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
Andrew Vasquez | 476e897 | 2006-08-23 14:54:55 -0700 | [diff] [blame] | 4057 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4058 | if (IS_QLA81XX(ha) || IS_QLA8031(ha)) |
| 4059 | qla2x00_get_fw_version(vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 4060 | if (ha->fce) { |
| 4061 | ha->flags.fce_enabled = 1; |
| 4062 | memset(ha->fce, 0, |
| 4063 | fce_calc_size(ha->fce_bufs)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4064 | rval = qla2x00_enable_fce_trace(vha, |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 4065 | ha->fce_dma, ha->fce_bufs, ha->fce_mb, |
| 4066 | &ha->fce_bufs); |
| 4067 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4068 | ql_log(ql_log_warn, vha, 0x8033, |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 4069 | "Unable to reinitialize FCE " |
| 4070 | "(%d).\n", rval); |
| 4071 | ha->flags.fce_enabled = 0; |
| 4072 | } |
| 4073 | } |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 4074 | |
| 4075 | if (ha->eft) { |
| 4076 | memset(ha->eft, 0, EFT_SIZE); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4077 | rval = qla2x00_enable_eft_trace(vha, |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 4078 | ha->eft_dma, EFT_NUM_BUFFERS); |
| 4079 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4080 | ql_log(ql_log_warn, vha, 0x8034, |
Andrew Vasquez | 436a7b1 | 2008-07-10 16:55:54 -0700 | [diff] [blame] | 4081 | "Unable to reinitialize EFT " |
| 4082 | "(%d).\n", rval); |
| 4083 | } |
| 4084 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4085 | } else { /* failed the ISP abort */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4086 | vha->flags.online = 1; |
| 4087 | if (test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4088 | if (ha->isp_abort_cnt == 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4089 | ql_log(ql_log_fatal, vha, 0x8035, |
| 4090 | "ISP error recover failed - " |
| 4091 | "board disabled.\n"); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 4092 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4093 | * The next call disables the board |
| 4094 | * completely. |
| 4095 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4096 | ha->isp_ops->reset_adapter(vha); |
| 4097 | vha->flags.online = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4098 | clear_bit(ISP_ABORT_RETRY, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4099 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4100 | status = 0; |
| 4101 | } else { /* schedule another ISP abort */ |
| 4102 | ha->isp_abort_cnt--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4103 | ql_dbg(ql_dbg_taskm, vha, 0x8020, |
| 4104 | "ISP abort - retry remaining %d.\n", |
| 4105 | ha->isp_abort_cnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4106 | status = 1; |
| 4107 | } |
| 4108 | } else { |
| 4109 | ha->isp_abort_cnt = MAX_RETRIES_OF_ISP_ABORT; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4110 | ql_dbg(ql_dbg_taskm, vha, 0x8021, |
| 4111 | "ISP error recovery - retrying (%d) " |
| 4112 | "more times.\n", ha->isp_abort_cnt); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4113 | set_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4114 | status = 1; |
| 4115 | } |
| 4116 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 4117 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4118 | } |
| 4119 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4120 | if (!status) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4121 | ql_dbg(ql_dbg_taskm, vha, 0x8022, "%s succeeded.\n", __func__); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4122 | |
| 4123 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 4124 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 4125 | if (vp->vp_idx) { |
| 4126 | atomic_inc(&vp->vref_count); |
| 4127 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 4128 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4129 | qla2x00_vp_abort_isp(vp); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4130 | |
| 4131 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 4132 | atomic_dec(&vp->vref_count); |
| 4133 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4134 | } |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4135 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 4136 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4137 | } else { |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 4138 | ql_log(ql_log_warn, vha, 0x8023, "%s **** FAILED ****.\n", |
| 4139 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4140 | } |
| 4141 | |
| 4142 | return(status); |
| 4143 | } |
| 4144 | |
| 4145 | /* |
| 4146 | * qla2x00_restart_isp |
| 4147 | * restarts the ISP after a reset |
| 4148 | * |
| 4149 | * Input: |
| 4150 | * ha = adapter block pointer. |
| 4151 | * |
| 4152 | * Returns: |
| 4153 | * 0 = success |
| 4154 | */ |
| 4155 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4156 | qla2x00_restart_isp(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4157 | { |
Andrew Vasquez | c6b2fca | 2009-03-05 11:07:03 -0800 | [diff] [blame] | 4158 | int status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4159 | uint32_t wait_time; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4160 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4161 | struct req_que *req = ha->req_q_map[0]; |
| 4162 | struct rsp_que *rsp = ha->rsp_q_map[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4163 | |
| 4164 | /* If firmware needs to be loaded */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4165 | if (qla2x00_isp_firmware(vha)) { |
| 4166 | vha->flags.online = 0; |
| 4167 | status = ha->isp_ops->chip_diag(vha); |
| 4168 | if (!status) |
| 4169 | status = qla2x00_setup_chip(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4170 | } |
| 4171 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4172 | if (!status && !(status = qla2x00_init_rings(vha))) { |
| 4173 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 4174 | ha->flags.chip_reset_done = 1; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4175 | /* Initialize the queues in use */ |
| 4176 | qla25xx_init_queues(ha); |
| 4177 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4178 | status = qla2x00_fw_ready(vha); |
| 4179 | if (!status) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4180 | ql_dbg(ql_dbg_taskm, vha, 0x8031, |
| 4181 | "Start configure loop status = %d.\n", status); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4182 | |
| 4183 | /* Issue a marker after FW becomes ready. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4184 | qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4185 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4186 | vha->flags.online = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4187 | /* Wait at most MAX_TARGET RSCNs for a stable link. */ |
| 4188 | wait_time = 256; |
| 4189 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4190 | clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 4191 | qla2x00_configure_loop(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4192 | wait_time--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4193 | } while (!atomic_read(&vha->loop_down_timer) && |
| 4194 | !(test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) |
| 4195 | && wait_time && (test_bit(LOOP_RESYNC_NEEDED, |
| 4196 | &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4197 | } |
| 4198 | |
| 4199 | /* if no cable then assume it's good */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4200 | if ((vha->device_flags & DFLG_NO_CABLE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4201 | status = 0; |
| 4202 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4203 | ql_dbg(ql_dbg_taskm, vha, 0x8032, |
| 4204 | "Configure loop done, status = 0x%x.\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4205 | } |
| 4206 | return (status); |
| 4207 | } |
| 4208 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4209 | static int |
| 4210 | qla25xx_init_queues(struct qla_hw_data *ha) |
| 4211 | { |
| 4212 | struct rsp_que *rsp = NULL; |
| 4213 | struct req_que *req = NULL; |
| 4214 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
| 4215 | int ret = -1; |
| 4216 | int i; |
| 4217 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 4218 | for (i = 1; i < ha->max_rsp_queues; i++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4219 | rsp = ha->rsp_q_map[i]; |
| 4220 | if (rsp) { |
| 4221 | rsp->options &= ~BIT_0; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4222 | ret = qla25xx_init_rsp_que(base_vha, rsp); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4223 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4224 | ql_dbg(ql_dbg_init, base_vha, 0x00ff, |
| 4225 | "%s Rsp que: %d init failed.\n", |
| 4226 | __func__, rsp->id); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4227 | else |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4228 | ql_dbg(ql_dbg_init, base_vha, 0x0100, |
| 4229 | "%s Rsp que: %d inited.\n", |
| 4230 | __func__, rsp->id); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4231 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 4232 | } |
| 4233 | for (i = 1; i < ha->max_req_queues; i++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4234 | req = ha->req_q_map[i]; |
| 4235 | if (req) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 4236 | /* Clear outstanding commands array. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4237 | req->options &= ~BIT_0; |
Anirban Chakraborty | 618a752 | 2009-02-08 20:50:11 -0800 | [diff] [blame] | 4238 | ret = qla25xx_init_req_que(base_vha, req); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4239 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4240 | ql_dbg(ql_dbg_init, base_vha, 0x0101, |
| 4241 | "%s Req que: %d init failed.\n", |
| 4242 | __func__, req->id); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4243 | else |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4244 | ql_dbg(ql_dbg_init, base_vha, 0x0102, |
| 4245 | "%s Req que: %d inited.\n", |
| 4246 | __func__, req->id); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4247 | } |
| 4248 | } |
| 4249 | return ret; |
| 4250 | } |
| 4251 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4252 | /* |
| 4253 | * qla2x00_reset_adapter |
| 4254 | * Reset adapter. |
| 4255 | * |
| 4256 | * Input: |
| 4257 | * ha = adapter block pointer. |
| 4258 | */ |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 4259 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4260 | qla2x00_reset_adapter(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4261 | { |
| 4262 | unsigned long flags = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4263 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 4264 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4265 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4266 | vha->flags.online = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 4267 | ha->isp_ops->disable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4268 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4269 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 4270 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); |
| 4271 | RD_REG_WORD(®->hccr); /* PCI Posting. */ |
| 4272 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
| 4273 | RD_REG_WORD(®->hccr); /* PCI Posting. */ |
| 4274 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 4275 | } |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4276 | |
| 4277 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4278 | qla24xx_reset_adapter(scsi_qla_host_t *vha) |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4279 | { |
| 4280 | unsigned long flags = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4281 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4282 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 4283 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4284 | if (IS_QLA82XX(ha)) |
| 4285 | return; |
| 4286 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4287 | vha->flags.online = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 4288 | ha->isp_ops->disable_intrs(ha); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4289 | |
| 4290 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 4291 | WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_RESET); |
| 4292 | RD_REG_DWORD(®->hccr); |
| 4293 | WRT_REG_DWORD(®->hccr, HCCRX_REL_RISC_PAUSE); |
| 4294 | RD_REG_DWORD(®->hccr); |
| 4295 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 09ff36d | 2009-01-22 09:45:30 -0800 | [diff] [blame] | 4296 | |
| 4297 | if (IS_NOPOLLING_TYPE(ha)) |
| 4298 | ha->isp_ops->enable_intrs(ha); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4299 | } |
| 4300 | |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4301 | /* On sparc systems, obtain port and node WWN from firmware |
| 4302 | * properties. |
| 4303 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4304 | static void qla24xx_nvram_wwn_from_ofw(scsi_qla_host_t *vha, |
| 4305 | struct nvram_24xx *nv) |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4306 | { |
| 4307 | #ifdef CONFIG_SPARC |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4308 | struct qla_hw_data *ha = vha->hw; |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4309 | struct pci_dev *pdev = ha->pdev; |
David S. Miller | 15576bc | 2007-05-08 00:36:49 -0700 | [diff] [blame] | 4310 | struct device_node *dp = pci_device_to_OF_node(pdev); |
| 4311 | const u8 *val; |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4312 | int len; |
| 4313 | |
| 4314 | val = of_get_property(dp, "port-wwn", &len); |
| 4315 | if (val && len >= WWN_SIZE) |
| 4316 | memcpy(nv->port_name, val, WWN_SIZE); |
| 4317 | |
| 4318 | val = of_get_property(dp, "node-wwn", &len); |
| 4319 | if (val && len >= WWN_SIZE) |
| 4320 | memcpy(nv->node_name, val, WWN_SIZE); |
| 4321 | #endif |
| 4322 | } |
| 4323 | |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4324 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4325 | qla24xx_nvram_config(scsi_qla_host_t *vha) |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4326 | { |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4327 | int rval; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4328 | struct init_cb_24xx *icb; |
| 4329 | struct nvram_24xx *nv; |
| 4330 | uint32_t *dptr; |
| 4331 | uint8_t *dptr1, *dptr2; |
| 4332 | uint32_t chksum; |
| 4333 | uint16_t cnt; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4334 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4335 | |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4336 | rval = QLA_SUCCESS; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4337 | icb = (struct init_cb_24xx *)ha->init_cb; |
Seokmann Ju | 281afe1 | 2007-07-26 13:43:34 -0700 | [diff] [blame] | 4338 | nv = ha->nvram; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4339 | |
| 4340 | /* Determine NVRAM starting address. */ |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 4341 | if (ha->flags.port0) { |
| 4342 | ha->nvram_base = FA_NVRAM_FUNC0_ADDR; |
| 4343 | ha->vpd_base = FA_NVRAM_VPD0_ADDR; |
| 4344 | } else { |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4345 | ha->nvram_base = FA_NVRAM_FUNC1_ADDR; |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 4346 | ha->vpd_base = FA_NVRAM_VPD1_ADDR; |
| 4347 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 4348 | ha->nvram_size = sizeof(struct nvram_24xx); |
| 4349 | ha->vpd_size = FA_NVRAM_VPD_SIZE; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4350 | if (IS_QLA82XX(ha)) |
| 4351 | ha->vpd_size = FA_VPD_SIZE_82XX; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4352 | |
Seokmann Ju | 281afe1 | 2007-07-26 13:43:34 -0700 | [diff] [blame] | 4353 | /* Get VPD data into cache */ |
| 4354 | ha->vpd = ha->nvram + VPD_OFFSET; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4355 | ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, |
Seokmann Ju | 281afe1 | 2007-07-26 13:43:34 -0700 | [diff] [blame] | 4356 | ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4); |
| 4357 | |
| 4358 | /* Get NVRAM data into cache and calculate checksum. */ |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4359 | dptr = (uint32_t *)nv; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4360 | ha->isp_ops->read_nvram(vha, (uint8_t *)dptr, ha->nvram_base, |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4361 | ha->nvram_size); |
| 4362 | for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++) |
| 4363 | chksum += le32_to_cpu(*dptr++); |
| 4364 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4365 | ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x006a, |
| 4366 | "Contents of NVRAM\n"); |
| 4367 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x010d, |
| 4368 | (uint8_t *)nv, ha->nvram_size); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4369 | |
| 4370 | /* Bad NVRAM data, set defaults parameters. */ |
| 4371 | if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P' |
| 4372 | || nv->id[3] != ' ' || |
| 4373 | nv->nvram_version < __constant_cpu_to_le16(ICB_VERSION)) { |
| 4374 | /* Reset NVRAM data. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4375 | ql_log(ql_log_warn, vha, 0x006b, |
| 4376 | "Inconisistent NVRAM detected: checksum=0x%x id=%c " |
| 4377 | "version=0x%x.\n", chksum, nv->id[0], nv->nvram_version); |
| 4378 | ql_log(ql_log_warn, vha, 0x006c, |
| 4379 | "Falling back to functioning (yet invalid -- WWPN) " |
| 4380 | "defaults.\n"); |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4381 | |
| 4382 | /* |
| 4383 | * Set default initialization control block. |
| 4384 | */ |
| 4385 | memset(nv, 0, ha->nvram_size); |
| 4386 | nv->nvram_version = __constant_cpu_to_le16(ICB_VERSION); |
| 4387 | nv->version = __constant_cpu_to_le16(ICB_VERSION); |
| 4388 | nv->frame_payload_size = __constant_cpu_to_le16(2048); |
| 4389 | nv->execution_throttle = __constant_cpu_to_le16(0xFFFF); |
| 4390 | nv->exchange_count = __constant_cpu_to_le16(0); |
| 4391 | nv->hard_address = __constant_cpu_to_le16(124); |
| 4392 | nv->port_name[0] = 0x21; |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 4393 | nv->port_name[1] = 0x00 + ha->port_no; |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4394 | nv->port_name[2] = 0x00; |
| 4395 | nv->port_name[3] = 0xe0; |
| 4396 | nv->port_name[4] = 0x8b; |
| 4397 | nv->port_name[5] = 0x1c; |
| 4398 | nv->port_name[6] = 0x55; |
| 4399 | nv->port_name[7] = 0x86; |
| 4400 | nv->node_name[0] = 0x20; |
| 4401 | nv->node_name[1] = 0x00; |
| 4402 | nv->node_name[2] = 0x00; |
| 4403 | nv->node_name[3] = 0xe0; |
| 4404 | nv->node_name[4] = 0x8b; |
| 4405 | nv->node_name[5] = 0x1c; |
| 4406 | nv->node_name[6] = 0x55; |
| 4407 | nv->node_name[7] = 0x86; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4408 | qla24xx_nvram_wwn_from_ofw(vha, nv); |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4409 | nv->login_retry_count = __constant_cpu_to_le16(8); |
| 4410 | nv->interrupt_delay_timer = __constant_cpu_to_le16(0); |
| 4411 | nv->login_timeout = __constant_cpu_to_le16(0); |
| 4412 | nv->firmware_options_1 = |
| 4413 | __constant_cpu_to_le32(BIT_14|BIT_13|BIT_2|BIT_1); |
| 4414 | nv->firmware_options_2 = __constant_cpu_to_le32(2 << 4); |
| 4415 | nv->firmware_options_2 |= __constant_cpu_to_le32(BIT_12); |
| 4416 | nv->firmware_options_3 = __constant_cpu_to_le32(2 << 13); |
| 4417 | nv->host_p = __constant_cpu_to_le32(BIT_11|BIT_10); |
| 4418 | nv->efi_parameters = __constant_cpu_to_le32(0); |
| 4419 | nv->reset_delay = 5; |
| 4420 | nv->max_luns_per_target = __constant_cpu_to_le16(128); |
| 4421 | nv->port_down_retry_count = __constant_cpu_to_le16(30); |
| 4422 | nv->link_down_timeout = __constant_cpu_to_le16(30); |
| 4423 | |
| 4424 | rval = 1; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4425 | } |
| 4426 | |
| 4427 | /* Reset Initialization control block */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4428 | memset(icb, 0, ha->init_cb_size); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4429 | |
| 4430 | /* Copy 1st segment. */ |
| 4431 | dptr1 = (uint8_t *)icb; |
| 4432 | dptr2 = (uint8_t *)&nv->version; |
| 4433 | cnt = (uint8_t *)&icb->response_q_inpointer - (uint8_t *)&icb->version; |
| 4434 | while (cnt--) |
| 4435 | *dptr1++ = *dptr2++; |
| 4436 | |
| 4437 | icb->login_retry_count = nv->login_retry_count; |
Andrew Vasquez | 3ea66e2 | 2006-06-23 16:11:27 -0700 | [diff] [blame] | 4438 | icb->link_down_on_nos = nv->link_down_on_nos; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4439 | |
| 4440 | /* Copy 2nd segment. */ |
| 4441 | dptr1 = (uint8_t *)&icb->interrupt_delay_timer; |
| 4442 | dptr2 = (uint8_t *)&nv->interrupt_delay_timer; |
| 4443 | cnt = (uint8_t *)&icb->reserved_3 - |
| 4444 | (uint8_t *)&icb->interrupt_delay_timer; |
| 4445 | while (cnt--) |
| 4446 | *dptr1++ = *dptr2++; |
| 4447 | |
| 4448 | /* |
| 4449 | * Setup driver NVRAM options. |
| 4450 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4451 | qla2x00_set_model_info(vha, nv->model_name, sizeof(nv->model_name), |
Andrew Vasquez | 9bb9fcf | 2007-01-29 10:22:24 -0800 | [diff] [blame] | 4452 | "QLA2462"); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4453 | |
Andrew Vasquez | 5341e86 | 2006-05-17 15:09:16 -0700 | [diff] [blame] | 4454 | /* Use alternate WWN? */ |
| 4455 | if (nv->host_p & __constant_cpu_to_le32(BIT_15)) { |
| 4456 | memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); |
| 4457 | memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); |
| 4458 | } |
| 4459 | |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4460 | /* Prepare nodename */ |
Andrew Vasquez | fd0e7e4 | 2006-05-17 15:09:11 -0700 | [diff] [blame] | 4461 | if ((icb->firmware_options_1 & __constant_cpu_to_le32(BIT_14)) == 0) { |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4462 | /* |
| 4463 | * Firmware will apply the following mask if the nodename was |
| 4464 | * not provided. |
| 4465 | */ |
| 4466 | memcpy(icb->node_name, icb->port_name, WWN_SIZE); |
| 4467 | icb->node_name[0] &= 0xF0; |
| 4468 | } |
| 4469 | |
| 4470 | /* Set host adapter parameters. */ |
| 4471 | ha->flags.disable_risc_code_load = 0; |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 4472 | ha->flags.enable_lip_reset = 0; |
| 4473 | ha->flags.enable_lip_full_login = |
| 4474 | le32_to_cpu(nv->host_p) & BIT_10 ? 1: 0; |
| 4475 | ha->flags.enable_target_reset = |
| 4476 | le32_to_cpu(nv->host_p) & BIT_11 ? 1: 0; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4477 | ha->flags.enable_led_scheme = 0; |
Andrew Vasquez | d4c760c | 2006-06-23 16:10:39 -0700 | [diff] [blame] | 4478 | ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1: 0; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4479 | |
Andrew Vasquez | fd0e7e4 | 2006-05-17 15:09:11 -0700 | [diff] [blame] | 4480 | ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) & |
| 4481 | (BIT_6 | BIT_5 | BIT_4)) >> 4; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4482 | |
| 4483 | memcpy(ha->fw_seriallink_options24, nv->seriallink_options, |
| 4484 | sizeof(ha->fw_seriallink_options24)); |
| 4485 | |
| 4486 | /* save HBA serial number */ |
| 4487 | ha->serial0 = icb->port_name[5]; |
| 4488 | ha->serial1 = icb->port_name[6]; |
| 4489 | ha->serial2 = icb->port_name[7]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4490 | memcpy(vha->node_name, icb->node_name, WWN_SIZE); |
| 4491 | memcpy(vha->port_name, icb->port_name, WWN_SIZE); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4492 | |
andrew.vasquez@qlogic.com | bc8fb3c | 2006-01-13 17:05:42 -0800 | [diff] [blame] | 4493 | icb->execution_throttle = __constant_cpu_to_le16(0xFFFF); |
| 4494 | |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4495 | ha->retry_count = le16_to_cpu(nv->login_retry_count); |
| 4496 | |
| 4497 | /* Set minimum login_timeout to 4 seconds. */ |
| 4498 | if (le16_to_cpu(nv->login_timeout) < ql2xlogintimeout) |
| 4499 | nv->login_timeout = cpu_to_le16(ql2xlogintimeout); |
| 4500 | if (le16_to_cpu(nv->login_timeout) < 4) |
| 4501 | nv->login_timeout = __constant_cpu_to_le16(4); |
| 4502 | ha->login_timeout = le16_to_cpu(nv->login_timeout); |
Seokmann Ju | c6852c4 | 2008-04-24 15:21:29 -0700 | [diff] [blame] | 4503 | icb->login_timeout = nv->login_timeout; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4504 | |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 4505 | /* Set minimum RATOV to 100 tenths of a second. */ |
| 4506 | ha->r_a_tov = 100; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4507 | |
| 4508 | ha->loop_reset_delay = nv->reset_delay; |
| 4509 | |
| 4510 | /* Link Down Timeout = 0: |
| 4511 | * |
| 4512 | * When Port Down timer expires we will start returning |
| 4513 | * I/O's to OS with "DID_NO_CONNECT". |
| 4514 | * |
| 4515 | * Link Down Timeout != 0: |
| 4516 | * |
| 4517 | * The driver waits for the link to come up after link down |
| 4518 | * before returning I/Os to OS with "DID_NO_CONNECT". |
| 4519 | */ |
| 4520 | if (le16_to_cpu(nv->link_down_timeout) == 0) { |
| 4521 | ha->loop_down_abort_time = |
| 4522 | (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); |
| 4523 | } else { |
| 4524 | ha->link_down_timeout = le16_to_cpu(nv->link_down_timeout); |
| 4525 | ha->loop_down_abort_time = |
| 4526 | (LOOP_DOWN_TIME - ha->link_down_timeout); |
| 4527 | } |
| 4528 | |
| 4529 | /* Need enough time to try and get the port back. */ |
| 4530 | ha->port_down_retry_count = le16_to_cpu(nv->port_down_retry_count); |
| 4531 | if (qlport_down_retry) |
| 4532 | ha->port_down_retry_count = qlport_down_retry; |
| 4533 | |
| 4534 | /* Set login_retry_count */ |
| 4535 | ha->login_retry_count = le16_to_cpu(nv->login_retry_count); |
| 4536 | if (ha->port_down_retry_count == |
| 4537 | le16_to_cpu(nv->port_down_retry_count) && |
| 4538 | ha->port_down_retry_count > 3) |
| 4539 | ha->login_retry_count = ha->port_down_retry_count; |
| 4540 | else if (ha->port_down_retry_count > (int)ha->login_retry_count) |
| 4541 | ha->login_retry_count = ha->port_down_retry_count; |
| 4542 | if (ql2xloginretrycount) |
| 4543 | ha->login_retry_count = ql2xloginretrycount; |
| 4544 | |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 4545 | /* Enable ZIO. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4546 | if (!vha->flags.init_done) { |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 4547 | ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & |
| 4548 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
| 4549 | ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? |
| 4550 | le16_to_cpu(icb->interrupt_delay_timer): 2; |
| 4551 | } |
| 4552 | icb->firmware_options_2 &= __constant_cpu_to_le32( |
| 4553 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4554 | vha->flags.process_response_queue = 0; |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 4555 | if (ha->zio_mode != QLA_ZIO_DISABLED) { |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 4556 | ha->zio_mode = QLA_ZIO_MODE_6; |
| 4557 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4558 | ql_log(ql_log_info, vha, 0x006f, |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 4559 | "ZIO mode %d enabled; timer delay (%d us).\n", |
| 4560 | ha->zio_mode, ha->zio_timer * 100); |
| 4561 | |
| 4562 | icb->firmware_options_2 |= cpu_to_le32( |
| 4563 | (uint32_t)ha->zio_mode); |
| 4564 | icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4565 | vha->flags.process_response_queue = 1; |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 4566 | } |
| 4567 | |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4568 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4569 | ql_log(ql_log_warn, vha, 0x0070, |
| 4570 | "NVRAM configuration failed.\n"); |
David Miller | 4e08df3 | 2007-04-16 12:37:43 -0700 | [diff] [blame] | 4571 | } |
| 4572 | return (rval); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4573 | } |
| 4574 | |
Adrian Bunk | 413975a | 2006-06-30 02:33:06 -0700 | [diff] [blame] | 4575 | static int |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4576 | qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr, |
| 4577 | uint32_t faddr) |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4578 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4579 | int rval = QLA_SUCCESS; |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4580 | int segments, fragment; |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4581 | uint32_t *dcode, dlen; |
| 4582 | uint32_t risc_addr; |
| 4583 | uint32_t risc_size; |
| 4584 | uint32_t i; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4585 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4586 | struct req_que *req = ha->req_q_map[0]; |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4587 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4588 | ql_dbg(ql_dbg_init, vha, 0x008b, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 4589 | "FW: Loading firmware from flash (%x).\n", faddr); |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4590 | |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4591 | rval = QLA_SUCCESS; |
| 4592 | |
| 4593 | segments = FA_RISC_CODE_SEGMENTS; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4594 | dcode = (uint32_t *)req->ring; |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4595 | *srisc_addr = 0; |
| 4596 | |
| 4597 | /* Validate firmware image by checking version. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4598 | qla24xx_read_flash_data(vha, dcode, faddr + 4, 4); |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4599 | for (i = 0; i < 4; i++) |
| 4600 | dcode[i] = be32_to_cpu(dcode[i]); |
| 4601 | if ((dcode[0] == 0xffffffff && dcode[1] == 0xffffffff && |
| 4602 | dcode[2] == 0xffffffff && dcode[3] == 0xffffffff) || |
| 4603 | (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 && |
| 4604 | dcode[3] == 0)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4605 | ql_log(ql_log_fatal, vha, 0x008c, |
| 4606 | "Unable to verify the integrity of flash firmware " |
| 4607 | "image.\n"); |
| 4608 | ql_log(ql_log_fatal, vha, 0x008d, |
| 4609 | "Firmware data: %08x %08x %08x %08x.\n", |
| 4610 | dcode[0], dcode[1], dcode[2], dcode[3]); |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4611 | |
| 4612 | return QLA_FUNCTION_FAILED; |
| 4613 | } |
| 4614 | |
| 4615 | while (segments && rval == QLA_SUCCESS) { |
| 4616 | /* Read segment's load information. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4617 | qla24xx_read_flash_data(vha, dcode, faddr, 4); |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4618 | |
| 4619 | risc_addr = be32_to_cpu(dcode[2]); |
| 4620 | *srisc_addr = *srisc_addr == 0 ? risc_addr : *srisc_addr; |
| 4621 | risc_size = be32_to_cpu(dcode[3]); |
| 4622 | |
| 4623 | fragment = 0; |
| 4624 | while (risc_size > 0 && rval == QLA_SUCCESS) { |
| 4625 | dlen = (uint32_t)(ha->fw_transfer_size >> 2); |
| 4626 | if (dlen > risc_size) |
| 4627 | dlen = risc_size; |
| 4628 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4629 | ql_dbg(ql_dbg_init, vha, 0x008e, |
| 4630 | "Loading risc segment@ risc addr %x " |
| 4631 | "number of dwords 0x%x offset 0x%x.\n", |
| 4632 | risc_addr, dlen, faddr); |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4633 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4634 | qla24xx_read_flash_data(vha, dcode, faddr, dlen); |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4635 | for (i = 0; i < dlen; i++) |
| 4636 | dcode[i] = swab32(dcode[i]); |
| 4637 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4638 | rval = qla2x00_load_ram(vha, req->dma, risc_addr, |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4639 | dlen); |
| 4640 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4641 | ql_log(ql_log_fatal, vha, 0x008f, |
| 4642 | "Failed to load segment %d of firmware.\n", |
| 4643 | fragment); |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4644 | break; |
| 4645 | } |
| 4646 | |
| 4647 | faddr += dlen; |
| 4648 | risc_addr += dlen; |
| 4649 | risc_size -= dlen; |
| 4650 | fragment++; |
| 4651 | } |
| 4652 | |
| 4653 | /* Next segment. */ |
| 4654 | segments--; |
| 4655 | } |
| 4656 | |
| 4657 | return rval; |
| 4658 | } |
| 4659 | |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4660 | #define QLA_FW_URL "ftp://ftp.qlogic.com/outgoing/linux/firmware/" |
| 4661 | |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4662 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4663 | qla2x00_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4664 | { |
| 4665 | int rval; |
| 4666 | int i, fragment; |
| 4667 | uint16_t *wcode, *fwcode; |
| 4668 | uint32_t risc_addr, risc_size, fwclen, wlen, *seg; |
| 4669 | struct fw_blob *blob; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4670 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4671 | struct req_que *req = ha->req_q_map[0]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4672 | |
| 4673 | /* Load firmware blob. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4674 | blob = qla2x00_request_firmware(vha); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4675 | if (!blob) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4676 | ql_log(ql_log_info, vha, 0x0083, |
| 4677 | "Fimware image unavailable.\n"); |
| 4678 | ql_log(ql_log_info, vha, 0x0084, |
| 4679 | "Firmware images can be retrieved from: "QLA_FW_URL ".\n"); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4680 | return QLA_FUNCTION_FAILED; |
| 4681 | } |
| 4682 | |
| 4683 | rval = QLA_SUCCESS; |
| 4684 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4685 | wcode = (uint16_t *)req->ring; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4686 | *srisc_addr = 0; |
| 4687 | fwcode = (uint16_t *)blob->fw->data; |
| 4688 | fwclen = 0; |
| 4689 | |
| 4690 | /* Validate firmware image by checking version. */ |
| 4691 | if (blob->fw->size < 8 * sizeof(uint16_t)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4692 | ql_log(ql_log_fatal, vha, 0x0085, |
| 4693 | "Unable to verify integrity of firmware image (%Zd).\n", |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4694 | blob->fw->size); |
| 4695 | goto fail_fw_integrity; |
| 4696 | } |
| 4697 | for (i = 0; i < 4; i++) |
| 4698 | wcode[i] = be16_to_cpu(fwcode[i + 4]); |
| 4699 | if ((wcode[0] == 0xffff && wcode[1] == 0xffff && wcode[2] == 0xffff && |
| 4700 | wcode[3] == 0xffff) || (wcode[0] == 0 && wcode[1] == 0 && |
| 4701 | wcode[2] == 0 && wcode[3] == 0)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4702 | ql_log(ql_log_fatal, vha, 0x0086, |
| 4703 | "Unable to verify integrity of firmware image.\n"); |
| 4704 | ql_log(ql_log_fatal, vha, 0x0087, |
| 4705 | "Firmware data: %04x %04x %04x %04x.\n", |
| 4706 | wcode[0], wcode[1], wcode[2], wcode[3]); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4707 | goto fail_fw_integrity; |
| 4708 | } |
| 4709 | |
| 4710 | seg = blob->segs; |
| 4711 | while (*seg && rval == QLA_SUCCESS) { |
| 4712 | risc_addr = *seg; |
| 4713 | *srisc_addr = *srisc_addr == 0 ? *seg : *srisc_addr; |
| 4714 | risc_size = be16_to_cpu(fwcode[3]); |
| 4715 | |
| 4716 | /* Validate firmware image size. */ |
| 4717 | fwclen += risc_size * sizeof(uint16_t); |
| 4718 | if (blob->fw->size < fwclen) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4719 | ql_log(ql_log_fatal, vha, 0x0088, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4720 | "Unable to verify integrity of firmware image " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4721 | "(%Zd).\n", blob->fw->size); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4722 | goto fail_fw_integrity; |
| 4723 | } |
| 4724 | |
| 4725 | fragment = 0; |
| 4726 | while (risc_size > 0 && rval == QLA_SUCCESS) { |
| 4727 | wlen = (uint16_t)(ha->fw_transfer_size >> 1); |
| 4728 | if (wlen > risc_size) |
| 4729 | wlen = risc_size; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4730 | ql_dbg(ql_dbg_init, vha, 0x0089, |
| 4731 | "Loading risc segment@ risc addr %x number of " |
| 4732 | "words 0x%x.\n", risc_addr, wlen); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4733 | |
| 4734 | for (i = 0; i < wlen; i++) |
| 4735 | wcode[i] = swab16(fwcode[i]); |
| 4736 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4737 | rval = qla2x00_load_ram(vha, req->dma, risc_addr, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4738 | wlen); |
| 4739 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4740 | ql_log(ql_log_fatal, vha, 0x008a, |
| 4741 | "Failed to load segment %d of firmware.\n", |
| 4742 | fragment); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4743 | break; |
| 4744 | } |
| 4745 | |
| 4746 | fwcode += wlen; |
| 4747 | risc_addr += wlen; |
| 4748 | risc_size -= wlen; |
| 4749 | fragment++; |
| 4750 | } |
| 4751 | |
| 4752 | /* Next segment. */ |
| 4753 | seg++; |
| 4754 | } |
| 4755 | return rval; |
| 4756 | |
| 4757 | fail_fw_integrity: |
| 4758 | return QLA_FUNCTION_FAILED; |
| 4759 | } |
| 4760 | |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4761 | static int |
| 4762 | qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t *srisc_addr) |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4763 | { |
| 4764 | int rval; |
| 4765 | int segments, fragment; |
| 4766 | uint32_t *dcode, dlen; |
| 4767 | uint32_t risc_addr; |
| 4768 | uint32_t risc_size; |
| 4769 | uint32_t i; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4770 | struct fw_blob *blob; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4771 | uint32_t *fwcode, fwclen; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4772 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4773 | struct req_que *req = ha->req_q_map[0]; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4774 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4775 | /* Load firmware blob. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4776 | blob = qla2x00_request_firmware(vha); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4777 | if (!blob) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4778 | ql_log(ql_log_warn, vha, 0x0090, |
| 4779 | "Fimware image unavailable.\n"); |
| 4780 | ql_log(ql_log_warn, vha, 0x0091, |
| 4781 | "Firmware images can be retrieved from: " |
| 4782 | QLA_FW_URL ".\n"); |
Andrew Vasquez | d1c6190 | 2006-05-17 15:09:00 -0700 | [diff] [blame] | 4783 | |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4784 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4785 | } |
| 4786 | |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 4787 | ql_dbg(ql_dbg_init, vha, 0x0092, |
| 4788 | "FW: Loading via request-firmware.\n"); |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4789 | |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4790 | rval = QLA_SUCCESS; |
| 4791 | |
| 4792 | segments = FA_RISC_CODE_SEGMENTS; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4793 | dcode = (uint32_t *)req->ring; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4794 | *srisc_addr = 0; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4795 | fwcode = (uint32_t *)blob->fw->data; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4796 | fwclen = 0; |
| 4797 | |
| 4798 | /* Validate firmware image by checking version. */ |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4799 | if (blob->fw->size < 8 * sizeof(uint32_t)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4800 | ql_log(ql_log_fatal, vha, 0x0093, |
| 4801 | "Unable to verify integrity of firmware image (%Zd).\n", |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4802 | blob->fw->size); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4803 | goto fail_fw_integrity; |
| 4804 | } |
| 4805 | for (i = 0; i < 4; i++) |
| 4806 | dcode[i] = be32_to_cpu(fwcode[i + 4]); |
| 4807 | if ((dcode[0] == 0xffffffff && dcode[1] == 0xffffffff && |
| 4808 | dcode[2] == 0xffffffff && dcode[3] == 0xffffffff) || |
| 4809 | (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 && |
| 4810 | dcode[3] == 0)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4811 | ql_log(ql_log_fatal, vha, 0x0094, |
| 4812 | "Unable to verify integrity of firmware image (%Zd).\n", |
| 4813 | blob->fw->size); |
| 4814 | ql_log(ql_log_fatal, vha, 0x0095, |
| 4815 | "Firmware data: %08x %08x %08x %08x.\n", |
| 4816 | dcode[0], dcode[1], dcode[2], dcode[3]); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4817 | goto fail_fw_integrity; |
| 4818 | } |
| 4819 | |
| 4820 | while (segments && rval == QLA_SUCCESS) { |
| 4821 | risc_addr = be32_to_cpu(fwcode[2]); |
| 4822 | *srisc_addr = *srisc_addr == 0 ? risc_addr : *srisc_addr; |
| 4823 | risc_size = be32_to_cpu(fwcode[3]); |
| 4824 | |
| 4825 | /* Validate firmware image size. */ |
| 4826 | fwclen += risc_size * sizeof(uint32_t); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4827 | if (blob->fw->size < fwclen) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4828 | ql_log(ql_log_fatal, vha, 0x0096, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4829 | "Unable to verify integrity of firmware image " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4830 | "(%Zd).\n", blob->fw->size); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4831 | |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4832 | goto fail_fw_integrity; |
| 4833 | } |
| 4834 | |
| 4835 | fragment = 0; |
| 4836 | while (risc_size > 0 && rval == QLA_SUCCESS) { |
| 4837 | dlen = (uint32_t)(ha->fw_transfer_size >> 2); |
| 4838 | if (dlen > risc_size) |
| 4839 | dlen = risc_size; |
| 4840 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4841 | ql_dbg(ql_dbg_init, vha, 0x0097, |
| 4842 | "Loading risc segment@ risc addr %x " |
| 4843 | "number of dwords 0x%x.\n", risc_addr, dlen); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4844 | |
| 4845 | for (i = 0; i < dlen; i++) |
| 4846 | dcode[i] = swab32(fwcode[i]); |
| 4847 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4848 | rval = qla2x00_load_ram(vha, req->dma, risc_addr, |
andrew.vasquez@qlogic.com | 590f98e | 2006-01-13 17:05:37 -0800 | [diff] [blame] | 4849 | dlen); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4850 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4851 | ql_log(ql_log_fatal, vha, 0x0098, |
| 4852 | "Failed to load segment %d of firmware.\n", |
| 4853 | fragment); |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4854 | break; |
| 4855 | } |
| 4856 | |
| 4857 | fwcode += dlen; |
| 4858 | risc_addr += dlen; |
| 4859 | risc_size -= dlen; |
| 4860 | fragment++; |
| 4861 | } |
| 4862 | |
| 4863 | /* Next segment. */ |
| 4864 | segments--; |
| 4865 | } |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4866 | return rval; |
| 4867 | |
| 4868 | fail_fw_integrity: |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4869 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | 0107109e | 2005-07-06 10:31:37 -0700 | [diff] [blame] | 4870 | } |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 4871 | |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4872 | int |
| 4873 | qla24xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr) |
| 4874 | { |
| 4875 | int rval; |
| 4876 | |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 4877 | if (ql2xfwloadbin == 1) |
| 4878 | return qla81xx_load_risc(vha, srisc_addr); |
| 4879 | |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4880 | /* |
| 4881 | * FW Load priority: |
| 4882 | * 1) Firmware via request-firmware interface (.bin file). |
| 4883 | * 2) Firmware residing in flash. |
| 4884 | */ |
| 4885 | rval = qla24xx_load_risc_blob(vha, srisc_addr); |
| 4886 | if (rval == QLA_SUCCESS) |
| 4887 | return rval; |
| 4888 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4889 | return qla24xx_load_risc_flash(vha, srisc_addr, |
| 4890 | vha->hw->flt_region_fw); |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4891 | } |
| 4892 | |
| 4893 | int |
| 4894 | qla81xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr) |
| 4895 | { |
| 4896 | int rval; |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4897 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4898 | |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 4899 | if (ql2xfwloadbin == 2) |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4900 | goto try_blob_fw; |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 4901 | |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4902 | /* |
| 4903 | * FW Load priority: |
| 4904 | * 1) Firmware residing in flash. |
| 4905 | * 2) Firmware via request-firmware interface (.bin file). |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4906 | * 3) Golden-Firmware residing in flash -- limited operation. |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4907 | */ |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4908 | rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_fw); |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4909 | if (rval == QLA_SUCCESS) |
| 4910 | return rval; |
| 4911 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4912 | try_blob_fw: |
| 4913 | rval = qla24xx_load_risc_blob(vha, srisc_addr); |
| 4914 | if (rval == QLA_SUCCESS || !ha->flt_region_gold_fw) |
| 4915 | return rval; |
| 4916 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4917 | ql_log(ql_log_info, vha, 0x0099, |
| 4918 | "Attempting to fallback to golden firmware.\n"); |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4919 | rval = qla24xx_load_risc_flash(vha, srisc_addr, ha->flt_region_gold_fw); |
| 4920 | if (rval != QLA_SUCCESS) |
| 4921 | return rval; |
| 4922 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4923 | ql_log(ql_log_info, vha, 0x009a, "Update operational firmware.\n"); |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4924 | ha->flags.running_gold_fw = 1; |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 4925 | return rval; |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 4926 | } |
| 4927 | |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 4928 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4929 | qla2x00_try_to_stop_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 4930 | { |
| 4931 | int ret, retries; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4932 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 4933 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4934 | if (ha->flags.pci_channel_io_perm_failure) |
| 4935 | return; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 4936 | if (!IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 4937 | return; |
Andrew Vasquez | 75edf81 | 2007-05-07 07:43:00 -0700 | [diff] [blame] | 4938 | if (!ha->fw_major_version) |
| 4939 | return; |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 4940 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4941 | ret = qla2x00_stop_firmware(vha); |
Andrew Vasquez | 7c7f1f2 | 2008-02-28 14:06:09 -0800 | [diff] [blame] | 4942 | for (retries = 5; ret != QLA_SUCCESS && ret != QLA_FUNCTION_TIMEOUT && |
Andrew Vasquez | b469a7c | 2009-04-06 22:33:48 -0700 | [diff] [blame] | 4943 | ret != QLA_INVALID_COMMAND && retries ; retries--) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4944 | ha->isp_ops->reset_chip(vha); |
| 4945 | if (ha->isp_ops->chip_diag(vha) != QLA_SUCCESS) |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 4946 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4947 | if (qla2x00_setup_chip(vha) != QLA_SUCCESS) |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 4948 | continue; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4949 | ql_log(ql_log_info, vha, 0x8015, |
| 4950 | "Attempting retry of stop-firmware command.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4951 | ret = qla2x00_stop_firmware(vha); |
Andrew Vasquez | 18c6c12 | 2006-10-13 09:33:38 -0700 | [diff] [blame] | 4952 | } |
| 4953 | } |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4954 | |
| 4955 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4956 | qla24xx_configure_vhba(scsi_qla_host_t *vha) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4957 | { |
| 4958 | int rval = QLA_SUCCESS; |
| 4959 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4960 | struct qla_hw_data *ha = vha->hw; |
| 4961 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 4962 | struct req_que *req; |
| 4963 | struct rsp_que *rsp; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4964 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4965 | if (!vha->vp_idx) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4966 | return -EINVAL; |
| 4967 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4968 | rval = qla2x00_fw_ready(base_vha); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 4969 | if (ha->flags.cpu_affinity_enabled) |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 4970 | req = ha->req_q_map[0]; |
| 4971 | else |
| 4972 | req = vha->req; |
| 4973 | rsp = req->rsp; |
| 4974 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4975 | if (rval == QLA_SUCCESS) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4976 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4977 | qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4978 | } |
| 4979 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4980 | vha->flags.management_server_logged_in = 0; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4981 | |
| 4982 | /* Login to SNS first */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4983 | 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] | 4984 | if (mb[0] != MBS_COMMAND_COMPLETE) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4985 | ql_dbg(ql_dbg_init, vha, 0x0103, |
| 4986 | "Failed SNS login: loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x " |
| 4987 | "mb[6]=%x mb[7]=%x.\n", |
| 4988 | NPH_SNS, mb[0], mb[1], mb[2], mb[6], mb[7]); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4989 | return (QLA_FUNCTION_FAILED); |
| 4990 | } |
| 4991 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4992 | atomic_set(&vha->loop_down_timer, 0); |
| 4993 | atomic_set(&vha->loop_state, LOOP_UP); |
| 4994 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 4995 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 4996 | rval = qla2x00_loop_resync(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4997 | |
| 4998 | return rval; |
| 4999 | } |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5000 | |
| 5001 | /* 84XX Support **************************************************************/ |
| 5002 | |
| 5003 | static LIST_HEAD(qla_cs84xx_list); |
| 5004 | static DEFINE_MUTEX(qla_cs84xx_mutex); |
| 5005 | |
| 5006 | static struct qla_chip_state_84xx * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5007 | qla84xx_get_chip(struct scsi_qla_host *vha) |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5008 | { |
| 5009 | struct qla_chip_state_84xx *cs84xx; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5010 | struct qla_hw_data *ha = vha->hw; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5011 | |
| 5012 | mutex_lock(&qla_cs84xx_mutex); |
| 5013 | |
| 5014 | /* Find any shared 84xx chip. */ |
| 5015 | list_for_each_entry(cs84xx, &qla_cs84xx_list, list) { |
| 5016 | if (cs84xx->bus == ha->pdev->bus) { |
| 5017 | kref_get(&cs84xx->kref); |
| 5018 | goto done; |
| 5019 | } |
| 5020 | } |
| 5021 | |
| 5022 | cs84xx = kzalloc(sizeof(*cs84xx), GFP_KERNEL); |
| 5023 | if (!cs84xx) |
| 5024 | goto done; |
| 5025 | |
| 5026 | kref_init(&cs84xx->kref); |
| 5027 | spin_lock_init(&cs84xx->access_lock); |
| 5028 | mutex_init(&cs84xx->fw_update_mutex); |
| 5029 | cs84xx->bus = ha->pdev->bus; |
| 5030 | |
| 5031 | list_add_tail(&cs84xx->list, &qla_cs84xx_list); |
| 5032 | done: |
| 5033 | mutex_unlock(&qla_cs84xx_mutex); |
| 5034 | return cs84xx; |
| 5035 | } |
| 5036 | |
| 5037 | static void |
| 5038 | __qla84xx_chip_release(struct kref *kref) |
| 5039 | { |
| 5040 | struct qla_chip_state_84xx *cs84xx = |
| 5041 | container_of(kref, struct qla_chip_state_84xx, kref); |
| 5042 | |
| 5043 | mutex_lock(&qla_cs84xx_mutex); |
| 5044 | list_del(&cs84xx->list); |
| 5045 | mutex_unlock(&qla_cs84xx_mutex); |
| 5046 | kfree(cs84xx); |
| 5047 | } |
| 5048 | |
| 5049 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5050 | qla84xx_put_chip(struct scsi_qla_host *vha) |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5051 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5052 | struct qla_hw_data *ha = vha->hw; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5053 | if (ha->cs84xx) |
| 5054 | kref_put(&ha->cs84xx->kref, __qla84xx_chip_release); |
| 5055 | } |
| 5056 | |
| 5057 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5058 | qla84xx_init_chip(scsi_qla_host_t *vha) |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5059 | { |
| 5060 | int rval; |
| 5061 | uint16_t status[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5062 | struct qla_hw_data *ha = vha->hw; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5063 | |
| 5064 | mutex_lock(&ha->cs84xx->fw_update_mutex); |
| 5065 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5066 | rval = qla84xx_verify_chip(vha, status); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5067 | |
| 5068 | mutex_unlock(&ha->cs84xx->fw_update_mutex); |
| 5069 | |
| 5070 | return rval != QLA_SUCCESS || status[0] ? QLA_FUNCTION_FAILED: |
| 5071 | QLA_SUCCESS; |
| 5072 | } |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5073 | |
| 5074 | /* 81XX Support **************************************************************/ |
| 5075 | |
| 5076 | int |
| 5077 | qla81xx_nvram_config(scsi_qla_host_t *vha) |
| 5078 | { |
| 5079 | int rval; |
| 5080 | struct init_cb_81xx *icb; |
| 5081 | struct nvram_81xx *nv; |
| 5082 | uint32_t *dptr; |
| 5083 | uint8_t *dptr1, *dptr2; |
| 5084 | uint32_t chksum; |
| 5085 | uint16_t cnt; |
| 5086 | struct qla_hw_data *ha = vha->hw; |
| 5087 | |
| 5088 | rval = QLA_SUCCESS; |
| 5089 | icb = (struct init_cb_81xx *)ha->init_cb; |
| 5090 | nv = ha->nvram; |
| 5091 | |
| 5092 | /* Determine NVRAM starting address. */ |
| 5093 | ha->nvram_size = sizeof(struct nvram_81xx); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5094 | ha->vpd_size = FA_NVRAM_VPD_SIZE; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5095 | |
| 5096 | /* Get VPD data into cache */ |
| 5097 | ha->vpd = ha->nvram + VPD_OFFSET; |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 5098 | ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_vpd << 2, |
| 5099 | ha->vpd_size); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5100 | |
| 5101 | /* Get NVRAM data into cache and calculate checksum. */ |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 5102 | 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] | 5103 | ha->nvram_size); |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 5104 | dptr = (uint32_t *)nv; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5105 | for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++) |
| 5106 | chksum += le32_to_cpu(*dptr++); |
| 5107 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5108 | ql_dbg(ql_dbg_init + ql_dbg_buffer, vha, 0x0111, |
| 5109 | "Contents of NVRAM:\n"); |
| 5110 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0112, |
| 5111 | (uint8_t *)nv, ha->nvram_size); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5112 | |
| 5113 | /* Bad NVRAM data, set defaults parameters. */ |
| 5114 | if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P' |
| 5115 | || nv->id[3] != ' ' || |
| 5116 | nv->nvram_version < __constant_cpu_to_le16(ICB_VERSION)) { |
| 5117 | /* Reset NVRAM data. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5118 | ql_log(ql_log_info, vha, 0x0073, |
| 5119 | "Inconisistent NVRAM detected: checksum=0x%x id=%c " |
| 5120 | "version=0x%x.\n", chksum, nv->id[0], |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5121 | le16_to_cpu(nv->nvram_version)); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5122 | ql_log(ql_log_info, vha, 0x0074, |
| 5123 | "Falling back to functioning (yet invalid -- WWPN) " |
| 5124 | "defaults.\n"); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5125 | |
| 5126 | /* |
| 5127 | * Set default initialization control block. |
| 5128 | */ |
| 5129 | memset(nv, 0, ha->nvram_size); |
| 5130 | nv->nvram_version = __constant_cpu_to_le16(ICB_VERSION); |
| 5131 | nv->version = __constant_cpu_to_le16(ICB_VERSION); |
| 5132 | nv->frame_payload_size = __constant_cpu_to_le16(2048); |
| 5133 | nv->execution_throttle = __constant_cpu_to_le16(0xFFFF); |
| 5134 | nv->exchange_count = __constant_cpu_to_le16(0); |
| 5135 | nv->port_name[0] = 0x21; |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 5136 | nv->port_name[1] = 0x00 + ha->port_no; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5137 | nv->port_name[2] = 0x00; |
| 5138 | nv->port_name[3] = 0xe0; |
| 5139 | nv->port_name[4] = 0x8b; |
| 5140 | nv->port_name[5] = 0x1c; |
| 5141 | nv->port_name[6] = 0x55; |
| 5142 | nv->port_name[7] = 0x86; |
| 5143 | nv->node_name[0] = 0x20; |
| 5144 | nv->node_name[1] = 0x00; |
| 5145 | nv->node_name[2] = 0x00; |
| 5146 | nv->node_name[3] = 0xe0; |
| 5147 | nv->node_name[4] = 0x8b; |
| 5148 | nv->node_name[5] = 0x1c; |
| 5149 | nv->node_name[6] = 0x55; |
| 5150 | nv->node_name[7] = 0x86; |
| 5151 | nv->login_retry_count = __constant_cpu_to_le16(8); |
| 5152 | nv->interrupt_delay_timer = __constant_cpu_to_le16(0); |
| 5153 | nv->login_timeout = __constant_cpu_to_le16(0); |
| 5154 | nv->firmware_options_1 = |
| 5155 | __constant_cpu_to_le32(BIT_14|BIT_13|BIT_2|BIT_1); |
| 5156 | nv->firmware_options_2 = __constant_cpu_to_le32(2 << 4); |
| 5157 | nv->firmware_options_2 |= __constant_cpu_to_le32(BIT_12); |
| 5158 | nv->firmware_options_3 = __constant_cpu_to_le32(2 << 13); |
| 5159 | nv->host_p = __constant_cpu_to_le32(BIT_11|BIT_10); |
| 5160 | nv->efi_parameters = __constant_cpu_to_le32(0); |
| 5161 | nv->reset_delay = 5; |
| 5162 | nv->max_luns_per_target = __constant_cpu_to_le16(128); |
| 5163 | nv->port_down_retry_count = __constant_cpu_to_le16(30); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5164 | nv->link_down_timeout = __constant_cpu_to_le16(180); |
Andrew Vasquez | eeebcc9 | 2009-06-03 09:55:24 -0700 | [diff] [blame] | 5165 | nv->enode_mac[0] = 0x00; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5166 | nv->enode_mac[1] = 0xC0; |
| 5167 | nv->enode_mac[2] = 0xDD; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5168 | nv->enode_mac[3] = 0x04; |
| 5169 | nv->enode_mac[4] = 0x05; |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 5170 | nv->enode_mac[5] = 0x06 + ha->port_no; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5171 | |
| 5172 | rval = 1; |
| 5173 | } |
| 5174 | |
| 5175 | /* Reset Initialization control block */ |
Andrew Vasquez | 773120e | 2011-05-10 11:30:14 -0700 | [diff] [blame] | 5176 | memset(icb, 0, ha->init_cb_size); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5177 | |
| 5178 | /* Copy 1st segment. */ |
| 5179 | dptr1 = (uint8_t *)icb; |
| 5180 | dptr2 = (uint8_t *)&nv->version; |
| 5181 | cnt = (uint8_t *)&icb->response_q_inpointer - (uint8_t *)&icb->version; |
| 5182 | while (cnt--) |
| 5183 | *dptr1++ = *dptr2++; |
| 5184 | |
| 5185 | icb->login_retry_count = nv->login_retry_count; |
| 5186 | |
| 5187 | /* Copy 2nd segment. */ |
| 5188 | dptr1 = (uint8_t *)&icb->interrupt_delay_timer; |
| 5189 | dptr2 = (uint8_t *)&nv->interrupt_delay_timer; |
| 5190 | cnt = (uint8_t *)&icb->reserved_5 - |
| 5191 | (uint8_t *)&icb->interrupt_delay_timer; |
| 5192 | while (cnt--) |
| 5193 | *dptr1++ = *dptr2++; |
| 5194 | |
| 5195 | memcpy(icb->enode_mac, nv->enode_mac, sizeof(icb->enode_mac)); |
| 5196 | /* Some boards (with valid NVRAMs) still have NULL enode_mac!! */ |
| 5197 | if (!memcmp(icb->enode_mac, "\0\0\0\0\0\0", sizeof(icb->enode_mac))) { |
Andrew Vasquez | 69e5f1e | 2012-02-09 11:15:35 -0800 | [diff] [blame] | 5198 | icb->enode_mac[0] = 0x00; |
| 5199 | icb->enode_mac[1] = 0xC0; |
| 5200 | icb->enode_mac[2] = 0xDD; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5201 | icb->enode_mac[3] = 0x04; |
| 5202 | icb->enode_mac[4] = 0x05; |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 5203 | icb->enode_mac[5] = 0x06 + ha->port_no; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5204 | } |
| 5205 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 5206 | /* Use extended-initialization control block. */ |
| 5207 | memcpy(ha->ex_init_cb, &nv->ex_version, sizeof(*ha->ex_init_cb)); |
| 5208 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5209 | /* |
| 5210 | * Setup driver NVRAM options. |
| 5211 | */ |
| 5212 | qla2x00_set_model_info(vha, nv->model_name, sizeof(nv->model_name), |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5213 | "QLE8XXX"); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5214 | |
| 5215 | /* Use alternate WWN? */ |
| 5216 | if (nv->host_p & __constant_cpu_to_le32(BIT_15)) { |
| 5217 | memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); |
| 5218 | memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); |
| 5219 | } |
| 5220 | |
| 5221 | /* Prepare nodename */ |
| 5222 | if ((icb->firmware_options_1 & __constant_cpu_to_le32(BIT_14)) == 0) { |
| 5223 | /* |
| 5224 | * Firmware will apply the following mask if the nodename was |
| 5225 | * not provided. |
| 5226 | */ |
| 5227 | memcpy(icb->node_name, icb->port_name, WWN_SIZE); |
| 5228 | icb->node_name[0] &= 0xF0; |
| 5229 | } |
| 5230 | |
| 5231 | /* Set host adapter parameters. */ |
| 5232 | ha->flags.disable_risc_code_load = 0; |
| 5233 | ha->flags.enable_lip_reset = 0; |
| 5234 | ha->flags.enable_lip_full_login = |
| 5235 | le32_to_cpu(nv->host_p) & BIT_10 ? 1: 0; |
| 5236 | ha->flags.enable_target_reset = |
| 5237 | le32_to_cpu(nv->host_p) & BIT_11 ? 1: 0; |
| 5238 | ha->flags.enable_led_scheme = 0; |
| 5239 | ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1: 0; |
| 5240 | |
| 5241 | ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) & |
| 5242 | (BIT_6 | BIT_5 | BIT_4)) >> 4; |
| 5243 | |
| 5244 | /* save HBA serial number */ |
| 5245 | ha->serial0 = icb->port_name[5]; |
| 5246 | ha->serial1 = icb->port_name[6]; |
| 5247 | ha->serial2 = icb->port_name[7]; |
| 5248 | memcpy(vha->node_name, icb->node_name, WWN_SIZE); |
| 5249 | memcpy(vha->port_name, icb->port_name, WWN_SIZE); |
| 5250 | |
| 5251 | icb->execution_throttle = __constant_cpu_to_le16(0xFFFF); |
| 5252 | |
| 5253 | ha->retry_count = le16_to_cpu(nv->login_retry_count); |
| 5254 | |
| 5255 | /* Set minimum login_timeout to 4 seconds. */ |
| 5256 | if (le16_to_cpu(nv->login_timeout) < ql2xlogintimeout) |
| 5257 | nv->login_timeout = cpu_to_le16(ql2xlogintimeout); |
| 5258 | if (le16_to_cpu(nv->login_timeout) < 4) |
| 5259 | nv->login_timeout = __constant_cpu_to_le16(4); |
| 5260 | ha->login_timeout = le16_to_cpu(nv->login_timeout); |
| 5261 | icb->login_timeout = nv->login_timeout; |
| 5262 | |
| 5263 | /* Set minimum RATOV to 100 tenths of a second. */ |
| 5264 | ha->r_a_tov = 100; |
| 5265 | |
| 5266 | ha->loop_reset_delay = nv->reset_delay; |
| 5267 | |
| 5268 | /* Link Down Timeout = 0: |
| 5269 | * |
| 5270 | * When Port Down timer expires we will start returning |
| 5271 | * I/O's to OS with "DID_NO_CONNECT". |
| 5272 | * |
| 5273 | * Link Down Timeout != 0: |
| 5274 | * |
| 5275 | * The driver waits for the link to come up after link down |
| 5276 | * before returning I/Os to OS with "DID_NO_CONNECT". |
| 5277 | */ |
| 5278 | if (le16_to_cpu(nv->link_down_timeout) == 0) { |
| 5279 | ha->loop_down_abort_time = |
| 5280 | (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); |
| 5281 | } else { |
| 5282 | ha->link_down_timeout = le16_to_cpu(nv->link_down_timeout); |
| 5283 | ha->loop_down_abort_time = |
| 5284 | (LOOP_DOWN_TIME - ha->link_down_timeout); |
| 5285 | } |
| 5286 | |
| 5287 | /* Need enough time to try and get the port back. */ |
| 5288 | ha->port_down_retry_count = le16_to_cpu(nv->port_down_retry_count); |
| 5289 | if (qlport_down_retry) |
| 5290 | ha->port_down_retry_count = qlport_down_retry; |
| 5291 | |
| 5292 | /* Set login_retry_count */ |
| 5293 | ha->login_retry_count = le16_to_cpu(nv->login_retry_count); |
| 5294 | if (ha->port_down_retry_count == |
| 5295 | le16_to_cpu(nv->port_down_retry_count) && |
| 5296 | ha->port_down_retry_count > 3) |
| 5297 | ha->login_retry_count = ha->port_down_retry_count; |
| 5298 | else if (ha->port_down_retry_count > (int)ha->login_retry_count) |
| 5299 | ha->login_retry_count = ha->port_down_retry_count; |
| 5300 | if (ql2xloginretrycount) |
| 5301 | ha->login_retry_count = ql2xloginretrycount; |
| 5302 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5303 | /* if not running MSI-X we need handshaking on interrupts */ |
| 5304 | if (!vha->hw->flags.msix_enabled && IS_QLA83XX(ha)) |
| 5305 | icb->firmware_options_2 |= __constant_cpu_to_le32(BIT_22); |
| 5306 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5307 | /* Enable ZIO. */ |
| 5308 | if (!vha->flags.init_done) { |
| 5309 | ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & |
| 5310 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
| 5311 | ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? |
| 5312 | le16_to_cpu(icb->interrupt_delay_timer): 2; |
| 5313 | } |
| 5314 | icb->firmware_options_2 &= __constant_cpu_to_le32( |
| 5315 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0)); |
| 5316 | vha->flags.process_response_queue = 0; |
| 5317 | if (ha->zio_mode != QLA_ZIO_DISABLED) { |
| 5318 | ha->zio_mode = QLA_ZIO_MODE_6; |
| 5319 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5320 | ql_log(ql_log_info, vha, 0x0075, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5321 | "ZIO mode %d enabled; timer delay (%d us).\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5322 | ha->zio_mode, |
| 5323 | ha->zio_timer * 100); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5324 | |
| 5325 | icb->firmware_options_2 |= cpu_to_le32( |
| 5326 | (uint32_t)ha->zio_mode); |
| 5327 | icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer); |
| 5328 | vha->flags.process_response_queue = 1; |
| 5329 | } |
| 5330 | |
| 5331 | if (rval) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5332 | ql_log(ql_log_warn, vha, 0x0076, |
| 5333 | "NVRAM configuration failed.\n"); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5334 | } |
| 5335 | return (rval); |
| 5336 | } |
| 5337 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5338 | int |
| 5339 | qla82xx_restart_isp(scsi_qla_host_t *vha) |
| 5340 | { |
| 5341 | int status, rval; |
| 5342 | uint32_t wait_time; |
| 5343 | struct qla_hw_data *ha = vha->hw; |
| 5344 | struct req_que *req = ha->req_q_map[0]; |
| 5345 | struct rsp_que *rsp = ha->rsp_q_map[0]; |
| 5346 | struct scsi_qla_host *vp; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 5347 | unsigned long flags; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5348 | |
| 5349 | status = qla2x00_init_rings(vha); |
| 5350 | if (!status) { |
| 5351 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
| 5352 | ha->flags.chip_reset_done = 1; |
| 5353 | |
| 5354 | status = qla2x00_fw_ready(vha); |
| 5355 | if (!status) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5356 | ql_log(ql_log_info, vha, 0x803c, |
| 5357 | "Start configure loop, status =%d.\n", status); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5358 | |
| 5359 | /* Issue a marker after FW becomes ready. */ |
| 5360 | qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL); |
| 5361 | |
| 5362 | vha->flags.online = 1; |
| 5363 | /* Wait at most MAX_TARGET RSCNs for a stable link. */ |
| 5364 | wait_time = 256; |
| 5365 | do { |
| 5366 | clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 5367 | qla2x00_configure_loop(vha); |
| 5368 | wait_time--; |
| 5369 | } while (!atomic_read(&vha->loop_down_timer) && |
| 5370 | !(test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) && |
| 5371 | wait_time && |
| 5372 | (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))); |
| 5373 | } |
| 5374 | |
| 5375 | /* if no cable then assume it's good */ |
| 5376 | if ((vha->device_flags & DFLG_NO_CABLE)) |
| 5377 | status = 0; |
| 5378 | |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5379 | ql_log(ql_log_info, vha, 0x8000, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5380 | "Configure loop done, status = 0x%x.\n", status); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5381 | } |
| 5382 | |
| 5383 | if (!status) { |
| 5384 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
| 5385 | |
| 5386 | if (!atomic_read(&vha->loop_down_timer)) { |
| 5387 | /* |
| 5388 | * Issue marker command only when we are going |
| 5389 | * to start the I/O . |
| 5390 | */ |
| 5391 | vha->marker_needed = 1; |
| 5392 | } |
| 5393 | |
| 5394 | vha->flags.online = 1; |
| 5395 | |
| 5396 | ha->isp_ops->enable_intrs(ha); |
| 5397 | |
| 5398 | ha->isp_abort_cnt = 0; |
| 5399 | clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
| 5400 | |
Saurav Kashyap | 5329678 | 2011-05-10 11:30:06 -0700 | [diff] [blame] | 5401 | /* Update the firmware version */ |
Giridhar Malavali | 3173167 | 2011-08-16 11:31:54 -0700 | [diff] [blame] | 5402 | status = qla82xx_check_md_needed(vha); |
Saurav Kashyap | 5329678 | 2011-05-10 11:30:06 -0700 | [diff] [blame] | 5403 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5404 | if (ha->fce) { |
| 5405 | ha->flags.fce_enabled = 1; |
| 5406 | memset(ha->fce, 0, |
| 5407 | fce_calc_size(ha->fce_bufs)); |
| 5408 | rval = qla2x00_enable_fce_trace(vha, |
| 5409 | ha->fce_dma, ha->fce_bufs, ha->fce_mb, |
| 5410 | &ha->fce_bufs); |
| 5411 | if (rval) { |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5412 | ql_log(ql_log_warn, vha, 0x8001, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5413 | "Unable to reinitialize FCE (%d).\n", |
| 5414 | rval); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5415 | ha->flags.fce_enabled = 0; |
| 5416 | } |
| 5417 | } |
| 5418 | |
| 5419 | if (ha->eft) { |
| 5420 | memset(ha->eft, 0, EFT_SIZE); |
| 5421 | rval = qla2x00_enable_eft_trace(vha, |
| 5422 | ha->eft_dma, EFT_NUM_BUFFERS); |
| 5423 | if (rval) { |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5424 | ql_log(ql_log_warn, vha, 0x8010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5425 | "Unable to reinitialize EFT (%d).\n", |
| 5426 | rval); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5427 | } |
| 5428 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5429 | } |
| 5430 | |
| 5431 | if (!status) { |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5432 | ql_dbg(ql_dbg_taskm, vha, 0x8011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5433 | "qla82xx_restart_isp succeeded.\n"); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 5434 | |
| 5435 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 5436 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 5437 | if (vp->vp_idx) { |
| 5438 | atomic_inc(&vp->vref_count); |
| 5439 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 5440 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5441 | qla2x00_vp_abort_isp(vp); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 5442 | |
| 5443 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 5444 | atomic_dec(&vp->vref_count); |
| 5445 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5446 | } |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 5447 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 5448 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5449 | } else { |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5450 | ql_log(ql_log_warn, vha, 0x8016, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5451 | "qla82xx_restart_isp **** FAILED ****.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5452 | } |
| 5453 | |
| 5454 | return status; |
| 5455 | } |
| 5456 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5457 | void |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 5458 | qla81xx_update_fw_options(scsi_qla_host_t *vha) |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5459 | { |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 5460 | struct qla_hw_data *ha = vha->hw; |
| 5461 | |
| 5462 | if (!ql2xetsenable) |
| 5463 | return; |
| 5464 | |
| 5465 | /* Enable ETS Burst. */ |
| 5466 | memset(ha->fw_options, 0, sizeof(ha->fw_options)); |
| 5467 | ha->fw_options[2] |= BIT_9; |
| 5468 | qla2x00_set_fw_options(vha, ha->fw_options); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5469 | } |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5470 | |
| 5471 | /* |
| 5472 | * qla24xx_get_fcp_prio |
| 5473 | * Gets the fcp cmd priority value for the logged in port. |
| 5474 | * Looks for a match of the port descriptors within |
| 5475 | * each of the fcp prio config entries. If a match is found, |
| 5476 | * the tag (priority) value is returned. |
| 5477 | * |
| 5478 | * Input: |
Madhuranath Iyengar | 21090cb | 2010-12-21 16:00:18 -0800 | [diff] [blame] | 5479 | * vha = scsi host structure pointer. |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5480 | * fcport = port structure pointer. |
| 5481 | * |
| 5482 | * Return: |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 5483 | * non-zero (if found) |
Andrew Vasquez | f28a0a9 | 2011-03-30 11:46:18 -0700 | [diff] [blame] | 5484 | * -1 (if not found) |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5485 | * |
| 5486 | * Context: |
| 5487 | * Kernel context |
| 5488 | */ |
Andrew Vasquez | f28a0a9 | 2011-03-30 11:46:18 -0700 | [diff] [blame] | 5489 | static int |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5490 | qla24xx_get_fcp_prio(scsi_qla_host_t *vha, fc_port_t *fcport) |
| 5491 | { |
| 5492 | int i, entries; |
| 5493 | uint8_t pid_match, wwn_match; |
Andrew Vasquez | f28a0a9 | 2011-03-30 11:46:18 -0700 | [diff] [blame] | 5494 | int priority; |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5495 | uint32_t pid1, pid2; |
| 5496 | uint64_t wwn1, wwn2; |
| 5497 | struct qla_fcp_prio_entry *pri_entry; |
| 5498 | struct qla_hw_data *ha = vha->hw; |
| 5499 | |
| 5500 | if (!ha->fcp_prio_cfg || !ha->flags.fcp_prio_enabled) |
Andrew Vasquez | f28a0a9 | 2011-03-30 11:46:18 -0700 | [diff] [blame] | 5501 | return -1; |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5502 | |
Andrew Vasquez | f28a0a9 | 2011-03-30 11:46:18 -0700 | [diff] [blame] | 5503 | priority = -1; |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5504 | entries = ha->fcp_prio_cfg->num_entries; |
| 5505 | pri_entry = &ha->fcp_prio_cfg->entry[0]; |
| 5506 | |
| 5507 | for (i = 0; i < entries; i++) { |
| 5508 | pid_match = wwn_match = 0; |
| 5509 | |
| 5510 | if (!(pri_entry->flags & FCP_PRIO_ENTRY_VALID)) { |
| 5511 | pri_entry++; |
| 5512 | continue; |
| 5513 | } |
| 5514 | |
| 5515 | /* check source pid for a match */ |
| 5516 | if (pri_entry->flags & FCP_PRIO_ENTRY_SPID_VALID) { |
| 5517 | pid1 = pri_entry->src_pid & INVALID_PORT_ID; |
| 5518 | pid2 = vha->d_id.b24 & INVALID_PORT_ID; |
| 5519 | if (pid1 == INVALID_PORT_ID) |
| 5520 | pid_match++; |
| 5521 | else if (pid1 == pid2) |
| 5522 | pid_match++; |
| 5523 | } |
| 5524 | |
| 5525 | /* check destination pid for a match */ |
| 5526 | if (pri_entry->flags & FCP_PRIO_ENTRY_DPID_VALID) { |
| 5527 | pid1 = pri_entry->dst_pid & INVALID_PORT_ID; |
| 5528 | pid2 = fcport->d_id.b24 & INVALID_PORT_ID; |
| 5529 | if (pid1 == INVALID_PORT_ID) |
| 5530 | pid_match++; |
| 5531 | else if (pid1 == pid2) |
| 5532 | pid_match++; |
| 5533 | } |
| 5534 | |
| 5535 | /* check source WWN for a match */ |
| 5536 | if (pri_entry->flags & FCP_PRIO_ENTRY_SWWN_VALID) { |
| 5537 | wwn1 = wwn_to_u64(vha->port_name); |
| 5538 | wwn2 = wwn_to_u64(pri_entry->src_wwpn); |
| 5539 | if (wwn2 == (uint64_t)-1) |
| 5540 | wwn_match++; |
| 5541 | else if (wwn1 == wwn2) |
| 5542 | wwn_match++; |
| 5543 | } |
| 5544 | |
| 5545 | /* check destination WWN for a match */ |
| 5546 | if (pri_entry->flags & FCP_PRIO_ENTRY_DWWN_VALID) { |
| 5547 | wwn1 = wwn_to_u64(fcport->port_name); |
| 5548 | wwn2 = wwn_to_u64(pri_entry->dst_wwpn); |
| 5549 | if (wwn2 == (uint64_t)-1) |
| 5550 | wwn_match++; |
| 5551 | else if (wwn1 == wwn2) |
| 5552 | wwn_match++; |
| 5553 | } |
| 5554 | |
| 5555 | if (pid_match == 2 || wwn_match == 2) { |
| 5556 | /* Found a matching entry */ |
| 5557 | if (pri_entry->flags & FCP_PRIO_ENTRY_TAG_VALID) |
| 5558 | priority = pri_entry->tag; |
| 5559 | break; |
| 5560 | } |
| 5561 | |
| 5562 | pri_entry++; |
| 5563 | } |
| 5564 | |
| 5565 | return priority; |
| 5566 | } |
| 5567 | |
| 5568 | /* |
| 5569 | * qla24xx_update_fcport_fcp_prio |
| 5570 | * Activates fcp priority for the logged in fc port |
| 5571 | * |
| 5572 | * Input: |
Madhuranath Iyengar | 21090cb | 2010-12-21 16:00:18 -0800 | [diff] [blame] | 5573 | * vha = scsi host structure pointer. |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5574 | * fcp = port structure pointer. |
| 5575 | * |
| 5576 | * Return: |
| 5577 | * QLA_SUCCESS or QLA_FUNCTION_FAILED |
| 5578 | * |
| 5579 | * Context: |
| 5580 | * Kernel context. |
| 5581 | */ |
| 5582 | int |
Madhuranath Iyengar | 21090cb | 2010-12-21 16:00:18 -0800 | [diff] [blame] | 5583 | 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] | 5584 | { |
| 5585 | int ret; |
Andrew Vasquez | f28a0a9 | 2011-03-30 11:46:18 -0700 | [diff] [blame] | 5586 | int priority; |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5587 | uint16_t mb[5]; |
| 5588 | |
Madhuranath Iyengar | 21090cb | 2010-12-21 16:00:18 -0800 | [diff] [blame] | 5589 | if (fcport->port_type != FCT_TARGET || |
| 5590 | fcport->loop_id == FC_NO_LOOP_ID) |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5591 | return QLA_FUNCTION_FAILED; |
| 5592 | |
Madhuranath Iyengar | 21090cb | 2010-12-21 16:00:18 -0800 | [diff] [blame] | 5593 | priority = qla24xx_get_fcp_prio(vha, fcport); |
Andrew Vasquez | f28a0a9 | 2011-03-30 11:46:18 -0700 | [diff] [blame] | 5594 | if (priority < 0) |
| 5595 | return QLA_FUNCTION_FAILED; |
| 5596 | |
Saurav Kashyap | a00f629 | 2011-11-18 09:03:19 -0800 | [diff] [blame] | 5597 | if (IS_QLA82XX(vha->hw)) { |
| 5598 | fcport->fcp_prio = priority & 0xf; |
| 5599 | return QLA_SUCCESS; |
| 5600 | } |
| 5601 | |
Madhuranath Iyengar | 21090cb | 2010-12-21 16:00:18 -0800 | [diff] [blame] | 5602 | ret = qla24xx_set_fcp_prio(vha, fcport->loop_id, priority, mb); |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5603 | if (ret == QLA_SUCCESS) { |
| 5604 | if (fcport->fcp_prio != priority) |
| 5605 | ql_dbg(ql_dbg_user, vha, 0x709e, |
| 5606 | "Updated FCP_CMND priority - value=%d loop_id=%d " |
| 5607 | "port_id=%02x%02x%02x.\n", priority, |
| 5608 | fcport->loop_id, fcport->d_id.b.domain, |
| 5609 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Saurav Kashyap | a00f629 | 2011-11-18 09:03:19 -0800 | [diff] [blame] | 5610 | fcport->fcp_prio = priority & 0xf; |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5611 | } else |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5612 | ql_dbg(ql_dbg_user, vha, 0x704f, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 5613 | "Unable to update FCP_CMND priority - ret=0x%x for " |
| 5614 | "loop_id=%d port_id=%02x%02x%02x.\n", ret, fcport->loop_id, |
| 5615 | fcport->d_id.b.domain, fcport->d_id.b.area, |
| 5616 | fcport->d_id.b.al_pa); |
Sarang Radke | 09ff701 | 2010-03-19 17:03:59 -0700 | [diff] [blame] | 5617 | return ret; |
| 5618 | } |
| 5619 | |
| 5620 | /* |
| 5621 | * qla24xx_update_all_fcp_prio |
| 5622 | * Activates fcp priority for all the logged in ports |
| 5623 | * |
| 5624 | * Input: |
| 5625 | * ha = adapter block pointer. |
| 5626 | * |
| 5627 | * Return: |
| 5628 | * QLA_SUCCESS or QLA_FUNCTION_FAILED |
| 5629 | * |
| 5630 | * Context: |
| 5631 | * Kernel context. |
| 5632 | */ |
| 5633 | int |
| 5634 | qla24xx_update_all_fcp_prio(scsi_qla_host_t *vha) |
| 5635 | { |
| 5636 | int ret; |
| 5637 | fc_port_t *fcport; |
| 5638 | |
| 5639 | ret = QLA_FUNCTION_FAILED; |
| 5640 | /* We need to set priority for all logged in ports */ |
| 5641 | list_for_each_entry(fcport, &vha->vp_fcports, list) |
| 5642 | ret = qla24xx_update_fcport_fcp_prio(vha, fcport); |
| 5643 | |
| 5644 | return ret; |
| 5645 | } |