Message ID | 20240429102519.25096-4-jiawenwu@trustnetic.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Wangxun fixes | expand |
> -----Original Message----- > From: Jiawen Wu <jiawenwu@trustnetic.com> > Sent: Monday, April 29, 2024 3:55 PM > To: davem@davemloft.net; edumazet@google.com; kuba@kernel.org; > pabeni@redhat.com; rmk+kernel@armlinux.org.uk; andrew@lunn.ch; > netdev@vger.kernel.org > Cc: mengyuanlou@net-swift.com; duanqiangwen@net-swift.com; Jiawen Wu > <jiawenwu@trustnetic.com> > Subject: [PATCH net v2 3/4] net: wangxun: match VLAN CTAG and > STAG features > > 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: 6670f1ece2c8 ("net: txgbe: Add netdev features support") > Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com> > --- > drivers/net/ethernet/wangxun/libwx/wx_lib.c | 46 +++++++++++++++++++ > drivers/net/ethernet/wangxun/libwx/wx_lib.h | 2 + > drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 1 + > .../net/ethernet/wangxun/txgbe/txgbe_main.c | 1 + > 4 files changed, 50 insertions(+) > > diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c > b/drivers/net/ethernet/wangxun/libwx/wx_lib.c > index 667a5675998c..aefd78455468 100644 > --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c > +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c > @@ -2701,6 +2701,52 @@ int wx_set_features(struct net_device *netdev, > netdev_features_t features) } EXPORT_SYMBOL(wx_set_features); > > +netdev_features_t wx_fix_features(struct net_device *netdev, > + netdev_features_t features) > +{ > + netdev_features_t changed = netdev->features ^ features; > + > + if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) { > + if (features & NETIF_F_HW_VLAN_CTAG_FILTER) > + features |= NETIF_F_HW_VLAN_STAG_FILTER; > + else > + features &= ~NETIF_F_HW_VLAN_STAG_FILTER; > + } > + if (changed & NETIF_F_HW_VLAN_STAG_FILTER) { > + if (features & NETIF_F_HW_VLAN_STAG_FILTER) > + features |= NETIF_F_HW_VLAN_CTAG_FILTER; > + else > + features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; > + } > + if (changed & NETIF_F_HW_VLAN_CTAG_RX) { > + if (features & NETIF_F_HW_VLAN_CTAG_RX) > + features |= NETIF_F_HW_VLAN_STAG_RX; > + else > + features &= ~NETIF_F_HW_VLAN_STAG_RX; > + } > + if (changed & NETIF_F_HW_VLAN_STAG_RX) { > + if (features & NETIF_F_HW_VLAN_STAG_RX) > + features |= NETIF_F_HW_VLAN_CTAG_RX; > + else > + features &= ~NETIF_F_HW_VLAN_CTAG_RX; > + } > + if (changed & NETIF_F_HW_VLAN_CTAG_TX) { > + if (features & NETIF_F_HW_VLAN_CTAG_TX) > + features |= NETIF_F_HW_VLAN_STAG_TX; > + else > + features &= ~NETIF_F_HW_VLAN_STAG_TX; > + } > + if (changed & NETIF_F_HW_VLAN_STAG_TX) { > + if (features & NETIF_F_HW_VLAN_STAG_TX) > + features |= NETIF_F_HW_VLAN_CTAG_TX; > + else > + features &= ~NETIF_F_HW_VLAN_CTAG_TX; > + } > + > + 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) { diff --git > a/drivers/net/ethernet/wangxun/libwx/wx_lib.h > b/drivers/net/ethernet/wangxun/libwx/wx_lib.h > index ec909e876720..c41b29ea812f 100644 > --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.h > +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.h > @@ -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); > > diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c > b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c > index fdd6b4f70b7a..e894e01d030d 100644 > --- a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c > +++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c > @@ -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, > diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c > b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c > index bd4624d14ca0..b3c0058b045d 100644 > --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c > +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c > @@ -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, > -- > 2.27.0 > Reviewed-by: Sai Krishna <saikrishnag@marvell.com
On Mon, Apr 29, 2024 at 06:25:18PM +0800, Jiawen Wu wrote: > 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: 6670f1ece2c8 ("net: txgbe: Add netdev features support") > Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com> Hi Jiawen Wu, Thanks for addressing my review of v1. Reviewed-by: Simon Horman <horms@kernel.org> ...
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c index 667a5675998c..aefd78455468 100644 --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c @@ -2701,6 +2701,52 @@ int wx_set_features(struct net_device *netdev, netdev_features_t features) } EXPORT_SYMBOL(wx_set_features); +netdev_features_t wx_fix_features(struct net_device *netdev, + netdev_features_t features) +{ + netdev_features_t changed = netdev->features ^ features; + + if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) { + if (features & NETIF_F_HW_VLAN_CTAG_FILTER) + features |= NETIF_F_HW_VLAN_STAG_FILTER; + else + features &= ~NETIF_F_HW_VLAN_STAG_FILTER; + } + if (changed & NETIF_F_HW_VLAN_STAG_FILTER) { + if (features & NETIF_F_HW_VLAN_STAG_FILTER) + features |= NETIF_F_HW_VLAN_CTAG_FILTER; + else + features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; + } + if (changed & NETIF_F_HW_VLAN_CTAG_RX) { + if (features & NETIF_F_HW_VLAN_CTAG_RX) + features |= NETIF_F_HW_VLAN_STAG_RX; + else + features &= ~NETIF_F_HW_VLAN_STAG_RX; + } + if (changed & NETIF_F_HW_VLAN_STAG_RX) { + if (features & NETIF_F_HW_VLAN_STAG_RX) + features |= NETIF_F_HW_VLAN_CTAG_RX; + else + features &= ~NETIF_F_HW_VLAN_CTAG_RX; + } + if (changed & NETIF_F_HW_VLAN_CTAG_TX) { + if (features & NETIF_F_HW_VLAN_CTAG_TX) + features |= NETIF_F_HW_VLAN_STAG_TX; + else + features &= ~NETIF_F_HW_VLAN_STAG_TX; + } + if (changed & NETIF_F_HW_VLAN_STAG_TX) { + if (features & NETIF_F_HW_VLAN_STAG_TX) + features |= NETIF_F_HW_VLAN_CTAG_TX; + else + features &= ~NETIF_F_HW_VLAN_CTAG_TX; + } + + 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) { diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.h b/drivers/net/ethernet/wangxun/libwx/wx_lib.h index ec909e876720..c41b29ea812f 100644 --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.h +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.h @@ -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); diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c index fdd6b4f70b7a..e894e01d030d 100644 --- a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c +++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c @@ -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, diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c index bd4624d14ca0..b3c0058b045d 100644 --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c @@ -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,
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: 6670f1ece2c8 ("net: txgbe: Add netdev features support") Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com> --- drivers/net/ethernet/wangxun/libwx/wx_lib.c | 46 +++++++++++++++++++ drivers/net/ethernet/wangxun/libwx/wx_lib.h | 2 + drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 1 + .../net/ethernet/wangxun/txgbe/txgbe_main.c | 1 + 4 files changed, 50 insertions(+)