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