Device Operations

The following commands are used for general device operations, allowing the user to query information about devices that are on the system as well as opening and closing a specific device.

Template: struct ibv_device **{*}ibv_get_device_list{*}(int *num_devices)

Input Parameters: none

Output Parameters: num_devices(optional) If non-null, the number of devices returned in the array will be stored here

Return Value: NULL terminated array of VPI devices or NULL on failure.

Description: ibv_get_device_list returns a list of VPI devices available on the system. Each entry on the list is a pointer to a struct ibv_device.

struct ibv_device is defined as:

Copy
Copied!
            

struct ibv_device { struct ibv_device_ops ops; enum ibv_node_type node_type; enum ibv_transport_type transport_type; char name[IBV_SYSFS_NAME_MAX]; char dev_name[IBV_SYSFS_NAME_MAX]; char dev_path[IBV_SYSFS_PATH_MAX]; char ibdev_path[IBV_SYSFS_PATH_MAX]; };   ops pointers to alloc and free functions node_type IBV_NODE_UNKNOWN IBV_NODE_CA IBV_NODE_SWITCH IBV_NODE_ROUTER IBV_NODE_RNIC transport_type IBV_TRANSPORT_UNKNOWN IBV_TRANSPORT_IB IBV_TRANSPORT_IWARP name kernel device name eg “mthca0” dev_name uverbs device name eg “uverbs0” dev_path path to infiniband_verbs class device in sysfs ibdev_path path to infiniband class device in sysfs

The list of ibv_device structs shall remain valid until the list is freed. After calling ibv_get_device_list, the user should open any desired devices and promptly free the list via the ibv_free_device_list command.

Template: void ibv_free_device_list(struct ibv_device **list)

Input Parameters: list list of devices provided from ibv_get_device_list command

Output Parameters: none

Return Value: none

Description: ibv_free_device_list frees the list of ibv_device structs provided by ibv_get_device_list. Any desired devices should be opened prior to calling this command. Once the list is freed, all ibv_de- vice structs that were on the list are invalid and can no longer be used.

Template: const char {}ibv_get_device_name{*}(struct ibv_device *device)

Input Parameters: devicestruct ibv_device for desired device

Output Parameters: none

Return Value: Pointer to device name char string or NULL on failure.

Description: ibv_get_device_name returns a pointer to the device name contained within the ibv_device struct.

Template: uint64_t ibv_get_device_guid(struct ibv_device *device)

Input Parameters: devicestruct ibv_device for desired device

Output Parameters: none

Return Value: 64 bit GUID

Description: ibv_get_device_guid returns the devices 64 bit Global Unique Identifier (GUID) in network byte order.

Template: struct ibv_context {}ibv_open_device{*}(struct ibv_device *device)

Input Parameters: devicestruct ibv_device for desired device

Output Parameters: none

Return Value: A verbs context that can be used for future operations on the device or NULL on failure.

Description: ibv_open_device provides the user with a verbs context which is the object that will be used for all other verb operations.

Template: int ibv_close_device(struct ibv_context *context)

Input Parameters: context struct ibv_context from ibv_open_device

Output Parameters: none

Return Value: 0 on success, -1 on error. If the call fails, errno will be set to indicate the reason for the failure.

Description: ibv_close_device closes the verb context previously opened with ibv_open_device. This operation does not free any other objects associated with the context. To avoid memory leaks, all other objects must be independently freed prior to calling this command.

Template: const char {}ibv_node_type_str* (enum ibv_node_type node_type)

Input Parameters: node_typeibv_node_typeenumvaluewhich may be an HCA, Switch, Router, RNIC or Unknown

Output Parameters: none

Return Value: A constant string which describes the enum value node_type

Description: ibv_node_type_str returns a string describing the node type enum value, node_type. This value can be an InfiniBand HCA, Switch, Router, an RDMA enabled NIC or unknown

Copy
Copied!
            

enum ibv_node_type { IBV_NODE_UNKNOWN = -1, IBV_NODE_CA = 1, IBV_NODE_SWITCH, IBV_NODE_ROUTER, IBV_NODE_RNIC };

Template: const char {}ibv_port_state_str* (enum ibv_port_state port_state)

Input Parameters: port_state The enumerated value of the port state

Output Parameters: None

Return Value: A constant string which describes the enum value port_state

Description: ibv_port_state_str returns a string describing the port state enum value, port_state.

Copy
Copied!
            

enum ibv_port_state { IBV_PORT_NOP = 0, IBV_PORT_DOWN = 1, IBV_PORT_INIT = 2, IBV_PORT_ARMED = 3, IBV_PORT_ACTIVE = 4, IBV_PORT_ACTIVE_DEFER = 5 };

© Copyright 2023, NVIDIA. Last updated on May 23, 2023.