[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210929155334.12454-42-shenjian15@huawei.com>
Date: Wed, 29 Sep 2021 23:51:28 +0800
From: Jian Shen <shenjian15@...wei.com>
To: <davem@...emloft.net>, <kuba@...nel.org>, <andrew@...n.ch>,
<hkallweit1@...il.com>
CC: <netdev@...r.kernel.org>, <linuxarm@...neuler.org>
Subject: [RFCv2 net-next 041/167] team: use netdev feature helpers
Use netdev_feature_xxx helpers to replace the logical operation
for netdev features.
Signed-off-by: Jian Shen <shenjian15@...wei.com>
---
drivers/net/team/team.c | 69 +++++++++++++++++++++++++----------------
1 file changed, 42 insertions(+), 27 deletions(-)
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index fa96ee62c91a..207771e0d1c8 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -985,21 +985,30 @@ static void team_port_disable(struct team *team,
static void __team_compute_features(struct team *team)
{
struct team_port *port;
- netdev_features_t vlan_features = TEAM_VLAN_FEATURES &
- NETIF_F_ALL_FOR_ALL;
- netdev_features_t enc_features = TEAM_ENC_FEATURES;
unsigned short max_hard_header_len = ETH_HLEN;
unsigned int dst_release_flag = IFF_XMIT_DST_RELEASE |
IFF_XMIT_DST_RELEASE_PERM;
+ netdev_features_t vlan_features;
+ netdev_features_t enc_features;
+ netdev_features_t mask_vlan;
+ netdev_features_t mask_enc;
+
+ netdev_feature_zero(&vlan_features);
+ netdev_feature_set_bits(TEAM_VLAN_FEATURES & NETIF_F_ALL_FOR_ALL,
+ &vlan_features);
+ netdev_feature_zero(&enc_features);
+ netdev_feature_set_bits(TEAM_ENC_FEATURES, &enc_features);
+ netdev_feature_zero(&mask_vlan);
+ netdev_feature_set_bits(TEAM_VLAN_FEATURES, &mask_vlan);
+ netdev_feature_zero(&mask_enc);
+ netdev_feature_set_bits(TEAM_ENC_FEATURES, &mask_enc);
rcu_read_lock();
list_for_each_entry_rcu(port, &team->port_list, list) {
netdev_increment_features(&vlan_features, vlan_features,
- port->dev->vlan_features,
- TEAM_VLAN_FEATURES);
+ port->dev->vlan_features, mask_vlan);
netdev_increment_features(&enc_features, enc_features,
- port->dev->hw_enc_features,
- TEAM_ENC_FEATURES);
+ port->dev->hw_enc_features, mask_enc);
dst_release_flag &= port->dev->priv_flags;
if (port->dev->hard_header_len > max_hard_header_len)
@@ -1007,10 +1016,12 @@ static void __team_compute_features(struct team *team)
}
rcu_read_unlock();
- team->dev->vlan_features = vlan_features;
- team->dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL |
- NETIF_F_HW_VLAN_CTAG_TX |
- NETIF_F_HW_VLAN_STAG_TX;
+ netdev_feature_copy(&team->dev->vlan_features, vlan_features);
+ netdev_feature_copy(&team->dev->hw_enc_features, enc_features);
+ netdev_feature_set_bits(NETIF_F_GSO_ENCAP_ALL |
+ NETIF_F_HW_VLAN_CTAG_TX |
+ NETIF_F_HW_VLAN_STAG_TX,
+ &team->dev->hw_enc_features);
team->dev->hard_header_len = max_hard_header_len;
team->dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
@@ -1161,7 +1172,8 @@ static int team_port_add(struct team *team, struct net_device *port_dev,
return -EBUSY;
}
- if (port_dev->features & NETIF_F_VLAN_CHALLENGED &&
+ if (netdev_feature_test_bit(NETIF_F_VLAN_CHALLENGED_BIT,
+ port_dev->features) &&
vlan_uses_dev(dev)) {
NL_SET_ERR_MSG(extack, "Device is VLAN challenged and team device has VLAN set up");
netdev_err(dev, "Device %s is VLAN challenged and team device has VLAN set up\n",
@@ -1226,7 +1238,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev,
goto err_enable_netpoll;
}
- if (!(dev->features & NETIF_F_LRO))
+ if (!netdev_feature_test_bit(NETIF_F_LRO_BIT, dev->features))
dev_disable_lro(port_dev);
err = netdev_rx_handler_register(port_dev, team_handle_frame,
@@ -2000,9 +2012,9 @@ static void team_fix_features(struct net_device *dev,
struct team *team = netdev_priv(dev);
netdev_features_t mask;
- mask = *features;
- *features &= ~NETIF_F_ONE_FOR_ALL;
- *features |= NETIF_F_ALL_FOR_ALL;
+ netdev_feature_copy(&mask, *features);
+ netdev_feature_clear_bits(NETIF_F_ONE_FOR_ALL, features);
+ netdev_feature_set_bits(NETIF_F_ALL_FOR_ALL, features);
rcu_read_lock();
list_for_each_entry_rcu(port, &team->port_list, list) {
@@ -2160,19 +2172,22 @@ static void team_setup(struct net_device *dev)
*/
dev->priv_flags |= IFF_UNICAST_FLT | IFF_LIVE_ADDR_CHANGE;
- dev->features |= NETIF_F_LLTX;
- dev->features |= NETIF_F_GRO;
+ netdev_feature_set_bit(NETIF_F_LLTX_BIT, &dev->features);
+ netdev_feature_set_bit(NETIF_F_GRO_BIT, &dev->features);
/* Don't allow team devices to change network namespaces. */
- dev->features |= NETIF_F_NETNS_LOCAL;
-
- dev->hw_features = TEAM_VLAN_FEATURES |
- NETIF_F_HW_VLAN_CTAG_RX |
- NETIF_F_HW_VLAN_CTAG_FILTER;
-
- dev->hw_features |= NETIF_F_GSO_ENCAP_ALL;
- dev->features |= dev->hw_features;
- dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
+ netdev_feature_set_bit(NETIF_F_NETNS_LOCAL_BIT, &dev->features);
+
+ netdev_feature_set_bits(TEAM_VLAN_FEATURES |
+ NETIF_F_HW_VLAN_CTAG_RX |
+ NETIF_F_HW_VLAN_CTAG_FILTER,
+ &dev->hw_features);
+
+ netdev_feature_set_bits(NETIF_F_GSO_ENCAP_ALL, &dev->hw_features);
+ netdev_feature_or(&dev->features, dev->features, dev->hw_features);
+ netdev_feature_set_bits(NETIF_F_HW_VLAN_CTAG_TX |
+ NETIF_F_HW_VLAN_STAG_TX,
+ &dev->features);
}
static int team_newlink(struct net *src_net, struct net_device *dev,
--
2.33.0
Powered by blists - more mailing lists