aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_fsf.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-03-29 04:40:34 -0400
committerDavid S. Miller <davem@davemloft.net>2009-03-29 04:40:34 -0400
commit13223cb02ccfa375f2d683d08d30db5b72264f1e (patch)
treed3fc7d803d22bbfe03b96cf0ba38041d42c8a1c2 /drivers/s390/scsi/zfcp_fsf.c
parent1383bdb98c01bbd28d72336d1bf614ce79114d29 (diff)
parent07d43ba98621f08e252a48c96b258b4d572b0257 (diff)
Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
Diffstat (limited to 'drivers/s390/scsi/zfcp_fsf.c')
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c240
1 files changed, 107 insertions, 133 deletions
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