Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DC9B3C4565 for ; Tue, 26 May 2026 22:12:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779833548; cv=none; b=fe5AKsHgzs1GFJkY30UX6R/hFCoswqqdd6YS+UgtMY2rOZGxFBCn1TxS0fdsJYGYT5kUwWrjEIdi/qZIZ1b63i6Jt8vz1sOog7ZJ5FPMw1K3Nu5g9i68oc61fjM0ueY0llctPdDYwXCiwCx/FVrI3i4MQV2X3Ksy+VVUwIJIjxU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779833548; c=relaxed/simple; bh=ivCtf1OcPHtXKU2jG0fg20Rv9Wm920Y6xaPkBBeWvlU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MJb2/JUAeYaox4KM4UOK4NqmPetwSIoPo8MI1NFmmpszxvhJS1FJyws8bXr9F8mzzGL2gun0q8qLh1bKhuWrJzpeFxOR4tkPsdRnYzBeg0u7NCWGBnJLIGVvKJeeoxowvzAtM9DNO2i5oI573Sai/ej5QB0EdyKVF4rZf1Vykt8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WEEY0EGS; arc=none smtp.client-ip=209.85.210.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WEEY0EGS" Received: by mail-pf1-f196.google.com with SMTP id d2e1a72fcca58-82f8b60e485so4706024b3a.0 for ; Tue, 26 May 2026 15:12:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779833545; x=1780438345; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=LS3JCSk6VUroBWMnTAalYS0P2J+lAQ2b0ipt6XKuTHs=; b=WEEY0EGSOe8v+VgZr5NRy6ZrfKnMfdq7syzP3KaqI6dI+/8iamvhutwu/XYUDdnaqf hhkbW2RjxX+m2entZZblANKTw/++0aZldO1pBqCTjDL3Jrjdbo0A7P6sb9upktwuNQ/n eDyVButPGLQun+aOPqEEWidG9oNu2NV3FHJrYUiSUAL+2IKFl+ZU0+r2SAAh14sYmUgZ XlM4piAjsHaWLU+ylmyNCydHqUcHT1KfdDK2doVYpv2KW2MpaUQYD24fSGnTWFjhyajG n8gDmZu8YYLPPVRtjVVUSl0P1B2p0BxpEbj1K4/XP5W1FTpJ/QFExcgu2F4k1DARBF6A 6Vxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779833545; x=1780438345; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LS3JCSk6VUroBWMnTAalYS0P2J+lAQ2b0ipt6XKuTHs=; b=UzQjQc6djUPtEwatX/nBuyjRLpFOTPcXoTJrs4YhfjKXQ5Ii+g7IChNfM3q+QRg20d hOmjQorVdZB6UwenJog8AXd9V+/B9e1kqTq8n+JyqutbSPYJ321Hjb5FqZAhBcx5E7Pi QQrhjcc7iSCyOmgnpKnhtpK5BBTVUrm4MT5BizDOYuyCnjUAaFlF4SqHa04hpS8M4qdI twtVLItsXelU7fpTW6ySDWUkWzMPja3caXZoY5f5ohHyLEa9dwbBbmiZ2cIZlWAgCsC3 vBp8H2Ht8eoANX3GNRrHsKqcULeSe/FlWLBuTjKw7KiwR/7RnHVPmWh/KC/m8HgLsVXO wdUA== X-Forwarded-Encrypted: i=1; AFNElJ+qBCkPgdkrV/RMhefYW8ysM391bgC2doHXd5tPJzXpL8JJLQAgkZJj5x8pRJ9a+NsfjsKlRrdrg20=@vger.kernel.org X-Gm-Message-State: AOJu0YzO0yJ0ye9amsHHv7Gc39s2IpOu3fLKDiRKVtPw8HqM3SRr4kxY lLdAz0SHfTZobtu1kPuswnQ7X5OLdG7LzpYn55AIRndrElq/zLMzf87s X-Gm-Gg: Acq92OEBqTNxm09e1t3Dy1cCEQdqiOPkLp4U/QU6ULRsFGFOmxr9XZ7cgvC/1NcfxGM Ds+XxgPYH3Ekj7Um/toocUiwN75Zmi7qJfiNEYEXyJ4CoYG2oakpx9A//HbSnOdl9IhkXz7mcDZ AUOiNjRuTNS73idSwZ3xA24N+tBkdULfSejpGwnNPV+WL1tkYkqdF60e/ldkp6lhNOmu1xLLwKb 3SPnO41Dtouo7J2yjCT0oQLy+m9r0U3ieLDBM2u93o85g4gfySn/7qjl+OIHxHqPX33crx5TsMw spf3y7F0BAKaAFuyKpEIrq+jf9iTe1ftWqHn99S6w/DFYDhmFf9PuTz5zA6yiWrzErq4AJGMzri MFecV8Pq3Af9K4c+AiTi2V8JWJ8423ugV7tIohZSqEv6runaav36QMelgdaqn1yo4ZADVKofe9h I9X+IWJeGJMzgBFNbA X-Received: by 2002:a05:6a00:2295:b0:82d:556b:7a01 with SMTP id d2e1a72fcca58-8415f15a680mr18903223b3a.16.1779833545023; Tue, 26 May 2026 15:12:25 -0700 (PDT) Received: from localhost ([2a03:2880:2ff:50::]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-841d6e80254sm289657b3a.3.2026.05.26.15.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2026 15:12:24 -0700 (PDT) Date: Tue, 26 May 2026 15:12:23 -0700 From: Stanislav Fomichev To: Jakub Kicinski Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org, corbet@lwn.net, vladimir.oltean@nxp.com, willemb@google.com, ecree.xilinx@gmail.com, jesse.brandeburg@intel.com, linux-doc@vger.kernel.org Subject: Re: [PATCH net-next 01/10] docs: net: netdevices: small fixes and clarifications Message-ID: References: <20260526160151.2793354-1-kuba@kernel.org> <20260526160151.2793354-2-kuba@kernel.org> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20260526160151.2793354-2-kuba@kernel.org> On 05/26, Jakub Kicinski wrote: > A handful of unrelated nits: > > - free_netdevice() does not exist; replace two stray references > with free_netdev(). > - The simple-driver probe example fell through into err_undo after > register_netdev() success; add return 0 for clarity. > - Clarify the netdev_priv() paragraph: "(netdev_priv())" was easy > to misread as the thing that needs explicit freeing; spell out > that it refers to extra pointers stored in the device private > struct. > - ndo_setup_tc synchronization note: TC_SETUP_BLOCK / TC_SETUP_FT > actually run under block->cb_lock, not "NFT locks", and rtnl_lock > may or may not be held depending on path. > - ->lltx guidance reads as very outdated, it's not really deprecated. > I suspect people may have been trying to use it for HW drivers > in the past but I can't think of such a case in the last decade. > > Signed-off-by: Jakub Kicinski > --- > Documentation/networking/netdevices.rst | 31 ++++++++++++++----------- > 1 file changed, 17 insertions(+), 14 deletions(-) > > diff --git a/Documentation/networking/netdevices.rst b/Documentation/networking/netdevices.rst > index 93e06e8d51a9..60492d4df2ee 100644 > --- a/Documentation/networking/netdevices.rst > +++ b/Documentation/networking/netdevices.rst > @@ -21,13 +21,14 @@ by free_netdev(). This is required to handle the pathological case cleanly > alloc_netdev_mqs() / alloc_netdev() reserve extra space for driver > private data which gets freed when the network device is freed. If > separately allocated data is attached to the network device > -(netdev_priv()) then it is up to the module exit handler to free that. > +(extra pointers stored in the device private struct) then it is up > +to the module exit handler to free that. > > There are two groups of APIs for registering struct net_device. > First group can be used in normal contexts where ``rtnl_lock`` is not already > held: register_netdev(), unregister_netdev(). > Second group can be used when ``rtnl_lock`` is already held: > -register_netdevice(), unregister_netdevice(), free_netdevice(). > +register_netdevice(), unregister_netdevice(), free_netdev(). > > Simple drivers > -------------- > @@ -58,6 +59,7 @@ In that case the struct net_device registration is done using > goto err_undo; > > /* net_device is visible to the user! */ > + return 0; > > err_undo: > /* ... undo the device setup ... */ > @@ -73,7 +75,7 @@ In that case the struct net_device registration is done using > > Note that after calling register_netdev() the device is visible in the system. > Users can open it and start sending / receiving traffic immediately, > -or run any other callback, so all initialization must be done prior to > +or run any other callback, so all initialization must be **complete** prior to > registration. > > unregister_netdev() closes the device and waits for all users to be done > @@ -157,7 +159,7 @@ register_netdevice() fails. The callback may be invoked with or without > There is no explicit constructor callback, driver "constructs" the private > netdev state after allocating it and before registration. > > -Setting struct net_device.needs_free_netdev makes core call free_netdevice() > +Setting 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 > @@ -256,7 +258,7 @@ struct net_device synchronization rules > lock if the driver implements queue management or shaper API. > Context: process > > -ndo_get_stats: > +ndo_get_stats / ndo_get_stats64: > Synchronization: RCU (can be called concurrently with the stats > update path). > Context: atomic (can't sleep under RCU) > @@ -264,12 +266,9 @@ struct net_device synchronization rules > ndo_start_xmit: > Synchronization: __netif_tx_lock spinlock. > > - When the driver sets dev->lltx this will be > - called without holding netif_tx_lock. In this case the driver > - has to lock by itself when needed. > - The locking there should also properly protect against > - set_rx_mode. WARNING: use of dev->lltx is deprecated. > - Don't use it for new drivers. > + 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. > @@ -304,11 +303,15 @@ struct net_device synchronization rules > lock if the driver implements queue management or shaper API. > [..] > ndo_setup_tc: > - ``TC_SETUP_BLOCK`` and ``TC_SETUP_FT`` are running under NFT locks > - (i.e. no ``rtnl_lock`` and no device instance lock). The rest of > - ``tc_setup_type`` types run under netdev instance lock if the driver > + 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``. > + > Most 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. LGTM! Acked-by: Stanislav Fomichev