458
499
.read = qla2x00_sysfs_read_sfp,
503
qla2x00_sysfs_write_reset(struct kobject *kobj,
504
struct bin_attribute *bin_attr,
505
char *buf, loff_t off, size_t count)
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;
515
type = simple_strtol(buf, NULL, 10);
518
qla_printk(KERN_INFO, ha,
519
"Issuing ISP reset on (%ld).\n", vha->host_no);
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);
531
qla_printk(KERN_INFO, ha,
532
"Issuing MPI reset on (%ld).\n", vha->host_no);
534
/* Make sure FC side is not in reset */
535
qla2x00_wait_for_hba_online(vha);
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);
548
static struct bin_attribute sysfs_reset_attr = {
554
.write = qla2x00_sysfs_write_reset,
558
qla2x00_sysfs_write_edc(struct kobject *kobj,
559
struct bin_attribute *bin_attr,
560
char *buf, loff_t off, size_t count)
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;
568
ha->edc_data_len = 0;
570
if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8)
574
ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
577
DEBUG2(qla_printk(KERN_INFO, ha,
578
"Unable to allocate memory for EDC write.\n"));
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]);
589
if (len == 0 || len > DMA_POOL_SIZE || len > count - 8)
592
memcpy(ha->edc_data, &buf[8], len);
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));
606
static struct bin_attribute sysfs_edc_attr = {
612
.write = qla2x00_sysfs_write_edc,
616
qla2x00_sysfs_write_edc_status(struct kobject *kobj,
617
struct bin_attribute *bin_attr,
618
char *buf, loff_t off, size_t count)
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;
626
ha->edc_data_len = 0;
628
if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8)
632
ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
635
DEBUG2(qla_printk(KERN_INFO, ha,
636
"Unable to allocate memory for EDC status.\n"));
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]);
647
if (len == 0 || len > DMA_POOL_SIZE)
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));
660
ha->edc_data_len = len;
666
qla2x00_sysfs_read_edc_status(struct kobject *kobj,
667
struct bin_attribute *bin_attr,
668
char *buf, loff_t off, size_t count)
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;
674
if (!capable(CAP_SYS_ADMIN) || off != 0 || count == 0)
677
if (!ha->edc_data || ha->edc_data_len == 0 || ha->edc_data_len > count)
680
memcpy(buf, ha->edc_data, ha->edc_data_len);
682
return ha->edc_data_len;
685
static struct bin_attribute sysfs_edc_status_attr = {
687
.name = "edc_status",
688
.mode = S_IRUSR | S_IWUSR,
691
.write = qla2x00_sysfs_write_edc_status,
692
.read = qla2x00_sysfs_read_edc_status,
696
qla2x00_sysfs_read_xgmac_stats(struct kobject *kobj,
697
struct bin_attribute *bin_attr,
698
char *buf, loff_t off, size_t count)
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;
704
uint16_t actual_size;
706
if (!capable(CAP_SYS_ADMIN) || off != 0 || count > XGMAC_DATA_SIZE)
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");
722
memset(ha->xgmac_data, 0, XGMAC_DATA_SIZE);
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);
732
count = actual_size > count ? count: actual_size;
733
memcpy(buf, ha->xgmac_data, count);
738
static struct bin_attribute sysfs_xgmac_stats_attr = {
740
.name = "xgmac_stats",
744
.read = qla2x00_sysfs_read_xgmac_stats,
748
qla2x00_sysfs_read_dcbx_tlv(struct kobject *kobj,
749
struct bin_attribute *bin_attr,
750
char *buf, loff_t off, size_t count)
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;
756
uint16_t actual_size;
758
if (!capable(CAP_SYS_ADMIN) || off != 0 || count > DCBX_TLV_DATA_SIZE)
764
ha->dcbx_tlv = dma_alloc_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE,
765
&ha->dcbx_tlv_dma, GFP_KERNEL);
767
qla_printk(KERN_WARNING, ha,
768
"Unable to allocate memory for DCBX TLV read-data.\n");
774
memset(ha->dcbx_tlv, 0, DCBX_TLV_DATA_SIZE);
776
rval = qla2x00_get_dcbx_params(vha, ha->dcbx_tlv_dma,
778
if (rval != QLA_SUCCESS) {
779
qla_printk(KERN_WARNING, ha,
780
"Unable to read DCBX TLV data (%x).\n", rval);
784
memcpy(buf, ha->dcbx_tlv, count);
789
static struct bin_attribute sysfs_dcbx_tlv_attr = {
795
.read = qla2x00_sysfs_read_dcbx_tlv,
461
798
static struct sysfs_entry {
463
800
struct bin_attribute *attr;
818
1168
if (!IS_QLA81XX(ha))
819
1169
return snprintf(buf, PAGE_SIZE, "\n");
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);
1177
qla2x00_phy_version_show(struct device *dev, struct device_attribute *attr,
1180
scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1181
struct qla_hw_data *ha = vha->hw;
1183
if (!IS_QLA81XX(ha))
1184
return snprintf(buf, PAGE_SIZE, "\n");
1186
return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d\n",
1187
ha->phy_version[0], ha->phy_version[1], ha->phy_version[2]);
1191
qla2x00_flash_block_size_show(struct device *dev,
1192
struct device_attribute *attr, char *buf)
1194
scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1195
struct qla_hw_data *ha = vha->hw;
1197
return snprintf(buf, PAGE_SIZE, "0x%x\n", ha->fdt_block_size);
1201
qla2x00_vlan_id_show(struct device *dev, struct device_attribute *attr,
1204
scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1206
if (!IS_QLA81XX(vha->hw))
1207
return snprintf(buf, PAGE_SIZE, "\n");
1209
return snprintf(buf, PAGE_SIZE, "%d\n", vha->fcoe_vlan_id);
1213
qla2x00_vn_port_mac_address_show(struct device *dev,
1214
struct device_attribute *attr, char *buf)
1216
scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1218
if (!IS_QLA81XX(vha->hw))
1219
return snprintf(buf, PAGE_SIZE, "\n");
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]);
1228
qla2x00_fabric_param_show(struct device *dev, struct device_attribute *attr,
1231
scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1233
return snprintf(buf, PAGE_SIZE, "%d\n", vha->hw->switch_cap);
1237
qla2x00_fw_state_show(struct device *dev, struct device_attribute *attr,
1240
scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1244
rval = qla2x00_get_firmware_state(vha, state);
1245
if (rval != QLA_SUCCESS)
1246
memset(state, -1, sizeof(state));
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]);
826
1252
static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL);