blob: da0fec7e8dc0a3a05010f3a5c63d061cb3ba8e58 [file] [log] [blame]
Kristian Høgsberg4c5a4432007-05-07 20:33:37 -04001/*
2 * Char device interface.
Kristian Høgsberg19a15b92006-12-19 19:58:31 -05003 *
4 * Copyright (C) 2005-2006 Kristian Hoegsberg <krh@bitplanet.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
Kristian Høgsberg4c5a4432007-05-07 20:33:37 -040021#ifndef _LINUX_FIREWIRE_CDEV_H
22#define _LINUX_FIREWIRE_CDEV_H
Kristian Høgsberg19a15b92006-12-19 19:58:31 -050023
Kristian Høgsberg04dfb8d2007-05-07 20:33:36 -040024#include <linux/ioctl.h>
25#include <linux/types.h>
Kristian Høgsberg4c5a4432007-05-07 20:33:37 -040026#include <linux/firewire-constants.h>
Kristian Høgsberg19a15b92006-12-19 19:58:31 -050027
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +010028#define FW_CDEV_EVENT_BUS_RESET 0x00
29#define FW_CDEV_EVENT_RESPONSE 0x01
30#define FW_CDEV_EVENT_REQUEST 0x02
31#define FW_CDEV_EVENT_ISO_INTERRUPT 0x03
32#define FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED 0x04
33#define FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 0x05
Kristian Høgsberg19a15b92006-12-19 19:58:31 -050034
Stefan Richtere2055972010-06-20 22:53:55 +020035/* available since kernel version 2.6.36 */
36#define FW_CDEV_EVENT_REQUEST2 0x06
Stefan Richter850bb6f2010-07-16 22:25:14 +020037#define FW_CDEV_EVENT_PHY_PACKET_SENT 0x07
Stefan Richterbf54e142010-07-16 22:25:51 +020038#define FW_CDEV_EVENT_PHY_PACKET_RECEIVED 0x08
Stefan Richtere2055972010-06-20 22:53:55 +020039
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +020040/**
41 * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types
42 * @closure: For arbitrary use by userspace
43 * @type: Discriminates the fw_cdev_event_ types
44 *
45 * This struct may be used to access generic members of all fw_cdev_event_
46 * types regardless of the specific type.
47 *
48 * Data passed in the @closure field for a request will be returned in the
49 * corresponding event. It is big enough to hold a pointer on all platforms.
50 * The ioctl used to set @closure depends on the @type of event.
51 */
Kristian Høgsbergda8ecff2007-03-27 01:43:39 -040052struct fw_cdev_event_common {
53 __u64 closure;
54 __u32 type;
55};
56
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +020057/**
58 * struct fw_cdev_event_bus_reset - Sent when a bus reset occurred
59 * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_GET_INFO ioctl
60 * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_BUS_RESET
61 * @node_id: New node ID of this node
62 * @local_node_id: Node ID of the local node, i.e. of the controller
63 * @bm_node_id: Node ID of the bus manager
64 * @irm_node_id: Node ID of the iso resource manager
65 * @root_node_id: Node ID of the root node
66 * @generation: New bus generation
67 *
68 * This event is sent when the bus the device belongs to goes through a bus
69 * reset. It provides information about the new bus configuration, such as
70 * new node ID for this device, new root ID, and others.
Stefan Richter250b2b62010-06-21 23:24:35 +020071 *
72 * If @bm_node_id is 0xffff right after bus reset it can be reread by an
73 * %FW_CDEV_IOC_GET_INFO ioctl after bus manager selection was finished.
74 * Kernels with ABI version < 4 do not set @bm_node_id.
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +020075 */
Kristian Høgsberg97bd9ef2007-03-07 12:12:41 -050076struct fw_cdev_event_bus_reset {
Kristian Høgsbergda8ecff2007-03-27 01:43:39 -040077 __u64 closure;
Kristian Høgsberg97bd9ef2007-03-07 12:12:41 -050078 __u32 type;
79 __u32 node_id;
80 __u32 local_node_id;
81 __u32 bm_node_id;
82 __u32 irm_node_id;
83 __u32 root_node_id;
84 __u32 generation;
85};
86
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +020087/**
88 * struct fw_cdev_event_response - Sent when a response packet was received
Stefan Richterd505e6e2010-07-17 21:36:02 +020089 * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_REQUEST
90 * or %FW_CDEV_IOC_SEND_BROADCAST_REQUEST
91 * or %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +020092 * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_RESPONSE
93 * @rcode: Response code returned by the remote node
94 * @length: Data length, i.e. the response's payload size in bytes
95 * @data: Payload data, if any
96 *
97 * This event is sent when the stack receives a response to an outgoing request
98 * sent by %FW_CDEV_IOC_SEND_REQUEST ioctl. The payload data for responses
99 * carrying data (read and lock responses) follows immediately and can be
100 * accessed through the @data field.
Stefan Richterd505e6e2010-07-17 21:36:02 +0200101 *
102 * The event is also generated after conclusions of transactions that do not
103 * involve response packets. This includes unified write transactions,
104 * broadcast write transactions, and transmission of asynchronous stream
105 * packets. @rcode indicates success or failure of such transmissions.
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200106 */
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500107struct fw_cdev_event_response {
Kristian Høgsbergda8ecff2007-03-27 01:43:39 -0400108 __u64 closure;
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500109 __u32 type;
110 __u32 rcode;
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500111 __u32 length;
112 __u32 data[0];
113};
114
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200115/**
Stefan Richtere2055972010-06-20 22:53:55 +0200116 * struct fw_cdev_event_request - Old version of &fw_cdev_event_request2
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200117 * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl
118 * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST
Stefan Richtere2055972010-06-20 22:53:55 +0200119 * @tcode: See &fw_cdev_event_request2
120 * @offset: See &fw_cdev_event_request2
121 * @handle: See &fw_cdev_event_request2
122 * @length: See &fw_cdev_event_request2
123 * @data: See &fw_cdev_event_request2
124 *
125 * This event is sent instead of &fw_cdev_event_request2 if the kernel or
126 * the client implements ABI version <= 3.
127 *
128 * Unlike &fw_cdev_event_request2, the sender identity cannot be established,
129 * broadcast write requests cannot be distinguished from unicast writes, and
130 * @tcode of lock requests is %TCODE_LOCK_REQUEST.
131 *
132 * Requests to the FCP_REQUEST or FCP_RESPONSE register are responded to as
133 * with &fw_cdev_event_request2, except in kernel 2.6.32 and older which send
134 * the response packet of the client's %FW_CDEV_IOC_SEND_RESPONSE ioctl.
135 */
136struct fw_cdev_event_request {
137 __u64 closure;
138 __u32 type;
139 __u32 tcode;
140 __u64 offset;
141 __u32 handle;
142 __u32 length;
143 __u32 data[0];
144};
145
146/**
147 * struct fw_cdev_event_request2 - Sent on incoming request to an address region
148 * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl
149 * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST2
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200150 * @tcode: Transaction code of the incoming request
151 * @offset: The offset into the 48-bit per-node address space
Stefan Richtere2055972010-06-20 22:53:55 +0200152 * @source_node_id: Sender node ID
153 * @destination_node_id: Destination node ID
154 * @card: The index of the card from which the request came
155 * @generation: Bus generation in which the request is valid
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200156 * @handle: Reference to the kernel-side pending request
157 * @length: Data length, i.e. the request's payload size in bytes
158 * @data: Incoming data, if any
159 *
160 * This event is sent when the stack receives an incoming request to an address
161 * region registered using the %FW_CDEV_IOC_ALLOCATE ioctl. The request is
162 * guaranteed to be completely contained in the specified region. Userspace is
163 * responsible for sending the response by %FW_CDEV_IOC_SEND_RESPONSE ioctl,
164 * using the same @handle.
165 *
166 * The payload data for requests carrying data (write and lock requests)
167 * follows immediately and can be accessed through the @data field.
Stefan Richtere2055972010-06-20 22:53:55 +0200168 *
169 * Unlike &fw_cdev_event_request, @tcode of lock requests is one of the
170 * firewire-core specific %TCODE_LOCK_MASK_SWAP...%TCODE_LOCK_VENDOR_DEPENDENT,
171 * i.e. encodes the extended transaction code.
172 *
173 * @card may differ from &fw_cdev_get_info.card because requests are received
174 * from all cards of the Linux host. @source_node_id, @destination_node_id, and
175 * @generation pertain to that card. Destination node ID and bus generation may
176 * therefore differ from the corresponding fields of the last
177 * &fw_cdev_event_bus_reset.
178 *
179 * @destination_node_id may also differ from the current node ID because of a
180 * non-local bus ID part or in case of a broadcast write request. Note, a
181 * client must call an %FW_CDEV_IOC_SEND_RESPONSE ioctl even in case of a
182 * broadcast write request; the kernel will then release the kernel-side pending
183 * request but will not actually send a response packet.
184 *
185 * In case of a write request to FCP_REQUEST or FCP_RESPONSE, the kernel already
186 * sent a write response immediately after the request was received; in this
187 * case the client must still call an %FW_CDEV_IOC_SEND_RESPONSE ioctl to
188 * release the kernel-side pending request, though another response won't be
189 * sent.
190 *
191 * If the client subsequently needs to initiate requests to the sender node of
192 * an &fw_cdev_event_request2, it needs to use a device file with matching
193 * card index, node ID, and generation for outbound requests.
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200194 */
Stefan Richtere2055972010-06-20 22:53:55 +0200195struct fw_cdev_event_request2 {
Kristian Høgsbergda8ecff2007-03-27 01:43:39 -0400196 __u64 closure;
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500197 __u32 type;
198 __u32 tcode;
199 __u64 offset;
Stefan Richtere2055972010-06-20 22:53:55 +0200200 __u32 source_node_id;
201 __u32 destination_node_id;
202 __u32 card;
203 __u32 generation;
Kristian Høgsberg3964a442007-03-27 01:43:41 -0400204 __u32 handle;
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500205 __u32 length;
206 __u32 data[0];
207};
208
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200209/**
210 * struct fw_cdev_event_iso_interrupt - Sent when an iso packet was completed
211 * @closure: See &fw_cdev_event_common;
212 * set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl
213 * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_ISO_INTERRUPT
214 * @cycle: Cycle counter of the interrupt packet
215 * @header_length: Total length of following headers, in bytes
216 * @header: Stripped headers, if any
217 *
218 * This event is sent when the controller has completed an &fw_cdev_iso_packet
Stefan Richter3b2b65d2010-06-20 22:54:22 +0200219 * with the %FW_CDEV_ISO_INTERRUPT bit set.
220 *
221 * Isochronous transmit events:
222 *
223 * In version 1 of the ABI, &header_length is 0. In version 3 and some
224 * implementations of version 2 of the ABI, &header_length is a multiple of 4
225 * and &header contains timestamps of all packets up until the interrupt packet.
226 * The format of the timestamps is as described below for isochronous reception.
227 *
228 * Isochronous receive events:
229 *
230 * The headers stripped of all packets up until and including the interrupt
231 * packet are returned in the @header field. The amount of header data per
232 * packet is as specified at iso context creation by
233 * &fw_cdev_create_iso_context.header_size.
Stefan Richter77258da2009-01-07 20:14:53 +0100234 *
235 * In version 1 of this ABI, header data consisted of the 1394 isochronous
236 * packet header, followed by quadlets from the packet payload if
237 * &fw_cdev_create_iso_context.header_size > 4.
238 *
239 * In version 2 of this ABI, header data consist of the 1394 isochronous
240 * packet header, followed by a timestamp quadlet if
241 * &fw_cdev_create_iso_context.header_size > 4, followed by quadlets from the
242 * packet payload if &fw_cdev_create_iso_context.header_size > 8.
243 *
244 * Behaviour of ver. 1 of this ABI is no longer available since ABI ver. 2.
245 *
246 * Format of 1394 iso packet header: 16 bits len, 2 bits tag, 6 bits channel,
247 * 4 bits tcode, 4 bits sy, in big endian byte order. Format of timestamp:
248 * 16 bits invalid, 3 bits cycleSeconds, 13 bits cycleCount, in big endian byte
249 * order.
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200250 */
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500251struct fw_cdev_event_iso_interrupt {
Kristian Høgsbergda8ecff2007-03-27 01:43:39 -0400252 __u64 closure;
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500253 __u32 type;
254 __u32 cycle;
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200255 __u32 header_length;
Kristian Høgsberg9b32d5f2007-02-16 17:34:44 -0500256 __u32 header[0];
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500257};
258
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200259/**
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100260 * struct fw_cdev_event_iso_resource - Iso resources were allocated or freed
261 * @closure: See &fw_cdev_event_common;
Stefan Richter1ec3c022009-01-04 16:23:29 +0100262 * set by %FW_CDEV_IOC_(DE)ALLOCATE_ISO_RESOURCE(_ONCE) ioctl
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100263 * @type: %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or
264 * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED
265 * @handle: Reference by which an allocated resource can be deallocated
266 * @channel: Isochronous channel which was (de)allocated, if any
267 * @bandwidth: Bandwidth allocation units which were (de)allocated, if any
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100268 *
269 * An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event is sent after an isochronous
270 * resource was allocated at the IRM. The client has to check @channel and
271 * @bandwidth for whether the allocation actually succeeded.
272 *
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100273 * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event is sent after an isochronous
274 * resource was deallocated at the IRM. It is also sent when automatic
275 * reallocation after a bus reset failed.
Stefan Richter1ec3c022009-01-04 16:23:29 +0100276 *
277 * @channel is <0 if no channel was (de)allocated or if reallocation failed.
278 * @bandwidth is 0 if no bandwidth was (de)allocated or if reallocation failed.
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100279 */
280struct fw_cdev_event_iso_resource {
281 __u64 closure;
282 __u32 type;
283 __u32 handle;
284 __s32 channel;
285 __s32 bandwidth;
286};
287
288/**
Stefan Richterbf54e142010-07-16 22:25:51 +0200289 * struct fw_cdev_event_phy_packet - A PHY packet was transmitted or received
290 * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_PHY_PACKET
291 * or %FW_CDEV_IOC_RECEIVE_PHY_PACKETS ioctl
292 * @type: %FW_CDEV_EVENT_PHY_PACKET_SENT or %..._RECEIVED
Stefan Richter850bb6f2010-07-16 22:25:14 +0200293 * @rcode: %RCODE_..., indicates success or failure of transmission
Stefan Richterbf54e142010-07-16 22:25:51 +0200294 * @length: Data length in bytes
295 * @data: Incoming data
296 *
Stefan Richtercc550212010-07-18 13:00:50 +0200297 * If @type is %FW_CDEV_EVENT_PHY_PACKET_SENT, @length is 0 and @data empty,
298 * except in case of a ping packet: Then, @length is 4, and @data[0] is the
299 * ping time in 49.152MHz clocks if @rcode is %RCODE_COMPLETE.
300 *
Stefan Richterbf54e142010-07-16 22:25:51 +0200301 * If @type is %FW_CDEV_EVENT_PHY_PACKET_RECEIVED, @length is 8 and @data
302 * consists of the two PHY packet quadlets, in host byte order.
Stefan Richter850bb6f2010-07-16 22:25:14 +0200303 */
304struct fw_cdev_event_phy_packet {
305 __u64 closure;
306 __u32 type;
307 __u32 rcode;
Stefan Richterbf54e142010-07-16 22:25:51 +0200308 __u32 length;
309 __u32 data[0];
Stefan Richter850bb6f2010-07-16 22:25:14 +0200310};
311
312/**
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200313 * union fw_cdev_event - Convenience union of fw_cdev_event_ types
314 * @common: Valid for all types
315 * @bus_reset: Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET
316 * @response: Valid if @common.type == %FW_CDEV_EVENT_RESPONSE
317 * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST
Stefan Richtere2055972010-06-20 22:53:55 +0200318 * @request2: Valid if @common.type == %FW_CDEV_EVENT_REQUEST2
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200319 * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100320 * @iso_resource: Valid if @common.type ==
321 * %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or
322 * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED
Stefan Richterbf54e142010-07-16 22:25:51 +0200323 * @phy_packet: Valid if @common.type ==
324 * %FW_CDEV_EVENT_PHY_PACKET_SENT or
325 * %FW_CDEV_EVENT_PHY_PACKET_RECEIVED
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200326 *
Jay Fenlasonbe585c02008-10-01 18:13:20 -0400327 * Convenience union for userspace use. Events could be read(2) into an
328 * appropriately aligned char buffer and then cast to this union for further
329 * processing. Note that for a request, response or iso_interrupt event,
330 * the data[] or header[] may make the size of the full event larger than
331 * sizeof(union fw_cdev_event). Also note that if you attempt to read(2)
332 * an event into a buffer that is not large enough for it, the data that does
333 * not fit will be discarded so that the next read(2) will return a new event.
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200334 */
Kristian Høgsbergda8ecff2007-03-27 01:43:39 -0400335union fw_cdev_event {
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100336 struct fw_cdev_event_common common;
337 struct fw_cdev_event_bus_reset bus_reset;
338 struct fw_cdev_event_response response;
339 struct fw_cdev_event_request request;
Stefan Richtere2055972010-06-20 22:53:55 +0200340 struct fw_cdev_event_request2 request2; /* added in 2.6.36 */
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100341 struct fw_cdev_event_iso_interrupt iso_interrupt;
Stefan Richter604f4512010-06-20 22:52:55 +0200342 struct fw_cdev_event_iso_resource iso_resource; /* added in 2.6.30 */
Stefan Richter850bb6f2010-07-16 22:25:14 +0200343 struct fw_cdev_event_phy_packet phy_packet; /* added in 2.6.36 */
Kristian Høgsbergda8ecff2007-03-27 01:43:39 -0400344};
345
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100346/* available since kernel version 2.6.22 */
Stefan Richterc8a25902009-03-10 20:59:16 +0100347#define FW_CDEV_IOC_GET_INFO _IOWR('#', 0x00, struct fw_cdev_get_info)
348#define FW_CDEV_IOC_SEND_REQUEST _IOW('#', 0x01, struct fw_cdev_send_request)
349#define FW_CDEV_IOC_ALLOCATE _IOWR('#', 0x02, struct fw_cdev_allocate)
350#define FW_CDEV_IOC_DEALLOCATE _IOW('#', 0x03, struct fw_cdev_deallocate)
351#define FW_CDEV_IOC_SEND_RESPONSE _IOW('#', 0x04, struct fw_cdev_send_response)
352#define FW_CDEV_IOC_INITIATE_BUS_RESET _IOW('#', 0x05, struct fw_cdev_initiate_bus_reset)
353#define FW_CDEV_IOC_ADD_DESCRIPTOR _IOWR('#', 0x06, struct fw_cdev_add_descriptor)
354#define FW_CDEV_IOC_REMOVE_DESCRIPTOR _IOW('#', 0x07, struct fw_cdev_remove_descriptor)
355#define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOWR('#', 0x08, struct fw_cdev_create_iso_context)
356#define FW_CDEV_IOC_QUEUE_ISO _IOWR('#', 0x09, struct fw_cdev_queue_iso)
357#define FW_CDEV_IOC_START_ISO _IOW('#', 0x0a, struct fw_cdev_start_iso)
358#define FW_CDEV_IOC_STOP_ISO _IOW('#', 0x0b, struct fw_cdev_stop_iso)
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100359
360/* available since kernel version 2.6.24 */
Stefan Richterc8a25902009-03-10 20:59:16 +0100361#define FW_CDEV_IOC_GET_CYCLE_TIMER _IOR('#', 0x0c, struct fw_cdev_get_cycle_timer)
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500362
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100363/* available since kernel version 2.6.30 */
Stefan Richter1ec3c022009-01-04 16:23:29 +0100364#define FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE _IOWR('#', 0x0d, struct fw_cdev_allocate_iso_resource)
365#define FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE _IOW('#', 0x0e, struct fw_cdev_deallocate)
366#define FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE _IOW('#', 0x0f, struct fw_cdev_allocate_iso_resource)
367#define FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE _IOW('#', 0x10, struct fw_cdev_allocate_iso_resource)
Stefan Richterc8a25902009-03-10 20:59:16 +0100368#define FW_CDEV_IOC_GET_SPEED _IO('#', 0x11) /* returns speed code */
Jay Fenlason, Stefan Richteracfe8332009-01-04 16:23:29 +0100369#define FW_CDEV_IOC_SEND_BROADCAST_REQUEST _IOW('#', 0x12, struct fw_cdev_send_request)
Jay Fenlasonf8c22872009-03-05 19:08:40 +0100370#define FW_CDEV_IOC_SEND_STREAM_PACKET _IOW('#', 0x13, struct fw_cdev_send_stream_packet)
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100371
Stefan Richterabfe5a02010-02-20 12:13:49 +0100372/* available since kernel version 2.6.34 */
373#define FW_CDEV_IOC_GET_CYCLE_TIMER2 _IOWR('#', 0x14, struct fw_cdev_get_cycle_timer2)
374
Stefan Richter850bb6f2010-07-16 22:25:14 +0200375/* available since kernel version 2.6.36 */
376#define FW_CDEV_IOC_SEND_PHY_PACKET _IOWR('#', 0x15, struct fw_cdev_send_phy_packet)
Stefan Richterbf54e142010-07-16 22:25:51 +0200377#define FW_CDEV_IOC_RECEIVE_PHY_PACKETS _IOW('#', 0x16, struct fw_cdev_receive_phy_packets)
Stefan Richter850bb6f2010-07-16 22:25:14 +0200378
Stefan Richter77258da2009-01-07 20:14:53 +0100379/*
Stefan Richter604f4512010-06-20 22:52:55 +0200380 * ABI version history
Stefan Richter77258da2009-01-07 20:14:53 +0100381 * 1 (2.6.22) - initial version
Stefan Richter604f4512010-06-20 22:52:55 +0200382 * (2.6.24) - added %FW_CDEV_IOC_GET_CYCLE_TIMER
Stefan Richter77258da2009-01-07 20:14:53 +0100383 * 2 (2.6.30) - changed &fw_cdev_event_iso_interrupt.header if
384 * &fw_cdev_create_iso_context.header_size is 8 or more
Stefan Richter604f4512010-06-20 22:52:55 +0200385 * - added %FW_CDEV_IOC_*_ISO_RESOURCE*,
386 * %FW_CDEV_IOC_GET_SPEED, %FW_CDEV_IOC_SEND_BROADCAST_REQUEST,
387 * %FW_CDEV_IOC_SEND_STREAM_PACKET
Stefan Richtere94b6d72010-02-21 12:48:57 +0100388 * (2.6.32) - added time stamp to xmit &fw_cdev_event_iso_interrupt
389 * (2.6.33) - IR has always packet-per-buffer semantics now, not one of
390 * dual-buffer or packet-per-buffer depending on hardware
Stefan Richtere2055972010-06-20 22:53:55 +0200391 * - shared use and auto-response for FCP registers
Stefan Richtere94b6d72010-02-21 12:48:57 +0100392 * 3 (2.6.34) - made &fw_cdev_get_cycle_timer reliable
Stefan Richter604f4512010-06-20 22:52:55 +0200393 * - added %FW_CDEV_IOC_GET_CYCLE_TIMER2
Stefan Richterbf54e142010-07-16 22:25:51 +0200394 * 4 (2.6.36) - added %FW_CDEV_EVENT_REQUEST2, %FW_CDEV_EVENT_PHY_PACKET_*
Stefan Richter250b2b62010-06-21 23:24:35 +0200395 * - implemented &fw_cdev_event_bus_reset.bm_node_id
Stefan Richterbf54e142010-07-16 22:25:51 +0200396 * - added %FW_CDEV_IOC_SEND_PHY_PACKET, _RECEIVE_PHY_PACKETS
Kristian Høgsberg344bbc42007-03-07 12:12:43 -0500397 */
Stefan Richter604f4512010-06-20 22:52:55 +0200398#define FW_CDEV_VERSION 3 /* Meaningless; don't use this macro. */
Kristian Høgsberg344bbc42007-03-07 12:12:43 -0500399
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200400/**
401 * struct fw_cdev_get_info - General purpose information ioctl
Stefan Richter604f4512010-06-20 22:52:55 +0200402 * @version: The version field is just a running serial number. Both an
403 * input parameter (ABI version implemented by the client) and
404 * output parameter (ABI version implemented by the kernel).
405 * A client must not fill in an %FW_CDEV_VERSION defined from an
406 * included kernel header file but the actual version for which
407 * the client was implemented. This is necessary for forward
408 * compatibility. We never break backwards compatibility, but
409 * may add more structs, events, and ioctls in later revisions.
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200410 * @rom_length: If @rom is non-zero, at most rom_length bytes of configuration
411 * ROM will be copied into that user space address. In either
412 * case, @rom_length is updated with the actual length of the
413 * configuration ROM.
414 * @rom: If non-zero, address of a buffer to be filled by a copy of the
Stefan Richter632321e2009-01-02 12:47:13 +0100415 * device's configuration ROM
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200416 * @bus_reset: If non-zero, address of a buffer to be filled by a
417 * &struct fw_cdev_event_bus_reset with the current state
418 * of the bus. This does not cause a bus reset to happen.
419 * @bus_reset_closure: Value of &closure in this and subsequent bus reset events
420 * @card: The index of the card this device belongs to
421 */
Kristian Høgsberg344bbc42007-03-07 12:12:43 -0500422struct fw_cdev_get_info {
Kristian Høgsberg344bbc42007-03-07 12:12:43 -0500423 __u32 version;
Kristian Høgsberg344bbc42007-03-07 12:12:43 -0500424 __u32 rom_length;
425 __u64 rom;
Kristian Høgsberg344bbc42007-03-07 12:12:43 -0500426 __u64 bus_reset;
Kristian Høgsbergda8ecff2007-03-27 01:43:39 -0400427 __u64 bus_reset_closure;
Kristian Høgsberge7533502007-03-07 12:12:52 -0500428 __u32 card;
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500429};
430
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200431/**
432 * struct fw_cdev_send_request - Send an asynchronous request packet
433 * @tcode: Transaction code of the request
434 * @length: Length of outgoing payload, in bytes
435 * @offset: 48-bit offset at destination node
436 * @closure: Passed back to userspace in the response event
437 * @data: Userspace pointer to payload
438 * @generation: The bus generation where packet is valid
439 *
440 * Send a request to the device. This ioctl implements all outgoing requests.
441 * Both quadlet and block request specify the payload as a pointer to the data
442 * in the @data field. Once the transaction completes, the kernel writes an
Stefan Richterbf8e3352008-12-05 22:43:41 +0100443 * &fw_cdev_event_response event back. The @closure field is passed back to
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200444 * user space in the response event.
445 */
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500446struct fw_cdev_send_request {
447 __u32 tcode;
448 __u32 length;
449 __u64 offset;
450 __u64 closure;
451 __u64 data;
Kristian Høgsberg97e35272007-03-07 12:12:53 -0500452 __u32 generation;
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500453};
454
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200455/**
456 * struct fw_cdev_send_response - Send an asynchronous response packet
457 * @rcode: Response code as determined by the userspace handler
458 * @length: Length of outgoing payload, in bytes
459 * @data: Userspace pointer to payload
460 * @handle: The handle from the &fw_cdev_event_request
461 *
462 * Send a response to an incoming request. By setting up an address range using
463 * the %FW_CDEV_IOC_ALLOCATE ioctl, userspace can listen for incoming requests. An
464 * incoming request will generate an %FW_CDEV_EVENT_REQUEST, and userspace must
465 * send a reply using this ioctl. The event has a handle to the kernel-side
466 * pending transaction, which should be used with this ioctl.
467 */
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500468struct fw_cdev_send_response {
469 __u32 rcode;
470 __u32 length;
471 __u64 data;
Kristian Høgsberg3964a442007-03-27 01:43:41 -0400472 __u32 handle;
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500473};
474
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200475/**
476 * struct fw_cdev_allocate - Allocate a CSR address range
477 * @offset: Start offset of the address range
478 * @closure: To be passed back to userspace in request events
479 * @length: Length of the address range, in bytes
480 * @handle: Handle to the allocation, written by the kernel
481 *
482 * Allocate an address range in the 48-bit address space on the local node
483 * (the controller). This allows userspace to listen for requests with an
484 * offset within that address range. When the kernel receives a request
485 * within the range, an &fw_cdev_event_request event will be written back.
486 * The @closure field is passed back to userspace in the response event.
487 * The @handle field is an out parameter, returning a handle to the allocated
488 * range to be used for later deallocation of the range.
Clemens Ladischdb5d2472009-12-24 12:05:58 +0100489 *
490 * The address range is allocated on all local nodes. The address allocation
Stefan Richterd505e6e2010-07-17 21:36:02 +0200491 * is exclusive except for the FCP command and response registers. If an
492 * exclusive address region is already in use, the ioctl fails with errno set
493 * to %EBUSY.
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200494 */
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500495struct fw_cdev_allocate {
496 __u64 offset;
497 __u64 closure;
498 __u32 length;
Kristian Høgsberg3964a442007-03-27 01:43:41 -0400499 __u32 handle;
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500500};
501
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200502/**
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100503 * struct fw_cdev_deallocate - Free a CSR address range or isochronous resource
504 * @handle: Handle to the address range or iso resource, as returned by the
505 * kernel when the range or resource was allocated
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200506 */
Kristian Høgsberg94723162007-03-14 17:34:55 -0400507struct fw_cdev_deallocate {
Kristian Høgsberg3964a442007-03-27 01:43:41 -0400508 __u32 handle;
Kristian Høgsberg94723162007-03-14 17:34:55 -0400509};
510
Kristian Høgsberg53718422007-03-07 12:12:42 -0500511#define FW_CDEV_LONG_RESET 0
512#define FW_CDEV_SHORT_RESET 1
513
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200514/**
515 * struct fw_cdev_initiate_bus_reset - Initiate a bus reset
516 * @type: %FW_CDEV_SHORT_RESET or %FW_CDEV_LONG_RESET
517 *
518 * Initiate a bus reset for the bus this device is on. The bus reset can be
519 * either the original (long) bus reset or the arbitrated (short) bus reset
520 * introduced in 1394a-2000.
Stefan Richterd505e6e2010-07-17 21:36:02 +0200521 *
522 * The ioctl returns immediately. A subsequent &fw_cdev_event_bus_reset
523 * indicates when the reset actually happened. Since ABI v4, this may be
524 * considerably later than the ioctl because the kernel ensures a grace period
525 * between subsequent bus resets as per IEEE 1394 bus management specification.
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200526 */
Kristian Høgsberg53718422007-03-07 12:12:42 -0500527struct fw_cdev_initiate_bus_reset {
Stefan Richterd505e6e2010-07-17 21:36:02 +0200528 __u32 type;
Kristian Høgsberg53718422007-03-07 12:12:42 -0500529};
530
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200531/**
532 * struct fw_cdev_add_descriptor - Add contents to the local node's config ROM
533 * @immediate: If non-zero, immediate key to insert before pointer
534 * @key: Upper 8 bits of root directory pointer
535 * @data: Userspace pointer to contents of descriptor block
Stefan Richter6d3faf62010-01-24 14:48:00 +0100536 * @length: Length of descriptor block data, in quadlets
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200537 * @handle: Handle to the descriptor, written by the kernel
538 *
539 * Add a descriptor block and optionally a preceding immediate key to the local
540 * node's configuration ROM.
541 *
542 * The @key field specifies the upper 8 bits of the descriptor root directory
543 * pointer and the @data and @length fields specify the contents. The @key
544 * should be of the form 0xXX000000. The offset part of the root directory entry
545 * will be filled in by the kernel.
546 *
547 * If not 0, the @immediate field specifies an immediate key which will be
548 * inserted before the root directory pointer.
549 *
Stefan Richter6d3faf62010-01-24 14:48:00 +0100550 * @immediate, @key, and @data array elements are CPU-endian quadlets.
551 *
Stefan Richterd505e6e2010-07-17 21:36:02 +0200552 * If successful, the kernel adds the descriptor and writes back a @handle to
553 * the kernel-side object to be used for later removal of the descriptor block
554 * and immediate key. The kernel will also generate a bus reset to signal the
555 * change of the configuration ROM to other nodes.
Stefan Richterde487da2009-03-10 21:00:23 +0100556 *
557 * This ioctl affects the configuration ROMs of all local nodes.
558 * The ioctl only succeeds on device files which represent a local node.
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200559 */
Kristian Høgsberg66dea3e2007-03-28 21:26:42 +0200560struct fw_cdev_add_descriptor {
561 __u32 immediate;
562 __u32 key;
563 __u64 data;
564 __u32 length;
565 __u32 handle;
566};
567
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200568/**
569 * struct fw_cdev_remove_descriptor - Remove contents from the configuration ROM
570 * @handle: Handle to the descriptor, as returned by the kernel when the
571 * descriptor was added
572 *
573 * Remove a descriptor block and accompanying immediate key from the local
Stefan Richterd505e6e2010-07-17 21:36:02 +0200574 * nodes' configuration ROMs. The kernel will also generate a bus reset to
575 * signal the change of the configuration ROM to other nodes.
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200576 */
Kristian Høgsberg66dea3e2007-03-28 21:26:42 +0200577struct fw_cdev_remove_descriptor {
578 __u32 handle;
579};
580
Kristian Høgsberg295e3fe2007-02-16 17:34:40 -0500581#define FW_CDEV_ISO_CONTEXT_TRANSMIT 0
582#define FW_CDEV_ISO_CONTEXT_RECEIVE 1
583
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200584/**
585 * struct fw_cdev_create_iso_context - Create a context for isochronous IO
586 * @type: %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE
587 * @header_size: Header size to strip for receive contexts
588 * @channel: Channel to bind to
Clemens Ladischaa6fec32010-03-31 16:26:52 +0200589 * @speed: Speed for transmit contexts
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200590 * @closure: To be returned in &fw_cdev_event_iso_interrupt
591 * @handle: Handle to context, written back by kernel
592 *
593 * Prior to sending or receiving isochronous I/O, a context must be created.
594 * The context records information about the transmit or receive configuration
595 * and typically maps to an underlying hardware resource. A context is set up
596 * for either sending or receiving. It is bound to a specific isochronous
597 * channel.
598 *
599 * If a context was successfully created, the kernel writes back a handle to the
600 * context, which must be passed in for subsequent operations on that context.
Stefan Richter77258da2009-01-07 20:14:53 +0100601 *
Clemens Ladischaa6fec32010-03-31 16:26:52 +0200602 * For receive contexts, @header_size must be at least 4 and must be a multiple
603 * of 4.
604 *
Stefan Richter77258da2009-01-07 20:14:53 +0100605 * Note that the effect of a @header_size > 4 depends on
606 * &fw_cdev_get_info.version, as documented at &fw_cdev_event_iso_interrupt.
Stefan Richterd505e6e2010-07-17 21:36:02 +0200607 *
608 * No more than one iso context can be created per fd.
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200609 */
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500610struct fw_cdev_create_iso_context {
Kristian Høgsberg295e3fe2007-02-16 17:34:40 -0500611 __u32 type;
612 __u32 header_size;
Kristian Høgsberg21efb3c2007-02-16 17:34:50 -0500613 __u32 channel;
614 __u32 speed;
Kristian Høgsbergabaa5742007-04-30 15:03:14 -0400615 __u64 closure;
616 __u32 handle;
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500617};
618
Kristian Høgsberg1ca31ae2007-05-31 11:16:43 -0400619#define FW_CDEV_ISO_PAYLOAD_LENGTH(v) (v)
620#define FW_CDEV_ISO_INTERRUPT (1 << 16)
621#define FW_CDEV_ISO_SKIP (1 << 17)
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200622#define FW_CDEV_ISO_SYNC (1 << 17)
Kristian Høgsberg1ca31ae2007-05-31 11:16:43 -0400623#define FW_CDEV_ISO_TAG(v) ((v) << 18)
624#define FW_CDEV_ISO_SY(v) ((v) << 20)
625#define FW_CDEV_ISO_HEADER_LENGTH(v) ((v) << 24)
626
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200627/**
628 * struct fw_cdev_iso_packet - Isochronous packet
629 * @control: Contains the header length (8 uppermost bits), the sy field
630 * (4 bits), the tag field (2 bits), a sync flag (1 bit),
631 * a skip flag (1 bit), an interrupt flag (1 bit), and the
632 * payload length (16 lowermost bits)
633 * @header: Header and payload
634 *
635 * &struct fw_cdev_iso_packet is used to describe isochronous packet queues.
636 *
Clemens Ladischaa6fec32010-03-31 16:26:52 +0200637 * Use the FW_CDEV_ISO_ macros to fill in @control.
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200638 *
Clemens Ladischaa6fec32010-03-31 16:26:52 +0200639 * For transmit packets, the header length must be a multiple of 4 and specifies
640 * the numbers of bytes in @header that will be prepended to the packet's
641 * payload; these bytes are copied into the kernel and will not be accessed
642 * after the ioctl has returned. The sy and tag fields are copied to the iso
643 * packet header (these fields are specified by IEEE 1394a and IEC 61883-1).
644 * The skip flag specifies that no packet is to be sent in a frame; when using
645 * this, all other fields except the interrupt flag must be zero.
646 *
647 * For receive packets, the header length must be a multiple of the context's
648 * header size; if the header length is larger than the context's header size,
649 * multiple packets are queued for this entry. The sy and tag fields are
650 * ignored. If the sync flag is set, the context drops all packets until
651 * a packet with a matching sy field is received (the sync value to wait for is
652 * specified in the &fw_cdev_start_iso structure). The payload length defines
653 * how many payload bytes can be received for one packet (in addition to payload
654 * quadlets that have been defined as headers and are stripped and returned in
655 * the &fw_cdev_event_iso_interrupt structure). If more bytes are received, the
656 * additional bytes are dropped. If less bytes are received, the remaining
657 * bytes in this part of the payload buffer will not be written to, not even by
658 * the next packet, i.e., packets received in consecutive frames will not
659 * necessarily be consecutive in memory. If an entry has queued multiple
660 * packets, the payload length is divided equally among them.
661 *
662 * When a packet with the interrupt flag set has been completed, the
663 * &fw_cdev_event_iso_interrupt event will be sent. An entry that has queued
664 * multiple receive packets is completed when its last packet is completed.
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200665 */
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500666struct fw_cdev_iso_packet {
Kristian Høgsberg1ca31ae2007-05-31 11:16:43 -0400667 __u32 control;
Stefan Richter5e20c282007-01-21 20:44:09 +0100668 __u32 header[0];
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500669};
670
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200671/**
672 * struct fw_cdev_queue_iso - Queue isochronous packets for I/O
673 * @packets: Userspace pointer to packet data
674 * @data: Pointer into mmap()'ed payload buffer
675 * @size: Size of packet data in bytes
676 * @handle: Isochronous context handle
677 *
678 * Queue a number of isochronous packets for reception or transmission.
679 * This ioctl takes a pointer to an array of &fw_cdev_iso_packet structs,
680 * which describe how to transmit from or receive into a contiguous region
Clemens Ladischaa6fec32010-03-31 16:26:52 +0200681 * of a mmap()'ed payload buffer. As part of transmit packet descriptors,
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200682 * a series of headers can be supplied, which will be prepended to the
683 * payload during DMA.
684 *
685 * The kernel may or may not queue all packets, but will write back updated
686 * values of the @packets, @data and @size fields, so the ioctl can be
687 * resubmitted easily.
688 */
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500689struct fw_cdev_queue_iso {
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500690 __u64 packets;
691 __u64 data;
Kristian Høgsbergda8ecff2007-03-27 01:43:39 -0400692 __u32 size;
Kristian Høgsbergabaa5742007-04-30 15:03:14 -0400693 __u32 handle;
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500694};
695
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200696#define FW_CDEV_ISO_CONTEXT_MATCH_TAG0 1
697#define FW_CDEV_ISO_CONTEXT_MATCH_TAG1 2
698#define FW_CDEV_ISO_CONTEXT_MATCH_TAG2 4
699#define FW_CDEV_ISO_CONTEXT_MATCH_TAG3 8
700#define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS 15
701
702/**
703 * struct fw_cdev_start_iso - Start an isochronous transmission or reception
704 * @cycle: Cycle in which to start I/O. If @cycle is greater than or
705 * equal to 0, the I/O will start on that cycle.
706 * @sync: Determines the value to wait for for receive packets that have
707 * the %FW_CDEV_ISO_SYNC bit set
708 * @tags: Tag filter bit mask. Only valid for isochronous reception.
709 * Determines the tag values for which packets will be accepted.
710 * Use FW_CDEV_ISO_CONTEXT_MATCH_ macros to set @tags.
711 * @handle: Isochronous context handle within which to transmit or receive
712 */
Kristian Høgsberg69cdb722007-02-16 17:34:41 -0500713struct fw_cdev_start_iso {
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500714 __s32 cycle;
Kristian Høgsbergeb0306e2007-03-14 17:34:54 -0400715 __u32 sync;
716 __u32 tags;
Kristian Høgsbergabaa5742007-04-30 15:03:14 -0400717 __u32 handle;
718};
719
Kristian Høgsberg7ada60e2007-06-22 00:20:34 +0200720/**
721 * struct fw_cdev_stop_iso - Stop an isochronous transmission or reception
722 * @handle: Handle of isochronous context to stop
723 */
Kristian Høgsbergabaa5742007-04-30 15:03:14 -0400724struct fw_cdev_stop_iso {
725 __u32 handle;
Kristian Høgsberg19a15b92006-12-19 19:58:31 -0500726};
727
Stefan Richtera64408b2007-09-29 10:41:58 +0200728/**
729 * struct fw_cdev_get_cycle_timer - read cycle timer register
730 * @local_time: system time, in microseconds since the Epoch
Stefan Richterabfe5a02010-02-20 12:13:49 +0100731 * @cycle_timer: Cycle Time register contents
Stefan Richtera64408b2007-09-29 10:41:58 +0200732 *
733 * The %FW_CDEV_IOC_GET_CYCLE_TIMER ioctl reads the isochronous cycle timer
Stefan Richterabfe5a02010-02-20 12:13:49 +0100734 * and also the system clock (%CLOCK_REALTIME). This allows to express the
735 * receive time of an isochronous packet as a system time.
Stefan Richter77258da2009-01-07 20:14:53 +0100736 *
737 * @cycle_timer consists of 7 bits cycleSeconds, 13 bits cycleCount, and
Stefan Richterabfe5a02010-02-20 12:13:49 +0100738 * 12 bits cycleOffset, in host byte order. Cf. the Cycle Time register
739 * per IEEE 1394 or Isochronous Cycle Timer register per OHCI-1394.
Stefan Richtere94b6d72010-02-21 12:48:57 +0100740 *
741 * In version 1 and 2 of the ABI, this ioctl returned unreliable (non-
742 * monotonic) @cycle_timer values on certain controllers.
Stefan Richtera64408b2007-09-29 10:41:58 +0200743 */
744struct fw_cdev_get_cycle_timer {
745 __u64 local_time;
746 __u32 cycle_timer;
747};
748
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100749/**
Stefan Richterabfe5a02010-02-20 12:13:49 +0100750 * struct fw_cdev_get_cycle_timer2 - read cycle timer register
751 * @tv_sec: system time, seconds
752 * @tv_nsec: system time, sub-seconds part in nanoseconds
753 * @clk_id: input parameter, clock from which to get the system time
754 * @cycle_timer: Cycle Time register contents
755 *
756 * The %FW_CDEV_IOC_GET_CYCLE_TIMER2 works like
757 * %FW_CDEV_IOC_GET_CYCLE_TIMER but lets you choose a clock like with POSIX'
758 * clock_gettime function. Supported @clk_id values are POSIX' %CLOCK_REALTIME
759 * and %CLOCK_MONOTONIC and Linux' %CLOCK_MONOTONIC_RAW.
760 */
761struct fw_cdev_get_cycle_timer2 {
762 __s64 tv_sec;
763 __s32 tv_nsec;
764 __s32 clk_id;
765 __u32 cycle_timer;
766};
767
768/**
Stefan Richter1ec3c022009-01-04 16:23:29 +0100769 * struct fw_cdev_allocate_iso_resource - (De)allocate a channel or bandwidth
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100770 * @closure: Passed back to userspace in correponding iso resource events
Stefan Richter1ec3c022009-01-04 16:23:29 +0100771 * @channels: Isochronous channels of which one is to be (de)allocated
772 * @bandwidth: Isochronous bandwidth units to be (de)allocated
773 * @handle: Handle to the allocation, written by the kernel (only valid in
774 * case of %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE ioctls)
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100775 *
776 * The %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE ioctl initiates allocation of an
777 * isochronous channel and/or of isochronous bandwidth at the isochronous
778 * resource manager (IRM). Only one of the channels specified in @channels is
779 * allocated. An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED is sent after
780 * communication with the IRM, indicating success or failure in the event data.
781 * The kernel will automatically reallocate the resources after bus resets.
782 * Should a reallocation fail, an %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event
783 * will be sent. The kernel will also automatically deallocate the resources
784 * when the file descriptor is closed.
785 *
Stefan Richter1ec3c022009-01-04 16:23:29 +0100786 * The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE ioctl can be used to initiate
787 * deallocation of resources which were allocated as described above.
788 * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation.
789 *
790 * The %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE ioctl is a variant of allocation
791 * without automatic re- or deallocation.
792 * An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event concludes this operation,
793 * indicating success or failure in its data.
794 *
795 * The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE ioctl works like
796 * %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE except that resources are freed
Stefan Richter5d9cb7d272009-01-08 23:07:40 +0100797 * instead of allocated.
Stefan Richter1ec3c022009-01-04 16:23:29 +0100798 * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation.
799 *
Stefan Richterca658b12010-04-10 12:23:09 +0200800 * To summarize, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE allocates iso resources
801 * for the lifetime of the fd or @handle.
Stefan Richter1ec3c022009-01-04 16:23:29 +0100802 * In contrast, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE allocates iso resources
803 * for the duration of a bus generation.
804 *
Stefan Richter5d9cb7d272009-01-08 23:07:40 +0100805 * @channels is a host-endian bitfield with the least significant bit
806 * representing channel 0 and the most significant bit representing channel 63:
807 * 1ULL << c for each channel c that is a candidate for (de)allocation.
Jay Fenlason, Stefan Richterb1bda4c2009-01-04 16:23:29 +0100808 *
809 * @bandwidth is expressed in bandwidth allocation units, i.e. the time to send
810 * one quadlet of data (payload or header data) at speed S1600.
811 */
812struct fw_cdev_allocate_iso_resource {
813 __u64 closure;
814 __u64 channels;
815 __u32 bandwidth;
816 __u32 handle;
817};
818
Stefan Richter33580a32009-01-04 16:23:29 +0100819/**
Jay Fenlasonf8c22872009-03-05 19:08:40 +0100820 * struct fw_cdev_send_stream_packet - send an asynchronous stream packet
Stefan Richter18e9b102009-03-10 21:02:21 +0100821 * @length: Length of outgoing payload, in bytes
822 * @tag: Data format tag
823 * @channel: Isochronous channel to transmit to
824 * @sy: Synchronization code
825 * @closure: Passed back to userspace in the response event
826 * @data: Userspace pointer to payload
827 * @generation: The bus generation where packet is valid
828 * @speed: Speed to transmit at
Jay Fenlasonf8c22872009-03-05 19:08:40 +0100829 *
830 * The %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl sends an asynchronous stream packet
Stefan Richter18e9b102009-03-10 21:02:21 +0100831 * to every device which is listening to the specified channel. The kernel
832 * writes an &fw_cdev_event_response event which indicates success or failure of
833 * the transmission.
Jay Fenlasonf8c22872009-03-05 19:08:40 +0100834 */
835struct fw_cdev_send_stream_packet {
Stefan Richter18e9b102009-03-10 21:02:21 +0100836 __u32 length;
837 __u32 tag;
Jay Fenlasonf8c22872009-03-05 19:08:40 +0100838 __u32 channel;
839 __u32 sy;
Stefan Richter18e9b102009-03-10 21:02:21 +0100840 __u64 closure;
Jay Fenlasonf8c22872009-03-05 19:08:40 +0100841 __u64 data;
Stefan Richter18e9b102009-03-10 21:02:21 +0100842 __u32 generation;
843 __u32 speed;
Jay Fenlasonf8c22872009-03-05 19:08:40 +0100844};
845
Stefan Richter850bb6f2010-07-16 22:25:14 +0200846/**
847 * struct fw_cdev_send_phy_packet - send a PHY packet
848 * @closure: Passed back to userspace in the PHY-packet-sent event
849 * @data: First and second quadlet of the PHY packet
850 * @generation: The bus generation where packet is valid
851 *
852 * The %FW_CDEV_IOC_SEND_PHY_PACKET ioctl sends a PHY packet to all nodes
853 * on the same card as this device. After transmission, an
854 * %FW_CDEV_EVENT_PHY_PACKET_SENT event is generated.
855 *
856 * The payload @data[] shall be specified in host byte order. Usually,
857 * @data[1] needs to be the bitwise inverse of @data[0]. VersaPHY packets
858 * are an exception to this rule.
859 *
860 * The ioctl is only permitted on device files which represent a local node.
861 */
862struct fw_cdev_send_phy_packet {
863 __u64 closure;
864 __u32 data[2];
865 __u32 generation;
866};
867
Stefan Richterbf54e142010-07-16 22:25:51 +0200868/**
869 * struct fw_cdev_receive_phy_packets - start reception of PHY packets
870 * @closure: Passed back to userspace in phy packet events
871 *
872 * This ioctl activates issuing of %FW_CDEV_EVENT_PHY_PACKET_RECEIVED due to
873 * incoming PHY packets from any node on the same bus as the device.
874 *
875 * The ioctl is only permitted on device files which represent a local node.
876 */
877struct fw_cdev_receive_phy_packets {
878 __u64 closure;
879};
880
Kristian Høgsberg4c5a4432007-05-07 20:33:37 -0400881#endif /* _LINUX_FIREWIRE_CDEV_H */