.. | .. |
---|
1 | 1 | /******************************************************************* |
---|
2 | 2 | * This file is part of the Emulex Linux Device Driver for * |
---|
3 | 3 | * Fibre Channel Host Bus Adapters. * |
---|
4 | | - * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term * |
---|
| 4 | + * Copyright (C) 2017-2020 Broadcom. All Rights Reserved. The term * |
---|
5 | 5 | * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * |
---|
6 | 6 | * Copyright (C) 2004-2016 Emulex. All rights reserved. * |
---|
7 | 7 | * EMULEX and SLI are trademarks of Emulex. * |
---|
.. | .. |
---|
53 | 53 | #define LPFC_RESET_WAIT 2 |
---|
54 | 54 | #define LPFC_ABORT_WAIT 2 |
---|
55 | 55 | |
---|
56 | | -int _dump_buf_done = 1; |
---|
57 | | - |
---|
58 | 56 | static char *dif_op_str[] = { |
---|
59 | 57 | "PROT_NORMAL", |
---|
60 | 58 | "PROT_READ_INSERT", |
---|
.. | .. |
---|
83 | 81 | } |
---|
84 | 82 | |
---|
85 | 83 | static void |
---|
86 | | -lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb); |
---|
| 84 | +lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_io_buf *psb); |
---|
87 | 85 | static void |
---|
88 | | -lpfc_release_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb); |
---|
| 86 | +lpfc_release_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_io_buf *psb); |
---|
89 | 87 | static int |
---|
90 | 88 | lpfc_prot_group_type(struct lpfc_hba *phba, struct scsi_cmnd *sc); |
---|
91 | | - |
---|
92 | | -static void |
---|
93 | | -lpfc_debug_save_data(struct lpfc_hba *phba, struct scsi_cmnd *cmnd) |
---|
94 | | -{ |
---|
95 | | - void *src, *dst; |
---|
96 | | - struct scatterlist *sgde = scsi_sglist(cmnd); |
---|
97 | | - |
---|
98 | | - if (!_dump_buf_data) { |
---|
99 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
100 | | - "9050 BLKGRD: ERROR %s _dump_buf_data is NULL\n", |
---|
101 | | - __func__); |
---|
102 | | - return; |
---|
103 | | - } |
---|
104 | | - |
---|
105 | | - |
---|
106 | | - if (!sgde) { |
---|
107 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
108 | | - "9051 BLKGRD: ERROR: data scatterlist is null\n"); |
---|
109 | | - return; |
---|
110 | | - } |
---|
111 | | - |
---|
112 | | - dst = (void *) _dump_buf_data; |
---|
113 | | - while (sgde) { |
---|
114 | | - src = sg_virt(sgde); |
---|
115 | | - memcpy(dst, src, sgde->length); |
---|
116 | | - dst += sgde->length; |
---|
117 | | - sgde = sg_next(sgde); |
---|
118 | | - } |
---|
119 | | -} |
---|
120 | | - |
---|
121 | | -static void |
---|
122 | | -lpfc_debug_save_dif(struct lpfc_hba *phba, struct scsi_cmnd *cmnd) |
---|
123 | | -{ |
---|
124 | | - void *src, *dst; |
---|
125 | | - struct scatterlist *sgde = scsi_prot_sglist(cmnd); |
---|
126 | | - |
---|
127 | | - if (!_dump_buf_dif) { |
---|
128 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
129 | | - "9052 BLKGRD: ERROR %s _dump_buf_data is NULL\n", |
---|
130 | | - __func__); |
---|
131 | | - return; |
---|
132 | | - } |
---|
133 | | - |
---|
134 | | - if (!sgde) { |
---|
135 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
136 | | - "9053 BLKGRD: ERROR: prot scatterlist is null\n"); |
---|
137 | | - return; |
---|
138 | | - } |
---|
139 | | - |
---|
140 | | - dst = _dump_buf_dif; |
---|
141 | | - while (sgde) { |
---|
142 | | - src = sg_virt(sgde); |
---|
143 | | - memcpy(dst, src, sgde->length); |
---|
144 | | - dst += sgde->length; |
---|
145 | | - sgde = sg_next(sgde); |
---|
146 | | - } |
---|
147 | | -} |
---|
148 | 89 | |
---|
149 | 90 | static inline unsigned |
---|
150 | 91 | lpfc_cmd_blksize(struct scsi_cmnd *sc) |
---|
.. | .. |
---|
180 | 121 | **/ |
---|
181 | 122 | static void |
---|
182 | 123 | lpfc_sli4_set_rsp_sgl_last(struct lpfc_hba *phba, |
---|
183 | | - struct lpfc_scsi_buf *lpfc_cmd) |
---|
| 124 | + struct lpfc_io_buf *lpfc_cmd) |
---|
184 | 125 | { |
---|
185 | | - struct sli4_sge *sgl = (struct sli4_sge *)lpfc_cmd->fcp_bpl; |
---|
| 126 | + struct sli4_sge *sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl; |
---|
186 | 127 | if (sgl) { |
---|
187 | 128 | sgl += 1; |
---|
188 | 129 | sgl->word2 = le32_to_cpu(sgl->word2); |
---|
.. | .. |
---|
193 | 134 | |
---|
194 | 135 | /** |
---|
195 | 136 | * lpfc_update_stats - Update statistical data for the command completion |
---|
196 | | - * @phba: Pointer to HBA object. |
---|
| 137 | + * @vport: The virtual port on which this call is executing. |
---|
197 | 138 | * @lpfc_cmd: lpfc scsi command object pointer. |
---|
198 | 139 | * |
---|
199 | 140 | * This function is called when there is a command completion and this |
---|
200 | 141 | * function updates the statistical data for the command completion. |
---|
201 | 142 | **/ |
---|
202 | 143 | static void |
---|
203 | | -lpfc_update_stats(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) |
---|
| 144 | +lpfc_update_stats(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd) |
---|
204 | 145 | { |
---|
205 | | - struct lpfc_rport_data *rdata = lpfc_cmd->rdata; |
---|
206 | | - struct lpfc_nodelist *pnode = rdata->pnode; |
---|
| 146 | + struct lpfc_hba *phba = vport->phba; |
---|
| 147 | + struct lpfc_rport_data *rdata; |
---|
| 148 | + struct lpfc_nodelist *pnode; |
---|
207 | 149 | struct scsi_cmnd *cmd = lpfc_cmd->pCmd; |
---|
208 | 150 | unsigned long flags; |
---|
209 | | - struct Scsi_Host *shost = cmd->device->host; |
---|
210 | | - struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; |
---|
| 151 | + struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
---|
211 | 152 | unsigned long latency; |
---|
212 | 153 | int i; |
---|
213 | 154 | |
---|
214 | | - if (cmd->result) |
---|
| 155 | + if (!vport->stat_data_enabled || |
---|
| 156 | + vport->stat_data_blocked || |
---|
| 157 | + (cmd->result)) |
---|
215 | 158 | return; |
---|
216 | 159 | |
---|
217 | 160 | latency = jiffies_to_msecs((long)jiffies - (long)lpfc_cmd->start_time); |
---|
| 161 | + rdata = lpfc_cmd->rdata; |
---|
| 162 | + pnode = rdata->pnode; |
---|
218 | 163 | |
---|
219 | 164 | spin_lock_irqsave(shost->host_lock, flags); |
---|
220 | | - if (!vport->stat_data_enabled || |
---|
221 | | - vport->stat_data_blocked || |
---|
222 | | - !pnode || |
---|
223 | | - !pnode->lat_data || |
---|
224 | | - (phba->bucket_type == LPFC_NO_BUCKET)) { |
---|
| 165 | + if (!pnode || |
---|
| 166 | + !pnode->lat_data || |
---|
| 167 | + (phba->bucket_type == LPFC_NO_BUCKET)) { |
---|
225 | 168 | spin_unlock_irqrestore(shost->host_lock, flags); |
---|
226 | 169 | return; |
---|
227 | 170 | } |
---|
.. | .. |
---|
387 | 330 | lpfc_new_scsi_buf_s3(struct lpfc_vport *vport, int num_to_alloc) |
---|
388 | 331 | { |
---|
389 | 332 | struct lpfc_hba *phba = vport->phba; |
---|
390 | | - struct lpfc_scsi_buf *psb; |
---|
| 333 | + struct lpfc_io_buf *psb; |
---|
391 | 334 | struct ulp_bde64 *bpl; |
---|
392 | 335 | IOCB_t *iocb; |
---|
393 | 336 | dma_addr_t pdma_phys_fcp_cmd; |
---|
394 | 337 | dma_addr_t pdma_phys_fcp_rsp; |
---|
395 | | - dma_addr_t pdma_phys_bpl; |
---|
| 338 | + dma_addr_t pdma_phys_sgl; |
---|
396 | 339 | uint16_t iotag; |
---|
397 | 340 | int bcnt, bpl_size; |
---|
398 | 341 | |
---|
.. | .. |
---|
406 | 349 | (int)sizeof(struct fcp_rsp), bpl_size); |
---|
407 | 350 | |
---|
408 | 351 | for (bcnt = 0; bcnt < num_to_alloc; bcnt++) { |
---|
409 | | - psb = kzalloc(sizeof(struct lpfc_scsi_buf), GFP_KERNEL); |
---|
| 352 | + psb = kzalloc(sizeof(struct lpfc_io_buf), GFP_KERNEL); |
---|
410 | 353 | if (!psb) |
---|
411 | 354 | break; |
---|
412 | 355 | |
---|
.. | .. |
---|
436 | 379 | |
---|
437 | 380 | psb->fcp_cmnd = psb->data; |
---|
438 | 381 | psb->fcp_rsp = psb->data + sizeof(struct fcp_cmnd); |
---|
439 | | - psb->fcp_bpl = psb->data + sizeof(struct fcp_cmnd) + |
---|
| 382 | + psb->dma_sgl = psb->data + sizeof(struct fcp_cmnd) + |
---|
440 | 383 | sizeof(struct fcp_rsp); |
---|
441 | 384 | |
---|
442 | 385 | /* Initialize local short-hand pointers. */ |
---|
443 | | - bpl = psb->fcp_bpl; |
---|
| 386 | + bpl = (struct ulp_bde64 *)psb->dma_sgl; |
---|
444 | 387 | pdma_phys_fcp_cmd = psb->dma_handle; |
---|
445 | 388 | pdma_phys_fcp_rsp = psb->dma_handle + sizeof(struct fcp_cmnd); |
---|
446 | | - pdma_phys_bpl = psb->dma_handle + sizeof(struct fcp_cmnd) + |
---|
| 389 | + pdma_phys_sgl = psb->dma_handle + sizeof(struct fcp_cmnd) + |
---|
447 | 390 | sizeof(struct fcp_rsp); |
---|
448 | 391 | |
---|
449 | 392 | /* |
---|
.. | .. |
---|
494 | 437 | iocb->un.fcpi64.bdl.bdeSize = |
---|
495 | 438 | (2 * sizeof(struct ulp_bde64)); |
---|
496 | 439 | iocb->un.fcpi64.bdl.addrLow = |
---|
497 | | - putPaddrLow(pdma_phys_bpl); |
---|
| 440 | + putPaddrLow(pdma_phys_sgl); |
---|
498 | 441 | iocb->un.fcpi64.bdl.addrHigh = |
---|
499 | | - putPaddrHigh(pdma_phys_bpl); |
---|
| 442 | + putPaddrHigh(pdma_phys_sgl); |
---|
500 | 443 | iocb->ulpBdeCount = 1; |
---|
501 | 444 | iocb->ulpLe = 1; |
---|
502 | 445 | } |
---|
.. | .. |
---|
504 | 447 | psb->status = IOSTAT_SUCCESS; |
---|
505 | 448 | /* Put it back into the SCSI buffer list */ |
---|
506 | 449 | psb->cur_iocbq.context1 = psb; |
---|
| 450 | + spin_lock_init(&psb->buf_lock); |
---|
507 | 451 | lpfc_release_scsi_buf_s3(phba, psb); |
---|
508 | 452 | |
---|
509 | 453 | } |
---|
.. | .. |
---|
522 | 466 | lpfc_sli4_vport_delete_fcp_xri_aborted(struct lpfc_vport *vport) |
---|
523 | 467 | { |
---|
524 | 468 | struct lpfc_hba *phba = vport->phba; |
---|
525 | | - struct lpfc_scsi_buf *psb, *next_psb; |
---|
| 469 | + struct lpfc_io_buf *psb, *next_psb; |
---|
| 470 | + struct lpfc_sli4_hdw_queue *qp; |
---|
526 | 471 | unsigned long iflag = 0; |
---|
| 472 | + int idx; |
---|
527 | 473 | |
---|
528 | | - if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) |
---|
| 474 | + if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) |
---|
529 | 475 | return; |
---|
| 476 | + |
---|
530 | 477 | spin_lock_irqsave(&phba->hbalock, iflag); |
---|
531 | | - spin_lock(&phba->sli4_hba.abts_scsi_buf_list_lock); |
---|
532 | | - list_for_each_entry_safe(psb, next_psb, |
---|
533 | | - &phba->sli4_hba.lpfc_abts_scsi_buf_list, list) { |
---|
534 | | - if (psb->rdata && psb->rdata->pnode |
---|
535 | | - && psb->rdata->pnode->vport == vport) |
---|
536 | | - psb->rdata = NULL; |
---|
| 478 | + for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { |
---|
| 479 | + qp = &phba->sli4_hba.hdwq[idx]; |
---|
| 480 | + |
---|
| 481 | + spin_lock(&qp->abts_io_buf_list_lock); |
---|
| 482 | + list_for_each_entry_safe(psb, next_psb, |
---|
| 483 | + &qp->lpfc_abts_io_buf_list, list) { |
---|
| 484 | + if (psb->cur_iocbq.iocb_flag & LPFC_IO_NVME) |
---|
| 485 | + continue; |
---|
| 486 | + |
---|
| 487 | + if (psb->rdata && psb->rdata->pnode && |
---|
| 488 | + psb->rdata->pnode->vport == vport) |
---|
| 489 | + psb->rdata = NULL; |
---|
| 490 | + } |
---|
| 491 | + spin_unlock(&qp->abts_io_buf_list_lock); |
---|
537 | 492 | } |
---|
538 | | - spin_unlock(&phba->sli4_hba.abts_scsi_buf_list_lock); |
---|
539 | 493 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
---|
540 | 494 | } |
---|
541 | 495 | |
---|
542 | 496 | /** |
---|
543 | | - * lpfc_sli4_fcp_xri_aborted - Fast-path process of fcp xri abort |
---|
| 497 | + * lpfc_sli4_io_xri_aborted - Fast-path process of fcp xri abort |
---|
544 | 498 | * @phba: pointer to lpfc hba data structure. |
---|
545 | 499 | * @axri: pointer to the fcp xri abort wcqe structure. |
---|
546 | 500 | * |
---|
547 | 501 | * This routine is invoked by the worker thread to process a SLI4 fast-path |
---|
548 | | - * FCP aborted xri. |
---|
| 502 | + * FCP or NVME aborted xri. |
---|
549 | 503 | **/ |
---|
550 | 504 | void |
---|
551 | | -lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba, |
---|
552 | | - struct sli4_wcqe_xri_aborted *axri) |
---|
| 505 | +lpfc_sli4_io_xri_aborted(struct lpfc_hba *phba, |
---|
| 506 | + struct sli4_wcqe_xri_aborted *axri, int idx) |
---|
553 | 507 | { |
---|
554 | 508 | uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri); |
---|
555 | 509 | uint16_t rxid = bf_get(lpfc_wcqe_xa_remote_xid, axri); |
---|
556 | | - struct lpfc_scsi_buf *psb, *next_psb; |
---|
| 510 | + struct lpfc_io_buf *psb, *next_psb; |
---|
| 511 | + struct lpfc_sli4_hdw_queue *qp; |
---|
557 | 512 | unsigned long iflag = 0; |
---|
558 | 513 | struct lpfc_iocbq *iocbq; |
---|
559 | 514 | int i; |
---|
.. | .. |
---|
563 | 518 | |
---|
564 | 519 | if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) |
---|
565 | 520 | return; |
---|
| 521 | + |
---|
| 522 | + qp = &phba->sli4_hba.hdwq[idx]; |
---|
566 | 523 | spin_lock_irqsave(&phba->hbalock, iflag); |
---|
567 | | - spin_lock(&phba->sli4_hba.abts_scsi_buf_list_lock); |
---|
| 524 | + spin_lock(&qp->abts_io_buf_list_lock); |
---|
568 | 525 | list_for_each_entry_safe(psb, next_psb, |
---|
569 | | - &phba->sli4_hba.lpfc_abts_scsi_buf_list, list) { |
---|
| 526 | + &qp->lpfc_abts_io_buf_list, list) { |
---|
570 | 527 | if (psb->cur_iocbq.sli4_xritag == xri) { |
---|
571 | | - list_del(&psb->list); |
---|
572 | | - psb->exch_busy = 0; |
---|
| 528 | + list_del_init(&psb->list); |
---|
| 529 | + psb->flags &= ~LPFC_SBUF_XBUSY; |
---|
573 | 530 | psb->status = IOSTAT_SUCCESS; |
---|
574 | | - spin_unlock( |
---|
575 | | - &phba->sli4_hba.abts_scsi_buf_list_lock); |
---|
| 531 | + if (psb->cur_iocbq.iocb_flag & LPFC_IO_NVME) { |
---|
| 532 | + qp->abts_nvme_io_bufs--; |
---|
| 533 | + spin_unlock(&qp->abts_io_buf_list_lock); |
---|
| 534 | + spin_unlock_irqrestore(&phba->hbalock, iflag); |
---|
| 535 | + lpfc_sli4_nvme_xri_aborted(phba, axri, psb); |
---|
| 536 | + return; |
---|
| 537 | + } |
---|
| 538 | + qp->abts_scsi_io_bufs--; |
---|
| 539 | + spin_unlock(&qp->abts_io_buf_list_lock); |
---|
| 540 | + |
---|
576 | 541 | if (psb->rdata && psb->rdata->pnode) |
---|
577 | 542 | ndlp = psb->rdata->pnode; |
---|
578 | 543 | else |
---|
.. | .. |
---|
591 | 556 | return; |
---|
592 | 557 | } |
---|
593 | 558 | } |
---|
594 | | - spin_unlock(&phba->sli4_hba.abts_scsi_buf_list_lock); |
---|
| 559 | + spin_unlock(&qp->abts_io_buf_list_lock); |
---|
595 | 560 | for (i = 1; i <= phba->sli.last_iotag; i++) { |
---|
596 | 561 | iocbq = phba->sli.iocbq_lookup[i]; |
---|
597 | 562 | |
---|
598 | | - if (!(iocbq->iocb_flag & LPFC_IO_FCP) || |
---|
599 | | - (iocbq->iocb_flag & LPFC_IO_LIBDFC)) |
---|
| 563 | + if (!(iocbq->iocb_flag & LPFC_IO_FCP) || |
---|
| 564 | + (iocbq->iocb_flag & LPFC_IO_LIBDFC)) |
---|
600 | 565 | continue; |
---|
601 | 566 | if (iocbq->sli4_xritag != xri) |
---|
602 | 567 | continue; |
---|
603 | | - psb = container_of(iocbq, struct lpfc_scsi_buf, cur_iocbq); |
---|
604 | | - psb->exch_busy = 0; |
---|
| 568 | + psb = container_of(iocbq, struct lpfc_io_buf, cur_iocbq); |
---|
| 569 | + psb->flags &= ~LPFC_SBUF_XBUSY; |
---|
605 | 570 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
---|
606 | 571 | if (!list_empty(&pring->txq)) |
---|
607 | 572 | lpfc_worker_wake_up(phba); |
---|
.. | .. |
---|
609 | 574 | |
---|
610 | 575 | } |
---|
611 | 576 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
---|
612 | | -} |
---|
613 | | - |
---|
614 | | -/** |
---|
615 | | - * lpfc_sli4_post_scsi_sgl_list - Post blocks of scsi buffer sgls from a list |
---|
616 | | - * @phba: pointer to lpfc hba data structure. |
---|
617 | | - * @post_sblist: pointer to the scsi buffer list. |
---|
618 | | - * |
---|
619 | | - * This routine walks a list of scsi buffers that was passed in. It attempts |
---|
620 | | - * to construct blocks of scsi buffer sgls which contains contiguous xris and |
---|
621 | | - * uses the non-embedded SGL block post mailbox commands to post to the port. |
---|
622 | | - * For single SCSI buffer sgl with non-contiguous xri, if any, it shall use |
---|
623 | | - * embedded SGL post mailbox command for posting. The @post_sblist passed in |
---|
624 | | - * must be local list, thus no lock is needed when manipulate the list. |
---|
625 | | - * |
---|
626 | | - * Returns: 0 = failure, non-zero number of successfully posted buffers. |
---|
627 | | - **/ |
---|
628 | | -static int |
---|
629 | | -lpfc_sli4_post_scsi_sgl_list(struct lpfc_hba *phba, |
---|
630 | | - struct list_head *post_sblist, int sb_count) |
---|
631 | | -{ |
---|
632 | | - struct lpfc_scsi_buf *psb, *psb_next; |
---|
633 | | - int status, sgl_size; |
---|
634 | | - int post_cnt = 0, block_cnt = 0, num_posting = 0, num_posted = 0; |
---|
635 | | - dma_addr_t pdma_phys_bpl1; |
---|
636 | | - int last_xritag = NO_XRI; |
---|
637 | | - LIST_HEAD(prep_sblist); |
---|
638 | | - LIST_HEAD(blck_sblist); |
---|
639 | | - LIST_HEAD(scsi_sblist); |
---|
640 | | - |
---|
641 | | - /* sanity check */ |
---|
642 | | - if (sb_count <= 0) |
---|
643 | | - return -EINVAL; |
---|
644 | | - |
---|
645 | | - sgl_size = phba->cfg_sg_dma_buf_size - |
---|
646 | | - (sizeof(struct fcp_cmnd) + sizeof(struct fcp_rsp)); |
---|
647 | | - |
---|
648 | | - list_for_each_entry_safe(psb, psb_next, post_sblist, list) { |
---|
649 | | - list_del_init(&psb->list); |
---|
650 | | - block_cnt++; |
---|
651 | | - if ((last_xritag != NO_XRI) && |
---|
652 | | - (psb->cur_iocbq.sli4_xritag != last_xritag + 1)) { |
---|
653 | | - /* a hole in xri block, form a sgl posting block */ |
---|
654 | | - list_splice_init(&prep_sblist, &blck_sblist); |
---|
655 | | - post_cnt = block_cnt - 1; |
---|
656 | | - /* prepare list for next posting block */ |
---|
657 | | - list_add_tail(&psb->list, &prep_sblist); |
---|
658 | | - block_cnt = 1; |
---|
659 | | - } else { |
---|
660 | | - /* prepare list for next posting block */ |
---|
661 | | - list_add_tail(&psb->list, &prep_sblist); |
---|
662 | | - /* enough sgls for non-embed sgl mbox command */ |
---|
663 | | - if (block_cnt == LPFC_NEMBED_MBOX_SGL_CNT) { |
---|
664 | | - list_splice_init(&prep_sblist, &blck_sblist); |
---|
665 | | - post_cnt = block_cnt; |
---|
666 | | - block_cnt = 0; |
---|
667 | | - } |
---|
668 | | - } |
---|
669 | | - num_posting++; |
---|
670 | | - last_xritag = psb->cur_iocbq.sli4_xritag; |
---|
671 | | - |
---|
672 | | - /* end of repost sgl list condition for SCSI buffers */ |
---|
673 | | - if (num_posting == sb_count) { |
---|
674 | | - if (post_cnt == 0) { |
---|
675 | | - /* last sgl posting block */ |
---|
676 | | - list_splice_init(&prep_sblist, &blck_sblist); |
---|
677 | | - post_cnt = block_cnt; |
---|
678 | | - } else if (block_cnt == 1) { |
---|
679 | | - /* last single sgl with non-contiguous xri */ |
---|
680 | | - if (sgl_size > SGL_PAGE_SIZE) |
---|
681 | | - pdma_phys_bpl1 = psb->dma_phys_bpl + |
---|
682 | | - SGL_PAGE_SIZE; |
---|
683 | | - else |
---|
684 | | - pdma_phys_bpl1 = 0; |
---|
685 | | - status = lpfc_sli4_post_sgl(phba, |
---|
686 | | - psb->dma_phys_bpl, |
---|
687 | | - pdma_phys_bpl1, |
---|
688 | | - psb->cur_iocbq.sli4_xritag); |
---|
689 | | - if (status) { |
---|
690 | | - /* failure, put on abort scsi list */ |
---|
691 | | - psb->exch_busy = 1; |
---|
692 | | - } else { |
---|
693 | | - /* success, put on SCSI buffer list */ |
---|
694 | | - psb->exch_busy = 0; |
---|
695 | | - psb->status = IOSTAT_SUCCESS; |
---|
696 | | - num_posted++; |
---|
697 | | - } |
---|
698 | | - /* success, put on SCSI buffer sgl list */ |
---|
699 | | - list_add_tail(&psb->list, &scsi_sblist); |
---|
700 | | - } |
---|
701 | | - } |
---|
702 | | - |
---|
703 | | - /* continue until a nembed page worth of sgls */ |
---|
704 | | - if (post_cnt == 0) |
---|
705 | | - continue; |
---|
706 | | - |
---|
707 | | - /* post block of SCSI buffer list sgls */ |
---|
708 | | - status = lpfc_sli4_post_scsi_sgl_block(phba, &blck_sblist, |
---|
709 | | - post_cnt); |
---|
710 | | - |
---|
711 | | - /* don't reset xirtag due to hole in xri block */ |
---|
712 | | - if (block_cnt == 0) |
---|
713 | | - last_xritag = NO_XRI; |
---|
714 | | - |
---|
715 | | - /* reset SCSI buffer post count for next round of posting */ |
---|
716 | | - post_cnt = 0; |
---|
717 | | - |
---|
718 | | - /* put posted SCSI buffer-sgl posted on SCSI buffer sgl list */ |
---|
719 | | - while (!list_empty(&blck_sblist)) { |
---|
720 | | - list_remove_head(&blck_sblist, psb, |
---|
721 | | - struct lpfc_scsi_buf, list); |
---|
722 | | - if (status) { |
---|
723 | | - /* failure, put on abort scsi list */ |
---|
724 | | - psb->exch_busy = 1; |
---|
725 | | - } else { |
---|
726 | | - /* success, put on SCSI buffer list */ |
---|
727 | | - psb->exch_busy = 0; |
---|
728 | | - psb->status = IOSTAT_SUCCESS; |
---|
729 | | - num_posted++; |
---|
730 | | - } |
---|
731 | | - list_add_tail(&psb->list, &scsi_sblist); |
---|
732 | | - } |
---|
733 | | - } |
---|
734 | | - /* Push SCSI buffers with sgl posted to the availble list */ |
---|
735 | | - while (!list_empty(&scsi_sblist)) { |
---|
736 | | - list_remove_head(&scsi_sblist, psb, |
---|
737 | | - struct lpfc_scsi_buf, list); |
---|
738 | | - lpfc_release_scsi_buf_s4(phba, psb); |
---|
739 | | - } |
---|
740 | | - return num_posted; |
---|
741 | | -} |
---|
742 | | - |
---|
743 | | -/** |
---|
744 | | - * lpfc_sli4_repost_scsi_sgl_list - Repost all the allocated scsi buffer sgls |
---|
745 | | - * @phba: pointer to lpfc hba data structure. |
---|
746 | | - * |
---|
747 | | - * This routine walks the list of scsi buffers that have been allocated and |
---|
748 | | - * repost them to the port by using SGL block post. This is needed after a |
---|
749 | | - * pci_function_reset/warm_start or start. The lpfc_hba_down_post_s4 routine |
---|
750 | | - * is responsible for moving all scsi buffers on the lpfc_abts_scsi_sgl_list |
---|
751 | | - * to the lpfc_scsi_buf_list. If the repost fails, reject all scsi buffers. |
---|
752 | | - * |
---|
753 | | - * Returns: 0 = success, non-zero failure. |
---|
754 | | - **/ |
---|
755 | | -int |
---|
756 | | -lpfc_sli4_repost_scsi_sgl_list(struct lpfc_hba *phba) |
---|
757 | | -{ |
---|
758 | | - LIST_HEAD(post_sblist); |
---|
759 | | - int num_posted, rc = 0; |
---|
760 | | - |
---|
761 | | - /* get all SCSI buffers need to repost to a local list */ |
---|
762 | | - spin_lock_irq(&phba->scsi_buf_list_get_lock); |
---|
763 | | - spin_lock(&phba->scsi_buf_list_put_lock); |
---|
764 | | - list_splice_init(&phba->lpfc_scsi_buf_list_get, &post_sblist); |
---|
765 | | - list_splice(&phba->lpfc_scsi_buf_list_put, &post_sblist); |
---|
766 | | - spin_unlock(&phba->scsi_buf_list_put_lock); |
---|
767 | | - spin_unlock_irq(&phba->scsi_buf_list_get_lock); |
---|
768 | | - |
---|
769 | | - /* post the list of scsi buffer sgls to port if available */ |
---|
770 | | - if (!list_empty(&post_sblist)) { |
---|
771 | | - num_posted = lpfc_sli4_post_scsi_sgl_list(phba, &post_sblist, |
---|
772 | | - phba->sli4_hba.scsi_xri_cnt); |
---|
773 | | - /* failed to post any scsi buffer, return error */ |
---|
774 | | - if (num_posted == 0) |
---|
775 | | - rc = -EIO; |
---|
776 | | - } |
---|
777 | | - return rc; |
---|
778 | | -} |
---|
779 | | - |
---|
780 | | -/** |
---|
781 | | - * lpfc_new_scsi_buf_s4 - Scsi buffer allocator for HBA with SLI4 IF spec |
---|
782 | | - * @vport: The virtual port for which this call being executed. |
---|
783 | | - * @num_to_allocate: The requested number of buffers to allocate. |
---|
784 | | - * |
---|
785 | | - * This routine allocates scsi buffers for device with SLI-4 interface spec, |
---|
786 | | - * the scsi buffer contains all the necessary information needed to initiate |
---|
787 | | - * a SCSI I/O. After allocating up to @num_to_allocate SCSI buffers and put |
---|
788 | | - * them on a list, it post them to the port by using SGL block post. |
---|
789 | | - * |
---|
790 | | - * Return codes: |
---|
791 | | - * int - number of scsi buffers that were allocated and posted. |
---|
792 | | - * 0 = failure, less than num_to_alloc is a partial failure. |
---|
793 | | - **/ |
---|
794 | | -static int |
---|
795 | | -lpfc_new_scsi_buf_s4(struct lpfc_vport *vport, int num_to_alloc) |
---|
796 | | -{ |
---|
797 | | - struct lpfc_hba *phba = vport->phba; |
---|
798 | | - struct lpfc_scsi_buf *psb; |
---|
799 | | - struct sli4_sge *sgl; |
---|
800 | | - IOCB_t *iocb; |
---|
801 | | - dma_addr_t pdma_phys_fcp_cmd; |
---|
802 | | - dma_addr_t pdma_phys_fcp_rsp; |
---|
803 | | - dma_addr_t pdma_phys_bpl; |
---|
804 | | - uint16_t iotag, lxri = 0; |
---|
805 | | - int bcnt, num_posted, sgl_size; |
---|
806 | | - LIST_HEAD(prep_sblist); |
---|
807 | | - LIST_HEAD(post_sblist); |
---|
808 | | - LIST_HEAD(scsi_sblist); |
---|
809 | | - |
---|
810 | | - sgl_size = phba->cfg_sg_dma_buf_size - |
---|
811 | | - (sizeof(struct fcp_cmnd) + sizeof(struct fcp_rsp)); |
---|
812 | | - |
---|
813 | | - lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP, |
---|
814 | | - "9068 ALLOC %d scsi_bufs: %d (%d + %d + %d)\n", |
---|
815 | | - num_to_alloc, phba->cfg_sg_dma_buf_size, sgl_size, |
---|
816 | | - (int)sizeof(struct fcp_cmnd), |
---|
817 | | - (int)sizeof(struct fcp_rsp)); |
---|
818 | | - |
---|
819 | | - for (bcnt = 0; bcnt < num_to_alloc; bcnt++) { |
---|
820 | | - psb = kzalloc(sizeof(struct lpfc_scsi_buf), GFP_KERNEL); |
---|
821 | | - if (!psb) |
---|
822 | | - break; |
---|
823 | | - /* |
---|
824 | | - * Get memory from the pci pool to map the virt space to |
---|
825 | | - * pci bus space for an I/O. The DMA buffer includes space |
---|
826 | | - * for the struct fcp_cmnd, struct fcp_rsp and the number |
---|
827 | | - * of bde's necessary to support the sg_tablesize. |
---|
828 | | - */ |
---|
829 | | - psb->data = dma_pool_zalloc(phba->lpfc_sg_dma_buf_pool, |
---|
830 | | - GFP_KERNEL, &psb->dma_handle); |
---|
831 | | - if (!psb->data) { |
---|
832 | | - kfree(psb); |
---|
833 | | - break; |
---|
834 | | - } |
---|
835 | | - |
---|
836 | | - /* |
---|
837 | | - * 4K Page alignment is CRITICAL to BlockGuard, double check |
---|
838 | | - * to be sure. |
---|
839 | | - */ |
---|
840 | | - if ((phba->sli3_options & LPFC_SLI3_BG_ENABLED) && |
---|
841 | | - (((unsigned long)(psb->data) & |
---|
842 | | - (unsigned long)(SLI4_PAGE_SIZE - 1)) != 0)) { |
---|
843 | | - lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
---|
844 | | - "3369 Memory alignment error " |
---|
845 | | - "addr=%lx\n", |
---|
846 | | - (unsigned long)psb->data); |
---|
847 | | - dma_pool_free(phba->lpfc_sg_dma_buf_pool, |
---|
848 | | - psb->data, psb->dma_handle); |
---|
849 | | - kfree(psb); |
---|
850 | | - break; |
---|
851 | | - } |
---|
852 | | - |
---|
853 | | - |
---|
854 | | - lxri = lpfc_sli4_next_xritag(phba); |
---|
855 | | - if (lxri == NO_XRI) { |
---|
856 | | - dma_pool_free(phba->lpfc_sg_dma_buf_pool, |
---|
857 | | - psb->data, psb->dma_handle); |
---|
858 | | - kfree(psb); |
---|
859 | | - break; |
---|
860 | | - } |
---|
861 | | - |
---|
862 | | - /* Allocate iotag for psb->cur_iocbq. */ |
---|
863 | | - iotag = lpfc_sli_next_iotag(phba, &psb->cur_iocbq); |
---|
864 | | - if (iotag == 0) { |
---|
865 | | - dma_pool_free(phba->lpfc_sg_dma_buf_pool, |
---|
866 | | - psb->data, psb->dma_handle); |
---|
867 | | - kfree(psb); |
---|
868 | | - lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
---|
869 | | - "3368 Failed to allocate IOTAG for" |
---|
870 | | - " XRI:0x%x\n", lxri); |
---|
871 | | - lpfc_sli4_free_xri(phba, lxri); |
---|
872 | | - break; |
---|
873 | | - } |
---|
874 | | - psb->cur_iocbq.sli4_lxritag = lxri; |
---|
875 | | - psb->cur_iocbq.sli4_xritag = phba->sli4_hba.xri_ids[lxri]; |
---|
876 | | - psb->cur_iocbq.iocb_flag |= LPFC_IO_FCP; |
---|
877 | | - psb->fcp_bpl = psb->data; |
---|
878 | | - psb->fcp_cmnd = (psb->data + sgl_size); |
---|
879 | | - psb->fcp_rsp = (struct fcp_rsp *)((uint8_t *)psb->fcp_cmnd + |
---|
880 | | - sizeof(struct fcp_cmnd)); |
---|
881 | | - |
---|
882 | | - /* Initialize local short-hand pointers. */ |
---|
883 | | - sgl = (struct sli4_sge *)psb->fcp_bpl; |
---|
884 | | - pdma_phys_bpl = psb->dma_handle; |
---|
885 | | - pdma_phys_fcp_cmd = (psb->dma_handle + sgl_size); |
---|
886 | | - pdma_phys_fcp_rsp = pdma_phys_fcp_cmd + sizeof(struct fcp_cmnd); |
---|
887 | | - |
---|
888 | | - /* |
---|
889 | | - * The first two bdes are the FCP_CMD and FCP_RSP. |
---|
890 | | - * The balance are sg list bdes. Initialize the |
---|
891 | | - * first two and leave the rest for queuecommand. |
---|
892 | | - */ |
---|
893 | | - sgl->addr_hi = cpu_to_le32(putPaddrHigh(pdma_phys_fcp_cmd)); |
---|
894 | | - sgl->addr_lo = cpu_to_le32(putPaddrLow(pdma_phys_fcp_cmd)); |
---|
895 | | - sgl->word2 = le32_to_cpu(sgl->word2); |
---|
896 | | - bf_set(lpfc_sli4_sge_last, sgl, 0); |
---|
897 | | - sgl->word2 = cpu_to_le32(sgl->word2); |
---|
898 | | - sgl->sge_len = cpu_to_le32(sizeof(struct fcp_cmnd)); |
---|
899 | | - sgl++; |
---|
900 | | - |
---|
901 | | - /* Setup the physical region for the FCP RSP */ |
---|
902 | | - sgl->addr_hi = cpu_to_le32(putPaddrHigh(pdma_phys_fcp_rsp)); |
---|
903 | | - sgl->addr_lo = cpu_to_le32(putPaddrLow(pdma_phys_fcp_rsp)); |
---|
904 | | - sgl->word2 = le32_to_cpu(sgl->word2); |
---|
905 | | - bf_set(lpfc_sli4_sge_last, sgl, 1); |
---|
906 | | - sgl->word2 = cpu_to_le32(sgl->word2); |
---|
907 | | - sgl->sge_len = cpu_to_le32(sizeof(struct fcp_rsp)); |
---|
908 | | - |
---|
909 | | - /* |
---|
910 | | - * Since the IOCB for the FCP I/O is built into this |
---|
911 | | - * lpfc_scsi_buf, initialize it with all known data now. |
---|
912 | | - */ |
---|
913 | | - iocb = &psb->cur_iocbq.iocb; |
---|
914 | | - iocb->un.fcpi64.bdl.ulpIoTag32 = 0; |
---|
915 | | - iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BDE_64; |
---|
916 | | - /* setting the BLP size to 2 * sizeof BDE may not be correct. |
---|
917 | | - * We are setting the bpl to point to out sgl. An sgl's |
---|
918 | | - * entries are 16 bytes, a bpl entries are 12 bytes. |
---|
919 | | - */ |
---|
920 | | - iocb->un.fcpi64.bdl.bdeSize = sizeof(struct fcp_cmnd); |
---|
921 | | - iocb->un.fcpi64.bdl.addrLow = putPaddrLow(pdma_phys_fcp_cmd); |
---|
922 | | - iocb->un.fcpi64.bdl.addrHigh = putPaddrHigh(pdma_phys_fcp_cmd); |
---|
923 | | - iocb->ulpBdeCount = 1; |
---|
924 | | - iocb->ulpLe = 1; |
---|
925 | | - iocb->ulpClass = CLASS3; |
---|
926 | | - psb->cur_iocbq.context1 = psb; |
---|
927 | | - psb->dma_phys_bpl = pdma_phys_bpl; |
---|
928 | | - |
---|
929 | | - /* add the scsi buffer to a post list */ |
---|
930 | | - list_add_tail(&psb->list, &post_sblist); |
---|
931 | | - spin_lock_irq(&phba->scsi_buf_list_get_lock); |
---|
932 | | - phba->sli4_hba.scsi_xri_cnt++; |
---|
933 | | - spin_unlock_irq(&phba->scsi_buf_list_get_lock); |
---|
934 | | - } |
---|
935 | | - lpfc_printf_log(phba, KERN_INFO, LOG_BG | LOG_FCP, |
---|
936 | | - "3021 Allocate %d out of %d requested new SCSI " |
---|
937 | | - "buffers\n", bcnt, num_to_alloc); |
---|
938 | | - |
---|
939 | | - /* post the list of scsi buffer sgls to port if available */ |
---|
940 | | - if (!list_empty(&post_sblist)) |
---|
941 | | - num_posted = lpfc_sli4_post_scsi_sgl_list(phba, |
---|
942 | | - &post_sblist, bcnt); |
---|
943 | | - else |
---|
944 | | - num_posted = 0; |
---|
945 | | - |
---|
946 | | - return num_posted; |
---|
947 | | -} |
---|
948 | | - |
---|
949 | | -/** |
---|
950 | | - * lpfc_new_scsi_buf - Wrapper funciton for scsi buffer allocator |
---|
951 | | - * @vport: The virtual port for which this call being executed. |
---|
952 | | - * @num_to_allocate: The requested number of buffers to allocate. |
---|
953 | | - * |
---|
954 | | - * This routine wraps the actual SCSI buffer allocator function pointer from |
---|
955 | | - * the lpfc_hba struct. |
---|
956 | | - * |
---|
957 | | - * Return codes: |
---|
958 | | - * int - number of scsi buffers that were allocated. |
---|
959 | | - * 0 = failure, less than num_to_alloc is a partial failure. |
---|
960 | | - **/ |
---|
961 | | -static inline int |
---|
962 | | -lpfc_new_scsi_buf(struct lpfc_vport *vport, int num_to_alloc) |
---|
963 | | -{ |
---|
964 | | - return vport->phba->lpfc_new_scsi_buf(vport, num_to_alloc); |
---|
965 | 577 | } |
---|
966 | 578 | |
---|
967 | 579 | /** |
---|
.. | .. |
---|
975 | 587 | * NULL - Error |
---|
976 | 588 | * Pointer to lpfc_scsi_buf - Success |
---|
977 | 589 | **/ |
---|
978 | | -static struct lpfc_scsi_buf* |
---|
979 | | -lpfc_get_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) |
---|
| 590 | +static struct lpfc_io_buf * |
---|
| 591 | +lpfc_get_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, |
---|
| 592 | + struct scsi_cmnd *cmnd) |
---|
980 | 593 | { |
---|
981 | | - struct lpfc_scsi_buf * lpfc_cmd = NULL; |
---|
| 594 | + struct lpfc_io_buf *lpfc_cmd = NULL; |
---|
982 | 595 | struct list_head *scsi_buf_list_get = &phba->lpfc_scsi_buf_list_get; |
---|
983 | 596 | unsigned long iflag = 0; |
---|
984 | 597 | |
---|
985 | 598 | spin_lock_irqsave(&phba->scsi_buf_list_get_lock, iflag); |
---|
986 | | - list_remove_head(scsi_buf_list_get, lpfc_cmd, struct lpfc_scsi_buf, |
---|
| 599 | + list_remove_head(scsi_buf_list_get, lpfc_cmd, struct lpfc_io_buf, |
---|
987 | 600 | list); |
---|
988 | 601 | if (!lpfc_cmd) { |
---|
989 | 602 | spin_lock(&phba->scsi_buf_list_put_lock); |
---|
.. | .. |
---|
991 | 604 | &phba->lpfc_scsi_buf_list_get); |
---|
992 | 605 | INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_put); |
---|
993 | 606 | list_remove_head(scsi_buf_list_get, lpfc_cmd, |
---|
994 | | - struct lpfc_scsi_buf, list); |
---|
| 607 | + struct lpfc_io_buf, list); |
---|
995 | 608 | spin_unlock(&phba->scsi_buf_list_put_lock); |
---|
996 | 609 | } |
---|
997 | 610 | spin_unlock_irqrestore(&phba->scsi_buf_list_get_lock, iflag); |
---|
.. | .. |
---|
1003 | 616 | return lpfc_cmd; |
---|
1004 | 617 | } |
---|
1005 | 618 | /** |
---|
1006 | | - * lpfc_get_scsi_buf_s4 - Get a scsi buffer from lpfc_scsi_buf_list of the HBA |
---|
| 619 | + * lpfc_get_scsi_buf_s4 - Get a scsi buffer from io_buf_list of the HBA |
---|
1007 | 620 | * @phba: The HBA for which this call is being executed. |
---|
1008 | 621 | * |
---|
1009 | | - * This routine removes a scsi buffer from head of @phba lpfc_scsi_buf_list list |
---|
| 622 | + * This routine removes a scsi buffer from head of @hdwq io_buf_list |
---|
1010 | 623 | * and returns to caller. |
---|
1011 | 624 | * |
---|
1012 | 625 | * Return codes: |
---|
1013 | 626 | * NULL - Error |
---|
1014 | 627 | * Pointer to lpfc_scsi_buf - Success |
---|
1015 | 628 | **/ |
---|
1016 | | -static struct lpfc_scsi_buf* |
---|
1017 | | -lpfc_get_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) |
---|
| 629 | +static struct lpfc_io_buf * |
---|
| 630 | +lpfc_get_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, |
---|
| 631 | + struct scsi_cmnd *cmnd) |
---|
1018 | 632 | { |
---|
1019 | | - struct lpfc_scsi_buf *lpfc_cmd, *lpfc_cmd_next; |
---|
1020 | | - unsigned long iflag = 0; |
---|
1021 | | - int found = 0; |
---|
| 633 | + struct lpfc_io_buf *lpfc_cmd; |
---|
| 634 | + struct lpfc_sli4_hdw_queue *qp; |
---|
| 635 | + struct sli4_sge *sgl; |
---|
| 636 | + IOCB_t *iocb; |
---|
| 637 | + dma_addr_t pdma_phys_fcp_rsp; |
---|
| 638 | + dma_addr_t pdma_phys_fcp_cmd; |
---|
| 639 | + uint32_t cpu, idx; |
---|
| 640 | + int tag; |
---|
| 641 | + struct fcp_cmd_rsp_buf *tmp = NULL; |
---|
1022 | 642 | |
---|
1023 | | - spin_lock_irqsave(&phba->scsi_buf_list_get_lock, iflag); |
---|
1024 | | - list_for_each_entry_safe(lpfc_cmd, lpfc_cmd_next, |
---|
1025 | | - &phba->lpfc_scsi_buf_list_get, list) { |
---|
1026 | | - if (lpfc_test_rrq_active(phba, ndlp, |
---|
1027 | | - lpfc_cmd->cur_iocbq.sli4_lxritag)) |
---|
1028 | | - continue; |
---|
1029 | | - list_del_init(&lpfc_cmd->list); |
---|
1030 | | - found = 1; |
---|
1031 | | - break; |
---|
| 643 | + cpu = raw_smp_processor_id(); |
---|
| 644 | + if (cmnd && phba->cfg_fcp_io_sched == LPFC_FCP_SCHED_BY_HDWQ) { |
---|
| 645 | + tag = blk_mq_unique_tag(cmnd->request); |
---|
| 646 | + idx = blk_mq_unique_tag_to_hwq(tag); |
---|
| 647 | + } else { |
---|
| 648 | + idx = phba->sli4_hba.cpu_map[cpu].hdwq; |
---|
1032 | 649 | } |
---|
1033 | | - if (!found) { |
---|
1034 | | - spin_lock(&phba->scsi_buf_list_put_lock); |
---|
1035 | | - list_splice(&phba->lpfc_scsi_buf_list_put, |
---|
1036 | | - &phba->lpfc_scsi_buf_list_get); |
---|
1037 | | - INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_put); |
---|
1038 | | - spin_unlock(&phba->scsi_buf_list_put_lock); |
---|
1039 | | - list_for_each_entry_safe(lpfc_cmd, lpfc_cmd_next, |
---|
1040 | | - &phba->lpfc_scsi_buf_list_get, list) { |
---|
1041 | | - if (lpfc_test_rrq_active( |
---|
1042 | | - phba, ndlp, lpfc_cmd->cur_iocbq.sli4_lxritag)) |
---|
1043 | | - continue; |
---|
1044 | | - list_del_init(&lpfc_cmd->list); |
---|
1045 | | - found = 1; |
---|
1046 | | - break; |
---|
1047 | | - } |
---|
1048 | | - } |
---|
1049 | | - spin_unlock_irqrestore(&phba->scsi_buf_list_get_lock, iflag); |
---|
1050 | | - if (!found) |
---|
| 650 | + |
---|
| 651 | + lpfc_cmd = lpfc_get_io_buf(phba, ndlp, idx, |
---|
| 652 | + !phba->cfg_xri_rebalancing); |
---|
| 653 | + if (!lpfc_cmd) { |
---|
| 654 | + qp = &phba->sli4_hba.hdwq[idx]; |
---|
| 655 | + qp->empty_io_bufs++; |
---|
1051 | 656 | return NULL; |
---|
| 657 | + } |
---|
1052 | 658 | |
---|
1053 | | - if (lpfc_ndlp_check_qdepth(phba, ndlp) && lpfc_cmd) { |
---|
| 659 | + /* Setup key fields in buffer that may have been changed |
---|
| 660 | + * if other protocols used this buffer. |
---|
| 661 | + */ |
---|
| 662 | + lpfc_cmd->cur_iocbq.iocb_flag = LPFC_IO_FCP; |
---|
| 663 | + lpfc_cmd->prot_seg_cnt = 0; |
---|
| 664 | + lpfc_cmd->seg_cnt = 0; |
---|
| 665 | + lpfc_cmd->timeout = 0; |
---|
| 666 | + lpfc_cmd->flags = 0; |
---|
| 667 | + lpfc_cmd->start_time = jiffies; |
---|
| 668 | + lpfc_cmd->waitq = NULL; |
---|
| 669 | + lpfc_cmd->cpu = cpu; |
---|
| 670 | +#ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
---|
| 671 | + lpfc_cmd->prot_data_type = 0; |
---|
| 672 | +#endif |
---|
| 673 | + tmp = lpfc_get_cmd_rsp_buf_per_hdwq(phba, lpfc_cmd); |
---|
| 674 | + if (!tmp) { |
---|
| 675 | + lpfc_release_io_buf(phba, lpfc_cmd, lpfc_cmd->hdwq); |
---|
| 676 | + return NULL; |
---|
| 677 | + } |
---|
| 678 | + |
---|
| 679 | + lpfc_cmd->fcp_cmnd = tmp->fcp_cmnd; |
---|
| 680 | + lpfc_cmd->fcp_rsp = tmp->fcp_rsp; |
---|
| 681 | + |
---|
| 682 | + /* |
---|
| 683 | + * The first two SGEs are the FCP_CMD and FCP_RSP. |
---|
| 684 | + * The balance are sg list bdes. Initialize the |
---|
| 685 | + * first two and leave the rest for queuecommand. |
---|
| 686 | + */ |
---|
| 687 | + sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl; |
---|
| 688 | + pdma_phys_fcp_cmd = tmp->fcp_cmd_rsp_dma_handle; |
---|
| 689 | + sgl->addr_hi = cpu_to_le32(putPaddrHigh(pdma_phys_fcp_cmd)); |
---|
| 690 | + sgl->addr_lo = cpu_to_le32(putPaddrLow(pdma_phys_fcp_cmd)); |
---|
| 691 | + sgl->word2 = le32_to_cpu(sgl->word2); |
---|
| 692 | + bf_set(lpfc_sli4_sge_last, sgl, 0); |
---|
| 693 | + sgl->word2 = cpu_to_le32(sgl->word2); |
---|
| 694 | + sgl->sge_len = cpu_to_le32(sizeof(struct fcp_cmnd)); |
---|
| 695 | + sgl++; |
---|
| 696 | + |
---|
| 697 | + /* Setup the physical region for the FCP RSP */ |
---|
| 698 | + pdma_phys_fcp_rsp = pdma_phys_fcp_cmd + sizeof(struct fcp_cmnd); |
---|
| 699 | + sgl->addr_hi = cpu_to_le32(putPaddrHigh(pdma_phys_fcp_rsp)); |
---|
| 700 | + sgl->addr_lo = cpu_to_le32(putPaddrLow(pdma_phys_fcp_rsp)); |
---|
| 701 | + sgl->word2 = le32_to_cpu(sgl->word2); |
---|
| 702 | + bf_set(lpfc_sli4_sge_last, sgl, 1); |
---|
| 703 | + sgl->word2 = cpu_to_le32(sgl->word2); |
---|
| 704 | + sgl->sge_len = cpu_to_le32(sizeof(struct fcp_rsp)); |
---|
| 705 | + |
---|
| 706 | + /* |
---|
| 707 | + * Since the IOCB for the FCP I/O is built into this |
---|
| 708 | + * lpfc_io_buf, initialize it with all known data now. |
---|
| 709 | + */ |
---|
| 710 | + iocb = &lpfc_cmd->cur_iocbq.iocb; |
---|
| 711 | + iocb->un.fcpi64.bdl.ulpIoTag32 = 0; |
---|
| 712 | + iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BDE_64; |
---|
| 713 | + /* setting the BLP size to 2 * sizeof BDE may not be correct. |
---|
| 714 | + * We are setting the bpl to point to out sgl. An sgl's |
---|
| 715 | + * entries are 16 bytes, a bpl entries are 12 bytes. |
---|
| 716 | + */ |
---|
| 717 | + iocb->un.fcpi64.bdl.bdeSize = sizeof(struct fcp_cmnd); |
---|
| 718 | + iocb->un.fcpi64.bdl.addrLow = putPaddrLow(pdma_phys_fcp_cmd); |
---|
| 719 | + iocb->un.fcpi64.bdl.addrHigh = putPaddrHigh(pdma_phys_fcp_cmd); |
---|
| 720 | + iocb->ulpBdeCount = 1; |
---|
| 721 | + iocb->ulpLe = 1; |
---|
| 722 | + iocb->ulpClass = CLASS3; |
---|
| 723 | + |
---|
| 724 | + if (lpfc_ndlp_check_qdepth(phba, ndlp)) { |
---|
1054 | 725 | atomic_inc(&ndlp->cmd_pending); |
---|
1055 | 726 | lpfc_cmd->flags |= LPFC_SBUF_BUMP_QDEPTH; |
---|
1056 | 727 | } |
---|
.. | .. |
---|
1067 | 738 | * NULL - Error |
---|
1068 | 739 | * Pointer to lpfc_scsi_buf - Success |
---|
1069 | 740 | **/ |
---|
1070 | | -static struct lpfc_scsi_buf* |
---|
1071 | | -lpfc_get_scsi_buf(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) |
---|
| 741 | +static struct lpfc_io_buf* |
---|
| 742 | +lpfc_get_scsi_buf(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, |
---|
| 743 | + struct scsi_cmnd *cmnd) |
---|
1072 | 744 | { |
---|
1073 | | - return phba->lpfc_get_scsi_buf(phba, ndlp); |
---|
| 745 | + return phba->lpfc_get_scsi_buf(phba, ndlp, cmnd); |
---|
1074 | 746 | } |
---|
1075 | 747 | |
---|
1076 | 748 | /** |
---|
.. | .. |
---|
1082 | 754 | * lpfc_scsi_buf_list list. |
---|
1083 | 755 | **/ |
---|
1084 | 756 | static void |
---|
1085 | | -lpfc_release_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb) |
---|
| 757 | +lpfc_release_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_io_buf *psb) |
---|
1086 | 758 | { |
---|
1087 | 759 | unsigned long iflag = 0; |
---|
1088 | 760 | |
---|
1089 | 761 | psb->seg_cnt = 0; |
---|
1090 | | - psb->nonsg_phys = 0; |
---|
1091 | 762 | psb->prot_seg_cnt = 0; |
---|
1092 | 763 | |
---|
1093 | 764 | spin_lock_irqsave(&phba->scsi_buf_list_put_lock, iflag); |
---|
.. | .. |
---|
1102 | 773 | * @phba: The Hba for which this call is being executed. |
---|
1103 | 774 | * @psb: The scsi buffer which is being released. |
---|
1104 | 775 | * |
---|
1105 | | - * This routine releases @psb scsi buffer by adding it to tail of @phba |
---|
1106 | | - * lpfc_scsi_buf_list list. For SLI4 XRI's are tied to the scsi buffer |
---|
| 776 | + * This routine releases @psb scsi buffer by adding it to tail of @hdwq |
---|
| 777 | + * io_buf_list list. For SLI4 XRI's are tied to the scsi buffer |
---|
1107 | 778 | * and cannot be reused for at least RA_TOV amount of time if it was |
---|
1108 | 779 | * aborted. |
---|
1109 | 780 | **/ |
---|
1110 | 781 | static void |
---|
1111 | | -lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb) |
---|
| 782 | +lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_io_buf *psb) |
---|
1112 | 783 | { |
---|
| 784 | + struct lpfc_sli4_hdw_queue *qp; |
---|
1113 | 785 | unsigned long iflag = 0; |
---|
1114 | 786 | |
---|
1115 | 787 | psb->seg_cnt = 0; |
---|
1116 | | - psb->nonsg_phys = 0; |
---|
1117 | 788 | psb->prot_seg_cnt = 0; |
---|
1118 | 789 | |
---|
1119 | | - if (psb->exch_busy) { |
---|
1120 | | - spin_lock_irqsave(&phba->sli4_hba.abts_scsi_buf_list_lock, |
---|
1121 | | - iflag); |
---|
| 790 | + qp = psb->hdwq; |
---|
| 791 | + if (psb->flags & LPFC_SBUF_XBUSY) { |
---|
| 792 | + spin_lock_irqsave(&qp->abts_io_buf_list_lock, iflag); |
---|
1122 | 793 | psb->pCmd = NULL; |
---|
1123 | | - list_add_tail(&psb->list, |
---|
1124 | | - &phba->sli4_hba.lpfc_abts_scsi_buf_list); |
---|
1125 | | - spin_unlock_irqrestore(&phba->sli4_hba.abts_scsi_buf_list_lock, |
---|
1126 | | - iflag); |
---|
| 794 | + list_add_tail(&psb->list, &qp->lpfc_abts_io_buf_list); |
---|
| 795 | + qp->abts_scsi_io_bufs++; |
---|
| 796 | + spin_unlock_irqrestore(&qp->abts_io_buf_list_lock, iflag); |
---|
1127 | 797 | } else { |
---|
1128 | | - psb->pCmd = NULL; |
---|
1129 | | - psb->cur_iocbq.iocb_flag = LPFC_IO_FCP; |
---|
1130 | | - spin_lock_irqsave(&phba->scsi_buf_list_put_lock, iflag); |
---|
1131 | | - list_add_tail(&psb->list, &phba->lpfc_scsi_buf_list_put); |
---|
1132 | | - spin_unlock_irqrestore(&phba->scsi_buf_list_put_lock, iflag); |
---|
| 798 | + lpfc_release_io_buf(phba, (struct lpfc_io_buf *)psb, qp); |
---|
1133 | 799 | } |
---|
1134 | 800 | } |
---|
1135 | 801 | |
---|
.. | .. |
---|
1142 | 808 | * lpfc_scsi_buf_list list. |
---|
1143 | 809 | **/ |
---|
1144 | 810 | static void |
---|
1145 | | -lpfc_release_scsi_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb) |
---|
| 811 | +lpfc_release_scsi_buf(struct lpfc_hba *phba, struct lpfc_io_buf *psb) |
---|
1146 | 812 | { |
---|
1147 | 813 | if ((psb->flags & LPFC_SBUF_BUMP_QDEPTH) && psb->ndlp) |
---|
1148 | 814 | atomic_dec(&psb->ndlp->cmd_pending); |
---|
.. | .. |
---|
1166 | 832 | * 0 - Success |
---|
1167 | 833 | **/ |
---|
1168 | 834 | static int |
---|
1169 | | -lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) |
---|
| 835 | +lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) |
---|
1170 | 836 | { |
---|
1171 | 837 | struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd; |
---|
1172 | 838 | struct scatterlist *sgel = NULL; |
---|
1173 | 839 | struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd; |
---|
1174 | | - struct ulp_bde64 *bpl = lpfc_cmd->fcp_bpl; |
---|
| 840 | + struct ulp_bde64 *bpl = (struct ulp_bde64 *)lpfc_cmd->dma_sgl; |
---|
1175 | 841 | struct lpfc_iocbq *iocbq = &lpfc_cmd->cur_iocbq; |
---|
1176 | 842 | IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb; |
---|
1177 | 843 | struct ulp_bde64 *data_bde = iocb_cmd->unsli3.fcp_ext.dbde; |
---|
.. | .. |
---|
1201 | 867 | |
---|
1202 | 868 | lpfc_cmd->seg_cnt = nseg; |
---|
1203 | 869 | if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) { |
---|
1204 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
1205 | | - "9064 BLKGRD: %s: Too many sg segments from " |
---|
1206 | | - "dma_map_sg. Config %d, seg_cnt %d\n", |
---|
1207 | | - __func__, phba->cfg_sg_seg_cnt, |
---|
1208 | | - lpfc_cmd->seg_cnt); |
---|
| 870 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
| 871 | + "9064 BLKGRD: %s: Too many sg segments" |
---|
| 872 | + " from dma_map_sg. Config %d, seg_cnt" |
---|
| 873 | + " %d\n", __func__, phba->cfg_sg_seg_cnt, |
---|
| 874 | + lpfc_cmd->seg_cnt); |
---|
| 875 | + WARN_ON_ONCE(lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt); |
---|
1209 | 876 | lpfc_cmd->seg_cnt = 0; |
---|
1210 | 877 | scsi_dma_unmap(scsi_cmnd); |
---|
1211 | | - return 1; |
---|
| 878 | + return 2; |
---|
1212 | 879 | } |
---|
1213 | 880 | |
---|
1214 | 881 | /* |
---|
.. | .. |
---|
1318 | 985 | uint32_t *reftag, uint16_t *apptag, uint32_t new_guard) |
---|
1319 | 986 | { |
---|
1320 | 987 | struct scatterlist *sgpe; /* s/g prot entry */ |
---|
1321 | | - struct lpfc_scsi_buf *lpfc_cmd = NULL; |
---|
| 988 | + struct lpfc_io_buf *lpfc_cmd = NULL; |
---|
1322 | 989 | struct scsi_dif_tuple *src = NULL; |
---|
1323 | 990 | struct lpfc_nodelist *ndlp; |
---|
1324 | 991 | struct lpfc_rport_data *rdata; |
---|
.. | .. |
---|
1377 | 1044 | if (sgpe) { |
---|
1378 | 1045 | src = (struct scsi_dif_tuple *)sg_virt(sgpe); |
---|
1379 | 1046 | src += blockoff; |
---|
1380 | | - lpfc_cmd = (struct lpfc_scsi_buf *)sc->host_scribble; |
---|
| 1047 | + lpfc_cmd = (struct lpfc_io_buf *)sc->host_scribble; |
---|
1381 | 1048 | } |
---|
1382 | 1049 | |
---|
1383 | 1050 | /* Should we change the Reference Tag */ |
---|
.. | .. |
---|
1394 | 1061 | * inserted in middle of the IO. |
---|
1395 | 1062 | */ |
---|
1396 | 1063 | |
---|
1397 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 1064 | + lpfc_printf_log(phba, KERN_ERR, |
---|
| 1065 | + LOG_TRACE_EVENT, |
---|
1398 | 1066 | "9076 BLKGRD: Injecting reftag error: " |
---|
1399 | 1067 | "write lba x%lx + x%x oldrefTag x%x\n", |
---|
1400 | 1068 | (unsigned long)lba, blockoff, |
---|
.. | .. |
---|
1425 | 1093 | |
---|
1426 | 1094 | break; |
---|
1427 | 1095 | } |
---|
1428 | | - /* Drop thru */ |
---|
| 1096 | + fallthrough; |
---|
1429 | 1097 | case SCSI_PROT_WRITE_INSERT: |
---|
1430 | 1098 | /* |
---|
1431 | 1099 | * For WRITE_INSERT, force the error |
---|
.. | .. |
---|
1444 | 1112 | } |
---|
1445 | 1113 | rc = BG_ERR_TGT | BG_ERR_CHECK; |
---|
1446 | 1114 | |
---|
1447 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 1115 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
1448 | 1116 | "9078 BLKGRD: Injecting reftag error: " |
---|
1449 | 1117 | "write lba x%lx\n", (unsigned long)lba); |
---|
1450 | 1118 | break; |
---|
.. | .. |
---|
1465 | 1133 | } |
---|
1466 | 1134 | rc = BG_ERR_INIT; |
---|
1467 | 1135 | |
---|
1468 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 1136 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
1469 | 1137 | "9077 BLKGRD: Injecting reftag error: " |
---|
1470 | 1138 | "write lba x%lx\n", (unsigned long)lba); |
---|
1471 | 1139 | break; |
---|
.. | .. |
---|
1492 | 1160 | } |
---|
1493 | 1161 | rc = BG_ERR_INIT; |
---|
1494 | 1162 | |
---|
1495 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 1163 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
1496 | 1164 | "9079 BLKGRD: Injecting reftag error: " |
---|
1497 | 1165 | "read lba x%lx\n", (unsigned long)lba); |
---|
1498 | 1166 | break; |
---|
.. | .. |
---|
1514 | 1182 | * inserted in middle of the IO. |
---|
1515 | 1183 | */ |
---|
1516 | 1184 | |
---|
1517 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 1185 | + lpfc_printf_log(phba, KERN_ERR, |
---|
| 1186 | + LOG_TRACE_EVENT, |
---|
1518 | 1187 | "9080 BLKGRD: Injecting apptag error: " |
---|
1519 | 1188 | "write lba x%lx + x%x oldappTag x%x\n", |
---|
1520 | 1189 | (unsigned long)lba, blockoff, |
---|
.. | .. |
---|
1544 | 1213 | rc = BG_ERR_TGT | BG_ERR_CHECK; |
---|
1545 | 1214 | break; |
---|
1546 | 1215 | } |
---|
1547 | | - /* Drop thru */ |
---|
| 1216 | + fallthrough; |
---|
1548 | 1217 | case SCSI_PROT_WRITE_INSERT: |
---|
1549 | 1218 | /* |
---|
1550 | 1219 | * For WRITE_INSERT, force the |
---|
.. | .. |
---|
1563 | 1232 | } |
---|
1564 | 1233 | rc = BG_ERR_TGT | BG_ERR_CHECK; |
---|
1565 | 1234 | |
---|
1566 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 1235 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
1567 | 1236 | "0813 BLKGRD: Injecting apptag error: " |
---|
1568 | 1237 | "write lba x%lx\n", (unsigned long)lba); |
---|
1569 | 1238 | break; |
---|
.. | .. |
---|
1584 | 1253 | } |
---|
1585 | 1254 | rc = BG_ERR_INIT; |
---|
1586 | 1255 | |
---|
1587 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 1256 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
1588 | 1257 | "0812 BLKGRD: Injecting apptag error: " |
---|
1589 | 1258 | "write lba x%lx\n", (unsigned long)lba); |
---|
1590 | 1259 | break; |
---|
.. | .. |
---|
1611 | 1280 | } |
---|
1612 | 1281 | rc = BG_ERR_INIT; |
---|
1613 | 1282 | |
---|
1614 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 1283 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
1615 | 1284 | "0814 BLKGRD: Injecting apptag error: " |
---|
1616 | 1285 | "read lba x%lx\n", (unsigned long)lba); |
---|
1617 | 1286 | break; |
---|
.. | .. |
---|
1626 | 1295 | switch (op) { |
---|
1627 | 1296 | case SCSI_PROT_WRITE_PASS: |
---|
1628 | 1297 | rc = BG_ERR_CHECK; |
---|
1629 | | - /* Drop thru */ |
---|
| 1298 | + fallthrough; |
---|
1630 | 1299 | |
---|
1631 | 1300 | case SCSI_PROT_WRITE_INSERT: |
---|
1632 | 1301 | /* |
---|
.. | .. |
---|
1646 | 1315 | rc |= BG_ERR_TGT | BG_ERR_SWAP; |
---|
1647 | 1316 | /* Signals the caller to swap CRC->CSUM */ |
---|
1648 | 1317 | |
---|
1649 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 1318 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
1650 | 1319 | "0817 BLKGRD: Injecting guard error: " |
---|
1651 | 1320 | "write lba x%lx\n", (unsigned long)lba); |
---|
1652 | 1321 | break; |
---|
.. | .. |
---|
1668 | 1337 | rc = BG_ERR_INIT | BG_ERR_SWAP; |
---|
1669 | 1338 | /* Signals the caller to swap CRC->CSUM */ |
---|
1670 | 1339 | |
---|
1671 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 1340 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
1672 | 1341 | "0816 BLKGRD: Injecting guard error: " |
---|
1673 | 1342 | "write lba x%lx\n", (unsigned long)lba); |
---|
1674 | 1343 | break; |
---|
.. | .. |
---|
1696 | 1365 | rc = BG_ERR_INIT | BG_ERR_SWAP; |
---|
1697 | 1366 | /* Signals the caller to swap CRC->CSUM */ |
---|
1698 | 1367 | |
---|
1699 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 1368 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
1700 | 1369 | "0818 BLKGRD: Injecting guard error: " |
---|
1701 | 1370 | "read lba x%lx\n", (unsigned long)lba); |
---|
1702 | 1371 | } |
---|
.. | .. |
---|
1746 | 1415 | |
---|
1747 | 1416 | case SCSI_PROT_NORMAL: |
---|
1748 | 1417 | default: |
---|
1749 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 1418 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
1750 | 1419 | "9063 BLKGRD: Bad op/guard:%d/IP combination\n", |
---|
1751 | 1420 | scsi_get_prot_op(sc)); |
---|
1752 | 1421 | ret = 1; |
---|
.. | .. |
---|
1775 | 1444 | |
---|
1776 | 1445 | case SCSI_PROT_NORMAL: |
---|
1777 | 1446 | default: |
---|
1778 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 1447 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
1779 | 1448 | "9075 BLKGRD: Bad op/guard:%d/CRC combination\n", |
---|
1780 | 1449 | scsi_get_prot_op(sc)); |
---|
1781 | 1450 | ret = 1; |
---|
.. | .. |
---|
2061 | 1730 | sgde = scsi_sglist(sc); |
---|
2062 | 1731 | |
---|
2063 | 1732 | if (!sgpe || !sgde) { |
---|
2064 | | - lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
---|
2065 | | - "9020 Invalid s/g entry: data=0x%p prot=0x%p\n", |
---|
| 1733 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
| 1734 | + "9020 Invalid s/g entry: data=x%px prot=x%px\n", |
---|
2066 | 1735 | sgpe, sgde); |
---|
2067 | 1736 | return 0; |
---|
2068 | 1737 | } |
---|
.. | .. |
---|
2173 | 1842 | return num_bde + 1; |
---|
2174 | 1843 | |
---|
2175 | 1844 | if (!sgde) { |
---|
2176 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 1845 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
2177 | 1846 | "9065 BLKGRD:%s Invalid data segment\n", |
---|
2178 | 1847 | __func__); |
---|
2179 | 1848 | return 0; |
---|
.. | .. |
---|
2236 | 1905 | reftag += protgrp_blks; |
---|
2237 | 1906 | } else { |
---|
2238 | 1907 | /* if we're here, we have a bug */ |
---|
2239 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
2240 | | - "9054 BLKGRD: bug in %s\n", __func__); |
---|
| 1908 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
| 1909 | + "9054 BLKGRD: bug in %s\n", __func__); |
---|
2241 | 1910 | } |
---|
2242 | 1911 | |
---|
2243 | 1912 | } while (!alldone); |
---|
.. | .. |
---|
2277 | 1946 | **/ |
---|
2278 | 1947 | static int |
---|
2279 | 1948 | lpfc_bg_setup_sgl(struct lpfc_hba *phba, struct scsi_cmnd *sc, |
---|
2280 | | - struct sli4_sge *sgl, int datasegcnt) |
---|
| 1949 | + struct sli4_sge *sgl, int datasegcnt, |
---|
| 1950 | + struct lpfc_io_buf *lpfc_cmd) |
---|
2281 | 1951 | { |
---|
2282 | 1952 | struct scatterlist *sgde = NULL; /* s/g data entry */ |
---|
2283 | 1953 | struct sli4_sge_diseed *diseed = NULL; |
---|
.. | .. |
---|
2291 | 1961 | uint32_t checking = 1; |
---|
2292 | 1962 | uint32_t dma_len; |
---|
2293 | 1963 | uint32_t dma_offset = 0; |
---|
| 1964 | + struct sli4_hybrid_sgl *sgl_xtra = NULL; |
---|
| 1965 | + int j; |
---|
| 1966 | + bool lsp_just_set = false; |
---|
2294 | 1967 | |
---|
2295 | 1968 | status = lpfc_sc_to_bg_opcodes(phba, sc, &txop, &rxop); |
---|
2296 | 1969 | if (status) |
---|
.. | .. |
---|
2350 | 2023 | sgl++; |
---|
2351 | 2024 | |
---|
2352 | 2025 | /* assumption: caller has already run dma_map_sg on command data */ |
---|
2353 | | - scsi_for_each_sg(sc, sgde, datasegcnt, i) { |
---|
2354 | | - physaddr = sg_dma_address(sgde); |
---|
2355 | | - dma_len = sg_dma_len(sgde); |
---|
2356 | | - sgl->addr_lo = cpu_to_le32(putPaddrLow(physaddr)); |
---|
2357 | | - sgl->addr_hi = cpu_to_le32(putPaddrHigh(physaddr)); |
---|
2358 | | - if ((i + 1) == datasegcnt) |
---|
2359 | | - bf_set(lpfc_sli4_sge_last, sgl, 1); |
---|
2360 | | - else |
---|
2361 | | - bf_set(lpfc_sli4_sge_last, sgl, 0); |
---|
2362 | | - bf_set(lpfc_sli4_sge_offset, sgl, dma_offset); |
---|
2363 | | - bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_DATA); |
---|
| 2026 | + sgde = scsi_sglist(sc); |
---|
| 2027 | + j = 3; |
---|
| 2028 | + for (i = 0; i < datasegcnt; i++) { |
---|
| 2029 | + /* clear it */ |
---|
| 2030 | + sgl->word2 = 0; |
---|
2364 | 2031 | |
---|
2365 | | - sgl->sge_len = cpu_to_le32(dma_len); |
---|
2366 | | - dma_offset += dma_len; |
---|
| 2032 | + /* do we need to expand the segment */ |
---|
| 2033 | + if (!lsp_just_set && !((j + 1) % phba->border_sge_num) && |
---|
| 2034 | + ((datasegcnt - 1) != i)) { |
---|
| 2035 | + /* set LSP type */ |
---|
| 2036 | + bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_LSP); |
---|
2367 | 2037 | |
---|
2368 | | - sgl++; |
---|
2369 | | - num_sge++; |
---|
| 2038 | + sgl_xtra = lpfc_get_sgl_per_hdwq(phba, lpfc_cmd); |
---|
| 2039 | + |
---|
| 2040 | + if (unlikely(!sgl_xtra)) { |
---|
| 2041 | + lpfc_cmd->seg_cnt = 0; |
---|
| 2042 | + return 0; |
---|
| 2043 | + } |
---|
| 2044 | + sgl->addr_lo = cpu_to_le32(putPaddrLow( |
---|
| 2045 | + sgl_xtra->dma_phys_sgl)); |
---|
| 2046 | + sgl->addr_hi = cpu_to_le32(putPaddrHigh( |
---|
| 2047 | + sgl_xtra->dma_phys_sgl)); |
---|
| 2048 | + |
---|
| 2049 | + } else { |
---|
| 2050 | + bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_DATA); |
---|
| 2051 | + } |
---|
| 2052 | + |
---|
| 2053 | + if (!(bf_get(lpfc_sli4_sge_type, sgl) & LPFC_SGE_TYPE_LSP)) { |
---|
| 2054 | + if ((datasegcnt - 1) == i) |
---|
| 2055 | + bf_set(lpfc_sli4_sge_last, sgl, 1); |
---|
| 2056 | + physaddr = sg_dma_address(sgde); |
---|
| 2057 | + dma_len = sg_dma_len(sgde); |
---|
| 2058 | + sgl->addr_lo = cpu_to_le32(putPaddrLow(physaddr)); |
---|
| 2059 | + sgl->addr_hi = cpu_to_le32(putPaddrHigh(physaddr)); |
---|
| 2060 | + |
---|
| 2061 | + bf_set(lpfc_sli4_sge_offset, sgl, dma_offset); |
---|
| 2062 | + sgl->word2 = cpu_to_le32(sgl->word2); |
---|
| 2063 | + sgl->sge_len = cpu_to_le32(dma_len); |
---|
| 2064 | + |
---|
| 2065 | + dma_offset += dma_len; |
---|
| 2066 | + sgde = sg_next(sgde); |
---|
| 2067 | + |
---|
| 2068 | + sgl++; |
---|
| 2069 | + num_sge++; |
---|
| 2070 | + lsp_just_set = false; |
---|
| 2071 | + |
---|
| 2072 | + } else { |
---|
| 2073 | + sgl->word2 = cpu_to_le32(sgl->word2); |
---|
| 2074 | + sgl->sge_len = cpu_to_le32(phba->cfg_sg_dma_buf_size); |
---|
| 2075 | + |
---|
| 2076 | + sgl = (struct sli4_sge *)sgl_xtra->dma_sgl; |
---|
| 2077 | + i = i - 1; |
---|
| 2078 | + |
---|
| 2079 | + lsp_just_set = true; |
---|
| 2080 | + } |
---|
| 2081 | + |
---|
| 2082 | + j++; |
---|
| 2083 | + |
---|
2370 | 2084 | } |
---|
2371 | 2085 | |
---|
2372 | 2086 | out: |
---|
.. | .. |
---|
2412 | 2126 | **/ |
---|
2413 | 2127 | static int |
---|
2414 | 2128 | lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, |
---|
2415 | | - struct sli4_sge *sgl, int datacnt, int protcnt) |
---|
| 2129 | + struct sli4_sge *sgl, int datacnt, int protcnt, |
---|
| 2130 | + struct lpfc_io_buf *lpfc_cmd) |
---|
2416 | 2131 | { |
---|
2417 | 2132 | struct scatterlist *sgde = NULL; /* s/g data entry */ |
---|
2418 | 2133 | struct scatterlist *sgpe = NULL; /* s/g prot entry */ |
---|
.. | .. |
---|
2434 | 2149 | #endif |
---|
2435 | 2150 | uint32_t checking = 1; |
---|
2436 | 2151 | uint32_t dma_offset = 0; |
---|
2437 | | - int num_sge = 0; |
---|
| 2152 | + int num_sge = 0, j = 2; |
---|
| 2153 | + struct sli4_hybrid_sgl *sgl_xtra = NULL; |
---|
2438 | 2154 | |
---|
2439 | 2155 | sgpe = scsi_prot_sglist(sc); |
---|
2440 | 2156 | sgde = scsi_sglist(sc); |
---|
2441 | 2157 | |
---|
2442 | 2158 | if (!sgpe || !sgde) { |
---|
2443 | | - lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
---|
2444 | | - "9082 Invalid s/g entry: data=0x%p prot=0x%p\n", |
---|
| 2159 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
| 2160 | + "9082 Invalid s/g entry: data=x%px prot=x%px\n", |
---|
2445 | 2161 | sgpe, sgde); |
---|
2446 | 2162 | return 0; |
---|
2447 | 2163 | } |
---|
.. | .. |
---|
2467 | 2183 | split_offset = 0; |
---|
2468 | 2184 | do { |
---|
2469 | 2185 | /* Check to see if we ran out of space */ |
---|
2470 | | - if (num_sge >= (phba->cfg_total_seg_cnt - 2)) |
---|
| 2186 | + if ((num_sge >= (phba->cfg_total_seg_cnt - 2)) && |
---|
| 2187 | + !(phba->cfg_xpsgl)) |
---|
2471 | 2188 | return num_sge + 3; |
---|
| 2189 | + |
---|
| 2190 | + /* DISEED and DIF have to be together */ |
---|
| 2191 | + if (!((j + 1) % phba->border_sge_num) || |
---|
| 2192 | + !((j + 2) % phba->border_sge_num) || |
---|
| 2193 | + !((j + 3) % phba->border_sge_num)) { |
---|
| 2194 | + sgl->word2 = 0; |
---|
| 2195 | + |
---|
| 2196 | + /* set LSP type */ |
---|
| 2197 | + bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_LSP); |
---|
| 2198 | + |
---|
| 2199 | + sgl_xtra = lpfc_get_sgl_per_hdwq(phba, lpfc_cmd); |
---|
| 2200 | + |
---|
| 2201 | + if (unlikely(!sgl_xtra)) { |
---|
| 2202 | + goto out; |
---|
| 2203 | + } else { |
---|
| 2204 | + sgl->addr_lo = cpu_to_le32(putPaddrLow( |
---|
| 2205 | + sgl_xtra->dma_phys_sgl)); |
---|
| 2206 | + sgl->addr_hi = cpu_to_le32(putPaddrHigh( |
---|
| 2207 | + sgl_xtra->dma_phys_sgl)); |
---|
| 2208 | + } |
---|
| 2209 | + |
---|
| 2210 | + sgl->word2 = cpu_to_le32(sgl->word2); |
---|
| 2211 | + sgl->sge_len = cpu_to_le32(phba->cfg_sg_dma_buf_size); |
---|
| 2212 | + |
---|
| 2213 | + sgl = (struct sli4_sge *)sgl_xtra->dma_sgl; |
---|
| 2214 | + j = 0; |
---|
| 2215 | + } |
---|
2472 | 2216 | |
---|
2473 | 2217 | /* setup DISEED with what we have */ |
---|
2474 | 2218 | diseed = (struct sli4_sge_diseed *) sgl; |
---|
.. | .. |
---|
2516 | 2260 | |
---|
2517 | 2261 | /* advance sgl and increment bde count */ |
---|
2518 | 2262 | num_sge++; |
---|
| 2263 | + |
---|
2519 | 2264 | sgl++; |
---|
| 2265 | + j++; |
---|
2520 | 2266 | |
---|
2521 | 2267 | /* setup the first BDE that points to protection buffer */ |
---|
2522 | 2268 | protphysaddr = sg_dma_address(sgpe) + protgroup_offset; |
---|
.. | .. |
---|
2531 | 2277 | sgl->addr_hi = le32_to_cpu(putPaddrHigh(protphysaddr)); |
---|
2532 | 2278 | sgl->addr_lo = le32_to_cpu(putPaddrLow(protphysaddr)); |
---|
2533 | 2279 | sgl->word2 = cpu_to_le32(sgl->word2); |
---|
| 2280 | + sgl->sge_len = 0; |
---|
2534 | 2281 | |
---|
2535 | 2282 | protgrp_blks = protgroup_len / 8; |
---|
2536 | 2283 | protgrp_bytes = protgrp_blks * blksize; |
---|
.. | .. |
---|
2551 | 2298 | /* setup SGE's for data blocks associated with DIF data */ |
---|
2552 | 2299 | pgdone = 0; |
---|
2553 | 2300 | subtotal = 0; /* total bytes processed for current prot grp */ |
---|
| 2301 | + |
---|
| 2302 | + sgl++; |
---|
| 2303 | + j++; |
---|
| 2304 | + |
---|
2554 | 2305 | while (!pgdone) { |
---|
2555 | 2306 | /* Check to see if we ran out of space */ |
---|
2556 | | - if (num_sge >= phba->cfg_total_seg_cnt) |
---|
| 2307 | + if ((num_sge >= phba->cfg_total_seg_cnt) && |
---|
| 2308 | + !phba->cfg_xpsgl) |
---|
2557 | 2309 | return num_sge + 1; |
---|
2558 | 2310 | |
---|
2559 | 2311 | if (!sgde) { |
---|
2560 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 2312 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
2561 | 2313 | "9086 BLKGRD:%s Invalid data segment\n", |
---|
2562 | 2314 | __func__); |
---|
2563 | 2315 | return 0; |
---|
2564 | 2316 | } |
---|
2565 | | - sgl++; |
---|
2566 | | - dataphysaddr = sg_dma_address(sgde) + split_offset; |
---|
2567 | 2317 | |
---|
2568 | | - remainder = sg_dma_len(sgde) - split_offset; |
---|
| 2318 | + if (!((j + 1) % phba->border_sge_num)) { |
---|
| 2319 | + sgl->word2 = 0; |
---|
2569 | 2320 | |
---|
2570 | | - if ((subtotal + remainder) <= protgrp_bytes) { |
---|
2571 | | - /* we can use this whole buffer */ |
---|
2572 | | - dma_len = remainder; |
---|
2573 | | - split_offset = 0; |
---|
| 2321 | + /* set LSP type */ |
---|
| 2322 | + bf_set(lpfc_sli4_sge_type, sgl, |
---|
| 2323 | + LPFC_SGE_TYPE_LSP); |
---|
2574 | 2324 | |
---|
2575 | | - if ((subtotal + remainder) == protgrp_bytes) |
---|
2576 | | - pgdone = 1; |
---|
| 2325 | + sgl_xtra = lpfc_get_sgl_per_hdwq(phba, |
---|
| 2326 | + lpfc_cmd); |
---|
| 2327 | + |
---|
| 2328 | + if (unlikely(!sgl_xtra)) { |
---|
| 2329 | + goto out; |
---|
| 2330 | + } else { |
---|
| 2331 | + sgl->addr_lo = cpu_to_le32( |
---|
| 2332 | + putPaddrLow(sgl_xtra->dma_phys_sgl)); |
---|
| 2333 | + sgl->addr_hi = cpu_to_le32( |
---|
| 2334 | + putPaddrHigh(sgl_xtra->dma_phys_sgl)); |
---|
| 2335 | + } |
---|
| 2336 | + |
---|
| 2337 | + sgl->word2 = cpu_to_le32(sgl->word2); |
---|
| 2338 | + sgl->sge_len = cpu_to_le32( |
---|
| 2339 | + phba->cfg_sg_dma_buf_size); |
---|
| 2340 | + |
---|
| 2341 | + sgl = (struct sli4_sge *)sgl_xtra->dma_sgl; |
---|
2577 | 2342 | } else { |
---|
2578 | | - /* must split this buffer with next prot grp */ |
---|
2579 | | - dma_len = protgrp_bytes - subtotal; |
---|
2580 | | - split_offset += dma_len; |
---|
| 2343 | + dataphysaddr = sg_dma_address(sgde) + |
---|
| 2344 | + split_offset; |
---|
| 2345 | + |
---|
| 2346 | + remainder = sg_dma_len(sgde) - split_offset; |
---|
| 2347 | + |
---|
| 2348 | + if ((subtotal + remainder) <= protgrp_bytes) { |
---|
| 2349 | + /* we can use this whole buffer */ |
---|
| 2350 | + dma_len = remainder; |
---|
| 2351 | + split_offset = 0; |
---|
| 2352 | + |
---|
| 2353 | + if ((subtotal + remainder) == |
---|
| 2354 | + protgrp_bytes) |
---|
| 2355 | + pgdone = 1; |
---|
| 2356 | + } else { |
---|
| 2357 | + /* must split this buffer with next |
---|
| 2358 | + * prot grp |
---|
| 2359 | + */ |
---|
| 2360 | + dma_len = protgrp_bytes - subtotal; |
---|
| 2361 | + split_offset += dma_len; |
---|
| 2362 | + } |
---|
| 2363 | + |
---|
| 2364 | + subtotal += dma_len; |
---|
| 2365 | + |
---|
| 2366 | + sgl->word2 = 0; |
---|
| 2367 | + sgl->addr_lo = cpu_to_le32(putPaddrLow( |
---|
| 2368 | + dataphysaddr)); |
---|
| 2369 | + sgl->addr_hi = cpu_to_le32(putPaddrHigh( |
---|
| 2370 | + dataphysaddr)); |
---|
| 2371 | + bf_set(lpfc_sli4_sge_last, sgl, 0); |
---|
| 2372 | + bf_set(lpfc_sli4_sge_offset, sgl, dma_offset); |
---|
| 2373 | + bf_set(lpfc_sli4_sge_type, sgl, |
---|
| 2374 | + LPFC_SGE_TYPE_DATA); |
---|
| 2375 | + |
---|
| 2376 | + sgl->sge_len = cpu_to_le32(dma_len); |
---|
| 2377 | + dma_offset += dma_len; |
---|
| 2378 | + |
---|
| 2379 | + num_sge++; |
---|
| 2380 | + curr_data++; |
---|
| 2381 | + |
---|
| 2382 | + if (split_offset) { |
---|
| 2383 | + sgl++; |
---|
| 2384 | + j++; |
---|
| 2385 | + break; |
---|
| 2386 | + } |
---|
| 2387 | + |
---|
| 2388 | + /* Move to the next s/g segment if possible */ |
---|
| 2389 | + sgde = sg_next(sgde); |
---|
| 2390 | + |
---|
| 2391 | + sgl++; |
---|
2581 | 2392 | } |
---|
2582 | 2393 | |
---|
2583 | | - subtotal += dma_len; |
---|
2584 | | - |
---|
2585 | | - sgl->addr_lo = cpu_to_le32(putPaddrLow(dataphysaddr)); |
---|
2586 | | - sgl->addr_hi = cpu_to_le32(putPaddrHigh(dataphysaddr)); |
---|
2587 | | - bf_set(lpfc_sli4_sge_last, sgl, 0); |
---|
2588 | | - bf_set(lpfc_sli4_sge_offset, sgl, dma_offset); |
---|
2589 | | - bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_DATA); |
---|
2590 | | - |
---|
2591 | | - sgl->sge_len = cpu_to_le32(dma_len); |
---|
2592 | | - dma_offset += dma_len; |
---|
2593 | | - |
---|
2594 | | - num_sge++; |
---|
2595 | | - curr_data++; |
---|
2596 | | - |
---|
2597 | | - if (split_offset) |
---|
2598 | | - break; |
---|
2599 | | - |
---|
2600 | | - /* Move to the next s/g segment if possible */ |
---|
2601 | | - sgde = sg_next(sgde); |
---|
| 2394 | + j++; |
---|
2602 | 2395 | } |
---|
2603 | 2396 | |
---|
2604 | 2397 | if (protgroup_offset) { |
---|
2605 | 2398 | /* update the reference tag */ |
---|
2606 | 2399 | reftag += protgrp_blks; |
---|
2607 | | - sgl++; |
---|
2608 | 2400 | continue; |
---|
2609 | 2401 | } |
---|
2610 | 2402 | |
---|
2611 | 2403 | /* are we done ? */ |
---|
2612 | 2404 | if (curr_prot == protcnt) { |
---|
| 2405 | + /* mark the last SGL */ |
---|
| 2406 | + sgl--; |
---|
2613 | 2407 | bf_set(lpfc_sli4_sge_last, sgl, 1); |
---|
2614 | 2408 | alldone = 1; |
---|
2615 | 2409 | } else if (curr_prot < protcnt) { |
---|
2616 | 2410 | /* advance to next prot buffer */ |
---|
2617 | 2411 | sgpe = sg_next(sgpe); |
---|
2618 | | - sgl++; |
---|
2619 | 2412 | |
---|
2620 | 2413 | /* update the reference tag */ |
---|
2621 | 2414 | reftag += protgrp_blks; |
---|
2622 | 2415 | } else { |
---|
2623 | 2416 | /* if we're here, we have a bug */ |
---|
2624 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
2625 | | - "9085 BLKGRD: bug in %s\n", __func__); |
---|
| 2417 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
| 2418 | + "9085 BLKGRD: bug in %s\n", __func__); |
---|
2626 | 2419 | } |
---|
2627 | 2420 | |
---|
2628 | 2421 | } while (!alldone); |
---|
.. | .. |
---|
2662 | 2455 | break; |
---|
2663 | 2456 | default: |
---|
2664 | 2457 | if (phba) |
---|
2665 | | - lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
---|
| 2458 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
2666 | 2459 | "9021 Unsupported protection op:%d\n", |
---|
2667 | 2460 | op); |
---|
2668 | 2461 | break; |
---|
.. | .. |
---|
2682 | 2475 | **/ |
---|
2683 | 2476 | static int |
---|
2684 | 2477 | lpfc_bg_scsi_adjust_dl(struct lpfc_hba *phba, |
---|
2685 | | - struct lpfc_scsi_buf *lpfc_cmd) |
---|
| 2478 | + struct lpfc_io_buf *lpfc_cmd) |
---|
2686 | 2479 | { |
---|
2687 | 2480 | struct scsi_cmnd *sc = lpfc_cmd->pCmd; |
---|
2688 | 2481 | int fcpdl; |
---|
.. | .. |
---|
2718 | 2511 | * |
---|
2719 | 2512 | * This is the protection/DIF aware version of |
---|
2720 | 2513 | * lpfc_scsi_prep_dma_buf(). It may be a good idea to combine the |
---|
2721 | | - * two functions eventually, but for now, it's here |
---|
| 2514 | + * two functions eventually, but for now, it's here. |
---|
| 2515 | + * RETURNS 0 - SUCCESS, |
---|
| 2516 | + * 1 - Failed DMA map, retry. |
---|
| 2517 | + * 2 - Invalid scsi cmd or prot-type. Do not rety. |
---|
2722 | 2518 | **/ |
---|
2723 | 2519 | static int |
---|
2724 | 2520 | lpfc_bg_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, |
---|
2725 | | - struct lpfc_scsi_buf *lpfc_cmd) |
---|
| 2521 | + struct lpfc_io_buf *lpfc_cmd) |
---|
2726 | 2522 | { |
---|
2727 | 2523 | struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd; |
---|
2728 | 2524 | struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd; |
---|
2729 | | - struct ulp_bde64 *bpl = lpfc_cmd->fcp_bpl; |
---|
| 2525 | + struct ulp_bde64 *bpl = (struct ulp_bde64 *)lpfc_cmd->dma_sgl; |
---|
2730 | 2526 | IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb; |
---|
2731 | 2527 | uint32_t num_bde = 0; |
---|
2732 | 2528 | int datasegcnt, protsegcnt, datadir = scsi_cmnd->sc_data_direction; |
---|
2733 | 2529 | int prot_group_type = 0; |
---|
2734 | 2530 | int fcpdl; |
---|
| 2531 | + int ret = 1; |
---|
2735 | 2532 | struct lpfc_vport *vport = phba->pport; |
---|
2736 | 2533 | |
---|
2737 | 2534 | /* |
---|
.. | .. |
---|
2755 | 2552 | lpfc_cmd->seg_cnt = datasegcnt; |
---|
2756 | 2553 | |
---|
2757 | 2554 | /* First check if data segment count from SCSI Layer is good */ |
---|
2758 | | - if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) |
---|
| 2555 | + if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) { |
---|
| 2556 | + WARN_ON_ONCE(lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt); |
---|
| 2557 | + ret = 2; |
---|
2759 | 2558 | goto err; |
---|
| 2559 | + } |
---|
2760 | 2560 | |
---|
2761 | 2561 | prot_group_type = lpfc_prot_group_type(phba, scsi_cmnd); |
---|
2762 | 2562 | |
---|
.. | .. |
---|
2764 | 2564 | case LPFC_PG_TYPE_NO_DIF: |
---|
2765 | 2565 | |
---|
2766 | 2566 | /* Here we need to add a PDE5 and PDE6 to the count */ |
---|
2767 | | - if ((lpfc_cmd->seg_cnt + 2) > phba->cfg_total_seg_cnt) |
---|
| 2567 | + if ((lpfc_cmd->seg_cnt + 2) > phba->cfg_total_seg_cnt) { |
---|
| 2568 | + ret = 2; |
---|
2768 | 2569 | goto err; |
---|
| 2570 | + } |
---|
2769 | 2571 | |
---|
2770 | 2572 | num_bde = lpfc_bg_setup_bpl(phba, scsi_cmnd, bpl, |
---|
2771 | 2573 | datasegcnt); |
---|
2772 | 2574 | /* we should have 2 or more entries in buffer list */ |
---|
2773 | | - if (num_bde < 2) |
---|
| 2575 | + if (num_bde < 2) { |
---|
| 2576 | + ret = 2; |
---|
2774 | 2577 | goto err; |
---|
| 2578 | + } |
---|
2775 | 2579 | break; |
---|
2776 | 2580 | |
---|
2777 | 2581 | case LPFC_PG_TYPE_DIF_BUF: |
---|
.. | .. |
---|
2795 | 2599 | * protection data segment. |
---|
2796 | 2600 | */ |
---|
2797 | 2601 | if ((lpfc_cmd->prot_seg_cnt * 4) > |
---|
2798 | | - (phba->cfg_total_seg_cnt - 2)) |
---|
| 2602 | + (phba->cfg_total_seg_cnt - 2)) { |
---|
| 2603 | + ret = 2; |
---|
2799 | 2604 | goto err; |
---|
| 2605 | + } |
---|
2800 | 2606 | |
---|
2801 | 2607 | num_bde = lpfc_bg_setup_bpl_prot(phba, scsi_cmnd, bpl, |
---|
2802 | 2608 | datasegcnt, protsegcnt); |
---|
2803 | 2609 | /* we should have 3 or more entries in buffer list */ |
---|
2804 | 2610 | if ((num_bde < 3) || |
---|
2805 | | - (num_bde > phba->cfg_total_seg_cnt)) |
---|
| 2611 | + (num_bde > phba->cfg_total_seg_cnt)) { |
---|
| 2612 | + ret = 2; |
---|
2806 | 2613 | goto err; |
---|
| 2614 | + } |
---|
2807 | 2615 | break; |
---|
2808 | 2616 | |
---|
2809 | 2617 | case LPFC_PG_TYPE_INVALID: |
---|
.. | .. |
---|
2811 | 2619 | scsi_dma_unmap(scsi_cmnd); |
---|
2812 | 2620 | lpfc_cmd->seg_cnt = 0; |
---|
2813 | 2621 | |
---|
2814 | | - lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
---|
| 2622 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
2815 | 2623 | "9022 Unexpected protection group %i\n", |
---|
2816 | 2624 | prot_group_type); |
---|
2817 | | - return 1; |
---|
| 2625 | + return 2; |
---|
2818 | 2626 | } |
---|
2819 | 2627 | } |
---|
2820 | 2628 | |
---|
.. | .. |
---|
2855 | 2663 | scsi_prot_sg_count(scsi_cmnd), |
---|
2856 | 2664 | scsi_cmnd->sc_data_direction); |
---|
2857 | 2665 | |
---|
2858 | | - lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
---|
| 2666 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
2859 | 2667 | "9023 Cannot setup S/G List for HBA" |
---|
2860 | 2668 | "IO segs %d/%d BPL %d SCSI %d: %d %d\n", |
---|
2861 | 2669 | lpfc_cmd->seg_cnt, lpfc_cmd->prot_seg_cnt, |
---|
.. | .. |
---|
2864 | 2672 | |
---|
2865 | 2673 | lpfc_cmd->seg_cnt = 0; |
---|
2866 | 2674 | lpfc_cmd->prot_seg_cnt = 0; |
---|
2867 | | - return 1; |
---|
| 2675 | + return ret; |
---|
2868 | 2676 | } |
---|
2869 | 2677 | |
---|
2870 | 2678 | /* |
---|
.. | .. |
---|
2902 | 2710 | * what type of T10-DIF error occurred. |
---|
2903 | 2711 | */ |
---|
2904 | 2712 | static void |
---|
2905 | | -lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) |
---|
| 2713 | +lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) |
---|
2906 | 2714 | { |
---|
2907 | 2715 | struct scatterlist *sgpe; /* s/g prot entry */ |
---|
2908 | 2716 | struct scatterlist *sgde; /* s/g data entry */ |
---|
.. | .. |
---|
3087 | 2895 | * -1 - Internal error (bad profile, ...etc) |
---|
3088 | 2896 | */ |
---|
3089 | 2897 | static int |
---|
3090 | | -lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd, |
---|
3091 | | - struct lpfc_iocbq *pIocbOut) |
---|
| 2898 | +lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd, |
---|
| 2899 | + struct lpfc_iocbq *pIocbOut) |
---|
3092 | 2900 | { |
---|
3093 | 2901 | struct scsi_cmnd *cmd = lpfc_cmd->pCmd; |
---|
3094 | 2902 | struct sli3_bg_fields *bgf = &pIocbOut->iocb.unsli3.sli3_bg; |
---|
.. | .. |
---|
3096 | 2904 | uint32_t bghm = bgf->bghm; |
---|
3097 | 2905 | uint32_t bgstat = bgf->bgstat; |
---|
3098 | 2906 | uint64_t failing_sector = 0; |
---|
3099 | | - |
---|
3100 | | - spin_lock(&_dump_buf_lock); |
---|
3101 | | - if (!_dump_buf_done) { |
---|
3102 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9070 BLKGRD: Saving" |
---|
3103 | | - " Data for %u blocks to debugfs\n", |
---|
3104 | | - (cmd->cmnd[7] << 8 | cmd->cmnd[8])); |
---|
3105 | | - lpfc_debug_save_data(phba, cmd); |
---|
3106 | | - |
---|
3107 | | - /* If we have a prot sgl, save the DIF buffer */ |
---|
3108 | | - if (lpfc_prot_group_type(phba, cmd) == |
---|
3109 | | - LPFC_PG_TYPE_DIF_BUF) { |
---|
3110 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9071 BLKGRD: " |
---|
3111 | | - "Saving DIF for %u blocks to debugfs\n", |
---|
3112 | | - (cmd->cmnd[7] << 8 | cmd->cmnd[8])); |
---|
3113 | | - lpfc_debug_save_dif(phba, cmd); |
---|
3114 | | - } |
---|
3115 | | - |
---|
3116 | | - _dump_buf_done = 1; |
---|
3117 | | - } |
---|
3118 | | - spin_unlock(&_dump_buf_lock); |
---|
3119 | 2907 | |
---|
3120 | 2908 | if (lpfc_bgs_get_invalid_prof(bgstat)) { |
---|
3121 | 2909 | cmd->result = DID_ERROR << 16; |
---|
.. | .. |
---|
3250 | 3038 | * field of @lpfc_cmd for device with SLI-4 interface spec. |
---|
3251 | 3039 | * |
---|
3252 | 3040 | * Return codes: |
---|
3253 | | - * 1 - Error |
---|
| 3041 | + * 2 - Error - Do not retry |
---|
| 3042 | + * 1 - Error - Retry |
---|
3254 | 3043 | * 0 - Success |
---|
3255 | 3044 | **/ |
---|
3256 | 3045 | static int |
---|
3257 | | -lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) |
---|
| 3046 | +lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) |
---|
3258 | 3047 | { |
---|
3259 | 3048 | struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd; |
---|
3260 | 3049 | struct scatterlist *sgel = NULL; |
---|
3261 | 3050 | struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd; |
---|
3262 | | - struct sli4_sge *sgl = (struct sli4_sge *)lpfc_cmd->fcp_bpl; |
---|
| 3051 | + struct sli4_sge *sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl; |
---|
3263 | 3052 | struct sli4_sge *first_data_sgl; |
---|
3264 | 3053 | IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb; |
---|
3265 | 3054 | dma_addr_t physaddr; |
---|
3266 | 3055 | uint32_t num_bde = 0; |
---|
3267 | 3056 | uint32_t dma_len; |
---|
3268 | 3057 | uint32_t dma_offset = 0; |
---|
3269 | | - int nseg; |
---|
| 3058 | + int nseg, i, j; |
---|
3270 | 3059 | struct ulp_bde64 *bde; |
---|
| 3060 | + bool lsp_just_set = false; |
---|
| 3061 | + struct sli4_hybrid_sgl *sgl_xtra = NULL; |
---|
3271 | 3062 | |
---|
3272 | 3063 | /* |
---|
3273 | 3064 | * There are three possibilities here - use scatter-gather segment, use |
---|
.. | .. |
---|
3294 | 3085 | sgl += 1; |
---|
3295 | 3086 | first_data_sgl = sgl; |
---|
3296 | 3087 | lpfc_cmd->seg_cnt = nseg; |
---|
3297 | | - if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) { |
---|
3298 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9074 BLKGRD:" |
---|
3299 | | - " %s: Too many sg segments from " |
---|
3300 | | - "dma_map_sg. Config %d, seg_cnt %d\n", |
---|
3301 | | - __func__, phba->cfg_sg_seg_cnt, |
---|
3302 | | - lpfc_cmd->seg_cnt); |
---|
| 3088 | + if (!phba->cfg_xpsgl && |
---|
| 3089 | + lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) { |
---|
| 3090 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
| 3091 | + "9074 BLKGRD:" |
---|
| 3092 | + " %s: Too many sg segments from " |
---|
| 3093 | + "dma_map_sg. Config %d, seg_cnt %d\n", |
---|
| 3094 | + __func__, phba->cfg_sg_seg_cnt, |
---|
| 3095 | + lpfc_cmd->seg_cnt); |
---|
| 3096 | + WARN_ON_ONCE(lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt); |
---|
3303 | 3097 | lpfc_cmd->seg_cnt = 0; |
---|
3304 | 3098 | scsi_dma_unmap(scsi_cmnd); |
---|
3305 | | - return 1; |
---|
| 3099 | + return 2; |
---|
3306 | 3100 | } |
---|
3307 | 3101 | |
---|
3308 | 3102 | /* |
---|
.. | .. |
---|
3314 | 3108 | * the IOCB. If it can't then the BDEs get added to a BPL as it |
---|
3315 | 3109 | * does for SLI-2 mode. |
---|
3316 | 3110 | */ |
---|
3317 | | - scsi_for_each_sg(scsi_cmnd, sgel, nseg, num_bde) { |
---|
3318 | | - physaddr = sg_dma_address(sgel); |
---|
3319 | | - dma_len = sg_dma_len(sgel); |
---|
3320 | | - sgl->addr_lo = cpu_to_le32(putPaddrLow(physaddr)); |
---|
3321 | | - sgl->addr_hi = cpu_to_le32(putPaddrHigh(physaddr)); |
---|
3322 | | - sgl->word2 = le32_to_cpu(sgl->word2); |
---|
3323 | | - if ((num_bde + 1) == nseg) |
---|
| 3111 | + |
---|
| 3112 | + /* for tracking segment boundaries */ |
---|
| 3113 | + sgel = scsi_sglist(scsi_cmnd); |
---|
| 3114 | + j = 2; |
---|
| 3115 | + for (i = 0; i < nseg; i++) { |
---|
| 3116 | + sgl->word2 = 0; |
---|
| 3117 | + if ((num_bde + 1) == nseg) { |
---|
3324 | 3118 | bf_set(lpfc_sli4_sge_last, sgl, 1); |
---|
3325 | | - else |
---|
| 3119 | + bf_set(lpfc_sli4_sge_type, sgl, |
---|
| 3120 | + LPFC_SGE_TYPE_DATA); |
---|
| 3121 | + } else { |
---|
3326 | 3122 | bf_set(lpfc_sli4_sge_last, sgl, 0); |
---|
3327 | | - bf_set(lpfc_sli4_sge_offset, sgl, dma_offset); |
---|
3328 | | - bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_DATA); |
---|
3329 | | - sgl->word2 = cpu_to_le32(sgl->word2); |
---|
3330 | | - sgl->sge_len = cpu_to_le32(dma_len); |
---|
3331 | | - dma_offset += dma_len; |
---|
3332 | | - sgl++; |
---|
| 3123 | + |
---|
| 3124 | + /* do we need to expand the segment */ |
---|
| 3125 | + if (!lsp_just_set && |
---|
| 3126 | + !((j + 1) % phba->border_sge_num) && |
---|
| 3127 | + ((nseg - 1) != i)) { |
---|
| 3128 | + /* set LSP type */ |
---|
| 3129 | + bf_set(lpfc_sli4_sge_type, sgl, |
---|
| 3130 | + LPFC_SGE_TYPE_LSP); |
---|
| 3131 | + |
---|
| 3132 | + sgl_xtra = lpfc_get_sgl_per_hdwq( |
---|
| 3133 | + phba, lpfc_cmd); |
---|
| 3134 | + |
---|
| 3135 | + if (unlikely(!sgl_xtra)) { |
---|
| 3136 | + lpfc_cmd->seg_cnt = 0; |
---|
| 3137 | + scsi_dma_unmap(scsi_cmnd); |
---|
| 3138 | + return 1; |
---|
| 3139 | + } |
---|
| 3140 | + sgl->addr_lo = cpu_to_le32(putPaddrLow( |
---|
| 3141 | + sgl_xtra->dma_phys_sgl)); |
---|
| 3142 | + sgl->addr_hi = cpu_to_le32(putPaddrHigh( |
---|
| 3143 | + sgl_xtra->dma_phys_sgl)); |
---|
| 3144 | + |
---|
| 3145 | + } else { |
---|
| 3146 | + bf_set(lpfc_sli4_sge_type, sgl, |
---|
| 3147 | + LPFC_SGE_TYPE_DATA); |
---|
| 3148 | + } |
---|
| 3149 | + } |
---|
| 3150 | + |
---|
| 3151 | + if (!(bf_get(lpfc_sli4_sge_type, sgl) & |
---|
| 3152 | + LPFC_SGE_TYPE_LSP)) { |
---|
| 3153 | + if ((nseg - 1) == i) |
---|
| 3154 | + bf_set(lpfc_sli4_sge_last, sgl, 1); |
---|
| 3155 | + |
---|
| 3156 | + physaddr = sg_dma_address(sgel); |
---|
| 3157 | + dma_len = sg_dma_len(sgel); |
---|
| 3158 | + sgl->addr_lo = cpu_to_le32(putPaddrLow( |
---|
| 3159 | + physaddr)); |
---|
| 3160 | + sgl->addr_hi = cpu_to_le32(putPaddrHigh( |
---|
| 3161 | + physaddr)); |
---|
| 3162 | + |
---|
| 3163 | + bf_set(lpfc_sli4_sge_offset, sgl, dma_offset); |
---|
| 3164 | + sgl->word2 = cpu_to_le32(sgl->word2); |
---|
| 3165 | + sgl->sge_len = cpu_to_le32(dma_len); |
---|
| 3166 | + |
---|
| 3167 | + dma_offset += dma_len; |
---|
| 3168 | + sgel = sg_next(sgel); |
---|
| 3169 | + |
---|
| 3170 | + sgl++; |
---|
| 3171 | + lsp_just_set = false; |
---|
| 3172 | + |
---|
| 3173 | + } else { |
---|
| 3174 | + sgl->word2 = cpu_to_le32(sgl->word2); |
---|
| 3175 | + sgl->sge_len = cpu_to_le32( |
---|
| 3176 | + phba->cfg_sg_dma_buf_size); |
---|
| 3177 | + |
---|
| 3178 | + sgl = (struct sli4_sge *)sgl_xtra->dma_sgl; |
---|
| 3179 | + i = i - 1; |
---|
| 3180 | + |
---|
| 3181 | + lsp_just_set = true; |
---|
| 3182 | + } |
---|
| 3183 | + |
---|
| 3184 | + j++; |
---|
3333 | 3185 | } |
---|
3334 | 3186 | /* |
---|
3335 | 3187 | * Setup the first Payload BDE. For FCoE we just key off |
---|
.. | .. |
---|
3386 | 3238 | lpfc_cmd->cur_iocbq.priority = ((struct lpfc_device_data *) |
---|
3387 | 3239 | scsi_cmnd->device->hostdata)->priority; |
---|
3388 | 3240 | } |
---|
| 3241 | + |
---|
3389 | 3242 | return 0; |
---|
3390 | 3243 | } |
---|
3391 | 3244 | |
---|
.. | .. |
---|
3397 | 3250 | * This is the protection/DIF aware version of |
---|
3398 | 3251 | * lpfc_scsi_prep_dma_buf(). It may be a good idea to combine the |
---|
3399 | 3252 | * two functions eventually, but for now, it's here |
---|
| 3253 | + * Return codes: |
---|
| 3254 | + * 2 - Error - Do not retry |
---|
| 3255 | + * 1 - Error - Retry |
---|
| 3256 | + * 0 - Success |
---|
3400 | 3257 | **/ |
---|
3401 | 3258 | static int |
---|
3402 | 3259 | lpfc_bg_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, |
---|
3403 | | - struct lpfc_scsi_buf *lpfc_cmd) |
---|
| 3260 | + struct lpfc_io_buf *lpfc_cmd) |
---|
3404 | 3261 | { |
---|
3405 | 3262 | struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd; |
---|
3406 | 3263 | struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd; |
---|
3407 | | - struct sli4_sge *sgl = (struct sli4_sge *)(lpfc_cmd->fcp_bpl); |
---|
| 3264 | + struct sli4_sge *sgl = (struct sli4_sge *)(lpfc_cmd->dma_sgl); |
---|
3408 | 3265 | IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb; |
---|
3409 | 3266 | uint32_t num_sge = 0; |
---|
3410 | 3267 | int datasegcnt, protsegcnt, datadir = scsi_cmnd->sc_data_direction; |
---|
3411 | 3268 | int prot_group_type = 0; |
---|
3412 | 3269 | int fcpdl; |
---|
| 3270 | + int ret = 1; |
---|
3413 | 3271 | struct lpfc_vport *vport = phba->pport; |
---|
3414 | 3272 | |
---|
3415 | 3273 | /* |
---|
.. | .. |
---|
3439 | 3297 | lpfc_cmd->seg_cnt = datasegcnt; |
---|
3440 | 3298 | |
---|
3441 | 3299 | /* First check if data segment count from SCSI Layer is good */ |
---|
3442 | | - if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) |
---|
| 3300 | + if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt && |
---|
| 3301 | + !phba->cfg_xpsgl) { |
---|
| 3302 | + WARN_ON_ONCE(lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt); |
---|
| 3303 | + ret = 2; |
---|
3443 | 3304 | goto err; |
---|
| 3305 | + } |
---|
3444 | 3306 | |
---|
3445 | 3307 | prot_group_type = lpfc_prot_group_type(phba, scsi_cmnd); |
---|
3446 | 3308 | |
---|
3447 | 3309 | switch (prot_group_type) { |
---|
3448 | 3310 | case LPFC_PG_TYPE_NO_DIF: |
---|
3449 | 3311 | /* Here we need to add a DISEED to the count */ |
---|
3450 | | - if ((lpfc_cmd->seg_cnt + 1) > phba->cfg_total_seg_cnt) |
---|
| 3312 | + if (((lpfc_cmd->seg_cnt + 1) > |
---|
| 3313 | + phba->cfg_total_seg_cnt) && |
---|
| 3314 | + !phba->cfg_xpsgl) { |
---|
| 3315 | + ret = 2; |
---|
3451 | 3316 | goto err; |
---|
| 3317 | + } |
---|
3452 | 3318 | |
---|
3453 | 3319 | num_sge = lpfc_bg_setup_sgl(phba, scsi_cmnd, sgl, |
---|
3454 | | - datasegcnt); |
---|
| 3320 | + datasegcnt, lpfc_cmd); |
---|
3455 | 3321 | |
---|
3456 | 3322 | /* we should have 2 or more entries in buffer list */ |
---|
3457 | | - if (num_sge < 2) |
---|
| 3323 | + if (num_sge < 2) { |
---|
| 3324 | + ret = 2; |
---|
3458 | 3325 | goto err; |
---|
| 3326 | + } |
---|
3459 | 3327 | break; |
---|
3460 | 3328 | |
---|
3461 | 3329 | case LPFC_PG_TYPE_DIF_BUF: |
---|
.. | .. |
---|
3477 | 3345 | * There is a minimun of 3 SGEs used for every |
---|
3478 | 3346 | * protection data segment. |
---|
3479 | 3347 | */ |
---|
3480 | | - if ((lpfc_cmd->prot_seg_cnt * 3) > |
---|
3481 | | - (phba->cfg_total_seg_cnt - 2)) |
---|
| 3348 | + if (((lpfc_cmd->prot_seg_cnt * 3) > |
---|
| 3349 | + (phba->cfg_total_seg_cnt - 2)) && |
---|
| 3350 | + !phba->cfg_xpsgl) { |
---|
| 3351 | + ret = 2; |
---|
3482 | 3352 | goto err; |
---|
| 3353 | + } |
---|
3483 | 3354 | |
---|
3484 | 3355 | num_sge = lpfc_bg_setup_sgl_prot(phba, scsi_cmnd, sgl, |
---|
3485 | | - datasegcnt, protsegcnt); |
---|
| 3356 | + datasegcnt, protsegcnt, lpfc_cmd); |
---|
3486 | 3357 | |
---|
3487 | 3358 | /* we should have 3 or more entries in buffer list */ |
---|
3488 | | - if ((num_sge < 3) || |
---|
3489 | | - (num_sge > phba->cfg_total_seg_cnt)) |
---|
| 3359 | + if (num_sge < 3 || |
---|
| 3360 | + (num_sge > phba->cfg_total_seg_cnt && |
---|
| 3361 | + !phba->cfg_xpsgl)) { |
---|
| 3362 | + ret = 2; |
---|
3490 | 3363 | goto err; |
---|
| 3364 | + } |
---|
3491 | 3365 | break; |
---|
3492 | 3366 | |
---|
3493 | 3367 | case LPFC_PG_TYPE_INVALID: |
---|
.. | .. |
---|
3495 | 3369 | scsi_dma_unmap(scsi_cmnd); |
---|
3496 | 3370 | lpfc_cmd->seg_cnt = 0; |
---|
3497 | 3371 | |
---|
3498 | | - lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
---|
| 3372 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
3499 | 3373 | "9083 Unexpected protection group %i\n", |
---|
3500 | 3374 | prot_group_type); |
---|
3501 | | - return 1; |
---|
| 3375 | + return 2; |
---|
3502 | 3376 | } |
---|
3503 | 3377 | } |
---|
3504 | 3378 | |
---|
.. | .. |
---|
3551 | 3425 | scsi_prot_sg_count(scsi_cmnd), |
---|
3552 | 3426 | scsi_cmnd->sc_data_direction); |
---|
3553 | 3427 | |
---|
3554 | | - lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
---|
| 3428 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
3555 | 3429 | "9084 Cannot setup S/G List for HBA" |
---|
3556 | 3430 | "IO segs %d/%d SGL %d SCSI %d: %d %d\n", |
---|
3557 | 3431 | lpfc_cmd->seg_cnt, lpfc_cmd->prot_seg_cnt, |
---|
.. | .. |
---|
3560 | 3434 | |
---|
3561 | 3435 | lpfc_cmd->seg_cnt = 0; |
---|
3562 | 3436 | lpfc_cmd->prot_seg_cnt = 0; |
---|
3563 | | - return 1; |
---|
| 3437 | + return ret; |
---|
3564 | 3438 | } |
---|
3565 | 3439 | |
---|
3566 | 3440 | /** |
---|
.. | .. |
---|
3576 | 3450 | * 0 - Success |
---|
3577 | 3451 | **/ |
---|
3578 | 3452 | static inline int |
---|
3579 | | -lpfc_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) |
---|
| 3453 | +lpfc_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) |
---|
3580 | 3454 | { |
---|
3581 | 3455 | return phba->lpfc_scsi_prep_dma_buf(phba, lpfc_cmd); |
---|
3582 | 3456 | } |
---|
.. | .. |
---|
3595 | 3469 | * 0 - Success |
---|
3596 | 3470 | **/ |
---|
3597 | 3471 | static inline int |
---|
3598 | | -lpfc_bg_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) |
---|
| 3472 | +lpfc_bg_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) |
---|
3599 | 3473 | { |
---|
3600 | 3474 | return phba->lpfc_bg_scsi_prep_dma_buf(phba, lpfc_cmd); |
---|
3601 | 3475 | } |
---|
.. | .. |
---|
3612 | 3486 | **/ |
---|
3613 | 3487 | static void |
---|
3614 | 3488 | lpfc_send_scsi_error_event(struct lpfc_hba *phba, struct lpfc_vport *vport, |
---|
3615 | | - struct lpfc_scsi_buf *lpfc_cmd, struct lpfc_iocbq *rsp_iocb) { |
---|
| 3489 | + struct lpfc_io_buf *lpfc_cmd, struct lpfc_iocbq *rsp_iocb) { |
---|
3616 | 3490 | struct scsi_cmnd *cmnd = lpfc_cmd->pCmd; |
---|
3617 | 3491 | struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp; |
---|
3618 | 3492 | uint32_t resp_info = fcprsp->rspStatus2; |
---|
.. | .. |
---|
3704 | 3578 | * field of @lpfc_cmd for device with SLI-3 interface spec. |
---|
3705 | 3579 | **/ |
---|
3706 | 3580 | static void |
---|
3707 | | -lpfc_scsi_unprep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb) |
---|
| 3581 | +lpfc_scsi_unprep_dma_buf(struct lpfc_hba *phba, struct lpfc_io_buf *psb) |
---|
3708 | 3582 | { |
---|
3709 | 3583 | /* |
---|
3710 | 3584 | * There are only two special cases to consider. (1) the scsi command |
---|
.. | .. |
---|
3723 | 3597 | /** |
---|
3724 | 3598 | * lpfc_handler_fcp_err - FCP response handler |
---|
3725 | 3599 | * @vport: The virtual port for which this call is being executed. |
---|
3726 | | - * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure. |
---|
| 3600 | + * @lpfc_cmd: Pointer to lpfc_io_buf data structure. |
---|
3727 | 3601 | * @rsp_iocb: The response IOCB which contains FCP error. |
---|
3728 | 3602 | * |
---|
3729 | 3603 | * This routine is called to process response IOCB with status field |
---|
.. | .. |
---|
3731 | 3605 | * based upon SCSI and FCP error. |
---|
3732 | 3606 | **/ |
---|
3733 | 3607 | static void |
---|
3734 | | -lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, |
---|
| 3608 | +lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd, |
---|
3735 | 3609 | struct lpfc_iocbq *rsp_iocb) |
---|
3736 | 3610 | { |
---|
3737 | 3611 | struct lpfc_hba *phba = vport->phba; |
---|
.. | .. |
---|
3761 | 3635 | if (resp_info & RSP_LEN_VALID) { |
---|
3762 | 3636 | rsplen = be32_to_cpu(fcprsp->rspRspLen); |
---|
3763 | 3637 | if (rsplen != 0 && rsplen != 4 && rsplen != 8) { |
---|
3764 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
3765 | | - "2719 Invalid response length: " |
---|
3766 | | - "tgt x%x lun x%llx cmnd x%x rsplen x%x\n", |
---|
3767 | | - cmnd->device->id, |
---|
3768 | | - cmnd->device->lun, cmnd->cmnd[0], |
---|
3769 | | - rsplen); |
---|
| 3638 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
| 3639 | + "2719 Invalid response length: " |
---|
| 3640 | + "tgt x%x lun x%llx cmnd x%x rsplen " |
---|
| 3641 | + "x%x\n", cmnd->device->id, |
---|
| 3642 | + cmnd->device->lun, cmnd->cmnd[0], |
---|
| 3643 | + rsplen); |
---|
3770 | 3644 | host_status = DID_ERROR; |
---|
3771 | 3645 | goto out; |
---|
3772 | 3646 | } |
---|
3773 | 3647 | if (fcprsp->rspInfo3 != RSP_NO_FAILURE) { |
---|
3774 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
| 3648 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
3775 | 3649 | "2757 Protocol failure detected during " |
---|
3776 | 3650 | "processing of FCP I/O op: " |
---|
3777 | 3651 | "tgt x%x lun x%llx cmnd x%x rspInfo3 x%x\n", |
---|
.. | .. |
---|
3910 | 3784 | } |
---|
3911 | 3785 | |
---|
3912 | 3786 | /** |
---|
3913 | | - * lpfc_sli4_scmd_to_wqidx_distr - scsi command to SLI4 WQ index distribution |
---|
3914 | | - * @phba: Pointer to HBA context object. |
---|
3915 | | - * |
---|
3916 | | - * This routine performs a roundrobin SCSI command to SLI4 FCP WQ index |
---|
3917 | | - * distribution. This is called by __lpfc_sli_issue_iocb_s4() with the hbalock |
---|
3918 | | - * held. |
---|
3919 | | - * If scsi-mq is enabled, get the default block layer mapping of software queues |
---|
3920 | | - * to hardware queues. This information is saved in request tag. |
---|
3921 | | - * |
---|
3922 | | - * Return: index into SLI4 fast-path FCP queue index. |
---|
3923 | | - **/ |
---|
3924 | | -int lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba, |
---|
3925 | | - struct lpfc_scsi_buf *lpfc_cmd) |
---|
3926 | | -{ |
---|
3927 | | - struct scsi_cmnd *cmnd = lpfc_cmd->pCmd; |
---|
3928 | | - struct lpfc_vector_map_info *cpup; |
---|
3929 | | - int chann, cpu; |
---|
3930 | | - uint32_t tag; |
---|
3931 | | - uint16_t hwq; |
---|
3932 | | - |
---|
3933 | | - if (cmnd && shost_use_blk_mq(cmnd->device->host)) { |
---|
3934 | | - tag = blk_mq_unique_tag(cmnd->request); |
---|
3935 | | - hwq = blk_mq_unique_tag_to_hwq(tag); |
---|
3936 | | - |
---|
3937 | | - return hwq; |
---|
3938 | | - } |
---|
3939 | | - |
---|
3940 | | - if (phba->cfg_fcp_io_sched == LPFC_FCP_SCHED_BY_CPU |
---|
3941 | | - && phba->cfg_fcp_io_channel > 1) { |
---|
3942 | | - cpu = smp_processor_id(); |
---|
3943 | | - if (cpu < phba->sli4_hba.num_present_cpu) { |
---|
3944 | | - cpup = phba->sli4_hba.cpu_map; |
---|
3945 | | - cpup += cpu; |
---|
3946 | | - return cpup->channel_id; |
---|
3947 | | - } |
---|
3948 | | - } |
---|
3949 | | - chann = atomic_add_return(1, &phba->fcp_qidx); |
---|
3950 | | - chann = chann % phba->cfg_fcp_io_channel; |
---|
3951 | | - return chann; |
---|
3952 | | -} |
---|
3953 | | - |
---|
3954 | | - |
---|
3955 | | -/** |
---|
3956 | 3787 | * lpfc_scsi_cmd_iocb_cmpl - Scsi cmnd IOCB completion routine |
---|
3957 | 3788 | * @phba: The Hba for which this call is being executed. |
---|
3958 | 3789 | * @pIocbIn: The command IOCBQ for the scsi cmnd. |
---|
.. | .. |
---|
3966 | 3797 | lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, |
---|
3967 | 3798 | struct lpfc_iocbq *pIocbOut) |
---|
3968 | 3799 | { |
---|
3969 | | - struct lpfc_scsi_buf *lpfc_cmd = |
---|
3970 | | - (struct lpfc_scsi_buf *) pIocbIn->context1; |
---|
| 3800 | + struct lpfc_io_buf *lpfc_cmd = |
---|
| 3801 | + (struct lpfc_io_buf *) pIocbIn->context1; |
---|
3971 | 3802 | struct lpfc_vport *vport = pIocbIn->vport; |
---|
3972 | 3803 | struct lpfc_rport_data *rdata = lpfc_cmd->rdata; |
---|
3973 | 3804 | struct lpfc_nodelist *pnode = rdata->pnode; |
---|
.. | .. |
---|
3975 | 3806 | unsigned long flags; |
---|
3976 | 3807 | struct lpfc_fast_path_event *fast_path_evt; |
---|
3977 | 3808 | struct Scsi_Host *shost; |
---|
| 3809 | + int idx; |
---|
3978 | 3810 | uint32_t logit = LOG_FCP; |
---|
3979 | 3811 | |
---|
3980 | | - atomic_inc(&phba->fc4ScsiIoCmpls); |
---|
| 3812 | + /* Guard against abort handler being called at same time */ |
---|
| 3813 | + spin_lock(&lpfc_cmd->buf_lock); |
---|
3981 | 3814 | |
---|
3982 | 3815 | /* Sanity check on return of outstanding command */ |
---|
3983 | 3816 | cmd = lpfc_cmd->pCmd; |
---|
3984 | | - if (!cmd) |
---|
| 3817 | + if (!cmd || !phba) { |
---|
| 3818 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
| 3819 | + "2621 IO completion: Not an active IO\n"); |
---|
| 3820 | + spin_unlock(&lpfc_cmd->buf_lock); |
---|
3985 | 3821 | return; |
---|
| 3822 | + } |
---|
| 3823 | + |
---|
| 3824 | + idx = lpfc_cmd->cur_iocbq.hba_wqidx; |
---|
| 3825 | + if (phba->sli4_hba.hdwq) |
---|
| 3826 | + phba->sli4_hba.hdwq[idx].scsi_cstat.io_cmpls++; |
---|
| 3827 | + |
---|
| 3828 | +#ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
---|
| 3829 | + if (unlikely(phba->hdwqstat_on & LPFC_CHECK_SCSI_IO)) |
---|
| 3830 | + this_cpu_inc(phba->sli4_hba.c_stat->cmpl_io); |
---|
| 3831 | +#endif |
---|
3986 | 3832 | shost = cmd->device->host; |
---|
3987 | 3833 | |
---|
3988 | 3834 | lpfc_cmd->result = (pIocbOut->iocb.un.ulpWord[4] & IOERR_PARAM_MASK); |
---|
3989 | 3835 | lpfc_cmd->status = pIocbOut->iocb.ulpStatus; |
---|
3990 | 3836 | /* pick up SLI4 exhange busy status from HBA */ |
---|
3991 | | - lpfc_cmd->exch_busy = pIocbOut->iocb_flag & LPFC_EXCHANGE_BUSY; |
---|
| 3837 | + if (pIocbOut->iocb_flag & LPFC_EXCHANGE_BUSY) |
---|
| 3838 | + lpfc_cmd->flags |= LPFC_SBUF_XBUSY; |
---|
| 3839 | + else |
---|
| 3840 | + lpfc_cmd->flags &= ~LPFC_SBUF_XBUSY; |
---|
3992 | 3841 | |
---|
3993 | 3842 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
---|
3994 | 3843 | if (lpfc_cmd->prot_data_type) { |
---|
.. | .. |
---|
4022 | 3871 | } |
---|
4023 | 3872 | #endif |
---|
4024 | 3873 | |
---|
4025 | | - if (lpfc_cmd->status) { |
---|
| 3874 | + if (unlikely(lpfc_cmd->status)) { |
---|
4026 | 3875 | if (lpfc_cmd->status == IOSTAT_LOCAL_REJECT && |
---|
4027 | 3876 | (lpfc_cmd->result & IOERR_DRVR_MASK)) |
---|
4028 | 3877 | lpfc_cmd->status = IOSTAT_DRIVER_REJECT; |
---|
.. | .. |
---|
4131 | 3980 | lpfc_cmd->cur_iocbq.sli4_lxritag, |
---|
4132 | 3981 | 0, 0); |
---|
4133 | 3982 | } |
---|
4134 | | - /* else: fall through */ |
---|
| 3983 | + fallthrough; |
---|
4135 | 3984 | default: |
---|
4136 | 3985 | cmd->result = DID_ERROR << 16; |
---|
4137 | 3986 | break; |
---|
.. | .. |
---|
4148 | 3997 | uint32_t *lp = (uint32_t *)cmd->sense_buffer; |
---|
4149 | 3998 | |
---|
4150 | 3999 | lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP, |
---|
4151 | | - "0710 Iodone <%d/%llu> cmd %p, error " |
---|
| 4000 | + "0710 Iodone <%d/%llu> cmd x%px, error " |
---|
4152 | 4001 | "x%x SNS x%x x%x Data: x%x x%x\n", |
---|
4153 | 4002 | cmd->device->id, cmd->device->lun, cmd, |
---|
4154 | 4003 | cmd->result, *lp, *(lp + 3), cmd->retries, |
---|
4155 | 4004 | scsi_get_resid(cmd)); |
---|
4156 | 4005 | } |
---|
4157 | 4006 | |
---|
4158 | | - lpfc_update_stats(phba, lpfc_cmd); |
---|
| 4007 | + lpfc_update_stats(vport, lpfc_cmd); |
---|
4159 | 4008 | if (vport->cfg_max_scsicmpl_time && |
---|
4160 | 4009 | time_after(jiffies, lpfc_cmd->start_time + |
---|
4161 | 4010 | msecs_to_jiffies(vport->cfg_max_scsicmpl_time))) { |
---|
.. | .. |
---|
4176 | 4025 | } |
---|
4177 | 4026 | lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd); |
---|
4178 | 4027 | |
---|
4179 | | - /* If pCmd was set to NULL from abort path, do not call scsi_done */ |
---|
4180 | | - if (xchg(&lpfc_cmd->pCmd, NULL) == NULL) { |
---|
4181 | | - lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP, |
---|
4182 | | - "5688 FCP cmd already NULL, sid: 0x%06x, " |
---|
4183 | | - "did: 0x%06x, oxid: 0x%04x\n", |
---|
4184 | | - vport->fc_myDID, |
---|
4185 | | - (pnode) ? pnode->nlp_DID : 0, |
---|
4186 | | - phba->sli_rev == LPFC_SLI_REV4 ? |
---|
4187 | | - lpfc_cmd->cur_iocbq.sli4_xritag : 0xffff); |
---|
4188 | | - return; |
---|
4189 | | - } |
---|
| 4028 | + lpfc_cmd->pCmd = NULL; |
---|
| 4029 | + spin_unlock(&lpfc_cmd->buf_lock); |
---|
4190 | 4030 | |
---|
| 4031 | +#ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
---|
| 4032 | + if (lpfc_cmd->ts_cmd_start) { |
---|
| 4033 | + lpfc_cmd->ts_isr_cmpl = pIocbIn->isr_timestamp; |
---|
| 4034 | + lpfc_cmd->ts_data_io = ktime_get_ns(); |
---|
| 4035 | + phba->ktime_last_cmd = lpfc_cmd->ts_data_io; |
---|
| 4036 | + lpfc_io_ktime(phba, lpfc_cmd); |
---|
| 4037 | + } |
---|
| 4038 | +#endif |
---|
4191 | 4039 | /* The sdev is not guaranteed to be valid post scsi_done upcall. */ |
---|
4192 | 4040 | cmd->scsi_done(cmd); |
---|
4193 | 4041 | |
---|
4194 | 4042 | /* |
---|
4195 | | - * If there is a thread waiting for command completion |
---|
| 4043 | + * If there is an abort thread waiting for command completion |
---|
4196 | 4044 | * wake up the thread. |
---|
4197 | 4045 | */ |
---|
4198 | | - spin_lock_irqsave(shost->host_lock, flags); |
---|
| 4046 | + spin_lock(&lpfc_cmd->buf_lock); |
---|
| 4047 | + lpfc_cmd->cur_iocbq.iocb_flag &= ~LPFC_DRIVER_ABORTED; |
---|
4199 | 4048 | if (lpfc_cmd->waitq) |
---|
4200 | 4049 | wake_up(lpfc_cmd->waitq); |
---|
4201 | | - spin_unlock_irqrestore(shost->host_lock, flags); |
---|
| 4050 | + spin_unlock(&lpfc_cmd->buf_lock); |
---|
4202 | 4051 | |
---|
4203 | 4052 | lpfc_release_scsi_buf(phba, lpfc_cmd); |
---|
4204 | 4053 | } |
---|
.. | .. |
---|
4231 | 4080 | * to transfer for device with SLI3 interface spec. |
---|
4232 | 4081 | **/ |
---|
4233 | 4082 | static void |
---|
4234 | | -lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, |
---|
| 4083 | +lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd, |
---|
4235 | 4084 | struct lpfc_nodelist *pnode) |
---|
4236 | 4085 | { |
---|
4237 | 4086 | struct lpfc_hba *phba = vport->phba; |
---|
.. | .. |
---|
4239 | 4088 | struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd; |
---|
4240 | 4089 | IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb; |
---|
4241 | 4090 | struct lpfc_iocbq *piocbq = &(lpfc_cmd->cur_iocbq); |
---|
| 4091 | + struct lpfc_sli4_hdw_queue *hdwq = NULL; |
---|
4242 | 4092 | int datadir = scsi_cmnd->sc_data_direction; |
---|
| 4093 | + int idx; |
---|
4243 | 4094 | uint8_t *ptr; |
---|
4244 | 4095 | bool sli4; |
---|
4245 | 4096 | uint32_t fcpdl; |
---|
.. | .. |
---|
4265 | 4116 | |
---|
4266 | 4117 | sli4 = (phba->sli_rev == LPFC_SLI_REV4); |
---|
4267 | 4118 | piocbq->iocb.un.fcpi.fcpi_XRdy = 0; |
---|
| 4119 | + idx = lpfc_cmd->hdwq_no; |
---|
| 4120 | + if (phba->sli4_hba.hdwq) |
---|
| 4121 | + hdwq = &phba->sli4_hba.hdwq[idx]; |
---|
4268 | 4122 | |
---|
4269 | 4123 | /* |
---|
4270 | 4124 | * There are three possibilities here - use scatter-gather segment, use |
---|
.. | .. |
---|
4286 | 4140 | vport->cfg_first_burst_size; |
---|
4287 | 4141 | } |
---|
4288 | 4142 | fcp_cmnd->fcpCntl3 = WRITE_DATA; |
---|
4289 | | - atomic_inc(&phba->fc4ScsiOutputRequests); |
---|
| 4143 | + if (hdwq) |
---|
| 4144 | + hdwq->scsi_cstat.output_requests++; |
---|
4290 | 4145 | } else { |
---|
4291 | 4146 | iocb_cmd->ulpCommand = CMD_FCP_IREAD64_CR; |
---|
4292 | 4147 | iocb_cmd->ulpPU = PARM_READ_CHECK; |
---|
4293 | 4148 | fcp_cmnd->fcpCntl3 = READ_DATA; |
---|
4294 | | - atomic_inc(&phba->fc4ScsiInputRequests); |
---|
| 4149 | + if (hdwq) |
---|
| 4150 | + hdwq->scsi_cstat.input_requests++; |
---|
4295 | 4151 | } |
---|
4296 | 4152 | } else { |
---|
4297 | 4153 | iocb_cmd->ulpCommand = CMD_FCP_ICMND64_CR; |
---|
4298 | 4154 | iocb_cmd->un.fcpi.fcpi_parm = 0; |
---|
4299 | 4155 | iocb_cmd->ulpPU = 0; |
---|
4300 | 4156 | fcp_cmnd->fcpCntl3 = 0; |
---|
4301 | | - atomic_inc(&phba->fc4ScsiControlRequests); |
---|
| 4157 | + if (hdwq) |
---|
| 4158 | + hdwq->scsi_cstat.control_requests++; |
---|
4302 | 4159 | } |
---|
4303 | 4160 | if (phba->sli_rev == 3 && |
---|
4304 | 4161 | !(phba->sli3_options & LPFC_SLI3_BG_ENABLED)) |
---|
.. | .. |
---|
4326 | 4183 | /** |
---|
4327 | 4184 | * lpfc_scsi_prep_task_mgmt_cmd - Convert SLI3 scsi TM cmd to FCP info unit |
---|
4328 | 4185 | * @vport: The virtual port for which this call is being executed. |
---|
4329 | | - * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure. |
---|
| 4186 | + * @lpfc_cmd: Pointer to lpfc_io_buf data structure. |
---|
4330 | 4187 | * @lun: Logical unit number. |
---|
4331 | 4188 | * @task_mgmt_cmd: SCSI task management command. |
---|
4332 | 4189 | * |
---|
.. | .. |
---|
4339 | 4196 | **/ |
---|
4340 | 4197 | static int |
---|
4341 | 4198 | lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_vport *vport, |
---|
4342 | | - struct lpfc_scsi_buf *lpfc_cmd, |
---|
| 4199 | + struct lpfc_io_buf *lpfc_cmd, |
---|
4343 | 4200 | uint64_t lun, |
---|
4344 | 4201 | uint8_t task_mgmt_cmd) |
---|
4345 | 4202 | { |
---|
.. | .. |
---|
4411 | 4268 | |
---|
4412 | 4269 | switch (dev_grp) { |
---|
4413 | 4270 | case LPFC_PCI_DEV_LP: |
---|
4414 | | - phba->lpfc_new_scsi_buf = lpfc_new_scsi_buf_s3; |
---|
4415 | 4271 | phba->lpfc_scsi_prep_dma_buf = lpfc_scsi_prep_dma_buf_s3; |
---|
4416 | 4272 | phba->lpfc_bg_scsi_prep_dma_buf = lpfc_bg_scsi_prep_dma_buf_s3; |
---|
4417 | 4273 | phba->lpfc_release_scsi_buf = lpfc_release_scsi_buf_s3; |
---|
4418 | 4274 | phba->lpfc_get_scsi_buf = lpfc_get_scsi_buf_s3; |
---|
4419 | 4275 | break; |
---|
4420 | 4276 | case LPFC_PCI_DEV_OC: |
---|
4421 | | - phba->lpfc_new_scsi_buf = lpfc_new_scsi_buf_s4; |
---|
4422 | 4277 | phba->lpfc_scsi_prep_dma_buf = lpfc_scsi_prep_dma_buf_s4; |
---|
4423 | 4278 | phba->lpfc_bg_scsi_prep_dma_buf = lpfc_bg_scsi_prep_dma_buf_s4; |
---|
4424 | 4279 | phba->lpfc_release_scsi_buf = lpfc_release_scsi_buf_s4; |
---|
4425 | 4280 | phba->lpfc_get_scsi_buf = lpfc_get_scsi_buf_s4; |
---|
4426 | 4281 | break; |
---|
4427 | 4282 | default: |
---|
4428 | | - lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
---|
| 4283 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
4429 | 4284 | "1418 Invalid HBA PCI-device group: 0x%x\n", |
---|
4430 | 4285 | dev_grp); |
---|
4431 | 4286 | return -ENODEV; |
---|
.. | .. |
---|
4450 | 4305 | struct lpfc_iocbq *cmdiocbq, |
---|
4451 | 4306 | struct lpfc_iocbq *rspiocbq) |
---|
4452 | 4307 | { |
---|
4453 | | - struct lpfc_scsi_buf *lpfc_cmd = |
---|
4454 | | - (struct lpfc_scsi_buf *) cmdiocbq->context1; |
---|
| 4308 | + struct lpfc_io_buf *lpfc_cmd = |
---|
| 4309 | + (struct lpfc_io_buf *) cmdiocbq->context1; |
---|
4455 | 4310 | if (lpfc_cmd) |
---|
4456 | 4311 | lpfc_release_scsi_buf(phba, lpfc_cmd); |
---|
4457 | 4312 | return; |
---|
| 4313 | +} |
---|
| 4314 | + |
---|
| 4315 | +/** |
---|
| 4316 | + * lpfc_check_pci_resettable - Walks list of devices on pci_dev's bus to check |
---|
| 4317 | + * if issuing a pci_bus_reset is possibly unsafe |
---|
| 4318 | + * @phba: lpfc_hba pointer. |
---|
| 4319 | + * |
---|
| 4320 | + * Description: |
---|
| 4321 | + * Walks the bus_list to ensure only PCI devices with Emulex |
---|
| 4322 | + * vendor id, device ids that support hot reset, and only one occurrence |
---|
| 4323 | + * of function 0. |
---|
| 4324 | + * |
---|
| 4325 | + * Returns: |
---|
| 4326 | + * -EBADSLT, detected invalid device |
---|
| 4327 | + * 0, successful |
---|
| 4328 | + */ |
---|
| 4329 | +int |
---|
| 4330 | +lpfc_check_pci_resettable(struct lpfc_hba *phba) |
---|
| 4331 | +{ |
---|
| 4332 | + const struct pci_dev *pdev = phba->pcidev; |
---|
| 4333 | + struct pci_dev *ptr = NULL; |
---|
| 4334 | + u8 counter = 0; |
---|
| 4335 | + |
---|
| 4336 | + /* Walk the list of devices on the pci_dev's bus */ |
---|
| 4337 | + list_for_each_entry(ptr, &pdev->bus->devices, bus_list) { |
---|
| 4338 | + /* Check for Emulex Vendor ID */ |
---|
| 4339 | + if (ptr->vendor != PCI_VENDOR_ID_EMULEX) { |
---|
| 4340 | + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
---|
| 4341 | + "8346 Non-Emulex vendor found: " |
---|
| 4342 | + "0x%04x\n", ptr->vendor); |
---|
| 4343 | + return -EBADSLT; |
---|
| 4344 | + } |
---|
| 4345 | + |
---|
| 4346 | + /* Check for valid Emulex Device ID */ |
---|
| 4347 | + switch (ptr->device) { |
---|
| 4348 | + case PCI_DEVICE_ID_LANCER_FC: |
---|
| 4349 | + case PCI_DEVICE_ID_LANCER_G6_FC: |
---|
| 4350 | + case PCI_DEVICE_ID_LANCER_G7_FC: |
---|
| 4351 | + break; |
---|
| 4352 | + default: |
---|
| 4353 | + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
---|
| 4354 | + "8347 Invalid device found: " |
---|
| 4355 | + "0x%04x\n", ptr->device); |
---|
| 4356 | + return -EBADSLT; |
---|
| 4357 | + } |
---|
| 4358 | + |
---|
| 4359 | + /* Check for only one function 0 ID to ensure only one HBA on |
---|
| 4360 | + * secondary bus |
---|
| 4361 | + */ |
---|
| 4362 | + if (ptr->devfn == 0) { |
---|
| 4363 | + if (++counter > 1) { |
---|
| 4364 | + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, |
---|
| 4365 | + "8348 More than one device on " |
---|
| 4366 | + "secondary bus found\n"); |
---|
| 4367 | + return -EBADSLT; |
---|
| 4368 | + } |
---|
| 4369 | + } |
---|
| 4370 | + } |
---|
| 4371 | + |
---|
| 4372 | + return 0; |
---|
4458 | 4373 | } |
---|
4459 | 4374 | |
---|
4460 | 4375 | /** |
---|
.. | .. |
---|
4471 | 4386 | { |
---|
4472 | 4387 | struct lpfc_vport *vport = (struct lpfc_vport *) host->hostdata; |
---|
4473 | 4388 | struct lpfc_hba *phba = vport->phba; |
---|
4474 | | - int len, link_speed = 0; |
---|
4475 | | - static char lpfcinfobuf[384]; |
---|
| 4389 | + int link_speed = 0; |
---|
| 4390 | + static char lpfcinfobuf[384]; |
---|
| 4391 | + char tmp[384] = {0}; |
---|
4476 | 4392 | |
---|
4477 | | - memset(lpfcinfobuf,0,384); |
---|
| 4393 | + memset(lpfcinfobuf, 0, sizeof(lpfcinfobuf)); |
---|
4478 | 4394 | if (phba && phba->pcidev){ |
---|
4479 | | - strncpy(lpfcinfobuf, phba->ModelDesc, 256); |
---|
4480 | | - len = strlen(lpfcinfobuf); |
---|
4481 | | - snprintf(lpfcinfobuf + len, |
---|
4482 | | - 384-len, |
---|
4483 | | - " on PCI bus %02x device %02x irq %d", |
---|
4484 | | - phba->pcidev->bus->number, |
---|
4485 | | - phba->pcidev->devfn, |
---|
4486 | | - phba->pcidev->irq); |
---|
4487 | | - len = strlen(lpfcinfobuf); |
---|
| 4395 | + /* Model Description */ |
---|
| 4396 | + scnprintf(tmp, sizeof(tmp), phba->ModelDesc); |
---|
| 4397 | + if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >= |
---|
| 4398 | + sizeof(lpfcinfobuf)) |
---|
| 4399 | + goto buffer_done; |
---|
| 4400 | + |
---|
| 4401 | + /* PCI Info */ |
---|
| 4402 | + scnprintf(tmp, sizeof(tmp), |
---|
| 4403 | + " on PCI bus %02x device %02x irq %d", |
---|
| 4404 | + phba->pcidev->bus->number, phba->pcidev->devfn, |
---|
| 4405 | + phba->pcidev->irq); |
---|
| 4406 | + if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >= |
---|
| 4407 | + sizeof(lpfcinfobuf)) |
---|
| 4408 | + goto buffer_done; |
---|
| 4409 | + |
---|
| 4410 | + /* Port Number */ |
---|
4488 | 4411 | if (phba->Port[0]) { |
---|
4489 | | - snprintf(lpfcinfobuf + len, |
---|
4490 | | - 384-len, |
---|
4491 | | - " port %s", |
---|
4492 | | - phba->Port); |
---|
| 4412 | + scnprintf(tmp, sizeof(tmp), " port %s", phba->Port); |
---|
| 4413 | + if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >= |
---|
| 4414 | + sizeof(lpfcinfobuf)) |
---|
| 4415 | + goto buffer_done; |
---|
4493 | 4416 | } |
---|
4494 | | - len = strlen(lpfcinfobuf); |
---|
| 4417 | + |
---|
| 4418 | + /* Link Speed */ |
---|
4495 | 4419 | link_speed = lpfc_sli_port_speed_get(phba); |
---|
4496 | | - if (link_speed != 0) |
---|
4497 | | - snprintf(lpfcinfobuf + len, 384-len, |
---|
4498 | | - " Logical Link Speed: %d Mbps", link_speed); |
---|
| 4420 | + if (link_speed != 0) { |
---|
| 4421 | + scnprintf(tmp, sizeof(tmp), |
---|
| 4422 | + " Logical Link Speed: %d Mbps", link_speed); |
---|
| 4423 | + if (strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)) >= |
---|
| 4424 | + sizeof(lpfcinfobuf)) |
---|
| 4425 | + goto buffer_done; |
---|
| 4426 | + } |
---|
| 4427 | + |
---|
| 4428 | + /* PCI resettable */ |
---|
| 4429 | + if (!lpfc_check_pci_resettable(phba)) { |
---|
| 4430 | + scnprintf(tmp, sizeof(tmp), " PCI resettable"); |
---|
| 4431 | + strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf)); |
---|
| 4432 | + } |
---|
4499 | 4433 | } |
---|
| 4434 | + |
---|
| 4435 | +buffer_done: |
---|
4500 | 4436 | return lpfcinfobuf; |
---|
4501 | 4437 | } |
---|
4502 | 4438 | |
---|
.. | .. |
---|
4569 | 4505 | struct lpfc_hba *phba = vport->phba; |
---|
4570 | 4506 | struct lpfc_rport_data *rdata; |
---|
4571 | 4507 | struct lpfc_nodelist *ndlp; |
---|
4572 | | - struct lpfc_scsi_buf *lpfc_cmd; |
---|
| 4508 | + struct lpfc_io_buf *lpfc_cmd; |
---|
4573 | 4509 | struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device)); |
---|
4574 | | - int err; |
---|
| 4510 | + int err, idx; |
---|
| 4511 | +#ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
---|
| 4512 | + uint64_t start = 0L; |
---|
| 4513 | + |
---|
| 4514 | + if (phba->ktime_on) |
---|
| 4515 | + start = ktime_get_ns(); |
---|
| 4516 | +#endif |
---|
4575 | 4517 | |
---|
4576 | 4518 | rdata = lpfc_rport_data_from_scsi_device(cmnd->device); |
---|
4577 | 4519 | |
---|
.. | .. |
---|
4589 | 4531 | if ((scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) && |
---|
4590 | 4532 | (!(phba->sli3_options & LPFC_SLI3_BG_ENABLED))) { |
---|
4591 | 4533 | |
---|
4592 | | - lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
---|
| 4534 | + lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, |
---|
4593 | 4535 | "9058 BLKGRD: ERROR: rcvd protected cmd:%02x" |
---|
4594 | 4536 | " op:%02x str=%s without registering for" |
---|
4595 | 4537 | " BlockGuard - Rejecting command\n", |
---|
.. | .. |
---|
4635 | 4577 | } |
---|
4636 | 4578 | } |
---|
4637 | 4579 | |
---|
4638 | | - lpfc_cmd = lpfc_get_scsi_buf(phba, ndlp); |
---|
| 4580 | + lpfc_cmd = lpfc_get_scsi_buf(phba, ndlp, cmnd); |
---|
4639 | 4581 | if (lpfc_cmd == NULL) { |
---|
4640 | 4582 | lpfc_rampdown_queue_depth(phba); |
---|
4641 | 4583 | |
---|
.. | .. |
---|
4652 | 4594 | lpfc_cmd->pCmd = cmnd; |
---|
4653 | 4595 | lpfc_cmd->rdata = rdata; |
---|
4654 | 4596 | lpfc_cmd->ndlp = ndlp; |
---|
4655 | | - lpfc_cmd->timeout = 0; |
---|
4656 | | - lpfc_cmd->start_time = jiffies; |
---|
4657 | 4597 | cmnd->host_scribble = (unsigned char *)lpfc_cmd; |
---|
4658 | 4598 | |
---|
4659 | 4599 | if (scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) { |
---|
.. | .. |
---|
4683 | 4623 | err = lpfc_scsi_prep_dma_buf(phba, lpfc_cmd); |
---|
4684 | 4624 | } |
---|
4685 | 4625 | |
---|
4686 | | - if (err) |
---|
| 4626 | + if (unlikely(err)) { |
---|
| 4627 | + if (err == 2) { |
---|
| 4628 | + cmnd->result = DID_ERROR << 16; |
---|
| 4629 | + goto out_fail_command_release_buf; |
---|
| 4630 | + } |
---|
4687 | 4631 | goto out_host_busy_free_buf; |
---|
| 4632 | + } |
---|
4688 | 4633 | |
---|
4689 | 4634 | lpfc_scsi_prep_cmnd(vport, lpfc_cmd, ndlp); |
---|
4690 | 4635 | |
---|
| 4636 | +#ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
---|
| 4637 | + if (unlikely(phba->hdwqstat_on & LPFC_CHECK_SCSI_IO)) |
---|
| 4638 | + this_cpu_inc(phba->sli4_hba.c_stat->xmt_io); |
---|
| 4639 | +#endif |
---|
4691 | 4640 | err = lpfc_sli_issue_iocb(phba, LPFC_FCP_RING, |
---|
4692 | 4641 | &lpfc_cmd->cur_iocbq, SLI_IOCB_RET_IOCB); |
---|
| 4642 | +#ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
---|
| 4643 | + if (start) { |
---|
| 4644 | + lpfc_cmd->ts_cmd_start = start; |
---|
| 4645 | + lpfc_cmd->ts_last_cmd = phba->ktime_last_cmd; |
---|
| 4646 | + lpfc_cmd->ts_cmd_wqput = ktime_get_ns(); |
---|
| 4647 | + } else { |
---|
| 4648 | + lpfc_cmd->ts_cmd_start = 0; |
---|
| 4649 | + } |
---|
| 4650 | +#endif |
---|
4693 | 4651 | if (err) { |
---|
4694 | 4652 | lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP, |
---|
4695 | 4653 | "3376 FCP could not issue IOCB err %x" |
---|
.. | .. |
---|
4708 | 4666 | (uint32_t) |
---|
4709 | 4667 | (cmnd->request->timeout / 1000)); |
---|
4710 | 4668 | |
---|
4711 | | - switch (lpfc_cmd->fcp_cmnd->fcpCntl3) { |
---|
4712 | | - case WRITE_DATA: |
---|
4713 | | - atomic_dec(&phba->fc4ScsiOutputRequests); |
---|
4714 | | - break; |
---|
4715 | | - case READ_DATA: |
---|
4716 | | - atomic_dec(&phba->fc4ScsiInputRequests); |
---|
4717 | | - break; |
---|
4718 | | - default: |
---|
4719 | | - atomic_dec(&phba->fc4ScsiControlRequests); |
---|
4720 | | - } |
---|
4721 | 4669 | goto out_host_busy_free_buf; |
---|
4722 | 4670 | } |
---|
4723 | 4671 | if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { |
---|
.. | .. |
---|
4728 | 4676 | lpfc_poll_rearm_timer(phba); |
---|
4729 | 4677 | } |
---|
4730 | 4678 | |
---|
| 4679 | + if (phba->cfg_xri_rebalancing) |
---|
| 4680 | + lpfc_keep_pvt_pool_above_lowwm(phba, lpfc_cmd->hdwq_no); |
---|
| 4681 | + |
---|
4731 | 4682 | return 0; |
---|
4732 | 4683 | |
---|
4733 | 4684 | out_host_busy_free_buf: |
---|
| 4685 | + idx = lpfc_cmd->hdwq_no; |
---|
4734 | 4686 | lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd); |
---|
| 4687 | + if (phba->sli4_hba.hdwq) { |
---|
| 4688 | + switch (lpfc_cmd->fcp_cmnd->fcpCntl3) { |
---|
| 4689 | + case WRITE_DATA: |
---|
| 4690 | + phba->sli4_hba.hdwq[idx].scsi_cstat.output_requests--; |
---|
| 4691 | + break; |
---|
| 4692 | + case READ_DATA: |
---|
| 4693 | + phba->sli4_hba.hdwq[idx].scsi_cstat.input_requests--; |
---|
| 4694 | + break; |
---|
| 4695 | + default: |
---|
| 4696 | + phba->sli4_hba.hdwq[idx].scsi_cstat.control_requests--; |
---|
| 4697 | + } |
---|
| 4698 | + } |
---|
4735 | 4699 | lpfc_release_scsi_buf(phba, lpfc_cmd); |
---|
4736 | 4700 | out_host_busy: |
---|
4737 | 4701 | return SCSI_MLQUEUE_HOST_BUSY; |
---|
4738 | 4702 | |
---|
4739 | 4703 | out_tgt_busy: |
---|
4740 | 4704 | return SCSI_MLQUEUE_TARGET_BUSY; |
---|
| 4705 | + |
---|
| 4706 | + out_fail_command_release_buf: |
---|
| 4707 | + lpfc_release_scsi_buf(phba, lpfc_cmd); |
---|
4741 | 4708 | |
---|
4742 | 4709 | out_fail_command: |
---|
4743 | 4710 | cmnd->scsi_done(cmnd); |
---|
.. | .. |
---|
4763 | 4730 | struct lpfc_hba *phba = vport->phba; |
---|
4764 | 4731 | struct lpfc_iocbq *iocb; |
---|
4765 | 4732 | struct lpfc_iocbq *abtsiocb; |
---|
4766 | | - struct lpfc_scsi_buf *lpfc_cmd; |
---|
| 4733 | + struct lpfc_io_buf *lpfc_cmd; |
---|
4767 | 4734 | IOCB_t *cmd, *icmd; |
---|
4768 | 4735 | int ret = SUCCESS, status = 0; |
---|
4769 | 4736 | struct lpfc_sli_ring *pring_s4 = NULL; |
---|
.. | .. |
---|
4775 | 4742 | if (status != 0 && status != SUCCESS) |
---|
4776 | 4743 | return status; |
---|
4777 | 4744 | |
---|
| 4745 | + lpfc_cmd = (struct lpfc_io_buf *)cmnd->host_scribble; |
---|
| 4746 | + if (!lpfc_cmd) |
---|
| 4747 | + return ret; |
---|
| 4748 | + |
---|
4778 | 4749 | spin_lock_irqsave(&phba->hbalock, flags); |
---|
4779 | 4750 | /* driver queued commands are in process of being flushed */ |
---|
4780 | | - if (phba->hba_flag & HBA_FCP_IOQ_FLUSH) { |
---|
4781 | | - spin_unlock_irqrestore(&phba->hbalock, flags); |
---|
| 4751 | + if (phba->hba_flag & HBA_IOQ_FLUSH) { |
---|
4782 | 4752 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, |
---|
4783 | 4753 | "3168 SCSI Layer abort requested I/O has been " |
---|
4784 | 4754 | "flushed by LLD.\n"); |
---|
4785 | | - return FAILED; |
---|
| 4755 | + ret = FAILED; |
---|
| 4756 | + goto out_unlock; |
---|
4786 | 4757 | } |
---|
4787 | 4758 | |
---|
4788 | | - lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble; |
---|
4789 | | - if (!lpfc_cmd || !lpfc_cmd->pCmd) { |
---|
4790 | | - spin_unlock_irqrestore(&phba->hbalock, flags); |
---|
| 4759 | + /* Guard against IO completion being called at same time */ |
---|
| 4760 | + spin_lock(&lpfc_cmd->buf_lock); |
---|
| 4761 | + |
---|
| 4762 | + if (!lpfc_cmd->pCmd) { |
---|
4791 | 4763 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, |
---|
4792 | 4764 | "2873 SCSI Layer I/O Abort Request IO CMPL Status " |
---|
4793 | 4765 | "x%x ID %d LUN %llu\n", |
---|
4794 | 4766 | SUCCESS, cmnd->device->id, cmnd->device->lun); |
---|
4795 | | - return SUCCESS; |
---|
| 4767 | + goto out_unlock_buf; |
---|
4796 | 4768 | } |
---|
4797 | 4769 | |
---|
4798 | 4770 | iocb = &lpfc_cmd->cur_iocbq; |
---|
4799 | 4771 | if (phba->sli_rev == LPFC_SLI_REV4) { |
---|
4800 | | - if (!(phba->cfg_fof) || |
---|
4801 | | - (!(iocb->iocb_flag & LPFC_IO_FOF))) { |
---|
4802 | | - pring_s4 = |
---|
4803 | | - phba->sli4_hba.fcp_wq[iocb->hba_wqidx]->pring; |
---|
4804 | | - } else { |
---|
4805 | | - iocb->hba_wqidx = 0; |
---|
4806 | | - pring_s4 = phba->sli4_hba.oas_wq->pring; |
---|
4807 | | - } |
---|
| 4772 | + pring_s4 = phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring; |
---|
4808 | 4773 | if (!pring_s4) { |
---|
4809 | 4774 | ret = FAILED; |
---|
4810 | | - goto out_unlock; |
---|
| 4775 | + goto out_unlock_buf; |
---|
4811 | 4776 | } |
---|
4812 | 4777 | spin_lock(&pring_s4->ring_lock); |
---|
4813 | 4778 | } |
---|
4814 | 4779 | /* the command is in process of being cancelled */ |
---|
4815 | 4780 | if (!(iocb->iocb_flag & LPFC_IO_ON_TXCMPLQ)) { |
---|
4816 | | - if (phba->sli_rev == LPFC_SLI_REV4) |
---|
4817 | | - spin_unlock(&pring_s4->ring_lock); |
---|
4818 | | - spin_unlock_irqrestore(&phba->hbalock, flags); |
---|
4819 | 4781 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, |
---|
4820 | 4782 | "3169 SCSI Layer abort requested I/O has been " |
---|
4821 | 4783 | "cancelled by LLD.\n"); |
---|
4822 | | - return FAILED; |
---|
| 4784 | + ret = FAILED; |
---|
| 4785 | + goto out_unlock_ring; |
---|
4823 | 4786 | } |
---|
4824 | 4787 | /* |
---|
4825 | | - * If pCmd field of the corresponding lpfc_scsi_buf structure |
---|
| 4788 | + * If pCmd field of the corresponding lpfc_io_buf structure |
---|
4826 | 4789 | * points to a different SCSI command, then the driver has |
---|
4827 | 4790 | * already completed this command, but the midlayer did not |
---|
4828 | 4791 | * see the completion before the eh fired. Just return SUCCESS. |
---|
4829 | 4792 | */ |
---|
4830 | 4793 | if (lpfc_cmd->pCmd != cmnd) { |
---|
4831 | | - if (phba->sli_rev == LPFC_SLI_REV4) |
---|
4832 | | - spin_unlock(&pring_s4->ring_lock); |
---|
4833 | 4794 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, |
---|
4834 | 4795 | "3170 SCSI Layer abort requested I/O has been " |
---|
4835 | 4796 | "completed by LLD.\n"); |
---|
4836 | | - goto out_unlock; |
---|
| 4797 | + goto out_unlock_ring; |
---|
4837 | 4798 | } |
---|
4838 | 4799 | |
---|
4839 | 4800 | BUG_ON(iocb->context1 != lpfc_cmd); |
---|
.. | .. |
---|
4844 | 4805 | "3389 SCSI Layer I/O Abort Request is pending\n"); |
---|
4845 | 4806 | if (phba->sli_rev == LPFC_SLI_REV4) |
---|
4846 | 4807 | spin_unlock(&pring_s4->ring_lock); |
---|
| 4808 | + spin_unlock(&lpfc_cmd->buf_lock); |
---|
4847 | 4809 | spin_unlock_irqrestore(&phba->hbalock, flags); |
---|
4848 | 4810 | goto wait_for_cmpl; |
---|
4849 | 4811 | } |
---|
.. | .. |
---|
4851 | 4813 | abtsiocb = __lpfc_sli_get_iocbq(phba); |
---|
4852 | 4814 | if (abtsiocb == NULL) { |
---|
4853 | 4815 | ret = FAILED; |
---|
4854 | | - if (phba->sli_rev == LPFC_SLI_REV4) |
---|
4855 | | - spin_unlock(&pring_s4->ring_lock); |
---|
4856 | | - goto out_unlock; |
---|
| 4816 | + goto out_unlock_ring; |
---|
4857 | 4817 | } |
---|
4858 | 4818 | |
---|
4859 | 4819 | /* Indicate the IO is being aborted by the driver. */ |
---|
.. | .. |
---|
4900 | 4860 | ret_val = __lpfc_sli_issue_iocb(phba, LPFC_FCP_RING, |
---|
4901 | 4861 | abtsiocb, 0); |
---|
4902 | 4862 | } |
---|
4903 | | - /* no longer need the lock after this point */ |
---|
4904 | | - spin_unlock_irqrestore(&phba->hbalock, flags); |
---|
4905 | | - |
---|
4906 | 4863 | |
---|
4907 | 4864 | if (ret_val == IOCB_ERROR) { |
---|
4908 | | - if (phba->sli_rev == LPFC_SLI_REV4) |
---|
4909 | | - spin_lock_irqsave(&pring_s4->ring_lock, flags); |
---|
4910 | | - else |
---|
4911 | | - spin_lock_irqsave(&phba->hbalock, flags); |
---|
4912 | 4865 | /* Indicate the IO is not being aborted by the driver. */ |
---|
4913 | 4866 | iocb->iocb_flag &= ~LPFC_DRIVER_ABORTED; |
---|
4914 | 4867 | lpfc_cmd->waitq = NULL; |
---|
4915 | | - if (phba->sli_rev == LPFC_SLI_REV4) |
---|
4916 | | - spin_unlock_irqrestore(&pring_s4->ring_lock, flags); |
---|
4917 | | - else |
---|
4918 | | - spin_unlock_irqrestore(&phba->hbalock, flags); |
---|
| 4868 | + spin_unlock(&lpfc_cmd->buf_lock); |
---|
| 4869 | + spin_unlock_irqrestore(&phba->hbalock, flags); |
---|
4919 | 4870 | lpfc_sli_release_iocbq(phba, abtsiocb); |
---|
4920 | 4871 | ret = FAILED; |
---|
4921 | 4872 | goto out; |
---|
4922 | 4873 | } |
---|
| 4874 | + |
---|
| 4875 | + /* no longer need the lock after this point */ |
---|
| 4876 | + spin_unlock(&lpfc_cmd->buf_lock); |
---|
| 4877 | + spin_unlock_irqrestore(&phba->hbalock, flags); |
---|
4923 | 4878 | |
---|
4924 | 4879 | if (phba->cfg_poll & DISABLE_FCP_RING_INT) |
---|
4925 | 4880 | lpfc_sli_handle_fast_ring_event(phba, |
---|
.. | .. |
---|
4931 | 4886 | (lpfc_cmd->pCmd != cmnd), |
---|
4932 | 4887 | msecs_to_jiffies(2*vport->cfg_devloss_tmo*1000)); |
---|
4933 | 4888 | |
---|
4934 | | - spin_lock_irqsave(shost->host_lock, flags); |
---|
4935 | | - lpfc_cmd->waitq = NULL; |
---|
4936 | | - spin_unlock_irqrestore(shost->host_lock, flags); |
---|
| 4889 | + spin_lock(&lpfc_cmd->buf_lock); |
---|
4937 | 4890 | |
---|
4938 | 4891 | if (lpfc_cmd->pCmd == cmnd) { |
---|
4939 | 4892 | ret = FAILED; |
---|
4940 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
| 4893 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
4941 | 4894 | "0748 abort handler timed out waiting " |
---|
4942 | 4895 | "for aborting I/O (xri:x%x) to complete: " |
---|
4943 | 4896 | "ret %#x, ID %d, LUN %llu\n", |
---|
4944 | 4897 | iocb->sli4_xritag, ret, |
---|
4945 | 4898 | cmnd->device->id, cmnd->device->lun); |
---|
4946 | 4899 | } |
---|
| 4900 | + |
---|
| 4901 | + lpfc_cmd->waitq = NULL; |
---|
| 4902 | + |
---|
| 4903 | + spin_unlock(&lpfc_cmd->buf_lock); |
---|
4947 | 4904 | goto out; |
---|
4948 | 4905 | |
---|
| 4906 | +out_unlock_ring: |
---|
| 4907 | + if (phba->sli_rev == LPFC_SLI_REV4) |
---|
| 4908 | + spin_unlock(&pring_s4->ring_lock); |
---|
| 4909 | +out_unlock_buf: |
---|
| 4910 | + spin_unlock(&lpfc_cmd->buf_lock); |
---|
4949 | 4911 | out_unlock: |
---|
4950 | 4912 | spin_unlock_irqrestore(&phba->hbalock, flags); |
---|
4951 | 4913 | out: |
---|
.. | .. |
---|
4983 | 4945 | /** |
---|
4984 | 4946 | * lpfc_check_fcp_rsp - check the returned fcp_rsp to see if task failed |
---|
4985 | 4947 | * @vport: The virtual port for which this call is being executed. |
---|
4986 | | - * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure. |
---|
| 4948 | + * @lpfc_cmd: Pointer to lpfc_io_buf data structure. |
---|
4987 | 4949 | * |
---|
4988 | 4950 | * This routine checks the FCP RSP INFO to see if the tsk mgmt command succeded |
---|
4989 | 4951 | * |
---|
.. | .. |
---|
4992 | 4954 | * 0x2002 - Success |
---|
4993 | 4955 | **/ |
---|
4994 | 4956 | static int |
---|
4995 | | -lpfc_check_fcp_rsp(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd) |
---|
| 4957 | +lpfc_check_fcp_rsp(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd) |
---|
4996 | 4958 | { |
---|
4997 | 4959 | struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp; |
---|
4998 | 4960 | uint32_t rsp_info; |
---|
.. | .. |
---|
5017 | 4979 | rsp_info, |
---|
5018 | 4980 | rsp_len, rsp_info_code); |
---|
5019 | 4981 | |
---|
5020 | | - if ((fcprsp->rspStatus2&RSP_LEN_VALID) && (rsp_len == 8)) { |
---|
| 4982 | + /* If FCP_RSP_LEN_VALID bit is one, then the FCP_RSP_LEN |
---|
| 4983 | + * field specifies the number of valid bytes of FCP_RSP_INFO. |
---|
| 4984 | + * The FCP_RSP_LEN field shall be set to 0x04 or 0x08 |
---|
| 4985 | + */ |
---|
| 4986 | + if ((fcprsp->rspStatus2 & RSP_LEN_VALID) && |
---|
| 4987 | + ((rsp_len == 8) || (rsp_len == 4))) { |
---|
5021 | 4988 | switch (rsp_info_code) { |
---|
5022 | 4989 | case RSP_NO_FAILURE: |
---|
5023 | 4990 | lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP, |
---|
.. | .. |
---|
5067 | 5034 | uint8_t task_mgmt_cmd) |
---|
5068 | 5035 | { |
---|
5069 | 5036 | struct lpfc_hba *phba = vport->phba; |
---|
5070 | | - struct lpfc_scsi_buf *lpfc_cmd; |
---|
| 5037 | + struct lpfc_io_buf *lpfc_cmd; |
---|
5071 | 5038 | struct lpfc_iocbq *iocbq; |
---|
5072 | 5039 | struct lpfc_iocbq *iocbqrsp; |
---|
5073 | 5040 | struct lpfc_rport_data *rdata; |
---|
.. | .. |
---|
5080 | 5047 | return FAILED; |
---|
5081 | 5048 | pnode = rdata->pnode; |
---|
5082 | 5049 | |
---|
5083 | | - lpfc_cmd = lpfc_get_scsi_buf(phba, pnode); |
---|
| 5050 | + lpfc_cmd = lpfc_get_scsi_buf(phba, pnode, NULL); |
---|
5084 | 5051 | if (lpfc_cmd == NULL) |
---|
5085 | 5052 | return FAILED; |
---|
5086 | 5053 | lpfc_cmd->timeout = phba->cfg_task_mgmt_tmo; |
---|
.. | .. |
---|
5116 | 5083 | (iocbqrsp->iocb.ulpStatus != IOSTAT_SUCCESS)) { |
---|
5117 | 5084 | if (status != IOCB_SUCCESS || |
---|
5118 | 5085 | iocbqrsp->iocb.ulpStatus != IOSTAT_FCP_RSP_ERROR) |
---|
5119 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
| 5086 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
5120 | 5087 | "0727 TMF %s to TGT %d LUN %llu " |
---|
5121 | 5088 | "failed (%d, %d) iocb_flag x%x\n", |
---|
5122 | 5089 | lpfc_taskmgmt_name(task_mgmt_cmd), |
---|
.. | .. |
---|
5170 | 5137 | rdata = lpfc_rport_data_from_scsi_device(cmnd->device); |
---|
5171 | 5138 | if (!rdata) { |
---|
5172 | 5139 | lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP, |
---|
5173 | | - "0797 Tgt Map rport failure: rdata x%p\n", rdata); |
---|
| 5140 | + "0797 Tgt Map rport failure: rdata x%px\n", rdata); |
---|
5174 | 5141 | return FAILED; |
---|
5175 | 5142 | } |
---|
5176 | 5143 | pnode = rdata->pnode; |
---|
.. | .. |
---|
5231 | 5198 | cnt = lpfc_sli_sum_iocb(vport, tgt_id, lun_id, context); |
---|
5232 | 5199 | } |
---|
5233 | 5200 | if (cnt) { |
---|
5234 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
| 5201 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
5235 | 5202 | "0724 I/O flush failure for context %s : cnt x%x\n", |
---|
5236 | 5203 | ((context == LPFC_CTX_LUN) ? "LUN" : |
---|
5237 | 5204 | ((context == LPFC_CTX_TGT) ? "TGT" : |
---|
.. | .. |
---|
5267 | 5234 | |
---|
5268 | 5235 | rdata = lpfc_rport_data_from_scsi_device(cmnd->device); |
---|
5269 | 5236 | if (!rdata || !rdata->pnode) { |
---|
5270 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
5271 | | - "0798 Device Reset rport failure: rdata x%p\n", |
---|
| 5237 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
| 5238 | + "0798 Device Reset rdata failure: rdata x%px\n", |
---|
5272 | 5239 | rdata); |
---|
5273 | 5240 | return FAILED; |
---|
5274 | 5241 | } |
---|
.. | .. |
---|
5279 | 5246 | |
---|
5280 | 5247 | status = lpfc_chk_tgt_mapped(vport, cmnd); |
---|
5281 | 5248 | if (status == FAILED) { |
---|
5282 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
5283 | | - "0721 Device Reset rport failure: rdata x%p\n", rdata); |
---|
| 5249 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
| 5250 | + "0721 Device Reset rport failure: rdata x%px\n", rdata); |
---|
5284 | 5251 | return FAILED; |
---|
5285 | 5252 | } |
---|
5286 | 5253 | |
---|
.. | .. |
---|
5296 | 5263 | status = lpfc_send_taskmgmt(vport, cmnd, tgt_id, lun_id, |
---|
5297 | 5264 | FCP_LUN_RESET); |
---|
5298 | 5265 | |
---|
5299 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
| 5266 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
5300 | 5267 | "0713 SCSI layer issued Device Reset (%d, %llu) " |
---|
5301 | 5268 | "return x%x\n", tgt_id, lun_id, status); |
---|
5302 | 5269 | |
---|
.. | .. |
---|
5337 | 5304 | int status; |
---|
5338 | 5305 | |
---|
5339 | 5306 | rdata = lpfc_rport_data_from_scsi_device(cmnd->device); |
---|
5340 | | - if (!rdata) { |
---|
5341 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
5342 | | - "0799 Target Reset rport failure: rdata x%p\n", rdata); |
---|
| 5307 | + if (!rdata || !rdata->pnode) { |
---|
| 5308 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
| 5309 | + "0799 Target Reset rdata failure: rdata x%px\n", |
---|
| 5310 | + rdata); |
---|
5343 | 5311 | return FAILED; |
---|
5344 | 5312 | } |
---|
5345 | 5313 | pnode = rdata->pnode; |
---|
.. | .. |
---|
5349 | 5317 | |
---|
5350 | 5318 | status = lpfc_chk_tgt_mapped(vport, cmnd); |
---|
5351 | 5319 | if (status == FAILED) { |
---|
5352 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
5353 | | - "0722 Target Reset rport failure: rdata x%p\n", rdata); |
---|
| 5320 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
| 5321 | + "0722 Target Reset rport failure: rdata x%px\n", rdata); |
---|
5354 | 5322 | if (pnode) { |
---|
5355 | 5323 | spin_lock_irq(shost->host_lock); |
---|
5356 | 5324 | pnode->nlp_flag &= ~NLP_NPR_ADISC; |
---|
.. | .. |
---|
5374 | 5342 | status = lpfc_send_taskmgmt(vport, cmnd, tgt_id, lun_id, |
---|
5375 | 5343 | FCP_TARGET_RESET); |
---|
5376 | 5344 | |
---|
5377 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
| 5345 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
5378 | 5346 | "0723 SCSI layer issued Target Reset (%d, %llu) " |
---|
5379 | 5347 | "return x%x\n", tgt_id, lun_id, status); |
---|
5380 | 5348 | |
---|
.. | .. |
---|
5455 | 5423 | i, 0, FCP_TARGET_RESET); |
---|
5456 | 5424 | |
---|
5457 | 5425 | if (status != SUCCESS) { |
---|
5458 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
| 5426 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
5459 | 5427 | "0700 Bus Reset on target %d failed\n", |
---|
5460 | 5428 | i); |
---|
5461 | 5429 | ret = FAILED; |
---|
.. | .. |
---|
5472 | 5440 | if (status != SUCCESS) |
---|
5473 | 5441 | ret = FAILED; |
---|
5474 | 5442 | |
---|
5475 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
| 5443 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
5476 | 5444 | "0714 SCSI layer issued Bus Reset Data: x%x\n", ret); |
---|
5477 | 5445 | return ret; |
---|
5478 | 5446 | } |
---|
.. | .. |
---|
5501 | 5469 | struct lpfc_hba *phba = vport->phba; |
---|
5502 | 5470 | int rc, ret = SUCCESS; |
---|
5503 | 5471 | |
---|
5504 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
| 5472 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
5505 | 5473 | "3172 SCSI layer issued Host Reset Data:\n"); |
---|
5506 | 5474 | |
---|
5507 | 5475 | lpfc_offline_prep(phba, LPFC_MBX_WAIT); |
---|
5508 | 5476 | lpfc_offline(phba); |
---|
5509 | 5477 | rc = lpfc_sli_brdrestart(phba); |
---|
5510 | 5478 | if (rc) |
---|
5511 | | - ret = FAILED; |
---|
| 5479 | + goto error; |
---|
| 5480 | + |
---|
5512 | 5481 | rc = lpfc_online(phba); |
---|
5513 | 5482 | if (rc) |
---|
5514 | | - ret = FAILED; |
---|
| 5483 | + goto error; |
---|
| 5484 | + |
---|
5515 | 5485 | lpfc_unblock_mgmt_io(phba); |
---|
5516 | 5486 | |
---|
5517 | | - if (ret == FAILED) { |
---|
5518 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
5519 | | - "3323 Failed host reset, bring it offline\n"); |
---|
5520 | | - lpfc_sli4_offline_eratt(phba); |
---|
5521 | | - } |
---|
5522 | 5487 | return ret; |
---|
| 5488 | +error: |
---|
| 5489 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
| 5490 | + "3323 Failed host reset\n"); |
---|
| 5491 | + lpfc_unblock_mgmt_io(phba); |
---|
| 5492 | + return FAILED; |
---|
5523 | 5493 | } |
---|
5524 | 5494 | |
---|
5525 | 5495 | /** |
---|
.. | .. |
---|
5588 | 5558 | } |
---|
5589 | 5559 | sdev_cnt = atomic_inc_return(&phba->sdev_cnt); |
---|
5590 | 5560 | |
---|
| 5561 | + /* For SLI4, all IO buffers are pre-allocated */ |
---|
| 5562 | + if (phba->sli_rev == LPFC_SLI_REV4) |
---|
| 5563 | + return 0; |
---|
| 5564 | + |
---|
| 5565 | + /* This code path is now ONLY for SLI3 adapters */ |
---|
| 5566 | + |
---|
5591 | 5567 | /* |
---|
5592 | 5568 | * Populate the cmds_per_lun count scsi_bufs into this host's globally |
---|
5593 | 5569 | * available list of scsi buffers. Don't allocate more than the |
---|
.. | .. |
---|
5619 | 5595 | (phba->cfg_hba_queue_depth - total)); |
---|
5620 | 5596 | num_to_alloc = phba->cfg_hba_queue_depth - total; |
---|
5621 | 5597 | } |
---|
5622 | | - num_allocated = lpfc_new_scsi_buf(vport, num_to_alloc); |
---|
| 5598 | + num_allocated = lpfc_new_scsi_buf_s3(vport, num_to_alloc); |
---|
5623 | 5599 | if (num_to_alloc != num_allocated) { |
---|
5624 | | - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, |
---|
| 5600 | + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
---|
5625 | 5601 | "0708 Allocation request of %d " |
---|
5626 | 5602 | "command buffers did not succeed. " |
---|
5627 | 5603 | "Allocated %d buffers.\n", |
---|
.. | .. |
---|
5954 | 5930 | |
---|
5955 | 5931 | /* Create an lun info structure and add to list of luns */ |
---|
5956 | 5932 | lun_info = lpfc_create_device_data(phba, vport_wwpn, target_wwpn, lun, |
---|
5957 | | - pri, false); |
---|
| 5933 | + pri, true); |
---|
5958 | 5934 | if (lun_info) { |
---|
5959 | 5935 | lun_info->oas_enabled = true; |
---|
5960 | 5936 | lun_info->priority = pri; |
---|
.. | .. |
---|
6052 | 6028 | .this_id = -1, |
---|
6053 | 6029 | .sg_tablesize = 1, |
---|
6054 | 6030 | .cmd_per_lun = 1, |
---|
6055 | | - .use_clustering = ENABLE_CLUSTERING, |
---|
6056 | 6031 | .shost_attrs = lpfc_hba_attrs, |
---|
6057 | 6032 | .max_sectors = 0xFFFF, |
---|
6058 | 6033 | .vendor_id = LPFC_NL_VENDOR_ID, |
---|
6059 | 6034 | .track_queue_depth = 0, |
---|
6060 | | -}; |
---|
6061 | | - |
---|
6062 | | -struct scsi_host_template lpfc_template_no_hr = { |
---|
6063 | | - .module = THIS_MODULE, |
---|
6064 | | - .name = LPFC_DRIVER_NAME, |
---|
6065 | | - .proc_name = LPFC_DRIVER_NAME, |
---|
6066 | | - .info = lpfc_info, |
---|
6067 | | - .queuecommand = lpfc_queuecommand, |
---|
6068 | | - .eh_timed_out = fc_eh_timed_out, |
---|
6069 | | - .eh_abort_handler = lpfc_abort_handler, |
---|
6070 | | - .eh_device_reset_handler = lpfc_device_reset_handler, |
---|
6071 | | - .eh_target_reset_handler = lpfc_target_reset_handler, |
---|
6072 | | - .eh_bus_reset_handler = lpfc_bus_reset_handler, |
---|
6073 | | - .slave_alloc = lpfc_slave_alloc, |
---|
6074 | | - .slave_configure = lpfc_slave_configure, |
---|
6075 | | - .slave_destroy = lpfc_slave_destroy, |
---|
6076 | | - .scan_finished = lpfc_scan_finished, |
---|
6077 | | - .this_id = -1, |
---|
6078 | | - .sg_tablesize = LPFC_DEFAULT_SG_SEG_CNT, |
---|
6079 | | - .cmd_per_lun = LPFC_CMD_PER_LUN, |
---|
6080 | | - .use_clustering = ENABLE_CLUSTERING, |
---|
6081 | | - .shost_attrs = lpfc_hba_attrs, |
---|
6082 | | - .max_sectors = 0xFFFF, |
---|
6083 | | - .vendor_id = LPFC_NL_VENDOR_ID, |
---|
6084 | | - .change_queue_depth = scsi_change_queue_depth, |
---|
6085 | | - .track_queue_depth = 1, |
---|
6086 | 6035 | }; |
---|
6087 | 6036 | |
---|
6088 | 6037 | struct scsi_host_template lpfc_template = { |
---|
.. | .. |
---|
6104 | 6053 | .this_id = -1, |
---|
6105 | 6054 | .sg_tablesize = LPFC_DEFAULT_SG_SEG_CNT, |
---|
6106 | 6055 | .cmd_per_lun = LPFC_CMD_PER_LUN, |
---|
6107 | | - .use_clustering = ENABLE_CLUSTERING, |
---|
6108 | 6056 | .shost_attrs = lpfc_hba_attrs, |
---|
6109 | 6057 | .max_sectors = 0xFFFF, |
---|
6110 | 6058 | .vendor_id = LPFC_NL_VENDOR_ID, |
---|
6111 | | - .change_queue_depth = scsi_change_queue_depth, |
---|
6112 | | - .track_queue_depth = 1, |
---|
6113 | | -}; |
---|
6114 | | - |
---|
6115 | | -struct scsi_host_template lpfc_vport_template = { |
---|
6116 | | - .module = THIS_MODULE, |
---|
6117 | | - .name = LPFC_DRIVER_NAME, |
---|
6118 | | - .proc_name = LPFC_DRIVER_NAME, |
---|
6119 | | - .info = lpfc_info, |
---|
6120 | | - .queuecommand = lpfc_queuecommand, |
---|
6121 | | - .eh_timed_out = fc_eh_timed_out, |
---|
6122 | | - .eh_abort_handler = lpfc_abort_handler, |
---|
6123 | | - .eh_device_reset_handler = lpfc_device_reset_handler, |
---|
6124 | | - .eh_target_reset_handler = lpfc_target_reset_handler, |
---|
6125 | | - .slave_alloc = lpfc_slave_alloc, |
---|
6126 | | - .slave_configure = lpfc_slave_configure, |
---|
6127 | | - .slave_destroy = lpfc_slave_destroy, |
---|
6128 | | - .scan_finished = lpfc_scan_finished, |
---|
6129 | | - .this_id = -1, |
---|
6130 | | - .sg_tablesize = LPFC_DEFAULT_SG_SEG_CNT, |
---|
6131 | | - .cmd_per_lun = LPFC_CMD_PER_LUN, |
---|
6132 | | - .use_clustering = ENABLE_CLUSTERING, |
---|
6133 | | - .shost_attrs = lpfc_vport_attrs, |
---|
6134 | | - .max_sectors = 0xFFFF, |
---|
6135 | 6059 | .change_queue_depth = scsi_change_queue_depth, |
---|
6136 | 6060 | .track_queue_depth = 1, |
---|
6137 | 6061 | }; |
---|