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.

r8152: Add 2500baseT EEE status/configuration support

The r8152 driver supports the RTL8156, which is a 2.5Gbit Ethernet controller for
USB 3.0, for which support is added for configuring and displaying the EEE
advertisement status for 2.5GBit connections.

The patch also corrects the determination of whether EEE is active to include
the 2.5GBit connection status and make the determination dependent not on the
desired speed configuration (tp->speed), but on the actual speed used by
the controller. For consistency, this is corrected also for the RTL8152/3.

This was tested on an Edimax EU-4307 V1.0 USB-Ethernet adapter with RTL8156,
and a SECOMP Value 12.99.1115 USB-C 3.1 Ethernet converter with RTL8153.

Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
Link: https://patch.msgid.link/20260224-b4-eee2g5-v2-1-cf5c83df036e@birger-koblitz.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Birger Koblitz and committed by
Jakub Kicinski
e8e83b67 c31770c4

+42 -8
+42 -8
drivers/net/usb/r8152.c
··· 207 207 #define OCP_EEE_LPABLE 0xa5d2 208 208 #define OCP_10GBT_CTRL 0xa5d4 209 209 #define OCP_10GBT_STAT 0xa5d6 210 + #define OCP_EEE_LPABLE2 0xa6d0 210 211 #define OCP_EEE_ADV2 0xa6d4 211 212 #define OCP_PHY_STATE 0xa708 /* nway state for 8153 */ 212 213 #define OCP_PHY_PATCH_STAT 0xb800 ··· 949 948 u16 ocp_base; 950 949 u16 speed; 951 950 u16 eee_adv; 951 + u16 eee_adv2; 952 952 u8 *intr_buff; 953 953 u8 version; 954 954 u8 duplex; ··· 5395 5393 5396 5394 config = ocp_reg_read(tp, OCP_EEE_ADV2); 5397 5395 5398 - if (enable) 5396 + if (enable && (tp->eee_adv2 & MDIO_EEE_2_5GT)) 5399 5397 config |= MDIO_EEE_2_5GT; 5400 5398 else 5401 5399 config &= ~MDIO_EEE_2_5GT; ··· 8924 8922 8925 8923 static int r8152_get_eee(struct r8152 *tp, struct ethtool_keee *eee) 8926 8924 { 8927 - __ETHTOOL_DECLARE_LINK_MODE_MASK(common); 8925 + __ETHTOOL_DECLARE_LINK_MODE_MASK(common) = {}; 8926 + u16 speed = rtl8152_get_speed(tp); 8928 8927 u16 val; 8929 8928 8930 8929 val = r8152_mmd_read(tp, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE); ··· 8939 8936 8940 8937 eee->eee_enabled = tp->eee_en; 8941 8938 8942 - linkmode_and(common, eee->advertised, eee->lp_advertised); 8943 - eee->eee_active = phy_check_valid(tp->speed, tp->duplex, common); 8939 + if (speed & _1000bps) 8940 + linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, common); 8941 + if (speed & _100bps) 8942 + linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, common); 8943 + 8944 + linkmode_and(common, common, eee->advertised); 8945 + linkmode_and(common, common, eee->lp_advertised); 8946 + eee->eee_active = !linkmode_empty(common); 8944 8947 8945 8948 return 0; 8946 8949 } ··· 8957 8948 8958 8949 tp->eee_en = eee->eee_enabled; 8959 8950 tp->eee_adv = val; 8960 - 8951 + if (tp->support_2500full) { 8952 + val = linkmode_to_mii_eee_cap2_t(eee->advertised); 8953 + tp->eee_adv2 = val; 8954 + } 8961 8955 rtl_eee_enable(tp, tp->eee_en); 8962 8956 8963 8957 return 0; ··· 8968 8956 8969 8957 static int r8153_get_eee(struct r8152 *tp, struct ethtool_keee *eee) 8970 8958 { 8971 - __ETHTOOL_DECLARE_LINK_MODE_MASK(common); 8959 + __ETHTOOL_DECLARE_LINK_MODE_MASK(common) = {}; 8960 + u16 speed = rtl8152_get_speed(tp); 8972 8961 u16 val; 8973 8962 8974 8963 val = ocp_reg_read(tp, OCP_EEE_ABLE); ··· 8981 8968 val = ocp_reg_read(tp, OCP_EEE_LPABLE); 8982 8969 mii_eee_cap1_mod_linkmode_t(eee->lp_advertised, val); 8983 8970 8971 + if (tp->support_2500full) { 8972 + linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, eee->supported); 8973 + 8974 + val = ocp_reg_read(tp, OCP_EEE_ADV2); 8975 + mii_eee_cap2_mod_linkmode_adv_t(eee->advertised, val); 8976 + 8977 + val = ocp_reg_read(tp, OCP_EEE_LPABLE2); 8978 + mii_eee_cap2_mod_linkmode_adv_t(eee->lp_advertised, val); 8979 + 8980 + if (speed & _2500bps) 8981 + linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, common); 8982 + } 8983 + 8984 8984 eee->eee_enabled = tp->eee_en; 8985 8985 8986 - linkmode_and(common, eee->advertised, eee->lp_advertised); 8987 - eee->eee_active = phy_check_valid(tp->speed, tp->duplex, common); 8986 + if (speed & _1000bps) 8987 + linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, common); 8988 + if (speed & _100bps) 8989 + linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, common); 8990 + 8991 + linkmode_and(common, common, eee->advertised); 8992 + linkmode_and(common, common, eee->lp_advertised); 8993 + eee->eee_active = !linkmode_empty(common); 8988 8994 8989 8995 return 0; 8990 8996 } ··· 9544 9512 case RTL_VER_11: 9545 9513 tp->eee_en = true; 9546 9514 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; 9515 + tp->eee_adv2 = MDIO_EEE_2_5GT; 9547 9516 fallthrough; 9548 9517 case RTL_VER_10: 9549 9518 ops->init = r8156_init; ··· 9570 9537 case RTL_VER_15: 9571 9538 tp->eee_en = true; 9572 9539 tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; 9540 + tp->eee_adv2 = MDIO_EEE_2_5GT; 9573 9541 ops->init = r8156b_init; 9574 9542 ops->enable = rtl8156b_enable; 9575 9543 ops->disable = rtl8153_disable;