From patchwork Wed Jul 8 20:44:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 235112 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp780429ilg; Wed, 8 Jul 2020 13:45:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1doPBF36uoHVPTIriRrxkoeBAXX/BOQ/4P8caS1U0ff6r3oufRMQIh/4AtZdUzPzQxnY8 X-Received: by 2002:a05:6402:c06:: with SMTP id co6mr69585286edb.142.1594241106756; Wed, 08 Jul 2020 13:45:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594241106; cv=none; d=google.com; s=arc-20160816; b=DNIPFjza+BIOi8oOaRNuXi4psarcl1sJjDjPjNMXfqH7qJRCfHgGSqWaWyyv1I6+k6 D1sV5SBsU7I3xy/D04kiwLVaFugn3f1PI1RC3+K5bZdywtyun3YweyYQ+6UyvUevUctS rM04vEASHvF5QBdiTFYGMf8O3Fy5wen9yYIcdLQPynPDW7UzZK2a6JZGKuPYd5JVElTv +NgNC6dUjm0Tn3E93DjR7AQeoP9AV1+FNk/clcvnMFaTOuAWuNRAZjqqWRj4t3e6qM0z 1fKSpnXp5HwqRzLbYTZfj6eZjRNSEU/gDthJlgitZW/sMA8QNyaCOfDtcobA0PVjjEBX WDyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bxpijXJIOjPIklfG1x2EzSdICT9vwKHmOm2JtWTs0Fw=; b=T24K+JPAArjkp4RoqX+W/RKEa46E1v3YKAcCl9WGB30evFJJmCR38PO93jSvGFwzQj VrqCUpDWgGkYeujSK1L6721v+xzEUxA82vk+/6mkfGVavU1M+eBnE5r9FGDjuhbajf+d oYU5fbJUZsLP0ye6AHMkK7VB8KJoTeq81W/JJK5dPwRYsMgEgPYXXlAfRugcLBxKHW/s VwDpILhk2wvpjAoY1wopMqTjoUmPHUCFP7hPsPir8B/DxzjeoBLd3ie1Bfhc8nvrkQj1 vahpeqpApHJvGiBjjnfUhD6zJjOjJTt3dM/EJXeiG9lwutC3lydCWVhykzJGVQdDRRGE RVZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SxfFGjjW; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p7si601135ejy.206.2020.07.08.13.45.06; Wed, 08 Jul 2020 13:45:06 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=@linaro.org header.s=google header.b=SxfFGjjW; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726213AbgGHUpF (ORCPT + 9 others); Wed, 8 Jul 2020 16:45:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725964AbgGHUpE (ORCPT ); Wed, 8 Jul 2020 16:45:04 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 801A2C061A0B for ; Wed, 8 Jul 2020 13:45:04 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id 9so55741318ljv.5 for ; Wed, 08 Jul 2020 13:45:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bxpijXJIOjPIklfG1x2EzSdICT9vwKHmOm2JtWTs0Fw=; b=SxfFGjjWk5hoNictuMHtMHPdx4driKUAgl2+5nTTA4FOs9zX8W+6rEq+lTwW7CwISh VmQumaukXRYIiWJ8KxHmZ8+Jxi47UGk+ZkM/0xh5joVEVISwOs/esBM8Jx1n8Hgs5Ztt Qyyvk5wNVRhNXmHIy+yY9MNTrsKAOWk98C/3BFSKr+MikvTa46newNAHv8fv9BAwF2bW mIOQVLyx1r25Tvh8i2WbYOwwv1vMP3RrA5UfvmByHl6+bU/Oh3iXo28LRF3gv8ZtRcq9 Pta1FUPzQV3awdvXh4iRVdg7DZUof8DS8Wt/oHgsMsv0DosKjMaWB2WlEDkMn3AisG0s C7DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bxpijXJIOjPIklfG1x2EzSdICT9vwKHmOm2JtWTs0Fw=; b=YNawcw0ip6bhCs4OnPA3FaHKOlrXPlsJD3zYjCMRc87tnPl8CLRPQxlCdSDI03gw1I fKOoRDa/FGmZmkf/ODBzePyjWxbc4yorRedh2y22/AjNt0edEEZkc6Wbm39xlz0ra8dd mOPIpBy8R3CnQA9gSShrHEnwc3xxw/kluS0Hh60OfpNmXMWx1k9M2qNzG/K9DIzt9a+m nwQ0enQMU45YhRDLNPkVtk/xhieRWOKCxLyvWrg1SrlhcImAt5tsabeTRlB9UhZG8ppD Z+UsFjL20dTTGaZaw/iFftUdxFvKnTurZE+l0HkioPJFOBnas8Xj/bAQ76nGmkOMY/fT ze6A== X-Gm-Message-State: AOAM530ZfxSjtATBUpORMFgsRBpuVyNjhQ9s+FMNngmPv9g6482ztcgp iB9hteASRblucqNBssQbxKV+FA== X-Received: by 2002:a2e:9f4d:: with SMTP id v13mr3616814ljk.122.1594241102993; Wed, 08 Jul 2020 13:45:02 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id i10sm206688ljg.80.2020.07.08.13.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 13:45:02 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , netdev@vger.kernel.org, "David S . Miller" Cc: Linus Walleij , DENG Qingfang , Mauri Sandberg Subject: [net-next PATCH 1/3 v1] net: dsa: rtl8366: Fix VLAN semantics Date: Wed, 8 Jul 2020 22:44:54 +0200 Message-Id: <20200708204456.1365855-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200708204456.1365855-1-linus.walleij@linaro.org> References: <20200708204456.1365855-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The RTL8366 would not handle adding new members (ports) to a VLAN: the code assumed that ->port_vlan_add() was only called once for a single port. When intializing the switch with .configure_vlan_while_not_filtering set to true, the function is called numerous times for adding all ports to VLAN1, which was something the code could not handle. Alter rtl8366_set_vlan() to just |= new members and untagged flags to 4k and MC VLAN table entries alike. This makes it possible to just add new ports to a VLAN. Put in some helpful debug code that can be used to find any further bugs here. Cc: DENG Qingfang Cc: Mauri Sandberg Fixes: d8652956cf37 ("net: dsa: realtek-smi: Add Realtek SMI driver") Signed-off-by: Linus Walleij --- drivers/net/dsa/rtl8366.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) -- 2.26.2 Reviewed-by: Florian Fainelli diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 993cf3ac59d9..2997abeecc4a 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -43,18 +43,26 @@ int rtl8366_set_vlan(struct realtek_smi *smi, int vid, u32 member, int ret; int i; + dev_dbg(smi->dev, + "setting VLAN%d 4k members: 0x%02x, untagged: 0x%02x\n", + vid, member, untag); + /* Update the 4K table */ ret = smi->ops->get_vlan_4k(smi, vid, &vlan4k); if (ret) return ret; - vlan4k.member = member; - vlan4k.untag = untag; + vlan4k.member |= member; + vlan4k.untag |= untag; vlan4k.fid = fid; ret = smi->ops->set_vlan_4k(smi, &vlan4k); if (ret) return ret; + dev_dbg(smi->dev, + "resulting VLAN%d 4k members: 0x%02x, untagged: 0x%02x\n", + vid, vlan4k.member, vlan4k.untag); + /* Try to find an existing MC entry for this VID */ for (i = 0; i < smi->num_vlan_mc; i++) { struct rtl8366_vlan_mc vlanmc; @@ -65,11 +73,16 @@ int rtl8366_set_vlan(struct realtek_smi *smi, int vid, u32 member, if (vid == vlanmc.vid) { /* update the MC entry */ - vlanmc.member = member; - vlanmc.untag = untag; + vlanmc.member |= member; + vlanmc.untag |= untag; vlanmc.fid = fid; ret = smi->ops->set_vlan_mc(smi, i, &vlanmc); + + dev_dbg(smi->dev, + "resulting VLAN%d MC members: 0x%02x, untagged: 0x%02x\n", + vid, vlanmc.member, vlanmc.untag); + break; } } From patchwork Wed Jul 8 20:44:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 235113 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp780459ilg; Wed, 8 Jul 2020 13:45:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNhaps3aiZhCRQ6mizLaDf9qY53Es/3a8btHgkHp7gSqmwgz2k+h65LL+8bvE+YgNoMhTC X-Received: by 2002:a50:e791:: with SMTP id b17mr72453789edn.366.1594241109436; Wed, 08 Jul 2020 13:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594241109; cv=none; d=google.com; s=arc-20160816; b=MrrCnxsrmwHMzJ0EdMtKtF2r6/+kKEjrYxRCUkAlfJe3JPVDXrRVNbokYrwUpdLqyM sy1kkLHFFv/BWZMH5nBFbwTZ4TqFq6/uC+2P5tmmPUxFP0zulO5MSXuFjJqD5bnyvMzi jIg8hbEKclkQmoTkPBZDt6vigNEtHt5lNVYm0cNI5/gwUQoyH9iWg9g8Tv/OakshGNdp xdQqtJhVxbncp5W9m9eCEByBAGfrZ0AJkXiFLRcYa9DTYlnBr1DuJu+N1N5DCiErUMyA 6PZcI+AhDeRzdZn65oY48aGI6UvRoERy4Ucvpwhl6nGbazk6dk6GB6NWdbk5jxeBX9Do tnfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ojDpkbjQrjWztNHKGgvu+G2UteIlDr/ArJVF6vvQsJk=; b=ATzJA2MxM3UbbQ6RjKD6mNjw5mRCbuyZ6WZvZyvYX0sqKpDLUltxr2t2kugyfKpwXR bZxrM0aMXqptYYxROrnJ3ixpAO8mdhjABsA75b4oMXgS5r+5VIY+/bM6mz9ZTVglyDGu +9ltKPEmgx/JVNLWKBxrlzEzN4AdmYAyTkk1I7bLrt4ZiPkFh5L0ImRuJUabvhhThLIV /yKsmj6CGRs47JclfGWkOBSei36QaTFg5710rFlXyGnMaGhuKJdIG1WbN+jxDnZbYLuo zRXJScTDXA+4FEA8DtfsPjyQmnbYpgbUOK9rk/ffJFF+X7x0/U0c/sDH9n53bXC/GTUf 6ohw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=El4Q5n+p; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p7si601135ejy.206.2020.07.08.13.45.09; Wed, 08 Jul 2020 13:45:09 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=@linaro.org header.s=google header.b=El4Q5n+p; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726245AbgGHUpI (ORCPT + 9 others); Wed, 8 Jul 2020 16:45:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725964AbgGHUpG (ORCPT ); Wed, 8 Jul 2020 16:45:06 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CA5FC061A0B for ; Wed, 8 Jul 2020 13:45:06 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id b25so52202121ljp.6 for ; Wed, 08 Jul 2020 13:45:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ojDpkbjQrjWztNHKGgvu+G2UteIlDr/ArJVF6vvQsJk=; b=El4Q5n+po7v0ra5+zSmgGUc6EHuDg+Ju2ewgZ0RTrQKT/Vwb39HLsrY//bLDXcZYHP uQTVfGct6ZaZAEaPquElqwqB+x+1/JYgCNyvdnSpHRZzgizmYxCqukaHCosmohZse92I rbw/NgIYocxT6paA47n16nGUMni8aNpmaj75x9NvrKIPewJOqdgYW/Fz6KjRpqLYT76g Ih+4hPPuGCYdgtTN+0EgEqL44E1fh+ApIBzg1miBlgf1bQh/plJg7cIHjws7FTXL3Fr9 PLgYgE9gMUjgNspmHR5qwGBAN2Z15+3eUqcHjTFQs0/dwCiEvGygnZBdT+6LYuxgvGi2 WmyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ojDpkbjQrjWztNHKGgvu+G2UteIlDr/ArJVF6vvQsJk=; b=hpR13NOc7mO1mdaRwXPXgGqLEUWWeA8AIO2/96pb/fA84TSBSnIuFxYi4x7YyyABJh 23sw4b4/IwfaM5YjiMMuPSpcyQTBonbMxiO6QWYOb/p2/URsUHsj7ONlJ8GuKGP1LCtp noJXFkKXP1bKrXqhtUetOJi6hDqXLUZOEJJQ7I24wPH5MC3hDTfE0fApisE1yMfKymBi cpOSPzX18pkGSNrCXtNqaB7+9/9CTdEr82QwtkWkLCw6Q+Q/+OxwKAYcxViSdvKEauZx u8rhqgWfdMv7zkDLKVJuE3SzEowHSBQaZFeya5hceK6BuJSgP+6EznvXfvQkM3/Bvtyw QMhQ== X-Gm-Message-State: AOAM533Mj3TCk4XEf4RhFciygup0h5u4eeCmTCbxVZQ8b5mWLv0ECuqx lfHy6S12L/zzn4O5e16b+bjS5A== X-Received: by 2002:a2e:870b:: with SMTP id m11mr21650732lji.269.1594241104928; Wed, 08 Jul 2020 13:45:04 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id i10sm206688ljg.80.2020.07.08.13.45.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 13:45:04 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , netdev@vger.kernel.org, "David S . Miller" Cc: Linus Walleij , DENG Qingfang , Mauri Sandberg Subject: [net-next PATCH 2/3 v1] net: dsa: rtl8366: Fix VLAN set-up Date: Wed, 8 Jul 2020 22:44:55 +0200 Message-Id: <20200708204456.1365855-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200708204456.1365855-1-linus.walleij@linaro.org> References: <20200708204456.1365855-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Alter the rtl8366_vlan_add() to call rtl8366_set_vlan() inside the loop that goes over all VIDs since we now properly support calling that function more than once. Augment the loop to postincrement as this is more intuitive. The loop moved past the last VID but called rtl8366_set_vlan() with the port number instead of the VID, assuming a 1-to-1 correspondence between ports and VIDs. This was also a bug. Cc: DENG Qingfang Cc: Mauri Sandberg Fixes: d8652956cf37 ("net: dsa: realtek-smi: Add Realtek SMI driver") Signed-off-by: Linus Walleij --- drivers/net/dsa/rtl8366.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.26.2 Reviewed-by: Florian Fainelli diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 2997abeecc4a..8f40fbf70a82 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -397,7 +397,7 @@ void rtl8366_vlan_add(struct dsa_switch *ds, int port, if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) dev_err(smi->dev, "port is DSA or CPU port\n"); - for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { + for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { int pvid_val = 0; dev_info(smi->dev, "add VLAN %04x\n", vid); @@ -420,13 +420,13 @@ void rtl8366_vlan_add(struct dsa_switch *ds, int port, if (ret < 0) return; } - } - ret = rtl8366_set_vlan(smi, port, member, untag, 0); - if (ret) - dev_err(smi->dev, - "failed to set up VLAN %04x", - vid); + ret = rtl8366_set_vlan(smi, vid, member, untag, 0); + if (ret) + dev_err(smi->dev, + "failed to set up VLAN %04x", + vid); + } } EXPORT_SYMBOL_GPL(rtl8366_vlan_add); From patchwork Wed Jul 8 20:44:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 235114 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp780475ilg; Wed, 8 Jul 2020 13:45:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0bPCiCh45GjE9cFgC6vpM/SiRt3NYO5/azgm2nEDEAyY2jmEcAgBNV+uI0bgRPTSJDKr3 X-Received: by 2002:a05:6402:1c96:: with SMTP id cy22mr67318496edb.79.1594241111588; Wed, 08 Jul 2020 13:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594241111; cv=none; d=google.com; s=arc-20160816; b=k+T5gReqC2RJ/Bvj031Km3bRKtcxHWlfFvdcHCGrp7TG9ExsE8Lz3kDghMMHvEPkC7 flegXm+oceXN3LvdsXBpdjjmCAcBx/tOOvmf7bTi/NNMbZljhLVafMnrPGz8NQfNe3SX CCxXQYI7Ka+0nqd6lwXT0eJ9zKGFv+bMGMVXnUGd/ww00zadM4nj326K/akbVXxbBXG1 0DTZycE4XPOJbpbsUZ7vfc3BWlSaO8iYcO7ZfHvrWX0CGN2qJco3Pnn7swYUpU4zvfiQ c7X8ghR/Zhh5JxvIW40Dv51IsBD5pSJHhu2uly8B9OO9S7b6eNOTZzp9DA1Dok16jl52 8tUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CYN4ZPTRRLmikf2AfGJfBSOfESO1vZ7Kmrp2kg16ins=; b=0ZlqBlNY2ESO8YBkkPsxDu24ypEfN9RaH70Te8LFbhN5N48nnkVBlwMSdGYEvSDWf0 Q7v8lfERe6blO3gq2YtssIW0djfNRturDazi7oMps1ypwd3FJJ+ijt7EPOU0zCOOnMSE 0qEwp7A1JLV2tXUj00GMQ9jRZqypOwTIOM8p943CsLQKVT6/GWTXJkDv9UgbDrNpWry3 hT0lABTe0inAo2lf2ExWVBd7/g1s13w5x3emJmGqGUDFLLeg3y3Z43/jK5fymfPeAjz3 jHxIeRYRKAvYPGA16KxtnV73sCgVz7aaQ2VkbAfiEPx+HMU2rh4DN5J/iQHqiVyLW6kz LMmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lj2fY8b5; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p7si601135ejy.206.2020.07.08.13.45.11; Wed, 08 Jul 2020 13:45:11 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=@linaro.org header.s=google header.b=lj2fY8b5; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726267AbgGHUpK (ORCPT + 9 others); Wed, 8 Jul 2020 16:45:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726247AbgGHUpJ (ORCPT ); Wed, 8 Jul 2020 16:45:09 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6227EC061A0B for ; Wed, 8 Jul 2020 13:45:09 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id 9so55741549ljv.5 for ; Wed, 08 Jul 2020 13:45:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CYN4ZPTRRLmikf2AfGJfBSOfESO1vZ7Kmrp2kg16ins=; b=lj2fY8b5b+/T0hqmF94GXmba3uJdPM5GXqZZPv419BtMmn7WoPmKxltsvm/W1ZWPbt 2ptHrAuBxDBvQ+hiYY/1AegpNnX/SfnKabmpB/0sWErzE6e7B6KkKR1QBSfiLfKvqpur /Lx9wFvxwMXXWzYGvbz1QT3SPHcbNPg0vvZxy/95M6hOB8GfWJYfJ+exgTpZnpJz05co iMjeSlWVLs/HUvqB4B+P8VXmHeSfcsTalFOObGN8L9AdHManuTIkho5iiCTJB0YqFt5z t5bP097C8cBvdag5FTd32dwliu0ThZQ2NrBOtmMPdrTbAExgUIHPF+G6wK68d0xpgiwW 69VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CYN4ZPTRRLmikf2AfGJfBSOfESO1vZ7Kmrp2kg16ins=; b=TDuI54/2Yskn20NdH8YTy5s65ccvg1Qd2VVs2Fa1RQpu9MDwpQyj0XZhhEhNtYooGp s5LUM6LxoAC86VDKEIfiNZ2DY9qWGAdKeWv1fBkoCaUY0n2LG9gqaptLsX5hdyKrAOxU MIyFyW1Qh8YL7mQSiLYSXTrZcUig10/LFaE80LhHyUcw8jQknzoahwCdCfrWcJZfrOJ0 BU/WW5y4igYMr4DbBf0yCt+s2mPzIkDg/bFRhewHuWDvkmTcchcu5J7lWjGy24G7Zpcy CZFcGQgWjTZ3BmKOgJBnuHQlxe0u5l41wEFTzWYiAGofeNeNhSazZqt1r8t48Y3L2aFY 7JXA== X-Gm-Message-State: AOAM530GRXKYiRr9Bcm/dDT4hwRIweK1rdImz3Vr/McGmOWIzSSEKR2/ bKd2vtNYiosJrZFymNgLRKFlwQ== X-Received: by 2002:a2e:3e15:: with SMTP id l21mr12753883lja.43.1594241107826; Wed, 08 Jul 2020 13:45:07 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id i10sm206688ljg.80.2020.07.08.13.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 13:45:06 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , netdev@vger.kernel.org, "David S . Miller" Cc: Linus Walleij , DENG Qingfang , Mauri Sandberg , Vladimir Oltean Subject: [net-next PATCH 3/3 v1] net: dsa: rtl8366: Use DSA core to set up VLAN Date: Wed, 8 Jul 2020 22:44:56 +0200 Message-Id: <20200708204456.1365855-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200708204456.1365855-1-linus.walleij@linaro.org> References: <20200708204456.1365855-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The current code in the RTL8366 VLAN handling code initializes the default VLANs like this: Ingress packets: port 0 ---> VLAN 1 ---> CPU port (5) port 1 ---> VLAN 2 ---> CPU port (5) port 2 ---> VLAN 3 ---> CPU port (5) port 3 ---> VLAN 4 ---> CPU port (5) port 4 ---> VLAN 5 ---> CPU port (5) Egress packets: port 5 (CPU) ---> VLAN 6 ---> port 0, 1, 2, 3, 4 So 5 VLANs for ingress packets and one VLAN for egress packets. Further it sets the PVID for each port to further restrict the packets to this VLAN only, and sets them as untagged. This is a neat set-up in a way and a leftover from the OpenWrt driver and the vendor code drop. However the DSA core can be instructed to assign all ports to a default VLAN, which will be VLAN 1. This patch will change the above picture to this: Ingress packets: port 0 ---> VLAN 1 ---> CPU port (5) port 1 ---> VLAN 1 ---> CPU port (5) port 2 ---> VLAN 1 ---> CPU port (5) port 3 ---> VLAN 1 ---> CPU port (5) port 4 ---> VLAN 1 ---> CPU port (5) Egress packets: port 5 (CPU) ---> VLAN 1 ---> port 0, 1, 2, 3, 4 So all traffic in the switch will by default pass on VLAN 1. No PVID is set for ports by the DSA core in this case. This might have performance impact since the switch hardware probably can sort packets into VLANs as they pass through the fabric, but it is better to fix the above set-up using generic code in that case so that it can be reused by other switches. The tested scenarios sure work fine with this set-up including video streaming from a NAS device. Cc: DENG Qingfang Cc: Mauri Sandberg Suggested-by: Florian Fainelli Suggested-by: Vladimir Oltean Signed-off-by: Linus Walleij --- drivers/net/dsa/rtl8366.c | 35 ----------------------------------- drivers/net/dsa/rtl8366rb.c | 3 +++ 2 files changed, 3 insertions(+), 35 deletions(-) -- 2.26.2 diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 8f40fbf70a82..e549b1167ddc 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -275,41 +275,6 @@ int rtl8366_init_vlan(struct realtek_smi *smi) if (ret) return ret; - /* Loop over the available ports, for each port, associate - * it with the VLAN (port+1) - */ - for (port = 0; port < smi->num_ports; port++) { - u32 mask; - - if (port == smi->cpu_port) - /* For the CPU port, make all ports members of this - * VLAN. - */ - mask = GENMASK((int)smi->num_ports - 1, 0); - else - /* For all other ports, enable itself plus the - * CPU port. - */ - mask = BIT(port) | BIT(smi->cpu_port); - - /* For each port, set the port as member of VLAN (port+1) - * and untagged, except for the CPU port: the CPU port (5) is - * member of VLAN 6 and so are ALL the other ports as well. - * Use filter 0 (no filter). - */ - dev_info(smi->dev, "VLAN%d port mask for port %d, %08x\n", - (port + 1), port, mask); - ret = rtl8366_set_vlan(smi, (port + 1), mask, mask, 0); - if (ret) - return ret; - - dev_info(smi->dev, "VLAN%d port %d, PVID set to %d\n", - (port + 1), port, (port + 1)); - ret = rtl8366_set_pvid(smi, port, (port + 1)); - if (ret) - return ret; - } - return rtl8366_enable_vlan(smi, true); } EXPORT_SYMBOL_GPL(rtl8366_init_vlan); diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index 48f1ff746799..226851e57c1b 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -743,6 +743,9 @@ static int rtl8366rb_setup(struct dsa_switch *ds) dev_info(smi->dev, "RTL%04x ver %u chip found\n", chip_id, chip_ver & RTL8366RB_CHIP_VERSION_MASK); + /* This chip requires that a VLAN be set up for each port */ + ds->configure_vlan_while_not_filtering = true; + /* Do the init dance using the right jam table */ switch (chip_ver) { case 0: