From patchwork Sun Jul 26 23:34:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 247151 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp4348142ilg; Sun, 26 Jul 2020 16:34:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKoOo8+rMpgUh6J1bRSZkep4YOHfv0Z33PJplY45cwKMHQzg+nyUWsL7E4401SrAzpkmg4 X-Received: by 2002:a17:906:6406:: with SMTP id d6mr17953578ejm.30.1595806497917; Sun, 26 Jul 2020 16:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595806497; cv=none; d=google.com; s=arc-20160816; b=bkmTw2vUyON/t89d5wtEahXPQNMbvsP/7mjLqRJ6mZoqDiRAspIELn1MW/EAqsnYua IHPbxtybaicmXIAMvlKjWKA5xXRQvQXm7a40yNAdIZ+2tv3FGWUDcP1VMwGHHqV1GtHK 9PxqjnxTVnbeOyoIzYeoEDdvQJjzBOdjCSeNAs+hnTbDnG0BTb05K1lhdmUhkWa9D6IW /oZ1BwVdHRaBybKmKoYZSckjsveleKnizxK7YL2r4yvrk3a2BgX59ET13qnniGTJ0EiC 41WDxuFGgvJ+ALJHX6WohR2HlUCktmT7uAcdb5jS4IRjvHrgEw72yH+25TQXRzt17Ocp zdbA== 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=Rc8F31vQgyzmseTSjEvvQ2ZmeNk370kua+35RMa42C4=; b=JMUBho/km3PPffTiYg+kAraW/74ZdTe1Nkl/lXM5lilNV4XcBuxZtJNTJtoN5LtF+l Dpjc/TeGNiUAT9KLsqEBiSsC7K+PGEbCOHM1KoY0+zi55X90SfZk6QqMgcJThgKFCilP NxNhgzMhYXfXfLK1WeT3x00+XCL0cRkf5KD9QRcvJh86gG9HQ2nCDaYmq33+Odt2A8VO 5BCaI8NYwtCMfemKgb+/t2apwr7JekpFaV4xu8Lr6GrO3nJ7DeWjlF/No4pFxIGiE5E2 LZKSzOTt66XFWCZ5M1mQLmLXirfIUCPFIaK7yLLIkLScwON6NzfPjqlJ0xSICyzxsFif lcPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OgV4FKg2; 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 nv2si4572961ejb.154.2020.07.26.16.34.57; Sun, 26 Jul 2020 16:34:57 -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=OgV4FKg2; 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 S1727940AbgGZXe5 (ORCPT + 9 others); Sun, 26 Jul 2020 19:34:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbgGZXe4 (ORCPT ); Sun, 26 Jul 2020 19:34:56 -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 C05C1C0619D2 for ; Sun, 26 Jul 2020 16:34:55 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id s16so20893ljc.8 for ; Sun, 26 Jul 2020 16:34:55 -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=Rc8F31vQgyzmseTSjEvvQ2ZmeNk370kua+35RMa42C4=; b=OgV4FKg2bFryYIZG1CBaMggEvTkCLo/3eYeIrf2hzbeJXmmwYekh/9gWr5QzbV6+Gh Sp0oOtSiMd5FLjOkaU/sU+TC03+1umvDfxoryaAoHBvpd2nsT6bmTHiQaPkWRIMOrfzh 2gx41dgrNJ0iaxngLIKSIgJLb1KImK7MqcTFInNeIHYUmyC/PE+BlEeCJDIvgzPXDdbI +V0pSFYy1Qvxp1cG/ZleREB3q2LodgdcirKz+BIh/ZJotDi0SKXgWMLEfjMxRwicydef iX69PJFCWqqwhP1xbGRiwz8LnMY9DQ1OzlKMt02R4qxolj+qrLQEVdvSGJmsOEv3eHKw WySA== 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=Rc8F31vQgyzmseTSjEvvQ2ZmeNk370kua+35RMa42C4=; b=BD/QckveiXY94jLYMsqk5YcgyTVba73heYFXi2A0R+FYaxODFo7QV2bhHG598FBu0Q 0T5iSrBpKe83Od+HVswWW+/DpYnZFxTqJ2BU4rCieVcv/OiyWVIyxCvizfpBA3YIoU3j GBMABTHz9qxhHHBnVKJ/hhAMstevv0wPEk76fgkgFZ2FMvbR4f52ozu1Ji/Bu5/NEoGu qs5pbrgi4jrPCYqOi5W+lT2ALFFBOQT3aE1ZfsJIWKcRenIOxklH5mVcA/mLm57JcgSk 1DX1QtWiI2TG8MPH20gUtZ522JHX2RSFz07sKxp22spCLy29QcqHQpvEzvsGRDwoCCpn 9ouw== X-Gm-Message-State: AOAM531he0d5v0pH4ddPL5bXGgs6eB3Db2ilcMxyXaDF52V75JjBMXve PR067RN+UZGiBs+Td4en1tR6fA== X-Received: by 2002:a2e:9d84:: with SMTP id c4mr8947727ljj.46.1595806493815; Sun, 26 Jul 2020 16:34:53 -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 v25sm2028605ljg.95.2020.07.26.16.34.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jul 2020 16:34:53 -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/2 v2] net: dsa: rtl8366: Fix VLAN semantics Date: Mon, 27 Jul 2020 01:34:39 +0200 Message-Id: <20200726233440.374390-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200726233440.374390-1-linus.walleij@linaro.org> References: <20200726233440.374390-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 Reviewed-by: Florian Fainelli Fixes: d8652956cf37 ("net: dsa: realtek-smi: Add Realtek SMI driver") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Collect Florian's Review-tag --- drivers/net/dsa/rtl8366.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) -- 2.26.2 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 Sun Jul 26 23:34:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 247152 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp4348157ilg; Sun, 26 Jul 2020 16:35:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9g5Xt8l1dhsDnO2yNoU4fRP6POYtIE6umKbXdE7m3ZmQJe/gA967sDgaMFLmYqMfGIPXa X-Received: by 2002:a17:907:389:: with SMTP id ss9mr19622242ejb.56.1595806500290; Sun, 26 Jul 2020 16:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595806500; cv=none; d=google.com; s=arc-20160816; b=HW6l4M+WxcLuuWQtNqUxv4GzoZVPGTgiqaWDQuC4HqF1Kp9D5054JSwUaQFGUBODZW 7BZm74JNciB9vDz4nseGNtbiuws6Qab7a8l6i2SIcm+EHPdo/UR3CL70fe4tK7eVnIK7 W8voLBmOZsac8jCPItizdJ7GfDb7IvEtACMD2//WtDSxWLRTOL1xTRYoqQ108YGKWoKe sO6XRX4Vx+8aCDq/vbY5Cd3H1niIhLM32ViBELsbDmP+uiY20pEVFD4wF6Kb5Kosj+WZ OUKnu6qElHnIKc0jd5pb7xvNRIdJiyS0rrOLlTzCvk50NL4CZCkrgcYyHZWve+Sd/sYQ 4XHA== 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=0NGy/9klYfszmbekc26ZLsPZ67iMjoQFTEnntnN7sDw=; b=s/EvC1Xmod/3aBVNeCISPxLzmgnOw5AI+2DD2+9nhCToJEL1j1ALmqSpuwrrW6uZC9 KEd9w1I4Mkl8DGow2EJiIsiYRFuWVXuVlg1u0qWAhwwSHY2fYRHnA61IRbZQhAIRXsXl IMrqGc9WMS+81RfhJw6zOG7MSVpWt6UC2ICEqBT1eQutSaWrosdl47PcnYbybuMmMDSa p6Tu2IIS1GeN63GaMPQUNGjX27m6aVRSOArPOJ32+bGmzHulpZ7oeWfQ01yUS5EPyXoH vMxVGgVXQxyOpY38lryObObSjaF5uSpAIsIHBxj+bZcJimGH4/JghviHBCNLr6Pftitm X09Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oxzlIgEN; 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 nv2si4572961ejb.154.2020.07.26.16.35.00; Sun, 26 Jul 2020 16:35:00 -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=oxzlIgEN; 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 S1727975AbgGZXe7 (ORCPT + 9 others); Sun, 26 Jul 2020 19:34:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbgGZXe6 (ORCPT ); Sun, 26 Jul 2020 19:34:58 -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 2E2D5C0619D2 for ; Sun, 26 Jul 2020 16:34:58 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id b25so15255189ljp.6 for ; Sun, 26 Jul 2020 16:34:58 -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=0NGy/9klYfszmbekc26ZLsPZ67iMjoQFTEnntnN7sDw=; b=oxzlIgENYFcYEpBd6AK3b87691hiV5Nvedr6ayi7wOf62xXA7zkiDEB6LrDy4Y1ZHJ ITgYYBSaM22ZAOqpFbJ8TmfAvucTqgTlRSjeFrXkfSP2zyoRqFtiH6kNW18snwk73nj4 vxd00uvd3TT+ojAt8lXE/FmeArq3pUxConVy9aDGzCcvWhAk8GuNlFmrY04+FSRB5pRT WKRkmWbR4Sy/hUIf26CHyA44hF/TGpB9D/6tHDWEeVj5WJVq1cqJgjWPKxB1g3uKUR74 7UZ5h82j1sbGETMXy6OCmK8j/J87PGIxHwmpBw0P/wKHPZIPSjzm1AJiEvmVkOXEDPlZ ND8A== 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=0NGy/9klYfszmbekc26ZLsPZ67iMjoQFTEnntnN7sDw=; b=bFxMnKEt4qrsS3ll72g5GbWSzNIxvqEAWdNq5gQj6tRQEyWug2DLfwxK7vdAe+y1Lh EnUsYefeXfTOeS92TrTLvYfS5hlWE4un9OoZaSuSfBV2ccvT4mNRf+wc6qAXm9oiCkh0 GS149x1YLEEAIqYnCHGbrBw3mQNPS+uM3Ziy1DLtY/oFzaazFTKLhoU7uZPH9n96V76k l2z6PqzihjEKLPCB+AL0tGnwoB+GtB6abm/syepyX1xV035nCbvBP03SV1eh8qpctWzX nRh40Cf+rDKtSMUsorCDaua5LdoMNo1NrUvLOZZa7RGJ7DoIO5D6Mko7gH40ZusNvhKH t36Q== X-Gm-Message-State: AOAM5326vxzdi6XPDucv3ll1u8IJyK3XVU31yEi2v/lOLMgVVgN0KMSj nNh7cudBLz6zmN48Po5f5smKvQ== X-Received: by 2002:a2e:9ed8:: with SMTP id h24mr8579896ljk.126.1595806496622; Sun, 26 Jul 2020 16:34:56 -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 v25sm2028605ljg.95.2020.07.26.16.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jul 2020 16:34:55 -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/2 v2] net: dsa: rtl8366: Fix VLAN set-up Date: Mon, 27 Jul 2020 01:34:40 +0200 Message-Id: <20200726233440.374390-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200726233440.374390-1-linus.walleij@linaro.org> References: <20200726233440.374390-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 Reviewed-by: Florian Fainelli Fixes: d8652956cf37 ("net: dsa: realtek-smi: Add Realtek SMI driver") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Collect Florian's Review-tag --- drivers/net/dsa/rtl8366.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.26.2 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);