int main(int argc, char *argv[])
{
struct ibv_device **dev_list;
+ int num_devices, i;
- dev_list = ibv_get_device_list(NULL);
+ dev_list = ibv_get_device_list(&num_devices);
if (!dev_list) {
fprintf(stderr, "No IB devices found\n");
return 1;
printf(" %-16s\t node GUID\n", "device");
printf(" %-16s\t----------------\n", "------");
- while (*dev_list) {
+ for (i = 0; i < num_devices; ++i) {
printf(" %-16s\t%016llx\n",
- ibv_get_device_name(*dev_list),
- (unsigned long long) ntohll(ibv_get_device_guid(*dev_list)));
- ++dev_list;
+ ibv_get_device_name(dev_list[i]),
+ (unsigned long long) ntohll(ibv_get_device_guid(dev_list[i])));
}
+ ibv_free_device_list(dev_list);
+
return 0;
}
{
char *ib_devname = NULL;
int ret = 0;
- struct ibv_device **dev_list;
+ struct ibv_device **dev_list, **orig_dev_list;
int num_of_hcas;
int ib_port = 0;
break;
case 'l':
- dev_list = ibv_get_device_list(&num_of_hcas);
+ dev_list = orig_dev_list = ibv_get_device_list(&num_of_hcas);
if (!dev_list) {
fprintf(stderr, "Failed to get IB devices list");
return -1;
}
printf("\n");
+
+ ibv_free_device_list(orig_dev_list);
+
return 0;
default:
}
}
- dev_list = ibv_get_device_list(NULL);
+ dev_list = orig_dev_list = ibv_get_device_list(NULL);
if (!dev_list) {
fprintf(stderr, "Failed to get IB device list\n");
return -1;
if (ib_devname)
free(ib_devname);
+ ibv_free_device_list(orig_dev_list);
+
return ret;
}
if (n < 0) {
fprintf(stderr, "%s for %s:%d\n", gai_strerror(n), servername, port);
+ free(service);
return NULL;
}
}
freeaddrinfo(res);
+ free(service);
if (sockfd < 0) {
fprintf(stderr, "Couldn't connect to %s:%d\n", servername, port);
if (n < 0) {
fprintf(stderr, "%s for port %d\n", gai_strerror(n), port);
+ free(service);
return NULL;
}
}
freeaddrinfo(res);
+ free(service);
if (sockfd < 0) {
fprintf(stderr, "Couldn't listen to port %d\n", port);
}
{
- struct ibv_qp_attr attr;
-
- attr.qp_state = IBV_QPS_INIT;
- attr.pkey_index = 0;
- attr.port_num = port;
- attr.qp_access_flags = 0;
+ struct ibv_qp_attr attr = {
+ .qp_state = IBV_QPS_INIT,
+ .pkey_index = 0,
+ .port_num = port,
+ .qp_access_flags = 0
+ };
if (ibv_modify_qp(ctx->qp, &attr,
IBV_QP_STATE |
if (n < 0) {
fprintf(stderr, "%s for %s:%d\n", gai_strerror(n), servername, port);
+ free(service);
return NULL;
}
}
freeaddrinfo(res);
+ free(service);
if (sockfd < 0) {
fprintf(stderr, "Couldn't connect to %s:%d\n", servername, port);
if (n < 0) {
fprintf(stderr, "%s for port %d\n", gai_strerror(n), port);
+ free(service);
return NULL;
}
}
freeaddrinfo(res);
+ free(service);
if (sockfd < 0) {
fprintf(stderr, "Couldn't listen to port %d\n", port);
}
for (i = 0; i < num_qp; ++i) {
- struct ibv_qp_attr attr;
-
- attr.qp_state = IBV_QPS_INIT;
- attr.pkey_index = 0;
- attr.port_num = port;
- attr.qp_access_flags = 0;
+ struct ibv_qp_attr attr = {
+ .qp_state = IBV_QPS_INIT,
+ .pkey_index = 0,
+ .port_num = port,
+ .qp_access_flags = 0
+ };
if (ibv_modify_qp(ctx->qp[i], &attr,
IBV_QP_STATE |
if (n < 0) {
fprintf(stderr, "%s for %s:%d\n", gai_strerror(n), servername, port);
+ free(service);
return NULL;
}
}
freeaddrinfo(res);
+ free(service);
if (sockfd < 0) {
fprintf(stderr, "Couldn't connect to %s:%d\n", servername, port);
if (n < 0) {
fprintf(stderr, "%s for port %d\n", gai_strerror(n), port);
+ free(service);
return NULL;
}
}
freeaddrinfo(res);
+ free(service);
if (sockfd < 0) {
fprintf(stderr, "Couldn't listen to port %d\n", port);
}
{
- struct ibv_qp_attr attr;
-
- attr.qp_state = IBV_QPS_INIT;
- attr.pkey_index = 0;
- attr.port_num = port;
- attr.qp_access_flags = 0;
+ struct ibv_qp_attr attr = {
+ .qp_state = IBV_QPS_INIT,
+ .pkey_index = 0,
+ .port_num = port,
+ .qp_access_flags = 0
+ };
if (ibv_modify_qp(ctx->qp, &attr,
IBV_QP_STATE |
static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn,
struct pingpong_dest *dest)
{
- struct ibv_qp_attr attr;
struct ibv_ah_attr ah_attr = {
.is_global = 0,
.dlid = dest->lid,
.src_path_bits = 0,
.port_num = port
};
-
- attr.qp_state = IBV_QPS_RTR;
+ struct ibv_qp_attr attr = {
+ .qp_state = IBV_QPS_RTR
+ };
if (ibv_modify_qp(ctx->qp, &attr, IBV_QP_STATE)) {
fprintf(stderr, "Failed to modify QP to RTR\n");
if (n < 0) {
fprintf(stderr, "%s for %s:%d\n", gai_strerror(n), servername, port);
+ free(service);
return NULL;
}
}
freeaddrinfo(res);
+ free(service);
if (sockfd < 0) {
fprintf(stderr, "Couldn't connect to %s:%d\n", servername, port);
if (n < 0) {
fprintf(stderr, "%s for port %d\n", gai_strerror(n), port);
+ free(service);
return NULL;
}
}
freeaddrinfo(res);
+ free(service);
if (sockfd < 0) {
fprintf(stderr, "Couldn't listen to port %d\n", port);
}
{
- struct ibv_qp_attr attr;
-
- attr.qp_state = IBV_QPS_INIT;
- attr.pkey_index = 0;
- attr.port_num = port;
- attr.qkey = 0x11111111;
+ struct ibv_qp_attr attr = {
+ .qp_state = IBV_QPS_INIT,
+ .pkey_index = 0,
+ .port_num = port,
+ .qkey = 0x11111111
+ };
if (ibv_modify_qp(ctx->qp, &attr,
IBV_QP_STATE |