Table of Contents of Series Articles
Ethernet (1) Introduction to MAC, MII, and PHY [ link ]
Article directory
In " Ethernet (1) Introduction to MAC, MII, and PHY ", MAC, PHY and MII are introduced. This article briefly introduces the relationship between PHY, network card and SWITCH.
- MAC: It can be understood as the data link layer.
- PHY: A pure physical layer chip, simply understood as a physical layer connection component, responsible for data conversion.
- Control interface: data interface, namely RGMII/GMII/MII, MDC/DMIO/I2C/SPI.
- Network card: It can be understood as a chip composed of PHY and MAC, which can be directly connected to the CPU through various interfaces.
- SWITCH: Multi-network port device, the internal structure is MAC+PHY, and its main function is to forward data between different ports. There will also be a data interface left to connect with SOC and other equipment.
1 Introduction to switch and gmac work
As shown in the figure below, only the GMAC network card is registered as eth0. In order to realize the WAN-LAN function, two virtual network cards, eth0.1 and eth0.2, are divided into eth0 and used as LAN and WAN respectively. When receiving, GMAC receives the data packet with the vlan header and sends it. The system will distinguish LAN and WAN according to the different vlan IDs in the data packet. The data packet of vlan 1 will strip the vlan header and send it to the LAN, and the data packet of vlan 2 will be sent to the LAN. The data packet will strip the VLAN header and send it to the WAN. When sending, the ordinary data packets sent by the system will also carry the vlan tag after passing through the virtual network cards eth0.1 and eth0.2, and are sent to the CPU port of the switch.
Therefore, the switch configuration also needs to correspond to the virtual network card division, and configure vlan and port binding, so that when input, the input data of different ports will be marked with the corresponding vlan tag, and the system can distinguish WAN and LAN. When outputting, the corresponding port will strip the vlan tag, so that normal WAN-LAN communication can be achieved.
2 MAC, PHY, network card, SWITCH working diagram
MAC and PHY diagram:
The network card (NIC) contains MAC and PHY. The diagram is as follows:
Single PHY port: There is also a multi-port PHY application, but most of it is used on switches, so it will not be extended here. The schematic diagram is as follows:
SWITCH working diagram:
Reference article:
switch and PHY chip debugging and selection [ link ]
Network driver->PHY driver debugging[ link ]
phy driver and switch driver[ link ]