Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. |
Roland Dreier | 2a1d9b7 | 2005-08-10 23:03:10 -0700 | [diff] [blame] | 3 | * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. |
| 4 | * Copyright (c) 2005 Mellanox Technologies. All rights reserved. |
| 5 | * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * |
| 7 | * This software is available to you under a choice of one of two |
| 8 | * licenses. You may choose to be licensed under the terms of the GNU |
| 9 | * General Public License (GPL) Version 2, available from the file |
| 10 | * COPYING in the main directory of this source tree, or the |
| 11 | * OpenIB.org BSD license below: |
| 12 | * |
| 13 | * Redistribution and use in source and binary forms, with or |
| 14 | * without modification, are permitted provided that the following |
| 15 | * conditions are met: |
| 16 | * |
| 17 | * - Redistributions of source code must retain the above |
| 18 | * copyright notice, this list of conditions and the following |
| 19 | * disclaimer. |
| 20 | * |
| 21 | * - Redistributions in binary form must reproduce the above |
| 22 | * copyright notice, this list of conditions and the following |
| 23 | * disclaimer in the documentation and/or other materials |
| 24 | * provided with the distribution. |
| 25 | * |
| 26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 27 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 29 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 30 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 31 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 32 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 33 | * SOFTWARE. |
| 34 | * |
| 35 | * $Id: ipoib_ib.c 1386 2004-12-27 16:23:17Z roland $ |
| 36 | */ |
| 37 | |
| 38 | #include <linux/delay.h> |
| 39 | #include <linux/dma-mapping.h> |
| 40 | |
Roland Dreier | a4d61e8 | 2005-08-25 13:40:04 -0700 | [diff] [blame] | 41 | #include <rdma/ib_cache.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
| 43 | #include "ipoib.h" |
| 44 | |
| 45 | #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA |
| 46 | static int data_debug_level; |
| 47 | |
| 48 | module_param(data_debug_level, int, 0644); |
| 49 | MODULE_PARM_DESC(data_debug_level, |
| 50 | "Enable data path debug tracing if > 0"); |
| 51 | #endif |
| 52 | |
| 53 | #define IPOIB_OP_RECV (1ul << 31) |
| 54 | |
Ingo Molnar | 95ed644 | 2006-01-13 14:51:39 -0800 | [diff] [blame] | 55 | static DEFINE_MUTEX(pkey_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
| 57 | struct ipoib_ah *ipoib_create_ah(struct net_device *dev, |
| 58 | struct ib_pd *pd, struct ib_ah_attr *attr) |
| 59 | { |
| 60 | struct ipoib_ah *ah; |
| 61 | |
| 62 | ah = kmalloc(sizeof *ah, GFP_KERNEL); |
| 63 | if (!ah) |
| 64 | return NULL; |
| 65 | |
| 66 | ah->dev = dev; |
| 67 | ah->last_send = 0; |
| 68 | kref_init(&ah->ref); |
| 69 | |
| 70 | ah->ah = ib_create_ah(pd, attr); |
| 71 | if (IS_ERR(ah->ah)) { |
| 72 | kfree(ah); |
| 73 | ah = NULL; |
| 74 | } else |
| 75 | ipoib_dbg(netdev_priv(dev), "Created ah %p\n", ah->ah); |
| 76 | |
| 77 | return ah; |
| 78 | } |
| 79 | |
| 80 | void ipoib_free_ah(struct kref *kref) |
| 81 | { |
| 82 | struct ipoib_ah *ah = container_of(kref, struct ipoib_ah, ref); |
| 83 | struct ipoib_dev_priv *priv = netdev_priv(ah->dev); |
| 84 | |
| 85 | unsigned long flags; |
| 86 | |
Roland Dreier | 31c02e2 | 2006-06-17 20:37:34 -0700 | [diff] [blame] | 87 | spin_lock_irqsave(&priv->lock, flags); |
| 88 | list_add_tail(&ah->list, &priv->dead_ahs); |
| 89 | spin_unlock_irqrestore(&priv->lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | static int ipoib_ib_post_receive(struct net_device *dev, int id) |
| 93 | { |
| 94 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
Roland Dreier | 1993d68 | 2005-10-28 15:30:34 -0700 | [diff] [blame] | 95 | struct ib_sge list; |
| 96 | struct ib_recv_wr param; |
| 97 | struct ib_recv_wr *bad_wr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | int ret; |
| 99 | |
Roland Dreier | 1993d68 | 2005-10-28 15:30:34 -0700 | [diff] [blame] | 100 | list.addr = priv->rx_ring[id].mapping; |
| 101 | list.length = IPOIB_BUF_SIZE; |
| 102 | list.lkey = priv->mr->lkey; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | |
Roland Dreier | 1993d68 | 2005-10-28 15:30:34 -0700 | [diff] [blame] | 104 | param.next = NULL; |
| 105 | param.wr_id = id | IPOIB_OP_RECV; |
| 106 | param.sg_list = &list; |
| 107 | param.num_sge = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
Roland Dreier | 1993d68 | 2005-10-28 15:30:34 -0700 | [diff] [blame] | 109 | ret = ib_post_recv(priv->qp, ¶m, &bad_wr); |
| 110 | if (unlikely(ret)) { |
| 111 | ipoib_warn(priv, "receive failed for buf %d (%d)\n", id, ret); |
Ralph Campbell | 37ccf9d | 2006-12-12 14:30:48 -0800 | [diff] [blame] | 112 | ib_dma_unmap_single(priv->ca, priv->rx_ring[id].mapping, |
| 113 | IPOIB_BUF_SIZE, DMA_FROM_DEVICE); |
Roland Dreier | 1993d68 | 2005-10-28 15:30:34 -0700 | [diff] [blame] | 114 | dev_kfree_skb_any(priv->rx_ring[id].skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | priv->rx_ring[id].skb = NULL; |
| 116 | } |
| 117 | |
| 118 | return ret; |
| 119 | } |
| 120 | |
Roland Dreier | 1993d68 | 2005-10-28 15:30:34 -0700 | [diff] [blame] | 121 | static int ipoib_alloc_rx_skb(struct net_device *dev, int id) |
| 122 | { |
| 123 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 124 | struct sk_buff *skb; |
Ralph Campbell | 37ccf9d | 2006-12-12 14:30:48 -0800 | [diff] [blame] | 125 | u64 addr; |
Roland Dreier | 1993d68 | 2005-10-28 15:30:34 -0700 | [diff] [blame] | 126 | |
| 127 | skb = dev_alloc_skb(IPOIB_BUF_SIZE + 4); |
| 128 | if (!skb) |
| 129 | return -ENOMEM; |
| 130 | |
| 131 | /* |
| 132 | * IB will leave a 40 byte gap for a GRH and IPoIB adds a 4 byte |
| 133 | * header. So we need 4 more bytes to get to 48 and align the |
| 134 | * IP header to a multiple of 16. |
| 135 | */ |
| 136 | skb_reserve(skb, 4); |
| 137 | |
Ralph Campbell | 37ccf9d | 2006-12-12 14:30:48 -0800 | [diff] [blame] | 138 | addr = ib_dma_map_single(priv->ca, skb->data, IPOIB_BUF_SIZE, |
| 139 | DMA_FROM_DEVICE); |
| 140 | if (unlikely(ib_dma_mapping_error(priv->ca, addr))) { |
Roland Dreier | 1993d68 | 2005-10-28 15:30:34 -0700 | [diff] [blame] | 141 | dev_kfree_skb_any(skb); |
| 142 | return -EIO; |
| 143 | } |
| 144 | |
| 145 | priv->rx_ring[id].skb = skb; |
| 146 | priv->rx_ring[id].mapping = addr; |
| 147 | |
| 148 | return 0; |
| 149 | } |
| 150 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | static int ipoib_ib_post_receives(struct net_device *dev) |
| 152 | { |
| 153 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 154 | int i; |
| 155 | |
Shirley Ma | 0f48525 | 2006-04-10 09:43:58 -0700 | [diff] [blame] | 156 | for (i = 0; i < ipoib_recvq_size; ++i) { |
Roland Dreier | 1993d68 | 2005-10-28 15:30:34 -0700 | [diff] [blame] | 157 | if (ipoib_alloc_rx_skb(dev, i)) { |
| 158 | ipoib_warn(priv, "failed to allocate receive buffer %d\n", i); |
| 159 | return -ENOMEM; |
| 160 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | if (ipoib_ib_post_receive(dev, i)) { |
| 162 | ipoib_warn(priv, "ipoib_ib_post_receive failed for buf %d\n", i); |
| 163 | return -EIO; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | return 0; |
| 168 | } |
| 169 | |
Roland Dreier | 2439a6e | 2006-09-22 15:22:52 -0700 | [diff] [blame] | 170 | static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc) |
| 171 | { |
| 172 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 173 | unsigned int wr_id = wc->wr_id & ~IPOIB_OP_RECV; |
| 174 | struct sk_buff *skb; |
Ralph Campbell | 37ccf9d | 2006-12-12 14:30:48 -0800 | [diff] [blame] | 175 | u64 addr; |
Roland Dreier | 2439a6e | 2006-09-22 15:22:52 -0700 | [diff] [blame] | 176 | |
| 177 | ipoib_dbg_data(priv, "recv completion: id %d, op %d, status: %d\n", |
| 178 | wr_id, wc->opcode, wc->status); |
| 179 | |
| 180 | if (unlikely(wr_id >= ipoib_recvq_size)) { |
| 181 | ipoib_warn(priv, "recv completion event with wrid %d (> %d)\n", |
| 182 | wr_id, ipoib_recvq_size); |
| 183 | return; |
| 184 | } |
| 185 | |
| 186 | skb = priv->rx_ring[wr_id].skb; |
| 187 | addr = priv->rx_ring[wr_id].mapping; |
| 188 | |
| 189 | if (unlikely(wc->status != IB_WC_SUCCESS)) { |
| 190 | if (wc->status != IB_WC_WR_FLUSH_ERR) |
| 191 | ipoib_warn(priv, "failed recv event " |
| 192 | "(status=%d, wrid=%d vend_err %x)\n", |
| 193 | wc->status, wr_id, wc->vendor_err); |
Ralph Campbell | 37ccf9d | 2006-12-12 14:30:48 -0800 | [diff] [blame] | 194 | ib_dma_unmap_single(priv->ca, addr, |
| 195 | IPOIB_BUF_SIZE, DMA_FROM_DEVICE); |
Roland Dreier | 2439a6e | 2006-09-22 15:22:52 -0700 | [diff] [blame] | 196 | dev_kfree_skb_any(skb); |
| 197 | priv->rx_ring[wr_id].skb = NULL; |
| 198 | return; |
| 199 | } |
| 200 | |
| 201 | /* |
| 202 | * If we can't allocate a new RX buffer, dump |
| 203 | * this packet and reuse the old buffer. |
| 204 | */ |
| 205 | if (unlikely(ipoib_alloc_rx_skb(dev, wr_id))) { |
| 206 | ++priv->stats.rx_dropped; |
| 207 | goto repost; |
| 208 | } |
| 209 | |
| 210 | ipoib_dbg_data(priv, "received %d bytes, SLID 0x%04x\n", |
| 211 | wc->byte_len, wc->slid); |
| 212 | |
Ralph Campbell | 37ccf9d | 2006-12-12 14:30:48 -0800 | [diff] [blame] | 213 | ib_dma_unmap_single(priv->ca, addr, IPOIB_BUF_SIZE, DMA_FROM_DEVICE); |
Roland Dreier | 2439a6e | 2006-09-22 15:22:52 -0700 | [diff] [blame] | 214 | |
| 215 | skb_put(skb, wc->byte_len); |
| 216 | skb_pull(skb, IB_GRH_BYTES); |
| 217 | |
| 218 | if (wc->slid != priv->local_lid || |
| 219 | wc->src_qp != priv->qp->qp_num) { |
| 220 | skb->protocol = ((struct ipoib_header *) skb->data)->proto; |
| 221 | skb->mac.raw = skb->data; |
| 222 | skb_pull(skb, IPOIB_ENCAP_LEN); |
| 223 | |
| 224 | dev->last_rx = jiffies; |
| 225 | ++priv->stats.rx_packets; |
| 226 | priv->stats.rx_bytes += skb->len; |
| 227 | |
| 228 | skb->dev = dev; |
| 229 | /* XXX get correct PACKET_ type here */ |
| 230 | skb->pkt_type = PACKET_HOST; |
| 231 | netif_rx_ni(skb); |
| 232 | } else { |
| 233 | ipoib_dbg_data(priv, "dropping loopback packet\n"); |
| 234 | dev_kfree_skb_any(skb); |
| 235 | } |
| 236 | |
| 237 | repost: |
| 238 | if (unlikely(ipoib_ib_post_receive(dev, wr_id))) |
| 239 | ipoib_warn(priv, "ipoib_ib_post_receive failed " |
| 240 | "for buf %d\n", wr_id); |
| 241 | } |
| 242 | |
| 243 | static void ipoib_ib_handle_tx_wc(struct net_device *dev, struct ib_wc *wc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | { |
| 245 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 246 | unsigned int wr_id = wc->wr_id; |
Roland Dreier | 2439a6e | 2006-09-22 15:22:52 -0700 | [diff] [blame] | 247 | struct ipoib_tx_buf *tx_req; |
| 248 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | |
Roland Dreier | 2439a6e | 2006-09-22 15:22:52 -0700 | [diff] [blame] | 250 | ipoib_dbg_data(priv, "send completion: id %d, op %d, status: %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | wr_id, wc->opcode, wc->status); |
| 252 | |
Roland Dreier | 2439a6e | 2006-09-22 15:22:52 -0700 | [diff] [blame] | 253 | if (unlikely(wr_id >= ipoib_sendq_size)) { |
| 254 | ipoib_warn(priv, "send completion event with wrid %d (> %d)\n", |
| 255 | wr_id, ipoib_sendq_size); |
| 256 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | } |
Roland Dreier | 2439a6e | 2006-09-22 15:22:52 -0700 | [diff] [blame] | 258 | |
| 259 | tx_req = &priv->tx_ring[wr_id]; |
| 260 | |
Ralph Campbell | 37ccf9d | 2006-12-12 14:30:48 -0800 | [diff] [blame] | 261 | ib_dma_unmap_single(priv->ca, tx_req->mapping, |
| 262 | tx_req->skb->len, DMA_TO_DEVICE); |
Roland Dreier | 2439a6e | 2006-09-22 15:22:52 -0700 | [diff] [blame] | 263 | |
| 264 | ++priv->stats.tx_packets; |
| 265 | priv->stats.tx_bytes += tx_req->skb->len; |
| 266 | |
| 267 | dev_kfree_skb_any(tx_req->skb); |
| 268 | |
| 269 | spin_lock_irqsave(&priv->tx_lock, flags); |
| 270 | ++priv->tx_tail; |
| 271 | if (netif_queue_stopped(dev) && |
| 272 | test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags) && |
| 273 | priv->tx_head - priv->tx_tail <= ipoib_sendq_size >> 1) |
| 274 | netif_wake_queue(dev); |
| 275 | spin_unlock_irqrestore(&priv->tx_lock, flags); |
| 276 | |
| 277 | if (wc->status != IB_WC_SUCCESS && |
| 278 | wc->status != IB_WC_WR_FLUSH_ERR) |
| 279 | ipoib_warn(priv, "failed send event " |
| 280 | "(status=%d, wrid=%d vend_err %x)\n", |
| 281 | wc->status, wr_id, wc->vendor_err); |
| 282 | } |
| 283 | |
| 284 | static void ipoib_ib_handle_wc(struct net_device *dev, struct ib_wc *wc) |
| 285 | { |
| 286 | if (wc->wr_id & IPOIB_OP_RECV) |
| 287 | ipoib_ib_handle_rx_wc(dev, wc); |
| 288 | else |
| 289 | ipoib_ib_handle_tx_wc(dev, wc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr) |
| 293 | { |
| 294 | struct net_device *dev = (struct net_device *) dev_ptr; |
| 295 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 296 | int n, i; |
| 297 | |
| 298 | ib_req_notify_cq(cq, IB_CQ_NEXT_COMP); |
| 299 | do { |
| 300 | n = ib_poll_cq(cq, IPOIB_NUM_WC, priv->ibwc); |
| 301 | for (i = 0; i < n; ++i) |
| 302 | ipoib_ib_handle_wc(dev, priv->ibwc + i); |
| 303 | } while (n == IPOIB_NUM_WC); |
| 304 | } |
| 305 | |
| 306 | static inline int post_send(struct ipoib_dev_priv *priv, |
| 307 | unsigned int wr_id, |
| 308 | struct ib_ah *address, u32 qpn, |
Ralph Campbell | 37ccf9d | 2006-12-12 14:30:48 -0800 | [diff] [blame] | 309 | u64 addr, int len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | { |
| 311 | struct ib_send_wr *bad_wr; |
| 312 | |
| 313 | priv->tx_sge.addr = addr; |
| 314 | priv->tx_sge.length = len; |
| 315 | |
| 316 | priv->tx_wr.wr_id = wr_id; |
| 317 | priv->tx_wr.wr.ud.remote_qpn = qpn; |
| 318 | priv->tx_wr.wr.ud.ah = address; |
| 319 | |
| 320 | return ib_post_send(priv->qp, &priv->tx_wr, &bad_wr); |
| 321 | } |
| 322 | |
| 323 | void ipoib_send(struct net_device *dev, struct sk_buff *skb, |
| 324 | struct ipoib_ah *address, u32 qpn) |
| 325 | { |
| 326 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
Roland Dreier | 1993d68 | 2005-10-28 15:30:34 -0700 | [diff] [blame] | 327 | struct ipoib_tx_buf *tx_req; |
Ralph Campbell | 37ccf9d | 2006-12-12 14:30:48 -0800 | [diff] [blame] | 328 | u64 addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | |
Eli Cohen | a8bfca0 | 2006-09-22 15:22:58 -0700 | [diff] [blame] | 330 | if (unlikely(skb->len > dev->mtu + INFINIBAND_ALEN)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n", |
| 332 | skb->len, dev->mtu + INFINIBAND_ALEN); |
| 333 | ++priv->stats.tx_dropped; |
| 334 | ++priv->stats.tx_errors; |
| 335 | dev_kfree_skb_any(skb); |
| 336 | return; |
| 337 | } |
| 338 | |
| 339 | ipoib_dbg_data(priv, "sending packet, length=%d address=%p qpn=0x%06x\n", |
| 340 | skb->len, address, qpn); |
| 341 | |
| 342 | /* |
| 343 | * We put the skb into the tx_ring _before_ we call post_send() |
| 344 | * because it's entirely possible that the completion handler will |
| 345 | * run before we execute anything after the post_send(). That |
| 346 | * means we have to make sure everything is properly recorded and |
| 347 | * our state is consistent before we call post_send(). |
| 348 | */ |
Shirley Ma | 0f48525 | 2006-04-10 09:43:58 -0700 | [diff] [blame] | 349 | tx_req = &priv->tx_ring[priv->tx_head & (ipoib_sendq_size - 1)]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | tx_req->skb = skb; |
Ralph Campbell | 37ccf9d | 2006-12-12 14:30:48 -0800 | [diff] [blame] | 351 | addr = ib_dma_map_single(priv->ca, skb->data, skb->len, |
| 352 | DMA_TO_DEVICE); |
| 353 | if (unlikely(ib_dma_mapping_error(priv->ca, addr))) { |
Roland Dreier | 73fbe8b | 2006-10-10 12:50:38 -0700 | [diff] [blame] | 354 | ++priv->stats.tx_errors; |
| 355 | dev_kfree_skb_any(skb); |
| 356 | return; |
| 357 | } |
Ralph Campbell | 37ccf9d | 2006-12-12 14:30:48 -0800 | [diff] [blame] | 358 | tx_req->mapping = addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | |
Shirley Ma | 0f48525 | 2006-04-10 09:43:58 -0700 | [diff] [blame] | 360 | if (unlikely(post_send(priv, priv->tx_head & (ipoib_sendq_size - 1), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | address->ah, qpn, addr, skb->len))) { |
| 362 | ipoib_warn(priv, "post_send failed\n"); |
| 363 | ++priv->stats.tx_errors; |
Ralph Campbell | 37ccf9d | 2006-12-12 14:30:48 -0800 | [diff] [blame] | 364 | ib_dma_unmap_single(priv->ca, addr, skb->len, DMA_TO_DEVICE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | dev_kfree_skb_any(skb); |
| 366 | } else { |
| 367 | dev->trans_start = jiffies; |
| 368 | |
| 369 | address->last_send = priv->tx_head; |
| 370 | ++priv->tx_head; |
| 371 | |
Shirley Ma | 0f48525 | 2006-04-10 09:43:58 -0700 | [diff] [blame] | 372 | if (priv->tx_head - priv->tx_tail == ipoib_sendq_size) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | ipoib_dbg(priv, "TX ring full, stopping kernel net queue\n"); |
| 374 | netif_stop_queue(dev); |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | static void __ipoib_reap_ah(struct net_device *dev) |
| 380 | { |
| 381 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 382 | struct ipoib_ah *ah, *tah; |
| 383 | LIST_HEAD(remove_list); |
| 384 | |
Roland Dreier | 31c02e2 | 2006-06-17 20:37:34 -0700 | [diff] [blame] | 385 | spin_lock_irq(&priv->tx_lock); |
| 386 | spin_lock(&priv->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | list_for_each_entry_safe(ah, tah, &priv->dead_ahs, list) |
Roland Dreier | 2181858 | 2005-07-27 14:41:32 -0700 | [diff] [blame] | 388 | if ((int) priv->tx_tail - (int) ah->last_send >= 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | list_del(&ah->list); |
Roland Dreier | 31c02e2 | 2006-06-17 20:37:34 -0700 | [diff] [blame] | 390 | ib_destroy_ah(ah->ah); |
| 391 | kfree(ah); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | } |
Roland Dreier | 31c02e2 | 2006-06-17 20:37:34 -0700 | [diff] [blame] | 393 | spin_unlock(&priv->lock); |
| 394 | spin_unlock_irq(&priv->tx_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | } |
| 396 | |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 397 | void ipoib_reap_ah(struct work_struct *work) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | { |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 399 | struct ipoib_dev_priv *priv = |
| 400 | container_of(work, struct ipoib_dev_priv, ah_reap_task.work); |
| 401 | struct net_device *dev = priv->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | |
| 403 | __ipoib_reap_ah(dev); |
| 404 | |
| 405 | if (!test_bit(IPOIB_STOP_REAPER, &priv->flags)) |
| 406 | queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, HZ); |
| 407 | } |
| 408 | |
| 409 | int ipoib_ib_dev_open(struct net_device *dev) |
| 410 | { |
| 411 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 412 | int ret; |
| 413 | |
Roland Dreier | 5b6810e | 2005-10-11 11:08:24 -0700 | [diff] [blame] | 414 | ret = ipoib_init_qp(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | if (ret) { |
Roland Dreier | 5b6810e | 2005-10-11 11:08:24 -0700 | [diff] [blame] | 416 | ipoib_warn(priv, "ipoib_init_qp returned %d\n", ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | return -1; |
| 418 | } |
| 419 | |
| 420 | ret = ipoib_ib_post_receives(dev); |
| 421 | if (ret) { |
| 422 | ipoib_warn(priv, "ipoib_ib_post_receives returned %d\n", ret); |
Eli Cohen | 54d07e2 | 2006-03-02 11:05:19 -0800 | [diff] [blame] | 423 | ipoib_ib_dev_stop(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | return -1; |
| 425 | } |
| 426 | |
| 427 | clear_bit(IPOIB_STOP_REAPER, &priv->flags); |
| 428 | queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, HZ); |
| 429 | |
Leonid Arsh | 7a343d4 | 2006-03-23 19:52:51 +0200 | [diff] [blame] | 430 | set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags); |
| 431 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | return 0; |
| 433 | } |
| 434 | |
Leonid Arsh | 7a343d4 | 2006-03-23 19:52:51 +0200 | [diff] [blame] | 435 | static void ipoib_pkey_dev_check_presence(struct net_device *dev) |
| 436 | { |
| 437 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 438 | u16 pkey_index = 0; |
| 439 | |
| 440 | if (ib_find_cached_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) |
| 441 | clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); |
| 442 | else |
| 443 | set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); |
| 444 | } |
| 445 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | int ipoib_ib_dev_up(struct net_device *dev) |
| 447 | { |
| 448 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 449 | |
Leonid Arsh | 7a343d4 | 2006-03-23 19:52:51 +0200 | [diff] [blame] | 450 | ipoib_pkey_dev_check_presence(dev); |
| 451 | |
| 452 | if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) { |
| 453 | ipoib_dbg(priv, "PKEY is not assigned.\n"); |
| 454 | return 0; |
| 455 | } |
| 456 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | set_bit(IPOIB_FLAG_OPER_UP, &priv->flags); |
| 458 | |
| 459 | return ipoib_mcast_start_thread(dev); |
| 460 | } |
| 461 | |
Jack Morgenstein | 0b3ea08 | 2006-03-20 10:08:24 -0800 | [diff] [blame] | 462 | int ipoib_ib_dev_down(struct net_device *dev, int flush) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | { |
| 464 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 465 | |
| 466 | ipoib_dbg(priv, "downing ib_dev\n"); |
| 467 | |
| 468 | clear_bit(IPOIB_FLAG_OPER_UP, &priv->flags); |
| 469 | netif_carrier_off(dev); |
| 470 | |
| 471 | /* Shutdown the P_Key thread if still active */ |
| 472 | if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) { |
Ingo Molnar | 95ed644 | 2006-01-13 14:51:39 -0800 | [diff] [blame] | 473 | mutex_lock(&pkey_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | set_bit(IPOIB_PKEY_STOP, &priv->flags); |
| 475 | cancel_delayed_work(&priv->pkey_task); |
Ingo Molnar | 95ed644 | 2006-01-13 14:51:39 -0800 | [diff] [blame] | 476 | mutex_unlock(&pkey_mutex); |
Jack Morgenstein | 0b3ea08 | 2006-03-20 10:08:24 -0800 | [diff] [blame] | 477 | if (flush) |
| 478 | flush_workqueue(ipoib_workqueue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | } |
| 480 | |
Jack Morgenstein | 0b3ea08 | 2006-03-20 10:08:24 -0800 | [diff] [blame] | 481 | ipoib_mcast_stop_thread(dev, flush); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | ipoib_mcast_dev_flush(dev); |
| 483 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | ipoib_flush_paths(dev); |
| 485 | |
| 486 | return 0; |
| 487 | } |
| 488 | |
| 489 | static int recvs_pending(struct net_device *dev) |
| 490 | { |
| 491 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 492 | int pending = 0; |
| 493 | int i; |
| 494 | |
Shirley Ma | 0f48525 | 2006-04-10 09:43:58 -0700 | [diff] [blame] | 495 | for (i = 0; i < ipoib_recvq_size; ++i) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | if (priv->rx_ring[i].skb) |
| 497 | ++pending; |
| 498 | |
| 499 | return pending; |
| 500 | } |
| 501 | |
| 502 | int ipoib_ib_dev_stop(struct net_device *dev) |
| 503 | { |
| 504 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 505 | struct ib_qp_attr qp_attr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | unsigned long begin; |
Roland Dreier | 1993d68 | 2005-10-28 15:30:34 -0700 | [diff] [blame] | 507 | struct ipoib_tx_buf *tx_req; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | int i; |
| 509 | |
Leonid Arsh | 7a343d4 | 2006-03-23 19:52:51 +0200 | [diff] [blame] | 510 | clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags); |
| 511 | |
Roland Dreier | 3bc12e7 | 2005-10-30 13:20:09 -0800 | [diff] [blame] | 512 | /* |
| 513 | * Move our QP to the error state and then reinitialize in |
| 514 | * when all work requests have completed or have been flushed. |
| 515 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | qp_attr.qp_state = IB_QPS_ERR; |
Roland Dreier | 3bc12e7 | 2005-10-30 13:20:09 -0800 | [diff] [blame] | 517 | if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | ipoib_warn(priv, "Failed to modify QP to ERROR state\n"); |
| 519 | |
| 520 | /* Wait for all sends and receives to complete */ |
| 521 | begin = jiffies; |
| 522 | |
| 523 | while (priv->tx_head != priv->tx_tail || recvs_pending(dev)) { |
| 524 | if (time_after(jiffies, begin + 5 * HZ)) { |
| 525 | ipoib_warn(priv, "timing out; %d sends %d receives not completed\n", |
| 526 | priv->tx_head - priv->tx_tail, recvs_pending(dev)); |
| 527 | |
| 528 | /* |
| 529 | * assume the HW is wedged and just free up |
| 530 | * all our pending work requests. |
| 531 | */ |
Roland Dreier | 2181858 | 2005-07-27 14:41:32 -0700 | [diff] [blame] | 532 | while ((int) priv->tx_tail - (int) priv->tx_head < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | tx_req = &priv->tx_ring[priv->tx_tail & |
Shirley Ma | 0f48525 | 2006-04-10 09:43:58 -0700 | [diff] [blame] | 534 | (ipoib_sendq_size - 1)]; |
Ralph Campbell | 37ccf9d | 2006-12-12 14:30:48 -0800 | [diff] [blame] | 535 | ib_dma_unmap_single(priv->ca, |
| 536 | tx_req->mapping, |
| 537 | tx_req->skb->len, |
| 538 | DMA_TO_DEVICE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | dev_kfree_skb_any(tx_req->skb); |
| 540 | ++priv->tx_tail; |
| 541 | } |
| 542 | |
Ralph Campbell | 37ccf9d | 2006-12-12 14:30:48 -0800 | [diff] [blame] | 543 | for (i = 0; i < ipoib_recvq_size; ++i) { |
| 544 | struct ipoib_rx_buf *rx_req; |
| 545 | |
| 546 | rx_req = &priv->rx_ring[i]; |
| 547 | if (!rx_req->skb) |
| 548 | continue; |
| 549 | ib_dma_unmap_single(priv->ca, |
| 550 | rx_req->mapping, |
| 551 | IPOIB_BUF_SIZE, |
| 552 | DMA_FROM_DEVICE); |
| 553 | dev_kfree_skb_any(rx_req->skb); |
| 554 | rx_req->skb = NULL; |
| 555 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | |
| 557 | goto timeout; |
| 558 | } |
| 559 | |
| 560 | msleep(1); |
| 561 | } |
| 562 | |
| 563 | ipoib_dbg(priv, "All sends and receives done.\n"); |
| 564 | |
| 565 | timeout: |
| 566 | qp_attr.qp_state = IB_QPS_RESET; |
Roland Dreier | 3bc12e7 | 2005-10-30 13:20:09 -0800 | [diff] [blame] | 567 | if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | ipoib_warn(priv, "Failed to modify QP to RESET state\n"); |
| 569 | |
| 570 | /* Wait for all AHs to be reaped */ |
| 571 | set_bit(IPOIB_STOP_REAPER, &priv->flags); |
| 572 | cancel_delayed_work(&priv->ah_reap_task); |
| 573 | flush_workqueue(ipoib_workqueue); |
| 574 | |
| 575 | begin = jiffies; |
| 576 | |
| 577 | while (!list_empty(&priv->dead_ahs)) { |
| 578 | __ipoib_reap_ah(dev); |
| 579 | |
| 580 | if (time_after(jiffies, begin + HZ)) { |
| 581 | ipoib_warn(priv, "timing out; will leak address handles\n"); |
| 582 | break; |
| 583 | } |
| 584 | |
| 585 | msleep(1); |
| 586 | } |
| 587 | |
| 588 | return 0; |
| 589 | } |
| 590 | |
| 591 | int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port) |
| 592 | { |
| 593 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 594 | |
| 595 | priv->ca = ca; |
| 596 | priv->port = port; |
| 597 | priv->qp = NULL; |
| 598 | |
| 599 | if (ipoib_transport_dev_init(dev, ca)) { |
| 600 | printk(KERN_WARNING "%s: ipoib_transport_dev_init failed\n", ca->name); |
| 601 | return -ENODEV; |
| 602 | } |
| 603 | |
| 604 | if (dev->flags & IFF_UP) { |
| 605 | if (ipoib_ib_dev_open(dev)) { |
| 606 | ipoib_transport_dev_cleanup(dev); |
| 607 | return -ENODEV; |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | return 0; |
| 612 | } |
| 613 | |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 614 | void ipoib_ib_dev_flush(struct work_struct *work) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | { |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 616 | struct ipoib_dev_priv *cpriv, *priv = |
| 617 | container_of(work, struct ipoib_dev_priv, flush_task); |
| 618 | struct net_device *dev = priv->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | |
Leonid Arsh | 7a343d4 | 2006-03-23 19:52:51 +0200 | [diff] [blame] | 620 | if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags) ) { |
| 621 | ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | return; |
Leonid Arsh | 7a343d4 | 2006-03-23 19:52:51 +0200 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) { |
| 626 | ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_ADMIN_UP not set.\n"); |
| 627 | return; |
| 628 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | |
| 630 | ipoib_dbg(priv, "flushing\n"); |
| 631 | |
Jack Morgenstein | 0b3ea08 | 2006-03-20 10:08:24 -0800 | [diff] [blame] | 632 | ipoib_ib_dev_down(dev, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | |
| 634 | /* |
| 635 | * The device could have been brought down between the start and when |
| 636 | * we get here, don't bring it back up if it's not configured up |
| 637 | */ |
Eli Cohen | 5ccd025 | 2006-09-22 15:22:56 -0700 | [diff] [blame] | 638 | if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | ipoib_ib_dev_up(dev); |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 640 | ipoib_mcast_restart_task(&priv->restart_task); |
Eli Cohen | 5ccd025 | 2006-09-22 15:22:56 -0700 | [diff] [blame] | 641 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | |
Ingo Molnar | 95ed644 | 2006-01-13 14:51:39 -0800 | [diff] [blame] | 643 | mutex_lock(&priv->vlan_mutex); |
Michael S. Tsirkin | 4f71055 | 2005-11-29 10:53:30 -0800 | [diff] [blame] | 644 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | /* Flush any child interfaces too */ |
| 646 | list_for_each_entry(cpriv, &priv->child_intfs, list) |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 647 | ipoib_ib_dev_flush(&cpriv->flush_task); |
Michael S. Tsirkin | 4f71055 | 2005-11-29 10:53:30 -0800 | [diff] [blame] | 648 | |
Ingo Molnar | 95ed644 | 2006-01-13 14:51:39 -0800 | [diff] [blame] | 649 | mutex_unlock(&priv->vlan_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | void ipoib_ib_dev_cleanup(struct net_device *dev) |
| 653 | { |
| 654 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 655 | |
| 656 | ipoib_dbg(priv, "cleaning up ib_dev\n"); |
| 657 | |
Roland Dreier | 8d2cae0 | 2005-09-20 10:52:04 -0700 | [diff] [blame] | 658 | ipoib_mcast_stop_thread(dev, 1); |
Eli Cohen | 988bd50 | 2006-01-12 14:32:20 -0800 | [diff] [blame] | 659 | ipoib_mcast_dev_flush(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | |
| 661 | ipoib_transport_dev_cleanup(dev); |
| 662 | } |
| 663 | |
| 664 | /* |
| 665 | * Delayed P_Key Assigment Interim Support |
| 666 | * |
| 667 | * The following is initial implementation of delayed P_Key assigment |
| 668 | * mechanism. It is using the same approach implemented for the multicast |
| 669 | * group join. The single goal of this implementation is to quickly address |
| 670 | * Bug #2507. This implementation will probably be removed when the P_Key |
| 671 | * change async notification is available. |
| 672 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 674 | void ipoib_pkey_poll(struct work_struct *work) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | { |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 676 | struct ipoib_dev_priv *priv = |
| 677 | container_of(work, struct ipoib_dev_priv, pkey_task.work); |
| 678 | struct net_device *dev = priv->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | |
| 680 | ipoib_pkey_dev_check_presence(dev); |
| 681 | |
| 682 | if (test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) |
| 683 | ipoib_open(dev); |
| 684 | else { |
Ingo Molnar | 95ed644 | 2006-01-13 14:51:39 -0800 | [diff] [blame] | 685 | mutex_lock(&pkey_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | if (!test_bit(IPOIB_PKEY_STOP, &priv->flags)) |
| 687 | queue_delayed_work(ipoib_workqueue, |
| 688 | &priv->pkey_task, |
| 689 | HZ); |
Ingo Molnar | 95ed644 | 2006-01-13 14:51:39 -0800 | [diff] [blame] | 690 | mutex_unlock(&pkey_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | } |
| 692 | } |
| 693 | |
| 694 | int ipoib_pkey_dev_delay_open(struct net_device *dev) |
| 695 | { |
| 696 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 697 | |
| 698 | /* Look for the interface pkey value in the IB Port P_Key table and */ |
| 699 | /* set the interface pkey assigment flag */ |
| 700 | ipoib_pkey_dev_check_presence(dev); |
| 701 | |
| 702 | /* P_Key value not assigned yet - start polling */ |
| 703 | if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) { |
Ingo Molnar | 95ed644 | 2006-01-13 14:51:39 -0800 | [diff] [blame] | 704 | mutex_lock(&pkey_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | clear_bit(IPOIB_PKEY_STOP, &priv->flags); |
| 706 | queue_delayed_work(ipoib_workqueue, |
| 707 | &priv->pkey_task, |
| 708 | HZ); |
Ingo Molnar | 95ed644 | 2006-01-13 14:51:39 -0800 | [diff] [blame] | 709 | mutex_unlock(&pkey_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | return 1; |
| 711 | } |
| 712 | |
| 713 | return 0; |
| 714 | } |