hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/scsi/lpfc/lpfc_scsi.c
....@@ -1,7 +1,7 @@
11 /*******************************************************************
22 * This file is part of the Emulex Linux Device Driver for *
33 * 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 *
55 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
66 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
77 * EMULEX and SLI are trademarks of Emulex. *
....@@ -53,8 +53,6 @@
5353 #define LPFC_RESET_WAIT 2
5454 #define LPFC_ABORT_WAIT 2
5555
56
-int _dump_buf_done = 1;
57
-
5856 static char *dif_op_str[] = {
5957 "PROT_NORMAL",
6058 "PROT_READ_INSERT",
....@@ -83,68 +81,11 @@
8381 }
8482
8583 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);
8785 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);
8987 static int
9088 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
-}
14889
14990 static inline unsigned
15091 lpfc_cmd_blksize(struct scsi_cmnd *sc)
....@@ -180,9 +121,9 @@
180121 **/
181122 static void
182123 lpfc_sli4_set_rsp_sgl_last(struct lpfc_hba *phba,
183
- struct lpfc_scsi_buf *lpfc_cmd)
124
+ struct lpfc_io_buf *lpfc_cmd)
184125 {
185
- struct sli4_sge *sgl = (struct sli4_sge *)lpfc_cmd->fcp_bpl;
126
+ struct sli4_sge *sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl;
186127 if (sgl) {
187128 sgl += 1;
188129 sgl->word2 = le32_to_cpu(sgl->word2);
....@@ -193,35 +134,37 @@
193134
194135 /**
195136 * 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.
197138 * @lpfc_cmd: lpfc scsi command object pointer.
198139 *
199140 * This function is called when there is a command completion and this
200141 * function updates the statistical data for the command completion.
201142 **/
202143 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)
204145 {
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;
207149 struct scsi_cmnd *cmd = lpfc_cmd->pCmd;
208150 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);
211152 unsigned long latency;
212153 int i;
213154
214
- if (cmd->result)
155
+ if (!vport->stat_data_enabled ||
156
+ vport->stat_data_blocked ||
157
+ (cmd->result))
215158 return;
216159
217160 latency = jiffies_to_msecs((long)jiffies - (long)lpfc_cmd->start_time);
161
+ rdata = lpfc_cmd->rdata;
162
+ pnode = rdata->pnode;
218163
219164 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)) {
225168 spin_unlock_irqrestore(shost->host_lock, flags);
226169 return;
227170 }
....@@ -387,12 +330,12 @@
387330 lpfc_new_scsi_buf_s3(struct lpfc_vport *vport, int num_to_alloc)
388331 {
389332 struct lpfc_hba *phba = vport->phba;
390
- struct lpfc_scsi_buf *psb;
333
+ struct lpfc_io_buf *psb;
391334 struct ulp_bde64 *bpl;
392335 IOCB_t *iocb;
393336 dma_addr_t pdma_phys_fcp_cmd;
394337 dma_addr_t pdma_phys_fcp_rsp;
395
- dma_addr_t pdma_phys_bpl;
338
+ dma_addr_t pdma_phys_sgl;
396339 uint16_t iotag;
397340 int bcnt, bpl_size;
398341
....@@ -406,7 +349,7 @@
406349 (int)sizeof(struct fcp_rsp), bpl_size);
407350
408351 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);
410353 if (!psb)
411354 break;
412355
....@@ -436,14 +379,14 @@
436379
437380 psb->fcp_cmnd = psb->data;
438381 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) +
440383 sizeof(struct fcp_rsp);
441384
442385 /* Initialize local short-hand pointers. */
443
- bpl = psb->fcp_bpl;
386
+ bpl = (struct ulp_bde64 *)psb->dma_sgl;
444387 pdma_phys_fcp_cmd = psb->dma_handle;
445388 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) +
447390 sizeof(struct fcp_rsp);
448391
449392 /*
....@@ -494,9 +437,9 @@
494437 iocb->un.fcpi64.bdl.bdeSize =
495438 (2 * sizeof(struct ulp_bde64));
496439 iocb->un.fcpi64.bdl.addrLow =
497
- putPaddrLow(pdma_phys_bpl);
440
+ putPaddrLow(pdma_phys_sgl);
498441 iocb->un.fcpi64.bdl.addrHigh =
499
- putPaddrHigh(pdma_phys_bpl);
442
+ putPaddrHigh(pdma_phys_sgl);
500443 iocb->ulpBdeCount = 1;
501444 iocb->ulpLe = 1;
502445 }
....@@ -504,6 +447,7 @@
504447 psb->status = IOSTAT_SUCCESS;
505448 /* Put it back into the SCSI buffer list */
506449 psb->cur_iocbq.context1 = psb;
450
+ spin_lock_init(&psb->buf_lock);
507451 lpfc_release_scsi_buf_s3(phba, psb);
508452
509453 }
....@@ -522,38 +466,49 @@
522466 lpfc_sli4_vport_delete_fcp_xri_aborted(struct lpfc_vport *vport)
523467 {
524468 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;
526471 unsigned long iflag = 0;
472
+ int idx;
527473
528
- if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP))
474
+ if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP))
529475 return;
476
+
530477 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);
537492 }
538
- spin_unlock(&phba->sli4_hba.abts_scsi_buf_list_lock);
539493 spin_unlock_irqrestore(&phba->hbalock, iflag);
540494 }
541495
542496 /**
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
544498 * @phba: pointer to lpfc hba data structure.
545499 * @axri: pointer to the fcp xri abort wcqe structure.
546500 *
547501 * This routine is invoked by the worker thread to process a SLI4 fast-path
548
- * FCP aborted xri.
502
+ * FCP or NVME aborted xri.
549503 **/
550504 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)
553507 {
554508 uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri);
555509 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;
557512 unsigned long iflag = 0;
558513 struct lpfc_iocbq *iocbq;
559514 int i;
....@@ -563,16 +518,26 @@
563518
564519 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP))
565520 return;
521
+
522
+ qp = &phba->sli4_hba.hdwq[idx];
566523 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);
568525 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) {
570527 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;
573530 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
+
576541 if (psb->rdata && psb->rdata->pnode)
577542 ndlp = psb->rdata->pnode;
578543 else
....@@ -591,17 +556,17 @@
591556 return;
592557 }
593558 }
594
- spin_unlock(&phba->sli4_hba.abts_scsi_buf_list_lock);
559
+ spin_unlock(&qp->abts_io_buf_list_lock);
595560 for (i = 1; i <= phba->sli.last_iotag; i++) {
596561 iocbq = phba->sli.iocbq_lookup[i];
597562
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))
600565 continue;
601566 if (iocbq->sli4_xritag != xri)
602567 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;
605570 spin_unlock_irqrestore(&phba->hbalock, iflag);
606571 if (!list_empty(&pring->txq))
607572 lpfc_worker_wake_up(phba);
....@@ -609,359 +574,6 @@
609574
610575 }
611576 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);
965577 }
966578
967579 /**
....@@ -975,15 +587,16 @@
975587 * NULL - Error
976588 * Pointer to lpfc_scsi_buf - Success
977589 **/
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)
980593 {
981
- struct lpfc_scsi_buf * lpfc_cmd = NULL;
594
+ struct lpfc_io_buf *lpfc_cmd = NULL;
982595 struct list_head *scsi_buf_list_get = &phba->lpfc_scsi_buf_list_get;
983596 unsigned long iflag = 0;
984597
985598 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,
987600 list);
988601 if (!lpfc_cmd) {
989602 spin_lock(&phba->scsi_buf_list_put_lock);
....@@ -991,7 +604,7 @@
991604 &phba->lpfc_scsi_buf_list_get);
992605 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_put);
993606 list_remove_head(scsi_buf_list_get, lpfc_cmd,
994
- struct lpfc_scsi_buf, list);
607
+ struct lpfc_io_buf, list);
995608 spin_unlock(&phba->scsi_buf_list_put_lock);
996609 }
997610 spin_unlock_irqrestore(&phba->scsi_buf_list_get_lock, iflag);
....@@ -1003,54 +616,112 @@
1003616 return lpfc_cmd;
1004617 }
1005618 /**
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
1007620 * @phba: The HBA for which this call is being executed.
1008621 *
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
1010623 * and returns to caller.
1011624 *
1012625 * Return codes:
1013626 * NULL - Error
1014627 * Pointer to lpfc_scsi_buf - Success
1015628 **/
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)
1018632 {
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;
1022642
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;
1032649 }
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++;
1051656 return NULL;
657
+ }
1052658
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)) {
1054725 atomic_inc(&ndlp->cmd_pending);
1055726 lpfc_cmd->flags |= LPFC_SBUF_BUMP_QDEPTH;
1056727 }
....@@ -1067,10 +738,11 @@
1067738 * NULL - Error
1068739 * Pointer to lpfc_scsi_buf - Success
1069740 **/
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)
1072744 {
1073
- return phba->lpfc_get_scsi_buf(phba, ndlp);
745
+ return phba->lpfc_get_scsi_buf(phba, ndlp, cmnd);
1074746 }
1075747
1076748 /**
....@@ -1082,12 +754,11 @@
1082754 * lpfc_scsi_buf_list list.
1083755 **/
1084756 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)
1086758 {
1087759 unsigned long iflag = 0;
1088760
1089761 psb->seg_cnt = 0;
1090
- psb->nonsg_phys = 0;
1091762 psb->prot_seg_cnt = 0;
1092763
1093764 spin_lock_irqsave(&phba->scsi_buf_list_put_lock, iflag);
....@@ -1102,34 +773,29 @@
1102773 * @phba: The Hba for which this call is being executed.
1103774 * @psb: The scsi buffer which is being released.
1104775 *
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
1107778 * and cannot be reused for at least RA_TOV amount of time if it was
1108779 * aborted.
1109780 **/
1110781 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)
1112783 {
784
+ struct lpfc_sli4_hdw_queue *qp;
1113785 unsigned long iflag = 0;
1114786
1115787 psb->seg_cnt = 0;
1116
- psb->nonsg_phys = 0;
1117788 psb->prot_seg_cnt = 0;
1118789
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);
1122793 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);
1127797 } 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);
1133799 }
1134800 }
1135801
....@@ -1142,7 +808,7 @@
1142808 * lpfc_scsi_buf_list list.
1143809 **/
1144810 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)
1146812 {
1147813 if ((psb->flags & LPFC_SBUF_BUMP_QDEPTH) && psb->ndlp)
1148814 atomic_dec(&psb->ndlp->cmd_pending);
....@@ -1166,12 +832,12 @@
1166832 * 0 - Success
1167833 **/
1168834 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)
1170836 {
1171837 struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd;
1172838 struct scatterlist *sgel = NULL;
1173839 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;
1175841 struct lpfc_iocbq *iocbq = &lpfc_cmd->cur_iocbq;
1176842 IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
1177843 struct ulp_bde64 *data_bde = iocb_cmd->unsli3.fcp_ext.dbde;
....@@ -1201,14 +867,15 @@
1201867
1202868 lpfc_cmd->seg_cnt = nseg;
1203869 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);
1209876 lpfc_cmd->seg_cnt = 0;
1210877 scsi_dma_unmap(scsi_cmnd);
1211
- return 1;
878
+ return 2;
1212879 }
1213880
1214881 /*
....@@ -1318,7 +985,7 @@
1318985 uint32_t *reftag, uint16_t *apptag, uint32_t new_guard)
1319986 {
1320987 struct scatterlist *sgpe; /* s/g prot entry */
1321
- struct lpfc_scsi_buf *lpfc_cmd = NULL;
988
+ struct lpfc_io_buf *lpfc_cmd = NULL;
1322989 struct scsi_dif_tuple *src = NULL;
1323990 struct lpfc_nodelist *ndlp;
1324991 struct lpfc_rport_data *rdata;
....@@ -1377,7 +1044,7 @@
13771044 if (sgpe) {
13781045 src = (struct scsi_dif_tuple *)sg_virt(sgpe);
13791046 src += blockoff;
1380
- lpfc_cmd = (struct lpfc_scsi_buf *)sc->host_scribble;
1047
+ lpfc_cmd = (struct lpfc_io_buf *)sc->host_scribble;
13811048 }
13821049
13831050 /* Should we change the Reference Tag */
....@@ -1394,7 +1061,8 @@
13941061 * inserted in middle of the IO.
13951062 */
13961063
1397
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1064
+ lpfc_printf_log(phba, KERN_ERR,
1065
+ LOG_TRACE_EVENT,
13981066 "9076 BLKGRD: Injecting reftag error: "
13991067 "write lba x%lx + x%x oldrefTag x%x\n",
14001068 (unsigned long)lba, blockoff,
....@@ -1425,7 +1093,7 @@
14251093
14261094 break;
14271095 }
1428
- /* Drop thru */
1096
+ fallthrough;
14291097 case SCSI_PROT_WRITE_INSERT:
14301098 /*
14311099 * For WRITE_INSERT, force the error
....@@ -1444,7 +1112,7 @@
14441112 }
14451113 rc = BG_ERR_TGT | BG_ERR_CHECK;
14461114
1447
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1115
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
14481116 "9078 BLKGRD: Injecting reftag error: "
14491117 "write lba x%lx\n", (unsigned long)lba);
14501118 break;
....@@ -1465,7 +1133,7 @@
14651133 }
14661134 rc = BG_ERR_INIT;
14671135
1468
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1136
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
14691137 "9077 BLKGRD: Injecting reftag error: "
14701138 "write lba x%lx\n", (unsigned long)lba);
14711139 break;
....@@ -1492,7 +1160,7 @@
14921160 }
14931161 rc = BG_ERR_INIT;
14941162
1495
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1163
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
14961164 "9079 BLKGRD: Injecting reftag error: "
14971165 "read lba x%lx\n", (unsigned long)lba);
14981166 break;
....@@ -1514,7 +1182,8 @@
15141182 * inserted in middle of the IO.
15151183 */
15161184
1517
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1185
+ lpfc_printf_log(phba, KERN_ERR,
1186
+ LOG_TRACE_EVENT,
15181187 "9080 BLKGRD: Injecting apptag error: "
15191188 "write lba x%lx + x%x oldappTag x%x\n",
15201189 (unsigned long)lba, blockoff,
....@@ -1544,7 +1213,7 @@
15441213 rc = BG_ERR_TGT | BG_ERR_CHECK;
15451214 break;
15461215 }
1547
- /* Drop thru */
1216
+ fallthrough;
15481217 case SCSI_PROT_WRITE_INSERT:
15491218 /*
15501219 * For WRITE_INSERT, force the
....@@ -1563,7 +1232,7 @@
15631232 }
15641233 rc = BG_ERR_TGT | BG_ERR_CHECK;
15651234
1566
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1235
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
15671236 "0813 BLKGRD: Injecting apptag error: "
15681237 "write lba x%lx\n", (unsigned long)lba);
15691238 break;
....@@ -1584,7 +1253,7 @@
15841253 }
15851254 rc = BG_ERR_INIT;
15861255
1587
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1256
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
15881257 "0812 BLKGRD: Injecting apptag error: "
15891258 "write lba x%lx\n", (unsigned long)lba);
15901259 break;
....@@ -1611,7 +1280,7 @@
16111280 }
16121281 rc = BG_ERR_INIT;
16131282
1614
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1283
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
16151284 "0814 BLKGRD: Injecting apptag error: "
16161285 "read lba x%lx\n", (unsigned long)lba);
16171286 break;
....@@ -1626,7 +1295,7 @@
16261295 switch (op) {
16271296 case SCSI_PROT_WRITE_PASS:
16281297 rc = BG_ERR_CHECK;
1629
- /* Drop thru */
1298
+ fallthrough;
16301299
16311300 case SCSI_PROT_WRITE_INSERT:
16321301 /*
....@@ -1646,7 +1315,7 @@
16461315 rc |= BG_ERR_TGT | BG_ERR_SWAP;
16471316 /* Signals the caller to swap CRC->CSUM */
16481317
1649
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1318
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
16501319 "0817 BLKGRD: Injecting guard error: "
16511320 "write lba x%lx\n", (unsigned long)lba);
16521321 break;
....@@ -1668,7 +1337,7 @@
16681337 rc = BG_ERR_INIT | BG_ERR_SWAP;
16691338 /* Signals the caller to swap CRC->CSUM */
16701339
1671
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1340
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
16721341 "0816 BLKGRD: Injecting guard error: "
16731342 "write lba x%lx\n", (unsigned long)lba);
16741343 break;
....@@ -1696,7 +1365,7 @@
16961365 rc = BG_ERR_INIT | BG_ERR_SWAP;
16971366 /* Signals the caller to swap CRC->CSUM */
16981367
1699
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1368
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
17001369 "0818 BLKGRD: Injecting guard error: "
17011370 "read lba x%lx\n", (unsigned long)lba);
17021371 }
....@@ -1746,7 +1415,7 @@
17461415
17471416 case SCSI_PROT_NORMAL:
17481417 default:
1749
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1418
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
17501419 "9063 BLKGRD: Bad op/guard:%d/IP combination\n",
17511420 scsi_get_prot_op(sc));
17521421 ret = 1;
....@@ -1775,7 +1444,7 @@
17751444
17761445 case SCSI_PROT_NORMAL:
17771446 default:
1778
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1447
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
17791448 "9075 BLKGRD: Bad op/guard:%d/CRC combination\n",
17801449 scsi_get_prot_op(sc));
17811450 ret = 1;
....@@ -2061,8 +1730,8 @@
20611730 sgde = scsi_sglist(sc);
20621731
20631732 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",
20661735 sgpe, sgde);
20671736 return 0;
20681737 }
....@@ -2173,7 +1842,7 @@
21731842 return num_bde + 1;
21741843
21751844 if (!sgde) {
2176
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1845
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
21771846 "9065 BLKGRD:%s Invalid data segment\n",
21781847 __func__);
21791848 return 0;
....@@ -2236,8 +1905,8 @@
22361905 reftag += protgrp_blks;
22371906 } else {
22381907 /* 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__);
22411910 }
22421911
22431912 } while (!alldone);
....@@ -2277,7 +1946,8 @@
22771946 **/
22781947 static int
22791948 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)
22811951 {
22821952 struct scatterlist *sgde = NULL; /* s/g data entry */
22831953 struct sli4_sge_diseed *diseed = NULL;
....@@ -2291,6 +1961,9 @@
22911961 uint32_t checking = 1;
22921962 uint32_t dma_len;
22931963 uint32_t dma_offset = 0;
1964
+ struct sli4_hybrid_sgl *sgl_xtra = NULL;
1965
+ int j;
1966
+ bool lsp_just_set = false;
22941967
22951968 status = lpfc_sc_to_bg_opcodes(phba, sc, &txop, &rxop);
22961969 if (status)
....@@ -2350,23 +2023,64 @@
23502023 sgl++;
23512024
23522025 /* 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;
23642031
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);
23672037
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
+
23702084 }
23712085
23722086 out:
....@@ -2412,7 +2126,8 @@
24122126 **/
24132127 static int
24142128 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)
24162131 {
24172132 struct scatterlist *sgde = NULL; /* s/g data entry */
24182133 struct scatterlist *sgpe = NULL; /* s/g prot entry */
....@@ -2434,14 +2149,15 @@
24342149 #endif
24352150 uint32_t checking = 1;
24362151 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;
24382154
24392155 sgpe = scsi_prot_sglist(sc);
24402156 sgde = scsi_sglist(sc);
24412157
24422158 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",
24452161 sgpe, sgde);
24462162 return 0;
24472163 }
....@@ -2467,8 +2183,36 @@
24672183 split_offset = 0;
24682184 do {
24692185 /* 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))
24712188 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
+ }
24722216
24732217 /* setup DISEED with what we have */
24742218 diseed = (struct sli4_sge_diseed *) sgl;
....@@ -2516,7 +2260,9 @@
25162260
25172261 /* advance sgl and increment bde count */
25182262 num_sge++;
2263
+
25192264 sgl++;
2265
+ j++;
25202266
25212267 /* setup the first BDE that points to protection buffer */
25222268 protphysaddr = sg_dma_address(sgpe) + protgroup_offset;
....@@ -2531,6 +2277,7 @@
25312277 sgl->addr_hi = le32_to_cpu(putPaddrHigh(protphysaddr));
25322278 sgl->addr_lo = le32_to_cpu(putPaddrLow(protphysaddr));
25332279 sgl->word2 = cpu_to_le32(sgl->word2);
2280
+ sgl->sge_len = 0;
25342281
25352282 protgrp_blks = protgroup_len / 8;
25362283 protgrp_bytes = protgrp_blks * blksize;
....@@ -2551,78 +2298,124 @@
25512298 /* setup SGE's for data blocks associated with DIF data */
25522299 pgdone = 0;
25532300 subtotal = 0; /* total bytes processed for current prot grp */
2301
+
2302
+ sgl++;
2303
+ j++;
2304
+
25542305 while (!pgdone) {
25552306 /* 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)
25572309 return num_sge + 1;
25582310
25592311 if (!sgde) {
2560
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
2312
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
25612313 "9086 BLKGRD:%s Invalid data segment\n",
25622314 __func__);
25632315 return 0;
25642316 }
2565
- sgl++;
2566
- dataphysaddr = sg_dma_address(sgde) + split_offset;
25672317
2568
- remainder = sg_dma_len(sgde) - split_offset;
2318
+ if (!((j + 1) % phba->border_sge_num)) {
2319
+ sgl->word2 = 0;
25692320
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);
25742324
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;
25772342 } 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++;
25812392 }
25822393
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++;
26022395 }
26032396
26042397 if (protgroup_offset) {
26052398 /* update the reference tag */
26062399 reftag += protgrp_blks;
2607
- sgl++;
26082400 continue;
26092401 }
26102402
26112403 /* are we done ? */
26122404 if (curr_prot == protcnt) {
2405
+ /* mark the last SGL */
2406
+ sgl--;
26132407 bf_set(lpfc_sli4_sge_last, sgl, 1);
26142408 alldone = 1;
26152409 } else if (curr_prot < protcnt) {
26162410 /* advance to next prot buffer */
26172411 sgpe = sg_next(sgpe);
2618
- sgl++;
26192412
26202413 /* update the reference tag */
26212414 reftag += protgrp_blks;
26222415 } else {
26232416 /* 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__);
26262419 }
26272420
26282421 } while (!alldone);
....@@ -2662,7 +2455,7 @@
26622455 break;
26632456 default:
26642457 if (phba)
2665
- lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
2458
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
26662459 "9021 Unsupported protection op:%d\n",
26672460 op);
26682461 break;
....@@ -2682,7 +2475,7 @@
26822475 **/
26832476 static int
26842477 lpfc_bg_scsi_adjust_dl(struct lpfc_hba *phba,
2685
- struct lpfc_scsi_buf *lpfc_cmd)
2478
+ struct lpfc_io_buf *lpfc_cmd)
26862479 {
26872480 struct scsi_cmnd *sc = lpfc_cmd->pCmd;
26882481 int fcpdl;
....@@ -2718,20 +2511,24 @@
27182511 *
27192512 * This is the protection/DIF aware version of
27202513 * 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.
27222518 **/
27232519 static int
27242520 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)
27262522 {
27272523 struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd;
27282524 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;
27302526 IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
27312527 uint32_t num_bde = 0;
27322528 int datasegcnt, protsegcnt, datadir = scsi_cmnd->sc_data_direction;
27332529 int prot_group_type = 0;
27342530 int fcpdl;
2531
+ int ret = 1;
27352532 struct lpfc_vport *vport = phba->pport;
27362533
27372534 /*
....@@ -2755,8 +2552,11 @@
27552552 lpfc_cmd->seg_cnt = datasegcnt;
27562553
27572554 /* 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;
27592558 goto err;
2559
+ }
27602560
27612561 prot_group_type = lpfc_prot_group_type(phba, scsi_cmnd);
27622562
....@@ -2764,14 +2564,18 @@
27642564 case LPFC_PG_TYPE_NO_DIF:
27652565
27662566 /* 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;
27682569 goto err;
2570
+ }
27692571
27702572 num_bde = lpfc_bg_setup_bpl(phba, scsi_cmnd, bpl,
27712573 datasegcnt);
27722574 /* we should have 2 or more entries in buffer list */
2773
- if (num_bde < 2)
2575
+ if (num_bde < 2) {
2576
+ ret = 2;
27742577 goto err;
2578
+ }
27752579 break;
27762580
27772581 case LPFC_PG_TYPE_DIF_BUF:
....@@ -2795,15 +2599,19 @@
27952599 * protection data segment.
27962600 */
27972601 if ((lpfc_cmd->prot_seg_cnt * 4) >
2798
- (phba->cfg_total_seg_cnt - 2))
2602
+ (phba->cfg_total_seg_cnt - 2)) {
2603
+ ret = 2;
27992604 goto err;
2605
+ }
28002606
28012607 num_bde = lpfc_bg_setup_bpl_prot(phba, scsi_cmnd, bpl,
28022608 datasegcnt, protsegcnt);
28032609 /* we should have 3 or more entries in buffer list */
28042610 if ((num_bde < 3) ||
2805
- (num_bde > phba->cfg_total_seg_cnt))
2611
+ (num_bde > phba->cfg_total_seg_cnt)) {
2612
+ ret = 2;
28062613 goto err;
2614
+ }
28072615 break;
28082616
28092617 case LPFC_PG_TYPE_INVALID:
....@@ -2811,10 +2619,10 @@
28112619 scsi_dma_unmap(scsi_cmnd);
28122620 lpfc_cmd->seg_cnt = 0;
28132621
2814
- lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
2622
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
28152623 "9022 Unexpected protection group %i\n",
28162624 prot_group_type);
2817
- return 1;
2625
+ return 2;
28182626 }
28192627 }
28202628
....@@ -2855,7 +2663,7 @@
28552663 scsi_prot_sg_count(scsi_cmnd),
28562664 scsi_cmnd->sc_data_direction);
28572665
2858
- lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
2666
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
28592667 "9023 Cannot setup S/G List for HBA"
28602668 "IO segs %d/%d BPL %d SCSI %d: %d %d\n",
28612669 lpfc_cmd->seg_cnt, lpfc_cmd->prot_seg_cnt,
....@@ -2864,7 +2672,7 @@
28642672
28652673 lpfc_cmd->seg_cnt = 0;
28662674 lpfc_cmd->prot_seg_cnt = 0;
2867
- return 1;
2675
+ return ret;
28682676 }
28692677
28702678 /*
....@@ -2902,7 +2710,7 @@
29022710 * what type of T10-DIF error occurred.
29032711 */
29042712 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)
29062714 {
29072715 struct scatterlist *sgpe; /* s/g prot entry */
29082716 struct scatterlist *sgde; /* s/g data entry */
....@@ -3087,8 +2895,8 @@
30872895 * -1 - Internal error (bad profile, ...etc)
30882896 */
30892897 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)
30922900 {
30932901 struct scsi_cmnd *cmd = lpfc_cmd->pCmd;
30942902 struct sli3_bg_fields *bgf = &pIocbOut->iocb.unsli3.sli3_bg;
....@@ -3096,26 +2904,6 @@
30962904 uint32_t bghm = bgf->bghm;
30972905 uint32_t bgstat = bgf->bgstat;
30982906 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);
31192907
31202908 if (lpfc_bgs_get_invalid_prof(bgstat)) {
31212909 cmd->result = DID_ERROR << 16;
....@@ -3250,24 +3038,27 @@
32503038 * field of @lpfc_cmd for device with SLI-4 interface spec.
32513039 *
32523040 * Return codes:
3253
- * 1 - Error
3041
+ * 2 - Error - Do not retry
3042
+ * 1 - Error - Retry
32543043 * 0 - Success
32553044 **/
32563045 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)
32583047 {
32593048 struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd;
32603049 struct scatterlist *sgel = NULL;
32613050 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;
32633052 struct sli4_sge *first_data_sgl;
32643053 IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
32653054 dma_addr_t physaddr;
32663055 uint32_t num_bde = 0;
32673056 uint32_t dma_len;
32683057 uint32_t dma_offset = 0;
3269
- int nseg;
3058
+ int nseg, i, j;
32703059 struct ulp_bde64 *bde;
3060
+ bool lsp_just_set = false;
3061
+ struct sli4_hybrid_sgl *sgl_xtra = NULL;
32713062
32723063 /*
32733064 * There are three possibilities here - use scatter-gather segment, use
....@@ -3294,15 +3085,18 @@
32943085 sgl += 1;
32953086 first_data_sgl = sgl;
32963087 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);
33033097 lpfc_cmd->seg_cnt = 0;
33043098 scsi_dma_unmap(scsi_cmnd);
3305
- return 1;
3099
+ return 2;
33063100 }
33073101
33083102 /*
....@@ -3314,22 +3108,80 @@
33143108 * the IOCB. If it can't then the BDEs get added to a BPL as it
33153109 * does for SLI-2 mode.
33163110 */
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) {
33243118 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 {
33263122 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++;
33333185 }
33343186 /*
33353187 * Setup the first Payload BDE. For FCoE we just key off
....@@ -3386,6 +3238,7 @@
33863238 lpfc_cmd->cur_iocbq.priority = ((struct lpfc_device_data *)
33873239 scsi_cmnd->device->hostdata)->priority;
33883240 }
3241
+
33893242 return 0;
33903243 }
33913244
....@@ -3397,19 +3250,24 @@
33973250 * This is the protection/DIF aware version of
33983251 * lpfc_scsi_prep_dma_buf(). It may be a good idea to combine the
33993252 * 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
34003257 **/
34013258 static int
34023259 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)
34043261 {
34053262 struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd;
34063263 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);
34083265 IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
34093266 uint32_t num_sge = 0;
34103267 int datasegcnt, protsegcnt, datadir = scsi_cmnd->sc_data_direction;
34113268 int prot_group_type = 0;
34123269 int fcpdl;
3270
+ int ret = 1;
34133271 struct lpfc_vport *vport = phba->pport;
34143272
34153273 /*
....@@ -3439,23 +3297,33 @@
34393297 lpfc_cmd->seg_cnt = datasegcnt;
34403298
34413299 /* 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;
34433304 goto err;
3305
+ }
34443306
34453307 prot_group_type = lpfc_prot_group_type(phba, scsi_cmnd);
34463308
34473309 switch (prot_group_type) {
34483310 case LPFC_PG_TYPE_NO_DIF:
34493311 /* 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;
34513316 goto err;
3317
+ }
34523318
34533319 num_sge = lpfc_bg_setup_sgl(phba, scsi_cmnd, sgl,
3454
- datasegcnt);
3320
+ datasegcnt, lpfc_cmd);
34553321
34563322 /* we should have 2 or more entries in buffer list */
3457
- if (num_sge < 2)
3323
+ if (num_sge < 2) {
3324
+ ret = 2;
34583325 goto err;
3326
+ }
34593327 break;
34603328
34613329 case LPFC_PG_TYPE_DIF_BUF:
....@@ -3477,17 +3345,23 @@
34773345 * There is a minimun of 3 SGEs used for every
34783346 * protection data segment.
34793347 */
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;
34823352 goto err;
3353
+ }
34833354
34843355 num_sge = lpfc_bg_setup_sgl_prot(phba, scsi_cmnd, sgl,
3485
- datasegcnt, protsegcnt);
3356
+ datasegcnt, protsegcnt, lpfc_cmd);
34863357
34873358 /* 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;
34903363 goto err;
3364
+ }
34913365 break;
34923366
34933367 case LPFC_PG_TYPE_INVALID:
....@@ -3495,10 +3369,10 @@
34953369 scsi_dma_unmap(scsi_cmnd);
34963370 lpfc_cmd->seg_cnt = 0;
34973371
3498
- lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
3372
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
34993373 "9083 Unexpected protection group %i\n",
35003374 prot_group_type);
3501
- return 1;
3375
+ return 2;
35023376 }
35033377 }
35043378
....@@ -3551,7 +3425,7 @@
35513425 scsi_prot_sg_count(scsi_cmnd),
35523426 scsi_cmnd->sc_data_direction);
35533427
3554
- lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
3428
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
35553429 "9084 Cannot setup S/G List for HBA"
35563430 "IO segs %d/%d SGL %d SCSI %d: %d %d\n",
35573431 lpfc_cmd->seg_cnt, lpfc_cmd->prot_seg_cnt,
....@@ -3560,7 +3434,7 @@
35603434
35613435 lpfc_cmd->seg_cnt = 0;
35623436 lpfc_cmd->prot_seg_cnt = 0;
3563
- return 1;
3437
+ return ret;
35643438 }
35653439
35663440 /**
....@@ -3576,7 +3450,7 @@
35763450 * 0 - Success
35773451 **/
35783452 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)
35803454 {
35813455 return phba->lpfc_scsi_prep_dma_buf(phba, lpfc_cmd);
35823456 }
....@@ -3595,7 +3469,7 @@
35953469 * 0 - Success
35963470 **/
35973471 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)
35993473 {
36003474 return phba->lpfc_bg_scsi_prep_dma_buf(phba, lpfc_cmd);
36013475 }
....@@ -3612,7 +3486,7 @@
36123486 **/
36133487 static void
36143488 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) {
36163490 struct scsi_cmnd *cmnd = lpfc_cmd->pCmd;
36173491 struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp;
36183492 uint32_t resp_info = fcprsp->rspStatus2;
....@@ -3704,7 +3578,7 @@
37043578 * field of @lpfc_cmd for device with SLI-3 interface spec.
37053579 **/
37063580 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)
37083582 {
37093583 /*
37103584 * There are only two special cases to consider. (1) the scsi command
....@@ -3723,7 +3597,7 @@
37233597 /**
37243598 * lpfc_handler_fcp_err - FCP response handler
37253599 * @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.
37273601 * @rsp_iocb: The response IOCB which contains FCP error.
37283602 *
37293603 * This routine is called to process response IOCB with status field
....@@ -3731,7 +3605,7 @@
37313605 * based upon SCSI and FCP error.
37323606 **/
37333607 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,
37353609 struct lpfc_iocbq *rsp_iocb)
37363610 {
37373611 struct lpfc_hba *phba = vport->phba;
....@@ -3761,17 +3635,17 @@
37613635 if (resp_info & RSP_LEN_VALID) {
37623636 rsplen = be32_to_cpu(fcprsp->rspRspLen);
37633637 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);
37703644 host_status = DID_ERROR;
37713645 goto out;
37723646 }
37733647 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,
37753649 "2757 Protocol failure detected during "
37763650 "processing of FCP I/O op: "
37773651 "tgt x%x lun x%llx cmnd x%x rspInfo3 x%x\n",
....@@ -3910,49 +3784,6 @@
39103784 }
39113785
39123786 /**
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
-/**
39563787 * lpfc_scsi_cmd_iocb_cmpl - Scsi cmnd IOCB completion routine
39573788 * @phba: The Hba for which this call is being executed.
39583789 * @pIocbIn: The command IOCBQ for the scsi cmnd.
....@@ -3966,8 +3797,8 @@
39663797 lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
39673798 struct lpfc_iocbq *pIocbOut)
39683799 {
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;
39713802 struct lpfc_vport *vport = pIocbIn->vport;
39723803 struct lpfc_rport_data *rdata = lpfc_cmd->rdata;
39733804 struct lpfc_nodelist *pnode = rdata->pnode;
....@@ -3975,20 +3806,38 @@
39753806 unsigned long flags;
39763807 struct lpfc_fast_path_event *fast_path_evt;
39773808 struct Scsi_Host *shost;
3809
+ int idx;
39783810 uint32_t logit = LOG_FCP;
39793811
3980
- atomic_inc(&phba->fc4ScsiIoCmpls);
3812
+ /* Guard against abort handler being called at same time */
3813
+ spin_lock(&lpfc_cmd->buf_lock);
39813814
39823815 /* Sanity check on return of outstanding command */
39833816 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);
39853821 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
39863832 shost = cmd->device->host;
39873833
39883834 lpfc_cmd->result = (pIocbOut->iocb.un.ulpWord[4] & IOERR_PARAM_MASK);
39893835 lpfc_cmd->status = pIocbOut->iocb.ulpStatus;
39903836 /* 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;
39923841
39933842 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
39943843 if (lpfc_cmd->prot_data_type) {
....@@ -4022,7 +3871,7 @@
40223871 }
40233872 #endif
40243873
4025
- if (lpfc_cmd->status) {
3874
+ if (unlikely(lpfc_cmd->status)) {
40263875 if (lpfc_cmd->status == IOSTAT_LOCAL_REJECT &&
40273876 (lpfc_cmd->result & IOERR_DRVR_MASK))
40283877 lpfc_cmd->status = IOSTAT_DRIVER_REJECT;
....@@ -4131,7 +3980,7 @@
41313980 lpfc_cmd->cur_iocbq.sli4_lxritag,
41323981 0, 0);
41333982 }
4134
- /* else: fall through */
3983
+ fallthrough;
41353984 default:
41363985 cmd->result = DID_ERROR << 16;
41373986 break;
....@@ -4148,14 +3997,14 @@
41483997 uint32_t *lp = (uint32_t *)cmd->sense_buffer;
41493998
41503999 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 "
41524001 "x%x SNS x%x x%x Data: x%x x%x\n",
41534002 cmd->device->id, cmd->device->lun, cmd,
41544003 cmd->result, *lp, *(lp + 3), cmd->retries,
41554004 scsi_get_resid(cmd));
41564005 }
41574006
4158
- lpfc_update_stats(phba, lpfc_cmd);
4007
+ lpfc_update_stats(vport, lpfc_cmd);
41594008 if (vport->cfg_max_scsicmpl_time &&
41604009 time_after(jiffies, lpfc_cmd->start_time +
41614010 msecs_to_jiffies(vport->cfg_max_scsicmpl_time))) {
....@@ -4176,29 +4025,29 @@
41764025 }
41774026 lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd);
41784027
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);
41904030
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
41914039 /* The sdev is not guaranteed to be valid post scsi_done upcall. */
41924040 cmd->scsi_done(cmd);
41934041
41944042 /*
4195
- * If there is a thread waiting for command completion
4043
+ * If there is an abort thread waiting for command completion
41964044 * wake up the thread.
41974045 */
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;
41994048 if (lpfc_cmd->waitq)
42004049 wake_up(lpfc_cmd->waitq);
4201
- spin_unlock_irqrestore(shost->host_lock, flags);
4050
+ spin_unlock(&lpfc_cmd->buf_lock);
42024051
42034052 lpfc_release_scsi_buf(phba, lpfc_cmd);
42044053 }
....@@ -4231,7 +4080,7 @@
42314080 * to transfer for device with SLI3 interface spec.
42324081 **/
42334082 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,
42354084 struct lpfc_nodelist *pnode)
42364085 {
42374086 struct lpfc_hba *phba = vport->phba;
....@@ -4239,7 +4088,9 @@
42394088 struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd;
42404089 IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
42414090 struct lpfc_iocbq *piocbq = &(lpfc_cmd->cur_iocbq);
4091
+ struct lpfc_sli4_hdw_queue *hdwq = NULL;
42424092 int datadir = scsi_cmnd->sc_data_direction;
4093
+ int idx;
42434094 uint8_t *ptr;
42444095 bool sli4;
42454096 uint32_t fcpdl;
....@@ -4265,6 +4116,9 @@
42654116
42664117 sli4 = (phba->sli_rev == LPFC_SLI_REV4);
42674118 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];
42684122
42694123 /*
42704124 * There are three possibilities here - use scatter-gather segment, use
....@@ -4286,19 +4140,22 @@
42864140 vport->cfg_first_burst_size;
42874141 }
42884142 fcp_cmnd->fcpCntl3 = WRITE_DATA;
4289
- atomic_inc(&phba->fc4ScsiOutputRequests);
4143
+ if (hdwq)
4144
+ hdwq->scsi_cstat.output_requests++;
42904145 } else {
42914146 iocb_cmd->ulpCommand = CMD_FCP_IREAD64_CR;
42924147 iocb_cmd->ulpPU = PARM_READ_CHECK;
42934148 fcp_cmnd->fcpCntl3 = READ_DATA;
4294
- atomic_inc(&phba->fc4ScsiInputRequests);
4149
+ if (hdwq)
4150
+ hdwq->scsi_cstat.input_requests++;
42954151 }
42964152 } else {
42974153 iocb_cmd->ulpCommand = CMD_FCP_ICMND64_CR;
42984154 iocb_cmd->un.fcpi.fcpi_parm = 0;
42994155 iocb_cmd->ulpPU = 0;
43004156 fcp_cmnd->fcpCntl3 = 0;
4301
- atomic_inc(&phba->fc4ScsiControlRequests);
4157
+ if (hdwq)
4158
+ hdwq->scsi_cstat.control_requests++;
43024159 }
43034160 if (phba->sli_rev == 3 &&
43044161 !(phba->sli3_options & LPFC_SLI3_BG_ENABLED))
....@@ -4326,7 +4183,7 @@
43264183 /**
43274184 * lpfc_scsi_prep_task_mgmt_cmd - Convert SLI3 scsi TM cmd to FCP info unit
43284185 * @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.
43304187 * @lun: Logical unit number.
43314188 * @task_mgmt_cmd: SCSI task management command.
43324189 *
....@@ -4339,7 +4196,7 @@
43394196 **/
43404197 static int
43414198 lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_vport *vport,
4342
- struct lpfc_scsi_buf *lpfc_cmd,
4199
+ struct lpfc_io_buf *lpfc_cmd,
43434200 uint64_t lun,
43444201 uint8_t task_mgmt_cmd)
43454202 {
....@@ -4411,21 +4268,19 @@
44114268
44124269 switch (dev_grp) {
44134270 case LPFC_PCI_DEV_LP:
4414
- phba->lpfc_new_scsi_buf = lpfc_new_scsi_buf_s3;
44154271 phba->lpfc_scsi_prep_dma_buf = lpfc_scsi_prep_dma_buf_s3;
44164272 phba->lpfc_bg_scsi_prep_dma_buf = lpfc_bg_scsi_prep_dma_buf_s3;
44174273 phba->lpfc_release_scsi_buf = lpfc_release_scsi_buf_s3;
44184274 phba->lpfc_get_scsi_buf = lpfc_get_scsi_buf_s3;
44194275 break;
44204276 case LPFC_PCI_DEV_OC:
4421
- phba->lpfc_new_scsi_buf = lpfc_new_scsi_buf_s4;
44224277 phba->lpfc_scsi_prep_dma_buf = lpfc_scsi_prep_dma_buf_s4;
44234278 phba->lpfc_bg_scsi_prep_dma_buf = lpfc_bg_scsi_prep_dma_buf_s4;
44244279 phba->lpfc_release_scsi_buf = lpfc_release_scsi_buf_s4;
44254280 phba->lpfc_get_scsi_buf = lpfc_get_scsi_buf_s4;
44264281 break;
44274282 default:
4428
- lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4283
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
44294284 "1418 Invalid HBA PCI-device group: 0x%x\n",
44304285 dev_grp);
44314286 return -ENODEV;
....@@ -4450,11 +4305,71 @@
44504305 struct lpfc_iocbq *cmdiocbq,
44514306 struct lpfc_iocbq *rspiocbq)
44524307 {
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;
44554310 if (lpfc_cmd)
44564311 lpfc_release_scsi_buf(phba, lpfc_cmd);
44574312 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;
44584373 }
44594374
44604375 /**
....@@ -4471,32 +4386,53 @@
44714386 {
44724387 struct lpfc_vport *vport = (struct lpfc_vport *) host->hostdata;
44734388 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};
44764392
4477
- memset(lpfcinfobuf,0,384);
4393
+ memset(lpfcinfobuf, 0, sizeof(lpfcinfobuf));
44784394 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 */
44884411 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;
44934416 }
4494
- len = strlen(lpfcinfobuf);
4417
+
4418
+ /* Link Speed */
44954419 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
+ }
44994433 }
4434
+
4435
+buffer_done:
45004436 return lpfcinfobuf;
45014437 }
45024438
....@@ -4569,9 +4505,15 @@
45694505 struct lpfc_hba *phba = vport->phba;
45704506 struct lpfc_rport_data *rdata;
45714507 struct lpfc_nodelist *ndlp;
4572
- struct lpfc_scsi_buf *lpfc_cmd;
4508
+ struct lpfc_io_buf *lpfc_cmd;
45734509 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
45754517
45764518 rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
45774519
....@@ -4589,7 +4531,7 @@
45894531 if ((scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) &&
45904532 (!(phba->sli3_options & LPFC_SLI3_BG_ENABLED))) {
45914533
4592
- lpfc_printf_log(phba, KERN_ERR, LOG_BG,
4534
+ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
45934535 "9058 BLKGRD: ERROR: rcvd protected cmd:%02x"
45944536 " op:%02x str=%s without registering for"
45954537 " BlockGuard - Rejecting command\n",
....@@ -4635,7 +4577,7 @@
46354577 }
46364578 }
46374579
4638
- lpfc_cmd = lpfc_get_scsi_buf(phba, ndlp);
4580
+ lpfc_cmd = lpfc_get_scsi_buf(phba, ndlp, cmnd);
46394581 if (lpfc_cmd == NULL) {
46404582 lpfc_rampdown_queue_depth(phba);
46414583
....@@ -4652,8 +4594,6 @@
46524594 lpfc_cmd->pCmd = cmnd;
46534595 lpfc_cmd->rdata = rdata;
46544596 lpfc_cmd->ndlp = ndlp;
4655
- lpfc_cmd->timeout = 0;
4656
- lpfc_cmd->start_time = jiffies;
46574597 cmnd->host_scribble = (unsigned char *)lpfc_cmd;
46584598
46594599 if (scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) {
....@@ -4683,13 +4623,31 @@
46834623 err = lpfc_scsi_prep_dma_buf(phba, lpfc_cmd);
46844624 }
46854625
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
+ }
46874631 goto out_host_busy_free_buf;
4632
+ }
46884633
46894634 lpfc_scsi_prep_cmnd(vport, lpfc_cmd, ndlp);
46904635
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
46914640 err = lpfc_sli_issue_iocb(phba, LPFC_FCP_RING,
46924641 &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
46934651 if (err) {
46944652 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
46954653 "3376 FCP could not issue IOCB err %x"
....@@ -4708,16 +4666,6 @@
47084666 (uint32_t)
47094667 (cmnd->request->timeout / 1000));
47104668
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
- }
47214669 goto out_host_busy_free_buf;
47224670 }
47234671 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
....@@ -4728,16 +4676,35 @@
47284676 lpfc_poll_rearm_timer(phba);
47294677 }
47304678
4679
+ if (phba->cfg_xri_rebalancing)
4680
+ lpfc_keep_pvt_pool_above_lowwm(phba, lpfc_cmd->hdwq_no);
4681
+
47314682 return 0;
47324683
47334684 out_host_busy_free_buf:
4685
+ idx = lpfc_cmd->hdwq_no;
47344686 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
+ }
47354699 lpfc_release_scsi_buf(phba, lpfc_cmd);
47364700 out_host_busy:
47374701 return SCSI_MLQUEUE_HOST_BUSY;
47384702
47394703 out_tgt_busy:
47404704 return SCSI_MLQUEUE_TARGET_BUSY;
4705
+
4706
+ out_fail_command_release_buf:
4707
+ lpfc_release_scsi_buf(phba, lpfc_cmd);
47414708
47424709 out_fail_command:
47434710 cmnd->scsi_done(cmnd);
....@@ -4763,7 +4730,7 @@
47634730 struct lpfc_hba *phba = vport->phba;
47644731 struct lpfc_iocbq *iocb;
47654732 struct lpfc_iocbq *abtsiocb;
4766
- struct lpfc_scsi_buf *lpfc_cmd;
4733
+ struct lpfc_io_buf *lpfc_cmd;
47674734 IOCB_t *cmd, *icmd;
47684735 int ret = SUCCESS, status = 0;
47694736 struct lpfc_sli_ring *pring_s4 = NULL;
....@@ -4775,65 +4742,59 @@
47754742 if (status != 0 && status != SUCCESS)
47764743 return status;
47774744
4745
+ lpfc_cmd = (struct lpfc_io_buf *)cmnd->host_scribble;
4746
+ if (!lpfc_cmd)
4747
+ return ret;
4748
+
47784749 spin_lock_irqsave(&phba->hbalock, flags);
47794750 /* 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) {
47824752 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
47834753 "3168 SCSI Layer abort requested I/O has been "
47844754 "flushed by LLD.\n");
4785
- return FAILED;
4755
+ ret = FAILED;
4756
+ goto out_unlock;
47864757 }
47874758
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) {
47914763 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
47924764 "2873 SCSI Layer I/O Abort Request IO CMPL Status "
47934765 "x%x ID %d LUN %llu\n",
47944766 SUCCESS, cmnd->device->id, cmnd->device->lun);
4795
- return SUCCESS;
4767
+ goto out_unlock_buf;
47964768 }
47974769
47984770 iocb = &lpfc_cmd->cur_iocbq;
47994771 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;
48084773 if (!pring_s4) {
48094774 ret = FAILED;
4810
- goto out_unlock;
4775
+ goto out_unlock_buf;
48114776 }
48124777 spin_lock(&pring_s4->ring_lock);
48134778 }
48144779 /* the command is in process of being cancelled */
48154780 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);
48194781 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
48204782 "3169 SCSI Layer abort requested I/O has been "
48214783 "cancelled by LLD.\n");
4822
- return FAILED;
4784
+ ret = FAILED;
4785
+ goto out_unlock_ring;
48234786 }
48244787 /*
4825
- * If pCmd field of the corresponding lpfc_scsi_buf structure
4788
+ * If pCmd field of the corresponding lpfc_io_buf structure
48264789 * points to a different SCSI command, then the driver has
48274790 * already completed this command, but the midlayer did not
48284791 * see the completion before the eh fired. Just return SUCCESS.
48294792 */
48304793 if (lpfc_cmd->pCmd != cmnd) {
4831
- if (phba->sli_rev == LPFC_SLI_REV4)
4832
- spin_unlock(&pring_s4->ring_lock);
48334794 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
48344795 "3170 SCSI Layer abort requested I/O has been "
48354796 "completed by LLD.\n");
4836
- goto out_unlock;
4797
+ goto out_unlock_ring;
48374798 }
48384799
48394800 BUG_ON(iocb->context1 != lpfc_cmd);
....@@ -4844,6 +4805,7 @@
48444805 "3389 SCSI Layer I/O Abort Request is pending\n");
48454806 if (phba->sli_rev == LPFC_SLI_REV4)
48464807 spin_unlock(&pring_s4->ring_lock);
4808
+ spin_unlock(&lpfc_cmd->buf_lock);
48474809 spin_unlock_irqrestore(&phba->hbalock, flags);
48484810 goto wait_for_cmpl;
48494811 }
....@@ -4851,9 +4813,7 @@
48514813 abtsiocb = __lpfc_sli_get_iocbq(phba);
48524814 if (abtsiocb == NULL) {
48534815 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;
48574817 }
48584818
48594819 /* Indicate the IO is being aborted by the driver. */
....@@ -4900,26 +4860,21 @@
49004860 ret_val = __lpfc_sli_issue_iocb(phba, LPFC_FCP_RING,
49014861 abtsiocb, 0);
49024862 }
4903
- /* no longer need the lock after this point */
4904
- spin_unlock_irqrestore(&phba->hbalock, flags);
4905
-
49064863
49074864 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);
49124865 /* Indicate the IO is not being aborted by the driver. */
49134866 iocb->iocb_flag &= ~LPFC_DRIVER_ABORTED;
49144867 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);
49194870 lpfc_sli_release_iocbq(phba, abtsiocb);
49204871 ret = FAILED;
49214872 goto out;
49224873 }
4874
+
4875
+ /* no longer need the lock after this point */
4876
+ spin_unlock(&lpfc_cmd->buf_lock);
4877
+ spin_unlock_irqrestore(&phba->hbalock, flags);
49234878
49244879 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
49254880 lpfc_sli_handle_fast_ring_event(phba,
....@@ -4931,21 +4886,28 @@
49314886 (lpfc_cmd->pCmd != cmnd),
49324887 msecs_to_jiffies(2*vport->cfg_devloss_tmo*1000));
49334888
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);
49374890
49384891 if (lpfc_cmd->pCmd == cmnd) {
49394892 ret = FAILED;
4940
- lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
4893
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
49414894 "0748 abort handler timed out waiting "
49424895 "for aborting I/O (xri:x%x) to complete: "
49434896 "ret %#x, ID %d, LUN %llu\n",
49444897 iocb->sli4_xritag, ret,
49454898 cmnd->device->id, cmnd->device->lun);
49464899 }
4900
+
4901
+ lpfc_cmd->waitq = NULL;
4902
+
4903
+ spin_unlock(&lpfc_cmd->buf_lock);
49474904 goto out;
49484905
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);
49494911 out_unlock:
49504912 spin_unlock_irqrestore(&phba->hbalock, flags);
49514913 out:
....@@ -4983,7 +4945,7 @@
49834945 /**
49844946 * lpfc_check_fcp_rsp - check the returned fcp_rsp to see if task failed
49854947 * @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.
49874949 *
49884950 * This routine checks the FCP RSP INFO to see if the tsk mgmt command succeded
49894951 *
....@@ -4992,7 +4954,7 @@
49924954 * 0x2002 - Success
49934955 **/
49944956 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)
49964958 {
49974959 struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp;
49984960 uint32_t rsp_info;
....@@ -5017,7 +4979,12 @@
50174979 rsp_info,
50184980 rsp_len, rsp_info_code);
50194981
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))) {
50214988 switch (rsp_info_code) {
50224989 case RSP_NO_FAILURE:
50234990 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
....@@ -5067,7 +5034,7 @@
50675034 uint8_t task_mgmt_cmd)
50685035 {
50695036 struct lpfc_hba *phba = vport->phba;
5070
- struct lpfc_scsi_buf *lpfc_cmd;
5037
+ struct lpfc_io_buf *lpfc_cmd;
50715038 struct lpfc_iocbq *iocbq;
50725039 struct lpfc_iocbq *iocbqrsp;
50735040 struct lpfc_rport_data *rdata;
....@@ -5080,7 +5047,7 @@
50805047 return FAILED;
50815048 pnode = rdata->pnode;
50825049
5083
- lpfc_cmd = lpfc_get_scsi_buf(phba, pnode);
5050
+ lpfc_cmd = lpfc_get_scsi_buf(phba, pnode, NULL);
50845051 if (lpfc_cmd == NULL)
50855052 return FAILED;
50865053 lpfc_cmd->timeout = phba->cfg_task_mgmt_tmo;
....@@ -5116,7 +5083,7 @@
51165083 (iocbqrsp->iocb.ulpStatus != IOSTAT_SUCCESS)) {
51175084 if (status != IOCB_SUCCESS ||
51185085 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,
51205087 "0727 TMF %s to TGT %d LUN %llu "
51215088 "failed (%d, %d) iocb_flag x%x\n",
51225089 lpfc_taskmgmt_name(task_mgmt_cmd),
....@@ -5170,7 +5137,7 @@
51705137 rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
51715138 if (!rdata) {
51725139 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);
51745141 return FAILED;
51755142 }
51765143 pnode = rdata->pnode;
....@@ -5231,7 +5198,7 @@
52315198 cnt = lpfc_sli_sum_iocb(vport, tgt_id, lun_id, context);
52325199 }
52335200 if (cnt) {
5234
- lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
5201
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
52355202 "0724 I/O flush failure for context %s : cnt x%x\n",
52365203 ((context == LPFC_CTX_LUN) ? "LUN" :
52375204 ((context == LPFC_CTX_TGT) ? "TGT" :
....@@ -5267,8 +5234,8 @@
52675234
52685235 rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
52695236 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",
52725239 rdata);
52735240 return FAILED;
52745241 }
....@@ -5279,8 +5246,8 @@
52795246
52805247 status = lpfc_chk_tgt_mapped(vport, cmnd);
52815248 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);
52845251 return FAILED;
52855252 }
52865253
....@@ -5296,7 +5263,7 @@
52965263 status = lpfc_send_taskmgmt(vport, cmnd, tgt_id, lun_id,
52975264 FCP_LUN_RESET);
52985265
5299
- lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
5266
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
53005267 "0713 SCSI layer issued Device Reset (%d, %llu) "
53015268 "return x%x\n", tgt_id, lun_id, status);
53025269
....@@ -5337,9 +5304,10 @@
53375304 int status;
53385305
53395306 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);
53435311 return FAILED;
53445312 }
53455313 pnode = rdata->pnode;
....@@ -5349,8 +5317,8 @@
53495317
53505318 status = lpfc_chk_tgt_mapped(vport, cmnd);
53515319 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);
53545322 if (pnode) {
53555323 spin_lock_irq(shost->host_lock);
53565324 pnode->nlp_flag &= ~NLP_NPR_ADISC;
....@@ -5374,7 +5342,7 @@
53745342 status = lpfc_send_taskmgmt(vport, cmnd, tgt_id, lun_id,
53755343 FCP_TARGET_RESET);
53765344
5377
- lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
5345
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
53785346 "0723 SCSI layer issued Target Reset (%d, %llu) "
53795347 "return x%x\n", tgt_id, lun_id, status);
53805348
....@@ -5455,7 +5423,7 @@
54555423 i, 0, FCP_TARGET_RESET);
54565424
54575425 if (status != SUCCESS) {
5458
- lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
5426
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
54595427 "0700 Bus Reset on target %d failed\n",
54605428 i);
54615429 ret = FAILED;
....@@ -5472,7 +5440,7 @@
54725440 if (status != SUCCESS)
54735441 ret = FAILED;
54745442
5475
- lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
5443
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
54765444 "0714 SCSI layer issued Bus Reset Data: x%x\n", ret);
54775445 return ret;
54785446 }
....@@ -5501,25 +5469,27 @@
55015469 struct lpfc_hba *phba = vport->phba;
55025470 int rc, ret = SUCCESS;
55035471
5504
- lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
5472
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
55055473 "3172 SCSI layer issued Host Reset Data:\n");
55065474
55075475 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
55085476 lpfc_offline(phba);
55095477 rc = lpfc_sli_brdrestart(phba);
55105478 if (rc)
5511
- ret = FAILED;
5479
+ goto error;
5480
+
55125481 rc = lpfc_online(phba);
55135482 if (rc)
5514
- ret = FAILED;
5483
+ goto error;
5484
+
55155485 lpfc_unblock_mgmt_io(phba);
55165486
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
- }
55225487 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;
55235493 }
55245494
55255495 /**
....@@ -5588,6 +5558,12 @@
55885558 }
55895559 sdev_cnt = atomic_inc_return(&phba->sdev_cnt);
55905560
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
+
55915567 /*
55925568 * Populate the cmds_per_lun count scsi_bufs into this host's globally
55935569 * available list of scsi buffers. Don't allocate more than the
....@@ -5619,9 +5595,9 @@
56195595 (phba->cfg_hba_queue_depth - total));
56205596 num_to_alloc = phba->cfg_hba_queue_depth - total;
56215597 }
5622
- num_allocated = lpfc_new_scsi_buf(vport, num_to_alloc);
5598
+ num_allocated = lpfc_new_scsi_buf_s3(vport, num_to_alloc);
56235599 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,
56255601 "0708 Allocation request of %d "
56265602 "command buffers did not succeed. "
56275603 "Allocated %d buffers.\n",
....@@ -5954,7 +5930,7 @@
59545930
59555931 /* Create an lun info structure and add to list of luns */
59565932 lun_info = lpfc_create_device_data(phba, vport_wwpn, target_wwpn, lun,
5957
- pri, false);
5933
+ pri, true);
59585934 if (lun_info) {
59595935 lun_info->oas_enabled = true;
59605936 lun_info->priority = pri;
....@@ -6052,37 +6028,10 @@
60526028 .this_id = -1,
60536029 .sg_tablesize = 1,
60546030 .cmd_per_lun = 1,
6055
- .use_clustering = ENABLE_CLUSTERING,
60566031 .shost_attrs = lpfc_hba_attrs,
60576032 .max_sectors = 0xFFFF,
60586033 .vendor_id = LPFC_NL_VENDOR_ID,
60596034 .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,
60866035 };
60876036
60886037 struct scsi_host_template lpfc_template = {
....@@ -6104,34 +6053,9 @@
61046053 .this_id = -1,
61056054 .sg_tablesize = LPFC_DEFAULT_SG_SEG_CNT,
61066055 .cmd_per_lun = LPFC_CMD_PER_LUN,
6107
- .use_clustering = ENABLE_CLUSTERING,
61086056 .shost_attrs = lpfc_hba_attrs,
61096057 .max_sectors = 0xFFFF,
61106058 .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,
61356059 .change_queue_depth = scsi_change_queue_depth,
61366060 .track_queue_depth = 1,
61376061 };