:sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget)/translations/zh_CN/networking/netdevicesmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget)/translations/zh_TW/networking/netdevicesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget)/translations/it_IT/networking/netdevicesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget)/translations/ja_JP/networking/netdevicesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget)/translations/ko_KR/networking/netdevicesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hPortuguese (Brazilian)}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget)/translations/pt_BR/networking/netdevicesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget)/translations/sp_SP/networking/netdevicesmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhC/var/lib/git/docbuild/linux/Documentation/networking/netdevices.rsthKubhsection)}(hhh](htitle)}(h%Network Devices, the Kernel, and You!h]h%Network Devices, the Kernel, and You!}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h Introductionh]h Introduction}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhK ubh paragraph)}(hvThe following is a random collection of documentation regarding network devices. It is intended for driver developers.h]hvThe following is a random collection of documentation regarding network devices. It is intended for driver developers.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubeh}(h] introductionah ]h"] introductionah$]h&]uh1hhhhhhhhK ubh)}(hhh](h)}(h struct net_device lifetime rulesh]h struct net_device lifetime rules}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXINetwork device structures need to persist even after module is unloaded and must be allocated with alloc_netdev_mqs() and friends. If device has registered successfully, it will be freed on last use by free_netdev(). This is required to handle the pathological case cleanly (example: ``rmmod mydriver hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj$ubh and }(hj$hhhNhNubj )}(h``priv_destructor``h]hpriv_destructor}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj$ubh members for freeing of state.}(hj$hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK[hjhhubh)}(h4Example flow of netdev handling under ``rtnl_lock``:h](h&Example flow of netdev handling under }(hjhhhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1jhjhubh:}(hjhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK`hjhhubj)}(hX"static void my_setup(struct net_device *dev) { dev->needs_free_netdev = true; } static void my_destructor(struct net_device *dev) { some_obj_destroy(priv->obj); some_uninit(priv); } int create_link() { struct my_device_priv *priv; int err; ASSERT_RTNL(); dev = alloc_netdev(sizeof(*priv), "net%d", NET_NAME_UNKNOWN, my_setup); if (!dev) return -ENOMEM; priv = netdev_priv(dev); /* Implicit constructor */ err = some_init(priv); if (err) goto err_free_dev; priv->obj = some_obj_create(); if (!priv->obj) { err = -ENOMEM; goto err_some_uninit; } /* End of constructor, set the destructor: */ dev->priv_destructor = my_destructor; err = register_netdevice(dev); if (err) /* register_netdevice() calls destructor on failure */ goto err_free_dev; /* If anything fails now unregister_netdevice() (or unregister_netdev()) * will take care of calling my_destructor and free_netdev(). */ return 0; err_some_uninit: some_uninit(priv); err_free_dev: free_netdev(dev); return err; }h]hX"static void my_setup(struct net_device *dev) { dev->needs_free_netdev = true; } static void my_destructor(struct net_device *dev) { some_obj_destroy(priv->obj); some_uninit(priv); } int create_link() { struct my_device_priv *priv; int err; ASSERT_RTNL(); dev = alloc_netdev(sizeof(*priv), "net%d", NET_NAME_UNKNOWN, my_setup); if (!dev) return -ENOMEM; priv = netdev_priv(dev); /* Implicit constructor */ err = some_init(priv); if (err) goto err_free_dev; priv->obj = some_obj_create(); if (!priv->obj) { err = -ENOMEM; goto err_some_uninit; } /* End of constructor, set the destructor: */ dev->priv_destructor = my_destructor; err = register_netdevice(dev); if (err) /* register_netdevice() calls destructor on failure */ goto err_free_dev; /* If anything fails now unregister_netdevice() (or unregister_netdev()) * will take care of calling my_destructor and free_netdev(). */ return 0; err_some_uninit: some_uninit(priv); err_free_dev: free_netdev(dev); return err; }}hjsbah}(h]h ]h"]h$]h&]hhjjjj}uh1jhhhKbhjhhubh)}(hIf struct net_device.priv_destructor is set it will be called by the core some time after unregister_netdevice(), it will also be called if register_netdevice() fails. The callback may be invoked with or without ``rtnl_lock`` held.h](hIf struct net_device.priv_destructor is set it will be called by the core some time after unregister_netdevice(), it will also be called if register_netdevice() fails. The callback may be invoked with or without }(hjhhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh held.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThere is no explicit constructor callback, driver "constructs" the private netdev state after allocating it and before registration.h]hThere is no explicit constructor callback, driver “constructs” the private netdev state after allocating it and before registration.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hX7Setting struct net_device.needs_free_netdev makes core call free_netdev() automatically after unregister_netdevice() when all references to the device are gone. It only takes effect after a successful call to register_netdevice() so if register_netdevice() fails driver is responsible for calling free_netdev().h]hX7Setting struct net_device.needs_free_netdev makes core call free_netdev() automatically after unregister_netdevice() when all references to the device are gone. It only takes effect after a successful call to register_netdevice() so if register_netdevice() fails driver is responsible for calling free_netdev().}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hX.free_netdev() is safe to call on error paths right after unregister_netdevice() or when register_netdevice() fails. Parts of netdev (de)registration process happen after ``rtnl_lock`` is released, therefore in those cases free_netdev() will defer some of the processing until ``rtnl_lock`` is released.h](hfree_netdev() is safe to call on error paths right after unregister_netdevice() or when register_netdevice() fails. Parts of netdev (de)registration process happen after }(hjhhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh] is released, therefore in those cases free_netdev() will defer some of the processing until }(hjhhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh is released.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h[Devices spawned from struct rtnl_link_ops should never free the struct net_device directly.h]h[Devices spawned from struct rtnl_link_ops should never free the struct net_device directly.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hhh](h)}(h.ndo_init and .ndo_uninith]h.ndo_init and .ndo_uninit}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(h``.ndo_init`` and ``.ndo_uninit`` callbacks are called during net_device registration and de-registration, under ``rtnl_lock``. Drivers can use those e.g. when parts of their init process need to run under ``rtnl_lock``.h](j )}(h ``.ndo_init``h]h .ndo_init}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj$ubh and }(hj$hhhNhNubj )}(h``.ndo_uninit``h]h .ndo_uninit}(hj:hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj$ubhP callbacks are called during net_device registration and de-registration, under }(hj$hhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj$ubhP. Drivers can use those e.g. when parts of their init process need to run under }(hj$hhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hj^hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj$ubh.}(hj$hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h``.ndo_init`` runs before device is visible in the system, ``.ndo_uninit`` runs during de-registering after device is closed but other subsystems may still have outstanding references to the netdevice.h](j )}(h ``.ndo_init``h]h .ndo_init}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjvubh. runs before device is visible in the system, }(hjvhhhNhNubj )}(h``.ndo_uninit``h]h .ndo_uninit}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjvubh runs during de-registering after device is closed but other subsystems may still have outstanding references to the netdevice.}(hjvhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]ndo-init-and-ndo-uninitah ]h"].ndo_init and .ndo_uninitah$]h&]uh1hhjhhhhhKubeh}(h]device-management-under-rtnlah ]h"]device management under rtnlah$]h&]uh1hhjhhhhhKYubeh}(h] struct-net-device-lifetime-rulesah ]h"] struct net_device lifetime rulesah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hMTUh]hMTU}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXEach network device has a Maximum Transfer Unit. The MTU does not include any link layer protocol overhead. Upper layer protocols must not pass a socket buffer (skb) to a device to transmit with more data than the mtu. The MTU does not include link layer header overhead, so for example on Ethernet if the standard MTU is 1500 bytes used, the actual skb will contain up to 1514 bytes because of the Ethernet header. Devices should allow for the 4 byte VLAN header as well.h]hXEach network device has a Maximum Transfer Unit. The MTU does not include any link layer protocol overhead. Upper layer protocols must not pass a socket buffer (skb) to a device to transmit with more data than the mtu. The MTU does not include link layer header overhead, so for example on Ethernet if the standard MTU is 1500 bytes used, the actual skb will contain up to 1514 bytes because of the Ethernet header. Devices should allow for the 4 byte VLAN header as well.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hSegmentation Offload (GSO, TSO) is an exception to this rule. The upper layer protocol may pass a large socket buffer to the device transmit routine, and the device will break that up into separate packets based on the current MTU.h]hSegmentation Offload (GSO, TSO) is an exception to this rule. The upper layer protocol may pass a large socket buffer to the device transmit routine, and the device will break that up into separate packets based on the current MTU.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXMTU is symmetrical and applies both to receive and transmit. A device must be able to receive at least the maximum size packet allowed by the MTU. A network device may use the MTU as mechanism to size receive buffers, but the device should allow packets with VLAN header. With standard Ethernet mtu of 1500 bytes, the device should allow up to 1518 byte packets (1500 + 14 header + 4 tag). The device may either: drop, truncate, or pass up oversize packets, but dropping oversize packets is preferred.h]hXMTU is symmetrical and applies both to receive and transmit. A device must be able to receive at least the maximum size packet allowed by the MTU. A network device may use the MTU as mechanism to size receive buffers, but the device should allow packets with VLAN header. With standard Ethernet mtu of 1500 bytes, the device should allow up to 1518 byte packets (1500 + 14 header + 4 tag). The device may either: drop, truncate, or pass up oversize packets, but dropping oversize packets is preferred.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]mtuah ]h"]mtuah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h'struct net_device synchronization rulesh]h'struct net_device synchronization rules}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubhdefinition_list)}(hhh](hdefinition_list_item)}(hndo_open: Synchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process h](hterm)}(h ndo_open:h]h ndo_open:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjubh definition)}(hhh]h)}(hSynchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: processh]hSynchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj-ubah}(h]h ]h"]h$]h&]uh1j+hjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(hndo_stop: Synchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process Note: netif_running() is guaranteed false h](j)}(h ndo_stop:h]h ndo_stop:}(hjNhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjJubj,)}(hhh]h)}(hSynchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process Note: netif_running() is guaranteed falseh]hSynchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process Note: netif_running() is guaranteed false}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj\ubah}(h]h ]h"]h$]h&]uh1j+hjJubeh}(h]h ]h"]h$]h&]uh1jhhhKhjhhubj)}(hndo_do_ioctl: Synchronization: rtnl_lock() semaphore. This is only called by network subsystems internally, not by user space calling ioctl as it was in before linux-5.14. h](j)}(h ndo_do_ioctl:h]h ndo_do_ioctl:}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjyubj,)}(hhh](h)}(h'Synchronization: rtnl_lock() semaphore.h]h'Synchronization: rtnl_lock() semaphore.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(huThis is only called by network subsystems internally, not by user space calling ioctl as it was in before linux-5.14.h]huThis is only called by network subsystems internally, not by user space calling ioctl as it was in before linux-5.14.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1j+hjyubeh}(h]h ]h"]h$]h&]uh1jhhhKhjhhubj)}(hndo_siocbond: Synchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process Used by the bonding driver for the SIOCBOND family of ioctl commands. h](j)}(h ndo_siocbond:h]h ndo_siocbond:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjubj,)}(hhh](h)}(hSynchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: processh]hSynchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hEUsed by the bonding driver for the SIOCBOND family of ioctl commands.h]hEUsed by the bonding driver for the SIOCBOND family of ioctl commands.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1j+hjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjhhubj)}(hX ndo_siocwandev: Synchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process Used by the drivers/net/wan framework to handle the SIOCWANDEV ioctl with the if_settings structure. h](j)}(hndo_siocwandev:h]hndo_siocwandev:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjubj,)}(hhh](h)}(hSynchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: processh]hSynchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hdUsed by the drivers/net/wan framework to handle the SIOCWANDEV ioctl with the if_settings structure.h]hdUsed by the drivers/net/wan framework to handle the SIOCWANDEV ioctl with the if_settings structure.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1j+hjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjhhubj)}(hXndo_siocdevprivate: Synchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process This is used to implement SIOCDEVPRIVATE ioctl helpers. These should not be added to new drivers, so don't use. h](j)}(hndo_siocdevprivate:h]hndo_siocdevprivate:}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhj0ubj,)}(hhh](h)}(hSynchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: processh]hSynchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process}(hjEhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjBubh)}(hoThis is used to implement SIOCDEVPRIVATE ioctl helpers. These should not be added to new drivers, so don't use.h]hqThis is used to implement SIOCDEVPRIVATE ioctl helpers. These should not be added to new drivers, so don’t use.}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjBubeh}(h]h ]h"]h$]h&]uh1j+hj0ubeh}(h]h ]h"]h$]h&]uh1jhhhKhjhhubj)}(hndo_eth_ioctl: Synchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process h](j)}(hndo_eth_ioctl:h]hndo_eth_ioctl:}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjmubj,)}(hhh]h)}(hSynchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: processh]hSynchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j+hjmubeh}(h]h ]h"]h$]h&]uh1jhhhMhjhhubj)}(hndo_get_stats / ndo_get_stats64: Synchronization: RCU (can be called concurrently with the stats update path). Context: atomic (can't sleep under RCU) h](j)}(h ndo_get_stats / ndo_get_stats64:h]h ndo_get_stats / ndo_get_stats64:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjubj,)}(hhh]h)}(huSynchronization: RCU (can be called concurrently with the stats update path). Context: atomic (can't sleep under RCU)h]hwSynchronization: RCU (can be called concurrently with the stats update path). Context: atomic (can’t sleep under RCU)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j+hjubeh}(h]h ]h"]h$]h&]uh1jhhhMhjhhubj)}(hXAndo_start_xmit: Synchronization: __netif_tx_lock spinlock. When the driver sets dev->lltx this will be called without holding netif_tx_lock. dev->lltx is meant for software drivers only, since they often have no per-queue state. Context: Process with BHs disabled or BH (timer), will be called with interrupts disabled by netconsole. Return codes: * NETDEV_TX_OK everything ok. * NETDEV_TX_BUSY Cannot transmit packet, try later Usually a bug, means queue start/stop flow control is broken in the driver. Note: the driver must NOT put the skb in its DMA ring. h](j)}(hndo_start_xmit:h]hndo_start_xmit:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjubj,)}(hhh](h)}(h*Synchronization: __netif_tx_lock spinlock.h]h*Synchronization: __netif_tx_lock spinlock.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjubh)}(hWhen the driver sets dev->lltx this will be called without holding netif_tx_lock. dev->lltx is meant for software drivers only, since they often have no per-queue state.h]hWhen the driver sets dev->lltx this will be called without holding netif_tx_lock. dev->lltx is meant for software drivers only, since they often have no per-queue state.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjubj)}(hhh]j)}(hiContext: Process with BHs disabled or BH (timer), will be called with interrupts disabled by netconsole. h](j)}(h1Context: Process with BHs disabled or BH (timer),h]h1Context: Process with BHs disabled or BH (timer),}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjubj,)}(hhh]h)}(h6will be called with interrupts disabled by netconsole.h]h6will be called with interrupts disabled by netconsole.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j+hjubeh}(h]h ]h"]h$]h&]uh1jhhhMhjubah}(h]h ]h"]h$]h&]uh1jhjubh)}(h Return codes:h]h Return codes:}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh bullet_list)}(hhh](h list_item)}(hNETDEV_TX_OK everything ok.h]h)}(hjKh]hNETDEV_TX_OK everything ok.}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjIubah}(h]h ]h"]h$]h&]uh1jGhjDubjH)}(hNETDEV_TX_BUSY Cannot transmit packet, try later Usually a bug, means queue start/stop flow control is broken in the driver. Note: the driver must NOT put the skb in its DMA ring. h]h)}(hNETDEV_TX_BUSY Cannot transmit packet, try later Usually a bug, means queue start/stop flow control is broken in the driver. Note: the driver must NOT put the skb in its DMA ring.h]hNETDEV_TX_BUSY Cannot transmit packet, try later Usually a bug, means queue start/stop flow control is broken in the driver. Note: the driver must NOT put the skb in its DMA ring.}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj`ubah}(h]h ]h"]h$]h&]uh1jGhjDubeh}(h]h ]h"]h$]h&]bullet*uh1jBhhhMhjubeh}(h]h ]h"]h$]h&]uh1j+hjubeh}(h]h ]h"]h$]h&]uh1jhhhMhjhhubj)}(hndo_tx_timeout: Synchronization: netif_tx_lock spinlock; all TX queues frozen. Context: BHs disabled Notes: netif_queue_stopped() is guaranteed true h](j)}(hndo_tx_timeout:h]hndo_tx_timeout:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjubj,)}(hhh]h)}(hSynchronization: netif_tx_lock spinlock; all TX queues frozen. Context: BHs disabled Notes: netif_queue_stopped() is guaranteed trueh]hSynchronization: netif_tx_lock spinlock; all TX queues frozen. Context: BHs disabled Notes: netif_queue_stopped() is guaranteed true}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j+hjubeh}(h]h ]h"]h$]h&]uh1jhhhMhjhhubj)}(hndo_set_rx_mode: Synchronization: netif_addr_lock spinlock. Context: BHs disabled Notes: Deprecated in favor of ndo_set_rx_mode_async which runs in process context. h](j)}(hndo_set_rx_mode:h]hndo_set_rx_mode:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM$hjubj,)}(hhh]h)}(hSynchronization: netif_addr_lock spinlock. Context: BHs disabled Notes: Deprecated in favor of ndo_set_rx_mode_async which runs in process context.h]hSynchronization: netif_addr_lock spinlock. Context: BHs disabled Notes: Deprecated in favor of ndo_set_rx_mode_async which runs in process context.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM!hjubah}(h]h ]h"]h$]h&]uh1j+hjubeh}(h]h ]h"]h$]h&]uh1jhhhM$hjhhubj)}(hXEndo_set_rx_mode_async: Synchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process (from a work queue) Notes: Async version of ndo_set_rx_mode which runs in process context. Receives snapshots of the unicast and multicast address lists. h](j)}(hndo_set_rx_mode_async:h]hndo_set_rx_mode_async:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM+hjubj,)}(hhh]h)}(hX-Synchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process (from a work queue) Notes: Async version of ndo_set_rx_mode which runs in process context. Receives snapshots of the unicast and multicast address lists.h]hX-Synchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. Context: process (from a work queue) Notes: Async version of ndo_set_rx_mode which runs in process context. Receives snapshots of the unicast and multicast address lists.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM'hjubah}(h]h ]h"]h$]h&]uh1j+hjubeh}(h]h ]h"]h$]h&]uh1jhhhM+hjhhubj)}(hndo_change_rx_flags: Synchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API. h](j)}(hndo_change_rx_flags:h]hndo_change_rx_flags:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM/hjubj,)}(hhh]h)}(hSynchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API.h]hSynchronization: rtnl_lock() semaphore. In addition, netdev instance lock if the driver implements queue management or shaper API.}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM.hj+ubah}(h]h ]h"]h$]h&]uh1j+hjubeh}(h]h ]h"]h$]h&]uh1jhhhM/hjhhubj)}(hXndo_setup_tc: Locking depends on ``tc_setup_type``. For most types the callback is invoked under ``rtnl_lock`` and netdev instance lock if the driver implements queue management or shaper API. For ``TC_SETUP_BLOCK`` and ``TC_SETUP_FT`` ``rtnl_lock`` may or may not be held, and the netdev instance lock is not held. ``TC_SETUP_BLOCK`` runs under ``block->cb_lock`` and ``TC_SETUP_FT`` runs under ``flowtable->flow_block_lock``. h](j)}(h ndo_setup_tc:h]h ndo_setup_tc:}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM9hjHubj,)}(hhh](h)}(hLocking depends on ``tc_setup_type``. For most types the callback is invoked under ``rtnl_lock`` and netdev instance lock if the driver implements queue management or shaper API.h](hLocking depends on }(hj]hhhNhNubj )}(h``tc_setup_type``h]h tc_setup_type}(hjehhhNhNubah}(h]h ]h"]h$]h&]uh1jhj]ubh/. For most types the callback is invoked under }(hj]hhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hjwhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj]ubhR and netdev instance lock if the driver implements queue management or shaper API.}(hj]hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM2hjZubh)}(hFor ``TC_SETUP_BLOCK`` and ``TC_SETUP_FT`` ``rtnl_lock`` may or may not be held, and the netdev instance lock is not held. ``TC_SETUP_BLOCK`` runs under ``block->cb_lock`` and ``TC_SETUP_FT`` runs under ``flowtable->flow_block_lock``.h](hFor }(hjhhhNhNubj )}(h``TC_SETUP_BLOCK``h]hTC_SETUP_BLOCK}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh and }(hjhhhNhNubj )}(h``TC_SETUP_FT``h]h TC_SETUP_FT}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh }(hjhhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhC may or may not be held, and the netdev instance lock is not held. }(hjhhhNhNubj )}(h``TC_SETUP_BLOCK``h]hTC_SETUP_BLOCK}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh runs under }(hjhhhNhNubj )}(h``block->cb_lock``h]hblock->cb_lock}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh and }hjsbj )}(h``TC_SETUP_FT``h]h TC_SETUP_FT}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh runs under }(hjhhhNhNubj )}(h``flowtable->flow_block_lock``h]hflowtable->flow_block_lock}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM6hjZubeh}(h]h ]h"]h$]h&]uh1j+hjHubeh}(h]h ]h"]h$]h&]uh1jhhhM9hjhhubeh}(h]h ]h"]h$]h&]uh1jhjhhhhhNubh)}(hMost ndo callbacks not specified in the list above are running under ``rtnl_lock``. In addition, netdev instance lock is taken as well if the driver implements queue management or shaper API.h](hEMost ndo callbacks not specified in the list above are running under }(hj-hhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj-ubhm. In addition, netdev instance lock is taken as well if the driver implements queue management or shaper API.}(hj-hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM;hjhhubeh}(h]'struct-net-device-synchronization-rulesah ]h"]'struct net_device synchronization rulesah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h(struct napi_struct synchronization rulesh]h(struct napi_struct synchronization rules}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjUhhhhhM@ubj)}(hhh]j)}(hXnapi->poll: Synchronization: NAPI_STATE_SCHED bit in napi->state. Device driver's ndo_stop method will invoke napi_disable() on all NAPI instances which will do a sleeping poll on the NAPI_STATE_SCHED napi->state bit, waiting for all pending NAPI activity to cease. Context: softirq will be called with interrupts disabled by netconsole. h](j)}(h napi->poll:h]h napi->poll:}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMKhjiubj,)}(hhh]j)}(hhh](j)}(hSynchronization: NAPI_STATE_SCHED bit in napi->state. Device driver's ndo_stop method will invoke napi_disable() on all NAPI instances which will do a sleeping poll on the NAPI_STATE_SCHED napi->state bit, waiting for all pending NAPI activity to cease. h](j)}(hSynchronization:h]hSynchronization:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMGhjubj,)}(hhh]h)}(hNAPI_STATE_SCHED bit in napi->state. Device driver's ndo_stop method will invoke napi_disable() on all NAPI instances which will do a sleeping poll on the NAPI_STATE_SCHED napi->state bit, waiting for all pending NAPI activity to cease.h]hNAPI_STATE_SCHED bit in napi->state. Device driver’s ndo_stop method will invoke napi_disable() on all NAPI instances which will do a sleeping poll on the NAPI_STATE_SCHED napi->state bit, waiting for all pending NAPI activity to cease.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMChjubah}(h]h ]h"]h$]h&]uh1j+hjubeh}(h]h ]h"]h$]h&]uh1jhhhMGhj~ubj)}(hHContext: softirq will be called with interrupts disabled by netconsole. h](j)}(hContext:h]hContext:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMKhjubj,)}(hhh]h)}(h>softirq will be called with interrupts disabled by netconsole.h]h>softirq will be called with interrupts disabled by netconsole.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMJhjubah}(h]h ]h"]h$]h&]uh1j+hjubeh}(h]h ]h"]h$]h&]uh1jhhhMKhj~ubeh}(h]h ]h"]h$]h&]uh1jhj{ubah}(h]h ]h"]h$]h&]uh1j+hjiubeh}(h]h ]h"]h$]h&]uh1jhhhMKhjfubah}(h]h ]h"]h$]h&]uh1jhjUhhhNhNubeh}(h](struct-napi-struct-synchronization-rulesah ]h"](struct napi_struct synchronization rulesah$]h&]uh1hhhhhhhhM@ubh)}(hhh](h)}(hnetdev instance lockh]hnetdev instance lock}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMNubh)}(hX3Historically, all networking control operations were protected by a single global lock known as ``rtnl_lock``. There is an ongoing effort to replace this global lock with separate locks for each network namespace. Additionally, properties of individual netdev are increasingly protected by per-netdev locks.h](h`Historically, all networking control operations were protected by a single global lock known as }(hj hhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh. There is an ongoing effort to replace this global lock with separate locks for each network namespace. Additionally, properties of individual netdev are increasingly protected by per-netdev locks.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMPhjhhubh)}(hXFor device drivers that implement shaping or queue management APIs, all control operations will be performed under the netdev instance lock. Drivers can also explicitly request instance lock to be held during ops by setting ``request_ops_lock`` to true. Code comments and docs refer to drivers which have ops called under the instance lock as "ops locked". See also the documentation of the ``lock`` member of struct net_device.h](hFor device drivers that implement shaping or queue management APIs, all control operations will be performed under the netdev instance lock. Drivers can also explicitly request instance lock to be held during ops by setting }(hj0 hhhNhNubj )}(h``request_ops_lock``h]hrequest_ops_lock}(hj8 hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj0 ubh to true. Code comments and docs refer to drivers which have ops called under the instance lock as “ops locked”. See also the documentation of the }(hj0 hhhNhNubj )}(h``lock``h]hlock}(hjJ hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj0 ubh member of struct net_device.}(hj0 hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMUhjhhubh)}(hX@There is also a case of taking two per-netdev locks in sequence when netdev queues are leased, that is, the netdev-scope lock is taken for both the virtual and the physical device. To prevent deadlocks, the virtual device's lock must always be acquired before the physical device's (see ``netdev_nl_queue_create_doit``).h](hX#There is also a case of taking two per-netdev locks in sequence when netdev queues are leased, that is, the netdev-scope lock is taken for both the virtual and the physical device. To prevent deadlocks, the virtual device’s lock must always be acquired before the physical device’s (see }(hjb hhhNhNubj )}(h``netdev_nl_queue_create_doit``h]hnetdev_nl_queue_create_doit}(hjj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjb ubh).}(hjb hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM\hjhhubh)}(hJDevice drivers are encouraged to rely on the instance lock where possible.h]hJDevice drivers are encouraged to rely on the instance lock where possible.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMbhjhhubh)}(hXFor the (mostly software) drivers that need to interact with the core stack, there are two sets of interfaces: ``dev_xxx``/``netdev_xxx`` and ``netif_xxx`` (e.g., ``dev_set_mtu`` and ``netif_set_mtu``). The ``dev_xxx``/``netdev_xxx`` functions handle acquiring the instance lock themselves, while the ``netif_xxx`` functions assume that the driver has already acquired the instance lock.h](hoFor the (mostly software) drivers that need to interact with the core stack, there are two sets of interfaces: }(hj hhhNhNubj )}(h ``dev_xxx``h]hdev_xxx}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh/}(hj hhhNhNubj )}(h``netdev_xxx``h]h netdev_xxx}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh and }(hj hhhNhNubj )}(h ``netif_xxx``h]h netif_xxx}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh (e.g., }(hj hhhNhNubj )}(h``dev_set_mtu``h]h dev_set_mtu}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh and }hj sbj )}(h``netif_set_mtu``h]h netif_set_mtu}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh). The }(hj hhhNhNubj )}(h ``dev_xxx``h]hdev_xxx}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh/}hj sbj )}(h``netdev_xxx``h]h netdev_xxx}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubhD functions handle acquiring the instance lock themselves, while the }(hj hhhNhNubj )}(h ``netif_xxx``h]h netif_xxx}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubhI functions assume that the driver has already acquired the instance lock.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMdhjhhubh)}(hhh](h)}(hstruct net_device_opsh]hstruct net_device_ops}(hj1 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj. hhhhhMlubh)}(hG``ndos`` are called without holding the instance lock for most drivers.h](j )}(h``ndos``h]hndos}(hjC hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj? ubh? are called without holding the instance lock for most drivers.}(hj? hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMnhj. hhubh)}(hT"Ops locked" drivers will have most of the ``ndos`` invoked under the instance lock.h](h/“Ops locked” drivers will have most of the }(hj[ hhhNhNubj )}(h``ndos``h]hndos}(hjc hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj[ ubh! invoked under the instance lock.}(hj[ hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMphj. hhubeh}(h]struct-net-device-opsah ]h"]struct net_device_opsah$]h&]uh1hhjhhhhhMlubh)}(hhh](h)}(hstruct ethtool_opsh]hstruct ethtool_ops}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMtubh)}(hJFor non-"ops locked" drivers ethtool_ops are executed under ``rtnl_lock``.h](h@For non-“ops locked” drivers ethtool_ops are executed under }(hj hhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMvhj hhubh)}(hX For "ops locked" drivers, ``ethtool_ops``, unlike ``ndos``, run under the instance lock **only**. Drivers may request that ``rtnl_lock`` is held around specific operations (both SET and GET) by setting appropriate bits in ``ethtool_ops::op_needs_rtnl`` (if the necessary ``ETHTOOL_OP_NEEDS_RTNL_*`` bit doesn't exist, just add it). Commonly used core helpers which force drivers to selectively opt-in to ``rtnl_lock`` protection include ``netdev_update_features()``, ``netif_set_real_num_tx_queues()``, and phylink helpers.h](hFor “ops locked” drivers, }(hj hhhNhNubj )}(h``ethtool_ops``h]h ethtool_ops}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh , unlike }(hj hhhNhNubj )}(h``ndos``h]hndos}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh, run under the instance lock }(hj hhhNhNubj)}(h**only**h]honly}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh. Drivers may request that }(hj hhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubhV is held around specific operations (both SET and GET) by setting appropriate bits in }(hj hhhNhNubj )}(h``ethtool_ops::op_needs_rtnl``h]hethtool_ops::op_needs_rtnl}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh (if the necessary }(hj hhhNhNubj )}(h``ETHTOOL_OP_NEEDS_RTNL_*``h]hETHTOOL_OP_NEEDS_RTNL_*}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubhl bit doesn’t exist, just add it). Commonly used core helpers which force drivers to selectively opt-in to }(hj hhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hj( hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh protection include }(hj hhhNhNubj )}(h``netdev_update_features()``h]hnetdev_update_features()}(hj: hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh, }(hj hhhNhNubj )}(h"``netif_set_real_num_tx_queues()``h]hnetif_set_real_num_tx_queues()}(hjL hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh, and phylink helpers.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMxhj hhubeh}(h]struct-ethtool-opsah ]h"]struct ethtool_opsah$]h&]uh1hhjhhhhhMtubh)}(hhh](h)}(hstruct netdev_stat_opsh]hstruct netdev_stat_ops}(hjo hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjl hhhhhMubh)}(ht"qstat" ops are invoked under the instance lock for "ops locked" drivers, and under rtnl_lock for all other drivers.h]h|“qstat” ops are invoked under the instance lock for “ops locked” drivers, and under rtnl_lock for all other drivers.}(hj} hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjl hhubeh}(h]struct-netdev-stat-opsah ]h"]struct netdev_stat_opsah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(hstruct net_shaper_opsh]hstruct net_shaper_ops}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(hrAll net shaper callbacks are invoked while holding the netdev instance lock. ``rtnl_lock`` may or may not be held.h](hMAll net shaper callbacks are invoked while holding the netdev instance lock. }(hj hhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh may or may not be held.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hENote that supporting net shapers automatically enables "ops locking".h]hINote that supporting net shapers automatically enables “ops locking”.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubeh}(h]struct-net-shaper-opsah ]h"]struct net_shaper_opsah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(hstruct netdev_queue_mgmt_opsh]hstruct netdev_queue_mgmt_ops}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(hxAll queue management callbacks are invoked while holding the netdev instance lock. ``rtnl_lock`` may or may not be held.h](hSAll queue management callbacks are invoked while holding the netdev instance lock. }(hj hhhNhNubj )}(h ``rtnl_lock``h]h rtnl_lock}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh may or may not be held.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hVNote that supporting struct netdev_queue_mgmt_ops automatically enables "ops locking".h]hZNote that supporting struct netdev_queue_mgmt_ops automatically enables “ops locking”.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubeh}(h]struct-netdev-queue-mgmt-opsah ]h"]struct netdev_queue_mgmt_opsah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(h"Notifiers and netdev instance lockh]h"Notifiers and netdev instance lock}(hj$ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj! hhhhhMubh)}(hFor device drivers that implement shaping or queue management APIs, some of the notifiers (``enum netdev_cmd``) are running under the netdev instance lock.h](h[For device drivers that implement shaping or queue management APIs, some of the notifiers (}(hj2 hhhNhNubj )}(h``enum netdev_cmd``h]henum netdev_cmd}(hj: hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj2 ubh-) are running under the netdev instance lock.}(hj2 hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj! hhubh)}(hcThe following netdev notifiers are always run under the instance lock: * ``NETDEV_XDP_FEAT_CHANGE``h](hIThe following netdev notifiers are always run under the instance lock: * }(hjR hhhNhNubj )}(h``NETDEV_XDP_FEAT_CHANGE``h]hNETDEV_XDP_FEAT_CHANGE}(hjZ hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjR ubeh}(h]h ]h"]h$]h&]uh1hhhhMhj! hhubh)}(hFor devices with locked ops, currently only the following notifiers are running under the lock: * ``NETDEV_CHANGE`` * ``NETDEV_CHANGENAME`` * ``NETDEV_REGISTER`` * ``NETDEV_UP``h](hbFor devices with locked ops, currently only the following notifiers are running under the lock: * }(hjn hhhNhNubj )}(h``NETDEV_CHANGE``h]h NETDEV_CHANGE}(hjv hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjn ubh * }(hjn hhhNhNubj )}(h``NETDEV_CHANGENAME``h]hNETDEV_CHANGENAME}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjn ubh * }hjn sbj )}(h``NETDEV_REGISTER``h]hNETDEV_REGISTER}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjn ubh * }hjn sbj )}(h ``NETDEV_UP``h]h NETDEV_UP}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjn ubeh}(h]h ]h"]h$]h&]uh1hhhhMhj! hhubh)}(hMThe following notifiers are running without the lock: * ``NETDEV_UNREGISTER``h](h8The following notifiers are running without the lock: * }(hj hhhNhNubj )}(h``NETDEV_UNREGISTER``h]hNETDEV_UNREGISTER}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1hhhhMhj! hhubh)}(hXThere are no clear expectations for the remaining notifiers. Notifiers not on the list may run with or without the instance lock, potentially even invoking the same notifier type with and without the lock from different code paths. The goal is to eventually ensure that all (or most, with a few documented exceptions) notifiers run under the instance lock. Please extend this documentation whenever you make explicit assumption about lock being held from a notifier.h]hXThere are no clear expectations for the remaining notifiers. Notifiers not on the list may run with or without the instance lock, potentially even invoking the same notifier type with and without the lock from different code paths. The goal is to eventually ensure that all (or most, with a few documented exceptions) notifiers run under the instance lock. Please extend this documentation whenever you make explicit assumption about lock being held from a notifier.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj! hhubh)}(hKDrivers **must not** generate nested notifications of the ops-locked types.h](hDrivers }(hj hhhNhNubj)}(h **must not**h]hmust not}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh7 generate nested notifications of the ops-locked types.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj! hhubeh}(h]"notifiers-and-netdev-instance-lockah ]h"]"notifiers and netdev instance lockah$]h&]uh1hhjhhhhhMubeh}(h]netdev-instance-lockah ]h"]netdev instance lockah$]h&]uh1hhhhhhhhMNubh)}(hhh](h)}(h NETDEV_INTERNAL symbol namespaceh]h NETDEV_INTERNAL symbol namespace}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(hXSymbols exported as NETDEV_INTERNAL can only be used in networking core and drivers which exclusively flow via the main networking list and trees. Note that the inverse is not true, most symbols outside of NETDEV_INTERNAL are not expected to be used by random code outside netdev either. Symbols may lack the designation because they predate the namespaces, or simply due to an oversight.h]hXSymbols exported as NETDEV_INTERNAL can only be used in networking core and drivers which exclusively flow via the main networking list and trees. Note that the inverse is not true, most symbols outside of NETDEV_INTERNAL are not expected to be used by random code outside netdev either. Symbols may lack the designation because they predate the namespaces, or simply due to an oversight.}(hj+ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubeh}(h] netdev-internal-symbol-namespaceah ]h"] netdev_internal symbol namespaceah$]h&]uh1hhhhhhhhMubeh}(h]"network-devices-the-kernel-and-youah ]h"]%network devices, the kernel, and you!ah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjl error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourcehnj _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jF jC jjjjjj jjjjjjjRjOjjj j j j} ji jf j j j j j j j j j> j; u nametypes}(jF jjjjjjjRjj j ji j j j j j> uh}(jC hjhjjj jyjjjjjjjOjjjUj jj} j. jf j j jl j j j j j j! j; j u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.