| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1 | /******************************************************************* |
| 2 | * This file is part of the Emulex Linux Device Driver for * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 3 | * Fibre Channel Host Bus Adapters. * |
James Smart | 9413aff | 2007-04-25 09:53:35 -0400 | [diff] [blame] | 4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 5 | * EMULEX and SLI are trademarks of Emulex. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6 | * www.emulex.com * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 8 | * * |
| 9 | * This program is free software; you can redistribute it and/or * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 10 | * modify it under the terms of version 2 of the GNU General * |
| 11 | * Public License as published by the Free Software Foundation. * |
| 12 | * This program is distributed in the hope that it will be useful. * |
| 13 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * |
| 14 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * |
| 16 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * |
| 17 | * TO BE LEGALLY INVALID. See the GNU General Public License for * |
| 18 | * more details, a copy of which can be found in the file COPYING * |
| 19 | * included with this package. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 20 | *******************************************************************/ |
| 21 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 22 | #include <linux/pci.h> |
| 23 | #include <linux/interrupt.h> |
James Smart | a90f568 | 2006-08-17 11:58:04 -0400 | [diff] [blame] | 24 | #include <linux/delay.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 25 | |
| 26 | #include <scsi/scsi.h> |
| 27 | #include <scsi/scsi_device.h> |
| 28 | #include <scsi/scsi_host.h> |
| 29 | #include <scsi/scsi_tcq.h> |
| 30 | #include <scsi/scsi_transport_fc.h> |
| 31 | |
| 32 | #include "lpfc_version.h" |
| 33 | #include "lpfc_hw.h" |
| 34 | #include "lpfc_sli.h" |
| 35 | #include "lpfc_disc.h" |
| 36 | #include "lpfc_scsi.h" |
| 37 | #include "lpfc.h" |
| 38 | #include "lpfc_logmsg.h" |
| 39 | #include "lpfc_crtn.h" |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 40 | #include "lpfc_vport.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 41 | |
| 42 | #define LPFC_RESET_WAIT 2 |
| 43 | #define LPFC_ABORT_WAIT 2 |
| 44 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 45 | /* |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 46 | * This function is called with no lock held when there is a resource |
| 47 | * error in driver or in firmware. |
| 48 | */ |
| 49 | void |
| 50 | lpfc_adjust_queue_depth(struct lpfc_hba *phba) |
| 51 | { |
| 52 | unsigned long flags; |
| 53 | |
| 54 | spin_lock_irqsave(&phba->hbalock, flags); |
| 55 | atomic_inc(&phba->num_rsrc_err); |
| 56 | phba->last_rsrc_error_time = jiffies; |
| 57 | |
| 58 | if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) { |
| 59 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| 60 | return; |
| 61 | } |
| 62 | |
| 63 | phba->last_ramp_down_time = jiffies; |
| 64 | |
| 65 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| 66 | |
| 67 | spin_lock_irqsave(&phba->pport->work_port_lock, flags); |
| 68 | if ((phba->pport->work_port_events & |
| 69 | WORKER_RAMP_DOWN_QUEUE) == 0) { |
| 70 | phba->pport->work_port_events |= WORKER_RAMP_DOWN_QUEUE; |
| 71 | } |
| 72 | spin_unlock_irqrestore(&phba->pport->work_port_lock, flags); |
| 73 | |
| 74 | spin_lock_irqsave(&phba->hbalock, flags); |
| 75 | if (phba->work_wait) |
| 76 | wake_up(phba->work_wait); |
| 77 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| 78 | |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | /* |
| 83 | * This function is called with no lock held when there is a successful |
| 84 | * SCSI command completion. |
| 85 | */ |
| 86 | static inline void |
| 87 | lpfc_rampup_queue_depth(struct lpfc_hba *phba, |
| 88 | struct scsi_device *sdev) |
| 89 | { |
| 90 | unsigned long flags; |
| 91 | atomic_inc(&phba->num_cmd_success); |
| 92 | |
| 93 | if (phba->cfg_lun_queue_depth <= sdev->queue_depth) |
| 94 | return; |
| 95 | |
| 96 | spin_lock_irqsave(&phba->hbalock, flags); |
| 97 | if (((phba->last_ramp_up_time + QUEUE_RAMP_UP_INTERVAL) > jiffies) || |
| 98 | ((phba->last_rsrc_error_time + QUEUE_RAMP_UP_INTERVAL ) > jiffies)) { |
| 99 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | phba->last_ramp_up_time = jiffies; |
| 104 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| 105 | |
| 106 | spin_lock_irqsave(&phba->pport->work_port_lock, flags); |
| 107 | if ((phba->pport->work_port_events & |
| 108 | WORKER_RAMP_UP_QUEUE) == 0) { |
| 109 | phba->pport->work_port_events |= WORKER_RAMP_UP_QUEUE; |
| 110 | } |
| 111 | spin_unlock_irqrestore(&phba->pport->work_port_lock, flags); |
| 112 | |
| 113 | spin_lock_irqsave(&phba->hbalock, flags); |
| 114 | if (phba->work_wait) |
| 115 | wake_up(phba->work_wait); |
| 116 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| 117 | } |
| 118 | |
| 119 | void |
| 120 | lpfc_ramp_down_queue_handler(struct lpfc_hba *phba) |
| 121 | { |
| 122 | struct lpfc_vport *vport; |
| 123 | struct Scsi_Host *host; |
| 124 | struct scsi_device *sdev; |
| 125 | unsigned long new_queue_depth; |
| 126 | unsigned long num_rsrc_err, num_cmd_success; |
| 127 | |
| 128 | num_rsrc_err = atomic_read(&phba->num_rsrc_err); |
| 129 | num_cmd_success = atomic_read(&phba->num_cmd_success); |
| 130 | |
| 131 | spin_lock_irq(&phba->hbalock); |
| 132 | list_for_each_entry(vport, &phba->port_list, listentry) { |
| 133 | host = lpfc_shost_from_vport(vport); |
| 134 | if (!scsi_host_get(host)) |
| 135 | continue; |
| 136 | |
| 137 | spin_unlock_irq(&phba->hbalock); |
| 138 | |
| 139 | shost_for_each_device(sdev, host) { |
| 140 | new_queue_depth = sdev->queue_depth * num_rsrc_err / |
| 141 | (num_rsrc_err + num_cmd_success); |
| 142 | if (!new_queue_depth) |
| 143 | new_queue_depth = sdev->queue_depth - 1; |
| 144 | else |
| 145 | new_queue_depth = |
| 146 | sdev->queue_depth - new_queue_depth; |
| 147 | |
| 148 | if (sdev->ordered_tags) |
| 149 | scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, |
| 150 | new_queue_depth); |
| 151 | else |
| 152 | scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, |
| 153 | new_queue_depth); |
| 154 | } |
| 155 | spin_lock_irq(&phba->hbalock); |
| 156 | scsi_host_put(host); |
| 157 | } |
| 158 | spin_unlock_irq(&phba->hbalock); |
| 159 | atomic_set(&phba->num_rsrc_err, 0); |
| 160 | atomic_set(&phba->num_cmd_success, 0); |
| 161 | } |
| 162 | |
| 163 | void |
| 164 | lpfc_ramp_up_queue_handler(struct lpfc_hba *phba) |
| 165 | { |
| 166 | struct lpfc_vport *vport; |
| 167 | struct Scsi_Host *host; |
| 168 | struct scsi_device *sdev; |
| 169 | |
| 170 | spin_lock_irq(&phba->hbalock); |
| 171 | list_for_each_entry(vport, &phba->port_list, listentry) { |
| 172 | host = lpfc_shost_from_vport(vport); |
| 173 | if (!scsi_host_get(host)) |
| 174 | continue; |
| 175 | |
| 176 | spin_unlock_irq(&phba->hbalock); |
| 177 | shost_for_each_device(sdev, host) { |
| 178 | if (sdev->ordered_tags) |
| 179 | scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, |
| 180 | sdev->queue_depth+1); |
| 181 | else |
| 182 | scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, |
| 183 | sdev->queue_depth+1); |
| 184 | } |
| 185 | spin_lock_irq(&phba->hbalock); |
| 186 | scsi_host_put(host); |
| 187 | } |
| 188 | spin_unlock_irq(&phba->hbalock); |
| 189 | atomic_set(&phba->num_rsrc_err, 0); |
| 190 | atomic_set(&phba->num_cmd_success, 0); |
| 191 | } |
| 192 | |
| 193 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 194 | * This routine allocates a scsi buffer, which contains all the necessary |
| 195 | * information needed to initiate a SCSI I/O. The non-DMAable buffer region |
| 196 | * contains information to build the IOCB. The DMAable region contains |
| 197 | * memory for the FCP CMND, FCP RSP, and the inital BPL. In addition to |
| 198 | * allocating memeory, the FCP CMND and FCP RSP BDEs are setup in the BPL |
| 199 | * and the BPL BDE is setup in the IOCB. |
| 200 | */ |
| 201 | static struct lpfc_scsi_buf * |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 202 | lpfc_new_scsi_buf(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 203 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 204 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 205 | struct lpfc_scsi_buf *psb; |
| 206 | struct ulp_bde64 *bpl; |
| 207 | IOCB_t *iocb; |
| 208 | dma_addr_t pdma_phys; |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 209 | uint16_t iotag; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 210 | |
| 211 | psb = kmalloc(sizeof(struct lpfc_scsi_buf), GFP_KERNEL); |
| 212 | if (!psb) |
| 213 | return NULL; |
| 214 | memset(psb, 0, sizeof (struct lpfc_scsi_buf)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 215 | |
| 216 | /* |
| 217 | * Get memory from the pci pool to map the virt space to pci bus space |
| 218 | * for an I/O. The DMA buffer includes space for the struct fcp_cmnd, |
| 219 | * struct fcp_rsp and the number of bde's necessary to support the |
| 220 | * sg_tablesize. |
| 221 | */ |
| 222 | psb->data = pci_pool_alloc(phba->lpfc_scsi_dma_buf_pool, GFP_KERNEL, |
| 223 | &psb->dma_handle); |
| 224 | if (!psb->data) { |
| 225 | kfree(psb); |
| 226 | return NULL; |
| 227 | } |
| 228 | |
| 229 | /* Initialize virtual ptrs to dma_buf region. */ |
| 230 | memset(psb->data, 0, phba->cfg_sg_dma_buf_size); |
| 231 | |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 232 | /* Allocate iotag for psb->cur_iocbq. */ |
| 233 | iotag = lpfc_sli_next_iotag(phba, &psb->cur_iocbq); |
| 234 | if (iotag == 0) { |
| 235 | pci_pool_free(phba->lpfc_scsi_dma_buf_pool, |
| 236 | psb->data, psb->dma_handle); |
| 237 | kfree (psb); |
| 238 | return NULL; |
| 239 | } |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 240 | psb->cur_iocbq.iocb_flag |= LPFC_IO_FCP; |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 241 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 242 | psb->fcp_cmnd = psb->data; |
| 243 | psb->fcp_rsp = psb->data + sizeof(struct fcp_cmnd); |
| 244 | psb->fcp_bpl = psb->data + sizeof(struct fcp_cmnd) + |
| 245 | sizeof(struct fcp_rsp); |
| 246 | |
| 247 | /* Initialize local short-hand pointers. */ |
| 248 | bpl = psb->fcp_bpl; |
| 249 | pdma_phys = psb->dma_handle; |
| 250 | |
| 251 | /* |
| 252 | * The first two bdes are the FCP_CMD and FCP_RSP. The balance are sg |
| 253 | * list bdes. Initialize the first two and leave the rest for |
| 254 | * queuecommand. |
| 255 | */ |
| 256 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys)); |
| 257 | bpl->addrLow = le32_to_cpu(putPaddrLow(pdma_phys)); |
| 258 | bpl->tus.f.bdeSize = sizeof (struct fcp_cmnd); |
| 259 | bpl->tus.f.bdeFlags = BUFF_USE_CMND; |
| 260 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 261 | bpl++; |
| 262 | |
| 263 | /* Setup the physical region for the FCP RSP */ |
| 264 | pdma_phys += sizeof (struct fcp_cmnd); |
| 265 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys)); |
| 266 | bpl->addrLow = le32_to_cpu(putPaddrLow(pdma_phys)); |
| 267 | bpl->tus.f.bdeSize = sizeof (struct fcp_rsp); |
| 268 | bpl->tus.f.bdeFlags = (BUFF_USE_CMND | BUFF_USE_RCV); |
| 269 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 270 | |
| 271 | /* |
| 272 | * Since the IOCB for the FCP I/O is built into this lpfc_scsi_buf, |
| 273 | * initialize it with all known data now. |
| 274 | */ |
| 275 | pdma_phys += (sizeof (struct fcp_rsp)); |
| 276 | iocb = &psb->cur_iocbq.iocb; |
| 277 | iocb->un.fcpi64.bdl.ulpIoTag32 = 0; |
| 278 | iocb->un.fcpi64.bdl.addrHigh = putPaddrHigh(pdma_phys); |
| 279 | iocb->un.fcpi64.bdl.addrLow = putPaddrLow(pdma_phys); |
| 280 | iocb->un.fcpi64.bdl.bdeSize = (2 * sizeof (struct ulp_bde64)); |
| 281 | iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BDL; |
| 282 | iocb->ulpBdeCount = 1; |
| 283 | iocb->ulpClass = CLASS3; |
| 284 | |
| 285 | return psb; |
| 286 | } |
| 287 | |
Adrian Bunk | 455c53e | 2006-01-06 20:21:28 +0100 | [diff] [blame] | 288 | static struct lpfc_scsi_buf* |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 289 | lpfc_get_scsi_buf(struct lpfc_hba * phba) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 290 | { |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 291 | struct lpfc_scsi_buf * lpfc_cmd = NULL; |
| 292 | struct list_head *scsi_buf_list = &phba->lpfc_scsi_buf_list; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 293 | unsigned long iflag = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 294 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 295 | spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag); |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 296 | list_remove_head(scsi_buf_list, lpfc_cmd, struct lpfc_scsi_buf, list); |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 297 | if (lpfc_cmd) { |
| 298 | lpfc_cmd->seg_cnt = 0; |
| 299 | lpfc_cmd->nonsg_phys = 0; |
| 300 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 301 | spin_unlock_irqrestore(&phba->scsi_buf_list_lock, iflag); |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 302 | return lpfc_cmd; |
| 303 | } |
| 304 | |
| 305 | static void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 306 | lpfc_release_scsi_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb) |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 307 | { |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 308 | unsigned long iflag = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 309 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 310 | spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag); |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 311 | psb->pCmd = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 312 | list_add_tail(&psb->list, &phba->lpfc_scsi_buf_list); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 313 | spin_unlock_irqrestore(&phba->scsi_buf_list_lock, iflag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | static int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 317 | lpfc_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 318 | { |
| 319 | struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd; |
| 320 | struct scatterlist *sgel = NULL; |
| 321 | struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd; |
| 322 | struct ulp_bde64 *bpl = lpfc_cmd->fcp_bpl; |
| 323 | IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb; |
| 324 | dma_addr_t physaddr; |
| 325 | uint32_t i, num_bde = 0; |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 326 | int nseg, datadir = scsi_cmnd->sc_data_direction; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 327 | |
| 328 | /* |
| 329 | * There are three possibilities here - use scatter-gather segment, use |
| 330 | * the single mapping, or neither. Start the lpfc command prep by |
| 331 | * bumping the bpl beyond the fcp_cmnd and fcp_rsp regions to the first |
| 332 | * data bde entry. |
| 333 | */ |
| 334 | bpl += 2; |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 335 | nseg = scsi_dma_map(scsi_cmnd); |
| 336 | if (nseg > 0) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 337 | /* |
| 338 | * The driver stores the segment count returned from pci_map_sg |
| 339 | * because this a count of dma-mappings used to map the use_sg |
| 340 | * pages. They are not guaranteed to be the same for those |
| 341 | * architectures that implement an IOMMU. |
| 342 | */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 343 | |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 344 | lpfc_cmd->seg_cnt = nseg; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 345 | if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) { |
| 346 | printk(KERN_ERR "%s: Too many sg segments from " |
| 347 | "dma_map_sg. Config %d, seg_cnt %d", |
| 348 | __FUNCTION__, phba->cfg_sg_seg_cnt, |
| 349 | lpfc_cmd->seg_cnt); |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 350 | scsi_dma_unmap(scsi_cmnd); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 351 | return 1; |
| 352 | } |
| 353 | |
| 354 | /* |
| 355 | * The driver established a maximum scatter-gather segment count |
| 356 | * during probe that limits the number of sg elements in any |
| 357 | * single scsi command. Just run through the seg_cnt and format |
| 358 | * the bde's. |
| 359 | */ |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 360 | scsi_for_each_sg(scsi_cmnd, sgel, nseg, i) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 361 | physaddr = sg_dma_address(sgel); |
| 362 | bpl->addrLow = le32_to_cpu(putPaddrLow(physaddr)); |
| 363 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(physaddr)); |
| 364 | bpl->tus.f.bdeSize = sg_dma_len(sgel); |
| 365 | if (datadir == DMA_TO_DEVICE) |
| 366 | bpl->tus.f.bdeFlags = 0; |
| 367 | else |
| 368 | bpl->tus.f.bdeFlags = BUFF_USE_RCV; |
| 369 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 370 | bpl++; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 371 | num_bde++; |
| 372 | } |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 373 | } else if (nseg < 0) |
| 374 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 375 | |
| 376 | /* |
| 377 | * Finish initializing those IOCB fields that are dependent on the |
James.Smart@Emulex.Com | 483f05f | 2005-08-10 15:02:45 -0400 | [diff] [blame] | 378 | * scsi_cmnd request_buffer. Note that the bdeSize is explicitly |
| 379 | * reinitialized since all iocb memory resources are used many times |
| 380 | * for transmit, receive, and continuation bpl's. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 381 | */ |
James.Smart@Emulex.Com | 483f05f | 2005-08-10 15:02:45 -0400 | [diff] [blame] | 382 | iocb_cmd->un.fcpi64.bdl.bdeSize = (2 * sizeof (struct ulp_bde64)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 383 | iocb_cmd->un.fcpi64.bdl.bdeSize += |
| 384 | (num_bde * sizeof (struct ulp_bde64)); |
| 385 | iocb_cmd->ulpBdeCount = 1; |
| 386 | iocb_cmd->ulpLe = 1; |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 387 | fcp_cmnd->fcpDl = be32_to_cpu(scsi_bufflen(scsi_cmnd)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 388 | return 0; |
| 389 | } |
| 390 | |
| 391 | static void |
James Smart | bcf4dbf | 2006-07-06 15:50:08 -0400 | [diff] [blame] | 392 | lpfc_scsi_unprep_dma_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb) |
| 393 | { |
| 394 | /* |
| 395 | * There are only two special cases to consider. (1) the scsi command |
| 396 | * requested scatter-gather usage or (2) the scsi command allocated |
| 397 | * a request buffer, but did not request use_sg. There is a third |
| 398 | * case, but it does not require resource deallocation. |
| 399 | */ |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 400 | if (psb->seg_cnt > 0) |
| 401 | scsi_dma_unmap(psb->pCmd); |
James Smart | bcf4dbf | 2006-07-06 15:50:08 -0400 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 405 | lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, |
| 406 | struct lpfc_iocbq *rsp_iocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 407 | { |
| 408 | struct scsi_cmnd *cmnd = lpfc_cmd->pCmd; |
| 409 | struct fcp_cmnd *fcpcmd = lpfc_cmd->fcp_cmnd; |
| 410 | struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 411 | struct lpfc_hba *phba = vport->phba; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 412 | uint32_t fcpi_parm = rsp_iocb->iocb.un.fcpi.fcpi_parm; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 413 | uint32_t vpi = vport->vpi; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 414 | uint32_t resp_info = fcprsp->rspStatus2; |
| 415 | uint32_t scsi_status = fcprsp->rspStatus3; |
James Smart | c774395 | 2006-12-02 13:34:42 -0500 | [diff] [blame] | 416 | uint32_t *lp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 417 | uint32_t host_status = DID_OK; |
| 418 | uint32_t rsplen = 0; |
James Smart | c774395 | 2006-12-02 13:34:42 -0500 | [diff] [blame] | 419 | uint32_t logit = LOG_FCP | LOG_FCP_ERROR; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 420 | |
| 421 | /* |
| 422 | * If this is a task management command, there is no |
| 423 | * scsi packet associated with this lpfc_cmd. The driver |
| 424 | * consumes it. |
| 425 | */ |
| 426 | if (fcpcmd->fcpCntl2) { |
| 427 | scsi_status = 0; |
| 428 | goto out; |
| 429 | } |
| 430 | |
James Smart | c774395 | 2006-12-02 13:34:42 -0500 | [diff] [blame] | 431 | if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) { |
| 432 | uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen); |
| 433 | if (snslen > SCSI_SENSE_BUFFERSIZE) |
| 434 | snslen = SCSI_SENSE_BUFFERSIZE; |
| 435 | |
| 436 | if (resp_info & RSP_LEN_VALID) |
| 437 | rsplen = be32_to_cpu(fcprsp->rspRspLen); |
| 438 | memcpy(cmnd->sense_buffer, &fcprsp->rspInfo0 + rsplen, snslen); |
| 439 | } |
| 440 | lp = (uint32_t *)cmnd->sense_buffer; |
| 441 | |
| 442 | if (!scsi_status && (resp_info & RESID_UNDER)) |
| 443 | logit = LOG_FCP; |
| 444 | |
| 445 | lpfc_printf_log(phba, KERN_WARNING, logit, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 446 | "%d (%d):0730 FCP command x%x failed: x%x SNS x%x x%x " |
James Smart | c774395 | 2006-12-02 13:34:42 -0500 | [diff] [blame] | 447 | "Data: x%x x%x x%x x%x x%x\n", |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 448 | phba->brd_no, vpi, cmnd->cmnd[0], scsi_status, |
James Smart | c774395 | 2006-12-02 13:34:42 -0500 | [diff] [blame] | 449 | be32_to_cpu(*lp), be32_to_cpu(*(lp + 3)), resp_info, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 450 | be32_to_cpu(fcprsp->rspResId), |
| 451 | be32_to_cpu(fcprsp->rspSnsLen), |
| 452 | be32_to_cpu(fcprsp->rspRspLen), |
| 453 | fcprsp->rspInfo3); |
| 454 | |
| 455 | if (resp_info & RSP_LEN_VALID) { |
| 456 | rsplen = be32_to_cpu(fcprsp->rspRspLen); |
| 457 | if ((rsplen != 0 && rsplen != 4 && rsplen != 8) || |
| 458 | (fcprsp->rspInfo3 != RSP_NO_FAILURE)) { |
| 459 | host_status = DID_ERROR; |
| 460 | goto out; |
| 461 | } |
| 462 | } |
| 463 | |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 464 | scsi_set_resid(cmnd, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 465 | if (resp_info & RESID_UNDER) { |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 466 | scsi_set_resid(cmnd, be32_to_cpu(fcprsp->rspResId)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 467 | |
| 468 | lpfc_printf_log(phba, KERN_INFO, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 469 | "%d (%d):0716 FCP Read Underrun, expected %d, " |
| 470 | "residual %d Data: x%x x%x x%x\n", |
| 471 | phba->brd_no, vpi, be32_to_cpu(fcpcmd->fcpDl), |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 472 | scsi_get_resid(cmnd), fcpi_parm, cmnd->cmnd[0], |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 473 | cmnd->underflow); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 474 | |
| 475 | /* |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 476 | * If there is an under run check if under run reported by |
| 477 | * storage array is same as the under run reported by HBA. |
| 478 | * If this is not same, there is a dropped frame. |
| 479 | */ |
| 480 | if ((cmnd->sc_data_direction == DMA_FROM_DEVICE) && |
| 481 | fcpi_parm && |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 482 | (scsi_get_resid(cmnd) != fcpi_parm)) { |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 483 | lpfc_printf_log(phba, KERN_WARNING, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 484 | LOG_FCP | LOG_FCP_ERROR, |
| 485 | "%d (%d):0735 FCP Read Check Error " |
| 486 | "and Underrun Data: x%x x%x x%x x%x\n", |
| 487 | phba->brd_no, vpi, |
| 488 | be32_to_cpu(fcpcmd->fcpDl), |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 489 | scsi_get_resid(cmnd), fcpi_parm, |
| 490 | cmnd->cmnd[0]); |
| 491 | scsi_set_resid(cmnd, scsi_bufflen(cmnd)); |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 492 | host_status = DID_ERROR; |
| 493 | } |
| 494 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 495 | * The cmnd->underflow is the minimum number of bytes that must |
| 496 | * be transfered for this command. Provided a sense condition |
| 497 | * is not present, make sure the actual amount transferred is at |
| 498 | * least the underflow value or fail. |
| 499 | */ |
| 500 | if (!(resp_info & SNS_LEN_VALID) && |
| 501 | (scsi_status == SAM_STAT_GOOD) && |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 502 | (scsi_bufflen(cmnd) - scsi_get_resid(cmnd) |
| 503 | < cmnd->underflow)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 504 | lpfc_printf_log(phba, KERN_INFO, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 505 | "%d (%d):0717 FCP command x%x residual " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 506 | "underrun converted to error " |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 507 | "Data: x%x x%x x%x\n", |
| 508 | phba->brd_no, vpi, cmnd->cmnd[0], |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 509 | cmnd->request_bufflen, |
| 510 | scsi_get_resid(cmnd), cmnd->underflow); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 511 | host_status = DID_ERROR; |
| 512 | } |
| 513 | } else if (resp_info & RESID_OVER) { |
| 514 | lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 515 | "%d (%d):0720 FCP command x%x residual " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 516 | "overrun error. Data: x%x x%x \n", |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 517 | phba->brd_no, vpi, cmnd->cmnd[0], |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 518 | scsi_bufflen(cmnd), scsi_get_resid(cmnd)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 519 | host_status = DID_ERROR; |
| 520 | |
| 521 | /* |
| 522 | * Check SLI validation that all the transfer was actually done |
| 523 | * (fcpi_parm should be zero). Apply check only to reads. |
| 524 | */ |
| 525 | } else if ((scsi_status == SAM_STAT_GOOD) && fcpi_parm && |
| 526 | (cmnd->sc_data_direction == DMA_FROM_DEVICE)) { |
James Smart | c774395 | 2006-12-02 13:34:42 -0500 | [diff] [blame] | 527 | lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_FCP_ERROR, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 528 | "%d (%d):0734 FCP Read Check Error Data: " |
| 529 | "x%x x%x x%x x%x\n", |
| 530 | phba->brd_no, vpi, |
| 531 | be32_to_cpu(fcpcmd->fcpDl), |
| 532 | be32_to_cpu(fcprsp->rspResId), |
| 533 | fcpi_parm, cmnd->cmnd[0]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 534 | host_status = DID_ERROR; |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 535 | scsi_set_resid(cmnd, scsi_bufflen(cmnd)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | out: |
| 539 | cmnd->result = ScsiResult(host_status, scsi_status); |
| 540 | } |
| 541 | |
| 542 | static void |
| 543 | lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, |
| 544 | struct lpfc_iocbq *pIocbOut) |
| 545 | { |
| 546 | struct lpfc_scsi_buf *lpfc_cmd = |
| 547 | (struct lpfc_scsi_buf *) pIocbIn->context1; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 548 | struct lpfc_vport *vport = pIocbIn->vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 549 | struct lpfc_rport_data *rdata = lpfc_cmd->rdata; |
| 550 | struct lpfc_nodelist *pnode = rdata->pnode; |
| 551 | struct scsi_cmnd *cmd = lpfc_cmd->pCmd; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 552 | uint32_t vpi = (lpfc_cmd->cur_iocbq.vport |
| 553 | ? lpfc_cmd->cur_iocbq.vport->vpi |
| 554 | : 0); |
James.Smart@Emulex.Com | 445cf4f | 2005-11-28 11:42:38 -0500 | [diff] [blame] | 555 | int result; |
| 556 | struct scsi_device *sdev, *tmp_sdev; |
| 557 | int depth = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 558 | |
| 559 | lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4]; |
| 560 | lpfc_cmd->status = pIocbOut->iocb.ulpStatus; |
| 561 | |
| 562 | if (lpfc_cmd->status) { |
| 563 | if (lpfc_cmd->status == IOSTAT_LOCAL_REJECT && |
| 564 | (lpfc_cmd->result & IOERR_DRVR_MASK)) |
| 565 | lpfc_cmd->status = IOSTAT_DRIVER_REJECT; |
| 566 | else if (lpfc_cmd->status >= IOSTAT_CNT) |
| 567 | lpfc_cmd->status = IOSTAT_DEFAULT; |
| 568 | |
| 569 | lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 570 | "%d (%d):0729 FCP cmd x%x failed <%d/%d> " |
| 571 | "status: x%x result: x%x Data: x%x x%x\n", |
| 572 | phba->brd_no, vpi, cmd->cmnd[0], |
| 573 | cmd->device ? cmd->device->id : 0xffff, |
| 574 | cmd->device ? cmd->device->lun : 0xffff, |
| 575 | lpfc_cmd->status, lpfc_cmd->result, |
| 576 | pIocbOut->iocb.ulpContext, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 577 | lpfc_cmd->cur_iocbq.iocb.ulpIoTag); |
| 578 | |
| 579 | switch (lpfc_cmd->status) { |
| 580 | case IOSTAT_FCP_RSP_ERROR: |
| 581 | /* Call FCP RSP handler to determine result */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 582 | lpfc_handle_fcp_err(vport, lpfc_cmd, pIocbOut); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 583 | break; |
| 584 | case IOSTAT_NPORT_BSY: |
| 585 | case IOSTAT_FABRIC_BSY: |
| 586 | cmd->result = ScsiResult(DID_BUS_BUSY, 0); |
| 587 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 588 | case IOSTAT_LOCAL_REJECT: |
| 589 | if (lpfc_cmd->result == RJT_UNAVAIL_PERM || |
| 590 | lpfc_cmd->result == IOERR_NO_RESOURCES || |
| 591 | lpfc_cmd->result == RJT_LOGIN_REQUIRED) { |
| 592 | cmd->result = ScsiResult(DID_REQUEUE, 0); |
| 593 | break; |
| 594 | } /* else: fall through */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 595 | default: |
| 596 | cmd->result = ScsiResult(DID_ERROR, 0); |
| 597 | break; |
| 598 | } |
| 599 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 600 | if ((pnode == NULL ) |
| 601 | || (pnode->nlp_state != NLP_STE_MAPPED_NODE)) |
| 602 | cmd->result = ScsiResult(DID_BUS_BUSY, SAM_STAT_BUSY); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 603 | } else { |
| 604 | cmd->result = ScsiResult(DID_OK, 0); |
| 605 | } |
| 606 | |
| 607 | if (cmd->result || lpfc_cmd->fcp_rsp->rspSnsLen) { |
| 608 | uint32_t *lp = (uint32_t *)cmd->sense_buffer; |
| 609 | |
| 610 | lpfc_printf_log(phba, KERN_INFO, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 611 | "%d (%d):0710 Iodone <%d/%d> cmd %p, error " |
| 612 | "x%x SNS x%x x%x Data: x%x x%x\n", |
| 613 | phba->brd_no, vpi, cmd->device->id, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 614 | cmd->device->lun, cmd, cmd->result, |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 615 | *lp, *(lp + 3), cmd->retries, |
| 616 | scsi_get_resid(cmd)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 617 | } |
| 618 | |
James.Smart@Emulex.Com | 445cf4f | 2005-11-28 11:42:38 -0500 | [diff] [blame] | 619 | result = cmd->result; |
| 620 | sdev = cmd->device; |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 621 | lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 622 | cmd->scsi_done(cmd); |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 623 | |
Jamie Wellnitz | b808608 | 2006-02-28 22:33:12 -0500 | [diff] [blame] | 624 | if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { |
| 625 | lpfc_release_scsi_buf(phba, lpfc_cmd); |
| 626 | return; |
| 627 | } |
| 628 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 629 | |
| 630 | if (!result) |
| 631 | lpfc_rampup_queue_depth(phba, sdev); |
| 632 | |
Jamie Wellnitz | 0c6ac8e | 2006-02-28 19:25:36 -0500 | [diff] [blame] | 633 | if (!result && pnode != NULL && |
James.Smart@Emulex.Com | 445cf4f | 2005-11-28 11:42:38 -0500 | [diff] [blame] | 634 | ((jiffies - pnode->last_ramp_up_time) > |
| 635 | LPFC_Q_RAMP_UP_INTERVAL * HZ) && |
| 636 | ((jiffies - pnode->last_q_full_time) > |
| 637 | LPFC_Q_RAMP_UP_INTERVAL * HZ) && |
| 638 | (phba->cfg_lun_queue_depth > sdev->queue_depth)) { |
| 639 | shost_for_each_device(tmp_sdev, sdev->host) { |
| 640 | if (phba->cfg_lun_queue_depth > tmp_sdev->queue_depth) { |
| 641 | if (tmp_sdev->id != sdev->id) |
| 642 | continue; |
| 643 | if (tmp_sdev->ordered_tags) |
| 644 | scsi_adjust_queue_depth(tmp_sdev, |
| 645 | MSG_ORDERED_TAG, |
| 646 | tmp_sdev->queue_depth+1); |
| 647 | else |
| 648 | scsi_adjust_queue_depth(tmp_sdev, |
| 649 | MSG_SIMPLE_TAG, |
| 650 | tmp_sdev->queue_depth+1); |
| 651 | |
| 652 | pnode->last_ramp_up_time = jiffies; |
| 653 | } |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | /* |
| 658 | * Check for queue full. If the lun is reporting queue full, then |
| 659 | * back off the lun queue depth to prevent target overloads. |
| 660 | */ |
Jamie Wellnitz | 0c6ac8e | 2006-02-28 19:25:36 -0500 | [diff] [blame] | 661 | if (result == SAM_STAT_TASK_SET_FULL && pnode != NULL) { |
James.Smart@Emulex.Com | 445cf4f | 2005-11-28 11:42:38 -0500 | [diff] [blame] | 662 | pnode->last_q_full_time = jiffies; |
| 663 | |
| 664 | shost_for_each_device(tmp_sdev, sdev->host) { |
| 665 | if (tmp_sdev->id != sdev->id) |
| 666 | continue; |
| 667 | depth = scsi_track_queue_full(tmp_sdev, |
| 668 | tmp_sdev->queue_depth - 1); |
| 669 | } |
| 670 | /* |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 671 | * The queue depth cannot be lowered any more. |
James.Smart@Emulex.Com | 445cf4f | 2005-11-28 11:42:38 -0500 | [diff] [blame] | 672 | * Modify the returned error code to store |
| 673 | * the final depth value set by |
| 674 | * scsi_track_queue_full. |
| 675 | */ |
| 676 | if (depth == -1) |
| 677 | depth = sdev->host->cmd_per_lun; |
| 678 | |
| 679 | if (depth) { |
| 680 | lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 681 | "%d (%d):0711 detected queue full - " |
| 682 | "lun queue depth adjusted to %d.\n", |
| 683 | phba->brd_no, vpi, depth); |
James.Smart@Emulex.Com | 445cf4f | 2005-11-28 11:42:38 -0500 | [diff] [blame] | 684 | } |
| 685 | } |
| 686 | |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 687 | lpfc_release_scsi_buf(phba, lpfc_cmd); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 691 | lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, |
| 692 | struct lpfc_nodelist *pnode) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 693 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 694 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 695 | struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd; |
| 696 | struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd; |
| 697 | IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb; |
| 698 | struct lpfc_iocbq *piocbq = &(lpfc_cmd->cur_iocbq); |
| 699 | int datadir = scsi_cmnd->sc_data_direction; |
| 700 | |
| 701 | lpfc_cmd->fcp_rsp->rspSnsLen = 0; |
James.Smart@Emulex.Com | 69859dc | 2005-08-10 15:02:37 -0400 | [diff] [blame] | 702 | /* clear task management bits */ |
| 703 | lpfc_cmd->fcp_cmnd->fcpCntl2 = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 704 | |
James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 705 | int_to_scsilun(lpfc_cmd->pCmd->device->lun, |
| 706 | &lpfc_cmd->fcp_cmnd->fcp_lun); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 707 | |
| 708 | memcpy(&fcp_cmnd->fcpCdb[0], scsi_cmnd->cmnd, 16); |
| 709 | |
| 710 | if (scsi_cmnd->device->tagged_supported) { |
| 711 | switch (scsi_cmnd->tag) { |
| 712 | case HEAD_OF_QUEUE_TAG: |
| 713 | fcp_cmnd->fcpCntl1 = HEAD_OF_Q; |
| 714 | break; |
| 715 | case ORDERED_QUEUE_TAG: |
| 716 | fcp_cmnd->fcpCntl1 = ORDERED_Q; |
| 717 | break; |
| 718 | default: |
| 719 | fcp_cmnd->fcpCntl1 = SIMPLE_Q; |
| 720 | break; |
| 721 | } |
| 722 | } else |
| 723 | fcp_cmnd->fcpCntl1 = 0; |
| 724 | |
| 725 | /* |
| 726 | * There are three possibilities here - use scatter-gather segment, use |
| 727 | * the single mapping, or neither. Start the lpfc command prep by |
| 728 | * bumping the bpl beyond the fcp_cmnd and fcp_rsp regions to the first |
| 729 | * data bde entry. |
| 730 | */ |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 731 | if (scsi_sg_count(scsi_cmnd)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 732 | if (datadir == DMA_TO_DEVICE) { |
| 733 | iocb_cmd->ulpCommand = CMD_FCP_IWRITE64_CR; |
| 734 | iocb_cmd->un.fcpi.fcpi_parm = 0; |
| 735 | iocb_cmd->ulpPU = 0; |
| 736 | fcp_cmnd->fcpCntl3 = WRITE_DATA; |
| 737 | phba->fc4OutputRequests++; |
| 738 | } else { |
| 739 | iocb_cmd->ulpCommand = CMD_FCP_IREAD64_CR; |
| 740 | iocb_cmd->ulpPU = PARM_READ_CHECK; |
FUJITA Tomonori | a0b4f78 | 2007-06-17 19:56:39 -0500 | [diff] [blame^] | 741 | iocb_cmd->un.fcpi.fcpi_parm = scsi_bufflen(scsi_cmnd); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 742 | fcp_cmnd->fcpCntl3 = READ_DATA; |
| 743 | phba->fc4InputRequests++; |
| 744 | } |
| 745 | } else { |
| 746 | iocb_cmd->ulpCommand = CMD_FCP_ICMND64_CR; |
| 747 | iocb_cmd->un.fcpi.fcpi_parm = 0; |
| 748 | iocb_cmd->ulpPU = 0; |
| 749 | fcp_cmnd->fcpCntl3 = 0; |
| 750 | phba->fc4ControlRequests++; |
| 751 | } |
| 752 | |
| 753 | /* |
| 754 | * Finish initializing those IOCB fields that are independent |
| 755 | * of the scsi_cmnd request_buffer |
| 756 | */ |
| 757 | piocbq->iocb.ulpContext = pnode->nlp_rpi; |
| 758 | if (pnode->nlp_fcp_info & NLP_FCP_2_DEVICE) |
| 759 | piocbq->iocb.ulpFCP2Rcvy = 1; |
| 760 | |
| 761 | piocbq->iocb.ulpClass = (pnode->nlp_fcp_info & 0x0f); |
| 762 | piocbq->context1 = lpfc_cmd; |
| 763 | piocbq->iocb_cmpl = lpfc_scsi_cmd_iocb_cmpl; |
| 764 | piocbq->iocb.ulpTimeout = lpfc_cmd->timeout; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 765 | piocbq->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 769 | lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_vport *vport, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 770 | struct lpfc_scsi_buf *lpfc_cmd, |
James Smart | 420b630d | 2006-07-06 15:50:16 -0400 | [diff] [blame] | 771 | unsigned int lun, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 772 | uint8_t task_mgmt_cmd) |
| 773 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 774 | struct lpfc_iocbq *piocbq; |
| 775 | IOCB_t *piocb; |
| 776 | struct fcp_cmnd *fcp_cmnd; |
James Smart | 0b18ac4 | 2006-05-01 21:50:40 -0400 | [diff] [blame] | 777 | struct lpfc_rport_data *rdata = lpfc_cmd->rdata; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 778 | struct lpfc_nodelist *ndlp = rdata->pnode; |
| 779 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 780 | if ((ndlp == NULL) || (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 781 | return 0; |
| 782 | } |
| 783 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 784 | piocbq = &(lpfc_cmd->cur_iocbq); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 785 | piocbq->vport = vport; |
| 786 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 787 | piocb = &piocbq->iocb; |
| 788 | |
| 789 | fcp_cmnd = lpfc_cmd->fcp_cmnd; |
James Smart | 420b630d | 2006-07-06 15:50:16 -0400 | [diff] [blame] | 790 | int_to_scsilun(lun, &lpfc_cmd->fcp_cmnd->fcp_lun); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 791 | fcp_cmnd->fcpCntl2 = task_mgmt_cmd; |
| 792 | |
| 793 | piocb->ulpCommand = CMD_FCP_ICMND64_CR; |
| 794 | |
| 795 | piocb->ulpContext = ndlp->nlp_rpi; |
| 796 | if (ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) { |
| 797 | piocb->ulpFCP2Rcvy = 1; |
| 798 | } |
| 799 | piocb->ulpClass = (ndlp->nlp_fcp_info & 0x0f); |
| 800 | |
| 801 | /* ulpTimeout is only one byte */ |
| 802 | if (lpfc_cmd->timeout > 0xff) { |
| 803 | /* |
| 804 | * Do not timeout the command at the firmware level. |
| 805 | * The driver will provide the timeout mechanism. |
| 806 | */ |
| 807 | piocb->ulpTimeout = 0; |
| 808 | } else { |
| 809 | piocb->ulpTimeout = lpfc_cmd->timeout; |
| 810 | } |
| 811 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 812 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 813 | } |
| 814 | |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 815 | static void |
| 816 | lpfc_tskmgmt_def_cmpl(struct lpfc_hba *phba, |
| 817 | struct lpfc_iocbq *cmdiocbq, |
| 818 | struct lpfc_iocbq *rspiocbq) |
| 819 | { |
| 820 | struct lpfc_scsi_buf *lpfc_cmd = |
| 821 | (struct lpfc_scsi_buf *) cmdiocbq->context1; |
| 822 | if (lpfc_cmd) |
| 823 | lpfc_release_scsi_buf(phba, lpfc_cmd); |
| 824 | return; |
| 825 | } |
| 826 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 827 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 828 | lpfc_scsi_tgt_reset(struct lpfc_scsi_buf *lpfc_cmd, struct lpfc_vport *vport, |
James Smart | 420b630d | 2006-07-06 15:50:16 -0400 | [diff] [blame] | 829 | unsigned tgt_id, unsigned int lun, |
| 830 | struct lpfc_rport_data *rdata) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 831 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 832 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 833 | struct lpfc_iocbq *iocbq; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 834 | struct lpfc_iocbq *iocbqrsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 835 | int ret; |
| 836 | |
James Smart | f560351 | 2006-12-02 13:35:43 -0500 | [diff] [blame] | 837 | if (!rdata->pnode) |
| 838 | return FAILED; |
| 839 | |
James Smart | 0b18ac4 | 2006-05-01 21:50:40 -0400 | [diff] [blame] | 840 | lpfc_cmd->rdata = rdata; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 841 | ret = lpfc_scsi_prep_task_mgmt_cmd(vport, lpfc_cmd, lun, |
James Smart | 420b630d | 2006-07-06 15:50:16 -0400 | [diff] [blame] | 842 | FCP_TARGET_RESET); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 843 | if (!ret) |
| 844 | return FAILED; |
| 845 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 846 | iocbq = &lpfc_cmd->cur_iocbq; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 847 | iocbqrsp = lpfc_sli_get_iocbq(phba); |
| 848 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 849 | if (!iocbqrsp) |
| 850 | return FAILED; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 851 | |
James Smart | 0b18ac4 | 2006-05-01 21:50:40 -0400 | [diff] [blame] | 852 | /* Issue Target Reset to TGT <num> */ |
| 853 | lpfc_printf_log(phba, KERN_INFO, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 854 | "%d (%d):0702 Issue Target Reset to TGT %d " |
James Smart | 0b18ac4 | 2006-05-01 21:50:40 -0400 | [diff] [blame] | 855 | "Data: x%x x%x\n", |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 856 | phba->brd_no, vport->vpi, tgt_id, |
| 857 | rdata->pnode->nlp_rpi, rdata->pnode->nlp_flag); |
James Smart | 0b18ac4 | 2006-05-01 21:50:40 -0400 | [diff] [blame] | 858 | |
James.Smart@Emulex.Com | 6887692 | 2005-10-28 20:29:47 -0400 | [diff] [blame] | 859 | ret = lpfc_sli_issue_iocb_wait(phba, |
| 860 | &phba->sli.ring[phba->sli.fcp_ring], |
| 861 | iocbq, iocbqrsp, lpfc_cmd->timeout); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 862 | if (ret != IOCB_SUCCESS) { |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 863 | if (ret == IOCB_TIMEDOUT) |
| 864 | iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 865 | lpfc_cmd->status = IOSTAT_DRIVER_REJECT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 866 | } else { |
| 867 | ret = SUCCESS; |
| 868 | lpfc_cmd->result = iocbqrsp->iocb.un.ulpWord[4]; |
| 869 | lpfc_cmd->status = iocbqrsp->iocb.ulpStatus; |
| 870 | if (lpfc_cmd->status == IOSTAT_LOCAL_REJECT && |
| 871 | (lpfc_cmd->result & IOERR_DRVR_MASK)) |
| 872 | lpfc_cmd->status = IOSTAT_DRIVER_REJECT; |
| 873 | } |
| 874 | |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 875 | lpfc_sli_release_iocbq(phba, iocbqrsp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 876 | return ret; |
| 877 | } |
| 878 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 879 | const char * |
| 880 | lpfc_info(struct Scsi_Host *host) |
| 881 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 882 | struct lpfc_vport *vport = (struct lpfc_vport *) host->hostdata; |
| 883 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 884 | int len; |
| 885 | static char lpfcinfobuf[384]; |
| 886 | |
| 887 | memset(lpfcinfobuf,0,384); |
| 888 | if (phba && phba->pcidev){ |
| 889 | strncpy(lpfcinfobuf, phba->ModelDesc, 256); |
| 890 | len = strlen(lpfcinfobuf); |
| 891 | snprintf(lpfcinfobuf + len, |
| 892 | 384-len, |
| 893 | " on PCI bus %02x device %02x irq %d", |
| 894 | phba->pcidev->bus->number, |
| 895 | phba->pcidev->devfn, |
| 896 | phba->pcidev->irq); |
| 897 | len = strlen(lpfcinfobuf); |
| 898 | if (phba->Port[0]) { |
| 899 | snprintf(lpfcinfobuf + len, |
| 900 | 384-len, |
| 901 | " port %s", |
| 902 | phba->Port); |
| 903 | } |
| 904 | } |
| 905 | return lpfcinfobuf; |
| 906 | } |
| 907 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 908 | static __inline__ void lpfc_poll_rearm_timer(struct lpfc_hba * phba) |
| 909 | { |
| 910 | unsigned long poll_tmo_expires = |
| 911 | (jiffies + msecs_to_jiffies(phba->cfg_poll_tmo)); |
| 912 | |
| 913 | if (phba->sli.ring[LPFC_FCP_RING].txcmplq_cnt) |
| 914 | mod_timer(&phba->fcp_poll_timer, |
| 915 | poll_tmo_expires); |
| 916 | } |
| 917 | |
| 918 | void lpfc_poll_start_timer(struct lpfc_hba * phba) |
| 919 | { |
| 920 | lpfc_poll_rearm_timer(phba); |
| 921 | } |
| 922 | |
| 923 | void lpfc_poll_timeout(unsigned long ptr) |
| 924 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 925 | struct lpfc_hba *phba = (struct lpfc_hba *) ptr; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 926 | |
| 927 | if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { |
| 928 | lpfc_sli_poll_fcp_ring (phba); |
| 929 | if (phba->cfg_poll & DISABLE_FCP_RING_INT) |
| 930 | lpfc_poll_rearm_timer(phba); |
| 931 | } |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 932 | } |
| 933 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 934 | static int |
| 935 | lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) |
| 936 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 937 | struct Scsi_Host *shost = cmnd->device->host; |
| 938 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 939 | struct lpfc_hba *phba = vport->phba; |
| 940 | struct lpfc_sli *psli = &phba->sli; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 941 | struct lpfc_rport_data *rdata = cmnd->device->hostdata; |
| 942 | struct lpfc_nodelist *ndlp = rdata->pnode; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 943 | struct lpfc_scsi_buf *lpfc_cmd; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 944 | struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device)); |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 945 | int err; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 946 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 947 | err = fc_remote_port_chkready(rport); |
| 948 | if (err) { |
| 949 | cmnd->result = err; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 950 | goto out_fail_command; |
| 951 | } |
| 952 | |
| 953 | /* |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 954 | * Catch race where our node has transitioned, but the |
| 955 | * transport is still transitioning. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 956 | */ |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 957 | if (!ndlp) { |
| 958 | cmnd->result = ScsiResult(DID_BUS_BUSY, 0); |
| 959 | goto out_fail_command; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 960 | } |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 961 | lpfc_cmd = lpfc_get_scsi_buf(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 962 | if (lpfc_cmd == NULL) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 963 | lpfc_adjust_queue_depth(phba); |
| 964 | |
James.Smart@Emulex.Com | 1de933f | 2005-11-28 11:41:15 -0500 | [diff] [blame] | 965 | lpfc_printf_log(phba, KERN_INFO, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 966 | "%d (%d):0707 driver's buffer pool is empty, " |
| 967 | "IO busied\n", |
| 968 | phba->brd_no, vport->vpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 969 | goto out_host_busy; |
| 970 | } |
| 971 | |
| 972 | /* |
| 973 | * Store the midlayer's command structure for the completion phase |
| 974 | * and complete the command initialization. |
| 975 | */ |
| 976 | lpfc_cmd->pCmd = cmnd; |
| 977 | lpfc_cmd->rdata = rdata; |
| 978 | lpfc_cmd->timeout = 0; |
| 979 | cmnd->host_scribble = (unsigned char *)lpfc_cmd; |
| 980 | cmnd->scsi_done = done; |
| 981 | |
| 982 | err = lpfc_scsi_prep_dma_buf(phba, lpfc_cmd); |
| 983 | if (err) |
| 984 | goto out_host_busy_free_buf; |
| 985 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 986 | lpfc_scsi_prep_cmnd(vport, lpfc_cmd, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 987 | |
| 988 | err = lpfc_sli_issue_iocb(phba, &phba->sli.ring[psli->fcp_ring], |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 989 | &lpfc_cmd->cur_iocbq, SLI_IOCB_RET_IOCB); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 990 | if (err) |
| 991 | goto out_host_busy_free_buf; |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 992 | |
| 993 | if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { |
| 994 | lpfc_sli_poll_fcp_ring(phba); |
| 995 | if (phba->cfg_poll & DISABLE_FCP_RING_INT) |
| 996 | lpfc_poll_rearm_timer(phba); |
| 997 | } |
| 998 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 999 | return 0; |
| 1000 | |
| 1001 | out_host_busy_free_buf: |
James Smart | bcf4dbf | 2006-07-06 15:50:08 -0400 | [diff] [blame] | 1002 | lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd); |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1003 | lpfc_release_scsi_buf(phba, lpfc_cmd); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1004 | out_host_busy: |
| 1005 | return SCSI_MLQUEUE_HOST_BUSY; |
| 1006 | |
| 1007 | out_fail_command: |
| 1008 | done(cmnd); |
| 1009 | return 0; |
| 1010 | } |
| 1011 | |
James Smart | a90f568 | 2006-08-17 11:58:04 -0400 | [diff] [blame] | 1012 | static void |
| 1013 | lpfc_block_error_handler(struct scsi_cmnd *cmnd) |
| 1014 | { |
| 1015 | struct Scsi_Host *shost = cmnd->device->host; |
| 1016 | struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device)); |
| 1017 | |
| 1018 | spin_lock_irq(shost->host_lock); |
| 1019 | while (rport->port_state == FC_PORTSTATE_BLOCKED) { |
| 1020 | spin_unlock_irq(shost->host_lock); |
| 1021 | msleep(1000); |
| 1022 | spin_lock_irq(shost->host_lock); |
| 1023 | } |
| 1024 | spin_unlock_irq(shost->host_lock); |
| 1025 | return; |
| 1026 | } |
James.Smart@Emulex.Com | 63c59c3 | 2005-11-28 11:41:53 -0500 | [diff] [blame] | 1027 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1028 | static int |
James.Smart@Emulex.Com | 63c59c3 | 2005-11-28 11:41:53 -0500 | [diff] [blame] | 1029 | lpfc_abort_handler(struct scsi_cmnd *cmnd) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1030 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1031 | struct Scsi_Host *shost = cmnd->device->host; |
| 1032 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1033 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1034 | struct lpfc_sli_ring *pring = &phba->sli.ring[phba->sli.fcp_ring]; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1035 | struct lpfc_iocbq *iocb; |
| 1036 | struct lpfc_iocbq *abtsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1037 | struct lpfc_scsi_buf *lpfc_cmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1038 | IOCB_t *cmd, *icmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1039 | unsigned int loop_count = 0; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1040 | int ret = SUCCESS; |
| 1041 | |
James Smart | a90f568 | 2006-08-17 11:58:04 -0400 | [diff] [blame] | 1042 | lpfc_block_error_handler(cmnd); |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1043 | lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble; |
| 1044 | BUG_ON(!lpfc_cmd); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1045 | |
| 1046 | /* |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1047 | * If pCmd field of the corresponding lpfc_scsi_buf structure |
| 1048 | * points to a different SCSI command, then the driver has |
| 1049 | * already completed this command, but the midlayer did not |
| 1050 | * see the completion before the eh fired. Just return |
| 1051 | * SUCCESS. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1052 | */ |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1053 | iocb = &lpfc_cmd->cur_iocbq; |
| 1054 | if (lpfc_cmd->pCmd != cmnd) |
| 1055 | goto out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1056 | |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1057 | BUG_ON(iocb->context1 != lpfc_cmd); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1058 | |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1059 | abtsiocb = lpfc_sli_get_iocbq(phba); |
| 1060 | if (abtsiocb == NULL) { |
| 1061 | ret = FAILED; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1062 | goto out; |
| 1063 | } |
| 1064 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1065 | /* |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1066 | * The scsi command can not be in txq and it is in flight because the |
| 1067 | * pCmd is still pointig at the SCSI command we have to abort. There |
| 1068 | * is no need to search the txcmplq. Just send an abort to the FW. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1069 | */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1070 | |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1071 | cmd = &iocb->iocb; |
| 1072 | icmd = &abtsiocb->iocb; |
| 1073 | icmd->un.acxri.abortType = ABORT_TYPE_ABTS; |
| 1074 | icmd->un.acxri.abortContextTag = cmd->ulpContext; |
| 1075 | icmd->un.acxri.abortIoTag = cmd->ulpIoTag; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1076 | |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1077 | icmd->ulpLe = 1; |
| 1078 | icmd->ulpClass = cmd->ulpClass; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1079 | if (lpfc_is_link_up(phba)) |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1080 | icmd->ulpCommand = CMD_ABORT_XRI_CN; |
| 1081 | else |
| 1082 | icmd->ulpCommand = CMD_CLOSE_XRI_CN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1083 | |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1084 | abtsiocb->iocb_cmpl = lpfc_sli_abort_fcp_cmpl; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1085 | abtsiocb->vport = vport; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1086 | if (lpfc_sli_issue_iocb(phba, pring, abtsiocb, 0) == IOCB_ERROR) { |
| 1087 | lpfc_sli_release_iocbq(phba, abtsiocb); |
| 1088 | ret = FAILED; |
| 1089 | goto out; |
| 1090 | } |
| 1091 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1092 | if (phba->cfg_poll & DISABLE_FCP_RING_INT) |
| 1093 | lpfc_sli_poll_fcp_ring (phba); |
| 1094 | |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1095 | /* Wait for abort to complete */ |
| 1096 | while (lpfc_cmd->pCmd == cmnd) |
| 1097 | { |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1098 | if (phba->cfg_poll & DISABLE_FCP_RING_INT) |
| 1099 | lpfc_sli_poll_fcp_ring (phba); |
| 1100 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1101 | schedule_timeout_uninterruptible(LPFC_ABORT_WAIT * HZ); |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1102 | if (++loop_count |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 1103 | > (2 * phba->cfg_devloss_tmo)/LPFC_ABORT_WAIT) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1104 | break; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1105 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1106 | |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1107 | if (lpfc_cmd->pCmd == cmnd) { |
| 1108 | ret = FAILED; |
| 1109 | lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1110 | "%d (%d):0748 abort handler timed out waiting " |
| 1111 | "for abort to complete: ret %#x, ID %d, " |
| 1112 | "LUN %d, snum %#lx\n", |
| 1113 | phba->brd_no, vport->vpi, ret, |
| 1114 | cmnd->device->id, cmnd->device->lun, |
| 1115 | cmnd->serial_number); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1116 | } |
| 1117 | |
| 1118 | out: |
| 1119 | lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1120 | "%d (%d):0749 SCSI Layer I/O Abort Request " |
James.Smart@Emulex.Com | 1de933f | 2005-11-28 11:41:15 -0500 | [diff] [blame] | 1121 | "Status x%x ID %d LUN %d snum %#lx\n", |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1122 | phba->brd_no, vport->vpi, ret, cmnd->device->id, |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1123 | cmnd->device->lun, cmnd->serial_number); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1124 | |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1125 | return ret; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1126 | } |
| 1127 | |
| 1128 | static int |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1129 | lpfc_device_reset_handler(struct scsi_cmnd *cmnd) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1130 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1131 | struct Scsi_Host *shost = cmnd->device->host; |
| 1132 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1133 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1134 | struct lpfc_scsi_buf *lpfc_cmd; |
| 1135 | struct lpfc_iocbq *iocbq, *iocbqrsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1136 | struct lpfc_rport_data *rdata = cmnd->device->hostdata; |
| 1137 | struct lpfc_nodelist *pnode = rdata->pnode; |
James.Smart@Emulex.Com | 6175c02 | 2005-11-28 11:42:05 -0500 | [diff] [blame] | 1138 | uint32_t cmd_result = 0, cmd_status = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1139 | int ret = FAILED; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1140 | int iocb_status = IOCB_SUCCESS; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1141 | int cnt, loopcnt; |
| 1142 | |
James Smart | a90f568 | 2006-08-17 11:58:04 -0400 | [diff] [blame] | 1143 | lpfc_block_error_handler(cmnd); |
James Smart | f560351 | 2006-12-02 13:35:43 -0500 | [diff] [blame] | 1144 | loopcnt = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1145 | /* |
| 1146 | * If target is not in a MAPPED state, delay the reset until |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 1147 | * target is rediscovered or devloss timeout expires. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1148 | */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1149 | while (1) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1150 | if (!pnode) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1151 | goto out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1152 | |
| 1153 | if (pnode->nlp_state != NLP_STE_MAPPED_NODE) { |
Nishanth Aravamudan | a9a3047 | 2005-11-07 01:01:20 -0800 | [diff] [blame] | 1154 | schedule_timeout_uninterruptible(msecs_to_jiffies(500)); |
James Smart | f560351 | 2006-12-02 13:35:43 -0500 | [diff] [blame] | 1155 | loopcnt++; |
| 1156 | rdata = cmnd->device->hostdata; |
| 1157 | if (!rdata || |
| 1158 | (loopcnt > ((phba->cfg_devloss_tmo * 2) + 1))) { |
| 1159 | lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1160 | "%d (%d):0721 LUN Reset rport " |
| 1161 | "failure: cnt x%x rdata x%p\n", |
| 1162 | phba->brd_no, vport->vpi, |
| 1163 | loopcnt, rdata); |
James Smart | f560351 | 2006-12-02 13:35:43 -0500 | [diff] [blame] | 1164 | goto out; |
| 1165 | } |
| 1166 | pnode = rdata->pnode; |
| 1167 | if (!pnode) |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1168 | goto out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1169 | } |
James Smart | f560351 | 2006-12-02 13:35:43 -0500 | [diff] [blame] | 1170 | if (pnode->nlp_state == NLP_STE_MAPPED_NODE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1171 | break; |
| 1172 | } |
| 1173 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1174 | lpfc_cmd = lpfc_get_scsi_buf(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1175 | if (lpfc_cmd == NULL) |
| 1176 | goto out; |
| 1177 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1178 | lpfc_cmd->timeout = 60; |
James Smart | 0b18ac4 | 2006-05-01 21:50:40 -0400 | [diff] [blame] | 1179 | lpfc_cmd->rdata = rdata; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1180 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1181 | ret = lpfc_scsi_prep_task_mgmt_cmd(vport, lpfc_cmd, cmnd->device->lun, |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1182 | FCP_TARGET_RESET); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1183 | if (!ret) |
| 1184 | goto out_free_scsi_buf; |
| 1185 | |
| 1186 | iocbq = &lpfc_cmd->cur_iocbq; |
| 1187 | |
| 1188 | /* get a buffer for this IOCB command response */ |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1189 | iocbqrsp = lpfc_sli_get_iocbq(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1190 | if (iocbqrsp == NULL) |
| 1191 | goto out_free_scsi_buf; |
| 1192 | |
James Smart | 0b18ac4 | 2006-05-01 21:50:40 -0400 | [diff] [blame] | 1193 | lpfc_printf_log(phba, KERN_INFO, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1194 | "%d (%d):0703 Issue target reset to TGT %d LUN %d " |
| 1195 | "rpi x%x nlp_flag x%x\n", |
| 1196 | phba->brd_no, vport->vpi, cmnd->device->id, |
James Smart | 0b18ac4 | 2006-05-01 21:50:40 -0400 | [diff] [blame] | 1197 | cmnd->device->lun, pnode->nlp_rpi, pnode->nlp_flag); |
| 1198 | |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1199 | iocb_status = lpfc_sli_issue_iocb_wait(phba, |
James.Smart@Emulex.Com | 6887692 | 2005-10-28 20:29:47 -0400 | [diff] [blame] | 1200 | &phba->sli.ring[phba->sli.fcp_ring], |
| 1201 | iocbq, iocbqrsp, lpfc_cmd->timeout); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1202 | |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1203 | if (iocb_status == IOCB_TIMEDOUT) |
| 1204 | iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl; |
| 1205 | |
| 1206 | if (iocb_status == IOCB_SUCCESS) |
| 1207 | ret = SUCCESS; |
| 1208 | else |
| 1209 | ret = iocb_status; |
James.Smart@Emulex.Com | 6175c02 | 2005-11-28 11:42:05 -0500 | [diff] [blame] | 1210 | |
| 1211 | cmd_result = iocbqrsp->iocb.un.ulpWord[4]; |
| 1212 | cmd_status = iocbqrsp->iocb.ulpStatus; |
| 1213 | |
| 1214 | lpfc_sli_release_iocbq(phba, iocbqrsp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1215 | |
| 1216 | /* |
James.Smart@Emulex.Com | 6175c02 | 2005-11-28 11:42:05 -0500 | [diff] [blame] | 1217 | * All outstanding txcmplq I/Os should have been aborted by the device. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1218 | * Unfortunately, some targets do not abide by this forcing the driver |
| 1219 | * to double check. |
| 1220 | */ |
James.Smart@Emulex.Com | 6175c02 | 2005-11-28 11:42:05 -0500 | [diff] [blame] | 1221 | cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], |
| 1222 | cmnd->device->id, cmnd->device->lun, |
| 1223 | LPFC_CTX_LUN); |
| 1224 | if (cnt) |
| 1225 | lpfc_sli_abort_iocb(phba, |
| 1226 | &phba->sli.ring[phba->sli.fcp_ring], |
| 1227 | cmnd->device->id, cmnd->device->lun, |
| 1228 | 0, LPFC_CTX_LUN); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1229 | loopcnt = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1230 | while(cnt) { |
Nishanth Aravamudan | a9a3047 | 2005-11-07 01:01:20 -0800 | [diff] [blame] | 1231 | schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1232 | |
| 1233 | if (++loopcnt |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 1234 | > (2 * phba->cfg_devloss_tmo)/LPFC_RESET_WAIT) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1235 | break; |
James.Smart@Emulex.Com | 6175c02 | 2005-11-28 11:42:05 -0500 | [diff] [blame] | 1236 | |
| 1237 | cnt = lpfc_sli_sum_iocb(phba, |
| 1238 | &phba->sli.ring[phba->sli.fcp_ring], |
| 1239 | cmnd->device->id, cmnd->device->lun, |
| 1240 | LPFC_CTX_LUN); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1241 | } |
| 1242 | |
| 1243 | if (cnt) { |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1244 | lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1245 | "%d (%d):0719 device reset I/O flush failure: " |
| 1246 | "cnt x%x\n", |
| 1247 | phba->brd_no, vport->vpi, cnt); |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1248 | ret = FAILED; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1249 | } |
| 1250 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1251 | out_free_scsi_buf: |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1252 | if (iocb_status != IOCB_TIMEDOUT) { |
| 1253 | lpfc_release_scsi_buf(phba, lpfc_cmd); |
| 1254 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1255 | lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1256 | "%d (%d):0713 SCSI layer issued device reset (%d, %d) " |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1257 | "return x%x status x%x result x%x\n", |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1258 | phba->brd_no, vport->vpi, cmnd->device->id, |
| 1259 | cmnd->device->lun, ret, cmd_status, cmd_result); |
James.Smart@Emulex.Com | 6175c02 | 2005-11-28 11:42:05 -0500 | [diff] [blame] | 1260 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1261 | out: |
| 1262 | return ret; |
| 1263 | } |
| 1264 | |
Jeff Garzik | 94d0e7b | 2005-05-28 07:55:48 -0400 | [diff] [blame] | 1265 | static int |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1266 | lpfc_bus_reset_handler(struct scsi_cmnd *cmnd) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1267 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1268 | struct Scsi_Host *shost = cmnd->device->host; |
| 1269 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
| 1270 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1271 | struct lpfc_nodelist *ndlp = NULL; |
| 1272 | int match; |
| 1273 | int ret = FAILED, i, err_count = 0; |
| 1274 | int cnt, loopcnt; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1275 | struct lpfc_scsi_buf * lpfc_cmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1276 | |
James Smart | a90f568 | 2006-08-17 11:58:04 -0400 | [diff] [blame] | 1277 | lpfc_block_error_handler(cmnd); |
James.Smart@Emulex.Com | 63c59c3 | 2005-11-28 11:41:53 -0500 | [diff] [blame] | 1278 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1279 | lpfc_cmd = lpfc_get_scsi_buf(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1280 | if (lpfc_cmd == NULL) |
| 1281 | goto out; |
| 1282 | |
| 1283 | /* The lpfc_cmd storage is reused. Set all loop invariants. */ |
| 1284 | lpfc_cmd->timeout = 60; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1285 | |
| 1286 | /* |
| 1287 | * Since the driver manages a single bus device, reset all |
| 1288 | * targets known to the driver. Should any target reset |
| 1289 | * fail, this routine returns failure to the midlayer. |
| 1290 | */ |
James Smart | e17da18 | 2006-07-06 15:49:25 -0400 | [diff] [blame] | 1291 | for (i = 0; i < LPFC_MAX_TARGET; i++) { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 1292 | /* Search for mapped node by target ID */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1293 | match = 0; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1294 | spin_lock_irq(shost->host_lock); |
| 1295 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 1296 | if (ndlp->nlp_state == NLP_STE_MAPPED_NODE && |
| 1297 | i == ndlp->nlp_sid && |
| 1298 | ndlp->rport) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1299 | match = 1; |
| 1300 | break; |
| 1301 | } |
| 1302 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1303 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1304 | if (!match) |
| 1305 | continue; |
| 1306 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1307 | ret = lpfc_scsi_tgt_reset(lpfc_cmd, vport, i, |
| 1308 | cmnd->device->lun, |
James Smart | 420b630d | 2006-07-06 15:50:16 -0400 | [diff] [blame] | 1309 | ndlp->rport->dd_data); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1310 | if (ret != SUCCESS) { |
James.Smart@Emulex.Com | 6175c02 | 2005-11-28 11:42:05 -0500 | [diff] [blame] | 1311 | lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1312 | "%d (%d):0700 Bus Reset on target %d " |
| 1313 | "failed\n", |
| 1314 | phba->brd_no, vport->vpi, i); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1315 | err_count++; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1316 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1317 | } |
| 1318 | } |
| 1319 | |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1320 | if (ret != IOCB_TIMEDOUT) |
| 1321 | lpfc_release_scsi_buf(phba, lpfc_cmd); |
| 1322 | |
James.Smart@Emulex.Com | 6175c02 | 2005-11-28 11:42:05 -0500 | [diff] [blame] | 1323 | if (err_count == 0) |
| 1324 | ret = SUCCESS; |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1325 | else |
| 1326 | ret = FAILED; |
James.Smart@Emulex.Com | 6175c02 | 2005-11-28 11:42:05 -0500 | [diff] [blame] | 1327 | |
| 1328 | /* |
| 1329 | * All outstanding txcmplq I/Os should have been aborted by |
| 1330 | * the targets. Unfortunately, some targets do not abide by |
| 1331 | * this forcing the driver to double check. |
| 1332 | */ |
James.Smart@Emulex.Com | 6175c02 | 2005-11-28 11:42:05 -0500 | [diff] [blame] | 1333 | cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], |
| 1334 | 0, 0, LPFC_CTX_HOST); |
| 1335 | if (cnt) |
| 1336 | lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], |
| 1337 | 0, 0, 0, LPFC_CTX_HOST); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1338 | loopcnt = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1339 | while(cnt) { |
Nishanth Aravamudan | a9a3047 | 2005-11-07 01:01:20 -0800 | [diff] [blame] | 1340 | schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1341 | |
| 1342 | if (++loopcnt |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 1343 | > (2 * phba->cfg_devloss_tmo)/LPFC_RESET_WAIT) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1344 | break; |
James.Smart@Emulex.Com | 6175c02 | 2005-11-28 11:42:05 -0500 | [diff] [blame] | 1345 | |
| 1346 | cnt = lpfc_sli_sum_iocb(phba, |
| 1347 | &phba->sli.ring[phba->sli.fcp_ring], |
| 1348 | 0, 0, LPFC_CTX_HOST); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1349 | } |
| 1350 | |
| 1351 | if (cnt) { |
James.Smart@Emulex.Com | 6175c02 | 2005-11-28 11:42:05 -0500 | [diff] [blame] | 1352 | lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1353 | "%d (%d):0715 Bus Reset I/O flush failure: " |
| 1354 | "cnt x%x left x%x\n", |
| 1355 | phba->brd_no, vport->vpi, cnt, i); |
James.Smart@Emulex.Com | 6175c02 | 2005-11-28 11:42:05 -0500 | [diff] [blame] | 1356 | ret = FAILED; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1357 | } |
| 1358 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1359 | lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
| 1360 | "%d (%d):0714 SCSI layer issued Bus Reset Data: x%x\n", |
| 1361 | phba->brd_no, vport->vpi, ret); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1362 | out: |
| 1363 | return ret; |
| 1364 | } |
| 1365 | |
| 1366 | static int |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1367 | lpfc_slave_alloc(struct scsi_device *sdev) |
| 1368 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1369 | struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata; |
| 1370 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1371 | struct lpfc_scsi_buf *scsi_buf = NULL; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1372 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1373 | uint32_t total = 0, i; |
| 1374 | uint32_t num_to_alloc = 0; |
| 1375 | unsigned long flags; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1376 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1377 | if (!rport || fc_remote_port_chkready(rport)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1378 | return -ENXIO; |
| 1379 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1380 | sdev->hostdata = rport->dd_data; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1381 | |
| 1382 | /* |
| 1383 | * Populate the cmds_per_lun count scsi_bufs into this host's globally |
| 1384 | * available list of scsi buffers. Don't allocate more than the |
James.Smart@Emulex.Com | a784efb | 2005-10-28 20:29:51 -0400 | [diff] [blame] | 1385 | * HBA limit conveyed to the midlayer via the host structure. The |
| 1386 | * formula accounts for the lun_queue_depth + error handlers + 1 |
| 1387 | * extra. This list of scsi bufs exists for the lifetime of the driver. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1388 | */ |
| 1389 | total = phba->total_scsi_bufs; |
James.Smart@Emulex.Com | a784efb | 2005-10-28 20:29:51 -0400 | [diff] [blame] | 1390 | num_to_alloc = phba->cfg_lun_queue_depth + 2; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1391 | |
| 1392 | /* Allow some exchanges to be available always to complete discovery */ |
| 1393 | if (total >= phba->cfg_hba_queue_depth - LPFC_DISC_IOCB_BUFF_COUNT ) { |
James.Smart@Emulex.Com | a784efb | 2005-10-28 20:29:51 -0400 | [diff] [blame] | 1394 | lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1395 | "%d (%d):0704 At limitation of %d " |
| 1396 | "preallocated command buffers\n", |
| 1397 | phba->brd_no, vport->vpi, total); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1398 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1399 | |
| 1400 | /* Allow some exchanges to be available always to complete discovery */ |
| 1401 | } else if (total + num_to_alloc > |
| 1402 | phba->cfg_hba_queue_depth - LPFC_DISC_IOCB_BUFF_COUNT ) { |
James.Smart@Emulex.Com | a784efb | 2005-10-28 20:29:51 -0400 | [diff] [blame] | 1403 | lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1404 | "%d (%d):0705 Allocation request of %d " |
| 1405 | "command buffers will exceed max of %d. " |
| 1406 | "Reducing allocation request to %d.\n", |
| 1407 | phba->brd_no, vport->vpi, num_to_alloc, |
| 1408 | phba->cfg_hba_queue_depth, |
James.Smart@Emulex.Com | a784efb | 2005-10-28 20:29:51 -0400 | [diff] [blame] | 1409 | (phba->cfg_hba_queue_depth - total)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1410 | num_to_alloc = phba->cfg_hba_queue_depth - total; |
| 1411 | } |
| 1412 | |
| 1413 | for (i = 0; i < num_to_alloc; i++) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1414 | scsi_buf = lpfc_new_scsi_buf(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1415 | if (!scsi_buf) { |
James.Smart@Emulex.Com | a784efb | 2005-10-28 20:29:51 -0400 | [diff] [blame] | 1416 | lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1417 | "%d (%d):0706 Failed to allocate " |
| 1418 | "command buffer\n", |
| 1419 | phba->brd_no, vport->vpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1420 | break; |
| 1421 | } |
| 1422 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1423 | spin_lock_irqsave(&phba->scsi_buf_list_lock, flags); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1424 | phba->total_scsi_bufs++; |
| 1425 | list_add_tail(&scsi_buf->list, &phba->lpfc_scsi_buf_list); |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1426 | spin_unlock_irqrestore(&phba->scsi_buf_list_lock, flags); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1427 | } |
| 1428 | return 0; |
| 1429 | } |
| 1430 | |
| 1431 | static int |
| 1432 | lpfc_slave_configure(struct scsi_device *sdev) |
| 1433 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1434 | struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata; |
| 1435 | struct lpfc_hba *phba = vport->phba; |
| 1436 | struct fc_rport *rport = starget_to_rport(sdev->sdev_target); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1437 | |
| 1438 | if (sdev->tagged_supported) |
| 1439 | scsi_activate_tcq(sdev, phba->cfg_lun_queue_depth); |
| 1440 | else |
| 1441 | scsi_deactivate_tcq(sdev, phba->cfg_lun_queue_depth); |
| 1442 | |
| 1443 | /* |
| 1444 | * Initialize the fc transport attributes for the target |
| 1445 | * containing this scsi device. Also note that the driver's |
| 1446 | * target pointer is stored in the starget_data for the |
| 1447 | * driver's sysfs entry point functions. |
| 1448 | */ |
James Smart | c01f320 | 2006-08-18 17:47:08 -0400 | [diff] [blame] | 1449 | rport->dev_loss_tmo = phba->cfg_devloss_tmo; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1450 | |
James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1451 | if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { |
| 1452 | lpfc_sli_poll_fcp_ring(phba); |
| 1453 | if (phba->cfg_poll & DISABLE_FCP_RING_INT) |
| 1454 | lpfc_poll_rearm_timer(phba); |
| 1455 | } |
| 1456 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1457 | return 0; |
| 1458 | } |
| 1459 | |
| 1460 | static void |
| 1461 | lpfc_slave_destroy(struct scsi_device *sdev) |
| 1462 | { |
| 1463 | sdev->hostdata = NULL; |
| 1464 | return; |
| 1465 | } |
| 1466 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1467 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1468 | struct scsi_host_template lpfc_template = { |
| 1469 | .module = THIS_MODULE, |
| 1470 | .name = LPFC_DRIVER_NAME, |
| 1471 | .info = lpfc_info, |
| 1472 | .queuecommand = lpfc_queuecommand, |
| 1473 | .eh_abort_handler = lpfc_abort_handler, |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1474 | .eh_device_reset_handler= lpfc_device_reset_handler, |
| 1475 | .eh_bus_reset_handler = lpfc_bus_reset_handler, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1476 | .slave_alloc = lpfc_slave_alloc, |
| 1477 | .slave_configure = lpfc_slave_configure, |
| 1478 | .slave_destroy = lpfc_slave_destroy, |
James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1479 | .scan_finished = lpfc_scan_finished, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1480 | .this_id = -1, |
| 1481 | .sg_tablesize = LPFC_SG_SEG_CNT, |
| 1482 | .cmd_per_lun = LPFC_CMD_PER_LUN, |
| 1483 | .use_clustering = ENABLE_CLUSTERING, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1484 | .shost_attrs = lpfc_hba_attrs, |
James.Smart@Emulex.Com | 564b296 | 2005-06-25 10:34:17 -0400 | [diff] [blame] | 1485 | .max_sectors = 0xFFFF, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1486 | }; |