@@ -286,7 +286,8 @@ void emac_mac_mode_config(struct emac_adapter *adpt)
mac = readl(adpt->base + EMAC_MAC_CTRL);
mac &= ~(VLAN_STRIP | PROM_MODE | MULTI_ALL | MAC_LP_EN);
- if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
+ if (netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_RX_BIT,
+ netdev->features))
mac |= VLAN_STRIP;
if (netdev->flags & IFF_PROMISC)
@@ -1143,7 +1144,8 @@ void emac_mac_rx_process(struct emac_adapter *adpt, struct emac_rx_queue *rx_q,
skb_put(skb, RRD_PKT_SIZE(&rrd) - ETH_FCS_LEN);
skb->dev = netdev;
skb->protocol = eth_type_trans(skb, skb->dev);
- if (netdev->features & NETIF_F_RXCSUM)
+ if (netdev_feature_test_bit(NETIF_F_RXCSUM_BIT,
+ netdev->features))
skb->ip_summed = RRD_L4F(&rrd) ?
CHECKSUM_NONE : CHECKSUM_UNNECESSARY;
else
@@ -175,13 +175,16 @@ static irqreturn_t emac_isr(int _irq, void *data)
static int emac_set_features(struct net_device *netdev,
netdev_features_t features)
{
- netdev_features_t changed = features ^ netdev->features;
struct emac_adapter *adpt = netdev_priv(netdev);
+ netdev_features_t changed;
+
+ netdev_feature_xor(&changed, features, netdev->features);
/* We only need to reprogram the hardware if the VLAN tag features
* have changed, and if it's already running.
*/
- if (!(changed & (NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX)))
+ if (!netdev_feature_test_bits(NETIF_F_HW_VLAN_CTAG_TX |
+ NETIF_F_HW_VLAN_CTAG_RX, changed))
return 0;
if (!netif_running(netdev))
@@ -190,7 +193,7 @@ static int emac_set_features(struct net_device *netdev,
/* emac_mac_mode_config() uses netdev->features to configure the EMAC,
* so make sure it's set first.
*/
- netdev->features = features;
+ netdev_feature_copy(&netdev->features, features);
return emac_reinit_locked(adpt);
}
@@ -668,13 +671,15 @@ static int emac_probe(struct platform_device *pdev)
}
/* set hw features */
- netdev->features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_RXCSUM |
- NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_HW_VLAN_CTAG_RX |
- NETIF_F_HW_VLAN_CTAG_TX;
- netdev->hw_features = netdev->features;
-
- netdev->vlan_features |= NETIF_F_SG | NETIF_F_HW_CSUM |
- NETIF_F_TSO | NETIF_F_TSO6;
+ netdev_feature_zero(&netdev->features);
+ netdev_feature_set_bits(NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_RXCSUM |
+ NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_HW_VLAN_CTAG_RX |
+ NETIF_F_HW_VLAN_CTAG_TX, &netdev->features);
+ netdev_feature_copy(&netdev->hw_features, netdev->features);
+
+ netdev_feature_set_bits(NETIF_F_SG | NETIF_F_HW_CSUM |
+ NETIF_F_TSO | NETIF_F_TSO6,
+ &netdev->vlan_features);
/* MTU range: 46 - 9194 */
netdev->min_mtu = EMAC_MIN_ETH_FRAME_SIZE -
@@ -406,7 +406,8 @@ int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len)
struct rmnet_priv *priv = netdev_priv(skb->dev);
struct rmnet_map_dl_csum_trailer *csum_trailer;
- if (unlikely(!(skb->dev->features & NETIF_F_RXCSUM))) {
+ if (unlikely(!netdev_feature_test_bit(NETIF_F_RXCSUM_BIT,
+ skb->dev->features))) {
priv->stats.csum_sw++;
return -EOPNOTSUPP;
}
@@ -439,8 +440,9 @@ static void rmnet_map_v4_checksum_uplink_packet(struct sk_buff *skb,
ul_header = (struct rmnet_map_ul_csum_header *)
skb_push(skb, sizeof(struct rmnet_map_ul_csum_header));
- if (unlikely(!(orig_dev->features &
- (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM))))
+ if (unlikely(!netdev_feature_test_bits(NETIF_F_IP_CSUM |
+ NETIF_F_IPV6_CSUM,
+ orig_dev->features)))
goto sw_csum;
if (skb->ip_summed != CHECKSUM_PARTIAL)
@@ -506,7 +508,8 @@ int rmnet_map_process_next_hdr_packet(struct sk_buff *skb,
if (nexthdr_type != RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD)
return -EINVAL;
- if (unlikely(!(skb->dev->features & NETIF_F_RXCSUM))) {
+ if (unlikely(!netdev_feature_test_bit(NETIF_F_RXCSUM_BIT,
+ skb->dev->features))) {
priv->stats.csum_sw++;
} else if (next_hdr->csum_info & MAPV5_CSUMINFO_VALID_FLAG) {
priv->stats.csum_ok++;
@@ -236,7 +236,7 @@ void rmnet_vnd_setup(struct net_device *rmnet_dev)
rmnet_dev->needs_free_netdev = true;
rmnet_dev->ethtool_ops = &rmnet_ethtool_ops;
- rmnet_dev->features |= NETIF_F_LLTX;
+ netdev_feature_set_bit(NETIF_F_LLTX_BIT, &rmnet_dev->features);
/* This perm addr will be used as interface identifier by IPv6 */
rmnet_dev->addr_assign_type = NET_ADDR_RANDOM;
@@ -261,9 +261,11 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
return -EBUSY;
}
- rmnet_dev->hw_features = NETIF_F_RXCSUM;
- rmnet_dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
- rmnet_dev->hw_features |= NETIF_F_SG;
+ netdev_feature_zero(&rmnet_dev->hw_features);
+ netdev_feature_set_bit(NETIF_F_RXCSUM_BIT, &rmnet_dev->hw_features);
+ netdev_feature_set_bits(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM,
+ &rmnet_dev->hw_features);
+ netdev_feature_set_bit(NETIF_F_SG_BIT, &rmnet_dev->hw_features);
priv->real_dev = real_dev;
Use netdev_feature_xxx helpers to replace the logical operation for netdev features. Signed-off-by: Jian Shen <shenjian15@huawei.com> --- drivers/net/ethernet/qualcomm/emac/emac-mac.c | 6 +++-- drivers/net/ethernet/qualcomm/emac/emac.c | 25 +++++++++++-------- .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 11 +++++--- .../net/ethernet/qualcomm/rmnet/rmnet_vnd.c | 10 +++++--- 4 files changed, 32 insertions(+), 20 deletions(-)