ib.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. /*
  2. * Copyright (c) 2006, 2019 Oracle and/or its affiliates. All rights reserved.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. *
  32. */
  33. #include <linux/kernel.h>
  34. #include <linux/in.h>
  35. #include <linux/if.h>
  36. #include <linux/netdevice.h>
  37. #include <linux/inetdevice.h>
  38. #include <linux/if_arp.h>
  39. #include <linux/delay.h>
  40. #include <linux/slab.h>
  41. #include <linux/module.h>
  42. #include <net/addrconf.h>
  43. #include "rds_single_path.h"
  44. #include "rds.h"
  45. #include "ib.h"
  46. #include "ib_mr.h"
  47. static unsigned int rds_ib_mr_1m_pool_size = RDS_MR_1M_POOL_SIZE;
  48. static unsigned int rds_ib_mr_8k_pool_size = RDS_MR_8K_POOL_SIZE;
  49. unsigned int rds_ib_retry_count = RDS_IB_DEFAULT_RETRY_COUNT;
  50. static atomic_t rds_ib_unloading;
  51. module_param(rds_ib_mr_1m_pool_size, int, 0444);
  52. MODULE_PARM_DESC(rds_ib_mr_1m_pool_size, " Max number of 1M mr per HCA");
  53. module_param(rds_ib_mr_8k_pool_size, int, 0444);
  54. MODULE_PARM_DESC(rds_ib_mr_8k_pool_size, " Max number of 8K mr per HCA");
  55. module_param(rds_ib_retry_count, int, 0444);
  56. MODULE_PARM_DESC(rds_ib_retry_count, " Number of hw retries before reporting an error");
  57. /*
  58. * we have a clumsy combination of RCU and a rwsem protecting this list
  59. * because it is used both in the get_mr fast path and while blocking in
  60. * the FMR flushing path.
  61. */
  62. DECLARE_RWSEM(rds_ib_devices_lock);
  63. struct list_head rds_ib_devices;
  64. /* NOTE: if also grabbing ibdev lock, grab this first */
  65. DEFINE_SPINLOCK(ib_nodev_conns_lock);
  66. LIST_HEAD(ib_nodev_conns);
  67. static void rds_ib_nodev_connect(void)
  68. {
  69. struct rds_ib_connection *ic;
  70. spin_lock(&ib_nodev_conns_lock);
  71. list_for_each_entry(ic, &ib_nodev_conns, ib_node)
  72. rds_conn_connect_if_down(ic->conn);
  73. spin_unlock(&ib_nodev_conns_lock);
  74. }
  75. static void rds_ib_dev_shutdown(struct rds_ib_device *rds_ibdev)
  76. {
  77. struct rds_ib_connection *ic;
  78. unsigned long flags;
  79. spin_lock_irqsave(&rds_ibdev->spinlock, flags);
  80. list_for_each_entry(ic, &rds_ibdev->conn_list, ib_node)
  81. rds_conn_path_drop(&ic->conn->c_path[0], true);
  82. spin_unlock_irqrestore(&rds_ibdev->spinlock, flags);
  83. }
  84. /*
  85. * rds_ib_destroy_mr_pool() blocks on a few things and mrs drop references
  86. * from interrupt context so we push freing off into a work struct in krdsd.
  87. */
  88. static void rds_ib_dev_free(struct work_struct *work)
  89. {
  90. struct rds_ib_ipaddr *i_ipaddr, *i_next;
  91. struct rds_ib_device *rds_ibdev = container_of(work,
  92. struct rds_ib_device, free_work);
  93. if (rds_ibdev->mr_8k_pool)
  94. rds_ib_destroy_mr_pool(rds_ibdev->mr_8k_pool);
  95. if (rds_ibdev->mr_1m_pool)
  96. rds_ib_destroy_mr_pool(rds_ibdev->mr_1m_pool);
  97. if (rds_ibdev->pd)
  98. ib_dealloc_pd(rds_ibdev->pd);
  99. list_for_each_entry_safe(i_ipaddr, i_next, &rds_ibdev->ipaddr_list, list) {
  100. list_del(&i_ipaddr->list);
  101. kfree(i_ipaddr);
  102. }
  103. kfree(rds_ibdev->vector_load);
  104. kfree(rds_ibdev);
  105. }
  106. void rds_ib_dev_put(struct rds_ib_device *rds_ibdev)
  107. {
  108. BUG_ON(refcount_read(&rds_ibdev->refcount) == 0);
  109. if (refcount_dec_and_test(&rds_ibdev->refcount))
  110. queue_work(rds_wq, &rds_ibdev->free_work);
  111. }
  112. static int rds_ib_add_one(struct ib_device *device)
  113. {
  114. struct rds_ib_device *rds_ibdev;
  115. int ret;
  116. /* Only handle IB (no iWARP) devices */
  117. if (device->node_type != RDMA_NODE_IB_CA)
  118. return -EOPNOTSUPP;
  119. /* Device must support FRWR */
  120. if (!(device->attrs.device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS))
  121. return -EOPNOTSUPP;
  122. rds_ibdev = kzalloc_node(sizeof(struct rds_ib_device), GFP_KERNEL,
  123. ibdev_to_node(device));
  124. if (!rds_ibdev)
  125. return -ENOMEM;
  126. spin_lock_init(&rds_ibdev->spinlock);
  127. refcount_set(&rds_ibdev->refcount, 1);
  128. INIT_WORK(&rds_ibdev->free_work, rds_ib_dev_free);
  129. INIT_LIST_HEAD(&rds_ibdev->ipaddr_list);
  130. INIT_LIST_HEAD(&rds_ibdev->conn_list);
  131. rds_ibdev->max_wrs = device->attrs.max_qp_wr;
  132. rds_ibdev->max_sge = min(device->attrs.max_send_sge, RDS_IB_MAX_SGE);
  133. rds_ibdev->odp_capable =
  134. !!(device->attrs.kernel_cap_flags &
  135. IBK_ON_DEMAND_PAGING) &&
  136. !!(device->attrs.odp_caps.per_transport_caps.rc_odp_caps &
  137. IB_ODP_SUPPORT_WRITE) &&
  138. !!(device->attrs.odp_caps.per_transport_caps.rc_odp_caps &
  139. IB_ODP_SUPPORT_READ);
  140. rds_ibdev->max_1m_mrs = device->attrs.max_mr ?
  141. min_t(unsigned int, (device->attrs.max_mr / 2),
  142. rds_ib_mr_1m_pool_size) : rds_ib_mr_1m_pool_size;
  143. rds_ibdev->max_8k_mrs = device->attrs.max_mr ?
  144. min_t(unsigned int, ((device->attrs.max_mr / 2) * RDS_MR_8K_SCALE),
  145. rds_ib_mr_8k_pool_size) : rds_ib_mr_8k_pool_size;
  146. rds_ibdev->max_initiator_depth = device->attrs.max_qp_init_rd_atom;
  147. rds_ibdev->max_responder_resources = device->attrs.max_qp_rd_atom;
  148. rds_ibdev->vector_load = kcalloc(device->num_comp_vectors,
  149. sizeof(int),
  150. GFP_KERNEL);
  151. if (!rds_ibdev->vector_load) {
  152. pr_err("RDS/IB: %s failed to allocate vector memory\n",
  153. __func__);
  154. ret = -ENOMEM;
  155. goto put_dev;
  156. }
  157. rds_ibdev->dev = device;
  158. rds_ibdev->pd = ib_alloc_pd(device, 0);
  159. if (IS_ERR(rds_ibdev->pd)) {
  160. ret = PTR_ERR(rds_ibdev->pd);
  161. rds_ibdev->pd = NULL;
  162. goto put_dev;
  163. }
  164. rds_ibdev->mr_1m_pool =
  165. rds_ib_create_mr_pool(rds_ibdev, RDS_IB_MR_1M_POOL);
  166. if (IS_ERR(rds_ibdev->mr_1m_pool)) {
  167. ret = PTR_ERR(rds_ibdev->mr_1m_pool);
  168. rds_ibdev->mr_1m_pool = NULL;
  169. goto put_dev;
  170. }
  171. rds_ibdev->mr_8k_pool =
  172. rds_ib_create_mr_pool(rds_ibdev, RDS_IB_MR_8K_POOL);
  173. if (IS_ERR(rds_ibdev->mr_8k_pool)) {
  174. ret = PTR_ERR(rds_ibdev->mr_8k_pool);
  175. rds_ibdev->mr_8k_pool = NULL;
  176. goto put_dev;
  177. }
  178. rdsdebug("RDS/IB: max_mr = %d, max_wrs = %d, max_sge = %d, max_1m_mrs = %d, max_8k_mrs = %d\n",
  179. device->attrs.max_mr, rds_ibdev->max_wrs, rds_ibdev->max_sge,
  180. rds_ibdev->max_1m_mrs, rds_ibdev->max_8k_mrs);
  181. pr_info("RDS/IB: %s: added\n", device->name);
  182. down_write(&rds_ib_devices_lock);
  183. list_add_tail_rcu(&rds_ibdev->list, &rds_ib_devices);
  184. up_write(&rds_ib_devices_lock);
  185. refcount_inc(&rds_ibdev->refcount);
  186. ib_set_client_data(device, &rds_ib_client, rds_ibdev);
  187. rds_ib_nodev_connect();
  188. return 0;
  189. put_dev:
  190. rds_ib_dev_put(rds_ibdev);
  191. return ret;
  192. }
  193. /*
  194. * New connections use this to find the device to associate with the
  195. * connection. It's not in the fast path so we're not concerned about the
  196. * performance of the IB call. (As of this writing, it uses an interrupt
  197. * blocking spinlock to serialize walking a per-device list of all registered
  198. * clients.)
  199. *
  200. * RCU is used to handle incoming connections racing with device teardown.
  201. * Rather than use a lock to serialize removal from the client_data and
  202. * getting a new reference, we use an RCU grace period. The destruction
  203. * path removes the device from client_data and then waits for all RCU
  204. * readers to finish.
  205. *
  206. * A new connection can get NULL from this if its arriving on a
  207. * device that is in the process of being removed.
  208. */
  209. struct rds_ib_device *rds_ib_get_client_data(struct ib_device *device)
  210. {
  211. struct rds_ib_device *rds_ibdev;
  212. rcu_read_lock();
  213. rds_ibdev = ib_get_client_data(device, &rds_ib_client);
  214. if (rds_ibdev)
  215. refcount_inc(&rds_ibdev->refcount);
  216. rcu_read_unlock();
  217. return rds_ibdev;
  218. }
  219. /*
  220. * The IB stack is letting us know that a device is going away. This can
  221. * happen if the underlying HCA driver is removed or if PCI hotplug is removing
  222. * the pci function, for example.
  223. *
  224. * This can be called at any time and can be racing with any other RDS path.
  225. */
  226. static void rds_ib_remove_one(struct ib_device *device, void *client_data)
  227. {
  228. struct rds_ib_device *rds_ibdev = client_data;
  229. rds_ib_dev_shutdown(rds_ibdev);
  230. /* stop connection attempts from getting a reference to this device. */
  231. ib_set_client_data(device, &rds_ib_client, NULL);
  232. down_write(&rds_ib_devices_lock);
  233. list_del_rcu(&rds_ibdev->list);
  234. up_write(&rds_ib_devices_lock);
  235. /*
  236. * This synchronize rcu is waiting for readers of both the ib
  237. * client data and the devices list to finish before we drop
  238. * both of those references.
  239. */
  240. synchronize_rcu();
  241. rds_ib_dev_put(rds_ibdev);
  242. rds_ib_dev_put(rds_ibdev);
  243. }
  244. struct ib_client rds_ib_client = {
  245. .name = "rds_ib",
  246. .add = rds_ib_add_one,
  247. .remove = rds_ib_remove_one
  248. };
  249. static int rds_ib_conn_info_visitor(struct rds_connection *conn,
  250. void *buffer)
  251. {
  252. struct rds_info_rdma_connection *iinfo = buffer;
  253. struct rds_ib_connection *ic = conn->c_transport_data;
  254. /* We will only ever look at IB transports */
  255. if (conn->c_trans != &rds_ib_transport)
  256. return 0;
  257. if (conn->c_isv6)
  258. return 0;
  259. iinfo->src_addr = conn->c_laddr.s6_addr32[3];
  260. iinfo->dst_addr = conn->c_faddr.s6_addr32[3];
  261. if (ic) {
  262. iinfo->tos = conn->c_tos;
  263. iinfo->sl = ic->i_sl;
  264. }
  265. memset(&iinfo->src_gid, 0, sizeof(iinfo->src_gid));
  266. memset(&iinfo->dst_gid, 0, sizeof(iinfo->dst_gid));
  267. if (rds_conn_state(conn) == RDS_CONN_UP) {
  268. struct rds_ib_device *rds_ibdev;
  269. rdma_read_gids(ic->i_cm_id, (union ib_gid *)&iinfo->src_gid,
  270. (union ib_gid *)&iinfo->dst_gid);
  271. rds_ibdev = ic->rds_ibdev;
  272. iinfo->max_send_wr = ic->i_send_ring.w_nr;
  273. iinfo->max_recv_wr = ic->i_recv_ring.w_nr;
  274. iinfo->max_send_sge = rds_ibdev->max_sge;
  275. rds_ib_get_mr_info(rds_ibdev, iinfo);
  276. iinfo->cache_allocs = atomic_read(&ic->i_cache_allocs);
  277. }
  278. return 1;
  279. }
  280. #if IS_ENABLED(CONFIG_IPV6)
  281. /* IPv6 version of rds_ib_conn_info_visitor(). */
  282. static int rds6_ib_conn_info_visitor(struct rds_connection *conn,
  283. void *buffer)
  284. {
  285. struct rds6_info_rdma_connection *iinfo6 = buffer;
  286. struct rds_ib_connection *ic = conn->c_transport_data;
  287. /* We will only ever look at IB transports */
  288. if (conn->c_trans != &rds_ib_transport)
  289. return 0;
  290. iinfo6->src_addr = conn->c_laddr;
  291. iinfo6->dst_addr = conn->c_faddr;
  292. if (ic) {
  293. iinfo6->tos = conn->c_tos;
  294. iinfo6->sl = ic->i_sl;
  295. }
  296. memset(&iinfo6->src_gid, 0, sizeof(iinfo6->src_gid));
  297. memset(&iinfo6->dst_gid, 0, sizeof(iinfo6->dst_gid));
  298. if (rds_conn_state(conn) == RDS_CONN_UP) {
  299. struct rds_ib_device *rds_ibdev;
  300. rdma_read_gids(ic->i_cm_id, (union ib_gid *)&iinfo6->src_gid,
  301. (union ib_gid *)&iinfo6->dst_gid);
  302. rds_ibdev = ic->rds_ibdev;
  303. iinfo6->max_send_wr = ic->i_send_ring.w_nr;
  304. iinfo6->max_recv_wr = ic->i_recv_ring.w_nr;
  305. iinfo6->max_send_sge = rds_ibdev->max_sge;
  306. rds6_ib_get_mr_info(rds_ibdev, iinfo6);
  307. iinfo6->cache_allocs = atomic_read(&ic->i_cache_allocs);
  308. }
  309. return 1;
  310. }
  311. #endif
  312. static void rds_ib_ic_info(struct socket *sock, unsigned int len,
  313. struct rds_info_iterator *iter,
  314. struct rds_info_lengths *lens)
  315. {
  316. u64 buffer[(sizeof(struct rds_info_rdma_connection) + 7) / 8];
  317. rds_for_each_conn_info(sock, len, iter, lens,
  318. rds_ib_conn_info_visitor,
  319. buffer,
  320. sizeof(struct rds_info_rdma_connection));
  321. }
  322. #if IS_ENABLED(CONFIG_IPV6)
  323. /* IPv6 version of rds_ib_ic_info(). */
  324. static void rds6_ib_ic_info(struct socket *sock, unsigned int len,
  325. struct rds_info_iterator *iter,
  326. struct rds_info_lengths *lens)
  327. {
  328. u64 buffer[(sizeof(struct rds6_info_rdma_connection) + 7) / 8];
  329. rds_for_each_conn_info(sock, len, iter, lens,
  330. rds6_ib_conn_info_visitor,
  331. buffer,
  332. sizeof(struct rds6_info_rdma_connection));
  333. }
  334. #endif
  335. /*
  336. * Early RDS/IB was built to only bind to an address if there is an IPoIB
  337. * device with that address set.
  338. *
  339. * If it were me, I'd advocate for something more flexible. Sending and
  340. * receiving should be device-agnostic. Transports would try and maintain
  341. * connections between peers who have messages queued. Userspace would be
  342. * allowed to influence which paths have priority. We could call userspace
  343. * asserting this policy "routing".
  344. */
  345. static int rds_ib_laddr_check(struct net *net, const struct in6_addr *addr,
  346. __u32 scope_id)
  347. {
  348. int ret;
  349. struct rdma_cm_id *cm_id;
  350. #if IS_ENABLED(CONFIG_IPV6)
  351. struct sockaddr_in6 sin6;
  352. #endif
  353. struct sockaddr_in sin;
  354. struct sockaddr *sa;
  355. bool isv4;
  356. isv4 = ipv6_addr_v4mapped(addr);
  357. /* Create a CMA ID and try to bind it. This catches both
  358. * IB and iWARP capable NICs.
  359. */
  360. cm_id = rdma_create_id(&init_net, rds_rdma_cm_event_handler,
  361. NULL, RDMA_PS_TCP, IB_QPT_RC);
  362. if (IS_ERR(cm_id))
  363. return PTR_ERR(cm_id);
  364. if (isv4) {
  365. memset(&sin, 0, sizeof(sin));
  366. sin.sin_family = AF_INET;
  367. sin.sin_addr.s_addr = addr->s6_addr32[3];
  368. sa = (struct sockaddr *)&sin;
  369. } else {
  370. #if IS_ENABLED(CONFIG_IPV6)
  371. memset(&sin6, 0, sizeof(sin6));
  372. sin6.sin6_family = AF_INET6;
  373. sin6.sin6_addr = *addr;
  374. sin6.sin6_scope_id = scope_id;
  375. sa = (struct sockaddr *)&sin6;
  376. /* XXX Do a special IPv6 link local address check here. The
  377. * reason is that rdma_bind_addr() always succeeds with IPv6
  378. * link local address regardless it is indeed configured in a
  379. * system.
  380. */
  381. if (ipv6_addr_type(addr) & IPV6_ADDR_LINKLOCAL) {
  382. struct net_device *dev;
  383. if (scope_id == 0) {
  384. ret = -EADDRNOTAVAIL;
  385. goto out;
  386. }
  387. /* Use init_net for now as RDS is not network
  388. * name space aware.
  389. */
  390. dev = dev_get_by_index(&init_net, scope_id);
  391. if (!dev) {
  392. ret = -EADDRNOTAVAIL;
  393. goto out;
  394. }
  395. if (!ipv6_chk_addr(&init_net, addr, dev, 1)) {
  396. dev_put(dev);
  397. ret = -EADDRNOTAVAIL;
  398. goto out;
  399. }
  400. dev_put(dev);
  401. }
  402. #else
  403. ret = -EADDRNOTAVAIL;
  404. goto out;
  405. #endif
  406. }
  407. /* rdma_bind_addr will only succeed for IB & iWARP devices */
  408. ret = rdma_bind_addr(cm_id, sa);
  409. /* due to this, we will claim to support iWARP devices unless we
  410. check node_type. */
  411. if (ret || !cm_id->device ||
  412. cm_id->device->node_type != RDMA_NODE_IB_CA)
  413. ret = -EADDRNOTAVAIL;
  414. rdsdebug("addr %pI6c%%%u ret %d node type %d\n",
  415. addr, scope_id, ret,
  416. cm_id->device ? cm_id->device->node_type : -1);
  417. out:
  418. rdma_destroy_id(cm_id);
  419. return ret;
  420. }
  421. static void rds_ib_unregister_client(void)
  422. {
  423. ib_unregister_client(&rds_ib_client);
  424. /* wait for rds_ib_dev_free() to complete */
  425. flush_workqueue(rds_wq);
  426. }
  427. static void rds_ib_set_unloading(void)
  428. {
  429. atomic_set(&rds_ib_unloading, 1);
  430. }
  431. static bool rds_ib_is_unloading(struct rds_connection *conn)
  432. {
  433. struct rds_conn_path *cp = &conn->c_path[0];
  434. return (test_bit(RDS_DESTROY_PENDING, &cp->cp_flags) ||
  435. atomic_read(&rds_ib_unloading) != 0);
  436. }
  437. void rds_ib_exit(void)
  438. {
  439. rds_ib_set_unloading();
  440. synchronize_rcu();
  441. rds_info_deregister_func(RDS_INFO_IB_CONNECTIONS, rds_ib_ic_info);
  442. #if IS_ENABLED(CONFIG_IPV6)
  443. rds_info_deregister_func(RDS6_INFO_IB_CONNECTIONS, rds6_ib_ic_info);
  444. #endif
  445. rds_ib_unregister_client();
  446. rds_ib_destroy_nodev_conns();
  447. rds_ib_sysctl_exit();
  448. rds_ib_recv_exit();
  449. rds_trans_unregister(&rds_ib_transport);
  450. rds_ib_mr_exit();
  451. }
  452. static u8 rds_ib_get_tos_map(u8 tos)
  453. {
  454. /* 1:1 user to transport map for RDMA transport.
  455. * In future, if custom map is desired, hook can export
  456. * user configurable map.
  457. */
  458. return tos;
  459. }
  460. struct rds_transport rds_ib_transport = {
  461. .laddr_check = rds_ib_laddr_check,
  462. .xmit_path_complete = rds_ib_xmit_path_complete,
  463. .xmit = rds_ib_xmit,
  464. .xmit_rdma = rds_ib_xmit_rdma,
  465. .xmit_atomic = rds_ib_xmit_atomic,
  466. .recv_path = rds_ib_recv_path,
  467. .conn_alloc = rds_ib_conn_alloc,
  468. .conn_free = rds_ib_conn_free,
  469. .conn_path_connect = rds_ib_conn_path_connect,
  470. .conn_path_shutdown = rds_ib_conn_path_shutdown,
  471. .inc_copy_to_user = rds_ib_inc_copy_to_user,
  472. .inc_free = rds_ib_inc_free,
  473. .cm_initiate_connect = rds_ib_cm_initiate_connect,
  474. .cm_handle_connect = rds_ib_cm_handle_connect,
  475. .cm_connect_complete = rds_ib_cm_connect_complete,
  476. .stats_info_copy = rds_ib_stats_info_copy,
  477. .exit = rds_ib_exit,
  478. .get_mr = rds_ib_get_mr,
  479. .sync_mr = rds_ib_sync_mr,
  480. .free_mr = rds_ib_free_mr,
  481. .flush_mrs = rds_ib_flush_mrs,
  482. .get_tos_map = rds_ib_get_tos_map,
  483. .t_owner = THIS_MODULE,
  484. .t_name = "infiniband",
  485. .t_unloading = rds_ib_is_unloading,
  486. .t_type = RDS_TRANS_IB
  487. };
  488. int rds_ib_init(void)
  489. {
  490. int ret;
  491. INIT_LIST_HEAD(&rds_ib_devices);
  492. ret = rds_ib_mr_init();
  493. if (ret)
  494. goto out;
  495. ret = ib_register_client(&rds_ib_client);
  496. if (ret)
  497. goto out_mr_exit;
  498. ret = rds_ib_sysctl_init();
  499. if (ret)
  500. goto out_ibreg;
  501. ret = rds_ib_recv_init();
  502. if (ret)
  503. goto out_sysctl;
  504. rds_trans_register(&rds_ib_transport);
  505. rds_info_register_func(RDS_INFO_IB_CONNECTIONS, rds_ib_ic_info);
  506. #if IS_ENABLED(CONFIG_IPV6)
  507. rds_info_register_func(RDS6_INFO_IB_CONNECTIONS, rds6_ib_ic_info);
  508. #endif
  509. goto out;
  510. out_sysctl:
  511. rds_ib_sysctl_exit();
  512. out_ibreg:
  513. rds_ib_unregister_client();
  514. out_mr_exit:
  515. rds_ib_mr_exit();
  516. out:
  517. return ret;
  518. }
  519. MODULE_LICENSE("GPL");