Skip to content

Commit a196e96

Browse files
Edwin Peerdavem330
authored andcommitted
bnxt_en: clean up VLAN feature bit handling
The hardware VLAN offload feature on our NIC does not have separate knobs for handling customer and service tags on RX. Either offloading of both must be enabled or both must be disabled. Introduce definitions for the combined feature set in order to clean up the code and make this constraint more clear. Technically these features can be separately enabled on TX, however, since the default is to turn both on, the combined TX feature set is also introduced for code consistency. Signed-off-by: Edwin Peer <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bd3191b commit a196e96

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
16141614
skb_set_hash(skb, tpa_info->rss_hash, tpa_info->hash_type);
16151615

16161616
if ((tpa_info->flags2 & RX_CMP_FLAGS2_META_FORMAT_VLAN) &&
1617-
(skb->dev->features & NETIF_F_HW_VLAN_CTAG_RX)) {
1617+
(skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)) {
16181618
u16 vlan_proto = tpa_info->metadata >>
16191619
RX_CMP_FLAGS2_METADATA_TPID_SFT;
16201620
u16 vtag = tpa_info->metadata & RX_CMP_FLAGS2_METADATA_TCI_MASK;
@@ -1832,7 +1832,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
18321832

18331833
if ((rxcmp1->rx_cmp_flags2 &
18341834
cpu_to_le32(RX_CMP_FLAGS2_META_FORMAT_VLAN)) &&
1835-
(skb->dev->features & NETIF_F_HW_VLAN_CTAG_RX)) {
1835+
(skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)) {
18361836
u32 meta_data = le32_to_cpu(rxcmp1->rx_cmp_meta_data);
18371837
u16 vtag = meta_data & RX_CMP_FLAGS2_METADATA_TCI_MASK;
18381838
u16 vlan_proto = meta_data >> RX_CMP_FLAGS2_METADATA_TPID_SFT;
@@ -9932,24 +9932,16 @@ static netdev_features_t bnxt_fix_features(struct net_device *dev,
99329932
/* Both CTAG and STAG VLAN accelaration on the RX side have to be
99339933
* turned on or off together.
99349934
*/
9935-
vlan_features = features & (NETIF_F_HW_VLAN_CTAG_RX |
9936-
NETIF_F_HW_VLAN_STAG_RX);
9937-
if (vlan_features != (NETIF_F_HW_VLAN_CTAG_RX |
9938-
NETIF_F_HW_VLAN_STAG_RX)) {
9939-
if (dev->features & NETIF_F_HW_VLAN_CTAG_RX)
9940-
features &= ~(NETIF_F_HW_VLAN_CTAG_RX |
9941-
NETIF_F_HW_VLAN_STAG_RX);
9935+
vlan_features = features & BNXT_HW_FEATURE_VLAN_ALL_RX;
9936+
if (vlan_features != BNXT_HW_FEATURE_VLAN_ALL_RX) {
9937+
if (dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)
9938+
features &= ~BNXT_HW_FEATURE_VLAN_ALL_RX;
99429939
else if (vlan_features)
9943-
features |= NETIF_F_HW_VLAN_CTAG_RX |
9944-
NETIF_F_HW_VLAN_STAG_RX;
9940+
features |= BNXT_HW_FEATURE_VLAN_ALL_RX;
99459941
}
99469942
#ifdef CONFIG_BNXT_SRIOV
9947-
if (BNXT_VF(bp)) {
9948-
if (bp->vf.vlan) {
9949-
features &= ~(NETIF_F_HW_VLAN_CTAG_RX |
9950-
NETIF_F_HW_VLAN_STAG_RX);
9951-
}
9952-
}
9943+
if (BNXT_VF(bp) && bp->vf.vlan)
9944+
features &= ~BNXT_HW_FEATURE_VLAN_ALL_RX;
99539945
#endif
99549946
return features;
99559947
}
@@ -9972,7 +9964,7 @@ static int bnxt_set_features(struct net_device *dev, netdev_features_t features)
99729964
if (bp->flags & BNXT_FLAG_NO_AGG_RINGS)
99739965
flags &= ~BNXT_FLAG_TPA;
99749966

9975-
if (features & NETIF_F_HW_VLAN_CTAG_RX)
9967+
if (features & BNXT_HW_FEATURE_VLAN_ALL_RX)
99769968
flags |= BNXT_FLAG_STRIP_VLAN;
99779969

99789970
if (features & NETIF_F_NTUPLE)
@@ -12060,8 +12052,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1206012052
dev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM |
1206112053
NETIF_F_GSO_GRE_CSUM;
1206212054
dev->vlan_features = dev->hw_features | NETIF_F_HIGHDMA;
12063-
dev->hw_features |= NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX |
12064-
NETIF_F_HW_VLAN_STAG_RX | NETIF_F_HW_VLAN_STAG_TX;
12055+
dev->hw_features |= BNXT_HW_FEATURE_VLAN_ALL_RX |
12056+
BNXT_HW_FEATURE_VLAN_ALL_TX;
1206512057
if (BNXT_SUPPORTS_TPA(bp))
1206612058
dev->hw_features |= NETIF_F_GRO_HW;
1206712059
dev->features |= dev->hw_features | NETIF_F_HIGHDMA;
@@ -12117,7 +12109,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1211712109

1211812110
bnxt_fw_init_one_p3(bp);
1211912111

12120-
if (dev->hw_features & NETIF_F_HW_VLAN_CTAG_RX)
12112+
if (dev->hw_features & BNXT_HW_FEATURE_VLAN_ALL_RX)
1212112113
bp->flags |= BNXT_FLAG_STRIP_VLAN;
1212212114

1212312115
rc = bnxt_init_int_mode(bp);

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,6 +1906,11 @@ struct bnxt {
19061906
#define BNXT_PCIE_STATS_OFFSET(counter) \
19071907
(offsetof(struct pcie_ctx_hw_stats, counter) / 8)
19081908

1909+
#define BNXT_HW_FEATURE_VLAN_ALL_RX \
1910+
(NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX)
1911+
#define BNXT_HW_FEATURE_VLAN_ALL_TX \
1912+
(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX)
1913+
19091914
#define I2C_DEV_ADDR_A0 0xa0
19101915
#define I2C_DEV_ADDR_A2 0xa2
19111916
#define SFF_DIAG_SUPPORT_OFFSET 0x5c

0 commit comments

Comments
 (0)