Skip to contentSkip to conversation

mpi3mr: add BSG interface support for controller management

PATCH Superseded Sumit Saxena 6 participants 18 messages Apr 7, 2022 – Apr 8, 2022

Subsystems (2)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Sumit Saxena

author maintainer
#0 lore raw

v3 cover mpi3mr: add BSG interface support for controller management

This patchset adds BSG interface support for controller management. BSG layer facilitates communication/data exchange between application and driver/firmware through BSG device node.

v3:
-Moved MPI headers to /include/uapi/scsi/mpi3mr -As Bart suggested, moved struct mpi3mr_nvme_pt_sge from
uapi header to driver header.

v2:
-Moved definitions to be used by user space applications to
header scsi_bsg_mpi3mr.h in /include/upai/scsi

Sumit Saxena (8):
mpi3mr: add BSG device support
mpi3mr: add support for driver commands
mpi3mr: move MPI headers to uapi/scsi/mpi3mr
mpi3mr: add support for MPT commands
mpi3mr: add support for PEL commands
mpi3mr: expose adapter state to sysfs
mpi3mr: add support for nvme pass-through
mpi3mr: update driver version to 8.0.0.69.0

 drivers/scsi/mpi3mr/Kconfig                   |    1 +
 drivers/scsi/mpi3mr/Makefile                  |    1 +
 drivers/scsi/mpi3mr/mpi3mr.h                  |  146 +-
 drivers/scsi/mpi3mr/mpi3mr_app.c              | 1612 +++++++++++++++++
 drivers/scsi/mpi3mr/mpi3mr_debug.h            |   37 +-
 drivers/scsi/mpi3mr/mpi3mr_fw.c               |  331 +++-
 drivers/scsi/mpi3mr/mpi3mr_os.c               |   52 +-
 .../uapi/scsi/mpi3mr}/mpi30_cnfg.h            |    0
 .../uapi/scsi/mpi3mr}/mpi30_image.h           |    0
 .../uapi/scsi/mpi3mr}/mpi30_init.h            |    0
 .../uapi/scsi/mpi3mr}/mpi30_ioc.h             |    0
 .../uapi/scsi/mpi3mr}/mpi30_pci.h             |    0
 .../uapi/scsi/mpi3mr}/mpi30_sas.h             |    0
 .../uapi/scsi/mpi3mr}/mpi30_transport.h       |    0
 include/uapi/scsi/mpi3mr/mpi3mr_bsg.h         |  444 +++++
 15 files changed, 2599 insertions(+), 25 deletions(-)
 create mode 100644 drivers/scsi/mpi3mr/mpi3mr_app.c
 rename {drivers/scsi/mpi3mr/mpi => include/uapi/scsi/mpi3mr}/mpi30_cnfg.h (100%)
 rename {drivers/scsi/mpi3mr/mpi => include/uapi/scsi/mpi3mr}/mpi30_image.h (100%)
 rename {drivers/scsi/mpi3mr/mpi => include/uapi/scsi/mpi3mr}/mpi30_init.h (100%)
 rename {drivers/scsi/mpi3mr/mpi => include/uapi/scsi/mpi3mr}/mpi30_ioc.h (100%)
 rename {drivers/scsi/mpi3mr/mpi => include/uapi/scsi/mpi3mr}/mpi30_pci.h (100%)
 rename {drivers/scsi/mpi3mr/mpi => include/uapi/scsi/mpi3mr}/mpi30_sas.h (100%)
 rename {drivers/scsi/mpi3mr/mpi => include/uapi/scsi/mpi3mr}/mpi30_transport.h (100%)
 create mode 100644 include/uapi/scsi/mpi3mr/mpi3mr_bsg.h
Signature · 1 line
2.27.0
author maintainer
#1 lore raw

PATCH v3 1/8 mpi3mr: add BSG device support

Create BSG device per controller for controller management purpose. BSG Device nodes will be named as /dev/bsg/mpi3mrctl0, /dev/bsg/mpi3mrctl1...

---
 drivers/scsi/mpi3mr/Kconfig      |   1 +
 drivers/scsi/mpi3mr/Makefile     |   1 +
 drivers/scsi/mpi3mr/mpi3mr.h     |  20 ++++++
 drivers/scsi/mpi3mr/mpi3mr_app.c | 105 +++++++++++++++++++++++++++++++
 drivers/scsi/mpi3mr/mpi3mr_os.c  |   2 +
 5 files changed, 129 insertions(+)
 create mode 100644 drivers/scsi/mpi3mr/mpi3mr_app.c
drivers/scsi/mpi3mr/Kconfig +1 -0
index f7882375e74f..8997531940c2 100644
@@ -3,5 +3,6 @@
 config SCSI_MPI3MR
 	tristate "Broadcom MPI3 Storage Controller Device Driver"
 	depends on PCI && SCSI
+	select BLK_DEV_BSGLIB
 	help
 	MPI3 based Storage & RAID Controllers Driver.
drivers/scsi/mpi3mr/Makefile +1 -0
index 7c2063e04c81..f5cdbe48c150 100644
@@ -2,3 +2,4 @@
 obj-m += mpi3mr.o
 mpi3mr-y +=  mpi3mr_os.o     \
 		mpi3mr_fw.o \
+		mpi3mr_app.o \
drivers/scsi/mpi3mr/mpi3mr.h +20 -0
index 6672d907d75d..f0515f929110 100644
@@ -148,6 +148,7 @@ extern int prot_mask;
 
 #define MPI3MR_DEFAULT_MDTS	(128 * 1024)
 #define MPI3MR_DEFAULT_PGSZEXP         (12)
+
 /* Command retry count definitions */
 #define MPI3MR_DEV_RMHS_RETRY_COUNT 3
 
@@ -175,6 +176,18 @@ extern int prot_mask;
 /* MSI Index from Reply Queue Index */
 #define REPLY_QUEUE_IDX_TO_MSIX_IDX(qidx, offset)	(qidx + offset)
 
+/*
+ * Maximum data transfer size definitions for management
+ * application commands
+ */
+#define MPI3MR_MAX_APP_XFER_SIZE	(1 * 1024 * 1024)
+#define MPI3MR_MAX_APP_XFER_SEGMENTS	512
+/*
+ * 2048 sectors are for data buffers and additional 512 sectors for
+ * other buffers
+ */
+#define MPI3MR_MAX_APP_XFER_SECTORS	(2048 + 512)
+
 /* IOC State definitions */
 enum mpi3mr_iocstate {
 	MRIOC_STATE_READY = 1,
@@ -714,6 +727,8 @@ struct scmd_priv {
  * @default_qcount: Total Default queues
  * @active_poll_qcount: Currently active poll queue count
  * @requested_poll_qcount: User requested poll queue count
+ * @bsg_dev: BSG device structure
+ * @bsg_queue: Request queue for BSG device
  */
 struct mpi3mr_ioc {
 	struct list_head list;
@@ -854,6 +869,9 @@ struct mpi3mr_ioc {
 	u16 default_qcount;
 	u16 active_poll_qcount;
 	u16 requested_poll_qcount;
+
+	struct device *bsg_dev;
+	struct request_queue *bsg_queue;
 };
 
 /**
@@ -962,5 +980,7 @@ void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code);
 int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc,
 	struct op_reply_qinfo *op_reply_q);
 int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num);
+void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc);
+void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc);
 
 #endif /*MPI3MR_H_INCLUDED*/
drivers/scsi/mpi3mr/mpi3mr_app.c new file +105 -0

105 lines not on this page · raw message

drivers/scsi/mpi3mr/mpi3mr_os.c +2 -0
index f7cd70a15ea6..faf14a5f9123 100644
@@ -4345,6 +4345,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	}
 
 	scsi_scan_host(shost);
+	mpi3mr_bsg_init(mrioc);
 	return retval;
 
 addhost_failed:
@@ -4389,6 +4390,7 @@ static void mpi3mr_remove(struct pci_dev *pdev)
 	while (mrioc->reset_in_progress || mrioc->is_driver_loading)
 		ssleep(1);
 
+	mpi3mr_bsg_exit(mrioc);
 	mrioc->stop_drv_processing = 1;
 	mpi3mr_cleanup_fwevt_list(mrioc);
 	spin_lock_irqsave(&mrioc->fwevt_lock, flags);
Signature · 1 line
2.27.0
Reviewed-by on v3 1/8
#2 lore raw

Re: [PATCH v3 1/8] mpi3mr: add BSG device support

Quoted 215 lines · Sumit Saxena

Create BSG device per controller for controller management purpose. BSG Device nodes will be named as /dev/bsg/mpi3mrctl0, /dev/bsg/mpi3mrctl1...

---
  drivers/scsi/mpi3mr/Kconfig      |   1 +
  drivers/scsi/mpi3mr/Makefile     |   1 +
  drivers/scsi/mpi3mr/mpi3mr.h     |  20 ++++++
  drivers/scsi/mpi3mr/mpi3mr_app.c | 105 +++++++++++++++++++++++++++++++
  drivers/scsi/mpi3mr/mpi3mr_os.c  |   2 +
  5 files changed, 129 insertions(+)

create mode 100644 drivers/scsi/mpi3mr/mpi3mr_app.c

drivers/scsi/mpi3mr/Kconfig +1 -0
index f7882375e74f..8997531940c2 100644
@@ -3,5 +3,6 @@
  config SCSI_MPI3MR
  	tristate "Broadcom MPI3 Storage Controller Device Driver"
  	depends on PCI && SCSI
+	select BLK_DEV_BSGLIB
  	help
  	MPI3 based Storage & RAID Controllers Driver.
drivers/scsi/mpi3mr/Makefile +1 -0
index 7c2063e04c81..f5cdbe48c150 100644
@@ -2,3 +2,4 @@
  obj-m += mpi3mr.o
  mpi3mr-y +=  mpi3mr_os.o     \
  		mpi3mr_fw.o \
+		mpi3mr_app.o \
drivers/scsi/mpi3mr/mpi3mr.h +20 -0
index 6672d907d75d..f0515f929110 100644
@@ -148,6 +148,7 @@ extern int prot_mask;
 
  #define MPI3MR_DEFAULT_MDTS	(128 * 1024)
  #define MPI3MR_DEFAULT_PGSZEXP         (12)
+
  /* Command retry count definitions */
  #define MPI3MR_DEV_RMHS_RETRY_COUNT 3
 
@@ -175,6 +176,18 @@ extern int prot_mask;
  /* MSI Index from Reply Queue Index */
  #define REPLY_QUEUE_IDX_TO_MSIX_IDX(qidx, offset)	(qidx + offset)
 
+/*
+ * Maximum data transfer size definitions for management
+ * application commands
+ */
+#define MPI3MR_MAX_APP_XFER_SIZE	(1 * 1024 * 1024)
+#define MPI3MR_MAX_APP_XFER_SEGMENTS	512
+/*
+ * 2048 sectors are for data buffers and additional 512 sectors for
+ * other buffers
+ */
+#define MPI3MR_MAX_APP_XFER_SECTORS	(2048 + 512)
+
  /* IOC State definitions */
  enum mpi3mr_iocstate {
  	MRIOC_STATE_READY = 1,
@@ -714,6 +727,8 @@ struct scmd_priv {
   * @default_qcount: Total Default queues
   * @active_poll_qcount: Currently active poll queue count
   * @requested_poll_qcount: User requested poll queue count
+ * @bsg_dev: BSG device structure
+ * @bsg_queue: Request queue for BSG device
   */
  struct mpi3mr_ioc {
  	struct list_head list;
@@ -854,6 +869,9 @@ struct mpi3mr_ioc {
  	u16 default_qcount;
  	u16 active_poll_qcount;
  	u16 requested_poll_qcount;
+
+	struct device *bsg_dev;
+	struct request_queue *bsg_queue;
  };
 
  /**
@@ -962,5 +980,7 @@ void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code);
  int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc,
  	struct op_reply_qinfo *op_reply_q);
  int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num);
+void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc);
+void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc);
 
  #endif /*MPI3MR_H_INCLUDED*/
drivers/scsi/mpi3mr/mpi3mr_app.c new file +105 -0
new file mode 100644
index 000000000000..9b6698525990
@@ -0,0 +1,105 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Driver for Broadcom MPI3 Storage Controllers
+ *
+ * Copyright (C) 2017-2022 Broadcom Inc.
+ *  (mailto: [email protected])
+ *
+ */
+
+#include "mpi3mr.h"
+#include <linux/bsg-lib.h>
+
+/**
+ * mpi3mr_bsg_request - bsg request entry point
+ * @job: BSG job reference
+ *
+ * This is driver's entry point for bsg requests
+ *
+ * Return: 0 on success and proper error codes on failure
+ */
+int mpi3mr_bsg_request(struct bsg_job *job)
+{
+	return 0;
+}
+
+/**
+ * mpi3mr_bsg_exit - de-registration from bsg layer
+ *
+ * This will be called during driver unload and all
+ * bsg resources allocated during load will be freed.
+ *
+ * Return:Nothing
+ */
+void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc)
+{
+	if (!mrioc->bsg_queue)
+		return;
+
+	bsg_remove_queue(mrioc->bsg_queue);
+	mrioc->bsg_queue = NULL;
+
+	device_del(mrioc->bsg_dev);
+	put_device(mrioc->bsg_dev);
+	kfree(mrioc->bsg_dev);
+}
+
+/**
+ * mpi3mr_bsg_node_release -release bsg device node
+ * @dev: bsg device node
+ *
+ * decrements bsg dev reference count
+ *
+ * Return:Nothing
+ */
+void mpi3mr_bsg_node_release(struct device *dev)
+{
+	put_device(dev);
+}
+
+/**
+ * mpi3mr_bsg_init -  registration with bsg layer
+ *
+ * This will be called during driver load and it will
+ * register driver with bsg layer
+ *
+ * Return:Nothing
+ */
+void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc)
+{
+	mrioc->bsg_dev = kzalloc(sizeof(struct device), GFP_KERNEL);
+	if (!mrioc->bsg_dev) {
+		ioc_err(mrioc, "bsg device mem allocation failed\n");
+		return;
+	}
+
+	device_initialize(mrioc->bsg_dev);
+	dev_set_name(mrioc->bsg_dev, "mpi3mrctl%u", mrioc->id);
+
+	if (device_add(mrioc->bsg_dev)) {
+		ioc_err(mrioc, "%s: bsg device add failed\n",
+		    dev_name(mrioc->bsg_dev));
+		goto err_device_add;
+	}
+
+	mrioc->bsg_dev->release = mpi3mr_bsg_node_release;
+
+	mrioc->bsg_queue = bsg_setup_queue(mrioc->bsg_dev, dev_name(mrioc->bsg_dev),
+			mpi3mr_bsg_request, NULL, 0);
+	if (!mrioc->bsg_queue) {
+		ioc_err(mrioc, "%s: bsg registration failed\n",
+		    dev_name(mrioc->bsg_dev));
+		goto err_setup_queue;
+	}
+
+	blk_queue_max_segments(mrioc->bsg_queue, MPI3MR_MAX_APP_XFER_SEGMENTS);
+	blk_queue_max_hw_sectors(mrioc->bsg_queue, MPI3MR_MAX_APP_XFER_SECTORS);
+
+	return;
+
+err_setup_queue:
+	device_del(mrioc->bsg_dev);
+	put_device(mrioc->bsg_dev);
+err_device_add:
+	kfree(mrioc->bsg_dev);
+}
drivers/scsi/mpi3mr/mpi3mr_os.c +1 -0
index f7cd70a15ea6..faf14a5f9123 100644
@@ -4345,6 +4345,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
  	}
 
  	scsi_scan_host(shost);
+	mpi3mr_bsg_init(mrioc);
  	return retval;
 
  addhost_failed:

drivers/scsi/mpi3mr/mpi3mr_os.c static void mpi3mr_remove(struct pci_dev *pdev) · line 4396

Quoted 7 lines
drivers/scsi/mpi3mr/mpi3mr_os.c +1 -0
@@ -4389,6 +4390,7 @@ static void mpi3mr_remove(struct pci_dev *pdev)
  	while (mrioc->reset_in_progress || mrioc->is_driver_loading)
  		ssleep(1);
 
+	mpi3mr_bsg_exit(mrioc);
  	mrioc->stop_drv_processing = 1;
  	mpi3mr_cleanup_fwevt_list(mrioc);
  	spin_lock_irqsave(&mrioc->fwevt_lock, flags);

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		           Kernel Storage Architect
[email protected]			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
Reviewed-by on v3 1/8
#3 lore raw

Re: [PATCH v3 1/8] mpi3mr: add BSG device support

In reply to Sumit Saxena
Quoted 216 lines · Sumit Saxena

Create BSG device per controller for controller management purpose. BSG Device nodes will be named as /dev/bsg/mpi3mrctl0, /dev/bsg/mpi3mrctl1...

---
  drivers/scsi/mpi3mr/Kconfig      |   1 +
  drivers/scsi/mpi3mr/Makefile     |   1 +
  drivers/scsi/mpi3mr/mpi3mr.h     |  20 ++++++
  drivers/scsi/mpi3mr/mpi3mr_app.c | 105 +++++++++++++++++++++++++++++++
  drivers/scsi/mpi3mr/mpi3mr_os.c  |   2 +
  5 files changed, 129 insertions(+)

create mode 100644 drivers/scsi/mpi3mr/mpi3mr_app.c

drivers/scsi/mpi3mr/Kconfig +1 -0
index f7882375e74f..8997531940c2 100644
@@ -3,5 +3,6 @@
  config SCSI_MPI3MR
  	tristate "Broadcom MPI3 Storage Controller Device Driver"
  	depends on PCI && SCSI
+	select BLK_DEV_BSGLIB
  	help
  	MPI3 based Storage & RAID Controllers Driver.
drivers/scsi/mpi3mr/Makefile +1 -0
index 7c2063e04c81..f5cdbe48c150 100644
@@ -2,3 +2,4 @@
  obj-m += mpi3mr.o
  mpi3mr-y +=  mpi3mr_os.o     \
  		mpi3mr_fw.o \
+		mpi3mr_app.o \
drivers/scsi/mpi3mr/mpi3mr.h +20 -0
index 6672d907d75d..f0515f929110 100644
@@ -148,6 +148,7 @@ extern int prot_mask;
 
  #define MPI3MR_DEFAULT_MDTS	(128 * 1024)
  #define MPI3MR_DEFAULT_PGSZEXP         (12)
+
  /* Command retry count definitions */
  #define MPI3MR_DEV_RMHS_RETRY_COUNT 3
 
@@ -175,6 +176,18 @@ extern int prot_mask;
  /* MSI Index from Reply Queue Index */
  #define REPLY_QUEUE_IDX_TO_MSIX_IDX(qidx, offset)	(qidx + offset)
 
+/*
+ * Maximum data transfer size definitions for management
+ * application commands
+ */
+#define MPI3MR_MAX_APP_XFER_SIZE	(1 * 1024 * 1024)
+#define MPI3MR_MAX_APP_XFER_SEGMENTS	512
+/*
+ * 2048 sectors are for data buffers and additional 512 sectors for
+ * other buffers
+ */
+#define MPI3MR_MAX_APP_XFER_SECTORS	(2048 + 512)
+
  /* IOC State definitions */
  enum mpi3mr_iocstate {
  	MRIOC_STATE_READY = 1,
@@ -714,6 +727,8 @@ struct scmd_priv {
   * @default_qcount: Total Default queues
   * @active_poll_qcount: Currently active poll queue count
   * @requested_poll_qcount: User requested poll queue count
+ * @bsg_dev: BSG device structure
+ * @bsg_queue: Request queue for BSG device
   */
  struct mpi3mr_ioc {
  	struct list_head list;
@@ -854,6 +869,9 @@ struct mpi3mr_ioc {
  	u16 default_qcount;
  	u16 active_poll_qcount;
  	u16 requested_poll_qcount;
+
+	struct device *bsg_dev;
+	struct request_queue *bsg_queue;
  };
 
  /**
@@ -962,5 +980,7 @@ void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code);
  int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc,
  	struct op_reply_qinfo *op_reply_q);
  int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num);
+void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc);
+void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc);
 
  #endif /*MPI3MR_H_INCLUDED*/
drivers/scsi/mpi3mr/mpi3mr_app.c new file +105 -0
new file mode 100644
index 000000000000..9b6698525990
@@ -0,0 +1,105 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Driver for Broadcom MPI3 Storage Controllers
+ *
+ * Copyright (C) 2017-2022 Broadcom Inc.
+ *  (mailto: [email protected])
+ *
+ */
+
+#include "mpi3mr.h"
+#include <linux/bsg-lib.h>
+
+/**
+ * mpi3mr_bsg_request - bsg request entry point
+ * @job: BSG job reference
+ *
+ * This is driver's entry point for bsg requests
+ *
+ * Return: 0 on success and proper error codes on failure
+ */
+int mpi3mr_bsg_request(struct bsg_job *job)
+{
+	return 0;
+}
+
+/**
+ * mpi3mr_bsg_exit - de-registration from bsg layer
+ *
+ * This will be called during driver unload and all
+ * bsg resources allocated during load will be freed.
+ *
+ * Return:Nothing
+ */
+void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc)
+{
+	if (!mrioc->bsg_queue)
+		return;
+
+	bsg_remove_queue(mrioc->bsg_queue);
+	mrioc->bsg_queue = NULL;
+
+	device_del(mrioc->bsg_dev);
+	put_device(mrioc->bsg_dev);
+	kfree(mrioc->bsg_dev);
+}
+
+/**
+ * mpi3mr_bsg_node_release -release bsg device node
+ * @dev: bsg device node
+ *
+ * decrements bsg dev reference count
+ *
+ * Return:Nothing
+ */
+void mpi3mr_bsg_node_release(struct device *dev)
+{
+	put_device(dev);
+}
+
+/**
+ * mpi3mr_bsg_init -  registration with bsg layer
+ *
+ * This will be called during driver load and it will
+ * register driver with bsg layer
+ *
+ * Return:Nothing
+ */
+void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc)
+{
+	mrioc->bsg_dev = kzalloc(sizeof(struct device), GFP_KERNEL);
+	if (!mrioc->bsg_dev) {
+		ioc_err(mrioc, "bsg device mem allocation failed\n");
+		return;
+	}
+
+	device_initialize(mrioc->bsg_dev);
+	dev_set_name(mrioc->bsg_dev, "mpi3mrctl%u", mrioc->id);
+
+	if (device_add(mrioc->bsg_dev)) {
+		ioc_err(mrioc, "%s: bsg device add failed\n",
+		    dev_name(mrioc->bsg_dev));
+		goto err_device_add;
+	}
+
+	mrioc->bsg_dev->release = mpi3mr_bsg_node_release;
+
+	mrioc->bsg_queue = bsg_setup_queue(mrioc->bsg_dev, dev_name(mrioc->bsg_dev),
+			mpi3mr_bsg_request, NULL, 0);
+	if (!mrioc->bsg_queue) {
+		ioc_err(mrioc, "%s: bsg registration failed\n",
+		    dev_name(mrioc->bsg_dev));
+		goto err_setup_queue;
+	}
+
+	blk_queue_max_segments(mrioc->bsg_queue, MPI3MR_MAX_APP_XFER_SEGMENTS);
+	blk_queue_max_hw_sectors(mrioc->bsg_queue, MPI3MR_MAX_APP_XFER_SECTORS);
+
+	return;
+
+err_setup_queue:
+	device_del(mrioc->bsg_dev);
+	put_device(mrioc->bsg_dev);
+err_device_add:
+	kfree(mrioc->bsg_dev);
+}
drivers/scsi/mpi3mr/mpi3mr_os.c +1 -0
index f7cd70a15ea6..faf14a5f9123 100644
@@ -4345,6 +4345,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
  	}
 
  	scsi_scan_host(shost);
+	mpi3mr_bsg_init(mrioc);
  	return retval;
 
  addhost_failed:

drivers/scsi/mpi3mr/mpi3mr_os.c static void mpi3mr_remove(struct pci_dev *pdev) · line 4396

Quoted 7 lines
drivers/scsi/mpi3mr/mpi3mr_os.c +1 -0
@@ -4389,6 +4390,7 @@ static void mpi3mr_remove(struct pci_dev *pdev)
  	while (mrioc->reset_in_progress || mrioc->is_driver_loading)
  		ssleep(1);
 
+	mpi3mr_bsg_exit(mrioc);
  	mrioc->stop_drv_processing = 1;
  	mpi3mr_cleanup_fwevt_list(mrioc);
  	spin_lock_irqsave(&mrioc->fwevt_lock, flags);
Signature · 1 line
Himanshu Madhani                                Oracle Linux Engineering
author maintainer
#4 lore raw

PATCH v3 2/8 mpi3mr: add support for driver commands

In reply to Sumit Saxena

There are certain BSG commands which is to be completed by driver without involving firmware. These requests are termed as driver commands. This patch adds support for the same.

---
 drivers/scsi/mpi3mr/mpi3mr.h          |  16 +-
 drivers/scsi/mpi3mr/mpi3mr_app.c      | 397 +++++++++++++++++++++++
 drivers/scsi/mpi3mr/mpi3mr_debug.h    |  12 +-
 drivers/scsi/mpi3mr/mpi3mr_fw.c       |  21 +-
 drivers/scsi/mpi3mr/mpi3mr_os.c       |   3 +
 include/uapi/scsi/mpi3mr/mpi3mr_bsg.h | 434 ++++++++++++++++++++++++++
 6 files changed, 871 insertions(+), 12 deletions(-)
 create mode 100644 include/uapi/scsi/mpi3mr/mpi3mr_bsg.h
drivers/scsi/mpi3mr/mpi3mr.h +13 -3
index f0515f929110..877b0925dbc5 100644
@@ -89,7 +89,7 @@ extern int prot_mask;
 /* Reserved Host Tag definitions */
 #define MPI3MR_HOSTTAG_INVALID		0xFFFF
 #define MPI3MR_HOSTTAG_INITCMDS		1
-#define MPI3MR_HOSTTAG_IOCTLCMDS	2
+#define MPI3MR_HOSTTAG_BSG_CMDS		2
 #define MPI3MR_HOSTTAG_BLK_TMS		5
 
 #define MPI3MR_NUM_DEVRMCMD		16
@@ -202,10 +202,10 @@ enum mpi3mr_iocstate {
 enum mpi3mr_reset_reason {
 	MPI3MR_RESET_FROM_BRINGUP = 1,
 	MPI3MR_RESET_FROM_FAULT_WATCH = 2,
-	MPI3MR_RESET_FROM_IOCTL = 3,
+	MPI3MR_RESET_FROM_APP = 3,
 	MPI3MR_RESET_FROM_EH_HOS = 4,
 	MPI3MR_RESET_FROM_TM_TIMEOUT = 5,
-	MPI3MR_RESET_FROM_IOCTL_TIMEOUT = 6,
+	MPI3MR_RESET_FROM_APP_TIMEOUT = 6,
 	MPI3MR_RESET_FROM_MUR_FAILURE = 7,
 	MPI3MR_RESET_FROM_CTLR_CLEANUP = 8,
 	MPI3MR_RESET_FROM_CIACTIV_FAULT = 9,
@@ -698,6 +698,7 @@ struct scmd_priv {
  * @chain_bitmap_sz: Chain buffer allocator bitmap size
  * @chain_bitmap: Chain buffer allocator bitmap
  * @chain_buf_lock: Chain buffer list lock
+ * @bsg_cmds: Command tracker for BSG command
  * @host_tm_cmds: Command tracker for task management commands
  * @dev_rmhs_cmds: Command tracker for device removal commands
  * @evtack_cmds: Command tracker for event ack commands
@@ -729,6 +730,10 @@ struct scmd_priv {
  * @requested_poll_qcount: User requested poll queue count
  * @bsg_dev: BSG device structure
  * @bsg_queue: Request queue for BSG device
+ * @stop_bsgs: Stop BSG request flag
+ * @logdata_buf: Circular buffer to store log data entries
+ * @logdata_buf_idx: Index of entry in buffer to store
+ * @logdata_entry_sz: log data entry size
  */
 struct mpi3mr_ioc {
 	struct list_head list;
@@ -835,6 +840,7 @@ struct mpi3mr_ioc {
 	void *chain_bitmap;
 	spinlock_t chain_buf_lock;
 
+	struct mpi3mr_drv_cmd bsg_cmds;
 	struct mpi3mr_drv_cmd host_tm_cmds;
 	struct mpi3mr_drv_cmd dev_rmhs_cmds[MPI3MR_NUM_DEVRMCMD];
 	struct mpi3mr_drv_cmd evtack_cmds[MPI3MR_NUM_EVTACKCMD];
@@ -872,6 +878,10 @@ struct mpi3mr_ioc {
 
 	struct device *bsg_dev;
 	struct request_queue *bsg_queue;
+	u8 stop_bsgs;
+	u8 *logdata_buf;
+	u16 logdata_buf_idx;
+	u16 logdata_entry_sz;
 };
 
 /**
drivers/scsi/mpi3mr/mpi3mr_app.c +397 -0

409 lines not on this page · raw message

drivers/scsi/mpi3mr/mpi3mr_debug.h +6 -6
index c7982443f45a..65bfac72948c 100644
@@ -23,8 +23,8 @@
 #define MPI3_DEBUG_RESET		0x00000020
 #define MPI3_DEBUG_SCSI_ERROR		0x00000040
 #define MPI3_DEBUG_REPLY		0x00000080
-#define MPI3_DEBUG_IOCTL_ERROR		0x00008000
-#define MPI3_DEBUG_IOCTL_INFO		0x00010000
+#define MPI3_DEBUG_BSG_ERROR		0x00008000
+#define MPI3_DEBUG_BSG_INFO		0x00010000
 #define MPI3_DEBUG_SCSI_INFO		0x00020000
 #define MPI3_DEBUG			0x01000000
 #define MPI3_DEBUG_SG			0x02000000
@@ -110,15 +110,15 @@
 	} while (0)
 
 
-#define dprint_ioctl_info(ioc, fmt, ...) \
+#define dprint_bsg_info(ioc, fmt, ...) \
 	do { \
-		if (ioc->logging_level & MPI3_DEBUG_IOCTL_INFO) \
+		if (ioc->logging_level & MPI3_DEBUG_BSG_INFO) \
 			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
 	} while (0)
 
-#define dprint_ioctl_err(ioc, fmt, ...) \
+#define dprint_bsg_err(ioc, fmt, ...) \
 	do { \
-		if (ioc->logging_level & MPI3_DEBUG_IOCTL_ERROR) \
+		if (ioc->logging_level & MPI3_DEBUG_BSG_ERROR) \
 			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
 	} while (0)
 
drivers/scsi/mpi3mr/mpi3mr_fw.c +18 -3
index e25c02466043..480730721f50 100644
@@ -297,6 +297,8 @@ mpi3mr_get_drv_cmd(struct mpi3mr_ioc *mrioc, u16 host_tag,
 	switch (host_tag) {
 	case MPI3MR_HOSTTAG_INITCMDS:
 		return &mrioc->init_cmds;
+	case MPI3MR_HOSTTAG_BSG_CMDS:
+		return &mrioc->bsg_cmds;
 	case MPI3MR_HOSTTAG_BLK_TMS:
 		return &mrioc->host_tm_cmds;
 	case MPI3MR_HOSTTAG_INVALID:
@@ -865,10 +867,10 @@ static const struct {
 } mpi3mr_reset_reason_codes[] = {
 	{ MPI3MR_RESET_FROM_BRINGUP, "timeout in bringup" },
 	{ MPI3MR_RESET_FROM_FAULT_WATCH, "fault" },
-	{ MPI3MR_RESET_FROM_IOCTL, "application invocation" },
+	{ MPI3MR_RESET_FROM_APP, "application invocation" },
 	{ MPI3MR_RESET_FROM_EH_HOS, "error handling" },
 	{ MPI3MR_RESET_FROM_TM_TIMEOUT, "TM timeout" },
-	{ MPI3MR_RESET_FROM_IOCTL_TIMEOUT, "IOCTL timeout" },
+	{ MPI3MR_RESET_FROM_APP_TIMEOUT, "application command timeout" },
 	{ MPI3MR_RESET_FROM_MUR_FAILURE, "MUR failure" },
 	{ MPI3MR_RESET_FROM_CTLR_CLEANUP, "timeout in controller cleanup" },
 	{ MPI3MR_RESET_FROM_CIACTIV_FAULT, "component image activation fault" },
@@ -2813,6 +2815,10 @@ static int mpi3mr_alloc_reply_sense_bufs(struct mpi3mr_ioc *mrioc)
 	if (!mrioc->init_cmds.reply)
 		goto out_failed;
 
+	mrioc->bsg_cmds.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL);
+	if (!mrioc->bsg_cmds.reply)
+		goto out_failed;
+
 	for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++) {
 		mrioc->dev_rmhs_cmds[i].reply = kzalloc(mrioc->reply_sz,
 		    GFP_KERNEL);
@@ -3948,6 +3954,8 @@ void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc)
 
 	if (mrioc->init_cmds.reply) {
 		memset(mrioc->init_cmds.reply, 0, sizeof(*mrioc->init_cmds.reply));
+		memset(mrioc->bsg_cmds.reply, 0,
+		    sizeof(*mrioc->bsg_cmds.reply));
 		memset(mrioc->host_tm_cmds.reply, 0,
 		    sizeof(*mrioc->host_tm_cmds.reply));
 		for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++)
@@ -4050,6 +4058,9 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc)
 	kfree(mrioc->init_cmds.reply);
 	mrioc->init_cmds.reply = NULL;
 
+	kfree(mrioc->bsg_cmds.reply);
+	mrioc->bsg_cmds.reply = NULL;
+
 	kfree(mrioc->host_tm_cmds.reply);
 	mrioc->host_tm_cmds.reply = NULL;
 
@@ -4235,6 +4246,8 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc)
 
 	cmdptr = &mrioc->init_cmds;
 	mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
+	cmdptr = &mrioc->bsg_cmds;
+	mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
 	cmdptr = &mrioc->host_tm_cmds;
 	mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
 
@@ -4258,7 +4271,7 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc)
  * This is an handler for recovering controller by issuing soft
  * reset are diag fault reset.  This is a blocking function and
  * when one reset is executed if any other resets they will be
- * blocked. All IOCTLs/IO will be blocked during the reset. If
+ * blocked. All BSG requests will be blocked during the reset. If
  * controller reset is successful then the controller will be
  * reinitalized, otherwise the controller will be marked as not
  * recoverable
@@ -4305,6 +4318,7 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc,
 	    mpi3mr_reset_rc_name(reset_reason));
 
 	mrioc->reset_in_progress = 1;
+	mrioc->stop_bsgs = 1;
 	mrioc->prev_reset_result = -1;
 
 	if ((!snapdump) && (reset_reason != MPI3MR_RESET_FROM_FAULT_WATCH) &&
@@ -4377,6 +4391,7 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc,
 			    &mrioc->watchdog_work,
 			    msecs_to_jiffies(MPI3MR_WATCHDOG_INTERVAL));
 		spin_unlock_irqrestore(&mrioc->watchdog_lock, flags);
+		mrioc->stop_bsgs = 0;
 	} else {
 		mpi3mr_issue_reset(mrioc,
 		    MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, reset_reason);
drivers/scsi/mpi3mr/mpi3mr_os.c +3 -0
index faf14a5f9123..a03e39083a42 100644
@@ -3589,6 +3589,7 @@ static int mpi3mr_scan_finished(struct Scsi_Host *shost,
 
 	mpi3mr_start_watchdog(mrioc);
 	mrioc->is_driver_loading = 0;
+	mrioc->stop_bsgs = 0;
 	return 1;
 }
 
@@ -4259,6 +4260,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	mutex_init(&mrioc->reset_mutex);
 	mpi3mr_init_drv_cmd(&mrioc->init_cmds, MPI3MR_HOSTTAG_INITCMDS);
 	mpi3mr_init_drv_cmd(&mrioc->host_tm_cmds, MPI3MR_HOSTTAG_BLK_TMS);
+	mpi3mr_init_drv_cmd(&mrioc->bsg_cmds, MPI3MR_HOSTTAG_BSG_CMDS);
 
 	for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++)
 		mpi3mr_init_drv_cmd(&mrioc->dev_rmhs_cmds[i],
@@ -4271,6 +4273,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	mrioc->logging_level = logging_level;
 	mrioc->shost = shost;
 	mrioc->pdev = pdev;
+	mrioc->stop_bsgs = 1;
 
 	/* init shost parameters */
 	shost->max_cmd_len = MPI3MR_MAX_CDB_LENGTH;
include/uapi/scsi/mpi3mr/mpi3mr_bsg.h new file +434 -0

434 lines not on this page · raw message

Signature · 1 line
2.27.0
#5 lore raw

Re: [PATCH v3 2/8] mpi3mr: add support for driver commands

Quoted 108 lines · Sumit Saxena

There are certain BSG commands which is to be completed by driver without involving firmware. These requests are termed as driver commands. This patch adds support for the same.

---
  drivers/scsi/mpi3mr/mpi3mr.h          |  16 +-
  drivers/scsi/mpi3mr/mpi3mr_app.c      | 397 +++++++++++++++++++++++
  drivers/scsi/mpi3mr/mpi3mr_debug.h    |  12 +-
  drivers/scsi/mpi3mr/mpi3mr_fw.c       |  21 +-
  drivers/scsi/mpi3mr/mpi3mr_os.c       |   3 +
  include/uapi/scsi/mpi3mr/mpi3mr_bsg.h | 434 ++++++++++++++++++++++++++
  6 files changed, 871 insertions(+), 12 deletions(-)

create mode 100644 include/uapi/scsi/mpi3mr/mpi3mr_bsg.h

drivers/scsi/mpi3mr/mpi3mr.h +13 -3
index f0515f929110..877b0925dbc5 100644
@@ -89,7 +89,7 @@ extern int prot_mask;
  /* Reserved Host Tag definitions */
  #define MPI3MR_HOSTTAG_INVALID		0xFFFF
  #define MPI3MR_HOSTTAG_INITCMDS		1
-#define MPI3MR_HOSTTAG_IOCTLCMDS	2
+#define MPI3MR_HOSTTAG_BSG_CMDS		2
  #define MPI3MR_HOSTTAG_BLK_TMS		5
 
  #define MPI3MR_NUM_DEVRMCMD		16
@@ -202,10 +202,10 @@ enum mpi3mr_iocstate {
  enum mpi3mr_reset_reason {
  	MPI3MR_RESET_FROM_BRINGUP = 1,
  	MPI3MR_RESET_FROM_FAULT_WATCH = 2,
-	MPI3MR_RESET_FROM_IOCTL = 3,
+	MPI3MR_RESET_FROM_APP = 3,
  	MPI3MR_RESET_FROM_EH_HOS = 4,
  	MPI3MR_RESET_FROM_TM_TIMEOUT = 5,
-	MPI3MR_RESET_FROM_IOCTL_TIMEOUT = 6,
+	MPI3MR_RESET_FROM_APP_TIMEOUT = 6,
  	MPI3MR_RESET_FROM_MUR_FAILURE = 7,
  	MPI3MR_RESET_FROM_CTLR_CLEANUP = 8,
  	MPI3MR_RESET_FROM_CIACTIV_FAULT = 9,
@@ -698,6 +698,7 @@ struct scmd_priv {
   * @chain_bitmap_sz: Chain buffer allocator bitmap size
   * @chain_bitmap: Chain buffer allocator bitmap
   * @chain_buf_lock: Chain buffer list lock
+ * @bsg_cmds: Command tracker for BSG command
   * @host_tm_cmds: Command tracker for task management commands
   * @dev_rmhs_cmds: Command tracker for device removal commands
   * @evtack_cmds: Command tracker for event ack commands
@@ -729,6 +730,10 @@ struct scmd_priv {
   * @requested_poll_qcount: User requested poll queue count
   * @bsg_dev: BSG device structure
   * @bsg_queue: Request queue for BSG device
+ * @stop_bsgs: Stop BSG request flag
+ * @logdata_buf: Circular buffer to store log data entries
+ * @logdata_buf_idx: Index of entry in buffer to store
+ * @logdata_entry_sz: log data entry size
   */
  struct mpi3mr_ioc {
  	struct list_head list;
@@ -835,6 +840,7 @@ struct mpi3mr_ioc {
  	void *chain_bitmap;
  	spinlock_t chain_buf_lock;
 
+	struct mpi3mr_drv_cmd bsg_cmds;
  	struct mpi3mr_drv_cmd host_tm_cmds;
  	struct mpi3mr_drv_cmd dev_rmhs_cmds[MPI3MR_NUM_DEVRMCMD];
  	struct mpi3mr_drv_cmd evtack_cmds[MPI3MR_NUM_EVTACKCMD];
@@ -872,6 +878,10 @@ struct mpi3mr_ioc {
 
  	struct device *bsg_dev;
  	struct request_queue *bsg_queue;
+	u8 stop_bsgs;
+	u8 *logdata_buf;
+	u16 logdata_buf_idx;
+	u16 logdata_entry_sz;
  };
 
  /**
drivers/scsi/mpi3mr/mpi3mr_app.c +21 -0
index 9b6698525990..3136f5c5d164 100644
@@ -9,6 +9,386 @@
 
  #include "mpi3mr.h"
  #include <linux/bsg-lib.h>
+#include <uapi/scsi/mpi3mr/mpi3mr_bsg.h>
+
+/**
+ * mpi3mr_bsg_verify_adapter - verify adapter number is valid
+ * @ioc_number: Adapter number
+ * @mriocpp: Pointer to hold per adapter instance
+ *
+ * This function checks whether given adapter number matches
+ * with an adapter id in the driver's list and if so fills
+ * pointer to the per adapter instance in mriocpp else set that
+ * to NULL.
+ *
+ * Return: Nothing.
+ */
+static void mpi3mr_bsg_verify_adapter(int ioc_number,
+	struct mpi3mr_ioc **mriocpp)
+{
+	struct mpi3mr_ioc *mrioc;
+
+	spin_lock(&mrioc_list_lock);
+	list_for_each_entry(mrioc, &mrioc_list, list) {

drivers/scsi/mpi3mr/mpi3mr_app.c line 42

Quoted 10 lines
drivers/scsi/mpi3mr/mpi3mr_app.c +10 -0
+		if (mrioc->id != ioc_number)
+			continue;
+		spin_unlock(&mrioc_list_lock);
+		*mriocpp = mrioc;
+		return;
+	}
+	spin_unlock(&mrioc_list_lock);
+	*mriocpp = NULL;
+}
+

Please return 'struct mpi3mr_io *' here and avoid having to pass a return pointer.

Quoted 32 lines
drivers/scsi/mpi3mr/mpi3mr_app.c +32 -0
+/**
+ * mpi3mr_enable_logdata - Handler for log data enable
+ * @mrioc: Adapter instance reference
+ * @job: BSG job reference
+ *
+ * This function enables log data caching in the driver if not
+ * already enabled and return the maximum number of log data
+ * entries that can be cached in the driver.
+ *
+ * Return: 0 on success and proper error codes on failure
+ */
+static long mpi3mr_enable_logdata(struct mpi3mr_ioc *mrioc,
+	struct bsg_job *job)
+{
+	long rval = -EINVAL;
+	struct mpi3mr_logdata_enable logdata_enable;
+
+	if (mrioc->logdata_buf)
+		goto copy_user_data;
+
+	mrioc->logdata_entry_sz =
+	    (mrioc->reply_sz - (sizeof(struct mpi3_event_notification_reply) - 4))
+	    + MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ;
+	mrioc->logdata_buf_idx = 0;
+
+	mrioc->logdata_buf = kcalloc(MPI3MR_BSG_LOGDATA_MAX_ENTRIES,
+	    mrioc->logdata_entry_sz, GFP_KERNEL);
+	if (!mrioc->logdata_buf)
+		return -ENOMEM;
+
+copy_user_data:
+	memset(&logdata_enable, 0, sizeof(logdata_enable));

drivers/scsi/mpi3mr/mpi3mr_app.c line 84

Quoted 10 lines
drivers/scsi/mpi3mr/mpi3mr_app.c +10 -0
+	logdata_enable.max_entries =
+	    MPI3MR_BSG_LOGDATA_MAX_ENTRIES;
+	if (job->request_payload.payload_len >= sizeof(logdata_enable)) {
+		sg_copy_from_buffer(job->request_payload.sg_list,
+				    job->request_payload.sg_cnt,
+				    &logdata_enable, sizeof(logdata_enable));
+		rval = 0;
+	}
+	return rval;
+}

This is a very unusual programming pattern.
You allocate the buffer only _after_ the command has been submitted, risking a failure in buffer allocation even though the command succeeded.

Please convert this to allocate the buffer _first_, then issue the command, and then evaluate the response.

Same for the other bsg handler functions.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		           Kernel Storage Architect
[email protected]			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
#6 lore raw

Re: [PATCH v3 2/8] mpi3mr: add support for driver commands

In reply to Sumit Saxena
Quoted 107 lines · Sumit Saxena

There are certain BSG commands which is to be completed by driver without involving firmware. These requests are termed as driver commands. This patch adds support for the same.

---
  drivers/scsi/mpi3mr/mpi3mr.h          |  16 +-
  drivers/scsi/mpi3mr/mpi3mr_app.c      | 397 +++++++++++++++++++++++
  drivers/scsi/mpi3mr/mpi3mr_debug.h    |  12 +-
  drivers/scsi/mpi3mr/mpi3mr_fw.c       |  21 +-
  drivers/scsi/mpi3mr/mpi3mr_os.c       |   3 +
  include/uapi/scsi/mpi3mr/mpi3mr_bsg.h | 434 ++++++++++++++++++++++++++
  6 files changed, 871 insertions(+), 12 deletions(-)

create mode 100644 include/uapi/scsi/mpi3mr/mpi3mr_bsg.h

drivers/scsi/mpi3mr/mpi3mr.h +13 -3
index f0515f929110..877b0925dbc5 100644
@@ -89,7 +89,7 @@ extern int prot_mask;
  /* Reserved Host Tag definitions */
  #define MPI3MR_HOSTTAG_INVALID		0xFFFF
  #define MPI3MR_HOSTTAG_INITCMDS		1
-#define MPI3MR_HOSTTAG_IOCTLCMDS	2
+#define MPI3MR_HOSTTAG_BSG_CMDS		2
  #define MPI3MR_HOSTTAG_BLK_TMS		5
 
  #define MPI3MR_NUM_DEVRMCMD		16
@@ -202,10 +202,10 @@ enum mpi3mr_iocstate {
  enum mpi3mr_reset_reason {
  	MPI3MR_RESET_FROM_BRINGUP = 1,
  	MPI3MR_RESET_FROM_FAULT_WATCH = 2,
-	MPI3MR_RESET_FROM_IOCTL = 3,
+	MPI3MR_RESET_FROM_APP = 3,
  	MPI3MR_RESET_FROM_EH_HOS = 4,
  	MPI3MR_RESET_FROM_TM_TIMEOUT = 5,
-	MPI3MR_RESET_FROM_IOCTL_TIMEOUT = 6,
+	MPI3MR_RESET_FROM_APP_TIMEOUT = 6,
  	MPI3MR_RESET_FROM_MUR_FAILURE = 7,
  	MPI3MR_RESET_FROM_CTLR_CLEANUP = 8,
  	MPI3MR_RESET_FROM_CIACTIV_FAULT = 9,
@@ -698,6 +698,7 @@ struct scmd_priv {
   * @chain_bitmap_sz: Chain buffer allocator bitmap size
   * @chain_bitmap: Chain buffer allocator bitmap
   * @chain_buf_lock: Chain buffer list lock
+ * @bsg_cmds: Command tracker for BSG command
   * @host_tm_cmds: Command tracker for task management commands
   * @dev_rmhs_cmds: Command tracker for device removal commands
   * @evtack_cmds: Command tracker for event ack commands
@@ -729,6 +730,10 @@ struct scmd_priv {
   * @requested_poll_qcount: User requested poll queue count
   * @bsg_dev: BSG device structure
   * @bsg_queue: Request queue for BSG device
+ * @stop_bsgs: Stop BSG request flag
+ * @logdata_buf: Circular buffer to store log data entries
+ * @logdata_buf_idx: Index of entry in buffer to store
+ * @logdata_entry_sz: log data entry size
   */
  struct mpi3mr_ioc {
  	struct list_head list;
@@ -835,6 +840,7 @@ struct mpi3mr_ioc {
  	void *chain_bitmap;
  	spinlock_t chain_buf_lock;
 
+	struct mpi3mr_drv_cmd bsg_cmds;
  	struct mpi3mr_drv_cmd host_tm_cmds;
  	struct mpi3mr_drv_cmd dev_rmhs_cmds[MPI3MR_NUM_DEVRMCMD];
  	struct mpi3mr_drv_cmd evtack_cmds[MPI3MR_NUM_EVTACKCMD];
@@ -872,6 +878,10 @@ struct mpi3mr_ioc {
 
  	struct device *bsg_dev;
  	struct request_queue *bsg_queue;
+	u8 stop_bsgs;
+	u8 *logdata_buf;
+	u16 logdata_buf_idx;
+	u16 logdata_entry_sz;
  };
 
  /**
drivers/scsi/mpi3mr/mpi3mr_app.c +20 -0
index 9b6698525990..3136f5c5d164 100644
@@ -9,6 +9,386 @@
 
  #include "mpi3mr.h"
  #include <linux/bsg-lib.h>
+#include <uapi/scsi/mpi3mr/mpi3mr_bsg.h>
+
+/**
+ * mpi3mr_bsg_verify_adapter - verify adapter number is valid
+ * @ioc_number: Adapter number
+ * @mriocpp: Pointer to hold per adapter instance
+ *
+ * This function checks whether given adapter number matches
+ * with an adapter id in the driver's list and if so fills
+ * pointer to the per adapter instance in mriocpp else set that
+ * to NULL.
+ *
+ * Return: Nothing.
+ */
+static void mpi3mr_bsg_verify_adapter(int ioc_number,
+	struct mpi3mr_ioc **mriocpp)
+{
+	struct mpi3mr_ioc *mrioc;
+
+	spin_lock(&mrioc_list_lock);

drivers/scsi/mpi3mr/mpi3mr_app.c line 41

Quoted 10 lines
drivers/scsi/mpi3mr/mpi3mr_app.c +10 -0
+	list_for_each_entry(mrioc, &mrioc_list, list) {
+		if (mrioc->id != ioc_number)
+			continue;
+		spin_unlock(&mrioc_list_lock);
+		*mriocpp = mrioc;
+		return;
+	}
+	spin_unlock(&mrioc_list_lock);
+	*mriocpp = NULL;
+}

Agree here with Hannes's comment. return struct mpi3mr_ioc * here.

Quoted 33 lines
drivers/scsi/mpi3mr/mpi3mr_app.c +33 -0
+
+/**
+ * mpi3mr_enable_logdata - Handler for log data enable
+ * @mrioc: Adapter instance reference
+ * @job: BSG job reference
+ *
+ * This function enables log data caching in the driver if not
+ * already enabled and return the maximum number of log data
+ * entries that can be cached in the driver.
+ *
+ * Return: 0 on success and proper error codes on failure
+ */
+static long mpi3mr_enable_logdata(struct mpi3mr_ioc *mrioc,
+	struct bsg_job *job)
+{
+	long rval = -EINVAL;
+	struct mpi3mr_logdata_enable logdata_enable;
+
+	if (mrioc->logdata_buf)
+		goto copy_user_data;
+
+	mrioc->logdata_entry_sz =
+	    (mrioc->reply_sz - (sizeof(struct mpi3_event_notification_reply) - 4))
+	    + MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ;
+	mrioc->logdata_buf_idx = 0;
+
+	mrioc->logdata_buf = kcalloc(MPI3MR_BSG_LOGDATA_MAX_ENTRIES,
+	    mrioc->logdata_entry_sz, GFP_KERNEL);
+	if (!mrioc->logdata_buf)
+		return -ENOMEM;
+
+copy_user_data:
+	memset(&logdata_enable, 0, sizeof(logdata_enable));

drivers/scsi/mpi3mr/mpi3mr_app.c line 84

Quoted 10 lines
drivers/scsi/mpi3mr/mpi3mr_app.c +10 -0
+	logdata_enable.max_entries =
+	    MPI3MR_BSG_LOGDATA_MAX_ENTRIES;
+	if (job->request_payload.payload_len >= sizeof(logdata_enable)) {
+		sg_copy_from_buffer(job->request_payload.sg_list,
+				    job->request_payload.sg_cnt,
+				    &logdata_enable, sizeof(logdata_enable));
+		rval = 0;
+	}
+	return rval;
+}

Again, agree with Hannes on this code. very unusual coding style.

Please follow norm as described by Hannes already.

Quoted 928 lines
drivers/scsi/mpi3mr/mpi3mr_app.c +324 -0
+/**
+ * mpi3mr_get_logdata - Handler for get log data
+ * @mrioc: Adapter instance reference
+ * @job: BSG job pointer
+ * This function copies the log data entries to the user buffer
+ * when log caching is enabled in the driver.
+ *
+ * Return: 0 on success and proper error codes on failure
+ */
+static long mpi3mr_get_logdata(struct mpi3mr_ioc *mrioc,
+	struct bsg_job *job)
+{
+	u16 num_entries, sz, entry_sz = mrioc->logdata_entry_sz;
+
+	if ((!mrioc->logdata_buf) || (job->request_payload.payload_len < entry_sz))
+		return -EINVAL;
+
+	num_entries = job->request_payload.payload_len / entry_sz;
+	if (num_entries > MPI3MR_BSG_LOGDATA_MAX_ENTRIES)
+		num_entries = MPI3MR_BSG_LOGDATA_MAX_ENTRIES;
+	sz = num_entries * entry_sz;
+
+	if (job->request_payload.payload_len >= sz) {
+		sg_copy_from_buffer(job->request_payload.sg_list,
+				    job->request_payload.sg_cnt,
+				    mrioc->logdata_buf, sz);
+		return 0;
+	}
+	return -EINVAL;
+}
+
+/**
+ * mpi3mr_get_all_tgt_info - Get all target information
+ * @mrioc: Adapter instance reference
+ * @job: BSG job reference
+ *
+ * This function copies the driver managed target devices device
+ * handle, persistent ID, bus ID and taret ID to the user
+ * provided buffer for the specific controller. This function
+ * also provides the number of devices managed by the driver for
+ * the specific controller.
+ *
+ * Return: 0 on success and proper error codes on failure
+ */
+static long mpi3mr_get_all_tgt_info(struct mpi3mr_ioc *mrioc,
+	struct bsg_job *job)
+{
+	long rval = -EINVAL;
+	u16 num_devices = 0, i = 0, size;
+	unsigned long flags;
+	struct mpi3mr_tgt_dev *tgtdev;
+	struct mpi3mr_device_map_info *devmap_info = NULL;
+	struct mpi3mr_all_tgt_info *alltgt_info = NULL;
+	uint32_t min_entrylen = 0, kern_entrylen = 0, usr_entrylen = 0;
+
+	if (job->request_payload.payload_len < sizeof(u32)) {
+		dprint_bsg_err(mrioc, "%s: invalid size argument\n",
+		    __func__);
+		return rval;
+	}
+
+	spin_lock_irqsave(&mrioc->tgtdev_lock, flags);
+	list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list)
+		num_devices++;
+	spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags);
+
+	if ((job->request_payload.payload_len == sizeof(u32)) ||
+		list_empty(&mrioc->tgtdev_list)) {
+		sg_copy_from_buffer(job->request_payload.sg_list,
+				    job->request_payload.sg_cnt,
+				    &num_devices, sizeof(num_devices));
+		return 0;
+	}
+
+	kern_entrylen = (num_devices - 1) * sizeof(*devmap_info);
+	size = sizeof(*alltgt_info) + kern_entrylen;
+	alltgt_info = kzalloc(size, GFP_KERNEL);
+	if (!alltgt_info)
+		return -ENOMEM;
+
+	devmap_info = alltgt_info->dmi;
+	memset((u8 *)devmap_info, 0xFF, (kern_entrylen + sizeof(*devmap_info)));
+	spin_lock_irqsave(&mrioc->tgtdev_lock, flags);
+	list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list) {
+		if (i < num_devices) {
+			devmap_info[i].handle = tgtdev->dev_handle;
+			devmap_info[i].perst_id = tgtdev->perst_id;
+			if (tgtdev->host_exposed && tgtdev->starget) {
+				devmap_info[i].target_id = tgtdev->starget->id;
+				devmap_info[i].bus_id =
+				    tgtdev->starget->channel;
+			}
+			i++;
+		}
+	}
+	num_devices = i;
+	spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags);
+
+	memcpy(&alltgt_info->num_devices, &num_devices, sizeof(num_devices));
+
+	usr_entrylen = (job->request_payload.payload_len - sizeof(u32)) / sizeof(*devmap_info);
+	usr_entrylen *= sizeof(*devmap_info);
+	min_entrylen = min(usr_entrylen, kern_entrylen);
+	if (min_entrylen && (!memcpy(&alltgt_info->dmi, devmap_info, min_entrylen))) {
+		dprint_bsg_err(mrioc, "%s:%d: device map info copy failed\n",
+		    __func__, __LINE__);
+		rval = -EFAULT;
+		goto out;
+	}
+
+	sg_copy_from_buffer(job->request_payload.sg_list,
+			    job->request_payload.sg_cnt,
+			    alltgt_info, job->request_payload.payload_len);
+	rval = 0;
+out:
+	kfree(alltgt_info);
+	return rval;
+}
+
+/**
+ * mpi3mr_get_change_count - Get topology change count
+ * @mrioc: Adapter instance reference
+ * @job: BSG job reference
+ *
+ * This function copies the toplogy change count provided by the
+ * driver in events and cached in the driver to the user
+ * provided buffer for the specific controller.
+ *
+ * Return: 0 on success and proper error codes on failure
+ */
+static long mpi3mr_get_change_count(struct mpi3mr_ioc *mrioc,
+	struct bsg_job *job)
+{
+	long rval = -EINVAL;
+	struct mpi3mr_change_count chgcnt;
+
+	memset(&chgcnt, 0, sizeof(chgcnt));
+	chgcnt.change_count = mrioc->change_count;
+	if (job->request_payload.payload_len >= sizeof(chgcnt)) {
+		sg_copy_from_buffer(job->request_payload.sg_list,
+				    job->request_payload.sg_cnt,
+				    &chgcnt, sizeof(chgcnt));
+		rval = 0;
+	}
+	return rval;
+}
+
+/**
+ * mpi3mr_bsg_adp_reset - Issue controller reset
+ * @mrioc: Adapter instance reference
+ * @job: BSG job reference
+ *
+ * This function identifies the user provided reset type and
+ * issues approporiate reset to the controller and wait for that
+ * to complete and reinitialize the controller and then returns
+ *
+ * Return: 0 on success and proper error codes on failure
+ */
+static long mpi3mr_bsg_adp_reset(struct mpi3mr_ioc *mrioc,
+	struct bsg_job *job)
+{
+	long rval = -EINVAL;
+	u8 save_snapdump;
+	struct mpi3mr_bsg_adp_reset adpreset;
+
+	if (job->request_payload.payload_len !=
+			sizeof(adpreset)) {
+		dprint_bsg_err(mrioc, "%s: invalid size argument\n",
+		    __func__);
+		goto out;
+	}
+
+	sg_copy_to_buffer(job->request_payload.sg_list,
+			  job->request_payload.sg_cnt,
+			  &adpreset, sizeof(adpreset));
+
+	switch (adpreset.reset_type) {
+	case MPI3MR_BSG_ADPRESET_SOFT:
+		save_snapdump = 0;
+		break;
+	case MPI3MR_BSG_ADPRESET_DIAG_FAULT:
+		save_snapdump = 1;
+		break;
+	default:
+		dprint_bsg_err(mrioc, "%s: unknown reset_type(%d)\n",
+		    __func__, adpreset.reset_type);
+		goto out;
+	}
+
+	rval = mpi3mr_soft_reset_handler(mrioc, MPI3MR_RESET_FROM_APP,
+	    save_snapdump);
+
+	if (rval)
+		dprint_bsg_err(mrioc,
+		    "%s: reset handler returned error(%ld) for reset type %d\n",
+		    __func__, rval, adpreset.reset_type);
+out:
+	return rval;
+}
+
+/**
+ * mpi3mr_bsg_populate_adpinfo - Get adapter info command handler
+ * @mrioc: Adapter instance reference
+ * @job: BSG job reference
+ *
+ * This function provides adapter information for the given
+ * controller
+ *
+ * Return: 0 on success and proper error codes on failure
+ */
+static long mpi3mr_bsg_populate_adpinfo(struct mpi3mr_ioc *mrioc,
+	struct bsg_job *job)
+{
+	enum mpi3mr_iocstate ioc_state;
+	struct mpi3mr_bsg_in_adpinfo adpinfo;
+
+	memset(&adpinfo, 0, sizeof(adpinfo));
+	adpinfo.adp_type = MPI3MR_BSG_ADPTYPE_AVGFAMILY;
+	adpinfo.pci_dev_id = mrioc->pdev->device;
+	adpinfo.pci_dev_hw_rev = mrioc->pdev->revision;
+	adpinfo.pci_subsys_dev_id = mrioc->pdev->subsystem_device;
+	adpinfo.pci_subsys_ven_id = mrioc->pdev->subsystem_vendor;
+	adpinfo.pci_bus = mrioc->pdev->bus->number;
+	adpinfo.pci_dev = PCI_SLOT(mrioc->pdev->devfn);
+	adpinfo.pci_func = PCI_FUNC(mrioc->pdev->devfn);
+	adpinfo.pci_seg_id = pci_domain_nr(mrioc->pdev->bus);
+	adpinfo.app_intfc_ver = MPI3MR_IOCTL_VERSION;
+
+	ioc_state = mpi3mr_get_iocstate(mrioc);
+	if (ioc_state == MRIOC_STATE_UNRECOVERABLE)
+		adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_UNRECOVERABLE;
+	else if ((mrioc->reset_in_progress) || (mrioc->stop_bsgs))
+		adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_IN_RESET;
+	else if (ioc_state == MRIOC_STATE_FAULT)
+		adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_FAULT;
+	else
+		adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_OPERATIONAL;
+
+	memcpy((u8 *)&adpinfo.driver_info, (u8 *)&mrioc->driver_info,
+	    sizeof(adpinfo.driver_info));
+
+	if (job->request_payload.payload_len >= sizeof(adpinfo)) {
+		sg_copy_from_buffer(job->request_payload.sg_list,
+				    job->request_payload.sg_cnt,
+				    &adpinfo, sizeof(adpinfo));
+		return 0;
+	}
+	return -EINVAL;
+}
+
+/**
+ * mpi3mr_bsg_process_drv_cmds - Driver Command handler
+ * @job: BSG job reference
+ *
+ * This function is the top level handler for driver commands,
+ * this does basic validation of the buffer and identifies the
+ * opcode and switches to correct sub handler.
+ *
+ * Return: 0 on success and proper error codes on failure
+ */
+static long mpi3mr_bsg_process_drv_cmds(struct bsg_job *job)
+{
+	long rval = -EINVAL;
+	struct mpi3mr_ioc *mrioc = NULL;
+	struct mpi3mr_bsg_packet *bsg_req = NULL;
+	struct mpi3mr_bsg_drv_cmd *drvrcmd = NULL;
+
+	bsg_req = job->request;
+	drvrcmd = &bsg_req->cmd.drvrcmd;
+
+	mpi3mr_bsg_verify_adapter(drvrcmd->mrioc_id, &mrioc);
+	if (!mrioc)
+		return -ENODEV;
+
+	if (drvrcmd->opcode == MPI3MR_DRVBSG_OPCODE_ADPINFO) {
+		rval = mpi3mr_bsg_populate_adpinfo(mrioc, job);
+		return rval;
+	}
+
+	if (mutex_lock_interruptible(&mrioc->bsg_cmds.mutex))
+		return -ERESTARTSYS;
+
+	switch (drvrcmd->opcode) {
+	case MPI3MR_DRVBSG_OPCODE_ADPRESET:
+		rval = mpi3mr_bsg_adp_reset(mrioc, job);
+		break;
+	case MPI3MR_DRVBSG_OPCODE_ALLTGTDEVINFO:
+		rval = mpi3mr_get_all_tgt_info(mrioc, job);
+		break;
+	case MPI3MR_DRVBSG_OPCODE_GETCHGCNT:
+		rval = mpi3mr_get_change_count(mrioc, job);
+		break;
+	case MPI3MR_DRVBSG_OPCODE_LOGDATAENABLE:
+		rval = mpi3mr_enable_logdata(mrioc, job);
+		break;
+	case MPI3MR_DRVBSG_OPCODE_GETLOGDATA:
+		rval = mpi3mr_get_logdata(mrioc, job);
+		break;
+	case MPI3MR_DRVBSG_OPCODE_UNKNOWN:
+	default:
+		pr_err("%s: unsupported driver command opcode %d\n",
+		    MPI3MR_DRIVER_NAME, drvrcmd->opcode);
+		break;
+	}
+	mutex_unlock(&mrioc->bsg_cmds.mutex);
+	return rval;
+}
 
  /**
   * mpi3mr_bsg_request - bsg request entry point
@@ -20,6 +400,23 @@
   */
  int mpi3mr_bsg_request(struct bsg_job *job)
  {
+	long rval = -EINVAL;
+	unsigned int reply_payload_rcv_len = 0;
+
+	struct mpi3mr_bsg_packet *bsg_req = job->request;
+
+	switch (bsg_req->cmd_type) {
+	case MPI3MR_DRV_CMD:
+		rval = mpi3mr_bsg_process_drv_cmds(job);
+		break;
+	default:
+		pr_err("%s: unsupported BSG command(0x%08x)\n",
+		    MPI3MR_DRIVER_NAME, bsg_req->cmd_type);
+		break;
+	}
+
+	bsg_job_done(job, rval, reply_payload_rcv_len);
+
  	return 0;
  }
 
drivers/scsi/mpi3mr/mpi3mr_debug.h +6 -6
index c7982443f45a..65bfac72948c 100644
@@ -23,8 +23,8 @@
  #define MPI3_DEBUG_RESET		0x00000020
  #define MPI3_DEBUG_SCSI_ERROR		0x00000040
  #define MPI3_DEBUG_REPLY		0x00000080
-#define MPI3_DEBUG_IOCTL_ERROR		0x00008000
-#define MPI3_DEBUG_IOCTL_INFO		0x00010000
+#define MPI3_DEBUG_BSG_ERROR		0x00008000
+#define MPI3_DEBUG_BSG_INFO		0x00010000
  #define MPI3_DEBUG_SCSI_INFO		0x00020000
  #define MPI3_DEBUG			0x01000000
  #define MPI3_DEBUG_SG			0x02000000
@@ -110,15 +110,15 @@
  	} while (0)
 
 
-#define dprint_ioctl_info(ioc, fmt, ...) \
+#define dprint_bsg_info(ioc, fmt, ...) \
  	do { \
-		if (ioc->logging_level & MPI3_DEBUG_IOCTL_INFO) \
+		if (ioc->logging_level & MPI3_DEBUG_BSG_INFO) \
  			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  	} while (0)
 
-#define dprint_ioctl_err(ioc, fmt, ...) \
+#define dprint_bsg_err(ioc, fmt, ...) \
  	do { \
-		if (ioc->logging_level & MPI3_DEBUG_IOCTL_ERROR) \
+		if (ioc->logging_level & MPI3_DEBUG_BSG_ERROR) \
  			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  	} while (0)
 
drivers/scsi/mpi3mr/mpi3mr_fw.c +18 -3
index e25c02466043..480730721f50 100644
@@ -297,6 +297,8 @@ mpi3mr_get_drv_cmd(struct mpi3mr_ioc *mrioc, u16 host_tag,
  	switch (host_tag) {
  	case MPI3MR_HOSTTAG_INITCMDS:
  		return &mrioc->init_cmds;
+	case MPI3MR_HOSTTAG_BSG_CMDS:
+		return &mrioc->bsg_cmds;
  	case MPI3MR_HOSTTAG_BLK_TMS:
  		return &mrioc->host_tm_cmds;
  	case MPI3MR_HOSTTAG_INVALID:
@@ -865,10 +867,10 @@ static const struct {
  } mpi3mr_reset_reason_codes[] = {
  	{ MPI3MR_RESET_FROM_BRINGUP, "timeout in bringup" },
  	{ MPI3MR_RESET_FROM_FAULT_WATCH, "fault" },
-	{ MPI3MR_RESET_FROM_IOCTL, "application invocation" },
+	{ MPI3MR_RESET_FROM_APP, "application invocation" },
  	{ MPI3MR_RESET_FROM_EH_HOS, "error handling" },
  	{ MPI3MR_RESET_FROM_TM_TIMEOUT, "TM timeout" },
-	{ MPI3MR_RESET_FROM_IOCTL_TIMEOUT, "IOCTL timeout" },
+	{ MPI3MR_RESET_FROM_APP_TIMEOUT, "application command timeout" },
  	{ MPI3MR_RESET_FROM_MUR_FAILURE, "MUR failure" },
  	{ MPI3MR_RESET_FROM_CTLR_CLEANUP, "timeout in controller cleanup" },
  	{ MPI3MR_RESET_FROM_CIACTIV_FAULT, "component image activation fault" },
@@ -2813,6 +2815,10 @@ static int mpi3mr_alloc_reply_sense_bufs(struct mpi3mr_ioc *mrioc)
  	if (!mrioc->init_cmds.reply)
  		goto out_failed;
 
+	mrioc->bsg_cmds.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL);
+	if (!mrioc->bsg_cmds.reply)
+		goto out_failed;
+
  	for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++) {
  		mrioc->dev_rmhs_cmds[i].reply = kzalloc(mrioc->reply_sz,
  		    GFP_KERNEL);
@@ -3948,6 +3954,8 @@ void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc)
 
  	if (mrioc->init_cmds.reply) {
  		memset(mrioc->init_cmds.reply, 0, sizeof(*mrioc->init_cmds.reply));
+		memset(mrioc->bsg_cmds.reply, 0,
+		    sizeof(*mrioc->bsg_cmds.reply));
  		memset(mrioc->host_tm_cmds.reply, 0,
  		    sizeof(*mrioc->host_tm_cmds.reply));
  		for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++)
@@ -4050,6 +4058,9 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc)
  	kfree(mrioc->init_cmds.reply);
  	mrioc->init_cmds.reply = NULL;
 
+	kfree(mrioc->bsg_cmds.reply);
+	mrioc->bsg_cmds.reply = NULL;
+
  	kfree(mrioc->host_tm_cmds.reply);
  	mrioc->host_tm_cmds.reply = NULL;
 
@@ -4235,6 +4246,8 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc)
 
  	cmdptr = &mrioc->init_cmds;
  	mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
+	cmdptr = &mrioc->bsg_cmds;
+	mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
  	cmdptr = &mrioc->host_tm_cmds;
  	mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
 
@@ -4258,7 +4271,7 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc)
   * This is an handler for recovering controller by issuing soft
   * reset are diag fault reset.  This is a blocking function and
   * when one reset is executed if any other resets they will be
- * blocked. All IOCTLs/IO will be blocked during the reset. If
+ * blocked. All BSG requests will be blocked during the reset. If
   * controller reset is successful then the controller will be
   * reinitalized, otherwise the controller will be marked as not
   * recoverable
@@ -4305,6 +4318,7 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc,
  	    mpi3mr_reset_rc_name(reset_reason));
 
  	mrioc->reset_in_progress = 1;
+	mrioc->stop_bsgs = 1;
  	mrioc->prev_reset_result = -1;
 
  	if ((!snapdump) && (reset_reason != MPI3MR_RESET_FROM_FAULT_WATCH) &&
@@ -4377,6 +4391,7 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc,
  			    &mrioc->watchdog_work,
  			    msecs_to_jiffies(MPI3MR_WATCHDOG_INTERVAL));
  		spin_unlock_irqrestore(&mrioc->watchdog_lock, flags);
+		mrioc->stop_bsgs = 0;
  	} else {
  		mpi3mr_issue_reset(mrioc,
  		    MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, reset_reason);
drivers/scsi/mpi3mr/mpi3mr_os.c +3 -0
index faf14a5f9123..a03e39083a42 100644
@@ -3589,6 +3589,7 @@ static int mpi3mr_scan_finished(struct Scsi_Host *shost,
 
  	mpi3mr_start_watchdog(mrioc);
  	mrioc->is_driver_loading = 0;
+	mrioc->stop_bsgs = 0;
  	return 1;
  }
 
@@ -4259,6 +4260,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
  	mutex_init(&mrioc->reset_mutex);
  	mpi3mr_init_drv_cmd(&mrioc->init_cmds, MPI3MR_HOSTTAG_INITCMDS);
  	mpi3mr_init_drv_cmd(&mrioc->host_tm_cmds, MPI3MR_HOSTTAG_BLK_TMS);
+	mpi3mr_init_drv_cmd(&mrioc->bsg_cmds, MPI3MR_HOSTTAG_BSG_CMDS);
 
  	for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++)
  		mpi3mr_init_drv_cmd(&mrioc->dev_rmhs_cmds[i],
@@ -4271,6 +4273,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
  	mrioc->logging_level = logging_level;
  	mrioc->shost = shost;
  	mrioc->pdev = pdev;
+	mrioc->stop_bsgs = 1;
 
  	/* init shost parameters */
  	shost->max_cmd_len = MPI3MR_MAX_CDB_LENGTH;
include/uapi/scsi/mpi3mr/mpi3mr_bsg.h new file +434 -0
new file mode 100644
index 000000000000..7535a9353807
@@ -0,0 +1,434 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Driver for Broadcom MPI3 Storage Controllers
+ *
+ * Copyright (C) 2017-2022 Broadcom Inc.
+ *  (mailto: [email protected])
+ *
+ */
+
+#ifndef MPI3MR_BSG_H_INCLUDED
+#define MPI3MR_BSG_H_INCLUDED
+
+
+/* Definitions for BSG commands */
+#define MPI3MR_IOCTL_VERSION			0x06
+
+#define MPI3MR_APP_DEFAULT_TIMEOUT		(60) /*seconds*/
+
+#define MPI3MR_BSG_ADPTYPE_UNKNOWN		0
+#define MPI3MR_BSG_ADPTYPE_AVGFAMILY		1
+
+#define MPI3MR_BSG_ADPSTATE_UNKNOWN		0
+#define MPI3MR_BSG_ADPSTATE_OPERATIONAL		1
+#define MPI3MR_BSG_ADPSTATE_FAULT		2
+#define MPI3MR_BSG_ADPSTATE_IN_RESET		3
+#define MPI3MR_BSG_ADPSTATE_UNRECOVERABLE	4
+
+#define MPI3MR_BSG_ADPRESET_UNKNOWN		0
+#define MPI3MR_BSG_ADPRESET_SOFT		1
+#define MPI3MR_BSG_ADPRESET_DIAG_FAULT		2
+
+#define MPI3MR_BSG_LOGDATA_MAX_ENTRIES		400
+#define MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ	4
+
+#define MPI3MR_DRVBSG_OPCODE_UNKNOWN		0
+#define MPI3MR_DRVBSG_OPCODE_ADPINFO		1
+#define MPI3MR_DRVBSG_OPCODE_ADPRESET		2
+#define MPI3MR_DRVBSG_OPCODE_ALLTGTDEVINFO	4
+#define MPI3MR_DRVBSG_OPCODE_GETCHGCNT		5
+#define MPI3MR_DRVBSG_OPCODE_LOGDATAENABLE	6
+#define MPI3MR_DRVBSG_OPCODE_PELENABLE		7
+#define MPI3MR_DRVBSG_OPCODE_GETLOGDATA		8
+#define MPI3MR_DRVBSG_OPCODE_QUERY_HDB		9
+#define MPI3MR_DRVBSG_OPCODE_REPOST_HDB		10
+#define MPI3MR_DRVBSG_OPCODE_UPLOAD_HDB		11
+#define MPI3MR_DRVBSG_OPCODE_REFRESH_HDB_TRIGGERS	12
+
+
+#define MPI3MR_BSG_BUFTYPE_UNKNOWN		0
+#define MPI3MR_BSG_BUFTYPE_RAIDMGMT_CMD		1
+#define MPI3MR_BSG_BUFTYPE_RAIDMGMT_RESP	2
+#define MPI3MR_BSG_BUFTYPE_DATA_IN		3
+#define MPI3MR_BSG_BUFTYPE_DATA_OUT		4
+#define MPI3MR_BSG_BUFTYPE_MPI_REPLY		5
+#define MPI3MR_BSG_BUFTYPE_ERR_RESPONSE		6
+#define MPI3MR_BSG_BUFTYPE_MPI_REQUEST		0xFE
+
+#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_UNKNOWN	0
+#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_STATUS	1
+#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_ADDRESS	2
+
+#define MPI3MR_HDB_BUFTYPE_UNKNOWN		0
+#define MPI3MR_HDB_BUFTYPE_TRACE		1
+#define MPI3MR_HDB_BUFTYPE_FIRMWARE		2
+#define MPI3MR_HDB_BUFTYPE_RESERVED		3
+
+#define MPI3MR_HDB_BUFSTATUS_UNKNOWN		0
+#define MPI3MR_HDB_BUFSTATUS_NOT_ALLOCATED	1
+#define MPI3MR_HDB_BUFSTATUS_POSTED_UNPAUSED	2
+#define MPI3MR_HDB_BUFSTATUS_POSTED_PAUSED	3
+#define MPI3MR_HDB_BUFSTATUS_RELEASED		4
+
+#define MPI3MR_HDB_TRIGGER_TYPE_UNKNOWN		0
+#define MPI3MR_HDB_TRIGGER_TYPE_DIAGFAULT	1
+#define MPI3MR_HDB_TRIGGER_TYPE_ELEMENT		2
+#define MPI3MR_HDB_TRIGGER_TYPE_MASTER		3
+
+
+/* Supported BSG commands */
+enum command {
+	MPI3MR_DRV_CMD = 1,
+	MPI3MR_MPT_CMD = 2,
+};
+
+/**
+ * struct mpi3mr_bsg_in_adpinfo - Adapter information request
+ * data returned by the driver.
+ *
+ * @adp_type: Adapter type
+ * @rsvd1: Reserved
+ * @pci_dev_id: PCI device ID of the adapter
+ * @pci_dev_hw_rev: PCI revision of the adapter
+ * @pci_subsys_dev_id: PCI subsystem device ID of the adapter
+ * @pci_subsys_ven_id: PCI subsystem vendor ID of the adapter
+ * @pci_dev: PCI device
+ * @pci_func: PCI function
+ * @pci_bus: PCI bus
+ * @rsvd2: Reserved
+ * @pci_seg_id: PCI segment ID
+ * @app_intfc_ver: version of the application interface definition
+ * @rsvd3: Reserved
+ * @rsvd4: Reserved
+ * @rsvd5: Reserved
+ * @driver_info: Driver Information (Version/Name)
+ */
+struct mpi3mr_bsg_in_adpinfo {
+	uint32_t adp_type;
+	uint32_t rsvd1;
+	uint32_t pci_dev_id;
+	uint32_t pci_dev_hw_rev;
+	uint32_t pci_subsys_dev_id;
+	uint32_t pci_subsys_ven_id;
+	uint32_t pci_dev:5;
+	uint32_t pci_func:3;
+	uint32_t pci_bus:8;
+	uint16_t rsvd2;
+	uint32_t pci_seg_id;
+	uint32_t app_intfc_ver;
+	uint8_t adp_state;
+	uint8_t rsvd3;
+	uint16_t rsvd4;
+	uint32_t rsvd5[2];
+	struct mpi3_driver_info_layout driver_info;
+};
+
+/**
+ * struct mpi3mr_bsg_adp_reset - Adapter reset request
+ * payload data to the driver.
+ *
+ * @reset_type: Reset type
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ */
+struct mpi3mr_bsg_adp_reset {
+	uint8_t reset_type;
+	uint8_t rsvd1;
+	uint16_t rsvd2;
+};
+
+/**
+ * struct mpi3mr_change_count - Topology change count
+ * returned by the driver.
+ *
+ * @change_count: Topology change count
+ * @rsvd: Reserved
+ */
+struct mpi3mr_change_count {
+	uint16_t change_count;
+	uint16_t rsvd;
+};
+
+/**
+ * struct mpi3mr_device_map_info - Target device mapping
+ * information
+ *
+ * @handle: Firmware device handle
+ * @perst_id: Persistent ID assigned by the firmware
+ * @target_id: Target ID assigned by the driver
+ * @bus_id: Bus ID assigned by the driver
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ */
+struct mpi3mr_device_map_info {
+	uint16_t handle;
+	uint16_t perst_id;
+	uint32_t target_id;
+	uint8_t bus_id;
+	uint8_t rsvd1;
+	uint16_t rsvd2;
+};
+
+/**
+ * struct mpi3mr_all_tgt_info - Target device mapping
+ * information returned by the driver
+ *
+ * @num_devices: The number of devices in driver's inventory
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @dmi: Variable length array of mapping information of targets
+ */
+struct mpi3mr_all_tgt_info {
+	uint16_t num_devices;
+	uint16_t rsvd1;
+	uint32_t rsvd2;
+	struct mpi3mr_device_map_info dmi[1];
+};
+
+/**
+ * struct mpi3mr_logdata_enable - Number of log data
+ * entries saved by the driver returned as payload data for
+ * enable logdata BSG request by the driver.
+ *
+ * @max_entries: Number of log data entries cached by the driver
+ * @rsvd: Reserved
+ */
+struct mpi3mr_logdata_enable {
+	uint16_t max_entries;
+	uint16_t rsvd;
+};
+
+/**
+ * struct mpi3mr_bsg_out_pel_enable - PEL enable request payload
+ * data to the driver.
+ *
+ * @pel_locale: PEL locale to the firmware
+ * @pel_class: PEL class to the firmware
+ * @rsvd: Reserved
+ */
+struct mpi3mr_bsg_out_pel_enable {
+	uint16_t pel_locale;
+	uint8_t pel_class;
+	uint8_t rsvd;
+};
+
+/**
+ * struct mpi3mr_logdata_entry - Log data entry cached by the
+ * driver.
+ *
+ * @valid_entry: Is the entry valid
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @data: Variable length Log entry data
+ */
+struct mpi3mr_logdata_entry {
+	uint8_t valid_entry;
+	uint8_t rsvd1;
+	uint16_t rsvd2;
+	uint8_t data[1]; /* Variable length Array */
+};
+
+/**
+ * struct mpi3mr_bsg_in_log_data - Log data entries saved by
+ * the driver returned as payload data for Get logdata request
+ * by the driver.
+ *
+ * @entry: Variable length Log data entry array
+ */
+struct mpi3mr_bsg_in_log_data {
+	struct mpi3mr_logdata_entry entry[1];
+};
+
+/**
+ * struct mpi3mr_hdb_entry - host diag buffer entry.
+ *
+ * @buf_type: Buffer type
+ * @status: Buffer status
+ * @trigger_type: Trigger type
+ * @rsvd1: Reserved
+ * @size: Buffer size
+ * @rsvd2: Reserved
+ * @trigger_data: Trigger specific data
+ * @rsvd3: Reserved
+ * @rsvd4: Reserved
+ */
+struct mpi3mr_hdb_entry {
+	uint8_t buf_type;
+	uint8_t status;
+	uint8_t trigger_type;
+	uint8_t rsvd1;
+	uint16_t size;
+	uint16_t rsvd2;
+	uint64_t trigger_data;
+	uint32_t rsvd3;
+	uint32_t rsvd4;
+};
+
+
+/**
+ * struct mpi3mr_bsg_in_hdb_status - This structure contains
+ * return data for the BSG request to retrieve the number of host
+ * diagnostic buffers supported by the driver and their current
+ * status and additional status specific data if any in forms of
+ * multiple hdb entries.
+ *
+ * @num_hdb_types: Number of host diag buffer types supported
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @rsvd3: Reserved
+ * @entry: Variable length Diag buffer status entry array
+ */
+struct mpi3mr_bsg_in_hdb_status {
+	uint8_t num_hdb_types;
+	uint8_t rsvd1;
+	uint16_t rsvd2;
+	uint32_t rsvd3;
+	struct mpi3mr_hdb_entry entry[1];
+};
+
+/**
+ * struct mpi3mr_bsg_out_repost_hdb - Repost host diagnostic
+ * buffer request payload data to the driver.
+ *
+ * @buf_type: Buffer type
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ */
+struct mpi3mr_bsg_out_repost_hdb {
+	uint8_t buf_type;
+	uint8_t rsvd1;
+	uint16_t rsvd2;
+};
+
+/**
+ * struct mpi3mr_bsg_out_upload_hdb - Upload host diagnostic
+ * buffer request payload data to the driver.
+ *
+ * @buf_type: Buffer type
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @start_offset: Start offset of the buffer from where to copy
+ * @length: Length of the buffer to copy
+ */
+struct mpi3mr_bsg_out_upload_hdb {
+	uint8_t buf_type;
+	uint8_t rsvd1;
+	uint16_t rsvd2;
+	uint32_t start_offset;
+	uint32_t length;
+};
+
+/**
+ * struct mpi3mr_bsg_out_refresh_hdb_triggers - Refresh host
+ * diagnostic buffer triggers request payload data to the driver.
+ *
+ * @page_type: Page type
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ */
+struct mpi3mr_bsg_out_refresh_hdb_triggers {
+	uint8_t page_type;
+	uint8_t rsvd1;
+	uint16_t rsvd2;
+};
+/**
+ * struct mpi3mr_bsg_drv_cmd -  Generic bsg data
+ * structure for all driver specific requests.
+ *
+ * @mrioc_id: Controller ID
+ * @opcode: Driver specific opcode
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ */
+struct mpi3mr_bsg_drv_cmd {
+	uint8_t mrioc_id;
+	uint8_t opcode;
+	uint16_t rsvd1;
+	uint32_t rsvd2[4];
+};
+/**
+ * struct mpi3mr_bsg_in_reply_buf - MPI reply buffer returned
+ * for MPI Passthrough request .
+ *
+ * @mpi_reply_type: Type of MPI reply
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @reply_buf: Variable Length buffer based on mpirep type
+ */
+struct mpi3mr_bsg_in_reply_buf {
+	uint8_t mpi_reply_type;
+	uint8_t rsvd1;
+	uint16_t rsvd2;
+	uint8_t reply_buf[1];
+};
+
+/**
+ * struct mpi3mr_buf_entry - User buffer descriptor for MPI
+ * Passthrough requests.
+ *
+ * @buf_type: Buffer type
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @buf_len: Buffer length
+ */
+struct mpi3mr_buf_entry {
+	uint8_t buf_type;
+	uint8_t rsvd1;
+	uint16_t rsvd2;
+	uint32_t buf_len;
+};
+/**
+ * struct mpi3mr_bsg_buf_entry_list - list of user buffer
+ * descriptor for MPI Passthrough requests.
+ *
+ * @num_of_entries: Number of buffer descriptors
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @rsvd3: Reserved
+ * @buf_entry: Variable length array of buffer descriptors
+ */
+struct mpi3mr_buf_entry_list {
+	uint8_t num_of_entries;
+	uint8_t rsvd1;
+	uint16_t rsvd2;
+	uint32_t rsvd3;
+	struct mpi3mr_buf_entry buf_entry[1];
+};
+/**
+ * struct mpi3mr_bsg_mptcmd -  Generic bsg data
+ * structure for all MPI Passthrough requests .
+ *
+ * @mrioc_id: Controller ID
+ * @rsvd1: Reserved
+ * @timeout: MPI request timeout
+ * @buf_entry_list: Buffer descriptor list
+ */
+struct mpi3mr_bsg_mptcmd {
+	uint8_t mrioc_id;
+	uint8_t rsvd1;
+	uint16_t timeout;
+	uint32_t rsvd2;
+	struct mpi3mr_buf_entry_list buf_entry_list;
+};
+
+/**
+ * struct mpi3mr_bsg_packet -  Generic bsg data
+ * structure for all supported requests .
+ *
+ * @cmd_type: represents drvrcmd or mptcmd
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @drvrcmd: driver request structure
+ * @mptcmd: mpt request structure
+ */
+struct mpi3mr_bsg_packet {
+	uint8_t cmd_type;
+	uint8_t rsvd1;
+	uint16_t rsvd2;
+	uint32_t rsvd3;
+	union {
+		struct mpi3mr_bsg_drv_cmd drvrcmd;
+		struct mpi3mr_bsg_mptcmd mptcmd;
+	} cmd;
+};
+#endif
Signature · 1 line
Himanshu Madhani                                Oracle Linux Engineering
author maintainer
#7 lore raw

PATCH v3 3/8 mpi3mr: move MPI headers to uapi/scsi/mpi3mr

In reply to Sumit Saxena

MPI headers are used by user space applications so it makes sense to move them to uapi/scsi/mpi3mr.

---
 drivers/scsi/mpi3mr/mpi3mr.h                       | 14 +++++++-------
 .../mpi => include/uapi/scsi/mpi3mr}/mpi30_cnfg.h  |  0
 .../mpi => include/uapi/scsi/mpi3mr}/mpi30_image.h |  0
 .../mpi => include/uapi/scsi/mpi3mr}/mpi30_init.h  |  0
 .../mpi => include/uapi/scsi/mpi3mr}/mpi30_ioc.h   |  0
 .../mpi => include/uapi/scsi/mpi3mr}/mpi30_pci.h   |  0
 .../mpi => include/uapi/scsi/mpi3mr}/mpi30_sas.h   |  0
 .../uapi/scsi/mpi3mr}/mpi30_transport.h            |  0
 8 files changed, 7 insertions(+), 7 deletions(-)
 rename {drivers/scsi/mpi3mr/mpi => include/uapi/scsi/mpi3mr}/mpi30_cnfg.h (100%)
 rename {drivers/scsi/mpi3mr/mpi => include/uapi/scsi/mpi3mr}/mpi30_image.h (100%)
 rename {drivers/scsi/mpi3mr/mpi => include/uapi/scsi/mpi3mr}/mpi30_init.h (100%)
 rename {drivers/scsi/mpi3mr/mpi => include/uapi/scsi/mpi3mr}/mpi30_ioc.h (100%)
 rename {drivers/scsi/mpi3mr/mpi => include/uapi/scsi/mpi3mr}/mpi30_pci.h (100%)
 rename {drivers/scsi/mpi3mr/mpi => include/uapi/scsi/mpi3mr}/mpi30_sas.h (100%)
 rename {drivers/scsi/mpi3mr/mpi => include/uapi/scsi/mpi3mr}/mpi30_transport.h (100%)
drivers/scsi/mpi3mr/mpi3mr.h +7 -7
index 877b0925dbc5..7538571e61a6 100644
@@ -39,13 +39,13 @@
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_tcq.h>
 
-#include "mpi/mpi30_transport.h"
-#include "mpi/mpi30_cnfg.h"
-#include "mpi/mpi30_image.h"
-#include "mpi/mpi30_init.h"
-#include "mpi/mpi30_ioc.h"
-#include "mpi/mpi30_sas.h"
-#include "mpi/mpi30_pci.h"
+#include <uapi/scsi/mpi3mr/mpi30_transport.h>
+#include <uapi/scsi/mpi3mr/mpi30_cnfg.h>
+#include <uapi/scsi/mpi3mr/mpi30_image.h>
+#include <uapi/scsi/mpi3mr/mpi30_init.h>
+#include <uapi/scsi/mpi3mr/mpi30_ioc.h>
+#include <uapi/scsi/mpi3mr/mpi30_sas.h>
+#include <uapi/scsi/mpi3mr/mpi30_pci.h>
 #include "mpi3mr_debug.h"
 
 /* Global list and lock for storing multiple adapters managed by the driver */
include/uapi/scsi/mpi3mr/mpi30_cnfg.h renamed from drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h +0 -0
similarity index 100%
rename from drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h
rename to include/uapi/scsi/mpi3mr/mpi30_cnfg.h
include/uapi/scsi/mpi3mr/mpi30_image.h renamed from drivers/scsi/mpi3mr/mpi/mpi30_image.h +0 -0
similarity index 100%
rename from drivers/scsi/mpi3mr/mpi/mpi30_image.h
rename to include/uapi/scsi/mpi3mr/mpi30_image.h
include/uapi/scsi/mpi3mr/mpi30_init.h renamed from drivers/scsi/mpi3mr/mpi/mpi30_init.h +0 -0
similarity index 100%
rename from drivers/scsi/mpi3mr/mpi/mpi30_init.h
rename to include/uapi/scsi/mpi3mr/mpi30_init.h
include/uapi/scsi/mpi3mr/mpi30_ioc.h renamed from drivers/scsi/mpi3mr/mpi/mpi30_ioc.h +0 -0
similarity index 100%
rename from drivers/scsi/mpi3mr/mpi/mpi30_ioc.h
rename to include/uapi/scsi/mpi3mr/mpi30_ioc.h
include/uapi/scsi/mpi3mr/mpi30_pci.h renamed from drivers/scsi/mpi3mr/mpi/mpi30_pci.h +0 -0
similarity index 100%
rename from drivers/scsi/mpi3mr/mpi/mpi30_pci.h
rename to include/uapi/scsi/mpi3mr/mpi30_pci.h
include/uapi/scsi/mpi3mr/mpi30_sas.h renamed from drivers/scsi/mpi3mr/mpi/mpi30_sas.h +0 -0
similarity index 100%
rename from drivers/scsi/mpi3mr/mpi/mpi30_sas.h
rename to include/uapi/scsi/mpi3mr/mpi30_sas.h
include/uapi/scsi/mpi3mr/mpi30_transport.h renamed from drivers/scsi/mpi3mr/mpi/mpi30_transport.h +0 -0
similarity index 100%
rename from drivers/scsi/mpi3mr/mpi/mpi30_transport.h
rename to include/uapi/scsi/mpi3mr/mpi30_transport.h
Signature · 1 line
2.27.0
#8 lore raw

Re: [PATCH v3 3/8] mpi3mr: move MPI headers to uapi/scsi/mpi3mr

include/uapi/scsi/mpi3mr/mpi30_transport.h

Quoted 28 lines · Sumit Saxena
include/uapi/scsi/mpi3mr/mpi30_cnfg.h renamed from drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h +0 -0
similarity index 100%
rename from drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h
rename to include/uapi/scsi/mpi3mr/mpi30_cnfg.h
include/uapi/scsi/mpi3mr/mpi30_image.h renamed from drivers/scsi/mpi3mr/mpi/mpi30_image.h +0 -0
similarity index 100%
rename from drivers/scsi/mpi3mr/mpi/mpi30_image.h
rename to include/uapi/scsi/mpi3mr/mpi30_image.h
include/uapi/scsi/mpi3mr/mpi30_init.h renamed from drivers/scsi/mpi3mr/mpi/mpi30_init.h +0 -0
similarity index 100%
rename from drivers/scsi/mpi3mr/mpi/mpi30_init.h
rename to include/uapi/scsi/mpi3mr/mpi30_init.h
include/uapi/scsi/mpi3mr/mpi30_ioc.h renamed from drivers/scsi/mpi3mr/mpi/mpi30_ioc.h +0 -0
similarity index 100%
rename from drivers/scsi/mpi3mr/mpi/mpi30_ioc.h
rename to include/uapi/scsi/mpi3mr/mpi30_ioc.h
include/uapi/scsi/mpi3mr/mpi30_pci.h renamed from drivers/scsi/mpi3mr/mpi/mpi30_pci.h +0 -0
similarity index 100%
rename from drivers/scsi/mpi3mr/mpi/mpi30_pci.h
rename to include/uapi/scsi/mpi3mr/mpi30_pci.h
include/uapi/scsi/mpi3mr/mpi30_sas.h renamed from drivers/scsi/mpi3mr/mpi/mpi30_sas.h +0 -0
similarity index 100%
rename from drivers/scsi/mpi3mr/mpi/mpi30_sas.h
rename to include/uapi/scsi/mpi3mr/mpi30_sas.h
include/uapi/scsi/mpi3mr/mpi30_transport.h renamed from drivers/scsi/mpi3mr/mpi/mpi30_transport.h +0 -0
similarity index 100%
rename from drivers/scsi/mpi3mr/mpi/mpi30_transport.h
rename to include/uapi/scsi/mpi3mr/mpi30_transport.h

Please only move the definitions that are useful for user space into include/uapi instead of moving all definitions, including those that are only used inside the kernel.

Thanks,

Bart.

#9 lore raw

Re: [PATCH v3 3/8] mpi3mr: move MPI headers to uapi/scsi/mpi3mr

In reply to Sumit Saxena
Quoted 2 lines · Sumit Saxena

MPI headers are used by user space applications so it makes sense to move them to uapi/scsi/mpi3mr.

I think this is a horrible idea. These headers are a huge and a bit of a mess, and no we need to provide uapi guarantees for them.

#10 lore raw

Re: [PATCH v3 3/8] mpi3mr: move MPI headers to uapi/scsi/mpi3mr

Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Sumit Saxena

MPI headers are used by user space applications so it makes sense to move them to uapi/scsi/mpi3mr.

I think this is a horrible idea. These headers are a huge and a bit of a mess, and no we need to provide uapi guarantees for them.

Hi Christoph,

Although I agree with the above: my understanding is that this patch series adds a new NVMe pass-through mechanism but without adding the necessary declarations under include/uapi. That is why I asked recently to move the necessary declarations into the include/uapi directory.

Bart.

#11 lore raw

Re: [PATCH v3 3/8] mpi3mr: move MPI headers to uapi/scsi/mpi3mr

Bart,
We can submit another patchset where we will move only structures which are used both by applications and drivers into the include/uapi and keep the remaining ones which are not used in the app into the older mpi3mr/mpi folder. However, I have a generic question on why we need to move the headers into uapi because the driver provides the transfer mechanism already in the uapi through app.h and the information transferred in through that is blob from the driver perspective and that goes to the controller directly and processed by the controller, only for specific cases like NVMe encapsulated command, to set up the DMA address the driver parse through the command. Wouldn't it make sense to keep all of the controller/firmware related structures along with the driver and expose only the transport mechanism in the uapi?

Thanks
Sathya

Quoted 17 lines · Bart Van Assche
Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Sumit Saxena

MPI headers are used by user space applications so it makes sense to move them to uapi/scsi/mpi3mr.

I think this is a horrible idea. These headers are a huge and a bit of a mess, and no we need to provide uapi guarantees for them.

Hi Christoph,

Although I agree with the above: my understanding is that this patch series adds a new NVMe pass-through mechanism but without adding the necessary declarations under include/uapi. That is why I asked recently to move the necessary declarations into the include/uapi directory.

Bart.

Signature · 11 lines
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.
#12 lore raw

Re: [PATCH v3 3/8] mpi3mr: move MPI headers to uapi/scsi/mpi3mr

Quoted 5 lines · Sathya Prakash Veerichetty

We can submit another patchset where we will move only structures which are used both by applications and drivers into the include/uapi and keep the remaining ones which are not used in the app into the older mpi3mr/mpi folder. However, I have a generic question on why we need to move the headers into uapi because the driver provides the

Quoted 8 lines

transfer mechanism already in the uapi through app.h and the information transferred in through that is blob from the driver perspective and that goes to the controller directly and processed by the controller, only for specific cases like NVMe encapsulated command, to set up the DMA address the driver parse through the command. Wouldn't it make sense to keep all of the controller/firmware related structures along with the driver and expose only the transport mechanism in the uapi?

Hi Sathya,

Please reply below the original email instead of above. From https://en.wikipedia.org/wiki/Posting_style:

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

Regarding the question in your email: the convention in the Linux kernel is to define data structures that are needed by user space applications (and only those data structures) under the include/uapi directory. These data structures are not only exported to user space apps but also used by the kernel code that implements the user space API. This guarantees the correctness of these header files.

I can't find the app.h header file anywhere in the kernel tree. Hence my request to move the user space data structures and constant definitions into a header file under the include/uapi/ directory.

Thanks,

Bart.

author maintainer
#13 lore raw

PATCH v3 4/8 mpi3mr: add support for MPT commands

In reply to Sumit Saxena

There are certain management commands requiring firmware intervention. These commands are termed as MPT commands. This patch adds support for the same.

---
 drivers/scsi/mpi3mr/mpi3mr.h       |  29 ++
 drivers/scsi/mpi3mr/mpi3mr_app.c   | 519 ++++++++++++++++++++++++++++-
 drivers/scsi/mpi3mr/mpi3mr_debug.h |  25 ++
 drivers/scsi/mpi3mr/mpi3mr_os.c    |   4 +-
 4 files changed, 574 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr.h +29 -0
index 7538571e61a6..e77a0744cac1 100644
@@ -188,6 +188,27 @@ extern int prot_mask;
  */
 #define MPI3MR_MAX_APP_XFER_SECTORS	(2048 + 512)
 
+/**
+ * struct mpi3mr_buf_map -  local structure to
+ * track kernel and user buffers associated with an BSG
+ * structure.
+ *
+ * @bsg_buf: BSG buffer virtual address
+ * @bsg_buf_len:  BSG buffer length
+ * @kern_buf: Kernel buffer virtual address
+ * @kern_buf_len: Kernel buffer length
+ * @kern_buf_dma: Kernel buffer DMA address
+ * @data_dir: Data direction.
+ */
+struct mpi3mr_buf_map {
+	void *bsg_buf;
+	u32 bsg_buf_len;
+	void *kern_buf;
+	u32 kern_buf_len;
+	dma_addr_t kern_buf_dma;
+	u8 data_dir;
+};
+
 /* IOC State definitions */
 enum mpi3mr_iocstate {
 	MRIOC_STATE_READY = 1,
@@ -556,6 +577,7 @@ struct mpi3mr_sdev_priv_data {
  * @ioc_status: IOC status from the firmware
  * @ioc_loginfo:IOC log info from the firmware
  * @is_waiting: Is the command issued in block mode
+ * @is_sense: Is Sense data present
  * @retry_count: Retry count for retriable commands
  * @host_tag: Host tag used by the command
  * @callback: Callback for non blocking commands
@@ -571,6 +593,7 @@ struct mpi3mr_drv_cmd {
 	u16 ioc_status;
 	u32 ioc_loginfo;
 	u8 is_waiting;
+	u8 is_sense;
 	u8 retry_count;
 	u16 host_tag;
 
@@ -992,5 +1015,11 @@ int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc,
 int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num);
 void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc);
 void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc);
+int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
+	u16 handle, uint lun, u16 htag, ulong timeout,
+	struct mpi3mr_drv_cmd *drv_cmd,
+	u8 *resp_code, struct scsi_cmnd *scmd);
+struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle(
+	struct mpi3mr_ioc *mrioc, u16 handle);
 
 #endif /*MPI3MR_H_INCLUDED*/
drivers/scsi/mpi3mr/mpi3mr_app.c +518 -1

537 lines not on this page · raw message

drivers/scsi/mpi3mr/mpi3mr_debug.h +25 -0
index 65bfac72948c..2464c400a5a4 100644
@@ -124,6 +124,31 @@
 
 #endif /* MPT3SAS_DEBUG_H_INCLUDED */
 
+/**
+ * dprint_dump - print contents of a memory buffer
+ * @req: Pointer to a memory buffer
+ * @sz: Memory buffer size
+ * @namestr: Name String to identify the buffer type
+ */
+static inline void
+dprint_dump(void *req, int sz, const char *name_string)
+{
+	int i;
+	__le32 *mfp = (__le32 *)req;
+
+	sz = sz/4;
+	if (name_string)
+		pr_info("%s:\n\t", name_string);
+	else
+		pr_info("request:\n\t");
+	for (i = 0; i < sz; i++) {
+		if (i && ((i % 8) == 0))
+			pr_info("\n\t");
+		pr_info("%08x ", le32_to_cpu(mfp[i]));
+	}
+	pr_info("\n");
+}
+
 /**
  * dprint_dump_req - print message frame contents
  * @req: pointer to message frame
drivers/scsi/mpi3mr/mpi3mr_os.c +2 -2
index a03e39083a42..450574fc1fec 100644
@@ -634,7 +634,7 @@ static struct mpi3mr_tgt_dev  *__mpi3mr_get_tgtdev_by_handle(
  *
  * Return: Target device reference.
  */
-static struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle(
+struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle(
 	struct mpi3mr_ioc *mrioc, u16 handle)
 {
 	struct mpi3mr_tgt_dev *tgtdev;
@@ -2996,7 +2996,7 @@ inline void mpi3mr_poll_pend_io_completions(struct mpi3mr_ioc *mrioc)
  *
  * Return: 0 on success, non-zero on errors
  */
-static int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
+int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
 	u16 handle, uint lun, u16 htag, ulong timeout,
 	struct mpi3mr_drv_cmd *drv_cmd,
 	u8 *resp_code, struct scsi_cmnd *scmd)
Signature · 1 line
2.27.0
author maintainer
#14 lore raw

PATCH v3 5/8 mpi3mr: add support for PEL commands

In reply to Sumit Saxena

This patch includes driver support for the management applications to enable the persistent event log(PEL) notification. Upon receipt of events, driver will increment sysfs variable named as event_counter. Application would poll for event_counter value and any change in it would signal the applications about events.

---
 drivers/scsi/mpi3mr/mpi3mr.h     |  36 +++-
 drivers/scsi/mpi3mr/mpi3mr_app.c | 205 ++++++++++++++++++++
 drivers/scsi/mpi3mr/mpi3mr_fw.c  | 310 +++++++++++++++++++++++++++++++
 drivers/scsi/mpi3mr/mpi3mr_os.c  |  42 +++++
 4 files changed, 592 insertions(+), 1 deletion(-)
drivers/scsi/mpi3mr/mpi3mr.h +35 -1
index e77a0744cac1..2c043e6b9d6a 100644
@@ -52,6 +52,7 @@
 extern spinlock_t mrioc_list_lock;
 extern struct list_head mrioc_list;
 extern int prot_mask;
+extern atomic64_t event_counter;
 
 #define MPI3MR_DRIVER_VERSION	"8.0.0.68.0"
 #define MPI3MR_DRIVER_RELDATE	"10-February-2022"
@@ -90,6 +91,8 @@ extern int prot_mask;
 #define MPI3MR_HOSTTAG_INVALID		0xFFFF
 #define MPI3MR_HOSTTAG_INITCMDS		1
 #define MPI3MR_HOSTTAG_BSG_CMDS		2
+#define MPI3MR_HOSTTAG_PEL_ABORT	3
+#define MPI3MR_HOSTTAG_PEL_WAIT		4
 #define MPI3MR_HOSTTAG_BLK_TMS		5
 
 #define MPI3MR_NUM_DEVRMCMD		16
@@ -151,6 +154,7 @@ extern int prot_mask;
 
 /* Command retry count definitions */
 #define MPI3MR_DEV_RMHS_RETRY_COUNT 3
+#define MPI3MR_PEL_RETRY_COUNT 3
 
 /* Default target device queue depth */
 #define MPI3MR_DEFAULT_SDEV_QD	32
@@ -747,6 +751,16 @@ struct scmd_priv {
  * @current_event: Firmware event currently in process
  * @driver_info: Driver, Kernel, OS information to firmware
  * @change_count: Topology change count
+ * @pel_enabled: Persistent Event Log(PEL) enabled or not
+ * @pel_abort_requested: PEL abort is requested or not
+ * @pel_class: PEL Class identifier
+ * @pel_locale: PEL Locale identifier
+ * @pel_cmds: Command tracker for PEL wait command
+ * @pel_abort_cmd: Command tracker for PEL abort command
+ * @pel_newest_seqnum: Newest PEL sequenece number
+ * @pel_seqnum_virt: PEL sequence number virtual address
+ * @pel_seqnum_dma: PEL sequence number DMA address
+ * @pel_seqnum_sz: PEL sequenece number size
  * @op_reply_q_offset: Operational reply queue offset with MSIx
  * @default_qcount: Total Default queues
  * @active_poll_qcount: Currently active poll queue count
@@ -893,8 +907,20 @@ struct mpi3mr_ioc {
 	struct mpi3mr_fwevt *current_event;
 	struct mpi3_driver_info_layout driver_info;
 	u16 change_count;
-	u16 op_reply_q_offset;
 
+	u8 pel_enabled;
+	u8 pel_abort_requested;
+	u8 pel_class;
+	u16 pel_locale;
+	struct mpi3mr_drv_cmd pel_cmds;
+	struct mpi3mr_drv_cmd pel_abort_cmd;
+
+	u32 pel_newest_seqnum;
+	void *pel_seqnum_virt;
+	dma_addr_t pel_seqnum_dma;
+	u32 pel_seqnum_sz;
+
+	u16 op_reply_q_offset;
 	u16 default_qcount;
 	u16 active_poll_qcount;
 	u16 requested_poll_qcount;
@@ -917,6 +943,7 @@ struct mpi3mr_ioc {
  * @send_ack: Event acknowledgment required or not
  * @process_evt: Bottomhalf processing required or not
  * @evt_ctx: Event context to send in Ack
+ * @event_data_size: size of the event data in bytes
  * @pending_at_sml: waiting for device add/remove API to complete
  * @discard: discard this event
  * @ref_count: kref count
@@ -930,6 +957,7 @@ struct mpi3mr_fwevt {
 	bool send_ack;
 	bool process_evt;
 	u32 evt_ctx;
+	u16 event_data_size;
 	bool pending_at_sml;
 	bool discard;
 	struct kref ref_count;
@@ -1021,5 +1049,11 @@ int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
 	u8 *resp_code, struct scsi_cmnd *scmd);
 struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle(
 	struct mpi3mr_ioc *mrioc, u16 handle);
+void mpi3mr_pel_get_seqnum_complete(struct mpi3mr_ioc *mrioc,
+	struct mpi3mr_drv_cmd *drv_cmd);
+int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc,
+	struct mpi3mr_drv_cmd *drv_cmd);
+void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data,
+	u16 event_data_size);
 
 #endif /*MPI3MR_H_INCLUDED*/
drivers/scsi/mpi3mr/mpi3mr_app.c +205 -0

229 lines not on this page · raw message

drivers/scsi/mpi3mr/mpi3mr_fw.c +310 -0

376 lines not on this page · raw message

drivers/scsi/mpi3mr/mpi3mr_os.c +42 -0

84 lines not on this page · raw message

Signature · 1 line
2.27.0
author maintainer
#15 lore raw

PATCH v3 6/8 mpi3mr: expose adapter state to sysfs

In reply to Sumit Saxena
---
 drivers/scsi/mpi3mr/mpi3mr.h     |  2 +-
 drivers/scsi/mpi3mr/mpi3mr_app.c | 46 ++++++++++++++++++++++++++++++++
 drivers/scsi/mpi3mr/mpi3mr_os.c  |  1 +
 3 files changed, 48 insertions(+), 1 deletion(-)
drivers/scsi/mpi3mr/mpi3mr.h +1 -1
index 2c043e6b9d6a..c4370c5b87d8 100644
@@ -1055,5 +1055,5 @@ int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc,
 	struct mpi3mr_drv_cmd *drv_cmd);
 void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data,
 	u16 event_data_size);
-
+extern const struct attribute_group *mpi3mr_host_groups[];
 #endif /*MPI3MR_H_INCLUDED*/
drivers/scsi/mpi3mr/mpi3mr_app.c +46 -0

49 lines not on this page · raw message

drivers/scsi/mpi3mr/mpi3mr_os.c +1 -0
index 19298136edb6..89a4918c4a9e 100644
@@ -4134,6 +4134,7 @@ static struct scsi_host_template mpi3mr_driver_template = {
 	.max_segment_size		= 0xffffffff,
 	.track_queue_depth		= 1,
 	.cmd_size			= sizeof(struct scmd_priv),
+	.shost_groups			= mpi3mr_host_groups,
 };
 
 /**
Signature · 1 line
2.27.0
author maintainer
#16 lore raw

PATCH v3 7/8 mpi3mr: add support for nvme pass-through

In reply to Sumit Saxena

This patch adds support for management applications to send an MPI3 Encapsulated NVMe passthru commands to the NVMe devices attached to the Avenger controller. Since the NVMe drives are exposed as SCSI devices by the controller the standard NVMe applications cannot be used to interact with the drives and the command sets supported is also limited by the controller firmware. Special handling is required for MPI3 Encapsulated NVMe passthru commands for PRP/SGL setup in the commands hence the additional changes.

---
 drivers/scsi/mpi3mr/mpi3mr.h          |  25 ++
 drivers/scsi/mpi3mr/mpi3mr_app.c      | 348 +++++++++++++++++++++++++-
 include/uapi/scsi/mpi3mr/mpi3mr_bsg.h |  10 +
 3 files changed, 380 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr.h +25 -0
index c4370c5b87d8..edd0846929b0 100644
@@ -192,6 +192,24 @@ extern atomic64_t event_counter;
  */
 #define MPI3MR_MAX_APP_XFER_SECTORS	(2048 + 512)
 
+/**
+ * struct mpi3mr_nvme_pt_sge -  Structure to store SGEs for NVMe
+ * Encapsulated commands.
+ *
+ * @base_addr: Physical address
+ * @length: SGE length
+ * @rsvd: Reserved
+ * @rsvd1: Reserved
+ * @sgl_type: sgl type
+ */
+struct mpi3mr_nvme_pt_sge {
+	u64 base_addr;
+	u32 length;
+	u16 rsvd;
+	u8 rsvd1;
+	u8 sgl_type;
+};
+
 /**
  * struct mpi3mr_buf_map -  local structure to
  * track kernel and user buffers associated with an BSG
@@ -745,6 +763,9 @@ struct scmd_priv {
  * @reset_waitq: Controller reset  wait queue
  * @prepare_for_reset: Prepare for reset event received
  * @prepare_for_reset_timeout_counter: Prepare for reset timeout
+ * @prp_list_virt: NVMe encapsulated PRP list virtual base
+ * @prp_list_dma: NVMe encapsulated PRP list DMA
+ * @prp_sz: NVME encapsulated PRP list size
  * @diagsave_timeout: Diagnostic information save timeout
  * @logging_level: Controller debug logging level
  * @flush_io_count: I/O count to flush after reset
@@ -900,6 +921,10 @@ struct mpi3mr_ioc {
 	u8 prepare_for_reset;
 	u16 prepare_for_reset_timeout_counter;
 
+	void *prp_list_virt;
+	dma_addr_t prp_list_dma;
+	u32 prp_sz;
+
 	u16 diagsave_timeout;
 	int logging_level;
 	u16 flush_io_count;
drivers/scsi/mpi3mr/mpi3mr_app.c +345 -3

378 lines not on this page · raw message

include/uapi/scsi/mpi3mr/mpi3mr_bsg.h +10 -0
index 7535a9353807..7eab2b265391 100644
@@ -431,4 +431,14 @@ struct mpi3mr_bsg_packet {
 		struct mpi3mr_bsg_mptcmd mptcmd;
 	} cmd;
 };
+
+/* Encapsulated NVMe command definitions */
+#define	MPI3MR_NVME_PRP_SIZE		8 /* PRP size */
+#define	MPI3MR_NVME_CMD_PRP1_OFFSET	24 /* PRP1 offset in NVMe cmd */
+#define	MPI3MR_NVME_CMD_PRP2_OFFSET	32 /* PRP2 offset in NVMe cmd */
+#define	MPI3MR_NVME_CMD_SGL_OFFSET	24 /* SGL offset in NVMe cmd */
+#define MPI3MR_NVME_DATA_FORMAT_PRP	0
+#define MPI3MR_NVME_DATA_FORMAT_SGL1	1
+#define MPI3MR_NVME_DATA_FORMAT_SGL2	2
+
 #endif
Signature · 1 line
2.27.0
author maintainer
#17 lore raw

PATCH v3 8/8 mpi3mr: update driver version to 8.0.0.69.0

In reply to Sumit Saxena
---
 drivers/scsi/mpi3mr/mpi3mr.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mpi3mr/mpi3mr.h +2 -2
index edd0846929b0..2b3d9af438e4 100644
@@ -54,8 +54,8 @@ extern struct list_head mrioc_list;
 extern int prot_mask;
 extern atomic64_t event_counter;
 
-#define MPI3MR_DRIVER_VERSION	"8.0.0.68.0"
-#define MPI3MR_DRIVER_RELDATE	"10-February-2022"
+#define MPI3MR_DRIVER_VERSION	"8.0.0.69.0"
+#define MPI3MR_DRIVER_RELDATE	"16-March-2022"
 
 #define MPI3MR_DRIVER_NAME	"mpi3mr"
 #define MPI3MR_DRIVER_LICENSE	"GPL"
Signature · 1 line
2.27.0