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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 288ECC636D6 for ; Tue, 7 Feb 2023 10:57:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231843AbjBGK5N (ORCPT ); Tue, 7 Feb 2023 05:57:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231792AbjBGK5J (ORCPT ); Tue, 7 Feb 2023 05:57:09 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB5BC39CCD for ; Tue, 7 Feb 2023 02:56:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675767382; 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=utLBczvzekSz+cWIa2fZgxlACvw9W5bN6q2slvl+YPI=; b=UCT/BJaxs27NZ7p5rreCdopTQJPhxKxcWljt+EzTdMYhCtCLbAaDAmhHL23zkUyrooC5nh FKuWPCYB5bl59p54V6uAluC0Zrya/Y+z+W4Aos+vMi0YV8HkhSZ28PH0JZuJ4Q1cmR4bI5 JXfTvddeJSdahccER3JJLXXkJokzAnk= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-672-vQXgwyeuNieDfstWqR2I8g-1; Tue, 07 Feb 2023 05:56:20 -0500 X-MC-Unique: vQXgwyeuNieDfstWqR2I8g-1 Received: by mail-qv1-f70.google.com with SMTP id dy3-20020ad44e83000000b0056bf716c68bso2844422qvb.10 for ; Tue, 07 Feb 2023 02:56:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=utLBczvzekSz+cWIa2fZgxlACvw9W5bN6q2slvl+YPI=; b=z45YOCtCAJ8/k+qS8cd8m1a4zXo6ea8jCRJESAQ1RJaimW6TOhTvdwlTf5PHk5IPTj MdbNtht9wyJi2HEbxAy5WZy0q9quXi+qFHg0fDqeY9KTF6jSx513Hu1YSFL/H6e2LPeE sqBveO1OfARSJgtSkHracKAZI+CAjTpPs7eTRl7O4ad/iZ6G23pl9qHPHoI01DKnQhh5 5gSHuTP4PAq1rYiIxZ5tsg5gkVGKI/bqduizaz+nC8xnQ+iTUrbge+PIImsxR7aogzl7 W2m0kvGpxpCdsJYLr2rtWkgGvoHwwKnxO9hQopTNTTQfp0dbHBad7VQuV0NXocdMnRE4 d/Rg== X-Gm-Message-State: AO0yUKXWNj+rcGgep3dD/um+wX7+EoOEJJ3+TsT4cPoNXIfQn2HrNeBR 0DkKj8+hQ5xP3qPmzsrkvRnC8RK+T19KK9LtiQcO7L3R6e8XB1lpO6sbJ4QM6yzpoxE3DkTjT7w sv6sKKiekxBEWGwIX74LlbSSB X-Received: by 2002:ac8:5709:0:b0:3b8:4951:57bb with SMTP id 9-20020ac85709000000b003b8495157bbmr5547278qtw.5.1675767379822; Tue, 07 Feb 2023 02:56:19 -0800 (PST) X-Google-Smtp-Source: AK7set/zTGzMRBR7nAgHkQ8IpNXUs+WHjz4jc2IOn+RfYLyKZo3Xwo4UgiGqPFMVxiMcEINisz+yfw== X-Received: by 2002:ac8:5709:0:b0:3b8:4951:57bb with SMTP id 9-20020ac85709000000b003b8495157bbmr5547245qtw.5.1675767379532; Tue, 07 Feb 2023 02:56:19 -0800 (PST) Received: from gerbillo.redhat.com (146-241-113-28.dyn.eolo.it. [146.241.113.28]) by smtp.gmail.com with ESMTPSA id s26-20020a05622a1a9a00b003b62e8b77e7sm9218291qtc.68.2023.02.07.02.56.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 02:56:19 -0800 (PST) Message-ID: Subject: Re: [PATCH net] net: dsa: mt7530: don't change PVC_EG_TAG when CPU port becomes VLAN-aware From: Paolo Abeni To: Vladimir Oltean , =?UTF-8?Q?Ar=C4=B1n=C3=A7_=C3=9CNAL?= Cc: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Sean Wang , Landen Chao , DENG Qingfang , Andrew Lunn , Florian Fainelli , Matthias Brugger , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Frank Wunderlich , erkin.bozoglu@xeront.com, richard@routerhints.com Date: Tue, 07 Feb 2023 11:56:13 +0100 In-Reply-To: <20230206174627.mv4ljr4gtkpr7w55@skbuf> References: <20230205140713.1609281-1-vladimir.oltean@nxp.com> <3649b6f9-a028-8eaf-ac89-c4d0fce412da@arinc9.com> <20230205203906.i3jci4pxd6mw74in@skbuf> <20230205235053.g5cttegcdsvh7uk3@skbuf> <116ff532-4ebc-4422-6599-1d5872ff9eb8@arinc9.com> <20230206174627.mv4ljr4gtkpr7w55@skbuf> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 (3.46.3-1.fc37) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Mon, 2023-02-06 at 19:46 +0200, Vladimir Oltean wrote: > On Mon, Feb 06, 2023 at 07:41:06PM +0300, Ar=C4=B1n=C3=A7 =C3=9CNAL wrote= : > > Finally I got time. It's been a seismically active day where I'm from. >=20 > My deepest condolences to those who experienced tragedies after today's > earthquakes. A lot of people in neighboring countries are horrified > thinking when this will happen to them. Hopefully you aren't living in > Gaziantep or nearby cities. >=20 > > # ping 192.168.2.2 > > PING 192.168.2.2 > > [ 39.508013] mtk_soc_eth 1b100000.ethernet eth1: dsa_switch_rcv: ther= e is no metadata dst attached to skb 0xc2dfecc0 > >=20 > > # ping 192.168.2.2 > > PING 192.168.2.2 > > [ 22.674182] mtk_soc_eth 1b100000.ethernet eth1: mtk_poll_rx: receive= d skb 0xc2d67840 without VLAN/DSA tag present >=20 > Thank you so much for testing. Would you mind cleaning everything up and > testing with this patch instead (formatted on top of net-next)? > Even if you need to adapt to your tree, hopefully you get the idea from > the commit message. >=20 > From 218025fd0c33a06865e4202c5170bfc17e26cc75 Mon Sep 17 00:00:00 2001 > From: Vladimir Oltean > Date: Mon, 6 Feb 2023 19:03:53 +0200 > Subject: [PATCH] net: ethernet: mtk_eth_soc: fix DSA TX tag hwaccel for s= witch > port 0 > MIME-Version: 1.0 > Content-Type: text/plain; charset=3DUTF-8 > Content-Transfer-Encoding: 8bit >=20 > Ar=C4=B1n=C3=A7 reports that on his MT7621AT Unielec U7621-06 board and M= T7623NI > Bananapi BPI-R2, packets received by the CPU over mt7530 switch port 0 > (of which this driver acts as the DSA master) are not processed > correctly by software. More precisely, they arrive without a DSA tag > (in packet or in the hwaccel area - skb_metadata_dst()), so DSA cannot > demux them towards the switch's interface for port 0. Traffic from other > ports receives a skb_metadata_dst() with the correct port and is demuxed > properly. >=20 > Looking at mtk_poll_rx(), it becomes apparent that this driver uses the > skb vlan hwaccel area: >=20 > union { > u32 vlan_all; > struct { > __be16 vlan_proto; > __u16 vlan_tci; > }; > }; >=20 > as a temporary storage for the VLAN hwaccel tag, or the DSA hwaccel tag. > If this is a DSA master it's a DSA hwaccel tag, and finally clears up > the skb VLAN hwaccel header. >=20 > I'm guessing that the problem is the (mis)use of API. > skb_vlan_tag_present() looks like this: >=20 > #define skb_vlan_tag_present(__skb) (!!(__skb)->vlan_all) >=20 > So if both vlan_proto and vlan_tci are zeroes, skb_vlan_tag_present() > returns precisely false. I don't know for sure what is the format of the > DSA hwaccel tag, but I surely know that lowermost 3 bits of vlan_proto > are 0 when receiving from port 0: >=20 > unsigned int port =3D vlan_proto & GENMASK(2, 0); >=20 > If the RX descriptor has no other bits set to non-zero values in > RX_DMA_VTAG, then the call to __vlan_hwaccel_put_tag() will not, in > fact, make the subsequent skb_vlan_tag_present() return true, because > it's implemented like this: >=20 > static inline void __vlan_hwaccel_put_tag(struct sk_buff *skb, > __be16 vlan_proto, u16 vlan_tci) > { > skb->vlan_proto =3D vlan_proto; > skb->vlan_tci =3D vlan_tci; > } >=20 > What we need to do to fix this problem (assuming this is the problem) is > to stop using skb->vlan_all as temporary storage for driver affairs, and > just create some local variables that serve the same purpose, but > hopefully better. Instead of calling skb_vlan_tag_present(), let's look > at a boolean has_hwaccel_tag which we set to true when the RX DMA > descriptors have something. Disambiguate based on netdev_uses_dsa() > whether this is a VLAN or DSA hwaccel tag, and only call > __vlan_hwaccel_put_tag() if we're certain it's a VLAN tag. >=20 > Link: https://lore.kernel.org/netdev/704f3a72-fc9e-714a-db54-272e17612637= @arinc9.com/ > Fixes: 2d7605a72906 ("net: ethernet: mtk_eth_soc: enable hardware DSA unt= agging") > Reported-by: Ar=C4=B1n=C3=A7 =C3=9CNAL > Signed-off-by: Vladimir Oltean Thank you Vladimir for the quick turn-around!=20 For future case, please avoid replying with new patches - tag area included - to existing patch/thread, as it confuses tag propagation, thanks! Paolo