git: bec8eb5998fc - stable/13 - Update smartqpi driver to vendor's latest submission

From: Warner Losh <imp_at_FreeBSD.org>
Date: Wed, 09 Mar 2022 20:53:00 UTC
The branch stable/13 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=bec8eb5998fc0f6869944150bb34144fe2676243

commit bec8eb5998fc0f6869944150bb34144fe2676243
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-03-09 00:01:04 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-03-09 20:52:23 +0000

    Update smartqpi driver to vendor's latest submission
    
    Newly added features & bug fixes
    
    o Fixed an issue smartpqi debug log messages are flooding kernel logs.
    o Fixed an issue where devices are shown as RAID 0 in display info.
    o Feature: Changed 32 bit dma address to 64 bit address
    o Added new controlller ids.
    
    Submitted by:           Microsemi
    Reviewed by:            Scott Benesh (Microsemi), imp
    Differential Revision:  https://reviews.freebsd.org/D34469
    MFC After:              3 days
    
    Sponsored by:           Netflix
    
    (cherry picked from commit 4f77349d5777c8ac504387e7e6d37c13da222294)
---
 sys/dev/smartpqi/smartpqi_cam.c     |  2 +-
 sys/dev/smartpqi/smartpqi_defines.h |  7 +++--
 sys/dev/smartpqi/smartpqi_helper.c  | 53 ++++++++++++++++++++++++++++++++++---
 sys/dev/smartpqi/smartpqi_main.c    | 34 ++++++++++++++++++++----
 sys/dev/smartpqi/smartpqi_request.c |  8 ++++++
 5 files changed, 90 insertions(+), 14 deletions(-)

diff --git a/sys/dev/smartpqi/smartpqi_cam.c b/sys/dev/smartpqi/smartpqi_cam.c
index e389eb143e4a..785a8323d6fc 100644
--- a/sys/dev/smartpqi/smartpqi_cam.c
+++ b/sys/dev/smartpqi/smartpqi_cam.c
@@ -507,7 +507,7 @@ os_aio_response_error(rcb_t *rcb, aio_path_error_info_elem_t *err_info)
 		unsigned sense_data_len = LE_16(err_info->data_len);
 		if (sense_data_len)
 			sense_data = err_info->data;
-		DBG_ERR_BTL(rcb->dvp, "SCSI_STATUS_CHECK_COND  sense size %u\n",
+		DBG_INFO("SCSI_STATUS_CHECK_COND  sense size %u\n",
 			sense_data_len);
 		copy_sense_data_to_csio(csio, sense_data, sense_data_len);
 		csio->ccb_h.status = CAM_SCSI_STATUS_ERROR | CAM_AUTOSNS_VALID;
diff --git a/sys/dev/smartpqi/smartpqi_defines.h b/sys/dev/smartpqi/smartpqi_defines.h
index 94000a06a4c5..10a1a78d4599 100644
--- a/sys/dev/smartpqi/smartpqi_defines.h
+++ b/sys/dev/smartpqi/smartpqi_defines.h
@@ -1076,10 +1076,6 @@ typedef struct sema OS_SEMA_LOCK_T;
 
 /* Debug facility */
 
-#define PQISRC_LOG_LEVEL  0x60
-
-static int logging_level  = PQISRC_LOG_LEVEL;
-
 #define	PQISRC_FLAGS_MASK		0x0000ffff
 #define	PQISRC_FLAGS_INIT 		0x00000001
 #define	PQISRC_FLAGS_INFO 		0x00000002
@@ -1090,6 +1086,9 @@ static int logging_level  = PQISRC_LOG_LEVEL;
 #define	PQISRC_FLAGS_ERROR		0x00000040
 #define	PQISRC_FLAGS_NOTE		0x00000080
 
+#define PQISRC_LOG_LEVEL  (PQISRC_FLAGS_WARN | PQISRC_FLAGS_ERROR | PQISRC_FLAGS_NOTE)
+
+static int logging_level  = PQISRC_LOG_LEVEL;
 
 #define	DBG_INIT(fmt,args...)						\
 		do {							\
diff --git a/sys/dev/smartpqi/smartpqi_helper.c b/sys/dev/smartpqi/smartpqi_helper.c
index b49fb2d5a718..45d9fca071d3 100644
--- a/sys/dev/smartpqi/smartpqi_helper.c
+++ b/sys/dev/smartpqi/smartpqi_helper.c
@@ -305,23 +305,68 @@ pqisrc_raidlevel_to_string(uint8_t raid_level)
 }
 
 /* Debug routine for displaying device info */
-void
-pqisrc_display_device_info(pqisrc_softstate_t *softs,
+void pqisrc_display_device_info(pqisrc_softstate_t *softs,
 	char *action, pqi_scsi_dev_t *device)
 {
-	DBG_INFO( "%s scsi BTL %d:%d:%d:  %.8s %.16s %-12s SSDSmartPathCap%c En%c Exp%c qd=%d\n",
+	if (device->is_physical_device) {
+		DBG_NOTE("%s scsi BTL %d:%d:%d:  %.8s %.16s %-12s "
+		"SSDSmartPathCap%c En%c Exp%c qd=%d\n",
 		action,
 		device->bus,
 		device->target,
 		device->lun,
 		device->vendor,
 		device->model,
-		pqisrc_raidlevel_to_string(device->raid_level),
+		"Physical",
 		device->offload_config ? '+' : '-',
 		device->offload_enabled_pending ? '+' : '-',
 		device->expose_device ? '+' : '-',
 		device->queue_depth);
+	} else if (device->devtype == RAID_DEVICE) {
+		DBG_NOTE("%s scsi BTL %d:%d:%d:  %.8s %.16s %-12s "
+		"SSDSmartPathCap%c En%c Exp%c qd=%d\n",
+		action,
+		device->bus,
+		device->target,
+		device->lun,
+		device->vendor,
+		device->model,
+		"Controller",
+		device->offload_config ? '+' : '-',
+		device->offload_enabled_pending ? '+' : '-',
+		device->expose_device ? '+' : '-',
+		device->queue_depth);
+	} else if (device->devtype == CONTROLLER_DEVICE) {
+		DBG_NOTE("%s scsi BTL %d:%d:%d:  %.8s %.16s %-12s "
+		"SSDSmartPathCap%c En%c Exp%c qd=%d\n",
+		action,
+		device->bus,
+		device->target,
+		device->lun,
+		device->vendor,
+		device->model,
+		"External",
+		device->offload_config ? '+' : '-',
+		device->offload_enabled_pending ? '+' : '-',
+		device->expose_device ? '+' : '-',
+		device->queue_depth);
+	} else {
+		DBG_NOTE("%s scsi BTL %d:%d:%d:  %.8s %.16s %-12s "
+		"SSDSmartPathCap%c En%c Exp%c qd=%d devtype=%d\n",
+		action,
+		device->bus,
+		device->target,
+		device->lun,
+		device->vendor,
+		device->model,
+		pqisrc_raidlevel_to_string(device->raid_level),
+		device->offload_config ? '+' : '-',
+		device->offload_enabled_pending ? '+' : '-',
+		device->expose_device ? '+' : '-',
+		device->queue_depth,
+		device->devtype);
 	pqisrc_raidlevel_to_string(device->raid_level); /* To use this function */
+	}
 }
 
 /* validate the structure sizes */
diff --git a/sys/dev/smartpqi/smartpqi_main.c b/sys/dev/smartpqi/smartpqi_main.c
index b4efa26b9784..97747be50d24 100644
--- a/sys/dev/smartpqi/smartpqi_main.c
+++ b/sys/dev/smartpqi/smartpqi_main.c
@@ -110,6 +110,8 @@ struct pqi_ident
 	{0x9005, 0x028f, 0x13fe, 0x8312, PQI_HWIF_SRCV, "MIC-8312BridgeB"},
 	{0x9005, 0x028f, 0x1bd4, 0x004f, PQI_HWIF_SRCV, "INSPUR PM8222-HBA"},
 	{0x9005, 0x028f, 0x1d8d, 0x908,	 PQI_HWIF_SRCV, "Fiberhome SmartHBA AIS-8222-8i"},
+	{0x9005, 0x028f, 0x1bd4, 0x006C, PQI_HWIF_SRCV, "INSPUR RS0800M5E8i"},
+	{0x9005, 0x028f, 0x1bd4, 0x006D, PQI_HWIF_SRCV, "INSPUR RS0800M5H8i"},
 
 	/* (SRCx MSCC FVB 24x12G based) */
 	{0x9005, 0x028f, 0x103c, 0x1001, PQI_HWIF_SRCV, "MSCC FVB"},
@@ -130,6 +132,10 @@ struct pqi_ident
 	{0x9005, 0x028f, 0x9005, 0x1380, PQI_HWIF_SRCV, "SmartRAID 3154-16i"},
 	{0x9005, 0x028f, 0x1bd4, 0x0046, PQI_HWIF_SRCV, "INSPUR RAID 8236-16i"},
 	{0x9005, 0x028f, 0x1d8d, 0x806,  PQI_HWIF_SRCV, "Fiberhome SmartRAID AIS-8236-16i"},
+	{0x9005, 0x028f, 0x1cf2, 0x5449, PQI_HWIF_SRCV, "ZTE SmartROC3100 RS241-18i 2G"},
+	{0x9005, 0x028f, 0x1cf2, 0x544A, PQI_HWIF_SRCV, "ZTE SmartROC3100 RS242-18i 4G"},
+	{0x9005, 0x028f, 0x1cf2, 0x544D, PQI_HWIF_SRCV, "ZTE SmartROC3100 RM241B-18i 2G"},
+	{0x9005, 0x028f, 0x1cf2, 0x544E, PQI_HWIF_SRCV, "ZTE SmartROC3100 RM242B-18i 4G"},
 
 	/* (MSCC PM8237 24x12G based) */
 	{0x9005, 0x028f, 0x103c, 0x1100, PQI_HWIF_SRCV, "P816i-a SR Gen10"},
@@ -144,6 +150,7 @@ struct pqi_ident
 	{0x9005, 0x028f, 0x9005, 0x1282, PQI_HWIF_SRCV, "SmartHBA 2100-16i"},
 	{0x9005, 0x028f, 0x1d8d, 0x916,  PQI_HWIF_SRCV, "Fiberhome SmartHBA AIS-8238-16i"},
 	{0x9005, 0x028f, 0x1458, 0x1000, PQI_HWIF_SRCV, "GIGABYTE SmartHBA CLN1832"},
+	{0x9005, 0x028f, 0x1cf2, 0x544F, PQI_HWIF_SRCV, "ZTE SmartIOC2100 RM243B-18i"},
 
 	/* (MSCC PM8240 24x12G based) */
 	{0x9005, 0x028f, 0x152d, 0x8a36, PQI_HWIF_SRCV, "QS-8240-24i"},
@@ -151,6 +158,7 @@ struct pqi_ident
 	{0x9005, 0x028f, 0x9005, 0x1201, PQI_HWIF_SRCV, "SmartRAID 3154-8i16e"},
 	{0x9005, 0x028f, 0x9005, 0x1202, PQI_HWIF_SRCV, "SmartRAID 3154-8i8e"},
 	{0x9005, 0x028f, 0x1bd4, 0x0047, PQI_HWIF_SRCV, "INSPUR RAID 8240-24i"},
+	{0x9005, 0x028f, 0x1F0C, 0x3161, PQI_HWIF_SRCV, "NT RAID 3100-24i"},
 
 	/* Huawei ID's */
 	{0x9005, 0x028f, 0x19e5, 0xd227, PQI_HWIF_SRCV, "SR465C-M 4G"},
@@ -159,6 +167,22 @@ struct pqi_ident
 	{0x9005, 0x028f, 0x19e5, 0xd22c, PQI_HWIF_SRCV, "SR455C-M 4G"},
 	{0x9005, 0x028f, 0x19e5, 0xd229, PQI_HWIF_SRCV, "SR155-M"},
 	{0x9005, 0x028f, 0x19e5, 0xd22b, PQI_HWIF_SRCV, "SR455C-ME 4G"},
+	/* (MSCC PM8254 32x12G based) */
+	{0x9005, 0x028f, 0x9005, 0x14a2, PQI_HWIF_SRCV, "SmartRAID 3252-8i"},
+	{0x9005, 0x028f, 0x9005, 0x14a4, PQI_HWIF_SRCV, "SmartRAID 3254-8i /e"},
+	{0x9005, 0x028f, 0x9005, 0x14a5, PQI_HWIF_SRCV, "SmartRAID 3252-8i /e"},
+	{0x9005, 0x028f, 0x9005, 0x14a6, PQI_HWIF_SRCV, "SmartRAID 3204-8i /e"},
+/* (MSCC PM8265 16x12G based) */
+	{0x9005, 0x028f, 0x9005, 0x1474, PQI_HWIF_SRCV, "SmartRAID 3254-16io /e"},
+/* (MSCC PM8270 16x12G based) */
+	{0x9005, 0x028f, 0x9005, 0x1463, PQI_HWIF_SRCV, "SmartHBA 2200-8io /e"},
+	{0x9005, 0x028f, 0x9005, 0x14c2, PQI_HWIF_SRCV, "SmartHBA 2200-16io /e"},
+	/* (MSCC PM8279 32x12G based) */
+	{0x9005, 0x028f, 0x1590, 0x0381, PQI_HWIF_SRCV, "SR932i-p Gen11"},
+	{0x9005, 0x028f, 0x1590, 0x0382, PQI_HWIF_SRCV, "SR308i-p Gen11"},
+	{0x9005, 0x028f, 0x1590, 0x0383, PQI_HWIF_SRCV, "SR308i-o Gen11"},
+	{0x9005, 0x028f, 0x1590, 0x02db, PQI_HWIF_SRCV, "SR416ie-m Gen11"},
+	{0x9005, 0x028f, 0x1590, 0x032e, PQI_HWIF_SRCV, "SR416i-o Gen11"},
 
 	{0, 0, 0, 0, 0, 0}
 };
@@ -327,12 +351,12 @@ smartpqi_attach(device_t dev)
 	 */
 	if (bus_dma_tag_create(bus_get_dma_tag(dev), 	/* parent */
 				PAGE_SIZE, 0,		/* algnmnt, boundary */
-				BUS_SPACE_MAXADDR_32BIT,/* lowaddr */
+				BUS_SPACE_MAXADDR,/* lowaddr */
 				BUS_SPACE_MAXADDR, 	/* highaddr */
 				NULL, NULL, 		/* filter, filterarg */
-				BUS_SPACE_MAXSIZE_32BIT,	/* maxsize */
+				BUS_SPACE_MAXSIZE,	/* maxsize */
 				BUS_SPACE_UNRESTRICTED,	/* nsegments */
-				BUS_SPACE_MAXSIZE_32BIT,	/* maxsegsize */
+				BUS_SPACE_MAXSIZE,	/* maxsegsize */
 				0,			/* flags */
 				NULL, NULL,		/* No locking needed */
 				&softs->os_specific.pqi_parent_dmat)) {
@@ -368,12 +392,12 @@ smartpqi_attach(device_t dev)
      */
     if (bus_dma_tag_create(softs->os_specific.pqi_parent_dmat,/* parent */
 				PAGE_SIZE, 0,		/* algnmnt, boundary */
-				BUS_SPACE_MAXADDR_32BIT,/* lowaddr */
+				BUS_SPACE_MAXADDR,/* lowaddr */
 				BUS_SPACE_MAXADDR,	/* highaddr */
 				NULL, NULL,		/* filter, filterarg */
 				(bus_size_t)softs->pqi_cap.max_sg_elem*PAGE_SIZE,/* maxsize */
 				softs->pqi_cap.max_sg_elem,	/* nsegments */
-				BUS_SPACE_MAXSIZE_32BIT,	/* maxsegsize */
+				BUS_SPACE_MAXSIZE,	/* maxsegsize */
 				BUS_DMA_ALLOCNOW,		/* flags */
 				busdma_lock_mutex,		/* lockfunc */
 				&softs->os_specific.map_lock,	/* lockfuncarg*/
diff --git a/sys/dev/smartpqi/smartpqi_request.c b/sys/dev/smartpqi/smartpqi_request.c
index 222852fbe088..81f9e106bd8a 100644
--- a/sys/dev/smartpqi/smartpqi_request.c
+++ b/sys/dev/smartpqi/smartpqi_request.c
@@ -837,6 +837,12 @@ pqisrc_send_aio_tmf(pqisrc_softstate_t *softs, pqi_scsi_dev_t *devp,
 	DBG_INFO("tmf_req.header.iu_type : %x tmf_req.req_id_to_manage :%d \n",tmf_req.header.iu_type,tmf_req.req_id_to_manage);
 	DBG_INFO("tmf_req.req_id : %d tmf_req.nexus : %x tmf_req.tmf %x QID : %d\n",tmf_req.req_id,tmf_req.nexus,tmf_req.tmf,op_ib_q->q_id);
 
+	DBG_WARN("aio tmf: iu_type=0x%x req_id_to_manage=0x%x\n",
+		tmf_req.header.iu_type, tmf_req.req_id_to_manage);
+	DBG_WARN("aio tmf: req_id=0x%x nexus=0x%x tmf=0x%x QID=%d\n",
+		tmf_req.req_id, tmf_req.nexus, tmf_req.tmf, op_ib_q->q_id);
+
+	rcb->path = AIO_PATH;
 	rcb->req_pending = true;
 	/* Timedout tmf response goes here */
 	rcb->error_cmp_callback = pqisrc_process_aio_response_error;
@@ -900,6 +906,7 @@ pqisrc_send_raid_tmf(pqisrc_softstate_t *softs, pqi_scsi_dev_t *devp,
 	}
 
 	op_ib_q = &softs->op_raid_ib_q[0];
+	rcb->path = RAID_PATH;
 	rcb->req_pending = true;
 	/* Timedout tmf response goes here */
 	rcb->error_cmp_callback = pqisrc_process_raid_response_error;
@@ -933,6 +940,7 @@ pqisrc_send_tmf(pqisrc_softstate_t *softs, pqi_scsi_dev_t *devp,
 	int ret = PQI_STATUS_SUCCESS;
 
 	DBG_FUNC("IN");
+	rcb->softs = softs;
 
 	if(!devp->is_physical_device) {
 		if (tmf_type == SOP_TASK_MANAGEMENT_FUNCTION_ABORT_TASK) {