diff mbox series

[net,1/5] net, team, bonding: Add netdev_base_features helper

Message ID 20241210141245.327886-1-daniel@iogearbox.net (mailing list archive)
State Accepted
Commit d2516c3a53705f783bb6868df0f4a2b977898a71
Delegated to: Netdev Maintainers
Headers show
Series [net,1/5] net, team, bonding: Add netdev_base_features helper | expand

Checks

Context Check Description
netdev/series_format warning Series does not have a cover letter
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 40 this patch: 40
netdev/build_tools success Errors and warnings before: 0 (+0) this patch: 0 (+0)
netdev/cc_maintainers warning 7 maintainers not CCed: pabeni@redhat.com edumazet@google.com kuba@kernel.org andy@greyhouse.net andrew+netdev@lunn.ch horms@kernel.org jv@jvosburgh.net
netdev/build_clang success Errors and warnings before: 77 this patch: 77
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4976 this patch: 4976
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 30 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 13 this patch: 13
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-12-12--00-00 (tests: 795)

Commit Message

Daniel Borkmann Dec. 10, 2024, 2:12 p.m. UTC
Both bonding and team driver have logic to derive the base feature
flags before iterating over their slave devices to refine the set
via netdev_increment_features().

Add a small helper netdev_base_features() so this can be reused
instead of having it open-coded multiple times.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Nikolay Aleksandrov <razor@blackwall.org>
Cc: Ido Schimmel <idosch@idosch.org>
Cc: Jiri Pirko <jiri@nvidia.com>
---
 drivers/net/bonding/bond_main.c | 4 +---
 drivers/net/team/team_core.c    | 3 +--
 include/linux/netdev_features.h | 7 +++++++
 3 files changed, 9 insertions(+), 5 deletions(-)

Comments

Hangbin Liu Dec. 11, 2024, 1:33 a.m. UTC | #1
On Tue, Dec 10, 2024 at 03:12:41PM +0100, Daniel Borkmann wrote:
> Both bonding and team driver have logic to derive the base feature
> flags before iterating over their slave devices to refine the set
> via netdev_increment_features().
> 
> Add a small helper netdev_base_features() so this can be reused
> instead of having it open-coded multiple times.
> 
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Nikolay Aleksandrov <razor@blackwall.org>
> Cc: Ido Schimmel <idosch@idosch.org>
> Cc: Jiri Pirko <jiri@nvidia.com>
> ---
>  drivers/net/bonding/bond_main.c | 4 +---
>  drivers/net/team/team_core.c    | 3 +--
>  include/linux/netdev_features.h | 7 +++++++
>  3 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 49dd4fe195e5..42c835c60cd8 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -1520,9 +1520,7 @@ static netdev_features_t bond_fix_features(struct net_device *dev,
>  	struct slave *slave;
>  
>  	mask = features;
> -
> -	features &= ~NETIF_F_ONE_FOR_ALL;
> -	features |= NETIF_F_ALL_FOR_ALL;
> +	features = netdev_base_features(features);
>  
>  	bond_for_each_slave(bond, slave, iter) {
>  		features = netdev_increment_features(features,
> diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c
> index a1b27b69f010..1df062c67640 100644
> --- a/drivers/net/team/team_core.c
> +++ b/drivers/net/team/team_core.c
> @@ -2011,8 +2011,7 @@ static netdev_features_t team_fix_features(struct net_device *dev,
>  	netdev_features_t mask;
>  
>  	mask = features;
> -	features &= ~NETIF_F_ONE_FOR_ALL;
> -	features |= NETIF_F_ALL_FOR_ALL;
> +	features = netdev_base_features(features);
>  
>  	rcu_read_lock();
>  	list_for_each_entry_rcu(port, &team->port_list, list) {
> diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
> index 66e7d26b70a4..11be70a7929f 100644
> --- a/include/linux/netdev_features.h
> +++ b/include/linux/netdev_features.h
> @@ -253,4 +253,11 @@ static inline int find_next_netdev_feature(u64 feature, unsigned long start)
>  				 NETIF_F_GSO_UDP_TUNNEL |		\
>  				 NETIF_F_GSO_UDP_TUNNEL_CSUM)
>  
> +static inline netdev_features_t netdev_base_features(netdev_features_t features)
> +{
> +	features &= ~NETIF_F_ONE_FOR_ALL;
> +	features |= NETIF_F_ALL_FOR_ALL;
> +	return features;
> +}
> +
>  #endif	/* _LINUX_NETDEV_FEATURES_H */
> -- 
> 2.43.0
> 

Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Nikolay Aleksandrov Dec. 11, 2024, 7:39 a.m. UTC | #2
On 12/10/24 16:12, Daniel Borkmann wrote:
> Both bonding and team driver have logic to derive the base feature
> flags before iterating over their slave devices to refine the set
> via netdev_increment_features().
> 
> Add a small helper netdev_base_features() so this can be reused
> instead of having it open-coded multiple times.
> 
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Nikolay Aleksandrov <razor@blackwall.org>
> Cc: Ido Schimmel <idosch@idosch.org>
> Cc: Jiri Pirko <jiri@nvidia.com>
> ---
>  drivers/net/bonding/bond_main.c | 4 +---
>  drivers/net/team/team_core.c    | 3 +--
>  include/linux/netdev_features.h | 7 +++++++
>  3 files changed, 9 insertions(+), 5 deletions(-)
> 

Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Paolo Abeni Dec. 12, 2024, 10:58 a.m. UTC | #3
On 12/10/24 15:12, Daniel Borkmann wrote:
> Both bonding and team driver have logic to derive the base feature
> flags before iterating over their slave devices to refine the set
> via netdev_increment_features().
> 
> Add a small helper netdev_base_features() so this can be reused
> instead of having it open-coded multiple times.
> 
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Nikolay Aleksandrov <razor@blackwall.org>
> Cc: Ido Schimmel <idosch@idosch.org>
> Cc: Jiri Pirko <jiri@nvidia.com>

The series looks good, I'm applying it right now, but please include a
(even small) cover letter in the next multi-patch submission, thanks!

Paolo
patchwork-bot+netdevbpf@kernel.org Dec. 12, 2024, 11:10 a.m. UTC | #4
Hello:

This series was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Tue, 10 Dec 2024 15:12:41 +0100 you wrote:
> Both bonding and team driver have logic to derive the base feature
> flags before iterating over their slave devices to refine the set
> via netdev_increment_features().
> 
> Add a small helper netdev_base_features() so this can be reused
> instead of having it open-coded multiple times.
> 
> [...]

Here is the summary with links:
  - [net,1/5] net, team, bonding: Add netdev_base_features helper
    https://git.kernel.org/netdev/net/c/d2516c3a5370
  - [net,2/5] bonding: Fix initial {vlan,mpls}_feature set in bond_compute_features
    https://git.kernel.org/netdev/net/c/d064ea7fe2a2
  - [net,3/5] bonding: Fix feature propagation of NETIF_F_GSO_ENCAP_ALL
    https://git.kernel.org/netdev/net/c/77b11c8bf3a2
  - [net,4/5] team: Fix initial vlan_feature set in __team_compute_features
    https://git.kernel.org/netdev/net/c/396699ac2cb1
  - [net,5/5] team: Fix feature propagation of NETIF_F_GSO_ENCAP_ALL
    https://git.kernel.org/netdev/net/c/98712844589e

You are awesome, thank you!
Daniel Borkmann Dec. 12, 2024, 12:07 p.m. UTC | #5
On 12/12/24 11:58 AM, Paolo Abeni wrote:
> On 12/10/24 15:12, Daniel Borkmann wrote:
>> Both bonding and team driver have logic to derive the base feature
>> flags before iterating over their slave devices to refine the set
>> via netdev_increment_features().
>>
>> Add a small helper netdev_base_features() so this can be reused
>> instead of having it open-coded multiple times.
>>
>> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
>> Cc: Nikolay Aleksandrov <razor@blackwall.org>
>> Cc: Ido Schimmel <idosch@idosch.org>
>> Cc: Jiri Pirko <jiri@nvidia.com>
> 
> The series looks good, I'm applying it right now, but please include a
> (even small) cover letter in the next multi-patch submission, thanks!

Ok, thanks, will do next time!

Cheers,
Daniel
diff mbox series

Patch

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 49dd4fe195e5..42c835c60cd8 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1520,9 +1520,7 @@  static netdev_features_t bond_fix_features(struct net_device *dev,
 	struct slave *slave;
 
 	mask = features;
-
-	features &= ~NETIF_F_ONE_FOR_ALL;
-	features |= NETIF_F_ALL_FOR_ALL;
+	features = netdev_base_features(features);
 
 	bond_for_each_slave(bond, slave, iter) {
 		features = netdev_increment_features(features,
diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c
index a1b27b69f010..1df062c67640 100644
--- a/drivers/net/team/team_core.c
+++ b/drivers/net/team/team_core.c
@@ -2011,8 +2011,7 @@  static netdev_features_t team_fix_features(struct net_device *dev,
 	netdev_features_t mask;
 
 	mask = features;
-	features &= ~NETIF_F_ONE_FOR_ALL;
-	features |= NETIF_F_ALL_FOR_ALL;
+	features = netdev_base_features(features);
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(port, &team->port_list, list) {
diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
index 66e7d26b70a4..11be70a7929f 100644
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
@@ -253,4 +253,11 @@  static inline int find_next_netdev_feature(u64 feature, unsigned long start)
 				 NETIF_F_GSO_UDP_TUNNEL |		\
 				 NETIF_F_GSO_UDP_TUNNEL_CSUM)
 
+static inline netdev_features_t netdev_base_features(netdev_features_t features)
+{
+	features &= ~NETIF_F_ONE_FOR_ALL;
+	features |= NETIF_F_ALL_FOR_ALL;
+	return features;
+}
+
 #endif	/* _LINUX_NETDEV_FEATURES_H */