Kristian Høgsberg | 4c5a443 | 2007-05-07 20:33:37 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Char device interface. |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 3 | * |
| 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øgsberg | 4c5a443 | 2007-05-07 20:33:37 -0400 | [diff] [blame] | 21 | #ifndef _LINUX_FIREWIRE_CDEV_H |
| 22 | #define _LINUX_FIREWIRE_CDEV_H |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 23 | |
Kristian Høgsberg | 04dfb8d | 2007-05-07 20:33:36 -0400 | [diff] [blame] | 24 | #include <linux/ioctl.h> |
| 25 | #include <linux/types.h> |
Kristian Høgsberg | 4c5a443 | 2007-05-07 20:33:37 -0400 | [diff] [blame] | 26 | #include <linux/firewire-constants.h> |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 27 | |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 28 | #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øgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 34 | |
Stefan Richter | e205597 | 2010-06-20 22:53:55 +0200 | [diff] [blame] | 35 | /* available since kernel version 2.6.36 */ |
| 36 | #define FW_CDEV_EVENT_REQUEST2 0x06 |
| 37 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 38 | /** |
| 39 | * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types |
| 40 | * @closure: For arbitrary use by userspace |
| 41 | * @type: Discriminates the fw_cdev_event_ types |
| 42 | * |
| 43 | * This struct may be used to access generic members of all fw_cdev_event_ |
| 44 | * types regardless of the specific type. |
| 45 | * |
| 46 | * Data passed in the @closure field for a request will be returned in the |
| 47 | * corresponding event. It is big enough to hold a pointer on all platforms. |
| 48 | * The ioctl used to set @closure depends on the @type of event. |
| 49 | */ |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 50 | struct fw_cdev_event_common { |
| 51 | __u64 closure; |
| 52 | __u32 type; |
| 53 | }; |
| 54 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 55 | /** |
| 56 | * struct fw_cdev_event_bus_reset - Sent when a bus reset occurred |
| 57 | * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_GET_INFO ioctl |
| 58 | * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_BUS_RESET |
| 59 | * @node_id: New node ID of this node |
| 60 | * @local_node_id: Node ID of the local node, i.e. of the controller |
| 61 | * @bm_node_id: Node ID of the bus manager |
| 62 | * @irm_node_id: Node ID of the iso resource manager |
| 63 | * @root_node_id: Node ID of the root node |
| 64 | * @generation: New bus generation |
| 65 | * |
| 66 | * This event is sent when the bus the device belongs to goes through a bus |
| 67 | * reset. It provides information about the new bus configuration, such as |
| 68 | * new node ID for this device, new root ID, and others. |
Stefan Richter | 250b2b6 | 2010-06-21 23:24:35 +0200 | [diff] [blame] | 69 | * |
| 70 | * If @bm_node_id is 0xffff right after bus reset it can be reread by an |
| 71 | * %FW_CDEV_IOC_GET_INFO ioctl after bus manager selection was finished. |
| 72 | * Kernels with ABI version < 4 do not set @bm_node_id. |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 73 | */ |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 74 | struct fw_cdev_event_bus_reset { |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 75 | __u64 closure; |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 76 | __u32 type; |
| 77 | __u32 node_id; |
| 78 | __u32 local_node_id; |
| 79 | __u32 bm_node_id; |
| 80 | __u32 irm_node_id; |
| 81 | __u32 root_node_id; |
| 82 | __u32 generation; |
| 83 | }; |
| 84 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 85 | /** |
| 86 | * struct fw_cdev_event_response - Sent when a response packet was received |
Stefan Richter | d505e6e | 2010-07-17 21:36:02 +0200 | [diff] [blame^] | 87 | * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_REQUEST |
| 88 | * or %FW_CDEV_IOC_SEND_BROADCAST_REQUEST |
| 89 | * or %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 90 | * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_RESPONSE |
| 91 | * @rcode: Response code returned by the remote node |
| 92 | * @length: Data length, i.e. the response's payload size in bytes |
| 93 | * @data: Payload data, if any |
| 94 | * |
| 95 | * This event is sent when the stack receives a response to an outgoing request |
| 96 | * sent by %FW_CDEV_IOC_SEND_REQUEST ioctl. The payload data for responses |
| 97 | * carrying data (read and lock responses) follows immediately and can be |
| 98 | * accessed through the @data field. |
Stefan Richter | d505e6e | 2010-07-17 21:36:02 +0200 | [diff] [blame^] | 99 | * |
| 100 | * The event is also generated after conclusions of transactions that do not |
| 101 | * involve response packets. This includes unified write transactions, |
| 102 | * broadcast write transactions, and transmission of asynchronous stream |
| 103 | * packets. @rcode indicates success or failure of such transmissions. |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 104 | */ |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 105 | struct fw_cdev_event_response { |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 106 | __u64 closure; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 107 | __u32 type; |
| 108 | __u32 rcode; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 109 | __u32 length; |
| 110 | __u32 data[0]; |
| 111 | }; |
| 112 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 113 | /** |
Stefan Richter | e205597 | 2010-06-20 22:53:55 +0200 | [diff] [blame] | 114 | * struct fw_cdev_event_request - Old version of &fw_cdev_event_request2 |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 115 | * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl |
| 116 | * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST |
Stefan Richter | e205597 | 2010-06-20 22:53:55 +0200 | [diff] [blame] | 117 | * @tcode: See &fw_cdev_event_request2 |
| 118 | * @offset: See &fw_cdev_event_request2 |
| 119 | * @handle: See &fw_cdev_event_request2 |
| 120 | * @length: See &fw_cdev_event_request2 |
| 121 | * @data: See &fw_cdev_event_request2 |
| 122 | * |
| 123 | * This event is sent instead of &fw_cdev_event_request2 if the kernel or |
| 124 | * the client implements ABI version <= 3. |
| 125 | * |
| 126 | * Unlike &fw_cdev_event_request2, the sender identity cannot be established, |
| 127 | * broadcast write requests cannot be distinguished from unicast writes, and |
| 128 | * @tcode of lock requests is %TCODE_LOCK_REQUEST. |
| 129 | * |
| 130 | * Requests to the FCP_REQUEST or FCP_RESPONSE register are responded to as |
| 131 | * with &fw_cdev_event_request2, except in kernel 2.6.32 and older which send |
| 132 | * the response packet of the client's %FW_CDEV_IOC_SEND_RESPONSE ioctl. |
| 133 | */ |
| 134 | struct fw_cdev_event_request { |
| 135 | __u64 closure; |
| 136 | __u32 type; |
| 137 | __u32 tcode; |
| 138 | __u64 offset; |
| 139 | __u32 handle; |
| 140 | __u32 length; |
| 141 | __u32 data[0]; |
| 142 | }; |
| 143 | |
| 144 | /** |
| 145 | * struct fw_cdev_event_request2 - Sent on incoming request to an address region |
| 146 | * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl |
| 147 | * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST2 |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 148 | * @tcode: Transaction code of the incoming request |
| 149 | * @offset: The offset into the 48-bit per-node address space |
Stefan Richter | e205597 | 2010-06-20 22:53:55 +0200 | [diff] [blame] | 150 | * @source_node_id: Sender node ID |
| 151 | * @destination_node_id: Destination node ID |
| 152 | * @card: The index of the card from which the request came |
| 153 | * @generation: Bus generation in which the request is valid |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 154 | * @handle: Reference to the kernel-side pending request |
| 155 | * @length: Data length, i.e. the request's payload size in bytes |
| 156 | * @data: Incoming data, if any |
| 157 | * |
| 158 | * This event is sent when the stack receives an incoming request to an address |
| 159 | * region registered using the %FW_CDEV_IOC_ALLOCATE ioctl. The request is |
| 160 | * guaranteed to be completely contained in the specified region. Userspace is |
| 161 | * responsible for sending the response by %FW_CDEV_IOC_SEND_RESPONSE ioctl, |
| 162 | * using the same @handle. |
| 163 | * |
| 164 | * The payload data for requests carrying data (write and lock requests) |
| 165 | * follows immediately and can be accessed through the @data field. |
Stefan Richter | e205597 | 2010-06-20 22:53:55 +0200 | [diff] [blame] | 166 | * |
| 167 | * Unlike &fw_cdev_event_request, @tcode of lock requests is one of the |
| 168 | * firewire-core specific %TCODE_LOCK_MASK_SWAP...%TCODE_LOCK_VENDOR_DEPENDENT, |
| 169 | * i.e. encodes the extended transaction code. |
| 170 | * |
| 171 | * @card may differ from &fw_cdev_get_info.card because requests are received |
| 172 | * from all cards of the Linux host. @source_node_id, @destination_node_id, and |
| 173 | * @generation pertain to that card. Destination node ID and bus generation may |
| 174 | * therefore differ from the corresponding fields of the last |
| 175 | * &fw_cdev_event_bus_reset. |
| 176 | * |
| 177 | * @destination_node_id may also differ from the current node ID because of a |
| 178 | * non-local bus ID part or in case of a broadcast write request. Note, a |
| 179 | * client must call an %FW_CDEV_IOC_SEND_RESPONSE ioctl even in case of a |
| 180 | * broadcast write request; the kernel will then release the kernel-side pending |
| 181 | * request but will not actually send a response packet. |
| 182 | * |
| 183 | * In case of a write request to FCP_REQUEST or FCP_RESPONSE, the kernel already |
| 184 | * sent a write response immediately after the request was received; in this |
| 185 | * case the client must still call an %FW_CDEV_IOC_SEND_RESPONSE ioctl to |
| 186 | * release the kernel-side pending request, though another response won't be |
| 187 | * sent. |
| 188 | * |
| 189 | * If the client subsequently needs to initiate requests to the sender node of |
| 190 | * an &fw_cdev_event_request2, it needs to use a device file with matching |
| 191 | * card index, node ID, and generation for outbound requests. |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 192 | */ |
Stefan Richter | e205597 | 2010-06-20 22:53:55 +0200 | [diff] [blame] | 193 | struct fw_cdev_event_request2 { |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 194 | __u64 closure; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 195 | __u32 type; |
| 196 | __u32 tcode; |
| 197 | __u64 offset; |
Stefan Richter | e205597 | 2010-06-20 22:53:55 +0200 | [diff] [blame] | 198 | __u32 source_node_id; |
| 199 | __u32 destination_node_id; |
| 200 | __u32 card; |
| 201 | __u32 generation; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 202 | __u32 handle; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 203 | __u32 length; |
| 204 | __u32 data[0]; |
| 205 | }; |
| 206 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 207 | /** |
| 208 | * struct fw_cdev_event_iso_interrupt - Sent when an iso packet was completed |
| 209 | * @closure: See &fw_cdev_event_common; |
| 210 | * set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl |
| 211 | * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_ISO_INTERRUPT |
| 212 | * @cycle: Cycle counter of the interrupt packet |
| 213 | * @header_length: Total length of following headers, in bytes |
| 214 | * @header: Stripped headers, if any |
| 215 | * |
| 216 | * This event is sent when the controller has completed an &fw_cdev_iso_packet |
Stefan Richter | 3b2b65d | 2010-06-20 22:54:22 +0200 | [diff] [blame] | 217 | * with the %FW_CDEV_ISO_INTERRUPT bit set. |
| 218 | * |
| 219 | * Isochronous transmit events: |
| 220 | * |
| 221 | * In version 1 of the ABI, &header_length is 0. In version 3 and some |
| 222 | * implementations of version 2 of the ABI, &header_length is a multiple of 4 |
| 223 | * and &header contains timestamps of all packets up until the interrupt packet. |
| 224 | * The format of the timestamps is as described below for isochronous reception. |
| 225 | * |
| 226 | * Isochronous receive events: |
| 227 | * |
| 228 | * The headers stripped of all packets up until and including the interrupt |
| 229 | * packet are returned in the @header field. The amount of header data per |
| 230 | * packet is as specified at iso context creation by |
| 231 | * &fw_cdev_create_iso_context.header_size. |
Stefan Richter | 77258da | 2009-01-07 20:14:53 +0100 | [diff] [blame] | 232 | * |
| 233 | * In version 1 of this ABI, header data consisted of the 1394 isochronous |
| 234 | * packet header, followed by quadlets from the packet payload if |
| 235 | * &fw_cdev_create_iso_context.header_size > 4. |
| 236 | * |
| 237 | * In version 2 of this ABI, header data consist of the 1394 isochronous |
| 238 | * packet header, followed by a timestamp quadlet if |
| 239 | * &fw_cdev_create_iso_context.header_size > 4, followed by quadlets from the |
| 240 | * packet payload if &fw_cdev_create_iso_context.header_size > 8. |
| 241 | * |
| 242 | * Behaviour of ver. 1 of this ABI is no longer available since ABI ver. 2. |
| 243 | * |
| 244 | * Format of 1394 iso packet header: 16 bits len, 2 bits tag, 6 bits channel, |
| 245 | * 4 bits tcode, 4 bits sy, in big endian byte order. Format of timestamp: |
| 246 | * 16 bits invalid, 3 bits cycleSeconds, 13 bits cycleCount, in big endian byte |
| 247 | * order. |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 248 | */ |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 249 | struct fw_cdev_event_iso_interrupt { |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 250 | __u64 closure; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 251 | __u32 type; |
| 252 | __u32 cycle; |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 253 | __u32 header_length; |
Kristian Høgsberg | 9b32d5f | 2007-02-16 17:34:44 -0500 | [diff] [blame] | 254 | __u32 header[0]; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 255 | }; |
| 256 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 257 | /** |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 258 | * struct fw_cdev_event_iso_resource - Iso resources were allocated or freed |
| 259 | * @closure: See &fw_cdev_event_common; |
Stefan Richter | 1ec3c02 | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 260 | * set by %FW_CDEV_IOC_(DE)ALLOCATE_ISO_RESOURCE(_ONCE) ioctl |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 261 | * @type: %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or |
| 262 | * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED |
| 263 | * @handle: Reference by which an allocated resource can be deallocated |
| 264 | * @channel: Isochronous channel which was (de)allocated, if any |
| 265 | * @bandwidth: Bandwidth allocation units which were (de)allocated, if any |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 266 | * |
| 267 | * An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event is sent after an isochronous |
| 268 | * resource was allocated at the IRM. The client has to check @channel and |
| 269 | * @bandwidth for whether the allocation actually succeeded. |
| 270 | * |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 271 | * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event is sent after an isochronous |
| 272 | * resource was deallocated at the IRM. It is also sent when automatic |
| 273 | * reallocation after a bus reset failed. |
Stefan Richter | 1ec3c02 | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 274 | * |
| 275 | * @channel is <0 if no channel was (de)allocated or if reallocation failed. |
| 276 | * @bandwidth is 0 if no bandwidth was (de)allocated or if reallocation failed. |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 277 | */ |
| 278 | struct fw_cdev_event_iso_resource { |
| 279 | __u64 closure; |
| 280 | __u32 type; |
| 281 | __u32 handle; |
| 282 | __s32 channel; |
| 283 | __s32 bandwidth; |
| 284 | }; |
| 285 | |
| 286 | /** |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 287 | * union fw_cdev_event - Convenience union of fw_cdev_event_ types |
| 288 | * @common: Valid for all types |
| 289 | * @bus_reset: Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET |
| 290 | * @response: Valid if @common.type == %FW_CDEV_EVENT_RESPONSE |
| 291 | * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST |
Stefan Richter | e205597 | 2010-06-20 22:53:55 +0200 | [diff] [blame] | 292 | * @request2: Valid if @common.type == %FW_CDEV_EVENT_REQUEST2 |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 293 | * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 294 | * @iso_resource: Valid if @common.type == |
| 295 | * %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or |
| 296 | * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 297 | * |
Jay Fenlason | be585c0 | 2008-10-01 18:13:20 -0400 | [diff] [blame] | 298 | * Convenience union for userspace use. Events could be read(2) into an |
| 299 | * appropriately aligned char buffer and then cast to this union for further |
| 300 | * processing. Note that for a request, response or iso_interrupt event, |
| 301 | * the data[] or header[] may make the size of the full event larger than |
| 302 | * sizeof(union fw_cdev_event). Also note that if you attempt to read(2) |
| 303 | * an event into a buffer that is not large enough for it, the data that does |
| 304 | * not fit will be discarded so that the next read(2) will return a new event. |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 305 | */ |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 306 | union fw_cdev_event { |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 307 | struct fw_cdev_event_common common; |
| 308 | struct fw_cdev_event_bus_reset bus_reset; |
| 309 | struct fw_cdev_event_response response; |
| 310 | struct fw_cdev_event_request request; |
Stefan Richter | e205597 | 2010-06-20 22:53:55 +0200 | [diff] [blame] | 311 | struct fw_cdev_event_request2 request2; /* added in 2.6.36 */ |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 312 | struct fw_cdev_event_iso_interrupt iso_interrupt; |
Stefan Richter | 604f451 | 2010-06-20 22:52:55 +0200 | [diff] [blame] | 313 | struct fw_cdev_event_iso_resource iso_resource; /* added in 2.6.30 */ |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 314 | }; |
| 315 | |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 316 | /* available since kernel version 2.6.22 */ |
Stefan Richter | c8a2590 | 2009-03-10 20:59:16 +0100 | [diff] [blame] | 317 | #define FW_CDEV_IOC_GET_INFO _IOWR('#', 0x00, struct fw_cdev_get_info) |
| 318 | #define FW_CDEV_IOC_SEND_REQUEST _IOW('#', 0x01, struct fw_cdev_send_request) |
| 319 | #define FW_CDEV_IOC_ALLOCATE _IOWR('#', 0x02, struct fw_cdev_allocate) |
| 320 | #define FW_CDEV_IOC_DEALLOCATE _IOW('#', 0x03, struct fw_cdev_deallocate) |
| 321 | #define FW_CDEV_IOC_SEND_RESPONSE _IOW('#', 0x04, struct fw_cdev_send_response) |
| 322 | #define FW_CDEV_IOC_INITIATE_BUS_RESET _IOW('#', 0x05, struct fw_cdev_initiate_bus_reset) |
| 323 | #define FW_CDEV_IOC_ADD_DESCRIPTOR _IOWR('#', 0x06, struct fw_cdev_add_descriptor) |
| 324 | #define FW_CDEV_IOC_REMOVE_DESCRIPTOR _IOW('#', 0x07, struct fw_cdev_remove_descriptor) |
| 325 | #define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOWR('#', 0x08, struct fw_cdev_create_iso_context) |
| 326 | #define FW_CDEV_IOC_QUEUE_ISO _IOWR('#', 0x09, struct fw_cdev_queue_iso) |
| 327 | #define FW_CDEV_IOC_START_ISO _IOW('#', 0x0a, struct fw_cdev_start_iso) |
| 328 | #define FW_CDEV_IOC_STOP_ISO _IOW('#', 0x0b, struct fw_cdev_stop_iso) |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 329 | |
| 330 | /* available since kernel version 2.6.24 */ |
Stefan Richter | c8a2590 | 2009-03-10 20:59:16 +0100 | [diff] [blame] | 331 | #define FW_CDEV_IOC_GET_CYCLE_TIMER _IOR('#', 0x0c, struct fw_cdev_get_cycle_timer) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 332 | |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 333 | /* available since kernel version 2.6.30 */ |
Stefan Richter | 1ec3c02 | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 334 | #define FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE _IOWR('#', 0x0d, struct fw_cdev_allocate_iso_resource) |
| 335 | #define FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE _IOW('#', 0x0e, struct fw_cdev_deallocate) |
| 336 | #define FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE _IOW('#', 0x0f, struct fw_cdev_allocate_iso_resource) |
| 337 | #define FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE _IOW('#', 0x10, struct fw_cdev_allocate_iso_resource) |
Stefan Richter | c8a2590 | 2009-03-10 20:59:16 +0100 | [diff] [blame] | 338 | #define FW_CDEV_IOC_GET_SPEED _IO('#', 0x11) /* returns speed code */ |
Jay Fenlason, Stefan Richter | acfe833 | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 339 | #define FW_CDEV_IOC_SEND_BROADCAST_REQUEST _IOW('#', 0x12, struct fw_cdev_send_request) |
Jay Fenlason | f8c2287 | 2009-03-05 19:08:40 +0100 | [diff] [blame] | 340 | #define FW_CDEV_IOC_SEND_STREAM_PACKET _IOW('#', 0x13, struct fw_cdev_send_stream_packet) |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 341 | |
Stefan Richter | abfe5a0 | 2010-02-20 12:13:49 +0100 | [diff] [blame] | 342 | /* available since kernel version 2.6.34 */ |
| 343 | #define FW_CDEV_IOC_GET_CYCLE_TIMER2 _IOWR('#', 0x14, struct fw_cdev_get_cycle_timer2) |
| 344 | |
Stefan Richter | 77258da | 2009-01-07 20:14:53 +0100 | [diff] [blame] | 345 | /* |
Stefan Richter | 604f451 | 2010-06-20 22:52:55 +0200 | [diff] [blame] | 346 | * ABI version history |
Stefan Richter | 77258da | 2009-01-07 20:14:53 +0100 | [diff] [blame] | 347 | * 1 (2.6.22) - initial version |
Stefan Richter | 604f451 | 2010-06-20 22:52:55 +0200 | [diff] [blame] | 348 | * (2.6.24) - added %FW_CDEV_IOC_GET_CYCLE_TIMER |
Stefan Richter | 77258da | 2009-01-07 20:14:53 +0100 | [diff] [blame] | 349 | * 2 (2.6.30) - changed &fw_cdev_event_iso_interrupt.header if |
| 350 | * &fw_cdev_create_iso_context.header_size is 8 or more |
Stefan Richter | 604f451 | 2010-06-20 22:52:55 +0200 | [diff] [blame] | 351 | * - added %FW_CDEV_IOC_*_ISO_RESOURCE*, |
| 352 | * %FW_CDEV_IOC_GET_SPEED, %FW_CDEV_IOC_SEND_BROADCAST_REQUEST, |
| 353 | * %FW_CDEV_IOC_SEND_STREAM_PACKET |
Stefan Richter | e94b6d7 | 2010-02-21 12:48:57 +0100 | [diff] [blame] | 354 | * (2.6.32) - added time stamp to xmit &fw_cdev_event_iso_interrupt |
| 355 | * (2.6.33) - IR has always packet-per-buffer semantics now, not one of |
| 356 | * dual-buffer or packet-per-buffer depending on hardware |
Stefan Richter | e205597 | 2010-06-20 22:53:55 +0200 | [diff] [blame] | 357 | * - shared use and auto-response for FCP registers |
Stefan Richter | e94b6d7 | 2010-02-21 12:48:57 +0100 | [diff] [blame] | 358 | * 3 (2.6.34) - made &fw_cdev_get_cycle_timer reliable |
Stefan Richter | 604f451 | 2010-06-20 22:52:55 +0200 | [diff] [blame] | 359 | * - added %FW_CDEV_IOC_GET_CYCLE_TIMER2 |
Stefan Richter | e205597 | 2010-06-20 22:53:55 +0200 | [diff] [blame] | 360 | * 4 (2.6.36) - added %FW_CDEV_EVENT_REQUEST2 |
Stefan Richter | 250b2b6 | 2010-06-21 23:24:35 +0200 | [diff] [blame] | 361 | * - implemented &fw_cdev_event_bus_reset.bm_node_id |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 362 | */ |
Stefan Richter | 604f451 | 2010-06-20 22:52:55 +0200 | [diff] [blame] | 363 | #define FW_CDEV_VERSION 3 /* Meaningless; don't use this macro. */ |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 364 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 365 | /** |
| 366 | * struct fw_cdev_get_info - General purpose information ioctl |
Stefan Richter | 604f451 | 2010-06-20 22:52:55 +0200 | [diff] [blame] | 367 | * @version: The version field is just a running serial number. Both an |
| 368 | * input parameter (ABI version implemented by the client) and |
| 369 | * output parameter (ABI version implemented by the kernel). |
| 370 | * A client must not fill in an %FW_CDEV_VERSION defined from an |
| 371 | * included kernel header file but the actual version for which |
| 372 | * the client was implemented. This is necessary for forward |
| 373 | * compatibility. We never break backwards compatibility, but |
| 374 | * may add more structs, events, and ioctls in later revisions. |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 375 | * @rom_length: If @rom is non-zero, at most rom_length bytes of configuration |
| 376 | * ROM will be copied into that user space address. In either |
| 377 | * case, @rom_length is updated with the actual length of the |
| 378 | * configuration ROM. |
| 379 | * @rom: If non-zero, address of a buffer to be filled by a copy of the |
Stefan Richter | 632321e | 2009-01-02 12:47:13 +0100 | [diff] [blame] | 380 | * device's configuration ROM |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 381 | * @bus_reset: If non-zero, address of a buffer to be filled by a |
| 382 | * &struct fw_cdev_event_bus_reset with the current state |
| 383 | * of the bus. This does not cause a bus reset to happen. |
| 384 | * @bus_reset_closure: Value of &closure in this and subsequent bus reset events |
| 385 | * @card: The index of the card this device belongs to |
| 386 | */ |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 387 | struct fw_cdev_get_info { |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 388 | __u32 version; |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 389 | __u32 rom_length; |
| 390 | __u64 rom; |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 391 | __u64 bus_reset; |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 392 | __u64 bus_reset_closure; |
Kristian Høgsberg | e753350 | 2007-03-07 12:12:52 -0500 | [diff] [blame] | 393 | __u32 card; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 394 | }; |
| 395 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 396 | /** |
| 397 | * struct fw_cdev_send_request - Send an asynchronous request packet |
| 398 | * @tcode: Transaction code of the request |
| 399 | * @length: Length of outgoing payload, in bytes |
| 400 | * @offset: 48-bit offset at destination node |
| 401 | * @closure: Passed back to userspace in the response event |
| 402 | * @data: Userspace pointer to payload |
| 403 | * @generation: The bus generation where packet is valid |
| 404 | * |
| 405 | * Send a request to the device. This ioctl implements all outgoing requests. |
| 406 | * Both quadlet and block request specify the payload as a pointer to the data |
| 407 | * in the @data field. Once the transaction completes, the kernel writes an |
Stefan Richter | bf8e335 | 2008-12-05 22:43:41 +0100 | [diff] [blame] | 408 | * &fw_cdev_event_response event back. The @closure field is passed back to |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 409 | * user space in the response event. |
| 410 | */ |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 411 | struct fw_cdev_send_request { |
| 412 | __u32 tcode; |
| 413 | __u32 length; |
| 414 | __u64 offset; |
| 415 | __u64 closure; |
| 416 | __u64 data; |
Kristian Høgsberg | 97e3527 | 2007-03-07 12:12:53 -0500 | [diff] [blame] | 417 | __u32 generation; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 418 | }; |
| 419 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 420 | /** |
| 421 | * struct fw_cdev_send_response - Send an asynchronous response packet |
| 422 | * @rcode: Response code as determined by the userspace handler |
| 423 | * @length: Length of outgoing payload, in bytes |
| 424 | * @data: Userspace pointer to payload |
| 425 | * @handle: The handle from the &fw_cdev_event_request |
| 426 | * |
| 427 | * Send a response to an incoming request. By setting up an address range using |
| 428 | * the %FW_CDEV_IOC_ALLOCATE ioctl, userspace can listen for incoming requests. An |
| 429 | * incoming request will generate an %FW_CDEV_EVENT_REQUEST, and userspace must |
| 430 | * send a reply using this ioctl. The event has a handle to the kernel-side |
| 431 | * pending transaction, which should be used with this ioctl. |
| 432 | */ |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 433 | struct fw_cdev_send_response { |
| 434 | __u32 rcode; |
| 435 | __u32 length; |
| 436 | __u64 data; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 437 | __u32 handle; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 438 | }; |
| 439 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 440 | /** |
| 441 | * struct fw_cdev_allocate - Allocate a CSR address range |
| 442 | * @offset: Start offset of the address range |
| 443 | * @closure: To be passed back to userspace in request events |
| 444 | * @length: Length of the address range, in bytes |
| 445 | * @handle: Handle to the allocation, written by the kernel |
| 446 | * |
| 447 | * Allocate an address range in the 48-bit address space on the local node |
| 448 | * (the controller). This allows userspace to listen for requests with an |
| 449 | * offset within that address range. When the kernel receives a request |
| 450 | * within the range, an &fw_cdev_event_request event will be written back. |
| 451 | * The @closure field is passed back to userspace in the response event. |
| 452 | * The @handle field is an out parameter, returning a handle to the allocated |
| 453 | * range to be used for later deallocation of the range. |
Clemens Ladisch | db5d247 | 2009-12-24 12:05:58 +0100 | [diff] [blame] | 454 | * |
| 455 | * The address range is allocated on all local nodes. The address allocation |
Stefan Richter | d505e6e | 2010-07-17 21:36:02 +0200 | [diff] [blame^] | 456 | * is exclusive except for the FCP command and response registers. If an |
| 457 | * exclusive address region is already in use, the ioctl fails with errno set |
| 458 | * to %EBUSY. |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 459 | */ |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 460 | struct fw_cdev_allocate { |
| 461 | __u64 offset; |
| 462 | __u64 closure; |
| 463 | __u32 length; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 464 | __u32 handle; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 465 | }; |
| 466 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 467 | /** |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 468 | * struct fw_cdev_deallocate - Free a CSR address range or isochronous resource |
| 469 | * @handle: Handle to the address range or iso resource, as returned by the |
| 470 | * kernel when the range or resource was allocated |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 471 | */ |
Kristian Høgsberg | 9472316 | 2007-03-14 17:34:55 -0400 | [diff] [blame] | 472 | struct fw_cdev_deallocate { |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 473 | __u32 handle; |
Kristian Høgsberg | 9472316 | 2007-03-14 17:34:55 -0400 | [diff] [blame] | 474 | }; |
| 475 | |
Kristian Høgsberg | 5371842 | 2007-03-07 12:12:42 -0500 | [diff] [blame] | 476 | #define FW_CDEV_LONG_RESET 0 |
| 477 | #define FW_CDEV_SHORT_RESET 1 |
| 478 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 479 | /** |
| 480 | * struct fw_cdev_initiate_bus_reset - Initiate a bus reset |
| 481 | * @type: %FW_CDEV_SHORT_RESET or %FW_CDEV_LONG_RESET |
| 482 | * |
| 483 | * Initiate a bus reset for the bus this device is on. The bus reset can be |
| 484 | * either the original (long) bus reset or the arbitrated (short) bus reset |
| 485 | * introduced in 1394a-2000. |
Stefan Richter | d505e6e | 2010-07-17 21:36:02 +0200 | [diff] [blame^] | 486 | * |
| 487 | * The ioctl returns immediately. A subsequent &fw_cdev_event_bus_reset |
| 488 | * indicates when the reset actually happened. Since ABI v4, this may be |
| 489 | * considerably later than the ioctl because the kernel ensures a grace period |
| 490 | * between subsequent bus resets as per IEEE 1394 bus management specification. |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 491 | */ |
Kristian Høgsberg | 5371842 | 2007-03-07 12:12:42 -0500 | [diff] [blame] | 492 | struct fw_cdev_initiate_bus_reset { |
Stefan Richter | d505e6e | 2010-07-17 21:36:02 +0200 | [diff] [blame^] | 493 | __u32 type; |
Kristian Høgsberg | 5371842 | 2007-03-07 12:12:42 -0500 | [diff] [blame] | 494 | }; |
| 495 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 496 | /** |
| 497 | * struct fw_cdev_add_descriptor - Add contents to the local node's config ROM |
| 498 | * @immediate: If non-zero, immediate key to insert before pointer |
| 499 | * @key: Upper 8 bits of root directory pointer |
| 500 | * @data: Userspace pointer to contents of descriptor block |
Stefan Richter | 6d3faf6 | 2010-01-24 14:48:00 +0100 | [diff] [blame] | 501 | * @length: Length of descriptor block data, in quadlets |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 502 | * @handle: Handle to the descriptor, written by the kernel |
| 503 | * |
| 504 | * Add a descriptor block and optionally a preceding immediate key to the local |
| 505 | * node's configuration ROM. |
| 506 | * |
| 507 | * The @key field specifies the upper 8 bits of the descriptor root directory |
| 508 | * pointer and the @data and @length fields specify the contents. The @key |
| 509 | * should be of the form 0xXX000000. The offset part of the root directory entry |
| 510 | * will be filled in by the kernel. |
| 511 | * |
| 512 | * If not 0, the @immediate field specifies an immediate key which will be |
| 513 | * inserted before the root directory pointer. |
| 514 | * |
Stefan Richter | 6d3faf6 | 2010-01-24 14:48:00 +0100 | [diff] [blame] | 515 | * @immediate, @key, and @data array elements are CPU-endian quadlets. |
| 516 | * |
Stefan Richter | d505e6e | 2010-07-17 21:36:02 +0200 | [diff] [blame^] | 517 | * If successful, the kernel adds the descriptor and writes back a @handle to |
| 518 | * the kernel-side object to be used for later removal of the descriptor block |
| 519 | * and immediate key. The kernel will also generate a bus reset to signal the |
| 520 | * change of the configuration ROM to other nodes. |
Stefan Richter | de487da | 2009-03-10 21:00:23 +0100 | [diff] [blame] | 521 | * |
| 522 | * This ioctl affects the configuration ROMs of all local nodes. |
| 523 | * The ioctl only succeeds on device files which represent a local node. |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 524 | */ |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 525 | struct fw_cdev_add_descriptor { |
| 526 | __u32 immediate; |
| 527 | __u32 key; |
| 528 | __u64 data; |
| 529 | __u32 length; |
| 530 | __u32 handle; |
| 531 | }; |
| 532 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 533 | /** |
| 534 | * struct fw_cdev_remove_descriptor - Remove contents from the configuration ROM |
| 535 | * @handle: Handle to the descriptor, as returned by the kernel when the |
| 536 | * descriptor was added |
| 537 | * |
| 538 | * Remove a descriptor block and accompanying immediate key from the local |
Stefan Richter | d505e6e | 2010-07-17 21:36:02 +0200 | [diff] [blame^] | 539 | * nodes' configuration ROMs. The kernel will also generate a bus reset to |
| 540 | * signal the change of the configuration ROM to other nodes. |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 541 | */ |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 542 | struct fw_cdev_remove_descriptor { |
| 543 | __u32 handle; |
| 544 | }; |
| 545 | |
Kristian Høgsberg | 295e3fe | 2007-02-16 17:34:40 -0500 | [diff] [blame] | 546 | #define FW_CDEV_ISO_CONTEXT_TRANSMIT 0 |
| 547 | #define FW_CDEV_ISO_CONTEXT_RECEIVE 1 |
| 548 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 549 | /** |
| 550 | * struct fw_cdev_create_iso_context - Create a context for isochronous IO |
| 551 | * @type: %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE |
| 552 | * @header_size: Header size to strip for receive contexts |
| 553 | * @channel: Channel to bind to |
Clemens Ladisch | aa6fec3 | 2010-03-31 16:26:52 +0200 | [diff] [blame] | 554 | * @speed: Speed for transmit contexts |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 555 | * @closure: To be returned in &fw_cdev_event_iso_interrupt |
| 556 | * @handle: Handle to context, written back by kernel |
| 557 | * |
| 558 | * Prior to sending or receiving isochronous I/O, a context must be created. |
| 559 | * The context records information about the transmit or receive configuration |
| 560 | * and typically maps to an underlying hardware resource. A context is set up |
| 561 | * for either sending or receiving. It is bound to a specific isochronous |
| 562 | * channel. |
| 563 | * |
| 564 | * If a context was successfully created, the kernel writes back a handle to the |
| 565 | * context, which must be passed in for subsequent operations on that context. |
Stefan Richter | 77258da | 2009-01-07 20:14:53 +0100 | [diff] [blame] | 566 | * |
Clemens Ladisch | aa6fec3 | 2010-03-31 16:26:52 +0200 | [diff] [blame] | 567 | * For receive contexts, @header_size must be at least 4 and must be a multiple |
| 568 | * of 4. |
| 569 | * |
Stefan Richter | 77258da | 2009-01-07 20:14:53 +0100 | [diff] [blame] | 570 | * Note that the effect of a @header_size > 4 depends on |
| 571 | * &fw_cdev_get_info.version, as documented at &fw_cdev_event_iso_interrupt. |
Stefan Richter | d505e6e | 2010-07-17 21:36:02 +0200 | [diff] [blame^] | 572 | * |
| 573 | * No more than one iso context can be created per fd. |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 574 | */ |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 575 | struct fw_cdev_create_iso_context { |
Kristian Høgsberg | 295e3fe | 2007-02-16 17:34:40 -0500 | [diff] [blame] | 576 | __u32 type; |
| 577 | __u32 header_size; |
Kristian Høgsberg | 21efb3c | 2007-02-16 17:34:50 -0500 | [diff] [blame] | 578 | __u32 channel; |
| 579 | __u32 speed; |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 580 | __u64 closure; |
| 581 | __u32 handle; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 582 | }; |
| 583 | |
Kristian Høgsberg | 1ca31ae | 2007-05-31 11:16:43 -0400 | [diff] [blame] | 584 | #define FW_CDEV_ISO_PAYLOAD_LENGTH(v) (v) |
| 585 | #define FW_CDEV_ISO_INTERRUPT (1 << 16) |
| 586 | #define FW_CDEV_ISO_SKIP (1 << 17) |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 587 | #define FW_CDEV_ISO_SYNC (1 << 17) |
Kristian Høgsberg | 1ca31ae | 2007-05-31 11:16:43 -0400 | [diff] [blame] | 588 | #define FW_CDEV_ISO_TAG(v) ((v) << 18) |
| 589 | #define FW_CDEV_ISO_SY(v) ((v) << 20) |
| 590 | #define FW_CDEV_ISO_HEADER_LENGTH(v) ((v) << 24) |
| 591 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 592 | /** |
| 593 | * struct fw_cdev_iso_packet - Isochronous packet |
| 594 | * @control: Contains the header length (8 uppermost bits), the sy field |
| 595 | * (4 bits), the tag field (2 bits), a sync flag (1 bit), |
| 596 | * a skip flag (1 bit), an interrupt flag (1 bit), and the |
| 597 | * payload length (16 lowermost bits) |
| 598 | * @header: Header and payload |
| 599 | * |
| 600 | * &struct fw_cdev_iso_packet is used to describe isochronous packet queues. |
| 601 | * |
Clemens Ladisch | aa6fec3 | 2010-03-31 16:26:52 +0200 | [diff] [blame] | 602 | * Use the FW_CDEV_ISO_ macros to fill in @control. |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 603 | * |
Clemens Ladisch | aa6fec3 | 2010-03-31 16:26:52 +0200 | [diff] [blame] | 604 | * For transmit packets, the header length must be a multiple of 4 and specifies |
| 605 | * the numbers of bytes in @header that will be prepended to the packet's |
| 606 | * payload; these bytes are copied into the kernel and will not be accessed |
| 607 | * after the ioctl has returned. The sy and tag fields are copied to the iso |
| 608 | * packet header (these fields are specified by IEEE 1394a and IEC 61883-1). |
| 609 | * The skip flag specifies that no packet is to be sent in a frame; when using |
| 610 | * this, all other fields except the interrupt flag must be zero. |
| 611 | * |
| 612 | * For receive packets, the header length must be a multiple of the context's |
| 613 | * header size; if the header length is larger than the context's header size, |
| 614 | * multiple packets are queued for this entry. The sy and tag fields are |
| 615 | * ignored. If the sync flag is set, the context drops all packets until |
| 616 | * a packet with a matching sy field is received (the sync value to wait for is |
| 617 | * specified in the &fw_cdev_start_iso structure). The payload length defines |
| 618 | * how many payload bytes can be received for one packet (in addition to payload |
| 619 | * quadlets that have been defined as headers and are stripped and returned in |
| 620 | * the &fw_cdev_event_iso_interrupt structure). If more bytes are received, the |
| 621 | * additional bytes are dropped. If less bytes are received, the remaining |
| 622 | * bytes in this part of the payload buffer will not be written to, not even by |
| 623 | * the next packet, i.e., packets received in consecutive frames will not |
| 624 | * necessarily be consecutive in memory. If an entry has queued multiple |
| 625 | * packets, the payload length is divided equally among them. |
| 626 | * |
| 627 | * When a packet with the interrupt flag set has been completed, the |
| 628 | * &fw_cdev_event_iso_interrupt event will be sent. An entry that has queued |
| 629 | * multiple receive packets is completed when its last packet is completed. |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 630 | */ |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 631 | struct fw_cdev_iso_packet { |
Kristian Høgsberg | 1ca31ae | 2007-05-31 11:16:43 -0400 | [diff] [blame] | 632 | __u32 control; |
Stefan Richter | 5e20c28 | 2007-01-21 20:44:09 +0100 | [diff] [blame] | 633 | __u32 header[0]; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 634 | }; |
| 635 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 636 | /** |
| 637 | * struct fw_cdev_queue_iso - Queue isochronous packets for I/O |
| 638 | * @packets: Userspace pointer to packet data |
| 639 | * @data: Pointer into mmap()'ed payload buffer |
| 640 | * @size: Size of packet data in bytes |
| 641 | * @handle: Isochronous context handle |
| 642 | * |
| 643 | * Queue a number of isochronous packets for reception or transmission. |
| 644 | * This ioctl takes a pointer to an array of &fw_cdev_iso_packet structs, |
| 645 | * which describe how to transmit from or receive into a contiguous region |
Clemens Ladisch | aa6fec3 | 2010-03-31 16:26:52 +0200 | [diff] [blame] | 646 | * of a mmap()'ed payload buffer. As part of transmit packet descriptors, |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 647 | * a series of headers can be supplied, which will be prepended to the |
| 648 | * payload during DMA. |
| 649 | * |
| 650 | * The kernel may or may not queue all packets, but will write back updated |
| 651 | * values of the @packets, @data and @size fields, so the ioctl can be |
| 652 | * resubmitted easily. |
| 653 | */ |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 654 | struct fw_cdev_queue_iso { |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 655 | __u64 packets; |
| 656 | __u64 data; |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 657 | __u32 size; |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 658 | __u32 handle; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 659 | }; |
| 660 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 661 | #define FW_CDEV_ISO_CONTEXT_MATCH_TAG0 1 |
| 662 | #define FW_CDEV_ISO_CONTEXT_MATCH_TAG1 2 |
| 663 | #define FW_CDEV_ISO_CONTEXT_MATCH_TAG2 4 |
| 664 | #define FW_CDEV_ISO_CONTEXT_MATCH_TAG3 8 |
| 665 | #define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS 15 |
| 666 | |
| 667 | /** |
| 668 | * struct fw_cdev_start_iso - Start an isochronous transmission or reception |
| 669 | * @cycle: Cycle in which to start I/O. If @cycle is greater than or |
| 670 | * equal to 0, the I/O will start on that cycle. |
| 671 | * @sync: Determines the value to wait for for receive packets that have |
| 672 | * the %FW_CDEV_ISO_SYNC bit set |
| 673 | * @tags: Tag filter bit mask. Only valid for isochronous reception. |
| 674 | * Determines the tag values for which packets will be accepted. |
| 675 | * Use FW_CDEV_ISO_CONTEXT_MATCH_ macros to set @tags. |
| 676 | * @handle: Isochronous context handle within which to transmit or receive |
| 677 | */ |
Kristian Høgsberg | 69cdb72 | 2007-02-16 17:34:41 -0500 | [diff] [blame] | 678 | struct fw_cdev_start_iso { |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 679 | __s32 cycle; |
Kristian Høgsberg | eb0306e | 2007-03-14 17:34:54 -0400 | [diff] [blame] | 680 | __u32 sync; |
| 681 | __u32 tags; |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 682 | __u32 handle; |
| 683 | }; |
| 684 | |
Kristian Høgsberg | 7ada60e | 2007-06-22 00:20:34 +0200 | [diff] [blame] | 685 | /** |
| 686 | * struct fw_cdev_stop_iso - Stop an isochronous transmission or reception |
| 687 | * @handle: Handle of isochronous context to stop |
| 688 | */ |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 689 | struct fw_cdev_stop_iso { |
| 690 | __u32 handle; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 691 | }; |
| 692 | |
Stefan Richter | a64408b | 2007-09-29 10:41:58 +0200 | [diff] [blame] | 693 | /** |
| 694 | * struct fw_cdev_get_cycle_timer - read cycle timer register |
| 695 | * @local_time: system time, in microseconds since the Epoch |
Stefan Richter | abfe5a0 | 2010-02-20 12:13:49 +0100 | [diff] [blame] | 696 | * @cycle_timer: Cycle Time register contents |
Stefan Richter | a64408b | 2007-09-29 10:41:58 +0200 | [diff] [blame] | 697 | * |
| 698 | * The %FW_CDEV_IOC_GET_CYCLE_TIMER ioctl reads the isochronous cycle timer |
Stefan Richter | abfe5a0 | 2010-02-20 12:13:49 +0100 | [diff] [blame] | 699 | * and also the system clock (%CLOCK_REALTIME). This allows to express the |
| 700 | * receive time of an isochronous packet as a system time. |
Stefan Richter | 77258da | 2009-01-07 20:14:53 +0100 | [diff] [blame] | 701 | * |
| 702 | * @cycle_timer consists of 7 bits cycleSeconds, 13 bits cycleCount, and |
Stefan Richter | abfe5a0 | 2010-02-20 12:13:49 +0100 | [diff] [blame] | 703 | * 12 bits cycleOffset, in host byte order. Cf. the Cycle Time register |
| 704 | * per IEEE 1394 or Isochronous Cycle Timer register per OHCI-1394. |
Stefan Richter | e94b6d7 | 2010-02-21 12:48:57 +0100 | [diff] [blame] | 705 | * |
| 706 | * In version 1 and 2 of the ABI, this ioctl returned unreliable (non- |
| 707 | * monotonic) @cycle_timer values on certain controllers. |
Stefan Richter | a64408b | 2007-09-29 10:41:58 +0200 | [diff] [blame] | 708 | */ |
| 709 | struct fw_cdev_get_cycle_timer { |
| 710 | __u64 local_time; |
| 711 | __u32 cycle_timer; |
| 712 | }; |
| 713 | |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 714 | /** |
Stefan Richter | abfe5a0 | 2010-02-20 12:13:49 +0100 | [diff] [blame] | 715 | * struct fw_cdev_get_cycle_timer2 - read cycle timer register |
| 716 | * @tv_sec: system time, seconds |
| 717 | * @tv_nsec: system time, sub-seconds part in nanoseconds |
| 718 | * @clk_id: input parameter, clock from which to get the system time |
| 719 | * @cycle_timer: Cycle Time register contents |
| 720 | * |
| 721 | * The %FW_CDEV_IOC_GET_CYCLE_TIMER2 works like |
| 722 | * %FW_CDEV_IOC_GET_CYCLE_TIMER but lets you choose a clock like with POSIX' |
| 723 | * clock_gettime function. Supported @clk_id values are POSIX' %CLOCK_REALTIME |
| 724 | * and %CLOCK_MONOTONIC and Linux' %CLOCK_MONOTONIC_RAW. |
| 725 | */ |
| 726 | struct fw_cdev_get_cycle_timer2 { |
| 727 | __s64 tv_sec; |
| 728 | __s32 tv_nsec; |
| 729 | __s32 clk_id; |
| 730 | __u32 cycle_timer; |
| 731 | }; |
| 732 | |
| 733 | /** |
Stefan Richter | 1ec3c02 | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 734 | * struct fw_cdev_allocate_iso_resource - (De)allocate a channel or bandwidth |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 735 | * @closure: Passed back to userspace in correponding iso resource events |
Stefan Richter | 1ec3c02 | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 736 | * @channels: Isochronous channels of which one is to be (de)allocated |
| 737 | * @bandwidth: Isochronous bandwidth units to be (de)allocated |
| 738 | * @handle: Handle to the allocation, written by the kernel (only valid in |
| 739 | * case of %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE ioctls) |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 740 | * |
| 741 | * The %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE ioctl initiates allocation of an |
| 742 | * isochronous channel and/or of isochronous bandwidth at the isochronous |
| 743 | * resource manager (IRM). Only one of the channels specified in @channels is |
| 744 | * allocated. An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED is sent after |
| 745 | * communication with the IRM, indicating success or failure in the event data. |
| 746 | * The kernel will automatically reallocate the resources after bus resets. |
| 747 | * Should a reallocation fail, an %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event |
| 748 | * will be sent. The kernel will also automatically deallocate the resources |
| 749 | * when the file descriptor is closed. |
| 750 | * |
Stefan Richter | 1ec3c02 | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 751 | * The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE ioctl can be used to initiate |
| 752 | * deallocation of resources which were allocated as described above. |
| 753 | * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation. |
| 754 | * |
| 755 | * The %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE ioctl is a variant of allocation |
| 756 | * without automatic re- or deallocation. |
| 757 | * An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event concludes this operation, |
| 758 | * indicating success or failure in its data. |
| 759 | * |
| 760 | * The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE ioctl works like |
| 761 | * %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE except that resources are freed |
Stefan Richter | 5d9cb7d | 2009-01-08 23:07:40 +0100 | [diff] [blame] | 762 | * instead of allocated. |
Stefan Richter | 1ec3c02 | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 763 | * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation. |
| 764 | * |
Stefan Richter | ca658b1 | 2010-04-10 12:23:09 +0200 | [diff] [blame] | 765 | * To summarize, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE allocates iso resources |
| 766 | * for the lifetime of the fd or @handle. |
Stefan Richter | 1ec3c02 | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 767 | * In contrast, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE allocates iso resources |
| 768 | * for the duration of a bus generation. |
| 769 | * |
Stefan Richter | 5d9cb7d | 2009-01-08 23:07:40 +0100 | [diff] [blame] | 770 | * @channels is a host-endian bitfield with the least significant bit |
| 771 | * representing channel 0 and the most significant bit representing channel 63: |
| 772 | * 1ULL << c for each channel c that is a candidate for (de)allocation. |
Jay Fenlason, Stefan Richter | b1bda4c | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 773 | * |
| 774 | * @bandwidth is expressed in bandwidth allocation units, i.e. the time to send |
| 775 | * one quadlet of data (payload or header data) at speed S1600. |
| 776 | */ |
| 777 | struct fw_cdev_allocate_iso_resource { |
| 778 | __u64 closure; |
| 779 | __u64 channels; |
| 780 | __u32 bandwidth; |
| 781 | __u32 handle; |
| 782 | }; |
| 783 | |
Stefan Richter | 33580a3 | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 784 | /** |
Jay Fenlason | f8c2287 | 2009-03-05 19:08:40 +0100 | [diff] [blame] | 785 | * struct fw_cdev_send_stream_packet - send an asynchronous stream packet |
Stefan Richter | 18e9b10 | 2009-03-10 21:02:21 +0100 | [diff] [blame] | 786 | * @length: Length of outgoing payload, in bytes |
| 787 | * @tag: Data format tag |
| 788 | * @channel: Isochronous channel to transmit to |
| 789 | * @sy: Synchronization code |
| 790 | * @closure: Passed back to userspace in the response event |
| 791 | * @data: Userspace pointer to payload |
| 792 | * @generation: The bus generation where packet is valid |
| 793 | * @speed: Speed to transmit at |
Jay Fenlason | f8c2287 | 2009-03-05 19:08:40 +0100 | [diff] [blame] | 794 | * |
| 795 | * The %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl sends an asynchronous stream packet |
Stefan Richter | 18e9b10 | 2009-03-10 21:02:21 +0100 | [diff] [blame] | 796 | * to every device which is listening to the specified channel. The kernel |
| 797 | * writes an &fw_cdev_event_response event which indicates success or failure of |
| 798 | * the transmission. |
Jay Fenlason | f8c2287 | 2009-03-05 19:08:40 +0100 | [diff] [blame] | 799 | */ |
| 800 | struct fw_cdev_send_stream_packet { |
Stefan Richter | 18e9b10 | 2009-03-10 21:02:21 +0100 | [diff] [blame] | 801 | __u32 length; |
| 802 | __u32 tag; |
Jay Fenlason | f8c2287 | 2009-03-05 19:08:40 +0100 | [diff] [blame] | 803 | __u32 channel; |
| 804 | __u32 sy; |
Stefan Richter | 18e9b10 | 2009-03-10 21:02:21 +0100 | [diff] [blame] | 805 | __u64 closure; |
Jay Fenlason | f8c2287 | 2009-03-05 19:08:40 +0100 | [diff] [blame] | 806 | __u64 data; |
Stefan Richter | 18e9b10 | 2009-03-10 21:02:21 +0100 | [diff] [blame] | 807 | __u32 generation; |
| 808 | __u32 speed; |
Jay Fenlason | f8c2287 | 2009-03-05 19:08:40 +0100 | [diff] [blame] | 809 | }; |
| 810 | |
Kristian Høgsberg | 4c5a443 | 2007-05-07 20:33:37 -0400 | [diff] [blame] | 811 | #endif /* _LINUX_FIREWIRE_CDEV_H */ |