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