
Use netdev_feature_xxx helpers to replace the logical operation for netdev features. Signed-off-by: Jian Shen <shenjian15@huawei.com> --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 50 +++++++++++++++++++---------- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 6a6ef1c..ae314ec 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1348,7 +1348,8 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, skb_set_hash(skb, hash, PKT_HASH_TYPE_L4); } - if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX && + if (netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_RX_BIT, + netdev->features) && (trxd.rxd2 & RX_DMA_VTAG)) __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), RX_DMA_VID(trxd.rxd3)); @@ -2024,14 +2025,14 @@ static int mtk_hwlro_get_fdir_all(struct net_device *dev, static void mtk_fix_features(struct net_device *dev, netdev_features_t *features) { - if (!(*features & NETIF_F_LRO)) { + if (!netdev_feature_test_bit(NETIF_F_LRO_BIT, *features)) { struct mtk_mac *mac = netdev_priv(dev); int ip_cnt = mtk_hwlro_get_ip_cnt(mac); if (ip_cnt) { netdev_info(dev, "RX flow is programmed, LRO should keep on\n"); - *features |= NETIF_F_LRO; + netdev_feature_set_bit(NETIF_F_LRO_BIT, features); } } } @@ -2040,10 +2041,11 @@ static int mtk_set_features(struct net_device *dev, netdev_features_t features) { int err = 0; - if (!((dev->features ^ features) & NETIF_F_LRO)) + if (netdev_feature_test_bit(NETIF_F_LRO_BIT, dev->features) == + netdev_feature_test_bit(NETIF_F_LRO_BIT, features)) return 0; - if (!(features & NETIF_F_LRO)) + if (!netdev_feature_test_bit(NETIF_F_LRO_BIT, features)) mtk_hwlro_netdev_disable(dev); return err; @@ -2859,13 +2861,15 @@ static int mtk_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, switch (cmd->cmd) { case ETHTOOL_GRXRINGS: - if (dev->hw_features & NETIF_F_LRO) { + if (netdev_feature_test_bit(NETIF_F_LRO_BIT, + dev->hw_features)) { cmd->data = MTK_MAX_RX_RING_NUM; ret = 0; } break; case ETHTOOL_GRXCLSRLCNT: - if (dev->hw_features & NETIF_F_LRO) { + if (netdev_feature_test_bit(NETIF_F_LRO_BIT, + dev->hw_features)) { struct mtk_mac *mac = netdev_priv(dev); cmd->rule_cnt = mac->hwlro_ip_cnt; @@ -2873,11 +2877,13 @@ static int mtk_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, } break; case ETHTOOL_GRXCLSRULE: - if (dev->hw_features & NETIF_F_LRO) + if (netdev_feature_test_bit(NETIF_F_LRO_BIT, + dev->hw_features)) ret = mtk_hwlro_get_fdir_entry(dev, cmd); break; case ETHTOOL_GRXCLSRLALL: - if (dev->hw_features & NETIF_F_LRO) + if (netdev_feature_test_bit(NETIF_F_LRO_BIT, + dev->hw_features)) ret = mtk_hwlro_get_fdir_all(dev, cmd, rule_locs); break; @@ -2894,11 +2900,13 @@ static int mtk_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd) switch (cmd->cmd) { case ETHTOOL_SRXCLSRLINS: - if (dev->hw_features & NETIF_F_LRO) + if (netdev_feature_test_bit(NETIF_F_LRO_BIT, + dev->hw_features)) ret = mtk_hwlro_add_ipaddr(dev, cmd); break; case ETHTOOL_SRXCLSRLDEL: - if (dev->hw_features & NETIF_F_LRO) + if (netdev_feature_test_bit(NETIF_F_LRO_BIT, + dev->hw_features)) ret = mtk_hwlro_del_ipaddr(dev, cmd); break; default: @@ -3023,13 +3031,21 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) eth->netdev[id]->netdev_ops = &mtk_netdev_ops; eth->netdev[id]->base_addr = (unsigned long)eth->base; - eth->netdev[id]->hw_features = eth->soc->hw_features; + netdev_feature_zero(ð->netdev[id]->hw_features); + netdev_feature_set_bits(eth->soc->hw_features, + ð->netdev[id]->hw_features); if (eth->hwlro) - eth->netdev[id]->hw_features |= NETIF_F_LRO; - - eth->netdev[id]->vlan_features = eth->soc->hw_features & - ~(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX); - eth->netdev[id]->features |= eth->soc->hw_features; + netdev_feature_set_bit(NETIF_F_LRO_BIT, + ð->netdev[id]->hw_features); + + netdev_feature_zero(ð->netdev[id]->vlan_features); + netdev_feature_set_bits(eth->soc->hw_features, + ð->netdev[id]->vlan_features); + netdev_feature_clear_bits(NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_CTAG_RX, + ð->netdev[id]->vlan_features); + netdev_feature_set_bits(eth->soc->hw_features, + ð->netdev[id]->features); eth->netdev[id]->ethtool_ops = &mtk_ethtool_ops; eth->netdev[id]->irq = eth->irq[0]; diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 5ef70dd..a7ab8e3 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -844,7 +844,7 @@ struct mtk_soc_data { u32 required_clks; bool required_pctl; u8 offload_version; - netdev_features_t hw_features; + u64 hw_features; }; /* currently no SoC has more than 2 macs */ -- 2.8.1