aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-03-28 16:30:43 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-03-28 16:30:43 -0400
commitd54b3538b0bfb31351d02d1669d4a978d2abfc5f (patch)
tree5ce539ecba525b30bbfb1c46c55487099264947e /drivers/s390
parent5d80f8e5a9dc9c9a94d4aeaa567e219a808b8a4a (diff)
parentaf50bb993dfa673cf21ab812efe620d7e0c36319 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (119 commits) [SCSI] scsi_dh_rdac: Retry for NOT_READY check condition [SCSI] mpt2sas: make global symbols unique [SCSI] sd: Make revalidate less chatty [SCSI] sd: Try READ CAPACITY 16 first for SBC-2 devices [SCSI] sd: Refactor sd_read_capacity() [SCSI] mpt2sas v00.100.11.15 [SCSI] mpt2sas: add MPT2SAS_MINOR(221) to miscdevice.h [SCSI] ch: Add scsi type modalias [SCSI] 3w-9xxx: add power management support [SCSI] bsg: add linux/types.h include to bsg.h [SCSI] cxgb3i: fix function descriptions [SCSI] libiscsi: fix possbile null ptr session command cleanup [SCSI] iscsi class: remove host no argument from session creation callout [SCSI] libiscsi: pass session failure a session struct [SCSI] iscsi lib: remove qdepth param from iscsi host allocation [SCSI] iscsi lib: have lib create work queue for transmitting IO [SCSI] iscsi class: fix lock dep warning on logout [SCSI] libiscsi: don't cap queue depth in iscsi modules [SCSI] iscsi_tcp: replace scsi_debug/tcp_debug logging with iscsi conn logging [SCSI] libiscsi_tcp: replace tcp_debug/scsi_debug logging with session/conn logging ...
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/scsi/zfcp_aux.c24
-rw-r--r--drivers/s390/scsi/zfcp_ccw.c24
-rw-r--r--drivers/s390/scsi/zfcp_dbf.c188
-rw-r--r--drivers/s390/scsi/zfcp_dbf.h3
-rw-r--r--drivers/s390/scsi/zfcp_def.h17
-rw-r--r--drivers/s390/scsi/zfcp_erp.c290
-rw-r--r--drivers/s390/scsi/zfcp_ext.h73
-rw-r--r--drivers/s390/scsi/zfcp_fc.c82
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c240
-rw-r--r--drivers/s390/scsi/zfcp_fsf.h4
-rw-r--r--drivers/s390/scsi/zfcp_qdio.c47
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c250
-rw-r--r--drivers/s390/scsi/zfcp_sysfs.c20
13 files changed, 586 insertions, 676 deletions
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 8af7dfbe022c..616c60ffcf2c 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Module interface and handling of zfcp data structures. 4 * Module interface and handling of zfcp data structures.
5 * 5 *
6 * Copyright IBM Corporation 2002, 2008 6 * Copyright IBM Corporation 2002, 2009
7 */ 7 */
8 8
9/* 9/*
@@ -249,8 +249,8 @@ struct zfcp_port *zfcp_get_port_by_wwpn(struct zfcp_adapter *adapter,
249 struct zfcp_port *port; 249 struct zfcp_port *port;
250 250
251 list_for_each_entry(port, &adapter->port_list_head, list) 251 list_for_each_entry(port, &adapter->port_list_head, list)
252 if ((port->wwpn == wwpn) && !(atomic_read(&port->status) & 252 if ((port->wwpn == wwpn) &&
253 (ZFCP_STATUS_PORT_NO_WWPN | ZFCP_STATUS_COMMON_REMOVE))) 253 !(atomic_read(&port->status) & ZFCP_STATUS_COMMON_REMOVE))
254 return port; 254 return port;
255 return NULL; 255 return NULL;
256} 256}
@@ -421,7 +421,8 @@ int zfcp_status_read_refill(struct zfcp_adapter *adapter)
421 while (atomic_read(&adapter->stat_miss) > 0) 421 while (atomic_read(&adapter->stat_miss) > 0)
422 if (zfcp_fsf_status_read(adapter)) { 422 if (zfcp_fsf_status_read(adapter)) {
423 if (atomic_read(&adapter->stat_miss) >= 16) { 423 if (atomic_read(&adapter->stat_miss) >= 16) {
424 zfcp_erp_adapter_reopen(adapter, 0, 103, NULL); 424 zfcp_erp_adapter_reopen(adapter, 0, "axsref1",
425 NULL);
425 return 1; 426 return 1;
426 } 427 }
427 break; 428 break;
@@ -501,6 +502,7 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device)
501 spin_lock_init(&adapter->scsi_dbf_lock); 502 spin_lock_init(&adapter->scsi_dbf_lock);
502 spin_lock_init(&adapter->rec_dbf_lock); 503 spin_lock_init(&adapter->rec_dbf_lock);
503 spin_lock_init(&adapter->req_q_lock); 504 spin_lock_init(&adapter->req_q_lock);
505 spin_lock_init(&adapter->qdio_stat_lock);
504 506
505 rwlock_init(&adapter->erp_lock); 507 rwlock_init(&adapter->erp_lock);
506 rwlock_init(&adapter->abort_lock); 508 rwlock_init(&adapter->abort_lock);
@@ -522,7 +524,6 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device)
522 goto sysfs_failed; 524 goto sysfs_failed;
523 525
524 atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status); 526 atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status);
525 zfcp_fc_nameserver_init(adapter);
526 527
527 if (!zfcp_adapter_scsi_register(adapter)) 528 if (!zfcp_adapter_scsi_register(adapter))
528 return 0; 529 return 0;
@@ -552,6 +553,7 @@ void zfcp_adapter_dequeue(struct zfcp_adapter *adapter)
552 553
553 cancel_work_sync(&adapter->scan_work); 554 cancel_work_sync(&adapter->scan_work);
554 cancel_work_sync(&adapter->stat_work); 555 cancel_work_sync(&adapter->stat_work);
556 cancel_delayed_work_sync(&adapter->nsp.work);
555 zfcp_adapter_scsi_unregister(adapter); 557 zfcp_adapter_scsi_unregister(adapter);
556 sysfs_remove_group(&adapter->ccw_device->dev.kobj, 558 sysfs_remove_group(&adapter->ccw_device->dev.kobj,
557 &zfcp_sysfs_adapter_attrs); 559 &zfcp_sysfs_adapter_attrs);
@@ -603,10 +605,13 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
603 init_waitqueue_head(&port->remove_wq); 605 init_waitqueue_head(&port->remove_wq);
604 INIT_LIST_HEAD(&port->unit_list_head); 606 INIT_LIST_HEAD(&port->unit_list_head);
605 INIT_WORK(&port->gid_pn_work, zfcp_erp_port_strategy_open_lookup); 607 INIT_WORK(&port->gid_pn_work, zfcp_erp_port_strategy_open_lookup);
608 INIT_WORK(&port->test_link_work, zfcp_fc_link_test_work);
609 INIT_WORK(&port->rport_work, zfcp_scsi_rport_work);
606 610
607 port->adapter = adapter; 611 port->adapter = adapter;
608 port->d_id = d_id; 612 port->d_id = d_id;
609 port->wwpn = wwpn; 613 port->wwpn = wwpn;
614 port->rport_task = RPORT_NONE;
610 615
611 /* mark port unusable as long as sysfs registration is not complete */ 616 /* mark port unusable as long as sysfs registration is not complete */
612 atomic_set_mask(status | ZFCP_STATUS_COMMON_REMOVE, &port->status); 617 atomic_set_mask(status | ZFCP_STATUS_COMMON_REMOVE, &port->status);
@@ -620,11 +625,10 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
620 dev_set_drvdata(&port->sysfs_device, port); 625 dev_set_drvdata(&port->sysfs_device, port);
621 626
622 read_lock_irq(&zfcp_data.config_lock); 627 read_lock_irq(&zfcp_data.config_lock);
623 if (!(status & ZFCP_STATUS_PORT_NO_WWPN)) 628 if (zfcp_get_port_by_wwpn(adapter, wwpn)) {
624 if (zfcp_get_port_by_wwpn(adapter, wwpn)) { 629 read_unlock_irq(&zfcp_data.config_lock);
625 read_unlock_irq(&zfcp_data.config_lock); 630 goto err_out_free;
626 goto err_out_free; 631 }
627 }
628 read_unlock_irq(&zfcp_data.config_lock); 632 read_unlock_irq(&zfcp_data.config_lock);
629 633
630 if (device_register(&port->sysfs_device)) 634 if (device_register(&port->sysfs_device))
diff --git a/drivers/s390/scsi/zfcp_ccw.c b/drivers/s390/scsi/zfcp_ccw.c
index 285881f07648..1fe1e2eda512 100644
--- a/drivers/s390/scsi/zfcp_ccw.c
+++ b/drivers/s390/scsi/zfcp_ccw.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Registration and callback for the s390 common I/O layer. 4 * Registration and callback for the s390 common I/O layer.
5 * 5 *
6 * Copyright IBM Corporation 2002, 2008 6 * Copyright IBM Corporation 2002, 2009
7 */ 7 */
8 8
9#define KMSG_COMPONENT "zfcp" 9#define KMSG_COMPONENT "zfcp"
@@ -72,8 +72,7 @@ static void zfcp_ccw_remove(struct ccw_device *ccw_device)
72 72
73 list_for_each_entry_safe(port, p, &port_remove_lh, list) { 73 list_for_each_entry_safe(port, p, &port_remove_lh, list) {
74 list_for_each_entry_safe(unit, u, &unit_remove_lh, list) { 74 list_for_each_entry_safe(unit, u, &unit_remove_lh, list) {
75 if (atomic_read(&unit->status) & 75 if (unit->device)
76 ZFCP_STATUS_UNIT_REGISTERED)
77 scsi_remove_device(unit->device); 76 scsi_remove_device(unit->device);
78 zfcp_unit_dequeue(unit); 77 zfcp_unit_dequeue(unit);
79 } 78 }
@@ -109,11 +108,12 @@ static int zfcp_ccw_set_online(struct ccw_device *ccw_device)
109 /* initialize request counter */ 108 /* initialize request counter */
110 BUG_ON(!zfcp_reqlist_isempty(adapter)); 109 BUG_ON(!zfcp_reqlist_isempty(adapter));
111 adapter->req_no = 0; 110 adapter->req_no = 0;
111 zfcp_fc_nameserver_init(adapter);
112 112
113 zfcp_erp_modify_adapter_status(adapter, 10, NULL, 113 zfcp_erp_modify_adapter_status(adapter, "ccsonl1", NULL,
114 ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET); 114 ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET);
115 zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, 85, 115 zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED,
116 NULL); 116 "ccsonl2", NULL);
117 zfcp_erp_wait(adapter); 117 zfcp_erp_wait(adapter);
118 up(&zfcp_data.config_sema); 118 up(&zfcp_data.config_sema);
119 flush_work(&adapter->scan_work); 119 flush_work(&adapter->scan_work);
@@ -137,7 +137,7 @@ static int zfcp_ccw_set_offline(struct ccw_device *ccw_device)
137 137
138 down(&zfcp_data.config_sema); 138 down(&zfcp_data.config_sema);
139 adapter = dev_get_drvdata(&ccw_device->dev); 139 adapter = dev_get_drvdata(&ccw_device->dev);
140 zfcp_erp_adapter_shutdown(adapter, 0, 86, NULL); 140 zfcp_erp_adapter_shutdown(adapter, 0, "ccsoff1", NULL);
141 zfcp_erp_wait(adapter); 141 zfcp_erp_wait(adapter);
142 zfcp_erp_thread_kill(adapter); 142 zfcp_erp_thread_kill(adapter);
143 up(&zfcp_data.config_sema); 143 up(&zfcp_data.config_sema);
@@ -160,21 +160,21 @@ static int zfcp_ccw_notify(struct ccw_device *ccw_device, int event)
160 case CIO_GONE: 160 case CIO_GONE:
161 dev_warn(&adapter->ccw_device->dev, 161 dev_warn(&adapter->ccw_device->dev,
162 "The FCP device has been detached\n"); 162 "The FCP device has been detached\n");
163 zfcp_erp_adapter_shutdown(adapter, 0, 87, NULL); 163 zfcp_erp_adapter_shutdown(adapter, 0, "ccnoti1", NULL);
164 break; 164 break;
165 case CIO_NO_PATH: 165 case CIO_NO_PATH:
166 dev_warn(&adapter->ccw_device->dev, 166 dev_warn(&adapter->ccw_device->dev,
167 "The CHPID for the FCP device is offline\n"); 167 "The CHPID for the FCP device is offline\n");
168 zfcp_erp_adapter_shutdown(adapter, 0, 88, NULL); 168 zfcp_erp_adapter_shutdown(adapter, 0, "ccnoti2", NULL);
169 break; 169 break;
170 case CIO_OPER: 170 case CIO_OPER:
171 dev_info(&adapter->ccw_device->dev, 171 dev_info(&adapter->ccw_device->dev,
172 "The FCP device is operational again\n"); 172 "The FCP device is operational again\n");
173 zfcp_erp_modify_adapter_status(adapter, 11, NULL, 173 zfcp_erp_modify_adapter_status(adapter, "ccnoti3", NULL,
174 ZFCP_STATUS_COMMON_RUNNING, 174 ZFCP_STATUS_COMMON_RUNNING,
175 ZFCP_SET); 175 ZFCP_SET);
176 zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, 176 zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED,
177 89, NULL); 177 "ccnoti4", NULL);
178 break; 178 break;
179 } 179 }
180 return 1; 180 return 1;
@@ -190,7 +190,7 @@ static void zfcp_ccw_shutdown(struct ccw_device *cdev)
190 190
191 down(&zfcp_data.config_sema); 191 down(&zfcp_data.config_sema);
192 adapter = dev_get_drvdata(&cdev->dev); 192 adapter = dev_get_drvdata(&cdev->dev);
193 zfcp_erp_adapter_shutdown(adapter, 0, 90, NULL); 193 zfcp_erp_adapter_shutdown(adapter, 0, "ccshut1", NULL);
194 zfcp_erp_wait(adapter); 194 zfcp_erp_wait(adapter);
195 up(&zfcp_data.config_sema); 195 up(&zfcp_data.config_sema);
196} 196}
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index cb6df609953e..0a1a5dd8d018 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -490,172 +490,17 @@ static const char *zfcp_rec_dbf_tags[] = {
490 [ZFCP_REC_DBF_ID_ACTION] = "action", 490 [ZFCP_REC_DBF_ID_ACTION] = "action",
491}; 491};
492 492
493static const char *zfcp_rec_dbf_ids[] = {
494 [1] = "new",
495 [2] = "ready",
496 [3] = "kill",
497 [4] = "down sleep",
498 [5] = "down wakeup",
499 [6] = "down sleep ecd",
500 [7] = "down wakeup ecd",
501 [8] = "down sleep epd",
502 [9] = "down wakeup epd",
503 [10] = "online",
504 [11] = "operational",
505 [12] = "scsi slave destroy",
506 [13] = "propagate failed adapter",
507 [14] = "propagate failed port",
508 [15] = "block adapter",
509 [16] = "unblock adapter",
510 [17] = "block port",
511 [18] = "unblock port",
512 [19] = "block unit",
513 [20] = "unblock unit",
514 [21] = "unit recovery failed",
515 [22] = "port recovery failed",
516 [23] = "adapter recovery failed",
517 [24] = "qdio queues down",
518 [25] = "p2p failed",
519 [26] = "nameserver lookup failed",
520 [27] = "nameserver port failed",
521 [28] = "link up",
522 [29] = "link down",
523 [30] = "link up status read",
524 [31] = "open port failed",
525 [32] = "",
526 [33] = "close port",
527 [34] = "open unit failed",
528 [35] = "exclusive open unit failed",
529 [36] = "shared open unit failed",
530 [37] = "link down",
531 [38] = "link down status read no link",
532 [39] = "link down status read fdisc login",
533 [40] = "link down status read firmware update",
534 [41] = "link down status read unknown reason",
535 [42] = "link down ecd incomplete",
536 [43] = "link down epd incomplete",
537 [44] = "sysfs adapter recovery",
538 [45] = "sysfs port recovery",
539 [46] = "sysfs unit recovery",
540 [47] = "port boxed abort",
541 [48] = "unit boxed abort",
542 [49] = "port boxed ct",
543 [50] = "port boxed close physical",
544 [51] = "port boxed open unit",
545 [52] = "port boxed close unit",
546 [53] = "port boxed fcp",
547 [54] = "unit boxed fcp",
548 [55] = "port access denied",
549 [56] = "",
550 [57] = "",
551 [58] = "",
552 [59] = "unit access denied",
553 [60] = "shared unit access denied open unit",
554 [61] = "",
555 [62] = "request timeout",
556 [63] = "adisc link test reject or timeout",
557 [64] = "adisc link test d_id changed",
558 [65] = "adisc link test failed",
559 [66] = "recovery out of memory",
560 [67] = "adapter recovery repeated after state change",
561 [68] = "port recovery repeated after state change",
562 [69] = "unit recovery repeated after state change",
563 [70] = "port recovery follow-up after successful adapter recovery",
564 [71] = "adapter recovery escalation after failed adapter recovery",
565 [72] = "port recovery follow-up after successful physical port "
566 "recovery",
567 [73] = "adapter recovery escalation after failed physical port "
568 "recovery",
569 [74] = "unit recovery follow-up after successful port recovery",
570 [75] = "physical port recovery escalation after failed port "
571 "recovery",
572 [76] = "port recovery escalation after failed unit recovery",
573 [77] = "",
574 [78] = "duplicate request id",
575 [79] = "link down",
576 [80] = "exclusive read-only unit access unsupported",
577 [81] = "shared read-write unit access unsupported",
578 [82] = "incoming rscn",
579 [83] = "incoming wwpn",
580 [84] = "wka port handle not valid close port",
581 [85] = "online",
582 [86] = "offline",
583 [87] = "ccw device gone",
584 [88] = "ccw device no path",
585 [89] = "ccw device operational",
586 [90] = "ccw device shutdown",
587 [91] = "sysfs port addition",
588 [92] = "sysfs port removal",
589 [93] = "sysfs adapter recovery",
590 [94] = "sysfs unit addition",
591 [95] = "sysfs unit removal",
592 [96] = "sysfs port recovery",
593 [97] = "sysfs unit recovery",
594 [98] = "sequence number mismatch",
595 [99] = "link up",
596 [100] = "error state",
597 [101] = "status read physical port closed",
598 [102] = "link up status read",
599 [103] = "too many failed status read buffers",
600 [104] = "port handle not valid abort",
601 [105] = "lun handle not valid abort",
602 [106] = "port handle not valid ct",
603 [107] = "port handle not valid close port",
604 [108] = "port handle not valid close physical port",
605 [109] = "port handle not valid open unit",
606 [110] = "port handle not valid close unit",
607 [111] = "lun handle not valid close unit",
608 [112] = "port handle not valid fcp",
609 [113] = "lun handle not valid fcp",
610 [114] = "handle mismatch fcp",
611 [115] = "lun not valid fcp",
612 [116] = "qdio send failed",
613 [117] = "version mismatch",
614 [118] = "incompatible qtcb type",
615 [119] = "unknown protocol status",
616 [120] = "unknown fsf command",
617 [121] = "no recommendation for status qualifier",
618 [122] = "status read physical port closed in error",
619 [123] = "fc service class not supported",
620 [124] = "",
621 [125] = "need newer zfcp",
622 [126] = "need newer microcode",
623 [127] = "arbitrated loop not supported",
624 [128] = "",
625 [129] = "qtcb size mismatch",
626 [130] = "unknown fsf status ecd",
627 [131] = "fcp request too big",
628 [132] = "",
629 [133] = "data direction not valid fcp",
630 [134] = "command length not valid fcp",
631 [135] = "status read act update",
632 [136] = "status read cfdc update",
633 [137] = "hbaapi port open",
634 [138] = "hbaapi unit open",
635 [139] = "hbaapi unit shutdown",
636 [140] = "qdio error outbound",
637 [141] = "scsi host reset",
638 [142] = "dismissing fsf request for recovery action",
639 [143] = "recovery action timed out",
640 [144] = "recovery action gone",
641 [145] = "recovery action being processed",
642 [146] = "recovery action ready for next step",
643 [147] = "qdio error inbound",
644 [148] = "nameserver needed for port scan",
645 [149] = "port scan",
646 [150] = "ptp attach",
647 [151] = "port validation failed",
648};
649
650static int zfcp_rec_dbf_view_format(debug_info_t *id, struct debug_view *view, 493static int zfcp_rec_dbf_view_format(debug_info_t *id, struct debug_view *view,
651 char *buf, const char *_rec) 494 char *buf, const char *_rec)
652{ 495{
653 struct zfcp_rec_dbf_record *r = (struct zfcp_rec_dbf_record *)_rec; 496 struct zfcp_rec_dbf_record *r = (struct zfcp_rec_dbf_record *)_rec;
654 char *p = buf; 497 char *p = buf;
498 char hint[ZFCP_DBF_ID_SIZE + 1];
655 499
500 memcpy(hint, r->id2, ZFCP_DBF_ID_SIZE);
501 hint[ZFCP_DBF_ID_SIZE] = 0;
656 zfcp_dbf_outs(&p, "tag", zfcp_rec_dbf_tags[r->id]); 502 zfcp_dbf_outs(&p, "tag", zfcp_rec_dbf_tags[r->id]);
657 zfcp_dbf_outs(&p, "hint", zfcp_rec_dbf_ids[r->id2]); 503 zfcp_dbf_outs(&p, "hint", hint);
658 zfcp_dbf_out(&p, "id", "%d", r->id2);
659 switch (r->id) { 504 switch (r->id) {
660 case ZFCP_REC_DBF_ID_THREAD: 505 case ZFCP_REC_DBF_ID_THREAD:
661 zfcp_dbf_out(&p, "total", "%d", r->u.thread.total); 506 zfcp_dbf_out(&p, "total", "%d", r->u.thread.total);
@@ -707,7 +552,7 @@ static struct debug_view zfcp_rec_dbf_view = {
707 * @adapter: adapter 552 * @adapter: adapter
708 * This function assumes that the caller is holding erp_lock. 553 * This function assumes that the caller is holding erp_lock.
709 */ 554 */
710void zfcp_rec_dbf_event_thread(u8 id2, struct zfcp_adapter *adapter) 555void zfcp_rec_dbf_event_thread(char *id2, struct zfcp_adapter *adapter)
711{ 556{
712 struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf; 557 struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf;
713 unsigned long flags = 0; 558 unsigned long flags = 0;
@@ -723,7 +568,7 @@ void zfcp_rec_dbf_event_thread(u8 id2, struct zfcp_adapter *adapter)
723 spin_lock_irqsave(&adapter->rec_dbf_lock, flags); 568 spin_lock_irqsave(&adapter->rec_dbf_lock, flags);
724 memset(r, 0, sizeof(*r)); 569 memset(r, 0, sizeof(*r));
725 r->id = ZFCP_REC_DBF_ID_THREAD; 570 r->id = ZFCP_REC_DBF_ID_THREAD;
726 r->id2 = id2; 571 memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE);
727 r->u.thread.total = total; 572 r->u.thread.total = total;
728 r->u.thread.ready = ready; 573 r->u.thread.ready = ready;
729 r->u.thread.running = running; 574 r->u.thread.running = running;
@@ -737,7 +582,7 @@ void zfcp_rec_dbf_event_thread(u8 id2, struct zfcp_adapter *adapter)
737 * @adapter: adapter 582 * @adapter: adapter
738 * This function assumes that the caller does not hold erp_lock. 583 * This function assumes that the caller does not hold erp_lock.
739 */ 584 */
740void zfcp_rec_dbf_event_thread_lock(u8 id2, struct zfcp_adapter *adapter) 585void zfcp_rec_dbf_event_thread_lock(char *id2, struct zfcp_adapter *adapter)
741{ 586{
742 unsigned long flags; 587 unsigned long flags;
743 588
@@ -746,7 +591,7 @@ void zfcp_rec_dbf_event_thread_lock(u8 id2, struct zfcp_adapter *adapter)
746 read_unlock_irqrestore(&adapter->erp_lock, flags); 591 read_unlock_irqrestore(&adapter->erp_lock, flags);
747} 592}
748 593
749static void zfcp_rec_dbf_event_target(u8 id2, void *ref, 594static void zfcp_rec_dbf_event_target(char *id2, void *ref,
750 struct zfcp_adapter *adapter, 595 struct zfcp_adapter *adapter,
751 atomic_t *status, atomic_t *erp_count, 596 atomic_t *status, atomic_t *erp_count,
752 u64 wwpn, u32 d_id, u64 fcp_lun) 597 u64 wwpn, u32 d_id, u64 fcp_lun)
@@ -757,7 +602,7 @@ static void zfcp_rec_dbf_event_target(u8 id2, void *ref,
757 spin_lock_irqsave(&adapter->rec_dbf_lock, flags); 602 spin_lock_irqsave(&adapter->rec_dbf_lock, flags);
758 memset(r, 0, sizeof(*r)); 603 memset(r, 0, sizeof(*r));
759 r->id = ZFCP_REC_DBF_ID_TARGET; 604 r->id = ZFCP_REC_DBF_ID_TARGET;
760 r->id2 = id2; 605 memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE);
761 r->u.target.ref = (unsigned long)ref; 606 r->u.target.ref = (unsigned long)ref;
762 r->u.target.status = atomic_read(status); 607 r->u.target.status = atomic_read(status);
763 r->u.target.wwpn = wwpn; 608 r->u.target.wwpn = wwpn;
@@ -774,7 +619,8 @@ static void zfcp_rec_dbf_event_target(u8 id2, void *ref,
774 * @ref: additional reference (e.g. request) 619 * @ref: additional reference (e.g. request)
775 * @adapter: adapter 620 * @adapter: adapter
776 */ 621 */
777void zfcp_rec_dbf_event_adapter(u8 id, void *ref, struct zfcp_adapter *adapter) 622void zfcp_rec_dbf_event_adapter(char *id, void *ref,
623 struct zfcp_adapter *adapter)
778{ 624{
779 zfcp_rec_dbf_event_target(id, ref, adapter, &adapter->status, 625 zfcp_rec_dbf_event_target(id, ref, adapter, &adapter->status,
780 &adapter->erp_counter, 0, 0, 0); 626 &adapter->erp_counter, 0, 0, 0);
@@ -786,7 +632,7 @@ void zfcp_rec_dbf_event_adapter(u8 id, void *ref, struct zfcp_adapter *adapter)
786 * @ref: additional reference (e.g. request) 632 * @ref: additional reference (e.g. request)
787 * @port: port 633 * @port: port
788 */ 634 */
789void zfcp_rec_dbf_event_port(u8 id, void *ref, struct zfcp_port *port) 635void zfcp_rec_dbf_event_port(char *id, void *ref, struct zfcp_port *port)
790{ 636{
791 struct zfcp_adapter *adapter = port->adapter; 637 struct zfcp_adapter *adapter = port->adapter;
792 638
@@ -801,7 +647,7 @@ void zfcp_rec_dbf_event_port(u8 id, void *ref, struct zfcp_port *port)
801 * @ref: additional reference (e.g. request) 647 * @ref: additional reference (e.g. request)
802 * @unit: unit 648 * @unit: unit
803 */ 649 */
804void zfcp_rec_dbf_event_unit(u8 id, void *ref, struct zfcp_unit *unit) 650void zfcp_rec_dbf_event_unit(char *id, void *ref, struct zfcp_unit *unit)
805{ 651{
806 struct zfcp_port *port = unit->port; 652 struct zfcp_port *port = unit->port;
807 struct zfcp_adapter *adapter = port->adapter; 653 struct zfcp_adapter *adapter = port->adapter;
@@ -822,7 +668,7 @@ void zfcp_rec_dbf_event_unit(u8 id, void *ref, struct zfcp_unit *unit)
822 * @port: port 668 * @port: port
823 * @unit: unit 669 * @unit: unit
824 */ 670 */
825void zfcp_rec_dbf_event_trigger(u8 id2, void *ref, u8 want, u8 need, 671void zfcp_rec_dbf_event_trigger(char *id2, void *ref, u8 want, u8 need,
826 void *action, struct zfcp_adapter *adapter, 672 void *action, struct zfcp_adapter *adapter,
827 struct zfcp_port *port, struct zfcp_unit *unit) 673 struct zfcp_port *port, struct zfcp_unit *unit)
828{ 674{
@@ -832,7 +678,7 @@ void zfcp_rec_dbf_event_trigger(u8 id2, void *ref, u8 want, u8 need,
832 spin_lock_irqsave(&adapter->rec_dbf_lock, flags); 678 spin_lock_irqsave(&adapter->rec_dbf_lock, flags);
833 memset(r, 0, sizeof(*r)); 679 memset(r, 0, sizeof(*r));
834 r->id = ZFCP_REC_DBF_ID_TRIGGER; 680 r->id = ZFCP_REC_DBF_ID_TRIGGER;
835 r->id2 = id2; 681 memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE);
836 r->u.trigger.ref = (unsigned long)ref; 682 r->u.trigger.ref = (unsigned long)ref;
837 r->u.trigger.want = want; 683 r->u.trigger.want = want;
838 r->u.trigger.need = need; 684 r->u.trigger.need = need;
@@ -855,7 +701,7 @@ void zfcp_rec_dbf_event_trigger(u8 id2, void *ref, u8 want, u8 need,
855 * @id2: identifier 701 * @id2: identifier
856 * @erp_action: error recovery action struct pointer 702 * @erp_action: error recovery action struct pointer
857 */ 703 */
858void zfcp_rec_dbf_event_action(u8 id2, struct zfcp_erp_action *erp_action) 704void zfcp_rec_dbf_event_action(char *id2, struct zfcp_erp_action *erp_action)
859{ 705{
860 struct zfcp_adapter *adapter = erp_action->adapter; 706 struct zfcp_adapter *adapter = erp_action->adapter;
861 struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf; 707 struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf;
@@ -864,7 +710,7 @@ void zfcp_rec_dbf_event_action(u8 id2, struct zfcp_erp_action *erp_action)
864 spin_lock_irqsave(&adapter->rec_dbf_lock, flags); 710 spin_lock_irqsave(&adapter->rec_dbf_lock, flags);
865 memset(r, 0, sizeof(*r)); 711 memset(r, 0, sizeof(*r));
866 r->id = ZFCP_REC_DBF_ID_ACTION; 712 r->id = ZFCP_REC_DBF_ID_ACTION;
867 r->id2 = id2; 713 memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE);
868 r->u.action.action = (unsigned long)erp_action; 714 r->u.action.action = (unsigned long)erp_action;
869 r->u.action.status = erp_action->status; 715 r->u.action.status = erp_action->status;
870 r->u.action.step = erp_action->step; 716 r->u.action.step = erp_action->step;
diff --git a/drivers/s390/scsi/zfcp_dbf.h b/drivers/s390/scsi/zfcp_dbf.h
index 74998ff88e57..a573f7344dd6 100644
--- a/drivers/s390/scsi/zfcp_dbf.h
+++ b/drivers/s390/scsi/zfcp_dbf.h
@@ -25,6 +25,7 @@
25#include "zfcp_fsf.h" 25#include "zfcp_fsf.h"
26 26
27#define ZFCP_DBF_TAG_SIZE 4 27#define ZFCP_DBF_TAG_SIZE 4
28#define ZFCP_DBF_ID_SIZE 7
28 29
29struct zfcp_dbf_dump { 30struct zfcp_dbf_dump {
30 u8 tag[ZFCP_DBF_TAG_SIZE]; 31 u8 tag[ZFCP_DBF_TAG_SIZE];
@@ -70,7 +71,7 @@ struct zfcp_rec_dbf_record_action {
70 71
71struct zfcp_rec_dbf_record { 72struct zfcp_rec_dbf_record {
72 u8 id; 73 u8 id;
73 u8 id2; 74 char id2[7];
74 union { 75 union {
75 struct zfcp_rec_dbf_record_action action; 76 struct zfcp_rec_dbf_record_action action;
76 struct zfcp_rec_dbf_record_thread thread; 77 struct zfcp_rec_dbf_record_thread thread;
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 510662783a6f..a0318630f047 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Global definitions for the zfcp device driver. 4 * Global definitions for the zfcp device driver.
5 * 5 *
6 * Copyright IBM Corporation 2002, 2008 6 * Copyright IBM Corporation 2002, 2009
7 */ 7 */
8 8
9#ifndef ZFCP_DEF_H 9#ifndef ZFCP_DEF_H
@@ -243,9 +243,6 @@ struct zfcp_ls_adisc {
243 243
244/* remote port status */ 244/* remote port status */
245#define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001 245#define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001
246#define ZFCP_STATUS_PORT_PHYS_CLOSING 0x00000004
247#define ZFCP_STATUS_PORT_NO_WWPN 0x00000008
248#define ZFCP_STATUS_PORT_INVALID_WWPN 0x00000020
249 246
250/* well known address (WKA) port status*/ 247/* well known address (WKA) port status*/
251enum zfcp_wka_status { 248enum zfcp_wka_status {
@@ -258,7 +255,6 @@ enum zfcp_wka_status {
258/* logical unit status */ 255/* logical unit status */
259#define ZFCP_STATUS_UNIT_SHARED 0x00000004 256#define ZFCP_STATUS_UNIT_SHARED 0x00000004
260#define ZFCP_STATUS_UNIT_READONLY 0x00000008 257#define ZFCP_STATUS_UNIT_READONLY 0x00000008
261#define ZFCP_STATUS_UNIT_REGISTERED 0x00000010
262#define ZFCP_STATUS_UNIT_SCSI_WORK_PENDING 0x00000020 258#define ZFCP_STATUS_UNIT_SCSI_WORK_PENDING 0x00000020
263 259
264/* FSF request status (this does not have a common part) */ 260/* FSF request status (this does not have a common part) */
@@ -447,8 +443,9 @@ struct zfcp_adapter {
447 spinlock_t req_list_lock; /* request list lock */ 443 spinlock_t req_list_lock; /* request list lock */
448 struct zfcp_qdio_queue req_q; /* request queue */ 444 struct zfcp_qdio_queue req_q; /* request queue */
449 spinlock_t req_q_lock; /* for operations on queue */ 445 spinlock_t req_q_lock; /* for operations on queue */
450 int req_q_pci_batch; /* SBALs since PCI indication 446 ktime_t req_q_time; /* time of last fill level change */
451 was last set */ 447 u64 req_q_util; /* for accounting */
448 spinlock_t qdio_stat_lock;
452 u32 fsf_req_seq_no; /* FSF cmnd seq number */ 449 u32 fsf_req_seq_no; /* FSF cmnd seq number */
453 wait_queue_head_t request_wq; /* can be used to wait for 450 wait_queue_head_t request_wq; /* can be used to wait for
454 more avaliable SBALs */ 451 more avaliable SBALs */
@@ -514,6 +511,9 @@ struct zfcp_port {
514 u32 maxframe_size; 511 u32 maxframe_size;
515 u32 supported_classes; 512 u32 supported_classes;
516 struct work_struct gid_pn_work; 513 struct work_struct gid_pn_work;
514 struct work_struct test_link_work;
515 struct work_struct rport_work;
516 enum { RPORT_NONE, RPORT_ADD, RPORT_DEL } rport_task;
517}; 517};
518 518
519struct zfcp_unit { 519struct zfcp_unit {
@@ -587,9 +587,6 @@ struct zfcp_fsf_req_qtcb {
587 587
588/********************** ZFCP SPECIFIC DEFINES ********************************/ 588/********************** ZFCP SPECIFIC DEFINES ********************************/
589 589
590#define ZFCP_REQ_AUTO_CLEANUP 0x00000002
591#define ZFCP_REQ_NO_QTCB 0x00000008
592
593#define ZFCP_SET 0x00000100 590#define ZFCP_SET 0x00000100
594#define ZFCP_CLEAR 0x00000200 591#define ZFCP_CLEAR 0x00000200
595 592
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index 387a3af528ac..631bdb1dfd6c 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Error Recovery Procedures (ERP). 4 * Error Recovery Procedures (ERP).
5 * 5 *
6 * Copyright IBM Corporation 2002, 2008 6 * Copyright IBM Corporation 2002, 2009
7 */ 7 */
8 8
9#define KMSG_COMPONENT "zfcp" 9#define KMSG_COMPONENT "zfcp"
@@ -55,7 +55,7 @@ enum zfcp_erp_act_result {
55 55
56static void zfcp_erp_adapter_block(struct zfcp_adapter *adapter, int mask) 56static void zfcp_erp_adapter_block(struct zfcp_adapter *adapter, int mask)
57{ 57{
58 zfcp_erp_modify_adapter_status(adapter, 15, NULL, 58 zfcp_erp_modify_adapter_status(adapter, "erablk1", NULL,
59 ZFCP_STATUS_COMMON_UNBLOCKED | mask, 59 ZFCP_STATUS_COMMON_UNBLOCKED | mask,
60 ZFCP_CLEAR); 60 ZFCP_CLEAR);
61} 61}
@@ -75,9 +75,9 @@ static void zfcp_erp_action_ready(struct zfcp_erp_action *act)
75 struct zfcp_adapter *adapter = act->adapter; 75 struct zfcp_adapter *adapter = act->adapter;
76 76
77 list_move(&act->list, &act->adapter->erp_ready_head); 77 list_move(&act->list, &act->adapter->erp_ready_head);
78 zfcp_rec_dbf_event_action(146, act); 78 zfcp_rec_dbf_event_action("erardy1", act);
79 up(&adapter->erp_ready_sem); 79 up(&adapter->erp_ready_sem);
80 zfcp_rec_dbf_event_thread(2, adapter); 80 zfcp_rec_dbf_event_thread("erardy2", adapter);
81} 81}
82 82
83static void zfcp_erp_action_dismiss(struct zfcp_erp_action *act) 83static void zfcp_erp_action_dismiss(struct zfcp_erp_action *act)
@@ -208,7 +208,7 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need,
208 208
209static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter, 209static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter,
210 struct zfcp_port *port, 210 struct zfcp_port *port,
211 struct zfcp_unit *unit, u8 id, void *ref) 211 struct zfcp_unit *unit, char *id, void *ref)
212{ 212{
213 int retval = 1, need; 213 int retval = 1, need;
214 struct zfcp_erp_action *act = NULL; 214 struct zfcp_erp_action *act = NULL;
@@ -228,7 +228,7 @@ static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter,
228 ++adapter->erp_total_count; 228 ++adapter->erp_total_count;
229 list_add_tail(&act->list, &adapter->erp_ready_head); 229 list_add_tail(&act->list, &adapter->erp_ready_head);
230 up(&adapter->erp_ready_sem); 230 up(&adapter->erp_ready_sem);
231 zfcp_rec_dbf_event_thread(1, adapter); 231 zfcp_rec_dbf_event_thread("eracte1", adapter);
232 retval = 0; 232 retval = 0;
233 out: 233 out:
234 zfcp_rec_dbf_event_trigger(id, ref, want, need, act, 234 zfcp_rec_dbf_event_trigger(id, ref, want, need, act,
@@ -237,13 +237,14 @@ static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter,
237} 237}
238 238
239static int _zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, 239static int _zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter,
240 int clear_mask, u8 id, void *ref) 240 int clear_mask, char *id, void *ref)
241{ 241{
242 zfcp_erp_adapter_block(adapter, clear_mask); 242 zfcp_erp_adapter_block(adapter, clear_mask);
243 zfcp_scsi_schedule_rports_block(adapter);
243 244
244 /* ensure propagation of failed status to new devices */ 245 /* ensure propagation of failed status to new devices */
245 if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { 246 if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
246 zfcp_erp_adapter_failed(adapter, 13, NULL); 247 zfcp_erp_adapter_failed(adapter, "erareo1", NULL);
247 return -EIO; 248 return -EIO;
248 } 249 }
249 return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER, 250 return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER,
@@ -258,7 +259,7 @@ static int _zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter,
258 * @ref: Reference for debug trace event. 259 * @ref: Reference for debug trace event.
259 */ 260 */
260void zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear, 261void zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear,
261 u8 id, void *ref) 262 char *id, void *ref)
262{ 263{
263 unsigned long flags; 264 unsigned long flags;
264 265
@@ -277,7 +278,7 @@ void zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear,
277 * @ref: Reference for debug trace event. 278 * @ref: Reference for debug trace event.
278 */ 279 */
279void zfcp_erp_adapter_shutdown(struct zfcp_adapter *adapter, int clear, 280void zfcp_erp_adapter_shutdown(struct zfcp_adapter *adapter, int clear,
280 u8 id, void *ref) 281 char *id, void *ref)
281{ 282{
282 int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; 283 int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED;
283 zfcp_erp_adapter_reopen(adapter, clear | flags, id, ref); 284 zfcp_erp_adapter_reopen(adapter, clear | flags, id, ref);
@@ -290,7 +291,8 @@ void zfcp_erp_adapter_shutdown(struct zfcp_adapter *adapter, int clear,
290 * @id: Id for debug trace event. 291 * @id: Id for debug trace event.
291 * @ref: Reference for debug trace event. 292 * @ref: Reference for debug trace event.
292 */ 293 */
293void zfcp_erp_port_shutdown(struct zfcp_port *port, int clear, u8 id, void *ref) 294void zfcp_erp_port_shutdown(struct zfcp_port *port, int clear, char *id,
295 void *ref)
294{ 296{
295 int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; 297 int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED;
296 zfcp_erp_port_reopen(port, clear | flags, id, ref); 298 zfcp_erp_port_reopen(port, clear | flags, id, ref);
@@ -303,7 +305,8 @@ void zfcp_erp_port_shutdown(struct zfcp_port *port, int clear, u8 id, void *ref)
303 * @id: Id for debug trace event. 305 * @id: Id for debug trace event.
304 * @ref: Reference for debug trace event. 306 * @ref: Reference for debug trace event.
305 */ 307 */
306void zfcp_erp_unit_shutdown(struct zfcp_unit *unit, int clear, u8 id, void *ref) 308void zfcp_erp_unit_shutdown(struct zfcp_unit *unit, int clear, char *id,
309 void *ref)
307{ 310{
308 int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; 311 int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED;
309 zfcp_erp_unit_reopen(unit, clear | flags, id, ref); 312 zfcp_erp_unit_reopen(unit, clear | flags, id, ref);
@@ -311,15 +314,16 @@ void zfcp_erp_unit_shutdown(struct zfcp_unit *unit, int clear, u8 id, void *ref)
311 314
312static void zfcp_erp_port_block(struct zfcp_port *port, int clear) 315static void zfcp_erp_port_block(struct zfcp_port *port, int clear)
313{ 316{
314 zfcp_erp_modify_port_status(port, 17, NULL, 317 zfcp_erp_modify_port_status(port, "erpblk1", NULL,
315 ZFCP_STATUS_COMMON_UNBLOCKED | clear, 318 ZFCP_STATUS_COMMON_UNBLOCKED | clear,
316 ZFCP_CLEAR); 319 ZFCP_CLEAR);
317} 320}
318 321
319static void _zfcp_erp_port_forced_reopen(struct zfcp_port *port, 322static void _zfcp_erp_port_forced_reopen(struct zfcp_port *port,
320 int clear, u8 id, void *ref) 323 int clear, char *id, void *ref)
321{ 324{
322 zfcp_erp_port_block(port, clear); 325 zfcp_erp_port_block(port, clear);
326 zfcp_scsi_schedule_rport_block(port);
323 327
324 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) 328 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
325 return; 329 return;
@@ -334,7 +338,7 @@ static void _zfcp_erp_port_forced_reopen(struct zfcp_port *port,
334 * @id: Id for debug trace event. 338 * @id: Id for debug trace event.
335 * @ref: Reference for debug trace event. 339 * @ref: Reference for debug trace event.
336 */ 340 */
337void zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear, u8 id, 341void zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear, char *id,
338 void *ref) 342 void *ref)
339{ 343{
340 unsigned long flags; 344 unsigned long flags;
@@ -347,14 +351,15 @@ void zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear, u8 id,
347 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 351 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
348} 352}
349 353
350static int _zfcp_erp_port_reopen(struct zfcp_port *port, int clear, u8 id, 354static int _zfcp_erp_port_reopen(struct zfcp_port *port, int clear, char *id,
351 void *ref) 355 void *ref)
352{ 356{
353 zfcp_erp_port_block(port, clear); 357 zfcp_erp_port_block(port, clear);
358 zfcp_scsi_schedule_rport_block(port);
354 359
355 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { 360 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
356 /* ensure propagation of failed status to new devices */ 361 /* ensure propagation of failed status to new devices */
357 zfcp_erp_port_failed(port, 14, NULL); 362 zfcp_erp_port_failed(port, "erpreo1", NULL);
358 return -EIO; 363 return -EIO;
359 } 364 }
360 365
@@ -369,7 +374,7 @@ static int _zfcp_erp_port_reopen(struct zfcp_port *port, int clear, u8 id,
369 * 374 *
370 * Returns 0 if recovery has been triggered, < 0 if not. 375 * Returns 0 if recovery has been triggered, < 0 if not.
371 */ 376 */
372int zfcp_erp_port_reopen(struct zfcp_port *port, int clear, u8 id, void *ref) 377int zfcp_erp_port_reopen(struct zfcp_port *port, int clear, char *id, void *ref)
373{ 378{
374 unsigned long flags; 379 unsigned long flags;
375 int retval; 380 int retval;
@@ -386,12 +391,12 @@ int zfcp_erp_port_reopen(struct zfcp_port *port, int clear, u8 id, void *ref)
386 391
387static void zfcp_erp_unit_block(struct zfcp_unit *unit, int clear_mask) 392static void zfcp_erp_unit_block(struct zfcp_unit *unit, int clear_mask)
388{ 393{
389 zfcp_erp_modify_unit_status(unit, 19, NULL, 394 zfcp_erp_modify_unit_status(unit, "erublk1", NULL,
390 ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask, 395 ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask,
391 ZFCP_CLEAR); 396 ZFCP_CLEAR);
392} 397}
393 398
394static void _zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, u8 id, 399static void _zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, char *id,
395 void *ref) 400 void *ref)
396{ 401{
397 struct zfcp_adapter *adapter = unit->port->adapter; 402 struct zfcp_adapter *adapter = unit->port->adapter;
@@ -411,7 +416,8 @@ static void _zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, u8 id,
411 * @clear_mask: specifies flags in unit status to be cleared 416 * @clear_mask: specifies flags in unit status to be cleared
412 * Return: 0 on success, < 0 on error 417 * Return: 0 on success, < 0 on error
413 */ 418 */
414void zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, u8 id, void *ref) 419void zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, char *id,
420 void *ref)
415{ 421{
416 unsigned long flags; 422 unsigned long flags;
417 struct zfcp_port *port = unit->port; 423 struct zfcp_port *port = unit->port;
@@ -437,28 +443,28 @@ static int status_change_clear(unsigned long mask, atomic_t *status)
437static void zfcp_erp_adapter_unblock(struct zfcp_adapter *adapter) 443static void zfcp_erp_adapter_unblock(struct zfcp_adapter *adapter)
438{ 444{
439 if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status)) 445 if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status))
440 zfcp_rec_dbf_event_adapter(16, NULL, adapter); 446 zfcp_rec_dbf_event_adapter("eraubl1", NULL, adapter);
441 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status); 447 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status);
442} 448}
443 449
444static void zfcp_erp_port_unblock(struct zfcp_port *port) 450static void zfcp_erp_port_unblock(struct zfcp_port *port)
445{ 451{
446 if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status)) 452 if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status))
447 zfcp_rec_dbf_event_port(18, NULL, port); 453 zfcp_rec_dbf_event_port("erpubl1", NULL, port);
448 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status); 454 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status);
449} 455}
450 456
451static void zfcp_erp_unit_unblock(struct zfcp_unit *unit) 457static void zfcp_erp_unit_unblock(struct zfcp_unit *unit)
452{ 458{
453 if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status)) 459 if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status))
454 zfcp_rec_dbf_event_unit(20, NULL, unit); 460 zfcp_rec_dbf_event_unit("eruubl1", NULL, unit);
455 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status); 461 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status);
456} 462}
457 463
458static void zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action) 464static void zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action)
459{ 465{
460 list_move(&erp_action->list, &erp_action->adapter->erp_running_head); 466 list_move(&erp_action->list, &erp_action->adapter->erp_running_head);
461 zfcp_rec_dbf_event_action(145, erp_action); 467 zfcp_rec_dbf_event_action("erator1", erp_action);
462} 468}
463 469
464static void zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *act) 470static void zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *act)
@@ -474,11 +480,11 @@ static void zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *act)
474 if (act->status & (ZFCP_STATUS_ERP_DISMISSED | 480 if (act->status & (ZFCP_STATUS_ERP_DISMISSED |
475 ZFCP_STATUS_ERP_TIMEDOUT)) { 481 ZFCP_STATUS_ERP_TIMEDOUT)) {
476 act->fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED; 482 act->fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
477 zfcp_rec_dbf_event_action(142, act); 483 zfcp_rec_dbf_event_action("erscf_1", act);
478 act->fsf_req->erp_action = NULL; 484 act->fsf_req->erp_action = NULL;
479 } 485 }
480 if (act->status & ZFCP_STATUS_ERP_TIMEDOUT) 486 if (act->status & ZFCP_STATUS_ERP_TIMEDOUT)
481 zfcp_rec_dbf_event_action(143, act); 487 zfcp_rec_dbf_event_action("erscf_2", act);
482 if (act->fsf_req->status & (ZFCP_STATUS_FSFREQ_COMPLETED | 488 if (act->fsf_req->status & (ZFCP_STATUS_FSFREQ_COMPLETED |
483 ZFCP_STATUS_FSFREQ_DISMISSED)) 489 ZFCP_STATUS_FSFREQ_DISMISSED))
484 act->fsf_req = NULL; 490 act->fsf_req = NULL;
@@ -530,7 +536,7 @@ static void zfcp_erp_strategy_memwait(struct zfcp_erp_action *erp_action)
530} 536}
531 537
532static void _zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter, 538static void _zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter,
533 int clear, u8 id, void *ref) 539 int clear, char *id, void *ref)
534{ 540{
535 struct zfcp_port *port; 541 struct zfcp_port *port;
536 542
@@ -538,8 +544,8 @@ static void _zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter,
538 _zfcp_erp_port_reopen(port, clear, id, ref); 544 _zfcp_erp_port_reopen(port, clear, id, ref);
539} 545}
540 546
541static void _zfcp_erp_unit_reopen_all(struct zfcp_port *port, int clear, u8 id, 547static void _zfcp_erp_unit_reopen_all(struct zfcp_port *port, int clear,
542 void *ref) 548 char *id, void *ref)
543{ 549{
544 struct zfcp_unit *unit; 550 struct zfcp_unit *unit;
545 551
@@ -559,28 +565,28 @@ static void zfcp_erp_strategy_followup_actions(struct zfcp_erp_action *act)
559 565
560 case ZFCP_ERP_ACTION_REOPEN_ADAPTER: 566 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
561 if (status == ZFCP_ERP_SUCCEEDED) 567 if (status == ZFCP_ERP_SUCCEEDED)
562 _zfcp_erp_port_reopen_all(adapter, 0, 70, NULL); 568 _zfcp_erp_port_reopen_all(adapter, 0, "ersfa_1", NULL);
563 else 569 else
564 _zfcp_erp_adapter_reopen(adapter, 0, 71, NULL); 570 _zfcp_erp_adapter_reopen(adapter, 0, "ersfa_2", NULL);
565 break; 571 break;
566 572
567 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: 573 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
568 if (status == ZFCP_ERP_SUCCEEDED) 574 if (status == ZFCP_ERP_SUCCEEDED)
569 _zfcp_erp_port_reopen(port, 0, 72, NULL); 575 _zfcp_erp_port_reopen(port, 0, "ersfa_3", NULL);
570 else 576 else
571 _zfcp_erp_adapter_reopen(adapter, 0, 73, NULL); 577 _zfcp_erp_adapter_reopen(adapter, 0, "ersfa_4", NULL);
572 break; 578 break;
573 579
574 case ZFCP_ERP_ACTION_REOPEN_PORT: 580 case ZFCP_ERP_ACTION_REOPEN_PORT:
575 if (status == ZFCP_ERP_SUCCEEDED) 581 if (status == ZFCP_ERP_SUCCEEDED)
576 _zfcp_erp_unit_reopen_all(port, 0, 74, NULL); 582 _zfcp_erp_unit_reopen_all(port, 0, "ersfa_5", NULL);
577 else 583 else
578 _zfcp_erp_port_forced_reopen(port, 0, 75, NULL); 584 _zfcp_erp_port_forced_reopen(port, 0, "ersfa_6", NULL);
579 break; 585 break;
580 586
581 case ZFCP_ERP_ACTION_REOPEN_UNIT: 587 case ZFCP_ERP_ACTION_REOPEN_UNIT:
582 if (status != ZFCP_ERP_SUCCEEDED) 588 if (status != ZFCP_ERP_SUCCEEDED)
583 _zfcp_erp_port_reopen(unit->port, 0, 76, NULL); 589 _zfcp_erp_port_reopen(unit->port, 0, "ersfa_7", NULL);
584 break; 590 break;
585 } 591 }
586} 592}
@@ -617,7 +623,7 @@ static void zfcp_erp_enqueue_ptp_port(struct zfcp_adapter *adapter)
617 adapter->peer_d_id); 623 adapter->peer_d_id);
618 if (IS_ERR(port)) /* error or port already attached */ 624 if (IS_ERR(port)) /* error or port already attached */
619 return; 625 return;
620 _zfcp_erp_port_reopen(port, 0, 150, NULL); 626 _zfcp_erp_port_reopen(port, 0, "ereptp1", NULL);
621} 627}
622 628
623static int zfcp_erp_adapter_strat_fsf_xconf(struct zfcp_erp_action *erp_action) 629static int zfcp_erp_adapter_strat_fsf_xconf(struct zfcp_erp_action *erp_action)
@@ -640,9 +646,9 @@ static int zfcp_erp_adapter_strat_fsf_xconf(struct zfcp_erp_action *erp_action)
640 return ZFCP_ERP_FAILED; 646 return ZFCP_ERP_FAILED;
641 } 647 }
642 648
643 zfcp_rec_dbf_event_thread_lock(6, adapter); 649 zfcp_rec_dbf_event_thread_lock("erasfx1", adapter);
644 down(&adapter->erp_ready_sem); 650 down(&adapter->erp_ready_sem);
645 zfcp_rec_dbf_event_thread_lock(7, adapter); 651 zfcp_rec_dbf_event_thread_lock("erasfx2", adapter);
646 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) 652 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT)
647 break; 653 break;
648 654
@@ -681,9 +687,9 @@ static int zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *act)
681 if (ret) 687 if (ret)
682 return ZFCP_ERP_FAILED; 688 return ZFCP_ERP_FAILED;
683 689
684 zfcp_rec_dbf_event_thread_lock(8, adapter); 690 zfcp_rec_dbf_event_thread_lock("erasox1", adapter);
685 down(&adapter->erp_ready_sem); 691 down(&adapter->erp_ready_sem);
686 zfcp_rec_dbf_event_thread_lock(9, adapter); 692 zfcp_rec_dbf_event_thread_lock("erasox2", adapter);
687 if (act->status & ZFCP_STATUS_ERP_TIMEDOUT) 693 if (act->status & ZFCP_STATUS_ERP_TIMEDOUT)
688 return ZFCP_ERP_FAILED; 694 return ZFCP_ERP_FAILED;
689 695
@@ -705,60 +711,59 @@ static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *act)
705 return ZFCP_ERP_SUCCEEDED; 711 return ZFCP_ERP_SUCCEEDED;
706} 712}
707 713
708static int zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *act, 714static void zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *act)
709 int close)
710{ 715{
711 int retval = ZFCP_ERP_SUCCEEDED;
712 struct zfcp_adapter *adapter = act->adapter; 716 struct zfcp_adapter *adapter = act->adapter;
713 717
714 if (close)
715 goto close_only;
716
717 retval = zfcp_erp_adapter_strategy_open_qdio(act);
718 if (retval != ZFCP_ERP_SUCCEEDED)
719 goto failed_qdio;
720
721 retval = zfcp_erp_adapter_strategy_open_fsf(act);
722 if (retval != ZFCP_ERP_SUCCEEDED)
723 goto failed_openfcp;
724
725 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &act->adapter->status);
726
727 return ZFCP_ERP_SUCCEEDED;
728
729 close_only:
730 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN,
731 &act->adapter->status);
732
733 failed_openfcp:
734 /* close queues to ensure that buffers are not accessed by adapter */ 718 /* close queues to ensure that buffers are not accessed by adapter */
735 zfcp_qdio_close(adapter); 719 zfcp_qdio_close(adapter);
736 zfcp_fsf_req_dismiss_all(adapter); 720 zfcp_fsf_req_dismiss_all(adapter);
737 adapter->fsf_req_seq_no = 0; 721 adapter->fsf_req_seq_no = 0;
738 /* all ports and units are closed */ 722 /* all ports and units are closed */
739 zfcp_erp_modify_adapter_status(adapter, 24, NULL, 723 zfcp_erp_modify_adapter_status(adapter, "erascl1", NULL,
740 ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR); 724 ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR);
741 failed_qdio: 725
742 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK | 726 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK |
743 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 727 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status);
744 &act->adapter->status);
745 return retval;
746} 728}
747 729
748static int zfcp_erp_adapter_strategy(struct zfcp_erp_action *act) 730static int zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *act)
749{ 731{
750 int retval; 732 struct zfcp_adapter *adapter = act->adapter;
751 733
752 zfcp_erp_adapter_strategy_generic(act, 1); /* close */ 734 if (zfcp_erp_adapter_strategy_open_qdio(act)) {
753 if (act->status & ZFCP_STATUS_ERP_CLOSE_ONLY) 735 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK |
754 return ZFCP_ERP_EXIT; 736 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
737 &adapter->status);
738 return ZFCP_ERP_FAILED;
739 }
740
741 if (zfcp_erp_adapter_strategy_open_fsf(act)) {
742 zfcp_erp_adapter_strategy_close(act);
743 return ZFCP_ERP_FAILED;
744 }
745
746 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &adapter->status);
747
748 return ZFCP_ERP_SUCCEEDED;
749}
755 750
756 retval = zfcp_erp_adapter_strategy_generic(act, 0); /* open */ 751static int zfcp_erp_adapter_strategy(struct zfcp_erp_action *act)
752{
753 struct zfcp_adapter *adapter = act->adapter;
757 754
758 if (retval == ZFCP_ERP_FAILED) 755 if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_OPEN) {
756 zfcp_erp_adapter_strategy_close(act);
757 if (act->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
758 return ZFCP_ERP_EXIT;
759 }
760
761 if (zfcp_erp_adapter_strategy_open(act)) {
759 ssleep(8); 762 ssleep(8);
763 return ZFCP_ERP_FAILED;
764 }
760 765
761 return retval; 766 return ZFCP_ERP_SUCCEEDED;
762} 767}
763 768
764static int zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *act) 769static int zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *act)
@@ -777,10 +782,7 @@ static int zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *act)
777 782
778static void zfcp_erp_port_strategy_clearstati(struct zfcp_port *port) 783static void zfcp_erp_port_strategy_clearstati(struct zfcp_port *port)
779{ 784{
780 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | 785 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED, &port->status);
781 ZFCP_STATUS_PORT_PHYS_CLOSING |
782 ZFCP_STATUS_PORT_INVALID_WWPN,
783 &port->status);
784} 786}
785 787
786static int zfcp_erp_port_forced_strategy(struct zfcp_erp_action *erp_action) 788static int zfcp_erp_port_forced_strategy(struct zfcp_erp_action *erp_action)
@@ -836,7 +838,7 @@ static int zfcp_erp_open_ptp_port(struct zfcp_erp_action *act)
836 struct zfcp_port *port = act->port; 838 struct zfcp_port *port = act->port;
837 839
838 if (port->wwpn != adapter->peer_wwpn) { 840 if (port->wwpn != adapter->peer_wwpn) {
839 zfcp_erp_port_failed(port, 25, NULL); 841 zfcp_erp_port_failed(port, "eroptp1", NULL);
840 return ZFCP_ERP_FAILED; 842 return ZFCP_ERP_FAILED;
841 } 843 }
842 port->d_id = adapter->peer_d_id; 844 port->d_id = adapter->peer_d_id;
@@ -855,7 +857,7 @@ void zfcp_erp_port_strategy_open_lookup(struct work_struct *work)
855 port->erp_action.step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP; 857 port->erp_action.step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP;
856 if (retval) 858 if (retval)
857 zfcp_erp_notify(&port->erp_action, ZFCP_ERP_FAILED); 859 zfcp_erp_notify(&port->erp_action, ZFCP_ERP_FAILED);
858 860 zfcp_port_put(port);
859} 861}
860 862
861static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *act) 863static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *act)
@@ -871,17 +873,15 @@ static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *act)
871 if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP) 873 if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP)
872 return zfcp_erp_open_ptp_port(act); 874 return zfcp_erp_open_ptp_port(act);
873 if (!port->d_id) { 875 if (!port->d_id) {
874 queue_work(zfcp_data.work_queue, &port->gid_pn_work); 876 zfcp_port_get(port);
877 if (!queue_work(zfcp_data.work_queue,
878 &port->gid_pn_work))
879 zfcp_port_put(port);
875 return ZFCP_ERP_CONTINUES; 880 return ZFCP_ERP_CONTINUES;
876 } 881 }
877 case ZFCP_ERP_STEP_NAMESERVER_LOOKUP: 882 case ZFCP_ERP_STEP_NAMESERVER_LOOKUP:
878 if (!port->d_id) { 883 if (!port->d_id)
879 if (p_status & (ZFCP_STATUS_PORT_INVALID_WWPN)) {
880 zfcp_erp_port_failed(port, 26, NULL);
881 return ZFCP_ERP_EXIT;
882 }
883 return ZFCP_ERP_FAILED; 884 return ZFCP_ERP_FAILED;
884 }
885 return zfcp_erp_port_strategy_open_port(act); 885 return zfcp_erp_port_strategy_open_port(act);
886 886
887 case ZFCP_ERP_STEP_PORT_OPENING: 887 case ZFCP_ERP_STEP_PORT_OPENING:
@@ -995,7 +995,7 @@ static int zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result)
995 "port 0x%016Lx\n", 995 "port 0x%016Lx\n",
996 (unsigned long long)unit->fcp_lun, 996 (unsigned long long)unit->fcp_lun,
997 (unsigned long long)unit->port->wwpn); 997 (unsigned long long)unit->port->wwpn);
998 zfcp_erp_unit_failed(unit, 21, NULL); 998 zfcp_erp_unit_failed(unit, "erusck1", NULL);
999 } 999 }
1000 break; 1000 break;
1001 } 1001 }
@@ -1025,7 +1025,7 @@ static int zfcp_erp_strategy_check_port(struct zfcp_port *port, int result)
1025 dev_err(&port->adapter->ccw_device->dev, 1025 dev_err(&port->adapter->ccw_device->dev,
1026 "ERP failed for remote port 0x%016Lx\n", 1026 "ERP failed for remote port 0x%016Lx\n",
1027 (unsigned long long)port->wwpn); 1027 (unsigned long long)port->wwpn);
1028 zfcp_erp_port_failed(port, 22, NULL); 1028 zfcp_erp_port_failed(port, "erpsck1", NULL);
1029 } 1029 }
1030 break; 1030 break;
1031 } 1031 }
@@ -1052,7 +1052,7 @@ static int zfcp_erp_strategy_check_adapter(struct zfcp_adapter *adapter,
1052 dev_err(&adapter->ccw_device->dev, 1052 dev_err(&adapter->ccw_device->dev,
1053 "ERP cannot recover an error " 1053 "ERP cannot recover an error "
1054 "on the FCP device\n"); 1054 "on the FCP device\n");
1055 zfcp_erp_adapter_failed(adapter, 23, NULL); 1055 zfcp_erp_adapter_failed(adapter, "erasck1", NULL);
1056 } 1056 }
1057 break; 1057 break;
1058 } 1058 }
@@ -1117,7 +1117,7 @@ static int zfcp_erp_strategy_statechange(struct zfcp_erp_action *act, int ret)
1117 if (zfcp_erp_strat_change_det(&adapter->status, erp_status)) { 1117 if (zfcp_erp_strat_change_det(&adapter->status, erp_status)) {
1118 _zfcp_erp_adapter_reopen(adapter, 1118 _zfcp_erp_adapter_reopen(adapter,
1119 ZFCP_STATUS_COMMON_ERP_FAILED, 1119 ZFCP_STATUS_COMMON_ERP_FAILED,
1120 67, NULL); 1120 "ersscg1", NULL);
1121 return ZFCP_ERP_EXIT; 1121 return ZFCP_ERP_EXIT;
1122 } 1122 }
1123 break; 1123 break;
@@ -1127,7 +1127,7 @@ static int zfcp_erp_strategy_statechange(struct zfcp_erp_action *act, int ret)
1127 if (zfcp_erp_strat_change_det(&port->status, erp_status)) { 1127 if (zfcp_erp_strat_change_det(&port->status, erp_status)) {
1128 _zfcp_erp_port_reopen(port, 1128 _zfcp_erp_port_reopen(port,
1129 ZFCP_STATUS_COMMON_ERP_FAILED, 1129 ZFCP_STATUS_COMMON_ERP_FAILED,
1130 68, NULL); 1130 "ersscg2", NULL);
1131 return ZFCP_ERP_EXIT; 1131 return ZFCP_ERP_EXIT;
1132 } 1132 }
1133 break; 1133 break;
@@ -1136,7 +1136,7 @@ static int zfcp_erp_strategy_statechange(struct zfcp_erp_action *act, int ret)
1136 if (zfcp_erp_strat_change_det(&unit->status, erp_status)) { 1136 if (zfcp_erp_strat_change_det(&unit->status, erp_status)) {
1137 _zfcp_erp_unit_reopen(unit, 1137 _zfcp_erp_unit_reopen(unit,
1138 ZFCP_STATUS_COMMON_ERP_FAILED, 1138 ZFCP_STATUS_COMMON_ERP_FAILED,
1139 69, NULL); 1139 "ersscg3", NULL);
1140 return ZFCP_ERP_EXIT; 1140 return ZFCP_ERP_EXIT;
1141 } 1141 }
1142 break; 1142 break;
@@ -1155,7 +1155,7 @@ static void zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action)
1155 } 1155 }
1156 1156
1157 list_del(&erp_action->list); 1157 list_del(&erp_action->list);
1158 zfcp_rec_dbf_event_action(144, erp_action); 1158 zfcp_rec_dbf_event_action("eractd1", erp_action);
1159 1159
1160 switch (erp_action->action) { 1160 switch (erp_action->action) {
1161 case ZFCP_ERP_ACTION_REOPEN_UNIT: 1161 case ZFCP_ERP_ACTION_REOPEN_UNIT:
@@ -1214,38 +1214,8 @@ static void zfcp_erp_schedule_work(struct zfcp_unit *unit)
1214 atomic_set_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status); 1214 atomic_set_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status);
1215 INIT_WORK(&p->work, zfcp_erp_scsi_scan); 1215 INIT_WORK(&p->work, zfcp_erp_scsi_scan);
1216 p->unit = unit; 1216 p->unit = unit;
1217 queue_work(zfcp_data.work_queue, &p->work); 1217 if (!queue_work(zfcp_data.work_queue, &p->work))
1218} 1218 zfcp_unit_put(unit);
1219
1220static void zfcp_erp_rport_register(struct zfcp_port *port)
1221{
1222 struct fc_rport_identifiers ids;
1223 ids.node_name = port->wwnn;
1224 ids.port_name = port->wwpn;
1225 ids.port_id = port->d_id;
1226 ids.roles = FC_RPORT_ROLE_FCP_TARGET;
1227 port->rport = fc_remote_port_add(port->adapter->scsi_host, 0, &ids);
1228 if (!port->rport) {
1229 dev_err(&port->adapter->ccw_device->dev,
1230 "Registering port 0x%016Lx failed\n",
1231 (unsigned long long)port->wwpn);
1232 return;
1233 }
1234
1235 scsi_target_unblock(&port->rport->dev);
1236 port->rport->maxframe_size = port->maxframe_size;
1237 port->rport->supported_classes = port->supported_classes;
1238}
1239
1240static void zfcp_erp_rports_del(struct zfcp_adapter *adapter)
1241{
1242 struct zfcp_port *port;
1243 list_for_each_entry(port, &adapter->port_list_head, list) {
1244 if (!port->rport)
1245 continue;
1246 fc_remote_port_delete(port->rport);
1247 port->rport = NULL;
1248 }
1249} 1219}
1250 1220
1251static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result) 1221static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result)
@@ -1256,10 +1226,8 @@ static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result)
1256 1226
1257 switch (act->action) { 1227 switch (act->action) {
1258 case ZFCP_ERP_ACTION_REOPEN_UNIT: 1228 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1259 if ((result == ZFCP_ERP_SUCCEEDED) && 1229 flush_work(&port->rport_work);
1260 !unit->device && port->rport) { 1230 if ((result == ZFCP_ERP_SUCCEEDED) && !unit->device) {
1261 atomic_set_mask(ZFCP_STATUS_UNIT_REGISTERED,
1262 &unit->status);
1263 if (!(atomic_read(&unit->status) & 1231 if (!(atomic_read(&unit->status) &
1264 ZFCP_STATUS_UNIT_SCSI_WORK_PENDING)) 1232 ZFCP_STATUS_UNIT_SCSI_WORK_PENDING))
1265 zfcp_erp_schedule_work(unit); 1233 zfcp_erp_schedule_work(unit);
@@ -1269,27 +1237,17 @@ static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result)
1269 1237
1270 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: 1238 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1271 case ZFCP_ERP_ACTION_REOPEN_PORT: 1239 case ZFCP_ERP_ACTION_REOPEN_PORT:
1272 if (atomic_read(&port->status) & ZFCP_STATUS_PORT_NO_WWPN) { 1240 if (result == ZFCP_ERP_SUCCEEDED)
1273 zfcp_port_put(port); 1241 zfcp_scsi_schedule_rport_register(port);
1274 return;
1275 }
1276 if ((result == ZFCP_ERP_SUCCEEDED) && !port->rport)
1277 zfcp_erp_rport_register(port);
1278 if ((result != ZFCP_ERP_SUCCEEDED) && port->rport) {
1279 fc_remote_port_delete(port->rport);
1280 port->rport = NULL;
1281 }
1282 zfcp_port_put(port); 1242 zfcp_port_put(port);
1283 break; 1243 break;
1284 1244
1285 case ZFCP_ERP_ACTION_REOPEN_ADAPTER: 1245 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1286 if (result != ZFCP_ERP_SUCCEEDED) { 1246 if (result == ZFCP_ERP_SUCCEEDED) {
1287 unregister_service_level(&adapter->service_level);
1288 zfcp_erp_rports_del(adapter);
1289 } else {
1290 register_service_level(&adapter->service_level); 1247 register_service_level(&adapter->service_level);
1291 schedule_work(&adapter->scan_work); 1248 schedule_work(&adapter->scan_work);
1292 } 1249 } else
1250 unregister_service_level(&adapter->service_level);
1293 zfcp_adapter_put(adapter); 1251 zfcp_adapter_put(adapter);
1294 break; 1252 break;
1295 } 1253 }
@@ -1346,7 +1304,7 @@ static int zfcp_erp_strategy(struct zfcp_erp_action *erp_action)
1346 erp_action->status |= ZFCP_STATUS_ERP_LOWMEM; 1304 erp_action->status |= ZFCP_STATUS_ERP_LOWMEM;
1347 } 1305 }
1348 if (adapter->erp_total_count == adapter->erp_low_mem_count) 1306 if (adapter->erp_total_count == adapter->erp_low_mem_count)
1349 _zfcp_erp_adapter_reopen(adapter, 0, 66, NULL); 1307 _zfcp_erp_adapter_reopen(adapter, 0, "erstgy1", NULL);
1350 else { 1308 else {
1351 zfcp_erp_strategy_memwait(erp_action); 1309 zfcp_erp_strategy_memwait(erp_action);
1352 retval = ZFCP_ERP_CONTINUES; 1310 retval = ZFCP_ERP_CONTINUES;
@@ -1406,9 +1364,9 @@ static int zfcp_erp_thread(void *data)
1406 zfcp_erp_wakeup(adapter); 1364 zfcp_erp_wakeup(adapter);
1407 } 1365 }
1408 1366
1409 zfcp_rec_dbf_event_thread_lock(4, adapter); 1367 zfcp_rec_dbf_event_thread_lock("erthrd1", adapter);
1410 ignore = down_interruptible(&adapter->erp_ready_sem); 1368 ignore = down_interruptible(&adapter->erp_ready_sem);
1411 zfcp_rec_dbf_event_thread_lock(5, adapter); 1369 zfcp_rec_dbf_event_thread_lock("erthrd2", adapter);
1412 } 1370 }
1413 1371
1414 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status); 1372 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
@@ -1453,7 +1411,7 @@ void zfcp_erp_thread_kill(struct zfcp_adapter *adapter)
1453{ 1411{
1454 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, &adapter->status); 1412 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, &adapter->status);
1455 up(&adapter->erp_ready_sem); 1413 up(&adapter->erp_ready_sem);
1456 zfcp_rec_dbf_event_thread_lock(3, adapter); 1414 zfcp_rec_dbf_event_thread_lock("erthrk1", adapter);
1457 1415
1458 wait_event(adapter->erp_thread_wqh, 1416 wait_event(adapter->erp_thread_wqh,
1459 !(atomic_read(&adapter->status) & 1417 !(atomic_read(&adapter->status) &
@@ -1469,7 +1427,7 @@ void zfcp_erp_thread_kill(struct zfcp_adapter *adapter)
1469 * @id: Event id for debug trace. 1427 * @id: Event id for debug trace.
1470 * @ref: Reference for debug trace. 1428 * @ref: Reference for debug trace.
1471 */ 1429 */
1472void zfcp_erp_adapter_failed(struct zfcp_adapter *adapter, u8 id, void *ref) 1430void zfcp_erp_adapter_failed(struct zfcp_adapter *adapter, char *id, void *ref)
1473{ 1431{
1474 zfcp_erp_modify_adapter_status(adapter, id, ref, 1432 zfcp_erp_modify_adapter_status(adapter, id, ref,
1475 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); 1433 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
@@ -1481,7 +1439,7 @@ void zfcp_erp_adapter_failed(struct zfcp_adapter *adapter, u8 id, void *ref)
1481 * @id: Event id for debug trace. 1439 * @id: Event id for debug trace.
1482 * @ref: Reference for debug trace. 1440 * @ref: Reference for debug trace.
1483 */ 1441 */
1484void zfcp_erp_port_failed(struct zfcp_port *port, u8 id, void *ref) 1442void zfcp_erp_port_failed(struct zfcp_port *port, char *id, void *ref)
1485{ 1443{
1486 zfcp_erp_modify_port_status(port, id, ref, 1444 zfcp_erp_modify_port_status(port, id, ref,
1487 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); 1445 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
@@ -1493,7 +1451,7 @@ void zfcp_erp_port_failed(struct zfcp_port *port, u8 id, void *ref)
1493 * @id: Event id for debug trace. 1451 * @id: Event id for debug trace.
1494 * @ref: Reference for debug trace. 1452 * @ref: Reference for debug trace.
1495 */ 1453 */
1496void zfcp_erp_unit_failed(struct zfcp_unit *unit, u8 id, void *ref) 1454void zfcp_erp_unit_failed(struct zfcp_unit *unit, char *id, void *ref)
1497{ 1455{
1498 zfcp_erp_modify_unit_status(unit, id, ref, 1456 zfcp_erp_modify_unit_status(unit, id, ref,
1499 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); 1457 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
@@ -1520,7 +1478,7 @@ void zfcp_erp_wait(struct zfcp_adapter *adapter)
1520 * 1478 *
1521 * Changes in common status bits are propagated to attached ports and units. 1479 * Changes in common status bits are propagated to attached ports and units.
1522 */ 1480 */
1523void zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter, u8 id, 1481void zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter, char *id,
1524 void *ref, u32 mask, int set_or_clear) 1482 void *ref, u32 mask, int set_or_clear)
1525{ 1483{
1526 struct zfcp_port *port; 1484 struct zfcp_port *port;
@@ -1554,7 +1512,7 @@ void zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter, u8 id,
1554 * 1512 *
1555 * Changes in common status bits are propagated to attached units. 1513 * Changes in common status bits are propagated to attached units.
1556 */ 1514 */
1557void zfcp_erp_modify_port_status(struct zfcp_port *port, u8 id, void *ref, 1515void zfcp_erp_modify_port_status(struct zfcp_port *port, char *id, void *ref,
1558 u32 mask, int set_or_clear) 1516 u32 mask, int set_or_clear)
1559{ 1517{
1560 struct zfcp_unit *unit; 1518 struct zfcp_unit *unit;
@@ -1586,7 +1544,7 @@ void zfcp_erp_modify_port_status(struct zfcp_port *port, u8 id, void *ref,
1586 * @mask: status bits to change 1544 * @mask: status bits to change
1587 * @set_or_clear: ZFCP_SET or ZFCP_CLEAR 1545 * @set_or_clear: ZFCP_SET or ZFCP_CLEAR
1588 */ 1546 */
1589void zfcp_erp_modify_unit_status(struct zfcp_unit *unit, u8 id, void *ref, 1547void zfcp_erp_modify_unit_status(struct zfcp_unit *unit, char *id, void *ref,
1590 u32 mask, int set_or_clear) 1548 u32 mask, int set_or_clear)
1591{ 1549{
1592 if (set_or_clear == ZFCP_SET) { 1550 if (set_or_clear == ZFCP_SET) {
@@ -1609,7 +1567,7 @@ void zfcp_erp_modify_unit_status(struct zfcp_unit *unit, u8 id, void *ref,
1609 * @id: The debug trace id. 1567 * @id: The debug trace id.
1610 * @id: Reference for the debug trace. 1568 * @id: Reference for the debug trace.
1611 */ 1569 */
1612void zfcp_erp_port_boxed(struct zfcp_port *port, u8 id, void *ref) 1570void zfcp_erp_port_boxed(struct zfcp_port *port, char *id, void *ref)
1613{ 1571{
1614 unsigned long flags; 1572 unsigned long flags;
1615 1573
@@ -1626,7 +1584,7 @@ void zfcp_erp_port_boxed(struct zfcp_port *port, u8 id, void *ref)
1626 * @id: The debug trace id. 1584 * @id: The debug trace id.
1627 * @id: Reference for the debug trace. 1585 * @id: Reference for the debug trace.
1628 */ 1586 */
1629void zfcp_erp_unit_boxed(struct zfcp_unit *unit, u8 id, void *ref) 1587void zfcp_erp_unit_boxed(struct zfcp_unit *unit, char *id, void *ref)
1630{ 1588{
1631 zfcp_erp_modify_unit_status(unit, id, ref, 1589 zfcp_erp_modify_unit_status(unit, id, ref,
1632 ZFCP_STATUS_COMMON_ACCESS_BOXED, ZFCP_SET); 1590 ZFCP_STATUS_COMMON_ACCESS_BOXED, ZFCP_SET);
@@ -1642,7 +1600,7 @@ void zfcp_erp_unit_boxed(struct zfcp_unit *unit, u8 id, void *ref)
1642 * Since the adapter has denied access, stop using the port and the 1600 * Since the adapter has denied access, stop using the port and the
1643 * attached units. 1601 * attached units.
1644 */ 1602 */
1645void zfcp_erp_port_access_denied(struct zfcp_port *port, u8 id, void *ref) 1603void zfcp_erp_port_access_denied(struct zfcp_port *port, char *id, void *ref)
1646{ 1604{
1647 unsigned long flags; 1605 unsigned long flags;
1648 1606
@@ -1661,14 +1619,14 @@ void zfcp_erp_port_access_denied(struct zfcp_port *port, u8 id, void *ref)
1661 * 1619 *
1662 * Since the adapter has denied access, stop using the unit. 1620 * Since the adapter has denied access, stop using the unit.
1663 */ 1621 */
1664void zfcp_erp_unit_access_denied(struct zfcp_unit *unit, u8 id, void *ref) 1622void zfcp_erp_unit_access_denied(struct zfcp_unit *unit, char *id, void *ref)
1665{ 1623{
1666 zfcp_erp_modify_unit_status(unit, id, ref, 1624 zfcp_erp_modify_unit_status(unit, id, ref,
1667 ZFCP_STATUS_COMMON_ERP_FAILED | 1625 ZFCP_STATUS_COMMON_ERP_FAILED |
1668 ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET); 1626 ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET);
1669} 1627}
1670 1628
1671static void zfcp_erp_unit_access_changed(struct zfcp_unit *unit, u8 id, 1629static void zfcp_erp_unit_access_changed(struct zfcp_unit *unit, char *id,
1672 void *ref) 1630 void *ref)
1673{ 1631{
1674 int status = atomic_read(&unit->status); 1632 int status = atomic_read(&unit->status);
@@ -1679,7 +1637,7 @@ static void zfcp_erp_unit_access_changed(struct zfcp_unit *unit, u8 id,
1679 zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); 1637 zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref);
1680} 1638}
1681 1639
1682static void zfcp_erp_port_access_changed(struct zfcp_port *port, u8 id, 1640static void zfcp_erp_port_access_changed(struct zfcp_port *port, char *id,
1683 void *ref) 1641 void *ref)
1684{ 1642{
1685 struct zfcp_unit *unit; 1643 struct zfcp_unit *unit;
@@ -1701,7 +1659,7 @@ static void zfcp_erp_port_access_changed(struct zfcp_port *port, u8 id,
1701 * @id: Id for debug trace 1659 * @id: Id for debug trace
1702 * @ref: Reference for debug trace 1660 * @ref: Reference for debug trace
1703 */ 1661 */
1704void zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter, u8 id, 1662void zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter, char *id,
1705 void *ref) 1663 void *ref)
1706{ 1664{
1707 struct zfcp_port *port; 1665 struct zfcp_port *port;
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
index b5adeda93e1d..f6399ca97bcb 100644
--- a/drivers/s390/scsi/zfcp_ext.h
+++ b/drivers/s390/scsi/zfcp_ext.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * External function declarations. 4 * External function declarations.
5 * 5 *
6 * Copyright IBM Corporation 2002, 2008 6 * Copyright IBM Corporation 2002, 2009
7 */ 7 */
8 8
9#ifndef ZFCP_EXT_H 9#ifndef ZFCP_EXT_H
@@ -35,15 +35,15 @@ extern struct miscdevice zfcp_cfdc_misc;
35/* zfcp_dbf.c */ 35/* zfcp_dbf.c */
36extern int zfcp_adapter_debug_register(struct zfcp_adapter *); 36extern int zfcp_adapter_debug_register(struct zfcp_adapter *);
37extern void zfcp_adapter_debug_unregister(struct zfcp_adapter *); 37extern void zfcp_adapter_debug_unregister(struct zfcp_adapter *);
38extern void zfcp_rec_dbf_event_thread(u8, struct zfcp_adapter *); 38extern void zfcp_rec_dbf_event_thread(char *, struct zfcp_adapter *);
39extern void zfcp_rec_dbf_event_thread_lock(u8, struct zfcp_adapter *); 39extern void zfcp_rec_dbf_event_thread_lock(char *, struct zfcp_adapter *);
40extern void zfcp_rec_dbf_event_adapter(u8, void *, struct zfcp_adapter *); 40extern void zfcp_rec_dbf_event_adapter(char *, void *, struct zfcp_adapter *);
41extern void zfcp_rec_dbf_event_port(u8, void *, struct zfcp_port *); 41extern void zfcp_rec_dbf_event_port(char *, void *, struct zfcp_port *);
42extern void zfcp_rec_dbf_event_unit(u8, void *, struct zfcp_unit *); 42extern void zfcp_rec_dbf_event_unit(char *, void *, struct zfcp_unit *);
43extern void zfcp_rec_dbf_event_trigger(u8, void *, u8, u8, void *, 43extern void zfcp_rec_dbf_event_trigger(char *, void *, u8, u8, void *,
44 struct zfcp_adapter *, 44 struct zfcp_adapter *,
45 struct zfcp_port *, struct zfcp_unit *); 45 struct zfcp_port *, struct zfcp_unit *);
46extern void zfcp_rec_dbf_event_action(u8, struct zfcp_erp_action *); 46extern void zfcp_rec_dbf_event_action(char *, struct zfcp_erp_action *);
47extern void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *); 47extern void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *);
48extern void zfcp_hba_dbf_event_fsf_unsol(const char *, struct zfcp_adapter *, 48extern void zfcp_hba_dbf_event_fsf_unsol(const char *, struct zfcp_adapter *,
49 struct fsf_status_read_buffer *); 49 struct fsf_status_read_buffer *);
@@ -66,31 +66,34 @@ extern void zfcp_scsi_dbf_event_devreset(const char *, u8, struct zfcp_unit *,
66 struct scsi_cmnd *); 66 struct scsi_cmnd *);
67 67
68/* zfcp_erp.c */ 68/* zfcp_erp.c */
69extern void zfcp_erp_modify_adapter_status(struct zfcp_adapter *, u8, void *, 69extern void zfcp_erp_modify_adapter_status(struct zfcp_adapter *, char *,
70 u32, int); 70 void *, u32, int);
71extern void zfcp_erp_adapter_reopen(struct zfcp_adapter *, int, u8, void *); 71extern void zfcp_erp_adapter_reopen(struct zfcp_adapter *, int, char *, void *);
72extern void zfcp_erp_adapter_shutdown(struct zfcp_adapter *, int, u8, void *); 72extern void zfcp_erp_adapter_shutdown(struct zfcp_adapter *, int, char *,
73extern void zfcp_erp_adapter_failed(struct zfcp_adapter *, u8, void *); 73 void *);
74extern void zfcp_erp_modify_port_status(struct zfcp_port *, u8, void *, u32, 74extern void zfcp_erp_adapter_failed(struct zfcp_adapter *, char *, void *);
75extern void zfcp_erp_modify_port_status(struct zfcp_port *, char *, void *, u32,
75 int); 76 int);
76extern int zfcp_erp_port_reopen(struct zfcp_port *, int, u8, void *); 77extern int zfcp_erp_port_reopen(struct zfcp_port *, int, char *, void *);
77extern void zfcp_erp_port_shutdown(struct zfcp_port *, int, u8, void *); 78extern void zfcp_erp_port_shutdown(struct zfcp_port *, int, char *, void *);
78extern void zfcp_erp_port_forced_reopen(struct zfcp_port *, int, u8, void *); 79extern void zfcp_erp_port_forced_reopen(struct zfcp_port *, int, char *,
79extern void zfcp_erp_port_failed(struct zfcp_port *, u8, void *); 80 void *);
80extern void zfcp_erp_modify_unit_status(struct zfcp_unit *, u8, void *, u32, 81extern void zfcp_erp_port_failed(struct zfcp_port *, char *, void *);
82extern void zfcp_erp_modify_unit_status(struct zfcp_unit *, char *, void *, u32,
81 int); 83 int);
82extern void zfcp_erp_unit_reopen(struct zfcp_unit *, int, u8, void *); 84extern void zfcp_erp_unit_reopen(struct zfcp_unit *, int, char *, void *);
83extern void zfcp_erp_unit_shutdown(struct zfcp_unit *, int, u8, void *); 85extern void zfcp_erp_unit_shutdown(struct zfcp_unit *, int, char *, void *);
84extern void zfcp_erp_unit_failed(struct zfcp_unit *, u8, void *); 86extern void zfcp_erp_unit_failed(struct zfcp_unit *, char *, void *);
85extern int zfcp_erp_thread_setup(struct zfcp_adapter *); 87extern int zfcp_erp_thread_setup(struct zfcp_adapter *);
86extern void zfcp_erp_thread_kill(struct zfcp_adapter *); 88extern void zfcp_erp_thread_kill(struct zfcp_adapter *);
87extern void zfcp_erp_wait(struct zfcp_adapter *); 89extern void zfcp_erp_wait(struct zfcp_adapter *);
88extern void zfcp_erp_notify(struct zfcp_erp_action *, unsigned long); 90extern void zfcp_erp_notify(struct zfcp_erp_action *, unsigned long);
89extern void zfcp_erp_port_boxed(struct zfcp_port *, u8, void *); 91extern void zfcp_erp_port_boxed(struct zfcp_port *, char *, void *);
90extern void zfcp_erp_unit_boxed(struct zfcp_unit *, u8, void *); 92extern void zfcp_erp_unit_boxed(struct zfcp_unit *, char *, void *);
91extern void zfcp_erp_port_access_denied(struct zfcp_port *, u8, void *); 93extern void zfcp_erp_port_access_denied(struct zfcp_port *, char *, void *);
92extern void zfcp_erp_unit_access_denied(struct zfcp_unit *, u8, void *); 94extern void zfcp_erp_unit_access_denied(struct zfcp_unit *, char *, void *);
93extern void zfcp_erp_adapter_access_changed(struct zfcp_adapter *, u8, void *); 95extern void zfcp_erp_adapter_access_changed(struct zfcp_adapter *, char *,
96 void *);
94extern void zfcp_erp_timeout_handler(unsigned long); 97extern void zfcp_erp_timeout_handler(unsigned long);
95extern void zfcp_erp_port_strategy_open_lookup(struct work_struct *); 98extern void zfcp_erp_port_strategy_open_lookup(struct work_struct *);
96 99
@@ -101,6 +104,7 @@ extern void zfcp_fc_incoming_els(struct zfcp_fsf_req *);
101extern int zfcp_fc_ns_gid_pn(struct zfcp_erp_action *); 104extern int zfcp_fc_ns_gid_pn(struct zfcp_erp_action *);
102extern void zfcp_fc_plogi_evaluate(struct zfcp_port *, struct fsf_plogi *); 105extern void zfcp_fc_plogi_evaluate(struct zfcp_port *, struct fsf_plogi *);
103extern void zfcp_test_link(struct zfcp_port *); 106extern void zfcp_test_link(struct zfcp_port *);
107extern void zfcp_fc_link_test_work(struct work_struct *);
104extern void zfcp_fc_nameserver_init(struct zfcp_adapter *); 108extern void zfcp_fc_nameserver_init(struct zfcp_adapter *);
105 109
106/* zfcp_fsf.c */ 110/* zfcp_fsf.c */
@@ -125,16 +129,13 @@ extern int zfcp_status_read_refill(struct zfcp_adapter *adapter);
125extern int zfcp_fsf_send_ct(struct zfcp_send_ct *, mempool_t *, 129extern int zfcp_fsf_send_ct(struct zfcp_send_ct *, mempool_t *,
126 struct zfcp_erp_action *); 130 struct zfcp_erp_action *);
127extern int zfcp_fsf_send_els(struct zfcp_send_els *); 131extern int zfcp_fsf_send_els(struct zfcp_send_els *);
128extern int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *, 132extern int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *,
129 struct zfcp_unit *, 133 struct scsi_cmnd *);
130 struct scsi_cmnd *, int, int);
131extern void zfcp_fsf_req_complete(struct zfcp_fsf_req *); 134extern void zfcp_fsf_req_complete(struct zfcp_fsf_req *);
132extern void zfcp_fsf_req_free(struct zfcp_fsf_req *); 135extern void zfcp_fsf_req_free(struct zfcp_fsf_req *);
133extern struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_adapter *, 136extern struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *, u8);
134 struct zfcp_unit *, u8, int);
135extern struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long, 137extern struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long,
136 struct zfcp_adapter *, 138 struct zfcp_unit *);
137 struct zfcp_unit *, int);
138 139
139/* zfcp_qdio.c */ 140/* zfcp_qdio.c */
140extern int zfcp_qdio_allocate(struct zfcp_adapter *); 141extern int zfcp_qdio_allocate(struct zfcp_adapter *);
@@ -153,6 +154,10 @@ extern int zfcp_adapter_scsi_register(struct zfcp_adapter *);
153extern void zfcp_adapter_scsi_unregister(struct zfcp_adapter *); 154extern void zfcp_adapter_scsi_unregister(struct zfcp_adapter *);
154extern char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *); 155extern char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *);
155extern struct fc_function_template zfcp_transport_functions; 156extern struct fc_function_template zfcp_transport_functions;
157extern void zfcp_scsi_rport_work(struct work_struct *);
158extern void zfcp_scsi_schedule_rport_register(struct zfcp_port *);
159extern void zfcp_scsi_schedule_rport_block(struct zfcp_port *);
160extern void zfcp_scsi_schedule_rports_block(struct zfcp_adapter *);
156 161
157/* zfcp_sysfs.c */ 162/* zfcp_sysfs.c */
158extern struct attribute_group zfcp_sysfs_unit_attrs; 163extern struct attribute_group zfcp_sysfs_unit_attrs;
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
index eabdfe24456e..aab8123c5966 100644
--- a/drivers/s390/scsi/zfcp_fc.c
+++ b/drivers/s390/scsi/zfcp_fc.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Fibre Channel related functions for the zfcp device driver. 4 * Fibre Channel related functions for the zfcp device driver.
5 * 5 *
6 * Copyright IBM Corporation 2008 6 * Copyright IBM Corporation 2008, 2009
7 */ 7 */
8 8
9#define KMSG_COMPONENT "zfcp" 9#define KMSG_COMPONENT "zfcp"
@@ -98,8 +98,12 @@ static void zfcp_wka_port_offline(struct work_struct *work)
98 struct zfcp_wka_port *wka_port = 98 struct zfcp_wka_port *wka_port =
99 container_of(dw, struct zfcp_wka_port, work); 99 container_of(dw, struct zfcp_wka_port, work);
100 100
101 wait_event(wka_port->completion_wq, 101 /* Don't wait forvever. If the wka_port is too busy take it offline
102 atomic_read(&wka_port->refcount) == 0); 102 through a new call later */
103 if (!wait_event_timeout(wka_port->completion_wq,
104 atomic_read(&wka_port->refcount) == 0,
105 HZ >> 1))
106 return;
103 107
104 mutex_lock(&wka_port->mutex); 108 mutex_lock(&wka_port->mutex);
105 if ((atomic_read(&wka_port->refcount) != 0) || 109 if ((atomic_read(&wka_port->refcount) != 0) ||
@@ -145,16 +149,10 @@ static void _zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req, u32 range,
145 struct zfcp_port *port; 149 struct zfcp_port *port;
146 150
147 read_lock_irqsave(&zfcp_data.config_lock, flags); 151 read_lock_irqsave(&zfcp_data.config_lock, flags);
148 list_for_each_entry(port, &fsf_req->adapter->port_list_head, list) { 152 list_for_each_entry(port, &fsf_req->adapter->port_list_head, list)
149 if (!(atomic_read(&port->status) & ZFCP_STATUS_PORT_PHYS_OPEN)) 153 if ((port->d_id & range) == (elem->nport_did & range))
150 /* Try to connect to unused ports anyway. */
151 zfcp_erp_port_reopen(port,
152 ZFCP_STATUS_COMMON_ERP_FAILED,
153 82, fsf_req);
154 else if ((port->d_id & range) == (elem->nport_did & range))
155 /* Check connection status for connected ports */
156 zfcp_test_link(port); 154 zfcp_test_link(port);
157 } 155
158 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 156 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
159} 157}
160 158
@@ -196,7 +194,7 @@ static void zfcp_fc_incoming_wwpn(struct zfcp_fsf_req *req, u64 wwpn)
196 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 194 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
197 195
198 if (port && (port->wwpn == wwpn)) 196 if (port && (port->wwpn == wwpn))
199 zfcp_erp_port_forced_reopen(port, 0, 83, req); 197 zfcp_erp_port_forced_reopen(port, 0, "fciwwp1", req);
200} 198}
201 199
202static void zfcp_fc_incoming_plogi(struct zfcp_fsf_req *req) 200static void zfcp_fc_incoming_plogi(struct zfcp_fsf_req *req)
@@ -259,10 +257,9 @@ static void zfcp_fc_ns_gid_pn_eval(unsigned long data)
259 257
260 if (ct->status) 258 if (ct->status)
261 return; 259 return;
262 if (ct_iu_resp->header.cmd_rsp_code != ZFCP_CT_ACCEPT) { 260 if (ct_iu_resp->header.cmd_rsp_code != ZFCP_CT_ACCEPT)
263 atomic_set_mask(ZFCP_STATUS_PORT_INVALID_WWPN, &port->status);
264 return; 261 return;
265 } 262
266 /* paranoia */ 263 /* paranoia */
267 if (ct_iu_req->wwpn != port->wwpn) 264 if (ct_iu_req->wwpn != port->wwpn)
268 return; 265 return;
@@ -375,16 +372,22 @@ static void zfcp_fc_adisc_handler(unsigned long data)
375 372
376 if (adisc->els.status) { 373 if (adisc->els.status) {
377 /* request rejected or timed out */ 374 /* request rejected or timed out */
378 zfcp_erp_port_forced_reopen(port, 0, 63, NULL); 375 zfcp_erp_port_forced_reopen(port, 0, "fcadh_1", NULL);
379 goto out; 376 goto out;
380 } 377 }
381 378
382 if (!port->wwnn) 379 if (!port->wwnn)
383 port->wwnn = ls_adisc->wwnn; 380 port->wwnn = ls_adisc->wwnn;
384 381
385 if (port->wwpn != ls_adisc->wwpn) 382 if ((port->wwpn != ls_adisc->wwpn) ||
386 zfcp_erp_port_reopen(port, 0, 64, NULL); 383 !(atomic_read(&port->status) & ZFCP_STATUS_COMMON_OPEN)) {
384 zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED,
385 "fcadh_2", NULL);
386 goto out;
387 }
387 388
389 /* port is good, unblock rport without going through erp */
390 zfcp_scsi_schedule_rport_register(port);
388 out: 391 out:
389 zfcp_port_put(port); 392 zfcp_port_put(port);
390 kfree(adisc); 393 kfree(adisc);
@@ -422,6 +425,31 @@ static int zfcp_fc_adisc(struct zfcp_port *port)
422 return zfcp_fsf_send_els(&adisc->els); 425 return zfcp_fsf_send_els(&adisc->els);
423} 426}
424 427
428void zfcp_fc_link_test_work(struct work_struct *work)
429{
430 struct zfcp_port *port =
431 container_of(work, struct zfcp_port, test_link_work);
432 int retval;
433
434 if (!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_UNBLOCKED)) {
435 zfcp_port_put(port);
436 return; /* port erp is running and will update rport status */
437 }
438
439 zfcp_port_get(port);
440 port->rport_task = RPORT_DEL;
441 zfcp_scsi_rport_work(&port->rport_work);
442
443 retval = zfcp_fc_adisc(port);
444 if (retval == 0)
445 return;
446
447 /* send of ADISC was not possible */
448 zfcp_erp_port_forced_reopen(port, 0, "fcltwk1", NULL);
449
450 zfcp_port_put(port);
451}
452
425/** 453/**
426 * zfcp_test_link - lightweight link test procedure 454 * zfcp_test_link - lightweight link test procedure
427 * @port: port to be tested 455 * @port: port to be tested
@@ -432,17 +460,9 @@ static int zfcp_fc_adisc(struct zfcp_port *port)
432 */ 460 */
433void zfcp_test_link(struct zfcp_port *port) 461void zfcp_test_link(struct zfcp_port *port)
434{ 462{
435 int retval;
436
437 zfcp_port_get(port); 463 zfcp_port_get(port);
438 retval = zfcp_fc_adisc(port); 464 if (!queue_work(zfcp_data.work_queue, &port->test_link_work))
439 if (retval == 0) 465 zfcp_port_put(port);
440 return;
441
442 /* send of ADISC was not possible */
443 zfcp_port_put(port);
444 if (retval != -EBUSY)
445 zfcp_erp_port_forced_reopen(port, 0, 65, NULL);
446} 466}
447 467
448static void zfcp_free_sg_env(struct zfcp_gpn_ft *gpn_ft, int buf_num) 468static void zfcp_free_sg_env(struct zfcp_gpn_ft *gpn_ft, int buf_num)
@@ -529,7 +549,7 @@ static void zfcp_validate_port(struct zfcp_port *port)
529 zfcp_port_put(port); 549 zfcp_port_put(port);
530 return; 550 return;
531 } 551 }
532 zfcp_erp_port_shutdown(port, 0, 151, NULL); 552 zfcp_erp_port_shutdown(port, 0, "fcpval1", NULL);
533 zfcp_erp_wait(adapter); 553 zfcp_erp_wait(adapter);
534 zfcp_port_put(port); 554 zfcp_port_put(port);
535 zfcp_port_dequeue(port); 555 zfcp_port_dequeue(port);
@@ -592,7 +612,7 @@ static int zfcp_scan_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft, int max_entries)
592 if (IS_ERR(port)) 612 if (IS_ERR(port))
593 ret = PTR_ERR(port); 613 ret = PTR_ERR(port);
594 else 614 else
595 zfcp_erp_port_reopen(port, 0, 149, NULL); 615 zfcp_erp_port_reopen(port, 0, "fcegpf1", NULL);
596 } 616 }
597 617
598 zfcp_erp_wait(adapter); 618 zfcp_erp_wait(adapter);
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index e6416f8541b0..b29f3121b666 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Implementation of FSF commands. 4 * Implementation of FSF commands.
5 * 5 *
6 * Copyright IBM Corporation 2002, 2008 6 * Copyright IBM Corporation 2002, 2009
7 */ 7 */
8 8
9#define KMSG_COMPONENT "zfcp" 9#define KMSG_COMPONENT "zfcp"
@@ -12,11 +12,14 @@
12#include <linux/blktrace_api.h> 12#include <linux/blktrace_api.h>
13#include "zfcp_ext.h" 13#include "zfcp_ext.h"
14 14
15#define ZFCP_REQ_AUTO_CLEANUP 0x00000002
16#define ZFCP_REQ_NO_QTCB 0x00000008
17
15static void zfcp_fsf_request_timeout_handler(unsigned long data) 18static void zfcp_fsf_request_timeout_handler(unsigned long data)
16{ 19{
17 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data; 20 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
18 zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, 62, 21 zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED,
19 NULL); 22 "fsrth_1", NULL);
20} 23}
21 24
22static void zfcp_fsf_start_timer(struct zfcp_fsf_req *fsf_req, 25static void zfcp_fsf_start_timer(struct zfcp_fsf_req *fsf_req,
@@ -75,7 +78,7 @@ static void zfcp_fsf_access_denied_port(struct zfcp_fsf_req *req,
75 (unsigned long long)port->wwpn); 78 (unsigned long long)port->wwpn);
76 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]); 79 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]);
77 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]); 80 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]);
78 zfcp_erp_port_access_denied(port, 55, req); 81 zfcp_erp_port_access_denied(port, "fspad_1", req);
79 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 82 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
80} 83}
81 84
@@ -89,7 +92,7 @@ static void zfcp_fsf_access_denied_unit(struct zfcp_fsf_req *req,
89 (unsigned long long)unit->port->wwpn); 92 (unsigned long long)unit->port->wwpn);
90 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]); 93 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]);
91 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]); 94 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]);
92 zfcp_erp_unit_access_denied(unit, 59, req); 95 zfcp_erp_unit_access_denied(unit, "fsuad_1", req);
93 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 96 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
94} 97}
95 98
@@ -97,7 +100,7 @@ static void zfcp_fsf_class_not_supp(struct zfcp_fsf_req *req)
97{ 100{
98 dev_err(&req->adapter->ccw_device->dev, "FCP device not " 101 dev_err(&req->adapter->ccw_device->dev, "FCP device not "
99 "operational because of an unsupported FC class\n"); 102 "operational because of an unsupported FC class\n");
100 zfcp_erp_adapter_shutdown(req->adapter, 0, 123, req); 103 zfcp_erp_adapter_shutdown(req->adapter, 0, "fscns_1", req);
101 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 104 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
102} 105}
103 106
@@ -159,20 +162,13 @@ static void zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *req)
159 list_for_each_entry(port, &adapter->port_list_head, list) 162 list_for_each_entry(port, &adapter->port_list_head, list)
160 if (port->d_id == d_id) { 163 if (port->d_id == d_id) {
161 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 164 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
162 switch (sr_buf->status_subtype) { 165 zfcp_erp_port_reopen(port, 0, "fssrpc1", req);
163 case FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT:
164 zfcp_erp_port_reopen(port, 0, 101, req);
165 break;
166 case FSF_STATUS_READ_SUB_ERROR_PORT:
167 zfcp_erp_port_shutdown(port, 0, 122, req);
168 break;
169 }
170 return; 166 return;
171 } 167 }
172 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 168 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
173} 169}
174 170
175static void zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *req, u8 id, 171static void zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *req, char *id,
176 struct fsf_link_down_info *link_down) 172 struct fsf_link_down_info *link_down)
177{ 173{
178 struct zfcp_adapter *adapter = req->adapter; 174 struct zfcp_adapter *adapter = req->adapter;
@@ -181,6 +177,7 @@ static void zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *req, u8 id,
181 return; 177 return;
182 178
183 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status); 179 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status);
180 zfcp_scsi_schedule_rports_block(adapter);
184 181
185 if (!link_down) 182 if (!link_down)
186 goto out; 183 goto out;
@@ -261,13 +258,13 @@ static void zfcp_fsf_status_read_link_down(struct zfcp_fsf_req *req)
261 258
262 switch (sr_buf->status_subtype) { 259 switch (sr_buf->status_subtype) {
263 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK: 260 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK:
264 zfcp_fsf_link_down_info_eval(req, 38, ldi); 261 zfcp_fsf_link_down_info_eval(req, "fssrld1", ldi);
265 break; 262 break;
266 case FSF_STATUS_READ_SUB_FDISC_FAILED: 263 case FSF_STATUS_READ_SUB_FDISC_FAILED:
267 zfcp_fsf_link_down_info_eval(req, 39, ldi); 264 zfcp_fsf_link_down_info_eval(req, "fssrld2", ldi);
268 break; 265 break;
269 case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE: 266 case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE:
270 zfcp_fsf_link_down_info_eval(req, 40, NULL); 267 zfcp_fsf_link_down_info_eval(req, "fssrld3", NULL);
271 }; 268 };
272} 269}
273 270
@@ -307,22 +304,23 @@ static void zfcp_fsf_status_read_handler(struct zfcp_fsf_req *req)
307 dev_info(&adapter->ccw_device->dev, 304 dev_info(&adapter->ccw_device->dev,
308 "The local link has been restored\n"); 305 "The local link has been restored\n");
309 /* All ports should be marked as ready to run again */ 306 /* All ports should be marked as ready to run again */
310 zfcp_erp_modify_adapter_status(adapter, 30, NULL, 307 zfcp_erp_modify_adapter_status(adapter, "fssrh_1", NULL,
311 ZFCP_STATUS_COMMON_RUNNING, 308 ZFCP_STATUS_COMMON_RUNNING,
312 ZFCP_SET); 309 ZFCP_SET);
313 zfcp_erp_adapter_reopen(adapter, 310 zfcp_erp_adapter_reopen(adapter,
314 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED | 311 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
315 ZFCP_STATUS_COMMON_ERP_FAILED, 312 ZFCP_STATUS_COMMON_ERP_FAILED,
316 102, req); 313 "fssrh_2", req);
317 break; 314 break;
318 case FSF_STATUS_READ_NOTIFICATION_LOST: 315 case FSF_STATUS_READ_NOTIFICATION_LOST:
319 if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_ACT_UPDATED) 316 if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_ACT_UPDATED)
320 zfcp_erp_adapter_access_changed(adapter, 135, req); 317 zfcp_erp_adapter_access_changed(adapter, "fssrh_3",
318 req);
321 if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_INCOMING_ELS) 319 if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_INCOMING_ELS)
322 schedule_work(&adapter->scan_work); 320 schedule_work(&adapter->scan_work);
323 break; 321 break;
324 case FSF_STATUS_READ_CFDC_UPDATED: 322 case FSF_STATUS_READ_CFDC_UPDATED:
325 zfcp_erp_adapter_access_changed(adapter, 136, req); 323 zfcp_erp_adapter_access_changed(adapter, "fssrh_4", req);
326 break; 324 break;
327 case FSF_STATUS_READ_FEATURE_UPDATE_ALERT: 325 case FSF_STATUS_READ_FEATURE_UPDATE_ALERT:
328 adapter->adapter_features = sr_buf->payload.word[0]; 326 adapter->adapter_features = sr_buf->payload.word[0];
@@ -351,7 +349,7 @@ static void zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *req)
351 dev_err(&req->adapter->ccw_device->dev, 349 dev_err(&req->adapter->ccw_device->dev,
352 "The FCP adapter reported a problem " 350 "The FCP adapter reported a problem "
353 "that cannot be recovered\n"); 351 "that cannot be recovered\n");
354 zfcp_erp_adapter_shutdown(req->adapter, 0, 121, req); 352 zfcp_erp_adapter_shutdown(req->adapter, 0, "fsfsqe1", req);
355 break; 353 break;
356 } 354 }
357 /* all non-return stats set FSFREQ_ERROR*/ 355 /* all non-return stats set FSFREQ_ERROR*/
@@ -368,7 +366,7 @@ static void zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *req)
368 dev_err(&req->adapter->ccw_device->dev, 366 dev_err(&req->adapter->ccw_device->dev,
369 "The FCP adapter does not recognize the command 0x%x\n", 367 "The FCP adapter does not recognize the command 0x%x\n",
370 req->qtcb->header.fsf_command); 368 req->qtcb->header.fsf_command);
371 zfcp_erp_adapter_shutdown(req->adapter, 0, 120, req); 369 zfcp_erp_adapter_shutdown(req->adapter, 0, "fsfse_1", req);
372 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 370 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
373 break; 371 break;
374 case FSF_ADAPTER_STATUS_AVAILABLE: 372 case FSF_ADAPTER_STATUS_AVAILABLE:
@@ -400,17 +398,17 @@ static void zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *req)
400 "QTCB version 0x%x not supported by FCP adapter " 398 "QTCB version 0x%x not supported by FCP adapter "
401 "(0x%x to 0x%x)\n", FSF_QTCB_CURRENT_VERSION, 399 "(0x%x to 0x%x)\n", FSF_QTCB_CURRENT_VERSION,
402 psq->word[0], psq->word[1]); 400 psq->word[0], psq->word[1]);
403 zfcp_erp_adapter_shutdown(adapter, 0, 117, req); 401 zfcp_erp_adapter_shutdown(adapter, 0, "fspse_1", req);
404 break; 402 break;
405 case FSF_PROT_ERROR_STATE: 403 case FSF_PROT_ERROR_STATE:
406 case FSF_PROT_SEQ_NUMB_ERROR: 404 case FSF_PROT_SEQ_NUMB_ERROR:
407 zfcp_erp_adapter_reopen(adapter, 0, 98, req); 405 zfcp_erp_adapter_reopen(adapter, 0, "fspse_2", req);
408 req->status |= ZFCP_STATUS_FSFREQ_RETRY; 406 req->status |= ZFCP_STATUS_FSFREQ_RETRY;
409 break; 407 break;
410 case FSF_PROT_UNSUPP_QTCB_TYPE: 408 case FSF_PROT_UNSUPP_QTCB_TYPE:
411 dev_err(&adapter->ccw_device->dev, 409 dev_err(&adapter->ccw_device->dev,
412 "The QTCB type is not supported by the FCP adapter\n"); 410 "The QTCB type is not supported by the FCP adapter\n");
413 zfcp_erp_adapter_shutdown(adapter, 0, 118, req); 411 zfcp_erp_adapter_shutdown(adapter, 0, "fspse_3", req);
414 break; 412 break;
415 case FSF_PROT_HOST_CONNECTION_INITIALIZING: 413 case FSF_PROT_HOST_CONNECTION_INITIALIZING:
416 atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT, 414 atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
@@ -420,27 +418,29 @@ static void zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *req)
420 dev_err(&adapter->ccw_device->dev, 418 dev_err(&adapter->ccw_device->dev,
421 "0x%Lx is an ambiguous request identifier\n", 419 "0x%Lx is an ambiguous request identifier\n",
422 (unsigned long long)qtcb->bottom.support.req_handle); 420 (unsigned long long)qtcb->bottom.support.req_handle);
423 zfcp_erp_adapter_shutdown(adapter, 0, 78, req); 421 zfcp_erp_adapter_shutdown(adapter, 0, "fspse_4", req);
424 break; 422 break;
425 case FSF_PROT_LINK_DOWN: 423 case FSF_PROT_LINK_DOWN:
426 zfcp_fsf_link_down_info_eval(req, 37, &psq->link_down_info); 424 zfcp_fsf_link_down_info_eval(req, "fspse_5",
425 &psq->link_down_info);
427 /* FIXME: reopening adapter now? better wait for link up */ 426 /* FIXME: reopening adapter now? better wait for link up */
428 zfcp_erp_adapter_reopen(adapter, 0, 79, req); 427 zfcp_erp_adapter_reopen(adapter, 0, "fspse_6", req);
429 break; 428 break;
430 case FSF_PROT_REEST_QUEUE: 429 case FSF_PROT_REEST_QUEUE:
431 /* All ports should be marked as ready to run again */ 430 /* All ports should be marked as ready to run again */
432 zfcp_erp_modify_adapter_status(adapter, 28, NULL, 431 zfcp_erp_modify_adapter_status(adapter, "fspse_7", NULL,
433 ZFCP_STATUS_COMMON_RUNNING, 432 ZFCP_STATUS_COMMON_RUNNING,
434 ZFCP_SET); 433 ZFCP_SET);
435 zfcp_erp_adapter_reopen(adapter, 434 zfcp_erp_adapter_reopen(adapter,
436 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED | 435 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
437 ZFCP_STATUS_COMMON_ERP_FAILED, 99, req); 436 ZFCP_STATUS_COMMON_ERP_FAILED,
437 "fspse_8", req);
438 break; 438 break;
439 default: 439 default:
440 dev_err(&adapter->ccw_device->dev, 440 dev_err(&adapter->ccw_device->dev,
441 "0x%x is not a valid transfer protocol status\n", 441 "0x%x is not a valid transfer protocol status\n",
442 qtcb->prefix.prot_status); 442 qtcb->prefix.prot_status);
443 zfcp_erp_adapter_shutdown(adapter, 0, 119, req); 443 zfcp_erp_adapter_shutdown(adapter, 0, "fspse_9", req);
444 } 444 }
445 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 445 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
446} 446}
@@ -526,7 +526,7 @@ static int zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *req)
526 dev_err(&adapter->ccw_device->dev, 526 dev_err(&adapter->ccw_device->dev,
527 "Unknown or unsupported arbitrated loop " 527 "Unknown or unsupported arbitrated loop "
528 "fibre channel topology detected\n"); 528 "fibre channel topology detected\n");
529 zfcp_erp_adapter_shutdown(adapter, 0, 127, req); 529 zfcp_erp_adapter_shutdown(adapter, 0, "fsece_1", req);
530 return -EIO; 530 return -EIO;
531 } 531 }
532 532
@@ -560,7 +560,7 @@ static void zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *req)
560 "FCP adapter maximum QTCB size (%d bytes) " 560 "FCP adapter maximum QTCB size (%d bytes) "
561 "is too small\n", 561 "is too small\n",
562 bottom->max_qtcb_size); 562 bottom->max_qtcb_size);
563 zfcp_erp_adapter_shutdown(adapter, 0, 129, req); 563 zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh1", req);
564 return; 564 return;
565 } 565 }
566 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, 566 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
@@ -577,11 +577,11 @@ static void zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *req)
577 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, 577 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
578 &adapter->status); 578 &adapter->status);
579 579
580 zfcp_fsf_link_down_info_eval(req, 42, 580 zfcp_fsf_link_down_info_eval(req, "fsecdh2",
581 &qtcb->header.fsf_status_qual.link_down_info); 581 &qtcb->header.fsf_status_qual.link_down_info);
582 break; 582 break;
583 default: 583 default:
584 zfcp_erp_adapter_shutdown(adapter, 0, 130, req); 584 zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh3", req);
585 return; 585 return;
586 } 586 }
587 587
@@ -597,14 +597,14 @@ static void zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *req)
597 dev_err(&adapter->ccw_device->dev, 597 dev_err(&adapter->ccw_device->dev,
598 "The FCP adapter only supports newer " 598 "The FCP adapter only supports newer "
599 "control block versions\n"); 599 "control block versions\n");
600 zfcp_erp_adapter_shutdown(adapter, 0, 125, req); 600 zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh4", req);
601 return; 601 return;
602 } 602 }
603 if (FSF_QTCB_CURRENT_VERSION > bottom->high_qtcb_version) { 603 if (FSF_QTCB_CURRENT_VERSION > bottom->high_qtcb_version) {
604 dev_err(&adapter->ccw_device->dev, 604 dev_err(&adapter->ccw_device->dev,
605 "The FCP adapter only supports older " 605 "The FCP adapter only supports older "
606 "control block versions\n"); 606 "control block versions\n");
607 zfcp_erp_adapter_shutdown(adapter, 0, 126, req); 607 zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh5", req);
608 } 608 }
609} 609}
610 610
@@ -617,9 +617,10 @@ static void zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *req)
617 if (req->data) 617 if (req->data)
618 memcpy(req->data, bottom, sizeof(*bottom)); 618 memcpy(req->data, bottom, sizeof(*bottom));
619 619
620 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) 620 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) {
621 fc_host_permanent_port_name(shost) = bottom->wwpn; 621 fc_host_permanent_port_name(shost) = bottom->wwpn;
622 else 622 fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
623 } else
623 fc_host_permanent_port_name(shost) = fc_host_port_name(shost); 624 fc_host_permanent_port_name(shost) = fc_host_port_name(shost);
624 fc_host_maxframe_size(shost) = bottom->maximum_frame_size; 625 fc_host_maxframe_size(shost) = bottom->maximum_frame_size;
625 fc_host_supported_speeds(shost) = bottom->supported_speed; 626 fc_host_supported_speeds(shost) = bottom->supported_speed;
@@ -638,20 +639,12 @@ static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req)
638 break; 639 break;
639 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE: 640 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
640 zfcp_fsf_exchange_port_evaluate(req); 641 zfcp_fsf_exchange_port_evaluate(req);
641 zfcp_fsf_link_down_info_eval(req, 43, 642 zfcp_fsf_link_down_info_eval(req, "fsepdh1",
642 &qtcb->header.fsf_status_qual.link_down_info); 643 &qtcb->header.fsf_status_qual.link_down_info);
643 break; 644 break;
644 } 645 }
645} 646}
646 647
647static int zfcp_fsf_sbal_available(struct zfcp_adapter *adapter)
648{
649 if (atomic_read(&adapter->req_q.count) > 0)
650 return 1;
651 atomic_inc(&adapter->qdio_outb_full);
652 return 0;
653}
654
655static int zfcp_fsf_req_sbal_get(struct zfcp_adapter *adapter) 648static int zfcp_fsf_req_sbal_get(struct zfcp_adapter *adapter)
656 __releases(&adapter->req_q_lock) 649 __releases(&adapter->req_q_lock)
657 __acquires(&adapter->req_q_lock) 650 __acquires(&adapter->req_q_lock)
@@ -735,7 +728,7 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_adapter *adapter,
735 728
736 req->adapter = adapter; 729 req->adapter = adapter;
737 req->fsf_command = fsf_cmd; 730 req->fsf_command = fsf_cmd;
738 req->req_id = adapter->req_no++; 731 req->req_id = adapter->req_no;
739 req->sbal_number = 1; 732 req->sbal_number = 1;
740 req->sbal_first = req_q->first; 733 req->sbal_first = req_q->first;
741 req->sbal_last = req_q->first; 734 req->sbal_last = req_q->first;
@@ -791,13 +784,14 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
791 if (zfcp_reqlist_find_safe(adapter, req)) 784 if (zfcp_reqlist_find_safe(adapter, req))
792 zfcp_reqlist_remove(adapter, req); 785 zfcp_reqlist_remove(adapter, req);
793 spin_unlock_irqrestore(&adapter->req_list_lock, flags); 786 spin_unlock_irqrestore(&adapter->req_list_lock, flags);
794 zfcp_erp_adapter_reopen(adapter, 0, 116, req); 787 zfcp_erp_adapter_reopen(adapter, 0, "fsrs__1", req);
795 return -EIO; 788 return -EIO;
796 } 789 }
797 790
798 /* Don't increase for unsolicited status */ 791 /* Don't increase for unsolicited status */
799 if (req->qtcb) 792 if (req->qtcb)
800 adapter->fsf_req_seq_no++; 793 adapter->fsf_req_seq_no++;
794 adapter->req_no++;
801 795
802 return 0; 796 return 0;
803} 797}
@@ -870,14 +864,14 @@ static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
870 switch (req->qtcb->header.fsf_status) { 864 switch (req->qtcb->header.fsf_status) {
871 case FSF_PORT_HANDLE_NOT_VALID: 865 case FSF_PORT_HANDLE_NOT_VALID:
872 if (fsq->word[0] == fsq->word[1]) { 866 if (fsq->word[0] == fsq->word[1]) {
873 zfcp_erp_adapter_reopen(unit->port->adapter, 0, 104, 867 zfcp_erp_adapter_reopen(unit->port->adapter, 0,
874 req); 868 "fsafch1", req);
875 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 869 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
876 } 870 }
877 break; 871 break;
878 case FSF_LUN_HANDLE_NOT_VALID: 872 case FSF_LUN_HANDLE_NOT_VALID:
879 if (fsq->word[0] == fsq->word[1]) { 873 if (fsq->word[0] == fsq->word[1]) {
880 zfcp_erp_port_reopen(unit->port, 0, 105, req); 874 zfcp_erp_port_reopen(unit->port, 0, "fsafch2", req);
881 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 875 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
882 } 876 }
883 break; 877 break;
@@ -885,12 +879,12 @@ static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
885 req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED; 879 req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED;
886 break; 880 break;
887 case FSF_PORT_BOXED: 881 case FSF_PORT_BOXED:
888 zfcp_erp_port_boxed(unit->port, 47, req); 882 zfcp_erp_port_boxed(unit->port, "fsafch3", req);
889 req->status |= ZFCP_STATUS_FSFREQ_ERROR | 883 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
890 ZFCP_STATUS_FSFREQ_RETRY; 884 ZFCP_STATUS_FSFREQ_RETRY;
891 break; 885 break;
892 case FSF_LUN_BOXED: 886 case FSF_LUN_BOXED:
893 zfcp_erp_unit_boxed(unit, 48, req); 887 zfcp_erp_unit_boxed(unit, "fsafch4", req);
894 req->status |= ZFCP_STATUS_FSFREQ_ERROR | 888 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
895 ZFCP_STATUS_FSFREQ_RETRY; 889 ZFCP_STATUS_FSFREQ_RETRY;
896 break; 890 break;
@@ -912,27 +906,22 @@ static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
912/** 906/**
913 * zfcp_fsf_abort_fcp_command - abort running SCSI command 907 * zfcp_fsf_abort_fcp_command - abort running SCSI command
914 * @old_req_id: unsigned long 908 * @old_req_id: unsigned long
915 * @adapter: pointer to struct zfcp_adapter
916 * @unit: pointer to struct zfcp_unit 909 * @unit: pointer to struct zfcp_unit
917 * @req_flags: integer specifying the request flags
918 * Returns: pointer to struct zfcp_fsf_req 910 * Returns: pointer to struct zfcp_fsf_req
919 *
920 * FIXME(design): should be watched by a timeout !!!
921 */ 911 */
922 912
923struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id, 913struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
924 struct zfcp_adapter *adapter, 914 struct zfcp_unit *unit)
925 struct zfcp_unit *unit,
926 int req_flags)
927{ 915{
928 struct qdio_buffer_element *sbale; 916 struct qdio_buffer_element *sbale;
929 struct zfcp_fsf_req *req = NULL; 917 struct zfcp_fsf_req *req = NULL;
918 struct zfcp_adapter *adapter = unit->port->adapter;
930 919
931 spin_lock(&adapter->req_q_lock); 920 spin_lock_bh(&adapter->req_q_lock);
932 if (!zfcp_fsf_sbal_available(adapter)) 921 if (zfcp_fsf_req_sbal_get(adapter))
933 goto out; 922 goto out;
934 req = zfcp_fsf_req_create(adapter, FSF_QTCB_ABORT_FCP_CMND, 923 req = zfcp_fsf_req_create(adapter, FSF_QTCB_ABORT_FCP_CMND,
935 req_flags, adapter->pool.fsf_req_abort); 924 0, adapter->pool.fsf_req_abort);
936 if (IS_ERR(req)) { 925 if (IS_ERR(req)) {
937 req = NULL; 926 req = NULL;
938 goto out; 927 goto out;
@@ -960,7 +949,7 @@ out_error_free:
960 zfcp_fsf_req_free(req); 949 zfcp_fsf_req_free(req);
961 req = NULL; 950 req = NULL;
962out: 951out:
963 spin_unlock(&adapter->req_q_lock); 952 spin_unlock_bh(&adapter->req_q_lock);
964 return req; 953 return req;
965} 954}
966 955
@@ -998,7 +987,7 @@ static void zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *req)
998 ZFCP_STATUS_FSFREQ_RETRY; 987 ZFCP_STATUS_FSFREQ_RETRY;
999 break; 988 break;
1000 case FSF_PORT_HANDLE_NOT_VALID: 989 case FSF_PORT_HANDLE_NOT_VALID:
1001 zfcp_erp_adapter_reopen(adapter, 0, 106, req); 990 zfcp_erp_adapter_reopen(adapter, 0, "fsscth1", req);
1002 case FSF_GENERIC_COMMAND_REJECTED: 991 case FSF_GENERIC_COMMAND_REJECTED:
1003 case FSF_PAYLOAD_SIZE_MISMATCH: 992 case FSF_PAYLOAD_SIZE_MISMATCH:
1004 case FSF_REQUEST_SIZE_TOO_LARGE: 993 case FSF_REQUEST_SIZE_TOO_LARGE:
@@ -1174,12 +1163,8 @@ int zfcp_fsf_send_els(struct zfcp_send_els *els)
1174 struct fsf_qtcb_bottom_support *bottom; 1163 struct fsf_qtcb_bottom_support *bottom;
1175 int ret = -EIO; 1164 int ret = -EIO;
1176 1165
1177 if (unlikely(!(atomic_read(&els->port->status) & 1166 spin_lock_bh(&adapter->req_q_lock);
1178 ZFCP_STATUS_COMMON_UNBLOCKED))) 1167 if (zfcp_fsf_req_sbal_get(adapter))
1179 return -EBUSY;
1180
1181 spin_lock(&adapter->req_q_lock);
1182 if (!zfcp_fsf_sbal_available(adapter))
1183 goto out; 1168 goto out;
1184 req = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_ELS, 1169 req = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_ELS,
1185 ZFCP_REQ_AUTO_CLEANUP, NULL); 1170 ZFCP_REQ_AUTO_CLEANUP, NULL);
@@ -1212,7 +1197,7 @@ int zfcp_fsf_send_els(struct zfcp_send_els *els)
1212failed_send: 1197failed_send:
1213 zfcp_fsf_req_free(req); 1198 zfcp_fsf_req_free(req);
1214out: 1199out:
1215 spin_unlock(&adapter->req_q_lock); 1200 spin_unlock_bh(&adapter->req_q_lock);
1216 return ret; 1201 return ret;
1217} 1202}
1218 1203
@@ -1224,7 +1209,7 @@ int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1224 int retval = -EIO; 1209 int retval = -EIO;
1225 1210
1226 spin_lock_bh(&adapter->req_q_lock); 1211 spin_lock_bh(&adapter->req_q_lock);
1227 if (!zfcp_fsf_sbal_available(adapter)) 1212 if (zfcp_fsf_req_sbal_get(adapter))
1228 goto out; 1213 goto out;
1229 req = zfcp_fsf_req_create(adapter, 1214 req = zfcp_fsf_req_create(adapter,
1230 FSF_QTCB_EXCHANGE_CONFIG_DATA, 1215 FSF_QTCB_EXCHANGE_CONFIG_DATA,
@@ -1320,7 +1305,7 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
1320 return -EOPNOTSUPP; 1305 return -EOPNOTSUPP;
1321 1306
1322 spin_lock_bh(&adapter->req_q_lock); 1307 spin_lock_bh(&adapter->req_q_lock);
1323 if (!zfcp_fsf_sbal_available(adapter)) 1308 if (zfcp_fsf_req_sbal_get(adapter))
1324 goto out; 1309 goto out;
1325 req = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA, 1310 req = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA,
1326 ZFCP_REQ_AUTO_CLEANUP, 1311 ZFCP_REQ_AUTO_CLEANUP,
@@ -1366,7 +1351,7 @@ int zfcp_fsf_exchange_port_data_sync(struct zfcp_adapter *adapter,
1366 return -EOPNOTSUPP; 1351 return -EOPNOTSUPP;
1367 1352
1368 spin_lock_bh(&adapter->req_q_lock); 1353 spin_lock_bh(&adapter->req_q_lock);
1369 if (!zfcp_fsf_sbal_available(adapter)) 1354 if (zfcp_fsf_req_sbal_get(adapter))
1370 goto out; 1355 goto out;
1371 1356
1372 req = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA, 0, 1357 req = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA, 0,
@@ -1416,7 +1401,7 @@ static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req)
1416 "Not enough FCP adapter resources to open " 1401 "Not enough FCP adapter resources to open "
1417 "remote port 0x%016Lx\n", 1402 "remote port 0x%016Lx\n",
1418 (unsigned long long)port->wwpn); 1403 (unsigned long long)port->wwpn);
1419 zfcp_erp_port_failed(port, 31, req); 1404 zfcp_erp_port_failed(port, "fsoph_1", req);
1420 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1405 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1421 break; 1406 break;
1422 case FSF_ADAPTER_STATUS_AVAILABLE: 1407 case FSF_ADAPTER_STATUS_AVAILABLE:
@@ -1522,13 +1507,13 @@ static void zfcp_fsf_close_port_handler(struct zfcp_fsf_req *req)
1522 1507
1523 switch (req->qtcb->header.fsf_status) { 1508 switch (req->qtcb->header.fsf_status) {
1524 case FSF_PORT_HANDLE_NOT_VALID: 1509 case FSF_PORT_HANDLE_NOT_VALID:
1525 zfcp_erp_adapter_reopen(port->adapter, 0, 107, req); 1510 zfcp_erp_adapter_reopen(port->adapter, 0, "fscph_1", req);
1526 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1511 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1527 break; 1512 break;
1528 case FSF_ADAPTER_STATUS_AVAILABLE: 1513 case FSF_ADAPTER_STATUS_AVAILABLE:
1529 break; 1514 break;
1530 case FSF_GOOD: 1515 case FSF_GOOD:
1531 zfcp_erp_modify_port_status(port, 33, req, 1516 zfcp_erp_modify_port_status(port, "fscph_2", req,
1532 ZFCP_STATUS_COMMON_OPEN, 1517 ZFCP_STATUS_COMMON_OPEN,
1533 ZFCP_CLEAR); 1518 ZFCP_CLEAR);
1534 break; 1519 break;
@@ -1657,7 +1642,7 @@ static void zfcp_fsf_close_wka_port_handler(struct zfcp_fsf_req *req)
1657 1642
1658 if (req->qtcb->header.fsf_status == FSF_PORT_HANDLE_NOT_VALID) { 1643 if (req->qtcb->header.fsf_status == FSF_PORT_HANDLE_NOT_VALID) {
1659 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1644 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1660 zfcp_erp_adapter_reopen(wka_port->adapter, 0, 84, req); 1645 zfcp_erp_adapter_reopen(wka_port->adapter, 0, "fscwph1", req);
1661 } 1646 }
1662 1647
1663 wka_port->status = ZFCP_WKA_PORT_OFFLINE; 1648 wka_port->status = ZFCP_WKA_PORT_OFFLINE;
@@ -1712,18 +1697,18 @@ static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req)
1712 struct zfcp_unit *unit; 1697 struct zfcp_unit *unit;
1713 1698
1714 if (req->status & ZFCP_STATUS_FSFREQ_ERROR) 1699 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1715 goto skip_fsfstatus; 1700 return;
1716 1701
1717 switch (header->fsf_status) { 1702 switch (header->fsf_status) {
1718 case FSF_PORT_HANDLE_NOT_VALID: 1703 case FSF_PORT_HANDLE_NOT_VALID:
1719 zfcp_erp_adapter_reopen(port->adapter, 0, 108, req); 1704 zfcp_erp_adapter_reopen(port->adapter, 0, "fscpph1", req);
1720 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1705 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1721 break; 1706 break;
1722 case FSF_ACCESS_DENIED: 1707 case FSF_ACCESS_DENIED:
1723 zfcp_fsf_access_denied_port(req, port); 1708 zfcp_fsf_access_denied_port(req, port);
1724 break; 1709 break;
1725 case FSF_PORT_BOXED: 1710 case FSF_PORT_BOXED:
1726 zfcp_erp_port_boxed(port, 50, req); 1711 zfcp_erp_port_boxed(port, "fscpph2", req);
1727 req->status |= ZFCP_STATUS_FSFREQ_ERROR | 1712 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
1728 ZFCP_STATUS_FSFREQ_RETRY; 1713 ZFCP_STATUS_FSFREQ_RETRY;
1729 /* can't use generic zfcp_erp_modify_port_status because 1714 /* can't use generic zfcp_erp_modify_port_status because
@@ -1752,8 +1737,6 @@ static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req)
1752 &unit->status); 1737 &unit->status);
1753 break; 1738 break;
1754 } 1739 }
1755skip_fsfstatus:
1756 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_CLOSING, &port->status);
1757} 1740}
1758 1741
1759/** 1742/**
@@ -1789,8 +1772,6 @@ int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
1789 req->erp_action = erp_action; 1772 req->erp_action = erp_action;
1790 req->handler = zfcp_fsf_close_physical_port_handler; 1773 req->handler = zfcp_fsf_close_physical_port_handler;
1791 erp_action->fsf_req = req; 1774 erp_action->fsf_req = req;
1792 atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING,
1793 &erp_action->port->status);
1794 1775
1795 zfcp_fsf_start_erp_timer(req); 1776 zfcp_fsf_start_erp_timer(req);
1796 retval = zfcp_fsf_req_send(req); 1777 retval = zfcp_fsf_req_send(req);
@@ -1825,7 +1806,7 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1825 switch (header->fsf_status) { 1806 switch (header->fsf_status) {
1826 1807
1827 case FSF_PORT_HANDLE_NOT_VALID: 1808 case FSF_PORT_HANDLE_NOT_VALID:
1828 zfcp_erp_adapter_reopen(unit->port->adapter, 0, 109, req); 1809 zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fsouh_1", req);
1829 /* fall through */ 1810 /* fall through */
1830 case FSF_LUN_ALREADY_OPEN: 1811 case FSF_LUN_ALREADY_OPEN:
1831 break; 1812 break;
@@ -1835,7 +1816,7 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1835 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status); 1816 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);
1836 break; 1817 break;
1837 case FSF_PORT_BOXED: 1818 case FSF_PORT_BOXED:
1838 zfcp_erp_port_boxed(unit->port, 51, req); 1819 zfcp_erp_port_boxed(unit->port, "fsouh_2", req);
1839 req->status |= ZFCP_STATUS_FSFREQ_ERROR | 1820 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
1840 ZFCP_STATUS_FSFREQ_RETRY; 1821 ZFCP_STATUS_FSFREQ_RETRY;
1841 break; 1822 break;
@@ -1851,7 +1832,7 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1851 else 1832 else
1852 zfcp_act_eval_err(adapter, 1833 zfcp_act_eval_err(adapter,
1853 header->fsf_status_qual.word[2]); 1834 header->fsf_status_qual.word[2]);
1854 zfcp_erp_unit_access_denied(unit, 60, req); 1835 zfcp_erp_unit_access_denied(unit, "fsouh_3", req);
1855 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status); 1836 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status);
1856 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status); 1837 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);
1857 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1838 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
@@ -1862,7 +1843,7 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1862 "0x%016Lx on port 0x%016Lx\n", 1843 "0x%016Lx on port 0x%016Lx\n",
1863 (unsigned long long)unit->fcp_lun, 1844 (unsigned long long)unit->fcp_lun,
1864 (unsigned long long)unit->port->wwpn); 1845 (unsigned long long)unit->port->wwpn);
1865 zfcp_erp_unit_failed(unit, 34, req); 1846 zfcp_erp_unit_failed(unit, "fsouh_4", req);
1866 /* fall through */ 1847 /* fall through */
1867 case FSF_INVALID_COMMAND_OPTION: 1848 case FSF_INVALID_COMMAND_OPTION:
1868 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1849 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
@@ -1911,9 +1892,9 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1911 "port 0x%016Lx)\n", 1892 "port 0x%016Lx)\n",
1912 (unsigned long long)unit->fcp_lun, 1893 (unsigned long long)unit->fcp_lun,
1913 (unsigned long long)unit->port->wwpn); 1894 (unsigned long long)unit->port->wwpn);
1914 zfcp_erp_unit_failed(unit, 35, req); 1895 zfcp_erp_unit_failed(unit, "fsouh_5", req);
1915 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1896 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1916 zfcp_erp_unit_shutdown(unit, 0, 80, req); 1897 zfcp_erp_unit_shutdown(unit, 0, "fsouh_6", req);
1917 } else if (!exclusive && readwrite) { 1898 } else if (!exclusive && readwrite) {
1918 dev_err(&adapter->ccw_device->dev, 1899 dev_err(&adapter->ccw_device->dev,
1919 "Shared read-write access not " 1900 "Shared read-write access not "
@@ -1921,9 +1902,9 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1921 "0x%016Lx)\n", 1902 "0x%016Lx)\n",
1922 (unsigned long long)unit->fcp_lun, 1903 (unsigned long long)unit->fcp_lun,
1923 (unsigned long long)unit->port->wwpn); 1904 (unsigned long long)unit->port->wwpn);
1924 zfcp_erp_unit_failed(unit, 36, req); 1905 zfcp_erp_unit_failed(unit, "fsouh_7", req);
1925 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1906 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1926 zfcp_erp_unit_shutdown(unit, 0, 81, req); 1907 zfcp_erp_unit_shutdown(unit, 0, "fsouh_8", req);
1927 } 1908 }
1928 } 1909 }
1929 break; 1910 break;
@@ -1988,15 +1969,15 @@ static void zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *req)
1988 1969
1989 switch (req->qtcb->header.fsf_status) { 1970 switch (req->qtcb->header.fsf_status) {
1990 case FSF_PORT_HANDLE_NOT_VALID: 1971 case FSF_PORT_HANDLE_NOT_VALID:
1991 zfcp_erp_adapter_reopen(unit->port->adapter, 0, 110, req); 1972 zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fscuh_1", req);
1992 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1973 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1993 break; 1974 break;
1994 case FSF_LUN_HANDLE_NOT_VALID: 1975 case FSF_LUN_HANDLE_NOT_VALID:
1995 zfcp_erp_port_reopen(unit->port, 0, 111, req); 1976 zfcp_erp_port_reopen(unit->port, 0, "fscuh_2", req);
1996 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1977 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1997 break; 1978 break;
1998 case FSF_PORT_BOXED: 1979 case FSF_PORT_BOXED:
1999 zfcp_erp_port_boxed(unit->port, 52, req); 1980 zfcp_erp_port_boxed(unit->port, "fscuh_3", req);
2000 req->status |= ZFCP_STATUS_FSFREQ_ERROR | 1981 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
2001 ZFCP_STATUS_FSFREQ_RETRY; 1982 ZFCP_STATUS_FSFREQ_RETRY;
2002 break; 1983 break;
@@ -2073,7 +2054,6 @@ static void zfcp_fsf_req_latency(struct zfcp_fsf_req *req)
2073 struct fsf_qual_latency_info *lat_inf; 2054 struct fsf_qual_latency_info *lat_inf;
2074 struct latency_cont *lat; 2055 struct latency_cont *lat;
2075 struct zfcp_unit *unit = req->unit; 2056 struct zfcp_unit *unit = req->unit;
2076 unsigned long flags;
2077 2057
2078 lat_inf = &req->qtcb->prefix.prot_status_qual.latency_info; 2058 lat_inf = &req->qtcb->prefix.prot_status_qual.latency_info;
2079 2059
@@ -2091,11 +2071,11 @@ static void zfcp_fsf_req_latency(struct zfcp_fsf_req *req)
2091 return; 2071 return;
2092 } 2072 }
2093 2073
2094 spin_lock_irqsave(&unit->latencies.lock, flags); 2074 spin_lock(&unit->latencies.lock);
2095 zfcp_fsf_update_lat(&lat->channel, lat_inf->channel_lat); 2075 zfcp_fsf_update_lat(&lat->channel, lat_inf->channel_lat);
2096 zfcp_fsf_update_lat(&lat->fabric, lat_inf->fabric_lat); 2076 zfcp_fsf_update_lat(&lat->fabric, lat_inf->fabric_lat);
2097 lat->counter++; 2077 lat->counter++;
2098 spin_unlock_irqrestore(&unit->latencies.lock, flags); 2078 spin_unlock(&unit->latencies.lock);
2099} 2079}
2100 2080
2101#ifdef CONFIG_BLK_DEV_IO_TRACE 2081#ifdef CONFIG_BLK_DEV_IO_TRACE
@@ -2147,7 +2127,6 @@ static void zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *req)
2147 2127
2148 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ABORTED)) { 2128 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ABORTED)) {
2149 set_host_byte(scpnt, DID_SOFT_ERROR); 2129 set_host_byte(scpnt, DID_SOFT_ERROR);
2150 set_driver_byte(scpnt, SUGGEST_RETRY);
2151 goto skip_fsfstatus; 2130 goto skip_fsfstatus;
2152 } 2131 }
2153 2132
@@ -2237,12 +2216,12 @@ static void zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *req)
2237 switch (header->fsf_status) { 2216 switch (header->fsf_status) {
2238 case FSF_HANDLE_MISMATCH: 2217 case FSF_HANDLE_MISMATCH:
2239 case FSF_PORT_HANDLE_NOT_VALID: 2218 case FSF_PORT_HANDLE_NOT_VALID:
2240 zfcp_erp_adapter_reopen(unit->port->adapter, 0, 112, req); 2219 zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fssfch1", req);
2241 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 2220 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2242 break; 2221 break;
2243 case FSF_FCPLUN_NOT_VALID: 2222 case FSF_FCPLUN_NOT_VALID:
2244 case FSF_LUN_HANDLE_NOT_VALID: 2223 case FSF_LUN_HANDLE_NOT_VALID:
2245 zfcp_erp_port_reopen(unit->port, 0, 113, req); 2224 zfcp_erp_port_reopen(unit->port, 0, "fssfch2", req);
2246 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 2225 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2247 break; 2226 break;
2248 case FSF_SERVICE_CLASS_NOT_SUPPORTED: 2227 case FSF_SERVICE_CLASS_NOT_SUPPORTED:
@@ -2258,7 +2237,8 @@ static void zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *req)
2258 req->qtcb->bottom.io.data_direction, 2237 req->qtcb->bottom.io.data_direction,
2259 (unsigned long long)unit->fcp_lun, 2238 (unsigned long long)unit->fcp_lun,
2260 (unsigned long long)unit->port->wwpn); 2239 (unsigned long long)unit->port->wwpn);
2261 zfcp_erp_adapter_shutdown(unit->port->adapter, 0, 133, req); 2240 zfcp_erp_adapter_shutdown(unit->port->adapter, 0, "fssfch3",
2241 req);
2262 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 2242 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2263 break; 2243 break;
2264 case FSF_CMND_LENGTH_NOT_VALID: 2244 case FSF_CMND_LENGTH_NOT_VALID:
@@ -2268,16 +2248,17 @@ static void zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *req)
2268 req->qtcb->bottom.io.fcp_cmnd_length, 2248 req->qtcb->bottom.io.fcp_cmnd_length,
2269 (unsigned long long)unit->fcp_lun, 2249 (unsigned long long)unit->fcp_lun,
2270 (unsigned long long)unit->port->wwpn); 2250 (unsigned long long)unit->port->wwpn);
2271 zfcp_erp_adapter_shutdown(unit->port->adapter, 0, 134, req); 2251 zfcp_erp_adapter_shutdown(unit->port->adapter, 0, "fssfch4",
2252 req);
2272 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 2253 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2273 break; 2254 break;
2274 case FSF_PORT_BOXED: 2255 case FSF_PORT_BOXED:
2275 zfcp_erp_port_boxed(unit->port, 53, req); 2256 zfcp_erp_port_boxed(unit->port, "fssfch5", req);
2276 req->status |= ZFCP_STATUS_FSFREQ_ERROR | 2257 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
2277 ZFCP_STATUS_FSFREQ_RETRY; 2258 ZFCP_STATUS_FSFREQ_RETRY;
2278 break; 2259 break;
2279 case FSF_LUN_BOXED: 2260 case FSF_LUN_BOXED:
2280 zfcp_erp_unit_boxed(unit, 54, req); 2261 zfcp_erp_unit_boxed(unit, "fssfch6", req);
2281 req->status |= ZFCP_STATUS_FSFREQ_ERROR | 2262 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
2282 ZFCP_STATUS_FSFREQ_RETRY; 2263 ZFCP_STATUS_FSFREQ_RETRY;
2283 break; 2264 break;
@@ -2314,30 +2295,29 @@ static void zfcp_set_fcp_dl(struct fcp_cmnd_iu *fcp_cmd, u32 fcp_dl)
2314 2295
2315/** 2296/**
2316 * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command) 2297 * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command)
2317 * @adapter: adapter where scsi command is issued
2318 * @unit: unit where command is sent to 2298 * @unit: unit where command is sent to
2319 * @scsi_cmnd: scsi command to be sent 2299 * @scsi_cmnd: scsi command to be sent
2320 * @timer: timer to be started when request is initiated
2321 * @req_flags: flags for fsf_request
2322 */ 2300 */
2323int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter, 2301int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
2324 struct zfcp_unit *unit, 2302 struct scsi_cmnd *scsi_cmnd)
2325 struct scsi_cmnd *scsi_cmnd,
2326 int use_timer, int req_flags)
2327{ 2303{
2328 struct zfcp_fsf_req *req; 2304 struct zfcp_fsf_req *req;
2329 struct fcp_cmnd_iu *fcp_cmnd_iu; 2305 struct fcp_cmnd_iu *fcp_cmnd_iu;
2330 unsigned int sbtype; 2306 unsigned int sbtype;
2331 int real_bytes, retval = -EIO; 2307 int real_bytes, retval = -EIO;
2308 struct zfcp_adapter *adapter = unit->port->adapter;
2332 2309
2333 if (unlikely(!(atomic_read(&unit->status) & 2310 if (unlikely(!(atomic_read(&unit->status) &
2334 ZFCP_STATUS_COMMON_UNBLOCKED))) 2311 ZFCP_STATUS_COMMON_UNBLOCKED)))
2335 return -EBUSY; 2312 return -EBUSY;
2336 2313
2337 spin_lock(&adapter->req_q_lock); 2314 spin_lock(&adapter->req_q_lock);
2338 if (!zfcp_fsf_sbal_available(adapter)) 2315 if (atomic_read(&adapter->req_q.count) <= 0) {
2316 atomic_inc(&adapter->qdio_outb_full);
2339 goto out; 2317 goto out;
2340 req = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags, 2318 }
2319 req = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND,
2320 ZFCP_REQ_AUTO_CLEANUP,
2341 adapter->pool.fsf_req_scsi); 2321 adapter->pool.fsf_req_scsi);
2342 if (IS_ERR(req)) { 2322 if (IS_ERR(req)) {
2343 retval = PTR_ERR(req); 2323 retval = PTR_ERR(req);
@@ -2411,7 +2391,7 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
2411 "on port 0x%016Lx closed\n", 2391 "on port 0x%016Lx closed\n",
2412 (unsigned long long)unit->fcp_lun, 2392 (unsigned long long)unit->fcp_lun,
2413 (unsigned long long)unit->port->wwpn); 2393 (unsigned long long)unit->port->wwpn);
2414 zfcp_erp_unit_shutdown(unit, 0, 131, req); 2394 zfcp_erp_unit_shutdown(unit, 0, "fssfct1", req);
2415 retval = -EINVAL; 2395 retval = -EINVAL;
2416 } 2396 }
2417 goto failed_scsi_cmnd; 2397 goto failed_scsi_cmnd;
@@ -2419,9 +2399,6 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
2419 2399
2420 zfcp_set_fcp_dl(fcp_cmnd_iu, real_bytes); 2400 zfcp_set_fcp_dl(fcp_cmnd_iu, real_bytes);
2421 2401
2422 if (use_timer)
2423 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
2424
2425 retval = zfcp_fsf_req_send(req); 2402 retval = zfcp_fsf_req_send(req);
2426 if (unlikely(retval)) 2403 if (unlikely(retval))
2427 goto failed_scsi_cmnd; 2404 goto failed_scsi_cmnd;
@@ -2439,28 +2416,25 @@ out:
2439 2416
2440/** 2417/**
2441 * zfcp_fsf_send_fcp_ctm - send SCSI task management command 2418 * zfcp_fsf_send_fcp_ctm - send SCSI task management command
2442 * @adapter: pointer to struct zfcp-adapter
2443 * @unit: pointer to struct zfcp_unit 2419 * @unit: pointer to struct zfcp_unit
2444 * @tm_flags: unsigned byte for task management flags 2420 * @tm_flags: unsigned byte for task management flags
2445 * @req_flags: int request flags
2446 * Returns: on success pointer to struct fsf_req, NULL otherwise 2421 * Returns: on success pointer to struct fsf_req, NULL otherwise
2447 */ 2422 */
2448struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_adapter *adapter, 2423struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags)
2449 struct zfcp_unit *unit,
2450 u8 tm_flags, int req_flags)
2451{ 2424{
2452 struct qdio_buffer_element *sbale; 2425 struct qdio_buffer_element *sbale;
2453 struct zfcp_fsf_req *req = NULL; 2426 struct zfcp_fsf_req *req = NULL;
2454 struct fcp_cmnd_iu *fcp_cmnd_iu; 2427 struct fcp_cmnd_iu *fcp_cmnd_iu;
2428 struct zfcp_adapter *adapter = unit->port->adapter;
2455 2429
2456 if (unlikely(!(atomic_read(&unit->status) & 2430 if (unlikely(!(atomic_read(&unit->status) &
2457 ZFCP_STATUS_COMMON_UNBLOCKED))) 2431 ZFCP_STATUS_COMMON_UNBLOCKED)))
2458 return NULL; 2432 return NULL;
2459 2433
2460 spin_lock(&adapter->req_q_lock); 2434 spin_lock_bh(&adapter->req_q_lock);
2461 if (!zfcp_fsf_sbal_available(adapter)) 2435 if (zfcp_fsf_req_sbal_get(adapter))
2462 goto out; 2436 goto out;
2463 req = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags, 2437 req = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, 0,
2464 adapter->pool.fsf_req_scsi); 2438 adapter->pool.fsf_req_scsi);
2465 if (IS_ERR(req)) { 2439 if (IS_ERR(req)) {
2466 req = NULL; 2440 req = NULL;
@@ -2492,7 +2466,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_adapter *adapter,
2492 zfcp_fsf_req_free(req); 2466 zfcp_fsf_req_free(req);
2493 req = NULL; 2467 req = NULL;
2494out: 2468out:
2495 spin_unlock(&adapter->req_q_lock); 2469 spin_unlock_bh(&adapter->req_q_lock);
2496 return req; 2470 return req;
2497} 2471}
2498 2472
diff --git a/drivers/s390/scsi/zfcp_fsf.h b/drivers/s390/scsi/zfcp_fsf.h
index 8bb200252347..df7f232faba8 100644
--- a/drivers/s390/scsi/zfcp_fsf.h
+++ b/drivers/s390/scsi/zfcp_fsf.h
@@ -127,10 +127,6 @@
127#define FSF_STATUS_READ_CFDC_UPDATED 0x0000000A 127#define FSF_STATUS_READ_CFDC_UPDATED 0x0000000A
128#define FSF_STATUS_READ_FEATURE_UPDATE_ALERT 0x0000000C 128#define FSF_STATUS_READ_FEATURE_UPDATE_ALERT 0x0000000C
129 129
130/* status subtypes in status read buffer */
131#define FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT 0x00000001
132#define FSF_STATUS_READ_SUB_ERROR_PORT 0x00000002
133
134/* status subtypes for link down */ 130/* status subtypes for link down */
135#define FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK 0x00000000 131#define FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK 0x00000000
136#define FSF_STATUS_READ_SUB_FDISC_FAILED 0x00000001 132#define FSF_STATUS_READ_SUB_FDISC_FAILED 0x00000001
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
index 33e0a206a0a4..e0a215309df0 100644
--- a/drivers/s390/scsi/zfcp_qdio.c
+++ b/drivers/s390/scsi/zfcp_qdio.c
@@ -11,9 +11,6 @@
11 11
12#include "zfcp_ext.h" 12#include "zfcp_ext.h"
13 13
14/* FIXME(tune): free space should be one max. SBAL chain plus what? */
15#define ZFCP_QDIO_PCI_INTERVAL (QDIO_MAX_BUFFERS_PER_Q \
16 - (FSF_MAX_SBALS_PER_REQ + 4))
17#define QBUFF_PER_PAGE (PAGE_SIZE / sizeof(struct qdio_buffer)) 14#define QBUFF_PER_PAGE (PAGE_SIZE / sizeof(struct qdio_buffer))
18 15
19static int zfcp_qdio_buffers_enqueue(struct qdio_buffer **sbal) 16static int zfcp_qdio_buffers_enqueue(struct qdio_buffer **sbal)
@@ -58,7 +55,7 @@ void zfcp_qdio_free(struct zfcp_adapter *adapter)
58 } 55 }
59} 56}
60 57
61static void zfcp_qdio_handler_error(struct zfcp_adapter *adapter, u8 id) 58static void zfcp_qdio_handler_error(struct zfcp_adapter *adapter, char *id)
62{ 59{
63 dev_warn(&adapter->ccw_device->dev, "A QDIO problem occurred\n"); 60 dev_warn(&adapter->ccw_device->dev, "A QDIO problem occurred\n");
64 61
@@ -77,6 +74,23 @@ static void zfcp_qdio_zero_sbals(struct qdio_buffer *sbal[], int first, int cnt)
77 } 74 }
78} 75}
79 76
77/* this needs to be called prior to updating the queue fill level */
78static void zfcp_qdio_account(struct zfcp_adapter *adapter)
79{
80 ktime_t now;
81 s64 span;
82 int free, used;
83
84 spin_lock(&adapter->qdio_stat_lock);
85 now = ktime_get();
86 span = ktime_us_delta(now, adapter->req_q_time);
87 free = max(0, atomic_read(&adapter->req_q.count));
88 used = QDIO_MAX_BUFFERS_PER_Q - free;
89 adapter->req_q_util += used * span;
90 adapter->req_q_time = now;
91 spin_unlock(&adapter->qdio_stat_lock);
92}
93
80static void zfcp_qdio_int_req(struct ccw_device *cdev, unsigned int qdio_err, 94static void zfcp_qdio_int_req(struct ccw_device *cdev, unsigned int qdio_err,
81 int queue_no, int first, int count, 95 int queue_no, int first, int count,
82 unsigned long parm) 96 unsigned long parm)
@@ -86,13 +100,14 @@ static void zfcp_qdio_int_req(struct ccw_device *cdev, unsigned int qdio_err,
86 100
87 if (unlikely(qdio_err)) { 101 if (unlikely(qdio_err)) {
88 zfcp_hba_dbf_event_qdio(adapter, qdio_err, first, count); 102 zfcp_hba_dbf_event_qdio(adapter, qdio_err, first, count);
89 zfcp_qdio_handler_error(adapter, 140); 103 zfcp_qdio_handler_error(adapter, "qdireq1");
90 return; 104 return;
91 } 105 }
92 106
93 /* cleanup all SBALs being program-owned now */ 107 /* cleanup all SBALs being program-owned now */
94 zfcp_qdio_zero_sbals(queue->sbal, first, count); 108 zfcp_qdio_zero_sbals(queue->sbal, first, count);
95 109
110 zfcp_qdio_account(adapter);
96 atomic_add(count, &queue->count); 111 atomic_add(count, &queue->count);
97 wake_up(&adapter->request_wq); 112 wake_up(&adapter->request_wq);
98} 113}
@@ -154,7 +169,7 @@ static void zfcp_qdio_int_resp(struct ccw_device *cdev, unsigned int qdio_err,
154 169
155 if (unlikely(qdio_err)) { 170 if (unlikely(qdio_err)) {
156 zfcp_hba_dbf_event_qdio(adapter, qdio_err, first, count); 171 zfcp_hba_dbf_event_qdio(adapter, qdio_err, first, count);
157 zfcp_qdio_handler_error(adapter, 147); 172 zfcp_qdio_handler_error(adapter, "qdires1");
158 return; 173 return;
159 } 174 }
160 175
@@ -346,21 +361,12 @@ int zfcp_qdio_send(struct zfcp_fsf_req *fsf_req)
346 struct zfcp_qdio_queue *req_q = &adapter->req_q; 361 struct zfcp_qdio_queue *req_q = &adapter->req_q;
347 int first = fsf_req->sbal_first; 362 int first = fsf_req->sbal_first;
348 int count = fsf_req->sbal_number; 363 int count = fsf_req->sbal_number;
349 int retval, pci, pci_batch; 364 int retval;
350 struct qdio_buffer_element *sbale; 365 unsigned int qdio_flags = QDIO_FLAG_SYNC_OUTPUT;
351 366
352 /* acknowledgements for transferred buffers */ 367 zfcp_qdio_account(adapter);
353 pci_batch = adapter->req_q_pci_batch + count;
354 if (unlikely(pci_batch >= ZFCP_QDIO_PCI_INTERVAL)) {
355 pci_batch %= ZFCP_QDIO_PCI_INTERVAL;
356 pci = first + count - (pci_batch + 1);
357 pci %= QDIO_MAX_BUFFERS_PER_Q;
358 sbale = zfcp_qdio_sbale(req_q, pci, 0);
359 sbale->flags |= SBAL_FLAGS0_PCI;
360 }
361 368
362 retval = do_QDIO(adapter->ccw_device, QDIO_FLAG_SYNC_OUTPUT, 0, first, 369 retval = do_QDIO(adapter->ccw_device, qdio_flags, 0, first, count);
363 count);
364 if (unlikely(retval)) { 370 if (unlikely(retval)) {
365 zfcp_qdio_zero_sbals(req_q->sbal, first, count); 371 zfcp_qdio_zero_sbals(req_q->sbal, first, count);
366 return retval; 372 return retval;
@@ -370,7 +376,6 @@ int zfcp_qdio_send(struct zfcp_fsf_req *fsf_req)
370 atomic_sub(count, &req_q->count); 376 atomic_sub(count, &req_q->count);
371 req_q->first += count; 377 req_q->first += count;
372 req_q->first %= QDIO_MAX_BUFFERS_PER_Q; 378 req_q->first %= QDIO_MAX_BUFFERS_PER_Q;
373 adapter->req_q_pci_batch = pci_batch;
374 return 0; 379 return 0;
375} 380}
376 381
@@ -441,7 +446,6 @@ void zfcp_qdio_close(struct zfcp_adapter *adapter)
441 } 446 }
442 req_q->first = 0; 447 req_q->first = 0;
443 atomic_set(&req_q->count, 0); 448 atomic_set(&req_q->count, 0);
444 adapter->req_q_pci_batch = 0;
445 adapter->resp_q.first = 0; 449 adapter->resp_q.first = 0;
446 atomic_set(&adapter->resp_q.count, 0); 450 atomic_set(&adapter->resp_q.count, 0);
447} 451}
@@ -479,7 +483,6 @@ int zfcp_qdio_open(struct zfcp_adapter *adapter)
479 /* set index of first avalable SBALS / number of available SBALS */ 483 /* set index of first avalable SBALS / number of available SBALS */
480 adapter->req_q.first = 0; 484 adapter->req_q.first = 0;
481 atomic_set(&adapter->req_q.count, QDIO_MAX_BUFFERS_PER_Q); 485 atomic_set(&adapter->req_q.count, QDIO_MAX_BUFFERS_PER_Q);
482 adapter->req_q_pci_batch = 0;
483 486
484 return 0; 487 return 0;
485 488
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 9dc42a68fbdd..58201e1ae478 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Interface to Linux SCSI midlayer. 4 * Interface to Linux SCSI midlayer.
5 * 5 *
6 * Copyright IBM Corporation 2002, 2008 6 * Copyright IBM Corporation 2002, 2009
7 */ 7 */
8 8
9#define KMSG_COMPONENT "zfcp" 9#define KMSG_COMPONENT "zfcp"
@@ -27,9 +27,7 @@ char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *fcp_rsp_iu)
27static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt) 27static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt)
28{ 28{
29 struct zfcp_unit *unit = (struct zfcp_unit *) sdpnt->hostdata; 29 struct zfcp_unit *unit = (struct zfcp_unit *) sdpnt->hostdata;
30 atomic_clear_mask(ZFCP_STATUS_UNIT_REGISTERED, &unit->status);
31 unit->device = NULL; 30 unit->device = NULL;
32 zfcp_erp_unit_failed(unit, 12, NULL);
33 zfcp_unit_put(unit); 31 zfcp_unit_put(unit);
34} 32}
35 33
@@ -58,8 +56,8 @@ static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
58{ 56{
59 struct zfcp_unit *unit; 57 struct zfcp_unit *unit;
60 struct zfcp_adapter *adapter; 58 struct zfcp_adapter *adapter;
61 int status; 59 int status, scsi_result, ret;
62 int ret; 60 struct fc_rport *rport = starget_to_rport(scsi_target(scpnt->device));
63 61
64 /* reset the status for this request */ 62 /* reset the status for this request */
65 scpnt->result = 0; 63 scpnt->result = 0;
@@ -81,6 +79,14 @@ static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
81 return 0; 79 return 0;
82 } 80 }
83 81
82 scsi_result = fc_remote_port_chkready(rport);
83 if (unlikely(scsi_result)) {
84 scpnt->result = scsi_result;
85 zfcp_scsi_dbf_event_result("fail", 4, adapter, scpnt, NULL);
86 scpnt->scsi_done(scpnt);
87 return 0;
88 }
89
84 status = atomic_read(&unit->status); 90 status = atomic_read(&unit->status);
85 if (unlikely((status & ZFCP_STATUS_COMMON_ERP_FAILED) || 91 if (unlikely((status & ZFCP_STATUS_COMMON_ERP_FAILED) ||
86 !(status & ZFCP_STATUS_COMMON_RUNNING))) { 92 !(status & ZFCP_STATUS_COMMON_RUNNING))) {
@@ -88,8 +94,7 @@ static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
88 return 0;; 94 return 0;;
89 } 95 }
90 96
91 ret = zfcp_fsf_send_fcp_command_task(adapter, unit, scpnt, 0, 97 ret = zfcp_fsf_send_fcp_command_task(unit, scpnt);
92 ZFCP_REQ_AUTO_CLEANUP);
93 if (unlikely(ret == -EBUSY)) 98 if (unlikely(ret == -EBUSY))
94 return SCSI_MLQUEUE_DEVICE_BUSY; 99 return SCSI_MLQUEUE_DEVICE_BUSY;
95 else if (unlikely(ret < 0)) 100 else if (unlikely(ret < 0))
@@ -133,8 +138,7 @@ static int zfcp_scsi_slave_alloc(struct scsi_device *sdp)
133 138
134 read_lock_irqsave(&zfcp_data.config_lock, flags); 139 read_lock_irqsave(&zfcp_data.config_lock, flags);
135 unit = zfcp_unit_lookup(adapter, sdp->channel, sdp->id, sdp->lun); 140 unit = zfcp_unit_lookup(adapter, sdp->channel, sdp->id, sdp->lun);
136 if (unit && 141 if (unit) {
137 (atomic_read(&unit->status) & ZFCP_STATUS_UNIT_REGISTERED)) {
138 sdp->hostdata = unit; 142 sdp->hostdata = unit;
139 unit->device = sdp; 143 unit->device = sdp;
140 zfcp_unit_get(unit); 144 zfcp_unit_get(unit);
@@ -147,79 +151,91 @@ out:
147 151
148static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt) 152static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
149{ 153{
150 struct Scsi_Host *scsi_host; 154 struct Scsi_Host *scsi_host = scpnt->device->host;
151 struct zfcp_adapter *adapter; 155 struct zfcp_adapter *adapter =
152 struct zfcp_unit *unit; 156 (struct zfcp_adapter *) scsi_host->hostdata[0];
153 struct zfcp_fsf_req *fsf_req; 157 struct zfcp_unit *unit = scpnt->device->hostdata;
158 struct zfcp_fsf_req *old_req, *abrt_req;
154 unsigned long flags; 159 unsigned long flags;
155 unsigned long old_req_id = (unsigned long) scpnt->host_scribble; 160 unsigned long old_req_id = (unsigned long) scpnt->host_scribble;
156 int retval = SUCCESS; 161 int retval = SUCCESS;
157 162 int retry = 3;
158 scsi_host = scpnt->device->host;
159 adapter = (struct zfcp_adapter *) scsi_host->hostdata[0];
160 unit = scpnt->device->hostdata;
161 163
162 /* avoid race condition between late normal completion and abort */ 164 /* avoid race condition between late normal completion and abort */
163 write_lock_irqsave(&adapter->abort_lock, flags); 165 write_lock_irqsave(&adapter->abort_lock, flags);
164 166
165 /* Check whether corresponding fsf_req is still pending */
166 spin_lock(&adapter->req_list_lock); 167 spin_lock(&adapter->req_list_lock);
167 fsf_req = zfcp_reqlist_find(adapter, old_req_id); 168 old_req = zfcp_reqlist_find(adapter, old_req_id);
168 spin_unlock(&adapter->req_list_lock); 169 spin_unlock(&adapter->req_list_lock);
169 if (!fsf_req) { 170 if (!old_req) {
170 write_unlock_irqrestore(&adapter->abort_lock, flags); 171 write_unlock_irqrestore(&adapter->abort_lock, flags);
171 zfcp_scsi_dbf_event_abort("lte1", adapter, scpnt, NULL, 0); 172 zfcp_scsi_dbf_event_abort("lte1", adapter, scpnt, NULL,
172 return retval; 173 old_req_id);
174 return SUCCESS;
173 } 175 }
174 fsf_req->data = NULL; 176 old_req->data = NULL;
175 177
176 /* don't access old fsf_req after releasing the abort_lock */ 178 /* don't access old fsf_req after releasing the abort_lock */
177 write_unlock_irqrestore(&adapter->abort_lock, flags); 179 write_unlock_irqrestore(&adapter->abort_lock, flags);
178 180
179 fsf_req = zfcp_fsf_abort_fcp_command(old_req_id, adapter, unit, 0); 181 while (retry--) {
180 if (!fsf_req) { 182 abrt_req = zfcp_fsf_abort_fcp_command(old_req_id, unit);
181 zfcp_scsi_dbf_event_abort("nres", adapter, scpnt, NULL, 183 if (abrt_req)
182 old_req_id); 184 break;
183 retval = FAILED; 185
184 return retval; 186 zfcp_erp_wait(adapter);
187 if (!(atomic_read(&adapter->status) &
188 ZFCP_STATUS_COMMON_RUNNING)) {
189 zfcp_scsi_dbf_event_abort("nres", adapter, scpnt, NULL,
190 old_req_id);
191 return SUCCESS;
192 }
185 } 193 }
194 if (!abrt_req)
195 return FAILED;
186 196
187 __wait_event(fsf_req->completion_wq, 197 wait_event(abrt_req->completion_wq,
188 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); 198 abrt_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
189 199
190 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED) { 200 if (abrt_req->status & ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED)
191 zfcp_scsi_dbf_event_abort("okay", adapter, scpnt, fsf_req, 0); 201 zfcp_scsi_dbf_event_abort("okay", adapter, scpnt, abrt_req, 0);
192 } else if (fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED) { 202 else if (abrt_req->status & ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED)
193 zfcp_scsi_dbf_event_abort("lte2", adapter, scpnt, fsf_req, 0); 203 zfcp_scsi_dbf_event_abort("lte2", adapter, scpnt, abrt_req, 0);
194 } else { 204 else {
195 zfcp_scsi_dbf_event_abort("fail", adapter, scpnt, fsf_req, 0); 205 zfcp_scsi_dbf_event_abort("fail", adapter, scpnt, abrt_req, 0);
196 retval = FAILED; 206 retval = FAILED;
197 } 207 }
198 zfcp_fsf_req_free(fsf_req); 208 zfcp_fsf_req_free(abrt_req);
199
200 return retval; 209 return retval;
201} 210}
202 211
203static int zfcp_task_mgmt_function(struct zfcp_unit *unit, u8 tm_flags, 212static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags)
204 struct scsi_cmnd *scpnt)
205{ 213{
214 struct zfcp_unit *unit = scpnt->device->hostdata;
206 struct zfcp_adapter *adapter = unit->port->adapter; 215 struct zfcp_adapter *adapter = unit->port->adapter;
207 struct zfcp_fsf_req *fsf_req; 216 struct zfcp_fsf_req *fsf_req;
208 int retval = SUCCESS; 217 int retval = SUCCESS;
209 218 int retry = 3;
210 /* issue task management function */ 219
211 fsf_req = zfcp_fsf_send_fcp_ctm(adapter, unit, tm_flags, 0); 220 while (retry--) {
212 if (!fsf_req) { 221 fsf_req = zfcp_fsf_send_fcp_ctm(unit, tm_flags);
213 zfcp_scsi_dbf_event_devreset("nres", tm_flags, unit, scpnt); 222 if (fsf_req)
214 return FAILED; 223 break;
224
225 zfcp_erp_wait(adapter);
226 if (!(atomic_read(&adapter->status) &
227 ZFCP_STATUS_COMMON_RUNNING)) {
228 zfcp_scsi_dbf_event_devreset("nres", tm_flags, unit,
229 scpnt);
230 return SUCCESS;
231 }
215 } 232 }
233 if (!fsf_req)
234 return FAILED;
216 235
217 __wait_event(fsf_req->completion_wq, 236 wait_event(fsf_req->completion_wq,
218 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); 237 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
219 238
220 /*
221 * check completion status of task management function
222 */
223 if (fsf_req->status & ZFCP_STATUS_FSFREQ_TMFUNCFAILED) { 239 if (fsf_req->status & ZFCP_STATUS_FSFREQ_TMFUNCFAILED) {
224 zfcp_scsi_dbf_event_devreset("fail", tm_flags, unit, scpnt); 240 zfcp_scsi_dbf_event_devreset("fail", tm_flags, unit, scpnt);
225 retval = FAILED; 241 retval = FAILED;
@@ -230,40 +246,25 @@ static int zfcp_task_mgmt_function(struct zfcp_unit *unit, u8 tm_flags,
230 zfcp_scsi_dbf_event_devreset("okay", tm_flags, unit, scpnt); 246 zfcp_scsi_dbf_event_devreset("okay", tm_flags, unit, scpnt);
231 247
232 zfcp_fsf_req_free(fsf_req); 248 zfcp_fsf_req_free(fsf_req);
233
234 return retval; 249 return retval;
235} 250}
236 251
237static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt) 252static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt)
238{ 253{
239 struct zfcp_unit *unit = scpnt->device->hostdata; 254 return zfcp_task_mgmt_function(scpnt, FCP_LOGICAL_UNIT_RESET);
240
241 if (!unit) {
242 WARN_ON(1);
243 return SUCCESS;
244 }
245 return zfcp_task_mgmt_function(unit, FCP_LOGICAL_UNIT_RESET, scpnt);
246} 255}
247 256
248static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt) 257static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt)
249{ 258{
250 struct zfcp_unit *unit = scpnt->device->hostdata; 259 return zfcp_task_mgmt_function(scpnt, FCP_TARGET_RESET);
251
252 if (!unit) {
253 WARN_ON(1);
254 return SUCCESS;
255 }
256 return zfcp_task_mgmt_function(unit, FCP_TARGET_RESET, scpnt);
257} 260}
258 261
259static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) 262static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
260{ 263{
261 struct zfcp_unit *unit; 264 struct zfcp_unit *unit = scpnt->device->hostdata;
262 struct zfcp_adapter *adapter; 265 struct zfcp_adapter *adapter = unit->port->adapter;
263 266
264 unit = scpnt->device->hostdata; 267 zfcp_erp_adapter_reopen(adapter, 0, "schrh_1", scpnt);
265 adapter = unit->port->adapter;
266 zfcp_erp_adapter_reopen(adapter, 0, 141, scpnt);
267 zfcp_erp_wait(adapter); 268 zfcp_erp_wait(adapter);
268 269
269 return SUCCESS; 270 return SUCCESS;
@@ -479,6 +480,109 @@ static void zfcp_set_rport_dev_loss_tmo(struct fc_rport *rport, u32 timeout)
479 rport->dev_loss_tmo = timeout; 480 rport->dev_loss_tmo = timeout;
480} 481}
481 482
483/**
484 * zfcp_scsi_dev_loss_tmo_callbk - Free any reference to rport
485 * @rport: The rport that is about to be deleted.
486 */
487static void zfcp_scsi_dev_loss_tmo_callbk(struct fc_rport *rport)
488{
489 struct zfcp_port *port = rport->dd_data;
490
491 write_lock_irq(&zfcp_data.config_lock);
492 port->rport = NULL;
493 write_unlock_irq(&zfcp_data.config_lock);
494}
495
496/**
497 * zfcp_scsi_terminate_rport_io - Terminate all I/O on a rport
498 * @rport: The FC rport where to teminate I/O
499 *
500 * Abort all pending SCSI commands for a port by closing the
501 * port. Using a reopen for avoids a conflict with a shutdown
502 * overwriting a reopen.
503 */
504static void zfcp_scsi_terminate_rport_io(struct fc_rport *rport)
505{
506 struct zfcp_port *port = rport->dd_data;
507
508 zfcp_erp_port_reopen(port, 0, "sctrpi1", NULL);
509}
510
511static void zfcp_scsi_rport_register(struct zfcp_port *port)
512{
513 struct fc_rport_identifiers ids;
514 struct fc_rport *rport;
515
516 ids.node_name = port->wwnn;
517 ids.port_name = port->wwpn;
518 ids.port_id = port->d_id;
519 ids.roles = FC_RPORT_ROLE_FCP_TARGET;
520
521 rport = fc_remote_port_add(port->adapter->scsi_host, 0, &ids);
522 if (!rport) {
523 dev_err(&port->adapter->ccw_device->dev,
524 "Registering port 0x%016Lx failed\n",
525 (unsigned long long)port->wwpn);
526 return;
527 }
528
529 rport->dd_data = port;
530 rport->maxframe_size = port->maxframe_size;
531 rport->supported_classes = port->supported_classes;
532 port->rport = rport;
533}
534
535static void zfcp_scsi_rport_block(struct zfcp_port *port)
536{
537 if (port->rport)
538 fc_remote_port_delete(port->rport);
539}
540
541void zfcp_scsi_schedule_rport_register(struct zfcp_port *port)
542{
543 zfcp_port_get(port);
544 port->rport_task = RPORT_ADD;
545
546 if (!queue_work(zfcp_data.work_queue, &port->rport_work))
547 zfcp_port_put(port);
548}
549
550void zfcp_scsi_schedule_rport_block(struct zfcp_port *port)
551{
552 zfcp_port_get(port);
553 port->rport_task = RPORT_DEL;
554
555 if (!queue_work(zfcp_data.work_queue, &port->rport_work))
556 zfcp_port_put(port);
557}
558
559void zfcp_scsi_schedule_rports_block(struct zfcp_adapter *adapter)
560{
561 struct zfcp_port *port;
562
563 list_for_each_entry(port, &adapter->port_list_head, list)
564 zfcp_scsi_schedule_rport_block(port);
565}
566
567void zfcp_scsi_rport_work(struct work_struct *work)
568{
569 struct zfcp_port *port = container_of(work, struct zfcp_port,
570 rport_work);
571
572 while (port->rport_task) {
573 if (port->rport_task == RPORT_ADD) {
574 port->rport_task = RPORT_NONE;
575 zfcp_scsi_rport_register(port);
576 } else {
577 port->rport_task = RPORT_NONE;
578 zfcp_scsi_rport_block(port);
579 }
580 }
581
582 zfcp_port_put(port);
583}
584
585
482struct fc_function_template zfcp_transport_functions = { 586struct fc_function_template zfcp_transport_functions = {
483 .show_starget_port_id = 1, 587 .show_starget_port_id = 1,
484 .show_starget_port_name = 1, 588 .show_starget_port_name = 1,
@@ -497,6 +601,8 @@ struct fc_function_template zfcp_transport_functions = {
497 .reset_fc_host_stats = zfcp_reset_fc_host_stats, 601 .reset_fc_host_stats = zfcp_reset_fc_host_stats,
498 .set_rport_dev_loss_tmo = zfcp_set_rport_dev_loss_tmo, 602 .set_rport_dev_loss_tmo = zfcp_set_rport_dev_loss_tmo,
499 .get_host_port_state = zfcp_get_host_port_state, 603 .get_host_port_state = zfcp_get_host_port_state,
604 .dev_loss_tmo_callbk = zfcp_scsi_dev_loss_tmo_callbk,
605 .terminate_rport_io = zfcp_scsi_terminate_rport_io,
500 .show_host_port_state = 1, 606 .show_host_port_state = 1,
501 /* no functions registered for following dynamic attributes but 607 /* no functions registered for following dynamic attributes but
502 directly set by LLDD */ 608 directly set by LLDD */
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index 899af2b45b1e..9a3b8e261c0a 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -112,9 +112,9 @@ static ZFCP_DEV_ATTR(_feat, failed, S_IWUSR | S_IRUGO, \
112 zfcp_sysfs_##_feat##_failed_show, \ 112 zfcp_sysfs_##_feat##_failed_show, \
113 zfcp_sysfs_##_feat##_failed_store); 113 zfcp_sysfs_##_feat##_failed_store);
114 114
115ZFCP_SYSFS_FAILED(zfcp_adapter, adapter, adapter, 44, 93); 115ZFCP_SYSFS_FAILED(zfcp_adapter, adapter, adapter, "syafai1", "syafai2");
116ZFCP_SYSFS_FAILED(zfcp_port, port, port->adapter, 45, 96); 116ZFCP_SYSFS_FAILED(zfcp_port, port, port->adapter, "sypfai1", "sypfai2");
117ZFCP_SYSFS_FAILED(zfcp_unit, unit, unit->port->adapter, 46, 97); 117ZFCP_SYSFS_FAILED(zfcp_unit, unit, unit->port->adapter, "syufai1", "syufai2");
118 118
119static ssize_t zfcp_sysfs_port_rescan_store(struct device *dev, 119static ssize_t zfcp_sysfs_port_rescan_store(struct device *dev,
120 struct device_attribute *attr, 120 struct device_attribute *attr,
@@ -168,7 +168,7 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
168 goto out; 168 goto out;
169 } 169 }
170 170
171 zfcp_erp_port_shutdown(port, 0, 92, NULL); 171 zfcp_erp_port_shutdown(port, 0, "syprs_1", NULL);
172 zfcp_erp_wait(adapter); 172 zfcp_erp_wait(adapter);
173 zfcp_port_put(port); 173 zfcp_port_put(port);
174 zfcp_port_dequeue(port); 174 zfcp_port_dequeue(port);
@@ -222,7 +222,7 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev,
222 222
223 retval = 0; 223 retval = 0;
224 224
225 zfcp_erp_unit_reopen(unit, 0, 94, NULL); 225 zfcp_erp_unit_reopen(unit, 0, "syuas_1", NULL);
226 zfcp_erp_wait(unit->port->adapter); 226 zfcp_erp_wait(unit->port->adapter);
227 zfcp_unit_put(unit); 227 zfcp_unit_put(unit);
228out: 228out:
@@ -268,7 +268,7 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
268 goto out; 268 goto out;
269 } 269 }
270 270
271 zfcp_erp_unit_shutdown(unit, 0, 95, NULL); 271 zfcp_erp_unit_shutdown(unit, 0, "syurs_1", NULL);
272 zfcp_erp_wait(unit->port->adapter); 272 zfcp_erp_wait(unit->port->adapter);
273 zfcp_unit_put(unit); 273 zfcp_unit_put(unit);
274 zfcp_unit_dequeue(unit); 274 zfcp_unit_dequeue(unit);
@@ -318,10 +318,9 @@ zfcp_sysfs_unit_##_name##_latency_show(struct device *dev, \
318 struct zfcp_unit *unit = sdev->hostdata; \ 318 struct zfcp_unit *unit = sdev->hostdata; \
319 struct zfcp_latencies *lat = &unit->latencies; \ 319 struct zfcp_latencies *lat = &unit->latencies; \
320 struct zfcp_adapter *adapter = unit->port->adapter; \ 320 struct zfcp_adapter *adapter = unit->port->adapter; \
321 unsigned long flags; \
322 unsigned long long fsum, fmin, fmax, csum, cmin, cmax, cc; \ 321 unsigned long long fsum, fmin, fmax, csum, cmin, cmax, cc; \
323 \ 322 \
324 spin_lock_irqsave(&lat->lock, flags); \ 323 spin_lock_bh(&lat->lock); \
325 fsum = lat->_name.fabric.sum * adapter->timer_ticks; \ 324 fsum = lat->_name.fabric.sum * adapter->timer_ticks; \
326 fmin = lat->_name.fabric.min * adapter->timer_ticks; \ 325 fmin = lat->_name.fabric.min * adapter->timer_ticks; \
327 fmax = lat->_name.fabric.max * adapter->timer_ticks; \ 326 fmax = lat->_name.fabric.max * adapter->timer_ticks; \
@@ -329,7 +328,7 @@ zfcp_sysfs_unit_##_name##_latency_show(struct device *dev, \
329 cmin = lat->_name.channel.min * adapter->timer_ticks; \ 328 cmin = lat->_name.channel.min * adapter->timer_ticks; \
330 cmax = lat->_name.channel.max * adapter->timer_ticks; \ 329 cmax = lat->_name.channel.max * adapter->timer_ticks; \
331 cc = lat->_name.counter; \ 330 cc = lat->_name.counter; \
332 spin_unlock_irqrestore(&lat->lock, flags); \ 331 spin_unlock_bh(&lat->lock); \
333 \ 332 \
334 do_div(fsum, 1000); \ 333 do_div(fsum, 1000); \
335 do_div(fmin, 1000); \ 334 do_div(fmin, 1000); \
@@ -487,7 +486,8 @@ static ssize_t zfcp_sysfs_adapter_q_full_show(struct device *dev,
487 struct zfcp_adapter *adapter = 486 struct zfcp_adapter *adapter =
488 (struct zfcp_adapter *) scsi_host->hostdata[0]; 487 (struct zfcp_adapter *) scsi_host->hostdata[0];
489 488
490 return sprintf(buf, "%d\n", atomic_read(&adapter->qdio_outb_full)); 489 return sprintf(buf, "%d %llu\n", atomic_read(&adapter->qdio_outb_full),
490 (unsigned long long)adapter->req_q_util);
491} 491}
492static DEVICE_ATTR(queue_full, S_IRUGO, zfcp_sysfs_adapter_q_full_show, NULL); 492static DEVICE_ATTR(queue_full, S_IRUGO, zfcp_sysfs_adapter_q_full_show, NULL);
493 493