Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2004 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) 2004 Voltaire, Inc. All rights reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | */ |
| 34 | |
| 35 | #include "ipoib.h" |
| 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #include <linux/module.h> |
| 38 | |
| 39 | #include <linux/init.h> |
| 40 | #include <linux/slab.h> |
Shirley Ma | 0f48525 | 2006-04-10 09:43:58 -0700 | [diff] [blame] | 41 | #include <linux/kernel.h> |
Roland Dreier | 10313cb | 2008-03-12 07:51:03 -0700 | [diff] [blame] | 42 | #include <linux/vmalloc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
| 44 | #include <linux/if_arp.h> /* For ARPHRD_xxx */ |
| 45 | |
| 46 | #include <linux/ip.h> |
| 47 | #include <linux/in.h> |
| 48 | |
Arnaldo Carvalho de Melo | 14c8502 | 2005-12-27 02:43:12 -0200 | [diff] [blame] | 49 | #include <net/dst.h> |
| 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | MODULE_AUTHOR("Roland Dreier"); |
| 52 | MODULE_DESCRIPTION("IP-over-InfiniBand net driver"); |
| 53 | MODULE_LICENSE("Dual BSD/GPL"); |
| 54 | |
Shirley Ma | 0f48525 | 2006-04-10 09:43:58 -0700 | [diff] [blame] | 55 | int ipoib_sendq_size __read_mostly = IPOIB_TX_RING_SIZE; |
| 56 | int ipoib_recvq_size __read_mostly = IPOIB_RX_RING_SIZE; |
| 57 | |
| 58 | module_param_named(send_queue_size, ipoib_sendq_size, int, 0444); |
| 59 | MODULE_PARM_DESC(send_queue_size, "Number of descriptors in send queue"); |
| 60 | module_param_named(recv_queue_size, ipoib_recvq_size, int, 0444); |
| 61 | MODULE_PARM_DESC(recv_queue_size, "Number of descriptors in receive queue"); |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG |
| 64 | int ipoib_debug_level; |
| 65 | |
| 66 | module_param_named(debug_level, ipoib_debug_level, int, 0644); |
| 67 | MODULE_PARM_DESC(debug_level, "Enable debug tracing if > 0"); |
| 68 | #endif |
| 69 | |
Roland Dreier | 1732b0e | 2005-11-07 10:33:11 -0800 | [diff] [blame] | 70 | struct ipoib_path_iter { |
| 71 | struct net_device *dev; |
| 72 | struct ipoib_path path; |
| 73 | }; |
| 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | static const u8 ipv4_bcast_addr[] = { |
| 76 | 0x00, 0xff, 0xff, 0xff, |
| 77 | 0xff, 0x12, 0x40, 0x1b, 0x00, 0x00, 0x00, 0x00, |
| 78 | 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff |
| 79 | }; |
| 80 | |
| 81 | struct workqueue_struct *ipoib_workqueue; |
| 82 | |
Michael S. Tsirkin | c1a0b23 | 2006-08-21 16:40:12 -0700 | [diff] [blame] | 83 | struct ib_sa_client ipoib_sa_client; |
| 84 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | static void ipoib_add_one(struct ib_device *device); |
| 86 | static void ipoib_remove_one(struct ib_device *device); |
| 87 | |
| 88 | static struct ib_client ipoib_client = { |
| 89 | .name = "ipoib", |
| 90 | .add = ipoib_add_one, |
| 91 | .remove = ipoib_remove_one |
| 92 | }; |
| 93 | |
| 94 | int ipoib_open(struct net_device *dev) |
| 95 | { |
| 96 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 97 | |
| 98 | ipoib_dbg(priv, "bringing up interface\n"); |
| 99 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 100 | napi_enable(&priv->napi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | set_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags); |
| 102 | |
| 103 | if (ipoib_pkey_dev_delay_open(dev)) |
| 104 | return 0; |
| 105 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 106 | if (ipoib_ib_dev_open(dev)) { |
| 107 | napi_disable(&priv->napi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | return -EINVAL; |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 109 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
Roland Dreier | 267ee88 | 2005-11-29 10:55:58 -0800 | [diff] [blame] | 111 | if (ipoib_ib_dev_up(dev)) { |
Yosef Etigin | 26bbf13 | 2007-05-19 08:51:54 -0700 | [diff] [blame] | 112 | ipoib_ib_dev_stop(dev, 1); |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 113 | napi_disable(&priv->napi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | return -EINVAL; |
Roland Dreier | 267ee88 | 2005-11-29 10:55:58 -0800 | [diff] [blame] | 115 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
| 117 | if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) { |
| 118 | struct ipoib_dev_priv *cpriv; |
| 119 | |
| 120 | /* Bring up any child interfaces too */ |
Ingo Molnar | 95ed644 | 2006-01-13 14:51:39 -0800 | [diff] [blame] | 121 | mutex_lock(&priv->vlan_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | list_for_each_entry(cpriv, &priv->child_intfs, list) { |
| 123 | int flags; |
| 124 | |
| 125 | flags = cpriv->dev->flags; |
| 126 | if (flags & IFF_UP) |
| 127 | continue; |
| 128 | |
| 129 | dev_change_flags(cpriv->dev, flags | IFF_UP); |
| 130 | } |
Ingo Molnar | 95ed644 | 2006-01-13 14:51:39 -0800 | [diff] [blame] | 131 | mutex_unlock(&priv->vlan_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | netif_start_queue(dev); |
| 135 | |
| 136 | return 0; |
| 137 | } |
| 138 | |
| 139 | static int ipoib_stop(struct net_device *dev) |
| 140 | { |
| 141 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 142 | |
| 143 | ipoib_dbg(priv, "stopping interface\n"); |
| 144 | |
| 145 | clear_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags); |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 146 | napi_disable(&priv->napi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | |
| 148 | netif_stop_queue(dev); |
| 149 | |
Jack Morgenstein | 0b3ea08 | 2006-03-20 10:08:24 -0800 | [diff] [blame] | 150 | /* |
| 151 | * Now flush workqueue to make sure a scheduled task doesn't |
| 152 | * bring our internal state back up. |
| 153 | */ |
| 154 | flush_workqueue(ipoib_workqueue); |
| 155 | |
| 156 | ipoib_ib_dev_down(dev, 1); |
Yosef Etigin | 26bbf13 | 2007-05-19 08:51:54 -0700 | [diff] [blame] | 157 | ipoib_ib_dev_stop(dev, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
| 159 | if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) { |
| 160 | struct ipoib_dev_priv *cpriv; |
| 161 | |
| 162 | /* Bring down any child interfaces too */ |
Ingo Molnar | 95ed644 | 2006-01-13 14:51:39 -0800 | [diff] [blame] | 163 | mutex_lock(&priv->vlan_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | list_for_each_entry(cpriv, &priv->child_intfs, list) { |
| 165 | int flags; |
| 166 | |
| 167 | flags = cpriv->dev->flags; |
| 168 | if (!(flags & IFF_UP)) |
| 169 | continue; |
| 170 | |
| 171 | dev_change_flags(cpriv->dev, flags & ~IFF_UP); |
| 172 | } |
Ingo Molnar | 95ed644 | 2006-01-13 14:51:39 -0800 | [diff] [blame] | 173 | mutex_unlock(&priv->vlan_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | return 0; |
| 177 | } |
| 178 | |
| 179 | static int ipoib_change_mtu(struct net_device *dev, int new_mtu) |
| 180 | { |
| 181 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 182 | |
Michael S. Tsirkin | 839fcab | 2007-02-05 22:12:23 +0200 | [diff] [blame] | 183 | /* dev->mtu > 2K ==> connected mode */ |
Pradeep Satyanarayana | 586a693 | 2007-12-21 13:08:23 -0800 | [diff] [blame] | 184 | if (ipoib_cm_admin_enabled(dev)) { |
| 185 | if (new_mtu > ipoib_cm_max_mtu(dev)) |
| 186 | return -EINVAL; |
| 187 | |
Michael S. Tsirkin | 839fcab | 2007-02-05 22:12:23 +0200 | [diff] [blame] | 188 | if (new_mtu > priv->mcast_mtu) |
| 189 | ipoib_warn(priv, "mtu > %d will cause multicast packet drops.\n", |
| 190 | priv->mcast_mtu); |
Pradeep Satyanarayana | 586a693 | 2007-12-21 13:08:23 -0800 | [diff] [blame] | 191 | |
Michael S. Tsirkin | 839fcab | 2007-02-05 22:12:23 +0200 | [diff] [blame] | 192 | dev->mtu = new_mtu; |
| 193 | return 0; |
| 194 | } |
| 195 | |
Shirley Ma | bc7b3a3 | 2008-04-23 11:55:45 -0700 | [diff] [blame] | 196 | if (new_mtu > IPOIB_UD_MTU(priv->max_ib_mtu)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | return -EINVAL; |
| 198 | |
| 199 | priv->admin_mtu = new_mtu; |
| 200 | |
| 201 | dev->mtu = min(priv->mcast_mtu, priv->admin_mtu); |
| 202 | |
| 203 | return 0; |
| 204 | } |
| 205 | |
Jack Morgenstein | 37c22a7 | 2006-05-29 19:14:05 +0300 | [diff] [blame] | 206 | static struct ipoib_path *__path_find(struct net_device *dev, void *gid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | { |
| 208 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 209 | struct rb_node *n = priv->path_tree.rb_node; |
| 210 | struct ipoib_path *path; |
| 211 | int ret; |
| 212 | |
| 213 | while (n) { |
| 214 | path = rb_entry(n, struct ipoib_path, rb_node); |
| 215 | |
Jack Morgenstein | 37c22a7 | 2006-05-29 19:14:05 +0300 | [diff] [blame] | 216 | ret = memcmp(gid, path->pathrec.dgid.raw, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | sizeof (union ib_gid)); |
| 218 | |
| 219 | if (ret < 0) |
| 220 | n = n->rb_left; |
| 221 | else if (ret > 0) |
| 222 | n = n->rb_right; |
| 223 | else |
| 224 | return path; |
| 225 | } |
| 226 | |
| 227 | return NULL; |
| 228 | } |
| 229 | |
| 230 | static int __path_add(struct net_device *dev, struct ipoib_path *path) |
| 231 | { |
| 232 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 233 | struct rb_node **n = &priv->path_tree.rb_node; |
| 234 | struct rb_node *pn = NULL; |
| 235 | struct ipoib_path *tpath; |
| 236 | int ret; |
| 237 | |
| 238 | while (*n) { |
| 239 | pn = *n; |
| 240 | tpath = rb_entry(pn, struct ipoib_path, rb_node); |
| 241 | |
| 242 | ret = memcmp(path->pathrec.dgid.raw, tpath->pathrec.dgid.raw, |
| 243 | sizeof (union ib_gid)); |
| 244 | if (ret < 0) |
| 245 | n = &pn->rb_left; |
| 246 | else if (ret > 0) |
| 247 | n = &pn->rb_right; |
| 248 | else |
| 249 | return -EEXIST; |
| 250 | } |
| 251 | |
| 252 | rb_link_node(&path->rb_node, pn, n); |
| 253 | rb_insert_color(&path->rb_node, &priv->path_tree); |
| 254 | |
| 255 | list_add_tail(&path->list, &priv->path_list); |
| 256 | |
| 257 | return 0; |
| 258 | } |
| 259 | |
| 260 | static void path_free(struct net_device *dev, struct ipoib_path *path) |
| 261 | { |
| 262 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 263 | struct ipoib_neigh *neigh, *tn; |
| 264 | struct sk_buff *skb; |
| 265 | unsigned long flags; |
| 266 | |
| 267 | while ((skb = __skb_dequeue(&path->queue))) |
| 268 | dev_kfree_skb_irq(skb); |
| 269 | |
| 270 | spin_lock_irqsave(&priv->lock, flags); |
| 271 | |
| 272 | list_for_each_entry_safe(neigh, tn, &path->neigh_list, list) { |
| 273 | /* |
| 274 | * It's safe to call ipoib_put_ah() inside priv->lock |
| 275 | * here, because we know that path->ah will always |
| 276 | * hold one more reference, so ipoib_put_ah() will |
| 277 | * never do more than decrement the ref count. |
| 278 | */ |
| 279 | if (neigh->ah) |
| 280 | ipoib_put_ah(neigh->ah); |
Michael S. Tsirkin | d2e0655 | 2006-04-04 19:59:40 +0300 | [diff] [blame] | 281 | |
Michael S. Tsirkin | 2745b5b | 2006-11-16 14:16:47 +0200 | [diff] [blame] | 282 | ipoib_neigh_free(dev, neigh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | spin_unlock_irqrestore(&priv->lock, flags); |
| 286 | |
| 287 | if (path->ah) |
| 288 | ipoib_put_ah(path->ah); |
| 289 | |
| 290 | kfree(path); |
| 291 | } |
| 292 | |
Roland Dreier | 1732b0e | 2005-11-07 10:33:11 -0800 | [diff] [blame] | 293 | #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG |
| 294 | |
| 295 | struct ipoib_path_iter *ipoib_path_iter_init(struct net_device *dev) |
| 296 | { |
| 297 | struct ipoib_path_iter *iter; |
| 298 | |
| 299 | iter = kmalloc(sizeof *iter, GFP_KERNEL); |
| 300 | if (!iter) |
| 301 | return NULL; |
| 302 | |
| 303 | iter->dev = dev; |
| 304 | memset(iter->path.pathrec.dgid.raw, 0, 16); |
| 305 | |
| 306 | if (ipoib_path_iter_next(iter)) { |
| 307 | kfree(iter); |
| 308 | return NULL; |
| 309 | } |
| 310 | |
| 311 | return iter; |
| 312 | } |
| 313 | |
| 314 | int ipoib_path_iter_next(struct ipoib_path_iter *iter) |
| 315 | { |
| 316 | struct ipoib_dev_priv *priv = netdev_priv(iter->dev); |
| 317 | struct rb_node *n; |
| 318 | struct ipoib_path *path; |
| 319 | int ret = 1; |
| 320 | |
| 321 | spin_lock_irq(&priv->lock); |
| 322 | |
| 323 | n = rb_first(&priv->path_tree); |
| 324 | |
| 325 | while (n) { |
| 326 | path = rb_entry(n, struct ipoib_path, rb_node); |
| 327 | |
| 328 | if (memcmp(iter->path.pathrec.dgid.raw, path->pathrec.dgid.raw, |
| 329 | sizeof (union ib_gid)) < 0) { |
| 330 | iter->path = *path; |
| 331 | ret = 0; |
| 332 | break; |
| 333 | } |
| 334 | |
| 335 | n = rb_next(n); |
| 336 | } |
| 337 | |
| 338 | spin_unlock_irq(&priv->lock); |
| 339 | |
| 340 | return ret; |
| 341 | } |
| 342 | |
| 343 | void ipoib_path_iter_read(struct ipoib_path_iter *iter, |
| 344 | struct ipoib_path *path) |
| 345 | { |
| 346 | *path = iter->path; |
| 347 | } |
| 348 | |
| 349 | #endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */ |
| 350 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | void ipoib_flush_paths(struct net_device *dev) |
| 352 | { |
| 353 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 354 | struct ipoib_path *path, *tp; |
| 355 | LIST_HEAD(remove_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | |
Michael S. Tsirkin | 9217b27 | 2006-08-03 22:16:06 +0300 | [diff] [blame] | 357 | spin_lock_irq(&priv->tx_lock); |
| 358 | spin_lock(&priv->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | |
Robert P. J. Day | 157de22 | 2008-04-16 21:09:26 -0700 | [diff] [blame] | 360 | list_splice_init(&priv->path_list, &remove_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | |
| 362 | list_for_each_entry(path, &remove_list, list) |
| 363 | rb_erase(&path->rb_node, &priv->path_tree); |
| 364 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | list_for_each_entry_safe(path, tp, &remove_list, list) { |
| 366 | if (path->query) |
| 367 | ib_sa_cancel_query(path->query_id, path->query); |
Michael S. Tsirkin | 9217b27 | 2006-08-03 22:16:06 +0300 | [diff] [blame] | 368 | spin_unlock(&priv->lock); |
| 369 | spin_unlock_irq(&priv->tx_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | wait_for_completion(&path->done); |
| 371 | path_free(dev, path); |
Michael S. Tsirkin | 9217b27 | 2006-08-03 22:16:06 +0300 | [diff] [blame] | 372 | spin_lock_irq(&priv->tx_lock); |
| 373 | spin_lock(&priv->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | } |
Michael S. Tsirkin | 9217b27 | 2006-08-03 22:16:06 +0300 | [diff] [blame] | 375 | spin_unlock(&priv->lock); |
| 376 | spin_unlock_irq(&priv->tx_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | static void path_rec_completion(int status, |
| 380 | struct ib_sa_path_rec *pathrec, |
| 381 | void *path_ptr) |
| 382 | { |
| 383 | struct ipoib_path *path = path_ptr; |
| 384 | struct net_device *dev = path->dev; |
| 385 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 386 | struct ipoib_ah *ah = NULL; |
Michael S. Tsirkin | d04d01b | 2007-03-22 14:40:16 -0700 | [diff] [blame] | 387 | struct ipoib_neigh *neigh, *tn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | struct sk_buff_head skqueue; |
| 389 | struct sk_buff *skb; |
| 390 | unsigned long flags; |
| 391 | |
Roland Dreier | 843613b | 2007-02-26 12:57:08 -0800 | [diff] [blame] | 392 | if (!status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | ipoib_dbg(priv, "PathRec LID 0x%04x for GID " IPOIB_GID_FMT "\n", |
| 394 | be16_to_cpu(pathrec->dlid), IPOIB_GID_ARG(pathrec->dgid)); |
| 395 | else |
| 396 | ipoib_dbg(priv, "PathRec status %d for GID " IPOIB_GID_FMT "\n", |
| 397 | status, IPOIB_GID_ARG(path->pathrec.dgid)); |
| 398 | |
| 399 | skb_queue_head_init(&skqueue); |
| 400 | |
| 401 | if (!status) { |
Sean Hefty | 46f1b3d | 2007-04-05 11:50:11 -0700 | [diff] [blame] | 402 | struct ib_ah_attr av; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | |
Sean Hefty | 46f1b3d | 2007-04-05 11:50:11 -0700 | [diff] [blame] | 404 | if (!ib_init_ah_from_path(priv->ca, priv->port, pathrec, &av)) |
| 405 | ah = ipoib_create_ah(dev, priv->pd, &av); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | spin_lock_irqsave(&priv->lock, flags); |
| 409 | |
| 410 | path->ah = ah; |
| 411 | |
| 412 | if (ah) { |
| 413 | path->pathrec = *pathrec; |
| 414 | |
| 415 | ipoib_dbg(priv, "created address handle %p for LID 0x%04x, SL %d\n", |
| 416 | ah, be16_to_cpu(pathrec->dlid), pathrec->sl); |
| 417 | |
| 418 | while ((skb = __skb_dequeue(&path->queue))) |
| 419 | __skb_queue_tail(&skqueue, skb); |
| 420 | |
Michael S. Tsirkin | d04d01b | 2007-03-22 14:40:16 -0700 | [diff] [blame] | 421 | list_for_each_entry_safe(neigh, tn, &path->neigh_list, list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | kref_get(&path->ah->ref); |
| 423 | neigh->ah = path->ah; |
Michael S. Tsirkin | 8a7f752 | 2006-07-19 17:44:37 +0300 | [diff] [blame] | 424 | memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw, |
| 425 | sizeof(union ib_gid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | |
Michael S. Tsirkin | 839fcab | 2007-02-05 22:12:23 +0200 | [diff] [blame] | 427 | if (ipoib_cm_enabled(dev, neigh->neighbour)) { |
| 428 | if (!ipoib_cm_get(neigh)) |
| 429 | ipoib_cm_set(neigh, ipoib_cm_create_tx(dev, |
| 430 | path, |
| 431 | neigh)); |
| 432 | if (!ipoib_cm_get(neigh)) { |
| 433 | list_del(&neigh->list); |
| 434 | if (neigh->ah) |
| 435 | ipoib_put_ah(neigh->ah); |
| 436 | ipoib_neigh_free(dev, neigh); |
| 437 | continue; |
| 438 | } |
| 439 | } |
| 440 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | while ((skb = __skb_dequeue(&neigh->queue))) |
| 442 | __skb_queue_tail(&skqueue, skb); |
| 443 | } |
Roland Dreier | 5872a9f | 2005-11-29 10:13:54 -0800 | [diff] [blame] | 444 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | |
Roland Dreier | 5872a9f | 2005-11-29 10:13:54 -0800 | [diff] [blame] | 446 | path->query = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | complete(&path->done); |
| 448 | |
| 449 | spin_unlock_irqrestore(&priv->lock, flags); |
| 450 | |
| 451 | while ((skb = __skb_dequeue(&skqueue))) { |
| 452 | skb->dev = dev; |
| 453 | if (dev_queue_xmit(skb)) |
| 454 | ipoib_warn(priv, "dev_queue_xmit failed " |
| 455 | "to requeue packet\n"); |
| 456 | } |
| 457 | } |
| 458 | |
Jack Morgenstein | 37c22a7 | 2006-05-29 19:14:05 +0300 | [diff] [blame] | 459 | static struct ipoib_path *path_rec_create(struct net_device *dev, void *gid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | { |
| 461 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 462 | struct ipoib_path *path; |
| 463 | |
Jack Morgenstein | 1401b53 | 2007-11-26 10:41:19 +0200 | [diff] [blame] | 464 | if (!priv->broadcast) |
| 465 | return NULL; |
| 466 | |
Roland Dreier | 21a3848 | 2005-11-02 10:07:59 -0800 | [diff] [blame] | 467 | path = kzalloc(sizeof *path, GFP_ATOMIC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | if (!path) |
| 469 | return NULL; |
| 470 | |
Roland Dreier | 21a3848 | 2005-11-02 10:07:59 -0800 | [diff] [blame] | 471 | path->dev = dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | |
| 473 | skb_queue_head_init(&path->queue); |
| 474 | |
| 475 | INIT_LIST_HEAD(&path->neigh_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | |
Jack Morgenstein | 37c22a7 | 2006-05-29 19:14:05 +0300 | [diff] [blame] | 477 | memcpy(path->pathrec.dgid.raw, gid, sizeof (union ib_gid)); |
Roland Dreier | 2337f80 | 2007-10-23 19:57:54 -0700 | [diff] [blame] | 478 | path->pathrec.sgid = priv->local_gid; |
| 479 | path->pathrec.pkey = cpu_to_be16(priv->pkey); |
Sean Hefty | 8166883 | 2007-08-02 12:21:31 -0700 | [diff] [blame] | 480 | path->pathrec.numb_path = 1; |
| 481 | path->pathrec.traffic_class = priv->broadcast->mcmember.traffic_class; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | |
| 483 | return path; |
| 484 | } |
| 485 | |
| 486 | static int path_rec_start(struct net_device *dev, |
| 487 | struct ipoib_path *path) |
| 488 | { |
| 489 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 490 | |
| 491 | ipoib_dbg(priv, "Start path record lookup for " IPOIB_GID_FMT "\n", |
| 492 | IPOIB_GID_ARG(path->pathrec.dgid)); |
| 493 | |
Roland Dreier | 65c7edd | 2005-11-28 21:20:34 -0800 | [diff] [blame] | 494 | init_completion(&path->done); |
| 495 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | path->query_id = |
Michael S. Tsirkin | c1a0b23 | 2006-08-21 16:40:12 -0700 | [diff] [blame] | 497 | ib_sa_path_rec_get(&ipoib_sa_client, priv->ca, priv->port, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | &path->pathrec, |
| 499 | IB_SA_PATH_REC_DGID | |
| 500 | IB_SA_PATH_REC_SGID | |
| 501 | IB_SA_PATH_REC_NUMB_PATH | |
Sean Hefty | 8166883 | 2007-08-02 12:21:31 -0700 | [diff] [blame] | 502 | IB_SA_PATH_REC_TRAFFIC_CLASS | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | IB_SA_PATH_REC_PKEY, |
| 504 | 1000, GFP_ATOMIC, |
| 505 | path_rec_completion, |
| 506 | path, &path->query); |
| 507 | if (path->query_id < 0) { |
| 508 | ipoib_warn(priv, "ib_sa_path_rec_get failed\n"); |
| 509 | path->query = NULL; |
| 510 | return path->query_id; |
| 511 | } |
| 512 | |
| 513 | return 0; |
| 514 | } |
| 515 | |
| 516 | static void neigh_add_path(struct sk_buff *skb, struct net_device *dev) |
| 517 | { |
| 518 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 519 | struct ipoib_path *path; |
| 520 | struct ipoib_neigh *neigh; |
| 521 | |
Moni Shoua | 732a217 | 2007-10-09 19:43:36 -0700 | [diff] [blame] | 522 | neigh = ipoib_neigh_alloc(skb->dst->neighbour, skb->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | if (!neigh) { |
Roland Dreier | de90351 | 2007-09-28 15:33:51 -0700 | [diff] [blame] | 524 | ++dev->stats.tx_dropped; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | dev_kfree_skb_any(skb); |
| 526 | return; |
| 527 | } |
| 528 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | /* |
| 530 | * We can only be called from ipoib_start_xmit, so we're |
| 531 | * inside tx_lock -- no need to save/restore flags. |
| 532 | */ |
| 533 | spin_lock(&priv->lock); |
| 534 | |
Jack Morgenstein | 37c22a7 | 2006-05-29 19:14:05 +0300 | [diff] [blame] | 535 | path = __path_find(dev, skb->dst->neighbour->ha + 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | if (!path) { |
Jack Morgenstein | 37c22a7 | 2006-05-29 19:14:05 +0300 | [diff] [blame] | 537 | path = path_rec_create(dev, skb->dst->neighbour->ha + 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | if (!path) |
Michael S. Tsirkin | d2e0655 | 2006-04-04 19:59:40 +0300 | [diff] [blame] | 539 | goto err_path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | |
| 541 | __path_add(dev, path); |
| 542 | } |
| 543 | |
| 544 | list_add_tail(&neigh->list, &path->neigh_list); |
| 545 | |
Michael S. Tsirkin | 47f7a07 | 2006-01-17 09:22:05 -0800 | [diff] [blame] | 546 | if (path->ah) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | kref_get(&path->ah->ref); |
| 548 | neigh->ah = path->ah; |
Michael S. Tsirkin | 8a7f752 | 2006-07-19 17:44:37 +0300 | [diff] [blame] | 549 | memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw, |
| 550 | sizeof(union ib_gid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | |
Michael S. Tsirkin | 839fcab | 2007-02-05 22:12:23 +0200 | [diff] [blame] | 552 | if (ipoib_cm_enabled(dev, neigh->neighbour)) { |
| 553 | if (!ipoib_cm_get(neigh)) |
| 554 | ipoib_cm_set(neigh, ipoib_cm_create_tx(dev, path, neigh)); |
| 555 | if (!ipoib_cm_get(neigh)) { |
| 556 | list_del(&neigh->list); |
| 557 | if (neigh->ah) |
| 558 | ipoib_put_ah(neigh->ah); |
| 559 | ipoib_neigh_free(dev, neigh); |
| 560 | goto err_drop; |
| 561 | } |
| 562 | if (skb_queue_len(&neigh->queue) < IPOIB_MAX_PATH_REC_QUEUE) |
| 563 | __skb_queue_tail(&neigh->queue, skb); |
| 564 | else { |
| 565 | ipoib_warn(priv, "queue length limit %d. Packet drop.\n", |
| 566 | skb_queue_len(&neigh->queue)); |
| 567 | goto err_drop; |
| 568 | } |
| 569 | } else |
| 570 | ipoib_send(dev, skb, path->ah, IPOIB_QPN(skb->dst->neighbour->ha)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | } else { |
| 572 | neigh->ah = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | |
| 574 | if (!path->query && path_rec_start(dev, path)) |
Michael S. Tsirkin | d2e0655 | 2006-04-04 19:59:40 +0300 | [diff] [blame] | 575 | goto err_list; |
Michael S. Tsirkin | 2745b5b | 2006-11-16 14:16:47 +0200 | [diff] [blame] | 576 | |
| 577 | __skb_queue_tail(&neigh->queue, skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | spin_unlock(&priv->lock); |
| 581 | return; |
| 582 | |
Michael S. Tsirkin | d2e0655 | 2006-04-04 19:59:40 +0300 | [diff] [blame] | 583 | err_list: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | list_del(&neigh->list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | |
Michael S. Tsirkin | d2e0655 | 2006-04-04 19:59:40 +0300 | [diff] [blame] | 586 | err_path: |
Michael S. Tsirkin | 2745b5b | 2006-11-16 14:16:47 +0200 | [diff] [blame] | 587 | ipoib_neigh_free(dev, neigh); |
Michael S. Tsirkin | 839fcab | 2007-02-05 22:12:23 +0200 | [diff] [blame] | 588 | err_drop: |
Roland Dreier | de90351 | 2007-09-28 15:33:51 -0700 | [diff] [blame] | 589 | ++dev->stats.tx_dropped; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | dev_kfree_skb_any(skb); |
| 591 | |
| 592 | spin_unlock(&priv->lock); |
| 593 | } |
| 594 | |
Roland Dreier | d70ed60 | 2005-09-28 19:56:57 -0700 | [diff] [blame] | 595 | static void ipoib_path_lookup(struct sk_buff *skb, struct net_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | { |
| 597 | struct ipoib_dev_priv *priv = netdev_priv(skb->dev); |
| 598 | |
| 599 | /* Look up path record for unicasts */ |
| 600 | if (skb->dst->neighbour->ha[4] != 0xff) { |
| 601 | neigh_add_path(skb, dev); |
| 602 | return; |
| 603 | } |
| 604 | |
| 605 | /* Add in the P_Key for multicasts */ |
| 606 | skb->dst->neighbour->ha[8] = (priv->pkey >> 8) & 0xff; |
| 607 | skb->dst->neighbour->ha[9] = priv->pkey & 0xff; |
Jack Morgenstein | 37c22a7 | 2006-05-29 19:14:05 +0300 | [diff] [blame] | 608 | ipoib_mcast_send(dev, skb->dst->neighbour->ha + 4, skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev, |
| 612 | struct ipoib_pseudoheader *phdr) |
| 613 | { |
| 614 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 615 | struct ipoib_path *path; |
| 616 | |
| 617 | /* |
| 618 | * We can only be called from ipoib_start_xmit, so we're |
| 619 | * inside tx_lock -- no need to save/restore flags. |
| 620 | */ |
| 621 | spin_lock(&priv->lock); |
| 622 | |
Jack Morgenstein | 37c22a7 | 2006-05-29 19:14:05 +0300 | [diff] [blame] | 623 | path = __path_find(dev, phdr->hwaddr + 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | if (!path) { |
Jack Morgenstein | 37c22a7 | 2006-05-29 19:14:05 +0300 | [diff] [blame] | 625 | path = path_rec_create(dev, phdr->hwaddr + 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | if (path) { |
| 627 | /* put pseudoheader back on for next time */ |
| 628 | skb_push(skb, sizeof *phdr); |
| 629 | __skb_queue_tail(&path->queue, skb); |
| 630 | |
| 631 | if (path_rec_start(dev, path)) { |
| 632 | spin_unlock(&priv->lock); |
| 633 | path_free(dev, path); |
| 634 | return; |
| 635 | } else |
| 636 | __path_add(dev, path); |
| 637 | } else { |
Roland Dreier | de90351 | 2007-09-28 15:33:51 -0700 | [diff] [blame] | 638 | ++dev->stats.tx_dropped; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | dev_kfree_skb_any(skb); |
| 640 | } |
| 641 | |
| 642 | spin_unlock(&priv->lock); |
| 643 | return; |
| 644 | } |
| 645 | |
Michael S. Tsirkin | 47f7a07 | 2006-01-17 09:22:05 -0800 | [diff] [blame] | 646 | if (path->ah) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | ipoib_dbg(priv, "Send unicast ARP to %04x\n", |
| 648 | be16_to_cpu(path->pathrec.dlid)); |
| 649 | |
Michael S. Tsirkin | 073ae84 | 2006-11-16 10:59:12 +0200 | [diff] [blame] | 650 | ipoib_send(dev, skb, path->ah, IPOIB_QPN(phdr->hwaddr)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | } else if ((path->query || !path_rec_start(dev, path)) && |
| 652 | skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) { |
| 653 | /* put pseudoheader back on for next time */ |
| 654 | skb_push(skb, sizeof *phdr); |
| 655 | __skb_queue_tail(&path->queue, skb); |
| 656 | } else { |
Roland Dreier | de90351 | 2007-09-28 15:33:51 -0700 | [diff] [blame] | 657 | ++dev->stats.tx_dropped; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | dev_kfree_skb_any(skb); |
| 659 | } |
| 660 | |
| 661 | spin_unlock(&priv->lock); |
| 662 | } |
| 663 | |
| 664 | static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev) |
| 665 | { |
| 666 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 667 | struct ipoib_neigh *neigh; |
| 668 | unsigned long flags; |
| 669 | |
Eli Cohen | a8bfca0 | 2006-09-22 15:22:58 -0700 | [diff] [blame] | 670 | if (unlikely(!spin_trylock_irqsave(&priv->tx_lock, flags))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | return NETDEV_TX_LOCKED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | |
Eli Cohen | a8bfca0 | 2006-09-22 15:22:58 -0700 | [diff] [blame] | 673 | if (likely(skb->dst && skb->dst->neighbour)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | if (unlikely(!*to_ipoib_neigh(skb->dst->neighbour))) { |
Roland Dreier | d70ed60 | 2005-09-28 19:56:57 -0700 | [diff] [blame] | 675 | ipoib_path_lookup(skb, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | goto out; |
| 677 | } |
| 678 | |
| 679 | neigh = *to_ipoib_neigh(skb->dst->neighbour); |
| 680 | |
Or Gerlitz | bafff97 | 2008-01-17 17:03:45 +0200 | [diff] [blame] | 681 | if (neigh->ah) |
Moni Shoua | 200d171 | 2007-10-09 19:43:37 -0700 | [diff] [blame] | 682 | if (unlikely((memcmp(&neigh->dgid.raw, |
Michael S. Tsirkin | 8a7f752 | 2006-07-19 17:44:37 +0300 | [diff] [blame] | 683 | skb->dst->neighbour->ha + 4, |
Moni Shoua | 200d171 | 2007-10-09 19:43:37 -0700 | [diff] [blame] | 684 | sizeof(union ib_gid))) || |
| 685 | (neigh->dev != dev))) { |
Michael S. Tsirkin | 8a7f752 | 2006-07-19 17:44:37 +0300 | [diff] [blame] | 686 | spin_lock(&priv->lock); |
| 687 | /* |
| 688 | * It's safe to call ipoib_put_ah() inside |
| 689 | * priv->lock here, because we know that |
| 690 | * path->ah will always hold one more reference, |
| 691 | * so ipoib_put_ah() will never do more than |
| 692 | * decrement the ref count. |
| 693 | */ |
| 694 | ipoib_put_ah(neigh->ah); |
| 695 | list_del(&neigh->list); |
Michael S. Tsirkin | 2745b5b | 2006-11-16 14:16:47 +0200 | [diff] [blame] | 696 | ipoib_neigh_free(dev, neigh); |
Michael S. Tsirkin | 8a7f752 | 2006-07-19 17:44:37 +0300 | [diff] [blame] | 697 | spin_unlock(&priv->lock); |
| 698 | ipoib_path_lookup(skb, dev); |
| 699 | goto out; |
| 700 | } |
| 701 | |
Or Gerlitz | bafff97 | 2008-01-17 17:03:45 +0200 | [diff] [blame] | 702 | if (ipoib_cm_get(neigh)) { |
| 703 | if (ipoib_cm_up(neigh)) { |
| 704 | ipoib_cm_send(dev, skb, ipoib_cm_get(neigh)); |
| 705 | goto out; |
| 706 | } |
| 707 | } else if (neigh->ah) { |
Michael S. Tsirkin | 073ae84 | 2006-11-16 10:59:12 +0200 | [diff] [blame] | 708 | ipoib_send(dev, skb, neigh->ah, IPOIB_QPN(skb->dst->neighbour->ha)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | goto out; |
| 710 | } |
| 711 | |
| 712 | if (skb_queue_len(&neigh->queue) < IPOIB_MAX_PATH_REC_QUEUE) { |
| 713 | spin_lock(&priv->lock); |
| 714 | __skb_queue_tail(&neigh->queue, skb); |
| 715 | spin_unlock(&priv->lock); |
| 716 | } else { |
Roland Dreier | de90351 | 2007-09-28 15:33:51 -0700 | [diff] [blame] | 717 | ++dev->stats.tx_dropped; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | dev_kfree_skb_any(skb); |
| 719 | } |
| 720 | } else { |
| 721 | struct ipoib_pseudoheader *phdr = |
| 722 | (struct ipoib_pseudoheader *) skb->data; |
| 723 | skb_pull(skb, sizeof *phdr); |
| 724 | |
| 725 | if (phdr->hwaddr[4] == 0xff) { |
| 726 | /* Add in the P_Key for multicast*/ |
| 727 | phdr->hwaddr[8] = (priv->pkey >> 8) & 0xff; |
| 728 | phdr->hwaddr[9] = priv->pkey & 0xff; |
| 729 | |
Jack Morgenstein | 37c22a7 | 2006-05-29 19:14:05 +0300 | [diff] [blame] | 730 | ipoib_mcast_send(dev, phdr->hwaddr + 4, skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | } else { |
Hal Rosenstock | 0dca0f7 | 2005-07-28 13:17:26 -0700 | [diff] [blame] | 732 | /* unicast GID -- should be ARP or RARP reply */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | |
Hal Rosenstock | 0dca0f7 | 2005-07-28 13:17:26 -0700 | [diff] [blame] | 734 | if ((be16_to_cpup((__be16 *) skb->data) != ETH_P_ARP) && |
| 735 | (be16_to_cpup((__be16 *) skb->data) != ETH_P_RARP)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | ipoib_warn(priv, "Unicast, no %s: type %04x, QPN %06x " |
| 737 | IPOIB_GID_FMT "\n", |
| 738 | skb->dst ? "neigh" : "dst", |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 739 | be16_to_cpup((__be16 *) skb->data), |
Michael S. Tsirkin | 073ae84 | 2006-11-16 10:59:12 +0200 | [diff] [blame] | 740 | IPOIB_QPN(phdr->hwaddr), |
Jack Morgenstein | 37c22a7 | 2006-05-29 19:14:05 +0300 | [diff] [blame] | 741 | IPOIB_GID_RAW_ARG(phdr->hwaddr + 4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | dev_kfree_skb_any(skb); |
Roland Dreier | de90351 | 2007-09-28 15:33:51 -0700 | [diff] [blame] | 743 | ++dev->stats.tx_dropped; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 744 | goto out; |
| 745 | } |
| 746 | |
| 747 | unicast_arp_send(skb, dev, phdr); |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | out: |
| 752 | spin_unlock_irqrestore(&priv->tx_lock, flags); |
| 753 | |
| 754 | return NETDEV_TX_OK; |
| 755 | } |
| 756 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | static void ipoib_timeout(struct net_device *dev) |
| 758 | { |
| 759 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 760 | |
Roland Dreier | 4b2d319 | 2005-10-18 12:20:06 -0700 | [diff] [blame] | 761 | ipoib_warn(priv, "transmit timeout: latency %d msecs\n", |
| 762 | jiffies_to_msecs(jiffies - dev->trans_start)); |
| 763 | ipoib_warn(priv, "queue stopped %d, tx_head %u, tx_tail %u\n", |
| 764 | netif_queue_stopped(dev), |
| 765 | priv->tx_head, priv->tx_tail); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | /* XXX reset QP, etc. */ |
| 767 | } |
| 768 | |
| 769 | static int ipoib_hard_header(struct sk_buff *skb, |
| 770 | struct net_device *dev, |
| 771 | unsigned short type, |
Stephen Hemminger | 3b04ddd | 2007-10-09 01:40:57 -0700 | [diff] [blame] | 772 | const void *daddr, const void *saddr, unsigned len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 773 | { |
| 774 | struct ipoib_header *header; |
| 775 | |
| 776 | header = (struct ipoib_header *) skb_push(skb, sizeof *header); |
| 777 | |
| 778 | header->proto = htons(type); |
| 779 | header->reserved = 0; |
| 780 | |
| 781 | /* |
| 782 | * If we don't have a neighbour structure, stuff the |
| 783 | * destination address onto the front of the skb so we can |
| 784 | * figure out where to send the packet later. |
| 785 | */ |
Roland Dreier | ef12d45 | 2006-03-29 09:36:46 -0800 | [diff] [blame] | 786 | if ((!skb->dst || !skb->dst->neighbour) && daddr) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | struct ipoib_pseudoheader *phdr = |
| 788 | (struct ipoib_pseudoheader *) skb_push(skb, sizeof *phdr); |
| 789 | memcpy(phdr->hwaddr, daddr, INFINIBAND_ALEN); |
| 790 | } |
| 791 | |
| 792 | return 0; |
| 793 | } |
| 794 | |
| 795 | static void ipoib_set_mcast_list(struct net_device *dev) |
| 796 | { |
| 797 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 798 | |
Leonid Arsh | 7a343d4 | 2006-03-23 19:52:51 +0200 | [diff] [blame] | 799 | if (!test_bit(IPOIB_FLAG_OPER_UP, &priv->flags)) { |
| 800 | ipoib_dbg(priv, "IPOIB_FLAG_OPER_UP not set"); |
| 801 | return; |
| 802 | } |
| 803 | |
Michael S. Tsirkin | 1ad62a1 | 2005-08-24 14:41:51 -0700 | [diff] [blame] | 804 | queue_work(ipoib_workqueue, &priv->restart_task); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | } |
| 806 | |
Alexey Kuznetsov | ecbb416 | 2007-03-24 12:52:16 -0700 | [diff] [blame] | 807 | static void ipoib_neigh_cleanup(struct neighbour *n) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | { |
| 809 | struct ipoib_neigh *neigh; |
| 810 | struct ipoib_dev_priv *priv = netdev_priv(n->dev); |
| 811 | unsigned long flags; |
| 812 | struct ipoib_ah *ah = NULL; |
| 813 | |
Moni Shoua | 732a217 | 2007-10-09 19:43:36 -0700 | [diff] [blame] | 814 | neigh = *to_ipoib_neigh(n); |
Or Gerlitz | 7bc531d | 2008-01-29 12:57:56 +0200 | [diff] [blame] | 815 | if (neigh) |
Moni Shoua | 732a217 | 2007-10-09 19:43:36 -0700 | [diff] [blame] | 816 | priv = netdev_priv(neigh->dev); |
Or Gerlitz | 7bc531d | 2008-01-29 12:57:56 +0200 | [diff] [blame] | 817 | else |
Moni Shoua | 732a217 | 2007-10-09 19:43:36 -0700 | [diff] [blame] | 818 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | ipoib_dbg(priv, |
Alexey Kuznetsov | ecbb416 | 2007-03-24 12:52:16 -0700 | [diff] [blame] | 820 | "neigh_cleanup for %06x " IPOIB_GID_FMT "\n", |
Michael S. Tsirkin | 073ae84 | 2006-11-16 10:59:12 +0200 | [diff] [blame] | 821 | IPOIB_QPN(n->ha), |
Jack Morgenstein | 37c22a7 | 2006-05-29 19:14:05 +0300 | [diff] [blame] | 822 | IPOIB_GID_RAW_ARG(n->ha + 4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | |
| 824 | spin_lock_irqsave(&priv->lock, flags); |
| 825 | |
Moni Shoua | 732a217 | 2007-10-09 19:43:36 -0700 | [diff] [blame] | 826 | if (neigh->ah) |
| 827 | ah = neigh->ah; |
| 828 | list_del(&neigh->list); |
| 829 | ipoib_neigh_free(n->dev, neigh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | |
| 831 | spin_unlock_irqrestore(&priv->lock, flags); |
| 832 | |
| 833 | if (ah) |
| 834 | ipoib_put_ah(ah); |
| 835 | } |
| 836 | |
Moni Shoua | 732a217 | 2007-10-09 19:43:36 -0700 | [diff] [blame] | 837 | struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neighbour, |
| 838 | struct net_device *dev) |
Michael S. Tsirkin | d2e0655 | 2006-04-04 19:59:40 +0300 | [diff] [blame] | 839 | { |
| 840 | struct ipoib_neigh *neigh; |
| 841 | |
| 842 | neigh = kmalloc(sizeof *neigh, GFP_ATOMIC); |
| 843 | if (!neigh) |
| 844 | return NULL; |
| 845 | |
| 846 | neigh->neighbour = neighbour; |
Moni Shoua | 732a217 | 2007-10-09 19:43:36 -0700 | [diff] [blame] | 847 | neigh->dev = dev; |
Michael S. Tsirkin | d2e0655 | 2006-04-04 19:59:40 +0300 | [diff] [blame] | 848 | *to_ipoib_neigh(neighbour) = neigh; |
Roland Dreier | 82b3991 | 2006-12-12 14:48:18 -0800 | [diff] [blame] | 849 | skb_queue_head_init(&neigh->queue); |
Michael S. Tsirkin | 839fcab | 2007-02-05 22:12:23 +0200 | [diff] [blame] | 850 | ipoib_cm_set(neigh, NULL); |
Michael S. Tsirkin | d2e0655 | 2006-04-04 19:59:40 +0300 | [diff] [blame] | 851 | |
| 852 | return neigh; |
| 853 | } |
| 854 | |
Michael S. Tsirkin | 2745b5b | 2006-11-16 14:16:47 +0200 | [diff] [blame] | 855 | void ipoib_neigh_free(struct net_device *dev, struct ipoib_neigh *neigh) |
Michael S. Tsirkin | d2e0655 | 2006-04-04 19:59:40 +0300 | [diff] [blame] | 856 | { |
Michael S. Tsirkin | 2745b5b | 2006-11-16 14:16:47 +0200 | [diff] [blame] | 857 | struct sk_buff *skb; |
Michael S. Tsirkin | d2e0655 | 2006-04-04 19:59:40 +0300 | [diff] [blame] | 858 | *to_ipoib_neigh(neigh->neighbour) = NULL; |
Michael S. Tsirkin | 2745b5b | 2006-11-16 14:16:47 +0200 | [diff] [blame] | 859 | while ((skb = __skb_dequeue(&neigh->queue))) { |
Roland Dreier | de90351 | 2007-09-28 15:33:51 -0700 | [diff] [blame] | 860 | ++dev->stats.tx_dropped; |
Michael S. Tsirkin | 2745b5b | 2006-11-16 14:16:47 +0200 | [diff] [blame] | 861 | dev_kfree_skb_any(skb); |
| 862 | } |
Michael S. Tsirkin | 839fcab | 2007-02-05 22:12:23 +0200 | [diff] [blame] | 863 | if (ipoib_cm_get(neigh)) |
| 864 | ipoib_cm_destroy_tx(ipoib_cm_get(neigh)); |
Michael S. Tsirkin | d2e0655 | 2006-04-04 19:59:40 +0300 | [diff] [blame] | 865 | kfree(neigh); |
| 866 | } |
| 867 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 868 | static int ipoib_neigh_setup_dev(struct net_device *dev, struct neigh_parms *parms) |
| 869 | { |
Alexey Kuznetsov | ecbb416 | 2007-03-24 12:52:16 -0700 | [diff] [blame] | 870 | parms->neigh_cleanup = ipoib_neigh_cleanup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | |
| 872 | return 0; |
| 873 | } |
| 874 | |
| 875 | int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port) |
| 876 | { |
| 877 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 878 | |
| 879 | /* Allocate RX/TX "rings" to hold queued skbs */ |
Shirley Ma | 0f48525 | 2006-04-10 09:43:58 -0700 | [diff] [blame] | 880 | priv->rx_ring = kzalloc(ipoib_recvq_size * sizeof *priv->rx_ring, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 881 | GFP_KERNEL); |
| 882 | if (!priv->rx_ring) { |
| 883 | printk(KERN_WARNING "%s: failed to allocate RX ring (%d entries)\n", |
Shirley Ma | 0f48525 | 2006-04-10 09:43:58 -0700 | [diff] [blame] | 884 | ca->name, ipoib_recvq_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 885 | goto out; |
| 886 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | |
Roland Dreier | 10313cb | 2008-03-12 07:51:03 -0700 | [diff] [blame] | 888 | priv->tx_ring = vmalloc(ipoib_sendq_size * sizeof *priv->tx_ring); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | if (!priv->tx_ring) { |
| 890 | printk(KERN_WARNING "%s: failed to allocate TX ring (%d entries)\n", |
Shirley Ma | 0f48525 | 2006-04-10 09:43:58 -0700 | [diff] [blame] | 891 | ca->name, ipoib_sendq_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | goto out_rx_ring_cleanup; |
| 893 | } |
Roland Dreier | 10313cb | 2008-03-12 07:51:03 -0700 | [diff] [blame] | 894 | memset(priv->tx_ring, 0, ipoib_sendq_size * sizeof *priv->tx_ring); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | |
Michael S. Tsirkin | 1b52496 | 2007-08-16 15:36:16 +0300 | [diff] [blame] | 896 | /* priv->tx_head, tx_tail & tx_outstanding are already 0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | |
| 898 | if (ipoib_ib_dev_init(dev, ca, port)) |
| 899 | goto out_tx_ring_cleanup; |
| 900 | |
| 901 | return 0; |
| 902 | |
| 903 | out_tx_ring_cleanup: |
Roland Dreier | 10313cb | 2008-03-12 07:51:03 -0700 | [diff] [blame] | 904 | vfree(priv->tx_ring); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | |
| 906 | out_rx_ring_cleanup: |
| 907 | kfree(priv->rx_ring); |
| 908 | |
| 909 | out: |
| 910 | return -ENOMEM; |
| 911 | } |
| 912 | |
| 913 | void ipoib_dev_cleanup(struct net_device *dev) |
| 914 | { |
| 915 | struct ipoib_dev_priv *priv = netdev_priv(dev), *cpriv, *tcpriv; |
| 916 | |
Roland Dreier | 1732b0e | 2005-11-07 10:33:11 -0800 | [diff] [blame] | 917 | ipoib_delete_debug_files(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | |
| 919 | /* Delete any child interfaces first */ |
| 920 | list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list) { |
| 921 | unregister_netdev(cpriv->dev); |
| 922 | ipoib_dev_cleanup(cpriv->dev); |
| 923 | free_netdev(cpriv->dev); |
| 924 | } |
| 925 | |
| 926 | ipoib_ib_dev_cleanup(dev); |
| 927 | |
Hal Rosenstock | 92a6b34 | 2005-08-13 20:50:27 -0700 | [diff] [blame] | 928 | kfree(priv->rx_ring); |
Roland Dreier | 10313cb | 2008-03-12 07:51:03 -0700 | [diff] [blame] | 929 | vfree(priv->tx_ring); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | |
Hal Rosenstock | 92a6b34 | 2005-08-13 20:50:27 -0700 | [diff] [blame] | 931 | priv->rx_ring = NULL; |
| 932 | priv->tx_ring = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | } |
| 934 | |
Stephen Hemminger | 3b04ddd | 2007-10-09 01:40:57 -0700 | [diff] [blame] | 935 | static const struct header_ops ipoib_header_ops = { |
| 936 | .create = ipoib_hard_header, |
| 937 | }; |
| 938 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 939 | static void ipoib_setup(struct net_device *dev) |
| 940 | { |
| 941 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
| 942 | |
Roland Dreier | 2337f80 | 2007-10-23 19:57:54 -0700 | [diff] [blame] | 943 | dev->open = ipoib_open; |
| 944 | dev->stop = ipoib_stop; |
| 945 | dev->change_mtu = ipoib_change_mtu; |
| 946 | dev->hard_start_xmit = ipoib_start_xmit; |
| 947 | dev->tx_timeout = ipoib_timeout; |
| 948 | dev->header_ops = &ipoib_header_ops; |
| 949 | dev->set_multicast_list = ipoib_set_mcast_list; |
| 950 | dev->neigh_setup = ipoib_neigh_setup_dev; |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 951 | |
Eli Cohen | 82c24c1 | 2008-04-16 21:09:32 -0700 | [diff] [blame] | 952 | ipoib_set_ethtool_ops(dev); |
| 953 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 954 | netif_napi_add(dev, &priv->napi, ipoib_poll, 100); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | |
Roland Dreier | 2337f80 | 2007-10-23 19:57:54 -0700 | [diff] [blame] | 956 | dev->watchdog_timeo = HZ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | |
Roland Dreier | 2337f80 | 2007-10-23 19:57:54 -0700 | [diff] [blame] | 958 | dev->flags |= IFF_BROADCAST | IFF_MULTICAST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 959 | |
| 960 | /* |
| 961 | * We add in INFINIBAND_ALEN to allow for the destination |
| 962 | * address "pseudoheader" for skbs without neighbour struct. |
| 963 | */ |
Roland Dreier | 2337f80 | 2007-10-23 19:57:54 -0700 | [diff] [blame] | 964 | dev->hard_header_len = IPOIB_ENCAP_LEN + INFINIBAND_ALEN; |
| 965 | dev->addr_len = INFINIBAND_ALEN; |
| 966 | dev->type = ARPHRD_INFINIBAND; |
| 967 | dev->tx_queue_len = ipoib_sendq_size * 2; |
Eli Cohen | eb14032f | 2008-01-30 18:30:46 +0200 | [diff] [blame] | 968 | dev->features = (NETIF_F_VLAN_CHALLENGED | |
| 969 | NETIF_F_LLTX | |
| 970 | NETIF_F_HIGHDMA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 971 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | memcpy(dev->broadcast, ipv4_bcast_addr, INFINIBAND_ALEN); |
| 973 | |
| 974 | netif_carrier_off(dev); |
| 975 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | priv->dev = dev; |
| 977 | |
| 978 | spin_lock_init(&priv->lock); |
| 979 | spin_lock_init(&priv->tx_lock); |
| 980 | |
Ingo Molnar | 95ed644 | 2006-01-13 14:51:39 -0800 | [diff] [blame] | 981 | mutex_init(&priv->mcast_mutex); |
| 982 | mutex_init(&priv->vlan_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | |
| 984 | INIT_LIST_HEAD(&priv->path_list); |
| 985 | INIT_LIST_HEAD(&priv->child_intfs); |
| 986 | INIT_LIST_HEAD(&priv->dead_ahs); |
| 987 | INIT_LIST_HEAD(&priv->multicast_list); |
| 988 | |
Yosef Etigin | 26bbf13 | 2007-05-19 08:51:54 -0700 | [diff] [blame] | 989 | INIT_DELAYED_WORK(&priv->pkey_poll_task, ipoib_pkey_poll); |
| 990 | INIT_WORK(&priv->pkey_event_task, ipoib_pkey_event); |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 991 | INIT_DELAYED_WORK(&priv->mcast_task, ipoib_mcast_join_task); |
| 992 | INIT_WORK(&priv->flush_task, ipoib_ib_dev_flush); |
| 993 | INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task); |
| 994 | INIT_DELAYED_WORK(&priv->ah_reap_task, ipoib_reap_ah); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | } |
| 996 | |
| 997 | struct ipoib_dev_priv *ipoib_intf_alloc(const char *name) |
| 998 | { |
| 999 | struct net_device *dev; |
| 1000 | |
| 1001 | dev = alloc_netdev((int) sizeof (struct ipoib_dev_priv), name, |
| 1002 | ipoib_setup); |
| 1003 | if (!dev) |
| 1004 | return NULL; |
| 1005 | |
| 1006 | return netdev_priv(dev); |
| 1007 | } |
| 1008 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1009 | static ssize_t show_pkey(struct device *dev, |
| 1010 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1012 | struct ipoib_dev_priv *priv = netdev_priv(to_net_dev(dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | |
| 1014 | return sprintf(buf, "0x%04x\n", priv->pkey); |
| 1015 | } |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1016 | static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1017 | |
Or Gerlitz | 335a64a5a | 2007-10-08 10:13:00 +0200 | [diff] [blame] | 1018 | static ssize_t show_umcast(struct device *dev, |
| 1019 | struct device_attribute *attr, char *buf) |
| 1020 | { |
| 1021 | struct ipoib_dev_priv *priv = netdev_priv(to_net_dev(dev)); |
| 1022 | |
| 1023 | return sprintf(buf, "%d\n", test_bit(IPOIB_FLAG_UMCAST, &priv->flags)); |
| 1024 | } |
| 1025 | |
| 1026 | static ssize_t set_umcast(struct device *dev, |
| 1027 | struct device_attribute *attr, |
| 1028 | const char *buf, size_t count) |
| 1029 | { |
| 1030 | struct ipoib_dev_priv *priv = netdev_priv(to_net_dev(dev)); |
| 1031 | unsigned long umcast_val = simple_strtoul(buf, NULL, 0); |
| 1032 | |
| 1033 | if (umcast_val > 0) { |
| 1034 | set_bit(IPOIB_FLAG_UMCAST, &priv->flags); |
| 1035 | ipoib_warn(priv, "ignoring multicast groups joined directly " |
| 1036 | "by userspace\n"); |
| 1037 | } else |
| 1038 | clear_bit(IPOIB_FLAG_UMCAST, &priv->flags); |
| 1039 | |
| 1040 | return count; |
| 1041 | } |
| 1042 | static DEVICE_ATTR(umcast, S_IWUSR | S_IRUGO, show_umcast, set_umcast); |
| 1043 | |
| 1044 | int ipoib_add_umcast_attr(struct net_device *dev) |
| 1045 | { |
| 1046 | return device_create_file(&dev->dev, &dev_attr_umcast); |
| 1047 | } |
| 1048 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1049 | static ssize_t create_child(struct device *dev, |
| 1050 | struct device_attribute *attr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1051 | const char *buf, size_t count) |
| 1052 | { |
| 1053 | int pkey; |
| 1054 | int ret; |
| 1055 | |
| 1056 | if (sscanf(buf, "%i", &pkey) != 1) |
| 1057 | return -EINVAL; |
| 1058 | |
| 1059 | if (pkey < 0 || pkey > 0xffff) |
| 1060 | return -EINVAL; |
| 1061 | |
Roland Dreier | 4ce0593 | 2005-08-19 12:03:17 -0700 | [diff] [blame] | 1062 | /* |
| 1063 | * Set the full membership bit, so that we join the right |
| 1064 | * broadcast group, etc. |
| 1065 | */ |
| 1066 | pkey |= 0x8000; |
| 1067 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1068 | ret = ipoib_vlan_add(to_net_dev(dev), pkey); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | |
| 1070 | return ret ? ret : count; |
| 1071 | } |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1072 | static DEVICE_ATTR(create_child, S_IWUGO, NULL, create_child); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1074 | static ssize_t delete_child(struct device *dev, |
| 1075 | struct device_attribute *attr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1076 | const char *buf, size_t count) |
| 1077 | { |
| 1078 | int pkey; |
| 1079 | int ret; |
| 1080 | |
| 1081 | if (sscanf(buf, "%i", &pkey) != 1) |
| 1082 | return -EINVAL; |
| 1083 | |
| 1084 | if (pkey < 0 || pkey > 0xffff) |
| 1085 | return -EINVAL; |
| 1086 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1087 | ret = ipoib_vlan_delete(to_net_dev(dev), pkey); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | |
| 1089 | return ret ? ret : count; |
| 1090 | |
| 1091 | } |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1092 | static DEVICE_ATTR(delete_child, S_IWUGO, NULL, delete_child); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1093 | |
| 1094 | int ipoib_add_pkey_attr(struct net_device *dev) |
| 1095 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1096 | return device_create_file(&dev->dev, &dev_attr_pkey); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1097 | } |
| 1098 | |
| 1099 | static struct net_device *ipoib_add_port(const char *format, |
| 1100 | struct ib_device *hca, u8 port) |
| 1101 | { |
| 1102 | struct ipoib_dev_priv *priv; |
Eli Cohen | 6046136 | 2008-04-16 21:01:10 -0700 | [diff] [blame] | 1103 | struct ib_device_attr *device_attr; |
Shirley Ma | bc7b3a3 | 2008-04-23 11:55:45 -0700 | [diff] [blame] | 1104 | struct ib_port_attr attr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | int result = -ENOMEM; |
| 1106 | |
| 1107 | priv = ipoib_intf_alloc(format); |
| 1108 | if (!priv) |
| 1109 | goto alloc_mem_failed; |
| 1110 | |
| 1111 | SET_NETDEV_DEV(priv->dev, hca->dma_device); |
| 1112 | |
Shirley Ma | bc7b3a3 | 2008-04-23 11:55:45 -0700 | [diff] [blame] | 1113 | if (!ib_query_port(hca, port, &attr)) |
| 1114 | priv->max_ib_mtu = ib_mtu_enum_to_int(attr.max_mtu); |
| 1115 | else { |
| 1116 | printk(KERN_WARNING "%s: ib_query_port %d failed\n", |
| 1117 | hca->name, port); |
| 1118 | goto device_init_failed; |
| 1119 | } |
| 1120 | |
| 1121 | /* MTU will be reset when mcast join happens */ |
| 1122 | priv->dev->mtu = IPOIB_UD_MTU(priv->max_ib_mtu); |
| 1123 | priv->mcast_mtu = priv->admin_mtu = priv->dev->mtu; |
| 1124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | result = ib_query_pkey(hca, port, 0, &priv->pkey); |
| 1126 | if (result) { |
| 1127 | printk(KERN_WARNING "%s: ib_query_pkey port %d failed (ret = %d)\n", |
| 1128 | hca->name, port, result); |
Eli Cohen | ca6de17 | 2007-08-21 18:46:10 +0300 | [diff] [blame] | 1129 | goto device_init_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | } |
| 1131 | |
Eli Cohen | 6046136 | 2008-04-16 21:01:10 -0700 | [diff] [blame] | 1132 | device_attr = kmalloc(sizeof *device_attr, GFP_KERNEL); |
| 1133 | if (!device_attr) { |
| 1134 | printk(KERN_WARNING "%s: allocation of %zu bytes failed\n", |
| 1135 | hca->name, sizeof *device_attr); |
| 1136 | goto device_init_failed; |
| 1137 | } |
| 1138 | |
| 1139 | result = ib_query_device(hca, device_attr); |
| 1140 | if (result) { |
| 1141 | printk(KERN_WARNING "%s: ib_query_device failed (ret = %d)\n", |
| 1142 | hca->name, result); |
| 1143 | kfree(device_attr); |
| 1144 | goto device_init_failed; |
| 1145 | } |
Eli Cohen | 40ca198 | 2008-04-16 21:09:27 -0700 | [diff] [blame] | 1146 | priv->hca_caps = device_attr->device_cap_flags; |
Eli Cohen | 6046136 | 2008-04-16 21:01:10 -0700 | [diff] [blame] | 1147 | |
Eli Cohen | 40ca198 | 2008-04-16 21:09:27 -0700 | [diff] [blame] | 1148 | kfree(device_attr); |
| 1149 | |
| 1150 | if (priv->hca_caps & IB_DEVICE_UD_IP_CSUM) { |
Eli Cohen | 6046136 | 2008-04-16 21:01:10 -0700 | [diff] [blame] | 1151 | set_bit(IPOIB_FLAG_CSUM, &priv->flags); |
| 1152 | priv->dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM; |
| 1153 | } |
| 1154 | |
Roland Dreier | 4ce0593 | 2005-08-19 12:03:17 -0700 | [diff] [blame] | 1155 | /* |
| 1156 | * Set the full membership bit, so that we join the right |
| 1157 | * broadcast group, etc. |
| 1158 | */ |
| 1159 | priv->pkey |= 0x8000; |
| 1160 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1161 | priv->dev->broadcast[8] = priv->pkey >> 8; |
| 1162 | priv->dev->broadcast[9] = priv->pkey & 0xff; |
| 1163 | |
| 1164 | result = ib_query_gid(hca, port, 0, &priv->local_gid); |
| 1165 | if (result) { |
| 1166 | printk(KERN_WARNING "%s: ib_query_gid port %d failed (ret = %d)\n", |
| 1167 | hca->name, port, result); |
Eli Cohen | ca6de17 | 2007-08-21 18:46:10 +0300 | [diff] [blame] | 1168 | goto device_init_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1169 | } else |
| 1170 | memcpy(priv->dev->dev_addr + 4, priv->local_gid.raw, sizeof (union ib_gid)); |
| 1171 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1172 | result = ipoib_dev_init(priv->dev, hca, port); |
| 1173 | if (result < 0) { |
| 1174 | printk(KERN_WARNING "%s: failed to initialize port %d (ret = %d)\n", |
| 1175 | hca->name, port, result); |
| 1176 | goto device_init_failed; |
| 1177 | } |
| 1178 | |
| 1179 | INIT_IB_EVENT_HANDLER(&priv->event_handler, |
| 1180 | priv->ca, ipoib_event); |
| 1181 | result = ib_register_event_handler(&priv->event_handler); |
| 1182 | if (result < 0) { |
| 1183 | printk(KERN_WARNING "%s: ib_register_event_handler failed for " |
| 1184 | "port %d (ret = %d)\n", |
| 1185 | hca->name, port, result); |
| 1186 | goto event_failed; |
| 1187 | } |
| 1188 | |
Eli Cohen | 40ca198 | 2008-04-16 21:09:27 -0700 | [diff] [blame] | 1189 | if (priv->dev->features & NETIF_F_SG && priv->hca_caps & IB_DEVICE_UD_TSO) |
| 1190 | priv->dev->features |= NETIF_F_TSO; |
| 1191 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1192 | result = register_netdev(priv->dev); |
| 1193 | if (result) { |
| 1194 | printk(KERN_WARNING "%s: couldn't register ipoib port %d; error %d\n", |
| 1195 | hca->name, port, result); |
| 1196 | goto register_failed; |
| 1197 | } |
| 1198 | |
Roland Dreier | 1732b0e | 2005-11-07 10:33:11 -0800 | [diff] [blame] | 1199 | ipoib_create_debug_files(priv->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1200 | |
Michael S. Tsirkin | 839fcab | 2007-02-05 22:12:23 +0200 | [diff] [blame] | 1201 | if (ipoib_cm_add_mode_attr(priv->dev)) |
| 1202 | goto sysfs_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1203 | if (ipoib_add_pkey_attr(priv->dev)) |
| 1204 | goto sysfs_failed; |
Or Gerlitz | 335a64a5a | 2007-10-08 10:13:00 +0200 | [diff] [blame] | 1205 | if (ipoib_add_umcast_attr(priv->dev)) |
| 1206 | goto sysfs_failed; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1207 | if (device_create_file(&priv->dev->dev, &dev_attr_create_child)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1208 | goto sysfs_failed; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1209 | if (device_create_file(&priv->dev->dev, &dev_attr_delete_child)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1210 | goto sysfs_failed; |
| 1211 | |
| 1212 | return priv->dev; |
| 1213 | |
| 1214 | sysfs_failed: |
Roland Dreier | 1732b0e | 2005-11-07 10:33:11 -0800 | [diff] [blame] | 1215 | ipoib_delete_debug_files(priv->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1216 | unregister_netdev(priv->dev); |
| 1217 | |
| 1218 | register_failed: |
| 1219 | ib_unregister_event_handler(&priv->event_handler); |
Michael S. Tsirkin | 51574e0 | 2005-09-12 09:52:28 -0700 | [diff] [blame] | 1220 | flush_scheduled_work(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | |
| 1222 | event_failed: |
| 1223 | ipoib_dev_cleanup(priv->dev); |
| 1224 | |
| 1225 | device_init_failed: |
| 1226 | free_netdev(priv->dev); |
| 1227 | |
| 1228 | alloc_mem_failed: |
| 1229 | return ERR_PTR(result); |
| 1230 | } |
| 1231 | |
| 1232 | static void ipoib_add_one(struct ib_device *device) |
| 1233 | { |
| 1234 | struct list_head *dev_list; |
| 1235 | struct net_device *dev; |
| 1236 | struct ipoib_dev_priv *priv; |
| 1237 | int s, e, p; |
| 1238 | |
Tom Tucker | 07ebafb | 2006-08-03 16:02:42 -0500 | [diff] [blame] | 1239 | if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) |
| 1240 | return; |
| 1241 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1242 | dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL); |
| 1243 | if (!dev_list) |
| 1244 | return; |
| 1245 | |
| 1246 | INIT_LIST_HEAD(dev_list); |
| 1247 | |
Tom Tucker | 07ebafb | 2006-08-03 16:02:42 -0500 | [diff] [blame] | 1248 | if (device->node_type == RDMA_NODE_IB_SWITCH) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | s = 0; |
| 1250 | e = 0; |
| 1251 | } else { |
| 1252 | s = 1; |
| 1253 | e = device->phys_port_cnt; |
| 1254 | } |
| 1255 | |
| 1256 | for (p = s; p <= e; ++p) { |
| 1257 | dev = ipoib_add_port("ib%d", device, p); |
| 1258 | if (!IS_ERR(dev)) { |
| 1259 | priv = netdev_priv(dev); |
| 1260 | list_add_tail(&priv->list, dev_list); |
| 1261 | } |
| 1262 | } |
| 1263 | |
| 1264 | ib_set_client_data(device, &ipoib_client, dev_list); |
| 1265 | } |
| 1266 | |
| 1267 | static void ipoib_remove_one(struct ib_device *device) |
| 1268 | { |
| 1269 | struct ipoib_dev_priv *priv, *tmp; |
| 1270 | struct list_head *dev_list; |
| 1271 | |
Tom Tucker | 07ebafb | 2006-08-03 16:02:42 -0500 | [diff] [blame] | 1272 | if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) |
| 1273 | return; |
| 1274 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1275 | dev_list = ib_get_client_data(device, &ipoib_client); |
| 1276 | |
| 1277 | list_for_each_entry_safe(priv, tmp, dev_list, list) { |
| 1278 | ib_unregister_event_handler(&priv->event_handler); |
Michael S. Tsirkin | 51574e0 | 2005-09-12 09:52:28 -0700 | [diff] [blame] | 1279 | flush_scheduled_work(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1280 | |
| 1281 | unregister_netdev(priv->dev); |
| 1282 | ipoib_dev_cleanup(priv->dev); |
| 1283 | free_netdev(priv->dev); |
| 1284 | } |
Michael S. Tsirkin | 06c56e4 | 2005-09-01 09:19:02 -0700 | [diff] [blame] | 1285 | |
| 1286 | kfree(dev_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1287 | } |
| 1288 | |
| 1289 | static int __init ipoib_init_module(void) |
| 1290 | { |
| 1291 | int ret; |
| 1292 | |
Shirley Ma | 0f48525 | 2006-04-10 09:43:58 -0700 | [diff] [blame] | 1293 | ipoib_recvq_size = roundup_pow_of_two(ipoib_recvq_size); |
| 1294 | ipoib_recvq_size = min(ipoib_recvq_size, IPOIB_MAX_QUEUE_SIZE); |
| 1295 | ipoib_recvq_size = max(ipoib_recvq_size, IPOIB_MIN_QUEUE_SIZE); |
| 1296 | |
| 1297 | ipoib_sendq_size = roundup_pow_of_two(ipoib_sendq_size); |
| 1298 | ipoib_sendq_size = min(ipoib_sendq_size, IPOIB_MAX_QUEUE_SIZE); |
Eli Cohen | f56bcd8 | 2008-04-29 13:46:53 -0700 | [diff] [blame] | 1299 | ipoib_sendq_size = max(ipoib_sendq_size, max(2 * MAX_SEND_CQE, |
| 1300 | IPOIB_MIN_QUEUE_SIZE)); |
Pradeep Satyanarayana | 68e995a | 2008-01-25 14:15:24 -0800 | [diff] [blame] | 1301 | #ifdef CONFIG_INFINIBAND_IPOIB_CM |
| 1302 | ipoib_max_conn_qp = min(ipoib_max_conn_qp, IPOIB_CM_MAX_CONN_QP); |
| 1303 | #endif |
Shirley Ma | 0f48525 | 2006-04-10 09:43:58 -0700 | [diff] [blame] | 1304 | |
Eli Cohen | f89271da | 2008-07-14 23:48:44 -0700 | [diff] [blame^] | 1305 | /* |
| 1306 | * When copying small received packets, we only copy from the |
| 1307 | * linear data part of the SKB, so we rely on this condition. |
| 1308 | */ |
| 1309 | BUILD_BUG_ON(IPOIB_CM_COPYBREAK > IPOIB_CM_HEAD_SIZE); |
| 1310 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1311 | ret = ipoib_register_debugfs(); |
| 1312 | if (ret) |
| 1313 | return ret; |
| 1314 | |
| 1315 | /* |
| 1316 | * We create our own workqueue mainly because we want to be |
| 1317 | * able to flush it when devices are being removed. We can't |
| 1318 | * use schedule_work()/flush_scheduled_work() because both |
| 1319 | * unregister_netdev() and linkwatch_event take the rtnl lock, |
| 1320 | * so flush_scheduled_work() can deadlock during device |
| 1321 | * removal. |
| 1322 | */ |
| 1323 | ipoib_workqueue = create_singlethread_workqueue("ipoib"); |
| 1324 | if (!ipoib_workqueue) { |
| 1325 | ret = -ENOMEM; |
| 1326 | goto err_fs; |
| 1327 | } |
| 1328 | |
Michael S. Tsirkin | c1a0b23 | 2006-08-21 16:40:12 -0700 | [diff] [blame] | 1329 | ib_sa_register_client(&ipoib_sa_client); |
| 1330 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1331 | ret = ib_register_client(&ipoib_client); |
| 1332 | if (ret) |
Michael S. Tsirkin | c1a0b23 | 2006-08-21 16:40:12 -0700 | [diff] [blame] | 1333 | goto err_sa; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | |
| 1335 | return 0; |
| 1336 | |
Michael S. Tsirkin | c1a0b23 | 2006-08-21 16:40:12 -0700 | [diff] [blame] | 1337 | err_sa: |
| 1338 | ib_sa_unregister_client(&ipoib_sa_client); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1339 | destroy_workqueue(ipoib_workqueue); |
| 1340 | |
Roland Dreier | 9adec1a | 2005-04-16 15:26:07 -0700 | [diff] [blame] | 1341 | err_fs: |
| 1342 | ipoib_unregister_debugfs(); |
| 1343 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | return ret; |
| 1345 | } |
| 1346 | |
| 1347 | static void __exit ipoib_cleanup_module(void) |
| 1348 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1349 | ib_unregister_client(&ipoib_client); |
Michael S. Tsirkin | c1a0b23 | 2006-08-21 16:40:12 -0700 | [diff] [blame] | 1350 | ib_sa_unregister_client(&ipoib_sa_client); |
Roland Dreier | 9adec1a | 2005-04-16 15:26:07 -0700 | [diff] [blame] | 1351 | ipoib_unregister_debugfs(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1352 | destroy_workqueue(ipoib_workqueue); |
| 1353 | } |
| 1354 | |
| 1355 | module_init(ipoib_init_module); |
| 1356 | module_exit(ipoib_cleanup_module); |