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