From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Florian Fainelli <f.fainelli@gmail.com>,
"David S . Miller" <davem@davemloft.net>,
Sasha Levin <sashal@kernel.org>,
netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 184/671] net: dsa: b53: Fix default VLAN ID
Date: Thu, 16 Jan 2020 11:51:33 -0500 [thread overview]
Message-ID: <20200116165940.10720-67-sashal@kernel.org> (raw)
In-Reply-To: <20200116165940.10720-1-sashal@kernel.org>
From: Florian Fainelli <f.fainelli@gmail.com>
[ Upstream commit fea83353177a55540c71c140887737c282137aa2 ]
We were not consistent in how the default VID of a given port was
defined, b53_br_leave() would make sure the VLAN ID would be either 0/1
depending on the switch generation, but b53_configure_vlan(), which is
the default configuration would unconditionally set it to 1. The correct
value is 1 for 5325/5365 series and 0 otherwise. To avoid repeating that
mistake ever again, introduce a helper function: b53_default_pvid() to
factor that out.
Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/dsa/b53/b53_common.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 2d3a2cb026d2..bceda1e88442 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -622,15 +622,25 @@ static void b53_enable_mib(struct b53_device *dev)
b53_write8(dev, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, gc);
}
+static u16 b53_default_pvid(struct b53_device *dev)
+{
+ if (is5325(dev) || is5365(dev))
+ return 1;
+ else
+ return 0;
+}
+
int b53_configure_vlan(struct dsa_switch *ds)
{
struct b53_device *dev = ds->priv;
struct b53_vlan vl = { 0 };
- int i;
+ int i, def_vid;
+
+ def_vid = b53_default_pvid(dev);
/* clear all vlan entries */
if (is5325(dev) || is5365(dev)) {
- for (i = 1; i < dev->num_vlans; i++)
+ for (i = def_vid; i < dev->num_vlans; i++)
b53_set_vlan_entry(dev, i, &vl);
} else {
b53_do_vlan_op(dev, VTA_CMD_CLEAR);
@@ -640,7 +650,7 @@ int b53_configure_vlan(struct dsa_switch *ds)
b53_for_each_port(dev, i)
b53_write16(dev, B53_VLAN_PAGE,
- B53_VLAN_PORT_DEF_TAG(i), 1);
+ B53_VLAN_PORT_DEF_TAG(i), def_vid);
if (!is5325(dev) && !is5365(dev))
b53_set_jumbo(dev, dev->enable_jumbo, false);
@@ -1142,12 +1152,8 @@ int b53_vlan_del(struct dsa_switch *ds, int port,
vl->members &= ~BIT(port);
- if (pvid == vid) {
- if (is5325(dev) || is5365(dev))
- pvid = 1;
- else
- pvid = 0;
- }
+ if (pvid == vid)
+ pvid = b53_default_pvid(dev);
if (untagged && !dsa_is_cpu_port(ds, port))
vl->untag &= ~(BIT(port));
@@ -1460,10 +1466,7 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *br)
b53_write16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), pvlan);
dev->ports[port].vlan_ctl_mask = pvlan;
- if (is5325(dev) || is5365(dev))
- pvid = 1;
- else
- pvid = 0;
+ pvid = b53_default_pvid(dev);
/* Make this port join all VLANs without VLAN entries */
if (is58xx(dev)) {
--
2.20.1
next prev parent reply other threads:[~2020-01-16 19:07 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200116165940.10720-1-sashal@kernel.org>
2020-01-16 16:50 ` [PATCH AUTOSEL 4.19 124/671] net: hns3: fix wrong combined count returned by ethtool -l Sasha Levin
2020-01-16 16:50 ` [PATCH AUTOSEL 4.19 129/671] net: hns3: fix bug of ethtool_ops.get_channels for VF Sasha Levin
2020-01-16 16:50 ` [PATCH AUTOSEL 4.19 132/671] iwlwifi: mvm: avoid possible access out of array Sasha Levin
2020-01-16 16:50 ` [PATCH AUTOSEL 4.19 133/671] net/mlx5: Take lock with IRQs disabled to avoid deadlock Sasha Levin
2020-01-16 16:50 ` [PATCH AUTOSEL 4.19 134/671] ip_tunnel: Fix route fl4 init in ip_md_tunnel_xmit Sasha Levin
2020-01-16 16:50 ` [PATCH AUTOSEL 4.19 136/671] iwlwifi: mvm: fix A-MPDU reference assignment Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 153/671] iwlwifi: mvm: fix RSS config command Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 159/671] ath10k: fix dma unmap direction for management frames Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 160/671] net: phy: fixed_phy: Fix fixed_phy not checking GPIO Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 162/671] net/smc: original socket family in inet_sock_diag Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 170/671] xsk: add missing smp_rmb() in xsk_mmap Sasha Levin
2020-01-16 16:51 ` Sasha Levin [this message]
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 185/671] net: dsa: b53: Properly account for VLAN filtering Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 186/671] net: dsa: b53: Do not program CPU port's PVID Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 187/671] mt76: usb: fix possible memory leak in mt76u_buf_free Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 191/671] mdio_bus: Fix PTR_ERR() usage after initialization to constant Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 196/671] brcmfmac: create debugfs files for bus-specific layer Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 200/671] net: dsa: qca8k: Enable delay for RGMII_ID mode Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 201/671] net/mlx5: Delete unused FPGA QPN variable Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 207/671] net: dsa: fix unintended change of bridge interface STP state Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 224/671] ath10k: Fix length of wmi tlv command for protected mgmt frames Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 225/671] netfilter: nft_set_hash: fix lookups with fixed size hash on big endian Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 226/671] netfilter: nft_set_hash: bogus element self comparison from deactivation path Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 227/671] net: sched: act_csum: Fix csum calc for tagged packets Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 232/671] net: aquantia: fixed instack structure overflow Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 240/671] nfp: fix simple vNIC mailbox length Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 243/671] net/mlx5: Fix multiple updates of steering rules in parallel Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 244/671] net/mlx5e: IPoIB, Fix RX checksum statistics update Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 245/671] net: sh_eth: fix a missing check of of_get_phy_mode Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 255/671] tipc: tipc clang warning Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 260/671] net: phy: don't clear BMCR in genphy_soft_reset Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 262/671] net: dsa: Avoid null pointer when failing to connect to PHY Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200116165940.10720-67-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).