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