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