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