Commit 664e42ac authored by Julian Wiedmann's avatar Julian Wiedmann Committed by David S. Miller

s390/qeth: consolidate pack buffer flushing

qeth_switch_to_nonpacking_if_needed() contains an open-coded version
of qeth_flush_buffers_on_no_pci(). Extract a single helper instead.
Signed-off-by: default avatarJulian Wiedmann <jwi@linux.vnet.ibm.com>
Acked-by: default avatarUrsula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 84616e86
...@@ -3347,6 +3347,28 @@ static void qeth_handle_send_error(struct qeth_card *card, ...@@ -3347,6 +3347,28 @@ static void qeth_handle_send_error(struct qeth_card *card,
(u16)qdio_err, (u8)sbalf15); (u16)qdio_err, (u8)sbalf15);
} }
/**
* qeth_prep_flush_pack_buffer - Prepares flushing of a packing buffer.
* @queue: queue to check for packing buffer
*
* Returns number of buffers that were prepared for flush.
*/
static int qeth_prep_flush_pack_buffer(struct qeth_qdio_out_q *queue)
{
struct qeth_qdio_out_buffer *buffer;
buffer = queue->bufs[queue->next_buf_to_fill];
if ((atomic_read(&buffer->state) == QETH_QDIO_BUF_EMPTY) &&
(buffer->next_element_to_fill > 0)) {
/* it's a packing buffer */
atomic_set(&buffer->state, QETH_QDIO_BUF_PRIMED);
queue->next_buf_to_fill =
(queue->next_buf_to_fill + 1) % QDIO_MAX_BUFFERS_PER_Q;
return 1;
}
return 0;
}
/* /*
* Switched to packing state if the number of used buffers on a queue * Switched to packing state if the number of used buffers on a queue
* reaches a certain limit. * reaches a certain limit.
...@@ -3373,9 +3395,6 @@ static void qeth_switch_to_packing_if_needed(struct qeth_qdio_out_q *queue) ...@@ -3373,9 +3395,6 @@ static void qeth_switch_to_packing_if_needed(struct qeth_qdio_out_q *queue)
*/ */
static int qeth_switch_to_nonpacking_if_needed(struct qeth_qdio_out_q *queue) static int qeth_switch_to_nonpacking_if_needed(struct qeth_qdio_out_q *queue)
{ {
struct qeth_qdio_out_buffer *buffer;
int flush_count = 0;
if (queue->do_pack) { if (queue->do_pack) {
if (atomic_read(&queue->used_buffers) if (atomic_read(&queue->used_buffers)
<= QETH_LOW_WATERMARK_PACK) { <= QETH_LOW_WATERMARK_PACK) {
...@@ -3384,41 +3403,8 @@ static int qeth_switch_to_nonpacking_if_needed(struct qeth_qdio_out_q *queue) ...@@ -3384,41 +3403,8 @@ static int qeth_switch_to_nonpacking_if_needed(struct qeth_qdio_out_q *queue)
if (queue->card->options.performance_stats) if (queue->card->options.performance_stats)
queue->card->perf_stats.sc_p_dp++; queue->card->perf_stats.sc_p_dp++;
queue->do_pack = 0; queue->do_pack = 0;
/* flush packing buffers */ return qeth_prep_flush_pack_buffer(queue);
buffer = queue->bufs[queue->next_buf_to_fill];
if ((atomic_read(&buffer->state) ==
QETH_QDIO_BUF_EMPTY) &&
(buffer->next_element_to_fill > 0)) {
atomic_set(&buffer->state,
QETH_QDIO_BUF_PRIMED);
flush_count++;
queue->next_buf_to_fill =
(queue->next_buf_to_fill + 1) %
QDIO_MAX_BUFFERS_PER_Q;
}
}
} }
return flush_count;
}
/*
* Called to flush a packing buffer if no more pci flags are on the queue.
* Checks if there is a packing buffer and prepares it to be flushed.
* In that case returns 1, otherwise zero.
*/
static int qeth_flush_buffers_on_no_pci(struct qeth_qdio_out_q *queue)
{
struct qeth_qdio_out_buffer *buffer;
buffer = queue->bufs[queue->next_buf_to_fill];
if ((atomic_read(&buffer->state) == QETH_QDIO_BUF_EMPTY) &&
(buffer->next_element_to_fill > 0)) {
/* it's a packing buffer */
atomic_set(&buffer->state, QETH_QDIO_BUF_PRIMED);
queue->next_buf_to_fill =
(queue->next_buf_to_fill + 1) % QDIO_MAX_BUFFERS_PER_Q;
return 1;
} }
return 0; return 0;
} }
...@@ -3532,8 +3518,7 @@ static void qeth_check_outbound_queue(struct qeth_qdio_out_q *queue) ...@@ -3532,8 +3518,7 @@ static void qeth_check_outbound_queue(struct qeth_qdio_out_q *queue)
flush_cnt += qeth_switch_to_nonpacking_if_needed(queue); flush_cnt += qeth_switch_to_nonpacking_if_needed(queue);
if (!flush_cnt && if (!flush_cnt &&
!atomic_read(&queue->set_pci_flags_count)) !atomic_read(&queue->set_pci_flags_count))
flush_cnt += flush_cnt += qeth_prep_flush_pack_buffer(queue);
qeth_flush_buffers_on_no_pci(queue);
if (queue->card->options.performance_stats && if (queue->card->options.performance_stats &&
q_was_packing) q_was_packing)
queue->card->perf_stats.bufs_sent_pack += queue->card->perf_stats.bufs_sent_pack +=
...@@ -4127,7 +4112,7 @@ int qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue, ...@@ -4127,7 +4112,7 @@ int qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue,
* flag out on the queue * flag out on the queue
*/ */
if (!flush_count && !atomic_read(&queue->set_pci_flags_count)) if (!flush_count && !atomic_read(&queue->set_pci_flags_count))
flush_count += qeth_flush_buffers_on_no_pci(queue); flush_count += qeth_prep_flush_pack_buffer(queue);
if (flush_count) if (flush_count)
qeth_flush_buffers(queue, start_index, flush_count); qeth_flush_buffers(queue, start_index, flush_count);
} }
......
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