Commit 53b6ce98 authored by Philip Davis's avatar Philip Davis
Browse files

Adjusted provider selection

parent c2c88282
Loading
Loading
Loading
Loading
+56 −57
Original line number Diff line number Diff line
@@ -89,10 +89,11 @@ struct fabric_state

static void init_fabric(struct fabric_state *fabric)
{
    struct fi_info *hints, *info;
    struct fi_info *hints, *info, *originfo, *useinfo;
    struct fi_av_attr av_attr = {0};
    struct fi_cq_attr cq_attr = {0};
    char *ifname;
    char *domain_name, *prov_name;

    hints = fi_allocinfo();
    hints->caps = FI_MSG | FI_SEND | FI_RECV | FI_REMOTE_READ |
@@ -106,11 +107,34 @@ static void init_fabric(struct fabric_state *fabric)
    fi_getinfo(FI_VERSION(1, 5), NULL, NULL, 0, hints, &info);
    fi_freeinfo(hints);

    fabric->info = NULL;

    originfo = info;
    useinfo = NULL;
    while(info) {
    	prov_name = info->fabric_attr->prov_name;
    	domain_name = info->domain_attr->name;
    	if (ifname && strcmp(ifname, domain_name) == 0) {
    		useinfo = info;
    		break;
    	}
    	if(strcmp(prov_name, "verbs") == 0
    			|| strcmp(prov_name, "gni") == 0
				|| strcmp(prov_name, "psm2") == 0) {
    		useinfo = info;
    	}
    	info = info->next;
    }

    info = useinfo;

    if (!info)
    {
        fabric->info = NULL;
    	return;
    }

    fabric->info = fi_dupinfo(info);

    if (info->mode & FI_CONTEXT2)
    {
        fabric->ctx = calloc(2, sizeof(*fabric->ctx));
@@ -142,16 +166,6 @@ static void init_fabric(struct fabric_state *fabric)
        fabric->msg_prefix_size = 0;
    }

    while (info->next)
    {
        if (ifname && strcmp(ifname, info->domain_attr->name) == 0)
        {
            break;
        }
        info = info->next;
    }

    fabric->info = fi_dupinfo(info);
    fabric->addr_len = info->src_addrlen;

    info->domain_attr->mr_mode = FI_MR_BASIC;
@@ -175,7 +189,7 @@ static void init_fabric(struct fabric_state *fabric)

    fi_enable(fabric->signal);

    fi_freeinfo(info);
    fi_freeinfo(originfo);
}

static void fini_fabric(struct fabric_state *fabric)
@@ -1037,13 +1051,17 @@ static struct _CP_DP_Interface RdmaDPInterface;
 * greater than 1 if it can.  Eventually if we have more than one
 * possible RDMA DP, we may need some better scheme, maybe where the
 * "priority" return value represents some desirability measure
 * (like expected bandwidth or something).
 * (like expected bandwidth or something)
 *
 * Returns 10 if a valid RDMA fabric is found, 100 if that fabric matches
 * what is set in the FABRIC_IFACE environment variable.
 *
 */
static int RdmaGetPriority(CP_Services Svcs, void *CP_Stream)
{
	struct fi_info *hints, *info, *originfo, *nextinfo;
	struct fi_info *hints, *info, *originfo, *useinfo;
	char *prov_name, *domain_name;
	char *ifname;
	int foundreq = 0;
	int Ret = -1;

	    hints = fi_allocinfo();
@@ -1058,44 +1076,27 @@ static int RdmaGetPriority(CP_Services Svcs, void *CP_Stream)
	    fi_getinfo(FI_VERSION(1, 5), NULL, NULL, 0, hints, &info);
	    fi_freeinfo(hints);

	        if (!info)
	        {
	            Svcs->verbose(CP_Stream, "No viable fabric found for RDMA Dataplane.\n");
	            Ret = -1;
	        } else {
	        	char *prov_name, *domain_name;

	    if(!info) {
	    	Svcs->verbose(CP_Stream, "RDMA Dataplane could not find any viable fabrics.\n");
	    }

	        	originfo = info;
	        	while (info->next)
	        	{
	        			domain_name = info->domain_attr->name;
	        	        if (ifname && strcmp(ifname, domain_name) == 0)
	        	        {
	    while(info) {
	    	prov_name = info->fabric_attr->prov_name;
	        	        	Svcs->verbose(CP_Stream, "RDMA Dataplane found the requested interface, provider type %s.\n", ifname);
	        	        	foundreq = 1;
	    	domain_name = info->domain_attr->name;
	    	if (ifname && strcmp(ifname, domain_name) == 0) {
	    		Svcs->verbose(CP_Stream, "RDMA Dataplane found the requested interface %s, provider type %s.\n", ifname, prov_name);
	    		Ret = 100;
	    		break;
	    	}
	        	       info = info->next;
	        	}

	        	if(Ret == -1) {
	        		info = originfo;
	        		while(info->next) {
	        			prov_name = info->fabric_attr->prov_name;
	    	if(strcmp(prov_name, "verbs") == 0
	    			|| strcmp(prov_name, "gni") == 0
					|| strcmp(prov_name, "psm2") == 0) {
	        				domain_name = info->domain_attr->name;
	        				Svcs->verbose(CP_Stream, "RDMA Dataplane sees interface %s, provider type %s, which should work.", domain_name, prov_name);

	    		Svcs->verbose(CP_Stream, "RDMA Dataplane sees interface %s, provider type %s, which should work.\n", domain_name, prov_name);
	    		Ret = 10;
	        				break;
	    	}
	    	info = info->next;
	    }
	        	}

	        	if(Ret == -1) {
	        		Svcs->verbose(CP_Stream, "RDMA Dataplane could not find an RDMA-compatible fabric.\n");
@@ -1103,8 +1104,6 @@ static int RdmaGetPriority(CP_Services Svcs, void *CP_Stream)

	        	fi_freeinfo(originfo);

	        }

    Svcs->verbose(
        CP_Stream,
        "RDMA Dataplane evaluating viability, returning priority %d\n", Ret);