Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Char device interface.
0003  *
0004  * Copyright (C) 2005-2007  Kristian Hoegsberg <krh@bitplanet.net>
0005  *
0006  * Permission is hereby granted, free of charge, to any person obtaining a
0007  * copy of this software and associated documentation files (the "Software"),
0008  * to deal in the Software without restriction, including without limitation
0009  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0010  * and/or sell copies of the Software, and to permit persons to whom the
0011  * Software is furnished to do so, subject to the following conditions:
0012  *
0013  * The above copyright notice and this permission notice (including the next
0014  * paragraph) shall be included in all copies or substantial portions of the
0015  * Software.
0016  *
0017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0018  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0020  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
0021  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0022  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0023  * DEALINGS IN THE SOFTWARE.
0024  */
0025 
0026 #ifndef _LINUX_FIREWIRE_CDEV_H
0027 #define _LINUX_FIREWIRE_CDEV_H
0028 
0029 #include <linux/ioctl.h>
0030 #include <linux/types.h>
0031 #include <linux/firewire-constants.h>
0032 
0033 /* available since kernel version 2.6.22 */
0034 #define FW_CDEV_EVENT_BUS_RESET             0x00
0035 #define FW_CDEV_EVENT_RESPONSE              0x01
0036 #define FW_CDEV_EVENT_REQUEST               0x02
0037 #define FW_CDEV_EVENT_ISO_INTERRUPT         0x03
0038 
0039 /* available since kernel version 2.6.30 */
0040 #define FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED        0x04
0041 #define FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED      0x05
0042 
0043 /* available since kernel version 2.6.36 */
0044 #define FW_CDEV_EVENT_REQUEST2              0x06
0045 #define FW_CDEV_EVENT_PHY_PACKET_SENT           0x07
0046 #define FW_CDEV_EVENT_PHY_PACKET_RECEIVED       0x08
0047 #define FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL    0x09
0048 
0049 /**
0050  * struct fw_cdev_event_common - Common part of all fw_cdev_event_* types
0051  * @closure:    For arbitrary use by userspace
0052  * @type:   Discriminates the fw_cdev_event_* types
0053  *
0054  * This struct may be used to access generic members of all fw_cdev_event_*
0055  * types regardless of the specific type.
0056  *
0057  * Data passed in the @closure field for a request will be returned in the
0058  * corresponding event.  It is big enough to hold a pointer on all platforms.
0059  * The ioctl used to set @closure depends on the @type of event.
0060  */
0061 struct fw_cdev_event_common {
0062     __u64 closure;
0063     __u32 type;
0064 };
0065 
0066 /**
0067  * struct fw_cdev_event_bus_reset - Sent when a bus reset occurred
0068  * @closure:    See &fw_cdev_event_common; set by %FW_CDEV_IOC_GET_INFO ioctl
0069  * @type:   See &fw_cdev_event_common; always %FW_CDEV_EVENT_BUS_RESET
0070  * @node_id:       New node ID of this node
0071  * @local_node_id: Node ID of the local node, i.e. of the controller
0072  * @bm_node_id:    Node ID of the bus manager
0073  * @irm_node_id:   Node ID of the iso resource manager
0074  * @root_node_id:  Node ID of the root node
0075  * @generation:    New bus generation
0076  *
0077  * This event is sent when the bus the device belongs to goes through a bus
0078  * reset.  It provides information about the new bus configuration, such as
0079  * new node ID for this device, new root ID, and others.
0080  *
0081  * If @bm_node_id is 0xffff right after bus reset it can be reread by an
0082  * %FW_CDEV_IOC_GET_INFO ioctl after bus manager selection was finished.
0083  * Kernels with ABI version < 4 do not set @bm_node_id.
0084  */
0085 struct fw_cdev_event_bus_reset {
0086     __u64 closure;
0087     __u32 type;
0088     __u32 node_id;
0089     __u32 local_node_id;
0090     __u32 bm_node_id;
0091     __u32 irm_node_id;
0092     __u32 root_node_id;
0093     __u32 generation;
0094 };
0095 
0096 /**
0097  * struct fw_cdev_event_response - Sent when a response packet was received
0098  * @closure:    See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_REQUEST
0099  *      or %FW_CDEV_IOC_SEND_BROADCAST_REQUEST
0100  *      or %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl
0101  * @type:   See &fw_cdev_event_common; always %FW_CDEV_EVENT_RESPONSE
0102  * @rcode:  Response code returned by the remote node
0103  * @length: Data length, i.e. the response's payload size in bytes
0104  * @data:   Payload data, if any
0105  *
0106  * This event is sent when the stack receives a response to an outgoing request
0107  * sent by %FW_CDEV_IOC_SEND_REQUEST ioctl.  The payload data for responses
0108  * carrying data (read and lock responses) follows immediately and can be
0109  * accessed through the @data field.
0110  *
0111  * The event is also generated after conclusions of transactions that do not
0112  * involve response packets.  This includes unified write transactions,
0113  * broadcast write transactions, and transmission of asynchronous stream
0114  * packets.  @rcode indicates success or failure of such transmissions.
0115  */
0116 struct fw_cdev_event_response {
0117     __u64 closure;
0118     __u32 type;
0119     __u32 rcode;
0120     __u32 length;
0121     __u32 data[];
0122 };
0123 
0124 /**
0125  * struct fw_cdev_event_request - Old version of &fw_cdev_event_request2
0126  * @closure:    See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl
0127  * @type:   See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST
0128  * @tcode:  Transaction code of the incoming request
0129  * @offset: The offset into the 48-bit per-node address space
0130  * @handle: Reference to the kernel-side pending request
0131  * @length: Data length, i.e. the request's payload size in bytes
0132  * @data:   Incoming data, if any
0133  *
0134  * This event is sent instead of &fw_cdev_event_request2 if the kernel or
0135  * the client implements ABI version <= 3.  &fw_cdev_event_request lacks
0136  * essential information; use &fw_cdev_event_request2 instead.
0137  */
0138 struct fw_cdev_event_request {
0139     __u64 closure;
0140     __u32 type;
0141     __u32 tcode;
0142     __u64 offset;
0143     __u32 handle;
0144     __u32 length;
0145     __u32 data[];
0146 };
0147 
0148 /**
0149  * struct fw_cdev_event_request2 - Sent on incoming request to an address region
0150  * @closure:    See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl
0151  * @type:   See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST2
0152  * @tcode:  Transaction code of the incoming request
0153  * @offset: The offset into the 48-bit per-node address space
0154  * @source_node_id: Sender node ID
0155  * @destination_node_id: Destination node ID
0156  * @card:   The index of the card from which the request came
0157  * @generation: Bus generation in which the request is valid
0158  * @handle: Reference to the kernel-side pending request
0159  * @length: Data length, i.e. the request's payload size in bytes
0160  * @data:   Incoming data, if any
0161  *
0162  * This event is sent when the stack receives an incoming request to an address
0163  * region registered using the %FW_CDEV_IOC_ALLOCATE ioctl.  The request is
0164  * guaranteed to be completely contained in the specified region.  Userspace is
0165  * responsible for sending the response by %FW_CDEV_IOC_SEND_RESPONSE ioctl,
0166  * using the same @handle.
0167  *
0168  * The payload data for requests carrying data (write and lock requests)
0169  * follows immediately and can be accessed through the @data field.
0170  *
0171  * Unlike &fw_cdev_event_request, @tcode of lock requests is one of the
0172  * firewire-core specific %TCODE_LOCK_MASK_SWAP...%TCODE_LOCK_VENDOR_DEPENDENT,
0173  * i.e. encodes the extended transaction code.
0174  *
0175  * @card may differ from &fw_cdev_get_info.card because requests are received
0176  * from all cards of the Linux host.  @source_node_id, @destination_node_id, and
0177  * @generation pertain to that card.  Destination node ID and bus generation may
0178  * therefore differ from the corresponding fields of the last
0179  * &fw_cdev_event_bus_reset.
0180  *
0181  * @destination_node_id may also differ from the current node ID because of a
0182  * non-local bus ID part or in case of a broadcast write request.  Note, a
0183  * client must call an %FW_CDEV_IOC_SEND_RESPONSE ioctl even in case of a
0184  * broadcast write request; the kernel will then release the kernel-side pending
0185  * request but will not actually send a response packet.
0186  *
0187  * In case of a write request to FCP_REQUEST or FCP_RESPONSE, the kernel already
0188  * sent a write response immediately after the request was received; in this
0189  * case the client must still call an %FW_CDEV_IOC_SEND_RESPONSE ioctl to
0190  * release the kernel-side pending request, though another response won't be
0191  * sent.
0192  *
0193  * If the client subsequently needs to initiate requests to the sender node of
0194  * an &fw_cdev_event_request2, it needs to use a device file with matching
0195  * card index, node ID, and generation for outbound requests.
0196  */
0197 struct fw_cdev_event_request2 {
0198     __u64 closure;
0199     __u32 type;
0200     __u32 tcode;
0201     __u64 offset;
0202     __u32 source_node_id;
0203     __u32 destination_node_id;
0204     __u32 card;
0205     __u32 generation;
0206     __u32 handle;
0207     __u32 length;
0208     __u32 data[];
0209 };
0210 
0211 /**
0212  * struct fw_cdev_event_iso_interrupt - Sent when an iso packet was completed
0213  * @closure:    See &fw_cdev_event_common;
0214  *      set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl
0215  * @type:   See &fw_cdev_event_common; always %FW_CDEV_EVENT_ISO_INTERRUPT
0216  * @cycle:  Cycle counter of the last completed packet
0217  * @header_length: Total length of following headers, in bytes
0218  * @header: Stripped headers, if any
0219  *
0220  * This event is sent when the controller has completed an &fw_cdev_iso_packet
0221  * with the %FW_CDEV_ISO_INTERRUPT bit set, when explicitly requested with
0222  * %FW_CDEV_IOC_FLUSH_ISO, or when there have been so many completed packets
0223  * without the interrupt bit set that the kernel's internal buffer for @header
0224  * is about to overflow.  (In the last case, ABI versions < 5 drop header data
0225  * up to the next interrupt packet.)
0226  *
0227  * Isochronous transmit events (context type %FW_CDEV_ISO_CONTEXT_TRANSMIT):
0228  *
0229  * In version 3 and some implementations of version 2 of the ABI, &header_length
0230  * is a multiple of 4 and &header contains timestamps of all packets up until
0231  * the interrupt packet.  The format of the timestamps is as described below for
0232  * isochronous reception.  In version 1 of the ABI, &header_length was 0.
0233  *
0234  * Isochronous receive events (context type %FW_CDEV_ISO_CONTEXT_RECEIVE):
0235  *
0236  * The headers stripped of all packets up until and including the interrupt
0237  * packet are returned in the @header field.  The amount of header data per
0238  * packet is as specified at iso context creation by
0239  * &fw_cdev_create_iso_context.header_size.
0240  *
0241  * Hence, _interrupt.header_length / _context.header_size is the number of
0242  * packets received in this interrupt event.  The client can now iterate
0243  * through the mmap()'ed DMA buffer according to this number of packets and
0244  * to the buffer sizes as the client specified in &fw_cdev_queue_iso.
0245  *
0246  * Since version 2 of this ABI, the portion for each packet in _interrupt.header
0247  * consists of the 1394 isochronous packet header, followed by a timestamp
0248  * quadlet if &fw_cdev_create_iso_context.header_size > 4, followed by quadlets
0249  * from the packet payload if &fw_cdev_create_iso_context.header_size > 8.
0250  *
0251  * Format of 1394 iso packet header:  16 bits data_length, 2 bits tag, 6 bits
0252  * channel, 4 bits tcode, 4 bits sy, in big endian byte order.
0253  * data_length is the actual received size of the packet without the four
0254  * 1394 iso packet header bytes.
0255  *
0256  * Format of timestamp:  16 bits invalid, 3 bits cycleSeconds, 13 bits
0257  * cycleCount, in big endian byte order.
0258  *
0259  * In version 1 of the ABI, no timestamp quadlet was inserted; instead, payload
0260  * data followed directly after the 1394 is header if header_size > 4.
0261  * Behaviour of ver. 1 of this ABI is no longer available since ABI ver. 2.
0262  */
0263 struct fw_cdev_event_iso_interrupt {
0264     __u64 closure;
0265     __u32 type;
0266     __u32 cycle;
0267     __u32 header_length;
0268     __u32 header[];
0269 };
0270 
0271 /**
0272  * struct fw_cdev_event_iso_interrupt_mc - An iso buffer chunk was completed
0273  * @closure:    See &fw_cdev_event_common;
0274  *      set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl
0275  * @type:   %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL
0276  * @completed:  Offset into the receive buffer; data before this offset is valid
0277  *
0278  * This event is sent in multichannel contexts (context type
0279  * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL) for &fw_cdev_iso_packet buffer
0280  * chunks that have been completely filled and that have the
0281  * %FW_CDEV_ISO_INTERRUPT bit set, or when explicitly requested with
0282  * %FW_CDEV_IOC_FLUSH_ISO.
0283  *
0284  * The buffer is continuously filled with the following data, per packet:
0285  *  - the 1394 iso packet header as described at &fw_cdev_event_iso_interrupt,
0286  *    but in little endian byte order,
0287  *  - packet payload (as many bytes as specified in the data_length field of
0288  *    the 1394 iso packet header) in big endian byte order,
0289  *  - 0...3 padding bytes as needed to align the following trailer quadlet,
0290  *  - trailer quadlet, containing the reception timestamp as described at
0291  *    &fw_cdev_event_iso_interrupt, but in little endian byte order.
0292  *
0293  * Hence the per-packet size is data_length (rounded up to a multiple of 4) + 8.
0294  * When processing the data, stop before a packet that would cross the
0295  * @completed offset.
0296  *
0297  * A packet near the end of a buffer chunk will typically spill over into the
0298  * next queued buffer chunk.  It is the responsibility of the client to check
0299  * for this condition, assemble a broken-up packet from its parts, and not to
0300  * re-queue any buffer chunks in which as yet unread packet parts reside.
0301  */
0302 struct fw_cdev_event_iso_interrupt_mc {
0303     __u64 closure;
0304     __u32 type;
0305     __u32 completed;
0306 };
0307 
0308 /**
0309  * struct fw_cdev_event_iso_resource - Iso resources were allocated or freed
0310  * @closure:    See &fw_cdev_event_common;
0311  *      set by``FW_CDEV_IOC_(DE)ALLOCATE_ISO_RESOURCE(_ONCE)`` ioctl
0312  * @type:   %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or
0313  *      %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED
0314  * @handle: Reference by which an allocated resource can be deallocated
0315  * @channel:    Isochronous channel which was (de)allocated, if any
0316  * @bandwidth:  Bandwidth allocation units which were (de)allocated, if any
0317  *
0318  * An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event is sent after an isochronous
0319  * resource was allocated at the IRM.  The client has to check @channel and
0320  * @bandwidth for whether the allocation actually succeeded.
0321  *
0322  * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event is sent after an isochronous
0323  * resource was deallocated at the IRM.  It is also sent when automatic
0324  * reallocation after a bus reset failed.
0325  *
0326  * @channel is <0 if no channel was (de)allocated or if reallocation failed.
0327  * @bandwidth is 0 if no bandwidth was (de)allocated or if reallocation failed.
0328  */
0329 struct fw_cdev_event_iso_resource {
0330     __u64 closure;
0331     __u32 type;
0332     __u32 handle;
0333     __s32 channel;
0334     __s32 bandwidth;
0335 };
0336 
0337 /**
0338  * struct fw_cdev_event_phy_packet - A PHY packet was transmitted or received
0339  * @closure:    See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_PHY_PACKET
0340  *      or %FW_CDEV_IOC_RECEIVE_PHY_PACKETS ioctl
0341  * @type:   %FW_CDEV_EVENT_PHY_PACKET_SENT or %..._RECEIVED
0342  * @rcode:  %RCODE_..., indicates success or failure of transmission
0343  * @length: Data length in bytes
0344  * @data:   Incoming data
0345  *
0346  * If @type is %FW_CDEV_EVENT_PHY_PACKET_SENT, @length is 0 and @data empty,
0347  * except in case of a ping packet:  Then, @length is 4, and @data[0] is the
0348  * ping time in 49.152MHz clocks if @rcode is %RCODE_COMPLETE.
0349  *
0350  * If @type is %FW_CDEV_EVENT_PHY_PACKET_RECEIVED, @length is 8 and @data
0351  * consists of the two PHY packet quadlets, in host byte order.
0352  */
0353 struct fw_cdev_event_phy_packet {
0354     __u64 closure;
0355     __u32 type;
0356     __u32 rcode;
0357     __u32 length;
0358     __u32 data[];
0359 };
0360 
0361 /**
0362  * union fw_cdev_event - Convenience union of fw_cdev_event_* types
0363  * @common:     Valid for all types
0364  * @bus_reset:      Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET
0365  * @response:       Valid if @common.type == %FW_CDEV_EVENT_RESPONSE
0366  * @request:        Valid if @common.type == %FW_CDEV_EVENT_REQUEST
0367  * @request2:       Valid if @common.type == %FW_CDEV_EVENT_REQUEST2
0368  * @iso_interrupt:  Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT
0369  * @iso_interrupt_mc:   Valid if @common.type ==
0370  *              %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL
0371  * @iso_resource:   Valid if @common.type ==
0372  *              %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or
0373  *              %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED
0374  * @phy_packet:     Valid if @common.type ==
0375  *              %FW_CDEV_EVENT_PHY_PACKET_SENT or
0376  *              %FW_CDEV_EVENT_PHY_PACKET_RECEIVED
0377  *
0378  * Convenience union for userspace use.  Events could be read(2) into an
0379  * appropriately aligned char buffer and then cast to this union for further
0380  * processing.  Note that for a request, response or iso_interrupt event,
0381  * the data[] or header[] may make the size of the full event larger than
0382  * sizeof(union fw_cdev_event).  Also note that if you attempt to read(2)
0383  * an event into a buffer that is not large enough for it, the data that does
0384  * not fit will be discarded so that the next read(2) will return a new event.
0385  */
0386 union fw_cdev_event {
0387     struct fw_cdev_event_common     common;
0388     struct fw_cdev_event_bus_reset      bus_reset;
0389     struct fw_cdev_event_response       response;
0390     struct fw_cdev_event_request        request;
0391     struct fw_cdev_event_request2       request2;       /* added in 2.6.36 */
0392     struct fw_cdev_event_iso_interrupt  iso_interrupt;
0393     struct fw_cdev_event_iso_interrupt_mc   iso_interrupt_mc;   /* added in 2.6.36 */
0394     struct fw_cdev_event_iso_resource   iso_resource;       /* added in 2.6.30 */
0395     struct fw_cdev_event_phy_packet     phy_packet;     /* added in 2.6.36 */
0396 };
0397 
0398 /* available since kernel version 2.6.22 */
0399 #define FW_CDEV_IOC_GET_INFO           _IOWR('#', 0x00, struct fw_cdev_get_info)
0400 #define FW_CDEV_IOC_SEND_REQUEST        _IOW('#', 0x01, struct fw_cdev_send_request)
0401 #define FW_CDEV_IOC_ALLOCATE           _IOWR('#', 0x02, struct fw_cdev_allocate)
0402 #define FW_CDEV_IOC_DEALLOCATE          _IOW('#', 0x03, struct fw_cdev_deallocate)
0403 #define FW_CDEV_IOC_SEND_RESPONSE       _IOW('#', 0x04, struct fw_cdev_send_response)
0404 #define FW_CDEV_IOC_INITIATE_BUS_RESET  _IOW('#', 0x05, struct fw_cdev_initiate_bus_reset)
0405 #define FW_CDEV_IOC_ADD_DESCRIPTOR     _IOWR('#', 0x06, struct fw_cdev_add_descriptor)
0406 #define FW_CDEV_IOC_REMOVE_DESCRIPTOR   _IOW('#', 0x07, struct fw_cdev_remove_descriptor)
0407 #define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOWR('#', 0x08, struct fw_cdev_create_iso_context)
0408 #define FW_CDEV_IOC_QUEUE_ISO          _IOWR('#', 0x09, struct fw_cdev_queue_iso)
0409 #define FW_CDEV_IOC_START_ISO           _IOW('#', 0x0a, struct fw_cdev_start_iso)
0410 #define FW_CDEV_IOC_STOP_ISO            _IOW('#', 0x0b, struct fw_cdev_stop_iso)
0411 
0412 /* available since kernel version 2.6.24 */
0413 #define FW_CDEV_IOC_GET_CYCLE_TIMER     _IOR('#', 0x0c, struct fw_cdev_get_cycle_timer)
0414 
0415 /* available since kernel version 2.6.30 */
0416 #define FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE       _IOWR('#', 0x0d, struct fw_cdev_allocate_iso_resource)
0417 #define FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE      _IOW('#', 0x0e, struct fw_cdev_deallocate)
0418 #define FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE   _IOW('#', 0x0f, struct fw_cdev_allocate_iso_resource)
0419 #define FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE _IOW('#', 0x10, struct fw_cdev_allocate_iso_resource)
0420 #define FW_CDEV_IOC_GET_SPEED                     _IO('#', 0x11) /* returns speed code */
0421 #define FW_CDEV_IOC_SEND_BROADCAST_REQUEST       _IOW('#', 0x12, struct fw_cdev_send_request)
0422 #define FW_CDEV_IOC_SEND_STREAM_PACKET           _IOW('#', 0x13, struct fw_cdev_send_stream_packet)
0423 
0424 /* available since kernel version 2.6.34 */
0425 #define FW_CDEV_IOC_GET_CYCLE_TIMER2   _IOWR('#', 0x14, struct fw_cdev_get_cycle_timer2)
0426 
0427 /* available since kernel version 2.6.36 */
0428 #define FW_CDEV_IOC_SEND_PHY_PACKET    _IOWR('#', 0x15, struct fw_cdev_send_phy_packet)
0429 #define FW_CDEV_IOC_RECEIVE_PHY_PACKETS _IOW('#', 0x16, struct fw_cdev_receive_phy_packets)
0430 #define FW_CDEV_IOC_SET_ISO_CHANNELS    _IOW('#', 0x17, struct fw_cdev_set_iso_channels)
0431 
0432 /* available since kernel version 3.4 */
0433 #define FW_CDEV_IOC_FLUSH_ISO           _IOW('#', 0x18, struct fw_cdev_flush_iso)
0434 
0435 /*
0436  * ABI version history
0437  *  1  (2.6.22)  - initial version
0438  *     (2.6.24)  - added %FW_CDEV_IOC_GET_CYCLE_TIMER
0439  *  2  (2.6.30)  - changed &fw_cdev_event_iso_interrupt.header if
0440  *                 &fw_cdev_create_iso_context.header_size is 8 or more
0441  *               - added %FW_CDEV_IOC_*_ISO_RESOURCE*,
0442  *                 %FW_CDEV_IOC_GET_SPEED, %FW_CDEV_IOC_SEND_BROADCAST_REQUEST,
0443  *                 %FW_CDEV_IOC_SEND_STREAM_PACKET
0444  *     (2.6.32)  - added time stamp to xmit &fw_cdev_event_iso_interrupt
0445  *     (2.6.33)  - IR has always packet-per-buffer semantics now, not one of
0446  *                 dual-buffer or packet-per-buffer depending on hardware
0447  *               - shared use and auto-response for FCP registers
0448  *  3  (2.6.34)  - made &fw_cdev_get_cycle_timer reliable
0449  *               - added %FW_CDEV_IOC_GET_CYCLE_TIMER2
0450  *  4  (2.6.36)  - added %FW_CDEV_EVENT_REQUEST2, %FW_CDEV_EVENT_PHY_PACKET_*,
0451  *                 and &fw_cdev_allocate.region_end
0452  *               - implemented &fw_cdev_event_bus_reset.bm_node_id
0453  *               - added %FW_CDEV_IOC_SEND_PHY_PACKET, _RECEIVE_PHY_PACKETS
0454  *               - added %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL,
0455  *                 %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL, and
0456  *                 %FW_CDEV_IOC_SET_ISO_CHANNELS
0457  *  5  (3.4)     - send %FW_CDEV_EVENT_ISO_INTERRUPT events when needed to
0458  *                 avoid dropping data
0459  *               - added %FW_CDEV_IOC_FLUSH_ISO
0460  */
0461 
0462 /**
0463  * struct fw_cdev_get_info - General purpose information ioctl
0464  * @version:    The version field is just a running serial number.  Both an
0465  *      input parameter (ABI version implemented by the client) and
0466  *      output parameter (ABI version implemented by the kernel).
0467  *      A client shall fill in the ABI @version for which the client
0468  *      was implemented.  This is necessary for forward compatibility.
0469  * @rom_length: If @rom is non-zero, up to @rom_length bytes of Configuration
0470  *      ROM will be copied into that user space address.  In either
0471  *      case, @rom_length is updated with the actual length of the
0472  *      Configuration ROM.
0473  * @rom:    If non-zero, address of a buffer to be filled by a copy of the
0474  *      device's Configuration ROM
0475  * @bus_reset:  If non-zero, address of a buffer to be filled by a
0476  *      &struct fw_cdev_event_bus_reset with the current state
0477  *      of the bus.  This does not cause a bus reset to happen.
0478  * @bus_reset_closure: Value of &closure in this and subsequent bus reset events
0479  * @card:   The index of the card this device belongs to
0480  *
0481  * The %FW_CDEV_IOC_GET_INFO ioctl is usually the very first one which a client
0482  * performs right after it opened a /dev/fw* file.
0483  *
0484  * As a side effect, reception of %FW_CDEV_EVENT_BUS_RESET events to be read(2)
0485  * is started by this ioctl.
0486  */
0487 struct fw_cdev_get_info {
0488     __u32 version;
0489     __u32 rom_length;
0490     __u64 rom;
0491     __u64 bus_reset;
0492     __u64 bus_reset_closure;
0493     __u32 card;
0494 };
0495 
0496 /**
0497  * struct fw_cdev_send_request - Send an asynchronous request packet
0498  * @tcode:  Transaction code of the request
0499  * @length: Length of outgoing payload, in bytes
0500  * @offset: 48-bit offset at destination node
0501  * @closure:    Passed back to userspace in the response event
0502  * @data:   Userspace pointer to payload
0503  * @generation: The bus generation where packet is valid
0504  *
0505  * Send a request to the device.  This ioctl implements all outgoing requests.
0506  * Both quadlet and block request specify the payload as a pointer to the data
0507  * in the @data field.  Once the transaction completes, the kernel writes an
0508  * &fw_cdev_event_response event back.  The @closure field is passed back to
0509  * user space in the response event.
0510  */
0511 struct fw_cdev_send_request {
0512     __u32 tcode;
0513     __u32 length;
0514     __u64 offset;
0515     __u64 closure;
0516     __u64 data;
0517     __u32 generation;
0518 };
0519 
0520 /**
0521  * struct fw_cdev_send_response - Send an asynchronous response packet
0522  * @rcode:  Response code as determined by the userspace handler
0523  * @length: Length of outgoing payload, in bytes
0524  * @data:   Userspace pointer to payload
0525  * @handle: The handle from the &fw_cdev_event_request
0526  *
0527  * Send a response to an incoming request.  By setting up an address range using
0528  * the %FW_CDEV_IOC_ALLOCATE ioctl, userspace can listen for incoming requests.  An
0529  * incoming request will generate an %FW_CDEV_EVENT_REQUEST, and userspace must
0530  * send a reply using this ioctl.  The event has a handle to the kernel-side
0531  * pending transaction, which should be used with this ioctl.
0532  */
0533 struct fw_cdev_send_response {
0534     __u32 rcode;
0535     __u32 length;
0536     __u64 data;
0537     __u32 handle;
0538 };
0539 
0540 /**
0541  * struct fw_cdev_allocate - Allocate a CSR in an address range
0542  * @offset: Start offset of the address range
0543  * @closure:    To be passed back to userspace in request events
0544  * @length: Length of the CSR, in bytes
0545  * @handle: Handle to the allocation, written by the kernel
0546  * @region_end: First address above the address range (added in ABI v4, 2.6.36)
0547  *
0548  * Allocate an address range in the 48-bit address space on the local node
0549  * (the controller).  This allows userspace to listen for requests with an
0550  * offset within that address range.  Every time when the kernel receives a
0551  * request within the range, an &fw_cdev_event_request2 event will be emitted.
0552  * (If the kernel or the client implements ABI version <= 3, an
0553  * &fw_cdev_event_request will be generated instead.)
0554  *
0555  * The @closure field is passed back to userspace in these request events.
0556  * The @handle field is an out parameter, returning a handle to the allocated
0557  * range to be used for later deallocation of the range.
0558  *
0559  * The address range is allocated on all local nodes.  The address allocation
0560  * is exclusive except for the FCP command and response registers.  If an
0561  * exclusive address region is already in use, the ioctl fails with errno set
0562  * to %EBUSY.
0563  *
0564  * If kernel and client implement ABI version >= 4, the kernel looks up a free
0565  * spot of size @length inside [@offset..@region_end) and, if found, writes
0566  * the start address of the new CSR back in @offset.  I.e. @offset is an
0567  * in and out parameter.  If this automatic placement of a CSR in a bigger
0568  * address range is not desired, the client simply needs to set @region_end
0569  * = @offset + @length.
0570  *
0571  * If the kernel or the client implements ABI version <= 3, @region_end is
0572  * ignored and effectively assumed to be @offset + @length.
0573  *
0574  * @region_end is only present in a kernel header >= 2.6.36.  If necessary,
0575  * this can for example be tested by #ifdef FW_CDEV_EVENT_REQUEST2.
0576  */
0577 struct fw_cdev_allocate {
0578     __u64 offset;
0579     __u64 closure;
0580     __u32 length;
0581     __u32 handle;
0582     __u64 region_end;   /* available since kernel version 2.6.36 */
0583 };
0584 
0585 /**
0586  * struct fw_cdev_deallocate - Free a CSR address range or isochronous resource
0587  * @handle: Handle to the address range or iso resource, as returned by the
0588  *      kernel when the range or resource was allocated
0589  */
0590 struct fw_cdev_deallocate {
0591     __u32 handle;
0592 };
0593 
0594 #define FW_CDEV_LONG_RESET  0
0595 #define FW_CDEV_SHORT_RESET 1
0596 
0597 /**
0598  * struct fw_cdev_initiate_bus_reset - Initiate a bus reset
0599  * @type:   %FW_CDEV_SHORT_RESET or %FW_CDEV_LONG_RESET
0600  *
0601  * Initiate a bus reset for the bus this device is on.  The bus reset can be
0602  * either the original (long) bus reset or the arbitrated (short) bus reset
0603  * introduced in 1394a-2000.
0604  *
0605  * The ioctl returns immediately.  A subsequent &fw_cdev_event_bus_reset
0606  * indicates when the reset actually happened.  Since ABI v4, this may be
0607  * considerably later than the ioctl because the kernel ensures a grace period
0608  * between subsequent bus resets as per IEEE 1394 bus management specification.
0609  */
0610 struct fw_cdev_initiate_bus_reset {
0611     __u32 type;
0612 };
0613 
0614 /**
0615  * struct fw_cdev_add_descriptor - Add contents to the local node's config ROM
0616  * @immediate:  If non-zero, immediate key to insert before pointer
0617  * @key:    Upper 8 bits of root directory pointer
0618  * @data:   Userspace pointer to contents of descriptor block
0619  * @length: Length of descriptor block data, in quadlets
0620  * @handle: Handle to the descriptor, written by the kernel
0621  *
0622  * Add a descriptor block and optionally a preceding immediate key to the local
0623  * node's Configuration ROM.
0624  *
0625  * The @key field specifies the upper 8 bits of the descriptor root directory
0626  * pointer and the @data and @length fields specify the contents. The @key
0627  * should be of the form 0xXX000000. The offset part of the root directory entry
0628  * will be filled in by the kernel.
0629  *
0630  * If not 0, the @immediate field specifies an immediate key which will be
0631  * inserted before the root directory pointer.
0632  *
0633  * @immediate, @key, and @data array elements are CPU-endian quadlets.
0634  *
0635  * If successful, the kernel adds the descriptor and writes back a @handle to
0636  * the kernel-side object to be used for later removal of the descriptor block
0637  * and immediate key.  The kernel will also generate a bus reset to signal the
0638  * change of the Configuration ROM to other nodes.
0639  *
0640  * This ioctl affects the Configuration ROMs of all local nodes.
0641  * The ioctl only succeeds on device files which represent a local node.
0642  */
0643 struct fw_cdev_add_descriptor {
0644     __u32 immediate;
0645     __u32 key;
0646     __u64 data;
0647     __u32 length;
0648     __u32 handle;
0649 };
0650 
0651 /**
0652  * struct fw_cdev_remove_descriptor - Remove contents from the Configuration ROM
0653  * @handle: Handle to the descriptor, as returned by the kernel when the
0654  *      descriptor was added
0655  *
0656  * Remove a descriptor block and accompanying immediate key from the local
0657  * nodes' Configuration ROMs.  The kernel will also generate a bus reset to
0658  * signal the change of the Configuration ROM to other nodes.
0659  */
0660 struct fw_cdev_remove_descriptor {
0661     __u32 handle;
0662 };
0663 
0664 #define FW_CDEV_ISO_CONTEXT_TRANSMIT            0
0665 #define FW_CDEV_ISO_CONTEXT_RECEIVE         1
0666 #define FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL    2 /* added in 2.6.36 */
0667 
0668 /**
0669  * struct fw_cdev_create_iso_context - Create a context for isochronous I/O
0670  * @type:   %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE or
0671  *      %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL
0672  * @header_size: Header size to strip in single-channel reception
0673  * @channel:    Channel to bind to in single-channel reception or transmission
0674  * @speed:  Transmission speed
0675  * @closure:    To be returned in &fw_cdev_event_iso_interrupt or
0676  *      &fw_cdev_event_iso_interrupt_multichannel
0677  * @handle: Handle to context, written back by kernel
0678  *
0679  * Prior to sending or receiving isochronous I/O, a context must be created.
0680  * The context records information about the transmit or receive configuration
0681  * and typically maps to an underlying hardware resource.  A context is set up
0682  * for either sending or receiving.  It is bound to a specific isochronous
0683  * @channel.
0684  *
0685  * In case of multichannel reception, @header_size and @channel are ignored
0686  * and the channels are selected by %FW_CDEV_IOC_SET_ISO_CHANNELS.
0687  *
0688  * For %FW_CDEV_ISO_CONTEXT_RECEIVE contexts, @header_size must be at least 4
0689  * and must be a multiple of 4.  It is ignored in other context types.
0690  *
0691  * @speed is ignored in receive context types.
0692  *
0693  * If a context was successfully created, the kernel writes back a handle to the
0694  * context, which must be passed in for subsequent operations on that context.
0695  *
0696  * Limitations:
0697  * No more than one iso context can be created per fd.
0698  * The total number of contexts that all userspace and kernelspace drivers can
0699  * create on a card at a time is a hardware limit, typically 4 or 8 contexts per
0700  * direction, and of them at most one multichannel receive context.
0701  */
0702 struct fw_cdev_create_iso_context {
0703     __u32 type;
0704     __u32 header_size;
0705     __u32 channel;
0706     __u32 speed;
0707     __u64 closure;
0708     __u32 handle;
0709 };
0710 
0711 /**
0712  * struct fw_cdev_set_iso_channels - Select channels in multichannel reception
0713  * @channels:   Bitmask of channels to listen to
0714  * @handle: Handle of the mutichannel receive context
0715  *
0716  * @channels is the bitwise or of 1ULL << n for each channel n to listen to.
0717  *
0718  * The ioctl fails with errno %EBUSY if there is already another receive context
0719  * on a channel in @channels.  In that case, the bitmask of all unoccupied
0720  * channels is returned in @channels.
0721  */
0722 struct fw_cdev_set_iso_channels {
0723     __u64 channels;
0724     __u32 handle;
0725 };
0726 
0727 #define FW_CDEV_ISO_PAYLOAD_LENGTH(v)   (v)
0728 #define FW_CDEV_ISO_INTERRUPT       (1 << 16)
0729 #define FW_CDEV_ISO_SKIP        (1 << 17)
0730 #define FW_CDEV_ISO_SYNC        (1 << 17)
0731 #define FW_CDEV_ISO_TAG(v)      ((v) << 18)
0732 #define FW_CDEV_ISO_SY(v)       ((v) << 20)
0733 #define FW_CDEV_ISO_HEADER_LENGTH(v)    ((v) << 24)
0734 
0735 /**
0736  * struct fw_cdev_iso_packet - Isochronous packet
0737  * @control:    Contains the header length (8 uppermost bits),
0738  *      the sy field (4 bits), the tag field (2 bits), a sync flag
0739  *      or a skip flag (1 bit), an interrupt flag (1 bit), and the
0740  *      payload length (16 lowermost bits)
0741  * @header: Header and payload in case of a transmit context.
0742  *
0743  * &struct fw_cdev_iso_packet is used to describe isochronous packet queues.
0744  * Use the FW_CDEV_ISO_* macros to fill in @control.
0745  * The @header array is empty in case of receive contexts.
0746  *
0747  * Context type %FW_CDEV_ISO_CONTEXT_TRANSMIT:
0748  *
0749  * @control.HEADER_LENGTH must be a multiple of 4.  It specifies the numbers of
0750  * bytes in @header that will be prepended to the packet's payload.  These bytes
0751  * are copied into the kernel and will not be accessed after the ioctl has
0752  * returned.
0753  *
0754  * The @control.SY and TAG fields are copied to the iso packet header.  These
0755  * fields are specified by IEEE 1394a and IEC 61883-1.
0756  *
0757  * The @control.SKIP flag specifies that no packet is to be sent in a frame.
0758  * When using this, all other fields except @control.INTERRUPT must be zero.
0759  *
0760  * When a packet with the @control.INTERRUPT flag set has been completed, an
0761  * &fw_cdev_event_iso_interrupt event will be sent.
0762  *
0763  * Context type %FW_CDEV_ISO_CONTEXT_RECEIVE:
0764  *
0765  * @control.HEADER_LENGTH must be a multiple of the context's header_size.
0766  * If the HEADER_LENGTH is larger than the context's header_size, multiple
0767  * packets are queued for this entry.
0768  *
0769  * The @control.SY and TAG fields are ignored.
0770  *
0771  * If the @control.SYNC flag is set, the context drops all packets until a
0772  * packet with a sy field is received which matches &fw_cdev_start_iso.sync.
0773  *
0774  * @control.PAYLOAD_LENGTH defines how many payload bytes can be received for
0775  * one packet (in addition to payload quadlets that have been defined as headers
0776  * and are stripped and returned in the &fw_cdev_event_iso_interrupt structure).
0777  * If more bytes are received, the additional bytes are dropped.  If less bytes
0778  * are received, the remaining bytes in this part of the payload buffer will not
0779  * be written to, not even by the next packet.  I.e., packets received in
0780  * consecutive frames will not necessarily be consecutive in memory.  If an
0781  * entry has queued multiple packets, the PAYLOAD_LENGTH is divided equally
0782  * among them.
0783  *
0784  * When a packet with the @control.INTERRUPT flag set has been completed, an
0785  * &fw_cdev_event_iso_interrupt event will be sent.  An entry that has queued
0786  * multiple receive packets is completed when its last packet is completed.
0787  *
0788  * Context type %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL:
0789  *
0790  * Here, &fw_cdev_iso_packet would be more aptly named _iso_buffer_chunk since
0791  * it specifies a chunk of the mmap()'ed buffer, while the number and alignment
0792  * of packets to be placed into the buffer chunk is not known beforehand.
0793  *
0794  * @control.PAYLOAD_LENGTH is the size of the buffer chunk and specifies room
0795  * for header, payload, padding, and trailer bytes of one or more packets.
0796  * It must be a multiple of 4.
0797  *
0798  * @control.HEADER_LENGTH, TAG and SY are ignored.  SYNC is treated as described
0799  * for single-channel reception.
0800  *
0801  * When a buffer chunk with the @control.INTERRUPT flag set has been filled
0802  * entirely, an &fw_cdev_event_iso_interrupt_mc event will be sent.
0803  */
0804 struct fw_cdev_iso_packet {
0805     __u32 control;
0806     __u32 header[];
0807 };
0808 
0809 /**
0810  * struct fw_cdev_queue_iso - Queue isochronous packets for I/O
0811  * @packets:    Userspace pointer to an array of &fw_cdev_iso_packet
0812  * @data:   Pointer into mmap()'ed payload buffer
0813  * @size:   Size of the @packets array, in bytes
0814  * @handle: Isochronous context handle
0815  *
0816  * Queue a number of isochronous packets for reception or transmission.
0817  * This ioctl takes a pointer to an array of &fw_cdev_iso_packet structs,
0818  * which describe how to transmit from or receive into a contiguous region
0819  * of a mmap()'ed payload buffer.  As part of transmit packet descriptors,
0820  * a series of headers can be supplied, which will be prepended to the
0821  * payload during DMA.
0822  *
0823  * The kernel may or may not queue all packets, but will write back updated
0824  * values of the @packets, @data and @size fields, so the ioctl can be
0825  * resubmitted easily.
0826  *
0827  * In case of a multichannel receive context, @data must be quadlet-aligned
0828  * relative to the buffer start.
0829  */
0830 struct fw_cdev_queue_iso {
0831     __u64 packets;
0832     __u64 data;
0833     __u32 size;
0834     __u32 handle;
0835 };
0836 
0837 #define FW_CDEV_ISO_CONTEXT_MATCH_TAG0       1
0838 #define FW_CDEV_ISO_CONTEXT_MATCH_TAG1       2
0839 #define FW_CDEV_ISO_CONTEXT_MATCH_TAG2       4
0840 #define FW_CDEV_ISO_CONTEXT_MATCH_TAG3       8
0841 #define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS  15
0842 
0843 /**
0844  * struct fw_cdev_start_iso - Start an isochronous transmission or reception
0845  * @cycle:  Cycle in which to start I/O.  If @cycle is greater than or
0846  *      equal to 0, the I/O will start on that cycle.
0847  * @sync:   Determines the value to wait for receive packets that have
0848  *      the %FW_CDEV_ISO_SYNC bit set
0849  * @tags:   Tag filter bit mask.  Only valid for isochronous reception.
0850  *      Determines the tag values for which packets will be accepted.
0851  *      Use FW_CDEV_ISO_CONTEXT_MATCH_* macros to set @tags.
0852  * @handle: Isochronous context handle within which to transmit or receive
0853  */
0854 struct fw_cdev_start_iso {
0855     __s32 cycle;
0856     __u32 sync;
0857     __u32 tags;
0858     __u32 handle;
0859 };
0860 
0861 /**
0862  * struct fw_cdev_stop_iso - Stop an isochronous transmission or reception
0863  * @handle: Handle of isochronous context to stop
0864  */
0865 struct fw_cdev_stop_iso {
0866     __u32 handle;
0867 };
0868 
0869 /**
0870  * struct fw_cdev_flush_iso - flush completed iso packets
0871  * @handle: handle of isochronous context to flush
0872  *
0873  * For %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE contexts,
0874  * report any completed packets.
0875  *
0876  * For %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL contexts, report the current
0877  * offset in the receive buffer, if it has changed; this is typically in the
0878  * middle of some buffer chunk.
0879  *
0880  * Any %FW_CDEV_EVENT_ISO_INTERRUPT or %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL
0881  * events generated by this ioctl are sent synchronously, i.e., are available
0882  * for reading from the file descriptor when this ioctl returns.
0883  */
0884 struct fw_cdev_flush_iso {
0885     __u32 handle;
0886 };
0887 
0888 /**
0889  * struct fw_cdev_get_cycle_timer - read cycle timer register
0890  * @local_time:   system time, in microseconds since the Epoch
0891  * @cycle_timer:  Cycle Time register contents
0892  *
0893  * Same as %FW_CDEV_IOC_GET_CYCLE_TIMER2, but fixed to use %CLOCK_REALTIME
0894  * and only with microseconds resolution.
0895  *
0896  * In version 1 and 2 of the ABI, this ioctl returned unreliable (non-
0897  * monotonic) @cycle_timer values on certain controllers.
0898  */
0899 struct fw_cdev_get_cycle_timer {
0900     __u64 local_time;
0901     __u32 cycle_timer;
0902 };
0903 
0904 /**
0905  * struct fw_cdev_get_cycle_timer2 - read cycle timer register
0906  * @tv_sec:       system time, seconds
0907  * @tv_nsec:      system time, sub-seconds part in nanoseconds
0908  * @clk_id:       input parameter, clock from which to get the system time
0909  * @cycle_timer:  Cycle Time register contents
0910  *
0911  * The %FW_CDEV_IOC_GET_CYCLE_TIMER2 ioctl reads the isochronous cycle timer
0912  * and also the system clock.  This allows to correlate reception time of
0913  * isochronous packets with system time.
0914  *
0915  * @clk_id lets you choose a clock like with POSIX' clock_gettime function.
0916  * Supported @clk_id values are POSIX' %CLOCK_REALTIME and %CLOCK_MONOTONIC
0917  * and Linux' %CLOCK_MONOTONIC_RAW.
0918  *
0919  * @cycle_timer consists of 7 bits cycleSeconds, 13 bits cycleCount, and
0920  * 12 bits cycleOffset, in host byte order.  Cf. the Cycle Time register
0921  * per IEEE 1394 or Isochronous Cycle Timer register per OHCI-1394.
0922  */
0923 struct fw_cdev_get_cycle_timer2 {
0924     __s64 tv_sec;
0925     __s32 tv_nsec;
0926     __s32 clk_id;
0927     __u32 cycle_timer;
0928 };
0929 
0930 /**
0931  * struct fw_cdev_allocate_iso_resource - (De)allocate a channel or bandwidth
0932  * @closure:    Passed back to userspace in corresponding iso resource events
0933  * @channels:   Isochronous channels of which one is to be (de)allocated
0934  * @bandwidth:  Isochronous bandwidth units to be (de)allocated
0935  * @handle: Handle to the allocation, written by the kernel (only valid in
0936  *      case of %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE ioctls)
0937  *
0938  * The %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE ioctl initiates allocation of an
0939  * isochronous channel and/or of isochronous bandwidth at the isochronous
0940  * resource manager (IRM).  Only one of the channels specified in @channels is
0941  * allocated.  An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED is sent after
0942  * communication with the IRM, indicating success or failure in the event data.
0943  * The kernel will automatically reallocate the resources after bus resets.
0944  * Should a reallocation fail, an %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event
0945  * will be sent.  The kernel will also automatically deallocate the resources
0946  * when the file descriptor is closed.
0947  *
0948  * The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE ioctl can be used to initiate
0949  * deallocation of resources which were allocated as described above.
0950  * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation.
0951  *
0952  * The %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE ioctl is a variant of allocation
0953  * without automatic re- or deallocation.
0954  * An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event concludes this operation,
0955  * indicating success or failure in its data.
0956  *
0957  * The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE ioctl works like
0958  * %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE except that resources are freed
0959  * instead of allocated.
0960  * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation.
0961  *
0962  * To summarize, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE allocates iso resources
0963  * for the lifetime of the fd or @handle.
0964  * In contrast, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE allocates iso resources
0965  * for the duration of a bus generation.
0966  *
0967  * @channels is a host-endian bitfield with the least significant bit
0968  * representing channel 0 and the most significant bit representing channel 63:
0969  * 1ULL << c for each channel c that is a candidate for (de)allocation.
0970  *
0971  * @bandwidth is expressed in bandwidth allocation units, i.e. the time to send
0972  * one quadlet of data (payload or header data) at speed S1600.
0973  */
0974 struct fw_cdev_allocate_iso_resource {
0975     __u64 closure;
0976     __u64 channels;
0977     __u32 bandwidth;
0978     __u32 handle;
0979 };
0980 
0981 /**
0982  * struct fw_cdev_send_stream_packet - send an asynchronous stream packet
0983  * @length: Length of outgoing payload, in bytes
0984  * @tag:    Data format tag
0985  * @channel:    Isochronous channel to transmit to
0986  * @sy:     Synchronization code
0987  * @closure:    Passed back to userspace in the response event
0988  * @data:   Userspace pointer to payload
0989  * @generation: The bus generation where packet is valid
0990  * @speed:  Speed to transmit at
0991  *
0992  * The %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl sends an asynchronous stream packet
0993  * to every device which is listening to the specified channel.  The kernel
0994  * writes an &fw_cdev_event_response event which indicates success or failure of
0995  * the transmission.
0996  */
0997 struct fw_cdev_send_stream_packet {
0998     __u32 length;
0999     __u32 tag;
1000     __u32 channel;
1001     __u32 sy;
1002     __u64 closure;
1003     __u64 data;
1004     __u32 generation;
1005     __u32 speed;
1006 };
1007 
1008 /**
1009  * struct fw_cdev_send_phy_packet - send a PHY packet
1010  * @closure:    Passed back to userspace in the PHY-packet-sent event
1011  * @data:   First and second quadlet of the PHY packet
1012  * @generation: The bus generation where packet is valid
1013  *
1014  * The %FW_CDEV_IOC_SEND_PHY_PACKET ioctl sends a PHY packet to all nodes
1015  * on the same card as this device.  After transmission, an
1016  * %FW_CDEV_EVENT_PHY_PACKET_SENT event is generated.
1017  *
1018  * The payload @data\[\] shall be specified in host byte order.  Usually,
1019  * @data\[1\] needs to be the bitwise inverse of @data\[0\].  VersaPHY packets
1020  * are an exception to this rule.
1021  *
1022  * The ioctl is only permitted on device files which represent a local node.
1023  */
1024 struct fw_cdev_send_phy_packet {
1025     __u64 closure;
1026     __u32 data[2];
1027     __u32 generation;
1028 };
1029 
1030 /**
1031  * struct fw_cdev_receive_phy_packets - start reception of PHY packets
1032  * @closure: Passed back to userspace in phy packet events
1033  *
1034  * This ioctl activates issuing of %FW_CDEV_EVENT_PHY_PACKET_RECEIVED due to
1035  * incoming PHY packets from any node on the same bus as the device.
1036  *
1037  * The ioctl is only permitted on device files which represent a local node.
1038  */
1039 struct fw_cdev_receive_phy_packets {
1040     __u64 closure;
1041 };
1042 
1043 #define FW_CDEV_VERSION 3 /* Meaningless legacy macro; don't use it. */
1044 
1045 #endif /* _LINUX_FIREWIRE_CDEV_H */