From patchwork Thu Dec 18 08:42:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xfguo@credosemi.com X-Patchwork-Id: 422513 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id F0D811400EA for ; Thu, 18 Dec 2014 19:43:35 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id B8E06281612; Thu, 18 Dec 2014 09:41:35 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00 autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 55BE6281612 for ; Thu, 18 Dec 2014 09:41:21 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .credosemi. - helo: .smtp73.ord1c.emailsrvr. - helo-domain: .emailsrvr.) FROM/MX_MATCHES_HELO(DOMAIN)=-2; rate: -8.5 Received: from smtp73.ord1c.emailsrvr.com (smtp73.ord1c.emailsrvr.com [108.166.43.73]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Thu, 18 Dec 2014 09:41:20 +0100 (CET) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp10.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 7BA10380157; Thu, 18 Dec 2014 03:43:10 -0500 (EST) X-Virus-Scanned: OK Received: by smtp10.relay.ord1c.emailsrvr.com (Authenticated sender: xfguo-AT-credosemi.com) with ESMTPSA id 234013800D8; Thu, 18 Dec 2014 03:43:03 -0500 (EST) X-Sender-Id: xfguo@credosemi.com Received: from localhost.localdomain ([UNAVAILABLE]. [116.231.199.248]) (using TLSv1.2 with cipher AES128-SHA256) by 0.0.0.0:25 (trex/5.4.2); Thu, 18 Dec 2014 08:43:10 GMT From: xfguo@credosemi.com To: blogic@openwrt.org Date: Thu, 18 Dec 2014 16:42:03 +0800 Message-Id: <1418892123-7679-1-git-send-email-xfguo@credosemi.com> X-Mailer: git-send-email 1.9.1 Cc: Xiongfei Guo , openwrt-devel@lists.openwrt.org Subject: [OpenWrt-Devel] [PATCH] BB: ralink/mt7530: fixbug: unused vlan entry will take effect to other vlan. X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" It will fail when you have an uci network config like this: ``` config switch option name 'switch0' option reset '1' option enable_vlan '1' config switch_vlan option device 'switch0' option vlan '15' option vid '1' option ports '0 6t' config switch_port option name 'switch0' option port '0' option pvid '1' ``` It will be good until you run: $ swconfig dev switch0 vlan 1 set vid 333 So it seems that when REG_ESW_VLAN_VAWD1_VALID is unset, it will still take effect for VTU matching when two VTU entries have a same VID. Signed-off-by: Xiongfei Guo --- .../files/drivers/net/ethernet/ralink/mt7530.c | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.c index 1352b25..27fc51a 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.c @@ -408,6 +408,22 @@ mt7530_apply_config(struct switch_dev *dev) u8 etags = priv->vlan_entries[i].etags; u32 val; + + /* vlan port membership */ + if (member) + mt7530_w32(priv, REG_ESW_VLAN_VAWD1, REG_ESW_VLAN_VAWD1_IVL_MAC | + REG_ESW_VLAN_VAWD1_VTAG_EN | (member << 16) | + REG_ESW_VLAN_VAWD1_VALID); + else { + mt7530_w32(priv, REG_ESW_VLAN_VAWD1, 0); + + /* ignore vid (just set it to 0) when the ports is empty, + * because even the REG_ESW_VLAN_VAWD1_VALID is set to disable, + * it will still take effect to other vlan when they have + * a same vid. */ + vid = 0; + } + /* vid of vlan */ val = mt7530_r32(priv, REG_ESW_VLAN_VTIM(i)); if (i % 2 == 0) { @@ -417,16 +433,8 @@ mt7530_apply_config(struct switch_dev *dev) val &= 0xfff; val |= (vid << 12); } - mt7530_w32(priv, REG_ESW_VLAN_VTIM(i), val); - - /* vlan port membership */ - if (member) - mt7530_w32(priv, REG_ESW_VLAN_VAWD1, REG_ESW_VLAN_VAWD1_IVL_MAC | - REG_ESW_VLAN_VAWD1_VTAG_EN | (member << 16) | - REG_ESW_VLAN_VAWD1_VALID); - else - mt7530_w32(priv, REG_ESW_VLAN_VAWD1, 0); + mt7530_w32(priv, REG_ESW_VLAN_VTIM(i), val); /* egress mode */ val = 0; for (j = 0; j < MT7530_NUM_PORTS; j++) {