xref: /openbmc/qemu/docs/specs/rocker.rst (revision 9ca6876d)
1*9ca6876dSPeter MaydellRocker Network Switch Register Programming Guide
2*9ca6876dSPeter Maydell************************************************
3*9ca6876dSPeter Maydell
4*9ca6876dSPeter Maydell..
5*9ca6876dSPeter Maydell   Copyright (c) Scott Feldman <sfeldma@gmail.com>
6*9ca6876dSPeter Maydell   Copyright (c) Neil Horman <nhorman@tuxdriver.com>
7*9ca6876dSPeter Maydell   Version 0.11, 12/29/2014
8*9ca6876dSPeter Maydell
9*9ca6876dSPeter Maydell   This program is free software; you can redistribute it and/or modify
10*9ca6876dSPeter Maydell   it under the terms of the GNU General Public License as published by
11*9ca6876dSPeter Maydell   the Free Software Foundation; either version 2 of the License, or
12*9ca6876dSPeter Maydell   (at your option) any later version.
13*9ca6876dSPeter Maydell
14*9ca6876dSPeter Maydell   This program is distributed in the hope that it will be useful,
15*9ca6876dSPeter Maydell   but WITHOUT ANY WARRANTY; without even the implied warranty of
16*9ca6876dSPeter Maydell   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17*9ca6876dSPeter Maydell   GNU General Public License for more details.
18*9ca6876dSPeter Maydell
19*9ca6876dSPeter MaydellIntroduction
20*9ca6876dSPeter Maydell============
21*9ca6876dSPeter Maydell
22*9ca6876dSPeter MaydellOverview
23*9ca6876dSPeter Maydell--------
24*9ca6876dSPeter Maydell
25*9ca6876dSPeter MaydellThis document describes the hardware/software interface for the Rocker switch
26*9ca6876dSPeter Maydelldevice.  The intended audience is authors of OS drivers and device emulation
27*9ca6876dSPeter Maydellsoftware.
28*9ca6876dSPeter Maydell
29*9ca6876dSPeter MaydellNotations and Conventions
30*9ca6876dSPeter Maydell-------------------------
31*9ca6876dSPeter Maydell
32*9ca6876dSPeter Maydell* In register descriptions, [n:m] indicates a range from bit n to bit m,
33*9ca6876dSPeter Maydell  inclusive.
34*9ca6876dSPeter Maydell* Use of leading 0x indicates a hexadecimal number.
35*9ca6876dSPeter Maydell* Use of leading 0b indicates a binary number.
36*9ca6876dSPeter Maydell* The use of RSVD or Reserved indicates that a bit or field is reserved for
37*9ca6876dSPeter Maydell  future use.
38*9ca6876dSPeter Maydell* Field width is in bytes, unless otherwise noted.
39*9ca6876dSPeter Maydell* Register are (R) read-only, (R/W) read/write, (W) write-only, or (COR) clear
40*9ca6876dSPeter Maydell  on read
41*9ca6876dSPeter Maydell* TLV values in network-byte-order are designated with (N).
42*9ca6876dSPeter Maydell
43*9ca6876dSPeter Maydell
44*9ca6876dSPeter MaydellPCI Configuration Registers
45*9ca6876dSPeter Maydell===========================
46*9ca6876dSPeter Maydell
47*9ca6876dSPeter MaydellPCI Configuration Space
48*9ca6876dSPeter Maydell-----------------------
49*9ca6876dSPeter Maydell
50*9ca6876dSPeter MaydellEach switch instance registers as a PCI device with PCI configuration space::
51*9ca6876dSPeter Maydell
52*9ca6876dSPeter Maydell	offset	width	description		value
53*9ca6876dSPeter Maydell	---------------------------------------------
54*9ca6876dSPeter Maydell	0x0	2	Vendor ID		0x1b36
55*9ca6876dSPeter Maydell	0x2	2	Device ID		0x0006
56*9ca6876dSPeter Maydell	0x4	4	Command/Status
57*9ca6876dSPeter Maydell	0x8	1	Revision ID		0x01
58*9ca6876dSPeter Maydell	0x9	3	Class code		0x2800
59*9ca6876dSPeter Maydell	0xC	1	Cache line size
60*9ca6876dSPeter Maydell	0xD	1	Latency timer
61*9ca6876dSPeter Maydell	0xE	1	Header type
62*9ca6876dSPeter Maydell	0xF	1	Built-in self test
63*9ca6876dSPeter Maydell	0x10	4	Base address low
64*9ca6876dSPeter Maydell	0x14	4	Base address high
65*9ca6876dSPeter Maydell	0x18-28		Reserved
66*9ca6876dSPeter Maydell	0x2C	2	Subsystem vendor ID	*
67*9ca6876dSPeter Maydell	0x2E	2	Subsystem ID		*
68*9ca6876dSPeter Maydell	0x30-38		Reserved
69*9ca6876dSPeter Maydell	0x3C	1	Interrupt line
70*9ca6876dSPeter Maydell	0x3D	1	Interrupt pin		0x00
71*9ca6876dSPeter Maydell	0x3E	1	Min grant		0x00
72*9ca6876dSPeter Maydell	0x3D	1	Max latency		0x00
73*9ca6876dSPeter Maydell	0x40	1	TRDY timeout
74*9ca6876dSPeter Maydell	0x41	1	Retry count
75*9ca6876dSPeter Maydell	0x42	2	Reserved
76*9ca6876dSPeter Maydell
77*9ca6876dSPeter Maydell        * Assigned by sub-system implementation
78*9ca6876dSPeter Maydell
79*9ca6876dSPeter MaydellMemory-Mapped Register Space
80*9ca6876dSPeter Maydell============================
81*9ca6876dSPeter Maydell
82*9ca6876dSPeter MaydellThere are two memory-mapped BARs.  BAR0 maps device register space and is
83*9ca6876dSPeter Maydell0x2000 in size.  BAR1 maps MSI-X vector and PBA tables and is also 0x2000 in
84*9ca6876dSPeter Maydellsize, allowing for 256 MSI-X vectors.
85*9ca6876dSPeter Maydell
86*9ca6876dSPeter MaydellAll registers are 4 or 8 bytes long.  It is assumed host software will access 4
87*9ca6876dSPeter Maydellbyte registers with one 4-byte access, and 8 byte registers with either two
88*9ca6876dSPeter Maydell4-byte accesses or a single 8-byte access.  In the case of two 4-byte accesses,
89*9ca6876dSPeter Maydellaccess must be lower and then upper 4-bytes, in that order.
90*9ca6876dSPeter Maydell
91*9ca6876dSPeter MaydellBAR0 device register space is organized as follows::
92*9ca6876dSPeter Maydell
93*9ca6876dSPeter Maydell	offset		description
94*9ca6876dSPeter Maydell	------------------------------------------------------
95*9ca6876dSPeter Maydell	0x0000-0x000f	Bogus registers to catch misbehaving
96*9ca6876dSPeter Maydell			drivers.  Writes do nothing.  Reads
97*9ca6876dSPeter Maydell			back as 0xDEADBABE.
98*9ca6876dSPeter Maydell	0x0010-0x00ff	Test registers
99*9ca6876dSPeter Maydell	0x0300-0x03ff	General purpose registers
100*9ca6876dSPeter Maydell	0x1000-0x1fff	Descriptor control
101*9ca6876dSPeter Maydell
102*9ca6876dSPeter MaydellHoles in register space are reserved.  Writes to reserved registers do nothing.
103*9ca6876dSPeter MaydellReads to reserved registers read back as 0.
104*9ca6876dSPeter Maydell
105*9ca6876dSPeter MaydellNo fancy stuff like write-combining is enabled on any of the registers.
106*9ca6876dSPeter Maydell
107*9ca6876dSPeter MaydellBAR1 MSI-X register space is organized as follows::
108*9ca6876dSPeter Maydell
109*9ca6876dSPeter Maydell	offset		description
110*9ca6876dSPeter Maydell	------------------------------------------------------
111*9ca6876dSPeter Maydell	0x0000-0x0fff	MSI-X vector table (256 vectors total)
112*9ca6876dSPeter Maydell	0x1000-0x1fff	MSI-X PBA table
113*9ca6876dSPeter Maydell
114*9ca6876dSPeter Maydell
115*9ca6876dSPeter MaydellInterrupts, DMA, and Endianness
116*9ca6876dSPeter Maydell===============================
117*9ca6876dSPeter Maydell
118*9ca6876dSPeter MaydellPCI Interrupts
119*9ca6876dSPeter Maydell--------------
120*9ca6876dSPeter Maydell
121*9ca6876dSPeter MaydellThe device supports only MSI-X interrupts.  BAR1 memory-mapped region contains
122*9ca6876dSPeter Maydellthe MSI-X vector and PBA tables, with support for up to 256 MSI-X vectors.
123*9ca6876dSPeter Maydell
124*9ca6876dSPeter MaydellThe vector assignment is::
125*9ca6876dSPeter Maydell
126*9ca6876dSPeter Maydell	vector		description
127*9ca6876dSPeter Maydell	-----------------------------------------------------
128*9ca6876dSPeter Maydell	0		Command descriptor ring completion
129*9ca6876dSPeter Maydell	1		Event descriptor ring completion
130*9ca6876dSPeter Maydell	2		Test operation completion
131*9ca6876dSPeter Maydell	3		RSVD
132*9ca6876dSPeter Maydell	4-255		Tx and Rx descriptor ring completion
133*9ca6876dSPeter Maydell			  Tx vector is even
134*9ca6876dSPeter Maydell			  Rx vector is odd
135*9ca6876dSPeter Maydell
136*9ca6876dSPeter MaydellA MSI-X vector table entry is 16 bytes::
137*9ca6876dSPeter Maydell
138*9ca6876dSPeter Maydell	field		offset	width	description
139*9ca6876dSPeter Maydell	-------------------------------------------------------------
140*9ca6876dSPeter Maydell	lower_addr	0x0	4	[31:2] message address[31:2]
141*9ca6876dSPeter Maydell					[1:0] Rsvd (4 byte alignment
142*9ca6876dSPeter Maydell						    required)
143*9ca6876dSPeter Maydell	upper_addr	0x4	4	[31:19] Rsvd
144*9ca6876dSPeter Maydell					[14:0] message address[46:32]
145*9ca6876dSPeter Maydell	data		0x8	4	message data[31:0]
146*9ca6876dSPeter Maydell	control		0xc	4	[31:1] Rsvd
147*9ca6876dSPeter Maydell					[0] mask (0 = enable,
148*9ca6876dSPeter Maydell						  1 = masked)
149*9ca6876dSPeter Maydell
150*9ca6876dSPeter MaydellSoftware should install the Interrupt Service Routine (ISR) before any ports
151*9ca6876dSPeter Maydellare enabled or any commands are issued on the command ring.
152*9ca6876dSPeter Maydell
153*9ca6876dSPeter MaydellDMA Operations
154*9ca6876dSPeter Maydell--------------
155*9ca6876dSPeter Maydell
156*9ca6876dSPeter MaydellDMA operations are used for packet DMA to/from the CPU, command and event
157*9ca6876dSPeter Maydellprocessing.  Command processing includes statistical counters and table dumps,
158*9ca6876dSPeter Maydelltable insertion/deletion, and more.  Event processing provides an async
159*9ca6876dSPeter Maydellnotification method for device-originating events.  Each DMA operation has a
160*9ca6876dSPeter Maydellset of control registers to manage a descriptor ring.  The descriptor rings are
161*9ca6876dSPeter Maydellallocated from contiguous host DMA-able memory and registers specify the rings
162*9ca6876dSPeter Maydellbase address, size and current head and tail indices.  Software always writes
163*9ca6876dSPeter Maydellthe head, and hardware always writes the tail.
164*9ca6876dSPeter Maydell
165*9ca6876dSPeter MaydellThe higher-order bit of DMA_DESC_COMP_ERR is used to mark hardware completion
166*9ca6876dSPeter Maydellof a descriptor.  Software will clear this bit when posting a descriptor to the
167*9ca6876dSPeter Maydellring, and hardware will set this bit when the descriptor is complete.
168*9ca6876dSPeter Maydell
169*9ca6876dSPeter MaydellDescriptor ring sizes must be a power of 2 and range from 2 to 64K entries.
170*9ca6876dSPeter MaydellDescriptor rings' base address must be 8-byte aligned.  Descriptors must be
171*9ca6876dSPeter Maydellpacked within ring.  Each descriptor in each ring must also be aligned on an 8
172*9ca6876dSPeter Maydellbyte boundary.  Each descriptor ring will have these registers::
173*9ca6876dSPeter Maydell
174*9ca6876dSPeter Maydell	DMA_DESC_xxx_BASE_ADDR, offset 0x1000 + (x * 32), 64-bit, (R/W)
175*9ca6876dSPeter Maydell	DMA_DESC_xxx_SIZE, offset 0x1008 + (x * 32), 32-bit, (R/W)
176*9ca6876dSPeter Maydell	DMA_DESC_xxx_HEAD, offset 0x100c + (x * 32), 32-bit, (R/W)
177*9ca6876dSPeter Maydell	DMA_DESC_xxx_TAIL, offset 0x1010 + (x * 32), 32-bit, (R)
178*9ca6876dSPeter Maydell	DMA_DESC_xxx_CTRL, offset 0x1014 + (x * 32), 32-bit, (W)
179*9ca6876dSPeter Maydell	DMA_DESC_xxx_CREDITS, offset 0x1018 + (x * 32), 32-bit, (R/W)
180*9ca6876dSPeter Maydell	DMA_DESC_xxx_RSVD1, offset 0x101c + (x * 32), 32-bit, (R/W)
181*9ca6876dSPeter Maydell
182*9ca6876dSPeter MaydellWhere x is descriptor ring index::
183*9ca6876dSPeter Maydell
184*9ca6876dSPeter Maydell	index		ring
185*9ca6876dSPeter Maydell	--------------------
186*9ca6876dSPeter Maydell	0		CMD
187*9ca6876dSPeter Maydell	1		EVENT
188*9ca6876dSPeter Maydell	2		TX (port 0)
189*9ca6876dSPeter Maydell	3		RX (port 0)
190*9ca6876dSPeter Maydell	4		TX (port 1)
191*9ca6876dSPeter Maydell	5		RX (port 1)
192*9ca6876dSPeter Maydell	.
193*9ca6876dSPeter Maydell	.
194*9ca6876dSPeter Maydell	.
195*9ca6876dSPeter Maydell	124		TX (port 61)
196*9ca6876dSPeter Maydell	125		RX (port 61)
197*9ca6876dSPeter Maydell	126		Resv
198*9ca6876dSPeter Maydell	127		Resv
199*9ca6876dSPeter Maydell
200*9ca6876dSPeter MaydellWriting BASE_ADDR or SIZE will reset HEAD and TAIL to zero.  HEAD cannot be
201*9ca6876dSPeter Maydellwritten past TAIL.  To do so would wrap the ring.  An empty ring is when HEAD
202*9ca6876dSPeter Maydell== TAIL.  A full ring is when HEAD is one position behind TAIL.  Both HEAD and
203*9ca6876dSPeter MaydellTAIL increment and modulo wrap at the ring size.
204*9ca6876dSPeter Maydell
205*9ca6876dSPeter MaydellCTRL register bits::
206*9ca6876dSPeter Maydell
207*9ca6876dSPeter Maydell	bit	name		description
208*9ca6876dSPeter Maydell	------------------------------------------------------------------------
209*9ca6876dSPeter Maydell	[0]	CTRL_RESET	Reset the descriptor ring
210*9ca6876dSPeter Maydell	[1:31]	Reserved
211*9ca6876dSPeter Maydell
212*9ca6876dSPeter MaydellAll descriptor types share some common fields::
213*9ca6876dSPeter Maydell
214*9ca6876dSPeter Maydell	field			width	description
215*9ca6876dSPeter Maydell	-------------------------------------------------------------------
216*9ca6876dSPeter Maydell	DMA_DESC_BUF_ADDR	8	Phys addr of desc payload, 8-byte
217*9ca6876dSPeter Maydell					aligned
218*9ca6876dSPeter Maydell	DMA_DESC_COOKIE		8	Desc cookie for completion matching,
219*9ca6876dSPeter Maydell					upper-most bit is reserved
220*9ca6876dSPeter Maydell	DMA_DESC_BUF_SIZE	2	Desc payload size in bytes
221*9ca6876dSPeter Maydell	DMA_DESC_TLV_SIZE	2	Desc payload total size in bytes
222*9ca6876dSPeter Maydell					used for TLVs.  Must be <=
223*9ca6876dSPeter Maydell					DMA_DESC_BUF_SIZE.
224*9ca6876dSPeter Maydell	DMA_DESC_COMP_ERR	2	Completion status of associated
225*9ca6876dSPeter Maydell					desc payload.  High order bit is
226*9ca6876dSPeter Maydell					clear on new descs, toggled by
227*9ca6876dSPeter Maydell					hw for completed items.
228*9ca6876dSPeter Maydell
229*9ca6876dSPeter MaydellTo support forward- and backward-compatibility, descriptor and completion
230*9ca6876dSPeter Maydellpayloads are specified in TLV format.  Fields are packed with Type=field name,
231*9ca6876dSPeter MaydellLength=field length, and Value=field value.  Software will ignore unknown fields
232*9ca6876dSPeter Maydellfilled in by the switch.  Likewise, the switch will ignore unknown fields
233*9ca6876dSPeter Maydellfilled in by software.
234*9ca6876dSPeter Maydell
235*9ca6876dSPeter MaydellDescriptor payload buffer is 8-byte aligned and TLVs are 8-byte aligned.  The
236*9ca6876dSPeter Maydellvalue within a TLV is also 8-byte aligned.  The (packed, 8 byte) TLV header is::
237*9ca6876dSPeter Maydell
238*9ca6876dSPeter Maydell	field	width	description
239*9ca6876dSPeter Maydell	-----------------------------
240*9ca6876dSPeter Maydell	type	4	TLV type
241*9ca6876dSPeter Maydell	len	2	TLV value length
242*9ca6876dSPeter Maydell	pad	2	Reserved
243*9ca6876dSPeter Maydell
244*9ca6876dSPeter MaydellThe alignment requirements for descriptors and TLVs are to avoid unaligned
245*9ca6876dSPeter Maydellaccess exceptions in software.  Note that the payload for each TLV is also
246*9ca6876dSPeter Maydell8 byte aligned.
247*9ca6876dSPeter Maydell
248*9ca6876dSPeter MaydellFigure 1 shows an example descriptor buffer with two TLVs::
249*9ca6876dSPeter Maydell
250*9ca6876dSPeter Maydell                  <------- 8 bytes ------->
251*9ca6876dSPeter Maydell
252*9ca6876dSPeter Maydell  8-byte  +––––+  +–––––––––––+–––––+–––––+                     +–+
253*9ca6876dSPeter Maydell  align           |   type    | len | pad |    TLV#1 hdr          |
254*9ca6876dSPeter Maydell                  +–––––––––––+–––––+–––––+    (len=22)           |
255*9ca6876dSPeter Maydell                  |                       |                       |
256*9ca6876dSPeter Maydell                  |  value                |    TVL#1 value        |
257*9ca6876dSPeter Maydell                  |                       |    (padded to 8-byte  |
258*9ca6876dSPeter Maydell                  |                 +–––––+     alignment)        |
259*9ca6876dSPeter Maydell                  |                 |/////|                       |
260*9ca6876dSPeter Maydell   8-byte +––––+  +–––––––––––+–––––––––––+                       |
261*9ca6876dSPeter Maydell   align          |   type    | len | pad |    TLV#2 hdr    DESC_BUF_SIZE
262*9ca6876dSPeter Maydell                  +–––––+–––––+–––––+–––––+    (len=2)            |
263*9ca6876dSPeter Maydell                  |value|/////////////////|    TLV#2 value        |
264*9ca6876dSPeter Maydell                  +–––––+/////////////////|                       |
265*9ca6876dSPeter Maydell                  |///////////////////////|                       |
266*9ca6876dSPeter Maydell                  |///////////////////////|                       |
267*9ca6876dSPeter Maydell                  |///////////////////////|                       |
268*9ca6876dSPeter Maydell                  |////////unused/////////|                       |
269*9ca6876dSPeter Maydell                  |////////space//////////|                       |
270*9ca6876dSPeter Maydell                  |///////////////////////|                       |
271*9ca6876dSPeter Maydell                  |///////////////////////|                       |
272*9ca6876dSPeter Maydell                  |///////////////////////|                       |
273*9ca6876dSPeter Maydell                  +–––––––––––––––––––––––+                     +–+
274*9ca6876dSPeter Maydell
275*9ca6876dSPeter Maydell				fig. 1
276*9ca6876dSPeter Maydell
277*9ca6876dSPeter MaydellTLVs can be nested within the NEST TLV type.
278*9ca6876dSPeter Maydell
279*9ca6876dSPeter MaydellInterrupt credits
280*9ca6876dSPeter Maydell^^^^^^^^^^^^^^^^^
281*9ca6876dSPeter Maydell
282*9ca6876dSPeter MaydellMSI-X vectors used for descriptor ring completions use a credit mechanism for
283*9ca6876dSPeter Maydellefficient device, PCIe bus, OS and driver operations.  Each descriptor ring has
284*9ca6876dSPeter Maydella credit count which represents the number of outstanding descriptors to be
285*9ca6876dSPeter Maydellprocessed by the driver.  As the device marks descriptors complete, the credit
286*9ca6876dSPeter Maydellcount is incremented.  As the driver processes those outstanding descriptors,
287*9ca6876dSPeter Maydellit returns credits back to the device.  This way, the device knows the driver's
288*9ca6876dSPeter Maydellprogress and can make decisions about when to fire the next interrupt or not.
289*9ca6876dSPeter MaydellWhen the credit count is zero, and the first descriptors are posted for the
290*9ca6876dSPeter Maydelldriver, a single interrupt is fired.  Once the interrupt is fired, the
291*9ca6876dSPeter Maydellinterrupt is disabled (auto-masked*).  In response to the interrupt, the driver
292*9ca6876dSPeter Maydellwill process descriptors and PIO write a returned credit value for that
293*9ca6876dSPeter Maydelldescriptor ring.  If the driver returns all credits (the driver caught up with
294*9ca6876dSPeter Maydellthe device and there is no outstanding work), then the interrupt is unmasked,
295*9ca6876dSPeter Maydellbut not fired.  If only partial credits are returned, the interrupt remains
296*9ca6876dSPeter Maydellmasked but the device generates an interrupt, signaling the driver that more
297*9ca6876dSPeter Maydelloutstanding work is available.
298*9ca6876dSPeter Maydell
299*9ca6876dSPeter Maydell(* this masking is unrelated to the MSI-X interrupt mask register)
300*9ca6876dSPeter Maydell
301*9ca6876dSPeter MaydellEndianness
302*9ca6876dSPeter Maydell----------
303*9ca6876dSPeter Maydell
304*9ca6876dSPeter MaydellDevice registers are hard-coded to little-endian (LE).  The driver should
305*9ca6876dSPeter Maydellconvert to/from host endianness to LE for device register accesses.
306*9ca6876dSPeter Maydell
307*9ca6876dSPeter MaydellDescriptors are LE.  Descriptor buffer TLVs will have LE type and length
308*9ca6876dSPeter Maydellfields, but the value field can either be LE or network-byte-order, depending
309*9ca6876dSPeter Maydellon context.  TLV values containing network packet data will be in network-byte
310*9ca6876dSPeter Maydellorder.  A TLV value containing a field or mask used to compare against network
311*9ca6876dSPeter Maydellpacket data is network-byte order.  For example, flow match fields (and masks)
312*9ca6876dSPeter Maydellare network-byte-order since they're matched directly, byte-by-byte, against
313*9ca6876dSPeter Maydellnetwork packet data.  All non-network-packet TLV multi-byte values will be LE.
314*9ca6876dSPeter Maydell
315*9ca6876dSPeter MaydellTLV values in network-byte-order are designated with (N).
316*9ca6876dSPeter Maydell
317*9ca6876dSPeter Maydell
318*9ca6876dSPeter MaydellTest Registers
319*9ca6876dSPeter Maydell==============
320*9ca6876dSPeter Maydell
321*9ca6876dSPeter MaydellRocker has several test registers to support troubleshooting register access,
322*9ca6876dSPeter Maydellinterrupt generation, and DMA operations::
323*9ca6876dSPeter Maydell
324*9ca6876dSPeter Maydell	TEST_REG, offset 0x0010, 32-bit (R/W)
325*9ca6876dSPeter Maydell	TEST_REG64, offset 0x0018, 64-bit (R/W)
326*9ca6876dSPeter Maydell	TEST_IRQ, offset 0x0020, 32-bit (R/W)
327*9ca6876dSPeter Maydell	TEST_DMA_ADDR, offset 0x0028, 64-bit (R/W)
328*9ca6876dSPeter Maydell	TEST_DMA_SIZE, offset 0x0030, 32-bit (R/W)
329*9ca6876dSPeter Maydell	TEST_DMA_CTRL, offset 0x0034, 32-bit (R/W)
330*9ca6876dSPeter Maydell
331*9ca6876dSPeter MaydellReads to TEST_REG and TEST_REG64 will read a value equal to twice the last
332*9ca6876dSPeter Maydellvalue written to the register.  The 32-bit and 64-bit versions are for testing
333*9ca6876dSPeter Maydell32-bit and 64-bit host accesses.
334*9ca6876dSPeter Maydell
335*9ca6876dSPeter MaydellA vector can be written to TEST_IRQ and the device will generate an interrupt
336*9ca6876dSPeter Maydellfor that vector.
337*9ca6876dSPeter Maydell
338*9ca6876dSPeter MaydellTo test basic DMA operations, allocate a DMA-able host buffer and put the
339*9ca6876dSPeter Maydellbuffer address into TEST_DMA_ADDR and size into TEST_DMA_SIZE.  Then, write to
340*9ca6876dSPeter MaydellTEST_DMA_CTRL to manipulate the buffer contents.  TEST_DMA_CTRL operations are::
341*9ca6876dSPeter Maydell
342*9ca6876dSPeter Maydell	operation		value	description
343*9ca6876dSPeter Maydell	-----------------------------------------------------------
344*9ca6876dSPeter Maydell	TEST_DMA_CTRL_CLEAR	1	clear buffer
345*9ca6876dSPeter Maydell	TEST_DMA_CTRL_FILL	2	fill buffer bytes with 0x96
346*9ca6876dSPeter Maydell	TEST_DMA_CTRL_INVERT	4	invert bytes in buffer
347*9ca6876dSPeter Maydell
348*9ca6876dSPeter MaydellVarious buffer address and sizes should be tested to verify no address boundary
349*9ca6876dSPeter Maydellissue exists.  In particular, buffers that start on odd-8-byte boundary and/or
350*9ca6876dSPeter Maydellspan multiple PAGE sizes should be tested.
351*9ca6876dSPeter Maydell
352*9ca6876dSPeter Maydell
353*9ca6876dSPeter MaydellPorts
354*9ca6876dSPeter Maydell=====
355*9ca6876dSPeter Maydell
356*9ca6876dSPeter MaydellPhysical and Logical Ports
357*9ca6876dSPeter Maydell------------------------------------
358*9ca6876dSPeter Maydell
359*9ca6876dSPeter MaydellThe switch supports up to 62 physical (front-panel) ports.  Register
360*9ca6876dSPeter MaydellPORT_PHYS_COUNT returns the actual number of physical ports available::
361*9ca6876dSPeter Maydell
362*9ca6876dSPeter Maydell	PORT_PHYS_COUNT, offset 0x0304, 32-bit, (R)
363*9ca6876dSPeter Maydell
364*9ca6876dSPeter MaydellIn addition to front-panel ports, the switch supports logical ports for
365*9ca6876dSPeter Maydelltunnels.
366*9ca6876dSPeter Maydell
367*9ca6876dSPeter MaydellFront-panel ports and logical tunnel ports are mapped into a single 32-bit port
368*9ca6876dSPeter Maydellspace.  A special CPU port is assigned port 0.  The front-panel ports are
369*9ca6876dSPeter Maydellmapped to ports 1-62.  A special loopback port is assigned port 63.  Logical
370*9ca6876dSPeter Maydelltunnel ports are assigned ports 0x0001000-0x0001ffff.
371*9ca6876dSPeter MaydellTo summarize the port assignments::
372*9ca6876dSPeter Maydell
373*9ca6876dSPeter Maydell	port			mapping
374*9ca6876dSPeter Maydell	-------------------------------------------------------
375*9ca6876dSPeter Maydell	0			CPU port (for packets to/from host CPU)
376*9ca6876dSPeter Maydell	1-62			front-panel physical ports
377*9ca6876dSPeter Maydell	63			loopback port
378*9ca6876dSPeter Maydell	64-0x0000ffff		RSVD
379*9ca6876dSPeter Maydell	0x00010000-0x0001ffff	logical tunnel ports
380*9ca6876dSPeter Maydell	0x00020000-0xffffffff	RSVD
381*9ca6876dSPeter Maydell
382*9ca6876dSPeter MaydellPhysical Port Mode
383*9ca6876dSPeter Maydell------------------
384*9ca6876dSPeter Maydell
385*9ca6876dSPeter MaydellSwitch front-panel ports operate in a mode.  Currently, the only mode is
386*9ca6876dSPeter MaydellOF-DPA.  OF-DPA[1] mode is based on OpenFlow Data Plane Abstraction (OF-DPA)
387*9ca6876dSPeter MaydellAbstract Switch Specification, Version 1.0, from Broadcom Corporation.  To
388*9ca6876dSPeter Maydellset/get the mode for front-panel ports, see port settings, below.
389*9ca6876dSPeter Maydell
390*9ca6876dSPeter MaydellPort Settings
391*9ca6876dSPeter Maydell-------------
392*9ca6876dSPeter Maydell
393*9ca6876dSPeter MaydellLink status for all front-panel ports is available via PORT_PHYS_LINK_STATUS::
394*9ca6876dSPeter Maydell
395*9ca6876dSPeter Maydell	PORT_PHYS_LINK_STATUS, offset 0x0310, 64-bit, (R)
396*9ca6876dSPeter Maydell
397*9ca6876dSPeter Maydell	Value is port bitmap.  Bits 0 and 63 always read 0.  Bits 1-62
398*9ca6876dSPeter Maydell	read 1 for link UP and 0 for link DOWN for respective front-panel ports.
399*9ca6876dSPeter Maydell
400*9ca6876dSPeter MaydellOther properties for front-panel ports are available via DMA CMD descriptors::
401*9ca6876dSPeter Maydell
402*9ca6876dSPeter Maydell	Get PORT_SETTINGS descriptor:
403*9ca6876dSPeter Maydell
404*9ca6876dSPeter Maydell		field		width	description
405*9ca6876dSPeter Maydell		----------------------------------------------
406*9ca6876dSPeter Maydell		PORT_SETTINGS	2	CMD_GET
407*9ca6876dSPeter Maydell		PPORT		4	Physical port #
408*9ca6876dSPeter Maydell
409*9ca6876dSPeter Maydell	Get PORT_SETTINGS completion:
410*9ca6876dSPeter Maydell
411*9ca6876dSPeter Maydell		field		width	description
412*9ca6876dSPeter Maydell		----------------------------------------------
413*9ca6876dSPeter Maydell		PPORT		4	Physical port #
414*9ca6876dSPeter Maydell		SPEED		4	Current port interface speed, in Mbps
415*9ca6876dSPeter Maydell		DUPLEX		1	1 = Full, 0 = Half
416*9ca6876dSPeter Maydell		AUTONEG		1	1 = enabled, 0 = disabled
417*9ca6876dSPeter Maydell		MACADDR		6	Port MAC address
418*9ca6876dSPeter Maydell		MODE		1	0 = OF-DPA
419*9ca6876dSPeter Maydell		LEARNING	1	MAC address learning on port
420*9ca6876dSPeter Maydell						1 = enabled
421*9ca6876dSPeter Maydell						0 = disabled
422*9ca6876dSPeter Maydell		PHYS_NAME	<var>	Physical port name (string)
423*9ca6876dSPeter Maydell
424*9ca6876dSPeter Maydell	Set PORT_SETTINGS descriptor:
425*9ca6876dSPeter Maydell
426*9ca6876dSPeter Maydell		field		width	description
427*9ca6876dSPeter Maydell		----------------------------------------------
428*9ca6876dSPeter Maydell		PORT_SETTINGS	2	CMD_SET
429*9ca6876dSPeter Maydell		PPORT		4	Physical port #
430*9ca6876dSPeter Maydell		SPEED		4	Port interface speed, in Mbps
431*9ca6876dSPeter Maydell		DUPLEX		1	1 = Full, 0 = Half
432*9ca6876dSPeter Maydell		AUTONEG		1	1 = enabled, 0 = disabled
433*9ca6876dSPeter Maydell		MACADDR		6	Port MAC address
434*9ca6876dSPeter Maydell		MODE		1	0 = OF-DPA
435*9ca6876dSPeter Maydell
436*9ca6876dSPeter MaydellPort Enable
437*9ca6876dSPeter Maydell-----------
438*9ca6876dSPeter Maydell
439*9ca6876dSPeter MaydellFront-panel ports are initially disabled, which means port ingress and egress
440*9ca6876dSPeter Maydellpackets will be dropped.  To enable or disable a port, use PORT_PHYS_ENABLE::
441*9ca6876dSPeter Maydell
442*9ca6876dSPeter Maydell	PORT_PHYS_ENABLE: offset 0x0318, 64-bit, (R/W)
443*9ca6876dSPeter Maydell
444*9ca6876dSPeter Maydell	Value is bitmap of first 64 ports.  Bits 0 and 63 are ignored
445*9ca6876dSPeter Maydell	and always read as 0.  Write 1 to enable port; write 0 to disable it.
446*9ca6876dSPeter Maydell	Default is 0.
447*9ca6876dSPeter Maydell
448*9ca6876dSPeter Maydell
449*9ca6876dSPeter MaydellSwitch Control
450*9ca6876dSPeter Maydell==============
451*9ca6876dSPeter Maydell
452*9ca6876dSPeter MaydellThis section covers switch-wide register settings.
453*9ca6876dSPeter Maydell
454*9ca6876dSPeter MaydellControl
455*9ca6876dSPeter Maydell-------
456*9ca6876dSPeter Maydell
457*9ca6876dSPeter MaydellThis register is used for low level control of the switch::
458*9ca6876dSPeter Maydell
459*9ca6876dSPeter Maydell	CONTROL: offset 0x0300, 32-bit, (W)
460*9ca6876dSPeter Maydell
461*9ca6876dSPeter Maydell	bit	name		description
462*9ca6876dSPeter Maydell	------------------------------------------------------------------------
463*9ca6876dSPeter Maydell	[0]	CONTROL_RESET	If set, device will perform reset
464*9ca6876dSPeter Maydell	[1:31]	Reserved
465*9ca6876dSPeter Maydell
466*9ca6876dSPeter MaydellSwitch ID
467*9ca6876dSPeter Maydell---------
468*9ca6876dSPeter Maydell
469*9ca6876dSPeter MaydellThe switch has a SWITCH_ID to be used by software to uniquely identify the
470*9ca6876dSPeter Maydellswitch::
471*9ca6876dSPeter Maydell
472*9ca6876dSPeter Maydell	SWITCH_ID: offset 0x0320, 64-bit, (R)
473*9ca6876dSPeter Maydell
474*9ca6876dSPeter Maydell	Value is opaque to switch software and no special encoding is implied.
475*9ca6876dSPeter Maydell
476*9ca6876dSPeter Maydell
477*9ca6876dSPeter MaydellEvents
478*9ca6876dSPeter Maydell======
479*9ca6876dSPeter Maydell
480*9ca6876dSPeter MaydellNon-I/O asynchronous events from the device are notified to the host using the
481*9ca6876dSPeter Maydellevent ring.  The TLV structure for events is::
482*9ca6876dSPeter Maydell
483*9ca6876dSPeter Maydell	field		width	description
484*9ca6876dSPeter Maydell	---------------------------------------------------
485*9ca6876dSPeter Maydell	TYPE		4	Event type, one of:
486*9ca6876dSPeter Maydell					1: LINK_CHANGED
487*9ca6876dSPeter Maydell					2: MAC_VLAN_SEEN
488*9ca6876dSPeter Maydell	INFO		<nest>	Event info (details below)
489*9ca6876dSPeter Maydell
490*9ca6876dSPeter MaydellLink Changed Event
491*9ca6876dSPeter Maydell------------------
492*9ca6876dSPeter Maydell
493*9ca6876dSPeter MaydellWhen link status changes on a physical port, this event is generated::
494*9ca6876dSPeter Maydell
495*9ca6876dSPeter Maydell	field		width	description
496*9ca6876dSPeter Maydell	---------------------------------------------------
497*9ca6876dSPeter Maydell	INFO		<nest>
498*9ca6876dSPeter Maydell	  PPORT		4	Physical port
499*9ca6876dSPeter Maydell	  LINKUP	1	Link status:
500*9ca6876dSPeter Maydell					0: down
501*9ca6876dSPeter Maydell					1: up
502*9ca6876dSPeter Maydell
503*9ca6876dSPeter MaydellMAC VLAN Seen Event
504*9ca6876dSPeter Maydell-------------------
505*9ca6876dSPeter Maydell
506*9ca6876dSPeter MaydellWhen a packet ingresses on a port and the source MAC/VLAN isn't known to the
507*9ca6876dSPeter Maydelldevice, the device will generate this event.  In response to the event, the
508*9ca6876dSPeter Maydelldriver should install to the device the MAC/VLAN on the port into the bridge
509*9ca6876dSPeter Maydelltable.  Once installed, the MAC/VLAN is known on the port and this event will
510*9ca6876dSPeter Maydellno longer be generated.
511*9ca6876dSPeter Maydell
512*9ca6876dSPeter Maydell::
513*9ca6876dSPeter Maydell
514*9ca6876dSPeter Maydell	field		width	description
515*9ca6876dSPeter Maydell	---------------------------------------------------
516*9ca6876dSPeter Maydell	INFO		<nest>
517*9ca6876dSPeter Maydell	  PPORT		4	Physical port
518*9ca6876dSPeter Maydell	  MAC		6	MAC address
519*9ca6876dSPeter Maydell	  VLAN		2	VLAN ID
520*9ca6876dSPeter Maydell
521*9ca6876dSPeter Maydell
522*9ca6876dSPeter MaydellCPU Packet Processing
523*9ca6876dSPeter Maydell=====================
524*9ca6876dSPeter Maydell
525*9ca6876dSPeter MaydellIngress packets directed to the host CPU for further processing are delivered
526*9ca6876dSPeter Maydellin the DMA RX ring.  Likewise, host CPU originating packets destined to egress
527*9ca6876dSPeter Maydellon switch ports are scheduled by software using the DMA TX ring.
528*9ca6876dSPeter Maydell
529*9ca6876dSPeter MaydellTx Packet Processing
530*9ca6876dSPeter Maydell--------------------
531*9ca6876dSPeter Maydell
532*9ca6876dSPeter MaydellSoftware schedules packets for egress on switch ports using the DMA TX ring.  A
533*9ca6876dSPeter MaydellTX descriptor buffer describes the packet location and size in host DMA-able
534*9ca6876dSPeter Maydellmemory, the destination port, and any hardware-offload functions (such as L3
535*9ca6876dSPeter Maydellpayload checksum offload).  Software then bumps the descriptor head to signal
536*9ca6876dSPeter Maydellhardware of new Tx work.  In response, hardware will DMA read Tx descriptors up
537*9ca6876dSPeter Maydellto head, DMA read descriptor buffer and packet data, perform offloading
538*9ca6876dSPeter Maydellfunctions, and finally frame packet on wire (network).  Once packet processing
539*9ca6876dSPeter Maydellis complete, hardware will writeback status to descriptor(s) to signal to
540*9ca6876dSPeter Maydellsoftware that Tx is complete and software resources (e.g. skb) backing packet
541*9ca6876dSPeter Maydellcan be released.
542*9ca6876dSPeter Maydell
543*9ca6876dSPeter MaydellFigure 2 shows an example 3-fragment packet queued with one Tx descriptor.  A
544*9ca6876dSPeter MaydellTLV is used for each packet fragment::
545*9ca6876dSPeter Maydell
546*9ca6876dSPeter Maydell	                                           pkt frag 1
547*9ca6876dSPeter Maydell	                                           +–––––––+  +–+
548*9ca6876dSPeter Maydell	                                       +–––+       |    |
549*9ca6876dSPeter Maydell	                         desc buf      |   |       |    |
550*9ca6876dSPeter Maydell	                        +––––––––+     |   |       |    |
551*9ca6876dSPeter Maydell	        Tx ring     +–––+        +–––––+   |       |    |
552*9ca6876dSPeter Maydell	      +–––––––––+   |   |  TLVs  |         +–––––––+    |
553*9ca6876dSPeter Maydell	      |         +–––+   +––––––––+         pkt frag 2   |
554*9ca6876dSPeter Maydell	      | desc 0  |       |        +–––––+   +–––––––+    |
555*9ca6876dSPeter Maydell	      +–––––––––+       |  TLVs  |     +–––+       |    |
556*9ca6876dSPeter Maydell	head+–+         |       +––––––––+         |       |    |
557*9ca6876dSPeter Maydell	      | desc 1  |       |        +–––––+   +–––––––+    |pkt
558*9ca6876dSPeter Maydell	      +–––––––––+       |  TLVs  |     |                |
559*9ca6876dSPeter Maydell	      |         |       +––––––––+     |   pkt frag 3   |
560*9ca6876dSPeter Maydell	      |         |                      |   +–––––––+    |
561*9ca6876dSPeter Maydell	      +–––––––––+                      +–––+       |    |
562*9ca6876dSPeter Maydell	      |         |                          |       |    |
563*9ca6876dSPeter Maydell	      |         |                          |       |    |
564*9ca6876dSPeter Maydell	      +–––––––––+                          |       |    |
565*9ca6876dSPeter Maydell	      |         |                          |       |    |
566*9ca6876dSPeter Maydell	      |         |                          |       |    |
567*9ca6876dSPeter Maydell	      +–––––––––+                          |       |    |
568*9ca6876dSPeter Maydell	      |         |                          +–––––––+  +–+
569*9ca6876dSPeter Maydell	      |         |
570*9ca6876dSPeter Maydell	      +–––––––––+
571*9ca6876dSPeter Maydell
572*9ca6876dSPeter Maydell				fig 2.
573*9ca6876dSPeter Maydell
574*9ca6876dSPeter MaydellThe TLVs for Tx descriptor buffer are::
575*9ca6876dSPeter Maydell
576*9ca6876dSPeter Maydell	field			width	description
577*9ca6876dSPeter Maydell	---------------------------------------------------------------------
578*9ca6876dSPeter Maydell	PPORT			4	Destination physical port #
579*9ca6876dSPeter Maydell	TX_OFFLOAD		1	Hardware offload modes:
580*9ca6876dSPeter Maydell					  0: no offload
581*9ca6876dSPeter Maydell					  1: insert IP csum (ipv4 only)
582*9ca6876dSPeter Maydell					  2: insert TCP/UDP csum
583*9ca6876dSPeter Maydell					  3: L3 csum calc and insert
584*9ca6876dSPeter Maydell                        	             into csum offset (TX_L3_CSUM_OFF)
585*9ca6876dSPeter Maydell                 	                    16-bit 1's complement csum value.
586*9ca6876dSPeter Maydell                                	     IPv4 pseudo-header and IP
587*9ca6876dSPeter Maydell                        	             already calculated by OS
588*9ca6876dSPeter Maydell                  	                   and inserted.
589*9ca6876dSPeter Maydell					  4: TSO (TCP Segmentation Offload)
590*9ca6876dSPeter Maydell	TX_L3_CSUM_OFF		2	For L3 csum offload mode, the offset,
591*9ca6876dSPeter Maydell					from the beginning of the packet,
592*9ca6876dSPeter Maydell					of the csum field in the L3 header
593*9ca6876dSPeter Maydell	TX_TSO_MSS		2	For TSO offload mode, the
594*9ca6876dSPeter Maydell					Maximum Segment Size in bytes
595*9ca6876dSPeter Maydell        TX_TSO_HDR_LEN		2	For TSO offload mode, the
596*9ca6876dSPeter Maydell					length of ethernet, IP, and
597*9ca6876dSPeter Maydell					TCP/UDP headers, including IP
598*9ca6876dSPeter Maydell					and TCP options.
599*9ca6876dSPeter Maydell	TX_FRAGS		<array>	Packet fragments
600*9ca6876dSPeter Maydell	  TX_FRAG		<nest>	Packet fragment
601*9ca6876dSPeter Maydell	    TX_FRAG_ADDR	8	DMA address of packet fragment
602*9ca6876dSPeter Maydell	    TX_FRAG_LEN		2	Packet fragment length
603*9ca6876dSPeter Maydell
604*9ca6876dSPeter MaydellPossible status return codes in descriptor on completion are::
605*9ca6876dSPeter Maydell
606*9ca6876dSPeter Maydell	DESC_COMP_ERR	reason
607*9ca6876dSPeter Maydell	--------------------------------------------------------------------
608*9ca6876dSPeter Maydell	0		OK
609*9ca6876dSPeter Maydell	-ROCKER_ENXIO	address or data read err on desc buf or packet
610*9ca6876dSPeter Maydell			fragment
611*9ca6876dSPeter Maydell	-ROCKER_EINVAL	bad pport or TSO or csum offloading error
612*9ca6876dSPeter Maydell	-ROCKER_ENOMEM	no memory for internal staging tx fragment
613*9ca6876dSPeter Maydell
614*9ca6876dSPeter MaydellRx Packet Processing
615*9ca6876dSPeter Maydell--------------------
616*9ca6876dSPeter Maydell
617*9ca6876dSPeter MaydellFor packets ingressing on switch ports that are not forwarded by the switch but
618*9ca6876dSPeter Maydellrather directed to the host CPU for further processing are delivered in the DMA
619*9ca6876dSPeter MaydellRX ring.  Rx descriptor buffers are allocated by software and placed on the
620*9ca6876dSPeter Maydellring.  Hardware will fill Rx descriptor buffers with packet data, write the
621*9ca6876dSPeter Maydellcompletion, and signal to software that a new packet is ready.  Since Rx packet
622*9ca6876dSPeter Maydellsize is not known a-priori, the Rx descriptor buffer must be allocated for
623*9ca6876dSPeter Maydellworst-case packet size.  A single Rx descriptor will contain the entire Rx
624*9ca6876dSPeter Maydellpacket data in one RX_FRAG.  Other Rx TLVs describe and hardware offloads
625*9ca6876dSPeter Maydellperformed on the packet, such as checksum validation.
626*9ca6876dSPeter Maydell
627*9ca6876dSPeter MaydellThe TLVs for Rx descriptor buffer are::
628*9ca6876dSPeter Maydell
629*9ca6876dSPeter Maydell	field		width	description
630*9ca6876dSPeter Maydell	---------------------------------------------------
631*9ca6876dSPeter Maydell	PPORT		4	Source physical port #
632*9ca6876dSPeter Maydell	RX_FLAGS	2	Packet parsing flags:
633*9ca6876dSPeter Maydell				  (1 << 0): IPv4 packet
634*9ca6876dSPeter Maydell				  (1 << 1): IPv6 packet
635*9ca6876dSPeter Maydell				  (1 << 2): csum calculated
636*9ca6876dSPeter Maydell				  (1 << 3): IPv4 csum good
637*9ca6876dSPeter Maydell				  (1 << 4): IP fragment
638*9ca6876dSPeter Maydell				  (1 << 5): TCP packet
639*9ca6876dSPeter Maydell				  (1 << 6): UDP packet
640*9ca6876dSPeter Maydell				  (1 << 7): TCP/UDP csum good
641*9ca6876dSPeter Maydell				  (1 << 8): Offload forward
642*9ca6876dSPeter Maydell	RX_CSUM		2	IP calculated checksum:
643*9ca6876dSPeter Maydell				  IPv4: IP payload csum
644*9ca6876dSPeter Maydell				  IPv6: header and payload csum
645*9ca6876dSPeter Maydell				(Only valid is RX_FLAGS:csum calc is set)
646*9ca6876dSPeter Maydell	RX_FRAG_ADDR	8	DMA address of packet fragment
647*9ca6876dSPeter Maydell	RX_FRAG_MAX_LEN	2	Packet maximum fragment length
648*9ca6876dSPeter Maydell	RX_FRAG_LEN	2	Actual packet fragment length after receive
649*9ca6876dSPeter Maydell
650*9ca6876dSPeter MaydellOffload forward RX_FLAG indicates the device has already forwarded the packet
651*9ca6876dSPeter Maydellso the host CPU should not also forward the packet.
652*9ca6876dSPeter Maydell
653*9ca6876dSPeter MaydellPossible status return codes in descriptor on completion are::
654*9ca6876dSPeter Maydell
655*9ca6876dSPeter Maydell	DESC_COMP_ERR	reason
656*9ca6876dSPeter Maydell	--------------------------------------------------------------------
657*9ca6876dSPeter Maydell	0		OK
658*9ca6876dSPeter Maydell	-ROCKER_ENXIO	address or data read err on desc buf
659*9ca6876dSPeter Maydell	-ROCKER_ENOMEM	no memory for internal staging desc buf
660*9ca6876dSPeter Maydell	-ROCKER_EMSGSIZE Rx descriptor buffer wasn't big enough to contain
661*9ca6876dSPeter Maydell			packet data TLV and other TLVs.
662*9ca6876dSPeter Maydell
663*9ca6876dSPeter Maydell
664*9ca6876dSPeter MaydellOF-DPA Mode
665*9ca6876dSPeter Maydell===========
666*9ca6876dSPeter Maydell
667*9ca6876dSPeter MaydellOF-DPA mode allows the switch to offload flow packet processing functions to
668*9ca6876dSPeter Maydellhardware.  An OpenFlow controller would communicate with an OpenFlow agent
669*9ca6876dSPeter Maydellinstalled on the switch.  The OpenFlow agent would (directly or indirectly)
670*9ca6876dSPeter Maydellcommunicate with the Rocker switch driver, which in turn would program switch
671*9ca6876dSPeter Maydellhardware with flow functionality, as defined in OF-DPA.  The block diagram is::
672*9ca6876dSPeter Maydell
673*9ca6876dSPeter Maydell		+–––––––––––––––----–––+
674*9ca6876dSPeter Maydell		|        OF            |
675*9ca6876dSPeter Maydell		|  Remote Controller   |
676*9ca6876dSPeter Maydell		+––––––––+––----–––––––+
677*9ca6876dSPeter Maydell		         |
678*9ca6876dSPeter Maydell		         |
679*9ca6876dSPeter Maydell		+––––––––+–––––––––+
680*9ca6876dSPeter Maydell		|       OF         |
681*9ca6876dSPeter Maydell		|   Local Agent    |
682*9ca6876dSPeter Maydell		+––––––––––––––––––+
683*9ca6876dSPeter Maydell		|                  |
684*9ca6876dSPeter Maydell		|   Rocker Driver  |
685*9ca6876dSPeter Maydell		+––––––––––––––––––+
686*9ca6876dSPeter Maydell		    <this spec>
687*9ca6876dSPeter Maydell		+––––––––––––––––––+
688*9ca6876dSPeter Maydell		|                  |
689*9ca6876dSPeter Maydell		|   Rocker Switch  |
690*9ca6876dSPeter Maydell		+––––––––––––––––––+
691*9ca6876dSPeter Maydell
692*9ca6876dSPeter MaydellTo participate in flow functions, ports must be configure for OF-DPA mode
693*9ca6876dSPeter Maydellduring switch initialization.
694*9ca6876dSPeter Maydell
695*9ca6876dSPeter MaydellOF-DPA Flow Table Interface
696*9ca6876dSPeter Maydell---------------------------
697*9ca6876dSPeter Maydell
698*9ca6876dSPeter MaydellThere are commands to add, modify, delete, and get stats of flow table entries.
699*9ca6876dSPeter MaydellThe commands are issued using the DMA CMD descriptor ring.  The following
700*9ca6876dSPeter Maydellcommands are defined::
701*9ca6876dSPeter Maydell
702*9ca6876dSPeter Maydell	CMD_ADD:		add an entry to flow table
703*9ca6876dSPeter Maydell	CMD_MOD:		modify an entry in flow table
704*9ca6876dSPeter Maydell	CMD_DEL:		delete an entry from flow table
705*9ca6876dSPeter Maydell	CMD_GET_STATS:		get stats for flow entry
706*9ca6876dSPeter Maydell
707*9ca6876dSPeter MaydellTLVs for add and modify commands are::
708*9ca6876dSPeter Maydell
709*9ca6876dSPeter Maydell	field			width	description
710*9ca6876dSPeter Maydell	----------------------------------------------------
711*9ca6876dSPeter Maydell	OF_DPA_CMD		2	CMD_[ADD|MOD]
712*9ca6876dSPeter Maydell	OF_DPA_TBL		2	Flow table ID
713*9ca6876dSPeter Maydell					  0: ingress port
714*9ca6876dSPeter Maydell					  10: vlan
715*9ca6876dSPeter Maydell					  20: termination mac
716*9ca6876dSPeter Maydell					  30: unicast routing
717*9ca6876dSPeter Maydell					  40: multicast routing
718*9ca6876dSPeter Maydell					  50: bridging
719*9ca6876dSPeter Maydell					  60: ACL policy
720*9ca6876dSPeter Maydell	OF_DPA_PRIORITY		4	Flow priority
721*9ca6876dSPeter Maydell	OF_DPA_HARDTIME		4	Hard timeout for flow
722*9ca6876dSPeter Maydell	OF_DPA_IDLETIME		4	Idle timeout for flow
723*9ca6876dSPeter Maydell	OF_DPA_COOKIE		8	Cookie
724*9ca6876dSPeter Maydell
725*9ca6876dSPeter MaydellAdditional TLVs based on flow table ID:
726*9ca6876dSPeter Maydell
727*9ca6876dSPeter MaydellTable ID 0: ingress port::
728*9ca6876dSPeter Maydell
729*9ca6876dSPeter Maydell	field			width	description
730*9ca6876dSPeter Maydell	----------------------------------------------------
731*9ca6876dSPeter Maydell	OF_DPA_IN_PPORT		4	ingress physical port number
732*9ca6876dSPeter Maydell	OF_DPA_GOTO_TBL		2	goto table ID; zero to drop
733*9ca6876dSPeter Maydell
734*9ca6876dSPeter MaydellTable ID 10: vlan::
735*9ca6876dSPeter Maydell
736*9ca6876dSPeter Maydell	field			width	description
737*9ca6876dSPeter Maydell	----------------------------------------------------
738*9ca6876dSPeter Maydell	OF_DPA_IN_PPORT		4	ingress physical port number
739*9ca6876dSPeter Maydell	OF_DPA_VLAN_ID		2 (N)	vlan ID
740*9ca6876dSPeter Maydell	OF_DPA_VLAN_ID_MASK	2 (N)	vlan ID mask
741*9ca6876dSPeter Maydell	OF_DPA_GOTO_TBL		2	goto table ID; zero to drop
742*9ca6876dSPeter Maydell	OF_DPA_NEW_VLAN_ID	2 (N)	new vlan ID
743*9ca6876dSPeter Maydell
744*9ca6876dSPeter MaydellTable ID 20: termination mac::
745*9ca6876dSPeter Maydell
746*9ca6876dSPeter Maydell	field			width	description
747*9ca6876dSPeter Maydell	----------------------------------------------------
748*9ca6876dSPeter Maydell	OF_DPA_IN_PPORT		4	ingress physical port number
749*9ca6876dSPeter Maydell	OF_DPA_IN_PPORT_MASK	4	ingress physical port number mask
750*9ca6876dSPeter Maydell	OF_DPA_ETHERTYPE	2 (N)	must be either 0x0800 or 0x86dd
751*9ca6876dSPeter Maydell	OF_DPA_DST_MAC		6 (N)	destination MAC
752*9ca6876dSPeter Maydell	OF_DPA_DST_MAC_MASK	6 (N)	destination MAC mask
753*9ca6876dSPeter Maydell	OF_DPA_VLAN_ID		2 (N)	vlan ID
754*9ca6876dSPeter Maydell	OF_DPA_VLAN_ID_MASK	2 (N)	vlan ID mask
755*9ca6876dSPeter Maydell	OF_DPA_GOTO_TBL		2	only acceptable values are
756*9ca6876dSPeter Maydell					unicast or multicast routing
757*9ca6876dSPeter Maydell					table IDs
758*9ca6876dSPeter Maydell	OF_DPA_OUT_PPORT	2	if specified, must be
759*9ca6876dSPeter Maydell					controller, set zero otherwise
760*9ca6876dSPeter Maydell
761*9ca6876dSPeter MaydellTable ID 30: unicast routing::
762*9ca6876dSPeter Maydell
763*9ca6876dSPeter Maydell	field			width	description
764*9ca6876dSPeter Maydell	----------------------------------------------------
765*9ca6876dSPeter Maydell	OF_DPA_ETHERTYPE	2 (N)	must be either 0x0800 or 0x86dd
766*9ca6876dSPeter Maydell	OF_DPA_DST_IP		4 (N)	destination IPv4 address.
767*9ca6876dSPeter Maydell					Must be unicast address
768*9ca6876dSPeter Maydell	OF_DPA_DST_IP_MASK	4 (N)	IP mask.  Must be prefix mask
769*9ca6876dSPeter Maydell	OF_DPA_DST_IPV6		16 (N)	destination IPv6 address.
770*9ca6876dSPeter Maydell					Must be unicast address
771*9ca6876dSPeter Maydell	OF_DPA_DST_IPV6_MASK	16 (N)	IPv6 mask. Must be prefix mask
772*9ca6876dSPeter Maydell	OF_DPA_GOTO_TBL		2	goto table ID; zero to drop
773*9ca6876dSPeter Maydell	OF_DPA_GROUP_ID		4	data for GROUP action must
774*9ca6876dSPeter Maydell					be an L3 Unicast group entry
775*9ca6876dSPeter Maydell
776*9ca6876dSPeter MaydellTable ID 40: multicast routing::
777*9ca6876dSPeter Maydell
778*9ca6876dSPeter Maydell	field			width	description
779*9ca6876dSPeter Maydell	----------------------------------------------------
780*9ca6876dSPeter Maydell	OF_DPA_ETHERTYPE	2 (N)	must be either 0x0800 or 0x86dd
781*9ca6876dSPeter Maydell	OF_DPA_VLAN_ID		2 (N)	vlan ID
782*9ca6876dSPeter Maydell	OF_DPA_SRC_IP		4 (N)	source IPv4. Optional,
783*9ca6876dSPeter Maydell					can contain IPv4 address,
784*9ca6876dSPeter Maydell					must be completely masked
785*9ca6876dSPeter Maydell					if not used
786*9ca6876dSPeter Maydell	OF_DPA_SRC_IP_MASK	4 (N)	IP Mask
787*9ca6876dSPeter Maydell	OF_DPA_DST_IP		4 (N)	destination IPv4 address.
788*9ca6876dSPeter Maydell					Must be multicast address
789*9ca6876dSPeter Maydell	OF_DPA_SRC_IPV6		16 (N)	source IPv6 Address. Optional.
790*9ca6876dSPeter Maydell					Can contain IPv6 address,
791*9ca6876dSPeter Maydell					must be completely masked
792*9ca6876dSPeter Maydell					if not used
793*9ca6876dSPeter Maydell	OF_DPA_SRC_IPV6_MASK	16 (N)	IPv6 mask.
794*9ca6876dSPeter Maydell	OF_DPA_DST_IPV6		16 (N)	destination IPv6 Address. Must
795*9ca6876dSPeter Maydell					be multicast address
796*9ca6876dSPeter Maydell					Must be multicast address
797*9ca6876dSPeter Maydell	OF_DPA_GOTO_TBL		2	goto table ID; zero to drop
798*9ca6876dSPeter Maydell	OF_DPA_GROUP_ID		4	data for GROUP action must
799*9ca6876dSPeter Maydell					be an L3 multicast group entry
800*9ca6876dSPeter Maydell
801*9ca6876dSPeter MaydellTable ID 50: bridging::
802*9ca6876dSPeter Maydell
803*9ca6876dSPeter Maydell	field			width	description
804*9ca6876dSPeter Maydell	----------------------------------------------------
805*9ca6876dSPeter Maydell	OF_DPA_VLAN_ID		2 (N)	vlan ID
806*9ca6876dSPeter Maydell	OF_DPA_TUNNEL_ID	4	tunnel ID
807*9ca6876dSPeter Maydell	OF_DPA_DST_MAC		6 (N)	destination MAC
808*9ca6876dSPeter Maydell	OF_DPA_DST_MAC_MASK	6 (N)	destination MAC mask
809*9ca6876dSPeter Maydell	OF_DPA_GOTO_TBL		2	goto table ID; zero to drop
810*9ca6876dSPeter Maydell	OF_DPA_GROUP_ID		4	data for GROUP action must
811*9ca6876dSPeter Maydell					be a L2 Interface, L2
812*9ca6876dSPeter Maydell					Multicast, L2 Flood,
813*9ca6876dSPeter Maydell					or L2 Overlay group entry
814*9ca6876dSPeter Maydell					as appropriate
815*9ca6876dSPeter Maydell	OF_DPA_TUNNEL_LPORT	4	unicast Tenant Bridging
816*9ca6876dSPeter Maydell					flows specify a tunnel
817*9ca6876dSPeter Maydell					logical port ID
818*9ca6876dSPeter Maydell	OF_DPA_OUT_PPORT	2	data for OUTPUT action,
819*9ca6876dSPeter Maydell					restricted to CONTROLLER,
820*9ca6876dSPeter Maydell					set to 0 otherwise
821*9ca6876dSPeter Maydell
822*9ca6876dSPeter MaydellTable ID 60: acl policy::
823*9ca6876dSPeter Maydell
824*9ca6876dSPeter Maydell	field			width	description
825*9ca6876dSPeter Maydell	----------------------------------------------------
826*9ca6876dSPeter Maydell	OF_DPA_IN_PPORT		4	ingress physical port number
827*9ca6876dSPeter Maydell	OF_DPA_IN_PPORT_MASK	4	ingress physical port number mask
828*9ca6876dSPeter Maydell	OF_DPA_ETHERTYPE	2 (N)	ethertype
829*9ca6876dSPeter Maydell	OF_DPA_VLAN_ID		2 (N)	vlan ID
830*9ca6876dSPeter Maydell	OF_DPA_VLAN_ID_MASK	2 (N)	vlan ID mask
831*9ca6876dSPeter Maydell	OF_DPA_VLAN_PCP		2 (N)	vlan Priority Code Point
832*9ca6876dSPeter Maydell	OF_DPA_VLAN_PCP_MASK	2 (N)	vlan Priority Code Point mask
833*9ca6876dSPeter Maydell	OF_DPA_SRC_MAC		6 (N)	source MAC
834*9ca6876dSPeter Maydell	OF_DPA_SRC_MAC_MASK	6 (N)	source MAC mask
835*9ca6876dSPeter Maydell	OF_DPA_DST_MAC		6 (N)	destination MAC
836*9ca6876dSPeter Maydell	OF_DPA_DST_MAC_MASK	6 (N)	destination MAC mask
837*9ca6876dSPeter Maydell	OF_DPA_TUNNEL_ID	4	tunnel ID
838*9ca6876dSPeter Maydell	OF_DPA_SRC_IP		4 (N)	source IPv4. Optional,
839*9ca6876dSPeter Maydell					can contain IPv4 address,
840*9ca6876dSPeter Maydell					must be completely masked
841*9ca6876dSPeter Maydell					if not used
842*9ca6876dSPeter Maydell	OF_DPA_SRC_IP_MASK	4 (N)	IP Mask
843*9ca6876dSPeter Maydell	OF_DPA_DST_IP		4 (N)	destination IPv4 address.
844*9ca6876dSPeter Maydell					Must be multicast address
845*9ca6876dSPeter Maydell	OF_DPA_DST_IP_MASK	4 (N)	IP Mask
846*9ca6876dSPeter Maydell	OF_DPA_SRC_IPV6		16 (N)	source IPv6 Address. Optional.
847*9ca6876dSPeter Maydell					Can contain IPv6 address,
848*9ca6876dSPeter Maydell					must be completely masked
849*9ca6876dSPeter Maydell					if not used
850*9ca6876dSPeter Maydell	OF_DPA_SRC_IPV6_MASK	16 (N)	IPv6 mask
851*9ca6876dSPeter Maydell	OF_DPA_DST_IPV6		16 (N)	destination IPv6 Address. Must
852*9ca6876dSPeter Maydell					be multicast address.
853*9ca6876dSPeter Maydell	OF_DPA_DST_IPV6_MASK	16 (N)	IPv6 mask
854*9ca6876dSPeter Maydell	OF_DPA_SRC_ARP_IP	4 (N)	source IPv4 address in the ARP
855*9ca6876dSPeter Maydell					payload.  Only used if ethertype
856*9ca6876dSPeter Maydell					== 0x0806.
857*9ca6876dSPeter Maydell	OF_DPA_SRC_ARP_IP_MASK	4 (N)	IP Mask
858*9ca6876dSPeter Maydell	OF_DPA_IP_PROTO		1	IP protocol
859*9ca6876dSPeter Maydell	OF_DPA_IP_PROTO_MASK	1	IP protocol mask
860*9ca6876dSPeter Maydell	OF_DPA_IP_DSCP		1	DSCP
861*9ca6876dSPeter Maydell	OF_DPA_IP_DSCP_MASK	1	DSCP mask
862*9ca6876dSPeter Maydell	OF_DPA_IP_ECN		1	ECN
863*9ca6876dSPeter Maydell	OF_DPA_IP_ECN_MASK		1	ECN mask
864*9ca6876dSPeter Maydell	OF_DPA_L4_SRC_PORT	2 (N)	L4 source port, only for
865*9ca6876dSPeter Maydell					TCP, UDP, or SCTP
866*9ca6876dSPeter Maydell	OF_DPA_L4_SRC_PORT_MASK	2 (N)	L4 source port mask
867*9ca6876dSPeter Maydell	OF_DPA_L4_DST_PORT	2 (N)	L4 source port, only for
868*9ca6876dSPeter Maydell					TCP, UDP, or SCTP
869*9ca6876dSPeter Maydell	OF_DPA_L4_DST_PORT_MASK	2 (N)	L4 source port mask
870*9ca6876dSPeter Maydell	OF_DPA_ICMP_TYPE	1	ICMP type, only if IP
871*9ca6876dSPeter Maydell					protocol is 1
872*9ca6876dSPeter Maydell	OF_DPA_ICMP_TYPE_MASK	1	ICMP type mask
873*9ca6876dSPeter Maydell	OF_DPA_ICMP_CODE	1	ICMP code
874*9ca6876dSPeter Maydell	OF_DPA_ICMP_CODE_MASK	1	ICMP code mask
875*9ca6876dSPeter Maydell	OF_DPA_IPV6_LABEL	4 (N)	IPv6 flow label
876*9ca6876dSPeter Maydell	OF_DPA_IPV6_LABEL_MASK	4 (N)	IPv6 flow label mask
877*9ca6876dSPeter Maydell	OF_DPA_GROUP_ID		4	data for GROUP action
878*9ca6876dSPeter Maydell	OF_DPA_QUEUE_ID_ACTION	1	write the queue ID
879*9ca6876dSPeter Maydell	OF_DPA_NEW_QUEUE_ID	1	queue ID
880*9ca6876dSPeter Maydell	OF_DPA_VLAN_PCP_ACTION	1	write the VLAN priority
881*9ca6876dSPeter Maydell	OF_DPA_NEW_VLAN_PCP	1	VLAN priority
882*9ca6876dSPeter Maydell	OF_DPA_IP_DSCP_ACTION	1	write the DSCP
883*9ca6876dSPeter Maydell	OF_DPA_NEW_IP_DSCP	1	new DSCP
884*9ca6876dSPeter Maydell	OF_DPA_TUNNEL_LPORT	4	restrct to valid tunnel
885*9ca6876dSPeter Maydell					logical port, set to 0
886*9ca6876dSPeter Maydell					otherwise.
887*9ca6876dSPeter Maydell	OF_DPA_OUT_PPORT	2	data for OUTPUT action,
888*9ca6876dSPeter Maydell					restricted to CONTROLLER,
889*9ca6876dSPeter Maydell					set to 0 otherwise
890*9ca6876dSPeter Maydell	OF_DPA_CLEAR_ACTIONS	4	if 1 packets matching flow are
891*9ca6876dSPeter Maydell					dropped (all other instructions
892*9ca6876dSPeter Maydell					ignored)
893*9ca6876dSPeter Maydell
894*9ca6876dSPeter MaydellTLVs for flow delete and get stats command are::
895*9ca6876dSPeter Maydell
896*9ca6876dSPeter Maydell	field			width	description
897*9ca6876dSPeter Maydell	---------------------------------------------------
898*9ca6876dSPeter Maydell	OF_DPA_CMD		2	CMD_[DEL|GET_STATS]
899*9ca6876dSPeter Maydell	OF_DPA_COOKIE		8	Cookie
900*9ca6876dSPeter Maydell
901*9ca6876dSPeter MaydellOn completion of get stats command, the descriptor buffer is written back with
902*9ca6876dSPeter Maydellthe following TLVs::
903*9ca6876dSPeter Maydell
904*9ca6876dSPeter Maydell	field			width	description
905*9ca6876dSPeter Maydell	---------------------------------------------------
906*9ca6876dSPeter Maydell	OF_DPA_STAT_DURATION	4	Flow duration
907*9ca6876dSPeter Maydell	OF_DPA_STAT_RX_PKTS	8	Received packets
908*9ca6876dSPeter Maydell	OF_DPA_STAT_TX_PKTS	8	Transmit packets
909*9ca6876dSPeter Maydell
910*9ca6876dSPeter MaydellPossible status return codes in descriptor on completion are::
911*9ca6876dSPeter Maydell
912*9ca6876dSPeter Maydell	DESC_COMP_ERR	command			reason
913*9ca6876dSPeter Maydell	--------------------------------------------------------------------
914*9ca6876dSPeter Maydell	0		all			OK
915*9ca6876dSPeter Maydell	-ROCKER_EFAULT	all			head or tail index outside
916*9ca6876dSPeter Maydell						of ring
917*9ca6876dSPeter Maydell	-ROCKER_ENXIO	all			address or data read err on
918*9ca6876dSPeter Maydell						desc buf
919*9ca6876dSPeter Maydell	-ROCKER_EMSGSIZE GET_STATS		cmd descriptor buffer wasn't
920*9ca6876dSPeter Maydell						big enough to contain write-back
921*9ca6876dSPeter Maydell						TLVs
922*9ca6876dSPeter Maydell	-ROCKER_EINVAL	all			invalid parameters passed in
923*9ca6876dSPeter Maydell	-ROCKER_EEXIST	ADD			entry already exists
924*9ca6876dSPeter Maydell	-ROCKER_ENOSPC	ADD			no space left in flow table
925*9ca6876dSPeter Maydell	-ROCKER_ENOENT	MOD|DEL|GET_STATS	cookie invalid
926*9ca6876dSPeter Maydell
927*9ca6876dSPeter MaydellGroup Table Interface
928*9ca6876dSPeter Maydell---------------------
929*9ca6876dSPeter Maydell
930*9ca6876dSPeter MaydellThere are commands to add, modify, delete, and get stats of group table
931*9ca6876dSPeter Maydellentries.  The commands are issued using the DMA CMD descriptor ring.  The
932*9ca6876dSPeter Maydellfollowing commands are defined::
933*9ca6876dSPeter Maydell
934*9ca6876dSPeter Maydell	CMD_ADD:		add an entry to group table
935*9ca6876dSPeter Maydell	CMD_MOD:		modify an entry in group table
936*9ca6876dSPeter Maydell	CMD_DEL:		delete an entry from group table
937*9ca6876dSPeter Maydell	CMD_GET_STATS:		get stats for group entry
938*9ca6876dSPeter Maydell
939*9ca6876dSPeter MaydellTLVs for add and modify commands are::
940*9ca6876dSPeter Maydell
941*9ca6876dSPeter Maydell	field			width	description
942*9ca6876dSPeter Maydell	-----------------------------------------------------------
943*9ca6876dSPeter Maydell	FLOW_GROUP_CMD		2	CMD_[ADD|MOD]
944*9ca6876dSPeter Maydell	FLOW_GROUP_ID		2	Flow group ID
945*9ca6876dSPeter Maydell	FLOW_GROUP_TYPE		1	Group type:
946*9ca6876dSPeter Maydell					  0: L2 interface
947*9ca6876dSPeter Maydell					  1: L2 rewrite
948*9ca6876dSPeter Maydell					  2: L3 unicast
949*9ca6876dSPeter Maydell					  3: L2 multicast
950*9ca6876dSPeter Maydell					  4: L2 flood
951*9ca6876dSPeter Maydell					  5: L3 interface
952*9ca6876dSPeter Maydell					  6: L3 multicast
953*9ca6876dSPeter Maydell					  7: L3 ECMP
954*9ca6876dSPeter Maydell					  8: L2 overlay
955*9ca6876dSPeter Maydell	FLOW_VLAN_ID		2	Vlan ID (types 0, 3, 4, 6)
956*9ca6876dSPeter Maydell	FLOW_L2_PORT		2	Port (types 0)
957*9ca6876dSPeter Maydell	FLOW_INDEX		4	Index (all types but 0)
958*9ca6876dSPeter Maydell	FLOW_OVERLAY_TYPE	1	Overlay sub-type (type 8):
959*9ca6876dSPeter Maydell					  0: Flood unicast tunnel
960*9ca6876dSPeter Maydell					  1: Flood multicast tunnel
961*9ca6876dSPeter Maydell					  2: Multicast unicast tunnel
962*9ca6876dSPeter Maydell					  3: Multicast multicast tunnel
963*9ca6876dSPeter Maydell	FLOW_GROUP_ACTION		nest
964*9ca6876dSPeter Maydell	  FLOW_GROUP_ID		2	next group ID in chain (all
965*9ca6876dSPeter Maydell					types except 0)
966*9ca6876dSPeter Maydell	  FLOW_OUT_PORT		4	egress port (types 0, 8)
967*9ca6876dSPeter Maydell	  FLOW_POP_VLAN_TAG	1	strip outer VLAN tag (type 1
968*9ca6876dSPeter Maydell					only)
969*9ca6876dSPeter Maydell	  FLOW_VLAN_ID		2	(types 1, 5)
970*9ca6876dSPeter Maydell	  FLOW_SRC_MAC		6	(types 1, 2, 5)
971*9ca6876dSPeter Maydell	  FLOW_DST_MAC		6	(types 1, 2)
972*9ca6876dSPeter Maydell
973*9ca6876dSPeter MaydellTLVs for flow delete and get stats command are::
974*9ca6876dSPeter Maydell
975*9ca6876dSPeter Maydell	field			width	description
976*9ca6876dSPeter Maydell	-----------------------------------------------------------
977*9ca6876dSPeter Maydell	FLOW_GROUP_CMD		2	CMD_[DEL|GET_STATS]
978*9ca6876dSPeter Maydell	FLOW_GROUP_ID		2	Flow group ID
979*9ca6876dSPeter Maydell
980*9ca6876dSPeter MaydellOn completion of get stats command, the descriptor buffer is written back with
981*9ca6876dSPeter Maydellthe following TLVs::
982*9ca6876dSPeter Maydell
983*9ca6876dSPeter Maydell	field			width	description
984*9ca6876dSPeter Maydell	---------------------------------------------------
985*9ca6876dSPeter Maydell	FLOW_GROUP_ID		2	Flow group ID
986*9ca6876dSPeter Maydell	FLOW_STAT_DURATION	4	Flow duration
987*9ca6876dSPeter Maydell	FLOW_STAT_REF_COUNT	4	Flow reference count
988*9ca6876dSPeter Maydell	FLOW_STAT_BUCKET_COUNT	4	Flow bucket count
989*9ca6876dSPeter Maydell
990*9ca6876dSPeter MaydellPossible status return codes in descriptor on completion are::
991*9ca6876dSPeter Maydell
992*9ca6876dSPeter Maydell	DESC_COMP_ERR	command			reason
993*9ca6876dSPeter Maydell	--------------------------------------------------------------------
994*9ca6876dSPeter Maydell	0		all			OK
995*9ca6876dSPeter Maydell	-ROCKER_EFAULT	all			head or tail index outside
996*9ca6876dSPeter Maydell						of ring
997*9ca6876dSPeter Maydell	-ROCKER_ENXIO	all			address or data read err on
998*9ca6876dSPeter Maydell						desc buf
999*9ca6876dSPeter Maydell	-ROCKER_ENOSPC	GET_STATS		cmd descriptor buffer wasn't
1000*9ca6876dSPeter Maydell						big enough to contain write-back
1001*9ca6876dSPeter Maydell						TLVs
1002*9ca6876dSPeter Maydell	-ROCKER_EINVAL	ADD|MOD			invalid parameters passed in
1003*9ca6876dSPeter Maydell	-ROCKER_EEXIST	ADD			entry already exists
1004*9ca6876dSPeter Maydell	-ROCKER_ENOSPC	ADD			no space left in flow table
1005*9ca6876dSPeter Maydell	-ROCKER_ENOENT	MOD|DEL|GET_STATS	group ID invalid
1006*9ca6876dSPeter Maydell	-ROCKER_EBUSY	DEL			group reference count non-zero
1007*9ca6876dSPeter Maydell	-ROCKER_ENODEV	ADD			next group ID doesn't exist
1008*9ca6876dSPeter Maydell
1009*9ca6876dSPeter Maydell
1010*9ca6876dSPeter Maydell
1011*9ca6876dSPeter MaydellReferences
1012*9ca6876dSPeter Maydell==========
1013*9ca6876dSPeter Maydell
1014*9ca6876dSPeter Maydell[1] OpenFlow Data Plane Abstraction (OF-DPA) Abstract Switch Specification,
1015*9ca6876dSPeter MaydellVersion 1.0, from Broadcom Corporation, February 21, 2014.
1016