1607ca46eSDavid Howells /* 2607ca46eSDavid Howells * Char device interface. 3607ca46eSDavid Howells * 4607ca46eSDavid Howells * Copyright (C) 2005-2007 Kristian Hoegsberg <[email protected]> 5607ca46eSDavid Howells * 6607ca46eSDavid Howells * Permission is hereby granted, free of charge, to any person obtaining a 7607ca46eSDavid Howells * copy of this software and associated documentation files (the "Software"), 8607ca46eSDavid Howells * to deal in the Software without restriction, including without limitation 9607ca46eSDavid Howells * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10607ca46eSDavid Howells * and/or sell copies of the Software, and to permit persons to whom the 11607ca46eSDavid Howells * Software is furnished to do so, subject to the following conditions: 12607ca46eSDavid Howells * 13607ca46eSDavid Howells * The above copyright notice and this permission notice (including the next 14607ca46eSDavid Howells * paragraph) shall be included in all copies or substantial portions of the 15607ca46eSDavid Howells * Software. 16607ca46eSDavid Howells * 17607ca46eSDavid Howells * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18607ca46eSDavid Howells * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19607ca46eSDavid Howells * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20607ca46eSDavid Howells * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21607ca46eSDavid Howells * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22607ca46eSDavid Howells * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23607ca46eSDavid Howells * DEALINGS IN THE SOFTWARE. 24607ca46eSDavid Howells */ 25607ca46eSDavid Howells 26607ca46eSDavid Howells #ifndef _LINUX_FIREWIRE_CDEV_H 27607ca46eSDavid Howells #define _LINUX_FIREWIRE_CDEV_H 28607ca46eSDavid Howells 29607ca46eSDavid Howells #include <linux/ioctl.h> 30607ca46eSDavid Howells #include <linux/types.h> 31607ca46eSDavid Howells #include <linux/firewire-constants.h> 32607ca46eSDavid Howells 33607ca46eSDavid Howells /* available since kernel version 2.6.22 */ 34607ca46eSDavid Howells #define FW_CDEV_EVENT_BUS_RESET 0x00 35607ca46eSDavid Howells #define FW_CDEV_EVENT_RESPONSE 0x01 36607ca46eSDavid Howells #define FW_CDEV_EVENT_REQUEST 0x02 37607ca46eSDavid Howells #define FW_CDEV_EVENT_ISO_INTERRUPT 0x03 38607ca46eSDavid Howells 39607ca46eSDavid Howells /* available since kernel version 2.6.30 */ 40607ca46eSDavid Howells #define FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED 0x04 41607ca46eSDavid Howells #define FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 0x05 42607ca46eSDavid Howells 43607ca46eSDavid Howells /* available since kernel version 2.6.36 */ 44607ca46eSDavid Howells #define FW_CDEV_EVENT_REQUEST2 0x06 45607ca46eSDavid Howells #define FW_CDEV_EVENT_PHY_PACKET_SENT 0x07 46607ca46eSDavid Howells #define FW_CDEV_EVENT_PHY_PACKET_RECEIVED 0x08 47607ca46eSDavid Howells #define FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL 0x09 48607ca46eSDavid Howells 497c22d4a9STakashi Sakamoto /* available since kernel version 6.5 */ 507c22d4a9STakashi Sakamoto #define FW_CDEV_EVENT_REQUEST3 0x0a 51*fc2b52cfSTakashi Sakamoto #define FW_CDEV_EVENT_RESPONSE2 0x0b 527c22d4a9STakashi Sakamoto 53607ca46eSDavid Howells /** 549a400682SRandy Dunlap * struct fw_cdev_event_common - Common part of all fw_cdev_event_* types 55607ca46eSDavid Howells * @closure: For arbitrary use by userspace 569a400682SRandy Dunlap * @type: Discriminates the fw_cdev_event_* types 57607ca46eSDavid Howells * 589a400682SRandy Dunlap * This struct may be used to access generic members of all fw_cdev_event_* 59607ca46eSDavid Howells * types regardless of the specific type. 60607ca46eSDavid Howells * 61607ca46eSDavid Howells * Data passed in the @closure field for a request will be returned in the 62607ca46eSDavid Howells * corresponding event. It is big enough to hold a pointer on all platforms. 63607ca46eSDavid Howells * The ioctl used to set @closure depends on the @type of event. 64607ca46eSDavid Howells */ 65607ca46eSDavid Howells struct fw_cdev_event_common { 66607ca46eSDavid Howells __u64 closure; 67607ca46eSDavid Howells __u32 type; 68607ca46eSDavid Howells }; 69607ca46eSDavid Howells 70607ca46eSDavid Howells /** 71607ca46eSDavid Howells * struct fw_cdev_event_bus_reset - Sent when a bus reset occurred 72607ca46eSDavid Howells * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_GET_INFO ioctl 73607ca46eSDavid Howells * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_BUS_RESET 74607ca46eSDavid Howells * @node_id: New node ID of this node 75607ca46eSDavid Howells * @local_node_id: Node ID of the local node, i.e. of the controller 76607ca46eSDavid Howells * @bm_node_id: Node ID of the bus manager 77607ca46eSDavid Howells * @irm_node_id: Node ID of the iso resource manager 78607ca46eSDavid Howells * @root_node_id: Node ID of the root node 79607ca46eSDavid Howells * @generation: New bus generation 80607ca46eSDavid Howells * 81607ca46eSDavid Howells * This event is sent when the bus the device belongs to goes through a bus 82607ca46eSDavid Howells * reset. It provides information about the new bus configuration, such as 83607ca46eSDavid Howells * new node ID for this device, new root ID, and others. 84607ca46eSDavid Howells * 85607ca46eSDavid Howells * If @bm_node_id is 0xffff right after bus reset it can be reread by an 86607ca46eSDavid Howells * %FW_CDEV_IOC_GET_INFO ioctl after bus manager selection was finished. 87607ca46eSDavid Howells * Kernels with ABI version < 4 do not set @bm_node_id. 88607ca46eSDavid Howells */ 89607ca46eSDavid Howells struct fw_cdev_event_bus_reset { 90607ca46eSDavid Howells __u64 closure; 91607ca46eSDavid Howells __u32 type; 92607ca46eSDavid Howells __u32 node_id; 93607ca46eSDavid Howells __u32 local_node_id; 94607ca46eSDavid Howells __u32 bm_node_id; 95607ca46eSDavid Howells __u32 irm_node_id; 96607ca46eSDavid Howells __u32 root_node_id; 97607ca46eSDavid Howells __u32 generation; 98607ca46eSDavid Howells }; 99607ca46eSDavid Howells 100607ca46eSDavid Howells /** 101607ca46eSDavid Howells * struct fw_cdev_event_response - Sent when a response packet was received 102607ca46eSDavid Howells * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_REQUEST 103607ca46eSDavid Howells * or %FW_CDEV_IOC_SEND_BROADCAST_REQUEST 104607ca46eSDavid Howells * or %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl 105607ca46eSDavid Howells * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_RESPONSE 106607ca46eSDavid Howells * @rcode: Response code returned by the remote node 107607ca46eSDavid Howells * @length: Data length, i.e. the response's payload size in bytes 108607ca46eSDavid Howells * @data: Payload data, if any 109607ca46eSDavid Howells * 110*fc2b52cfSTakashi Sakamoto * This event is sent instead of &fw_cdev_event_response if the kernel or the client implements 111*fc2b52cfSTakashi Sakamoto * ABI version <= 5. It has the lack of time stamp field comparing to &fw_cdev_event_response2. 112*fc2b52cfSTakashi Sakamoto */ 113*fc2b52cfSTakashi Sakamoto struct fw_cdev_event_response { 114*fc2b52cfSTakashi Sakamoto __u64 closure; 115*fc2b52cfSTakashi Sakamoto __u32 type; 116*fc2b52cfSTakashi Sakamoto __u32 rcode; 117*fc2b52cfSTakashi Sakamoto __u32 length; 118*fc2b52cfSTakashi Sakamoto __u32 data[]; 119*fc2b52cfSTakashi Sakamoto }; 120*fc2b52cfSTakashi Sakamoto 121*fc2b52cfSTakashi Sakamoto /** 122*fc2b52cfSTakashi Sakamoto * struct fw_cdev_event_response2 - Sent when a response packet was received 123*fc2b52cfSTakashi Sakamoto * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_REQUEST 124*fc2b52cfSTakashi Sakamoto * or %FW_CDEV_IOC_SEND_BROADCAST_REQUEST 125*fc2b52cfSTakashi Sakamoto * or %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl 126*fc2b52cfSTakashi Sakamoto * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_RESPONSE 127*fc2b52cfSTakashi Sakamoto * @rcode: Response code returned by the remote node 128*fc2b52cfSTakashi Sakamoto * @length: Data length, i.e. the response's payload size in bytes 129*fc2b52cfSTakashi Sakamoto * @request_tstamp: The time stamp of isochronous cycle at which the request was sent. 130*fc2b52cfSTakashi Sakamoto * @response_tstamp: The time stamp of isochronous cycle at which the response was sent. 131*fc2b52cfSTakashi Sakamoto * @data: Payload data, if any 132*fc2b52cfSTakashi Sakamoto * 133607ca46eSDavid Howells * This event is sent when the stack receives a response to an outgoing request 134607ca46eSDavid Howells * sent by %FW_CDEV_IOC_SEND_REQUEST ioctl. The payload data for responses 135607ca46eSDavid Howells * carrying data (read and lock responses) follows immediately and can be 136607ca46eSDavid Howells * accessed through the @data field. 137607ca46eSDavid Howells * 138607ca46eSDavid Howells * The event is also generated after conclusions of transactions that do not 139607ca46eSDavid Howells * involve response packets. This includes unified write transactions, 140607ca46eSDavid Howells * broadcast write transactions, and transmission of asynchronous stream 141607ca46eSDavid Howells * packets. @rcode indicates success or failure of such transmissions. 142*fc2b52cfSTakashi Sakamoto * 143*fc2b52cfSTakashi Sakamoto * The value of @request_tstamp expresses the isochronous cycle at which the request was sent to 144*fc2b52cfSTakashi Sakamoto * initiate the transaction. The value of @response_tstamp expresses the isochronous cycle at which 145*fc2b52cfSTakashi Sakamoto * the response arrived to complete the transaction. Each value is unsigned 16 bit integer 146*fc2b52cfSTakashi Sakamoto * containing three low order bits of second field and all 13 bits of cycle field in format of 147*fc2b52cfSTakashi Sakamoto * CYCLE_TIMER register. 148607ca46eSDavid Howells */ 149*fc2b52cfSTakashi Sakamoto struct fw_cdev_event_response2 { 150607ca46eSDavid Howells __u64 closure; 151607ca46eSDavid Howells __u32 type; 152607ca46eSDavid Howells __u32 rcode; 153607ca46eSDavid Howells __u32 length; 154*fc2b52cfSTakashi Sakamoto __u32 request_tstamp; 155*fc2b52cfSTakashi Sakamoto __u32 response_tstamp; 156*fc2b52cfSTakashi Sakamoto /* 157*fc2b52cfSTakashi Sakamoto * Padding to keep the size of structure as multiples of 8 in various architectures since 158*fc2b52cfSTakashi Sakamoto * 4 byte alignment is used for 8 byte of object type in System V ABI for i386 architecture. 159*fc2b52cfSTakashi Sakamoto */ 160*fc2b52cfSTakashi Sakamoto __u32 padding; 16194dfc73eSGustavo A. R. Silva __u32 data[]; 162607ca46eSDavid Howells }; 163607ca46eSDavid Howells 164607ca46eSDavid Howells /** 165607ca46eSDavid Howells * struct fw_cdev_event_request - Old version of &fw_cdev_event_request2 1669a400682SRandy Dunlap * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl 167607ca46eSDavid Howells * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST 1689a400682SRandy Dunlap * @tcode: Transaction code of the incoming request 1699a400682SRandy Dunlap * @offset: The offset into the 48-bit per-node address space 1709a400682SRandy Dunlap * @handle: Reference to the kernel-side pending request 1719a400682SRandy Dunlap * @length: Data length, i.e. the request's payload size in bytes 1729a400682SRandy Dunlap * @data: Incoming data, if any 173607ca46eSDavid Howells * 174607ca46eSDavid Howells * This event is sent instead of &fw_cdev_event_request2 if the kernel or 175607ca46eSDavid Howells * the client implements ABI version <= 3. &fw_cdev_event_request lacks 176607ca46eSDavid Howells * essential information; use &fw_cdev_event_request2 instead. 177607ca46eSDavid Howells */ 178607ca46eSDavid Howells struct fw_cdev_event_request { 179607ca46eSDavid Howells __u64 closure; 180607ca46eSDavid Howells __u32 type; 181607ca46eSDavid Howells __u32 tcode; 182607ca46eSDavid Howells __u64 offset; 183607ca46eSDavid Howells __u32 handle; 184607ca46eSDavid Howells __u32 length; 18594dfc73eSGustavo A. R. Silva __u32 data[]; 186607ca46eSDavid Howells }; 187607ca46eSDavid Howells 188607ca46eSDavid Howells /** 189607ca46eSDavid Howells * struct fw_cdev_event_request2 - Sent on incoming request to an address region 190607ca46eSDavid Howells * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl 191607ca46eSDavid Howells * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST2 192607ca46eSDavid Howells * @tcode: Transaction code of the incoming request 193607ca46eSDavid Howells * @offset: The offset into the 48-bit per-node address space 194607ca46eSDavid Howells * @source_node_id: Sender node ID 195607ca46eSDavid Howells * @destination_node_id: Destination node ID 196607ca46eSDavid Howells * @card: The index of the card from which the request came 197607ca46eSDavid Howells * @generation: Bus generation in which the request is valid 198607ca46eSDavid Howells * @handle: Reference to the kernel-side pending request 199607ca46eSDavid Howells * @length: Data length, i.e. the request's payload size in bytes 200607ca46eSDavid Howells * @data: Incoming data, if any 201607ca46eSDavid Howells * 2027c22d4a9STakashi Sakamoto * This event is sent instead of &fw_cdev_event_request3 if the kernel or the client implements 2037c22d4a9STakashi Sakamoto * ABI version <= 5. It has the lack of time stamp field comparing to &fw_cdev_event_request3. 2047c22d4a9STakashi Sakamoto */ 2057c22d4a9STakashi Sakamoto struct fw_cdev_event_request2 { 2067c22d4a9STakashi Sakamoto __u64 closure; 2077c22d4a9STakashi Sakamoto __u32 type; 2087c22d4a9STakashi Sakamoto __u32 tcode; 2097c22d4a9STakashi Sakamoto __u64 offset; 2107c22d4a9STakashi Sakamoto __u32 source_node_id; 2117c22d4a9STakashi Sakamoto __u32 destination_node_id; 2127c22d4a9STakashi Sakamoto __u32 card; 2137c22d4a9STakashi Sakamoto __u32 generation; 2147c22d4a9STakashi Sakamoto __u32 handle; 2157c22d4a9STakashi Sakamoto __u32 length; 2167c22d4a9STakashi Sakamoto __u32 data[]; 2177c22d4a9STakashi Sakamoto }; 2187c22d4a9STakashi Sakamoto 2197c22d4a9STakashi Sakamoto /** 2207c22d4a9STakashi Sakamoto * struct fw_cdev_event_request3 - Sent on incoming request to an address region 2217c22d4a9STakashi Sakamoto * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl 2227c22d4a9STakashi Sakamoto * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST2 2237c22d4a9STakashi Sakamoto * @tcode: Transaction code of the incoming request 2247c22d4a9STakashi Sakamoto * @offset: The offset into the 48-bit per-node address space 2257c22d4a9STakashi Sakamoto * @source_node_id: Sender node ID 2267c22d4a9STakashi Sakamoto * @destination_node_id: Destination node ID 2277c22d4a9STakashi Sakamoto * @card: The index of the card from which the request came 2287c22d4a9STakashi Sakamoto * @generation: Bus generation in which the request is valid 2297c22d4a9STakashi Sakamoto * @handle: Reference to the kernel-side pending request 2307c22d4a9STakashi Sakamoto * @length: Data length, i.e. the request's payload size in bytes 2317c22d4a9STakashi Sakamoto * @tstamp: The time stamp of isochronous cycle at which the request arrived. 2327c22d4a9STakashi Sakamoto * @data: Incoming data, if any 2337c22d4a9STakashi Sakamoto * 234607ca46eSDavid Howells * This event is sent when the stack receives an incoming request to an address 235607ca46eSDavid Howells * region registered using the %FW_CDEV_IOC_ALLOCATE ioctl. The request is 236607ca46eSDavid Howells * guaranteed to be completely contained in the specified region. Userspace is 237607ca46eSDavid Howells * responsible for sending the response by %FW_CDEV_IOC_SEND_RESPONSE ioctl, 238607ca46eSDavid Howells * using the same @handle. 239607ca46eSDavid Howells * 240607ca46eSDavid Howells * The payload data for requests carrying data (write and lock requests) 241607ca46eSDavid Howells * follows immediately and can be accessed through the @data field. 242607ca46eSDavid Howells * 243607ca46eSDavid Howells * Unlike &fw_cdev_event_request, @tcode of lock requests is one of the 244607ca46eSDavid Howells * firewire-core specific %TCODE_LOCK_MASK_SWAP...%TCODE_LOCK_VENDOR_DEPENDENT, 245607ca46eSDavid Howells * i.e. encodes the extended transaction code. 246607ca46eSDavid Howells * 247607ca46eSDavid Howells * @card may differ from &fw_cdev_get_info.card because requests are received 248607ca46eSDavid Howells * from all cards of the Linux host. @source_node_id, @destination_node_id, and 249607ca46eSDavid Howells * @generation pertain to that card. Destination node ID and bus generation may 250607ca46eSDavid Howells * therefore differ from the corresponding fields of the last 251607ca46eSDavid Howells * &fw_cdev_event_bus_reset. 252607ca46eSDavid Howells * 253607ca46eSDavid Howells * @destination_node_id may also differ from the current node ID because of a 254607ca46eSDavid Howells * non-local bus ID part or in case of a broadcast write request. Note, a 255607ca46eSDavid Howells * client must call an %FW_CDEV_IOC_SEND_RESPONSE ioctl even in case of a 256607ca46eSDavid Howells * broadcast write request; the kernel will then release the kernel-side pending 257607ca46eSDavid Howells * request but will not actually send a response packet. 258607ca46eSDavid Howells * 259607ca46eSDavid Howells * In case of a write request to FCP_REQUEST or FCP_RESPONSE, the kernel already 260607ca46eSDavid Howells * sent a write response immediately after the request was received; in this 261607ca46eSDavid Howells * case the client must still call an %FW_CDEV_IOC_SEND_RESPONSE ioctl to 262607ca46eSDavid Howells * release the kernel-side pending request, though another response won't be 263607ca46eSDavid Howells * sent. 264607ca46eSDavid Howells * 265607ca46eSDavid Howells * If the client subsequently needs to initiate requests to the sender node of 2667c22d4a9STakashi Sakamoto * an &fw_cdev_event_request3, it needs to use a device file with matching 267607ca46eSDavid Howells * card index, node ID, and generation for outbound requests. 2687c22d4a9STakashi Sakamoto * 2697c22d4a9STakashi Sakamoto * @tstamp is isochronous cycle at which the request arrived. It is 16 bit integer value and the 2707c22d4a9STakashi Sakamoto * higher 3 bits expresses three low order bits of second field in the format of CYCLE_TIME 2717c22d4a9STakashi Sakamoto * register and the rest 13 bits expresses cycle field. 272607ca46eSDavid Howells */ 2737c22d4a9STakashi Sakamoto struct fw_cdev_event_request3 { 274607ca46eSDavid Howells __u64 closure; 275607ca46eSDavid Howells __u32 type; 276607ca46eSDavid Howells __u32 tcode; 277607ca46eSDavid Howells __u64 offset; 278607ca46eSDavid Howells __u32 source_node_id; 279607ca46eSDavid Howells __u32 destination_node_id; 280607ca46eSDavid Howells __u32 card; 281607ca46eSDavid Howells __u32 generation; 282607ca46eSDavid Howells __u32 handle; 283607ca46eSDavid Howells __u32 length; 2847c22d4a9STakashi Sakamoto __u32 tstamp; 2857c22d4a9STakashi Sakamoto /* 2867c22d4a9STakashi Sakamoto * Padding to keep the size of structure as multiples of 8 in various architectures since 2877c22d4a9STakashi Sakamoto * 4 byte alignment is used for 8 byte of object type in System V ABI for i386 architecture. 2887c22d4a9STakashi Sakamoto */ 2897c22d4a9STakashi Sakamoto __u32 padding; 29094dfc73eSGustavo A. R. Silva __u32 data[]; 291607ca46eSDavid Howells }; 292607ca46eSDavid Howells 293607ca46eSDavid Howells /** 294607ca46eSDavid Howells * struct fw_cdev_event_iso_interrupt - Sent when an iso packet was completed 295607ca46eSDavid Howells * @closure: See &fw_cdev_event_common; 296607ca46eSDavid Howells * set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl 297607ca46eSDavid Howells * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_ISO_INTERRUPT 298607ca46eSDavid Howells * @cycle: Cycle counter of the last completed packet 299607ca46eSDavid Howells * @header_length: Total length of following headers, in bytes 300607ca46eSDavid Howells * @header: Stripped headers, if any 301607ca46eSDavid Howells * 302607ca46eSDavid Howells * This event is sent when the controller has completed an &fw_cdev_iso_packet 303607ca46eSDavid Howells * with the %FW_CDEV_ISO_INTERRUPT bit set, when explicitly requested with 304607ca46eSDavid Howells * %FW_CDEV_IOC_FLUSH_ISO, or when there have been so many completed packets 305607ca46eSDavid Howells * without the interrupt bit set that the kernel's internal buffer for @header 3060699a73aSClemens Ladisch * is about to overflow. (In the last case, ABI versions < 5 drop header data 3070699a73aSClemens Ladisch * up to the next interrupt packet.) 308607ca46eSDavid Howells * 309607ca46eSDavid Howells * Isochronous transmit events (context type %FW_CDEV_ISO_CONTEXT_TRANSMIT): 310607ca46eSDavid Howells * 311607ca46eSDavid Howells * In version 3 and some implementations of version 2 of the ABI, &header_length 312607ca46eSDavid Howells * is a multiple of 4 and &header contains timestamps of all packets up until 313607ca46eSDavid Howells * the interrupt packet. The format of the timestamps is as described below for 314607ca46eSDavid Howells * isochronous reception. In version 1 of the ABI, &header_length was 0. 315607ca46eSDavid Howells * 316607ca46eSDavid Howells * Isochronous receive events (context type %FW_CDEV_ISO_CONTEXT_RECEIVE): 317607ca46eSDavid Howells * 318607ca46eSDavid Howells * The headers stripped of all packets up until and including the interrupt 319607ca46eSDavid Howells * packet are returned in the @header field. The amount of header data per 320607ca46eSDavid Howells * packet is as specified at iso context creation by 321607ca46eSDavid Howells * &fw_cdev_create_iso_context.header_size. 322607ca46eSDavid Howells * 323607ca46eSDavid Howells * Hence, _interrupt.header_length / _context.header_size is the number of 324607ca46eSDavid Howells * packets received in this interrupt event. The client can now iterate 325607ca46eSDavid Howells * through the mmap()'ed DMA buffer according to this number of packets and 326607ca46eSDavid Howells * to the buffer sizes as the client specified in &fw_cdev_queue_iso. 327607ca46eSDavid Howells * 328607ca46eSDavid Howells * Since version 2 of this ABI, the portion for each packet in _interrupt.header 329607ca46eSDavid Howells * consists of the 1394 isochronous packet header, followed by a timestamp 330607ca46eSDavid Howells * quadlet if &fw_cdev_create_iso_context.header_size > 4, followed by quadlets 331607ca46eSDavid Howells * from the packet payload if &fw_cdev_create_iso_context.header_size > 8. 332607ca46eSDavid Howells * 333607ca46eSDavid Howells * Format of 1394 iso packet header: 16 bits data_length, 2 bits tag, 6 bits 334607ca46eSDavid Howells * channel, 4 bits tcode, 4 bits sy, in big endian byte order. 335607ca46eSDavid Howells * data_length is the actual received size of the packet without the four 336607ca46eSDavid Howells * 1394 iso packet header bytes. 337607ca46eSDavid Howells * 338607ca46eSDavid Howells * Format of timestamp: 16 bits invalid, 3 bits cycleSeconds, 13 bits 339607ca46eSDavid Howells * cycleCount, in big endian byte order. 340607ca46eSDavid Howells * 341607ca46eSDavid Howells * In version 1 of the ABI, no timestamp quadlet was inserted; instead, payload 342607ca46eSDavid Howells * data followed directly after the 1394 is header if header_size > 4. 343607ca46eSDavid Howells * Behaviour of ver. 1 of this ABI is no longer available since ABI ver. 2. 344607ca46eSDavid Howells */ 345607ca46eSDavid Howells struct fw_cdev_event_iso_interrupt { 346607ca46eSDavid Howells __u64 closure; 347607ca46eSDavid Howells __u32 type; 348607ca46eSDavid Howells __u32 cycle; 349607ca46eSDavid Howells __u32 header_length; 35094dfc73eSGustavo A. R. Silva __u32 header[]; 351607ca46eSDavid Howells }; 352607ca46eSDavid Howells 353607ca46eSDavid Howells /** 354607ca46eSDavid Howells * struct fw_cdev_event_iso_interrupt_mc - An iso buffer chunk was completed 355607ca46eSDavid Howells * @closure: See &fw_cdev_event_common; 356607ca46eSDavid Howells * set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl 357607ca46eSDavid Howells * @type: %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL 358607ca46eSDavid Howells * @completed: Offset into the receive buffer; data before this offset is valid 359607ca46eSDavid Howells * 360607ca46eSDavid Howells * This event is sent in multichannel contexts (context type 361607ca46eSDavid Howells * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL) for &fw_cdev_iso_packet buffer 362607ca46eSDavid Howells * chunks that have been completely filled and that have the 363607ca46eSDavid Howells * %FW_CDEV_ISO_INTERRUPT bit set, or when explicitly requested with 364607ca46eSDavid Howells * %FW_CDEV_IOC_FLUSH_ISO. 365607ca46eSDavid Howells * 366607ca46eSDavid Howells * The buffer is continuously filled with the following data, per packet: 367607ca46eSDavid Howells * - the 1394 iso packet header as described at &fw_cdev_event_iso_interrupt, 368607ca46eSDavid Howells * but in little endian byte order, 369607ca46eSDavid Howells * - packet payload (as many bytes as specified in the data_length field of 370607ca46eSDavid Howells * the 1394 iso packet header) in big endian byte order, 371607ca46eSDavid Howells * - 0...3 padding bytes as needed to align the following trailer quadlet, 372607ca46eSDavid Howells * - trailer quadlet, containing the reception timestamp as described at 373607ca46eSDavid Howells * &fw_cdev_event_iso_interrupt, but in little endian byte order. 374607ca46eSDavid Howells * 375607ca46eSDavid Howells * Hence the per-packet size is data_length (rounded up to a multiple of 4) + 8. 376607ca46eSDavid Howells * When processing the data, stop before a packet that would cross the 377607ca46eSDavid Howells * @completed offset. 378607ca46eSDavid Howells * 379607ca46eSDavid Howells * A packet near the end of a buffer chunk will typically spill over into the 380607ca46eSDavid Howells * next queued buffer chunk. It is the responsibility of the client to check 381607ca46eSDavid Howells * for this condition, assemble a broken-up packet from its parts, and not to 382607ca46eSDavid Howells * re-queue any buffer chunks in which as yet unread packet parts reside. 383607ca46eSDavid Howells */ 384607ca46eSDavid Howells struct fw_cdev_event_iso_interrupt_mc { 385607ca46eSDavid Howells __u64 closure; 386607ca46eSDavid Howells __u32 type; 387607ca46eSDavid Howells __u32 completed; 388607ca46eSDavid Howells }; 389607ca46eSDavid Howells 390607ca46eSDavid Howells /** 391607ca46eSDavid Howells * struct fw_cdev_event_iso_resource - Iso resources were allocated or freed 392607ca46eSDavid Howells * @closure: See &fw_cdev_event_common; 393af690f45SMauro Carvalho Chehab * set by``FW_CDEV_IOC_(DE)ALLOCATE_ISO_RESOURCE(_ONCE)`` ioctl 394607ca46eSDavid Howells * @type: %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or 395607ca46eSDavid Howells * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 396607ca46eSDavid Howells * @handle: Reference by which an allocated resource can be deallocated 397607ca46eSDavid Howells * @channel: Isochronous channel which was (de)allocated, if any 398607ca46eSDavid Howells * @bandwidth: Bandwidth allocation units which were (de)allocated, if any 399607ca46eSDavid Howells * 400607ca46eSDavid Howells * An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event is sent after an isochronous 401607ca46eSDavid Howells * resource was allocated at the IRM. The client has to check @channel and 402607ca46eSDavid Howells * @bandwidth for whether the allocation actually succeeded. 403607ca46eSDavid Howells * 404607ca46eSDavid Howells * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event is sent after an isochronous 405607ca46eSDavid Howells * resource was deallocated at the IRM. It is also sent when automatic 406607ca46eSDavid Howells * reallocation after a bus reset failed. 407607ca46eSDavid Howells * 408607ca46eSDavid Howells * @channel is <0 if no channel was (de)allocated or if reallocation failed. 409607ca46eSDavid Howells * @bandwidth is 0 if no bandwidth was (de)allocated or if reallocation failed. 410607ca46eSDavid Howells */ 411607ca46eSDavid Howells struct fw_cdev_event_iso_resource { 412607ca46eSDavid Howells __u64 closure; 413607ca46eSDavid Howells __u32 type; 414607ca46eSDavid Howells __u32 handle; 415607ca46eSDavid Howells __s32 channel; 416607ca46eSDavid Howells __s32 bandwidth; 417607ca46eSDavid Howells }; 418607ca46eSDavid Howells 419607ca46eSDavid Howells /** 420607ca46eSDavid Howells * struct fw_cdev_event_phy_packet - A PHY packet was transmitted or received 421607ca46eSDavid Howells * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_PHY_PACKET 422607ca46eSDavid Howells * or %FW_CDEV_IOC_RECEIVE_PHY_PACKETS ioctl 423607ca46eSDavid Howells * @type: %FW_CDEV_EVENT_PHY_PACKET_SENT or %..._RECEIVED 424607ca46eSDavid Howells * @rcode: %RCODE_..., indicates success or failure of transmission 425607ca46eSDavid Howells * @length: Data length in bytes 426607ca46eSDavid Howells * @data: Incoming data 427607ca46eSDavid Howells * 428607ca46eSDavid Howells * If @type is %FW_CDEV_EVENT_PHY_PACKET_SENT, @length is 0 and @data empty, 429607ca46eSDavid Howells * except in case of a ping packet: Then, @length is 4, and @data[0] is the 430607ca46eSDavid Howells * ping time in 49.152MHz clocks if @rcode is %RCODE_COMPLETE. 431607ca46eSDavid Howells * 432607ca46eSDavid Howells * If @type is %FW_CDEV_EVENT_PHY_PACKET_RECEIVED, @length is 8 and @data 433607ca46eSDavid Howells * consists of the two PHY packet quadlets, in host byte order. 434607ca46eSDavid Howells */ 435607ca46eSDavid Howells struct fw_cdev_event_phy_packet { 436607ca46eSDavid Howells __u64 closure; 437607ca46eSDavid Howells __u32 type; 438607ca46eSDavid Howells __u32 rcode; 439607ca46eSDavid Howells __u32 length; 44094dfc73eSGustavo A. R. Silva __u32 data[]; 441607ca46eSDavid Howells }; 442607ca46eSDavid Howells 443607ca46eSDavid Howells /** 4449a400682SRandy Dunlap * union fw_cdev_event - Convenience union of fw_cdev_event_* types 445607ca46eSDavid Howells * @common: Valid for all types 446607ca46eSDavid Howells * @bus_reset: Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET 447607ca46eSDavid Howells * @response: Valid if @common.type == %FW_CDEV_EVENT_RESPONSE 448607ca46eSDavid Howells * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST 449607ca46eSDavid Howells * @request2: Valid if @common.type == %FW_CDEV_EVENT_REQUEST2 450607ca46eSDavid Howells * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT 451607ca46eSDavid Howells * @iso_interrupt_mc: Valid if @common.type == 452607ca46eSDavid Howells * %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL 453607ca46eSDavid Howells * @iso_resource: Valid if @common.type == 454607ca46eSDavid Howells * %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or 455607ca46eSDavid Howells * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 456607ca46eSDavid Howells * @phy_packet: Valid if @common.type == 457607ca46eSDavid Howells * %FW_CDEV_EVENT_PHY_PACKET_SENT or 458607ca46eSDavid Howells * %FW_CDEV_EVENT_PHY_PACKET_RECEIVED 459607ca46eSDavid Howells * 4607c22d4a9STakashi Sakamoto * @request3: Valid if @common.type == %FW_CDEV_EVENT_REQUEST3 461*fc2b52cfSTakashi Sakamoto * @response2: Valid if @common.type == %FW_CDEV_EVENT_RESPONSE2 4627c22d4a9STakashi Sakamoto * 463607ca46eSDavid Howells * Convenience union for userspace use. Events could be read(2) into an 464607ca46eSDavid Howells * appropriately aligned char buffer and then cast to this union for further 465607ca46eSDavid Howells * processing. Note that for a request, response or iso_interrupt event, 466607ca46eSDavid Howells * the data[] or header[] may make the size of the full event larger than 467607ca46eSDavid Howells * sizeof(union fw_cdev_event). Also note that if you attempt to read(2) 468607ca46eSDavid Howells * an event into a buffer that is not large enough for it, the data that does 469607ca46eSDavid Howells * not fit will be discarded so that the next read(2) will return a new event. 470607ca46eSDavid Howells */ 471607ca46eSDavid Howells union fw_cdev_event { 472607ca46eSDavid Howells struct fw_cdev_event_common common; 473607ca46eSDavid Howells struct fw_cdev_event_bus_reset bus_reset; 474607ca46eSDavid Howells struct fw_cdev_event_response response; 475607ca46eSDavid Howells struct fw_cdev_event_request request; 476607ca46eSDavid Howells struct fw_cdev_event_request2 request2; /* added in 2.6.36 */ 477607ca46eSDavid Howells struct fw_cdev_event_iso_interrupt iso_interrupt; 478607ca46eSDavid Howells struct fw_cdev_event_iso_interrupt_mc iso_interrupt_mc; /* added in 2.6.36 */ 479607ca46eSDavid Howells struct fw_cdev_event_iso_resource iso_resource; /* added in 2.6.30 */ 480607ca46eSDavid Howells struct fw_cdev_event_phy_packet phy_packet; /* added in 2.6.36 */ 4817c22d4a9STakashi Sakamoto struct fw_cdev_event_request3 request3; /* added in 6.5 */ 482*fc2b52cfSTakashi Sakamoto struct fw_cdev_event_response2 response2; /* added in 6.5 */ 483607ca46eSDavid Howells }; 484607ca46eSDavid Howells 485607ca46eSDavid Howells /* available since kernel version 2.6.22 */ 486607ca46eSDavid Howells #define FW_CDEV_IOC_GET_INFO _IOWR('#', 0x00, struct fw_cdev_get_info) 487607ca46eSDavid Howells #define FW_CDEV_IOC_SEND_REQUEST _IOW('#', 0x01, struct fw_cdev_send_request) 488607ca46eSDavid Howells #define FW_CDEV_IOC_ALLOCATE _IOWR('#', 0x02, struct fw_cdev_allocate) 489607ca46eSDavid Howells #define FW_CDEV_IOC_DEALLOCATE _IOW('#', 0x03, struct fw_cdev_deallocate) 490607ca46eSDavid Howells #define FW_CDEV_IOC_SEND_RESPONSE _IOW('#', 0x04, struct fw_cdev_send_response) 491607ca46eSDavid Howells #define FW_CDEV_IOC_INITIATE_BUS_RESET _IOW('#', 0x05, struct fw_cdev_initiate_bus_reset) 492607ca46eSDavid Howells #define FW_CDEV_IOC_ADD_DESCRIPTOR _IOWR('#', 0x06, struct fw_cdev_add_descriptor) 493607ca46eSDavid Howells #define FW_CDEV_IOC_REMOVE_DESCRIPTOR _IOW('#', 0x07, struct fw_cdev_remove_descriptor) 494607ca46eSDavid Howells #define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOWR('#', 0x08, struct fw_cdev_create_iso_context) 495607ca46eSDavid Howells #define FW_CDEV_IOC_QUEUE_ISO _IOWR('#', 0x09, struct fw_cdev_queue_iso) 496607ca46eSDavid Howells #define FW_CDEV_IOC_START_ISO _IOW('#', 0x0a, struct fw_cdev_start_iso) 497607ca46eSDavid Howells #define FW_CDEV_IOC_STOP_ISO _IOW('#', 0x0b, struct fw_cdev_stop_iso) 498607ca46eSDavid Howells 499607ca46eSDavid Howells /* available since kernel version 2.6.24 */ 500607ca46eSDavid Howells #define FW_CDEV_IOC_GET_CYCLE_TIMER _IOR('#', 0x0c, struct fw_cdev_get_cycle_timer) 501607ca46eSDavid Howells 502607ca46eSDavid Howells /* available since kernel version 2.6.30 */ 503607ca46eSDavid Howells #define FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE _IOWR('#', 0x0d, struct fw_cdev_allocate_iso_resource) 504607ca46eSDavid Howells #define FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE _IOW('#', 0x0e, struct fw_cdev_deallocate) 505607ca46eSDavid Howells #define FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE _IOW('#', 0x0f, struct fw_cdev_allocate_iso_resource) 506607ca46eSDavid Howells #define FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE _IOW('#', 0x10, struct fw_cdev_allocate_iso_resource) 507607ca46eSDavid Howells #define FW_CDEV_IOC_GET_SPEED _IO('#', 0x11) /* returns speed code */ 508607ca46eSDavid Howells #define FW_CDEV_IOC_SEND_BROADCAST_REQUEST _IOW('#', 0x12, struct fw_cdev_send_request) 509607ca46eSDavid Howells #define FW_CDEV_IOC_SEND_STREAM_PACKET _IOW('#', 0x13, struct fw_cdev_send_stream_packet) 510607ca46eSDavid Howells 511607ca46eSDavid Howells /* available since kernel version 2.6.34 */ 512607ca46eSDavid Howells #define FW_CDEV_IOC_GET_CYCLE_TIMER2 _IOWR('#', 0x14, struct fw_cdev_get_cycle_timer2) 513607ca46eSDavid Howells 514607ca46eSDavid Howells /* available since kernel version 2.6.36 */ 515607ca46eSDavid Howells #define FW_CDEV_IOC_SEND_PHY_PACKET _IOWR('#', 0x15, struct fw_cdev_send_phy_packet) 516607ca46eSDavid Howells #define FW_CDEV_IOC_RECEIVE_PHY_PACKETS _IOW('#', 0x16, struct fw_cdev_receive_phy_packets) 517607ca46eSDavid Howells #define FW_CDEV_IOC_SET_ISO_CHANNELS _IOW('#', 0x17, struct fw_cdev_set_iso_channels) 518607ca46eSDavid Howells 519607ca46eSDavid Howells /* available since kernel version 3.4 */ 520607ca46eSDavid Howells #define FW_CDEV_IOC_FLUSH_ISO _IOW('#', 0x18, struct fw_cdev_flush_iso) 521607ca46eSDavid Howells 522607ca46eSDavid Howells /* 523607ca46eSDavid Howells * ABI version history 524607ca46eSDavid Howells * 1 (2.6.22) - initial version 525607ca46eSDavid Howells * (2.6.24) - added %FW_CDEV_IOC_GET_CYCLE_TIMER 526607ca46eSDavid Howells * 2 (2.6.30) - changed &fw_cdev_event_iso_interrupt.header if 527607ca46eSDavid Howells * &fw_cdev_create_iso_context.header_size is 8 or more 528607ca46eSDavid Howells * - added %FW_CDEV_IOC_*_ISO_RESOURCE*, 529607ca46eSDavid Howells * %FW_CDEV_IOC_GET_SPEED, %FW_CDEV_IOC_SEND_BROADCAST_REQUEST, 530607ca46eSDavid Howells * %FW_CDEV_IOC_SEND_STREAM_PACKET 531607ca46eSDavid Howells * (2.6.32) - added time stamp to xmit &fw_cdev_event_iso_interrupt 532607ca46eSDavid Howells * (2.6.33) - IR has always packet-per-buffer semantics now, not one of 533607ca46eSDavid Howells * dual-buffer or packet-per-buffer depending on hardware 534607ca46eSDavid Howells * - shared use and auto-response for FCP registers 535607ca46eSDavid Howells * 3 (2.6.34) - made &fw_cdev_get_cycle_timer reliable 536607ca46eSDavid Howells * - added %FW_CDEV_IOC_GET_CYCLE_TIMER2 537607ca46eSDavid Howells * 4 (2.6.36) - added %FW_CDEV_EVENT_REQUEST2, %FW_CDEV_EVENT_PHY_PACKET_*, 538607ca46eSDavid Howells * and &fw_cdev_allocate.region_end 539607ca46eSDavid Howells * - implemented &fw_cdev_event_bus_reset.bm_node_id 540607ca46eSDavid Howells * - added %FW_CDEV_IOC_SEND_PHY_PACKET, _RECEIVE_PHY_PACKETS 541607ca46eSDavid Howells * - added %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL, 542607ca46eSDavid Howells * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL, and 543607ca46eSDavid Howells * %FW_CDEV_IOC_SET_ISO_CHANNELS 544607ca46eSDavid Howells * 5 (3.4) - send %FW_CDEV_EVENT_ISO_INTERRUPT events when needed to 545607ca46eSDavid Howells * avoid dropping data 546607ca46eSDavid Howells * - added %FW_CDEV_IOC_FLUSH_ISO 5476add87e9STakashi Sakamoto * 6 (6.5) - added some event for subactions of asynchronous transaction with time stamp 5487c22d4a9STakashi Sakamoto * - %FW_CDEV_EVENT_REQUEST3 549*fc2b52cfSTakashi Sakamoto * - %FW_CDEV_EVENT_RESPONSE2 550607ca46eSDavid Howells */ 551607ca46eSDavid Howells 552607ca46eSDavid Howells /** 553607ca46eSDavid Howells * struct fw_cdev_get_info - General purpose information ioctl 554607ca46eSDavid Howells * @version: The version field is just a running serial number. Both an 555607ca46eSDavid Howells * input parameter (ABI version implemented by the client) and 556607ca46eSDavid Howells * output parameter (ABI version implemented by the kernel). 557607ca46eSDavid Howells * A client shall fill in the ABI @version for which the client 558607ca46eSDavid Howells * was implemented. This is necessary for forward compatibility. 559607ca46eSDavid Howells * @rom_length: If @rom is non-zero, up to @rom_length bytes of Configuration 560607ca46eSDavid Howells * ROM will be copied into that user space address. In either 561607ca46eSDavid Howells * case, @rom_length is updated with the actual length of the 562607ca46eSDavid Howells * Configuration ROM. 563607ca46eSDavid Howells * @rom: If non-zero, address of a buffer to be filled by a copy of the 564607ca46eSDavid Howells * device's Configuration ROM 565607ca46eSDavid Howells * @bus_reset: If non-zero, address of a buffer to be filled by a 566607ca46eSDavid Howells * &struct fw_cdev_event_bus_reset with the current state 567607ca46eSDavid Howells * of the bus. This does not cause a bus reset to happen. 568607ca46eSDavid Howells * @bus_reset_closure: Value of &closure in this and subsequent bus reset events 569607ca46eSDavid Howells * @card: The index of the card this device belongs to 570607ca46eSDavid Howells * 571607ca46eSDavid Howells * The %FW_CDEV_IOC_GET_INFO ioctl is usually the very first one which a client 572607ca46eSDavid Howells * performs right after it opened a /dev/fw* file. 573607ca46eSDavid Howells * 574607ca46eSDavid Howells * As a side effect, reception of %FW_CDEV_EVENT_BUS_RESET events to be read(2) 575607ca46eSDavid Howells * is started by this ioctl. 576607ca46eSDavid Howells */ 577607ca46eSDavid Howells struct fw_cdev_get_info { 578607ca46eSDavid Howells __u32 version; 579607ca46eSDavid Howells __u32 rom_length; 580607ca46eSDavid Howells __u64 rom; 581607ca46eSDavid Howells __u64 bus_reset; 582607ca46eSDavid Howells __u64 bus_reset_closure; 583607ca46eSDavid Howells __u32 card; 584607ca46eSDavid Howells }; 585607ca46eSDavid Howells 586607ca46eSDavid Howells /** 587607ca46eSDavid Howells * struct fw_cdev_send_request - Send an asynchronous request packet 588607ca46eSDavid Howells * @tcode: Transaction code of the request 589607ca46eSDavid Howells * @length: Length of outgoing payload, in bytes 590607ca46eSDavid Howells * @offset: 48-bit offset at destination node 591607ca46eSDavid Howells * @closure: Passed back to userspace in the response event 592607ca46eSDavid Howells * @data: Userspace pointer to payload 593607ca46eSDavid Howells * @generation: The bus generation where packet is valid 594607ca46eSDavid Howells * 595*fc2b52cfSTakashi Sakamoto * Send a request to the device. This ioctl implements all outgoing requests. Both quadlet and 596*fc2b52cfSTakashi Sakamoto * block request specify the payload as a pointer to the data in the @data field. Once the 597*fc2b52cfSTakashi Sakamoto * transaction completes, the kernel writes either &fw_cdev_event_response event or 598*fc2b52cfSTakashi Sakamoto * &fw_cdev_event_response event back. The @closure field is passed back to user space in the 599*fc2b52cfSTakashi Sakamoto * response event. 600607ca46eSDavid Howells */ 601607ca46eSDavid Howells struct fw_cdev_send_request { 602607ca46eSDavid Howells __u32 tcode; 603607ca46eSDavid Howells __u32 length; 604607ca46eSDavid Howells __u64 offset; 605607ca46eSDavid Howells __u64 closure; 606607ca46eSDavid Howells __u64 data; 607607ca46eSDavid Howells __u32 generation; 608607ca46eSDavid Howells }; 609607ca46eSDavid Howells 610607ca46eSDavid Howells /** 611607ca46eSDavid Howells * struct fw_cdev_send_response - Send an asynchronous response packet 612607ca46eSDavid Howells * @rcode: Response code as determined by the userspace handler 613607ca46eSDavid Howells * @length: Length of outgoing payload, in bytes 614607ca46eSDavid Howells * @data: Userspace pointer to payload 615607ca46eSDavid Howells * @handle: The handle from the &fw_cdev_event_request 616607ca46eSDavid Howells * 617607ca46eSDavid Howells * Send a response to an incoming request. By setting up an address range using 618607ca46eSDavid Howells * the %FW_CDEV_IOC_ALLOCATE ioctl, userspace can listen for incoming requests. An 619607ca46eSDavid Howells * incoming request will generate an %FW_CDEV_EVENT_REQUEST, and userspace must 620607ca46eSDavid Howells * send a reply using this ioctl. The event has a handle to the kernel-side 621607ca46eSDavid Howells * pending transaction, which should be used with this ioctl. 622607ca46eSDavid Howells */ 623607ca46eSDavid Howells struct fw_cdev_send_response { 624607ca46eSDavid Howells __u32 rcode; 625607ca46eSDavid Howells __u32 length; 626607ca46eSDavid Howells __u64 data; 627607ca46eSDavid Howells __u32 handle; 628607ca46eSDavid Howells }; 629607ca46eSDavid Howells 630607ca46eSDavid Howells /** 631607ca46eSDavid Howells * struct fw_cdev_allocate - Allocate a CSR in an address range 632607ca46eSDavid Howells * @offset: Start offset of the address range 633607ca46eSDavid Howells * @closure: To be passed back to userspace in request events 634607ca46eSDavid Howells * @length: Length of the CSR, in bytes 635607ca46eSDavid Howells * @handle: Handle to the allocation, written by the kernel 636607ca46eSDavid Howells * @region_end: First address above the address range (added in ABI v4, 2.6.36) 637607ca46eSDavid Howells * 638607ca46eSDavid Howells * Allocate an address range in the 48-bit address space on the local node 639607ca46eSDavid Howells * (the controller). This allows userspace to listen for requests with an 640607ca46eSDavid Howells * offset within that address range. Every time when the kernel receives a 641607ca46eSDavid Howells * request within the range, an &fw_cdev_event_request2 event will be emitted. 642607ca46eSDavid Howells * (If the kernel or the client implements ABI version <= 3, an 643607ca46eSDavid Howells * &fw_cdev_event_request will be generated instead.) 644607ca46eSDavid Howells * 645607ca46eSDavid Howells * The @closure field is passed back to userspace in these request events. 646607ca46eSDavid Howells * The @handle field is an out parameter, returning a handle to the allocated 647607ca46eSDavid Howells * range to be used for later deallocation of the range. 648607ca46eSDavid Howells * 649607ca46eSDavid Howells * The address range is allocated on all local nodes. The address allocation 650607ca46eSDavid Howells * is exclusive except for the FCP command and response registers. If an 651607ca46eSDavid Howells * exclusive address region is already in use, the ioctl fails with errno set 652607ca46eSDavid Howells * to %EBUSY. 653607ca46eSDavid Howells * 654607ca46eSDavid Howells * If kernel and client implement ABI version >= 4, the kernel looks up a free 655607ca46eSDavid Howells * spot of size @length inside [@offset..@region_end) and, if found, writes 656607ca46eSDavid Howells * the start address of the new CSR back in @offset. I.e. @offset is an 657607ca46eSDavid Howells * in and out parameter. If this automatic placement of a CSR in a bigger 658607ca46eSDavid Howells * address range is not desired, the client simply needs to set @region_end 659607ca46eSDavid Howells * = @offset + @length. 660607ca46eSDavid Howells * 661607ca46eSDavid Howells * If the kernel or the client implements ABI version <= 3, @region_end is 662607ca46eSDavid Howells * ignored and effectively assumed to be @offset + @length. 663607ca46eSDavid Howells * 664607ca46eSDavid Howells * @region_end is only present in a kernel header >= 2.6.36. If necessary, 665607ca46eSDavid Howells * this can for example be tested by #ifdef FW_CDEV_EVENT_REQUEST2. 666607ca46eSDavid Howells */ 667607ca46eSDavid Howells struct fw_cdev_allocate { 668607ca46eSDavid Howells __u64 offset; 669607ca46eSDavid Howells __u64 closure; 670607ca46eSDavid Howells __u32 length; 671607ca46eSDavid Howells __u32 handle; 672607ca46eSDavid Howells __u64 region_end; /* available since kernel version 2.6.36 */ 673607ca46eSDavid Howells }; 674607ca46eSDavid Howells 675607ca46eSDavid Howells /** 676607ca46eSDavid Howells * struct fw_cdev_deallocate - Free a CSR address range or isochronous resource 677607ca46eSDavid Howells * @handle: Handle to the address range or iso resource, as returned by the 678607ca46eSDavid Howells * kernel when the range or resource was allocated 679607ca46eSDavid Howells */ 680607ca46eSDavid Howells struct fw_cdev_deallocate { 681607ca46eSDavid Howells __u32 handle; 682607ca46eSDavid Howells }; 683607ca46eSDavid Howells 684607ca46eSDavid Howells #define FW_CDEV_LONG_RESET 0 685607ca46eSDavid Howells #define FW_CDEV_SHORT_RESET 1 686607ca46eSDavid Howells 687607ca46eSDavid Howells /** 688607ca46eSDavid Howells * struct fw_cdev_initiate_bus_reset - Initiate a bus reset 689607ca46eSDavid Howells * @type: %FW_CDEV_SHORT_RESET or %FW_CDEV_LONG_RESET 690607ca46eSDavid Howells * 691607ca46eSDavid Howells * Initiate a bus reset for the bus this device is on. The bus reset can be 692607ca46eSDavid Howells * either the original (long) bus reset or the arbitrated (short) bus reset 693607ca46eSDavid Howells * introduced in 1394a-2000. 694607ca46eSDavid Howells * 695607ca46eSDavid Howells * The ioctl returns immediately. A subsequent &fw_cdev_event_bus_reset 696607ca46eSDavid Howells * indicates when the reset actually happened. Since ABI v4, this may be 697607ca46eSDavid Howells * considerably later than the ioctl because the kernel ensures a grace period 698607ca46eSDavid Howells * between subsequent bus resets as per IEEE 1394 bus management specification. 699607ca46eSDavid Howells */ 700607ca46eSDavid Howells struct fw_cdev_initiate_bus_reset { 701607ca46eSDavid Howells __u32 type; 702607ca46eSDavid Howells }; 703607ca46eSDavid Howells 704607ca46eSDavid Howells /** 705607ca46eSDavid Howells * struct fw_cdev_add_descriptor - Add contents to the local node's config ROM 706607ca46eSDavid Howells * @immediate: If non-zero, immediate key to insert before pointer 707607ca46eSDavid Howells * @key: Upper 8 bits of root directory pointer 708607ca46eSDavid Howells * @data: Userspace pointer to contents of descriptor block 709607ca46eSDavid Howells * @length: Length of descriptor block data, in quadlets 710607ca46eSDavid Howells * @handle: Handle to the descriptor, written by the kernel 711607ca46eSDavid Howells * 712607ca46eSDavid Howells * Add a descriptor block and optionally a preceding immediate key to the local 713607ca46eSDavid Howells * node's Configuration ROM. 714607ca46eSDavid Howells * 715607ca46eSDavid Howells * The @key field specifies the upper 8 bits of the descriptor root directory 716607ca46eSDavid Howells * pointer and the @data and @length fields specify the contents. The @key 717607ca46eSDavid Howells * should be of the form 0xXX000000. The offset part of the root directory entry 718607ca46eSDavid Howells * will be filled in by the kernel. 719607ca46eSDavid Howells * 720607ca46eSDavid Howells * If not 0, the @immediate field specifies an immediate key which will be 721607ca46eSDavid Howells * inserted before the root directory pointer. 722607ca46eSDavid Howells * 723607ca46eSDavid Howells * @immediate, @key, and @data array elements are CPU-endian quadlets. 724607ca46eSDavid Howells * 725607ca46eSDavid Howells * If successful, the kernel adds the descriptor and writes back a @handle to 726607ca46eSDavid Howells * the kernel-side object to be used for later removal of the descriptor block 727607ca46eSDavid Howells * and immediate key. The kernel will also generate a bus reset to signal the 728607ca46eSDavid Howells * change of the Configuration ROM to other nodes. 729607ca46eSDavid Howells * 730607ca46eSDavid Howells * This ioctl affects the Configuration ROMs of all local nodes. 731607ca46eSDavid Howells * The ioctl only succeeds on device files which represent a local node. 732607ca46eSDavid Howells */ 733607ca46eSDavid Howells struct fw_cdev_add_descriptor { 734607ca46eSDavid Howells __u32 immediate; 735607ca46eSDavid Howells __u32 key; 736607ca46eSDavid Howells __u64 data; 737607ca46eSDavid Howells __u32 length; 738607ca46eSDavid Howells __u32 handle; 739607ca46eSDavid Howells }; 740607ca46eSDavid Howells 741607ca46eSDavid Howells /** 742607ca46eSDavid Howells * struct fw_cdev_remove_descriptor - Remove contents from the Configuration ROM 743607ca46eSDavid Howells * @handle: Handle to the descriptor, as returned by the kernel when the 744607ca46eSDavid Howells * descriptor was added 745607ca46eSDavid Howells * 746607ca46eSDavid Howells * Remove a descriptor block and accompanying immediate key from the local 747607ca46eSDavid Howells * nodes' Configuration ROMs. The kernel will also generate a bus reset to 748607ca46eSDavid Howells * signal the change of the Configuration ROM to other nodes. 749607ca46eSDavid Howells */ 750607ca46eSDavid Howells struct fw_cdev_remove_descriptor { 751607ca46eSDavid Howells __u32 handle; 752607ca46eSDavid Howells }; 753607ca46eSDavid Howells 754607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_TRANSMIT 0 755607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_RECEIVE 1 756607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL 2 /* added in 2.6.36 */ 757607ca46eSDavid Howells 758607ca46eSDavid Howells /** 759607ca46eSDavid Howells * struct fw_cdev_create_iso_context - Create a context for isochronous I/O 760607ca46eSDavid Howells * @type: %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE or 761607ca46eSDavid Howells * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL 762607ca46eSDavid Howells * @header_size: Header size to strip in single-channel reception 763607ca46eSDavid Howells * @channel: Channel to bind to in single-channel reception or transmission 764607ca46eSDavid Howells * @speed: Transmission speed 765607ca46eSDavid Howells * @closure: To be returned in &fw_cdev_event_iso_interrupt or 766607ca46eSDavid Howells * &fw_cdev_event_iso_interrupt_multichannel 767607ca46eSDavid Howells * @handle: Handle to context, written back by kernel 768607ca46eSDavid Howells * 769607ca46eSDavid Howells * Prior to sending or receiving isochronous I/O, a context must be created. 770607ca46eSDavid Howells * The context records information about the transmit or receive configuration 771607ca46eSDavid Howells * and typically maps to an underlying hardware resource. A context is set up 772607ca46eSDavid Howells * for either sending or receiving. It is bound to a specific isochronous 773607ca46eSDavid Howells * @channel. 774607ca46eSDavid Howells * 775607ca46eSDavid Howells * In case of multichannel reception, @header_size and @channel are ignored 776607ca46eSDavid Howells * and the channels are selected by %FW_CDEV_IOC_SET_ISO_CHANNELS. 777607ca46eSDavid Howells * 778607ca46eSDavid Howells * For %FW_CDEV_ISO_CONTEXT_RECEIVE contexts, @header_size must be at least 4 779607ca46eSDavid Howells * and must be a multiple of 4. It is ignored in other context types. 780607ca46eSDavid Howells * 781607ca46eSDavid Howells * @speed is ignored in receive context types. 782607ca46eSDavid Howells * 783607ca46eSDavid Howells * If a context was successfully created, the kernel writes back a handle to the 784607ca46eSDavid Howells * context, which must be passed in for subsequent operations on that context. 785607ca46eSDavid Howells * 786607ca46eSDavid Howells * Limitations: 787607ca46eSDavid Howells * No more than one iso context can be created per fd. 788607ca46eSDavid Howells * The total number of contexts that all userspace and kernelspace drivers can 789607ca46eSDavid Howells * create on a card at a time is a hardware limit, typically 4 or 8 contexts per 790607ca46eSDavid Howells * direction, and of them at most one multichannel receive context. 791607ca46eSDavid Howells */ 792607ca46eSDavid Howells struct fw_cdev_create_iso_context { 793607ca46eSDavid Howells __u32 type; 794607ca46eSDavid Howells __u32 header_size; 795607ca46eSDavid Howells __u32 channel; 796607ca46eSDavid Howells __u32 speed; 797607ca46eSDavid Howells __u64 closure; 798607ca46eSDavid Howells __u32 handle; 799607ca46eSDavid Howells }; 800607ca46eSDavid Howells 801607ca46eSDavid Howells /** 802607ca46eSDavid Howells * struct fw_cdev_set_iso_channels - Select channels in multichannel reception 803607ca46eSDavid Howells * @channels: Bitmask of channels to listen to 804607ca46eSDavid Howells * @handle: Handle of the mutichannel receive context 805607ca46eSDavid Howells * 806607ca46eSDavid Howells * @channels is the bitwise or of 1ULL << n for each channel n to listen to. 807607ca46eSDavid Howells * 808607ca46eSDavid Howells * The ioctl fails with errno %EBUSY if there is already another receive context 809607ca46eSDavid Howells * on a channel in @channels. In that case, the bitmask of all unoccupied 810607ca46eSDavid Howells * channels is returned in @channels. 811607ca46eSDavid Howells */ 812607ca46eSDavid Howells struct fw_cdev_set_iso_channels { 813607ca46eSDavid Howells __u64 channels; 814607ca46eSDavid Howells __u32 handle; 815607ca46eSDavid Howells }; 816607ca46eSDavid Howells 817607ca46eSDavid Howells #define FW_CDEV_ISO_PAYLOAD_LENGTH(v) (v) 818607ca46eSDavid Howells #define FW_CDEV_ISO_INTERRUPT (1 << 16) 819607ca46eSDavid Howells #define FW_CDEV_ISO_SKIP (1 << 17) 820607ca46eSDavid Howells #define FW_CDEV_ISO_SYNC (1 << 17) 821607ca46eSDavid Howells #define FW_CDEV_ISO_TAG(v) ((v) << 18) 822607ca46eSDavid Howells #define FW_CDEV_ISO_SY(v) ((v) << 20) 823607ca46eSDavid Howells #define FW_CDEV_ISO_HEADER_LENGTH(v) ((v) << 24) 824607ca46eSDavid Howells 825607ca46eSDavid Howells /** 826607ca46eSDavid Howells * struct fw_cdev_iso_packet - Isochronous packet 827607ca46eSDavid Howells * @control: Contains the header length (8 uppermost bits), 828607ca46eSDavid Howells * the sy field (4 bits), the tag field (2 bits), a sync flag 829607ca46eSDavid Howells * or a skip flag (1 bit), an interrupt flag (1 bit), and the 830607ca46eSDavid Howells * payload length (16 lowermost bits) 831607ca46eSDavid Howells * @header: Header and payload in case of a transmit context. 832607ca46eSDavid Howells * 833607ca46eSDavid Howells * &struct fw_cdev_iso_packet is used to describe isochronous packet queues. 8349a400682SRandy Dunlap * Use the FW_CDEV_ISO_* macros to fill in @control. 835607ca46eSDavid Howells * The @header array is empty in case of receive contexts. 836607ca46eSDavid Howells * 837607ca46eSDavid Howells * Context type %FW_CDEV_ISO_CONTEXT_TRANSMIT: 838607ca46eSDavid Howells * 839607ca46eSDavid Howells * @control.HEADER_LENGTH must be a multiple of 4. It specifies the numbers of 840607ca46eSDavid Howells * bytes in @header that will be prepended to the packet's payload. These bytes 841607ca46eSDavid Howells * are copied into the kernel and will not be accessed after the ioctl has 842607ca46eSDavid Howells * returned. 843607ca46eSDavid Howells * 844607ca46eSDavid Howells * The @control.SY and TAG fields are copied to the iso packet header. These 845607ca46eSDavid Howells * fields are specified by IEEE 1394a and IEC 61883-1. 846607ca46eSDavid Howells * 847607ca46eSDavid Howells * The @control.SKIP flag specifies that no packet is to be sent in a frame. 848607ca46eSDavid Howells * When using this, all other fields except @control.INTERRUPT must be zero. 849607ca46eSDavid Howells * 850607ca46eSDavid Howells * When a packet with the @control.INTERRUPT flag set has been completed, an 851607ca46eSDavid Howells * &fw_cdev_event_iso_interrupt event will be sent. 852607ca46eSDavid Howells * 853607ca46eSDavid Howells * Context type %FW_CDEV_ISO_CONTEXT_RECEIVE: 854607ca46eSDavid Howells * 855607ca46eSDavid Howells * @control.HEADER_LENGTH must be a multiple of the context's header_size. 856607ca46eSDavid Howells * If the HEADER_LENGTH is larger than the context's header_size, multiple 857607ca46eSDavid Howells * packets are queued for this entry. 858607ca46eSDavid Howells * 859607ca46eSDavid Howells * The @control.SY and TAG fields are ignored. 860607ca46eSDavid Howells * 861607ca46eSDavid Howells * If the @control.SYNC flag is set, the context drops all packets until a 862607ca46eSDavid Howells * packet with a sy field is received which matches &fw_cdev_start_iso.sync. 863607ca46eSDavid Howells * 864607ca46eSDavid Howells * @control.PAYLOAD_LENGTH defines how many payload bytes can be received for 865607ca46eSDavid Howells * one packet (in addition to payload quadlets that have been defined as headers 866607ca46eSDavid Howells * and are stripped and returned in the &fw_cdev_event_iso_interrupt structure). 867607ca46eSDavid Howells * If more bytes are received, the additional bytes are dropped. If less bytes 868607ca46eSDavid Howells * are received, the remaining bytes in this part of the payload buffer will not 869607ca46eSDavid Howells * be written to, not even by the next packet. I.e., packets received in 870607ca46eSDavid Howells * consecutive frames will not necessarily be consecutive in memory. If an 871607ca46eSDavid Howells * entry has queued multiple packets, the PAYLOAD_LENGTH is divided equally 872607ca46eSDavid Howells * among them. 873607ca46eSDavid Howells * 874607ca46eSDavid Howells * When a packet with the @control.INTERRUPT flag set has been completed, an 875607ca46eSDavid Howells * &fw_cdev_event_iso_interrupt event will be sent. An entry that has queued 876607ca46eSDavid Howells * multiple receive packets is completed when its last packet is completed. 877607ca46eSDavid Howells * 878607ca46eSDavid Howells * Context type %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL: 879607ca46eSDavid Howells * 880607ca46eSDavid Howells * Here, &fw_cdev_iso_packet would be more aptly named _iso_buffer_chunk since 881607ca46eSDavid Howells * it specifies a chunk of the mmap()'ed buffer, while the number and alignment 882607ca46eSDavid Howells * of packets to be placed into the buffer chunk is not known beforehand. 883607ca46eSDavid Howells * 884607ca46eSDavid Howells * @control.PAYLOAD_LENGTH is the size of the buffer chunk and specifies room 885607ca46eSDavid Howells * for header, payload, padding, and trailer bytes of one or more packets. 886607ca46eSDavid Howells * It must be a multiple of 4. 887607ca46eSDavid Howells * 888607ca46eSDavid Howells * @control.HEADER_LENGTH, TAG and SY are ignored. SYNC is treated as described 889607ca46eSDavid Howells * for single-channel reception. 890607ca46eSDavid Howells * 891607ca46eSDavid Howells * When a buffer chunk with the @control.INTERRUPT flag set has been filled 892607ca46eSDavid Howells * entirely, an &fw_cdev_event_iso_interrupt_mc event will be sent. 893607ca46eSDavid Howells */ 894607ca46eSDavid Howells struct fw_cdev_iso_packet { 895607ca46eSDavid Howells __u32 control; 89694dfc73eSGustavo A. R. Silva __u32 header[]; 897607ca46eSDavid Howells }; 898607ca46eSDavid Howells 899607ca46eSDavid Howells /** 900607ca46eSDavid Howells * struct fw_cdev_queue_iso - Queue isochronous packets for I/O 901607ca46eSDavid Howells * @packets: Userspace pointer to an array of &fw_cdev_iso_packet 902607ca46eSDavid Howells * @data: Pointer into mmap()'ed payload buffer 903607ca46eSDavid Howells * @size: Size of the @packets array, in bytes 904607ca46eSDavid Howells * @handle: Isochronous context handle 905607ca46eSDavid Howells * 906607ca46eSDavid Howells * Queue a number of isochronous packets for reception or transmission. 907607ca46eSDavid Howells * This ioctl takes a pointer to an array of &fw_cdev_iso_packet structs, 908607ca46eSDavid Howells * which describe how to transmit from or receive into a contiguous region 909607ca46eSDavid Howells * of a mmap()'ed payload buffer. As part of transmit packet descriptors, 910607ca46eSDavid Howells * a series of headers can be supplied, which will be prepended to the 911607ca46eSDavid Howells * payload during DMA. 912607ca46eSDavid Howells * 913607ca46eSDavid Howells * The kernel may or may not queue all packets, but will write back updated 914607ca46eSDavid Howells * values of the @packets, @data and @size fields, so the ioctl can be 915607ca46eSDavid Howells * resubmitted easily. 916607ca46eSDavid Howells * 917607ca46eSDavid Howells * In case of a multichannel receive context, @data must be quadlet-aligned 918607ca46eSDavid Howells * relative to the buffer start. 919607ca46eSDavid Howells */ 920607ca46eSDavid Howells struct fw_cdev_queue_iso { 921607ca46eSDavid Howells __u64 packets; 922607ca46eSDavid Howells __u64 data; 923607ca46eSDavid Howells __u32 size; 924607ca46eSDavid Howells __u32 handle; 925607ca46eSDavid Howells }; 926607ca46eSDavid Howells 927607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_MATCH_TAG0 1 928607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_MATCH_TAG1 2 929607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_MATCH_TAG2 4 930607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_MATCH_TAG3 8 931607ca46eSDavid Howells #define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS 15 932607ca46eSDavid Howells 933607ca46eSDavid Howells /** 934607ca46eSDavid Howells * struct fw_cdev_start_iso - Start an isochronous transmission or reception 935607ca46eSDavid Howells * @cycle: Cycle in which to start I/O. If @cycle is greater than or 936607ca46eSDavid Howells * equal to 0, the I/O will start on that cycle. 937df54714fSRandy Dunlap * @sync: Determines the value to wait for receive packets that have 938607ca46eSDavid Howells * the %FW_CDEV_ISO_SYNC bit set 939607ca46eSDavid Howells * @tags: Tag filter bit mask. Only valid for isochronous reception. 940607ca46eSDavid Howells * Determines the tag values for which packets will be accepted. 9419a400682SRandy Dunlap * Use FW_CDEV_ISO_CONTEXT_MATCH_* macros to set @tags. 942607ca46eSDavid Howells * @handle: Isochronous context handle within which to transmit or receive 943607ca46eSDavid Howells */ 944607ca46eSDavid Howells struct fw_cdev_start_iso { 945607ca46eSDavid Howells __s32 cycle; 946607ca46eSDavid Howells __u32 sync; 947607ca46eSDavid Howells __u32 tags; 948607ca46eSDavid Howells __u32 handle; 949607ca46eSDavid Howells }; 950607ca46eSDavid Howells 951607ca46eSDavid Howells /** 952607ca46eSDavid Howells * struct fw_cdev_stop_iso - Stop an isochronous transmission or reception 953607ca46eSDavid Howells * @handle: Handle of isochronous context to stop 954607ca46eSDavid Howells */ 955607ca46eSDavid Howells struct fw_cdev_stop_iso { 956607ca46eSDavid Howells __u32 handle; 957607ca46eSDavid Howells }; 958607ca46eSDavid Howells 959607ca46eSDavid Howells /** 960607ca46eSDavid Howells * struct fw_cdev_flush_iso - flush completed iso packets 961607ca46eSDavid Howells * @handle: handle of isochronous context to flush 962607ca46eSDavid Howells * 963607ca46eSDavid Howells * For %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE contexts, 964607ca46eSDavid Howells * report any completed packets. 965607ca46eSDavid Howells * 966607ca46eSDavid Howells * For %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL contexts, report the current 967607ca46eSDavid Howells * offset in the receive buffer, if it has changed; this is typically in the 968607ca46eSDavid Howells * middle of some buffer chunk. 969607ca46eSDavid Howells * 970607ca46eSDavid Howells * Any %FW_CDEV_EVENT_ISO_INTERRUPT or %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL 971607ca46eSDavid Howells * events generated by this ioctl are sent synchronously, i.e., are available 972607ca46eSDavid Howells * for reading from the file descriptor when this ioctl returns. 973607ca46eSDavid Howells */ 974607ca46eSDavid Howells struct fw_cdev_flush_iso { 975607ca46eSDavid Howells __u32 handle; 976607ca46eSDavid Howells }; 977607ca46eSDavid Howells 978607ca46eSDavid Howells /** 979607ca46eSDavid Howells * struct fw_cdev_get_cycle_timer - read cycle timer register 980607ca46eSDavid Howells * @local_time: system time, in microseconds since the Epoch 981607ca46eSDavid Howells * @cycle_timer: Cycle Time register contents 982607ca46eSDavid Howells * 983607ca46eSDavid Howells * Same as %FW_CDEV_IOC_GET_CYCLE_TIMER2, but fixed to use %CLOCK_REALTIME 984607ca46eSDavid Howells * and only with microseconds resolution. 985607ca46eSDavid Howells * 986607ca46eSDavid Howells * In version 1 and 2 of the ABI, this ioctl returned unreliable (non- 987607ca46eSDavid Howells * monotonic) @cycle_timer values on certain controllers. 988607ca46eSDavid Howells */ 989607ca46eSDavid Howells struct fw_cdev_get_cycle_timer { 990607ca46eSDavid Howells __u64 local_time; 991607ca46eSDavid Howells __u32 cycle_timer; 992607ca46eSDavid Howells }; 993607ca46eSDavid Howells 994607ca46eSDavid Howells /** 995607ca46eSDavid Howells * struct fw_cdev_get_cycle_timer2 - read cycle timer register 996607ca46eSDavid Howells * @tv_sec: system time, seconds 997607ca46eSDavid Howells * @tv_nsec: system time, sub-seconds part in nanoseconds 998607ca46eSDavid Howells * @clk_id: input parameter, clock from which to get the system time 999607ca46eSDavid Howells * @cycle_timer: Cycle Time register contents 1000607ca46eSDavid Howells * 1001607ca46eSDavid Howells * The %FW_CDEV_IOC_GET_CYCLE_TIMER2 ioctl reads the isochronous cycle timer 1002607ca46eSDavid Howells * and also the system clock. This allows to correlate reception time of 1003607ca46eSDavid Howells * isochronous packets with system time. 1004607ca46eSDavid Howells * 1005607ca46eSDavid Howells * @clk_id lets you choose a clock like with POSIX' clock_gettime function. 1006607ca46eSDavid Howells * Supported @clk_id values are POSIX' %CLOCK_REALTIME and %CLOCK_MONOTONIC 1007607ca46eSDavid Howells * and Linux' %CLOCK_MONOTONIC_RAW. 1008607ca46eSDavid Howells * 1009607ca46eSDavid Howells * @cycle_timer consists of 7 bits cycleSeconds, 13 bits cycleCount, and 1010607ca46eSDavid Howells * 12 bits cycleOffset, in host byte order. Cf. the Cycle Time register 1011607ca46eSDavid Howells * per IEEE 1394 or Isochronous Cycle Timer register per OHCI-1394. 1012607ca46eSDavid Howells */ 1013607ca46eSDavid Howells struct fw_cdev_get_cycle_timer2 { 1014607ca46eSDavid Howells __s64 tv_sec; 1015607ca46eSDavid Howells __s32 tv_nsec; 1016607ca46eSDavid Howells __s32 clk_id; 1017607ca46eSDavid Howells __u32 cycle_timer; 1018607ca46eSDavid Howells }; 1019607ca46eSDavid Howells 1020607ca46eSDavid Howells /** 1021607ca46eSDavid Howells * struct fw_cdev_allocate_iso_resource - (De)allocate a channel or bandwidth 1022607ca46eSDavid Howells * @closure: Passed back to userspace in corresponding iso resource events 1023607ca46eSDavid Howells * @channels: Isochronous channels of which one is to be (de)allocated 1024607ca46eSDavid Howells * @bandwidth: Isochronous bandwidth units to be (de)allocated 1025607ca46eSDavid Howells * @handle: Handle to the allocation, written by the kernel (only valid in 1026607ca46eSDavid Howells * case of %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE ioctls) 1027607ca46eSDavid Howells * 1028607ca46eSDavid Howells * The %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE ioctl initiates allocation of an 1029607ca46eSDavid Howells * isochronous channel and/or of isochronous bandwidth at the isochronous 1030607ca46eSDavid Howells * resource manager (IRM). Only one of the channels specified in @channels is 1031607ca46eSDavid Howells * allocated. An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED is sent after 1032607ca46eSDavid Howells * communication with the IRM, indicating success or failure in the event data. 1033607ca46eSDavid Howells * The kernel will automatically reallocate the resources after bus resets. 1034607ca46eSDavid Howells * Should a reallocation fail, an %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event 1035607ca46eSDavid Howells * will be sent. The kernel will also automatically deallocate the resources 1036607ca46eSDavid Howells * when the file descriptor is closed. 1037607ca46eSDavid Howells * 1038607ca46eSDavid Howells * The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE ioctl can be used to initiate 1039607ca46eSDavid Howells * deallocation of resources which were allocated as described above. 1040607ca46eSDavid Howells * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation. 1041607ca46eSDavid Howells * 1042607ca46eSDavid Howells * The %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE ioctl is a variant of allocation 1043607ca46eSDavid Howells * without automatic re- or deallocation. 1044607ca46eSDavid Howells * An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event concludes this operation, 1045607ca46eSDavid Howells * indicating success or failure in its data. 1046607ca46eSDavid Howells * 1047607ca46eSDavid Howells * The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE ioctl works like 1048607ca46eSDavid Howells * %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE except that resources are freed 1049607ca46eSDavid Howells * instead of allocated. 1050607ca46eSDavid Howells * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation. 1051607ca46eSDavid Howells * 1052607ca46eSDavid Howells * To summarize, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE allocates iso resources 1053607ca46eSDavid Howells * for the lifetime of the fd or @handle. 1054607ca46eSDavid Howells * In contrast, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE allocates iso resources 1055607ca46eSDavid Howells * for the duration of a bus generation. 1056607ca46eSDavid Howells * 1057607ca46eSDavid Howells * @channels is a host-endian bitfield with the least significant bit 1058607ca46eSDavid Howells * representing channel 0 and the most significant bit representing channel 63: 1059607ca46eSDavid Howells * 1ULL << c for each channel c that is a candidate for (de)allocation. 1060607ca46eSDavid Howells * 1061607ca46eSDavid Howells * @bandwidth is expressed in bandwidth allocation units, i.e. the time to send 1062607ca46eSDavid Howells * one quadlet of data (payload or header data) at speed S1600. 1063607ca46eSDavid Howells */ 1064607ca46eSDavid Howells struct fw_cdev_allocate_iso_resource { 1065607ca46eSDavid Howells __u64 closure; 1066607ca46eSDavid Howells __u64 channels; 1067607ca46eSDavid Howells __u32 bandwidth; 1068607ca46eSDavid Howells __u32 handle; 1069607ca46eSDavid Howells }; 1070607ca46eSDavid Howells 1071607ca46eSDavid Howells /** 1072607ca46eSDavid Howells * struct fw_cdev_send_stream_packet - send an asynchronous stream packet 1073607ca46eSDavid Howells * @length: Length of outgoing payload, in bytes 1074607ca46eSDavid Howells * @tag: Data format tag 1075607ca46eSDavid Howells * @channel: Isochronous channel to transmit to 1076607ca46eSDavid Howells * @sy: Synchronization code 1077607ca46eSDavid Howells * @closure: Passed back to userspace in the response event 1078607ca46eSDavid Howells * @data: Userspace pointer to payload 1079607ca46eSDavid Howells * @generation: The bus generation where packet is valid 1080607ca46eSDavid Howells * @speed: Speed to transmit at 1081607ca46eSDavid Howells * 1082*fc2b52cfSTakashi Sakamoto * The %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl sends an asynchronous stream packet to every device 1083*fc2b52cfSTakashi Sakamoto * which is listening to the specified channel. The kernel writes either &fw_cdev_event_response 1084*fc2b52cfSTakashi Sakamoto * event or &fw_cdev_event_response2 event which indicates success or failure of the transmission. 1085607ca46eSDavid Howells */ 1086607ca46eSDavid Howells struct fw_cdev_send_stream_packet { 1087607ca46eSDavid Howells __u32 length; 1088607ca46eSDavid Howells __u32 tag; 1089607ca46eSDavid Howells __u32 channel; 1090607ca46eSDavid Howells __u32 sy; 1091607ca46eSDavid Howells __u64 closure; 1092607ca46eSDavid Howells __u64 data; 1093607ca46eSDavid Howells __u32 generation; 1094607ca46eSDavid Howells __u32 speed; 1095607ca46eSDavid Howells }; 1096607ca46eSDavid Howells 1097607ca46eSDavid Howells /** 1098607ca46eSDavid Howells * struct fw_cdev_send_phy_packet - send a PHY packet 1099607ca46eSDavid Howells * @closure: Passed back to userspace in the PHY-packet-sent event 1100607ca46eSDavid Howells * @data: First and second quadlet of the PHY packet 1101607ca46eSDavid Howells * @generation: The bus generation where packet is valid 1102607ca46eSDavid Howells * 1103607ca46eSDavid Howells * The %FW_CDEV_IOC_SEND_PHY_PACKET ioctl sends a PHY packet to all nodes 1104607ca46eSDavid Howells * on the same card as this device. After transmission, an 1105607ca46eSDavid Howells * %FW_CDEV_EVENT_PHY_PACKET_SENT event is generated. 1106607ca46eSDavid Howells * 11079a400682SRandy Dunlap * The payload @data\[\] shall be specified in host byte order. Usually, 11089a400682SRandy Dunlap * @data\[1\] needs to be the bitwise inverse of @data\[0\]. VersaPHY packets 1109607ca46eSDavid Howells * are an exception to this rule. 1110607ca46eSDavid Howells * 1111607ca46eSDavid Howells * The ioctl is only permitted on device files which represent a local node. 1112607ca46eSDavid Howells */ 1113607ca46eSDavid Howells struct fw_cdev_send_phy_packet { 1114607ca46eSDavid Howells __u64 closure; 1115607ca46eSDavid Howells __u32 data[2]; 1116607ca46eSDavid Howells __u32 generation; 1117607ca46eSDavid Howells }; 1118607ca46eSDavid Howells 1119607ca46eSDavid Howells /** 1120607ca46eSDavid Howells * struct fw_cdev_receive_phy_packets - start reception of PHY packets 1121607ca46eSDavid Howells * @closure: Passed back to userspace in phy packet events 1122607ca46eSDavid Howells * 1123607ca46eSDavid Howells * This ioctl activates issuing of %FW_CDEV_EVENT_PHY_PACKET_RECEIVED due to 1124607ca46eSDavid Howells * incoming PHY packets from any node on the same bus as the device. 1125607ca46eSDavid Howells * 1126607ca46eSDavid Howells * The ioctl is only permitted on device files which represent a local node. 1127607ca46eSDavid Howells */ 1128607ca46eSDavid Howells struct fw_cdev_receive_phy_packets { 1129607ca46eSDavid Howells __u64 closure; 1130607ca46eSDavid Howells }; 1131607ca46eSDavid Howells 1132607ca46eSDavid Howells #define FW_CDEV_VERSION 3 /* Meaningless legacy macro; don't use it. */ 1133607ca46eSDavid Howells 1134607ca46eSDavid Howells #endif /* _LINUX_FIREWIRE_CDEV_H */ 1135