Commit c55f34a7 authored by Paolo Abeni's avatar Paolo Abeni
Browse files

Merge branch 'netdev_features-start-cleaning-netdev_features_t-up'

Alexander Lobakin says:

====================
netdev_features: start cleaning netdev_features_t up

NETDEV_FEATURE_COUNT is currently 64, which means we can't add any new
features as netdev_features_t is u64.
As per several discussions, instead of converting netdev_features_t to
a bitmap, which would mean A LOT of changes, we can try cleaning up
netdev feature bits.
There's a bunch of bits which don't really mean features, rather device
attributes/properties that can't be changed via Ethtool in any of the
drivers. Such attributes can be moved to netdev private flags without
losing any functionality.

Start converting some read-only netdev features to private flags from
the ones that are most obvious, like lockless Tx, inability to change
network namespace etc. I was able to reduce NETDEV_FEATURE_COUNT from
64 to 60, which mean 4 free slots for new features. There are obviously
more read-only features to convert, such as highDMA, "challenged VLAN",
HSR (4 bits) - this will be done in subsequent series.

Please note that currently netdev features are not uAPI/ABI by any means.
Ethtool passes their names and bits to the userspace separately and there
are no hardcoded names/bits in the userspace, so that new Ethtool could
work on older kernels and vice versa.
This, however, isn't true for Ethtools < 3.4. I haven't changed the bit
positions of the already existing features and instead replaced the freed
bits with stubs. But it's anyway theoretically possible that Ethtools
older than 2011 will break. I hope no currently supported distros supply
such an ancient version.
Shell scripts also most likely won't break since the removed bits were
always read-only, meaning nobody would try touching them from a script.
====================

Link: https://patch.msgid.link/20240829123340.789395-1-aleksander.lobakin@intel.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 075e3d30 a61fec1c
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@ net_device struct fast path usage breakdown

Type                                Name                    fastpath_tx_access  fastpath_rx_access  Comments
..struct                            ..net_device                                                    
unsigned_long:32                    priv_flags              read_mostly         -                   __dev_queue_xmit(tx)
unsigned_long:1                     lltx                    read_mostly         -                   HARD_TX_LOCK,HARD_TX_TRYLOCK,HARD_TX_UNLOCK(tx)
char                                name[16]                -                   -                   
struct_netdev_name_node*            name_node                                                       
struct_dev_ifalias*                 ifalias                                                         
@@ -23,7 +25,6 @@ struct_list_head ptype_specific
struct                              adj_list                                                        
unsigned_int                        flags                   read_mostly         read_mostly         __dev_queue_xmit,__dev_xmit_skb,ip6_output,__ip6_finish_output(tx);ip6_rcv_core(rx)
xdp_features_t                      xdp_features                                                    
unsigned_long_long                  priv_flags              read_mostly         -                   __dev_queue_xmit(tx)
struct_net_device_ops*              netdev_ops              read_mostly         -                   netdev_core_pick_tx,netdev_start_xmit(tx)
struct_xdp_metadata_ops*            xdp_metadata_ops                                                
int                                 ifindex                 -                   read_mostly         ip6_rcv_core
@@ -163,6 +164,10 @@ struct_lock_class_key* qdisc_tx_busylock
bool                                proto_down                                                      
unsigned:1                          wol_enabled                                                     
unsigned:1                          threaded                -                   -                   napi_poll(napi_enable,dev_set_threaded)
unsigned_long:1                     see_all_hwtstamp_requests                                       
unsigned_long:1                     change_proto_down                                               
unsigned_long:1                     netns_local                                                     
unsigned_long:1                     fcoe_mtu                                                        
struct_list_head                    net_notifier_list                                               
struct_macsec_ops*                  macsec_ops                                                      
struct_udp_tunnel_nic_info*         udp_tunnel_nic_info                                             
+0 −15
Original line number Diff line number Diff line
@@ -139,21 +139,6 @@ chained skbs (skb->next/prev list).
Features contained in NETIF_F_SOFT_FEATURES are features of networking
stack. Driver should not change behaviour based on them.

 * LLTX driver (deprecated for hardware drivers)

NETIF_F_LLTX is meant to be used by drivers that don't need locking at all,
e.g. software tunnels.

This is also used in a few legacy drivers that implement their
own locking, don't use it for new (hardware) drivers.

 * netns-local device

NETIF_F_NETNS_LOCAL is set for devices that are not allowed to move between
network namespaces (e.g. loopback).

Don't use it in drivers.

 * VLAN challenged

NETIF_F_VLAN_CHALLENGED should be set for devices which can't cope with VLAN
+2 −2
Original line number Diff line number Diff line
@@ -258,11 +258,11 @@ ndo_get_stats:
ndo_start_xmit:
	Synchronization: __netif_tx_lock spinlock.

	When the driver sets NETIF_F_LLTX in dev->features this will be
	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 NETIF_F_LLTX is deprecated.
	set_rx_mode. WARNING: use of dev->lltx is deprecated.
	Don't use it for new drivers.

	Context: Process with BHs disabled or BH (timer),
+2 −2
Original line number Diff line number Diff line
@@ -137,10 +137,10 @@ would be sub-port 0 on port 1 on switch 1.
Port Features
^^^^^^^^^^^^^

NETIF_F_NETNS_LOCAL
dev->netns_local

If the switchdev driver (and device) only supports offloading of the default
network namespace (netns), the driver should set this feature flag to prevent
network namespace (netns), the driver should set this private flag to prevent
the port netdev from being moved out of the default netns.  A netns-aware
driver/device would not set this flag and be responsible for partitioning
hardware to preserve netns containment.  This means hardware cannot forward
+2 −2
Original line number Diff line number Diff line
@@ -3098,9 +3098,9 @@ static void amt_link_setup(struct net_device *dev)
	dev->hard_header_len	= 0;
	dev->addr_len		= 0;
	dev->priv_flags		|= IFF_NO_QUEUE;
	dev->features		|= NETIF_F_LLTX;
	dev->lltx		= true;
	dev->netns_local	= true;
	dev->features		|= NETIF_F_GSO_SOFTWARE;
	dev->features		|= NETIF_F_NETNS_LOCAL;
	dev->hw_features	|= NETIF_F_SG | NETIF_F_HW_CSUM;
	dev->hw_features	|= NETIF_F_FRAGLIST | NETIF_F_RXCSUM;
	dev->hw_features	|= NETIF_F_GSO_SOFTWARE;
Loading