If an AIX® application needs to determine which verbs API to use (OFED iWARP/RNIC verbs or AIX IB verbs) to communicate with a specific destination, here is an example in pseudo-code, to test the result of a rdma_resolve_addr command on the required remote address to know if OFED iWARP/RNIC verbs can be used.
/*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);
}