ibv_open_device()
Contents
struct ibv_context *ibv_open_device(struct ibv_device *device); |
Description
ibv_open_device() creates a context for the RDMA device device. This context will later be used to query its resources or for creating resources and should be released with ibv_close_device().
Unlike the verb name suggests, it doesn't actually open the device, this device was opened by the kernel low-level driver and may be used by other user/kernel level code. This verb only opens a context to allow user level applications to use it.
Parameters
Name | Direction | Description |
---|---|---|
device | in | RDMA device entry that was returned from ibv_get_device_list() |
Return Values
Value | Description | ||||
---|---|---|---|---|---|
device context | A pointer to the RDMA device context This pointer also contains the following fields:
|
||||
NULL | On failure |
Examples
Open a device context and close it:
/* In this example, we assume that this variable already holds the list of available devices */ struct ibv_device **device_list; struct ibv_context *ctx; ctx = ibv_open_device(device_list[0]); if (!ctx) { fprintf(stderr, "Error, failed to open the device '%s'\n", ibv_get_device_name(device_list[i])); return -1; } printf("The device '%s' was opened\n", ibv_get_device_name(ctx->device)); rc = ibv_close_device(ctx); if (rc) { fprintf(stderr, "Error, failed to close the device '%s'\n", ibv_get_device_name(ctx->device)); return -1; } |
Comments
Tell us what do you think.
Whenever I call a ibv_open_device will it return me a same context or a different one. This doubt is because can I use same protection domain for different rdma queue pairs.
Hi.
ibv_open_device() may or may not return a different context (it is implementation dependent).
I would suggest to you: please don't assume that the context is the same.
Thanks
Dotan
If this goes wrong, and returns NULL, is there a way to find out why?
Hi.
Unfortunately ,the answer is "no".
This is once of the problems in the RDMA verbs
:(
You can get the same errno code for many reasons, without a real ability to understand what went wrong.
Thanks
Dotan
Will the context still remain valid, if the RDMA device is rebooted after ibv_open_device() is called. Or do we need to call ibv_open_device() again after reboot to get a valid context?
Hi.
I don't understand what "RDMA device is rebooted", so i can't answer.
Can you elaborate on that?
Sorry
Dotan