Netdev List
 help / color / mirror / Atom feed
From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Jiawen Wu <jiawenwu@trustnetic.com>
Cc: Duanqiang Wen <duanqiangwen@net-swift.com>,
	<netdev@vger.kernel.org>,
	Mengyuan Lou <mengyuanlou@net-swift.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Jacob Keller <jacob.e.keller@intel.com>,
	Kees Cook <kees@kernel.org>
Subject: Re: [PATCH net-next] net: libwx: disable TX VLAN offload for packets with >2 VLAN tags
Date: Fri, 10 Jul 2026 11:49:13 +0200	[thread overview]
Message-ID: <f0be57b5-8574-4107-bb31-e1658b73267f@intel.com> (raw)
In-Reply-To: <C1BF77C0E073A40C+20260710071831.210196-1-jiawenwu@trustnetic.com>

On 7/10/26 09:18, Jiawen Wu wrote:
> The current hardware does not support TX VLAN offload for packets with
> three or more VLAN tags. When such packets are transmitted with hardware
> VLAN offload enabled, the hardware may malfunction or produce corrupted
> frames.
> 
> Add a check in wx_features_check() to parse the VLAN depth of the
> skb. If more than two VLAN tags are detected (including both the
> hardware tag and in-band tags), strip NETIF_F_HW_VLAN_CTAG_TX and
> NETIF_F_HW_VLAN_STAG_TX from the feature set. This forces the
> kernel networking stack to handle VLAN insertion in software for
> these specific packets, ensuring correct transmission.
> 
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> ---
>   drivers/net/ethernet/wangxun/libwx/wx_lib.c | 25 +++++++++++++++++++++
>   1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> index 814d88d2aee4..65dab6bd8a39 100644
> --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> @@ -3223,12 +3223,37 @@ netdev_features_t wx_fix_features(struct net_device *netdev,
>   EXPORT_SYMBOL(wx_fix_features);
>   
>   #define WX_MAX_TUNNEL_HDR_LEN	80
> +#define WX_VLAN_MAX_DEPTH	8
>   netdev_features_t wx_features_check(struct sk_buff *skb,
>   				    struct net_device *netdev,
>   				    netdev_features_t features)
>   {
>   	struct wx *wx = netdev_priv(netdev);
> +	u16 parse_depth = WX_VLAN_MAX_DEPTH;
> +	__be16 type = skb->protocol;
> +	u16 vlan_depth = ETH_HLEN;
> +	u32 vlan_num = 0;
>   
> +	if (!skb_vlan_tag_present(skb))

this if jumping over the loop with essentially the same condition
does not help much, I would just remove

> +		goto tunnel_check;
> +
> +	vlan_num++;
> +	while (eth_type_vlan(type) && --parse_depth) {
> +		struct vlan_hdr vhdr, *vh;
> +
> +		vh = skb_header_pointer(skb, vlan_depth, sizeof(vhdr), &vhdr);
> +		if (unlikely(!vh))
> +			break;
> +
> +		type = vh->h_vlan_encapsulated_proto;
> +		vlan_depth += VLAN_HLEN;
> +		vlan_num++;

parse depth of 8 does not make sense if you are detecting
"are the three first protocols a VLAN"

> +	}
> +
> +	if (vlan_num > 2)
> +		features &= ~(NETIF_F_HW_VLAN_CTAG_TX |
> +			      NETIF_F_HW_VLAN_STAG_TX);

you could move this if condition inside a loop with an added "break"

> +tunnel_check:
>   	if (!skb->encapsulation)
>   		return features;
>   


      reply	other threads:[~2026-07-10  9:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10  7:18 [PATCH net-next] net: libwx: disable TX VLAN offload for packets with >2 VLAN tags Jiawen Wu
2026-07-10  9:49 ` Przemek Kitszel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f0be57b5-8574-4107-bb31-e1658b73267f@intel.com \
    --to=przemyslaw.kitszel@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=duanqiangwen@net-swift.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=jiawenwu@trustnetic.com \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=mengyuanlou@net-swift.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox