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 defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
  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) || IS_ENABLED(CONFIG_VLAN_8021Q)
  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 *event_netdev = ifa->idev->dev;
  185. struct net_device *netdev = NULL;
  186. struct ib_event gid_event;
  187. struct ocrdma_dev *dev;
  188. bool found = false;
  189. bool updated = false;
  190. bool is_vlan = false;
  191. u16 vid = 0;
  192. netdev = vlan_dev_real_dev(event_netdev);
  193. if (netdev != event_netdev) {
  194. is_vlan = true;
  195. vid = vlan_dev_vlan_id(event_netdev);
  196. }
  197. rcu_read_lock();
  198. list_for_each_entry_rcu(dev, &ocrdma_dev_list, entry) {
  199. if (dev->nic_info.netdev == netdev) {
  200. found = true;
  201. break;
  202. }
  203. }
  204. rcu_read_unlock();
  205. if (!found)
  206. return NOTIFY_DONE;
  207. if (!rdma_link_local_addr((struct in6_addr *)&ifa->addr))
  208. return NOTIFY_DONE;
  209. mutex_lock(&dev->dev_lock);
  210. switch (event) {
  211. case NETDEV_UP:
  212. updated = ocrdma_add_sgid(dev, netdev->dev_addr, is_vlan, vid);
  213. break;
  214. case NETDEV_DOWN:
  215. updated = ocrdma_del_sgid(dev, netdev->dev_addr, is_vlan, vid);
  216. break;
  217. default:
  218. break;
  219. }
  220. if (updated) {
  221. /* GID table updated, notify the consumers about it */
  222. gid_event.device = &dev->ibdev;
  223. gid_event.element.port_num = 1;
  224. gid_event.event = IB_EVENT_GID_CHANGE;
  225. ib_dispatch_event(&gid_event);
  226. }
  227. mutex_unlock(&dev->dev_lock);
  228. return NOTIFY_OK;
  229. }
  230. static struct notifier_block ocrdma_inet6addr_notifier = {
  231. .notifier_call = ocrdma_inet6addr_event
  232. };
  233. #endif /* IPV6 and VLAN */
  234. static enum rdma_link_layer ocrdma_link_layer(struct ib_device *device,
  235. u8 port_num)
  236. {
  237. return IB_LINK_LAYER_ETHERNET;
  238. }
  239. static int ocrdma_register_device(struct ocrdma_dev *dev)
  240. {
  241. strlcpy(dev->ibdev.name, "ocrdma%d", IB_DEVICE_NAME_MAX);
  242. ocrdma_get_guid(dev, (u8 *)&dev->ibdev.node_guid);
  243. memcpy(dev->ibdev.node_desc, OCRDMA_NODE_DESC,
  244. sizeof(OCRDMA_NODE_DESC));
  245. dev->ibdev.owner = THIS_MODULE;
  246. dev->ibdev.uverbs_cmd_mask =
  247. OCRDMA_UVERBS(GET_CONTEXT) |
  248. OCRDMA_UVERBS(QUERY_DEVICE) |
  249. OCRDMA_UVERBS(QUERY_PORT) |
  250. OCRDMA_UVERBS(ALLOC_PD) |
  251. OCRDMA_UVERBS(DEALLOC_PD) |
  252. OCRDMA_UVERBS(REG_MR) |
  253. OCRDMA_UVERBS(DEREG_MR) |
  254. OCRDMA_UVERBS(CREATE_COMP_CHANNEL) |
  255. OCRDMA_UVERBS(CREATE_CQ) |
  256. OCRDMA_UVERBS(RESIZE_CQ) |
  257. OCRDMA_UVERBS(DESTROY_CQ) |
  258. OCRDMA_UVERBS(REQ_NOTIFY_CQ) |
  259. OCRDMA_UVERBS(CREATE_QP) |
  260. OCRDMA_UVERBS(MODIFY_QP) |
  261. OCRDMA_UVERBS(QUERY_QP) |
  262. OCRDMA_UVERBS(DESTROY_QP) |
  263. OCRDMA_UVERBS(POLL_CQ) |
  264. OCRDMA_UVERBS(POST_SEND) |
  265. OCRDMA_UVERBS(POST_RECV);
  266. dev->ibdev.uverbs_cmd_mask |=
  267. OCRDMA_UVERBS(CREATE_AH) |
  268. OCRDMA_UVERBS(MODIFY_AH) |
  269. OCRDMA_UVERBS(QUERY_AH) |
  270. OCRDMA_UVERBS(DESTROY_AH);
  271. dev->ibdev.node_type = RDMA_NODE_IB_CA;
  272. dev->ibdev.phys_port_cnt = 1;
  273. dev->ibdev.num_comp_vectors = 1;
  274. /* mandatory verbs. */
  275. dev->ibdev.query_device = ocrdma_query_device;
  276. dev->ibdev.query_port = ocrdma_query_port;
  277. dev->ibdev.modify_port = ocrdma_modify_port;
  278. dev->ibdev.query_gid = ocrdma_query_gid;
  279. dev->ibdev.get_link_layer = ocrdma_link_layer;
  280. dev->ibdev.alloc_pd = ocrdma_alloc_pd;
  281. dev->ibdev.dealloc_pd = ocrdma_dealloc_pd;
  282. dev->ibdev.create_cq = ocrdma_create_cq;
  283. dev->ibdev.destroy_cq = ocrdma_destroy_cq;
  284. dev->ibdev.resize_cq = ocrdma_resize_cq;
  285. dev->ibdev.create_qp = ocrdma_create_qp;
  286. dev->ibdev.modify_qp = ocrdma_modify_qp;
  287. dev->ibdev.query_qp = ocrdma_query_qp;
  288. dev->ibdev.destroy_qp = ocrdma_destroy_qp;
  289. dev->ibdev.query_pkey = ocrdma_query_pkey;
  290. dev->ibdev.create_ah = ocrdma_create_ah;
  291. dev->ibdev.destroy_ah = ocrdma_destroy_ah;
  292. dev->ibdev.query_ah = ocrdma_query_ah;
  293. dev->ibdev.modify_ah = ocrdma_modify_ah;
  294. dev->ibdev.poll_cq = ocrdma_poll_cq;
  295. dev->ibdev.post_send = ocrdma_post_send;
  296. dev->ibdev.post_recv = ocrdma_post_recv;
  297. dev->ibdev.req_notify_cq = ocrdma_arm_cq;
  298. dev->ibdev.get_dma_mr = ocrdma_get_dma_mr;
  299. dev->ibdev.dereg_mr = ocrdma_dereg_mr;
  300. dev->ibdev.reg_user_mr = ocrdma_reg_user_mr;
  301. /* mandatory to support user space verbs consumer. */
  302. dev->ibdev.alloc_ucontext = ocrdma_alloc_ucontext;
  303. dev->ibdev.dealloc_ucontext = ocrdma_dealloc_ucontext;
  304. dev->ibdev.mmap = ocrdma_mmap;
  305. dev->ibdev.dma_device = &dev->nic_info.pdev->dev;
  306. dev->ibdev.process_mad = ocrdma_process_mad;
  307. if (dev->nic_info.dev_family == OCRDMA_GEN2_FAMILY) {
  308. dev->ibdev.uverbs_cmd_mask |=
  309. OCRDMA_UVERBS(CREATE_SRQ) |
  310. OCRDMA_UVERBS(MODIFY_SRQ) |
  311. OCRDMA_UVERBS(QUERY_SRQ) |
  312. OCRDMA_UVERBS(DESTROY_SRQ) |
  313. OCRDMA_UVERBS(POST_SRQ_RECV);
  314. dev->ibdev.create_srq = ocrdma_create_srq;
  315. dev->ibdev.modify_srq = ocrdma_modify_srq;
  316. dev->ibdev.query_srq = ocrdma_query_srq;
  317. dev->ibdev.destroy_srq = ocrdma_destroy_srq;
  318. dev->ibdev.post_srq_recv = ocrdma_post_srq_recv;
  319. }
  320. return ib_register_device(&dev->ibdev, NULL);
  321. }
  322. static int ocrdma_alloc_resources(struct ocrdma_dev *dev)
  323. {
  324. mutex_init(&dev->dev_lock);
  325. dev->sgid_tbl = kzalloc(sizeof(union ib_gid) *
  326. OCRDMA_MAX_SGID, GFP_KERNEL);
  327. if (!dev->sgid_tbl)
  328. goto alloc_err;
  329. spin_lock_init(&dev->sgid_lock);
  330. dev->cq_tbl = kzalloc(sizeof(struct ocrdma_cq *) *
  331. OCRDMA_MAX_CQ, GFP_KERNEL);
  332. if (!dev->cq_tbl)
  333. goto alloc_err;
  334. if (dev->attr.max_qp) {
  335. dev->qp_tbl = kzalloc(sizeof(struct ocrdma_qp *) *
  336. OCRDMA_MAX_QP, GFP_KERNEL);
  337. if (!dev->qp_tbl)
  338. goto alloc_err;
  339. }
  340. spin_lock_init(&dev->av_tbl.lock);
  341. spin_lock_init(&dev->flush_q_lock);
  342. return 0;
  343. alloc_err:
  344. ocrdma_err("%s(%d) error.\n", __func__, dev->id);
  345. return -ENOMEM;
  346. }
  347. static void ocrdma_free_resources(struct ocrdma_dev *dev)
  348. {
  349. kfree(dev->qp_tbl);
  350. kfree(dev->cq_tbl);
  351. kfree(dev->sgid_tbl);
  352. }
  353. static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info)
  354. {
  355. int status = 0;
  356. struct ocrdma_dev *dev;
  357. dev = (struct ocrdma_dev *)ib_alloc_device(sizeof(struct ocrdma_dev));
  358. if (!dev) {
  359. ocrdma_err("Unable to allocate ib device\n");
  360. return NULL;
  361. }
  362. dev->mbx_cmd = kzalloc(sizeof(struct ocrdma_mqe_emb_cmd), GFP_KERNEL);
  363. if (!dev->mbx_cmd)
  364. goto idr_err;
  365. memcpy(&dev->nic_info, dev_info, sizeof(*dev_info));
  366. dev->id = ocrdma_get_instance();
  367. if (dev->id < 0)
  368. goto idr_err;
  369. status = ocrdma_init_hw(dev);
  370. if (status)
  371. goto init_err;
  372. status = ocrdma_alloc_resources(dev);
  373. if (status)
  374. goto alloc_err;
  375. status = ocrdma_build_sgid_tbl(dev);
  376. if (status)
  377. goto alloc_err;
  378. status = ocrdma_register_device(dev);
  379. if (status)
  380. goto alloc_err;
  381. spin_lock(&ocrdma_devlist_lock);
  382. list_add_tail_rcu(&dev->entry, &ocrdma_dev_list);
  383. spin_unlock(&ocrdma_devlist_lock);
  384. return dev;
  385. alloc_err:
  386. ocrdma_free_resources(dev);
  387. ocrdma_cleanup_hw(dev);
  388. init_err:
  389. idr_remove(&ocrdma_dev_id, dev->id);
  390. idr_err:
  391. kfree(dev->mbx_cmd);
  392. ib_dealloc_device(&dev->ibdev);
  393. ocrdma_err("%s() leaving. ret=%d\n", __func__, status);
  394. return NULL;
  395. }
  396. static void ocrdma_remove_free(struct rcu_head *rcu)
  397. {
  398. struct ocrdma_dev *dev = container_of(rcu, struct ocrdma_dev, rcu);
  399. ocrdma_free_resources(dev);
  400. ocrdma_cleanup_hw(dev);
  401. idr_remove(&ocrdma_dev_id, dev->id);
  402. kfree(dev->mbx_cmd);
  403. ib_dealloc_device(&dev->ibdev);
  404. }
  405. static void ocrdma_remove(struct ocrdma_dev *dev)
  406. {
  407. /* first unregister with stack to stop all the active traffic
  408. * of the registered clients.
  409. */
  410. ib_unregister_device(&dev->ibdev);
  411. spin_lock(&ocrdma_devlist_lock);
  412. list_del_rcu(&dev->entry);
  413. spin_unlock(&ocrdma_devlist_lock);
  414. call_rcu(&dev->rcu, ocrdma_remove_free);
  415. }
  416. static int ocrdma_open(struct ocrdma_dev *dev)
  417. {
  418. struct ib_event port_event;
  419. port_event.event = IB_EVENT_PORT_ACTIVE;
  420. port_event.element.port_num = 1;
  421. port_event.device = &dev->ibdev;
  422. ib_dispatch_event(&port_event);
  423. return 0;
  424. }
  425. static int ocrdma_close(struct ocrdma_dev *dev)
  426. {
  427. int i;
  428. struct ocrdma_qp *qp, **cur_qp;
  429. struct ib_event err_event;
  430. struct ib_qp_attr attrs;
  431. int attr_mask = IB_QP_STATE;
  432. attrs.qp_state = IB_QPS_ERR;
  433. mutex_lock(&dev->dev_lock);
  434. if (dev->qp_tbl) {
  435. cur_qp = dev->qp_tbl;
  436. for (i = 0; i < OCRDMA_MAX_QP; i++) {
  437. qp = cur_qp[i];
  438. if (qp) {
  439. /* change the QP state to ERROR */
  440. _ocrdma_modify_qp(&qp->ibqp, &attrs, attr_mask);
  441. err_event.event = IB_EVENT_QP_FATAL;
  442. err_event.element.qp = &qp->ibqp;
  443. err_event.device = &dev->ibdev;
  444. ib_dispatch_event(&err_event);
  445. }
  446. }
  447. }
  448. mutex_unlock(&dev->dev_lock);
  449. err_event.event = IB_EVENT_PORT_ERR;
  450. err_event.element.port_num = 1;
  451. err_event.device = &dev->ibdev;
  452. ib_dispatch_event(&err_event);
  453. return 0;
  454. }
  455. /* event handling via NIC driver ensures that all the NIC specific
  456. * initialization done before RoCE driver notifies
  457. * event to stack.
  458. */
  459. static void ocrdma_event_handler(struct ocrdma_dev *dev, u32 event)
  460. {
  461. switch (event) {
  462. case BE_DEV_UP:
  463. ocrdma_open(dev);
  464. break;
  465. case BE_DEV_DOWN:
  466. ocrdma_close(dev);
  467. break;
  468. };
  469. }
  470. static struct ocrdma_driver ocrdma_drv = {
  471. .name = "ocrdma_driver",
  472. .add = ocrdma_add,
  473. .remove = ocrdma_remove,
  474. .state_change_handler = ocrdma_event_handler,
  475. };
  476. static void ocrdma_unregister_inet6addr_notifier(void)
  477. {
  478. #if IS_ENABLED(CONFIG_IPV6)
  479. unregister_inet6addr_notifier(&ocrdma_inet6addr_notifier);
  480. #endif
  481. }
  482. static int __init ocrdma_init_module(void)
  483. {
  484. int status;
  485. #if IS_ENABLED(CONFIG_IPV6)
  486. status = register_inet6addr_notifier(&ocrdma_inet6addr_notifier);
  487. if (status)
  488. return status;
  489. #endif
  490. status = be_roce_register_driver(&ocrdma_drv);
  491. if (status)
  492. ocrdma_unregister_inet6addr_notifier();
  493. return status;
  494. }
  495. static void __exit ocrdma_exit_module(void)
  496. {
  497. be_roce_unregister_driver(&ocrdma_drv);
  498. ocrdma_unregister_inet6addr_notifier();
  499. }
  500. module_init(ocrdma_init_module);
  501. module_exit(ocrdma_exit_module);