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