Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3038718pxb; Mon, 18 Oct 2021 07:06:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybyXXFOArSdNPGaTSYhTz+ypfIoDmsiTneHItLd4qCkDRTy4+dUk/Mm9zI5BbHkM0pLJcO X-Received: by 2002:a17:902:b410:b0:13f:afe4:bf17 with SMTP id x16-20020a170902b41000b0013fafe4bf17mr10255902plr.24.1634565967735; Mon, 18 Oct 2021 07:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634565967; cv=none; d=google.com; s=arc-20160816; b=EFaNXJPW/4KrTBV9ywQ0BPBHaRHDYQZ1hqlNZZ9rWDs8FKPmB3X0c+QNa5dTYvaTg2 JsYBqv5LoHgTPOFqQ9bbglDS5adWkJK10evic0vlHPgLiEeUba9hQ3GOw68H4zuLdpow SUhG/neRKBP2VzZ+CIy2yBDpb6qV2IMVzdGjBhS+raVbtziNGWMz9VaCk0D6GoAa2po/ WuCHP35GblWmsdtafu3l1n//zExY+44FKZx1JzrG+xys5haxC56LMzhB8DA2TAfYGEEa cX4y+0x0dFNHn9XReKCE8j4fzEndOQrt7F96kbubF4MAWoZ7vyLGtO3xNPaUodeySa01 M3qg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OzjC6X3pjyxunQVSM7g0Ux67d1BJQm7tTQVFhexoEh4=; b=JrPaycBGZXcz5IOEUbgZA11RRis9DASjASwxqyR0wS3JCJerKfu53nZ6ytAMf5RrJR iqUqj7lriQvZqK2/uEtrQdTeSsF+9pZ/96gaZZitjcwmpRS+vGx51QrcUxxje4OylWjb dg+8shIaTkRXkqH2FFEDSu3dL4lMcVoOH89IKmCOOWlhcP+zaUC4bzfPQ5NyKbTqsmZ9 Xx9Hljjw1KHVnIpj4GYOVu/IRBP1Y45gMlB35oXRb5GTQ3YWKE0+s8xNCsDrp10xRN0s Xxumw6XfHAwp6FE1ADQ1Wsg7jNkMQrkYOjDGb3GC2sdTd3LiqGp7vdxvR9YAL7jMKKwU xDsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JZV2Zosc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t70si10225123pgd.496.2021.10.18.07.05.54; Mon, 18 Oct 2021 07:06:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JZV2Zosc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234490AbhJROGI (ORCPT + 99 others); Mon, 18 Oct 2021 10:06:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:38968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234773AbhJROCy (ORCPT ); Mon, 18 Oct 2021 10:02:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 420B361A57; Mon, 18 Oct 2021 13:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564597; bh=zvjs20sOg4WIawD97wRDFk2JlaVcAWA3whOAUNX5+0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JZV2ZosctdurZsFuiNL265gcgjLOvnP9uRL1HveSHIYGZQeai2KgyMZy4shmt4Qwi 8XorYzr8b33ORqy59+s5qSaKoPJ0PNg1Xyq1r6E3Xowsq6Jaisdbn9yygl1kM8MfmF Qi53KpDI98OHY7Mx5xxeCPKbD7eyWZRm6k+ciAKE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Florian Fainelli , Jakub Kicinski Subject: [PATCH 5.14 150/151] net: dsa: felix: break at first CPU port during init and teardown Date: Mon, 18 Oct 2021 15:25:29 +0200 Message-Id: <20211018132345.533806301@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean commit 8d5f7954b7c8de54902a8beda141064a7e2e6ee0 upstream. The NXP LS1028A switch has two Ethernet ports towards the CPU, but only one of them is capable of acting as an NPI port at a time (inject and extract packets using DSA tags). However, using the alternative ocelot-8021q tagging protocol, it should be possible to use both CPU ports symmetrically, but for that we need to mark both ports in the device tree as DSA masters. In the process of doing that, it can be seen that traffic to/from the network stack gets broken, and this is because the Felix driver iterates through all DSA CPU ports and configures them as NPI ports. But since there can only be a single NPI port, we effectively end up in a situation where DSA thinks the default CPU port is the first one, but the hardware port configured to be an NPI is the last one. I would like to treat this as a bug, because if the updated device trees are going to start circulating, it would be really good for existing kernels to support them, too. Fixes: adb3dccf090b ("net: dsa: felix: convert to the new .change_tag_protocol DSA API") Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/ocelot/felix.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -271,12 +271,12 @@ static void felix_8021q_cpu_port_deinit( */ static int felix_setup_mmio_filtering(struct felix *felix) { - unsigned long user_ports = 0, cpu_ports = 0; + unsigned long user_ports = dsa_user_ports(felix->ds); struct ocelot_vcap_filter *redirect_rule; struct ocelot_vcap_filter *tagging_rule; struct ocelot *ocelot = &felix->ocelot; struct dsa_switch *ds = felix->ds; - int port, ret; + int cpu = -1, port, ret; tagging_rule = kzalloc(sizeof(struct ocelot_vcap_filter), GFP_KERNEL); if (!tagging_rule) @@ -289,12 +289,15 @@ static int felix_setup_mmio_filtering(st } for (port = 0; port < ocelot->num_phys_ports; port++) { - if (dsa_is_user_port(ds, port)) - user_ports |= BIT(port); - if (dsa_is_cpu_port(ds, port)) - cpu_ports |= BIT(port); + if (dsa_is_cpu_port(ds, port)) { + cpu = port; + break; + } } + if (cpu < 0) + return -EINVAL; + tagging_rule->key_type = OCELOT_VCAP_KEY_ETYPE; *(__be16 *)tagging_rule->key.etype.etype.value = htons(ETH_P_1588); *(__be16 *)tagging_rule->key.etype.etype.mask = htons(0xffff); @@ -330,7 +333,7 @@ static int felix_setup_mmio_filtering(st * the CPU port module */ redirect_rule->action.mask_mode = OCELOT_MASK_MODE_REDIRECT; - redirect_rule->action.port_mask = cpu_ports; + redirect_rule->action.port_mask = BIT(cpu); } else { /* Trap PTP packets only to the CPU port module (which is * redirected to the NPI port) @@ -1241,6 +1244,7 @@ static int felix_setup(struct dsa_switch * there's no real point in checking for errors. */ felix_set_tag_protocol(ds, port, felix->tag_proto); + break; } ds->mtu_enforcement_ingress = true; @@ -1277,6 +1281,7 @@ static void felix_teardown(struct dsa_sw continue; felix_del_tag_protocol(ds, port, felix->tag_proto); + break; } ocelot_devlink_sb_unregister(ocelot);