diff options
author | Roland Dreier <rolandd@cisco.com> | 2008-07-15 02:48:49 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2008-07-15 02:48:49 -0400 |
commit | 1ff66e8c1faee7c2711b84b9c89e1c5fcd767839 (patch) | |
tree | 7a42adc119605abd1acb54d16b8a93f1effd2069 /drivers/infiniband/hw/nes/nes_utils.c | |
parent | ee1e2c82c245a5fb2864e9dbcdaab3390fde3fcc (diff) |
RDMA/nes: Encapsulate logic nes_put_cqp_request()
The iw_nes driver repeats the logic
if (atomic_dec_and_test(&cqp_request->refcount)) {
if (cqp_request->dynamic) {
kfree(cqp_request);
} else {
spin_lock_irqsave(&nesdev->cqp.lock, flags);
list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
}
}
over and over. Wrap this up in functions nes_free_cqp_request() and
nes_put_cqp_request() to simplify such code.
In addition to making the source smaller and more readable, this shrinks
the compiled code quite a bit:
add/remove: 2/0 grow/shrink: 0/13 up/down: 164/-1692 (-1528)
function old new delta
nes_free_cqp_request - 147 +147
nes_put_cqp_request - 17 +17
nes_modify_qp 2316 2293 -23
nes_hw_modify_qp 737 657 -80
nes_dereg_mr 945 860 -85
flush_wqes 501 416 -85
nes_manage_apbvt 648 560 -88
nes_reg_mr 1117 1026 -91
nes_cqp_ce_handler 927 769 -158
nes_alloc_mw 1052 884 -168
nes_create_qp 5314 5141 -173
nes_alloc_fmr 2212 2035 -177
nes_destroy_cq 1097 918 -179
nes_create_cq 2787 2598 -189
nes_dealloc_mw 762 566 -196
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Acked-by: Faisal Latif <flatif@neteffect.com>
Diffstat (limited to 'drivers/infiniband/hw/nes/nes_utils.c')
-rw-r--r-- | drivers/infiniband/hw/nes/nes_utils.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/nes/nes_utils.c b/drivers/infiniband/hw/nes/nes_utils.c index fe83d1b2b177..8f519c860872 100644 --- a/drivers/infiniband/hw/nes/nes_utils.c +++ b/drivers/infiniband/hw/nes/nes_utils.c | |||
@@ -567,6 +567,30 @@ struct nes_cqp_request *nes_get_cqp_request(struct nes_device *nesdev) | |||
567 | return cqp_request; | 567 | return cqp_request; |
568 | } | 568 | } |
569 | 569 | ||
570 | void nes_free_cqp_request(struct nes_device *nesdev, | ||
571 | struct nes_cqp_request *cqp_request) | ||
572 | { | ||
573 | unsigned long flags; | ||
574 | |||
575 | nes_debug(NES_DBG_CQP, "CQP request %p (opcode 0x%02X) freed.\n", | ||
576 | cqp_request, | ||
577 | le32_to_cpu(cqp_request->cqp_wqe.wqe_words[NES_CQP_WQE_OPCODE_IDX]) & 0x3f); | ||
578 | |||
579 | if (cqp_request->dynamic) { | ||
580 | kfree(cqp_request); | ||
581 | } else { | ||
582 | spin_lock_irqsave(&nesdev->cqp.lock, flags); | ||
583 | list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs); | ||
584 | spin_unlock_irqrestore(&nesdev->cqp.lock, flags); | ||
585 | } | ||
586 | } | ||
587 | |||
588 | void nes_put_cqp_request(struct nes_device *nesdev, | ||
589 | struct nes_cqp_request *cqp_request) | ||
590 | { | ||
591 | if (atomic_dec_and_test(&cqp_request->refcount)) | ||
592 | nes_free_cqp_request(nesdev, cqp_request); | ||
593 | } | ||
570 | 594 | ||
571 | /** | 595 | /** |
572 | * nes_post_cqp_request | 596 | * nes_post_cqp_request |