| 8482e11 | 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 | 01e58d8 | 2008-04-03 13:13:13 -0700 | [diff] [blame] | 3 | * Copyright (c) 2003-2008 QLogic Corporation |
| 8482e11 | 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. |
| 8482e11 | 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> |
FUJITA Tomonori | 00eabe7 | 2008-07-28 11:59:20 +0900 | [diff] [blame] | 11 | #include <linux/delay.h> |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 12 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 13 | static int qla24xx_vport_disable(struct fc_vport *, bool); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 14 | |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 15 | /* SYSFS attributes --------------------------------------------------------- */ |
| 16 | |
| 17 | static ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 18 | qla2x00_sysfs_read_fw_dump(struct kobject *kobj, |
| 19 | struct bin_attribute *bin_attr, |
| 20 | char *buf, loff_t off, size_t count) |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 21 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 22 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 23 | struct device, kobj))); |
| 24 | |
| 25 | if (ha->fw_dump_reading == 0) |
| 26 | return 0; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 27 | |
Akinobu Mita | b3dc908 | 2008-07-24 08:31:47 -0700 | [diff] [blame] | 28 | return memory_read_from_buffer(buf, count, &off, ha->fw_dump, |
| 29 | ha->fw_dump_len); |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | static ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 33 | qla2x00_sysfs_write_fw_dump(struct kobject *kobj, |
| 34 | struct bin_attribute *bin_attr, |
| 35 | char *buf, loff_t off, size_t count) |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 36 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 37 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 38 | struct device, kobj))); |
| 39 | int reading; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 40 | |
| 41 | if (off != 0) |
| 42 | return (0); |
| 43 | |
| 44 | reading = simple_strtol(buf, NULL, 10); |
| 45 | switch (reading) { |
| 46 | case 0: |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 47 | if (!ha->fw_dump_reading) |
| 48 | break; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 49 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 50 | qla_printk(KERN_INFO, ha, |
| 51 | "Firmware dump cleared on (%ld).\n", ha->host_no); |
| 52 | |
| 53 | ha->fw_dump_reading = 0; |
| 54 | ha->fw_dumped = 0; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 55 | break; |
| 56 | case 1: |
Andrew Vasquez | d4e3e04 | 2006-05-17 15:09:50 -0700 | [diff] [blame] | 57 | if (ha->fw_dumped && !ha->fw_dump_reading) { |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 58 | ha->fw_dump_reading = 1; |
| 59 | |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 60 | qla_printk(KERN_INFO, ha, |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 61 | "Raw firmware dump ready for read on (%ld).\n", |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 62 | ha->host_no); |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 63 | } |
| 64 | break; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 65 | case 2: |
| 66 | qla2x00_alloc_fw_dump(ha); |
| 67 | break; |
Andrew Vasquez | 68af081 | 2008-05-12 22:21:13 -0700 | [diff] [blame] | 68 | case 3: |
| 69 | qla2x00_system_error(ha); |
| 70 | break; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 71 | } |
| 72 | return (count); |
| 73 | } |
| 74 | |
| 75 | static struct bin_attribute sysfs_fw_dump_attr = { |
| 76 | .attr = { |
| 77 | .name = "fw_dump", |
| 78 | .mode = S_IRUSR | S_IWUSR, |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 79 | }, |
| 80 | .size = 0, |
| 81 | .read = qla2x00_sysfs_read_fw_dump, |
| 82 | .write = qla2x00_sysfs_write_fw_dump, |
| 83 | }; |
| 84 | |
| 85 | static ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 86 | qla2x00_sysfs_read_nvram(struct kobject *kobj, |
| 87 | struct bin_attribute *bin_attr, |
| 88 | char *buf, loff_t off, size_t count) |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 89 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 90 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 91 | struct device, kobj))); |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 92 | |
Akinobu Mita | b3dc908 | 2008-07-24 08:31:47 -0700 | [diff] [blame] | 93 | if (!capable(CAP_SYS_ADMIN)) |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 94 | return 0; |
| 95 | |
Seokmann Ju | 281afe1 | 2007-07-26 13:43:34 -0700 | [diff] [blame] | 96 | /* Read NVRAM data from cache. */ |
Akinobu Mita | b3dc908 | 2008-07-24 08:31:47 -0700 | [diff] [blame] | 97 | return memory_read_from_buffer(buf, count, &off, ha->nvram, |
| 98 | ha->nvram_size); |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | static ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 102 | qla2x00_sysfs_write_nvram(struct kobject *kobj, |
| 103 | struct bin_attribute *bin_attr, |
| 104 | char *buf, loff_t off, size_t count) |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 105 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 106 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 107 | struct device, kobj))); |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 108 | uint16_t cnt; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 109 | |
Andrew Vasquez | 459c537 | 2005-07-06 10:31:07 -0700 | [diff] [blame] | 110 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size) |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 111 | return 0; |
| 112 | |
| 113 | /* Checksum NVRAM. */ |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 114 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 459c537 | 2005-07-06 10:31:07 -0700 | [diff] [blame] | 115 | uint32_t *iter; |
| 116 | uint32_t chksum; |
| 117 | |
| 118 | iter = (uint32_t *)buf; |
| 119 | chksum = 0; |
| 120 | for (cnt = 0; cnt < ((count >> 2) - 1); cnt++) |
| 121 | chksum += le32_to_cpu(*iter++); |
| 122 | chksum = ~chksum + 1; |
| 123 | *iter = cpu_to_le32(chksum); |
| 124 | } else { |
| 125 | uint8_t *iter; |
| 126 | uint8_t chksum; |
| 127 | |
| 128 | iter = (uint8_t *)buf; |
| 129 | chksum = 0; |
| 130 | for (cnt = 0; cnt < count - 1; cnt++) |
| 131 | chksum += *iter++; |
| 132 | chksum = ~chksum + 1; |
| 133 | *iter = chksum; |
| 134 | } |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 135 | |
| 136 | /* Write NVRAM. */ |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 137 | ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count); |
Andrew Vasquez | c45bcc8 | 2007-09-20 14:07:42 -0700 | [diff] [blame] | 138 | ha->isp_ops->read_nvram(ha, (uint8_t *)ha->nvram, ha->nvram_base, |
Seokmann Ju | 281afe1 | 2007-07-26 13:43:34 -0700 | [diff] [blame] | 139 | count); |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 140 | |
Andrew Vasquez | 26b8d348 | 2007-01-29 10:22:28 -0800 | [diff] [blame] | 141 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); |
| 142 | |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 143 | return (count); |
| 144 | } |
| 145 | |
| 146 | static struct bin_attribute sysfs_nvram_attr = { |
| 147 | .attr = { |
| 148 | .name = "nvram", |
| 149 | .mode = S_IRUSR | S_IWUSR, |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 150 | }, |
andrew.vasquez@qlogic.com | 1b3f636 | 2006-01-31 16:05:12 -0800 | [diff] [blame] | 151 | .size = 512, |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 152 | .read = qla2x00_sysfs_read_nvram, |
| 153 | .write = qla2x00_sysfs_write_nvram, |
| 154 | }; |
| 155 | |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 156 | static ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 157 | qla2x00_sysfs_read_optrom(struct kobject *kobj, |
| 158 | struct bin_attribute *bin_attr, |
| 159 | char *buf, loff_t off, size_t count) |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 160 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 161 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 162 | struct device, kobj))); |
| 163 | |
| 164 | if (ha->optrom_state != QLA_SREADING) |
| 165 | return 0; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 166 | |
Akinobu Mita | b3dc908 | 2008-07-24 08:31:47 -0700 | [diff] [blame] | 167 | return memory_read_from_buffer(buf, count, &off, ha->optrom_buffer, |
| 168 | ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | static ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 172 | qla2x00_sysfs_write_optrom(struct kobject *kobj, |
| 173 | struct bin_attribute *bin_attr, |
| 174 | char *buf, loff_t off, size_t count) |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 175 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 176 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 177 | struct device, kobj))); |
| 178 | |
| 179 | if (ha->optrom_state != QLA_SWRITING) |
| 180 | return -EINVAL; |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 181 | if (off > ha->optrom_region_size) |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 182 | return -ERANGE; |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 183 | if (off + count > ha->optrom_region_size) |
| 184 | count = ha->optrom_region_size - off; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 185 | |
| 186 | memcpy(&ha->optrom_buffer[off], buf, count); |
| 187 | |
| 188 | return count; |
| 189 | } |
| 190 | |
| 191 | static struct bin_attribute sysfs_optrom_attr = { |
| 192 | .attr = { |
| 193 | .name = "optrom", |
| 194 | .mode = S_IRUSR | S_IWUSR, |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 195 | }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 196 | .size = 0, |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 197 | .read = qla2x00_sysfs_read_optrom, |
| 198 | .write = qla2x00_sysfs_write_optrom, |
| 199 | }; |
| 200 | |
| 201 | static ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 202 | qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj, |
| 203 | struct bin_attribute *bin_attr, |
| 204 | char *buf, loff_t off, size_t count) |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 205 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 206 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 207 | struct device, kobj))); |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 208 | uint32_t start = 0; |
| 209 | uint32_t size = ha->optrom_size; |
| 210 | int val, valid; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 211 | |
| 212 | if (off) |
| 213 | return 0; |
| 214 | |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 215 | if (sscanf(buf, "%d:%x:%x", &val, &start, &size) < 1) |
| 216 | return -EINVAL; |
| 217 | if (start > ha->optrom_size) |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 218 | return -EINVAL; |
| 219 | |
| 220 | switch (val) { |
| 221 | case 0: |
| 222 | if (ha->optrom_state != QLA_SREADING && |
| 223 | ha->optrom_state != QLA_SWRITING) |
| 224 | break; |
| 225 | |
| 226 | ha->optrom_state = QLA_SWAITING; |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 227 | |
| 228 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 229 | "Freeing flash region allocation -- 0x%x bytes.\n", |
| 230 | ha->optrom_region_size)); |
| 231 | |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 232 | vfree(ha->optrom_buffer); |
| 233 | ha->optrom_buffer = NULL; |
| 234 | break; |
| 235 | case 1: |
| 236 | if (ha->optrom_state != QLA_SWAITING) |
| 237 | break; |
| 238 | |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 239 | if (start & 0xfff) { |
| 240 | qla_printk(KERN_WARNING, ha, |
| 241 | "Invalid start region 0x%x/0x%x.\n", start, size); |
| 242 | return -EINVAL; |
| 243 | } |
| 244 | |
| 245 | ha->optrom_region_start = start; |
| 246 | ha->optrom_region_size = start + size > ha->optrom_size ? |
| 247 | ha->optrom_size - start : size; |
| 248 | |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 249 | ha->optrom_state = QLA_SREADING; |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 250 | ha->optrom_buffer = vmalloc(ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 251 | if (ha->optrom_buffer == NULL) { |
| 252 | qla_printk(KERN_WARNING, ha, |
| 253 | "Unable to allocate memory for optrom retrieval " |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 254 | "(%x).\n", ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 255 | |
| 256 | ha->optrom_state = QLA_SWAITING; |
| 257 | return count; |
| 258 | } |
| 259 | |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 260 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 261 | "Reading flash region -- 0x%x/0x%x.\n", |
| 262 | ha->optrom_region_start, ha->optrom_region_size)); |
| 263 | |
| 264 | memset(ha->optrom_buffer, 0, ha->optrom_region_size); |
| 265 | ha->isp_ops->read_optrom(ha, ha->optrom_buffer, |
| 266 | ha->optrom_region_start, ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 267 | break; |
| 268 | case 2: |
| 269 | if (ha->optrom_state != QLA_SWAITING) |
| 270 | break; |
| 271 | |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 272 | /* |
| 273 | * We need to be more restrictive on which FLASH regions are |
| 274 | * allowed to be updated via user-space. Regions accessible |
| 275 | * via this method include: |
| 276 | * |
| 277 | * ISP21xx/ISP22xx/ISP23xx type boards: |
| 278 | * |
| 279 | * 0x000000 -> 0x020000 -- Boot code. |
| 280 | * |
| 281 | * ISP2322/ISP24xx type boards: |
| 282 | * |
| 283 | * 0x000000 -> 0x07ffff -- Boot code. |
| 284 | * 0x080000 -> 0x0fffff -- Firmware. |
| 285 | * |
| 286 | * ISP25xx type boards: |
| 287 | * |
| 288 | * 0x000000 -> 0x07ffff -- Boot code. |
| 289 | * 0x080000 -> 0x0fffff -- Firmware. |
| 290 | * 0x120000 -> 0x12ffff -- VPD and HBA parameters. |
| 291 | */ |
| 292 | valid = 0; |
| 293 | if (ha->optrom_size == OPTROM_SIZE_2300 && start == 0) |
| 294 | valid = 1; |
| 295 | else if (start == (FA_BOOT_CODE_ADDR*4) || |
| 296 | start == (FA_RISC_CODE_ADDR*4)) |
| 297 | valid = 1; |
| 298 | else if (IS_QLA25XX(ha) && start == (FA_VPD_NVRAM_ADDR*4)) |
| 299 | valid = 1; |
| 300 | if (!valid) { |
| 301 | qla_printk(KERN_WARNING, ha, |
| 302 | "Invalid start region 0x%x/0x%x.\n", start, size); |
| 303 | return -EINVAL; |
| 304 | } |
| 305 | |
| 306 | ha->optrom_region_start = start; |
| 307 | ha->optrom_region_size = start + size > ha->optrom_size ? |
| 308 | ha->optrom_size - start : size; |
| 309 | |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 310 | ha->optrom_state = QLA_SWRITING; |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 311 | ha->optrom_buffer = vmalloc(ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 312 | if (ha->optrom_buffer == NULL) { |
| 313 | qla_printk(KERN_WARNING, ha, |
| 314 | "Unable to allocate memory for optrom update " |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 315 | "(%x).\n", ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 316 | |
| 317 | ha->optrom_state = QLA_SWAITING; |
| 318 | return count; |
| 319 | } |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 320 | |
| 321 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 322 | "Staging flash region write -- 0x%x/0x%x.\n", |
| 323 | ha->optrom_region_start, ha->optrom_region_size)); |
| 324 | |
| 325 | memset(ha->optrom_buffer, 0, ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 326 | break; |
| 327 | case 3: |
| 328 | if (ha->optrom_state != QLA_SWRITING) |
| 329 | break; |
| 330 | |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 331 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 332 | "Writing flash region -- 0x%x/0x%x.\n", |
| 333 | ha->optrom_region_start, ha->optrom_region_size)); |
| 334 | |
| 335 | ha->isp_ops->write_optrom(ha, ha->optrom_buffer, |
| 336 | ha->optrom_region_start, ha->optrom_region_size); |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 337 | break; |
Joe Carnuccio | b7cc176 | 2007-09-20 14:07:35 -0700 | [diff] [blame] | 338 | default: |
| 339 | count = -EINVAL; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 340 | } |
| 341 | return count; |
| 342 | } |
| 343 | |
| 344 | static struct bin_attribute sysfs_optrom_ctl_attr = { |
| 345 | .attr = { |
| 346 | .name = "optrom_ctl", |
| 347 | .mode = S_IWUSR, |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 348 | }, |
| 349 | .size = 0, |
| 350 | .write = qla2x00_sysfs_write_optrom_ctl, |
| 351 | }; |
| 352 | |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 353 | static ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 354 | qla2x00_sysfs_read_vpd(struct kobject *kobj, |
| 355 | struct bin_attribute *bin_attr, |
| 356 | char *buf, loff_t off, size_t count) |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 357 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 358 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 359 | struct device, kobj))); |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 360 | |
Akinobu Mita | b3dc908 | 2008-07-24 08:31:47 -0700 | [diff] [blame] | 361 | if (!capable(CAP_SYS_ADMIN)) |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 362 | return 0; |
| 363 | |
Seokmann Ju | 281afe1 | 2007-07-26 13:43:34 -0700 | [diff] [blame] | 364 | /* Read NVRAM data from cache. */ |
Akinobu Mita | b3dc908 | 2008-07-24 08:31:47 -0700 | [diff] [blame] | 365 | 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] | 366 | } |
| 367 | |
| 368 | static ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 369 | qla2x00_sysfs_write_vpd(struct kobject *kobj, |
| 370 | struct bin_attribute *bin_attr, |
| 371 | char *buf, loff_t off, size_t count) |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 372 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 373 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 374 | struct device, kobj))); |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 375 | |
| 376 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size) |
| 377 | return 0; |
| 378 | |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 379 | /* Write NVRAM. */ |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 380 | ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->vpd_base, count); |
Seokmann Ju | 281afe1 | 2007-07-26 13:43:34 -0700 | [diff] [blame] | 381 | ha->isp_ops->read_nvram(ha, (uint8_t *)ha->vpd, ha->vpd_base, count); |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 382 | |
| 383 | return count; |
| 384 | } |
| 385 | |
| 386 | static struct bin_attribute sysfs_vpd_attr = { |
| 387 | .attr = { |
| 388 | .name = "vpd", |
| 389 | .mode = S_IRUSR | S_IWUSR, |
andrew.vasquez@qlogic.com | 6f64179 | 2006-03-09 14:27:34 -0800 | [diff] [blame] | 390 | }, |
| 391 | .size = 0, |
| 392 | .read = qla2x00_sysfs_read_vpd, |
| 393 | .write = qla2x00_sysfs_write_vpd, |
| 394 | }; |
| 395 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 396 | static ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 397 | qla2x00_sysfs_read_sfp(struct kobject *kobj, |
| 398 | struct bin_attribute *bin_attr, |
| 399 | char *buf, loff_t off, size_t count) |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 400 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 401 | struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 402 | struct device, kobj))); |
| 403 | uint16_t iter, addr, offset; |
| 404 | int rval; |
| 405 | |
| 406 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != SFP_DEV_SIZE * 2) |
| 407 | return 0; |
| 408 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 409 | if (ha->sfp_data) |
| 410 | goto do_read; |
| 411 | |
| 412 | ha->sfp_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 413 | &ha->sfp_data_dma); |
| 414 | if (!ha->sfp_data) { |
| 415 | qla_printk(KERN_WARNING, ha, |
| 416 | "Unable to allocate memory for SFP read-data.\n"); |
| 417 | return 0; |
| 418 | } |
| 419 | |
| 420 | do_read: |
| 421 | memset(ha->sfp_data, 0, SFP_BLOCK_SIZE); |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 422 | addr = 0xa0; |
| 423 | for (iter = 0, offset = 0; iter < (SFP_DEV_SIZE * 2) / SFP_BLOCK_SIZE; |
| 424 | iter++, offset += SFP_BLOCK_SIZE) { |
| 425 | if (iter == 4) { |
| 426 | /* Skip to next device address. */ |
| 427 | addr = 0xa2; |
| 428 | offset = 0; |
| 429 | } |
| 430 | |
| 431 | rval = qla2x00_read_sfp(ha, ha->sfp_data_dma, addr, offset, |
| 432 | SFP_BLOCK_SIZE); |
| 433 | if (rval != QLA_SUCCESS) { |
| 434 | qla_printk(KERN_WARNING, ha, |
| 435 | "Unable to read SFP data (%x/%x/%x).\n", rval, |
| 436 | addr, offset); |
| 437 | count = 0; |
| 438 | break; |
| 439 | } |
| 440 | memcpy(buf, ha->sfp_data, SFP_BLOCK_SIZE); |
| 441 | buf += SFP_BLOCK_SIZE; |
| 442 | } |
| 443 | |
| 444 | return count; |
| 445 | } |
| 446 | |
| 447 | static struct bin_attribute sysfs_sfp_attr = { |
| 448 | .attr = { |
| 449 | .name = "sfp", |
| 450 | .mode = S_IRUSR | S_IWUSR, |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 451 | }, |
| 452 | .size = SFP_DEV_SIZE * 2, |
| 453 | .read = qla2x00_sysfs_read_sfp, |
| 454 | }; |
| 455 | |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 456 | static struct sysfs_entry { |
| 457 | char *name; |
| 458 | struct bin_attribute *attr; |
| 459 | int is4GBp_only; |
| 460 | } bin_file_entries[] = { |
| 461 | { "fw_dump", &sysfs_fw_dump_attr, }, |
| 462 | { "nvram", &sysfs_nvram_attr, }, |
| 463 | { "optrom", &sysfs_optrom_attr, }, |
| 464 | { "optrom_ctl", &sysfs_optrom_ctl_attr, }, |
| 465 | { "vpd", &sysfs_vpd_attr, 1 }, |
| 466 | { "sfp", &sysfs_sfp_attr, 1 }, |
Randy Dunlap | 46ddab7 | 2006-11-27 09:35:42 -0800 | [diff] [blame] | 467 | { NULL }, |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 468 | }; |
| 469 | |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 470 | void |
| 471 | qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha) |
| 472 | { |
| 473 | struct Scsi_Host *host = ha->host; |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 474 | struct sysfs_entry *iter; |
| 475 | int ret; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 476 | |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 477 | for (iter = bin_file_entries; iter->name; iter++) { |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 478 | if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 479 | continue; |
| 480 | |
| 481 | ret = sysfs_create_bin_file(&host->shost_gendev.kobj, |
| 482 | iter->attr); |
| 483 | if (ret) |
| 484 | qla_printk(KERN_INFO, ha, |
| 485 | "Unable to create sysfs %s binary attribute " |
| 486 | "(%d).\n", iter->name, ret); |
Andrew Vasquez | 7914d00 | 2006-06-23 16:10:55 -0700 | [diff] [blame] | 487 | } |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 488 | } |
| 489 | |
| 490 | void |
| 491 | qla2x00_free_sysfs_attr(scsi_qla_host_t *ha) |
| 492 | { |
| 493 | struct Scsi_Host *host = ha->host; |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 494 | struct sysfs_entry *iter; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 495 | |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 496 | for (iter = bin_file_entries; iter->name; iter++) { |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 497 | if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 498 | continue; |
| 499 | |
Andrew Vasquez | 7914d00 | 2006-06-23 16:10:55 -0700 | [diff] [blame] | 500 | sysfs_remove_bin_file(&host->shost_gendev.kobj, |
Andrew Vasquez | f1663ad | 2006-10-13 09:33:37 -0700 | [diff] [blame] | 501 | iter->attr); |
Andrew Vasquez | 7914d00 | 2006-06-23 16:10:55 -0700 | [diff] [blame] | 502 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 503 | |
| 504 | if (ha->beacon_blink_led == 1) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 505 | ha->isp_ops->beacon_off(ha); |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 506 | } |
| 507 | |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 508 | /* Scsi_Host attributes. */ |
| 509 | |
| 510 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 511 | qla2x00_drvr_version_show(struct device *dev, |
| 512 | struct device_attribute *attr, char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 513 | { |
| 514 | return snprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str); |
| 515 | } |
| 516 | |
| 517 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 518 | qla2x00_fw_version_show(struct device *dev, |
| 519 | struct device_attribute *attr, char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 520 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 521 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 522 | char fw_str[30]; |
| 523 | |
| 524 | return snprintf(buf, PAGE_SIZE, "%s\n", |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 525 | ha->isp_ops->fw_version_str(ha, fw_str)); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 529 | qla2x00_serial_num_show(struct device *dev, struct device_attribute *attr, |
| 530 | char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 531 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 532 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 533 | uint32_t sn; |
| 534 | |
Joe Carnuccio | 1ee2714 | 2008-07-10 16:55:53 -0700 | [diff] [blame] | 535 | if (IS_FWI2_CAPABLE(ha)) { |
| 536 | qla2xxx_get_vpd_field(ha, "SN", buf, PAGE_SIZE); |
| 537 | return snprintf(buf, PAGE_SIZE, "%s\n", buf); |
| 538 | } |
Andrew Vasquez | 8b7afc2 | 2007-10-19 15:59:19 -0700 | [diff] [blame] | 539 | |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 540 | sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; |
| 541 | return snprintf(buf, PAGE_SIZE, "%c%05d\n", 'A' + sn / 100000, |
| 542 | sn % 100000); |
| 543 | } |
| 544 | |
| 545 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 546 | qla2x00_isp_name_show(struct device *dev, struct device_attribute *attr, |
| 547 | char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 548 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 549 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 550 | return snprintf(buf, PAGE_SIZE, "ISP%04X\n", ha->pdev->device); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 554 | qla2x00_isp_id_show(struct device *dev, struct device_attribute *attr, |
| 555 | char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 556 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 557 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 558 | return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n", |
| 559 | ha->product_id[0], ha->product_id[1], ha->product_id[2], |
| 560 | ha->product_id[3]); |
| 561 | } |
| 562 | |
| 563 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 564 | qla2x00_model_name_show(struct device *dev, struct device_attribute *attr, |
| 565 | char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 566 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 567 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 568 | return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_number); |
| 569 | } |
| 570 | |
| 571 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 572 | qla2x00_model_desc_show(struct device *dev, struct device_attribute *attr, |
| 573 | char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 574 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 575 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 576 | return snprintf(buf, PAGE_SIZE, "%s\n", |
| 577 | ha->model_desc ? ha->model_desc: ""); |
| 578 | } |
| 579 | |
| 580 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 581 | qla2x00_pci_info_show(struct device *dev, struct device_attribute *attr, |
| 582 | char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 583 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 584 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 585 | char pci_info[30]; |
| 586 | |
| 587 | return snprintf(buf, PAGE_SIZE, "%s\n", |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 588 | ha->isp_ops->pci_info_str(ha, pci_info)); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | static ssize_t |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 592 | qla2x00_link_state_show(struct device *dev, struct device_attribute *attr, |
| 593 | char *buf) |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 594 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 595 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 596 | int len = 0; |
| 597 | |
| 598 | if (atomic_read(&ha->loop_state) == LOOP_DOWN || |
| 599 | atomic_read(&ha->loop_state) == LOOP_DEAD) |
| 600 | len = snprintf(buf, PAGE_SIZE, "Link Down\n"); |
| 601 | else if (atomic_read(&ha->loop_state) != LOOP_READY || |
| 602 | test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) || |
| 603 | test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) |
| 604 | len = snprintf(buf, PAGE_SIZE, "Unknown Link State\n"); |
| 605 | else { |
| 606 | len = snprintf(buf, PAGE_SIZE, "Link Up - "); |
| 607 | |
| 608 | switch (ha->current_topology) { |
| 609 | case ISP_CFG_NL: |
| 610 | len += snprintf(buf + len, PAGE_SIZE-len, "Loop\n"); |
| 611 | break; |
| 612 | case ISP_CFG_FL: |
| 613 | len += snprintf(buf + len, PAGE_SIZE-len, "FL_Port\n"); |
| 614 | break; |
| 615 | case ISP_CFG_N: |
| 616 | len += snprintf(buf + len, PAGE_SIZE-len, |
| 617 | "N_Port to N_Port\n"); |
| 618 | break; |
| 619 | case ISP_CFG_F: |
| 620 | len += snprintf(buf + len, PAGE_SIZE-len, "F_Port\n"); |
| 621 | break; |
| 622 | default: |
| 623 | len += snprintf(buf + len, PAGE_SIZE-len, "Loop\n"); |
| 624 | break; |
| 625 | } |
| 626 | } |
| 627 | return len; |
| 628 | } |
| 629 | |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 630 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 631 | qla2x00_zio_show(struct device *dev, struct device_attribute *attr, |
| 632 | char *buf) |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 633 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 634 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 635 | int len = 0; |
| 636 | |
| 637 | switch (ha->zio_mode) { |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 638 | case QLA_ZIO_MODE_6: |
| 639 | len += snprintf(buf + len, PAGE_SIZE-len, "Mode 6\n"); |
| 640 | break; |
| 641 | case QLA_ZIO_DISABLED: |
| 642 | len += snprintf(buf + len, PAGE_SIZE-len, "Disabled\n"); |
| 643 | break; |
| 644 | } |
| 645 | return len; |
| 646 | } |
| 647 | |
| 648 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 649 | qla2x00_zio_store(struct device *dev, struct device_attribute *attr, |
| 650 | const char *buf, size_t count) |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 651 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 652 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 653 | int val = 0; |
| 654 | uint16_t zio_mode; |
| 655 | |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 656 | if (!IS_ZIO_SUPPORTED(ha)) |
| 657 | return -ENOTSUPP; |
| 658 | |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 659 | if (sscanf(buf, "%d", &val) != 1) |
| 660 | return -EINVAL; |
| 661 | |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 662 | if (val) |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 663 | zio_mode = QLA_ZIO_MODE_6; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 664 | else |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 665 | zio_mode = QLA_ZIO_DISABLED; |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 666 | |
| 667 | /* Update per-hba values and queue a reset. */ |
| 668 | if (zio_mode != QLA_ZIO_DISABLED || ha->zio_mode != QLA_ZIO_DISABLED) { |
| 669 | ha->zio_mode = zio_mode; |
| 670 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); |
| 671 | } |
| 672 | return strlen(buf); |
| 673 | } |
| 674 | |
| 675 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 676 | qla2x00_zio_timer_show(struct device *dev, struct device_attribute *attr, |
| 677 | char *buf) |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 678 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 679 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 680 | |
| 681 | return snprintf(buf, PAGE_SIZE, "%d us\n", ha->zio_timer * 100); |
| 682 | } |
| 683 | |
| 684 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 685 | qla2x00_zio_timer_store(struct device *dev, struct device_attribute *attr, |
| 686 | const char *buf, size_t count) |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 687 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 688 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 689 | int val = 0; |
| 690 | uint16_t zio_timer; |
| 691 | |
| 692 | if (sscanf(buf, "%d", &val) != 1) |
| 693 | return -EINVAL; |
| 694 | if (val > 25500 || val < 100) |
| 695 | return -ERANGE; |
| 696 | |
| 697 | zio_timer = (uint16_t)(val / 100); |
| 698 | ha->zio_timer = zio_timer; |
| 699 | |
| 700 | return strlen(buf); |
| 701 | } |
| 702 | |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 703 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 704 | qla2x00_beacon_show(struct device *dev, struct device_attribute *attr, |
| 705 | char *buf) |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 706 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 707 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 708 | int len = 0; |
| 709 | |
| 710 | if (ha->beacon_blink_led) |
| 711 | len += snprintf(buf + len, PAGE_SIZE-len, "Enabled\n"); |
| 712 | else |
| 713 | len += snprintf(buf + len, PAGE_SIZE-len, "Disabled\n"); |
| 714 | return len; |
| 715 | } |
| 716 | |
| 717 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 718 | qla2x00_beacon_store(struct device *dev, struct device_attribute *attr, |
| 719 | const char *buf, size_t count) |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 720 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 721 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 722 | int val = 0; |
| 723 | int rval; |
| 724 | |
| 725 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 726 | return -EPERM; |
| 727 | |
| 728 | if (test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags)) { |
| 729 | qla_printk(KERN_WARNING, ha, |
| 730 | "Abort ISP active -- ignoring beacon request.\n"); |
| 731 | return -EBUSY; |
| 732 | } |
| 733 | |
| 734 | if (sscanf(buf, "%d", &val) != 1) |
| 735 | return -EINVAL; |
| 736 | |
| 737 | if (val) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 738 | rval = ha->isp_ops->beacon_on(ha); |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 739 | else |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 740 | rval = ha->isp_ops->beacon_off(ha); |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 741 | |
| 742 | if (rval != QLA_SUCCESS) |
| 743 | count = 0; |
| 744 | |
| 745 | return count; |
| 746 | } |
| 747 | |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 748 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 749 | qla2x00_optrom_bios_version_show(struct device *dev, |
| 750 | struct device_attribute *attr, char *buf) |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 751 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 752 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 753 | |
| 754 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1], |
| 755 | ha->bios_revision[0]); |
| 756 | } |
| 757 | |
| 758 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 759 | qla2x00_optrom_efi_version_show(struct device *dev, |
| 760 | struct device_attribute *attr, char *buf) |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 761 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 762 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 763 | |
| 764 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1], |
| 765 | ha->efi_revision[0]); |
| 766 | } |
| 767 | |
| 768 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 769 | qla2x00_optrom_fcode_version_show(struct device *dev, |
| 770 | struct device_attribute *attr, char *buf) |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 771 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 772 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 773 | |
| 774 | return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1], |
| 775 | ha->fcode_revision[0]); |
| 776 | } |
| 777 | |
| 778 | static ssize_t |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 779 | qla2x00_optrom_fw_version_show(struct device *dev, |
| 780 | struct device_attribute *attr, char *buf) |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 781 | { |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 782 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
Andrew Vasquez | 30c4766 | 2007-01-29 10:22:21 -0800 | [diff] [blame] | 783 | |
| 784 | return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n", |
| 785 | ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2], |
| 786 | ha->fw_revision[3]); |
| 787 | } |
| 788 | |
Harish Zunjarrao | e5f5f6f | 2008-07-10 16:55:49 -0700 | [diff] [blame] | 789 | static ssize_t |
| 790 | qla2x00_total_isp_aborts_show(struct device *dev, |
| 791 | struct device_attribute *attr, char *buf) |
| 792 | { |
| 793 | scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); |
| 794 | |
| 795 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 796 | ha->qla_stats.total_isp_aborts); |
| 797 | } |
| 798 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 799 | static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL); |
| 800 | static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL); |
| 801 | static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL); |
| 802 | static DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL); |
| 803 | static DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL); |
| 804 | static DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL); |
| 805 | static DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL); |
| 806 | static DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL); |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 807 | static DEVICE_ATTR(link_state, S_IRUGO, qla2x00_link_state_show, NULL); |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 808 | static DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show, qla2x00_zio_store); |
| 809 | static DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show, |
| 810 | qla2x00_zio_timer_store); |
| 811 | static DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show, |
| 812 | qla2x00_beacon_store); |
| 813 | static DEVICE_ATTR(optrom_bios_version, S_IRUGO, |
| 814 | qla2x00_optrom_bios_version_show, NULL); |
| 815 | static DEVICE_ATTR(optrom_efi_version, S_IRUGO, |
| 816 | qla2x00_optrom_efi_version_show, NULL); |
| 817 | static DEVICE_ATTR(optrom_fcode_version, S_IRUGO, |
| 818 | qla2x00_optrom_fcode_version_show, NULL); |
| 819 | static DEVICE_ATTR(optrom_fw_version, S_IRUGO, qla2x00_optrom_fw_version_show, |
| 820 | NULL); |
Harish Zunjarrao | e5f5f6f | 2008-07-10 16:55:49 -0700 | [diff] [blame] | 821 | static DEVICE_ATTR(total_isp_aborts, S_IRUGO, qla2x00_total_isp_aborts_show, |
| 822 | NULL); |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 823 | |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 824 | struct device_attribute *qla2x00_host_attrs[] = { |
| 825 | &dev_attr_driver_version, |
| 826 | &dev_attr_fw_version, |
| 827 | &dev_attr_serial_num, |
| 828 | &dev_attr_isp_name, |
| 829 | &dev_attr_isp_id, |
| 830 | &dev_attr_model_name, |
| 831 | &dev_attr_model_desc, |
| 832 | &dev_attr_pci_info, |
Hannes Reinecke | bbd1ae4 | 2008-03-18 14:32:28 +0100 | [diff] [blame] | 833 | &dev_attr_link_state, |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 834 | &dev_attr_zio, |
| 835 | &dev_attr_zio_timer, |
| 836 | &dev_attr_beacon, |
| 837 | &dev_attr_optrom_bios_version, |
| 838 | &dev_attr_optrom_efi_version, |
| 839 | &dev_attr_optrom_fcode_version, |
| 840 | &dev_attr_optrom_fw_version, |
Harish Zunjarrao | e5f5f6f | 2008-07-10 16:55:49 -0700 | [diff] [blame] | 841 | &dev_attr_total_isp_aborts, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 842 | NULL, |
| 843 | }; |
| 844 | |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 845 | /* Host attributes. */ |
| 846 | |
| 847 | static void |
| 848 | qla2x00_get_host_port_id(struct Scsi_Host *shost) |
| 849 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 850 | scsi_qla_host_t *ha = shost_priv(shost); |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 851 | |
| 852 | fc_host_port_id(shost) = ha->d_id.b.domain << 16 | |
| 853 | ha->d_id.b.area << 8 | ha->d_id.b.al_pa; |
| 854 | } |
| 855 | |
| 856 | static void |
andrew.vasquez@qlogic.com | 0441401 | 2006-01-31 16:04:51 -0800 | [diff] [blame] | 857 | qla2x00_get_host_speed(struct Scsi_Host *shost) |
| 858 | { |
Seokmann Ju | da4541b | 2008-01-31 12:33:52 -0800 | [diff] [blame] | 859 | scsi_qla_host_t *ha = to_qla_parent(shost_priv(shost)); |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 860 | u32 speed = FC_PORTSPEED_UNKNOWN; |
andrew.vasquez@qlogic.com | 0441401 | 2006-01-31 16:04:51 -0800 | [diff] [blame] | 861 | |
| 862 | switch (ha->link_data_rate) { |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 863 | case PORT_SPEED_1GB: |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 864 | speed = FC_PORTSPEED_1GBIT; |
andrew.vasquez@qlogic.com | 0441401 | 2006-01-31 16:04:51 -0800 | [diff] [blame] | 865 | break; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 866 | case PORT_SPEED_2GB: |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 867 | speed = FC_PORTSPEED_2GBIT; |
andrew.vasquez@qlogic.com | 0441401 | 2006-01-31 16:04:51 -0800 | [diff] [blame] | 868 | break; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 869 | case PORT_SPEED_4GB: |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 870 | speed = FC_PORTSPEED_4GBIT; |
andrew.vasquez@qlogic.com | 0441401 | 2006-01-31 16:04:51 -0800 | [diff] [blame] | 871 | break; |
Seokmann Ju | da4541b | 2008-01-31 12:33:52 -0800 | [diff] [blame] | 872 | case PORT_SPEED_8GB: |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 873 | speed = FC_PORTSPEED_8GBIT; |
Seokmann Ju | da4541b | 2008-01-31 12:33:52 -0800 | [diff] [blame] | 874 | break; |
andrew.vasquez@qlogic.com | 0441401 | 2006-01-31 16:04:51 -0800 | [diff] [blame] | 875 | } |
| 876 | fc_host_speed(shost) = speed; |
| 877 | } |
| 878 | |
| 879 | static void |
andrew.vasquez@qlogic.com | 8d06762 | 2006-01-31 16:04:56 -0800 | [diff] [blame] | 880 | qla2x00_get_host_port_type(struct Scsi_Host *shost) |
| 881 | { |
Shyam Sundar | 2f2fa13 | 2008-05-12 22:21:07 -0700 | [diff] [blame] | 882 | scsi_qla_host_t *ha = shost_priv(shost); |
andrew.vasquez@qlogic.com | 8d06762 | 2006-01-31 16:04:56 -0800 | [diff] [blame] | 883 | uint32_t port_type = FC_PORTTYPE_UNKNOWN; |
| 884 | |
Shyam Sundar | 2f2fa13 | 2008-05-12 22:21:07 -0700 | [diff] [blame] | 885 | if (ha->parent) { |
| 886 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 887 | return; |
| 888 | } |
andrew.vasquez@qlogic.com | 8d06762 | 2006-01-31 16:04:56 -0800 | [diff] [blame] | 889 | switch (ha->current_topology) { |
| 890 | case ISP_CFG_NL: |
| 891 | port_type = FC_PORTTYPE_LPORT; |
| 892 | break; |
| 893 | case ISP_CFG_FL: |
| 894 | port_type = FC_PORTTYPE_NLPORT; |
| 895 | break; |
| 896 | case ISP_CFG_N: |
| 897 | port_type = FC_PORTTYPE_PTP; |
| 898 | break; |
| 899 | case ISP_CFG_F: |
| 900 | port_type = FC_PORTTYPE_NPORT; |
| 901 | break; |
| 902 | } |
| 903 | fc_host_port_type(shost) = port_type; |
| 904 | } |
| 905 | |
| 906 | static void |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 907 | qla2x00_get_starget_node_name(struct scsi_target *starget) |
| 908 | { |
| 909 | struct Scsi_Host *host = dev_to_shost(starget->dev.parent); |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 910 | scsi_qla_host_t *ha = shost_priv(host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 911 | fc_port_t *fcport; |
Andrew Vasquez | f8b02a8 | 2005-08-31 15:21:20 -0700 | [diff] [blame] | 912 | u64 node_name = 0; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 913 | |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 914 | list_for_each_entry(fcport, &ha->fcports, list) { |
Andrew Vasquez | 5ab5a4d | 2008-04-03 13:13:16 -0700 | [diff] [blame] | 915 | if (fcport->rport && |
| 916 | starget->id == fcport->rport->scsi_target_id) { |
Andrew Vasquez | f8b02a8 | 2005-08-31 15:21:20 -0700 | [diff] [blame] | 917 | node_name = wwn_to_u64(fcport->node_name); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 918 | break; |
| 919 | } |
| 920 | } |
| 921 | |
Andrew Vasquez | f8b02a8 | 2005-08-31 15:21:20 -0700 | [diff] [blame] | 922 | fc_starget_node_name(starget) = node_name; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 923 | } |
| 924 | |
| 925 | static void |
| 926 | qla2x00_get_starget_port_name(struct scsi_target *starget) |
| 927 | { |
| 928 | struct Scsi_Host *host = dev_to_shost(starget->dev.parent); |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 929 | scsi_qla_host_t *ha = shost_priv(host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 930 | fc_port_t *fcport; |
Andrew Vasquez | f8b02a8 | 2005-08-31 15:21:20 -0700 | [diff] [blame] | 931 | u64 port_name = 0; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 932 | |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 933 | list_for_each_entry(fcport, &ha->fcports, list) { |
Andrew Vasquez | 5ab5a4d | 2008-04-03 13:13:16 -0700 | [diff] [blame] | 934 | if (fcport->rport && |
| 935 | starget->id == fcport->rport->scsi_target_id) { |
Andrew Vasquez | f8b02a8 | 2005-08-31 15:21:20 -0700 | [diff] [blame] | 936 | port_name = wwn_to_u64(fcport->port_name); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 937 | break; |
| 938 | } |
| 939 | } |
| 940 | |
Andrew Vasquez | f8b02a8 | 2005-08-31 15:21:20 -0700 | [diff] [blame] | 941 | fc_starget_port_name(starget) = port_name; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | static void |
| 945 | qla2x00_get_starget_port_id(struct scsi_target *starget) |
| 946 | { |
| 947 | struct Scsi_Host *host = dev_to_shost(starget->dev.parent); |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 948 | scsi_qla_host_t *ha = shost_priv(host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 949 | fc_port_t *fcport; |
| 950 | uint32_t port_id = ~0U; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 951 | |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 952 | list_for_each_entry(fcport, &ha->fcports, list) { |
Andrew Vasquez | 5ab5a4d | 2008-04-03 13:13:16 -0700 | [diff] [blame] | 953 | if (fcport->rport && |
| 954 | starget->id == fcport->rport->scsi_target_id) { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 955 | port_id = fcport->d_id.b.domain << 16 | |
| 956 | fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; |
| 957 | break; |
| 958 | } |
| 959 | } |
| 960 | |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 961 | fc_starget_port_id(starget) = port_id; |
| 962 | } |
| 963 | |
| 964 | static void |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 965 | qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
| 966 | { |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 967 | if (timeout) |
Andrew Vasquez | 85821c9 | 2008-07-10 16:55:48 -0700 | [diff] [blame] | 968 | rport->dev_loss_tmo = timeout; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 969 | else |
Andrew Vasquez | 85821c9 | 2008-07-10 16:55:48 -0700 | [diff] [blame] | 970 | rport->dev_loss_tmo = 1; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 971 | } |
| 972 | |
Seokmann Ju | 5f3a9a2 | 2008-07-10 16:55:47 -0700 | [diff] [blame] | 973 | static void |
| 974 | qla2x00_dev_loss_tmo_callbk(struct fc_rport *rport) |
| 975 | { |
| 976 | struct Scsi_Host *host = rport_to_shost(rport); |
| 977 | fc_port_t *fcport = *(fc_port_t **)rport->dd_data; |
| 978 | |
| 979 | qla2x00_abort_fcport_cmds(fcport); |
| 980 | |
| 981 | /* |
| 982 | * Transport has effectively 'deleted' the rport, clear |
| 983 | * all local references. |
| 984 | */ |
| 985 | spin_lock_irq(host->host_lock); |
| 986 | fcport->rport = NULL; |
| 987 | *((fc_port_t **)rport->dd_data) = NULL; |
| 988 | spin_unlock_irq(host->host_lock); |
| 989 | } |
| 990 | |
| 991 | static void |
| 992 | qla2x00_terminate_rport_io(struct fc_rport *rport) |
| 993 | { |
| 994 | fc_port_t *fcport = *(fc_port_t **)rport->dd_data; |
| 995 | |
| 996 | qla2x00_abort_fcport_cmds(fcport); |
| 997 | scsi_target_unblock(&rport->dev); |
| 998 | } |
| 999 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1000 | static int |
| 1001 | qla2x00_issue_lip(struct Scsi_Host *shost) |
| 1002 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 1003 | scsi_qla_host_t *ha = shost_priv(shost); |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1004 | |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1005 | qla2x00_loop_reset(ha); |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1006 | return 0; |
| 1007 | } |
| 1008 | |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1009 | static struct fc_host_statistics * |
| 1010 | qla2x00_get_fc_host_stats(struct Scsi_Host *shost) |
| 1011 | { |
Seokmann Ju | da4541b | 2008-01-31 12:33:52 -0800 | [diff] [blame] | 1012 | scsi_qla_host_t *ha = to_qla_parent(shost_priv(shost)); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1013 | int rval; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 1014 | struct link_statistics *stats; |
| 1015 | dma_addr_t stats_dma; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1016 | struct fc_host_statistics *pfc_host_stat; |
| 1017 | |
| 1018 | pfc_host_stat = &ha->fc_host_stat; |
| 1019 | memset(pfc_host_stat, -1, sizeof(struct fc_host_statistics)); |
| 1020 | |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 1021 | stats = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &stats_dma); |
| 1022 | if (stats == NULL) { |
| 1023 | DEBUG2_3_11(printk("%s(%ld): Failed to allocate memory.\n", |
| 1024 | __func__, ha->host_no)); |
| 1025 | goto done; |
| 1026 | } |
| 1027 | memset(stats, 0, DMA_POOL_SIZE); |
| 1028 | |
| 1029 | rval = QLA_FUNCTION_FAILED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1030 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 1031 | rval = qla24xx_get_isp_stats(ha, stats, stats_dma); |
Andrew Vasquez | 178779a | 2007-01-29 10:22:25 -0800 | [diff] [blame] | 1032 | } else if (atomic_read(&ha->loop_state) == LOOP_READY && |
| 1033 | !test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) && |
| 1034 | !test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) && |
| 1035 | !ha->dpc_active) { |
| 1036 | /* Must be in a 'READY' state for statistics retrieval. */ |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 1037 | rval = qla2x00_get_link_status(ha, ha->loop_id, stats, |
| 1038 | stats_dma); |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1039 | } |
Andrew Vasquez | 178779a | 2007-01-29 10:22:25 -0800 | [diff] [blame] | 1040 | |
| 1041 | if (rval != QLA_SUCCESS) |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 1042 | goto done_free; |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1043 | |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 1044 | pfc_host_stat->link_failure_count = stats->link_fail_cnt; |
| 1045 | pfc_host_stat->loss_of_sync_count = stats->loss_sync_cnt; |
| 1046 | pfc_host_stat->loss_of_signal_count = stats->loss_sig_cnt; |
| 1047 | pfc_host_stat->prim_seq_protocol_err_count = stats->prim_seq_err_cnt; |
| 1048 | pfc_host_stat->invalid_tx_word_count = stats->inval_xmit_word_cnt; |
| 1049 | pfc_host_stat->invalid_crc_count = stats->inval_crc_cnt; |
| 1050 | if (IS_FWI2_CAPABLE(ha)) { |
Harish Zunjarrao | 032d8dd | 2008-07-10 16:55:50 -0700 | [diff] [blame] | 1051 | pfc_host_stat->lip_count = stats->lip_cnt; |
Andrew Vasquez | 43ef058 | 2008-01-17 09:02:08 -0800 | [diff] [blame] | 1052 | pfc_host_stat->tx_frames = stats->tx_frames; |
| 1053 | pfc_host_stat->rx_frames = stats->rx_frames; |
| 1054 | pfc_host_stat->dumped_frames = stats->dumped_frames; |
| 1055 | pfc_host_stat->nos_count = stats->nos_rcvd; |
| 1056 | } |
| 1057 | |
| 1058 | done_free: |
| 1059 | dma_pool_free(ha->s_dma_pool, stats, stats_dma); |
Andrew Vasquez | 178779a | 2007-01-29 10:22:25 -0800 | [diff] [blame] | 1060 | done: |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1061 | return pfc_host_stat; |
| 1062 | } |
| 1063 | |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 1064 | static void |
| 1065 | qla2x00_get_host_symbolic_name(struct Scsi_Host *shost) |
| 1066 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 1067 | scsi_qla_host_t *ha = shost_priv(shost); |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 1068 | |
| 1069 | qla2x00_get_sym_node_name(ha, fc_host_symbolic_name(shost)); |
| 1070 | } |
| 1071 | |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 1072 | static void |
| 1073 | qla2x00_set_host_system_hostname(struct Scsi_Host *shost) |
| 1074 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 1075 | scsi_qla_host_t *ha = shost_priv(shost); |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 1076 | |
| 1077 | set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags); |
| 1078 | } |
| 1079 | |
Andrew Vasquez | 90991c8 | 2006-10-02 12:00:46 -0700 | [diff] [blame] | 1080 | static void |
| 1081 | qla2x00_get_host_fabric_name(struct Scsi_Host *shost) |
| 1082 | { |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 1083 | scsi_qla_host_t *ha = shost_priv(shost); |
Andrew Vasquez | 90991c8 | 2006-10-02 12:00:46 -0700 | [diff] [blame] | 1084 | u64 node_name; |
| 1085 | |
| 1086 | if (ha->device_flags & SWITCH_FOUND) |
| 1087 | node_name = wwn_to_u64(ha->fabric_node_name); |
| 1088 | else |
| 1089 | node_name = wwn_to_u64(ha->node_name); |
| 1090 | |
| 1091 | fc_host_fabric_name(shost) = node_name; |
| 1092 | } |
| 1093 | |
Andrew Vasquez | 7047fcd | 2006-10-02 12:00:47 -0700 | [diff] [blame] | 1094 | static void |
| 1095 | qla2x00_get_host_port_state(struct Scsi_Host *shost) |
| 1096 | { |
Seokmann Ju | da4541b | 2008-01-31 12:33:52 -0800 | [diff] [blame] | 1097 | scsi_qla_host_t *ha = to_qla_parent(shost_priv(shost)); |
Andrew Vasquez | 7047fcd | 2006-10-02 12:00:47 -0700 | [diff] [blame] | 1098 | |
| 1099 | if (!ha->flags.online) |
| 1100 | fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; |
| 1101 | else if (atomic_read(&ha->loop_state) == LOOP_TIMEOUT) |
| 1102 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
| 1103 | else |
| 1104 | fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; |
| 1105 | } |
| 1106 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1107 | static int |
| 1108 | qla24xx_vport_create(struct fc_vport *fc_vport, bool disable) |
| 1109 | { |
| 1110 | int ret = 0; |
Andrew Vasquez | f363b94 | 2007-09-20 14:07:45 -0700 | [diff] [blame] | 1111 | scsi_qla_host_t *ha = shost_priv(fc_vport->shost); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1112 | scsi_qla_host_t *vha; |
| 1113 | |
| 1114 | ret = qla24xx_vport_create_req_sanity_check(fc_vport); |
| 1115 | if (ret) { |
| 1116 | DEBUG15(printk("qla24xx_vport_create_req_sanity_check failed, " |
| 1117 | "status %x\n", ret)); |
| 1118 | return (ret); |
| 1119 | } |
| 1120 | |
| 1121 | vha = qla24xx_create_vhost(fc_vport); |
| 1122 | if (vha == NULL) { |
| 1123 | DEBUG15(printk ("qla24xx_create_vhost failed, vha = %p\n", |
| 1124 | vha)); |
| 1125 | return FC_VPORT_FAILED; |
| 1126 | } |
| 1127 | if (disable) { |
| 1128 | atomic_set(&vha->vp_state, VP_OFFLINE); |
| 1129 | fc_vport_set_state(fc_vport, FC_VPORT_DISABLED); |
| 1130 | } else |
| 1131 | atomic_set(&vha->vp_state, VP_FAILED); |
| 1132 | |
| 1133 | /* ready to create vport */ |
| 1134 | qla_printk(KERN_INFO, vha, "VP entry id %d assigned.\n", vha->vp_idx); |
| 1135 | |
| 1136 | /* initialized vport states */ |
| 1137 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1138 | vha->vp_err_state= VP_ERR_PORTDWN; |
| 1139 | vha->vp_prev_err_state= VP_ERR_UNKWN; |
| 1140 | /* Check if physical ha port is Up */ |
| 1141 | if (atomic_read(&ha->loop_state) == LOOP_DOWN || |
| 1142 | atomic_read(&ha->loop_state) == LOOP_DEAD) { |
| 1143 | /* Don't retry or attempt login of this virtual port */ |
| 1144 | DEBUG15(printk ("scsi(%ld): pport loop_state is not UP.\n", |
| 1145 | vha->host_no)); |
| 1146 | atomic_set(&vha->loop_state, LOOP_DEAD); |
| 1147 | if (!disable) |
| 1148 | fc_vport_set_state(fc_vport, FC_VPORT_LINKDOWN); |
| 1149 | } |
| 1150 | |
| 1151 | if (scsi_add_host(vha->host, &fc_vport->dev)) { |
| 1152 | DEBUG15(printk("scsi(%ld): scsi_add_host failure for VP[%d].\n", |
| 1153 | vha->host_no, vha->vp_idx)); |
| 1154 | goto vport_create_failed_2; |
| 1155 | } |
| 1156 | |
| 1157 | /* initialize attributes */ |
| 1158 | fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name); |
| 1159 | fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name); |
| 1160 | fc_host_supported_classes(vha->host) = |
| 1161 | fc_host_supported_classes(ha->host); |
| 1162 | fc_host_supported_speeds(vha->host) = |
| 1163 | fc_host_supported_speeds(ha->host); |
| 1164 | |
| 1165 | qla24xx_vport_disable(fc_vport, disable); |
| 1166 | |
| 1167 | return 0; |
| 1168 | vport_create_failed_2: |
| 1169 | qla24xx_disable_vp(vha); |
| 1170 | qla24xx_deallocate_vp_id(vha); |
| 1171 | kfree(vha->port_name); |
| 1172 | kfree(vha->node_name); |
| 1173 | scsi_host_put(vha->host); |
| 1174 | return FC_VPORT_FAILED; |
| 1175 | } |
| 1176 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 1177 | static int |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1178 | qla24xx_vport_delete(struct fc_vport *fc_vport) |
| 1179 | { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1180 | scsi_qla_host_t *vha = fc_vport->dd_data; |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 1181 | scsi_qla_host_t *pha = to_qla_parent(vha); |
| 1182 | |
| 1183 | while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) || |
| 1184 | test_bit(FCPORT_UPDATE_NEEDED, &pha->dpc_flags)) |
| 1185 | msleep(1000); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1186 | |
| 1187 | qla24xx_disable_vp(vha); |
| 1188 | qla24xx_deallocate_vp_id(vha); |
| 1189 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1190 | kfree(vha->node_name); |
| 1191 | kfree(vha->port_name); |
| 1192 | |
| 1193 | if (vha->timer_active) { |
| 1194 | qla2x00_vp_stop_timer(vha); |
| 1195 | DEBUG15(printk ("scsi(%ld): timer for the vport[%d] = %p " |
| 1196 | "has stopped\n", |
| 1197 | vha->host_no, vha->vp_idx, vha)); |
| 1198 | } |
| 1199 | |
| 1200 | fc_remove_host(vha->host); |
| 1201 | |
| 1202 | scsi_remove_host(vha->host); |
| 1203 | |
| 1204 | scsi_host_put(vha->host); |
| 1205 | |
| 1206 | return 0; |
| 1207 | } |
| 1208 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 1209 | static int |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1210 | qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable) |
| 1211 | { |
| 1212 | scsi_qla_host_t *vha = fc_vport->dd_data; |
| 1213 | |
| 1214 | if (disable) |
| 1215 | qla24xx_disable_vp(vha); |
| 1216 | else |
| 1217 | qla24xx_enable_vp(vha); |
| 1218 | |
| 1219 | return 0; |
| 1220 | } |
| 1221 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 1222 | struct fc_function_template qla2xxx_transport_functions = { |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1223 | |
| 1224 | .show_host_node_name = 1, |
| 1225 | .show_host_port_name = 1, |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1226 | .show_host_supported_classes = 1, |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 1227 | .show_host_supported_speeds = 1, |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1228 | |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1229 | .get_host_port_id = qla2x00_get_host_port_id, |
| 1230 | .show_host_port_id = 1, |
andrew.vasquez@qlogic.com | 0441401 | 2006-01-31 16:04:51 -0800 | [diff] [blame] | 1231 | .get_host_speed = qla2x00_get_host_speed, |
| 1232 | .show_host_speed = 1, |
andrew.vasquez@qlogic.com | 8d06762 | 2006-01-31 16:04:56 -0800 | [diff] [blame] | 1233 | .get_host_port_type = qla2x00_get_host_port_type, |
| 1234 | .show_host_port_type = 1, |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 1235 | .get_host_symbolic_name = qla2x00_get_host_symbolic_name, |
| 1236 | .show_host_symbolic_name = 1, |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 1237 | .set_host_system_hostname = qla2x00_set_host_system_hostname, |
| 1238 | .show_host_system_hostname = 1, |
Andrew Vasquez | 90991c8 | 2006-10-02 12:00:46 -0700 | [diff] [blame] | 1239 | .get_host_fabric_name = qla2x00_get_host_fabric_name, |
| 1240 | .show_host_fabric_name = 1, |
Andrew Vasquez | 7047fcd | 2006-10-02 12:00:47 -0700 | [diff] [blame] | 1241 | .get_host_port_state = qla2x00_get_host_port_state, |
| 1242 | .show_host_port_state = 1, |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1243 | |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1244 | .dd_fcrport_size = sizeof(struct fc_port *), |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1245 | .show_rport_supported_classes = 1, |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1246 | |
| 1247 | .get_starget_node_name = qla2x00_get_starget_node_name, |
| 1248 | .show_starget_node_name = 1, |
| 1249 | .get_starget_port_name = qla2x00_get_starget_port_name, |
| 1250 | .show_starget_port_name = 1, |
| 1251 | .get_starget_port_id = qla2x00_get_starget_port_id, |
| 1252 | .show_starget_port_id = 1, |
| 1253 | |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1254 | .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo, |
| 1255 | .show_rport_dev_loss_tmo = 1, |
| 1256 | |
Andrew Vasquez | 91ca7b0 | 2005-10-27 16:03:37 -0700 | [diff] [blame] | 1257 | .issue_fc_host_lip = qla2x00_issue_lip, |
Seokmann Ju | 5f3a9a2 | 2008-07-10 16:55:47 -0700 | [diff] [blame] | 1258 | .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk, |
| 1259 | .terminate_rport_io = qla2x00_terminate_rport_io, |
andrew.vasquez@qlogic.com | 392e2f6 | 2006-01-31 16:05:02 -0800 | [diff] [blame] | 1260 | .get_fc_host_stats = qla2x00_get_fc_host_stats, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1261 | |
| 1262 | .vport_create = qla24xx_vport_create, |
| 1263 | .vport_disable = qla24xx_vport_disable, |
| 1264 | .vport_delete = qla24xx_vport_delete, |
| 1265 | }; |
| 1266 | |
| 1267 | struct fc_function_template qla2xxx_transport_vport_functions = { |
| 1268 | |
| 1269 | .show_host_node_name = 1, |
| 1270 | .show_host_port_name = 1, |
| 1271 | .show_host_supported_classes = 1, |
| 1272 | |
| 1273 | .get_host_port_id = qla2x00_get_host_port_id, |
| 1274 | .show_host_port_id = 1, |
| 1275 | .get_host_speed = qla2x00_get_host_speed, |
| 1276 | .show_host_speed = 1, |
| 1277 | .get_host_port_type = qla2x00_get_host_port_type, |
| 1278 | .show_host_port_type = 1, |
| 1279 | .get_host_symbolic_name = qla2x00_get_host_symbolic_name, |
| 1280 | .show_host_symbolic_name = 1, |
| 1281 | .set_host_system_hostname = qla2x00_set_host_system_hostname, |
| 1282 | .show_host_system_hostname = 1, |
| 1283 | .get_host_fabric_name = qla2x00_get_host_fabric_name, |
| 1284 | .show_host_fabric_name = 1, |
| 1285 | .get_host_port_state = qla2x00_get_host_port_state, |
| 1286 | .show_host_port_state = 1, |
| 1287 | |
| 1288 | .dd_fcrport_size = sizeof(struct fc_port *), |
| 1289 | .show_rport_supported_classes = 1, |
| 1290 | |
| 1291 | .get_starget_node_name = qla2x00_get_starget_node_name, |
| 1292 | .show_starget_node_name = 1, |
| 1293 | .get_starget_port_name = qla2x00_get_starget_port_name, |
| 1294 | .show_starget_port_name = 1, |
| 1295 | .get_starget_port_id = qla2x00_get_starget_port_id, |
| 1296 | .show_starget_port_id = 1, |
| 1297 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1298 | .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo, |
| 1299 | .show_rport_dev_loss_tmo = 1, |
| 1300 | |
| 1301 | .issue_fc_host_lip = qla2x00_issue_lip, |
Seokmann Ju | 5f3a9a2 | 2008-07-10 16:55:47 -0700 | [diff] [blame] | 1302 | .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk, |
| 1303 | .terminate_rport_io = qla2x00_terminate_rport_io, |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1304 | .get_fc_host_stats = qla2x00_get_fc_host_stats, |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1305 | }; |
| 1306 | |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1307 | void |
| 1308 | qla2x00_init_host_attr(scsi_qla_host_t *ha) |
| 1309 | { |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 1310 | u32 speed = FC_PORTSPEED_UNKNOWN; |
| 1311 | |
andrew.vasquez@qlogic.com | dad9c8c | 2006-01-13 17:04:49 -0800 | [diff] [blame] | 1312 | fc_host_node_name(ha->host) = wwn_to_u64(ha->node_name); |
| 1313 | fc_host_port_name(ha->host) = wwn_to_u64(ha->port_name); |
Andrew Vasquez | ad3e0ed | 2005-08-26 19:08:10 -0700 | [diff] [blame] | 1314 | fc_host_supported_classes(ha->host) = FC_COS_CLASS3; |
Seokmann Ju | 4d0ea24 | 2007-09-20 14:07:43 -0700 | [diff] [blame] | 1315 | fc_host_max_npiv_vports(ha->host) = ha->max_npiv_vports;; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1316 | fc_host_npiv_vports_inuse(ha->host) = ha->cur_vport_count; |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 1317 | |
| 1318 | if (IS_QLA25XX(ha)) |
| 1319 | speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT | |
| 1320 | FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1321 | else if (IS_QLA24XX_TYPE(ha)) |
Andrew Vasquez | 2ae2b37 | 2008-04-03 13:13:14 -0700 | [diff] [blame] | 1322 | speed = FC_PORTSPEED_4GBIT | FC_PORTSPEED_2GBIT | |
| 1323 | FC_PORTSPEED_1GBIT; |
| 1324 | else if (IS_QLA23XX(ha)) |
| 1325 | speed = FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT; |
| 1326 | else |
| 1327 | speed = FC_PORTSPEED_1GBIT; |
| 1328 | fc_host_supported_speeds(ha->host) = speed; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1329 | } |