From: Hangbin Liu <liuhangbin@gmail.com>
To: Jay Vosburgh <jv@jvosburgh.net>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Jiri Pirko <jiri@resnulli.us>,
Nikolay Aleksandrov <razor@blackwall.org>,
Ido Schimmel <idosch@nvidia.com>,
Simon Horman <horms@kernel.org>,
Sridhar Samudrala <sridhar.samudrala@intel.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
bridge@lists.linux.dev, Hangbin Liu <liuhangbin@gmail.com>
Subject: [PATCH net-next 2/3] failover: use ndo_set_features for failover offload compute
Date: Tue, 10 Mar 2026 15:45:06 +0800 [thread overview]
Message-ID: <20260310-offload_compute-v1-2-3df79c09ea65@gmail.com> (raw)
In-Reply-To: <20260310-offload_compute-v1-0-3df79c09ea65@gmail.com>
Convert net_failover to use the ndo_set_features callback and calls
netdev_compute_master_upper_features() to compute new offload flags
during slave registration/unregistration.
This simplifies the failover code significantly by removing the custom
feature computation logic and relying on the centralized feature update
mechanism. The callback is automatically invoked during feature updates
when upper/lower device links change.
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
drivers/net/net_failover.c | 67 ++++++----------------------------------------
include/net/net_failover.h | 7 -----
2 files changed, 8 insertions(+), 66 deletions(-)
diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c
index d0361aaf25ef..10041a271bf5 100644
--- a/drivers/net/net_failover.c
+++ b/drivers/net/net_failover.c
@@ -300,6 +300,12 @@ static int net_failover_vlan_rx_kill_vid(struct net_device *dev, __be16 proto,
return 0;
}
+static int net_failover_set_features(struct net_device *dev, netdev_features_t features)
+{
+ netdev_compute_master_upper_features(dev, true);
+ return 0;
+}
+
static const struct net_device_ops failover_dev_ops = {
.ndo_open = net_failover_open,
.ndo_stop = net_failover_close,
@@ -312,6 +318,7 @@ static const struct net_device_ops failover_dev_ops = {
.ndo_vlan_rx_kill_vid = net_failover_vlan_rx_kill_vid,
.ndo_validate_addr = eth_validate_addr,
.ndo_features_check = passthru_features_check,
+ .ndo_set_features = net_failover_set_features,
};
#define FAILOVER_NAME "net_failover"
@@ -373,61 +380,6 @@ static rx_handler_result_t net_failover_handle_frame(struct sk_buff **pskb)
return RX_HANDLER_ANOTHER;
}
-static void net_failover_compute_features(struct net_device *dev)
-{
- netdev_features_t vlan_features = FAILOVER_VLAN_FEATURES &
- NETIF_F_ALL_FOR_ALL;
- netdev_features_t enc_features = FAILOVER_ENC_FEATURES;
- unsigned short max_hard_header_len = ETH_HLEN;
- unsigned int dst_release_flag = IFF_XMIT_DST_RELEASE |
- IFF_XMIT_DST_RELEASE_PERM;
- struct net_failover_info *nfo_info = netdev_priv(dev);
- struct net_device *primary_dev, *standby_dev;
-
- primary_dev = rcu_dereference(nfo_info->primary_dev);
- if (primary_dev) {
- vlan_features =
- netdev_increment_features(vlan_features,
- primary_dev->vlan_features,
- FAILOVER_VLAN_FEATURES);
- enc_features =
- netdev_increment_features(enc_features,
- primary_dev->hw_enc_features,
- FAILOVER_ENC_FEATURES);
-
- dst_release_flag &= primary_dev->priv_flags;
- if (primary_dev->hard_header_len > max_hard_header_len)
- max_hard_header_len = primary_dev->hard_header_len;
- }
-
- standby_dev = rcu_dereference(nfo_info->standby_dev);
- if (standby_dev) {
- vlan_features =
- netdev_increment_features(vlan_features,
- standby_dev->vlan_features,
- FAILOVER_VLAN_FEATURES);
- enc_features =
- netdev_increment_features(enc_features,
- standby_dev->hw_enc_features,
- FAILOVER_ENC_FEATURES);
-
- dst_release_flag &= standby_dev->priv_flags;
- if (standby_dev->hard_header_len > max_hard_header_len)
- max_hard_header_len = standby_dev->hard_header_len;
- }
-
- dev->vlan_features = vlan_features;
- dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL;
- dev->hard_header_len = max_hard_header_len;
-
- dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
- if (dst_release_flag == (IFF_XMIT_DST_RELEASE |
- IFF_XMIT_DST_RELEASE_PERM))
- dev->priv_flags |= IFF_XMIT_DST_RELEASE;
-
- netdev_change_features(dev);
-}
-
static void net_failover_lower_state_changed(struct net_device *slave_dev,
struct net_device *primary_dev,
struct net_device *standby_dev)
@@ -550,7 +502,6 @@ static int net_failover_slave_register(struct net_device *slave_dev,
}
net_failover_lower_state_changed(slave_dev, primary_dev, standby_dev);
- net_failover_compute_features(failover_dev);
call_netdevice_notifiers(NETDEV_JOIN, slave_dev);
@@ -621,8 +572,6 @@ static int net_failover_slave_unregister(struct net_device *slave_dev,
dev_put(slave_dev);
- net_failover_compute_features(failover_dev);
-
netdev_info(failover_dev, "failover %s slave:%s unregistered\n",
slave_is_standby ? "standby" : "primary", slave_dev->name);
@@ -736,7 +685,7 @@ struct failover *net_failover_create(struct net_device *standby_dev)
/* Don't allow failover devices to change network namespaces. */
failover_dev->netns_immutable = true;
- failover_dev->hw_features = FAILOVER_VLAN_FEATURES |
+ failover_dev->hw_features = MASTER_UPPER_DEV_VLAN_FEATURES |
NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_CTAG_RX |
NETIF_F_HW_VLAN_CTAG_FILTER;
diff --git a/include/net/net_failover.h b/include/net/net_failover.h
index b12a1c469d1c..f0f038d113a0 100644
--- a/include/net/net_failover.h
+++ b/include/net/net_failover.h
@@ -30,11 +30,4 @@ struct net_failover_info {
struct failover *net_failover_create(struct net_device *standby_dev);
void net_failover_destroy(struct failover *failover);
-#define FAILOVER_VLAN_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \
- NETIF_F_FRAGLIST | NETIF_F_ALL_TSO | \
- NETIF_F_HIGHDMA | NETIF_F_LRO)
-
-#define FAILOVER_ENC_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \
- NETIF_F_RXCSUM | NETIF_F_ALL_TSO)
-
#endif /* _NET_FAILOVER_H */
--
Git-155)
next prev parent reply other threads:[~2026-03-10 7:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 7:45 [PATCH net-next 0/3] net: move netdev_compute_master_upper_features to ndo_set_features Hangbin Liu
2026-03-10 7:45 ` [PATCH net-next 1/3] net: use ndo_set_features to set offload features for bonding/bridge/team Hangbin Liu
2026-03-10 7:45 ` Hangbin Liu [this message]
2026-03-10 7:45 ` [PATCH net-next 3/3] net: no need to disable LRO specifically Hangbin Liu
2026-03-10 17:02 ` [syzbot ci] Re: net: move netdev_compute_master_upper_features to ndo_set_features syzbot ci
2026-03-10 19:17 ` Sabrina Dubroca
2026-03-11 0:47 ` Hangbin Liu
2026-03-11 21:18 ` Sabrina Dubroca
2026-03-12 9:40 ` Paolo Abeni
2026-03-12 11:13 ` Sabrina Dubroca
2026-03-12 14:34 ` Hangbin Liu
2026-03-12 15:58 ` Sabrina Dubroca
2026-03-12 16:47 ` Paolo Abeni
2026-03-12 17:07 ` Sabrina Dubroca
2026-03-12 9:46 ` [PATCH net-next 0/3] " Paolo Abeni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260310-offload_compute-v1-2-3df79c09ea65@gmail.com \
--to=liuhangbin@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=bridge@lists.linux.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=jiri@resnulli.us \
--cc=jv@jvosburgh.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
--cc=sridhar.samudrala@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox