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>
This commit is contained in:
committed by
David S. Miller
parent
2950e95292
commit
937f1ba56b
@@ -4430,6 +4430,45 @@ err_uninit:
|
||||
goto out;
|
||||
}
|
||||
|
||||
/**
|
||||
* init_dummy_netdev - init a dummy network device for NAPI
|
||||
* @dev: device to init
|
||||
*
|
||||
* This takes a network device structure 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.
|
||||
*/
|
||||
int init_dummy_netdev(struct net_device *dev)
|
||||
{
|
||||
/* Clear everything. Note we don't initialize spinlocks
|
||||
* are they aren't supposed to be taken by any of the
|
||||
* NAPI code and this dummy netdev is supposed to be
|
||||
* only ever used for NAPI polls
|
||||
*/
|
||||
memset(dev, 0, sizeof(struct net_device));
|
||||
|
||||
/* make sure we BUG if trying to hit standard
|
||||
* register/unregister code path
|
||||
*/
|
||||
dev->reg_state = NETREG_DUMMY;
|
||||
|
||||
/* initialize the ref count */
|
||||
atomic_set(&dev->refcnt, 1);
|
||||
|
||||
/* NAPI wants this */
|
||||
INIT_LIST_HEAD(&dev->napi_list);
|
||||
|
||||
/* a dummy interface is started by default */
|
||||
set_bit(__LINK_STATE_PRESENT, &dev->state);
|
||||
set_bit(__LINK_STATE_START, &dev->state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(init_dummy_netdev);
|
||||
|
||||
|
||||
/**
|
||||
* register_netdev - register a network device
|
||||
* @dev: device to register
|
||||
|
Reference in New Issue
Block a user