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