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