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