diff mbox series

[v2,1/3] qla2xxx: Fix MPI failure AEN (8200) handling.

Message ID 20200327143248.27288-2-njavali@marvell.com (mailing list archive)
State Superseded
Headers show
Series qla2xxx: Updates for the driver | expand

Commit Message

Nilesh Javali March 27, 2020, 2:32 p.m. UTC
From: Arun Easi <aeasi@marvell.com>

Today, upon an MPI failure AEN, on top of collecting an MPI dump, a
regular firmware dump is also taken and the chip reset. This is
disruptive to IOs and not required. So, make the firmware dump
collection, followed by chip reset optional (not done by default).

Firmware dump buffer and MPI dump buffer are independent of each
other with this change and each can have dump that was taken at two
different times for two different issues. The MPI dump is saved in a
separate buffer and is retrieved differently from firmware dump.

To collect full dump on MPI failure AEN, a module parameter is
introduced:
    ql2xfulldump_on_mpifail (default: 0)

Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
---
 drivers/scsi/qla2xxx/qla_attr.c |  30 +++++++-
 drivers/scsi/qla2xxx/qla_def.h  |  13 +++-
 drivers/scsi/qla2xxx/qla_gbl.h  |   3 +
 drivers/scsi/qla2xxx/qla_init.c |   2 +
 drivers/scsi/qla2xxx/qla_isr.c  |  54 +++++++++-----
 drivers/scsi/qla2xxx/qla_os.c   |   6 ++
 drivers/scsi/qla2xxx/qla_tmpl.c | 121 ++++++++++++++++++++++++++------
 7 files changed, 186 insertions(+), 43 deletions(-)

Comments

kernel test robot March 27, 2020, 11:48 p.m. UTC | #1
Hi Nilesh,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on scsi/for-next]
[also build test WARNING on mkp-scsi/for-next next-20200327]
[cannot apply to v5.6-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Nilesh-Javali/qla2xxx-Updates-for-the-driver/20200328-041450
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: powerpc-defconfig (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 9.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=9.2.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/scsi/qla2xxx/qla_isr.c: In function 'qla2x00_async_event':
>> drivers/scsi/qla2xxx/qla_isr.c:903:5: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
     903 |   } else
         |     ^~~~
   drivers/scsi/qla2xxx/qla_isr.c:908:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
     908 |    if ((IS_QLA27XX(ha) || IS_QLA28XX(ha)) &&
         |    ^~

vim +/else +903 drivers/scsi/qla2xxx/qla_isr.c

ff3a920efcdbfa Arun Easi           2020-03-27   792  
^1da177e4c3f41 Linus Torvalds      2005-04-16   793  /**
^1da177e4c3f41 Linus Torvalds      2005-04-16   794   * qla2x00_async_event() - Process aynchronous events.
2db6228d9cd13b Bart Van Assche     2018-01-23   795   * @vha: SCSI driver HA context
2db6228d9cd13b Bart Van Assche     2018-01-23   796   * @rsp: response queue
9a853f71804d80 Andrew Vasquez      2005-07-06   797   * @mb: Mailbox registers (0 - 3)
^1da177e4c3f41 Linus Torvalds      2005-04-16   798   */
2c3dfe3f6ad8da Seokmann Ju         2007-07-05   799  void
73208dfd7ab19f Anirban Chakraborty 2008-12-09   800  qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
^1da177e4c3f41 Linus Torvalds      2005-04-16   801  {
^1da177e4c3f41 Linus Torvalds      2005-04-16   802  	uint16_t	handle_cnt;
bdab23da71c369 Andrew Vasquez      2009-10-13   803  	uint16_t	cnt, mbx;
^1da177e4c3f41 Linus Torvalds      2005-04-16   804  	uint32_t	handles[5];
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   805  	struct qla_hw_data *ha = vha->hw;
3d71644cf952fd Andrew Vasquez      2005-07-06   806  	struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
bdab23da71c369 Andrew Vasquez      2009-10-13   807  	struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24;
bc5c2aad17b045 Andrew Vasquez      2010-12-21   808  	struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82;
52c82823cc686d Bart Van Assche     2015-07-09   809  	uint32_t	rscn_entry, host_pid;
4d4df1932b6b11 Harihara Kadayam    2008-04-03   810  	unsigned long	flags;
ef86cb2059a14b Chad Dupuis         2014-09-25   811  	fc_port_t	*fcport = NULL;
^1da177e4c3f41 Linus Torvalds      2005-04-16   812  
45235022da9925 Quinn Tran          2018-07-18   813  	if (!vha->hw->flags.fw_started)
45235022da9925 Quinn Tran          2018-07-18   814  		return;
45235022da9925 Quinn Tran          2018-07-18   815  
^1da177e4c3f41 Linus Torvalds      2005-04-16   816  	/* Setup to process RIO completion. */
^1da177e4c3f41 Linus Torvalds      2005-04-16   817  	handle_cnt = 0;
6246b8a1d26c7c Giridhar Malavali   2012-02-09   818  	if (IS_CNA_CAPABLE(ha))
3a03eb797ce76a Andrew Vasquez      2009-01-05   819  		goto skip_rio;
^1da177e4c3f41 Linus Torvalds      2005-04-16   820  	switch (mb[0]) {
^1da177e4c3f41 Linus Torvalds      2005-04-16   821  	case MBA_SCSI_COMPLETION:
9a853f71804d80 Andrew Vasquez      2005-07-06   822  		handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1]));
^1da177e4c3f41 Linus Torvalds      2005-04-16   823  		handle_cnt = 1;
^1da177e4c3f41 Linus Torvalds      2005-04-16   824  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   825  	case MBA_CMPLT_1_16BIT:
9a853f71804d80 Andrew Vasquez      2005-07-06   826  		handles[0] = mb[1];
^1da177e4c3f41 Linus Torvalds      2005-04-16   827  		handle_cnt = 1;
^1da177e4c3f41 Linus Torvalds      2005-04-16   828  		mb[0] = MBA_SCSI_COMPLETION;
^1da177e4c3f41 Linus Torvalds      2005-04-16   829  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   830  	case MBA_CMPLT_2_16BIT:
9a853f71804d80 Andrew Vasquez      2005-07-06   831  		handles[0] = mb[1];
9a853f71804d80 Andrew Vasquez      2005-07-06   832  		handles[1] = mb[2];
^1da177e4c3f41 Linus Torvalds      2005-04-16   833  		handle_cnt = 2;
^1da177e4c3f41 Linus Torvalds      2005-04-16   834  		mb[0] = MBA_SCSI_COMPLETION;
^1da177e4c3f41 Linus Torvalds      2005-04-16   835  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   836  	case MBA_CMPLT_3_16BIT:
9a853f71804d80 Andrew Vasquez      2005-07-06   837  		handles[0] = mb[1];
9a853f71804d80 Andrew Vasquez      2005-07-06   838  		handles[1] = mb[2];
9a853f71804d80 Andrew Vasquez      2005-07-06   839  		handles[2] = mb[3];
^1da177e4c3f41 Linus Torvalds      2005-04-16   840  		handle_cnt = 3;
^1da177e4c3f41 Linus Torvalds      2005-04-16   841  		mb[0] = MBA_SCSI_COMPLETION;
^1da177e4c3f41 Linus Torvalds      2005-04-16   842  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   843  	case MBA_CMPLT_4_16BIT:
9a853f71804d80 Andrew Vasquez      2005-07-06   844  		handles[0] = mb[1];
9a853f71804d80 Andrew Vasquez      2005-07-06   845  		handles[1] = mb[2];
9a853f71804d80 Andrew Vasquez      2005-07-06   846  		handles[2] = mb[3];
^1da177e4c3f41 Linus Torvalds      2005-04-16   847  		handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6);
^1da177e4c3f41 Linus Torvalds      2005-04-16   848  		handle_cnt = 4;
^1da177e4c3f41 Linus Torvalds      2005-04-16   849  		mb[0] = MBA_SCSI_COMPLETION;
^1da177e4c3f41 Linus Torvalds      2005-04-16   850  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   851  	case MBA_CMPLT_5_16BIT:
9a853f71804d80 Andrew Vasquez      2005-07-06   852  		handles[0] = mb[1];
9a853f71804d80 Andrew Vasquez      2005-07-06   853  		handles[1] = mb[2];
9a853f71804d80 Andrew Vasquez      2005-07-06   854  		handles[2] = mb[3];
^1da177e4c3f41 Linus Torvalds      2005-04-16   855  		handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6);
^1da177e4c3f41 Linus Torvalds      2005-04-16   856  		handles[4] = (uint32_t)RD_MAILBOX_REG(ha, reg, 7);
^1da177e4c3f41 Linus Torvalds      2005-04-16   857  		handle_cnt = 5;
^1da177e4c3f41 Linus Torvalds      2005-04-16   858  		mb[0] = MBA_SCSI_COMPLETION;
^1da177e4c3f41 Linus Torvalds      2005-04-16   859  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   860  	case MBA_CMPLT_2_32BIT:
9a853f71804d80 Andrew Vasquez      2005-07-06   861  		handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1]));
^1da177e4c3f41 Linus Torvalds      2005-04-16   862  		handles[1] = le32_to_cpu(
^1da177e4c3f41 Linus Torvalds      2005-04-16   863  		    ((uint32_t)(RD_MAILBOX_REG(ha, reg, 7) << 16)) |
^1da177e4c3f41 Linus Torvalds      2005-04-16   864  		    RD_MAILBOX_REG(ha, reg, 6));
^1da177e4c3f41 Linus Torvalds      2005-04-16   865  		handle_cnt = 2;
^1da177e4c3f41 Linus Torvalds      2005-04-16   866  		mb[0] = MBA_SCSI_COMPLETION;
^1da177e4c3f41 Linus Torvalds      2005-04-16   867  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   868  	default:
^1da177e4c3f41 Linus Torvalds      2005-04-16   869  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   870  	}
3a03eb797ce76a Andrew Vasquez      2009-01-05   871  skip_rio:
^1da177e4c3f41 Linus Torvalds      2005-04-16   872  	switch (mb[0]) {
^1da177e4c3f41 Linus Torvalds      2005-04-16   873  	case MBA_SCSI_COMPLETION:	/* Fast Post */
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   874  		if (!vha->flags.online)
^1da177e4c3f41 Linus Torvalds      2005-04-16   875  			break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   876  
^1da177e4c3f41 Linus Torvalds      2005-04-16   877  		for (cnt = 0; cnt < handle_cnt; cnt++)
73208dfd7ab19f Anirban Chakraborty 2008-12-09   878  			qla2x00_process_completed_request(vha, rsp->req,
73208dfd7ab19f Anirban Chakraborty 2008-12-09   879  				handles[cnt]);
^1da177e4c3f41 Linus Torvalds      2005-04-16   880  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   881  
^1da177e4c3f41 Linus Torvalds      2005-04-16   882  	case MBA_RESET:			/* Reset */
7c3df1320e5e87 Saurav Kashyap      2011-07-14   883  		ql_dbg(ql_dbg_async, vha, 0x5002,
7c3df1320e5e87 Saurav Kashyap      2011-07-14   884  		    "Asynchronous RESET.\n");
^1da177e4c3f41 Linus Torvalds      2005-04-16   885  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   886  		set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags);
^1da177e4c3f41 Linus Torvalds      2005-04-16   887  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   888  
^1da177e4c3f41 Linus Torvalds      2005-04-16   889  	case MBA_SYSTEM_ERR:		/* System Error */
a82c307e69c465 Quinn Tran          2020-02-26   890  		mbx = 0;
a82c307e69c465 Quinn Tran          2020-02-26   891  		if (IS_QLA81XX(ha) || IS_QLA83XX(ha) ||
a82c307e69c465 Quinn Tran          2020-02-26   892  		    IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
a82c307e69c465 Quinn Tran          2020-02-26   893  			u16 m[4];
a82c307e69c465 Quinn Tran          2020-02-26   894  
a82c307e69c465 Quinn Tran          2020-02-26   895  			m[0] = RD_REG_WORD(&reg24->mailbox4);
a82c307e69c465 Quinn Tran          2020-02-26   896  			m[1] = RD_REG_WORD(&reg24->mailbox5);
a82c307e69c465 Quinn Tran          2020-02-26   897  			m[2] = RD_REG_WORD(&reg24->mailbox6);
a82c307e69c465 Quinn Tran          2020-02-26   898  			mbx = m[3] = RD_REG_WORD(&reg24->mailbox7);
a82c307e69c465 Quinn Tran          2020-02-26   899  
7c3df1320e5e87 Saurav Kashyap      2011-07-14   900  			ql_log(ql_log_warn, vha, 0x5003,
a82c307e69c465 Quinn Tran          2020-02-26   901  			    "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh mbx4=%xh mbx5=%xh mbx6=%xh mbx7=%xh.\n",
a82c307e69c465 Quinn Tran          2020-02-26   902  			    mb[1], mb[2], mb[3], m[0], m[1], m[2], m[3]);
a82c307e69c465 Quinn Tran          2020-02-26  @903  		} else
a82c307e69c465 Quinn Tran          2020-02-26   904  			ql_log(ql_log_warn, vha, 0x5003,
a82c307e69c465 Quinn Tran          2020-02-26   905  			    "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n ",
a82c307e69c465 Quinn Tran          2020-02-26   906  			    mb[1], mb[2], mb[3]);
a82c307e69c465 Quinn Tran          2020-02-26   907  
ff3a920efcdbfa Arun Easi           2020-03-27   908  			if ((IS_QLA27XX(ha) || IS_QLA28XX(ha)) &&
ff3a920efcdbfa Arun Easi           2020-03-27   909  			   RD_REG_WORD(&reg24->mailbox7) & BIT_8)
ff3a920efcdbfa Arun Easi           2020-03-27   910  				ha->isp_ops->mpi_fw_dump(vha, 1);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   911  		ha->isp_ops->fw_dump(vha, 1);
ec7193e2605511 Quinn Tran          2017-03-15   912  		ha->flags.fw_init_done = 0;
4b60c82736d0e2 Quinn Tran          2017-06-13   913  		QLA_FW_STOPPED(ha);
^1da177e4c3f41 Linus Torvalds      2005-04-16   914  
e428924ccdf464 Andrew Vasquez      2007-07-19   915  		if (IS_FWI2_CAPABLE(ha)) {
9a853f71804d80 Andrew Vasquez      2005-07-06   916  			if (mb[1] == 0 && mb[2] == 0) {
7c3df1320e5e87 Saurav Kashyap      2011-07-14   917  				ql_log(ql_log_fatal, vha, 0x5004,
9a853f71804d80 Andrew Vasquez      2005-07-06   918  				    "Unrecoverable Hardware Error: adapter "
9a853f71804d80 Andrew Vasquez      2005-07-06   919  				    "marked OFFLINE!\n");
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   920  				vha->flags.online = 0;
6246b8a1d26c7c Giridhar Malavali   2012-02-09   921  				vha->device_flags |= DFLG_DEV_FAILED;
b1d46989c12ec4 Madhuranath Iyengar 2010-09-03   922  			} else {
25985edcedea63 Lucas De Marchi     2011-03-30   923  				/* Check to see if MPI timeout occurred */
f73cb695d3eccd Chad Dupuis         2014-02-26   924  				if ((mbx & MBX_3) && (ha->port_no == 0))
b1d46989c12ec4 Madhuranath Iyengar 2010-09-03   925  					set_bit(MPI_RESET_NEEDED,
b1d46989c12ec4 Madhuranath Iyengar 2010-09-03   926  					    &vha->dpc_flags);
b1d46989c12ec4 Madhuranath Iyengar 2010-09-03   927  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   928  				set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
b1d46989c12ec4 Madhuranath Iyengar 2010-09-03   929  			}
9a853f71804d80 Andrew Vasquez      2005-07-06   930  		} else if (mb[1] == 0) {
7c3df1320e5e87 Saurav Kashyap      2011-07-14   931  			ql_log(ql_log_fatal, vha, 0x5005,
^1da177e4c3f41 Linus Torvalds      2005-04-16   932  			    "Unrecoverable Hardware Error: adapter marked "
^1da177e4c3f41 Linus Torvalds      2005-04-16   933  			    "OFFLINE!\n");
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   934  			vha->flags.online = 0;
6246b8a1d26c7c Giridhar Malavali   2012-02-09   935  			vha->device_flags |= DFLG_DEV_FAILED;
^1da177e4c3f41 Linus Torvalds      2005-04-16   936  		} else
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   937  			set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
^1da177e4c3f41 Linus Torvalds      2005-04-16   938  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   939  
^1da177e4c3f41 Linus Torvalds      2005-04-16   940  	case MBA_REQ_TRANSFER_ERR:	/* Request Transfer Error */
7c3df1320e5e87 Saurav Kashyap      2011-07-14   941  		ql_log(ql_log_warn, vha, 0x5006,
bdab23da71c369 Andrew Vasquez      2009-10-13   942  		    "ISP Request Transfer Error (%x).\n",  mb[1]);
^1da177e4c3f41 Linus Torvalds      2005-04-16   943  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   944  		set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
^1da177e4c3f41 Linus Torvalds      2005-04-16   945  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   946  
^1da177e4c3f41 Linus Torvalds      2005-04-16   947  	case MBA_RSP_TRANSFER_ERR:	/* Response Transfer Error */
7c3df1320e5e87 Saurav Kashyap      2011-07-14   948  		ql_log(ql_log_warn, vha, 0x5007,
41233cd3a454b6 Joe Carnuccio       2016-07-06   949  		    "ISP Response Transfer Error (%x).\n", mb[1]);
^1da177e4c3f41 Linus Torvalds      2005-04-16   950  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   951  		set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
^1da177e4c3f41 Linus Torvalds      2005-04-16   952  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   953  
^1da177e4c3f41 Linus Torvalds      2005-04-16   954  	case MBA_WAKEUP_THRES:		/* Request Queue Wake-up */
7c3df1320e5e87 Saurav Kashyap      2011-07-14   955  		ql_dbg(ql_dbg_async, vha, 0x5008,
41233cd3a454b6 Joe Carnuccio       2016-07-06   956  		    "Asynchronous WAKEUP_THRES (%x).\n", mb[1]);
41233cd3a454b6 Joe Carnuccio       2016-07-06   957  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   958  
41233cd3a454b6 Joe Carnuccio       2016-07-06   959  	case MBA_LOOP_INIT_ERR:
75d560e0952466 Sawan Chandak       2016-07-06   960  		ql_log(ql_log_warn, vha, 0x5090,
41233cd3a454b6 Joe Carnuccio       2016-07-06   961  		    "LOOP INIT ERROR (%x).\n", mb[1]);
41233cd3a454b6 Joe Carnuccio       2016-07-06   962  		set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
2d70c103fd2a06 Nicholas Bellinger  2012-05-15   963  		break;
41233cd3a454b6 Joe Carnuccio       2016-07-06   964  
^1da177e4c3f41 Linus Torvalds      2005-04-16   965  	case MBA_LIP_OCCURRED:		/* Loop Initialization Procedure */
ec7193e2605511 Quinn Tran          2017-03-15   966  		ha->flags.lip_ae = 1;
ec7193e2605511 Quinn Tran          2017-03-15   967  
cfb0919c12a331 Chad Dupuis         2011-11-18   968  		ql_dbg(ql_dbg_async, vha, 0x5009,
7c3df1320e5e87 Saurav Kashyap      2011-07-14   969  		    "LIP occurred (%x).\n", mb[1]);
^1da177e4c3f41 Linus Torvalds      2005-04-16   970  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   971  		if (atomic_read(&vha->loop_state) != LOOP_DOWN) {
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   972  			atomic_set(&vha->loop_state, LOOP_DOWN);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   973  			atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
3c75ad1d87c7d2 Himanshu Madhani    2019-12-17   974  			qla2x00_mark_all_devices_lost(vha);
^1da177e4c3f41 Linus Torvalds      2005-04-16   975  		}
^1da177e4c3f41 Linus Torvalds      2005-04-16   976  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   977  		if (vha->vp_idx) {
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   978  			atomic_set(&vha->vp_state, VP_FAILED);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   979  			fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED);
2c3dfe3f6ad8da Seokmann Ju         2007-07-05   980  		}
2c3dfe3f6ad8da Seokmann Ju         2007-07-05   981  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   982  		set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   983  		set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
^1da177e4c3f41 Linus Torvalds      2005-04-16   984  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   985  		vha->flags.management_server_logged_in = 0;
e315cd28b9ef0d Anirban Chakraborty 2008-11-06   986  		qla2x00_post_aen_work(vha, FCH_EVT_LIP, mb[1]);
^1da177e4c3f41 Linus Torvalds      2005-04-16   987  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16   988  
^1da177e4c3f41 Linus Torvalds      2005-04-16   989  	case MBA_LOOP_UP:		/* Loop Up Event */
daae62a33e4f9b Chad Dupuis         2012-05-15   990  		if (IS_QLA2100(ha) || IS_QLA2200(ha))
d8b4521349274a Andrew Vasquez      2006-10-02   991  			ha->link_data_rate = PORT_SPEED_1GB;
daae62a33e4f9b Chad Dupuis         2012-05-15   992  		else
^1da177e4c3f41 Linus Torvalds      2005-04-16   993  			ha->link_data_rate = mb[1];
^1da177e4c3f41 Linus Torvalds      2005-04-16   994  
8e5a9484aee8d4 Chad Dupuis         2014-08-08   995  		ql_log(ql_log_info, vha, 0x500a,
daae62a33e4f9b Chad Dupuis         2012-05-15   996  		    "LOOP UP detected (%s Gbps).\n",
d0297c9a3f429d Joe Carnuccio       2012-11-21   997  		    qla2x00_get_link_speed_str(ha, ha->link_data_rate));
^1da177e4c3f41 Linus Torvalds      2005-04-16   998  
75666f4a8c4103 Himanshu Madhani    2020-02-12   999  		if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
75666f4a8c4103 Himanshu Madhani    2020-02-12  1000  			if (mb[2] & BIT_0)
75666f4a8c4103 Himanshu Madhani    2020-02-12  1001  				ql_log(ql_log_info, vha, 0x11a0,
75666f4a8c4103 Himanshu Madhani    2020-02-12  1002  				    "FEC=enabled (link up).\n");
75666f4a8c4103 Himanshu Madhani    2020-02-12  1003  		}
75666f4a8c4103 Himanshu Madhani    2020-02-12  1004  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1005  		vha->flags.management_server_logged_in = 0;
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1006  		qla2x00_post_aen_work(vha, FCH_EVT_LINKUP, ha->link_data_rate);
e4e3a2ce9556cc Quinn Tran          2017-08-23  1007  
^1da177e4c3f41 Linus Torvalds      2005-04-16  1008  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1009  
^1da177e4c3f41 Linus Torvalds      2005-04-16  1010  	case MBA_LOOP_DOWN:		/* Loop Down Event */
9cd883f07a54e5 Quinn Tran          2017-12-28  1011  		SAVE_TOPO(ha);
ec7193e2605511 Quinn Tran          2017-03-15  1012  		ha->flags.lip_ae = 0;
ec7193e2605511 Quinn Tran          2017-03-15  1013  		ha->current_topology = 0;
ec7193e2605511 Quinn Tran          2017-03-15  1014  
6246b8a1d26c7c Giridhar Malavali   2012-02-09  1015  		mbx = (IS_QLA81XX(ha) || IS_QLA8031(ha))
6246b8a1d26c7c Giridhar Malavali   2012-02-09  1016  			? RD_REG_WORD(&reg24->mailbox4) : 0;
7ec0effd30bb4b Atul Deshmukh       2013-08-27  1017  		mbx = (IS_P3P_TYPE(ha)) ? RD_REG_WORD(&reg82->mailbox_out[4])
7ec0effd30bb4b Atul Deshmukh       2013-08-27  1018  			: mbx;
8e5a9484aee8d4 Chad Dupuis         2014-08-08  1019  		ql_log(ql_log_info, vha, 0x500b,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1020  		    "LOOP DOWN detected (%x %x %x %x).\n",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1021  		    mb[1], mb[2], mb[3], mbx);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1022  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1023  		if (atomic_read(&vha->loop_state) != LOOP_DOWN) {
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1024  			atomic_set(&vha->loop_state, LOOP_DOWN);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1025  			atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
2486c62765d73a Himanshu Madhani    2014-09-25  1026  			/*
2486c62765d73a Himanshu Madhani    2014-09-25  1027  			 * In case of loop down, restore WWPN from
2486c62765d73a Himanshu Madhani    2014-09-25  1028  			 * NVRAM in case of FA-WWPN capable ISP
718abbdca79f8a Sawan Chandak       2015-04-09  1029  			 * Restore for Physical Port only
2486c62765d73a Himanshu Madhani    2014-09-25  1030  			 */
718abbdca79f8a Sawan Chandak       2015-04-09  1031  			if (!vha->vp_idx) {
dcbf8f8087ebc4 Sawan Chandak       2019-01-24  1032  				if (ha->flags.fawwpn_enabled &&
dcbf8f8087ebc4 Sawan Chandak       2019-01-24  1033  				    (ha->current_topology == ISP_CFG_F)) {
2486c62765d73a Himanshu Madhani    2014-09-25  1034  					void *wwpn = ha->init_cb->port_name;
bd432bb53cffea Bart Van Assche     2019-04-11  1035  
2486c62765d73a Himanshu Madhani    2014-09-25  1036  					memcpy(vha->port_name, wwpn, WWN_SIZE);
718abbdca79f8a Sawan Chandak       2015-04-09  1037  					fc_host_port_name(vha->host) =
718abbdca79f8a Sawan Chandak       2015-04-09  1038  					    wwn_to_u64(vha->port_name);
718abbdca79f8a Sawan Chandak       2015-04-09  1039  					ql_dbg(ql_dbg_init + ql_dbg_verbose,
83548fe2fcbb78 Quinn Tran          2017-06-02  1040  					    vha, 0x00d8, "LOOP DOWN detected,"
718abbdca79f8a Sawan Chandak       2015-04-09  1041  					    "restore WWPN %016llx\n",
718abbdca79f8a Sawan Chandak       2015-04-09  1042  					    wwn_to_u64(vha->port_name));
2486c62765d73a Himanshu Madhani    2014-09-25  1043  				}
2486c62765d73a Himanshu Madhani    2014-09-25  1044  
ded6411fd88267 Sawan Chandak       2015-04-09  1045  				clear_bit(VP_CONFIG_OK, &vha->vp_flags);
718abbdca79f8a Sawan Chandak       2015-04-09  1046  			}
718abbdca79f8a Sawan Chandak       2015-04-09  1047  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1048  			vha->device_flags |= DFLG_NO_CABLE;
3c75ad1d87c7d2 Himanshu Madhani    2019-12-17  1049  			qla2x00_mark_all_devices_lost(vha);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1050  		}
^1da177e4c3f41 Linus Torvalds      2005-04-16  1051  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1052  		if (vha->vp_idx) {
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1053  			atomic_set(&vha->vp_state, VP_FAILED);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1054  			fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED);
2c3dfe3f6ad8da Seokmann Ju         2007-07-05  1055  		}
2c3dfe3f6ad8da Seokmann Ju         2007-07-05  1056  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1057  		vha->flags.management_server_logged_in = 0;
d8b4521349274a Andrew Vasquez      2006-10-02  1058  		ha->link_data_rate = PORT_SPEED_UNKNOWN;
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1059  		qla2x00_post_aen_work(vha, FCH_EVT_LINKDOWN, 0);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1060  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1061  
^1da177e4c3f41 Linus Torvalds      2005-04-16  1062  	case MBA_LIP_RESET:		/* LIP reset occurred */
cfb0919c12a331 Chad Dupuis         2011-11-18  1063  		ql_dbg(ql_dbg_async, vha, 0x500c,
cc3ef7bc40bbed Bjorn Helgaas       2008-09-11  1064  		    "LIP reset occurred (%x).\n", mb[1]);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1065  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1066  		if (atomic_read(&vha->loop_state) != LOOP_DOWN) {
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1067  			atomic_set(&vha->loop_state, LOOP_DOWN);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1068  			atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
3c75ad1d87c7d2 Himanshu Madhani    2019-12-17  1069  			qla2x00_mark_all_devices_lost(vha);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1070  		}
^1da177e4c3f41 Linus Torvalds      2005-04-16  1071  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1072  		if (vha->vp_idx) {
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1073  			atomic_set(&vha->vp_state, VP_FAILED);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1074  			fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED);
2c3dfe3f6ad8da Seokmann Ju         2007-07-05  1075  		}
2c3dfe3f6ad8da Seokmann Ju         2007-07-05  1076  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1077  		set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1078  
^1da177e4c3f41 Linus Torvalds      2005-04-16  1079  		ha->operating_mode = LOOP;
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1080  		vha->flags.management_server_logged_in = 0;
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1081  		qla2x00_post_aen_work(vha, FCH_EVT_LIPRESET, mb[1]);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1082  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1083  
3a03eb797ce76a Andrew Vasquez      2009-01-05  1084  	/* case MBA_DCBX_COMPLETE: */
^1da177e4c3f41 Linus Torvalds      2005-04-16  1085  	case MBA_POINT_TO_POINT:	/* Point-to-Point */
ec7193e2605511 Quinn Tran          2017-03-15  1086  		ha->flags.lip_ae = 0;
ec7193e2605511 Quinn Tran          2017-03-15  1087  
^1da177e4c3f41 Linus Torvalds      2005-04-16  1088  		if (IS_QLA2100(ha))
^1da177e4c3f41 Linus Torvalds      2005-04-16  1089  			break;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1090  
7ec0effd30bb4b Atul Deshmukh       2013-08-27  1091  		if (IS_CNA_CAPABLE(ha)) {
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1092  			ql_dbg(ql_dbg_async, vha, 0x500d,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1093  			    "DCBX Completed -- %04x %04x %04x.\n",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1094  			    mb[1], mb[2], mb[3]);
9aaf2cea4e63ed Chad Dupuis         2013-10-30  1095  			if (ha->notify_dcbx_comp && !vha->vp_idx)
23f2ebd17a1383 Sarang Radke        2010-05-28  1096  				complete(&ha->dcbx_comp);
23f2ebd17a1383 Sarang Radke        2010-05-28  1097  
23f2ebd17a1383 Sarang Radke        2010-05-28  1098  		} else
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1099  			ql_dbg(ql_dbg_async, vha, 0x500e,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1100  			    "Asynchronous P2P MODE received.\n");
^1da177e4c3f41 Linus Torvalds      2005-04-16  1101  
^1da177e4c3f41 Linus Torvalds      2005-04-16  1102  		/*
^1da177e4c3f41 Linus Torvalds      2005-04-16  1103  		 * Until there's a transition from loop down to loop up, treat
^1da177e4c3f41 Linus Torvalds      2005-04-16  1104  		 * this as loop down only.
^1da177e4c3f41 Linus Torvalds      2005-04-16  1105  		 */
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1106  		if (atomic_read(&vha->loop_state) != LOOP_DOWN) {
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1107  			atomic_set(&vha->loop_state, LOOP_DOWN);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1108  			if (!atomic_read(&vha->loop_down_timer))
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1109  				atomic_set(&vha->loop_down_timer,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1110  				    LOOP_DOWN_TIME);
48acad09907498 Quinn Tran          2018-08-02  1111  			if (!N2N_TOPO(ha))
3c75ad1d87c7d2 Himanshu Madhani    2019-12-17  1112  				qla2x00_mark_all_devices_lost(vha);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1113  		}
^1da177e4c3f41 Linus Torvalds      2005-04-16  1114  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1115  		if (vha->vp_idx) {
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1116  			atomic_set(&vha->vp_state, VP_FAILED);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1117  			fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED);
2c3dfe3f6ad8da Seokmann Ju         2007-07-05  1118  		}
2c3dfe3f6ad8da Seokmann Ju         2007-07-05  1119  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1120  		if (!(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)))
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1121  			set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1122  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1123  		set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1124  		set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
4346b14942dbb6 Andrew Vasquez      2006-12-13  1125  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1126  		vha->flags.management_server_logged_in = 0;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1127  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1128  
^1da177e4c3f41 Linus Torvalds      2005-04-16  1129  	case MBA_CHG_IN_CONNECTION:	/* Change in connection mode */
^1da177e4c3f41 Linus Torvalds      2005-04-16  1130  		if (IS_QLA2100(ha))
^1da177e4c3f41 Linus Torvalds      2005-04-16  1131  			break;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1132  
cfb0919c12a331 Chad Dupuis         2011-11-18  1133  		ql_dbg(ql_dbg_async, vha, 0x500f,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1134  		    "Configuration change detected: value=%x.\n", mb[1]);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1135  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1136  		if (atomic_read(&vha->loop_state) != LOOP_DOWN) {
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1137  			atomic_set(&vha->loop_state, LOOP_DOWN);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1138  			if (!atomic_read(&vha->loop_down_timer))
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1139  				atomic_set(&vha->loop_down_timer,
^1da177e4c3f41 Linus Torvalds      2005-04-16  1140  				    LOOP_DOWN_TIME);
3c75ad1d87c7d2 Himanshu Madhani    2019-12-17  1141  			qla2x00_mark_all_devices_lost(vha);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1142  		}
^1da177e4c3f41 Linus Torvalds      2005-04-16  1143  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1144  		if (vha->vp_idx) {
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1145  			atomic_set(&vha->vp_state, VP_FAILED);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1146  			fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED);
2c3dfe3f6ad8da Seokmann Ju         2007-07-05  1147  		}
2c3dfe3f6ad8da Seokmann Ju         2007-07-05  1148  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1149  		set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1150  		set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1151  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1152  
^1da177e4c3f41 Linus Torvalds      2005-04-16  1153  	case MBA_PORT_UPDATE:		/* Port database update */
55903b9d152e91 Santosh Vernekar    2009-07-31  1154  		/*
55903b9d152e91 Santosh Vernekar    2009-07-31  1155  		 * Handle only global and vn-port update events
55903b9d152e91 Santosh Vernekar    2009-07-31  1156  		 *
55903b9d152e91 Santosh Vernekar    2009-07-31  1157  		 * Relevant inputs:
55903b9d152e91 Santosh Vernekar    2009-07-31  1158  		 * mb[1] = N_Port handle of changed port
55903b9d152e91 Santosh Vernekar    2009-07-31  1159  		 * OR 0xffff for global event
55903b9d152e91 Santosh Vernekar    2009-07-31  1160  		 * mb[2] = New login state
55903b9d152e91 Santosh Vernekar    2009-07-31  1161  		 * 7 = Port logged out
55903b9d152e91 Santosh Vernekar    2009-07-31  1162  		 * mb[3] = LSB is vp_idx, 0xff = all vps
55903b9d152e91 Santosh Vernekar    2009-07-31  1163  		 *
55903b9d152e91 Santosh Vernekar    2009-07-31  1164  		 * Skip processing if:
55903b9d152e91 Santosh Vernekar    2009-07-31  1165  		 *       Event is global, vp_idx is NOT all vps,
55903b9d152e91 Santosh Vernekar    2009-07-31  1166  		 *           vp_idx does not match
55903b9d152e91 Santosh Vernekar    2009-07-31  1167  		 *       Event is not global, vp_idx does not match
55903b9d152e91 Santosh Vernekar    2009-07-31  1168  		 */
12cec63e40f9b9 Andrew Vasquez      2010-03-19  1169  		if (IS_QLA2XXX_MIDTYPE(ha) &&
12cec63e40f9b9 Andrew Vasquez      2010-03-19  1170  		    ((mb[1] == 0xffff && (mb[3] & 0xff) != 0xff) ||
12cec63e40f9b9 Andrew Vasquez      2010-03-19  1171  			(mb[1] != 0xffff)) && vha->vp_idx != (mb[3] & 0xff))
73208dfd7ab19f Anirban Chakraborty 2008-12-09  1172  			break;
73208dfd7ab19f Anirban Chakraborty 2008-12-09  1173  
17cac3a175a02c Joe Carnuccio       2015-08-04  1174  		if (mb[2] == 0x7) {
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1175  			ql_dbg(ql_dbg_async, vha, 0x5010,
17cac3a175a02c Joe Carnuccio       2015-08-04  1176  			    "Port %s %04x %04x %04x.\n",
17cac3a175a02c Joe Carnuccio       2015-08-04  1177  			    mb[1] == 0xffff ? "unavailable" : "logout",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1178  			    mb[1], mb[2], mb[3]);
17cac3a175a02c Joe Carnuccio       2015-08-04  1179  
17cac3a175a02c Joe Carnuccio       2015-08-04  1180  			if (mb[1] == 0xffff)
17cac3a175a02c Joe Carnuccio       2015-08-04  1181  				goto global_port_update;
17cac3a175a02c Joe Carnuccio       2015-08-04  1182  
b98ae0d748dbc8 Quinn Tran          2017-06-02  1183  			if (mb[1] == NPH_SNS_LID(ha)) {
b98ae0d748dbc8 Quinn Tran          2017-06-02  1184  				set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
b98ae0d748dbc8 Quinn Tran          2017-06-02  1185  				set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
b98ae0d748dbc8 Quinn Tran          2017-06-02  1186  				break;
b98ae0d748dbc8 Quinn Tran          2017-06-02  1187  			}
b98ae0d748dbc8 Quinn Tran          2017-06-02  1188  
b98ae0d748dbc8 Quinn Tran          2017-06-02  1189  			/* use handle_cnt for loop id/nport handle */
b98ae0d748dbc8 Quinn Tran          2017-06-02  1190  			if (IS_FWI2_CAPABLE(ha))
b98ae0d748dbc8 Quinn Tran          2017-06-02  1191  				handle_cnt = NPH_SNS;
b98ae0d748dbc8 Quinn Tran          2017-06-02  1192  			else
b98ae0d748dbc8 Quinn Tran          2017-06-02  1193  				handle_cnt = SIMPLE_NAME_SERVER;
b98ae0d748dbc8 Quinn Tran          2017-06-02  1194  			if (mb[1] == handle_cnt) {
b98ae0d748dbc8 Quinn Tran          2017-06-02  1195  				set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
b98ae0d748dbc8 Quinn Tran          2017-06-02  1196  				set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
b98ae0d748dbc8 Quinn Tran          2017-06-02  1197  				break;
b98ae0d748dbc8 Quinn Tran          2017-06-02  1198  			}
b98ae0d748dbc8 Quinn Tran          2017-06-02  1199  
17cac3a175a02c Joe Carnuccio       2015-08-04  1200  			/* Port logout */
17cac3a175a02c Joe Carnuccio       2015-08-04  1201  			fcport = qla2x00_find_fcport_by_loopid(vha, mb[1]);
17cac3a175a02c Joe Carnuccio       2015-08-04  1202  			if (!fcport)
17cac3a175a02c Joe Carnuccio       2015-08-04  1203  				break;
17cac3a175a02c Joe Carnuccio       2015-08-04  1204  			if (atomic_read(&fcport->state) != FCS_ONLINE)
17cac3a175a02c Joe Carnuccio       2015-08-04  1205  				break;
17cac3a175a02c Joe Carnuccio       2015-08-04  1206  			ql_dbg(ql_dbg_async, vha, 0x508a,
17cac3a175a02c Joe Carnuccio       2015-08-04  1207  			    "Marking port lost loopid=%04x portid=%06x.\n",
17cac3a175a02c Joe Carnuccio       2015-08-04  1208  			    fcport->loop_id, fcport->d_id.b24);
726b85487067d7 Quinn Tran          2017-01-19  1209  			if (qla_ini_mode_enabled(vha)) {
726b85487067d7 Quinn Tran          2017-01-19  1210  				fcport->logout_on_delete = 0;
d8630bb95f46ea Quinn Tran          2017-12-28  1211  				qlt_schedule_sess_for_deletion(fcport);
726b85487067d7 Quinn Tran          2017-01-19  1212  			}
17cac3a175a02c Joe Carnuccio       2015-08-04  1213  			break;
17cac3a175a02c Joe Carnuccio       2015-08-04  1214  
17cac3a175a02c Joe Carnuccio       2015-08-04  1215  global_port_update:
9764ff8807a245 Andrew Vasquez      2009-07-31  1216  			if (atomic_read(&vha->loop_state) != LOOP_DOWN) {
9764ff8807a245 Andrew Vasquez      2009-07-31  1217  				atomic_set(&vha->loop_state, LOOP_DOWN);
9764ff8807a245 Andrew Vasquez      2009-07-31  1218  				atomic_set(&vha->loop_down_timer,
9764ff8807a245 Andrew Vasquez      2009-07-31  1219  				    LOOP_DOWN_TIME);
9764ff8807a245 Andrew Vasquez      2009-07-31  1220  				vha->device_flags |= DFLG_NO_CABLE;
3c75ad1d87c7d2 Himanshu Madhani    2019-12-17  1221  				qla2x00_mark_all_devices_lost(vha);
9764ff8807a245 Andrew Vasquez      2009-07-31  1222  			}
9764ff8807a245 Andrew Vasquez      2009-07-31  1223  
9764ff8807a245 Andrew Vasquez      2009-07-31  1224  			if (vha->vp_idx) {
9764ff8807a245 Andrew Vasquez      2009-07-31  1225  				atomic_set(&vha->vp_state, VP_FAILED);
9764ff8807a245 Andrew Vasquez      2009-07-31  1226  				fc_vport_set_state(vha->fc_vport,
9764ff8807a245 Andrew Vasquez      2009-07-31  1227  				    FC_VPORT_FAILED);
3c75ad1d87c7d2 Himanshu Madhani    2019-12-17  1228  				qla2x00_mark_all_devices_lost(vha);
9764ff8807a245 Andrew Vasquez      2009-07-31  1229  			}
9764ff8807a245 Andrew Vasquez      2009-07-31  1230  
9764ff8807a245 Andrew Vasquez      2009-07-31  1231  			vha->flags.management_server_logged_in = 0;
9764ff8807a245 Andrew Vasquez      2009-07-31  1232  			ha->link_data_rate = PORT_SPEED_UNKNOWN;
9764ff8807a245 Andrew Vasquez      2009-07-31  1233  			break;
9764ff8807a245 Andrew Vasquez      2009-07-31  1234  		}
9764ff8807a245 Andrew Vasquez      2009-07-31  1235  
^1da177e4c3f41 Linus Torvalds      2005-04-16  1236  		/*
cc3ef7bc40bbed Bjorn Helgaas       2008-09-11  1237  		 * If PORT UPDATE is global (received LIP_OCCURRED/LIP_RESET
^1da177e4c3f41 Linus Torvalds      2005-04-16  1238  		 * event etc. earlier indicating loop is down) then process
^1da177e4c3f41 Linus Torvalds      2005-04-16  1239  		 * it.  Otherwise ignore it and Wait for RSCN to come in.
^1da177e4c3f41 Linus Torvalds      2005-04-16  1240  		 */
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1241  		atomic_set(&vha->loop_down_timer, 0);
8e5a9484aee8d4 Chad Dupuis         2014-08-08  1242  		if (atomic_read(&vha->loop_state) != LOOP_DOWN &&
edd05de1975927 Duane Grigsby       2017-10-13  1243  			!ha->flags.n2n_ae  &&
8e5a9484aee8d4 Chad Dupuis         2014-08-08  1244  		    atomic_read(&vha->loop_state) != LOOP_DEAD) {
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1245  			ql_dbg(ql_dbg_async, vha, 0x5011,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1246  			    "Asynchronous PORT UPDATE ignored %04x/%04x/%04x.\n",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1247  			    mb[1], mb[2], mb[3]);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1248  			break;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1249  		}
^1da177e4c3f41 Linus Torvalds      2005-04-16  1250  
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1251  		ql_dbg(ql_dbg_async, vha, 0x5012,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1252  		    "Port database changed %04x %04x %04x.\n",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1253  		    mb[1], mb[2], mb[3]);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1254  
^1da177e4c3f41 Linus Torvalds      2005-04-16  1255  		/*
^1da177e4c3f41 Linus Torvalds      2005-04-16  1256  		 * Mark all devices as missing so we will login again.
^1da177e4c3f41 Linus Torvalds      2005-04-16  1257  		 */
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1258  		atomic_set(&vha->loop_state, LOOP_UP);
6944dccbb7c9db Quinn Tran          2017-12-28  1259  		vha->scan.scan_retry = 0;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1260  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1261  		set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1262  		set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
ded6411fd88267 Sawan Chandak       2015-04-09  1263  		set_bit(VP_CONFIG_OK, &vha->vp_flags);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1264  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1265  
^1da177e4c3f41 Linus Torvalds      2005-04-16  1266  	case MBA_RSCN_UPDATE:		/* State Change Registration */
3c39740073b20d Seokmann Ju         2008-05-19  1267  		/* Check if the Vport has issued a SCR */
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1268  		if (vha->vp_idx && test_bit(VP_SCR_NEEDED, &vha->vp_flags))
3c39740073b20d Seokmann Ju         2008-05-19  1269  			break;
3c39740073b20d Seokmann Ju         2008-05-19  1270  		/* Only handle SCNs for our Vport index. */
0d6e61bc6a4f3f Andrew Vasquez      2009-08-25  1271  		if (ha->flags.npiv_supported && vha->vp_idx != (mb[3] & 0xff))
f4a8dbc7f6ca8c Shyam Sundar        2007-11-12  1272  			break;
0d6e61bc6a4f3f Andrew Vasquez      2009-08-25  1273  
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1274  		ql_dbg(ql_dbg_async, vha, 0x5013,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1275  		    "RSCN database changed -- %04x %04x %04x.\n",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1276  		    mb[1], mb[2], mb[3]);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1277  
59d72d873ccfaf Ravi Anand          2008-09-11  1278  		rscn_entry = ((mb[1] & 0xff) << 16) | mb[2];
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1279  		host_pid = (vha->d_id.b.domain << 16) | (vha->d_id.b.area << 8)
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1280  				| vha->d_id.b.al_pa;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1281  		if (rscn_entry == host_pid) {
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1282  			ql_dbg(ql_dbg_async, vha, 0x5014,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1283  			    "Ignoring RSCN update to local host "
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1284  			    "port ID (%06x).\n", host_pid);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1285  			break;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1286  		}
^1da177e4c3f41 Linus Torvalds      2005-04-16  1287  
59d72d873ccfaf Ravi Anand          2008-09-11  1288  		/* Ignore reserved bits from RSCN-payload. */
59d72d873ccfaf Ravi Anand          2008-09-11  1289  		rscn_entry = ((mb[1] & 0x3ff) << 16) | mb[2];
^1da177e4c3f41 Linus Torvalds      2005-04-16  1290  
bb4cf5b73b47fe Chad Dupuis         2013-02-08  1291  		/* Skip RSCNs for virtual ports on the same physical port */
bb4cf5b73b47fe Chad Dupuis         2013-02-08  1292  		if (qla2x00_is_a_vp_did(vha, rscn_entry))
bb4cf5b73b47fe Chad Dupuis         2013-02-08  1293  			break;
bb4cf5b73b47fe Chad Dupuis         2013-02-08  1294  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1295  		atomic_set(&vha->loop_down_timer, 0);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1296  		vha->flags.management_server_logged_in = 0;
726b85487067d7 Quinn Tran          2017-01-19  1297  		{
726b85487067d7 Quinn Tran          2017-01-19  1298  			struct event_arg ea;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1299  
726b85487067d7 Quinn Tran          2017-01-19  1300  			memset(&ea, 0, sizeof(ea));
726b85487067d7 Quinn Tran          2017-01-19  1301  			ea.id.b24 = rscn_entry;
41dc529a4602ac Quinn Tran          2017-01-19  1302  			ea.id.b.rsvd_1 = rscn_entry >> 24;
897def20042136 Bart Van Assche     2019-08-08  1303  			qla2x00_handle_rscn(vha, &ea);
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1304  			qla2x00_post_aen_work(vha, FCH_EVT_RSCN, rscn_entry);
726b85487067d7 Quinn Tran          2017-01-19  1305  		}
^1da177e4c3f41 Linus Torvalds      2005-04-16  1306  		break;
^1da177e4c3f41 Linus Torvalds      2005-04-16  1307  	/* case MBA_RIO_RESPONSE: */
^1da177e4c3f41 Linus Torvalds      2005-04-16  1308  	case MBA_ZIO_RESPONSE:
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1309  		ql_dbg(ql_dbg_async, vha, 0x5015,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1310  		    "[R|Z]IO update completion.\n");
^1da177e4c3f41 Linus Torvalds      2005-04-16  1311  
e428924ccdf464 Andrew Vasquez      2007-07-19  1312  		if (IS_FWI2_CAPABLE(ha))
2afa19a9377ca6 Anirban Chakraborty 2009-04-06  1313  			qla24xx_process_response_queue(vha, rsp);
4fdfefe52944f5 Andrew Vasquez      2005-10-27  1314  		else
73208dfd7ab19f Anirban Chakraborty 2008-12-09  1315  			qla2x00_process_response_queue(rsp);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1316  		break;
9a853f71804d80 Andrew Vasquez      2005-07-06  1317  
9a853f71804d80 Andrew Vasquez      2005-07-06  1318  	case MBA_DISCARD_RND_FRAME:
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1319  		ql_dbg(ql_dbg_async, vha, 0x5016,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1320  		    "Discard RND Frame -- %04x %04x %04x.\n",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1321  		    mb[1], mb[2], mb[3]);
9a853f71804d80 Andrew Vasquez      2005-07-06  1322  		break;
45ebeb560570fd Andrew Vasquez      2006-08-01  1323  
45ebeb560570fd Andrew Vasquez      2006-08-01  1324  	case MBA_TRACE_NOTIFICATION:
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1325  		ql_dbg(ql_dbg_async, vha, 0x5017,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1326  		    "Trace Notification -- %04x %04x.\n", mb[1], mb[2]);
45ebeb560570fd Andrew Vasquez      2006-08-01  1327  		break;
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1328  
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1329  	case MBA_ISP84XX_ALERT:
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1330  		ql_dbg(ql_dbg_async, vha, 0x5018,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1331  		    "ISP84XX Alert Notification -- %04x %04x %04x.\n",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1332  		    mb[1], mb[2], mb[3]);
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1333  
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1334  		spin_lock_irqsave(&ha->cs84xx->access_lock, flags);
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1335  		switch (mb[1]) {
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1336  		case A84_PANIC_RECOVERY:
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1337  			ql_log(ql_log_info, vha, 0x5019,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1338  			    "Alert 84XX: panic recovery %04x %04x.\n",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1339  			    mb[2], mb[3]);
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1340  			break;
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1341  		case A84_OP_LOGIN_COMPLETE:
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1342  			ha->cs84xx->op_fw_version = mb[3] << 16 | mb[2];
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1343  			ql_log(ql_log_info, vha, 0x501a,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1344  			    "Alert 84XX: firmware version %x.\n",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1345  			    ha->cs84xx->op_fw_version);
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1346  			break;
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1347  		case A84_DIAG_LOGIN_COMPLETE:
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1348  			ha->cs84xx->diag_fw_version = mb[3] << 16 | mb[2];
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1349  			ql_log(ql_log_info, vha, 0x501b,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1350  			    "Alert 84XX: diagnostic firmware version %x.\n",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1351  			    ha->cs84xx->diag_fw_version);
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1352  			break;
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1353  		case A84_GOLD_LOGIN_COMPLETE:
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1354  			ha->cs84xx->diag_fw_version = mb[3] << 16 | mb[2];
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1355  			ha->cs84xx->fw_update = 1;
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1356  			ql_log(ql_log_info, vha, 0x501c,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1357  			    "Alert 84XX: gold firmware version %x.\n",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1358  			    ha->cs84xx->gold_fw_version);
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1359  			break;
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1360  		default:
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1361  			ql_log(ql_log_warn, vha, 0x501d,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1362  			    "Alert 84xx: Invalid Alert %04x %04x %04x.\n",
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1363  			    mb[1], mb[2], mb[3]);
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1364  		}
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1365  		spin_unlock_irqrestore(&ha->cs84xx->access_lock, flags);
4d4df1932b6b11 Harihara Kadayam    2008-04-03  1366  		break;
3a03eb797ce76a Andrew Vasquez      2009-01-05  1367  	case MBA_DCBX_START:
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1368  		ql_dbg(ql_dbg_async, vha, 0x501e,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1369  		    "DCBX Started -- %04x %04x %04x.\n",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1370  		    mb[1], mb[2], mb[3]);
3a03eb797ce76a Andrew Vasquez      2009-01-05  1371  		break;
3a03eb797ce76a Andrew Vasquez      2009-01-05  1372  	case MBA_DCBX_PARAM_UPDATE:
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1373  		ql_dbg(ql_dbg_async, vha, 0x501f,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1374  		    "DCBX Parameters Updated -- %04x %04x %04x.\n",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1375  		    mb[1], mb[2], mb[3]);
3a03eb797ce76a Andrew Vasquez      2009-01-05  1376  		break;
3a03eb797ce76a Andrew Vasquez      2009-01-05  1377  	case MBA_FCF_CONF_ERR:
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1378  		ql_dbg(ql_dbg_async, vha, 0x5020,
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1379  		    "FCF Configuration Error -- %04x %04x %04x.\n",
7c3df1320e5e87 Saurav Kashyap      2011-07-14  1380  		    mb[1], mb[2], mb[3]);
3a03eb797ce76a Andrew Vasquez      2009-01-05  1381  		break;
3a03eb797ce76a Andrew Vasquez      2009-01-05  1382  	case MBA_IDC_NOTIFY:
7ec0effd30bb4b Atul Deshmukh       2013-08-27  1383  		if (IS_QLA8031(vha->hw) || IS_QLA8044(ha)) {
67b2a31f517a43 Chad Dupuis         2013-02-08  1384  			mb[4] = RD_REG_WORD(&reg24->mailbox4);
67b2a31f517a43 Chad Dupuis         2013-02-08  1385  			if (((mb[2] & 0x7fff) == MBC_PORT_RESET ||
67b2a31f517a43 Chad Dupuis         2013-02-08  1386  			    (mb[2] & 0x7fff) == MBC_SET_PORT_CONFIG) &&
67b2a31f517a43 Chad Dupuis         2013-02-08  1387  			    (mb[4] & INTERNAL_LOOPBACK_MASK) != 0) {
8fcd6b8b0fbc61 Chad Dupuis         2012-08-22  1388  				set_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags);
67b2a31f517a43 Chad Dupuis         2013-02-08  1389  				/*
67b2a31f517a43 Chad Dupuis         2013-02-08  1390  				 * Extend loop down timer since port is active.
67b2a31f517a43 Chad Dupuis         2013-02-08  1391  				 */
67b2a31f517a43 Chad Dupuis         2013-02-08  1392  				if (atomic_read(&vha->loop_state) == LOOP_DOWN)
67b2a31f517a43 Chad Dupuis         2013-02-08  1393  					atomic_set(&vha->loop_down_timer,
67b2a31f517a43 Chad Dupuis         2013-02-08  1394  					    LOOP_DOWN_TIME);
8fcd6b8b0fbc61 Chad Dupuis         2012-08-22  1395  				qla2xxx_wake_dpc(vha);
8fcd6b8b0fbc61 Chad Dupuis         2012-08-22  1396  			}
67b2a31f517a43 Chad Dupuis         2013-02-08  1397  		}
81881861ae10ef Bart Van Assche     2017-12-07  1398  		/* fall through */
8fcd6b8b0fbc61 Chad Dupuis         2012-08-22  1399  	case MBA_IDC_COMPLETE:
9aaf2cea4e63ed Chad Dupuis         2013-10-30  1400  		if (ha->notify_lb_portup_comp && !vha->vp_idx)
f356bef134dda5 Chad Dupuis         2013-02-08  1401  			complete(&ha->lb_portup_comp);
f356bef134dda5 Chad Dupuis         2013-02-08  1402  		/* Fallthru */
3a03eb797ce76a Andrew Vasquez      2009-01-05  1403  	case MBA_IDC_TIME_EXT:
7ec0effd30bb4b Atul Deshmukh       2013-08-27  1404  		if (IS_QLA81XX(vha->hw) || IS_QLA8031(vha->hw) ||
7ec0effd30bb4b Atul Deshmukh       2013-08-27  1405  		    IS_QLA8044(ha))
8a659571eccfde Andrew Vasquez      2009-02-08  1406  			qla81xx_idc_event(vha, mb[0], mb[1]);
3a03eb797ce76a Andrew Vasquez      2009-01-05  1407  		break;
7d613ac6acec8c Santosh Vernekar    2012-08-22  1408  
7d613ac6acec8c Santosh Vernekar    2012-08-22  1409  	case MBA_IDC_AEN:
d52cd7747d905f Quinn Tran          2019-09-12  1410  		if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
ff3a920efcdbfa Arun Easi           2020-03-27  1411  			qla27xx_handle_8200_aen(vha, mb);
d52cd7747d905f Quinn Tran          2019-09-12  1412  		} else if (IS_QLA83XX(ha)) {
7d613ac6acec8c Santosh Vernekar    2012-08-22  1413  			mb[4] = RD_REG_WORD(&reg24->mailbox4);
7d613ac6acec8c Santosh Vernekar    2012-08-22  1414  			mb[5] = RD_REG_WORD(&reg24->mailbox5);
7d613ac6acec8c Santosh Vernekar    2012-08-22  1415  			mb[6] = RD_REG_WORD(&reg24->mailbox6);
7d613ac6acec8c Santosh Vernekar    2012-08-22  1416  			mb[7] = RD_REG_WORD(&reg24->mailbox7);
7d613ac6acec8c Santosh Vernekar    2012-08-22  1417  			qla83xx_handle_8200_aen(vha, mb);
d52cd7747d905f Quinn Tran          2019-09-12  1418  		} else {
d52cd7747d905f Quinn Tran          2019-09-12  1419  			ql_dbg(ql_dbg_async, vha, 0x5052,
d52cd7747d905f Quinn Tran          2019-09-12  1420  			    "skip Heartbeat processing mb0-3=[0x%04x] [0x%04x] [0x%04x] [0x%04x]\n",
d52cd7747d905f Quinn Tran          2019-09-12  1421  			    mb[0], mb[1], mb[2], mb[3]);
d52cd7747d905f Quinn Tran          2019-09-12  1422  		}
7d613ac6acec8c Santosh Vernekar    2012-08-22  1423  		break;
7d613ac6acec8c Santosh Vernekar    2012-08-22  1424  
b5a340dd858b5b Joe Carnuccio       2014-09-25  1425  	case MBA_DPORT_DIAGNOSTICS:
b5a340dd858b5b Joe Carnuccio       2014-09-25  1426  		ql_dbg(ql_dbg_async, vha, 0x5052,
425215647fc53b Joe Carnuccio       2019-12-17  1427  		    "D-Port Diagnostics: %04x %04x %04x %04x\n",
425215647fc53b Joe Carnuccio       2019-12-17  1428  		    mb[0], mb[1], mb[2], mb[3]);
e6ad2b79b82f41 Joe Carnuccio       2020-02-12  1429  		memcpy(vha->dport_data, mb, sizeof(vha->dport_data));
425215647fc53b Joe Carnuccio       2019-12-17  1430  		if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
425215647fc53b Joe Carnuccio       2019-12-17  1431  			static char *results[] = {
425215647fc53b Joe Carnuccio       2019-12-17  1432  			    "start", "done(pass)", "done(error)", "undefined" };
425215647fc53b Joe Carnuccio       2019-12-17  1433  			static char *types[] = {
425215647fc53b Joe Carnuccio       2019-12-17  1434  			    "none", "dynamic", "static", "other" };
425215647fc53b Joe Carnuccio       2019-12-17  1435  			uint result = mb[1] >> 0 & 0x3;
425215647fc53b Joe Carnuccio       2019-12-17  1436  			uint type = mb[1] >> 6 & 0x3;
425215647fc53b Joe Carnuccio       2019-12-17  1437  			uint sw = mb[1] >> 15 & 0x1;
425215647fc53b Joe Carnuccio       2019-12-17  1438  			ql_dbg(ql_dbg_async, vha, 0x5052,
425215647fc53b Joe Carnuccio       2019-12-17  1439  			    "D-Port Diagnostics: result=%s type=%s [sw=%u]\n",
425215647fc53b Joe Carnuccio       2019-12-17  1440  			    results[result], types[type], sw);
425215647fc53b Joe Carnuccio       2019-12-17  1441  			if (result == 2) {
425215647fc53b Joe Carnuccio       2019-12-17  1442  				static char *reasons[] = {
425215647fc53b Joe Carnuccio       2019-12-17  1443  				    "reserved", "unexpected reject",
425215647fc53b Joe Carnuccio       2019-12-17  1444  				    "unexpected phase", "retry exceeded",
425215647fc53b Joe Carnuccio       2019-12-17  1445  				    "timed out", "not supported",
425215647fc53b Joe Carnuccio       2019-12-17  1446  				    "user stopped" };
425215647fc53b Joe Carnuccio       2019-12-17  1447  				uint reason = mb[2] >> 0 & 0xf;
425215647fc53b Joe Carnuccio       2019-12-17  1448  				uint phase = mb[2] >> 12 & 0xf;
425215647fc53b Joe Carnuccio       2019-12-17  1449  				ql_dbg(ql_dbg_async, vha, 0x5052,
425215647fc53b Joe Carnuccio       2019-12-17  1450  				    "D-Port Diagnostics: reason=%s phase=%u \n",
425215647fc53b Joe Carnuccio       2019-12-17  1451  				    reason < 7 ? reasons[reason] : "other",
425215647fc53b Joe Carnuccio       2019-12-17  1452  				    phase >> 1);
425215647fc53b Joe Carnuccio       2019-12-17  1453  			}
425215647fc53b Joe Carnuccio       2019-12-17  1454  		}
b5a340dd858b5b Joe Carnuccio       2014-09-25  1455  		break;
b5a340dd858b5b Joe Carnuccio       2014-09-25  1456  
a29b3dd7aa14fa Joe Carnuccio       2016-07-06  1457  	case MBA_TEMPERATURE_ALERT:
a29b3dd7aa14fa Joe Carnuccio       2016-07-06  1458  		ql_dbg(ql_dbg_async, vha, 0x505e,
a29b3dd7aa14fa Joe Carnuccio       2016-07-06  1459  		    "TEMPERATURE ALERT: %04x %04x %04x\n", mb[1], mb[2], mb[3]);
a29b3dd7aa14fa Joe Carnuccio       2016-07-06  1460  		if (mb[1] == 0x12)
a29b3dd7aa14fa Joe Carnuccio       2016-07-06  1461  			schedule_work(&ha->board_disable);
a29b3dd7aa14fa Joe Carnuccio       2016-07-06  1462  		break;
a29b3dd7aa14fa Joe Carnuccio       2016-07-06  1463  
92d4408e34667f Sawan Chandak       2017-08-23  1464  	case MBA_TRANS_INSERT:
92d4408e34667f Sawan Chandak       2017-08-23  1465  		ql_dbg(ql_dbg_async, vha, 0x5091,
92d4408e34667f Sawan Chandak       2017-08-23  1466  		    "Transceiver Insertion: %04x\n", mb[1]);
b0f18eee6fc1ee Andrew Vasquez      2020-02-26  1467  		set_bit(DETECT_SFP_CHANGE, &vha->dpc_flags);
b0f18eee6fc1ee Andrew Vasquez      2020-02-26  1468  		break;
b0f18eee6fc1ee Andrew Vasquez      2020-02-26  1469  
b0f18eee6fc1ee Andrew Vasquez      2020-02-26  1470  	case MBA_TRANS_REMOVE:
b0f18eee6fc1ee Andrew Vasquez      2020-02-26  1471  		ql_dbg(ql_dbg_async, vha, 0x5091, "Transceiver Removal\n");
92d4408e34667f Sawan Chandak       2017-08-23  1472  		break;
92d4408e34667f Sawan Chandak       2017-08-23  1473  
6246b8a1d26c7c Giridhar Malavali   2012-02-09  1474  	default:
6246b8a1d26c7c Giridhar Malavali   2012-02-09  1475  		ql_dbg(ql_dbg_async, vha, 0x5057,
6246b8a1d26c7c Giridhar Malavali   2012-02-09  1476  		    "Unknown AEN:%04x %04x %04x %04x\n",
6246b8a1d26c7c Giridhar Malavali   2012-02-09  1477  		    mb[0], mb[1], mb[2], mb[3]);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1478  	}
2c3dfe3f6ad8da Seokmann Ju         2007-07-05  1479  
2d70c103fd2a06 Nicholas Bellinger  2012-05-15  1480  	qlt_async_event(mb[0], vha, mb);
2d70c103fd2a06 Nicholas Bellinger  2012-05-15  1481  
e315cd28b9ef0d Anirban Chakraborty 2008-11-06  1482  	if (!vha->vp_idx && ha->num_vhosts)
73208dfd7ab19f Anirban Chakraborty 2008-12-09  1483  		qla2x00_alert_all_vps(rsp, mb);
^1da177e4c3f41 Linus Torvalds      2005-04-16  1484  }
^1da177e4c3f41 Linus Torvalds      2005-04-16  1485  

:::::: The code at line 903 was first introduced by commit
:::::: a82c307e69c465e4d80cc15fde3c00f5b95832d6 scsi: qla2xxx: add more FW debug information

:::::: TO: Quinn Tran <qutran@marvell.com>
:::::: CC: Martin K. Petersen <martin.petersen@oracle.com>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 97cabd7e0014..3a5f6f27587e 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -26,7 +26,8 @@  qla2x00_sysfs_read_fw_dump(struct file *filp, struct kobject *kobj,
 	struct qla_hw_data *ha = vha->hw;
 	int rval = 0;
 
-	if (!(ha->fw_dump_reading || ha->mctp_dump_reading))
+	if (!(ha->fw_dump_reading || ha->mctp_dump_reading ||
+	      ha->mpi_fw_dump_reading))
 		return 0;
 
 	mutex_lock(&ha->optrom_mutex);
@@ -42,6 +43,10 @@  qla2x00_sysfs_read_fw_dump(struct file *filp, struct kobject *kobj,
 	} else if (ha->mctp_dumped && ha->mctp_dump_reading) {
 		rval = memory_read_from_buffer(buf, count, &off, ha->mctp_dump,
 		    MCTP_DUMP_SIZE);
+	} else if (ha->mpi_fw_dumped && ha->mpi_fw_dump_reading) {
+		rval = memory_read_from_buffer(buf, count, &off,
+					       ha->mpi_fw_dump,
+					       ha->mpi_fw_dump_len);
 	} else if (ha->fw_dump_reading) {
 		rval = memory_read_from_buffer(buf, count, &off, ha->fw_dump,
 					ha->fw_dump_len);
@@ -103,7 +108,6 @@  qla2x00_sysfs_write_fw_dump(struct file *filp, struct kobject *kobj,
 			qla82xx_set_reset_owner(vha);
 			qla8044_idc_unlock(ha);
 		} else {
-			ha->fw_dump_mpi = 1;
 			qla2x00_system_error(vha);
 		}
 		break;
@@ -137,6 +141,22 @@  qla2x00_sysfs_write_fw_dump(struct file *filp, struct kobject *kobj,
 			    vha->host_no);
 		}
 		break;
+	case 8:
+		if (!ha->mpi_fw_dump_reading)
+			break;
+		ql_log(ql_log_info, vha, 0x70e7,
+		       "MPI firmware dump cleared on (%ld).\n", vha->host_no);
+		ha->mpi_fw_dump_reading = 0;
+		ha->mpi_fw_dumped = 0;
+		break;
+	case 9:
+		if (ha->mpi_fw_dumped && !ha->mpi_fw_dump_reading) {
+			ha->mpi_fw_dump_reading = 1;
+			ql_log(ql_log_info, vha, 0x70e8,
+			       "Raw MPI firmware dump ready for read on (%ld).\n",
+			       vha->host_no);
+		}
+		break;
 	}
 	return count;
 }
@@ -706,7 +726,8 @@  qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj,
 		scsi_unblock_requests(vha->host);
 		break;
 	case 0x2025d:
-		if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha))
+		if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) &&
+		    !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
 			return -EPERM;
 
 		ql_log(ql_log_info, vha, 0x706f,
@@ -724,6 +745,8 @@  qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj,
 			qla83xx_idc_audit(vha, IDC_AUDIT_TIMESTAMP);
 			qla83xx_idc_unlock(vha, 0);
 			break;
+		} else if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
+			qla27xx_reset_mpi(vha);
 		} else {
 			/* Make sure FC side is not in reset */
 			WARN_ON_ONCE(qla2x00_wait_for_hba_online(vha) !=
@@ -737,6 +760,7 @@  qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj,
 			scsi_unblock_requests(vha->host);
 			break;
 		}
+		break;
 	case 0x2025e:
 		if (!IS_P3P_TYPE(ha) || vha != base_vha) {
 			ql_log(ql_log_info, vha, 0x7071,
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 47c7a56438b5..daa9e936887b 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -3223,6 +3223,7 @@  struct isp_operations {
 		uint32_t);
 
 	void (*fw_dump) (struct scsi_qla_host *, int);
+	void (*mpi_fw_dump)(struct scsi_qla_host *, int);
 
 	int (*beacon_on) (struct scsi_qla_host *);
 	int (*beacon_off) (struct scsi_qla_host *);
@@ -3748,6 +3749,11 @@  struct qlt_hw_data {
 
 #define LEAK_EXCHG_THRESH_HOLD_PERCENT 75	/* 75 percent */
 
+struct qla_hw_data_stat {
+	u32 num_fw_dump;
+	u32 num_mpi_reset;
+};
+
 /*
  * Qlogic host adapter specific data structure.
 */
@@ -4230,7 +4236,6 @@  struct qla_hw_data {
 	uint32_t	fw_dump_len;
 	u32		fw_dump_alloc_len;
 	bool		fw_dumped;
-	bool		fw_dump_mpi;
 	unsigned long	fw_dump_cap_flags;
 #define RISC_PAUSE_CMPL		0
 #define DMA_SHUTDOWN_CMPL	1
@@ -4241,6 +4246,10 @@  struct qla_hw_data {
 #define ISP_MBX_RDY		6
 #define ISP_SOFT_RESET_CMPL	7
 	int		fw_dump_reading;
+	void		*mpi_fw_dump;
+	u32		mpi_fw_dump_len;
+	int		mpi_fw_dump_reading:1;
+	int		mpi_fw_dumped:1;
 	int		prev_minidump_failed;
 	dma_addr_t	eft_dma;
 	void		*eft;
@@ -4454,6 +4463,8 @@  struct qla_hw_data {
 	uint16_t last_zio_threshold;
 
 #define DEFAULT_ZIO_THRESHOLD 5
+
+	struct qla_hw_data_stat stat;
 };
 
 struct active_regions {
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 1b93f5b4d77d..b20c5fa122fb 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -173,6 +173,7 @@  extern int ql2xenablemsix;
 extern int qla2xuseresexchforels;
 extern int ql2xexlogins;
 extern int ql2xdifbundlinginternalbuffers;
+extern int ql2xfulldump_on_mpifail;
 
 extern int qla2x00_loop_reset(scsi_qla_host_t *);
 extern void qla2x00_abort_all_cmds(scsi_qla_host_t *, int);
@@ -645,6 +646,7 @@  extern void qla82xx_fw_dump(scsi_qla_host_t *, int);
 extern void qla8044_fw_dump(scsi_qla_host_t *, int);
 
 extern void qla27xx_fwdump(scsi_qla_host_t *, int);
+extern void qla27xx_mpi_fwdump(scsi_qla_host_t *, int);
 extern ulong qla27xx_fwdt_calculate_dump_size(struct scsi_qla_host *, void *);
 extern int qla27xx_fwdt_template_valid(void *);
 extern ulong qla27xx_fwdt_template_size(void *);
@@ -933,5 +935,6 @@  extern void qla24xx_process_purex_list(struct purex_list *);
 
 /* nvme.c */
 void qla_nvme_unregister_remote_port(struct fc_port *fcport);
+void qla27xx_reset_mpi(scsi_qla_host_t *vha);
 void qla_handle_els_plogi_done(scsi_qla_host_t *vha, struct event_arg *ea);
 #endif /* _QLA_GBL_H */
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 5b2deaa730bf..3e9b7a079554 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -3339,6 +3339,8 @@  qla2x00_alloc_fw_dump(scsi_qla_host_t *vha)
 				    dump_size / 1024);
 
 				if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
+					ha->mpi_fw_dump = (char *)fw_dump +
+						ha->fwdt[1].dump_size;
 					mutex_unlock(&ha->optrom_mutex);
 					return;
 				}
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 8d7a905f6247..1cd9d3773cd3 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -757,6 +757,39 @@  qla2x00_find_fcport_by_nportid(scsi_qla_host_t *vha, port_id_t *id,
 	return NULL;
 }
 
+/* Shall be called only on supported adapters. */
+static void
+qla27xx_handle_8200_aen(scsi_qla_host_t *vha, uint16_t *mb)
+{
+	struct qla_hw_data *ha = vha->hw;
+	bool reset_isp_needed = 0;
+
+	ql_log(ql_log_warn, vha, 0x02f0,
+	       "MPI Heartbeat stop. MPI reset is%s needed. "
+	       "MB0[%xh] MB1[%xh] MB2[%xh] MB3[%xh]\n",
+	       mb[0] & BIT_8 ? "" : " not",
+	       mb[0], mb[1], mb[2], mb[3]);
+
+	if ((mb[1] & BIT_8) == 0)
+		return;
+
+	ql_log(ql_log_warn, vha, 0x02f1,
+	       "MPI Heartbeat stop. FW dump needed\n");
+
+	if (ql2xfulldump_on_mpifail) {
+		ha->isp_ops->fw_dump(vha, 1);
+		reset_isp_needed = 1;
+	}
+
+	ha->isp_ops->mpi_fw_dump(vha, 1);
+
+	if (reset_isp_needed) {
+		vha->hw->flags.fw_init_done = 0;
+		set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
+		qla2xxx_wake_dpc(vha);
+	}
+}
+
 /**
  * qla2x00_async_event() - Process aynchronous events.
  * @vha: SCSI driver HA context
@@ -872,9 +905,9 @@  qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
 			    "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n ",
 			    mb[1], mb[2], mb[3]);
 
-		ha->fw_dump_mpi =
-		    (IS_QLA27XX(ha) || IS_QLA28XX(ha)) &&
-		    RD_REG_WORD(&reg24->mailbox7) & BIT_8;
+			if ((IS_QLA27XX(ha) || IS_QLA28XX(ha)) &&
+			   RD_REG_WORD(&reg24->mailbox7) & BIT_8)
+				ha->isp_ops->mpi_fw_dump(vha, 1);
 		ha->isp_ops->fw_dump(vha, 1);
 		ha->flags.fw_init_done = 0;
 		QLA_FW_STOPPED(ha);
@@ -1375,20 +1408,7 @@  qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
 
 	case MBA_IDC_AEN:
 		if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
-			ha->flags.fw_init_done = 0;
-			ql_log(ql_log_warn, vha, 0xffff,
-			    "MPI Heartbeat stop. Chip reset needed. MB0[%xh] MB1[%xh] MB2[%xh] MB3[%xh]\n",
-			    mb[0], mb[1], mb[2], mb[3]);
-
-			if ((mb[1] & BIT_8) ||
-			    (mb[2] & BIT_8)) {
-				ql_log(ql_log_warn, vha, 0xd013,
-				    "MPI Heartbeat stop. FW dump needed\n");
-				ha->fw_dump_mpi = 1;
-				ha->isp_ops->fw_dump(vha, 1);
-			}
-			set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
-			qla2xxx_wake_dpc(vha);
+			qla27xx_handle_8200_aen(vha, mb);
 		} else if (IS_QLA83XX(ha)) {
 			mb[4] = RD_REG_WORD(&reg24->mailbox4);
 			mb[5] = RD_REG_WORD(&reg24->mailbox5);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 3e65b8e9ed47..5ad320f81140 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -35,6 +35,11 @@  static int apidev_major;
  */
 struct kmem_cache *srb_cachep;
 
+int ql2xfulldump_on_mpifail;
+module_param(ql2xfulldump_on_mpifail, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(ql2xfulldump_on_mpifail,
+		 "Set this to take full dump on MPI hang.");
+
 /*
  * CT6 CTX allocation cache
  */
@@ -2518,6 +2523,7 @@  static struct isp_operations qla27xx_isp_ops = {
 	.read_nvram		= NULL,
 	.write_nvram		= NULL,
 	.fw_dump		= qla27xx_fwdump,
+	.mpi_fw_dump		= qla27xx_mpi_fwdump,
 	.beacon_on		= qla24xx_beacon_on,
 	.beacon_off		= qla24xx_beacon_off,
 	.beacon_blink		= qla83xx_beacon_blink,
diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c
index 6aeb1c3fb7a8..342363862434 100644
--- a/drivers/scsi/qla2xxx/qla_tmpl.c
+++ b/drivers/scsi/qla2xxx/qla_tmpl.c
@@ -12,6 +12,33 @@ 
 #define IOBASE(vha)	IOBAR(ISPREG(vha))
 #define INVALID_ENTRY ((struct qla27xx_fwdt_entry *)0xffffffffffffffffUL)
 
+/* hardware_lock assumed held. */
+static void
+qla27xx_write_remote_reg(struct scsi_qla_host *vha,
+			 u32 addr, u32 data)
+{
+	char *reg = (char *)ISPREG(vha);
+
+	ql_dbg(ql_dbg_misc, vha, 0xd300,
+	       "%s: addr/data = %xh/%xh\n", __func__, addr, data);
+
+	WRT_REG_DWORD(reg + IOBASE(vha), 0x40);
+	WRT_REG_DWORD(reg + 0xc4, data);
+	WRT_REG_DWORD(reg + 0xc0, addr);
+}
+
+void
+qla27xx_reset_mpi(scsi_qla_host_t *vha)
+{
+	ql_dbg(ql_dbg_misc + ql_dbg_verbose, vha, 0xd301,
+	       "Entered %s.\n", __func__);
+
+	qla27xx_write_remote_reg(vha, 0x104050, 0x40004);
+	qla27xx_write_remote_reg(vha, 0x10405c, 0x4);
+
+	vha->hw->stat.num_mpi_reset++;
+}
+
 static inline void
 qla27xx_insert16(uint16_t value, void *buf, ulong *len)
 {
@@ -997,6 +1024,62 @@  qla27xx_fwdt_template_valid(void *p)
 	return true;
 }
 
+void
+qla27xx_mpi_fwdump(scsi_qla_host_t *vha, int hardware_locked)
+{
+	ulong flags = 0;
+	bool need_mpi_reset = 1;
+
+#ifndef __CHECKER__
+	if (!hardware_locked)
+		spin_lock_irqsave(&vha->hw->hardware_lock, flags);
+#endif
+	if (!vha->hw->mpi_fw_dump) {
+		ql_log(ql_log_warn, vha, 0x02f3, "-> mpi_fwdump no buffer\n");
+	} else if (vha->hw->mpi_fw_dumped) {
+		ql_log(ql_log_warn, vha, 0x02f4,
+		       "-> MPI firmware already dumped (%p) -- ignoring request\n",
+		       vha->hw->mpi_fw_dump);
+	} else {
+		struct fwdt *fwdt = &vha->hw->fwdt[1];
+		ulong len;
+		void *buf = vha->hw->mpi_fw_dump;
+
+		ql_log(ql_log_warn, vha, 0x02f5, "-> fwdt1 running...\n");
+		if (!fwdt->template) {
+			ql_log(ql_log_warn, vha, 0x02f6,
+			       "-> fwdt1 no template\n");
+			goto bailout;
+		}
+		len = qla27xx_execute_fwdt_template(vha, fwdt->template, buf);
+		if (len == 0) {
+			goto bailout;
+		} else if (len != fwdt->dump_size) {
+			ql_log(ql_log_warn, vha, 0x02f7,
+			       "-> fwdt1 fwdump residual=%+ld\n",
+			       fwdt->dump_size - len);
+		} else {
+			need_mpi_reset = 0;
+		}
+
+		vha->hw->mpi_fw_dump_len = len;
+		vha->hw->mpi_fw_dumped = 1;
+
+		ql_log(ql_log_warn, vha, 0x02f8,
+		       "-> MPI firmware dump saved to buffer (%lu/%p)\n",
+		       vha->host_no, vha->hw->mpi_fw_dump);
+		qla2x00_post_uevent_work(vha, QLA_UEVENT_CODE_FW_DUMP);
+	}
+
+bailout:
+	if (need_mpi_reset)
+		qla27xx_reset_mpi(vha);
+#ifndef __CHECKER__
+	if (!hardware_locked)
+		spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);
+#endif
+}
+
 void
 qla27xx_fwdump(scsi_qla_host_t *vha, int hardware_locked)
 {
@@ -1015,30 +1098,25 @@  qla27xx_fwdump(scsi_qla_host_t *vha, int hardware_locked)
 		    vha->hw->fw_dump);
 	} else {
 		struct fwdt *fwdt = vha->hw->fwdt;
-		uint j;
 		ulong len;
 		void *buf = vha->hw->fw_dump;
-		uint count = vha->hw->fw_dump_mpi ? 2 : 1;
-
-		for (j = 0; j < count; j++, fwdt++, buf += len) {
-			ql_log(ql_log_warn, vha, 0xd011,
-			    "-> fwdt%u running...\n", j);
-			if (!fwdt->template) {
-				ql_log(ql_log_warn, vha, 0xd012,
-				    "-> fwdt%u no template\n", j);
-				break;
-			}
-			len = qla27xx_execute_fwdt_template(vha,
-			    fwdt->template, buf);
-			if (len == 0) {
-				goto bailout;
-			} else if (len != fwdt->dump_size) {
-				ql_log(ql_log_warn, vha, 0xd013,
-				    "-> fwdt%u fwdump residual=%+ld\n",
-				    j, fwdt->dump_size - len);
-			}
+
+		ql_log(ql_log_warn, vha, 0xd011, "-> fwdt0 running...\n");
+		if (!fwdt->template) {
+			ql_log(ql_log_warn, vha, 0xd012,
+			       "-> fwdt0 no template\n");
+			goto bailout;
 		}
-		vha->hw->fw_dump_len = buf - (void *)vha->hw->fw_dump;
+		len = qla27xx_execute_fwdt_template(vha, fwdt->template, buf);
+		if (len == 0) {
+			goto bailout;
+		} else if (len != fwdt->dump_size) {
+			ql_log(ql_log_warn, vha, 0xd013,
+			       "-> fwdt0 fwdump residual=%+ld\n",
+				fwdt->dump_size - len);
+		}
+
+		vha->hw->fw_dump_len = len;
 		vha->hw->fw_dumped = 1;
 
 		ql_log(ql_log_warn, vha, 0xd015,
@@ -1048,7 +1126,6 @@  qla27xx_fwdump(scsi_qla_host_t *vha, int hardware_locked)
 	}
 
 bailout:
-	vha->hw->fw_dump_mpi = 0;
 #ifndef __CHECKER__
 	if (!hardware_locked)
 		spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);