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