Lines Matching refs:q
116 static int qdio_do_eqbs(struct qdio_q *q, unsigned char *state, in qdio_do_eqbs() argument
119 int tmp_count = count, tmp_start = start, nr = q->nr; in qdio_do_eqbs()
122 qperf_inc(q, eqbs); in qdio_do_eqbs()
124 if (!q->is_input_q) in qdio_do_eqbs()
125 nr += q->irq_ptr->nr_input_qs; in qdio_do_eqbs()
127 ccq = do_eqbs(q->irq_ptr->sch_token, state, nr, &tmp_start, &tmp_count, in qdio_do_eqbs()
137 qperf_inc(q, eqbs_partial); in qdio_do_eqbs()
138 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "EQBS part:%02x", in qdio_do_eqbs()
143 DBF_DEV_EVENT(DBF_WARN, q->irq_ptr, "EQBS again:%2d", ccq); in qdio_do_eqbs()
146 DBF_ERROR("%4x ccq:%3d", SCH_NO(q), ccq); in qdio_do_eqbs()
147 DBF_ERROR("%4x EQBS ERROR", SCH_NO(q)); in qdio_do_eqbs()
149 q->handler(q->irq_ptr->cdev, QDIO_ERROR_GET_BUF_STATE, q->nr, in qdio_do_eqbs()
150 q->first_to_check, count, q->irq_ptr->int_parm); in qdio_do_eqbs()
166 static int qdio_do_sqbs(struct qdio_q *q, unsigned char state, int start, in qdio_do_sqbs() argument
171 int nr = q->nr; in qdio_do_sqbs()
173 qperf_inc(q, sqbs); in qdio_do_sqbs()
175 if (!q->is_input_q) in qdio_do_sqbs()
176 nr += q->irq_ptr->nr_input_qs; in qdio_do_sqbs()
178 ccq = do_sqbs(q->irq_ptr->sch_token, state, nr, &tmp_start, &tmp_count); in qdio_do_sqbs()
188 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "SQBS again:%2d", ccq); in qdio_do_sqbs()
189 qperf_inc(q, sqbs_partial); in qdio_do_sqbs()
192 DBF_ERROR("%4x ccq:%3d", SCH_NO(q), ccq); in qdio_do_sqbs()
193 DBF_ERROR("%4x SQBS ERROR", SCH_NO(q)); in qdio_do_sqbs()
195 q->handler(q->irq_ptr->cdev, QDIO_ERROR_SET_BUF_STATE, q->nr, in qdio_do_sqbs()
196 q->first_to_check, count, q->irq_ptr->int_parm); in qdio_do_sqbs()
205 static inline int get_buf_states(struct qdio_q *q, unsigned int bufnr, in get_buf_states() argument
212 if (is_qebsm(q)) in get_buf_states()
213 return qdio_do_eqbs(q, state, bufnr, count, auto_ack); in get_buf_states()
216 __state = q->slsb.val[bufnr]; in get_buf_states()
226 if (q->slsb.val[bufnr] != __state) in get_buf_states()
235 static inline int get_buf_state(struct qdio_q *q, unsigned int bufnr, in get_buf_state() argument
238 return get_buf_states(q, bufnr, state, 1, auto_ack); in get_buf_state()
242 static inline int set_buf_states(struct qdio_q *q, int bufnr, in set_buf_states() argument
247 if (is_qebsm(q)) in set_buf_states()
248 return qdio_do_sqbs(q, state, bufnr, count); in set_buf_states()
254 WRITE_ONCE(q->slsb.val[bufnr], state); in set_buf_states()
264 static inline int set_buf_state(struct qdio_q *q, int bufnr, in set_buf_state() argument
267 return set_buf_states(q, bufnr, state, 1); in set_buf_state()
273 struct qdio_q *q; in qdio_init_buf_states() local
276 for_each_input_queue(irq_ptr, q, i) in qdio_init_buf_states()
277 set_buf_states(q, 0, SLSB_P_INPUT_NOT_INIT, in qdio_init_buf_states()
279 for_each_output_queue(irq_ptr, q, i) in qdio_init_buf_states()
280 set_buf_states(q, 0, SLSB_P_OUTPUT_NOT_INIT, in qdio_init_buf_states()
284 static inline int qdio_siga_sync(struct qdio_q *q, unsigned int output, in qdio_siga_sync() argument
287 unsigned long schid = *((u32 *) &q->irq_ptr->schid); in qdio_siga_sync()
291 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "siga-s:%1d", q->nr); in qdio_siga_sync()
292 qperf_inc(q, siga_sync); in qdio_siga_sync()
294 if (is_qebsm(q)) { in qdio_siga_sync()
295 schid = q->irq_ptr->sch_token; in qdio_siga_sync()
301 DBF_ERROR("%4x SIGA-S:%2d", SCH_NO(q), cc); in qdio_siga_sync()
305 static inline int qdio_sync_input_queue(struct qdio_q *q) in qdio_sync_input_queue() argument
307 return qdio_siga_sync(q, 0, q->mask); in qdio_sync_input_queue()
310 static inline int qdio_sync_output_queue(struct qdio_q *q) in qdio_sync_output_queue() argument
312 return qdio_siga_sync(q, q->mask, 0); in qdio_sync_output_queue()
315 static inline int qdio_siga_sync_q(struct qdio_q *q) in qdio_siga_sync_q() argument
317 if (q->is_input_q) in qdio_siga_sync_q()
318 return qdio_sync_input_queue(q); in qdio_siga_sync_q()
320 return qdio_sync_output_queue(q); in qdio_siga_sync_q()
323 static int qdio_siga_output(struct qdio_q *q, unsigned int count, in qdio_siga_output() argument
326 unsigned long schid = *((u32 *) &q->irq_ptr->schid); in qdio_siga_output()
331 if (queue_type(q) == QDIO_IQDIO_QFMT && !multicast_outbound(q)) { in qdio_siga_output()
338 if (is_qebsm(q)) { in qdio_siga_output()
339 schid = q->irq_ptr->sch_token; in qdio_siga_output()
343 cc = do_siga_output(schid, q->mask, busy_bit, fc, aob); in qdio_siga_output()
357 DBF_DEV_EVENT(DBF_WARN, q->irq_ptr, in qdio_siga_output()
358 "%4x cc2 BB1:%1d", SCH_NO(q), q->nr); in qdio_siga_output()
359 DBF_DEV_EVENT(DBF_WARN, q->irq_ptr, "count:%u", retries); in qdio_siga_output()
364 static inline int qdio_siga_input(struct qdio_q *q) in qdio_siga_input() argument
366 unsigned long schid = *((u32 *) &q->irq_ptr->schid); in qdio_siga_input()
370 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "siga-r:%1d", q->nr); in qdio_siga_input()
371 qperf_inc(q, siga_read); in qdio_siga_input()
373 if (is_qebsm(q)) { in qdio_siga_input()
374 schid = q->irq_ptr->sch_token; in qdio_siga_input()
378 cc = do_siga_input(schid, q->mask, fc); in qdio_siga_input()
380 DBF_ERROR("%4x SIGA-R:%2d", SCH_NO(q), cc); in qdio_siga_input()
384 int debug_get_buf_state(struct qdio_q *q, unsigned int bufnr, in debug_get_buf_state() argument
387 if (qdio_need_siga_sync(q->irq_ptr)) in debug_get_buf_state()
388 qdio_siga_sync_q(q); in debug_get_buf_state()
389 return get_buf_state(q, bufnr, state, 0); in debug_get_buf_state()
392 static inline void qdio_stop_polling(struct qdio_q *q) in qdio_stop_polling() argument
394 if (!q->u.in.batch_count) in qdio_stop_polling()
397 qperf_inc(q, stop_polling); in qdio_stop_polling()
400 set_buf_states(q, q->u.in.batch_start, SLSB_P_INPUT_NOT_INIT, in qdio_stop_polling()
401 q->u.in.batch_count); in qdio_stop_polling()
402 q->u.in.batch_count = 0; in qdio_stop_polling()
405 static inline void account_sbals(struct qdio_q *q, unsigned int count) in account_sbals() argument
407 q->q_stats.nr_sbal_total += count; in account_sbals()
408 q->q_stats.nr_sbals[ilog2(count)]++; in account_sbals()
411 static void process_buffer_error(struct qdio_q *q, unsigned int start, in process_buffer_error() argument
415 if (queue_type(q) == QDIO_IQDIO_QFMT && !q->is_input_q && in process_buffer_error()
416 q->sbal[start]->element[15].sflags == 0x10) { in process_buffer_error()
417 qperf_inc(q, target_full); in process_buffer_error()
418 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "OUTFULL FTC:%02x", start); in process_buffer_error()
422 DBF_ERROR("%4x BUF ERROR", SCH_NO(q)); in process_buffer_error()
423 DBF_ERROR((q->is_input_q) ? "IN:%2d" : "OUT:%2d", q->nr); in process_buffer_error()
426 q->sbal[start]->element[14].sflags, in process_buffer_error()
427 q->sbal[start]->element[15].sflags); in process_buffer_error()
430 static inline void inbound_handle_work(struct qdio_q *q, unsigned int start, in inbound_handle_work() argument
435 set_buf_state(q, add_buf(start, count - 1), SLSB_P_INPUT_ACK); in inbound_handle_work()
437 if (!q->u.in.batch_count) in inbound_handle_work()
438 q->u.in.batch_start = start; in inbound_handle_work()
439 q->u.in.batch_count += count; in inbound_handle_work()
442 static int get_inbound_buffer_frontier(struct qdio_q *q, unsigned int start, in get_inbound_buffer_frontier() argument
448 q->timestamp = get_tod_clock_fast(); in get_inbound_buffer_frontier()
450 count = atomic_read(&q->nr_buf_used); in get_inbound_buffer_frontier()
454 if (qdio_need_siga_sync(q->irq_ptr)) in get_inbound_buffer_frontier()
455 qdio_sync_input_queue(q); in get_inbound_buffer_frontier()
457 count = get_buf_states(q, start, &state, count, 1); in get_inbound_buffer_frontier()
463 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "in prim:%1d %02x", q->nr, in get_inbound_buffer_frontier()
466 inbound_handle_work(q, start, count, is_qebsm(q)); in get_inbound_buffer_frontier()
467 if (atomic_sub_return(count, &q->nr_buf_used) == 0) in get_inbound_buffer_frontier()
468 qperf_inc(q, inbound_queue_full); in get_inbound_buffer_frontier()
469 if (q->irq_ptr->perf_stat_enabled) in get_inbound_buffer_frontier()
470 account_sbals(q, count); in get_inbound_buffer_frontier()
473 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "in err:%1d %02x", q->nr, in get_inbound_buffer_frontier()
477 process_buffer_error(q, start, count); in get_inbound_buffer_frontier()
478 inbound_handle_work(q, start, count, false); in get_inbound_buffer_frontier()
479 if (atomic_sub_return(count, &q->nr_buf_used) == 0) in get_inbound_buffer_frontier()
480 qperf_inc(q, inbound_queue_full); in get_inbound_buffer_frontier()
481 if (q->irq_ptr->perf_stat_enabled) in get_inbound_buffer_frontier()
482 account_sbals_error(q, count); in get_inbound_buffer_frontier()
485 if (q->irq_ptr->perf_stat_enabled) in get_inbound_buffer_frontier()
486 q->q_stats.nr_sbal_nop++; in get_inbound_buffer_frontier()
487 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "in nop:%1d %#02x", in get_inbound_buffer_frontier()
488 q->nr, start); in get_inbound_buffer_frontier()
494 dev_WARN_ONCE(&q->irq_ptr->cdev->dev, 1, in get_inbound_buffer_frontier()
496 state, start, q->nr); in get_inbound_buffer_frontier()
506 struct qdio_q *q; in qdio_inspect_input_queue() local
512 q = irq->input_qs[nr]; in qdio_inspect_input_queue()
513 start = q->first_to_check; in qdio_inspect_input_queue()
516 count = get_inbound_buffer_frontier(q, start, error); in qdio_inspect_input_queue()
521 q->first_to_check = add_buf(start, count); in qdio_inspect_input_queue()
526 static inline int qdio_inbound_q_done(struct qdio_q *q, unsigned int start) in qdio_inbound_q_done() argument
530 if (!atomic_read(&q->nr_buf_used)) in qdio_inbound_q_done()
533 if (qdio_need_siga_sync(q->irq_ptr)) in qdio_inbound_q_done()
534 qdio_sync_input_queue(q); in qdio_inbound_q_done()
535 get_buf_state(q, start, &state, 0); in qdio_inbound_q_done()
544 static int get_outbound_buffer_frontier(struct qdio_q *q, unsigned int start, in get_outbound_buffer_frontier() argument
550 q->timestamp = get_tod_clock_fast(); in get_outbound_buffer_frontier()
552 count = atomic_read(&q->nr_buf_used); in get_outbound_buffer_frontier()
556 if (qdio_need_siga_sync(q->irq_ptr)) in get_outbound_buffer_frontier()
557 qdio_sync_output_queue(q); in get_outbound_buffer_frontier()
559 count = get_buf_states(q, start, &state, count, 0); in get_outbound_buffer_frontier()
569 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, in get_outbound_buffer_frontier()
570 "out empty:%1d %02x", q->nr, count); in get_outbound_buffer_frontier()
572 atomic_sub(count, &q->nr_buf_used); in get_outbound_buffer_frontier()
573 if (q->irq_ptr->perf_stat_enabled) in get_outbound_buffer_frontier()
574 account_sbals(q, count); in get_outbound_buffer_frontier()
577 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "out error:%1d %02x", in get_outbound_buffer_frontier()
578 q->nr, count); in get_outbound_buffer_frontier()
581 process_buffer_error(q, start, count); in get_outbound_buffer_frontier()
582 atomic_sub(count, &q->nr_buf_used); in get_outbound_buffer_frontier()
583 if (q->irq_ptr->perf_stat_enabled) in get_outbound_buffer_frontier()
584 account_sbals_error(q, count); in get_outbound_buffer_frontier()
588 if (q->irq_ptr->perf_stat_enabled) in get_outbound_buffer_frontier()
589 q->q_stats.nr_sbal_nop++; in get_outbound_buffer_frontier()
590 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "out primed:%1d", in get_outbound_buffer_frontier()
591 q->nr); in get_outbound_buffer_frontier()
598 dev_WARN_ONCE(&q->irq_ptr->cdev->dev, 1, in get_outbound_buffer_frontier()
600 state, start, q->nr); in get_outbound_buffer_frontier()
610 struct qdio_q *q; in qdio_inspect_output_queue() local
616 q = irq->output_qs[nr]; in qdio_inspect_output_queue()
617 start = q->first_to_check; in qdio_inspect_output_queue()
620 count = get_outbound_buffer_frontier(q, start, error); in qdio_inspect_output_queue()
625 q->first_to_check = add_buf(start, count); in qdio_inspect_output_queue()
630 static int qdio_kick_outbound_q(struct qdio_q *q, unsigned int count, in qdio_kick_outbound_q() argument
636 if (!qdio_need_siga_out(q->irq_ptr)) in qdio_kick_outbound_q()
639 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "siga-w:%1d", q->nr); in qdio_kick_outbound_q()
641 qperf_inc(q, siga_write); in qdio_kick_outbound_q()
643 cc = qdio_siga_output(q, count, &busy_bit, aob); in qdio_kick_outbound_q()
653 DBF_ERROR("%4x cc2 BBC:%1d", SCH_NO(q), q->nr); in qdio_kick_outbound_q()
656 DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "siga-w cc2:%1d", q->nr); in qdio_kick_outbound_q()
662 DBF_ERROR("%4x SIGA-W:%1d", SCH_NO(q), cc); in qdio_kick_outbound_q()
667 DBF_ERROR("%4x cc2 BB2:%1d", SCH_NO(q), q->nr); in qdio_kick_outbound_q()
1192 static int handle_inbound(struct qdio_q *q, int bufnr, int count) in handle_inbound() argument
1196 qperf_inc(q, inbound_call); in handle_inbound()
1199 overlap = min_t(int, count - sub_buf(q->u.in.batch_start, bufnr), in handle_inbound()
1200 q->u.in.batch_count); in handle_inbound()
1202 q->u.in.batch_start = add_buf(q->u.in.batch_start, overlap); in handle_inbound()
1203 q->u.in.batch_count -= overlap; in handle_inbound()
1206 count = set_buf_states(q, bufnr, SLSB_CU_INPUT_EMPTY, count); in handle_inbound()
1207 atomic_add(count, &q->nr_buf_used); in handle_inbound()
1209 if (qdio_need_siga_in(q->irq_ptr)) in handle_inbound()
1210 return qdio_siga_input(q); in handle_inbound()
1251 static int handle_outbound(struct qdio_q *q, unsigned int bufnr, unsigned int count, in handle_outbound() argument
1257 qperf_inc(q, outbound_call); in handle_outbound()
1259 count = set_buf_states(q, bufnr, SLSB_CU_OUTPUT_PRIMED, count); in handle_outbound()
1260 used = atomic_add_return(count, &q->nr_buf_used); in handle_outbound()
1263 qperf_inc(q, outbound_queue_full); in handle_outbound()
1265 if (queue_type(q) == QDIO_IQDIO_QFMT) { in handle_outbound()
1269 rc = qdio_kick_outbound_q(q, count, phys_aob); in handle_outbound()
1270 } else if (qdio_need_siga_sync(q->irq_ptr)) { in handle_outbound()
1271 rc = qdio_sync_output_queue(q); in handle_outbound()
1273 get_buf_state(q, prev_buf(bufnr), &state, 0) > 0 && in handle_outbound()
1276 qperf_inc(q, fast_requeue); in handle_outbound()
1278 rc = qdio_kick_outbound_q(q, count, 0); in handle_outbound()
1325 struct qdio_q *q; in qdio_start_irq() local
1332 for_each_input_queue(irq_ptr, q, i) in qdio_start_irq()
1333 qdio_stop_polling(q); in qdio_start_irq()
1344 for_each_input_queue(irq_ptr, q, i) { in qdio_start_irq()
1345 if (!qdio_inbound_q_done(q, q->first_to_check)) in qdio_start_irq()