All of lore.kernel.org
 help / color / mirror / Atom feed
From: Himanshu Madhani <hmadhani@marvell.com>
To: <James.Bottomley@HansenPartnership.com>, <martin.petersen@oracle.com>
Cc: <hmadhani@marvell.com>, <linux-scsi@vger.kernel.org>
Subject: [PATCH 01/25] qla2xxx: Add beacon LED config sysfs interface
Date: Wed, 12 Feb 2020 13:44:12 -0800	[thread overview]
Message-ID: <20200212214436.25532-2-hmadhani@marvell.com> (raw)
In-Reply-To: <20200212214436.25532-1-hmadhani@marvell.com>

From: Joe Carnuccio <joe.carnuccio@cavium.com>

This patch Provides interface to do the following
(using MBC 0x3B):
- Displays (in hex) the LED config words for all
  three LEDs.
- Programs the config words for one LED or for all
  three LEDs.

The sysfs node defined is named beacon_config.

First, to allow driver to gain LED control, do this:
 # echo 1 > /sys/class/scsi_host/host#/beacon

Then, to display config words for all three LEDs do this:
 # cat /sys/class/scsi_host/host#/beacon_config

To set config words for all three LEDs do this:
 # echo 3 xxxx yyyy zzzz > /sys/class/scsi_host/host#/beacon_config

Or, to set config word for a specific single LED n do this:
 # echo n xxxx > /sys/class/scsi_host/host#/beacon_config
  where n is the LED number (0, 1, 2)

Finally, to restore LED control back to firmware, do this:
 # echo 0 > /sys/class/scsi_host/host#/beacon

Signed-off-by: Joe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
---
 drivers/scsi/qla2xxx/qla_attr.c | 76 +++++++++++++++++++++++++++++++++++++++++
 drivers/scsi/qla2xxx/qla_def.h  |  1 +
 drivers/scsi/qla2xxx/qla_gbl.h  |  1 +
 drivers/scsi/qla2xxx/qla_mbx.c  | 57 +++++++++++++++++++++++++++++++
 4 files changed, 135 insertions(+)

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index d7e7043f9eab..927115dc2526 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -1324,6 +1324,79 @@ qla2x00_beacon_store(struct device *dev, struct device_attribute *attr,
 }
 
 static ssize_t
+qla2x00_beacon_config_show(struct device *dev, struct device_attribute *attr,
+    char *buf)
+{
+	scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+	struct qla_hw_data *ha = vha->hw;
+	uint16_t led[3] = { 0 };
+
+	if (!IS_QLA2031(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
+		return -EPERM;
+
+	if (ql26xx_led_config(vha, 0, led))
+		return scnprintf(buf, PAGE_SIZE, "\n");
+
+	return scnprintf(buf, PAGE_SIZE, "%#04hx %#04hx %#04hx\n",
+	    led[0], led[1], led[2]);
+}
+
+static ssize_t
+qla2x00_beacon_config_store(struct device *dev, struct device_attribute *attr,
+    const char *buf, size_t count)
+{
+	scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+	struct qla_hw_data *ha = vha->hw;
+	uint16_t options = BIT_0;
+	uint16_t led[3] = { 0 };
+	uint16_t word[4];
+	int n;
+
+	if (!IS_QLA2031(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
+		return -EPERM;
+
+	n = sscanf(buf, "%hx %hx %hx %hx", word+0, word+1, word+2, word+3);
+	if (n == 4) {
+		if (word[0] == 3) {
+			options |= BIT_3|BIT_2|BIT_1;
+			led[0] = word[1];
+			led[1] = word[2];
+			led[2] = word[3];
+			goto write;
+		}
+		return -EINVAL;
+	}
+
+	if (n == 2) {
+		/* check led index */
+		if (word[0] == 0) {
+			options |= BIT_2;
+			led[0] = word[1];
+			goto write;
+		}
+		if (word[0] == 1) {
+			options |= BIT_3;
+			led[1] = word[1];
+			goto write;
+		}
+		if (word[0] == 2) {
+			options |= BIT_1;
+			led[2] = word[1];
+			goto write;
+		}
+		return -EINVAL;
+	}
+
+	return -EINVAL;
+
+write:
+	if (ql26xx_led_config(vha, options, led))
+		return -EFAULT;
+
+	return count;
+}
+
+static ssize_t
 qla2x00_optrom_bios_version_show(struct device *dev,
 				 struct device_attribute *attr, char *buf)
 {
@@ -2264,6 +2337,8 @@ static DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show,
 		   qla2x00_zio_timer_store);
 static DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show,
 		   qla2x00_beacon_store);
+static DEVICE_ATTR(beacon_config, 0644, qla2x00_beacon_config_show,
+		   qla2x00_beacon_config_store);
 static DEVICE_ATTR(optrom_bios_version, S_IRUGO,
 		   qla2x00_optrom_bios_version_show, NULL);
 static DEVICE_ATTR(optrom_efi_version, S_IRUGO,
@@ -2327,6 +2402,7 @@ struct device_attribute *qla2x00_host_attrs[] = {
 	&dev_attr_zio,
 	&dev_attr_zio_timer,
 	&dev_attr_beacon,
+	&dev_attr_beacon_config,
 	&dev_attr_optrom_bios_version,
 	&dev_attr_optrom_efi_version,
 	&dev_attr_optrom_fcode_version,
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index ed32e9715794..b59643883ad1 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -1134,6 +1134,7 @@ static inline bool qla2xxx_is_valid_mbs(unsigned int mbs)
 #define MBC_GET_FIRMWARE_OPTION		0x28	/* Get Firmware Options. */
 #define MBC_GET_MEM_OFFLOAD_CNTRL_STAT	0x34	/* Memory Offload ctrl/Stat*/
 #define MBC_SET_FIRMWARE_OPTION		0x38	/* Set Firmware Options. */
+#define MBC_SET_GET_FC_LED_CONFIG	0x3b	/* Set/Get FC LED config */
 #define MBC_LOOP_PORT_BYPASS		0x40	/* Loop Port Bypass. */
 #define MBC_LOOP_PORT_ENABLE		0x41	/* Loop Port Enable. */
 #define MBC_GET_RESOURCE_COUNTS		0x42	/* Get Resource Counts. */
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 2a64729a2bc5..156ad11a15c4 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -844,6 +844,7 @@ extern void qla82xx_clear_pending_mbx(scsi_qla_host_t *);
 extern int qla82xx_read_temperature(scsi_qla_host_t *);
 extern int qla8044_read_temperature(scsi_qla_host_t *);
 extern int qla2x00_read_sfp_dev(struct scsi_qla_host *, char *, int);
+extern int ql26xx_led_config(scsi_qla_host_t *, uint16_t, uint16_t *);
 
 /* BSG related functions */
 extern int qla24xx_bsg_request(struct bsg_job *);
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 9e09964f5c0e..e1916bec5e36 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -6688,3 +6688,60 @@ int qla2xxx_read_remote_register(scsi_qla_host_t *vha, uint32_t addr,
 
 	return rval;
 }
+
+int
+ql26xx_led_config(scsi_qla_host_t *vha, uint16_t options, uint16_t *led)
+{
+	struct qla_hw_data *ha = vha->hw;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+	int rval;
+
+	if (!IS_QLA2031(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
+		return QLA_FUNCTION_FAILED;
+
+	ql_dbg(ql_dbg_mbx, vha, 0x7070, "Entered %s (options=%x).\n",
+	    __func__, options);
+
+	mcp->mb[0] = MBC_SET_GET_FC_LED_CONFIG;
+	mcp->mb[1] = options;
+	mcp->out_mb = MBX_1|MBX_0;
+	mcp->in_mb = MBX_1|MBX_0;
+	if (options & BIT_0) {
+		if (options & BIT_1) {
+			mcp->mb[2] = led[2];
+			mcp->out_mb |= MBX_2;
+		}
+		if (options & BIT_2) {
+			mcp->mb[3] = led[0];
+			mcp->out_mb |= MBX_3;
+		}
+		if (options & BIT_3) {
+			mcp->mb[4] = led[1];
+			mcp->out_mb |= MBX_4;
+		}
+	} else {
+		mcp->in_mb |= MBX_4|MBX_3|MBX_2;
+	}
+	mcp->tov = MBX_TOV_SECONDS;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(vha, mcp);
+	if (rval) {
+		ql_dbg(ql_dbg_mbx, vha, 0x7071, "Failed %s %x (mb=%x,%x)\n",
+		    __func__, rval, mcp->mb[0], mcp->mb[1]);
+		return rval;
+	}
+
+	if (options & BIT_0) {
+		ha->beacon_blink_led = 0;
+		ql_dbg(ql_dbg_mbx, vha, 0x7072, "Done %s\n", __func__);
+	} else {
+		led[2] = mcp->mb[2];
+		led[0] = mcp->mb[3];
+		led[1] = mcp->mb[4];
+		ql_dbg(ql_dbg_mbx, vha, 0x7073, "Done %s (led=%x,%x,%x)\n",
+		    __func__, led[0], led[1], led[2]);
+	}
+
+	return rval;
+}
-- 
2.12.0


  reply	other threads:[~2020-02-12 21:44 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12 21:44 [PATCH 00/25] qla2xxx: Updates for the driver Himanshu Madhani
2020-02-12 21:44 ` Himanshu Madhani [this message]
2020-02-12 21:44 ` [PATCH 02/25] qla2xxx: Move free of fcport out of interrupt context Himanshu Madhani
2020-02-12 21:44 ` [PATCH 03/25] qla2xxx: Add sysfs node for D-Port Diagnostics AEN data Himanshu Madhani
2020-02-12 21:44 ` [PATCH 04/25] qla2xxx: Remove all DIX-0 references Himanshu Madhani
2020-02-12 21:44 ` [PATCH 05/25] qla2xxx: Add endianizer macro calls to fc host stats Himanshu Madhani
2020-02-12 21:44 ` [PATCH 06/25] qla2xxx: Add changes in preparation for vendor extended FDMI/RDP Himanshu Madhani
2020-02-12 21:44 ` [PATCH 07/25] qla2xxx: Add vendor extended RDP additions and amendments Himanshu Madhani
2020-02-12 21:44 ` [PATCH 08/25] qla2xxx: Add ql2xrdpenable module parameter for RDP Himanshu Madhani
2020-02-12 21:44 ` [PATCH 09/25] qla2xxx: Add vendor extended FDMI commands Himanshu Madhani
2020-02-12 21:44 ` [PATCH 10/25] qla2xxx: Display message for FCE enabled Himanshu Madhani
2020-02-12 21:44 ` [PATCH 11/25] qla2xxx: Show correct port speed capabilities for RDP command Himanshu Madhani
2020-02-12 21:44 ` [PATCH 12/25] qla2xxx: Cleanup ELS/PUREX iocb fields Himanshu Madhani
2020-02-12 21:44 ` [PATCH 13/25] qla2xxx: Add deferred queue for processing ABTS and RDP Himanshu Madhani
2020-02-12 21:44 ` [PATCH 14/25] qla2xxx: Handle cases for limiting RDP response payload length Himanshu Madhani
2020-02-12 21:44 ` [PATCH 15/25] qla2xxx: Fix RDP response size Himanshu Madhani
2020-02-12 21:44 ` [PATCH 16/25] qla2xxx: Use endian macros to assign static fields in fwdump header Himanshu Madhani
2020-02-12 21:44 ` [PATCH 17/25] qla2xxx: Correction to selection of loopback/echo test Himanshu Madhani
2020-02-12 21:44 ` [PATCH 18/25] qla2xxx: Fix qla2x00_echo_test() based on ISP type Himanshu Madhani
2020-02-12 21:44 ` [PATCH 19/25] qla2xxx: Print portname for logging in qla24xx_logio_entry() Himanshu Madhani
2020-02-12 21:44 ` [PATCH 20/25] qla2xxx: Use correct ISP28xx active FW region Himanshu Madhani
2020-02-12 21:44 ` [PATCH 21/25] qla2xxx: Save rscn_gen for new fcport Himanshu Madhani
2020-02-12 21:44 ` [PATCH 22/25] qla2xxx: Fix control flags for login/logout IOCB Himanshu Madhani
2020-02-12 21:44 ` [PATCH 23/25] qla2xxx: Add fixes for mailbox command Himanshu Madhani
2020-02-12 21:44 ` [PATCH 24/25] qla2xxx: Use QLA_FW_STOPPED macro to propagate flag Himanshu Madhani
2020-02-12 21:44 ` [PATCH 25/25] qla2xxx: Update driver version to 10.01.00.24-k Himanshu Madhani
2020-02-21 23:33 ` [PATCH 00/25] qla2xxx: Updates for the driver Martin K. Petersen
2020-02-24 16:36   ` Himanshu Madhani
2020-02-25  4:32   ` Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200212214436.25532-2-hmadhani@marvell.com \
    --to=hmadhani@marvell.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.