Add ETHTOOL_LINK_MODE_500baseT2_Full_BIT and SPEED_500 for 500 Mbps
over two pairs, together with the matching phylib link capability.
Signed-off-by: Hee-Suk Kim <hsk…@dilluti0n.com>
---
drivers/net/phy/phy-caps.h | 1 +
drivers/net/phy/phy-core.c | 4 +++-
drivers/net/phy/phy_caps.c | 7 +++++++
include/uapi/linux/ethtool.h | 2 ++
net/ethtool/common.c | 3 +++
5 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/phy-caps.h b/drivers/net/phy/phy-caps.h
index ec3d39a0ae06..0b39e0e7aca9 100644
--- a/drivers/net/phy/phy-caps.h
+++ b/drivers/net/phy/phy-caps.h
@@ -15,6 +15,7 @@ enum {
LINK_CAPA_10FD,
LINK_CAPA_100HD,
LINK_CAPA_100FD,
+ LINK_CAPA_500FD,
LINK_CAPA_1000HD,
LINK_CAPA_1000FD,
LINK_CAPA_2500FD,
diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
index d7a4a977fc8a..0c464e0d971e 100644
--- a/drivers/net/phy/phy-core.c
+++ b/drivers/net/phy/phy-core.c
@@ -18,7 +18,7 @@
*/
const char *phy_speed_to_str(int speed)
{
- BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS != 125,
+ BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS != 126,
"Enum ethtool_link_mode_bit_indices and phylib are out of sync. "
"If a speed or mode has been added please update phy_speed_to_str "
"and the PHY settings array.\n");
@@ -28,6 +28,8 @@ const char *phy_speed_to_str(int speed)
return "10Mbps";
case SPEED_100:
return "100Mbps";
+ case SPEED_500:
+ return "500Mbps";
case SPEED_1000:
return "1Gbps";
case SPEED_2500:
diff --git a/drivers/net/phy/phy_caps.c b/drivers/net/phy/phy_caps.c
index 558e4df4d63c..3112e9034566 100644
--- a/drivers/net/phy/phy_caps.c
+++ b/drivers/net/phy/phy_caps.c
@@ -11,6 +11,7 @@ static struct link_capabilities link_caps[__LINK_CAPA_MAX] __ro_after_init = {
{ SPEED_10, DUPLEX_FULL, {0} }, /* LINK_CAPA_10FD */
{ SPEED_100, DUPLEX_HALF, {0} }, /* LINK_CAPA_100HD */
{ SPEED_100, DUPLEX_FULL, {0} }, /* LINK_CAPA_100FD */
+ { SPEED_500, DUPLEX_FULL, {0} }, /* LINK_CAPA_500FD */
{ SPEED_1000, DUPLEX_HALF, {0} }, /* LINK_CAPA_1000HD */
{ SPEED_1000, DUPLEX_FULL, {0} }, /* LINK_CAPA_1000FD */
{ SPEED_2500, DUPLEX_FULL, {0} }, /* LINK_CAPA_2500FD */
@@ -40,6 +41,8 @@ static int speed_duplex_to_capa(int speed, unsigned int duplex)
LINK_CAPA_10FD : LINK_CAPA_10HD;
case SPEED_100: return duplex == DUPLEX_FULL ?
LINK_CAPA_100FD : LINK_CAPA_100HD;
+ case SPEED_500: return duplex == DUPLEX_FULL ?
+ LINK_CAPA_500FD : -EINVAL;
case SPEED_1000: return duplex == DUPLEX_FULL ?
LINK_CAPA_1000FD : LINK_CAPA_1000HD;
case SPEED_2500: return LINK_CAPA_2500FD;
@@ -295,6 +298,10 @@ unsigned long phy_caps_from_interface(phy_interface_t interface)
{
unsigned long link_caps = 0;
+ /* The only PHYs known to support 500baseT2 are attached over GMII */
+ if (interface == PHY_INTERFACE_MODE_GMII)
+ link_caps |= BIT(LINK_CAPA_500FD);
+
switch (interface) {
case PHY_INTERFACE_MODE_USXGMII:
link_caps |= BIT(LINK_CAPA_10000FD) | BIT(LINK_CAPA_5000FD);
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 9e60c17b48c8..aa978de7390a 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -2105,6 +2105,7 @@ enum ethtool_link_mode_bit_indices {
ETHTOOL_LINK_MODE_1600000baseKR8_Full_BIT = 122,
ETHTOOL_LINK_MODE_1600000baseDR8_Full_BIT = 123,
ETHTOOL_LINK_MODE_1600000baseDR8_2_Full_BIT = 124,
+ ETHTOOL_LINK_MODE_500baseT2_Full_BIT = 125,
/* must be last entry */
__ETHTOOL_LINK_MODE_MASK_NBITS
@@ -2204,6 +2205,7 @@ enum ethtool_link_mode_bit_indices {
*/
#define SPEED_10 10
#define SPEED_100 100
+#define SPEED_500 500
#define SPEED_1000 1000
#define SPEED_2500 2500
#define SPEED_5000 5000
diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index ec67fbd6bb86..f8fc67e1f3a2 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -242,6 +242,7 @@ const char link_mode_names[][ETH_GSTRING_LEN] = {
__DEFINE_LINK_MODE_NAME(1600000, KR8, Full),
__DEFINE_LINK_MODE_NAME(1600000, DR8, Full),
__DEFINE_LINK_MODE_NAME(1600000, DR8_2, Full),
+ __DEFINE_LINK_MODE_NAME(500, T2, Full),
};
static_assert(ARRAY_SIZE(link_mode_names) == __ETHTOOL_LINK_MODE_MASK_NBITS);
@@ -289,6 +290,7 @@ static_assert(ARRAY_SIZE(link_mode_names) == __ETHTOOL_LINK_MODE_MASK_NBITS);
#define __LINK_MODE_LANES_VR8 8
#define __LINK_MODE_LANES_DR8_2 8
#define __LINK_MODE_LANES_T1BRR 1
+#define __LINK_MODE_LANES_T2 1
#define __DEFINE_LINK_MODE_PARAMS_PAIRS(_speed, _type, _min_pairs, _pairs, _duplex, _medium) \
[ETHTOOL_LINK_MODE(_speed, _type, _duplex)] = { \
@@ -469,6 +471,7 @@ const struct link_mode_info link_mode_params[] = {
__DEFINE_LINK_MODE_PARAMS(1600000, KR8, Full, K),
__DEFINE_LINK_MODE_PARAMS(1600000, DR8, Full, D),
__DEFINE_LINK_MODE_PARAMS(1600000, DR8_2, Full, D),
+ __DEFINE_LINK_MODE_PARAMS_PAIRS(500, T2, 2, 2, Full, T),
};
static_assert(ARRAY_SIZE(link_mode_params) == __ETHTOOL_LINK_MODE_MASK_NBITS);
EXPORT_SYMBOL_GPL(link_mode_params);
--
2.56.1