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