@@ -852,7 +852,8 @@ int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, struct sk_buff **nskb)
/* Update the statistics if part of the FCS was read before */
len -= ETH_FCS_LEN - sz;
- if (unlikely(dev->features & NETIF_F_RXFCS)) {
+ if (unlikely(netdev_feature_test_bit(NETIF_F_RXFCS_BIT,
+ dev->features))) {
buf = (u32 *)skb_put(skb, ETH_FCS_LEN);
*buf = val;
}
@@ -714,7 +714,7 @@ static void ocelot_vlan_mode(struct ocelot *ocelot, int port,
/* Filtering */
val = ocelot_read(ocelot, ANA_VLANMASK);
- if (features & NETIF_F_HW_VLAN_CTAG_FILTER)
+ if (netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, features))
val |= BIT(port);
else
val &= ~BIT(port);
@@ -724,19 +724,22 @@ static void ocelot_vlan_mode(struct ocelot *ocelot, int port,
static int ocelot_set_features(struct net_device *dev,
netdev_features_t features)
{
- netdev_features_t changed = dev->features ^ features;
struct ocelot_port_private *priv = netdev_priv(dev);
struct ocelot *ocelot = priv->port.ocelot;
int port = priv->chip_port;
+ netdev_features_t changed;
- if ((dev->features & NETIF_F_HW_TC) > (features & NETIF_F_HW_TC) &&
+ netdev_feature_xor(&changed, dev->features, features);
+
+ if (netdev_feature_test_bit(NETIF_F_HW_TC_BIT, dev->features) &&
+ !netdev_feature_test_bit(NETIF_F_HW_TC_BIT, features) &&
priv->tc.offload_cnt) {
netdev_err(dev,
"Cannot disable HW TC offload while offloads active\n");
return -EBUSY;
}
- if (changed & NETIF_F_HW_VLAN_CTAG_FILTER)
+ if (netdev_feature_test_bit(NETIF_F_HW_VLAN_CTAG_FILTER_BIT, changed))
ocelot_vlan_mode(ocelot, port, features);
return 0;
@@ -1700,9 +1703,10 @@ int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target,
dev->netdev_ops = &ocelot_port_netdev_ops;
dev->ethtool_ops = &ocelot_ethtool_ops;
- dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_RXFCS |
- NETIF_F_HW_TC;
- dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_TC;
+ netdev_feature_set_bits(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_RXFCS |
+ NETIF_F_HW_TC, &dev->hw_features);
+ netdev_feature_set_bits(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_TC,
+ &dev->features);
memcpy(dev->dev_addr, ocelot->base_mac, ETH_ALEN);
dev->dev_addr[ETH_ALEN - 1] += port;
Use netdev_feature_xxx helpers to replace the logical operation for netdev features. Signed-off-by: Jian Shen <shenjian15@huawei.com> --- drivers/net/ethernet/mscc/ocelot.c | 3 ++- drivers/net/ethernet/mscc/ocelot_net.c | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-)