Issue
I have a doubt about Ethernet MAC and PHY initializition process.Provided the auto-negotiation is enabled and the physical net is linked up between two PHYs,then these two PHYs will process auto-negotiation to fit best opreaion mode(speed and duplex mode).After auto-negotiation is down, the PHY will write an interrupt into self register which results into a interrupt to MAC.The MAC transfer the interrupt to software and software needs to set MAC opreaion mode after read PHY registers by MDIO bus.But in the time window started from negotiation down to software set MAC down, if there is packet received by PHY in RX channel, the PHY will send this frame to MAC right? So my question is,before the MAC is set to proper state, the MAC will drop the frame received from MII bus because the RECEIVE ENABLE bit is set to low after reset?
I try to read linux driver code ./linux-master/drivers/net/ethernet/stmicro but I am not familiar with driver code or C/C++ so I try to ask this question on stackoverflow. I see in the procedure of PHY init is a part of MAC open,"ret = stmmac_hw_setup(dev, true);" the hw setup is after PHY link up.
Solution
Your question is quite technical and specific, but I’ll do my best to provide a helpful response based on the information available.
The Ethernet PHY (Physical Layer) and MAC (Media Access Control) work together to handle Ethernet frames. The PHY is responsible for the physical signaling to the Ethernet cable, while the MAC handles the data link layer which includes frame assembly/disassembly and error checking.
Here this Application Report can help you: Application Report
When the PHY is linked up after auto-negotiation, it indeed sends an interrupt to the MAC. The MAC then transfers this interrupt to the software, which reads the PHY registers via the MDIO (Management Data Input/Output) bus to set the MAC operation mode.
If a packet is received by the PHY in the RX (Receive) channel during the time window from negotiation completion to MAC setup, the PHY will indeed send this frame to the MAC. However, if the MAC is not yet in the proper state (i.e., the RECEIVE ENABLE bit is set to low after reset), the MAC will not process the frame. This is because the MAC is not yet ready to receive frames.
This can help: 802.11/DMA
In the Linux driver code you mentioned, the stmmac_hw_setup(dev, true);
function is part of the MAC initialization process. This function is responsible for setting up the hardware, including the MAC, after the PHY link is up. If a frame is received before this function is called and the MAC is set up, the frame would likely be dropped.
This can help: Ethernet Controllers "stmmac"
Please note that this is a high-level explanation and the exact behavior can depend on the specific Ethernet controller and driver implementation.
Answered By - João Gervas Answer Checked By - Robin (WPSolving Admin)