Skip to content

Commit

Permalink
net: wangxun: match VLAN CTAG and STAG features
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Sai Krishna <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Jiawen Wu authored and davem330 committed May 17, 2024
1 parent 68067f0 commit ac71ab7
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
46 changes: 46 additions & 0 deletions drivers/net/ethernet/wangxun/libwx/wx_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2701,6 +2701,52 @@ int wx_set_features(struct net_device *netdev, netdev_features_t features)
}
EXPORT_SYMBOL(wx_set_features);

#define NETIF_VLAN_STRIPPING_FEATURES (NETIF_F_HW_VLAN_CTAG_RX | \
NETIF_F_HW_VLAN_STAG_RX)

#define NETIF_VLAN_INSERTION_FEATURES (NETIF_F_HW_VLAN_CTAG_TX | \
NETIF_F_HW_VLAN_STAG_TX)

#define NETIF_VLAN_FILTERING_FEATURES (NETIF_F_HW_VLAN_CTAG_FILTER | \
NETIF_F_HW_VLAN_STAG_FILTER)

netdev_features_t wx_fix_features(struct net_device *netdev,
netdev_features_t features)
{
netdev_features_t changed = netdev->features ^ features;
struct wx *wx = netdev_priv(netdev);

if (changed & NETIF_VLAN_STRIPPING_FEATURES) {
if ((features & NETIF_VLAN_STRIPPING_FEATURES) != NETIF_VLAN_STRIPPING_FEATURES &&
(features & NETIF_VLAN_STRIPPING_FEATURES) != 0) {
features &= ~NETIF_VLAN_STRIPPING_FEATURES;
features |= netdev->features & NETIF_VLAN_STRIPPING_FEATURES;
wx_err(wx, "802.1Q and 802.1ad VLAN stripping must be either both on or both off.");
}
}

if (changed & NETIF_VLAN_INSERTION_FEATURES) {
if ((features & NETIF_VLAN_INSERTION_FEATURES) != NETIF_VLAN_INSERTION_FEATURES &&
(features & NETIF_VLAN_INSERTION_FEATURES) != 0) {
features &= ~NETIF_VLAN_INSERTION_FEATURES;
features |= netdev->features & NETIF_VLAN_INSERTION_FEATURES;
wx_err(wx, "802.1Q and 802.1ad VLAN insertion must be either both on or both off.");
}
}

if (changed & NETIF_VLAN_FILTERING_FEATURES) {
if ((features & NETIF_VLAN_FILTERING_FEATURES) != NETIF_VLAN_FILTERING_FEATURES &&
(features & NETIF_VLAN_FILTERING_FEATURES) != 0) {
features &= ~NETIF_VLAN_FILTERING_FEATURES;
features |= netdev->features & NETIF_VLAN_FILTERING_FEATURES;
wx_err(wx, "802.1Q and 802.1ad VLAN filtering must be either both on or both off.");
}
}

return features;
}
EXPORT_SYMBOL(wx_fix_features);

void wx_set_ring(struct wx *wx, u32 new_tx_count,
u32 new_rx_count, struct wx_ring *temp_ring)
{
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/wangxun/libwx/wx_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ int wx_setup_resources(struct wx *wx);
void wx_get_stats64(struct net_device *netdev,
struct rtnl_link_stats64 *stats);
int wx_set_features(struct net_device *netdev, netdev_features_t features);
netdev_features_t wx_fix_features(struct net_device *netdev,
netdev_features_t features);
void wx_set_ring(struct wx *wx, u32 new_tx_count,
u32 new_rx_count, struct wx_ring *temp_ring);

Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ static const struct net_device_ops ngbe_netdev_ops = {
.ndo_start_xmit = wx_xmit_frame,
.ndo_set_rx_mode = wx_set_rx_mode,
.ndo_set_features = wx_set_features,
.ndo_fix_features = wx_fix_features,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = wx_set_mac,
.ndo_get_stats64 = wx_get_stats64,
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ static const struct net_device_ops txgbe_netdev_ops = {
.ndo_start_xmit = wx_xmit_frame,
.ndo_set_rx_mode = wx_set_rx_mode,
.ndo_set_features = wx_set_features,
.ndo_fix_features = wx_fix_features,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = wx_set_mac,
.ndo_get_stats64 = wx_get_stats64,
Expand Down

0 comments on commit ac71ab7

Please sign in to comment.