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