Lines Matching +full:scan +full:- +full:delay +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0
17 #include <linux/bsg-lib.h>
40 "upper limit of port scan random backoff in msecs (default 500)");
59 adapter->next_port_scan = jiffies + interval + backoff; in zfcp_fc_port_scan_time()
65 unsigned long next = adapter->next_port_scan; in zfcp_fc_port_scan()
66 unsigned long delay = 0, max; in zfcp_fc_port_scan() local
68 /* delay only needed within waiting period */ in zfcp_fc_port_scan()
70 delay = next - now; in zfcp_fc_port_scan()
71 /* paranoia: never ever delay scans longer than specified */ in zfcp_fc_port_scan()
73 delay = min(delay, max); in zfcp_fc_port_scan()
76 queue_delayed_work(adapter->work_queue, &adapter->scan_work, delay); in zfcp_fc_port_scan()
96 * zfcp_fc_post_event - post event to userspace via fc_transport
108 spin_lock_bh(&events->list_lock); in zfcp_fc_post_event()
109 list_splice_init(&events->list, &tmp_lh); in zfcp_fc_post_event()
110 spin_unlock_bh(&events->list_lock); in zfcp_fc_post_event()
113 fc_host_post_event(adapter->scsi_host, fc_get_event_number(), in zfcp_fc_post_event()
114 event->code, event->data); in zfcp_fc_post_event()
115 list_del(&event->list); in zfcp_fc_post_event()
121 * zfcp_fc_enqueue_event - safely enqueue FC HBA API event from irq context
136 event->code = event_code; in zfcp_fc_enqueue_event()
137 event->data = event_data; in zfcp_fc_enqueue_event()
139 spin_lock(&adapter->events.list_lock); in zfcp_fc_enqueue_event()
140 list_add_tail(&event->list, &adapter->events.list); in zfcp_fc_enqueue_event()
141 spin_unlock(&adapter->events.list_lock); in zfcp_fc_enqueue_event()
143 queue_work(adapter->work_queue, &adapter->events.work); in zfcp_fc_enqueue_event()
148 int ret = -EIO; in zfcp_fc_wka_port_get()
150 if (mutex_lock_interruptible(&wka_port->mutex)) in zfcp_fc_wka_port_get()
151 return -ERESTARTSYS; in zfcp_fc_wka_port_get()
153 if (wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE || in zfcp_fc_wka_port_get()
154 wka_port->status == ZFCP_FC_WKA_PORT_CLOSING) { in zfcp_fc_wka_port_get()
155 wka_port->status = ZFCP_FC_WKA_PORT_OPENING; in zfcp_fc_wka_port_get()
158 wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; in zfcp_fc_wka_port_get()
163 wait_event(wka_port->opened, in zfcp_fc_wka_port_get()
164 wka_port->status == ZFCP_FC_WKA_PORT_ONLINE || in zfcp_fc_wka_port_get()
165 wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE); in zfcp_fc_wka_port_get()
167 if (wka_port->status == ZFCP_FC_WKA_PORT_ONLINE) { in zfcp_fc_wka_port_get()
168 atomic_inc(&wka_port->refcount); in zfcp_fc_wka_port_get()
173 mutex_unlock(&wka_port->mutex); in zfcp_fc_wka_port_get()
183 mutex_lock(&wka_port->mutex); in zfcp_fc_wka_port_offline()
184 if ((atomic_read(&wka_port->refcount) != 0) || in zfcp_fc_wka_port_offline()
185 (wka_port->status != ZFCP_FC_WKA_PORT_ONLINE)) in zfcp_fc_wka_port_offline()
188 wka_port->status = ZFCP_FC_WKA_PORT_CLOSING; in zfcp_fc_wka_port_offline()
191 wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; in zfcp_fc_wka_port_offline()
194 wait_event(wka_port->closed, in zfcp_fc_wka_port_offline()
195 wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE); in zfcp_fc_wka_port_offline()
197 mutex_unlock(&wka_port->mutex); in zfcp_fc_wka_port_offline()
202 if (atomic_dec_return(&wka_port->refcount) != 0) in zfcp_fc_wka_port_put()
205 queue_delayed_work(wka_port->adapter->work_queue, &wka_port->work, in zfcp_fc_wka_port_put()
212 init_waitqueue_head(&wka_port->opened); in zfcp_fc_wka_port_init()
213 init_waitqueue_head(&wka_port->closed); in zfcp_fc_wka_port_init()
215 wka_port->adapter = adapter; in zfcp_fc_wka_port_init()
216 wka_port->d_id = d_id; in zfcp_fc_wka_port_init()
218 wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; in zfcp_fc_wka_port_init()
219 atomic_set(&wka_port->refcount, 0); in zfcp_fc_wka_port_init()
220 mutex_init(&wka_port->mutex); in zfcp_fc_wka_port_init()
221 INIT_DELAYED_WORK(&wka_port->work, zfcp_fc_wka_port_offline); in zfcp_fc_wka_port_init()
226 cancel_delayed_work_sync(&wka->work); in zfcp_fc_wka_port_force_offline()
227 mutex_lock(&wka->mutex); in zfcp_fc_wka_port_force_offline()
228 wka->status = ZFCP_FC_WKA_PORT_OFFLINE; in zfcp_fc_wka_port_force_offline()
229 mutex_unlock(&wka->mutex); in zfcp_fc_wka_port_force_offline()
236 zfcp_fc_wka_port_force_offline(&gs->ms); in zfcp_fc_wka_ports_force_offline()
237 zfcp_fc_wka_port_force_offline(&gs->ts); in zfcp_fc_wka_ports_force_offline()
238 zfcp_fc_wka_port_force_offline(&gs->ds); in zfcp_fc_wka_ports_force_offline()
239 zfcp_fc_wka_port_force_offline(&gs->as); in zfcp_fc_wka_ports_force_offline()
246 struct zfcp_adapter *adapter = fsf_req->adapter; in _zfcp_fc_incoming_rscn()
249 read_lock_irqsave(&adapter->port_list_lock, flags); in _zfcp_fc_incoming_rscn()
250 list_for_each_entry(port, &adapter->port_list, list) { in _zfcp_fc_incoming_rscn()
251 if ((port->d_id & range) == (ntoh24(page->rscn_fid) & range)) in _zfcp_fc_incoming_rscn()
254 read_unlock_irqrestore(&adapter->port_list_lock, flags); in _zfcp_fc_incoming_rscn()
259 struct fsf_status_read_buffer *status_buffer = (void *)fsf_req->data; in zfcp_fc_incoming_rscn()
260 struct zfcp_adapter *adapter = fsf_req->adapter; in zfcp_fc_incoming_rscn()
267 head = (struct fc_els_rscn *) status_buffer->payload.data; in zfcp_fc_incoming_rscn()
270 /* see FC-FS */ in zfcp_fc_incoming_rscn()
271 no_entries = be16_to_cpu(head->rscn_plen) / in zfcp_fc_incoming_rscn()
279 read_lock_irqsave(&adapter->port_list_lock, flags); in zfcp_fc_incoming_rscn()
280 list_for_each_entry(port, &adapter->port_list, list) { in zfcp_fc_incoming_rscn()
281 if (port->d_id) in zfcp_fc_incoming_rscn()
287 read_unlock_irqrestore(&adapter->port_list_lock, flags); in zfcp_fc_incoming_rscn()
293 afmt = page->rscn_page_flags & ELS_RSCN_ADDR_FMT_MASK; in zfcp_fc_incoming_rscn()
296 zfcp_fc_enqueue_event(fsf_req->adapter, FCH_EVT_RSCN, in zfcp_fc_incoming_rscn()
299 zfcp_fc_conditional_port_scan(fsf_req->adapter); in zfcp_fc_incoming_rscn()
305 struct zfcp_adapter *adapter = req->adapter; in zfcp_fc_incoming_wwpn()
308 read_lock_irqsave(&adapter->port_list_lock, flags); in zfcp_fc_incoming_wwpn()
309 list_for_each_entry(port, &adapter->port_list, list) in zfcp_fc_incoming_wwpn()
310 if (port->wwpn == wwpn) { in zfcp_fc_incoming_wwpn()
314 read_unlock_irqrestore(&adapter->port_list_lock, flags); in zfcp_fc_incoming_wwpn()
322 status_buffer = (struct fsf_status_read_buffer *) req->data; in zfcp_fc_incoming_plogi()
323 plogi = (struct fc_els_flogi *) status_buffer->payload.data; in zfcp_fc_incoming_plogi()
324 zfcp_fc_incoming_wwpn(req, be64_to_cpu(plogi->fl_wwpn)); in zfcp_fc_incoming_plogi()
330 (struct fsf_status_read_buffer *)req->data; in zfcp_fc_incoming_logo()
332 (struct fc_els_logo *) status_buffer->payload.data; in zfcp_fc_incoming_logo()
334 zfcp_fc_incoming_wwpn(req, be64_to_cpu(logo->fl_n_port_wwn)); in zfcp_fc_incoming_logo()
338 * zfcp_fc_incoming_els - handle incoming ELS
344 (struct fsf_status_read_buffer *) fsf_req->data; in zfcp_fc_incoming_els()
345 unsigned int els_type = status_buffer->payload.data[0]; in zfcp_fc_incoming_els()
358 struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els; in zfcp_fc_ns_gid_pn_eval()
359 struct zfcp_fc_gid_pn_rsp *gid_pn_rsp = &fc_req->u.gid_pn.rsp; in zfcp_fc_ns_gid_pn_eval()
361 if (ct_els->status) in zfcp_fc_ns_gid_pn_eval()
363 if (gid_pn_rsp->ct_hdr.ct_cmd != cpu_to_be16(FC_FS_ACC)) in zfcp_fc_ns_gid_pn_eval()
367 ct_els->port->d_id = ntoh24(gid_pn_rsp->gid_pn.fp_fid); in zfcp_fc_ns_gid_pn_eval()
377 ct_hdr->ct_rev = FC_CT_REV; in zfcp_fc_ct_ns_init()
378 ct_hdr->ct_fs_type = FC_FST_DIR; in zfcp_fc_ct_ns_init()
379 ct_hdr->ct_fs_subtype = FC_NS_SUBTYPE; in zfcp_fc_ct_ns_init()
380 ct_hdr->ct_cmd = cpu_to_be16(cmd); in zfcp_fc_ct_ns_init()
381 ct_hdr->ct_mr_size = cpu_to_be16(mr_size / 4); in zfcp_fc_ct_ns_init()
387 struct zfcp_adapter *adapter = port->adapter; in zfcp_fc_ns_gid_pn_request()
389 struct zfcp_fc_gid_pn_req *gid_pn_req = &fc_req->u.gid_pn.req; in zfcp_fc_ns_gid_pn_request()
390 struct zfcp_fc_gid_pn_rsp *gid_pn_rsp = &fc_req->u.gid_pn.rsp; in zfcp_fc_ns_gid_pn_request()
394 fc_req->ct_els.port = port; in zfcp_fc_ns_gid_pn_request()
395 fc_req->ct_els.handler = zfcp_fc_complete; in zfcp_fc_ns_gid_pn_request()
396 fc_req->ct_els.handler_data = &completion; in zfcp_fc_ns_gid_pn_request()
397 fc_req->ct_els.req = &fc_req->sg_req; in zfcp_fc_ns_gid_pn_request()
398 fc_req->ct_els.resp = &fc_req->sg_rsp; in zfcp_fc_ns_gid_pn_request()
399 sg_init_one(&fc_req->sg_req, gid_pn_req, sizeof(*gid_pn_req)); in zfcp_fc_ns_gid_pn_request()
400 sg_init_one(&fc_req->sg_rsp, gid_pn_rsp, sizeof(*gid_pn_rsp)); in zfcp_fc_ns_gid_pn_request()
402 zfcp_fc_ct_ns_init(&gid_pn_req->ct_hdr, in zfcp_fc_ns_gid_pn_request()
404 gid_pn_req->gid_pn.fn_wwpn = cpu_to_be64(port->wwpn); in zfcp_fc_ns_gid_pn_request()
406 ret = zfcp_fsf_send_ct(&adapter->gs->ds, &fc_req->ct_els, in zfcp_fc_ns_gid_pn_request()
407 adapter->pool.gid_pn_req, in zfcp_fc_ns_gid_pn_request()
417 * zfcp_fc_ns_gid_pn - initiate GID_PN nameserver request
419 * return: -ENOMEM on error, 0 otherwise
425 struct zfcp_adapter *adapter = port->adapter; in zfcp_fc_ns_gid_pn()
427 fc_req = mempool_alloc(adapter->pool.gid_pn, GFP_ATOMIC); in zfcp_fc_ns_gid_pn()
429 return -ENOMEM; in zfcp_fc_ns_gid_pn()
433 ret = zfcp_fc_wka_port_get(&adapter->gs->ds); in zfcp_fc_ns_gid_pn()
439 zfcp_fc_wka_port_put(&adapter->gs->ds); in zfcp_fc_ns_gid_pn()
441 mempool_free(fc_req, adapter->pool.gid_pn); in zfcp_fc_ns_gid_pn()
451 set_worker_desc("zgidpn%16llx", port->wwpn); /* < WORKER_DESC_LEN=24 */ in zfcp_fc_port_did_lookup()
455 zfcp_erp_adapter_reopen(port->adapter, 0, "fcgpn_1"); in zfcp_fc_port_did_lookup()
459 if (!port->d_id) { in zfcp_fc_port_did_lookup()
466 put_device(&port->dev); in zfcp_fc_port_did_lookup()
470 * zfcp_fc_trigger_did_lookup - trigger the d_id lookup using a GID_PN request
475 get_device(&port->dev); in zfcp_fc_trigger_did_lookup()
476 if (!queue_work(port->adapter->work_queue, &port->gid_pn_work)) in zfcp_fc_trigger_did_lookup()
477 put_device(&port->dev); in zfcp_fc_trigger_did_lookup()
481 * zfcp_fc_plogi_evaluate - evaluate PLOGI playload
489 if (be64_to_cpu(plogi->fl_wwpn) != port->wwpn) { in zfcp_fc_plogi_evaluate()
490 port->d_id = 0; in zfcp_fc_plogi_evaluate()
491 dev_warn(&port->adapter->ccw_device->dev, in zfcp_fc_plogi_evaluate()
494 (unsigned long long) port->wwpn, in zfcp_fc_plogi_evaluate()
495 (unsigned long long) be64_to_cpu(plogi->fl_wwpn)); in zfcp_fc_plogi_evaluate()
499 port->wwnn = be64_to_cpu(plogi->fl_wwnn); in zfcp_fc_plogi_evaluate()
500 port->maxframe_size = be16_to_cpu(plogi->fl_csp.sp_bb_data); in zfcp_fc_plogi_evaluate()
502 if (plogi->fl_cssp[0].cp_class & cpu_to_be16(FC_CPC_VALID)) in zfcp_fc_plogi_evaluate()
503 port->supported_classes |= FC_COS_CLASS1; in zfcp_fc_plogi_evaluate()
504 if (plogi->fl_cssp[1].cp_class & cpu_to_be16(FC_CPC_VALID)) in zfcp_fc_plogi_evaluate()
505 port->supported_classes |= FC_COS_CLASS2; in zfcp_fc_plogi_evaluate()
506 if (plogi->fl_cssp[2].cp_class & cpu_to_be16(FC_CPC_VALID)) in zfcp_fc_plogi_evaluate()
507 port->supported_classes |= FC_COS_CLASS3; in zfcp_fc_plogi_evaluate()
508 if (plogi->fl_cssp[3].cp_class & cpu_to_be16(FC_CPC_VALID)) in zfcp_fc_plogi_evaluate()
509 port->supported_classes |= FC_COS_CLASS4; in zfcp_fc_plogi_evaluate()
515 struct zfcp_port *port = fc_req->ct_els.port; in zfcp_fc_adisc_handler()
516 struct fc_els_adisc *adisc_resp = &fc_req->u.adisc.rsp; in zfcp_fc_adisc_handler()
518 if (fc_req->ct_els.status) { in zfcp_fc_adisc_handler()
525 if (!port->wwnn) in zfcp_fc_adisc_handler()
526 port->wwnn = be64_to_cpu(adisc_resp->adisc_wwnn); in zfcp_fc_adisc_handler()
528 if ((port->wwpn != be64_to_cpu(adisc_resp->adisc_wwpn)) || in zfcp_fc_adisc_handler()
529 !(atomic_read(&port->status) & ZFCP_STATUS_COMMON_OPEN)) { in zfcp_fc_adisc_handler()
535 /* re-init to undo drop from zfcp_fc_adisc() */ in zfcp_fc_adisc_handler()
536 port->d_id = ntoh24(adisc_resp->adisc_port_id); in zfcp_fc_adisc_handler()
539 atomic_andnot(ZFCP_STATUS_PORT_LINK_TEST, &port->status); in zfcp_fc_adisc_handler()
545 put_device(&port->dev); in zfcp_fc_adisc_handler()
552 struct zfcp_adapter *adapter = port->adapter; in zfcp_fc_adisc()
553 struct Scsi_Host *shost = adapter->scsi_host; in zfcp_fc_adisc()
559 return -ENOMEM; in zfcp_fc_adisc()
561 fc_req->ct_els.port = port; in zfcp_fc_adisc()
562 fc_req->ct_els.req = &fc_req->sg_req; in zfcp_fc_adisc()
563 fc_req->ct_els.resp = &fc_req->sg_rsp; in zfcp_fc_adisc()
564 sg_init_one(&fc_req->sg_req, &fc_req->u.adisc.req, in zfcp_fc_adisc()
566 sg_init_one(&fc_req->sg_rsp, &fc_req->u.adisc.rsp, in zfcp_fc_adisc()
569 fc_req->ct_els.handler = zfcp_fc_adisc_handler; in zfcp_fc_adisc()
570 fc_req->ct_els.handler_data = fc_req; in zfcp_fc_adisc()
572 /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports in zfcp_fc_adisc()
573 without FC-AL-2 capability, so we don't set it */ in zfcp_fc_adisc()
574 fc_req->u.adisc.req.adisc_wwpn = cpu_to_be64(fc_host_port_name(shost)); in zfcp_fc_adisc()
575 fc_req->u.adisc.req.adisc_wwnn = cpu_to_be64(fc_host_node_name(shost)); in zfcp_fc_adisc()
576 fc_req->u.adisc.req.adisc_cmd = ELS_ADISC; in zfcp_fc_adisc()
577 hton24(fc_req->u.adisc.req.adisc_port_id, fc_host_port_id(shost)); in zfcp_fc_adisc()
579 d_id = port->d_id; /* remember as destination for send els below */ in zfcp_fc_adisc()
583 * to prevent race with port->d_id re-init in zfcp_fc_adisc_handler(). in zfcp_fc_adisc()
585 port->d_id = 0; in zfcp_fc_adisc()
587 ret = zfcp_fsf_send_els(adapter, d_id, &fc_req->ct_els, in zfcp_fc_adisc()
601 set_worker_desc("zadisc%16llx", port->wwpn); /* < WORKER_DESC_LEN=24 */ in zfcp_fc_link_test_work()
604 if (atomic_read(&port->status) & ZFCP_STATUS_PORT_LINK_TEST) in zfcp_fc_link_test_work()
607 atomic_or(ZFCP_STATUS_PORT_LINK_TEST, &port->status); in zfcp_fc_link_test_work()
614 atomic_andnot(ZFCP_STATUS_PORT_LINK_TEST, &port->status); in zfcp_fc_link_test_work()
618 put_device(&port->dev); in zfcp_fc_link_test_work()
622 * zfcp_fc_test_link - lightweight link test procedure
631 get_device(&port->dev); in zfcp_fc_test_link()
632 if (!queue_work(port->adapter->work_queue, &port->test_link_work)) in zfcp_fc_test_link()
633 put_device(&port->dev); in zfcp_fc_test_link()
637 * zfcp_fc_sg_free_table - free memory used by scatterlists
654 * zfcp_fc_sg_setup_table - init scatterlist and allocate, assign buffers
659 * Returns: 0 on success, -ENOMEM otherwise
671 return -ENOMEM; in zfcp_fc_sg_setup_table()
686 if (zfcp_fc_sg_setup_table(&fc_req->sg_rsp, buf_num)) { in zfcp_fc_alloc_sg_env()
691 sg_init_one(&fc_req->sg_req, &fc_req->u.gpn_ft.req, in zfcp_fc_alloc_sg_env()
700 struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els; in zfcp_fc_send_gpn_ft()
701 struct zfcp_fc_gpn_ft_req *req = &fc_req->u.gpn_ft.req; in zfcp_fc_send_gpn_ft()
705 zfcp_fc_ct_ns_init(&req->ct_hdr, FC_NS_GPN_FT, max_bytes); in zfcp_fc_send_gpn_ft()
706 req->gpn_ft.fn_fc4_type = FC_TYPE_FCP; in zfcp_fc_send_gpn_ft()
708 ct_els->handler = zfcp_fc_complete; in zfcp_fc_send_gpn_ft()
709 ct_els->handler_data = &completion; in zfcp_fc_send_gpn_ft()
710 ct_els->req = &fc_req->sg_req; in zfcp_fc_send_gpn_ft()
711 ct_els->resp = &fc_req->sg_rsp; in zfcp_fc_send_gpn_ft()
713 ret = zfcp_fsf_send_ct(&adapter->gs->ds, ct_els, NULL, in zfcp_fc_send_gpn_ft()
722 if (!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_NOESC)) in zfcp_fc_validate_port()
725 atomic_andnot(ZFCP_STATUS_COMMON_NOESC, &port->status); in zfcp_fc_validate_port()
727 if ((port->supported_classes != 0) || in zfcp_fc_validate_port()
728 !list_empty(&port->unit_list)) in zfcp_fc_validate_port()
731 list_move_tail(&port->list, lh); in zfcp_fc_validate_port()
737 struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els; in zfcp_fc_eval_gpn_ft()
738 struct scatterlist *sg = &fc_req->sg_rsp; in zfcp_fc_eval_gpn_ft()
747 if (ct_els->status) in zfcp_fc_eval_gpn_ft()
748 return -EIO; in zfcp_fc_eval_gpn_ft()
750 if (hdr->ct_cmd != cpu_to_be16(FC_FS_ACC)) { in zfcp_fc_eval_gpn_ft()
751 if (hdr->ct_reason == FC_FS_RJT_UNABL) in zfcp_fc_eval_gpn_ft()
752 return -EAGAIN; /* might be a temporary condition */ in zfcp_fc_eval_gpn_ft()
753 return -EIO; in zfcp_fc_eval_gpn_ft()
756 if (hdr->ct_mr_size) { in zfcp_fc_eval_gpn_ft()
757 dev_warn(&adapter->ccw_device->dev, in zfcp_fc_eval_gpn_ft()
759 hdr->ct_mr_size); in zfcp_fc_eval_gpn_ft()
760 return -E2BIG; in zfcp_fc_eval_gpn_ft()
770 last = acc->fp_flags & FC_NS_FID_LAST; in zfcp_fc_eval_gpn_ft()
771 d_id = ntoh24(acc->fp_fid); in zfcp_fc_eval_gpn_ft()
777 if (be64_to_cpu(acc->fp_wwpn) == in zfcp_fc_eval_gpn_ft()
778 fc_host_port_name(adapter->scsi_host)) in zfcp_fc_eval_gpn_ft()
781 port = zfcp_port_enqueue(adapter, be64_to_cpu(acc->fp_wwpn), in zfcp_fc_eval_gpn_ft()
785 else if (PTR_ERR(port) != -EEXIST) in zfcp_fc_eval_gpn_ft()
790 write_lock_irqsave(&adapter->port_list_lock, flags); in zfcp_fc_eval_gpn_ft()
791 list_for_each_entry_safe(port, tmp, &adapter->port_list, list) in zfcp_fc_eval_gpn_ft()
793 write_unlock_irqrestore(&adapter->port_list_lock, flags); in zfcp_fc_eval_gpn_ft()
797 device_unregister(&port->dev); in zfcp_fc_eval_gpn_ft()
804 * zfcp_fc_scan_ports - scan remote ports and attach new ports
818 chain = adapter->adapter_features & FSF_FEATURE_ELS_CT_CHAINED_SBALS; in zfcp_fc_scan_ports()
823 if (fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPORT && in zfcp_fc_scan_ports()
824 fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPIV) in zfcp_fc_scan_ports()
827 if (zfcp_fc_wka_port_get(&adapter->gs->ds)) in zfcp_fc_scan_ports()
838 if (ret == -EAGAIN) in zfcp_fc_scan_ports()
844 zfcp_fc_sg_free_table(&fc_req->sg_rsp, buf_num); in zfcp_fc_scan_ports()
847 zfcp_fc_wka_port_put(&adapter->gs->ds); in zfcp_fc_scan_ports()
855 struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els; in zfcp_fc_gspn()
856 struct zfcp_fc_gspn_req *gspn_req = &fc_req->u.gspn.req; in zfcp_fc_gspn()
857 struct zfcp_fc_gspn_rsp *gspn_rsp = &fc_req->u.gspn.rsp; in zfcp_fc_gspn()
860 zfcp_fc_ct_ns_init(&gspn_req->ct_hdr, FC_NS_GSPN_ID, in zfcp_fc_gspn()
862 hton24(gspn_req->gspn.fp_fid, fc_host_port_id(adapter->scsi_host)); in zfcp_fc_gspn()
864 sg_init_one(&fc_req->sg_req, gspn_req, sizeof(*gspn_req)); in zfcp_fc_gspn()
865 sg_init_one(&fc_req->sg_rsp, gspn_rsp, sizeof(*gspn_rsp)); in zfcp_fc_gspn()
867 ct_els->handler = zfcp_fc_complete; in zfcp_fc_gspn()
868 ct_els->handler_data = &completion; in zfcp_fc_gspn()
869 ct_els->req = &fc_req->sg_req; in zfcp_fc_gspn()
870 ct_els->resp = &fc_req->sg_rsp; in zfcp_fc_gspn()
872 ret = zfcp_fsf_send_ct(&adapter->gs->ds, ct_els, NULL, in zfcp_fc_gspn()
878 if (ct_els->status) in zfcp_fc_gspn()
879 return ct_els->status; in zfcp_fc_gspn()
881 if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_NPIV && in zfcp_fc_gspn()
882 !(strstr(gspn_rsp->gspn.fp_name, devno))) in zfcp_fc_gspn()
883 snprintf(fc_host_symbolic_name(adapter->scsi_host), in zfcp_fc_gspn()
885 gspn_rsp->gspn.fp_name, devno, in zfcp_fc_gspn()
886 dev_name(&adapter->ccw_device->dev), in zfcp_fc_gspn()
887 init_utsname()->nodename); in zfcp_fc_gspn()
889 strscpy(fc_host_symbolic_name(adapter->scsi_host), in zfcp_fc_gspn()
890 gspn_rsp->gspn.fp_name, FC_SYMBOLIC_NAME_SIZE); in zfcp_fc_gspn()
899 struct Scsi_Host *shost = adapter->scsi_host; in zfcp_fc_rspn()
900 struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els; in zfcp_fc_rspn()
901 struct zfcp_fc_rspn_req *rspn_req = &fc_req->u.rspn.req; in zfcp_fc_rspn()
902 struct fc_ct_hdr *rspn_rsp = &fc_req->u.rspn.rsp; in zfcp_fc_rspn()
905 zfcp_fc_ct_ns_init(&rspn_req->ct_hdr, FC_NS_RSPN_ID, in zfcp_fc_rspn()
907 hton24(rspn_req->rspn.fr_fid.fp_fid, fc_host_port_id(shost)); in zfcp_fc_rspn()
909 BUILD_BUG_ON(sizeof(rspn_req->name) != in zfcp_fc_rspn()
911 BUILD_BUG_ON(sizeof(rspn_req->name) != in zfcp_fc_rspn()
912 type_max(typeof(rspn_req->rspn.fr_name_len)) + 1); in zfcp_fc_rspn()
913 len = strscpy(rspn_req->name, fc_host_symbolic_name(shost), in zfcp_fc_rspn()
914 sizeof(rspn_req->name)); in zfcp_fc_rspn()
920 len = sizeof(rspn_req->name) - 1; in zfcp_fc_rspn()
921 rspn_req->rspn.fr_name_len = len; in zfcp_fc_rspn()
923 sg_init_one(&fc_req->sg_req, rspn_req, sizeof(*rspn_req)); in zfcp_fc_rspn()
924 sg_init_one(&fc_req->sg_rsp, rspn_rsp, sizeof(*rspn_rsp)); in zfcp_fc_rspn()
926 ct_els->handler = zfcp_fc_complete; in zfcp_fc_rspn()
927 ct_els->handler_data = &completion; in zfcp_fc_rspn()
928 ct_els->req = &fc_req->sg_req; in zfcp_fc_rspn()
929 ct_els->resp = &fc_req->sg_rsp; in zfcp_fc_rspn()
931 ret = zfcp_fsf_send_ct(&adapter->gs->ds, ct_els, NULL, in zfcp_fc_rspn()
938 * zfcp_fc_sym_name_update - Retrieve and update the symbolic port name
955 if (fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPORT && in zfcp_fc_sym_name_update()
956 fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPIV) in zfcp_fc_sym_name_update()
963 ret = zfcp_fc_wka_port_get(&adapter->gs->ds); in zfcp_fc_sym_name_update()
968 if (ret || fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPIV) in zfcp_fc_sym_name_update()
975 zfcp_fc_wka_port_put(&adapter->gs->ds); in zfcp_fc_sym_name_update()
983 struct zfcp_fsf_ct_els *zfcp_ct_els = job->dd_data; in zfcp_fc_ct_els_job_handler()
984 struct fc_bsg_reply *jr = job->reply; in zfcp_fc_ct_els_job_handler()
986 jr->reply_payload_rcv_len = job->reply_payload.payload_len; in zfcp_fc_ct_els_job_handler()
987 jr->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK; in zfcp_fc_ct_els_job_handler()
988 jr->result = zfcp_ct_els->status ? -EIO : 0; in zfcp_fc_ct_els_job_handler()
989 bsg_job_done(job, jr->result, jr->reply_payload_rcv_len); in zfcp_fc_ct_els_job_handler()
997 struct fc_bsg_request *bsg_request = job->request; in zfcp_fc_job_wka_port()
1001 preamble_word1 = bsg_request->rqst_data.r_ct.preamble_word1; in zfcp_fc_job_wka_port()
1005 adapter = (struct zfcp_adapter *) shost->hostdata[0]; in zfcp_fc_job_wka_port()
1009 return &adapter->gs->as; in zfcp_fc_job_wka_port()
1011 return &adapter->gs->ms; in zfcp_fc_job_wka_port()
1013 return &adapter->gs->ts; in zfcp_fc_job_wka_port()
1016 return &adapter->gs->ds; in zfcp_fc_job_wka_port()
1037 struct zfcp_fsf_ct_els *els = job->dd_data; in zfcp_fc_exec_els_job()
1039 struct fc_bsg_request *bsg_request = job->request; in zfcp_fc_exec_els_job()
1044 port = zfcp_get_port_by_wwpn(adapter, rport->port_name); in zfcp_fc_exec_els_job()
1046 return -EINVAL; in zfcp_fc_exec_els_job()
1048 d_id = port->d_id; in zfcp_fc_exec_els_job()
1049 put_device(&port->dev); in zfcp_fc_exec_els_job()
1051 d_id = ntoh24(bsg_request->rqst_data.h_els.port_id); in zfcp_fc_exec_els_job()
1053 els->handler = zfcp_fc_ct_els_job_handler; in zfcp_fc_exec_els_job()
1054 return zfcp_fsf_send_els(adapter, d_id, els, job->timeout / HZ); in zfcp_fc_exec_els_job()
1061 struct zfcp_fsf_ct_els *ct = job->dd_data; in zfcp_fc_exec_ct_job()
1066 return -EINVAL; in zfcp_fc_exec_ct_job()
1072 ct->handler = zfcp_fc_ct_job_handler; in zfcp_fc_exec_ct_job()
1073 ret = zfcp_fsf_send_ct(wka_port, ct, NULL, job->timeout / HZ); in zfcp_fc_exec_ct_job()
1084 struct zfcp_fsf_ct_els *ct_els = job->dd_data; in zfcp_fc_exec_bsg_job()
1085 struct fc_bsg_request *bsg_request = job->request; in zfcp_fc_exec_bsg_job()
1089 adapter = (struct zfcp_adapter *)shost->hostdata[0]; in zfcp_fc_exec_bsg_job()
1091 if (!(atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_OPEN)) in zfcp_fc_exec_bsg_job()
1092 return -EINVAL; in zfcp_fc_exec_bsg_job()
1094 ct_els->req = job->request_payload.sg_list; in zfcp_fc_exec_bsg_job()
1095 ct_els->resp = job->reply_payload.sg_list; in zfcp_fc_exec_bsg_job()
1096 ct_els->handler_data = job; in zfcp_fc_exec_bsg_job()
1098 switch (bsg_request->msgcode) { in zfcp_fc_exec_bsg_job()
1106 return -EINVAL; in zfcp_fc_exec_bsg_job()
1113 return -EAGAIN; in zfcp_fc_timeout_bsg_job()
1122 return -ENOMEM; in zfcp_fc_gs_setup()
1124 adapter->gs = wka_ports; in zfcp_fc_gs_setup()
1125 zfcp_fc_wka_port_init(&wka_ports->ms, FC_FID_MGMT_SERV, adapter); in zfcp_fc_gs_setup()
1126 zfcp_fc_wka_port_init(&wka_ports->ts, FC_FID_TIME_SERV, adapter); in zfcp_fc_gs_setup()
1127 zfcp_fc_wka_port_init(&wka_ports->ds, FC_FID_DIR_SERV, adapter); in zfcp_fc_gs_setup()
1128 zfcp_fc_wka_port_init(&wka_ports->as, FC_FID_ALIASES, adapter); in zfcp_fc_gs_setup()
1135 kfree(adapter->gs); in zfcp_fc_gs_destroy()
1136 adapter->gs = NULL; in zfcp_fc_gs_destroy()