Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4062444rwb; Sun, 9 Oct 2022 17:06:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Q7IC5gekL1jRiITLaLzTAu64yzRhGxb28XfEecMV9GsF4rRSPAVkBd8hcLK9CwQsQfH0P X-Received: by 2002:a05:6a00:3493:b0:562:f7c0:cbd9 with SMTP id cp19-20020a056a00349300b00562f7c0cbd9mr9213858pfb.4.1665360371458; Sun, 09 Oct 2022 17:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665360371; cv=none; d=google.com; s=arc-20160816; b=Jlbmt/b7fxmdAUMMgxaM1eeoBoBNsZv99nq7I272K6Ek7NSzRsLZ7fUv0YSiyXxoVp FdhXSaH1IKucmQusIm+1gaQ9rW4HWH87PmY4m3dq3ZWVJigGe09EC3TSDGjZvBL57Adw vuKUAsyqgDaYgF/L/hG2vNnWGn0ZnX4+lBEWApGNjMHPHyYu8SnD0YGhB36p0XZaIkny 0lek0OiV3529lx6rJf1p/7w8du0/4BWKpyNN2AO8oHZJGsQXOGyme0GQkXLbLrOty75H jM8v6JVnCOw3vQRX0CAdCPx98hRsjAjYhN2t2iGxZ7JNu2tkpbDui2GiziLrEQyZUqYF EtFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CQG9luvitAemYuW/ObzbCok0S4agIUB5z/CmIZ7FlxM=; b=CgDqbHow6yUjETGavMsfZ5kdlq2Im6ldaBUviHuBdZEjYJxCIWaDvoFXcMG/ODUdlN KTQw18WDv+4TMk5/tRGoNybf5NE3YP3+qmCFkj95gycLy9PQ9RWf2aITlgfY3RB0YX/l 9HNVp0oQ/iBtV9reNWoIFZUJvwGP45JDgHia1EFY+MwpemQgIddjmWFmDhHu9l6Ur3MJ 4ue8KwjKdozvxBZ+dWTWWnHxOjGQgWIj1+FydCnQCMe5uypZNard4lBhkC6J6vQN7kdH tC9bIcaOLpc4nzwViuiz1aZaiU2wQ3Vo+u9HYuC251vLCwzSv9mA6hE6ICA5i5eOoM8U lDTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JC9haYZE; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pf16-20020a17090b1d9000b0020d4590814esi1524966pjb.87.2022.10.09.17.06.00; Sun, 09 Oct 2022 17:06:11 -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=@kernel.org header.s=k20201202 header.b=JC9haYZE; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231966AbiJIW0Z (ORCPT + 99 others); Sun, 9 Oct 2022 18:26:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231495AbiJIWYA (ORCPT ); Sun, 9 Oct 2022 18:24:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE3C53C8F3; Sun, 9 Oct 2022 15:18:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 97FF4B80DF6; Sun, 9 Oct 2022 22:15:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16ED1C43470; Sun, 9 Oct 2022 22:15:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665353745; bh=sOJf2HMfcZ1hjIAO+qoNr5T6ovrDWP07KCEdymXI3QQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JC9haYZEUk1xW5ACEVnafhbR71Uc03iZtGuVGBg+oyX4YDt1DGa0te5jh9LGUTYEB r+Cy44CgmCXAYoeUurGjDKii6IAiAZsuj2/Z3dLibC+ugk1p7IKqhw2V5gFI/HwqeM cl/CcavewRS4oQqH3YVlAxuNuucsg7MTusruQccq7yCg7+VPsbRyFW2EmaK632234x 5lt893BE7XrwGYR5CTtO3cQe/Xi8ZwYgLCdZkLHYtyjq87rYRyE/YNZIstJdAj4HZJ s5i7gtw5DoAjvGgAilmE5ZpEYr0BQcSQmvv03dea+AorCV7TTT1DDA0zM7nyIrabGF uTVDQCHeG2/5Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vladimir Oltean , Paolo Abeni , Sasha Levin , claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.19 11/73] net: mscc: ocelot: adjust forwarding domain for CPU ports in a LAG Date: Sun, 9 Oct 2022 18:13:49 -0400 Message-Id: <20221009221453.1216158-11-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009221453.1216158-1-sashal@kernel.org> References: <20221009221453.1216158-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 From: Vladimir Oltean [ Upstream commit 291ac1517af58670740528466ccebe3caefb9093 ] Currently when we have 2 CPU ports configured for DSA tag_8021q mode and we put them in a LAG, a PGID dump looks like this: PGID_SRC[0] = ports 4, PGID_SRC[1] = ports 4, PGID_SRC[2] = ports 4, PGID_SRC[3] = ports 4, PGID_SRC[4] = ports 0, 1, 2, 3, 4, 5, PGID_SRC[5] = no ports (ports 0-3 are user ports, ports 4 and 5 are CPU ports) There are 2 problems with the configuration above: - user ports should enable forwarding towards both CPU ports, not just 4, and the aggregation PGIDs should prune one CPU port or the other from the destination port mask, based on a hash computed from packet headers. - CPU ports should not be allowed to forward towards themselves and also not towards other ports in the same LAG as themselves The first problem requires fixing up the PGID_SRC of user ports, when ocelot_port_assigned_dsa_8021q_cpu_mask() is called. We need to say that when a user port is assigned to a tag_8021q CPU port and that port is in a LAG, it should forward towards all ports in that LAG. The second problem requires fixing up the PGID_SRC of port 4, to remove ports 4 and 5 (in a LAG) from the allowed destinations. After this change, the PGID source masks look as follows: PGID_SRC[0] = ports 4, 5, PGID_SRC[1] = ports 4, 5, PGID_SRC[2] = ports 4, 5, PGID_SRC[3] = ports 4, 5, PGID_SRC[4] = ports 0, 1, 2, 3, PGID_SRC[5] = no ports Note that PGID_SRC[5] still looks weird (it should say "0, 1, 2, 3" just like PGID_SRC[4] does), but I've tested forwarding through this CPU port and it doesn't seem like anything is affected (it appears that PGID_SRC[4] is being looked up on forwarding from the CPU, since both ports 4 and 5 have logical port ID 4). The reason why it looks weird is because we've never called ocelot_port_assign_dsa_8021q_cpu() for any user port towards port 5 (all user ports are assigned to port 4 which is in a LAG with 5). Since things aren't broken, I'm willing to leave it like that for now and just document the oddity. Signed-off-by: Vladimir Oltean Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- drivers/net/ethernet/mscc/ocelot.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 68991b021c56..f6ec299a2b5a 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -2065,6 +2065,16 @@ static int ocelot_bond_get_id(struct ocelot *ocelot, struct net_device *bond) return __ffs(bond_mask); } +/* Returns the mask of user ports assigned to this DSA tag_8021q CPU port. + * Note that when CPU ports are in a LAG, the user ports are assigned to the + * 'primary' CPU port, the one whose physical port number gives the logical + * port number of the LAG. + * + * We leave PGID_SRC poorly configured for the 'secondary' CPU port in the LAG + * (to which no user port is assigned), but it appears that forwarding from + * this secondary CPU port looks at the PGID_SRC associated with the logical + * port ID that it's assigned to, which *is* configured properly. + */ static u32 ocelot_dsa_8021q_cpu_assigned_ports(struct ocelot *ocelot, struct ocelot_port *cpu) { @@ -2081,9 +2091,15 @@ static u32 ocelot_dsa_8021q_cpu_assigned_ports(struct ocelot *ocelot, mask |= BIT(port); } + if (cpu->bond) + mask &= ~ocelot_get_bond_mask(ocelot, cpu->bond); + return mask; } +/* Returns the DSA tag_8021q CPU port that the given port is assigned to, + * or the bit mask of CPU ports if said CPU port is in a LAG. + */ u32 ocelot_port_assigned_dsa_8021q_cpu_mask(struct ocelot *ocelot, int port) { struct ocelot_port *ocelot_port = ocelot->ports[port]; @@ -2092,6 +2108,9 @@ u32 ocelot_port_assigned_dsa_8021q_cpu_mask(struct ocelot *ocelot, int port) if (!cpu_port) return 0; + if (cpu_port->bond) + return ocelot_get_bond_mask(ocelot, cpu_port->bond); + return BIT(cpu_port->index); } EXPORT_SYMBOL_GPL(ocelot_port_assigned_dsa_8021q_cpu_mask); -- 2.35.1