aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAnirban Chakraborty <anirban.chakraborty@qlogic.com>2008-11-06 13:40:19 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-12-29 12:24:15 -0500
commit7b867cf76fbcc8d77867cbec6f509f71dce8a98f (patch)
treeef5fcc1e21701ed1baa1b131c7c29f29cd41d5d6 /drivers
parenta9b589d90e3d7748dae459031c2d912cd9e83c88 (diff)
[SCSI] qla2xxx: Refactor qla data structures
Following changes have been made to the qla2xxx FC driver in preparation for the multi- queue and future SR IOV hardware. 1. scsi_qla_host structure has been changed to contain scsi host specific data only. 2. A new structure, qla_hw_data is created to contain HBA specific hardware data. 3. Request and response IO specific data strucures are created. 4. The global list of fcports for the hba is not maintained anymore, instead a fcport list is construted on per scsi_qla_host. Signed-of-by: Anirban Chakraborty <anirban.chakraborty@qlogic.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c298
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c61
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h525
-rw-r--r--drivers/scsi/qla2xxx/qla_dfs.c21
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h13
-rw-r--r--drivers/scsi/qla2xxx/qla_gs.c479
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c759
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c173
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c537
9 files changed, 1479 insertions, 1387 deletions
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index ed731968f15f..b22384229378 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -19,8 +19,9 @@ qla2x00_sysfs_read_fw_dump(struct kobject *kobj,
19 struct bin_attribute *bin_attr, 19 struct bin_attribute *bin_attr,
20 char *buf, loff_t off, size_t count) 20 char *buf, loff_t off, size_t count)
21{ 21{
22 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 22 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
23 struct device, kobj))); 23 struct device, kobj)));
24 struct qla_hw_data *ha = vha->hw;
24 25
25 if (ha->fw_dump_reading == 0) 26 if (ha->fw_dump_reading == 0)
26 return 0; 27 return 0;
@@ -34,8 +35,9 @@ qla2x00_sysfs_write_fw_dump(struct kobject *kobj,
34 struct bin_attribute *bin_attr, 35 struct bin_attribute *bin_attr,
35 char *buf, loff_t off, size_t count) 36 char *buf, loff_t off, size_t count)
36{ 37{
37 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 38 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
38 struct device, kobj))); 39 struct device, kobj)));
40 struct qla_hw_data *ha = vha->hw;
39 int reading; 41 int reading;
40 42
41 if (off != 0) 43 if (off != 0)
@@ -48,7 +50,7 @@ qla2x00_sysfs_write_fw_dump(struct kobject *kobj,
48 break; 50 break;
49 51
50 qla_printk(KERN_INFO, ha, 52 qla_printk(KERN_INFO, ha,
51 "Firmware dump cleared on (%ld).\n", ha->host_no); 53 "Firmware dump cleared on (%ld).\n", vha->host_no);
52 54
53 ha->fw_dump_reading = 0; 55 ha->fw_dump_reading = 0;
54 ha->fw_dumped = 0; 56 ha->fw_dumped = 0;
@@ -59,14 +61,14 @@ qla2x00_sysfs_write_fw_dump(struct kobject *kobj,
59 61
60 qla_printk(KERN_INFO, ha, 62 qla_printk(KERN_INFO, ha,
61 "Raw firmware dump ready for read on (%ld).\n", 63 "Raw firmware dump ready for read on (%ld).\n",
62 ha->host_no); 64 vha->host_no);
63 } 65 }
64 break; 66 break;
65 case 2: 67 case 2:
66 qla2x00_alloc_fw_dump(ha); 68 qla2x00_alloc_fw_dump(vha);
67 break; 69 break;
68 case 3: 70 case 3:
69 qla2x00_system_error(ha); 71 qla2x00_system_error(vha);
70 break; 72 break;
71 } 73 }
72 return (count); 74 return (count);
@@ -87,8 +89,9 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj,
87 struct bin_attribute *bin_attr, 89 struct bin_attribute *bin_attr,
88 char *buf, loff_t off, size_t count) 90 char *buf, loff_t off, size_t count)
89{ 91{
90 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 92 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
91 struct device, kobj))); 93 struct device, kobj)));
94 struct qla_hw_data *ha = vha->hw;
92 95
93 if (!capable(CAP_SYS_ADMIN)) 96 if (!capable(CAP_SYS_ADMIN))
94 return 0; 97 return 0;
@@ -103,8 +106,9 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj,
103 struct bin_attribute *bin_attr, 106 struct bin_attribute *bin_attr,
104 char *buf, loff_t off, size_t count) 107 char *buf, loff_t off, size_t count)
105{ 108{
106 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 109 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
107 struct device, kobj))); 110 struct device, kobj)));
111 struct qla_hw_data *ha = vha->hw;
108 uint16_t cnt; 112 uint16_t cnt;
109 113
110 if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size) 114 if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size)
@@ -134,11 +138,11 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj,
134 } 138 }
135 139
136 /* Write NVRAM. */ 140 /* Write NVRAM. */
137 ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count); 141 ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->nvram_base, count);
138 ha->isp_ops->read_nvram(ha, (uint8_t *)ha->nvram, ha->nvram_base, 142 ha->isp_ops->read_nvram(vha, (uint8_t *)ha->nvram, ha->nvram_base,
139 count); 143 count);
140 144
141 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 145 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
142 146
143 return (count); 147 return (count);
144} 148}
@@ -158,8 +162,9 @@ qla2x00_sysfs_read_optrom(struct kobject *kobj,
158 struct bin_attribute *bin_attr, 162 struct bin_attribute *bin_attr,
159 char *buf, loff_t off, size_t count) 163 char *buf, loff_t off, size_t count)
160{ 164{
161 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 165 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
162 struct device, kobj))); 166 struct device, kobj)));
167 struct qla_hw_data *ha = vha->hw;
163 168
164 if (ha->optrom_state != QLA_SREADING) 169 if (ha->optrom_state != QLA_SREADING)
165 return 0; 170 return 0;
@@ -173,8 +178,9 @@ qla2x00_sysfs_write_optrom(struct kobject *kobj,
173 struct bin_attribute *bin_attr, 178 struct bin_attribute *bin_attr,
174 char *buf, loff_t off, size_t count) 179 char *buf, loff_t off, size_t count)
175{ 180{
176 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 181 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
177 struct device, kobj))); 182 struct device, kobj)));
183 struct qla_hw_data *ha = vha->hw;
178 184
179 if (ha->optrom_state != QLA_SWRITING) 185 if (ha->optrom_state != QLA_SWRITING)
180 return -EINVAL; 186 return -EINVAL;
@@ -203,8 +209,10 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
203 struct bin_attribute *bin_attr, 209 struct bin_attribute *bin_attr,
204 char *buf, loff_t off, size_t count) 210 char *buf, loff_t off, size_t count)
205{ 211{
206 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 212 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
207 struct device, kobj))); 213 struct device, kobj)));
214 struct qla_hw_data *ha = vha->hw;
215
208 uint32_t start = 0; 216 uint32_t start = 0;
209 uint32_t size = ha->optrom_size; 217 uint32_t size = ha->optrom_size;
210 int val, valid; 218 int val, valid;
@@ -262,7 +270,7 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
262 ha->optrom_region_start, ha->optrom_region_size)); 270 ha->optrom_region_start, ha->optrom_region_size));
263 271
264 memset(ha->optrom_buffer, 0, ha->optrom_region_size); 272 memset(ha->optrom_buffer, 0, ha->optrom_region_size);
265 ha->isp_ops->read_optrom(ha, ha->optrom_buffer, 273 ha->isp_ops->read_optrom(vha, ha->optrom_buffer,
266 ha->optrom_region_start, ha->optrom_region_size); 274 ha->optrom_region_start, ha->optrom_region_size);
267 break; 275 break;
268 case 2: 276 case 2:
@@ -333,7 +341,7 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
333 "Writing flash region -- 0x%x/0x%x.\n", 341 "Writing flash region -- 0x%x/0x%x.\n",
334 ha->optrom_region_start, ha->optrom_region_size)); 342 ha->optrom_region_start, ha->optrom_region_size));
335 343
336 ha->isp_ops->write_optrom(ha, ha->optrom_buffer, 344 ha->isp_ops->write_optrom(vha, ha->optrom_buffer,
337 ha->optrom_region_start, ha->optrom_region_size); 345 ha->optrom_region_start, ha->optrom_region_size);
338 break; 346 break;
339 default: 347 default:
@@ -356,8 +364,9 @@ qla2x00_sysfs_read_vpd(struct kobject *kobj,
356 struct bin_attribute *bin_attr, 364 struct bin_attribute *bin_attr,
357 char *buf, loff_t off, size_t count) 365 char *buf, loff_t off, size_t count)
358{ 366{
359 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 367 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
360 struct device, kobj))); 368 struct device, kobj)));
369 struct qla_hw_data *ha = vha->hw;
361 370
362 if (!capable(CAP_SYS_ADMIN)) 371 if (!capable(CAP_SYS_ADMIN))
363 return 0; 372 return 0;
@@ -371,15 +380,16 @@ qla2x00_sysfs_write_vpd(struct kobject *kobj,
371 struct bin_attribute *bin_attr, 380 struct bin_attribute *bin_attr,
372 char *buf, loff_t off, size_t count) 381 char *buf, loff_t off, size_t count)
373{ 382{
374 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 383 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
375 struct device, kobj))); 384 struct device, kobj)));
385 struct qla_hw_data *ha = vha->hw;
376 386
377 if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size) 387 if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size)
378 return 0; 388 return 0;
379 389
380 /* Write NVRAM. */ 390 /* Write NVRAM. */
381 ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->vpd_base, count); 391 ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->vpd_base, count);
382 ha->isp_ops->read_nvram(ha, (uint8_t *)ha->vpd, ha->vpd_base, count); 392 ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, ha->vpd_base, count);
383 393
384 return count; 394 return count;
385} 395}
@@ -399,8 +409,9 @@ qla2x00_sysfs_read_sfp(struct kobject *kobj,
399 struct bin_attribute *bin_attr, 409 struct bin_attribute *bin_attr,
400 char *buf, loff_t off, size_t count) 410 char *buf, loff_t off, size_t count)
401{ 411{
402 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 412 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
403 struct device, kobj))); 413 struct device, kobj)));
414 struct qla_hw_data *ha = vha->hw;
404 uint16_t iter, addr, offset; 415 uint16_t iter, addr, offset;
405 int rval; 416 int rval;
406 417
@@ -429,7 +440,7 @@ do_read:
429 offset = 0; 440 offset = 0;
430 } 441 }
431 442
432 rval = qla2x00_read_sfp(ha, ha->sfp_data_dma, addr, offset, 443 rval = qla2x00_read_sfp(vha, ha->sfp_data_dma, addr, offset,
433 SFP_BLOCK_SIZE); 444 SFP_BLOCK_SIZE);
434 if (rval != QLA_SUCCESS) { 445 if (rval != QLA_SUCCESS) {
435 qla_printk(KERN_WARNING, ha, 446 qla_printk(KERN_WARNING, ha,
@@ -469,30 +480,31 @@ static struct sysfs_entry {
469}; 480};
470 481
471void 482void
472qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha) 483qla2x00_alloc_sysfs_attr(scsi_qla_host_t *vha)
473{ 484{
474 struct Scsi_Host *host = ha->host; 485 struct Scsi_Host *host = vha->host;
475 struct sysfs_entry *iter; 486 struct sysfs_entry *iter;
476 int ret; 487 int ret;
477 488
478 for (iter = bin_file_entries; iter->name; iter++) { 489 for (iter = bin_file_entries; iter->name; iter++) {
479 if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha)) 490 if (iter->is4GBp_only && !IS_FWI2_CAPABLE(vha->hw))
480 continue; 491 continue;
481 492
482 ret = sysfs_create_bin_file(&host->shost_gendev.kobj, 493 ret = sysfs_create_bin_file(&host->shost_gendev.kobj,
483 iter->attr); 494 iter->attr);
484 if (ret) 495 if (ret)
485 qla_printk(KERN_INFO, ha, 496 qla_printk(KERN_INFO, vha->hw,
486 "Unable to create sysfs %s binary attribute " 497 "Unable to create sysfs %s binary attribute "
487 "(%d).\n", iter->name, ret); 498 "(%d).\n", iter->name, ret);
488 } 499 }
489} 500}
490 501
491void 502void
492qla2x00_free_sysfs_attr(scsi_qla_host_t *ha) 503qla2x00_free_sysfs_attr(scsi_qla_host_t *vha)
493{ 504{
494 struct Scsi_Host *host = ha->host; 505 struct Scsi_Host *host = vha->host;
495 struct sysfs_entry *iter; 506 struct sysfs_entry *iter;
507 struct qla_hw_data *ha = vha->hw;
496 508
497 for (iter = bin_file_entries; iter->name; iter++) { 509 for (iter = bin_file_entries; iter->name; iter++) {
498 if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha)) 510 if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha))
@@ -503,7 +515,7 @@ qla2x00_free_sysfs_attr(scsi_qla_host_t *ha)
503 } 515 }
504 516
505 if (ha->beacon_blink_led == 1) 517 if (ha->beacon_blink_led == 1)
506 ha->isp_ops->beacon_off(ha); 518 ha->isp_ops->beacon_off(vha);
507} 519}
508 520
509/* Scsi_Host attributes. */ 521/* Scsi_Host attributes. */
@@ -519,22 +531,24 @@ static ssize_t
519qla2x00_fw_version_show(struct device *dev, 531qla2x00_fw_version_show(struct device *dev,
520 struct device_attribute *attr, char *buf) 532 struct device_attribute *attr, char *buf)
521{ 533{
522 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 534 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
523 char fw_str[30]; 535 struct qla_hw_data *ha = vha->hw;
536 char fw_str[128];
524 537
525 return snprintf(buf, PAGE_SIZE, "%s\n", 538 return snprintf(buf, PAGE_SIZE, "%s\n",
526 ha->isp_ops->fw_version_str(ha, fw_str)); 539 ha->isp_ops->fw_version_str(vha, fw_str));
527} 540}
528 541
529static ssize_t 542static ssize_t
530qla2x00_serial_num_show(struct device *dev, struct device_attribute *attr, 543qla2x00_serial_num_show(struct device *dev, struct device_attribute *attr,
531 char *buf) 544 char *buf)
532{ 545{
533 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 546 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
547 struct qla_hw_data *ha = vha->hw;
534 uint32_t sn; 548 uint32_t sn;
535 549
536 if (IS_FWI2_CAPABLE(ha)) { 550 if (IS_FWI2_CAPABLE(ha)) {
537 qla2xxx_get_vpd_field(ha, "SN", buf, PAGE_SIZE); 551 qla2xxx_get_vpd_field(vha, "SN", buf, PAGE_SIZE);
538 return snprintf(buf, PAGE_SIZE, "%s\n", buf); 552 return snprintf(buf, PAGE_SIZE, "%s\n", buf);
539 } 553 }
540 554
@@ -547,15 +561,16 @@ static ssize_t
547qla2x00_isp_name_show(struct device *dev, struct device_attribute *attr, 561qla2x00_isp_name_show(struct device *dev, struct device_attribute *attr,
548 char *buf) 562 char *buf)
549{ 563{
550 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 564 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
551 return snprintf(buf, PAGE_SIZE, "ISP%04X\n", ha->pdev->device); 565 return snprintf(buf, PAGE_SIZE, "ISP%04X\n", vha->hw->pdev->device);
552} 566}
553 567
554static ssize_t 568static ssize_t
555qla2x00_isp_id_show(struct device *dev, struct device_attribute *attr, 569qla2x00_isp_id_show(struct device *dev, struct device_attribute *attr,
556 char *buf) 570 char *buf)
557{ 571{
558 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 572 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
573 struct qla_hw_data *ha = vha->hw;
559 return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n", 574 return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n",
560 ha->product_id[0], ha->product_id[1], ha->product_id[2], 575 ha->product_id[0], ha->product_id[1], ha->product_id[2],
561 ha->product_id[3]); 576 ha->product_id[3]);
@@ -565,43 +580,44 @@ static ssize_t
565qla2x00_model_name_show(struct device *dev, struct device_attribute *attr, 580qla2x00_model_name_show(struct device *dev, struct device_attribute *attr,
566 char *buf) 581 char *buf)
567{ 582{
568 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 583 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
569 return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_number); 584 return snprintf(buf, PAGE_SIZE, "%s\n", vha->hw->model_number);
570} 585}
571 586
572static ssize_t 587static ssize_t
573qla2x00_model_desc_show(struct device *dev, struct device_attribute *attr, 588qla2x00_model_desc_show(struct device *dev, struct device_attribute *attr,
574 char *buf) 589 char *buf)
575{ 590{
576 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 591 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
577 return snprintf(buf, PAGE_SIZE, "%s\n", 592 return snprintf(buf, PAGE_SIZE, "%s\n",
578 ha->model_desc ? ha->model_desc: ""); 593 vha->hw->model_desc ? vha->hw->model_desc : "");
579} 594}
580 595
581static ssize_t 596static ssize_t
582qla2x00_pci_info_show(struct device *dev, struct device_attribute *attr, 597qla2x00_pci_info_show(struct device *dev, struct device_attribute *attr,
583 char *buf) 598 char *buf)
584{ 599{
585 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 600 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
586 char pci_info[30]; 601 char pci_info[30];
587 602
588 return snprintf(buf, PAGE_SIZE, "%s\n", 603 return snprintf(buf, PAGE_SIZE, "%s\n",
589 ha->isp_ops->pci_info_str(ha, pci_info)); 604 vha->hw->isp_ops->pci_info_str(vha, pci_info));
590} 605}
591 606
592static ssize_t 607static ssize_t
593qla2x00_link_state_show(struct device *dev, struct device_attribute *attr, 608qla2x00_link_state_show(struct device *dev, struct device_attribute *attr,
594 char *buf) 609 char *buf)
595{ 610{
596 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 611 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
612 struct qla_hw_data *ha = vha->hw;
597 int len = 0; 613 int len = 0;
598 614
599 if (atomic_read(&ha->loop_state) == LOOP_DOWN || 615 if (atomic_read(&vha->loop_state) == LOOP_DOWN ||
600 atomic_read(&ha->loop_state) == LOOP_DEAD) 616 atomic_read(&vha->loop_state) == LOOP_DEAD)
601 len = snprintf(buf, PAGE_SIZE, "Link Down\n"); 617 len = snprintf(buf, PAGE_SIZE, "Link Down\n");
602 else if (atomic_read(&ha->loop_state) != LOOP_READY || 618 else if (atomic_read(&vha->loop_state) != LOOP_READY ||
603 test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) || 619 test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
604 test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) 620 test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags))
605 len = snprintf(buf, PAGE_SIZE, "Unknown Link State\n"); 621 len = snprintf(buf, PAGE_SIZE, "Unknown Link State\n");
606 else { 622 else {
607 len = snprintf(buf, PAGE_SIZE, "Link Up - "); 623 len = snprintf(buf, PAGE_SIZE, "Link Up - ");
@@ -632,10 +648,10 @@ static ssize_t
632qla2x00_zio_show(struct device *dev, struct device_attribute *attr, 648qla2x00_zio_show(struct device *dev, struct device_attribute *attr,
633 char *buf) 649 char *buf)
634{ 650{
635 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 651 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
636 int len = 0; 652 int len = 0;
637 653
638 switch (ha->zio_mode) { 654 switch (vha->hw->zio_mode) {
639 case QLA_ZIO_MODE_6: 655 case QLA_ZIO_MODE_6:
640 len += snprintf(buf + len, PAGE_SIZE-len, "Mode 6\n"); 656 len += snprintf(buf + len, PAGE_SIZE-len, "Mode 6\n");
641 break; 657 break;
@@ -650,7 +666,8 @@ static ssize_t
650qla2x00_zio_store(struct device *dev, struct device_attribute *attr, 666qla2x00_zio_store(struct device *dev, struct device_attribute *attr,
651 const char *buf, size_t count) 667 const char *buf, size_t count)
652{ 668{
653 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 669 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
670 struct qla_hw_data *ha = vha->hw;
654 int val = 0; 671 int val = 0;
655 uint16_t zio_mode; 672 uint16_t zio_mode;
656 673
@@ -668,7 +685,7 @@ qla2x00_zio_store(struct device *dev, struct device_attribute *attr,
668 /* Update per-hba values and queue a reset. */ 685 /* Update per-hba values and queue a reset. */
669 if (zio_mode != QLA_ZIO_DISABLED || ha->zio_mode != QLA_ZIO_DISABLED) { 686 if (zio_mode != QLA_ZIO_DISABLED || ha->zio_mode != QLA_ZIO_DISABLED) {
670 ha->zio_mode = zio_mode; 687 ha->zio_mode = zio_mode;
671 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 688 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
672 } 689 }
673 return strlen(buf); 690 return strlen(buf);
674} 691}
@@ -677,16 +694,16 @@ static ssize_t
677qla2x00_zio_timer_show(struct device *dev, struct device_attribute *attr, 694qla2x00_zio_timer_show(struct device *dev, struct device_attribute *attr,
678 char *buf) 695 char *buf)
679{ 696{
680 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 697 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
681 698
682 return snprintf(buf, PAGE_SIZE, "%d us\n", ha->zio_timer * 100); 699 return snprintf(buf, PAGE_SIZE, "%d us\n", vha->hw->zio_timer * 100);
683} 700}
684 701
685static ssize_t 702static ssize_t
686qla2x00_zio_timer_store(struct device *dev, struct device_attribute *attr, 703qla2x00_zio_timer_store(struct device *dev, struct device_attribute *attr,
687 const char *buf, size_t count) 704 const char *buf, size_t count)
688{ 705{
689 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 706 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
690 int val = 0; 707 int val = 0;
691 uint16_t zio_timer; 708 uint16_t zio_timer;
692 709
@@ -696,7 +713,7 @@ qla2x00_zio_timer_store(struct device *dev, struct device_attribute *attr,
696 return -ERANGE; 713 return -ERANGE;
697 714
698 zio_timer = (uint16_t)(val / 100); 715 zio_timer = (uint16_t)(val / 100);
699 ha->zio_timer = zio_timer; 716 vha->hw->zio_timer = zio_timer;
700 717
701 return strlen(buf); 718 return strlen(buf);
702} 719}
@@ -705,10 +722,10 @@ static ssize_t
705qla2x00_beacon_show(struct device *dev, struct device_attribute *attr, 722qla2x00_beacon_show(struct device *dev, struct device_attribute *attr,
706 char *buf) 723 char *buf)
707{ 724{
708 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 725 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
709 int len = 0; 726 int len = 0;
710 727
711 if (ha->beacon_blink_led) 728 if (vha->hw->beacon_blink_led)
712 len += snprintf(buf + len, PAGE_SIZE-len, "Enabled\n"); 729 len += snprintf(buf + len, PAGE_SIZE-len, "Enabled\n");
713 else 730 else
714 len += snprintf(buf + len, PAGE_SIZE-len, "Disabled\n"); 731 len += snprintf(buf + len, PAGE_SIZE-len, "Disabled\n");
@@ -719,14 +736,15 @@ static ssize_t
719qla2x00_beacon_store(struct device *dev, struct device_attribute *attr, 736qla2x00_beacon_store(struct device *dev, struct device_attribute *attr,
720 const char *buf, size_t count) 737 const char *buf, size_t count)
721{ 738{
722 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 739 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
740 struct qla_hw_data *ha = vha->hw;
723 int val = 0; 741 int val = 0;
724 int rval; 742 int rval;
725 743
726 if (IS_QLA2100(ha) || IS_QLA2200(ha)) 744 if (IS_QLA2100(ha) || IS_QLA2200(ha))
727 return -EPERM; 745 return -EPERM;
728 746
729 if (test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags)) { 747 if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) {
730 qla_printk(KERN_WARNING, ha, 748 qla_printk(KERN_WARNING, ha,
731 "Abort ISP active -- ignoring beacon request.\n"); 749 "Abort ISP active -- ignoring beacon request.\n");
732 return -EBUSY; 750 return -EBUSY;
@@ -736,9 +754,9 @@ qla2x00_beacon_store(struct device *dev, struct device_attribute *attr,
736 return -EINVAL; 754 return -EINVAL;
737 755
738 if (val) 756 if (val)
739 rval = ha->isp_ops->beacon_on(ha); 757 rval = ha->isp_ops->beacon_on(vha);
740 else 758 else
741 rval = ha->isp_ops->beacon_off(ha); 759 rval = ha->isp_ops->beacon_off(vha);
742 760
743 if (rval != QLA_SUCCESS) 761 if (rval != QLA_SUCCESS)
744 count = 0; 762 count = 0;
@@ -750,8 +768,8 @@ static ssize_t
750qla2x00_optrom_bios_version_show(struct device *dev, 768qla2x00_optrom_bios_version_show(struct device *dev,
751 struct device_attribute *attr, char *buf) 769 struct device_attribute *attr, char *buf)
752{ 770{
753 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 771 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
754 772 struct qla_hw_data *ha = vha->hw;
755 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1], 773 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1],
756 ha->bios_revision[0]); 774 ha->bios_revision[0]);
757} 775}
@@ -760,8 +778,8 @@ static ssize_t
760qla2x00_optrom_efi_version_show(struct device *dev, 778qla2x00_optrom_efi_version_show(struct device *dev,
761 struct device_attribute *attr, char *buf) 779 struct device_attribute *attr, char *buf)
762{ 780{
763 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 781 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
764 782 struct qla_hw_data *ha = vha->hw;
765 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1], 783 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1],
766 ha->efi_revision[0]); 784 ha->efi_revision[0]);
767} 785}
@@ -770,8 +788,8 @@ static ssize_t
770qla2x00_optrom_fcode_version_show(struct device *dev, 788qla2x00_optrom_fcode_version_show(struct device *dev,
771 struct device_attribute *attr, char *buf) 789 struct device_attribute *attr, char *buf)
772{ 790{
773 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 791 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
774 792 struct qla_hw_data *ha = vha->hw;
775 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1], 793 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1],
776 ha->fcode_revision[0]); 794 ha->fcode_revision[0]);
777} 795}
@@ -780,8 +798,8 @@ static ssize_t
780qla2x00_optrom_fw_version_show(struct device *dev, 798qla2x00_optrom_fw_version_show(struct device *dev,
781 struct device_attribute *attr, char *buf) 799 struct device_attribute *attr, char *buf)
782{ 800{
783 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 801 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
784 802 struct qla_hw_data *ha = vha->hw;
785 return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n", 803 return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n",
786 ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2], 804 ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2],
787 ha->fw_revision[3]); 805 ha->fw_revision[3]);
@@ -791,8 +809,8 @@ static ssize_t
791qla2x00_total_isp_aborts_show(struct device *dev, 809qla2x00_total_isp_aborts_show(struct device *dev,
792 struct device_attribute *attr, char *buf) 810 struct device_attribute *attr, char *buf)
793{ 811{
794 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 812 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
795 813 struct qla_hw_data *ha = vha->hw;
796 return snprintf(buf, PAGE_SIZE, "%d\n", 814 return snprintf(buf, PAGE_SIZE, "%d\n",
797 ha->qla_stats.total_isp_aborts); 815 ha->qla_stats.total_isp_aborts);
798} 816}
@@ -848,16 +866,17 @@ struct device_attribute *qla2x00_host_attrs[] = {
848static void 866static void
849qla2x00_get_host_port_id(struct Scsi_Host *shost) 867qla2x00_get_host_port_id(struct Scsi_Host *shost)
850{ 868{
851 scsi_qla_host_t *ha = shost_priv(shost); 869 scsi_qla_host_t *vha = shost_priv(shost);
852 870
853 fc_host_port_id(shost) = ha->d_id.b.domain << 16 | 871 fc_host_port_id(shost) = vha->d_id.b.domain << 16 |
854 ha->d_id.b.area << 8 | ha->d_id.b.al_pa; 872 vha->d_id.b.area << 8 | vha->d_id.b.al_pa;
855} 873}
856 874
857static void 875static void
858qla2x00_get_host_speed(struct Scsi_Host *shost) 876qla2x00_get_host_speed(struct Scsi_Host *shost)
859{ 877{
860 scsi_qla_host_t *ha = to_qla_parent(shost_priv(shost)); 878 struct qla_hw_data *ha = ((struct scsi_qla_host *)
879 (shost_priv(shost)))->hw;
861 u32 speed = FC_PORTSPEED_UNKNOWN; 880 u32 speed = FC_PORTSPEED_UNKNOWN;
862 881
863 switch (ha->link_data_rate) { 882 switch (ha->link_data_rate) {
@@ -880,14 +899,14 @@ qla2x00_get_host_speed(struct Scsi_Host *shost)
880static void 899static void
881qla2x00_get_host_port_type(struct Scsi_Host *shost) 900qla2x00_get_host_port_type(struct Scsi_Host *shost)
882{ 901{
883 scsi_qla_host_t *ha = shost_priv(shost); 902 scsi_qla_host_t *vha = shost_priv(shost);
884 uint32_t port_type = FC_PORTTYPE_UNKNOWN; 903 uint32_t port_type = FC_PORTTYPE_UNKNOWN;
885 904
886 if (ha->parent) { 905 if (vha->vp_idx) {
887 fc_host_port_type(shost) = FC_PORTTYPE_NPIV; 906 fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
888 return; 907 return;
889 } 908 }
890 switch (ha->current_topology) { 909 switch (vha->hw->current_topology) {
891 case ISP_CFG_NL: 910 case ISP_CFG_NL:
892 port_type = FC_PORTTYPE_LPORT; 911 port_type = FC_PORTTYPE_LPORT;
893 break; 912 break;
@@ -908,11 +927,11 @@ static void
908qla2x00_get_starget_node_name(struct scsi_target *starget) 927qla2x00_get_starget_node_name(struct scsi_target *starget)
909{ 928{
910 struct Scsi_Host *host = dev_to_shost(starget->dev.parent); 929 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
911 scsi_qla_host_t *ha = shost_priv(host); 930 scsi_qla_host_t *vha = shost_priv(host);
912 fc_port_t *fcport; 931 fc_port_t *fcport;
913 u64 node_name = 0; 932 u64 node_name = 0;
914 933
915 list_for_each_entry(fcport, &ha->fcports, list) { 934 list_for_each_entry(fcport, &vha->vp_fcports, list) {
916 if (fcport->rport && 935 if (fcport->rport &&
917 starget->id == fcport->rport->scsi_target_id) { 936 starget->id == fcport->rport->scsi_target_id) {
918 node_name = wwn_to_u64(fcport->node_name); 937 node_name = wwn_to_u64(fcport->node_name);
@@ -927,11 +946,11 @@ static void
927qla2x00_get_starget_port_name(struct scsi_target *starget) 946qla2x00_get_starget_port_name(struct scsi_target *starget)
928{ 947{
929 struct Scsi_Host *host = dev_to_shost(starget->dev.parent); 948 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
930 scsi_qla_host_t *ha = shost_priv(host); 949 scsi_qla_host_t *vha = shost_priv(host);
931 fc_port_t *fcport; 950 fc_port_t *fcport;
932 u64 port_name = 0; 951 u64 port_name = 0;
933 952
934 list_for_each_entry(fcport, &ha->fcports, list) { 953 list_for_each_entry(fcport, &vha->vp_fcports, list) {
935 if (fcport->rport && 954 if (fcport->rport &&
936 starget->id == fcport->rport->scsi_target_id) { 955 starget->id == fcport->rport->scsi_target_id) {
937 port_name = wwn_to_u64(fcport->port_name); 956 port_name = wwn_to_u64(fcport->port_name);
@@ -946,11 +965,11 @@ static void
946qla2x00_get_starget_port_id(struct scsi_target *starget) 965qla2x00_get_starget_port_id(struct scsi_target *starget)
947{ 966{
948 struct Scsi_Host *host = dev_to_shost(starget->dev.parent); 967 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
949 scsi_qla_host_t *ha = shost_priv(host); 968 scsi_qla_host_t *vha = shost_priv(host);
950 fc_port_t *fcport; 969 fc_port_t *fcport;
951 uint32_t port_id = ~0U; 970 uint32_t port_id = ~0U;
952 971
953 list_for_each_entry(fcport, &ha->fcports, list) { 972 list_for_each_entry(fcport, &vha->vp_fcports, list) {
954 if (fcport->rport && 973 if (fcport->rport &&
955 starget->id == fcport->rport->scsi_target_id) { 974 starget->id == fcport->rport->scsi_target_id) {
956 port_id = fcport->d_id.b.domain << 16 | 975 port_id = fcport->d_id.b.domain << 16 |
@@ -999,9 +1018,9 @@ qla2x00_terminate_rport_io(struct fc_rport *rport)
999 * final cleanup of firmware resources (PCBs and XCBs). 1018 * final cleanup of firmware resources (PCBs and XCBs).
1000 */ 1019 */
1001 if (fcport->loop_id != FC_NO_LOOP_ID) { 1020 if (fcport->loop_id != FC_NO_LOOP_ID) {
1002 fcport->ha->isp_ops->fabric_logout(fcport->ha, fcport->loop_id, 1021 fcport->vha->hw->isp_ops->fabric_logout(fcport->vha,
1003 fcport->d_id.b.domain, fcport->d_id.b.area, 1022 fcport->loop_id, fcport->d_id.b.domain,
1004 fcport->d_id.b.al_pa); 1023 fcport->d_id.b.area, fcport->d_id.b.al_pa);
1005 fcport->loop_id = FC_NO_LOOP_ID; 1024 fcport->loop_id = FC_NO_LOOP_ID;
1006 } 1025 }
1007 1026
@@ -1011,16 +1030,18 @@ qla2x00_terminate_rport_io(struct fc_rport *rport)
1011static int 1030static int
1012qla2x00_issue_lip(struct Scsi_Host *shost) 1031qla2x00_issue_lip(struct Scsi_Host *shost)
1013{ 1032{
1014 scsi_qla_host_t *ha = shost_priv(shost); 1033 scsi_qla_host_t *vha = shost_priv(shost);
1015 1034
1016 qla2x00_loop_reset(ha); 1035 qla2x00_loop_reset(vha);
1017 return 0; 1036 return 0;
1018} 1037}
1019 1038
1020static struct fc_host_statistics * 1039static struct fc_host_statistics *
1021qla2x00_get_fc_host_stats(struct Scsi_Host *shost) 1040qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
1022{ 1041{
1023 scsi_qla_host_t *ha = to_qla_parent(shost_priv(shost)); 1042 scsi_qla_host_t *vha = shost_priv(shost);
1043 struct qla_hw_data *ha = vha->hw;
1044 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
1024 int rval; 1045 int rval;
1025 struct link_statistics *stats; 1046 struct link_statistics *stats;
1026 dma_addr_t stats_dma; 1047 dma_addr_t stats_dma;
@@ -1032,21 +1053,21 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
1032 stats = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &stats_dma); 1053 stats = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &stats_dma);
1033 if (stats == NULL) { 1054 if (stats == NULL) {
1034 DEBUG2_3_11(printk("%s(%ld): Failed to allocate memory.\n", 1055 DEBUG2_3_11(printk("%s(%ld): Failed to allocate memory.\n",
1035 __func__, ha->host_no)); 1056 __func__, base_vha->host_no));
1036 goto done; 1057 goto done;
1037 } 1058 }
1038 memset(stats, 0, DMA_POOL_SIZE); 1059 memset(stats, 0, DMA_POOL_SIZE);
1039 1060
1040 rval = QLA_FUNCTION_FAILED; 1061 rval = QLA_FUNCTION_FAILED;
1041 if (IS_FWI2_CAPABLE(ha)) { 1062 if (IS_FWI2_CAPABLE(ha)) {
1042 rval = qla24xx_get_isp_stats(ha, stats, stats_dma); 1063 rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma);
1043 } else if (atomic_read(&ha->loop_state) == LOOP_READY && 1064 } else if (atomic_read(&base_vha->loop_state) == LOOP_READY &&
1044 !test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) && 1065 !test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) &&
1045 !test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) && 1066 !test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) &&
1046 !ha->dpc_active) { 1067 !ha->dpc_active) {
1047 /* Must be in a 'READY' state for statistics retrieval. */ 1068 /* Must be in a 'READY' state for statistics retrieval. */
1048 rval = qla2x00_get_link_status(ha, ha->loop_id, stats, 1069 rval = qla2x00_get_link_status(base_vha, base_vha->loop_id,
1049 stats_dma); 1070 stats, stats_dma);
1050 } 1071 }
1051 1072
1052 if (rval != QLA_SUCCESS) 1073 if (rval != QLA_SUCCESS)
@@ -1077,29 +1098,29 @@ done:
1077static void 1098static void
1078qla2x00_get_host_symbolic_name(struct Scsi_Host *shost) 1099qla2x00_get_host_symbolic_name(struct Scsi_Host *shost)
1079{ 1100{
1080 scsi_qla_host_t *ha = shost_priv(shost); 1101 scsi_qla_host_t *vha = shost_priv(shost);
1081 1102
1082 qla2x00_get_sym_node_name(ha, fc_host_symbolic_name(shost)); 1103 qla2x00_get_sym_node_name(vha, fc_host_symbolic_name(shost));
1083} 1104}
1084 1105
1085static void 1106static void
1086qla2x00_set_host_system_hostname(struct Scsi_Host *shost) 1107qla2x00_set_host_system_hostname(struct Scsi_Host *shost)
1087{ 1108{
1088 scsi_qla_host_t *ha = shost_priv(shost); 1109 scsi_qla_host_t *vha = shost_priv(shost);
1089 1110
1090 set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags); 1111 set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
1091} 1112}
1092 1113
1093static void 1114static void
1094qla2x00_get_host_fabric_name(struct Scsi_Host *shost) 1115qla2x00_get_host_fabric_name(struct Scsi_Host *shost)
1095{ 1116{
1096 scsi_qla_host_t *ha = shost_priv(shost); 1117 scsi_qla_host_t *vha = shost_priv(shost);
1097 u64 node_name; 1118 u64 node_name;
1098 1119
1099 if (ha->device_flags & SWITCH_FOUND) 1120 if (vha->device_flags & SWITCH_FOUND)
1100 node_name = wwn_to_u64(ha->fabric_node_name); 1121 node_name = wwn_to_u64(vha->fabric_node_name);
1101 else 1122 else
1102 node_name = wwn_to_u64(ha->node_name); 1123 node_name = wwn_to_u64(vha->node_name);
1103 1124
1104 fc_host_fabric_name(shost) = node_name; 1125 fc_host_fabric_name(shost) = node_name;
1105} 1126}
@@ -1107,11 +1128,12 @@ qla2x00_get_host_fabric_name(struct Scsi_Host *shost)
1107static void 1128static void
1108qla2x00_get_host_port_state(struct Scsi_Host *shost) 1129qla2x00_get_host_port_state(struct Scsi_Host *shost)
1109{ 1130{
1110 scsi_qla_host_t *ha = to_qla_parent(shost_priv(shost)); 1131 scsi_qla_host_t *vha = shost_priv(shost);
1132 struct scsi_qla_host *base_vha = pci_get_drvdata(vha->hw->pdev);
1111 1133
1112 if (!ha->flags.online) 1134 if (!base_vha->flags.online)
1113 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; 1135 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
1114 else if (atomic_read(&ha->loop_state) == LOOP_TIMEOUT) 1136 else if (atomic_read(&base_vha->loop_state) == LOOP_TIMEOUT)
1115 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; 1137 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
1116 else 1138 else
1117 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; 1139 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
@@ -1121,8 +1143,8 @@ static int
1121qla24xx_vport_create(struct fc_vport *fc_vport, bool disable) 1143qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
1122{ 1144{
1123 int ret = 0; 1145 int ret = 0;
1124 scsi_qla_host_t *ha = shost_priv(fc_vport->shost); 1146 scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
1125 scsi_qla_host_t *vha; 1147 scsi_qla_host_t *vha = NULL;
1126 1148
1127 ret = qla24xx_vport_create_req_sanity_check(fc_vport); 1149 ret = qla24xx_vport_create_req_sanity_check(fc_vport);
1128 if (ret) { 1150 if (ret) {
@@ -1144,18 +1166,19 @@ qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
1144 atomic_set(&vha->vp_state, VP_FAILED); 1166 atomic_set(&vha->vp_state, VP_FAILED);
1145 1167
1146 /* ready to create vport */ 1168 /* ready to create vport */
1147 qla_printk(KERN_INFO, vha, "VP entry id %d assigned.\n", vha->vp_idx); 1169 qla_printk(KERN_INFO, vha->hw, "VP entry id %d assigned.\n",
1170 vha->vp_idx);
1148 1171
1149 /* initialized vport states */ 1172 /* initialized vport states */
1150 atomic_set(&vha->loop_state, LOOP_DOWN); 1173 atomic_set(&vha->loop_state, LOOP_DOWN);
1151 vha->vp_err_state= VP_ERR_PORTDWN; 1174 vha->vp_err_state= VP_ERR_PORTDWN;
1152 vha->vp_prev_err_state= VP_ERR_UNKWN; 1175 vha->vp_prev_err_state= VP_ERR_UNKWN;
1153 /* Check if physical ha port is Up */ 1176 /* Check if physical ha port is Up */
1154 if (atomic_read(&ha->loop_state) == LOOP_DOWN || 1177 if (atomic_read(&base_vha->loop_state) == LOOP_DOWN ||
1155 atomic_read(&ha->loop_state) == LOOP_DEAD) { 1178 atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
1156 /* Don't retry or attempt login of this virtual port */ 1179 /* Don't retry or attempt login of this virtual port */
1157 DEBUG15(printk ("scsi(%ld): pport loop_state is not UP.\n", 1180 DEBUG15(printk ("scsi(%ld): pport loop_state is not UP.\n",
1158 vha->host_no)); 1181 base_vha->host_no));
1159 atomic_set(&vha->loop_state, LOOP_DEAD); 1182 atomic_set(&vha->loop_state, LOOP_DEAD);
1160 if (!disable) 1183 if (!disable)
1161 fc_vport_set_state(fc_vport, FC_VPORT_LINKDOWN); 1184 fc_vport_set_state(fc_vport, FC_VPORT_LINKDOWN);
@@ -1171,9 +1194,9 @@ qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
1171 fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name); 1194 fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name);
1172 fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name); 1195 fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name);
1173 fc_host_supported_classes(vha->host) = 1196 fc_host_supported_classes(vha->host) =
1174 fc_host_supported_classes(ha->host); 1197 fc_host_supported_classes(base_vha->host);
1175 fc_host_supported_speeds(vha->host) = 1198 fc_host_supported_speeds(vha->host) =
1176 fc_host_supported_speeds(ha->host); 1199 fc_host_supported_speeds(base_vha->host);
1177 1200
1178 qla24xx_vport_disable(fc_vport, disable); 1201 qla24xx_vport_disable(fc_vport, disable);
1179 1202
@@ -1181,8 +1204,6 @@ qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
1181vport_create_failed_2: 1204vport_create_failed_2:
1182 qla24xx_disable_vp(vha); 1205 qla24xx_disable_vp(vha);
1183 qla24xx_deallocate_vp_id(vha); 1206 qla24xx_deallocate_vp_id(vha);
1184 kfree(vha->port_name);
1185 kfree(vha->node_name);
1186 scsi_host_put(vha->host); 1207 scsi_host_put(vha->host);
1187 return FC_VPORT_FAILED; 1208 return FC_VPORT_FAILED;
1188} 1209}
@@ -1191,17 +1212,25 @@ static int
1191qla24xx_vport_delete(struct fc_vport *fc_vport) 1212qla24xx_vport_delete(struct fc_vport *fc_vport)
1192{ 1213{
1193 scsi_qla_host_t *vha = fc_vport->dd_data; 1214 scsi_qla_host_t *vha = fc_vport->dd_data;
1194 scsi_qla_host_t *pha = to_qla_parent(vha); 1215 fc_port_t *fcport, *tfcport;
1195 1216
1196 while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) || 1217 while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) ||
1197 test_bit(FCPORT_UPDATE_NEEDED, &pha->dpc_flags)) 1218 test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags))
1198 msleep(1000); 1219 msleep(1000);
1199 1220
1200 qla24xx_disable_vp(vha); 1221 qla24xx_disable_vp(vha);
1201 qla24xx_deallocate_vp_id(vha);
1202 1222
1203 kfree(vha->node_name); 1223 fc_remove_host(vha->host);
1204 kfree(vha->port_name); 1224
1225 scsi_remove_host(vha->host);
1226
1227 list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) {
1228 list_del(&fcport->list);
1229 kfree(fcport);
1230 fcport = NULL;
1231 }
1232
1233 qla24xx_deallocate_vp_id(vha);
1205 1234
1206 if (vha->timer_active) { 1235 if (vha->timer_active) {
1207 qla2x00_vp_stop_timer(vha); 1236 qla2x00_vp_stop_timer(vha);
@@ -1210,10 +1239,6 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
1210 vha->host_no, vha->vp_idx, vha)); 1239 vha->host_no, vha->vp_idx, vha));
1211 } 1240 }
1212 1241
1213 fc_remove_host(vha->host);
1214
1215 scsi_remove_host(vha->host);
1216
1217 scsi_host_put(vha->host); 1242 scsi_host_put(vha->host);
1218 1243
1219 return 0; 1244 return 0;
@@ -1318,15 +1343,16 @@ struct fc_function_template qla2xxx_transport_vport_functions = {
1318}; 1343};
1319 1344
1320void 1345void
1321qla2x00_init_host_attr(scsi_qla_host_t *ha) 1346qla2x00_init_host_attr(scsi_qla_host_t *vha)
1322{ 1347{
1348 struct qla_hw_data *ha = vha->hw;
1323 u32 speed = FC_PORTSPEED_UNKNOWN; 1349 u32 speed = FC_PORTSPEED_UNKNOWN;
1324 1350
1325 fc_host_node_name(ha->host) = wwn_to_u64(ha->node_name); 1351 fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name);
1326 fc_host_port_name(ha->host) = wwn_to_u64(ha->port_name); 1352 fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name);
1327 fc_host_supported_classes(ha->host) = FC_COS_CLASS3; 1353 fc_host_supported_classes(vha->host) = FC_COS_CLASS3;
1328 fc_host_max_npiv_vports(ha->host) = ha->max_npiv_vports;; 1354 fc_host_max_npiv_vports(vha->host) = ha->max_npiv_vports;
1329 fc_host_npiv_vports_inuse(ha->host) = ha->cur_vport_count; 1355 fc_host_npiv_vports_inuse(vha->host) = ha->cur_vport_count;
1330 1356
1331 if (IS_QLA25XX(ha)) 1357 if (IS_QLA25XX(ha))
1332 speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT | 1358 speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT |
@@ -1338,5 +1364,5 @@ qla2x00_init_host_attr(scsi_qla_host_t *ha)
1338 speed = FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT; 1364 speed = FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
1339 else 1365 else
1340 speed = FC_PORTSPEED_1GBIT; 1366 speed = FC_PORTSPEED_1GBIT;
1341 fc_host_supported_speeds(ha->host) = speed; 1367 fc_host_supported_speeds(vha->host) = speed;
1342} 1368}
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 510ba64bc286..f15f903aec55 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -9,7 +9,7 @@
9#include <linux/delay.h> 9#include <linux/delay.h>
10 10
11static inline void 11static inline void
12qla2xxx_prep_dump(scsi_qla_host_t *ha, struct qla2xxx_fw_dump *fw_dump) 12qla2xxx_prep_dump(struct qla_hw_data *ha, struct qla2xxx_fw_dump *fw_dump)
13{ 13{
14 fw_dump->fw_major_version = htonl(ha->fw_major_version); 14 fw_dump->fw_major_version = htonl(ha->fw_major_version);
15 fw_dump->fw_minor_version = htonl(ha->fw_minor_version); 15 fw_dump->fw_minor_version = htonl(ha->fw_minor_version);
@@ -23,22 +23,25 @@ qla2xxx_prep_dump(scsi_qla_host_t *ha, struct qla2xxx_fw_dump *fw_dump)
23} 23}
24 24
25static inline void * 25static inline void *
26qla2xxx_copy_queues(scsi_qla_host_t *ha, void *ptr) 26qla2xxx_copy_queues(scsi_qla_host_t *vha, void *ptr)
27{ 27{
28 struct req_que *req = vha->hw->req;
29 struct rsp_que *rsp = vha->hw->rsp;
30
28 /* Request queue. */ 31 /* Request queue. */
29 memcpy(ptr, ha->request_ring, ha->request_q_length * 32 memcpy(ptr, req->ring, req->length *
30 sizeof(request_t)); 33 sizeof(request_t));
31 34
32 /* Response queue. */ 35 /* Response queue. */
33 ptr += ha->request_q_length * sizeof(request_t); 36 ptr += req->length * sizeof(request_t);
34 memcpy(ptr, ha->response_ring, ha->response_q_length * 37 memcpy(ptr, rsp->ring, rsp->length *
35 sizeof(response_t)); 38 sizeof(response_t));
36 39
37 return ptr + (ha->response_q_length * sizeof(response_t)); 40 return ptr + (rsp->length * sizeof(response_t));
38} 41}
39 42
40static int 43static int
41qla24xx_dump_ram(scsi_qla_host_t *ha, uint32_t addr, uint32_t *ram, 44qla24xx_dump_ram(struct qla_hw_data *ha, uint32_t addr, uint32_t *ram,
42 uint32_t ram_dwords, void **nxt) 45 uint32_t ram_dwords, void **nxt)
43{ 46{
44 int rval; 47 int rval;
@@ -112,7 +115,7 @@ qla24xx_dump_ram(scsi_qla_host_t *ha, uint32_t addr, uint32_t *ram,
112} 115}
113 116
114static int 117static int
115qla24xx_dump_memory(scsi_qla_host_t *ha, uint32_t *code_ram, 118qla24xx_dump_memory(struct qla_hw_data *ha, uint32_t *code_ram,
116 uint32_t cram_size, void **nxt) 119 uint32_t cram_size, void **nxt)
117{ 120{
118 int rval; 121 int rval;
@@ -163,7 +166,7 @@ qla24xx_pause_risc(struct device_reg_24xx __iomem *reg)
163} 166}
164 167
165static int 168static int
166qla24xx_soft_reset(scsi_qla_host_t *ha) 169qla24xx_soft_reset(struct qla_hw_data *ha)
167{ 170{
168 int rval = QLA_SUCCESS; 171 int rval = QLA_SUCCESS;
169 uint32_t cnt; 172 uint32_t cnt;
@@ -215,8 +218,8 @@ qla24xx_soft_reset(scsi_qla_host_t *ha)
215} 218}
216 219
217static int 220static int
218qla2xxx_dump_ram(scsi_qla_host_t *ha, uint32_t addr, uint16_t *ram, 221qla2xxx_dump_ram(struct qla_hw_data *ha, uint32_t addr, uint16_t *ram,
219 uint32_t ram_words, void **nxt) 222 uint16_t ram_words, void **nxt)
220{ 223{
221 int rval; 224 int rval;
222 uint32_t cnt, stat, timer, words, idx; 225 uint32_t cnt, stat, timer, words, idx;
@@ -314,11 +317,11 @@ qla2xxx_read_window(struct device_reg_2xxx __iomem *reg, uint32_t count,
314 * @hardware_locked: Called with the hardware_lock 317 * @hardware_locked: Called with the hardware_lock
315 */ 318 */
316void 319void
317qla2300_fw_dump(scsi_qla_host_t *ha, int hardware_locked) 320qla2300_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
318{ 321{
319 int rval; 322 int rval;
320 uint32_t cnt; 323 uint32_t cnt;
321 324 struct qla_hw_data *ha = vha->hw;
322 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 325 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
323 uint16_t __iomem *dmp_reg; 326 uint16_t __iomem *dmp_reg;
324 unsigned long flags; 327 unsigned long flags;
@@ -458,7 +461,7 @@ qla2300_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
458 ha->fw_memory_size - 0x11000 + 1, &nxt); 461 ha->fw_memory_size - 0x11000 + 1, &nxt);
459 462
460 if (rval == QLA_SUCCESS) 463 if (rval == QLA_SUCCESS)
461 qla2xxx_copy_queues(ha, nxt); 464 qla2xxx_copy_queues(vha, nxt);
462 465
463 if (rval != QLA_SUCCESS) { 466 if (rval != QLA_SUCCESS) {
464 qla_printk(KERN_WARNING, ha, 467 qla_printk(KERN_WARNING, ha,
@@ -468,7 +471,7 @@ qla2300_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
468 } else { 471 } else {
469 qla_printk(KERN_INFO, ha, 472 qla_printk(KERN_INFO, ha,
470 "Firmware dump saved to temp buffer (%ld/%p).\n", 473 "Firmware dump saved to temp buffer (%ld/%p).\n",
471 ha->host_no, ha->fw_dump); 474 vha->host_no, ha->fw_dump);
472 ha->fw_dumped = 1; 475 ha->fw_dumped = 1;
473 } 476 }
474 477
@@ -483,12 +486,13 @@ qla2300_fw_dump_failed:
483 * @hardware_locked: Called with the hardware_lock 486 * @hardware_locked: Called with the hardware_lock
484 */ 487 */
485void 488void
486qla2100_fw_dump(scsi_qla_host_t *ha, int hardware_locked) 489qla2100_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
487{ 490{
488 int rval; 491 int rval;
489 uint32_t cnt, timer; 492 uint32_t cnt, timer;
490 uint16_t risc_address; 493 uint16_t risc_address;
491 uint16_t mb0, mb2; 494 uint16_t mb0, mb2;
495 struct qla_hw_data *ha = vha->hw;
492 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 496 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
493 uint16_t __iomem *dmp_reg; 497 uint16_t __iomem *dmp_reg;
494 unsigned long flags; 498 unsigned long flags;
@@ -663,7 +667,7 @@ qla2100_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
663 } 667 }
664 668
665 if (rval == QLA_SUCCESS) 669 if (rval == QLA_SUCCESS)
666 qla2xxx_copy_queues(ha, &fw->risc_ram[cnt]); 670 qla2xxx_copy_queues(vha, &fw->risc_ram[cnt]);
667 671
668 if (rval != QLA_SUCCESS) { 672 if (rval != QLA_SUCCESS) {
669 qla_printk(KERN_WARNING, ha, 673 qla_printk(KERN_WARNING, ha,
@@ -673,7 +677,7 @@ qla2100_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
673 } else { 677 } else {
674 qla_printk(KERN_INFO, ha, 678 qla_printk(KERN_INFO, ha,
675 "Firmware dump saved to temp buffer (%ld/%p).\n", 679 "Firmware dump saved to temp buffer (%ld/%p).\n",
676 ha->host_no, ha->fw_dump); 680 vha->host_no, ha->fw_dump);
677 ha->fw_dumped = 1; 681 ha->fw_dumped = 1;
678 } 682 }
679 683
@@ -683,12 +687,12 @@ qla2100_fw_dump_failed:
683} 687}
684 688
685void 689void
686qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked) 690qla24xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
687{ 691{
688 int rval; 692 int rval;
689 uint32_t cnt; 693 uint32_t cnt;
690 uint32_t risc_address; 694 uint32_t risc_address;
691 695 struct qla_hw_data *ha = vha->hw;
692 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 696 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
693 uint32_t __iomem *dmp_reg; 697 uint32_t __iomem *dmp_reg;
694 uint32_t *iter_reg; 698 uint32_t *iter_reg;
@@ -906,7 +910,7 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
906 if (rval != QLA_SUCCESS) 910 if (rval != QLA_SUCCESS)
907 goto qla24xx_fw_dump_failed_0; 911 goto qla24xx_fw_dump_failed_0;
908 912
909 nxt = qla2xxx_copy_queues(ha, nxt); 913 nxt = qla2xxx_copy_queues(vha, nxt);
910 if (ha->eft) 914 if (ha->eft)
911 memcpy(nxt, ha->eft, ntohl(ha->fw_dump->eft_size)); 915 memcpy(nxt, ha->eft, ntohl(ha->fw_dump->eft_size));
912 916
@@ -919,7 +923,7 @@ qla24xx_fw_dump_failed_0:
919 } else { 923 } else {
920 qla_printk(KERN_INFO, ha, 924 qla_printk(KERN_INFO, ha,
921 "Firmware dump saved to temp buffer (%ld/%p).\n", 925 "Firmware dump saved to temp buffer (%ld/%p).\n",
922 ha->host_no, ha->fw_dump); 926 vha->host_no, ha->fw_dump);
923 ha->fw_dumped = 1; 927 ha->fw_dumped = 1;
924 } 928 }
925 929
@@ -929,12 +933,12 @@ qla24xx_fw_dump_failed:
929} 933}
930 934
931void 935void
932qla25xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked) 936qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
933{ 937{
934 int rval; 938 int rval;
935 uint32_t cnt; 939 uint32_t cnt;
936 uint32_t risc_address; 940 uint32_t risc_address;
937 941 struct qla_hw_data *ha = vha->hw;
938 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 942 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
939 uint32_t __iomem *dmp_reg; 943 uint32_t __iomem *dmp_reg;
940 uint32_t *iter_reg; 944 uint32_t *iter_reg;
@@ -1215,7 +1219,7 @@ qla25xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
1215 goto qla25xx_fw_dump_failed_0; 1219 goto qla25xx_fw_dump_failed_0;
1216 1220
1217 /* Fibre Channel Trace Buffer. */ 1221 /* Fibre Channel Trace Buffer. */
1218 nxt = qla2xxx_copy_queues(ha, nxt); 1222 nxt = qla2xxx_copy_queues(vha, nxt);
1219 if (ha->eft) 1223 if (ha->eft)
1220 memcpy(nxt, ha->eft, ntohl(ha->fw_dump->eft_size)); 1224 memcpy(nxt, ha->eft, ntohl(ha->fw_dump->eft_size));
1221 1225
@@ -1248,7 +1252,7 @@ qla25xx_fw_dump_failed_0:
1248 } else { 1252 } else {
1249 qla_printk(KERN_INFO, ha, 1253 qla_printk(KERN_INFO, ha,
1250 "Firmware dump saved to temp buffer (%ld/%p).\n", 1254 "Firmware dump saved to temp buffer (%ld/%p).\n",
1251 ha->host_no, ha->fw_dump); 1255 vha->host_no, ha->fw_dump);
1252 ha->fw_dumped = 1; 1256 ha->fw_dumped = 1;
1253 } 1257 }
1254 1258
@@ -1262,9 +1266,10 @@ qla25xx_fw_dump_failed:
1262/****************************************************************************/ 1266/****************************************************************************/
1263 1267
1264void 1268void
1265qla2x00_dump_regs(scsi_qla_host_t *ha) 1269qla2x00_dump_regs(scsi_qla_host_t *vha)
1266{ 1270{
1267 int i; 1271 int i;
1272 struct qla_hw_data *ha = vha->hw;
1268 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 1273 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1269 struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; 1274 struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24;
1270 uint16_t __iomem *mbx_reg; 1275 uint16_t __iomem *mbx_reg;
@@ -1274,7 +1279,7 @@ qla2x00_dump_regs(scsi_qla_host_t *ha)
1274 1279
1275 printk("Mailbox registers:\n"); 1280 printk("Mailbox registers:\n");
1276 for (i = 0; i < 6; i++) 1281 for (i = 0; i < 6; i++)
1277 printk("scsi(%ld): mbox %d 0x%04x \n", ha->host_no, i, 1282 printk("scsi(%ld): mbox %d 0x%04x \n", vha->host_no, i,
1278 RD_REG_WORD(mbx_reg++)); 1283 RD_REG_WORD(mbx_reg++));
1279} 1284}
1280 1285
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index b97194096d8e..edead2802517 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -185,7 +185,7 @@
185 * SCSI Request Block 185 * SCSI Request Block
186 */ 186 */
187typedef struct srb { 187typedef struct srb {
188 struct scsi_qla_host *ha; /* HA the SP is queued on */ 188 struct scsi_qla_host *vha; /* HA the SP is queued on */
189 struct fc_port *fcport; 189 struct fc_port *fcport;
190 190
191 struct scsi_cmnd *cmd; /* Linux SCSI command pkt */ 191 struct scsi_cmnd *cmd; /* Linux SCSI command pkt */
@@ -1524,7 +1524,7 @@ typedef struct {
1524 */ 1524 */
1525typedef struct fc_port { 1525typedef struct fc_port {
1526 struct list_head list; 1526 struct list_head list;
1527 struct scsi_qla_host *ha; 1527 struct scsi_qla_host *vha;
1528 1528
1529 uint8_t node_name[WWN_SIZE]; 1529 uint8_t node_name[WWN_SIZE];
1530 uint8_t port_name[WWN_SIZE]; 1530 uint8_t port_name[WWN_SIZE];
@@ -1550,7 +1550,6 @@ typedef struct fc_port {
1550 unsigned long last_queue_full; 1550 unsigned long last_queue_full;
1551 unsigned long last_ramp_up; 1551 unsigned long last_ramp_up;
1552 1552
1553 struct list_head vp_fcport;
1554 uint16_t vp_idx; 1553 uint16_t vp_idx;
1555} fc_port_t; 1554} fc_port_t;
1556 1555
@@ -2037,6 +2036,8 @@ typedef struct vport_params {
2037#define VP_RET_CODE_NO_MEM 5 2036#define VP_RET_CODE_NO_MEM 5
2038#define VP_RET_CODE_NOT_FOUND 6 2037#define VP_RET_CODE_NOT_FOUND 6
2039 2038
2039struct qla_hw_data;
2040
2040/* 2041/*
2041 * ISP operations 2042 * ISP operations
2042 */ 2043 */
@@ -2055,8 +2056,8 @@ struct isp_operations {
2055 char * (*fw_version_str) (struct scsi_qla_host *, char *); 2056 char * (*fw_version_str) (struct scsi_qla_host *, char *);
2056 2057
2057 irq_handler_t intr_handler; 2058 irq_handler_t intr_handler;
2058 void (*enable_intrs) (struct scsi_qla_host *); 2059 void (*enable_intrs) (struct qla_hw_data *);
2059 void (*disable_intrs) (struct scsi_qla_host *); 2060 void (*disable_intrs) (struct qla_hw_data *);
2060 2061
2061 int (*abort_command) (struct scsi_qla_host *, srb_t *); 2062 int (*abort_command) (struct scsi_qla_host *, srb_t *);
2062 int (*target_reset) (struct fc_port *, unsigned int); 2063 int (*target_reset) (struct fc_port *, unsigned int);
@@ -2089,6 +2090,7 @@ struct isp_operations {
2089 uint32_t); 2090 uint32_t);
2090 2091
2091 int (*get_flash_version) (struct scsi_qla_host *, void *); 2092 int (*get_flash_version) (struct scsi_qla_host *, void *);
2093 int (*start_scsi) (srb_t *);
2092}; 2094};
2093 2095
2094/* MSI-X Support *************************************************************/ 2096/* MSI-X Support *************************************************************/
@@ -2160,208 +2162,108 @@ struct qla_statistics {
2160 uint64_t output_bytes; 2162 uint64_t output_bytes;
2161}; 2163};
2162 2164
2163/* 2165/* Response queue data structure */
2164 * Linux Host Adapter structure 2166struct rsp_que {
2165 */ 2167 dma_addr_t dma;
2166typedef struct scsi_qla_host { 2168 response_t *ring;
2167 struct list_head list; 2169 response_t *ring_ptr;
2170 uint16_t ring_index;
2171 uint16_t out_ptr;
2172 uint16_t length;
2173 uint16_t options;
2174 uint16_t msix_vector;
2175 uint16_t rid;
2176 struct qla_hw_data *hw;
2177};
2168 2178
2169 /* Commonly used flags and state information. */ 2179/* Request queue data structure */
2170 struct Scsi_Host *host; 2180struct req_que {
2171 struct pci_dev *pdev; 2181 dma_addr_t dma;
2182 request_t *ring;
2183 request_t *ring_ptr;
2184 uint16_t ring_index;
2185 uint16_t in_ptr;
2186 uint16_t cnt;
2187 uint16_t length;
2188 uint16_t options;
2189 uint16_t rid;
2190 uint16_t qos;
2191 uint16_t vp_idx;
2192 struct rsp_que *asso_que;
2193 /* Outstandings ISP commands. */
2194 srb_t *outstanding_cmds[MAX_OUTSTANDING_COMMANDS];
2195 uint32_t current_outstanding_cmd;
2196 int max_q_depth;
2197};
2172 2198
2173 unsigned long host_no; 2199/*
2200 * Qlogic host adapter specific data structure.
2201*/
2202struct qla_hw_data {
2203 struct pci_dev *pdev;
2204 /* SRB cache. */
2205#define SRB_MIN_REQ 128
2206 mempool_t *srb_mempool;
2174 2207
2175 volatile struct { 2208 volatile struct {
2176 uint32_t init_done :1;
2177 uint32_t online :1;
2178 uint32_t mbox_int :1; 2209 uint32_t mbox_int :1;
2179 uint32_t mbox_busy :1; 2210 uint32_t mbox_busy :1;
2180 uint32_t rscn_queue_overflow :1;
2181 uint32_t reset_active :1;
2182
2183 uint32_t management_server_logged_in :1;
2184 uint32_t process_response_queue :1;
2185 2211
2186 uint32_t disable_risc_code_load :1; 2212 uint32_t disable_risc_code_load :1;
2187 uint32_t enable_64bit_addressing :1; 2213 uint32_t enable_64bit_addressing :1;
2188 uint32_t enable_lip_reset :1; 2214 uint32_t enable_lip_reset :1;
2189 uint32_t enable_lip_full_login :1;
2190 uint32_t enable_target_reset :1; 2215 uint32_t enable_target_reset :1;
2216 uint32_t enable_lip_full_login :1;
2191 uint32_t enable_led_scheme :1; 2217 uint32_t enable_led_scheme :1;
2192 uint32_t inta_enabled :1; 2218 uint32_t inta_enabled :1;
2193 uint32_t msi_enabled :1; 2219 uint32_t msi_enabled :1;
2194 uint32_t msix_enabled :1; 2220 uint32_t msix_enabled :1;
2195 uint32_t disable_serdes :1; 2221 uint32_t disable_serdes :1;
2196 uint32_t gpsc_supported :1; 2222 uint32_t gpsc_supported :1;
2197 uint32_t vsan_enabled :1; 2223 uint32_t vsan_enabled :1;
2198 uint32_t npiv_supported :1; 2224 uint32_t npiv_supported :1;
2199 uint32_t fce_enabled :1; 2225 uint32_t fce_enabled :1;
2200 uint32_t hw_event_marker_found :1; 2226 uint32_t hw_event_marker_found:1;
2201 } flags; 2227 } flags;
2202 2228
2203 atomic_t loop_state;
2204#define LOOP_TIMEOUT 1
2205#define LOOP_DOWN 2
2206#define LOOP_UP 3
2207#define LOOP_UPDATE 4
2208#define LOOP_READY 5
2209#define LOOP_DEAD 6
2210
2211 unsigned long dpc_flags;
2212#define RESET_MARKER_NEEDED 0 /* Send marker to ISP. */
2213#define RESET_ACTIVE 1
2214#define ISP_ABORT_NEEDED 2 /* Initiate ISP abort. */
2215#define ABORT_ISP_ACTIVE 3 /* ISP abort in progress. */
2216#define LOOP_RESYNC_NEEDED 4 /* Device Resync needed. */
2217#define LOOP_RESYNC_ACTIVE 5
2218#define LOCAL_LOOP_UPDATE 6 /* Perform a local loop update. */
2219#define RSCN_UPDATE 7 /* Perform an RSCN update. */
2220#define MAILBOX_RETRY 8
2221#define ISP_RESET_NEEDED 9 /* Initiate a ISP reset. */
2222#define FAILOVER_EVENT_NEEDED 10
2223#define FAILOVER_EVENT 11
2224#define FAILOVER_NEEDED 12
2225#define SCSI_RESTART_NEEDED 13 /* Processes SCSI retry queue. */
2226#define PORT_RESTART_NEEDED 14 /* Processes Retry queue. */
2227#define RESTART_QUEUES_NEEDED 15 /* Restarts the Lun queue. */
2228#define ABORT_QUEUES_NEEDED 16
2229#define RELOGIN_NEEDED 17
2230#define LOGIN_RETRY_NEEDED 18 /* Initiate required fabric logins. */
2231#define REGISTER_FC4_NEEDED 19 /* SNS FC4 registration required. */
2232#define ISP_ABORT_RETRY 20 /* ISP aborted. */
2233#define FCPORT_RESCAN_NEEDED 21 /* IO descriptor processing needed */
2234#define IODESC_PROCESS_NEEDED 22 /* IO descriptor processing needed */
2235#define IOCTL_ERROR_RECOVERY 23
2236#define LOOP_RESET_NEEDED 24
2237#define BEACON_BLINK_NEEDED 25
2238#define REGISTER_FDMI_NEEDED 26
2239#define FCPORT_UPDATE_NEEDED 27
2240#define VP_DPC_NEEDED 28 /* wake up for VP dpc handling */
2241#define UNLOADING 29
2242#define NPIV_CONFIG_NEEDED 30
2243
2244 uint32_t device_flags;
2245#define DFLG_LOCAL_DEVICES BIT_0
2246#define DFLG_RETRY_LOCAL_DEVICES BIT_1
2247#define DFLG_FABRIC_DEVICES BIT_2
2248#define SWITCH_FOUND BIT_3
2249#define DFLG_NO_CABLE BIT_4
2250
2251#define PCI_DEVICE_ID_QLOGIC_ISP2532 0x2532
2252#define PCI_DEVICE_ID_QLOGIC_ISP8432 0x8432
2253 uint32_t device_type;
2254#define DT_ISP2100 BIT_0
2255#define DT_ISP2200 BIT_1
2256#define DT_ISP2300 BIT_2
2257#define DT_ISP2312 BIT_3
2258#define DT_ISP2322 BIT_4
2259#define DT_ISP6312 BIT_5
2260#define DT_ISP6322 BIT_6
2261#define DT_ISP2422 BIT_7
2262#define DT_ISP2432 BIT_8
2263#define DT_ISP5422 BIT_9
2264#define DT_ISP5432 BIT_10
2265#define DT_ISP2532 BIT_11
2266#define DT_ISP8432 BIT_12
2267#define DT_ISP_LAST (DT_ISP8432 << 1)
2268
2269#define DT_IIDMA BIT_26
2270#define DT_FWI2 BIT_27
2271#define DT_ZIO_SUPPORTED BIT_28
2272#define DT_OEM_001 BIT_29
2273#define DT_ISP2200A BIT_30
2274#define DT_EXTENDED_IDS BIT_31
2275
2276#define DT_MASK(ha) ((ha)->device_type & (DT_ISP_LAST - 1))
2277#define IS_QLA2100(ha) (DT_MASK(ha) & DT_ISP2100)
2278#define IS_QLA2200(ha) (DT_MASK(ha) & DT_ISP2200)
2279#define IS_QLA2300(ha) (DT_MASK(ha) & DT_ISP2300)
2280#define IS_QLA2312(ha) (DT_MASK(ha) & DT_ISP2312)
2281#define IS_QLA2322(ha) (DT_MASK(ha) & DT_ISP2322)
2282#define IS_QLA6312(ha) (DT_MASK(ha) & DT_ISP6312)
2283#define IS_QLA6322(ha) (DT_MASK(ha) & DT_ISP6322)
2284#define IS_QLA2422(ha) (DT_MASK(ha) & DT_ISP2422)
2285#define IS_QLA2432(ha) (DT_MASK(ha) & DT_ISP2432)
2286#define IS_QLA5422(ha) (DT_MASK(ha) & DT_ISP5422)
2287#define IS_QLA5432(ha) (DT_MASK(ha) & DT_ISP5432)
2288#define IS_QLA2532(ha) (DT_MASK(ha) & DT_ISP2532)
2289#define IS_QLA8432(ha) (DT_MASK(ha) & DT_ISP8432)
2290
2291#define IS_QLA23XX(ha) (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \
2292 IS_QLA6312(ha) || IS_QLA6322(ha))
2293#define IS_QLA24XX(ha) (IS_QLA2422(ha) || IS_QLA2432(ha))
2294#define IS_QLA54XX(ha) (IS_QLA5422(ha) || IS_QLA5432(ha))
2295#define IS_QLA25XX(ha) (IS_QLA2532(ha))
2296#define IS_QLA84XX(ha) (IS_QLA8432(ha))
2297#define IS_QLA24XX_TYPE(ha) (IS_QLA24XX(ha) || IS_QLA54XX(ha) || \
2298 IS_QLA84XX(ha))
2299
2300#define IS_IIDMA_CAPABLE(ha) ((ha)->device_type & DT_IIDMA)
2301#define IS_FWI2_CAPABLE(ha) ((ha)->device_type & DT_FWI2)
2302#define IS_ZIO_SUPPORTED(ha) ((ha)->device_type & DT_ZIO_SUPPORTED)
2303#define IS_OEM_001(ha) ((ha)->device_type & DT_OEM_001)
2304#define HAS_EXTENDED_IDS(ha) ((ha)->device_type & DT_EXTENDED_IDS)
2305
2306 /* SRB cache. */
2307#define SRB_MIN_REQ 128
2308 mempool_t *srb_mempool;
2309
2310 /* This spinlock is used to protect "io transactions", you must 2229 /* This spinlock is used to protect "io transactions", you must
2311 * acquire it before doing any IO to the card, eg with RD_REG*() and 2230 * acquire it before doing any IO to the card, eg with RD_REG*() and
2312 * WRT_REG*() for the duration of your entire commandtransaction. 2231 * WRT_REG*() for the duration of your entire commandtransaction.
2313 * 2232 *
2314 * This spinlock is of lower priority than the io request lock. 2233 * This spinlock is of lower priority than the io request lock.
2315 */ 2234 */
2316
2317 spinlock_t hardware_lock ____cacheline_aligned;
2318 2235
2236 spinlock_t hardware_lock ____cacheline_aligned;
2319 int bars; 2237 int bars;
2320 int mem_only; 2238 int mem_only;
2321 device_reg_t __iomem *iobase; /* Base I/O address */ 2239 device_reg_t __iomem *iobase; /* Base I/O address */
2322 resource_size_t pio_address; 2240 resource_size_t pio_address;
2323#define MIN_IOBASE_LEN 0x100
2324
2325 /* ISP ring lock, rings, and indexes */
2326 dma_addr_t request_dma; /* Physical address. */
2327 request_t *request_ring; /* Base virtual address */
2328 request_t *request_ring_ptr; /* Current address. */
2329 uint16_t req_ring_index; /* Current index. */
2330 uint16_t req_q_cnt; /* Number of available entries. */
2331 uint16_t request_q_length;
2332
2333 dma_addr_t response_dma; /* Physical address. */
2334 response_t *response_ring; /* Base virtual address */
2335 response_t *response_ring_ptr; /* Current address. */
2336 uint16_t rsp_ring_index; /* Current index. */
2337 uint16_t response_q_length;
2338 2241
2339 struct isp_operations *isp_ops; 2242#define MIN_IOBASE_LEN 0x100
2243 struct req_que *req;
2244 struct rsp_que *rsp;
2340 2245
2341 /* Outstandings ISP commands. */ 2246 uint16_t switch_cap;
2342 srb_t *outstanding_cmds[MAX_OUTSTANDING_COMMANDS]; 2247#define FLOGI_SEQ_DEL BIT_8
2343 uint32_t current_outstanding_cmd; 2248#define FLOGI_MID_SUPPORT BIT_10
2344 srb_t *status_srb; /* Status continuation entry. */ 2249#define FLOGI_VSAN_SUPPORT BIT_12
2250#define FLOGI_SP_SUPPORT BIT_13
2251 /* Timeout timers. */
2252 uint8_t loop_down_abort_time; /* port down timer */
2253 atomic_t loop_down_timer; /* loop down timer */
2254 uint8_t link_down_timeout; /* link down timeout */
2255 uint16_t max_loop_id;
2345 2256
2346 /* ISP configuration data. */
2347 uint16_t loop_id; /* Host adapter loop id */
2348 uint16_t switch_cap;
2349#define FLOGI_SEQ_DEL BIT_8
2350#define FLOGI_MID_SUPPORT BIT_10
2351#define FLOGI_VSAN_SUPPORT BIT_12
2352#define FLOGI_SP_SUPPORT BIT_13
2353 uint16_t fb_rev; 2257 uint16_t fb_rev;
2354
2355 port_id_t d_id; /* Host adapter port id */
2356 uint16_t max_public_loop_ids; 2258 uint16_t max_public_loop_ids;
2357 uint16_t min_external_loopid; /* First external loop Id */ 2259 uint16_t min_external_loopid; /* First external loop Id */
2358 2260
2359#define PORT_SPEED_UNKNOWN 0xFFFF 2261#define PORT_SPEED_UNKNOWN 0xFFFF
2360#define PORT_SPEED_1GB 0x00 2262#define PORT_SPEED_1GB 0x00
2361#define PORT_SPEED_2GB 0x01 2263#define PORT_SPEED_2GB 0x01
2362#define PORT_SPEED_4GB 0x03 2264#define PORT_SPEED_4GB 0x03
2363#define PORT_SPEED_8GB 0x04 2265#define PORT_SPEED_8GB 0x04
2364 uint16_t link_data_rate; /* F/W operating speed */ 2266 uint16_t link_data_rate; /* F/W operating speed */
2365 2267
2366 uint8_t current_topology; 2268 uint8_t current_topology;
2367 uint8_t prev_topology; 2269 uint8_t prev_topology;
@@ -2370,15 +2272,69 @@ typedef struct scsi_qla_host {
2370#define ISP_CFG_FL 4 2272#define ISP_CFG_FL 4
2371#define ISP_CFG_F 8 2273#define ISP_CFG_F 8
2372 2274
2373 uint8_t operating_mode; /* F/W operating mode */ 2275 uint8_t operating_mode; /* F/W operating mode */
2374#define LOOP 0 2276#define LOOP 0
2375#define P2P 1 2277#define P2P 1
2376#define LOOP_P2P 2 2278#define LOOP_P2P 2
2377#define P2P_LOOP 3 2279#define P2P_LOOP 3
2378
2379 uint8_t marker_needed;
2380
2381 uint8_t interrupts_on; 2280 uint8_t interrupts_on;
2281 uint32_t isp_abort_cnt;
2282
2283#define PCI_DEVICE_ID_QLOGIC_ISP2532 0x2532
2284#define PCI_DEVICE_ID_QLOGIC_ISP8432 0x8432
2285 uint32_t device_type;
2286#define DT_ISP2100 BIT_0
2287#define DT_ISP2200 BIT_1
2288#define DT_ISP2300 BIT_2
2289#define DT_ISP2312 BIT_3
2290#define DT_ISP2322 BIT_4
2291#define DT_ISP6312 BIT_5
2292#define DT_ISP6322 BIT_6
2293#define DT_ISP2422 BIT_7
2294#define DT_ISP2432 BIT_8
2295#define DT_ISP5422 BIT_9
2296#define DT_ISP5432 BIT_10
2297#define DT_ISP2532 BIT_11
2298#define DT_ISP8432 BIT_12
2299#define DT_ISP_LAST (DT_ISP8432 << 1)
2300
2301#define DT_IIDMA BIT_26
2302#define DT_FWI2 BIT_27
2303#define DT_ZIO_SUPPORTED BIT_28
2304#define DT_OEM_001 BIT_29
2305#define DT_ISP2200A BIT_30
2306#define DT_EXTENDED_IDS BIT_31
2307#define DT_MASK(ha) ((ha)->device_type & (DT_ISP_LAST - 1))
2308#define IS_QLA2100(ha) (DT_MASK(ha) & DT_ISP2100)
2309#define IS_QLA2200(ha) (DT_MASK(ha) & DT_ISP2200)
2310#define IS_QLA2300(ha) (DT_MASK(ha) & DT_ISP2300)
2311#define IS_QLA2312(ha) (DT_MASK(ha) & DT_ISP2312)
2312#define IS_QLA2322(ha) (DT_MASK(ha) & DT_ISP2322)
2313#define IS_QLA6312(ha) (DT_MASK(ha) & DT_ISP6312)
2314#define IS_QLA6322(ha) (DT_MASK(ha) & DT_ISP6322)
2315#define IS_QLA2422(ha) (DT_MASK(ha) & DT_ISP2422)
2316#define IS_QLA2432(ha) (DT_MASK(ha) & DT_ISP2432)
2317#define IS_QLA5422(ha) (DT_MASK(ha) & DT_ISP5422)
2318#define IS_QLA5432(ha) (DT_MASK(ha) & DT_ISP5432)
2319#define IS_QLA2532(ha) (DT_MASK(ha) & DT_ISP2532)
2320#define IS_QLA8432(ha) (DT_MASK(ha) & DT_ISP8432)
2321
2322#define IS_QLA23XX(ha) (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \
2323 IS_QLA6312(ha) || IS_QLA6322(ha))
2324#define IS_QLA24XX(ha) (IS_QLA2422(ha) || IS_QLA2432(ha))
2325#define IS_QLA54XX(ha) (IS_QLA5422(ha) || IS_QLA5432(ha))
2326#define IS_QLA25XX(ha) (IS_QLA2532(ha))
2327#define IS_QLA84XX(ha) (IS_QLA8432(ha))
2328#define IS_QLA24XX_TYPE(ha) (IS_QLA24XX(ha) || IS_QLA54XX(ha) || \
2329 IS_QLA84XX(ha))
2330#define IS_QLA2XXX_MIDTYPE(ha) (IS_QLA24XX(ha) || IS_QLA84XX(ha) || \
2331 IS_QLA25XX(ha))
2332
2333#define IS_IIDMA_CAPABLE(ha) ((ha)->device_type & DT_IIDMA)
2334#define IS_FWI2_CAPABLE(ha) ((ha)->device_type & DT_FWI2)
2335#define IS_ZIO_SUPPORTED(ha) ((ha)->device_type & DT_ZIO_SUPPORTED)
2336#define IS_OEM_001(ha) ((ha)->device_type & DT_OEM_001)
2337#define HAS_EXTENDED_IDS(ha) ((ha)->device_type & DT_EXTENDED_IDS)
2382 2338
2383 /* HBA serial number */ 2339 /* HBA serial number */
2384 uint8_t serial0; 2340 uint8_t serial0;
@@ -2386,8 +2342,8 @@ typedef struct scsi_qla_host {
2386 uint8_t serial2; 2342 uint8_t serial2;
2387 2343
2388 /* NVRAM configuration data */ 2344 /* NVRAM configuration data */
2389#define MAX_NVRAM_SIZE 4096 2345#define MAX_NVRAM_SIZE 4096
2390#define VPD_OFFSET MAX_NVRAM_SIZE / 2 2346#define VPD_OFFSET MAX_NVRAM_SIZE / 2
2391 uint16_t nvram_size; 2347 uint16_t nvram_size;
2392 uint16_t nvram_base; 2348 uint16_t nvram_base;
2393 void *nvram; 2349 void *nvram;
@@ -2401,22 +2357,8 @@ typedef struct scsi_qla_host {
2401 uint16_t r_a_tov; 2357 uint16_t r_a_tov;
2402 int port_down_retry_count; 2358 int port_down_retry_count;
2403 uint8_t mbx_count; 2359 uint8_t mbx_count;
2404 uint16_t last_loop_id;
2405 uint16_t mgmt_svr_loop_id;
2406
2407 uint32_t login_retry_count;
2408 int max_q_depth;
2409
2410 struct list_head work_list;
2411
2412 /* Fibre Channel Device List. */
2413 struct list_head fcports;
2414
2415 /* RSCN queue. */
2416 uint32_t rscn_queue[MAX_RSCN_COUNT];
2417 uint8_t rscn_in_ptr;
2418 uint8_t rscn_out_ptr;
2419 2360
2361 uint32_t login_retry_count;
2420 /* SNS command interfaces. */ 2362 /* SNS command interfaces. */
2421 ms_iocb_entry_t *ms_iocb; 2363 ms_iocb_entry_t *ms_iocb;
2422 dma_addr_t ms_iocb_dma; 2364 dma_addr_t ms_iocb_dma;
@@ -2426,28 +2368,20 @@ typedef struct scsi_qla_host {
2426 struct sns_cmd_pkt *sns_cmd; 2368 struct sns_cmd_pkt *sns_cmd;
2427 dma_addr_t sns_cmd_dma; 2369 dma_addr_t sns_cmd_dma;
2428 2370
2429#define SFP_DEV_SIZE 256 2371#define SFP_DEV_SIZE 256
2430#define SFP_BLOCK_SIZE 64 2372#define SFP_BLOCK_SIZE 64
2431 void *sfp_data; 2373 void *sfp_data;
2432 dma_addr_t sfp_data_dma; 2374 dma_addr_t sfp_data_dma;
2433 2375
2434 struct task_struct *dpc_thread; 2376 struct task_struct *dpc_thread;
2435 uint8_t dpc_active; /* DPC routine is active */ 2377 uint8_t dpc_active; /* DPC routine is active */
2436 2378
2437 /* Timeout timers. */
2438 uint8_t loop_down_abort_time; /* port down timer */
2439 atomic_t loop_down_timer; /* loop down timer */
2440 uint8_t link_down_timeout; /* link down timeout */
2441
2442 uint32_t timer_active;
2443 struct timer_list timer;
2444
2445 dma_addr_t gid_list_dma; 2379 dma_addr_t gid_list_dma;
2446 struct gid_list_info *gid_list; 2380 struct gid_list_info *gid_list;
2447 int gid_list_info_size; 2381 int gid_list_info_size;
2448 2382
2449 /* Small DMA pool allocations -- maximum 256 bytes in length. */ 2383 /* Small DMA pool allocations -- maximum 256 bytes in length. */
2450#define DMA_POOL_SIZE 256 2384#define DMA_POOL_SIZE 256
2451 struct dma_pool *s_dma_pool; 2385 struct dma_pool *s_dma_pool;
2452 2386
2453 dma_addr_t init_cb_dma; 2387 dma_addr_t init_cb_dma;
@@ -2459,17 +2393,17 @@ typedef struct scsi_qla_host {
2459 2393
2460 mbx_cmd_t *mcp; 2394 mbx_cmd_t *mcp;
2461 unsigned long mbx_cmd_flags; 2395 unsigned long mbx_cmd_flags;
2462#define MBX_INTERRUPT 1 2396#define MBX_INTERRUPT 1
2463#define MBX_INTR_WAIT 2 2397#define MBX_INTR_WAIT 2
2464#define MBX_UPDATE_FLASH_ACTIVE 3 2398#define MBX_UPDATE_FLASH_ACTIVE 3
2465 2399
2466 struct mutex vport_lock; /* Virtual port synchronization */ 2400 struct mutex vport_lock; /* Virtual port synchronization */
2467 struct completion mbx_cmd_comp; /* Serialize mbx access */ 2401 struct completion mbx_cmd_comp; /* Serialize mbx access */
2468 struct completion mbx_intr_comp; /* Used for completion notification */ 2402 struct completion mbx_intr_comp; /* Used for completion notification */
2469 2403
2470 uint32_t mbx_flags; 2404 uint32_t mbx_flags;
2471#define MBX_IN_PROGRESS BIT_0 2405#define MBX_IN_PROGRESS BIT_0
2472#define MBX_BUSY BIT_1 /* Got the Access */ 2406#define MBX_BUSY BIT_1 /* Got the Access */
2473#define MBX_SLEEPING_ON_SEM BIT_2 2407#define MBX_SLEEPING_ON_SEM BIT_2
2474#define MBX_POLLING_FOR_COMP BIT_3 2408#define MBX_POLLING_FOR_COMP BIT_3
2475#define MBX_COMPLETED BIT_4 2409#define MBX_COMPLETED BIT_4
@@ -2488,7 +2422,7 @@ typedef struct scsi_qla_host {
2488#define RISC_START_ADDRESS_2300 0x800 2422#define RISC_START_ADDRESS_2300 0x800
2489#define RISC_START_ADDRESS_2400 0x100000 2423#define RISC_START_ADDRESS_2400 0x100000
2490 2424
2491 uint16_t fw_options[16]; /* slots: 1,2,3,10,11 */ 2425 uint16_t fw_options[16]; /* slots: 1,2,3,10,11 */
2492 uint8_t fw_seriallink_options[4]; 2426 uint8_t fw_seriallink_options[4];
2493 uint16_t fw_seriallink_options24[4]; 2427 uint16_t fw_seriallink_options24[4];
2494 2428
@@ -2509,10 +2443,10 @@ typedef struct scsi_qla_host {
2509 uint64_t fce_wr, fce_rd; 2443 uint64_t fce_wr, fce_rd;
2510 struct mutex fce_mutex; 2444 struct mutex fce_mutex;
2511 2445
2446 uint32_t hw_event_start;
2512 uint32_t hw_event_ptr; 2447 uint32_t hw_event_ptr;
2513 uint32_t hw_event_pause_errors; 2448 uint32_t hw_event_pause_errors;
2514 2449
2515 uint8_t host_str[16];
2516 uint32_t pci_attr; 2450 uint32_t pci_attr;
2517 uint16_t chip_revision; 2451 uint16_t chip_revision;
2518 2452
@@ -2523,11 +2457,6 @@ typedef struct scsi_qla_host {
2523 char model_desc[80]; 2457 char model_desc[80];
2524 uint8_t adapter_id[16+1]; 2458 uint8_t adapter_id[16+1];
2525 2459
2526 uint8_t *node_name;
2527 uint8_t *port_name;
2528 uint8_t fabric_node_name[WWN_SIZE];
2529 uint32_t isp_abort_cnt;
2530
2531 /* Option ROM information. */ 2460 /* Option ROM information. */
2532 char *optrom_buffer; 2461 char *optrom_buffer;
2533 uint32_t optrom_size; 2462 uint32_t optrom_size;
@@ -2538,13 +2467,13 @@ typedef struct scsi_qla_host {
2538 uint32_t optrom_region_start; 2467 uint32_t optrom_region_start;
2539 uint32_t optrom_region_size; 2468 uint32_t optrom_region_size;
2540 2469
2541 /* PCI expansion ROM image information. */ 2470/* PCI expansion ROM image information. */
2542#define ROM_CODE_TYPE_BIOS 0 2471#define ROM_CODE_TYPE_BIOS 0
2543#define ROM_CODE_TYPE_FCODE 1 2472#define ROM_CODE_TYPE_FCODE 1
2544#define ROM_CODE_TYPE_EFI 3 2473#define ROM_CODE_TYPE_EFI 3
2545 uint8_t bios_revision[2]; 2474 uint8_t bios_revision[2];
2546 uint8_t efi_revision[2]; 2475 uint8_t efi_revision[2];
2547 uint8_t fcode_revision[16]; 2476 uint8_t fcode_revision[16];
2548 uint32_t fw_revision[4]; 2477 uint32_t fw_revision[4];
2549 2478
2550 uint32_t fdt_wrt_disable; 2479 uint32_t fdt_wrt_disable;
@@ -2553,39 +2482,145 @@ typedef struct scsi_qla_host {
2553 uint32_t fdt_unprotect_sec_cmd; 2482 uint32_t fdt_unprotect_sec_cmd;
2554 uint32_t fdt_protect_sec_cmd; 2483 uint32_t fdt_protect_sec_cmd;
2555 2484
2556 uint32_t flt_region_flt; 2485 uint32_t flt_region_flt;
2557 uint32_t flt_region_fdt; 2486 uint32_t flt_region_fdt;
2558 uint32_t flt_region_boot; 2487 uint32_t flt_region_boot;
2559 uint32_t flt_region_fw; 2488 uint32_t flt_region_fw;
2560 uint32_t flt_region_vpd_nvram; 2489 uint32_t flt_region_vpd_nvram;
2561 uint32_t flt_region_hw_event; 2490 uint32_t flt_region_hw_event;
2562 uint32_t flt_region_npiv_conf; 2491 uint32_t flt_region_npiv_conf;
2563 2492
2564 /* Needed for BEACON */ 2493 /* Needed for BEACON */
2565 uint16_t beacon_blink_led; 2494 uint16_t beacon_blink_led;
2566 uint8_t beacon_color_state; 2495 uint8_t beacon_color_state;
2567#define QLA_LED_GRN_ON 0x01 2496#define QLA_LED_GRN_ON 0x01
2568#define QLA_LED_YLW_ON 0x02 2497#define QLA_LED_YLW_ON 0x02
2569#define QLA_LED_ABR_ON 0x04 2498#define QLA_LED_ABR_ON 0x04
2570#define QLA_LED_ALL_ON 0x07 /* yellow, green, amber. */ 2499#define QLA_LED_ALL_ON 0x07 /* yellow, green, amber. */
2571 /* ISP2322: red, green, amber. */ 2500 /* ISP2322: red, green, amber. */
2572 2501 uint16_t zio_mode;
2573 uint16_t zio_mode; 2502 uint16_t zio_timer;
2574 uint16_t zio_timer;
2575 struct fc_host_statistics fc_host_stat; 2503 struct fc_host_statistics fc_host_stat;
2576 2504
2577 struct qla_msix_entry msix_entries[QLA_MSIX_ENTRIES]; 2505 struct qla_msix_entry msix_entries[QLA_MSIX_ENTRIES];
2578 2506
2579 struct list_head vp_list; /* list of VP */ 2507 struct list_head vp_list; /* list of VP */
2508 unsigned long vp_idx_map[(MAX_MULTI_ID_FABRIC / 8) /
2509 sizeof(unsigned long)];
2510 uint16_t num_vhosts; /* number of vports created */
2511 uint16_t num_vsans; /* number of vsan created */
2512 uint16_t max_npiv_vports; /* 63 or 125 per topoloty */
2513 int cur_vport_count;
2514
2515 struct qla_chip_state_84xx *cs84xx;
2516 struct qla_statistics qla_stats;
2517 struct isp_operations *isp_ops;
2518};
2519
2520/*
2521 * Qlogic scsi host structure
2522 */
2523typedef struct scsi_qla_host {
2524 struct list_head list;
2525 struct list_head vp_fcports; /* list of fcports */
2526 struct list_head work_list;
2527
2528 /* Commonly used flags and state information. */
2529 struct Scsi_Host *host;
2530 unsigned long host_no;
2531 uint8_t host_str[16];
2532
2533 volatile struct {
2534 uint32_t init_done :1;
2535 uint32_t online :1;
2536 uint32_t rscn_queue_overflow :1;
2537 uint32_t reset_active :1;
2538
2539 uint32_t management_server_logged_in :1;
2540 uint32_t process_response_queue :1;
2541 } flags;
2542
2543 atomic_t loop_state;
2544#define LOOP_TIMEOUT 1
2545#define LOOP_DOWN 2
2546#define LOOP_UP 3
2547#define LOOP_UPDATE 4
2548#define LOOP_READY 5
2549#define LOOP_DEAD 6
2550
2551 unsigned long dpc_flags;
2552#define RESET_MARKER_NEEDED 0 /* Send marker to ISP. */
2553#define RESET_ACTIVE 1
2554#define ISP_ABORT_NEEDED 2 /* Initiate ISP abort. */
2555#define ABORT_ISP_ACTIVE 3 /* ISP abort in progress. */
2556#define LOOP_RESYNC_NEEDED 4 /* Device Resync needed. */
2557#define LOOP_RESYNC_ACTIVE 5
2558#define LOCAL_LOOP_UPDATE 6 /* Perform a local loop update. */
2559#define RSCN_UPDATE 7 /* Perform an RSCN update. */
2560#define MAILBOX_RETRY 8
2561#define ISP_RESET_NEEDED 9 /* Initiate a ISP reset. */
2562#define FAILOVER_EVENT_NEEDED 10
2563#define FAILOVER_EVENT 11
2564#define FAILOVER_NEEDED 12
2565#define SCSI_RESTART_NEEDED 13 /* Processes SCSI retry queue. */
2566#define PORT_RESTART_NEEDED 14 /* Processes Retry queue. */
2567#define RESTART_QUEUES_NEEDED 15 /* Restarts the Lun queue. */
2568#define ABORT_QUEUES_NEEDED 16
2569#define RELOGIN_NEEDED 17
2570#define LOGIN_RETRY_NEEDED 18 /* Initiate required fabric logins. */
2571#define REGISTER_FC4_NEEDED 19 /* SNS FC4 registration required. */
2572#define ISP_ABORT_RETRY 20 /* ISP aborted. */
2573#define FCPORT_RESCAN_NEEDED 21 /* IO descriptor processing needed */
2574#define IODESC_PROCESS_NEEDED 22 /* IO descriptor processing needed */
2575#define IOCTL_ERROR_RECOVERY 23
2576#define LOOP_RESET_NEEDED 24
2577#define BEACON_BLINK_NEEDED 25
2578#define REGISTER_FDMI_NEEDED 26
2579#define FCPORT_UPDATE_NEEDED 27
2580#define VP_DPC_NEEDED 28 /* wake up for VP dpc handling */
2581#define UNLOADING 29
2582#define NPIV_CONFIG_NEEDED 30
2583
2584 uint32_t device_flags;
2585#define DFLG_LOCAL_DEVICES BIT_0
2586#define DFLG_RETRY_LOCAL_DEVICES BIT_1
2587#define DFLG_FABRIC_DEVICES BIT_2
2588#define SWITCH_FOUND BIT_3
2589#define DFLG_NO_CABLE BIT_4
2590
2591 srb_t *status_srb; /* Status continuation entry. */
2592
2593 /* ISP configuration data. */
2594 uint16_t loop_id; /* Host adapter loop id */
2595
2596 port_id_t d_id; /* Host adapter port id */
2597 uint8_t marker_needed;
2598 uint16_t mgmt_svr_loop_id;
2599
2600
2601
2602 /* RSCN queue. */
2603 uint32_t rscn_queue[MAX_RSCN_COUNT];
2604 uint8_t rscn_in_ptr;
2605 uint8_t rscn_out_ptr;
2606
2607 /* Timeout timers. */
2608 uint8_t loop_down_abort_time; /* port down timer */
2609 atomic_t loop_down_timer; /* loop down timer */
2610 uint8_t link_down_timeout; /* link down timeout */
2611
2612 uint32_t timer_active;
2613 struct timer_list timer;
2614
2615 uint8_t node_name[WWN_SIZE];
2616 uint8_t port_name[WWN_SIZE];
2617 uint8_t fabric_node_name[WWN_SIZE];
2618 uint32_t vp_abort_cnt;
2619
2580 struct fc_vport *fc_vport; /* holds fc_vport * for each vport */ 2620 struct fc_vport *fc_vport; /* holds fc_vport * for each vport */
2581 unsigned long vp_idx_map[(MAX_MULTI_ID_FABRIC / 8) / sizeof(unsigned long)];
2582 uint16_t num_vhosts; /* number of vports created */
2583 uint16_t num_vsans; /* number of vsan created */
2584 uint16_t vp_idx; /* vport ID */ 2621 uint16_t vp_idx; /* vport ID */
2585 2622
2586 struct scsi_qla_host *parent; /* holds pport */
2587 unsigned long vp_flags; 2623 unsigned long vp_flags;
2588 struct list_head vp_fcports; /* list of fcports */
2589#define VP_IDX_ACQUIRED 0 /* bit no 0 */ 2624#define VP_IDX_ACQUIRED 0 /* bit no 0 */
2590#define VP_CREATE_NEEDED 1 2625#define VP_CREATE_NEEDED 1
2591#define VP_BIND_NEEDED 2 2626#define VP_BIND_NEEDED 2
@@ -2604,11 +2639,7 @@ typedef struct scsi_qla_host {
2604#define VP_ERR_FAB_NORESOURCES 3 2639#define VP_ERR_FAB_NORESOURCES 3
2605#define VP_ERR_FAB_LOGOUT 4 2640#define VP_ERR_FAB_LOGOUT 4
2606#define VP_ERR_ADAP_NORESOURCES 5 2641#define VP_ERR_ADAP_NORESOURCES 5
2607 uint16_t max_npiv_vports; /* 63 or 125 per topoloty */ 2642 struct qla_hw_data *hw;
2608 int cur_vport_count;
2609
2610 struct qla_chip_state_84xx *cs84xx;
2611 struct qla_statistics qla_stats;
2612} scsi_qla_host_t; 2643} scsi_qla_host_t;
2613 2644
2614 2645
diff --git a/drivers/scsi/qla2xxx/qla_dfs.c b/drivers/scsi/qla2xxx/qla_dfs.c
index 561a4411719d..0e366a1b44b3 100644
--- a/drivers/scsi/qla2xxx/qla_dfs.c
+++ b/drivers/scsi/qla2xxx/qla_dfs.c
@@ -15,10 +15,11 @@ static atomic_t qla2x00_dfs_root_count;
15static int 15static int
16qla2x00_dfs_fce_show(struct seq_file *s, void *unused) 16qla2x00_dfs_fce_show(struct seq_file *s, void *unused)
17{ 17{
18 scsi_qla_host_t *ha = s->private; 18 scsi_qla_host_t *vha = s->private;
19 uint32_t cnt; 19 uint32_t cnt;
20 uint32_t *fce; 20 uint32_t *fce;
21 uint64_t fce_start; 21 uint64_t fce_start;
22 struct qla_hw_data *ha = vha->hw;
22 23
23 mutex_lock(&ha->fce_mutex); 24 mutex_lock(&ha->fce_mutex);
24 25
@@ -51,7 +52,8 @@ qla2x00_dfs_fce_show(struct seq_file *s, void *unused)
51static int 52static int
52qla2x00_dfs_fce_open(struct inode *inode, struct file *file) 53qla2x00_dfs_fce_open(struct inode *inode, struct file *file)
53{ 54{
54 scsi_qla_host_t *ha = inode->i_private; 55 scsi_qla_host_t *vha = inode->i_private;
56 struct qla_hw_data *ha = vha->hw;
55 int rval; 57 int rval;
56 58
57 if (!ha->flags.fce_enabled) 59 if (!ha->flags.fce_enabled)
@@ -60,7 +62,7 @@ qla2x00_dfs_fce_open(struct inode *inode, struct file *file)
60 mutex_lock(&ha->fce_mutex); 62 mutex_lock(&ha->fce_mutex);
61 63
62 /* Pause tracing to flush FCE buffers. */ 64 /* Pause tracing to flush FCE buffers. */
63 rval = qla2x00_disable_fce_trace(ha, &ha->fce_wr, &ha->fce_rd); 65 rval = qla2x00_disable_fce_trace(vha, &ha->fce_wr, &ha->fce_rd);
64 if (rval) 66 if (rval)
65 qla_printk(KERN_WARNING, ha, 67 qla_printk(KERN_WARNING, ha,
66 "DebugFS: Unable to disable FCE (%d).\n", rval); 68 "DebugFS: Unable to disable FCE (%d).\n", rval);
@@ -75,7 +77,8 @@ out:
75static int 77static int
76qla2x00_dfs_fce_release(struct inode *inode, struct file *file) 78qla2x00_dfs_fce_release(struct inode *inode, struct file *file)
77{ 79{
78 scsi_qla_host_t *ha = inode->i_private; 80 scsi_qla_host_t *vha = inode->i_private;
81 struct qla_hw_data *ha = vha->hw;
79 int rval; 82 int rval;
80 83
81 if (ha->flags.fce_enabled) 84 if (ha->flags.fce_enabled)
@@ -86,7 +89,7 @@ qla2x00_dfs_fce_release(struct inode *inode, struct file *file)
86 /* Re-enable FCE tracing. */ 89 /* Re-enable FCE tracing. */
87 ha->flags.fce_enabled = 1; 90 ha->flags.fce_enabled = 1;
88 memset(ha->fce, 0, fce_calc_size(ha->fce_bufs)); 91 memset(ha->fce, 0, fce_calc_size(ha->fce_bufs));
89 rval = qla2x00_enable_fce_trace(ha, ha->fce_dma, ha->fce_bufs, 92 rval = qla2x00_enable_fce_trace(vha, ha->fce_dma, ha->fce_bufs,
90 ha->fce_mb, &ha->fce_bufs); 93 ha->fce_mb, &ha->fce_bufs);
91 if (rval) { 94 if (rval) {
92 qla_printk(KERN_WARNING, ha, 95 qla_printk(KERN_WARNING, ha,
@@ -107,8 +110,9 @@ static const struct file_operations dfs_fce_ops = {
107}; 110};
108 111
109int 112int
110qla2x00_dfs_setup(scsi_qla_host_t *ha) 113qla2x00_dfs_setup(scsi_qla_host_t *vha)
111{ 114{
115 struct qla_hw_data *ha = vha->hw;
112 if (!IS_QLA25XX(ha)) 116 if (!IS_QLA25XX(ha))
113 goto out; 117 goto out;
114 if (!ha->fce) 118 if (!ha->fce)
@@ -130,7 +134,7 @@ create_dir:
130 goto create_nodes; 134 goto create_nodes;
131 135
132 mutex_init(&ha->fce_mutex); 136 mutex_init(&ha->fce_mutex);
133 ha->dfs_dir = debugfs_create_dir(ha->host_str, qla2x00_dfs_root); 137 ha->dfs_dir = debugfs_create_dir(vha->host_str, qla2x00_dfs_root);
134 if (!ha->dfs_dir) { 138 if (!ha->dfs_dir) {
135 qla_printk(KERN_NOTICE, ha, 139 qla_printk(KERN_NOTICE, ha,
136 "DebugFS: Unable to create ha directory.\n"); 140 "DebugFS: Unable to create ha directory.\n");
@@ -152,8 +156,9 @@ out:
152} 156}
153 157
154int 158int
155qla2x00_dfs_remove(scsi_qla_host_t *ha) 159qla2x00_dfs_remove(scsi_qla_host_t *vha)
156{ 160{
161 struct qla_hw_data *ha = vha->hw;
157 if (ha->dfs_fce) { 162 if (ha->dfs_fce) {
158 debugfs_remove(ha->dfs_fce); 163 debugfs_remove(ha->dfs_fce);
159 ha->dfs_fce = NULL; 164 ha->dfs_fce = NULL;
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 753dbe6cce6e..c0cc686d6cc3 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -72,7 +72,10 @@ extern int qla2x00_post_hwe_work(struct scsi_qla_host *, uint16_t , uint16_t,
72 uint16_t, uint16_t); 72 uint16_t, uint16_t);
73 73
74extern void qla2x00_abort_fcport_cmds(fc_port_t *); 74extern void qla2x00_abort_fcport_cmds(fc_port_t *);
75 75extern struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *,
76 struct qla_hw_data *);
77extern void qla2x00_free_host(struct scsi_qla_host *);
78extern void qla2x00_relogin(struct scsi_qla_host *);
76/* 79/*
77 * Global Functions in qla_mid.c source file. 80 * Global Functions in qla_mid.c source file.
78 */ 81 */
@@ -105,10 +108,10 @@ extern struct fw_blob *qla2x00_request_firmware(scsi_qla_host_t *);
105 108
106extern int qla2x00_wait_for_hba_online(scsi_qla_host_t *); 109extern int qla2x00_wait_for_hba_online(scsi_qla_host_t *);
107 110
108extern void qla2xxx_wake_dpc(scsi_qla_host_t *); 111extern void qla2xxx_wake_dpc(struct scsi_qla_host *);
109extern void qla2x00_alert_all_vps(scsi_qla_host_t *, uint16_t *); 112extern void qla2x00_alert_all_vps(struct qla_hw_data *, uint16_t *);
110extern void qla2x00_async_event(scsi_qla_host_t *, uint16_t *); 113extern void qla2x00_async_event(scsi_qla_host_t *, uint16_t *);
111extern void qla2x00_vp_abort_isp(scsi_qla_host_t *); 114extern int qla2x00_vp_abort_isp(scsi_qla_host_t *);
112 115
113/* 116/*
114 * Global Function Prototypes in qla_iocb.c source file. 117 * Global Function Prototypes in qla_iocb.c source file.
@@ -267,7 +270,7 @@ extern irqreturn_t qla24xx_intr_handler(int, void *);
267extern void qla2x00_process_response_queue(struct scsi_qla_host *); 270extern void qla2x00_process_response_queue(struct scsi_qla_host *);
268extern void qla24xx_process_response_queue(struct scsi_qla_host *); 271extern void qla24xx_process_response_queue(struct scsi_qla_host *);
269 272
270extern int qla2x00_request_irqs(scsi_qla_host_t *); 273extern int qla2x00_request_irqs(struct qla_hw_data *);
271extern void qla2x00_free_irqs(scsi_qla_host_t *); 274extern void qla2x00_free_irqs(scsi_qla_host_t *);
272 275
273/* 276/*
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index c2a4bfbcb05b..db8de063e1cb 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -22,8 +22,9 @@ static int qla2x00_sns_rnn_id(scsi_qla_host_t *);
22 * Returns a pointer to the @ha's ms_iocb. 22 * Returns a pointer to the @ha's ms_iocb.
23 */ 23 */
24void * 24void *
25qla2x00_prep_ms_iocb(scsi_qla_host_t *ha, uint32_t req_size, uint32_t rsp_size) 25qla2x00_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size)
26{ 26{
27 struct qla_hw_data *ha = vha->hw;
27 ms_iocb_entry_t *ms_pkt; 28 ms_iocb_entry_t *ms_pkt;
28 29
29 ms_pkt = ha->ms_iocb; 30 ms_pkt = ha->ms_iocb;
@@ -59,8 +60,9 @@ qla2x00_prep_ms_iocb(scsi_qla_host_t *ha, uint32_t req_size, uint32_t rsp_size)
59 * Returns a pointer to the @ha's ms_iocb. 60 * Returns a pointer to the @ha's ms_iocb.
60 */ 61 */
61void * 62void *
62qla24xx_prep_ms_iocb(scsi_qla_host_t *ha, uint32_t req_size, uint32_t rsp_size) 63qla24xx_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size)
63{ 64{
65 struct qla_hw_data *ha = vha->hw;
64 struct ct_entry_24xx *ct_pkt; 66 struct ct_entry_24xx *ct_pkt;
65 67
66 ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; 68 ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
@@ -82,7 +84,7 @@ qla24xx_prep_ms_iocb(scsi_qla_host_t *ha, uint32_t req_size, uint32_t rsp_size)
82 ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); 84 ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
83 ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); 85 ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
84 ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; 86 ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
85 ct_pkt->vp_index = ha->vp_idx; 87 ct_pkt->vp_index = vha->vp_idx;
86 88
87 return (ct_pkt); 89 return (ct_pkt);
88} 90}
@@ -110,16 +112,17 @@ qla2x00_prep_ct_req(struct ct_sns_req *ct_req, uint16_t cmd, uint16_t rsp_size)
110} 112}
111 113
112static int 114static int
113qla2x00_chk_ms_status(scsi_qla_host_t *ha, ms_iocb_entry_t *ms_pkt, 115qla2x00_chk_ms_status(scsi_qla_host_t *vha, ms_iocb_entry_t *ms_pkt,
114 struct ct_sns_rsp *ct_rsp, const char *routine) 116 struct ct_sns_rsp *ct_rsp, const char *routine)
115{ 117{
116 int rval; 118 int rval;
117 uint16_t comp_status; 119 uint16_t comp_status;
120 struct qla_hw_data *ha = vha->hw;
118 121
119 rval = QLA_FUNCTION_FAILED; 122 rval = QLA_FUNCTION_FAILED;
120 if (ms_pkt->entry_status != 0) { 123 if (ms_pkt->entry_status != 0) {
121 DEBUG2_3(printk("scsi(%ld): %s failed, error status (%x).\n", 124 DEBUG2_3(printk("scsi(%ld): %s failed, error status (%x).\n",
122 ha->host_no, routine, ms_pkt->entry_status)); 125 vha->host_no, routine, ms_pkt->entry_status));
123 } else { 126 } else {
124 if (IS_FWI2_CAPABLE(ha)) 127 if (IS_FWI2_CAPABLE(ha))
125 comp_status = le16_to_cpu( 128 comp_status = le16_to_cpu(
@@ -133,7 +136,7 @@ qla2x00_chk_ms_status(scsi_qla_host_t *ha, ms_iocb_entry_t *ms_pkt,
133 if (ct_rsp->header.response != 136 if (ct_rsp->header.response !=
134 __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { 137 __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) {
135 DEBUG2_3(printk("scsi(%ld): %s failed, " 138 DEBUG2_3(printk("scsi(%ld): %s failed, "
136 "rejected request:\n", ha->host_no, 139 "rejected request:\n", vha->host_no,
137 routine)); 140 routine));
138 DEBUG2_3(qla2x00_dump_buffer( 141 DEBUG2_3(qla2x00_dump_buffer(
139 (uint8_t *)&ct_rsp->header, 142 (uint8_t *)&ct_rsp->header,
@@ -144,7 +147,7 @@ qla2x00_chk_ms_status(scsi_qla_host_t *ha, ms_iocb_entry_t *ms_pkt,
144 break; 147 break;
145 default: 148 default:
146 DEBUG2_3(printk("scsi(%ld): %s failed, completion " 149 DEBUG2_3(printk("scsi(%ld): %s failed, completion "
147 "status (%x).\n", ha->host_no, routine, 150 "status (%x).\n", vha->host_no, routine,
148 comp_status)); 151 comp_status));
149 break; 152 break;
150 } 153 }
@@ -160,21 +163,21 @@ qla2x00_chk_ms_status(scsi_qla_host_t *ha, ms_iocb_entry_t *ms_pkt,
160 * Returns 0 on success. 163 * Returns 0 on success.
161 */ 164 */
162int 165int
163qla2x00_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport) 166qla2x00_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport)
164{ 167{
165 int rval; 168 int rval;
166 169
167 ms_iocb_entry_t *ms_pkt; 170 ms_iocb_entry_t *ms_pkt;
168 struct ct_sns_req *ct_req; 171 struct ct_sns_req *ct_req;
169 struct ct_sns_rsp *ct_rsp; 172 struct ct_sns_rsp *ct_rsp;
173 struct qla_hw_data *ha = vha->hw;
170 174
171 if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 175 if (IS_QLA2100(ha) || IS_QLA2200(ha))
172 return (qla2x00_sns_ga_nxt(ha, fcport)); 176 return qla2x00_sns_ga_nxt(vha, fcport);
173 }
174 177
175 /* Issue GA_NXT */ 178 /* Issue GA_NXT */
176 /* Prepare common MS IOCB */ 179 /* Prepare common MS IOCB */
177 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, GA_NXT_REQ_SIZE, 180 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GA_NXT_REQ_SIZE,
178 GA_NXT_RSP_SIZE); 181 GA_NXT_RSP_SIZE);
179 182
180 /* Prepare CT request */ 183 /* Prepare CT request */
@@ -188,13 +191,13 @@ qla2x00_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport)
188 ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa; 191 ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa;
189 192
190 /* Execute MS IOCB */ 193 /* Execute MS IOCB */
191 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, 194 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
192 sizeof(ms_iocb_entry_t)); 195 sizeof(ms_iocb_entry_t));
193 if (rval != QLA_SUCCESS) { 196 if (rval != QLA_SUCCESS) {
194 /*EMPTY*/ 197 /*EMPTY*/
195 DEBUG2_3(printk("scsi(%ld): GA_NXT issue IOCB failed (%d).\n", 198 DEBUG2_3(printk("scsi(%ld): GA_NXT issue IOCB failed (%d).\n",
196 ha->host_no, rval)); 199 vha->host_no, rval));
197 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "GA_NXT") != 200 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "GA_NXT") !=
198 QLA_SUCCESS) { 201 QLA_SUCCESS) {
199 rval = QLA_FUNCTION_FAILED; 202 rval = QLA_FUNCTION_FAILED;
200 } else { 203 } else {
@@ -216,7 +219,7 @@ qla2x00_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport)
216 "nn %02x%02x%02x%02x%02x%02x%02x%02x " 219 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
217 "pn %02x%02x%02x%02x%02x%02x%02x%02x " 220 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
218 "portid=%02x%02x%02x.\n", 221 "portid=%02x%02x%02x.\n",
219 ha->host_no, 222 vha->host_no,
220 fcport->node_name[0], fcport->node_name[1], 223 fcport->node_name[0], fcport->node_name[1],
221 fcport->node_name[2], fcport->node_name[3], 224 fcport->node_name[2], fcport->node_name[3],
222 fcport->node_name[4], fcport->node_name[5], 225 fcport->node_name[4], fcport->node_name[5],
@@ -242,7 +245,7 @@ qla2x00_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport)
242 * Returns 0 on success. 245 * Returns 0 on success.
243 */ 246 */
244int 247int
245qla2x00_gid_pt(scsi_qla_host_t *ha, sw_info_t *list) 248qla2x00_gid_pt(scsi_qla_host_t *vha, sw_info_t *list)
246{ 249{
247 int rval; 250 int rval;
248 uint16_t i; 251 uint16_t i;
@@ -252,16 +255,16 @@ qla2x00_gid_pt(scsi_qla_host_t *ha, sw_info_t *list)
252 struct ct_sns_rsp *ct_rsp; 255 struct ct_sns_rsp *ct_rsp;
253 256
254 struct ct_sns_gid_pt_data *gid_data; 257 struct ct_sns_gid_pt_data *gid_data;
258 struct qla_hw_data *ha = vha->hw;
255 259
256 if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 260 if (IS_QLA2100(ha) || IS_QLA2200(ha))
257 return (qla2x00_sns_gid_pt(ha, list)); 261 return qla2x00_sns_gid_pt(vha, list);
258 }
259 262
260 gid_data = NULL; 263 gid_data = NULL;
261 264
262 /* Issue GID_PT */ 265 /* Issue GID_PT */
263 /* Prepare common MS IOCB */ 266 /* Prepare common MS IOCB */
264 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, GID_PT_REQ_SIZE, 267 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GID_PT_REQ_SIZE,
265 GID_PT_RSP_SIZE); 268 GID_PT_RSP_SIZE);
266 269
267 /* Prepare CT request */ 270 /* Prepare CT request */
@@ -273,13 +276,13 @@ qla2x00_gid_pt(scsi_qla_host_t *ha, sw_info_t *list)
273 ct_req->req.gid_pt.port_type = NS_NX_PORT_TYPE; 276 ct_req->req.gid_pt.port_type = NS_NX_PORT_TYPE;
274 277
275 /* Execute MS IOCB */ 278 /* Execute MS IOCB */
276 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, 279 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
277 sizeof(ms_iocb_entry_t)); 280 sizeof(ms_iocb_entry_t));
278 if (rval != QLA_SUCCESS) { 281 if (rval != QLA_SUCCESS) {
279 /*EMPTY*/ 282 /*EMPTY*/
280 DEBUG2_3(printk("scsi(%ld): GID_PT issue IOCB failed (%d).\n", 283 DEBUG2_3(printk("scsi(%ld): GID_PT issue IOCB failed (%d).\n",
281 ha->host_no, rval)); 284 vha->host_no, rval));
282 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "GID_PT") != 285 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "GID_PT") !=
283 QLA_SUCCESS) { 286 QLA_SUCCESS) {
284 rval = QLA_FUNCTION_FAILED; 287 rval = QLA_FUNCTION_FAILED;
285 } else { 288 } else {
@@ -320,7 +323,7 @@ qla2x00_gid_pt(scsi_qla_host_t *ha, sw_info_t *list)
320 * Returns 0 on success. 323 * Returns 0 on success.
321 */ 324 */
322int 325int
323qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list) 326qla2x00_gpn_id(scsi_qla_host_t *vha, sw_info_t *list)
324{ 327{
325 int rval; 328 int rval;
326 uint16_t i; 329 uint16_t i;
@@ -328,15 +331,15 @@ qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list)
328 ms_iocb_entry_t *ms_pkt; 331 ms_iocb_entry_t *ms_pkt;
329 struct ct_sns_req *ct_req; 332 struct ct_sns_req *ct_req;
330 struct ct_sns_rsp *ct_rsp; 333 struct ct_sns_rsp *ct_rsp;
334 struct qla_hw_data *ha = vha->hw;
331 335
332 if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 336 if (IS_QLA2100(ha) || IS_QLA2200(ha))
333 return (qla2x00_sns_gpn_id(ha, list)); 337 return qla2x00_sns_gpn_id(vha, list);
334 }
335 338
336 for (i = 0; i < MAX_FIBRE_DEVICES; i++) { 339 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
337 /* Issue GPN_ID */ 340 /* Issue GPN_ID */
338 /* Prepare common MS IOCB */ 341 /* Prepare common MS IOCB */
339 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, GPN_ID_REQ_SIZE, 342 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GPN_ID_REQ_SIZE,
340 GPN_ID_RSP_SIZE); 343 GPN_ID_RSP_SIZE);
341 344
342 /* Prepare CT request */ 345 /* Prepare CT request */
@@ -350,13 +353,13 @@ qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list)
350 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; 353 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
351 354
352 /* Execute MS IOCB */ 355 /* Execute MS IOCB */
353 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, 356 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
354 sizeof(ms_iocb_entry_t)); 357 sizeof(ms_iocb_entry_t));
355 if (rval != QLA_SUCCESS) { 358 if (rval != QLA_SUCCESS) {
356 /*EMPTY*/ 359 /*EMPTY*/
357 DEBUG2_3(printk("scsi(%ld): GPN_ID issue IOCB failed " 360 DEBUG2_3(printk("scsi(%ld): GPN_ID issue IOCB failed "
358 "(%d).\n", ha->host_no, rval)); 361 "(%d).\n", vha->host_no, rval));
359 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, 362 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
360 "GPN_ID") != QLA_SUCCESS) { 363 "GPN_ID") != QLA_SUCCESS) {
361 rval = QLA_FUNCTION_FAILED; 364 rval = QLA_FUNCTION_FAILED;
362 } else { 365 } else {
@@ -381,23 +384,22 @@ qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list)
381 * Returns 0 on success. 384 * Returns 0 on success.
382 */ 385 */
383int 386int
384qla2x00_gnn_id(scsi_qla_host_t *ha, sw_info_t *list) 387qla2x00_gnn_id(scsi_qla_host_t *vha, sw_info_t *list)
385{ 388{
386 int rval; 389 int rval;
387 uint16_t i; 390 uint16_t i;
388 391 struct qla_hw_data *ha = vha->hw;
389 ms_iocb_entry_t *ms_pkt; 392 ms_iocb_entry_t *ms_pkt;
390 struct ct_sns_req *ct_req; 393 struct ct_sns_req *ct_req;
391 struct ct_sns_rsp *ct_rsp; 394 struct ct_sns_rsp *ct_rsp;
392 395
393 if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 396 if (IS_QLA2100(ha) || IS_QLA2200(ha))
394 return (qla2x00_sns_gnn_id(ha, list)); 397 return qla2x00_sns_gnn_id(vha, list);
395 }
396 398
397 for (i = 0; i < MAX_FIBRE_DEVICES; i++) { 399 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
398 /* Issue GNN_ID */ 400 /* Issue GNN_ID */
399 /* Prepare common MS IOCB */ 401 /* Prepare common MS IOCB */
400 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, GNN_ID_REQ_SIZE, 402 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GNN_ID_REQ_SIZE,
401 GNN_ID_RSP_SIZE); 403 GNN_ID_RSP_SIZE);
402 404
403 /* Prepare CT request */ 405 /* Prepare CT request */
@@ -411,13 +413,13 @@ qla2x00_gnn_id(scsi_qla_host_t *ha, sw_info_t *list)
411 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; 413 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
412 414
413 /* Execute MS IOCB */ 415 /* Execute MS IOCB */
414 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, 416 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
415 sizeof(ms_iocb_entry_t)); 417 sizeof(ms_iocb_entry_t));
416 if (rval != QLA_SUCCESS) { 418 if (rval != QLA_SUCCESS) {
417 /*EMPTY*/ 419 /*EMPTY*/
418 DEBUG2_3(printk("scsi(%ld): GNN_ID issue IOCB failed " 420 DEBUG2_3(printk("scsi(%ld): GNN_ID issue IOCB failed "
419 "(%d).\n", ha->host_no, rval)); 421 "(%d).\n", vha->host_no, rval));
420 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, 422 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
421 "GNN_ID") != QLA_SUCCESS) { 423 "GNN_ID") != QLA_SUCCESS) {
422 rval = QLA_FUNCTION_FAILED; 424 rval = QLA_FUNCTION_FAILED;
423 } else { 425 } else {
@@ -429,7 +431,7 @@ qla2x00_gnn_id(scsi_qla_host_t *ha, sw_info_t *list)
429 "nn %02x%02x%02x%02x%02x%02x%02x%02x " 431 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
430 "pn %02x%02x%02x%02x%02x%02x%02x%02x " 432 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
431 "portid=%02x%02x%02x.\n", 433 "portid=%02x%02x%02x.\n",
432 ha->host_no, 434 vha->host_no,
433 list[i].node_name[0], list[i].node_name[1], 435 list[i].node_name[0], list[i].node_name[1],
434 list[i].node_name[2], list[i].node_name[3], 436 list[i].node_name[2], list[i].node_name[3],
435 list[i].node_name[4], list[i].node_name[5], 437 list[i].node_name[4], list[i].node_name[5],
@@ -457,21 +459,20 @@ qla2x00_gnn_id(scsi_qla_host_t *ha, sw_info_t *list)
457 * Returns 0 on success. 459 * Returns 0 on success.
458 */ 460 */
459int 461int
460qla2x00_rft_id(scsi_qla_host_t *ha) 462qla2x00_rft_id(scsi_qla_host_t *vha)
461{ 463{
462 int rval; 464 int rval;
463 465 struct qla_hw_data *ha = vha->hw;
464 ms_iocb_entry_t *ms_pkt; 466 ms_iocb_entry_t *ms_pkt;
465 struct ct_sns_req *ct_req; 467 struct ct_sns_req *ct_req;
466 struct ct_sns_rsp *ct_rsp; 468 struct ct_sns_rsp *ct_rsp;
467 469
468 if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 470 if (IS_QLA2100(ha) || IS_QLA2200(ha))
469 return (qla2x00_sns_rft_id(ha)); 471 return qla2x00_sns_rft_id(vha);
470 }
471 472
472 /* Issue RFT_ID */ 473 /* Issue RFT_ID */
473 /* Prepare common MS IOCB */ 474 /* Prepare common MS IOCB */
474 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, RFT_ID_REQ_SIZE, 475 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RFT_ID_REQ_SIZE,
475 RFT_ID_RSP_SIZE); 476 RFT_ID_RSP_SIZE);
476 477
477 /* Prepare CT request */ 478 /* Prepare CT request */
@@ -480,25 +481,25 @@ qla2x00_rft_id(scsi_qla_host_t *ha)
480 ct_rsp = &ha->ct_sns->p.rsp; 481 ct_rsp = &ha->ct_sns->p.rsp;
481 482
482 /* Prepare CT arguments -- port_id, FC-4 types */ 483 /* Prepare CT arguments -- port_id, FC-4 types */
483 ct_req->req.rft_id.port_id[0] = ha->d_id.b.domain; 484 ct_req->req.rft_id.port_id[0] = vha->d_id.b.domain;
484 ct_req->req.rft_id.port_id[1] = ha->d_id.b.area; 485 ct_req->req.rft_id.port_id[1] = vha->d_id.b.area;
485 ct_req->req.rft_id.port_id[2] = ha->d_id.b.al_pa; 486 ct_req->req.rft_id.port_id[2] = vha->d_id.b.al_pa;
486 487
487 ct_req->req.rft_id.fc4_types[2] = 0x01; /* FCP-3 */ 488 ct_req->req.rft_id.fc4_types[2] = 0x01; /* FCP-3 */
488 489
489 /* Execute MS IOCB */ 490 /* Execute MS IOCB */
490 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, 491 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
491 sizeof(ms_iocb_entry_t)); 492 sizeof(ms_iocb_entry_t));
492 if (rval != QLA_SUCCESS) { 493 if (rval != QLA_SUCCESS) {
493 /*EMPTY*/ 494 /*EMPTY*/
494 DEBUG2_3(printk("scsi(%ld): RFT_ID issue IOCB failed (%d).\n", 495 DEBUG2_3(printk("scsi(%ld): RFT_ID issue IOCB failed (%d).\n",
495 ha->host_no, rval)); 496 vha->host_no, rval));
496 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RFT_ID") != 497 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RFT_ID") !=
497 QLA_SUCCESS) { 498 QLA_SUCCESS) {
498 rval = QLA_FUNCTION_FAILED; 499 rval = QLA_FUNCTION_FAILED;
499 } else { 500 } else {
500 DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n", 501 DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
501 ha->host_no)); 502 vha->host_no));
502 } 503 }
503 504
504 return (rval); 505 return (rval);
@@ -511,23 +512,23 @@ qla2x00_rft_id(scsi_qla_host_t *ha)
511 * Returns 0 on success. 512 * Returns 0 on success.
512 */ 513 */
513int 514int
514qla2x00_rff_id(scsi_qla_host_t *ha) 515qla2x00_rff_id(scsi_qla_host_t *vha)
515{ 516{
516 int rval; 517 int rval;
517 518 struct qla_hw_data *ha = vha->hw;
518 ms_iocb_entry_t *ms_pkt; 519 ms_iocb_entry_t *ms_pkt;
519 struct ct_sns_req *ct_req; 520 struct ct_sns_req *ct_req;
520 struct ct_sns_rsp *ct_rsp; 521 struct ct_sns_rsp *ct_rsp;
521 522
522 if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 523 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
523 DEBUG2(printk("scsi(%ld): RFF_ID call unsupported on " 524 DEBUG2(printk("scsi(%ld): RFF_ID call unsupported on "
524 "ISP2100/ISP2200.\n", ha->host_no)); 525 "ISP2100/ISP2200.\n", vha->host_no));
525 return (QLA_SUCCESS); 526 return (QLA_SUCCESS);
526 } 527 }
527 528
528 /* Issue RFF_ID */ 529 /* Issue RFF_ID */
529 /* Prepare common MS IOCB */ 530 /* Prepare common MS IOCB */
530 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, RFF_ID_REQ_SIZE, 531 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RFF_ID_REQ_SIZE,
531 RFF_ID_RSP_SIZE); 532 RFF_ID_RSP_SIZE);
532 533
533 /* Prepare CT request */ 534 /* Prepare CT request */
@@ -536,26 +537,26 @@ qla2x00_rff_id(scsi_qla_host_t *ha)
536 ct_rsp = &ha->ct_sns->p.rsp; 537 ct_rsp = &ha->ct_sns->p.rsp;
537 538
538 /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */ 539 /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */
539 ct_req->req.rff_id.port_id[0] = ha->d_id.b.domain; 540 ct_req->req.rff_id.port_id[0] = vha->d_id.b.domain;
540 ct_req->req.rff_id.port_id[1] = ha->d_id.b.area; 541 ct_req->req.rff_id.port_id[1] = vha->d_id.b.area;
541 ct_req->req.rff_id.port_id[2] = ha->d_id.b.al_pa; 542 ct_req->req.rff_id.port_id[2] = vha->d_id.b.al_pa;
542 543
543 ct_req->req.rff_id.fc4_feature = BIT_1; 544 ct_req->req.rff_id.fc4_feature = BIT_1;
544 ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */ 545 ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */
545 546
546 /* Execute MS IOCB */ 547 /* Execute MS IOCB */
547 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, 548 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
548 sizeof(ms_iocb_entry_t)); 549 sizeof(ms_iocb_entry_t));
549 if (rval != QLA_SUCCESS) { 550 if (rval != QLA_SUCCESS) {
550 /*EMPTY*/ 551 /*EMPTY*/
551 DEBUG2_3(printk("scsi(%ld): RFF_ID issue IOCB failed (%d).\n", 552 DEBUG2_3(printk("scsi(%ld): RFF_ID issue IOCB failed (%d).\n",
552 ha->host_no, rval)); 553 vha->host_no, rval));
553 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RFF_ID") != 554 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RFF_ID") !=
554 QLA_SUCCESS) { 555 QLA_SUCCESS) {
555 rval = QLA_FUNCTION_FAILED; 556 rval = QLA_FUNCTION_FAILED;
556 } else { 557 } else {
557 DEBUG2(printk("scsi(%ld): RFF_ID exiting normally.\n", 558 DEBUG2(printk("scsi(%ld): RFF_ID exiting normally.\n",
558 ha->host_no)); 559 vha->host_no));
559 } 560 }
560 561
561 return (rval); 562 return (rval);
@@ -568,21 +569,20 @@ qla2x00_rff_id(scsi_qla_host_t *ha)
568 * Returns 0 on success. 569 * Returns 0 on success.
569 */ 570 */
570int 571int
571qla2x00_rnn_id(scsi_qla_host_t *ha) 572qla2x00_rnn_id(scsi_qla_host_t *vha)
572{ 573{
573 int rval; 574 int rval;
574 575 struct qla_hw_data *ha = vha->hw;
575 ms_iocb_entry_t *ms_pkt; 576 ms_iocb_entry_t *ms_pkt;
576 struct ct_sns_req *ct_req; 577 struct ct_sns_req *ct_req;
577 struct ct_sns_rsp *ct_rsp; 578 struct ct_sns_rsp *ct_rsp;
578 579
579 if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 580 if (IS_QLA2100(ha) || IS_QLA2200(ha))
580 return (qla2x00_sns_rnn_id(ha)); 581 return qla2x00_sns_rnn_id(vha);
581 }
582 582
583 /* Issue RNN_ID */ 583 /* Issue RNN_ID */
584 /* Prepare common MS IOCB */ 584 /* Prepare common MS IOCB */
585 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, RNN_ID_REQ_SIZE, 585 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RNN_ID_REQ_SIZE,
586 RNN_ID_RSP_SIZE); 586 RNN_ID_RSP_SIZE);
587 587
588 /* Prepare CT request */ 588 /* Prepare CT request */
@@ -591,33 +591,34 @@ qla2x00_rnn_id(scsi_qla_host_t *ha)
591 ct_rsp = &ha->ct_sns->p.rsp; 591 ct_rsp = &ha->ct_sns->p.rsp;
592 592
593 /* Prepare CT arguments -- port_id, node_name */ 593 /* Prepare CT arguments -- port_id, node_name */
594 ct_req->req.rnn_id.port_id[0] = ha->d_id.b.domain; 594 ct_req->req.rnn_id.port_id[0] = vha->d_id.b.domain;
595 ct_req->req.rnn_id.port_id[1] = ha->d_id.b.area; 595 ct_req->req.rnn_id.port_id[1] = vha->d_id.b.area;
596 ct_req->req.rnn_id.port_id[2] = ha->d_id.b.al_pa; 596 ct_req->req.rnn_id.port_id[2] = vha->d_id.b.al_pa;
597 597
598 memcpy(ct_req->req.rnn_id.node_name, ha->node_name, WWN_SIZE); 598 memcpy(ct_req->req.rnn_id.node_name, vha->node_name, WWN_SIZE);
599 599
600 /* Execute MS IOCB */ 600 /* Execute MS IOCB */
601 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, 601 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
602 sizeof(ms_iocb_entry_t)); 602 sizeof(ms_iocb_entry_t));
603 if (rval != QLA_SUCCESS) { 603 if (rval != QLA_SUCCESS) {
604 /*EMPTY*/ 604 /*EMPTY*/
605 DEBUG2_3(printk("scsi(%ld): RNN_ID issue IOCB failed (%d).\n", 605 DEBUG2_3(printk("scsi(%ld): RNN_ID issue IOCB failed (%d).\n",
606 ha->host_no, rval)); 606 vha->host_no, rval));
607 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RNN_ID") != 607 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RNN_ID") !=
608 QLA_SUCCESS) { 608 QLA_SUCCESS) {
609 rval = QLA_FUNCTION_FAILED; 609 rval = QLA_FUNCTION_FAILED;
610 } else { 610 } else {
611 DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n", 611 DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
612 ha->host_no)); 612 vha->host_no));
613 } 613 }
614 614
615 return (rval); 615 return (rval);
616} 616}
617 617
618void 618void
619qla2x00_get_sym_node_name(scsi_qla_host_t *ha, uint8_t *snn) 619qla2x00_get_sym_node_name(scsi_qla_host_t *vha, uint8_t *snn)
620{ 620{
621 struct qla_hw_data *ha = vha->hw;
621 sprintf(snn, "%s FW:v%d.%02d.%02d DVR:v%s",ha->model_number, 622 sprintf(snn, "%s FW:v%d.%02d.%02d DVR:v%s",ha->model_number,
622 ha->fw_major_version, ha->fw_minor_version, 623 ha->fw_major_version, ha->fw_minor_version,
623 ha->fw_subminor_version, qla2x00_version_str); 624 ha->fw_subminor_version, qla2x00_version_str);
@@ -630,23 +631,24 @@ qla2x00_get_sym_node_name(scsi_qla_host_t *ha, uint8_t *snn)
630 * Returns 0 on success. 631 * Returns 0 on success.
631 */ 632 */
632int 633int
633qla2x00_rsnn_nn(scsi_qla_host_t *ha) 634qla2x00_rsnn_nn(scsi_qla_host_t *vha)
634{ 635{
635 int rval; 636 int rval;
637 struct qla_hw_data *ha = vha->hw;
636 ms_iocb_entry_t *ms_pkt; 638 ms_iocb_entry_t *ms_pkt;
637 struct ct_sns_req *ct_req; 639 struct ct_sns_req *ct_req;
638 struct ct_sns_rsp *ct_rsp; 640 struct ct_sns_rsp *ct_rsp;
639 641
640 if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 642 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
641 DEBUG2(printk("scsi(%ld): RSNN_ID call unsupported on " 643 DEBUG2(printk("scsi(%ld): RSNN_ID call unsupported on "
642 "ISP2100/ISP2200.\n", ha->host_no)); 644 "ISP2100/ISP2200.\n", vha->host_no));
643 return (QLA_SUCCESS); 645 return (QLA_SUCCESS);
644 } 646 }
645 647
646 /* Issue RSNN_NN */ 648 /* Issue RSNN_NN */
647 /* Prepare common MS IOCB */ 649 /* Prepare common MS IOCB */
648 /* Request size adjusted after CT preparation */ 650 /* Request size adjusted after CT preparation */
649 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, 0, RSNN_NN_RSP_SIZE); 651 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, 0, RSNN_NN_RSP_SIZE);
650 652
651 /* Prepare CT request */ 653 /* Prepare CT request */
652 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD, 654 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD,
@@ -654,10 +656,10 @@ qla2x00_rsnn_nn(scsi_qla_host_t *ha)
654 ct_rsp = &ha->ct_sns->p.rsp; 656 ct_rsp = &ha->ct_sns->p.rsp;
655 657
656 /* Prepare CT arguments -- node_name, symbolic node_name, size */ 658 /* Prepare CT arguments -- node_name, symbolic node_name, size */
657 memcpy(ct_req->req.rsnn_nn.node_name, ha->node_name, WWN_SIZE); 659 memcpy(ct_req->req.rsnn_nn.node_name, vha->node_name, WWN_SIZE);
658 660
659 /* Prepare the Symbolic Node Name */ 661 /* Prepare the Symbolic Node Name */
660 qla2x00_get_sym_node_name(ha, ct_req->req.rsnn_nn.sym_node_name); 662 qla2x00_get_sym_node_name(vha, ct_req->req.rsnn_nn.sym_node_name);
661 663
662 /* Calculate SNN length */ 664 /* Calculate SNN length */
663 ct_req->req.rsnn_nn.name_len = 665 ct_req->req.rsnn_nn.name_len =
@@ -669,18 +671,18 @@ qla2x00_rsnn_nn(scsi_qla_host_t *ha)
669 ms_pkt->dseg_req_length = ms_pkt->req_bytecount; 671 ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
670 672
671 /* Execute MS IOCB */ 673 /* Execute MS IOCB */
672 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, 674 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
673 sizeof(ms_iocb_entry_t)); 675 sizeof(ms_iocb_entry_t));
674 if (rval != QLA_SUCCESS) { 676 if (rval != QLA_SUCCESS) {
675 /*EMPTY*/ 677 /*EMPTY*/
676 DEBUG2_3(printk("scsi(%ld): RSNN_NN issue IOCB failed (%d).\n", 678 DEBUG2_3(printk("scsi(%ld): RSNN_NN issue IOCB failed (%d).\n",
677 ha->host_no, rval)); 679 vha->host_no, rval));
678 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RSNN_NN") != 680 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RSNN_NN") !=
679 QLA_SUCCESS) { 681 QLA_SUCCESS) {
680 rval = QLA_FUNCTION_FAILED; 682 rval = QLA_FUNCTION_FAILED;
681 } else { 683 } else {
682 DEBUG2(printk("scsi(%ld): RSNN_NN exiting normally.\n", 684 DEBUG2(printk("scsi(%ld): RSNN_NN exiting normally.\n",
683 ha->host_no)); 685 vha->host_no));
684 } 686 }
685 687
686 return (rval); 688 return (rval);
@@ -696,11 +698,12 @@ qla2x00_rsnn_nn(scsi_qla_host_t *ha)
696 * Returns a pointer to the @ha's sns_cmd. 698 * Returns a pointer to the @ha's sns_cmd.
697 */ 699 */
698static inline struct sns_cmd_pkt * 700static inline struct sns_cmd_pkt *
699qla2x00_prep_sns_cmd(scsi_qla_host_t *ha, uint16_t cmd, uint16_t scmd_len, 701qla2x00_prep_sns_cmd(scsi_qla_host_t *vha, uint16_t cmd, uint16_t scmd_len,
700 uint16_t data_size) 702 uint16_t data_size)
701{ 703{
702 uint16_t wc; 704 uint16_t wc;
703 struct sns_cmd_pkt *sns_cmd; 705 struct sns_cmd_pkt *sns_cmd;
706 struct qla_hw_data *ha = vha->hw;
704 707
705 sns_cmd = ha->sns_cmd; 708 sns_cmd = ha->sns_cmd;
706 memset(sns_cmd, 0, sizeof(struct sns_cmd_pkt)); 709 memset(sns_cmd, 0, sizeof(struct sns_cmd_pkt));
@@ -726,15 +729,15 @@ qla2x00_prep_sns_cmd(scsi_qla_host_t *ha, uint16_t cmd, uint16_t scmd_len,
726 * Returns 0 on success. 729 * Returns 0 on success.
727 */ 730 */
728static int 731static int
729qla2x00_sns_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport) 732qla2x00_sns_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport)
730{ 733{
731 int rval; 734 int rval;
732 735 struct qla_hw_data *ha = vha->hw;
733 struct sns_cmd_pkt *sns_cmd; 736 struct sns_cmd_pkt *sns_cmd;
734 737
735 /* Issue GA_NXT. */ 738 /* Issue GA_NXT. */
736 /* Prepare SNS command request. */ 739 /* Prepare SNS command request. */
737 sns_cmd = qla2x00_prep_sns_cmd(ha, GA_NXT_CMD, GA_NXT_SNS_SCMD_LEN, 740 sns_cmd = qla2x00_prep_sns_cmd(vha, GA_NXT_CMD, GA_NXT_SNS_SCMD_LEN,
738 GA_NXT_SNS_DATA_SIZE); 741 GA_NXT_SNS_DATA_SIZE);
739 742
740 /* Prepare SNS command arguments -- port_id. */ 743 /* Prepare SNS command arguments -- port_id. */
@@ -743,16 +746,16 @@ qla2x00_sns_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport)
743 sns_cmd->p.cmd.param[2] = fcport->d_id.b.domain; 746 sns_cmd->p.cmd.param[2] = fcport->d_id.b.domain;
744 747
745 /* Execute SNS command. */ 748 /* Execute SNS command. */
746 rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, GA_NXT_SNS_CMD_SIZE / 2, 749 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, GA_NXT_SNS_CMD_SIZE / 2,
747 sizeof(struct sns_cmd_pkt)); 750 sizeof(struct sns_cmd_pkt));
748 if (rval != QLA_SUCCESS) { 751 if (rval != QLA_SUCCESS) {
749 /*EMPTY*/ 752 /*EMPTY*/
750 DEBUG2_3(printk("scsi(%ld): GA_NXT Send SNS failed (%d).\n", 753 DEBUG2_3(printk("scsi(%ld): GA_NXT Send SNS failed (%d).\n",
751 ha->host_no, rval)); 754 vha->host_no, rval));
752 } else if (sns_cmd->p.gan_data[8] != 0x80 || 755 } else if (sns_cmd->p.gan_data[8] != 0x80 ||
753 sns_cmd->p.gan_data[9] != 0x02) { 756 sns_cmd->p.gan_data[9] != 0x02) {
754 DEBUG2_3(printk("scsi(%ld): GA_NXT failed, rejected request, " 757 DEBUG2_3(printk("scsi(%ld): GA_NXT failed, rejected request, "
755 "ga_nxt_rsp:\n", ha->host_no)); 758 "ga_nxt_rsp:\n", vha->host_no));
756 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gan_data, 16)); 759 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gan_data, 16));
757 rval = QLA_FUNCTION_FAILED; 760 rval = QLA_FUNCTION_FAILED;
758 } else { 761 } else {
@@ -772,7 +775,7 @@ qla2x00_sns_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport)
772 "nn %02x%02x%02x%02x%02x%02x%02x%02x " 775 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
773 "pn %02x%02x%02x%02x%02x%02x%02x%02x " 776 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
774 "portid=%02x%02x%02x.\n", 777 "portid=%02x%02x%02x.\n",
775 ha->host_no, 778 vha->host_no,
776 fcport->node_name[0], fcport->node_name[1], 779 fcport->node_name[0], fcport->node_name[1],
777 fcport->node_name[2], fcport->node_name[3], 780 fcport->node_name[2], fcport->node_name[3],
778 fcport->node_name[4], fcport->node_name[5], 781 fcport->node_name[4], fcport->node_name[5],
@@ -800,33 +803,33 @@ qla2x00_sns_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport)
800 * Returns 0 on success. 803 * Returns 0 on success.
801 */ 804 */
802static int 805static int
803qla2x00_sns_gid_pt(scsi_qla_host_t *ha, sw_info_t *list) 806qla2x00_sns_gid_pt(scsi_qla_host_t *vha, sw_info_t *list)
804{ 807{
805 int rval; 808 int rval;
806 809 struct qla_hw_data *ha = vha->hw;
807 uint16_t i; 810 uint16_t i;
808 uint8_t *entry; 811 uint8_t *entry;
809 struct sns_cmd_pkt *sns_cmd; 812 struct sns_cmd_pkt *sns_cmd;
810 813
811 /* Issue GID_PT. */ 814 /* Issue GID_PT. */
812 /* Prepare SNS command request. */ 815 /* Prepare SNS command request. */
813 sns_cmd = qla2x00_prep_sns_cmd(ha, GID_PT_CMD, GID_PT_SNS_SCMD_LEN, 816 sns_cmd = qla2x00_prep_sns_cmd(vha, GID_PT_CMD, GID_PT_SNS_SCMD_LEN,
814 GID_PT_SNS_DATA_SIZE); 817 GID_PT_SNS_DATA_SIZE);
815 818
816 /* Prepare SNS command arguments -- port_type. */ 819 /* Prepare SNS command arguments -- port_type. */
817 sns_cmd->p.cmd.param[0] = NS_NX_PORT_TYPE; 820 sns_cmd->p.cmd.param[0] = NS_NX_PORT_TYPE;
818 821
819 /* Execute SNS command. */ 822 /* Execute SNS command. */
820 rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, GID_PT_SNS_CMD_SIZE / 2, 823 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, GID_PT_SNS_CMD_SIZE / 2,
821 sizeof(struct sns_cmd_pkt)); 824 sizeof(struct sns_cmd_pkt));
822 if (rval != QLA_SUCCESS) { 825 if (rval != QLA_SUCCESS) {
823 /*EMPTY*/ 826 /*EMPTY*/
824 DEBUG2_3(printk("scsi(%ld): GID_PT Send SNS failed (%d).\n", 827 DEBUG2_3(printk("scsi(%ld): GID_PT Send SNS failed (%d).\n",
825 ha->host_no, rval)); 828 vha->host_no, rval));
826 } else if (sns_cmd->p.gid_data[8] != 0x80 || 829 } else if (sns_cmd->p.gid_data[8] != 0x80 ||
827 sns_cmd->p.gid_data[9] != 0x02) { 830 sns_cmd->p.gid_data[9] != 0x02) {
828 DEBUG2_3(printk("scsi(%ld): GID_PT failed, rejected request, " 831 DEBUG2_3(printk("scsi(%ld): GID_PT failed, rejected request, "
829 "gid_rsp:\n", ha->host_no)); 832 "gid_rsp:\n", vha->host_no));
830 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gid_data, 16)); 833 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gid_data, 16));
831 rval = QLA_FUNCTION_FAILED; 834 rval = QLA_FUNCTION_FAILED;
832 } else { 835 } else {
@@ -867,17 +870,17 @@ qla2x00_sns_gid_pt(scsi_qla_host_t *ha, sw_info_t *list)
867 * Returns 0 on success. 870 * Returns 0 on success.
868 */ 871 */
869static int 872static int
870qla2x00_sns_gpn_id(scsi_qla_host_t *ha, sw_info_t *list) 873qla2x00_sns_gpn_id(scsi_qla_host_t *vha, sw_info_t *list)
871{ 874{
872 int rval; 875 int rval;
873 876 struct qla_hw_data *ha = vha->hw;
874 uint16_t i; 877 uint16_t i;
875 struct sns_cmd_pkt *sns_cmd; 878 struct sns_cmd_pkt *sns_cmd;
876 879
877 for (i = 0; i < MAX_FIBRE_DEVICES; i++) { 880 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
878 /* Issue GPN_ID */ 881 /* Issue GPN_ID */
879 /* Prepare SNS command request. */ 882 /* Prepare SNS command request. */
880 sns_cmd = qla2x00_prep_sns_cmd(ha, GPN_ID_CMD, 883 sns_cmd = qla2x00_prep_sns_cmd(vha, GPN_ID_CMD,
881 GPN_ID_SNS_SCMD_LEN, GPN_ID_SNS_DATA_SIZE); 884 GPN_ID_SNS_SCMD_LEN, GPN_ID_SNS_DATA_SIZE);
882 885
883 /* Prepare SNS command arguments -- port_id. */ 886 /* Prepare SNS command arguments -- port_id. */
@@ -886,16 +889,16 @@ qla2x00_sns_gpn_id(scsi_qla_host_t *ha, sw_info_t *list)
886 sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain; 889 sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain;
887 890
888 /* Execute SNS command. */ 891 /* Execute SNS command. */
889 rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, 892 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma,
890 GPN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt)); 893 GPN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt));
891 if (rval != QLA_SUCCESS) { 894 if (rval != QLA_SUCCESS) {
892 /*EMPTY*/ 895 /*EMPTY*/
893 DEBUG2_3(printk("scsi(%ld): GPN_ID Send SNS failed " 896 DEBUG2_3(printk("scsi(%ld): GPN_ID Send SNS failed "
894 "(%d).\n", ha->host_no, rval)); 897 "(%d).\n", vha->host_no, rval));
895 } else if (sns_cmd->p.gpn_data[8] != 0x80 || 898 } else if (sns_cmd->p.gpn_data[8] != 0x80 ||
896 sns_cmd->p.gpn_data[9] != 0x02) { 899 sns_cmd->p.gpn_data[9] != 0x02) {
897 DEBUG2_3(printk("scsi(%ld): GPN_ID failed, rejected " 900 DEBUG2_3(printk("scsi(%ld): GPN_ID failed, rejected "
898 "request, gpn_rsp:\n", ha->host_no)); 901 "request, gpn_rsp:\n", vha->host_no));
899 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gpn_data, 16)); 902 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gpn_data, 16));
900 rval = QLA_FUNCTION_FAILED; 903 rval = QLA_FUNCTION_FAILED;
901 } else { 904 } else {
@@ -922,17 +925,17 @@ qla2x00_sns_gpn_id(scsi_qla_host_t *ha, sw_info_t *list)
922 * Returns 0 on success. 925 * Returns 0 on success.
923 */ 926 */
924static int 927static int
925qla2x00_sns_gnn_id(scsi_qla_host_t *ha, sw_info_t *list) 928qla2x00_sns_gnn_id(scsi_qla_host_t *vha, sw_info_t *list)
926{ 929{
927 int rval; 930 int rval;
928 931 struct qla_hw_data *ha = vha->hw;
929 uint16_t i; 932 uint16_t i;
930 struct sns_cmd_pkt *sns_cmd; 933 struct sns_cmd_pkt *sns_cmd;
931 934
932 for (i = 0; i < MAX_FIBRE_DEVICES; i++) { 935 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
933 /* Issue GNN_ID */ 936 /* Issue GNN_ID */
934 /* Prepare SNS command request. */ 937 /* Prepare SNS command request. */
935 sns_cmd = qla2x00_prep_sns_cmd(ha, GNN_ID_CMD, 938 sns_cmd = qla2x00_prep_sns_cmd(vha, GNN_ID_CMD,
936 GNN_ID_SNS_SCMD_LEN, GNN_ID_SNS_DATA_SIZE); 939 GNN_ID_SNS_SCMD_LEN, GNN_ID_SNS_DATA_SIZE);
937 940
938 /* Prepare SNS command arguments -- port_id. */ 941 /* Prepare SNS command arguments -- port_id. */
@@ -941,16 +944,16 @@ qla2x00_sns_gnn_id(scsi_qla_host_t *ha, sw_info_t *list)
941 sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain; 944 sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain;
942 945
943 /* Execute SNS command. */ 946 /* Execute SNS command. */
944 rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, 947 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma,
945 GNN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt)); 948 GNN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt));
946 if (rval != QLA_SUCCESS) { 949 if (rval != QLA_SUCCESS) {
947 /*EMPTY*/ 950 /*EMPTY*/
948 DEBUG2_3(printk("scsi(%ld): GNN_ID Send SNS failed " 951 DEBUG2_3(printk("scsi(%ld): GNN_ID Send SNS failed "
949 "(%d).\n", ha->host_no, rval)); 952 "(%d).\n", vha->host_no, rval));
950 } else if (sns_cmd->p.gnn_data[8] != 0x80 || 953 } else if (sns_cmd->p.gnn_data[8] != 0x80 ||
951 sns_cmd->p.gnn_data[9] != 0x02) { 954 sns_cmd->p.gnn_data[9] != 0x02) {
952 DEBUG2_3(printk("scsi(%ld): GNN_ID failed, rejected " 955 DEBUG2_3(printk("scsi(%ld): GNN_ID failed, rejected "
953 "request, gnn_rsp:\n", ha->host_no)); 956 "request, gnn_rsp:\n", vha->host_no));
954 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gnn_data, 16)); 957 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gnn_data, 16));
955 rval = QLA_FUNCTION_FAILED; 958 rval = QLA_FUNCTION_FAILED;
956 } else { 959 } else {
@@ -962,7 +965,7 @@ qla2x00_sns_gnn_id(scsi_qla_host_t *ha, sw_info_t *list)
962 "nn %02x%02x%02x%02x%02x%02x%02x%02x " 965 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
963 "pn %02x%02x%02x%02x%02x%02x%02x%02x " 966 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
964 "portid=%02x%02x%02x.\n", 967 "portid=%02x%02x%02x.\n",
965 ha->host_no, 968 vha->host_no,
966 list[i].node_name[0], list[i].node_name[1], 969 list[i].node_name[0], list[i].node_name[1],
967 list[i].node_name[2], list[i].node_name[3], 970 list[i].node_name[2], list[i].node_name[3],
968 list[i].node_name[4], list[i].node_name[5], 971 list[i].node_name[4], list[i].node_name[5],
@@ -992,40 +995,40 @@ qla2x00_sns_gnn_id(scsi_qla_host_t *ha, sw_info_t *list)
992 * Returns 0 on success. 995 * Returns 0 on success.
993 */ 996 */
994static int 997static int
995qla2x00_sns_rft_id(scsi_qla_host_t *ha) 998qla2x00_sns_rft_id(scsi_qla_host_t *vha)
996{ 999{
997 int rval; 1000 int rval;
998 1001 struct qla_hw_data *ha = vha->hw;
999 struct sns_cmd_pkt *sns_cmd; 1002 struct sns_cmd_pkt *sns_cmd;
1000 1003
1001 /* Issue RFT_ID. */ 1004 /* Issue RFT_ID. */
1002 /* Prepare SNS command request. */ 1005 /* Prepare SNS command request. */
1003 sns_cmd = qla2x00_prep_sns_cmd(ha, RFT_ID_CMD, RFT_ID_SNS_SCMD_LEN, 1006 sns_cmd = qla2x00_prep_sns_cmd(vha, RFT_ID_CMD, RFT_ID_SNS_SCMD_LEN,
1004 RFT_ID_SNS_DATA_SIZE); 1007 RFT_ID_SNS_DATA_SIZE);
1005 1008
1006 /* Prepare SNS command arguments -- port_id, FC-4 types */ 1009 /* Prepare SNS command arguments -- port_id, FC-4 types */
1007 sns_cmd->p.cmd.param[0] = ha->d_id.b.al_pa; 1010 sns_cmd->p.cmd.param[0] = vha->d_id.b.al_pa;
1008 sns_cmd->p.cmd.param[1] = ha->d_id.b.area; 1011 sns_cmd->p.cmd.param[1] = vha->d_id.b.area;
1009 sns_cmd->p.cmd.param[2] = ha->d_id.b.domain; 1012 sns_cmd->p.cmd.param[2] = vha->d_id.b.domain;
1010 1013
1011 sns_cmd->p.cmd.param[5] = 0x01; /* FCP-3 */ 1014 sns_cmd->p.cmd.param[5] = 0x01; /* FCP-3 */
1012 1015
1013 /* Execute SNS command. */ 1016 /* Execute SNS command. */
1014 rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, RFT_ID_SNS_CMD_SIZE / 2, 1017 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, RFT_ID_SNS_CMD_SIZE / 2,
1015 sizeof(struct sns_cmd_pkt)); 1018 sizeof(struct sns_cmd_pkt));
1016 if (rval != QLA_SUCCESS) { 1019 if (rval != QLA_SUCCESS) {
1017 /*EMPTY*/ 1020 /*EMPTY*/
1018 DEBUG2_3(printk("scsi(%ld): RFT_ID Send SNS failed (%d).\n", 1021 DEBUG2_3(printk("scsi(%ld): RFT_ID Send SNS failed (%d).\n",
1019 ha->host_no, rval)); 1022 vha->host_no, rval));
1020 } else if (sns_cmd->p.rft_data[8] != 0x80 || 1023 } else if (sns_cmd->p.rft_data[8] != 0x80 ||
1021 sns_cmd->p.rft_data[9] != 0x02) { 1024 sns_cmd->p.rft_data[9] != 0x02) {
1022 DEBUG2_3(printk("scsi(%ld): RFT_ID failed, rejected request, " 1025 DEBUG2_3(printk("scsi(%ld): RFT_ID failed, rejected request, "
1023 "rft_rsp:\n", ha->host_no)); 1026 "rft_rsp:\n", vha->host_no));
1024 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rft_data, 16)); 1027 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rft_data, 16));
1025 rval = QLA_FUNCTION_FAILED; 1028 rval = QLA_FUNCTION_FAILED;
1026 } else { 1029 } else {
1027 DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n", 1030 DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
1028 ha->host_no)); 1031 vha->host_no));
1029 } 1032 }
1030 1033
1031 return (rval); 1034 return (rval);
@@ -1041,47 +1044,47 @@ qla2x00_sns_rft_id(scsi_qla_host_t *ha)
1041 * Returns 0 on success. 1044 * Returns 0 on success.
1042 */ 1045 */
1043static int 1046static int
1044qla2x00_sns_rnn_id(scsi_qla_host_t *ha) 1047qla2x00_sns_rnn_id(scsi_qla_host_t *vha)
1045{ 1048{
1046 int rval; 1049 int rval;
1047 1050 struct qla_hw_data *ha = vha->hw;
1048 struct sns_cmd_pkt *sns_cmd; 1051 struct sns_cmd_pkt *sns_cmd;
1049 1052
1050 /* Issue RNN_ID. */ 1053 /* Issue RNN_ID. */
1051 /* Prepare SNS command request. */ 1054 /* Prepare SNS command request. */
1052 sns_cmd = qla2x00_prep_sns_cmd(ha, RNN_ID_CMD, RNN_ID_SNS_SCMD_LEN, 1055 sns_cmd = qla2x00_prep_sns_cmd(vha, RNN_ID_CMD, RNN_ID_SNS_SCMD_LEN,
1053 RNN_ID_SNS_DATA_SIZE); 1056 RNN_ID_SNS_DATA_SIZE);
1054 1057
1055 /* Prepare SNS command arguments -- port_id, nodename. */ 1058 /* Prepare SNS command arguments -- port_id, nodename. */
1056 sns_cmd->p.cmd.param[0] = ha->d_id.b.al_pa; 1059 sns_cmd->p.cmd.param[0] = vha->d_id.b.al_pa;
1057 sns_cmd->p.cmd.param[1] = ha->d_id.b.area; 1060 sns_cmd->p.cmd.param[1] = vha->d_id.b.area;
1058 sns_cmd->p.cmd.param[2] = ha->d_id.b.domain; 1061 sns_cmd->p.cmd.param[2] = vha->d_id.b.domain;
1059 1062
1060 sns_cmd->p.cmd.param[4] = ha->node_name[7]; 1063 sns_cmd->p.cmd.param[4] = vha->node_name[7];
1061 sns_cmd->p.cmd.param[5] = ha->node_name[6]; 1064 sns_cmd->p.cmd.param[5] = vha->node_name[6];
1062 sns_cmd->p.cmd.param[6] = ha->node_name[5]; 1065 sns_cmd->p.cmd.param[6] = vha->node_name[5];
1063 sns_cmd->p.cmd.param[7] = ha->node_name[4]; 1066 sns_cmd->p.cmd.param[7] = vha->node_name[4];
1064 sns_cmd->p.cmd.param[8] = ha->node_name[3]; 1067 sns_cmd->p.cmd.param[8] = vha->node_name[3];
1065 sns_cmd->p.cmd.param[9] = ha->node_name[2]; 1068 sns_cmd->p.cmd.param[9] = vha->node_name[2];
1066 sns_cmd->p.cmd.param[10] = ha->node_name[1]; 1069 sns_cmd->p.cmd.param[10] = vha->node_name[1];
1067 sns_cmd->p.cmd.param[11] = ha->node_name[0]; 1070 sns_cmd->p.cmd.param[11] = vha->node_name[0];
1068 1071
1069 /* Execute SNS command. */ 1072 /* Execute SNS command. */
1070 rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, RNN_ID_SNS_CMD_SIZE / 2, 1073 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, RNN_ID_SNS_CMD_SIZE / 2,
1071 sizeof(struct sns_cmd_pkt)); 1074 sizeof(struct sns_cmd_pkt));
1072 if (rval != QLA_SUCCESS) { 1075 if (rval != QLA_SUCCESS) {
1073 /*EMPTY*/ 1076 /*EMPTY*/
1074 DEBUG2_3(printk("scsi(%ld): RNN_ID Send SNS failed (%d).\n", 1077 DEBUG2_3(printk("scsi(%ld): RNN_ID Send SNS failed (%d).\n",
1075 ha->host_no, rval)); 1078 vha->host_no, rval));
1076 } else if (sns_cmd->p.rnn_data[8] != 0x80 || 1079 } else if (sns_cmd->p.rnn_data[8] != 0x80 ||
1077 sns_cmd->p.rnn_data[9] != 0x02) { 1080 sns_cmd->p.rnn_data[9] != 0x02) {
1078 DEBUG2_3(printk("scsi(%ld): RNN_ID failed, rejected request, " 1081 DEBUG2_3(printk("scsi(%ld): RNN_ID failed, rejected request, "
1079 "rnn_rsp:\n", ha->host_no)); 1082 "rnn_rsp:\n", vha->host_no));
1080 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rnn_data, 16)); 1083 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rnn_data, 16));
1081 rval = QLA_FUNCTION_FAILED; 1084 rval = QLA_FUNCTION_FAILED;
1082 } else { 1085 } else {
1083 DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n", 1086 DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
1084 ha->host_no)); 1087 vha->host_no));
1085 } 1088 }
1086 1089
1087 return (rval); 1090 return (rval);
@@ -1094,25 +1097,25 @@ qla2x00_sns_rnn_id(scsi_qla_host_t *ha)
1094 * Returns 0 on success. 1097 * Returns 0 on success.
1095 */ 1098 */
1096static int 1099static int
1097qla2x00_mgmt_svr_login(scsi_qla_host_t *ha) 1100qla2x00_mgmt_svr_login(scsi_qla_host_t *vha)
1098{ 1101{
1099 int ret; 1102 int ret;
1100 uint16_t mb[MAILBOX_REGISTER_COUNT]; 1103 uint16_t mb[MAILBOX_REGISTER_COUNT];
1101 1104 struct qla_hw_data *ha = vha->hw;
1102 ret = QLA_SUCCESS; 1105 ret = QLA_SUCCESS;
1103 if (ha->flags.management_server_logged_in) 1106 if (vha->flags.management_server_logged_in)
1104 return ret; 1107 return ret;
1105 1108
1106 ha->isp_ops->fabric_login(ha, ha->mgmt_svr_loop_id, 0xff, 0xff, 0xfa, 1109 ha->isp_ops->fabric_login(vha, vha->mgmt_svr_loop_id, 0xff, 0xff, 0xfa,
1107 mb, BIT_1); 1110 mb, BIT_1);
1108 if (mb[0] != MBS_COMMAND_COMPLETE) { 1111 if (mb[0] != MBS_COMMAND_COMPLETE) {
1109 DEBUG2_13(printk("%s(%ld): Failed MANAGEMENT_SERVER login: " 1112 DEBUG2_13(printk("%s(%ld): Failed MANAGEMENT_SERVER login: "
1110 "loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x\n", 1113 "loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x\n",
1111 __func__, ha->host_no, ha->mgmt_svr_loop_id, mb[0], mb[1], 1114 __func__, vha->host_no, vha->mgmt_svr_loop_id, mb[0], mb[1],
1112 mb[2], mb[6], mb[7])); 1115 mb[2], mb[6], mb[7]));
1113 ret = QLA_FUNCTION_FAILED; 1116 ret = QLA_FUNCTION_FAILED;
1114 } else 1117 } else
1115 ha->flags.management_server_logged_in = 1; 1118 vha->flags.management_server_logged_in = 1;
1116 1119
1117 return ret; 1120 return ret;
1118} 1121}
@@ -1126,17 +1129,17 @@ qla2x00_mgmt_svr_login(scsi_qla_host_t *ha)
1126 * Returns a pointer to the @ha's ms_iocb. 1129 * Returns a pointer to the @ha's ms_iocb.
1127 */ 1130 */
1128void * 1131void *
1129qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size, 1132qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size,
1130 uint32_t rsp_size) 1133 uint32_t rsp_size)
1131{ 1134{
1132 ms_iocb_entry_t *ms_pkt; 1135 ms_iocb_entry_t *ms_pkt;
1133 1136 struct qla_hw_data *ha = vha->hw;
1134 ms_pkt = ha->ms_iocb; 1137 ms_pkt = ha->ms_iocb;
1135 memset(ms_pkt, 0, sizeof(ms_iocb_entry_t)); 1138 memset(ms_pkt, 0, sizeof(ms_iocb_entry_t));
1136 1139
1137 ms_pkt->entry_type = MS_IOCB_TYPE; 1140 ms_pkt->entry_type = MS_IOCB_TYPE;
1138 ms_pkt->entry_count = 1; 1141 ms_pkt->entry_count = 1;
1139 SET_TARGET_ID(ha, ms_pkt->loop_id, ha->mgmt_svr_loop_id); 1142 SET_TARGET_ID(ha, ms_pkt->loop_id, vha->mgmt_svr_loop_id);
1140 ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG); 1143 ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG);
1141 ms_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); 1144 ms_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
1142 ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); 1145 ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
@@ -1164,17 +1167,18 @@ qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size,
1164 * Returns a pointer to the @ha's ms_iocb. 1167 * Returns a pointer to the @ha's ms_iocb.
1165 */ 1168 */
1166void * 1169void *
1167qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size, 1170qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size,
1168 uint32_t rsp_size) 1171 uint32_t rsp_size)
1169{ 1172{
1170 struct ct_entry_24xx *ct_pkt; 1173 struct ct_entry_24xx *ct_pkt;
1174 struct qla_hw_data *ha = vha->hw;
1171 1175
1172 ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; 1176 ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
1173 memset(ct_pkt, 0, sizeof(struct ct_entry_24xx)); 1177 memset(ct_pkt, 0, sizeof(struct ct_entry_24xx));
1174 1178
1175 ct_pkt->entry_type = CT_IOCB_TYPE; 1179 ct_pkt->entry_type = CT_IOCB_TYPE;
1176 ct_pkt->entry_count = 1; 1180 ct_pkt->entry_count = 1;
1177 ct_pkt->nport_handle = cpu_to_le16(ha->mgmt_svr_loop_id); 1181 ct_pkt->nport_handle = cpu_to_le16(vha->mgmt_svr_loop_id);
1178 ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); 1182 ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
1179 ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); 1183 ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
1180 ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1); 1184 ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1);
@@ -1188,14 +1192,15 @@ qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size,
1188 ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); 1192 ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1189 ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); 1193 ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1190 ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; 1194 ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
1191 ct_pkt->vp_index = ha->vp_idx; 1195 ct_pkt->vp_index = vha->vp_idx;
1192 1196
1193 return ct_pkt; 1197 return ct_pkt;
1194} 1198}
1195 1199
1196static inline ms_iocb_entry_t * 1200static inline ms_iocb_entry_t *
1197qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size) 1201qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size)
1198{ 1202{
1203 struct qla_hw_data *ha = vha->hw;
1199 ms_iocb_entry_t *ms_pkt = ha->ms_iocb; 1204 ms_iocb_entry_t *ms_pkt = ha->ms_iocb;
1200 struct ct_entry_24xx *ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; 1205 struct ct_entry_24xx *ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
1201 1206
@@ -1240,7 +1245,7 @@ qla2x00_prep_ct_fdmi_req(struct ct_sns_req *ct_req, uint16_t cmd,
1240 * Returns 0 on success. 1245 * Returns 0 on success.
1241 */ 1246 */
1242static int 1247static int
1243qla2x00_fdmi_rhba(scsi_qla_host_t *ha) 1248qla2x00_fdmi_rhba(scsi_qla_host_t *vha)
1244{ 1249{
1245 int rval, alen; 1250 int rval, alen;
1246 uint32_t size, sn; 1251 uint32_t size, sn;
@@ -1250,11 +1255,12 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1250 struct ct_sns_rsp *ct_rsp; 1255 struct ct_sns_rsp *ct_rsp;
1251 uint8_t *entries; 1256 uint8_t *entries;
1252 struct ct_fdmi_hba_attr *eiter; 1257 struct ct_fdmi_hba_attr *eiter;
1258 struct qla_hw_data *ha = vha->hw;
1253 1259
1254 /* Issue RHBA */ 1260 /* Issue RHBA */
1255 /* Prepare common MS IOCB */ 1261 /* Prepare common MS IOCB */
1256 /* Request size adjusted after CT preparation */ 1262 /* Request size adjusted after CT preparation */
1257 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(ha, 0, RHBA_RSP_SIZE); 1263 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RHBA_RSP_SIZE);
1258 1264
1259 /* Prepare CT request */ 1265 /* Prepare CT request */
1260 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD, 1266 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD,
@@ -1262,9 +1268,9 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1262 ct_rsp = &ha->ct_sns->p.rsp; 1268 ct_rsp = &ha->ct_sns->p.rsp;
1263 1269
1264 /* Prepare FDMI command arguments -- attribute block, attributes. */ 1270 /* Prepare FDMI command arguments -- attribute block, attributes. */
1265 memcpy(ct_req->req.rhba.hba_identifier, ha->port_name, WWN_SIZE); 1271 memcpy(ct_req->req.rhba.hba_identifier, vha->port_name, WWN_SIZE);
1266 ct_req->req.rhba.entry_count = __constant_cpu_to_be32(1); 1272 ct_req->req.rhba.entry_count = __constant_cpu_to_be32(1);
1267 memcpy(ct_req->req.rhba.port_name, ha->port_name, WWN_SIZE); 1273 memcpy(ct_req->req.rhba.port_name, vha->port_name, WWN_SIZE);
1268 size = 2 * WWN_SIZE + 4 + 4; 1274 size = 2 * WWN_SIZE + 4 + 4;
1269 1275
1270 /* Attributes */ 1276 /* Attributes */
@@ -1276,11 +1282,11 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1276 eiter = (struct ct_fdmi_hba_attr *) (entries + size); 1282 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1277 eiter->type = __constant_cpu_to_be16(FDMI_HBA_NODE_NAME); 1283 eiter->type = __constant_cpu_to_be16(FDMI_HBA_NODE_NAME);
1278 eiter->len = __constant_cpu_to_be16(4 + WWN_SIZE); 1284 eiter->len = __constant_cpu_to_be16(4 + WWN_SIZE);
1279 memcpy(eiter->a.node_name, ha->node_name, WWN_SIZE); 1285 memcpy(eiter->a.node_name, vha->node_name, WWN_SIZE);
1280 size += 4 + WWN_SIZE; 1286 size += 4 + WWN_SIZE;
1281 1287
1282 DEBUG13(printk("%s(%ld): NODENAME=%02x%02x%02x%02x%02x%02x%02x%02x.\n", 1288 DEBUG13(printk("%s(%ld): NODENAME=%02x%02x%02x%02x%02x%02x%02x%02x.\n",
1283 __func__, ha->host_no, 1289 __func__, vha->host_no,
1284 eiter->a.node_name[0], eiter->a.node_name[1], eiter->a.node_name[2], 1290 eiter->a.node_name[0], eiter->a.node_name[1], eiter->a.node_name[2],
1285 eiter->a.node_name[3], eiter->a.node_name[4], eiter->a.node_name[5], 1291 eiter->a.node_name[3], eiter->a.node_name[4], eiter->a.node_name[5],
1286 eiter->a.node_name[6], eiter->a.node_name[7])); 1292 eiter->a.node_name[6], eiter->a.node_name[7]));
@@ -1294,7 +1300,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1294 eiter->len = cpu_to_be16(4 + alen); 1300 eiter->len = cpu_to_be16(4 + alen);
1295 size += 4 + alen; 1301 size += 4 + alen;
1296 1302
1297 DEBUG13(printk("%s(%ld): MANUFACTURER=%s.\n", __func__, ha->host_no, 1303 DEBUG13(printk("%s(%ld): MANUFACTURER=%s.\n", __func__, vha->host_no,
1298 eiter->a.manufacturer)); 1304 eiter->a.manufacturer));
1299 1305
1300 /* Serial number. */ 1306 /* Serial number. */
@@ -1307,7 +1313,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1307 eiter->len = cpu_to_be16(4 + alen); 1313 eiter->len = cpu_to_be16(4 + alen);
1308 size += 4 + alen; 1314 size += 4 + alen;
1309 1315
1310 DEBUG13(printk("%s(%ld): SERIALNO=%s.\n", __func__, ha->host_no, 1316 DEBUG13(printk("%s(%ld): SERIALNO=%s.\n", __func__, vha->host_no,
1311 eiter->a.serial_num)); 1317 eiter->a.serial_num));
1312 1318
1313 /* Model name. */ 1319 /* Model name. */
@@ -1319,7 +1325,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1319 eiter->len = cpu_to_be16(4 + alen); 1325 eiter->len = cpu_to_be16(4 + alen);
1320 size += 4 + alen; 1326 size += 4 + alen;
1321 1327
1322 DEBUG13(printk("%s(%ld): MODEL_NAME=%s.\n", __func__, ha->host_no, 1328 DEBUG13(printk("%s(%ld): MODEL_NAME=%s.\n", __func__, vha->host_no,
1323 eiter->a.model)); 1329 eiter->a.model));
1324 1330
1325 /* Model description. */ 1331 /* Model description. */
@@ -1332,7 +1338,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1332 eiter->len = cpu_to_be16(4 + alen); 1338 eiter->len = cpu_to_be16(4 + alen);
1333 size += 4 + alen; 1339 size += 4 + alen;
1334 1340
1335 DEBUG13(printk("%s(%ld): MODEL_DESC=%s.\n", __func__, ha->host_no, 1341 DEBUG13(printk("%s(%ld): MODEL_DESC=%s.\n", __func__, vha->host_no,
1336 eiter->a.model_desc)); 1342 eiter->a.model_desc));
1337 1343
1338 /* Hardware version. */ 1344 /* Hardware version. */
@@ -1344,7 +1350,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1344 eiter->len = cpu_to_be16(4 + alen); 1350 eiter->len = cpu_to_be16(4 + alen);
1345 size += 4 + alen; 1351 size += 4 + alen;
1346 1352
1347 DEBUG13(printk("%s(%ld): HARDWAREVER=%s.\n", __func__, ha->host_no, 1353 DEBUG13(printk("%s(%ld): HARDWAREVER=%s.\n", __func__, vha->host_no,
1348 eiter->a.hw_version)); 1354 eiter->a.hw_version));
1349 1355
1350 /* Driver version. */ 1356 /* Driver version. */
@@ -1356,7 +1362,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1356 eiter->len = cpu_to_be16(4 + alen); 1362 eiter->len = cpu_to_be16(4 + alen);
1357 size += 4 + alen; 1363 size += 4 + alen;
1358 1364
1359 DEBUG13(printk("%s(%ld): DRIVERVER=%s.\n", __func__, ha->host_no, 1365 DEBUG13(printk("%s(%ld): DRIVERVER=%s.\n", __func__, vha->host_no,
1360 eiter->a.driver_version)); 1366 eiter->a.driver_version));
1361 1367
1362 /* Option ROM version. */ 1368 /* Option ROM version. */
@@ -1368,27 +1374,27 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1368 eiter->len = cpu_to_be16(4 + alen); 1374 eiter->len = cpu_to_be16(4 + alen);
1369 size += 4 + alen; 1375 size += 4 + alen;
1370 1376
1371 DEBUG13(printk("%s(%ld): OPTROMVER=%s.\n", __func__, ha->host_no, 1377 DEBUG13(printk("%s(%ld): OPTROMVER=%s.\n", __func__, vha->host_no,
1372 eiter->a.orom_version)); 1378 eiter->a.orom_version));
1373 1379
1374 /* Firmware version */ 1380 /* Firmware version */
1375 eiter = (struct ct_fdmi_hba_attr *) (entries + size); 1381 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1376 eiter->type = __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION); 1382 eiter->type = __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION);
1377 ha->isp_ops->fw_version_str(ha, eiter->a.fw_version); 1383 ha->isp_ops->fw_version_str(vha, eiter->a.fw_version);
1378 alen = strlen(eiter->a.fw_version); 1384 alen = strlen(eiter->a.fw_version);
1379 alen += (alen & 3) ? (4 - (alen & 3)) : 4; 1385 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1380 eiter->len = cpu_to_be16(4 + alen); 1386 eiter->len = cpu_to_be16(4 + alen);
1381 size += 4 + alen; 1387 size += 4 + alen;
1382 1388
1383 DEBUG13(printk("%s(%ld): FIRMWAREVER=%s.\n", __func__, ha->host_no, 1389 DEBUG13(printk("%s(%ld): FIRMWAREVER=%s.\n", __func__, vha->host_no,
1384 eiter->a.fw_version)); 1390 eiter->a.fw_version));
1385 1391
1386 /* Update MS request size. */ 1392 /* Update MS request size. */
1387 qla2x00_update_ms_fdmi_iocb(ha, size + 16); 1393 qla2x00_update_ms_fdmi_iocb(vha, size + 16);
1388 1394
1389 DEBUG13(printk("%s(%ld): RHBA identifier=" 1395 DEBUG13(printk("%s(%ld): RHBA identifier="
1390 "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__, 1396 "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__,
1391 ha->host_no, ct_req->req.rhba.hba_identifier[0], 1397 vha->host_no, ct_req->req.rhba.hba_identifier[0],
1392 ct_req->req.rhba.hba_identifier[1], 1398 ct_req->req.rhba.hba_identifier[1],
1393 ct_req->req.rhba.hba_identifier[2], 1399 ct_req->req.rhba.hba_identifier[2],
1394 ct_req->req.rhba.hba_identifier[3], 1400 ct_req->req.rhba.hba_identifier[3],
@@ -1399,25 +1405,25 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1399 DEBUG13(qla2x00_dump_buffer(entries, size)); 1405 DEBUG13(qla2x00_dump_buffer(entries, size));
1400 1406
1401 /* Execute MS IOCB */ 1407 /* Execute MS IOCB */
1402 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, 1408 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
1403 sizeof(ms_iocb_entry_t)); 1409 sizeof(ms_iocb_entry_t));
1404 if (rval != QLA_SUCCESS) { 1410 if (rval != QLA_SUCCESS) {
1405 /*EMPTY*/ 1411 /*EMPTY*/
1406 DEBUG2_3(printk("scsi(%ld): RHBA issue IOCB failed (%d).\n", 1412 DEBUG2_3(printk("scsi(%ld): RHBA issue IOCB failed (%d).\n",
1407 ha->host_no, rval)); 1413 vha->host_no, rval));
1408 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RHBA") != 1414 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RHBA") !=
1409 QLA_SUCCESS) { 1415 QLA_SUCCESS) {
1410 rval = QLA_FUNCTION_FAILED; 1416 rval = QLA_FUNCTION_FAILED;
1411 if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM && 1417 if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM &&
1412 ct_rsp->header.explanation_code == 1418 ct_rsp->header.explanation_code ==
1413 CT_EXPL_ALREADY_REGISTERED) { 1419 CT_EXPL_ALREADY_REGISTERED) {
1414 DEBUG2_13(printk("%s(%ld): HBA already registered.\n", 1420 DEBUG2_13(printk("%s(%ld): HBA already registered.\n",
1415 __func__, ha->host_no)); 1421 __func__, vha->host_no));
1416 rval = QLA_ALREADY_REGISTERED; 1422 rval = QLA_ALREADY_REGISTERED;
1417 } 1423 }
1418 } else { 1424 } else {
1419 DEBUG2(printk("scsi(%ld): RHBA exiting normally.\n", 1425 DEBUG2(printk("scsi(%ld): RHBA exiting normally.\n",
1420 ha->host_no)); 1426 vha->host_no));
1421 } 1427 }
1422 1428
1423 return rval; 1429 return rval;
@@ -1430,17 +1436,17 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1430 * Returns 0 on success. 1436 * Returns 0 on success.
1431 */ 1437 */
1432static int 1438static int
1433qla2x00_fdmi_dhba(scsi_qla_host_t *ha) 1439qla2x00_fdmi_dhba(scsi_qla_host_t *vha)
1434{ 1440{
1435 int rval; 1441 int rval;
1436 1442 struct qla_hw_data *ha = vha->hw;
1437 ms_iocb_entry_t *ms_pkt; 1443 ms_iocb_entry_t *ms_pkt;
1438 struct ct_sns_req *ct_req; 1444 struct ct_sns_req *ct_req;
1439 struct ct_sns_rsp *ct_rsp; 1445 struct ct_sns_rsp *ct_rsp;
1440 1446
1441 /* Issue RPA */ 1447 /* Issue RPA */
1442 /* Prepare common MS IOCB */ 1448 /* Prepare common MS IOCB */
1443 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(ha, DHBA_REQ_SIZE, 1449 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, DHBA_REQ_SIZE,
1444 DHBA_RSP_SIZE); 1450 DHBA_RSP_SIZE);
1445 1451
1446 /* Prepare CT request */ 1452 /* Prepare CT request */
@@ -1449,28 +1455,28 @@ qla2x00_fdmi_dhba(scsi_qla_host_t *ha)
1449 ct_rsp = &ha->ct_sns->p.rsp; 1455 ct_rsp = &ha->ct_sns->p.rsp;
1450 1456
1451 /* Prepare FDMI command arguments -- portname. */ 1457 /* Prepare FDMI command arguments -- portname. */
1452 memcpy(ct_req->req.dhba.port_name, ha->port_name, WWN_SIZE); 1458 memcpy(ct_req->req.dhba.port_name, vha->port_name, WWN_SIZE);
1453 1459
1454 DEBUG13(printk("%s(%ld): DHBA portname=" 1460 DEBUG13(printk("%s(%ld): DHBA portname="
1455 "%02x%02x%02x%02x%02x%02x%02x%02x.\n", __func__, ha->host_no, 1461 "%02x%02x%02x%02x%02x%02x%02x%02x.\n", __func__, vha->host_no,
1456 ct_req->req.dhba.port_name[0], ct_req->req.dhba.port_name[1], 1462 ct_req->req.dhba.port_name[0], ct_req->req.dhba.port_name[1],
1457 ct_req->req.dhba.port_name[2], ct_req->req.dhba.port_name[3], 1463 ct_req->req.dhba.port_name[2], ct_req->req.dhba.port_name[3],
1458 ct_req->req.dhba.port_name[4], ct_req->req.dhba.port_name[5], 1464 ct_req->req.dhba.port_name[4], ct_req->req.dhba.port_name[5],
1459 ct_req->req.dhba.port_name[6], ct_req->req.dhba.port_name[7])); 1465 ct_req->req.dhba.port_name[6], ct_req->req.dhba.port_name[7]));
1460 1466
1461 /* Execute MS IOCB */ 1467 /* Execute MS IOCB */
1462 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, 1468 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
1463 sizeof(ms_iocb_entry_t)); 1469 sizeof(ms_iocb_entry_t));
1464 if (rval != QLA_SUCCESS) { 1470 if (rval != QLA_SUCCESS) {
1465 /*EMPTY*/ 1471 /*EMPTY*/
1466 DEBUG2_3(printk("scsi(%ld): DHBA issue IOCB failed (%d).\n", 1472 DEBUG2_3(printk("scsi(%ld): DHBA issue IOCB failed (%d).\n",
1467 ha->host_no, rval)); 1473 vha->host_no, rval));
1468 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "DHBA") != 1474 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "DHBA") !=
1469 QLA_SUCCESS) { 1475 QLA_SUCCESS) {
1470 rval = QLA_FUNCTION_FAILED; 1476 rval = QLA_FUNCTION_FAILED;
1471 } else { 1477 } else {
1472 DEBUG2(printk("scsi(%ld): DHBA exiting normally.\n", 1478 DEBUG2(printk("scsi(%ld): DHBA exiting normally.\n",
1473 ha->host_no)); 1479 vha->host_no));
1474 } 1480 }
1475 1481
1476 return rval; 1482 return rval;
@@ -1483,11 +1489,11 @@ qla2x00_fdmi_dhba(scsi_qla_host_t *ha)
1483 * Returns 0 on success. 1489 * Returns 0 on success.
1484 */ 1490 */
1485static int 1491static int
1486qla2x00_fdmi_rpa(scsi_qla_host_t *ha) 1492qla2x00_fdmi_rpa(scsi_qla_host_t *vha)
1487{ 1493{
1488 int rval, alen; 1494 int rval, alen;
1489 uint32_t size, max_frame_size; 1495 uint32_t size, max_frame_size;
1490 1496 struct qla_hw_data *ha = vha->hw;
1491 ms_iocb_entry_t *ms_pkt; 1497 ms_iocb_entry_t *ms_pkt;
1492 struct ct_sns_req *ct_req; 1498 struct ct_sns_req *ct_req;
1493 struct ct_sns_rsp *ct_rsp; 1499 struct ct_sns_rsp *ct_rsp;
@@ -1498,7 +1504,7 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1498 /* Issue RPA */ 1504 /* Issue RPA */
1499 /* Prepare common MS IOCB */ 1505 /* Prepare common MS IOCB */
1500 /* Request size adjusted after CT preparation */ 1506 /* Request size adjusted after CT preparation */
1501 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(ha, 0, RPA_RSP_SIZE); 1507 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RPA_RSP_SIZE);
1502 1508
1503 /* Prepare CT request */ 1509 /* Prepare CT request */
1504 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD, 1510 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD,
@@ -1506,7 +1512,7 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1506 ct_rsp = &ha->ct_sns->p.rsp; 1512 ct_rsp = &ha->ct_sns->p.rsp;
1507 1513
1508 /* Prepare FDMI command arguments -- attribute block, attributes. */ 1514 /* Prepare FDMI command arguments -- attribute block, attributes. */
1509 memcpy(ct_req->req.rpa.port_name, ha->port_name, WWN_SIZE); 1515 memcpy(ct_req->req.rpa.port_name, vha->port_name, WWN_SIZE);
1510 size = WWN_SIZE + 4; 1516 size = WWN_SIZE + 4;
1511 1517
1512 /* Attributes */ 1518 /* Attributes */
@@ -1521,8 +1527,9 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1521 eiter->a.fc4_types[2] = 0x01; 1527 eiter->a.fc4_types[2] = 0x01;
1522 size += 4 + 32; 1528 size += 4 + 32;
1523 1529
1524 DEBUG13(printk("%s(%ld): FC4_TYPES=%02x %02x.\n", __func__, ha->host_no, 1530 DEBUG13(printk("%s(%ld): FC4_TYPES=%02x %02x.\n", __func__,
1525 eiter->a.fc4_types[2], eiter->a.fc4_types[1])); 1531 vha->host_no, eiter->a.fc4_types[2],
1532 eiter->a.fc4_types[1]));
1526 1533
1527 /* Supported speed. */ 1534 /* Supported speed. */
1528 eiter = (struct ct_fdmi_port_attr *) (entries + size); 1535 eiter = (struct ct_fdmi_port_attr *) (entries + size);
@@ -1544,7 +1551,7 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1544 FDMI_PORT_SPEED_1GB); 1551 FDMI_PORT_SPEED_1GB);
1545 size += 4 + 4; 1552 size += 4 + 4;
1546 1553
1547 DEBUG13(printk("%s(%ld): SUPPORTED_SPEED=%x.\n", __func__, ha->host_no, 1554 DEBUG13(printk("%s(%ld): SUPPORTED_SPEED=%x.\n", __func__, vha->host_no,
1548 eiter->a.sup_speed)); 1555 eiter->a.sup_speed));
1549 1556
1550 /* Current speed. */ 1557 /* Current speed. */
@@ -1575,7 +1582,7 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1575 } 1582 }
1576 size += 4 + 4; 1583 size += 4 + 4;
1577 1584
1578 DEBUG13(printk("%s(%ld): CURRENT_SPEED=%x.\n", __func__, ha->host_no, 1585 DEBUG13(printk("%s(%ld): CURRENT_SPEED=%x.\n", __func__, vha->host_no,
1579 eiter->a.cur_speed)); 1586 eiter->a.cur_speed));
1580 1587
1581 /* Max frame size. */ 1588 /* Max frame size. */
@@ -1588,7 +1595,7 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1588 eiter->a.max_frame_size = cpu_to_be32(max_frame_size); 1595 eiter->a.max_frame_size = cpu_to_be32(max_frame_size);
1589 size += 4 + 4; 1596 size += 4 + 4;
1590 1597
1591 DEBUG13(printk("%s(%ld): MAX_FRAME_SIZE=%x.\n", __func__, ha->host_no, 1598 DEBUG13(printk("%s(%ld): MAX_FRAME_SIZE=%x.\n", __func__, vha->host_no,
1592 eiter->a.max_frame_size)); 1599 eiter->a.max_frame_size));
1593 1600
1594 /* OS device name. */ 1601 /* OS device name. */
@@ -1600,32 +1607,32 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1600 eiter->len = cpu_to_be16(4 + alen); 1607 eiter->len = cpu_to_be16(4 + alen);
1601 size += 4 + alen; 1608 size += 4 + alen;
1602 1609
1603 DEBUG13(printk("%s(%ld): OS_DEVICE_NAME=%s.\n", __func__, ha->host_no, 1610 DEBUG13(printk("%s(%ld): OS_DEVICE_NAME=%s.\n", __func__, vha->host_no,
1604 eiter->a.os_dev_name)); 1611 eiter->a.os_dev_name));
1605 1612
1606 /* Hostname. */ 1613 /* Hostname. */
1607 if (strlen(fc_host_system_hostname(ha->host))) { 1614 if (strlen(fc_host_system_hostname(vha->host))) {
1608 ct_req->req.rpa.attrs.count = 1615 ct_req->req.rpa.attrs.count =
1609 __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT); 1616 __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT);
1610 eiter = (struct ct_fdmi_port_attr *) (entries + size); 1617 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1611 eiter->type = __constant_cpu_to_be16(FDMI_PORT_HOST_NAME); 1618 eiter->type = __constant_cpu_to_be16(FDMI_PORT_HOST_NAME);
1612 snprintf(eiter->a.host_name, sizeof(eiter->a.host_name), 1619 snprintf(eiter->a.host_name, sizeof(eiter->a.host_name),
1613 "%s", fc_host_system_hostname(ha->host)); 1620 "%s", fc_host_system_hostname(vha->host));
1614 alen = strlen(eiter->a.host_name); 1621 alen = strlen(eiter->a.host_name);
1615 alen += (alen & 3) ? (4 - (alen & 3)) : 4; 1622 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1616 eiter->len = cpu_to_be16(4 + alen); 1623 eiter->len = cpu_to_be16(4 + alen);
1617 size += 4 + alen; 1624 size += 4 + alen;
1618 1625
1619 DEBUG13(printk("%s(%ld): HOSTNAME=%s.\n", __func__, 1626 DEBUG13(printk("%s(%ld): HOSTNAME=%s.\n", __func__,
1620 ha->host_no, eiter->a.host_name)); 1627 vha->host_no, eiter->a.host_name));
1621 } 1628 }
1622 1629
1623 /* Update MS request size. */ 1630 /* Update MS request size. */
1624 qla2x00_update_ms_fdmi_iocb(ha, size + 16); 1631 qla2x00_update_ms_fdmi_iocb(vha, size + 16);
1625 1632
1626 DEBUG13(printk("%s(%ld): RPA portname=" 1633 DEBUG13(printk("%s(%ld): RPA portname="
1627 "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__, 1634 "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__,
1628 ha->host_no, ct_req->req.rpa.port_name[0], 1635 vha->host_no, ct_req->req.rpa.port_name[0],
1629 ct_req->req.rpa.port_name[1], ct_req->req.rpa.port_name[2], 1636 ct_req->req.rpa.port_name[1], ct_req->req.rpa.port_name[2],
1630 ct_req->req.rpa.port_name[3], ct_req->req.rpa.port_name[4], 1637 ct_req->req.rpa.port_name[3], ct_req->req.rpa.port_name[4],
1631 ct_req->req.rpa.port_name[5], ct_req->req.rpa.port_name[6], 1638 ct_req->req.rpa.port_name[5], ct_req->req.rpa.port_name[6],
@@ -1633,18 +1640,18 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1633 DEBUG13(qla2x00_dump_buffer(entries, size)); 1640 DEBUG13(qla2x00_dump_buffer(entries, size));
1634 1641
1635 /* Execute MS IOCB */ 1642 /* Execute MS IOCB */
1636 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, 1643 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
1637 sizeof(ms_iocb_entry_t)); 1644 sizeof(ms_iocb_entry_t));
1638 if (rval != QLA_SUCCESS) { 1645 if (rval != QLA_SUCCESS) {
1639 /*EMPTY*/ 1646 /*EMPTY*/
1640 DEBUG2_3(printk("scsi(%ld): RPA issue IOCB failed (%d).\n", 1647 DEBUG2_3(printk("scsi(%ld): RPA issue IOCB failed (%d).\n",
1641 ha->host_no, rval)); 1648 vha->host_no, rval));
1642 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RPA") != 1649 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RPA") !=
1643 QLA_SUCCESS) { 1650 QLA_SUCCESS) {
1644 rval = QLA_FUNCTION_FAILED; 1651 rval = QLA_FUNCTION_FAILED;
1645 } else { 1652 } else {
1646 DEBUG2(printk("scsi(%ld): RPA exiting normally.\n", 1653 DEBUG2(printk("scsi(%ld): RPA exiting normally.\n",
1647 ha->host_no)); 1654 vha->host_no));
1648 } 1655 }
1649 1656
1650 return rval; 1657 return rval;
@@ -1657,34 +1664,34 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1657 * Returns 0 on success. 1664 * Returns 0 on success.
1658 */ 1665 */
1659int 1666int
1660qla2x00_fdmi_register(scsi_qla_host_t *ha) 1667qla2x00_fdmi_register(scsi_qla_host_t *vha)
1661{ 1668{
1662 int rval; 1669 int rval;
1663 1670
1664 if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 1671 if (IS_QLA2100(vha->hw) || IS_QLA2200(vha->hw)) {
1665 DEBUG2(printk("scsi(%ld): FDMI unsupported on " 1672 DEBUG2(printk("scsi(%ld): FDMI unsupported on "
1666 "ISP2100/ISP2200.\n", ha->host_no)); 1673 "ISP2100/ISP2200.\n", vha->host_no));
1667 return QLA_SUCCESS; 1674 return QLA_SUCCESS;
1668 } 1675 }
1669 1676
1670 rval = qla2x00_mgmt_svr_login(ha); 1677 rval = qla2x00_mgmt_svr_login(vha);
1671 if (rval) 1678 if (rval)
1672 return rval; 1679 return rval;
1673 1680
1674 rval = qla2x00_fdmi_rhba(ha); 1681 rval = qla2x00_fdmi_rhba(vha);
1675 if (rval) { 1682 if (rval) {
1676 if (rval != QLA_ALREADY_REGISTERED) 1683 if (rval != QLA_ALREADY_REGISTERED)
1677 return rval; 1684 return rval;
1678 1685
1679 rval = qla2x00_fdmi_dhba(ha); 1686 rval = qla2x00_fdmi_dhba(vha);
1680 if (rval) 1687 if (rval)
1681 return rval; 1688 return rval;
1682 1689
1683 rval = qla2x00_fdmi_rhba(ha); 1690 rval = qla2x00_fdmi_rhba(vha);
1684 if (rval) 1691 if (rval)
1685 return rval; 1692 return rval;
1686 } 1693 }
1687 rval = qla2x00_fdmi_rpa(ha); 1694 rval = qla2x00_fdmi_rpa(vha);
1688 1695
1689 return rval; 1696 return rval;
1690} 1697}
@@ -1697,11 +1704,11 @@ qla2x00_fdmi_register(scsi_qla_host_t *ha)
1697 * Returns 0 on success. 1704 * Returns 0 on success.
1698 */ 1705 */
1699int 1706int
1700qla2x00_gfpn_id(scsi_qla_host_t *ha, sw_info_t *list) 1707qla2x00_gfpn_id(scsi_qla_host_t *vha, sw_info_t *list)
1701{ 1708{
1702 int rval; 1709 int rval;
1703 uint16_t i; 1710 uint16_t i;
1704 1711 struct qla_hw_data *ha = vha->hw;
1705 ms_iocb_entry_t *ms_pkt; 1712 ms_iocb_entry_t *ms_pkt;
1706 struct ct_sns_req *ct_req; 1713 struct ct_sns_req *ct_req;
1707 struct ct_sns_rsp *ct_rsp; 1714 struct ct_sns_rsp *ct_rsp;
@@ -1712,7 +1719,7 @@ qla2x00_gfpn_id(scsi_qla_host_t *ha, sw_info_t *list)
1712 for (i = 0; i < MAX_FIBRE_DEVICES; i++) { 1719 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
1713 /* Issue GFPN_ID */ 1720 /* Issue GFPN_ID */
1714 /* Prepare common MS IOCB */ 1721 /* Prepare common MS IOCB */
1715 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, GFPN_ID_REQ_SIZE, 1722 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GFPN_ID_REQ_SIZE,
1716 GFPN_ID_RSP_SIZE); 1723 GFPN_ID_RSP_SIZE);
1717 1724
1718 /* Prepare CT request */ 1725 /* Prepare CT request */
@@ -1726,13 +1733,13 @@ qla2x00_gfpn_id(scsi_qla_host_t *ha, sw_info_t *list)
1726 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; 1733 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
1727 1734
1728 /* Execute MS IOCB */ 1735 /* Execute MS IOCB */
1729 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, 1736 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
1730 sizeof(ms_iocb_entry_t)); 1737 sizeof(ms_iocb_entry_t));
1731 if (rval != QLA_SUCCESS) { 1738 if (rval != QLA_SUCCESS) {
1732 /*EMPTY*/ 1739 /*EMPTY*/
1733 DEBUG2_3(printk("scsi(%ld): GFPN_ID issue IOCB " 1740 DEBUG2_3(printk("scsi(%ld): GFPN_ID issue IOCB "
1734 "failed (%d).\n", ha->host_no, rval)); 1741 "failed (%d).\n", vha->host_no, rval));
1735 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, 1742 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
1736 "GFPN_ID") != QLA_SUCCESS) { 1743 "GFPN_ID") != QLA_SUCCESS) {
1737 rval = QLA_FUNCTION_FAILED; 1744 rval = QLA_FUNCTION_FAILED;
1738 } else { 1745 } else {
@@ -1750,17 +1757,17 @@ qla2x00_gfpn_id(scsi_qla_host_t *ha, sw_info_t *list)
1750} 1757}
1751 1758
1752static inline void * 1759static inline void *
1753qla24xx_prep_ms_fm_iocb(scsi_qla_host_t *ha, uint32_t req_size, 1760qla24xx_prep_ms_fm_iocb(scsi_qla_host_t *vha, uint32_t req_size,
1754 uint32_t rsp_size) 1761 uint32_t rsp_size)
1755{ 1762{
1756 struct ct_entry_24xx *ct_pkt; 1763 struct ct_entry_24xx *ct_pkt;
1757 1764 struct qla_hw_data *ha = vha->hw;
1758 ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; 1765 ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
1759 memset(ct_pkt, 0, sizeof(struct ct_entry_24xx)); 1766 memset(ct_pkt, 0, sizeof(struct ct_entry_24xx));
1760 1767
1761 ct_pkt->entry_type = CT_IOCB_TYPE; 1768 ct_pkt->entry_type = CT_IOCB_TYPE;
1762 ct_pkt->entry_count = 1; 1769 ct_pkt->entry_count = 1;
1763 ct_pkt->nport_handle = cpu_to_le16(ha->mgmt_svr_loop_id); 1770 ct_pkt->nport_handle = cpu_to_le16(vha->mgmt_svr_loop_id);
1764 ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); 1771 ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
1765 ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); 1772 ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
1766 ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1); 1773 ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1);
@@ -1774,7 +1781,7 @@ qla24xx_prep_ms_fm_iocb(scsi_qla_host_t *ha, uint32_t req_size,
1774 ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); 1781 ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1775 ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); 1782 ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1776 ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; 1783 ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
1777 ct_pkt->vp_index = ha->vp_idx; 1784 ct_pkt->vp_index = vha->vp_idx;
1778 1785
1779 return ct_pkt; 1786 return ct_pkt;
1780} 1787}
@@ -1803,11 +1810,11 @@ qla24xx_prep_ct_fm_req(struct ct_sns_req *ct_req, uint16_t cmd,
1803 * Returns 0 on success. 1810 * Returns 0 on success.
1804 */ 1811 */
1805int 1812int
1806qla2x00_gpsc(scsi_qla_host_t *ha, sw_info_t *list) 1813qla2x00_gpsc(scsi_qla_host_t *vha, sw_info_t *list)
1807{ 1814{
1808 int rval; 1815 int rval;
1809 uint16_t i; 1816 uint16_t i;
1810 1817 struct qla_hw_data *ha = vha->hw;
1811 ms_iocb_entry_t *ms_pkt; 1818 ms_iocb_entry_t *ms_pkt;
1812 struct ct_sns_req *ct_req; 1819 struct ct_sns_req *ct_req;
1813 struct ct_sns_rsp *ct_rsp; 1820 struct ct_sns_rsp *ct_rsp;
@@ -1817,14 +1824,14 @@ qla2x00_gpsc(scsi_qla_host_t *ha, sw_info_t *list)
1817 if (!ha->flags.gpsc_supported) 1824 if (!ha->flags.gpsc_supported)
1818 return QLA_FUNCTION_FAILED; 1825 return QLA_FUNCTION_FAILED;
1819 1826
1820 rval = qla2x00_mgmt_svr_login(ha); 1827 rval = qla2x00_mgmt_svr_login(vha);
1821 if (rval) 1828 if (rval)
1822 return rval; 1829 return rval;
1823 1830
1824 for (i = 0; i < MAX_FIBRE_DEVICES; i++) { 1831 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
1825 /* Issue GFPN_ID */ 1832 /* Issue GFPN_ID */
1826 /* Prepare common MS IOCB */ 1833 /* Prepare common MS IOCB */
1827 ms_pkt = qla24xx_prep_ms_fm_iocb(ha, GPSC_REQ_SIZE, 1834 ms_pkt = qla24xx_prep_ms_fm_iocb(vha, GPSC_REQ_SIZE,
1828 GPSC_RSP_SIZE); 1835 GPSC_RSP_SIZE);
1829 1836
1830 /* Prepare CT request */ 1837 /* Prepare CT request */
@@ -1837,13 +1844,13 @@ qla2x00_gpsc(scsi_qla_host_t *ha, sw_info_t *list)
1837 WWN_SIZE); 1844 WWN_SIZE);
1838 1845
1839 /* Execute MS IOCB */ 1846 /* Execute MS IOCB */
1840 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, 1847 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
1841 sizeof(ms_iocb_entry_t)); 1848 sizeof(ms_iocb_entry_t));
1842 if (rval != QLA_SUCCESS) { 1849 if (rval != QLA_SUCCESS) {
1843 /*EMPTY*/ 1850 /*EMPTY*/
1844 DEBUG2_3(printk("scsi(%ld): GPSC issue IOCB " 1851 DEBUG2_3(printk("scsi(%ld): GPSC issue IOCB "
1845 "failed (%d).\n", ha->host_no, rval)); 1852 "failed (%d).\n", vha->host_no, rval));
1846 } else if ((rval = qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, 1853 } else if ((rval = qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
1847 "GPSC")) != QLA_SUCCESS) { 1854 "GPSC")) != QLA_SUCCESS) {
1848 /* FM command unsupported? */ 1855 /* FM command unsupported? */
1849 if (rval == QLA_INVALID_COMMAND && 1856 if (rval == QLA_INVALID_COMMAND &&
@@ -1853,7 +1860,7 @@ qla2x00_gpsc(scsi_qla_host_t *ha, sw_info_t *list)
1853 CT_REASON_COMMAND_UNSUPPORTED)) { 1860 CT_REASON_COMMAND_UNSUPPORTED)) {
1854 DEBUG2(printk("scsi(%ld): GPSC command " 1861 DEBUG2(printk("scsi(%ld): GPSC command "
1855 "unsupported, disabling query...\n", 1862 "unsupported, disabling query...\n",
1856 ha->host_no)); 1863 vha->host_no));
1857 ha->flags.gpsc_supported = 0; 1864 ha->flags.gpsc_supported = 0;
1858 rval = QLA_FUNCTION_FAILED; 1865 rval = QLA_FUNCTION_FAILED;
1859 break; 1866 break;
@@ -1878,7 +1885,7 @@ qla2x00_gpsc(scsi_qla_host_t *ha, sw_info_t *list)
1878 1885
1879 DEBUG2_3(printk("scsi(%ld): GPSC ext entry - " 1886 DEBUG2_3(printk("scsi(%ld): GPSC ext entry - "
1880 "fpn %02x%02x%02x%02x%02x%02x%02x%02x speeds=%04x " 1887 "fpn %02x%02x%02x%02x%02x%02x%02x%02x speeds=%04x "
1881 "speed=%04x.\n", ha->host_no, 1888 "speed=%04x.\n", vha->host_no,
1882 list[i].fabric_port_name[0], 1889 list[i].fabric_port_name[0],
1883 list[i].fabric_port_name[1], 1890 list[i].fabric_port_name[1],
1884 list[i].fabric_port_name[2], 1891 list[i].fabric_port_name[2],
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 3402746ec128..bc52aa01a49e 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -29,7 +29,7 @@
29 * Kernel context. 29 * Kernel context.
30 */ 30 */
31static int 31static int
32qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp) 32qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
33{ 33{
34 int rval; 34 int rval;
35 unsigned long flags = 0; 35 unsigned long flags = 0;
@@ -42,15 +42,16 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
42 uint32_t cnt; 42 uint32_t cnt;
43 uint32_t mboxes; 43 uint32_t mboxes;
44 unsigned long wait_time; 44 unsigned long wait_time;
45 scsi_qla_host_t *ha = to_qla_parent(pvha); 45 struct qla_hw_data *ha = vha->hw;
46 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
46 47
47 reg = ha->iobase; 48 reg = ha->iobase;
48 io_lock_on = ha->flags.init_done; 49 io_lock_on = base_vha->flags.init_done;
49 50
50 rval = QLA_SUCCESS; 51 rval = QLA_SUCCESS;
51 abort_active = test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags); 52 abort_active = test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
52 53
53 DEBUG11(printk("%s(%ld): entered.\n", __func__, pvha->host_no)); 54 DEBUG11(printk("%s(%ld): entered.\n", __func__, base_vha->host_no));
54 55
55 /* 56 /*
56 * Wait for active mailbox commands to finish by waiting at most tov 57 * Wait for active mailbox commands to finish by waiting at most tov
@@ -62,7 +63,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
62 mcp->tov * HZ)) { 63 mcp->tov * HZ)) {
63 /* Timeout occurred. Return error. */ 64 /* Timeout occurred. Return error. */
64 DEBUG2_3_11(printk("%s(%ld): cmd access timeout. " 65 DEBUG2_3_11(printk("%s(%ld): cmd access timeout. "
65 "Exiting.\n", __func__, ha->host_no)); 66 "Exiting.\n", __func__, base_vha->host_no));
66 return QLA_FUNCTION_TIMEOUT; 67 return QLA_FUNCTION_TIMEOUT;
67 } 68 }
68 } 69 }
@@ -72,7 +73,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
72 ha->mcp = mcp; 73 ha->mcp = mcp;
73 74
74 DEBUG11(printk("scsi(%ld): prepare to issue mbox cmd=0x%x.\n", 75 DEBUG11(printk("scsi(%ld): prepare to issue mbox cmd=0x%x.\n",
75 ha->host_no, mcp->mb[0])); 76 base_vha->host_no, mcp->mb[0]));
76 77
77 spin_lock_irqsave(&ha->hardware_lock, flags); 78 spin_lock_irqsave(&ha->hardware_lock, flags);
78 79
@@ -100,15 +101,16 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
100 101
101#if defined(QL_DEBUG_LEVEL_1) 102#if defined(QL_DEBUG_LEVEL_1)
102 printk("%s(%ld): Loaded MBX registers (displayed in bytes) = \n", 103 printk("%s(%ld): Loaded MBX registers (displayed in bytes) = \n",
103 __func__, ha->host_no); 104 __func__, base_vha->host_no);
104 qla2x00_dump_buffer((uint8_t *)mcp->mb, 16); 105 qla2x00_dump_buffer((uint8_t *)mcp->mb, 16);
105 printk("\n"); 106 printk("\n");
106 qla2x00_dump_buffer(((uint8_t *)mcp->mb + 0x10), 16); 107 qla2x00_dump_buffer(((uint8_t *)mcp->mb + 0x10), 16);
107 printk("\n"); 108 printk("\n");
108 qla2x00_dump_buffer(((uint8_t *)mcp->mb + 0x20), 8); 109 qla2x00_dump_buffer(((uint8_t *)mcp->mb + 0x20), 8);
109 printk("\n"); 110 printk("\n");
110 printk("%s(%ld): I/O address = %p.\n", __func__, ha->host_no, optr); 111 printk("%s(%ld): I/O address = %p.\n", __func__, base_vha->host_no,
111 qla2x00_dump_regs(ha); 112 optr);
113 qla2x00_dump_regs(base_vha);
112#endif 114#endif
113 115
114 /* Issue set host interrupt command to send cmd out. */ 116 /* Issue set host interrupt command to send cmd out. */
@@ -117,7 +119,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
117 119
118 /* Unlock mbx registers and wait for interrupt */ 120 /* Unlock mbx registers and wait for interrupt */
119 DEBUG11(printk("%s(%ld): going to unlock irq & waiting for interrupt. " 121 DEBUG11(printk("%s(%ld): going to unlock irq & waiting for interrupt. "
120 "jiffies=%lx.\n", __func__, ha->host_no, jiffies)); 122 "jiffies=%lx.\n", __func__, base_vha->host_no, jiffies));
121 123
122 /* Wait for mbx cmd completion until timeout */ 124 /* Wait for mbx cmd completion until timeout */
123 125
@@ -137,7 +139,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
137 139
138 } else { 140 } else {
139 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__, 141 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__,
140 ha->host_no, command)); 142 base_vha->host_no, command));
141 143
142 if (IS_FWI2_CAPABLE(ha)) 144 if (IS_FWI2_CAPABLE(ha))
143 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT); 145 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
@@ -151,7 +153,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
151 break; 153 break;
152 154
153 /* Check for pending interrupts. */ 155 /* Check for pending interrupts. */
154 qla2x00_poll(ha); 156 qla2x00_poll(ha->rsp);
155 157
156 if (command != MBC_LOAD_RISC_RAM_EXTENDED && 158 if (command != MBC_LOAD_RISC_RAM_EXTENDED &&
157 !ha->flags.mbox_int) 159 !ha->flags.mbox_int)
@@ -164,7 +166,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
164 uint16_t *iptr2; 166 uint16_t *iptr2;
165 167
166 DEBUG3_11(printk("%s(%ld): cmd %x completed.\n", __func__, 168 DEBUG3_11(printk("%s(%ld): cmd %x completed.\n", __func__,
167 ha->host_no, command)); 169 base_vha->host_no, command));
168 170
169 /* Got interrupt. Clear the flag. */ 171 /* Got interrupt. Clear the flag. */
170 ha->flags.mbox_int = 0; 172 ha->flags.mbox_int = 0;
@@ -200,12 +202,12 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
200 ictrl = RD_REG_WORD(&reg->isp.ictrl); 202 ictrl = RD_REG_WORD(&reg->isp.ictrl);
201 } 203 }
202 printk("%s(%ld): **** MB Command Timeout for cmd %x ****\n", 204 printk("%s(%ld): **** MB Command Timeout for cmd %x ****\n",
203 __func__, ha->host_no, command); 205 __func__, base_vha->host_no, command);
204 printk("%s(%ld): icontrol=%x jiffies=%lx\n", __func__, 206 printk("%s(%ld): icontrol=%x jiffies=%lx\n", __func__,
205 ha->host_no, ictrl, jiffies); 207 base_vha->host_no, ictrl, jiffies);
206 printk("%s(%ld): *** mailbox[0] = 0x%x ***\n", __func__, 208 printk("%s(%ld): *** mailbox[0] = 0x%x ***\n", __func__,
207 ha->host_no, mb0); 209 base_vha->host_no, mb0);
208 qla2x00_dump_regs(ha); 210 qla2x00_dump_regs(base_vha);
209#endif 211#endif
210 212
211 rval = QLA_FUNCTION_TIMEOUT; 213 rval = QLA_FUNCTION_TIMEOUT;
@@ -218,10 +220,10 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
218 220
219 if (abort_active || !io_lock_on) { 221 if (abort_active || !io_lock_on) {
220 DEBUG11(printk("%s(%ld): checking for additional resp " 222 DEBUG11(printk("%s(%ld): checking for additional resp "
221 "interrupt.\n", __func__, ha->host_no)); 223 "interrupt.\n", __func__, base_vha->host_no));
222 224
223 /* polling mode for non isp_abort commands. */ 225 /* polling mode for non isp_abort commands. */
224 qla2x00_poll(ha); 226 qla2x00_poll(ha->rsp);
225 } 227 }
226 228
227 if (rval == QLA_FUNCTION_TIMEOUT && 229 if (rval == QLA_FUNCTION_TIMEOUT &&
@@ -229,35 +231,37 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
229 if (!io_lock_on || (mcp->flags & IOCTL_CMD)) { 231 if (!io_lock_on || (mcp->flags & IOCTL_CMD)) {
230 /* not in dpc. schedule it for dpc to take over. */ 232 /* not in dpc. schedule it for dpc to take over. */
231 DEBUG(printk("%s(%ld): timeout schedule " 233 DEBUG(printk("%s(%ld): timeout schedule "
232 "isp_abort_needed.\n", __func__, ha->host_no)); 234 "isp_abort_needed.\n", __func__,
235 base_vha->host_no));
233 DEBUG2_3_11(printk("%s(%ld): timeout schedule " 236 DEBUG2_3_11(printk("%s(%ld): timeout schedule "
234 "isp_abort_needed.\n", __func__, ha->host_no)); 237 "isp_abort_needed.\n", __func__,
238 base_vha->host_no));
235 qla_printk(KERN_WARNING, ha, 239 qla_printk(KERN_WARNING, ha,
236 "Mailbox command timeout occurred. Scheduling ISP " 240 "Mailbox command timeout occurred. Scheduling ISP "
237 "abort.\n"); 241 "abort.\n");
238 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 242 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
239 qla2xxx_wake_dpc(ha); 243 qla2xxx_wake_dpc(vha);
240 } else if (!abort_active) { 244 } else if (!abort_active) {
241 /* call abort directly since we are in the DPC thread */ 245 /* call abort directly since we are in the DPC thread */
242 DEBUG(printk("%s(%ld): timeout calling abort_isp\n", 246 DEBUG(printk("%s(%ld): timeout calling abort_isp\n",
243 __func__, ha->host_no)); 247 __func__, base_vha->host_no));
244 DEBUG2_3_11(printk("%s(%ld): timeout calling " 248 DEBUG2_3_11(printk("%s(%ld): timeout calling "
245 "abort_isp\n", __func__, ha->host_no)); 249 "abort_isp\n", __func__, base_vha->host_no));
246 qla_printk(KERN_WARNING, ha, 250 qla_printk(KERN_WARNING, ha,
247 "Mailbox command timeout occurred. Issuing ISP " 251 "Mailbox command timeout occurred. Issuing ISP "
248 "abort.\n"); 252 "abort.\n");
249 253
250 set_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags); 254 set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
251 clear_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 255 clear_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
252 if (qla2x00_abort_isp(ha)) { 256 if (qla2x00_abort_isp(base_vha)) {
253 /* Failed. retry later. */ 257 /* Failed. retry later. */
254 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 258 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
255 } 259 }
256 clear_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags); 260 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
257 DEBUG(printk("%s(%ld): finished abort_isp\n", __func__, 261 DEBUG(printk("%s(%ld): finished abort_isp\n", __func__,
258 ha->host_no)); 262 base_vha->host_no));
259 DEBUG2_3_11(printk("%s(%ld): finished abort_isp\n", 263 DEBUG2_3_11(printk("%s(%ld): finished abort_isp\n",
260 __func__, ha->host_no)); 264 __func__, base_vha->host_no));
261 } 265 }
262 } 266 }
263 267
@@ -267,24 +271,26 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
267 271
268 if (rval) { 272 if (rval) {
269 DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, " 273 DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, "
270 "mbx2=%x, cmd=%x ****\n", __func__, ha->host_no, 274 "mbx2=%x, cmd=%x ****\n", __func__, base_vha->host_no,
271 mcp->mb[0], mcp->mb[1], mcp->mb[2], command)); 275 mcp->mb[0], mcp->mb[1], mcp->mb[2], command));
272 } else { 276 } else {
273 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 277 DEBUG11(printk("%s(%ld): done.\n", __func__,
278 base_vha->host_no));
274 } 279 }
275 280
276 return rval; 281 return rval;
277} 282}
278 283
279int 284int
280qla2x00_load_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t risc_addr, 285qla2x00_load_ram(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t risc_addr,
281 uint32_t risc_code_size) 286 uint32_t risc_code_size)
282{ 287{
283 int rval; 288 int rval;
289 struct qla_hw_data *ha = vha->hw;
284 mbx_cmd_t mc; 290 mbx_cmd_t mc;
285 mbx_cmd_t *mcp = &mc; 291 mbx_cmd_t *mcp = &mc;
286 292
287 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 293 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
288 294
289 if (MSW(risc_addr) || IS_FWI2_CAPABLE(ha)) { 295 if (MSW(risc_addr) || IS_FWI2_CAPABLE(ha)) {
290 mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED; 296 mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED;
@@ -312,13 +318,13 @@ qla2x00_load_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t risc_addr,
312 mcp->in_mb = MBX_0; 318 mcp->in_mb = MBX_0;
313 mcp->tov = MBX_TOV_SECONDS; 319 mcp->tov = MBX_TOV_SECONDS;
314 mcp->flags = 0; 320 mcp->flags = 0;
315 rval = qla2x00_mailbox_command(ha, mcp); 321 rval = qla2x00_mailbox_command(vha, mcp);
316 322
317 if (rval != QLA_SUCCESS) { 323 if (rval != QLA_SUCCESS) {
318 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__, 324 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__,
319 ha->host_no, rval, mcp->mb[0])); 325 vha->host_no, rval, mcp->mb[0]));
320 } else { 326 } else {
321 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 327 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
322 } 328 }
323 329
324 return rval; 330 return rval;
@@ -340,13 +346,14 @@ qla2x00_load_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t risc_addr,
340 * Kernel context. 346 * Kernel context.
341 */ 347 */
342int 348int
343qla2x00_execute_fw(scsi_qla_host_t *ha, uint32_t risc_addr) 349qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr)
344{ 350{
345 int rval; 351 int rval;
352 struct qla_hw_data *ha = vha->hw;
346 mbx_cmd_t mc; 353 mbx_cmd_t mc;
347 mbx_cmd_t *mcp = &mc; 354 mbx_cmd_t *mcp = &mc;
348 355
349 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 356 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
350 357
351 mcp->mb[0] = MBC_EXECUTE_FIRMWARE; 358 mcp->mb[0] = MBC_EXECUTE_FIRMWARE;
352 mcp->out_mb = MBX_0; 359 mcp->out_mb = MBX_0;
@@ -369,18 +376,18 @@ qla2x00_execute_fw(scsi_qla_host_t *ha, uint32_t risc_addr)
369 376
370 mcp->tov = MBX_TOV_SECONDS; 377 mcp->tov = MBX_TOV_SECONDS;
371 mcp->flags = 0; 378 mcp->flags = 0;
372 rval = qla2x00_mailbox_command(ha, mcp); 379 rval = qla2x00_mailbox_command(vha, mcp);
373 380
374 if (rval != QLA_SUCCESS) { 381 if (rval != QLA_SUCCESS) {
375 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__, 382 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__,
376 ha->host_no, rval, mcp->mb[0])); 383 vha->host_no, rval, mcp->mb[0]));
377 } else { 384 } else {
378 if (IS_FWI2_CAPABLE(ha)) { 385 if (IS_FWI2_CAPABLE(ha)) {
379 DEBUG11(printk("%s(%ld): done exchanges=%x.\n", 386 DEBUG11(printk("%s(%ld): done exchanges=%x.\n",
380 __func__, ha->host_no, mcp->mb[1])); 387 __func__, vha->host_no, mcp->mb[1]));
381 } else { 388 } else {
382 DEBUG11(printk("%s(%ld): done.\n", __func__, 389 DEBUG11(printk("%s(%ld): done.\n", __func__,
383 ha->host_no)); 390 vha->host_no));
384 } 391 }
385 } 392 }
386 393
@@ -404,28 +411,28 @@ qla2x00_execute_fw(scsi_qla_host_t *ha, uint32_t risc_addr)
404 * Kernel context. 411 * Kernel context.
405 */ 412 */
406void 413void
407qla2x00_get_fw_version(scsi_qla_host_t *ha, uint16_t *major, uint16_t *minor, 414qla2x00_get_fw_version(scsi_qla_host_t *vha, uint16_t *major, uint16_t *minor,
408 uint16_t *subminor, uint16_t *attributes, uint32_t *memory) 415 uint16_t *subminor, uint16_t *attributes, uint32_t *memory)
409{ 416{
410 int rval; 417 int rval;
411 mbx_cmd_t mc; 418 mbx_cmd_t mc;
412 mbx_cmd_t *mcp = &mc; 419 mbx_cmd_t *mcp = &mc;
413 420
414 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 421 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
415 422
416 mcp->mb[0] = MBC_GET_FIRMWARE_VERSION; 423 mcp->mb[0] = MBC_GET_FIRMWARE_VERSION;
417 mcp->out_mb = MBX_0; 424 mcp->out_mb = MBX_0;
418 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 425 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
419 mcp->flags = 0; 426 mcp->flags = 0;
420 mcp->tov = MBX_TOV_SECONDS; 427 mcp->tov = MBX_TOV_SECONDS;
421 rval = qla2x00_mailbox_command(ha, mcp); 428 rval = qla2x00_mailbox_command(vha, mcp);
422 429
423 /* Return mailbox data. */ 430 /* Return mailbox data. */
424 *major = mcp->mb[1]; 431 *major = mcp->mb[1];
425 *minor = mcp->mb[2]; 432 *minor = mcp->mb[2];
426 *subminor = mcp->mb[3]; 433 *subminor = mcp->mb[3];
427 *attributes = mcp->mb[6]; 434 *attributes = mcp->mb[6];
428 if (IS_QLA2100(ha) || IS_QLA2200(ha)) 435 if (IS_QLA2100(vha->hw) || IS_QLA2200(vha->hw))
429 *memory = 0x1FFFF; /* Defaults to 128KB. */ 436 *memory = 0x1FFFF; /* Defaults to 128KB. */
430 else 437 else
431 *memory = (mcp->mb[5] << 16) | mcp->mb[4]; 438 *memory = (mcp->mb[5] << 16) | mcp->mb[4];
@@ -433,10 +440,10 @@ qla2x00_get_fw_version(scsi_qla_host_t *ha, uint16_t *major, uint16_t *minor,
433 if (rval != QLA_SUCCESS) { 440 if (rval != QLA_SUCCESS) {
434 /*EMPTY*/ 441 /*EMPTY*/
435 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 442 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
436 ha->host_no, rval)); 443 vha->host_no, rval));
437 } else { 444 } else {
438 /*EMPTY*/ 445 /*EMPTY*/
439 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 446 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
440 } 447 }
441} 448}
442 449
@@ -455,32 +462,32 @@ qla2x00_get_fw_version(scsi_qla_host_t *ha, uint16_t *major, uint16_t *minor,
455 * Kernel context. 462 * Kernel context.
456 */ 463 */
457int 464int
458qla2x00_get_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts) 465qla2x00_get_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts)
459{ 466{
460 int rval; 467 int rval;
461 mbx_cmd_t mc; 468 mbx_cmd_t mc;
462 mbx_cmd_t *mcp = &mc; 469 mbx_cmd_t *mcp = &mc;
463 470
464 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 471 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
465 472
466 mcp->mb[0] = MBC_GET_FIRMWARE_OPTION; 473 mcp->mb[0] = MBC_GET_FIRMWARE_OPTION;
467 mcp->out_mb = MBX_0; 474 mcp->out_mb = MBX_0;
468 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; 475 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
469 mcp->tov = MBX_TOV_SECONDS; 476 mcp->tov = MBX_TOV_SECONDS;
470 mcp->flags = 0; 477 mcp->flags = 0;
471 rval = qla2x00_mailbox_command(ha, mcp); 478 rval = qla2x00_mailbox_command(vha, mcp);
472 479
473 if (rval != QLA_SUCCESS) { 480 if (rval != QLA_SUCCESS) {
474 /*EMPTY*/ 481 /*EMPTY*/
475 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 482 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
476 ha->host_no, rval)); 483 vha->host_no, rval));
477 } else { 484 } else {
478 fwopts[0] = mcp->mb[0]; 485 fwopts[0] = mcp->mb[0];
479 fwopts[1] = mcp->mb[1]; 486 fwopts[1] = mcp->mb[1];
480 fwopts[2] = mcp->mb[2]; 487 fwopts[2] = mcp->mb[2];
481 fwopts[3] = mcp->mb[3]; 488 fwopts[3] = mcp->mb[3];
482 489
483 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 490 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
484 } 491 }
485 492
486 return rval; 493 return rval;
@@ -502,13 +509,13 @@ qla2x00_get_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts)
502 * Kernel context. 509 * Kernel context.
503 */ 510 */
504int 511int
505qla2x00_set_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts) 512qla2x00_set_fw_options(scsi_qla_host_t *vha, uint16_t *fwopts)
506{ 513{
507 int rval; 514 int rval;
508 mbx_cmd_t mc; 515 mbx_cmd_t mc;
509 mbx_cmd_t *mcp = &mc; 516 mbx_cmd_t *mcp = &mc;
510 517
511 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 518 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
512 519
513 mcp->mb[0] = MBC_SET_FIRMWARE_OPTION; 520 mcp->mb[0] = MBC_SET_FIRMWARE_OPTION;
514 mcp->mb[1] = fwopts[1]; 521 mcp->mb[1] = fwopts[1];
@@ -516,7 +523,7 @@ qla2x00_set_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts)
516 mcp->mb[3] = fwopts[3]; 523 mcp->mb[3] = fwopts[3];
517 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 524 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
518 mcp->in_mb = MBX_0; 525 mcp->in_mb = MBX_0;
519 if (IS_FWI2_CAPABLE(ha)) { 526 if (IS_FWI2_CAPABLE(vha->hw)) {
520 mcp->in_mb |= MBX_1; 527 mcp->in_mb |= MBX_1;
521 } else { 528 } else {
522 mcp->mb[10] = fwopts[10]; 529 mcp->mb[10] = fwopts[10];
@@ -526,17 +533,17 @@ qla2x00_set_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts)
526 } 533 }
527 mcp->tov = MBX_TOV_SECONDS; 534 mcp->tov = MBX_TOV_SECONDS;
528 mcp->flags = 0; 535 mcp->flags = 0;
529 rval = qla2x00_mailbox_command(ha, mcp); 536 rval = qla2x00_mailbox_command(vha, mcp);
530 537
531 fwopts[0] = mcp->mb[0]; 538 fwopts[0] = mcp->mb[0];
532 539
533 if (rval != QLA_SUCCESS) { 540 if (rval != QLA_SUCCESS) {
534 /*EMPTY*/ 541 /*EMPTY*/
535 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x/%x).\n", __func__, 542 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x/%x).\n", __func__,
536 ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 543 vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
537 } else { 544 } else {
538 /*EMPTY*/ 545 /*EMPTY*/
539 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 546 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
540 } 547 }
541 548
542 return rval; 549 return rval;
@@ -558,13 +565,14 @@ qla2x00_set_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts)
558 * Kernel context. 565 * Kernel context.
559 */ 566 */
560int 567int
561qla2x00_mbx_reg_test(scsi_qla_host_t *ha) 568qla2x00_mbx_reg_test(scsi_qla_host_t *vha)
562{ 569{
563 int rval; 570 int rval;
571 struct qla_hw_data *ha = vha->hw;
564 mbx_cmd_t mc; 572 mbx_cmd_t mc;
565 mbx_cmd_t *mcp = &mc; 573 mbx_cmd_t *mcp = &mc;
566 574
567 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): entered.\n", ha->host_no)); 575 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): entered.\n", vha->host_no));
568 576
569 mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST; 577 mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST;
570 mcp->mb[1] = 0xAAAA; 578 mcp->mb[1] = 0xAAAA;
@@ -578,7 +586,7 @@ qla2x00_mbx_reg_test(scsi_qla_host_t *ha)
578 mcp->in_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 586 mcp->in_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
579 mcp->tov = MBX_TOV_SECONDS; 587 mcp->tov = MBX_TOV_SECONDS;
580 mcp->flags = 0; 588 mcp->flags = 0;
581 rval = qla2x00_mailbox_command(ha, mcp); 589 rval = qla2x00_mailbox_command(vha, mcp);
582 590
583 if (rval == QLA_SUCCESS) { 591 if (rval == QLA_SUCCESS) {
584 if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 || 592 if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 ||
@@ -591,7 +599,7 @@ qla2x00_mbx_reg_test(scsi_qla_host_t *ha)
591 struct device_reg_24xx __iomem *reg = 599 struct device_reg_24xx __iomem *reg =
592 &ha->iobase->isp24; 600 &ha->iobase->isp24;
593 601
594 qla2xxx_hw_event_log(ha, HW_EVENT_ISP_ERR, 0, 602 qla2xxx_hw_event_log(vha, HW_EVENT_ISP_ERR, 0,
595 LSW(RD_REG_DWORD(&reg->hccr)), 603 LSW(RD_REG_DWORD(&reg->hccr)),
596 LSW(RD_REG_DWORD(&reg->istatus))); 604 LSW(RD_REG_DWORD(&reg->istatus)));
597 } 605 }
@@ -600,11 +608,11 @@ qla2x00_mbx_reg_test(scsi_qla_host_t *ha)
600 if (rval != QLA_SUCCESS) { 608 if (rval != QLA_SUCCESS) {
601 /*EMPTY*/ 609 /*EMPTY*/
602 DEBUG2_3_11(printk("qla2x00_mbx_reg_test(%ld): failed=%x.\n", 610 DEBUG2_3_11(printk("qla2x00_mbx_reg_test(%ld): failed=%x.\n",
603 ha->host_no, rval)); 611 vha->host_no, rval));
604 } else { 612 } else {
605 /*EMPTY*/ 613 /*EMPTY*/
606 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): done.\n", 614 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): done.\n",
607 ha->host_no)); 615 vha->host_no));
608 } 616 }
609 617
610 return rval; 618 return rval;
@@ -626,18 +634,18 @@ qla2x00_mbx_reg_test(scsi_qla_host_t *ha)
626 * Kernel context. 634 * Kernel context.
627 */ 635 */
628int 636int
629qla2x00_verify_checksum(scsi_qla_host_t *ha, uint32_t risc_addr) 637qla2x00_verify_checksum(scsi_qla_host_t *vha, uint32_t risc_addr)
630{ 638{
631 int rval; 639 int rval;
632 mbx_cmd_t mc; 640 mbx_cmd_t mc;
633 mbx_cmd_t *mcp = &mc; 641 mbx_cmd_t *mcp = &mc;
634 642
635 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 643 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
636 644
637 mcp->mb[0] = MBC_VERIFY_CHECKSUM; 645 mcp->mb[0] = MBC_VERIFY_CHECKSUM;
638 mcp->out_mb = MBX_0; 646 mcp->out_mb = MBX_0;
639 mcp->in_mb = MBX_0; 647 mcp->in_mb = MBX_0;
640 if (IS_FWI2_CAPABLE(ha)) { 648 if (IS_FWI2_CAPABLE(vha->hw)) {
641 mcp->mb[1] = MSW(risc_addr); 649 mcp->mb[1] = MSW(risc_addr);
642 mcp->mb[2] = LSW(risc_addr); 650 mcp->mb[2] = LSW(risc_addr);
643 mcp->out_mb |= MBX_2|MBX_1; 651 mcp->out_mb |= MBX_2|MBX_1;
@@ -650,14 +658,14 @@ qla2x00_verify_checksum(scsi_qla_host_t *ha, uint32_t risc_addr)
650 658
651 mcp->tov = MBX_TOV_SECONDS; 659 mcp->tov = MBX_TOV_SECONDS;
652 mcp->flags = 0; 660 mcp->flags = 0;
653 rval = qla2x00_mailbox_command(ha, mcp); 661 rval = qla2x00_mailbox_command(vha, mcp);
654 662
655 if (rval != QLA_SUCCESS) { 663 if (rval != QLA_SUCCESS) {
656 DEBUG2_3_11(printk("%s(%ld): failed=%x chk sum=%x.\n", __func__, 664 DEBUG2_3_11(printk("%s(%ld): failed=%x chk sum=%x.\n", __func__,
657 ha->host_no, rval, IS_FWI2_CAPABLE(ha) ? 665 vha->host_no, rval, IS_FWI2_CAPABLE(vha->hw) ?
658 (mcp->mb[2] << 16) | mcp->mb[1]: mcp->mb[1])); 666 (mcp->mb[2] << 16) | mcp->mb[1]: mcp->mb[1]));
659 } else { 667 } else {
660 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 668 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
661 } 669 }
662 670
663 return rval; 671 return rval;
@@ -682,7 +690,7 @@ qla2x00_verify_checksum(scsi_qla_host_t *ha, uint32_t risc_addr)
682 * Kernel context. 690 * Kernel context.
683 */ 691 */
684static int 692static int
685qla2x00_issue_iocb_timeout(scsi_qla_host_t *ha, void *buffer, 693qla2x00_issue_iocb_timeout(scsi_qla_host_t *vha, void *buffer,
686 dma_addr_t phys_addr, size_t size, uint32_t tov) 694 dma_addr_t phys_addr, size_t size, uint32_t tov)
687{ 695{
688 int rval; 696 int rval;
@@ -699,30 +707,30 @@ qla2x00_issue_iocb_timeout(scsi_qla_host_t *ha, void *buffer,
699 mcp->in_mb = MBX_2|MBX_0; 707 mcp->in_mb = MBX_2|MBX_0;
700 mcp->tov = tov; 708 mcp->tov = tov;
701 mcp->flags = 0; 709 mcp->flags = 0;
702 rval = qla2x00_mailbox_command(ha, mcp); 710 rval = qla2x00_mailbox_command(vha, mcp);
703 711
704 if (rval != QLA_SUCCESS) { 712 if (rval != QLA_SUCCESS) {
705 /*EMPTY*/ 713 /*EMPTY*/
706 DEBUG(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n", 714 DEBUG(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n",
707 ha->host_no, rval)); 715 vha->host_no, rval));
708 DEBUG2(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n", 716 DEBUG2(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n",
709 ha->host_no, rval)); 717 vha->host_no, rval));
710 } else { 718 } else {
711 sts_entry_t *sts_entry = (sts_entry_t *) buffer; 719 sts_entry_t *sts_entry = (sts_entry_t *) buffer;
712 720
713 /* Mask reserved bits. */ 721 /* Mask reserved bits. */
714 sts_entry->entry_status &= 722 sts_entry->entry_status &=
715 IS_FWI2_CAPABLE(ha) ? RF_MASK_24XX :RF_MASK; 723 IS_FWI2_CAPABLE(vha->hw) ? RF_MASK_24XX : RF_MASK;
716 } 724 }
717 725
718 return rval; 726 return rval;
719} 727}
720 728
721int 729int
722qla2x00_issue_iocb(scsi_qla_host_t *ha, void *buffer, dma_addr_t phys_addr, 730qla2x00_issue_iocb(scsi_qla_host_t *vha, void *buffer, dma_addr_t phys_addr,
723 size_t size) 731 size_t size)
724{ 732{
725 return qla2x00_issue_iocb_timeout(ha, buffer, phys_addr, size, 733 return qla2x00_issue_iocb_timeout(vha, buffer, phys_addr, size,
726 MBX_TOV_SECONDS); 734 MBX_TOV_SECONDS);
727} 735}
728 736
@@ -741,7 +749,7 @@ qla2x00_issue_iocb(scsi_qla_host_t *ha, void *buffer, dma_addr_t phys_addr,
741 * Kernel context. 749 * Kernel context.
742 */ 750 */
743int 751int
744qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp) 752qla2x00_abort_command(scsi_qla_host_t *vha, srb_t *sp)
745{ 753{
746 unsigned long flags = 0; 754 unsigned long flags = 0;
747 fc_port_t *fcport; 755 fc_port_t *fcport;
@@ -749,14 +757,16 @@ qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp)
749 uint32_t handle; 757 uint32_t handle;
750 mbx_cmd_t mc; 758 mbx_cmd_t mc;
751 mbx_cmd_t *mcp = &mc; 759 mbx_cmd_t *mcp = &mc;
760 struct qla_hw_data *ha = vha->hw;
761 struct req_que *req = ha->req;
752 762
753 DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no)); 763 DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", vha->host_no));
754 764
755 fcport = sp->fcport; 765 fcport = sp->fcport;
756 766
757 spin_lock_irqsave(&ha->hardware_lock, flags); 767 spin_lock_irqsave(&ha->hardware_lock, flags);
758 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { 768 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) {
759 if (ha->outstanding_cmds[handle] == sp) 769 if (req->outstanding_cmds[handle] == sp)
760 break; 770 break;
761 } 771 }
762 spin_unlock_irqrestore(&ha->hardware_lock, flags); 772 spin_unlock_irqrestore(&ha->hardware_lock, flags);
@@ -778,14 +788,14 @@ qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp)
778 mcp->in_mb = MBX_0; 788 mcp->in_mb = MBX_0;
779 mcp->tov = MBX_TOV_SECONDS; 789 mcp->tov = MBX_TOV_SECONDS;
780 mcp->flags = 0; 790 mcp->flags = 0;
781 rval = qla2x00_mailbox_command(ha, mcp); 791 rval = qla2x00_mailbox_command(vha, mcp);
782 792
783 if (rval != QLA_SUCCESS) { 793 if (rval != QLA_SUCCESS) {
784 DEBUG2_3_11(printk("qla2x00_abort_command(%ld): failed=%x.\n", 794 DEBUG2_3_11(printk("qla2x00_abort_command(%ld): failed=%x.\n",
785 ha->host_no, rval)); 795 vha->host_no, rval));
786 } else { 796 } else {
787 DEBUG11(printk("qla2x00_abort_command(%ld): done.\n", 797 DEBUG11(printk("qla2x00_abort_command(%ld): done.\n",
788 ha->host_no)); 798 vha->host_no));
789 } 799 }
790 800
791 return rval; 801 return rval;
@@ -797,40 +807,40 @@ qla2x00_abort_target(struct fc_port *fcport, unsigned int l)
797 int rval, rval2; 807 int rval, rval2;
798 mbx_cmd_t mc; 808 mbx_cmd_t mc;
799 mbx_cmd_t *mcp = &mc; 809 mbx_cmd_t *mcp = &mc;
800 scsi_qla_host_t *ha; 810 scsi_qla_host_t *vha;
801 811
802 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no)); 812 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->vha->host_no));
803 813
804 l = l; 814 l = l;
805 ha = fcport->ha; 815 vha = fcport->vha;
806 mcp->mb[0] = MBC_ABORT_TARGET; 816 mcp->mb[0] = MBC_ABORT_TARGET;
807 mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0; 817 mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0;
808 if (HAS_EXTENDED_IDS(ha)) { 818 if (HAS_EXTENDED_IDS(vha->hw)) {
809 mcp->mb[1] = fcport->loop_id; 819 mcp->mb[1] = fcport->loop_id;
810 mcp->mb[10] = 0; 820 mcp->mb[10] = 0;
811 mcp->out_mb |= MBX_10; 821 mcp->out_mb |= MBX_10;
812 } else { 822 } else {
813 mcp->mb[1] = fcport->loop_id << 8; 823 mcp->mb[1] = fcport->loop_id << 8;
814 } 824 }
815 mcp->mb[2] = ha->loop_reset_delay; 825 mcp->mb[2] = vha->hw->loop_reset_delay;
816 mcp->mb[9] = ha->vp_idx; 826 mcp->mb[9] = vha->vp_idx;
817 827
818 mcp->in_mb = MBX_0; 828 mcp->in_mb = MBX_0;
819 mcp->tov = MBX_TOV_SECONDS; 829 mcp->tov = MBX_TOV_SECONDS;
820 mcp->flags = 0; 830 mcp->flags = 0;
821 rval = qla2x00_mailbox_command(ha, mcp); 831 rval = qla2x00_mailbox_command(vha, mcp);
822 if (rval != QLA_SUCCESS) { 832 if (rval != QLA_SUCCESS) {
823 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 833 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
824 ha->host_no, rval)); 834 vha->host_no, rval));
825 } 835 }
826 836
827 /* Issue marker IOCB. */ 837 /* Issue marker IOCB. */
828 rval2 = qla2x00_marker(ha, fcport->loop_id, 0, MK_SYNC_ID); 838 rval2 = qla2x00_marker(vha, fcport->loop_id, 0, MK_SYNC_ID);
829 if (rval2 != QLA_SUCCESS) { 839 if (rval2 != QLA_SUCCESS) {
830 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB " 840 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
831 "(%x).\n", __func__, ha->host_no, rval2)); 841 "(%x).\n", __func__, vha->host_no, rval2));
832 } else { 842 } else {
833 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 843 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
834 } 844 }
835 845
836 return rval; 846 return rval;
@@ -842,37 +852,37 @@ qla2x00_lun_reset(struct fc_port *fcport, unsigned int l)
842 int rval, rval2; 852 int rval, rval2;
843 mbx_cmd_t mc; 853 mbx_cmd_t mc;
844 mbx_cmd_t *mcp = &mc; 854 mbx_cmd_t *mcp = &mc;
845 scsi_qla_host_t *ha; 855 scsi_qla_host_t *vha;
846 856
847 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no)); 857 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->vha->host_no));
848 858
849 ha = fcport->ha; 859 vha = fcport->vha;
850 mcp->mb[0] = MBC_LUN_RESET; 860 mcp->mb[0] = MBC_LUN_RESET;
851 mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; 861 mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0;
852 if (HAS_EXTENDED_IDS(ha)) 862 if (HAS_EXTENDED_IDS(vha->hw))
853 mcp->mb[1] = fcport->loop_id; 863 mcp->mb[1] = fcport->loop_id;
854 else 864 else
855 mcp->mb[1] = fcport->loop_id << 8; 865 mcp->mb[1] = fcport->loop_id << 8;
856 mcp->mb[2] = l; 866 mcp->mb[2] = l;
857 mcp->mb[3] = 0; 867 mcp->mb[3] = 0;
858 mcp->mb[9] = ha->vp_idx; 868 mcp->mb[9] = vha->vp_idx;
859 869
860 mcp->in_mb = MBX_0; 870 mcp->in_mb = MBX_0;
861 mcp->tov = MBX_TOV_SECONDS; 871 mcp->tov = MBX_TOV_SECONDS;
862 mcp->flags = 0; 872 mcp->flags = 0;
863 rval = qla2x00_mailbox_command(ha, mcp); 873 rval = qla2x00_mailbox_command(vha, mcp);
864 if (rval != QLA_SUCCESS) { 874 if (rval != QLA_SUCCESS) {
865 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 875 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
866 ha->host_no, rval)); 876 vha->host_no, rval));
867 } 877 }
868 878
869 /* Issue marker IOCB. */ 879 /* Issue marker IOCB. */
870 rval2 = qla2x00_marker(ha, fcport->loop_id, l, MK_SYNC_ID_LUN); 880 rval2 = qla2x00_marker(vha, fcport->loop_id, l, MK_SYNC_ID_LUN);
871 if (rval2 != QLA_SUCCESS) { 881 if (rval2 != QLA_SUCCESS) {
872 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB " 882 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
873 "(%x).\n", __func__, ha->host_no, rval2)); 883 "(%x).\n", __func__, vha->host_no, rval2));
874 } else { 884 } else {
875 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 885 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
876 } 886 }
877 887
878 return rval; 888 return rval;
@@ -899,7 +909,7 @@ qla2x00_lun_reset(struct fc_port *fcport, unsigned int l)
899 * Kernel context. 909 * Kernel context.
900 */ 910 */
901int 911int
902qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa, 912qla2x00_get_adapter_id(scsi_qla_host_t *vha, uint16_t *id, uint8_t *al_pa,
903 uint8_t *area, uint8_t *domain, uint16_t *top, uint16_t *sw_cap) 913 uint8_t *area, uint8_t *domain, uint16_t *top, uint16_t *sw_cap)
904{ 914{
905 int rval; 915 int rval;
@@ -907,15 +917,15 @@ qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa,
907 mbx_cmd_t *mcp = &mc; 917 mbx_cmd_t *mcp = &mc;
908 918
909 DEBUG11(printk("qla2x00_get_adapter_id(%ld): entered.\n", 919 DEBUG11(printk("qla2x00_get_adapter_id(%ld): entered.\n",
910 ha->host_no)); 920 vha->host_no));
911 921
912 mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID; 922 mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID;
913 mcp->mb[9] = ha->vp_idx; 923 mcp->mb[9] = vha->vp_idx;
914 mcp->out_mb = MBX_9|MBX_0; 924 mcp->out_mb = MBX_9|MBX_0;
915 mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 925 mcp->in_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
916 mcp->tov = MBX_TOV_SECONDS; 926 mcp->tov = MBX_TOV_SECONDS;
917 mcp->flags = 0; 927 mcp->flags = 0;
918 rval = qla2x00_mailbox_command(ha, mcp); 928 rval = qla2x00_mailbox_command(vha, mcp);
919 if (mcp->mb[0] == MBS_COMMAND_ERROR) 929 if (mcp->mb[0] == MBS_COMMAND_ERROR)
920 rval = QLA_COMMAND_ERROR; 930 rval = QLA_COMMAND_ERROR;
921 else if (mcp->mb[0] == MBS_INVALID_COMMAND) 931 else if (mcp->mb[0] == MBS_INVALID_COMMAND)
@@ -932,11 +942,11 @@ qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa,
932 if (rval != QLA_SUCCESS) { 942 if (rval != QLA_SUCCESS) {
933 /*EMPTY*/ 943 /*EMPTY*/
934 DEBUG2_3_11(printk("qla2x00_get_adapter_id(%ld): failed=%x.\n", 944 DEBUG2_3_11(printk("qla2x00_get_adapter_id(%ld): failed=%x.\n",
935 ha->host_no, rval)); 945 vha->host_no, rval));
936 } else { 946 } else {
937 /*EMPTY*/ 947 /*EMPTY*/
938 DEBUG11(printk("qla2x00_get_adapter_id(%ld): done.\n", 948 DEBUG11(printk("qla2x00_get_adapter_id(%ld): done.\n",
939 ha->host_no)); 949 vha->host_no));
940 } 950 }
941 951
942 return rval; 952 return rval;
@@ -958,7 +968,7 @@ qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa,
958 * Kernel context. 968 * Kernel context.
959 */ 969 */
960int 970int
961qla2x00_get_retry_cnt(scsi_qla_host_t *ha, uint8_t *retry_cnt, uint8_t *tov, 971qla2x00_get_retry_cnt(scsi_qla_host_t *vha, uint8_t *retry_cnt, uint8_t *tov,
962 uint16_t *r_a_tov) 972 uint16_t *r_a_tov)
963{ 973{
964 int rval; 974 int rval;
@@ -967,19 +977,19 @@ qla2x00_get_retry_cnt(scsi_qla_host_t *ha, uint8_t *retry_cnt, uint8_t *tov,
967 mbx_cmd_t *mcp = &mc; 977 mbx_cmd_t *mcp = &mc;
968 978
969 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): entered.\n", 979 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): entered.\n",
970 ha->host_no)); 980 vha->host_no));
971 981
972 mcp->mb[0] = MBC_GET_RETRY_COUNT; 982 mcp->mb[0] = MBC_GET_RETRY_COUNT;
973 mcp->out_mb = MBX_0; 983 mcp->out_mb = MBX_0;
974 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; 984 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
975 mcp->tov = MBX_TOV_SECONDS; 985 mcp->tov = MBX_TOV_SECONDS;
976 mcp->flags = 0; 986 mcp->flags = 0;
977 rval = qla2x00_mailbox_command(ha, mcp); 987 rval = qla2x00_mailbox_command(vha, mcp);
978 988
979 if (rval != QLA_SUCCESS) { 989 if (rval != QLA_SUCCESS) {
980 /*EMPTY*/ 990 /*EMPTY*/
981 DEBUG2_3_11(printk("qla2x00_get_retry_cnt(%ld): failed = %x.\n", 991 DEBUG2_3_11(printk("qla2x00_get_retry_cnt(%ld): failed = %x.\n",
982 ha->host_no, mcp->mb[0])); 992 vha->host_no, mcp->mb[0]));
983 } else { 993 } else {
984 /* Convert returned data and check our values. */ 994 /* Convert returned data and check our values. */
985 *r_a_tov = mcp->mb[3] / 2; 995 *r_a_tov = mcp->mb[3] / 2;
@@ -991,7 +1001,7 @@ qla2x00_get_retry_cnt(scsi_qla_host_t *ha, uint8_t *retry_cnt, uint8_t *tov,
991 } 1001 }
992 1002
993 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): done. mb3=%d " 1003 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): done. mb3=%d "
994 "ratov=%d.\n", ha->host_no, mcp->mb[3], ratov)); 1004 "ratov=%d.\n", vha->host_no, mcp->mb[3], ratov));
995 } 1005 }
996 1006
997 return rval; 1007 return rval;
@@ -1015,14 +1025,15 @@ qla2x00_get_retry_cnt(scsi_qla_host_t *ha, uint8_t *retry_cnt, uint8_t *tov,
1015 * Kernel context. 1025 * Kernel context.
1016 */ 1026 */
1017int 1027int
1018qla2x00_init_firmware(scsi_qla_host_t *ha, uint16_t size) 1028qla2x00_init_firmware(scsi_qla_host_t *vha, uint16_t size)
1019{ 1029{
1020 int rval; 1030 int rval;
1021 mbx_cmd_t mc; 1031 mbx_cmd_t mc;
1022 mbx_cmd_t *mcp = &mc; 1032 mbx_cmd_t *mcp = &mc;
1033 struct qla_hw_data *ha = vha->hw;
1023 1034
1024 DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n", 1035 DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n",
1025 ha->host_no)); 1036 vha->host_no));
1026 1037
1027 if (ha->flags.npiv_supported) 1038 if (ha->flags.npiv_supported)
1028 mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE; 1039 mcp->mb[0] = MBC_MID_INITIALIZE_FIRMWARE;
@@ -1040,17 +1051,17 @@ qla2x00_init_firmware(scsi_qla_host_t *ha, uint16_t size)
1040 mcp->buf_size = size; 1051 mcp->buf_size = size;
1041 mcp->flags = MBX_DMA_OUT; 1052 mcp->flags = MBX_DMA_OUT;
1042 mcp->tov = MBX_TOV_SECONDS; 1053 mcp->tov = MBX_TOV_SECONDS;
1043 rval = qla2x00_mailbox_command(ha, mcp); 1054 rval = qla2x00_mailbox_command(vha, mcp);
1044 1055
1045 if (rval != QLA_SUCCESS) { 1056 if (rval != QLA_SUCCESS) {
1046 /*EMPTY*/ 1057 /*EMPTY*/
1047 DEBUG2_3_11(printk("qla2x00_init_firmware(%ld): failed=%x " 1058 DEBUG2_3_11(printk("qla2x00_init_firmware(%ld): failed=%x "
1048 "mb0=%x.\n", 1059 "mb0=%x.\n",
1049 ha->host_no, rval, mcp->mb[0])); 1060 vha->host_no, rval, mcp->mb[0]));
1050 } else { 1061 } else {
1051 /*EMPTY*/ 1062 /*EMPTY*/
1052 DEBUG11(printk("qla2x00_init_firmware(%ld): done.\n", 1063 DEBUG11(printk("qla2x00_init_firmware(%ld): done.\n",
1053 ha->host_no)); 1064 vha->host_no));
1054 } 1065 }
1055 1066
1056 return rval; 1067 return rval;
@@ -1073,7 +1084,7 @@ qla2x00_init_firmware(scsi_qla_host_t *ha, uint16_t size)
1073 * Kernel context. 1084 * Kernel context.
1074 */ 1085 */
1075int 1086int
1076qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt) 1087qla2x00_get_port_database(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t opt)
1077{ 1088{
1078 int rval; 1089 int rval;
1079 mbx_cmd_t mc; 1090 mbx_cmd_t mc;
@@ -1081,14 +1092,15 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
1081 port_database_t *pd; 1092 port_database_t *pd;
1082 struct port_database_24xx *pd24; 1093 struct port_database_24xx *pd24;
1083 dma_addr_t pd_dma; 1094 dma_addr_t pd_dma;
1095 struct qla_hw_data *ha = vha->hw;
1084 1096
1085 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1097 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1086 1098
1087 pd24 = NULL; 1099 pd24 = NULL;
1088 pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); 1100 pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
1089 if (pd == NULL) { 1101 if (pd == NULL) {
1090 DEBUG2_3(printk("%s(%ld): failed to allocate Port Database " 1102 DEBUG2_3(printk("%s(%ld): failed to allocate Port Database "
1091 "structure.\n", __func__, ha->host_no)); 1103 "structure.\n", __func__, vha->host_no));
1092 return QLA_MEMORY_ALLOC_FAILED; 1104 return QLA_MEMORY_ALLOC_FAILED;
1093 } 1105 }
1094 memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE)); 1106 memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE));
@@ -1100,7 +1112,7 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
1100 mcp->mb[3] = LSW(pd_dma); 1112 mcp->mb[3] = LSW(pd_dma);
1101 mcp->mb[6] = MSW(MSD(pd_dma)); 1113 mcp->mb[6] = MSW(MSD(pd_dma));
1102 mcp->mb[7] = LSW(MSD(pd_dma)); 1114 mcp->mb[7] = LSW(MSD(pd_dma));
1103 mcp->mb[9] = ha->vp_idx; 1115 mcp->mb[9] = vha->vp_idx;
1104 mcp->out_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 1116 mcp->out_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
1105 mcp->in_mb = MBX_0; 1117 mcp->in_mb = MBX_0;
1106 if (IS_FWI2_CAPABLE(ha)) { 1118 if (IS_FWI2_CAPABLE(ha)) {
@@ -1120,7 +1132,7 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
1120 PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE; 1132 PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE;
1121 mcp->flags = MBX_DMA_IN; 1133 mcp->flags = MBX_DMA_IN;
1122 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 1134 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
1123 rval = qla2x00_mailbox_command(ha, mcp); 1135 rval = qla2x00_mailbox_command(vha, mcp);
1124 if (rval != QLA_SUCCESS) 1136 if (rval != QLA_SUCCESS)
1125 goto gpd_error_out; 1137 goto gpd_error_out;
1126 1138
@@ -1132,7 +1144,7 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
1132 pd24->last_login_state != PDS_PRLI_COMPLETE) { 1144 pd24->last_login_state != PDS_PRLI_COMPLETE) {
1133 DEBUG2(printk("%s(%ld): Unable to verify " 1145 DEBUG2(printk("%s(%ld): Unable to verify "
1134 "login-state (%x/%x) for loop_id %x\n", 1146 "login-state (%x/%x) for loop_id %x\n",
1135 __func__, ha->host_no, 1147 __func__, vha->host_no,
1136 pd24->current_login_state, 1148 pd24->current_login_state,
1137 pd24->last_login_state, fcport->loop_id)); 1149 pd24->last_login_state, fcport->loop_id));
1138 rval = QLA_FUNCTION_FAILED; 1150 rval = QLA_FUNCTION_FAILED;
@@ -1192,9 +1204,9 @@ gpd_error_out:
1192 1204
1193 if (rval != QLA_SUCCESS) { 1205 if (rval != QLA_SUCCESS) {
1194 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 1206 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
1195 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 1207 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
1196 } else { 1208 } else {
1197 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 1209 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
1198 } 1210 }
1199 1211
1200 return rval; 1212 return rval;
@@ -1217,21 +1229,21 @@ gpd_error_out:
1217 * Kernel context. 1229 * Kernel context.
1218 */ 1230 */
1219int 1231int
1220qla2x00_get_firmware_state(scsi_qla_host_t *ha, uint16_t *states) 1232qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states)
1221{ 1233{
1222 int rval; 1234 int rval;
1223 mbx_cmd_t mc; 1235 mbx_cmd_t mc;
1224 mbx_cmd_t *mcp = &mc; 1236 mbx_cmd_t *mcp = &mc;
1225 1237
1226 DEBUG11(printk("qla2x00_get_firmware_state(%ld): entered.\n", 1238 DEBUG11(printk("qla2x00_get_firmware_state(%ld): entered.\n",
1227 ha->host_no)); 1239 vha->host_no));
1228 1240
1229 mcp->mb[0] = MBC_GET_FIRMWARE_STATE; 1241 mcp->mb[0] = MBC_GET_FIRMWARE_STATE;
1230 mcp->out_mb = MBX_0; 1242 mcp->out_mb = MBX_0;
1231 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1243 mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1232 mcp->tov = MBX_TOV_SECONDS; 1244 mcp->tov = MBX_TOV_SECONDS;
1233 mcp->flags = 0; 1245 mcp->flags = 0;
1234 rval = qla2x00_mailbox_command(ha, mcp); 1246 rval = qla2x00_mailbox_command(vha, mcp);
1235 1247
1236 /* Return firmware states. */ 1248 /* Return firmware states. */
1237 states[0] = mcp->mb[1]; 1249 states[0] = mcp->mb[1];
@@ -1241,11 +1253,11 @@ qla2x00_get_firmware_state(scsi_qla_host_t *ha, uint16_t *states)
1241 if (rval != QLA_SUCCESS) { 1253 if (rval != QLA_SUCCESS) {
1242 /*EMPTY*/ 1254 /*EMPTY*/
1243 DEBUG2_3_11(printk("qla2x00_get_firmware_state(%ld): " 1255 DEBUG2_3_11(printk("qla2x00_get_firmware_state(%ld): "
1244 "failed=%x.\n", ha->host_no, rval)); 1256 "failed=%x.\n", vha->host_no, rval));
1245 } else { 1257 } else {
1246 /*EMPTY*/ 1258 /*EMPTY*/
1247 DEBUG11(printk("qla2x00_get_firmware_state(%ld): done.\n", 1259 DEBUG11(printk("qla2x00_get_firmware_state(%ld): done.\n",
1248 ha->host_no)); 1260 vha->host_no));
1249 } 1261 }
1250 1262
1251 return rval; 1263 return rval;
@@ -1270,7 +1282,7 @@ qla2x00_get_firmware_state(scsi_qla_host_t *ha, uint16_t *states)
1270 * Kernel context. 1282 * Kernel context.
1271 */ 1283 */
1272int 1284int
1273qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name, 1285qla2x00_get_port_name(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t *name,
1274 uint8_t opt) 1286 uint8_t opt)
1275{ 1287{
1276 int rval; 1288 int rval;
@@ -1278,12 +1290,12 @@ qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name,
1278 mbx_cmd_t *mcp = &mc; 1290 mbx_cmd_t *mcp = &mc;
1279 1291
1280 DEBUG11(printk("qla2x00_get_port_name(%ld): entered.\n", 1292 DEBUG11(printk("qla2x00_get_port_name(%ld): entered.\n",
1281 ha->host_no)); 1293 vha->host_no));
1282 1294
1283 mcp->mb[0] = MBC_GET_PORT_NAME; 1295 mcp->mb[0] = MBC_GET_PORT_NAME;
1284 mcp->mb[9] = ha->vp_idx; 1296 mcp->mb[9] = vha->vp_idx;
1285 mcp->out_mb = MBX_9|MBX_1|MBX_0; 1297 mcp->out_mb = MBX_9|MBX_1|MBX_0;
1286 if (HAS_EXTENDED_IDS(ha)) { 1298 if (HAS_EXTENDED_IDS(vha->hw)) {
1287 mcp->mb[1] = loop_id; 1299 mcp->mb[1] = loop_id;
1288 mcp->mb[10] = opt; 1300 mcp->mb[10] = opt;
1289 mcp->out_mb |= MBX_10; 1301 mcp->out_mb |= MBX_10;
@@ -1294,12 +1306,12 @@ qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name,
1294 mcp->in_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 1306 mcp->in_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
1295 mcp->tov = MBX_TOV_SECONDS; 1307 mcp->tov = MBX_TOV_SECONDS;
1296 mcp->flags = 0; 1308 mcp->flags = 0;
1297 rval = qla2x00_mailbox_command(ha, mcp); 1309 rval = qla2x00_mailbox_command(vha, mcp);
1298 1310
1299 if (rval != QLA_SUCCESS) { 1311 if (rval != QLA_SUCCESS) {
1300 /*EMPTY*/ 1312 /*EMPTY*/
1301 DEBUG2_3_11(printk("qla2x00_get_port_name(%ld): failed=%x.\n", 1313 DEBUG2_3_11(printk("qla2x00_get_port_name(%ld): failed=%x.\n",
1302 ha->host_no, rval)); 1314 vha->host_no, rval));
1303 } else { 1315 } else {
1304 if (name != NULL) { 1316 if (name != NULL) {
1305 /* This function returns name in big endian. */ 1317 /* This function returns name in big endian. */
@@ -1314,7 +1326,7 @@ qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name,
1314 } 1326 }
1315 1327
1316 DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n", 1328 DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n",
1317 ha->host_no)); 1329 vha->host_no));
1318 } 1330 }
1319 1331
1320 return rval; 1332 return rval;
@@ -1336,45 +1348,45 @@ qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name,
1336 * Kernel context. 1348 * Kernel context.
1337 */ 1349 */
1338int 1350int
1339qla2x00_lip_reset(scsi_qla_host_t *ha) 1351qla2x00_lip_reset(scsi_qla_host_t *vha)
1340{ 1352{
1341 int rval; 1353 int rval;
1342 mbx_cmd_t mc; 1354 mbx_cmd_t mc;
1343 mbx_cmd_t *mcp = &mc; 1355 mbx_cmd_t *mcp = &mc;
1344 1356
1345 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1357 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1346 1358
1347 if (IS_FWI2_CAPABLE(ha)) { 1359 if (IS_FWI2_CAPABLE(vha->hw)) {
1348 mcp->mb[0] = MBC_LIP_FULL_LOGIN; 1360 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
1349 mcp->mb[1] = BIT_6; 1361 mcp->mb[1] = BIT_6;
1350 mcp->mb[2] = 0; 1362 mcp->mb[2] = 0;
1351 mcp->mb[3] = ha->loop_reset_delay; 1363 mcp->mb[3] = vha->hw->loop_reset_delay;
1352 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1364 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1353 } else { 1365 } else {
1354 mcp->mb[0] = MBC_LIP_RESET; 1366 mcp->mb[0] = MBC_LIP_RESET;
1355 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1367 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1356 if (HAS_EXTENDED_IDS(ha)) { 1368 if (HAS_EXTENDED_IDS(vha->hw)) {
1357 mcp->mb[1] = 0x00ff; 1369 mcp->mb[1] = 0x00ff;
1358 mcp->mb[10] = 0; 1370 mcp->mb[10] = 0;
1359 mcp->out_mb |= MBX_10; 1371 mcp->out_mb |= MBX_10;
1360 } else { 1372 } else {
1361 mcp->mb[1] = 0xff00; 1373 mcp->mb[1] = 0xff00;
1362 } 1374 }
1363 mcp->mb[2] = ha->loop_reset_delay; 1375 mcp->mb[2] = vha->hw->loop_reset_delay;
1364 mcp->mb[3] = 0; 1376 mcp->mb[3] = 0;
1365 } 1377 }
1366 mcp->in_mb = MBX_0; 1378 mcp->in_mb = MBX_0;
1367 mcp->tov = MBX_TOV_SECONDS; 1379 mcp->tov = MBX_TOV_SECONDS;
1368 mcp->flags = 0; 1380 mcp->flags = 0;
1369 rval = qla2x00_mailbox_command(ha, mcp); 1381 rval = qla2x00_mailbox_command(vha, mcp);
1370 1382
1371 if (rval != QLA_SUCCESS) { 1383 if (rval != QLA_SUCCESS) {
1372 /*EMPTY*/ 1384 /*EMPTY*/
1373 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", 1385 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n",
1374 __func__, ha->host_no, rval)); 1386 __func__, vha->host_no, rval));
1375 } else { 1387 } else {
1376 /*EMPTY*/ 1388 /*EMPTY*/
1377 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 1389 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
1378 } 1390 }
1379 1391
1380 return rval; 1392 return rval;
@@ -1399,7 +1411,7 @@ qla2x00_lip_reset(scsi_qla_host_t *ha)
1399 * Kernel context. 1411 * Kernel context.
1400 */ 1412 */
1401int 1413int
1402qla2x00_send_sns(scsi_qla_host_t *ha, dma_addr_t sns_phys_address, 1414qla2x00_send_sns(scsi_qla_host_t *vha, dma_addr_t sns_phys_address,
1403 uint16_t cmd_size, size_t buf_size) 1415 uint16_t cmd_size, size_t buf_size)
1404{ 1416{
1405 int rval; 1417 int rval;
@@ -1407,10 +1419,11 @@ qla2x00_send_sns(scsi_qla_host_t *ha, dma_addr_t sns_phys_address,
1407 mbx_cmd_t *mcp = &mc; 1419 mbx_cmd_t *mcp = &mc;
1408 1420
1409 DEBUG11(printk("qla2x00_send_sns(%ld): entered.\n", 1421 DEBUG11(printk("qla2x00_send_sns(%ld): entered.\n",
1410 ha->host_no)); 1422 vha->host_no));
1411 1423
1412 DEBUG11(printk("qla2x00_send_sns: retry cnt=%d ratov=%d total " 1424 DEBUG11(printk("qla2x00_send_sns: retry cnt=%d ratov=%d total "
1413 "tov=%d.\n", ha->retry_count, ha->login_timeout, mcp->tov)); 1425 "tov=%d.\n", vha->hw->retry_count, vha->hw->login_timeout,
1426 mcp->tov));
1414 1427
1415 mcp->mb[0] = MBC_SEND_SNS_COMMAND; 1428 mcp->mb[0] = MBC_SEND_SNS_COMMAND;
1416 mcp->mb[1] = cmd_size; 1429 mcp->mb[1] = cmd_size;
@@ -1422,25 +1435,25 @@ qla2x00_send_sns(scsi_qla_host_t *ha, dma_addr_t sns_phys_address,
1422 mcp->in_mb = MBX_0|MBX_1; 1435 mcp->in_mb = MBX_0|MBX_1;
1423 mcp->buf_size = buf_size; 1436 mcp->buf_size = buf_size;
1424 mcp->flags = MBX_DMA_OUT|MBX_DMA_IN; 1437 mcp->flags = MBX_DMA_OUT|MBX_DMA_IN;
1425 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 1438 mcp->tov = (vha->hw->login_timeout * 2) + (vha->hw->login_timeout / 2);
1426 rval = qla2x00_mailbox_command(ha, mcp); 1439 rval = qla2x00_mailbox_command(vha, mcp);
1427 1440
1428 if (rval != QLA_SUCCESS) { 1441 if (rval != QLA_SUCCESS) {
1429 /*EMPTY*/ 1442 /*EMPTY*/
1430 DEBUG(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x " 1443 DEBUG(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
1431 "mb[1]=%x.\n", ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 1444 "mb[1]=%x.\n", vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
1432 DEBUG2_3_11(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x " 1445 DEBUG2_3_11(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
1433 "mb[1]=%x.\n", ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 1446 "mb[1]=%x.\n", vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
1434 } else { 1447 } else {
1435 /*EMPTY*/ 1448 /*EMPTY*/
1436 DEBUG11(printk("qla2x00_send_sns(%ld): done.\n", ha->host_no)); 1449 DEBUG11(printk("qla2x00_send_sns(%ld): done.\n", vha->host_no));
1437 } 1450 }
1438 1451
1439 return rval; 1452 return rval;
1440} 1453}
1441 1454
1442int 1455int
1443qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain, 1456qla24xx_login_fabric(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
1444 uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) 1457 uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt)
1445{ 1458{
1446 int rval; 1459 int rval;
@@ -1448,13 +1461,14 @@ qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1448 struct logio_entry_24xx *lg; 1461 struct logio_entry_24xx *lg;
1449 dma_addr_t lg_dma; 1462 dma_addr_t lg_dma;
1450 uint32_t iop[2]; 1463 uint32_t iop[2];
1464 struct qla_hw_data *ha = vha->hw;
1451 1465
1452 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1466 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1453 1467
1454 lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); 1468 lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
1455 if (lg == NULL) { 1469 if (lg == NULL) {
1456 DEBUG2_3(printk("%s(%ld): failed to allocate Login IOCB.\n", 1470 DEBUG2_3(printk("%s(%ld): failed to allocate Login IOCB.\n",
1457 __func__, ha->host_no)); 1471 __func__, vha->host_no));
1458 return QLA_MEMORY_ALLOC_FAILED; 1472 return QLA_MEMORY_ALLOC_FAILED;
1459 } 1473 }
1460 memset(lg, 0, sizeof(struct logio_entry_24xx)); 1474 memset(lg, 0, sizeof(struct logio_entry_24xx));
@@ -1470,14 +1484,14 @@ qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1470 lg->port_id[0] = al_pa; 1484 lg->port_id[0] = al_pa;
1471 lg->port_id[1] = area; 1485 lg->port_id[1] = area;
1472 lg->port_id[2] = domain; 1486 lg->port_id[2] = domain;
1473 lg->vp_index = ha->vp_idx; 1487 lg->vp_index = vha->vp_idx;
1474 rval = qla2x00_issue_iocb(ha, lg, lg_dma, 0); 1488 rval = qla2x00_issue_iocb(vha, lg, lg_dma, 0);
1475 if (rval != QLA_SUCCESS) { 1489 if (rval != QLA_SUCCESS) {
1476 DEBUG2_3_11(printk("%s(%ld): failed to issue Login IOCB " 1490 DEBUG2_3_11(printk("%s(%ld): failed to issue Login IOCB "
1477 "(%x).\n", __func__, ha->host_no, rval)); 1491 "(%x).\n", __func__, vha->host_no, rval));
1478 } else if (lg->entry_status != 0) { 1492 } else if (lg->entry_status != 0) {
1479 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 1493 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1480 "-- error status (%x).\n", __func__, ha->host_no, 1494 "-- error status (%x).\n", __func__, vha->host_no,
1481 lg->entry_status)); 1495 lg->entry_status));
1482 rval = QLA_FUNCTION_FAILED; 1496 rval = QLA_FUNCTION_FAILED;
1483 } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { 1497 } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
@@ -1486,7 +1500,7 @@ qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1486 1500
1487 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 1501 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1488 "-- completion status (%x) ioparam=%x/%x.\n", __func__, 1502 "-- completion status (%x) ioparam=%x/%x.\n", __func__,
1489 ha->host_no, le16_to_cpu(lg->comp_status), iop[0], 1503 vha->host_no, le16_to_cpu(lg->comp_status), iop[0],
1490 iop[1])); 1504 iop[1]));
1491 1505
1492 switch (iop[0]) { 1506 switch (iop[0]) {
@@ -1515,7 +1529,7 @@ qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1515 break; 1529 break;
1516 } 1530 }
1517 } else { 1531 } else {
1518 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 1532 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
1519 1533
1520 iop[0] = le32_to_cpu(lg->io_parameter[0]); 1534 iop[0] = le32_to_cpu(lg->io_parameter[0]);
1521 1535
@@ -1562,14 +1576,15 @@ qla24xx_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1562 * Kernel context. 1576 * Kernel context.
1563 */ 1577 */
1564int 1578int
1565qla2x00_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain, 1579qla2x00_login_fabric(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
1566 uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt) 1580 uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt)
1567{ 1581{
1568 int rval; 1582 int rval;
1569 mbx_cmd_t mc; 1583 mbx_cmd_t mc;
1570 mbx_cmd_t *mcp = &mc; 1584 mbx_cmd_t *mcp = &mc;
1585 struct qla_hw_data *ha = vha->hw;
1571 1586
1572 DEBUG11(printk("qla2x00_login_fabric(%ld): entered.\n", ha->host_no)); 1587 DEBUG11(printk("qla2x00_login_fabric(%ld): entered.\n", vha->host_no));
1573 1588
1574 mcp->mb[0] = MBC_LOGIN_FABRIC_PORT; 1589 mcp->mb[0] = MBC_LOGIN_FABRIC_PORT;
1575 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1590 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
@@ -1586,7 +1601,7 @@ qla2x00_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1586 mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0; 1601 mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0;
1587 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 1602 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
1588 mcp->flags = 0; 1603 mcp->flags = 0;
1589 rval = qla2x00_mailbox_command(ha, mcp); 1604 rval = qla2x00_mailbox_command(vha, mcp);
1590 1605
1591 /* Return mailbox statuses. */ 1606 /* Return mailbox statuses. */
1592 if (mb != NULL) { 1607 if (mb != NULL) {
@@ -1613,12 +1628,12 @@ qla2x00_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1613 1628
1614 /*EMPTY*/ 1629 /*EMPTY*/
1615 DEBUG2_3_11(printk("qla2x00_login_fabric(%ld): failed=%x " 1630 DEBUG2_3_11(printk("qla2x00_login_fabric(%ld): failed=%x "
1616 "mb[0]=%x mb[1]=%x mb[2]=%x.\n", ha->host_no, rval, 1631 "mb[0]=%x mb[1]=%x mb[2]=%x.\n", vha->host_no, rval,
1617 mcp->mb[0], mcp->mb[1], mcp->mb[2])); 1632 mcp->mb[0], mcp->mb[1], mcp->mb[2]));
1618 } else { 1633 } else {
1619 /*EMPTY*/ 1634 /*EMPTY*/
1620 DEBUG11(printk("qla2x00_login_fabric(%ld): done.\n", 1635 DEBUG11(printk("qla2x00_login_fabric(%ld): done.\n",
1621 ha->host_no)); 1636 vha->host_no));
1622 } 1637 }
1623 1638
1624 return rval; 1639 return rval;
@@ -1641,19 +1656,20 @@ qla2x00_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1641 * 1656 *
1642 */ 1657 */
1643int 1658int
1644qla2x00_login_local_device(scsi_qla_host_t *ha, fc_port_t *fcport, 1659qla2x00_login_local_device(scsi_qla_host_t *vha, fc_port_t *fcport,
1645 uint16_t *mb_ret, uint8_t opt) 1660 uint16_t *mb_ret, uint8_t opt)
1646{ 1661{
1647 int rval; 1662 int rval;
1648 mbx_cmd_t mc; 1663 mbx_cmd_t mc;
1649 mbx_cmd_t *mcp = &mc; 1664 mbx_cmd_t *mcp = &mc;
1665 struct qla_hw_data *ha = vha->hw;
1650 1666
1651 if (IS_FWI2_CAPABLE(ha)) 1667 if (IS_FWI2_CAPABLE(ha))
1652 return qla24xx_login_fabric(ha, fcport->loop_id, 1668 return qla24xx_login_fabric(vha, fcport->loop_id,
1653 fcport->d_id.b.domain, fcport->d_id.b.area, 1669 fcport->d_id.b.domain, fcport->d_id.b.area,
1654 fcport->d_id.b.al_pa, mb_ret, opt); 1670 fcport->d_id.b.al_pa, mb_ret, opt);
1655 1671
1656 DEBUG3(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1672 DEBUG3(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1657 1673
1658 mcp->mb[0] = MBC_LOGIN_LOOP_PORT; 1674 mcp->mb[0] = MBC_LOGIN_LOOP_PORT;
1659 if (HAS_EXTENDED_IDS(ha)) 1675 if (HAS_EXTENDED_IDS(ha))
@@ -1665,7 +1681,7 @@ qla2x00_login_local_device(scsi_qla_host_t *ha, fc_port_t *fcport,
1665 mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0; 1681 mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0;
1666 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 1682 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
1667 mcp->flags = 0; 1683 mcp->flags = 0;
1668 rval = qla2x00_mailbox_command(ha, mcp); 1684 rval = qla2x00_mailbox_command(vha, mcp);
1669 1685
1670 /* Return mailbox statuses. */ 1686 /* Return mailbox statuses. */
1671 if (mb_ret != NULL) { 1687 if (mb_ret != NULL) {
@@ -1686,33 +1702,34 @@ qla2x00_login_local_device(scsi_qla_host_t *ha, fc_port_t *fcport,
1686 rval = QLA_SUCCESS; 1702 rval = QLA_SUCCESS;
1687 1703
1688 DEBUG(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x " 1704 DEBUG(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
1689 "mb[6]=%x mb[7]=%x.\n", __func__, ha->host_no, rval, 1705 "mb[6]=%x mb[7]=%x.\n", __func__, vha->host_no, rval,
1690 mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7])); 1706 mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]));
1691 DEBUG2_3(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x " 1707 DEBUG2_3(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
1692 "mb[6]=%x mb[7]=%x.\n", __func__, ha->host_no, rval, 1708 "mb[6]=%x mb[7]=%x.\n", __func__, vha->host_no, rval,
1693 mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7])); 1709 mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]));
1694 } else { 1710 } else {
1695 /*EMPTY*/ 1711 /*EMPTY*/
1696 DEBUG3(printk("%s(%ld): done.\n", __func__, ha->host_no)); 1712 DEBUG3(printk("%s(%ld): done.\n", __func__, vha->host_no));
1697 } 1713 }
1698 1714
1699 return (rval); 1715 return (rval);
1700} 1716}
1701 1717
1702int 1718int
1703qla24xx_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain, 1719qla24xx_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
1704 uint8_t area, uint8_t al_pa) 1720 uint8_t area, uint8_t al_pa)
1705{ 1721{
1706 int rval; 1722 int rval;
1707 struct logio_entry_24xx *lg; 1723 struct logio_entry_24xx *lg;
1708 dma_addr_t lg_dma; 1724 dma_addr_t lg_dma;
1725 struct qla_hw_data *ha = vha->hw;
1709 1726
1710 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1727 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1711 1728
1712 lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); 1729 lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
1713 if (lg == NULL) { 1730 if (lg == NULL) {
1714 DEBUG2_3(printk("%s(%ld): failed to allocate Logout IOCB.\n", 1731 DEBUG2_3(printk("%s(%ld): failed to allocate Logout IOCB.\n",
1715 __func__, ha->host_no)); 1732 __func__, vha->host_no));
1716 return QLA_MEMORY_ALLOC_FAILED; 1733 return QLA_MEMORY_ALLOC_FAILED;
1717 } 1734 }
1718 memset(lg, 0, sizeof(struct logio_entry_24xx)); 1735 memset(lg, 0, sizeof(struct logio_entry_24xx));
@@ -1725,25 +1742,25 @@ qla24xx_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1725 lg->port_id[0] = al_pa; 1742 lg->port_id[0] = al_pa;
1726 lg->port_id[1] = area; 1743 lg->port_id[1] = area;
1727 lg->port_id[2] = domain; 1744 lg->port_id[2] = domain;
1728 lg->vp_index = ha->vp_idx; 1745 lg->vp_index = vha->vp_idx;
1729 rval = qla2x00_issue_iocb(ha, lg, lg_dma, 0); 1746 rval = qla2x00_issue_iocb(vha, lg, lg_dma, 0);
1730 if (rval != QLA_SUCCESS) { 1747 if (rval != QLA_SUCCESS) {
1731 DEBUG2_3_11(printk("%s(%ld): failed to issue Logout IOCB " 1748 DEBUG2_3_11(printk("%s(%ld): failed to issue Logout IOCB "
1732 "(%x).\n", __func__, ha->host_no, rval)); 1749 "(%x).\n", __func__, vha->host_no, rval));
1733 } else if (lg->entry_status != 0) { 1750 } else if (lg->entry_status != 0) {
1734 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 1751 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1735 "-- error status (%x).\n", __func__, ha->host_no, 1752 "-- error status (%x).\n", __func__, vha->host_no,
1736 lg->entry_status)); 1753 lg->entry_status));
1737 rval = QLA_FUNCTION_FAILED; 1754 rval = QLA_FUNCTION_FAILED;
1738 } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { 1755 } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
1739 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 1756 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1740 "-- completion status (%x) ioparam=%x/%x.\n", __func__, 1757 "-- completion status (%x) ioparam=%x/%x.\n", __func__,
1741 ha->host_no, le16_to_cpu(lg->comp_status), 1758 vha->host_no, le16_to_cpu(lg->comp_status),
1742 le32_to_cpu(lg->io_parameter[0]), 1759 le32_to_cpu(lg->io_parameter[0]),
1743 le32_to_cpu(lg->io_parameter[1]))); 1760 le32_to_cpu(lg->io_parameter[1])));
1744 } else { 1761 } else {
1745 /*EMPTY*/ 1762 /*EMPTY*/
1746 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 1763 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
1747 } 1764 }
1748 1765
1749 dma_pool_free(ha->s_dma_pool, lg, lg_dma); 1766 dma_pool_free(ha->s_dma_pool, lg, lg_dma);
@@ -1768,7 +1785,7 @@ qla24xx_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1768 * Kernel context. 1785 * Kernel context.
1769 */ 1786 */
1770int 1787int
1771qla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain, 1788qla2x00_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
1772 uint8_t area, uint8_t al_pa) 1789 uint8_t area, uint8_t al_pa)
1773{ 1790{
1774 int rval; 1791 int rval;
@@ -1776,11 +1793,11 @@ qla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1776 mbx_cmd_t *mcp = &mc; 1793 mbx_cmd_t *mcp = &mc;
1777 1794
1778 DEBUG11(printk("qla2x00_fabric_logout(%ld): entered.\n", 1795 DEBUG11(printk("qla2x00_fabric_logout(%ld): entered.\n",
1779 ha->host_no)); 1796 vha->host_no));
1780 1797
1781 mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT; 1798 mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT;
1782 mcp->out_mb = MBX_1|MBX_0; 1799 mcp->out_mb = MBX_1|MBX_0;
1783 if (HAS_EXTENDED_IDS(ha)) { 1800 if (HAS_EXTENDED_IDS(vha->hw)) {
1784 mcp->mb[1] = loop_id; 1801 mcp->mb[1] = loop_id;
1785 mcp->mb[10] = 0; 1802 mcp->mb[10] = 0;
1786 mcp->out_mb |= MBX_10; 1803 mcp->out_mb |= MBX_10;
@@ -1791,16 +1808,16 @@ qla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1791 mcp->in_mb = MBX_1|MBX_0; 1808 mcp->in_mb = MBX_1|MBX_0;
1792 mcp->tov = MBX_TOV_SECONDS; 1809 mcp->tov = MBX_TOV_SECONDS;
1793 mcp->flags = 0; 1810 mcp->flags = 0;
1794 rval = qla2x00_mailbox_command(ha, mcp); 1811 rval = qla2x00_mailbox_command(vha, mcp);
1795 1812
1796 if (rval != QLA_SUCCESS) { 1813 if (rval != QLA_SUCCESS) {
1797 /*EMPTY*/ 1814 /*EMPTY*/
1798 DEBUG2_3_11(printk("qla2x00_fabric_logout(%ld): failed=%x " 1815 DEBUG2_3_11(printk("qla2x00_fabric_logout(%ld): failed=%x "
1799 "mbx1=%x.\n", ha->host_no, rval, mcp->mb[1])); 1816 "mbx1=%x.\n", vha->host_no, rval, mcp->mb[1]));
1800 } else { 1817 } else {
1801 /*EMPTY*/ 1818 /*EMPTY*/
1802 DEBUG11(printk("qla2x00_fabric_logout(%ld): done.\n", 1819 DEBUG11(printk("qla2x00_fabric_logout(%ld): done.\n",
1803 ha->host_no)); 1820 vha->host_no));
1804 } 1821 }
1805 1822
1806 return rval; 1823 return rval;
@@ -1822,33 +1839,33 @@ qla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
1822 * Kernel context. 1839 * Kernel context.
1823 */ 1840 */
1824int 1841int
1825qla2x00_full_login_lip(scsi_qla_host_t *ha) 1842qla2x00_full_login_lip(scsi_qla_host_t *vha)
1826{ 1843{
1827 int rval; 1844 int rval;
1828 mbx_cmd_t mc; 1845 mbx_cmd_t mc;
1829 mbx_cmd_t *mcp = &mc; 1846 mbx_cmd_t *mcp = &mc;
1830 1847
1831 DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n", 1848 DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n",
1832 ha->host_no)); 1849 vha->host_no));
1833 1850
1834 mcp->mb[0] = MBC_LIP_FULL_LOGIN; 1851 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
1835 mcp->mb[1] = IS_FWI2_CAPABLE(ha) ? BIT_3: 0; 1852 mcp->mb[1] = IS_FWI2_CAPABLE(vha->hw) ? BIT_3 : 0;
1836 mcp->mb[2] = 0; 1853 mcp->mb[2] = 0;
1837 mcp->mb[3] = 0; 1854 mcp->mb[3] = 0;
1838 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1855 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
1839 mcp->in_mb = MBX_0; 1856 mcp->in_mb = MBX_0;
1840 mcp->tov = MBX_TOV_SECONDS; 1857 mcp->tov = MBX_TOV_SECONDS;
1841 mcp->flags = 0; 1858 mcp->flags = 0;
1842 rval = qla2x00_mailbox_command(ha, mcp); 1859 rval = qla2x00_mailbox_command(vha, mcp);
1843 1860
1844 if (rval != QLA_SUCCESS) { 1861 if (rval != QLA_SUCCESS) {
1845 /*EMPTY*/ 1862 /*EMPTY*/
1846 DEBUG2_3_11(printk("qla2x00_full_login_lip(%ld): failed=%x.\n", 1863 DEBUG2_3_11(printk("qla2x00_full_login_lip(%ld): failed=%x.\n",
1847 ha->host_no, rval)); 1864 vha->host_no, rval));
1848 } else { 1865 } else {
1849 /*EMPTY*/ 1866 /*EMPTY*/
1850 DEBUG11(printk("qla2x00_full_login_lip(%ld): done.\n", 1867 DEBUG11(printk("qla2x00_full_login_lip(%ld): done.\n",
1851 ha->host_no)); 1868 vha->host_no));
1852 } 1869 }
1853 1870
1854 return rval; 1871 return rval;
@@ -1867,7 +1884,7 @@ qla2x00_full_login_lip(scsi_qla_host_t *ha)
1867 * Kernel context. 1884 * Kernel context.
1868 */ 1885 */
1869int 1886int
1870qla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma, 1887qla2x00_get_id_list(scsi_qla_host_t *vha, void *id_list, dma_addr_t id_list_dma,
1871 uint16_t *entries) 1888 uint16_t *entries)
1872{ 1889{
1873 int rval; 1890 int rval;
@@ -1875,20 +1892,20 @@ qla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma,
1875 mbx_cmd_t *mcp = &mc; 1892 mbx_cmd_t *mcp = &mc;
1876 1893
1877 DEBUG11(printk("qla2x00_get_id_list(%ld): entered.\n", 1894 DEBUG11(printk("qla2x00_get_id_list(%ld): entered.\n",
1878 ha->host_no)); 1895 vha->host_no));
1879 1896
1880 if (id_list == NULL) 1897 if (id_list == NULL)
1881 return QLA_FUNCTION_FAILED; 1898 return QLA_FUNCTION_FAILED;
1882 1899
1883 mcp->mb[0] = MBC_GET_ID_LIST; 1900 mcp->mb[0] = MBC_GET_ID_LIST;
1884 mcp->out_mb = MBX_0; 1901 mcp->out_mb = MBX_0;
1885 if (IS_FWI2_CAPABLE(ha)) { 1902 if (IS_FWI2_CAPABLE(vha->hw)) {
1886 mcp->mb[2] = MSW(id_list_dma); 1903 mcp->mb[2] = MSW(id_list_dma);
1887 mcp->mb[3] = LSW(id_list_dma); 1904 mcp->mb[3] = LSW(id_list_dma);
1888 mcp->mb[6] = MSW(MSD(id_list_dma)); 1905 mcp->mb[6] = MSW(MSD(id_list_dma));
1889 mcp->mb[7] = LSW(MSD(id_list_dma)); 1906 mcp->mb[7] = LSW(MSD(id_list_dma));
1890 mcp->mb[8] = 0; 1907 mcp->mb[8] = 0;
1891 mcp->mb[9] = ha->vp_idx; 1908 mcp->mb[9] = vha->vp_idx;
1892 mcp->out_mb |= MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2; 1909 mcp->out_mb |= MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2;
1893 } else { 1910 } else {
1894 mcp->mb[1] = MSW(id_list_dma); 1911 mcp->mb[1] = MSW(id_list_dma);
@@ -1900,16 +1917,16 @@ qla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma,
1900 mcp->in_mb = MBX_1|MBX_0; 1917 mcp->in_mb = MBX_1|MBX_0;
1901 mcp->tov = MBX_TOV_SECONDS; 1918 mcp->tov = MBX_TOV_SECONDS;
1902 mcp->flags = 0; 1919 mcp->flags = 0;
1903 rval = qla2x00_mailbox_command(ha, mcp); 1920 rval = qla2x00_mailbox_command(vha, mcp);
1904 1921
1905 if (rval != QLA_SUCCESS) { 1922 if (rval != QLA_SUCCESS) {
1906 /*EMPTY*/ 1923 /*EMPTY*/
1907 DEBUG2_3_11(printk("qla2x00_get_id_list(%ld): failed=%x.\n", 1924 DEBUG2_3_11(printk("qla2x00_get_id_list(%ld): failed=%x.\n",
1908 ha->host_no, rval)); 1925 vha->host_no, rval));
1909 } else { 1926 } else {
1910 *entries = mcp->mb[1]; 1927 *entries = mcp->mb[1];
1911 DEBUG11(printk("qla2x00_get_id_list(%ld): done.\n", 1928 DEBUG11(printk("qla2x00_get_id_list(%ld): done.\n",
1912 ha->host_no)); 1929 vha->host_no));
1913 } 1930 }
1914 1931
1915 return rval; 1932 return rval;
@@ -1929,7 +1946,7 @@ qla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma,
1929 * Kernel context. 1946 * Kernel context.
1930 */ 1947 */
1931int 1948int
1932qla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt, 1949qla2x00_get_resource_cnts(scsi_qla_host_t *vha, uint16_t *cur_xchg_cnt,
1933 uint16_t *orig_xchg_cnt, uint16_t *cur_iocb_cnt, 1950 uint16_t *orig_xchg_cnt, uint16_t *cur_iocb_cnt,
1934 uint16_t *orig_iocb_cnt, uint16_t *max_npiv_vports) 1951 uint16_t *orig_iocb_cnt, uint16_t *max_npiv_vports)
1935{ 1952{
@@ -1937,22 +1954,22 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt,
1937 mbx_cmd_t mc; 1954 mbx_cmd_t mc;
1938 mbx_cmd_t *mcp = &mc; 1955 mbx_cmd_t *mcp = &mc;
1939 1956
1940 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1957 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1941 1958
1942 mcp->mb[0] = MBC_GET_RESOURCE_COUNTS; 1959 mcp->mb[0] = MBC_GET_RESOURCE_COUNTS;
1943 mcp->out_mb = MBX_0; 1960 mcp->out_mb = MBX_0;
1944 mcp->in_mb = MBX_11|MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 1961 mcp->in_mb = MBX_11|MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
1945 mcp->tov = MBX_TOV_SECONDS; 1962 mcp->tov = MBX_TOV_SECONDS;
1946 mcp->flags = 0; 1963 mcp->flags = 0;
1947 rval = qla2x00_mailbox_command(ha, mcp); 1964 rval = qla2x00_mailbox_command(vha, mcp);
1948 1965
1949 if (rval != QLA_SUCCESS) { 1966 if (rval != QLA_SUCCESS) {
1950 /*EMPTY*/ 1967 /*EMPTY*/
1951 DEBUG2_3_11(printk("%s(%ld): failed = %x.\n", __func__, 1968 DEBUG2_3_11(printk("%s(%ld): failed = %x.\n", __func__,
1952 ha->host_no, mcp->mb[0])); 1969 vha->host_no, mcp->mb[0]));
1953 } else { 1970 } else {
1954 DEBUG11(printk("%s(%ld): done. mb1=%x mb2=%x mb3=%x mb6=%x " 1971 DEBUG11(printk("%s(%ld): done. mb1=%x mb2=%x mb3=%x mb6=%x "
1955 "mb7=%x mb10=%x mb11=%x.\n", __func__, ha->host_no, 1972 "mb7=%x mb10=%x mb11=%x.\n", __func__, vha->host_no,
1956 mcp->mb[1], mcp->mb[2], mcp->mb[3], mcp->mb[6], mcp->mb[7], 1973 mcp->mb[1], mcp->mb[2], mcp->mb[3], mcp->mb[6], mcp->mb[7],
1957 mcp->mb[10], mcp->mb[11])); 1974 mcp->mb[10], mcp->mb[11]));
1958 1975
@@ -1964,7 +1981,7 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt,
1964 *cur_iocb_cnt = mcp->mb[7]; 1981 *cur_iocb_cnt = mcp->mb[7];
1965 if (orig_iocb_cnt) 1982 if (orig_iocb_cnt)
1966 *orig_iocb_cnt = mcp->mb[10]; 1983 *orig_iocb_cnt = mcp->mb[10];
1967 if (ha->flags.npiv_supported && max_npiv_vports) 1984 if (vha->hw->flags.npiv_supported && max_npiv_vports)
1968 *max_npiv_vports = mcp->mb[11]; 1985 *max_npiv_vports = mcp->mb[11];
1969 } 1986 }
1970 1987
@@ -1987,18 +2004,19 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt,
1987 * Kernel context. 2004 * Kernel context.
1988 */ 2005 */
1989int 2006int
1990qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map) 2007qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map)
1991{ 2008{
1992 int rval; 2009 int rval;
1993 mbx_cmd_t mc; 2010 mbx_cmd_t mc;
1994 mbx_cmd_t *mcp = &mc; 2011 mbx_cmd_t *mcp = &mc;
1995 char *pmap; 2012 char *pmap;
1996 dma_addr_t pmap_dma; 2013 dma_addr_t pmap_dma;
2014 struct qla_hw_data *ha = vha->hw;
1997 2015
1998 pmap = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma); 2016 pmap = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma);
1999 if (pmap == NULL) { 2017 if (pmap == NULL) {
2000 DEBUG2_3_11(printk("%s(%ld): **** Mem Alloc Failed ****", 2018 DEBUG2_3_11(printk("%s(%ld): **** Mem Alloc Failed ****",
2001 __func__, ha->host_no)); 2019 __func__, vha->host_no));
2002 return QLA_MEMORY_ALLOC_FAILED; 2020 return QLA_MEMORY_ALLOC_FAILED;
2003 } 2021 }
2004 memset(pmap, 0, FCAL_MAP_SIZE); 2022 memset(pmap, 0, FCAL_MAP_SIZE);
@@ -2013,11 +2031,11 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map)
2013 mcp->buf_size = FCAL_MAP_SIZE; 2031 mcp->buf_size = FCAL_MAP_SIZE;
2014 mcp->flags = MBX_DMA_IN; 2032 mcp->flags = MBX_DMA_IN;
2015 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 2033 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
2016 rval = qla2x00_mailbox_command(ha, mcp); 2034 rval = qla2x00_mailbox_command(vha, mcp);
2017 2035
2018 if (rval == QLA_SUCCESS) { 2036 if (rval == QLA_SUCCESS) {
2019 DEBUG11(printk("%s(%ld): (mb0=%x/mb1=%x) FC/AL Position Map " 2037 DEBUG11(printk("%s(%ld): (mb0=%x/mb1=%x) FC/AL Position Map "
2020 "size (%x)\n", __func__, ha->host_no, mcp->mb[0], 2038 "size (%x)\n", __func__, vha->host_no, mcp->mb[0],
2021 mcp->mb[1], (unsigned)pmap[0])); 2039 mcp->mb[1], (unsigned)pmap[0]));
2022 DEBUG11(qla2x00_dump_buffer(pmap, pmap[0] + 1)); 2040 DEBUG11(qla2x00_dump_buffer(pmap, pmap[0] + 1));
2023 2041
@@ -2028,9 +2046,9 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map)
2028 2046
2029 if (rval != QLA_SUCCESS) { 2047 if (rval != QLA_SUCCESS) {
2030 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2048 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2031 ha->host_no, rval)); 2049 vha->host_no, rval));
2032 } else { 2050 } else {
2033 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2051 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2034 } 2052 }
2035 2053
2036 return rval; 2054 return rval;
@@ -2051,15 +2069,16 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map)
2051 * BIT_1 = mailbox error. 2069 * BIT_1 = mailbox error.
2052 */ 2070 */
2053int 2071int
2054qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id, 2072qla2x00_get_link_status(scsi_qla_host_t *vha, uint16_t loop_id,
2055 struct link_statistics *stats, dma_addr_t stats_dma) 2073 struct link_statistics *stats, dma_addr_t stats_dma)
2056{ 2074{
2057 int rval; 2075 int rval;
2058 mbx_cmd_t mc; 2076 mbx_cmd_t mc;
2059 mbx_cmd_t *mcp = &mc; 2077 mbx_cmd_t *mcp = &mc;
2060 uint32_t *siter, *diter, dwords; 2078 uint32_t *siter, *diter, dwords;
2079 struct qla_hw_data *ha = vha->hw;
2061 2080
2062 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2081 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2063 2082
2064 mcp->mb[0] = MBC_GET_LINK_STATUS; 2083 mcp->mb[0] = MBC_GET_LINK_STATUS;
2065 mcp->mb[2] = MSW(stats_dma); 2084 mcp->mb[2] = MSW(stats_dma);
@@ -2084,12 +2103,12 @@ qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
2084 } 2103 }
2085 mcp->tov = MBX_TOV_SECONDS; 2104 mcp->tov = MBX_TOV_SECONDS;
2086 mcp->flags = IOCTL_CMD; 2105 mcp->flags = IOCTL_CMD;
2087 rval = qla2x00_mailbox_command(ha, mcp); 2106 rval = qla2x00_mailbox_command(vha, mcp);
2088 2107
2089 if (rval == QLA_SUCCESS) { 2108 if (rval == QLA_SUCCESS) {
2090 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { 2109 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
2091 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n", 2110 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2092 __func__, ha->host_no, mcp->mb[0])); 2111 __func__, vha->host_no, mcp->mb[0]));
2093 rval = QLA_FUNCTION_FAILED; 2112 rval = QLA_FUNCTION_FAILED;
2094 } else { 2113 } else {
2095 /* Copy over data -- firmware data is LE. */ 2114 /* Copy over data -- firmware data is LE. */
@@ -2101,14 +2120,14 @@ qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
2101 } else { 2120 } else {
2102 /* Failed. */ 2121 /* Failed. */
2103 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2122 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2104 ha->host_no, rval)); 2123 vha->host_no, rval));
2105 } 2124 }
2106 2125
2107 return rval; 2126 return rval;
2108} 2127}
2109 2128
2110int 2129int
2111qla24xx_get_isp_stats(scsi_qla_host_t *ha, struct link_statistics *stats, 2130qla24xx_get_isp_stats(scsi_qla_host_t *vha, struct link_statistics *stats,
2112 dma_addr_t stats_dma) 2131 dma_addr_t stats_dma)
2113{ 2132{
2114 int rval; 2133 int rval;
@@ -2116,7 +2135,7 @@ qla24xx_get_isp_stats(scsi_qla_host_t *ha, struct link_statistics *stats,
2116 mbx_cmd_t *mcp = &mc; 2135 mbx_cmd_t *mcp = &mc;
2117 uint32_t *siter, *diter, dwords; 2136 uint32_t *siter, *diter, dwords;
2118 2137
2119 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2138 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2120 2139
2121 mcp->mb[0] = MBC_GET_LINK_PRIV_STATS; 2140 mcp->mb[0] = MBC_GET_LINK_PRIV_STATS;
2122 mcp->mb[2] = MSW(stats_dma); 2141 mcp->mb[2] = MSW(stats_dma);
@@ -2124,18 +2143,18 @@ qla24xx_get_isp_stats(scsi_qla_host_t *ha, struct link_statistics *stats,
2124 mcp->mb[6] = MSW(MSD(stats_dma)); 2143 mcp->mb[6] = MSW(MSD(stats_dma));
2125 mcp->mb[7] = LSW(MSD(stats_dma)); 2144 mcp->mb[7] = LSW(MSD(stats_dma));
2126 mcp->mb[8] = sizeof(struct link_statistics) / 4; 2145 mcp->mb[8] = sizeof(struct link_statistics) / 4;
2127 mcp->mb[9] = ha->vp_idx; 2146 mcp->mb[9] = vha->vp_idx;
2128 mcp->mb[10] = 0; 2147 mcp->mb[10] = 0;
2129 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 2148 mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
2130 mcp->in_mb = MBX_2|MBX_1|MBX_0; 2149 mcp->in_mb = MBX_2|MBX_1|MBX_0;
2131 mcp->tov = MBX_TOV_SECONDS; 2150 mcp->tov = MBX_TOV_SECONDS;
2132 mcp->flags = IOCTL_CMD; 2151 mcp->flags = IOCTL_CMD;
2133 rval = qla2x00_mailbox_command(ha, mcp); 2152 rval = qla2x00_mailbox_command(vha, mcp);
2134 2153
2135 if (rval == QLA_SUCCESS) { 2154 if (rval == QLA_SUCCESS) {
2136 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { 2155 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
2137 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n", 2156 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2138 __func__, ha->host_no, mcp->mb[0])); 2157 __func__, vha->host_no, mcp->mb[0]));
2139 rval = QLA_FUNCTION_FAILED; 2158 rval = QLA_FUNCTION_FAILED;
2140 } else { 2159 } else {
2141 /* Copy over data -- firmware data is LE. */ 2160 /* Copy over data -- firmware data is LE. */
@@ -2147,14 +2166,14 @@ qla24xx_get_isp_stats(scsi_qla_host_t *ha, struct link_statistics *stats,
2147 } else { 2166 } else {
2148 /* Failed. */ 2167 /* Failed. */
2149 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2168 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2150 ha->host_no, rval)); 2169 vha->host_no, rval));
2151 } 2170 }
2152 2171
2153 return rval; 2172 return rval;
2154} 2173}
2155 2174
2156int 2175int
2157qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp) 2176qla24xx_abort_command(scsi_qla_host_t *vha, srb_t *sp)
2158{ 2177{
2159 int rval; 2178 int rval;
2160 fc_port_t *fcport; 2179 fc_port_t *fcport;
@@ -2163,18 +2182,19 @@ qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp)
2163 struct abort_entry_24xx *abt; 2182 struct abort_entry_24xx *abt;
2164 dma_addr_t abt_dma; 2183 dma_addr_t abt_dma;
2165 uint32_t handle; 2184 uint32_t handle;
2166 scsi_qla_host_t *pha = to_qla_parent(ha); 2185 struct qla_hw_data *ha = vha->hw;
2186 struct req_que *req = ha->req;
2167 2187
2168 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2188 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2169 2189
2170 fcport = sp->fcport; 2190 fcport = sp->fcport;
2171 2191
2172 spin_lock_irqsave(&pha->hardware_lock, flags); 2192 spin_lock_irqsave(&ha->hardware_lock, flags);
2173 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { 2193 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) {
2174 if (pha->outstanding_cmds[handle] == sp) 2194 if (req->outstanding_cmds[handle] == sp)
2175 break; 2195 break;
2176 } 2196 }
2177 spin_unlock_irqrestore(&pha->hardware_lock, flags); 2197 spin_unlock_irqrestore(&ha->hardware_lock, flags);
2178 if (handle == MAX_OUTSTANDING_COMMANDS) { 2198 if (handle == MAX_OUTSTANDING_COMMANDS) {
2179 /* Command not found. */ 2199 /* Command not found. */
2180 return QLA_FUNCTION_FAILED; 2200 return QLA_FUNCTION_FAILED;
@@ -2183,7 +2203,7 @@ qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp)
2183 abt = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma); 2203 abt = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma);
2184 if (abt == NULL) { 2204 if (abt == NULL) {
2185 DEBUG2_3(printk("%s(%ld): failed to allocate Abort IOCB.\n", 2205 DEBUG2_3(printk("%s(%ld): failed to allocate Abort IOCB.\n",
2186 __func__, ha->host_no)); 2206 __func__, vha->host_no));
2187 return QLA_MEMORY_ALLOC_FAILED; 2207 return QLA_MEMORY_ALLOC_FAILED;
2188 } 2208 }
2189 memset(abt, 0, sizeof(struct abort_entry_24xx)); 2209 memset(abt, 0, sizeof(struct abort_entry_24xx));
@@ -2196,22 +2216,22 @@ qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp)
2196 abt->port_id[1] = fcport->d_id.b.area; 2216 abt->port_id[1] = fcport->d_id.b.area;
2197 abt->port_id[2] = fcport->d_id.b.domain; 2217 abt->port_id[2] = fcport->d_id.b.domain;
2198 abt->vp_index = fcport->vp_idx; 2218 abt->vp_index = fcport->vp_idx;
2199 rval = qla2x00_issue_iocb(ha, abt, abt_dma, 0); 2219 rval = qla2x00_issue_iocb(vha, abt, abt_dma, 0);
2200 if (rval != QLA_SUCCESS) { 2220 if (rval != QLA_SUCCESS) {
2201 DEBUG2_3_11(printk("%s(%ld): failed to issue IOCB (%x).\n", 2221 DEBUG2_3_11(printk("%s(%ld): failed to issue IOCB (%x).\n",
2202 __func__, ha->host_no, rval)); 2222 __func__, vha->host_no, rval));
2203 } else if (abt->entry_status != 0) { 2223 } else if (abt->entry_status != 0) {
2204 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2224 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2205 "-- error status (%x).\n", __func__, ha->host_no, 2225 "-- error status (%x).\n", __func__, vha->host_no,
2206 abt->entry_status)); 2226 abt->entry_status));
2207 rval = QLA_FUNCTION_FAILED; 2227 rval = QLA_FUNCTION_FAILED;
2208 } else if (abt->nport_handle != __constant_cpu_to_le16(0)) { 2228 } else if (abt->nport_handle != __constant_cpu_to_le16(0)) {
2209 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2229 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2210 "-- completion status (%x).\n", __func__, ha->host_no, 2230 "-- completion status (%x).\n", __func__, vha->host_no,
2211 le16_to_cpu(abt->nport_handle))); 2231 le16_to_cpu(abt->nport_handle)));
2212 rval = QLA_FUNCTION_FAILED; 2232 rval = QLA_FUNCTION_FAILED;
2213 } else { 2233 } else {
2214 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2234 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2215 } 2235 }
2216 2236
2217 dma_pool_free(ha->s_dma_pool, abt, abt_dma); 2237 dma_pool_free(ha->s_dma_pool, abt, abt_dma);
@@ -2233,16 +2253,17 @@ __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport,
2233 int rval, rval2; 2253 int rval, rval2;
2234 struct tsk_mgmt_cmd *tsk; 2254 struct tsk_mgmt_cmd *tsk;
2235 dma_addr_t tsk_dma; 2255 dma_addr_t tsk_dma;
2236 scsi_qla_host_t *ha, *pha; 2256 scsi_qla_host_t *vha;
2257 struct qla_hw_data *ha;
2237 2258
2238 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no)); 2259 DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no));
2239 2260
2240 ha = fcport->ha; 2261 vha = fcport->vha;
2241 pha = to_qla_parent(ha); 2262 ha = vha->hw;
2242 tsk = dma_pool_alloc(pha->s_dma_pool, GFP_KERNEL, &tsk_dma); 2263 tsk = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma);
2243 if (tsk == NULL) { 2264 if (tsk == NULL) {
2244 DEBUG2_3(printk("%s(%ld): failed to allocate Task Management " 2265 DEBUG2_3(printk("%s(%ld): failed to allocate Task Management "
2245 "IOCB.\n", __func__, ha->host_no)); 2266 "IOCB.\n", __func__, vha->host_no));
2246 return QLA_MEMORY_ALLOC_FAILED; 2267 return QLA_MEMORY_ALLOC_FAILED;
2247 } 2268 }
2248 memset(tsk, 0, sizeof(struct tsk_mgmt_cmd)); 2269 memset(tsk, 0, sizeof(struct tsk_mgmt_cmd));
@@ -2262,34 +2283,34 @@ __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport,
2262 sizeof(tsk->p.tsk.lun)); 2283 sizeof(tsk->p.tsk.lun));
2263 } 2284 }
2264 2285
2265 rval = qla2x00_issue_iocb(ha, tsk, tsk_dma, 0); 2286 rval = qla2x00_issue_iocb(vha, tsk, tsk_dma, 0);
2266 if (rval != QLA_SUCCESS) { 2287 if (rval != QLA_SUCCESS) {
2267 DEBUG2_3_11(printk("%s(%ld): failed to issue %s Reset IOCB " 2288 DEBUG2_3_11(printk("%s(%ld): failed to issue %s Reset IOCB "
2268 "(%x).\n", __func__, ha->host_no, name, rval)); 2289 "(%x).\n", __func__, vha->host_no, name, rval));
2269 } else if (tsk->p.sts.entry_status != 0) { 2290 } else if (tsk->p.sts.entry_status != 0) {
2270 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2291 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2271 "-- error status (%x).\n", __func__, ha->host_no, 2292 "-- error status (%x).\n", __func__, vha->host_no,
2272 tsk->p.sts.entry_status)); 2293 tsk->p.sts.entry_status));
2273 rval = QLA_FUNCTION_FAILED; 2294 rval = QLA_FUNCTION_FAILED;
2274 } else if (tsk->p.sts.comp_status != 2295 } else if (tsk->p.sts.comp_status !=
2275 __constant_cpu_to_le16(CS_COMPLETE)) { 2296 __constant_cpu_to_le16(CS_COMPLETE)) {
2276 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2297 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2277 "-- completion status (%x).\n", __func__, 2298 "-- completion status (%x).\n", __func__,
2278 ha->host_no, le16_to_cpu(tsk->p.sts.comp_status))); 2299 vha->host_no, le16_to_cpu(tsk->p.sts.comp_status)));
2279 rval = QLA_FUNCTION_FAILED; 2300 rval = QLA_FUNCTION_FAILED;
2280 } 2301 }
2281 2302
2282 /* Issue marker IOCB. */ 2303 /* Issue marker IOCB. */
2283 rval2 = qla2x00_marker(ha, fcport->loop_id, l, 2304 rval2 = qla2x00_marker(vha, fcport->loop_id, l,
2284 type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID); 2305 type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID);
2285 if (rval2 != QLA_SUCCESS) { 2306 if (rval2 != QLA_SUCCESS) {
2286 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB " 2307 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
2287 "(%x).\n", __func__, ha->host_no, rval2)); 2308 "(%x).\n", __func__, vha->host_no, rval2));
2288 } else { 2309 } else {
2289 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2310 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2290 } 2311 }
2291 2312
2292 dma_pool_free(pha->s_dma_pool, tsk, tsk_dma); 2313 dma_pool_free(ha->s_dma_pool, tsk, tsk_dma);
2293 2314
2294 return rval; 2315 return rval;
2295} 2316}
@@ -2307,29 +2328,30 @@ qla24xx_lun_reset(struct fc_port *fcport, unsigned int l)
2307} 2328}
2308 2329
2309int 2330int
2310qla2x00_system_error(scsi_qla_host_t *ha) 2331qla2x00_system_error(scsi_qla_host_t *vha)
2311{ 2332{
2312 int rval; 2333 int rval;
2313 mbx_cmd_t mc; 2334 mbx_cmd_t mc;
2314 mbx_cmd_t *mcp = &mc; 2335 mbx_cmd_t *mcp = &mc;
2336 struct qla_hw_data *ha = vha->hw;
2315 2337
2316 if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha)) 2338 if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha))
2317 return QLA_FUNCTION_FAILED; 2339 return QLA_FUNCTION_FAILED;
2318 2340
2319 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2341 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2320 2342
2321 mcp->mb[0] = MBC_GEN_SYSTEM_ERROR; 2343 mcp->mb[0] = MBC_GEN_SYSTEM_ERROR;
2322 mcp->out_mb = MBX_0; 2344 mcp->out_mb = MBX_0;
2323 mcp->in_mb = MBX_0; 2345 mcp->in_mb = MBX_0;
2324 mcp->tov = 5; 2346 mcp->tov = 5;
2325 mcp->flags = 0; 2347 mcp->flags = 0;
2326 rval = qla2x00_mailbox_command(ha, mcp); 2348 rval = qla2x00_mailbox_command(vha, mcp);
2327 2349
2328 if (rval != QLA_SUCCESS) { 2350 if (rval != QLA_SUCCESS) {
2329 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2351 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2330 ha->host_no, rval)); 2352 vha->host_no, rval));
2331 } else { 2353 } else {
2332 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2354 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2333 } 2355 }
2334 2356
2335 return rval; 2357 return rval;
@@ -2342,14 +2364,14 @@ qla2x00_system_error(scsi_qla_host_t *ha)
2342 * Returns 2364 * Returns
2343 */ 2365 */
2344int 2366int
2345qla2x00_set_serdes_params(scsi_qla_host_t *ha, uint16_t sw_em_1g, 2367qla2x00_set_serdes_params(scsi_qla_host_t *vha, uint16_t sw_em_1g,
2346 uint16_t sw_em_2g, uint16_t sw_em_4g) 2368 uint16_t sw_em_2g, uint16_t sw_em_4g)
2347{ 2369{
2348 int rval; 2370 int rval;
2349 mbx_cmd_t mc; 2371 mbx_cmd_t mc;
2350 mbx_cmd_t *mcp = &mc; 2372 mbx_cmd_t *mcp = &mc;
2351 2373
2352 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2374 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2353 2375
2354 mcp->mb[0] = MBC_SERDES_PARAMS; 2376 mcp->mb[0] = MBC_SERDES_PARAMS;
2355 mcp->mb[1] = BIT_0; 2377 mcp->mb[1] = BIT_0;
@@ -2360,61 +2382,61 @@ qla2x00_set_serdes_params(scsi_qla_host_t *ha, uint16_t sw_em_1g,
2360 mcp->in_mb = MBX_0; 2382 mcp->in_mb = MBX_0;
2361 mcp->tov = MBX_TOV_SECONDS; 2383 mcp->tov = MBX_TOV_SECONDS;
2362 mcp->flags = 0; 2384 mcp->flags = 0;
2363 rval = qla2x00_mailbox_command(ha, mcp); 2385 rval = qla2x00_mailbox_command(vha, mcp);
2364 2386
2365 if (rval != QLA_SUCCESS) { 2387 if (rval != QLA_SUCCESS) {
2366 /*EMPTY*/ 2388 /*EMPTY*/
2367 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__, 2389 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
2368 ha->host_no, rval, mcp->mb[0])); 2390 vha->host_no, rval, mcp->mb[0]));
2369 } else { 2391 } else {
2370 /*EMPTY*/ 2392 /*EMPTY*/
2371 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2393 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2372 } 2394 }
2373 2395
2374 return rval; 2396 return rval;
2375} 2397}
2376 2398
2377int 2399int
2378qla2x00_stop_firmware(scsi_qla_host_t *ha) 2400qla2x00_stop_firmware(scsi_qla_host_t *vha)
2379{ 2401{
2380 int rval; 2402 int rval;
2381 mbx_cmd_t mc; 2403 mbx_cmd_t mc;
2382 mbx_cmd_t *mcp = &mc; 2404 mbx_cmd_t *mcp = &mc;
2383 2405
2384 if (!IS_FWI2_CAPABLE(ha)) 2406 if (!IS_FWI2_CAPABLE(vha->hw))
2385 return QLA_FUNCTION_FAILED; 2407 return QLA_FUNCTION_FAILED;
2386 2408
2387 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2409 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2388 2410
2389 mcp->mb[0] = MBC_STOP_FIRMWARE; 2411 mcp->mb[0] = MBC_STOP_FIRMWARE;
2390 mcp->out_mb = MBX_0; 2412 mcp->out_mb = MBX_0;
2391 mcp->in_mb = MBX_0; 2413 mcp->in_mb = MBX_0;
2392 mcp->tov = 5; 2414 mcp->tov = 5;
2393 mcp->flags = 0; 2415 mcp->flags = 0;
2394 rval = qla2x00_mailbox_command(ha, mcp); 2416 rval = qla2x00_mailbox_command(vha, mcp);
2395 2417
2396 if (rval != QLA_SUCCESS) { 2418 if (rval != QLA_SUCCESS) {
2397 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2419 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2398 ha->host_no, rval)); 2420 vha->host_no, rval));
2399 } else { 2421 } else {
2400 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2422 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2401 } 2423 }
2402 2424
2403 return rval; 2425 return rval;
2404} 2426}
2405 2427
2406int 2428int
2407qla2x00_enable_eft_trace(scsi_qla_host_t *ha, dma_addr_t eft_dma, 2429qla2x00_enable_eft_trace(scsi_qla_host_t *vha, dma_addr_t eft_dma,
2408 uint16_t buffers) 2430 uint16_t buffers)
2409{ 2431{
2410 int rval; 2432 int rval;
2411 mbx_cmd_t mc; 2433 mbx_cmd_t mc;
2412 mbx_cmd_t *mcp = &mc; 2434 mbx_cmd_t *mcp = &mc;
2413 2435
2414 if (!IS_FWI2_CAPABLE(ha)) 2436 if (!IS_FWI2_CAPABLE(vha->hw))
2415 return QLA_FUNCTION_FAILED; 2437 return QLA_FUNCTION_FAILED;
2416 2438
2417 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2439 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2418 2440
2419 mcp->mb[0] = MBC_TRACE_CONTROL; 2441 mcp->mb[0] = MBC_TRACE_CONTROL;
2420 mcp->mb[1] = TC_EFT_ENABLE; 2442 mcp->mb[1] = TC_EFT_ENABLE;
@@ -2428,28 +2450,28 @@ qla2x00_enable_eft_trace(scsi_qla_host_t *ha, dma_addr_t eft_dma,
2428 mcp->in_mb = MBX_1|MBX_0; 2450 mcp->in_mb = MBX_1|MBX_0;
2429 mcp->tov = MBX_TOV_SECONDS; 2451 mcp->tov = MBX_TOV_SECONDS;
2430 mcp->flags = 0; 2452 mcp->flags = 0;
2431 rval = qla2x00_mailbox_command(ha, mcp); 2453 rval = qla2x00_mailbox_command(vha, mcp);
2432 if (rval != QLA_SUCCESS) { 2454 if (rval != QLA_SUCCESS) {
2433 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 2455 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2434 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 2456 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2435 } else { 2457 } else {
2436 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2458 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2437 } 2459 }
2438 2460
2439 return rval; 2461 return rval;
2440} 2462}
2441 2463
2442int 2464int
2443qla2x00_disable_eft_trace(scsi_qla_host_t *ha) 2465qla2x00_disable_eft_trace(scsi_qla_host_t *vha)
2444{ 2466{
2445 int rval; 2467 int rval;
2446 mbx_cmd_t mc; 2468 mbx_cmd_t mc;
2447 mbx_cmd_t *mcp = &mc; 2469 mbx_cmd_t *mcp = &mc;
2448 2470
2449 if (!IS_FWI2_CAPABLE(ha)) 2471 if (!IS_FWI2_CAPABLE(vha->hw))
2450 return QLA_FUNCTION_FAILED; 2472 return QLA_FUNCTION_FAILED;
2451 2473
2452 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2474 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2453 2475
2454 mcp->mb[0] = MBC_TRACE_CONTROL; 2476 mcp->mb[0] = MBC_TRACE_CONTROL;
2455 mcp->mb[1] = TC_EFT_DISABLE; 2477 mcp->mb[1] = TC_EFT_DISABLE;
@@ -2457,29 +2479,29 @@ qla2x00_disable_eft_trace(scsi_qla_host_t *ha)
2457 mcp->in_mb = MBX_1|MBX_0; 2479 mcp->in_mb = MBX_1|MBX_0;
2458 mcp->tov = MBX_TOV_SECONDS; 2480 mcp->tov = MBX_TOV_SECONDS;
2459 mcp->flags = 0; 2481 mcp->flags = 0;
2460 rval = qla2x00_mailbox_command(ha, mcp); 2482 rval = qla2x00_mailbox_command(vha, mcp);
2461 if (rval != QLA_SUCCESS) { 2483 if (rval != QLA_SUCCESS) {
2462 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 2484 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2463 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 2485 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2464 } else { 2486 } else {
2465 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2487 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2466 } 2488 }
2467 2489
2468 return rval; 2490 return rval;
2469} 2491}
2470 2492
2471int 2493int
2472qla2x00_enable_fce_trace(scsi_qla_host_t *ha, dma_addr_t fce_dma, 2494qla2x00_enable_fce_trace(scsi_qla_host_t *vha, dma_addr_t fce_dma,
2473 uint16_t buffers, uint16_t *mb, uint32_t *dwords) 2495 uint16_t buffers, uint16_t *mb, uint32_t *dwords)
2474{ 2496{
2475 int rval; 2497 int rval;
2476 mbx_cmd_t mc; 2498 mbx_cmd_t mc;
2477 mbx_cmd_t *mcp = &mc; 2499 mbx_cmd_t *mcp = &mc;
2478 2500
2479 if (!IS_QLA25XX(ha)) 2501 if (!IS_QLA25XX(vha->hw))
2480 return QLA_FUNCTION_FAILED; 2502 return QLA_FUNCTION_FAILED;
2481 2503
2482 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2504 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2483 2505
2484 mcp->mb[0] = MBC_TRACE_CONTROL; 2506 mcp->mb[0] = MBC_TRACE_CONTROL;
2485 mcp->mb[1] = TC_FCE_ENABLE; 2507 mcp->mb[1] = TC_FCE_ENABLE;
@@ -2497,12 +2519,12 @@ qla2x00_enable_fce_trace(scsi_qla_host_t *ha, dma_addr_t fce_dma,
2497 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 2519 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
2498 mcp->tov = MBX_TOV_SECONDS; 2520 mcp->tov = MBX_TOV_SECONDS;
2499 mcp->flags = 0; 2521 mcp->flags = 0;
2500 rval = qla2x00_mailbox_command(ha, mcp); 2522 rval = qla2x00_mailbox_command(vha, mcp);
2501 if (rval != QLA_SUCCESS) { 2523 if (rval != QLA_SUCCESS) {
2502 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 2524 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2503 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 2525 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2504 } else { 2526 } else {
2505 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2527 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2506 2528
2507 if (mb) 2529 if (mb)
2508 memcpy(mb, mcp->mb, 8 * sizeof(*mb)); 2530 memcpy(mb, mcp->mb, 8 * sizeof(*mb));
@@ -2514,16 +2536,16 @@ qla2x00_enable_fce_trace(scsi_qla_host_t *ha, dma_addr_t fce_dma,
2514} 2536}
2515 2537
2516int 2538int
2517qla2x00_disable_fce_trace(scsi_qla_host_t *ha, uint64_t *wr, uint64_t *rd) 2539qla2x00_disable_fce_trace(scsi_qla_host_t *vha, uint64_t *wr, uint64_t *rd)
2518{ 2540{
2519 int rval; 2541 int rval;
2520 mbx_cmd_t mc; 2542 mbx_cmd_t mc;
2521 mbx_cmd_t *mcp = &mc; 2543 mbx_cmd_t *mcp = &mc;
2522 2544
2523 if (!IS_FWI2_CAPABLE(ha)) 2545 if (!IS_FWI2_CAPABLE(vha->hw))
2524 return QLA_FUNCTION_FAILED; 2546 return QLA_FUNCTION_FAILED;
2525 2547
2526 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2548 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2527 2549
2528 mcp->mb[0] = MBC_TRACE_CONTROL; 2550 mcp->mb[0] = MBC_TRACE_CONTROL;
2529 mcp->mb[1] = TC_FCE_DISABLE; 2551 mcp->mb[1] = TC_FCE_DISABLE;
@@ -2533,12 +2555,12 @@ qla2x00_disable_fce_trace(scsi_qla_host_t *ha, uint64_t *wr, uint64_t *rd)
2533 MBX_1|MBX_0; 2555 MBX_1|MBX_0;
2534 mcp->tov = MBX_TOV_SECONDS; 2556 mcp->tov = MBX_TOV_SECONDS;
2535 mcp->flags = 0; 2557 mcp->flags = 0;
2536 rval = qla2x00_mailbox_command(ha, mcp); 2558 rval = qla2x00_mailbox_command(vha, mcp);
2537 if (rval != QLA_SUCCESS) { 2559 if (rval != QLA_SUCCESS) {
2538 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 2560 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2539 __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 2561 __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1]));
2540 } else { 2562 } else {
2541 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2563 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2542 2564
2543 if (wr) 2565 if (wr)
2544 *wr = (uint64_t) mcp->mb[5] << 48 | 2566 *wr = (uint64_t) mcp->mb[5] << 48 |
@@ -2556,17 +2578,17 @@ qla2x00_disable_fce_trace(scsi_qla_host_t *ha, uint64_t *wr, uint64_t *rd)
2556} 2578}
2557 2579
2558int 2580int
2559qla2x00_read_sfp(scsi_qla_host_t *ha, dma_addr_t sfp_dma, uint16_t addr, 2581qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint16_t addr,
2560 uint16_t off, uint16_t count) 2582 uint16_t off, uint16_t count)
2561{ 2583{
2562 int rval; 2584 int rval;
2563 mbx_cmd_t mc; 2585 mbx_cmd_t mc;
2564 mbx_cmd_t *mcp = &mc; 2586 mbx_cmd_t *mcp = &mc;
2565 2587
2566 if (!IS_FWI2_CAPABLE(ha)) 2588 if (!IS_FWI2_CAPABLE(vha->hw))
2567 return QLA_FUNCTION_FAILED; 2589 return QLA_FUNCTION_FAILED;
2568 2590
2569 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2591 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2570 2592
2571 mcp->mb[0] = MBC_READ_SFP; 2593 mcp->mb[0] = MBC_READ_SFP;
2572 mcp->mb[1] = addr; 2594 mcp->mb[1] = addr;
@@ -2581,30 +2603,30 @@ qla2x00_read_sfp(scsi_qla_host_t *ha, dma_addr_t sfp_dma, uint16_t addr,
2581 mcp->in_mb = MBX_0; 2603 mcp->in_mb = MBX_0;
2582 mcp->tov = MBX_TOV_SECONDS; 2604 mcp->tov = MBX_TOV_SECONDS;
2583 mcp->flags = 0; 2605 mcp->flags = 0;
2584 rval = qla2x00_mailbox_command(ha, mcp); 2606 rval = qla2x00_mailbox_command(vha, mcp);
2585 2607
2586 if (rval != QLA_SUCCESS) { 2608 if (rval != QLA_SUCCESS) {
2587 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__, 2609 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
2588 ha->host_no, rval, mcp->mb[0])); 2610 vha->host_no, rval, mcp->mb[0]));
2589 } else { 2611 } else {
2590 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2612 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2591 } 2613 }
2592 2614
2593 return rval; 2615 return rval;
2594} 2616}
2595 2617
2596int 2618int
2597qla2x00_set_idma_speed(scsi_qla_host_t *ha, uint16_t loop_id, 2619qla2x00_set_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id,
2598 uint16_t port_speed, uint16_t *mb) 2620 uint16_t port_speed, uint16_t *mb)
2599{ 2621{
2600 int rval; 2622 int rval;
2601 mbx_cmd_t mc; 2623 mbx_cmd_t mc;
2602 mbx_cmd_t *mcp = &mc; 2624 mbx_cmd_t *mcp = &mc;
2603 2625
2604 if (!IS_IIDMA_CAPABLE(ha)) 2626 if (!IS_IIDMA_CAPABLE(vha->hw))
2605 return QLA_FUNCTION_FAILED; 2627 return QLA_FUNCTION_FAILED;
2606 2628
2607 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2629 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2608 2630
2609 mcp->mb[0] = MBC_PORT_PARAMS; 2631 mcp->mb[0] = MBC_PORT_PARAMS;
2610 mcp->mb[1] = loop_id; 2632 mcp->mb[1] = loop_id;
@@ -2615,7 +2637,7 @@ qla2x00_set_idma_speed(scsi_qla_host_t *ha, uint16_t loop_id,
2615 mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_1|MBX_0; 2637 mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_1|MBX_0;
2616 mcp->tov = MBX_TOV_SECONDS; 2638 mcp->tov = MBX_TOV_SECONDS;
2617 mcp->flags = 0; 2639 mcp->flags = 0;
2618 rval = qla2x00_mailbox_command(ha, mcp); 2640 rval = qla2x00_mailbox_command(vha, mcp);
2619 2641
2620 /* Return mailbox statuses. */ 2642 /* Return mailbox statuses. */
2621 if (mb != NULL) { 2643 if (mb != NULL) {
@@ -2628,28 +2650,29 @@ qla2x00_set_idma_speed(scsi_qla_host_t *ha, uint16_t loop_id,
2628 2650
2629 if (rval != QLA_SUCCESS) { 2651 if (rval != QLA_SUCCESS) {
2630 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2652 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
2631 ha->host_no, rval)); 2653 vha->host_no, rval));
2632 } else { 2654 } else {
2633 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2655 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2634 } 2656 }
2635 2657
2636 return rval; 2658 return rval;
2637} 2659}
2638 2660
2639void 2661void
2640qla24xx_report_id_acquisition(scsi_qla_host_t *ha, 2662qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
2641 struct vp_rpt_id_entry_24xx *rptid_entry) 2663 struct vp_rpt_id_entry_24xx *rptid_entry)
2642{ 2664{
2643 uint8_t vp_idx; 2665 uint8_t vp_idx;
2644 uint16_t stat = le16_to_cpu(rptid_entry->vp_idx); 2666 uint16_t stat = le16_to_cpu(rptid_entry->vp_idx);
2645 scsi_qla_host_t *vha; 2667 struct qla_hw_data *ha = vha->hw;
2668 scsi_qla_host_t *vp;
2646 2669
2647 if (rptid_entry->entry_status != 0) 2670 if (rptid_entry->entry_status != 0)
2648 return; 2671 return;
2649 2672
2650 if (rptid_entry->format == 0) { 2673 if (rptid_entry->format == 0) {
2651 DEBUG15(printk("%s:format 0 : scsi(%ld) number of VPs setup %d," 2674 DEBUG15(printk("%s:format 0 : scsi(%ld) number of VPs setup %d,"
2652 " number of VPs acquired %d\n", __func__, ha->host_no, 2675 " number of VPs acquired %d\n", __func__, vha->host_no,
2653 MSB(rptid_entry->vp_count), LSB(rptid_entry->vp_count))); 2676 MSB(rptid_entry->vp_count), LSB(rptid_entry->vp_count)));
2654 DEBUG15(printk("%s primary port id %02x%02x%02x\n", __func__, 2677 DEBUG15(printk("%s primary port id %02x%02x%02x\n", __func__,
2655 rptid_entry->port_id[2], rptid_entry->port_id[1], 2678 rptid_entry->port_id[2], rptid_entry->port_id[1],
@@ -2658,7 +2681,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *ha,
2658 vp_idx = LSB(stat); 2681 vp_idx = LSB(stat);
2659 DEBUG15(printk("%s:format 1: scsi(%ld): VP[%d] enabled " 2682 DEBUG15(printk("%s:format 1: scsi(%ld): VP[%d] enabled "
2660 "- status %d - " 2683 "- status %d - "
2661 "with port id %02x%02x%02x\n",__func__,ha->host_no, 2684 "with port id %02x%02x%02x\n", __func__, vha->host_no,
2662 vp_idx, MSB(stat), 2685 vp_idx, MSB(stat),
2663 rptid_entry->port_id[2], rptid_entry->port_id[1], 2686 rptid_entry->port_id[2], rptid_entry->port_id[1],
2664 rptid_entry->port_id[0])); 2687 rptid_entry->port_id[0]));
@@ -2668,25 +2691,24 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *ha,
2668 if (MSB(stat) == 1) 2691 if (MSB(stat) == 1)
2669 return; 2692 return;
2670 2693
2671 list_for_each_entry(vha, &ha->vp_list, vp_list) 2694 list_for_each_entry(vp, &ha->vp_list, list)
2672 if (vp_idx == vha->vp_idx) 2695 if (vp_idx == vp->vp_idx)
2673 break; 2696 break;
2674 2697 if (!vp)
2675 if (!vha)
2676 return; 2698 return;
2677 2699
2678 vha->d_id.b.domain = rptid_entry->port_id[2]; 2700 vp->d_id.b.domain = rptid_entry->port_id[2];
2679 vha->d_id.b.area = rptid_entry->port_id[1]; 2701 vp->d_id.b.area = rptid_entry->port_id[1];
2680 vha->d_id.b.al_pa = rptid_entry->port_id[0]; 2702 vp->d_id.b.al_pa = rptid_entry->port_id[0];
2681 2703
2682 /* 2704 /*
2683 * Cannot configure here as we are still sitting on the 2705 * Cannot configure here as we are still sitting on the
2684 * response queue. Handle it in dpc context. 2706 * response queue. Handle it in dpc context.
2685 */ 2707 */
2686 set_bit(VP_IDX_ACQUIRED, &vha->vp_flags); 2708 set_bit(VP_IDX_ACQUIRED, &vp->vp_flags);
2687 set_bit(VP_DPC_NEEDED, &ha->dpc_flags); 2709 set_bit(VP_DPC_NEEDED, &vha->dpc_flags);
2688 2710
2689 qla2xxx_wake_dpc(ha); 2711 qla2xxx_wake_dpc(vha);
2690 } 2712 }
2691} 2713}
2692 2714
@@ -2709,15 +2731,15 @@ qla24xx_modify_vp_config(scsi_qla_host_t *vha)
2709 int rval; 2731 int rval;
2710 struct vp_config_entry_24xx *vpmod; 2732 struct vp_config_entry_24xx *vpmod;
2711 dma_addr_t vpmod_dma; 2733 dma_addr_t vpmod_dma;
2712 scsi_qla_host_t *pha; 2734 struct qla_hw_data *ha = vha->hw;
2735 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
2713 2736
2714 /* This can be called by the parent */ 2737 /* This can be called by the parent */
2715 pha = to_qla_parent(vha);
2716 2738
2717 vpmod = dma_pool_alloc(pha->s_dma_pool, GFP_KERNEL, &vpmod_dma); 2739 vpmod = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma);
2718 if (!vpmod) { 2740 if (!vpmod) {
2719 DEBUG2_3(printk("%s(%ld): failed to allocate Modify VP " 2741 DEBUG2_3(printk("%s(%ld): failed to allocate Modify VP "
2720 "IOCB.\n", __func__, pha->host_no)); 2742 "IOCB.\n", __func__, vha->host_no));
2721 return QLA_MEMORY_ALLOC_FAILED; 2743 return QLA_MEMORY_ALLOC_FAILED;
2722 } 2744 }
2723 2745
@@ -2732,26 +2754,27 @@ qla24xx_modify_vp_config(scsi_qla_host_t *vha)
2732 memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE); 2754 memcpy(vpmod->port_name_idx1, vha->port_name, WWN_SIZE);
2733 vpmod->entry_count = 1; 2755 vpmod->entry_count = 1;
2734 2756
2735 rval = qla2x00_issue_iocb(pha, vpmod, vpmod_dma, 0); 2757 rval = qla2x00_issue_iocb(base_vha, vpmod, vpmod_dma, 0);
2736 if (rval != QLA_SUCCESS) { 2758 if (rval != QLA_SUCCESS) {
2737 DEBUG2_3_11(printk("%s(%ld): failed to issue VP config IOCB" 2759 DEBUG2_3_11(printk("%s(%ld): failed to issue VP config IOCB"
2738 "(%x).\n", __func__, pha->host_no, rval)); 2760 "(%x).\n", __func__, base_vha->host_no, rval));
2739 } else if (vpmod->comp_status != 0) { 2761 } else if (vpmod->comp_status != 0) {
2740 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2762 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2741 "-- error status (%x).\n", __func__, pha->host_no, 2763 "-- error status (%x).\n", __func__, base_vha->host_no,
2742 vpmod->comp_status)); 2764 vpmod->comp_status));
2743 rval = QLA_FUNCTION_FAILED; 2765 rval = QLA_FUNCTION_FAILED;
2744 } else if (vpmod->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { 2766 } else if (vpmod->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
2745 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2767 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2746 "-- completion status (%x).\n", __func__, pha->host_no, 2768 "-- completion status (%x).\n", __func__, base_vha->host_no,
2747 le16_to_cpu(vpmod->comp_status))); 2769 le16_to_cpu(vpmod->comp_status)));
2748 rval = QLA_FUNCTION_FAILED; 2770 rval = QLA_FUNCTION_FAILED;
2749 } else { 2771 } else {
2750 /* EMPTY */ 2772 /* EMPTY */
2751 DEBUG11(printk("%s(%ld): done.\n", __func__, pha->host_no)); 2773 DEBUG11(printk("%s(%ld): done.\n", __func__,
2774 base_vha->host_no));
2752 fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING); 2775 fc_vport_set_state(vha->fc_vport, FC_VPORT_INITIALIZING);
2753 } 2776 }
2754 dma_pool_free(pha->s_dma_pool, vpmod, vpmod_dma); 2777 dma_pool_free(ha->s_dma_pool, vpmod, vpmod_dma);
2755 2778
2756 return rval; 2779 return rval;
2757} 2780}
@@ -2778,11 +2801,12 @@ qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
2778 int map, pos; 2801 int map, pos;
2779 struct vp_ctrl_entry_24xx *vce; 2802 struct vp_ctrl_entry_24xx *vce;
2780 dma_addr_t vce_dma; 2803 dma_addr_t vce_dma;
2781 scsi_qla_host_t *ha = vha->parent; 2804 struct qla_hw_data *ha = vha->hw;
2782 int vp_index = vha->vp_idx; 2805 int vp_index = vha->vp_idx;
2806 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
2783 2807
2784 DEBUG11(printk("%s(%ld): entered. Enabling index %d\n", __func__, 2808 DEBUG11(printk("%s(%ld): entered. Enabling index %d\n", __func__,
2785 ha->host_no, vp_index)); 2809 vha->host_no, vp_index));
2786 2810
2787 if (vp_index == 0 || vp_index >= ha->max_npiv_vports) 2811 if (vp_index == 0 || vp_index >= ha->max_npiv_vports)
2788 return QLA_PARAMETER_ERROR; 2812 return QLA_PARAMETER_ERROR;
@@ -2791,7 +2815,7 @@ qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
2791 if (!vce) { 2815 if (!vce) {
2792 DEBUG2_3(printk("%s(%ld): " 2816 DEBUG2_3(printk("%s(%ld): "
2793 "failed to allocate VP Control IOCB.\n", __func__, 2817 "failed to allocate VP Control IOCB.\n", __func__,
2794 ha->host_no)); 2818 base_vha->host_no));
2795 return QLA_MEMORY_ALLOC_FAILED; 2819 return QLA_MEMORY_ALLOC_FAILED;
2796 } 2820 }
2797 memset(vce, 0, sizeof(struct vp_ctrl_entry_24xx)); 2821 memset(vce, 0, sizeof(struct vp_ctrl_entry_24xx));
@@ -2810,30 +2834,30 @@ qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
2810 vce->vp_idx_map[map] |= 1 << pos; 2834 vce->vp_idx_map[map] |= 1 << pos;
2811 mutex_unlock(&ha->vport_lock); 2835 mutex_unlock(&ha->vport_lock);
2812 2836
2813 rval = qla2x00_issue_iocb(ha, vce, vce_dma, 0); 2837 rval = qla2x00_issue_iocb(base_vha, vce, vce_dma, 0);
2814 if (rval != QLA_SUCCESS) { 2838 if (rval != QLA_SUCCESS) {
2815 DEBUG2_3_11(printk("%s(%ld): failed to issue VP control IOCB" 2839 DEBUG2_3_11(printk("%s(%ld): failed to issue VP control IOCB"
2816 "(%x).\n", __func__, ha->host_no, rval)); 2840 "(%x).\n", __func__, base_vha->host_no, rval));
2817 printk("%s(%ld): failed to issue VP control IOCB" 2841 printk("%s(%ld): failed to issue VP control IOCB"
2818 "(%x).\n", __func__, ha->host_no, rval); 2842 "(%x).\n", __func__, base_vha->host_no, rval);
2819 } else if (vce->entry_status != 0) { 2843 } else if (vce->entry_status != 0) {
2820 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2844 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2821 "-- error status (%x).\n", __func__, ha->host_no, 2845 "-- error status (%x).\n", __func__, base_vha->host_no,
2822 vce->entry_status)); 2846 vce->entry_status));
2823 printk("%s(%ld): failed to complete IOCB " 2847 printk("%s(%ld): failed to complete IOCB "
2824 "-- error status (%x).\n", __func__, ha->host_no, 2848 "-- error status (%x).\n", __func__, base_vha->host_no,
2825 vce->entry_status); 2849 vce->entry_status);
2826 rval = QLA_FUNCTION_FAILED; 2850 rval = QLA_FUNCTION_FAILED;
2827 } else if (vce->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { 2851 } else if (vce->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
2828 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2852 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2829 "-- completion status (%x).\n", __func__, ha->host_no, 2853 "-- completion status (%x).\n", __func__, base_vha->host_no,
2830 le16_to_cpu(vce->comp_status))); 2854 le16_to_cpu(vce->comp_status)));
2831 printk("%s(%ld): failed to complete IOCB " 2855 printk("%s(%ld): failed to complete IOCB "
2832 "-- completion status (%x).\n", __func__, ha->host_no, 2856 "-- completion status (%x).\n", __func__, base_vha->host_no,
2833 le16_to_cpu(vce->comp_status)); 2857 le16_to_cpu(vce->comp_status));
2834 rval = QLA_FUNCTION_FAILED; 2858 rval = QLA_FUNCTION_FAILED;
2835 } else { 2859 } else {
2836 DEBUG2(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2860 DEBUG2(printk("%s(%ld): done.\n", __func__, base_vha->host_no));
2837 } 2861 }
2838 2862
2839 dma_pool_free(ha->s_dma_pool, vce, vce_dma); 2863 dma_pool_free(ha->s_dma_pool, vce, vce_dma);
@@ -2863,7 +2887,7 @@ qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
2863 */ 2887 */
2864 2888
2865int 2889int
2866qla2x00_send_change_request(scsi_qla_host_t *ha, uint16_t format, 2890qla2x00_send_change_request(scsi_qla_host_t *vha, uint16_t format,
2867 uint16_t vp_idx) 2891 uint16_t vp_idx)
2868{ 2892{
2869 int rval; 2893 int rval;
@@ -2884,7 +2908,7 @@ qla2x00_send_change_request(scsi_qla_host_t *ha, uint16_t format,
2884 mcp->in_mb = MBX_0|MBX_1; 2908 mcp->in_mb = MBX_0|MBX_1;
2885 mcp->tov = MBX_TOV_SECONDS; 2909 mcp->tov = MBX_TOV_SECONDS;
2886 mcp->flags = 0; 2910 mcp->flags = 0;
2887 rval = qla2x00_mailbox_command(ha, mcp); 2911 rval = qla2x00_mailbox_command(vha, mcp);
2888 2912
2889 if (rval == QLA_SUCCESS) { 2913 if (rval == QLA_SUCCESS) {
2890 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { 2914 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
@@ -2897,16 +2921,16 @@ qla2x00_send_change_request(scsi_qla_host_t *ha, uint16_t format,
2897} 2921}
2898 2922
2899int 2923int
2900qla2x00_dump_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t addr, 2924qla2x00_dump_ram(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t addr,
2901 uint32_t size) 2925 uint32_t size)
2902{ 2926{
2903 int rval; 2927 int rval;
2904 mbx_cmd_t mc; 2928 mbx_cmd_t mc;
2905 mbx_cmd_t *mcp = &mc; 2929 mbx_cmd_t *mcp = &mc;
2906 2930
2907 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2931 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2908 2932
2909 if (MSW(addr) || IS_FWI2_CAPABLE(ha)) { 2933 if (MSW(addr) || IS_FWI2_CAPABLE(vha->hw)) {
2910 mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED; 2934 mcp->mb[0] = MBC_DUMP_RISC_RAM_EXTENDED;
2911 mcp->mb[8] = MSW(addr); 2935 mcp->mb[8] = MSW(addr);
2912 mcp->out_mb = MBX_8|MBX_0; 2936 mcp->out_mb = MBX_8|MBX_0;
@@ -2920,7 +2944,7 @@ qla2x00_dump_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t addr,
2920 mcp->mb[6] = MSW(MSD(req_dma)); 2944 mcp->mb[6] = MSW(MSD(req_dma));
2921 mcp->mb[7] = LSW(MSD(req_dma)); 2945 mcp->mb[7] = LSW(MSD(req_dma));
2922 mcp->out_mb |= MBX_7|MBX_6|MBX_3|MBX_2|MBX_1; 2946 mcp->out_mb |= MBX_7|MBX_6|MBX_3|MBX_2|MBX_1;
2923 if (IS_FWI2_CAPABLE(ha)) { 2947 if (IS_FWI2_CAPABLE(vha->hw)) {
2924 mcp->mb[4] = MSW(size); 2948 mcp->mb[4] = MSW(size);
2925 mcp->mb[5] = LSW(size); 2949 mcp->mb[5] = LSW(size);
2926 mcp->out_mb |= MBX_5|MBX_4; 2950 mcp->out_mb |= MBX_5|MBX_4;
@@ -2932,13 +2956,13 @@ qla2x00_dump_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t addr,
2932 mcp->in_mb = MBX_0; 2956 mcp->in_mb = MBX_0;
2933 mcp->tov = MBX_TOV_SECONDS; 2957 mcp->tov = MBX_TOV_SECONDS;
2934 mcp->flags = 0; 2958 mcp->flags = 0;
2935 rval = qla2x00_mailbox_command(ha, mcp); 2959 rval = qla2x00_mailbox_command(vha, mcp);
2936 2960
2937 if (rval != QLA_SUCCESS) { 2961 if (rval != QLA_SUCCESS) {
2938 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__, 2962 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__,
2939 ha->host_no, rval, mcp->mb[0])); 2963 vha->host_no, rval, mcp->mb[0]));
2940 } else { 2964 } else {
2941 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2965 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
2942 } 2966 }
2943 2967
2944 return rval; 2968 return rval;
@@ -2954,20 +2978,21 @@ struct cs84xx_mgmt_cmd {
2954}; 2978};
2955 2979
2956int 2980int
2957qla84xx_verify_chip(struct scsi_qla_host *ha, uint16_t *status) 2981qla84xx_verify_chip(struct scsi_qla_host *vha, uint16_t *status)
2958{ 2982{
2959 int rval, retry; 2983 int rval, retry;
2960 struct cs84xx_mgmt_cmd *mn; 2984 struct cs84xx_mgmt_cmd *mn;
2961 dma_addr_t mn_dma; 2985 dma_addr_t mn_dma;
2962 uint16_t options; 2986 uint16_t options;
2963 unsigned long flags; 2987 unsigned long flags;
2988 struct qla_hw_data *ha = vha->hw;
2964 2989
2965 DEBUG16(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2990 DEBUG16(printk("%s(%ld): entered.\n", __func__, vha->host_no));
2966 2991
2967 mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); 2992 mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma);
2968 if (mn == NULL) { 2993 if (mn == NULL) {
2969 DEBUG2_3(printk("%s(%ld): failed to allocate Verify ISP84XX " 2994 DEBUG2_3(printk("%s(%ld): failed to allocate Verify ISP84XX "
2970 "IOCB.\n", __func__, ha->host_no)); 2995 "IOCB.\n", __func__, vha->host_no));
2971 return QLA_MEMORY_ALLOC_FAILED; 2996 return QLA_MEMORY_ALLOC_FAILED;
2972 } 2997 }
2973 2998
@@ -2986,19 +3011,19 @@ qla84xx_verify_chip(struct scsi_qla_host *ha, uint16_t *status)
2986 mn->p.req.options = cpu_to_le16(options); 3011 mn->p.req.options = cpu_to_le16(options);
2987 3012
2988 DEBUG16(printk("%s(%ld): Dump of Verify Request.\n", __func__, 3013 DEBUG16(printk("%s(%ld): Dump of Verify Request.\n", __func__,
2989 ha->host_no)); 3014 vha->host_no));
2990 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn, 3015 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn,
2991 sizeof(*mn))); 3016 sizeof(*mn)));
2992 3017
2993 rval = qla2x00_issue_iocb_timeout(ha, mn, mn_dma, 0, 120); 3018 rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120);
2994 if (rval != QLA_SUCCESS) { 3019 if (rval != QLA_SUCCESS) {
2995 DEBUG2_16(printk("%s(%ld): failed to issue Verify " 3020 DEBUG2_16(printk("%s(%ld): failed to issue Verify "
2996 "IOCB (%x).\n", __func__, ha->host_no, rval)); 3021 "IOCB (%x).\n", __func__, vha->host_no, rval));
2997 goto verify_done; 3022 goto verify_done;
2998 } 3023 }
2999 3024
3000 DEBUG16(printk("%s(%ld): Dump of Verify Response.\n", __func__, 3025 DEBUG16(printk("%s(%ld): Dump of Verify Response.\n", __func__,
3001 ha->host_no)); 3026 vha->host_no));
3002 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn, 3027 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn,
3003 sizeof(*mn))); 3028 sizeof(*mn)));
3004 3029
@@ -3006,21 +3031,21 @@ qla84xx_verify_chip(struct scsi_qla_host *ha, uint16_t *status)
3006 status[1] = status[0] == CS_VCS_CHIP_FAILURE ? 3031 status[1] = status[0] == CS_VCS_CHIP_FAILURE ?
3007 le16_to_cpu(mn->p.rsp.failure_code) : 0; 3032 le16_to_cpu(mn->p.rsp.failure_code) : 0;
3008 DEBUG2_16(printk("%s(%ld): cs=%x fc=%x\n", __func__, 3033 DEBUG2_16(printk("%s(%ld): cs=%x fc=%x\n", __func__,
3009 ha->host_no, status[0], status[1])); 3034 vha->host_no, status[0], status[1]));
3010 3035
3011 if (status[0] != CS_COMPLETE) { 3036 if (status[0] != CS_COMPLETE) {
3012 rval = QLA_FUNCTION_FAILED; 3037 rval = QLA_FUNCTION_FAILED;
3013 if (!(options & VCO_DONT_UPDATE_FW)) { 3038 if (!(options & VCO_DONT_UPDATE_FW)) {
3014 DEBUG2_16(printk("%s(%ld): Firmware update " 3039 DEBUG2_16(printk("%s(%ld): Firmware update "
3015 "failed. Retrying without update " 3040 "failed. Retrying without update "
3016 "firmware.\n", __func__, ha->host_no)); 3041 "firmware.\n", __func__, vha->host_no));
3017 options |= VCO_DONT_UPDATE_FW; 3042 options |= VCO_DONT_UPDATE_FW;
3018 options &= ~VCO_FORCE_UPDATE; 3043 options &= ~VCO_FORCE_UPDATE;
3019 retry = 1; 3044 retry = 1;
3020 } 3045 }
3021 } else { 3046 } else {
3022 DEBUG2_16(printk("%s(%ld): firmware updated to %x.\n", 3047 DEBUG2_16(printk("%s(%ld): firmware updated to %x.\n",
3023 __func__, ha->host_no, 3048 __func__, vha->host_no,
3024 le32_to_cpu(mn->p.rsp.fw_ver))); 3049 le32_to_cpu(mn->p.rsp.fw_ver)));
3025 3050
3026 /* NOTE: we only update OP firmware. */ 3051 /* NOTE: we only update OP firmware. */
@@ -3037,9 +3062,9 @@ verify_done:
3037 3062
3038 if (rval != QLA_SUCCESS) { 3063 if (rval != QLA_SUCCESS) {
3039 DEBUG2_16(printk("%s(%ld): failed=%x.\n", __func__, 3064 DEBUG2_16(printk("%s(%ld): failed=%x.\n", __func__,
3040 ha->host_no, rval)); 3065 vha->host_no, rval));
3041 } else { 3066 } else {
3042 DEBUG16(printk("%s(%ld): done.\n", __func__, ha->host_no)); 3067 DEBUG16(printk("%s(%ld): done.\n", __func__, vha->host_no));
3043 } 3068 }
3044 3069
3045 return rval; 3070 return rval;
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index 93560cd72784..da3db3abb82c 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -5,6 +5,7 @@
5 * See LICENSE.qla2xxx for copyright and licensing details. 5 * See LICENSE.qla2xxx for copyright and licensing details.
6 */ 6 */
7#include "qla_def.h" 7#include "qla_def.h"
8#include "qla_gbl.h"
8 9
9#include <linux/moduleparam.h> 10#include <linux/moduleparam.h>
10#include <linux/vmalloc.h> 11#include <linux/vmalloc.h>
@@ -18,7 +19,7 @@
18void 19void
19qla2x00_vp_stop_timer(scsi_qla_host_t *vha) 20qla2x00_vp_stop_timer(scsi_qla_host_t *vha)
20{ 21{
21 if (vha->parent && vha->timer_active) { 22 if (vha->vp_idx && vha->timer_active) {
22 del_timer_sync(&vha->timer); 23 del_timer_sync(&vha->timer);
23 vha->timer_active = 0; 24 vha->timer_active = 0;
24 } 25 }
@@ -28,7 +29,7 @@ static uint32_t
28qla24xx_allocate_vp_id(scsi_qla_host_t *vha) 29qla24xx_allocate_vp_id(scsi_qla_host_t *vha)
29{ 30{
30 uint32_t vp_id; 31 uint32_t vp_id;
31 scsi_qla_host_t *ha = vha->parent; 32 struct qla_hw_data *ha = vha->hw;
32 33
33 /* Find an empty slot and assign an vp_id */ 34 /* Find an empty slot and assign an vp_id */
34 mutex_lock(&ha->vport_lock); 35 mutex_lock(&ha->vport_lock);
@@ -44,7 +45,7 @@ qla24xx_allocate_vp_id(scsi_qla_host_t *vha)
44 ha->num_vhosts++; 45 ha->num_vhosts++;
45 ha->cur_vport_count++; 46 ha->cur_vport_count++;
46 vha->vp_idx = vp_id; 47 vha->vp_idx = vp_id;
47 list_add_tail(&vha->vp_list, &ha->vp_list); 48 list_add_tail(&vha->list, &ha->vp_list);
48 mutex_unlock(&ha->vport_lock); 49 mutex_unlock(&ha->vport_lock);
49 return vp_id; 50 return vp_id;
50} 51}
@@ -53,24 +54,24 @@ void
53qla24xx_deallocate_vp_id(scsi_qla_host_t *vha) 54qla24xx_deallocate_vp_id(scsi_qla_host_t *vha)
54{ 55{
55 uint16_t vp_id; 56 uint16_t vp_id;
56 scsi_qla_host_t *ha = vha->parent; 57 struct qla_hw_data *ha = vha->hw;
57 58
58 mutex_lock(&ha->vport_lock); 59 mutex_lock(&ha->vport_lock);
59 vp_id = vha->vp_idx; 60 vp_id = vha->vp_idx;
60 ha->num_vhosts--; 61 ha->num_vhosts--;
61 ha->cur_vport_count--; 62 ha->cur_vport_count--;
62 clear_bit(vp_id, ha->vp_idx_map); 63 clear_bit(vp_id, ha->vp_idx_map);
63 list_del(&vha->vp_list); 64 list_del(&vha->list);
64 mutex_unlock(&ha->vport_lock); 65 mutex_unlock(&ha->vport_lock);
65} 66}
66 67
67static scsi_qla_host_t * 68static scsi_qla_host_t *
68qla24xx_find_vhost_by_name(scsi_qla_host_t *ha, uint8_t *port_name) 69qla24xx_find_vhost_by_name(struct qla_hw_data *ha, uint8_t *port_name)
69{ 70{
70 scsi_qla_host_t *vha; 71 scsi_qla_host_t *vha;
71 72
72 /* Locate matching device in database. */ 73 /* Locate matching device in database. */
73 list_for_each_entry(vha, &ha->vp_list, vp_list) { 74 list_for_each_entry(vha, &ha->vp_list, list) {
74 if (!memcmp(port_name, vha->port_name, WWN_SIZE)) 75 if (!memcmp(port_name, vha->port_name, WWN_SIZE))
75 return vha; 76 return vha;
76 } 77 }
@@ -94,12 +95,8 @@ static void
94qla2x00_mark_vp_devices_dead(scsi_qla_host_t *vha) 95qla2x00_mark_vp_devices_dead(scsi_qla_host_t *vha)
95{ 96{
96 fc_port_t *fcport; 97 fc_port_t *fcport;
97 scsi_qla_host_t *pha = to_qla_parent(vha);
98
99 list_for_each_entry(fcport, &pha->fcports, list) {
100 if (fcport->vp_idx != vha->vp_idx)
101 continue;
102 98
99 list_for_each_entry(fcport, &vha->vp_fcports, list) {
103 DEBUG15(printk("scsi(%ld): Marking port dead, " 100 DEBUG15(printk("scsi(%ld): Marking port dead, "
104 "loop_id=0x%04x :%x\n", 101 "loop_id=0x%04x :%x\n",
105 vha->host_no, fcport->loop_id, fcport->vp_idx)); 102 vha->host_no, fcport->loop_id, fcport->vp_idx));
@@ -118,7 +115,6 @@ qla24xx_disable_vp(scsi_qla_host_t *vha)
118 atomic_set(&vha->loop_state, LOOP_DOWN); 115 atomic_set(&vha->loop_state, LOOP_DOWN);
119 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); 116 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
120 117
121 /* Delete all vp's fcports from parent's list */
122 qla2x00_mark_vp_devices_dead(vha); 118 qla2x00_mark_vp_devices_dead(vha);
123 atomic_set(&vha->vp_state, VP_FAILED); 119 atomic_set(&vha->vp_state, VP_FAILED);
124 vha->flags.management_server_logged_in = 0; 120 vha->flags.management_server_logged_in = 0;
@@ -135,11 +131,12 @@ int
135qla24xx_enable_vp(scsi_qla_host_t *vha) 131qla24xx_enable_vp(scsi_qla_host_t *vha)
136{ 132{
137 int ret; 133 int ret;
138 scsi_qla_host_t *ha = vha->parent; 134 struct qla_hw_data *ha = vha->hw;
135 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
139 136
140 /* Check if physical ha port is Up */ 137 /* Check if physical ha port is Up */
141 if (atomic_read(&ha->loop_state) == LOOP_DOWN || 138 if (atomic_read(&base_vha->loop_state) == LOOP_DOWN ||
142 atomic_read(&ha->loop_state) == LOOP_DEAD ) { 139 atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
143 vha->vp_err_state = VP_ERR_PORTDWN; 140 vha->vp_err_state = VP_ERR_PORTDWN;
144 fc_vport_set_state(vha->fc_vport, FC_VPORT_LINKDOWN); 141 fc_vport_set_state(vha->fc_vport, FC_VPORT_LINKDOWN);
145 goto enable_failed; 142 goto enable_failed;
@@ -177,8 +174,8 @@ qla24xx_configure_vp(scsi_qla_host_t *vha)
177 vha->host_no, __func__)); 174 vha->host_no, __func__));
178 ret = qla2x00_send_change_request(vha, 0x3, vha->vp_idx); 175 ret = qla2x00_send_change_request(vha, 0x3, vha->vp_idx);
179 if (ret != QLA_SUCCESS) { 176 if (ret != QLA_SUCCESS) {
180 DEBUG15(qla_printk(KERN_ERR, vha, "Failed to enable receiving" 177 DEBUG15(qla_printk(KERN_ERR, vha->hw, "Failed to enable "
181 " of RSCN requests: 0x%x\n", ret)); 178 "receiving of RSCN requests: 0x%x\n", ret));
182 return; 179 return;
183 } else { 180 } else {
184 /* Corresponds to SCR enabled */ 181 /* Corresponds to SCR enabled */
@@ -194,25 +191,13 @@ qla24xx_configure_vp(scsi_qla_host_t *vha)
194} 191}
195 192
196void 193void
197qla2x00_alert_all_vps(scsi_qla_host_t *ha, uint16_t *mb) 194qla2x00_alert_all_vps(struct qla_hw_data *ha, uint16_t *mb)
198{ 195{
199 int i, vp_idx_matched;
200 scsi_qla_host_t *vha; 196 scsi_qla_host_t *vha;
197 int i = 0;
201 198
202 if (ha->parent) 199 list_for_each_entry(vha, &ha->vp_list, list) {
203 return; 200 if (vha->vp_idx) {
204
205 for_each_mapped_vp_idx(ha, i) {
206 vp_idx_matched = 0;
207
208 list_for_each_entry(vha, &ha->vp_list, vp_list) {
209 if (i == vha->vp_idx) {
210 vp_idx_matched = 1;
211 break;
212 }
213 }
214
215 if (vp_idx_matched) {
216 switch (mb[0]) { 201 switch (mb[0]) {
217 case MBA_LIP_OCCURRED: 202 case MBA_LIP_OCCURRED:
218 case MBA_LOOP_UP: 203 case MBA_LOOP_UP:
@@ -223,16 +208,17 @@ qla2x00_alert_all_vps(scsi_qla_host_t *ha, uint16_t *mb)
223 case MBA_PORT_UPDATE: 208 case MBA_PORT_UPDATE:
224 case MBA_RSCN_UPDATE: 209 case MBA_RSCN_UPDATE:
225 DEBUG15(printk("scsi(%ld)%s: Async_event for" 210 DEBUG15(printk("scsi(%ld)%s: Async_event for"
226 " VP[%d], mb = 0x%x, vha=%p\n", 211 " VP[%d], mb = 0x%x, vha=%p\n",
227 vha->host_no, __func__,i, *mb, vha)); 212 vha->host_no, __func__, i, *mb, vha));
228 qla2x00_async_event(vha, mb); 213 qla2x00_async_event(vha, mb);
229 break; 214 break;
230 } 215 }
231 } 216 }
217 i++;
232 } 218 }
233} 219}
234 220
235void 221int
236qla2x00_vp_abort_isp(scsi_qla_host_t *vha) 222qla2x00_vp_abort_isp(scsi_qla_host_t *vha)
237{ 223{
238 /* 224 /*
@@ -247,30 +233,49 @@ qla2x00_vp_abort_isp(scsi_qla_host_t *vha)
247 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); 233 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
248 } 234 }
249 235
236 /* To exclusively reset vport, we need to log it out first.*/
237 if (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
238 qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
239
250 DEBUG15(printk("scsi(%ld): Scheduling enable of Vport %d...\n", 240 DEBUG15(printk("scsi(%ld): Scheduling enable of Vport %d...\n",
251 vha->host_no, vha->vp_idx)); 241 vha->host_no, vha->vp_idx));
252 qla24xx_enable_vp(vha); 242 return qla24xx_enable_vp(vha);
253} 243}
254 244
255static int 245static int
256qla2x00_do_dpc_vp(scsi_qla_host_t *vha) 246qla2x00_do_dpc_vp(scsi_qla_host_t *vha)
257{ 247{
258 scsi_qla_host_t *ha = vha->parent; 248 struct qla_hw_data *ha = vha->hw;
249 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
259 250
260 if (test_and_clear_bit(VP_IDX_ACQUIRED, &vha->vp_flags)) { 251 if (test_and_clear_bit(VP_IDX_ACQUIRED, &vha->vp_flags)) {
261 /* VP acquired. complete port configuration */ 252 /* VP acquired. complete port configuration */
262 if (atomic_read(&ha->loop_state) == LOOP_READY) { 253 if (atomic_read(&base_vha->loop_state) == LOOP_READY) {
263 qla24xx_configure_vp(vha); 254 qla24xx_configure_vp(vha);
264 } else { 255 } else {
265 set_bit(VP_IDX_ACQUIRED, &vha->vp_flags); 256 set_bit(VP_IDX_ACQUIRED, &vha->vp_flags);
266 set_bit(VP_DPC_NEEDED, &ha->dpc_flags); 257 set_bit(VP_DPC_NEEDED, &base_vha->dpc_flags);
267 } 258 }
268 259
269 return 0; 260 return 0;
270 } 261 }
271 262
272 if (test_and_clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) 263 if (test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags)) {
273 qla2x00_vp_abort_isp(vha); 264 qla2x00_update_fcports(vha);
265 clear_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags);
266 }
267
268 if ((test_and_clear_bit(RELOGIN_NEEDED, &vha->dpc_flags)) &&
269 !test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) &&
270 atomic_read(&vha->loop_state) != LOOP_DOWN) {
271
272 DEBUG(printk("scsi(%ld): qla2x00_port_login()\n",
273 vha->host_no));
274 qla2x00_relogin(vha);
275
276 DEBUG(printk("scsi(%ld): qla2x00_port_login - end\n",
277 vha->host_no));
278 }
274 279
275 if (test_and_clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) && 280 if (test_and_clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) &&
276 (!(test_and_set_bit(RESET_ACTIVE, &vha->dpc_flags)))) { 281 (!(test_and_set_bit(RESET_ACTIVE, &vha->dpc_flags)))) {
@@ -289,38 +294,30 @@ qla2x00_do_dpc_vp(scsi_qla_host_t *vha)
289} 294}
290 295
291void 296void
292qla2x00_do_dpc_all_vps(scsi_qla_host_t *ha) 297qla2x00_do_dpc_all_vps(scsi_qla_host_t *vha)
293{ 298{
294 int ret; 299 int ret;
295 int i, vp_idx_matched; 300 struct qla_hw_data *ha = vha->hw;
296 scsi_qla_host_t *vha; 301 scsi_qla_host_t *vp;
297 302
298 if (ha->parent) 303 if (vha->vp_idx)
299 return; 304 return;
300 if (list_empty(&ha->vp_list)) 305 if (list_empty(&ha->vp_list))
301 return; 306 return;
302 307
303 clear_bit(VP_DPC_NEEDED, &ha->dpc_flags); 308 clear_bit(VP_DPC_NEEDED, &vha->dpc_flags);
304
305 for_each_mapped_vp_idx(ha, i) {
306 vp_idx_matched = 0;
307
308 list_for_each_entry(vha, &ha->vp_list, vp_list) {
309 if (i == vha->vp_idx) {
310 vp_idx_matched = 1;
311 break;
312 }
313 }
314 309
315 if (vp_idx_matched) 310 list_for_each_entry(vp, &ha->vp_list, list) {
316 ret = qla2x00_do_dpc_vp(vha); 311 if (vp->vp_idx)
312 ret = qla2x00_do_dpc_vp(vp);
317 } 313 }
318} 314}
319 315
320int 316int
321qla24xx_vport_create_req_sanity_check(struct fc_vport *fc_vport) 317qla24xx_vport_create_req_sanity_check(struct fc_vport *fc_vport)
322{ 318{
323 scsi_qla_host_t *ha = shost_priv(fc_vport->shost); 319 scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
320 struct qla_hw_data *ha = base_vha->hw;
324 scsi_qla_host_t *vha; 321 scsi_qla_host_t *vha;
325 uint8_t port_name[WWN_SIZE]; 322 uint8_t port_name[WWN_SIZE];
326 323
@@ -337,7 +334,7 @@ qla24xx_vport_create_req_sanity_check(struct fc_vport *fc_vport)
337 334
338 /* Check up unique WWPN */ 335 /* Check up unique WWPN */
339 u64_to_wwn(fc_vport->port_name, port_name); 336 u64_to_wwn(fc_vport->port_name, port_name);
340 if (!memcmp(port_name, ha->port_name, WWN_SIZE)) 337 if (!memcmp(port_name, base_vha->port_name, WWN_SIZE))
341 return VPCERR_BAD_WWN; 338 return VPCERR_BAD_WWN;
342 vha = qla24xx_find_vhost_by_name(ha, port_name); 339 vha = qla24xx_find_vhost_by_name(ha, port_name);
343 if (vha) 340 if (vha)
@@ -346,7 +343,7 @@ qla24xx_vport_create_req_sanity_check(struct fc_vport *fc_vport)
346 /* Check up max-npiv-supports */ 343 /* Check up max-npiv-supports */
347 if (ha->num_vhosts > ha->max_npiv_vports) { 344 if (ha->num_vhosts > ha->max_npiv_vports) {
348 DEBUG15(printk("scsi(%ld): num_vhosts %ud is bigger than " 345 DEBUG15(printk("scsi(%ld): num_vhosts %ud is bigger than "
349 "max_npv_vports %ud.\n", ha->host_no, 346 "max_npv_vports %ud.\n", base_vha->host_no,
350 ha->num_vhosts, ha->max_npiv_vports)); 347 ha->num_vhosts, ha->max_npiv_vports));
351 return VPCERR_UNSUPPORTED; 348 return VPCERR_UNSUPPORTED;
352 } 349 }
@@ -356,59 +353,35 @@ qla24xx_vport_create_req_sanity_check(struct fc_vport *fc_vport)
356scsi_qla_host_t * 353scsi_qla_host_t *
357qla24xx_create_vhost(struct fc_vport *fc_vport) 354qla24xx_create_vhost(struct fc_vport *fc_vport)
358{ 355{
359 scsi_qla_host_t *ha = shost_priv(fc_vport->shost); 356 scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
357 struct qla_hw_data *ha = base_vha->hw;
360 scsi_qla_host_t *vha; 358 scsi_qla_host_t *vha;
359 struct scsi_host_template *sht = &qla24xx_driver_template;
361 struct Scsi_Host *host; 360 struct Scsi_Host *host;
362 361
363 host = scsi_host_alloc(&qla24xx_driver_template, 362 vha = qla2x00_create_host(sht, ha);
364 sizeof(scsi_qla_host_t)); 363 if (!vha) {
365 if (!host) { 364 DEBUG(printk("qla2xxx: scsi_host_alloc() failed for vport\n"));
366 printk(KERN_WARNING
367 "qla2xxx: scsi_host_alloc() failed for vport\n");
368 return(NULL); 365 return(NULL);
369 } 366 }
370 367
371 vha = shost_priv(host); 368 host = vha->host;
372
373 /* clone the parent hba */
374 memcpy(vha, ha, sizeof (scsi_qla_host_t));
375
376 fc_vport->dd_data = vha; 369 fc_vport->dd_data = vha;
377 370
378 vha->node_name = kmalloc(WWN_SIZE * sizeof(char), GFP_KERNEL);
379 if (!vha->node_name)
380 goto create_vhost_failed_1;
381
382 vha->port_name = kmalloc(WWN_SIZE * sizeof(char), GFP_KERNEL);
383 if (!vha->port_name)
384 goto create_vhost_failed_2;
385
386 /* New host info */ 371 /* New host info */
387 u64_to_wwn(fc_vport->node_name, vha->node_name); 372 u64_to_wwn(fc_vport->node_name, vha->node_name);
388 u64_to_wwn(fc_vport->port_name, vha->port_name); 373 u64_to_wwn(fc_vport->port_name, vha->port_name);
389 374
390 vha->host = host;
391 vha->host_no = host->host_no;
392 vha->parent = ha;
393 vha->fc_vport = fc_vport; 375 vha->fc_vport = fc_vport;
394 vha->device_flags = 0; 376 vha->device_flags = 0;
395 vha->vp_idx = qla24xx_allocate_vp_id(vha); 377 vha->vp_idx = qla24xx_allocate_vp_id(vha);
396 if (vha->vp_idx > ha->max_npiv_vports) { 378 if (vha->vp_idx > ha->max_npiv_vports) {
397 DEBUG15(printk("scsi(%ld): Couldn't allocate vp_id.\n", 379 DEBUG15(printk("scsi(%ld): Couldn't allocate vp_id.\n",
398 vha->host_no)); 380 vha->host_no));
399 goto create_vhost_failed_3; 381 goto create_vhost_failed;
400 } 382 }
401 vha->mgmt_svr_loop_id = 10 + vha->vp_idx; 383 vha->mgmt_svr_loop_id = 10 + vha->vp_idx;
402 384
403 init_completion(&vha->mbx_cmd_comp);
404 complete(&vha->mbx_cmd_comp);
405 init_completion(&vha->mbx_intr_comp);
406
407 INIT_LIST_HEAD(&vha->list);
408 INIT_LIST_HEAD(&vha->fcports);
409 INIT_LIST_HEAD(&vha->vp_fcports);
410 INIT_LIST_HEAD(&vha->work_list);
411
412 vha->dpc_flags = 0L; 385 vha->dpc_flags = 0L;
413 set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); 386 set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
414 set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); 387 set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags);
@@ -423,7 +396,7 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
423 396
424 qla2x00_start_timer(vha, qla2x00_timer, WATCH_INTERVAL); 397 qla2x00_start_timer(vha, qla2x00_timer, WATCH_INTERVAL);
425 398
426 host->can_queue = vha->request_q_length + 128; 399 host->can_queue = ha->req->length + 128;
427 host->this_id = 255; 400 host->this_id = 255;
428 host->cmd_per_lun = 3; 401 host->cmd_per_lun = 3;
429 host->max_cmd_len = MAX_CMDSZ; 402 host->max_cmd_len = MAX_CMDSZ;
@@ -440,12 +413,6 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
440 413
441 return vha; 414 return vha;
442 415
443create_vhost_failed_3: 416create_vhost_failed:
444 kfree(vha->port_name);
445
446create_vhost_failed_2:
447 kfree(vha->node_name);
448
449create_vhost_failed_1:
450 return NULL; 417 return NULL;
451} 418}
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index e4af678eb2d6..6d6c02129a53 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -10,10 +10,6 @@
10#include <linux/vmalloc.h> 10#include <linux/vmalloc.h>
11#include <asm/uaccess.h> 11#include <asm/uaccess.h>
12 12
13static uint16_t qla2x00_nvram_request(scsi_qla_host_t *, uint32_t);
14static void qla2x00_nv_deselect(scsi_qla_host_t *);
15static void qla2x00_nv_write(scsi_qla_host_t *, uint16_t);
16
17/* 13/*
18 * NVRAM support routines 14 * NVRAM support routines
19 */ 15 */
@@ -23,7 +19,7 @@ static void qla2x00_nv_write(scsi_qla_host_t *, uint16_t);
23 * @ha: HA context 19 * @ha: HA context
24 */ 20 */
25static void 21static void
26qla2x00_lock_nvram_access(scsi_qla_host_t *ha) 22qla2x00_lock_nvram_access(struct qla_hw_data *ha)
27{ 23{
28 uint16_t data; 24 uint16_t data;
29 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 25 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
@@ -56,7 +52,7 @@ qla2x00_lock_nvram_access(scsi_qla_host_t *ha)
56 * @ha: HA context 52 * @ha: HA context
57 */ 53 */
58static void 54static void
59qla2x00_unlock_nvram_access(scsi_qla_host_t *ha) 55qla2x00_unlock_nvram_access(struct qla_hw_data *ha)
60{ 56{
61 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 57 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
62 58
@@ -67,6 +63,84 @@ qla2x00_unlock_nvram_access(scsi_qla_host_t *ha)
67} 63}
68 64
69/** 65/**
66 * qla2x00_nv_write() - Prepare for NVRAM read/write operation.
67 * @ha: HA context
68 * @data: Serial interface selector
69 */
70static void
71qla2x00_nv_write(struct qla_hw_data *ha, uint16_t data)
72{
73 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
74
75 WRT_REG_WORD(&reg->nvram, data | NVR_SELECT | NVR_WRT_ENABLE);
76 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
77 NVRAM_DELAY();
78 WRT_REG_WORD(&reg->nvram, data | NVR_SELECT | NVR_CLOCK |
79 NVR_WRT_ENABLE);
80 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
81 NVRAM_DELAY();
82 WRT_REG_WORD(&reg->nvram, data | NVR_SELECT | NVR_WRT_ENABLE);
83 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
84 NVRAM_DELAY();
85}
86
87/**
88 * qla2x00_nvram_request() - Sends read command to NVRAM and gets data from
89 * NVRAM.
90 * @ha: HA context
91 * @nv_cmd: NVRAM command
92 *
93 * Bit definitions for NVRAM command:
94 *
95 * Bit 26 = start bit
96 * Bit 25, 24 = opcode
97 * Bit 23-16 = address
98 * Bit 15-0 = write data
99 *
100 * Returns the word read from nvram @addr.
101 */
102static uint16_t
103qla2x00_nvram_request(struct qla_hw_data *ha, uint32_t nv_cmd)
104{
105 uint8_t cnt;
106 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
107 uint16_t data = 0;
108 uint16_t reg_data;
109
110 /* Send command to NVRAM. */
111 nv_cmd <<= 5;
112 for (cnt = 0; cnt < 11; cnt++) {
113 if (nv_cmd & BIT_31)
114 qla2x00_nv_write(ha, NVR_DATA_OUT);
115 else
116 qla2x00_nv_write(ha, 0);
117 nv_cmd <<= 1;
118 }
119
120 /* Read data from NVRAM. */
121 for (cnt = 0; cnt < 16; cnt++) {
122 WRT_REG_WORD(&reg->nvram, NVR_SELECT | NVR_CLOCK);
123 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
124 NVRAM_DELAY();
125 data <<= 1;
126 reg_data = RD_REG_WORD(&reg->nvram);
127 if (reg_data & NVR_DATA_IN)
128 data |= BIT_0;
129 WRT_REG_WORD(&reg->nvram, NVR_SELECT);
130 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
131 NVRAM_DELAY();
132 }
133
134 /* Deselect chip. */
135 WRT_REG_WORD(&reg->nvram, NVR_DESELECT);
136 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
137 NVRAM_DELAY();
138
139 return data;
140}
141
142
143/**
70 * qla2x00_get_nvram_word() - Calculates word position in NVRAM and calls the 144 * qla2x00_get_nvram_word() - Calculates word position in NVRAM and calls the
71 * request routine to get the word from NVRAM. 145 * request routine to get the word from NVRAM.
72 * @ha: HA context 146 * @ha: HA context
@@ -75,7 +149,7 @@ qla2x00_unlock_nvram_access(scsi_qla_host_t *ha)
75 * Returns the word read from nvram @addr. 149 * Returns the word read from nvram @addr.
76 */ 150 */
77static uint16_t 151static uint16_t
78qla2x00_get_nvram_word(scsi_qla_host_t *ha, uint32_t addr) 152qla2x00_get_nvram_word(struct qla_hw_data *ha, uint32_t addr)
79{ 153{
80 uint16_t data; 154 uint16_t data;
81 uint32_t nv_cmd; 155 uint32_t nv_cmd;
@@ -88,13 +162,27 @@ qla2x00_get_nvram_word(scsi_qla_host_t *ha, uint32_t addr)
88} 162}
89 163
90/** 164/**
165 * qla2x00_nv_deselect() - Deselect NVRAM operations.
166 * @ha: HA context
167 */
168static void
169qla2x00_nv_deselect(struct qla_hw_data *ha)
170{
171 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
172
173 WRT_REG_WORD(&reg->nvram, NVR_DESELECT);
174 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
175 NVRAM_DELAY();
176}
177
178/**
91 * qla2x00_write_nvram_word() - Write NVRAM data. 179 * qla2x00_write_nvram_word() - Write NVRAM data.
92 * @ha: HA context 180 * @ha: HA context
93 * @addr: Address in NVRAM to write 181 * @addr: Address in NVRAM to write
94 * @data: word to program 182 * @data: word to program
95 */ 183 */
96static void 184static void
97qla2x00_write_nvram_word(scsi_qla_host_t *ha, uint32_t addr, uint16_t data) 185qla2x00_write_nvram_word(struct qla_hw_data *ha, uint32_t addr, uint16_t data)
98{ 186{
99 int count; 187 int count;
100 uint16_t word; 188 uint16_t word;
@@ -132,7 +220,7 @@ qla2x00_write_nvram_word(scsi_qla_host_t *ha, uint32_t addr, uint16_t data)
132 do { 220 do {
133 if (!--wait_cnt) { 221 if (!--wait_cnt) {
134 DEBUG9_10(printk("%s(%ld): NVRAM didn't go ready...\n", 222 DEBUG9_10(printk("%s(%ld): NVRAM didn't go ready...\n",
135 __func__, ha->host_no)); 223 __func__, vha->host_no));
136 break; 224 break;
137 } 225 }
138 NVRAM_DELAY(); 226 NVRAM_DELAY();
@@ -150,8 +238,8 @@ qla2x00_write_nvram_word(scsi_qla_host_t *ha, uint32_t addr, uint16_t data)
150} 238}
151 239
152static int 240static int
153qla2x00_write_nvram_word_tmo(scsi_qla_host_t *ha, uint32_t addr, uint16_t data, 241qla2x00_write_nvram_word_tmo(struct qla_hw_data *ha, uint32_t addr,
154 uint32_t tmo) 242 uint16_t data, uint32_t tmo)
155{ 243{
156 int ret, count; 244 int ret, count;
157 uint16_t word; 245 uint16_t word;
@@ -209,102 +297,11 @@ qla2x00_write_nvram_word_tmo(scsi_qla_host_t *ha, uint32_t addr, uint16_t data,
209} 297}
210 298
211/** 299/**
212 * qla2x00_nvram_request() - Sends read command to NVRAM and gets data from
213 * NVRAM.
214 * @ha: HA context
215 * @nv_cmd: NVRAM command
216 *
217 * Bit definitions for NVRAM command:
218 *
219 * Bit 26 = start bit
220 * Bit 25, 24 = opcode
221 * Bit 23-16 = address
222 * Bit 15-0 = write data
223 *
224 * Returns the word read from nvram @addr.
225 */
226static uint16_t
227qla2x00_nvram_request(scsi_qla_host_t *ha, uint32_t nv_cmd)
228{
229 uint8_t cnt;
230 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
231 uint16_t data = 0;
232 uint16_t reg_data;
233
234 /* Send command to NVRAM. */
235 nv_cmd <<= 5;
236 for (cnt = 0; cnt < 11; cnt++) {
237 if (nv_cmd & BIT_31)
238 qla2x00_nv_write(ha, NVR_DATA_OUT);
239 else
240 qla2x00_nv_write(ha, 0);
241 nv_cmd <<= 1;
242 }
243
244 /* Read data from NVRAM. */
245 for (cnt = 0; cnt < 16; cnt++) {
246 WRT_REG_WORD(&reg->nvram, NVR_SELECT | NVR_CLOCK);
247 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
248 NVRAM_DELAY();
249 data <<= 1;
250 reg_data = RD_REG_WORD(&reg->nvram);
251 if (reg_data & NVR_DATA_IN)
252 data |= BIT_0;
253 WRT_REG_WORD(&reg->nvram, NVR_SELECT);
254 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
255 NVRAM_DELAY();
256 }
257
258 /* Deselect chip. */
259 WRT_REG_WORD(&reg->nvram, NVR_DESELECT);
260 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
261 NVRAM_DELAY();
262
263 return (data);
264}
265
266/**
267 * qla2x00_nv_write() - Clean NVRAM operations.
268 * @ha: HA context
269 */
270static void
271qla2x00_nv_deselect(scsi_qla_host_t *ha)
272{
273 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
274
275 WRT_REG_WORD(&reg->nvram, NVR_DESELECT);
276 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
277 NVRAM_DELAY();
278}
279
280/**
281 * qla2x00_nv_write() - Prepare for NVRAM read/write operation.
282 * @ha: HA context
283 * @data: Serial interface selector
284 */
285static void
286qla2x00_nv_write(scsi_qla_host_t *ha, uint16_t data)
287{
288 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
289
290 WRT_REG_WORD(&reg->nvram, data | NVR_SELECT | NVR_WRT_ENABLE);
291 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
292 NVRAM_DELAY();
293 WRT_REG_WORD(&reg->nvram, data | NVR_SELECT| NVR_CLOCK |
294 NVR_WRT_ENABLE);
295 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
296 NVRAM_DELAY();
297 WRT_REG_WORD(&reg->nvram, data | NVR_SELECT | NVR_WRT_ENABLE);
298 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
299 NVRAM_DELAY();
300}
301
302/**
303 * qla2x00_clear_nvram_protection() - 300 * qla2x00_clear_nvram_protection() -
304 * @ha: HA context 301 * @ha: HA context
305 */ 302 */
306static int 303static int
307qla2x00_clear_nvram_protection(scsi_qla_host_t *ha) 304qla2x00_clear_nvram_protection(struct qla_hw_data *ha)
308{ 305{
309 int ret, stat; 306 int ret, stat;
310 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 307 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
@@ -352,9 +349,8 @@ qla2x00_clear_nvram_protection(scsi_qla_host_t *ha)
352 wait_cnt = NVR_WAIT_CNT; 349 wait_cnt = NVR_WAIT_CNT;
353 do { 350 do {
354 if (!--wait_cnt) { 351 if (!--wait_cnt) {
355 DEBUG9_10(printk("%s(%ld): NVRAM didn't go " 352 DEBUG9_10(qla_printk(
356 "ready...\n", __func__, 353 "NVRAM didn't go ready...\n"));
357 ha->host_no));
358 break; 354 break;
359 } 355 }
360 NVRAM_DELAY(); 356 NVRAM_DELAY();
@@ -370,7 +366,7 @@ qla2x00_clear_nvram_protection(scsi_qla_host_t *ha)
370} 366}
371 367
372static void 368static void
373qla2x00_set_nvram_protection(scsi_qla_host_t *ha, int stat) 369qla2x00_set_nvram_protection(struct qla_hw_data *ha, int stat)
374{ 370{
375 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 371 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
376 uint32_t word, wait_cnt; 372 uint32_t word, wait_cnt;
@@ -412,8 +408,7 @@ qla2x00_set_nvram_protection(scsi_qla_host_t *ha, int stat)
412 wait_cnt = NVR_WAIT_CNT; 408 wait_cnt = NVR_WAIT_CNT;
413 do { 409 do {
414 if (!--wait_cnt) { 410 if (!--wait_cnt) {
415 DEBUG9_10(printk("%s(%ld): NVRAM didn't go ready...\n", 411 DEBUG9_10(qla_printk("NVRAM didn't go ready...\n"));
416 __func__, ha->host_no));
417 break; 412 break;
418 } 413 }
419 NVRAM_DELAY(); 414 NVRAM_DELAY();
@@ -454,7 +449,7 @@ nvram_data_to_access_addr(uint32_t naddr)
454} 449}
455 450
456static uint32_t 451static uint32_t
457qla24xx_read_flash_dword(scsi_qla_host_t *ha, uint32_t addr) 452qla24xx_read_flash_dword(struct qla_hw_data *ha, uint32_t addr)
458{ 453{
459 int rval; 454 int rval;
460 uint32_t cnt, data; 455 uint32_t cnt, data;
@@ -482,21 +477,20 @@ qla24xx_read_flash_dword(scsi_qla_host_t *ha, uint32_t addr)
482} 477}
483 478
484uint32_t * 479uint32_t *
485qla24xx_read_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr, 480qla24xx_read_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
486 uint32_t dwords) 481 uint32_t dwords)
487{ 482{
488 uint32_t i; 483 uint32_t i;
489
490 /* Dword reads to flash. */ 484 /* Dword reads to flash. */
491 for (i = 0; i < dwords; i++, faddr++) 485 for (i = 0; i < dwords; i++, faddr++)
492 dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(ha, 486 dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(vha->hw,
493 flash_data_to_access_addr(faddr))); 487 flash_data_to_access_addr(faddr)));
494 488
495 return dwptr; 489 return dwptr;
496} 490}
497 491
498static int 492static int
499qla24xx_write_flash_dword(scsi_qla_host_t *ha, uint32_t addr, uint32_t data) 493qla24xx_write_flash_dword(struct qla_hw_data *ha, uint32_t addr, uint32_t data)
500{ 494{
501 int rval; 495 int rval;
502 uint32_t cnt; 496 uint32_t cnt;
@@ -519,7 +513,7 @@ qla24xx_write_flash_dword(scsi_qla_host_t *ha, uint32_t addr, uint32_t data)
519} 513}
520 514
521static void 515static void
522qla24xx_get_flash_manufacturer(scsi_qla_host_t *ha, uint8_t *man_id, 516qla24xx_get_flash_manufacturer(struct qla_hw_data *ha, uint8_t *man_id,
523 uint8_t *flash_id) 517 uint8_t *flash_id)
524{ 518{
525 uint32_t ids; 519 uint32_t ids;
@@ -544,7 +538,7 @@ qla24xx_get_flash_manufacturer(scsi_qla_host_t *ha, uint8_t *man_id,
544} 538}
545 539
546static int 540static int
547qla2xxx_find_flt_start(scsi_qla_host_t *ha, uint32_t *start) 541qla2xxx_find_flt_start(scsi_qla_host_t *vha, uint32_t *start)
548{ 542{
549 const char *loc, *locations[] = { "DEF", "PCI" }; 543 const char *loc, *locations[] = { "DEF", "PCI" };
550 uint32_t pcihdr, pcids; 544 uint32_t pcihdr, pcids;
@@ -552,6 +546,8 @@ qla2xxx_find_flt_start(scsi_qla_host_t *ha, uint32_t *start)
552 uint8_t *buf, *bcode, last_image; 546 uint8_t *buf, *bcode, last_image;
553 uint16_t cnt, chksum, *wptr; 547 uint16_t cnt, chksum, *wptr;
554 struct qla_flt_location *fltl; 548 struct qla_flt_location *fltl;
549 struct qla_hw_data *ha = vha->hw;
550 struct req_que *req = ha->req;
555 551
556 /* 552 /*
557 * FLT-location structure resides after the last PCI region. 553 * FLT-location structure resides after the last PCI region.
@@ -563,20 +559,20 @@ qla2xxx_find_flt_start(scsi_qla_host_t *ha, uint32_t *start)
563 FA_FLASH_LAYOUT_ADDR; 559 FA_FLASH_LAYOUT_ADDR;
564 560
565 /* Begin with first PCI expansion ROM header. */ 561 /* Begin with first PCI expansion ROM header. */
566 buf = (uint8_t *)ha->request_ring; 562 buf = (uint8_t *)req->ring;
567 dcode = (uint32_t *)ha->request_ring; 563 dcode = (uint32_t *)req->ring;
568 pcihdr = 0; 564 pcihdr = 0;
569 last_image = 1; 565 last_image = 1;
570 do { 566 do {
571 /* Verify PCI expansion ROM header. */ 567 /* Verify PCI expansion ROM header. */
572 qla24xx_read_flash_data(ha, dcode, pcihdr >> 2, 0x20); 568 qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, 0x20);
573 bcode = buf + (pcihdr % 4); 569 bcode = buf + (pcihdr % 4);
574 if (bcode[0x0] != 0x55 || bcode[0x1] != 0xaa) 570 if (bcode[0x0] != 0x55 || bcode[0x1] != 0xaa)
575 goto end; 571 goto end;
576 572
577 /* Locate PCI data structure. */ 573 /* Locate PCI data structure. */
578 pcids = pcihdr + ((bcode[0x19] << 8) | bcode[0x18]); 574 pcids = pcihdr + ((bcode[0x19] << 8) | bcode[0x18]);
579 qla24xx_read_flash_data(ha, dcode, pcids >> 2, 0x20); 575 qla24xx_read_flash_data(vha, dcode, pcids >> 2, 0x20);
580 bcode = buf + (pcihdr % 4); 576 bcode = buf + (pcihdr % 4);
581 577
582 /* Validate signature of PCI data structure. */ 578 /* Validate signature of PCI data structure. */
@@ -591,14 +587,14 @@ qla2xxx_find_flt_start(scsi_qla_host_t *ha, uint32_t *start)
591 } while (!last_image); 587 } while (!last_image);
592 588
593 /* Now verify FLT-location structure. */ 589 /* Now verify FLT-location structure. */
594 fltl = (struct qla_flt_location *)ha->request_ring; 590 fltl = (struct qla_flt_location *)req->ring;
595 qla24xx_read_flash_data(ha, dcode, pcihdr >> 2, 591 qla24xx_read_flash_data(vha, dcode, pcihdr >> 2,
596 sizeof(struct qla_flt_location) >> 2); 592 sizeof(struct qla_flt_location) >> 2);
597 if (fltl->sig[0] != 'Q' || fltl->sig[1] != 'F' || 593 if (fltl->sig[0] != 'Q' || fltl->sig[1] != 'F' ||
598 fltl->sig[2] != 'L' || fltl->sig[3] != 'T') 594 fltl->sig[2] != 'L' || fltl->sig[3] != 'T')
599 goto end; 595 goto end;
600 596
601 wptr = (uint16_t *)ha->request_ring; 597 wptr = (uint16_t *)req->ring;
602 cnt = sizeof(struct qla_flt_location) >> 1; 598 cnt = sizeof(struct qla_flt_location) >> 1;
603 for (chksum = 0; cnt; cnt--) 599 for (chksum = 0; cnt; cnt--)
604 chksum += le16_to_cpu(*wptr++); 600 chksum += le16_to_cpu(*wptr++);
@@ -619,7 +615,7 @@ end:
619} 615}
620 616
621static void 617static void
622qla2xxx_get_flt_info(scsi_qla_host_t *ha, uint32_t flt_addr) 618qla2xxx_get_flt_info(scsi_qla_host_t *vha, uint32_t flt_addr)
623{ 619{
624 const char *loc, *locations[] = { "DEF", "FLT" }; 620 const char *loc, *locations[] = { "DEF", "FLT" };
625 uint16_t *wptr; 621 uint16_t *wptr;
@@ -627,12 +623,14 @@ qla2xxx_get_flt_info(scsi_qla_host_t *ha, uint32_t flt_addr)
627 uint32_t start; 623 uint32_t start;
628 struct qla_flt_header *flt; 624 struct qla_flt_header *flt;
629 struct qla_flt_region *region; 625 struct qla_flt_region *region;
626 struct qla_hw_data *ha = vha->hw;
627 struct req_que *req = ha->req;
630 628
631 ha->flt_region_flt = flt_addr; 629 ha->flt_region_flt = flt_addr;
632 wptr = (uint16_t *)ha->request_ring; 630 wptr = (uint16_t *)req->ring;
633 flt = (struct qla_flt_header *)ha->request_ring; 631 flt = (struct qla_flt_header *)req->ring;
634 region = (struct qla_flt_region *)&flt[1]; 632 region = (struct qla_flt_region *)&flt[1];
635 ha->isp_ops->read_optrom(ha, (uint8_t *)ha->request_ring, 633 ha->isp_ops->read_optrom(vha, (uint8_t *)req->ring,
636 flt_addr << 2, OPTROM_BURST_SIZE); 634 flt_addr << 2, OPTROM_BURST_SIZE);
637 if (*wptr == __constant_cpu_to_le16(0xffff)) 635 if (*wptr == __constant_cpu_to_le16(0xffff))
638 goto no_flash_data; 636 goto no_flash_data;
@@ -720,7 +718,7 @@ done:
720} 718}
721 719
722static void 720static void
723qla2xxx_get_fdt_info(scsi_qla_host_t *ha) 721qla2xxx_get_fdt_info(scsi_qla_host_t *vha)
724{ 722{
725#define FLASH_BLK_SIZE_4K 0x1000 723#define FLASH_BLK_SIZE_4K 0x1000
726#define FLASH_BLK_SIZE_32K 0x8000 724#define FLASH_BLK_SIZE_32K 0x8000
@@ -731,10 +729,12 @@ qla2xxx_get_fdt_info(scsi_qla_host_t *ha)
731 struct qla_fdt_layout *fdt; 729 struct qla_fdt_layout *fdt;
732 uint8_t man_id, flash_id; 730 uint8_t man_id, flash_id;
733 uint16_t mid, fid; 731 uint16_t mid, fid;
732 struct qla_hw_data *ha = vha->hw;
733 struct req_que *req = ha->req;
734 734
735 wptr = (uint16_t *)ha->request_ring; 735 wptr = (uint16_t *)req->ring;
736 fdt = (struct qla_fdt_layout *)ha->request_ring; 736 fdt = (struct qla_fdt_layout *)req->ring;
737 ha->isp_ops->read_optrom(ha, (uint8_t *)ha->request_ring, 737 ha->isp_ops->read_optrom(vha, (uint8_t *)req->ring,
738 ha->flt_region_fdt << 2, OPTROM_BURST_SIZE); 738 ha->flt_region_fdt << 2, OPTROM_BURST_SIZE);
739 if (*wptr == __constant_cpu_to_le16(0xffff)) 739 if (*wptr == __constant_cpu_to_le16(0xffff))
740 goto no_flash_data; 740 goto no_flash_data;
@@ -807,26 +807,27 @@ done:
807} 807}
808 808
809int 809int
810qla2xxx_get_flash_info(scsi_qla_host_t *ha) 810qla2xxx_get_flash_info(scsi_qla_host_t *vha)
811{ 811{
812 int ret; 812 int ret;
813 uint32_t flt_addr; 813 uint32_t flt_addr;
814 struct qla_hw_data *ha = vha->hw;
814 815
815 if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha)) 816 if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha))
816 return QLA_SUCCESS; 817 return QLA_SUCCESS;
817 818
818 ret = qla2xxx_find_flt_start(ha, &flt_addr); 819 ret = qla2xxx_find_flt_start(vha, &flt_addr);
819 if (ret != QLA_SUCCESS) 820 if (ret != QLA_SUCCESS)
820 return ret; 821 return ret;
821 822
822 qla2xxx_get_flt_info(ha, flt_addr); 823 qla2xxx_get_flt_info(vha, flt_addr);
823 qla2xxx_get_fdt_info(ha); 824 qla2xxx_get_fdt_info(vha);
824 825
825 return QLA_SUCCESS; 826 return QLA_SUCCESS;
826} 827}
827 828
828void 829void
829qla2xxx_flash_npiv_conf(scsi_qla_host_t *ha) 830qla2xxx_flash_npiv_conf(scsi_qla_host_t *vha)
830{ 831{
831#define NPIV_CONFIG_SIZE (16*1024) 832#define NPIV_CONFIG_SIZE (16*1024)
832 void *data; 833 void *data;
@@ -834,11 +835,12 @@ qla2xxx_flash_npiv_conf(scsi_qla_host_t *ha)
834 uint16_t cnt, chksum; 835 uint16_t cnt, chksum;
835 struct qla_npiv_header hdr; 836 struct qla_npiv_header hdr;
836 struct qla_npiv_entry *entry; 837 struct qla_npiv_entry *entry;
838 struct qla_hw_data *ha = vha->hw;
837 839
838 if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha)) 840 if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha))
839 return; 841 return;
840 842
841 ha->isp_ops->read_optrom(ha, (uint8_t *)&hdr, 843 ha->isp_ops->read_optrom(vha, (uint8_t *)&hdr,
842 ha->flt_region_npiv_conf << 2, sizeof(struct qla_npiv_header)); 844 ha->flt_region_npiv_conf << 2, sizeof(struct qla_npiv_header));
843 if (hdr.version == __constant_cpu_to_le16(0xffff)) 845 if (hdr.version == __constant_cpu_to_le16(0xffff))
844 return; 846 return;
@@ -857,7 +859,7 @@ qla2xxx_flash_npiv_conf(scsi_qla_host_t *ha)
857 return; 859 return;
858 } 860 }
859 861
860 ha->isp_ops->read_optrom(ha, (uint8_t *)data, 862 ha->isp_ops->read_optrom(vha, (uint8_t *)data,
861 ha->flt_region_npiv_conf << 2, NPIV_CONFIG_SIZE); 863 ha->flt_region_npiv_conf << 2, NPIV_CONFIG_SIZE);
862 864
863 cnt = (sizeof(struct qla_npiv_header) + le16_to_cpu(hdr.entries) * 865 cnt = (sizeof(struct qla_npiv_header) + le16_to_cpu(hdr.entries) *
@@ -893,24 +895,22 @@ qla2xxx_flash_npiv_conf(scsi_qla_host_t *ha)
893 vid.node_name = wwn_to_u64(entry->node_name); 895 vid.node_name = wwn_to_u64(entry->node_name);
894 896
895 DEBUG2(qla_printk(KERN_DEBUG, ha, "NPIV[%02x]: wwpn=%llx " 897 DEBUG2(qla_printk(KERN_DEBUG, ha, "NPIV[%02x]: wwpn=%llx "
896 "wwnn=%llx vf_id=0x%x qos=0x%x.\n", cnt, 898 "wwnn=%llx vf_id=0x%x qos=0x%x.\n", cnt, vid.port_name,
897 (unsigned long long)vid.port_name, 899 vid.node_name, le16_to_cpu(entry->vf_id),
898 (unsigned long long)vid.node_name, 900 le16_to_cpu(entry->qos)));
899 le16_to_cpu(entry->vf_id), le16_to_cpu(entry->qos)));
900 901
901 vport = fc_vport_create(ha->host, 0, &vid); 902 vport = fc_vport_create(vha->host, 0, &vid);
902 if (!vport) 903 if (!vport)
903 qla_printk(KERN_INFO, ha, "NPIV-Config: Failed to " 904 qla_printk(KERN_INFO, ha, "NPIV-Config: Failed to "
904 "create vport [%02x]: wwpn=%llx wwnn=%llx.\n", cnt, 905 "create vport [%02x]: wwpn=%llx wwnn=%llx.\n", cnt,
905 (unsigned long long)vid.port_name, 906 vid.port_name, vid.node_name);
906 (unsigned long long)vid.node_name);
907 } 907 }
908done: 908done:
909 kfree(data); 909 kfree(data);
910} 910}
911 911
912static void 912static void
913qla24xx_unprotect_flash(scsi_qla_host_t *ha) 913qla24xx_unprotect_flash(struct qla_hw_data *ha)
914{ 914{
915 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 915 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
916 916
@@ -929,7 +929,7 @@ qla24xx_unprotect_flash(scsi_qla_host_t *ha)
929} 929}
930 930
931static void 931static void
932qla24xx_protect_flash(scsi_qla_host_t *ha) 932qla24xx_protect_flash(struct qla_hw_data *ha)
933{ 933{
934 uint32_t cnt; 934 uint32_t cnt;
935 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 935 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
@@ -955,7 +955,7 @@ skip_wrt_protect:
955} 955}
956 956
957static int 957static int
958qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr, 958qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
959 uint32_t dwords) 959 uint32_t dwords)
960{ 960{
961 int ret; 961 int ret;
@@ -965,6 +965,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr,
965 dma_addr_t optrom_dma; 965 dma_addr_t optrom_dma;
966 void *optrom = NULL; 966 void *optrom = NULL;
967 uint32_t *s, *d; 967 uint32_t *s, *d;
968 struct qla_hw_data *ha = vha->hw;
968 969
969 ret = QLA_SUCCESS; 970 ret = QLA_SUCCESS;
970 971
@@ -1002,9 +1003,8 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr,
1002 (fdata & 0xff00) |((fdata << 16) & 1003 (fdata & 0xff00) |((fdata << 16) &
1003 0xff0000) | ((fdata >> 16) & 0xff)); 1004 0xff0000) | ((fdata >> 16) & 0xff));
1004 if (ret != QLA_SUCCESS) { 1005 if (ret != QLA_SUCCESS) {
1005 DEBUG9(printk("%s(%ld) Unable to flash " 1006 DEBUG9(qla_printk("Unable to flash sector: "
1006 "sector: address=%x.\n", __func__, 1007 "address=%x.\n", faddr));
1007 ha->host_no, faddr));
1008 break; 1008 break;
1009 } 1009 }
1010 } 1010 }
@@ -1016,7 +1016,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr,
1016 miter < OPTROM_BURST_DWORDS; miter++, s++, d++) 1016 miter < OPTROM_BURST_DWORDS; miter++, s++, d++)
1017 *s = cpu_to_le32(*d); 1017 *s = cpu_to_le32(*d);
1018 1018
1019 ret = qla2x00_load_ram(ha, optrom_dma, 1019 ret = qla2x00_load_ram(vha, optrom_dma,
1020 flash_data_to_access_addr(faddr), 1020 flash_data_to_access_addr(faddr),
1021 OPTROM_BURST_DWORDS); 1021 OPTROM_BURST_DWORDS);
1022 if (ret != QLA_SUCCESS) { 1022 if (ret != QLA_SUCCESS) {
@@ -1044,7 +1044,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr,
1044 if (ret != QLA_SUCCESS) { 1044 if (ret != QLA_SUCCESS) {
1045 DEBUG9(printk("%s(%ld) Unable to program flash " 1045 DEBUG9(printk("%s(%ld) Unable to program flash "
1046 "address=%x data=%x.\n", __func__, 1046 "address=%x data=%x.\n", __func__,
1047 ha->host_no, faddr, *dwptr)); 1047 vha->host_no, faddr, *dwptr));
1048 break; 1048 break;
1049 } 1049 }
1050 1050
@@ -1067,11 +1067,12 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr,
1067} 1067}
1068 1068
1069uint8_t * 1069uint8_t *
1070qla2x00_read_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, 1070qla2x00_read_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
1071 uint32_t bytes) 1071 uint32_t bytes)
1072{ 1072{
1073 uint32_t i; 1073 uint32_t i;
1074 uint16_t *wptr; 1074 uint16_t *wptr;
1075 struct qla_hw_data *ha = vha->hw;
1075 1076
1076 /* Word reads to NVRAM via registers. */ 1077 /* Word reads to NVRAM via registers. */
1077 wptr = (uint16_t *)buf; 1078 wptr = (uint16_t *)buf;
@@ -1085,7 +1086,7 @@ qla2x00_read_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr,
1085} 1086}
1086 1087
1087uint8_t * 1088uint8_t *
1088qla24xx_read_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, 1089qla24xx_read_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
1089 uint32_t bytes) 1090 uint32_t bytes)
1090{ 1091{
1091 uint32_t i; 1092 uint32_t i;
@@ -1094,20 +1095,21 @@ qla24xx_read_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr,
1094 /* Dword reads to flash. */ 1095 /* Dword reads to flash. */
1095 dwptr = (uint32_t *)buf; 1096 dwptr = (uint32_t *)buf;
1096 for (i = 0; i < bytes >> 2; i++, naddr++) 1097 for (i = 0; i < bytes >> 2; i++, naddr++)
1097 dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(ha, 1098 dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(vha->hw,
1098 nvram_data_to_access_addr(naddr))); 1099 nvram_data_to_access_addr(naddr)));
1099 1100
1100 return buf; 1101 return buf;
1101} 1102}
1102 1103
1103int 1104int
1104qla2x00_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, 1105qla2x00_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
1105 uint32_t bytes) 1106 uint32_t bytes)
1106{ 1107{
1107 int ret, stat; 1108 int ret, stat;
1108 uint32_t i; 1109 uint32_t i;
1109 uint16_t *wptr; 1110 uint16_t *wptr;
1110 unsigned long flags; 1111 unsigned long flags;
1112 struct qla_hw_data *ha = vha->hw;
1111 1113
1112 ret = QLA_SUCCESS; 1114 ret = QLA_SUCCESS;
1113 1115
@@ -1134,12 +1136,13 @@ qla2x00_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr,
1134} 1136}
1135 1137
1136int 1138int
1137qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, 1139qla24xx_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
1138 uint32_t bytes) 1140 uint32_t bytes)
1139{ 1141{
1140 int ret; 1142 int ret;
1141 uint32_t i; 1143 uint32_t i;
1142 uint32_t *dwptr; 1144 uint32_t *dwptr;
1145 struct qla_hw_data *ha = vha->hw;
1143 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 1146 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1144 1147
1145 ret = QLA_SUCCESS; 1148 ret = QLA_SUCCESS;
@@ -1162,9 +1165,8 @@ qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr,
1162 nvram_data_to_access_addr(naddr), 1165 nvram_data_to_access_addr(naddr),
1163 cpu_to_le32(*dwptr)); 1166 cpu_to_le32(*dwptr));
1164 if (ret != QLA_SUCCESS) { 1167 if (ret != QLA_SUCCESS) {
1165 DEBUG9(printk("%s(%ld) Unable to program " 1168 DEBUG9(qla_printk("Unable to program nvram address=%x "
1166 "nvram address=%x data=%x.\n", __func__, 1169 "data=%x.\n", naddr, *dwptr));
1167 ha->host_no, naddr, *dwptr));
1168 break; 1170 break;
1169 } 1171 }
1170 } 1172 }
@@ -1182,11 +1184,12 @@ qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr,
1182} 1184}
1183 1185
1184uint8_t * 1186uint8_t *
1185qla25xx_read_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, 1187qla25xx_read_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
1186 uint32_t bytes) 1188 uint32_t bytes)
1187{ 1189{
1188 uint32_t i; 1190 uint32_t i;
1189 uint32_t *dwptr; 1191 uint32_t *dwptr;
1192 struct qla_hw_data *ha = vha->hw;
1190 1193
1191 /* Dword reads to flash. */ 1194 /* Dword reads to flash. */
1192 dwptr = (uint32_t *)buf; 1195 dwptr = (uint32_t *)buf;
@@ -1199,19 +1202,20 @@ qla25xx_read_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr,
1199} 1202}
1200 1203
1201int 1204int
1202qla25xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, 1205qla25xx_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
1203 uint32_t bytes) 1206 uint32_t bytes)
1204{ 1207{
1208 struct qla_hw_data *ha = vha->hw;
1205#define RMW_BUFFER_SIZE (64 * 1024) 1209#define RMW_BUFFER_SIZE (64 * 1024)
1206 uint8_t *dbuf; 1210 uint8_t *dbuf;
1207 1211
1208 dbuf = vmalloc(RMW_BUFFER_SIZE); 1212 dbuf = vmalloc(RMW_BUFFER_SIZE);
1209 if (!dbuf) 1213 if (!dbuf)
1210 return QLA_MEMORY_ALLOC_FAILED; 1214 return QLA_MEMORY_ALLOC_FAILED;
1211 ha->isp_ops->read_optrom(ha, dbuf, ha->flt_region_vpd_nvram << 2, 1215 ha->isp_ops->read_optrom(vha, dbuf, ha->flt_region_vpd_nvram << 2,
1212 RMW_BUFFER_SIZE); 1216 RMW_BUFFER_SIZE);
1213 memcpy(dbuf + (naddr << 2), buf, bytes); 1217 memcpy(dbuf + (naddr << 2), buf, bytes);
1214 ha->isp_ops->write_optrom(ha, dbuf, ha->flt_region_vpd_nvram << 2, 1218 ha->isp_ops->write_optrom(vha, dbuf, ha->flt_region_vpd_nvram << 2,
1215 RMW_BUFFER_SIZE); 1219 RMW_BUFFER_SIZE);
1216 vfree(dbuf); 1220 vfree(dbuf);
1217 1221
@@ -1219,7 +1223,7 @@ qla25xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr,
1219} 1223}
1220 1224
1221static inline void 1225static inline void
1222qla2x00_flip_colors(scsi_qla_host_t *ha, uint16_t *pflags) 1226qla2x00_flip_colors(struct qla_hw_data *ha, uint16_t *pflags)
1223{ 1227{
1224 if (IS_QLA2322(ha)) { 1228 if (IS_QLA2322(ha)) {
1225 /* Flip all colors. */ 1229 /* Flip all colors. */
@@ -1249,12 +1253,13 @@ qla2x00_flip_colors(scsi_qla_host_t *ha, uint16_t *pflags)
1249#define PIO_REG(h, r) ((h)->pio_address + offsetof(struct device_reg_2xxx, r)) 1253#define PIO_REG(h, r) ((h)->pio_address + offsetof(struct device_reg_2xxx, r))
1250 1254
1251void 1255void
1252qla2x00_beacon_blink(struct scsi_qla_host *ha) 1256qla2x00_beacon_blink(struct scsi_qla_host *vha)
1253{ 1257{
1254 uint16_t gpio_enable; 1258 uint16_t gpio_enable;
1255 uint16_t gpio_data; 1259 uint16_t gpio_data;
1256 uint16_t led_color = 0; 1260 uint16_t led_color = 0;
1257 unsigned long flags; 1261 unsigned long flags;
1262 struct qla_hw_data *ha = vha->hw;
1258 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 1263 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1259 1264
1260 spin_lock_irqsave(&ha->hardware_lock, flags); 1265 spin_lock_irqsave(&ha->hardware_lock, flags);
@@ -1298,17 +1303,18 @@ qla2x00_beacon_blink(struct scsi_qla_host *ha)
1298} 1303}
1299 1304
1300int 1305int
1301qla2x00_beacon_on(struct scsi_qla_host *ha) 1306qla2x00_beacon_on(struct scsi_qla_host *vha)
1302{ 1307{
1303 uint16_t gpio_enable; 1308 uint16_t gpio_enable;
1304 uint16_t gpio_data; 1309 uint16_t gpio_data;
1305 unsigned long flags; 1310 unsigned long flags;
1311 struct qla_hw_data *ha = vha->hw;
1306 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 1312 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1307 1313
1308 ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING; 1314 ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING;
1309 ha->fw_options[1] |= FO1_DISABLE_GPIO6_7; 1315 ha->fw_options[1] |= FO1_DISABLE_GPIO6_7;
1310 1316
1311 if (qla2x00_set_fw_options(ha, ha->fw_options) != QLA_SUCCESS) { 1317 if (qla2x00_set_fw_options(vha, ha->fw_options) != QLA_SUCCESS) {
1312 qla_printk(KERN_WARNING, ha, 1318 qla_printk(KERN_WARNING, ha,
1313 "Unable to update fw options (beacon on).\n"); 1319 "Unable to update fw options (beacon on).\n");
1314 return QLA_FUNCTION_FAILED; 1320 return QLA_FUNCTION_FAILED;
@@ -1354,9 +1360,10 @@ qla2x00_beacon_on(struct scsi_qla_host *ha)
1354} 1360}
1355 1361
1356int 1362int
1357qla2x00_beacon_off(struct scsi_qla_host *ha) 1363qla2x00_beacon_off(struct scsi_qla_host *vha)
1358{ 1364{
1359 int rval = QLA_SUCCESS; 1365 int rval = QLA_SUCCESS;
1366 struct qla_hw_data *ha = vha->hw;
1360 1367
1361 ha->beacon_blink_led = 0; 1368 ha->beacon_blink_led = 0;
1362 1369
@@ -1366,12 +1373,12 @@ qla2x00_beacon_off(struct scsi_qla_host *ha)
1366 else 1373 else
1367 ha->beacon_color_state = QLA_LED_GRN_ON; 1374 ha->beacon_color_state = QLA_LED_GRN_ON;
1368 1375
1369 ha->isp_ops->beacon_blink(ha); /* This turns green LED off */ 1376 ha->isp_ops->beacon_blink(vha); /* This turns green LED off */
1370 1377
1371 ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING; 1378 ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING;
1372 ha->fw_options[1] &= ~FO1_DISABLE_GPIO6_7; 1379 ha->fw_options[1] &= ~FO1_DISABLE_GPIO6_7;
1373 1380
1374 rval = qla2x00_set_fw_options(ha, ha->fw_options); 1381 rval = qla2x00_set_fw_options(vha, ha->fw_options);
1375 if (rval != QLA_SUCCESS) 1382 if (rval != QLA_SUCCESS)
1376 qla_printk(KERN_WARNING, ha, 1383 qla_printk(KERN_WARNING, ha,
1377 "Unable to update fw options (beacon off).\n"); 1384 "Unable to update fw options (beacon off).\n");
@@ -1380,7 +1387,7 @@ qla2x00_beacon_off(struct scsi_qla_host *ha)
1380 1387
1381 1388
1382static inline void 1389static inline void
1383qla24xx_flip_colors(scsi_qla_host_t *ha, uint16_t *pflags) 1390qla24xx_flip_colors(struct qla_hw_data *ha, uint16_t *pflags)
1384{ 1391{
1385 /* Flip all colors. */ 1392 /* Flip all colors. */
1386 if (ha->beacon_color_state == QLA_LED_ALL_ON) { 1393 if (ha->beacon_color_state == QLA_LED_ALL_ON) {
@@ -1395,11 +1402,12 @@ qla24xx_flip_colors(scsi_qla_host_t *ha, uint16_t *pflags)
1395} 1402}
1396 1403
1397void 1404void
1398qla24xx_beacon_blink(struct scsi_qla_host *ha) 1405qla24xx_beacon_blink(struct scsi_qla_host *vha)
1399{ 1406{
1400 uint16_t led_color = 0; 1407 uint16_t led_color = 0;
1401 uint32_t gpio_data; 1408 uint32_t gpio_data;
1402 unsigned long flags; 1409 unsigned long flags;
1410 struct qla_hw_data *ha = vha->hw;
1403 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 1411 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1404 1412
1405 /* Save the Original GPIOD. */ 1413 /* Save the Original GPIOD. */
@@ -1428,20 +1436,21 @@ qla24xx_beacon_blink(struct scsi_qla_host *ha)
1428} 1436}
1429 1437
1430int 1438int
1431qla24xx_beacon_on(struct scsi_qla_host *ha) 1439qla24xx_beacon_on(struct scsi_qla_host *vha)
1432{ 1440{
1433 uint32_t gpio_data; 1441 uint32_t gpio_data;
1434 unsigned long flags; 1442 unsigned long flags;
1443 struct qla_hw_data *ha = vha->hw;
1435 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 1444 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1436 1445
1437 if (ha->beacon_blink_led == 0) { 1446 if (ha->beacon_blink_led == 0) {
1438 /* Enable firmware for update */ 1447 /* Enable firmware for update */
1439 ha->fw_options[1] |= ADD_FO1_DISABLE_GPIO_LED_CTRL; 1448 ha->fw_options[1] |= ADD_FO1_DISABLE_GPIO_LED_CTRL;
1440 1449
1441 if (qla2x00_set_fw_options(ha, ha->fw_options) != QLA_SUCCESS) 1450 if (qla2x00_set_fw_options(vha, ha->fw_options) != QLA_SUCCESS)
1442 return QLA_FUNCTION_FAILED; 1451 return QLA_FUNCTION_FAILED;
1443 1452
1444 if (qla2x00_get_fw_options(ha, ha->fw_options) != 1453 if (qla2x00_get_fw_options(vha, ha->fw_options) !=
1445 QLA_SUCCESS) { 1454 QLA_SUCCESS) {
1446 qla_printk(KERN_WARNING, ha, 1455 qla_printk(KERN_WARNING, ha,
1447 "Unable to update fw options (beacon on).\n"); 1456 "Unable to update fw options (beacon on).\n");
@@ -1469,16 +1478,17 @@ qla24xx_beacon_on(struct scsi_qla_host *ha)
1469} 1478}
1470 1479
1471int 1480int
1472qla24xx_beacon_off(struct scsi_qla_host *ha) 1481qla24xx_beacon_off(struct scsi_qla_host *vha)
1473{ 1482{
1474 uint32_t gpio_data; 1483 uint32_t gpio_data;
1475 unsigned long flags; 1484 unsigned long flags;
1485 struct qla_hw_data *ha = vha->hw;
1476 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 1486 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1477 1487
1478 ha->beacon_blink_led = 0; 1488 ha->beacon_blink_led = 0;
1479 ha->beacon_color_state = QLA_LED_ALL_ON; 1489 ha->beacon_color_state = QLA_LED_ALL_ON;
1480 1490
1481 ha->isp_ops->beacon_blink(ha); /* Will flip to all off. */ 1491 ha->isp_ops->beacon_blink(vha); /* Will flip to all off. */
1482 1492
1483 /* Give control back to firmware. */ 1493 /* Give control back to firmware. */
1484 spin_lock_irqsave(&ha->hardware_lock, flags); 1494 spin_lock_irqsave(&ha->hardware_lock, flags);
@@ -1492,13 +1502,13 @@ qla24xx_beacon_off(struct scsi_qla_host *ha)
1492 1502
1493 ha->fw_options[1] &= ~ADD_FO1_DISABLE_GPIO_LED_CTRL; 1503 ha->fw_options[1] &= ~ADD_FO1_DISABLE_GPIO_LED_CTRL;
1494 1504
1495 if (qla2x00_set_fw_options(ha, ha->fw_options) != QLA_SUCCESS) { 1505 if (qla2x00_set_fw_options(vha, ha->fw_options) != QLA_SUCCESS) {
1496 qla_printk(KERN_WARNING, ha, 1506 qla_printk(KERN_WARNING, ha,
1497 "Unable to update fw options (beacon off).\n"); 1507 "Unable to update fw options (beacon off).\n");
1498 return QLA_FUNCTION_FAILED; 1508 return QLA_FUNCTION_FAILED;
1499 } 1509 }
1500 1510
1501 if (qla2x00_get_fw_options(ha, ha->fw_options) != QLA_SUCCESS) { 1511 if (qla2x00_get_fw_options(vha, ha->fw_options) != QLA_SUCCESS) {
1502 qla_printk(KERN_WARNING, ha, 1512 qla_printk(KERN_WARNING, ha,
1503 "Unable to get fw options (beacon off).\n"); 1513 "Unable to get fw options (beacon off).\n");
1504 return QLA_FUNCTION_FAILED; 1514 return QLA_FUNCTION_FAILED;
@@ -1517,7 +1527,7 @@ qla24xx_beacon_off(struct scsi_qla_host *ha)
1517 * @ha: HA context 1527 * @ha: HA context
1518 */ 1528 */
1519static void 1529static void
1520qla2x00_flash_enable(scsi_qla_host_t *ha) 1530qla2x00_flash_enable(struct qla_hw_data *ha)
1521{ 1531{
1522 uint16_t data; 1532 uint16_t data;
1523 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 1533 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
@@ -1533,7 +1543,7 @@ qla2x00_flash_enable(scsi_qla_host_t *ha)
1533 * @ha: HA context 1543 * @ha: HA context
1534 */ 1544 */
1535static void 1545static void
1536qla2x00_flash_disable(scsi_qla_host_t *ha) 1546qla2x00_flash_disable(struct qla_hw_data *ha)
1537{ 1547{
1538 uint16_t data; 1548 uint16_t data;
1539 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 1549 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
@@ -1554,7 +1564,7 @@ qla2x00_flash_disable(scsi_qla_host_t *ha)
1554 * Returns the byte read from flash @addr. 1564 * Returns the byte read from flash @addr.
1555 */ 1565 */
1556static uint8_t 1566static uint8_t
1557qla2x00_read_flash_byte(scsi_qla_host_t *ha, uint32_t addr) 1567qla2x00_read_flash_byte(struct qla_hw_data *ha, uint32_t addr)
1558{ 1568{
1559 uint16_t data; 1569 uint16_t data;
1560 uint16_t bank_select; 1570 uint16_t bank_select;
@@ -1615,7 +1625,7 @@ qla2x00_read_flash_byte(scsi_qla_host_t *ha, uint32_t addr)
1615 * @data: Data to write 1625 * @data: Data to write
1616 */ 1626 */
1617static void 1627static void
1618qla2x00_write_flash_byte(scsi_qla_host_t *ha, uint32_t addr, uint8_t data) 1628qla2x00_write_flash_byte(struct qla_hw_data *ha, uint32_t addr, uint8_t data)
1619{ 1629{
1620 uint16_t bank_select; 1630 uint16_t bank_select;
1621 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 1631 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
@@ -1678,7 +1688,7 @@ qla2x00_write_flash_byte(scsi_qla_host_t *ha, uint32_t addr, uint8_t data)
1678 * Returns 0 on success, else non-zero. 1688 * Returns 0 on success, else non-zero.
1679 */ 1689 */
1680static int 1690static int
1681qla2x00_poll_flash(scsi_qla_host_t *ha, uint32_t addr, uint8_t poll_data, 1691qla2x00_poll_flash(struct qla_hw_data *ha, uint32_t addr, uint8_t poll_data,
1682 uint8_t man_id, uint8_t flash_id) 1692 uint8_t man_id, uint8_t flash_id)
1683{ 1693{
1684 int status; 1694 int status;
@@ -1718,8 +1728,8 @@ qla2x00_poll_flash(scsi_qla_host_t *ha, uint32_t addr, uint8_t poll_data,
1718 * Returns 0 on success, else non-zero. 1728 * Returns 0 on success, else non-zero.
1719 */ 1729 */
1720static int 1730static int
1721qla2x00_program_flash_address(scsi_qla_host_t *ha, uint32_t addr, uint8_t data, 1731qla2x00_program_flash_address(struct qla_hw_data *ha, uint32_t addr,
1722 uint8_t man_id, uint8_t flash_id) 1732 uint8_t data, uint8_t man_id, uint8_t flash_id)
1723{ 1733{
1724 /* Write Program Command Sequence. */ 1734 /* Write Program Command Sequence. */
1725 if (IS_OEM_001(ha)) { 1735 if (IS_OEM_001(ha)) {
@@ -1755,7 +1765,7 @@ qla2x00_program_flash_address(scsi_qla_host_t *ha, uint32_t addr, uint8_t data,
1755 * Returns 0 on success, else non-zero. 1765 * Returns 0 on success, else non-zero.
1756 */ 1766 */
1757static int 1767static int
1758qla2x00_erase_flash(scsi_qla_host_t *ha, uint8_t man_id, uint8_t flash_id) 1768qla2x00_erase_flash(struct qla_hw_data *ha, uint8_t man_id, uint8_t flash_id)
1759{ 1769{
1760 /* Individual Sector Erase Command Sequence */ 1770 /* Individual Sector Erase Command Sequence */
1761 if (IS_OEM_001(ha)) { 1771 if (IS_OEM_001(ha)) {
@@ -1791,7 +1801,7 @@ qla2x00_erase_flash(scsi_qla_host_t *ha, uint8_t man_id, uint8_t flash_id)
1791 * Returns 0 on success, else non-zero. 1801 * Returns 0 on success, else non-zero.
1792 */ 1802 */
1793static int 1803static int
1794qla2x00_erase_flash_sector(scsi_qla_host_t *ha, uint32_t addr, 1804qla2x00_erase_flash_sector(struct qla_hw_data *ha, uint32_t addr,
1795 uint32_t sec_mask, uint8_t man_id, uint8_t flash_id) 1805 uint32_t sec_mask, uint8_t man_id, uint8_t flash_id)
1796{ 1806{
1797 /* Individual Sector Erase Command Sequence */ 1807 /* Individual Sector Erase Command Sequence */
@@ -1817,7 +1827,7 @@ qla2x00_erase_flash_sector(scsi_qla_host_t *ha, uint32_t addr,
1817 * @flash_id: Flash ID 1827 * @flash_id: Flash ID
1818 */ 1828 */
1819static void 1829static void
1820qla2x00_get_flash_manufacturer(scsi_qla_host_t *ha, uint8_t *man_id, 1830qla2x00_get_flash_manufacturer(struct qla_hw_data *ha, uint8_t *man_id,
1821 uint8_t *flash_id) 1831 uint8_t *flash_id)
1822{ 1832{
1823 qla2x00_write_flash_byte(ha, 0x5555, 0xaa); 1833 qla2x00_write_flash_byte(ha, 0x5555, 0xaa);
@@ -1831,8 +1841,8 @@ qla2x00_get_flash_manufacturer(scsi_qla_host_t *ha, uint8_t *man_id,
1831} 1841}
1832 1842
1833static void 1843static void
1834qla2x00_read_flash_data(scsi_qla_host_t *ha, uint8_t *tmp_buf, uint32_t saddr, 1844qla2x00_read_flash_data(struct qla_hw_data *ha, uint8_t *tmp_buf,
1835 uint32_t length) 1845 uint32_t saddr, uint32_t length)
1836{ 1846{
1837 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 1847 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1838 uint32_t midpoint, ilength; 1848 uint32_t midpoint, ilength;
@@ -1856,14 +1866,15 @@ qla2x00_read_flash_data(scsi_qla_host_t *ha, uint8_t *tmp_buf, uint32_t saddr,
1856} 1866}
1857 1867
1858static inline void 1868static inline void
1859qla2x00_suspend_hba(struct scsi_qla_host *ha) 1869qla2x00_suspend_hba(struct scsi_qla_host *vha)
1860{ 1870{
1861 int cnt; 1871 int cnt;
1862 unsigned long flags; 1872 unsigned long flags;
1873 struct qla_hw_data *ha = vha->hw;
1863 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 1874 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1864 1875
1865 /* Suspend HBA. */ 1876 /* Suspend HBA. */
1866 scsi_block_requests(ha->host); 1877 scsi_block_requests(vha->host);
1867 ha->isp_ops->disable_intrs(ha); 1878 ha->isp_ops->disable_intrs(ha);
1868 set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); 1879 set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
1869 1880
@@ -1884,26 +1895,29 @@ qla2x00_suspend_hba(struct scsi_qla_host *ha)
1884} 1895}
1885 1896
1886static inline void 1897static inline void
1887qla2x00_resume_hba(struct scsi_qla_host *ha) 1898qla2x00_resume_hba(struct scsi_qla_host *vha)
1888{ 1899{
1900 struct qla_hw_data *ha = vha->hw;
1901
1889 /* Resume HBA. */ 1902 /* Resume HBA. */
1890 clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); 1903 clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
1891 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 1904 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
1892 qla2xxx_wake_dpc(ha); 1905 qla2xxx_wake_dpc(vha);
1893 qla2x00_wait_for_hba_online(ha); 1906 qla2x00_wait_for_hba_online(vha);
1894 scsi_unblock_requests(ha->host); 1907 scsi_unblock_requests(vha->host);
1895} 1908}
1896 1909
1897uint8_t * 1910uint8_t *
1898qla2x00_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf, 1911qla2x00_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf,
1899 uint32_t offset, uint32_t length) 1912 uint32_t offset, uint32_t length)
1900{ 1913{
1901 uint32_t addr, midpoint; 1914 uint32_t addr, midpoint;
1902 uint8_t *data; 1915 uint8_t *data;
1916 struct qla_hw_data *ha = vha->hw;
1903 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 1917 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1904 1918
1905 /* Suspend HBA. */ 1919 /* Suspend HBA. */
1906 qla2x00_suspend_hba(ha); 1920 qla2x00_suspend_hba(vha);
1907 1921
1908 /* Go with read. */ 1922 /* Go with read. */
1909 midpoint = ha->optrom_size / 2; 1923 midpoint = ha->optrom_size / 2;
@@ -1922,13 +1936,13 @@ qla2x00_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf,
1922 qla2x00_flash_disable(ha); 1936 qla2x00_flash_disable(ha);
1923 1937
1924 /* Resume HBA. */ 1938 /* Resume HBA. */
1925 qla2x00_resume_hba(ha); 1939 qla2x00_resume_hba(vha);
1926 1940
1927 return buf; 1941 return buf;
1928} 1942}
1929 1943
1930int 1944int
1931qla2x00_write_optrom_data(struct scsi_qla_host *ha, uint8_t *buf, 1945qla2x00_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf,
1932 uint32_t offset, uint32_t length) 1946 uint32_t offset, uint32_t length)
1933{ 1947{
1934 1948
@@ -1936,10 +1950,11 @@ qla2x00_write_optrom_data(struct scsi_qla_host *ha, uint8_t *buf,
1936 uint8_t man_id, flash_id, sec_number, data; 1950 uint8_t man_id, flash_id, sec_number, data;
1937 uint16_t wd; 1951 uint16_t wd;
1938 uint32_t addr, liter, sec_mask, rest_addr; 1952 uint32_t addr, liter, sec_mask, rest_addr;
1953 struct qla_hw_data *ha = vha->hw;
1939 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 1954 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1940 1955
1941 /* Suspend HBA. */ 1956 /* Suspend HBA. */
1942 qla2x00_suspend_hba(ha); 1957 qla2x00_suspend_hba(vha);
1943 1958
1944 rval = QLA_SUCCESS; 1959 rval = QLA_SUCCESS;
1945 sec_number = 0; 1960 sec_number = 0;
@@ -2139,55 +2154,58 @@ update_flash:
2139 qla2x00_flash_disable(ha); 2154 qla2x00_flash_disable(ha);
2140 2155
2141 /* Resume HBA. */ 2156 /* Resume HBA. */
2142 qla2x00_resume_hba(ha); 2157 qla2x00_resume_hba(vha);
2143 2158
2144 return rval; 2159 return rval;
2145} 2160}
2146 2161
2147uint8_t * 2162uint8_t *
2148qla24xx_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf, 2163qla24xx_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf,
2149 uint32_t offset, uint32_t length) 2164 uint32_t offset, uint32_t length)
2150{ 2165{
2166 struct qla_hw_data *ha = vha->hw;
2167
2151 /* Suspend HBA. */ 2168 /* Suspend HBA. */
2152 scsi_block_requests(ha->host); 2169 scsi_block_requests(vha->host);
2153 set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); 2170 set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
2154 2171
2155 /* Go with read. */ 2172 /* Go with read. */
2156 qla24xx_read_flash_data(ha, (uint32_t *)buf, offset >> 2, length >> 2); 2173 qla24xx_read_flash_data(vha, (uint32_t *)buf, offset >> 2, length >> 2);
2157 2174
2158 /* Resume HBA. */ 2175 /* Resume HBA. */
2159 clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); 2176 clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
2160 scsi_unblock_requests(ha->host); 2177 scsi_unblock_requests(vha->host);
2161 2178
2162 return buf; 2179 return buf;
2163} 2180}
2164 2181
2165int 2182int
2166qla24xx_write_optrom_data(struct scsi_qla_host *ha, uint8_t *buf, 2183qla24xx_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf,
2167 uint32_t offset, uint32_t length) 2184 uint32_t offset, uint32_t length)
2168{ 2185{
2169 int rval; 2186 int rval;
2187 struct qla_hw_data *ha = vha->hw;
2170 2188
2171 /* Suspend HBA. */ 2189 /* Suspend HBA. */
2172 scsi_block_requests(ha->host); 2190 scsi_block_requests(vha->host);
2173 set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); 2191 set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
2174 2192
2175 /* Go with write. */ 2193 /* Go with write. */
2176 rval = qla24xx_write_flash_data(ha, (uint32_t *)buf, offset >> 2, 2194 rval = qla24xx_write_flash_data(vha, (uint32_t *)buf, offset >> 2,
2177 length >> 2); 2195 length >> 2);
2178 2196
2179 /* Resume HBA -- RISC reset needed. */ 2197 /* Resume HBA -- RISC reset needed. */
2180 clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); 2198 clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
2181 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 2199 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
2182 qla2xxx_wake_dpc(ha); 2200 qla2xxx_wake_dpc(vha);
2183 qla2x00_wait_for_hba_online(ha); 2201 qla2x00_wait_for_hba_online(vha);
2184 scsi_unblock_requests(ha->host); 2202 scsi_unblock_requests(vha->host);
2185 2203
2186 return rval; 2204 return rval;
2187} 2205}
2188 2206
2189uint8_t * 2207uint8_t *
2190qla25xx_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf, 2208qla25xx_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf,
2191 uint32_t offset, uint32_t length) 2209 uint32_t offset, uint32_t length)
2192{ 2210{
2193 int rval; 2211 int rval;
@@ -2195,6 +2213,7 @@ qla25xx_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf,
2195 void *optrom; 2213 void *optrom;
2196 uint8_t *pbuf; 2214 uint8_t *pbuf;
2197 uint32_t faddr, left, burst; 2215 uint32_t faddr, left, burst;
2216 struct qla_hw_data *ha = vha->hw;
2198 2217
2199 if (offset & 0xfff) 2218 if (offset & 0xfff)
2200 goto slow_read; 2219 goto slow_read;
@@ -2219,7 +2238,7 @@ qla25xx_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf,
2219 if (burst > left) 2238 if (burst > left)
2220 burst = left; 2239 burst = left;
2221 2240
2222 rval = qla2x00_dump_ram(ha, optrom_dma, 2241 rval = qla2x00_dump_ram(vha, optrom_dma,
2223 flash_data_to_access_addr(faddr), burst); 2242 flash_data_to_access_addr(faddr), burst);
2224 if (rval) { 2243 if (rval) {
2225 qla_printk(KERN_WARNING, ha, 2244 qla_printk(KERN_WARNING, ha,
@@ -2248,7 +2267,7 @@ qla25xx_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf,
2248 return buf; 2267 return buf;
2249 2268
2250slow_read: 2269slow_read:
2251 return qla24xx_read_optrom_data(ha, buf, offset, length); 2270 return qla24xx_read_optrom_data(vha, buf, offset, length);
2252} 2271}
2253 2272
2254/** 2273/**
@@ -2270,7 +2289,7 @@ slow_read:
2270 * Returns QLA_SUCCESS on successful retrieval of version. 2289 * Returns QLA_SUCCESS on successful retrieval of version.
2271 */ 2290 */
2272static void 2291static void
2273qla2x00_get_fcode_version(scsi_qla_host_t *ha, uint32_t pcids) 2292qla2x00_get_fcode_version(struct qla_hw_data *ha, uint32_t pcids)
2274{ 2293{
2275 int ret = QLA_FUNCTION_FAILED; 2294 int ret = QLA_FUNCTION_FAILED;
2276 uint32_t istart, iend, iter, vend; 2295 uint32_t istart, iend, iter, vend;
@@ -2344,13 +2363,14 @@ qla2x00_get_fcode_version(scsi_qla_host_t *ha, uint32_t pcids)
2344} 2363}
2345 2364
2346int 2365int
2347qla2x00_get_flash_version(scsi_qla_host_t *ha, void *mbuf) 2366qla2x00_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
2348{ 2367{
2349 int ret = QLA_SUCCESS; 2368 int ret = QLA_SUCCESS;
2350 uint8_t code_type, last_image; 2369 uint8_t code_type, last_image;
2351 uint32_t pcihdr, pcids; 2370 uint32_t pcihdr, pcids;
2352 uint8_t *dbyte; 2371 uint8_t *dbyte;
2353 uint16_t *dcode; 2372 uint16_t *dcode;
2373 struct qla_hw_data *ha = vha->hw;
2354 2374
2355 if (!ha->pio_address || !mbuf) 2375 if (!ha->pio_address || !mbuf)
2356 return QLA_FUNCTION_FAILED; 2376 return QLA_FUNCTION_FAILED;
@@ -2370,8 +2390,8 @@ qla2x00_get_flash_version(scsi_qla_host_t *ha, void *mbuf)
2370 if (qla2x00_read_flash_byte(ha, pcihdr) != 0x55 || 2390 if (qla2x00_read_flash_byte(ha, pcihdr) != 0x55 ||
2371 qla2x00_read_flash_byte(ha, pcihdr + 0x01) != 0xaa) { 2391 qla2x00_read_flash_byte(ha, pcihdr + 0x01) != 0xaa) {
2372 /* No signature */ 2392 /* No signature */
2373 DEBUG2(printk("scsi(%ld): No matching ROM " 2393 DEBUG2(qla_printk(KERN_DEBUG, ha, "No matching ROM "
2374 "signature.\n", ha->host_no)); 2394 "signature.\n"));
2375 ret = QLA_FUNCTION_FAILED; 2395 ret = QLA_FUNCTION_FAILED;
2376 break; 2396 break;
2377 } 2397 }
@@ -2387,8 +2407,8 @@ qla2x00_get_flash_version(scsi_qla_host_t *ha, void *mbuf)
2387 qla2x00_read_flash_byte(ha, pcids + 0x2) != 'I' || 2407 qla2x00_read_flash_byte(ha, pcids + 0x2) != 'I' ||
2388 qla2x00_read_flash_byte(ha, pcids + 0x3) != 'R') { 2408 qla2x00_read_flash_byte(ha, pcids + 0x3) != 'R') {
2389 /* Incorrect header. */ 2409 /* Incorrect header. */
2390 DEBUG2(printk("%s(): PCI data struct not found " 2410 DEBUG2(qla_printk(KERN_INFO, ha, "PCI data struct not "
2391 "pcir_adr=%x.\n", __func__, pcids)); 2411 "found pcir_adr=%x.\n", pcids));
2392 ret = QLA_FUNCTION_FAILED; 2412 ret = QLA_FUNCTION_FAILED;
2393 break; 2413 break;
2394 } 2414 }
@@ -2402,7 +2422,7 @@ qla2x00_get_flash_version(scsi_qla_host_t *ha, void *mbuf)
2402 qla2x00_read_flash_byte(ha, pcids + 0x12); 2422 qla2x00_read_flash_byte(ha, pcids + 0x12);
2403 ha->bios_revision[1] = 2423 ha->bios_revision[1] =
2404 qla2x00_read_flash_byte(ha, pcids + 0x13); 2424 qla2x00_read_flash_byte(ha, pcids + 0x13);
2405 DEBUG3(printk("%s(): read BIOS %d.%d.\n", __func__, 2425 DEBUG3(qla_printk(KERN_DEBUG, ha, "read BIOS %d.%d.\n",
2406 ha->bios_revision[1], ha->bios_revision[0])); 2426 ha->bios_revision[1], ha->bios_revision[0]));
2407 break; 2427 break;
2408 case ROM_CODE_TYPE_FCODE: 2428 case ROM_CODE_TYPE_FCODE:
@@ -2416,12 +2436,12 @@ qla2x00_get_flash_version(scsi_qla_host_t *ha, void *mbuf)
2416 qla2x00_read_flash_byte(ha, pcids + 0x12); 2436 qla2x00_read_flash_byte(ha, pcids + 0x12);
2417 ha->efi_revision[1] = 2437 ha->efi_revision[1] =
2418 qla2x00_read_flash_byte(ha, pcids + 0x13); 2438 qla2x00_read_flash_byte(ha, pcids + 0x13);
2419 DEBUG3(printk("%s(): read EFI %d.%d.\n", __func__, 2439 DEBUG3(qla_printk(KERN_DEBUG, ha, "read EFI %d.%d.\n",
2420 ha->efi_revision[1], ha->efi_revision[0])); 2440 ha->efi_revision[1], ha->efi_revision[0]));
2421 break; 2441 break;
2422 default: 2442 default:
2423 DEBUG2(printk("%s(): Unrecognized code type %x at " 2443 DEBUG2(qla_printk(KERN_INFO, ha, "Unrecognized code "
2424 "pcids %x.\n", __func__, code_type, pcids)); 2444 "type %x at pcids %x.\n", code_type, pcids));
2425 break; 2445 break;
2426 } 2446 }
2427 2447
@@ -2441,16 +2461,16 @@ qla2x00_get_flash_version(scsi_qla_host_t *ha, void *mbuf)
2441 2461
2442 qla2x00_read_flash_data(ha, dbyte, ha->flt_region_fw * 4 + 10, 2462 qla2x00_read_flash_data(ha, dbyte, ha->flt_region_fw * 4 + 10,
2443 8); 2463 8);
2444 DEBUG3(printk("%s(%ld): dumping fw ver from flash:\n", 2464 DEBUG3(qla_printk(KERN_DEBUG, ha, "dumping fw ver from "
2445 __func__, ha->host_no)); 2465 "flash:\n"));
2446 DEBUG3(qla2x00_dump_buffer((uint8_t *)dbyte, 8)); 2466 DEBUG3(qla2x00_dump_buffer((uint8_t *)dbyte, 8));
2447 2467
2448 if ((dcode[0] == 0xffff && dcode[1] == 0xffff && 2468 if ((dcode[0] == 0xffff && dcode[1] == 0xffff &&
2449 dcode[2] == 0xffff && dcode[3] == 0xffff) || 2469 dcode[2] == 0xffff && dcode[3] == 0xffff) ||
2450 (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 && 2470 (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 &&
2451 dcode[3] == 0)) { 2471 dcode[3] == 0)) {
2452 DEBUG2(printk("%s(): Unrecognized fw revision at " 2472 DEBUG2(qla_printk(KERN_INFO, ha, "Unrecognized fw "
2453 "%x.\n", __func__, ha->flt_region_fw * 4)); 2473 "revision at %x.\n", ha->flt_region_fw * 4));
2454 } else { 2474 } else {
2455 /* values are in big endian */ 2475 /* values are in big endian */
2456 ha->fw_revision[0] = dbyte[0] << 16 | dbyte[1]; 2476 ha->fw_revision[0] = dbyte[0] << 16 | dbyte[1];
@@ -2465,7 +2485,7 @@ qla2x00_get_flash_version(scsi_qla_host_t *ha, void *mbuf)
2465} 2485}
2466 2486
2467int 2487int
2468qla24xx_get_flash_version(scsi_qla_host_t *ha, void *mbuf) 2488qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
2469{ 2489{
2470 int ret = QLA_SUCCESS; 2490 int ret = QLA_SUCCESS;
2471 uint32_t pcihdr, pcids; 2491 uint32_t pcihdr, pcids;
@@ -2473,6 +2493,7 @@ qla24xx_get_flash_version(scsi_qla_host_t *ha, void *mbuf)
2473 uint8_t *bcode; 2493 uint8_t *bcode;
2474 uint8_t code_type, last_image; 2494 uint8_t code_type, last_image;
2475 int i; 2495 int i;
2496 struct qla_hw_data *ha = vha->hw;
2476 2497
2477 if (!mbuf) 2498 if (!mbuf)
2478 return QLA_FUNCTION_FAILED; 2499 return QLA_FUNCTION_FAILED;
@@ -2489,12 +2510,12 @@ qla24xx_get_flash_version(scsi_qla_host_t *ha, void *mbuf)
2489 last_image = 1; 2510 last_image = 1;
2490 do { 2511 do {
2491 /* Verify PCI expansion ROM header. */ 2512 /* Verify PCI expansion ROM header. */
2492 qla24xx_read_flash_data(ha, dcode, pcihdr >> 2, 0x20); 2513 qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, 0x20);
2493 bcode = mbuf + (pcihdr % 4); 2514 bcode = mbuf + (pcihdr % 4);
2494 if (bcode[0x0] != 0x55 || bcode[0x1] != 0xaa) { 2515 if (bcode[0x0] != 0x55 || bcode[0x1] != 0xaa) {
2495 /* No signature */ 2516 /* No signature */
2496 DEBUG2(printk("scsi(%ld): No matching ROM " 2517 DEBUG2(qla_printk(KERN_DEBUG, ha, "No matching ROM "
2497 "signature.\n", ha->host_no)); 2518 "signature.\n"));
2498 ret = QLA_FUNCTION_FAILED; 2519 ret = QLA_FUNCTION_FAILED;
2499 break; 2520 break;
2500 } 2521 }
@@ -2502,15 +2523,15 @@ qla24xx_get_flash_version(scsi_qla_host_t *ha, void *mbuf)
2502 /* Locate PCI data structure. */ 2523 /* Locate PCI data structure. */
2503 pcids = pcihdr + ((bcode[0x19] << 8) | bcode[0x18]); 2524 pcids = pcihdr + ((bcode[0x19] << 8) | bcode[0x18]);
2504 2525
2505 qla24xx_read_flash_data(ha, dcode, pcids >> 2, 0x20); 2526 qla24xx_read_flash_data(vha, dcode, pcids >> 2, 0x20);
2506 bcode = mbuf + (pcihdr % 4); 2527 bcode = mbuf + (pcihdr % 4);
2507 2528
2508 /* Validate signature of PCI data structure. */ 2529 /* Validate signature of PCI data structure. */
2509 if (bcode[0x0] != 'P' || bcode[0x1] != 'C' || 2530 if (bcode[0x0] != 'P' || bcode[0x1] != 'C' ||
2510 bcode[0x2] != 'I' || bcode[0x3] != 'R') { 2531 bcode[0x2] != 'I' || bcode[0x3] != 'R') {
2511 /* Incorrect header. */ 2532 /* Incorrect header. */
2512 DEBUG2(printk("%s(): PCI data struct not found " 2533 DEBUG2(qla_printk(KERN_INFO, ha, "PCI data struct not "
2513 "pcir_adr=%x.\n", __func__, pcids)); 2534 "found pcir_adr=%x.\n", pcids));
2514 ret = QLA_FUNCTION_FAILED; 2535 ret = QLA_FUNCTION_FAILED;
2515 break; 2536 break;
2516 } 2537 }
@@ -2522,26 +2543,26 @@ qla24xx_get_flash_version(scsi_qla_host_t *ha, void *mbuf)
2522 /* Intel x86, PC-AT compatible. */ 2543 /* Intel x86, PC-AT compatible. */
2523 ha->bios_revision[0] = bcode[0x12]; 2544 ha->bios_revision[0] = bcode[0x12];
2524 ha->bios_revision[1] = bcode[0x13]; 2545 ha->bios_revision[1] = bcode[0x13];
2525 DEBUG3(printk("%s(): read BIOS %d.%d.\n", __func__, 2546 DEBUG3(qla_printk(KERN_DEBUG, ha, "read BIOS %d.%d.\n",
2526 ha->bios_revision[1], ha->bios_revision[0])); 2547 ha->bios_revision[1], ha->bios_revision[0]));
2527 break; 2548 break;
2528 case ROM_CODE_TYPE_FCODE: 2549 case ROM_CODE_TYPE_FCODE:
2529 /* Open Firmware standard for PCI (FCode). */ 2550 /* Open Firmware standard for PCI (FCode). */
2530 ha->fcode_revision[0] = bcode[0x12]; 2551 ha->fcode_revision[0] = bcode[0x12];
2531 ha->fcode_revision[1] = bcode[0x13]; 2552 ha->fcode_revision[1] = bcode[0x13];
2532 DEBUG3(printk("%s(): read FCODE %d.%d.\n", __func__, 2553 DEBUG3(qla_printk(KERN_DEBUG, ha, "read FCODE %d.%d.\n",
2533 ha->fcode_revision[1], ha->fcode_revision[0])); 2554 ha->fcode_revision[1], ha->fcode_revision[0]));
2534 break; 2555 break;
2535 case ROM_CODE_TYPE_EFI: 2556 case ROM_CODE_TYPE_EFI:
2536 /* Extensible Firmware Interface (EFI). */ 2557 /* Extensible Firmware Interface (EFI). */
2537 ha->efi_revision[0] = bcode[0x12]; 2558 ha->efi_revision[0] = bcode[0x12];
2538 ha->efi_revision[1] = bcode[0x13]; 2559 ha->efi_revision[1] = bcode[0x13];
2539 DEBUG3(printk("%s(): read EFI %d.%d.\n", __func__, 2560 DEBUG3(qla_printk(KERN_DEBUG, ha, "read EFI %d.%d.\n",
2540 ha->efi_revision[1], ha->efi_revision[0])); 2561 ha->efi_revision[1], ha->efi_revision[0]));
2541 break; 2562 break;
2542 default: 2563 default:
2543 DEBUG2(printk("%s(): Unrecognized code type %x at " 2564 DEBUG2(qla_printk(KERN_INFO, ha, "Unrecognized code "
2544 "pcids %x.\n", __func__, code_type, pcids)); 2565 "type %x at pcids %x.\n", code_type, pcids));
2545 break; 2566 break;
2546 } 2567 }
2547 2568
@@ -2555,7 +2576,7 @@ qla24xx_get_flash_version(scsi_qla_host_t *ha, void *mbuf)
2555 memset(ha->fw_revision, 0, sizeof(ha->fw_revision)); 2576 memset(ha->fw_revision, 0, sizeof(ha->fw_revision));
2556 dcode = mbuf; 2577 dcode = mbuf;
2557 2578
2558 qla24xx_read_flash_data(ha, dcode, ha->flt_region_fw + 4, 4); 2579 qla24xx_read_flash_data(vha, dcode, ha->flt_region_fw + 4, 4);
2559 for (i = 0; i < 4; i++) 2580 for (i = 0; i < 4; i++)
2560 dcode[i] = be32_to_cpu(dcode[i]); 2581 dcode[i] = be32_to_cpu(dcode[i]);
2561 2582
@@ -2563,8 +2584,8 @@ qla24xx_get_flash_version(scsi_qla_host_t *ha, void *mbuf)
2563 dcode[2] == 0xffffffff && dcode[3] == 0xffffffff) || 2584 dcode[2] == 0xffffffff && dcode[3] == 0xffffffff) ||
2564 (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 && 2585 (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 &&
2565 dcode[3] == 0)) { 2586 dcode[3] == 0)) {
2566 DEBUG2(printk("%s(): Unrecognized fw version at %x.\n", 2587 DEBUG2(qla_printk(KERN_INFO, ha, "Unrecognized fw "
2567 __func__, ha->flt_region_fw)); 2588 "revision at %x.\n", ha->flt_region_fw * 4));
2568 } else { 2589 } else {
2569 ha->fw_revision[0] = dcode[0]; 2590 ha->fw_revision[0] = dcode[0];
2570 ha->fw_revision[1] = dcode[1]; 2591 ha->fw_revision[1] = dcode[1];
@@ -2593,8 +2614,9 @@ qla2xxx_is_vpd_valid(uint8_t *pos, uint8_t *end)
2593} 2614}
2594 2615
2595int 2616int
2596qla2xxx_get_vpd_field(scsi_qla_host_t *ha, char *key, char *str, size_t size) 2617qla2xxx_get_vpd_field(scsi_qla_host_t *vha, char *key, char *str, size_t size)
2597{ 2618{
2619 struct qla_hw_data *ha = vha->hw;
2598 uint8_t *pos = ha->vpd; 2620 uint8_t *pos = ha->vpd;
2599 uint8_t *end = pos + ha->vpd_size; 2621 uint8_t *end = pos + ha->vpd_size;
2600 int len = 0; 2622 int len = 0;
@@ -2621,9 +2643,10 @@ qla2xxx_get_vpd_field(scsi_qla_host_t *ha, char *key, char *str, size_t size)
2621} 2643}
2622 2644
2623static int 2645static int
2624qla2xxx_hw_event_store(scsi_qla_host_t *ha, uint32_t *fdata) 2646qla2xxx_hw_event_store(scsi_qla_host_t *vha, uint32_t *fdata)
2625{ 2647{
2626 uint32_t d[2], faddr; 2648 uint32_t d[2], faddr;
2649 struct qla_hw_data *ha = vha->hw;
2627 2650
2628 /* Locate first empty entry. */ 2651 /* Locate first empty entry. */
2629 for (;;) { 2652 for (;;) {
@@ -2634,7 +2657,7 @@ qla2xxx_hw_event_store(scsi_qla_host_t *ha, uint32_t *fdata)
2634 return QLA_MEMORY_ALLOC_FAILED; 2657 return QLA_MEMORY_ALLOC_FAILED;
2635 } 2658 }
2636 2659
2637 qla24xx_read_flash_data(ha, d, ha->hw_event_ptr, 2); 2660 qla24xx_read_flash_data(vha, d, ha->hw_event_ptr, 2);
2638 faddr = flash_data_to_access_addr(ha->hw_event_ptr); 2661 faddr = flash_data_to_access_addr(ha->hw_event_ptr);
2639 ha->hw_event_ptr += FA_HW_EVENT_ENTRY_SIZE; 2662 ha->hw_event_ptr += FA_HW_EVENT_ENTRY_SIZE;
2640 if (d[0] == __constant_cpu_to_le32(0xffffffff) && 2663 if (d[0] == __constant_cpu_to_le32(0xffffffff) &&
@@ -2655,12 +2678,12 @@ qla2xxx_hw_event_store(scsi_qla_host_t *ha, uint32_t *fdata)
2655} 2678}
2656 2679
2657int 2680int
2658qla2xxx_hw_event_log(scsi_qla_host_t *ha, uint16_t code, uint16_t d1, 2681qla2xxx_hw_event_log(scsi_qla_host_t *vha, uint16_t code, uint16_t d1,
2659 uint16_t d2, uint16_t d3) 2682 uint16_t d2, uint16_t d3)
2660{ 2683{
2661#define QMARK(a, b, c, d) \ 2684#define QMARK(a, b, c, d) \
2662 cpu_to_le32(LSB(a) << 24 | LSB(b) << 16 | LSB(c) << 8 | LSB(d)) 2685 cpu_to_le32(LSB(a) << 24 | LSB(b) << 16 | LSB(c) << 8 | LSB(d))
2663 2686 struct qla_hw_data *ha = vha->hw;
2664 int rval; 2687 int rval;
2665 uint32_t marker[2], fdata[4]; 2688 uint32_t marker[2], fdata[4];
2666 2689
@@ -2681,7 +2704,7 @@ qla2xxx_hw_event_log(scsi_qla_host_t *ha, uint16_t code, uint16_t d1,
2681 /* Locate marker. */ 2704 /* Locate marker. */
2682 ha->hw_event_ptr = ha->flt_region_hw_event; 2705 ha->hw_event_ptr = ha->flt_region_hw_event;
2683 for (;;) { 2706 for (;;) {
2684 qla24xx_read_flash_data(ha, fdata, ha->hw_event_ptr, 2707 qla24xx_read_flash_data(vha, fdata, ha->hw_event_ptr,
2685 4); 2708 4);
2686 if (fdata[0] == __constant_cpu_to_le32(0xffffffff) && 2709 if (fdata[0] == __constant_cpu_to_le32(0xffffffff) &&
2687 fdata[1] == __constant_cpu_to_le32(0xffffffff)) 2710 fdata[1] == __constant_cpu_to_le32(0xffffffff))
@@ -2700,7 +2723,7 @@ qla2xxx_hw_event_log(scsi_qla_host_t *ha, uint16_t code, uint16_t d1,
2700 } 2723 }
2701 /* No marker, write it. */ 2724 /* No marker, write it. */
2702 if (!ha->flags.hw_event_marker_found) { 2725 if (!ha->flags.hw_event_marker_found) {
2703 rval = qla2xxx_hw_event_store(ha, marker); 2726 rval = qla2xxx_hw_event_store(vha, marker);
2704 if (rval != QLA_SUCCESS) { 2727 if (rval != QLA_SUCCESS) {
2705 DEBUG2(qla_printk(KERN_WARNING, ha, 2728 DEBUG2(qla_printk(KERN_WARNING, ha,
2706 "HW event -- Failed marker write=%x.!\n", 2729 "HW event -- Failed marker write=%x.!\n",
@@ -2714,7 +2737,7 @@ qla2xxx_hw_event_log(scsi_qla_host_t *ha, uint16_t code, uint16_t d1,
2714 /* Store error. */ 2737 /* Store error. */
2715 fdata[0] = cpu_to_le32(code << 16 | d1); 2738 fdata[0] = cpu_to_le32(code << 16 | d1);
2716 fdata[1] = cpu_to_le32(d2 << 16 | d3); 2739 fdata[1] = cpu_to_le32(d2 << 16 | d3);
2717 rval = qla2xxx_hw_event_store(ha, fdata); 2740 rval = qla2xxx_hw_event_store(vha, fdata);
2718 if (rval != QLA_SUCCESS) { 2741 if (rval != QLA_SUCCESS) {
2719 DEBUG2(qla_printk(KERN_WARNING, ha, 2742 DEBUG2(qla_printk(KERN_WARNING, ha,
2720 "HW event -- Failed error write=%x.!\n", 2743 "HW event -- Failed error write=%x.!\n",