Example #1
0
static int fi_ibv_get_srcaddr_devs(struct fi_info **info)
{
	struct fi_info *fi, *add_info;
	struct fi_info *fi_unconf = NULL, *fi_prev = NULL;
	struct verbs_dev_info *dev;
	struct verbs_addr *addr;
	int ret = 0;

	DEFINE_LIST(verbs_devs);

	ret = fi_ibv_getifaddrs(&verbs_devs);
	if (ret)
		return ret;

	if (dlist_empty(&verbs_devs)) {
		VERBS_WARN(FI_LOG_CORE, "No interface address found\n");
		return 0;
	}

	for (fi = *info; fi; fi = fi->next) {
		dlist_foreach_container(&verbs_devs, struct verbs_dev_info, dev, entry)
			if (!strncmp(fi->domain_attr->name, dev->name, strlen(dev->name))) {
				dlist_foreach_container(&dev->addrs, struct verbs_addr, addr, entry) {
					/* When a device has multiple interfaces/addresses configured
					 * duplicate fi_info and add the address info. fi->src_addr
					 * would have been set in the previous iteration */
					if (fi->src_addr) {
						if (!(add_info = fi_dupinfo(fi))) {
							ret = -FI_ENOMEM;
							goto out;
						}

						add_info->next = fi->next;
						fi->next = add_info;
						fi = add_info;
					}

					ret = fi_ibv_rai_to_fi(addr->rai, fi);
					if (ret)
						goto out;
				}
				break;
			}
	}
Example #2
0
bool test_list()
{
    bool test_result = true; // true == passed
    
    DEFINE_LIST(int, int_list);
    DEFINE_LIST(Vector, vec_list);
    
    int_list test_int;
    vec_list test_vec;
    
    CREATE_LIST(test_int, int, 5);
    CREATE_LIST(test_vec, Vector, 5);
    
    ADD_LIST(test_int, 5);
    
    CHECK(test_int.l[0] == 5, "test_int vector ADD_LIST failed");
    CHECK(test_int.cur_size = 1, "test_int vector ADD_LIST failed");

    ADD_LIST(test_int, 6);
    ADD_LIST(test_int, 7);
    ADD_LIST(test_int, 8);
    ADD_LIST(test_int, 9);
    ADD_LIST(test_int, 10);
    ADD_LIST(test_int, 11);

    CHECK(test_int.l[0] == 5, "test_int vector ADD_LIST failed");
    CHECK(test_int.l[1] == 6, "test_int vector ADD_LIST failed");
    CHECK(test_int.l[2] == 7, "test_int vector ADD_LIST failed");
    CHECK(test_int.l[3] == 8, "test_int vector ADD_LIST failed");
    CHECK(test_int.l[4] == 9, "test_int vector ADD_LIST failed");
    CHECK(test_int.l[5] == 10, "test_int vector ADD_LIST failed");
    CHECK(test_int.l[6] == 11, "test_int vector ADD_LIST failed");
    CHECK(test_int.cur_size == 7, "test_int vector ADD_LIST failed");
    CHECK(test_int.max_size == 10, "test_int vector ADD_LIST failed");

    FREE_LIST(test_int);
    
    Vector val;
    val.v[0] = val.v[1] = val.v[2] = val.v[3] = 10.0f;
    ADD_LIST(test_vec, val);
    
    CHECK(test_vec.l[0].v[0] == 10.0f, "test_vec vector ADD_LIST failed");
    CHECK(test_vec.l[0].v[1] == 10.0f, "test_vec vector ADD_LIST failed");
    CHECK(test_vec.l[0].v[2] == 10.0f, "test_vec vector ADD_LIST failed");
    CHECK(test_vec.l[0].v[3] == 10.0f, "test_vec vector ADD_LIST failed");
    
    Vector inc;
    VEC_ASSIGN(inc, 1.0f, 1.0f, 1.0f, 1.0f);
    
    VEC_ADD(val, val, inc);
    ADD_LIST(test_vec, val);
    VEC_ADD(val, val, inc);
    ADD_LIST(test_vec, val);
    VEC_ADD(val, val, inc);
    ADD_LIST(test_vec, val);
    VEC_ADD(val, val, inc);
    ADD_LIST(test_vec, val);
    VEC_ADD(val, val, inc);
    ADD_LIST(test_vec, val);
    VEC_ADD(val, val, inc);
    ADD_LIST(test_vec, val);
    
    CHECK(test_vec.l[6].v[0] == 16.0f, "test_vec vector ADD_LIST failed");
    CHECK(test_vec.l[6].v[1] == 16.0f, "test_vec vector ADD_LIST failed");
    CHECK(test_vec.l[6].v[2] == 16.0f, "test_vec vector ADD_LIST failed");
    CHECK(test_vec.l[6].v[3] == 16.0f, "test_vec vector ADD_LIST failed");
    CHECK(test_int.cur_size == 7, "test_int vector ADD_LIST failed");
    CHECK(test_int.max_size == 10, "test_int vector ADD_LIST failed");
    
    return test_result;
}