Verbs API
An AIX® application can determine the verbs API that is either the Open Fabrics Enterprise Distribution (OFED) verbs or the AIX InfiniBand (IB) verbs that must communicate with a specific destination.
The following example in pseudocode tests the result of the rdma_resolve_addr command on the required remote address to determine the OFED verbs that can be used.
The program returns the following values:
- 0- if the communication with the destination can be established by using the OFED verbs.
- error- if the communication with the destination cannot be established through an OFED supported device, but communication can be established by using the InfiniBand architecture.
/*The following check_ofed_verbs_support routine does:
/*- Call rdma_create_event_channel to open a channel event */
/*- Calls rdma_create_id() to get a cm_id */
/*- And then calls rdma_resolve_addr() */
/*- Get the communication event */
/*- Returns the event status: */
/* 0: OK */
/* error: NOK output device may be not a RNIC device */
/*- Calls rdma_destroy_id() to delete the cm_id created */
/*- Call rdma_destroy_event_channel to close a channel event */
int check_ofed_verbs_support (struct sockaddr *remoteaddr)
{
struct rdma_event channel *cm_channel;
struct rdma_cm_id *cm_id;
int ret=0;
cm_channel = rdma_create_event_channel();
if (!cm_channel) {
fprintf(stderr,"rdma_create_event_channel error\n");
return -1;
}
ret = rdma_create_id(cm_channel, &cm_id, NULL, RDMA_PS_TCP);
if (ret) {
fprintf(stderr,"rdma_create_id: %d\n", ret);
rdma_destroy_event_channel(cm_channel);
return(ret);
}
ret = rdma_resolve_addr(cm_id, NULL, remoteaddr, RESOLVE_TIMEOUT_MS);
if (ret) {
fprintf(stderr,"rdma_resolve_addr: %d\n", ret);
goto out;
}
ret = rdma_get_cm_event(cm_channel, &event);
if (ret) {
fprintf(stderr," rdma_get_cm_event() failed\n");
goto out;
}
ret = event->status;
rdma_ack_cm_event(event);
out:
rdma_destroy_id(cm_id);
rdma_destroy_event_channel(cm_channel);
return(ret);
}