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