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

net: phylink: pass neg_mode into phylink_mii_c22_pcs_config()

Convert fman_dtsec, xilinx_axienet and pcs-lynx to pass the neg_mode
into phylink_mii_c22_pcs_config(). Where appropriate, drivers are
updated to have neg_mode passed into their pcs_config() and
pcs_link_up() functions. For other drivers, we just hoist the call
to phylink_pcs_neg_mode() to their pcs_config() method out of
phylink_mii_c22_pcs_config().

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/E1qA8Do-00EaFM-Ra@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Russell King (Oracle) and committed by
Jakub Kicinski
febf2aaf cdb08aa0

+27 -18
+4 -3
drivers/net/ethernet/freescale/fman/fman_dtsec.c
··· 763 763 phylink_mii_c22_pcs_get_state(dtsec->tbidev, state); 764 764 } 765 765 766 - static int dtsec_pcs_config(struct phylink_pcs *pcs, unsigned int mode, 766 + static int dtsec_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, 767 767 phy_interface_t interface, 768 768 const unsigned long *advertising, 769 769 bool permit_pause_to_mac) 770 770 { 771 771 struct fman_mac *dtsec = pcs_to_dtsec(pcs); 772 772 773 - return phylink_mii_c22_pcs_config(dtsec->tbidev, mode, interface, 774 - advertising); 773 + return phylink_mii_c22_pcs_config(dtsec->tbidev, interface, 774 + advertising, neg_mode); 775 775 } 776 776 777 777 static void dtsec_pcs_an_restart(struct phylink_pcs *pcs) ··· 1447 1447 goto _return_fm_mac_free; 1448 1448 } 1449 1449 dtsec->pcs.ops = &dtsec_pcs_ops; 1450 + dtsec->pcs.neg_mode = true; 1450 1451 dtsec->pcs.poll = true; 1451 1452 1452 1453 supported = mac_dev->phylink_config.supported_interfaces;
+4 -2
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
··· 1631 1631 phylink_mii_c22_pcs_an_restart(pcs_phy); 1632 1632 } 1633 1633 1634 - static int axienet_pcs_config(struct phylink_pcs *pcs, unsigned int mode, 1634 + static int axienet_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, 1635 1635 phy_interface_t interface, 1636 1636 const unsigned long *advertising, 1637 1637 bool permit_pause_to_mac) ··· 1653 1653 } 1654 1654 } 1655 1655 1656 - ret = phylink_mii_c22_pcs_config(pcs_phy, mode, interface, advertising); 1656 + ret = phylink_mii_c22_pcs_config(pcs_phy, interface, advertising, 1657 + neg_mode); 1657 1658 if (ret < 0) 1658 1659 netdev_warn(ndev, "Failed to configure PCS: %d\n", ret); 1659 1660 ··· 2130 2129 } 2131 2130 of_node_put(np); 2132 2131 lp->pcs.ops = &axienet_pcs_ops; 2132 + lp->pcs.neg_mode = true; 2133 2133 lp->pcs.poll = true; 2134 2134 } 2135 2135
+12 -6
drivers/net/pcs/pcs-lynx.c
··· 112 112 state->link, state->an_complete); 113 113 } 114 114 115 - static int lynx_pcs_config_giga(struct mdio_device *pcs, unsigned int mode, 115 + static int lynx_pcs_config_giga(struct mdio_device *pcs, 116 116 phy_interface_t interface, 117 - const unsigned long *advertising) 117 + const unsigned long *advertising, 118 + unsigned int neg_mode) 118 119 { 119 120 int link_timer_ns; 120 121 u32 link_timer; ··· 133 132 if (interface == PHY_INTERFACE_MODE_1000BASEX) { 134 133 if_mode = 0; 135 134 } else { 135 + /* SGMII and QSGMII */ 136 136 if_mode = IF_MODE_SGMII_EN; 137 - if (mode == MLO_AN_INBAND) 137 + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) 138 138 if_mode |= IF_MODE_USE_SGMII_AN; 139 139 } 140 140 ··· 145 143 if (err) 146 144 return err; 147 145 148 - return phylink_mii_c22_pcs_config(pcs, mode, interface, advertising); 146 + return phylink_mii_c22_pcs_config(pcs, interface, advertising, 147 + neg_mode); 149 148 } 150 149 151 150 static int lynx_pcs_config_usxgmii(struct mdio_device *pcs, unsigned int mode, ··· 173 170 bool permit) 174 171 { 175 172 struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); 173 + unsigned int neg_mode; 174 + 175 + neg_mode = phylink_pcs_neg_mode(mode, ifmode, advertising); 176 176 177 177 switch (ifmode) { 178 178 case PHY_INTERFACE_MODE_1000BASEX: 179 179 case PHY_INTERFACE_MODE_SGMII: 180 180 case PHY_INTERFACE_MODE_QSGMII: 181 - return lynx_pcs_config_giga(lynx->mdio, mode, ifmode, 182 - advertising); 181 + return lynx_pcs_config_giga(lynx->mdio, ifmode, advertising, 182 + neg_mode); 183 183 case PHY_INTERFACE_MODE_2500BASEX: 184 184 if (phylink_autoneg_inband(mode)) { 185 185 dev_err(&lynx->mdio->dev,
+4 -5
drivers/net/phy/phylink.c
··· 3545 3545 /** 3546 3546 * phylink_mii_c22_pcs_config() - configure clause 22 PCS 3547 3547 * @pcs: a pointer to a &struct mdio_device. 3548 - * @mode: link autonegotiation mode 3549 3548 * @interface: the PHY interface mode being configured 3550 3549 * @advertising: the ethtool advertisement mask 3550 + * @neg_mode: PCS negotiation mode 3551 3551 * 3552 3552 * Configure a Clause 22 PCS PHY with the appropriate negotiation 3553 3553 * parameters for the @mode, @interface and @advertising parameters. 3554 3554 * Returns negative error number on failure, zero if the advertisement 3555 3555 * has not changed, or positive if there is a change. 3556 3556 */ 3557 - int phylink_mii_c22_pcs_config(struct mdio_device *pcs, unsigned int mode, 3557 + int phylink_mii_c22_pcs_config(struct mdio_device *pcs, 3558 3558 phy_interface_t interface, 3559 - const unsigned long *advertising) 3559 + const unsigned long *advertising, 3560 + unsigned int neg_mode) 3560 3561 { 3561 - unsigned int neg_mode; 3562 3562 bool changed = 0; 3563 3563 u16 bmcr; 3564 3564 int ret, adv; ··· 3572 3572 changed = ret; 3573 3573 } 3574 3574 3575 - neg_mode = phylink_pcs_neg_mode(mode, interface, advertising); 3576 3575 if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) 3577 3576 bmcr = BMCR_ANENABLE; 3578 3577 else
+3 -2
include/linux/phylink.h
··· 743 743 struct phylink_link_state *state); 744 744 int phylink_mii_c22_pcs_encode_advertisement(phy_interface_t interface, 745 745 const unsigned long *advertising); 746 - int phylink_mii_c22_pcs_config(struct mdio_device *pcs, unsigned int mode, 746 + int phylink_mii_c22_pcs_config(struct mdio_device *pcs, 747 747 phy_interface_t interface, 748 - const unsigned long *advertising); 748 + const unsigned long *advertising, 749 + unsigned int neg_mode); 749 750 void phylink_mii_c22_pcs_an_restart(struct mdio_device *pcs); 750 751 751 752 void phylink_resolve_c73(struct phylink_link_state *state);