Skip to content

Commit f835bda

Browse files
committed
net: remove init_dummy_netdev()
init_dummy_netdev() can initialize statically declared or embedded net_devices. Such netdevs did not come from alloc_netdev_mqs(). After recent work by Breno, there are the only two cases where we have do that. Switch those cases to alloc_netdev_mqs() and delete init_dummy_netdev(). Dealing with static netdevs is not worth the maintenance burden. Reviewed-by: Alexander Lobakin <[email protected]> Reviewed-by: Matthieu Baerts (NGI0) <[email protected]> Reviewed-by: Joe Damato <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b1b62d6 commit f835bda

File tree

4 files changed

+11
-29
lines changed

4 files changed

+11
-29
lines changed

include/linux/netdevice.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3238,7 +3238,6 @@ static inline void unregister_netdevice(struct net_device *dev)
32383238

32393239
int netdev_refcnt_read(const struct net_device *dev);
32403240
void free_netdev(struct net_device *dev);
3241-
void init_dummy_netdev(struct net_device *dev);
32423241

32433242
struct net_device *netdev_get_xmit_slave(struct net_device *dev,
32443243
struct sk_buff *skb,

net/core/dev.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10762,28 +10762,6 @@ static void init_dummy_netdev_core(struct net_device *dev)
1076210762
*/
1076310763
}
1076410764

10765-
/**
10766-
* init_dummy_netdev - init a dummy network device for NAPI
10767-
* @dev: device to init
10768-
*
10769-
* This takes a network device structure and initializes the minimum
10770-
* amount of fields so it can be used to schedule NAPI polls without
10771-
* registering a full blown interface. This is to be used by drivers
10772-
* that need to tie several hardware interfaces to a single NAPI
10773-
* poll scheduler due to HW limitations.
10774-
*/
10775-
void init_dummy_netdev(struct net_device *dev)
10776-
{
10777-
/* Clear everything. Note we don't initialize spinlocks
10778-
* as they aren't supposed to be taken by any of the
10779-
* NAPI code and this dummy netdev is supposed to be
10780-
* only ever used for NAPI polls
10781-
*/
10782-
memset(dev, 0, sizeof(struct net_device));
10783-
init_dummy_netdev_core(dev);
10784-
}
10785-
EXPORT_SYMBOL_GPL(init_dummy_netdev);
10786-
1078710765
/**
1078810766
* register_netdev - register a network device
1078910767
* @dev: device to register

net/mptcp/protocol.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static void __mptcp_destroy_sock(struct sock *sk);
4747
static void mptcp_check_send_data_fin(struct sock *sk);
4848

4949
DEFINE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions);
50-
static struct net_device mptcp_napi_dev;
50+
static struct net_device *mptcp_napi_dev;
5151

5252
/* Returns end sequence number of the receiver's advertised window */
5353
static u64 mptcp_wnd_end(const struct mptcp_sock *msk)
@@ -4147,11 +4147,13 @@ void __init mptcp_proto_init(void)
41474147
if (percpu_counter_init(&mptcp_sockets_allocated, 0, GFP_KERNEL))
41484148
panic("Failed to allocate MPTCP pcpu counter\n");
41494149

4150-
init_dummy_netdev(&mptcp_napi_dev);
4150+
mptcp_napi_dev = alloc_netdev_dummy(0);
4151+
if (!mptcp_napi_dev)
4152+
panic("Failed to allocate MPTCP dummy netdev\n");
41514153
for_each_possible_cpu(cpu) {
41524154
delegated = per_cpu_ptr(&mptcp_delegated_actions, cpu);
41534155
INIT_LIST_HEAD(&delegated->head);
4154-
netif_napi_add_tx(&mptcp_napi_dev, &delegated->napi,
4156+
netif_napi_add_tx(mptcp_napi_dev, &delegated->napi,
41554157
mptcp_napi_poll);
41564158
napi_enable(&delegated->napi);
41574159
}

net/xfrm/xfrm_input.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static DEFINE_SPINLOCK(xfrm_input_afinfo_lock);
4848
static struct xfrm_input_afinfo const __rcu *xfrm_input_afinfo[2][AF_INET6 + 1];
4949

5050
static struct gro_cells gro_cells;
51-
static struct net_device xfrm_napi_dev;
51+
static struct net_device *xfrm_napi_dev;
5252

5353
static DEFINE_PER_CPU(struct xfrm_trans_tasklet, xfrm_trans_tasklet);
5454

@@ -825,8 +825,11 @@ void __init xfrm_input_init(void)
825825
int err;
826826
int i;
827827

828-
init_dummy_netdev(&xfrm_napi_dev);
829-
err = gro_cells_init(&gro_cells, &xfrm_napi_dev);
828+
xfrm_napi_dev = alloc_netdev_dummy(0);
829+
if (!xfrm_napi_dev)
830+
panic("Failed to allocate XFRM dummy netdev\n");
831+
832+
err = gro_cells_init(&gro_cells, xfrm_napi_dev);
830833
if (err)
831834
gro_cells.cells = NULL;
832835

0 commit comments

Comments
 (0)