From patchwork Mon Aug 17 15:14:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 247798 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2734185ilo; Mon, 17 Aug 2020 08:33:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxElFF/PMtyyYN3plTVwmiVCJvXrsMZRWO+r92Ud9nYZGGOQ0RzLIMYgam7YT/B0kpydapk X-Received: by 2002:aa7:c395:: with SMTP id k21mr15829668edq.386.1597678380942; Mon, 17 Aug 2020 08:33:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597678380; cv=none; d=google.com; s=arc-20160816; b=Sv+UVsDoPuM1UU1z4no4a61okVB38TbohOVYpDlNvNN8MqJnvWsqH61k9Ay74TQCLz CCk4hsw9s2HEH+Vw64tUEO/QhAcS6lHpWla9MkAWZdOqYmTtIn1a2X8jLMV07iEtaPw2 ZExwfAedLxhe9uSl4MBuGLZ+OxC6EdQy2UjAPO/F2WEnZKZgjo9I8ZWWhz9Aa6+KMsnY KWgYvXpHPapJZA6W6JRNqTfi68ENEGzb8ydUmYtXaZsNaARnMbrZ/7ZK1msa0W/VyvMq fHYzvhd7btZ1OM0ExaI99cUjLb9gT4IUlk/p6qLjfNSDqORHSNIg1g1MDsnlUPs0/jjH ayRQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eCJt3Jx9CXZyArpRuccNyRV9Acq91DtUAs3nkSDA6vw=; b=tra0dqW18dCxCzfudUaUBZgOWMb3OOhOaOMr+zkUs7HfOlqdvkUuTLxowO/fFT7971 CKCzsrTGv+eJBpr6vvuF3s3ZsAT/HfOCxgE7Gp4TnoEGII7XJJtDNN36Dmxie6UTft9h IyX1gNU+2aY1PbyIBIWRnpP161sKqAPOfmQVom4Veo1MU0H29GSjb/DnT8wvb4TrTUjc DdAxYGsNtzlCmRL3AZfP+0vtUYPfneMfQHkwFJE1goS23YxrTYgU9RddaEmMcJEObHku RuduhiYROiNlODE4U9z39MLf2QQIwrjcpM7slG74OIhrRBtVqWtTogFICdwi2Yj3TIQZ wU5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nQuzbFHH; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (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 gh13si11412414ejb.3.2020.08.17.08.33.00; Mon, 17 Aug 2020 08:33:00 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=@kernel.org header.s=default header.b=nQuzbFHH; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730340AbgHQPc5 (ORCPT + 15 others); Mon, 17 Aug 2020 11:32:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:33340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730335AbgHQPcx (ORCPT ); Mon, 17 Aug 2020 11:32:53 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 45B7022B40; Mon, 17 Aug 2020 15:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678372; bh=3bA66jFSyUuGfQ13Zx/hap/5xok8FbaDikQg8GCSOgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nQuzbFHHQnjOsbXYP9rmMUNWlb1aQZowyq8LQRAadE8Z1MlNJ2vxh69mgVYBoZpbd ZJKLS9Kug26ntKHQCr1IiCA3GLyXtyfoWRW5nlbBKlqz+rZlAIiH93IB/pI9otELCp BdYifF9bm/4knXAAa/YR53EfbSMBNyAzINSYXQDY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, DENG Qingfang , Mauri Sandberg , Florian Fainelli , Linus Walleij , "David S. Miller" , Sasha Levin Subject: [PATCH 5.8 311/464] net: dsa: rtl8366: Fix VLAN semantics Date: Mon, 17 Aug 2020 17:14:24 +0200 Message-Id: <20200817143848.693885753@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Linus Walleij [ Upstream commit 15ab7906cc9290afb006df1bb1074907fbcc7061 ] 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 Reviewed-by: Florian Fainelli Fixes: d8652956cf37 ("net: dsa: realtek-smi: Add Realtek SMI driver") Signed-off-by: Linus Walleij Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/dsa/rtl8366.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index ac88caca5ad4d..a75dcd6698b8a 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; } }