12 #include <linux/slab.h>
15 static int qla24xx_vport_disable(
struct fc_vport *,
bool);
20 qla2x00_sysfs_read_fw_dump(
struct file *filp,
struct kobject *kobj,
53 qla2x00_sysfs_write_fw_dump(
struct file *filp,
struct kobject *kobj,
55 char *buf, loff_t off,
size_t count)
72 "Firmware dump cleared on (%ld).\n", vha->
host_no);
86 "Raw firmware dump ready for read on (%ld).\n",
105 "MiniDump supported with this firmware.\n");
108 "MiniDump not supported with this firmware.\n");
119 "MCTP dump cleared on (%ld).\n", vha->
host_no);
127 "Raw mctp dump ready for read on (%ld).\n",
141 .read = qla2x00_sysfs_read_fw_dump,
142 .write = qla2x00_sysfs_write_fw_dump,
146 qla2x00_sysfs_read_nvram(
struct file *filp,
struct kobject *kobj,
148 char *buf, loff_t off,
size_t count)
165 qla2x00_sysfs_write_nvram(
struct file *filp,
struct kobject *kobj,
167 char *buf, loff_t off,
size_t count)
185 for (cnt = 0; cnt < ((count >> 2) - 1); cnt++)
187 chksum = ~chksum + 1;
195 for (cnt = 0; cnt < count - 1; cnt++)
197 chksum = ~chksum + 1;
203 "HBA not online, failing NVRAM update.\n");
213 "Setting ISP_ABORT_NEEDED\n");
228 .read = qla2x00_sysfs_read_nvram,
229 .write = qla2x00_sysfs_write_nvram,
233 qla2x00_sysfs_read_optrom(
struct file *filp,
struct kobject *kobj,
235 char *buf, loff_t off,
size_t count)
249 qla2x00_sysfs_write_optrom(
struct file *filp,
struct kobject *kobj,
251 char *buf, loff_t off,
size_t count)
275 .read = qla2x00_sysfs_read_optrom,
276 .write = qla2x00_sysfs_write_optrom,
280 qla2x00_sysfs_write_optrom_ctl(
struct file *filp,
struct kobject *kobj,
282 char *buf, loff_t off,
size_t count)
298 if (
sscanf(buf,
"%d:%x:%x", &val, &start, &size) < 1)
312 "Freeing flash region allocation -- 0x%x bytes.\n",
330 "Unable to allocate memory for optrom retrieval "
339 "HBA not online, failing NVRAM update.\n");
344 "Reading flash region -- 0x%x/0x%x.\n",
386 "Invalid start region 0x%x/0x%x.\n", start, size);
398 "Unable to allocate memory for optrom update "
406 "Staging flash region write -- 0x%x/0x%x.\n",
417 "HBA not online, failing flash update.\n");
422 "Writing flash region -- 0x%x/0x%x.\n",
436 .name =
"optrom_ctl",
440 .write = qla2x00_sysfs_write_optrom_ctl,
444 qla2x00_sysfs_read_vpd(
struct file *filp,
struct kobject *kobj,
446 char *buf, loff_t off,
size_t count)
465 qla2x00_sysfs_write_vpd(
struct file *filp,
struct kobject *kobj,
467 char *buf, loff_t off,
size_t count)
483 "HBA not online, failing VPD update.\n");
498 "Unable to allocate memory for VPD information update.\n");
501 ha->
isp_ops->get_flash_version(vha, tmp_data);
513 .read = qla2x00_sysfs_read_vpd,
514 .write = qla2x00_sysfs_write_vpd,
518 qla2x00_sysfs_read_sfp(
struct file *filp,
struct kobject *kobj,
520 char *buf, loff_t off,
size_t count)
538 "Unable to allocate memory for SFP read-data.\n");
557 "Unable to read SFP data (%x/%x/%x).\n", rval,
575 .read = qla2x00_sysfs_read_sfp,
579 qla2x00_sysfs_write_reset(
struct file *filp,
struct kobject *kobj,
581 char *buf, loff_t off,
size_t count)
597 "Issuing ISP reset.\n");
602 ha->
flags.isp82xx_no_md_cap = 1;
616 "Issuing MPI reset.\n");
638 "MPI reset failed.\n");
645 "FCoE ctx reset no supported.\n");
650 "Issuing FCoE ctx reset.\n");
659 "Disabling Reset by IDC control\n");
670 "Enabling Reset by IDC control\n");
688 .write = qla2x00_sysfs_write_reset,
692 qla2x00_sysfs_read_xgmac_stats(
struct file *filp,
struct kobject *kobj,
694 char *buf, loff_t off,
size_t count)
712 "Unable to allocate memory for XGMAC read-data.\n");
724 "Unable to read XGMAC data (%x).\n", rval);
728 count = actual_size > count ? count: actual_size;
736 .name =
"xgmac_stats",
740 .read = qla2x00_sysfs_read_xgmac_stats,
744 qla2x00_sysfs_read_dcbx_tlv(
struct file *filp,
struct kobject *kobj,
746 char *buf, loff_t off,
size_t count)
764 "Unable to allocate memory for DCBX TLV read-data.\n");
776 "Unable to read DCBX TLV (%x).\n", rval);
791 .read = qla2x00_sysfs_read_dcbx_tlv,
794 static struct sysfs_entry {
798 } bin_file_entries[] = {
799 {
"fw_dump", &sysfs_fw_dump_attr, },
800 {
"nvram", &sysfs_nvram_attr, },
801 {
"optrom", &sysfs_optrom_attr, },
802 {
"optrom_ctl", &sysfs_optrom_ctl_attr, },
803 {
"vpd", &sysfs_vpd_attr, 1 },
804 {
"sfp", &sysfs_sfp_attr, 1 },
805 {
"reset", &sysfs_reset_attr, },
806 {
"xgmac_stats", &sysfs_xgmac_stats_attr, 3 },
807 {
"dcbx_tlv", &sysfs_dcbx_tlv_attr, 3 },
815 struct sysfs_entry *iter;
818 for (iter = bin_file_entries; iter->name; iter++) {
830 "Unable to create sysfs %s binary attribute (%d).\n",
834 "Successfully created sysfs %s binary attribure.\n",
843 struct sysfs_entry *iter;
846 for (iter = bin_file_entries; iter->name; iter++) {
849 if (iter->is4GBp_only == 2 && !
IS_QLA25XX(ha))
865 qla2x00_drvr_version_show(
struct device *
dev,
872 qla2x00_fw_version_show(
struct device *
dev,
880 ha->
isp_ops->fw_version_str(vha, fw_str));
934 vha->
hw->model_desc ? vha->
hw->model_desc :
"");
945 vha->
hw->isp_ops->pci_info_str(vha, pci_info));
961 qla2x00_reset_active(vha))
975 "N_Port to N_Port\n");
995 switch (vha->
hw->zio_mode) {
1008 const char *buf,
size_t count)
1018 if (
sscanf(buf,
"%d", &val) != 1)
1045 const char *buf,
size_t count)
1051 if (
sscanf(buf,
"%d", &val) != 1)
1053 if (val > 25500 || val < 100)
1069 if (vha->
hw->beacon_blink_led)
1078 const char *buf,
size_t count)
1090 "Abort ISP active -- ignoring beacon request.\n");
1094 if (
sscanf(buf,
"%d", &val) != 1)
1098 rval = ha->
isp_ops->beacon_on(vha);
1100 rval = ha->
isp_ops->beacon_off(vha);
1109 qla2x00_optrom_bios_version_show(
struct device *dev,
1119 qla2x00_optrom_efi_version_show(
struct device *dev,
1129 qla2x00_optrom_fcode_version_show(
struct device *dev,
1139 qla2x00_optrom_fw_version_show(
struct device *dev,
1150 qla2x00_optrom_gold_fw_version_show(
struct device *dev,
1165 qla2x00_total_isp_aborts_show(
struct device *dev,
1174 qla24xx_84xx_fw_version_show(
struct device *dev,
1185 if (ha->
cs84xx->op_fw_version == 0)
1225 qla2x00_flash_block_size_show(
struct device *dev,
1247 qla2x00_vn_port_mac_address_show(
struct device *dev,
1271 qla2x00_thermal_temp_show(
struct device *dev,
1278 if (!vha->
hw->flags.thermal_supported)
1282 if (qla2x00_reset_active(vha))
1284 "ISP reset active.\n");
1285 else if (!vha->
hw->flags.eeh_busy)
1301 if (qla2x00_reset_active(vha))
1303 "ISP reset active.\n");
1304 else if (!vha->
hw->flags.eeh_busy)
1307 memset(state, -1,
sizeof(state));
1310 state[1], state[2], state[3], state[4]);
1314 qla2x00_diag_requests_show(
struct device *dev,
1326 qla2x00_diag_megabytes_show(
struct device *dev,
1367 qla2x00_zio_timer_store);
1369 qla2x00_beacon_store);
1371 qla2x00_optrom_bios_version_show,
NULL);
1373 qla2x00_optrom_efi_version_show,
NULL);
1375 qla2x00_optrom_fcode_version_show,
NULL);
1379 qla2x00_optrom_gold_fw_version_show,
NULL);
1390 qla2x00_vn_port_mac_address_show,
NULL);
1399 &dev_attr_driver_version,
1400 &dev_attr_fw_version,
1401 &dev_attr_serial_num,
1404 &dev_attr_model_name,
1405 &dev_attr_model_desc,
1407 &dev_attr_link_state,
1409 &dev_attr_zio_timer,
1411 &dev_attr_optrom_bios_version,
1412 &dev_attr_optrom_efi_version,
1413 &dev_attr_optrom_fcode_version,
1414 &dev_attr_optrom_fw_version,
1415 &dev_attr_84xx_fw_version,
1416 &dev_attr_total_isp_aborts,
1417 &dev_attr_mpi_version,
1418 &dev_attr_phy_version,
1419 &dev_attr_flash_block_size,
1421 &dev_attr_vn_port_mac_address,
1422 &dev_attr_fabric_param,
1424 &dev_attr_optrom_gold_fw_version,
1425 &dev_attr_thermal_temp,
1426 &dev_attr_diag_requests,
1427 &dev_attr_diag_megabytes,
1428 &dev_attr_fw_dump_size,
1447 (shost_priv(shost)))->hw;
1474 qla2x00_get_host_port_type(
struct Scsi_Host *shost)
1483 switch (vha->
hw->current_topology) {
1501 qla2x00_get_starget_node_name(
struct scsi_target *starget)
1509 if (fcport->
rport &&
1510 starget->
id == fcport->
rport->scsi_target_id) {
1511 node_name = wwn_to_u64(fcport->
node_name);
1520 qla2x00_get_starget_port_name(
struct scsi_target *starget)
1522 struct Scsi_Host *host = dev_to_shost(starget->
dev.parent);
1528 if (fcport->
rport &&
1529 starget->
id == fcport->
rport->scsi_target_id) {
1530 port_name = wwn_to_u64(fcport->
port_name);
1539 qla2x00_get_starget_port_id(
struct scsi_target *starget)
1541 struct Scsi_Host *host = dev_to_shost(starget->
dev.parent);
1547 if (fcport->
rport &&
1548 starget->
id == fcport->
rport->scsi_target_id) {
1549 port_id = fcport->
d_id.
b.domain << 16 |
1550 fcport->
d_id.
b.area << 8 | fcport->
d_id.
b.al_pa;
1568 qla2x00_dev_loss_tmo_callbk(
struct fc_rport *rport)
1572 unsigned long flags;
1593 if (
unlikely(pci_channel_offline(fcport->
vha->hw->pdev))) {
1600 qla2x00_terminate_rport_io(
struct fc_rport *rport)
1610 if (
unlikely(pci_channel_offline(fcport->
vha->hw->pdev))) {
1621 fcport->
vha->hw->isp_ops->fabric_logout(fcport->
vha,
1630 qla2x00_issue_lip(
struct Scsi_Host *shost)
1639 qla2x00_get_fc_host_stats(
struct Scsi_Host *shost)
1659 if (stats ==
NULL) {
1661 "Failed to allocate memory for stats.\n");
1670 !qla2x00_reset_active(vha) && !ha->
dpc_active) {
1698 return pfc_host_stat;
1702 qla2x00_get_host_symbolic_name(
struct Scsi_Host *shost)
1710 qla2x00_set_host_system_hostname(
struct Scsi_Host *shost)
1718 qla2x00_get_host_fabric_name(
struct Scsi_Host *shost)
1722 0xFF, 0xFF, 0xFF, 0xFF};
1723 u64 fabric_name = wwn_to_u64(node_name);
1732 qla2x00_get_host_port_state(
struct Scsi_Host *shost)
1737 if (!base_vha->
flags.online) {
1779 "Vport sanity check failed, status %x\n", ret);
1796 "VP entry id %d assigned.\n", vha->
vp_idx);
1807 "Vport loop state is not UP.\n");
1815 int prot = 0, guard;
1816 vha->
flags.difdix_supported = 1;
1818 "Registered for DIF/DIX type 1 and 3 protection.\n");
1821 scsi_host_set_prot(vha->
host,
1835 scsi_host_set_guard(vha->
host, guard);
1837 vha->
flags.difdix_supported = 0;
1843 "scsi_add_host failure for VP[%d].\n", vha->
vp_idx);
1844 goto vport_create_failed_2;
1857 qla24xx_vport_disable(fc_vport, disable);
1859 if (ha->
flags.cpu_affinity_enabled) {
1862 "Request queue %p attached with "
1863 "VP[%d], cpu affinity =%d\n",
1864 req, vha->
vp_idx, ha->
flags.cpu_affinity_enabled);
1883 "Can't create request queue for VP[%d]\n",
1887 "Request Que:%d Q0s: %d) created for VP[%d]\n",
1890 "Request Que:%d Q0s: %d) created for VP[%d]\n",
1900 vport_create_failed_2:
1908 qla24xx_vport_delete(
struct fc_vport *fc_vport)
1920 vha->
flags.delete_progress = 1;
1932 "Timer for the VP[%d] has stopped\n", vha->
vp_idx);
1949 if (vha->
req->id && !ha->
flags.cpu_affinity_enabled) {
1952 "Queue delete failed.\n");
1961 qla24xx_vport_disable(
struct fc_vport *fc_vport,
bool disable)
1975 .show_host_node_name = 1,
1976 .show_host_port_name = 1,
1977 .show_host_supported_classes = 1,
1978 .show_host_supported_speeds = 1,
1980 .get_host_port_id = qla2x00_get_host_port_id,
1981 .show_host_port_id = 1,
1982 .get_host_speed = qla2x00_get_host_speed,
1983 .show_host_speed = 1,
1984 .get_host_port_type = qla2x00_get_host_port_type,
1985 .show_host_port_type = 1,
1986 .get_host_symbolic_name = qla2x00_get_host_symbolic_name,
1987 .show_host_symbolic_name = 1,
1988 .set_host_system_hostname = qla2x00_set_host_system_hostname,
1989 .show_host_system_hostname = 1,
1990 .get_host_fabric_name = qla2x00_get_host_fabric_name,
1991 .show_host_fabric_name = 1,
1992 .get_host_port_state = qla2x00_get_host_port_state,
1993 .show_host_port_state = 1,
1995 .dd_fcrport_size =
sizeof(
struct fc_port *),
1996 .show_rport_supported_classes = 1,
1998 .get_starget_node_name = qla2x00_get_starget_node_name,
1999 .show_starget_node_name = 1,
2000 .get_starget_port_name = qla2x00_get_starget_port_name,
2001 .show_starget_port_name = 1,
2002 .get_starget_port_id = qla2x00_get_starget_port_id,
2003 .show_starget_port_id = 1,
2005 .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
2006 .show_rport_dev_loss_tmo = 1,
2008 .issue_fc_host_lip = qla2x00_issue_lip,
2009 .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk,
2010 .terminate_rport_io = qla2x00_terminate_rport_io,
2011 .get_fc_host_stats = qla2x00_get_fc_host_stats,
2013 .vport_create = qla24xx_vport_create,
2014 .vport_disable = qla24xx_vport_disable,
2015 .vport_delete = qla24xx_vport_delete,
2022 .show_host_node_name = 1,
2023 .show_host_port_name = 1,
2024 .show_host_supported_classes = 1,
2026 .get_host_port_id = qla2x00_get_host_port_id,
2027 .show_host_port_id = 1,
2028 .get_host_speed = qla2x00_get_host_speed,
2029 .show_host_speed = 1,
2030 .get_host_port_type = qla2x00_get_host_port_type,
2031 .show_host_port_type = 1,
2032 .get_host_symbolic_name = qla2x00_get_host_symbolic_name,
2033 .show_host_symbolic_name = 1,
2034 .set_host_system_hostname = qla2x00_set_host_system_hostname,
2035 .show_host_system_hostname = 1,
2036 .get_host_fabric_name = qla2x00_get_host_fabric_name,
2037 .show_host_fabric_name = 1,
2038 .get_host_port_state = qla2x00_get_host_port_state,
2039 .show_host_port_state = 1,
2041 .dd_fcrport_size =
sizeof(
struct fc_port *),
2042 .show_rport_supported_classes = 1,
2044 .get_starget_node_name = qla2x00_get_starget_node_name,
2045 .show_starget_node_name = 1,
2046 .get_starget_port_name = qla2x00_get_starget_port_name,
2047 .show_starget_port_name = 1,
2048 .get_starget_port_id = qla2x00_get_starget_port_id,
2049 .show_starget_port_id = 1,
2051 .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
2052 .show_rport_dev_loss_tmo = 1,
2054 .issue_fc_host_lip = qla2x00_issue_lip,
2055 .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk,
2056 .terminate_rport_io = qla2x00_terminate_rport_io,
2057 .get_fc_host_stats = qla2x00_get_fc_host_stats,