4 * Implementation of FSF commands.
6 * Copyright IBM Corporation 2002, 2009
9 #define KMSG_COMPONENT "zfcp"
10 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12 #include <linux/blktrace_api.h>
15 #define ZFCP_REQ_AUTO_CLEANUP 0x00000002
16 #define ZFCP_REQ_NO_QTCB 0x00000008
18 static void zfcp_fsf_request_timeout_handler(unsigned long data)
20 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
21 zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED,
25 static void zfcp_fsf_start_timer(struct zfcp_fsf_req *fsf_req,
26 unsigned long timeout)
28 fsf_req->timer.function = zfcp_fsf_request_timeout_handler;
29 fsf_req->timer.data = (unsigned long) fsf_req->adapter;
30 fsf_req->timer.expires = jiffies + timeout;
31 add_timer(&fsf_req->timer);
34 static void zfcp_fsf_start_erp_timer(struct zfcp_fsf_req *fsf_req)
36 BUG_ON(!fsf_req->erp_action);
37 fsf_req->timer.function = zfcp_erp_timeout_handler;
38 fsf_req->timer.data = (unsigned long) fsf_req->erp_action;
39 fsf_req->timer.expires = jiffies + 30 * HZ;
40 add_timer(&fsf_req->timer);
43 /* association between FSF command and FSF QTCB type */
44 static u32 fsf_qtcb_type[] = {
45 [FSF_QTCB_FCP_CMND] = FSF_IO_COMMAND,
46 [FSF_QTCB_ABORT_FCP_CMND] = FSF_SUPPORT_COMMAND,
47 [FSF_QTCB_OPEN_PORT_WITH_DID] = FSF_SUPPORT_COMMAND,
48 [FSF_QTCB_OPEN_LUN] = FSF_SUPPORT_COMMAND,
49 [FSF_QTCB_CLOSE_LUN] = FSF_SUPPORT_COMMAND,
50 [FSF_QTCB_CLOSE_PORT] = FSF_SUPPORT_COMMAND,
51 [FSF_QTCB_CLOSE_PHYSICAL_PORT] = FSF_SUPPORT_COMMAND,
52 [FSF_QTCB_SEND_ELS] = FSF_SUPPORT_COMMAND,
53 [FSF_QTCB_SEND_GENERIC] = FSF_SUPPORT_COMMAND,
54 [FSF_QTCB_EXCHANGE_CONFIG_DATA] = FSF_CONFIG_COMMAND,
55 [FSF_QTCB_EXCHANGE_PORT_DATA] = FSF_PORT_COMMAND,
56 [FSF_QTCB_DOWNLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND,
57 [FSF_QTCB_UPLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND
60 static void zfcp_act_eval_err(struct zfcp_adapter *adapter, u32 table)
62 u16 subtable = table >> 16;
63 u16 rule = table & 0xffff;
64 const char *act_type[] = { "unknown", "OS", "WWPN", "DID", "LUN" };
66 if (subtable && subtable < ARRAY_SIZE(act_type))
67 dev_warn(&adapter->ccw_device->dev,
68 "Access denied according to ACT rule type %s, "
69 "rule %d\n", act_type[subtable], rule);
72 static void zfcp_fsf_access_denied_port(struct zfcp_fsf_req *req,
73 struct zfcp_port *port)
75 struct fsf_qtcb_header *header = &req->qtcb->header;
76 dev_warn(&req->adapter->ccw_device->dev,
77 "Access denied to port 0x%016Lx\n",
78 (unsigned long long)port->wwpn);
79 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]);
80 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]);
81 zfcp_erp_port_access_denied(port, "fspad_1", req);
82 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
85 static void zfcp_fsf_access_denied_unit(struct zfcp_fsf_req *req,
86 struct zfcp_unit *unit)
88 struct fsf_qtcb_header *header = &req->qtcb->header;
89 dev_warn(&req->adapter->ccw_device->dev,
90 "Access denied to unit 0x%016Lx on port 0x%016Lx\n",
91 (unsigned long long)unit->fcp_lun,
92 (unsigned long long)unit->port->wwpn);
93 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]);
94 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]);
95 zfcp_erp_unit_access_denied(unit, "fsuad_1", req);
96 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
99 static void zfcp_fsf_class_not_supp(struct zfcp_fsf_req *req)
101 dev_err(&req->adapter->ccw_device->dev, "FCP device not "
102 "operational because of an unsupported FC class\n");
103 zfcp_erp_adapter_shutdown(req->adapter, 0, "fscns_1", req);
104 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
108 * zfcp_fsf_req_free - free memory used by fsf request
109 * @fsf_req: pointer to struct zfcp_fsf_req
111 void zfcp_fsf_req_free(struct zfcp_fsf_req *req)
113 if (likely(req->pool)) {
114 mempool_free(req, req->pool);
119 kmem_cache_free(zfcp_data.fsf_req_qtcb_cache, req);
125 * zfcp_fsf_req_dismiss_all - dismiss all fsf requests
126 * @adapter: pointer to struct zfcp_adapter
128 * Never ever call this without shutting down the adapter first.
129 * Otherwise the adapter would continue using and corrupting s390 storage.
130 * Included BUG_ON() call to ensure this is done.
131 * ERP is supposed to be the only user of this function.
133 void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter)
135 struct zfcp_fsf_req *req, *tmp;
137 LIST_HEAD(remove_queue);
140 BUG_ON(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP);
141 spin_lock_irqsave(&adapter->req_list_lock, flags);
142 for (i = 0; i < REQUEST_LIST_SIZE; i++)
143 list_splice_init(&adapter->req_list[i], &remove_queue);
144 spin_unlock_irqrestore(&adapter->req_list_lock, flags);
146 list_for_each_entry_safe(req, tmp, &remove_queue, list) {
147 list_del(&req->list);
148 req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
149 zfcp_fsf_req_complete(req);
153 static void zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *req)
155 struct fsf_status_read_buffer *sr_buf = req->data;
156 struct zfcp_adapter *adapter = req->adapter;
157 struct zfcp_port *port;
158 int d_id = sr_buf->d_id & ZFCP_DID_MASK;
161 read_lock_irqsave(&zfcp_data.config_lock, flags);
162 list_for_each_entry(port, &adapter->port_list_head, list)
163 if (port->d_id == d_id) {
164 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
165 zfcp_erp_port_reopen(port, 0, "fssrpc1", req);
168 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
171 static void zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *req, char *id,
172 struct fsf_link_down_info *link_down)
174 struct zfcp_adapter *adapter = req->adapter;
177 if (atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED)
180 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status);
182 read_lock_irqsave(&zfcp_data.config_lock, flags);
183 zfcp_scsi_schedule_rports_block(adapter);
184 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
189 switch (link_down->error_code) {
190 case FSF_PSQ_LINK_NO_LIGHT:
191 dev_warn(&req->adapter->ccw_device->dev,
192 "There is no light signal from the local "
193 "fibre channel cable\n");
195 case FSF_PSQ_LINK_WRAP_PLUG:
196 dev_warn(&req->adapter->ccw_device->dev,
197 "There is a wrap plug instead of a fibre "
200 case FSF_PSQ_LINK_NO_FCP:
201 dev_warn(&req->adapter->ccw_device->dev,
202 "The adjacent fibre channel node does not "
205 case FSF_PSQ_LINK_FIRMWARE_UPDATE:
206 dev_warn(&req->adapter->ccw_device->dev,
207 "The FCP device is suspended because of a "
208 "firmware update\n");
210 case FSF_PSQ_LINK_INVALID_WWPN:
211 dev_warn(&req->adapter->ccw_device->dev,
212 "The FCP device detected a WWPN that is "
213 "duplicate or not valid\n");
215 case FSF_PSQ_LINK_NO_NPIV_SUPPORT:
216 dev_warn(&req->adapter->ccw_device->dev,
217 "The fibre channel fabric does not support NPIV\n");
219 case FSF_PSQ_LINK_NO_FCP_RESOURCES:
220 dev_warn(&req->adapter->ccw_device->dev,
221 "The FCP adapter cannot support more NPIV ports\n");
223 case FSF_PSQ_LINK_NO_FABRIC_RESOURCES:
224 dev_warn(&req->adapter->ccw_device->dev,
225 "The adjacent switch cannot support "
226 "more NPIV ports\n");
228 case FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE:
229 dev_warn(&req->adapter->ccw_device->dev,
230 "The FCP adapter could not log in to the "
231 "fibre channel fabric\n");
233 case FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED:
234 dev_warn(&req->adapter->ccw_device->dev,
235 "The WWPN assignment file on the FCP adapter "
236 "has been damaged\n");
238 case FSF_PSQ_LINK_MODE_TABLE_CURRUPTED:
239 dev_warn(&req->adapter->ccw_device->dev,
240 "The mode table on the FCP adapter "
241 "has been damaged\n");
243 case FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT:
244 dev_warn(&req->adapter->ccw_device->dev,
245 "All NPIV ports on the FCP adapter have "
249 dev_warn(&req->adapter->ccw_device->dev,
250 "The link between the FCP adapter and "
251 "the FC fabric is down\n");
254 zfcp_erp_adapter_failed(adapter, id, req);
257 static void zfcp_fsf_status_read_link_down(struct zfcp_fsf_req *req)
259 struct fsf_status_read_buffer *sr_buf = req->data;
260 struct fsf_link_down_info *ldi =
261 (struct fsf_link_down_info *) &sr_buf->payload;
263 switch (sr_buf->status_subtype) {
264 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK:
265 zfcp_fsf_link_down_info_eval(req, "fssrld1", ldi);
267 case FSF_STATUS_READ_SUB_FDISC_FAILED:
268 zfcp_fsf_link_down_info_eval(req, "fssrld2", ldi);
270 case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE:
271 zfcp_fsf_link_down_info_eval(req, "fssrld3", NULL);
275 static void zfcp_fsf_status_read_handler(struct zfcp_fsf_req *req)
277 struct zfcp_adapter *adapter = req->adapter;
278 struct fsf_status_read_buffer *sr_buf = req->data;
280 if (req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
281 zfcp_hba_dbf_event_fsf_unsol("dism", adapter, sr_buf);
282 mempool_free(sr_buf, adapter->pool.data_status_read);
283 zfcp_fsf_req_free(req);
287 zfcp_hba_dbf_event_fsf_unsol("read", adapter, sr_buf);
289 switch (sr_buf->status_type) {
290 case FSF_STATUS_READ_PORT_CLOSED:
291 zfcp_fsf_status_read_port_closed(req);
293 case FSF_STATUS_READ_INCOMING_ELS:
294 zfcp_fc_incoming_els(req);
296 case FSF_STATUS_READ_SENSE_DATA_AVAIL:
298 case FSF_STATUS_READ_BIT_ERROR_THRESHOLD:
299 dev_warn(&adapter->ccw_device->dev,
300 "The error threshold for checksum statistics "
301 "has been exceeded\n");
302 zfcp_hba_dbf_event_berr(adapter, req);
304 case FSF_STATUS_READ_LINK_DOWN:
305 zfcp_fsf_status_read_link_down(req);
307 case FSF_STATUS_READ_LINK_UP:
308 dev_info(&adapter->ccw_device->dev,
309 "The local link has been restored\n");
310 /* All ports should be marked as ready to run again */
311 zfcp_erp_modify_adapter_status(adapter, "fssrh_1", NULL,
312 ZFCP_STATUS_COMMON_RUNNING,
314 zfcp_erp_adapter_reopen(adapter,
315 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
316 ZFCP_STATUS_COMMON_ERP_FAILED,
319 case FSF_STATUS_READ_NOTIFICATION_LOST:
320 if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_ACT_UPDATED)
321 zfcp_erp_adapter_access_changed(adapter, "fssrh_3",
323 if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_INCOMING_ELS)
324 schedule_work(&adapter->scan_work);
326 case FSF_STATUS_READ_CFDC_UPDATED:
327 zfcp_erp_adapter_access_changed(adapter, "fssrh_4", req);
329 case FSF_STATUS_READ_FEATURE_UPDATE_ALERT:
330 adapter->adapter_features = sr_buf->payload.word[0];
334 mempool_free(sr_buf, adapter->pool.data_status_read);
335 zfcp_fsf_req_free(req);
337 atomic_inc(&adapter->stat_miss);
338 queue_work(zfcp_data.work_queue, &adapter->stat_work);
341 static void zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *req)
343 switch (req->qtcb->header.fsf_status_qual.word[0]) {
344 case FSF_SQ_FCP_RSP_AVAILABLE:
345 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
346 case FSF_SQ_NO_RETRY_POSSIBLE:
347 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
349 case FSF_SQ_COMMAND_ABORTED:
350 req->status |= ZFCP_STATUS_FSFREQ_ABORTED;
352 case FSF_SQ_NO_RECOM:
353 dev_err(&req->adapter->ccw_device->dev,
354 "The FCP adapter reported a problem "
355 "that cannot be recovered\n");
356 zfcp_erp_adapter_shutdown(req->adapter, 0, "fsfsqe1", req);
359 /* all non-return stats set FSFREQ_ERROR*/
360 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
363 static void zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *req)
365 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR))
368 switch (req->qtcb->header.fsf_status) {
369 case FSF_UNKNOWN_COMMAND:
370 dev_err(&req->adapter->ccw_device->dev,
371 "The FCP adapter does not recognize the command 0x%x\n",
372 req->qtcb->header.fsf_command);
373 zfcp_erp_adapter_shutdown(req->adapter, 0, "fsfse_1", req);
374 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
376 case FSF_ADAPTER_STATUS_AVAILABLE:
377 zfcp_fsf_fsfstatus_qual_eval(req);
382 static void zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *req)
384 struct zfcp_adapter *adapter = req->adapter;
385 struct fsf_qtcb *qtcb = req->qtcb;
386 union fsf_prot_status_qual *psq = &qtcb->prefix.prot_status_qual;
388 zfcp_hba_dbf_event_fsf_response(req);
390 if (req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
391 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
392 ZFCP_STATUS_FSFREQ_RETRY; /* only for SCSI cmnds. */
396 switch (qtcb->prefix.prot_status) {
398 case FSF_PROT_FSF_STATUS_PRESENTED:
400 case FSF_PROT_QTCB_VERSION_ERROR:
401 dev_err(&adapter->ccw_device->dev,
402 "QTCB version 0x%x not supported by FCP adapter "
403 "(0x%x to 0x%x)\n", FSF_QTCB_CURRENT_VERSION,
404 psq->word[0], psq->word[1]);
405 zfcp_erp_adapter_shutdown(adapter, 0, "fspse_1", req);
407 case FSF_PROT_ERROR_STATE:
408 case FSF_PROT_SEQ_NUMB_ERROR:
409 zfcp_erp_adapter_reopen(adapter, 0, "fspse_2", req);
410 req->status |= ZFCP_STATUS_FSFREQ_RETRY;
412 case FSF_PROT_UNSUPP_QTCB_TYPE:
413 dev_err(&adapter->ccw_device->dev,
414 "The QTCB type is not supported by the FCP adapter\n");
415 zfcp_erp_adapter_shutdown(adapter, 0, "fspse_3", req);
417 case FSF_PROT_HOST_CONNECTION_INITIALIZING:
418 atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
421 case FSF_PROT_DUPLICATE_REQUEST_ID:
422 dev_err(&adapter->ccw_device->dev,
423 "0x%Lx is an ambiguous request identifier\n",
424 (unsigned long long)qtcb->bottom.support.req_handle);
425 zfcp_erp_adapter_shutdown(adapter, 0, "fspse_4", req);
427 case FSF_PROT_LINK_DOWN:
428 zfcp_fsf_link_down_info_eval(req, "fspse_5",
429 &psq->link_down_info);
430 /* FIXME: reopening adapter now? better wait for link up */
431 zfcp_erp_adapter_reopen(adapter, 0, "fspse_6", req);
433 case FSF_PROT_REEST_QUEUE:
434 /* All ports should be marked as ready to run again */
435 zfcp_erp_modify_adapter_status(adapter, "fspse_7", NULL,
436 ZFCP_STATUS_COMMON_RUNNING,
438 zfcp_erp_adapter_reopen(adapter,
439 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
440 ZFCP_STATUS_COMMON_ERP_FAILED,
444 dev_err(&adapter->ccw_device->dev,
445 "0x%x is not a valid transfer protocol status\n",
446 qtcb->prefix.prot_status);
447 zfcp_erp_adapter_shutdown(adapter, 0, "fspse_9", req);
449 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
453 * zfcp_fsf_req_complete - process completion of a FSF request
454 * @fsf_req: The FSF request that has been completed.
456 * When a request has been completed either from the FCP adapter,
457 * or it has been dismissed due to a queue shutdown, this function
458 * is called to process the completion status and trigger further
459 * events related to the FSF request.
461 void zfcp_fsf_req_complete(struct zfcp_fsf_req *req)
463 if (unlikely(req->fsf_command == FSF_QTCB_UNSOLICITED_STATUS)) {
464 zfcp_fsf_status_read_handler(req);
468 del_timer(&req->timer);
469 zfcp_fsf_protstatus_eval(req);
470 zfcp_fsf_fsfstatus_eval(req);
474 zfcp_erp_notify(req->erp_action, 0);
475 req->status |= ZFCP_STATUS_FSFREQ_COMPLETED;
477 if (likely(req->status & ZFCP_STATUS_FSFREQ_CLEANUP))
478 zfcp_fsf_req_free(req);
480 /* notify initiator waiting for the requests completion */
482 * FIXME: Race! We must not access fsf_req here as it might have been
483 * cleaned up already due to the set ZFCP_STATUS_FSFREQ_COMPLETED
484 * flag. It's an improbable case. But, we have the same paranoia for
485 * the cleanup flag already.
486 * Might better be handled using complete()?
487 * (setting the flag and doing wakeup ought to be atomic
488 * with regard to checking the flag as long as waitqueue is
489 * part of the to be released structure)
491 wake_up(&req->completion_wq);
494 static int zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *req)
496 struct fsf_qtcb_bottom_config *bottom;
497 struct zfcp_adapter *adapter = req->adapter;
498 struct Scsi_Host *shost = adapter->scsi_host;
500 bottom = &req->qtcb->bottom.config;
503 memcpy(req->data, bottom, sizeof(*bottom));
505 fc_host_node_name(shost) = bottom->nport_serv_param.wwnn;
506 fc_host_port_name(shost) = bottom->nport_serv_param.wwpn;
507 fc_host_port_id(shost) = bottom->s_id & ZFCP_DID_MASK;
508 fc_host_speed(shost) = bottom->fc_link_speed;
509 fc_host_supported_classes(shost) = FC_COS_CLASS2 | FC_COS_CLASS3;
511 adapter->hydra_version = bottom->adapter_type;
512 adapter->timer_ticks = bottom->timer_interval;
514 if (fc_host_permanent_port_name(shost) == -1)
515 fc_host_permanent_port_name(shost) = fc_host_port_name(shost);
517 switch (bottom->fc_topology) {
519 adapter->peer_d_id = bottom->peer_d_id & ZFCP_DID_MASK;
520 adapter->peer_wwpn = bottom->plogi_payload.wwpn;
521 adapter->peer_wwnn = bottom->plogi_payload.wwnn;
522 fc_host_port_type(shost) = FC_PORTTYPE_PTP;
524 case FSF_TOPO_FABRIC:
525 fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
528 fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
531 dev_err(&adapter->ccw_device->dev,
532 "Unknown or unsupported arbitrated loop "
533 "fibre channel topology detected\n");
534 zfcp_erp_adapter_shutdown(adapter, 0, "fsece_1", req);
541 static void zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *req)
543 struct zfcp_adapter *adapter = req->adapter;
544 struct fsf_qtcb *qtcb = req->qtcb;
545 struct fsf_qtcb_bottom_config *bottom = &qtcb->bottom.config;
546 struct Scsi_Host *shost = adapter->scsi_host;
548 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
551 adapter->fsf_lic_version = bottom->lic_version;
552 adapter->adapter_features = bottom->adapter_features;
553 adapter->connection_features = bottom->connection_features;
554 adapter->peer_wwpn = 0;
555 adapter->peer_wwnn = 0;
556 adapter->peer_d_id = 0;
558 switch (qtcb->header.fsf_status) {
560 if (zfcp_fsf_exchange_config_evaluate(req))
563 if (bottom->max_qtcb_size < sizeof(struct fsf_qtcb)) {
564 dev_err(&adapter->ccw_device->dev,
565 "FCP adapter maximum QTCB size (%d bytes) "
567 bottom->max_qtcb_size);
568 zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh1", req);
571 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
574 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
575 fc_host_node_name(shost) = 0;
576 fc_host_port_name(shost) = 0;
577 fc_host_port_id(shost) = 0;
578 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
579 fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
580 adapter->hydra_version = 0;
582 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
585 zfcp_fsf_link_down_info_eval(req, "fsecdh2",
586 &qtcb->header.fsf_status_qual.link_down_info);
589 zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh3", req);
593 if (adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT) {
594 adapter->hardware_version = bottom->hardware_version;
595 memcpy(fc_host_serial_number(shost), bottom->serial_number,
596 min(FC_SERIAL_NUMBER_SIZE, 17));
597 EBCASC(fc_host_serial_number(shost),
598 min(FC_SERIAL_NUMBER_SIZE, 17));
601 if (FSF_QTCB_CURRENT_VERSION < bottom->low_qtcb_version) {
602 dev_err(&adapter->ccw_device->dev,
603 "The FCP adapter only supports newer "
604 "control block versions\n");
605 zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh4", req);
608 if (FSF_QTCB_CURRENT_VERSION > bottom->high_qtcb_version) {
609 dev_err(&adapter->ccw_device->dev,
610 "The FCP adapter only supports older "
611 "control block versions\n");
612 zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh5", req);
616 static void zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *req)
618 struct zfcp_adapter *adapter = req->adapter;
619 struct fsf_qtcb_bottom_port *bottom = &req->qtcb->bottom.port;
620 struct Scsi_Host *shost = adapter->scsi_host;
623 memcpy(req->data, bottom, sizeof(*bottom));
625 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) {
626 fc_host_permanent_port_name(shost) = bottom->wwpn;
627 fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
629 fc_host_permanent_port_name(shost) = fc_host_port_name(shost);
630 fc_host_maxframe_size(shost) = bottom->maximum_frame_size;
631 fc_host_supported_speeds(shost) = bottom->supported_speed;
634 static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req)
636 struct fsf_qtcb *qtcb = req->qtcb;
638 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
641 switch (qtcb->header.fsf_status) {
643 zfcp_fsf_exchange_port_evaluate(req);
645 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
646 zfcp_fsf_exchange_port_evaluate(req);
647 zfcp_fsf_link_down_info_eval(req, "fsepdh1",
648 &qtcb->header.fsf_status_qual.link_down_info);
653 static int zfcp_fsf_sbal_check(struct zfcp_adapter *adapter)
655 struct zfcp_qdio_queue *req_q = &adapter->req_q;
657 spin_lock_bh(&adapter->req_q_lock);
658 if (atomic_read(&req_q->count))
660 spin_unlock_bh(&adapter->req_q_lock);
664 static int zfcp_fsf_req_sbal_get(struct zfcp_adapter *adapter)
668 spin_unlock_bh(&adapter->req_q_lock);
669 ret = wait_event_interruptible_timeout(adapter->request_wq,
670 zfcp_fsf_sbal_check(adapter), 5 * HZ);
674 atomic_inc(&adapter->qdio_outb_full);
676 spin_lock_bh(&adapter->req_q_lock);
680 static struct zfcp_fsf_req *zfcp_fsf_alloc_noqtcb(mempool_t *pool)
682 struct zfcp_fsf_req *req;
683 req = mempool_alloc(pool, GFP_ATOMIC);
686 memset(req, 0, sizeof(*req));
691 static struct zfcp_fsf_req *zfcp_fsf_alloc_qtcb(mempool_t *pool)
693 struct zfcp_fsf_req_qtcb *qtcb;
696 qtcb = mempool_alloc(pool, GFP_ATOMIC);
698 qtcb = kmem_cache_alloc(zfcp_data.fsf_req_qtcb_cache,
703 memset(qtcb, 0, sizeof(*qtcb));
704 qtcb->fsf_req.qtcb = &qtcb->qtcb;
705 qtcb->fsf_req.pool = pool;
707 return &qtcb->fsf_req;
710 static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_adapter *adapter,
711 u32 fsf_cmd, int req_flags,
714 struct qdio_buffer_element *sbale;
716 struct zfcp_fsf_req *req;
717 struct zfcp_qdio_queue *req_q = &adapter->req_q;
719 if (req_flags & ZFCP_REQ_NO_QTCB)
720 req = zfcp_fsf_alloc_noqtcb(pool);
722 req = zfcp_fsf_alloc_qtcb(pool);
725 return ERR_PTR(-ENOMEM);
727 if (adapter->req_no == 0)
730 INIT_LIST_HEAD(&req->list);
731 init_timer(&req->timer);
732 init_waitqueue_head(&req->completion_wq);
734 req->adapter = adapter;
735 req->fsf_command = fsf_cmd;
736 req->req_id = adapter->req_no;
737 req->sbal_number = 1;
738 req->sbal_first = req_q->first;
739 req->sbal_last = req_q->first;
742 sbale = zfcp_qdio_sbale_req(req);
743 sbale[0].addr = (void *) req->req_id;
744 sbale[0].flags |= SBAL_FLAGS0_COMMAND;
746 if (likely(req->qtcb)) {
747 req->qtcb->prefix.req_seq_no = req->adapter->fsf_req_seq_no;
748 req->qtcb->prefix.req_id = req->req_id;
749 req->qtcb->prefix.ulp_info = 26;
750 req->qtcb->prefix.qtcb_type = fsf_qtcb_type[req->fsf_command];
751 req->qtcb->prefix.qtcb_version = FSF_QTCB_CURRENT_VERSION;
752 req->qtcb->header.req_handle = req->req_id;
753 req->qtcb->header.fsf_command = req->fsf_command;
754 req->seq_no = adapter->fsf_req_seq_no;
755 req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no;
756 sbale[1].addr = (void *) req->qtcb;
757 sbale[1].length = sizeof(struct fsf_qtcb);
760 if (!(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) {
761 zfcp_fsf_req_free(req);
762 return ERR_PTR(-EIO);
765 if (likely(req_flags & ZFCP_REQ_AUTO_CLEANUP))
766 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
771 static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
773 struct zfcp_adapter *adapter = req->adapter;
776 int with_qtcb = (req->qtcb != NULL);
778 /* put allocated FSF request into hash table */
779 spin_lock_irqsave(&adapter->req_list_lock, flags);
780 idx = zfcp_reqlist_hash(req->req_id);
781 list_add_tail(&req->list, &adapter->req_list[idx]);
782 spin_unlock_irqrestore(&adapter->req_list_lock, flags);
784 req->qdio_outb_usage = atomic_read(&adapter->req_q.count);
785 req->issued = get_clock();
786 if (zfcp_qdio_send(req)) {
787 del_timer(&req->timer);
788 spin_lock_irqsave(&adapter->req_list_lock, flags);
789 /* lookup request again, list might have changed */
790 if (zfcp_reqlist_find_safe(adapter, req))
791 zfcp_reqlist_remove(adapter, req);
792 spin_unlock_irqrestore(&adapter->req_list_lock, flags);
793 zfcp_erp_adapter_reopen(adapter, 0, "fsrs__1", req);
797 /* Don't increase for unsolicited status */
799 adapter->fsf_req_seq_no++;
806 * zfcp_fsf_status_read - send status read request
807 * @adapter: pointer to struct zfcp_adapter
808 * @req_flags: request flags
809 * Returns: 0 on success, ERROR otherwise
811 int zfcp_fsf_status_read(struct zfcp_adapter *adapter)
813 struct zfcp_fsf_req *req;
814 struct fsf_status_read_buffer *sr_buf;
815 struct qdio_buffer_element *sbale;
818 spin_lock_bh(&adapter->req_q_lock);
819 if (zfcp_fsf_req_sbal_get(adapter))
822 req = zfcp_fsf_req_create(adapter, FSF_QTCB_UNSOLICITED_STATUS,
824 adapter->pool.fsf_req_status_read);
826 retval = PTR_ERR(req);
830 sbale = zfcp_qdio_sbale_req(req);
831 sbale[0].flags |= SBAL_FLAGS0_TYPE_STATUS;
832 sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY;
835 sr_buf = mempool_alloc(adapter->pool.data_status_read, GFP_ATOMIC);
840 memset(sr_buf, 0, sizeof(*sr_buf));
842 sbale = zfcp_qdio_sbale_curr(req);
843 sbale->addr = (void *) sr_buf;
844 sbale->length = sizeof(*sr_buf);
846 retval = zfcp_fsf_req_send(req);
848 goto failed_req_send;
853 mempool_free(sr_buf, adapter->pool.data_status_read);
855 zfcp_fsf_req_free(req);
856 zfcp_hba_dbf_event_fsf_unsol("fail", adapter, NULL);
858 spin_unlock_bh(&adapter->req_q_lock);
862 static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
864 struct zfcp_unit *unit = req->data;
865 union fsf_status_qual *fsq = &req->qtcb->header.fsf_status_qual;
867 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
870 switch (req->qtcb->header.fsf_status) {
871 case FSF_PORT_HANDLE_NOT_VALID:
872 if (fsq->word[0] == fsq->word[1]) {
873 zfcp_erp_adapter_reopen(unit->port->adapter, 0,
875 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
878 case FSF_LUN_HANDLE_NOT_VALID:
879 if (fsq->word[0] == fsq->word[1]) {
880 zfcp_erp_port_reopen(unit->port, 0, "fsafch2", req);
881 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
884 case FSF_FCP_COMMAND_DOES_NOT_EXIST:
885 req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED;
888 zfcp_erp_port_boxed(unit->port, "fsafch3", req);
889 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
890 ZFCP_STATUS_FSFREQ_RETRY;
893 zfcp_erp_unit_boxed(unit, "fsafch4", req);
894 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
895 ZFCP_STATUS_FSFREQ_RETRY;
897 case FSF_ADAPTER_STATUS_AVAILABLE:
898 switch (fsq->word[0]) {
899 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
900 zfcp_test_link(unit->port);
902 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
903 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
908 req->status |= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED;
914 * zfcp_fsf_abort_fcp_command - abort running SCSI command
915 * @old_req_id: unsigned long
916 * @unit: pointer to struct zfcp_unit
917 * Returns: pointer to struct zfcp_fsf_req
920 struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
921 struct zfcp_unit *unit)
923 struct qdio_buffer_element *sbale;
924 struct zfcp_fsf_req *req = NULL;
925 struct zfcp_adapter *adapter = unit->port->adapter;
927 spin_lock_bh(&adapter->req_q_lock);
928 if (zfcp_fsf_req_sbal_get(adapter))
930 req = zfcp_fsf_req_create(adapter, FSF_QTCB_ABORT_FCP_CMND,
931 0, adapter->pool.fsf_req_abort);
937 if (unlikely(!(atomic_read(&unit->status) &
938 ZFCP_STATUS_COMMON_UNBLOCKED)))
941 sbale = zfcp_qdio_sbale_req(req);
942 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
943 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
946 req->handler = zfcp_fsf_abort_fcp_command_handler;
947 req->qtcb->header.lun_handle = unit->handle;
948 req->qtcb->header.port_handle = unit->port->handle;
949 req->qtcb->bottom.support.req_handle = (u64) old_req_id;
951 zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT);
952 if (!zfcp_fsf_req_send(req))
956 zfcp_fsf_req_free(req);
959 spin_unlock_bh(&adapter->req_q_lock);
963 static void zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *req)
965 struct zfcp_adapter *adapter = req->adapter;
966 struct zfcp_send_ct *send_ct = req->data;
967 struct fsf_qtcb_header *header = &req->qtcb->header;
969 send_ct->status = -EINVAL;
971 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
974 switch (header->fsf_status) {
976 zfcp_san_dbf_event_ct_response(req);
979 case FSF_SERVICE_CLASS_NOT_SUPPORTED:
980 zfcp_fsf_class_not_supp(req);
982 case FSF_ADAPTER_STATUS_AVAILABLE:
983 switch (header->fsf_status_qual.word[0]){
984 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
985 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
986 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
990 case FSF_ACCESS_DENIED:
993 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
994 ZFCP_STATUS_FSFREQ_RETRY;
996 case FSF_PORT_HANDLE_NOT_VALID:
997 zfcp_erp_adapter_reopen(adapter, 0, "fsscth1", req);
999 case FSF_GENERIC_COMMAND_REJECTED:
1000 case FSF_PAYLOAD_SIZE_MISMATCH:
1001 case FSF_REQUEST_SIZE_TOO_LARGE:
1002 case FSF_RESPONSE_SIZE_TOO_LARGE:
1003 case FSF_SBAL_MISMATCH:
1004 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1009 if (send_ct->handler)
1010 send_ct->handler(send_ct->handler_data);
1013 static void zfcp_fsf_setup_ct_els_unchained(struct qdio_buffer_element *sbale,
1014 struct scatterlist *sg_req,
1015 struct scatterlist *sg_resp)
1017 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ;
1018 sbale[2].addr = sg_virt(sg_req);
1019 sbale[2].length = sg_req->length;
1020 sbale[3].addr = sg_virt(sg_resp);
1021 sbale[3].length = sg_resp->length;
1022 sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
1025 static int zfcp_fsf_one_sbal(struct scatterlist *sg)
1027 return sg_is_last(sg) && sg->length <= PAGE_SIZE;
1030 static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
1031 struct scatterlist *sg_req,
1032 struct scatterlist *sg_resp,
1035 struct qdio_buffer_element *sbale = zfcp_qdio_sbale_req(req);
1036 u32 feat = req->adapter->adapter_features;
1039 if (!(feat & FSF_FEATURE_ELS_CT_CHAINED_SBALS)) {
1040 if (!zfcp_fsf_one_sbal(sg_req) || !zfcp_fsf_one_sbal(sg_resp))
1043 zfcp_fsf_setup_ct_els_unchained(sbale, sg_req, sg_resp);
1047 /* use single, unchained SBAL if it can hold the request */
1048 if (zfcp_fsf_one_sbal(sg_req) && zfcp_fsf_one_sbal(sg_resp)) {
1049 zfcp_fsf_setup_ct_els_unchained(sbale, sg_req, sg_resp);
1053 bytes = zfcp_qdio_sbals_from_sg(req, SBAL_FLAGS0_TYPE_WRITE_READ,
1057 req->qtcb->bottom.support.req_buf_length = bytes;
1058 req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
1060 bytes = zfcp_qdio_sbals_from_sg(req, SBAL_FLAGS0_TYPE_WRITE_READ,
1061 sg_resp, max_sbals);
1064 req->qtcb->bottom.support.resp_buf_length = bytes;
1070 * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS)
1071 * @ct: pointer to struct zfcp_send_ct with data for request
1072 * @pool: if non-null this mempool is used to allocate struct zfcp_fsf_req
1073 * @erp_action: if non-null the Generic Service request sent within ERP
1075 int zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
1076 struct zfcp_erp_action *erp_action)
1078 struct zfcp_wka_port *wka_port = ct->wka_port;
1079 struct zfcp_adapter *adapter = wka_port->adapter;
1080 struct zfcp_fsf_req *req;
1083 spin_lock_bh(&adapter->req_q_lock);
1084 if (zfcp_fsf_req_sbal_get(adapter))
1087 req = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_GENERIC,
1088 ZFCP_REQ_AUTO_CLEANUP, pool);
1094 ret = zfcp_fsf_setup_ct_els_sbals(req, ct->req, ct->resp,
1095 FSF_MAX_SBALS_PER_REQ);
1099 req->handler = zfcp_fsf_send_ct_handler;
1100 req->qtcb->header.port_handle = wka_port->handle;
1101 req->qtcb->bottom.support.service_class = FSF_CLASS_3;
1102 req->qtcb->bottom.support.timeout = ct->timeout;
1105 zfcp_san_dbf_event_ct_request(req);
1108 erp_action->fsf_req = req;
1109 req->erp_action = erp_action;
1110 zfcp_fsf_start_erp_timer(req);
1112 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
1114 ret = zfcp_fsf_req_send(req);
1121 zfcp_fsf_req_free(req);
1123 erp_action->fsf_req = NULL;
1125 spin_unlock_bh(&adapter->req_q_lock);
1129 static void zfcp_fsf_send_els_handler(struct zfcp_fsf_req *req)
1131 struct zfcp_send_els *send_els = req->data;
1132 struct zfcp_port *port = send_els->port;
1133 struct fsf_qtcb_header *header = &req->qtcb->header;
1135 send_els->status = -EINVAL;
1137 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1138 goto skip_fsfstatus;
1140 switch (header->fsf_status) {
1142 zfcp_san_dbf_event_els_response(req);
1143 send_els->status = 0;
1145 case FSF_SERVICE_CLASS_NOT_SUPPORTED:
1146 zfcp_fsf_class_not_supp(req);
1148 case FSF_ADAPTER_STATUS_AVAILABLE:
1149 switch (header->fsf_status_qual.word[0]){
1150 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
1151 if (port && (send_els->ls_code != ZFCP_LS_ADISC))
1152 zfcp_test_link(port);
1154 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
1155 case FSF_SQ_RETRY_IF_POSSIBLE:
1156 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1160 case FSF_ELS_COMMAND_REJECTED:
1161 case FSF_PAYLOAD_SIZE_MISMATCH:
1162 case FSF_REQUEST_SIZE_TOO_LARGE:
1163 case FSF_RESPONSE_SIZE_TOO_LARGE:
1165 case FSF_ACCESS_DENIED:
1167 zfcp_fsf_access_denied_port(req, port);
1169 case FSF_SBAL_MISMATCH:
1170 /* should never occure, avoided in zfcp_fsf_send_els */
1173 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1177 if (send_els->handler)
1178 send_els->handler(send_els->handler_data);
1182 * zfcp_fsf_send_els - initiate an ELS command (FC-FS)
1183 * @els: pointer to struct zfcp_send_els with data for the command
1185 int zfcp_fsf_send_els(struct zfcp_send_els *els)
1187 struct zfcp_fsf_req *req;
1188 struct zfcp_adapter *adapter = els->adapter;
1189 struct fsf_qtcb_bottom_support *bottom;
1192 spin_lock_bh(&adapter->req_q_lock);
1193 if (zfcp_fsf_req_sbal_get(adapter))
1195 req = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_ELS,
1196 ZFCP_REQ_AUTO_CLEANUP, NULL);
1202 ret = zfcp_fsf_setup_ct_els_sbals(req, els->req, els->resp, 2);
1207 bottom = &req->qtcb->bottom.support;
1208 req->handler = zfcp_fsf_send_els_handler;
1209 bottom->d_id = els->d_id;
1210 bottom->service_class = FSF_CLASS_3;
1211 bottom->timeout = 2 * R_A_TOV;
1214 zfcp_san_dbf_event_els_request(req);
1216 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
1217 ret = zfcp_fsf_req_send(req);
1224 zfcp_fsf_req_free(req);
1226 spin_unlock_bh(&adapter->req_q_lock);
1230 int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1232 struct qdio_buffer_element *sbale;
1233 struct zfcp_fsf_req *req;
1234 struct zfcp_adapter *adapter = erp_action->adapter;
1237 spin_lock_bh(&adapter->req_q_lock);
1238 if (zfcp_fsf_req_sbal_get(adapter))
1240 req = zfcp_fsf_req_create(adapter,
1241 FSF_QTCB_EXCHANGE_CONFIG_DATA,
1242 ZFCP_REQ_AUTO_CLEANUP,
1243 adapter->pool.fsf_req_erp);
1245 retval = PTR_ERR(req);
1249 sbale = zfcp_qdio_sbale_req(req);
1250 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1251 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1253 req->qtcb->bottom.config.feature_selection =
1255 FSF_FEATURE_LUN_SHARING |
1256 FSF_FEATURE_NOTIFICATION_LOST |
1257 FSF_FEATURE_UPDATE_ALERT;
1258 req->erp_action = erp_action;
1259 req->handler = zfcp_fsf_exchange_config_data_handler;
1260 erp_action->fsf_req = req;
1262 zfcp_fsf_start_erp_timer(req);
1263 retval = zfcp_fsf_req_send(req);
1265 zfcp_fsf_req_free(req);
1266 erp_action->fsf_req = NULL;
1269 spin_unlock_bh(&adapter->req_q_lock);
1273 int zfcp_fsf_exchange_config_data_sync(struct zfcp_adapter *adapter,
1274 struct fsf_qtcb_bottom_config *data)
1276 struct qdio_buffer_element *sbale;
1277 struct zfcp_fsf_req *req = NULL;
1280 spin_lock_bh(&adapter->req_q_lock);
1281 if (zfcp_fsf_req_sbal_get(adapter))
1284 req = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_CONFIG_DATA,
1287 retval = PTR_ERR(req);
1291 sbale = zfcp_qdio_sbale_req(req);
1292 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1293 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1294 req->handler = zfcp_fsf_exchange_config_data_handler;
1296 req->qtcb->bottom.config.feature_selection =
1298 FSF_FEATURE_LUN_SHARING |
1299 FSF_FEATURE_NOTIFICATION_LOST |
1300 FSF_FEATURE_UPDATE_ALERT;
1305 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
1306 retval = zfcp_fsf_req_send(req);
1307 spin_unlock_bh(&adapter->req_q_lock);
1309 wait_event(req->completion_wq,
1310 req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
1312 zfcp_fsf_req_free(req);
1316 spin_unlock_bh(&adapter->req_q_lock);
1321 * zfcp_fsf_exchange_port_data - request information about local port
1322 * @erp_action: ERP action for the adapter for which port data is requested
1323 * Returns: 0 on success, error otherwise
1325 int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
1327 struct qdio_buffer_element *sbale;
1328 struct zfcp_fsf_req *req;
1329 struct zfcp_adapter *adapter = erp_action->adapter;
1332 if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT))
1335 spin_lock_bh(&adapter->req_q_lock);
1336 if (zfcp_fsf_req_sbal_get(adapter))
1338 req = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA,
1339 ZFCP_REQ_AUTO_CLEANUP,
1340 adapter->pool.fsf_req_erp);
1342 retval = PTR_ERR(req);
1346 sbale = zfcp_qdio_sbale_req(req);
1347 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1348 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1350 req->handler = zfcp_fsf_exchange_port_data_handler;
1351 req->erp_action = erp_action;
1352 erp_action->fsf_req = req;
1354 zfcp_fsf_start_erp_timer(req);
1355 retval = zfcp_fsf_req_send(req);
1357 zfcp_fsf_req_free(req);
1358 erp_action->fsf_req = NULL;
1361 spin_unlock_bh(&adapter->req_q_lock);
1366 * zfcp_fsf_exchange_port_data_sync - request information about local port
1367 * @adapter: pointer to struct zfcp_adapter
1368 * @data: pointer to struct fsf_qtcb_bottom_port
1369 * Returns: 0 on success, error otherwise
1371 int zfcp_fsf_exchange_port_data_sync(struct zfcp_adapter *adapter,
1372 struct fsf_qtcb_bottom_port *data)
1374 struct qdio_buffer_element *sbale;
1375 struct zfcp_fsf_req *req = NULL;
1378 if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT))
1381 spin_lock_bh(&adapter->req_q_lock);
1382 if (zfcp_fsf_req_sbal_get(adapter))
1385 req = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA, 0,
1388 retval = PTR_ERR(req);
1395 sbale = zfcp_qdio_sbale_req(req);
1396 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1397 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1399 req->handler = zfcp_fsf_exchange_port_data_handler;
1400 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
1401 retval = zfcp_fsf_req_send(req);
1402 spin_unlock_bh(&adapter->req_q_lock);
1405 wait_event(req->completion_wq,
1406 req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
1407 zfcp_fsf_req_free(req);
1412 spin_unlock_bh(&adapter->req_q_lock);
1416 static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req)
1418 struct zfcp_port *port = req->data;
1419 struct fsf_qtcb_header *header = &req->qtcb->header;
1420 struct fsf_plogi *plogi;
1422 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1425 switch (header->fsf_status) {
1426 case FSF_PORT_ALREADY_OPEN:
1428 case FSF_ACCESS_DENIED:
1429 zfcp_fsf_access_denied_port(req, port);
1431 case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
1432 dev_warn(&req->adapter->ccw_device->dev,
1433 "Not enough FCP adapter resources to open "
1434 "remote port 0x%016Lx\n",
1435 (unsigned long long)port->wwpn);
1436 zfcp_erp_port_failed(port, "fsoph_1", req);
1437 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1439 case FSF_ADAPTER_STATUS_AVAILABLE:
1440 switch (header->fsf_status_qual.word[0]) {
1441 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
1442 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
1443 case FSF_SQ_NO_RETRY_POSSIBLE:
1444 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1449 port->handle = header->port_handle;
1450 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN |
1451 ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
1452 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED |
1453 ZFCP_STATUS_COMMON_ACCESS_BOXED,
1455 /* check whether D_ID has changed during open */
1457 * FIXME: This check is not airtight, as the FCP channel does
1458 * not monitor closures of target port connections caused on
1459 * the remote side. Thus, they might miss out on invalidating
1460 * locally cached WWPNs (and other N_Port parameters) of gone
1461 * target ports. So, our heroic attempt to make things safe
1462 * could be undermined by 'open port' response data tagged with
1463 * obsolete WWPNs. Another reason to monitor potential
1464 * connection closures ourself at least (by interpreting
1465 * incoming ELS' and unsolicited status). It just crosses my
1466 * mind that one should be able to cross-check by means of
1467 * another GID_PN straight after a port has been opened.
1468 * Alternately, an ADISC/PDISC ELS should suffice, as well.
1470 plogi = (struct fsf_plogi *) req->qtcb->bottom.support.els;
1471 if (req->qtcb->bottom.support.els1_length >=
1472 FSF_PLOGI_MIN_LEN) {
1473 if (plogi->serv_param.wwpn != port->wwpn)
1476 port->wwnn = plogi->serv_param.wwnn;
1477 zfcp_fc_plogi_evaluate(port, plogi);
1481 case FSF_UNKNOWN_OP_SUBTYPE:
1482 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1487 zfcp_port_put(port);
1491 * zfcp_fsf_open_port - create and send open port request
1492 * @erp_action: pointer to struct zfcp_erp_action
1493 * Returns: 0 on success, error otherwise
1495 int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
1497 struct qdio_buffer_element *sbale;
1498 struct zfcp_adapter *adapter = erp_action->adapter;
1499 struct zfcp_fsf_req *req;
1500 struct zfcp_port *port = erp_action->port;
1503 spin_lock_bh(&adapter->req_q_lock);
1504 if (zfcp_fsf_req_sbal_get(adapter))
1507 req = zfcp_fsf_req_create(adapter,
1508 FSF_QTCB_OPEN_PORT_WITH_DID,
1509 ZFCP_REQ_AUTO_CLEANUP,
1510 adapter->pool.fsf_req_erp);
1512 retval = PTR_ERR(req);
1516 sbale = zfcp_qdio_sbale_req(req);
1517 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1518 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1520 req->handler = zfcp_fsf_open_port_handler;
1521 req->qtcb->bottom.support.d_id = port->d_id;
1523 req->erp_action = erp_action;
1524 erp_action->fsf_req = req;
1525 zfcp_port_get(port);
1527 zfcp_fsf_start_erp_timer(req);
1528 retval = zfcp_fsf_req_send(req);
1530 zfcp_fsf_req_free(req);
1531 erp_action->fsf_req = NULL;
1532 zfcp_port_put(port);
1535 spin_unlock_bh(&adapter->req_q_lock);
1539 static void zfcp_fsf_close_port_handler(struct zfcp_fsf_req *req)
1541 struct zfcp_port *port = req->data;
1543 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1546 switch (req->qtcb->header.fsf_status) {
1547 case FSF_PORT_HANDLE_NOT_VALID:
1548 zfcp_erp_adapter_reopen(port->adapter, 0, "fscph_1", req);
1549 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1551 case FSF_ADAPTER_STATUS_AVAILABLE:
1554 zfcp_erp_modify_port_status(port, "fscph_2", req,
1555 ZFCP_STATUS_COMMON_OPEN,
1562 * zfcp_fsf_close_port - create and send close port request
1563 * @erp_action: pointer to struct zfcp_erp_action
1564 * Returns: 0 on success, error otherwise
1566 int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
1568 struct qdio_buffer_element *sbale;
1569 struct zfcp_adapter *adapter = erp_action->adapter;
1570 struct zfcp_fsf_req *req;
1573 spin_lock_bh(&adapter->req_q_lock);
1574 if (zfcp_fsf_req_sbal_get(adapter))
1577 req = zfcp_fsf_req_create(adapter, FSF_QTCB_CLOSE_PORT,
1578 ZFCP_REQ_AUTO_CLEANUP,
1579 adapter->pool.fsf_req_erp);
1581 retval = PTR_ERR(req);
1585 sbale = zfcp_qdio_sbale_req(req);
1586 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1587 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1589 req->handler = zfcp_fsf_close_port_handler;
1590 req->data = erp_action->port;
1591 req->erp_action = erp_action;
1592 req->qtcb->header.port_handle = erp_action->port->handle;
1593 erp_action->fsf_req = req;
1595 zfcp_fsf_start_erp_timer(req);
1596 retval = zfcp_fsf_req_send(req);
1598 zfcp_fsf_req_free(req);
1599 erp_action->fsf_req = NULL;
1602 spin_unlock_bh(&adapter->req_q_lock);
1606 static void zfcp_fsf_open_wka_port_handler(struct zfcp_fsf_req *req)
1608 struct zfcp_wka_port *wka_port = req->data;
1609 struct fsf_qtcb_header *header = &req->qtcb->header;
1611 if (req->status & ZFCP_STATUS_FSFREQ_ERROR) {
1612 wka_port->status = ZFCP_WKA_PORT_OFFLINE;
1616 switch (header->fsf_status) {
1617 case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
1618 dev_warn(&req->adapter->ccw_device->dev,
1619 "Opening WKA port 0x%x failed\n", wka_port->d_id);
1621 case FSF_ADAPTER_STATUS_AVAILABLE:
1622 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1624 case FSF_ACCESS_DENIED:
1625 wka_port->status = ZFCP_WKA_PORT_OFFLINE;
1627 case FSF_PORT_ALREADY_OPEN:
1630 wka_port->handle = header->port_handle;
1631 wka_port->status = ZFCP_WKA_PORT_ONLINE;
1634 wake_up(&wka_port->completion_wq);
1638 * zfcp_fsf_open_wka_port - create and send open wka-port request
1639 * @wka_port: pointer to struct zfcp_wka_port
1640 * Returns: 0 on success, error otherwise
1642 int zfcp_fsf_open_wka_port(struct zfcp_wka_port *wka_port)
1644 struct qdio_buffer_element *sbale;
1645 struct zfcp_adapter *adapter = wka_port->adapter;
1646 struct zfcp_fsf_req *req;
1649 spin_lock_bh(&adapter->req_q_lock);
1650 if (zfcp_fsf_req_sbal_get(adapter))
1653 req = zfcp_fsf_req_create(adapter,
1654 FSF_QTCB_OPEN_PORT_WITH_DID,
1655 ZFCP_REQ_AUTO_CLEANUP,
1656 adapter->pool.fsf_req_erp);
1657 if (unlikely(IS_ERR(req))) {
1658 retval = PTR_ERR(req);
1662 sbale = zfcp_qdio_sbale_req(req);
1663 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1664 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1666 req->handler = zfcp_fsf_open_wka_port_handler;
1667 req->qtcb->bottom.support.d_id = wka_port->d_id;
1668 req->data = wka_port;
1670 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
1671 retval = zfcp_fsf_req_send(req);
1673 zfcp_fsf_req_free(req);
1675 spin_unlock_bh(&adapter->req_q_lock);
1679 static void zfcp_fsf_close_wka_port_handler(struct zfcp_fsf_req *req)
1681 struct zfcp_wka_port *wka_port = req->data;
1683 if (req->qtcb->header.fsf_status == FSF_PORT_HANDLE_NOT_VALID) {
1684 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1685 zfcp_erp_adapter_reopen(wka_port->adapter, 0, "fscwph1", req);
1688 wka_port->status = ZFCP_WKA_PORT_OFFLINE;
1689 wake_up(&wka_port->completion_wq);
1693 * zfcp_fsf_close_wka_port - create and send close wka port request
1694 * @erp_action: pointer to struct zfcp_erp_action
1695 * Returns: 0 on success, error otherwise
1697 int zfcp_fsf_close_wka_port(struct zfcp_wka_port *wka_port)
1699 struct qdio_buffer_element *sbale;
1700 struct zfcp_adapter *adapter = wka_port->adapter;
1701 struct zfcp_fsf_req *req;
1704 spin_lock_bh(&adapter->req_q_lock);
1705 if (zfcp_fsf_req_sbal_get(adapter))
1708 req = zfcp_fsf_req_create(adapter, FSF_QTCB_CLOSE_PORT,
1709 ZFCP_REQ_AUTO_CLEANUP,
1710 adapter->pool.fsf_req_erp);
1711 if (unlikely(IS_ERR(req))) {
1712 retval = PTR_ERR(req);
1716 sbale = zfcp_qdio_sbale_req(req);
1717 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1718 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1720 req->handler = zfcp_fsf_close_wka_port_handler;
1721 req->data = wka_port;
1722 req->qtcb->header.port_handle = wka_port->handle;
1724 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
1725 retval = zfcp_fsf_req_send(req);
1727 zfcp_fsf_req_free(req);
1729 spin_unlock_bh(&adapter->req_q_lock);
1733 static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req)
1735 struct zfcp_port *port = req->data;
1736 struct fsf_qtcb_header *header = &req->qtcb->header;
1737 struct zfcp_unit *unit;
1739 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1742 switch (header->fsf_status) {
1743 case FSF_PORT_HANDLE_NOT_VALID:
1744 zfcp_erp_adapter_reopen(port->adapter, 0, "fscpph1", req);
1745 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1747 case FSF_ACCESS_DENIED:
1748 zfcp_fsf_access_denied_port(req, port);
1750 case FSF_PORT_BOXED:
1751 /* can't use generic zfcp_erp_modify_port_status because
1752 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port */
1753 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
1754 list_for_each_entry(unit, &port->unit_list_head, list)
1755 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN,
1757 zfcp_erp_port_boxed(port, "fscpph2", req);
1758 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
1759 ZFCP_STATUS_FSFREQ_RETRY;
1762 case FSF_ADAPTER_STATUS_AVAILABLE:
1763 switch (header->fsf_status_qual.word[0]) {
1764 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
1766 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
1767 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1772 /* can't use generic zfcp_erp_modify_port_status because
1773 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port
1775 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
1776 list_for_each_entry(unit, &port->unit_list_head, list)
1777 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN,
1784 * zfcp_fsf_close_physical_port - close physical port
1785 * @erp_action: pointer to struct zfcp_erp_action
1786 * Returns: 0 on success
1788 int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
1790 struct qdio_buffer_element *sbale;
1791 struct zfcp_adapter *adapter = erp_action->adapter;
1792 struct zfcp_fsf_req *req;
1795 spin_lock_bh(&adapter->req_q_lock);
1796 if (zfcp_fsf_req_sbal_get(adapter))
1799 req = zfcp_fsf_req_create(adapter, FSF_QTCB_CLOSE_PHYSICAL_PORT,
1800 ZFCP_REQ_AUTO_CLEANUP,
1801 adapter->pool.fsf_req_erp);
1803 retval = PTR_ERR(req);
1807 sbale = zfcp_qdio_sbale_req(req);
1808 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1809 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1811 req->data = erp_action->port;
1812 req->qtcb->header.port_handle = erp_action->port->handle;
1813 req->erp_action = erp_action;
1814 req->handler = zfcp_fsf_close_physical_port_handler;
1815 erp_action->fsf_req = req;
1817 zfcp_fsf_start_erp_timer(req);
1818 retval = zfcp_fsf_req_send(req);
1820 zfcp_fsf_req_free(req);
1821 erp_action->fsf_req = NULL;
1824 spin_unlock_bh(&adapter->req_q_lock);
1828 static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1830 struct zfcp_adapter *adapter = req->adapter;
1831 struct zfcp_unit *unit = req->data;
1832 struct fsf_qtcb_header *header = &req->qtcb->header;
1833 struct fsf_qtcb_bottom_support *bottom = &req->qtcb->bottom.support;
1834 struct fsf_queue_designator *queue_designator =
1835 &header->fsf_status_qual.fsf_queue_designator;
1836 int exclusive, readwrite;
1838 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1841 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED |
1842 ZFCP_STATUS_COMMON_ACCESS_BOXED |
1843 ZFCP_STATUS_UNIT_SHARED |
1844 ZFCP_STATUS_UNIT_READONLY,
1847 switch (header->fsf_status) {
1849 case FSF_PORT_HANDLE_NOT_VALID:
1850 zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fsouh_1", req);
1852 case FSF_LUN_ALREADY_OPEN:
1854 case FSF_ACCESS_DENIED:
1855 zfcp_fsf_access_denied_unit(req, unit);
1856 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status);
1857 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);
1859 case FSF_PORT_BOXED:
1860 zfcp_erp_port_boxed(unit->port, "fsouh_2", req);
1861 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
1862 ZFCP_STATUS_FSFREQ_RETRY;
1864 case FSF_LUN_SHARING_VIOLATION:
1865 if (header->fsf_status_qual.word[0])
1866 dev_warn(&adapter->ccw_device->dev,
1867 "LUN 0x%Lx on port 0x%Lx is already in "
1868 "use by CSS%d, MIF Image ID %x\n",
1869 (unsigned long long)unit->fcp_lun,
1870 (unsigned long long)unit->port->wwpn,
1871 queue_designator->cssid,
1872 queue_designator->hla);
1874 zfcp_act_eval_err(adapter,
1875 header->fsf_status_qual.word[2]);
1876 zfcp_erp_unit_access_denied(unit, "fsouh_3", req);
1877 atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status);
1878 atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);
1879 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1881 case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED:
1882 dev_warn(&adapter->ccw_device->dev,
1883 "No handle is available for LUN "
1884 "0x%016Lx on port 0x%016Lx\n",
1885 (unsigned long long)unit->fcp_lun,
1886 (unsigned long long)unit->port->wwpn);
1887 zfcp_erp_unit_failed(unit, "fsouh_4", req);
1889 case FSF_INVALID_COMMAND_OPTION:
1890 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1892 case FSF_ADAPTER_STATUS_AVAILABLE:
1893 switch (header->fsf_status_qual.word[0]) {
1894 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
1895 zfcp_test_link(unit->port);
1897 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
1898 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1904 unit->handle = header->lun_handle;
1905 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
1907 if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE) &&
1908 (adapter->adapter_features & FSF_FEATURE_LUN_SHARING) &&
1909 !zfcp_ccw_priv_sch(adapter)) {
1910 exclusive = (bottom->lun_access_info &
1911 FSF_UNIT_ACCESS_EXCLUSIVE);
1912 readwrite = (bottom->lun_access_info &
1913 FSF_UNIT_ACCESS_OUTBOUND_TRANSFER);
1916 atomic_set_mask(ZFCP_STATUS_UNIT_SHARED,
1920 atomic_set_mask(ZFCP_STATUS_UNIT_READONLY,
1922 dev_info(&adapter->ccw_device->dev,
1923 "SCSI device at LUN 0x%016Lx on port "
1924 "0x%016Lx opened read-only\n",
1925 (unsigned long long)unit->fcp_lun,
1926 (unsigned long long)unit->port->wwpn);
1929 if (exclusive && !readwrite) {
1930 dev_err(&adapter->ccw_device->dev,
1931 "Exclusive read-only access not "
1932 "supported (unit 0x%016Lx, "
1934 (unsigned long long)unit->fcp_lun,
1935 (unsigned long long)unit->port->wwpn);
1936 zfcp_erp_unit_failed(unit, "fsouh_5", req);
1937 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1938 zfcp_erp_unit_shutdown(unit, 0, "fsouh_6", req);
1939 } else if (!exclusive && readwrite) {
1940 dev_err(&adapter->ccw_device->dev,
1941 "Shared read-write access not "
1942 "supported (unit 0x%016Lx, port "
1944 (unsigned long long)unit->fcp_lun,
1945 (unsigned long long)unit->port->wwpn);
1946 zfcp_erp_unit_failed(unit, "fsouh_7", req);
1947 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1948 zfcp_erp_unit_shutdown(unit, 0, "fsouh_8", req);
1956 * zfcp_fsf_open_unit - open unit
1957 * @erp_action: pointer to struct zfcp_erp_action
1958 * Returns: 0 on success, error otherwise
1960 int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
1962 struct qdio_buffer_element *sbale;
1963 struct zfcp_adapter *adapter = erp_action->adapter;
1964 struct zfcp_fsf_req *req;
1967 spin_lock_bh(&adapter->req_q_lock);
1968 if (zfcp_fsf_req_sbal_get(adapter))
1971 req = zfcp_fsf_req_create(adapter, FSF_QTCB_OPEN_LUN,
1972 ZFCP_REQ_AUTO_CLEANUP,
1973 adapter->pool.fsf_req_erp);
1975 retval = PTR_ERR(req);
1979 sbale = zfcp_qdio_sbale_req(req);
1980 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1981 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1983 req->qtcb->header.port_handle = erp_action->port->handle;
1984 req->qtcb->bottom.support.fcp_lun = erp_action->unit->fcp_lun;
1985 req->handler = zfcp_fsf_open_unit_handler;
1986 req->data = erp_action->unit;
1987 req->erp_action = erp_action;
1988 erp_action->fsf_req = req;
1990 if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE))
1991 req->qtcb->bottom.support.option = FSF_OPEN_LUN_SUPPRESS_BOXING;
1993 zfcp_fsf_start_erp_timer(req);
1994 retval = zfcp_fsf_req_send(req);
1996 zfcp_fsf_req_free(req);
1997 erp_action->fsf_req = NULL;
2000 spin_unlock_bh(&adapter->req_q_lock);
2004 static void zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *req)
2006 struct zfcp_unit *unit = req->data;
2008 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
2011 switch (req->qtcb->header.fsf_status) {
2012 case FSF_PORT_HANDLE_NOT_VALID:
2013 zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fscuh_1", req);
2014 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2016 case FSF_LUN_HANDLE_NOT_VALID:
2017 zfcp_erp_port_reopen(unit->port, 0, "fscuh_2", req);
2018 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2020 case FSF_PORT_BOXED:
2021 zfcp_erp_port_boxed(unit->port, "fscuh_3", req);
2022 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
2023 ZFCP_STATUS_FSFREQ_RETRY;
2025 case FSF_ADAPTER_STATUS_AVAILABLE:
2026 switch (req->qtcb->header.fsf_status_qual.word[0]) {
2027 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
2028 zfcp_test_link(unit->port);
2030 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
2031 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2036 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
2042 * zfcp_fsf_close_unit - close zfcp unit
2043 * @erp_action: pointer to struct zfcp_unit
2044 * Returns: 0 on success, error otherwise
2046 int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
2048 struct qdio_buffer_element *sbale;
2049 struct zfcp_adapter *adapter = erp_action->adapter;
2050 struct zfcp_fsf_req *req;
2053 spin_lock_bh(&adapter->req_q_lock);
2054 if (zfcp_fsf_req_sbal_get(adapter))
2056 req = zfcp_fsf_req_create(adapter, FSF_QTCB_CLOSE_LUN,
2057 ZFCP_REQ_AUTO_CLEANUP,
2058 adapter->pool.fsf_req_erp);
2060 retval = PTR_ERR(req);
2064 sbale = zfcp_qdio_sbale_req(req);
2065 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2066 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2068 req->qtcb->header.port_handle = erp_action->port->handle;
2069 req->qtcb->header.lun_handle = erp_action->unit->handle;
2070 req->handler = zfcp_fsf_close_unit_handler;
2071 req->data = erp_action->unit;
2072 req->erp_action = erp_action;
2073 erp_action->fsf_req = req;
2075 zfcp_fsf_start_erp_timer(req);
2076 retval = zfcp_fsf_req_send(req);
2078 zfcp_fsf_req_free(req);
2079 erp_action->fsf_req = NULL;
2082 spin_unlock_bh(&adapter->req_q_lock);
2086 static void zfcp_fsf_update_lat(struct fsf_latency_record *lat_rec, u32 lat)
2088 lat_rec->sum += lat;
2089 lat_rec->min = min(lat_rec->min, lat);
2090 lat_rec->max = max(lat_rec->max, lat);
2093 static void zfcp_fsf_req_latency(struct zfcp_fsf_req *req)
2095 struct fsf_qual_latency_info *lat_inf;
2096 struct latency_cont *lat;
2097 struct zfcp_unit *unit = req->unit;
2099 lat_inf = &req->qtcb->prefix.prot_status_qual.latency_info;
2101 switch (req->qtcb->bottom.io.data_direction) {
2102 case FSF_DATADIR_READ:
2103 lat = &unit->latencies.read;
2105 case FSF_DATADIR_WRITE:
2106 lat = &unit->latencies.write;
2108 case FSF_DATADIR_CMND:
2109 lat = &unit->latencies.cmd;
2115 spin_lock(&unit->latencies.lock);
2116 zfcp_fsf_update_lat(&lat->channel, lat_inf->channel_lat);
2117 zfcp_fsf_update_lat(&lat->fabric, lat_inf->fabric_lat);
2119 spin_unlock(&unit->latencies.lock);
2122 #ifdef CONFIG_BLK_DEV_IO_TRACE
2123 static void zfcp_fsf_trace_latency(struct zfcp_fsf_req *fsf_req)
2125 struct fsf_qual_latency_info *lat_inf;
2126 struct scsi_cmnd *scsi_cmnd = (struct scsi_cmnd *)fsf_req->data;
2127 struct request *req = scsi_cmnd->request;
2128 struct zfcp_blk_drv_data trace;
2129 int ticks = fsf_req->adapter->timer_ticks;
2132 trace.magic = ZFCP_BLK_DRV_DATA_MAGIC;
2133 if (fsf_req->adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA) {
2134 trace.flags |= ZFCP_BLK_LAT_VALID;
2135 lat_inf = &fsf_req->qtcb->prefix.prot_status_qual.latency_info;
2136 trace.channel_lat = lat_inf->channel_lat * ticks;
2137 trace.fabric_lat = lat_inf->fabric_lat * ticks;
2139 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
2140 trace.flags |= ZFCP_BLK_REQ_ERROR;
2141 trace.inb_usage = fsf_req->qdio_inb_usage;
2142 trace.outb_usage = fsf_req->qdio_outb_usage;
2144 blk_add_driver_data(req->q, req, &trace, sizeof(trace));
2147 static inline void zfcp_fsf_trace_latency(struct zfcp_fsf_req *fsf_req)
2152 static void zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *req)
2154 struct scsi_cmnd *scpnt;
2155 struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *)
2156 &(req->qtcb->bottom.io.fcp_rsp);
2158 char *fcp_rsp_info = (unsigned char *) &fcp_rsp_iu[1];
2159 unsigned long flags;
2161 read_lock_irqsave(&req->adapter->abort_lock, flags);
2164 if (unlikely(!scpnt)) {
2165 read_unlock_irqrestore(&req->adapter->abort_lock, flags);
2169 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ABORTED)) {
2170 set_host_byte(scpnt, DID_SOFT_ERROR);
2171 goto skip_fsfstatus;
2174 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
2175 set_host_byte(scpnt, DID_ERROR);
2176 goto skip_fsfstatus;
2179 set_msg_byte(scpnt, COMMAND_COMPLETE);
2181 scpnt->result |= fcp_rsp_iu->scsi_status;
2183 if (req->adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA)
2184 zfcp_fsf_req_latency(req);
2186 zfcp_fsf_trace_latency(req);
2188 if (unlikely(fcp_rsp_iu->validity.bits.fcp_rsp_len_valid)) {
2189 if (fcp_rsp_info[3] == RSP_CODE_GOOD)
2190 set_host_byte(scpnt, DID_OK);
2192 set_host_byte(scpnt, DID_ERROR);
2193 goto skip_fsfstatus;
2197 if (unlikely(fcp_rsp_iu->validity.bits.fcp_sns_len_valid)) {
2198 sns_len = FSF_FCP_RSP_SIZE - sizeof(struct fcp_rsp_iu) +
2199 fcp_rsp_iu->fcp_rsp_len;
2200 sns_len = min(sns_len, (u32) SCSI_SENSE_BUFFERSIZE);
2201 sns_len = min(sns_len, fcp_rsp_iu->fcp_sns_len);
2203 memcpy(scpnt->sense_buffer,
2204 zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu), sns_len);
2207 if (unlikely(fcp_rsp_iu->validity.bits.fcp_resid_under)) {
2208 scsi_set_resid(scpnt, fcp_rsp_iu->fcp_resid);
2209 if (scsi_bufflen(scpnt) - scsi_get_resid(scpnt) <
2211 set_host_byte(scpnt, DID_ERROR);
2214 if (scpnt->result != 0)
2215 zfcp_scsi_dbf_event_result("erro", 3, req->adapter, scpnt, req);
2216 else if (scpnt->retries > 0)
2217 zfcp_scsi_dbf_event_result("retr", 4, req->adapter, scpnt, req);
2219 zfcp_scsi_dbf_event_result("norm", 6, req->adapter, scpnt, req);
2221 scpnt->host_scribble = NULL;
2222 (scpnt->scsi_done) (scpnt);
2224 * We must hold this lock until scsi_done has been called.
2225 * Otherwise we may call scsi_done after abort regarding this
2226 * command has completed.
2227 * Note: scsi_done must not block!
2229 read_unlock_irqrestore(&req->adapter->abort_lock, flags);
2232 static void zfcp_fsf_send_fcp_ctm_handler(struct zfcp_fsf_req *req)
2234 struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *)
2235 &(req->qtcb->bottom.io.fcp_rsp);
2236 char *fcp_rsp_info = (unsigned char *) &fcp_rsp_iu[1];
2238 if ((fcp_rsp_info[3] != RSP_CODE_GOOD) ||
2239 (req->status & ZFCP_STATUS_FSFREQ_ERROR))
2240 req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED;
2244 static void zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *req)
2246 struct zfcp_unit *unit;
2247 struct fsf_qtcb_header *header = &req->qtcb->header;
2249 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT))
2254 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR))
2255 goto skip_fsfstatus;
2257 switch (header->fsf_status) {
2258 case FSF_HANDLE_MISMATCH:
2259 case FSF_PORT_HANDLE_NOT_VALID:
2260 zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fssfch1", req);
2261 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2263 case FSF_FCPLUN_NOT_VALID:
2264 case FSF_LUN_HANDLE_NOT_VALID:
2265 zfcp_erp_port_reopen(unit->port, 0, "fssfch2", req);
2266 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2268 case FSF_SERVICE_CLASS_NOT_SUPPORTED:
2269 zfcp_fsf_class_not_supp(req);
2271 case FSF_ACCESS_DENIED:
2272 zfcp_fsf_access_denied_unit(req, unit);
2274 case FSF_DIRECTION_INDICATOR_NOT_VALID:
2275 dev_err(&req->adapter->ccw_device->dev,
2276 "Incorrect direction %d, unit 0x%016Lx on port "
2277 "0x%016Lx closed\n",
2278 req->qtcb->bottom.io.data_direction,
2279 (unsigned long long)unit->fcp_lun,
2280 (unsigned long long)unit->port->wwpn);
2281 zfcp_erp_adapter_shutdown(unit->port->adapter, 0, "fssfch3",
2283 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2285 case FSF_CMND_LENGTH_NOT_VALID:
2286 dev_err(&req->adapter->ccw_device->dev,
2287 "Incorrect CDB length %d, unit 0x%016Lx on "
2288 "port 0x%016Lx closed\n",
2289 req->qtcb->bottom.io.fcp_cmnd_length,
2290 (unsigned long long)unit->fcp_lun,
2291 (unsigned long long)unit->port->wwpn);
2292 zfcp_erp_adapter_shutdown(unit->port->adapter, 0, "fssfch4",
2294 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2296 case FSF_PORT_BOXED:
2297 zfcp_erp_port_boxed(unit->port, "fssfch5", req);
2298 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
2299 ZFCP_STATUS_FSFREQ_RETRY;
2302 zfcp_erp_unit_boxed(unit, "fssfch6", req);
2303 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
2304 ZFCP_STATUS_FSFREQ_RETRY;
2306 case FSF_ADAPTER_STATUS_AVAILABLE:
2307 if (header->fsf_status_qual.word[0] ==
2308 FSF_SQ_INVOKE_LINK_TEST_PROCEDURE)
2309 zfcp_test_link(unit->port);
2310 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2314 if (req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT)
2315 zfcp_fsf_send_fcp_ctm_handler(req);
2317 zfcp_fsf_send_fcp_command_task_handler(req);
2319 zfcp_unit_put(unit);
2323 static void zfcp_set_fcp_dl(struct fcp_cmnd_iu *fcp_cmd, u32 fcp_dl)
2328 * fcp_dl_addr = start address of fcp_cmnd structure +
2329 * size of fixed part + size of dynamically sized add_dcp_cdb field
2330 * SEE FCP-2 documentation
2332 fcp_dl_ptr = (u32 *) ((unsigned char *) &fcp_cmd[1] +
2333 (fcp_cmd->add_fcp_cdb_length << 2));
2334 *fcp_dl_ptr = fcp_dl;
2338 * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command)
2339 * @unit: unit where command is sent to
2340 * @scsi_cmnd: scsi command to be sent
2342 int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
2343 struct scsi_cmnd *scsi_cmnd)
2345 struct zfcp_fsf_req *req;
2346 struct fcp_cmnd_iu *fcp_cmnd_iu;
2347 unsigned int sbtype = SBAL_FLAGS0_TYPE_READ;
2348 int real_bytes, retval = -EIO;
2349 struct zfcp_adapter *adapter = unit->port->adapter;
2351 if (unlikely(!(atomic_read(&unit->status) &
2352 ZFCP_STATUS_COMMON_UNBLOCKED)))
2355 spin_lock(&adapter->req_q_lock);
2356 if (atomic_read(&adapter->req_q.count) <= 0) {
2357 atomic_inc(&adapter->qdio_outb_full);
2360 req = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND,
2361 ZFCP_REQ_AUTO_CLEANUP,
2362 adapter->pool.fsf_req_scsi);
2364 retval = PTR_ERR(req);
2368 zfcp_unit_get(unit);
2370 req->data = scsi_cmnd;
2371 req->handler = zfcp_fsf_send_fcp_command_handler;
2372 req->qtcb->header.lun_handle = unit->handle;
2373 req->qtcb->header.port_handle = unit->port->handle;
2374 req->qtcb->bottom.io.service_class = FSF_CLASS_3;
2376 scsi_cmnd->host_scribble = (unsigned char *) req->req_id;
2378 fcp_cmnd_iu = (struct fcp_cmnd_iu *) &(req->qtcb->bottom.io.fcp_cmnd);
2379 fcp_cmnd_iu->fcp_lun = unit->fcp_lun;
2381 * set depending on data direction:
2382 * data direction bits in SBALE (SB Type)
2383 * data direction bits in QTCB
2384 * data direction bits in FCP_CMND IU
2386 switch (scsi_cmnd->sc_data_direction) {
2388 req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
2390 case DMA_FROM_DEVICE:
2391 req->qtcb->bottom.io.data_direction = FSF_DATADIR_READ;
2392 fcp_cmnd_iu->rddata = 1;
2395 req->qtcb->bottom.io.data_direction = FSF_DATADIR_WRITE;
2396 sbtype = SBAL_FLAGS0_TYPE_WRITE;
2397 fcp_cmnd_iu->wddata = 1;
2399 case DMA_BIDIRECTIONAL:
2400 goto failed_scsi_cmnd;
2403 if (likely((scsi_cmnd->device->simple_tags) ||
2404 ((atomic_read(&unit->status) & ZFCP_STATUS_UNIT_READONLY) &&
2405 (atomic_read(&unit->status) & ZFCP_STATUS_UNIT_SHARED))))
2406 fcp_cmnd_iu->task_attribute = SIMPLE_Q;
2408 fcp_cmnd_iu->task_attribute = UNTAGGED;
2410 if (unlikely(scsi_cmnd->cmd_len > FCP_CDB_LENGTH))
2411 fcp_cmnd_iu->add_fcp_cdb_length =
2412 (scsi_cmnd->cmd_len - FCP_CDB_LENGTH) >> 2;
2414 memcpy(fcp_cmnd_iu->fcp_cdb, scsi_cmnd->cmnd, scsi_cmnd->cmd_len);
2416 req->qtcb->bottom.io.fcp_cmnd_length = sizeof(struct fcp_cmnd_iu) +
2417 fcp_cmnd_iu->add_fcp_cdb_length + sizeof(u32);
2419 real_bytes = zfcp_qdio_sbals_from_sg(req, sbtype,
2420 scsi_sglist(scsi_cmnd),
2421 FSF_MAX_SBALS_PER_REQ);
2422 if (unlikely(real_bytes < 0)) {
2423 if (req->sbal_number >= FSF_MAX_SBALS_PER_REQ) {
2424 dev_err(&adapter->ccw_device->dev,
2425 "Oversize data package, unit 0x%016Lx "
2426 "on port 0x%016Lx closed\n",
2427 (unsigned long long)unit->fcp_lun,
2428 (unsigned long long)unit->port->wwpn);
2429 zfcp_erp_unit_shutdown(unit, 0, "fssfct1", req);
2432 goto failed_scsi_cmnd;
2435 zfcp_set_fcp_dl(fcp_cmnd_iu, real_bytes);
2437 retval = zfcp_fsf_req_send(req);
2438 if (unlikely(retval))
2439 goto failed_scsi_cmnd;
2444 zfcp_unit_put(unit);
2445 zfcp_fsf_req_free(req);
2446 scsi_cmnd->host_scribble = NULL;
2448 spin_unlock(&adapter->req_q_lock);
2453 * zfcp_fsf_send_fcp_ctm - send SCSI task management command
2454 * @unit: pointer to struct zfcp_unit
2455 * @tm_flags: unsigned byte for task management flags
2456 * Returns: on success pointer to struct fsf_req, NULL otherwise
2458 struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags)
2460 struct qdio_buffer_element *sbale;
2461 struct zfcp_fsf_req *req = NULL;
2462 struct fcp_cmnd_iu *fcp_cmnd_iu;
2463 struct zfcp_adapter *adapter = unit->port->adapter;
2465 if (unlikely(!(atomic_read(&unit->status) &
2466 ZFCP_STATUS_COMMON_UNBLOCKED)))
2469 spin_lock_bh(&adapter->req_q_lock);
2470 if (zfcp_fsf_req_sbal_get(adapter))
2472 req = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, 0,
2473 adapter->pool.fsf_req_scsi);
2479 req->status |= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT;
2481 req->handler = zfcp_fsf_send_fcp_command_handler;
2482 req->qtcb->header.lun_handle = unit->handle;
2483 req->qtcb->header.port_handle = unit->port->handle;
2484 req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
2485 req->qtcb->bottom.io.service_class = FSF_CLASS_3;
2486 req->qtcb->bottom.io.fcp_cmnd_length = sizeof(struct fcp_cmnd_iu) +
2489 sbale = zfcp_qdio_sbale_req(req);
2490 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE;
2491 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2493 fcp_cmnd_iu = (struct fcp_cmnd_iu *) &req->qtcb->bottom.io.fcp_cmnd;
2494 fcp_cmnd_iu->fcp_lun = unit->fcp_lun;
2495 fcp_cmnd_iu->task_management_flags = tm_flags;
2497 zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT);
2498 if (!zfcp_fsf_req_send(req))
2501 zfcp_fsf_req_free(req);
2504 spin_unlock_bh(&adapter->req_q_lock);
2508 static void zfcp_fsf_control_file_handler(struct zfcp_fsf_req *req)
2513 * zfcp_fsf_control_file - control file upload/download
2514 * @adapter: pointer to struct zfcp_adapter
2515 * @fsf_cfdc: pointer to struct zfcp_fsf_cfdc
2516 * Returns: on success pointer to struct zfcp_fsf_req, NULL otherwise
2518 struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
2519 struct zfcp_fsf_cfdc *fsf_cfdc)
2521 struct qdio_buffer_element *sbale;
2522 struct zfcp_fsf_req *req = NULL;
2523 struct fsf_qtcb_bottom_support *bottom;
2524 int direction, retval = -EIO, bytes;
2526 if (!(adapter->adapter_features & FSF_FEATURE_CFDC))
2527 return ERR_PTR(-EOPNOTSUPP);
2529 switch (fsf_cfdc->command) {
2530 case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
2531 direction = SBAL_FLAGS0_TYPE_WRITE;
2533 case FSF_QTCB_UPLOAD_CONTROL_FILE:
2534 direction = SBAL_FLAGS0_TYPE_READ;
2537 return ERR_PTR(-EINVAL);
2540 spin_lock_bh(&adapter->req_q_lock);
2541 if (zfcp_fsf_req_sbal_get(adapter))
2544 req = zfcp_fsf_req_create(adapter, fsf_cfdc->command, 0, NULL);
2550 req->handler = zfcp_fsf_control_file_handler;
2552 sbale = zfcp_qdio_sbale_req(req);
2553 sbale[0].flags |= direction;
2555 bottom = &req->qtcb->bottom.support;
2556 bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE;
2557 bottom->option = fsf_cfdc->option;
2559 bytes = zfcp_qdio_sbals_from_sg(req, direction, fsf_cfdc->sg,
2560 FSF_MAX_SBALS_PER_REQ);
2561 if (bytes != ZFCP_CFDC_MAX_SIZE) {
2562 zfcp_fsf_req_free(req);
2566 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
2567 retval = zfcp_fsf_req_send(req);
2569 spin_unlock_bh(&adapter->req_q_lock);
2572 wait_event(req->completion_wq,
2573 req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
2576 return ERR_PTR(retval);