| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1 | /* |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 2 | * QLogic Fibre Channel HBA Driver |
Andrew Vasquez | 07e264b | 2011-03-30 11:46:23 -0700 | [diff] [blame] | 3 | * Copyright (c) 2003-2011 QLogic Corporation |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 4 | * |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 6 | */ |
| 7 | #include "qla_def.h" |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 8 | #include "qla_target.h" |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 9 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 10 | #include <linux/kthread.h> |
| 7aaef27 | 2005-04-17 16:32:42 -0500 | [diff] [blame] | 11 | #include <linux/vmalloc.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 12 | #include <linux/slab.h> |
FUJITA Tomonori | 00eabe7 | 2008-07-28 11:59:20 +0900 | [diff] [blame] | 13 | #include <linux/delay.h> |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 14 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 15 | static int qla24xx_vport_disable(struct fc_vport *, bool); |
Giridhar Malavali | 6e98016 | 2010-03-19 17:03:58 -0700 | [diff] [blame] | 16 | |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 17 | /* SYSFS attributes --------------------------------------------------------- */ |
| 18 | |
| 19 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 20 | qla2x00_sysfs_read_fw_dump(struct file *filp, struct kobject *kobj, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 21 | struct bin_attribute *bin_attr, |
| 22 | char *buf, loff_t off, size_t count) |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 23 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 24 | struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 25 | struct device, kobj))); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 26 | struct qla_hw_data *ha = vha->hw; |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 27 | int rval = 0; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 28 | |
| 29 | if (ha->fw_dump_reading == 0) |
| 30 | return 0; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 31 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 32 | if (IS_QLA82XX(ha)) { |
| 33 | if (off < ha->md_template_size) { |
| 34 | rval = memory_read_from_buffer(buf, count, |
| 35 | &off, ha->md_tmplt_hdr, ha->md_template_size); |
| 36 | return rval; |
| 37 | } |
| 38 | off -= ha->md_template_size; |
| 39 | rval = memory_read_from_buffer(buf, count, |
| 40 | &off, ha->md_dump, ha->md_dump_size); |
| 41 | return rval; |
| 42 | } else |
| 43 | return memory_read_from_buffer(buf, count, &off, ha->fw_dump, |
Akinobu Mita | b3dc908 | 2008-07-24 08:31:47 -0700 | [diff] [blame] | 44 | ha->fw_dump_len); |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 48 | qla2x00_sysfs_write_fw_dump(struct file *filp, struct kobject *kobj, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 49 | struct bin_attribute *bin_attr, |
| 50 | char *buf, loff_t off, size_t count) |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 51 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 52 | struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 53 | struct device, kobj))); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 54 | struct qla_hw_data *ha = vha->hw; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 55 | int reading; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 56 | |
| 57 | if (off != 0) |
| 58 | return (0); |
| 59 | |
| 60 | reading = simple_strtol(buf, NULL, 10); |
| 61 | switch (reading) { |
| 62 | case 0: |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 63 | if (!ha->fw_dump_reading) |
| 64 | break; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 65 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 66 | ql_log(ql_log_info, vha, 0x705d, |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 67 | "Firmware dump cleared on (%ld).\n", vha->host_no); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 68 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 69 | if (IS_QLA82XX(vha->hw)) { |
| 70 | qla82xx_md_free(vha); |
| 71 | qla82xx_md_prep(vha); |
| 72 | } |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 73 | ha->fw_dump_reading = 0; |
| 74 | ha->fw_dumped = 0; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 75 | break; |
| 76 | case 1: |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 77 | if (ha->fw_dumped && !ha->fw_dump_reading) { |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 78 | ha->fw_dump_reading = 1; |
| 79 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 80 | ql_log(ql_log_info, vha, 0x705e, |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 81 | "Raw firmware dump ready for read on (%ld).\n", |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 82 | vha->host_no); |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 83 | } |
| 84 | break; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 85 | case 2: |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 86 | qla2x00_alloc_fw_dump(vha); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 87 | break; |
Andrew Vasquez | 68af081 | 2008-05-12 22:21:13 -0700 | [diff] [blame] | 88 | case 3: |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 89 | if (IS_QLA82XX(ha)) { |
| 90 | qla82xx_idc_lock(ha); |
| 91 | qla82xx_set_reset_owner(vha); |
| 92 | qla82xx_idc_unlock(ha); |
| 93 | } else |
| 94 | qla2x00_system_error(vha); |
| 95 | break; |
| 96 | case 4: |
| 97 | if (IS_QLA82XX(ha)) { |
| 98 | if (ha->md_tmplt_hdr) |
| 99 | ql_dbg(ql_dbg_user, vha, 0x705b, |
| 100 | "MiniDump supported with this firmware.\n"); |
| 101 | else |
| 102 | ql_dbg(ql_dbg_user, vha, 0x709d, |
| 103 | "MiniDump not supported with this firmware.\n"); |
| 104 | } |
| 105 | break; |
| 106 | case 5: |
| 107 | if (IS_QLA82XX(ha)) |
| 108 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 68af081 | 2008-05-12 22:21:13 -0700 | [diff] [blame] | 109 | break; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 110 | } |
Joe Carnuccio | 71dfe9e | 2011-11-18 09:03:13 -0800 | [diff] [blame] | 111 | return count; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | static struct bin_attribute sysfs_fw_dump_attr = { |
| 115 | .attr = { |
| 116 | .name = "fw_dump", |
| 117 | .mode = S_IRUSR | S_IWUSR, |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 118 | }, |
| 119 | .size = 0, |
| 120 | .read = qla2x00_sysfs_read_fw_dump, |
| 121 | .write = qla2x00_sysfs_write_fw_dump, |
| 122 | }; |
| 123 | |
| 124 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 125 | qla2x00_sysfs_read_nvram(struct file *filp, struct kobject *kobj, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 126 | struct bin_attribute *bin_attr, |
| 127 | char *buf, loff_t off, size_t count) |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 128 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 129 | struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 130 | struct device, kobj))); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 131 | struct qla_hw_data *ha = vha->hw; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 132 | |
Akinobu Mita | b3dc908 | 2008-07-24 08:31:47 -0700 | [diff] [blame] | 133 | if (!capable(CAP_SYS_ADMIN)) |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 134 | return 0; |
| 135 | |
Andrew Vasquez | 6749ce3 | 2009-03-24 09:08:17 -0700 | [diff] [blame] | 136 | if (IS_NOCACHE_VPD_TYPE(ha)) |
Andrew Vasquez | 8f97975 | 2009-04-06 22:33:43 -0700 | [diff] [blame] | 137 | ha->isp_ops->read_optrom(vha, ha->nvram, ha->flt_region_nvram << 2, |
Andrew Vasquez | 6749ce3 | 2009-03-24 09:08:17 -0700 | [diff] [blame] | 138 | ha->nvram_size); |
Akinobu Mita | b3dc908 | 2008-07-24 08:31:47 -0700 | [diff] [blame] | 139 | return memory_read_from_buffer(buf, count, &off, ha->nvram, |
| 140 | ha->nvram_size); |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 144 | qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 145 | struct bin_attribute *bin_attr, |
| 146 | char *buf, loff_t off, size_t count) |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 147 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 148 | struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 149 | struct device, kobj))); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 150 | struct qla_hw_data *ha = vha->hw; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 151 | uint16_t cnt; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 152 | |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 153 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size || |
| 154 | !ha->isp_ops->write_nvram) |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 155 | return -EINVAL; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 156 | |
| 157 | /* Checksum NVRAM. */ |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 158 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 459c537 | 2005-07-06 10:31:07 -0700 | [diff] [blame] | 159 | uint32_t *iter; |
| 160 | uint32_t chksum; |
| 161 | |
| 162 | iter = (uint32_t *)buf; |
| 163 | chksum = 0; |
| 164 | for (cnt = 0; cnt < ((count >> 2) - 1); cnt++) |
| 165 | chksum += le32_to_cpu(*iter++); |
| 166 | chksum = ~chksum + 1; |
| 167 | *iter = cpu_to_le32(chksum); |
| 168 | } else { |
| 169 | uint8_t *iter; |
| 170 | uint8_t chksum; |
| 171 | |
| 172 | iter = (uint8_t *)buf; |
| 173 | chksum = 0; |
| 174 | for (cnt = 0; cnt < count - 1; cnt++) |
| 175 | chksum += *iter++; |
| 176 | chksum = ~chksum + 1; |
| 177 | *iter = chksum; |
| 178 | } |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 179 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 180 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 181 | ql_log(ql_log_warn, vha, 0x705f, |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 182 | "HBA not online, failing NVRAM update.\n"); |
| 183 | return -EAGAIN; |
| 184 | } |
| 185 | |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 186 | /* Write NVRAM. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 187 | ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->nvram_base, count); |
| 188 | ha->isp_ops->read_nvram(vha, (uint8_t *)ha->nvram, ha->nvram_base, |
Seokmann Ju | 281afe1 | 2007-07-26 13:43:34 -0700 | [diff] [blame] | 189 | count); |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 190 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 191 | ql_dbg(ql_dbg_user, vha, 0x7060, |
| 192 | "Setting ISP_ABORT_NEEDED\n"); |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 193 | /* NVRAM settings take effect immediately. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 194 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 195 | qla2xxx_wake_dpc(vha); |
| 196 | qla2x00_wait_for_chip_reset(vha); |
Andrew Vasquez | 26b8d348 | 2007-01-29 10:22:28 -0800 | [diff] [blame] | 197 | |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 198 | return count; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | static struct bin_attribute sysfs_nvram_attr = { |
| 202 | .attr = { |
| 203 | .name = "nvram", |
| 204 | .mode = S_IRUSR | S_IWUSR, |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 205 | }, |
andrew.vasquez@qlogic.com | 1b3f636 | 2006-01-31 16:05:12 -0800 | [diff] [blame] | 206 | .size = 512, |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 207 | .read = qla2x00_sysfs_read_nvram, |
| 208 | .write = qla2x00_sysfs_write_nvram, |
| 209 | }; |
| 210 | |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 211 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 212 | qla2x00_sysfs_read_optrom(struct file *filp, struct kobject *kobj, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 213 | struct bin_attribute *bin_attr, |
| 214 | char *buf, loff_t off, size_t count) |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 215 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 216 | struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 217 | struct device, kobj))); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 218 | struct qla_hw_data *ha = vha->hw; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 219 | |
| 220 | if (ha->optrom_state != QLA_SREADING) |
| 221 | return 0; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 222 | |
Akinobu Mita | b3dc908 | 2008-07-24 08:31:47 -0700 | [diff] [blame] | 223 | return memory_read_from_buffer(buf, count, &off, ha->optrom_buffer, |
| 224 | ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 228 | qla2x00_sysfs_write_optrom(struct file *filp, struct kobject *kobj, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 229 | struct bin_attribute *bin_attr, |
| 230 | char *buf, loff_t off, size_t count) |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 231 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 232 | struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 233 | struct device, kobj))); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 234 | struct qla_hw_data *ha = vha->hw; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 235 | |
| 236 | if (ha->optrom_state != QLA_SWRITING) |
| 237 | return -EINVAL; |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 238 | if (off > ha->optrom_region_size) |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 239 | return -ERANGE; |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 240 | if (off + count > ha->optrom_region_size) |
| 241 | count = ha->optrom_region_size - off; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 242 | |
| 243 | memcpy(&ha->optrom_buffer[off], buf, count); |
| 244 | |
| 245 | return count; |
| 246 | } |
| 247 | |
| 248 | static struct bin_attribute sysfs_optrom_attr = { |
| 249 | .attr = { |
| 250 | .name = "optrom", |
| 251 | .mode = S_IRUSR | S_IWUSR, |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 252 | }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 253 | .size = 0, |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 254 | .read = qla2x00_sysfs_read_optrom, |
| 255 | .write = qla2x00_sysfs_write_optrom, |
| 256 | }; |
| 257 | |
| 258 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 259 | qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 260 | struct bin_attribute *bin_attr, |
| 261 | char *buf, loff_t off, size_t count) |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 262 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 263 | struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 264 | struct device, kobj))); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 265 | struct qla_hw_data *ha = vha->hw; |
| 266 | |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 267 | uint32_t start = 0; |
| 268 | uint32_t size = ha->optrom_size; |
| 269 | int val, valid; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 270 | |
| 271 | if (off) |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 272 | return -EINVAL; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 273 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 274 | if (unlikely(pci_channel_offline(ha->pdev))) |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 275 | return -EAGAIN; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 276 | |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 277 | if (sscanf(buf, "%d:%x:%x", &val, &start, &size) < 1) |
| 278 | return -EINVAL; |
| 279 | if (start > ha->optrom_size) |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 280 | return -EINVAL; |
| 281 | |
| 282 | switch (val) { |
| 283 | case 0: |
| 284 | if (ha->optrom_state != QLA_SREADING && |
| 285 | ha->optrom_state != QLA_SWRITING) |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 286 | return -EINVAL; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 287 | |
| 288 | ha->optrom_state = QLA_SWAITING; |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 289 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 290 | ql_dbg(ql_dbg_user, vha, 0x7061, |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 291 | "Freeing flash region allocation -- 0x%x bytes.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 292 | ha->optrom_region_size); |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 293 | |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 294 | vfree(ha->optrom_buffer); |
| 295 | ha->optrom_buffer = NULL; |
| 296 | break; |
| 297 | case 1: |
| 298 | if (ha->optrom_state != QLA_SWAITING) |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 299 | return -EINVAL; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 300 | |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 301 | ha->optrom_region_start = start; |
| 302 | ha->optrom_region_size = start + size > ha->optrom_size ? |
| 303 | ha->optrom_size - start : size; |
| 304 | |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 305 | ha->optrom_state = QLA_SREADING; |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 306 | ha->optrom_buffer = vmalloc(ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 307 | if (ha->optrom_buffer == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 308 | ql_log(ql_log_warn, vha, 0x7062, |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 309 | "Unable to allocate memory for optrom retrieval " |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 310 | "(%x).\n", ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 311 | |
| 312 | ha->optrom_state = QLA_SWAITING; |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 313 | return -ENOMEM; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 314 | } |
| 315 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 316 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 317 | ql_log(ql_log_warn, vha, 0x7063, |
| 318 | "HBA not online, failing NVRAM update.\n"); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 319 | return -EAGAIN; |
| 320 | } |
| 321 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 322 | ql_dbg(ql_dbg_user, vha, 0x7064, |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 323 | "Reading flash region -- 0x%x/0x%x.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 324 | ha->optrom_region_start, ha->optrom_region_size); |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 325 | |
| 326 | memset(ha->optrom_buffer, 0, ha->optrom_region_size); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 327 | ha->isp_ops->read_optrom(vha, ha->optrom_buffer, |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 328 | ha->optrom_region_start, ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 329 | break; |
| 330 | case 2: |
| 331 | if (ha->optrom_state != QLA_SWAITING) |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 332 | return -EINVAL; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 333 | |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 334 | /* |
| 335 | * We need to be more restrictive on which FLASH regions are |
| 336 | * allowed to be updated via user-space. Regions accessible |
| 337 | * via this method include: |
| 338 | * |
| 339 | * ISP21xx/ISP22xx/ISP23xx type boards: |
| 340 | * |
| 341 | * 0x000000 -> 0x020000 -- Boot code. |
| 342 | * |
| 343 | * ISP2322/ISP24xx type boards: |
| 344 | * |
| 345 | * 0x000000 -> 0x07ffff -- Boot code. |
| 346 | * 0x080000 -> 0x0fffff -- Firmware. |
| 347 | * |
| 348 | * ISP25xx type boards: |
| 349 | * |
| 350 | * 0x000000 -> 0x07ffff -- Boot code. |
| 351 | * 0x080000 -> 0x0fffff -- Firmware. |
| 352 | * 0x120000 -> 0x12ffff -- VPD and HBA parameters. |
| 353 | */ |
| 354 | valid = 0; |
| 355 | if (ha->optrom_size == OPTROM_SIZE_2300 && start == 0) |
| 356 | valid = 1; |
Andrew Vasquez | c00d899 | 2008-09-11 21:22:49 -0700 | [diff] [blame] | 357 | else if (start == (ha->flt_region_boot * 4) || |
| 358 | start == (ha->flt_region_fw * 4)) |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 359 | valid = 1; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 360 | else if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) |
| 361 | || IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 362 | valid = 1; |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 363 | if (!valid) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 364 | ql_log(ql_log_warn, vha, 0x7065, |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 365 | "Invalid start region 0x%x/0x%x.\n", start, size); |
| 366 | return -EINVAL; |
| 367 | } |
| 368 | |
| 369 | ha->optrom_region_start = start; |
| 370 | ha->optrom_region_size = start + size > ha->optrom_size ? |
| 371 | ha->optrom_size - start : size; |
| 372 | |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 373 | ha->optrom_state = QLA_SWRITING; |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 374 | ha->optrom_buffer = vmalloc(ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 375 | if (ha->optrom_buffer == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 376 | ql_log(ql_log_warn, vha, 0x7066, |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 377 | "Unable to allocate memory for optrom update " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 378 | "(%x)\n", ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 379 | |
| 380 | ha->optrom_state = QLA_SWAITING; |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 381 | return -ENOMEM; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 382 | } |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 383 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 384 | ql_dbg(ql_dbg_user, vha, 0x7067, |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 385 | "Staging flash region write -- 0x%x/0x%x.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 386 | ha->optrom_region_start, ha->optrom_region_size); |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 387 | |
| 388 | memset(ha->optrom_buffer, 0, ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 389 | break; |
| 390 | case 3: |
| 391 | if (ha->optrom_state != QLA_SWRITING) |
Joe Carnuccio | 71dfe9e | 2011-11-18 09:03:13 -0800 | [diff] [blame] | 392 | return -EINVAL; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 393 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 394 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 395 | ql_log(ql_log_warn, vha, 0x7068, |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 396 | "HBA not online, failing flash update.\n"); |
| 397 | return -EAGAIN; |
| 398 | } |
| 399 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 400 | ql_dbg(ql_dbg_user, vha, 0x7069, |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 401 | "Writing flash region -- 0x%x/0x%x.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 402 | ha->optrom_region_start, ha->optrom_region_size); |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 403 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 404 | ha->isp_ops->write_optrom(vha, ha->optrom_buffer, |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 405 | ha->optrom_region_start, ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 406 | break; |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 407 | default: |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 408 | return -EINVAL; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 409 | } |
| 410 | return count; |
| 411 | } |
| 412 | |
| 413 | static struct bin_attribute sysfs_optrom_ctl_attr = { |
| 414 | .attr = { |
| 415 | .name = "optrom_ctl", |
| 416 | .mode = S_IWUSR, |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 417 | }, |
| 418 | .size = 0, |
| 419 | .write = qla2x00_sysfs_write_optrom_ctl, |
| 420 | }; |
| 421 | |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 422 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 423 | qla2x00_sysfs_read_vpd(struct file *filp, struct kobject *kobj, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 424 | struct bin_attribute *bin_attr, |
| 425 | char *buf, loff_t off, size_t count) |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 426 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 427 | struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 428 | struct device, kobj))); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 429 | struct qla_hw_data *ha = vha->hw; |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 430 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 431 | if (unlikely(pci_channel_offline(ha->pdev))) |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 432 | return -EAGAIN; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 433 | |
Akinobu Mita | b3dc908 | 2008-07-24 08:31:47 -0700 | [diff] [blame] | 434 | if (!capable(CAP_SYS_ADMIN)) |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 435 | return -EINVAL; |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 436 | |
Andrew Vasquez | 6749ce3 | 2009-03-24 09:08:17 -0700 | [diff] [blame] | 437 | if (IS_NOCACHE_VPD_TYPE(ha)) |
| 438 | ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_vpd << 2, |
| 439 | ha->vpd_size); |
Akinobu Mita | b3dc908 | 2008-07-24 08:31:47 -0700 | [diff] [blame] | 440 | return memory_read_from_buffer(buf, count, &off, ha->vpd, ha->vpd_size); |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 441 | } |
| 442 | |
| 443 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 444 | qla2x00_sysfs_write_vpd(struct file *filp, struct kobject *kobj, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 445 | struct bin_attribute *bin_attr, |
| 446 | char *buf, loff_t off, size_t count) |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 447 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 448 | struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 449 | struct device, kobj))); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 450 | struct qla_hw_data *ha = vha->hw; |
Lalit Chandivade | d0c3eef | 2009-03-24 09:08:09 -0700 | [diff] [blame] | 451 | uint8_t *tmp_data; |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 452 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 453 | if (unlikely(pci_channel_offline(ha->pdev))) |
| 454 | return 0; |
| 455 | |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 456 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size || |
| 457 | !ha->isp_ops->write_nvram) |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 458 | return 0; |
| 459 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 460 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 461 | ql_log(ql_log_warn, vha, 0x706a, |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 462 | "HBA not online, failing VPD update.\n"); |
| 463 | return -EAGAIN; |
| 464 | } |
| 465 | |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 466 | /* Write NVRAM. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 467 | ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->vpd_base, count); |
| 468 | ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, ha->vpd_base, count); |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 469 | |
Lalit Chandivade | d0c3eef | 2009-03-24 09:08:09 -0700 | [diff] [blame] | 470 | /* Update flash version information for 4Gb & above. */ |
| 471 | if (!IS_FWI2_CAPABLE(ha)) |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 472 | return -EINVAL; |
Lalit Chandivade | d0c3eef | 2009-03-24 09:08:09 -0700 | [diff] [blame] | 473 | |
| 474 | tmp_data = vmalloc(256); |
| 475 | if (!tmp_data) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 476 | ql_log(ql_log_warn, vha, 0x706b, |
Lalit Chandivade | d0c3eef | 2009-03-24 09:08:09 -0700 | [diff] [blame] | 477 | "Unable to allocate memory for VPD information update.\n"); |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 478 | return -ENOMEM; |
Lalit Chandivade | d0c3eef | 2009-03-24 09:08:09 -0700 | [diff] [blame] | 479 | } |
| 480 | ha->isp_ops->get_flash_version(vha, tmp_data); |
| 481 | vfree(tmp_data); |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 482 | |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 483 | return count; |
| 484 | } |
| 485 | |
| 486 | static struct bin_attribute sysfs_vpd_attr = { |
| 487 | .attr = { |
| 488 | .name = "vpd", |
| 489 | .mode = S_IRUSR | S_IWUSR, |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 490 | }, |
| 491 | .size = 0, |
| 492 | .read = qla2x00_sysfs_read_vpd, |
| 493 | .write = qla2x00_sysfs_write_vpd, |
| 494 | }; |
| 495 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 496 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 497 | qla2x00_sysfs_read_sfp(struct file *filp, struct kobject *kobj, |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 498 | struct bin_attribute *bin_attr, |
| 499 | char *buf, loff_t off, size_t count) |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 500 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 501 | struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 502 | struct device, kobj))); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 503 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 504 | uint16_t iter, addr, offset; |
| 505 | int rval; |
| 506 | |
| 507 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != SFP_DEV_SIZE * 2) |
| 508 | return 0; |
| 509 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 510 | if (ha->sfp_data) |
| 511 | goto do_read; |
| 512 | |
| 513 | ha->sfp_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 514 | &ha->sfp_data_dma); |
| 515 | if (!ha->sfp_data) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 516 | ql_log(ql_log_warn, vha, 0x706c, |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 517 | "Unable to allocate memory for SFP read-data.\n"); |
| 518 | return 0; |
| 519 | } |
| 520 | |
| 521 | do_read: |
| 522 | memset(ha->sfp_data, 0, SFP_BLOCK_SIZE); |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 523 | addr = 0xa0; |
| 524 | for (iter = 0, offset = 0; iter < (SFP_DEV_SIZE * 2) / SFP_BLOCK_SIZE; |
| 525 | iter++, offset += SFP_BLOCK_SIZE) { |
| 526 | if (iter == 4) { |
| 527 | /* Skip to next device address. */ |
| 528 | addr = 0xa2; |
| 529 | offset = 0; |
| 530 | } |
| 531 | |
Joe Carnuccio | 6766df9 | 2011-05-10 11:30:15 -0700 | [diff] [blame] | 532 | rval = qla2x00_read_sfp(vha, ha->sfp_data_dma, ha->sfp_data, |
| 533 | addr, offset, SFP_BLOCK_SIZE, 0); |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 534 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 535 | ql_log(ql_log_warn, vha, 0x706d, |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 536 | "Unable to read SFP data (%x/%x/%x).\n", rval, |
| 537 | addr, offset); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 538 | |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 539 | return -EIO; |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 540 | } |
| 541 | memcpy(buf, ha->sfp_data, SFP_BLOCK_SIZE); |
| 542 | buf += SFP_BLOCK_SIZE; |
| 543 | } |
| 544 | |
| 545 | return count; |
| 546 | } |
| 547 | |
| 548 | static struct bin_attribute sysfs_sfp_attr = { |
| 549 | .attr = { |
| 550 | .name = "sfp", |
| 551 | .mode = S_IRUSR | S_IWUSR, |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 552 | }, |
| 553 | .size = SFP_DEV_SIZE * 2, |
| 554 | .read = qla2x00_sysfs_read_sfp, |
| 555 | }; |
| 556 | |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 557 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 558 | qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 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; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 565 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 566 | int type; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame^] | 567 | uint32_t idc_control; |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 568 | |
| 569 | if (off != 0) |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 570 | return -EINVAL; |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 571 | |
| 572 | type = simple_strtol(buf, NULL, 10); |
| 573 | switch (type) { |
| 574 | case 0x2025c: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 575 | ql_log(ql_log_info, vha, 0x706e, |
| 576 | "Issuing ISP reset.\n"); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 577 | |
| 578 | scsi_block_requests(vha->host); |
| 579 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 580 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b6d0d9d | 2012-05-15 14:34:25 -0400 | [diff] [blame] | 581 | ha->flags.isp82xx_no_md_cap = 1; |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 582 | qla82xx_idc_lock(ha); |
| 583 | qla82xx_set_reset_owner(vha); |
| 584 | qla82xx_idc_unlock(ha); |
| 585 | } |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 586 | qla2xxx_wake_dpc(vha); |
| 587 | qla2x00_wait_for_chip_reset(vha); |
| 588 | scsi_unblock_requests(vha->host); |
| 589 | break; |
| 590 | case 0x2025d: |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame^] | 591 | if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha)) |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 592 | return -EPERM; |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 593 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 594 | ql_log(ql_log_info, vha, 0x706f, |
| 595 | "Issuing MPI reset.\n"); |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 596 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame^] | 597 | if (IS_QLA83XX(ha)) { |
| 598 | uint32_t idc_control; |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 599 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame^] | 600 | qla83xx_idc_lock(vha, 0); |
| 601 | __qla83xx_get_idc_control(vha, &idc_control); |
| 602 | idc_control |= QLA83XX_IDC_GRACEFUL_RESET; |
| 603 | __qla83xx_set_idc_control(vha, idc_control); |
| 604 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, |
| 605 | QLA8XXX_DEV_NEED_RESET); |
| 606 | qla83xx_idc_audit(vha, IDC_AUDIT_TIMESTAMP); |
| 607 | qla83xx_idc_unlock(vha, 0); |
| 608 | break; |
| 609 | } else { |
| 610 | /* Make sure FC side is not in reset */ |
| 611 | qla2x00_wait_for_hba_online(vha); |
| 612 | |
| 613 | /* Issue MPI reset */ |
| 614 | scsi_block_requests(vha->host); |
| 615 | if (qla81xx_restart_mpi_firmware(vha) != QLA_SUCCESS) |
| 616 | ql_log(ql_log_warn, vha, 0x7070, |
| 617 | "MPI reset failed.\n"); |
| 618 | scsi_unblock_requests(vha->host); |
| 619 | break; |
| 620 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 621 | case 0x2025e: |
| 622 | if (!IS_QLA82XX(ha) || vha != base_vha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 623 | ql_log(ql_log_info, vha, 0x7071, |
| 624 | "FCoE ctx reset no supported.\n"); |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 625 | return -EPERM; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 626 | } |
| 627 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 628 | ql_log(ql_log_info, vha, 0x7072, |
| 629 | "Issuing FCoE ctx reset.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 630 | set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); |
| 631 | qla2xxx_wake_dpc(vha); |
| 632 | qla2x00_wait_for_fcoe_ctx_reset(vha); |
| 633 | break; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame^] | 634 | case 0x2025f: |
| 635 | if (!IS_QLA8031(ha)) |
| 636 | return -EPERM; |
| 637 | ql_log(ql_log_info, vha, 0x70bc, |
| 638 | "Disabling Reset by IDC control\n"); |
| 639 | qla83xx_idc_lock(vha, 0); |
| 640 | __qla83xx_get_idc_control(vha, &idc_control); |
| 641 | idc_control |= QLA83XX_IDC_RESET_DISABLED; |
| 642 | __qla83xx_set_idc_control(vha, idc_control); |
| 643 | qla83xx_idc_unlock(vha, 0); |
| 644 | break; |
| 645 | case 0x20260: |
| 646 | if (!IS_QLA8031(ha)) |
| 647 | return -EPERM; |
| 648 | ql_log(ql_log_info, vha, 0x70bd, |
| 649 | "Enabling Reset by IDC control\n"); |
| 650 | qla83xx_idc_lock(vha, 0); |
| 651 | __qla83xx_get_idc_control(vha, &idc_control); |
| 652 | idc_control &= ~QLA83XX_IDC_RESET_DISABLED; |
| 653 | __qla83xx_set_idc_control(vha, idc_control); |
| 654 | qla83xx_idc_unlock(vha, 0); |
| 655 | break; |
| 656 | |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 657 | } |
| 658 | return count; |
| 659 | } |
| 660 | |
| 661 | static struct bin_attribute sysfs_reset_attr = { |
| 662 | .attr = { |
| 663 | .name = "reset", |
| 664 | .mode = S_IWUSR, |
| 665 | }, |
| 666 | .size = 0, |
| 667 | .write = qla2x00_sysfs_write_reset, |
| 668 | }; |
| 669 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 670 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 671 | qla2x00_sysfs_read_xgmac_stats(struct file *filp, struct kobject *kobj, |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 672 | struct bin_attribute *bin_attr, |
| 673 | char *buf, loff_t off, size_t count) |
| 674 | { |
| 675 | struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, |
| 676 | struct device, kobj))); |
| 677 | struct qla_hw_data *ha = vha->hw; |
| 678 | int rval; |
| 679 | uint16_t actual_size; |
| 680 | |
| 681 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count > XGMAC_DATA_SIZE) |
| 682 | return 0; |
| 683 | |
| 684 | if (ha->xgmac_data) |
| 685 | goto do_read; |
| 686 | |
| 687 | ha->xgmac_data = dma_alloc_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 688 | &ha->xgmac_data_dma, GFP_KERNEL); |
| 689 | if (!ha->xgmac_data) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 690 | ql_log(ql_log_warn, vha, 0x7076, |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 691 | "Unable to allocate memory for XGMAC read-data.\n"); |
| 692 | return 0; |
| 693 | } |
| 694 | |
| 695 | do_read: |
| 696 | actual_size = 0; |
| 697 | memset(ha->xgmac_data, 0, XGMAC_DATA_SIZE); |
| 698 | |
| 699 | rval = qla2x00_get_xgmac_stats(vha, ha->xgmac_data_dma, |
| 700 | XGMAC_DATA_SIZE, &actual_size); |
| 701 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 702 | ql_log(ql_log_warn, vha, 0x7077, |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 703 | "Unable to read XGMAC data (%x).\n", rval); |
| 704 | count = 0; |
| 705 | } |
| 706 | |
| 707 | count = actual_size > count ? count: actual_size; |
| 708 | memcpy(buf, ha->xgmac_data, count); |
| 709 | |
| 710 | return count; |
| 711 | } |
| 712 | |
| 713 | static struct bin_attribute sysfs_xgmac_stats_attr = { |
| 714 | .attr = { |
| 715 | .name = "xgmac_stats", |
| 716 | .mode = S_IRUSR, |
| 717 | }, |
| 718 | .size = 0, |
| 719 | .read = qla2x00_sysfs_read_xgmac_stats, |
| 720 | }; |
| 721 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 722 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 723 | qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj, |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 724 | struct bin_attribute *bin_attr, |
| 725 | char *buf, loff_t off, size_t count) |
| 726 | { |
| 727 | struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, |
| 728 | struct device, kobj))); |
| 729 | struct qla_hw_data *ha = vha->hw; |
| 730 | int rval; |
| 731 | uint16_t actual_size; |
| 732 | |
| 733 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count > DCBX_TLV_DATA_SIZE) |
| 734 | return 0; |
| 735 | |
| 736 | if (ha->dcbx_tlv) |
| 737 | goto do_read; |
| 738 | |
| 739 | ha->dcbx_tlv = dma_alloc_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 740 | &ha->dcbx_tlv_dma, GFP_KERNEL); |
| 741 | if (!ha->dcbx_tlv) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 742 | ql_log(ql_log_warn, vha, 0x7078, |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 743 | "Unable to allocate memory for DCBX TLV read-data.\n"); |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 744 | return -ENOMEM; |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | do_read: |
| 748 | actual_size = 0; |
| 749 | memset(ha->dcbx_tlv, 0, DCBX_TLV_DATA_SIZE); |
| 750 | |
| 751 | rval = qla2x00_get_dcbx_params(vha, ha->dcbx_tlv_dma, |
| 752 | DCBX_TLV_DATA_SIZE); |
| 753 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 754 | ql_log(ql_log_warn, vha, 0x7079, |
| 755 | "Unable to read DCBX TLV (%x).\n", rval); |
Joe Carnuccio | b668ae3 | 2011-08-16 11:31:53 -0700 | [diff] [blame] | 756 | return -EIO; |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 757 | } |
| 758 | |
| 759 | memcpy(buf, ha->dcbx_tlv, count); |
| 760 | |
| 761 | return count; |
| 762 | } |
| 763 | |
| 764 | static struct bin_attribute sysfs_dcbx_tlv_attr = { |
| 765 | .attr = { |
| 766 | .name = "dcbx_tlv", |
| 767 | .mode = S_IRUSR, |
| 768 | }, |
| 769 | .size = 0, |
| 770 | .read = qla2x00_sysfs_read_dcbx_tlv, |
| 771 | }; |
| 772 | |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 773 | static struct sysfs_entry { |
| 774 | char *name; |
| 775 | struct bin_attribute *attr; |
| 776 | int is4GBp_only; |
| 777 | } bin_file_entries[] = { |
| 778 | { "fw_dump", &sysfs_fw_dump_attr, }, |
| 779 | { "nvram", &sysfs_nvram_attr, }, |
| 780 | { "optrom", &sysfs_optrom_attr, }, |
| 781 | { "optrom_ctl", &sysfs_optrom_ctl_attr, }, |
| 782 | { "vpd", &sysfs_vpd_attr, 1 }, |
| 783 | { "sfp", &sysfs_sfp_attr, 1 }, |
Lalit Chandivade | 6e181be | 2009-03-26 08:49:17 -0700 | [diff] [blame] | 784 | { "reset", &sysfs_reset_attr, }, |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 785 | { "xgmac_stats", &sysfs_xgmac_stats_attr, 3 }, |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 786 | { "dcbx_tlv", &sysfs_dcbx_tlv_attr, 3 }, |
Randy Dunlap | 46ddab7 | 2006-11-27 09:35:42 -0800 | [diff] [blame] | 787 | { NULL }, |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 788 | }; |
| 789 | |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 790 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 791 | qla2x00_alloc_sysfs_attr(scsi_qla_host_t *vha) |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 792 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 793 | struct Scsi_Host *host = vha->host; |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 794 | struct sysfs_entry *iter; |
| 795 | int ret; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 796 | |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 797 | for (iter = bin_file_entries; iter->name; iter++) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 798 | if (iter->is4GBp_only && !IS_FWI2_CAPABLE(vha->hw)) |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 799 | continue; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 800 | if (iter->is4GBp_only == 2 && !IS_QLA25XX(vha->hw)) |
| 801 | continue; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 802 | if (iter->is4GBp_only == 3 && !(IS_CNA_CAPABLE(vha->hw))) |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 803 | continue; |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 804 | |
| 805 | ret = sysfs_create_bin_file(&host->shost_gendev.kobj, |
| 806 | iter->attr); |
| 807 | if (ret) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 808 | ql_log(ql_log_warn, vha, 0x00f3, |
| 809 | "Unable to create sysfs %s binary attribute (%d).\n", |
| 810 | iter->name, ret); |
| 811 | else |
| 812 | ql_dbg(ql_dbg_init, vha, 0x00f4, |
| 813 | "Successfully created sysfs %s binary attribure.\n", |
| 814 | iter->name); |
Andrew Vasquez | 7914d00 | 2006-06-23 16:10:55 -0700 | [diff] [blame] | 815 | } |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 816 | } |
| 817 | |
| 818 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 819 | qla2x00_free_sysfs_attr(scsi_qla_host_t *vha) |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 820 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 821 | struct Scsi_Host *host = vha->host; |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 822 | struct sysfs_entry *iter; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 823 | struct qla_hw_data *ha = vha->hw; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 824 | |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 825 | for (iter = bin_file_entries; iter->name; iter++) { |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 826 | if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 827 | continue; |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 828 | if (iter->is4GBp_only == 2 && !IS_QLA25XX(ha)) |
| 829 | continue; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 830 | if (iter->is4GBp_only == 3 && !(IS_CNA_CAPABLE(vha->hw))) |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 831 | continue; |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 832 | |
Andrew Vasquez | 7914d00 | 2006-06-23 16:10:55 -0700 | [diff] [blame] | 833 | sysfs_remove_bin_file(&host->shost_gendev.kobj, |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 834 | iter->attr); |
Andrew Vasquez | 7914d00 | 2006-06-23 16:10:55 -0700 | [diff] [blame] | 835 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 836 | |
| 837 | if (ha->beacon_blink_led == 1) |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 838 | ha->isp_ops->beacon_off(vha); |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 839 | } |
| 840 | |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 841 | /* Scsi_Host attributes. */ |
| 842 | |
| 843 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 844 | qla2x00_drvr_version_show(struct device *dev, |
| 845 | struct device_attribute *attr, char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 846 | { |
| 847 | return snprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str); |
| 848 | } |
| 849 | |
| 850 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 851 | qla2x00_fw_version_show(struct device *dev, |
| 852 | struct device_attribute *attr, char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 853 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 854 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 855 | struct qla_hw_data *ha = vha->hw; |
| 856 | char fw_str[128]; |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 857 | |
| 858 | return snprintf(buf, PAGE_SIZE, "%s\n", |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 859 | ha->isp_ops->fw_version_str(vha, fw_str)); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 860 | } |
| 861 | |
| 862 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 863 | qla2x00_serial_num_show(struct device *dev, struct device_attribute *attr, |
| 864 | char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 865 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 866 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 867 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 868 | uint32_t sn; |
| 869 | |
Joe Carnuccio | 1ee2714 | 2008-07-10 16:55:53 -0700 | [diff] [blame] | 870 | if (IS_FWI2_CAPABLE(ha)) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 871 | qla2xxx_get_vpd_field(vha, "SN", buf, PAGE_SIZE); |
Joe Carnuccio | 1ee2714 | 2008-07-10 16:55:53 -0700 | [diff] [blame] | 872 | return snprintf(buf, PAGE_SIZE, "%s\n", buf); |
| 873 | } |
Andrew Vasquez | 8b7afc2 | 2007-10-19 15:59:19 -0700 | [diff] [blame] | 874 | |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 875 | sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; |
| 876 | return snprintf(buf, PAGE_SIZE, "%c%05d\n", 'A' + sn / 100000, |
| 877 | sn % 100000); |
| 878 | } |
| 879 | |
| 880 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 881 | qla2x00_isp_name_show(struct device *dev, struct device_attribute *attr, |
| 882 | char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 883 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 884 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 885 | return snprintf(buf, PAGE_SIZE, "ISP%04X\n", vha->hw->pdev->device); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 886 | } |
| 887 | |
| 888 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 889 | qla2x00_isp_id_show(struct device *dev, struct device_attribute *attr, |
| 890 | char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 891 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 892 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 893 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 894 | return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n", |
| 895 | ha->product_id[0], ha->product_id[1], ha->product_id[2], |
| 896 | ha->product_id[3]); |
| 897 | } |
| 898 | |
| 899 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 900 | qla2x00_model_name_show(struct device *dev, struct device_attribute *attr, |
| 901 | char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 902 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 903 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 904 | return snprintf(buf, PAGE_SIZE, "%s\n", vha->hw->model_number); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 905 | } |
| 906 | |
| 907 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 908 | qla2x00_model_desc_show(struct device *dev, struct device_attribute *attr, |
| 909 | char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 910 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 911 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 912 | return snprintf(buf, PAGE_SIZE, "%s\n", |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 913 | vha->hw->model_desc ? vha->hw->model_desc : ""); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 914 | } |
| 915 | |
| 916 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 917 | qla2x00_pci_info_show(struct device *dev, struct device_attribute *attr, |
| 918 | char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 919 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 920 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 921 | char pci_info[30]; |
| 922 | |
| 923 | return snprintf(buf, PAGE_SIZE, "%s\n", |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 924 | vha->hw->isp_ops->pci_info_str(vha, pci_info)); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 925 | } |
| 926 | |
| 927 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 928 | qla2x00_link_state_show(struct device *dev, struct device_attribute *attr, |
| 929 | char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 930 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 931 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 932 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 933 | int len = 0; |
| 934 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 935 | if (atomic_read(&vha->loop_state) == LOOP_DOWN || |
Andrew Vasquez | 62542f4 | 2010-05-04 15:01:22 -0700 | [diff] [blame] | 936 | atomic_read(&vha->loop_state) == LOOP_DEAD || |
| 937 | vha->device_flags & DFLG_NO_CABLE) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 938 | len = snprintf(buf, PAGE_SIZE, "Link Down\n"); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 939 | else if (atomic_read(&vha->loop_state) != LOOP_READY || |
Andrew Vasquez | d051a5aa | 2012-02-09 11:14:05 -0800 | [diff] [blame] | 940 | qla2x00_reset_active(vha)) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 941 | len = snprintf(buf, PAGE_SIZE, "Unknown Link State\n"); |
| 942 | else { |
| 943 | len = snprintf(buf, PAGE_SIZE, "Link Up - "); |
| 944 | |
| 945 | switch (ha->current_topology) { |
| 946 | case ISP_CFG_NL: |
| 947 | len += snprintf(buf + len, PAGE_SIZE-len, "Loop\n"); |
| 948 | break; |
| 949 | case ISP_CFG_FL: |
| 950 | len += snprintf(buf + len, PAGE_SIZE-len, "FL_Port\n"); |
| 951 | break; |
| 952 | case ISP_CFG_N: |
| 953 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 954 | "N_Port to N_Port\n"); |
| 955 | break; |
| 956 | case ISP_CFG_F: |
| 957 | len += snprintf(buf + len, PAGE_SIZE-len, "F_Port\n"); |
| 958 | break; |
| 959 | default: |
| 960 | len += snprintf(buf + len, PAGE_SIZE-len, "Loop\n"); |
| 961 | break; |
| 962 | } |
| 963 | } |
| 964 | return len; |
| 965 | } |
| 966 | |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 967 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 968 | qla2x00_zio_show(struct device *dev, struct device_attribute *attr, |
| 969 | char *buf) |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 970 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 971 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 972 | int len = 0; |
| 973 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 974 | switch (vha->hw->zio_mode) { |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 975 | case QLA_ZIO_MODE_6: |
| 976 | len += snprintf(buf + len, PAGE_SIZE-len, "Mode 6\n"); |
| 977 | break; |
| 978 | case QLA_ZIO_DISABLED: |
| 979 | len += snprintf(buf + len, PAGE_SIZE-len, "Disabled\n"); |
| 980 | break; |
| 981 | } |
| 982 | return len; |
| 983 | } |
| 984 | |
| 985 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 986 | qla2x00_zio_store(struct device *dev, struct device_attribute *attr, |
| 987 | const char *buf, size_t count) |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 988 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 989 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 990 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 991 | int val = 0; |
| 992 | uint16_t zio_mode; |
| 993 | |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 994 | if (!IS_ZIO_SUPPORTED(ha)) |
| 995 | return -ENOTSUPP; |
| 996 | |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 997 | if (sscanf(buf, "%d", &val) != 1) |
| 998 | return -EINVAL; |
| 999 | |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 1000 | if (val) |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 1001 | zio_mode = QLA_ZIO_MODE_6; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 1002 | else |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 1003 | zio_mode = QLA_ZIO_DISABLED; |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 1004 | |
| 1005 | /* Update per-hba values and queue a reset. */ |
| 1006 | if (zio_mode != QLA_ZIO_DISABLED || ha->zio_mode != QLA_ZIO_DISABLED) { |
| 1007 | ha->zio_mode = zio_mode; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1008 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 1009 | } |
| 1010 | return strlen(buf); |
| 1011 | } |
| 1012 | |
| 1013 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1014 | qla2x00_zio_timer_show(struct device *dev, struct device_attribute *attr, |
| 1015 | char *buf) |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 1016 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1017 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 1018 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1019 | return snprintf(buf, PAGE_SIZE, "%d us\n", vha->hw->zio_timer * 100); |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 1020 | } |
| 1021 | |
| 1022 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1023 | qla2x00_zio_timer_store(struct device *dev, struct device_attribute *attr, |
| 1024 | const char *buf, size_t count) |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 1025 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1026 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 1027 | int val = 0; |
| 1028 | uint16_t zio_timer; |
| 1029 | |
| 1030 | if (sscanf(buf, "%d", &val) != 1) |
| 1031 | return -EINVAL; |
| 1032 | if (val > 25500 || val < 100) |
| 1033 | return -ERANGE; |
| 1034 | |
| 1035 | zio_timer = (uint16_t)(val / 100); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1036 | vha->hw->zio_timer = zio_timer; |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 1037 | |
| 1038 | return strlen(buf); |
| 1039 | } |
| 1040 | |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 1041 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1042 | qla2x00_beacon_show(struct device *dev, struct device_attribute *attr, |
| 1043 | char *buf) |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 1044 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1045 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 1046 | int len = 0; |
| 1047 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1048 | if (vha->hw->beacon_blink_led) |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 1049 | len += snprintf(buf + len, PAGE_SIZE-len, "Enabled\n"); |
| 1050 | else |
| 1051 | len += snprintf(buf + len, PAGE_SIZE-len, "Disabled\n"); |
| 1052 | return len; |
| 1053 | } |
| 1054 | |
| 1055 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1056 | qla2x00_beacon_store(struct device *dev, struct device_attribute *attr, |
| 1057 | const char *buf, size_t count) |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 1058 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1059 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1060 | struct qla_hw_data *ha = vha->hw; |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 1061 | int val = 0; |
| 1062 | int rval; |
| 1063 | |
| 1064 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 1065 | return -EPERM; |
| 1066 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1067 | if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1068 | ql_log(ql_log_warn, vha, 0x707a, |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 1069 | "Abort ISP active -- ignoring beacon request.\n"); |
| 1070 | return -EBUSY; |
| 1071 | } |
| 1072 | |
| 1073 | if (sscanf(buf, "%d", &val) != 1) |
| 1074 | return -EINVAL; |
| 1075 | |
| 1076 | if (val) |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1077 | rval = ha->isp_ops->beacon_on(vha); |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 1078 | else |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1079 | rval = ha->isp_ops->beacon_off(vha); |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 1080 | |
| 1081 | if (rval != QLA_SUCCESS) |
| 1082 | count = 0; |
| 1083 | |
| 1084 | return count; |
| 1085 | } |
| 1086 | |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 1087 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1088 | qla2x00_optrom_bios_version_show(struct device *dev, |
| 1089 | struct device_attribute *attr, char *buf) |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 1090 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1091 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1092 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 1093 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1], |
| 1094 | ha->bios_revision[0]); |
| 1095 | } |
| 1096 | |
| 1097 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1098 | qla2x00_optrom_efi_version_show(struct device *dev, |
| 1099 | struct device_attribute *attr, char *buf) |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 1100 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1101 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1102 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 1103 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1], |
| 1104 | ha->efi_revision[0]); |
| 1105 | } |
| 1106 | |
| 1107 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1108 | qla2x00_optrom_fcode_version_show(struct device *dev, |
| 1109 | struct device_attribute *attr, char *buf) |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 1110 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1111 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1112 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 1113 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1], |
| 1114 | ha->fcode_revision[0]); |
| 1115 | } |
| 1116 | |
| 1117 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1118 | qla2x00_optrom_fw_version_show(struct device *dev, |
| 1119 | struct device_attribute *attr, char *buf) |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 1120 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1121 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1122 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 1123 | return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n", |
| 1124 | ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2], |
| 1125 | ha->fw_revision[3]); |
| 1126 | } |
| 1127 | |
Harish Zunjarrao | e5f5f6f | 2008-07-10 16:55:49 -0700 | [diff] [blame] | 1128 | static ssize_t |
Madhuranath Iyengar | 0f2d962 | 2010-07-23 15:28:26 +0500 | [diff] [blame] | 1129 | qla2x00_optrom_gold_fw_version_show(struct device *dev, |
| 1130 | struct device_attribute *attr, char *buf) |
| 1131 | { |
| 1132 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1133 | struct qla_hw_data *ha = vha->hw; |
| 1134 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1135 | if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha)) |
Madhuranath Iyengar | 0f2d962 | 2010-07-23 15:28:26 +0500 | [diff] [blame] | 1136 | return snprintf(buf, PAGE_SIZE, "\n"); |
| 1137 | |
| 1138 | return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%d)\n", |
| 1139 | ha->gold_fw_version[0], ha->gold_fw_version[1], |
| 1140 | ha->gold_fw_version[2], ha->gold_fw_version[3]); |
| 1141 | } |
| 1142 | |
| 1143 | static ssize_t |
Harish Zunjarrao | e5f5f6f | 2008-07-10 16:55:49 -0700 | [diff] [blame] | 1144 | qla2x00_total_isp_aborts_show(struct device *dev, |
| 1145 | struct device_attribute *attr, char *buf) |
| 1146 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1147 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
Harish Zunjarrao | e5f5f6f | 2008-07-10 16:55:49 -0700 | [diff] [blame] | 1148 | return snprintf(buf, PAGE_SIZE, "%d\n", |
Saurav Kashyap | 2be21fa | 2012-05-15 14:34:16 -0400 | [diff] [blame] | 1149 | vha->qla_stats.total_isp_aborts); |
Harish Zunjarrao | e5f5f6f | 2008-07-10 16:55:49 -0700 | [diff] [blame] | 1150 | } |
| 1151 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1152 | static ssize_t |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1153 | qla24xx_84xx_fw_version_show(struct device *dev, |
| 1154 | struct device_attribute *attr, char *buf) |
| 1155 | { |
| 1156 | int rval = QLA_SUCCESS; |
| 1157 | uint16_t status[2] = {0, 0}; |
| 1158 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1159 | struct qla_hw_data *ha = vha->hw; |
| 1160 | |
Andrew Vasquez | 0b9dae6 | 2010-05-04 15:01:21 -0700 | [diff] [blame] | 1161 | if (!IS_QLA84XX(ha)) |
| 1162 | return snprintf(buf, PAGE_SIZE, "\n"); |
| 1163 | |
Giridhar Malavali | 6c7ccf7 | 2010-05-28 15:08:29 -0700 | [diff] [blame] | 1164 | if (ha->cs84xx->op_fw_version == 0) |
Andrew Vasquez | 0b9dae6 | 2010-05-04 15:01:21 -0700 | [diff] [blame] | 1165 | rval = qla84xx_verify_chip(vha, status); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1166 | |
| 1167 | if ((rval == QLA_SUCCESS) && (status[0] == 0)) |
| 1168 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 1169 | (uint32_t)ha->cs84xx->op_fw_version); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1170 | |
| 1171 | return snprintf(buf, PAGE_SIZE, "\n"); |
| 1172 | } |
| 1173 | |
| 1174 | static ssize_t |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1175 | qla2x00_mpi_version_show(struct device *dev, struct device_attribute *attr, |
| 1176 | char *buf) |
| 1177 | { |
| 1178 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1179 | struct qla_hw_data *ha = vha->hw; |
| 1180 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1181 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1182 | return snprintf(buf, PAGE_SIZE, "\n"); |
| 1183 | |
Andrew Vasquez | 55a9615 | 2009-03-24 09:08:03 -0700 | [diff] [blame] | 1184 | return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n", |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1185 | ha->mpi_version[0], ha->mpi_version[1], ha->mpi_version[2], |
Andrew Vasquez | 55a9615 | 2009-03-24 09:08:03 -0700 | [diff] [blame] | 1186 | ha->mpi_capabilities); |
| 1187 | } |
| 1188 | |
| 1189 | static ssize_t |
| 1190 | qla2x00_phy_version_show(struct device *dev, struct device_attribute *attr, |
| 1191 | char *buf) |
| 1192 | { |
| 1193 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1194 | struct qla_hw_data *ha = vha->hw; |
| 1195 | |
Nigel Kirkland | f863f60 | 2012-05-15 14:34:19 -0400 | [diff] [blame] | 1196 | if (!IS_QLA81XX(ha) && !IS_QLA8031(ha)) |
Andrew Vasquez | 55a9615 | 2009-03-24 09:08:03 -0700 | [diff] [blame] | 1197 | return snprintf(buf, PAGE_SIZE, "\n"); |
| 1198 | |
| 1199 | return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d\n", |
| 1200 | ha->phy_version[0], ha->phy_version[1], ha->phy_version[2]); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1201 | } |
| 1202 | |
Lalit Chandivade | fbcbb5d | 2009-03-24 09:08:11 -0700 | [diff] [blame] | 1203 | static ssize_t |
| 1204 | qla2x00_flash_block_size_show(struct device *dev, |
| 1205 | struct device_attribute *attr, char *buf) |
| 1206 | { |
| 1207 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1208 | struct qla_hw_data *ha = vha->hw; |
| 1209 | |
| 1210 | return snprintf(buf, PAGE_SIZE, "0x%x\n", ha->fdt_block_size); |
| 1211 | } |
| 1212 | |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1213 | static ssize_t |
| 1214 | qla2x00_vlan_id_show(struct device *dev, struct device_attribute *attr, |
| 1215 | char *buf) |
| 1216 | { |
| 1217 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1218 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1219 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1220 | return snprintf(buf, PAGE_SIZE, "\n"); |
| 1221 | |
| 1222 | return snprintf(buf, PAGE_SIZE, "%d\n", vha->fcoe_vlan_id); |
| 1223 | } |
| 1224 | |
| 1225 | static ssize_t |
| 1226 | qla2x00_vn_port_mac_address_show(struct device *dev, |
| 1227 | struct device_attribute *attr, char *buf) |
| 1228 | { |
| 1229 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1230 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1231 | if (!IS_CNA_CAPABLE(vha->hw)) |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1232 | return snprintf(buf, PAGE_SIZE, "\n"); |
| 1233 | |
| 1234 | return snprintf(buf, PAGE_SIZE, "%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 1235 | vha->fcoe_vn_port_mac[5], vha->fcoe_vn_port_mac[4], |
| 1236 | vha->fcoe_vn_port_mac[3], vha->fcoe_vn_port_mac[2], |
| 1237 | vha->fcoe_vn_port_mac[1], vha->fcoe_vn_port_mac[0]); |
| 1238 | } |
| 1239 | |
Andrew Vasquez | 7f77402 | 2009-06-03 09:55:12 -0700 | [diff] [blame] | 1240 | static ssize_t |
| 1241 | qla2x00_fabric_param_show(struct device *dev, struct device_attribute *attr, |
| 1242 | char *buf) |
| 1243 | { |
| 1244 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1245 | |
| 1246 | return snprintf(buf, PAGE_SIZE, "%d\n", vha->hw->switch_cap); |
| 1247 | } |
| 1248 | |
Andrew Vasquez | 656e891 | 2009-06-03 09:55:29 -0700 | [diff] [blame] | 1249 | static ssize_t |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 1250 | qla2x00_thermal_temp_show(struct device *dev, |
| 1251 | struct device_attribute *attr, char *buf) |
| 1252 | { |
| 1253 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1254 | int rval = QLA_FUNCTION_FAILED; |
| 1255 | uint16_t temp, frac; |
| 1256 | |
| 1257 | if (!vha->hw->flags.thermal_supported) |
| 1258 | return snprintf(buf, PAGE_SIZE, "\n"); |
| 1259 | |
| 1260 | temp = frac = 0; |
Andrew Vasquez | d051a5aa | 2012-02-09 11:14:05 -0800 | [diff] [blame] | 1261 | if (qla2x00_reset_active(vha)) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1262 | ql_log(ql_log_warn, vha, 0x707b, |
| 1263 | "ISP reset active.\n"); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 1264 | else if (!vha->hw->flags.eeh_busy) |
| 1265 | rval = qla2x00_get_thermal_temp(vha, &temp, &frac); |
| 1266 | if (rval != QLA_SUCCESS) |
Joe Carnuccio | aa61556 | 2012-02-09 11:15:40 -0800 | [diff] [blame] | 1267 | return snprintf(buf, PAGE_SIZE, "\n"); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 1268 | |
| 1269 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", temp, frac); |
| 1270 | } |
| 1271 | |
| 1272 | static ssize_t |
Andrew Vasquez | 656e891 | 2009-06-03 09:55:29 -0700 | [diff] [blame] | 1273 | qla2x00_fw_state_show(struct device *dev, struct device_attribute *attr, |
| 1274 | char *buf) |
| 1275 | { |
| 1276 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1277 | int rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | 656e891 | 2009-06-03 09:55:29 -0700 | [diff] [blame] | 1278 | uint16_t state[5]; |
| 1279 | |
Andrew Vasquez | d051a5aa | 2012-02-09 11:14:05 -0800 | [diff] [blame] | 1280 | if (qla2x00_reset_active(vha)) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1281 | ql_log(ql_log_warn, vha, 0x707c, |
| 1282 | "ISP reset active.\n"); |
Santosh Vernekar | d6136f3 | 2010-03-19 16:59:20 -0700 | [diff] [blame] | 1283 | else if (!vha->hw->flags.eeh_busy) |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1284 | rval = qla2x00_get_firmware_state(vha, state); |
Andrew Vasquez | 656e891 | 2009-06-03 09:55:29 -0700 | [diff] [blame] | 1285 | if (rval != QLA_SUCCESS) |
| 1286 | memset(state, -1, sizeof(state)); |
| 1287 | |
| 1288 | return snprintf(buf, PAGE_SIZE, "0x%x 0x%x 0x%x 0x%x 0x%x\n", state[0], |
| 1289 | state[1], state[2], state[3], state[4]); |
| 1290 | } |
| 1291 | |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 1292 | static ssize_t |
| 1293 | qla2x00_diag_requests_show(struct device *dev, |
| 1294 | struct device_attribute *attr, char *buf) |
| 1295 | { |
| 1296 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1297 | |
| 1298 | if (!IS_BIDI_CAPABLE(vha->hw)) |
| 1299 | return snprintf(buf, PAGE_SIZE, "\n"); |
| 1300 | |
| 1301 | return snprintf(buf, PAGE_SIZE, "%llu\n", vha->bidi_stats.io_count); |
| 1302 | } |
| 1303 | |
| 1304 | static ssize_t |
| 1305 | qla2x00_diag_megabytes_show(struct device *dev, |
| 1306 | struct device_attribute *attr, char *buf) |
| 1307 | { |
| 1308 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1309 | |
| 1310 | if (!IS_BIDI_CAPABLE(vha->hw)) |
| 1311 | return snprintf(buf, PAGE_SIZE, "\n"); |
| 1312 | |
| 1313 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
| 1314 | vha->bidi_stats.transfer_bytes >> 20); |
| 1315 | } |
| 1316 | |
Harish Zunjarrao | 40129a4 | 2012-08-22 14:21:02 -0400 | [diff] [blame] | 1317 | static ssize_t |
| 1318 | qla2x00_fw_dump_size_show(struct device *dev, struct device_attribute *attr, |
| 1319 | char *buf) |
| 1320 | { |
| 1321 | scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); |
| 1322 | struct qla_hw_data *ha = vha->hw; |
| 1323 | uint32_t size; |
| 1324 | |
| 1325 | if (!ha->fw_dumped) |
| 1326 | size = 0; |
| 1327 | else if (IS_QLA82XX(ha)) |
| 1328 | size = ha->md_template_size + ha->md_dump_size; |
| 1329 | else |
| 1330 | size = ha->fw_dump_len; |
| 1331 | |
| 1332 | return snprintf(buf, PAGE_SIZE, "%d\n", size); |
| 1333 | } |
| 1334 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1335 | static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL); |
| 1336 | static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL); |
| 1337 | static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL); |
| 1338 | static DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL); |
| 1339 | static DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL); |
| 1340 | static DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL); |
| 1341 | static DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL); |
| 1342 | static DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL); |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 1343 | static DEVICE_ATTR(link_state, S_IRUGO, qla2x00_link_state_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1344 | static DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show, qla2x00_zio_store); |
| 1345 | static DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show, |
| 1346 | qla2x00_zio_timer_store); |
| 1347 | static DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show, |
| 1348 | qla2x00_beacon_store); |
| 1349 | static DEVICE_ATTR(optrom_bios_version, S_IRUGO, |
| 1350 | qla2x00_optrom_bios_version_show, NULL); |
| 1351 | static DEVICE_ATTR(optrom_efi_version, S_IRUGO, |
| 1352 | qla2x00_optrom_efi_version_show, NULL); |
| 1353 | static DEVICE_ATTR(optrom_fcode_version, S_IRUGO, |
| 1354 | qla2x00_optrom_fcode_version_show, NULL); |
| 1355 | static DEVICE_ATTR(optrom_fw_version, S_IRUGO, qla2x00_optrom_fw_version_show, |
| 1356 | NULL); |
Madhuranath Iyengar | 0f2d962 | 2010-07-23 15:28:26 +0500 | [diff] [blame] | 1357 | static DEVICE_ATTR(optrom_gold_fw_version, S_IRUGO, |
| 1358 | qla2x00_optrom_gold_fw_version_show, NULL); |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1359 | static DEVICE_ATTR(84xx_fw_version, S_IRUGO, qla24xx_84xx_fw_version_show, |
| 1360 | NULL); |
Harish Zunjarrao | e5f5f6f | 2008-07-10 16:55:49 -0700 | [diff] [blame] | 1361 | static DEVICE_ATTR(total_isp_aborts, S_IRUGO, qla2x00_total_isp_aborts_show, |
| 1362 | NULL); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1363 | static DEVICE_ATTR(mpi_version, S_IRUGO, qla2x00_mpi_version_show, NULL); |
Andrew Vasquez | 55a9615 | 2009-03-24 09:08:03 -0700 | [diff] [blame] | 1364 | static DEVICE_ATTR(phy_version, S_IRUGO, qla2x00_phy_version_show, NULL); |
Lalit Chandivade | fbcbb5d | 2009-03-24 09:08:11 -0700 | [diff] [blame] | 1365 | static DEVICE_ATTR(flash_block_size, S_IRUGO, qla2x00_flash_block_size_show, |
| 1366 | NULL); |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1367 | static DEVICE_ATTR(vlan_id, S_IRUGO, qla2x00_vlan_id_show, NULL); |
| 1368 | static DEVICE_ATTR(vn_port_mac_address, S_IRUGO, |
| 1369 | qla2x00_vn_port_mac_address_show, NULL); |
Andrew Vasquez | 7f77402 | 2009-06-03 09:55:12 -0700 | [diff] [blame] | 1370 | static DEVICE_ATTR(fabric_param, S_IRUGO, qla2x00_fabric_param_show, NULL); |
Andrew Vasquez | 656e891 | 2009-06-03 09:55:29 -0700 | [diff] [blame] | 1371 | static DEVICE_ATTR(fw_state, S_IRUGO, qla2x00_fw_state_show, NULL); |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 1372 | static DEVICE_ATTR(thermal_temp, S_IRUGO, qla2x00_thermal_temp_show, NULL); |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 1373 | static DEVICE_ATTR(diag_requests, S_IRUGO, qla2x00_diag_requests_show, NULL); |
| 1374 | static DEVICE_ATTR(diag_megabytes, S_IRUGO, qla2x00_diag_megabytes_show, NULL); |
Harish Zunjarrao | 40129a4 | 2012-08-22 14:21:02 -0400 | [diff] [blame] | 1375 | static DEVICE_ATTR(fw_dump_size, S_IRUGO, qla2x00_fw_dump_size_show, NULL); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 1376 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1377 | struct device_attribute *qla2x00_host_attrs[] = { |
| 1378 | &dev_attr_driver_version, |
| 1379 | &dev_attr_fw_version, |
| 1380 | &dev_attr_serial_num, |
| 1381 | &dev_attr_isp_name, |
| 1382 | &dev_attr_isp_id, |
| 1383 | &dev_attr_model_name, |
| 1384 | &dev_attr_model_desc, |
| 1385 | &dev_attr_pci_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 1386 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1387 | &dev_attr_zio, |
| 1388 | &dev_attr_zio_timer, |
| 1389 | &dev_attr_beacon, |
| 1390 | &dev_attr_optrom_bios_version, |
| 1391 | &dev_attr_optrom_efi_version, |
| 1392 | &dev_attr_optrom_fcode_version, |
| 1393 | &dev_attr_optrom_fw_version, |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1394 | &dev_attr_84xx_fw_version, |
Harish Zunjarrao | e5f5f6f | 2008-07-10 16:55:49 -0700 | [diff] [blame] | 1395 | &dev_attr_total_isp_aborts, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1396 | &dev_attr_mpi_version, |
Andrew Vasquez | 55a9615 | 2009-03-24 09:08:03 -0700 | [diff] [blame] | 1397 | &dev_attr_phy_version, |
Lalit Chandivade | fbcbb5d | 2009-03-24 09:08:11 -0700 | [diff] [blame] | 1398 | &dev_attr_flash_block_size, |
Andrew Vasquez | bad7001 | 2009-04-06 22:33:38 -0700 | [diff] [blame] | 1399 | &dev_attr_vlan_id, |
| 1400 | &dev_attr_vn_port_mac_address, |
Andrew Vasquez | 7f77402 | 2009-06-03 09:55:12 -0700 | [diff] [blame] | 1401 | &dev_attr_fabric_param, |
Andrew Vasquez | 656e891 | 2009-06-03 09:55:29 -0700 | [diff] [blame] | 1402 | &dev_attr_fw_state, |
Madhuranath Iyengar | 0f2d962 | 2010-07-23 15:28:26 +0500 | [diff] [blame] | 1403 | &dev_attr_optrom_gold_fw_version, |
Andrew Vasquez | 794a569 | 2010-12-21 16:00:21 -0800 | [diff] [blame] | 1404 | &dev_attr_thermal_temp, |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 1405 | &dev_attr_diag_requests, |
| 1406 | &dev_attr_diag_megabytes, |
Harish Zunjarrao | 40129a4 | 2012-08-22 14:21:02 -0400 | [diff] [blame] | 1407 | &dev_attr_fw_dump_size, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 1408 | NULL, |
| 1409 | }; |
| 1410 | |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1411 | /* Host attributes. */ |
| 1412 | |
| 1413 | static void |
| 1414 | qla2x00_get_host_port_id(struct Scsi_Host *shost) |
| 1415 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1416 | scsi_qla_host_t *vha = shost_priv(shost); |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1417 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1418 | fc_host_port_id(shost) = vha->d_id.b.domain << 16 | |
| 1419 | vha->d_id.b.area << 8 | vha->d_id.b.al_pa; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1420 | } |
| 1421 | |
| 1422 | static void |
andrew.vasquez@qlogic.com | 0441401 | 2006-01-31 16:04:51 -0800 | [diff] [blame] | 1423 | qla2x00_get_host_speed(struct Scsi_Host *shost) |
| 1424 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1425 | struct qla_hw_data *ha = ((struct scsi_qla_host *) |
| 1426 | (shost_priv(shost)))->hw; |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 1427 | u32 speed = FC_PORTSPEED_UNKNOWN; |
andrew.vasquez@qlogic.com | 0441401 | 2006-01-31 16:04:51 -0800 | [diff] [blame] | 1428 | |
| 1429 | switch (ha->link_data_rate) { |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1430 | case PORT_SPEED_1GB: |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 1431 | speed = FC_PORTSPEED_1GBIT; |
andrew.vasquez@qlogic.com | 0441401 | 2006-01-31 16:04:51 -0800 | [diff] [blame] | 1432 | break; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1433 | case PORT_SPEED_2GB: |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 1434 | speed = FC_PORTSPEED_2GBIT; |
andrew.vasquez@qlogic.com | 0441401 | 2006-01-31 16:04:51 -0800 | [diff] [blame] | 1435 | break; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1436 | case PORT_SPEED_4GB: |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 1437 | speed = FC_PORTSPEED_4GBIT; |
andrew.vasquez@qlogic.com | 0441401 | 2006-01-31 16:04:51 -0800 | [diff] [blame] | 1438 | break; |
Seokmann Ju | da4541b | 2008-01-31 12:33:52 -0800 | [diff] [blame] | 1439 | case PORT_SPEED_8GB: |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 1440 | speed = FC_PORTSPEED_8GBIT; |
Seokmann Ju | da4541b | 2008-01-31 12:33:52 -0800 | [diff] [blame] | 1441 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1442 | case PORT_SPEED_10GB: |
| 1443 | speed = FC_PORTSPEED_10GBIT; |
| 1444 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1445 | case PORT_SPEED_16GB: |
| 1446 | speed = FC_PORTSPEED_16GBIT; |
| 1447 | break; |
andrew.vasquez@qlogic.com | 0441401 | 2006-01-31 16:04:51 -0800 | [diff] [blame] | 1448 | } |
| 1449 | fc_host_speed(shost) = speed; |
| 1450 | } |
| 1451 | |
| 1452 | static void |
andrew.vasquez@qlogic.com | 8d06762 | 2006-01-31 16:04:56 -0800 | [diff] [blame] | 1453 | qla2x00_get_host_port_type(struct Scsi_Host *shost) |
| 1454 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1455 | scsi_qla_host_t *vha = shost_priv(shost); |
andrew.vasquez@qlogic.com | 8d06762 | 2006-01-31 16:04:56 -0800 | [diff] [blame] | 1456 | uint32_t port_type = FC_PORTTYPE_UNKNOWN; |
| 1457 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1458 | if (vha->vp_idx) { |
Shyam Sundar | 2f2fa13 | 2008-05-12 22:21:07 -0700 | [diff] [blame] | 1459 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 1460 | return; |
| 1461 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1462 | switch (vha->hw->current_topology) { |
andrew.vasquez@qlogic.com | 8d06762 | 2006-01-31 16:04:56 -0800 | [diff] [blame] | 1463 | case ISP_CFG_NL: |
| 1464 | port_type = FC_PORTTYPE_LPORT; |
| 1465 | break; |
| 1466 | case ISP_CFG_FL: |
| 1467 | port_type = FC_PORTTYPE_NLPORT; |
| 1468 | break; |
| 1469 | case ISP_CFG_N: |
| 1470 | port_type = FC_PORTTYPE_PTP; |
| 1471 | break; |
| 1472 | case ISP_CFG_F: |
| 1473 | port_type = FC_PORTTYPE_NPORT; |
| 1474 | break; |
| 1475 | } |
| 1476 | fc_host_port_type(shost) = port_type; |
| 1477 | } |
| 1478 | |
| 1479 | static void |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1480 | qla2x00_get_starget_node_name(struct scsi_target *starget) |
| 1481 | { |
| 1482 | struct Scsi_Host *host = dev_to_shost(starget->dev.parent); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1483 | scsi_qla_host_t *vha = shost_priv(host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1484 | fc_port_t *fcport; |
Andrew Vasquez | f8b02a8 | 2005-08-31 15:21:20 -0700 | [diff] [blame] | 1485 | u64 node_name = 0; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1486 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1487 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Andrew Vasquez | 5ab5a4d | 2008-04-03 13:13:16 -0700 | [diff] [blame] | 1488 | if (fcport->rport && |
| 1489 | starget->id == fcport->rport->scsi_target_id) { |
Andrew Vasquez | f8b02a8 | 2005-08-31 15:21:20 -0700 | [diff] [blame] | 1490 | node_name = wwn_to_u64(fcport->node_name); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1491 | break; |
| 1492 | } |
| 1493 | } |
| 1494 | |
Andrew Vasquez | f8b02a8 | 2005-08-31 15:21:20 -0700 | [diff] [blame] | 1495 | fc_starget_node_name(starget) = node_name; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1496 | } |
| 1497 | |
| 1498 | static void |
| 1499 | qla2x00_get_starget_port_name(struct scsi_target *starget) |
| 1500 | { |
| 1501 | struct Scsi_Host *host = dev_to_shost(starget->dev.parent); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1502 | scsi_qla_host_t *vha = shost_priv(host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1503 | fc_port_t *fcport; |
Andrew Vasquez | f8b02a8 | 2005-08-31 15:21:20 -0700 | [diff] [blame] | 1504 | u64 port_name = 0; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1505 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1506 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Andrew Vasquez | 5ab5a4d | 2008-04-03 13:13:16 -0700 | [diff] [blame] | 1507 | if (fcport->rport && |
| 1508 | starget->id == fcport->rport->scsi_target_id) { |
Andrew Vasquez | f8b02a8 | 2005-08-31 15:21:20 -0700 | [diff] [blame] | 1509 | port_name = wwn_to_u64(fcport->port_name); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1510 | break; |
| 1511 | } |
| 1512 | } |
| 1513 | |
Andrew Vasquez | f8b02a8 | 2005-08-31 15:21:20 -0700 | [diff] [blame] | 1514 | fc_starget_port_name(starget) = port_name; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1515 | } |
| 1516 | |
| 1517 | static void |
| 1518 | qla2x00_get_starget_port_id(struct scsi_target *starget) |
| 1519 | { |
| 1520 | struct Scsi_Host *host = dev_to_shost(starget->dev.parent); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1521 | scsi_qla_host_t *vha = shost_priv(host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1522 | fc_port_t *fcport; |
| 1523 | uint32_t port_id = ~0U; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1524 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1525 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Andrew Vasquez | 5ab5a4d | 2008-04-03 13:13:16 -0700 | [diff] [blame] | 1526 | if (fcport->rport && |
| 1527 | starget->id == fcport->rport->scsi_target_id) { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1528 | port_id = fcport->d_id.b.domain << 16 | |
| 1529 | fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; |
| 1530 | break; |
| 1531 | } |
| 1532 | } |
| 1533 | |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1534 | fc_starget_port_id(starget) = port_id; |
| 1535 | } |
| 1536 | |
| 1537 | static void |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1538 | qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 1539 | { |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1540 | if (timeout) |
Andrew Vasquez | 85821c9 | 2008-07-10 16:55:48 -0700 | [diff] [blame] | 1541 | rport->dev_loss_tmo = timeout; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1542 | else |
Andrew Vasquez | 85821c9 | 2008-07-10 16:55:48 -0700 | [diff] [blame] | 1543 | rport->dev_loss_tmo = 1; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1544 | } |
| 1545 | |
Seokmann Ju | 5f3a9a2 | 2008-07-10 16:55:47 -0700 | [diff] [blame] | 1546 | static void |
| 1547 | qla2x00_dev_loss_tmo_callbk(struct fc_rport *rport) |
| 1548 | { |
| 1549 | struct Scsi_Host *host = rport_to_shost(rport); |
| 1550 | fc_port_t *fcport = *(fc_port_t **)rport->dd_data; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 1551 | unsigned long flags; |
Seokmann Ju | 5f3a9a2 | 2008-07-10 16:55:47 -0700 | [diff] [blame] | 1552 | |
Seokmann Ju | 3c01b4f | 2009-01-22 09:45:38 -0800 | [diff] [blame] | 1553 | if (!fcport) |
| 1554 | return; |
| 1555 | |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 1556 | /* Now that the rport has been deleted, set the fcport state to |
| 1557 | FCS_DEVICE_DEAD */ |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 1558 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_DEAD); |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 1559 | |
Giridhar Malavali | 3fadb80b | 2010-09-03 15:20:55 -0700 | [diff] [blame] | 1560 | /* |
| 1561 | * Transport has effectively 'deleted' the rport, clear |
| 1562 | * all local references. |
| 1563 | */ |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 1564 | spin_lock_irqsave(host->host_lock, flags); |
Giridhar Malavali | 3fadb80b | 2010-09-03 15:20:55 -0700 | [diff] [blame] | 1565 | fcport->rport = fcport->drport = NULL; |
| 1566 | *((fc_port_t **)rport->dd_data) = NULL; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 1567 | spin_unlock_irqrestore(host->host_lock, flags); |
Giridhar Malavali | 3fadb80b | 2010-09-03 15:20:55 -0700 | [diff] [blame] | 1568 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1569 | if (test_bit(ABORT_ISP_ACTIVE, &fcport->vha->dpc_flags)) |
| 1570 | return; |
| 1571 | |
| 1572 | if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) { |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 1573 | qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1574 | return; |
| 1575 | } |
Seokmann Ju | 5f3a9a2 | 2008-07-10 16:55:47 -0700 | [diff] [blame] | 1576 | } |
| 1577 | |
| 1578 | static void |
| 1579 | qla2x00_terminate_rport_io(struct fc_rport *rport) |
| 1580 | { |
| 1581 | fc_port_t *fcport = *(fc_port_t **)rport->dd_data; |
| 1582 | |
Seokmann Ju | 3c01b4f | 2009-01-22 09:45:38 -0800 | [diff] [blame] | 1583 | if (!fcport) |
| 1584 | return; |
| 1585 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1586 | if (test_bit(ABORT_ISP_ACTIVE, &fcport->vha->dpc_flags)) |
| 1587 | return; |
| 1588 | |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 1589 | if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) { |
| 1590 | qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16); |
| 1591 | return; |
| 1592 | } |
Andrew Vasquez | 6390d1f | 2008-08-13 21:36:56 -0700 | [diff] [blame] | 1593 | /* |
| 1594 | * At this point all fcport's software-states are cleared. Perform any |
| 1595 | * final cleanup of firmware resources (PCBs and XCBs). |
| 1596 | */ |
Andrew Vasquez | 6805c15 | 2009-06-03 09:55:27 -0700 | [diff] [blame] | 1597 | if (fcport->loop_id != FC_NO_LOOP_ID && |
Andrew Vasquez | af11f64 | 2012-02-09 11:15:43 -0800 | [diff] [blame] | 1598 | !test_bit(UNLOADING, &fcport->vha->dpc_flags)) { |
| 1599 | if (IS_FWI2_CAPABLE(fcport->vha->hw)) |
| 1600 | fcport->vha->hw->isp_ops->fabric_logout(fcport->vha, |
| 1601 | fcport->loop_id, fcport->d_id.b.domain, |
| 1602 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
| 1603 | else |
| 1604 | qla2x00_port_logout(fcport->vha, fcport); |
| 1605 | } |
Seokmann Ju | 5f3a9a2 | 2008-07-10 16:55:47 -0700 | [diff] [blame] | 1606 | } |
| 1607 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1608 | static int |
| 1609 | qla2x00_issue_lip(struct Scsi_Host *shost) |
| 1610 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1611 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1612 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1613 | qla2x00_loop_reset(vha); |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1614 | return 0; |
| 1615 | } |
| 1616 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1617 | static struct fc_host_statistics * |
| 1618 | qla2x00_get_fc_host_stats(struct Scsi_Host *shost) |
| 1619 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1620 | scsi_qla_host_t *vha = shost_priv(shost); |
| 1621 | struct qla_hw_data *ha = vha->hw; |
| 1622 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1623 | int rval; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 1624 | struct link_statistics *stats; |
| 1625 | dma_addr_t stats_dma; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1626 | struct fc_host_statistics *pfc_host_stat; |
| 1627 | |
Saurav Kashyap | 2be21fa | 2012-05-15 14:34:16 -0400 | [diff] [blame] | 1628 | pfc_host_stat = &vha->fc_host_stat; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1629 | memset(pfc_host_stat, -1, sizeof(struct fc_host_statistics)); |
| 1630 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1631 | if (test_bit(UNLOADING, &vha->dpc_flags)) |
| 1632 | goto done; |
| 1633 | |
| 1634 | if (unlikely(pci_channel_offline(ha->pdev))) |
| 1635 | goto done; |
| 1636 | |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 1637 | stats = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &stats_dma); |
| 1638 | if (stats == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1639 | ql_log(ql_log_warn, vha, 0x707d, |
| 1640 | "Failed to allocate memory for stats.\n"); |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 1641 | goto done; |
| 1642 | } |
| 1643 | memset(stats, 0, DMA_POOL_SIZE); |
| 1644 | |
| 1645 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1646 | if (IS_FWI2_CAPABLE(ha)) { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1647 | rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma); |
| 1648 | } else if (atomic_read(&base_vha->loop_state) == LOOP_READY && |
Andrew Vasquez | d051a5aa | 2012-02-09 11:14:05 -0800 | [diff] [blame] | 1649 | !qla2x00_reset_active(vha) && !ha->dpc_active) { |
Andrew Vasquez | 178779a | 2007-01-29 10:22:25 -0800 | [diff] [blame] | 1650 | /* Must be in a 'READY' state for statistics retrieval. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1651 | rval = qla2x00_get_link_status(base_vha, base_vha->loop_id, |
| 1652 | stats, stats_dma); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1653 | } |
Andrew Vasquez | 178779a | 2007-01-29 10:22:25 -0800 | [diff] [blame] | 1654 | |
| 1655 | if (rval != QLA_SUCCESS) |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 1656 | goto done_free; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1657 | |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 1658 | pfc_host_stat->link_failure_count = stats->link_fail_cnt; |
| 1659 | pfc_host_stat->loss_of_sync_count = stats->loss_sync_cnt; |
| 1660 | pfc_host_stat->loss_of_signal_count = stats->loss_sig_cnt; |
| 1661 | pfc_host_stat->prim_seq_protocol_err_count = stats->prim_seq_err_cnt; |
| 1662 | pfc_host_stat->invalid_tx_word_count = stats->inval_xmit_word_cnt; |
| 1663 | pfc_host_stat->invalid_crc_count = stats->inval_crc_cnt; |
| 1664 | if (IS_FWI2_CAPABLE(ha)) { |
Harish Zunjarrao | 032d8dd | 2008-07-10 16:55:50 -0700 | [diff] [blame] | 1665 | pfc_host_stat->lip_count = stats->lip_cnt; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 1666 | pfc_host_stat->tx_frames = stats->tx_frames; |
| 1667 | pfc_host_stat->rx_frames = stats->rx_frames; |
| 1668 | pfc_host_stat->dumped_frames = stats->dumped_frames; |
| 1669 | pfc_host_stat->nos_count = stats->nos_rcvd; |
| 1670 | } |
Saurav Kashyap | 2be21fa | 2012-05-15 14:34:16 -0400 | [diff] [blame] | 1671 | pfc_host_stat->fcp_input_megabytes = vha->qla_stats.input_bytes >> 20; |
| 1672 | pfc_host_stat->fcp_output_megabytes = vha->qla_stats.output_bytes >> 20; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 1673 | |
| 1674 | done_free: |
| 1675 | dma_pool_free(ha->s_dma_pool, stats, stats_dma); |
Andrew Vasquez | 178779a | 2007-01-29 10:22:25 -0800 | [diff] [blame] | 1676 | done: |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1677 | return pfc_host_stat; |
| 1678 | } |
| 1679 | |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 1680 | static void |
| 1681 | qla2x00_get_host_symbolic_name(struct Scsi_Host *shost) |
| 1682 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1683 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 1684 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1685 | qla2x00_get_sym_node_name(vha, fc_host_symbolic_name(shost)); |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 1686 | } |
| 1687 | |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 1688 | static void |
| 1689 | qla2x00_set_host_system_hostname(struct Scsi_Host *shost) |
| 1690 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1691 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 1692 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1693 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 1694 | } |
| 1695 | |
Andrew Vasquez | 90991c8 | 2006-10-02 12:00:46 -0700 | [diff] [blame] | 1696 | static void |
| 1697 | qla2x00_get_host_fabric_name(struct Scsi_Host *shost) |
| 1698 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1699 | scsi_qla_host_t *vha = shost_priv(shost); |
Giridhar Malavali | 35e0cbd | 2010-09-03 15:20:51 -0700 | [diff] [blame] | 1700 | uint8_t node_name[WWN_SIZE] = { 0xFF, 0xFF, 0xFF, 0xFF, \ |
| 1701 | 0xFF, 0xFF, 0xFF, 0xFF}; |
| 1702 | u64 fabric_name = wwn_to_u64(node_name); |
Andrew Vasquez | 90991c8 | 2006-10-02 12:00:46 -0700 | [diff] [blame] | 1703 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1704 | if (vha->device_flags & SWITCH_FOUND) |
Giridhar Malavali | 35e0cbd | 2010-09-03 15:20:51 -0700 | [diff] [blame] | 1705 | fabric_name = wwn_to_u64(vha->fabric_node_name); |
Andrew Vasquez | 90991c8 | 2006-10-02 12:00:46 -0700 | [diff] [blame] | 1706 | |
Giridhar Malavali | 35e0cbd | 2010-09-03 15:20:51 -0700 | [diff] [blame] | 1707 | fc_host_fabric_name(shost) = fabric_name; |
Andrew Vasquez | 90991c8 | 2006-10-02 12:00:46 -0700 | [diff] [blame] | 1708 | } |
| 1709 | |
Andrew Vasquez | 7047fcd | 2006-10-02 12:00:47 -0700 | [diff] [blame] | 1710 | static void |
| 1711 | qla2x00_get_host_port_state(struct Scsi_Host *shost) |
| 1712 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1713 | scsi_qla_host_t *vha = shost_priv(shost); |
| 1714 | struct scsi_qla_host *base_vha = pci_get_drvdata(vha->hw->pdev); |
Andrew Vasquez | 7047fcd | 2006-10-02 12:00:47 -0700 | [diff] [blame] | 1715 | |
Saurav Kashyap | 49e85c2 | 2011-11-18 09:02:20 -0800 | [diff] [blame] | 1716 | if (!base_vha->flags.online) { |
Andrew Vasquez | 7047fcd | 2006-10-02 12:00:47 -0700 | [diff] [blame] | 1717 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
Saurav Kashyap | 49e85c2 | 2011-11-18 09:02:20 -0800 | [diff] [blame] | 1718 | return; |
| 1719 | } |
| 1720 | |
| 1721 | switch (atomic_read(&base_vha->loop_state)) { |
| 1722 | case LOOP_UPDATE: |
| 1723 | fc_host_port_state(shost) = FC_PORTSTATE_DIAGNOSTICS; |
| 1724 | break; |
| 1725 | case LOOP_DOWN: |
| 1726 | if (test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags)) |
| 1727 | fc_host_port_state(shost) = FC_PORTSTATE_DIAGNOSTICS; |
| 1728 | else |
| 1729 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 1730 | break; |
| 1731 | case LOOP_DEAD: |
| 1732 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
| 1733 | break; |
| 1734 | case LOOP_READY: |
Andrew Vasquez | 7047fcd | 2006-10-02 12:00:47 -0700 | [diff] [blame] | 1735 | fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; |
Saurav Kashyap | 49e85c2 | 2011-11-18 09:02:20 -0800 | [diff] [blame] | 1736 | break; |
| 1737 | default: |
| 1738 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 1739 | break; |
| 1740 | } |
Andrew Vasquez | 7047fcd | 2006-10-02 12:00:47 -0700 | [diff] [blame] | 1741 | } |
| 1742 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1743 | static int |
| 1744 | qla24xx_vport_create(struct fc_vport *fc_vport, bool disable) |
| 1745 | { |
| 1746 | int ret = 0; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1747 | uint8_t qos = 0; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1748 | scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost); |
| 1749 | scsi_qla_host_t *vha = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1750 | struct qla_hw_data *ha = base_vha->hw; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1751 | uint16_t options = 0; |
| 1752 | int cnt; |
Anirban Chakraborty | 59e0b8b | 2009-06-03 09:55:19 -0700 | [diff] [blame] | 1753 | struct req_que *req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1754 | |
| 1755 | ret = qla24xx_vport_create_req_sanity_check(fc_vport); |
| 1756 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1757 | ql_log(ql_log_warn, vha, 0x707e, |
| 1758 | "Vport sanity check failed, status %x\n", ret); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1759 | return (ret); |
| 1760 | } |
| 1761 | |
| 1762 | vha = qla24xx_create_vhost(fc_vport); |
| 1763 | if (vha == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1764 | ql_log(ql_log_warn, vha, 0x707f, "Vport create host failed.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1765 | return FC_VPORT_FAILED; |
| 1766 | } |
| 1767 | if (disable) { |
| 1768 | atomic_set(&vha->vp_state, VP_OFFLINE); |
| 1769 | fc_vport_set_state(fc_vport, FC_VPORT_DISABLED); |
| 1770 | } else |
| 1771 | atomic_set(&vha->vp_state, VP_FAILED); |
| 1772 | |
| 1773 | /* ready to create vport */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1774 | ql_log(ql_log_info, vha, 0x7080, |
| 1775 | "VP entry id %d assigned.\n", vha->vp_idx); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1776 | |
| 1777 | /* initialized vport states */ |
| 1778 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1779 | vha->vp_err_state= VP_ERR_PORTDWN; |
| 1780 | vha->vp_prev_err_state= VP_ERR_UNKWN; |
| 1781 | /* Check if physical ha port is Up */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1782 | if (atomic_read(&base_vha->loop_state) == LOOP_DOWN || |
| 1783 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1784 | /* Don't retry or attempt login of this virtual port */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1785 | ql_dbg(ql_dbg_user, vha, 0x7081, |
| 1786 | "Vport loop state is not UP.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1787 | atomic_set(&vha->loop_state, LOOP_DEAD); |
| 1788 | if (!disable) |
| 1789 | fc_vport_set_state(fc_vport, FC_VPORT_LINKDOWN); |
| 1790 | } |
| 1791 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 1792 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1793 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 1794 | int prot = 0; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1795 | vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1796 | ql_dbg(ql_dbg_user, vha, 0x7082, |
| 1797 | "Registered for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 1798 | if (ql2xenabledif == 1) |
| 1799 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1800 | scsi_host_set_prot(vha->host, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 1801 | prot | SHOST_DIF_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 1802 | | SHOST_DIF_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1803 | | SHOST_DIF_TYPE3_PROTECTION |
| 1804 | | SHOST_DIX_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 1805 | | SHOST_DIX_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1806 | | SHOST_DIX_TYPE3_PROTECTION); |
| 1807 | scsi_host_set_guard(vha->host, SHOST_DIX_GUARD_CRC); |
| 1808 | } else |
| 1809 | vha->flags.difdix_supported = 0; |
| 1810 | } |
| 1811 | |
James Bottomley | d139b9b | 2009-11-05 13:33:12 -0600 | [diff] [blame] | 1812 | if (scsi_add_host_with_dma(vha->host, &fc_vport->dev, |
| 1813 | &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1814 | ql_dbg(ql_dbg_user, vha, 0x7083, |
| 1815 | "scsi_add_host failure for VP[%d].\n", vha->vp_idx); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1816 | goto vport_create_failed_2; |
| 1817 | } |
| 1818 | |
| 1819 | /* initialize attributes */ |
Mike Christie | d2b5f10 | 2010-09-15 16:52:30 -0500 | [diff] [blame] | 1820 | fc_host_dev_loss_tmo(vha->host) = ha->port_down_retry_count; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1821 | fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name); |
| 1822 | fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name); |
| 1823 | fc_host_supported_classes(vha->host) = |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1824 | fc_host_supported_classes(base_vha->host); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1825 | fc_host_supported_speeds(vha->host) = |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1826 | fc_host_supported_speeds(base_vha->host); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1827 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 1828 | qlt_vport_create(vha, ha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1829 | qla24xx_vport_disable(fc_vport, disable); |
| 1830 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 1831 | if (ha->flags.cpu_affinity_enabled) { |
Anirban Chakraborty | 59e0b8b | 2009-06-03 09:55:19 -0700 | [diff] [blame] | 1832 | req = ha->req_q_map[1]; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1833 | ql_dbg(ql_dbg_multiq, vha, 0xc000, |
| 1834 | "Request queue %p attached with " |
| 1835 | "VP[%d], cpu affinity =%d\n", |
| 1836 | req, vha->vp_idx, ha->flags.cpu_affinity_enabled); |
Anirban Chakraborty | 59e0b8b | 2009-06-03 09:55:19 -0700 | [diff] [blame] | 1837 | goto vport_queue; |
| 1838 | } else if (ql2xmaxqueues == 1 || !ha->npiv_info) |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1839 | goto vport_queue; |
| 1840 | /* Create a request queue in QoS mode for the vport */ |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 1841 | for (cnt = 0; cnt < ha->nvram_npiv_size; cnt++) { |
| 1842 | if (memcmp(ha->npiv_info[cnt].port_name, vha->port_name, 8) == 0 |
| 1843 | && memcmp(ha->npiv_info[cnt].node_name, vha->node_name, |
Anirban Chakraborty | 59e0b8b | 2009-06-03 09:55:19 -0700 | [diff] [blame] | 1844 | 8) == 0) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1845 | qos = ha->npiv_info[cnt].q_qos; |
| 1846 | break; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1847 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1848 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1849 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1850 | if (qos) { |
| 1851 | ret = qla25xx_create_req_que(ha, options, vha->vp_idx, 0, 0, |
| 1852 | qos); |
| 1853 | if (!ret) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1854 | ql_log(ql_log_warn, vha, 0x7084, |
| 1855 | "Can't create request queue for VP[%d]\n", |
| 1856 | vha->vp_idx); |
Anirban Chakraborty | 59e0b8b | 2009-06-03 09:55:19 -0700 | [diff] [blame] | 1857 | else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1858 | ql_dbg(ql_dbg_multiq, vha, 0xc001, |
| 1859 | "Request Que:%d Q0s: %d) created for VP[%d]\n", |
| 1860 | ret, qos, vha->vp_idx); |
| 1861 | ql_dbg(ql_dbg_user, vha, 0x7085, |
| 1862 | "Request Que:%d Q0s: %d) created for VP[%d]\n", |
| 1863 | ret, qos, vha->vp_idx); |
Anirban Chakraborty | 59e0b8b | 2009-06-03 09:55:19 -0700 | [diff] [blame] | 1864 | req = ha->req_q_map[ret]; |
| 1865 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1866 | } |
| 1867 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1868 | vport_queue: |
Anirban Chakraborty | 59e0b8b | 2009-06-03 09:55:19 -0700 | [diff] [blame] | 1869 | vha->req = req; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1870 | return 0; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1871 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1872 | vport_create_failed_2: |
| 1873 | qla24xx_disable_vp(vha); |
| 1874 | qla24xx_deallocate_vp_id(vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1875 | scsi_host_put(vha->host); |
| 1876 | return FC_VPORT_FAILED; |
| 1877 | } |
| 1878 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 1879 | static int |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1880 | qla24xx_vport_delete(struct fc_vport *fc_vport) |
| 1881 | { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1882 | scsi_qla_host_t *vha = fc_vport->dd_data; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1883 | struct qla_hw_data *ha = vha->hw; |
| 1884 | uint16_t id = vha->vp_idx; |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 1885 | |
| 1886 | while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) || |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1887 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags)) |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 1888 | msleep(1000); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1889 | |
| 1890 | qla24xx_disable_vp(vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1891 | |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 1892 | vha->flags.delete_progress = 1; |
| 1893 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1894 | fc_remove_host(vha->host); |
| 1895 | |
| 1896 | scsi_remove_host(vha->host); |
| 1897 | |
Arun Easi | 9f40682 | 2011-05-10 11:18:17 -0700 | [diff] [blame] | 1898 | /* Allow timer to run to drain queued items, when removing vp */ |
| 1899 | qla24xx_deallocate_vp_id(vha); |
| 1900 | |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 1901 | if (vha->timer_active) { |
| 1902 | qla2x00_vp_stop_timer(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1903 | ql_dbg(ql_dbg_user, vha, 0x7086, |
| 1904 | "Timer for the VP[%d] has stopped\n", vha->vp_idx); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 1905 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1906 | |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 1907 | /* No pending activities shall be there on the vha now */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1908 | if (ql2xextended_error_logging & ql_dbg_user) |
| 1909 | msleep(random32()%10); /* Just to see if something falls on |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 1910 | * the net we have placed below */ |
| 1911 | |
| 1912 | BUG_ON(atomic_read(&vha->vref_count)); |
| 1913 | |
| 1914 | qla2x00_free_fcports(vha); |
| 1915 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1916 | mutex_lock(&ha->vport_lock); |
| 1917 | ha->cur_vport_count--; |
| 1918 | clear_bit(vha->vp_idx, ha->vp_idx_map); |
| 1919 | mutex_unlock(&ha->vport_lock); |
| 1920 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 1921 | if (vha->req->id && !ha->flags.cpu_affinity_enabled) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1922 | if (qla25xx_delete_req_que(vha, vha->req) != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1923 | ql_log(ql_log_warn, vha, 0x7087, |
| 1924 | "Queue delete failed.\n"); |
Anirban Chakraborty | cf5a163 | 2009-02-08 20:50:13 -0800 | [diff] [blame] | 1925 | } |
| 1926 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1927 | ql_log(ql_log_info, vha, 0x7088, "VP[%d] deleted.\n", id); |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1928 | scsi_host_put(vha->host); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1929 | return 0; |
| 1930 | } |
| 1931 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 1932 | static int |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1933 | qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable) |
| 1934 | { |
| 1935 | scsi_qla_host_t *vha = fc_vport->dd_data; |
| 1936 | |
| 1937 | if (disable) |
| 1938 | qla24xx_disable_vp(vha); |
| 1939 | else |
| 1940 | qla24xx_enable_vp(vha); |
| 1941 | |
| 1942 | return 0; |
| 1943 | } |
| 1944 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 1945 | struct fc_function_template qla2xxx_transport_functions = { |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1946 | |
| 1947 | .show_host_node_name = 1, |
| 1948 | .show_host_port_name = 1, |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1949 | .show_host_supported_classes = 1, |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 1950 | .show_host_supported_speeds = 1, |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1951 | |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1952 | .get_host_port_id = qla2x00_get_host_port_id, |
| 1953 | .show_host_port_id = 1, |
andrew.vasquez@qlogic.com | 0441401 | 2006-01-31 16:04:51 -0800 | [diff] [blame] | 1954 | .get_host_speed = qla2x00_get_host_speed, |
| 1955 | .show_host_speed = 1, |
andrew.vasquez@qlogic.com | 8d06762 | 2006-01-31 16:04:56 -0800 | [diff] [blame] | 1956 | .get_host_port_type = qla2x00_get_host_port_type, |
| 1957 | .show_host_port_type = 1, |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 1958 | .get_host_symbolic_name = qla2x00_get_host_symbolic_name, |
| 1959 | .show_host_symbolic_name = 1, |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 1960 | .set_host_system_hostname = qla2x00_set_host_system_hostname, |
| 1961 | .show_host_system_hostname = 1, |
Andrew Vasquez | 90991c8 | 2006-10-02 12:00:46 -0700 | [diff] [blame] | 1962 | .get_host_fabric_name = qla2x00_get_host_fabric_name, |
| 1963 | .show_host_fabric_name = 1, |
Andrew Vasquez | 7047fcd | 2006-10-02 12:00:47 -0700 | [diff] [blame] | 1964 | .get_host_port_state = qla2x00_get_host_port_state, |
| 1965 | .show_host_port_state = 1, |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1966 | |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1967 | .dd_fcrport_size = sizeof(struct fc_port *), |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1968 | .show_rport_supported_classes = 1, |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1969 | |
| 1970 | .get_starget_node_name = qla2x00_get_starget_node_name, |
| 1971 | .show_starget_node_name = 1, |
| 1972 | .get_starget_port_name = qla2x00_get_starget_port_name, |
| 1973 | .show_starget_port_name = 1, |
| 1974 | .get_starget_port_id = qla2x00_get_starget_port_id, |
| 1975 | .show_starget_port_id = 1, |
| 1976 | |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1977 | .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo, |
| 1978 | .show_rport_dev_loss_tmo = 1, |
| 1979 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1980 | .issue_fc_host_lip = qla2x00_issue_lip, |
Seokmann Ju | 5f3a9a2 | 2008-07-10 16:55:47 -0700 | [diff] [blame] | 1981 | .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk, |
| 1982 | .terminate_rport_io = qla2x00_terminate_rport_io, |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1983 | .get_fc_host_stats = qla2x00_get_fc_host_stats, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1984 | |
| 1985 | .vport_create = qla24xx_vport_create, |
| 1986 | .vport_disable = qla24xx_vport_disable, |
| 1987 | .vport_delete = qla24xx_vport_delete, |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1988 | .bsg_request = qla24xx_bsg_request, |
| 1989 | .bsg_timeout = qla24xx_bsg_timeout, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1990 | }; |
| 1991 | |
| 1992 | struct fc_function_template qla2xxx_transport_vport_functions = { |
| 1993 | |
| 1994 | .show_host_node_name = 1, |
| 1995 | .show_host_port_name = 1, |
| 1996 | .show_host_supported_classes = 1, |
| 1997 | |
| 1998 | .get_host_port_id = qla2x00_get_host_port_id, |
| 1999 | .show_host_port_id = 1, |
| 2000 | .get_host_speed = qla2x00_get_host_speed, |
| 2001 | .show_host_speed = 1, |
| 2002 | .get_host_port_type = qla2x00_get_host_port_type, |
| 2003 | .show_host_port_type = 1, |
| 2004 | .get_host_symbolic_name = qla2x00_get_host_symbolic_name, |
| 2005 | .show_host_symbolic_name = 1, |
| 2006 | .set_host_system_hostname = qla2x00_set_host_system_hostname, |
| 2007 | .show_host_system_hostname = 1, |
| 2008 | .get_host_fabric_name = qla2x00_get_host_fabric_name, |
| 2009 | .show_host_fabric_name = 1, |
| 2010 | .get_host_port_state = qla2x00_get_host_port_state, |
| 2011 | .show_host_port_state = 1, |
| 2012 | |
| 2013 | .dd_fcrport_size = sizeof(struct fc_port *), |
| 2014 | .show_rport_supported_classes = 1, |
| 2015 | |
| 2016 | .get_starget_node_name = qla2x00_get_starget_node_name, |
| 2017 | .show_starget_node_name = 1, |
| 2018 | .get_starget_port_name = qla2x00_get_starget_port_name, |
| 2019 | .show_starget_port_name = 1, |
| 2020 | .get_starget_port_id = qla2x00_get_starget_port_id, |
| 2021 | .show_starget_port_id = 1, |
| 2022 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2023 | .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo, |
| 2024 | .show_rport_dev_loss_tmo = 1, |
| 2025 | |
| 2026 | .issue_fc_host_lip = qla2x00_issue_lip, |
Seokmann Ju | 5f3a9a2 | 2008-07-10 16:55:47 -0700 | [diff] [blame] | 2027 | .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk, |
| 2028 | .terminate_rport_io = qla2x00_terminate_rport_io, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2029 | .get_fc_host_stats = qla2x00_get_fc_host_stats, |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 2030 | .bsg_request = qla24xx_bsg_request, |
| 2031 | .bsg_timeout = qla24xx_bsg_timeout, |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2032 | }; |
| 2033 | |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2034 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2035 | qla2x00_init_host_attr(scsi_qla_host_t *vha) |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2036 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2037 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 2038 | u32 speed = FC_PORTSPEED_UNKNOWN; |
| 2039 | |
Mike Christie | d2b5f10 | 2010-09-15 16:52:30 -0500 | [diff] [blame] | 2040 | fc_host_dev_loss_tmo(vha->host) = ha->port_down_retry_count; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2041 | fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name); |
| 2042 | fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2043 | fc_host_supported_classes(vha->host) = ha->tgt.enable_class_2 ? |
| 2044 | (FC_COS_CLASS2|FC_COS_CLASS3) : FC_COS_CLASS3; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2045 | fc_host_max_npiv_vports(vha->host) = ha->max_npiv_vports; |
| 2046 | fc_host_npiv_vports_inuse(vha->host) = ha->cur_vport_count; |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 2047 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2048 | if (IS_CNA_CAPABLE(ha)) |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2049 | speed = FC_PORTSPEED_10GBIT; |
Giridhar Malavali | 6f606d2 | 2012-05-15 14:34:18 -0400 | [diff] [blame] | 2050 | else if (IS_QLA2031(ha)) |
| 2051 | speed = FC_PORTSPEED_16GBIT | FC_PORTSPEED_8GBIT | |
| 2052 | FC_PORTSPEED_4GBIT; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2053 | else if (IS_QLA25XX(ha)) |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 2054 | speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT | |
| 2055 | FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2056 | else if (IS_QLA24XX_TYPE(ha)) |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 2057 | speed = FC_PORTSPEED_4GBIT | FC_PORTSPEED_2GBIT | |
| 2058 | FC_PORTSPEED_1GBIT; |
| 2059 | else if (IS_QLA23XX(ha)) |
| 2060 | speed = FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT; |
| 2061 | else |
| 2062 | speed = FC_PORTSPEED_1GBIT; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2063 | fc_host_supported_speeds(vha->host) = speed; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 2064 | } |