提交 4601ba6c 编写于 作者: S Sebastian Ott 提交者: Martin Schwidefsky

s390/qeth: qdio queue helpers

Get rid of duplicated code by introducing some helpers to allocate
and free qdio queues used by qeth for its input and completion queue.

No functional change.
Reviewed-by: NUrsula Braun <ursula.braun@de.ibm.com>
Signed-off-by: NSebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
上级 5245c924
......@@ -292,6 +292,26 @@ int qeth_realloc_buffer_pool(struct qeth_card *card, int bufcnt)
}
EXPORT_SYMBOL_GPL(qeth_realloc_buffer_pool);
static void qeth_free_qdio_queue(struct qeth_qdio_q *q)
{
kfree(q);
}
static struct qeth_qdio_q *qeth_alloc_qdio_queue(void)
{
struct qeth_qdio_q *q = kzalloc(sizeof(*q), GFP_KERNEL);
int i;
if (!q)
return NULL;
for (i = 0; i < QDIO_MAX_BUFFERS_PER_Q; ++i)
q->bufs[i].buffer = &q->qdio_bufs[i];
QETH_DBF_HEX(SETUP, 2, &q, sizeof(void *));
return q;
}
static inline int qeth_cq_init(struct qeth_card *card)
{
int rc;
......@@ -323,21 +343,12 @@ static inline int qeth_alloc_cq(struct qeth_card *card)
struct qdio_outbuf_state *outbuf_states;
QETH_DBF_TEXT(SETUP, 2, "cqon");
card->qdio.c_q = kzalloc(sizeof(struct qeth_qdio_q),
GFP_KERNEL);
card->qdio.c_q = qeth_alloc_qdio_queue();
if (!card->qdio.c_q) {
rc = -1;
goto kmsg_out;
}
QETH_DBF_HEX(SETUP, 2, &card->qdio.c_q, sizeof(void *));
for (i = 0; i < QDIO_MAX_BUFFERS_PER_Q; ++i) {
card->qdio.c_q->bufs[i].buffer =
&card->qdio.c_q->qdio_bufs[i];
}
card->qdio.no_in_queues = 2;
card->qdio.out_bufstates =
kzalloc(card->qdio.no_out_queues *
QDIO_MAX_BUFFERS_PER_Q *
......@@ -361,7 +372,7 @@ static inline int qeth_alloc_cq(struct qeth_card *card)
out:
return rc;
free_cq_out:
kfree(card->qdio.c_q);
qeth_free_qdio_queue(card->qdio.c_q);
card->qdio.c_q = NULL;
kmsg_out:
dev_err(&card->gdev->dev, "Failed to create completion queue\n");
......@@ -372,7 +383,7 @@ static inline void qeth_free_cq(struct qeth_card *card)
{
if (card->qdio.c_q) {
--card->qdio.no_in_queues;
kfree(card->qdio.c_q);
qeth_free_qdio_queue(card->qdio.c_q);
card->qdio.c_q = NULL;
}
kfree(card->qdio.out_bufstates);
......@@ -1296,7 +1307,7 @@ static void qeth_free_qdio_buffers(struct qeth_card *card)
if (card->qdio.in_q->bufs[j].rx_skb)
dev_kfree_skb_any(card->qdio.in_q->bufs[j].rx_skb);
}
kfree(card->qdio.in_q);
qeth_free_qdio_queue(card->qdio.in_q);
card->qdio.in_q = NULL;
/* inbound buffer pool */
qeth_free_buffer_pool(card);
......@@ -2422,19 +2433,11 @@ static int qeth_alloc_qdio_buffers(struct qeth_card *card)
QETH_QDIO_ALLOCATED) != QETH_QDIO_UNINITIALIZED)
return 0;
card->qdio.in_q = kzalloc(sizeof(struct qeth_qdio_q),
GFP_KERNEL);
QETH_DBF_TEXT(SETUP, 2, "inq");
card->qdio.in_q = qeth_alloc_qdio_queue();
if (!card->qdio.in_q)
goto out_nomem;
QETH_DBF_TEXT(SETUP, 2, "inq");
QETH_DBF_HEX(SETUP, 2, &card->qdio.in_q, sizeof(void *));
memset(card->qdio.in_q, 0, sizeof(struct qeth_qdio_q));
/* give inbound qeth_qdio_buffers their qdio_buffers */
for (i = 0; i < QDIO_MAX_BUFFERS_PER_Q; ++i) {
card->qdio.in_q->bufs[i].buffer =
&card->qdio.in_q->qdio_bufs[i];
card->qdio.in_q->bufs[i].rx_skb = NULL;
}
/* inbound buffer pool */
if (qeth_alloc_buffer_pool(card))
goto out_freeinq;
......@@ -2484,7 +2487,7 @@ static int qeth_alloc_qdio_buffers(struct qeth_card *card)
out_freepool:
qeth_free_buffer_pool(card);
out_freeinq:
kfree(card->qdio.in_q);
qeth_free_qdio_queue(card->qdio.in_q);
card->qdio.in_q = NULL;
out_nomem:
atomic_set(&card->qdio.state, QETH_QDIO_UNINITIALIZED);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册