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