/net/rds/ib.c

http://github.com/mirrors/linux · C · 618 lines · 425 code · 88 blank · 105 comment · 45 complexity · 48e7bc19a07bfccf8cb65ddbe359c04f MD5 · raw file

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