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