Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1800861rwd; Tue, 13 Jun 2023 14:34:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4av3yODLXMYGzEowq5twYNlmoIhWzM7RRDX+/Kf4b49Kkl9pHcwiNN8galaCa7zAiAMKuC X-Received: by 2002:a17:907:3f10:b0:982:3801:e998 with SMTP id hq16-20020a1709073f1000b009823801e998mr4810417ejc.53.1686692096964; Tue, 13 Jun 2023 14:34:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686692096; cv=none; d=google.com; s=arc-20160816; b=vYxlpmecPqtoprZBw58MbJZ4v6iUKRW5ZYcFDIHcp3GDKZIPfvuz/xA3OAygb5tbCA rAngrdHrI/DIhjN2Y6sgmaUUDO/on7/06CPSc8JBEMXZGb3nfnCot9rWvMjApyJhGQbn 89vJaPTW/UWDWnh06YVShuF+StDCZ4rwrf8jeXBb+TATkUxeyV9/YjZV6m7Vd1qx3d/a 5YfVZSxO33I7MLU4t2FR9f/evVyWn2xCB6g1kVsppK2JoR9NUL28kcjq/5FSpGhk4Qvt EORJ189TCKpahOwO7kqWZ86QUaC/6/Sl4LHDYV6HpOzyjta7iooYx+Vw/JEqVlpYfJkt NCUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fSNOwltAQrxAVV68XPYGPjq5L/bIYHyNYEji3sovMB8=; b=XgO4rx7CxUH//4n69hIavYlHMDkHkM0tSxO14jj+ngOXbDCEb/rTbMc8aOgU74AFPW gN1nbzJWFeuqkIsj4/+JY2LLh0K23pYhFLCz9Mg4Dc+YYDKctR63I9Wg1c0whJGiu/3V Z2RpUqYGX6dMaTE/xjH7UgtTTOwcOnCAJJtG4PiqK0SuWDdvLnrHuMtJAl9nS5VqRLv0 NlMRC3sl/QIDlr2nJT1X02Vpyrm6vGJ+KYwZM2lbyUyMCIVWKzfWPYppMdTyHznq/d4X ap34WKvEwYQ/dLIysZizMsM2Dbh18X0bwChVYvymjDERwANpoowdP35KuzHqVUtYpde+ yagA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Ls9NCRli; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a22-20020aa7d916000000b005149135a97csi8229088edr.272.2023.06.13.14.34.32; Tue, 13 Jun 2023 14:34:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Ls9NCRli; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233095AbjFMUrD (ORCPT + 99 others); Tue, 13 Jun 2023 16:47:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231363AbjFMUrC (ORCPT ); Tue, 13 Jun 2023 16:47:02 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E968810E6; Tue, 13 Jun 2023 13:47:00 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-5187ae34127so998816a12.2; Tue, 13 Jun 2023 13:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686689219; x=1689281219; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=fSNOwltAQrxAVV68XPYGPjq5L/bIYHyNYEji3sovMB8=; b=Ls9NCRlivmPC49auVyJHDRF+h04dMXwMGmh110SKXer2GYxSqLJ9P1EGp0FjvkdV5Y ZT59hga7BfF3nhKADgA++VIjISbHOXjbarrE22ZfAE111jgQ3jK7jtShuQEjePBTdLis yciak/fmFmqGLf0kPVtaE83SgyEUNf4EYJ8t+BcD70N9SeDplDhhnv21ndbgohUjIo3Q qoIFrDRIjD3zlcF+yzNquVLT03HQips/sNO/bgOKLbcYVEkAQUc21wT7i4P3CHKfFH3E JBqhJVUG2DsUf/DTTO0WW993S6gOxx5pmwiBMHSV5JbAOZ/Gt2Ydgt6O9rNJJ0aBuvZC X8tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686689219; x=1689281219; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fSNOwltAQrxAVV68XPYGPjq5L/bIYHyNYEji3sovMB8=; b=MffYQCu4czD09SAUosdYpiNxpsxYXR3J+9M9YE6C1B+ksGn5tQMyzruG1aML0Zzc/j 4hdEEl4KNXHfASprcRdrLE8I4CQ+bLsQvp87NHBzIaIrVEnY8FCmuG3dumGw1WuW4NMt hUKgXpjT1OuUiWNi7S3GfaoED3pwtTHvZIRKmGqKRXX8GEQcSJNPNeTJGxP3rvu2TAKm qfJaksbdK0NnAsuwdmvsLdVzmemsnh4YGZJUJP2CWoFbE7O5h3ivrT9FUFp0Sz466oGg iCZNYufsgegeT+EIcG9M+ukxpjLFfKdk8ClX+0nhg0JYQXLGwK+jLoeCjCv/yfMh5dqB JHww== X-Gm-Message-State: AC+VfDxdrQxW9NsNUrc2+cR9g++J54Epp/yzfBjqvGnBbiAaCYIqrG0D KyOIlAeXNW3L2/dphYRF6f4= X-Received: by 2002:a05:6402:2055:b0:514:9df0:e3f3 with SMTP id bc21-20020a056402205500b005149df0e3f3mr9203260edb.0.1686689219118; Tue, 13 Jun 2023 13:46:59 -0700 (PDT) Received: from skbuf ([188.27.184.189]) by smtp.gmail.com with ESMTPSA id b14-20020aa7c6ce000000b00506987c5c71sm6802283eds.70.2023.06.13.13.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 13:46:58 -0700 (PDT) Date: Tue, 13 Jun 2023 23:46:55 +0300 From: Vladimir Oltean To: "Russell King (Oracle)" Cc: =?utf-8?B?QXLEsW7DpyDDnE5BTA==?= , Daniel Golle , Landen Chao , DENG Qingfang , Sean Wang , Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Frank Wunderlich , Bartel Eerdekens , mithat.guner@xeront.com, erkin.bozoglu@xeront.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH net v2 2/7] net: dsa: mt7530: fix trapping frames with multiple CPU ports on MT7530 Message-ID: <20230613204655.7dk5f5pbcyrquva5@skbuf> References: <20230611081547.26747-1-arinc.unal@arinc9.com> <20230611081547.26747-2-arinc.unal@arinc9.com> <20230613150815.67uoz3cvvwgmhdp2@skbuf> <20230613171858.ybhtlwxqwp7gyrfs@skbuf> <20230613172402.grdpgago6in4jogq@skbuf> <20230613173908.iuofbuvkanwyr7as@skbuf> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 13, 2023 at 07:29:18PM +0100, Russell King (Oracle) wrote: > Maybe it's just me being dumb, but I keep finding things difficult to > understand, such as the above paragraph. > > It sounds like you're saying that _before_ this patch, port 5 is the > active CPU port, but the CPU_PORT *FIELD* NOT BITS are set such that > port 6 is the active CPU port. Therefore, things are broken, and this > patch fixes it. > > Or are you saying that after this patch is applied, port 5 is the > active CPU port, but the CPU_PORT *FIELD* is set to port 6. If that's > true, then I've no idea what the hell is going on here because it > seems to be senseless. There are 2 distinct patches at play. I'll be showing some tables below. Their legend is that patch (1) affects only the second column and patch (2) affects only the third column. Patch (1): net: dsa: mt7530: fix trapping frames with multiple CPU ports on MT7530 ---------------------------------------------------------------------------------- What you need to know looking at the current code in net-next is that mt753x_cpu_port_enable() always overwrites the CPU_MASK field of MT7530_MFC, because that contains a single port. So when operating on a device tree with multiple CPU ports defined, only the last CPU port will be recorded in that register, and this will affect the destination port for trapped-to-CPU frames. However, DSA, when operating on a DT with multiple CPU ports, makes the dp->cpu_dp pointer of all user ports equal to the first CPU port. That affects which DSA master is automatically brought up when user ports are brought up. Minor issue, TBH, because it is sufficient for the user to manually bring up the DSA master corresponding to the second CPU port, and then trapped frames would be processed just fine. Prior to ~2021/v5.12, that facility wasn't even a thing - the user always had to bring that interface up manually. That means that without patch (1) we have: CPU ports in the Trapping CPU port Default CPU port device tree (MT7530_MFC:CPU_MASK) (all dp->cpu_dp point to it) ------------------------------------------------------------------------- 5 5 5 6 6 6 5 and 6 6 5 The semi-problem is that the DSA master of the trapping port (6) is not automatically brought up by the dsa_slave_open() logic, because no slave has port 6 (the trapping port) as a master. All that this patch is doing is that it moves around the trapping CPU port towards one of the DSA masters that is up, so that the user doesn't really need to care. The table becomes: CPU ports in the Trapping CPU port Default CPU port device tree (MT7530_MFC:CPU_MASK) (all dp->cpu_dp point to it) -------------------------------------------------------------------------- 5 5 5 6 6 6 5 and 6 5 5 Patch (2) net: dsa: introduce preferred_default_local_cpu_port and use on MT7530 -------------------------------------------------------------------------------- This patch influences the choice that DSA makes when it comes to the dp->cpu_dp assignments of user ports, when fed a device tree with multiple CPU ports. The preference of the mt7530 driver is: if port 6 is defined in the DT as a CPU port, choose that. Otherwise don't care (which implicitly means: let DSA pick the first CPU port that is defined there, be it 5 or 6). The effect of this patch taken in isolation is (showing only "after", because "before" is the same as the "before" of patch 1): CPU ports in the Trapping CPU port Default CPU port device tree (MT7530_MFC:CPU_MASK) (all dp->cpu_dp point to it) ------------------------------------------------------------------------- 5 5 5 6 6 6 5 and 6 6 6 As you can see, patch (2) resolves the same semi-problem even in isolation because it makes the trapping port coincide with the default CPU port in a different way. > > I think at this point I just give up trying to understand what the > hell these patches are trying to do - in my opinion, the commit > messages are worded attrociously and incomprehensively. +1, could have been better..