ocrdma_main.c 15 KB

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