A race condition in the MII layer causes spurious link down events, see:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252165
. In statchg, on link down, check if the PHY reports the link as
actually down using the BMSR register, if not, force the status of the
link to back up and restart TX. Do the same in a MII linkchg handler.
On actual link up, restart TX in case it went idle and down.
I have tested this patch with a Realtek 8153 USB interface, and it fixes
the link flaps.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>