xref: /linux/Documentation/networking/device_drivers/ethernet/freescale/dpaa.rst (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
1*132db935SJakub Kicinski.. SPDX-License-Identifier: GPL-2.0
2*132db935SJakub Kicinski
3*132db935SJakub Kicinski==============================
4*132db935SJakub KicinskiThe QorIQ DPAA Ethernet Driver
5*132db935SJakub Kicinski==============================
6*132db935SJakub Kicinski
7*132db935SJakub KicinskiAuthors:
8*132db935SJakub Kicinski- Madalin Bucur <madalin.bucur@nxp.com>
9*132db935SJakub Kicinski- Camelia Groza <camelia.groza@nxp.com>
10*132db935SJakub Kicinski
11*132db935SJakub Kicinski.. Contents
12*132db935SJakub Kicinski
13*132db935SJakub Kicinski	- DPAA Ethernet Overview
14*132db935SJakub Kicinski	- DPAA Ethernet Supported SoCs
15*132db935SJakub Kicinski	- Configuring DPAA Ethernet in your kernel
16*132db935SJakub Kicinski	- DPAA Ethernet Frame Processing
17*132db935SJakub Kicinski	- DPAA Ethernet Features
18*132db935SJakub Kicinski	- DPAA IRQ Affinity and Receive Side Scaling
19*132db935SJakub Kicinski	- Debugging
20*132db935SJakub Kicinski
21*132db935SJakub KicinskiDPAA Ethernet Overview
22*132db935SJakub Kicinski======================
23*132db935SJakub Kicinski
24*132db935SJakub KicinskiDPAA stands for Data Path Acceleration Architecture and it is a
25*132db935SJakub Kicinskiset of networking acceleration IPs that are available on several
26*132db935SJakub Kicinskigenerations of SoCs, both on PowerPC and ARM64.
27*132db935SJakub Kicinski
28*132db935SJakub KicinskiThe Freescale DPAA architecture consists of a series of hardware blocks
29*132db935SJakub Kicinskithat support Ethernet connectivity. The Ethernet driver depends upon the
30*132db935SJakub Kicinskifollowing drivers in the Linux kernel:
31*132db935SJakub Kicinski
32*132db935SJakub Kicinski - Peripheral Access Memory Unit (PAMU) (* needed only for PPC platforms)
33*132db935SJakub Kicinski    drivers/iommu/fsl_*
34*132db935SJakub Kicinski - Frame Manager (FMan)
35*132db935SJakub Kicinski    drivers/net/ethernet/freescale/fman
36*132db935SJakub Kicinski - Queue Manager (QMan), Buffer Manager (BMan)
37*132db935SJakub Kicinski    drivers/soc/fsl/qbman
38*132db935SJakub Kicinski
39*132db935SJakub KicinskiA simplified view of the dpaa_eth interfaces mapped to FMan MACs::
40*132db935SJakub Kicinski
41*132db935SJakub Kicinski  dpaa_eth       /eth0\     ...       /ethN\
42*132db935SJakub Kicinski  driver        |      |             |      |
43*132db935SJakub Kicinski  -------------   ----   -----------   ----   -------------
44*132db935SJakub Kicinski       -Ports  / Tx  Rx \    ...    / Tx  Rx \
45*132db935SJakub Kicinski  FMan        |          |         |          |
46*132db935SJakub Kicinski       -MACs  |   MAC0   |         |   MACN   |
47*132db935SJakub Kicinski	     /   dtsec0   \  ...  /   dtsecN   \ (or tgec)
48*132db935SJakub Kicinski	    /              \     /              \(or memac)
49*132db935SJakub Kicinski  ---------  --------------  ---  --------------  ---------
50*132db935SJakub Kicinski      FMan, FMan Port, FMan SP, FMan MURAM drivers
51*132db935SJakub Kicinski  ---------------------------------------------------------
52*132db935SJakub Kicinski      FMan HW blocks: MURAM, MACs, Ports, SP
53*132db935SJakub Kicinski  ---------------------------------------------------------
54*132db935SJakub Kicinski
55*132db935SJakub KicinskiThe dpaa_eth relation to the QMan, BMan and FMan::
56*132db935SJakub Kicinski
57*132db935SJakub Kicinski	      ________________________________
58*132db935SJakub Kicinski  dpaa_eth   /            eth0                \
59*132db935SJakub Kicinski  driver    /                                  \
60*132db935SJakub Kicinski  ---------   -^-   -^-   -^-   ---    ---------
61*132db935SJakub Kicinski  QMan driver / \   / \   / \  \   /  | BMan    |
62*132db935SJakub Kicinski	     |Rx | |Rx | |Tx | |Tx |  | driver  |
63*132db935SJakub Kicinski  ---------  |Dfl| |Err| |Cnf| |FQs|  |         |
64*132db935SJakub Kicinski  QMan HW    |FQ | |FQ | |FQs| |   |  |         |
65*132db935SJakub Kicinski	     /   \ /   \ /   \  \ /   |         |
66*132db935SJakub Kicinski  ---------   ---   ---   ---   -v-    ---------
67*132db935SJakub Kicinski	    |        FMan QMI         |         |
68*132db935SJakub Kicinski	    | FMan HW       FMan BMI  | BMan HW |
69*132db935SJakub Kicinski	      -----------------------   --------
70*132db935SJakub Kicinski
71*132db935SJakub Kicinskiwhere the acronyms used above (and in the code) are:
72*132db935SJakub Kicinski
73*132db935SJakub Kicinski=============== ===========================================================
74*132db935SJakub KicinskiDPAA 		Data Path Acceleration Architecture
75*132db935SJakub KicinskiFMan 		DPAA Frame Manager
76*132db935SJakub KicinskiQMan 		DPAA Queue Manager
77*132db935SJakub KicinskiBMan 		DPAA Buffers Manager
78*132db935SJakub KicinskiQMI 		QMan interface in FMan
79*132db935SJakub KicinskiBMI 		BMan interface in FMan
80*132db935SJakub KicinskiFMan SP 	FMan Storage Profiles
81*132db935SJakub KicinskiMURAM 		Multi-user RAM in FMan
82*132db935SJakub KicinskiFQ 		QMan Frame Queue
83*132db935SJakub KicinskiRx Dfl FQ 	default reception FQ
84*132db935SJakub KicinskiRx Err FQ 	Rx error frames FQ
85*132db935SJakub KicinskiTx Cnf FQ 	Tx confirmation FQs
86*132db935SJakub KicinskiTx FQs 		transmission frame queues
87*132db935SJakub Kicinskidtsec 		datapath three speed Ethernet controller (10/100/1000 Mbps)
88*132db935SJakub Kicinskitgec 		ten gigabit Ethernet controller (10 Gbps)
89*132db935SJakub Kicinskimemac 		multirate Ethernet MAC (10/100/1000/10000)
90*132db935SJakub Kicinski=============== ===========================================================
91*132db935SJakub Kicinski
92*132db935SJakub KicinskiDPAA Ethernet Supported SoCs
93*132db935SJakub Kicinski============================
94*132db935SJakub Kicinski
95*132db935SJakub KicinskiThe DPAA drivers enable the Ethernet controllers present on the following SoCs:
96*132db935SJakub Kicinski
97*132db935SJakub KicinskiPPC
98*132db935SJakub Kicinski- P1023
99*132db935SJakub Kicinski- P2041
100*132db935SJakub Kicinski- P3041
101*132db935SJakub Kicinski- P4080
102*132db935SJakub Kicinski- P5020
103*132db935SJakub Kicinski- P5040
104*132db935SJakub Kicinski- T1023
105*132db935SJakub Kicinski- T1024
106*132db935SJakub Kicinski- T1040
107*132db935SJakub Kicinski- T1042
108*132db935SJakub Kicinski- T2080
109*132db935SJakub Kicinski- T4240
110*132db935SJakub Kicinski- B4860
111*132db935SJakub Kicinski
112*132db935SJakub KicinskiARM
113*132db935SJakub Kicinski- LS1043A
114*132db935SJakub Kicinski- LS1046A
115*132db935SJakub Kicinski
116*132db935SJakub KicinskiConfiguring DPAA Ethernet in your kernel
117*132db935SJakub Kicinski========================================
118*132db935SJakub Kicinski
119*132db935SJakub KicinskiTo enable the DPAA Ethernet driver, the following Kconfig options are required::
120*132db935SJakub Kicinski
121*132db935SJakub Kicinski  # common for arch/arm64 and arch/powerpc platforms
122*132db935SJakub Kicinski  CONFIG_FSL_DPAA=y
123*132db935SJakub Kicinski  CONFIG_FSL_FMAN=y
124*132db935SJakub Kicinski  CONFIG_FSL_DPAA_ETH=y
125*132db935SJakub Kicinski  CONFIG_FSL_XGMAC_MDIO=y
126*132db935SJakub Kicinski
127*132db935SJakub Kicinski  # for arch/powerpc only
128*132db935SJakub Kicinski  CONFIG_FSL_PAMU=y
129*132db935SJakub Kicinski
130*132db935SJakub Kicinski  # common options needed for the PHYs used on the RDBs
131*132db935SJakub Kicinski  CONFIG_VITESSE_PHY=y
132*132db935SJakub Kicinski  CONFIG_REALTEK_PHY=y
133*132db935SJakub Kicinski  CONFIG_AQUANTIA_PHY=y
134*132db935SJakub Kicinski
135*132db935SJakub KicinskiDPAA Ethernet Frame Processing
136*132db935SJakub Kicinski==============================
137*132db935SJakub Kicinski
138*132db935SJakub KicinskiOn Rx, buffers for the incoming frames are retrieved from the buffers found
139*132db935SJakub Kicinskiin the dedicated interface buffer pool. The driver initializes and seeds these
140*132db935SJakub Kicinskiwith one page buffers.
141*132db935SJakub Kicinski
142*132db935SJakub KicinskiOn Tx, all transmitted frames are returned to the driver through Tx
143*132db935SJakub Kicinskiconfirmation frame queues. The driver is then responsible for freeing the
144*132db935SJakub Kicinskibuffers. In order to do this properly, a backpointer is added to the buffer
145*132db935SJakub Kicinskibefore transmission that points to the skb. When the buffer returns to the
146*132db935SJakub Kicinskidriver on a confirmation FQ, the skb can be correctly consumed.
147*132db935SJakub Kicinski
148*132db935SJakub KicinskiDPAA Ethernet Features
149*132db935SJakub Kicinski======================
150*132db935SJakub Kicinski
151*132db935SJakub KicinskiCurrently the DPAA Ethernet driver enables the basic features required for
152*132db935SJakub Kicinskia Linux Ethernet driver. The support for advanced features will be added
153*132db935SJakub Kicinskigradually.
154*132db935SJakub Kicinski
155*132db935SJakub KicinskiThe driver has Rx and Tx checksum offloading for UDP and TCP. Currently the Rx
156*132db935SJakub Kicinskichecksum offload feature is enabled by default and cannot be controlled through
157*132db935SJakub Kicinskiethtool. Also, rx-flow-hash and rx-hashing was added. The addition of RSS
158*132db935SJakub Kicinskiprovides a big performance boost for the forwarding scenarios, allowing
159*132db935SJakub Kicinskidifferent traffic flows received by one interface to be processed by different
160*132db935SJakub KicinskiCPUs in parallel.
161*132db935SJakub Kicinski
162*132db935SJakub KicinskiThe driver has support for multiple prioritized Tx traffic classes. Priorities
163*132db935SJakub Kicinskirange from 0 (lowest) to 3 (highest). These are mapped to HW workqueues with
164*132db935SJakub Kicinskistrict priority levels. Each traffic class contains NR_CPU TX queues. By
165*132db935SJakub Kicinskidefault, only one traffic class is enabled and the lowest priority Tx queues
166*132db935SJakub Kicinskiare used. Higher priority traffic classes can be enabled with the mqprio
167*132db935SJakub Kicinskiqdisc. For example, all four traffic classes are enabled on an interface with
168*132db935SJakub Kicinskithe following command. Furthermore, skb priority levels are mapped to traffic
169*132db935SJakub Kicinskiclasses as follows:
170*132db935SJakub Kicinski
171*132db935SJakub Kicinski	* priorities 0 to 3 - traffic class 0 (low priority)
172*132db935SJakub Kicinski	* priorities 4 to 7 - traffic class 1 (medium-low priority)
173*132db935SJakub Kicinski	* priorities 8 to 11 - traffic class 2 (medium-high priority)
174*132db935SJakub Kicinski	* priorities 12 to 15 - traffic class 3 (high priority)
175*132db935SJakub Kicinski
176*132db935SJakub Kicinski::
177*132db935SJakub Kicinski
178*132db935SJakub Kicinski  tc qdisc add dev <int> root handle 1: \
179*132db935SJakub Kicinski	 mqprio num_tc 4 map 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 hw 1
180*132db935SJakub Kicinski
181*132db935SJakub KicinskiDPAA IRQ Affinity and Receive Side Scaling
182*132db935SJakub Kicinski==========================================
183*132db935SJakub Kicinski
184*132db935SJakub KicinskiTraffic coming on the DPAA Rx queues or on the DPAA Tx confirmation
185*132db935SJakub Kicinskiqueues is seen by the CPU as ingress traffic on a certain portal.
186*132db935SJakub KicinskiThe DPAA QMan portal interrupts are affined each to a certain CPU.
187*132db935SJakub KicinskiThe same portal interrupt services all the QMan portal consumers.
188*132db935SJakub Kicinski
189*132db935SJakub KicinskiBy default the DPAA Ethernet driver enables RSS, making use of the
190*132db935SJakub KicinskiDPAA FMan Parser and Keygen blocks to distribute traffic on 128
191*132db935SJakub Kicinskihardware frame queues using a hash on IP v4/v6 source and destination
192*132db935SJakub Kicinskiand L4 source and destination ports, in present in the received frame.
193*132db935SJakub KicinskiWhen RSS is disabled, all traffic received by a certain interface is
194*132db935SJakub Kicinskireceived on the default Rx frame queue. The default DPAA Rx frame
195*132db935SJakub Kicinskiqueues are configured to put the received traffic into a pool channel
196*132db935SJakub Kicinskithat allows any available CPU portal to dequeue the ingress traffic.
197*132db935SJakub KicinskiThe default frame queues have the HOLDACTIVE option set, ensuring that
198*132db935SJakub Kicinskitraffic bursts from a certain queue are serviced by the same CPU.
199*132db935SJakub KicinskiThis ensures a very low rate of frame reordering. A drawback of this
200*132db935SJakub Kicinskiis that only one CPU at a time can service the traffic received by a
201*132db935SJakub Kicinskicertain interface when RSS is not enabled.
202*132db935SJakub Kicinski
203*132db935SJakub KicinskiTo implement RSS, the DPAA Ethernet driver allocates an extra set of
204*132db935SJakub Kicinski128 Rx frame queues that are configured to dedicated channels, in a
205*132db935SJakub Kicinskiround-robin manner. The mapping of the frame queues to CPUs is now
206*132db935SJakub Kicinskihardcoded, there is no indirection table to move traffic for a certain
207*132db935SJakub KicinskiFQ (hash result) to another CPU. The ingress traffic arriving on one
208*132db935SJakub Kicinskiof these frame queues will arrive at the same portal and will always
209*132db935SJakub Kicinskibe processed by the same CPU. This ensures intra-flow order preservation
210*132db935SJakub Kicinskiand workload distribution for multiple traffic flows.
211*132db935SJakub Kicinski
212*132db935SJakub KicinskiRSS can be turned off for a certain interface using ethtool, i.e.::
213*132db935SJakub Kicinski
214*132db935SJakub Kicinski	# ethtool -N fm1-mac9 rx-flow-hash tcp4 ""
215*132db935SJakub Kicinski
216*132db935SJakub KicinskiTo turn it back on, one needs to set rx-flow-hash for tcp4/6 or udp4/6::
217*132db935SJakub Kicinski
218*132db935SJakub Kicinski	# ethtool -N fm1-mac9 rx-flow-hash udp4 sfdn
219*132db935SJakub Kicinski
220*132db935SJakub KicinskiThere is no independent control for individual protocols, any command
221*132db935SJakub Kicinskirun for one of tcp4|udp4|ah4|esp4|sctp4|tcp6|udp6|ah6|esp6|sctp6 is
222*132db935SJakub Kicinskigoing to control the rx-flow-hashing for all protocols on that interface.
223*132db935SJakub Kicinski
224*132db935SJakub KicinskiBesides using the FMan Keygen computed hash for spreading traffic on the
225*132db935SJakub Kicinski128 Rx FQs, the DPAA Ethernet driver also sets the skb hash value when
226*132db935SJakub Kicinskithe NETIF_F_RXHASH feature is on (active by default). This can be turned
227*132db935SJakub Kicinskion or off through ethtool, i.e.::
228*132db935SJakub Kicinski
229*132db935SJakub Kicinski	# ethtool -K fm1-mac9 rx-hashing off
230*132db935SJakub Kicinski	# ethtool -k fm1-mac9 | grep hash
231*132db935SJakub Kicinski	receive-hashing: off
232*132db935SJakub Kicinski	# ethtool -K fm1-mac9 rx-hashing on
233*132db935SJakub Kicinski	Actual changes:
234*132db935SJakub Kicinski	receive-hashing: on
235*132db935SJakub Kicinski	# ethtool -k fm1-mac9 | grep hash
236*132db935SJakub Kicinski	receive-hashing: on
237*132db935SJakub Kicinski
238*132db935SJakub KicinskiPlease note that Rx hashing depends upon the rx-flow-hashing being on
239*132db935SJakub Kicinskifor that interface - turning off rx-flow-hashing will also disable the
240*132db935SJakub Kicinskirx-hashing (without ethtool reporting it as off as that depends on the
241*132db935SJakub KicinskiNETIF_F_RXHASH feature flag).
242*132db935SJakub Kicinski
243*132db935SJakub KicinskiDebugging
244*132db935SJakub Kicinski=========
245*132db935SJakub Kicinski
246*132db935SJakub KicinskiThe following statistics are exported for each interface through ethtool:
247*132db935SJakub Kicinski
248*132db935SJakub Kicinski	- interrupt count per CPU
249*132db935SJakub Kicinski	- Rx packets count per CPU
250*132db935SJakub Kicinski	- Tx packets count per CPU
251*132db935SJakub Kicinski	- Tx confirmed packets count per CPU
252*132db935SJakub Kicinski	- Tx S/G frames count per CPU
253*132db935SJakub Kicinski	- Tx error count per CPU
254*132db935SJakub Kicinski	- Rx error count per CPU
255*132db935SJakub Kicinski	- Rx error count per type
256*132db935SJakub Kicinski	- congestion related statistics:
257*132db935SJakub Kicinski
258*132db935SJakub Kicinski		- congestion status
259*132db935SJakub Kicinski		- time spent in congestion
260*132db935SJakub Kicinski		- number of time the device entered congestion
261*132db935SJakub Kicinski		- dropped packets count per cause
262*132db935SJakub Kicinski
263*132db935SJakub KicinskiThe driver also exports the following information in sysfs:
264*132db935SJakub Kicinski
265*132db935SJakub Kicinski	- the FQ IDs for each FQ type
266*132db935SJakub Kicinski	  /sys/devices/platform/soc/<addr>.fman/<addr>.ethernet/dpaa-ethernet.<id>/net/fm<nr>-mac<nr>/fqids
267*132db935SJakub Kicinski
268*132db935SJakub Kicinski	- the ID of the buffer pool in use
269*132db935SJakub Kicinski	  /sys/devices/platform/soc/<addr>.fman/<addr>.ethernet/dpaa-ethernet.<id>/net/fm<nr>-mac<nr>/bpids
270