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