ocrdma_main.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /*******************************************************************
  2. * This file is part of the Emulex RoCE Device Driver for *
  3. * RoCE (RDMA over Converged Ethernet) adapters. *
  4. * Copyright (C) 2008-2012 Emulex. All rights reserved. *
  5. * EMULEX and SLI are trademarks of Emulex. *
  6. * www.emulex.com *
  7. * *
  8. * This program is free software; you can redistribute it and/or *
  9. * modify it under the terms of version 2 of the GNU General *
  10. * Public License as published by the Free Software Foundation. *
  11. * This program is distributed in the hope that it will be useful. *
  12. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
  13. * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
  14. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
  15. * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
  16. * TO BE LEGALLY INVALID. See the GNU General Public License for *
  17. * more details, a copy of which can be found in the file COPYING *
  18. * included with this package. *
  19. *
  20. * Contact Information:
  21. * linux-drivers@emulex.com
  22. *
  23. * Emulex
  24. * 3333 Susan Street
  25. * Costa Mesa, CA 92626
  26. *******************************************************************/
  27. #include <linux/module.h>
  28. #include <linux/idr.h>
  29. #include <rdma/ib_verbs.h>
  30. #include <rdma/ib_user_verbs.h>
  31. #include <rdma/ib_addr.h>
  32. #include <linux/netdevice.h>
  33. #include <net/addrconf.h>
  34. #include "ocrdma.h"
  35. #include "ocrdma_verbs.h"
  36. #include "ocrdma_ah.h"
  37. #include "be_roce.h"
  38. #include "ocrdma_hw.h"
  39. MODULE_VERSION(OCRDMA_ROCE_DEV_VERSION);
  40. MODULE_DESCRIPTION("Emulex RoCE HCA Driver");
  41. MODULE_AUTHOR("Emulex Corporation");
  42. MODULE_LICENSE("GPL");
  43. static LIST_HEAD(ocrdma_dev_list);
  44. static DEFINE_SPINLOCK(ocrdma_devlist_lock);
  45. static DEFINE_IDR(ocrdma_dev_id);
  46. static union ib_gid ocrdma_zero_sgid;
  47. static int ocrdma_get_instance(void)
  48. {
  49. int instance = 0;
  50. /* Assign an unused number */
  51. if (!idr_pre_get(&ocrdma_dev_id, GFP_KERNEL))
  52. return -1;
  53. if (idr_get_new(&ocrdma_dev_id, NULL, &instance))
  54. return -1;
  55. return instance;
  56. }
  57. void ocrdma_get_guid(struct ocrdma_dev *dev, u8 *guid)
  58. {
  59. u8 mac_addr[6];
  60. memcpy(&mac_addr[0], &dev->nic_info.mac_addr[0], ETH_ALEN);
  61. guid[0] = mac_addr[0] ^ 2;
  62. guid[1] = mac_addr[1];
  63. guid[2] = mac_addr[2];
  64. guid[3] = 0xff;
  65. guid[4] = 0xfe;
  66. guid[5] = mac_addr[3];
  67. guid[6] = mac_addr[4];
  68. guid[7] = mac_addr[5];
  69. }
  70. static void ocrdma_build_sgid_mac(union ib_gid *sgid, unsigned char *mac_addr,
  71. bool is_vlan, u16 vlan_id)
  72. {
  73. sgid->global.subnet_prefix = cpu_to_be64(0xfe80000000000000LL);
  74. sgid->raw[8] = mac_addr[0] ^ 2;
  75. sgid->raw[9] = mac_addr[1];
  76. sgid->raw[10] = mac_addr[2];
  77. if (is_vlan) {
  78. sgid->raw[11] = vlan_id >> 8;
  79. sgid->raw[12] = vlan_id & 0xff;
  80. } else {
  81. sgid->raw[11] = 0xff;
  82. sgid->raw[12] = 0xfe;
  83. }
  84. sgid->raw[13] = mac_addr[3];
  85. sgid->raw[14] = mac_addr[4];
  86. sgid->raw[15] = mac_addr[5];
  87. }
  88. static bool ocrdma_add_sgid(struct ocrdma_dev *dev, unsigned char *mac_addr,
  89. bool is_vlan, u16 vlan_id)
  90. {
  91. int i;
  92. union ib_gid new_sgid;
  93. unsigned long flags;
  94. memset(&ocrdma_zero_sgid, 0, sizeof(union ib_gid));
  95. ocrdma_build_sgid_mac(&new_sgid, mac_addr, is_vlan, vlan_id);
  96. spin_lock_irqsave(&dev->sgid_lock, flags);
  97. for (i = 0; i < OCRDMA_MAX_SGID; i++) {
  98. if (!memcmp(&dev->sgid_tbl[i], &ocrdma_zero_sgid,
  99. sizeof(union ib_gid))) {
  100. /* found free entry */
  101. memcpy(&dev->sgid_tbl[i], &new_sgid,
  102. sizeof(union ib_gid));
  103. spin_unlock_irqrestore(&dev->sgid_lock, flags);
  104. return true;
  105. } else if (!memcmp(&dev->sgid_tbl[i], &new_sgid,
  106. sizeof(union ib_gid))) {
  107. /* entry already present, no addition is required. */
  108. spin_unlock_irqrestore(&dev->sgid_lock, flags);
  109. return false;
  110. }
  111. }
  112. spin_unlock_irqrestore(&dev->sgid_lock, flags);
  113. return false;
  114. }
  115. static bool ocrdma_del_sgid(struct ocrdma_dev *dev, unsigned char *mac_addr,
  116. bool is_vlan, u16 vlan_id)
  117. {
  118. int found = false;
  119. int i;
  120. union ib_gid sgid;
  121. unsigned long flags;
  122. ocrdma_build_sgid_mac(&sgid, mac_addr, is_vlan, vlan_id);
  123. spin_lock_irqsave(&dev->sgid_lock, flags);
  124. /* first is default sgid, which cannot be deleted. */
  125. for (i = 1; i < OCRDMA_MAX_SGID; i++) {
  126. if (!memcmp(&dev->sgid_tbl[i], &sgid, sizeof(union ib_gid))) {
  127. /* found matching entry */
  128. memset(&dev->sgid_tbl[i], 0, sizeof(union ib_gid));
  129. found = true;
  130. break;
  131. }
  132. }
  133. spin_unlock_irqrestore(&dev->sgid_lock, flags);
  134. return found;
  135. }
  136. static void ocrdma_add_default_sgid(struct ocrdma_dev *dev)
  137. {
  138. /* GID Index 0 - Invariant manufacturer-assigned EUI-64 */
  139. union ib_gid *sgid = &dev->sgid_tbl[0];
  140. sgid->global.subnet_prefix = cpu_to_be64(0xfe80000000000000LL);
  141. ocrdma_get_guid(dev, &sgid->raw[8]);
  142. }
  143. #if IS_ENABLED(CONFIG_VLAN_8021Q)
  144. static void ocrdma_add_vlan_sgids(struct ocrdma_dev *dev)
  145. {
  146. struct net_device *netdev, *tmp;
  147. u16 vlan_id;
  148. bool is_vlan;
  149. netdev = dev->nic_info.netdev;
  150. rcu_read_lock();
  151. for_each_netdev_rcu(&init_net, tmp) {
  152. if (netdev == tmp || vlan_dev_real_dev(tmp) == netdev) {
  153. if (!netif_running(tmp) || !netif_oper_up(tmp))
  154. continue;
  155. if (netdev != tmp) {
  156. vlan_id = vlan_dev_vlan_id(tmp);
  157. is_vlan = true;
  158. } else {
  159. is_vlan = false;
  160. vlan_id = 0;
  161. tmp = netdev;
  162. }
  163. ocrdma_add_sgid(dev, tmp->dev_addr, is_vlan, vlan_id);
  164. }
  165. }
  166. rcu_read_unlock();
  167. }
  168. #else
  169. static void ocrdma_add_vlan_sgids(struct ocrdma_dev *dev)
  170. {
  171. }
  172. #endif /* VLAN */
  173. static int ocrdma_build_sgid_tbl(struct ocrdma_dev *dev)
  174. {
  175. ocrdma_add_default_sgid(dev);
  176. ocrdma_add_vlan_sgids(dev);
  177. return 0;
  178. }
  179. #if IS_ENABLED(CONFIG_IPV6)
  180. static int ocrdma_inet6addr_event(struct notifier_block *notifier,
  181. unsigned long event, void *ptr)
  182. {
  183. struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr;
  184. struct net_device *netdev = ifa->idev->dev;
  185. struct ib_event gid_event;
  186. struct ocrdma_dev *dev;
  187. bool found = false;
  188. bool updated = false;
  189. bool is_vlan = false;
  190. u16 vid = 0;
  191. is_vlan = netdev->priv_flags & IFF_802_1Q_VLAN;
  192. if (is_vlan) {
  193. vid = vlan_dev_vlan_id(netdev);
  194. netdev = vlan_dev_real_dev(netdev);
  195. }
  196. rcu_read_lock();
  197. list_for_each_entry_rcu(dev, &ocrdma_dev_list, entry) {
  198. if (dev->nic_info.netdev == netdev) {
  199. found = true;
  200. break;
  201. }
  202. }
  203. rcu_read_unlock();
  204. if (!found)
  205. return NOTIFY_DONE;
  206. if (!rdma_link_local_addr((struct in6_addr *)&ifa->addr))
  207. return NOTIFY_DONE;
  208. mutex_lock(&dev->dev_lock);
  209. switch (event) {
  210. case NETDEV_UP:
  211. updated = ocrdma_add_sgid(dev, netdev->dev_addr, is_vlan, vid);
  212. break;
  213. case NETDEV_DOWN:
  214. updated = ocrdma_del_sgid(dev, netdev->dev_addr, is_vlan, vid);
  215. break;
  216. default:
  217. break;
  218. }
  219. if (updated) {
  220. /* GID table updated, notify the consumers about it */
  221. gid_event.device = &dev->ibdev;
  222. gid_event.element.port_num = 1;
  223. gid_event.event = IB_EVENT_GID_CHANGE;
  224. ib_dispatch_event(&gid_event);
  225. }
  226. mutex_unlock(&dev->dev_lock);
  227. return NOTIFY_OK;
  228. }
  229. static struct notifier_block ocrdma_inet6addr_notifier = {
  230. .notifier_call = ocrdma_inet6addr_event
  231. };
  232. #endif /* IPV6 and VLAN */
  233. static enum rdma_link_layer ocrdma_link_layer(struct ib_device *device,
  234. u8 port_num)
  235. {
  236. return IB_LINK_LAYER_ETHERNET;
  237. }
  238. static int ocrdma_register_device(struct ocrdma_dev *dev)
  239. {
  240. strlcpy(dev->ibdev.name, "ocrdma%d", IB_DEVICE_NAME_MAX);
  241. ocrdma_get_guid(dev, (u8 *)&dev->ibdev.node_guid);
  242. memcpy(dev->ibdev.node_desc, OCRDMA_NODE_DESC,
  243. sizeof(OCRDMA_NODE_DESC));
  244. dev->ibdev.owner = THIS_MODULE;
  245. dev->ibdev.uverbs_cmd_mask =
  246. OCRDMA_UVERBS(GET_CONTEXT) |
  247. OCRDMA_UVERBS(QUERY_DEVICE) |
  248. OCRDMA_UVERBS(QUERY_PORT) |
  249. OCRDMA_UVERBS(ALLOC_PD) |
  250. OCRDMA_UVERBS(DEALLOC_PD) |
  251. OCRDMA_UVERBS(REG_MR) |
  252. OCRDMA_UVERBS(DEREG_MR) |
  253. OCRDMA_UVERBS(CREATE_COMP_CHANNEL) |
  254. OCRDMA_UVERBS(CREATE_CQ) |
  255. OCRDMA_UVERBS(RESIZE_CQ) |
  256. OCRDMA_UVERBS(DESTROY_CQ) |
  257. OCRDMA_UVERBS(REQ_NOTIFY_CQ) |
  258. OCRDMA_UVERBS(CREATE_QP) |
  259. OCRDMA_UVERBS(MODIFY_QP) |
  260. OCRDMA_UVERBS(QUERY_QP) |
  261. OCRDMA_UVERBS(DESTROY_QP) |
  262. OCRDMA_UVERBS(POLL_CQ) |
  263. OCRDMA_UVERBS(POST_SEND) |
  264. OCRDMA_UVERBS(POST_RECV);
  265. dev->ibdev.uverbs_cmd_mask |=
  266. OCRDMA_UVERBS(CREATE_AH) |
  267. OCRDMA_UVERBS(MODIFY_AH) |
  268. OCRDMA_UVERBS(QUERY_AH) |
  269. OCRDMA_UVERBS(DESTROY_AH);
  270. dev->ibdev.node_type = RDMA_NODE_IB_CA;
  271. dev->ibdev.phys_port_cnt = 1;
  272. dev->ibdev.num_comp_vectors = 1;
  273. /* mandatory verbs. */
  274. dev->ibdev.query_device = ocrdma_query_device;
  275. dev->ibdev.query_port = ocrdma_query_port;
  276. dev->ibdev.modify_port = ocrdma_modify_port;
  277. dev->ibdev.query_gid = ocrdma_query_gid;
  278. dev->ibdev.get_link_layer = ocrdma_link_layer;
  279. dev->ibdev.alloc_pd = ocrdma_alloc_pd;
  280. dev->ibdev.dealloc_pd = ocrdma_dealloc_pd;
  281. dev->ibdev.create_cq = ocrdma_create_cq;
  282. dev->ibdev.destroy_cq = ocrdma_destroy_cq;
  283. dev->ibdev.resize_cq = ocrdma_resize_cq;
  284. dev->ibdev.create_qp = ocrdma_create_qp;
  285. dev->ibdev.modify_qp = ocrdma_modify_qp;
  286. dev->ibdev.query_qp = ocrdma_query_qp;
  287. dev->ibdev.destroy_qp = ocrdma_destroy_qp;
  288. dev->ibdev.query_pkey = ocrdma_query_pkey;
  289. dev->ibdev.create_ah = ocrdma_create_ah;
  290. dev->ibdev.destroy_ah = ocrdma_destroy_ah;
  291. dev->ibdev.query_ah = ocrdma_query_ah;
  292. dev->ibdev.modify_ah = ocrdma_modify_ah;
  293. dev->ibdev.poll_cq = ocrdma_poll_cq;
  294. dev->ibdev.post_send = ocrdma_post_send;
  295. dev->ibdev.post_recv = ocrdma_post_recv;
  296. dev->ibdev.req_notify_cq = ocrdma_arm_cq;
  297. dev->ibdev.get_dma_mr = ocrdma_get_dma_mr;
  298. dev->ibdev.dereg_mr = ocrdma_dereg_mr;
  299. dev->ibdev.reg_user_mr = ocrdma_reg_user_mr;
  300. /* mandatory to support user space verbs consumer. */
  301. dev->ibdev.alloc_ucontext = ocrdma_alloc_ucontext;
  302. dev->ibdev.dealloc_ucontext = ocrdma_dealloc_ucontext;
  303. dev->ibdev.mmap = ocrdma_mmap;
  304. dev->ibdev.dma_device = &dev->nic_info.pdev->dev;
  305. dev->ibdev.process_mad = ocrdma_process_mad;
  306. if (dev->nic_info.dev_family == OCRDMA_GEN2_FAMILY) {
  307. dev->ibdev.uverbs_cmd_mask |=
  308. OCRDMA_UVERBS(CREATE_SRQ) |
  309. OCRDMA_UVERBS(MODIFY_SRQ) |
  310. OCRDMA_UVERBS(QUERY_SRQ) |
  311. OCRDMA_UVERBS(DESTROY_SRQ) |
  312. OCRDMA_UVERBS(POST_SRQ_RECV);
  313. dev->ibdev.create_srq = ocrdma_create_srq;
  314. dev->ibdev.modify_srq = ocrdma_modify_srq;
  315. dev->ibdev.query_srq = ocrdma_query_srq;
  316. dev->ibdev.destroy_srq = ocrdma_destroy_srq;
  317. dev->ibdev.post_srq_recv = ocrdma_post_srq_recv;
  318. }
  319. return ib_register_device(&dev->ibdev, NULL);
  320. }
  321. static int ocrdma_alloc_resources(struct ocrdma_dev *dev)
  322. {
  323. mutex_init(&dev->dev_lock);
  324. dev->sgid_tbl = kzalloc(sizeof(union ib_gid) *
  325. OCRDMA_MAX_SGID, GFP_KERNEL);
  326. if (!dev->sgid_tbl)
  327. goto alloc_err;
  328. spin_lock_init(&dev->sgid_lock);
  329. dev->cq_tbl = kzalloc(sizeof(struct ocrdma_cq *) *
  330. OCRDMA_MAX_CQ, GFP_KERNEL);
  331. if (!dev->cq_tbl)
  332. goto alloc_err;
  333. if (dev->attr.max_qp) {
  334. dev->qp_tbl = kzalloc(sizeof(struct ocrdma_qp *) *
  335. OCRDMA_MAX_QP, GFP_KERNEL);
  336. if (!dev->qp_tbl)
  337. goto alloc_err;
  338. }
  339. spin_lock_init(&dev->av_tbl.lock);
  340. spin_lock_init(&dev->flush_q_lock);
  341. return 0;
  342. alloc_err:
  343. ocrdma_err("%s(%d) error.\n", __func__, dev->id);
  344. return -ENOMEM;
  345. }
  346. static void ocrdma_free_resources(struct ocrdma_dev *dev)
  347. {
  348. kfree(dev->qp_tbl);
  349. kfree(dev->cq_tbl);
  350. kfree(dev->sgid_tbl);
  351. }
  352. static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info)
  353. {
  354. int status = 0;
  355. struct ocrdma_dev *dev;
  356. dev = (struct ocrdma_dev *)ib_alloc_device(sizeof(struct ocrdma_dev));
  357. if (!dev) {
  358. ocrdma_err("Unable to allocate ib device\n");
  359. return NULL;
  360. }
  361. dev->mbx_cmd = kzalloc(sizeof(struct ocrdma_mqe_emb_cmd), GFP_KERNEL);
  362. if (!dev->mbx_cmd)
  363. goto idr_err;
  364. memcpy(&dev->nic_info, dev_info, sizeof(*dev_info));
  365. dev->id = ocrdma_get_instance();
  366. if (dev->id < 0)
  367. goto idr_err;
  368. status = ocrdma_init_hw(dev);
  369. if (status)
  370. goto init_err;
  371. status = ocrdma_alloc_resources(dev);
  372. if (status)
  373. goto alloc_err;
  374. status = ocrdma_build_sgid_tbl(dev);
  375. if (status)
  376. goto alloc_err;
  377. status = ocrdma_register_device(dev);
  378. if (status)
  379. goto alloc_err;
  380. spin_lock(&ocrdma_devlist_lock);
  381. list_add_tail_rcu(&dev->entry, &ocrdma_dev_list);
  382. spin_unlock(&ocrdma_devlist_lock);
  383. return dev;
  384. alloc_err:
  385. ocrdma_free_resources(dev);
  386. ocrdma_cleanup_hw(dev);
  387. init_err:
  388. idr_remove(&ocrdma_dev_id, dev->id);
  389. idr_err:
  390. kfree(dev->mbx_cmd);
  391. ib_dealloc_device(&dev->ibdev);
  392. ocrdma_err("%s() leaving. ret=%d\n", __func__, status);
  393. return NULL;
  394. }
  395. static void ocrdma_remove_free(struct rcu_head *rcu)
  396. {
  397. struct ocrdma_dev *dev = container_of(rcu, struct ocrdma_dev, rcu);
  398. ocrdma_free_resources(dev);
  399. ocrdma_cleanup_hw(dev);
  400. idr_remove(&ocrdma_dev_id, dev->id);
  401. kfree(dev->mbx_cmd);
  402. ib_dealloc_device(&dev->ibdev);
  403. }
  404. static void ocrdma_remove(struct ocrdma_dev *dev)
  405. {
  406. /* first unregister with stack to stop all the active traffic
  407. * of the registered clients.
  408. */
  409. ib_unregister_device(&dev->ibdev);
  410. spin_lock(&ocrdma_devlist_lock);
  411. list_del_rcu(&dev->entry);
  412. spin_unlock(&ocrdma_devlist_lock);
  413. call_rcu(&dev->rcu, ocrdma_remove_free);
  414. }
  415. static int ocrdma_open(struct ocrdma_dev *dev)
  416. {
  417. struct ib_event port_event;
  418. port_event.event = IB_EVENT_PORT_ACTIVE;
  419. port_event.element.port_num = 1;
  420. port_event.device = &dev->ibdev;
  421. ib_dispatch_event(&port_event);
  422. return 0;
  423. }
  424. static int ocrdma_close(struct ocrdma_dev *dev)
  425. {
  426. int i;
  427. struct ocrdma_qp *qp, **cur_qp;
  428. struct ib_event err_event;
  429. struct ib_qp_attr attrs;
  430. int attr_mask = IB_QP_STATE;
  431. attrs.qp_state = IB_QPS_ERR;
  432. mutex_lock(&dev->dev_lock);
  433. if (dev->qp_tbl) {
  434. cur_qp = dev->qp_tbl;
  435. for (i = 0; i < OCRDMA_MAX_QP; i++) {
  436. qp = cur_qp[i];
  437. if (qp) {
  438. /* change the QP state to ERROR */
  439. _ocrdma_modify_qp(&qp->ibqp, &attrs, attr_mask);
  440. err_event.event = IB_EVENT_QP_FATAL;
  441. err_event.element.qp = &qp->ibqp;
  442. err_event.device = &dev->ibdev;
  443. ib_dispatch_event(&err_event);
  444. }
  445. }
  446. }
  447. mutex_unlock(&dev->dev_lock);
  448. err_event.event = IB_EVENT_PORT_ERR;
  449. err_event.element.port_num = 1;
  450. err_event.device = &dev->ibdev;
  451. ib_dispatch_event(&err_event);
  452. return 0;
  453. }
  454. /* event handling via NIC driver ensures that all the NIC specific
  455. * initialization done before RoCE driver notifies
  456. * event to stack.
  457. */
  458. static void ocrdma_event_handler(struct ocrdma_dev *dev, u32 event)
  459. {
  460. switch (event) {
  461. case BE_DEV_UP:
  462. ocrdma_open(dev);
  463. break;
  464. case BE_DEV_DOWN:
  465. ocrdma_close(dev);
  466. break;
  467. };
  468. }
  469. static struct ocrdma_driver ocrdma_drv = {
  470. .name = "ocrdma_driver",
  471. .add = ocrdma_add,
  472. .remove = ocrdma_remove,
  473. .state_change_handler = ocrdma_event_handler,
  474. };
  475. static void ocrdma_unregister_inet6addr_notifier(void)
  476. {
  477. #if IS_ENABLED(CONFIG_IPV6)
  478. unregister_inet6addr_notifier(&ocrdma_inet6addr_notifier);
  479. #endif
  480. }
  481. static int __init ocrdma_init_module(void)
  482. {
  483. int status;
  484. #if IS_ENABLED(CONFIG_IPV6)
  485. status = register_inet6addr_notifier(&ocrdma_inet6addr_notifier);
  486. if (status)
  487. return status;
  488. #endif
  489. status = be_roce_register_driver(&ocrdma_drv);
  490. if (status)
  491. ocrdma_unregister_inet6addr_notifier();
  492. return status;
  493. }
  494. static void __exit ocrdma_exit_module(void)
  495. {
  496. be_roce_unregister_driver(&ocrdma_drv);
  497. ocrdma_unregister_inet6addr_notifier();
  498. }
  499. module_init(ocrdma_init_module);
  500. module_exit(ocrdma_exit_module);