mpi3mr: add BSG interface support for controller management
Subsystems (2)
Sumit Saxena
maintainerv6 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.
v6:
-Fixed errors/warnings reported by kernel test robot <[email protected]>.
v5:
-Addressed review comments from Himanshu for patch#2 and added
reviewed-by tags.
v4:
-Restored MPI headers to driver source directory(drivers/scsi/mpi3mr). -Moved data structures/definitions used by user space applications
from MPI headers to uapi header(uapi/scsi/scsi_bsg_mpi3mr.h).
-Addressed review comments from Bart Van Assche and Himanshu Madhani.
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 data structures/definitions from MPI headers to uapi
header
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/mpi/mpi30_init.h | 53 - drivers/scsi/mpi3mr/mpi/mpi30_ioc.h | 28 - drivers/scsi/mpi3mr/mpi/mpi30_pci.h | 31 +- drivers/scsi/mpi3mr/mpi3mr.h | 133 ++- drivers/scsi/mpi3mr/mpi3mr_app.c | 1605 ++++++++++++++++++++++++++ drivers/scsi/mpi3mr/mpi3mr_debug.h | 37 +- drivers/scsi/mpi3mr/mpi3mr_fw.c | 331 +++++- drivers/scsi/mpi3mr/mpi3mr_os.c | 52 +- include/uapi/scsi/scsi_bsg_mpi3mr.h | 580 ++++++++++ 11 files changed, 2723 insertions(+), 129 deletions(-) create mode 100644 drivers/scsi/mpi3mr/mpi3mr_app.c create mode 100644 include/uapi/scsi/scsi_bsg_mpi3mr.h
Signature · 1 line
2.27.0
Sumit Saxena
maintainerPATCH v6 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
@@ -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
@@ -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
@@ -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
@@ -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
Sumit Saxena
maintainerPATCH v6 2/8 mpi3mr: add support for driver commands
In reply to Sumit SaxenaThere 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 | 390 +++++++++++++++++++++++++ drivers/scsi/mpi3mr/mpi3mr_debug.h | 12 +- drivers/scsi/mpi3mr/mpi3mr_fw.c | 21 +- drivers/scsi/mpi3mr/mpi3mr_os.c | 3 + include/uapi/scsi/scsi_bsg_mpi3mr.h | 433 ++++++++++++++++++++++++++++ 6 files changed, 863 insertions(+), 12 deletions(-) create mode 100644 include/uapi/scsi/scsi_bsg_mpi3mr.h
drivers/scsi/mpi3mr/mpi3mr.h +13 -3
@@ -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 +390 -0
402 lines not on this page · raw message
drivers/scsi/mpi3mr/mpi3mr_debug.h +6 -6
@@ -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
@@ -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
@@ -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/scsi_bsg_mpi3mr.h new file +433 -0
433 lines not on this page · raw message
Signature · 1 line
2.27.0
Sumit Saxena
maintainerPATCH v6 3/8 mpi3mr: move data structures/definitions from MPI headers to uapi header
In reply to Sumit SaxenaThis patch moves the data structures/definitions which are used by user space applications from MPI headers to uapi/scsi/scsi_bsg_mpi3mr.h
--- drivers/scsi/mpi3mr/mpi/mpi30_init.h | 53 ---------- drivers/scsi/mpi3mr/mpi/mpi30_ioc.h | 28 ------ drivers/scsi/mpi3mr/mpi/mpi30_pci.h | 31 +----- drivers/scsi/mpi3mr/mpi3mr.h | 1 + include/uapi/scsi/scsi_bsg_mpi3mr.h | 139 +++++++++++++++++++++++++++ 5 files changed, 141 insertions(+), 111 deletions(-)
drivers/scsi/mpi3mr/mpi/mpi30_init.h +0 -53
@@ -115,57 +115,4 @@ struct mpi3_scsi_io_reply {#define MPI3_SCSI_RSP_ARI0_MASK (0xff000000)#define MPI3_SCSI_RSP_ARI0_SHIFT (24)#define MPI3_SCSI_TASKTAG_UNKNOWN (0xffff) -struct mpi3_scsi_task_mgmt_request { -__le16 host_tag; -u8 ioc_use_only02; -u8 function; -__le16 ioc_use_only04; -u8 ioc_use_only06; -u8 msg_flags; -__le16 change_count; -__le16 dev_handle; -__le16 task_host_tag; -u8 task_type; -u8 reserved0f; -__le16 task_request_queue_id; -__le16 reserved12; -__le32 reserved14; -u8 lun[8 ]; -}; - -#define MPI3_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU (0x08) -#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK (0x01) -#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK_SET (0x02) -#define MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET (0x03) -#define MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET (0x05) -#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET (0x06) -#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07) -#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_ACA (0x08) -#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK_SET (0x09) -#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_ASYNC_EVENT (0x0a) -#define MPI3_SCSITASKMGMT_TASKTYPE_I_T_NEXUS_RESET (0x0b) -struct mpi3_scsi_task_mgmt_reply { -__le16 host_tag; -u8 ioc_use_only02; -u8 function; -__le16 ioc_use_only04; -u8 ioc_use_only06; -u8 msg_flags; -__le16 ioc_use_only08; -__le16 ioc_status; -__le32 ioc_log_info; -__le32 termination_count; -__le32 response_data; -__le32 reserved18; -}; - -#define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE (0x00) -#define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME (0x02) -#define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED (0x04) -#define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED (0x05) -#define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED (0x08) -#define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN (0x09) -#define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG (0x0a) -#define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC (0x80) -#define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED (0x81)#endif
drivers/scsi/mpi3mr/mpi/mpi30_ioc.h +0 -28
@@ -38,17 +38,6 @@ struct mpi3_ioc_init_request {#define MPI3_WHOINIT_ROM_BIOS (0x02)#define MPI3_WHOINIT_HOST_DRIVER (0x03)#define MPI3_WHOINIT_MANUFACTURER (0x04) -struct mpi3_driver_info_layout { -__le32 information_length; -u8 driver_signature[12 ]; -u8 os_name[16 ]; -u8 os_version[12 ]; -u8 driver_name[20 ]; -u8 driver_version[32 ]; -u8 driver_release_date[20 ]; -__le32 driver_capabilities; -}; -struct mpi3_ioc_facts_request {__le16 host_tag;u8 ioc_use_only02;
@@ -647,23 +636,6 @@ struct mpi3_event_data_diag_buffer_status_change {#define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_RELEASED (0x01)#define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_PAUSED (0x02)#define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_RESUMED (0x03) -#define MPI3_PEL_LOCALE_FLAGS_NON_BLOCKING_BOOT_EVENT (0x0200) -#define MPI3_PEL_LOCALE_FLAGS_BLOCKING_BOOT_EVENT (0x0100) -#define MPI3_PEL_LOCALE_FLAGS_PCIE (0x0080) -#define MPI3_PEL_LOCALE_FLAGS_CONFIGURATION (0x0040) -#define MPI3_PEL_LOCALE_FLAGS_CONTROLER (0x0020) -#define MPI3_PEL_LOCALE_FLAGS_SAS (0x0010) -#define MPI3_PEL_LOCALE_FLAGS_EPACK (0x0008) -#define MPI3_PEL_LOCALE_FLAGS_ENCLOSURE (0x0004) -#define MPI3_PEL_LOCALE_FLAGS_PD (0x0002) -#define MPI3_PEL_LOCALE_FLAGS_VD (0x0001) -#define MPI3_PEL_CLASS_DEBUG (0x00) -#define MPI3_PEL_CLASS_PROGRESS (0x01) -#define MPI3_PEL_CLASS_INFORMATIONAL (0x02) -#define MPI3_PEL_CLASS_WARNING (0x03) -#define MPI3_PEL_CLASS_CRITICAL (0x04) -#define MPI3_PEL_CLASS_FATAL (0x05) -#define MPI3_PEL_CLASS_FAULT (0x06)#define MPI3_PEL_CLEARTYPE_CLEAR (0x00)#define MPI3_PEL_WAITTIME_INFINITE_WAIT (0x00)#define MPI3_PEL_ACTION_GET_SEQNUM (0x01)
drivers/scsi/mpi3mr/mpi/mpi30_pci.h +1 -30
@@ -5,24 +5,6 @@*/ #ifndef MPI30_PCI_H #define MPI30_PCI_H 1 -#ifndef MPI3_NVME_ENCAP_CMD_MAX -#define MPI3_NVME_ENCAP_CMD_MAX (1) -#endif -struct mpi3_nvme_encapsulated_request { -__le16 host_tag; -u8 ioc_use_only02; -u8 function; -__le16 ioc_use_only04; -u8 ioc_use_only06; -u8 msg_flags; -__le16 change_count; -__le16 dev_handle; -__le16 encapsulated_command_length; -__le16 flags; -__le32 data_length; -__le32 reserved14[3 ]; -__le32 command[MPI3_NVME_ENCAP_CMD_MAX ]; -};#define MPI3_NVME_FLAGS_FORCE_ADMIN_ERR_REPLY_MASK (0x0002)#define MPI3_NVME_FLAGS_FORCE_ADMIN_ERR_REPLY_FAIL_ONLY (0x0000)
@@ -30,16 +12,5 @@ struct mpi3_nvme_encapsulated_request {#define MPI3_NVME_FLAGS_SUBMISSIONQ_MASK (0x0001)#define MPI3_NVME_FLAGS_SUBMISSIONQ_IO (0x0000)#define MPI3_NVME_FLAGS_SUBMISSIONQ_ADMIN (0x0001) -struct mpi3_nvme_encapsulated_error_reply { -__le16 host_tag; -u8 ioc_use_only02; -u8 function; -__le16 ioc_use_only04; -u8 ioc_use_only06; -u8 msg_flags; -__le16 ioc_use_only08; -__le16 ioc_status; -__le32 ioc_log_info; -__le32 nvme_completion_entry[4 ]; -}; +#endif
drivers/scsi/mpi3mr/mpi3mr.h +1 -0
@@ -38,6 +38,7 @@#include <scsi/scsi_device.h> #include <scsi/scsi_host.h> #include <scsi/scsi_tcq.h> +#include <uapi/scsi/scsi_bsg_mpi3mr.h> #include "mpi/mpi30_transport.h" #include "mpi/mpi30_cnfg.h"
include/uapi/scsi/scsi_bsg_mpi3mr.h +139 -0
149 lines not on this page · raw message
Signature · 1 line
2.27.0
Sumit Saxena
maintainerPATCH v6 4/8 mpi3mr: add support for MPT commands
In reply to Sumit SaxenaThere 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
@@ -189,6 +189,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 ,
@@ -557,6 +578,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
@@ -572,6 +594,7 @@ struct mpi3mr_drv_cmd {u16 ioc_status;u32 ioc_loginfo;u8 is_waiting; +u8 is_sense;u8 retry_count;u16 host_tag;
@@ -993,5 +1016,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
@@ -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
@@ -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
Sumit Saxena
maintainerPATCH v6 5/8 mpi3mr: add support for PEL commands
In reply to Sumit SaxenaThis 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
@@ -53,6 +53,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"
@@ -91,6 +92,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
@@ -152,6 +155,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
@@ -748,6 +752,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
@@ -894,8 +908,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;
@@ -918,6 +944,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
@@ -931,6 +958,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;
@@ -1022,5 +1050,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
Sumit Saxena
maintainerPATCH v6 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
@@ -1056,5 +1056,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
@@ -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
Sumit Saxena
maintainerPATCH v6 7/8 mpi3mr: add support for nvme pass-through
In reply to Sumit SaxenaThis 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/scsi_bsg_mpi3mr.h | 8 + 3 files changed, 378 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr.h +25 -0
@@ -193,6 +193,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
@@ -746,6 +764,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
@@ -901,6 +922,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/scsi_bsg_mpi3mr.h +8 -0
@@ -488,6 +488,14 @@ struct mpi3_nvme_encapsulated_error_reply {__le32 nvme_completion_entry[4 ]; }; +#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 +/* MPI3: task management related definitions */ struct mpi3_scsi_task_mgmt_request {__le16 host_tag;
Signature · 1 line
2.27.0
Sumit Saxena
maintainerPATCH v6 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
@@ -55,8 +55,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
Martin K. Petersen
AppliedSumit,
Quoted 3 lines
This patchset adds BSG interface support for controller management. BSG layer facilitates communication/data exchange between application and driver/firmware through BSG device node.
Applied to 5.19/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering