Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2642378pxa; Mon, 17 Aug 2020 15:15:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1w7f2bKv+i9Q7SwUsRwP/yCeFg7uq8iM7QnfRHqP3X5V3K9IKnXb6ZyMiguK9eIZ93j3W X-Received: by 2002:a17:906:a399:: with SMTP id k25mr18247654ejz.467.1597702547520; Mon, 17 Aug 2020 15:15:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597702547; cv=none; d=google.com; s=arc-20160816; b=p5Pd+0csy0Y/A3Ln65sGUSO3vEWFtVXzIMeVCfw0WHSwoYkXak6EBeCCBhX2WSpzg5 cdUkNjsihQZRApQZhJbio49o9eAkejf/OUq3S4yTqvARzI+QjmYVcyoAezb3TGIMlJjq CVP8+L9jZn2l2HzVf1Sp3Fn7mlxISQfxxywZIAF/t1uNZN06OBOHmuVicEPde8LLswrK Xl/6VZ5dsgrmtq+vO0V43JAj14cpJjLr9QczG4cN+Ojj8HFXSAEOd2MOYghH3b+Kfgi5 rbffTEusszEaxa/SILrDqdEf5KighQ61A+CxCxmr79+oY41DKV6LaoljuK15J1p+gej0 5qYQ== 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=eRuO3YbiqJoCqvTwO3P6ClTiYQcZ9zQ0oCQzSrPGOB/v25UD6FUJVHGAHgAH1Mw4uF wNqYzfKUVPjjwT1FDDVX5z9oDW9fLZkeczcltyPLo3oDWwStDTkvgtFK0UPWyQyqBiwZ Z8odTA6QJ8T9waSaLCTHYdy4zwElsRDUel6CsXCMzZBMDK8A+/x//U9F81HVBn6PLoEk 8POSS4rFOE9besb6pqnPhgb2e5u64TArOh4ozHsSLUR0v3o/LGC1o5+Vi+PnL25KbVb/ o9dXIMjg2yct2L2mULaqAljJUrmpH7KxT85RLmSgj0FAsEfh0I8nBF1Sm28hiEkGQYs0 1+Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xCbhXGTH; 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=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 si17si11243070ejb.599.2020.08.17.15.15.24; Mon, 17 Aug 2020 15:15:47 -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=@kernel.org header.s=default header.b=xCbhXGTH; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729664AbgHQRAH (ORCPT + 99 others); Mon, 17 Aug 2020 13:00:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:53970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731056AbgHQQG5 (ORCPT ); Mon, 17 Aug 2020 12:06:57 -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 E609922B3F; Mon, 17 Aug 2020 16:06:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680409; bh=3bA66jFSyUuGfQ13Zx/hap/5xok8FbaDikQg8GCSOgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xCbhXGTHJ7zuPRJieriahyqU8rgI9JNozhMXUUw7y6gWtWH1pc7w6PQbrQI6FJv74 Wt5fUpWWVVisrGoACa/hAmzKUolaE5e8pmarmL0cNNboefB7GiEkr4FCSaZdzc1pKK nVai7BKc92Uo0T/08w2jBPfqVBhWFDG2m6JAK76I= 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.4 176/270] net: dsa: rtl8366: Fix VLAN semantics Date: Mon, 17 Aug 2020 17:16:17 +0200 Message-Id: <20200817143804.581469469@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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; } } -- 2.25.1