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