Skip to content

Commit 742f74b

Browse files
committed
Merge branch 'phy-doc-improvements'
Florian Fainelli says: ==================== Documentation: net: phy: Improve documentation This patch series addresses discussions and feedback that was recently received on the mailing-list in the area of: flow control/pause frames, interpretation of phy_interface_t and finally add some links to useful standards documents. Changes in v3: - add Timur's feedback into patch 3 Changes in v2: - clarify a few things in the RGMII section, add a paragraph about common issues with RGMII delay mismatches ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 5edef2f + cc91111 commit 742f74b

File tree

1 file changed

+105
-35
lines changed

1 file changed

+105
-35
lines changed

Documentation/networking/phy.txt

Lines changed: 105 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,83 @@ The MDIO bus
6565
drivers/net/ethernet/freescale/fsl_pq_mdio.c and an associated DTS file
6666
for one of the users. (e.g. "git grep fsl,.*-mdio arch/powerpc/boot/dts/")
6767

68+
(RG)MII/electrical interface considerations
69+
70+
The Reduced Gigabit Medium Independent Interface (RGMII) is a 12-pin
71+
electrical signal interface using a synchronous 125Mhz clock signal and several
72+
data lines. Due to this design decision, a 1.5ns to 2ns delay must be added
73+
between the clock line (RXC or TXC) and the data lines to let the PHY (clock
74+
sink) have enough setup and hold times to sample the data lines correctly. The
75+
PHY library offers different types of PHY_INTERFACE_MODE_RGMII* values to let
76+
the PHY driver and optionally the MAC driver, implement the required delay. The
77+
values of phy_interface_t must be understood from the perspective of the PHY
78+
device itself, leading to the following:
79+
80+
* PHY_INTERFACE_MODE_RGMII: the PHY is not responsible for inserting any
81+
internal delay by itself, it assumes that either the Ethernet MAC (if capable
82+
or the PCB traces) insert the correct 1.5-2ns delay
83+
84+
* PHY_INTERFACE_MODE_RGMII_TXID: the PHY should insert an internal delay
85+
for the transmit data lines (TXD[3:0]) processed by the PHY device
86+
87+
* PHY_INTERFACE_MODE_RGMII_RXID: the PHY should insert an internal delay
88+
for the receive data lines (RXD[3:0]) processed by the PHY device
89+
90+
* PHY_INTERFACE_MODE_RGMII_ID: the PHY should insert internal delays for
91+
both transmit AND receive data lines from/to the PHY device
92+
93+
Whenever possible, use the PHY side RGMII delay for these reasons:
94+
95+
* PHY devices may offer sub-nanosecond granularity in how they allow a
96+
receiver/transmitter side delay (e.g: 0.5, 1.0, 1.5ns) to be specified. Such
97+
precision may be required to account for differences in PCB trace lengths
98+
99+
* PHY devices are typically qualified for a large range of applications
100+
(industrial, medical, automotive...), and they provide a constant and
101+
reliable delay across temperature/pressure/voltage ranges
102+
103+
* PHY device drivers in PHYLIB being reusable by nature, being able to
104+
configure correctly a specified delay enables more designs with similar delay
105+
requirements to be operate correctly
106+
107+
For cases where the PHY is not capable of providing this delay, but the
108+
Ethernet MAC driver is capable of doing so, the correct phy_interface_t value
109+
should be PHY_INTERFACE_MODE_RGMII, and the Ethernet MAC driver should be
110+
configured correctly in order to provide the required transmit and/or receive
111+
side delay from the perspective of the PHY device. Conversely, if the Ethernet
112+
MAC driver looks at the phy_interface_t value, for any other mode but
113+
PHY_INTERFACE_MODE_RGMII, it should make sure that the MAC-level delays are
114+
disabled.
115+
116+
In case neither the Ethernet MAC, nor the PHY are capable of providing the
117+
required delays, as defined per the RGMII standard, several options may be
118+
available:
119+
120+
* Some SoCs may offer a pin pad/mux/controller capable of configuring a given
121+
set of pins'strength, delays, and voltage; and it may be a suitable
122+
option to insert the expected 2ns RGMII delay.
123+
124+
* Modifying the PCB design to include a fixed delay (e.g: using a specifically
125+
designed serpentine), which may not require software configuration at all.
126+
127+
Common problems with RGMII delay mismatch
128+
129+
When there is a RGMII delay mismatch between the Ethernet MAC and the PHY, this
130+
will most likely result in the clock and data line signals to be unstable when
131+
the PHY or MAC take a snapshot of these signals to translate them into logical
132+
1 or 0 states and reconstruct the data being transmitted/received. Typical
133+
symptoms include:
134+
135+
* Transmission/reception partially works, and there is frequent or occasional
136+
packet loss observed
137+
138+
* Ethernet MAC may report some or all packets ingressing with a FCS/CRC error,
139+
or just discard them all
140+
141+
* Switching to lower speeds such as 10/100Mbits/sec makes the problem go away
142+
(since there is enough setup/hold time in that case)
143+
144+
68145
Connecting to a PHY
69146

70147
Sometime during startup, the network driver needs to establish a connection
@@ -127,8 +204,9 @@ Letting the PHY Abstraction Layer do Everything
127204
values pruned from them which don't make sense for your controller (a 10/100
128205
controller may be connected to a gigabit capable PHY, so you would need to
129206
mask off SUPPORTED_1000baseT*). See include/linux/ethtool.h for definitions
130-
for these bitfields. Note that you should not SET any bits, or the PHY may
131-
get put into an unsupported state.
207+
for these bitfields. Note that you should not SET any bits, except the
208+
SUPPORTED_Pause and SUPPORTED_AsymPause bits (see below), or the PHY may get
209+
put into an unsupported state.
132210

133211
Lastly, once the controller is ready to handle network traffic, you call
134212
phy_start(phydev). This tells the PAL that you are ready, and configures the
@@ -139,6 +217,19 @@ Letting the PHY Abstraction Layer do Everything
139217
When you want to disconnect from the network (even if just briefly), you call
140218
phy_stop(phydev).
141219

220+
Pause frames / flow control
221+
222+
The PHY does not participate directly in flow control/pause frames except by
223+
making sure that the SUPPORTED_Pause and SUPPORTED_AsymPause bits are set in
224+
MII_ADVERTISE to indicate towards the link partner that the Ethernet MAC
225+
controller supports such a thing. Since flow control/pause frames generation
226+
involves the Ethernet MAC driver, it is recommended that this driver takes care
227+
of properly indicating advertisement and support for such features by setting
228+
the SUPPORTED_Pause and SUPPORTED_AsymPause bits accordingly. This can be done
229+
either before or after phy_connect() and/or as a result of implementing the
230+
ethtool::set_pauseparam feature.
231+
232+
142233
Keeping Close Tabs on the PAL
143234

144235
It is possible that the PAL's built-in state machine needs a little help to
@@ -251,39 +342,8 @@ Writing a PHY driver
251342
PHY_BASIC_FEATURES, but you can look in include/mii.h for other
252343
features.
253344

254-
Each driver consists of a number of function pointers:
255-
256-
soft_reset: perform a PHY software reset
257-
config_init: configures PHY into a sane state after a reset.
258-
For instance, a Davicom PHY requires descrambling disabled.
259-
probe: Allocate phy->priv, optionally refuse to bind.
260-
PHY may not have been reset or had fixups run yet.
261-
suspend/resume: power management
262-
config_aneg: Changes the speed/duplex/negotiation settings
263-
aneg_done: Determines the auto-negotiation result
264-
read_status: Reads the current speed/duplex/negotiation settings
265-
ack_interrupt: Clear a pending interrupt
266-
did_interrupt: Checks if the PHY generated an interrupt
267-
config_intr: Enable or disable interrupts
268-
remove: Does any driver take-down
269-
ts_info: Queries about the HW timestamping status
270-
match_phy_device: used for Clause 45 capable PHYs to match devices
271-
in package and ensure they are compatible
272-
hwtstamp: Set the PHY HW timestamping configuration
273-
rxtstamp: Requests a receive timestamp at the PHY level for a 'skb'
274-
txtsamp: Requests a transmit timestamp at the PHY level for a 'skb'
275-
set_wol: Enable Wake-on-LAN at the PHY level
276-
get_wol: Get the Wake-on-LAN status at the PHY level
277-
link_change_notify: called to inform the core is about to change the
278-
link state, can be used to work around bogus PHY between state changes
279-
read_mmd_indirect: Read PHY MMD indirect register
280-
write_mmd_indirect: Write PHY MMD indirect register
281-
module_info: Get the size and type of an EEPROM contained in an plug-in
282-
module
283-
module_eeprom: Get EEPROM information of a plug-in module
284-
get_sset_count: Get number of strings sets that get_strings will count
285-
get_strings: Get strings from requested objects (statistics)
286-
get_stats: Get the extended statistics from the PHY device
345+
Each driver consists of a number of function pointers, documented
346+
in include/linux/phy.h under the phy_driver structure.
287347

288348
Of these, only config_aneg and read_status are required to be
289349
assigned by the driver code. The rest are optional. Also, it is
@@ -347,3 +407,13 @@ Board Fixups
347407
The stubs set one of the two matching criteria, and set the other one to
348408
match anything.
349409

410+
Standards
411+
412+
IEEE Standard 802.3: CSMA/CD Access Method and Physical Layer Specifications, Section Two:
413+
http://standards.ieee.org/getieee802/download/802.3-2008_section2.pdf
414+
415+
RGMII v1.3:
416+
http://web.archive.org/web/20160303212629/http://www.hp.com/rnd/pdfs/RGMIIv1_3.pdf
417+
418+
RGMII v2.0:
419+
http://web.archive.org/web/20160303171328/http://www.hp.com/rnd/pdfs/RGMIIv2_0_final_hp.pdf

0 commit comments

Comments
 (0)