Skip to contentSkip to conversation

lpfc: NVME Initiator: Base modifications Part A

PATCH Superseded James Smart 4 participants 7 messages Jan 18, 2017 – Jan 19, 2017

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/17 lpfc: NVME Initiator: Base modifications Part A

NVME Initiator: Base modifications

This is part A of parts A..F.

Part A is the bulk of the file list changed by the modifications as most mods are small-ish. Changes may be for any aspect below.

*********

This set of patches (6 parts) adds base modifications for NVME initiator support to the lpfc driver.

The base modifications consist of:
- Formal split of SLI3 rings from SLI-4 WQs (sometimes referred to as rings as well) as implementation now widely varies between the two.
- Addition of configuration modes:
SCSI initiator only; NVME initiator only; NVME target only; and SCSI and NVME initiator.
The configuration mode drives overall adapter configuration, offloads enabled, and resource splits.
NVME support is only available on SLI-4 devices and newer fw.
- Implements the following based on configuration mode:
- Exchange resources are split by protocol; Obviously, if only 1 mode, then no split occurs. Default is 50/50. module attribute allows tuning.
- Each protocol has it's own set of queues, but share interrupt vectors.
SCSI:
SLI3 devices have few queues and the original style of queue
allocation remains.
SLI4 devices piggy back on an "io-channel" concept that
eventually needs to merge with scsi-mq/blk-mq support (it is underway). For now, the paradigm continues as it existed prior. io channel allocates N msix and N WQs (N=4 default) and either round robins or uses cpu # modulo N for scheduling. A bunch of module parameters allow the configuration to be tuned.
NVME (initiator):
Allocates an msix per cpu (or whatever pci_alloc_irq_vectors
gets)
Allocates a WQ per cpu, and maps the WQs to msix on a WQ #
modulo msix vector count basis.
Module parameters exist to cap/control the config if desired.
- Each protocol has its own buffer and dma pools.

Unfortunately, it was very difficult to break out the above into functional patches. A such, they are presented as a 6-patch set to keep email size reasonable. All patches in the set must be applied to create a functional unit.

Signed-off-by Dick Kennedy <dick.kennedy at broadcom.com>
Signed-off-by James Smart <james.smart at broadcom.com>
---
 drivers/scsi/lpfc/lpfc.h           |  77 ++++++++++++++--
 drivers/scsi/lpfc/lpfc_attr.h      |   1 +
 drivers/scsi/lpfc/lpfc_bsg.c       |  37 ++++++--
 drivers/scsi/lpfc/lpfc_crtn.h      |  44 ++++++++-
 drivers/scsi/lpfc/lpfc_disc.h      |   1 +
 drivers/scsi/lpfc/lpfc_els.c       |  56 ++++++++----
 drivers/scsi/lpfc/lpfc_hbadisc.c   | 148 +++++++++++++++++++-----------
 drivers/scsi/lpfc/lpfc_hw.h        |   5 +-
 drivers/scsi/lpfc/lpfc_hw4.h       | 183 +++++++++++++++++++++++++++++++++++--
 drivers/scsi/lpfc/lpfc_logmsg.h    |   4 +
 drivers/scsi/lpfc/lpfc_mbox.c      |  47 ++++++----
 drivers/scsi/lpfc/lpfc_mem.c       | 111 ++++++++++++++++------
 drivers/scsi/lpfc/lpfc_nportdisc.c |   9 +-
 drivers/scsi/lpfc/lpfc_nvme.h      |  87 ++++++++++++++++++
 drivers/scsi/lpfc/lpfc_scsi.c      | 140 +++++++++++++++++++---------
 drivers/scsi/lpfc/lpfc_scsi.h      |  18 ++--
 drivers/scsi/lpfc/lpfc_sli.h       |  37 ++++++--
 drivers/scsi/lpfc/lpfc_sli4.h      |  75 +++++++++++----
 drivers/scsi/lpfc/lpfc_version.h   |   1 +
 drivers/scsi/lpfc/lpfc_vport.c     |   3 +
 20 files changed, 854 insertions(+), 230 deletions(-)
 create mode 100644 drivers/scsi/lpfc/lpfc_nvme.h
drivers/scsi/lpfc/lpfc.h +68 -9
index 6593b07..3fad85e 100644
@@ -20,6 +20,7 @@
  *******************************************************************/
 
 #include <scsi/scsi_host.h>
+#include <linux/ktime.h>
 
 #if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_SCSI_LPFC_DEBUG_FS)
 #define CONFIG_SCSI_LPFC_DEBUG_FS
@@ -53,6 +54,7 @@ struct lpfc_sli2_slim;
 #define LPFC_MAX_SG_SEG_CNT	4096	/* sg element count per scsi cmnd */
 #define LPFC_MAX_SGL_SEG_CNT	512	/* SGL element count per scsi cmnd */
 #define LPFC_MAX_BPL_SEG_CNT	4096	/* BPL element count per scsi cmnd */
+#define LPFC_MIN_NVME_SEG_CNT	254
 
 #define LPFC_MAX_SGE_SIZE       0x80000000 /* Maximum data allowed in a SGE */
 #define LPFC_IOCB_LIST_CNT	2250	/* list of IOCBs for fast-path usage. */
@@ -114,6 +116,13 @@ enum lpfc_polling_flags {
 	DISABLE_FCP_RING_INT    = 0x2
 };
 
+struct perf_prof {
+	uint16_t cmd_cpu[40];
+	uint16_t rsp_cpu[40];
+	uint16_t qh_cpu[40];
+	uint16_t wqidx[40];
+};
+
 /* Provide DMA memory definitions the driver uses per port instance. */
 struct lpfc_dmabuf {
 	struct list_head list;
@@ -131,10 +140,24 @@ struct lpfc_dma_pool {
 struct hbq_dmabuf {
 	struct lpfc_dmabuf hbuf;
 	struct lpfc_dmabuf dbuf;
-	uint32_t size;
+	uint16_t total_size;
+	uint16_t bytes_recv;
 	uint32_t tag;
 	struct lpfc_cq_event cq_event;
 	unsigned long time_stamp;
+	void *context;
+};
+
+struct rqb_dmabuf {
+	struct lpfc_dmabuf hbuf;
+	struct lpfc_dmabuf dbuf;
+	uint16_t total_size;
+	uint16_t bytes_recv;
+	void *context;
+	struct lpfc_iocbq *iocbq;
+	struct lpfc_sglq *sglq;
+	struct lpfc_queue *hrq;	  /* ptr to associated Header RQ */
+	struct lpfc_queue *drq;	  /* ptr to associated Data RQ */
 };
 
 /* Priority bit.  Set value to exceed low water mark in lpfc_mem. */
@@ -442,6 +465,11 @@ struct lpfc_vport {
 	uint16_t fdmi_num_disc;
 	uint32_t fdmi_hba_mask;
 	uint32_t fdmi_port_mask;
+
+	/* There is a single nvme instance per vport. */
+	struct nvme_fc_local_port *localport;
+	uint8_t  nvmei_support; /* driver supports NVME Initiator */
+	uint32_t last_fcp_wqidx;
 };
 
 struct hbq_s {
@@ -459,10 +487,9 @@ struct hbq_s {
 					       struct hbq_dmabuf *);
 };
 
-#define LPFC_MAX_HBQS  4
 /* this matches the position in the lpfc_hbq_defs array */
 #define LPFC_ELS_HBQ	0
-#define LPFC_EXTRA_HBQ	1
+#define LPFC_MAX_HBQS	1
 
 enum hba_temp_state {
 	HBA_NORMAL_TEMP,
@@ -652,6 +679,8 @@ struct lpfc_hba {
 					 * Firmware supports Forced Link Speed
 					 * capability
 					 */
+#define HBA_NVME_IOQ_FLUSH      0x80000 /* NVME IO queues flushed. */
+
 	uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/
 	struct lpfc_dmabuf slim2p;
 
@@ -700,6 +729,8 @@ struct lpfc_hba {
 	uint8_t  wwpn[8];
 	uint32_t RandomData[7];
 	uint8_t  fcp_embed_io;
+	uint8_t  nvme_support;	/* Firmware supports NVME */
+	uint8_t  nvmet_support;	/* driver supports NVMET */
 	uint8_t  mds_diags_support;
 
 	/* HBA Config Parameters */
@@ -725,6 +756,13 @@ struct lpfc_hba {
 	uint32_t cfg_fcp_imax;
 	uint32_t cfg_fcp_cpu_map;
 	uint32_t cfg_fcp_io_channel;
+	uint32_t cfg_suppress_rsp;
+	uint32_t cfg_nvme_oas;
+	uint32_t cfg_nvme_io_channel;
+	uint32_t cfg_fcp_max_hw_queue;
+	uint32_t cfg_nvme_max_hw_queue;
+	uint32_t cfg_nvme_posted_buf;
+	uint32_t cfg_nvme_enable_fb;
 	uint32_t cfg_total_seg_cnt;
 	uint32_t cfg_sg_seg_cnt;
 	uint32_t cfg_sg_dma_buf_size;
@@ -770,6 +808,12 @@ struct lpfc_hba {
 #define LPFC_FDMI_SUPPORT	1	/* FDMI supported? */
 	uint32_t cfg_enable_SmartSAN;
 	uint32_t cfg_enable_mds_diags;
+	uint32_t cfg_enable_fc4_type;
+	uint32_t cfg_xri_split;
+#define LPFC_ENABLE_FCP  1
+#define LPFC_ENABLE_NVME 2
+#define LPFC_ENABLE_BOTH 3
+	uint32_t io_channel;	/* max of fcp or nvme io channels */
 	lpfc_vpd_t vpd;		/* vital product data */
 
 	struct pci_dev *pcidev;
@@ -784,11 +828,11 @@ struct lpfc_hba {
 	unsigned long data_flags;
 
 	uint32_t hbq_in_use;		/* HBQs in use flag */
-	struct list_head rb_pend_list;  /* Received buffers to be processed */
 	uint32_t hbq_count;	        /* Count of configured HBQs */
 	struct hbq_s hbqs[LPFC_MAX_HBQS]; /* local copy of hbq indicies  */
 
-	atomic_t fcp_qidx;		/* next work queue to post work to */
+	atomic_t fcp_qidx;         /* next FCP WQ (RR Policy) */
+	atomic_t nvme_qidx;        /* next NVME WQ (RR Policy) */
 
 	phys_addr_t pci_bar0_map;     /* Physical address for PCI BAR0 */
 	phys_addr_t pci_bar1_map;     /* Physical address for PCI BAR1 */
@@ -843,9 +887,17 @@ struct lpfc_hba {
 	/*
 	 * stat  counters
 	 */
-	uint64_t fc4InputRequests;
-	uint64_t fc4OutputRequests;
-	uint64_t fc4ControlRequests;
+	uint64_t fc4ScsiInputRequests;
+	uint64_t fc4ScsiOutputRequests;
+	uint64_t fc4ScsiControlRequests;
+	uint64_t fc4ScsiIoCmpls;
+	uint64_t fc4NvmeInputRequests;
+	uint64_t fc4NvmeOutputRequests;
+	uint64_t fc4NvmeControlRequests;
+	uint64_t fc4NvmeIoCmpls;
+	uint64_t fc4NvmeLsRequests;
+	uint64_t fc4NvmeLsCmpls;
+
 	uint64_t bg_guard_err_cnt;
 	uint64_t bg_apptag_err_cnt;
 	uint64_t bg_reftag_err_cnt;
@@ -856,17 +908,23 @@ struct lpfc_hba {
 	struct list_head lpfc_scsi_buf_list_get;
 	struct list_head lpfc_scsi_buf_list_put;
 	uint32_t total_scsi_bufs;
+	spinlock_t nvme_buf_list_get_lock;  /* NVME buf alloc list lock */
+	spinlock_t nvme_buf_list_put_lock;  /* NVME buf free list lock */
+	struct list_head lpfc_nvme_buf_list_get;
+	struct list_head lpfc_nvme_buf_list_put;
+	uint32_t total_nvme_bufs;
 	struct list_head lpfc_iocb_list;
 	uint32_t total_iocbq_bufs;
 	struct list_head active_rrq_list;
 	spinlock_t hbalock;
 
 	/* pci_mem_pools */
-	struct pci_pool *lpfc_scsi_dma_buf_pool;
+	struct pci_pool *lpfc_sg_dma_buf_pool;
 	struct pci_pool *lpfc_mbuf_pool;
 	struct pci_pool *lpfc_hrb_pool;	/* header receive buffer pool */
 	struct pci_pool *lpfc_drb_pool; /* data receive buffer pool */
 	struct pci_pool *lpfc_hbq_pool;	/* SLI3 hbq buffer pool */
+	struct pci_pool *txrdy_payload_pool;
 	struct lpfc_dma_pool lpfc_mbuf_safety_pool;
 
 	mempool_t *mbox_mem_pool;
@@ -950,6 +1008,7 @@ struct lpfc_hba {
 	struct dentry *idiag_ctl_acc;
 	struct dentry *idiag_mbx_acc;
 	struct dentry *idiag_ext_acc;
+	uint8_t lpfc_idiag_last_eq;
 #endif
 
 	/* Used for deferred freeing of ELS data buffers */
drivers/scsi/lpfc/lpfc_attr.h +1 -0
index b2bd28e..95c6b83 100644
@@ -114,3 +114,4 @@ lpfc_vport_param_set(name, defval, minval, maxval)\
 lpfc_vport_param_store(name)\
 static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
 		   lpfc_##name##_show, lpfc_##name##_store)
+
drivers/scsi/lpfc/lpfc_bsg.c +27 -10
index 7dca4d6..1e88b35 100644
@@ -1704,6 +1704,7 @@ lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba)
 	struct lpfc_vport **vports;
 	struct Scsi_Host *shost;
 	struct lpfc_sli *psli;
+	struct lpfc_queue *qp = NULL;
 	struct lpfc_sli_ring *pring;
 	int i = 0;
 
@@ -1711,9 +1712,6 @@ lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba)
 	if (!psli)
 		return -ENODEV;
 
-	pring = &psli->ring[LPFC_FCP_RING];
-	if (!pring)
-		return -ENODEV;
 
 	if ((phba->link_state == LPFC_HBA_ERROR) ||
 	    (psli->sli_flag & LPFC_BLOCK_MGMT_IO) ||
@@ -1732,10 +1730,18 @@ lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba)
 		scsi_block_requests(shost);
 	}
 
-	while (!list_empty(&pring->txcmplq)) {
-		if (i++ > 500)  /* wait up to 5 seconds */
+	if (phba->sli_rev != LPFC_SLI_REV4) {
+		pring = &psli->sli3_ring[LPFC_FCP_RING];
+		lpfc_emptyq_wait(phba, &pring->txcmplq, &phba->hbalock);
+		return 0;
+	}
+	list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) {
+		pring = qp->pring;
+		if (!pring || (pring->ringno != LPFC_FCP_RING))
+			continue;
+		if (!lpfc_emptyq_wait(phba, &pring->txcmplq,
+				      &pring->ring_lock))
 			break;
-		msleep(10);
 	}
 	return 0;
 }
@@ -2704,7 +2710,7 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi,
  * @phba: Pointer to HBA context object
  *
  * This function allocates BSG_MBOX_SIZE (4KB) page size dma buffer and.
- * returns the pointer to the buffer.
+ * retruns the pointer to the buffer.
  **/
 static struct lpfc_dmabuf *
 lpfc_bsg_dma_page_alloc(struct lpfc_hba *phba)
@@ -2876,7 +2882,7 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,
 			     size_t len)
 {
 	struct lpfc_sli *psli = &phba->sli;
-	struct lpfc_sli_ring *pring = &psli->ring[LPFC_ELS_RING];
+	struct lpfc_sli_ring *pring;
 	struct lpfc_iocbq *cmdiocbq;
 	IOCB_t *cmd = NULL;
 	struct list_head head, *curr, *next;
@@ -2890,6 +2896,11 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,
 	int iocb_stat;
 	int i = 0;
 
+	if (phba->sli_rev == LPFC_SLI_REV4)
+		pring = phba->sli4_hba.els_wq->pring;
+	else
+		pring = &psli->sli3_ring[LPFC_ELS_RING];
+
 	cmdiocbq = lpfc_sli_get_iocbq(phba);
 	rxbmp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
 	if (rxbmp != NULL) {
@@ -5258,7 +5269,7 @@ static int
 lpfc_forced_link_speed(struct bsg_job *job)
 {
 	struct Scsi_Host *shost = fc_bsg_to_shost(job);
-	struct lpfc_vport *vport = shost_priv(shost);
+	struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
 	struct lpfc_hba *phba = vport->phba;
 	struct fc_bsg_reply *bsg_reply = job->reply;
 	struct forced_link_speed_support_reply *forced_reply;
@@ -5402,14 +5413,20 @@ lpfc_bsg_timeout(struct bsg_job *job)
 {
 	struct lpfc_vport *vport = shost_priv(fc_bsg_to_shost(job));
 	struct lpfc_hba *phba = vport->phba;
+	struct lpfc_sli *psli = &phba->sli;
 	struct lpfc_iocbq *cmdiocb;
-	struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING];
+	struct lpfc_sli_ring *pring;
 	struct bsg_job_data *dd_data;
 	unsigned long flags;
 	int rc = 0;
 	LIST_HEAD(completions);
 	struct lpfc_iocbq *check_iocb, *next_iocb;
 
+	if (phba->sli_rev == LPFC_SLI_REV4)
+		pring = phba->sli4_hba.els_wq->pring;
+	else
+		pring = &psli->sli3_ring[LPFC_ELS_RING];
+
 	/* if job's driver data is NULL, the command completed or is in the
 	 * the process of completing.  In this case, return status to request
 	 * so the timeout is retried.  This avoids double completion issues
drivers/scsi/lpfc/lpfc_crtn.h +40 -4

112 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_disc.h +1 -0
index 361f5b3..1d07a5f 100644
@@ -133,6 +133,7 @@ struct lpfc_node_rrq {
 /* Defines for nlp_flag (uint32) */
 #define NLP_IGNR_REG_CMPL  0x00000001 /* Rcvd rscn before we cmpl reg login */
 #define NLP_REG_LOGIN_SEND 0x00000002   /* sent reglogin to adapter */
+#define NLP_SUPPRESS_RSP   0x00000010	/* Remote NPort supports suppress rsp */
 #define NLP_PLOGI_SND      0x00000020	/* sent PLOGI request for this entry */
 #define NLP_PRLI_SND       0x00000040	/* sent PRLI request for this entry */
 #define NLP_ADISC_SND      0x00000080	/* sent ADISC request for this entry */
drivers/scsi/lpfc/lpfc_els.c +38 -18

137 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_hbadisc.c +97 -51

321 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_hw.h +2 -3
index 3b970d37..5d7416c 100644
@@ -44,8 +44,6 @@
 #define LPFC_FCP_RING            0	/* ring 0 for FCP initiator commands */
 #define LPFC_EXTRA_RING          1	/* ring 1 for other protocols */
 #define LPFC_ELS_RING            2	/* ring 2 for ELS commands */
-#define LPFC_FCP_NEXT_RING       3
-#define LPFC_FCP_OAS_RING        3
 
 #define SLI2_IOCB_CMD_R0_ENTRIES    172	/* SLI-2 FCP command ring entries */
 #define SLI2_IOCB_RSP_R0_ENTRIES    134	/* SLI-2 FCP response ring entries */
@@ -1791,6 +1789,7 @@ typedef struct {		/* FireFly BIU registers */
 #define MBX_INIT_VFI        0xA3
 #define MBX_INIT_VPI        0xA4
 #define MBX_ACCESS_VDATA    0xA5
+#define MBX_REG_FCFI_MRQ    0xAF
 
 #define MBX_AUTH_PORT       0xF8
 #define MBX_SECURITY_MGMT   0xF9
@@ -4163,7 +4162,7 @@ typedef struct _IOCB {	/* IOCB structure */
 
 /* HBQ entries are 4 words each = 4k */
 #define LPFC_TOTAL_HBQ_SIZE (sizeof(struct lpfc_hbq_entry) *  \
-			     lpfc_sli_hbq_count())
+			     lpfc_sli_hbq_count(phba))
 
 struct lpfc_sli2_slim {
 	MAILBOX_t mbx;
drivers/scsi/lpfc/lpfc_hw4.h +173 -10

311 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_logmsg.h +4 -0
index 2a4e5d2..3faf7a0 100644
@@ -38,6 +38,10 @@
 #define LOG_FIP		0x00020000	/* FIP events */
 #define LOG_FCP_UNDER	0x00040000	/* FCP underruns errors */
 #define LOG_SCSI_CMD	0x00080000	/* ALL SCSI commands */
+#define LOG_NVME	0x00100000	/* NVME general events. */
+#define LOG_NVME_DISC   0x00200000      /* NVME Discovery/Connect events. */
+#define LOG_NVME_ABTS   0x00400000      /* NVME ABTS events. */
+#define LOG_NVME_IOERR  0x00800000      /* NVME IO Error events. */
 #define LOG_ALL_MSG	0xffffffff	/* LOG all messages */
 
 #define lpfc_printf_vlog(vport, level, mask, fmt, arg...) \
drivers/scsi/lpfc/lpfc_mbox.c +29 -18

111 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_mem.c +84 -27

212 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_nportdisc.c +7 -2
index 56a3df4..9643a59 100644
@@ -205,9 +205,14 @@ lpfc_els_abort(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
 {
 	LIST_HEAD(abort_list);
 	struct lpfc_sli  *psli = &phba->sli;
-	struct lpfc_sli_ring *pring = &psli->ring[LPFC_ELS_RING];
+	struct lpfc_sli_ring *pring;
 	struct lpfc_iocbq *iocb, *next_iocb;
 
+	if (phba->sli_rev == LPFC_SLI_REV4)
+		pring = phba->sli4_hba.els_wq->pring;
+	else
+		pring = &psli->sli3_ring[LPFC_ELS_RING];
+
 	/* Abort outstanding I/O on NPort <nlp_DID> */
 	lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_DISCOVERY,
 			 "2819 Abort outstanding I/O on NPort x%x "
@@ -2104,7 +2109,7 @@ lpfc_rcv_prlo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 	struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
 
 	/* flush the target */
-	lpfc_sli_abort_iocb(vport, &phba->sli.ring[phba->sli.fcp_ring],
+	lpfc_sli_abort_iocb(vport, &phba->sli.sli3_ring[LPFC_FCP_RING],
 			    ndlp->nlp_sid, 0, LPFC_CTX_TGT);
 
 	/* Treat like rcv logo */
drivers/scsi/lpfc/lpfc_nvme.h new file +87 -0

87 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_scsi.c +95 -45

366 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_scsi.h +12 -6
index 8cb80da..def0c0a5 100644
@@ -135,6 +135,8 @@ struct lpfc_scsi_buf {
 
 	uint32_t timeout;
 
+	uint16_t flags;  /* TBD convert exch_busy to flags */
+#define LPFC_SBUF_XBUSY         0x1     /* SLI4 hba reported XB on WCQE cmpl */
 	uint16_t exch_busy;     /* SLI4 hba reported XB on complete WCQE */
 	uint16_t status;	/* From IOCB Word 7- ulpStatus */
 	uint32_t result;	/* From IOCB Word 4. */
@@ -164,6 +166,8 @@ struct lpfc_scsi_buf {
 	 * Iotag is in here
 	 */
 	struct lpfc_iocbq cur_iocbq;
+	uint16_t cpu;
+
 	wait_queue_head_t *waitq;
 	unsigned long start_time;
 
@@ -178,13 +182,15 @@ struct lpfc_scsi_buf {
 #endif
 };
 
-#define LPFC_SCSI_DMA_EXT_SIZE 264
-#define LPFC_BPL_SIZE          1024
-#define MDAC_DIRECT_CMD                  0x22
+#define LPFC_SCSI_DMA_EXT_SIZE	264
+#define LPFC_BPL_SIZE		1024
+#define MDAC_DIRECT_CMD		0x22
+
+#define FIND_FIRST_OAS_LUN	0
+#define NO_MORE_OAS_LUN		-1
+#define NOT_OAS_ENABLED_LUN	NO_MORE_OAS_LUN
 
-#define FIND_FIRST_OAS_LUN		 0
-#define NO_MORE_OAS_LUN			-1
-#define NOT_OAS_ENABLED_LUN		NO_MORE_OAS_LUN
+#define TXRDY_PAYLOAD_LEN	12
 
 int lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba,
 				  struct lpfc_scsi_buf *lpfc_cmd);
drivers/scsi/lpfc/lpfc_sli.h +27 -10
index 74227a2..acb431f 100644
@@ -54,9 +54,16 @@ struct lpfc_iocbq {
 	uint16_t iotag;         /* pre-assigned IO tag */
 	uint16_t sli4_lxritag;  /* logical pre-assigned XRI. */
 	uint16_t sli4_xritag;   /* pre-assigned XRI, (OXID) tag. */
+	uint16_t hba_wqidx;     /* index to HBA work queue */
 	struct lpfc_cq_event cq_event;
+	struct lpfc_wcqe_complete wcqe_cmpl;	/* WQE cmpl */
+	uint64_t isr_timestamp;
 
-	IOCB_t iocb;		/* IOCB cmd */
+	/* Be careful here */
+	union lpfc_wqe wqe;	/* WQE cmd */
+	IOCB_t iocb;		/* For IOCB cmd or if we want 128 byte WQE */
+
+	uint8_t rsvd2;
 	uint8_t priority;	/* OAS priority */
 	uint8_t retry;		/* retry counter for IOCB cmd - if needed */
 	uint32_t iocb_flag;
@@ -82,9 +89,12 @@ struct lpfc_iocbq {
 #define LPFC_IO_OAS		0x10000 /* OAS FCP IO */
 #define LPFC_IO_FOF		0x20000 /* FOF FCP IO */
 #define LPFC_IO_LOOPBACK	0x40000 /* Loopback IO */
+#define LPFC_PRLI_NVME_REQ	0x80000 /* This is an NVME PRLI. */
+#define LPFC_PRLI_FCP_REQ	0x100000 /* This is an NVME PRLI. */
+#define LPFC_IO_NVME	        0x200000 /* NVME FCP command */
+#define LPFC_IO_NVME_LS		0x400000 /* NVME LS command */
 
 	uint32_t drvrTimeout;	/* driver timeout in seconds */
-	uint32_t fcp_wqidx;	/* index to FCP work queue */
 	struct lpfc_vport *vport;/* virtual port pointer */
 	void *context1;		/* caller context information */
 	void *context2;		/* caller context information */
@@ -97,12 +107,14 @@ struct lpfc_iocbq {
 		struct lpfc_node_rrq *rrq;
 	} context_un;
 
-	void (*fabric_iocb_cmpl) (struct lpfc_hba *, struct lpfc_iocbq *,
+	void (*fabric_iocb_cmpl)(struct lpfc_hba *, struct lpfc_iocbq *,
 			   struct lpfc_iocbq *);
-	void (*wait_iocb_cmpl) (struct lpfc_hba *, struct lpfc_iocbq *,
+	void (*wait_iocb_cmpl)(struct lpfc_hba *, struct lpfc_iocbq *,
 			   struct lpfc_iocbq *);
-	void (*iocb_cmpl) (struct lpfc_hba *, struct lpfc_iocbq *,
+	void (*iocb_cmpl)(struct lpfc_hba *, struct lpfc_iocbq *,
 			   struct lpfc_iocbq *);
+	void (*wqe_cmpl)(struct lpfc_hba *, struct lpfc_iocbq *,
+			  struct lpfc_wcqe_complete *);
 };
 
 #define SLI_IOCB_RET_IOCB      1	/* Return IOCB if cmd ring full */
@@ -112,6 +124,14 @@ struct lpfc_iocbq {
 #define IOCB_ERROR          2
 #define IOCB_TIMEDOUT       3
 
+#define SLI_WQE_RET_WQE    1    /* Return WQE if cmd ring full */
+
+#define WQE_SUCCESS        0
+#define WQE_BUSY           1
+#define WQE_ERROR          2
+#define WQE_TIMEDOUT       3
+#define WQE_ABORTED        4
+
 #define LPFC_MBX_WAKE		1
 #define LPFC_MBX_IMED_UNREG	2
 
@@ -297,12 +317,9 @@ struct lpfc_sli {
 #define LPFC_BLOCK_MGMT_IO        0x800	/* Don't allow mgmt mbx or iocb cmds */
 #define LPFC_MENLO_MAINT          0x1000 /* need for menl fw download */
 #define LPFC_SLI_ASYNC_MBX_BLK    0x2000 /* Async mailbox is blocked */
+#define LPFC_SLI_SUPPRESS_RSP     0x4000 /* Suppress RSP feature is supported */
 
-	struct lpfc_sli_ring *ring;
-	int fcp_ring;		/* ring used for FCP initiator commands */
-	int next_ring;
-
-	int extra_ring;		/* extra ring used for other protocols */
+	struct lpfc_sli_ring *sli3_ring;
 
 	struct lpfc_sli_stat slistat;	/* SLI statistical info */
 	struct list_head mboxq;
drivers/scsi/lpfc/lpfc_sli4.h +58 -17

196 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_version.h +1 -0
index 0ee0623..31328a7 100644
@@ -20,6 +20,7 @@
 
 #define LPFC_DRIVER_VERSION "11.2.0.4"
 #define LPFC_DRIVER_NAME		"lpfc"
+#define LPFCMGMT_NAME			"lpfcmgmt"
 
 /* Used for SLI 2/3 */
 #define LPFC_SP_DRIVER_HANDLER_NAME	"lpfc:sp"
drivers/scsi/lpfc/lpfc_vport.c +3 -0
index e18bbc6..07c7c5f 100644
@@ -33,6 +33,7 @@
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_transport_fc.h>
+
 #include "lpfc_hw4.h"
 #include "lpfc_hw.h"
 #include "lpfc_sli.h"
@@ -402,6 +403,8 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
 		vport->fdmi_port_mask = phba->pport->fdmi_port_mask;
 	}
 
+	/* todo: init: register port with nvme */
+
 	/*
 	 * In SLI4, the vpi must be activated before it can be used
 	 * by the port.
Signature · 1 line
2.5.0
#1 lore raw

PATCH 2/17 lpfc: NVME Initiator: Base modifications Part A

Quoted 77 lines · James Smart

NVME Initiator: Base modifications

This is part A of parts A..F.

Part A is the bulk of the file list changed by the modifications as most mods are small-ish. Changes may be for any aspect below.

*********

This set of patches (6 parts) adds base modifications for NVME initiator support to the lpfc driver.

The base modifications consist of:
- Formal split of SLI3 rings from SLI-4 WQs (sometimes referred to as rings as well) as implementation now widely varies between the two.
- Addition of configuration modes:
SCSI initiator only; NVME initiator only; NVME target only; and SCSI and NVME initiator.
The configuration mode drives overall adapter configuration, offloads enabled, and resource splits.
NVME support is only available on SLI-4 devices and newer fw.
- Implements the following based on configuration mode:
- Exchange resources are split by protocol; Obviously, if only 1 mode, then no split occurs. Default is 50/50. module attribute allows tuning.
- Each protocol has it's own set of queues, but share interrupt vectors.
SCSI:
SLI3 devices have few queues and the original style of queue
allocation remains.
SLI4 devices piggy back on an "io-channel" concept that
eventually needs to merge with scsi-mq/blk-mq support (it is underway). For now, the paradigm continues as it existed prior. io channel allocates N msix and N WQs (N=4 default) and either round robins or uses cpu # modulo N for scheduling. A bunch of module parameters allow the configuration to be tuned.
NVME (initiator):
Allocates an msix per cpu (or whatever pci_alloc_irq_vectors
gets)
Allocates a WQ per cpu, and maps the WQs to msix on a WQ #
modulo msix vector count basis.
Module parameters exist to cap/control the config if desired.
- Each protocol has its own buffer and dma pools.

Unfortunately, it was very difficult to break out the above into functional patches. A such, they are presented as a 6-patch set to keep email size reasonable. All patches in the set must be applied to create a functional unit.

Signed-off-by Dick Kennedy <dick.kennedy at broadcom.com>
Signed-off-by James Smart <james.smart at broadcom.com>
---
 drivers/scsi/lpfc/lpfc.h           |  77 ++++++++++++++--
 drivers/scsi/lpfc/lpfc_attr.h      |   1 +
 drivers/scsi/lpfc/lpfc_bsg.c       |  37 ++++++--
 drivers/scsi/lpfc/lpfc_crtn.h      |  44 ++++++++-
 drivers/scsi/lpfc/lpfc_disc.h      |   1 +
 drivers/scsi/lpfc/lpfc_els.c       |  56 ++++++++----
 drivers/scsi/lpfc/lpfc_hbadisc.c   | 148 +++++++++++++++++++-----------
 drivers/scsi/lpfc/lpfc_hw.h        |   5 +-
 drivers/scsi/lpfc/lpfc_hw4.h       | 183 +++++++++++++++++++++++++++++++++++--
 drivers/scsi/lpfc/lpfc_logmsg.h    |   4 +
 drivers/scsi/lpfc/lpfc_mbox.c      |  47 ++++++----
 drivers/scsi/lpfc/lpfc_mem.c       | 111 ++++++++++++++++------
 drivers/scsi/lpfc/lpfc_nportdisc.c |   9 +-
 drivers/scsi/lpfc/lpfc_nvme.h      |  87 ++++++++++++++++++
 drivers/scsi/lpfc/lpfc_scsi.c      | 140 +++++++++++++++++++---------
 drivers/scsi/lpfc/lpfc_scsi.h      |  18 ++--
 drivers/scsi/lpfc/lpfc_sli.h       |  37 ++++++--
 drivers/scsi/lpfc/lpfc_sli4.h      |  75 +++++++++++----
 drivers/scsi/lpfc/lpfc_version.h   |   1 +
 drivers/scsi/lpfc/lpfc_vport.c     |   3 +
 20 files changed, 854 insertions(+), 230 deletions(-)
 create mode 100644 drivers/scsi/lpfc/lpfc_nvme.h

[ .. ]

drivers/scsi/lpfc/lpfc_scsi.c lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba, · line 616

Quoted 9 lines
drivers/scsi/lpfc/lpfc_scsi.c +1 -1
@@ -605,7 +610,7 @@ lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba,
 }
 
 /**
- * lpfc_sli4_post_scsi_sgl_list - Post blocks of scsi buffer sgls from a list
+ * lpfc_sli4_post_scsi_sgl_list - Psot blocks of scsi buffer sgls from a list
  * @phba: pointer to lpfc hba data structure.
  * @post_sblist: pointer to the scsi buffer list.
  *

Psot?

drivers/scsi/lpfc/lpfc_scsi.c lpfc_sli4_post_scsi_sgl_list(struct lpfc_hba *phba, · line 745

Quoted 9 lines
drivers/scsi/lpfc/lpfc_scsi.c +1 -1
@@ -734,7 +739,7 @@ lpfc_sli4_post_scsi_sgl_list(struct lpfc_hba *phba,
 }
 
 /**
- * lpfc_sli4_repost_scsi_sgl_list - Repost all the allocated scsi buffer sgls
+ * lpfc_sli4_repost_scsi_sgl_list - Repsot all the allocated scsi buffer sgls
  * @phba: pointer to lpfc hba data structure.
  *
  * This routine walks the list of scsi buffers that have been allocated and

Repsot? The reverse of 'Psot'?

[ .. ]

drivers/scsi/lpfc/lpfc_scsi.c lpfc_release_scsi_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb) · line 1144

Quoted 9 lines
drivers/scsi/lpfc/lpfc_scsi.c +1 -1
@@ -1133,7 +1138,7 @@ lpfc_release_scsi_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb)
  *
  * This routine does the pci dma mapping for scatter-gather list of scsi cmnd
  * field of @lpfc_cmd for device with SLI-3 interface spec. This routine scans
- * through sg elements and format the bde. This routine also initializes all
+ * through sg elements and format the bdea. This routine also initializes all
  * IOCB fields which are dependent on scsi command request buffer.
  *
  * Return codes:

bdea?

[ .. ]

drivers/scsi/lpfc/lpfc_scsi.c lpfc_send_taskmgmt(struct lpfc_vport *vport, struct scsi_cmnd *cmnd, · line 5012

Quoted 9 lines
drivers/scsi/lpfc/lpfc_scsi.c +1 -1
@@ -4997,7 +5006,7 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct scsi_cmnd *cmnd,
 	if ((status != IOCB_SUCCESS) ||
 	    (iocbqrsp->iocb.ulpStatus != IOSTAT_SUCCESS)) {
 		if (status != IOCB_SUCCESS ||
-		    iocbqrsp->iocb.ulpStatus != IOSTAT_FCP_RSP_ERROR)
+			iocbqrsp->iocb.ulpStatus != IOSTAT_FCP_RSP_ERROR)
 			lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
 					 "0727 TMF %s to TGT %d LUN %llu "
 					 "failed (%d, %d) iocb_flag x%x\n",

Wrong indent.

[ .. ]

drivers/scsi/lpfc/lpfc_scsi.h struct lpfc_scsi_buf { · line 142

Quoted 13 lines
drivers/scsi/lpfc/lpfc_scsi.h +2 -0
index 8cb80da..def0c0a5 100644
@@ -135,6 +135,8 @@ struct lpfc_scsi_buf {
 
 	uint32_t timeout;
 
+	uint16_t flags;  /* TBD convert exch_busy to flags */
+#define LPFC_SBUF_XBUSY         0x1     /* SLI4 hba reported XB on WCQE cmpl */
 	uint16_t exch_busy;     /* SLI4 hba reported XB on complete WCQE */
 	uint16_t status;	/* From IOCB Word 7- ulpStatus */
 	uint32_t result;	/* From IOCB Word 4. */

I thought I had a patch for that ... lemme see.

Other than that:

Reviewed-by Hannes Reinecke <hare at suse.com>

Cheers,

Hannes

Signature · 5 lines
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare at suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: F. Imend?rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG N?rnberg)
#2 lore raw

PATCH 2/17 lpfc: NVME Initiator: Base modifications Part A

Quoted 9 lines · Hannes Reinecke
Quoted 6 lines

- * lpfc_sli4_post_scsi_sgl_list - Post blocks of scsi buffer sgls from a list
+ * lpfc_sli4_post_scsi_sgl_list - Psot blocks of scsi buffer sgls from a list
* @phba: pointer to lpfc hba data structure.
* @post_sblist: pointer to the scsi buffer list.
*

Psot?

Repsot? The reverse of 'Psot'?

lol...

Quoted 2 lines

bdea?

Crud - caught a bunch of those but looks like a couple got through. Surprised checkpatch let them through. oh well.

anyway - will fix and repost (repsot?) what you mentioned.

-- james

#3 lore raw

PATCH 2/17 lpfc: NVME Initiator: Base modifications Part A

In reply to James Smart

Hi James,

Quoted 54 lines · James Smart

NVME Initiator: Base modifications

This is part A of parts A..F.

Part A is the bulk of the file list changed by the modifications as most mods are small-ish. Changes may be for any aspect below.

*********

This set of patches (6 parts) adds base modifications for NVME initiator support to the lpfc driver.

The base modifications consist of:
- Formal split of SLI3 rings from SLI-4 WQs (sometimes referred to as rings as well) as implementation now widely varies between the two.
- Addition of configuration modes:
SCSI initiator only; NVME initiator only; NVME target only; and SCSI and NVME initiator.
The configuration mode drives overall adapter configuration, offloads enabled, and resource splits.
NVME support is only available on SLI-4 devices and newer fw.
- Implements the following based on configuration mode:
- Exchange resources are split by protocol; Obviously, if only 1 mode, then no split occurs. Default is 50/50. module attribute allows tuning.
- Each protocol has it's own set of queues, but share interrupt vectors.
SCSI:
SLI3 devices have few queues and the original style of queue
allocation remains.
SLI4 devices piggy back on an "io-channel" concept that
eventually needs to merge with scsi-mq/blk-mq support (it is underway). For now, the paradigm continues as it existed prior. io channel allocates N msix and N WQs (N=4 default) and either round robins or uses cpu # modulo N for scheduling. A bunch of module parameters allow the configuration to be tuned.
NVME (initiator):
Allocates an msix per cpu (or whatever pci_alloc_irq_vectors
gets)
Allocates a WQ per cpu, and maps the WQs to msix on a WQ #
modulo msix vector count basis.
Module parameters exist to cap/control the config if desired.
- Each protocol has its own buffer and dma pools.

Unfortunately, it was very difficult to break out the above into functional patches. A such, they are presented as a 6-patch set to keep email size reasonable. All patches in the set must be applied to create a functional unit.

Signed-off-by Dick Kennedy <dick.kennedy at broadcom.com>
Signed-off-by James Smart <james.smart at broadcom.com>

---

[...]

drivers/scsi/lpfc/lpfc_bsg.c static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi, · line 2713

Quoted 6 lines
drivers/scsi/lpfc/lpfc_bsg.c +1 -1
@@ -2704,7 +2710,7 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi,
  * @phba: Pointer to HBA context object
  *
  * This function allocates BSG_MBOX_SIZE (4KB) page size dma buffer and.
- * returns the pointer to the buffer.
+ * retruns the pointer to the buffer.

This hunk introduces a spelling error.

Quoted 25 lines
drivers/scsi/lpfc/lpfc_bsg.c +6 -1
  **/
 static struct lpfc_dmabuf *
 lpfc_bsg_dma_page_alloc(struct lpfc_hba *phba)
@@ -2876,7 +2882,7 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,
 			     size_t len)
 {
 	struct lpfc_sli *psli = &phba->sli;
-	struct lpfc_sli_ring *pring = &psli->ring[LPFC_ELS_RING];
+	struct lpfc_sli_ring *pring;
 	struct lpfc_iocbq *cmdiocbq;
 	IOCB_t *cmd = NULL;
 	struct list_head head, *curr, *next;
@@ -2890,6 +2896,11 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,
 	int iocb_stat;
 	int i = 0;
 
+	if (phba->sli_rev == LPFC_SLI_REV4)
+		pring = phba->sli4_hba.els_wq->pring;
+	else
+		pring = &psli->sli3_ring[LPFC_ELS_RING];
+
 	cmdiocbq = lpfc_sli_get_iocbq(phba);
 	rxbmp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
 	if (rxbmp != NULL) {

drivers/scsi/lpfc/lpfc_bsg.c static int · line 5272

Quoted 5 lines
drivers/scsi/lpfc/lpfc_bsg.c +1 -1
@@ -5258,7 +5269,7 @@ static int
 lpfc_forced_link_speed(struct bsg_job *job)
 {
 	struct Scsi_Host *shost = fc_bsg_to_shost(job);
-	struct lpfc_vport *vport = shost_priv(shost);
+	struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;

Please don't. A) it's unnecessary to cast a void* and b) shost_priv() just returns shost->hostdata (casted to void*). So all's fine.

[...]

Quoted 17 lines
drivers/scsi/lpfc/lpfc_disc.h +1 -0
index 361f5b3..1d07a5f 100644
@@ -133,6 +133,7 @@ struct lpfc_node_rrq {
 /* Defines for nlp_flag (uint32) */
 #define NLP_IGNR_REG_CMPL  0x00000001 /* Rcvd rscn before we cmpl reg login */
 #define NLP_REG_LOGIN_SEND 0x00000002   /* sent reglogin to adapter */
+#define NLP_SUPPRESS_RSP   0x00000010	/* Remote NPort supports suppress rsp */
 #define NLP_PLOGI_SND      0x00000020	/* sent PLOGI request for this entry */
 #define NLP_PRLI_SND       0x00000040	/* sent PRLI request for this entry */
 #define NLP_ADISC_SND      0x00000080	/* sent ADISC request for this entry */
drivers/scsi/lpfc/lpfc_els.c +0 -0
index 27f0cbb..f61e1c2 100644

drivers/scsi/lpfc/lpfc_els.c lpfc_els_abort_flogi(struct lpfc_hba *phba) · line 1330

Quoted 9 lines
drivers/scsi/lpfc/lpfc_els.c +4 -1
@@ -1323,7 +1323,10 @@ lpfc_els_abort_flogi(struct lpfc_hba *phba)
 			"0201 Abort outstanding I/O on NPort x%x\n",
 			Fabric_DID);
 
-	pring = &phba->sli.ring[LPFC_ELS_RING];
+	if (phba->sli_rev != LPFC_SLI_REV4)
+		pring = &phba->sli.sli3_ring[LPFC_ELS_RING];
+	else
+		pring = phba->sli4_hba.els_wq->pring;
 

You're doing this quite often, can you make a small helper for it? static inline struct lpfc_sli_ring *lpfc_sli_ring_from_hba(struct lpfc_hba *phba)

{
	if (phba->sli_rev != LPFC_SLI_REV4)
		pring = &phba->sli.sli3_ring[LPFC_ELS_RING];
	else
		pring = phba->sli4_hba.els_wq->pring;
}

[...]

drivers/scsi/lpfc/lpfc_els.c lpfc_sli4_new_fcf_random_select(struct lpfc_hba *phba, uint32_t fcf_cnt) · line 1760

Quoted 6 lines
drivers/scsi/lpfc/lpfc_els.c +1 -1
@@ -1751,7 +1757,7 @@ lpfc_sli4_new_fcf_random_select(struct lpfc_hba *phba, uint32_t fcf_cnt)
 	uint32_t rand_num;
 
 	/* Get 16-bit uniform random number */
-	rand_num = 0xFFFF & prandom_u32();
+	rand_num = (0xFFFF & prandom_u32());

Unnecessary introduction of parenthesis.

[...]

Quoted 27 lines
drivers/scsi/lpfc/lpfc_els.c +13 -10
@@ -4452,28 +4471,51 @@ lpfc_no_rpi(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
 	psli = &phba->sli;
 	if (ndlp->nlp_flag & NLP_RPI_REGISTERED) {
 		/* Now process each ring */
-		for (i = 0; i < psli->num_rings; i++) {
-			pring = &psli->ring[i];
-
-			spin_lock_irq(&phba->hbalock);
-			list_for_each_entry_safe(iocb, next_iocb, &pring->txq,
-						 list) {
-				/*
-				 * Check to see if iocb matches the nport we are
-				 * looking for
-				 */
+		if (phba->sli_rev != LPFC_SLI_REV4) {
+			for (i = 0; i < psli->num_rings; i++) {
+				pring = &psli->sli3_ring[i];
+				spin_lock_irq(&phba->hbalock);
+				list_for_each_entry_safe(iocb, next_iocb,
+							 &pring->txq, list) {
+					/*
+					 * Check to see if iocb matches the
+					 * nport we are looking for
+					 */
+					if ((lpfc_check_sli_ndlp(phba, pring,
+								 iocb, ndlp))) {
+						/* It matches, so deque and

drivers/scsi/lpfc/lpfc_els.c lpfc_no_rpi(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) · line 4496

Quoted 10 lines
drivers/scsi/lpfc/lpfc_els.c +10 -0
+						 * call compl with an error
+						 */
+						list_move_tail(&iocb->list,
+							       &completions);
+					}
+				}
+				spin_unlock_irq(&phba->hbalock);
+			}
+			goto out;
+		}

Can you please factor the for loop into an own function so that we get

		if (phba->sli_rev != LPFC_SLI_REV4)
			lpfc_handle_sli_rev4();

The level of indentation is just too high. Btw checkpatch.pl tells you about it with '--type DEEP_INDENTATION'.

Quoted 12 lines
drivers/scsi/lpfc/lpfc_els.c +8 -2
+		spin_lock_irq(&phba->hbalock);
+		list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) {
+			pring = qp->pring;
+			if (!pring)
+				continue;
+			spin_lock_irq(&pring->ring_lock);
+			list_for_each_entry_safe(iocb, next_iocb,
+						 &pring->txq, list) {
 				if ((lpfc_check_sli_ndlp(phba, pring, iocb,
 							 ndlp))) {
-					/* It matches, so deque and call compl
-					   with an error */

drivers/scsi/lpfc/lpfc_els.c lpfc_no_rpi(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) · line 4515

Quoted 10 lines
drivers/scsi/lpfc/lpfc_els.c +4 -1
+					/* It matches, so deque and
+					 * call compl with an error
+					 */
 					list_move_tail(&iocb->list,
 						       &completions);
 				}
 			}
-			spin_unlock_irq(&phba->hbalock);
+			spin_unlock_irq(&pring->ring_lock);
 		}

like above, is it possible to do

		spin_lock_irq(...);
		handler();
		spin_unlock_irq();

This makes it way easier to follow.

[...]

drivers/scsi/lpfc/lpfc_els.c lpfc_free_tx(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) · line 5255

Quoted 10 lines
drivers/scsi/lpfc/lpfc_els.c +4 -1
@@ -5207,7 +5248,10 @@ lpfc_free_tx(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
 	struct lpfc_sli_ring *pring;
 
 	psli = &phba->sli;
-	pring = &psli->ring[LPFC_ELS_RING];
+	if (phba->sli_rev != LPFC_SLI_REV4)
+		pring = &phba->sli.sli3_ring[LPFC_ELS_RING];
+	else
+		pring = phba->sli4_hba.els_wq->pring;
 

you really might want to write a coccinelle rule for this pattern...

[...]

drivers/scsi/lpfc/lpfc_scsi.c lpfc_update_stats(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) · line 245

Quoted 9 lines
drivers/scsi/lpfc/lpfc_scsi.c +1 -0
index 19d349f..c60dfc9 100644
@@ -242,6 +242,7 @@ lpfc_update_stats(struct lpfc_hba *phba, struct  lpfc_scsi_buf *lpfc_cmd)
 	spin_unlock_irqrestore(shost->host_lock, flags);
 }
 
+

Stray newine.

[...]

drivers/scsi/lpfc/lpfc_scsi.c lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba, · line 613

Quoted 6 lines
drivers/scsi/lpfc/lpfc_scsi.c +1 -1
@@ -605,7 +610,7 @@ lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba,
 }
 
 /**
- * lpfc_sli4_post_scsi_sgl_list - Post blocks of scsi buffer sgls from a list
+ * lpfc_sli4_post_scsi_sgl_list - Psot blocks of scsi buffer sgls from a list
                                     ^^^ o.O

[...]

drivers/scsi/lpfc/lpfc_scsi.c int lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba, · line 3899

Quoted 6 lines
drivers/scsi/lpfc/lpfc_scsi.c +1 -1
@@ -3894,7 +3896,7 @@ int lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba,
 		}
 	}
 	chann = atomic_add_return(1, &phba->fcp_qidx);
-	chann = (chann % phba->cfg_fcp_io_channel);
+	chann = (chann % phba->cfg_fcp_max_hw_queue);

No need for the parenthesis.

[...]

drivers/scsi/lpfc/lpfc_scsi.c lpfc_send_taskmgmt(struct lpfc_vport *vport, struct scsi_cmnd *cmnd, · line 4963

Quoted 6 lines
drivers/scsi/lpfc/lpfc_scsi.c +0 -2
@@ -4959,11 +4968,11 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct scsi_cmnd *cmnd,
 	int status;
 
 	rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
-	if (!rdata || !rdata->pnode || !NLP_CHK_NODE_ACT(rdata->pnode))
-		return FAILED;

OK, I don't get this hunk. lpfc_rport_data_from_scsi_device() cannot return NULL anymore?

I at least expected something like:

  	rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
	if (!rdata || !rdata->pnode)
		return FAILED;
	
	pnode = rdata->pnode;
	if (!NLP_CHK_NODE_ACT(pnode)
		return FAILED;
Quoted 9 lines
drivers/scsi/lpfc/lpfc_scsi.c +3 -1
 	pnode = rdata->pnode;
+	if (!pnode || !NLP_CHK_NODE_ACT(pnode))
+		return FAILED;
 
-	lpfc_cmd = lpfc_get_scsi_buf(phba, pnode);
+	lpfc_cmd = lpfc_get_scsi_buf(phba, rdata->pnode);
 	if (lpfc_cmd == NULL)
 		return FAILED;
 	lpfc_cmd->timeout = phba->cfg_task_mgmt_tmo;

[...]

Signature · 6 lines
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
#4 lore raw

PATCH 2/17 lpfc: NVME Initiator: Base modifications Part A

Quoted 11 lines · Johannes Thumshirn

drivers/scsi/lpfc/lpfc_scsi.c lpfc_send_taskmgmt(struct lpfc_vport *vport, struct scsi_cmnd *cmnd, · line 4963

Quoted 6 lines
drivers/scsi/lpfc/lpfc_scsi.c +0 -2
@@ -4959,11 +4968,11 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct scsi_cmnd *cmnd,
  	int status;
 
  	rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
-	if (!rdata || !rdata->pnode || !NLP_CHK_NODE_ACT(rdata->pnode))
-		return FAILED;

OK, I don't get this hunk. lpfc_rport_data_from_scsi_device() cannot return NULL anymore?

I at least expected something like:

Quoted 7 lines
   	rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
	if (!rdata || !rdata->pnode)
		return FAILED;
	
	pnode = rdata->pnode;
	if (!NLP_CHK_NODE_ACT(pnode)
		return FAILED;

it can and the order of precedence for the if check allows for it. I don't see any difference in what you wrote vs what's there, other than pnode gets an assignment.

Agree with all your other comments and will address them.

-- james

#5 lore raw

PATCH 2/17 lpfc: NVME Initiator: Base modifications Part A

Quoted 18 lines · James Smart
Quoted 14 lines · Johannes Thumshirn

drivers/scsi/lpfc/lpfc_scsi.c lpfc_send_taskmgmt(struct lpfc_vport *vport, struct scsi_cmnd *cmnd, · line 4962

Quoted 5 lines
drivers/scsi/lpfc/lpfc_scsi.c +0 -2
@@ -4959,11 +4968,11 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct scsi_cmnd *cmnd,
 	int status;
 	rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
-	if (!rdata || !rdata->pnode || !NLP_CHK_NODE_ACT(rdata->pnode))
-		return FAILED;

OK, I don't get this hunk. lpfc_rport_data_from_scsi_device() cannot return NULL anymore?

I at least expected something like:

  	rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
	if (!rdata || !rdata->pnode)
		return FAILED;
Quoted 7 lines
Quoted 3 lines
	pnode = rdata->pnode;
	if (!NLP_CHK_NODE_ACT(pnode)
		return FAILED;

it can and the order of precedence for the if check allows for it. I don't see any difference in what you wrote vs what's there, other than pnode gets an assignment.

You're doing:
rdata = lpfc_rport_data_from_scsi_device(cmnd->device); pnode = rdata->pnode;
if (!pnode || !NLP_CHK_NODE_ACT(pnode))

	return FAILED;

So if rdata is already NULL, the pnode = rdata->pnode line will blow up.

Signature · 6 lines
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
#6 lore raw

PATCH 2/17 lpfc: NVME Initiator: Base modifications Part A

Nevermind - I misread the "-" for "+". will fix

-- james