aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/net
diff options
context:
space:
mode:
authorSebastian Ott <sebott@linux.vnet.ibm.com>2014-06-27 11:04:07 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2014-07-22 03:26:14 -0400
commit4601ba6c92b000dcda37c9d74587e3b88374c00c (patch)
tree6b045f597b92aa35483e446ca1804ba3bd77a599 /drivers/s390/net
parent5245c924c2191ee0f39d8586a57178baba13dbf2 (diff)
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: Ursula Braun <ursula.braun@de.ibm.com> Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/net')
-rw-r--r--drivers/s390/net/qeth_core_main.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index f54bec54d677..a0a6ad7a1739 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -292,6 +292,26 @@ int qeth_realloc_buffer_pool(struct qeth_card *card, int bufcnt)
292} 292}
293EXPORT_SYMBOL_GPL(qeth_realloc_buffer_pool); 293EXPORT_SYMBOL_GPL(qeth_realloc_buffer_pool);
294 294
295static void qeth_free_qdio_queue(struct qeth_qdio_q *q)
296{
297 kfree(q);
298}
299
300static struct qeth_qdio_q *qeth_alloc_qdio_queue(void)
301{
302 struct qeth_qdio_q *q = kzalloc(sizeof(*q), GFP_KERNEL);
303 int i;
304
305 if (!q)
306 return NULL;
307
308 for (i = 0; i < QDIO_MAX_BUFFERS_PER_Q; ++i)
309 q->bufs[i].buffer = &q->qdio_bufs[i];
310
311 QETH_DBF_HEX(SETUP, 2, &q, sizeof(void *));
312 return q;
313}
314
295static inline int qeth_cq_init(struct qeth_card *card) 315static inline int qeth_cq_init(struct qeth_card *card)
296{ 316{
297 int rc; 317 int rc;
@@ -323,21 +343,12 @@ static inline int qeth_alloc_cq(struct qeth_card *card)
323 struct qdio_outbuf_state *outbuf_states; 343 struct qdio_outbuf_state *outbuf_states;
324 344
325 QETH_DBF_TEXT(SETUP, 2, "cqon"); 345 QETH_DBF_TEXT(SETUP, 2, "cqon");
326 card->qdio.c_q = kzalloc(sizeof(struct qeth_qdio_q), 346 card->qdio.c_q = qeth_alloc_qdio_queue();
327 GFP_KERNEL);
328 if (!card->qdio.c_q) { 347 if (!card->qdio.c_q) {
329 rc = -1; 348 rc = -1;
330 goto kmsg_out; 349 goto kmsg_out;
331 } 350 }
332 QETH_DBF_HEX(SETUP, 2, &card->qdio.c_q, sizeof(void *));
333
334 for (i = 0; i < QDIO_MAX_BUFFERS_PER_Q; ++i) {
335 card->qdio.c_q->bufs[i].buffer =
336 &card->qdio.c_q->qdio_bufs[i];
337 }
338
339 card->qdio.no_in_queues = 2; 351 card->qdio.no_in_queues = 2;
340
341 card->qdio.out_bufstates = 352 card->qdio.out_bufstates =
342 kzalloc(card->qdio.no_out_queues * 353 kzalloc(card->qdio.no_out_queues *
343 QDIO_MAX_BUFFERS_PER_Q * 354 QDIO_MAX_BUFFERS_PER_Q *
@@ -361,7 +372,7 @@ static inline int qeth_alloc_cq(struct qeth_card *card)
361out: 372out:
362 return rc; 373 return rc;
363free_cq_out: 374free_cq_out:
364 kfree(card->qdio.c_q); 375 qeth_free_qdio_queue(card->qdio.c_q);
365 card->qdio.c_q = NULL; 376 card->qdio.c_q = NULL;
366kmsg_out: 377kmsg_out:
367 dev_err(&card->gdev->dev, "Failed to create completion queue\n"); 378 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)
372{ 383{
373 if (card->qdio.c_q) { 384 if (card->qdio.c_q) {
374 --card->qdio.no_in_queues; 385 --card->qdio.no_in_queues;
375 kfree(card->qdio.c_q); 386 qeth_free_qdio_queue(card->qdio.c_q);
376 card->qdio.c_q = NULL; 387 card->qdio.c_q = NULL;
377 } 388 }
378 kfree(card->qdio.out_bufstates); 389 kfree(card->qdio.out_bufstates);
@@ -1296,7 +1307,7 @@ static void qeth_free_qdio_buffers(struct qeth_card *card)
1296 if (card->qdio.in_q->bufs[j].rx_skb) 1307 if (card->qdio.in_q->bufs[j].rx_skb)
1297 dev_kfree_skb_any(card->qdio.in_q->bufs[j].rx_skb); 1308 dev_kfree_skb_any(card->qdio.in_q->bufs[j].rx_skb);
1298 } 1309 }
1299 kfree(card->qdio.in_q); 1310 qeth_free_qdio_queue(card->qdio.in_q);
1300 card->qdio.in_q = NULL; 1311 card->qdio.in_q = NULL;
1301 /* inbound buffer pool */ 1312 /* inbound buffer pool */
1302 qeth_free_buffer_pool(card); 1313 qeth_free_buffer_pool(card);
@@ -2422,19 +2433,11 @@ static int qeth_alloc_qdio_buffers(struct qeth_card *card)
2422 QETH_QDIO_ALLOCATED) != QETH_QDIO_UNINITIALIZED) 2433 QETH_QDIO_ALLOCATED) != QETH_QDIO_UNINITIALIZED)
2423 return 0; 2434 return 0;
2424 2435
2425 card->qdio.in_q = kzalloc(sizeof(struct qeth_qdio_q), 2436 QETH_DBF_TEXT(SETUP, 2, "inq");
2426 GFP_KERNEL); 2437 card->qdio.in_q = qeth_alloc_qdio_queue();
2427 if (!card->qdio.in_q) 2438 if (!card->qdio.in_q)
2428 goto out_nomem; 2439 goto out_nomem;
2429 QETH_DBF_TEXT(SETUP, 2, "inq"); 2440
2430 QETH_DBF_HEX(SETUP, 2, &card->qdio.in_q, sizeof(void *));
2431 memset(card->qdio.in_q, 0, sizeof(struct qeth_qdio_q));
2432 /* give inbound qeth_qdio_buffers their qdio_buffers */
2433 for (i = 0; i < QDIO_MAX_BUFFERS_PER_Q; ++i) {
2434 card->qdio.in_q->bufs[i].buffer =
2435 &card->qdio.in_q->qdio_bufs[i];
2436 card->qdio.in_q->bufs[i].rx_skb = NULL;
2437 }
2438 /* inbound buffer pool */ 2441 /* inbound buffer pool */
2439 if (qeth_alloc_buffer_pool(card)) 2442 if (qeth_alloc_buffer_pool(card))
2440 goto out_freeinq; 2443 goto out_freeinq;
@@ -2484,7 +2487,7 @@ out_freeoutq:
2484out_freepool: 2487out_freepool:
2485 qeth_free_buffer_pool(card); 2488 qeth_free_buffer_pool(card);
2486out_freeinq: 2489out_freeinq:
2487 kfree(card->qdio.in_q); 2490 qeth_free_qdio_queue(card->qdio.in_q);
2488 card->qdio.in_q = NULL; 2491 card->qdio.in_q = NULL;
2489out_nomem: 2492out_nomem:
2490 atomic_set(&card->qdio.state, QETH_QDIO_UNINITIALIZED); 2493 atomic_set(&card->qdio.state, QETH_QDIO_UNINITIALIZED);