Originally authored by Tim Pletcher <bugs@pletch.org>, with my additions
The EEE sysctl calls if_init() with an ifnet where iflib expects its context. On an E610-XT2, writing eee_state can therefore block indefinitely in sx_xlock() and corrupt if_broadcastaddr, causing broadcasts to use the wrong destination address. Cache the requested policy under the iflib context lock and request a reset through the admin task if the interface is still administratively up. Recheck the setting after copying in the sysctl value so concurrent writers do not act on stale state. Identical writes remain no-ops. Replay EEE after hardware reset and PHY power-up, before enabling queues. This also applies settings saved while down or suspended. Log EEE replay failures and retain the requested policy for subsequent initialization. On E610, skip Set PHY Config when the active EEE mask already matches, avoiding unnecessary link restarts during unrelated initialization. Allow bounded retries of Set PHY Config only on an explicit firmware busy response, including when the preceding PHY power-up is still completing. Document the requested-setting readback, asynchronous application, retry behavior, and recovery-mode restrictions. PR: 300670 MFC after: 1 week Sponsored by: BBOX.io Co-authored-by: Kevin Bowling <kbowling@FreeBSD.org>