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

net: pcs: xpcs: update PCS driver to use neg_mode

Update xpcs to use neg_mode to configure whether inband negotiation
should be used. We need to update sja1105 as well as that directly
calls into the XPCS driver's config function.

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

authored by

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

+31 -30
+6 -8
drivers/net/dsa/sja1105/sja1105_main.c
··· 2314 2314 2315 2315 for (i = 0; i < ds->num_ports; i++) { 2316 2316 struct dw_xpcs *xpcs = priv->xpcs[i]; 2317 - unsigned int mode; 2317 + unsigned int neg_mode; 2318 2318 2319 2319 rc = sja1105_adjust_port_config(priv, i, speed_mbps[i]); 2320 2320 if (rc < 0) ··· 2324 2324 continue; 2325 2325 2326 2326 if (bmcr[i] & BMCR_ANENABLE) 2327 - mode = MLO_AN_INBAND; 2328 - else if (priv->fixed_link[i]) 2329 - mode = MLO_AN_FIXED; 2327 + neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED; 2330 2328 else 2331 - mode = MLO_AN_PHY; 2329 + neg_mode = PHYLINK_PCS_NEG_OUTBAND; 2332 2330 2333 - rc = xpcs_do_config(xpcs, priv->phy_mode[i], mode, NULL); 2331 + rc = xpcs_do_config(xpcs, priv->phy_mode[i], NULL, neg_mode); 2334 2332 if (rc < 0) 2335 2333 goto out; 2336 2334 2337 - if (!phylink_autoneg_inband(mode)) { 2335 + if (neg_mode == PHYLINK_PCS_NEG_OUTBAND) { 2338 2336 int speed = SPEED_UNKNOWN; 2339 2337 2340 2338 if (priv->phy_mode[i] == PHY_INTERFACE_MODE_2500BASEX) ··· 2344 2346 else 2345 2347 speed = SPEED_10; 2346 2348 2347 - xpcs_link_up(&xpcs->pcs, mode, priv->phy_mode[i], 2349 + xpcs_link_up(&xpcs->pcs, neg_mode, priv->phy_mode[i], 2348 2350 speed, DUPLEX_FULL); 2349 2351 } 2350 2352 }
+23 -20
drivers/net/pcs/pcs-xpcs.c
··· 657 657 } 658 658 EXPORT_SYMBOL_GPL(xpcs_config_eee); 659 659 660 - static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, unsigned int mode) 660 + static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, 661 + unsigned int neg_mode) 661 662 { 662 663 int ret, mdio_ctrl; 663 664 ··· 708 707 if (ret < 0) 709 708 return ret; 710 709 711 - if (phylink_autoneg_inband(mode)) 710 + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) 712 711 ret |= DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW; 713 712 else 714 713 ret &= ~DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW; ··· 717 716 if (ret < 0) 718 717 return ret; 719 718 720 - if (phylink_autoneg_inband(mode)) 719 + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) 721 720 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL, 722 721 mdio_ctrl | AN_CL37_EN); 723 722 724 723 return ret; 725 724 } 726 725 727 - static int xpcs_config_aneg_c37_1000basex(struct dw_xpcs *xpcs, unsigned int mode, 726 + static int xpcs_config_aneg_c37_1000basex(struct dw_xpcs *xpcs, 727 + unsigned int neg_mode, 728 728 const unsigned long *advertising) 729 729 { 730 730 phy_interface_t interface = PHY_INTERFACE_MODE_1000BASEX; ··· 776 774 if (ret < 0) 777 775 return ret; 778 776 779 - if (phylink_autoneg_inband(mode) && 780 - linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, advertising)) { 777 + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) { 781 778 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL, 782 779 mdio_ctrl | AN_CL37_EN); 783 780 if (ret < 0) ··· 809 808 } 810 809 811 810 int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, 812 - unsigned int mode, const unsigned long *advertising) 811 + const unsigned long *advertising, unsigned int neg_mode) 813 812 { 814 813 const struct xpcs_compat *compat; 815 814 int ret; ··· 822 821 case DW_10GBASER: 823 822 break; 824 823 case DW_AN_C73: 825 - if (test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, advertising)) { 824 + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) { 826 825 ret = xpcs_config_aneg_c73(xpcs, compat); 827 826 if (ret) 828 827 return ret; 829 828 } 830 829 break; 831 830 case DW_AN_C37_SGMII: 832 - ret = xpcs_config_aneg_c37_sgmii(xpcs, mode); 831 + ret = xpcs_config_aneg_c37_sgmii(xpcs, neg_mode); 833 832 if (ret) 834 833 return ret; 835 834 break; 836 835 case DW_AN_C37_1000BASEX: 837 - ret = xpcs_config_aneg_c37_1000basex(xpcs, mode, 836 + ret = xpcs_config_aneg_c37_1000basex(xpcs, neg_mode, 838 837 advertising); 839 838 if (ret) 840 839 return ret; ··· 858 857 } 859 858 EXPORT_SYMBOL_GPL(xpcs_do_config); 860 859 861 - static int xpcs_config(struct phylink_pcs *pcs, unsigned int mode, 860 + static int xpcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, 862 861 phy_interface_t interface, 863 862 const unsigned long *advertising, 864 863 bool permit_pause_to_mac) 865 864 { 866 865 struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); 867 866 868 - return xpcs_do_config(xpcs, interface, mode, advertising); 867 + return xpcs_do_config(xpcs, interface, advertising, neg_mode); 869 868 } 870 869 871 870 static int xpcs_get_state_c73(struct dw_xpcs *xpcs, ··· 899 898 900 899 state->link = 0; 901 900 902 - return xpcs_do_config(xpcs, state->interface, MLO_AN_INBAND, NULL); 901 + return xpcs_do_config(xpcs, state->interface, NULL, 902 + PHYLINK_PCS_NEG_INBAND_ENABLED); 903 903 } 904 904 905 905 /* There is no point doing anything else if the link is down. */ ··· 1048 1046 } 1049 1047 } 1050 1048 1051 - static void xpcs_link_up_sgmii(struct dw_xpcs *xpcs, unsigned int mode, 1049 + static void xpcs_link_up_sgmii(struct dw_xpcs *xpcs, unsigned int neg_mode, 1052 1050 int speed, int duplex) 1053 1051 { 1054 1052 int val, ret; 1055 1053 1056 - if (phylink_autoneg_inband(mode)) 1054 + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) 1057 1055 return; 1058 1056 1059 1057 val = mii_bmcr_encode_fixed(speed, duplex); ··· 1062 1060 pr_err("%s: xpcs_write returned %pe\n", __func__, ERR_PTR(ret)); 1063 1061 } 1064 1062 1065 - static void xpcs_link_up_1000basex(struct dw_xpcs *xpcs, unsigned int mode, 1063 + static void xpcs_link_up_1000basex(struct dw_xpcs *xpcs, unsigned int neg_mode, 1066 1064 int speed, int duplex) 1067 1065 { 1068 1066 int val, ret; 1069 1067 1070 - if (phylink_autoneg_inband(mode)) 1068 + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) 1071 1069 return; 1072 1070 1073 1071 switch (speed) { ··· 1091 1089 pr_err("%s: xpcs_write returned %pe\n", __func__, ERR_PTR(ret)); 1092 1090 } 1093 1091 1094 - void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode, 1092 + void xpcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode, 1095 1093 phy_interface_t interface, int speed, int duplex) 1096 1094 { 1097 1095 struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); ··· 1099 1097 if (interface == PHY_INTERFACE_MODE_USXGMII) 1100 1098 return xpcs_config_usxgmii(xpcs, speed); 1101 1099 if (interface == PHY_INTERFACE_MODE_SGMII) 1102 - return xpcs_link_up_sgmii(xpcs, mode, speed, duplex); 1100 + return xpcs_link_up_sgmii(xpcs, neg_mode, speed, duplex); 1103 1101 if (interface == PHY_INTERFACE_MODE_1000BASEX) 1104 - return xpcs_link_up_1000basex(xpcs, mode, speed, duplex); 1102 + return xpcs_link_up_1000basex(xpcs, neg_mode, speed, duplex); 1105 1103 } 1106 1104 EXPORT_SYMBOL_GPL(xpcs_link_up); 1107 1105 ··· 1285 1283 } 1286 1284 1287 1285 xpcs->pcs.ops = &xpcs_phylink_ops; 1286 + xpcs->pcs.neg_mode = true; 1288 1287 if (compat->an_mode == DW_10GBASER) 1289 1288 return xpcs; 1290 1289
+2 -2
include/linux/pcs/pcs-xpcs.h
··· 29 29 }; 30 30 31 31 int xpcs_get_an_mode(struct dw_xpcs *xpcs, phy_interface_t interface); 32 - void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode, 32 + void xpcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode, 33 33 phy_interface_t interface, int speed, int duplex); 34 34 int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, 35 - unsigned int mode, const unsigned long *advertising); 35 + const unsigned long *advertising, unsigned int neg_mode); 36 36 void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces); 37 37 int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, 38 38 int enable);