forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/scsi/qla2xxx/qla_mbx.c
....@@ -1,14 +1,19 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * QLogic Fibre Channel HBA Driver
34 * Copyright (c) 2003-2014 QLogic Corporation
4
- *
5
- * See LICENSE.qla2xxx for copyright and licensing details.
65 */
76 #include "qla_def.h"
87 #include "qla_target.h"
98
109 #include <linux/delay.h>
1110 #include <linux/gfp.h>
11
+
12
+#ifdef CONFIG_PPC
13
+#define IS_PPCARCH true
14
+#else
15
+#define IS_PPCARCH false
16
+#endif
1217
1318 static struct mb_cmd_name {
1419 uint16_t cmd;
....@@ -59,7 +64,9 @@
5964 { MBC_IOCB_COMMAND_A64 },
6065 { MBC_GET_ADAPTER_LOOP_ID },
6166 { MBC_READ_SFP },
67
+ { MBC_SET_RNID_PARAMS },
6268 { MBC_GET_RNID_PARAMS },
69
+ { MBC_GET_SET_ZIO_THRESHOLD },
6370 };
6471
6572 static int is_rom_cmd(uint16_t cmd)
....@@ -105,7 +112,7 @@
105112 uint8_t io_lock_on;
106113 uint16_t command = 0;
107114 uint16_t *iptr;
108
- uint16_t __iomem *optr;
115
+ __le16 __iomem *optr;
109116 uint32_t cnt;
110117 uint32_t mboxes;
111118 unsigned long wait_time;
....@@ -116,10 +123,9 @@
116123
117124 ql_dbg(ql_dbg_mbx, vha, 0x1000, "Entered %s.\n", __func__);
118125
119
- if (ha->pdev->error_state > pci_channel_io_frozen) {
126
+ if (ha->pdev->error_state == pci_channel_io_perm_failure) {
120127 ql_log(ql_log_warn, vha, 0x1001,
121
- "error_state is greater than pci_channel_io_frozen, "
122
- "exiting.\n");
128
+ "PCI channel failed permanently, exiting.\n");
123129 return QLA_FUNCTION_TIMEOUT;
124130 }
125131
....@@ -161,7 +167,8 @@
161167 /* check if ISP abort is active and return cmd with timeout */
162168 if ((test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) ||
163169 test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) ||
164
- test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) &&
170
+ test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) ||
171
+ ha->flags.eeh_busy) &&
165172 !is_rom_cmd(mcp->mb[0])) {
166173 ql_log(ql_log_info, vha, 0x1005,
167174 "Cmd 0x%x aborted with timeout since ISP Abort is pending\n",
....@@ -189,7 +196,7 @@
189196 goto premature_exit;
190197 }
191198
192
- ha->flags.mbox_busy = 1;
199
+
193200 /* Save mailbox command for debug */
194201 ha->mcp = mcp;
195202
....@@ -198,20 +205,21 @@
198205
199206 spin_lock_irqsave(&ha->hardware_lock, flags);
200207
201
- if (ha->flags.purge_mbox || chip_reset != ha->chip_reset) {
208
+ if (ha->flags.purge_mbox || chip_reset != ha->chip_reset ||
209
+ ha->flags.mbox_busy) {
202210 rval = QLA_ABORTED;
203
- ha->flags.mbox_busy = 0;
204211 spin_unlock_irqrestore(&ha->hardware_lock, flags);
205212 goto premature_exit;
206213 }
214
+ ha->flags.mbox_busy = 1;
207215
208216 /* Load mailbox registers. */
209217 if (IS_P3P_TYPE(ha))
210
- optr = (uint16_t __iomem *)&reg->isp82.mailbox_in[0];
218
+ optr = &reg->isp82.mailbox_in[0];
211219 else if (IS_FWI2_CAPABLE(ha) && !(IS_P3P_TYPE(ha)))
212
- optr = (uint16_t __iomem *)&reg->isp24.mailbox0;
220
+ optr = &reg->isp24.mailbox0;
213221 else
214
- optr = (uint16_t __iomem *)MAILBOX_REG(ha, &reg->isp, 0);
222
+ optr = MAILBOX_REG(ha, &reg->isp, 0);
215223
216224 iptr = mcp->mb;
217225 command = mcp->mb[0];
....@@ -221,12 +229,13 @@
221229 "Mailbox registers (OUT):\n");
222230 for (cnt = 0; cnt < ha->mbx_count; cnt++) {
223231 if (IS_QLA2200(ha) && cnt == 8)
224
- optr =
225
- (uint16_t __iomem *)MAILBOX_REG(ha, &reg->isp, 8);
232
+ optr = MAILBOX_REG(ha, &reg->isp, 8);
226233 if (mboxes & BIT_0) {
227234 ql_dbg(ql_dbg_mbx, vha, 0x1112,
228235 "mbox[%d]<-0x%04x\n", cnt, *iptr);
229
- WRT_REG_WORD(optr, *iptr);
236
+ wrt_reg_word(optr, *iptr);
237
+ } else {
238
+ wrt_reg_word(optr, 0);
230239 }
231240
232241 mboxes >>= 1;
....@@ -251,27 +260,15 @@
251260 if ((!abort_active && io_lock_on) || IS_NOPOLLING_TYPE(ha)) {
252261 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
253262
254
- if (IS_P3P_TYPE(ha)) {
255
- if (RD_REG_DWORD(&reg->isp82.hint) &
256
- HINT_MBX_INT_PENDING) {
257
- spin_unlock_irqrestore(&ha->hardware_lock,
258
- flags);
259
- ha->flags.mbox_busy = 0;
260
- atomic_dec(&ha->num_pend_mbx_stage2);
261
- ql_dbg(ql_dbg_mbx, vha, 0x1010,
262
- "Pending mailbox timeout, exiting.\n");
263
- rval = QLA_FUNCTION_TIMEOUT;
264
- goto premature_exit;
265
- }
266
- WRT_REG_DWORD(&reg->isp82.hint, HINT_MBX_INT_PENDING);
267
- } else if (IS_FWI2_CAPABLE(ha))
268
- WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
263
+ if (IS_P3P_TYPE(ha))
264
+ wrt_reg_dword(&reg->isp82.hint, HINT_MBX_INT_PENDING);
265
+ else if (IS_FWI2_CAPABLE(ha))
266
+ wrt_reg_dword(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
269267 else
270
- WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT);
268
+ wrt_reg_word(&reg->isp.hccr, HCCR_SET_HOST_INT);
271269 spin_unlock_irqrestore(&ha->hardware_lock, flags);
272270
273271 wait_time = jiffies;
274
- atomic_inc(&ha->num_pend_mbx_stage3);
275272 if (!wait_for_completion_timeout(&ha->mbx_intr_comp,
276273 mcp->tov * HZ)) {
277274 ql_dbg(ql_dbg_mbx, vha, 0x117a,
....@@ -280,15 +277,24 @@
280277 clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
281278 spin_unlock_irqrestore(&ha->hardware_lock, flags);
282279
280
+ if (chip_reset != ha->chip_reset) {
281
+ spin_lock_irqsave(&ha->hardware_lock, flags);
282
+ ha->flags.mbox_busy = 0;
283
+ spin_unlock_irqrestore(&ha->hardware_lock,
284
+ flags);
285
+ atomic_dec(&ha->num_pend_mbx_stage2);
286
+ rval = QLA_ABORTED;
287
+ goto premature_exit;
288
+ }
283289 } else if (ha->flags.purge_mbox ||
284290 chip_reset != ha->chip_reset) {
291
+ spin_lock_irqsave(&ha->hardware_lock, flags);
285292 ha->flags.mbox_busy = 0;
293
+ spin_unlock_irqrestore(&ha->hardware_lock, flags);
286294 atomic_dec(&ha->num_pend_mbx_stage2);
287
- atomic_dec(&ha->num_pend_mbx_stage3);
288295 rval = QLA_ABORTED;
289296 goto premature_exit;
290297 }
291
- atomic_dec(&ha->num_pend_mbx_stage3);
292298
293299 if (time_after(jiffies, wait_time + 5 * HZ))
294300 ql_log(ql_log_warn, vha, 0x1015, "cmd=0x%x, waited %d msecs\n",
....@@ -298,29 +304,32 @@
298304 "Cmd=%x Polling Mode.\n", command);
299305
300306 if (IS_P3P_TYPE(ha)) {
301
- if (RD_REG_DWORD(&reg->isp82.hint) &
307
+ if (rd_reg_dword(&reg->isp82.hint) &
302308 HINT_MBX_INT_PENDING) {
309
+ ha->flags.mbox_busy = 0;
303310 spin_unlock_irqrestore(&ha->hardware_lock,
304311 flags);
305
- ha->flags.mbox_busy = 0;
306312 atomic_dec(&ha->num_pend_mbx_stage2);
307313 ql_dbg(ql_dbg_mbx, vha, 0x1012,
308314 "Pending mailbox timeout, exiting.\n");
309315 rval = QLA_FUNCTION_TIMEOUT;
310316 goto premature_exit;
311317 }
312
- WRT_REG_DWORD(&reg->isp82.hint, HINT_MBX_INT_PENDING);
318
+ wrt_reg_dword(&reg->isp82.hint, HINT_MBX_INT_PENDING);
313319 } else if (IS_FWI2_CAPABLE(ha))
314
- WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
320
+ wrt_reg_dword(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
315321 else
316
- WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT);
322
+ wrt_reg_word(&reg->isp.hccr, HCCR_SET_HOST_INT);
317323 spin_unlock_irqrestore(&ha->hardware_lock, flags);
318324
319325 wait_time = jiffies + mcp->tov * HZ; /* wait at most tov secs */
320326 while (!ha->flags.mbox_int) {
321327 if (ha->flags.purge_mbox ||
322328 chip_reset != ha->chip_reset) {
329
+ spin_lock_irqsave(&ha->hardware_lock, flags);
323330 ha->flags.mbox_busy = 0;
331
+ spin_unlock_irqrestore(&ha->hardware_lock,
332
+ flags);
324333 atomic_dec(&ha->num_pend_mbx_stage2);
325334 rval = QLA_ABORTED;
326335 goto premature_exit;
....@@ -355,7 +364,10 @@
355364 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
356365
357366 if (IS_P3P_TYPE(ha) && ha->flags.isp82xx_fw_hung) {
367
+ spin_lock_irqsave(&ha->hardware_lock, flags);
358368 ha->flags.mbox_busy = 0;
369
+ spin_unlock_irqrestore(&ha->hardware_lock, flags);
370
+
359371 /* Setting Link-Down error */
360372 mcp->mb[0] = MBS_LINK_DOWN_ERROR;
361373 ha->mcp = NULL;
....@@ -365,8 +377,12 @@
365377 goto premature_exit;
366378 }
367379
368
- if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE)
380
+ if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE) {
381
+ ql_dbg(ql_dbg_mbx, vha, 0x11ff,
382
+ "mb_out[0] = %#x <> %#x\n", ha->mailbox_out[0],
383
+ MBS_COMMAND_COMPLETE);
369384 rval = QLA_FUNCTION_FAILED;
385
+ }
370386
371387 /* Load return mailbox registers. */
372388 iptr2 = mcp->mb;
....@@ -393,14 +409,14 @@
393409 uint16_t w;
394410
395411 if (IS_FWI2_CAPABLE(ha)) {
396
- mb[0] = RD_REG_WORD(&reg->isp24.mailbox0);
397
- mb[1] = RD_REG_WORD(&reg->isp24.mailbox1);
398
- mb[2] = RD_REG_WORD(&reg->isp24.mailbox2);
399
- mb[3] = RD_REG_WORD(&reg->isp24.mailbox3);
400
- mb[7] = RD_REG_WORD(&reg->isp24.mailbox7);
401
- ictrl = RD_REG_DWORD(&reg->isp24.ictrl);
402
- host_status = RD_REG_DWORD(&reg->isp24.host_status);
403
- hccr = RD_REG_DWORD(&reg->isp24.hccr);
412
+ mb[0] = rd_reg_word(&reg->isp24.mailbox0);
413
+ mb[1] = rd_reg_word(&reg->isp24.mailbox1);
414
+ mb[2] = rd_reg_word(&reg->isp24.mailbox2);
415
+ mb[3] = rd_reg_word(&reg->isp24.mailbox3);
416
+ mb[7] = rd_reg_word(&reg->isp24.mailbox7);
417
+ ictrl = rd_reg_dword(&reg->isp24.ictrl);
418
+ host_status = rd_reg_dword(&reg->isp24.host_status);
419
+ hccr = rd_reg_dword(&reg->isp24.hccr);
404420
405421 ql_log(ql_log_warn, vha, 0xd04c,
406422 "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx "
....@@ -410,7 +426,7 @@
410426
411427 } else {
412428 mb[0] = RD_MAILBOX_REG(ha, &reg->isp, 0);
413
- ictrl = RD_REG_WORD(&reg->isp.ictrl);
429
+ ictrl = rd_reg_word(&reg->isp.ictrl);
414430 ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1119,
415431 "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx "
416432 "mb[0]=0x%x\n", command, ictrl, jiffies, mb[0]);
....@@ -428,7 +444,10 @@
428444 * then only PCI ERR flag would be set.
429445 * we will do premature exit for above case.
430446 */
447
+ spin_lock_irqsave(&ha->hardware_lock, flags);
431448 ha->flags.mbox_busy = 0;
449
+ spin_unlock_irqrestore(&ha->hardware_lock,
450
+ flags);
432451 rval = QLA_FUNCTION_TIMEOUT;
433452 goto premature_exit;
434453 }
....@@ -439,12 +458,13 @@
439458 * a dump
440459 */
441460 if (mcp->mb[0] != MBC_GEN_SYSTEM_ERROR)
442
- ha->isp_ops->fw_dump(vha, 0);
461
+ qla2xxx_dump_fw(vha);
443462 rval = QLA_FUNCTION_TIMEOUT;
444463 }
445464 }
446
-
465
+ spin_lock_irqsave(&ha->hardware_lock, flags);
447466 ha->flags.mbox_busy = 0;
467
+ spin_unlock_irqrestore(&ha->hardware_lock, flags);
448468
449469 /* Clean up */
450470 ha->mcp = NULL;
....@@ -534,9 +554,9 @@
534554 mcp->mb[0]);
535555 } else if (rval) {
536556 if (ql2xextended_error_logging & (ql_dbg_disc|ql_dbg_mbx)) {
537
- pr_warn("%s [%s]-%04x:%ld: **** Failed", QL_MSGHDR,
557
+ pr_warn("%s [%s]-%04x:%ld: **** Failed=%x", QL_MSGHDR,
538558 dev_name(&ha->pdev->dev), 0x1020+0x800,
539
- vha->host_no);
559
+ vha->host_no, rval);
540560 mboxes = mcp->in_mb;
541561 cnt = 4;
542562 for (i = 0; i < ha->mbx_count && cnt; i++, mboxes >>= 1)
....@@ -549,15 +569,15 @@
549569 if (IS_FWI2_CAPABLE(ha) && !(IS_P3P_TYPE(ha))) {
550570 ql_dbg(ql_dbg_mbx, vha, 0x1198,
551571 "host_status=%#x intr_ctrl=%#x intr_status=%#x\n",
552
- RD_REG_DWORD(&reg->isp24.host_status),
553
- RD_REG_DWORD(&reg->isp24.ictrl),
554
- RD_REG_DWORD(&reg->isp24.istatus));
572
+ rd_reg_dword(&reg->isp24.host_status),
573
+ rd_reg_dword(&reg->isp24.ictrl),
574
+ rd_reg_dword(&reg->isp24.istatus));
555575 } else {
556576 ql_dbg(ql_dbg_mbx, vha, 0x1206,
557577 "ctrl_status=%#x ictrl=%#x istatus=%#x\n",
558
- RD_REG_WORD(&reg->isp.ctrl_status),
559
- RD_REG_WORD(&reg->isp.ictrl),
560
- RD_REG_WORD(&reg->isp.istatus));
578
+ rd_reg_word(&reg->isp.ctrl_status),
579
+ rd_reg_word(&reg->isp.ictrl),
580
+ rd_reg_word(&reg->isp.istatus));
561581 }
562582 } else {
563583 ql_dbg(ql_dbg_mbx, base_vha, 0x1021, "Done %s.\n", __func__);
....@@ -601,14 +621,15 @@
601621 mcp->out_mb |= MBX_4;
602622 }
603623
604
- mcp->in_mb = MBX_0;
624
+ mcp->in_mb = MBX_1|MBX_0;
605625 mcp->tov = MBX_TOV_SECONDS;
606626 mcp->flags = 0;
607627 rval = qla2x00_mailbox_command(vha, mcp);
608628
609629 if (rval != QLA_SUCCESS) {
610630 ql_dbg(ql_dbg_mbx, vha, 0x1023,
611
- "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
631
+ "Failed=%x mb[0]=%x mb[1]=%x.\n",
632
+ rval, mcp->mb[0], mcp->mb[1]);
612633 } else {
613634 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1024,
614635 "Done %s.\n", __func__);
....@@ -617,30 +638,7 @@
617638 return rval;
618639 }
619640
620
-#define EXTENDED_BB_CREDITS BIT_0
621641 #define NVME_ENABLE_FLAG BIT_3
622
-static inline uint16_t qla25xx_set_sfp_lr_dist(struct qla_hw_data *ha)
623
-{
624
- uint16_t mb4 = BIT_0;
625
-
626
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha))
627
- mb4 |= ha->long_range_distance << LR_DIST_FW_POS;
628
-
629
- return mb4;
630
-}
631
-
632
-static inline uint16_t qla25xx_set_nvr_lr_dist(struct qla_hw_data *ha)
633
-{
634
- uint16_t mb4 = BIT_0;
635
-
636
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
637
- struct nvram_81xx *nv = ha->nvram;
638
-
639
- mb4 |= LR_DIST_FW_FIELD(nv->enhanced_features);
640
- }
641
-
642
- return mb4;
643
-}
644642
645643 /*
646644 * qla2x00_execute_fw
....@@ -664,10 +662,14 @@
664662 struct qla_hw_data *ha = vha->hw;
665663 mbx_cmd_t mc;
666664 mbx_cmd_t *mcp = &mc;
665
+ u8 semaphore = 0;
666
+#define EXE_FW_FORCE_SEMAPHORE BIT_7
667
+ u8 retry = 3;
667668
668669 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1025,
669670 "Entered %s.\n", __func__);
670671
672
+again:
671673 mcp->mb[0] = MBC_EXECUTE_FIRMWARE;
672674 mcp->out_mb = MBX_0;
673675 mcp->in_mb = MBX_0;
....@@ -677,41 +679,33 @@
677679 mcp->mb[3] = 0;
678680 mcp->mb[4] = 0;
679681 mcp->mb[11] = 0;
680
- ha->flags.using_lr_setting = 0;
681
- if (IS_QLA25XX(ha) || IS_QLA81XX(ha) || IS_QLA83XX(ha) ||
682
- IS_QLA27XX(ha)) {
683
- if (ql2xautodetectsfp) {
684
- if (ha->flags.detected_lr_sfp) {
685
- mcp->mb[4] |=
686
- qla25xx_set_sfp_lr_dist(ha);
687
- ha->flags.using_lr_setting = 1;
688
- }
689
- } else {
690
- struct nvram_81xx *nv = ha->nvram;
691
- /* set LR distance if specified in nvram */
692
- if (nv->enhanced_features &
693
- NEF_LR_DIST_ENABLE) {
694
- mcp->mb[4] |=
695
- qla25xx_set_nvr_lr_dist(ha);
696
- ha->flags.using_lr_setting = 1;
697
- }
698
- }
682
+
683
+ /* Enable BPM? */
684
+ if (ha->flags.lr_detected) {
685
+ mcp->mb[4] = BIT_0;
686
+ if (IS_BPM_RANGE_CAPABLE(ha))
687
+ mcp->mb[4] |=
688
+ ha->lr_distance << LR_DIST_FW_POS;
699689 }
700690
701
- if (ql2xnvmeenable && IS_QLA27XX(ha))
691
+ if (ql2xnvmeenable && (IS_QLA27XX(ha) || IS_QLA28XX(ha)))
702692 mcp->mb[4] |= NVME_ENABLE_FLAG;
703693
704
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
694
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
705695 struct nvram_81xx *nv = ha->nvram;
706696 /* set minimum speed if specified in nvram */
707
- if (nv->min_link_speed >= 2 &&
708
- nv->min_link_speed <= 5) {
697
+ if (nv->min_supported_speed >= 2 &&
698
+ nv->min_supported_speed <= 5) {
709699 mcp->mb[4] |= BIT_4;
710
- mcp->mb[11] = nv->min_link_speed;
700
+ mcp->mb[11] |= nv->min_supported_speed & 0xF;
711701 mcp->out_mb |= MBX_11;
712702 mcp->in_mb |= BIT_5;
713
- vha->min_link_speed_feat = nv->min_link_speed;
703
+ vha->min_supported_speed =
704
+ nv->min_supported_speed;
714705 }
706
+
707
+ if (IS_PPCARCH)
708
+ mcp->mb[11] |= BIT_4;
715709 }
716710
717711 if (ha->flags.exlogins_enabled)
....@@ -719,6 +713,9 @@
719713
720714 if (ha->flags.exchoffld_enabled)
721715 mcp->mb[4] |= ENABLE_EXCHANGE_OFFLD;
716
+
717
+ if (semaphore)
718
+ mcp->mb[11] |= EXE_FW_FORCE_SEMAPHORE;
722719
723720 mcp->out_mb |= MBX_4 | MBX_3 | MBX_2 | MBX_1 | MBX_11;
724721 mcp->in_mb |= MBX_3 | MBX_2 | MBX_1;
....@@ -736,35 +733,49 @@
736733 rval = qla2x00_mailbox_command(vha, mcp);
737734
738735 if (rval != QLA_SUCCESS) {
736
+ if (IS_QLA28XX(ha) && rval == QLA_COMMAND_ERROR &&
737
+ mcp->mb[1] == 0x27 && retry) {
738
+ semaphore = 1;
739
+ retry--;
740
+ ql_dbg(ql_dbg_async, vha, 0x1026,
741
+ "Exe FW: force semaphore.\n");
742
+ goto again;
743
+ }
744
+
739745 ql_dbg(ql_dbg_mbx, vha, 0x1026,
740746 "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
741
- } else {
742
- if (IS_FWI2_CAPABLE(ha)) {
743
- ha->fw_ability_mask = mcp->mb[3] << 16 | mcp->mb[2];
744
- ql_dbg(ql_dbg_mbx, vha, 0x119a,
745
- "fw_ability_mask=%x.\n", ha->fw_ability_mask);
746
- ql_dbg(ql_dbg_mbx, vha, 0x1027,
747
- "exchanges=%x.\n", mcp->mb[1]);
748
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
749
- ha->max_speed_sup = mcp->mb[2] & BIT_0;
750
- ql_dbg(ql_dbg_mbx, vha, 0x119b,
751
- "Maximum speed supported=%s.\n",
752
- ha->max_speed_sup ? "32Gps" : "16Gps");
753
- if (vha->min_link_speed_feat) {
754
- ha->min_link_speed = mcp->mb[5];
755
- ql_dbg(ql_dbg_mbx, vha, 0x119c,
756
- "Minimum speed set=%s.\n",
757
- mcp->mb[5] == 5 ? "32Gps" :
758
- mcp->mb[5] == 4 ? "16Gps" :
759
- mcp->mb[5] == 3 ? "8Gps" :
760
- mcp->mb[5] == 2 ? "4Gps" :
761
- "unknown");
762
- }
763
- }
764
- }
765
- ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1028,
766
- "Done.\n");
747
+ return rval;
767748 }
749
+
750
+ if (!IS_FWI2_CAPABLE(ha))
751
+ goto done;
752
+
753
+ ha->fw_ability_mask = mcp->mb[3] << 16 | mcp->mb[2];
754
+ ql_dbg(ql_dbg_mbx, vha, 0x119a,
755
+ "fw_ability_mask=%x.\n", ha->fw_ability_mask);
756
+ ql_dbg(ql_dbg_mbx, vha, 0x1027, "exchanges=%x.\n", mcp->mb[1]);
757
+ if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
758
+ ha->max_supported_speed = mcp->mb[2] & (BIT_0|BIT_1);
759
+ ql_dbg(ql_dbg_mbx, vha, 0x119b, "max_supported_speed=%s.\n",
760
+ ha->max_supported_speed == 0 ? "16Gps" :
761
+ ha->max_supported_speed == 1 ? "32Gps" :
762
+ ha->max_supported_speed == 2 ? "64Gps" : "unknown");
763
+ if (vha->min_supported_speed) {
764
+ ha->min_supported_speed = mcp->mb[5] &
765
+ (BIT_0 | BIT_1 | BIT_2);
766
+ ql_dbg(ql_dbg_mbx, vha, 0x119c,
767
+ "min_supported_speed=%s.\n",
768
+ ha->min_supported_speed == 6 ? "64Gps" :
769
+ ha->min_supported_speed == 5 ? "32Gps" :
770
+ ha->min_supported_speed == 4 ? "16Gps" :
771
+ ha->min_supported_speed == 3 ? "8Gps" :
772
+ ha->min_supported_speed == 2 ? "4Gps" : "unknown");
773
+ }
774
+ }
775
+
776
+done:
777
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1028,
778
+ "Done %s.\n", __func__);
768779
769780 return rval;
770781 }
....@@ -841,7 +852,7 @@
841852 * Context:
842853 * Kernel context.
843854 */
844
-#define CONFIG_XLOGINS_MEM 0x3
855
+#define CONFIG_XLOGINS_MEM 0x9
845856 int
846857 qla_set_exlogin_mem_cfg(scsi_qla_host_t *vha, dma_addr_t phys_addr)
847858 {
....@@ -868,8 +879,9 @@
868879 mcp->flags = 0;
869880 rval = qla2x00_mailbox_command(vha, mcp);
870881 if (rval != QLA_SUCCESS) {
871
- /*EMPTY*/
872
- ql_dbg(ql_dbg_mbx, vha, 0x111b, "Failed=%x.\n", rval);
882
+ ql_dbg(ql_dbg_mbx, vha, 0x111b,
883
+ "EXlogin Failed=%x. MB0=%x MB11=%x\n",
884
+ rval, mcp->mb[0], mcp->mb[11]);
873885 } else {
874886 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118c,
875887 "Done %s.\n", __func__);
....@@ -1021,10 +1033,10 @@
10211033 mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8;
10221034 if (IS_FWI2_CAPABLE(ha))
10231035 mcp->in_mb |= MBX_17|MBX_16|MBX_15;
1024
- if (IS_QLA27XX(ha))
1036
+ if (IS_QLA27XX(ha) || IS_QLA28XX(ha))
10251037 mcp->in_mb |=
10261038 MBX_25|MBX_24|MBX_23|MBX_22|MBX_21|MBX_20|MBX_19|MBX_18|
1027
- MBX_14|MBX_13|MBX_11|MBX_10|MBX_9|MBX_8;
1039
+ MBX_14|MBX_13|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7;
10281040
10291041 mcp->flags = 0;
10301042 mcp->tov = MBX_TOV_SECONDS;
....@@ -1077,15 +1089,31 @@
10771089 * FW supports nvme and driver load parameter requested nvme.
10781090 * BIT 26 of fw_attributes indicates NVMe support.
10791091 */
1080
- if ((ha->fw_attributes_h & 0x400) && ql2xnvmeenable) {
1092
+ if ((ha->fw_attributes_h &
1093
+ (FW_ATTR_H_NVME | FW_ATTR_H_NVME_UPDATED)) &&
1094
+ ql2xnvmeenable) {
1095
+ if (ha->fw_attributes_h & FW_ATTR_H_NVME_FBURST)
1096
+ vha->flags.nvme_first_burst = 1;
1097
+
10811098 vha->flags.nvme_enabled = 1;
10821099 ql_log(ql_log_info, vha, 0xd302,
10831100 "%s: FC-NVMe is Enabled (0x%x)\n",
10841101 __func__, ha->fw_attributes_h);
10851102 }
1103
+
1104
+ /* BIT_13 of Extended FW Attributes informs about NVMe2 support */
1105
+ if (ha->fw_attributes_ext[0] & FW_ATTR_EXT0_NVME2) {
1106
+ ql_log(ql_log_info, vha, 0xd302,
1107
+ "Firmware supports NVMe2 0x%x\n",
1108
+ ha->fw_attributes_ext[0]);
1109
+ vha->flags.nvme2_enabled = 1;
1110
+ }
10861111 }
10871112
1088
- if (IS_QLA27XX(ha)) {
1113
+ if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
1114
+ ha->serdes_version[0] = mcp->mb[7] & 0xff;
1115
+ ha->serdes_version[1] = mcp->mb[8] >> 8;
1116
+ ha->serdes_version[2] = mcp->mb[8] & 0xff;
10891117 ha->mpi_version[0] = mcp->mb[10] & 0xff;
10901118 ha->mpi_version[1] = mcp->mb[11] >> 8;
10911119 ha->mpi_version[2] = mcp->mb[11] & 0xff;
....@@ -1096,6 +1124,31 @@
10961124 ha->fw_shared_ram_end = (mcp->mb[21] << 16) | mcp->mb[20];
10971125 ha->fw_ddr_ram_start = (mcp->mb[23] << 16) | mcp->mb[22];
10981126 ha->fw_ddr_ram_end = (mcp->mb[25] << 16) | mcp->mb[24];
1127
+ if (IS_QLA28XX(ha)) {
1128
+ if (mcp->mb[16] & BIT_10)
1129
+ ha->flags.secure_fw = 1;
1130
+
1131
+ ql_log(ql_log_info, vha, 0xffff,
1132
+ "Secure Flash Update in FW: %s\n",
1133
+ (ha->flags.secure_fw) ? "Supported" :
1134
+ "Not Supported");
1135
+ }
1136
+
1137
+ if (ha->flags.scm_supported_a &&
1138
+ (ha->fw_attributes_ext[0] & FW_ATTR_EXT0_SCM_SUPPORTED)) {
1139
+ ha->flags.scm_supported_f = 1;
1140
+ ha->sf_init_cb->flags |= cpu_to_le16(BIT_13);
1141
+ }
1142
+ ql_log(ql_log_info, vha, 0x11a3, "SCM in FW: %s\n",
1143
+ (ha->flags.scm_supported_f) ? "Supported" :
1144
+ "Not Supported");
1145
+
1146
+ if (vha->flags.nvme2_enabled) {
1147
+ /* set BIT_15 of special feature control block for SLER */
1148
+ ha->sf_init_cb->flags |= cpu_to_le16(BIT_15);
1149
+ /* set BIT_14 of special feature control block for PI CTRL*/
1150
+ ha->sf_init_cb->flags |= cpu_to_le16(BIT_14);
1151
+ }
10991152 }
11001153
11011154 failed:
....@@ -1358,17 +1411,20 @@
13581411 mbx_cmd_t mc;
13591412 mbx_cmd_t *mcp = &mc;
13601413
1414
+ if (!vha->hw->flags.fw_started)
1415
+ return QLA_INVALID_COMMAND;
1416
+
13611417 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1038,
13621418 "Entered %s.\n", __func__);
13631419
13641420 mcp->mb[0] = MBC_IOCB_COMMAND_A64;
13651421 mcp->mb[1] = 0;
1366
- mcp->mb[2] = MSW(phys_addr);
1367
- mcp->mb[3] = LSW(phys_addr);
1422
+ mcp->mb[2] = MSW(LSD(phys_addr));
1423
+ mcp->mb[3] = LSW(LSD(phys_addr));
13681424 mcp->mb[6] = MSW(MSD(phys_addr));
13691425 mcp->mb[7] = LSW(MSD(phys_addr));
13701426 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
1371
- mcp->in_mb = MBX_2|MBX_0;
1427
+ mcp->in_mb = MBX_1|MBX_0;
13721428 mcp->tov = tov;
13731429 mcp->flags = 0;
13741430 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -1377,13 +1433,14 @@
13771433 /*EMPTY*/
13781434 ql_dbg(ql_dbg_mbx, vha, 0x1039, "Failed=%x.\n", rval);
13791435 } else {
1380
- sts_entry_t *sts_entry = (sts_entry_t *) buffer;
1436
+ sts_entry_t *sts_entry = buffer;
13811437
13821438 /* Mask reserved bits. */
13831439 sts_entry->entry_status &=
13841440 IS_FWI2_CAPABLE(vha->hw) ? RF_MASK_24XX : RF_MASK;
13851441 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103a,
1386
- "Done %s.\n", __func__);
1442
+ "Done %s (status=%x).\n", __func__,
1443
+ sts_entry->entry_status);
13871444 }
13881445
13891446 return rval;
....@@ -1428,7 +1485,7 @@
14281485 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103b,
14291486 "Entered %s.\n", __func__);
14301487
1431
- if (vha->flags.qpairs_available && sp->qpair)
1488
+ if (sp->qpair)
14321489 req = sp->qpair->req;
14331490 else
14341491 req = vha->req;
....@@ -1476,17 +1533,12 @@
14761533 mbx_cmd_t mc;
14771534 mbx_cmd_t *mcp = &mc;
14781535 scsi_qla_host_t *vha;
1479
- struct req_que *req;
1480
- struct rsp_que *rsp;
14811536
1482
- l = l;
14831537 vha = fcport->vha;
14841538
14851539 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103e,
14861540 "Entered %s.\n", __func__);
14871541
1488
- req = vha->hw->req_q_map[0];
1489
- rsp = req->rsp;
14901542 mcp->mb[0] = MBC_ABORT_TARGET;
14911543 mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0;
14921544 if (HAS_EXTENDED_IDS(vha->hw)) {
....@@ -1509,7 +1561,7 @@
15091561 }
15101562
15111563 /* Issue marker IOCB. */
1512
- rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, 0,
1564
+ rval2 = qla2x00_marker(vha, vha->hw->base_qpair, fcport->loop_id, 0,
15131565 MK_SYNC_ID);
15141566 if (rval2 != QLA_SUCCESS) {
15151567 ql_dbg(ql_dbg_mbx, vha, 0x1040,
....@@ -1529,16 +1581,12 @@
15291581 mbx_cmd_t mc;
15301582 mbx_cmd_t *mcp = &mc;
15311583 scsi_qla_host_t *vha;
1532
- struct req_que *req;
1533
- struct rsp_que *rsp;
15341584
15351585 vha = fcport->vha;
15361586
15371587 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1042,
15381588 "Entered %s.\n", __func__);
15391589
1540
- req = vha->hw->req_q_map[0];
1541
- rsp = req->rsp;
15421590 mcp->mb[0] = MBC_LUN_RESET;
15431591 mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0;
15441592 if (HAS_EXTENDED_IDS(vha->hw))
....@@ -1558,7 +1606,7 @@
15581606 }
15591607
15601608 /* Issue marker IOCB. */
1561
- rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l,
1609
+ rval2 = qla2x00_marker(vha, vha->hw->base_qpair, fcport->loop_id, l,
15621610 MK_SYNC_ID_LUN);
15631611 if (rval2 != QLA_SUCCESS) {
15641612 ql_dbg(ql_dbg_mbx, vha, 0x1044,
....@@ -1610,8 +1658,9 @@
16101658 mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10;
16111659 if (IS_FWI2_CAPABLE(vha->hw))
16121660 mcp->in_mb |= MBX_19|MBX_18|MBX_17|MBX_16;
1613
- if (IS_QLA27XX(vha->hw))
1614
- mcp->in_mb |= MBX_15;
1661
+ if (IS_QLA27XX(vha->hw) || IS_QLA28XX(vha->hw))
1662
+ mcp->in_mb |= MBX_15|MBX_21|MBX_22|MBX_23;
1663
+
16151664 mcp->tov = MBX_TOV_SECONDS;
16161665 mcp->flags = 0;
16171666 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -1664,8 +1713,22 @@
16641713 }
16651714 }
16661715
1667
- if (IS_QLA27XX(vha->hw))
1716
+ if (IS_QLA27XX(vha->hw) || IS_QLA28XX(vha->hw)) {
16681717 vha->bbcr = mcp->mb[15];
1718
+ if (mcp->mb[7] & SCM_EDC_ACC_RECEIVED) {
1719
+ ql_log(ql_log_info, vha, 0x11a4,
1720
+ "SCM: EDC ELS completed, flags 0x%x\n",
1721
+ mcp->mb[21]);
1722
+ }
1723
+ if (mcp->mb[7] & SCM_RDF_ACC_RECEIVED) {
1724
+ vha->hw->flags.scm_enabled = 1;
1725
+ vha->scm_fabric_connection_flags |=
1726
+ SCM_FLAG_RDF_COMPLETED;
1727
+ ql_log(ql_log_info, vha, 0x11a5,
1728
+ "SCM: RDF ELS completed, flags 0x%x\n",
1729
+ mcp->mb[23]);
1730
+ }
1731
+ }
16691732 }
16701733
16711734 return rval;
....@@ -1778,9 +1841,20 @@
17781841 mcp->mb[14] = sizeof(*ha->ex_init_cb);
17791842 mcp->out_mb |= MBX_14|MBX_13|MBX_12|MBX_11|MBX_10;
17801843 }
1844
+
1845
+ if (ha->flags.scm_supported_f || vha->flags.nvme2_enabled) {
1846
+ mcp->mb[1] |= BIT_1;
1847
+ mcp->mb[16] = MSW(ha->sf_init_cb_dma);
1848
+ mcp->mb[17] = LSW(ha->sf_init_cb_dma);
1849
+ mcp->mb[18] = MSW(MSD(ha->sf_init_cb_dma));
1850
+ mcp->mb[19] = LSW(MSD(ha->sf_init_cb_dma));
1851
+ mcp->mb[15] = sizeof(*ha->sf_init_cb);
1852
+ mcp->out_mb |= MBX_19|MBX_18|MBX_17|MBX_16|MBX_15;
1853
+ }
1854
+
17811855 /* 1 and 2 should normally be captured. */
17821856 mcp->in_mb = MBX_2|MBX_1|MBX_0;
1783
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha))
1857
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
17841858 /* mb3 is additional info about the installed SFP. */
17851859 mcp->in_mb |= MBX_3;
17861860 mcp->buf_size = size;
....@@ -1791,10 +1865,20 @@
17911865 if (rval != QLA_SUCCESS) {
17921866 /*EMPTY*/
17931867 ql_dbg(ql_dbg_mbx, vha, 0x104d,
1794
- "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x,.\n",
1868
+ "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x.\n",
17951869 rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3]);
1870
+ if (ha->init_cb) {
1871
+ ql_dbg(ql_dbg_mbx, vha, 0x104d, "init_cb:\n");
1872
+ ql_dump_buffer(ql_dbg_init + ql_dbg_verbose, vha,
1873
+ 0x0104d, ha->init_cb, sizeof(*ha->init_cb));
1874
+ }
1875
+ if (ha->ex_init_cb && ha->ex_init_cb->ex_version) {
1876
+ ql_dbg(ql_dbg_mbx, vha, 0x104d, "ex_init_cb:\n");
1877
+ ql_dump_buffer(ql_dbg_init + ql_dbg_verbose, vha,
1878
+ 0x0104d, ha->ex_init_cb, sizeof(*ha->ex_init_cb));
1879
+ }
17961880 } else {
1797
- if (IS_QLA27XX(ha)) {
1881
+ if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
17981882 if (mcp->mb[2] == 6 || mcp->mb[3] == 2)
17991883 ql_dbg(ql_dbg_mbx, vha, 0x119d,
18001884 "Invalid SFP/Validation Failed\n");
....@@ -1884,7 +1968,7 @@
18841968 pd24 = (struct port_database_24xx *) pd;
18851969
18861970 /* Check for logged in state. */
1887
- if (fcport->fc4f_nvme) {
1971
+ if (NVME_TARGET(ha, fcport)) {
18881972 current_login_state = pd24->current_login_state >> 4;
18891973 last_login_state = pd24->last_login_state >> 4;
18901974 } else {
....@@ -1978,7 +2062,7 @@
19782062
19792063 /* Passback COS information. */
19802064 fcport->supported_classes = (pd->options & BIT_4) ?
1981
- FC_COS_CLASS2: FC_COS_CLASS3;
2065
+ FC_COS_CLASS2 : FC_COS_CLASS3;
19822066 }
19832067
19842068 gpd_error_out:
....@@ -1993,6 +2077,57 @@
19932077 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1053,
19942078 "Done %s.\n", __func__);
19952079 }
2080
+
2081
+ return rval;
2082
+}
2083
+
2084
+int
2085
+qla24xx_get_port_database(scsi_qla_host_t *vha, u16 nport_handle,
2086
+ struct port_database_24xx *pdb)
2087
+{
2088
+ mbx_cmd_t mc;
2089
+ mbx_cmd_t *mcp = &mc;
2090
+ dma_addr_t pdb_dma;
2091
+ int rval;
2092
+
2093
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1115,
2094
+ "Entered %s.\n", __func__);
2095
+
2096
+ memset(pdb, 0, sizeof(*pdb));
2097
+
2098
+ pdb_dma = dma_map_single(&vha->hw->pdev->dev, pdb,
2099
+ sizeof(*pdb), DMA_FROM_DEVICE);
2100
+ if (!pdb_dma) {
2101
+ ql_log(ql_log_warn, vha, 0x1116, "Failed to map dma buffer.\n");
2102
+ return QLA_MEMORY_ALLOC_FAILED;
2103
+ }
2104
+
2105
+ mcp->mb[0] = MBC_GET_PORT_DATABASE;
2106
+ mcp->mb[1] = nport_handle;
2107
+ mcp->mb[2] = MSW(LSD(pdb_dma));
2108
+ mcp->mb[3] = LSW(LSD(pdb_dma));
2109
+ mcp->mb[6] = MSW(MSD(pdb_dma));
2110
+ mcp->mb[7] = LSW(MSD(pdb_dma));
2111
+ mcp->mb[9] = 0;
2112
+ mcp->mb[10] = 0;
2113
+ mcp->out_mb = MBX_10|MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
2114
+ mcp->in_mb = MBX_1|MBX_0;
2115
+ mcp->buf_size = sizeof(*pdb);
2116
+ mcp->flags = MBX_DMA_IN;
2117
+ mcp->tov = vha->hw->login_timeout * 2;
2118
+ rval = qla2x00_mailbox_command(vha, mcp);
2119
+
2120
+ if (rval != QLA_SUCCESS) {
2121
+ ql_dbg(ql_dbg_mbx, vha, 0x111a,
2122
+ "Failed=%x mb[0]=%x mb[1]=%x.\n",
2123
+ rval, mcp->mb[0], mcp->mb[1]);
2124
+ } else {
2125
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111b,
2126
+ "Done %s.\n", __func__);
2127
+ }
2128
+
2129
+ dma_unmap_single(&vha->hw->pdev->dev, pdb_dma,
2130
+ sizeof(*pdb), DMA_FROM_DEVICE);
19962131
19972132 return rval;
19982133 }
....@@ -2048,7 +2183,7 @@
20482183 /*EMPTY*/
20492184 ql_dbg(ql_dbg_mbx, vha, 0x1055, "Failed=%x.\n", rval);
20502185 } else {
2051
- if (IS_QLA27XX(ha)) {
2186
+ if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
20522187 if (mcp->mb[2] == 6 || mcp->mb[3] == 2)
20532188 ql_dbg(ql_dbg_mbx, vha, 0x119e,
20542189 "Invalid SFP/Validation Failed\n");
....@@ -2202,7 +2337,7 @@
22022337 mbx_cmd_t mc;
22032338 mbx_cmd_t *mcp = &mc;
22042339
2205
- ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105a,
2340
+ ql_dbg(ql_dbg_disc, vha, 0x105a,
22062341 "Entered %s.\n", __func__);
22072342
22082343 if (IS_CNA_CAPABLE(vha->hw)) {
....@@ -2213,10 +2348,7 @@
22132348 mcp->out_mb = MBX_2|MBX_1|MBX_0;
22142349 } else if (IS_FWI2_CAPABLE(vha->hw)) {
22152350 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
2216
- if (N2N_TOPO(vha->hw))
2217
- mcp->mb[1] = BIT_4; /* re-init */
2218
- else
2219
- mcp->mb[1] = BIT_6; /* LIP */
2351
+ mcp->mb[1] = BIT_4;
22202352 mcp->mb[2] = 0;
22212353 mcp->mb[3] = vha->hw->loop_reset_delay;
22222354 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
....@@ -2339,7 +2471,7 @@
23392471
23402472 lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
23412473 lg->entry_count = 1;
2342
- lg->handle = MAKE_HANDLE(req->id, lg->handle);
2474
+ lg->handle = make_handle(req->id, lg->handle);
23432475 lg->nport_handle = cpu_to_le16(loop_id);
23442476 lg->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI);
23452477 if (opt & BIT_0)
....@@ -2609,7 +2741,7 @@
26092741 req = vha->req;
26102742 lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
26112743 lg->entry_count = 1;
2612
- lg->handle = MAKE_HANDLE(req->id, lg->handle);
2744
+ lg->handle = make_handle(req->id, lg->handle);
26132745 lg->nport_handle = cpu_to_le16(loop_id);
26142746 lg->control_flags =
26152747 cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO|
....@@ -2726,7 +2858,7 @@
27262858 "Entered %s.\n", __func__);
27272859
27282860 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
2729
- mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_3 : 0;
2861
+ mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_4 : 0;
27302862 mcp->mb[2] = 0;
27312863 mcp->mb[3] = 0;
27322864 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
....@@ -2834,7 +2966,8 @@
28342966 mcp->mb[0] = MBC_GET_RESOURCE_COUNTS;
28352967 mcp->out_mb = MBX_0;
28362968 mcp->in_mb = MBX_11|MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
2837
- if (IS_QLA81XX(vha->hw) || IS_QLA83XX(vha->hw) || IS_QLA27XX(vha->hw))
2969
+ if (IS_QLA81XX(ha) || IS_QLA83XX(ha) ||
2970
+ IS_QLA27XX(ha) || IS_QLA28XX(ha))
28382971 mcp->in_mb |= MBX_12;
28392972 mcp->tov = MBX_TOV_SECONDS;
28402973 mcp->flags = 0;
....@@ -2859,7 +2992,7 @@
28592992 ha->orig_fw_iocb_count = mcp->mb[10];
28602993 if (ha->flags.npiv_supported)
28612994 ha->max_npiv_vports = mcp->mb[11];
2862
- if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha))
2995
+ if (IS_QLA81XX(ha) || IS_QLA83XX(ha))
28632996 ha->fw_max_fcf_count = mcp->mb[12];
28642997 }
28652998
....@@ -2881,7 +3014,8 @@
28813014 * Kernel context.
28823015 */
28833016 int
2884
-qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map)
3017
+qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map,
3018
+ u8 *num_entries)
28853019 {
28863020 int rval;
28873021 mbx_cmd_t mc;
....@@ -2921,6 +3055,8 @@
29213055
29223056 if (pos_map)
29233057 memcpy(pos_map, pmap, FCAL_MAP_SIZE);
3058
+ if (num_entries)
3059
+ *num_entries = pmap[0];
29243060 }
29253061 dma_pool_free(ha->s_dma_pool, pmap, pmap_dma);
29263062
....@@ -2954,7 +3090,7 @@
29543090 int rval;
29553091 mbx_cmd_t mc;
29563092 mbx_cmd_t *mcp = &mc;
2957
- uint32_t *iter = (void *)stats;
3093
+ uint32_t *iter = (uint32_t *)stats;
29583094 ushort dwords = offsetof(typeof(*stats), link_up_cnt)/sizeof(*iter);
29593095 struct qla_hw_data *ha = vha->hw;
29603096
....@@ -3013,20 +3149,21 @@
30133149 int rval;
30143150 mbx_cmd_t mc;
30153151 mbx_cmd_t *mcp = &mc;
3016
- uint32_t *iter, dwords;
3152
+ uint32_t *iter = (uint32_t *)stats;
3153
+ ushort dwords = sizeof(*stats)/sizeof(*iter);
30173154
30183155 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1088,
30193156 "Entered %s.\n", __func__);
30203157
30213158 memset(&mc, 0, sizeof(mc));
30223159 mc.mb[0] = MBC_GET_LINK_PRIV_STATS;
3023
- mc.mb[2] = MSW(stats_dma);
3024
- mc.mb[3] = LSW(stats_dma);
3160
+ mc.mb[2] = MSW(LSD(stats_dma));
3161
+ mc.mb[3] = LSW(LSD(stats_dma));
30253162 mc.mb[6] = MSW(MSD(stats_dma));
30263163 mc.mb[7] = LSW(MSD(stats_dma));
3027
- mc.mb[8] = sizeof(struct link_statistics) / 4;
3028
- mc.mb[9] = cpu_to_le16(vha->vp_idx);
3029
- mc.mb[10] = cpu_to_le16(options);
3164
+ mc.mb[8] = dwords;
3165
+ mc.mb[9] = vha->vp_idx;
3166
+ mc.mb[10] = options;
30303167
30313168 rval = qla24xx_send_mb_cmd(vha, &mc);
30323169
....@@ -3039,8 +3176,6 @@
30393176 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108a,
30403177 "Done %s.\n", __func__);
30413178 /* Re-endianize - firmware data is le32. */
3042
- dwords = sizeof(struct link_statistics) / 4;
3043
- iter = &stats->link_fail_cnt;
30443179 for ( ; dwords--; iter++)
30453180 le32_to_cpus(iter);
30463181 }
....@@ -3065,22 +3200,25 @@
30653200 struct scsi_qla_host *vha = fcport->vha;
30663201 struct qla_hw_data *ha = vha->hw;
30673202 struct req_que *req = vha->req;
3203
+ struct qla_qpair *qpair = sp->qpair;
30683204
30693205 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108c,
30703206 "Entered %s.\n", __func__);
30713207
30723208 if (sp->qpair)
30733209 req = sp->qpair->req;
3210
+ else
3211
+ return QLA_FUNCTION_FAILED;
30743212
30753213 if (ql2xasynctmfenable)
30763214 return qla24xx_async_abort_command(sp);
30773215
3078
- spin_lock_irqsave(&ha->hardware_lock, flags);
3216
+ spin_lock_irqsave(qpair->qp_lock_ptr, flags);
30793217 for (handle = 1; handle < req->num_outstanding_cmds; handle++) {
30803218 if (req->outstanding_cmds[handle] == sp)
30813219 break;
30823220 }
3083
- spin_unlock_irqrestore(&ha->hardware_lock, flags);
3221
+ spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
30843222 if (handle == req->num_outstanding_cmds) {
30853223 /* Command not found. */
30863224 return QLA_FUNCTION_FAILED;
....@@ -3095,9 +3233,9 @@
30953233
30963234 abt->entry_type = ABORT_IOCB_TYPE;
30973235 abt->entry_count = 1;
3098
- abt->handle = MAKE_HANDLE(req->id, abt->handle);
3236
+ abt->handle = make_handle(req->id, abt->handle);
30993237 abt->nport_handle = cpu_to_le16(fcport->loop_id);
3100
- abt->handle_to_abort = MAKE_HANDLE(req->id, handle);
3238
+ abt->handle_to_abort = make_handle(req->id, handle);
31013239 abt->port_id[0] = fcport->d_id.b.al_pa;
31023240 abt->port_id[1] = fcport->d_id.b.area;
31033241 abt->port_id[2] = fcport->d_id.b.domain;
....@@ -3118,7 +3256,7 @@
31183256 ql_dbg(ql_dbg_mbx, vha, 0x1090,
31193257 "Failed to complete IOCB -- completion status (%x).\n",
31203258 le16_to_cpu(abt->nport_handle));
3121
- if (abt->nport_handle == CS_IOCB_ERROR)
3259
+ if (abt->nport_handle == cpu_to_le16(CS_IOCB_ERROR))
31223260 rval = QLA_FUNCTION_PARAMETER_ERROR;
31233261 else
31243262 rval = QLA_FUNCTION_FAILED;
....@@ -3150,7 +3288,6 @@
31503288 scsi_qla_host_t *vha;
31513289 struct qla_hw_data *ha;
31523290 struct req_que *req;
3153
- struct rsp_que *rsp;
31543291 struct qla_qpair *qpair;
31553292
31563293 vha = fcport->vha;
....@@ -3163,10 +3300,7 @@
31633300 if (vha->vp_idx && vha->qpair) {
31643301 /* NPIV port */
31653302 qpair = vha->qpair;
3166
- rsp = qpair->rsp;
31673303 req = qpair->req;
3168
- } else {
3169
- rsp = req->rsp;
31703304 }
31713305
31723306 tsk = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma);
....@@ -3178,7 +3312,7 @@
31783312
31793313 tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE;
31803314 tsk->p.tsk.entry_count = 1;
3181
- tsk->p.tsk.handle = MAKE_HANDLE(req->id, tsk->p.tsk.handle);
3315
+ tsk->p.tsk.handle = make_handle(req->id, tsk->p.tsk.handle);
31823316 tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id);
31833317 tsk->p.tsk.timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
31843318 tsk->p.tsk.control_flags = cpu_to_le32(type);
....@@ -3223,8 +3357,8 @@
32233357 }
32243358
32253359 /* Issue marker IOCB. */
3226
- rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l,
3227
- type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID);
3360
+ rval2 = qla2x00_marker(vha, ha->base_qpair, fcport->loop_id, l,
3361
+ type == TCF_LUN_RESET ? MK_SYNC_ID_LUN : MK_SYNC_ID);
32283362 if (rval2 != QLA_SUCCESS) {
32293363 ql_dbg(ql_dbg_mbx, vha, 0x1099,
32303364 "Failed to issue marker IOCB (%x).\n", rval2);
....@@ -3299,7 +3433,7 @@
32993433 mbx_cmd_t *mcp = &mc;
33003434
33013435 if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) &&
3302
- !IS_QLA27XX(vha->hw))
3436
+ !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw))
33033437 return QLA_FUNCTION_FAILED;
33043438
33053439 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1182,
....@@ -3338,7 +3472,7 @@
33383472 mbx_cmd_t *mcp = &mc;
33393473
33403474 if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) &&
3341
- !IS_QLA27XX(vha->hw))
3475
+ !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw))
33423476 return QLA_FUNCTION_FAILED;
33433477
33443478 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1185,
....@@ -3444,9 +3578,9 @@
34443578 /**
34453579 * qla2x00_set_serdes_params() -
34463580 * @vha: HA context
3447
- * @sw_em_1g:
3448
- * @sw_em_2g:
3449
- * @sw_em_4g:
3581
+ * @sw_em_1g: serial link options
3582
+ * @sw_em_2g: serial link options
3583
+ * @sw_em_4g: serial link options
34503584 *
34513585 * Returns
34523586 */
....@@ -3607,7 +3741,8 @@
36073741 "Entered %s.\n", __func__);
36083742
36093743 if (!IS_QLA25XX(vha->hw) && !IS_QLA81XX(vha->hw) &&
3610
- !IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw))
3744
+ !IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw) &&
3745
+ !IS_QLA28XX(vha->hw))
36113746 return QLA_FUNCTION_FAILED;
36123747
36133748 if (unlikely(pci_channel_offline(vha->hw->pdev)))
....@@ -3720,7 +3855,7 @@
37203855 rval = qla2x00_mailbox_command(vha, mcp);
37213856
37223857 /* Return mailbox statuses. */
3723
- if (mb != NULL) {
3858
+ if (mb) {
37243859 mb[0] = mcp->mb[0];
37253860 mb[1] = mcp->mb[1];
37263861 mb[3] = mcp->mb[3];
....@@ -3755,7 +3890,7 @@
37553890 mcp->mb[0] = MBC_PORT_PARAMS;
37563891 mcp->mb[1] = loop_id;
37573892 mcp->mb[2] = BIT_0;
3758
- mcp->mb[3] = port_speed & (BIT_5|BIT_4|BIT_3|BIT_2|BIT_1|BIT_0);
3893
+ mcp->mb[3] = port_speed & 0x3F;
37593894 mcp->mb[9] = vha->vp_idx;
37603895 mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0;
37613896 mcp->in_mb = MBX_3|MBX_1|MBX_0;
....@@ -3764,7 +3899,7 @@
37643899 rval = qla2x00_mailbox_command(vha, mcp);
37653900
37663901 /* Return mailbox statuses. */
3767
- if (mb != NULL) {
3902
+ if (mb) {
37683903 mb[0] = mcp->mb[0];
37693904 mb[1] = mcp->mb[1];
37703905 mb[3] = mcp->mb[3];
....@@ -3837,14 +3972,46 @@
38373972 case TOPO_N2N:
38383973 ha->current_topology = ISP_CFG_N;
38393974 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags);
3975
+ list_for_each_entry(fcport, &vha->vp_fcports, list) {
3976
+ fcport->scan_state = QLA_FCPORT_SCAN;
3977
+ fcport->n2n_flag = 0;
3978
+ }
3979
+ id.b24 = 0;
3980
+ if (wwn_to_u64(vha->port_name) >
3981
+ wwn_to_u64(rptid_entry->u.f1.port_name)) {
3982
+ vha->d_id.b24 = 0;
3983
+ vha->d_id.b.al_pa = 1;
3984
+ ha->flags.n2n_bigger = 1;
3985
+
3986
+ id.b.al_pa = 2;
3987
+ ql_dbg(ql_dbg_async, vha, 0x5075,
3988
+ "Format 1: assign local id %x remote id %x\n",
3989
+ vha->d_id.b24, id.b24);
3990
+ } else {
3991
+ ql_dbg(ql_dbg_async, vha, 0x5075,
3992
+ "Format 1: Remote login - Waiting for WWPN %8phC.\n",
3993
+ rptid_entry->u.f1.port_name);
3994
+ ha->flags.n2n_bigger = 0;
3995
+ }
3996
+
38403997 fcport = qla2x00_find_fcport_by_wwpn(vha,
38413998 rptid_entry->u.f1.port_name, 1);
38423999 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
38434000
4001
+
38444002 if (fcport) {
38454003 fcport->plogi_nack_done_deadline = jiffies + HZ;
3846
- fcport->dm_login_expire = jiffies + 3*HZ;
4004
+ fcport->dm_login_expire = jiffies +
4005
+ QLA_N2N_WAIT_TIME * HZ;
38474006 fcport->scan_state = QLA_FCPORT_FOUND;
4007
+ fcport->n2n_flag = 1;
4008
+ fcport->keep_nport_handle = 1;
4009
+
4010
+ if (wwn_to_u64(vha->port_name) >
4011
+ wwn_to_u64(fcport->port_name)) {
4012
+ fcport->d_id = id;
4013
+ }
4014
+
38484015 switch (fcport->disc_state) {
38494016 case DSC_DELETED:
38504017 set_bit(RELOGIN_NEEDED,
....@@ -3857,30 +4024,11 @@
38574024 break;
38584025 }
38594026 } else {
3860
- id.b24 = 0;
3861
- if (wwn_to_u64(vha->port_name) >
3862
- wwn_to_u64(rptid_entry->u.f1.port_name)) {
3863
- vha->d_id.b24 = 0;
3864
- vha->d_id.b.al_pa = 1;
3865
- ha->flags.n2n_bigger = 1;
3866
- ha->flags.n2n_ae = 0;
3867
-
3868
- id.b.al_pa = 2;
3869
- ql_dbg(ql_dbg_async, vha, 0x5075,
3870
- "Format 1: assign local id %x remote id %x\n",
3871
- vha->d_id.b24, id.b24);
3872
- } else {
3873
- ql_dbg(ql_dbg_async, vha, 0x5075,
3874
- "Format 1: Remote login - Waiting for WWPN %8phC.\n",
3875
- rptid_entry->u.f1.port_name);
3876
- ha->flags.n2n_bigger = 0;
3877
- ha->flags.n2n_ae = 1;
3878
- }
38794027 qla24xx_post_newsess_work(vha, &id,
38804028 rptid_entry->u.f1.port_name,
38814029 rptid_entry->u.f1.node_name,
38824030 NULL,
3883
- FC4_TYPE_UNKNOWN);
4031
+ FS_FCP_IS_N2N);
38844032 }
38854033
38864034 /* if our portname is higher then initiate N2N login */
....@@ -3978,6 +4126,7 @@
39784126
39794127 list_for_each_entry(fcport, &vha->vp_fcports, list) {
39804128 fcport->scan_state = QLA_FCPORT_SCAN;
4129
+ fcport->n2n_flag = 0;
39814130 }
39824131
39834132 fcport = qla2x00_find_fcport_by_wwpn(vha,
....@@ -3987,6 +4136,14 @@
39874136 fcport->login_retry = vha->hw->login_retry_count;
39884137 fcport->plogi_nack_done_deadline = jiffies + HZ;
39894138 fcport->scan_state = QLA_FCPORT_FOUND;
4139
+ fcport->keep_nport_handle = 1;
4140
+ fcport->n2n_flag = 1;
4141
+ fcport->d_id.b.domain =
4142
+ rptid_entry->u.f2.remote_nport_id[2];
4143
+ fcport->d_id.b.area =
4144
+ rptid_entry->u.f2.remote_nport_id[1];
4145
+ fcport->d_id.b.al_pa =
4146
+ rptid_entry->u.f2.remote_nport_id[0];
39904147 }
39914148 }
39924149 }
....@@ -4128,7 +4285,8 @@
41284285 if (MSW(addr) || IS_FWI2_CAPABLE(vha->hw)) {
41294286 mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED;
41304287 mcp->mb[8] = MSW(addr);
4131
- mcp->out_mb = MBX_8|MBX_0;
4288
+ mcp->mb[10] = 0;
4289
+ mcp->out_mb = MBX_10|MBX_8|MBX_0;
41324290 } else {
41334291 mcp->mb[0] = MBC_DUMP_RISC_RAM;
41344292 mcp->out_mb = MBX_0;
....@@ -4207,7 +4365,7 @@
42074365 ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111c,
42084366 "Dump of Verify Request.\n");
42094367 ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111e,
4210
- (uint8_t *)mn, sizeof(*mn));
4368
+ mn, sizeof(*mn));
42114369
42124370 rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120);
42134371 if (rval != QLA_SUCCESS) {
....@@ -4219,7 +4377,7 @@
42194377 ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1110,
42204378 "Dump of Verify Response.\n");
42214379 ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1118,
4222
- (uint8_t *)mn, sizeof(*mn));
4380
+ mn, sizeof(*mn));
42234381
42244382 status[0] = le16_to_cpu(mn->p.rsp.comp_status);
42254383 status[1] = status[0] == CS_VCS_CHIP_FAILURE ?
....@@ -4295,7 +4453,7 @@
42954453 mcp->mb[12] = req->qos;
42964454 mcp->mb[11] = req->vp_idx;
42974455 mcp->mb[13] = req->rid;
4298
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha))
4456
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
42994457 mcp->mb[15] = 0;
43004458
43014459 mcp->mb[4] = req->id;
....@@ -4309,9 +4467,10 @@
43094467 mcp->flags = MBX_DMA_OUT;
43104468 mcp->tov = MBX_TOV_SECONDS * 2;
43114469
4312
- if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha))
4470
+ if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha) ||
4471
+ IS_QLA28XX(ha))
43134472 mcp->in_mb |= MBX_1;
4314
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
4473
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
43154474 mcp->out_mb |= MBX_15;
43164475 /* debug q create issue in SR-IOV */
43174476 mcp->in_mb |= MBX_9 | MBX_8 | MBX_7;
....@@ -4319,9 +4478,9 @@
43194478
43204479 spin_lock_irqsave(&ha->hardware_lock, flags);
43214480 if (!(req->options & BIT_0)) {
4322
- WRT_REG_DWORD(req->req_q_in, 0);
4323
- if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
4324
- WRT_REG_DWORD(req->req_q_out, 0);
4481
+ wrt_reg_dword(req->req_q_in, 0);
4482
+ if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
4483
+ wrt_reg_dword(req->req_q_out, 0);
43254484 }
43264485 spin_unlock_irqrestore(&ha->hardware_lock, flags);
43274486
....@@ -4364,7 +4523,7 @@
43644523 mcp->mb[5] = rsp->length;
43654524 mcp->mb[14] = rsp->msix->entry;
43664525 mcp->mb[13] = rsp->rid;
4367
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha))
4526
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
43684527 mcp->mb[15] = 0;
43694528
43704529 mcp->mb[4] = rsp->id;
....@@ -4381,7 +4540,7 @@
43814540 if (IS_QLA81XX(ha)) {
43824541 mcp->out_mb |= MBX_12|MBX_11|MBX_10;
43834542 mcp->in_mb |= MBX_1;
4384
- } else if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
4543
+ } else if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
43854544 mcp->out_mb |= MBX_15|MBX_12|MBX_11|MBX_10;
43864545 mcp->in_mb |= MBX_1;
43874546 /* debug q create issue in SR-IOV */
....@@ -4390,9 +4549,9 @@
43904549
43914550 spin_lock_irqsave(&ha->hardware_lock, flags);
43924551 if (!(rsp->options & BIT_0)) {
4393
- WRT_REG_DWORD(rsp->rsp_q_out, 0);
4394
- if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
4395
- WRT_REG_DWORD(rsp->rsp_q_in, 0);
4552
+ wrt_reg_dword(rsp->rsp_q_out, 0);
4553
+ if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
4554
+ wrt_reg_dword(rsp->rsp_q_in, 0);
43964555 }
43974556
43984557 spin_unlock_irqrestore(&ha->hardware_lock, flags);
....@@ -4449,7 +4608,7 @@
44494608 "Entered %s.\n", __func__);
44504609
44514610 if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) &&
4452
- !IS_QLA27XX(vha->hw))
4611
+ !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw))
44534612 return QLA_FUNCTION_FAILED;
44544613
44554614 mcp->mb[0] = MBC_FLASH_ACCESS_CTRL;
....@@ -4481,7 +4640,7 @@
44814640 mbx_cmd_t *mcp = &mc;
44824641
44834642 if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) &&
4484
- !IS_QLA27XX(vha->hw))
4643
+ !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw))
44854644 return QLA_FUNCTION_FAILED;
44864645
44874646 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10df,
....@@ -4516,7 +4675,7 @@
45164675 mbx_cmd_t *mcp = &mc;
45174676
45184677 if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) &&
4519
- !IS_QLA27XX(vha->hw))
4678
+ !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw))
45204679 return QLA_FUNCTION_FAILED;
45214680
45224681 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e2,
....@@ -4530,6 +4689,42 @@
45304689 mcp->mb[5] = MSW(finish);
45314690 mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
45324691 mcp->in_mb = MBX_2|MBX_1|MBX_0;
4692
+ mcp->tov = MBX_TOV_SECONDS;
4693
+ mcp->flags = 0;
4694
+ rval = qla2x00_mailbox_command(vha, mcp);
4695
+
4696
+ if (rval != QLA_SUCCESS) {
4697
+ ql_dbg(ql_dbg_mbx, vha, 0x10e3,
4698
+ "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
4699
+ rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]);
4700
+ } else {
4701
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e4,
4702
+ "Done %s.\n", __func__);
4703
+ }
4704
+
4705
+ return rval;
4706
+}
4707
+
4708
+int
4709
+qla81xx_fac_semaphore_access(scsi_qla_host_t *vha, int lock)
4710
+{
4711
+ int rval = QLA_SUCCESS;
4712
+ mbx_cmd_t mc;
4713
+ mbx_cmd_t *mcp = &mc;
4714
+ struct qla_hw_data *ha = vha->hw;
4715
+
4716
+ if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) &&
4717
+ !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
4718
+ return rval;
4719
+
4720
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e2,
4721
+ "Entered %s.\n", __func__);
4722
+
4723
+ mcp->mb[0] = MBC_FLASH_ACCESS_CTRL;
4724
+ mcp->mb[1] = (lock ? FAC_OPT_CMD_LOCK_SEMAPHORE :
4725
+ FAC_OPT_CMD_UNLOCK_SEMAPHORE);
4726
+ mcp->out_mb = MBX_1|MBX_0;
4727
+ mcp->in_mb = MBX_1|MBX_0;
45334728 mcp->tov = MBX_TOV_SECONDS;
45344729 mcp->flags = 0;
45354730 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -4583,7 +4778,7 @@
45834778 mbx_cmd_t *mcp = &mc;
45844779 int i;
45854780 int len;
4586
- uint16_t *str;
4781
+ __le16 *str;
45874782 struct qla_hw_data *ha = vha->hw;
45884783
45894784 if (!IS_P3P_TYPE(ha))
....@@ -4592,14 +4787,14 @@
45924787 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117b,
45934788 "Entered %s.\n", __func__);
45944789
4595
- str = (void *)version;
4790
+ str = (__force __le16 *)version;
45964791 len = strlen(version);
45974792
45984793 mcp->mb[0] = MBC_SET_RNID_PARAMS;
45994794 mcp->mb[1] = RNID_TYPE_SET_VERSION << 8;
46004795 mcp->out_mb = MBX_1|MBX_0;
46014796 for (i = 4; i < 16 && len; i++, str++, len -= 2) {
4602
- mcp->mb[i] = cpu_to_le16p(str);
4797
+ mcp->mb[i] = le16_to_cpup(str);
46034798 mcp->out_mb |= 1<<i;
46044799 }
46054800 for (; i < 16; i++) {
....@@ -4717,8 +4912,73 @@
47174912 "Done %s.\n", __func__);
47184913 bp = (uint32_t *) buf;
47194914 for (i = 0; i < (bufsiz-4)/4; i++, bp++)
4720
- *bp = le32_to_cpu(*bp);
4915
+ *bp = le32_to_cpu((__force __le32)*bp);
47214916 }
4917
+
4918
+ return rval;
4919
+}
4920
+
4921
+#define PUREX_CMD_COUNT 2
4922
+int
4923
+qla25xx_set_els_cmds_supported(scsi_qla_host_t *vha)
4924
+{
4925
+ int rval;
4926
+ mbx_cmd_t mc;
4927
+ mbx_cmd_t *mcp = &mc;
4928
+ uint8_t *els_cmd_map;
4929
+ dma_addr_t els_cmd_map_dma;
4930
+ uint8_t cmd_opcode[PUREX_CMD_COUNT];
4931
+ uint8_t i, index, purex_bit;
4932
+ struct qla_hw_data *ha = vha->hw;
4933
+
4934
+ if (!IS_QLA25XX(ha) && !IS_QLA2031(ha) &&
4935
+ !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
4936
+ return QLA_SUCCESS;
4937
+
4938
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1197,
4939
+ "Entered %s.\n", __func__);
4940
+
4941
+ els_cmd_map = dma_alloc_coherent(&ha->pdev->dev, ELS_CMD_MAP_SIZE,
4942
+ &els_cmd_map_dma, GFP_KERNEL);
4943
+ if (!els_cmd_map) {
4944
+ ql_log(ql_log_warn, vha, 0x7101,
4945
+ "Failed to allocate RDP els command param.\n");
4946
+ return QLA_MEMORY_ALLOC_FAILED;
4947
+ }
4948
+
4949
+ /* List of Purex ELS */
4950
+ cmd_opcode[0] = ELS_FPIN;
4951
+ cmd_opcode[1] = ELS_RDP;
4952
+
4953
+ for (i = 0; i < PUREX_CMD_COUNT; i++) {
4954
+ index = cmd_opcode[i] / 8;
4955
+ purex_bit = cmd_opcode[i] % 8;
4956
+ els_cmd_map[index] |= 1 << purex_bit;
4957
+ }
4958
+
4959
+ mcp->mb[0] = MBC_SET_RNID_PARAMS;
4960
+ mcp->mb[1] = RNID_TYPE_ELS_CMD << 8;
4961
+ mcp->mb[2] = MSW(LSD(els_cmd_map_dma));
4962
+ mcp->mb[3] = LSW(LSD(els_cmd_map_dma));
4963
+ mcp->mb[6] = MSW(MSD(els_cmd_map_dma));
4964
+ mcp->mb[7] = LSW(MSD(els_cmd_map_dma));
4965
+ mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
4966
+ mcp->in_mb = MBX_1|MBX_0;
4967
+ mcp->tov = MBX_TOV_SECONDS;
4968
+ mcp->flags = MBX_DMA_OUT;
4969
+ mcp->buf_size = ELS_CMD_MAP_SIZE;
4970
+ rval = qla2x00_mailbox_command(vha, mcp);
4971
+
4972
+ if (rval != QLA_SUCCESS) {
4973
+ ql_dbg(ql_dbg_mbx, vha, 0x118d,
4974
+ "Failed=%x (%x,%x).\n", rval, mcp->mb[0], mcp->mb[1]);
4975
+ } else {
4976
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118c,
4977
+ "Done %s.\n", __func__);
4978
+ }
4979
+
4980
+ dma_free_coherent(&ha->pdev->dev, ELS_CMD_MAP_SIZE,
4981
+ els_cmd_map, els_cmd_map_dma);
47224982
47234983 return rval;
47244984 }
....@@ -4776,8 +5036,8 @@
47765036
47775037 mcp->mb[0] = MBC_READ_SFP;
47785038 mcp->mb[1] = dev;
4779
- mcp->mb[2] = MSW(sfp_dma);
4780
- mcp->mb[3] = LSW(sfp_dma);
5039
+ mcp->mb[2] = MSW(LSD(sfp_dma));
5040
+ mcp->mb[3] = LSW(LSD(sfp_dma));
47815041 mcp->mb[6] = MSW(MSD(sfp_dma));
47825042 mcp->mb[7] = LSW(MSD(sfp_dma));
47835043 mcp->mb[8] = len;
....@@ -4795,10 +5055,10 @@
47955055 if (rval != QLA_SUCCESS) {
47965056 ql_dbg(ql_dbg_mbx, vha, 0x10e9,
47975057 "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
4798
- if (mcp->mb[0] == MBS_COMMAND_ERROR &&
4799
- mcp->mb[1] == 0x22)
5058
+ if (mcp->mb[0] == MBS_COMMAND_ERROR && mcp->mb[1] == 0x22) {
48005059 /* sfp is not there */
48015060 rval = QLA_INTERFACE_ERROR;
5061
+ }
48025062 } else {
48035063 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea,
48045064 "Done %s.\n", __func__);
....@@ -4830,8 +5090,8 @@
48305090
48315091 mcp->mb[0] = MBC_WRITE_SFP;
48325092 mcp->mb[1] = dev;
4833
- mcp->mb[2] = MSW(sfp_dma);
4834
- mcp->mb[3] = LSW(sfp_dma);
5093
+ mcp->mb[2] = MSW(LSD(sfp_dma));
5094
+ mcp->mb[3] = LSW(LSD(sfp_dma));
48355095 mcp->mb[6] = MSW(MSD(sfp_dma));
48365096 mcp->mb[7] = LSW(MSD(sfp_dma));
48375097 mcp->mb[8] = len;
....@@ -4952,7 +5212,7 @@
49525212 mcp->mb[8] = MSW(risc_addr);
49535213 mcp->out_mb = MBX_8|MBX_1|MBX_0;
49545214 mcp->in_mb = MBX_3|MBX_2|MBX_0;
4955
- mcp->tov = 30;
5215
+ mcp->tov = MBX_TOV_SECONDS;
49565216 mcp->flags = 0;
49575217 rval = qla2x00_mailbox_command(vha, mcp);
49585218 if (rval != QLA_SUCCESS) {
....@@ -5066,10 +5326,11 @@
50665326 mcp->out_mb |= MBX_2;
50675327
50685328 mcp->in_mb = MBX_0;
5069
- if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) ||
5070
- IS_CNA_CAPABLE(ha) || IS_QLA2031(ha))
5329
+ if (IS_CNA_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) ||
5330
+ IS_QLA2031(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
50715331 mcp->in_mb |= MBX_1;
5072
- if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha))
5332
+ if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha) ||
5333
+ IS_QLA28XX(ha))
50735334 mcp->in_mb |= MBX_3;
50745335
50755336 mcp->tov = MBX_TOV_SECONDS;
....@@ -5138,13 +5399,14 @@
51385399 mcp->mb[3] = MSW(data);
51395400 mcp->mb[8] = MSW(risc_addr);
51405401 mcp->out_mb = MBX_8|MBX_3|MBX_2|MBX_1|MBX_0;
5141
- mcp->in_mb = MBX_0;
5142
- mcp->tov = 30;
5402
+ mcp->in_mb = MBX_1|MBX_0;
5403
+ mcp->tov = MBX_TOV_SECONDS;
51435404 mcp->flags = 0;
51445405 rval = qla2x00_mailbox_command(vha, mcp);
51455406 if (rval != QLA_SUCCESS) {
51465407 ql_dbg(ql_dbg_mbx, vha, 0x1101,
5147
- "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
5408
+ "Failed=%x mb[0]=%x mb[1]=%x.\n",
5409
+ rval, mcp->mb[0], mcp->mb[1]);
51485410 } else {
51495411 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1102,
51505412 "Done %s.\n", __func__);
....@@ -5170,18 +5432,18 @@
51705432 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
51715433
51725434 /* Write the MBC data to the registers */
5173
- WRT_REG_WORD(&reg->mailbox0, MBC_WRITE_MPI_REGISTER);
5174
- WRT_REG_WORD(&reg->mailbox1, mb[0]);
5175
- WRT_REG_WORD(&reg->mailbox2, mb[1]);
5176
- WRT_REG_WORD(&reg->mailbox3, mb[2]);
5177
- WRT_REG_WORD(&reg->mailbox4, mb[3]);
5435
+ wrt_reg_word(&reg->mailbox0, MBC_WRITE_MPI_REGISTER);
5436
+ wrt_reg_word(&reg->mailbox1, mb[0]);
5437
+ wrt_reg_word(&reg->mailbox2, mb[1]);
5438
+ wrt_reg_word(&reg->mailbox3, mb[2]);
5439
+ wrt_reg_word(&reg->mailbox4, mb[3]);
51785440
5179
- WRT_REG_DWORD(&reg->hccr, HCCRX_SET_HOST_INT);
5441
+ wrt_reg_dword(&reg->hccr, HCCRX_SET_HOST_INT);
51805442
51815443 /* Poll for MBC interrupt */
51825444 for (timer = 6000000; timer; timer--) {
51835445 /* Check for pending interrupts. */
5184
- stat = RD_REG_DWORD(&reg->host_status);
5446
+ stat = rd_reg_dword(&reg->host_status);
51855447 if (stat & HSRX_RISC_INT) {
51865448 stat &= 0xff;
51875449
....@@ -5189,10 +5451,10 @@
51895451 stat == 0x10 || stat == 0x11) {
51905452 set_bit(MBX_INTERRUPT,
51915453 &ha->mbx_cmd_flags);
5192
- mb0 = RD_REG_WORD(&reg->mailbox0);
5193
- WRT_REG_DWORD(&reg->hccr,
5454
+ mb0 = rd_reg_word(&reg->mailbox0);
5455
+ wrt_reg_dword(&reg->hccr,
51945456 HCCRX_CLR_RISC_INT);
5195
- RD_REG_DWORD(&reg->hccr);
5457
+ rd_reg_dword(&reg->hccr);
51965458 break;
51975459 }
51985460 }
....@@ -5215,6 +5477,66 @@
52155477 return rval;
52165478 }
52175479
5480
+/* Set the specified data rate */
5481
+int
5482
+qla2x00_set_data_rate(scsi_qla_host_t *vha, uint16_t mode)
5483
+{
5484
+ int rval;
5485
+ mbx_cmd_t mc;
5486
+ mbx_cmd_t *mcp = &mc;
5487
+ struct qla_hw_data *ha = vha->hw;
5488
+ uint16_t val;
5489
+
5490
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1106,
5491
+ "Entered %s speed:0x%x mode:0x%x.\n", __func__, ha->set_data_rate,
5492
+ mode);
5493
+
5494
+ if (!IS_FWI2_CAPABLE(ha))
5495
+ return QLA_FUNCTION_FAILED;
5496
+
5497
+ memset(mcp, 0, sizeof(*mcp));
5498
+ switch (ha->set_data_rate) {
5499
+ case PORT_SPEED_AUTO:
5500
+ case PORT_SPEED_4GB:
5501
+ case PORT_SPEED_8GB:
5502
+ case PORT_SPEED_16GB:
5503
+ case PORT_SPEED_32GB:
5504
+ val = ha->set_data_rate;
5505
+ break;
5506
+ default:
5507
+ ql_log(ql_log_warn, vha, 0x1199,
5508
+ "Unrecognized speed setting:%d. Setting Autoneg\n",
5509
+ ha->set_data_rate);
5510
+ val = ha->set_data_rate = PORT_SPEED_AUTO;
5511
+ break;
5512
+ }
5513
+
5514
+ mcp->mb[0] = MBC_DATA_RATE;
5515
+ mcp->mb[1] = mode;
5516
+ mcp->mb[2] = val;
5517
+
5518
+ mcp->out_mb = MBX_2|MBX_1|MBX_0;
5519
+ mcp->in_mb = MBX_2|MBX_1|MBX_0;
5520
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
5521
+ mcp->in_mb |= MBX_4|MBX_3;
5522
+ mcp->tov = MBX_TOV_SECONDS;
5523
+ mcp->flags = 0;
5524
+ rval = qla2x00_mailbox_command(vha, mcp);
5525
+ if (rval != QLA_SUCCESS) {
5526
+ ql_dbg(ql_dbg_mbx, vha, 0x1107,
5527
+ "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
5528
+ } else {
5529
+ if (mcp->mb[1] != 0x7)
5530
+ ql_dbg(ql_dbg_mbx, vha, 0x1179,
5531
+ "Speed set:0x%x\n", mcp->mb[1]);
5532
+
5533
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1108,
5534
+ "Done %s.\n", __func__);
5535
+ }
5536
+
5537
+ return rval;
5538
+}
5539
+
52185540 int
52195541 qla2x00_get_data_rate(scsi_qla_host_t *vha)
52205542 {
....@@ -5230,11 +5552,11 @@
52305552 return QLA_FUNCTION_FAILED;
52315553
52325554 mcp->mb[0] = MBC_DATA_RATE;
5233
- mcp->mb[1] = 0;
5555
+ mcp->mb[1] = QLA_GET_DATA_RATE;
52345556 mcp->out_mb = MBX_1|MBX_0;
52355557 mcp->in_mb = MBX_2|MBX_1|MBX_0;
5236
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha))
5237
- mcp->in_mb |= MBX_3;
5558
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
5559
+ mcp->in_mb |= MBX_4|MBX_3;
52385560 mcp->tov = MBX_TOV_SECONDS;
52395561 mcp->flags = 0;
52405562 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -5242,6 +5564,15 @@
52425564 ql_dbg(ql_dbg_mbx, vha, 0x1107,
52435565 "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
52445566 } else {
5567
+ if (mcp->mb[1] != 0x7)
5568
+ ha->link_data_rate = mcp->mb[1];
5569
+
5570
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
5571
+ if (mcp->mb[4] & BIT_0)
5572
+ ql_log(ql_log_info, vha, 0x11a2,
5573
+ "FEC=enabled (data rate).\n");
5574
+ }
5575
+
52455576 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1108,
52465577 "Done %s.\n", __func__);
52475578 if (mcp->mb[1] != 0x7)
....@@ -5263,7 +5594,7 @@
52635594 "Entered %s.\n", __func__);
52645595
52655596 if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) && !IS_QLA8044(ha) &&
5266
- !IS_QLA27XX(ha))
5597
+ !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
52675598 return QLA_FUNCTION_FAILED;
52685599 mcp->mb[0] = MBC_GET_PORT_CONFIG;
52695600 mcp->out_mb = MBX_0;
....@@ -5341,7 +5672,7 @@
53415672 mcp->mb[9] = vha->vp_idx;
53425673 mcp->out_mb = MBX_9|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
53435674 mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0;
5344
- mcp->tov = 30;
5675
+ mcp->tov = MBX_TOV_SECONDS;
53455676 mcp->flags = 0;
53465677 rval = qla2x00_mailbox_command(vha, mcp);
53475678 if (mb != NULL) {
....@@ -5428,7 +5759,7 @@
54285759
54295760 mcp->out_mb = MBX_1|MBX_0;
54305761 mcp->in_mb = MBX_0;
5431
- mcp->tov = 30;
5762
+ mcp->tov = MBX_TOV_SECONDS;
54325763 mcp->flags = 0;
54335764
54345765 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -5463,7 +5794,7 @@
54635794
54645795 mcp->out_mb = MBX_1|MBX_0;
54655796 mcp->in_mb = MBX_0;
5466
- mcp->tov = 30;
5797
+ mcp->tov = MBX_TOV_SECONDS;
54675798 mcp->flags = 0;
54685799
54695800 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -5579,6 +5910,7 @@
55795910 mbx_cmd_t *mcp = &mc;
55805911 int rval = QLA_FUNCTION_FAILED;
55815912 int offset = 0, size = MINIDUMP_SIZE_36K;
5913
+
55825914 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11f,
55835915 "Entered %s.\n", __func__);
55845916
....@@ -5654,7 +5986,7 @@
56545986 if (IS_QLA8031(ha))
56555987 mcp->out_mb |= MBX_6|MBX_5|MBX_4|MBX_3;
56565988 mcp->in_mb = MBX_0;
5657
- mcp->tov = 30;
5989
+ mcp->tov = MBX_TOV_SECONDS;
56585990 mcp->flags = 0;
56595991
56605992 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -5690,7 +6022,7 @@
56906022 mcp->in_mb = MBX_2|MBX_1|MBX_0;
56916023 if (IS_QLA8031(ha))
56926024 mcp->in_mb |= MBX_6|MBX_5|MBX_4|MBX_3;
5693
- mcp->tov = 30;
6025
+ mcp->tov = MBX_TOV_SECONDS;
56946026 mcp->flags = 0;
56956027
56966028 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -5759,7 +6091,7 @@
57596091 mbx_cmd_t mc;
57606092 mbx_cmd_t *mcp = &mc;
57616093
5762
- if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
6094
+ if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
57636095 return QLA_FUNCTION_FAILED;
57646096
57656097 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1130,
....@@ -5834,7 +6166,7 @@
58346166 struct qla_hw_data *ha = vha->hw;
58356167 unsigned long retry_max_time = jiffies + (2 * HZ);
58366168
5837
- if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
6169
+ if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
58386170 return QLA_FUNCTION_FAILED;
58396171
58406172 ql_dbg(ql_dbg_mbx, vha, 0x114b, "Entered %s.\n", __func__);
....@@ -5884,7 +6216,7 @@
58846216 mbx_cmd_t *mcp = &mc;
58856217 struct qla_hw_data *ha = vha->hw;
58866218
5887
- if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
6219
+ if (!IS_QLA83XX(ha))
58886220 return QLA_FUNCTION_FAILED;
58896221
58906222 ql_dbg(ql_dbg_mbx, vha, 0x1143, "Entered %s.\n", __func__);
....@@ -5900,7 +6232,7 @@
59006232 ql_dbg(ql_dbg_mbx, vha, 0x1144,
59016233 "Failed=%x mb[0]=%x mb[1]=%x.\n",
59026234 rval, mcp->mb[0], mcp->mb[1]);
5903
- ha->isp_ops->fw_dump(vha, 0);
6235
+ qla2xxx_dump_fw(vha);
59046236 } else {
59056237 ql_dbg(ql_dbg_mbx, vha, 0x1145, "Done %s.\n", __func__);
59066238 }
....@@ -5945,7 +6277,7 @@
59456277 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[4]=%x.\n",
59466278 rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3],
59476279 mcp->mb[4]);
5948
- ha->isp_ops->fw_dump(vha, 0);
6280
+ qla2xxx_dump_fw(vha);
59496281 } else {
59506282 if (subcode & BIT_5)
59516283 *sector_size = mcp->mb[1];
....@@ -6017,7 +6349,8 @@
60176349 mbx_cmd_t *mcp = &mc;
60186350 dma_addr_t dd_dma;
60196351
6020
- if (!IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw))
6352
+ if (!IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw) &&
6353
+ !IS_QLA28XX(vha->hw))
60216354 return QLA_FUNCTION_FAILED;
60226355
60236356 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x119f,
....@@ -6059,10 +6392,8 @@
60596392 return rval;
60606393 }
60616394
6062
-static void qla2x00_async_mb_sp_done(void *s, int res)
6395
+static void qla2x00_async_mb_sp_done(srb_t *sp, int res)
60636396 {
6064
- struct srb *sp = s;
6065
-
60666397 sp->u.iocb_cmd.u.mbx.rc = res;
60676398
60686399 complete(&sp->u.iocb_cmd.u.mbx.comp);
....@@ -6160,13 +6491,13 @@
61606491
61616492 memset(&mc, 0, sizeof(mc));
61626493 mc.mb[0] = MBC_GET_PORT_DATABASE;
6163
- mc.mb[1] = cpu_to_le16(fcport->loop_id);
6494
+ mc.mb[1] = fcport->loop_id;
61646495 mc.mb[2] = MSW(pd_dma);
61656496 mc.mb[3] = LSW(pd_dma);
61666497 mc.mb[6] = MSW(MSD(pd_dma));
61676498 mc.mb[7] = LSW(MSD(pd_dma));
6168
- mc.mb[9] = cpu_to_le16(vha->vp_idx);
6169
- mc.mb[10] = cpu_to_le16((uint16_t)opt);
6499
+ mc.mb[9] = vha->vp_idx;
6500
+ mc.mb[10] = opt;
61706501
61716502 rval = qla24xx_send_mb_cmd(vha, &mc);
61726503 if (rval != QLA_SUCCESS) {
....@@ -6194,7 +6525,7 @@
61946525 uint64_t zero = 0;
61956526 u8 current_login_state, last_login_state;
61966527
6197
- if (fcport->fc4f_nvme) {
6528
+ if (NVME_TARGET(vha->hw, fcport)) {
61986529 current_login_state = pd->current_login_state >> 4;
61996530 last_login_state = pd->last_login_state >> 4;
62006531 } else {
....@@ -6229,10 +6560,14 @@
62296560 fcport->d_id.b.al_pa = pd->port_id[2];
62306561 fcport->d_id.b.rsvd_1 = 0;
62316562
6232
- if (fcport->fc4f_nvme) {
6233
- fcport->nvme_prli_service_param =
6234
- pd->prli_nvme_svc_param_word_3;
6563
+ if (NVME_TARGET(vha->hw, fcport)) {
62356564 fcport->port_type = FCT_NVME;
6565
+ if ((pd->prli_svc_param_word_3[0] & BIT_5) == 0)
6566
+ fcport->port_type |= FCT_NVME_INITIATOR;
6567
+ if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0)
6568
+ fcport->port_type |= FCT_NVME_TARGET;
6569
+ if ((pd->prli_svc_param_word_3[0] & BIT_3) == 0)
6570
+ fcport->port_type |= FCT_NVME_DISCOVERY;
62366571 } else {
62376572 /* If not target must be initiator or unknown type. */
62386573 if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0)
....@@ -6273,7 +6608,7 @@
62736608 mc.mb[6] = MSW(MSD(id_list_dma));
62746609 mc.mb[7] = LSW(MSD(id_list_dma));
62756610 mc.mb[8] = 0;
6276
- mc.mb[9] = cpu_to_le16(vha->vp_idx);
6611
+ mc.mb[9] = vha->vp_idx;
62776612
62786613 rval = qla24xx_send_mb_cmd(vha, &mc);
62796614 if (rval != QLA_SUCCESS) {
....@@ -6299,8 +6634,8 @@
62996634
63006635 memset(mcp->mb, 0 , sizeof(mcp->mb));
63016636 mcp->mb[0] = MBC_GET_SET_ZIO_THRESHOLD;
6302
- mcp->mb[1] = cpu_to_le16(1);
6303
- mcp->mb[2] = cpu_to_le16(value);
6637
+ mcp->mb[1] = 1;
6638
+ mcp->mb[2] = value;
63046639 mcp->out_mb = MBX_2 | MBX_1 | MBX_0;
63056640 mcp->in_mb = MBX_2 | MBX_0;
63066641 mcp->tov = MBX_TOV_SECONDS;
....@@ -6325,7 +6660,7 @@
63256660
63266661 memset(mcp->mb, 0, sizeof(mcp->mb));
63276662 mcp->mb[0] = MBC_GET_SET_ZIO_THRESHOLD;
6328
- mcp->mb[1] = cpu_to_le16(0);
6663
+ mcp->mb[1] = 0;
63296664 mcp->out_mb = MBX_1 | MBX_0;
63306665 mcp->in_mb = MBX_2 | MBX_0;
63316666 mcp->tov = MBX_TOV_SECONDS;
....@@ -6421,3 +6756,158 @@
64216756 done:
64226757 return rval;
64236758 }
6759
+
6760
+int qla28xx_secure_flash_update(scsi_qla_host_t *vha, uint16_t opts,
6761
+ uint16_t region, uint32_t len, dma_addr_t sfub_dma_addr,
6762
+ uint32_t sfub_len)
6763
+{
6764
+ int rval;
6765
+ mbx_cmd_t mc;
6766
+ mbx_cmd_t *mcp = &mc;
6767
+
6768
+ mcp->mb[0] = MBC_SECURE_FLASH_UPDATE;
6769
+ mcp->mb[1] = opts;
6770
+ mcp->mb[2] = region;
6771
+ mcp->mb[3] = MSW(len);
6772
+ mcp->mb[4] = LSW(len);
6773
+ mcp->mb[5] = MSW(sfub_dma_addr);
6774
+ mcp->mb[6] = LSW(sfub_dma_addr);
6775
+ mcp->mb[7] = MSW(MSD(sfub_dma_addr));
6776
+ mcp->mb[8] = LSW(MSD(sfub_dma_addr));
6777
+ mcp->mb[9] = sfub_len;
6778
+ mcp->out_mb =
6779
+ MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
6780
+ mcp->in_mb = MBX_2|MBX_1|MBX_0;
6781
+ mcp->tov = MBX_TOV_SECONDS;
6782
+ mcp->flags = 0;
6783
+ rval = qla2x00_mailbox_command(vha, mcp);
6784
+
6785
+ if (rval != QLA_SUCCESS) {
6786
+ ql_dbg(ql_dbg_mbx, vha, 0xffff, "%s(%ld): failed rval 0x%x, %x %x %x",
6787
+ __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1],
6788
+ mcp->mb[2]);
6789
+ }
6790
+
6791
+ return rval;
6792
+}
6793
+
6794
+int qla2xxx_write_remote_register(scsi_qla_host_t *vha, uint32_t addr,
6795
+ uint32_t data)
6796
+{
6797
+ int rval;
6798
+ mbx_cmd_t mc;
6799
+ mbx_cmd_t *mcp = &mc;
6800
+
6801
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e8,
6802
+ "Entered %s.\n", __func__);
6803
+
6804
+ mcp->mb[0] = MBC_WRITE_REMOTE_REG;
6805
+ mcp->mb[1] = LSW(addr);
6806
+ mcp->mb[2] = MSW(addr);
6807
+ mcp->mb[3] = LSW(data);
6808
+ mcp->mb[4] = MSW(data);
6809
+ mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
6810
+ mcp->in_mb = MBX_1|MBX_0;
6811
+ mcp->tov = MBX_TOV_SECONDS;
6812
+ mcp->flags = 0;
6813
+ rval = qla2x00_mailbox_command(vha, mcp);
6814
+
6815
+ if (rval != QLA_SUCCESS) {
6816
+ ql_dbg(ql_dbg_mbx, vha, 0x10e9,
6817
+ "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
6818
+ } else {
6819
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea,
6820
+ "Done %s.\n", __func__);
6821
+ }
6822
+
6823
+ return rval;
6824
+}
6825
+
6826
+int qla2xxx_read_remote_register(scsi_qla_host_t *vha, uint32_t addr,
6827
+ uint32_t *data)
6828
+{
6829
+ int rval;
6830
+ mbx_cmd_t mc;
6831
+ mbx_cmd_t *mcp = &mc;
6832
+
6833
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e8,
6834
+ "Entered %s.\n", __func__);
6835
+
6836
+ mcp->mb[0] = MBC_READ_REMOTE_REG;
6837
+ mcp->mb[1] = LSW(addr);
6838
+ mcp->mb[2] = MSW(addr);
6839
+ mcp->out_mb = MBX_2|MBX_1|MBX_0;
6840
+ mcp->in_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
6841
+ mcp->tov = MBX_TOV_SECONDS;
6842
+ mcp->flags = 0;
6843
+ rval = qla2x00_mailbox_command(vha, mcp);
6844
+
6845
+ *data = (uint32_t)((((uint32_t)mcp->mb[4]) << 16) | mcp->mb[3]);
6846
+
6847
+ if (rval != QLA_SUCCESS) {
6848
+ ql_dbg(ql_dbg_mbx, vha, 0x10e9,
6849
+ "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
6850
+ } else {
6851
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea,
6852
+ "Done %s.\n", __func__);
6853
+ }
6854
+
6855
+ return rval;
6856
+}
6857
+
6858
+int
6859
+ql26xx_led_config(scsi_qla_host_t *vha, uint16_t options, uint16_t *led)
6860
+{
6861
+ struct qla_hw_data *ha = vha->hw;
6862
+ mbx_cmd_t mc;
6863
+ mbx_cmd_t *mcp = &mc;
6864
+ int rval;
6865
+
6866
+ if (!IS_QLA2031(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
6867
+ return QLA_FUNCTION_FAILED;
6868
+
6869
+ ql_dbg(ql_dbg_mbx, vha, 0x7070, "Entered %s (options=%x).\n",
6870
+ __func__, options);
6871
+
6872
+ mcp->mb[0] = MBC_SET_GET_FC_LED_CONFIG;
6873
+ mcp->mb[1] = options;
6874
+ mcp->out_mb = MBX_1|MBX_0;
6875
+ mcp->in_mb = MBX_1|MBX_0;
6876
+ if (options & BIT_0) {
6877
+ if (options & BIT_1) {
6878
+ mcp->mb[2] = led[2];
6879
+ mcp->out_mb |= MBX_2;
6880
+ }
6881
+ if (options & BIT_2) {
6882
+ mcp->mb[3] = led[0];
6883
+ mcp->out_mb |= MBX_3;
6884
+ }
6885
+ if (options & BIT_3) {
6886
+ mcp->mb[4] = led[1];
6887
+ mcp->out_mb |= MBX_4;
6888
+ }
6889
+ } else {
6890
+ mcp->in_mb |= MBX_4|MBX_3|MBX_2;
6891
+ }
6892
+ mcp->tov = MBX_TOV_SECONDS;
6893
+ mcp->flags = 0;
6894
+ rval = qla2x00_mailbox_command(vha, mcp);
6895
+ if (rval) {
6896
+ ql_dbg(ql_dbg_mbx, vha, 0x7071, "Failed %s %x (mb=%x,%x)\n",
6897
+ __func__, rval, mcp->mb[0], mcp->mb[1]);
6898
+ return rval;
6899
+ }
6900
+
6901
+ if (options & BIT_0) {
6902
+ ha->beacon_blink_led = 0;
6903
+ ql_dbg(ql_dbg_mbx, vha, 0x7072, "Done %s\n", __func__);
6904
+ } else {
6905
+ led[2] = mcp->mb[2];
6906
+ led[0] = mcp->mb[3];
6907
+ led[1] = mcp->mb[4];
6908
+ ql_dbg(ql_dbg_mbx, vha, 0x7073, "Done %s (led=%x,%x,%x)\n",
6909
+ __func__, led[0], led[1], led[2]);
6910
+ }
6911
+
6912
+ return rval;
6913
+}