Commit b44995e5 authored by Julian Wiedmann's avatar Julian Wiedmann Committed by Heiko Carstens

s390/qdio: split qdio_inspect_queue()

The callers know what type of queue they want to inspect. Introduce
type-specific variants to inspect an {Input,Output} queue, so that we
can avoid one function parameter and some conditional branches in the
hot paths.
Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: default avatarBenjamin Block <bblock@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 513251fe
......@@ -352,9 +352,10 @@ extern int do_QDIO(struct ccw_device *cdev, unsigned int callflags, int q_nr,
unsigned int bufnr, unsigned int count, struct qaob *aob);
extern int qdio_start_irq(struct ccw_device *cdev);
extern int qdio_stop_irq(struct ccw_device *cdev);
extern int qdio_inspect_queue(struct ccw_device *cdev, unsigned int nr,
bool is_input, unsigned int *bufnr,
unsigned int *error);
extern int qdio_inspect_input_queue(struct ccw_device *cdev, unsigned int nr,
unsigned int *bufnr, unsigned int *error);
extern int qdio_inspect_output_queue(struct ccw_device *cdev, unsigned int nr,
unsigned int *bufnr, unsigned int *error);
extern int qdio_shutdown(struct ccw_device *, int);
extern int qdio_free(struct ccw_device *);
extern int qdio_get_ssqd_desc(struct ccw_device *, struct qdio_ssqd_desc *);
......
......@@ -500,6 +500,31 @@ static int get_inbound_buffer_frontier(struct qdio_q *q, unsigned int start,
}
}
int qdio_inspect_input_queue(struct ccw_device *cdev, unsigned int nr,
unsigned int *bufnr, unsigned int *error)
{
struct qdio_irq *irq = cdev->private->qdio_data;
unsigned int start;
struct qdio_q *q;
int count;
if (!irq)
return -ENODEV;
q = irq->input_qs[nr];
start = q->first_to_check;
*error = 0;
count = get_inbound_buffer_frontier(q, start, error);
if (count == 0)
return 0;
*bufnr = start;
q->first_to_check = add_buf(start, count);
return count;
}
EXPORT_SYMBOL_GPL(qdio_inspect_input_queue);
static inline int qdio_inbound_q_done(struct qdio_q *q, unsigned int start)
{
unsigned char state = 0;
......@@ -579,6 +604,31 @@ static int get_outbound_buffer_frontier(struct qdio_q *q, unsigned int start,
}
}
int qdio_inspect_output_queue(struct ccw_device *cdev, unsigned int nr,
unsigned int *bufnr, unsigned int *error)
{
struct qdio_irq *irq = cdev->private->qdio_data;
unsigned int start;
struct qdio_q *q;
int count;
if (!irq)
return -ENODEV;
q = irq->output_qs[nr];
start = q->first_to_check;
*error = 0;
count = get_outbound_buffer_frontier(q, start, error);
if (count == 0)
return 0;
*bufnr = start;
q->first_to_check = add_buf(start, count);
return count;
}
EXPORT_SYMBOL_GPL(qdio_inspect_output_queue);
static int qdio_kick_outbound_q(struct qdio_q *q, unsigned int count,
unsigned long aob)
{
......@@ -1284,40 +1334,6 @@ int qdio_start_irq(struct ccw_device *cdev)
}
EXPORT_SYMBOL(qdio_start_irq);
static int __qdio_inspect_queue(struct qdio_q *q, unsigned int *bufnr,
unsigned int *error)
{
unsigned int start = q->first_to_check;
int count;
*error = 0;
count = q->is_input_q ? get_inbound_buffer_frontier(q, start, error) :
get_outbound_buffer_frontier(q, start, error);
if (count == 0)
return 0;
*bufnr = start;
/* for the next time */
q->first_to_check = add_buf(start, count);
return count;
}
int qdio_inspect_queue(struct ccw_device *cdev, unsigned int nr, bool is_input,
unsigned int *bufnr, unsigned int *error)
{
struct qdio_irq *irq_ptr = cdev->private->qdio_data;
struct qdio_q *q;
if (!irq_ptr)
return -ENODEV;
q = is_input ? irq_ptr->input_qs[nr] : irq_ptr->output_qs[nr];
return __qdio_inspect_queue(q, bufnr, error);
}
EXPORT_SYMBOL_GPL(qdio_inspect_queue);
/**
* qdio_stop_irq - disable interrupt processing for the device
* @cdev: associated ccw_device for the qdio subchannel
......
......@@ -5850,10 +5850,10 @@ static unsigned int qeth_rx_poll(struct qeth_card *card, int budget)
/* Fetch completed RX buffers: */
if (!card->rx.b_count) {
card->rx.qdio_err = 0;
card->rx.b_count = qdio_inspect_queue(CARD_DDEV(card),
0, true,
&card->rx.b_index,
&card->rx.qdio_err);
card->rx.b_count =
qdio_inspect_input_queue(CARD_DDEV(card), 0,
&card->rx.b_index,
&card->rx.qdio_err);
if (card->rx.b_count <= 0) {
card->rx.b_count = 0;
break;
......@@ -5900,8 +5900,8 @@ static void qeth_cq_poll(struct qeth_card *card)
unsigned int start, error;
int completed;
completed = qdio_inspect_queue(CARD_DDEV(card), 1, true, &start,
&error);
completed = qdio_inspect_input_queue(CARD_DDEV(card), 1, &start,
&error);
if (completed <= 0)
return;
......@@ -6038,8 +6038,8 @@ static int qeth_tx_poll(struct napi_struct *napi, int budget)
return 0;
}
completed = qdio_inspect_queue(CARD_DDEV(card), queue_no, false,
&start, &error);
completed = qdio_inspect_output_queue(CARD_DDEV(card), queue_no,
&start, &error);
if (completed <= 0) {
/* Ensure we see TX completion for pending work: */
if (napi_complete_done(napi, 0) &&
......
......@@ -79,7 +79,7 @@ static void zfcp_qdio_request_tasklet(struct tasklet_struct *tasklet)
unsigned int start, error;
int completed;
completed = qdio_inspect_queue(cdev, 0, false, &start, &error);
completed = qdio_inspect_output_queue(cdev, 0, &start, &error);
if (completed > 0) {
if (error) {
zfcp_qdio_handler_error(qdio, "qdreqt1", error);
......@@ -169,7 +169,7 @@ static void zfcp_qdio_irq_tasklet(struct tasklet_struct *tasklet)
tasklet_schedule(&qdio->request_tasklet);
/* Check the Response Queue: */
completed = qdio_inspect_queue(cdev, 0, true, &start, &error);
completed = qdio_inspect_input_queue(cdev, 0, &start, &error);
if (completed < 0)
return;
if (completed > 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment