mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Lee Jones <lee@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Maxime Chevallier <maxime.chevallier@bootlin.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, netdev@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	upstream@airoha.com
Subject: Re: [net-next PATCH v13 13/14] net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver
Date: Tue, 18 Mar 2025 17:15:40 +0200	[thread overview]
Message-ID: <20250318151540.4rmw6jj5hh2rp4b4@skbuf> (raw)
In-Reply-To: <20250315154407.26304-14-ansuelsmth@gmail.com>

On Sat, Mar 15, 2025 at 04:43:53PM +0100, Christian Marangi wrote:
> +/* Similar to MT7530 also trap link local frame and special frame to CPU */
> +static int an8855_trap_special_frames(struct an8855_priv *priv)
> +{
> +	int ret;
> +
> +	/* Trap BPDUs to the CPU port(s) and egress them
> +	 * VLAN-untagged.
> +	 */
> +	ret = regmap_update_bits(priv->regmap, AN8855_BPC,
> +				 AN8855_BPDU_BPDU_FR | AN8855_BPDU_EG_TAG |
> +				 AN8855_BPDU_PORT_FW,
> +				 AN8855_BPDU_BPDU_FR |
> +				 FIELD_PREP(AN8855_BPDU_EG_TAG, AN8855_VLAN_EG_UNTAGGED) |
> +				 FIELD_PREP(AN8855_BPDU_PORT_FW, AN8855_BPDU_CPU_ONLY));
> +	if (ret)
> +		return ret;
> +
> +	/* Trap 802.1X PAE frames to the CPU port(s) and egress them
> +	 * VLAN-untagged.
> +	 */
> +	ret = regmap_update_bits(priv->regmap, AN8855_PAC,
> +				 AN8855_PAE_BPDU_FR | AN8855_PAE_EG_TAG |
> +				 AN8855_PAE_PORT_FW,
> +				 AN8855_PAE_BPDU_FR |
> +				 FIELD_PREP(AN8855_PAE_EG_TAG, AN8855_VLAN_EG_UNTAGGED) |
> +				 FIELD_PREP(AN8855_PAE_PORT_FW, AN8855_BPDU_CPU_ONLY));
> +	if (ret)
> +		return ret;
> +
> +	/* Trap frames with :01 MAC DAs to the CPU port(s) and egress
> +	 * them VLAN-untagged.
> +	 */
> +	ret = regmap_update_bits(priv->regmap, AN8855_RGAC1,
> +				 AN8855_R01_BPDU_FR | AN8855_R01_EG_TAG |
> +				 AN8855_R01_PORT_FW,
> +				 AN8855_R01_BPDU_FR |
> +				 FIELD_PREP(AN8855_R01_EG_TAG, AN8855_VLAN_EG_UNTAGGED) |
> +				 FIELD_PREP(AN8855_R01_PORT_FW, AN8855_BPDU_CPU_ONLY));
> +	if (ret)
> +		return ret;
> +
> +	/* Trap frames with :02 MAC DAs to the CPU port(s) and egress
> +	 * them VLAN-untagged.
> +	 */
> +	ret = regmap_update_bits(priv->regmap, AN8855_RGAC1,
> +				 AN8855_R02_BPDU_FR | AN8855_R02_EG_TAG |
> +				 AN8855_R02_PORT_FW,
> +				 AN8855_R02_BPDU_FR |
> +				 FIELD_PREP(AN8855_R02_EG_TAG, AN8855_VLAN_EG_UNTAGGED) |
> +				 FIELD_PREP(AN8855_R02_PORT_FW, AN8855_BPDU_CPU_ONLY));
> +	if (ret)
> +		return ret;
> +
> +	/* Trap frames with :03 MAC DAs to the CPU port(s) and egress
> +	 * them VLAN-untagged.
> +	 */
> +	ret = regmap_update_bits(priv->regmap, AN8855_RGAC1,
> +				 AN8855_R03_BPDU_FR | AN8855_R03_EG_TAG |
> +				 AN8855_R03_PORT_FW,
> +				 AN8855_R03_BPDU_FR |
> +				 FIELD_PREP(AN8855_R03_EG_TAG, AN8855_VLAN_EG_UNTAGGED) |
> +				 FIELD_PREP(AN8855_R03_PORT_FW, AN8855_BPDU_CPU_ONLY));
> +	if (ret)
> +		return ret;
> +
> +	/* Trap frames with :0E MAC DAs to the CPU port(s) and egress
> +	 * them VLAN-untagged.
> +	 */
> +	return regmap_update_bits(priv->regmap, AN8855_RGAC1,
> +				  AN8855_R0E_BPDU_FR | AN8855_R0E_EG_TAG |
> +				  AN8855_R0E_PORT_FW,
> +				  AN8855_R0E_BPDU_FR |
> +				  FIELD_PREP(AN8855_R0E_EG_TAG, AN8855_VLAN_EG_UNTAGGED) |
> +				  FIELD_PREP(AN8855_R0E_PORT_FW, AN8855_BPDU_CPU_ONLY));
> +}

Is there a way in which you could group the registers a bit more?
The function occupies 2 screens :-/

There are 4 read-modify-write operations in succession to the RGAC1
register. Maybe you can converge them into a single regmap_update_bits()
call.

Also, for packets which reach the CPU via a trap, we shouldn't set
skb->offload_fwd_mark = 1. In other words, if the bridge layer wants to
forward them in software (including to other an8855 ports), let it do so.
The common example given in commit 515853ccecc6 ("bridge: allow
forwarding some link local frames") is 802.1X PAE (01-80-C2-00-00-03).

I notice mtk_tag_rcv() calls dsa_default_offload_fwd_mark() with no
pre-condition. Do you know whether there exists any bit in the RX tag
which signifies whether the packet was received because of a trap
(or if it was autonomously forwarded by the switch to the other bridge
ports as well)? The offload_fwd_mark bit should be set based on
something like that.

  reply	other threads:[~2025-03-18 15:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-15 15:43 [net-next PATCH v13 00/14] net: dsa: Add Airoha AN8855 support Christian Marangi
2025-03-15 15:43 ` [net-next PATCH v13 01/14] dt-bindings: nvmem: Document support for Airoha AN8855 Switch EFUSE Christian Marangi
2025-03-15 15:43 ` [net-next PATCH v13 02/14] dt-bindings: net: Document support for Airoha AN8855 Switch Virtual MDIO Christian Marangi
2025-03-15 15:43 ` [net-next PATCH v13 03/14] dt-bindings: net: dsa: Document support for Airoha AN8855 DSA Switch Christian Marangi
2025-03-17 16:21   ` Rob Herring (Arm)
2025-03-15 15:43 ` [net-next PATCH v13 04/14] dt-bindings: net: Document support for AN8855 Switch Internal PHY Christian Marangi
2025-03-17 16:22   ` Rob Herring (Arm)
2025-03-15 15:43 ` [net-next PATCH v13 05/14] dt-bindings: mfd: Document support for Airoha AN8855 Switch SoC Christian Marangi
2025-03-15 17:12   ` Rob Herring (Arm)
2025-03-17 14:28   ` Rob Herring
2025-03-15 15:43 ` [net-next PATCH v13 06/14] net: mdio: regmap: prepare support for multiple valid addr Christian Marangi
2025-03-15 15:43 ` [net-next PATCH v13 07/14] net: mdio: regmap: add support for C45 read/write Christian Marangi
2025-03-15 15:43 ` [net-next PATCH v13 08/14] net: mdio: regmap: add support for multiple valid addr Christian Marangi
2025-03-15 15:43 ` [net-next PATCH v13 09/14] net: mdio: regmap: add OF support Christian Marangi
2025-03-15 15:43 ` [net-next PATCH v13 10/14] mfd: an8855: Add support for Airoha AN8855 Switch MFD Christian Marangi
2025-03-21  6:12   ` kernel test robot
2025-04-04 13:01   ` Lee Jones
2025-03-15 15:43 ` [net-next PATCH v13 11/14] net: mdio: Add Airoha AN8855 Switch MDIO Passtrough Christian Marangi
2025-03-15 15:43 ` [net-next PATCH v13 12/14] nvmem: an8855: Add support for Airoha AN8855 Switch EFUSE Christian Marangi
2025-03-15 15:43 ` [net-next PATCH v13 13/14] net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver Christian Marangi
2025-03-18 15:15   ` Vladimir Oltean [this message]
2025-04-08  9:13     ` Christian Marangi
2025-03-15 15:43 ` [net-next PATCH v13 14/14] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY Christian Marangi

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=20250318151540.4rmw6jj5hh2rp4b4@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=ansuelsmth@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=matthias.bgg@gmail.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=upstream@airoha.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

all inboxes | Powered by JetHome®