Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-pcs-add-supported_interfaces-bitmap-for-pcs'

Russell King says:

====================
net: pcs: add supported_interfaces bitmap for PCS

This series adds supported_interfaces for PCS, which gives MAC code
a way to determine the interface modes that the PCS supports without
having to implement functions such as xpcs_get_interfaces(), or
workarounds such as in

https://lore.kernel.org/20241213090526.71516-3-maxime.chevallier@bootlin.com

Patch 1 adds the new bitmask to struct phylink_pcs, and code within
phylink to validate that the PCS returned by the MAC driver supports
the interface mode - but only if this bitmask is non-empty.

Patch 2 through 4 fills in the interface modes for XPCS, Mediatek LynxI
and Lynx PCS.

Patch 5 adds support to stmmac to make use of this bitmask when filling
in phylink_config.supported_interfaces, eliminating the call to
xpcs_get_interfaces.

As xpcs_get_interfaces() is now unused outside of pcs-xpcs.c, patch 6
makes this function static and removes it from the header file.
====================

Link: https://patch.msgid.link/Z3fG9oTY9F9fCYHv@shell.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+43 -5
+9 -2
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 1203 1203 struct stmmac_mdio_bus_data *mdio_bus_data; 1204 1204 int mode = priv->plat->phy_interface; 1205 1205 struct fwnode_handle *fwnode; 1206 + struct phylink_pcs *pcs; 1206 1207 struct phylink *phylink; 1207 1208 1208 1209 priv->phylink_config.dev = &priv->dev->dev; ··· 1225 1224 1226 1225 /* If we have an xpcs, it defines which PHY interfaces are supported. */ 1227 1226 if (priv->hw->xpcs) 1228 - xpcs_get_interfaces(priv->hw->xpcs, 1229 - priv->phylink_config.supported_interfaces); 1227 + pcs = xpcs_to_phylink_pcs(priv->hw->xpcs); 1228 + else 1229 + pcs = priv->hw->phylink_pcs; 1230 + 1231 + if (pcs) 1232 + phy_interface_or(priv->phylink_config.supported_interfaces, 1233 + priv->phylink_config.supported_interfaces, 1234 + pcs->supported_interfaces); 1230 1235 1231 1236 fwnode = priv->plat->port_node; 1232 1237 if (!fwnode)
+13
drivers/net/pcs/pcs-lynx.c
··· 334 334 .pcs_link_up = lynx_pcs_link_up, 335 335 }; 336 336 337 + static const phy_interface_t lynx_interfaces[] = { 338 + PHY_INTERFACE_MODE_SGMII, 339 + PHY_INTERFACE_MODE_QSGMII, 340 + PHY_INTERFACE_MODE_1000BASEX, 341 + PHY_INTERFACE_MODE_2500BASEX, 342 + PHY_INTERFACE_MODE_10GBASER, 343 + PHY_INTERFACE_MODE_USXGMII, 344 + }; 345 + 337 346 static struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio) 338 347 { 339 348 struct lynx_pcs *lynx; 349 + int i; 340 350 341 351 lynx = kzalloc(sizeof(*lynx), GFP_KERNEL); 342 352 if (!lynx) ··· 357 347 lynx->pcs.ops = &lynx_pcs_phylink_ops; 358 348 lynx->pcs.neg_mode = true; 359 349 lynx->pcs.poll = true; 350 + 351 + for (i = 0; i < ARRAY_SIZE(lynx_interfaces); i++) 352 + __set_bit(lynx_interfaces[i], lynx->pcs.supported_interfaces); 360 353 361 354 return lynx_to_phylink_pcs(lynx); 362 355 }
+4
drivers/net/pcs/pcs-mtk-lynxi.c
··· 307 307 mpcs->pcs.poll = true; 308 308 mpcs->interface = PHY_INTERFACE_MODE_NA; 309 309 310 + __set_bit(PHY_INTERFACE_MODE_SGMII, mpcs->pcs.supported_interfaces); 311 + __set_bit(PHY_INTERFACE_MODE_1000BASEX, mpcs->pcs.supported_interfaces); 312 + __set_bit(PHY_INTERFACE_MODE_2500BASEX, mpcs->pcs.supported_interfaces); 313 + 310 314 return &mpcs->pcs; 311 315 } 312 316 EXPORT_SYMBOL(mtk_pcs_lynxi_create);
+3 -2
drivers/net/pcs/pcs-xpcs.c
··· 594 594 } 595 595 } 596 596 597 - void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces) 597 + static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces) 598 598 { 599 599 const struct dw_xpcs_compat *compat; 600 600 601 601 for (compat = xpcs->desc->compat; compat->supported; compat++) 602 602 __set_bit(compat->interface, interfaces); 603 603 } 604 - EXPORT_SYMBOL_GPL(xpcs_get_interfaces); 605 604 606 605 int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable) 607 606 { ··· 1444 1445 ret = xpcs_init_id(xpcs); 1445 1446 if (ret) 1446 1447 goto out_clear_clks; 1448 + 1449 + xpcs_get_interfaces(xpcs, xpcs->pcs.supported_interfaces); 1447 1450 1448 1451 if (xpcs->info.pma == WX_TXGBE_XPCS_PMA_10G_ID) 1449 1452 xpcs->pcs.poll = false;
+11
drivers/net/phy/phylink.c
··· 691 691 return -EINVAL; 692 692 } 693 693 694 + /* Ensure that this PCS supports the interface which the MAC 695 + * returned it for. It is an error for the MAC to return a PCS 696 + * that does not support the interface mode. 697 + */ 698 + if (!phy_interface_empty(pcs->supported_interfaces) && 699 + !test_bit(state->interface, pcs->supported_interfaces)) { 700 + phylink_err(pl, "MAC returned PCS which does not support %s\n", 701 + phy_modes(state->interface)); 702 + return -EINVAL; 703 + } 704 + 694 705 /* Validate the link parameters with the PCS */ 695 706 if (pcs->ops->pcs_validate) { 696 707 ret = pcs->ops->pcs_validate(pcs, supported, state);
-1
include/linux/pcs/pcs-xpcs.h
··· 50 50 51 51 struct phylink_pcs *xpcs_to_phylink_pcs(struct dw_xpcs *xpcs); 52 52 int xpcs_get_an_mode(struct dw_xpcs *xpcs, phy_interface_t interface); 53 - void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces); 54 53 int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, 55 54 int enable); 56 55 struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr);
+3
include/linux/phylink.h
··· 393 393 394 394 /** 395 395 * struct phylink_pcs - PHYLINK PCS instance 396 + * @supported_interfaces: describing which PHY_INTERFACE_MODE_xxx 397 + * are supported by this PCS. 396 398 * @ops: a pointer to the &struct phylink_pcs_ops structure 397 399 * @phylink: pointer to &struct phylink_config 398 400 * @neg_mode: provide PCS neg mode via "mode" argument ··· 411 409 * the PCS driver. 412 410 */ 413 411 struct phylink_pcs { 412 + DECLARE_PHY_INTERFACE_MASK(supported_interfaces); 414 413 const struct phylink_pcs_ops *ops; 415 414 struct phylink *phylink; 416 415 bool neg_mode;