drivers/net/dsa/mxl862xx/mxl862xx-phylink.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/mxl862xx/mxl862xx-phylink.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/mxl862xx/mxl862xx-phylink.c- Extension
.c- Size
- 13665 bytes
- Lines
- 447
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/mutex.hlinux/phylink.hnet/dsa.hmxl862xx.hmxl862xx-api.hmxl862xx-cmd.hmxl862xx-host.hmxl862xx-phylink.h
Detected Declarations
function Copyrightfunction mxl862xx_xpcs_if_modefunction mxl862xx_xpcs_neg_modefunction mxl862xx_pcs_enablefunction mxl862xx_pcs_disablefunction mxl862xx_xpcs_errnofunction mxl862xx_pcs_configfunction mxl862xx_pcs_get_statefunction mxl862xx_pcs_an_restartfunction mxl862xx_pcs_link_upfunction mxl862xx_pcs_inband_capsfunction mxl862xx_setup_pcsfunction mxl862xx_phylink_mac_select_pcsfunction mxl862xx_phylink_mac_config
Annotated Snippet
if (state->link) {
state->speed = SPEED_10000;
state->duplex = DUPLEX_FULL;
}
break;
default:
state->link = false;
break;
}
}
static void mxl862xx_pcs_an_restart(struct phylink_pcs *pcs)
{
struct mxl862xx_pcs *mpcs = pcs_to_mxl862xx_pcs(pcs);
struct mxl862xx_priv *priv = mpcs->priv;
struct mxl862xx_xpcs_an_restart an = {};
int if_mode, lane;
if_mode = mxl862xx_xpcs_if_mode(mpcs->interface);
if (if_mode < 0)
return;
lane = (mpcs->interface == PHY_INTERFACE_MODE_10G_QXGMII) ?
MXL862XX_XPCS_USX_QUAD : MXL862XX_XPCS_USX_SINGLE;
an.mode = cpu_to_le16(FIELD_PREP(MXL862XX_XPCS_ANR_PORT_ID,
mpcs->serdes_id) |
FIELD_PREP(MXL862XX_XPCS_ANR_INTERFACE, if_mode) |
FIELD_PREP(MXL862XX_XPCS_ANR_USX_SUBPORT,
mpcs->slot) |
FIELD_PREP(MXL862XX_XPCS_ANR_USX_LANE_MODE, lane));
MXL862XX_API_WRITE(priv, MXL862XX_XPCS_AN_RESTART, an);
}
static void mxl862xx_pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode,
phy_interface_t interface, int speed,
int duplex)
{
struct mxl862xx_pcs *mpcs = pcs_to_mxl862xx_pcs(pcs);
struct mxl862xx_xpcs_pcs_link_up lu = {};
struct mxl862xx_priv *priv = mpcs->priv;
int if_mode, lane, dup;
/* With inband-AN enabled (role=MAC), the XPCS auto-resolves
* speed/duplex from the partner's AN word and the firmware
* short-circuits link_up. Skip the firmware round-trip, same
* as pcs-mtk-lynxi.
*/
if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED)
return;
if_mode = mxl862xx_xpcs_if_mode(interface);
if (if_mode < 0)
return;
lane = (interface == PHY_INTERFACE_MODE_10G_QXGMII) ?
MXL862XX_XPCS_USX_QUAD : MXL862XX_XPCS_USX_SINGLE;
dup = (duplex == DUPLEX_FULL) ? MXL862XX_XPCS_DUPLEX_FULL :
MXL862XX_XPCS_DUPLEX_HALF;
lu.mode = cpu_to_le16(FIELD_PREP(MXL862XX_XPCS_LU_PORT_ID,
mpcs->serdes_id) |
FIELD_PREP(MXL862XX_XPCS_LU_INTERFACE, if_mode) |
FIELD_PREP(MXL862XX_XPCS_LU_USX_SUBPORT,
mpcs->slot) |
FIELD_PREP(MXL862XX_XPCS_LU_USX_LANE_MODE, lane) |
FIELD_PREP(MXL862XX_XPCS_LU_DUPLEX, dup));
lu.speed = cpu_to_le16(speed);
MXL862XX_API_WRITE(priv, MXL862XX_XPCS_PCS_LINK_UP, lu);
}
static unsigned int mxl862xx_pcs_inband_caps(struct phylink_pcs *pcs,
phy_interface_t interface)
{
switch (interface) {
case PHY_INTERFACE_MODE_SGMII:
case PHY_INTERFACE_MODE_QSGMII:
case PHY_INTERFACE_MODE_1000BASEX:
case PHY_INTERFACE_MODE_2500BASEX:
return LINK_INBAND_DISABLE | LINK_INBAND_ENABLE;
case PHY_INTERFACE_MODE_USXGMII:
case PHY_INTERFACE_MODE_10G_QXGMII:
case PHY_INTERFACE_MODE_10GKR:
return LINK_INBAND_ENABLE;
case PHY_INTERFACE_MODE_10GBASER:
return LINK_INBAND_DISABLE;
default:
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/mutex.h`, `linux/phylink.h`, `net/dsa.h`, `mxl862xx.h`, `mxl862xx-api.h`, `mxl862xx-cmd.h`, `mxl862xx-host.h`.
- Detected declarations: `function Copyright`, `function mxl862xx_xpcs_if_mode`, `function mxl862xx_xpcs_neg_mode`, `function mxl862xx_pcs_enable`, `function mxl862xx_pcs_disable`, `function mxl862xx_xpcs_errno`, `function mxl862xx_pcs_config`, `function mxl862xx_pcs_get_state`, `function mxl862xx_pcs_an_restart`, `function mxl862xx_pcs_link_up`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.