From: Arun Ramadoss <arun.ramadoss@microchip.com>
To: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: Woojung Huh <woojung.huh@microchip.com>,
<UNGLinuxDriver@microchip.com>, Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"Russell King" <linux@armlinux.org.uk>
Subject: [Patch net-next 03/13] net: dsa: microchip: add the enable_stp_addr pointer in ksz_dev_ops
Date: Wed, 22 Jun 2022 14:34:15 +0530 [thread overview]
Message-ID: <20220622090425.17709-4-arun.ramadoss@microchip.com> (raw)
In-Reply-To: <20220622090425.17709-1-arun.ramadoss@microchip.com>
In order to transmit the STP BPDU packet to the CPU port, the STP
address 01-80-c2-00-00-00 has to be added to static alu table for
ksz8795 series switch. For the ksz9477 switch, there is reserved
multicast table which handles forwarding the particular set of
multicast address to cpu port. So enabling the multicast reserved table
and updated the cpu port index. The stp addr is enabled during the setup
phase using the enable_stp_addr pointer in struct ksz_dev_ops.
Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
---
drivers/net/dsa/microchip/ksz8795.c | 27 ++++++++++++++-------
drivers/net/dsa/microchip/ksz9477.c | 33 ++++++++++++++++++++++++++
drivers/net/dsa/microchip/ksz_common.h | 1 +
3 files changed, 52 insertions(+), 9 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index 0df2140b7ccc..30052dc5b9a1 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -1368,10 +1368,25 @@ static int ksz8_handle_global_errata(struct dsa_switch *ds)
return ret;
}
+static int ksz8_enable_stp_addr(struct ksz_device *dev)
+{
+ struct alu_struct alu;
+
+ /* Setup STP address for STP operation. */
+ memset(&alu, 0, sizeof(alu));
+ ether_addr_copy(alu.mac, eth_stp_addr);
+ alu.is_static = true;
+ alu.is_override = true;
+ alu.port_forward = dev->info->cpu_ports;
+
+ ksz8_w_sta_mac_table(dev, 0, &alu);
+
+ return 0;
+}
+
static int ksz8_setup(struct dsa_switch *ds)
{
struct ksz_device *dev = ds->priv;
- struct alu_struct alu;
int i, ret = 0;
dev->vlan_cache = devm_kcalloc(dev->dev, sizeof(struct vlan_table),
@@ -1422,14 +1437,7 @@ static int ksz8_setup(struct dsa_switch *ds)
for (i = 0; i < (dev->info->num_vlans / 4); i++)
ksz8_r_vlan_entries(dev, i);
- /* Setup STP address for STP operation. */
- memset(&alu, 0, sizeof(alu));
- ether_addr_copy(alu.mac, eth_stp_addr);
- alu.is_static = true;
- alu.is_override = true;
- alu.port_forward = dev->info->cpu_ports;
-
- ksz8_w_sta_mac_table(dev, 0, &alu);
+ dev->dev_ops->enable_stp_addr(dev);
ksz_init_mib_timer(dev);
@@ -1546,6 +1554,7 @@ static const struct ksz_dev_ops ksz8_dev_ops = {
.mirror_del = ksz8_port_mirror_del,
.get_caps = ksz8_get_caps,
.config_cpu_port = ksz8_config_cpu_port,
+ .enable_stp_addr = ksz8_enable_stp_addr,
.reset = ksz8_reset_switch,
.init = ksz8_switch_init,
.exit = ksz8_switch_exit,
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index fef8142440cf..6ca0d5753df0 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -1236,6 +1236,36 @@ static void ksz9477_config_cpu_port(struct dsa_switch *ds)
}
}
+static int ksz9477_enable_stp_addr(struct ksz_device *dev)
+{
+ u32 data;
+ int ret;
+
+ /* Enable Reserved multicast table */
+ ksz_cfg(dev, REG_SW_LUE_CTRL_0, SW_RESV_MCAST_ENABLE, true);
+
+ /* Set the Override bit for forwarding BPDU packet to CPU */
+ ret = ksz_write32(dev, REG_SW_ALU_VAL_B,
+ ALU_V_OVERRIDE | BIT(dev->cpu_port));
+ if (ret < 0)
+ return ret;
+
+ data = ALU_STAT_START | ALU_RESV_MCAST_ADDR;
+
+ ret = ksz_write32(dev, REG_SW_ALU_STAT_CTRL__4, data);
+ if (ret < 0)
+ return ret;
+
+ /* wait to be finished */
+ ret = ksz9477_wait_alu_sta_ready(dev);
+ if (ret < 0) {
+ dev_err(dev->dev, "Failed to update Reserved Multicast table\n");
+ return ret;
+ }
+
+ return 0;
+}
+
static int ksz9477_setup(struct dsa_switch *ds)
{
struct ksz_device *dev = ds->priv;
@@ -1281,6 +1311,8 @@ static int ksz9477_setup(struct dsa_switch *ds)
/* start switch */
ksz_cfg(dev, REG_SW_OPERATION, SW_START, true);
+ dev->dev_ops->enable_stp_addr(dev);
+
ksz_init_mib_timer(dev);
ds->configure_vlan_while_not_filtering = false;
@@ -1401,6 +1433,7 @@ static const struct ksz_dev_ops ksz9477_dev_ops = {
.change_mtu = ksz9477_change_mtu,
.max_mtu = ksz9477_max_mtu,
.config_cpu_port = ksz9477_config_cpu_port,
+ .enable_stp_addr = ksz9477_enable_stp_addr,
.reset = ksz9477_reset_switch,
.init = ksz9477_switch_init,
.exit = ksz9477_switch_exit,
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index d5b53b5b7b51..e38bdf1f5b41 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -205,6 +205,7 @@ struct ksz_dev_ops {
void (*freeze_mib)(struct ksz_device *dev, int port, bool freeze);
void (*port_init_cnt)(struct ksz_device *dev, int port);
void (*config_cpu_port)(struct dsa_switch *ds);
+ int (*enable_stp_addr)(struct ksz_device *dev);
int (*reset)(struct ksz_device *dev);
int (*init)(struct ksz_device *dev);
void (*exit)(struct ksz_device *dev);
--
2.36.1
next prev parent reply other threads:[~2022-06-22 9:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-22 9:04 [Patch net-next 00/13] net: dsa: microchip: common spi probe for the ksz series switches - part 2 Arun Ramadoss
2022-06-22 9:04 ` [Patch net-next 01/13] net: dsa: microchip: rename shutdown to reset in ksz_dev_ops Arun Ramadoss
2022-06-22 9:04 ` [Patch net-next 02/13] net: dsa: microchip: add config_cpu_port to struct ksz_dev_ops Arun Ramadoss
2022-06-22 9:04 ` Arun Ramadoss [this message]
2022-06-22 9:04 ` [Patch net-next 04/13] net: dsa: microchip: move setup function to ksz_common Arun Ramadoss
2022-06-22 9:04 ` [Patch net-next 05/13] net: dsa: microchip: move broadcast rate limit to ksz_setup Arun Ramadoss
2022-06-22 9:04 ` [Patch net-next 06/13] net: dsa: microchip: move multicast enable " Arun Ramadoss
2022-06-22 9:04 ` [Patch net-next 07/13] net: dsa: microchip: move start of switch " Arun Ramadoss
2022-06-22 9:04 ` [Patch net-next 08/13] net: dsa: microchip: common dsa_switch_ops for ksz switches Arun Ramadoss
2022-06-22 9:04 ` [Patch net-next 09/13] net: dsa: microchip: ksz9477: separate phylink mode from switch register Arun Ramadoss
2022-06-22 9:04 ` [Patch net-next 10/13] net: dsa: microchip: common menuconfig for ksz series switch Arun Ramadoss
2022-06-22 9:04 ` [Patch net-next 11/13] net: dsa: microchip: move ksz_dev_ops to ksz_common.c Arun Ramadoss
2022-06-22 9:04 ` [Patch net-next 12/13] net: dsa: microchip: remove the ksz8/ksz9477_switch_register Arun Ramadoss
2022-06-22 9:04 ` [Patch net-next 13/13] net: dsa: microchip: common ksz_spi_probe for ksz switches Arun Ramadoss
2022-06-24 10:50 ` [Patch net-next 00/13] net: dsa: microchip: common spi probe for the ksz series switches - part 2 patchwork-bot+netdevbpf
2022-06-24 11:23 ` Vladimir Oltean
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=20220622090425.17709-4-arun.ramadoss@microchip.com \
--to=arun.ramadoss@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=vivien.didelot@gmail.com \
--cc=woojung.huh@microchip.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.