diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-01-15 00:05:05 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-01-15 00:05:05 -0500 |
commit | 937f1ba56b4be37d9e2ad77412f95048662058d2 (patch) | |
tree | 154e0c5ce11b5afe25816d667c76b19ac679d530 /net | |
parent | 2950e952920811be465ec95c6b56f03dc66a05c0 (diff) |
net: Add init_dummy_netdev() and fix EMAC driver using it
This adds an init_dummy_netdev() function that gets a network device
structure (allocation and lifetime entirely under caller's control) and
initialize the minimum amount of fields so it can be used to schedule
NAPI polls without registering a full blown interface. This is to be
used by drivers that need to tie several hardware interfaces to a single
NAPI poll scheduler due to HW limitations.
It also updates the ibm_newemac driver to use that, this fixing the
oops on 2.6.29 due to passing NULL as "dev" to netif_napi_add()
Symbol is exported GPL only a I don't think we want binary drivers doing
that sort of acrobatics (if we want them at all).
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Tested-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/dev.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 60377b6c0a80..8d675975d85b 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -4431,6 +4431,45 @@ err_uninit: | |||
4431 | } | 4431 | } |
4432 | 4432 | ||
4433 | /** | 4433 | /** |
4434 | * init_dummy_netdev - init a dummy network device for NAPI | ||
4435 | * @dev: device to init | ||
4436 | * | ||
4437 | * This takes a network device structure and initialize the minimum | ||
4438 | * amount of fields so it can be used to schedule NAPI polls without | ||
4439 | * registering a full blown interface. This is to be used by drivers | ||
4440 | * that need to tie several hardware interfaces to a single NAPI | ||
4441 | * poll scheduler due to HW limitations. | ||
4442 | */ | ||
4443 | int init_dummy_netdev(struct net_device *dev) | ||
4444 | { | ||
4445 | /* Clear everything. Note we don't initialize spinlocks | ||
4446 | * are they aren't supposed to be taken by any of the | ||
4447 | * NAPI code and this dummy netdev is supposed to be | ||
4448 | * only ever used for NAPI polls | ||
4449 | */ | ||
4450 | memset(dev, 0, sizeof(struct net_device)); | ||
4451 | |||
4452 | /* make sure we BUG if trying to hit standard | ||
4453 | * register/unregister code path | ||
4454 | */ | ||
4455 | dev->reg_state = NETREG_DUMMY; | ||
4456 | |||
4457 | /* initialize the ref count */ | ||
4458 | atomic_set(&dev->refcnt, 1); | ||
4459 | |||
4460 | /* NAPI wants this */ | ||
4461 | INIT_LIST_HEAD(&dev->napi_list); | ||
4462 | |||
4463 | /* a dummy interface is started by default */ | ||
4464 | set_bit(__LINK_STATE_PRESENT, &dev->state); | ||
4465 | set_bit(__LINK_STATE_START, &dev->state); | ||
4466 | |||
4467 | return 0; | ||
4468 | } | ||
4469 | EXPORT_SYMBOL_GPL(init_dummy_netdev); | ||
4470 | |||
4471 | |||
4472 | /** | ||
4434 | * register_netdev - register a network device | 4473 | * register_netdev - register a network device |
4435 | * @dev: device to register | 4474 | * @dev: device to register |
4436 | * | 4475 | * |