mac_config(9)
π mac_config(9) β the kernel API glow-up guide π
okay so bestie, welcome to mac_config(9), straight out of the Kernel API Manual. this is the function that configures the MAC for whatever mode and state you're rolling with, and yes you're gonna need to read all of it because the caveats are real π«Ά
β¨ SYNOPSIS β¨
void mac_config (struct phylink_config *config , unsigned int mode ,
const struct phylink_link_state *state );
literally just three things in, nothing out. void, no cap.
πΈ ARGUMENTS πΈ
configβ a pointer to astruct phylink_config. your config bestie πmodeβ one ofMLO_AN_FIXED,MLO_AN_PHY,MLO_AN_INBAND. pick your fighter β¨stateβ a pointer to astruct phylink_link_state. this one's got lore (see below)
π DESCRIPTION π
β οΈ note note note: not all members ofstateare valid!! in particular,state->lp_advertising,state->link, andstate->an_completeare never guaranteed to be correct. so anymac_configimplementation must never reference these fields. like, ever. i'm so serious π
okay so this function will only be called to reconfigure the MAC for a "major" change, like in interface mode. it will not be called for changes in speed, duplex, or pause modes, and it will not be called to change the in-band advertisement. so don't come here asking for little tweaks π
π¦ pause settings, explained
in all negotiation modes (as defined by mode), state->pause indicates the pause settings that should be applied, like this:
- if
MLO_PAUSE_ANis not set,MLO_PAUSE_TXandMLO_PAUSE_RXindicate whether the MAC should send pause frames and/or act on received pause frames, respectively. - otherwise, the results of in-band negotiation/status from the MAC PCS should be used to control the MAC pause mode settings. iykyk π
π the action depends on the currently selected mode
π MLO_AN_FIXED, MLO_AN_PHY
configure for non-inband negotiation mode, where the link settings are completely communicated via mac_link_up. the physical link protocol from the MAC is specified by state->interface β
state->advertising may be used, but is not required. (optional queen behavior)
older drivers (prior to the mac_link_up change) may use state->speed, state->duplex and state->pause to configure the MAC, but this is deprecated β such drivers should be converted to use mac_link_up. like, it's giving legacy, and not in a cute way π
other members of state must be ignored.
- valid state members:
interface,advertising - deprecated state members:
speed,duplex,pause
π§ MLO_AN_INBAND
place the link in an inband negotiation mode (such as 802.3z 1000base-X or Cisco SGMII mode, depending on the state->interface mode). in both cases, link state management (whether the link is up or not) is performed by the MAC, and reported via the pcs_get_state callback. changes in link state must be made by calling phylink_mac_change π₯
interface mode specific details are mentioned below π
if in 802.3z mode: the link speed is fixed, dependent on the state->interface. duplex and pause modes are negotiated via the in-band configuration word. advertised pause modes are set according to state->advertising. β οΈ beware of MACs which only support full duplex at gigabit and higher speeds. beware!! fr fr
if in Cisco SGMII mode: the link speed and duplex mode are passed in the serial bitstream 16-bit configuration word, and the MAC should be configured to read these bits and acknowledge the configuration word. nothing is advertised by the MAC. the MAC is responsible for reading the configuration word and configuring itself accordingly. main character energy, honestly π
- valid state members:
interface,pause,advertisingπ
π the update rule (this one matters)
implementations are expected to update the MAC to reflect the requested settings β i.o.w., if nothing has changed between two calls, no action is expected. if only flow control settings have changed, flow control should be updated without taking the link down. this "update" behaviour is critical to avoid bouncing the link up status. critical!!! do not bounce the link, bestie, that's so not slay π
π SEE ALSO π
- Kernel file
./include/linux/phylink.h struct phylink_link_state(9)struct phylink_config(9)struct phylink_mac_ops(9)mac_get_caps(9)mac_select_pcs(9)mac_prepare(9)mac_finish(9)mac_link_down(9)mac_link_up(9)mac_disable_tx_lpi(9)mac_enable_tx_lpi(9)mac_wol_set(9)struct phylink_pcs(9)struct phylink_pcs_ops(9)pcs_validate(9)pcs_inband_caps(9)pcs_enable(9)pcs_disable(9)pcs_get_state(9)pcs_config(9)pcs_an_restart(9)pcs_link_up(9)pcs_disable_eee(9)pcs_enable_eee(9)pcs_pre_init(9)phylink_get_link_timer_ns(9)phylink_mac_implements_lpi(9)
and that's the whole page, bestie π«Ά this edition lives in ./include/linux and it's dated October 2026 β so go forth, configure your MAC, and remember: never touch state->lp_advertising, state->link, or state->an_complete. periodt. π
β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms