Lines Matching refs:qdio
38 static void zfcp_qdio_handler_error(struct zfcp_qdio *qdio, char *id, in zfcp_qdio_handler_error() argument
41 struct zfcp_adapter *adapter = qdio->adapter; in zfcp_qdio_handler_error()
66 static inline void zfcp_qdio_account(struct zfcp_qdio *qdio) in zfcp_qdio_account() argument
72 span = (now - qdio->req_q_time) >> 12; in zfcp_qdio_account()
73 used = QDIO_MAX_BUFFERS_PER_Q - atomic_read(&qdio->req_q_free); in zfcp_qdio_account()
74 qdio->req_q_util += used * span; in zfcp_qdio_account()
75 qdio->req_q_time = now; in zfcp_qdio_account()
82 struct zfcp_qdio *qdio = (struct zfcp_qdio *) parm; in zfcp_qdio_int_req() local
85 zfcp_qdio_handler_error(qdio, "qdireq1", qdio_err); in zfcp_qdio_int_req()
90 zfcp_qdio_zero_sbals(qdio->req_q, idx, count); in zfcp_qdio_int_req()
92 spin_lock_irq(&qdio->stat_lock); in zfcp_qdio_int_req()
93 zfcp_qdio_account(qdio); in zfcp_qdio_int_req()
94 spin_unlock_irq(&qdio->stat_lock); in zfcp_qdio_int_req()
95 atomic_add(count, &qdio->req_q_free); in zfcp_qdio_int_req()
96 wake_up(&qdio->req_q_wq); in zfcp_qdio_int_req()
103 struct zfcp_qdio *qdio = (struct zfcp_qdio *) parm; in zfcp_qdio_int_resp() local
104 struct zfcp_adapter *adapter = qdio->adapter; in zfcp_qdio_int_resp()
116 sbale = qdio->res_q[idx]->element; in zfcp_qdio_int_resp()
125 pl[sbal_no] = qdio->res_q[sbal_idx]; in zfcp_qdio_int_resp()
129 zfcp_qdio_handler_error(qdio, "qdires1", qdio_err); in zfcp_qdio_int_resp()
140 zfcp_fsf_reqid_check(qdio, sbal_idx); in zfcp_qdio_int_resp()
147 zfcp_erp_adapter_reopen(qdio->adapter, 0, "qdires2"); in zfcp_qdio_int_resp()
151 zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req) in zfcp_qdio_sbal_chain() argument
156 sbale = zfcp_qdio_sbale_curr(qdio, q_req); in zfcp_qdio_sbal_chain()
164 sbale = zfcp_qdio_sbale_req(qdio, q_req); in zfcp_qdio_sbal_chain()
179 sbale = zfcp_qdio_sbale_curr(qdio, q_req); in zfcp_qdio_sbal_chain()
186 zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req) in zfcp_qdio_sbale_next() argument
188 if (q_req->sbale_curr == qdio->max_sbale_per_sbal - 1) in zfcp_qdio_sbale_next()
189 return zfcp_qdio_sbal_chain(qdio, q_req); in zfcp_qdio_sbale_next()
191 return zfcp_qdio_sbale_curr(qdio, q_req); in zfcp_qdio_sbale_next()
202 int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, in zfcp_qdio_sbals_from_sg() argument
208 sbale = zfcp_qdio_sbale_req(qdio, q_req); in zfcp_qdio_sbals_from_sg()
212 sbale = zfcp_qdio_sbale_next(qdio, q_req); in zfcp_qdio_sbals_from_sg()
214 atomic_inc(&qdio->req_q_full); in zfcp_qdio_sbals_from_sg()
215 zfcp_qdio_zero_sbals(qdio->req_q, q_req->sbal_first, in zfcp_qdio_sbals_from_sg()
225 static int zfcp_qdio_sbal_check(struct zfcp_qdio *qdio) in zfcp_qdio_sbal_check() argument
227 if (atomic_read(&qdio->req_q_free) || in zfcp_qdio_sbal_check()
228 !(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) in zfcp_qdio_sbal_check()
243 int zfcp_qdio_sbal_get(struct zfcp_qdio *qdio) in zfcp_qdio_sbal_get() argument
247 ret = wait_event_interruptible_lock_irq_timeout(qdio->req_q_wq, in zfcp_qdio_sbal_get()
248 zfcp_qdio_sbal_check(qdio), qdio->req_q_lock, 5 * HZ); in zfcp_qdio_sbal_get()
250 if (!(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) in zfcp_qdio_sbal_get()
257 atomic_inc(&qdio->req_q_full); in zfcp_qdio_sbal_get()
259 zfcp_erp_adapter_reopen(qdio->adapter, 0, "qdsbg_1"); in zfcp_qdio_sbal_get()
271 int zfcp_qdio_send(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req) in zfcp_qdio_send() argument
276 spin_lock(&qdio->stat_lock); in zfcp_qdio_send()
277 zfcp_qdio_account(qdio); in zfcp_qdio_send()
278 spin_unlock(&qdio->stat_lock); in zfcp_qdio_send()
280 retval = do_QDIO(qdio->adapter->ccw_device, QDIO_FLAG_SYNC_OUTPUT, 0, in zfcp_qdio_send()
284 zfcp_qdio_zero_sbals(qdio->req_q, q_req->sbal_first, in zfcp_qdio_send()
290 atomic_sub(sbal_number, &qdio->req_q_free); in zfcp_qdio_send()
291 qdio->req_q_idx += sbal_number; in zfcp_qdio_send()
292 qdio->req_q_idx %= QDIO_MAX_BUFFERS_PER_Q; in zfcp_qdio_send()
299 struct zfcp_qdio *qdio) in zfcp_qdio_setup_init_data() argument
302 id->cdev = qdio->adapter->ccw_device; in zfcp_qdio_setup_init_data()
313 id->int_parm = (unsigned long) qdio; in zfcp_qdio_setup_init_data()
314 id->input_sbal_addr_array = (void **) (qdio->res_q); in zfcp_qdio_setup_init_data()
315 id->output_sbal_addr_array = (void **) (qdio->req_q); in zfcp_qdio_setup_init_data()
326 static int zfcp_qdio_allocate(struct zfcp_qdio *qdio) in zfcp_qdio_allocate() argument
330 if (zfcp_qdio_buffers_enqueue(qdio->req_q) || in zfcp_qdio_allocate()
331 zfcp_qdio_buffers_enqueue(qdio->res_q)) in zfcp_qdio_allocate()
334 zfcp_qdio_setup_init_data(&init_data, qdio); in zfcp_qdio_allocate()
335 init_waitqueue_head(&qdio->req_q_wq); in zfcp_qdio_allocate()
344 void zfcp_qdio_close(struct zfcp_qdio *qdio) in zfcp_qdio_close() argument
346 struct zfcp_adapter *adapter = qdio->adapter; in zfcp_qdio_close()
353 spin_lock_irq(&qdio->req_q_lock); in zfcp_qdio_close()
355 spin_unlock_irq(&qdio->req_q_lock); in zfcp_qdio_close()
357 wake_up(&qdio->req_q_wq); in zfcp_qdio_close()
362 count = atomic_read(&qdio->req_q_free); in zfcp_qdio_close()
364 idx = (qdio->req_q_idx + count) % QDIO_MAX_BUFFERS_PER_Q; in zfcp_qdio_close()
366 zfcp_qdio_zero_sbals(qdio->req_q, idx, count); in zfcp_qdio_close()
368 qdio->req_q_idx = 0; in zfcp_qdio_close()
369 atomic_set(&qdio->req_q_free, 0); in zfcp_qdio_close()
377 int zfcp_qdio_open(struct zfcp_qdio *qdio) in zfcp_qdio_open() argument
381 struct zfcp_adapter *adapter = qdio->adapter; in zfcp_qdio_open()
390 &qdio->adapter->status); in zfcp_qdio_open()
392 zfcp_qdio_setup_init_data(&init_data, qdio); in zfcp_qdio_open()
402 &qdio->adapter->status); in zfcp_qdio_open()
406 qdio->max_sbale_per_sbal = QDIO_MAX_ELEMENTS_PER_BUFFER; in zfcp_qdio_open()
409 qdio->max_sbale_per_sbal = QDIO_MAX_ELEMENTS_PER_BUFFER - 1; in zfcp_qdio_open()
412 qdio->max_sbale_per_req = in zfcp_qdio_open()
413 ZFCP_QDIO_MAX_SBALS_PER_REQ * qdio->max_sbale_per_sbal in zfcp_qdio_open()
419 sbale = &(qdio->res_q[cc]->element[0]); in zfcp_qdio_open()
430 qdio->req_q_idx = 0; in zfcp_qdio_open()
431 atomic_set(&qdio->req_q_free, QDIO_MAX_BUFFERS_PER_Q); in zfcp_qdio_open()
432 atomic_set_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &qdio->adapter->status); in zfcp_qdio_open()
435 adapter->scsi_host->sg_tablesize = qdio->max_sbale_per_req; in zfcp_qdio_open()
436 adapter->scsi_host->max_sectors = qdio->max_sbale_per_req * 8; in zfcp_qdio_open()
449 void zfcp_qdio_destroy(struct zfcp_qdio *qdio) in zfcp_qdio_destroy() argument
453 if (!qdio) in zfcp_qdio_destroy()
456 if (qdio->adapter->ccw_device) in zfcp_qdio_destroy()
457 qdio_free(qdio->adapter->ccw_device); in zfcp_qdio_destroy()
460 free_page((unsigned long) qdio->req_q[p]); in zfcp_qdio_destroy()
461 free_page((unsigned long) qdio->res_q[p]); in zfcp_qdio_destroy()
464 kfree(qdio); in zfcp_qdio_destroy()
469 struct zfcp_qdio *qdio; in zfcp_qdio_setup() local
471 qdio = kzalloc(sizeof(struct zfcp_qdio), GFP_KERNEL); in zfcp_qdio_setup()
472 if (!qdio) in zfcp_qdio_setup()
475 qdio->adapter = adapter; in zfcp_qdio_setup()
477 if (zfcp_qdio_allocate(qdio)) { in zfcp_qdio_setup()
478 zfcp_qdio_destroy(qdio); in zfcp_qdio_setup()
482 spin_lock_init(&qdio->req_q_lock); in zfcp_qdio_setup()
483 spin_lock_init(&qdio->stat_lock); in zfcp_qdio_setup()
485 adapter->qdio = qdio; in zfcp_qdio_setup()