Skip to content

Commit ef5b69d

Browse files
Jiawen Wugregkh
authored andcommitted
net: wangxun: match VLAN CTAG and STAG features
[ Upstream commit ac71ab7 ] Hardware requires VLAN CTAG and STAG configuration always matches. And whether VLAN CTAG or STAG changes, the configuration needs to be changed as well. Fixes: 6670f1e ("net: txgbe: Add netdev features support") Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com> Reviewed-by: Sai Krishna <saikrishnag@marvell.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 20844ad commit ef5b69d

4 files changed

Lines changed: 50 additions & 0 deletions

File tree

drivers/net/ethernet/wangxun/libwx/wx_lib.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,6 +2701,52 @@ int wx_set_features(struct net_device *netdev, netdev_features_t features)
27012701
}
27022702
EXPORT_SYMBOL(wx_set_features);
27032703

2704+
#define NETIF_VLAN_STRIPPING_FEATURES (NETIF_F_HW_VLAN_CTAG_RX | \
2705+
NETIF_F_HW_VLAN_STAG_RX)
2706+
2707+
#define NETIF_VLAN_INSERTION_FEATURES (NETIF_F_HW_VLAN_CTAG_TX | \
2708+
NETIF_F_HW_VLAN_STAG_TX)
2709+
2710+
#define NETIF_VLAN_FILTERING_FEATURES (NETIF_F_HW_VLAN_CTAG_FILTER | \
2711+
NETIF_F_HW_VLAN_STAG_FILTER)
2712+
2713+
netdev_features_t wx_fix_features(struct net_device *netdev,
2714+
netdev_features_t features)
2715+
{
2716+
netdev_features_t changed = netdev->features ^ features;
2717+
struct wx *wx = netdev_priv(netdev);
2718+
2719+
if (changed & NETIF_VLAN_STRIPPING_FEATURES) {
2720+
if ((features & NETIF_VLAN_STRIPPING_FEATURES) != NETIF_VLAN_STRIPPING_FEATURES &&
2721+
(features & NETIF_VLAN_STRIPPING_FEATURES) != 0) {
2722+
features &= ~NETIF_VLAN_STRIPPING_FEATURES;
2723+
features |= netdev->features & NETIF_VLAN_STRIPPING_FEATURES;
2724+
wx_err(wx, "802.1Q and 802.1ad VLAN stripping must be either both on or both off.");
2725+
}
2726+
}
2727+
2728+
if (changed & NETIF_VLAN_INSERTION_FEATURES) {
2729+
if ((features & NETIF_VLAN_INSERTION_FEATURES) != NETIF_VLAN_INSERTION_FEATURES &&
2730+
(features & NETIF_VLAN_INSERTION_FEATURES) != 0) {
2731+
features &= ~NETIF_VLAN_INSERTION_FEATURES;
2732+
features |= netdev->features & NETIF_VLAN_INSERTION_FEATURES;
2733+
wx_err(wx, "802.1Q and 802.1ad VLAN insertion must be either both on or both off.");
2734+
}
2735+
}
2736+
2737+
if (changed & NETIF_VLAN_FILTERING_FEATURES) {
2738+
if ((features & NETIF_VLAN_FILTERING_FEATURES) != NETIF_VLAN_FILTERING_FEATURES &&
2739+
(features & NETIF_VLAN_FILTERING_FEATURES) != 0) {
2740+
features &= ~NETIF_VLAN_FILTERING_FEATURES;
2741+
features |= netdev->features & NETIF_VLAN_FILTERING_FEATURES;
2742+
wx_err(wx, "802.1Q and 802.1ad VLAN filtering must be either both on or both off.");
2743+
}
2744+
}
2745+
2746+
return features;
2747+
}
2748+
EXPORT_SYMBOL(wx_fix_features);
2749+
27042750
void wx_set_ring(struct wx *wx, u32 new_tx_count,
27052751
u32 new_rx_count, struct wx_ring *temp_ring)
27062752
{

drivers/net/ethernet/wangxun/libwx/wx_lib.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ int wx_setup_resources(struct wx *wx);
3030
void wx_get_stats64(struct net_device *netdev,
3131
struct rtnl_link_stats64 *stats);
3232
int wx_set_features(struct net_device *netdev, netdev_features_t features);
33+
netdev_features_t wx_fix_features(struct net_device *netdev,
34+
netdev_features_t features);
3335
void wx_set_ring(struct wx *wx, u32 new_tx_count,
3436
u32 new_rx_count, struct wx_ring *temp_ring);
3537

drivers/net/ethernet/wangxun/ngbe/ngbe_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ static const struct net_device_ops ngbe_netdev_ops = {
499499
.ndo_start_xmit = wx_xmit_frame,
500500
.ndo_set_rx_mode = wx_set_rx_mode,
501501
.ndo_set_features = wx_set_features,
502+
.ndo_fix_features = wx_fix_features,
502503
.ndo_validate_addr = eth_validate_addr,
503504
.ndo_set_mac_address = wx_set_mac,
504505
.ndo_get_stats64 = wx_get_stats64,

drivers/net/ethernet/wangxun/txgbe/txgbe_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ static const struct net_device_ops txgbe_netdev_ops = {
428428
.ndo_start_xmit = wx_xmit_frame,
429429
.ndo_set_rx_mode = wx_set_rx_mode,
430430
.ndo_set_features = wx_set_features,
431+
.ndo_fix_features = wx_fix_features,
431432
.ndo_validate_addr = eth_validate_addr,
432433
.ndo_set_mac_address = wx_set_mac,
433434
.ndo_get_stats64 = wx_get_stats64,

0 commit comments

Comments
 (0)