Lines Matching refs:wka_port
81 static int zfcp_fc_wka_port_get(struct zfcp_fc_wka_port *wka_port) in zfcp_fc_wka_port_get() argument
83 if (mutex_lock_interruptible(&wka_port->mutex)) in zfcp_fc_wka_port_get()
86 if (wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE || in zfcp_fc_wka_port_get()
87 wka_port->status == ZFCP_FC_WKA_PORT_CLOSING) { in zfcp_fc_wka_port_get()
88 wka_port->status = ZFCP_FC_WKA_PORT_OPENING; in zfcp_fc_wka_port_get()
89 if (zfcp_fsf_open_wka_port(wka_port)) in zfcp_fc_wka_port_get()
90 wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; in zfcp_fc_wka_port_get()
93 mutex_unlock(&wka_port->mutex); in zfcp_fc_wka_port_get()
95 wait_event(wka_port->completion_wq, in zfcp_fc_wka_port_get()
96 wka_port->status == ZFCP_FC_WKA_PORT_ONLINE || in zfcp_fc_wka_port_get()
97 wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE); in zfcp_fc_wka_port_get()
99 if (wka_port->status == ZFCP_FC_WKA_PORT_ONLINE) { in zfcp_fc_wka_port_get()
100 atomic_inc(&wka_port->refcount); in zfcp_fc_wka_port_get()
109 struct zfcp_fc_wka_port *wka_port = in zfcp_fc_wka_port_offline() local
112 mutex_lock(&wka_port->mutex); in zfcp_fc_wka_port_offline()
113 if ((atomic_read(&wka_port->refcount) != 0) || in zfcp_fc_wka_port_offline()
114 (wka_port->status != ZFCP_FC_WKA_PORT_ONLINE)) in zfcp_fc_wka_port_offline()
117 wka_port->status = ZFCP_FC_WKA_PORT_CLOSING; in zfcp_fc_wka_port_offline()
118 if (zfcp_fsf_close_wka_port(wka_port)) { in zfcp_fc_wka_port_offline()
119 wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; in zfcp_fc_wka_port_offline()
120 wake_up(&wka_port->completion_wq); in zfcp_fc_wka_port_offline()
123 mutex_unlock(&wka_port->mutex); in zfcp_fc_wka_port_offline()
126 static void zfcp_fc_wka_port_put(struct zfcp_fc_wka_port *wka_port) in zfcp_fc_wka_port_put() argument
128 if (atomic_dec_return(&wka_port->refcount) != 0) in zfcp_fc_wka_port_put()
131 schedule_delayed_work(&wka_port->work, HZ / 100); in zfcp_fc_wka_port_put()
134 static void zfcp_fc_wka_port_init(struct zfcp_fc_wka_port *wka_port, u32 d_id, in zfcp_fc_wka_port_init() argument
137 init_waitqueue_head(&wka_port->completion_wq); in zfcp_fc_wka_port_init()
139 wka_port->adapter = adapter; in zfcp_fc_wka_port_init()
140 wka_port->d_id = d_id; in zfcp_fc_wka_port_init()
142 wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; in zfcp_fc_wka_port_init()
143 atomic_set(&wka_port->refcount, 0); in zfcp_fc_wka_port_init()
144 mutex_init(&wka_port->mutex); in zfcp_fc_wka_port_init()
145 INIT_DELAYED_WORK(&wka_port->work, zfcp_fc_wka_port_offline); in zfcp_fc_wka_port_init()
861 struct zfcp_fc_wka_port *wka_port; in zfcp_fc_ct_job_handler() local
863 wka_port = zfcp_fc_job_wka_port(job); in zfcp_fc_ct_job_handler()
864 zfcp_fc_wka_port_put(wka_port); in zfcp_fc_ct_job_handler()
896 struct zfcp_fc_wka_port *wka_port; in zfcp_fc_exec_ct_job() local
898 wka_port = zfcp_fc_job_wka_port(job); in zfcp_fc_exec_ct_job()
899 if (!wka_port) in zfcp_fc_exec_ct_job()
902 ret = zfcp_fc_wka_port_get(wka_port); in zfcp_fc_exec_ct_job()
907 ret = zfcp_fsf_send_ct(wka_port, ct, NULL, job->req->timeout / HZ); in zfcp_fc_exec_ct_job()
909 zfcp_fc_wka_port_put(wka_port); in zfcp_fc_exec_ct_job()