forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
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
....@@ -189,7 +195,7 @@
189195 goto premature_exit;
190196 }
191197
192
- ha->flags.mbox_busy = 1;
198
+
193199 /* Save mailbox command for debug */
194200 ha->mcp = mcp;
195201
....@@ -198,20 +204,21 @@
198204
199205 spin_lock_irqsave(&ha->hardware_lock, flags);
200206
201
- if (ha->flags.purge_mbox || chip_reset != ha->chip_reset) {
207
+ if (ha->flags.purge_mbox || chip_reset != ha->chip_reset ||
208
+ ha->flags.mbox_busy) {
202209 rval = QLA_ABORTED;
203
- ha->flags.mbox_busy = 0;
204210 spin_unlock_irqrestore(&ha->hardware_lock, flags);
205211 goto premature_exit;
206212 }
213
+ ha->flags.mbox_busy = 1;
207214
208215 /* Load mailbox registers. */
209216 if (IS_P3P_TYPE(ha))
210
- optr = (uint16_t __iomem *)&reg->isp82.mailbox_in[0];
217
+ optr = &reg->isp82.mailbox_in[0];
211218 else if (IS_FWI2_CAPABLE(ha) && !(IS_P3P_TYPE(ha)))
212
- optr = (uint16_t __iomem *)&reg->isp24.mailbox0;
219
+ optr = &reg->isp24.mailbox0;
213220 else
214
- optr = (uint16_t __iomem *)MAILBOX_REG(ha, &reg->isp, 0);
221
+ optr = MAILBOX_REG(ha, &reg->isp, 0);
215222
216223 iptr = mcp->mb;
217224 command = mcp->mb[0];
....@@ -221,12 +228,13 @@
221228 "Mailbox registers (OUT):\n");
222229 for (cnt = 0; cnt < ha->mbx_count; cnt++) {
223230 if (IS_QLA2200(ha) && cnt == 8)
224
- optr =
225
- (uint16_t __iomem *)MAILBOX_REG(ha, &reg->isp, 8);
231
+ optr = MAILBOX_REG(ha, &reg->isp, 8);
226232 if (mboxes & BIT_0) {
227233 ql_dbg(ql_dbg_mbx, vha, 0x1112,
228234 "mbox[%d]<-0x%04x\n", cnt, *iptr);
229
- WRT_REG_WORD(optr, *iptr);
235
+ wrt_reg_word(optr, *iptr);
236
+ } else {
237
+ wrt_reg_word(optr, 0);
230238 }
231239
232240 mboxes >>= 1;
....@@ -251,23 +259,12 @@
251259 if ((!abort_active && io_lock_on) || IS_NOPOLLING_TYPE(ha)) {
252260 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
253261
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);
262
+ if (IS_P3P_TYPE(ha))
263
+ wrt_reg_dword(&reg->isp82.hint, HINT_MBX_INT_PENDING);
264
+ else if (IS_FWI2_CAPABLE(ha))
265
+ wrt_reg_dword(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
269266 else
270
- WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT);
267
+ wrt_reg_word(&reg->isp.hccr, HCCR_SET_HOST_INT);
271268 spin_unlock_irqrestore(&ha->hardware_lock, flags);
272269
273270 wait_time = jiffies;
....@@ -280,9 +277,21 @@
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
+ atomic_dec(&ha->num_pend_mbx_stage3);
287
+ rval = QLA_ABORTED;
288
+ goto premature_exit;
289
+ }
283290 } else if (ha->flags.purge_mbox ||
284291 chip_reset != ha->chip_reset) {
292
+ spin_lock_irqsave(&ha->hardware_lock, flags);
285293 ha->flags.mbox_busy = 0;
294
+ spin_unlock_irqrestore(&ha->hardware_lock, flags);
286295 atomic_dec(&ha->num_pend_mbx_stage2);
287296 atomic_dec(&ha->num_pend_mbx_stage3);
288297 rval = QLA_ABORTED;
....@@ -298,29 +307,32 @@
298307 "Cmd=%x Polling Mode.\n", command);
299308
300309 if (IS_P3P_TYPE(ha)) {
301
- if (RD_REG_DWORD(&reg->isp82.hint) &
310
+ if (rd_reg_dword(&reg->isp82.hint) &
302311 HINT_MBX_INT_PENDING) {
312
+ ha->flags.mbox_busy = 0;
303313 spin_unlock_irqrestore(&ha->hardware_lock,
304314 flags);
305
- ha->flags.mbox_busy = 0;
306315 atomic_dec(&ha->num_pend_mbx_stage2);
307316 ql_dbg(ql_dbg_mbx, vha, 0x1012,
308317 "Pending mailbox timeout, exiting.\n");
309318 rval = QLA_FUNCTION_TIMEOUT;
310319 goto premature_exit;
311320 }
312
- WRT_REG_DWORD(&reg->isp82.hint, HINT_MBX_INT_PENDING);
321
+ wrt_reg_dword(&reg->isp82.hint, HINT_MBX_INT_PENDING);
313322 } else if (IS_FWI2_CAPABLE(ha))
314
- WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
323
+ wrt_reg_dword(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
315324 else
316
- WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT);
325
+ wrt_reg_word(&reg->isp.hccr, HCCR_SET_HOST_INT);
317326 spin_unlock_irqrestore(&ha->hardware_lock, flags);
318327
319328 wait_time = jiffies + mcp->tov * HZ; /* wait at most tov secs */
320329 while (!ha->flags.mbox_int) {
321330 if (ha->flags.purge_mbox ||
322331 chip_reset != ha->chip_reset) {
332
+ spin_lock_irqsave(&ha->hardware_lock, flags);
323333 ha->flags.mbox_busy = 0;
334
+ spin_unlock_irqrestore(&ha->hardware_lock,
335
+ flags);
324336 atomic_dec(&ha->num_pend_mbx_stage2);
325337 rval = QLA_ABORTED;
326338 goto premature_exit;
....@@ -355,7 +367,10 @@
355367 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
356368
357369 if (IS_P3P_TYPE(ha) && ha->flags.isp82xx_fw_hung) {
370
+ spin_lock_irqsave(&ha->hardware_lock, flags);
358371 ha->flags.mbox_busy = 0;
372
+ spin_unlock_irqrestore(&ha->hardware_lock, flags);
373
+
359374 /* Setting Link-Down error */
360375 mcp->mb[0] = MBS_LINK_DOWN_ERROR;
361376 ha->mcp = NULL;
....@@ -365,8 +380,12 @@
365380 goto premature_exit;
366381 }
367382
368
- if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE)
383
+ if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE) {
384
+ ql_dbg(ql_dbg_mbx, vha, 0x11ff,
385
+ "mb_out[0] = %#x <> %#x\n", ha->mailbox_out[0],
386
+ MBS_COMMAND_COMPLETE);
369387 rval = QLA_FUNCTION_FAILED;
388
+ }
370389
371390 /* Load return mailbox registers. */
372391 iptr2 = mcp->mb;
....@@ -393,14 +412,14 @@
393412 uint16_t w;
394413
395414 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);
415
+ mb[0] = rd_reg_word(&reg->isp24.mailbox0);
416
+ mb[1] = rd_reg_word(&reg->isp24.mailbox1);
417
+ mb[2] = rd_reg_word(&reg->isp24.mailbox2);
418
+ mb[3] = rd_reg_word(&reg->isp24.mailbox3);
419
+ mb[7] = rd_reg_word(&reg->isp24.mailbox7);
420
+ ictrl = rd_reg_dword(&reg->isp24.ictrl);
421
+ host_status = rd_reg_dword(&reg->isp24.host_status);
422
+ hccr = rd_reg_dword(&reg->isp24.hccr);
404423
405424 ql_log(ql_log_warn, vha, 0xd04c,
406425 "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx "
....@@ -410,7 +429,7 @@
410429
411430 } else {
412431 mb[0] = RD_MAILBOX_REG(ha, &reg->isp, 0);
413
- ictrl = RD_REG_WORD(&reg->isp.ictrl);
432
+ ictrl = rd_reg_word(&reg->isp.ictrl);
414433 ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1119,
415434 "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx "
416435 "mb[0]=0x%x\n", command, ictrl, jiffies, mb[0]);
....@@ -428,7 +447,10 @@
428447 * then only PCI ERR flag would be set.
429448 * we will do premature exit for above case.
430449 */
450
+ spin_lock_irqsave(&ha->hardware_lock, flags);
431451 ha->flags.mbox_busy = 0;
452
+ spin_unlock_irqrestore(&ha->hardware_lock,
453
+ flags);
432454 rval = QLA_FUNCTION_TIMEOUT;
433455 goto premature_exit;
434456 }
....@@ -439,12 +461,13 @@
439461 * a dump
440462 */
441463 if (mcp->mb[0] != MBC_GEN_SYSTEM_ERROR)
442
- ha->isp_ops->fw_dump(vha, 0);
464
+ qla2xxx_dump_fw(vha);
443465 rval = QLA_FUNCTION_TIMEOUT;
444466 }
445467 }
446
-
468
+ spin_lock_irqsave(&ha->hardware_lock, flags);
447469 ha->flags.mbox_busy = 0;
470
+ spin_unlock_irqrestore(&ha->hardware_lock, flags);
448471
449472 /* Clean up */
450473 ha->mcp = NULL;
....@@ -534,9 +557,9 @@
534557 mcp->mb[0]);
535558 } else if (rval) {
536559 if (ql2xextended_error_logging & (ql_dbg_disc|ql_dbg_mbx)) {
537
- pr_warn("%s [%s]-%04x:%ld: **** Failed", QL_MSGHDR,
560
+ pr_warn("%s [%s]-%04x:%ld: **** Failed=%x", QL_MSGHDR,
538561 dev_name(&ha->pdev->dev), 0x1020+0x800,
539
- vha->host_no);
562
+ vha->host_no, rval);
540563 mboxes = mcp->in_mb;
541564 cnt = 4;
542565 for (i = 0; i < ha->mbx_count && cnt; i++, mboxes >>= 1)
....@@ -549,15 +572,15 @@
549572 if (IS_FWI2_CAPABLE(ha) && !(IS_P3P_TYPE(ha))) {
550573 ql_dbg(ql_dbg_mbx, vha, 0x1198,
551574 "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));
575
+ rd_reg_dword(&reg->isp24.host_status),
576
+ rd_reg_dword(&reg->isp24.ictrl),
577
+ rd_reg_dword(&reg->isp24.istatus));
555578 } else {
556579 ql_dbg(ql_dbg_mbx, vha, 0x1206,
557580 "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));
581
+ rd_reg_word(&reg->isp.ctrl_status),
582
+ rd_reg_word(&reg->isp.ictrl),
583
+ rd_reg_word(&reg->isp.istatus));
561584 }
562585 } else {
563586 ql_dbg(ql_dbg_mbx, base_vha, 0x1021, "Done %s.\n", __func__);
....@@ -601,14 +624,15 @@
601624 mcp->out_mb |= MBX_4;
602625 }
603626
604
- mcp->in_mb = MBX_0;
627
+ mcp->in_mb = MBX_1|MBX_0;
605628 mcp->tov = MBX_TOV_SECONDS;
606629 mcp->flags = 0;
607630 rval = qla2x00_mailbox_command(vha, mcp);
608631
609632 if (rval != QLA_SUCCESS) {
610633 ql_dbg(ql_dbg_mbx, vha, 0x1023,
611
- "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
634
+ "Failed=%x mb[0]=%x mb[1]=%x.\n",
635
+ rval, mcp->mb[0], mcp->mb[1]);
612636 } else {
613637 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1024,
614638 "Done %s.\n", __func__);
....@@ -617,30 +641,7 @@
617641 return rval;
618642 }
619643
620
-#define EXTENDED_BB_CREDITS BIT_0
621644 #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
-}
644645
645646 /*
646647 * qla2x00_execute_fw
....@@ -664,10 +665,14 @@
664665 struct qla_hw_data *ha = vha->hw;
665666 mbx_cmd_t mc;
666667 mbx_cmd_t *mcp = &mc;
668
+ u8 semaphore = 0;
669
+#define EXE_FW_FORCE_SEMAPHORE BIT_7
670
+ u8 retry = 3;
667671
668672 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1025,
669673 "Entered %s.\n", __func__);
670674
675
+again:
671676 mcp->mb[0] = MBC_EXECUTE_FIRMWARE;
672677 mcp->out_mb = MBX_0;
673678 mcp->in_mb = MBX_0;
....@@ -677,41 +682,33 @@
677682 mcp->mb[3] = 0;
678683 mcp->mb[4] = 0;
679684 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
- }
685
+
686
+ /* Enable BPM? */
687
+ if (ha->flags.lr_detected) {
688
+ mcp->mb[4] = BIT_0;
689
+ if (IS_BPM_RANGE_CAPABLE(ha))
690
+ mcp->mb[4] |=
691
+ ha->lr_distance << LR_DIST_FW_POS;
699692 }
700693
701
- if (ql2xnvmeenable && IS_QLA27XX(ha))
694
+ if (ql2xnvmeenable && (IS_QLA27XX(ha) || IS_QLA28XX(ha)))
702695 mcp->mb[4] |= NVME_ENABLE_FLAG;
703696
704
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
697
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
705698 struct nvram_81xx *nv = ha->nvram;
706699 /* set minimum speed if specified in nvram */
707
- if (nv->min_link_speed >= 2 &&
708
- nv->min_link_speed <= 5) {
700
+ if (nv->min_supported_speed >= 2 &&
701
+ nv->min_supported_speed <= 5) {
709702 mcp->mb[4] |= BIT_4;
710
- mcp->mb[11] = nv->min_link_speed;
703
+ mcp->mb[11] |= nv->min_supported_speed & 0xF;
711704 mcp->out_mb |= MBX_11;
712705 mcp->in_mb |= BIT_5;
713
- vha->min_link_speed_feat = nv->min_link_speed;
706
+ vha->min_supported_speed =
707
+ nv->min_supported_speed;
714708 }
709
+
710
+ if (IS_PPCARCH)
711
+ mcp->mb[11] |= BIT_4;
715712 }
716713
717714 if (ha->flags.exlogins_enabled)
....@@ -719,6 +716,9 @@
719716
720717 if (ha->flags.exchoffld_enabled)
721718 mcp->mb[4] |= ENABLE_EXCHANGE_OFFLD;
719
+
720
+ if (semaphore)
721
+ mcp->mb[11] |= EXE_FW_FORCE_SEMAPHORE;
722722
723723 mcp->out_mb |= MBX_4 | MBX_3 | MBX_2 | MBX_1 | MBX_11;
724724 mcp->in_mb |= MBX_3 | MBX_2 | MBX_1;
....@@ -736,35 +736,49 @@
736736 rval = qla2x00_mailbox_command(vha, mcp);
737737
738738 if (rval != QLA_SUCCESS) {
739
+ if (IS_QLA28XX(ha) && rval == QLA_COMMAND_ERROR &&
740
+ mcp->mb[1] == 0x27 && retry) {
741
+ semaphore = 1;
742
+ retry--;
743
+ ql_dbg(ql_dbg_async, vha, 0x1026,
744
+ "Exe FW: force semaphore.\n");
745
+ goto again;
746
+ }
747
+
739748 ql_dbg(ql_dbg_mbx, vha, 0x1026,
740749 "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");
750
+ return rval;
767751 }
752
+
753
+ if (!IS_FWI2_CAPABLE(ha))
754
+ goto done;
755
+
756
+ ha->fw_ability_mask = mcp->mb[3] << 16 | mcp->mb[2];
757
+ ql_dbg(ql_dbg_mbx, vha, 0x119a,
758
+ "fw_ability_mask=%x.\n", ha->fw_ability_mask);
759
+ ql_dbg(ql_dbg_mbx, vha, 0x1027, "exchanges=%x.\n", mcp->mb[1]);
760
+ if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
761
+ ha->max_supported_speed = mcp->mb[2] & (BIT_0|BIT_1);
762
+ ql_dbg(ql_dbg_mbx, vha, 0x119b, "max_supported_speed=%s.\n",
763
+ ha->max_supported_speed == 0 ? "16Gps" :
764
+ ha->max_supported_speed == 1 ? "32Gps" :
765
+ ha->max_supported_speed == 2 ? "64Gps" : "unknown");
766
+ if (vha->min_supported_speed) {
767
+ ha->min_supported_speed = mcp->mb[5] &
768
+ (BIT_0 | BIT_1 | BIT_2);
769
+ ql_dbg(ql_dbg_mbx, vha, 0x119c,
770
+ "min_supported_speed=%s.\n",
771
+ ha->min_supported_speed == 6 ? "64Gps" :
772
+ ha->min_supported_speed == 5 ? "32Gps" :
773
+ ha->min_supported_speed == 4 ? "16Gps" :
774
+ ha->min_supported_speed == 3 ? "8Gps" :
775
+ ha->min_supported_speed == 2 ? "4Gps" : "unknown");
776
+ }
777
+ }
778
+
779
+done:
780
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1028,
781
+ "Done %s.\n", __func__);
768782
769783 return rval;
770784 }
....@@ -841,7 +855,7 @@
841855 * Context:
842856 * Kernel context.
843857 */
844
-#define CONFIG_XLOGINS_MEM 0x3
858
+#define CONFIG_XLOGINS_MEM 0x9
845859 int
846860 qla_set_exlogin_mem_cfg(scsi_qla_host_t *vha, dma_addr_t phys_addr)
847861 {
....@@ -868,8 +882,9 @@
868882 mcp->flags = 0;
869883 rval = qla2x00_mailbox_command(vha, mcp);
870884 if (rval != QLA_SUCCESS) {
871
- /*EMPTY*/
872
- ql_dbg(ql_dbg_mbx, vha, 0x111b, "Failed=%x.\n", rval);
885
+ ql_dbg(ql_dbg_mbx, vha, 0x111b,
886
+ "EXlogin Failed=%x. MB0=%x MB11=%x\n",
887
+ rval, mcp->mb[0], mcp->mb[11]);
873888 } else {
874889 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118c,
875890 "Done %s.\n", __func__);
....@@ -1021,10 +1036,10 @@
10211036 mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8;
10221037 if (IS_FWI2_CAPABLE(ha))
10231038 mcp->in_mb |= MBX_17|MBX_16|MBX_15;
1024
- if (IS_QLA27XX(ha))
1039
+ if (IS_QLA27XX(ha) || IS_QLA28XX(ha))
10251040 mcp->in_mb |=
10261041 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;
1042
+ MBX_14|MBX_13|MBX_11|MBX_10|MBX_9|MBX_8|MBX_7;
10281043
10291044 mcp->flags = 0;
10301045 mcp->tov = MBX_TOV_SECONDS;
....@@ -1077,15 +1092,31 @@
10771092 * FW supports nvme and driver load parameter requested nvme.
10781093 * BIT 26 of fw_attributes indicates NVMe support.
10791094 */
1080
- if ((ha->fw_attributes_h & 0x400) && ql2xnvmeenable) {
1095
+ if ((ha->fw_attributes_h &
1096
+ (FW_ATTR_H_NVME | FW_ATTR_H_NVME_UPDATED)) &&
1097
+ ql2xnvmeenable) {
1098
+ if (ha->fw_attributes_h & FW_ATTR_H_NVME_FBURST)
1099
+ vha->flags.nvme_first_burst = 1;
1100
+
10811101 vha->flags.nvme_enabled = 1;
10821102 ql_log(ql_log_info, vha, 0xd302,
10831103 "%s: FC-NVMe is Enabled (0x%x)\n",
10841104 __func__, ha->fw_attributes_h);
10851105 }
1106
+
1107
+ /* BIT_13 of Extended FW Attributes informs about NVMe2 support */
1108
+ if (ha->fw_attributes_ext[0] & FW_ATTR_EXT0_NVME2) {
1109
+ ql_log(ql_log_info, vha, 0xd302,
1110
+ "Firmware supports NVMe2 0x%x\n",
1111
+ ha->fw_attributes_ext[0]);
1112
+ vha->flags.nvme2_enabled = 1;
1113
+ }
10861114 }
10871115
1088
- if (IS_QLA27XX(ha)) {
1116
+ if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
1117
+ ha->serdes_version[0] = mcp->mb[7] & 0xff;
1118
+ ha->serdes_version[1] = mcp->mb[8] >> 8;
1119
+ ha->serdes_version[2] = mcp->mb[8] & 0xff;
10891120 ha->mpi_version[0] = mcp->mb[10] & 0xff;
10901121 ha->mpi_version[1] = mcp->mb[11] >> 8;
10911122 ha->mpi_version[2] = mcp->mb[11] & 0xff;
....@@ -1096,6 +1127,31 @@
10961127 ha->fw_shared_ram_end = (mcp->mb[21] << 16) | mcp->mb[20];
10971128 ha->fw_ddr_ram_start = (mcp->mb[23] << 16) | mcp->mb[22];
10981129 ha->fw_ddr_ram_end = (mcp->mb[25] << 16) | mcp->mb[24];
1130
+ if (IS_QLA28XX(ha)) {
1131
+ if (mcp->mb[16] & BIT_10)
1132
+ ha->flags.secure_fw = 1;
1133
+
1134
+ ql_log(ql_log_info, vha, 0xffff,
1135
+ "Secure Flash Update in FW: %s\n",
1136
+ (ha->flags.secure_fw) ? "Supported" :
1137
+ "Not Supported");
1138
+ }
1139
+
1140
+ if (ha->flags.scm_supported_a &&
1141
+ (ha->fw_attributes_ext[0] & FW_ATTR_EXT0_SCM_SUPPORTED)) {
1142
+ ha->flags.scm_supported_f = 1;
1143
+ ha->sf_init_cb->flags |= cpu_to_le16(BIT_13);
1144
+ }
1145
+ ql_log(ql_log_info, vha, 0x11a3, "SCM in FW: %s\n",
1146
+ (ha->flags.scm_supported_f) ? "Supported" :
1147
+ "Not Supported");
1148
+
1149
+ if (vha->flags.nvme2_enabled) {
1150
+ /* set BIT_15 of special feature control block for SLER */
1151
+ ha->sf_init_cb->flags |= cpu_to_le16(BIT_15);
1152
+ /* set BIT_14 of special feature control block for PI CTRL*/
1153
+ ha->sf_init_cb->flags |= cpu_to_le16(BIT_14);
1154
+ }
10991155 }
11001156
11011157 failed:
....@@ -1358,17 +1414,20 @@
13581414 mbx_cmd_t mc;
13591415 mbx_cmd_t *mcp = &mc;
13601416
1417
+ if (!vha->hw->flags.fw_started)
1418
+ return QLA_INVALID_COMMAND;
1419
+
13611420 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1038,
13621421 "Entered %s.\n", __func__);
13631422
13641423 mcp->mb[0] = MBC_IOCB_COMMAND_A64;
13651424 mcp->mb[1] = 0;
1366
- mcp->mb[2] = MSW(phys_addr);
1367
- mcp->mb[3] = LSW(phys_addr);
1425
+ mcp->mb[2] = MSW(LSD(phys_addr));
1426
+ mcp->mb[3] = LSW(LSD(phys_addr));
13681427 mcp->mb[6] = MSW(MSD(phys_addr));
13691428 mcp->mb[7] = LSW(MSD(phys_addr));
13701429 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
1371
- mcp->in_mb = MBX_2|MBX_0;
1430
+ mcp->in_mb = MBX_1|MBX_0;
13721431 mcp->tov = tov;
13731432 mcp->flags = 0;
13741433 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -1377,13 +1436,14 @@
13771436 /*EMPTY*/
13781437 ql_dbg(ql_dbg_mbx, vha, 0x1039, "Failed=%x.\n", rval);
13791438 } else {
1380
- sts_entry_t *sts_entry = (sts_entry_t *) buffer;
1439
+ sts_entry_t *sts_entry = buffer;
13811440
13821441 /* Mask reserved bits. */
13831442 sts_entry->entry_status &=
13841443 IS_FWI2_CAPABLE(vha->hw) ? RF_MASK_24XX : RF_MASK;
13851444 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103a,
1386
- "Done %s.\n", __func__);
1445
+ "Done %s (status=%x).\n", __func__,
1446
+ sts_entry->entry_status);
13871447 }
13881448
13891449 return rval;
....@@ -1428,7 +1488,7 @@
14281488 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103b,
14291489 "Entered %s.\n", __func__);
14301490
1431
- if (vha->flags.qpairs_available && sp->qpair)
1491
+ if (sp->qpair)
14321492 req = sp->qpair->req;
14331493 else
14341494 req = vha->req;
....@@ -1476,17 +1536,12 @@
14761536 mbx_cmd_t mc;
14771537 mbx_cmd_t *mcp = &mc;
14781538 scsi_qla_host_t *vha;
1479
- struct req_que *req;
1480
- struct rsp_que *rsp;
14811539
1482
- l = l;
14831540 vha = fcport->vha;
14841541
14851542 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x103e,
14861543 "Entered %s.\n", __func__);
14871544
1488
- req = vha->hw->req_q_map[0];
1489
- rsp = req->rsp;
14901545 mcp->mb[0] = MBC_ABORT_TARGET;
14911546 mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0;
14921547 if (HAS_EXTENDED_IDS(vha->hw)) {
....@@ -1509,7 +1564,7 @@
15091564 }
15101565
15111566 /* Issue marker IOCB. */
1512
- rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, 0,
1567
+ rval2 = qla2x00_marker(vha, vha->hw->base_qpair, fcport->loop_id, 0,
15131568 MK_SYNC_ID);
15141569 if (rval2 != QLA_SUCCESS) {
15151570 ql_dbg(ql_dbg_mbx, vha, 0x1040,
....@@ -1529,16 +1584,12 @@
15291584 mbx_cmd_t mc;
15301585 mbx_cmd_t *mcp = &mc;
15311586 scsi_qla_host_t *vha;
1532
- struct req_que *req;
1533
- struct rsp_que *rsp;
15341587
15351588 vha = fcport->vha;
15361589
15371590 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1042,
15381591 "Entered %s.\n", __func__);
15391592
1540
- req = vha->hw->req_q_map[0];
1541
- rsp = req->rsp;
15421593 mcp->mb[0] = MBC_LUN_RESET;
15431594 mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0;
15441595 if (HAS_EXTENDED_IDS(vha->hw))
....@@ -1558,7 +1609,7 @@
15581609 }
15591610
15601611 /* Issue marker IOCB. */
1561
- rval2 = qla2x00_marker(vha, req, rsp, fcport->loop_id, l,
1612
+ rval2 = qla2x00_marker(vha, vha->hw->base_qpair, fcport->loop_id, l,
15621613 MK_SYNC_ID_LUN);
15631614 if (rval2 != QLA_SUCCESS) {
15641615 ql_dbg(ql_dbg_mbx, vha, 0x1044,
....@@ -1610,8 +1661,9 @@
16101661 mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10;
16111662 if (IS_FWI2_CAPABLE(vha->hw))
16121663 mcp->in_mb |= MBX_19|MBX_18|MBX_17|MBX_16;
1613
- if (IS_QLA27XX(vha->hw))
1614
- mcp->in_mb |= MBX_15;
1664
+ if (IS_QLA27XX(vha->hw) || IS_QLA28XX(vha->hw))
1665
+ mcp->in_mb |= MBX_15|MBX_21|MBX_22|MBX_23;
1666
+
16151667 mcp->tov = MBX_TOV_SECONDS;
16161668 mcp->flags = 0;
16171669 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -1664,8 +1716,22 @@
16641716 }
16651717 }
16661718
1667
- if (IS_QLA27XX(vha->hw))
1719
+ if (IS_QLA27XX(vha->hw) || IS_QLA28XX(vha->hw)) {
16681720 vha->bbcr = mcp->mb[15];
1721
+ if (mcp->mb[7] & SCM_EDC_ACC_RECEIVED) {
1722
+ ql_log(ql_log_info, vha, 0x11a4,
1723
+ "SCM: EDC ELS completed, flags 0x%x\n",
1724
+ mcp->mb[21]);
1725
+ }
1726
+ if (mcp->mb[7] & SCM_RDF_ACC_RECEIVED) {
1727
+ vha->hw->flags.scm_enabled = 1;
1728
+ vha->scm_fabric_connection_flags |=
1729
+ SCM_FLAG_RDF_COMPLETED;
1730
+ ql_log(ql_log_info, vha, 0x11a5,
1731
+ "SCM: RDF ELS completed, flags 0x%x\n",
1732
+ mcp->mb[23]);
1733
+ }
1734
+ }
16691735 }
16701736
16711737 return rval;
....@@ -1778,9 +1844,20 @@
17781844 mcp->mb[14] = sizeof(*ha->ex_init_cb);
17791845 mcp->out_mb |= MBX_14|MBX_13|MBX_12|MBX_11|MBX_10;
17801846 }
1847
+
1848
+ if (ha->flags.scm_supported_f || vha->flags.nvme2_enabled) {
1849
+ mcp->mb[1] |= BIT_1;
1850
+ mcp->mb[16] = MSW(ha->sf_init_cb_dma);
1851
+ mcp->mb[17] = LSW(ha->sf_init_cb_dma);
1852
+ mcp->mb[18] = MSW(MSD(ha->sf_init_cb_dma));
1853
+ mcp->mb[19] = LSW(MSD(ha->sf_init_cb_dma));
1854
+ mcp->mb[15] = sizeof(*ha->sf_init_cb);
1855
+ mcp->out_mb |= MBX_19|MBX_18|MBX_17|MBX_16|MBX_15;
1856
+ }
1857
+
17811858 /* 1 and 2 should normally be captured. */
17821859 mcp->in_mb = MBX_2|MBX_1|MBX_0;
1783
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha))
1860
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
17841861 /* mb3 is additional info about the installed SFP. */
17851862 mcp->in_mb |= MBX_3;
17861863 mcp->buf_size = size;
....@@ -1791,10 +1868,20 @@
17911868 if (rval != QLA_SUCCESS) {
17921869 /*EMPTY*/
17931870 ql_dbg(ql_dbg_mbx, vha, 0x104d,
1794
- "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x,.\n",
1871
+ "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x.\n",
17951872 rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3]);
1873
+ if (ha->init_cb) {
1874
+ ql_dbg(ql_dbg_mbx, vha, 0x104d, "init_cb:\n");
1875
+ ql_dump_buffer(ql_dbg_init + ql_dbg_verbose, vha,
1876
+ 0x0104d, ha->init_cb, sizeof(*ha->init_cb));
1877
+ }
1878
+ if (ha->ex_init_cb && ha->ex_init_cb->ex_version) {
1879
+ ql_dbg(ql_dbg_mbx, vha, 0x104d, "ex_init_cb:\n");
1880
+ ql_dump_buffer(ql_dbg_init + ql_dbg_verbose, vha,
1881
+ 0x0104d, ha->ex_init_cb, sizeof(*ha->ex_init_cb));
1882
+ }
17961883 } else {
1797
- if (IS_QLA27XX(ha)) {
1884
+ if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
17981885 if (mcp->mb[2] == 6 || mcp->mb[3] == 2)
17991886 ql_dbg(ql_dbg_mbx, vha, 0x119d,
18001887 "Invalid SFP/Validation Failed\n");
....@@ -1884,7 +1971,7 @@
18841971 pd24 = (struct port_database_24xx *) pd;
18851972
18861973 /* Check for logged in state. */
1887
- if (fcport->fc4f_nvme) {
1974
+ if (NVME_TARGET(ha, fcport)) {
18881975 current_login_state = pd24->current_login_state >> 4;
18891976 last_login_state = pd24->last_login_state >> 4;
18901977 } else {
....@@ -1978,7 +2065,7 @@
19782065
19792066 /* Passback COS information. */
19802067 fcport->supported_classes = (pd->options & BIT_4) ?
1981
- FC_COS_CLASS2: FC_COS_CLASS3;
2068
+ FC_COS_CLASS2 : FC_COS_CLASS3;
19822069 }
19832070
19842071 gpd_error_out:
....@@ -1993,6 +2080,57 @@
19932080 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1053,
19942081 "Done %s.\n", __func__);
19952082 }
2083
+
2084
+ return rval;
2085
+}
2086
+
2087
+int
2088
+qla24xx_get_port_database(scsi_qla_host_t *vha, u16 nport_handle,
2089
+ struct port_database_24xx *pdb)
2090
+{
2091
+ mbx_cmd_t mc;
2092
+ mbx_cmd_t *mcp = &mc;
2093
+ dma_addr_t pdb_dma;
2094
+ int rval;
2095
+
2096
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1115,
2097
+ "Entered %s.\n", __func__);
2098
+
2099
+ memset(pdb, 0, sizeof(*pdb));
2100
+
2101
+ pdb_dma = dma_map_single(&vha->hw->pdev->dev, pdb,
2102
+ sizeof(*pdb), DMA_FROM_DEVICE);
2103
+ if (!pdb_dma) {
2104
+ ql_log(ql_log_warn, vha, 0x1116, "Failed to map dma buffer.\n");
2105
+ return QLA_MEMORY_ALLOC_FAILED;
2106
+ }
2107
+
2108
+ mcp->mb[0] = MBC_GET_PORT_DATABASE;
2109
+ mcp->mb[1] = nport_handle;
2110
+ mcp->mb[2] = MSW(LSD(pdb_dma));
2111
+ mcp->mb[3] = LSW(LSD(pdb_dma));
2112
+ mcp->mb[6] = MSW(MSD(pdb_dma));
2113
+ mcp->mb[7] = LSW(MSD(pdb_dma));
2114
+ mcp->mb[9] = 0;
2115
+ mcp->mb[10] = 0;
2116
+ mcp->out_mb = MBX_10|MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
2117
+ mcp->in_mb = MBX_1|MBX_0;
2118
+ mcp->buf_size = sizeof(*pdb);
2119
+ mcp->flags = MBX_DMA_IN;
2120
+ mcp->tov = vha->hw->login_timeout * 2;
2121
+ rval = qla2x00_mailbox_command(vha, mcp);
2122
+
2123
+ if (rval != QLA_SUCCESS) {
2124
+ ql_dbg(ql_dbg_mbx, vha, 0x111a,
2125
+ "Failed=%x mb[0]=%x mb[1]=%x.\n",
2126
+ rval, mcp->mb[0], mcp->mb[1]);
2127
+ } else {
2128
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x111b,
2129
+ "Done %s.\n", __func__);
2130
+ }
2131
+
2132
+ dma_unmap_single(&vha->hw->pdev->dev, pdb_dma,
2133
+ sizeof(*pdb), DMA_FROM_DEVICE);
19962134
19972135 return rval;
19982136 }
....@@ -2048,7 +2186,7 @@
20482186 /*EMPTY*/
20492187 ql_dbg(ql_dbg_mbx, vha, 0x1055, "Failed=%x.\n", rval);
20502188 } else {
2051
- if (IS_QLA27XX(ha)) {
2189
+ if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
20522190 if (mcp->mb[2] == 6 || mcp->mb[3] == 2)
20532191 ql_dbg(ql_dbg_mbx, vha, 0x119e,
20542192 "Invalid SFP/Validation Failed\n");
....@@ -2202,7 +2340,7 @@
22022340 mbx_cmd_t mc;
22032341 mbx_cmd_t *mcp = &mc;
22042342
2205
- ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105a,
2343
+ ql_dbg(ql_dbg_disc, vha, 0x105a,
22062344 "Entered %s.\n", __func__);
22072345
22082346 if (IS_CNA_CAPABLE(vha->hw)) {
....@@ -2213,10 +2351,7 @@
22132351 mcp->out_mb = MBX_2|MBX_1|MBX_0;
22142352 } else if (IS_FWI2_CAPABLE(vha->hw)) {
22152353 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 */
2354
+ mcp->mb[1] = BIT_4;
22202355 mcp->mb[2] = 0;
22212356 mcp->mb[3] = vha->hw->loop_reset_delay;
22222357 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
....@@ -2339,7 +2474,7 @@
23392474
23402475 lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
23412476 lg->entry_count = 1;
2342
- lg->handle = MAKE_HANDLE(req->id, lg->handle);
2477
+ lg->handle = make_handle(req->id, lg->handle);
23432478 lg->nport_handle = cpu_to_le16(loop_id);
23442479 lg->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI);
23452480 if (opt & BIT_0)
....@@ -2609,7 +2744,7 @@
26092744 req = vha->req;
26102745 lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
26112746 lg->entry_count = 1;
2612
- lg->handle = MAKE_HANDLE(req->id, lg->handle);
2747
+ lg->handle = make_handle(req->id, lg->handle);
26132748 lg->nport_handle = cpu_to_le16(loop_id);
26142749 lg->control_flags =
26152750 cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO|
....@@ -2726,7 +2861,7 @@
27262861 "Entered %s.\n", __func__);
27272862
27282863 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
2729
- mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_3 : 0;
2864
+ mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_4 : 0;
27302865 mcp->mb[2] = 0;
27312866 mcp->mb[3] = 0;
27322867 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
....@@ -2834,7 +2969,8 @@
28342969 mcp->mb[0] = MBC_GET_RESOURCE_COUNTS;
28352970 mcp->out_mb = MBX_0;
28362971 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))
2972
+ if (IS_QLA81XX(ha) || IS_QLA83XX(ha) ||
2973
+ IS_QLA27XX(ha) || IS_QLA28XX(ha))
28382974 mcp->in_mb |= MBX_12;
28392975 mcp->tov = MBX_TOV_SECONDS;
28402976 mcp->flags = 0;
....@@ -2859,7 +2995,7 @@
28592995 ha->orig_fw_iocb_count = mcp->mb[10];
28602996 if (ha->flags.npiv_supported)
28612997 ha->max_npiv_vports = mcp->mb[11];
2862
- if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha))
2998
+ if (IS_QLA81XX(ha) || IS_QLA83XX(ha))
28632999 ha->fw_max_fcf_count = mcp->mb[12];
28643000 }
28653001
....@@ -2881,7 +3017,8 @@
28813017 * Kernel context.
28823018 */
28833019 int
2884
-qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map)
3020
+qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map,
3021
+ u8 *num_entries)
28853022 {
28863023 int rval;
28873024 mbx_cmd_t mc;
....@@ -2921,6 +3058,8 @@
29213058
29223059 if (pos_map)
29233060 memcpy(pos_map, pmap, FCAL_MAP_SIZE);
3061
+ if (num_entries)
3062
+ *num_entries = pmap[0];
29243063 }
29253064 dma_pool_free(ha->s_dma_pool, pmap, pmap_dma);
29263065
....@@ -2954,7 +3093,7 @@
29543093 int rval;
29553094 mbx_cmd_t mc;
29563095 mbx_cmd_t *mcp = &mc;
2957
- uint32_t *iter = (void *)stats;
3096
+ uint32_t *iter = (uint32_t *)stats;
29583097 ushort dwords = offsetof(typeof(*stats), link_up_cnt)/sizeof(*iter);
29593098 struct qla_hw_data *ha = vha->hw;
29603099
....@@ -3013,20 +3152,21 @@
30133152 int rval;
30143153 mbx_cmd_t mc;
30153154 mbx_cmd_t *mcp = &mc;
3016
- uint32_t *iter, dwords;
3155
+ uint32_t *iter = (uint32_t *)stats;
3156
+ ushort dwords = sizeof(*stats)/sizeof(*iter);
30173157
30183158 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1088,
30193159 "Entered %s.\n", __func__);
30203160
30213161 memset(&mc, 0, sizeof(mc));
30223162 mc.mb[0] = MBC_GET_LINK_PRIV_STATS;
3023
- mc.mb[2] = MSW(stats_dma);
3024
- mc.mb[3] = LSW(stats_dma);
3163
+ mc.mb[2] = MSW(LSD(stats_dma));
3164
+ mc.mb[3] = LSW(LSD(stats_dma));
30253165 mc.mb[6] = MSW(MSD(stats_dma));
30263166 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);
3167
+ mc.mb[8] = dwords;
3168
+ mc.mb[9] = vha->vp_idx;
3169
+ mc.mb[10] = options;
30303170
30313171 rval = qla24xx_send_mb_cmd(vha, &mc);
30323172
....@@ -3039,8 +3179,6 @@
30393179 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108a,
30403180 "Done %s.\n", __func__);
30413181 /* Re-endianize - firmware data is le32. */
3042
- dwords = sizeof(struct link_statistics) / 4;
3043
- iter = &stats->link_fail_cnt;
30443182 for ( ; dwords--; iter++)
30453183 le32_to_cpus(iter);
30463184 }
....@@ -3065,22 +3203,25 @@
30653203 struct scsi_qla_host *vha = fcport->vha;
30663204 struct qla_hw_data *ha = vha->hw;
30673205 struct req_que *req = vha->req;
3206
+ struct qla_qpair *qpair = sp->qpair;
30683207
30693208 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108c,
30703209 "Entered %s.\n", __func__);
30713210
30723211 if (sp->qpair)
30733212 req = sp->qpair->req;
3213
+ else
3214
+ return QLA_FUNCTION_FAILED;
30743215
30753216 if (ql2xasynctmfenable)
30763217 return qla24xx_async_abort_command(sp);
30773218
3078
- spin_lock_irqsave(&ha->hardware_lock, flags);
3219
+ spin_lock_irqsave(qpair->qp_lock_ptr, flags);
30793220 for (handle = 1; handle < req->num_outstanding_cmds; handle++) {
30803221 if (req->outstanding_cmds[handle] == sp)
30813222 break;
30823223 }
3083
- spin_unlock_irqrestore(&ha->hardware_lock, flags);
3224
+ spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
30843225 if (handle == req->num_outstanding_cmds) {
30853226 /* Command not found. */
30863227 return QLA_FUNCTION_FAILED;
....@@ -3095,9 +3236,9 @@
30953236
30963237 abt->entry_type = ABORT_IOCB_TYPE;
30973238 abt->entry_count = 1;
3098
- abt->handle = MAKE_HANDLE(req->id, abt->handle);
3239
+ abt->handle = make_handle(req->id, abt->handle);
30993240 abt->nport_handle = cpu_to_le16(fcport->loop_id);
3100
- abt->handle_to_abort = MAKE_HANDLE(req->id, handle);
3241
+ abt->handle_to_abort = make_handle(req->id, handle);
31013242 abt->port_id[0] = fcport->d_id.b.al_pa;
31023243 abt->port_id[1] = fcport->d_id.b.area;
31033244 abt->port_id[2] = fcport->d_id.b.domain;
....@@ -3118,7 +3259,7 @@
31183259 ql_dbg(ql_dbg_mbx, vha, 0x1090,
31193260 "Failed to complete IOCB -- completion status (%x).\n",
31203261 le16_to_cpu(abt->nport_handle));
3121
- if (abt->nport_handle == CS_IOCB_ERROR)
3262
+ if (abt->nport_handle == cpu_to_le16(CS_IOCB_ERROR))
31223263 rval = QLA_FUNCTION_PARAMETER_ERROR;
31233264 else
31243265 rval = QLA_FUNCTION_FAILED;
....@@ -3150,7 +3291,6 @@
31503291 scsi_qla_host_t *vha;
31513292 struct qla_hw_data *ha;
31523293 struct req_que *req;
3153
- struct rsp_que *rsp;
31543294 struct qla_qpair *qpair;
31553295
31563296 vha = fcport->vha;
....@@ -3163,10 +3303,7 @@
31633303 if (vha->vp_idx && vha->qpair) {
31643304 /* NPIV port */
31653305 qpair = vha->qpair;
3166
- rsp = qpair->rsp;
31673306 req = qpair->req;
3168
- } else {
3169
- rsp = req->rsp;
31703307 }
31713308
31723309 tsk = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma);
....@@ -3178,7 +3315,7 @@
31783315
31793316 tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE;
31803317 tsk->p.tsk.entry_count = 1;
3181
- tsk->p.tsk.handle = MAKE_HANDLE(req->id, tsk->p.tsk.handle);
3318
+ tsk->p.tsk.handle = make_handle(req->id, tsk->p.tsk.handle);
31823319 tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id);
31833320 tsk->p.tsk.timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
31843321 tsk->p.tsk.control_flags = cpu_to_le32(type);
....@@ -3223,8 +3360,8 @@
32233360 }
32243361
32253362 /* 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);
3363
+ rval2 = qla2x00_marker(vha, ha->base_qpair, fcport->loop_id, l,
3364
+ type == TCF_LUN_RESET ? MK_SYNC_ID_LUN : MK_SYNC_ID);
32283365 if (rval2 != QLA_SUCCESS) {
32293366 ql_dbg(ql_dbg_mbx, vha, 0x1099,
32303367 "Failed to issue marker IOCB (%x).\n", rval2);
....@@ -3299,7 +3436,7 @@
32993436 mbx_cmd_t *mcp = &mc;
33003437
33013438 if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) &&
3302
- !IS_QLA27XX(vha->hw))
3439
+ !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw))
33033440 return QLA_FUNCTION_FAILED;
33043441
33053442 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1182,
....@@ -3338,7 +3475,7 @@
33383475 mbx_cmd_t *mcp = &mc;
33393476
33403477 if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) &&
3341
- !IS_QLA27XX(vha->hw))
3478
+ !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw))
33423479 return QLA_FUNCTION_FAILED;
33433480
33443481 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1185,
....@@ -3444,9 +3581,9 @@
34443581 /**
34453582 * qla2x00_set_serdes_params() -
34463583 * @vha: HA context
3447
- * @sw_em_1g:
3448
- * @sw_em_2g:
3449
- * @sw_em_4g:
3584
+ * @sw_em_1g: serial link options
3585
+ * @sw_em_2g: serial link options
3586
+ * @sw_em_4g: serial link options
34503587 *
34513588 * Returns
34523589 */
....@@ -3607,7 +3744,8 @@
36073744 "Entered %s.\n", __func__);
36083745
36093746 if (!IS_QLA25XX(vha->hw) && !IS_QLA81XX(vha->hw) &&
3610
- !IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw))
3747
+ !IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw) &&
3748
+ !IS_QLA28XX(vha->hw))
36113749 return QLA_FUNCTION_FAILED;
36123750
36133751 if (unlikely(pci_channel_offline(vha->hw->pdev)))
....@@ -3720,7 +3858,7 @@
37203858 rval = qla2x00_mailbox_command(vha, mcp);
37213859
37223860 /* Return mailbox statuses. */
3723
- if (mb != NULL) {
3861
+ if (mb) {
37243862 mb[0] = mcp->mb[0];
37253863 mb[1] = mcp->mb[1];
37263864 mb[3] = mcp->mb[3];
....@@ -3755,7 +3893,7 @@
37553893 mcp->mb[0] = MBC_PORT_PARAMS;
37563894 mcp->mb[1] = loop_id;
37573895 mcp->mb[2] = BIT_0;
3758
- mcp->mb[3] = port_speed & (BIT_5|BIT_4|BIT_3|BIT_2|BIT_1|BIT_0);
3896
+ mcp->mb[3] = port_speed & 0x3F;
37593897 mcp->mb[9] = vha->vp_idx;
37603898 mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0;
37613899 mcp->in_mb = MBX_3|MBX_1|MBX_0;
....@@ -3764,7 +3902,7 @@
37643902 rval = qla2x00_mailbox_command(vha, mcp);
37653903
37663904 /* Return mailbox statuses. */
3767
- if (mb != NULL) {
3905
+ if (mb) {
37683906 mb[0] = mcp->mb[0];
37693907 mb[1] = mcp->mb[1];
37703908 mb[3] = mcp->mb[3];
....@@ -3837,14 +3975,46 @@
38373975 case TOPO_N2N:
38383976 ha->current_topology = ISP_CFG_N;
38393977 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags);
3978
+ list_for_each_entry(fcport, &vha->vp_fcports, list) {
3979
+ fcport->scan_state = QLA_FCPORT_SCAN;
3980
+ fcport->n2n_flag = 0;
3981
+ }
3982
+ id.b24 = 0;
3983
+ if (wwn_to_u64(vha->port_name) >
3984
+ wwn_to_u64(rptid_entry->u.f1.port_name)) {
3985
+ vha->d_id.b24 = 0;
3986
+ vha->d_id.b.al_pa = 1;
3987
+ ha->flags.n2n_bigger = 1;
3988
+
3989
+ id.b.al_pa = 2;
3990
+ ql_dbg(ql_dbg_async, vha, 0x5075,
3991
+ "Format 1: assign local id %x remote id %x\n",
3992
+ vha->d_id.b24, id.b24);
3993
+ } else {
3994
+ ql_dbg(ql_dbg_async, vha, 0x5075,
3995
+ "Format 1: Remote login - Waiting for WWPN %8phC.\n",
3996
+ rptid_entry->u.f1.port_name);
3997
+ ha->flags.n2n_bigger = 0;
3998
+ }
3999
+
38404000 fcport = qla2x00_find_fcport_by_wwpn(vha,
38414001 rptid_entry->u.f1.port_name, 1);
38424002 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
38434003
4004
+
38444005 if (fcport) {
38454006 fcport->plogi_nack_done_deadline = jiffies + HZ;
3846
- fcport->dm_login_expire = jiffies + 3*HZ;
4007
+ fcport->dm_login_expire = jiffies +
4008
+ QLA_N2N_WAIT_TIME * HZ;
38474009 fcport->scan_state = QLA_FCPORT_FOUND;
4010
+ fcport->n2n_flag = 1;
4011
+ fcport->keep_nport_handle = 1;
4012
+
4013
+ if (wwn_to_u64(vha->port_name) >
4014
+ wwn_to_u64(fcport->port_name)) {
4015
+ fcport->d_id = id;
4016
+ }
4017
+
38484018 switch (fcport->disc_state) {
38494019 case DSC_DELETED:
38504020 set_bit(RELOGIN_NEEDED,
....@@ -3857,30 +4027,11 @@
38574027 break;
38584028 }
38594029 } 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
- }
38794030 qla24xx_post_newsess_work(vha, &id,
38804031 rptid_entry->u.f1.port_name,
38814032 rptid_entry->u.f1.node_name,
38824033 NULL,
3883
- FC4_TYPE_UNKNOWN);
4034
+ FS_FCP_IS_N2N);
38844035 }
38854036
38864037 /* if our portname is higher then initiate N2N login */
....@@ -3978,6 +4129,7 @@
39784129
39794130 list_for_each_entry(fcport, &vha->vp_fcports, list) {
39804131 fcport->scan_state = QLA_FCPORT_SCAN;
4132
+ fcport->n2n_flag = 0;
39814133 }
39824134
39834135 fcport = qla2x00_find_fcport_by_wwpn(vha,
....@@ -3987,6 +4139,14 @@
39874139 fcport->login_retry = vha->hw->login_retry_count;
39884140 fcport->plogi_nack_done_deadline = jiffies + HZ;
39894141 fcport->scan_state = QLA_FCPORT_FOUND;
4142
+ fcport->keep_nport_handle = 1;
4143
+ fcport->n2n_flag = 1;
4144
+ fcport->d_id.b.domain =
4145
+ rptid_entry->u.f2.remote_nport_id[2];
4146
+ fcport->d_id.b.area =
4147
+ rptid_entry->u.f2.remote_nport_id[1];
4148
+ fcport->d_id.b.al_pa =
4149
+ rptid_entry->u.f2.remote_nport_id[0];
39904150 }
39914151 }
39924152 }
....@@ -4128,7 +4288,8 @@
41284288 if (MSW(addr) || IS_FWI2_CAPABLE(vha->hw)) {
41294289 mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED;
41304290 mcp->mb[8] = MSW(addr);
4131
- mcp->out_mb = MBX_8|MBX_0;
4291
+ mcp->mb[10] = 0;
4292
+ mcp->out_mb = MBX_10|MBX_8|MBX_0;
41324293 } else {
41334294 mcp->mb[0] = MBC_DUMP_RISC_RAM;
41344295 mcp->out_mb = MBX_0;
....@@ -4207,7 +4368,7 @@
42074368 ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111c,
42084369 "Dump of Verify Request.\n");
42094370 ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x111e,
4210
- (uint8_t *)mn, sizeof(*mn));
4371
+ mn, sizeof(*mn));
42114372
42124373 rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120);
42134374 if (rval != QLA_SUCCESS) {
....@@ -4219,7 +4380,7 @@
42194380 ql_dbg(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1110,
42204381 "Dump of Verify Response.\n");
42214382 ql_dump_buffer(ql_dbg_mbx + ql_dbg_buffer, vha, 0x1118,
4222
- (uint8_t *)mn, sizeof(*mn));
4383
+ mn, sizeof(*mn));
42234384
42244385 status[0] = le16_to_cpu(mn->p.rsp.comp_status);
42254386 status[1] = status[0] == CS_VCS_CHIP_FAILURE ?
....@@ -4295,7 +4456,7 @@
42954456 mcp->mb[12] = req->qos;
42964457 mcp->mb[11] = req->vp_idx;
42974458 mcp->mb[13] = req->rid;
4298
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha))
4459
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
42994460 mcp->mb[15] = 0;
43004461
43014462 mcp->mb[4] = req->id;
....@@ -4309,9 +4470,10 @@
43094470 mcp->flags = MBX_DMA_OUT;
43104471 mcp->tov = MBX_TOV_SECONDS * 2;
43114472
4312
- if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha))
4473
+ if (IS_QLA81XX(ha) || IS_QLA83XX(ha) || IS_QLA27XX(ha) ||
4474
+ IS_QLA28XX(ha))
43134475 mcp->in_mb |= MBX_1;
4314
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
4476
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
43154477 mcp->out_mb |= MBX_15;
43164478 /* debug q create issue in SR-IOV */
43174479 mcp->in_mb |= MBX_9 | MBX_8 | MBX_7;
....@@ -4319,9 +4481,9 @@
43194481
43204482 spin_lock_irqsave(&ha->hardware_lock, flags);
43214483 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);
4484
+ wrt_reg_dword(req->req_q_in, 0);
4485
+ if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
4486
+ wrt_reg_dword(req->req_q_out, 0);
43254487 }
43264488 spin_unlock_irqrestore(&ha->hardware_lock, flags);
43274489
....@@ -4364,7 +4526,7 @@
43644526 mcp->mb[5] = rsp->length;
43654527 mcp->mb[14] = rsp->msix->entry;
43664528 mcp->mb[13] = rsp->rid;
4367
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha))
4529
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
43684530 mcp->mb[15] = 0;
43694531
43704532 mcp->mb[4] = rsp->id;
....@@ -4381,7 +4543,7 @@
43814543 if (IS_QLA81XX(ha)) {
43824544 mcp->out_mb |= MBX_12|MBX_11|MBX_10;
43834545 mcp->in_mb |= MBX_1;
4384
- } else if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
4546
+ } else if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
43854547 mcp->out_mb |= MBX_15|MBX_12|MBX_11|MBX_10;
43864548 mcp->in_mb |= MBX_1;
43874549 /* debug q create issue in SR-IOV */
....@@ -4390,9 +4552,9 @@
43904552
43914553 spin_lock_irqsave(&ha->hardware_lock, flags);
43924554 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);
4555
+ wrt_reg_dword(rsp->rsp_q_out, 0);
4556
+ if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
4557
+ wrt_reg_dword(rsp->rsp_q_in, 0);
43964558 }
43974559
43984560 spin_unlock_irqrestore(&ha->hardware_lock, flags);
....@@ -4449,7 +4611,7 @@
44494611 "Entered %s.\n", __func__);
44504612
44514613 if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) &&
4452
- !IS_QLA27XX(vha->hw))
4614
+ !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw))
44534615 return QLA_FUNCTION_FAILED;
44544616
44554617 mcp->mb[0] = MBC_FLASH_ACCESS_CTRL;
....@@ -4481,7 +4643,7 @@
44814643 mbx_cmd_t *mcp = &mc;
44824644
44834645 if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) &&
4484
- !IS_QLA27XX(vha->hw))
4646
+ !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw))
44854647 return QLA_FUNCTION_FAILED;
44864648
44874649 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10df,
....@@ -4516,7 +4678,7 @@
45164678 mbx_cmd_t *mcp = &mc;
45174679
45184680 if (!IS_QLA81XX(vha->hw) && !IS_QLA83XX(vha->hw) &&
4519
- !IS_QLA27XX(vha->hw))
4681
+ !IS_QLA27XX(vha->hw) && !IS_QLA28XX(vha->hw))
45204682 return QLA_FUNCTION_FAILED;
45214683
45224684 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e2,
....@@ -4530,6 +4692,42 @@
45304692 mcp->mb[5] = MSW(finish);
45314693 mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
45324694 mcp->in_mb = MBX_2|MBX_1|MBX_0;
4695
+ mcp->tov = MBX_TOV_SECONDS;
4696
+ mcp->flags = 0;
4697
+ rval = qla2x00_mailbox_command(vha, mcp);
4698
+
4699
+ if (rval != QLA_SUCCESS) {
4700
+ ql_dbg(ql_dbg_mbx, vha, 0x10e3,
4701
+ "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
4702
+ rval, mcp->mb[0], mcp->mb[1], mcp->mb[2]);
4703
+ } else {
4704
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e4,
4705
+ "Done %s.\n", __func__);
4706
+ }
4707
+
4708
+ return rval;
4709
+}
4710
+
4711
+int
4712
+qla81xx_fac_semaphore_access(scsi_qla_host_t *vha, int lock)
4713
+{
4714
+ int rval = QLA_SUCCESS;
4715
+ mbx_cmd_t mc;
4716
+ mbx_cmd_t *mcp = &mc;
4717
+ struct qla_hw_data *ha = vha->hw;
4718
+
4719
+ if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) &&
4720
+ !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
4721
+ return rval;
4722
+
4723
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e2,
4724
+ "Entered %s.\n", __func__);
4725
+
4726
+ mcp->mb[0] = MBC_FLASH_ACCESS_CTRL;
4727
+ mcp->mb[1] = (lock ? FAC_OPT_CMD_LOCK_SEMAPHORE :
4728
+ FAC_OPT_CMD_UNLOCK_SEMAPHORE);
4729
+ mcp->out_mb = MBX_1|MBX_0;
4730
+ mcp->in_mb = MBX_1|MBX_0;
45334731 mcp->tov = MBX_TOV_SECONDS;
45344732 mcp->flags = 0;
45354733 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -4583,7 +4781,7 @@
45834781 mbx_cmd_t *mcp = &mc;
45844782 int i;
45854783 int len;
4586
- uint16_t *str;
4784
+ __le16 *str;
45874785 struct qla_hw_data *ha = vha->hw;
45884786
45894787 if (!IS_P3P_TYPE(ha))
....@@ -4592,14 +4790,14 @@
45924790 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x117b,
45934791 "Entered %s.\n", __func__);
45944792
4595
- str = (void *)version;
4793
+ str = (__force __le16 *)version;
45964794 len = strlen(version);
45974795
45984796 mcp->mb[0] = MBC_SET_RNID_PARAMS;
45994797 mcp->mb[1] = RNID_TYPE_SET_VERSION << 8;
46004798 mcp->out_mb = MBX_1|MBX_0;
46014799 for (i = 4; i < 16 && len; i++, str++, len -= 2) {
4602
- mcp->mb[i] = cpu_to_le16p(str);
4800
+ mcp->mb[i] = le16_to_cpup(str);
46034801 mcp->out_mb |= 1<<i;
46044802 }
46054803 for (; i < 16; i++) {
....@@ -4717,8 +4915,73 @@
47174915 "Done %s.\n", __func__);
47184916 bp = (uint32_t *) buf;
47194917 for (i = 0; i < (bufsiz-4)/4; i++, bp++)
4720
- *bp = le32_to_cpu(*bp);
4918
+ *bp = le32_to_cpu((__force __le32)*bp);
47214919 }
4920
+
4921
+ return rval;
4922
+}
4923
+
4924
+#define PUREX_CMD_COUNT 2
4925
+int
4926
+qla25xx_set_els_cmds_supported(scsi_qla_host_t *vha)
4927
+{
4928
+ int rval;
4929
+ mbx_cmd_t mc;
4930
+ mbx_cmd_t *mcp = &mc;
4931
+ uint8_t *els_cmd_map;
4932
+ dma_addr_t els_cmd_map_dma;
4933
+ uint8_t cmd_opcode[PUREX_CMD_COUNT];
4934
+ uint8_t i, index, purex_bit;
4935
+ struct qla_hw_data *ha = vha->hw;
4936
+
4937
+ if (!IS_QLA25XX(ha) && !IS_QLA2031(ha) &&
4938
+ !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
4939
+ return QLA_SUCCESS;
4940
+
4941
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1197,
4942
+ "Entered %s.\n", __func__);
4943
+
4944
+ els_cmd_map = dma_alloc_coherent(&ha->pdev->dev, ELS_CMD_MAP_SIZE,
4945
+ &els_cmd_map_dma, GFP_KERNEL);
4946
+ if (!els_cmd_map) {
4947
+ ql_log(ql_log_warn, vha, 0x7101,
4948
+ "Failed to allocate RDP els command param.\n");
4949
+ return QLA_MEMORY_ALLOC_FAILED;
4950
+ }
4951
+
4952
+ /* List of Purex ELS */
4953
+ cmd_opcode[0] = ELS_FPIN;
4954
+ cmd_opcode[1] = ELS_RDP;
4955
+
4956
+ for (i = 0; i < PUREX_CMD_COUNT; i++) {
4957
+ index = cmd_opcode[i] / 8;
4958
+ purex_bit = cmd_opcode[i] % 8;
4959
+ els_cmd_map[index] |= 1 << purex_bit;
4960
+ }
4961
+
4962
+ mcp->mb[0] = MBC_SET_RNID_PARAMS;
4963
+ mcp->mb[1] = RNID_TYPE_ELS_CMD << 8;
4964
+ mcp->mb[2] = MSW(LSD(els_cmd_map_dma));
4965
+ mcp->mb[3] = LSW(LSD(els_cmd_map_dma));
4966
+ mcp->mb[6] = MSW(MSD(els_cmd_map_dma));
4967
+ mcp->mb[7] = LSW(MSD(els_cmd_map_dma));
4968
+ mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
4969
+ mcp->in_mb = MBX_1|MBX_0;
4970
+ mcp->tov = MBX_TOV_SECONDS;
4971
+ mcp->flags = MBX_DMA_OUT;
4972
+ mcp->buf_size = ELS_CMD_MAP_SIZE;
4973
+ rval = qla2x00_mailbox_command(vha, mcp);
4974
+
4975
+ if (rval != QLA_SUCCESS) {
4976
+ ql_dbg(ql_dbg_mbx, vha, 0x118d,
4977
+ "Failed=%x (%x,%x).\n", rval, mcp->mb[0], mcp->mb[1]);
4978
+ } else {
4979
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x118c,
4980
+ "Done %s.\n", __func__);
4981
+ }
4982
+
4983
+ dma_free_coherent(&ha->pdev->dev, ELS_CMD_MAP_SIZE,
4984
+ els_cmd_map, els_cmd_map_dma);
47224985
47234986 return rval;
47244987 }
....@@ -4776,8 +5039,8 @@
47765039
47775040 mcp->mb[0] = MBC_READ_SFP;
47785041 mcp->mb[1] = dev;
4779
- mcp->mb[2] = MSW(sfp_dma);
4780
- mcp->mb[3] = LSW(sfp_dma);
5042
+ mcp->mb[2] = MSW(LSD(sfp_dma));
5043
+ mcp->mb[3] = LSW(LSD(sfp_dma));
47815044 mcp->mb[6] = MSW(MSD(sfp_dma));
47825045 mcp->mb[7] = LSW(MSD(sfp_dma));
47835046 mcp->mb[8] = len;
....@@ -4795,10 +5058,10 @@
47955058 if (rval != QLA_SUCCESS) {
47965059 ql_dbg(ql_dbg_mbx, vha, 0x10e9,
47975060 "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
4798
- if (mcp->mb[0] == MBS_COMMAND_ERROR &&
4799
- mcp->mb[1] == 0x22)
5061
+ if (mcp->mb[0] == MBS_COMMAND_ERROR && mcp->mb[1] == 0x22) {
48005062 /* sfp is not there */
48015063 rval = QLA_INTERFACE_ERROR;
5064
+ }
48025065 } else {
48035066 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea,
48045067 "Done %s.\n", __func__);
....@@ -4830,8 +5093,8 @@
48305093
48315094 mcp->mb[0] = MBC_WRITE_SFP;
48325095 mcp->mb[1] = dev;
4833
- mcp->mb[2] = MSW(sfp_dma);
4834
- mcp->mb[3] = LSW(sfp_dma);
5096
+ mcp->mb[2] = MSW(LSD(sfp_dma));
5097
+ mcp->mb[3] = LSW(LSD(sfp_dma));
48355098 mcp->mb[6] = MSW(MSD(sfp_dma));
48365099 mcp->mb[7] = LSW(MSD(sfp_dma));
48375100 mcp->mb[8] = len;
....@@ -4952,7 +5215,7 @@
49525215 mcp->mb[8] = MSW(risc_addr);
49535216 mcp->out_mb = MBX_8|MBX_1|MBX_0;
49545217 mcp->in_mb = MBX_3|MBX_2|MBX_0;
4955
- mcp->tov = 30;
5218
+ mcp->tov = MBX_TOV_SECONDS;
49565219 mcp->flags = 0;
49575220 rval = qla2x00_mailbox_command(vha, mcp);
49585221 if (rval != QLA_SUCCESS) {
....@@ -5066,10 +5329,11 @@
50665329 mcp->out_mb |= MBX_2;
50675330
50685331 mcp->in_mb = MBX_0;
5069
- if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) ||
5070
- IS_CNA_CAPABLE(ha) || IS_QLA2031(ha))
5332
+ if (IS_CNA_CAPABLE(ha) || IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) ||
5333
+ IS_QLA2031(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
50715334 mcp->in_mb |= MBX_1;
5072
- if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha))
5335
+ if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha) ||
5336
+ IS_QLA28XX(ha))
50735337 mcp->in_mb |= MBX_3;
50745338
50755339 mcp->tov = MBX_TOV_SECONDS;
....@@ -5138,13 +5402,14 @@
51385402 mcp->mb[3] = MSW(data);
51395403 mcp->mb[8] = MSW(risc_addr);
51405404 mcp->out_mb = MBX_8|MBX_3|MBX_2|MBX_1|MBX_0;
5141
- mcp->in_mb = MBX_0;
5142
- mcp->tov = 30;
5405
+ mcp->in_mb = MBX_1|MBX_0;
5406
+ mcp->tov = MBX_TOV_SECONDS;
51435407 mcp->flags = 0;
51445408 rval = qla2x00_mailbox_command(vha, mcp);
51455409 if (rval != QLA_SUCCESS) {
51465410 ql_dbg(ql_dbg_mbx, vha, 0x1101,
5147
- "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
5411
+ "Failed=%x mb[0]=%x mb[1]=%x.\n",
5412
+ rval, mcp->mb[0], mcp->mb[1]);
51485413 } else {
51495414 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1102,
51505415 "Done %s.\n", __func__);
....@@ -5170,18 +5435,18 @@
51705435 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
51715436
51725437 /* 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]);
5438
+ wrt_reg_word(&reg->mailbox0, MBC_WRITE_MPI_REGISTER);
5439
+ wrt_reg_word(&reg->mailbox1, mb[0]);
5440
+ wrt_reg_word(&reg->mailbox2, mb[1]);
5441
+ wrt_reg_word(&reg->mailbox3, mb[2]);
5442
+ wrt_reg_word(&reg->mailbox4, mb[3]);
51785443
5179
- WRT_REG_DWORD(&reg->hccr, HCCRX_SET_HOST_INT);
5444
+ wrt_reg_dword(&reg->hccr, HCCRX_SET_HOST_INT);
51805445
51815446 /* Poll for MBC interrupt */
51825447 for (timer = 6000000; timer; timer--) {
51835448 /* Check for pending interrupts. */
5184
- stat = RD_REG_DWORD(&reg->host_status);
5449
+ stat = rd_reg_dword(&reg->host_status);
51855450 if (stat & HSRX_RISC_INT) {
51865451 stat &= 0xff;
51875452
....@@ -5189,10 +5454,10 @@
51895454 stat == 0x10 || stat == 0x11) {
51905455 set_bit(MBX_INTERRUPT,
51915456 &ha->mbx_cmd_flags);
5192
- mb0 = RD_REG_WORD(&reg->mailbox0);
5193
- WRT_REG_DWORD(&reg->hccr,
5457
+ mb0 = rd_reg_word(&reg->mailbox0);
5458
+ wrt_reg_dword(&reg->hccr,
51945459 HCCRX_CLR_RISC_INT);
5195
- RD_REG_DWORD(&reg->hccr);
5460
+ rd_reg_dword(&reg->hccr);
51965461 break;
51975462 }
51985463 }
....@@ -5215,6 +5480,66 @@
52155480 return rval;
52165481 }
52175482
5483
+/* Set the specified data rate */
5484
+int
5485
+qla2x00_set_data_rate(scsi_qla_host_t *vha, uint16_t mode)
5486
+{
5487
+ int rval;
5488
+ mbx_cmd_t mc;
5489
+ mbx_cmd_t *mcp = &mc;
5490
+ struct qla_hw_data *ha = vha->hw;
5491
+ uint16_t val;
5492
+
5493
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1106,
5494
+ "Entered %s speed:0x%x mode:0x%x.\n", __func__, ha->set_data_rate,
5495
+ mode);
5496
+
5497
+ if (!IS_FWI2_CAPABLE(ha))
5498
+ return QLA_FUNCTION_FAILED;
5499
+
5500
+ memset(mcp, 0, sizeof(*mcp));
5501
+ switch (ha->set_data_rate) {
5502
+ case PORT_SPEED_AUTO:
5503
+ case PORT_SPEED_4GB:
5504
+ case PORT_SPEED_8GB:
5505
+ case PORT_SPEED_16GB:
5506
+ case PORT_SPEED_32GB:
5507
+ val = ha->set_data_rate;
5508
+ break;
5509
+ default:
5510
+ ql_log(ql_log_warn, vha, 0x1199,
5511
+ "Unrecognized speed setting:%d. Setting Autoneg\n",
5512
+ ha->set_data_rate);
5513
+ val = ha->set_data_rate = PORT_SPEED_AUTO;
5514
+ break;
5515
+ }
5516
+
5517
+ mcp->mb[0] = MBC_DATA_RATE;
5518
+ mcp->mb[1] = mode;
5519
+ mcp->mb[2] = val;
5520
+
5521
+ mcp->out_mb = MBX_2|MBX_1|MBX_0;
5522
+ mcp->in_mb = MBX_2|MBX_1|MBX_0;
5523
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
5524
+ mcp->in_mb |= MBX_4|MBX_3;
5525
+ mcp->tov = MBX_TOV_SECONDS;
5526
+ mcp->flags = 0;
5527
+ rval = qla2x00_mailbox_command(vha, mcp);
5528
+ if (rval != QLA_SUCCESS) {
5529
+ ql_dbg(ql_dbg_mbx, vha, 0x1107,
5530
+ "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
5531
+ } else {
5532
+ if (mcp->mb[1] != 0x7)
5533
+ ql_dbg(ql_dbg_mbx, vha, 0x1179,
5534
+ "Speed set:0x%x\n", mcp->mb[1]);
5535
+
5536
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1108,
5537
+ "Done %s.\n", __func__);
5538
+ }
5539
+
5540
+ return rval;
5541
+}
5542
+
52185543 int
52195544 qla2x00_get_data_rate(scsi_qla_host_t *vha)
52205545 {
....@@ -5230,11 +5555,11 @@
52305555 return QLA_FUNCTION_FAILED;
52315556
52325557 mcp->mb[0] = MBC_DATA_RATE;
5233
- mcp->mb[1] = 0;
5558
+ mcp->mb[1] = QLA_GET_DATA_RATE;
52345559 mcp->out_mb = MBX_1|MBX_0;
52355560 mcp->in_mb = MBX_2|MBX_1|MBX_0;
5236
- if (IS_QLA83XX(ha) || IS_QLA27XX(ha))
5237
- mcp->in_mb |= MBX_3;
5561
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
5562
+ mcp->in_mb |= MBX_4|MBX_3;
52385563 mcp->tov = MBX_TOV_SECONDS;
52395564 mcp->flags = 0;
52405565 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -5242,6 +5567,15 @@
52425567 ql_dbg(ql_dbg_mbx, vha, 0x1107,
52435568 "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
52445569 } else {
5570
+ if (mcp->mb[1] != 0x7)
5571
+ ha->link_data_rate = mcp->mb[1];
5572
+
5573
+ if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
5574
+ if (mcp->mb[4] & BIT_0)
5575
+ ql_log(ql_log_info, vha, 0x11a2,
5576
+ "FEC=enabled (data rate).\n");
5577
+ }
5578
+
52455579 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1108,
52465580 "Done %s.\n", __func__);
52475581 if (mcp->mb[1] != 0x7)
....@@ -5263,7 +5597,7 @@
52635597 "Entered %s.\n", __func__);
52645598
52655599 if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) && !IS_QLA8044(ha) &&
5266
- !IS_QLA27XX(ha))
5600
+ !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
52675601 return QLA_FUNCTION_FAILED;
52685602 mcp->mb[0] = MBC_GET_PORT_CONFIG;
52695603 mcp->out_mb = MBX_0;
....@@ -5341,7 +5675,7 @@
53415675 mcp->mb[9] = vha->vp_idx;
53425676 mcp->out_mb = MBX_9|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
53435677 mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0;
5344
- mcp->tov = 30;
5678
+ mcp->tov = MBX_TOV_SECONDS;
53455679 mcp->flags = 0;
53465680 rval = qla2x00_mailbox_command(vha, mcp);
53475681 if (mb != NULL) {
....@@ -5428,7 +5762,7 @@
54285762
54295763 mcp->out_mb = MBX_1|MBX_0;
54305764 mcp->in_mb = MBX_0;
5431
- mcp->tov = 30;
5765
+ mcp->tov = MBX_TOV_SECONDS;
54325766 mcp->flags = 0;
54335767
54345768 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -5463,7 +5797,7 @@
54635797
54645798 mcp->out_mb = MBX_1|MBX_0;
54655799 mcp->in_mb = MBX_0;
5466
- mcp->tov = 30;
5800
+ mcp->tov = MBX_TOV_SECONDS;
54675801 mcp->flags = 0;
54685802
54695803 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -5579,6 +5913,7 @@
55795913 mbx_cmd_t *mcp = &mc;
55805914 int rval = QLA_FUNCTION_FAILED;
55815915 int offset = 0, size = MINIDUMP_SIZE_36K;
5916
+
55825917 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0xb11f,
55835918 "Entered %s.\n", __func__);
55845919
....@@ -5654,7 +5989,7 @@
56545989 if (IS_QLA8031(ha))
56555990 mcp->out_mb |= MBX_6|MBX_5|MBX_4|MBX_3;
56565991 mcp->in_mb = MBX_0;
5657
- mcp->tov = 30;
5992
+ mcp->tov = MBX_TOV_SECONDS;
56585993 mcp->flags = 0;
56595994
56605995 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -5690,7 +6025,7 @@
56906025 mcp->in_mb = MBX_2|MBX_1|MBX_0;
56916026 if (IS_QLA8031(ha))
56926027 mcp->in_mb |= MBX_6|MBX_5|MBX_4|MBX_3;
5693
- mcp->tov = 30;
6028
+ mcp->tov = MBX_TOV_SECONDS;
56946029 mcp->flags = 0;
56956030
56966031 rval = qla2x00_mailbox_command(vha, mcp);
....@@ -5759,7 +6094,7 @@
57596094 mbx_cmd_t mc;
57606095 mbx_cmd_t *mcp = &mc;
57616096
5762
- if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
6097
+ if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
57636098 return QLA_FUNCTION_FAILED;
57646099
57656100 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1130,
....@@ -5834,7 +6169,7 @@
58346169 struct qla_hw_data *ha = vha->hw;
58356170 unsigned long retry_max_time = jiffies + (2 * HZ);
58366171
5837
- if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
6172
+ if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
58386173 return QLA_FUNCTION_FAILED;
58396174
58406175 ql_dbg(ql_dbg_mbx, vha, 0x114b, "Entered %s.\n", __func__);
....@@ -5884,7 +6219,7 @@
58846219 mbx_cmd_t *mcp = &mc;
58856220 struct qla_hw_data *ha = vha->hw;
58866221
5887
- if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
6222
+ if (!IS_QLA83XX(ha))
58886223 return QLA_FUNCTION_FAILED;
58896224
58906225 ql_dbg(ql_dbg_mbx, vha, 0x1143, "Entered %s.\n", __func__);
....@@ -5900,7 +6235,7 @@
59006235 ql_dbg(ql_dbg_mbx, vha, 0x1144,
59016236 "Failed=%x mb[0]=%x mb[1]=%x.\n",
59026237 rval, mcp->mb[0], mcp->mb[1]);
5903
- ha->isp_ops->fw_dump(vha, 0);
6238
+ qla2xxx_dump_fw(vha);
59046239 } else {
59056240 ql_dbg(ql_dbg_mbx, vha, 0x1145, "Done %s.\n", __func__);
59066241 }
....@@ -5945,7 +6280,7 @@
59456280 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[4]=%x.\n",
59466281 rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3],
59476282 mcp->mb[4]);
5948
- ha->isp_ops->fw_dump(vha, 0);
6283
+ qla2xxx_dump_fw(vha);
59496284 } else {
59506285 if (subcode & BIT_5)
59516286 *sector_size = mcp->mb[1];
....@@ -6017,7 +6352,8 @@
60176352 mbx_cmd_t *mcp = &mc;
60186353 dma_addr_t dd_dma;
60196354
6020
- if (!IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw))
6355
+ if (!IS_QLA83XX(vha->hw) && !IS_QLA27XX(vha->hw) &&
6356
+ !IS_QLA28XX(vha->hw))
60216357 return QLA_FUNCTION_FAILED;
60226358
60236359 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x119f,
....@@ -6059,10 +6395,8 @@
60596395 return rval;
60606396 }
60616397
6062
-static void qla2x00_async_mb_sp_done(void *s, int res)
6398
+static void qla2x00_async_mb_sp_done(srb_t *sp, int res)
60636399 {
6064
- struct srb *sp = s;
6065
-
60666400 sp->u.iocb_cmd.u.mbx.rc = res;
60676401
60686402 complete(&sp->u.iocb_cmd.u.mbx.comp);
....@@ -6160,13 +6494,13 @@
61606494
61616495 memset(&mc, 0, sizeof(mc));
61626496 mc.mb[0] = MBC_GET_PORT_DATABASE;
6163
- mc.mb[1] = cpu_to_le16(fcport->loop_id);
6497
+ mc.mb[1] = fcport->loop_id;
61646498 mc.mb[2] = MSW(pd_dma);
61656499 mc.mb[3] = LSW(pd_dma);
61666500 mc.mb[6] = MSW(MSD(pd_dma));
61676501 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);
6502
+ mc.mb[9] = vha->vp_idx;
6503
+ mc.mb[10] = opt;
61706504
61716505 rval = qla24xx_send_mb_cmd(vha, &mc);
61726506 if (rval != QLA_SUCCESS) {
....@@ -6194,7 +6528,7 @@
61946528 uint64_t zero = 0;
61956529 u8 current_login_state, last_login_state;
61966530
6197
- if (fcport->fc4f_nvme) {
6531
+ if (NVME_TARGET(vha->hw, fcport)) {
61986532 current_login_state = pd->current_login_state >> 4;
61996533 last_login_state = pd->last_login_state >> 4;
62006534 } else {
....@@ -6229,10 +6563,14 @@
62296563 fcport->d_id.b.al_pa = pd->port_id[2];
62306564 fcport->d_id.b.rsvd_1 = 0;
62316565
6232
- if (fcport->fc4f_nvme) {
6233
- fcport->nvme_prli_service_param =
6234
- pd->prli_nvme_svc_param_word_3;
6566
+ if (NVME_TARGET(vha->hw, fcport)) {
62356567 fcport->port_type = FCT_NVME;
6568
+ if ((pd->prli_svc_param_word_3[0] & BIT_5) == 0)
6569
+ fcport->port_type |= FCT_NVME_INITIATOR;
6570
+ if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0)
6571
+ fcport->port_type |= FCT_NVME_TARGET;
6572
+ if ((pd->prli_svc_param_word_3[0] & BIT_3) == 0)
6573
+ fcport->port_type |= FCT_NVME_DISCOVERY;
62366574 } else {
62376575 /* If not target must be initiator or unknown type. */
62386576 if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0)
....@@ -6273,7 +6611,7 @@
62736611 mc.mb[6] = MSW(MSD(id_list_dma));
62746612 mc.mb[7] = LSW(MSD(id_list_dma));
62756613 mc.mb[8] = 0;
6276
- mc.mb[9] = cpu_to_le16(vha->vp_idx);
6614
+ mc.mb[9] = vha->vp_idx;
62776615
62786616 rval = qla24xx_send_mb_cmd(vha, &mc);
62796617 if (rval != QLA_SUCCESS) {
....@@ -6299,8 +6637,8 @@
62996637
63006638 memset(mcp->mb, 0 , sizeof(mcp->mb));
63016639 mcp->mb[0] = MBC_GET_SET_ZIO_THRESHOLD;
6302
- mcp->mb[1] = cpu_to_le16(1);
6303
- mcp->mb[2] = cpu_to_le16(value);
6640
+ mcp->mb[1] = 1;
6641
+ mcp->mb[2] = value;
63046642 mcp->out_mb = MBX_2 | MBX_1 | MBX_0;
63056643 mcp->in_mb = MBX_2 | MBX_0;
63066644 mcp->tov = MBX_TOV_SECONDS;
....@@ -6325,7 +6663,7 @@
63256663
63266664 memset(mcp->mb, 0, sizeof(mcp->mb));
63276665 mcp->mb[0] = MBC_GET_SET_ZIO_THRESHOLD;
6328
- mcp->mb[1] = cpu_to_le16(0);
6666
+ mcp->mb[1] = 0;
63296667 mcp->out_mb = MBX_1 | MBX_0;
63306668 mcp->in_mb = MBX_2 | MBX_0;
63316669 mcp->tov = MBX_TOV_SECONDS;
....@@ -6421,3 +6759,158 @@
64216759 done:
64226760 return rval;
64236761 }
6762
+
6763
+int qla28xx_secure_flash_update(scsi_qla_host_t *vha, uint16_t opts,
6764
+ uint16_t region, uint32_t len, dma_addr_t sfub_dma_addr,
6765
+ uint32_t sfub_len)
6766
+{
6767
+ int rval;
6768
+ mbx_cmd_t mc;
6769
+ mbx_cmd_t *mcp = &mc;
6770
+
6771
+ mcp->mb[0] = MBC_SECURE_FLASH_UPDATE;
6772
+ mcp->mb[1] = opts;
6773
+ mcp->mb[2] = region;
6774
+ mcp->mb[3] = MSW(len);
6775
+ mcp->mb[4] = LSW(len);
6776
+ mcp->mb[5] = MSW(sfub_dma_addr);
6777
+ mcp->mb[6] = LSW(sfub_dma_addr);
6778
+ mcp->mb[7] = MSW(MSD(sfub_dma_addr));
6779
+ mcp->mb[8] = LSW(MSD(sfub_dma_addr));
6780
+ mcp->mb[9] = sfub_len;
6781
+ mcp->out_mb =
6782
+ MBX_9|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
6783
+ mcp->in_mb = MBX_2|MBX_1|MBX_0;
6784
+ mcp->tov = MBX_TOV_SECONDS;
6785
+ mcp->flags = 0;
6786
+ rval = qla2x00_mailbox_command(vha, mcp);
6787
+
6788
+ if (rval != QLA_SUCCESS) {
6789
+ ql_dbg(ql_dbg_mbx, vha, 0xffff, "%s(%ld): failed rval 0x%x, %x %x %x",
6790
+ __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1],
6791
+ mcp->mb[2]);
6792
+ }
6793
+
6794
+ return rval;
6795
+}
6796
+
6797
+int qla2xxx_write_remote_register(scsi_qla_host_t *vha, uint32_t addr,
6798
+ uint32_t data)
6799
+{
6800
+ int rval;
6801
+ mbx_cmd_t mc;
6802
+ mbx_cmd_t *mcp = &mc;
6803
+
6804
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e8,
6805
+ "Entered %s.\n", __func__);
6806
+
6807
+ mcp->mb[0] = MBC_WRITE_REMOTE_REG;
6808
+ mcp->mb[1] = LSW(addr);
6809
+ mcp->mb[2] = MSW(addr);
6810
+ mcp->mb[3] = LSW(data);
6811
+ mcp->mb[4] = MSW(data);
6812
+ mcp->out_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
6813
+ mcp->in_mb = MBX_1|MBX_0;
6814
+ mcp->tov = MBX_TOV_SECONDS;
6815
+ mcp->flags = 0;
6816
+ rval = qla2x00_mailbox_command(vha, mcp);
6817
+
6818
+ if (rval != QLA_SUCCESS) {
6819
+ ql_dbg(ql_dbg_mbx, vha, 0x10e9,
6820
+ "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
6821
+ } else {
6822
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea,
6823
+ "Done %s.\n", __func__);
6824
+ }
6825
+
6826
+ return rval;
6827
+}
6828
+
6829
+int qla2xxx_read_remote_register(scsi_qla_host_t *vha, uint32_t addr,
6830
+ uint32_t *data)
6831
+{
6832
+ int rval;
6833
+ mbx_cmd_t mc;
6834
+ mbx_cmd_t *mcp = &mc;
6835
+
6836
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10e8,
6837
+ "Entered %s.\n", __func__);
6838
+
6839
+ mcp->mb[0] = MBC_READ_REMOTE_REG;
6840
+ mcp->mb[1] = LSW(addr);
6841
+ mcp->mb[2] = MSW(addr);
6842
+ mcp->out_mb = MBX_2|MBX_1|MBX_0;
6843
+ mcp->in_mb = MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
6844
+ mcp->tov = MBX_TOV_SECONDS;
6845
+ mcp->flags = 0;
6846
+ rval = qla2x00_mailbox_command(vha, mcp);
6847
+
6848
+ *data = (uint32_t)((((uint32_t)mcp->mb[4]) << 16) | mcp->mb[3]);
6849
+
6850
+ if (rval != QLA_SUCCESS) {
6851
+ ql_dbg(ql_dbg_mbx, vha, 0x10e9,
6852
+ "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]);
6853
+ } else {
6854
+ ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ea,
6855
+ "Done %s.\n", __func__);
6856
+ }
6857
+
6858
+ return rval;
6859
+}
6860
+
6861
+int
6862
+ql26xx_led_config(scsi_qla_host_t *vha, uint16_t options, uint16_t *led)
6863
+{
6864
+ struct qla_hw_data *ha = vha->hw;
6865
+ mbx_cmd_t mc;
6866
+ mbx_cmd_t *mcp = &mc;
6867
+ int rval;
6868
+
6869
+ if (!IS_QLA2031(ha) && !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
6870
+ return QLA_FUNCTION_FAILED;
6871
+
6872
+ ql_dbg(ql_dbg_mbx, vha, 0x7070, "Entered %s (options=%x).\n",
6873
+ __func__, options);
6874
+
6875
+ mcp->mb[0] = MBC_SET_GET_FC_LED_CONFIG;
6876
+ mcp->mb[1] = options;
6877
+ mcp->out_mb = MBX_1|MBX_0;
6878
+ mcp->in_mb = MBX_1|MBX_0;
6879
+ if (options & BIT_0) {
6880
+ if (options & BIT_1) {
6881
+ mcp->mb[2] = led[2];
6882
+ mcp->out_mb |= MBX_2;
6883
+ }
6884
+ if (options & BIT_2) {
6885
+ mcp->mb[3] = led[0];
6886
+ mcp->out_mb |= MBX_3;
6887
+ }
6888
+ if (options & BIT_3) {
6889
+ mcp->mb[4] = led[1];
6890
+ mcp->out_mb |= MBX_4;
6891
+ }
6892
+ } else {
6893
+ mcp->in_mb |= MBX_4|MBX_3|MBX_2;
6894
+ }
6895
+ mcp->tov = MBX_TOV_SECONDS;
6896
+ mcp->flags = 0;
6897
+ rval = qla2x00_mailbox_command(vha, mcp);
6898
+ if (rval) {
6899
+ ql_dbg(ql_dbg_mbx, vha, 0x7071, "Failed %s %x (mb=%x,%x)\n",
6900
+ __func__, rval, mcp->mb[0], mcp->mb[1]);
6901
+ return rval;
6902
+ }
6903
+
6904
+ if (options & BIT_0) {
6905
+ ha->beacon_blink_led = 0;
6906
+ ql_dbg(ql_dbg_mbx, vha, 0x7072, "Done %s\n", __func__);
6907
+ } else {
6908
+ led[2] = mcp->mb[2];
6909
+ led[0] = mcp->mb[3];
6910
+ led[1] = mcp->mb[4];
6911
+ ql_dbg(ql_dbg_mbx, vha, 0x7073, "Done %s (led=%x,%x,%x)\n",
6912
+ __func__, led[0], led[1], led[2]);
6913
+ }
6914
+
6915
+ return rval;
6916
+}