/drivers/infiniband/ulp/ipoib/ipoib_ib.c

https://bitbucket.org/evzijst/gittest · C · 668 lines · 465 code · 129 blank · 74 comment · 61 complexity · 38e0ac9242c68feeab0e75a9fb9b98e4 MD5 · raw file

  1. /*
  2. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. *
  32. * $Id: ipoib_ib.c 1386 2004-12-27 16:23:17Z roland $
  33. */
  34. #include <linux/delay.h>
  35. #include <linux/dma-mapping.h>
  36. #include <ib_cache.h>
  37. #include "ipoib.h"
  38. #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA
  39. static int data_debug_level;
  40. module_param(data_debug_level, int, 0644);
  41. MODULE_PARM_DESC(data_debug_level,
  42. "Enable data path debug tracing if > 0");
  43. #endif
  44. #define IPOIB_OP_RECV (1ul << 31)
  45. static DECLARE_MUTEX(pkey_sem);
  46. struct ipoib_ah *ipoib_create_ah(struct net_device *dev,
  47. struct ib_pd *pd, struct ib_ah_attr *attr)
  48. {
  49. struct ipoib_ah *ah;
  50. ah = kmalloc(sizeof *ah, GFP_KERNEL);
  51. if (!ah)
  52. return NULL;
  53. ah->dev = dev;
  54. ah->last_send = 0;
  55. kref_init(&ah->ref);
  56. ah->ah = ib_create_ah(pd, attr);
  57. if (IS_ERR(ah->ah)) {
  58. kfree(ah);
  59. ah = NULL;
  60. } else
  61. ipoib_dbg(netdev_priv(dev), "Created ah %p\n", ah->ah);
  62. return ah;
  63. }
  64. void ipoib_free_ah(struct kref *kref)
  65. {
  66. struct ipoib_ah *ah = container_of(kref, struct ipoib_ah, ref);
  67. struct ipoib_dev_priv *priv = netdev_priv(ah->dev);
  68. unsigned long flags;
  69. if (ah->last_send <= priv->tx_tail) {
  70. ipoib_dbg(priv, "Freeing ah %p\n", ah->ah);
  71. ib_destroy_ah(ah->ah);
  72. kfree(ah);
  73. } else {
  74. spin_lock_irqsave(&priv->lock, flags);
  75. list_add_tail(&ah->list, &priv->dead_ahs);
  76. spin_unlock_irqrestore(&priv->lock, flags);
  77. }
  78. }
  79. static inline int ipoib_ib_receive(struct ipoib_dev_priv *priv,
  80. unsigned int wr_id,
  81. dma_addr_t addr)
  82. {
  83. struct ib_sge list = {
  84. .addr = addr,
  85. .length = IPOIB_BUF_SIZE,
  86. .lkey = priv->mr->lkey,
  87. };
  88. struct ib_recv_wr param = {
  89. .wr_id = wr_id | IPOIB_OP_RECV,
  90. .sg_list = &list,
  91. .num_sge = 1,
  92. };
  93. struct ib_recv_wr *bad_wr;
  94. return ib_post_recv(priv->qp, &param, &bad_wr);
  95. }
  96. static int ipoib_ib_post_receive(struct net_device *dev, int id)
  97. {
  98. struct ipoib_dev_priv *priv = netdev_priv(dev);
  99. struct sk_buff *skb;
  100. dma_addr_t addr;
  101. int ret;
  102. skb = dev_alloc_skb(IPOIB_BUF_SIZE + 4);
  103. if (!skb) {
  104. ipoib_warn(priv, "failed to allocate receive buffer\n");
  105. priv->rx_ring[id].skb = NULL;
  106. return -ENOMEM;
  107. }
  108. skb_reserve(skb, 4); /* 16 byte align IP header */
  109. priv->rx_ring[id].skb = skb;
  110. addr = dma_map_single(priv->ca->dma_device,
  111. skb->data, IPOIB_BUF_SIZE,
  112. DMA_FROM_DEVICE);
  113. pci_unmap_addr_set(&priv->rx_ring[id], mapping, addr);
  114. ret = ipoib_ib_receive(priv, id, addr);
  115. if (ret) {
  116. ipoib_warn(priv, "ipoib_ib_receive failed for buf %d (%d)\n",
  117. id, ret);
  118. dma_unmap_single(priv->ca->dma_device, addr,
  119. IPOIB_BUF_SIZE, DMA_FROM_DEVICE);
  120. dev_kfree_skb_any(skb);
  121. priv->rx_ring[id].skb = NULL;
  122. }
  123. return ret;
  124. }
  125. static int ipoib_ib_post_receives(struct net_device *dev)
  126. {
  127. struct ipoib_dev_priv *priv = netdev_priv(dev);
  128. int i;
  129. for (i = 0; i < IPOIB_RX_RING_SIZE; ++i) {
  130. if (ipoib_ib_post_receive(dev, i)) {
  131. ipoib_warn(priv, "ipoib_ib_post_receive failed for buf %d\n", i);
  132. return -EIO;
  133. }
  134. }
  135. return 0;
  136. }
  137. static void ipoib_ib_handle_wc(struct net_device *dev,
  138. struct ib_wc *wc)
  139. {
  140. struct ipoib_dev_priv *priv = netdev_priv(dev);
  141. unsigned int wr_id = wc->wr_id;
  142. ipoib_dbg_data(priv, "called: id %d, op %d, status: %d\n",
  143. wr_id, wc->opcode, wc->status);
  144. if (wr_id & IPOIB_OP_RECV) {
  145. wr_id &= ~IPOIB_OP_RECV;
  146. if (wr_id < IPOIB_RX_RING_SIZE) {
  147. struct sk_buff *skb = priv->rx_ring[wr_id].skb;
  148. priv->rx_ring[wr_id].skb = NULL;
  149. dma_unmap_single(priv->ca->dma_device,
  150. pci_unmap_addr(&priv->rx_ring[wr_id],
  151. mapping),
  152. IPOIB_BUF_SIZE,
  153. DMA_FROM_DEVICE);
  154. if (wc->status != IB_WC_SUCCESS) {
  155. if (wc->status != IB_WC_WR_FLUSH_ERR)
  156. ipoib_warn(priv, "failed recv event "
  157. "(status=%d, wrid=%d vend_err %x)\n",
  158. wc->status, wr_id, wc->vendor_err);
  159. dev_kfree_skb_any(skb);
  160. return;
  161. }
  162. ipoib_dbg_data(priv, "received %d bytes, SLID 0x%04x\n",
  163. wc->byte_len, wc->slid);
  164. skb_put(skb, wc->byte_len);
  165. skb_pull(skb, IB_GRH_BYTES);
  166. if (wc->slid != priv->local_lid ||
  167. wc->src_qp != priv->qp->qp_num) {
  168. skb->protocol = ((struct ipoib_header *) skb->data)->proto;
  169. skb_pull(skb, IPOIB_ENCAP_LEN);
  170. dev->last_rx = jiffies;
  171. ++priv->stats.rx_packets;
  172. priv->stats.rx_bytes += skb->len;
  173. skb->dev = dev;
  174. /* XXX get correct PACKET_ type here */
  175. skb->pkt_type = PACKET_HOST;
  176. netif_rx_ni(skb);
  177. } else {
  178. ipoib_dbg_data(priv, "dropping loopback packet\n");
  179. dev_kfree_skb_any(skb);
  180. }
  181. /* repost receive */
  182. if (ipoib_ib_post_receive(dev, wr_id))
  183. ipoib_warn(priv, "ipoib_ib_post_receive failed "
  184. "for buf %d\n", wr_id);
  185. } else
  186. ipoib_warn(priv, "completion event with wrid %d\n",
  187. wr_id);
  188. } else {
  189. struct ipoib_buf *tx_req;
  190. unsigned long flags;
  191. if (wr_id >= IPOIB_TX_RING_SIZE) {
  192. ipoib_warn(priv, "completion event with wrid %d (> %d)\n",
  193. wr_id, IPOIB_TX_RING_SIZE);
  194. return;
  195. }
  196. ipoib_dbg_data(priv, "send complete, wrid %d\n", wr_id);
  197. tx_req = &priv->tx_ring[wr_id];
  198. dma_unmap_single(priv->ca->dma_device,
  199. pci_unmap_addr(tx_req, mapping),
  200. tx_req->skb->len,
  201. DMA_TO_DEVICE);
  202. ++priv->stats.tx_packets;
  203. priv->stats.tx_bytes += tx_req->skb->len;
  204. dev_kfree_skb_any(tx_req->skb);
  205. spin_lock_irqsave(&priv->tx_lock, flags);
  206. ++priv->tx_tail;
  207. if (netif_queue_stopped(dev) &&
  208. priv->tx_head - priv->tx_tail <= IPOIB_TX_RING_SIZE / 2)
  209. netif_wake_queue(dev);
  210. spin_unlock_irqrestore(&priv->tx_lock, flags);
  211. if (wc->status != IB_WC_SUCCESS &&
  212. wc->status != IB_WC_WR_FLUSH_ERR)
  213. ipoib_warn(priv, "failed send event "
  214. "(status=%d, wrid=%d vend_err %x)\n",
  215. wc->status, wr_id, wc->vendor_err);
  216. }
  217. }
  218. void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr)
  219. {
  220. struct net_device *dev = (struct net_device *) dev_ptr;
  221. struct ipoib_dev_priv *priv = netdev_priv(dev);
  222. int n, i;
  223. ib_req_notify_cq(cq, IB_CQ_NEXT_COMP);
  224. do {
  225. n = ib_poll_cq(cq, IPOIB_NUM_WC, priv->ibwc);
  226. for (i = 0; i < n; ++i)
  227. ipoib_ib_handle_wc(dev, priv->ibwc + i);
  228. } while (n == IPOIB_NUM_WC);
  229. }
  230. static inline int post_send(struct ipoib_dev_priv *priv,
  231. unsigned int wr_id,
  232. struct ib_ah *address, u32 qpn,
  233. dma_addr_t addr, int len)
  234. {
  235. struct ib_send_wr *bad_wr;
  236. priv->tx_sge.addr = addr;
  237. priv->tx_sge.length = len;
  238. priv->tx_wr.wr_id = wr_id;
  239. priv->tx_wr.wr.ud.remote_qpn = qpn;
  240. priv->tx_wr.wr.ud.ah = address;
  241. return ib_post_send(priv->qp, &priv->tx_wr, &bad_wr);
  242. }
  243. void ipoib_send(struct net_device *dev, struct sk_buff *skb,
  244. struct ipoib_ah *address, u32 qpn)
  245. {
  246. struct ipoib_dev_priv *priv = netdev_priv(dev);
  247. struct ipoib_buf *tx_req;
  248. dma_addr_t addr;
  249. if (skb->len > dev->mtu + INFINIBAND_ALEN) {
  250. ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n",
  251. skb->len, dev->mtu + INFINIBAND_ALEN);
  252. ++priv->stats.tx_dropped;
  253. ++priv->stats.tx_errors;
  254. dev_kfree_skb_any(skb);
  255. return;
  256. }
  257. ipoib_dbg_data(priv, "sending packet, length=%d address=%p qpn=0x%06x\n",
  258. skb->len, address, qpn);
  259. /*
  260. * We put the skb into the tx_ring _before_ we call post_send()
  261. * because it's entirely possible that the completion handler will
  262. * run before we execute anything after the post_send(). That
  263. * means we have to make sure everything is properly recorded and
  264. * our state is consistent before we call post_send().
  265. */
  266. tx_req = &priv->tx_ring[priv->tx_head & (IPOIB_TX_RING_SIZE - 1)];
  267. tx_req->skb = skb;
  268. addr = dma_map_single(priv->ca->dma_device, skb->data, skb->len,
  269. DMA_TO_DEVICE);
  270. pci_unmap_addr_set(tx_req, mapping, addr);
  271. if (unlikely(post_send(priv, priv->tx_head & (IPOIB_TX_RING_SIZE - 1),
  272. address->ah, qpn, addr, skb->len))) {
  273. ipoib_warn(priv, "post_send failed\n");
  274. ++priv->stats.tx_errors;
  275. dma_unmap_single(priv->ca->dma_device, addr, skb->len,
  276. DMA_TO_DEVICE);
  277. dev_kfree_skb_any(skb);
  278. } else {
  279. dev->trans_start = jiffies;
  280. address->last_send = priv->tx_head;
  281. ++priv->tx_head;
  282. if (priv->tx_head - priv->tx_tail == IPOIB_TX_RING_SIZE) {
  283. ipoib_dbg(priv, "TX ring full, stopping kernel net queue\n");
  284. netif_stop_queue(dev);
  285. }
  286. }
  287. }
  288. static void __ipoib_reap_ah(struct net_device *dev)
  289. {
  290. struct ipoib_dev_priv *priv = netdev_priv(dev);
  291. struct ipoib_ah *ah, *tah;
  292. LIST_HEAD(remove_list);
  293. spin_lock_irq(&priv->lock);
  294. list_for_each_entry_safe(ah, tah, &priv->dead_ahs, list)
  295. if (ah->last_send <= priv->tx_tail) {
  296. list_del(&ah->list);
  297. list_add_tail(&ah->list, &remove_list);
  298. }
  299. spin_unlock_irq(&priv->lock);
  300. list_for_each_entry_safe(ah, tah, &remove_list, list) {
  301. ipoib_dbg(priv, "Reaping ah %p\n", ah->ah);
  302. ib_destroy_ah(ah->ah);
  303. kfree(ah);
  304. }
  305. }
  306. void ipoib_reap_ah(void *dev_ptr)
  307. {
  308. struct net_device *dev = dev_ptr;
  309. struct ipoib_dev_priv *priv = netdev_priv(dev);
  310. __ipoib_reap_ah(dev);
  311. if (!test_bit(IPOIB_STOP_REAPER, &priv->flags))
  312. queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, HZ);
  313. }
  314. int ipoib_ib_dev_open(struct net_device *dev)
  315. {
  316. struct ipoib_dev_priv *priv = netdev_priv(dev);
  317. int ret;
  318. ret = ipoib_qp_create(dev);
  319. if (ret) {
  320. ipoib_warn(priv, "ipoib_qp_create returned %d\n", ret);
  321. return -1;
  322. }
  323. ret = ipoib_ib_post_receives(dev);
  324. if (ret) {
  325. ipoib_warn(priv, "ipoib_ib_post_receives returned %d\n", ret);
  326. return -1;
  327. }
  328. clear_bit(IPOIB_STOP_REAPER, &priv->flags);
  329. queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, HZ);
  330. return 0;
  331. }
  332. int ipoib_ib_dev_up(struct net_device *dev)
  333. {
  334. struct ipoib_dev_priv *priv = netdev_priv(dev);
  335. set_bit(IPOIB_FLAG_OPER_UP, &priv->flags);
  336. return ipoib_mcast_start_thread(dev);
  337. }
  338. int ipoib_ib_dev_down(struct net_device *dev)
  339. {
  340. struct ipoib_dev_priv *priv = netdev_priv(dev);
  341. ipoib_dbg(priv, "downing ib_dev\n");
  342. clear_bit(IPOIB_FLAG_OPER_UP, &priv->flags);
  343. netif_carrier_off(dev);
  344. /* Shutdown the P_Key thread if still active */
  345. if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) {
  346. down(&pkey_sem);
  347. set_bit(IPOIB_PKEY_STOP, &priv->flags);
  348. cancel_delayed_work(&priv->pkey_task);
  349. up(&pkey_sem);
  350. flush_workqueue(ipoib_workqueue);
  351. }
  352. ipoib_mcast_stop_thread(dev);
  353. /*
  354. * Flush the multicast groups first so we stop any multicast joins. The
  355. * completion thread may have already died and we may deadlock waiting
  356. * for the completion thread to finish some multicast joins.
  357. */
  358. ipoib_mcast_dev_flush(dev);
  359. /* Delete broadcast and local addresses since they will be recreated */
  360. ipoib_mcast_dev_down(dev);
  361. ipoib_flush_paths(dev);
  362. return 0;
  363. }
  364. static int recvs_pending(struct net_device *dev)
  365. {
  366. struct ipoib_dev_priv *priv = netdev_priv(dev);
  367. int pending = 0;
  368. int i;
  369. for (i = 0; i < IPOIB_RX_RING_SIZE; ++i)
  370. if (priv->rx_ring[i].skb)
  371. ++pending;
  372. return pending;
  373. }
  374. int ipoib_ib_dev_stop(struct net_device *dev)
  375. {
  376. struct ipoib_dev_priv *priv = netdev_priv(dev);
  377. struct ib_qp_attr qp_attr;
  378. int attr_mask;
  379. unsigned long begin;
  380. struct ipoib_buf *tx_req;
  381. int i;
  382. /* Kill the existing QP and allocate a new one */
  383. qp_attr.qp_state = IB_QPS_ERR;
  384. attr_mask = IB_QP_STATE;
  385. if (ib_modify_qp(priv->qp, &qp_attr, attr_mask))
  386. ipoib_warn(priv, "Failed to modify QP to ERROR state\n");
  387. /* Wait for all sends and receives to complete */
  388. begin = jiffies;
  389. while (priv->tx_head != priv->tx_tail || recvs_pending(dev)) {
  390. if (time_after(jiffies, begin + 5 * HZ)) {
  391. ipoib_warn(priv, "timing out; %d sends %d receives not completed\n",
  392. priv->tx_head - priv->tx_tail, recvs_pending(dev));
  393. /*
  394. * assume the HW is wedged and just free up
  395. * all our pending work requests.
  396. */
  397. while (priv->tx_tail < priv->tx_head) {
  398. tx_req = &priv->tx_ring[priv->tx_tail &
  399. (IPOIB_TX_RING_SIZE - 1)];
  400. dma_unmap_single(priv->ca->dma_device,
  401. pci_unmap_addr(tx_req, mapping),
  402. tx_req->skb->len,
  403. DMA_TO_DEVICE);
  404. dev_kfree_skb_any(tx_req->skb);
  405. ++priv->tx_tail;
  406. }
  407. for (i = 0; i < IPOIB_RX_RING_SIZE; ++i)
  408. if (priv->rx_ring[i].skb) {
  409. dma_unmap_single(priv->ca->dma_device,
  410. pci_unmap_addr(&priv->rx_ring[i],
  411. mapping),
  412. IPOIB_BUF_SIZE,
  413. DMA_FROM_DEVICE);
  414. dev_kfree_skb_any(priv->rx_ring[i].skb);
  415. priv->rx_ring[i].skb = NULL;
  416. }
  417. goto timeout;
  418. }
  419. msleep(1);
  420. }
  421. ipoib_dbg(priv, "All sends and receives done.\n");
  422. timeout:
  423. qp_attr.qp_state = IB_QPS_RESET;
  424. attr_mask = IB_QP_STATE;
  425. if (ib_modify_qp(priv->qp, &qp_attr, attr_mask))
  426. ipoib_warn(priv, "Failed to modify QP to RESET state\n");
  427. /* Wait for all AHs to be reaped */
  428. set_bit(IPOIB_STOP_REAPER, &priv->flags);
  429. cancel_delayed_work(&priv->ah_reap_task);
  430. flush_workqueue(ipoib_workqueue);
  431. begin = jiffies;
  432. while (!list_empty(&priv->dead_ahs)) {
  433. __ipoib_reap_ah(dev);
  434. if (time_after(jiffies, begin + HZ)) {
  435. ipoib_warn(priv, "timing out; will leak address handles\n");
  436. break;
  437. }
  438. msleep(1);
  439. }
  440. return 0;
  441. }
  442. int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
  443. {
  444. struct ipoib_dev_priv *priv = netdev_priv(dev);
  445. priv->ca = ca;
  446. priv->port = port;
  447. priv->qp = NULL;
  448. if (ipoib_transport_dev_init(dev, ca)) {
  449. printk(KERN_WARNING "%s: ipoib_transport_dev_init failed\n", ca->name);
  450. return -ENODEV;
  451. }
  452. if (dev->flags & IFF_UP) {
  453. if (ipoib_ib_dev_open(dev)) {
  454. ipoib_transport_dev_cleanup(dev);
  455. return -ENODEV;
  456. }
  457. }
  458. return 0;
  459. }
  460. void ipoib_ib_dev_flush(void *_dev)
  461. {
  462. struct net_device *dev = (struct net_device *)_dev;
  463. struct ipoib_dev_priv *priv = netdev_priv(dev), *cpriv;
  464. if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
  465. return;
  466. ipoib_dbg(priv, "flushing\n");
  467. ipoib_ib_dev_down(dev);
  468. /*
  469. * The device could have been brought down between the start and when
  470. * we get here, don't bring it back up if it's not configured up
  471. */
  472. if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
  473. ipoib_ib_dev_up(dev);
  474. /* Flush any child interfaces too */
  475. list_for_each_entry(cpriv, &priv->child_intfs, list)
  476. ipoib_ib_dev_flush(&cpriv->dev);
  477. }
  478. void ipoib_ib_dev_cleanup(struct net_device *dev)
  479. {
  480. struct ipoib_dev_priv *priv = netdev_priv(dev);
  481. ipoib_dbg(priv, "cleaning up ib_dev\n");
  482. ipoib_mcast_stop_thread(dev);
  483. /* Delete the broadcast address and the local address */
  484. ipoib_mcast_dev_down(dev);
  485. ipoib_transport_dev_cleanup(dev);
  486. }
  487. /*
  488. * Delayed P_Key Assigment Interim Support
  489. *
  490. * The following is initial implementation of delayed P_Key assigment
  491. * mechanism. It is using the same approach implemented for the multicast
  492. * group join. The single goal of this implementation is to quickly address
  493. * Bug #2507. This implementation will probably be removed when the P_Key
  494. * change async notification is available.
  495. */
  496. int ipoib_open(struct net_device *dev);
  497. static void ipoib_pkey_dev_check_presence(struct net_device *dev)
  498. {
  499. struct ipoib_dev_priv *priv = netdev_priv(dev);
  500. u16 pkey_index = 0;
  501. if (ib_find_cached_pkey(priv->ca, priv->port, priv->pkey, &pkey_index))
  502. clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
  503. else
  504. set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
  505. }
  506. void ipoib_pkey_poll(void *dev_ptr)
  507. {
  508. struct net_device *dev = dev_ptr;
  509. struct ipoib_dev_priv *priv = netdev_priv(dev);
  510. ipoib_pkey_dev_check_presence(dev);
  511. if (test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags))
  512. ipoib_open(dev);
  513. else {
  514. down(&pkey_sem);
  515. if (!test_bit(IPOIB_PKEY_STOP, &priv->flags))
  516. queue_delayed_work(ipoib_workqueue,
  517. &priv->pkey_task,
  518. HZ);
  519. up(&pkey_sem);
  520. }
  521. }
  522. int ipoib_pkey_dev_delay_open(struct net_device *dev)
  523. {
  524. struct ipoib_dev_priv *priv = netdev_priv(dev);
  525. /* Look for the interface pkey value in the IB Port P_Key table and */
  526. /* set the interface pkey assigment flag */
  527. ipoib_pkey_dev_check_presence(dev);
  528. /* P_Key value not assigned yet - start polling */
  529. if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) {
  530. down(&pkey_sem);
  531. clear_bit(IPOIB_PKEY_STOP, &priv->flags);
  532. queue_delayed_work(ipoib_workqueue,
  533. &priv->pkey_task,
  534. HZ);
  535. up(&pkey_sem);
  536. return 1;
  537. }
  538. return 0;
  539. }