From: Simon Horman <horms@kernel.org>
To: wei.fang@nxp.com
Cc: Simon Horman <horms@kernel.org>,
f.fainelli@gmail.com, krzk+dt@kernel.org, netdev@vger.kernel.org,
devicetree@vger.kernel.org, imx@lists.linux.dev,
linux-kernel@vger.kernel.org, claudiu.manoil@nxp.com,
xiaoning.wang@nxp.com, linux-arm-kernel@lists.infradead.org,
linux@armlinux.org.uk, pabeni@redhat.com, conor+dt@kernel.org,
chleroy@kernel.org, edumazet@google.com, frank.li@nxp.com,
kuba@kernel.org, vladimir.oltean@nxp.com,
linuxppc-dev@lists.ozlabs.org, robh@kernel.org,
davem@davemloft.net, andrew+netdev@lunn.ch
Subject: Re: [net-next,11/14] net: dsa: netc: add phylink MAC operations
Date: Wed, 18 Mar 2026 14:46:51 +0000 [thread overview]
Message-ID: <20260318144651.1891670-1-horms@kernel.org> (raw)
In-Reply-To: <20260316094152.1558671-12-wei.fang@nxp.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: dsa: netc: add phylink MAC operations
This commit adds phylink MAC operations to the NETC DSA switch driver,
including support for different PHY interface modes (RGMII, RMII, MII,
REVMII, SGMII, 2500BASE-X).
> diff --git a/drivers/net/dsa/netc/netc_main.c b/drivers/net/dsa/netc/netc_main.c
> index bc7d48b99610..884ee899fc89 100644
> --- a/drivers/net/dsa/netc/netc_main.c
> +++ b/drivers/net/dsa/netc/netc_main.c
[ ... ]
> @@ -595,10 +595,221 @@ static void netc_switch_get_ip_revision(struct netc_switch *priv)
> priv->revision = val & IPBRR0_IP_REV;
> }
>
> +static void netc_phylink_get_caps(struct dsa_switch *ds, int port,
> + struct phylink_config *config)
> +{
> + struct netc_switch *priv = ds->priv;
> +
> + priv->info->phylink_get_caps(port, config);
> +}
> +
> +static void netc_port_set_mac_mode(struct netc_port *np,
> + unsigned int mode,
> + phy_interface_t phy_mode)
> +{
> + u32 mask = PM_IF_MODE_IFMODE | PM_IF_MODE_ENA;
> + u32 val = 0;
> +
> + switch (phy_mode) {
> + case PHY_INTERFACE_MODE_RGMII:
> + case PHY_INTERFACE_MODE_RGMII_ID:
> + case PHY_INTERFACE_MODE_RGMII_RXID:
> + case PHY_INTERFACE_MODE_RGMII_TXID:
> + val |= IFMODE_RGMII;
> + /* Enable auto-negotiation for the MAC if its
> + * RGMII interface supports In-Band status.
> + */
> + if (phylink_autoneg_inband(mode))
> + val |= PM_IF_MODE_ENA;
> + break;
> + case PHY_INTERFACE_MODE_RMII:
> + val |= IFMODE_RMII;
> + break;
> + case PHY_INTERFACE_MODE_REVMII:
> + val |= PM_IF_MODE_REVMII;
> + fallthrough;
> + case PHY_INTERFACE_MODE_MII:
> + val |= IFMODE_MII;
> + break;
Does the mask need to include PM_IF_MODE_REVMII? Looking at
netc_port_set_mac_mode(), the mask is set to:
u32 mask = PM_IF_MODE_IFMODE | PM_IF_MODE_ENA;
which expands to GENMASK(2,0) | BIT(15) = 0x8007. When the REVMII
case sets val |= PM_IF_MODE_REVMII (BIT(3)), this makes val = 0x9.
In netc_mac_port_rmw(), there's a check:
WARN_ON((mask | val) != mask)
This check would fire on every REVMII configuration since 0x800F != 0x8007.
Additionally, REVMII is reachable because imx94_switch_phylink_get_caps()
advertises PHY_INTERFACE_MODE_REVMII as supported for port 2. When
transitioning FROM REVMII to another mode, PM_IF_MODE_REVMII (BIT(3))
won't be cleared since it's not in the mask, leaving stale configuration.
Should the mask be:
u32 mask = PM_IF_MODE_IFMODE | PM_IF_MODE_REVMII | PM_IF_MODE_ENA;
> + case PHY_INTERFACE_MODE_SGMII:
> + case PHY_INTERFACE_MODE_2500BASEX:
> + val |= IFMODE_SGMII;
> + break;
> + default:
> + break;
> + }
> +
> + netc_mac_port_rmw(np, NETC_PM_IF_MODE(0), mask, val);
> +}
[ ... ]
> +static void netc_port_force_set_rgmii_mac(struct netc_port *np,
> + int speed, int duplex)
> +{
> + u32 mask, val;
> +
> + mask = PM_IF_MODE_ENA | PM_IF_MODE_SSP | PM_IF_MODE_HD |
> + PM_IF_MODE_M10 | PM_IF_MODE_REVMII;
> +
> + switch (speed) {
> + default:
> + case SPEED_1000:
> + val = FIELD_PREP(PM_IF_MODE_SSP, SSP_1G);
> + break;
> + case SPEED_100:
> + val = FIELD_PREP(PM_IF_MODE_SSP, SSP_100M);
> + break;
> + case SPEED_10:
> + val = FIELD_PREP(PM_IF_MODE_SSP, SSP_10M);
> + break;
> + }
> +
> + if (duplex != DUPLEX_FULL)
> + val |= PM_IF_MODE_HD;
> +
> + netc_mac_port_rmw(np, NETC_PM_IF_MODE(0), mask, val);
> +}
> +
> +static void net_port_set_rmii_mii_mac(struct netc_port *np,
This isn't a bug, but should this function be named
netc_port_set_rmii_mii_mac() instead of net_port_set_rmii_mii_mac()?
All other functions in this driver use the netc_ prefix
(netc_port_set_speed, netc_port_force_set_rgmii_mac,
netc_port_set_mac_mode, etc.).
> + int speed, int duplex)
> +{
> + u32 mask, val = 0;
> +
> + mask = PM_IF_MODE_ENA | PM_IF_MODE_SSP | PM_IF_MODE_HD |
> + PM_IF_MODE_M10;
> +
> + if (speed == SPEED_10)
> + val |= PM_IF_MODE_M10;
> +
> + if (duplex != DUPLEX_FULL)
> + val |= PM_IF_MODE_HD;
> +
> + netc_mac_port_rmw(np, NETC_PM_IF_MODE(0), mask, val);
> +}
[ ... ]
> +static void netc_mac_link_up(struct phylink_config *config,
> + struct phy_device *phy, unsigned int mode,
> + phy_interface_t interface, int speed,
> + int duplex, bool tx_pause, bool rx_pause)
> +{
> + struct dsa_port *dp = dsa_phylink_to_port(config);
> + struct netc_port *np;
> +
> + np = NETC_PORT(dp->ds, dp->index);
> + netc_port_set_speed(np, speed);
> +
> + if (phy_interface_mode_is_rgmii(interface) &&
> + !phylink_autoneg_inband(mode)) {
> + netc_port_force_set_rgmii_mac(np, speed, duplex);
> + }
> +
> + if (interface == PHY_INTERFACE_MODE_RMII ||
> + interface == PHY_INTERFACE_MODE_REVMII ||
> + interface == PHY_INTERFACE_MODE_MII) {
> + net_port_set_rmii_mii_mac(np, speed, duplex);
> + }
> +
> + netc_port_set_hd_flow_control(np, duplex == DUPLEX_HALF);
> + netc_port_mac_rx_enable(np);
> +}
> +
> +static void netc_mac_link_down(struct phylink_config *config,
> + unsigned int mode,
> + phy_interface_t interface)
> +{
> + struct dsa_port *dp = dsa_phylink_to_port(config);
> +
> + netc_port_mac_rx_graceful_stop(NETC_PORT(dp->ds, dp->index));
> +}
> +
> +static const struct phylink_mac_ops netc_phylink_mac_ops = {
> + .mac_config = netc_mac_config,
> + .mac_link_up = netc_mac_link_up,
> + .mac_link_down = netc_mac_link_down,
> +};
> +
> static const struct dsa_switch_ops netc_switch_ops = {
> .get_tag_protocol = netc_get_tag_protocol,
> .setup = netc_setup,
> .teardown = netc_teardown,
> + .phylink_get_caps = netc_phylink_get_caps,
> };
>
> static int netc_switch_probe(struct pci_dev *pdev,
> @@ -639,6 +850,7 @@ static int netc_switch_probe(struct pci_dev *pdev,
> ds->num_ports = priv->info->num_ports;
> ds->num_tx_queues = NETC_TC_NUM;
> ds->ops = &netc_switch_ops;
> + ds->phylink_mac_ops = &netc_phylink_mac_ops;
> ds->priv = priv;
>
> priv->ds = ds;
[ ... ]
next prev parent reply other threads:[~2026-03-18 14:47 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 9:41 [PATCH net-next 00/14] Add preliminary NETC switch support for i.MX94 Wei Fang
2026-03-16 9:41 ` [PATCH net-next 01/14] dt-bindings: net: dsa: update the description of 'dsa,member' property Wei Fang
2026-03-16 9:41 ` [PATCH net-next 02/14] dt-bindings: net: dsa: add NETC switch Wei Fang
2026-03-16 9:41 ` [PATCH net-next 03/14] net: enetc: add pre-boot initialization for i.MX94 switch Wei Fang
2026-03-16 9:41 ` [PATCH net-next 04/14] net: enetc: add basic operations to the FDB table Wei Fang
2026-03-16 9:41 ` [PATCH net-next 05/14] net: enetc: add support for the "Add" operation to VLAN filter table Wei Fang
2026-03-16 9:41 ` [PATCH net-next 06/14] net: enetc: add support for the "Update" operation to buffer pool table Wei Fang
2026-03-16 9:41 ` [PATCH net-next 07/14] net: enetc: add support for "Add" and "Delete" operations to IPFT Wei Fang
2026-03-16 9:41 ` [PATCH net-next 08/14] net: enetc: add multiple command BD rings support Wei Fang
2026-03-18 14:32 ` [net-next,08/14] " Simon Horman
2026-03-19 2:15 ` Wei Fang
2026-03-18 22:41 ` [PATCH net-next 08/14] " Frank Li
2026-03-16 9:41 ` [PATCH net-next 09/14] net: dsa: add NETC switch tag support Wei Fang
2026-03-16 9:41 ` [PATCH net-next 10/14] net: dsa: netc: introduce NXP NETC switch driver for i.MX94 Wei Fang
2026-03-18 14:39 ` [net-next,10/14] " Simon Horman
2026-03-19 2:48 ` Wei Fang
2026-03-16 9:41 ` [PATCH net-next 11/14] net: dsa: netc: add phylink MAC operations Wei Fang
2026-03-18 14:46 ` Simon Horman [this message]
2026-03-19 2:01 ` [net-next,11/14] " Wei Fang
2026-03-16 9:41 ` [PATCH net-next 12/14] net: dsa: netc: add more basic functions support Wei Fang
2026-03-18 14:49 ` [net-next,12/14] " Simon Horman
2026-03-19 2:59 ` Wei Fang
2026-03-16 9:41 ` [PATCH net-next 13/14] net: dsa: netc: initialize buffer bool table and implement flow-control Wei Fang
2026-03-18 14:54 ` [net-next,13/14] " Simon Horman
2026-03-18 14:56 ` Krzysztof Kozlowski
2026-03-18 22:24 ` Jakub Kicinski
2026-03-19 15:00 ` Simon Horman
2026-03-19 14:59 ` Simon Horman
2026-03-16 9:41 ` [PATCH net-next 14/14] net: dsa: netc: add support for the standardized counters Wei Fang
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=20260318144651.1891670-1-horms@kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=chleroy@kernel.org \
--cc=claudiu.manoil@nxp.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=frank.li@nxp.com \
--cc=imx@lists.linux.dev \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=vladimir.oltean@nxp.com \
--cc=wei.fang@nxp.com \
--cc=xiaoning.wang@nxp.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