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