Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 2 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] This patch turns three device-tree properties into hard
requirements without updating the DT binding or saying so in the…
- [Medium] The hardware flow-control state does not follow the pause
result that phylink negotiates and reports.
- [Medium] For GDM2/3/4, airoha_setup_phylink() sets mac_capabilities to
include MAC_10 | MAC_100 | MAC_1000.
- [Low] The commit message does not fully describe what the patch does.
--
net: airoha: add phylink support
This adds phylink support to every GDM port of the airoha ethernet
driver. GDM1 uses the internal interface. GDM2/3/4 look up PCS instances
through pcs-handle. Phylink is connected and started in ndo_open, stopped
in ndo_stop, GDM4 MBI fragment sizes are programmed on link up, and
get/set_link_ksettings now go through phylink.
> Add phylink support for each GDM port. For GDM1 add the internal interface
> mode as the only supported mode. For GDM2/3/4 add the required
> configuration of the PCS to make the external PHY or attached SFP cage
> work.
[Severity: Low]
This isn't a bug, but is this description accurate for this patch?
The MAC driver change does not touch any PCS registers. It only fills
pcs_interfaces, num_possible_pcs and fill_available_pcs in phylink_config
so PCS instances can be looked up through pcs-handle. The PCS programming
itself is in the separate "net: pcs: airoha: add PCS driver for Airoha
AN7581 SoC" commit.
The message also leaves out the one MAC-side hardware change. On link up,
GDM4 now writes speed-dependent TX/RX fragment sizes into the SGMII0 or
SGMII1 field of the new REG_FE_GDM4_TMBI_FRAG and REG_FE_GDM4_RMBI_FRAG
registers, protected by a new per-port link_lock mutex.
The "Nothing to do in MAC, everything is handled in PCS" comments on
airoha_mac_config() and airoha_mac_link_down() are also misleading,
because airoha_mac_link_up() does program FE state for GDM4.
> diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
> index 044ad0302ef35..e41dfad58b258 100644
> --- a/drivers/net/ethernet/airoha/airoha_eth.c
> +++ b/drivers/net/ethernet/airoha/airoha_eth.c
[ ... ]
> @@ -3752,6 +3790,155 @@ bool airoha_is_valid_gdm_dev(struct airoha_eth *eth,
> return false;
> }
>
> +/* Nothing to do in MAC, everything is handled in PCS */
> +static void airoha_mac_config(struct phylink_config *config, unsigned int mode,
> + const struct phylink_link_state *state)
> +{
> +}
> +
> +static void airoha_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 airoha_gdm_dev *dev = container_of(config, struct airoha_gdm_dev,
> + phylink_config);
> + struct airoha_gdm_port *port = dev->port;
> + struct airoha_eth *eth = dev->eth;
> + u32 frag_size_tx, frag_size_rx;
> +
> + /* TX/RX frag is configured only for GDM4 */
> + if (port->id != AIROHA_GDM4_IDX)
> + return;
[Severity: Medium]
Should tx_pause and rx_pause be applied to the hardware somewhere?
airoha_setup_phylink() advertises MAC_SYM_PAUSE | MAC_ASYM_PAUSE on every
GDM port. Phylink will negotiate pause and pass the result here, but
airoha_mac_link_up() never uses it, and airoha_mac_config() and
airoha_mac_link_down() are empty. GDM_INGRESS_FC_EN_MASK in
REG_GDM_INGRESS_CFG is never written by the driver either.
The only flow-control programming is in the PCS driver:
drivers/net/pcs/airoha/pcs-airoha-common.c:airoha_pcs_config() {
...
regmap_update_bits(maps->pcs_mac, AIROHA_PCS_XFI_MAC_XFI_GIB_CFG,
AIROHA_PCS_XFI_TX_FC_EN | AIROHA_PCS_XFI_RX_FC_EN,
permit_pause_to_mac ?
AIROHA_PCS_XFI_TX_FC_EN | AIROHA_PCS_XFI_RX_FC_EN :
0);
...
}
permit_pause_to_mac comes from link_config.pause & MLO_PAUSE_AN, and
phylink_create() defaults link_config.pause to MLO_PAUSE_AN. No
.get_pauseparam or .set_pauseparam is routed to phylink, so the user
cannot change this.
If the link partner advertises no pause, or only asymmetric pause, would
the XFI MAC still send and honour PAUSE frames in both directions?
ethtool would then report a different pause state from the one the
hardware is actually using.
[ ... ]
> +static int airoha_setup_phylink(struct net_device *netdev)
> +{
[ ... ]
> + err = of_get_phy_mode(np, &phy_mode);
> + if (err) {
> + dev_err(&netdev->dev, "incorrect phy-mode\n");
> + return err;
> + }
[ ... ]
> + if (port->id == AIROHA_GDM1_IDX) {
> + config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
> + MAC_10000FD;
> +
> + __set_bit(PHY_INTERFACE_MODE_INTERNAL,
> + config->supported_interfaces);
> + } else {
> + config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
> + MAC_10 | MAC_100 | MAC_1000 |
> + MAC_2500FD | MAC_5000FD | MAC_10000FD;
[Severity: Medium]
Can the hardware actually do half duplex here?
MAC_10, MAC_100 and MAC_1000 include the HD variants, so phylink lets an
attached SGMII PHY advertise and resolve half duplex. Nothing seems to
program duplex, though:
- airoha_mac_link_up() ignores its duplex argument
- airoha_mac_config() is empty
- airoha_pcs_link_up() in the PCS driver also ignores duplex
- AIROHA_PCS_HSGMII_AN_DUPLEX_FORCE_MODE is defined but never used
- the PCS get_state helpers hard-code state->duplex = DUPLEX_FULL
Suppose an external SGMII PHY resolves 10/100/1000 half duplex, for
example to a hub. Would that leave phylink reporting half duplex while
the MAC/PCS still runs full duplex, giving a duplex mismatch?
If the datapath is full duplex only, MAC_10FD | MAC_100FD | MAC_1000FD
may be the right capabilities.
> +
> + config->num_possible_pcs = fwnode_phylink_pcs_count(dev_fwnode(config->dev));
> + config->fill_available_pcs = airoha_fill_available_pcs;
> +
[ ... ]
> + phy_interface_copy(config->pcs_interfaces,
> + config->supported_interfaces);
> + }
> +
> + phylink = phylink_create(config, of_fwnode_handle(np),
> + phy_mode, &airoha_phylink_ops);
> + if (IS_ERR(phylink))
> + return PTR_ERR(phylink);
[Severity: High]
Does this break probe for device trees that follow the current binding?
phy-mode is now mandatory on every GDM node, because a failing
of_get_phy_mode() returns an error.
For GDM2/3/4, pcs_interfaces and fill_available_pcs are always set.
num_possible_pcs comes from fwnode_phylink_pcs_count(), which returns 0
when there is no pcs-handle or no #pcs-cells. phylink_create() then
rejects the config:
drivers/net/phy/phylink.c:phylink_create() {
...
if (has_pcs_interfaces != has_pcs_callback ||
has_pcs_interfaces != has_pcs_count) {
dev_err(config->dev,
"phylink: error: pcs_interfaces, num_possible_pcs and fill_available_pcs must be set together\n");
return ERR_PTR(-EINVAL);
}
...
}
Errors from fwnode_pcs_get() other than -ENOENT/-ENODEV are also passed
back up.
airoha_alloc_gdm_device() now ends with "return
airoha_setup_phylink(netdev)", so the failure travels up this path:
airoha_probe()->airoha_alloc_gdm_port()->airoha_alloc_gdm_device()->
airoha_setup_phylink()
airoha_probe() then jumps to error_napi_stop and tears down every port,
including the GDM1 DSA conduit.
Documentation/devicetree/bindings/net/airoha,en7581-eth.yaml still
requires only reg and compatible for the ethernet@ nodes. Its own example
(ethe…@1, and ethe…@4 with eth-port children) has no phy-mode,
pcs-handle or fixed-link. The binding also does not say whether pcs-handle
goes on the GDM node or on the airoha,eth-port child.
The new PCS provider only matches airoha,an7581-pcs-* compatibles, but
this MAC driver also binds airoha,an7583-eth. Would AN7583 GDM2/3/4 nodes,
which probed before this patch, now fail probe for the whole controller?
For GDM1, if phy-mode is "internal" but there is no fixed-link or
phy-handle, phylink stays in MLO_AN_PHY. phylink_of_phy_connect() in
airoha_dev_open() then returns -ENODEV, so the conduit can no longer be
opened. Is fixed-link now required on GDM1 as well?
The in-tree en7581.dtsi gdm1 node already has phy-mode = "internal" and
fixed-link, so in-tree boards look unaffected.
The commit message only says:
These needs to be defined in the GDM port node using the pcs-handle
property.
It does not say that a missing pcs-handle fails the whole controller, and
it does not mention the phy-mode or fixed-link requirements.
Could these cases fail only the affected netdev, for example by setting
the PCS fields only when num_possible_pcs is non-zero? Could the binding
and commit message also document the new requirements?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40gmail.com