ibv_destroy_cq

Posted on Mar 27, 2024

ibv_destroy_cq()

5.00 avg. rating (97% score) - 1 vote

int ibv_destroy_cq(struct ibv_cq *cq);

Description

ibv_destroy_cq() destroys a Completion Queue.

The destruction of a CQ will fail if any QP is still associated with it.

If there is any affiliated asynchronous event on that CQ that was read, using ibv_get_async_event(), but still wasn’t acknowledged, using ibv_ack_async_event(), calling to ibv_destroy_cq() will never end until that event will be acknowledged.

A CQ can be destroyed either if it is empty or contains Work Completions that still weren’t polled by ibv_poll_cq(). Also, it can be destroyed if a request for notification was requested using ibv_req_notify_cq() before any notification event was created.

Parameters

Name Direction Description
cq in CQ that was returned from ibv_create_cq()

Return Values

Value Description
0 On success
errno On failure
EBUSY One or more Work Queues is still associated with the CQ

Examples

Create a CQ with 100 entries and destroy it:

struct ibv_cq *cq;
 
cq = ibv_create_cq(context, 100, NULL, NULL, 0);
if (!cq) {
	fprintf(stderr, "Error, ibv_create_cq() failed\n");
	return -1;
}
 
if (ibv_destroy_cq(cq)) {
	fprintf(stderr, "Error, ibv_destroy_cq() failed\n");
	return -1;
}

FAQs

ibv_destroy_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_destroy_cq() failed, can I know which QPs are associated with it and caused this failure?

No, currently the RDMA stack doesn’t have this capability.

Can I destroy a CQ with Work Completion in it?

Yes, you can. When a CQ is being destroyed, it doesn’t matter if it contains Work Completions or not.

I called ibv_req_notify_cq() on a CQ and didn’t get any Completion event on it. Can I destroy that CQ?

Yes, you can.

I called ibv_destroy_cq(), but it never ended. What happened?

There is at least one affiliated asynchronous event on that CQ that was read without a proper acknowledgement.

Comments

Tell us what do you think.

Add a Comment

This comment will be moderated; answer may be provided within 14 days.