From SEGGER Wiki
Jump to: navigation, search

PHY in short for physical and often used for an Ethernet physical transceiver is an IC that connects to a MAC unit to convert binary data into signals on the line. As PHYs do not exist for Ethernet and cable based networks alone, a PHY can also mean a transceiver for WiFi or other medium.

emNet support for PHYs

emNet supports supports virtually any single port PHY on the market as long as the PHY is compatible to the IEEE 802.3u standard. The emNet Generic PHY driver expects the first six PHY registers to be the following registers with their standardized bits according to IEEE 802.3u:

SMI register address Register short name Register full name
0x0 BMCR Basic Mode Control Register
0x1 BMSR Basic Mode Status Register
0x2 PHYIDR1 PHY ID Identifier Register #1
0x3 PHYIDR2 PHY ID Identifier Register #2
0x4 ANAR Auto-Negotiation Advertisement Register
0x5 ANLPAR Auto-Negotiation Link Partner Ability register

Other PHYs with different register layouts, requirements for special treatment or interfaces other than SMI are supported as well via the emNet PHY drivers interface API.

Link Up detection

A link up is detected by the PHY by either actively receiving data or by listening for idle data bits sent by each host on a network. The type of idle data sent differs based on the medium used and varies from sending link pulses (also called NLP for Normal Link Pulses) up to depending on the auto-negotiation advertisement being used as link up detection.

emNet polls the link status once directly after the NI driver init and from there on relies on a one second periodic poll executed by the IP_Task(). Apart from this periodic polling mechanism to make the stack aware of the link status, the link detection time depends entirely on the PHY itself. This can be tested by pausing the program execution after IP_Init() for a couple of seconds and when continuing the program the link gets immediately (in respect to the periodic timer) detected. If the execution is paused before the very first link check during the NI driver init it is even possible to get a link up immediately (of course this does not apply to a real application and is only mentioned for testing purposes).

PHY latency

When measuring response times like the answer to a PING, the latency by the PHY is usually included in the result. Ignoring this latency is typically fine for large(r) transmissions as it is only added once on top of the complete runtime for a full Ethernet packet of 1518 bytes for example. For a regular Fast-Ethernet of 100Mbit/s, one bit on the cable means a runtime of 10ns. The latency for a regular Fast-Ethernet PHY such as the Davicom DM9161A has been measured with approx. 235ns (Network performance measurement). The worse the ratio between PHY latency and packet runtime becomes, the less maximum throughput this results in.

Of course this might be irrelevant if there is an OS or network stack that introduces other processing delays but should be kept in mind in case a protocol with very high packet count and small payload is used. PHY or even more important switch latency might easily become relevant if multiple of them are involved for example in a bigger network with multiple switches, one after another.

More on how to measure network latency and response times can be found in the article Network performance measurement.