@@ -10158,25 +10158,12 @@ int register_netdevice(struct net_device *dev)
1015810158}
1015910159EXPORT_SYMBOL (register_netdevice );
1016010160
10161- /**
10162- * init_dummy_netdev - init a dummy network device for NAPI
10163- * @dev: device to init
10164- *
10165- * This takes a network device structure and initialize the minimum
10166- * amount of fields so it can be used to schedule NAPI polls without
10167- * registering a full blown interface. This is to be used by drivers
10168- * that need to tie several hardware interfaces to a single NAPI
10169- * poll scheduler due to HW limitations.
10161+ /* Initialize the core of a dummy net device.
10162+ * This is useful if you are calling this function after alloc_netdev(),
10163+ * since it does not memset the net_device fields.
1017010164 */
10171- int init_dummy_netdev (struct net_device * dev )
10165+ static void init_dummy_netdev_core (struct net_device * dev )
1017210166{
10173- /* Clear everything. Note we don't initialize spinlocks
10174- * are they aren't supposed to be taken by any of the
10175- * NAPI code and this dummy netdev is supposed to be
10176- * only ever used for NAPI polls
10177- */
10178- memset (dev , 0 , sizeof (struct net_device ));
10179-
1018010167 /* make sure we BUG if trying to hit standard
1018110168 * register/unregister code path
1018210169 */
@@ -10196,12 +10183,30 @@ int init_dummy_netdev(struct net_device *dev)
1019610183 * because users of this 'device' dont need to change
1019710184 * its refcount.
1019810185 */
10186+ }
1019910187
10200- return 0 ;
10188+ /**
10189+ * init_dummy_netdev - init a dummy network device for NAPI
10190+ * @dev: device to init
10191+ *
10192+ * This takes a network device structure and initializes the minimum
10193+ * amount of fields so it can be used to schedule NAPI polls without
10194+ * registering a full blown interface. This is to be used by drivers
10195+ * that need to tie several hardware interfaces to a single NAPI
10196+ * poll scheduler due to HW limitations.
10197+ */
10198+ void init_dummy_netdev (struct net_device * dev )
10199+ {
10200+ /* Clear everything. Note we don't initialize spinlocks
10201+ * as they aren't supposed to be taken by any of the
10202+ * NAPI code and this dummy netdev is supposed to be
10203+ * only ever used for NAPI polls
10204+ */
10205+ memset (dev , 0 , sizeof (struct net_device ));
10206+ init_dummy_netdev_core (dev );
1020110207}
1020210208EXPORT_SYMBOL_GPL (init_dummy_netdev );
1020310209
10204-
1020510210/**
1020610211 * register_netdev - register a network device
1020710212 * @dev: device to register
@@ -10776,7 +10781,8 @@ void free_netdev(struct net_device *dev)
1077610781 dev -> xdp_bulkq = NULL ;
1077710782
1077810783 /* Compatibility with error handling in drivers */
10779- if (dev -> reg_state == NETREG_UNINITIALIZED ) {
10784+ if (dev -> reg_state == NETREG_UNINITIALIZED ||
10785+ dev -> reg_state == NETREG_DUMMY ) {
1078010786 netdev_freemem (dev );
1078110787 return ;
1078210788 }
@@ -10789,6 +10795,19 @@ void free_netdev(struct net_device *dev)
1078910795}
1079010796EXPORT_SYMBOL (free_netdev );
1079110797
10798+ /**
10799+ * alloc_netdev_dummy - Allocate and initialize a dummy net device.
10800+ * @sizeof_priv: size of private data to allocate space for
10801+ *
10802+ * Return: the allocated net_device on success, NULL otherwise
10803+ */
10804+ struct net_device * alloc_netdev_dummy (int sizeof_priv )
10805+ {
10806+ return alloc_netdev (sizeof_priv , "dummy#" , NET_NAME_UNKNOWN ,
10807+ init_dummy_netdev_core );
10808+ }
10809+ EXPORT_SYMBOL_GPL (alloc_netdev_dummy );
10810+
1079210811/**
1079310812 * synchronize_net - Synchronize with packet receive processing
1079410813 *
0 commit comments