Skip to content

Commit ca8db75

Browse files
njavaligregkh
authored andcommitted
scsi: qla2xxx: Add support to report MPI FW state
[ Upstream commit 0e124af ] MPI firmware state was returned as 0. Get MPI FW state to proceed with flash image validation. A new sysfs node 'mpi_fw_state' is added to report MPI firmware state: /sys/class/scsi_host/hostXX/mpi_fw_state Fixes: d74181c ("scsi: qla2xxx: Add bsg interface to support firmware img validation") Signed-off-by: Nilesh Javali <njavali@marvell.com> Link: https://patch.msgid.link/20260305093337.2007205-1-njavali@marvell.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 45e9bfc commit ca8db75

3 files changed

Lines changed: 71 additions & 2 deletions

File tree

drivers/scsi/qla2xxx/qla_attr.c

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@ qla2x00_fw_state_show(struct device *dev, struct device_attribute *attr,
16381638
{
16391639
scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
16401640
int rval = QLA_FUNCTION_FAILED;
1641-
uint16_t state[6];
1641+
uint16_t state[16];
16421642
uint32_t pstate;
16431643

16441644
if (IS_QLAFX00(vha->hw)) {
@@ -2402,6 +2402,63 @@ qla2x00_dport_diagnostics_show(struct device *dev,
24022402
vha->dport_data[0], vha->dport_data[1],
24032403
vha->dport_data[2], vha->dport_data[3]);
24042404
}
2405+
2406+
static ssize_t
2407+
qla2x00_mpi_fw_state_show(struct device *dev, struct device_attribute *attr,
2408+
char *buf)
2409+
{
2410+
scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
2411+
int rval = QLA_FUNCTION_FAILED;
2412+
u16 state[16];
2413+
u16 mpi_state;
2414+
struct qla_hw_data *ha = vha->hw;
2415+
2416+
if (!(IS_QLA27XX(ha) || IS_QLA28XX(ha)))
2417+
return scnprintf(buf, PAGE_SIZE,
2418+
"MPI state reporting is not supported for this HBA.\n");
2419+
2420+
memset(state, 0, sizeof(state));
2421+
2422+
mutex_lock(&vha->hw->optrom_mutex);
2423+
if (qla2x00_chip_is_down(vha)) {
2424+
mutex_unlock(&vha->hw->optrom_mutex);
2425+
ql_dbg(ql_dbg_user, vha, 0x70df,
2426+
"ISP reset is in progress, failing mpi_fw_state.\n");
2427+
return -EBUSY;
2428+
} else if (vha->hw->flags.eeh_busy) {
2429+
mutex_unlock(&vha->hw->optrom_mutex);
2430+
ql_dbg(ql_dbg_user, vha, 0x70ea,
2431+
"HBA in PCI error state, failing mpi_fw_state.\n");
2432+
return -EBUSY;
2433+
}
2434+
2435+
rval = qla2x00_get_firmware_state(vha, state);
2436+
mutex_unlock(&vha->hw->optrom_mutex);
2437+
if (rval != QLA_SUCCESS) {
2438+
ql_dbg(ql_dbg_user, vha, 0x70eb,
2439+
"MB Command to retrieve MPI state failed (%d), failing mpi_fw_state.\n",
2440+
rval);
2441+
return -EIO;
2442+
}
2443+
2444+
mpi_state = state[11];
2445+
2446+
if (!(mpi_state & BIT_15))
2447+
return scnprintf(buf, PAGE_SIZE,
2448+
"MPI firmware state reporting is not supported by this firmware. (0x%02x)\n",
2449+
mpi_state);
2450+
2451+
if (!(mpi_state & BIT_8))
2452+
return scnprintf(buf, PAGE_SIZE,
2453+
"MPI firmware is disabled. (0x%02x)\n",
2454+
mpi_state);
2455+
2456+
return scnprintf(buf, PAGE_SIZE,
2457+
"MPI firmware is enabled, state is %s. (0x%02x)\n",
2458+
mpi_state & BIT_9 ? "active" : "inactive",
2459+
mpi_state);
2460+
}
2461+
24052462
static DEVICE_ATTR(dport_diagnostics, 0444,
24062463
qla2x00_dport_diagnostics_show, NULL);
24072464

@@ -2469,6 +2526,8 @@ static DEVICE_ATTR(port_speed, 0644, qla2x00_port_speed_show,
24692526
qla2x00_port_speed_store);
24702527
static DEVICE_ATTR(port_no, 0444, qla2x00_port_no_show, NULL);
24712528
static DEVICE_ATTR(fw_attr, 0444, qla2x00_fw_attr_show, NULL);
2529+
static DEVICE_ATTR(mpi_fw_state, 0444, qla2x00_mpi_fw_state_show, NULL);
2530+
24722531

24732532
static struct attribute *qla2x00_host_attrs[] = {
24742533
&dev_attr_driver_version.attr.attr,
@@ -2517,6 +2576,7 @@ static struct attribute *qla2x00_host_attrs[] = {
25172576
&dev_attr_qlini_mode.attr,
25182577
&dev_attr_ql2xiniexchg.attr,
25192578
&dev_attr_ql2xexchoffld.attr,
2579+
&dev_attr_mpi_fw_state.attr,
25202580
NULL,
25212581
};
25222582

drivers/scsi/qla2xxx/qla_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4914,7 +4914,7 @@ qla2x00_fw_ready(scsi_qla_host_t *vha)
49144914
unsigned long wtime, mtime, cs84xx_time;
49154915
uint16_t min_wait; /* Minimum wait time if loop is down */
49164916
uint16_t wait_time; /* Wait time if loop is coming ready */
4917-
uint16_t state[6];
4917+
uint16_t state[16];
49184918
struct qla_hw_data *ha = vha->hw;
49194919

49204920
if (IS_QLAFX00(vha->hw))

drivers/scsi/qla2xxx/qla_mbx.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,6 +2268,13 @@ qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states)
22682268
mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
22692269
else
22702270
mcp->in_mb = MBX_1|MBX_0;
2271+
2272+
if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
2273+
mcp->mb[12] = 0;
2274+
mcp->out_mb |= MBX_12;
2275+
mcp->in_mb |= MBX_12;
2276+
}
2277+
22712278
mcp->tov = MBX_TOV_SECONDS;
22722279
mcp->flags = 0;
22732280
rval = qla2x00_mailbox_command(vha, mcp);
@@ -2280,6 +2287,8 @@ qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states)
22802287
states[3] = mcp->mb[4];
22812288
states[4] = mcp->mb[5];
22822289
states[5] = mcp->mb[6]; /* DPORT status */
2290+
if (IS_QLA27XX(ha) || IS_QLA28XX(ha))
2291+
states[11] = mcp->mb[12]; /* MPI state. */
22832292
}
22842293

22852294
if (rval != QLA_SUCCESS) {

0 commit comments

Comments
 (0)