~ubuntu-branches/ubuntu/lucid/linux-rt/lucid

« back to all changes in this revision

Viewing changes to drivers/scsi/qla2xxx/qla_attr.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2009-08-05 23:00:52 UTC
  • Revision ID: james.westby@ubuntu.com-20090805230052-7xedvqcyk9dnnxb2
Tags: 2.6.31-1.1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
        if (!capable(CAP_SYS_ADMIN))
97
97
                return 0;
98
98
 
99
 
        /* Read NVRAM data from cache. */
 
99
        if (IS_NOCACHE_VPD_TYPE(ha))
 
100
                ha->isp_ops->read_optrom(vha, ha->nvram, ha->flt_region_nvram << 2,
 
101
                    ha->nvram_size);
100
102
        return memory_read_from_buffer(buf, count, &off, ha->nvram,
101
103
                                        ha->nvram_size);
102
104
}
111
113
        struct qla_hw_data *ha = vha->hw;
112
114
        uint16_t        cnt;
113
115
 
114
 
        if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size)
 
116
        if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size ||
 
117
            !ha->isp_ops->write_nvram)
115
118
                return 0;
116
119
 
117
120
        /* Checksum NVRAM. */
137
140
                *iter = chksum;
138
141
        }
139
142
 
 
143
        if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
 
144
                qla_printk(KERN_WARNING, ha,
 
145
                    "HBA not online, failing NVRAM update.\n");
 
146
                return -EAGAIN;
 
147
        }
 
148
 
140
149
        /* Write NVRAM. */
141
150
        ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->nvram_base, count);
142
151
        ha->isp_ops->read_nvram(vha, (uint8_t *)ha->nvram, ha->nvram_base,
143
152
            count);
144
153
 
 
154
        /* NVRAM settings take effect immediately. */
145
155
        set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
 
156
        qla2xxx_wake_dpc(vha);
 
157
        qla2x00_wait_for_chip_reset(vha);
146
158
 
147
159
        return (count);
148
160
}
330
342
                if (ha->optrom_state != QLA_SWRITING)
331
343
                        break;
332
344
 
 
345
                if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
 
346
                        qla_printk(KERN_WARNING, ha,
 
347
                            "HBA not online, failing flash update.\n");
 
348
                        return -EAGAIN;
 
349
                }
 
350
 
333
351
                DEBUG2(qla_printk(KERN_INFO, ha,
334
352
                    "Writing flash region -- 0x%x/0x%x.\n",
335
353
                    ha->optrom_region_start, ha->optrom_region_size));
364
382
        if (!capable(CAP_SYS_ADMIN))
365
383
                return 0;
366
384
 
367
 
        /* Read NVRAM data from cache. */
 
385
        if (IS_NOCACHE_VPD_TYPE(ha))
 
386
                ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_vpd << 2,
 
387
                    ha->vpd_size);
368
388
        return memory_read_from_buffer(buf, count, &off, ha->vpd, ha->vpd_size);
369
389
}
370
390
 
376
396
        struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
377
397
            struct device, kobj)));
378
398
        struct qla_hw_data *ha = vha->hw;
 
399
        uint8_t *tmp_data;
379
400
 
380
 
        if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size)
 
401
        if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size ||
 
402
            !ha->isp_ops->write_nvram)
381
403
                return 0;
382
404
 
 
405
        if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
 
406
                qla_printk(KERN_WARNING, ha,
 
407
                    "HBA not online, failing VPD update.\n");
 
408
                return -EAGAIN;
 
409
        }
 
410
 
383
411
        /* Write NVRAM. */
384
412
        ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->vpd_base, count);
385
413
        ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, ha->vpd_base, count);
386
414
 
 
415
        /* Update flash version information for 4Gb & above. */
 
416
        if (!IS_FWI2_CAPABLE(ha))
 
417
                goto done;
 
418
 
 
419
        tmp_data = vmalloc(256);
 
420
        if (!tmp_data) {
 
421
                qla_printk(KERN_WARNING, ha,
 
422
                    "Unable to allocate memory for VPD information update.\n");
 
423
                goto done;
 
424
        }
 
425
        ha->isp_ops->get_flash_version(vha, tmp_data);
 
426
        vfree(tmp_data);
 
427
done:
387
428
        return count;
388
429
}
389
430
 
458
499
        .read = qla2x00_sysfs_read_sfp,
459
500
};
460
501
 
 
502
static ssize_t
 
503
qla2x00_sysfs_write_reset(struct kobject *kobj,
 
504
                        struct bin_attribute *bin_attr,
 
505
                        char *buf, loff_t off, size_t count)
 
506
{
 
507
        struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
 
508
            struct device, kobj)));
 
509
        struct qla_hw_data *ha = vha->hw;
 
510
        int type;
 
511
 
 
512
        if (off != 0)
 
513
                return 0;
 
514
 
 
515
        type = simple_strtol(buf, NULL, 10);
 
516
        switch (type) {
 
517
        case 0x2025c:
 
518
                qla_printk(KERN_INFO, ha,
 
519
                    "Issuing ISP reset on (%ld).\n", vha->host_no);
 
520
 
 
521
                scsi_block_requests(vha->host);
 
522
                set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
 
523
                qla2xxx_wake_dpc(vha);
 
524
                qla2x00_wait_for_chip_reset(vha);
 
525
                scsi_unblock_requests(vha->host);
 
526
                break;
 
527
        case 0x2025d:
 
528
                if (!IS_QLA81XX(ha))
 
529
                        break;
 
530
 
 
531
                qla_printk(KERN_INFO, ha,
 
532
                    "Issuing MPI reset on (%ld).\n", vha->host_no);
 
533
 
 
534
                /* Make sure FC side is not in reset */
 
535
                qla2x00_wait_for_hba_online(vha);
 
536
 
 
537
                /* Issue MPI reset */
 
538
                scsi_block_requests(vha->host);
 
539
                if (qla81xx_restart_mpi_firmware(vha) != QLA_SUCCESS)
 
540
                        qla_printk(KERN_WARNING, ha,
 
541
                            "MPI reset failed on (%ld).\n", vha->host_no);
 
542
                scsi_unblock_requests(vha->host);
 
543
                break;
 
544
        }
 
545
        return count;
 
546
}
 
547
 
 
548
static struct bin_attribute sysfs_reset_attr = {
 
549
        .attr = {
 
550
                .name = "reset",
 
551
                .mode = S_IWUSR,
 
552
        },
 
553
        .size = 0,
 
554
        .write = qla2x00_sysfs_write_reset,
 
555
};
 
556
 
 
557
static ssize_t
 
558
qla2x00_sysfs_write_edc(struct kobject *kobj,
 
559
                        struct bin_attribute *bin_attr,
 
560
                        char *buf, loff_t off, size_t count)
 
561
{
 
562
        struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
 
563
            struct device, kobj)));
 
564
        struct qla_hw_data *ha = vha->hw;
 
565
        uint16_t dev, adr, opt, len;
 
566
        int rval;
 
567
 
 
568
        ha->edc_data_len = 0;
 
569
 
 
570
        if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8)
 
571
                return 0;
 
572
 
 
573
        if (!ha->edc_data) {
 
574
                ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
 
575
                    &ha->edc_data_dma);
 
576
                if (!ha->edc_data) {
 
577
                        DEBUG2(qla_printk(KERN_INFO, ha,
 
578
                            "Unable to allocate memory for EDC write.\n"));
 
579
                        return 0;
 
580
                }
 
581
        }
 
582
 
 
583
        dev = le16_to_cpup((void *)&buf[0]);
 
584
        adr = le16_to_cpup((void *)&buf[2]);
 
585
        opt = le16_to_cpup((void *)&buf[4]);
 
586
        len = le16_to_cpup((void *)&buf[6]);
 
587
 
 
588
        if (!(opt & BIT_0))
 
589
                if (len == 0 || len > DMA_POOL_SIZE || len > count - 8)
 
590
                        return -EINVAL;
 
591
 
 
592
        memcpy(ha->edc_data, &buf[8], len);
 
593
 
 
594
        rval = qla2x00_write_edc(vha, dev, adr, ha->edc_data_dma,
 
595
            ha->edc_data, len, opt);
 
596
        if (rval != QLA_SUCCESS) {
 
597
                DEBUG2(qla_printk(KERN_INFO, ha,
 
598
                    "Unable to write EDC (%x) %02x:%02x:%04x:%02x:%02x.\n",
 
599
                    rval, dev, adr, opt, len, *buf));
 
600
                return 0;
 
601
        }
 
602
 
 
603
        return count;
 
604
}
 
605
 
 
606
static struct bin_attribute sysfs_edc_attr = {
 
607
        .attr = {
 
608
                .name = "edc",
 
609
                .mode = S_IWUSR,
 
610
        },
 
611
        .size = 0,
 
612
        .write = qla2x00_sysfs_write_edc,
 
613
};
 
614
 
 
615
static ssize_t
 
616
qla2x00_sysfs_write_edc_status(struct kobject *kobj,
 
617
                        struct bin_attribute *bin_attr,
 
618
                        char *buf, loff_t off, size_t count)
 
619
{
 
620
        struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
 
621
            struct device, kobj)));
 
622
        struct qla_hw_data *ha = vha->hw;
 
623
        uint16_t dev, adr, opt, len;
 
624
        int rval;
 
625
 
 
626
        ha->edc_data_len = 0;
 
627
 
 
628
        if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8)
 
629
                return 0;
 
630
 
 
631
        if (!ha->edc_data) {
 
632
                ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
 
633
                    &ha->edc_data_dma);
 
634
                if (!ha->edc_data) {
 
635
                        DEBUG2(qla_printk(KERN_INFO, ha,
 
636
                            "Unable to allocate memory for EDC status.\n"));
 
637
                        return 0;
 
638
                }
 
639
        }
 
640
 
 
641
        dev = le16_to_cpup((void *)&buf[0]);
 
642
        adr = le16_to_cpup((void *)&buf[2]);
 
643
        opt = le16_to_cpup((void *)&buf[4]);
 
644
        len = le16_to_cpup((void *)&buf[6]);
 
645
 
 
646
        if (!(opt & BIT_0))
 
647
                if (len == 0 || len > DMA_POOL_SIZE)
 
648
                        return -EINVAL;
 
649
 
 
650
        memset(ha->edc_data, 0, len);
 
651
        rval = qla2x00_read_edc(vha, dev, adr, ha->edc_data_dma,
 
652
            ha->edc_data, len, opt);
 
653
        if (rval != QLA_SUCCESS) {
 
654
                DEBUG2(qla_printk(KERN_INFO, ha,
 
655
                    "Unable to write EDC status (%x) %02x:%02x:%04x:%02x.\n",
 
656
                    rval, dev, adr, opt, len));
 
657
                return 0;
 
658
        }
 
659
 
 
660
        ha->edc_data_len = len;
 
661
 
 
662
        return count;
 
663
}
 
664
 
 
665
static ssize_t
 
666
qla2x00_sysfs_read_edc_status(struct kobject *kobj,
 
667
                           struct bin_attribute *bin_attr,
 
668
                           char *buf, loff_t off, size_t count)
 
669
{
 
670
        struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
 
671
            struct device, kobj)));
 
672
        struct qla_hw_data *ha = vha->hw;
 
673
 
 
674
        if (!capable(CAP_SYS_ADMIN) || off != 0 || count == 0)
 
675
                return 0;
 
676
 
 
677
        if (!ha->edc_data || ha->edc_data_len == 0 || ha->edc_data_len > count)
 
678
                return -EINVAL;
 
679
 
 
680
        memcpy(buf, ha->edc_data, ha->edc_data_len);
 
681
 
 
682
        return ha->edc_data_len;
 
683
}
 
684
 
 
685
static struct bin_attribute sysfs_edc_status_attr = {
 
686
        .attr = {
 
687
                .name = "edc_status",
 
688
                .mode = S_IRUSR | S_IWUSR,
 
689
        },
 
690
        .size = 0,
 
691
        .write = qla2x00_sysfs_write_edc_status,
 
692
        .read = qla2x00_sysfs_read_edc_status,
 
693
};
 
694
 
 
695
static ssize_t
 
696
qla2x00_sysfs_read_xgmac_stats(struct kobject *kobj,
 
697
                       struct bin_attribute *bin_attr,
 
698
                       char *buf, loff_t off, size_t count)
 
699
{
 
700
        struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
 
701
            struct device, kobj)));
 
702
        struct qla_hw_data *ha = vha->hw;
 
703
        int rval;
 
704
        uint16_t actual_size;
 
705
 
 
706
        if (!capable(CAP_SYS_ADMIN) || off != 0 || count > XGMAC_DATA_SIZE)
 
707
                return 0;
 
708
 
 
709
        if (ha->xgmac_data)
 
710
                goto do_read;
 
711
 
 
712
        ha->xgmac_data = dma_alloc_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE,
 
713
            &ha->xgmac_data_dma, GFP_KERNEL);
 
714
        if (!ha->xgmac_data) {
 
715
                qla_printk(KERN_WARNING, ha,
 
716
                    "Unable to allocate memory for XGMAC read-data.\n");
 
717
                return 0;
 
718
        }
 
719
 
 
720
do_read:
 
721
        actual_size = 0;
 
722
        memset(ha->xgmac_data, 0, XGMAC_DATA_SIZE);
 
723
 
 
724
        rval = qla2x00_get_xgmac_stats(vha, ha->xgmac_data_dma,
 
725
            XGMAC_DATA_SIZE, &actual_size);
 
726
        if (rval != QLA_SUCCESS) {
 
727
                qla_printk(KERN_WARNING, ha,
 
728
                    "Unable to read XGMAC data (%x).\n", rval);
 
729
                count = 0;
 
730
        }
 
731
 
 
732
        count = actual_size > count ? count: actual_size;
 
733
        memcpy(buf, ha->xgmac_data, count);
 
734
 
 
735
        return count;
 
736
}
 
737
 
 
738
static struct bin_attribute sysfs_xgmac_stats_attr = {
 
739
        .attr = {
 
740
                .name = "xgmac_stats",
 
741
                .mode = S_IRUSR,
 
742
        },
 
743
        .size = 0,
 
744
        .read = qla2x00_sysfs_read_xgmac_stats,
 
745
};
 
746
 
 
747
static ssize_t
 
748
qla2x00_sysfs_read_dcbx_tlv(struct kobject *kobj,
 
749
                       struct bin_attribute *bin_attr,
 
750
                       char *buf, loff_t off, size_t count)
 
751
{
 
752
        struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
 
753
            struct device, kobj)));
 
754
        struct qla_hw_data *ha = vha->hw;
 
755
        int rval;
 
756
        uint16_t actual_size;
 
757
 
 
758
        if (!capable(CAP_SYS_ADMIN) || off != 0 || count > DCBX_TLV_DATA_SIZE)
 
759
                return 0;
 
760
 
 
761
        if (ha->dcbx_tlv)
 
762
                goto do_read;
 
763
 
 
764
        ha->dcbx_tlv = dma_alloc_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE,
 
765
            &ha->dcbx_tlv_dma, GFP_KERNEL);
 
766
        if (!ha->dcbx_tlv) {
 
767
                qla_printk(KERN_WARNING, ha,
 
768
                    "Unable to allocate memory for DCBX TLV read-data.\n");
 
769
                return 0;
 
770
        }
 
771
 
 
772
do_read:
 
773
        actual_size = 0;
 
774
        memset(ha->dcbx_tlv, 0, DCBX_TLV_DATA_SIZE);
 
775
 
 
776
        rval = qla2x00_get_dcbx_params(vha, ha->dcbx_tlv_dma,
 
777
            DCBX_TLV_DATA_SIZE);
 
778
        if (rval != QLA_SUCCESS) {
 
779
                qla_printk(KERN_WARNING, ha,
 
780
                    "Unable to read DCBX TLV data (%x).\n", rval);
 
781
                count = 0;
 
782
        }
 
783
 
 
784
        memcpy(buf, ha->dcbx_tlv, count);
 
785
 
 
786
        return count;
 
787
}
 
788
 
 
789
static struct bin_attribute sysfs_dcbx_tlv_attr = {
 
790
        .attr = {
 
791
                .name = "dcbx_tlv",
 
792
                .mode = S_IRUSR,
 
793
        },
 
794
        .size = 0,
 
795
        .read = qla2x00_sysfs_read_dcbx_tlv,
 
796
};
 
797
 
461
798
static struct sysfs_entry {
462
799
        char *name;
463
800
        struct bin_attribute *attr;
469
806
        { "optrom_ctl", &sysfs_optrom_ctl_attr, },
470
807
        { "vpd", &sysfs_vpd_attr, 1 },
471
808
        { "sfp", &sysfs_sfp_attr, 1 },
 
809
        { "reset", &sysfs_reset_attr, },
 
810
        { "edc", &sysfs_edc_attr, 2 },
 
811
        { "edc_status", &sysfs_edc_status_attr, 2 },
 
812
        { "xgmac_stats", &sysfs_xgmac_stats_attr, 3 },
 
813
        { "dcbx_tlv", &sysfs_dcbx_tlv_attr, 3 },
472
814
        { NULL },
473
815
};
474
816
 
482
824
        for (iter = bin_file_entries; iter->name; iter++) {
483
825
                if (iter->is4GBp_only && !IS_FWI2_CAPABLE(vha->hw))
484
826
                        continue;
 
827
                if (iter->is4GBp_only == 2 && !IS_QLA25XX(vha->hw))
 
828
                        continue;
 
829
                if (iter->is4GBp_only == 3 && !IS_QLA81XX(vha->hw))
 
830
                        continue;
485
831
 
486
832
                ret = sysfs_create_bin_file(&host->shost_gendev.kobj,
487
833
                    iter->attr);
502
848
        for (iter = bin_file_entries; iter->name; iter++) {
503
849
                if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha))
504
850
                        continue;
 
851
                if (iter->is4GBp_only == 2 && !IS_QLA25XX(ha))
 
852
                        continue;
 
853
                if (iter->is4GBp_only == 3 && !IS_QLA81XX(ha))
 
854
                        continue;
505
855
 
506
856
                sysfs_remove_bin_file(&host->shost_gendev.kobj,
507
857
                    iter->attr);
818
1168
        if (!IS_QLA81XX(ha))
819
1169
                return snprintf(buf, PAGE_SIZE, "\n");
820
1170
 
821
 
        return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x (%x)\n",
 
1171
        return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
822
1172
            ha->mpi_version[0], ha->mpi_version[1], ha->mpi_version[2],
823
 
            ha->mpi_version[3], ha->mpi_capabilities);
 
1173
            ha->mpi_capabilities);
 
1174
}
 
1175
 
 
1176
static ssize_t
 
1177
qla2x00_phy_version_show(struct device *dev, struct device_attribute *attr,
 
1178
    char *buf)
 
1179
{
 
1180
        scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
 
1181
        struct qla_hw_data *ha = vha->hw;
 
1182
 
 
1183
        if (!IS_QLA81XX(ha))
 
1184
                return snprintf(buf, PAGE_SIZE, "\n");
 
1185
 
 
1186
        return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d\n",
 
1187
            ha->phy_version[0], ha->phy_version[1], ha->phy_version[2]);
 
1188
}
 
1189
 
 
1190
static ssize_t
 
1191
qla2x00_flash_block_size_show(struct device *dev,
 
1192
                              struct device_attribute *attr, char *buf)
 
1193
{
 
1194
        scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
 
1195
        struct qla_hw_data *ha = vha->hw;
 
1196
 
 
1197
        return snprintf(buf, PAGE_SIZE, "0x%x\n", ha->fdt_block_size);
 
1198
}
 
1199
 
 
1200
static ssize_t
 
1201
qla2x00_vlan_id_show(struct device *dev, struct device_attribute *attr,
 
1202
    char *buf)
 
1203
{
 
1204
        scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
 
1205
 
 
1206
        if (!IS_QLA81XX(vha->hw))
 
1207
                return snprintf(buf, PAGE_SIZE, "\n");
 
1208
 
 
1209
        return snprintf(buf, PAGE_SIZE, "%d\n", vha->fcoe_vlan_id);
 
1210
}
 
1211
 
 
1212
static ssize_t
 
1213
qla2x00_vn_port_mac_address_show(struct device *dev,
 
1214
    struct device_attribute *attr, char *buf)
 
1215
{
 
1216
        scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
 
1217
 
 
1218
        if (!IS_QLA81XX(vha->hw))
 
1219
                return snprintf(buf, PAGE_SIZE, "\n");
 
1220
 
 
1221
        return snprintf(buf, PAGE_SIZE, "%02x:%02x:%02x:%02x:%02x:%02x\n",
 
1222
            vha->fcoe_vn_port_mac[5], vha->fcoe_vn_port_mac[4],
 
1223
            vha->fcoe_vn_port_mac[3], vha->fcoe_vn_port_mac[2],
 
1224
            vha->fcoe_vn_port_mac[1], vha->fcoe_vn_port_mac[0]);
 
1225
}
 
1226
 
 
1227
static ssize_t
 
1228
qla2x00_fabric_param_show(struct device *dev, struct device_attribute *attr,
 
1229
    char *buf)
 
1230
{
 
1231
        scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
 
1232
 
 
1233
        return snprintf(buf, PAGE_SIZE, "%d\n", vha->hw->switch_cap);
 
1234
}
 
1235
 
 
1236
static ssize_t
 
1237
qla2x00_fw_state_show(struct device *dev, struct device_attribute *attr,
 
1238
    char *buf)
 
1239
{
 
1240
        scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
 
1241
        int rval;
 
1242
        uint16_t state[5];
 
1243
 
 
1244
        rval = qla2x00_get_firmware_state(vha, state);
 
1245
        if (rval != QLA_SUCCESS)
 
1246
                memset(state, -1, sizeof(state));
 
1247
 
 
1248
        return snprintf(buf, PAGE_SIZE, "0x%x 0x%x 0x%x 0x%x 0x%x\n", state[0],
 
1249
            state[1], state[2], state[3], state[4]);
824
1250
}
825
1251
 
826
1252
static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL);
848
1274
static DEVICE_ATTR(total_isp_aborts, S_IRUGO, qla2x00_total_isp_aborts_show,
849
1275
                   NULL);
850
1276
static DEVICE_ATTR(mpi_version, S_IRUGO, qla2x00_mpi_version_show, NULL);
 
1277
static DEVICE_ATTR(phy_version, S_IRUGO, qla2x00_phy_version_show, NULL);
 
1278
static DEVICE_ATTR(flash_block_size, S_IRUGO, qla2x00_flash_block_size_show,
 
1279
                   NULL);
 
1280
static DEVICE_ATTR(vlan_id, S_IRUGO, qla2x00_vlan_id_show, NULL);
 
1281
static DEVICE_ATTR(vn_port_mac_address, S_IRUGO,
 
1282
                   qla2x00_vn_port_mac_address_show, NULL);
 
1283
static DEVICE_ATTR(fabric_param, S_IRUGO, qla2x00_fabric_param_show, NULL);
 
1284
static DEVICE_ATTR(fw_state, S_IRUGO, qla2x00_fw_state_show, NULL);
851
1285
 
852
1286
struct device_attribute *qla2x00_host_attrs[] = {
853
1287
        &dev_attr_driver_version,
868
1302
        &dev_attr_optrom_fw_version,
869
1303
        &dev_attr_total_isp_aborts,
870
1304
        &dev_attr_mpi_version,
 
1305
        &dev_attr_phy_version,
 
1306
        &dev_attr_flash_block_size,
 
1307
        &dev_attr_vlan_id,
 
1308
        &dev_attr_vn_port_mac_address,
 
1309
        &dev_attr_fabric_param,
 
1310
        &dev_attr_fw_state,
871
1311
        NULL,
872
1312
};
873
1313
 
1012
1452
        if (!fcport)
1013
1453
                return;
1014
1454
 
1015
 
        qla2x00_abort_fcport_cmds(fcport);
 
1455
        if (unlikely(pci_channel_offline(fcport->vha->hw->pdev)))
 
1456
                qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
 
1457
        else
 
1458
                qla2x00_abort_fcport_cmds(fcport);
1016
1459
 
1017
1460
        /*
1018
1461
         * Transport has effectively 'deleted' the rport, clear
1032
1475
        if (!fcport)
1033
1476
                return;
1034
1477
 
 
1478
        if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) {
 
1479
                qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
 
1480
                return;
 
1481
        }
1035
1482
        /*
1036
1483
         * At this point all fcport's software-states are cleared.  Perform any
1037
1484
         * final cleanup of firmware resources (PCBs and XCBs).
1038
1485
         */
1039
 
        if (fcport->loop_id != FC_NO_LOOP_ID) {
 
1486
        if (fcport->loop_id != FC_NO_LOOP_ID &&
 
1487
            !test_bit(UNLOADING, &fcport->vha->dpc_flags))
1040
1488
                fcport->vha->hw->isp_ops->fabric_logout(fcport->vha,
1041
1489
                        fcport->loop_id, fcport->d_id.b.domain,
1042
1490
                        fcport->d_id.b.area, fcport->d_id.b.al_pa);
1043
 
                fcport->loop_id = FC_NO_LOOP_ID;
1044
 
        }
1045
1491
 
1046
1492
        qla2x00_abort_fcport_cmds(fcport);
1047
1493
}
1162
1608
qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
1163
1609
{
1164
1610
        int     ret = 0;
1165
 
        int     cnt = 0;
1166
 
        uint8_t qos = QLA_DEFAULT_QUE_QOS;
 
1611
        uint8_t qos = 0;
1167
1612
        scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
1168
1613
        scsi_qla_host_t *vha = NULL;
1169
1614
        struct qla_hw_data *ha = base_vha->hw;
 
1615
        uint16_t options = 0;
 
1616
        int     cnt;
 
1617
        struct req_que *req = ha->req_q_map[0];
1170
1618
 
1171
1619
        ret = qla24xx_vport_create_req_sanity_check(fc_vport);
1172
1620
        if (ret) {
1222
1670
 
1223
1671
        qla24xx_vport_disable(fc_vport, disable);
1224
1672
 
1225
 
        /* Create a queue pair for the vport */
1226
 
        if (ha->mqenable) {
1227
 
                if (ha->npiv_info) {
1228
 
                        for (; cnt < ha->nvram_npiv_size; cnt++) {
1229
 
                                if (ha->npiv_info[cnt].port_name ==
1230
 
                                        vha->port_name &&
1231
 
                                        ha->npiv_info[cnt].node_name ==
1232
 
                                        vha->node_name) {
1233
 
                                        qos = ha->npiv_info[cnt].q_qos;
1234
 
                                        break;
1235
 
                                }
1236
 
                        }
1237
 
                }
1238
 
                qla25xx_create_queues(vha, qos);
 
1673
        if (ql2xmultique_tag) {
 
1674
                req = ha->req_q_map[1];
 
1675
                goto vport_queue;
 
1676
        } else if (ql2xmaxqueues == 1 || !ha->npiv_info)
 
1677
                goto vport_queue;
 
1678
        /* Create a request queue in QoS mode for the vport */
 
1679
        for (cnt = 0; cnt < ha->nvram_npiv_size; cnt++) {
 
1680
                if (memcmp(ha->npiv_info[cnt].port_name, vha->port_name, 8) == 0
 
1681
                        && memcmp(ha->npiv_info[cnt].node_name, vha->node_name,
 
1682
                                        8) == 0) {
 
1683
                        qos = ha->npiv_info[cnt].q_qos;
 
1684
                        break;
 
1685
                }
 
1686
        }
 
1687
        if (qos) {
 
1688
                ret = qla25xx_create_req_que(ha, options, vha->vp_idx, 0, 0,
 
1689
                        qos);
 
1690
                if (!ret)
 
1691
                        qla_printk(KERN_WARNING, ha,
 
1692
                        "Can't create request queue for vp_idx:%d\n",
 
1693
                        vha->vp_idx);
 
1694
                else {
 
1695
                        DEBUG2(qla_printk(KERN_INFO, ha,
 
1696
                        "Request Que:%d (QoS: %d) created for vp_idx:%d\n",
 
1697
                        ret, qos, vha->vp_idx));
 
1698
                        req = ha->req_q_map[ret];
 
1699
                }
1239
1700
        }
1240
1701
 
 
1702
vport_queue:
 
1703
        vha->req = req;
1241
1704
        return 0;
 
1705
 
1242
1706
vport_create_failed_2:
1243
1707
        qla24xx_disable_vp(vha);
1244
1708
        qla24xx_deallocate_vp_id(vha);
1279
1743
                    vha->host_no, vha->vp_idx, vha));
1280
1744
        }
1281
1745
 
1282
 
        if (ha->mqenable) {
1283
 
                if (qla25xx_delete_queues(vha, 0) != QLA_SUCCESS)
 
1746
        if (vha->req->id && !ql2xmultique_tag) {
 
1747
                if (qla25xx_delete_req_que(vha, vha->req) != QLA_SUCCESS)
1284
1748
                        qla_printk(KERN_WARNING, ha,
1285
1749
                                "Queue delete failed.\n");
1286
1750
        }