Blame SOURCES/0034-scsi-scsi-qla2xxx-Correctly-report-max-min-supported.patch

3d7c23
From fa4b63b7b3b4b775ec0915db64984f82bbce9cd7 Mon Sep 17 00:00:00 2001
3d7c23
From: Himanshu Madhani <hmadhani@redhat.com>
3d7c23
Date: Thu, 1 Aug 2019 15:54:54 -0400
3d7c23
Subject: [PATCH 034/124] [scsi] scsi: qla2xxx: Correctly report max/min
3d7c23
 supported speeds
3d7c23
3d7c23
Message-id: <20190801155618.12650-35-hmadhani@redhat.com>
3d7c23
Patchwork-id: 267809
3d7c23
O-Subject: [RHEL 7.8 e-stor PATCH 034/118] scsi: qla2xxx: Correctly report max/min supported speeds
3d7c23
Bugzilla: 1729270
3d7c23
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
3d7c23
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
3d7c23
3d7c23
From: Joe Carnuccio <joe.carnuccio@cavium.com>
3d7c23
3d7c23
Bugzilla 1729270
3d7c23
3d7c23
This patch fixes reported speed for min_link and max_supported speed. Also
3d7c23
rename sysfs nodes link_speed and max_supported to be consistent with
3d7c23
{min|max}_suuported_speed.
3d7c23
3d7c23
Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
3d7c23
Signed-off-by: Mike Hernandez <mhernandez@marvell.com>
3d7c23
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
3d7c23
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3d7c23
(cherry picked from commit 72a92df2109bf62094c25436ded2be0283d9aa24)
3d7c23
Signed-off-by: Himanshu Madhani <hmadhani@redhat.com>
3d7c23
Signed-off-by: Jan Stancek <jstancek@redhat.com>
3d7c23
---
3d7c23
 drivers/scsi/qla2xxx/qla_attr.c | 94 +++++++++++++++++++++++++----------------
3d7c23
 drivers/scsi/qla2xxx/qla_def.h  |  7 +--
3d7c23
 drivers/scsi/qla2xxx/qla_fw.h   |  2 +-
3d7c23
 drivers/scsi/qla2xxx/qla_mbx.c  | 65 +++++++++++++++-------------
3d7c23
 4 files changed, 98 insertions(+), 70 deletions(-)
3d7c23
3d7c23
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
3d7c23
index 4dd5dd9767ed..4b3cd62a5c5b 100644
3d7c23
--- a/drivers/scsi/qla2xxx/qla_attr.c
3d7c23
+++ b/drivers/scsi/qla2xxx/qla_attr.c
3d7c23
@@ -1622,8 +1622,8 @@ qla2x00_pep_version_show(struct device *dev, struct device_attribute *attr,
3d7c23
 }
3d7c23
 
3d7c23
 static ssize_t
3d7c23
-qla2x00_min_link_speed_show(struct device *dev, struct device_attribute *attr,
3d7c23
-    char *buf)
3d7c23
+qla2x00_min_supported_speed_show(struct device *dev,
3d7c23
+    struct device_attribute *attr, char *buf)
3d7c23
 {
3d7c23
 	scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
3d7c23
 	struct qla_hw_data *ha = vha->hw;
3d7c23
@@ -1632,16 +1632,17 @@ qla2x00_min_link_speed_show(struct device *dev, struct device_attribute *attr,
3d7c23
 		return scnprintf(buf, PAGE_SIZE, "\n");
3d7c23
 
3d7c23
 	return scnprintf(buf, PAGE_SIZE, "%s\n",
3d7c23
-	    ha->min_link_speed == 5 ? "32Gps" :
3d7c23
-	    ha->min_link_speed == 4 ? "16Gps" :
3d7c23
-	    ha->min_link_speed == 3 ? "8Gps" :
3d7c23
-	    ha->min_link_speed == 2 ? "4Gps" :
3d7c23
-	    ha->min_link_speed != 0 ? "unknown" : "");
3d7c23
+	    ha->min_supported_speed == 6 ? "64Gps" :
3d7c23
+	    ha->min_supported_speed == 5 ? "32Gps" :
3d7c23
+	    ha->min_supported_speed == 4 ? "16Gps" :
3d7c23
+	    ha->min_supported_speed == 3 ? "8Gps" :
3d7c23
+	    ha->min_supported_speed == 2 ? "4Gps" :
3d7c23
+	    ha->min_supported_speed != 0 ? "unknown" : "");
3d7c23
 }
3d7c23
 
3d7c23
 static ssize_t
3d7c23
-qla2x00_max_speed_sup_show(struct device *dev, struct device_attribute *attr,
3d7c23
-    char *buf)
3d7c23
+qla2x00_max_supported_speed_show(struct device *dev,
3d7c23
+    struct device_attribute *attr, char *buf)
3d7c23
 {
3d7c23
 	scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
3d7c23
 	struct qla_hw_data *ha = vha->hw;
3d7c23
@@ -1650,7 +1651,9 @@ qla2x00_max_speed_sup_show(struct device *dev, struct device_attribute *attr,
3d7c23
 		return scnprintf(buf, PAGE_SIZE, "\n");
3d7c23
 
3d7c23
 	return scnprintf(buf, PAGE_SIZE, "%s\n",
3d7c23
-	    ha->max_speed_sup ? "32Gps" : "16Gps");
3d7c23
+	    ha->max_supported_speed  == 2 ? "64Gps" :
3d7c23
+	    ha->max_supported_speed  == 1 ? "32Gps" :
3d7c23
+	    ha->max_supported_speed  == 0 ? "16Gps" : "unknown");
3d7c23
 }
3d7c23
 
3d7c23
 static ssize_t
3d7c23
@@ -2254,8 +2257,10 @@ static DEVICE_ATTR(allow_cna_fw_dump, S_IRUGO | S_IWUSR,
3d7c23
 		   qla2x00_allow_cna_fw_dump_show,
3d7c23
 		   qla2x00_allow_cna_fw_dump_store);
3d7c23
 static DEVICE_ATTR(pep_version, S_IRUGO, qla2x00_pep_version_show, NULL);
3d7c23
-static DEVICE_ATTR(min_link_speed, S_IRUGO, qla2x00_min_link_speed_show, NULL);
3d7c23
-static DEVICE_ATTR(max_speed_sup, S_IRUGO, qla2x00_max_speed_sup_show, NULL);
3d7c23
+static DEVICE_ATTR(min_supported_speed, 0444,
3d7c23
+		   qla2x00_min_supported_speed_show, NULL);
3d7c23
+static DEVICE_ATTR(max_supported_speed, 0444,
3d7c23
+		   qla2x00_max_supported_speed_show, NULL);
3d7c23
 static DEVICE_ATTR(zio_threshold, 0644,
3d7c23
     qla_zio_threshold_show,
3d7c23
     qla_zio_threshold_store);
3d7c23
@@ -2304,8 +2309,8 @@ struct device_attribute *qla2x00_host_attrs[] = {
3d7c23
 	&dev_attr_fw_dump_size,
3d7c23
 	&dev_attr_allow_cna_fw_dump,
3d7c23
 	&dev_attr_pep_version,
3d7c23
-	&dev_attr_min_link_speed,
3d7c23
-	&dev_attr_max_speed_sup,
3d7c23
+	&dev_attr_min_supported_speed,
3d7c23
+	&dev_attr_max_supported_speed,
3d7c23
 	&dev_attr_zio_threshold,
3d7c23
 	&dev_attr_dif_bundle_statistics,
3d7c23
 	&dev_attr_port_speed,
3d7c23
@@ -3034,7 +3039,7 @@ void
3d7c23
 qla2x00_init_host_attr(scsi_qla_host_t *vha)
3d7c23
 {
3d7c23
 	struct qla_hw_data *ha = vha->hw;
3d7c23
-	u32 speed = FC_PORTSPEED_UNKNOWN;
3d7c23
+	u32 speeds = FC_PORTSPEED_UNKNOWN;
3d7c23
 
3d7c23
 	fc_host_dev_loss_tmo(vha->host) = ha->port_down_retry_count;
3d7c23
 	fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name);
3d7c23
@@ -3045,28 +3050,45 @@ qla2x00_init_host_attr(scsi_qla_host_t *vha)
3d7c23
 	fc_host_npiv_vports_inuse(vha->host) = ha->cur_vport_count;
3d7c23
 
3d7c23
 	if (IS_CNA_CAPABLE(ha))
3d7c23
-		speed = FC_PORTSPEED_10GBIT;
3d7c23
-	else if (IS_QLA2031(ha))
3d7c23
-		speed = FC_PORTSPEED_16GBIT | FC_PORTSPEED_8GBIT |
3d7c23
-		    FC_PORTSPEED_4GBIT;
3d7c23
-	else if (IS_QLA25XX(ha))
3d7c23
-		speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT |
3d7c23
-		    FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
3d7c23
+		speeds = FC_PORTSPEED_10GBIT;
3d7c23
+	else if (IS_QLA28XX(ha) || IS_QLA27XX(ha)) {
3d7c23
+		if (ha->max_supported_speed == 2) {
3d7c23
+			if (ha->min_supported_speed <= 6)
3d7c23
+				speeds |= FC_PORTSPEED_64GBIT;
3d7c23
+		}
3d7c23
+		if (ha->max_supported_speed == 2 ||
3d7c23
+		    ha->max_supported_speed == 1) {
3d7c23
+			if (ha->min_supported_speed <= 5)
3d7c23
+				speeds |= FC_PORTSPEED_32GBIT;
3d7c23
+		}
3d7c23
+		if (ha->max_supported_speed == 2 ||
3d7c23
+		    ha->max_supported_speed == 1 ||
3d7c23
+		    ha->max_supported_speed == 0) {
3d7c23
+			if (ha->min_supported_speed <= 4)
3d7c23
+				speeds |= FC_PORTSPEED_16GBIT;
3d7c23
+		}
3d7c23
+		if (ha->max_supported_speed == 1 ||
3d7c23
+		    ha->max_supported_speed == 0) {
3d7c23
+			if (ha->min_supported_speed <= 3)
3d7c23
+				speeds |= FC_PORTSPEED_8GBIT;
3d7c23
+		}
3d7c23
+		if (ha->max_supported_speed == 0) {
3d7c23
+			if (ha->min_supported_speed <= 2)
3d7c23
+				speeds |= FC_PORTSPEED_4GBIT;
3d7c23
+		}
3d7c23
+	} else if (IS_QLA2031(ha))
3d7c23
+		speeds = FC_PORTSPEED_16GBIT|FC_PORTSPEED_8GBIT|
3d7c23
+			FC_PORTSPEED_4GBIT;
3d7c23
+	else if (IS_QLA25XX(ha) || IS_QLAFX00(ha))
3d7c23
+		speeds = FC_PORTSPEED_8GBIT|FC_PORTSPEED_4GBIT|
3d7c23
+			FC_PORTSPEED_2GBIT|FC_PORTSPEED_1GBIT;
3d7c23
 	else if (IS_QLA24XX_TYPE(ha))
3d7c23
-		speed = FC_PORTSPEED_4GBIT | FC_PORTSPEED_2GBIT |
3d7c23
-		    FC_PORTSPEED_1GBIT;
3d7c23
+		speeds = FC_PORTSPEED_4GBIT|FC_PORTSPEED_2GBIT|
3d7c23
+			FC_PORTSPEED_1GBIT;
3d7c23
 	else if (IS_QLA23XX(ha))
3d7c23
-		speed = FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
3d7c23
-	else if (IS_QLAFX00(ha))
3d7c23
-		speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT |
3d7c23
-		    FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
3d7c23
-	else if (IS_QLA27XX(ha))
3d7c23
-		speed = FC_PORTSPEED_32GBIT | FC_PORTSPEED_16GBIT |
3d7c23
-		    FC_PORTSPEED_8GBIT;
3d7c23
-	else if (IS_QLA28XX(ha))
3d7c23
-		speed = FC_PORTSPEED_64GBIT | FC_PORTSPEED_32GBIT |
3d7c23
-		    FC_PORTSPEED_16GBIT | FC_PORTSPEED_8GBIT;
3d7c23
+		speeds = FC_PORTSPEED_2GBIT|FC_PORTSPEED_1GBIT;
3d7c23
 	else
3d7c23
-		speed = FC_PORTSPEED_1GBIT;
3d7c23
-	fc_host_supported_speeds(vha->host) = speed;
3d7c23
+		speeds = FC_PORTSPEED_1GBIT;
3d7c23
+
3d7c23
+	fc_host_supported_speeds(vha->host) = speeds;
3d7c23
 }
3d7c23
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
3d7c23
index 2c1fe64d2454..1730931cd6b2 100644
3d7c23
--- a/drivers/scsi/qla2xxx/qla_def.h
3d7c23
+++ b/drivers/scsi/qla2xxx/qla_def.h
3d7c23
@@ -4230,8 +4230,8 @@ struct qla_hw_data {
3d7c23
 	struct qlt_hw_data tgt;
3d7c23
 	int	allow_cna_fw_dump;
3d7c23
 	uint32_t fw_ability_mask;
3d7c23
-	uint16_t min_link_speed;
3d7c23
-	uint16_t max_speed_sup;
3d7c23
+	uint16_t min_supported_speed;
3d7c23
+	uint16_t max_supported_speed;
3d7c23
 
3d7c23
 	/* DMA pool for the DIF bundling buffers */
3d7c23
 	struct dma_pool *dif_bundl_pool;
3d7c23
@@ -4462,7 +4462,7 @@ typedef struct scsi_qla_host {
3d7c23
 	int fcport_count;
3d7c23
 	wait_queue_head_t fcport_waitQ;
3d7c23
 	wait_queue_head_t vref_waitq;
3d7c23
-	uint8_t min_link_speed_feat;
3d7c23
+	uint8_t min_supported_speed;
3d7c23
 	uint8_t n2n_node_name[WWN_SIZE];
3d7c23
 	uint8_t n2n_port_name[WWN_SIZE];
3d7c23
 	uint16_t	n2n_id;
3d7c23
@@ -4740,4 +4740,5 @@ struct sff_8247_a0 {
3d7c23
 #include "qla_gbl.h"
3d7c23
 #include "qla_dbg.h"
3d7c23
 #include "qla_inline.h"
3d7c23
+
3d7c23
 #endif
3d7c23
diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h
3d7c23
index f7ff1d01a315..62b37775a7b8 100644
3d7c23
--- a/drivers/scsi/qla2xxx/qla_fw.h
3d7c23
+++ b/drivers/scsi/qla2xxx/qla_fw.h
3d7c23
@@ -1757,7 +1757,7 @@ struct nvram_81xx {
3d7c23
 	uint16_t reserved_6_3[14];
3d7c23
 
3d7c23
 	/* Offset 192. */
3d7c23
-	uint8_t min_link_speed;
3d7c23
+	uint8_t min_supported_speed;
3d7c23
 	uint8_t reserved_7_0;
3d7c23
 	uint16_t reserved_7[31];
3d7c23
 
3d7c23
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
3d7c23
index b64b7b9be08b..509fc2d78614 100644
3d7c23
--- a/drivers/scsi/qla2xxx/qla_mbx.c
3d7c23
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
3d7c23
@@ -737,13 +737,14 @@ qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr)
3d7c23
 		if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
3d7c23
 			struct nvram_81xx *nv = ha->nvram;
3d7c23
 			/* set minimum speed if specified in nvram */
3d7c23
-			if (nv->min_link_speed >= 2 &&
3d7c23
-			    nv->min_link_speed <= 5) {
3d7c23
+			if (nv->min_supported_speed >= 2 &&
3d7c23
+			    nv->min_supported_speed <= 5) {
3d7c23
 				mcp->mb[4] |= BIT_4;
3d7c23
-				mcp->mb[11] = nv->min_link_speed;
3d7c23
+				mcp->mb[11] |= nv->min_supported_speed & 0xF;
3d7c23
 				mcp->out_mb |= MBX_11;
3d7c23
 				mcp->in_mb |= BIT_5;
3d7c23
-				vha->min_link_speed_feat = nv->min_link_speed;
3d7c23
+				vha->min_supported_speed =
3d7c23
+				    nv->min_supported_speed;
3d7c23
 			}
3d7c23
 		}
3d7c23
 
3d7c23
@@ -771,35 +772,39 @@ qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr)
3d7c23
 	if (rval != QLA_SUCCESS) {
3d7c23
 		ql_dbg(ql_dbg_mbx, vha, 0x1026,
3d7c23
 		    "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
3d7c23
-	} else {
3d7c23
-		if (IS_FWI2_CAPABLE(ha)) {
3d7c23
-			ha->fw_ability_mask = mcp->mb[3] << 16 | mcp->mb[2];
3d7c23
-			ql_dbg(ql_dbg_mbx, vha, 0x119a,
3d7c23
-			    "fw_ability_mask=%x.\n", ha->fw_ability_mask);
3d7c23
-			ql_dbg(ql_dbg_mbx, vha, 0x1027,
3d7c23
-			    "exchanges=%x.\n", mcp->mb[1]);
3d7c23
-			if (IS_QLA83XX(ha) || IS_QLA27XX(ha) ||
3d7c23
-			    IS_QLA28XX(ha)) {
3d7c23
-				ha->max_speed_sup = mcp->mb[2] & BIT_0;
3d7c23
-				ql_dbg(ql_dbg_mbx, vha, 0x119b,
3d7c23
-				    "Maximum speed supported=%s.\n",
3d7c23
-				    ha->max_speed_sup ? "32Gps" : "16Gps");
3d7c23
-				if (vha->min_link_speed_feat) {
3d7c23
-					ha->min_link_speed = mcp->mb[5];
3d7c23
-					ql_dbg(ql_dbg_mbx, vha, 0x119c,
3d7c23
-					    "Minimum speed set=%s.\n",
3d7c23
-					    mcp->mb[5] == 5 ? "32Gps" :
3d7c23
-					    mcp->mb[5] == 4 ? "16Gps" :
3d7c23
-					    mcp->mb[5] == 3 ? "8Gps" :
3d7c23
-					    mcp->mb[5] == 2 ? "4Gps" :
3d7c23
-						"unknown");
3d7c23
-				}
3d7c23
-			}
3d7c23
+		return rval;
3d7c23
+	}
3d7c23
+
3d7c23
+	if (!IS_FWI2_CAPABLE(ha))
3d7c23
+		goto done;
3d7c23
+
3d7c23
+	ha->fw_ability_mask = mcp->mb[3] << 16 | mcp->mb[2];
3d7c23
+	ql_dbg(ql_dbg_mbx, vha, 0x119a,
3d7c23
+	    "fw_ability_mask=%x.\n", ha->fw_ability_mask);
3d7c23
+	ql_dbg(ql_dbg_mbx, vha, 0x1027, "exchanges=%x.\n", mcp->mb[1]);
3d7c23
+	if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
3d7c23
+		ha->max_supported_speed = mcp->mb[2] & (BIT_0|BIT_1);
3d7c23
+		ql_dbg(ql_dbg_mbx, vha, 0x119b, "max_supported_speed=%s.\n",
3d7c23
+		    ha->max_supported_speed == 0 ? "16Gps" :
3d7c23
+		    ha->max_supported_speed == 1 ? "32Gps" :
3d7c23
+		    ha->max_supported_speed == 2 ? "64Gps" : "unknown");
3d7c23
+		if (vha->min_supported_speed) {
3d7c23
+			ha->min_supported_speed = mcp->mb[5] &
3d7c23
+			    (BIT_0 | BIT_1 | BIT_2);
3d7c23
+			ql_dbg(ql_dbg_mbx, vha, 0x119c,
3d7c23
+			    "min_supported_speed=%s.\n",
3d7c23
+			    ha->min_supported_speed == 6 ? "64Gps" :
3d7c23
+			    ha->min_supported_speed == 5 ? "32Gps" :
3d7c23
+			    ha->min_supported_speed == 4 ? "16Gps" :
3d7c23
+			    ha->min_supported_speed == 3 ? "8Gps" :
3d7c23
+			    ha->min_supported_speed == 2 ? "4Gps" : "unknown");
3d7c23
 		}
3d7c23
-		ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1028,
3d7c23
-		    "Done.\n");
3d7c23
 	}
3d7c23
 
3d7c23
+done:
3d7c23
+	ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1028,
3d7c23
+	    "Done %s.\n", __func__);
3d7c23
+
3d7c23
 	return rval;
3d7c23
 }
3d7c23
 
3d7c23
-- 
3d7c23
2.13.6
3d7c23