@@ -1364,14 +1364,14 @@ netdev_features_t efx_features_check(struct sk_buff *skb, struct net_device *dev
struct efx_nic *efx = netdev_priv(dev);
if (skb->encapsulation) {
- if (features & NETIF_F_GSO_MASK)
+ if (netdev_features_intersects(features, NETIF_F_GSO_MASK))
/* Hardware can only do TSO with at most 208 bytes
* of headers.
*/
if (skb_inner_transport_offset(skb) >
EFX_TSO2_MAX_HDRLEN)
netdev_features_clear(&features, NETIF_F_GSO_MASK);
- if (features & netdev_csum_gso_features_mask)
+ if (netdev_features_intersects(features, netdev_csum_gso_features_mask))
if (!efx_can_encap_offloads(efx, skb))
netdev_features_clear(&features,
netdev_csum_gso_features_mask);
@@ -3593,7 +3593,7 @@ int skb_csum_hwoffload_help(struct sk_buff *skb,
if (netdev_feature_test(NETIF_F_HW_CSUM_BIT, features))
return 0;
- if (features & netdev_ip_csum_features) {
+ if (netdev_features_intersects(features, netdev_ip_csum_features)) {
switch (skb->csum_offset) {
case offsetof(struct tcphdr, check):
case offsetof(struct udphdr, check):
@@ -9461,8 +9461,8 @@ static netdev_features_t netdev_sync_upper_features(struct net_device *lower,
upper_disables = NETIF_F_UPPER_DISABLES;
for_each_netdev_feature(upper_disables, feature_bit) {
feature = __NETIF_F_BIT(feature_bit);
- if (!(upper->wanted_features & feature)
- && (features & feature)) {
+ if (!netdev_wanted_features_intersects(upper, feature) &&
+ netdev_features_intersects(features, feature)) {
netdev_dbg(lower, "Dropping feature %pNF, upper dev %s has it off.\n",
&feature, upper->name);
netdev_features_clear(&features, feature);
@@ -9482,13 +9482,14 @@ static void netdev_sync_lower_features(struct net_device *upper,
upper_disables = NETIF_F_UPPER_DISABLES;
for_each_netdev_feature(upper_disables, feature_bit) {
feature = __NETIF_F_BIT(feature_bit);
- if (!(features & feature) && (lower->features & feature)) {
+ if (!netdev_features_intersects(features, feature) &&
+ netdev_active_features_intersects(lower, feature)) {
netdev_dbg(upper, "Disabling feature %pNF on lower dev %s.\n",
&feature, lower->name);
netdev_wanted_features_clear(lower, feature);
__netdev_update_features(lower);
- if (unlikely(lower->features & feature))
+ if (unlikely(netdev_active_features_intersects(lower, feature)))
netdev_WARN(upper, "failed to disable %pNF on %s!\n",
&feature, lower->name);
else
@@ -9504,13 +9505,14 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
/* Fix illegal checksum combinations */
if (netdev_feature_test(NETIF_F_HW_CSUM_BIT, features) &&
- (features & netdev_ip_csum_features)) {
+ netdev_features_intersects(features, netdev_ip_csum_features)) {
netdev_warn(dev, "mixed HW and IP checksum settings.\n");
netdev_features_clear(&features, netdev_ip_csum_features);
}
/* TSO requires that SG is present as well. */
- if (features & NETIF_F_ALL_TSO && !netdev_feature_test(NETIF_F_SG_BIT, features)) {
+ if (netdev_features_intersects(features, NETIF_F_ALL_TSO) &&
+ !netdev_feature_test(NETIF_F_SG_BIT, features)) {
netdev_dbg(dev, "Dropping TSO features since no SG feature.\n");
netdev_features_clear(&features, NETIF_F_ALL_TSO);
}
@@ -9538,7 +9540,8 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
/* TSO ECN requires that TSO is present as well. */
tmp = NETIF_F_ALL_TSO;
netdev_feature_del(NETIF_F_TSO_ECN_BIT, &tmp);
- if (!(features & tmp) && netdev_feature_test(NETIF_F_TSO_ECN_BIT, features))
+ if (!netdev_features_intersects(features, tmp) &&
+ netdev_feature_test(NETIF_F_TSO_ECN_BIT, features))
netdev_feature_del(NETIF_F_TSO_ECN_BIT, &features);
/* Software GSO depends on SG. */
@@ -9548,7 +9551,7 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
}
/* GSO partial features require GSO partial be set */
- if ((features & dev->gso_partial_features) &&
+ if (netdev_gso_partial_features_intersects(dev, features) &&
!netdev_feature_test(NETIF_F_GSO_PARTIAL_BIT, features)) {
netdev_dbg(dev,
"Dropping partially supported GSO features since no GSO partial.\n");
@@ -165,7 +165,7 @@ static int ethtool_set_features(struct net_device *dev, void __user *useraddr)
__netdev_update_features(dev);
tmp = netdev_wanted_features_xor(dev, dev->features);
- if (tmp & valid)
+ if (netdev_features_intersects(tmp, valid))
ret |= ETHTOOL_F_WISH;
return ret;
@@ -278,7 +278,7 @@ static int ethtool_get_one_feature(struct net_device *dev,
};
mask = ethtool_get_feature_mask(ethcmd);
- edata.data = !!(dev->features & mask);
+ edata.data = !!netdev_active_features_intersects(dev, mask);
if (copy_to_user(useraddr, &edata, sizeof(edata)))
return -EFAULT;
return 0;
@@ -366,7 +366,7 @@ static int __ethtool_set_flags(struct net_device *dev, u32 data)
changed &= eth_all_features;
tmp = netdev_hw_features_andnot_r(dev, changed);
if (tmp)
- return (changed & dev->hw_features) ? -EINVAL : -EOPNOTSUPP;
+ return netdev_hw_features_intersects(dev, changed) ? -EINVAL : -EOPNOTSUPP;
netdev_wanted_features_clear(dev, changed);
tmp = features & changed;
Replace the '(f1 & f2)' operations of features by netdev_features_intersects helpers. Signed-off-by: Jian Shen <shenjian15@huawei.com> --- drivers/net/ethernet/sfc/efx_common.c | 4 ++-- net/core/dev.c | 21 ++++++++++++--------- net/ethtool/ioctl.c | 6 +++--- 3 files changed, 17 insertions(+), 14 deletions(-)