Version: 1
-Previous: 9dd197ec91fbb62763307a0f4ca621306187b26b
-Head: b47a674bb0e73731a5684d6d32d1608c0aef4caf
+Previous: 0f42ac578d5ffa4c34c06c15ea9d7dc4b02b1bd0
+Head: 3a732c7b1faeb0bb06b7f6ae9cf1cfca2f100353
Applied:
sync: 452ce3b051e10e10363baa77834962a89267e052
pre-af-ib: 73504ef1f812bea6d1fd59f194f90e5194ca2efa
opt-cq: eb08384598a3829b40cc525aa2871e4e96817507
max-rdma: 0dd5de47b21e3a7274ec258f969cfb366f7b5e46
opt-cp: 0c67e54602a5ce5524698f8aba7f543f356a865a
- gai: 720aaa185b9ce215b2d0678f103ccdf50fa7ffbf
- refresh-temp: b47a674bb0e73731a5684d6d32d1608c0aef4caf
+ gai: 3a732c7b1faeb0bb06b7f6ae9cf1cfca2f100353
Unapplied:
getreq: 0b8f86a7e557e3b9abf4c2586ae9e7e885462623
ep: fea80cb274fe256711bd021fef0e7ca7c1ec3dd5
Bottom: 5a4bd54fa45c17ca116710f00c36a7a09b2b37db
-Top: fb20772a871decb83a5e3e8bdf727c07ca0f6777
+Top: 26c28fccf32c564d326dfb53a57a5951e469e12a
Author: Sean Hefty <sean.hefty@intel.com>
Date: 2010-08-16 10:05:05 -0700
..\..\..\inc\user\linux;\r
diff --git a/trunk/ulp/librdmacm/src/addrinfo.cpp b/trunk/ulp/librdmacm/src/addrinfo.cpp
new file mode 100644
-index 0000000..2ef1f38
+index 0000000..f40503b
--- /dev/null
+++ b/trunk/ulp/librdmacm/src/addrinfo.cpp
@@ -0,0 +1,209 @@
-+/*
-+ * Copyright (c) 2010 Intel Corporation. All rights reserved.
-+ *
-+ * This software is available to you under a choice of one of two
-+ * licenses. You may choose to be licensed under the terms of the GNU
-+ * General Public License (GPL) Version 2, available from the file
-+ * COPYING in the main directory of this source tree, or the
-+ * OpenIB.org BSD license below:
-+ *
-+ * Redistribution and use in source and binary forms, with or
-+ * without modification, are permitted provided that the following
-+ * conditions are met:
-+ *
-+ * - Redistributions of source code must retain the above
-+ * copyright notice, this list of conditions and the following
-+ * disclaimer.
-+ *
-+ * - Redistributions in binary form must reproduce the above
-+ * copyright notice, this list of conditions and the following
-+ * disclaimer in the documentation and/or other materials
-+ * provided with the distribution.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-+ * SOFTWARE.
-+ */
-+
-+#if HAVE_CONFIG_H
-+# include <config.h>
-+#endif /* HAVE_CONFIG_H */
-+
++/*\r
++ * Copyright (c) 2010 Intel Corporation. All rights reserved.\r
++ *\r
++ * This software is available to you under a choice of one of two\r
++ * licenses. You may choose to be licensed under the terms of the GNU\r
++ * General Public License (GPL) Version 2, available from the file\r
++ * COPYING in the main directory of this source tree, or the\r
++ * OpenIB.org BSD license below:\r
++ *\r
++ * Redistribution and use in source and binary forms, with or\r
++ * without modification, are permitted provided that the following\r
++ * conditions are met:\r
++ *\r
++ * - Redistributions of source code must retain the above\r
++ * copyright notice, this list of conditions and the following\r
++ * disclaimer.\r
++ *\r
++ * - Redistributions in binary form must reproduce the above\r
++ * copyright notice, this list of conditions and the following\r
++ * disclaimer in the documentation and/or other materials\r
++ * provided with the distribution.\r
++ *\r
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
++ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
++ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
++ * SOFTWARE.\r
++ */\r
++\r
++#if HAVE_CONFIG_H\r
++# include <config.h>\r
++#endif /* HAVE_CONFIG_H */\r
++\r
+#include <windows.h>\r
+#include <winsock2.h>\r
-+
-+#include "cma.h"
-+#include <rdma/rdma_cma.h>
-+#include <rdma/rdma_verbs.h>
-+
-+static void ucma_convert_to_ai(struct addrinfo *ai, struct rdma_addrinfo *rai)
-+{
-+ memset(ai, 0, sizeof *ai);
-+ ai->ai_flags = rai->ai_flags;
-+ ai->ai_family = rai->ai_family;
-+
-+ switch (rai->ai_qp_type) {
-+ case IBV_QPT_RC:
-+ ai->ai_socktype = SOCK_STREAM;
-+ break;
-+ case IBV_QPT_UD:
-+ ai->ai_socktype = SOCK_DGRAM;
-+ break;
-+ }
-+
-+ switch (rai->ai_port_space) {
-+ case RDMA_PS_TCP:
-+ ai->ai_protocol = IPPROTO_TCP;
-+ break;
-+ case RDMA_PS_IPOIB:
-+ case RDMA_PS_UDP:
-+ ai->ai_protocol = IPPROTO_UDP;
-+ break;
-+ }
-+
-+ if (rai->ai_flags & RAI_PASSIVE) {
-+ ai->ai_addrlen = rai->ai_src_len;
-+ ai->ai_addr = rai->ai_src_addr;
-+ } else {
-+ ai->ai_addrlen = rai->ai_dst_len;
-+ ai->ai_addr = rai->ai_dst_addr;
-+ }
-+ ai->ai_canonname = rai->ai_dst_canonname;
-+ ai->ai_next = NULL;
-+}
-+
-+static int ucma_convert_to_rai(struct rdma_addrinfo *rai, struct addrinfo *ai)
-+{
-+ struct sockaddr *addr;
-+ char *canonname;
-+
-+ memset(rai, 0, sizeof *rai);
-+ rai->ai_flags = ai->ai_flags;
-+ rai->ai_family = ai->ai_family;
-+
-+ switch (ai->ai_socktype) {
-+ case SOCK_STREAM:
-+ rai->ai_qp_type = IBV_QPT_RC;
-+ break;
-+ case SOCK_DGRAM:
-+ rai->ai_qp_type = IBV_QPT_UD;
-+ break;
-+ }
-+
-+ switch (ai->ai_protocol) {
-+ case IPPROTO_TCP:
-+ rai->ai_port_space = RDMA_PS_TCP;
-+ break;
-+ case IPPROTO_UDP:
-+ rai->ai_port_space = RDMA_PS_UDP;
-+ break;
-+ }
-+
-+ addr = (struct sockaddr *) malloc(ai->ai_addrlen);
-+ if (!addr)
-+ return rdma_seterrno(ENOMEM);
-+
-+ canonname = (char *) (ai->ai_canonname ? malloc(strlen(ai->ai_canonname) + 1) : NULL);
-+ if (canonname)
-+ strcpy(canonname, ai->ai_canonname);
-+
-+ memcpy(addr, ai->ai_addr, ai->ai_addrlen);
-+ if (ai->ai_flags & RAI_PASSIVE) {
-+ rai->ai_src_addr = addr;
-+ rai->ai_src_len = ai->ai_addrlen;
-+ rai->ai_src_canonname = canonname;
-+ } else {
-+ rai->ai_dst_addr = addr;
-+ rai->ai_dst_len = ai->ai_addrlen;
-+ rai->ai_dst_canonname = canonname;
-+ }
-+
-+ return 0;
-+}
-+
-+int rdma_getaddrinfo(char *node, char *service,
-+ struct rdma_addrinfo *hints,
-+ struct rdma_addrinfo **res)
-+{
-+ struct rdma_addrinfo *rai;
-+ struct addrinfo ai_hints;
-+ struct addrinfo *ai;
-+ int ret;
-+
-+ if (hints)
-+ ucma_convert_to_ai(&ai_hints, hints);
-+
-+ ret = getaddrinfo(node, service, &ai_hints, &ai);
-+ if (ret)
-+ return ret;
-+
-+ rai = (struct rdma_addrinfo *) malloc(sizeof(*rai));
-+ if (!rai) {
-+ ret = rdma_seterrno(ENOMEM);
-+ goto err1;
-+ }
-+
-+ ret = ucma_convert_to_rai(rai, ai);
-+ if (ret)
-+ goto err2;
-+
-+ if (!rai->ai_src_len && hints && hints->ai_src_len) {
-+ rai->ai_src_addr = (struct sockaddr *) calloc(1, hints->ai_src_len);
-+ if (!rai->ai_src_addr) {
-+ ret = rdma_seterrno(ENOMEM);
-+ goto err2;
-+ }
-+ memcpy(rai->ai_src_addr, hints->ai_src_addr,
-+ hints->ai_src_len);
-+ rai->ai_src_len = hints->ai_src_len;
-+ }
-+
-+ // requires ib acm support --
-+ //if (!(rai->ai_flags & RAI_PASSIVE))
-+ // ucma_ib_resolve(rai);
-+
-+ freeaddrinfo(ai);
-+ *res = rai;
-+ return 0;
-+
-+err2:
-+ rdma_freeaddrinfo(rai);
-+err1:
-+ freeaddrinfo(ai);
-+ return ret;
-+}
-+
-+void rdma_freeaddrinfo(struct rdma_addrinfo *res)
-+{
-+ struct rdma_addrinfo *rai;
-+
-+ while (res) {
-+ rai = res;
-+ res = res->ai_next;
-+
-+ if (rai->ai_connect)
-+ free(rai->ai_connect);
-+
-+ if (rai->ai_route)
-+ free(rai->ai_route);
-+
-+ if (rai->ai_src_canonname)
-+ free(rai->ai_src_canonname);
-+
-+ if (rai->ai_dst_canonname)
-+ free(rai->ai_dst_canonname);
-+
-+ if (rai->ai_src_addr)
-+ free(rai->ai_src_addr);
-+
-+ if (rai->ai_dst_addr)
-+ free(rai->ai_dst_addr);
-+
-+ free(rai);
-+ }
-+}
++\r
++#include "cma.h"\r
++#include <rdma/rdma_cma.h>\r
++#include <rdma/rdma_verbs.h>\r
++\r
++static void ucma_convert_to_ai(struct addrinfo *ai, struct rdma_addrinfo *rai)\r
++{\r
++ memset(ai, 0, sizeof *ai);\r
++ ai->ai_flags = rai->ai_flags;\r
++ ai->ai_family = rai->ai_family;\r
++\r
++ switch (rai->ai_qp_type) {\r
++ case IBV_QPT_RC:\r
++ ai->ai_socktype = SOCK_STREAM;\r
++ break;\r
++ case IBV_QPT_UD:\r
++ ai->ai_socktype = SOCK_DGRAM;\r
++ break;\r
++ }\r
++\r
++ switch (rai->ai_port_space) {\r
++ case RDMA_PS_TCP:\r
++ ai->ai_protocol = IPPROTO_TCP;\r
++ break;\r
++ case RDMA_PS_IPOIB:\r
++ case RDMA_PS_UDP:\r
++ ai->ai_protocol = IPPROTO_UDP;\r
++ break;\r
++ }\r
++\r
++ if (rai->ai_flags & RAI_PASSIVE) {\r
++ ai->ai_addrlen = rai->ai_src_len;\r
++ ai->ai_addr = rai->ai_src_addr;\r
++ } else {\r
++ ai->ai_addrlen = rai->ai_dst_len;\r
++ ai->ai_addr = rai->ai_dst_addr;\r
++ }\r
++ ai->ai_canonname = rai->ai_dst_canonname;\r
++ ai->ai_next = NULL;\r
++}\r
++\r
++static int ucma_convert_to_rai(struct rdma_addrinfo *rai, struct addrinfo *ai)\r
++{\r
++ struct sockaddr *addr;\r
++ char *canonname;\r
++\r
++ memset(rai, 0, sizeof *rai);\r
++ rai->ai_flags = ai->ai_flags;\r
++ rai->ai_family = ai->ai_family;\r
++\r
++ switch (ai->ai_socktype) {\r
++ case SOCK_STREAM:\r
++ rai->ai_qp_type = IBV_QPT_RC;\r
++ break;\r
++ case SOCK_DGRAM:\r
++ rai->ai_qp_type = IBV_QPT_UD;\r
++ break;\r
++ }\r
++\r
++ switch (ai->ai_protocol) {\r
++ case IPPROTO_TCP:\r
++ rai->ai_port_space = RDMA_PS_TCP;\r
++ break;\r
++ case IPPROTO_UDP:\r
++ rai->ai_port_space = RDMA_PS_UDP;\r
++ break;\r
++ }\r
++\r
++ addr = (struct sockaddr *) malloc(ai->ai_addrlen);\r
++ if (!addr)\r
++ return rdma_seterrno(ENOMEM);\r
++\r
++ canonname = (char *) (ai->ai_canonname ? malloc(strlen(ai->ai_canonname) + 1) : NULL);\r
++ if (canonname)\r
++ strcpy(canonname, ai->ai_canonname);\r
++\r
++ memcpy(addr, ai->ai_addr, ai->ai_addrlen);\r
++ if (ai->ai_flags & RAI_PASSIVE) {\r
++ rai->ai_src_addr = addr;\r
++ rai->ai_src_len = ai->ai_addrlen;\r
++ rai->ai_src_canonname = canonname;\r
++ } else {\r
++ rai->ai_dst_addr = addr;\r
++ rai->ai_dst_len = ai->ai_addrlen;\r
++ rai->ai_dst_canonname = canonname;\r
++ }\r
++\r
++ return 0;\r
++}\r
++\r
++int rdma_getaddrinfo(char *node, char *service,\r
++ struct rdma_addrinfo *hints,\r
++ struct rdma_addrinfo **res)\r
++{\r
++ struct rdma_addrinfo *rai;\r
++ struct addrinfo ai_hints;\r
++ struct addrinfo *ai;\r
++ int ret;\r
++\r
++ if (hints)\r
++ ucma_convert_to_ai(&ai_hints, hints);\r
++\r
++ ret = getaddrinfo(node, service, &ai_hints, &ai);\r
++ if (ret)\r
++ return ret;\r
++\r
++ rai = (struct rdma_addrinfo *) malloc(sizeof(*rai));\r
++ if (!rai) {\r
++ ret = rdma_seterrno(ENOMEM);\r
++ goto err1;\r
++ }\r
++\r
++ ret = ucma_convert_to_rai(rai, ai);\r
++ if (ret)\r
++ goto err2;\r
++\r
++ if (!rai->ai_src_len && hints && hints->ai_src_len) {\r
++ rai->ai_src_addr = (struct sockaddr *) calloc(1, hints->ai_src_len);\r
++ if (!rai->ai_src_addr) {\r
++ ret = rdma_seterrno(ENOMEM);\r
++ goto err2;\r
++ }\r
++ memcpy(rai->ai_src_addr, hints->ai_src_addr,\r
++ hints->ai_src_len);\r
++ rai->ai_src_len = hints->ai_src_len;\r
++ }\r
++\r
++ // requires ib acm support --\r
++ //if (!(rai->ai_flags & RAI_PASSIVE))\r
++ // ucma_ib_resolve(rai);\r
++\r
++ freeaddrinfo(ai);\r
++ *res = rai;\r
++ return 0;\r
++\r
++err2:\r
++ rdma_freeaddrinfo(rai);\r
++err1:\r
++ freeaddrinfo(ai);\r
++ return ret;\r
++}\r
++\r
++void rdma_freeaddrinfo(struct rdma_addrinfo *res)\r
++{\r
++ struct rdma_addrinfo *rai;\r
++\r
++ while (res) {\r
++ rai = res;\r
++ res = res->ai_next;\r
++\r
++ if (rai->ai_connect)\r
++ free(rai->ai_connect);\r
++\r
++ if (rai->ai_route)\r
++ free(rai->ai_route);\r
++\r
++ if (rai->ai_src_canonname)\r
++ free(rai->ai_src_canonname);\r
++\r
++ if (rai->ai_dst_canonname)\r
++ free(rai->ai_dst_canonname);\r
++\r
++ if (rai->ai_src_addr)\r
++ free(rai->ai_src_addr);\r
++\r
++ if (rai->ai_dst_addr)\r
++ free(rai->ai_dst_addr);\r
++\r
++ free(rai);\r
++ }\r
++}\r
diff --git a/trunk/ulp/librdmacm/src/cma_exports.src b/trunk/ulp/librdmacm/src/cma_exports.src
index a8fe8f3..8f370be 100644
--- a/trunk/ulp/librdmacm/src/cma_exports.src
+++ /dev/null
-Bottom: fb20772a871decb83a5e3e8bdf727c07ca0f6777
-Top: 26c28fccf32c564d326dfb53a57a5951e469e12a
-Author: Sean Hefty <sean.hefty@intel.com>
-Date: 2010-08-16 12:03:11 -0700
-
-Refresh of gai
-
----
-
-diff --git a/trunk/ulp/librdmacm/src/addrinfo.cpp b/trunk/ulp/librdmacm/src/addrinfo.cpp
-index 2ef1f38..f40503b 100644
---- a/trunk/ulp/librdmacm/src/addrinfo.cpp
-+++ b/trunk/ulp/librdmacm/src/addrinfo.cpp
-@@ -1,209 +1,209 @@
--/*
-- * Copyright (c) 2010 Intel Corporation. All rights reserved.
-- *
-- * This software is available to you under a choice of one of two
-- * licenses. You may choose to be licensed under the terms of the GNU
-- * General Public License (GPL) Version 2, available from the file
-- * COPYING in the main directory of this source tree, or the
-- * OpenIB.org BSD license below:
-- *
-- * Redistribution and use in source and binary forms, with or
-- * without modification, are permitted provided that the following
-- * conditions are met:
-- *
-- * - Redistributions of source code must retain the above
-- * copyright notice, this list of conditions and the following
-- * disclaimer.
-- *
-- * - Redistributions in binary form must reproduce the above
-- * copyright notice, this list of conditions and the following
-- * disclaimer in the documentation and/or other materials
-- * provided with the distribution.
-- *
-- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- * SOFTWARE.
-- */
--
--#if HAVE_CONFIG_H
--# include <config.h>
--#endif /* HAVE_CONFIG_H */
--
-+/*\r
-+ * Copyright (c) 2010 Intel Corporation. All rights reserved.\r
-+ *\r
-+ * This software is available to you under a choice of one of two\r
-+ * licenses. You may choose to be licensed under the terms of the GNU\r
-+ * General Public License (GPL) Version 2, available from the file\r
-+ * COPYING in the main directory of this source tree, or the\r
-+ * OpenIB.org BSD license below:\r
-+ *\r
-+ * Redistribution and use in source and binary forms, with or\r
-+ * without modification, are permitted provided that the following\r
-+ * conditions are met:\r
-+ *\r
-+ * - Redistributions of source code must retain the above\r
-+ * copyright notice, this list of conditions and the following\r
-+ * disclaimer.\r
-+ *\r
-+ * - Redistributions in binary form must reproduce the above\r
-+ * copyright notice, this list of conditions and the following\r
-+ * disclaimer in the documentation and/or other materials\r
-+ * provided with the distribution.\r
-+ *\r
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
-+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
-+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
-+ * SOFTWARE.\r
-+ */\r
-+\r
-+#if HAVE_CONFIG_H\r
-+# include <config.h>\r
-+#endif /* HAVE_CONFIG_H */\r
-+\r
- #include <windows.h>\r
- #include <winsock2.h>\r
--
--#include "cma.h"
--#include <rdma/rdma_cma.h>
--#include <rdma/rdma_verbs.h>
--
--static void ucma_convert_to_ai(struct addrinfo *ai, struct rdma_addrinfo *rai)
--{
-- memset(ai, 0, sizeof *ai);
-- ai->ai_flags = rai->ai_flags;
-- ai->ai_family = rai->ai_family;
--
-- switch (rai->ai_qp_type) {
-- case IBV_QPT_RC:
-- ai->ai_socktype = SOCK_STREAM;
-- break;
-- case IBV_QPT_UD:
-- ai->ai_socktype = SOCK_DGRAM;
-- break;
-- }
--
-- switch (rai->ai_port_space) {
-- case RDMA_PS_TCP:
-- ai->ai_protocol = IPPROTO_TCP;
-- break;
-- case RDMA_PS_IPOIB:
-- case RDMA_PS_UDP:
-- ai->ai_protocol = IPPROTO_UDP;
-- break;
-- }
--
-- if (rai->ai_flags & RAI_PASSIVE) {
-- ai->ai_addrlen = rai->ai_src_len;
-- ai->ai_addr = rai->ai_src_addr;
-- } else {
-- ai->ai_addrlen = rai->ai_dst_len;
-- ai->ai_addr = rai->ai_dst_addr;
-- }
-- ai->ai_canonname = rai->ai_dst_canonname;
-- ai->ai_next = NULL;
--}
--
--static int ucma_convert_to_rai(struct rdma_addrinfo *rai, struct addrinfo *ai)
--{
-- struct sockaddr *addr;
-- char *canonname;
--
-- memset(rai, 0, sizeof *rai);
-- rai->ai_flags = ai->ai_flags;
-- rai->ai_family = ai->ai_family;
--
-- switch (ai->ai_socktype) {
-- case SOCK_STREAM:
-- rai->ai_qp_type = IBV_QPT_RC;
-- break;
-- case SOCK_DGRAM:
-- rai->ai_qp_type = IBV_QPT_UD;
-- break;
-- }
--
-- switch (ai->ai_protocol) {
-- case IPPROTO_TCP:
-- rai->ai_port_space = RDMA_PS_TCP;
-- break;
-- case IPPROTO_UDP:
-- rai->ai_port_space = RDMA_PS_UDP;
-- break;
-- }
--
-- addr = (struct sockaddr *) malloc(ai->ai_addrlen);
-- if (!addr)
-- return rdma_seterrno(ENOMEM);
--
-- canonname = (char *) (ai->ai_canonname ? malloc(strlen(ai->ai_canonname) + 1) : NULL);
-- if (canonname)
-- strcpy(canonname, ai->ai_canonname);
--
-- memcpy(addr, ai->ai_addr, ai->ai_addrlen);
-- if (ai->ai_flags & RAI_PASSIVE) {
-- rai->ai_src_addr = addr;
-- rai->ai_src_len = ai->ai_addrlen;
-- rai->ai_src_canonname = canonname;
-- } else {
-- rai->ai_dst_addr = addr;
-- rai->ai_dst_len = ai->ai_addrlen;
-- rai->ai_dst_canonname = canonname;
-- }
--
-- return 0;
--}
--
--int rdma_getaddrinfo(char *node, char *service,
-- struct rdma_addrinfo *hints,
-- struct rdma_addrinfo **res)
--{
-- struct rdma_addrinfo *rai;
-- struct addrinfo ai_hints;
-- struct addrinfo *ai;
-- int ret;
--
-- if (hints)
-- ucma_convert_to_ai(&ai_hints, hints);
--
-- ret = getaddrinfo(node, service, &ai_hints, &ai);
-- if (ret)
-- return ret;
--
-- rai = (struct rdma_addrinfo *) malloc(sizeof(*rai));
-- if (!rai) {
-- ret = rdma_seterrno(ENOMEM);
-- goto err1;
-- }
--
-- ret = ucma_convert_to_rai(rai, ai);
-- if (ret)
-- goto err2;
--
-- if (!rai->ai_src_len && hints && hints->ai_src_len) {
-- rai->ai_src_addr = (struct sockaddr *) calloc(1, hints->ai_src_len);
-- if (!rai->ai_src_addr) {
-- ret = rdma_seterrno(ENOMEM);
-- goto err2;
-- }
-- memcpy(rai->ai_src_addr, hints->ai_src_addr,
-- hints->ai_src_len);
-- rai->ai_src_len = hints->ai_src_len;
-- }
--
-- // requires ib acm support --
-- //if (!(rai->ai_flags & RAI_PASSIVE))
-- // ucma_ib_resolve(rai);
--
-- freeaddrinfo(ai);
-- *res = rai;
-- return 0;
--
--err2:
-- rdma_freeaddrinfo(rai);
--err1:
-- freeaddrinfo(ai);
-- return ret;
--}
--
--void rdma_freeaddrinfo(struct rdma_addrinfo *res)
--{
-- struct rdma_addrinfo *rai;
--
-- while (res) {
-- rai = res;
-- res = res->ai_next;
--
-- if (rai->ai_connect)
-- free(rai->ai_connect);
--
-- if (rai->ai_route)
-- free(rai->ai_route);
--
-- if (rai->ai_src_canonname)
-- free(rai->ai_src_canonname);
--
-- if (rai->ai_dst_canonname)
-- free(rai->ai_dst_canonname);
--
-- if (rai->ai_src_addr)
-- free(rai->ai_src_addr);
--
-- if (rai->ai_dst_addr)
-- free(rai->ai_dst_addr);
--
-- free(rai);
-- }
--}
-+\r
-+#include "cma.h"\r
-+#include <rdma/rdma_cma.h>\r
-+#include <rdma/rdma_verbs.h>\r
-+\r
-+static void ucma_convert_to_ai(struct addrinfo *ai, struct rdma_addrinfo *rai)\r
-+{\r
-+ memset(ai, 0, sizeof *ai);\r
-+ ai->ai_flags = rai->ai_flags;\r
-+ ai->ai_family = rai->ai_family;\r
-+\r
-+ switch (rai->ai_qp_type) {\r
-+ case IBV_QPT_RC:\r
-+ ai->ai_socktype = SOCK_STREAM;\r
-+ break;\r
-+ case IBV_QPT_UD:\r
-+ ai->ai_socktype = SOCK_DGRAM;\r
-+ break;\r
-+ }\r
-+\r
-+ switch (rai->ai_port_space) {\r
-+ case RDMA_PS_TCP:\r
-+ ai->ai_protocol = IPPROTO_TCP;\r
-+ break;\r
-+ case RDMA_PS_IPOIB:\r
-+ case RDMA_PS_UDP:\r
-+ ai->ai_protocol = IPPROTO_UDP;\r
-+ break;\r
-+ }\r
-+\r
-+ if (rai->ai_flags & RAI_PASSIVE) {\r
-+ ai->ai_addrlen = rai->ai_src_len;\r
-+ ai->ai_addr = rai->ai_src_addr;\r
-+ } else {\r
-+ ai->ai_addrlen = rai->ai_dst_len;\r
-+ ai->ai_addr = rai->ai_dst_addr;\r
-+ }\r
-+ ai->ai_canonname = rai->ai_dst_canonname;\r
-+ ai->ai_next = NULL;\r
-+}\r
-+\r
-+static int ucma_convert_to_rai(struct rdma_addrinfo *rai, struct addrinfo *ai)\r
-+{\r
-+ struct sockaddr *addr;\r
-+ char *canonname;\r
-+\r
-+ memset(rai, 0, sizeof *rai);\r
-+ rai->ai_flags = ai->ai_flags;\r
-+ rai->ai_family = ai->ai_family;\r
-+\r
-+ switch (ai->ai_socktype) {\r
-+ case SOCK_STREAM:\r
-+ rai->ai_qp_type = IBV_QPT_RC;\r
-+ break;\r
-+ case SOCK_DGRAM:\r
-+ rai->ai_qp_type = IBV_QPT_UD;\r
-+ break;\r
-+ }\r
-+\r
-+ switch (ai->ai_protocol) {\r
-+ case IPPROTO_TCP:\r
-+ rai->ai_port_space = RDMA_PS_TCP;\r
-+ break;\r
-+ case IPPROTO_UDP:\r
-+ rai->ai_port_space = RDMA_PS_UDP;\r
-+ break;\r
-+ }\r
-+\r
-+ addr = (struct sockaddr *) malloc(ai->ai_addrlen);\r
-+ if (!addr)\r
-+ return rdma_seterrno(ENOMEM);\r
-+\r
-+ canonname = (char *) (ai->ai_canonname ? malloc(strlen(ai->ai_canonname) + 1) : NULL);\r
-+ if (canonname)\r
-+ strcpy(canonname, ai->ai_canonname);\r
-+\r
-+ memcpy(addr, ai->ai_addr, ai->ai_addrlen);\r
-+ if (ai->ai_flags & RAI_PASSIVE) {\r
-+ rai->ai_src_addr = addr;\r
-+ rai->ai_src_len = ai->ai_addrlen;\r
-+ rai->ai_src_canonname = canonname;\r
-+ } else {\r
-+ rai->ai_dst_addr = addr;\r
-+ rai->ai_dst_len = ai->ai_addrlen;\r
-+ rai->ai_dst_canonname = canonname;\r
-+ }\r
-+\r
-+ return 0;\r
-+}\r
-+\r
-+int rdma_getaddrinfo(char *node, char *service,\r
-+ struct rdma_addrinfo *hints,\r
-+ struct rdma_addrinfo **res)\r
-+{\r
-+ struct rdma_addrinfo *rai;\r
-+ struct addrinfo ai_hints;\r
-+ struct addrinfo *ai;\r
-+ int ret;\r
-+\r
-+ if (hints)\r
-+ ucma_convert_to_ai(&ai_hints, hints);\r
-+\r
-+ ret = getaddrinfo(node, service, &ai_hints, &ai);\r
-+ if (ret)\r
-+ return ret;\r
-+\r
-+ rai = (struct rdma_addrinfo *) malloc(sizeof(*rai));\r
-+ if (!rai) {\r
-+ ret = rdma_seterrno(ENOMEM);\r
-+ goto err1;\r
-+ }\r
-+\r
-+ ret = ucma_convert_to_rai(rai, ai);\r
-+ if (ret)\r
-+ goto err2;\r
-+\r
-+ if (!rai->ai_src_len && hints && hints->ai_src_len) {\r
-+ rai->ai_src_addr = (struct sockaddr *) calloc(1, hints->ai_src_len);\r
-+ if (!rai->ai_src_addr) {\r
-+ ret = rdma_seterrno(ENOMEM);\r
-+ goto err2;\r
-+ }\r
-+ memcpy(rai->ai_src_addr, hints->ai_src_addr,\r
-+ hints->ai_src_len);\r
-+ rai->ai_src_len = hints->ai_src_len;\r
-+ }\r
-+\r
-+ // requires ib acm support --\r
-+ //if (!(rai->ai_flags & RAI_PASSIVE))\r
-+ // ucma_ib_resolve(rai);\r
-+\r
-+ freeaddrinfo(ai);\r
-+ *res = rai;\r
-+ return 0;\r
-+\r
-+err2:\r
-+ rdma_freeaddrinfo(rai);\r
-+err1:\r
-+ freeaddrinfo(ai);\r
-+ return ret;\r
-+}\r
-+\r
-+void rdma_freeaddrinfo(struct rdma_addrinfo *res)\r
-+{\r
-+ struct rdma_addrinfo *rai;\r
-+\r
-+ while (res) {\r
-+ rai = res;\r
-+ res = res->ai_next;\r
-+\r
-+ if (rai->ai_connect)\r
-+ free(rai->ai_connect);\r
-+\r
-+ if (rai->ai_route)\r
-+ free(rai->ai_route);\r
-+\r
-+ if (rai->ai_src_canonname)\r
-+ free(rai->ai_src_canonname);\r
-+\r
-+ if (rai->ai_dst_canonname)\r
-+ free(rai->ai_dst_canonname);\r
-+\r
-+ if (rai->ai_src_addr)\r
-+ free(rai->ai_src_addr);\r
-+\r
-+ if (rai->ai_dst_addr)\r
-+ free(rai->ai_dst_addr);\r
-+\r
-+ free(rai);\r
-+ }\r
-+}