From: David Yang <mmyangfl@gmail.com>
To: netdev@vger.kernel.org
Cc: David Yang <mmyangfl@gmail.com>, Andrew Lunn <andrew@lunn.ch>,
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>,
Simon Horman <horms@kernel.org>,
Russell King <linux@armlinux.org.uk>,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next v3 3/4] net: dsa: yt921x: Add HSR offloading support
Date: Wed, 26 Nov 2025 17:32:36 +0800 [thread overview]
Message-ID: <20251126093240.2853294-4-mmyangfl@gmail.com> (raw)
In-Reply-To: <20251126093240.2853294-1-mmyangfl@gmail.com>
Add offloading for packet duplication supported by the YT921x switches.
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
drivers/net/dsa/yt921x.c | 24 ++++++++++++++++++++++++
net/dsa/tag_yt921x.c | 4 ++++
2 files changed, 28 insertions(+)
diff --git a/drivers/net/dsa/yt921x.c b/drivers/net/dsa/yt921x.c
index e88b4037ee80..e7b416719b58 100644
--- a/drivers/net/dsa/yt921x.c
+++ b/drivers/net/dsa/yt921x.c
@@ -1038,6 +1038,27 @@ static int yt921x_dsa_port_max_mtu(struct dsa_switch *ds, int port)
return YT921X_FRAME_SIZE_MAX - ETH_HLEN - ETH_FCS_LEN - YT921X_TAG_LEN;
}
+static int
+yt921x_dsa_port_hsr_leave(struct dsa_switch *ds, int port,
+ struct net_device *hsr)
+{
+ return 0;
+}
+
+static int
+yt921x_dsa_port_hsr_join(struct dsa_switch *ds, int port,
+ struct net_device *hsr, struct netlink_ext_ack *extack)
+{
+ struct dsa_port *dp = dsa_to_port(ds, port);
+ struct net_device *user = dp->user;
+
+ /* Nothing special here; we natively support tx packet duplication */
+
+ user->features |= NETIF_F_HW_HSR_DUP;
+
+ return 0;
+}
+
static int
yt921x_mirror_del(struct yt921x_priv *priv, int port, bool ingress)
{
@@ -2880,6 +2901,9 @@ static const struct dsa_switch_ops yt921x_dsa_switch_ops = {
/* mtu */
.port_change_mtu = yt921x_dsa_port_change_mtu,
.port_max_mtu = yt921x_dsa_port_max_mtu,
+ /* hsr */
+ .port_hsr_leave = yt921x_dsa_port_hsr_leave,
+ .port_hsr_join = yt921x_dsa_port_hsr_join,
/* mirror */
.port_mirror_del = yt921x_dsa_port_mirror_del,
.port_mirror_add = yt921x_dsa_port_mirror_add,
diff --git a/net/dsa/tag_yt921x.c b/net/dsa/tag_yt921x.c
index 995da44f0a2a..0ad83924fda1 100644
--- a/net/dsa/tag_yt921x.c
+++ b/net/dsa/tag_yt921x.c
@@ -46,6 +46,7 @@ yt921x_tag_xmit(struct sk_buff *skb, struct net_device *netdev)
{
struct dsa_port *dp = dsa_user_to_port(netdev);
unsigned int port = dp->index;
+ struct dsa_port *partner;
__be16 *tag;
u16 tx;
@@ -59,6 +60,9 @@ yt921x_tag_xmit(struct sk_buff *skb, struct net_device *netdev)
tag[1] = 0;
tag[2] = 0;
tx = YT921X_TAG_PORT_EN | YT921X_TAG_TX_PORTn(port);
+ if (dp->hsr_dev)
+ dsa_hsr_foreach_port(partner, dp->ds, dp->hsr_dev)
+ tx |= YT921X_TAG_TX_PORTn(partner->index);
tag[3] = htons(tx);
return skb;
--
2.51.0
next prev parent reply other threads:[~2025-11-26 9:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 9:32 [PATCH net-next v3 0/4] net: dsa: yt921x: Add STP/MST/HSR/LAG support David Yang
2025-11-26 9:32 ` [PATCH net-next v3 1/4] net: dsa: yt921x: Use *_ULL bitfield macros for VLAN_CTRL David Yang
2025-11-28 1:58 ` Jakub Kicinski
2025-11-28 10:51 ` david laight
2025-11-28 11:43 ` Russell King (Oracle)
2025-11-28 19:25 ` david laight
2025-11-26 9:32 ` [PATCH net-next v3 2/4] net: dsa: yt921x: Add STP/MST support David Yang
2025-11-26 9:32 ` David Yang [this message]
2025-11-26 16:26 ` [PATCH net-next v3 3/4] net: dsa: yt921x: Add HSR offloading support Vladimir Oltean
2025-11-26 9:32 ` [PATCH net-next v3 4/4] net: dsa: yt921x: Add LAG " David Yang
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=20251126093240.2853294-4-mmyangfl@gmail.com \
--to=mmyangfl@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--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 \
/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).