xref: /linux/include/uapi/linux/firewire-cdev.h (revision 607ca46e97a1b6594b29647d98a32d545c24bdff)
1*607ca46eSDavid Howells /*
2*607ca46eSDavid Howells  * Char device interface.
3*607ca46eSDavid Howells  *
4*607ca46eSDavid Howells  * Copyright (C) 2005-2007  Kristian Hoegsberg <krh@bitplanet.net>
5*607ca46eSDavid Howells  *
6*607ca46eSDavid Howells  * Permission is hereby granted, free of charge, to any person obtaining a
7*607ca46eSDavid Howells  * copy of this software and associated documentation files (the "Software"),
8*607ca46eSDavid Howells  * to deal in the Software without restriction, including without limitation
9*607ca46eSDavid Howells  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10*607ca46eSDavid Howells  * and/or sell copies of the Software, and to permit persons to whom the
11*607ca46eSDavid Howells  * Software is furnished to do so, subject to the following conditions:
12*607ca46eSDavid Howells  *
13*607ca46eSDavid Howells  * The above copyright notice and this permission notice (including the next
14*607ca46eSDavid Howells  * paragraph) shall be included in all copies or substantial portions of the
15*607ca46eSDavid Howells  * Software.
16*607ca46eSDavid Howells  *
17*607ca46eSDavid Howells  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18*607ca46eSDavid Howells  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19*607ca46eSDavid Howells  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20*607ca46eSDavid Howells  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21*607ca46eSDavid Howells  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22*607ca46eSDavid Howells  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23*607ca46eSDavid Howells  * DEALINGS IN THE SOFTWARE.
24*607ca46eSDavid Howells  */
25*607ca46eSDavid Howells 
26*607ca46eSDavid Howells #ifndef _LINUX_FIREWIRE_CDEV_H
27*607ca46eSDavid Howells #define _LINUX_FIREWIRE_CDEV_H
28*607ca46eSDavid Howells 
29*607ca46eSDavid Howells #include <linux/ioctl.h>
30*607ca46eSDavid Howells #include <linux/types.h>
31*607ca46eSDavid Howells #include <linux/firewire-constants.h>
32*607ca46eSDavid Howells 
33*607ca46eSDavid Howells /* available since kernel version 2.6.22 */
34*607ca46eSDavid Howells #define FW_CDEV_EVENT_BUS_RESET				0x00
35*607ca46eSDavid Howells #define FW_CDEV_EVENT_RESPONSE				0x01
36*607ca46eSDavid Howells #define FW_CDEV_EVENT_REQUEST				0x02
37*607ca46eSDavid Howells #define FW_CDEV_EVENT_ISO_INTERRUPT			0x03
38*607ca46eSDavid Howells 
39*607ca46eSDavid Howells /* available since kernel version 2.6.30 */
40*607ca46eSDavid Howells #define FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED		0x04
41*607ca46eSDavid Howells #define FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED		0x05
42*607ca46eSDavid Howells 
43*607ca46eSDavid Howells /* available since kernel version 2.6.36 */
44*607ca46eSDavid Howells #define FW_CDEV_EVENT_REQUEST2				0x06
45*607ca46eSDavid Howells #define FW_CDEV_EVENT_PHY_PACKET_SENT			0x07
46*607ca46eSDavid Howells #define FW_CDEV_EVENT_PHY_PACKET_RECEIVED		0x08
47*607ca46eSDavid Howells #define FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL	0x09
48*607ca46eSDavid Howells 
49*607ca46eSDavid Howells /**
50*607ca46eSDavid Howells  * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types
51*607ca46eSDavid Howells  * @closure:	For arbitrary use by userspace
52*607ca46eSDavid Howells  * @type:	Discriminates the fw_cdev_event_ types
53*607ca46eSDavid Howells  *
54*607ca46eSDavid Howells  * This struct may be used to access generic members of all fw_cdev_event_
55*607ca46eSDavid Howells  * types regardless of the specific type.
56*607ca46eSDavid Howells  *
57*607ca46eSDavid Howells  * Data passed in the @closure field for a request will be returned in the
58*607ca46eSDavid Howells  * corresponding event.  It is big enough to hold a pointer on all platforms.
59*607ca46eSDavid Howells  * The ioctl used to set @closure depends on the @type of event.
60*607ca46eSDavid Howells  */
61*607ca46eSDavid Howells struct fw_cdev_event_common {
62*607ca46eSDavid Howells 	__u64 closure;
63*607ca46eSDavid Howells 	__u32 type;
64*607ca46eSDavid Howells };
65*607ca46eSDavid Howells 
66*607ca46eSDavid Howells /**
67*607ca46eSDavid Howells  * struct fw_cdev_event_bus_reset - Sent when a bus reset occurred
68*607ca46eSDavid Howells  * @closure:	See &fw_cdev_event_common; set by %FW_CDEV_IOC_GET_INFO ioctl
69*607ca46eSDavid Howells  * @type:	See &fw_cdev_event_common; always %FW_CDEV_EVENT_BUS_RESET
70*607ca46eSDavid Howells  * @node_id:       New node ID of this node
71*607ca46eSDavid Howells  * @local_node_id: Node ID of the local node, i.e. of the controller
72*607ca46eSDavid Howells  * @bm_node_id:    Node ID of the bus manager
73*607ca46eSDavid Howells  * @irm_node_id:   Node ID of the iso resource manager
74*607ca46eSDavid Howells  * @root_node_id:  Node ID of the root node
75*607ca46eSDavid Howells  * @generation:    New bus generation
76*607ca46eSDavid Howells  *
77*607ca46eSDavid Howells  * This event is sent when the bus the device belongs to goes through a bus
78*607ca46eSDavid Howells  * reset.  It provides information about the new bus configuration, such as
79*607ca46eSDavid Howells  * new node ID for this device, new root ID, and others.
80*607ca46eSDavid Howells  *
81*607ca46eSDavid Howells  * If @bm_node_id is 0xffff right after bus reset it can be reread by an
82*607ca46eSDavid Howells  * %FW_CDEV_IOC_GET_INFO ioctl after bus manager selection was finished.
83*607ca46eSDavid Howells  * Kernels with ABI version < 4 do not set @bm_node_id.
84*607ca46eSDavid Howells  */
85*607ca46eSDavid Howells struct fw_cdev_event_bus_reset {
86*607ca46eSDavid Howells 	__u64 closure;
87*607ca46eSDavid Howells 	__u32 type;
88*607ca46eSDavid Howells 	__u32 node_id;
89*607ca46eSDavid Howells 	__u32 local_node_id;
90*607ca46eSDavid Howells 	__u32 bm_node_id;
91*607ca46eSDavid Howells 	__u32 irm_node_id;
92*607ca46eSDavid Howells 	__u32 root_node_id;
93*607ca46eSDavid Howells 	__u32 generation;
94*607ca46eSDavid Howells };
95*607ca46eSDavid Howells 
96*607ca46eSDavid Howells /**
97*607ca46eSDavid Howells  * struct fw_cdev_event_response - Sent when a response packet was received
98*607ca46eSDavid Howells  * @closure:	See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_REQUEST
99*607ca46eSDavid Howells  *		or %FW_CDEV_IOC_SEND_BROADCAST_REQUEST
100*607ca46eSDavid Howells  *		or %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl
101*607ca46eSDavid Howells  * @type:	See &fw_cdev_event_common; always %FW_CDEV_EVENT_RESPONSE
102*607ca46eSDavid Howells  * @rcode:	Response code returned by the remote node
103*607ca46eSDavid Howells  * @length:	Data length, i.e. the response's payload size in bytes
104*607ca46eSDavid Howells  * @data:	Payload data, if any
105*607ca46eSDavid Howells  *
106*607ca46eSDavid Howells  * This event is sent when the stack receives a response to an outgoing request
107*607ca46eSDavid Howells  * sent by %FW_CDEV_IOC_SEND_REQUEST ioctl.  The payload data for responses
108*607ca46eSDavid Howells  * carrying data (read and lock responses) follows immediately and can be
109*607ca46eSDavid Howells  * accessed through the @data field.
110*607ca46eSDavid Howells  *
111*607ca46eSDavid Howells  * The event is also generated after conclusions of transactions that do not
112*607ca46eSDavid Howells  * involve response packets.  This includes unified write transactions,
113*607ca46eSDavid Howells  * broadcast write transactions, and transmission of asynchronous stream
114*607ca46eSDavid Howells  * packets.  @rcode indicates success or failure of such transmissions.
115*607ca46eSDavid Howells  */
116*607ca46eSDavid Howells struct fw_cdev_event_response {
117*607ca46eSDavid Howells 	__u64 closure;
118*607ca46eSDavid Howells 	__u32 type;
119*607ca46eSDavid Howells 	__u32 rcode;
120*607ca46eSDavid Howells 	__u32 length;
121*607ca46eSDavid Howells 	__u32 data[0];
122*607ca46eSDavid Howells };
123*607ca46eSDavid Howells 
124*607ca46eSDavid Howells /**
125*607ca46eSDavid Howells  * struct fw_cdev_event_request - Old version of &fw_cdev_event_request2
126*607ca46eSDavid Howells  * @type:	See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST
127*607ca46eSDavid Howells  *
128*607ca46eSDavid Howells  * This event is sent instead of &fw_cdev_event_request2 if the kernel or
129*607ca46eSDavid Howells  * the client implements ABI version <= 3.  &fw_cdev_event_request lacks
130*607ca46eSDavid Howells  * essential information; use &fw_cdev_event_request2 instead.
131*607ca46eSDavid Howells  */
132*607ca46eSDavid Howells struct fw_cdev_event_request {
133*607ca46eSDavid Howells 	__u64 closure;
134*607ca46eSDavid Howells 	__u32 type;
135*607ca46eSDavid Howells 	__u32 tcode;
136*607ca46eSDavid Howells 	__u64 offset;
137*607ca46eSDavid Howells 	__u32 handle;
138*607ca46eSDavid Howells 	__u32 length;
139*607ca46eSDavid Howells 	__u32 data[0];
140*607ca46eSDavid Howells };
141*607ca46eSDavid Howells 
142*607ca46eSDavid Howells /**
143*607ca46eSDavid Howells  * struct fw_cdev_event_request2 - Sent on incoming request to an address region
144*607ca46eSDavid Howells  * @closure:	See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl
145*607ca46eSDavid Howells  * @type:	See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST2
146*607ca46eSDavid Howells  * @tcode:	Transaction code of the incoming request
147*607ca46eSDavid Howells  * @offset:	The offset into the 48-bit per-node address space
148*607ca46eSDavid Howells  * @source_node_id: Sender node ID
149*607ca46eSDavid Howells  * @destination_node_id: Destination node ID
150*607ca46eSDavid Howells  * @card:	The index of the card from which the request came
151*607ca46eSDavid Howells  * @generation:	Bus generation in which the request is valid
152*607ca46eSDavid Howells  * @handle:	Reference to the kernel-side pending request
153*607ca46eSDavid Howells  * @length:	Data length, i.e. the request's payload size in bytes
154*607ca46eSDavid Howells  * @data:	Incoming data, if any
155*607ca46eSDavid Howells  *
156*607ca46eSDavid Howells  * This event is sent when the stack receives an incoming request to an address
157*607ca46eSDavid Howells  * region registered using the %FW_CDEV_IOC_ALLOCATE ioctl.  The request is
158*607ca46eSDavid Howells  * guaranteed to be completely contained in the specified region.  Userspace is
159*607ca46eSDavid Howells  * responsible for sending the response by %FW_CDEV_IOC_SEND_RESPONSE ioctl,
160*607ca46eSDavid Howells  * using the same @handle.
161*607ca46eSDavid Howells  *
162*607ca46eSDavid Howells  * The payload data for requests carrying data (write and lock requests)
163*607ca46eSDavid Howells  * follows immediately and can be accessed through the @data field.
164*607ca46eSDavid Howells  *
165*607ca46eSDavid Howells  * Unlike &fw_cdev_event_request, @tcode of lock requests is one of the
166*607ca46eSDavid Howells  * firewire-core specific %TCODE_LOCK_MASK_SWAP...%TCODE_LOCK_VENDOR_DEPENDENT,
167*607ca46eSDavid Howells  * i.e. encodes the extended transaction code.
168*607ca46eSDavid Howells  *
169*607ca46eSDavid Howells  * @card may differ from &fw_cdev_get_info.card because requests are received
170*607ca46eSDavid Howells  * from all cards of the Linux host.  @source_node_id, @destination_node_id, and
171*607ca46eSDavid Howells  * @generation pertain to that card.  Destination node ID and bus generation may
172*607ca46eSDavid Howells  * therefore differ from the corresponding fields of the last
173*607ca46eSDavid Howells  * &fw_cdev_event_bus_reset.
174*607ca46eSDavid Howells  *
175*607ca46eSDavid Howells  * @destination_node_id may also differ from the current node ID because of a
176*607ca46eSDavid Howells  * non-local bus ID part or in case of a broadcast write request.  Note, a
177*607ca46eSDavid Howells  * client must call an %FW_CDEV_IOC_SEND_RESPONSE ioctl even in case of a
178*607ca46eSDavid Howells  * broadcast write request; the kernel will then release the kernel-side pending
179*607ca46eSDavid Howells  * request but will not actually send a response packet.
180*607ca46eSDavid Howells  *
181*607ca46eSDavid Howells  * In case of a write request to FCP_REQUEST or FCP_RESPONSE, the kernel already
182*607ca46eSDavid Howells  * sent a write response immediately after the request was received; in this
183*607ca46eSDavid Howells  * case the client must still call an %FW_CDEV_IOC_SEND_RESPONSE ioctl to
184*607ca46eSDavid Howells  * release the kernel-side pending request, though another response won't be
185*607ca46eSDavid Howells  * sent.
186*607ca46eSDavid Howells  *
187*607ca46eSDavid Howells  * If the client subsequently needs to initiate requests to the sender node of
188*607ca46eSDavid Howells  * an &fw_cdev_event_request2, it needs to use a device file with matching
189*607ca46eSDavid Howells  * card index, node ID, and generation for outbound requests.
190*607ca46eSDavid Howells  */
191*607ca46eSDavid Howells struct fw_cdev_event_request2 {
192*607ca46eSDavid Howells 	__u64 closure;
193*607ca46eSDavid Howells 	__u32 type;
194*607ca46eSDavid Howells 	__u32 tcode;
195*607ca46eSDavid Howells 	__u64 offset;
196*607ca46eSDavid Howells 	__u32 source_node_id;
197*607ca46eSDavid Howells 	__u32 destination_node_id;
198*607ca46eSDavid Howells 	__u32 card;
199*607ca46eSDavid Howells 	__u32 generation;
200*607ca46eSDavid Howells 	__u32 handle;
201*607ca46eSDavid Howells 	__u32 length;
202*607ca46eSDavid Howells 	__u32 data[0];
203*607ca46eSDavid Howells };
204*607ca46eSDavid Howells 
205*607ca46eSDavid Howells /**
206*607ca46eSDavid Howells  * struct fw_cdev_event_iso_interrupt - Sent when an iso packet was completed
207*607ca46eSDavid Howells  * @closure:	See &fw_cdev_event_common;
208*607ca46eSDavid Howells  *		set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl
209*607ca46eSDavid Howells  * @type:	See &fw_cdev_event_common; always %FW_CDEV_EVENT_ISO_INTERRUPT
210*607ca46eSDavid Howells  * @cycle:	Cycle counter of the last completed packet
211*607ca46eSDavid Howells  * @header_length: Total length of following headers, in bytes
212*607ca46eSDavid Howells  * @header:	Stripped headers, if any
213*607ca46eSDavid Howells  *
214*607ca46eSDavid Howells  * This event is sent when the controller has completed an &fw_cdev_iso_packet
215*607ca46eSDavid Howells  * with the %FW_CDEV_ISO_INTERRUPT bit set, when explicitly requested with
216*607ca46eSDavid Howells  * %FW_CDEV_IOC_FLUSH_ISO, or when there have been so many completed packets
217*607ca46eSDavid Howells  * without the interrupt bit set that the kernel's internal buffer for @header
218*607ca46eSDavid Howells  * is about to overflow.  (In the last case, kernels with ABI version < 5 drop
219*607ca46eSDavid Howells  * header data up to the next interrupt packet.)
220*607ca46eSDavid Howells  *
221*607ca46eSDavid Howells  * Isochronous transmit events (context type %FW_CDEV_ISO_CONTEXT_TRANSMIT):
222*607ca46eSDavid Howells  *
223*607ca46eSDavid Howells  * In version 3 and some implementations of version 2 of the ABI, &header_length
224*607ca46eSDavid Howells  * is a multiple of 4 and &header contains timestamps of all packets up until
225*607ca46eSDavid Howells  * the interrupt packet.  The format of the timestamps is as described below for
226*607ca46eSDavid Howells  * isochronous reception.  In version 1 of the ABI, &header_length was 0.
227*607ca46eSDavid Howells  *
228*607ca46eSDavid Howells  * Isochronous receive events (context type %FW_CDEV_ISO_CONTEXT_RECEIVE):
229*607ca46eSDavid Howells  *
230*607ca46eSDavid Howells  * The headers stripped of all packets up until and including the interrupt
231*607ca46eSDavid Howells  * packet are returned in the @header field.  The amount of header data per
232*607ca46eSDavid Howells  * packet is as specified at iso context creation by
233*607ca46eSDavid Howells  * &fw_cdev_create_iso_context.header_size.
234*607ca46eSDavid Howells  *
235*607ca46eSDavid Howells  * Hence, _interrupt.header_length / _context.header_size is the number of
236*607ca46eSDavid Howells  * packets received in this interrupt event.  The client can now iterate
237*607ca46eSDavid Howells  * through the mmap()'ed DMA buffer according to this number of packets and
238*607ca46eSDavid Howells  * to the buffer sizes as the client specified in &fw_cdev_queue_iso.
239*607ca46eSDavid Howells  *
240*607ca46eSDavid Howells  * Since version 2 of this ABI, the portion for each packet in _interrupt.header
241*607ca46eSDavid Howells  * consists of the 1394 isochronous packet header, followed by a timestamp
242*607ca46eSDavid Howells  * quadlet if &fw_cdev_create_iso_context.header_size > 4, followed by quadlets
243*607ca46eSDavid Howells  * from the packet payload if &fw_cdev_create_iso_context.header_size > 8.
244*607ca46eSDavid Howells  *
245*607ca46eSDavid Howells  * Format of 1394 iso packet header:  16 bits data_length, 2 bits tag, 6 bits
246*607ca46eSDavid Howells  * channel, 4 bits tcode, 4 bits sy, in big endian byte order.
247*607ca46eSDavid Howells  * data_length is the actual received size of the packet without the four
248*607ca46eSDavid Howells  * 1394 iso packet header bytes.
249*607ca46eSDavid Howells  *
250*607ca46eSDavid Howells  * Format of timestamp:  16 bits invalid, 3 bits cycleSeconds, 13 bits
251*607ca46eSDavid Howells  * cycleCount, in big endian byte order.
252*607ca46eSDavid Howells  *
253*607ca46eSDavid Howells  * In version 1 of the ABI, no timestamp quadlet was inserted; instead, payload
254*607ca46eSDavid Howells  * data followed directly after the 1394 is header if header_size > 4.
255*607ca46eSDavid Howells  * Behaviour of ver. 1 of this ABI is no longer available since ABI ver. 2.
256*607ca46eSDavid Howells  */
257*607ca46eSDavid Howells struct fw_cdev_event_iso_interrupt {
258*607ca46eSDavid Howells 	__u64 closure;
259*607ca46eSDavid Howells 	__u32 type;
260*607ca46eSDavid Howells 	__u32 cycle;
261*607ca46eSDavid Howells 	__u32 header_length;
262*607ca46eSDavid Howells 	__u32 header[0];
263*607ca46eSDavid Howells };
264*607ca46eSDavid Howells 
265*607ca46eSDavid Howells /**
266*607ca46eSDavid Howells  * struct fw_cdev_event_iso_interrupt_mc - An iso buffer chunk was completed
267*607ca46eSDavid Howells  * @closure:	See &fw_cdev_event_common;
268*607ca46eSDavid Howells  *		set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl
269*607ca46eSDavid Howells  * @type:	%FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL
270*607ca46eSDavid Howells  * @completed:	Offset into the receive buffer; data before this offset is valid
271*607ca46eSDavid Howells  *
272*607ca46eSDavid Howells  * This event is sent in multichannel contexts (context type
273*607ca46eSDavid Howells  * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL) for &fw_cdev_iso_packet buffer
274*607ca46eSDavid Howells  * chunks that have been completely filled and that have the
275*607ca46eSDavid Howells  * %FW_CDEV_ISO_INTERRUPT bit set, or when explicitly requested with
276*607ca46eSDavid Howells  * %FW_CDEV_IOC_FLUSH_ISO.
277*607ca46eSDavid Howells  *
278*607ca46eSDavid Howells  * The buffer is continuously filled with the following data, per packet:
279*607ca46eSDavid Howells  *  - the 1394 iso packet header as described at &fw_cdev_event_iso_interrupt,
280*607ca46eSDavid Howells  *    but in little endian byte order,
281*607ca46eSDavid Howells  *  - packet payload (as many bytes as specified in the data_length field of
282*607ca46eSDavid Howells  *    the 1394 iso packet header) in big endian byte order,
283*607ca46eSDavid Howells  *  - 0...3 padding bytes as needed to align the following trailer quadlet,
284*607ca46eSDavid Howells  *  - trailer quadlet, containing the reception timestamp as described at
285*607ca46eSDavid Howells  *    &fw_cdev_event_iso_interrupt, but in little endian byte order.
286*607ca46eSDavid Howells  *
287*607ca46eSDavid Howells  * Hence the per-packet size is data_length (rounded up to a multiple of 4) + 8.
288*607ca46eSDavid Howells  * When processing the data, stop before a packet that would cross the
289*607ca46eSDavid Howells  * @completed offset.
290*607ca46eSDavid Howells  *
291*607ca46eSDavid Howells  * A packet near the end of a buffer chunk will typically spill over into the
292*607ca46eSDavid Howells  * next queued buffer chunk.  It is the responsibility of the client to check
293*607ca46eSDavid Howells  * for this condition, assemble a broken-up packet from its parts, and not to
294*607ca46eSDavid Howells  * re-queue any buffer chunks in which as yet unread packet parts reside.
295*607ca46eSDavid Howells  */
296*607ca46eSDavid Howells struct fw_cdev_event_iso_interrupt_mc {
297*607ca46eSDavid Howells 	__u64 closure;
298*607ca46eSDavid Howells 	__u32 type;
299*607ca46eSDavid Howells 	__u32 completed;
300*607ca46eSDavid Howells };
301*607ca46eSDavid Howells 
302*607ca46eSDavid Howells /**
303*607ca46eSDavid Howells  * struct fw_cdev_event_iso_resource - Iso resources were allocated or freed
304*607ca46eSDavid Howells  * @closure:	See &fw_cdev_event_common;
305*607ca46eSDavid Howells  *		set by %FW_CDEV_IOC_(DE)ALLOCATE_ISO_RESOURCE(_ONCE) ioctl
306*607ca46eSDavid Howells  * @type:	%FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or
307*607ca46eSDavid Howells  *		%FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED
308*607ca46eSDavid Howells  * @handle:	Reference by which an allocated resource can be deallocated
309*607ca46eSDavid Howells  * @channel:	Isochronous channel which was (de)allocated, if any
310*607ca46eSDavid Howells  * @bandwidth:	Bandwidth allocation units which were (de)allocated, if any
311*607ca46eSDavid Howells  *
312*607ca46eSDavid Howells  * An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event is sent after an isochronous
313*607ca46eSDavid Howells  * resource was allocated at the IRM.  The client has to check @channel and
314*607ca46eSDavid Howells  * @bandwidth for whether the allocation actually succeeded.
315*607ca46eSDavid Howells  *
316*607ca46eSDavid Howells  * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event is sent after an isochronous
317*607ca46eSDavid Howells  * resource was deallocated at the IRM.  It is also sent when automatic
318*607ca46eSDavid Howells  * reallocation after a bus reset failed.
319*607ca46eSDavid Howells  *
320*607ca46eSDavid Howells  * @channel is <0 if no channel was (de)allocated or if reallocation failed.
321*607ca46eSDavid Howells  * @bandwidth is 0 if no bandwidth was (de)allocated or if reallocation failed.
322*607ca46eSDavid Howells  */
323*607ca46eSDavid Howells struct fw_cdev_event_iso_resource {
324*607ca46eSDavid Howells 	__u64 closure;
325*607ca46eSDavid Howells 	__u32 type;
326*607ca46eSDavid Howells 	__u32 handle;
327*607ca46eSDavid Howells 	__s32 channel;
328*607ca46eSDavid Howells 	__s32 bandwidth;
329*607ca46eSDavid Howells };
330*607ca46eSDavid Howells 
331*607ca46eSDavid Howells /**
332*607ca46eSDavid Howells  * struct fw_cdev_event_phy_packet - A PHY packet was transmitted or received
333*607ca46eSDavid Howells  * @closure:	See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_PHY_PACKET
334*607ca46eSDavid Howells  *		or %FW_CDEV_IOC_RECEIVE_PHY_PACKETS ioctl
335*607ca46eSDavid Howells  * @type:	%FW_CDEV_EVENT_PHY_PACKET_SENT or %..._RECEIVED
336*607ca46eSDavid Howells  * @rcode:	%RCODE_..., indicates success or failure of transmission
337*607ca46eSDavid Howells  * @length:	Data length in bytes
338*607ca46eSDavid Howells  * @data:	Incoming data
339*607ca46eSDavid Howells  *
340*607ca46eSDavid Howells  * If @type is %FW_CDEV_EVENT_PHY_PACKET_SENT, @length is 0 and @data empty,
341*607ca46eSDavid Howells  * except in case of a ping packet:  Then, @length is 4, and @data[0] is the
342*607ca46eSDavid Howells  * ping time in 49.152MHz clocks if @rcode is %RCODE_COMPLETE.
343*607ca46eSDavid Howells  *
344*607ca46eSDavid Howells  * If @type is %FW_CDEV_EVENT_PHY_PACKET_RECEIVED, @length is 8 and @data
345*607ca46eSDavid Howells  * consists of the two PHY packet quadlets, in host byte order.
346*607ca46eSDavid Howells  */
347*607ca46eSDavid Howells struct fw_cdev_event_phy_packet {
348*607ca46eSDavid Howells 	__u64 closure;
349*607ca46eSDavid Howells 	__u32 type;
350*607ca46eSDavid Howells 	__u32 rcode;
351*607ca46eSDavid Howells 	__u32 length;
352*607ca46eSDavid Howells 	__u32 data[0];
353*607ca46eSDavid Howells };
354*607ca46eSDavid Howells 
355*607ca46eSDavid Howells /**
356*607ca46eSDavid Howells  * union fw_cdev_event - Convenience union of fw_cdev_event_ types
357*607ca46eSDavid Howells  * @common:		Valid for all types
358*607ca46eSDavid Howells  * @bus_reset:		Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET
359*607ca46eSDavid Howells  * @response:		Valid if @common.type == %FW_CDEV_EVENT_RESPONSE
360*607ca46eSDavid Howells  * @request:		Valid if @common.type == %FW_CDEV_EVENT_REQUEST
361*607ca46eSDavid Howells  * @request2:		Valid if @common.type == %FW_CDEV_EVENT_REQUEST2
362*607ca46eSDavid Howells  * @iso_interrupt:	Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT
363*607ca46eSDavid Howells  * @iso_interrupt_mc:	Valid if @common.type ==
364*607ca46eSDavid Howells  *				%FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL
365*607ca46eSDavid Howells  * @iso_resource:	Valid if @common.type ==
366*607ca46eSDavid Howells  *				%FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or
367*607ca46eSDavid Howells  *				%FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED
368*607ca46eSDavid Howells  * @phy_packet:		Valid if @common.type ==
369*607ca46eSDavid Howells  *				%FW_CDEV_EVENT_PHY_PACKET_SENT or
370*607ca46eSDavid Howells  *				%FW_CDEV_EVENT_PHY_PACKET_RECEIVED
371*607ca46eSDavid Howells  *
372*607ca46eSDavid Howells  * Convenience union for userspace use.  Events could be read(2) into an
373*607ca46eSDavid Howells  * appropriately aligned char buffer and then cast to this union for further
374*607ca46eSDavid Howells  * processing.  Note that for a request, response or iso_interrupt event,
375*607ca46eSDavid Howells  * the data[] or header[] may make the size of the full event larger than
376*607ca46eSDavid Howells  * sizeof(union fw_cdev_event).  Also note that if you attempt to read(2)
377*607ca46eSDavid Howells  * an event into a buffer that is not large enough for it, the data that does
378*607ca46eSDavid Howells  * not fit will be discarded so that the next read(2) will return a new event.
379*607ca46eSDavid Howells  */
380*607ca46eSDavid Howells union fw_cdev_event {
381*607ca46eSDavid Howells 	struct fw_cdev_event_common		common;
382*607ca46eSDavid Howells 	struct fw_cdev_event_bus_reset		bus_reset;
383*607ca46eSDavid Howells 	struct fw_cdev_event_response		response;
384*607ca46eSDavid Howells 	struct fw_cdev_event_request		request;
385*607ca46eSDavid Howells 	struct fw_cdev_event_request2		request2;		/* added in 2.6.36 */
386*607ca46eSDavid Howells 	struct fw_cdev_event_iso_interrupt	iso_interrupt;
387*607ca46eSDavid Howells 	struct fw_cdev_event_iso_interrupt_mc	iso_interrupt_mc;	/* added in 2.6.36 */
388*607ca46eSDavid Howells 	struct fw_cdev_event_iso_resource	iso_resource;		/* added in 2.6.30 */
389*607ca46eSDavid Howells 	struct fw_cdev_event_phy_packet		phy_packet;		/* added in 2.6.36 */
390*607ca46eSDavid Howells };
391*607ca46eSDavid Howells 
392*607ca46eSDavid Howells /* available since kernel version 2.6.22 */
393*607ca46eSDavid Howells #define FW_CDEV_IOC_GET_INFO           _IOWR('#', 0x00, struct fw_cdev_get_info)
394*607ca46eSDavid Howells #define FW_CDEV_IOC_SEND_REQUEST        _IOW('#', 0x01, struct fw_cdev_send_request)
395*607ca46eSDavid Howells #define FW_CDEV_IOC_ALLOCATE           _IOWR('#', 0x02, struct fw_cdev_allocate)
396*607ca46eSDavid Howells #define FW_CDEV_IOC_DEALLOCATE          _IOW('#', 0x03, struct fw_cdev_deallocate)
397*607ca46eSDavid Howells #define FW_CDEV_IOC_SEND_RESPONSE       _IOW('#', 0x04, struct fw_cdev_send_response)
398*607ca46eSDavid Howells #define FW_CDEV_IOC_INITIATE_BUS_RESET  _IOW('#', 0x05, struct fw_cdev_initiate_bus_reset)
399*607ca46eSDavid Howells #define FW_CDEV_IOC_ADD_DESCRIPTOR     _IOWR('#', 0x06, struct fw_cdev_add_descriptor)
400*607ca46eSDavid Howells #define FW_CDEV_IOC_REMOVE_DESCRIPTOR   _IOW('#', 0x07, struct fw_cdev_remove_descriptor)
401*607ca46eSDavid Howells #define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOWR('#', 0x08, struct fw_cdev_create_iso_context)
402*607ca46eSDavid Howells #define FW_CDEV_IOC_QUEUE_ISO          _IOWR('#', 0x09, struct fw_cdev_queue_iso)
403*607ca46eSDavid Howells #define FW_CDEV_IOC_START_ISO           _IOW('#', 0x0a, struct fw_cdev_start_iso)
404*607ca46eSDavid Howells #define FW_CDEV_IOC_STOP_ISO            _IOW('#', 0x0b, struct fw_cdev_stop_iso)
405*607ca46eSDavid Howells 
406*607ca46eSDavid Howells /* available since kernel version 2.6.24 */
407*607ca46eSDavid Howells #define FW_CDEV_IOC_GET_CYCLE_TIMER     _IOR('#', 0x0c, struct fw_cdev_get_cycle_timer)
408*607ca46eSDavid Howells 
409*607ca46eSDavid Howells /* available since kernel version 2.6.30 */
410*607ca46eSDavid Howells #define FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE       _IOWR('#', 0x0d, struct fw_cdev_allocate_iso_resource)
411*607ca46eSDavid Howells #define FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE      _IOW('#', 0x0e, struct fw_cdev_deallocate)
412*607ca46eSDavid Howells #define FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE   _IOW('#', 0x0f, struct fw_cdev_allocate_iso_resource)
413*607ca46eSDavid Howells #define FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE _IOW('#', 0x10, struct fw_cdev_allocate_iso_resource)
414*607ca46eSDavid Howells #define FW_CDEV_IOC_GET_SPEED                     _IO('#', 0x11) /* returns speed code */
415*607ca46eSDavid Howells #define FW_CDEV_IOC_SEND_BROADCAST_REQUEST       _IOW('#', 0x12, struct fw_cdev_send_request)
416*607ca46eSDavid Howells #define FW_CDEV_IOC_SEND_STREAM_PACKET           _IOW('#', 0x13, struct fw_cdev_send_stream_packet)
417*607ca46eSDavid Howells 
418*607ca46eSDavid Howells /* available since kernel version 2.6.34 */
419*607ca46eSDavid Howells #define FW_CDEV_IOC_GET_CYCLE_TIMER2   _IOWR('#', 0x14, struct fw_cdev_get_cycle_timer2)
420*607ca46eSDavid Howells 
421*607ca46eSDavid Howells /* available since kernel version 2.6.36 */
422*607ca46eSDavid Howells #define FW_CDEV_IOC_SEND_PHY_PACKET    _IOWR('#', 0x15, struct fw_cdev_send_phy_packet)
423*607ca46eSDavid Howells #define FW_CDEV_IOC_RECEIVE_PHY_PACKETS _IOW('#', 0x16, struct fw_cdev_receive_phy_packets)
424*607ca46eSDavid Howells #define FW_CDEV_IOC_SET_ISO_CHANNELS    _IOW('#', 0x17, struct fw_cdev_set_iso_channels)
425*607ca46eSDavid Howells 
426*607ca46eSDavid Howells /* available since kernel version 3.4 */
427*607ca46eSDavid Howells #define FW_CDEV_IOC_FLUSH_ISO           _IOW('#', 0x18, struct fw_cdev_flush_iso)
428*607ca46eSDavid Howells 
429*607ca46eSDavid Howells /*
430*607ca46eSDavid Howells  * ABI version history
431*607ca46eSDavid Howells  *  1  (2.6.22)  - initial version
432*607ca46eSDavid Howells  *     (2.6.24)  - added %FW_CDEV_IOC_GET_CYCLE_TIMER
433*607ca46eSDavid Howells  *  2  (2.6.30)  - changed &fw_cdev_event_iso_interrupt.header if
434*607ca46eSDavid Howells  *                 &fw_cdev_create_iso_context.header_size is 8 or more
435*607ca46eSDavid Howells  *               - added %FW_CDEV_IOC_*_ISO_RESOURCE*,
436*607ca46eSDavid Howells  *                 %FW_CDEV_IOC_GET_SPEED, %FW_CDEV_IOC_SEND_BROADCAST_REQUEST,
437*607ca46eSDavid Howells  *                 %FW_CDEV_IOC_SEND_STREAM_PACKET
438*607ca46eSDavid Howells  *     (2.6.32)  - added time stamp to xmit &fw_cdev_event_iso_interrupt
439*607ca46eSDavid Howells  *     (2.6.33)  - IR has always packet-per-buffer semantics now, not one of
440*607ca46eSDavid Howells  *                 dual-buffer or packet-per-buffer depending on hardware
441*607ca46eSDavid Howells  *               - shared use and auto-response for FCP registers
442*607ca46eSDavid Howells  *  3  (2.6.34)  - made &fw_cdev_get_cycle_timer reliable
443*607ca46eSDavid Howells  *               - added %FW_CDEV_IOC_GET_CYCLE_TIMER2
444*607ca46eSDavid Howells  *  4  (2.6.36)  - added %FW_CDEV_EVENT_REQUEST2, %FW_CDEV_EVENT_PHY_PACKET_*,
445*607ca46eSDavid Howells  *                 and &fw_cdev_allocate.region_end
446*607ca46eSDavid Howells  *               - implemented &fw_cdev_event_bus_reset.bm_node_id
447*607ca46eSDavid Howells  *               - added %FW_CDEV_IOC_SEND_PHY_PACKET, _RECEIVE_PHY_PACKETS
448*607ca46eSDavid Howells  *               - added %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL,
449*607ca46eSDavid Howells  *                 %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL, and
450*607ca46eSDavid Howells  *                 %FW_CDEV_IOC_SET_ISO_CHANNELS
451*607ca46eSDavid Howells  *  5  (3.4)     - send %FW_CDEV_EVENT_ISO_INTERRUPT events when needed to
452*607ca46eSDavid Howells  *                 avoid dropping data
453*607ca46eSDavid Howells  *               - added %FW_CDEV_IOC_FLUSH_ISO
454*607ca46eSDavid Howells  */
455*607ca46eSDavid Howells 
456*607ca46eSDavid Howells /**
457*607ca46eSDavid Howells  * struct fw_cdev_get_info - General purpose information ioctl
458*607ca46eSDavid Howells  * @version:	The version field is just a running serial number.  Both an
459*607ca46eSDavid Howells  *		input parameter (ABI version implemented by the client) and
460*607ca46eSDavid Howells  *		output parameter (ABI version implemented by the kernel).
461*607ca46eSDavid Howells  *		A client shall fill in the ABI @version for which the client
462*607ca46eSDavid Howells  *		was implemented.  This is necessary for forward compatibility.
463*607ca46eSDavid Howells  * @rom_length:	If @rom is non-zero, up to @rom_length bytes of Configuration
464*607ca46eSDavid Howells  *		ROM will be copied into that user space address.  In either
465*607ca46eSDavid Howells  *		case, @rom_length is updated with the actual length of the
466*607ca46eSDavid Howells  *		Configuration ROM.
467*607ca46eSDavid Howells  * @rom:	If non-zero, address of a buffer to be filled by a copy of the
468*607ca46eSDavid Howells  *		device's Configuration ROM
469*607ca46eSDavid Howells  * @bus_reset:	If non-zero, address of a buffer to be filled by a
470*607ca46eSDavid Howells  *		&struct fw_cdev_event_bus_reset with the current state
471*607ca46eSDavid Howells  *		of the bus.  This does not cause a bus reset to happen.
472*607ca46eSDavid Howells  * @bus_reset_closure: Value of &closure in this and subsequent bus reset events
473*607ca46eSDavid Howells  * @card:	The index of the card this device belongs to
474*607ca46eSDavid Howells  *
475*607ca46eSDavid Howells  * The %FW_CDEV_IOC_GET_INFO ioctl is usually the very first one which a client
476*607ca46eSDavid Howells  * performs right after it opened a /dev/fw* file.
477*607ca46eSDavid Howells  *
478*607ca46eSDavid Howells  * As a side effect, reception of %FW_CDEV_EVENT_BUS_RESET events to be read(2)
479*607ca46eSDavid Howells  * is started by this ioctl.
480*607ca46eSDavid Howells  */
481*607ca46eSDavid Howells struct fw_cdev_get_info {
482*607ca46eSDavid Howells 	__u32 version;
483*607ca46eSDavid Howells 	__u32 rom_length;
484*607ca46eSDavid Howells 	__u64 rom;
485*607ca46eSDavid Howells 	__u64 bus_reset;
486*607ca46eSDavid Howells 	__u64 bus_reset_closure;
487*607ca46eSDavid Howells 	__u32 card;
488*607ca46eSDavid Howells };
489*607ca46eSDavid Howells 
490*607ca46eSDavid Howells /**
491*607ca46eSDavid Howells  * struct fw_cdev_send_request - Send an asynchronous request packet
492*607ca46eSDavid Howells  * @tcode:	Transaction code of the request
493*607ca46eSDavid Howells  * @length:	Length of outgoing payload, in bytes
494*607ca46eSDavid Howells  * @offset:	48-bit offset at destination node
495*607ca46eSDavid Howells  * @closure:	Passed back to userspace in the response event
496*607ca46eSDavid Howells  * @data:	Userspace pointer to payload
497*607ca46eSDavid Howells  * @generation:	The bus generation where packet is valid
498*607ca46eSDavid Howells  *
499*607ca46eSDavid Howells  * Send a request to the device.  This ioctl implements all outgoing requests.
500*607ca46eSDavid Howells  * Both quadlet and block request specify the payload as a pointer to the data
501*607ca46eSDavid Howells  * in the @data field.  Once the transaction completes, the kernel writes an
502*607ca46eSDavid Howells  * &fw_cdev_event_response event back.  The @closure field is passed back to
503*607ca46eSDavid Howells  * user space in the response event.
504*607ca46eSDavid Howells  */
505*607ca46eSDavid Howells struct fw_cdev_send_request {
506*607ca46eSDavid Howells 	__u32 tcode;
507*607ca46eSDavid Howells 	__u32 length;
508*607ca46eSDavid Howells 	__u64 offset;
509*607ca46eSDavid Howells 	__u64 closure;
510*607ca46eSDavid Howells 	__u64 data;
511*607ca46eSDavid Howells 	__u32 generation;
512*607ca46eSDavid Howells };
513*607ca46eSDavid Howells 
514*607ca46eSDavid Howells /**
515*607ca46eSDavid Howells  * struct fw_cdev_send_response - Send an asynchronous response packet
516*607ca46eSDavid Howells  * @rcode:	Response code as determined by the userspace handler
517*607ca46eSDavid Howells  * @length:	Length of outgoing payload, in bytes
518*607ca46eSDavid Howells  * @data:	Userspace pointer to payload
519*607ca46eSDavid Howells  * @handle:	The handle from the &fw_cdev_event_request
520*607ca46eSDavid Howells  *
521*607ca46eSDavid Howells  * Send a response to an incoming request.  By setting up an address range using
522*607ca46eSDavid Howells  * the %FW_CDEV_IOC_ALLOCATE ioctl, userspace can listen for incoming requests.  An
523*607ca46eSDavid Howells  * incoming request will generate an %FW_CDEV_EVENT_REQUEST, and userspace must
524*607ca46eSDavid Howells  * send a reply using this ioctl.  The event has a handle to the kernel-side
525*607ca46eSDavid Howells  * pending transaction, which should be used with this ioctl.
526*607ca46eSDavid Howells  */
527*607ca46eSDavid Howells struct fw_cdev_send_response {
528*607ca46eSDavid Howells 	__u32 rcode;
529*607ca46eSDavid Howells 	__u32 length;
530*607ca46eSDavid Howells 	__u64 data;
531*607ca46eSDavid Howells 	__u32 handle;
532*607ca46eSDavid Howells };
533*607ca46eSDavid Howells 
534*607ca46eSDavid Howells /**
535*607ca46eSDavid Howells  * struct fw_cdev_allocate - Allocate a CSR in an address range
536*607ca46eSDavid Howells  * @offset:	Start offset of the address range
537*607ca46eSDavid Howells  * @closure:	To be passed back to userspace in request events
538*607ca46eSDavid Howells  * @length:	Length of the CSR, in bytes
539*607ca46eSDavid Howells  * @handle:	Handle to the allocation, written by the kernel
540*607ca46eSDavid Howells  * @region_end:	First address above the address range (added in ABI v4, 2.6.36)
541*607ca46eSDavid Howells  *
542*607ca46eSDavid Howells  * Allocate an address range in the 48-bit address space on the local node
543*607ca46eSDavid Howells  * (the controller).  This allows userspace to listen for requests with an
544*607ca46eSDavid Howells  * offset within that address range.  Every time when the kernel receives a
545*607ca46eSDavid Howells  * request within the range, an &fw_cdev_event_request2 event will be emitted.
546*607ca46eSDavid Howells  * (If the kernel or the client implements ABI version <= 3, an
547*607ca46eSDavid Howells  * &fw_cdev_event_request will be generated instead.)
548*607ca46eSDavid Howells  *
549*607ca46eSDavid Howells  * The @closure field is passed back to userspace in these request events.
550*607ca46eSDavid Howells  * The @handle field is an out parameter, returning a handle to the allocated
551*607ca46eSDavid Howells  * range to be used for later deallocation of the range.
552*607ca46eSDavid Howells  *
553*607ca46eSDavid Howells  * The address range is allocated on all local nodes.  The address allocation
554*607ca46eSDavid Howells  * is exclusive except for the FCP command and response registers.  If an
555*607ca46eSDavid Howells  * exclusive address region is already in use, the ioctl fails with errno set
556*607ca46eSDavid Howells  * to %EBUSY.
557*607ca46eSDavid Howells  *
558*607ca46eSDavid Howells  * If kernel and client implement ABI version >= 4, the kernel looks up a free
559*607ca46eSDavid Howells  * spot of size @length inside [@offset..@region_end) and, if found, writes
560*607ca46eSDavid Howells  * the start address of the new CSR back in @offset.  I.e. @offset is an
561*607ca46eSDavid Howells  * in and out parameter.  If this automatic placement of a CSR in a bigger
562*607ca46eSDavid Howells  * address range is not desired, the client simply needs to set @region_end
563*607ca46eSDavid Howells  * = @offset + @length.
564*607ca46eSDavid Howells  *
565*607ca46eSDavid Howells  * If the kernel or the client implements ABI version <= 3, @region_end is
566*607ca46eSDavid Howells  * ignored and effectively assumed to be @offset + @length.
567*607ca46eSDavid Howells  *
568*607ca46eSDavid Howells  * @region_end is only present in a kernel header >= 2.6.36.  If necessary,
569*607ca46eSDavid Howells  * this can for example be tested by #ifdef FW_CDEV_EVENT_REQUEST2.
570*607ca46eSDavid Howells  */
571*607ca46eSDavid Howells struct fw_cdev_allocate {
572*607ca46eSDavid Howells 	__u64 offset;
573*607ca46eSDavid Howells 	__u64 closure;
574*607ca46eSDavid Howells 	__u32 length;
575*607ca46eSDavid Howells 	__u32 handle;
576*607ca46eSDavid Howells 	__u64 region_end;	/* available since kernel version 2.6.36 */
577*607ca46eSDavid Howells };
578*607ca46eSDavid Howells 
579*607ca46eSDavid Howells /**
580*607ca46eSDavid Howells  * struct fw_cdev_deallocate - Free a CSR address range or isochronous resource
581*607ca46eSDavid Howells  * @handle:	Handle to the address range or iso resource, as returned by the
582*607ca46eSDavid Howells  *		kernel when the range or resource was allocated
583*607ca46eSDavid Howells  */
584*607ca46eSDavid Howells struct fw_cdev_deallocate {
585*607ca46eSDavid Howells 	__u32 handle;
586*607ca46eSDavid Howells };
587*607ca46eSDavid Howells 
588*607ca46eSDavid Howells #define FW_CDEV_LONG_RESET	0
589*607ca46eSDavid Howells #define FW_CDEV_SHORT_RESET	1
590*607ca46eSDavid Howells 
591*607ca46eSDavid Howells /**
592*607ca46eSDavid Howells  * struct fw_cdev_initiate_bus_reset - Initiate a bus reset
593*607ca46eSDavid Howells  * @type:	%FW_CDEV_SHORT_RESET or %FW_CDEV_LONG_RESET
594*607ca46eSDavid Howells  *
595*607ca46eSDavid Howells  * Initiate a bus reset for the bus this device is on.  The bus reset can be
596*607ca46eSDavid Howells  * either the original (long) bus reset or the arbitrated (short) bus reset
597*607ca46eSDavid Howells  * introduced in 1394a-2000.
598*607ca46eSDavid Howells  *
599*607ca46eSDavid Howells  * The ioctl returns immediately.  A subsequent &fw_cdev_event_bus_reset
600*607ca46eSDavid Howells  * indicates when the reset actually happened.  Since ABI v4, this may be
601*607ca46eSDavid Howells  * considerably later than the ioctl because the kernel ensures a grace period
602*607ca46eSDavid Howells  * between subsequent bus resets as per IEEE 1394 bus management specification.
603*607ca46eSDavid Howells  */
604*607ca46eSDavid Howells struct fw_cdev_initiate_bus_reset {
605*607ca46eSDavid Howells 	__u32 type;
606*607ca46eSDavid Howells };
607*607ca46eSDavid Howells 
608*607ca46eSDavid Howells /**
609*607ca46eSDavid Howells  * struct fw_cdev_add_descriptor - Add contents to the local node's config ROM
610*607ca46eSDavid Howells  * @immediate:	If non-zero, immediate key to insert before pointer
611*607ca46eSDavid Howells  * @key:	Upper 8 bits of root directory pointer
612*607ca46eSDavid Howells  * @data:	Userspace pointer to contents of descriptor block
613*607ca46eSDavid Howells  * @length:	Length of descriptor block data, in quadlets
614*607ca46eSDavid Howells  * @handle:	Handle to the descriptor, written by the kernel
615*607ca46eSDavid Howells  *
616*607ca46eSDavid Howells  * Add a descriptor block and optionally a preceding immediate key to the local
617*607ca46eSDavid Howells  * node's Configuration ROM.
618*607ca46eSDavid Howells  *
619*607ca46eSDavid Howells  * The @key field specifies the upper 8 bits of the descriptor root directory
620*607ca46eSDavid Howells  * pointer and the @data and @length fields specify the contents. The @key
621*607ca46eSDavid Howells  * should be of the form 0xXX000000. The offset part of the root directory entry
622*607ca46eSDavid Howells  * will be filled in by the kernel.
623*607ca46eSDavid Howells  *
624*607ca46eSDavid Howells  * If not 0, the @immediate field specifies an immediate key which will be
625*607ca46eSDavid Howells  * inserted before the root directory pointer.
626*607ca46eSDavid Howells  *
627*607ca46eSDavid Howells  * @immediate, @key, and @data array elements are CPU-endian quadlets.
628*607ca46eSDavid Howells  *
629*607ca46eSDavid Howells  * If successful, the kernel adds the descriptor and writes back a @handle to
630*607ca46eSDavid Howells  * the kernel-side object to be used for later removal of the descriptor block
631*607ca46eSDavid Howells  * and immediate key.  The kernel will also generate a bus reset to signal the
632*607ca46eSDavid Howells  * change of the Configuration ROM to other nodes.
633*607ca46eSDavid Howells  *
634*607ca46eSDavid Howells  * This ioctl affects the Configuration ROMs of all local nodes.
635*607ca46eSDavid Howells  * The ioctl only succeeds on device files which represent a local node.
636*607ca46eSDavid Howells  */
637*607ca46eSDavid Howells struct fw_cdev_add_descriptor {
638*607ca46eSDavid Howells 	__u32 immediate;
639*607ca46eSDavid Howells 	__u32 key;
640*607ca46eSDavid Howells 	__u64 data;
641*607ca46eSDavid Howells 	__u32 length;
642*607ca46eSDavid Howells 	__u32 handle;
643*607ca46eSDavid Howells };
644*607ca46eSDavid Howells 
645*607ca46eSDavid Howells /**
646*607ca46eSDavid Howells  * struct fw_cdev_remove_descriptor - Remove contents from the Configuration ROM
647*607ca46eSDavid Howells  * @handle:	Handle to the descriptor, as returned by the kernel when the
648*607ca46eSDavid Howells  *		descriptor was added
649*607ca46eSDavid Howells  *
650*607ca46eSDavid Howells  * Remove a descriptor block and accompanying immediate key from the local
651*607ca46eSDavid Howells  * nodes' Configuration ROMs.  The kernel will also generate a bus reset to
652*607ca46eSDavid Howells  * signal the change of the Configuration ROM to other nodes.
653*607ca46eSDavid Howells  */
654*607ca46eSDavid Howells struct fw_cdev_remove_descriptor {
655*607ca46eSDavid Howells 	__u32 handle;
656*607ca46eSDavid Howells };
657*607ca46eSDavid Howells 
658*607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_TRANSMIT			0
659*607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_RECEIVE			1
660*607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL	2 /* added in 2.6.36 */
661*607ca46eSDavid Howells 
662*607ca46eSDavid Howells /**
663*607ca46eSDavid Howells  * struct fw_cdev_create_iso_context - Create a context for isochronous I/O
664*607ca46eSDavid Howells  * @type:	%FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE or
665*607ca46eSDavid Howells  *		%FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL
666*607ca46eSDavid Howells  * @header_size: Header size to strip in single-channel reception
667*607ca46eSDavid Howells  * @channel:	Channel to bind to in single-channel reception or transmission
668*607ca46eSDavid Howells  * @speed:	Transmission speed
669*607ca46eSDavid Howells  * @closure:	To be returned in &fw_cdev_event_iso_interrupt or
670*607ca46eSDavid Howells  *		&fw_cdev_event_iso_interrupt_multichannel
671*607ca46eSDavid Howells  * @handle:	Handle to context, written back by kernel
672*607ca46eSDavid Howells  *
673*607ca46eSDavid Howells  * Prior to sending or receiving isochronous I/O, a context must be created.
674*607ca46eSDavid Howells  * The context records information about the transmit or receive configuration
675*607ca46eSDavid Howells  * and typically maps to an underlying hardware resource.  A context is set up
676*607ca46eSDavid Howells  * for either sending or receiving.  It is bound to a specific isochronous
677*607ca46eSDavid Howells  * @channel.
678*607ca46eSDavid Howells  *
679*607ca46eSDavid Howells  * In case of multichannel reception, @header_size and @channel are ignored
680*607ca46eSDavid Howells  * and the channels are selected by %FW_CDEV_IOC_SET_ISO_CHANNELS.
681*607ca46eSDavid Howells  *
682*607ca46eSDavid Howells  * For %FW_CDEV_ISO_CONTEXT_RECEIVE contexts, @header_size must be at least 4
683*607ca46eSDavid Howells  * and must be a multiple of 4.  It is ignored in other context types.
684*607ca46eSDavid Howells  *
685*607ca46eSDavid Howells  * @speed is ignored in receive context types.
686*607ca46eSDavid Howells  *
687*607ca46eSDavid Howells  * If a context was successfully created, the kernel writes back a handle to the
688*607ca46eSDavid Howells  * context, which must be passed in for subsequent operations on that context.
689*607ca46eSDavid Howells  *
690*607ca46eSDavid Howells  * Limitations:
691*607ca46eSDavid Howells  * No more than one iso context can be created per fd.
692*607ca46eSDavid Howells  * The total number of contexts that all userspace and kernelspace drivers can
693*607ca46eSDavid Howells  * create on a card at a time is a hardware limit, typically 4 or 8 contexts per
694*607ca46eSDavid Howells  * direction, and of them at most one multichannel receive context.
695*607ca46eSDavid Howells  */
696*607ca46eSDavid Howells struct fw_cdev_create_iso_context {
697*607ca46eSDavid Howells 	__u32 type;
698*607ca46eSDavid Howells 	__u32 header_size;
699*607ca46eSDavid Howells 	__u32 channel;
700*607ca46eSDavid Howells 	__u32 speed;
701*607ca46eSDavid Howells 	__u64 closure;
702*607ca46eSDavid Howells 	__u32 handle;
703*607ca46eSDavid Howells };
704*607ca46eSDavid Howells 
705*607ca46eSDavid Howells /**
706*607ca46eSDavid Howells  * struct fw_cdev_set_iso_channels - Select channels in multichannel reception
707*607ca46eSDavid Howells  * @channels:	Bitmask of channels to listen to
708*607ca46eSDavid Howells  * @handle:	Handle of the mutichannel receive context
709*607ca46eSDavid Howells  *
710*607ca46eSDavid Howells  * @channels is the bitwise or of 1ULL << n for each channel n to listen to.
711*607ca46eSDavid Howells  *
712*607ca46eSDavid Howells  * The ioctl fails with errno %EBUSY if there is already another receive context
713*607ca46eSDavid Howells  * on a channel in @channels.  In that case, the bitmask of all unoccupied
714*607ca46eSDavid Howells  * channels is returned in @channels.
715*607ca46eSDavid Howells  */
716*607ca46eSDavid Howells struct fw_cdev_set_iso_channels {
717*607ca46eSDavid Howells 	__u64 channels;
718*607ca46eSDavid Howells 	__u32 handle;
719*607ca46eSDavid Howells };
720*607ca46eSDavid Howells 
721*607ca46eSDavid Howells #define FW_CDEV_ISO_PAYLOAD_LENGTH(v)	(v)
722*607ca46eSDavid Howells #define FW_CDEV_ISO_INTERRUPT		(1 << 16)
723*607ca46eSDavid Howells #define FW_CDEV_ISO_SKIP		(1 << 17)
724*607ca46eSDavid Howells #define FW_CDEV_ISO_SYNC		(1 << 17)
725*607ca46eSDavid Howells #define FW_CDEV_ISO_TAG(v)		((v) << 18)
726*607ca46eSDavid Howells #define FW_CDEV_ISO_SY(v)		((v) << 20)
727*607ca46eSDavid Howells #define FW_CDEV_ISO_HEADER_LENGTH(v)	((v) << 24)
728*607ca46eSDavid Howells 
729*607ca46eSDavid Howells /**
730*607ca46eSDavid Howells  * struct fw_cdev_iso_packet - Isochronous packet
731*607ca46eSDavid Howells  * @control:	Contains the header length (8 uppermost bits),
732*607ca46eSDavid Howells  *		the sy field (4 bits), the tag field (2 bits), a sync flag
733*607ca46eSDavid Howells  *		or a skip flag (1 bit), an interrupt flag (1 bit), and the
734*607ca46eSDavid Howells  *		payload length (16 lowermost bits)
735*607ca46eSDavid Howells  * @header:	Header and payload in case of a transmit context.
736*607ca46eSDavid Howells  *
737*607ca46eSDavid Howells  * &struct fw_cdev_iso_packet is used to describe isochronous packet queues.
738*607ca46eSDavid Howells  * Use the FW_CDEV_ISO_ macros to fill in @control.
739*607ca46eSDavid Howells  * The @header array is empty in case of receive contexts.
740*607ca46eSDavid Howells  *
741*607ca46eSDavid Howells  * Context type %FW_CDEV_ISO_CONTEXT_TRANSMIT:
742*607ca46eSDavid Howells  *
743*607ca46eSDavid Howells  * @control.HEADER_LENGTH must be a multiple of 4.  It specifies the numbers of
744*607ca46eSDavid Howells  * bytes in @header that will be prepended to the packet's payload.  These bytes
745*607ca46eSDavid Howells  * are copied into the kernel and will not be accessed after the ioctl has
746*607ca46eSDavid Howells  * returned.
747*607ca46eSDavid Howells  *
748*607ca46eSDavid Howells  * The @control.SY and TAG fields are copied to the iso packet header.  These
749*607ca46eSDavid Howells  * fields are specified by IEEE 1394a and IEC 61883-1.
750*607ca46eSDavid Howells  *
751*607ca46eSDavid Howells  * The @control.SKIP flag specifies that no packet is to be sent in a frame.
752*607ca46eSDavid Howells  * When using this, all other fields except @control.INTERRUPT must be zero.
753*607ca46eSDavid Howells  *
754*607ca46eSDavid Howells  * When a packet with the @control.INTERRUPT flag set has been completed, an
755*607ca46eSDavid Howells  * &fw_cdev_event_iso_interrupt event will be sent.
756*607ca46eSDavid Howells  *
757*607ca46eSDavid Howells  * Context type %FW_CDEV_ISO_CONTEXT_RECEIVE:
758*607ca46eSDavid Howells  *
759*607ca46eSDavid Howells  * @control.HEADER_LENGTH must be a multiple of the context's header_size.
760*607ca46eSDavid Howells  * If the HEADER_LENGTH is larger than the context's header_size, multiple
761*607ca46eSDavid Howells  * packets are queued for this entry.
762*607ca46eSDavid Howells  *
763*607ca46eSDavid Howells  * The @control.SY and TAG fields are ignored.
764*607ca46eSDavid Howells  *
765*607ca46eSDavid Howells  * If the @control.SYNC flag is set, the context drops all packets until a
766*607ca46eSDavid Howells  * packet with a sy field is received which matches &fw_cdev_start_iso.sync.
767*607ca46eSDavid Howells  *
768*607ca46eSDavid Howells  * @control.PAYLOAD_LENGTH defines how many payload bytes can be received for
769*607ca46eSDavid Howells  * one packet (in addition to payload quadlets that have been defined as headers
770*607ca46eSDavid Howells  * and are stripped and returned in the &fw_cdev_event_iso_interrupt structure).
771*607ca46eSDavid Howells  * If more bytes are received, the additional bytes are dropped.  If less bytes
772*607ca46eSDavid Howells  * are received, the remaining bytes in this part of the payload buffer will not
773*607ca46eSDavid Howells  * be written to, not even by the next packet.  I.e., packets received in
774*607ca46eSDavid Howells  * consecutive frames will not necessarily be consecutive in memory.  If an
775*607ca46eSDavid Howells  * entry has queued multiple packets, the PAYLOAD_LENGTH is divided equally
776*607ca46eSDavid Howells  * among them.
777*607ca46eSDavid Howells  *
778*607ca46eSDavid Howells  * When a packet with the @control.INTERRUPT flag set has been completed, an
779*607ca46eSDavid Howells  * &fw_cdev_event_iso_interrupt event will be sent.  An entry that has queued
780*607ca46eSDavid Howells  * multiple receive packets is completed when its last packet is completed.
781*607ca46eSDavid Howells  *
782*607ca46eSDavid Howells  * Context type %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL:
783*607ca46eSDavid Howells  *
784*607ca46eSDavid Howells  * Here, &fw_cdev_iso_packet would be more aptly named _iso_buffer_chunk since
785*607ca46eSDavid Howells  * it specifies a chunk of the mmap()'ed buffer, while the number and alignment
786*607ca46eSDavid Howells  * of packets to be placed into the buffer chunk is not known beforehand.
787*607ca46eSDavid Howells  *
788*607ca46eSDavid Howells  * @control.PAYLOAD_LENGTH is the size of the buffer chunk and specifies room
789*607ca46eSDavid Howells  * for header, payload, padding, and trailer bytes of one or more packets.
790*607ca46eSDavid Howells  * It must be a multiple of 4.
791*607ca46eSDavid Howells  *
792*607ca46eSDavid Howells  * @control.HEADER_LENGTH, TAG and SY are ignored.  SYNC is treated as described
793*607ca46eSDavid Howells  * for single-channel reception.
794*607ca46eSDavid Howells  *
795*607ca46eSDavid Howells  * When a buffer chunk with the @control.INTERRUPT flag set has been filled
796*607ca46eSDavid Howells  * entirely, an &fw_cdev_event_iso_interrupt_mc event will be sent.
797*607ca46eSDavid Howells  */
798*607ca46eSDavid Howells struct fw_cdev_iso_packet {
799*607ca46eSDavid Howells 	__u32 control;
800*607ca46eSDavid Howells 	__u32 header[0];
801*607ca46eSDavid Howells };
802*607ca46eSDavid Howells 
803*607ca46eSDavid Howells /**
804*607ca46eSDavid Howells  * struct fw_cdev_queue_iso - Queue isochronous packets for I/O
805*607ca46eSDavid Howells  * @packets:	Userspace pointer to an array of &fw_cdev_iso_packet
806*607ca46eSDavid Howells  * @data:	Pointer into mmap()'ed payload buffer
807*607ca46eSDavid Howells  * @size:	Size of the @packets array, in bytes
808*607ca46eSDavid Howells  * @handle:	Isochronous context handle
809*607ca46eSDavid Howells  *
810*607ca46eSDavid Howells  * Queue a number of isochronous packets for reception or transmission.
811*607ca46eSDavid Howells  * This ioctl takes a pointer to an array of &fw_cdev_iso_packet structs,
812*607ca46eSDavid Howells  * which describe how to transmit from or receive into a contiguous region
813*607ca46eSDavid Howells  * of a mmap()'ed payload buffer.  As part of transmit packet descriptors,
814*607ca46eSDavid Howells  * a series of headers can be supplied, which will be prepended to the
815*607ca46eSDavid Howells  * payload during DMA.
816*607ca46eSDavid Howells  *
817*607ca46eSDavid Howells  * The kernel may or may not queue all packets, but will write back updated
818*607ca46eSDavid Howells  * values of the @packets, @data and @size fields, so the ioctl can be
819*607ca46eSDavid Howells  * resubmitted easily.
820*607ca46eSDavid Howells  *
821*607ca46eSDavid Howells  * In case of a multichannel receive context, @data must be quadlet-aligned
822*607ca46eSDavid Howells  * relative to the buffer start.
823*607ca46eSDavid Howells  */
824*607ca46eSDavid Howells struct fw_cdev_queue_iso {
825*607ca46eSDavid Howells 	__u64 packets;
826*607ca46eSDavid Howells 	__u64 data;
827*607ca46eSDavid Howells 	__u32 size;
828*607ca46eSDavid Howells 	__u32 handle;
829*607ca46eSDavid Howells };
830*607ca46eSDavid Howells 
831*607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_MATCH_TAG0		 1
832*607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_MATCH_TAG1		 2
833*607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_MATCH_TAG2		 4
834*607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_MATCH_TAG3		 8
835*607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS	15
836*607ca46eSDavid Howells 
837*607ca46eSDavid Howells /**
838*607ca46eSDavid Howells  * struct fw_cdev_start_iso - Start an isochronous transmission or reception
839*607ca46eSDavid Howells  * @cycle:	Cycle in which to start I/O.  If @cycle is greater than or
840*607ca46eSDavid Howells  *		equal to 0, the I/O will start on that cycle.
841*607ca46eSDavid Howells  * @sync:	Determines the value to wait for for receive packets that have
842*607ca46eSDavid Howells  *		the %FW_CDEV_ISO_SYNC bit set
843*607ca46eSDavid Howells  * @tags:	Tag filter bit mask.  Only valid for isochronous reception.
844*607ca46eSDavid Howells  *		Determines the tag values for which packets will be accepted.
845*607ca46eSDavid Howells  *		Use FW_CDEV_ISO_CONTEXT_MATCH_ macros to set @tags.
846*607ca46eSDavid Howells  * @handle:	Isochronous context handle within which to transmit or receive
847*607ca46eSDavid Howells  */
848*607ca46eSDavid Howells struct fw_cdev_start_iso {
849*607ca46eSDavid Howells 	__s32 cycle;
850*607ca46eSDavid Howells 	__u32 sync;
851*607ca46eSDavid Howells 	__u32 tags;
852*607ca46eSDavid Howells 	__u32 handle;
853*607ca46eSDavid Howells };
854*607ca46eSDavid Howells 
855*607ca46eSDavid Howells /**
856*607ca46eSDavid Howells  * struct fw_cdev_stop_iso - Stop an isochronous transmission or reception
857*607ca46eSDavid Howells  * @handle:	Handle of isochronous context to stop
858*607ca46eSDavid Howells  */
859*607ca46eSDavid Howells struct fw_cdev_stop_iso {
860*607ca46eSDavid Howells 	__u32 handle;
861*607ca46eSDavid Howells };
862*607ca46eSDavid Howells 
863*607ca46eSDavid Howells /**
864*607ca46eSDavid Howells  * struct fw_cdev_flush_iso - flush completed iso packets
865*607ca46eSDavid Howells  * @handle:	handle of isochronous context to flush
866*607ca46eSDavid Howells  *
867*607ca46eSDavid Howells  * For %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE contexts,
868*607ca46eSDavid Howells  * report any completed packets.
869*607ca46eSDavid Howells  *
870*607ca46eSDavid Howells  * For %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL contexts, report the current
871*607ca46eSDavid Howells  * offset in the receive buffer, if it has changed; this is typically in the
872*607ca46eSDavid Howells  * middle of some buffer chunk.
873*607ca46eSDavid Howells  *
874*607ca46eSDavid Howells  * Any %FW_CDEV_EVENT_ISO_INTERRUPT or %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL
875*607ca46eSDavid Howells  * events generated by this ioctl are sent synchronously, i.e., are available
876*607ca46eSDavid Howells  * for reading from the file descriptor when this ioctl returns.
877*607ca46eSDavid Howells  */
878*607ca46eSDavid Howells struct fw_cdev_flush_iso {
879*607ca46eSDavid Howells 	__u32 handle;
880*607ca46eSDavid Howells };
881*607ca46eSDavid Howells 
882*607ca46eSDavid Howells /**
883*607ca46eSDavid Howells  * struct fw_cdev_get_cycle_timer - read cycle timer register
884*607ca46eSDavid Howells  * @local_time:   system time, in microseconds since the Epoch
885*607ca46eSDavid Howells  * @cycle_timer:  Cycle Time register contents
886*607ca46eSDavid Howells  *
887*607ca46eSDavid Howells  * Same as %FW_CDEV_IOC_GET_CYCLE_TIMER2, but fixed to use %CLOCK_REALTIME
888*607ca46eSDavid Howells  * and only with microseconds resolution.
889*607ca46eSDavid Howells  *
890*607ca46eSDavid Howells  * In version 1 and 2 of the ABI, this ioctl returned unreliable (non-
891*607ca46eSDavid Howells  * monotonic) @cycle_timer values on certain controllers.
892*607ca46eSDavid Howells  */
893*607ca46eSDavid Howells struct fw_cdev_get_cycle_timer {
894*607ca46eSDavid Howells 	__u64 local_time;
895*607ca46eSDavid Howells 	__u32 cycle_timer;
896*607ca46eSDavid Howells };
897*607ca46eSDavid Howells 
898*607ca46eSDavid Howells /**
899*607ca46eSDavid Howells  * struct fw_cdev_get_cycle_timer2 - read cycle timer register
900*607ca46eSDavid Howells  * @tv_sec:       system time, seconds
901*607ca46eSDavid Howells  * @tv_nsec:      system time, sub-seconds part in nanoseconds
902*607ca46eSDavid Howells  * @clk_id:       input parameter, clock from which to get the system time
903*607ca46eSDavid Howells  * @cycle_timer:  Cycle Time register contents
904*607ca46eSDavid Howells  *
905*607ca46eSDavid Howells  * The %FW_CDEV_IOC_GET_CYCLE_TIMER2 ioctl reads the isochronous cycle timer
906*607ca46eSDavid Howells  * and also the system clock.  This allows to correlate reception time of
907*607ca46eSDavid Howells  * isochronous packets with system time.
908*607ca46eSDavid Howells  *
909*607ca46eSDavid Howells  * @clk_id lets you choose a clock like with POSIX' clock_gettime function.
910*607ca46eSDavid Howells  * Supported @clk_id values are POSIX' %CLOCK_REALTIME and %CLOCK_MONOTONIC
911*607ca46eSDavid Howells  * and Linux' %CLOCK_MONOTONIC_RAW.
912*607ca46eSDavid Howells  *
913*607ca46eSDavid Howells  * @cycle_timer consists of 7 bits cycleSeconds, 13 bits cycleCount, and
914*607ca46eSDavid Howells  * 12 bits cycleOffset, in host byte order.  Cf. the Cycle Time register
915*607ca46eSDavid Howells  * per IEEE 1394 or Isochronous Cycle Timer register per OHCI-1394.
916*607ca46eSDavid Howells  */
917*607ca46eSDavid Howells struct fw_cdev_get_cycle_timer2 {
918*607ca46eSDavid Howells 	__s64 tv_sec;
919*607ca46eSDavid Howells 	__s32 tv_nsec;
920*607ca46eSDavid Howells 	__s32 clk_id;
921*607ca46eSDavid Howells 	__u32 cycle_timer;
922*607ca46eSDavid Howells };
923*607ca46eSDavid Howells 
924*607ca46eSDavid Howells /**
925*607ca46eSDavid Howells  * struct fw_cdev_allocate_iso_resource - (De)allocate a channel or bandwidth
926*607ca46eSDavid Howells  * @closure:	Passed back to userspace in corresponding iso resource events
927*607ca46eSDavid Howells  * @channels:	Isochronous channels of which one is to be (de)allocated
928*607ca46eSDavid Howells  * @bandwidth:	Isochronous bandwidth units to be (de)allocated
929*607ca46eSDavid Howells  * @handle:	Handle to the allocation, written by the kernel (only valid in
930*607ca46eSDavid Howells  *		case of %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE ioctls)
931*607ca46eSDavid Howells  *
932*607ca46eSDavid Howells  * The %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE ioctl initiates allocation of an
933*607ca46eSDavid Howells  * isochronous channel and/or of isochronous bandwidth at the isochronous
934*607ca46eSDavid Howells  * resource manager (IRM).  Only one of the channels specified in @channels is
935*607ca46eSDavid Howells  * allocated.  An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED is sent after
936*607ca46eSDavid Howells  * communication with the IRM, indicating success or failure in the event data.
937*607ca46eSDavid Howells  * The kernel will automatically reallocate the resources after bus resets.
938*607ca46eSDavid Howells  * Should a reallocation fail, an %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event
939*607ca46eSDavid Howells  * will be sent.  The kernel will also automatically deallocate the resources
940*607ca46eSDavid Howells  * when the file descriptor is closed.
941*607ca46eSDavid Howells  *
942*607ca46eSDavid Howells  * The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE ioctl can be used to initiate
943*607ca46eSDavid Howells  * deallocation of resources which were allocated as described above.
944*607ca46eSDavid Howells  * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation.
945*607ca46eSDavid Howells  *
946*607ca46eSDavid Howells  * The %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE ioctl is a variant of allocation
947*607ca46eSDavid Howells  * without automatic re- or deallocation.
948*607ca46eSDavid Howells  * An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event concludes this operation,
949*607ca46eSDavid Howells  * indicating success or failure in its data.
950*607ca46eSDavid Howells  *
951*607ca46eSDavid Howells  * The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE ioctl works like
952*607ca46eSDavid Howells  * %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE except that resources are freed
953*607ca46eSDavid Howells  * instead of allocated.
954*607ca46eSDavid Howells  * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation.
955*607ca46eSDavid Howells  *
956*607ca46eSDavid Howells  * To summarize, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE allocates iso resources
957*607ca46eSDavid Howells  * for the lifetime of the fd or @handle.
958*607ca46eSDavid Howells  * In contrast, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE allocates iso resources
959*607ca46eSDavid Howells  * for the duration of a bus generation.
960*607ca46eSDavid Howells  *
961*607ca46eSDavid Howells  * @channels is a host-endian bitfield with the least significant bit
962*607ca46eSDavid Howells  * representing channel 0 and the most significant bit representing channel 63:
963*607ca46eSDavid Howells  * 1ULL << c for each channel c that is a candidate for (de)allocation.
964*607ca46eSDavid Howells  *
965*607ca46eSDavid Howells  * @bandwidth is expressed in bandwidth allocation units, i.e. the time to send
966*607ca46eSDavid Howells  * one quadlet of data (payload or header data) at speed S1600.
967*607ca46eSDavid Howells  */
968*607ca46eSDavid Howells struct fw_cdev_allocate_iso_resource {
969*607ca46eSDavid Howells 	__u64 closure;
970*607ca46eSDavid Howells 	__u64 channels;
971*607ca46eSDavid Howells 	__u32 bandwidth;
972*607ca46eSDavid Howells 	__u32 handle;
973*607ca46eSDavid Howells };
974*607ca46eSDavid Howells 
975*607ca46eSDavid Howells /**
976*607ca46eSDavid Howells  * struct fw_cdev_send_stream_packet - send an asynchronous stream packet
977*607ca46eSDavid Howells  * @length:	Length of outgoing payload, in bytes
978*607ca46eSDavid Howells  * @tag:	Data format tag
979*607ca46eSDavid Howells  * @channel:	Isochronous channel to transmit to
980*607ca46eSDavid Howells  * @sy:		Synchronization code
981*607ca46eSDavid Howells  * @closure:	Passed back to userspace in the response event
982*607ca46eSDavid Howells  * @data:	Userspace pointer to payload
983*607ca46eSDavid Howells  * @generation:	The bus generation where packet is valid
984*607ca46eSDavid Howells  * @speed:	Speed to transmit at
985*607ca46eSDavid Howells  *
986*607ca46eSDavid Howells  * The %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl sends an asynchronous stream packet
987*607ca46eSDavid Howells  * to every device which is listening to the specified channel.  The kernel
988*607ca46eSDavid Howells  * writes an &fw_cdev_event_response event which indicates success or failure of
989*607ca46eSDavid Howells  * the transmission.
990*607ca46eSDavid Howells  */
991*607ca46eSDavid Howells struct fw_cdev_send_stream_packet {
992*607ca46eSDavid Howells 	__u32 length;
993*607ca46eSDavid Howells 	__u32 tag;
994*607ca46eSDavid Howells 	__u32 channel;
995*607ca46eSDavid Howells 	__u32 sy;
996*607ca46eSDavid Howells 	__u64 closure;
997*607ca46eSDavid Howells 	__u64 data;
998*607ca46eSDavid Howells 	__u32 generation;
999*607ca46eSDavid Howells 	__u32 speed;
1000*607ca46eSDavid Howells };
1001*607ca46eSDavid Howells 
1002*607ca46eSDavid Howells /**
1003*607ca46eSDavid Howells  * struct fw_cdev_send_phy_packet - send a PHY packet
1004*607ca46eSDavid Howells  * @closure:	Passed back to userspace in the PHY-packet-sent event
1005*607ca46eSDavid Howells  * @data:	First and second quadlet of the PHY packet
1006*607ca46eSDavid Howells  * @generation:	The bus generation where packet is valid
1007*607ca46eSDavid Howells  *
1008*607ca46eSDavid Howells  * The %FW_CDEV_IOC_SEND_PHY_PACKET ioctl sends a PHY packet to all nodes
1009*607ca46eSDavid Howells  * on the same card as this device.  After transmission, an
1010*607ca46eSDavid Howells  * %FW_CDEV_EVENT_PHY_PACKET_SENT event is generated.
1011*607ca46eSDavid Howells  *
1012*607ca46eSDavid Howells  * The payload @data[] shall be specified in host byte order.  Usually,
1013*607ca46eSDavid Howells  * @data[1] needs to be the bitwise inverse of @data[0].  VersaPHY packets
1014*607ca46eSDavid Howells  * are an exception to this rule.
1015*607ca46eSDavid Howells  *
1016*607ca46eSDavid Howells  * The ioctl is only permitted on device files which represent a local node.
1017*607ca46eSDavid Howells  */
1018*607ca46eSDavid Howells struct fw_cdev_send_phy_packet {
1019*607ca46eSDavid Howells 	__u64 closure;
1020*607ca46eSDavid Howells 	__u32 data[2];
1021*607ca46eSDavid Howells 	__u32 generation;
1022*607ca46eSDavid Howells };
1023*607ca46eSDavid Howells 
1024*607ca46eSDavid Howells /**
1025*607ca46eSDavid Howells  * struct fw_cdev_receive_phy_packets - start reception of PHY packets
1026*607ca46eSDavid Howells  * @closure: Passed back to userspace in phy packet events
1027*607ca46eSDavid Howells  *
1028*607ca46eSDavid Howells  * This ioctl activates issuing of %FW_CDEV_EVENT_PHY_PACKET_RECEIVED due to
1029*607ca46eSDavid Howells  * incoming PHY packets from any node on the same bus as the device.
1030*607ca46eSDavid Howells  *
1031*607ca46eSDavid Howells  * The ioctl is only permitted on device files which represent a local node.
1032*607ca46eSDavid Howells  */
1033*607ca46eSDavid Howells struct fw_cdev_receive_phy_packets {
1034*607ca46eSDavid Howells 	__u64 closure;
1035*607ca46eSDavid Howells };
1036*607ca46eSDavid Howells 
1037*607ca46eSDavid Howells #define FW_CDEV_VERSION 3 /* Meaningless legacy macro; don't use it. */
1038*607ca46eSDavid Howells 
1039*607ca46eSDavid Howells #endif /* _LINUX_FIREWIRE_CDEV_H */
1040