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; } }