[ofa-general] [PATCH] dapl/windows cma provider: add support for network devices based on index

Sean Hefty sean.hefty at intel.com
Tue Jun 2 17:10:11 PDT 2009


The linux cma provider provides support for named network devices, such
as 'ib0' or 'eth0'.  This allows the same dapl configuration file to 
be used easily across a cluster.

To allow similar support on Windows, allow users to specify the device
name 'rdma_devN' in the dapl.conf file.  The given index, N, is map to a
corresponding IP address that is associated with an RDMA device.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
diff -up -r -X \mshefty\scm\winof\trunk\docs\dontdiff.txt -I '\$Id:' trunk\ulp\dapl2/dapl/openib_cma/dapl_ib_util.c
branches\winverbs\ulp\dapl2/dapl/openib_cma/dapl_ib_util.c
--- trunk\ulp\dapl2/dapl/openib_cma/dapl_ib_util.c	2009-05-01 10:18:28.000000000 -0700
+++ branches\winverbs\ulp\dapl2/dapl/openib_cma/dapl_ib_util.c	2009-06-02 15:26:19.534649800 -0700
@@ -57,10 +57,50 @@ struct dapl_llist_entry *g_hca_list;
 #if defined(_WIN64) || defined(_WIN32)
 #include "..\..\..\..\..\etc\user\comp_channel.cpp"
 #include "..\..\..\..\..\etc\user\dlist.c"
+#include <rdma\winverbs.h>
 
-#define getipaddr_netdev(x,y,z) -1
 struct ibvw_windata windata;
 
+static int getipaddr_netdev(char *name, char *addr, int addr_len)
+{
+	IWVProvider *prov;
+	WV_DEVICE_ADDRESS devaddr;
+	struct addrinfo *res, *ai;
+	HRESULT hr;
+	int index;
+
+	if (strncmp(name, "rdma_dev", 8)) {
+		return EINVAL;
+	}
+
+	index = atoi(name + 8);
+
+	hr = WvGetObject(&IID_IWVProvider, (LPVOID *) &prov);
+	if (FAILED(hr)) {
+		return hr;
+	}
+
+	hr = getaddrinfo("..localmachine", NULL, NULL, &res);
+	if (hr) {
+		goto release;
+	}
+
+	for (ai = res; ai; ai = ai->ai_next) {
+		hr = prov->lpVtbl->TranslateAddress(prov, ai->ai_addr, &devaddr);
+		if (SUCCEEDED(hr) && (ai->ai_addrlen <= addr_len) && (index-- == 0)) {
+			memcpy(addr, ai->ai_addr, ai->ai_addrlen);
+			goto free;
+		}
+	}
+	hr = ENODEV;
+
+free:
+	freeaddrinfo(res);
+release:
+	prov->lpVtbl->Release(prov);
+	return hr;
+}
+
 static int dapls_os_init(void)
 {
 	return ibvw_get_windata(&windata, IBVW_WINDATA_VERSION);
diff -up -r -X \mshefty\scm\winof\trunk\docs\dontdiff.txt -I '\$Id:' trunk\ulp\dapl2/dapl/openib_cma/SOURCES
branches\winverbs\ulp\dapl2/dapl/openib_cma/SOURCES
--- trunk\ulp\dapl2/dapl/openib_cma/SOURCES	2009-05-27 07:25:19.000000000 -0700
+++ branches\winverbs\ulp\dapl2/dapl/openib_cma/SOURCES	2009-06-02 10:38:04.799012200 -0700
@@ -45,10 +45,12 @@ TARGETLIBS= \
 	$(SDK_LIB_PATH)\ws2_32.lib \
 !if $(FREEBUILD)
 	$(TARGETPATH)\*\dat2.lib \
+	$(TARGETPATH)\*\winverbs.lib \
 	$(TARGETPATH)\*\libibverbs.lib \
 	$(TARGETPATH)\*\librdmacm.lib
 !else
 	$(TARGETPATH)\*\dat2d.lib \
+	$(TARGETPATH)\*\winverbsd.lib \
 	$(TARGETPATH)\*\libibverbsd.lib \
 	$(TARGETPATH)\*\librdmacmd.lib
 !endif





More information about the general mailing list