From patchwork Mon Aug 17 15:15:11 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: 247817 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2749693ilo; Mon, 17 Aug 2020 08:54:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytN8lPZ1fnl+iJaKIDdJNu5Ku3zdGqTMwl7dqnIgMHXJk1YiC+LPEYlzlVqqKlXaDQFQsJ X-Received: by 2002:a17:906:430b:: with SMTP id j11mr15461532ejm.270.1597679675822; Mon, 17 Aug 2020 08:54:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597679675; cv=none; d=google.com; s=arc-20160816; b=uBwQJMWaklb+7DiIK0ErJXYY5pTz7px6b6MQMBfJdro51KOx7bk+yyQBSG7k9VO1Wg nRk99c8SSSa8to4mc4rBL8udZ2XtFNkg9kwoakpOi7UuZe4Ypn45q8LuRJ1FWV+Mh/HD p/EkCJ7UV73fnIcM42jH34RCqCEcYz5r8nxnk2IReF+UKcPyTfu9RwzRg4X4dbzmXWZI n4UTWAesG/PXW0ROvJogYFWzaB7w006PqtU3Z8AixrrLwxHA0jpN4qkYiiy5ASZ27jU8 qfF1JVvac/gmi2Y5kDdWDH9+2rSxGH9/Wu/EVarESqhIbdugY/lAHP//mairXA6dXluo 8q3A== 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=XpKQ+BP6vQS060lrAN6kLJQJIJO7jBnqfFa4xYmBZ4bi28QrTuV3S4I74N5QevAsUk h5HzV+wD/NoSsjHUvYrJ9NxDOTCoddjBA7yRhohcOMEfi0Z/Mgiwh4unDP+eES9RLNPO 37gufPVlZIvggdxNioreaG9uuaDTD8q4DvYQZZqbfmhTGHvPGbMGyK1dOZ+Z+fQzWySe 1jbUZ3+9S1AkdxY29XINnM3kgxeJ6VL+HzouxnZcBX15XoJ0I9pSa2HKCTIjSUOQcK3V 7jCphGZHqLCVxw5bA1EOgPF+6Tqj+jOpKPhA5iHVq0u6UTRbPVOV+PFytsp3q95MbD+M SFSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iDyIyUN6; 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 u24si12802447edb.159.2020.08.17.08.54.35; Mon, 17 Aug 2020 08:54:35 -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=iDyIyUN6; 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 S2387712AbgHQPye (ORCPT + 15 others); Mon, 17 Aug 2020 11:54:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:41992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387986AbgHQPy1 (ORCPT ); Mon, 17 Aug 2020 11:54:27 -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 6B5AD20657; Mon, 17 Aug 2020 15:54:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597679666; bh=3bA66jFSyUuGfQ13Zx/hap/5xok8FbaDikQg8GCSOgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iDyIyUN6S1QiPQl8bxu3AmeT4JgI4PI32hcsAaWNeSpbMYpVZLPk8kl+HCxEdCbcM 7wIdiGEAi92IFUZIYHei0TMDtC9plHNwDynxWZR9EQ2mmGdL8bT52IKEBiZ7XpW8wf d2LDSVhRS7f/gVOb6x3KZu1uEg0RP32e7CuL9/I4= 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.7 261/393] net: dsa: rtl8366: Fix VLAN semantics Date: Mon, 17 Aug 2020 17:15:11 +0200 Message-Id: <20200817143832.271000552@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@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; } }