From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A57DC27C6E for ; Fri, 14 Jun 2024 10:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SgrqTw+/It1adEehXLmXgK1moXKsGq11xoueSFrMzIE=; b=mzJMWWgJHF/yA7+IAkdgY37JQG pVuKoU+RiuhBLvDj/vy/H5ZRDQWjj/pCv6jNPTv9DX6L4yV6OHK2Fc+gR5WVowcdYu9aBIWLERy+5 EFHNyG2hPcZlBiebvm2kZ8s0wGtFPWiKUNLTQE6zLjX+Jmpw+6L0oyABZ9NpoKhP6enh4y2BTnrvG Gv3fC89Vlj+WCyr77eZkHeEvUjWhUVvOSGv4WxUH+c1AVSyjh3fsNIauKysmpO4I1ICluZrAYly3Z Dn50QI+3WGW57RecJkeZsW1zJDrkKgNpuv3ip4LJeMWvhpWobSMrG11JTAeWNU7aSz6siQNmDRcPM LZgtHqUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sI4Op-00000002UnD-14Pn; Fri, 14 Jun 2024 10:43:15 +0000 Received: from out-184.mta0.migadu.com ([91.218.175.184]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sI4Om-00000002UmW-0WYx for linux-arm-kernel@lists.infradead.org; Fri, 14 Jun 2024 10:43:14 +0000 X-Envelope-To: 0x1207@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1718361788; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SgrqTw+/It1adEehXLmXgK1moXKsGq11xoueSFrMzIE=; b=rHe5tIyFpYY8WnnvPWz/uRNkvY1NX0ZvYBVNgMPpFZoqBS5Er8gvmcjyMkxpNGymbke3VK rrSwU18WcSDFZhwwFjaNC1iU8syEFiPYTXUIA8KVMF6O3Zz8/R6xbj2f3LDVicpL2eid9F rBqWnk88DXauX70HneT4jxMDHcG/uF0= X-Envelope-To: linux@armlinux.org.uk X-Envelope-To: davem@davemloft.net X-Envelope-To: alexandre.torgue@foss.st.com X-Envelope-To: joabreu@synopsys.com X-Envelope-To: edumazet@google.com X-Envelope-To: kuba@kernel.org X-Envelope-To: pabeni@redhat.com X-Envelope-To: mcoquelin.stm32@gmail.com X-Envelope-To: jpinto@synopsys.com X-Envelope-To: vinschen@redhat.com X-Envelope-To: netdev@vger.kernel.org X-Envelope-To: linux-stm32@st-md-mailman.stormreply.com X-Envelope-To: linux-arm-kernel@lists.infradead.org X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: xfr@outlook.com X-Envelope-To: rock.xu@nio.com Message-ID: <0474a247-e5f2-4a7f-879b-c764591a5f28@linux.dev> Date: Fri, 14 Jun 2024 11:43:00 +0100 MIME-Version: 1.0 Subject: Re: [PATCH net-next v2] net: stmmac: Enable TSO on VLANs To: Furong Xu <0x1207@gmail.com>, "Russell King (Oracle)" , "David S. Miller" , Alexandre Torgue , Jose Abreu , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Joao Pinto , Corinna Vinschen Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, xfr@outlook.com, rock.xu@nio.com References: <20240614060349.498414-1-0x1207@gmail.com> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Vadim Fedorenko In-Reply-To: <20240614060349.498414-1-0x1207@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240614_034312_582760_77C4BF63 X-CRM114-Status: GOOD ( 17.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 14/06/2024 07:03, Furong Xu wrote: > The TSO engine works well when the frames are not VLAN Tagged. > But it will produce broken segments when frames are VLAN Tagged. > > The first segment is all good, while the second segment to the > last segment are broken, they lack of required VLAN tag. > > An example here: > ======== > // 1st segment of a VLAN Tagged TSO frame, nothing wrong. > MacSrc > MacDst, ethertype 802.1Q (0x8100), length 1518: vlan 100, p 1, ethertype IPv4 (0x0800), HostA:42643 > HostB:5201: Flags [.], seq 1:1449 > > // 2nd to last segments of a VLAN Tagged TSO frame, VLAN tag is missing. > MacSrc > MacDst, ethertype IPv4 (0x0800), length 1514: HostA:42643 > HostB:5201: Flags [.], seq 1449:2897 > MacSrc > MacDst, ethertype IPv4 (0x0800), length 1514: HostA:42643 > HostB:5201: Flags [.], seq 2897:4345 > MacSrc > MacDst, ethertype IPv4 (0x0800), length 1514: HostA:42643 > HostB:5201: Flags [.], seq 4345:5793 > MacSrc > MacDst, ethertype IPv4 (0x0800), length 1514: HostA:42643 > HostB:5201: Flags [P.], seq 5793:7241 > > // normal VLAN Tagged non-TSO frame, nothing wrong. > MacSrc > MacDst, ethertype 802.1Q (0x8100), length 1022: vlan 100, p 1, ethertype IPv4 (0x0800), HostA:42643 > HostB:5201: Flags [P.], seq 7241:8193 > MacSrc > MacDst, ethertype 802.1Q (0x8100), length 70: vlan 100, p 1, ethertype IPv4 (0x0800), HostA:42643 > HostB:5201: Flags [F.], seq 8193 > ======== > > When transmitting VLAN Tagged TSO frames, never insert VLAN tag by HW, > always insert VLAN tag to SKB payload, then TSO works well on VLANs for > all MAC cores. > > Tested on DWMAC CORE 5.10a, DWMAC CORE 5.20a and DWXGMAC CORE 3.20a > > Signed-off-by: Furong Xu <0x1207@gmail.com> > --- > Changes in v2: > - Use __vlan_hwaccel_push_inside() to insert vlan tag to the payload. > --- > .../net/ethernet/stmicro/stmmac/stmmac_main.c | 27 ++++++++++--------- > 1 file changed, 14 insertions(+), 13 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index bbedf2a8c60f..e8cbfada63ca 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -4233,18 +4233,27 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) > { > struct dma_desc *desc, *first, *mss_desc = NULL; > struct stmmac_priv *priv = netdev_priv(dev); > - int nfrags = skb_shinfo(skb)->nr_frags; > - u32 queue = skb_get_queue_mapping(skb); > unsigned int first_entry, tx_packets; > struct stmmac_txq_stats *txq_stats; > - int tmp_pay_len = 0, first_tx; > + int tmp_pay_len = 0, first_tx, nfrags; > struct stmmac_tx_queue *tx_q; > - bool has_vlan, set_ic; > + bool set_ic; > u8 proto_hdr_len, hdr; > - u32 pay_len, mss; > + u32 pay_len, mss, queue; > dma_addr_t des; > int i; > As there will be another iteration, could you please re-arrange variables to keep reverse x-mas tree order?