]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: remove init_dummy_netdev()
authorJakub Kicinski <kuba@kernel.org>
Mon, 13 Jan 2025 00:34:55 +0000 (16:34 -0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 14 Jan 2025 03:06:51 +0000 (19:06 -0800)
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 <aleksander.lobakin@intel.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Reviewed-by: Joe Damato <jdamato@fastly.com>
Link: https://patch.msgid.link/20250113003456.3904110-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/netdevice.h
net/core/dev.c
net/mptcp/protocol.c
net/xfrm/xfrm_input.c

index aeb4a6cff171820982321f912a07ac36d56fe77d..dd8f6f8991feeac2ff57e864c36d7ce82fb7a87f 100644 (file)
@@ -3238,7 +3238,6 @@ static inline void unregister_netdevice(struct net_device *dev)
 
 int netdev_refcnt_read(const struct net_device *dev);
 void free_netdev(struct net_device *dev);
-void init_dummy_netdev(struct net_device *dev);
 
 struct net_device *netdev_get_xmit_slave(struct net_device *dev,
                                         struct sk_buff *skb,
index 1a90ed8cc6cc29452ea85973b6229210d184098a..c9abc9fc770e27d6213993bf6aa8e5192f6e9ed2 100644 (file)
@@ -10762,28 +10762,6 @@ static void init_dummy_netdev_core(struct net_device *dev)
         */
 }
 
-/**
- *     init_dummy_netdev       - init a dummy network device for NAPI
- *     @dev: device to init
- *
- *     This takes a network device structure and initializes 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.
- */
-void init_dummy_netdev(struct net_device *dev)
-{
-       /* Clear everything. Note we don't initialize spinlocks
-        * as 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));
-       init_dummy_netdev_core(dev);
-}
-EXPORT_SYMBOL_GPL(init_dummy_netdev);
-
 /**
  *     register_netdev - register a network device
  *     @dev: device to register
index 1b2e7cbb577fc26280f31e58adceb36987112f54..c44c89ecaca658bd2a2fdbfd72bfa2d33a8d95ea 100644 (file)
@@ -47,7 +47,7 @@ static void __mptcp_destroy_sock(struct sock *sk);
 static void mptcp_check_send_data_fin(struct sock *sk);
 
 DEFINE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions);
-static struct net_device mptcp_napi_dev;
+static struct net_device *mptcp_napi_dev;
 
 /* Returns end sequence number of the receiver's advertised window */
 static u64 mptcp_wnd_end(const struct mptcp_sock *msk)
@@ -4147,11 +4147,13 @@ void __init mptcp_proto_init(void)
        if (percpu_counter_init(&mptcp_sockets_allocated, 0, GFP_KERNEL))
                panic("Failed to allocate MPTCP pcpu counter\n");
 
-       init_dummy_netdev(&mptcp_napi_dev);
+       mptcp_napi_dev = alloc_netdev_dummy(0);
+       if (!mptcp_napi_dev)
+               panic("Failed to allocate MPTCP dummy netdev\n");
        for_each_possible_cpu(cpu) {
                delegated = per_cpu_ptr(&mptcp_delegated_actions, cpu);
                INIT_LIST_HEAD(&delegated->head);
-               netif_napi_add_tx(&mptcp_napi_dev, &delegated->napi,
+               netif_napi_add_tx(mptcp_napi_dev, &delegated->napi,
                                  mptcp_napi_poll);
                napi_enable(&delegated->napi);
        }
index 2c4ae61e7e3a0114c5d8d914efc6bc28dbe5634c..7e6a71b9d6a3ae2ff1a2742ca620729128823a06 100644 (file)
@@ -48,7 +48,7 @@ static DEFINE_SPINLOCK(xfrm_input_afinfo_lock);
 static struct xfrm_input_afinfo const __rcu *xfrm_input_afinfo[2][AF_INET6 + 1];
 
 static struct gro_cells gro_cells;
-static struct net_device xfrm_napi_dev;
+static struct net_device *xfrm_napi_dev;
 
 static DEFINE_PER_CPU(struct xfrm_trans_tasklet, xfrm_trans_tasklet);
 
@@ -825,8 +825,11 @@ void __init xfrm_input_init(void)
        int err;
        int i;
 
-       init_dummy_netdev(&xfrm_napi_dev);
-       err = gro_cells_init(&gro_cells, &xfrm_napi_dev);
+       xfrm_napi_dev = alloc_netdev_dummy(0);
+       if (!xfrm_napi_dev)
+               panic("Failed to allocate XFRM dummy netdev\n");
+
+       err = gro_cells_init(&gro_cells, xfrm_napi_dev);
        if (err)
                gro_cells.cells = NULL;