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