Skip to contentSkip to conversation

Introduce support for multiqueue (MQ) in

PATCH Superseded Karan Tilak Kumar 4 participants 19 messages Oct 20, 2023 – Nov 9, 2023

Subsystems (2)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Karan Tilak Kumar

author maintainer
#0 lore raw

cover Introduce support for multiqueue (MQ) in

Hi Martin,

This cover letter describes the feature: add support for multiqueue (MQ) to fnic driver.

Background: The Virtual Interface Card (VIC) firmware exposes several queues that can be configured for sending IOs and receiving IO responses. Unified Computing System Manager (UCSM) and Intersight Manager (IMM) allows users to configure the number of queues to be used for IOs.

The number of IO queues to be used is stored in a configuration file by the VIC firmware. The fNIC driver reads the configuration file and sets the number of queues to be used. Previously, the driver was hard-coded to use only one queue. With this set of changes, the fNIC driver will configure itself to use multiple queues. This feature takes advantage of the block multiqueue layer to parallelize IOs being sent out of the VIC card.

Here's a brief description of some of the salient patches:

- vnic_scsi.h needs to be in sync with VIC firmware to be able to read the number of queues from the firmware config file. A patch has been created for this.
- In an environment with many fnics (like we see in our customer environments), it is hard to distinguish which fnic is printing logs. Therefore, an fnic number has been included in the logs.
- read the number of queues from the firmware config file.
- include definitions in fnic.h to support multiqueue.
- modify the interrupt service routines (ISRs) to read from the correct registers. The numbers that are used here come from discussions with the VIC firmware team.
- track IO statistics for different queues.
- remove usage of host_lock, and only use fnic_lock in the fnic driver.
- use a hardware queue based spinlock to protect io_req.
- replace the hard-coded zeroth queue with a hardware queue number. This presents a bulk of the changes.
- modify the definition of fnic_queuecommand to accept multiqueue tags.
- improve log messages, and indicate fnic number and multiqueue tags for effective debugging.

Even though the patches have been made into a series, some patches are heavier than others.
But, every effort has been made to keep the purpose of each patch as a single-purpose, and to compile cleanly.

This patchset has been tested as a whole. Therefore, the tested-by fields have been added only to the last two patches
in the set. All the individual patches compile cleanly. However, I've refrained from adding tested-by to
most of the patches, so as to not mislead the reviewer/reader.

A brief note on the unit tests:

1. Increase number of queues to 64. Load driver. Run IOs via Medusa. 12+ hour run successful.
2. Configure multipathing, and run link flaps on single link. IOs drop briefly, but pick up as expected.
3. Configure multipathing, and run link flaps on two links, with a 30 second delay in between. IOs drop briefly, but pick up as expected.

Repeat the above tests with single queue. All tests were successful.

Please consider this patch series for the next merge window.

Thanks and regards,
Karan

Karan Tilak Kumar (13):
scsi: fnic: Modify definitions to sync with VIC firmware
scsi: fnic: Add and use fnic number
scsi: fnic: Add and improve log messages
scsi: fnic: Rename wq_copy to hw_copy_wq
scsi: fnic: Get copy workqueue count and interrupt mode from config
scsi: fnic: Refactor and redefine fnic.h for multiqueue
scsi: fnic: Modify ISRs to support multiqueue(MQ)
scsi: fnic: Define stats to track multiqueue (MQ) IOs
scsi: fnic: Remove usage of host_lock
scsi: fnic: Add support for multiqueue (MQ) in fnic_main.c
scsi: fnic: Use fnic_lock to protect fnic structures in queuecommand
scsi: fnic: Add support for multiqueue (MQ) in fnic driver
scsi: fnic: Improve logs and add support for multiqueue (MQ)

 drivers/scsi/fnic/fnic.h         |  41 +-
 drivers/scsi/fnic/fnic_debugfs.c |   2 +-
 drivers/scsi/fnic/fnic_fcs.c     |  36 +-
 drivers/scsi/fnic/fnic_io.h      |   2 +
 drivers/scsi/fnic/fnic_isr.c     | 166 +++++--
 drivers/scsi/fnic/fnic_main.c    | 156 ++++--
 drivers/scsi/fnic/fnic_res.c     |  48 +-
 drivers/scsi/fnic/fnic_scsi.c    | 797 ++++++++++++++++++-------------
 drivers/scsi/fnic/fnic_stats.h   |   3 +
 drivers/scsi/fnic/fnic_trace.c   |  11 +
 drivers/scsi/fnic/vnic_dev.c     |   4 +
 drivers/scsi/fnic/vnic_scsi.h    |  13 +-
 12 files changed, 835 insertions(+), 444 deletions(-)
Signature · 1 line
2.31.1
author maintainer
#1 lore raw

PATCH 1/13 scsi: fnic: Modify definitions to sync with VIC firmware

VIC firmware has updated definitions.
Modify structure and definitions to sync with the latest VIC firmware.

---
 drivers/scsi/fnic/vnic_scsi.h | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/scsi/fnic/vnic_scsi.h +11 -2
index 4e12f7b32d9d..f715f7942bfe 100644
@@ -26,7 +26,7 @@
 #define VNIC_FNIC_RATOV_MAX                 255000
 
 #define VNIC_FNIC_MAXDATAFIELDSIZE_MIN      256
-#define VNIC_FNIC_MAXDATAFIELDSIZE_MAX      2112
+#define VNIC_FNIC_MAXDATAFIELDSIZE_MAX      2048
 
 #define VNIC_FNIC_FLOGI_RETRIES_MIN         0
 #define VNIC_FNIC_FLOGI_RETRIES_MAX         0xffffffff
@@ -55,7 +55,7 @@
 #define VNIC_FNIC_PORT_DOWN_IO_RETRIES_MAX  255
 
 #define VNIC_FNIC_LUNS_PER_TARGET_MIN       1
-#define VNIC_FNIC_LUNS_PER_TARGET_MAX       1024
+#define VNIC_FNIC_LUNS_PER_TARGET_MAX       4096
 
 /* Device-specific region: scsi configuration */
 struct vnic_fc_config {
@@ -79,10 +79,19 @@ struct vnic_fc_config {
 	u16 ra_tov;
 	u16 intr_timer;
 	u8 intr_timer_type;
+	u8 intr_mode;
+	u8 lun_queue_depth;
+	u8 io_timeout_retry;
+	u16 wq_copy_count;
 };
 
 #define VFCF_FCP_SEQ_LVL_ERR	0x1	/* Enable FCP-2 Error Recovery */
 #define VFCF_PERBI		0x2	/* persistent binding info available */
 #define VFCF_FIP_CAPABLE	0x4	/* firmware can handle FIP */
 
+#define VFCF_FC_INITIATOR         0x20    /* FC Initiator Mode */
+#define VFCF_FC_TARGET            0x40    /* FC Target Mode */
+#define VFCF_FC_NVME_INITIATOR    0x80    /* FC-NVMe Initiator Mode */
+#define VFCF_FC_NVME_TARGET       0x100   /* FC-NVMe Target Mode */
+
 #endif /* _VNIC_SCSI_H_ */
Signature · 1 line
2.31.1
author maintainer
#2 lore raw

PATCH 2/13 scsi: fnic: Add and use fnic number

In reply to Karan Tilak Kumar

Add fnic_num in fnic.h to identify fnic in a multi-fnic environment. Increment and set the fnic number during driver load in fnic_probe. Replace the host number with fnic number in debugfs.

---
 drivers/scsi/fnic/fnic.h         | 1 +
 drivers/scsi/fnic/fnic_debugfs.c | 2 +-
 drivers/scsi/fnic/fnic_main.c    | 6 +++++-
 3 files changed, 7 insertions(+), 2 deletions(-)
drivers/scsi/fnic/fnic.h +1 -0
index 93c68931a593..c6c549c633b1 100644
@@ -216,6 +216,7 @@ struct fnic_event {
 
 /* Per-instance private data structure */
 struct fnic {
+	int fnic_num;
 	struct fc_lport *lport;
 	struct fcoe_ctlr ctlr;		/* FIP FCoE controller structure */
 	struct vnic_dev_bar bar0;
drivers/scsi/fnic/fnic_debugfs.c +1 -1
index c4d9ed0d7d75..fac617672868 100644
@@ -676,7 +676,7 @@ void fnic_stats_debugfs_init(struct fnic *fnic)
 {
 	char name[16];
 
-	snprintf(name, sizeof(name), "host%d", fnic->lport->host->host_no);
+	snprintf(name, sizeof(name), "fnic%d", fnic->fnic_num);
 
 	fnic->fnic_stats_debugfs_host = debugfs_create_dir(name,
 						fnic_stats_debugfs_root);
drivers/scsi/fnic/fnic_main.c +5 -1
index 984bc5fc55e2..ea7b1ba27ac7 100644
@@ -84,6 +84,9 @@ static struct libfc_function_template fnic_transport_template = {
 	.exch_mgr_reset = fnic_exch_mgr_reset
 };
 
+
+atomic_t fnic_num;
+
 static int fnic_slave_alloc(struct scsi_device *sdev)
 {
 	struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
@@ -587,6 +590,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	int i;
 	unsigned long flags;
 
+	atomic_inc(&fnic_num);
 	/*
 	 * Allocate SCSI Host and set up association between host,
 	 * local port, and fnic
@@ -608,7 +612,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		 host->host_no);
 
 	host->transportt = fnic_fc_transport;
-
+	fnic->fnic_num = atomic_read(&fnic_num);
 	fnic_stats_debugfs_init(fnic);
 
 	/* Setup PCI resources */
Signature · 1 line
2.31.1
author maintainer
#3 lore raw

PATCH 3/13 scsi: fnic: Add and improve log messages

In reply to Karan Tilak Kumar

Add link related log messages in fnic_fcs.c, Improve log message in fnic_fcs.c,
Add log message in vnic_dev.c.

---
 drivers/scsi/fnic/fnic_fcs.c | 36 ++++++++++++++++++++++++------------
 drivers/scsi/fnic/vnic_dev.c |  4 ++++
 2 files changed, 28 insertions(+), 12 deletions(-)
drivers/scsi/fnic/fnic_fcs.c +24 -12
index 55632c67a8f2..203ffec625a4 100644
@@ -64,8 +64,8 @@ void fnic_handle_link(struct work_struct *work)
 			new_port_speed);
 	if (old_port_speed != new_port_speed)
 		FNIC_MAIN_DBG(KERN_INFO, fnic->lport->host,
-				"Current vnic speed set to :  %llu\n",
-				new_port_speed);
+				"fnic<%d>: %s: %d: Current vnic speed set to: %llu\n",
+				fnic->fnic_num, __func__, __LINE__, new_port_speed);
 
 	switch (vnic_dev_port_speed(fnic->vdev)) {
 	case DCEM_PORTSPEED_10G:
@@ -102,6 +102,9 @@ void fnic_handle_link(struct work_struct *work)
 			fnic_fc_trace_set_data(fnic->lport->host->host_no,
 				FNIC_FC_LE, "Link Status: DOWN->DOWN",
 				strlen("Link Status: DOWN->DOWN"));
+			FNIC_MAIN_DBG(KERN_INFO, fnic->lport->host,
+					"fnic<%d>: %s: %d: down->down\n",
+					fnic->fnic_num, __func__, __LINE__);
 		} else {
 			if (old_link_down_cnt != fnic->link_down_cnt) {
 				/* UP -> DOWN -> UP */
@@ -128,8 +131,9 @@ void fnic_handle_link(struct work_struct *work)
 					fnic_fcoe_send_vlan_req(fnic);
 					return;
 				}
-				FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
-					     "link up\n");
+				FNIC_MAIN_DBG(KERN_INFO, fnic->lport->host,
+						"fnic<%d>: %s: %d: up->down->up: Link up\n",
+						fnic->fnic_num, __func__, __LINE__);
 				fcoe_ctlr_link_up(&fnic->ctlr);
 			} else {
 				/* UP -> UP */
@@ -138,6 +142,9 @@ void fnic_handle_link(struct work_struct *work)
 					fnic->lport->host->host_no, FNIC_FC_LE,
 					"Link Status: UP_UP",
 					strlen("Link Status: UP_UP"));
+				FNIC_MAIN_DBG(KERN_INFO, fnic->lport->host,
+						"fnic<%d>: %s: %d: up->up\n",
+						fnic->fnic_num, __func__, __LINE__);
 			}
 		}
 	} else if (fnic->link_status) {
@@ -153,7 +160,9 @@ void fnic_handle_link(struct work_struct *work)
 			return;
 		}
 
-		FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "link up\n");
+		FNIC_MAIN_DBG(KERN_INFO, fnic->lport->host,
+				"fnic<%d>: %s: %d: down->up: Link up\n",
+				fnic->fnic_num, __func__, __LINE__);
 		fnic_fc_trace_set_data(fnic->lport->host->host_no, FNIC_FC_LE,
 				       "Link Status: DOWN_UP", strlen("Link Status: DOWN_UP"));
 		fcoe_ctlr_link_up(&fnic->ctlr);
@@ -161,7 +170,9 @@ void fnic_handle_link(struct work_struct *work)
 		/* UP -> DOWN */
 		fnic->lport->host_stats.link_failure_count++;
 		spin_unlock_irqrestore(&fnic->fnic_lock, flags);
-		FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "link down\n");
+		FNIC_MAIN_DBG(KERN_INFO, fnic->lport->host,
+				"fnic<%d>: %s: %d: up->down: Link down\n",
+				fnic->fnic_num, __func__, __LINE__);
 		fnic_fc_trace_set_data(
 			fnic->lport->host->host_no, FNIC_FC_LE,
 			"Link Status: UP_DOWN",
@@ -763,8 +774,9 @@ void fnic_set_port_id(struct fc_lport *lport, u32 port_id, struct fc_frame *fp)
 	u8 *mac;
 	int ret;
 
-	FNIC_FCS_DBG(KERN_DEBUG, lport->host, "set port_id %x fp %p\n",
-		     port_id, fp);
+	FNIC_FCS_DBG(KERN_DEBUG, lport->host,
+			"fnic<%d>: %s: %d: set port_id 0x%x fp 0x%p\n",
+			fnic->fnic_num, __func__, __LINE__, port_id, fp);
 
 	/*
 	 * If we're clearing the FC_ID, change to use the ctl_src_addr.
@@ -790,10 +802,10 @@ void fnic_set_port_id(struct fc_lport *lport, u32 port_id, struct fc_frame *fp)
 	if (fnic->state == FNIC_IN_ETH_MODE || fnic->state == FNIC_IN_FC_MODE)
 		fnic->state = FNIC_IN_ETH_TRANS_FC_MODE;
 	else {
-		FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
-			     "Unexpected fnic state %s while"
-			     " processing flogi resp\n",
-			     fnic_state_to_str(fnic->state));
+		FNIC_FCS_DBG(KERN_ERR, fnic->lport->host,
+			     "fnic<%d>: %s: %d: Unexpected fnic state: %s processing FLOGI response",
+			     fnic->fnic_num, __func__, __LINE__,
+				 fnic_state_to_str(fnic->state));
 		spin_unlock_irq(&fnic->fnic_lock);
 		return;
 	}
drivers/scsi/fnic/vnic_dev.c +4 -0
index 3e5b437c0492..e0b173cc9d5f 100644
@@ -143,6 +143,10 @@ static int vnic_dev_discover_res(struct vnic_dev *vdev,
 		vdev->res[type].vaddr = (char __iomem *)bar->vaddr + bar_offset;
 	}
 
+	pr_info("res_type_wq: %d res_type_rq: %d res_type_cq: %d res_type_intr_ctrl: %d\n",
+		vdev->res[RES_TYPE_WQ].count, vdev->res[RES_TYPE_RQ].count,
+		vdev->res[RES_TYPE_CQ].count, vdev->res[RES_TYPE_INTR_CTRL].count);
+
 	return 0;
 }
 
Signature · 1 line
2.31.1
author maintainer
#4 lore raw

PATCH 4/13 scsi: fnic: Rename wq_copy to hw_copy_wq

In reply to Karan Tilak Kumar

Rename wq_copy to hw_copy_wq to accurately describe the copy workqueue. This will also help distinguish this data structure from software data structures that can be introduced.

---
 drivers/scsi/fnic/fnic.h      |  2 +-
 drivers/scsi/fnic/fnic_isr.c  |  2 +-
 drivers/scsi/fnic/fnic_main.c |  8 ++++----
 drivers/scsi/fnic/fnic_res.c  |  6 +++---
 drivers/scsi/fnic/fnic_scsi.c | 12 ++++++------
 5 files changed, 15 insertions(+), 15 deletions(-)
drivers/scsi/fnic/fnic.h +1 -1
index c6c549c633b1..9fd01a867788 100644
@@ -301,7 +301,7 @@ struct fnic {
 	/*** FIP related data members  -- end ***/
 
 	/* copy work queue cache line section */
-	____cacheline_aligned struct vnic_wq_copy wq_copy[FNIC_WQ_COPY_MAX];
+	____cacheline_aligned struct vnic_wq_copy hw_copy_wq[FNIC_WQ_COPY_MAX];
 	/* completion queue cache line section */
 	____cacheline_aligned struct vnic_cq cq[FNIC_CQ_MAX];
 
drivers/scsi/fnic/fnic_isr.c +1 -1
index 8896758fed8c..dff9689023e4 100644
@@ -224,7 +224,7 @@ int fnic_set_intr_mode(struct fnic *fnic)
 {
 	unsigned int n = ARRAY_SIZE(fnic->rq);
 	unsigned int m = ARRAY_SIZE(fnic->wq);
-	unsigned int o = ARRAY_SIZE(fnic->wq_copy);
+	unsigned int o = ARRAY_SIZE(fnic->hw_copy_wq);
 
 	/*
 	 * Set interrupt mode (INTx, MSI, MSI-X) depending
drivers/scsi/fnic/fnic_main.c +4 -4
index ea7b1ba27ac7..887e3e168579 100644
@@ -357,7 +357,7 @@ void fnic_log_q_error(struct fnic *fnic)
 	}
 
 	for (i = 0; i < fnic->wq_copy_count; i++) {
-		error_status = ioread32(&fnic->wq_copy[i].ctrl->error_status);
+		error_status = ioread32(&fnic->hw_copy_wq[i].ctrl->error_status);
 		if (error_status)
 			shost_printk(KERN_ERR, fnic->lport->host,
 				     "CWQ[%d] error_status"
@@ -494,7 +494,7 @@ static int fnic_cleanup(struct fnic *fnic)
 			return err;
 	}
 	for (i = 0; i < fnic->wq_copy_count; i++) {
-		err = vnic_wq_copy_disable(&fnic->wq_copy[i]);
+		err = vnic_wq_copy_disable(&fnic->hw_copy_wq[i]);
 		if (err)
 			return err;
 	}
@@ -510,7 +510,7 @@ static int fnic_cleanup(struct fnic *fnic)
 	for (i = 0; i < fnic->rq_count; i++)
 		vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf);
 	for (i = 0; i < fnic->wq_copy_count; i++)
-		vnic_wq_copy_clean(&fnic->wq_copy[i],
+		vnic_wq_copy_clean(&fnic->hw_copy_wq[i],
 				   fnic_wq_copy_cleanup_handler);
 
 	for (i = 0; i < fnic->cq_count; i++)
@@ -901,7 +901,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	for (i = 0; i < fnic->raw_wq_count; i++)
 		vnic_wq_enable(&fnic->wq[i]);
 	for (i = 0; i < fnic->wq_copy_count; i++)
-		vnic_wq_copy_enable(&fnic->wq_copy[i]);
+		vnic_wq_copy_enable(&fnic->hw_copy_wq[i]);
 
 	fc_fabric_login(lp);
 
drivers/scsi/fnic/fnic_res.c +3 -3
index a1c9cfcace7f..109316cc4ad9 100644
@@ -203,7 +203,7 @@ void fnic_free_vnic_resources(struct fnic *fnic)
 		vnic_wq_free(&fnic->wq[i]);
 
 	for (i = 0; i < fnic->wq_copy_count; i++)
-		vnic_wq_copy_free(&fnic->wq_copy[i]);
+		vnic_wq_copy_free(&fnic->hw_copy_wq[i]);
 
 	for (i = 0; i < fnic->rq_count; i++)
 		vnic_rq_free(&fnic->rq[i]);
@@ -250,7 +250,7 @@ int fnic_alloc_vnic_resources(struct fnic *fnic)
 
 	/* Allocate Copy WQs used for SCSI IOs */
 	for (i = 0; i < fnic->wq_copy_count; i++) {
-		err = vnic_wq_copy_alloc(fnic->vdev, &fnic->wq_copy[i],
+		err = vnic_wq_copy_alloc(fnic->vdev, &fnic->hw_copy_wq[i],
 			(fnic->raw_wq_count + i),
 			fnic->config.wq_copy_desc_count,
 			sizeof(struct fcpio_host_req));
@@ -357,7 +357,7 @@ int fnic_alloc_vnic_resources(struct fnic *fnic)
 	}
 
 	for (i = 0; i < fnic->wq_copy_count; i++) {
-		vnic_wq_copy_init(&fnic->wq_copy[i],
+		vnic_wq_copy_init(&fnic->hw_copy_wq[i],
 				  0 /* cq_index 0 - always */,
 				  error_interrupt_enable,
 				  error_interrupt_offset);
drivers/scsi/fnic/fnic_scsi.c +6 -6
index 9761b2c9db48..3498a8d670b1 100644
@@ -193,7 +193,7 @@ __fnic_set_state_flags(struct fnic *fnic, unsigned long st_flags,
  */
 int fnic_fw_reset_handler(struct fnic *fnic)
 {
-	struct vnic_wq_copy *wq = &fnic->wq_copy[0];
+	struct vnic_wq_copy *wq = &fnic->hw_copy_wq[0];
 	int ret = 0;
 	unsigned long flags;
 
@@ -246,7 +246,7 @@ int fnic_fw_reset_handler(struct fnic *fnic)
  */
 int fnic_flogi_reg_handler(struct fnic *fnic, u32 fc_id)
 {
-	struct vnic_wq_copy *wq = &fnic->wq_copy[0];
+	struct vnic_wq_copy *wq = &fnic->hw_copy_wq[0];
 	enum fcpio_flogi_reg_format_type format;
 	struct fc_lport *lp = fnic->lport;
 	u8 gw_mac[ETH_ALEN];
@@ -551,7 +551,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 	fnic_priv(sc)->flags |= FNIC_IO_INITIALIZED;
 
 	/* create copy wq desc and enqueue it */
-	wq = &fnic->wq_copy[0];
+	wq = &fnic->hw_copy_wq[0];
 	ret = fnic_queue_wq_copy_desc(fnic, wq, io_req, sc, sg_count);
 	if (ret) {
 		/*
@@ -782,7 +782,7 @@ static inline void fnic_fcpio_ack_handler(struct fnic *fnic,
 	u64 *ox_id_tag = (u64 *)(void *)desc;
 
 	/* mark the ack state */
-	wq = &fnic->wq_copy[cq_index - fnic->raw_wq_count - fnic->rq_count];
+	wq = &fnic->hw_copy_wq[cq_index - fnic->raw_wq_count - fnic->rq_count];
 	spin_lock_irqsave(&fnic->wq_copy_lock[0], flags);
 
 	fnic->fnic_stats.misc_stats.last_ack_time = jiffies;
@@ -1486,7 +1486,7 @@ static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag,
 					  u32 task_req, u8 *fc_lun,
 					  struct fnic_io_req *io_req)
 {
-	struct vnic_wq_copy *wq = &fnic->wq_copy[0];
+	struct vnic_wq_copy *wq = &fnic->hw_copy_wq[0];
 	struct Scsi_Host *host = fnic->lport->host;
 	struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats;
 	unsigned long flags;
@@ -1932,7 +1932,7 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic,
 				       struct scsi_cmnd *sc,
 				       struct fnic_io_req *io_req)
 {
-	struct vnic_wq_copy *wq = &fnic->wq_copy[0];
+	struct vnic_wq_copy *wq = &fnic->hw_copy_wq[0];
 	struct Scsi_Host *host = fnic->lport->host;
 	struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats;
 	struct scsi_lun fc_lun;
Signature · 1 line
2.31.1
author maintainer
#5 lore raw

PATCH 5/13 scsi: fnic: Get copy workqueue count and interrupt mode from config

In reply to Karan Tilak Kumar

Get the copy workqueue count and interrupt mode from the configuration. The config can be changed via UCSM. Add logs to print the interrupt mode and copy workqueue count. Add logs to print the vNIC resources.

---
 drivers/scsi/fnic/fnic_res.c | 42 ++++++++++++++++++++++++++++++------
 1 file changed, 36 insertions(+), 6 deletions(-)
drivers/scsi/fnic/fnic_res.c +36 -6
index 109316cc4ad9..33dd27f6f24e 100644
@@ -57,6 +57,8 @@ int fnic_get_vnic_config(struct fnic *fnic)
 	GET_CONFIG(port_down_timeout);
 	GET_CONFIG(port_down_io_retries);
 	GET_CONFIG(luns_per_tgt);
+	GET_CONFIG(intr_mode);
+	GET_CONFIG(wq_copy_count);
 
 	c->wq_enet_desc_count =
 		min_t(u32, VNIC_FNIC_WQ_DESCS_MAX,
@@ -131,6 +133,12 @@ int fnic_get_vnic_config(struct fnic *fnic)
 	c->intr_timer = min_t(u16, VNIC_INTR_TIMER_MAX, c->intr_timer);
 	c->intr_timer_type = c->intr_timer_type;
 
+	/* for older firmware, GET_CONFIG will not return anything */
+	if (c->wq_copy_count == 0)
+		c->wq_copy_count = 1;
+
+	c->wq_copy_count = min_t(u16, FNIC_WQ_COPY_MAX, c->wq_copy_count);
+
 	shost_printk(KERN_INFO, fnic->lport->host,
 		     "vNIC MAC addr %pM "
 		     "wq/wq_copy/rq %d/%d/%d\n",
@@ -161,6 +169,10 @@ int fnic_get_vnic_config(struct fnic *fnic)
 	shost_printk(KERN_INFO, fnic->lport->host,
 		     "vNIC port dn io retries %d port dn timeout %d\n",
 		     c->port_down_io_retries, c->port_down_timeout);
+	shost_printk(KERN_INFO, fnic->lport->host,
+			"vNIC wq_copy_count: %d\n", c->wq_copy_count);
+	shost_printk(KERN_INFO, fnic->lport->host,
+			"vNIC intr mode: %d\n", c->intr_mode);
 
 	return 0;
 }
@@ -187,12 +199,25 @@ int fnic_set_nic_config(struct fnic *fnic, u8 rss_default_cpu,
 void fnic_get_res_counts(struct fnic *fnic)
 {
 	fnic->wq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_WQ);
-	fnic->raw_wq_count = fnic->wq_count - 1;
-	fnic->wq_copy_count = fnic->wq_count - fnic->raw_wq_count;
+	fnic->raw_wq_count = 1;
+	fnic->wq_copy_count = fnic->config.wq_copy_count;
 	fnic->rq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_RQ);
 	fnic->cq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_CQ);
 	fnic->intr_count = vnic_dev_get_res_count(fnic->vdev,
 		RES_TYPE_INTR_CTRL);
+
+	shost_printk(KERN_INFO, fnic->lport->host,
+		"vNIC fw resources wq_count: %d\n", fnic->wq_count);
+	shost_printk(KERN_INFO, fnic->lport->host,
+		"vNIC fw resources raw_wq_count: %d\n", fnic->raw_wq_count);
+	shost_printk(KERN_INFO, fnic->lport->host,
+		"vNIC fw resources wq_copy_count: %d\n", fnic->wq_copy_count);
+	shost_printk(KERN_INFO, fnic->lport->host,
+		"vNIC fw resources rq_count: %d\n", fnic->rq_count);
+	shost_printk(KERN_INFO, fnic->lport->host,
+		"vNIC fw resources cq_count: %d\n", fnic->cq_count);
+	shost_printk(KERN_INFO, fnic->lport->host,
+		"vNIC fw resources intr_count: %d\n", fnic->intr_count);
 }
 
 void fnic_free_vnic_resources(struct fnic *fnic)
@@ -234,10 +259,15 @@ int fnic_alloc_vnic_resources(struct fnic *fnic)
 		     intr_mode == VNIC_DEV_INTR_MODE_MSIX ?
 		     "MSI-X" : "unknown");
 
-	shost_printk(KERN_INFO, fnic->lport->host, "vNIC resources avail: "
-		     "wq %d cp_wq %d raw_wq %d rq %d cq %d intr %d\n",
-		     fnic->wq_count, fnic->wq_copy_count, fnic->raw_wq_count,
-		     fnic->rq_count, fnic->cq_count, fnic->intr_count);
+	shost_printk(KERN_INFO, fnic->lport->host,
+			"vNIC resources avail: wq %d cp_wq %d raw_wq %d rq %d",
+			fnic->wq_count, fnic->wq_copy_count,
+			fnic->raw_wq_count, fnic->rq_count);
+
+	shost_printk(KERN_INFO, fnic->lport->host,
+			"vNIC resources avail: cq %d intr %d cpy-wq desc count %d\n",
+			fnic->cq_count, fnic->intr_count,
+			fnic->config.wq_copy_desc_count);
 
 	/* Allocate Raw WQ used for FCS frames */
 	for (i = 0; i < fnic->raw_wq_count; i++) {
Signature · 1 line
2.31.1
author maintainer
#6 lore raw

PATCH 6/13 scsi: fnic: Refactor and redefine fnic.h for multiqueue

In reply to Karan Tilak Kumar

Refactor and re-define values in fnic.h to implement multiqueue(MQ) functionality.

VIC firmware allows fnic to create up to 64 copy workqueues. Update the copy workqueue max to 64. Modify the interrupt index to be in sync with the firmware to support MQ.
Add irq number to the MSIX entry.
Define a software workqueue table to track the status of io_reqs. Define a base for the copy workqueue.

---
 drivers/scsi/fnic/fnic.h | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)
drivers/scsi/fnic/fnic.h +22 -8
index 9fd01a867788..f4390fc96323 100644
@@ -163,12 +163,21 @@ do {								\
 #define FNIC_MAIN_NOTE(kern_level, host, fmt, args...)          \
 	shost_printk(kern_level, host, fmt, ##args)
 
+#define FNIC_WQ_COPY_MAX 64
+#define FNIC_WQ_MAX 1
+#define FNIC_RQ_MAX 1
+#define FNIC_CQ_MAX (FNIC_WQ_COPY_MAX + FNIC_WQ_MAX + FNIC_RQ_MAX)
+#define FNIC_DFLT_IO_COMPLETIONS 256
+
+#define FNIC_MQ_CQ_INDEX        2
+
 extern const char *fnic_state_str[];
 
 enum fnic_intx_intr_index {
 	FNIC_INTX_WQ_RQ_COPYWQ,
-	FNIC_INTX_ERR,
+	FNIC_INTX_DUMMY,
 	FNIC_INTX_NOTIFY,
+	FNIC_INTX_ERR,
 	FNIC_INTX_INTR_MAX,
 };
 
@@ -176,7 +185,7 @@ enum fnic_msix_intr_index {
 	FNIC_MSIX_RQ,
 	FNIC_MSIX_WQ,
 	FNIC_MSIX_WQ_COPY,
-	FNIC_MSIX_ERR_NOTIFY,
+	FNIC_MSIX_ERR_NOTIFY = FNIC_MSIX_WQ_COPY + FNIC_WQ_COPY_MAX,
 	FNIC_MSIX_INTR_MAX,
 };
 
@@ -185,6 +194,7 @@ struct fnic_msix_entry {
 	char devname[IFNAMSIZ + 11];
 	irqreturn_t (*isr)(int, void *);
 	void *devid;
+	int irq_num;
 };
 
 enum fnic_state {
@@ -194,12 +204,6 @@ enum fnic_state {
 	FNIC_IN_ETH_TRANS_FC_MODE,
 };
 
-#define FNIC_WQ_COPY_MAX 1
-#define FNIC_WQ_MAX 1
-#define FNIC_RQ_MAX 1
-#define FNIC_CQ_MAX (FNIC_WQ_COPY_MAX + FNIC_WQ_MAX + FNIC_RQ_MAX)
-#define FNIC_DFLT_IO_COMPLETIONS 256
-
 struct mempool;
 
 enum fnic_evt {
@@ -214,6 +218,13 @@ struct fnic_event {
 	enum fnic_evt event;
 };
 
+struct fnic_cpy_wq {
+	unsigned long hw_lock_flags;
+	u16 active_ioreq_count;
+	u16 ioreq_table_size;
+	____cacheline_aligned struct fnic_io_req **io_req_table;
+};
+
 /* Per-instance private data structure */
 struct fnic {
 	int fnic_num;
@@ -283,6 +294,7 @@ struct fnic {
 	mempool_t *io_sgl_pool[FNIC_SGL_NUM_CACHES];
 	spinlock_t io_req_lock[FNIC_IO_LOCKS];	/* locks for scsi cmnds */
 
+	unsigned int cpy_wq_base;
 	struct work_struct link_work;
 	struct work_struct frame_work;
 	struct sk_buff_head frame_queue;
@@ -302,6 +314,8 @@ struct fnic {
 
 	/* copy work queue cache line section */
 	____cacheline_aligned struct vnic_wq_copy hw_copy_wq[FNIC_WQ_COPY_MAX];
+	____cacheline_aligned struct fnic_cpy_wq sw_copy_wq[FNIC_WQ_COPY_MAX];
+
 	/* completion queue cache line section */
 	____cacheline_aligned struct vnic_cq cq[FNIC_CQ_MAX];
 
Signature · 1 line
2.31.1
author maintainer
#7 lore raw

PATCH 7/13 scsi: fnic: Modify ISRs to support multiqueue(MQ)

In reply to Karan Tilak Kumar

Modify interrupt service routines for INTx, MSI, and MSI-x to support multiqueue.
Modify parameter list of fnic_wq_copy_cmpl_handler to take cq_index.
Modify fnic_cleanup function to use the new function call of fnic_wq_copy_cmpl_handler. Refactor code to set
interrupt mode to MSI-x to a new function.
Add a new stat for intx_dummy.

---
 drivers/scsi/fnic/fnic.h       |   2 +-
 drivers/scsi/fnic/fnic_isr.c   | 164 ++++++++++++++++++++++++---------
 drivers/scsi/fnic/fnic_main.c  |   4 +-
 drivers/scsi/fnic/fnic_scsi.c  |  38 +++-----
 drivers/scsi/fnic/fnic_stats.h |   1 +
 5 files changed, 139 insertions(+), 70 deletions(-)
drivers/scsi/fnic/fnic.h +1 -1
index f4390fc96323..692175cfa557 100644
@@ -369,7 +369,7 @@ void fnic_scsi_cleanup(struct fc_lport *);
 void fnic_scsi_abort_io(struct fc_lport *);
 void fnic_empty_scsi_cleanup(struct fc_lport *);
 void fnic_exch_mgr_reset(struct fc_lport *, u32, u32);
-int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int);
+int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do, unsigned int cq_index);
 int fnic_wq_cmpl_handler(struct fnic *fnic, int);
 int fnic_flogi_reg_handler(struct fnic *fnic, u32);
 void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
drivers/scsi/fnic/fnic_isr.c +120 -44

224 lines not on this page · raw message

drivers/scsi/fnic/fnic_main.c +3 -1
index 887e3e168579..66e85754c1d6 100644
@@ -478,6 +478,7 @@ static int fnic_cleanup(struct fnic *fnic)
 {
 	unsigned int i;
 	int err;
+	int raw_wq_rq_counts;
 
 	vnic_dev_disable(fnic->vdev);
 	for (i = 0; i < fnic->intr_count; i++)
@@ -497,10 +498,11 @@ static int fnic_cleanup(struct fnic *fnic)
 		err = vnic_wq_copy_disable(&fnic->hw_copy_wq[i]);
 		if (err)
 			return err;
+		raw_wq_rq_counts = fnic->raw_wq_count + fnic->rq_count;
+		fnic_wq_copy_cmpl_handler(fnic, -1, i + raw_wq_rq_counts);
 	}
 
 	/* Clean up completed IOs and FCS frames */
-	fnic_wq_copy_cmpl_handler(fnic, io_completions);
 	fnic_wq_cmpl_handler(fnic, -1);
 	fnic_rq_cmpl_handler(fnic, -1);
 
drivers/scsi/fnic/fnic_scsi.c +14 -24
index 3498a8d670b1..f32781f8fdd0 100644
@@ -1303,10 +1303,8 @@ static int fnic_fcpio_cmpl_handler(struct vnic_dev *vdev,
  * fnic_wq_copy_cmpl_handler
  * Routine to process wq copy
  */
-int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do)
+int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do, unsigned int cq_index)
 {
-	unsigned int wq_work_done = 0;
-	unsigned int i, cq_index;
 	unsigned int cur_work_done;
 	struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats;
 	u64 start_jiffies = 0;
@@ -1314,28 +1312,20 @@ int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do)
 	u64 delta_jiffies = 0;
 	u64 delta_ms = 0;
 
-	for (i = 0; i < fnic->wq_copy_count; i++) {
-		cq_index = i + fnic->raw_wq_count + fnic->rq_count;
-
-		start_jiffies = jiffies;
-		cur_work_done = vnic_cq_copy_service(&fnic->cq[cq_index],
-						     fnic_fcpio_cmpl_handler,
-						     copy_work_to_do);
-		end_jiffies = jiffies;
-
-		wq_work_done += cur_work_done;
-		delta_jiffies = end_jiffies - start_jiffies;
-		if (delta_jiffies >
-			(u64) atomic64_read(&misc_stats->max_isr_jiffies)) {
-			atomic64_set(&misc_stats->max_isr_jiffies,
-					delta_jiffies);
-			delta_ms = jiffies_to_msecs(delta_jiffies);
-			atomic64_set(&misc_stats->max_isr_time_ms, delta_ms);
-			atomic64_set(&misc_stats->corr_work_done,
-					cur_work_done);
-		}
+	start_jiffies = jiffies;
+	cur_work_done = vnic_cq_copy_service(&fnic->cq[cq_index],
+					fnic_fcpio_cmpl_handler,
+					copy_work_to_do);
+	end_jiffies = jiffies;
+	delta_jiffies = end_jiffies - start_jiffies;
+	if (delta_jiffies > (u64) atomic64_read(&misc_stats->max_isr_jiffies)) {
+		atomic64_set(&misc_stats->max_isr_jiffies, delta_jiffies);
+		delta_ms = jiffies_to_msecs(delta_jiffies);
+		atomic64_set(&misc_stats->max_isr_time_ms, delta_ms);
+		atomic64_set(&misc_stats->corr_work_done, cur_work_done);
 	}
-	return wq_work_done;
+
+	return cur_work_done;
 }
 
 static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data)
drivers/scsi/fnic/fnic_stats.h +1 -0
index bdf639eef8cf..07d1556e3c32 100644
@@ -103,6 +103,7 @@ struct misc_stats {
 	atomic64_t rport_not_ready;
 	atomic64_t frame_errors;
 	atomic64_t current_port_speed;
+	atomic64_t intx_dummy;
 };
 
 struct fnic_stats {
Signature · 1 line
2.31.1
#8 lore raw

Re: [PATCH 07/13] scsi: fnic: Modify ISRs to support multiqueue(MQ)

kernel test robot noticed the following build warnings:

Hi Karan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on jejb-scsi/for-next next-20231025] [cannot apply to linus/master v6.6-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Karan-Tilak-Kumar/scsi-fnic-Modify-definitions-to-sync-with-VIC-firmware/20231021-031259
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
patch link:    https://lore.kernel.org/r/20231020190629.338623-8-kartilak%40cisco.com
patch subject: [PATCH 07/13] scsi: fnic: Modify ISRs to support multiqueue(MQ)
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20231025/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231025/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/scsi/fnic/fnic_isr.c:242:5: warning: no previous prototype for 'fnic_set_intr_mode_msix' [-Wmissing-prototypes]

242 | int fnic_set_intr_mode_msix(struct fnic *fnic)
| ^~~~~~~~~~~~~~~~~~~~~~~

vim +/fnic_set_intr_mode_msix +242 drivers/scsi/fnic/fnic_isr.c

241

 > 242	int fnic_set_intr_mode_msix(struct fnic *fnic)

243 {
244 unsigned int n = ARRAY_SIZE(fnic->rq);
245 unsigned int m = ARRAY_SIZE(fnic->wq);
246 unsigned int o = ARRAY_SIZE(fnic->hw_copy_wq);
247 unsigned int min_irqs = n + m + 1 + 1; /*rq, raw wq, wq, err*/
248
249 /*
250 * We need n RQs, m WQs, o Copy WQs, n+m+o CQs, and n+m+o+1 INTRs
251 * (last INTR is used for WQ/RQ errors and notification area)
252 */
253 FNIC_ISR_DBG(KERN_INFO, fnic->lport->host,
254 "fnic<%d>: %s: %d: rq-array size: %d wq-array size: %d copy-wq array size: %d\n",
255 fnic->fnic_num, __func__, __LINE__, n, m, o);
256 FNIC_ISR_DBG(KERN_INFO, fnic->lport->host,
257 "fnic<%d>: %s: %d: rq_count: %d raw_wq_count: %d wq_copy_count: %d cq_count: %d\n",
258 fnic->fnic_num, __func__, __LINE__, fnic->rq_count, fnic->raw_wq_count,
259 fnic->wq_copy_count, fnic->cq_count);
260
261 if (fnic->rq_count <= n && fnic->raw_wq_count <= m &&
262 fnic->wq_copy_count <= o) {
263 int vec_count = 0;
264 int vecs = fnic->rq_count + fnic->raw_wq_count + fnic->wq_copy_count + 1;
265
266 vec_count = pci_alloc_irq_vectors(fnic->pdev, min_irqs, vecs,
267 PCI_IRQ_MSIX | PCI_IRQ_AFFINITY);
268 FNIC_ISR_DBG(KERN_INFO, fnic->lport->host,
269 "fnic<%d>: %s: %d: allocated %d MSI-X vectors\n",
270 fnic->fnic_num, __func__, __LINE__, vec_count);
271
272 if (vec_count > 0) {
273 if (vec_count < vecs) {
274 FNIC_ISR_DBG(KERN_ERR, fnic->lport->host,
275 "fnic<%d>: %s: %d: interrupts number mismatch: vec_count: %d vecs: %d\n",
276 fnic->fnic_num, __func__, __LINE__, vec_count, vecs);
277 if (vec_count < min_irqs) {
278 FNIC_ISR_DBG(KERN_ERR, fnic->lport->host,
279 "fnic<%d>: %s: %d: no interrupts for copy wq\n",
280 fnic->fnic_num, __func__, __LINE__);
281 return 1;
282 }
283 }
284
285 fnic->rq_count = n;
286 fnic->raw_wq_count = m;
287 fnic->cpy_wq_base = fnic->rq_count + fnic->raw_wq_count;
288 fnic->wq_copy_count = vec_count - n - m - 1;
289 fnic->wq_count = fnic->raw_wq_count + fnic->wq_copy_count;
290 if (fnic->cq_count != vec_count - 1) {
291 FNIC_ISR_DBG(KERN_ERR, fnic->lport->host,
292 "fnic<%d>: %s: %d: CQ count: %d does not match MSI-X vector count: %d\n",
293 fnic->fnic_num, __func__, __LINE__, fnic->cq_count, vec_count);
294 fnic->cq_count = vec_count - 1;
295 }
296 fnic->intr_count = vec_count;
297 fnic->err_intr_offset = fnic->rq_count + fnic->wq_count;
298
299 FNIC_ISR_DBG(KERN_INFO, fnic->lport->host,
300 "fnic<%d>: %s: %d: rq_count: %d raw_wq_count: %d cpy_wq_base: %d\n",
301 fnic->fnic_num, __func__, __LINE__, fnic->rq_count,
302 fnic->raw_wq_count, fnic->cpy_wq_base);
303
304 FNIC_ISR_DBG(KERN_INFO, fnic->lport->host,
305 "fnic<%d>: %s: %d: wq_copy_count: %d wq_count: %d cq_count: %d\n",
306 fnic->fnic_num, __func__, __LINE__, fnic->wq_copy_count,
307 fnic->wq_count, fnic->cq_count);
308
309 FNIC_ISR_DBG(KERN_INFO, fnic->lport->host,
310 "fnic<%d>: %s: %d: intr_count: %d err_intr_offset: %u",
311 fnic->fnic_num, __func__, __LINE__, fnic->intr_count,
312 fnic->err_intr_offset);
313
314 vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_MSIX);
315 FNIC_ISR_DBG(KERN_INFO, fnic->lport->host,
316 "fnic<%d>: %s: %d: fnic using MSI-X\n", fnic->fnic_num,
317 __func__, __LINE__);
318 return 0;
319 }
320 }
321 return 1;
322 } //fnic_set_intr_mode_msix
323

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#9 lore raw

PATCH 8/13 scsi: fnic: Define stats to track multiqueue (MQ) IOs

In reply to Karan Tilak Kumar

Define an array to track IOs for the different queues, print the IO stats in fnic get stats data.

---
 drivers/scsi/fnic/fnic_stats.h |  2 ++
 drivers/scsi/fnic/fnic_trace.c | 11 +++++++++++
 2 files changed, 13 insertions(+)
drivers/scsi/fnic/fnic_stats.h +2 -0
index 07d1556e3c32..9d7f98c452dd 100644
@@ -2,6 +2,7 @@
 /* Copyright 2013 Cisco Systems, Inc.  All rights reserved. */
 #ifndef _FNIC_STATS_H_
 #define _FNIC_STATS_H_
+#define FNIC_MQ_MAX_QUEUES 64
 
 struct stats_timestamps {
 	struct timespec64 last_reset_time;
@@ -26,6 +27,7 @@ struct io_path_stats {
 	atomic64_t io_btw_10000_to_30000_msec;
 	atomic64_t io_greater_than_30000_msec;
 	atomic64_t current_max_io_time;
+	atomic64_t ios[FNIC_MQ_MAX_QUEUES];
 };
 
 struct abort_stats {
drivers/scsi/fnic/fnic_trace.c +11 -0
index be0d7c57b242..aaa4ea02fb7c 100644
@@ -204,6 +204,7 @@ int fnic_get_stats_data(struct stats_debug_info *debug,
 	int len = 0;
 	int buf_size = debug->buf_size;
 	struct timespec64 val1, val2;
+	int i = 0;
 
 	ktime_get_real_ts64(&val1);
 	len = scnprintf(debug->debug_buffer + len, buf_size - len,
@@ -266,6 +267,16 @@ int fnic_get_stats_data(struct stats_debug_info *debug,
 		  (u64)atomic64_read(&stats->io_stats.io_btw_10000_to_30000_msec),
 		  (u64)atomic64_read(&stats->io_stats.io_greater_than_30000_msec));
 
+	len += scnprintf(debug->debug_buffer + len, buf_size - len,
+			"------------------------------------------\n"
+			"\t\tIO Queues and cumulative IOs\n"
+			"------------------------------------------\n");
+
+	for (i = 0; i < FNIC_MQ_MAX_QUEUES; i++) {
+		len += scnprintf(debug->debug_buffer + len, buf_size - len,
+				"Q:%d -> %lld\n", i, (u64)atomic64_read(&stats->io_stats.ios[i]));
+	}
+
 	len += scnprintf(debug->debug_buffer + len, buf_size - len,
 		  "\nCurrent Max IO time : %lld\n",
 		  (u64)atomic64_read(&stats->io_stats.current_max_io_time));
Signature · 1 line
2.31.1
author maintainer
#10 lore raw

PATCH 9/13 scsi: fnic: Remove usage of host_lock

In reply to Karan Tilak Kumar

Remove usage of host_lock.
Replace with fnic_lock, where necessary.

---
 drivers/scsi/fnic/fnic_scsi.c | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)
drivers/scsi/fnic/fnic_scsi.c +6 -21
index f32781f8fdd0..9a1beb3e7269 100644
@@ -170,17 +170,14 @@ __fnic_set_state_flags(struct fnic *fnic, unsigned long st_flags,
 			unsigned long clearbits)
 {
 	unsigned long flags = 0;
-	unsigned long host_lock_flags = 0;
 
 	spin_lock_irqsave(&fnic->fnic_lock, flags);
-	spin_lock_irqsave(fnic->lport->host->host_lock, host_lock_flags);
 
 	if (clearbits)
 		fnic->state_flags &= ~st_flags;
 	else
 		fnic->state_flags |= st_flags;
 
-	spin_unlock_irqrestore(fnic->lport->host->host_lock, host_lock_flags);
 	spin_unlock_irqrestore(&fnic->fnic_lock, flags);
 
 	return;
@@ -479,12 +476,6 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 
 	atomic_inc(&fnic->in_flight);
 
-	/*
-	 * Release host lock, use driver resource specific locks from here.
-	 * Don't re-enable interrupts in case they were disabled prior to the
-	 * caller disabling them.
-	 */
-	spin_unlock(lp->host->host_lock);
 	fnic_priv(sc)->state = FNIC_IOREQ_NOT_INITED;
 	fnic_priv(sc)->flags = FNIC_NO_FLAGS;
 
@@ -569,8 +560,6 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 			mempool_free(io_req, fnic->io_req_pool);
 		}
 		atomic_dec(&fnic->in_flight);
-		/* acquire host lock before returning to SCSI */
-		spin_lock(lp->host->host_lock);
 		return ret;
 	} else {
 		atomic64_inc(&fnic_stats->io_stats.active_ios);
@@ -598,8 +587,6 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 		spin_unlock_irqrestore(io_lock, flags);
 
 	atomic_dec(&fnic->in_flight);
-	/* acquire host lock before returning to SCSI */
-	spin_lock(lp->host->host_lock);
 	return ret;
 }
 
@@ -1477,18 +1464,17 @@ static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag,
 					  struct fnic_io_req *io_req)
 {
 	struct vnic_wq_copy *wq = &fnic->hw_copy_wq[0];
-	struct Scsi_Host *host = fnic->lport->host;
 	struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats;
 	unsigned long flags;
 
-	spin_lock_irqsave(host->host_lock, flags);
+	spin_lock_irqsave(&fnic->fnic_lock, flags);
 	if (unlikely(fnic_chk_state_flags_locked(fnic,
 						FNIC_FLAGS_IO_BLOCKED))) {
-		spin_unlock_irqrestore(host->host_lock, flags);
+		spin_unlock_irqrestore(&fnic->fnic_lock, flags);
 		return 1;
 	} else
 		atomic_inc(&fnic->in_flight);
-	spin_unlock_irqrestore(host->host_lock, flags);
+	spin_unlock_irqrestore(&fnic->fnic_lock, flags);
 
 	spin_lock_irqsave(&fnic->wq_copy_lock[0], flags);
 
@@ -1923,20 +1909,19 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic,
 				       struct fnic_io_req *io_req)
 {
 	struct vnic_wq_copy *wq = &fnic->hw_copy_wq[0];
-	struct Scsi_Host *host = fnic->lport->host;
 	struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats;
 	struct scsi_lun fc_lun;
 	int ret = 0;
 	unsigned long intr_flags;
 
-	spin_lock_irqsave(host->host_lock, intr_flags);
+	spin_lock_irqsave(&fnic->fnic_lock, intr_flags);
 	if (unlikely(fnic_chk_state_flags_locked(fnic,
 						FNIC_FLAGS_IO_BLOCKED))) {
-		spin_unlock_irqrestore(host->host_lock, intr_flags);
+		spin_unlock_irqrestore(&fnic->fnic_lock, intr_flags);
 		return FAILED;
 	} else
 		atomic_inc(&fnic->in_flight);
-	spin_unlock_irqrestore(host->host_lock, intr_flags);
+	spin_unlock_irqrestore(&fnic->fnic_lock, intr_flags);
 
 	spin_lock_irqsave(&fnic->wq_copy_lock[0], intr_flags);
 
Signature · 1 line
2.31.1
author maintainer
#11 lore raw

PATCH 10/13 scsi: fnic: Add support for multiqueue (MQ) in fnic_main.c

In reply to Karan Tilak Kumar

Set map_queues in the fnic_host_template to fnic_mq_map_queues_cpus. Define fnic_mq_map_queues_cpus to set cpu assignment to
fnic queues.
Refactor code in fnic_probe to enable vnic queues before scsi_add_host. Modify notify set to the correct index.

---
 drivers/scsi/fnic/fnic.h      |   2 +-
 drivers/scsi/fnic/fnic_main.c | 137 ++++++++++++++++++++++++++--------
 2 files changed, 105 insertions(+), 34 deletions(-)
drivers/scsi/fnic/fnic.h +1 -1
index 692175cfa557..182194b6d51d 100644
@@ -377,7 +377,7 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
 int fnic_fw_reset_handler(struct fnic *fnic);
 void fnic_terminate_rport_io(struct fc_rport *);
 const char *fnic_state_to_str(unsigned int state);
-
+void fnic_mq_map_queues_cpus(struct Scsi_Host *host);
 void fnic_log_q_error(struct fnic *fnic);
 void fnic_handle_link_event(struct fnic *fnic);
 
drivers/scsi/fnic/fnic_main.c +104 -33

264 lines not on this page · raw message

Signature · 1 line
2.31.1
#12 lore raw

Re: [PATCH 10/13] scsi: fnic: Add support for multiqueue (MQ) in fnic_main.c

Quoted 12 lines

static void

drivers/scsi/fnic/fnic_main.c +1 -1
@@ -392,7 +394,7 @@ static int fnic_notify_set(struct fnic *fnic)
  		err = vnic_dev_notify_set(fnic->vdev, -1);
  		break;
  	case VNIC_DEV_INTR_MODE_MSIX:
-		err = vnic_dev_notify_set(fnic->vdev, FNIC_MSIX_ERR_NOTIFY);
+		err = vnic_dev_notify_set(fnic->vdev, fnic->wq_copy_count + fnic->cpy_wq_base);
  		break;
  	default:
  		shost_printk(KERN_ERR, fnic->lport->host,

drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 569

Quoted 3 lines
drivers/scsi/fnic/fnic_main.c +0 -0
@@ -565,11 +567,6 @@ static int fnic_scsi_drv_init(struct fnic *fnic)
  	host->max_cmd_len = FCOE_MAX_CMD_LEN;
 
  	host->nr_hw_queues = fnic->wq_copy_count;

Please be aware of comment on nr_hw_queues in scsi_host.h - maybe it is relevant to this adapter:

"the total queue depth per host is nr_hw_queues * can_queue"

Also, since you seem to be using blk_mq_unique_tag() as the per-IO tag, I assume that you don't need to set shost.host_tagset (for that reason).

drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 582

Quoted 13 lines
drivers/scsi/fnic/fnic_main.c +1 -5
-	if (host->nr_hw_queues > 1)
-		shost_printk(KERN_ERR, host,
-				"fnic: blk-mq is not supported");
-
-	host->nr_hw_queues = fnic->wq_copy_count = 1;
 
  	shost_printk(KERN_INFO, host,
  			"fnic: can_queue: %d max_lun: %llu",
@@ -582,15 +579,71 @@ static int fnic_scsi_drv_init(struct fnic *fnic)
  	return 0;
  }
 
+void fnic_mq_map_queues_cpus(struct Scsi_Host *host)

This function looks to do effectively the same as blk_mq_pci_map_queues(), right?

Quoted 44 lines
drivers/scsi/fnic/fnic_main.c +44 -0
+{
+	const struct cpumask *mask;
+	unsigned int queue, cpu;
+	int irq_num;
+	struct fc_lport *lp = shost_priv(host);
+	struct fnic *fnic = lport_priv(lp);
+	struct pci_dev *l_pdev = fnic->pdev;
+	struct blk_mq_tag_set *set = &host->tag_set;
+	int intr_mode = fnic->config.intr_mode;
+
+	if (intr_mode == VNIC_DEV_INTR_MODE_MSI || intr_mode == VNIC_DEV_INTR_MODE_INTX) {
+		shost_printk(KERN_ERR, fnic->lport->host,
+			"fnic<%d>: %s: %d: intr_mode is not msix\n",
+			fnic->fnic_num, __func__, __LINE__);
+		return;
+	}
+
+	shost_printk(KERN_INFO, fnic->lport->host,
+			"fnic<%d>: %s: %d: set->nr_hw_queues: %d\n",
+			fnic->fnic_num, __func__, __LINE__, set->nr_hw_queues);
+
+	for (queue = 0; queue < set->nr_hw_queues; queue++) {
+		if (l_pdev == NULL) {
+			shost_printk(KERN_ERR, fnic->lport->host,
+				"fnic<%d>: %s: %d: l_pdev is null\n",
+				fnic->fnic_num, __func__, __LINE__);
+			return;
+		}
+
+		irq_num = pci_irq_vector(l_pdev, queue+2);
+		if (irq_num < 0) {
+			shost_printk(KERN_ERR, fnic->lport->host,
+				"fnic<%d>: %s: %d: irq_num less than zero: %d\n",
+				fnic->fnic_num, __func__, __LINE__, irq_num);
+			continue;
+		}
+
+		mask = irq_get_effective_affinity_mask(irq_num);
+		if (!mask) {
+			shost_printk(KERN_ERR, fnic->lport->host,
+				"fnic<%d>: %s: %d: failed to get irq_affinity map for queue: %d\n",
+				fnic->fnic_num, __func__, __LINE__, irq_num);
+			continue;
+		}

drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 636

Quoted 10 lines
drivers/scsi/fnic/fnic_main.c +10 -0
+
+		for_each_cpu(cpu, mask) {
+			set->map[HCTX_TYPE_DEFAULT].mq_map[cpu] = queue;
+			shost_printk(KERN_INFO, fnic->lport->host,
+				"fnic<%d>: %s: %d: cpu: %d <=> queue: %d\n",
+				fnic->fnic_num, __func__, __LINE__, cpu, irq_num);
+		}
+	}
+}
+

Thanks,
John

#13 lore raw

RE: [PATCH 10/13] scsi: fnic: Add support for multiqueue (MQ) in fnic_main.c

Quoted 3 lines · John Garry

Please be aware of comment on nr_hw_queues in scsi_host.h - maybe it is relevant to this adapter:

"the total queue depth per host is nr_hw_queues * can_queue"

Thanks John.

Quoted 1 line

Also, since you seem to be using blk_mq_unique_tag() as the per-IO tag, I assume that you don't need to set shost.host_tagset (for that reason).

Yes, that's correct.

Quoted 3 lines
Quoted 1 line

+void fnic_mq_map_queues_cpus(struct Scsi_Host *host)

This function looks to do effectively the same as blk_mq_pci_map_queues(), right?

Yes, it looks like it is accomplishing the same goal. Thanks for this information. I'll experiment with this function on my setup and make suitable modifications in v3, if successful.

Regards,
Karan

author maintainer
#14 lore raw

PATCH 11/13 scsi: fnic: Use fnic_lock to protect fnic structures in queuecommand

In reply to Karan Tilak Kumar

fnic does not use host_lock. fnic uses fnic_lock. Use fnic lock to protect fnic members in fnic_queuecommand. Add log messages in error cases.

---
 drivers/scsi/fnic/fnic_scsi.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)
drivers/scsi/fnic/fnic_scsi.c +25 -3
index 9a1beb3e7269..ffdbdbfcdf57 100644
@@ -424,14 +424,27 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 	int io_lock_acquired = 0;
 	struct fc_rport_libfc_priv *rp;
 
-	if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED)))
+	spin_lock_irqsave(&fnic->fnic_lock, flags);
+
+	if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED))) {
+		spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+		FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host,
+			"fnic<%d>: %s: %d: fnic IO blocked flags: 0x%lx. Returning SCSI_MLQUEUE_HOST_BUSY\n",
+			fnic->fnic_num, __func__, __LINE__, fnic->state_flags);
 		return SCSI_MLQUEUE_HOST_BUSY;
+	}
 
-	if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_FWRESET)))
+	if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_FWRESET))) {
+		spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+		FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host,
+			"fnic<%d>: %s: %d: fnic flags: 0x%lx. Returning SCSI_MLQUEUE_HOST_BUSY\n",
+			fnic->fnic_num, __func__, __LINE__, fnic->state_flags);
 		return SCSI_MLQUEUE_HOST_BUSY;
+	}
 
 	rport = starget_to_rport(scsi_target(sc->device));
 	if (!rport) {
+		spin_unlock_irqrestore(&fnic->fnic_lock, flags);
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 				"returning DID_NO_CONNECT for IO as rport is NULL\n");
 		sc->result = DID_NO_CONNECT << 16;
@@ -441,6 +454,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 
 	ret = fc_remote_port_chkready(rport);
 	if (ret) {
+		spin_unlock_irqrestore(&fnic->fnic_lock, flags);
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 				"rport is not ready\n");
 		atomic64_inc(&fnic_stats->misc_stats.rport_not_ready);
@@ -451,6 +465,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 
 	rp = rport->dd_data;
 	if (!rp || rp->rp_state == RPORT_ST_DELETE) {
+		spin_unlock_irqrestore(&fnic->fnic_lock, flags);
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 			"rport 0x%x removed, returning DID_NO_CONNECT\n",
 			rport->port_id);
@@ -462,6 +477,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 	}
 
 	if (rp->rp_state != RPORT_ST_READY) {
+		spin_unlock_irqrestore(&fnic->fnic_lock, flags);
 		FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
 			"rport 0x%x in state 0x%x, returning DID_IMM_RETRY\n",
 			rport->port_id, rp->rp_state);
@@ -471,11 +487,17 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
 		return 0;
 	}
 
-	if (lp->state != LPORT_ST_READY || !(lp->link_up))
+	if (lp->state != LPORT_ST_READY || !(lp->link_up)) {
+		spin_unlock_irqrestore(&fnic->fnic_lock, flags);
+		FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host,
+			"fnic<%d>: %s: %d: state not ready: %d/link not up: %d Returning HOST_BUSY\n",
+			fnic->fnic_num, __func__, __LINE__, lp->state, lp->link_up);
 		return SCSI_MLQUEUE_HOST_BUSY;
+	}
 
 	atomic_inc(&fnic->in_flight);
 
+	spin_unlock_irqrestore(&fnic->fnic_lock, flags);
 	fnic_priv(sc)->state = FNIC_IOREQ_NOT_INITED;
 	fnic_priv(sc)->flags = FNIC_NO_FLAGS;
 
Signature · 1 line
2.31.1
author maintainer
#15 lore raw

PATCH 12/13 scsi: fnic: Add support for multiqueue (MQ) in fnic driver

In reply to Karan Tilak Kumar

Implement support for MQ in fnic driver:

The block multiqueue layer issues IO to the fnic driver with an MQ tag. Use the mqtag and derive a tag from it. Derive the hardware queue from the mqtag and use it in all paths. Modify queuecommand to handle mqtag.

Replace wq and cq indices to support MQ. Replace the zeroth queue with a hardware queue. Implement spin locks on a per hardware queue basis. Replace io_lock with per hardware queue spinlock. Implement out of range tag checks.

Allocate an io_req_table to track status of the io_req.

Test the driver by building it, loading it,
and configuring 64 queues in UCSM. Issue IOs using Medusa on multiple fnics. Enable/disable links to exercise the abort and clean up path.

---
 drivers/scsi/fnic/fnic.h      |   2 -
 drivers/scsi/fnic/fnic_io.h   |   2 +
 drivers/scsi/fnic/fnic_main.c |   3 -
 drivers/scsi/fnic/fnic_scsi.c | 579 +++++++++++++++++++++-------------
 4 files changed, 359 insertions(+), 227 deletions(-)
drivers/scsi/fnic/fnic.h +0 -2
index 182194b6d51d..bfc333366d1f 100644
@@ -36,7 +36,6 @@
 #define FNIC_MIN_IO_REQ			256 /* Min IO throttle count */
 #define FNIC_MAX_IO_REQ		1024 /* scsi_cmnd tag map entries */
 #define FNIC_DFLT_IO_REQ        256 /* Default scsi_cmnd tag map entries */
-#define	FNIC_IO_LOCKS		64 /* IO locks: power of 2 */
 #define FNIC_DFLT_QUEUE_DEPTH	256
 #define	FNIC_STATS_RATE_LIMIT	4 /* limit rate at which stats are pulled up */
 
@@ -292,7 +291,6 @@ struct fnic {
 	struct fnic_host_tag *tags;
 	mempool_t *io_req_pool;
 	mempool_t *io_sgl_pool[FNIC_SGL_NUM_CACHES];
-	spinlock_t io_req_lock[FNIC_IO_LOCKS];	/* locks for scsi cmnds */
 
 	unsigned int cpy_wq_base;
 	struct work_struct link_work;
drivers/scsi/fnic/fnic_io.h +2 -0
index f4c8769df312..5895ead20e14 100644
@@ -52,6 +52,8 @@ struct fnic_io_req {
 	unsigned long start_time; /* in jiffies */
 	struct completion *abts_done; /* completion for abts */
 	struct completion *dr_done; /* completion for device reset */
+	unsigned int tag;
+	struct scsi_cmnd *sc; /* midlayer's cmd pointer */
 };
 
 enum fnic_port_speeds {
drivers/scsi/fnic/fnic_main.c +0 -3
index 5b60396e7349..9ab115a5fc74 100644
@@ -816,9 +816,6 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		fnic->fw_ack_index[i] = -1;
 	}
 
-	for (i = 0; i < FNIC_IO_LOCKS; i++)
-		spin_lock_init(&fnic->io_req_lock[i]);
-
 	err = -ENOMEM;
 	fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache);
 	if (!fnic->io_req_pool)
drivers/scsi/fnic/fnic_scsi.c +357 -222

1,384 lines not on this page · raw message

Signature · 1 line
2.31.1
#16 lore raw

Re: [PATCH 12/13] scsi: fnic: Add support for multiqueue (MQ) in fnic driver

drivers/scsi/fnic/fnic_scsi.c static inline int fnic_queue_wq_copy_desc(struct fnic *fnic, · line 390

Quoted 4 lines · Karan Tilak Kumar
drivers/scsi/fnic/fnic_scsi.c +0 -0
@@ -405,22 +388,20 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
   * Routine to send a scsi cdb
   * Called with host_lock held and interrupts disabled.
   */

This patch removes the DEF_SCSI_QCMD() invocation so the above comment is now wrong. Please fix it.

drivers/scsi/fnic/fnic_scsi.c static inline int fnic_queue_wq_copy_desc(struct fnic *fnic, · line 391

Quoted 2 lines
drivers/scsi/fnic/fnic_scsi.c +1 -1
-static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
+static int fnic_queuecommand_lck(struct scsi_cmnd *sc, uint32_t mqtag, uint16_t hwq)

Because this patch removes the DEF_SCSI_QCMD() invocation, the name of the fnic_queuecommand_lck() function is now incorrect. Please remove the _lck() suffix.

Quoted 17 lines
drivers/scsi/fnic/fnic_scsi.c +16 -1
-DEF_SCSI_QCMD(fnic_queuecommand)
+int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc)
+{
+	struct request *const rq = scsi_cmd_to_rq(sc);
+	int rc;
+	struct fc_lport *lp = shost_priv(sc->device->host);
+	struct fnic *fnic = lport_priv(lp);
+	uint32_t mqtag = 0;
+	int tag = 0;
+	uint16_t hwq = 0;
+
+	mqtag = blk_mq_unique_tag(rq);
+	hwq = blk_mq_unique_tag_to_hwq(mqtag);
+	tag = blk_mq_unique_tag_to_tag(mqtag);
+
+	if (tag >= fnic->fnic_max_tag_id) {
+		FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host,

drivers/scsi/fnic/fnic_scsi.c static int fnic_queuecommand_lck(struct scsi_cmnd *sc) · line 632

Quoted 10 lines
drivers/scsi/fnic/fnic_scsi.c +10 -0
+				"fnic<%d>: %s: Out of range tag: 0x%x\n",
+				fnic->fnic_num, __func__, tag);
+		sc->result = DID_ERROR << 16;
+		scsi_done(sc);
+		return 0;
+	}
+
+	rc = fnic_queuecommand_lck(sc, mqtag, hwq);
+	return rc;
+}

The code guarded by "if (tag >= fnic->fnic_max_tag_id)" should be removed and instead the driver should ensure that tags never exceed the fnic->fnic_max_tag_id limit.

Please also remove the local variable 'rc'.

Thanks,

Bart.

#17 lore raw

RE: [PATCH 12/13] scsi: fnic: Add support for multiqueue (MQ) in fnic driver

Hi Bart,

Thanks for your review comments. I'll fix the issues.

Regards,
Karan

-----Original Message-----
From: Bart Van Assche <[email protected]>
Sent: Wednesday, October 25, 2023 11:20 AM
To: Karan Tilak Kumar (kartilak) <[email protected]>; Sesidhar Baddela (sebaddel) <[email protected]>
Cc: Arulprabhu Ponnusamy (arulponn) <[email protected]>; Dhanraj Jhawar (djhawar) <[email protected]>; Gian Carlo Boffa (gcboffa) <[email protected]>; Masa Kai (mkai2) <[email protected]>; Satish Kharat (satishkh) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 12/13] scsi: fnic: Add support for multiqueue (MQ) in fnic driver

drivers/scsi/fnic/fnic_scsi.c static inline int fnic_queue_wq_copy_desc(struct fnic *fnic, · line 390

Quoted 4 lines · Karan Tilak Kumar
drivers/scsi/fnic/fnic_scsi.c +0 -0
@@ -405,22 +388,20 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
   * Routine to send a scsi cdb
   * Called with host_lock held and interrupts disabled.
   */

This patch removes the DEF_SCSI_QCMD() invocation so the above comment is now wrong. Please fix it.

drivers/scsi/fnic/fnic_scsi.c static inline int fnic_queue_wq_copy_desc(struct fnic *fnic, · line 391

Quoted 2 lines
drivers/scsi/fnic/fnic_scsi.c +1 -1
-static int fnic_queuecommand_lck(struct scsi_cmnd *sc)
+static int fnic_queuecommand_lck(struct scsi_cmnd *sc, uint32_t mqtag, uint16_t hwq)

Because this patch removes the DEF_SCSI_QCMD() invocation, the name of the fnic_queuecommand_lck() function is now incorrect. Please remove the _lck() suffix.

Quoted 17 lines
drivers/scsi/fnic/fnic_scsi.c +16 -1
-DEF_SCSI_QCMD(fnic_queuecommand)
+int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc)
+{
+	struct request *const rq = scsi_cmd_to_rq(sc);
+	int rc;
+	struct fc_lport *lp = shost_priv(sc->device->host);
+	struct fnic *fnic = lport_priv(lp);
+	uint32_t mqtag = 0;
+	int tag = 0;
+	uint16_t hwq = 0;
+
+	mqtag = blk_mq_unique_tag(rq);
+	hwq = blk_mq_unique_tag_to_hwq(mqtag);
+	tag = blk_mq_unique_tag_to_tag(mqtag);
+
+	if (tag >= fnic->fnic_max_tag_id) {
+		FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host,

drivers/scsi/fnic/fnic_scsi.c static int fnic_queuecommand_lck(struct scsi_cmnd *sc) · line 632

Quoted 10 lines
drivers/scsi/fnic/fnic_scsi.c +10 -0
+				"fnic<%d>: %s: Out of range tag: 0x%x\n",
+				fnic->fnic_num, __func__, tag);
+		sc->result = DID_ERROR << 16;
+		scsi_done(sc);
+		return 0;
+	}
+
+	rc = fnic_queuecommand_lck(sc, mqtag, hwq);
+	return rc;
+}

The code guarded by "if (tag >= fnic->fnic_max_tag_id)" should be removed and instead the driver should ensure that tags never exceed the fnic->fnic_max_tag_id limit.

Please also remove the local variable 'rc'.

Thanks,

Bart.

author maintainer
#18 lore raw

PATCH 13/13 scsi: fnic: Improve logs and add support for multiqueue (MQ)

In reply to Karan Tilak Kumar

Improve existing logs by adding fnic number, hardware queue, tag, and mqtag in the prints.
Add logs with the above elements for effective debugging.

---
 drivers/scsi/fnic/fnic.h      |   2 +-
 drivers/scsi/fnic/fnic_scsi.c | 127 ++++++++++++++++++++--------------
 2 files changed, 77 insertions(+), 52 deletions(-)
drivers/scsi/fnic/fnic.h +1 -1
index bfc333366d1f..35c570d595e9 100644
@@ -27,7 +27,7 @@
 
 #define DRV_NAME		"fnic"
 #define DRV_DESCRIPTION		"Cisco FCoE HBA Driver"
-#define DRV_VERSION		"1.6.0.56"
+#define DRV_VERSION		"1.6.0.58"
 #define PFX			DRV_NAME ": "
 #define DFX                     DRV_NAME "%d: "
 
drivers/scsi/fnic/fnic_scsi.c +76 -51

260 lines not on this page · raw message

Signature · 1 line
2.31.1