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