在 2021/8/11 22:44, Jian Shen 写道:
Use netdev_feature_xxx helpers to replace the logical operation for netdev features.
Signed-off-by: Jian Shen shenjian15@huawei.com
drivers/net/ipvlan/ipvlan_main.c | 28 ++++++++++++++++++---------- drivers/net/ipvlan/ipvtap.c | 4 ++-- 2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index 6a0b7bd..84ad786a 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c @@ -135,11 +135,14 @@ static int ipvlan_init(struct net_device *dev)
dev->state = (dev->state & ~IPVLAN_STATE_MASK) | (phy_dev->state & IPVLAN_STATE_MASK);
- dev->features = phy_dev->features & IPVLAN_FEATURES;
- dev->features |= IPVLAN_ALWAYS_ON;
- dev->vlan_features = phy_dev->vlan_features & IPVLAN_FEATURES;
- dev->vlan_features |= IPVLAN_ALWAYS_ON_OFLOADS;
- dev->hw_enc_features |= dev->features;
- netdev_feature_copy(&dev->features, phy_dev->features);
- netdev_feature_and_bits(IPVLAN_FEATURES, &dev->features);
- netdev_feature_set_bits(IPVLAN_ALWAYS_ON, &dev->features);
- netdev_feature_copy(&dev->vlan_features, phy_dev->vlan_features);
- netdev_feature_and_bits(IPVLAN_FEATURES, &dev->vlan_features);
- netdev_feature_set_bits(IPVLAN_ALWAYS_ON_OFLOADS, &dev->vlan_features);
- netdev_feature_or(&dev->hw_enc_features, dev->hw_enc_features,
dev->gso_max_size = phy_dev->gso_max_size; dev->gso_max_segs = phy_dev->gso_max_segs; dev->hard_header_len = phy_dev->hard_header_len;dev->features);
@@ -239,13 +242,17 @@ static void ipvlan_fix_features(struct net_device *dev, netdev_features_t *features) { struct ipvl_dev *ipvlan = netdev_priv(dev);
- netdev_features_t tmp;
- *features |= NETIF_F_ALL_FOR_ALL;
- *features &= (ipvlan->sfeatures | ~IPVLAN_FEATURES);
- netdev_feature_set_bits(NETIF_F_ALL_FOR_ALL, features);
- netdev_feature_fill(&tmp);
- netdev_feature_clear_bits(IPVLAN_FEATURES, &tmp);
- netdev_feature_or(&tmp, tmp, ipvlan->sfeatures);
- netdev_feature_and(features, *features, tmp); netdev_increment_features(features, ipvlan->phy_dev->features, *features, *features);
- *features |= IPVLAN_ALWAYS_ON;
- *features &= (IPVLAN_FEATURES | IPVLAN_ALWAYS_ON);
netdev_feature_set_bits(IPVLAN_ALWAYS_ON, features);
netdev_feature_and_bits(IPVLAN_FEATURES | IPVLAN_ALWAYS_ON, features); }
static void ipvlan_change_rx_flags(struct net_device *dev, int change)
@@ -567,7 +574,8 @@ int ipvlan_link_new(struct net *src_net, struct net_device *dev,
ipvlan->phy_dev = phy_dev; ipvlan->dev = dev;
- ipvlan->sfeatures = IPVLAN_FEATURES;
- netdev_feature_zero(&ipvlan->sfeatures);
- netdev_feature_set_bits(IPVLAN_FEATURES, &ipvlan->sfeatures); if (!tb[IFLA_MTU]) ipvlan_adjust_mtu(ipvlan, phy_dev); INIT_LIST_HEAD(&ipvlan->addrs);
diff --git a/drivers/net/ipvlan/ipvtap.c b/drivers/net/ipvlan/ipvtap.c index 1cedb63..e7fb343 100644 --- a/drivers/net/ipvlan/ipvtap.c +++ b/drivers/net/ipvlan/ipvtap.c @@ -70,7 +70,7 @@ static void ipvtap_update_features(struct tap_dev *tap, struct ipvtap_dev *vlantap = container_of(tap, struct ipvtap_dev, tap); struct ipvl_dev *vlan = &vlantap->vlan;
- vlan->sfeatures = features;
- netdev_feature_copy(&vlan->sfeatures, features); netdev_update_features(vlan->dev); }
@@ -86,7 +86,7 @@ static int ipvtap_newlink(struct net *src_net, struct net_device *dev, /* Since macvlan supports all offloads by default, make * tap support all offloads also. */
- vlantap->tap.tap_features = TUN_OFFLOADS;
missing "netdev_feature_zero(vlantap->tap.tap_features)" here, will fix it next version.
- netdev_feature_set_bits(TUN_OFFLOADS, &vlantap->tap.tap_features); vlantap->tap.count_tx_dropped = ipvtap_count_tx_dropped; vlantap->tap.update_features = ipvtap_update_features; vlantap->tap.count_rx_dropped = ipvtap_count_rx_dropped;