ibv_resize_cq()
Contents
int ibv_resize_cq(struct ibv_cq *cq, int cqe); |
Description
ibv_resize_cq() resizes a Completion Queue.
A CQ can be resized either if it is empty or contains Work Completions that still weren’t polled by ibv_poll_cq(). It can be resized if request for notification was requested using ibv_req_notify_cq() before any notification event was created. It can be resized either if one or more QPs are associated with it or not.
If the CQ size is being decreased, there are some limitations to the new size:
- It can't be less than the number of Work Completion that currently exists in the CQ
- It should be enough to hold the Work Completions that may enter this CQ (otherwise, CQ overrun will occur(
The user can define the minimum size of the CQ. The actual size can be equal or higher than this value.
Calling to ibv_resize_cq() may not do anything since this verb only guarantees to resize the CQ to a size at least as big as the requested size.
Parameters
Name | Direction | Description |
---|---|---|
cq | in | CQ that was returned from ibv_create_cq() |
cqe | in | The minimum requested capacity of the CQ after resizing it, value can be [1..dev_cap.max_cqe] |
Return Values
Value | Description |
---|---|
0 | On success
cq->cqe will hold the actual size of the CQ after resizing it |
errno | On failure |
EINVAL | Invalid cqe |
ENOMEM | Not enough resources to complete this operation |
ENOSYS | CQ resize is not supported by this device |
Examples
Resize a CQ to have at least 2000 entries:
struct ibv_cq *cq; /* A pointer to a CQ that was created before */ if (ibv_resize_cq(cq, 2000)) { fprintf(stderr, "Error, ibv_resize_cq() failed\n"); return -1; } |
FAQs
ibv_resize_cq() failed, what will happen to the QPs which are associated with it?
Nothing at all. You can continue working with them without any side-effect.
ibv_resize_cq() failed, can I know how many Work Completion exists in this CQ?
No, the RDMA stack doesn’t have this capability (it wasn't defined in the specifications).
Can I resize a CQ which holds Work Completions in it?
Yes, you can.
I called ibv_req_notify_cq() on a CQ and didn't get any Completion event on it. Can I resize that CQ?
Yes, you can as long as the new size isn't smaller than the current number of the Work Completions in that CQ.
I called ibv_resize_cq() and tried to decrease the CQ size, but the CQ size wasn't changed. What happened?
This may happen. The rule is that a user can define the minimum size of the CQ and the actual size can be equal or higher than this value. Trying decreasing the CQ size may result in doing nothing; this is implementation (of the low-level driver) dependent.
Comments
Tell us what do you think.
There are no comments on this entry.