ipoib_main.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. /*
  2. * Copyright (c) 2004 Topspin Communications. All rights reserved.
  3. * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
  4. * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
  5. *
  6. * This software is available to you under a choice of one of two
  7. * licenses. You may choose to be licensed under the terms of the GNU
  8. * General Public License (GPL) Version 2, available from the file
  9. * COPYING in the main directory of this source tree, or the
  10. * OpenIB.org BSD license below:
  11. *
  12. * Redistribution and use in source and binary forms, with or
  13. * without modification, are permitted provided that the following
  14. * conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above
  17. * copyright notice, this list of conditions and the following
  18. * disclaimer.
  19. *
  20. * - Redistributions in binary form must reproduce the above
  21. * copyright notice, this list of conditions and the following
  22. * disclaimer in the documentation and/or other materials
  23. * provided with the distribution.
  24. *
  25. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  29. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  30. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  31. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32. * SOFTWARE.
  33. *
  34. * $Id: ipoib_main.c 1377 2004-12-23 19:57:12Z roland $
  35. */
  36. #include "ipoib.h"
  37. #include <linux/module.h>
  38. #include <linux/init.h>
  39. #include <linux/slab.h>
  40. #include <linux/kernel.h>
  41. #include <linux/if_arp.h> /* For ARPHRD_xxx */
  42. #include <linux/ip.h>
  43. #include <linux/in.h>
  44. #include <net/dst.h>
  45. MODULE_AUTHOR("Roland Dreier");
  46. MODULE_DESCRIPTION("IP-over-InfiniBand net driver");
  47. MODULE_LICENSE("Dual BSD/GPL");
  48. int ipoib_sendq_size __read_mostly = IPOIB_TX_RING_SIZE;
  49. int ipoib_recvq_size __read_mostly = IPOIB_RX_RING_SIZE;
  50. module_param_named(send_queue_size, ipoib_sendq_size, int, 0444);
  51. MODULE_PARM_DESC(send_queue_size, "Number of descriptors in send queue");
  52. module_param_named(recv_queue_size, ipoib_recvq_size, int, 0444);
  53. MODULE_PARM_DESC(recv_queue_size, "Number of descriptors in receive queue");
  54. #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
  55. int ipoib_debug_level;
  56. module_param_named(debug_level, ipoib_debug_level, int, 0644);
  57. MODULE_PARM_DESC(debug_level, "Enable debug tracing if > 0");
  58. #endif
  59. struct ipoib_path_iter {
  60. struct net_device *dev;
  61. struct ipoib_path path;
  62. };
  63. static const u8 ipv4_bcast_addr[] = {
  64. 0x00, 0xff, 0xff, 0xff,
  65. 0xff, 0x12, 0x40, 0x1b, 0x00, 0x00, 0x00, 0x00,
  66. 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
  67. };
  68. struct workqueue_struct *ipoib_workqueue;
  69. struct ib_sa_client ipoib_sa_client;
  70. static void ipoib_add_one(struct ib_device *device);
  71. static void ipoib_remove_one(struct ib_device *device);
  72. static struct ib_client ipoib_client = {
  73. .name = "ipoib",
  74. .add = ipoib_add_one,
  75. .remove = ipoib_remove_one
  76. };
  77. int ipoib_open(struct net_device *dev)
  78. {
  79. struct ipoib_dev_priv *priv = netdev_priv(dev);
  80. ipoib_dbg(priv, "bringing up interface\n");
  81. set_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags);
  82. if (ipoib_pkey_dev_delay_open(dev))
  83. return 0;
  84. if (ipoib_ib_dev_open(dev))
  85. return -EINVAL;
  86. if (ipoib_ib_dev_up(dev)) {
  87. ipoib_ib_dev_stop(dev, 1);
  88. return -EINVAL;
  89. }
  90. if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) {
  91. struct ipoib_dev_priv *cpriv;
  92. /* Bring up any child interfaces too */
  93. mutex_lock(&priv->vlan_mutex);
  94. list_for_each_entry(cpriv, &priv->child_intfs, list) {
  95. int flags;
  96. flags = cpriv->dev->flags;
  97. if (flags & IFF_UP)
  98. continue;
  99. dev_change_flags(cpriv->dev, flags | IFF_UP);
  100. }
  101. mutex_unlock(&priv->vlan_mutex);
  102. }
  103. netif_start_queue(dev);
  104. return 0;
  105. }
  106. static int ipoib_stop(struct net_device *dev)
  107. {
  108. struct ipoib_dev_priv *priv = netdev_priv(dev);
  109. ipoib_dbg(priv, "stopping interface\n");
  110. clear_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags);
  111. netif_stop_queue(dev);
  112. clear_bit(IPOIB_FLAG_NETIF_STOPPED, &priv->flags);
  113. /*
  114. * Now flush workqueue to make sure a scheduled task doesn't
  115. * bring our internal state back up.
  116. */
  117. flush_workqueue(ipoib_workqueue);
  118. ipoib_ib_dev_down(dev, 1);
  119. ipoib_ib_dev_stop(dev, 1);
  120. if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) {
  121. struct ipoib_dev_priv *cpriv;
  122. /* Bring down any child interfaces too */
  123. mutex_lock(&priv->vlan_mutex);
  124. list_for_each_entry(cpriv, &priv->child_intfs, list) {
  125. int flags;
  126. flags = cpriv->dev->flags;
  127. if (!(flags & IFF_UP))
  128. continue;
  129. dev_change_flags(cpriv->dev, flags & ~IFF_UP);
  130. }
  131. mutex_unlock(&priv->vlan_mutex);
  132. }
  133. return 0;
  134. }
  135. static int ipoib_change_mtu(struct net_device *dev, int new_mtu)
  136. {
  137. struct ipoib_dev_priv *priv = netdev_priv(dev);
  138. /* dev->mtu > 2K ==> connected mode */
  139. if (ipoib_cm_admin_enabled(dev) && new_mtu <= IPOIB_CM_MTU) {
  140. if (new_mtu > priv->mcast_mtu)
  141. ipoib_warn(priv, "mtu > %d will cause multicast packet drops.\n",
  142. priv->mcast_mtu);
  143. dev->mtu = new_mtu;
  144. return 0;
  145. }
  146. if (new_mtu > IPOIB_PACKET_SIZE - IPOIB_ENCAP_LEN) {
  147. return -EINVAL;
  148. }
  149. priv->admin_mtu = new_mtu;
  150. dev->mtu = min(priv->mcast_mtu, priv->admin_mtu);
  151. return 0;
  152. }
  153. static struct ipoib_path *__path_find(struct net_device *dev, void *gid)
  154. {
  155. struct ipoib_dev_priv *priv = netdev_priv(dev);
  156. struct rb_node *n = priv->path_tree.rb_node;
  157. struct ipoib_path *path;
  158. int ret;
  159. while (n) {
  160. path = rb_entry(n, struct ipoib_path, rb_node);
  161. ret = memcmp(gid, path->pathrec.dgid.raw,
  162. sizeof (union ib_gid));
  163. if (ret < 0)
  164. n = n->rb_left;
  165. else if (ret > 0)
  166. n = n->rb_right;
  167. else
  168. return path;
  169. }
  170. return NULL;
  171. }
  172. static int __path_add(struct net_device *dev, struct ipoib_path *path)
  173. {
  174. struct ipoib_dev_priv *priv = netdev_priv(dev);
  175. struct rb_node **n = &priv->path_tree.rb_node;
  176. struct rb_node *pn = NULL;
  177. struct ipoib_path *tpath;
  178. int ret;
  179. while (*n) {
  180. pn = *n;
  181. tpath = rb_entry(pn, struct ipoib_path, rb_node);
  182. ret = memcmp(path->pathrec.dgid.raw, tpath->pathrec.dgid.raw,
  183. sizeof (union ib_gid));
  184. if (ret < 0)
  185. n = &pn->rb_left;
  186. else if (ret > 0)
  187. n = &pn->rb_right;
  188. else
  189. return -EEXIST;
  190. }
  191. rb_link_node(&path->rb_node, pn, n);
  192. rb_insert_color(&path->rb_node, &priv->path_tree);
  193. list_add_tail(&path->list, &priv->path_list);
  194. return 0;
  195. }
  196. static void path_free(struct net_device *dev, struct ipoib_path *path)
  197. {
  198. struct ipoib_dev_priv *priv = netdev_priv(dev);
  199. struct ipoib_neigh *neigh, *tn;
  200. struct sk_buff *skb;
  201. unsigned long flags;
  202. while ((skb = __skb_dequeue(&path->queue)))
  203. dev_kfree_skb_irq(skb);
  204. spin_lock_irqsave(&priv->lock, flags);
  205. list_for_each_entry_safe(neigh, tn, &path->neigh_list, list) {
  206. /*
  207. * It's safe to call ipoib_put_ah() inside priv->lock
  208. * here, because we know that path->ah will always
  209. * hold one more reference, so ipoib_put_ah() will
  210. * never do more than decrement the ref count.
  211. */
  212. if (neigh->ah)
  213. ipoib_put_ah(neigh->ah);
  214. ipoib_neigh_free(dev, neigh);
  215. }
  216. spin_unlock_irqrestore(&priv->lock, flags);
  217. if (path->ah)
  218. ipoib_put_ah(path->ah);
  219. kfree(path);
  220. }
  221. #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
  222. struct ipoib_path_iter *ipoib_path_iter_init(struct net_device *dev)
  223. {
  224. struct ipoib_path_iter *iter;
  225. iter = kmalloc(sizeof *iter, GFP_KERNEL);
  226. if (!iter)
  227. return NULL;
  228. iter->dev = dev;
  229. memset(iter->path.pathrec.dgid.raw, 0, 16);
  230. if (ipoib_path_iter_next(iter)) {
  231. kfree(iter);
  232. return NULL;
  233. }
  234. return iter;
  235. }
  236. int ipoib_path_iter_next(struct ipoib_path_iter *iter)
  237. {
  238. struct ipoib_dev_priv *priv = netdev_priv(iter->dev);
  239. struct rb_node *n;
  240. struct ipoib_path *path;
  241. int ret = 1;
  242. spin_lock_irq(&priv->lock);
  243. n = rb_first(&priv->path_tree);
  244. while (n) {
  245. path = rb_entry(n, struct ipoib_path, rb_node);
  246. if (memcmp(iter->path.pathrec.dgid.raw, path->pathrec.dgid.raw,
  247. sizeof (union ib_gid)) < 0) {
  248. iter->path = *path;
  249. ret = 0;
  250. break;
  251. }
  252. n = rb_next(n);
  253. }
  254. spin_unlock_irq(&priv->lock);
  255. return ret;
  256. }
  257. void ipoib_path_iter_read(struct ipoib_path_iter *iter,
  258. struct ipoib_path *path)
  259. {
  260. *path = iter->path;
  261. }
  262. #endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */
  263. void ipoib_flush_paths(struct net_device *dev)
  264. {
  265. struct ipoib_dev_priv *priv = netdev_priv(dev);
  266. struct ipoib_path *path, *tp;
  267. LIST_HEAD(remove_list);
  268. spin_lock_irq(&priv->tx_lock);
  269. spin_lock(&priv->lock);
  270. list_splice(&priv->path_list, &remove_list);
  271. INIT_LIST_HEAD(&priv->path_list);
  272. list_for_each_entry(path, &remove_list, list)
  273. rb_erase(&path->rb_node, &priv->path_tree);
  274. list_for_each_entry_safe(path, tp, &remove_list, list) {
  275. if (path->query)
  276. ib_sa_cancel_query(path->query_id, path->query);
  277. spin_unlock(&priv->lock);
  278. spin_unlock_irq(&priv->tx_lock);
  279. wait_for_completion(&path->done);
  280. path_free(dev, path);
  281. spin_lock_irq(&priv->tx_lock);
  282. spin_lock(&priv->lock);
  283. }
  284. spin_unlock(&priv->lock);
  285. spin_unlock_irq(&priv->tx_lock);
  286. }
  287. static void path_rec_completion(int status,
  288. struct ib_sa_path_rec *pathrec,
  289. void *path_ptr)
  290. {
  291. struct ipoib_path *path = path_ptr;
  292. struct net_device *dev = path->dev;
  293. struct ipoib_dev_priv *priv = netdev_priv(dev);
  294. struct ipoib_ah *ah = NULL;
  295. struct ipoib_neigh *neigh, *tn;
  296. struct sk_buff_head skqueue;
  297. struct sk_buff *skb;
  298. unsigned long flags;
  299. if (!status)
  300. ipoib_dbg(priv, "PathRec LID 0x%04x for GID " IPOIB_GID_FMT "\n",
  301. be16_to_cpu(pathrec->dlid), IPOIB_GID_ARG(pathrec->dgid));
  302. else
  303. ipoib_dbg(priv, "PathRec status %d for GID " IPOIB_GID_FMT "\n",
  304. status, IPOIB_GID_ARG(path->pathrec.dgid));
  305. skb_queue_head_init(&skqueue);
  306. if (!status) {
  307. struct ib_ah_attr av;
  308. if (!ib_init_ah_from_path(priv->ca, priv->port, pathrec, &av))
  309. ah = ipoib_create_ah(dev, priv->pd, &av);
  310. }
  311. spin_lock_irqsave(&priv->lock, flags);
  312. path->ah = ah;
  313. if (ah) {
  314. path->pathrec = *pathrec;
  315. ipoib_dbg(priv, "created address handle %p for LID 0x%04x, SL %d\n",
  316. ah, be16_to_cpu(pathrec->dlid), pathrec->sl);
  317. while ((skb = __skb_dequeue(&path->queue)))
  318. __skb_queue_tail(&skqueue, skb);
  319. list_for_each_entry_safe(neigh, tn, &path->neigh_list, list) {
  320. kref_get(&path->ah->ref);
  321. neigh->ah = path->ah;
  322. memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw,
  323. sizeof(union ib_gid));
  324. if (ipoib_cm_enabled(dev, neigh->neighbour)) {
  325. if (!ipoib_cm_get(neigh))
  326. ipoib_cm_set(neigh, ipoib_cm_create_tx(dev,
  327. path,
  328. neigh));
  329. if (!ipoib_cm_get(neigh)) {
  330. list_del(&neigh->list);
  331. if (neigh->ah)
  332. ipoib_put_ah(neigh->ah);
  333. ipoib_neigh_free(dev, neigh);
  334. continue;
  335. }
  336. }
  337. while ((skb = __skb_dequeue(&neigh->queue)))
  338. __skb_queue_tail(&skqueue, skb);
  339. }
  340. }
  341. path->query = NULL;
  342. complete(&path->done);
  343. spin_unlock_irqrestore(&priv->lock, flags);
  344. while ((skb = __skb_dequeue(&skqueue))) {
  345. skb->dev = dev;
  346. if (dev_queue_xmit(skb))
  347. ipoib_warn(priv, "dev_queue_xmit failed "
  348. "to requeue packet\n");
  349. }
  350. }
  351. static struct ipoib_path *path_rec_create(struct net_device *dev, void *gid)
  352. {
  353. struct ipoib_dev_priv *priv = netdev_priv(dev);
  354. struct ipoib_path *path;
  355. path = kzalloc(sizeof *path, GFP_ATOMIC);
  356. if (!path)
  357. return NULL;
  358. path->dev = dev;
  359. skb_queue_head_init(&path->queue);
  360. INIT_LIST_HEAD(&path->neigh_list);
  361. memcpy(path->pathrec.dgid.raw, gid, sizeof (union ib_gid));
  362. path->pathrec.sgid = priv->local_gid;
  363. path->pathrec.pkey = cpu_to_be16(priv->pkey);
  364. path->pathrec.numb_path = 1;
  365. return path;
  366. }
  367. static int path_rec_start(struct net_device *dev,
  368. struct ipoib_path *path)
  369. {
  370. struct ipoib_dev_priv *priv = netdev_priv(dev);
  371. ipoib_dbg(priv, "Start path record lookup for " IPOIB_GID_FMT "\n",
  372. IPOIB_GID_ARG(path->pathrec.dgid));
  373. init_completion(&path->done);
  374. path->query_id =
  375. ib_sa_path_rec_get(&ipoib_sa_client, priv->ca, priv->port,
  376. &path->pathrec,
  377. IB_SA_PATH_REC_DGID |
  378. IB_SA_PATH_REC_SGID |
  379. IB_SA_PATH_REC_NUMB_PATH |
  380. IB_SA_PATH_REC_PKEY,
  381. 1000, GFP_ATOMIC,
  382. path_rec_completion,
  383. path, &path->query);
  384. if (path->query_id < 0) {
  385. ipoib_warn(priv, "ib_sa_path_rec_get failed\n");
  386. path->query = NULL;
  387. return path->query_id;
  388. }
  389. return 0;
  390. }
  391. static void neigh_add_path(struct sk_buff *skb, struct net_device *dev)
  392. {
  393. struct ipoib_dev_priv *priv = netdev_priv(dev);
  394. struct ipoib_path *path;
  395. struct ipoib_neigh *neigh;
  396. neigh = ipoib_neigh_alloc(skb->dst->neighbour);
  397. if (!neigh) {
  398. ++priv->stats.tx_dropped;
  399. dev_kfree_skb_any(skb);
  400. return;
  401. }
  402. /*
  403. * We can only be called from ipoib_start_xmit, so we're
  404. * inside tx_lock -- no need to save/restore flags.
  405. */
  406. spin_lock(&priv->lock);
  407. path = __path_find(dev, skb->dst->neighbour->ha + 4);
  408. if (!path) {
  409. path = path_rec_create(dev, skb->dst->neighbour->ha + 4);
  410. if (!path)
  411. goto err_path;
  412. __path_add(dev, path);
  413. }
  414. list_add_tail(&neigh->list, &path->neigh_list);
  415. if (path->ah) {
  416. kref_get(&path->ah->ref);
  417. neigh->ah = path->ah;
  418. memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw,
  419. sizeof(union ib_gid));
  420. if (ipoib_cm_enabled(dev, neigh->neighbour)) {
  421. if (!ipoib_cm_get(neigh))
  422. ipoib_cm_set(neigh, ipoib_cm_create_tx(dev, path, neigh));
  423. if (!ipoib_cm_get(neigh)) {
  424. list_del(&neigh->list);
  425. if (neigh->ah)
  426. ipoib_put_ah(neigh->ah);
  427. ipoib_neigh_free(dev, neigh);
  428. goto err_drop;
  429. }
  430. if (skb_queue_len(&neigh->queue) < IPOIB_MAX_PATH_REC_QUEUE)
  431. __skb_queue_tail(&neigh->queue, skb);
  432. else {
  433. ipoib_warn(priv, "queue length limit %d. Packet drop.\n",
  434. skb_queue_len(&neigh->queue));
  435. goto err_drop;
  436. }
  437. } else
  438. ipoib_send(dev, skb, path->ah, IPOIB_QPN(skb->dst->neighbour->ha));
  439. } else {
  440. neigh->ah = NULL;
  441. if (!path->query && path_rec_start(dev, path))
  442. goto err_list;
  443. __skb_queue_tail(&neigh->queue, skb);
  444. }
  445. spin_unlock(&priv->lock);
  446. return;
  447. err_list:
  448. list_del(&neigh->list);
  449. err_path:
  450. ipoib_neigh_free(dev, neigh);
  451. err_drop:
  452. ++priv->stats.tx_dropped;
  453. dev_kfree_skb_any(skb);
  454. spin_unlock(&priv->lock);
  455. }
  456. static void ipoib_path_lookup(struct sk_buff *skb, struct net_device *dev)
  457. {
  458. struct ipoib_dev_priv *priv = netdev_priv(skb->dev);
  459. /* Look up path record for unicasts */
  460. if (skb->dst->neighbour->ha[4] != 0xff) {
  461. neigh_add_path(skb, dev);
  462. return;
  463. }
  464. /* Add in the P_Key for multicasts */
  465. skb->dst->neighbour->ha[8] = (priv->pkey >> 8) & 0xff;
  466. skb->dst->neighbour->ha[9] = priv->pkey & 0xff;
  467. ipoib_mcast_send(dev, skb->dst->neighbour->ha + 4, skb);
  468. }
  469. static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
  470. struct ipoib_pseudoheader *phdr)
  471. {
  472. struct ipoib_dev_priv *priv = netdev_priv(dev);
  473. struct ipoib_path *path;
  474. /*
  475. * We can only be called from ipoib_start_xmit, so we're
  476. * inside tx_lock -- no need to save/restore flags.
  477. */
  478. spin_lock(&priv->lock);
  479. path = __path_find(dev, phdr->hwaddr + 4);
  480. if (!path) {
  481. path = path_rec_create(dev, phdr->hwaddr + 4);
  482. if (path) {
  483. /* put pseudoheader back on for next time */
  484. skb_push(skb, sizeof *phdr);
  485. __skb_queue_tail(&path->queue, skb);
  486. if (path_rec_start(dev, path)) {
  487. spin_unlock(&priv->lock);
  488. path_free(dev, path);
  489. return;
  490. } else
  491. __path_add(dev, path);
  492. } else {
  493. ++priv->stats.tx_dropped;
  494. dev_kfree_skb_any(skb);
  495. }
  496. spin_unlock(&priv->lock);
  497. return;
  498. }
  499. if (path->ah) {
  500. ipoib_dbg(priv, "Send unicast ARP to %04x\n",
  501. be16_to_cpu(path->pathrec.dlid));
  502. ipoib_send(dev, skb, path->ah, IPOIB_QPN(phdr->hwaddr));
  503. } else if ((path->query || !path_rec_start(dev, path)) &&
  504. skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) {
  505. /* put pseudoheader back on for next time */
  506. skb_push(skb, sizeof *phdr);
  507. __skb_queue_tail(&path->queue, skb);
  508. } else {
  509. ++priv->stats.tx_dropped;
  510. dev_kfree_skb_any(skb);
  511. }
  512. spin_unlock(&priv->lock);
  513. }
  514. static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
  515. {
  516. struct ipoib_dev_priv *priv = netdev_priv(dev);
  517. struct ipoib_neigh *neigh;
  518. unsigned long flags;
  519. if (unlikely(!spin_trylock_irqsave(&priv->tx_lock, flags)))
  520. return NETDEV_TX_LOCKED;
  521. /*
  522. * Check if our queue is stopped. Since we have the LLTX bit
  523. * set, we can't rely on netif_stop_queue() preventing our
  524. * xmit function from being called with a full queue.
  525. */
  526. if (unlikely(netif_queue_stopped(dev))) {
  527. spin_unlock_irqrestore(&priv->tx_lock, flags);
  528. return NETDEV_TX_BUSY;
  529. }
  530. if (likely(skb->dst && skb->dst->neighbour)) {
  531. if (unlikely(!*to_ipoib_neigh(skb->dst->neighbour))) {
  532. ipoib_path_lookup(skb, dev);
  533. goto out;
  534. }
  535. neigh = *to_ipoib_neigh(skb->dst->neighbour);
  536. if (ipoib_cm_get(neigh)) {
  537. if (ipoib_cm_up(neigh)) {
  538. ipoib_cm_send(dev, skb, ipoib_cm_get(neigh));
  539. goto out;
  540. }
  541. } else if (neigh->ah) {
  542. if (unlikely(memcmp(&neigh->dgid.raw,
  543. skb->dst->neighbour->ha + 4,
  544. sizeof(union ib_gid)))) {
  545. spin_lock(&priv->lock);
  546. /*
  547. * It's safe to call ipoib_put_ah() inside
  548. * priv->lock here, because we know that
  549. * path->ah will always hold one more reference,
  550. * so ipoib_put_ah() will never do more than
  551. * decrement the ref count.
  552. */
  553. ipoib_put_ah(neigh->ah);
  554. list_del(&neigh->list);
  555. ipoib_neigh_free(dev, neigh);
  556. spin_unlock(&priv->lock);
  557. ipoib_path_lookup(skb, dev);
  558. goto out;
  559. }
  560. ipoib_send(dev, skb, neigh->ah, IPOIB_QPN(skb->dst->neighbour->ha));
  561. goto out;
  562. }
  563. if (skb_queue_len(&neigh->queue) < IPOIB_MAX_PATH_REC_QUEUE) {
  564. spin_lock(&priv->lock);
  565. __skb_queue_tail(&neigh->queue, skb);
  566. spin_unlock(&priv->lock);
  567. } else {
  568. ++priv->stats.tx_dropped;
  569. dev_kfree_skb_any(skb);
  570. }
  571. } else {
  572. struct ipoib_pseudoheader *phdr =
  573. (struct ipoib_pseudoheader *) skb->data;
  574. skb_pull(skb, sizeof *phdr);
  575. if (phdr->hwaddr[4] == 0xff) {
  576. /* Add in the P_Key for multicast*/
  577. phdr->hwaddr[8] = (priv->pkey >> 8) & 0xff;
  578. phdr->hwaddr[9] = priv->pkey & 0xff;
  579. ipoib_mcast_send(dev, phdr->hwaddr + 4, skb);
  580. } else {
  581. /* unicast GID -- should be ARP or RARP reply */
  582. if ((be16_to_cpup((__be16 *) skb->data) != ETH_P_ARP) &&
  583. (be16_to_cpup((__be16 *) skb->data) != ETH_P_RARP)) {
  584. ipoib_warn(priv, "Unicast, no %s: type %04x, QPN %06x "
  585. IPOIB_GID_FMT "\n",
  586. skb->dst ? "neigh" : "dst",
  587. be16_to_cpup((__be16 *) skb->data),
  588. IPOIB_QPN(phdr->hwaddr),
  589. IPOIB_GID_RAW_ARG(phdr->hwaddr + 4));
  590. dev_kfree_skb_any(skb);
  591. ++priv->stats.tx_dropped;
  592. goto out;
  593. }
  594. unicast_arp_send(skb, dev, phdr);
  595. }
  596. }
  597. out:
  598. spin_unlock_irqrestore(&priv->tx_lock, flags);
  599. return NETDEV_TX_OK;
  600. }
  601. static struct net_device_stats *ipoib_get_stats(struct net_device *dev)
  602. {
  603. struct ipoib_dev_priv *priv = netdev_priv(dev);
  604. return &priv->stats;
  605. }
  606. static void ipoib_timeout(struct net_device *dev)
  607. {
  608. struct ipoib_dev_priv *priv = netdev_priv(dev);
  609. ipoib_warn(priv, "transmit timeout: latency %d msecs\n",
  610. jiffies_to_msecs(jiffies - dev->trans_start));
  611. ipoib_warn(priv, "queue stopped %d, tx_head %u, tx_tail %u\n",
  612. netif_queue_stopped(dev),
  613. priv->tx_head, priv->tx_tail);
  614. /* XXX reset QP, etc. */
  615. }
  616. static int ipoib_hard_header(struct sk_buff *skb,
  617. struct net_device *dev,
  618. unsigned short type,
  619. void *daddr, void *saddr, unsigned len)
  620. {
  621. struct ipoib_header *header;
  622. header = (struct ipoib_header *) skb_push(skb, sizeof *header);
  623. header->proto = htons(type);
  624. header->reserved = 0;
  625. /*
  626. * If we don't have a neighbour structure, stuff the
  627. * destination address onto the front of the skb so we can
  628. * figure out where to send the packet later.
  629. */
  630. if ((!skb->dst || !skb->dst->neighbour) && daddr) {
  631. struct ipoib_pseudoheader *phdr =
  632. (struct ipoib_pseudoheader *) skb_push(skb, sizeof *phdr);
  633. memcpy(phdr->hwaddr, daddr, INFINIBAND_ALEN);
  634. }
  635. return 0;
  636. }
  637. static void ipoib_set_mcast_list(struct net_device *dev)
  638. {
  639. struct ipoib_dev_priv *priv = netdev_priv(dev);
  640. if (!test_bit(IPOIB_FLAG_OPER_UP, &priv->flags)) {
  641. ipoib_dbg(priv, "IPOIB_FLAG_OPER_UP not set");
  642. return;
  643. }
  644. queue_work(ipoib_workqueue, &priv->restart_task);
  645. }
  646. static void ipoib_neigh_cleanup(struct neighbour *n)
  647. {
  648. struct ipoib_neigh *neigh;
  649. struct ipoib_dev_priv *priv = netdev_priv(n->dev);
  650. unsigned long flags;
  651. struct ipoib_ah *ah = NULL;
  652. ipoib_dbg(priv,
  653. "neigh_cleanup for %06x " IPOIB_GID_FMT "\n",
  654. IPOIB_QPN(n->ha),
  655. IPOIB_GID_RAW_ARG(n->ha + 4));
  656. spin_lock_irqsave(&priv->lock, flags);
  657. neigh = *to_ipoib_neigh(n);
  658. if (neigh) {
  659. if (neigh->ah)
  660. ah = neigh->ah;
  661. list_del(&neigh->list);
  662. ipoib_neigh_free(n->dev, neigh);
  663. }
  664. spin_unlock_irqrestore(&priv->lock, flags);
  665. if (ah)
  666. ipoib_put_ah(ah);
  667. }
  668. struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neighbour)
  669. {
  670. struct ipoib_neigh *neigh;
  671. neigh = kmalloc(sizeof *neigh, GFP_ATOMIC);
  672. if (!neigh)
  673. return NULL;
  674. neigh->neighbour = neighbour;
  675. *to_ipoib_neigh(neighbour) = neigh;
  676. skb_queue_head_init(&neigh->queue);
  677. ipoib_cm_set(neigh, NULL);
  678. return neigh;
  679. }
  680. void ipoib_neigh_free(struct net_device *dev, struct ipoib_neigh *neigh)
  681. {
  682. struct ipoib_dev_priv *priv = netdev_priv(dev);
  683. struct sk_buff *skb;
  684. *to_ipoib_neigh(neigh->neighbour) = NULL;
  685. while ((skb = __skb_dequeue(&neigh->queue))) {
  686. ++priv->stats.tx_dropped;
  687. dev_kfree_skb_any(skb);
  688. }
  689. if (ipoib_cm_get(neigh))
  690. ipoib_cm_destroy_tx(ipoib_cm_get(neigh));
  691. kfree(neigh);
  692. }
  693. static int ipoib_neigh_setup_dev(struct net_device *dev, struct neigh_parms *parms)
  694. {
  695. parms->neigh_cleanup = ipoib_neigh_cleanup;
  696. return 0;
  697. }
  698. int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
  699. {
  700. struct ipoib_dev_priv *priv = netdev_priv(dev);
  701. /* Allocate RX/TX "rings" to hold queued skbs */
  702. priv->rx_ring = kzalloc(ipoib_recvq_size * sizeof *priv->rx_ring,
  703. GFP_KERNEL);
  704. if (!priv->rx_ring) {
  705. printk(KERN_WARNING "%s: failed to allocate RX ring (%d entries)\n",
  706. ca->name, ipoib_recvq_size);
  707. goto out;
  708. }
  709. priv->tx_ring = kzalloc(ipoib_sendq_size * sizeof *priv->tx_ring,
  710. GFP_KERNEL);
  711. if (!priv->tx_ring) {
  712. printk(KERN_WARNING "%s: failed to allocate TX ring (%d entries)\n",
  713. ca->name, ipoib_sendq_size);
  714. goto out_rx_ring_cleanup;
  715. }
  716. /* priv->tx_head & tx_tail are already 0 */
  717. if (ipoib_ib_dev_init(dev, ca, port))
  718. goto out_tx_ring_cleanup;
  719. return 0;
  720. out_tx_ring_cleanup:
  721. kfree(priv->tx_ring);
  722. out_rx_ring_cleanup:
  723. kfree(priv->rx_ring);
  724. out:
  725. return -ENOMEM;
  726. }
  727. void ipoib_dev_cleanup(struct net_device *dev)
  728. {
  729. struct ipoib_dev_priv *priv = netdev_priv(dev), *cpriv, *tcpriv;
  730. ipoib_delete_debug_files(dev);
  731. /* Delete any child interfaces first */
  732. list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list) {
  733. unregister_netdev(cpriv->dev);
  734. ipoib_dev_cleanup(cpriv->dev);
  735. free_netdev(cpriv->dev);
  736. }
  737. ipoib_ib_dev_cleanup(dev);
  738. kfree(priv->rx_ring);
  739. kfree(priv->tx_ring);
  740. priv->rx_ring = NULL;
  741. priv->tx_ring = NULL;
  742. }
  743. static void ipoib_setup(struct net_device *dev)
  744. {
  745. struct ipoib_dev_priv *priv = netdev_priv(dev);
  746. dev->open = ipoib_open;
  747. dev->stop = ipoib_stop;
  748. dev->change_mtu = ipoib_change_mtu;
  749. dev->hard_start_xmit = ipoib_start_xmit;
  750. dev->get_stats = ipoib_get_stats;
  751. dev->tx_timeout = ipoib_timeout;
  752. dev->hard_header = ipoib_hard_header;
  753. dev->set_multicast_list = ipoib_set_mcast_list;
  754. dev->neigh_setup = ipoib_neigh_setup_dev;
  755. dev->poll = ipoib_poll;
  756. dev->weight = 100;
  757. dev->watchdog_timeo = HZ;
  758. dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
  759. /*
  760. * We add in INFINIBAND_ALEN to allow for the destination
  761. * address "pseudoheader" for skbs without neighbour struct.
  762. */
  763. dev->hard_header_len = IPOIB_ENCAP_LEN + INFINIBAND_ALEN;
  764. dev->addr_len = INFINIBAND_ALEN;
  765. dev->type = ARPHRD_INFINIBAND;
  766. dev->tx_queue_len = ipoib_sendq_size * 2;
  767. dev->features = NETIF_F_VLAN_CHALLENGED | NETIF_F_LLTX;
  768. /* MTU will be reset when mcast join happens */
  769. dev->mtu = IPOIB_PACKET_SIZE - IPOIB_ENCAP_LEN;
  770. priv->mcast_mtu = priv->admin_mtu = dev->mtu;
  771. memcpy(dev->broadcast, ipv4_bcast_addr, INFINIBAND_ALEN);
  772. netif_carrier_off(dev);
  773. SET_MODULE_OWNER(dev);
  774. priv->dev = dev;
  775. spin_lock_init(&priv->lock);
  776. spin_lock_init(&priv->tx_lock);
  777. mutex_init(&priv->mcast_mutex);
  778. mutex_init(&priv->vlan_mutex);
  779. INIT_LIST_HEAD(&priv->path_list);
  780. INIT_LIST_HEAD(&priv->child_intfs);
  781. INIT_LIST_HEAD(&priv->dead_ahs);
  782. INIT_LIST_HEAD(&priv->multicast_list);
  783. INIT_DELAYED_WORK(&priv->pkey_poll_task, ipoib_pkey_poll);
  784. INIT_WORK(&priv->pkey_event_task, ipoib_pkey_event);
  785. INIT_DELAYED_WORK(&priv->mcast_task, ipoib_mcast_join_task);
  786. INIT_WORK(&priv->flush_task, ipoib_ib_dev_flush);
  787. INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task);
  788. INIT_DELAYED_WORK(&priv->ah_reap_task, ipoib_reap_ah);
  789. }
  790. struct ipoib_dev_priv *ipoib_intf_alloc(const char *name)
  791. {
  792. struct net_device *dev;
  793. dev = alloc_netdev((int) sizeof (struct ipoib_dev_priv), name,
  794. ipoib_setup);
  795. if (!dev)
  796. return NULL;
  797. return netdev_priv(dev);
  798. }
  799. static ssize_t show_pkey(struct device *dev,
  800. struct device_attribute *attr, char *buf)
  801. {
  802. struct ipoib_dev_priv *priv = netdev_priv(to_net_dev(dev));
  803. return sprintf(buf, "0x%04x\n", priv->pkey);
  804. }
  805. static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
  806. static ssize_t create_child(struct device *dev,
  807. struct device_attribute *attr,
  808. const char *buf, size_t count)
  809. {
  810. int pkey;
  811. int ret;
  812. if (sscanf(buf, "%i", &pkey) != 1)
  813. return -EINVAL;
  814. if (pkey < 0 || pkey > 0xffff)
  815. return -EINVAL;
  816. /*
  817. * Set the full membership bit, so that we join the right
  818. * broadcast group, etc.
  819. */
  820. pkey |= 0x8000;
  821. ret = ipoib_vlan_add(to_net_dev(dev), pkey);
  822. return ret ? ret : count;
  823. }
  824. static DEVICE_ATTR(create_child, S_IWUGO, NULL, create_child);
  825. static ssize_t delete_child(struct device *dev,
  826. struct device_attribute *attr,
  827. const char *buf, size_t count)
  828. {
  829. int pkey;
  830. int ret;
  831. if (sscanf(buf, "%i", &pkey) != 1)
  832. return -EINVAL;
  833. if (pkey < 0 || pkey > 0xffff)
  834. return -EINVAL;
  835. ret = ipoib_vlan_delete(to_net_dev(dev), pkey);
  836. return ret ? ret : count;
  837. }
  838. static DEVICE_ATTR(delete_child, S_IWUGO, NULL, delete_child);
  839. int ipoib_add_pkey_attr(struct net_device *dev)
  840. {
  841. return device_create_file(&dev->dev, &dev_attr_pkey);
  842. }
  843. static struct net_device *ipoib_add_port(const char *format,
  844. struct ib_device *hca, u8 port)
  845. {
  846. struct ipoib_dev_priv *priv;
  847. int result = -ENOMEM;
  848. priv = ipoib_intf_alloc(format);
  849. if (!priv)
  850. goto alloc_mem_failed;
  851. SET_NETDEV_DEV(priv->dev, hca->dma_device);
  852. result = ib_query_pkey(hca, port, 0, &priv->pkey);
  853. if (result) {
  854. printk(KERN_WARNING "%s: ib_query_pkey port %d failed (ret = %d)\n",
  855. hca->name, port, result);
  856. goto alloc_mem_failed;
  857. }
  858. /*
  859. * Set the full membership bit, so that we join the right
  860. * broadcast group, etc.
  861. */
  862. priv->pkey |= 0x8000;
  863. priv->dev->broadcast[8] = priv->pkey >> 8;
  864. priv->dev->broadcast[9] = priv->pkey & 0xff;
  865. result = ib_query_gid(hca, port, 0, &priv->local_gid);
  866. if (result) {
  867. printk(KERN_WARNING "%s: ib_query_gid port %d failed (ret = %d)\n",
  868. hca->name, port, result);
  869. goto alloc_mem_failed;
  870. } else
  871. memcpy(priv->dev->dev_addr + 4, priv->local_gid.raw, sizeof (union ib_gid));
  872. result = ipoib_dev_init(priv->dev, hca, port);
  873. if (result < 0) {
  874. printk(KERN_WARNING "%s: failed to initialize port %d (ret = %d)\n",
  875. hca->name, port, result);
  876. goto device_init_failed;
  877. }
  878. INIT_IB_EVENT_HANDLER(&priv->event_handler,
  879. priv->ca, ipoib_event);
  880. result = ib_register_event_handler(&priv->event_handler);
  881. if (result < 0) {
  882. printk(KERN_WARNING "%s: ib_register_event_handler failed for "
  883. "port %d (ret = %d)\n",
  884. hca->name, port, result);
  885. goto event_failed;
  886. }
  887. result = register_netdev(priv->dev);
  888. if (result) {
  889. printk(KERN_WARNING "%s: couldn't register ipoib port %d; error %d\n",
  890. hca->name, port, result);
  891. goto register_failed;
  892. }
  893. ipoib_create_debug_files(priv->dev);
  894. if (ipoib_cm_add_mode_attr(priv->dev))
  895. goto sysfs_failed;
  896. if (ipoib_add_pkey_attr(priv->dev))
  897. goto sysfs_failed;
  898. if (device_create_file(&priv->dev->dev, &dev_attr_create_child))
  899. goto sysfs_failed;
  900. if (device_create_file(&priv->dev->dev, &dev_attr_delete_child))
  901. goto sysfs_failed;
  902. return priv->dev;
  903. sysfs_failed:
  904. ipoib_delete_debug_files(priv->dev);
  905. unregister_netdev(priv->dev);
  906. register_failed:
  907. ib_unregister_event_handler(&priv->event_handler);
  908. flush_scheduled_work();
  909. event_failed:
  910. ipoib_dev_cleanup(priv->dev);
  911. device_init_failed:
  912. free_netdev(priv->dev);
  913. alloc_mem_failed:
  914. return ERR_PTR(result);
  915. }
  916. static void ipoib_add_one(struct ib_device *device)
  917. {
  918. struct list_head *dev_list;
  919. struct net_device *dev;
  920. struct ipoib_dev_priv *priv;
  921. int s, e, p;
  922. if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
  923. return;
  924. dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
  925. if (!dev_list)
  926. return;
  927. INIT_LIST_HEAD(dev_list);
  928. if (device->node_type == RDMA_NODE_IB_SWITCH) {
  929. s = 0;
  930. e = 0;
  931. } else {
  932. s = 1;
  933. e = device->phys_port_cnt;
  934. }
  935. for (p = s; p <= e; ++p) {
  936. dev = ipoib_add_port("ib%d", device, p);
  937. if (!IS_ERR(dev)) {
  938. priv = netdev_priv(dev);
  939. list_add_tail(&priv->list, dev_list);
  940. }
  941. }
  942. ib_set_client_data(device, &ipoib_client, dev_list);
  943. }
  944. static void ipoib_remove_one(struct ib_device *device)
  945. {
  946. struct ipoib_dev_priv *priv, *tmp;
  947. struct list_head *dev_list;
  948. if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
  949. return;
  950. dev_list = ib_get_client_data(device, &ipoib_client);
  951. list_for_each_entry_safe(priv, tmp, dev_list, list) {
  952. ib_unregister_event_handler(&priv->event_handler);
  953. flush_scheduled_work();
  954. unregister_netdev(priv->dev);
  955. ipoib_dev_cleanup(priv->dev);
  956. free_netdev(priv->dev);
  957. }
  958. kfree(dev_list);
  959. }
  960. static int __init ipoib_init_module(void)
  961. {
  962. int ret;
  963. ipoib_recvq_size = roundup_pow_of_two(ipoib_recvq_size);
  964. ipoib_recvq_size = min(ipoib_recvq_size, IPOIB_MAX_QUEUE_SIZE);
  965. ipoib_recvq_size = max(ipoib_recvq_size, IPOIB_MIN_QUEUE_SIZE);
  966. ipoib_sendq_size = roundup_pow_of_two(ipoib_sendq_size);
  967. ipoib_sendq_size = min(ipoib_sendq_size, IPOIB_MAX_QUEUE_SIZE);
  968. ipoib_sendq_size = max(ipoib_sendq_size, IPOIB_MIN_QUEUE_SIZE);
  969. ret = ipoib_register_debugfs();
  970. if (ret)
  971. return ret;
  972. /*
  973. * We create our own workqueue mainly because we want to be
  974. * able to flush it when devices are being removed. We can't
  975. * use schedule_work()/flush_scheduled_work() because both
  976. * unregister_netdev() and linkwatch_event take the rtnl lock,
  977. * so flush_scheduled_work() can deadlock during device
  978. * removal.
  979. */
  980. ipoib_workqueue = create_singlethread_workqueue("ipoib");
  981. if (!ipoib_workqueue) {
  982. ret = -ENOMEM;
  983. goto err_fs;
  984. }
  985. ib_sa_register_client(&ipoib_sa_client);
  986. ret = ib_register_client(&ipoib_client);
  987. if (ret)
  988. goto err_sa;
  989. return 0;
  990. err_sa:
  991. ib_sa_unregister_client(&ipoib_sa_client);
  992. destroy_workqueue(ipoib_workqueue);
  993. err_fs:
  994. ipoib_unregister_debugfs();
  995. return ret;
  996. }
  997. static void __exit ipoib_cleanup_module(void)
  998. {
  999. ib_unregister_client(&ipoib_client);
  1000. ib_sa_unregister_client(&ipoib_sa_client);
  1001. ipoib_unregister_debugfs();
  1002. destroy_workqueue(ipoib_workqueue);
  1003. }
  1004. module_init(ipoib_init_module);
  1005. module_exit(ipoib_cleanup_module);