Thread (181 messages) flat view 181 messages, 6 authors, 2022-01-27

[RFCv2 net-next 027/167] bridge: use netdev feature helpers

From: Jian Shen <shenjian15@huawei.com>
Date: 2021-09-29 16:01:09
Subsystem: ethernet bridge, networking [general], the rest · Maintainers: Nikolay Aleksandrov, Ido Schimmel, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

Use netdev_feature_xxx helpers to replace the logical operation
for netdev features.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
---
 net/bridge/br_device.c | 16 +++++++++++-----
 net/bridge/br_if.c     |  4 ++--
 2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index fc508b9cbaa9..c9894b9944ab 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -490,11 +490,17 @@ void br_dev_setup(struct net_device *dev)
 	SET_NETDEV_DEVTYPE(dev, &br_type);
 	dev->priv_flags = IFF_EBRIDGE | IFF_NO_QUEUE;
 
-	dev->features = COMMON_FEATURES | NETIF_F_LLTX | NETIF_F_NETNS_LOCAL |
-			NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
-	dev->hw_features = COMMON_FEATURES | NETIF_F_HW_VLAN_CTAG_TX |
-			   NETIF_F_HW_VLAN_STAG_TX;
-	dev->vlan_features = COMMON_FEATURES;
+	netdev_feature_zero(&dev->features);
+	netdev_feature_set_bits(COMMON_FEATURES | NETIF_F_LLTX |
+				NETIF_F_NETNS_LOCAL |
+				NETIF_F_HW_VLAN_CTAG_TX |
+				NETIF_F_HW_VLAN_STAG_TX,
+				&dev->features);
+	netdev_feature_zero(&dev->hw_features);
+	netdev_feature_set_bits(COMMON_FEATURES | NETIF_F_HW_VLAN_CTAG_TX |
+				NETIF_F_HW_VLAN_STAG_TX, &dev->hw_features);
+	netdev_feature_zero(&dev->vlan_features);
+	netdev_feature_set_bits(COMMON_FEATURES, &dev->vlan_features);
 
 	br->dev = dev;
 	spin_lock_init(&br->lock);
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 914ca4b2d07c..c0a71fd6f772 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -540,8 +540,8 @@ void br_features_recompute(struct net_bridge *br, netdev_features_t *features)
 	if (list_empty(&br->port_list))
 		return;
 
-	mask = *features;
-	*features &= ~NETIF_F_ONE_FOR_ALL;
+	netdev_feature_copy(&mask, *features);
+	netdev_feature_clear_bits(NETIF_F_ONE_FOR_ALL, features);
 
 	list_for_each_entry(p, &br->port_list, list) {
 		netdev_increment_features(features, *features, p->dev->features,
-- 
2.33.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help