kernel: 5.15: backport v6.1 PHY changes required for Aquantia
[openwrt/staging/dangole.git] / target / linux / generic / backport-5.15 / 731-v6.1-0003-net-phy-Add-1000BASE-KX-interface-mode.patch
1 From 05ad5d4581c3c1cc724fe50d4652833fb9f3037b Mon Sep 17 00:00:00 2001
2 From: Sean Anderson <sean.anderson@seco.com>
3 Date: Fri, 2 Sep 2022 18:02:39 -0400
4 Subject: [PATCH] net: phy: Add 1000BASE-KX interface mode
5
6 Add 1000BASE-KX interface mode. This 1G backplane ethernet as described in
7 clause 70. Clause 73 autonegotiation is mandatory, and only full duplex
8 operation is supported.
9
10 Although at the PMA level this interface mode is identical to
11 1000BASE-X, it uses a different form of in-band autonegation. This
12 justifies a separate interface mode, since the interface mode (along
13 with the MLO_AN_* autonegotiation mode) sets the type of autonegotiation
14 which will be used on a link. This results in more than just electrical
15 differences between the link modes.
16
17 With regard to 1000BASE-X, 1000BASE-KX holds a similar position to
18 SGMII: same signaling, but different autonegotiation. PCS drivers
19 (which typically handle in-band autonegotiation) may only support
20 1000BASE-X, and not 1000BASE-KX. Similarly, the phy mode is used to
21 configure serdes phys with phy_set_mode_ext. Due to the different
22 electrical standards (SFI or XFI vs Clause 70), they will likely want to
23 use different configuration. Adding a phy interface mode for
24 1000BASE-KX helps simplify configuration in these areas.
25
26 Signed-off-by: Sean Anderson <sean.anderson@seco.com>
27 Signed-off-by: David S. Miller <davem@davemloft.net>
28 ---
29 Documentation/networking/phy.rst | 6 ++++++
30 drivers/net/phy/phy-core.c | 1 +
31 drivers/net/phy/phylink.c | 1 +
32 include/linux/phy.h | 4 ++++
33 4 files changed, 12 insertions(+)
34
35 --- a/Documentation/networking/phy.rst
36 +++ b/Documentation/networking/phy.rst
37 @@ -312,6 +312,12 @@ Some of the interface modes are describe
38 PTP-enabled PHYs. This mode isn't compatible with QSGMII, but offers the
39 same capabilities in terms of link speed and negociation.
40
41 +``PHY_INTERFACE_MODE_1000BASEKX``
42 + This is 1000BASE-X as defined by IEEE 802.3 Clause 36 with Clause 73
43 + autonegotiation. Generally, it will be used with a Clause 70 PMD. To
44 + contrast with the 1000BASE-X phy mode used for Clause 38 and 39 PMDs, this
45 + interface mode has different autonegotiation and only supports full duplex.
46 +
47 Pause frames / flow control
48 ===========================
49
50 --- a/drivers/net/phy/phy-core.c
51 +++ b/drivers/net/phy/phy-core.c
52 @@ -114,6 +114,7 @@ int phy_interface_num_ports(phy_interfac
53 case PHY_INTERFACE_MODE_100BASEX:
54 case PHY_INTERFACE_MODE_RXAUI:
55 case PHY_INTERFACE_MODE_XAUI:
56 + case PHY_INTERFACE_MODE_1000BASEKX:
57 return 1;
58 case PHY_INTERFACE_MODE_QSGMII:
59 case PHY_INTERFACE_MODE_QUSGMII:
60 --- a/drivers/net/phy/phylink.c
61 +++ b/drivers/net/phy/phylink.c
62 @@ -390,6 +390,7 @@ void phylink_get_linkmodes(unsigned long
63 case PHY_INTERFACE_MODE_1000BASEX:
64 caps |= MAC_1000HD;
65 fallthrough;
66 + case PHY_INTERFACE_MODE_1000BASEKX:
67 case PHY_INTERFACE_MODE_TRGMII:
68 caps |= MAC_1000FD;
69 break;
70 --- a/include/linux/phy.h
71 +++ b/include/linux/phy.h
72 @@ -116,6 +116,7 @@ extern const int phy_10gbit_features_arr
73 * @PHY_INTERFACE_MODE_USXGMII: Universal Serial 10GE MII
74 * @PHY_INTERFACE_MODE_10GKR: 10GBASE-KR - with Clause 73 AN
75 * @PHY_INTERFACE_MODE_QUSGMII: Quad Universal SGMII
76 + * @PHY_INTERFACE_MODE_1000BASEKX: 1000Base-KX - with Clause 73 AN
77 * @PHY_INTERFACE_MODE_MAX: Book keeping
78 *
79 * Describes the interface between the MAC and PHY.
80 @@ -154,6 +155,7 @@ typedef enum {
81 /* 10GBASE-KR - with Clause 73 AN */
82 PHY_INTERFACE_MODE_10GKR,
83 PHY_INTERFACE_MODE_QUSGMII,
84 + PHY_INTERFACE_MODE_1000BASEKX,
85 PHY_INTERFACE_MODE_MAX,
86 } phy_interface_t;
87
88 @@ -251,6 +253,8 @@ static inline const char *phy_modes(phy_
89 return "trgmii";
90 case PHY_INTERFACE_MODE_1000BASEX:
91 return "1000base-x";
92 + case PHY_INTERFACE_MODE_1000BASEKX:
93 + return "1000base-kx";
94 case PHY_INTERFACE_MODE_2500BASEX:
95 return "2500base-x";
96 case PHY_INTERFACE_MODE_5GBASER: