From: Andrew Lunn <andrew@lunn.ch>
To: Tristram.Ha@microchip.com
Cc: "Woojung Huh" <woojung.huh@microchip.com>,
"Arun Ramadoss" <arun.ramadoss@microchip.com>,
"Vladimir Oltean" <olteanv@gmail.com>,
"Oleksij Rempel" <linux@rempel-privat.de>,
"Łukasz Majewski" <lukma@nabladev.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
UNGLinuxDriver@microchip.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net: dsa: microchip: Fix reserved multicast address table programming
Date: Sun, 2 Nov 2025 16:30:32 +0100 [thread overview]
Message-ID: <9f8e7666-d78b-418d-b660-82af4d79983e@lunn.ch> (raw)
In-Reply-To: <20251101014803.49842-1-Tristram.Ha@microchip.com>
> + /* The reserved multicast address table has 8 entries. Each entry has
> + * a default value of which port to forward. It is assumed the host
> + * port is the last port in most of the switches, but that is not the
> + * case for KSZ9477 or maybe KSZ9897. For LAN937X family the default
> + * port is port 5, the first RGMII port. It is okay for LAN9370, a
> + * 5-port switch, but may not be correct for the other 8-port
> + * versions. It is necessary to update the whole table to forward to
> + * the right ports.
> + * Furthermore PTP messages can use a reserved multicast address and
> + * the host will not receive them if this table is not correct.
> + */
> + def_port = BIT(dev->info->port_cnt - 1);
> + if (is_lan937x(dev))
> + def_port = BIT(4);
Why not just def_port = dsa_cpu_ports(ds)?
The aim here is to send frames to the CPU. You then don't need the
comment about different switch versions.
> + for (i = 0; i < 8; i++) {
Please replace the 8 with a #define.
> + if (ports == def_port) {
> + /* Change the host port. */
> + update = BIT(dev->cpu_port);
> +
> + /* The host port is correct so no need to update the
> + * the whole table but the first entry still needs to
> + * set the Override bit for STP.
> + */
> + if (update == def_port && i == 0)
> + ports = 0;
> + } else if (ports == 0) {
> + /* No change to entry. */
> + update = 0;
> + } else if (ports == (all_ports & ~def_port)) {
> + /* This entry does not forward to host port. But if
> + * the host needs to process protocols like MVRP and
> + * MMRP the host port needs to be set.
> + */
> + update = ports & ~BIT(dev->cpu_port);
> + update |= def_port;
> + } else {
> + /* No change to entry. */
> + update = ports;
> + }
> + if (update != ports) {
> + data &= ~dev->port_mask;
> + data |= update;
> + /* Set Override bit for STP in the first entry. */
> + if (i == 0)
> + data |= ALU_V_OVERRIDE;
You have already made this comparison once before. Maybe
update |= ALU_V_OVERRIDE
higher up?
Andrew
next prev parent reply other threads:[~2025-11-02 15:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-01 1:48 [PATCH net] net: dsa: microchip: Fix reserved multicast address table programming Tristram.Ha
2025-11-02 13:18 ` Łukasz Majewski
2025-11-02 15:30 ` Andrew Lunn [this message]
2025-11-05 1:52 ` Tristram.Ha
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=9f8e7666-d78b-418d-b660-82af4d79983e@lunn.ch \
--to=andrew@lunn.ch \
--cc=Tristram.Ha@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=arun.ramadoss@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rempel-privat.de \
--cc=lukma@nabladev.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox