Skip to content

Commit dc9b5ce

Browse files
IronShendavem330
authored andcommitted
net: hns3: refine function hns3_set_default_feature()
Currently, the driver sets default feature for netdev->features, netdev->hw_features, netdev->vlan_features and netdev->hw_enc_features separately. It's fussy, because most of the feature bits are same. So refine it by copy value from netdev->features. Signed-off-by: Jian Shen <[email protected]> Signed-off-by: Guangbin Huang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 53c622d commit dc9b5ce

File tree

1 file changed

+16
-46
lines changed

1 file changed

+16
-46
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3126,11 +3126,6 @@ static void hns3_set_default_feature(struct net_device *netdev)
31263126

31273127
netdev->priv_flags |= IFF_UNICAST_FLT;
31283128

3129-
netdev->hw_enc_features |= NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_GSO |
3130-
NETIF_F_GRO | NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_GSO_GRE |
3131-
NETIF_F_GSO_GRE_CSUM | NETIF_F_GSO_UDP_TUNNEL |
3132-
NETIF_F_SCTP_CRC | NETIF_F_TSO_MANGLEID | NETIF_F_FRAGLIST;
3133-
31343129
netdev->gso_partial_features |= NETIF_F_GSO_GRE_CSUM;
31353130

31363131
netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER |
@@ -3140,62 +3135,37 @@ static void hns3_set_default_feature(struct net_device *netdev)
31403135
NETIF_F_GSO_GRE_CSUM | NETIF_F_GSO_UDP_TUNNEL |
31413136
NETIF_F_SCTP_CRC | NETIF_F_FRAGLIST;
31423137

3143-
netdev->vlan_features |= NETIF_F_RXCSUM |
3144-
NETIF_F_SG | NETIF_F_GSO | NETIF_F_GRO |
3145-
NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_GSO_GRE |
3146-
NETIF_F_GSO_GRE_CSUM | NETIF_F_GSO_UDP_TUNNEL |
3147-
NETIF_F_SCTP_CRC | NETIF_F_FRAGLIST;
3148-
3149-
netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_TX |
3150-
NETIF_F_HW_VLAN_CTAG_RX |
3151-
NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_GSO |
3152-
NETIF_F_GRO | NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_GSO_GRE |
3153-
NETIF_F_GSO_GRE_CSUM | NETIF_F_GSO_UDP_TUNNEL |
3154-
NETIF_F_SCTP_CRC | NETIF_F_FRAGLIST;
3155-
31563138
if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) {
3157-
netdev->hw_features |= NETIF_F_GRO_HW;
31583139
netdev->features |= NETIF_F_GRO_HW;
31593140

3160-
if (!(h->flags & HNAE3_SUPPORT_VF)) {
3161-
netdev->hw_features |= NETIF_F_NTUPLE;
3141+
if (!(h->flags & HNAE3_SUPPORT_VF))
31623142
netdev->features |= NETIF_F_NTUPLE;
3163-
}
31643143
}
31653144

3166-
if (test_bit(HNAE3_DEV_SUPPORT_UDP_GSO_B, ae_dev->caps)) {
3167-
netdev->hw_features |= NETIF_F_GSO_UDP_L4;
3145+
if (test_bit(HNAE3_DEV_SUPPORT_UDP_GSO_B, ae_dev->caps))
31683146
netdev->features |= NETIF_F_GSO_UDP_L4;
3169-
netdev->vlan_features |= NETIF_F_GSO_UDP_L4;
3170-
netdev->hw_enc_features |= NETIF_F_GSO_UDP_L4;
3171-
}
31723147

3173-
if (test_bit(HNAE3_DEV_SUPPORT_HW_TX_CSUM_B, ae_dev->caps)) {
3174-
netdev->hw_features |= NETIF_F_HW_CSUM;
3148+
if (test_bit(HNAE3_DEV_SUPPORT_HW_TX_CSUM_B, ae_dev->caps))
31753149
netdev->features |= NETIF_F_HW_CSUM;
3176-
netdev->vlan_features |= NETIF_F_HW_CSUM;
3177-
netdev->hw_enc_features |= NETIF_F_HW_CSUM;
3178-
} else {
3179-
netdev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
3150+
else
31803151
netdev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
3181-
netdev->vlan_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
3182-
netdev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
3183-
}
31843152

3185-
if (test_bit(HNAE3_DEV_SUPPORT_UDP_TUNNEL_CSUM_B, ae_dev->caps)) {
3186-
netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL_CSUM;
3153+
if (test_bit(HNAE3_DEV_SUPPORT_UDP_TUNNEL_CSUM_B, ae_dev->caps))
31873154
netdev->features |= NETIF_F_GSO_UDP_TUNNEL_CSUM;
3188-
netdev->vlan_features |= NETIF_F_GSO_UDP_TUNNEL_CSUM;
3189-
netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL_CSUM;
3190-
}
31913155

3192-
if (test_bit(HNAE3_DEV_SUPPORT_FD_FORWARD_TC_B, ae_dev->caps)) {
3193-
netdev->hw_features |= NETIF_F_HW_TC;
3156+
if (test_bit(HNAE3_DEV_SUPPORT_FD_FORWARD_TC_B, ae_dev->caps))
31943157
netdev->features |= NETIF_F_HW_TC;
3195-
}
31963158

3197-
if (test_bit(HNAE3_DEV_SUPPORT_VLAN_FLTR_MDF_B, ae_dev->caps))
3198-
netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
3159+
netdev->hw_features |= netdev->features;
3160+
if (!test_bit(HNAE3_DEV_SUPPORT_VLAN_FLTR_MDF_B, ae_dev->caps))
3161+
netdev->hw_features &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
3162+
3163+
netdev->vlan_features |= netdev->features &
3164+
~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_CTAG_TX |
3165+
NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_GRO_HW | NETIF_F_NTUPLE |
3166+
NETIF_F_HW_TC);
3167+
3168+
netdev->hw_enc_features |= netdev->vlan_features | NETIF_F_TSO_MANGLEID;
31993169
}
32003170

32013171
static int hns3_alloc_buffer(struct hns3_enet_ring *ring,

0 commit comments

Comments
 (0)