Lines Matching refs:qdio
26 static void zfcp_qdio_handler_error(struct zfcp_qdio *qdio, char *dbftag, in zfcp_qdio_handler_error() argument
29 struct zfcp_adapter *adapter = qdio->adapter; in zfcp_qdio_handler_error()
54 static inline void zfcp_qdio_account(struct zfcp_qdio *qdio) in zfcp_qdio_account() argument
60 span = (now - qdio->req_q_time) >> 12; in zfcp_qdio_account()
61 used = QDIO_MAX_BUFFERS_PER_Q - atomic_read(&qdio->req_q_free); in zfcp_qdio_account()
62 qdio->req_q_util += used * span; in zfcp_qdio_account()
63 qdio->req_q_time = now; in zfcp_qdio_account()
70 struct zfcp_qdio *qdio = (struct zfcp_qdio *) parm; in zfcp_qdio_int_req() local
72 zfcp_qdio_handler_error(qdio, "qdireq1", qdio_err); in zfcp_qdio_int_req()
77 struct zfcp_qdio *qdio = from_tasklet(qdio, tasklet, request_tasklet); in zfcp_qdio_request_tasklet() local
78 struct ccw_device *cdev = qdio->adapter->ccw_device; in zfcp_qdio_request_tasklet()
85 zfcp_qdio_handler_error(qdio, "qdreqt1", error); in zfcp_qdio_request_tasklet()
88 zfcp_qdio_zero_sbals(qdio->req_q, start, completed); in zfcp_qdio_request_tasklet()
90 spin_lock_irq(&qdio->stat_lock); in zfcp_qdio_request_tasklet()
91 zfcp_qdio_account(qdio); in zfcp_qdio_request_tasklet()
92 spin_unlock_irq(&qdio->stat_lock); in zfcp_qdio_request_tasklet()
93 atomic_add(completed, &qdio->req_q_free); in zfcp_qdio_request_tasklet()
94 wake_up(&qdio->req_q_wq); in zfcp_qdio_request_tasklet()
98 if (atomic_read(&qdio->req_q_free) < QDIO_MAX_BUFFERS_PER_Q) in zfcp_qdio_request_tasklet()
99 timer_reduce(&qdio->request_timer, in zfcp_qdio_request_tasklet()
105 struct zfcp_qdio *qdio = from_timer(qdio, timer, request_timer); in zfcp_qdio_request_timer() local
107 tasklet_schedule(&qdio->request_tasklet); in zfcp_qdio_request_timer()
114 struct zfcp_qdio *qdio = (struct zfcp_qdio *) parm; in zfcp_qdio_int_resp() local
115 struct zfcp_adapter *adapter = qdio->adapter; in zfcp_qdio_int_resp()
127 sbale = qdio->res_q[idx]->element; in zfcp_qdio_int_resp()
136 pl[sbal_no] = qdio->res_q[sbal_idx]; in zfcp_qdio_int_resp()
140 zfcp_qdio_handler_error(qdio, "qdires1", qdio_err); in zfcp_qdio_int_resp()
151 zfcp_fsf_reqid_check(qdio, sbal_idx); in zfcp_qdio_int_resp()
158 zfcp_erp_adapter_reopen(qdio->adapter, 0, "qdires2"); in zfcp_qdio_int_resp()
163 struct zfcp_qdio *qdio = from_tasklet(qdio, tasklet, irq_tasklet); in zfcp_qdio_irq_tasklet() local
164 struct ccw_device *cdev = qdio->adapter->ccw_device; in zfcp_qdio_irq_tasklet()
168 if (atomic_read(&qdio->req_q_free) < QDIO_MAX_BUFFERS_PER_Q) in zfcp_qdio_irq_tasklet()
169 tasklet_schedule(&qdio->request_tasklet); in zfcp_qdio_irq_tasklet()
177 (unsigned long) qdio); in zfcp_qdio_irq_tasklet()
181 tasklet_schedule(&qdio->irq_tasklet); in zfcp_qdio_irq_tasklet()
186 struct zfcp_qdio *qdio = (struct zfcp_qdio *) data; in zfcp_qdio_poll() local
188 tasklet_schedule(&qdio->irq_tasklet); in zfcp_qdio_poll()
192 zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req) in zfcp_qdio_sbal_chain() argument
197 sbale = zfcp_qdio_sbale_curr(qdio, q_req); in zfcp_qdio_sbal_chain()
205 sbale = zfcp_qdio_sbale_req(qdio, q_req); in zfcp_qdio_sbal_chain()
220 sbale = zfcp_qdio_sbale_curr(qdio, q_req); in zfcp_qdio_sbal_chain()
227 zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req) in zfcp_qdio_sbale_next() argument
229 if (q_req->sbale_curr == qdio->max_sbale_per_sbal - 1) in zfcp_qdio_sbale_next()
230 return zfcp_qdio_sbal_chain(qdio, q_req); in zfcp_qdio_sbale_next()
232 return zfcp_qdio_sbale_curr(qdio, q_req); in zfcp_qdio_sbale_next()
242 int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, in zfcp_qdio_sbals_from_sg() argument
248 sbale = zfcp_qdio_sbale_req(qdio, q_req); in zfcp_qdio_sbals_from_sg()
252 sbale = zfcp_qdio_sbale_next(qdio, q_req); in zfcp_qdio_sbals_from_sg()
254 atomic_inc(&qdio->req_q_full); in zfcp_qdio_sbals_from_sg()
255 zfcp_qdio_zero_sbals(qdio->req_q, q_req->sbal_first, in zfcp_qdio_sbals_from_sg()
265 static int zfcp_qdio_sbal_check(struct zfcp_qdio *qdio) in zfcp_qdio_sbal_check() argument
267 if (atomic_read(&qdio->req_q_free) || in zfcp_qdio_sbal_check()
268 !(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) in zfcp_qdio_sbal_check()
283 int zfcp_qdio_sbal_get(struct zfcp_qdio *qdio) in zfcp_qdio_sbal_get() argument
287 ret = wait_event_interruptible_lock_irq_timeout(qdio->req_q_wq, in zfcp_qdio_sbal_get()
288 zfcp_qdio_sbal_check(qdio), qdio->req_q_lock, 5 * HZ); in zfcp_qdio_sbal_get()
290 if (!(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) in zfcp_qdio_sbal_get()
297 atomic_inc(&qdio->req_q_full); in zfcp_qdio_sbal_get()
299 zfcp_erp_adapter_reopen(qdio->adapter, 0, "qdsbg_1"); in zfcp_qdio_sbal_get()
311 int zfcp_qdio_send(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req) in zfcp_qdio_send() argument
323 spin_lock(&qdio->stat_lock); in zfcp_qdio_send()
324 zfcp_qdio_account(qdio); in zfcp_qdio_send()
325 spin_unlock(&qdio->stat_lock); in zfcp_qdio_send()
327 atomic_sub(sbal_number, &qdio->req_q_free); in zfcp_qdio_send()
329 retval = qdio_add_bufs_to_output_queue(qdio->adapter->ccw_device, 0, in zfcp_qdio_send()
335 atomic_add(sbal_number, &qdio->req_q_free); in zfcp_qdio_send()
336 zfcp_qdio_zero_sbals(qdio->req_q, q_req->sbal_first, in zfcp_qdio_send()
341 if (atomic_read(&qdio->req_q_free) <= 2 * ZFCP_QDIO_MAX_SBALS_PER_REQ) in zfcp_qdio_send()
342 tasklet_schedule(&qdio->request_tasklet); in zfcp_qdio_send()
344 timer_reduce(&qdio->request_timer, in zfcp_qdio_send()
348 qdio->req_q_idx += sbal_number; in zfcp_qdio_send()
349 qdio->req_q_idx %= QDIO_MAX_BUFFERS_PER_Q; in zfcp_qdio_send()
360 static int zfcp_qdio_allocate(struct zfcp_qdio *qdio) in zfcp_qdio_allocate() argument
364 ret = qdio_alloc_buffers(qdio->req_q, QDIO_MAX_BUFFERS_PER_Q); in zfcp_qdio_allocate()
368 ret = qdio_alloc_buffers(qdio->res_q, QDIO_MAX_BUFFERS_PER_Q); in zfcp_qdio_allocate()
372 init_waitqueue_head(&qdio->req_q_wq); in zfcp_qdio_allocate()
374 ret = qdio_allocate(qdio->adapter->ccw_device, 1, 1); in zfcp_qdio_allocate()
381 qdio_free_buffers(qdio->res_q, QDIO_MAX_BUFFERS_PER_Q); in zfcp_qdio_allocate()
383 qdio_free_buffers(qdio->req_q, QDIO_MAX_BUFFERS_PER_Q); in zfcp_qdio_allocate()
391 void zfcp_qdio_close(struct zfcp_qdio *qdio) in zfcp_qdio_close() argument
393 struct zfcp_adapter *adapter = qdio->adapter; in zfcp_qdio_close()
403 spin_lock_irq(&qdio->req_q_lock); in zfcp_qdio_close()
405 spin_unlock_irq(&qdio->req_q_lock); in zfcp_qdio_close()
407 wake_up(&qdio->req_q_wq); in zfcp_qdio_close()
409 tasklet_disable(&qdio->irq_tasklet); in zfcp_qdio_close()
410 tasklet_disable(&qdio->request_tasklet); in zfcp_qdio_close()
411 del_timer_sync(&qdio->request_timer); in zfcp_qdio_close()
416 count = atomic_read(&qdio->req_q_free); in zfcp_qdio_close()
418 idx = (qdio->req_q_idx + count) % QDIO_MAX_BUFFERS_PER_Q; in zfcp_qdio_close()
420 zfcp_qdio_zero_sbals(qdio->req_q, idx, count); in zfcp_qdio_close()
422 qdio->req_q_idx = 0; in zfcp_qdio_close()
423 atomic_set(&qdio->req_q_free, 0); in zfcp_qdio_close()
427 const struct zfcp_qdio *const qdio) in zfcp_qdio_shost_update() argument
434 shost->sg_tablesize = qdio->max_sbale_per_req; in zfcp_qdio_shost_update()
435 shost->max_sectors = qdio->max_sbale_per_req * 8; in zfcp_qdio_shost_update()
443 int zfcp_qdio_open(struct zfcp_qdio *qdio) in zfcp_qdio_open() argument
445 struct qdio_buffer **input_sbals[1] = {qdio->res_q}; in zfcp_qdio_open()
446 struct qdio_buffer **output_sbals[1] = {qdio->req_q}; in zfcp_qdio_open()
449 struct zfcp_adapter *adapter = qdio->adapter; in zfcp_qdio_open()
458 &qdio->adapter->status); in zfcp_qdio_open()
469 init_data.int_parm = (unsigned long) qdio; in zfcp_qdio_open()
481 &qdio->adapter->status); in zfcp_qdio_open()
485 qdio->max_sbale_per_sbal = QDIO_MAX_ELEMENTS_PER_BUFFER; in zfcp_qdio_open()
488 qdio->max_sbale_per_sbal = QDIO_MAX_ELEMENTS_PER_BUFFER - 1; in zfcp_qdio_open()
491 qdio->max_sbale_per_req = in zfcp_qdio_open()
492 ZFCP_QDIO_MAX_SBALS_PER_REQ * qdio->max_sbale_per_sbal in zfcp_qdio_open()
498 sbale = &(qdio->res_q[cc]->element[0]); in zfcp_qdio_open()
509 qdio->req_q_idx = 0; in zfcp_qdio_open()
510 atomic_set(&qdio->req_q_free, QDIO_MAX_BUFFERS_PER_Q); in zfcp_qdio_open()
511 atomic_or(ZFCP_STATUS_ADAPTER_QDIOUP, &qdio->adapter->status); in zfcp_qdio_open()
514 tasklet_enable(&qdio->request_tasklet); in zfcp_qdio_open()
516 tasklet_enable(&qdio->irq_tasklet); in zfcp_qdio_open()
518 tasklet_schedule(&qdio->irq_tasklet); in zfcp_qdio_open()
520 zfcp_qdio_shost_update(adapter, qdio); in zfcp_qdio_open()
532 void zfcp_qdio_destroy(struct zfcp_qdio *qdio) in zfcp_qdio_destroy() argument
534 if (!qdio) in zfcp_qdio_destroy()
537 tasklet_kill(&qdio->irq_tasklet); in zfcp_qdio_destroy()
538 tasklet_kill(&qdio->request_tasklet); in zfcp_qdio_destroy()
540 if (qdio->adapter->ccw_device) in zfcp_qdio_destroy()
541 qdio_free(qdio->adapter->ccw_device); in zfcp_qdio_destroy()
543 qdio_free_buffers(qdio->req_q, QDIO_MAX_BUFFERS_PER_Q); in zfcp_qdio_destroy()
544 qdio_free_buffers(qdio->res_q, QDIO_MAX_BUFFERS_PER_Q); in zfcp_qdio_destroy()
545 kfree(qdio); in zfcp_qdio_destroy()
550 struct zfcp_qdio *qdio; in zfcp_qdio_setup() local
552 qdio = kzalloc(sizeof(struct zfcp_qdio), GFP_KERNEL); in zfcp_qdio_setup()
553 if (!qdio) in zfcp_qdio_setup()
556 qdio->adapter = adapter; in zfcp_qdio_setup()
558 if (zfcp_qdio_allocate(qdio)) { in zfcp_qdio_setup()
559 kfree(qdio); in zfcp_qdio_setup()
563 spin_lock_init(&qdio->req_q_lock); in zfcp_qdio_setup()
564 spin_lock_init(&qdio->stat_lock); in zfcp_qdio_setup()
565 timer_setup(&qdio->request_timer, zfcp_qdio_request_timer, 0); in zfcp_qdio_setup()
566 tasklet_setup(&qdio->irq_tasklet, zfcp_qdio_irq_tasklet); in zfcp_qdio_setup()
567 tasklet_setup(&qdio->request_tasklet, zfcp_qdio_request_tasklet); in zfcp_qdio_setup()
568 tasklet_disable(&qdio->irq_tasklet); in zfcp_qdio_setup()
569 tasklet_disable(&qdio->request_tasklet); in zfcp_qdio_setup()
571 adapter->qdio = qdio; in zfcp_qdio_setup()