History

net: phylink: pcs: add 802.3 clause 45 helpers

Implement helpers for PCS accessed via the MII bus using 802.3 clause 45 cycles for 10GBASE-R. Only link up/down is supported, 10G full duplex is assumed.

Russell King committed 6 years ago

Commit b8679ef1 parent 74db1c12 files · +32 −0Browse files

Unified · Split

2 files
  1. drivers/net/phy/phylink.c +30 −0
  2. include/linux/phylink.h +2 −0
drivers/net/phy/phylink.c+30−0
@@ -2274,4 +2274,34 @@ void phylink_mii_c22_pcs_an_restart(struct mdio_device *pcs) · 2273 unmodified lines
22742274 }
22752275 EXPORT_SYMBOL_GPL(phylink_mii_c22_pcs_an_restart);
22762276
2277+#define C45_ADDR(d,a) (MII_ADDR_C45 | (d) << 16 | (a))
2278+void phylink_mii_c45_pcs_get_state(struct mdio_device *pcs,
2279+ struct phylink_link_state *state)
2280+{
2281+ struct mii_bus *bus = pcs->bus;
2282+ int addr = pcs->addr;
2283+ int stat;
2284+
2285+ stat = mdiobus_read(bus, addr, C45_ADDR(MDIO_MMD_PCS, MDIO_STAT1));
2286+ if (stat < 0) {
2287+ state->link = false;
2288+ return;
2289+ }
2290+
2291+ state->link = !!(stat & MDIO_STAT1_LSTATUS);
2292+ if (!state->link)
2293+ return;
2294+
2295+ switch (state->interface) {
2296+ case PHY_INTERFACE_MODE_10GBASER:
2297+ state->speed = SPEED_10000;
2298+ state->duplex = DUPLEX_FULL;
2299+ break;
2300+
2301+ default:
2302+ break;
2303+ }
2304+}
2305+EXPORT_SYMBOL_GPL(phylink_mii_c45_pcs_get_state);
2306+
22772307 MODULE_LICENSE("GPL v2");
include/linux/phylink.h+2−0
@@ -323,4 +323,6 @@ int phylink_mii_c22_pcs_set_advertisement(struct mdio_device *pcs, · 322 unmodified lines
323323 const struct phylink_link_state *state);
324324 void phylink_mii_c22_pcs_an_restart(struct mdio_device *pcs);
325325
326+void phylink_mii_c45_pcs_get_state(struct mdio_device *pcs,
327+ struct phylink_link_state *state);
326328 #endif