| From 5b287416a10c6f89b20d4921df20abd4ad6757a1 Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Sun, 8 Feb 2026 22:56:01 +0000 |
| Subject: net: mscc: ocelot: split xmit into FDMA and register injection paths |
| |
| From: Ziyi Guo <n7l8m4@u.northwestern.edu> |
| |
| [ Upstream commit 47f79b20e7fb885aa1623b759a68e8e27401ec4d ] |
| |
| Split ocelot_port_xmit() into two separate functions: |
| - ocelot_port_xmit_fdma(): handles the FDMA injection path |
| - ocelot_port_xmit_inj(): handles the register-based injection path |
| |
| The top-level ocelot_port_xmit() now dispatches to the appropriate |
| function based on the ocelot_fdma_enabled static key. |
| |
| This is a pure refactor with no behavioral change. Separating the two |
| code paths makes each one simpler and prepares for adding proper locking |
| to the register injection path without affecting the FDMA path. |
| |
| Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu> |
| Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> |
| Link: https://patch.msgid.link/20260208225602.1339325-3-n7l8m4@u.northwestern.edu |
| Signed-off-by: Jakub Kicinski <kuba@kernel.org> |
| Stable-dep-of: 026f6513c588 ("net: mscc: ocelot: add missing lock protection in ocelot_port_xmit_inj()") |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| drivers/net/ethernet/mscc/ocelot_net.c | 39 ++++++++++++++++++++------ |
| 1 file changed, 30 insertions(+), 9 deletions(-) |
| |
| diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c |
| index e2b475bf58e6c..84b3dcf1d2f5a 100644 |
| --- a/drivers/net/ethernet/mscc/ocelot_net.c |
| +++ b/drivers/net/ethernet/mscc/ocelot_net.c |
| @@ -571,7 +571,25 @@ static bool ocelot_xmit_timestamp(struct ocelot *ocelot, int port, |
| return true; |
| } |
| |
| -static netdev_tx_t ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev) |
| +static netdev_tx_t ocelot_port_xmit_fdma(struct sk_buff *skb, |
| + struct net_device *dev) |
| +{ |
| + struct ocelot_port_private *priv = netdev_priv(dev); |
| + struct ocelot_port *ocelot_port = &priv->port; |
| + struct ocelot *ocelot = ocelot_port->ocelot; |
| + int port = priv->port.index; |
| + u32 rew_op = 0; |
| + |
| + if (!ocelot_xmit_timestamp(ocelot, port, skb, &rew_op)) |
| + return NETDEV_TX_OK; |
| + |
| + ocelot_fdma_inject_frame(ocelot, port, rew_op, skb, dev); |
| + |
| + return NETDEV_TX_OK; |
| +} |
| + |
| +static netdev_tx_t ocelot_port_xmit_inj(struct sk_buff *skb, |
| + struct net_device *dev) |
| { |
| struct ocelot_port_private *priv = netdev_priv(dev); |
| struct ocelot_port *ocelot_port = &priv->port; |
| @@ -579,24 +597,27 @@ static netdev_tx_t ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev) |
| int port = priv->port.index; |
| u32 rew_op = 0; |
| |
| - if (!static_branch_unlikely(&ocelot_fdma_enabled) && |
| - !ocelot_can_inject(ocelot, 0)) |
| + if (!ocelot_can_inject(ocelot, 0)) |
| return NETDEV_TX_BUSY; |
| |
| if (!ocelot_xmit_timestamp(ocelot, port, skb, &rew_op)) |
| return NETDEV_TX_OK; |
| |
| - if (static_branch_unlikely(&ocelot_fdma_enabled)) { |
| - ocelot_fdma_inject_frame(ocelot, port, rew_op, skb, dev); |
| - } else { |
| - ocelot_port_inject_frame(ocelot, port, 0, rew_op, skb); |
| + ocelot_port_inject_frame(ocelot, port, 0, rew_op, skb); |
| |
| - consume_skb(skb); |
| - } |
| + consume_skb(skb); |
| |
| return NETDEV_TX_OK; |
| } |
| |
| +static netdev_tx_t ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev) |
| +{ |
| + if (static_branch_unlikely(&ocelot_fdma_enabled)) |
| + return ocelot_port_xmit_fdma(skb, dev); |
| + |
| + return ocelot_port_xmit_inj(skb, dev); |
| +} |
| + |
| enum ocelot_action_type { |
| OCELOT_MACT_LEARN, |
| OCELOT_MACT_FORGET, |
| -- |
| 2.51.0 |
| |