aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/firewire-cdev.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/firewire-cdev.h')
-rw-r--r--include/linux/firewire-cdev.h501
1 files changed, 407 insertions, 94 deletions
diff --git a/include/linux/firewire-cdev.h b/include/linux/firewire-cdev.h
index 68f883b30a53..68c642d8843d 100644
--- a/include/linux/firewire-cdev.h
+++ b/include/linux/firewire-cdev.h
@@ -30,12 +30,18 @@
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/firewire-constants.h> 31#include <linux/firewire-constants.h>
32 32
33#define FW_CDEV_EVENT_BUS_RESET 0x00 33#define FW_CDEV_EVENT_BUS_RESET 0x00
34#define FW_CDEV_EVENT_RESPONSE 0x01 34#define FW_CDEV_EVENT_RESPONSE 0x01
35#define FW_CDEV_EVENT_REQUEST 0x02 35#define FW_CDEV_EVENT_REQUEST 0x02
36#define FW_CDEV_EVENT_ISO_INTERRUPT 0x03 36#define FW_CDEV_EVENT_ISO_INTERRUPT 0x03
37#define FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED 0x04 37#define FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED 0x04
38#define FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 0x05 38#define FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 0x05
39
40/* available since kernel version 2.6.36 */
41#define FW_CDEV_EVENT_REQUEST2 0x06
42#define FW_CDEV_EVENT_PHY_PACKET_SENT 0x07
43#define FW_CDEV_EVENT_PHY_PACKET_RECEIVED 0x08
44#define FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL 0x09
39 45
40/** 46/**
41 * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types 47 * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types
@@ -68,6 +74,10 @@ struct fw_cdev_event_common {
68 * This event is sent when the bus the device belongs to goes through a bus 74 * This event is sent when the bus the device belongs to goes through a bus
69 * reset. It provides information about the new bus configuration, such as 75 * reset. It provides information about the new bus configuration, such as
70 * new node ID for this device, new root ID, and others. 76 * new node ID for this device, new root ID, and others.
77 *
78 * If @bm_node_id is 0xffff right after bus reset it can be reread by an
79 * %FW_CDEV_IOC_GET_INFO ioctl after bus manager selection was finished.
80 * Kernels with ABI version < 4 do not set @bm_node_id.
71 */ 81 */
72struct fw_cdev_event_bus_reset { 82struct fw_cdev_event_bus_reset {
73 __u64 closure; 83 __u64 closure;
@@ -82,8 +92,9 @@ struct fw_cdev_event_bus_reset {
82 92
83/** 93/**
84 * struct fw_cdev_event_response - Sent when a response packet was received 94 * struct fw_cdev_event_response - Sent when a response packet was received
85 * @closure: See &fw_cdev_event_common; 95 * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_REQUEST
86 * set by %FW_CDEV_IOC_SEND_REQUEST ioctl 96 * or %FW_CDEV_IOC_SEND_BROADCAST_REQUEST
97 * or %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl
87 * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_RESPONSE 98 * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_RESPONSE
88 * @rcode: Response code returned by the remote node 99 * @rcode: Response code returned by the remote node
89 * @length: Data length, i.e. the response's payload size in bytes 100 * @length: Data length, i.e. the response's payload size in bytes
@@ -93,6 +104,11 @@ struct fw_cdev_event_bus_reset {
93 * sent by %FW_CDEV_IOC_SEND_REQUEST ioctl. The payload data for responses 104 * sent by %FW_CDEV_IOC_SEND_REQUEST ioctl. The payload data for responses
94 * carrying data (read and lock responses) follows immediately and can be 105 * carrying data (read and lock responses) follows immediately and can be
95 * accessed through the @data field. 106 * accessed through the @data field.
107 *
108 * The event is also generated after conclusions of transactions that do not
109 * involve response packets. This includes unified write transactions,
110 * broadcast write transactions, and transmission of asynchronous stream
111 * packets. @rcode indicates success or failure of such transmissions.
96 */ 112 */
97struct fw_cdev_event_response { 113struct fw_cdev_event_response {
98 __u64 closure; 114 __u64 closure;
@@ -103,11 +119,46 @@ struct fw_cdev_event_response {
103}; 119};
104 120
105/** 121/**
106 * struct fw_cdev_event_request - Sent on incoming request to an address region 122 * struct fw_cdev_event_request - Old version of &fw_cdev_event_request2
107 * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl 123 * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl
108 * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST 124 * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST
125 * @tcode: See &fw_cdev_event_request2
126 * @offset: See &fw_cdev_event_request2
127 * @handle: See &fw_cdev_event_request2
128 * @length: See &fw_cdev_event_request2
129 * @data: See &fw_cdev_event_request2
130 *
131 * This event is sent instead of &fw_cdev_event_request2 if the kernel or
132 * the client implements ABI version <= 3.
133 *
134 * Unlike &fw_cdev_event_request2, the sender identity cannot be established,
135 * broadcast write requests cannot be distinguished from unicast writes, and
136 * @tcode of lock requests is %TCODE_LOCK_REQUEST.
137 *
138 * Requests to the FCP_REQUEST or FCP_RESPONSE register are responded to as
139 * with &fw_cdev_event_request2, except in kernel 2.6.32 and older which send
140 * the response packet of the client's %FW_CDEV_IOC_SEND_RESPONSE ioctl.
141 */
142struct fw_cdev_event_request {
143 __u64 closure;
144 __u32 type;
145 __u32 tcode;
146 __u64 offset;
147 __u32 handle;
148 __u32 length;
149 __u32 data[0];
150};
151
152/**
153 * struct fw_cdev_event_request2 - Sent on incoming request to an address region
154 * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl
155 * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST2
109 * @tcode: Transaction code of the incoming request 156 * @tcode: Transaction code of the incoming request
110 * @offset: The offset into the 48-bit per-node address space 157 * @offset: The offset into the 48-bit per-node address space
158 * @source_node_id: Sender node ID
159 * @destination_node_id: Destination node ID
160 * @card: The index of the card from which the request came
161 * @generation: Bus generation in which the request is valid
111 * @handle: Reference to the kernel-side pending request 162 * @handle: Reference to the kernel-side pending request
112 * @length: Data length, i.e. the request's payload size in bytes 163 * @length: Data length, i.e. the request's payload size in bytes
113 * @data: Incoming data, if any 164 * @data: Incoming data, if any
@@ -120,12 +171,42 @@ struct fw_cdev_event_response {
120 * 171 *
121 * The payload data for requests carrying data (write and lock requests) 172 * The payload data for requests carrying data (write and lock requests)
122 * follows immediately and can be accessed through the @data field. 173 * follows immediately and can be accessed through the @data field.
174 *
175 * Unlike &fw_cdev_event_request, @tcode of lock requests is one of the
176 * firewire-core specific %TCODE_LOCK_MASK_SWAP...%TCODE_LOCK_VENDOR_DEPENDENT,
177 * i.e. encodes the extended transaction code.
178 *
179 * @card may differ from &fw_cdev_get_info.card because requests are received
180 * from all cards of the Linux host. @source_node_id, @destination_node_id, and
181 * @generation pertain to that card. Destination node ID and bus generation may
182 * therefore differ from the corresponding fields of the last
183 * &fw_cdev_event_bus_reset.
184 *
185 * @destination_node_id may also differ from the current node ID because of a
186 * non-local bus ID part or in case of a broadcast write request. Note, a
187 * client must call an %FW_CDEV_IOC_SEND_RESPONSE ioctl even in case of a
188 * broadcast write request; the kernel will then release the kernel-side pending
189 * request but will not actually send a response packet.
190 *
191 * In case of a write request to FCP_REQUEST or FCP_RESPONSE, the kernel already
192 * sent a write response immediately after the request was received; in this
193 * case the client must still call an %FW_CDEV_IOC_SEND_RESPONSE ioctl to
194 * release the kernel-side pending request, though another response won't be
195 * sent.
196 *
197 * If the client subsequently needs to initiate requests to the sender node of
198 * an &fw_cdev_event_request2, it needs to use a device file with matching
199 * card index, node ID, and generation for outbound requests.
123 */ 200 */
124struct fw_cdev_event_request { 201struct fw_cdev_event_request2 {
125 __u64 closure; 202 __u64 closure;
126 __u32 type; 203 __u32 type;
127 __u32 tcode; 204 __u32 tcode;
128 __u64 offset; 205 __u64 offset;
206 __u32 source_node_id;
207 __u32 destination_node_id;
208 __u32 card;
209 __u32 generation;
129 __u32 handle; 210 __u32 handle;
130 __u32 length; 211 __u32 length;
131 __u32 data[0]; 212 __u32 data[0];
@@ -141,26 +222,43 @@ struct fw_cdev_event_request {
141 * @header: Stripped headers, if any 222 * @header: Stripped headers, if any
142 * 223 *
143 * This event is sent when the controller has completed an &fw_cdev_iso_packet 224 * This event is sent when the controller has completed an &fw_cdev_iso_packet
144 * with the %FW_CDEV_ISO_INTERRUPT bit set. In the receive case, the headers 225 * with the %FW_CDEV_ISO_INTERRUPT bit set.
145 * stripped of all packets up until and including the interrupt packet are
146 * returned in the @header field. The amount of header data per packet is as
147 * specified at iso context creation by &fw_cdev_create_iso_context.header_size.
148 * 226 *
149 * In version 1 of this ABI, header data consisted of the 1394 isochronous 227 * Isochronous transmit events (context type %FW_CDEV_ISO_CONTEXT_TRANSMIT):
150 * packet header, followed by quadlets from the packet payload if
151 * &fw_cdev_create_iso_context.header_size > 4.
152 * 228 *
153 * In version 2 of this ABI, header data consist of the 1394 isochronous 229 * In version 3 and some implementations of version 2 of the ABI, &header_length
154 * packet header, followed by a timestamp quadlet if 230 * is a multiple of 4 and &header contains timestamps of all packets up until
155 * &fw_cdev_create_iso_context.header_size > 4, followed by quadlets from the 231 * the interrupt packet. The format of the timestamps is as described below for
156 * packet payload if &fw_cdev_create_iso_context.header_size > 8. 232 * isochronous reception. In version 1 of the ABI, &header_length was 0.
157 * 233 *
158 * Behaviour of ver. 1 of this ABI is no longer available since ABI ver. 2. 234 * Isochronous receive events (context type %FW_CDEV_ISO_CONTEXT_RECEIVE):
235 *
236 * The headers stripped of all packets up until and including the interrupt
237 * packet are returned in the @header field. The amount of header data per
238 * packet is as specified at iso context creation by
239 * &fw_cdev_create_iso_context.header_size.
240 *
241 * Hence, _interrupt.header_length / _context.header_size is the number of
242 * packets received in this interrupt event. The client can now iterate
243 * through the mmap()'ed DMA buffer according to this number of packets and
244 * to the buffer sizes as the client specified in &fw_cdev_queue_iso.
245 *
246 * Since version 2 of this ABI, the portion for each packet in _interrupt.header
247 * consists of the 1394 isochronous packet header, followed by a timestamp
248 * quadlet if &fw_cdev_create_iso_context.header_size > 4, followed by quadlets
249 * from the packet payload if &fw_cdev_create_iso_context.header_size > 8.
159 * 250 *
160 * Format of 1394 iso packet header: 16 bits len, 2 bits tag, 6 bits channel, 251 * Format of 1394 iso packet header: 16 bits data_length, 2 bits tag, 6 bits
161 * 4 bits tcode, 4 bits sy, in big endian byte order. Format of timestamp: 252 * channel, 4 bits tcode, 4 bits sy, in big endian byte order.
162 * 16 bits invalid, 3 bits cycleSeconds, 13 bits cycleCount, in big endian byte 253 * data_length is the actual received size of the packet without the four
163 * order. 254 * 1394 iso packet header bytes.
255 *
256 * Format of timestamp: 16 bits invalid, 3 bits cycleSeconds, 13 bits
257 * cycleCount, in big endian byte order.
258 *
259 * In version 1 of the ABI, no timestamp quadlet was inserted; instead, payload
260 * data followed directly after the 1394 is header if header_size > 4.
261 * Behaviour of ver. 1 of this ABI is no longer available since ABI ver. 2.
164 */ 262 */
165struct fw_cdev_event_iso_interrupt { 263struct fw_cdev_event_iso_interrupt {
166 __u64 closure; 264 __u64 closure;
@@ -171,6 +269,43 @@ struct fw_cdev_event_iso_interrupt {
171}; 269};
172 270
173/** 271/**
272 * struct fw_cdev_event_iso_interrupt_mc - An iso buffer chunk was completed
273 * @closure: See &fw_cdev_event_common;
274 * set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl
275 * @type: %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL
276 * @completed: Offset into the receive buffer; data before this offest is valid
277 *
278 * This event is sent in multichannel contexts (context type
279 * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL) for &fw_cdev_iso_packet buffer
280 * chunks that have the %FW_CDEV_ISO_INTERRUPT bit set. Whether this happens
281 * when a packet is completed and/or when a buffer chunk is completed depends
282 * on the hardware implementation.
283 *
284 * The buffer is continuously filled with the following data, per packet:
285 * - the 1394 iso packet header as described at &fw_cdev_event_iso_interrupt,
286 * but in little endian byte order,
287 * - packet payload (as many bytes as specified in the data_length field of
288 * the 1394 iso packet header) in big endian byte order,
289 * - 0...3 padding bytes as needed to align the following trailer quadlet,
290 * - trailer quadlet, containing the reception timestamp as described at
291 * &fw_cdev_event_iso_interrupt, but in little endian byte order.
292 *
293 * Hence the per-packet size is data_length (rounded up to a multiple of 4) + 8.
294 * When processing the data, stop before a packet that would cross the
295 * @completed offset.
296 *
297 * A packet near the end of a buffer chunk will typically spill over into the
298 * next queued buffer chunk. It is the responsibility of the client to check
299 * for this condition, assemble a broken-up packet from its parts, and not to
300 * re-queue any buffer chunks in which as yet unread packet parts reside.
301 */
302struct fw_cdev_event_iso_interrupt_mc {
303 __u64 closure;
304 __u32 type;
305 __u32 completed;
306};
307
308/**
174 * struct fw_cdev_event_iso_resource - Iso resources were allocated or freed 309 * struct fw_cdev_event_iso_resource - Iso resources were allocated or freed
175 * @closure: See &fw_cdev_event_common; 310 * @closure: See &fw_cdev_event_common;
176 * set by %FW_CDEV_IOC_(DE)ALLOCATE_ISO_RESOURCE(_ONCE) ioctl 311 * set by %FW_CDEV_IOC_(DE)ALLOCATE_ISO_RESOURCE(_ONCE) ioctl
@@ -200,15 +335,45 @@ struct fw_cdev_event_iso_resource {
200}; 335};
201 336
202/** 337/**
338 * struct fw_cdev_event_phy_packet - A PHY packet was transmitted or received
339 * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_PHY_PACKET
340 * or %FW_CDEV_IOC_RECEIVE_PHY_PACKETS ioctl
341 * @type: %FW_CDEV_EVENT_PHY_PACKET_SENT or %..._RECEIVED
342 * @rcode: %RCODE_..., indicates success or failure of transmission
343 * @length: Data length in bytes
344 * @data: Incoming data
345 *
346 * If @type is %FW_CDEV_EVENT_PHY_PACKET_SENT, @length is 0 and @data empty,
347 * except in case of a ping packet: Then, @length is 4, and @data[0] is the
348 * ping time in 49.152MHz clocks if @rcode is %RCODE_COMPLETE.
349 *
350 * If @type is %FW_CDEV_EVENT_PHY_PACKET_RECEIVED, @length is 8 and @data
351 * consists of the two PHY packet quadlets, in host byte order.
352 */
353struct fw_cdev_event_phy_packet {
354 __u64 closure;
355 __u32 type;
356 __u32 rcode;
357 __u32 length;
358 __u32 data[0];
359};
360
361/**
203 * union fw_cdev_event - Convenience union of fw_cdev_event_ types 362 * union fw_cdev_event - Convenience union of fw_cdev_event_ types
204 * @common: Valid for all types 363 * @common: Valid for all types
205 * @bus_reset: Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET 364 * @bus_reset: Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET
206 * @response: Valid if @common.type == %FW_CDEV_EVENT_RESPONSE 365 * @response: Valid if @common.type == %FW_CDEV_EVENT_RESPONSE
207 * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST 366 * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST
208 * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT 367 * @request2: Valid if @common.type == %FW_CDEV_EVENT_REQUEST2
209 * @iso_resource: Valid if @common.type == 368 * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT
369 * @iso_interrupt_mc: Valid if @common.type ==
370 * %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL
371 * @iso_resource: Valid if @common.type ==
210 * %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or 372 * %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or
211 * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 373 * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED
374 * @phy_packet: Valid if @common.type ==
375 * %FW_CDEV_EVENT_PHY_PACKET_SENT or
376 * %FW_CDEV_EVENT_PHY_PACKET_RECEIVED
212 * 377 *
213 * Convenience union for userspace use. Events could be read(2) into an 378 * Convenience union for userspace use. Events could be read(2) into an
214 * appropriately aligned char buffer and then cast to this union for further 379 * appropriately aligned char buffer and then cast to this union for further
@@ -223,8 +388,11 @@ union fw_cdev_event {
223 struct fw_cdev_event_bus_reset bus_reset; 388 struct fw_cdev_event_bus_reset bus_reset;
224 struct fw_cdev_event_response response; 389 struct fw_cdev_event_response response;
225 struct fw_cdev_event_request request; 390 struct fw_cdev_event_request request;
391 struct fw_cdev_event_request2 request2; /* added in 2.6.36 */
226 struct fw_cdev_event_iso_interrupt iso_interrupt; 392 struct fw_cdev_event_iso_interrupt iso_interrupt;
227 struct fw_cdev_event_iso_resource iso_resource; 393 struct fw_cdev_event_iso_interrupt_mc iso_interrupt_mc; /* added in 2.6.36 */
394 struct fw_cdev_event_iso_resource iso_resource; /* added in 2.6.30 */
395 struct fw_cdev_event_phy_packet phy_packet; /* added in 2.6.36 */
228}; 396};
229 397
230/* available since kernel version 2.6.22 */ 398/* available since kernel version 2.6.22 */
@@ -256,23 +424,46 @@ union fw_cdev_event {
256/* available since kernel version 2.6.34 */ 424/* available since kernel version 2.6.34 */
257#define FW_CDEV_IOC_GET_CYCLE_TIMER2 _IOWR('#', 0x14, struct fw_cdev_get_cycle_timer2) 425#define FW_CDEV_IOC_GET_CYCLE_TIMER2 _IOWR('#', 0x14, struct fw_cdev_get_cycle_timer2)
258 426
427/* available since kernel version 2.6.36 */
428#define FW_CDEV_IOC_SEND_PHY_PACKET _IOWR('#', 0x15, struct fw_cdev_send_phy_packet)
429#define FW_CDEV_IOC_RECEIVE_PHY_PACKETS _IOW('#', 0x16, struct fw_cdev_receive_phy_packets)
430#define FW_CDEV_IOC_SET_ISO_CHANNELS _IOW('#', 0x17, struct fw_cdev_set_iso_channels)
431
259/* 432/*
260 * FW_CDEV_VERSION History 433 * ABI version history
261 * 1 (2.6.22) - initial version 434 * 1 (2.6.22) - initial version
435 * (2.6.24) - added %FW_CDEV_IOC_GET_CYCLE_TIMER
262 * 2 (2.6.30) - changed &fw_cdev_event_iso_interrupt.header if 436 * 2 (2.6.30) - changed &fw_cdev_event_iso_interrupt.header if
263 * &fw_cdev_create_iso_context.header_size is 8 or more 437 * &fw_cdev_create_iso_context.header_size is 8 or more
438 * - added %FW_CDEV_IOC_*_ISO_RESOURCE*,
439 * %FW_CDEV_IOC_GET_SPEED, %FW_CDEV_IOC_SEND_BROADCAST_REQUEST,
440 * %FW_CDEV_IOC_SEND_STREAM_PACKET
264 * (2.6.32) - added time stamp to xmit &fw_cdev_event_iso_interrupt 441 * (2.6.32) - added time stamp to xmit &fw_cdev_event_iso_interrupt
265 * (2.6.33) - IR has always packet-per-buffer semantics now, not one of 442 * (2.6.33) - IR has always packet-per-buffer semantics now, not one of
266 * dual-buffer or packet-per-buffer depending on hardware 443 * dual-buffer or packet-per-buffer depending on hardware
444 * - shared use and auto-response for FCP registers
267 * 3 (2.6.34) - made &fw_cdev_get_cycle_timer reliable 445 * 3 (2.6.34) - made &fw_cdev_get_cycle_timer reliable
446 * - added %FW_CDEV_IOC_GET_CYCLE_TIMER2
447 * 4 (2.6.36) - added %FW_CDEV_EVENT_REQUEST2, %FW_CDEV_EVENT_PHY_PACKET_*,
448 * and &fw_cdev_allocate.region_end
449 * - implemented &fw_cdev_event_bus_reset.bm_node_id
450 * - added %FW_CDEV_IOC_SEND_PHY_PACKET, _RECEIVE_PHY_PACKETS
451 * - added %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL,
452 * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL, and
453 * %FW_CDEV_IOC_SET_ISO_CHANNELS
268 */ 454 */
269#define FW_CDEV_VERSION 3 455#define FW_CDEV_VERSION 3 /* Meaningless; don't use this macro. */
270 456
271/** 457/**
272 * struct fw_cdev_get_info - General purpose information ioctl 458 * struct fw_cdev_get_info - General purpose information ioctl
273 * @version: The version field is just a running serial number. 459 * @version: The version field is just a running serial number. Both an
274 * We never break backwards compatibility, but may add more 460 * input parameter (ABI version implemented by the client) and
275 * structs and ioctls in later revisions. 461 * output parameter (ABI version implemented by the kernel).
462 * A client must not fill in an %FW_CDEV_VERSION defined from an
463 * included kernel header file but the actual version for which
464 * the client was implemented. This is necessary for forward
465 * compatibility. We never break backwards compatibility, but
466 * may add more structs, events, and ioctls in later revisions.
276 * @rom_length: If @rom is non-zero, at most rom_length bytes of configuration 467 * @rom_length: If @rom is non-zero, at most rom_length bytes of configuration
277 * ROM will be copied into that user space address. In either 468 * ROM will be copied into that user space address. In either
278 * case, @rom_length is updated with the actual length of the 469 * case, @rom_length is updated with the actual length of the
@@ -339,28 +530,48 @@ struct fw_cdev_send_response {
339}; 530};
340 531
341/** 532/**
342 * struct fw_cdev_allocate - Allocate a CSR address range 533 * struct fw_cdev_allocate - Allocate a CSR in an address range
343 * @offset: Start offset of the address range 534 * @offset: Start offset of the address range
344 * @closure: To be passed back to userspace in request events 535 * @closure: To be passed back to userspace in request events
345 * @length: Length of the address range, in bytes 536 * @length: Length of the CSR, in bytes
346 * @handle: Handle to the allocation, written by the kernel 537 * @handle: Handle to the allocation, written by the kernel
538 * @region_end: First address above the address range (added in ABI v4, 2.6.36)
347 * 539 *
348 * Allocate an address range in the 48-bit address space on the local node 540 * Allocate an address range in the 48-bit address space on the local node
349 * (the controller). This allows userspace to listen for requests with an 541 * (the controller). This allows userspace to listen for requests with an
350 * offset within that address range. When the kernel receives a request 542 * offset within that address range. Every time when the kernel receives a
351 * within the range, an &fw_cdev_event_request event will be written back. 543 * request within the range, an &fw_cdev_event_request2 event will be emitted.
352 * The @closure field is passed back to userspace in the response event. 544 * (If the kernel or the client implements ABI version <= 3, an
545 * &fw_cdev_event_request will be generated instead.)
546 *
547 * The @closure field is passed back to userspace in these request events.
353 * The @handle field is an out parameter, returning a handle to the allocated 548 * The @handle field is an out parameter, returning a handle to the allocated
354 * range to be used for later deallocation of the range. 549 * range to be used for later deallocation of the range.
355 * 550 *
356 * The address range is allocated on all local nodes. The address allocation 551 * The address range is allocated on all local nodes. The address allocation
357 * is exclusive except for the FCP command and response registers. 552 * is exclusive except for the FCP command and response registers. If an
553 * exclusive address region is already in use, the ioctl fails with errno set
554 * to %EBUSY.
555 *
556 * If kernel and client implement ABI version >= 4, the kernel looks up a free
557 * spot of size @length inside [@offset..@region_end) and, if found, writes
558 * the start address of the new CSR back in @offset. I.e. @offset is an
559 * in and out parameter. If this automatic placement of a CSR in a bigger
560 * address range is not desired, the client simply needs to set @region_end
561 * = @offset + @length.
562 *
563 * If the kernel or the client implements ABI version <= 3, @region_end is
564 * ignored and effectively assumed to be @offset + @length.
565 *
566 * @region_end is only present in a kernel header >= 2.6.36. If necessary,
567 * this can for example be tested by #ifdef FW_CDEV_EVENT_REQUEST2.
358 */ 568 */
359struct fw_cdev_allocate { 569struct fw_cdev_allocate {
360 __u64 offset; 570 __u64 offset;
361 __u64 closure; 571 __u64 closure;
362 __u32 length; 572 __u32 length;
363 __u32 handle; 573 __u32 handle;
574 __u64 region_end; /* available since kernel version 2.6.36 */
364}; 575};
365 576
366/** 577/**
@@ -382,9 +593,14 @@ struct fw_cdev_deallocate {
382 * Initiate a bus reset for the bus this device is on. The bus reset can be 593 * Initiate a bus reset for the bus this device is on. The bus reset can be
383 * either the original (long) bus reset or the arbitrated (short) bus reset 594 * either the original (long) bus reset or the arbitrated (short) bus reset
384 * introduced in 1394a-2000. 595 * introduced in 1394a-2000.
596 *
597 * The ioctl returns immediately. A subsequent &fw_cdev_event_bus_reset
598 * indicates when the reset actually happened. Since ABI v4, this may be
599 * considerably later than the ioctl because the kernel ensures a grace period
600 * between subsequent bus resets as per IEEE 1394 bus management specification.
385 */ 601 */
386struct fw_cdev_initiate_bus_reset { 602struct fw_cdev_initiate_bus_reset {
387 __u32 type; /* FW_CDEV_SHORT_RESET or FW_CDEV_LONG_RESET */ 603 __u32 type;
388}; 604};
389 605
390/** 606/**
@@ -408,9 +624,10 @@ struct fw_cdev_initiate_bus_reset {
408 * 624 *
409 * @immediate, @key, and @data array elements are CPU-endian quadlets. 625 * @immediate, @key, and @data array elements are CPU-endian quadlets.
410 * 626 *
411 * If successful, the kernel adds the descriptor and writes back a handle to the 627 * If successful, the kernel adds the descriptor and writes back a @handle to
412 * kernel-side object to be used for later removal of the descriptor block and 628 * the kernel-side object to be used for later removal of the descriptor block
413 * immediate key. 629 * and immediate key. The kernel will also generate a bus reset to signal the
630 * change of the configuration ROM to other nodes.
414 * 631 *
415 * This ioctl affects the configuration ROMs of all local nodes. 632 * This ioctl affects the configuration ROMs of all local nodes.
416 * The ioctl only succeeds on device files which represent a local node. 633 * The ioctl only succeeds on device files which represent a local node.
@@ -429,38 +646,50 @@ struct fw_cdev_add_descriptor {
429 * descriptor was added 646 * descriptor was added
430 * 647 *
431 * Remove a descriptor block and accompanying immediate key from the local 648 * Remove a descriptor block and accompanying immediate key from the local
432 * nodes' configuration ROMs. 649 * nodes' configuration ROMs. The kernel will also generate a bus reset to
650 * signal the change of the configuration ROM to other nodes.
433 */ 651 */
434struct fw_cdev_remove_descriptor { 652struct fw_cdev_remove_descriptor {
435 __u32 handle; 653 __u32 handle;
436}; 654};
437 655
438#define FW_CDEV_ISO_CONTEXT_TRANSMIT 0 656#define FW_CDEV_ISO_CONTEXT_TRANSMIT 0
439#define FW_CDEV_ISO_CONTEXT_RECEIVE 1 657#define FW_CDEV_ISO_CONTEXT_RECEIVE 1
658#define FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL 2 /* added in 2.6.36 */
440 659
441/** 660/**
442 * struct fw_cdev_create_iso_context - Create a context for isochronous IO 661 * struct fw_cdev_create_iso_context - Create a context for isochronous I/O
443 * @type: %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE 662 * @type: %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE or
444 * @header_size: Header size to strip for receive contexts 663 * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL
445 * @channel: Channel to bind to 664 * @header_size: Header size to strip in single-channel reception
446 * @speed: Speed for transmit contexts 665 * @channel: Channel to bind to in single-channel reception or transmission
447 * @closure: To be returned in &fw_cdev_event_iso_interrupt 666 * @speed: Transmission speed
667 * @closure: To be returned in &fw_cdev_event_iso_interrupt or
668 * &fw_cdev_event_iso_interrupt_multichannel
448 * @handle: Handle to context, written back by kernel 669 * @handle: Handle to context, written back by kernel
449 * 670 *
450 * Prior to sending or receiving isochronous I/O, a context must be created. 671 * Prior to sending or receiving isochronous I/O, a context must be created.
451 * The context records information about the transmit or receive configuration 672 * The context records information about the transmit or receive configuration
452 * and typically maps to an underlying hardware resource. A context is set up 673 * and typically maps to an underlying hardware resource. A context is set up
453 * for either sending or receiving. It is bound to a specific isochronous 674 * for either sending or receiving. It is bound to a specific isochronous
454 * channel. 675 * @channel.
676 *
677 * In case of multichannel reception, @header_size and @channel are ignored
678 * and the channels are selected by %FW_CDEV_IOC_SET_ISO_CHANNELS.
679 *
680 * For %FW_CDEV_ISO_CONTEXT_RECEIVE contexts, @header_size must be at least 4
681 * and must be a multiple of 4. It is ignored in other context types.
682 *
683 * @speed is ignored in receive context types.
455 * 684 *
456 * If a context was successfully created, the kernel writes back a handle to the 685 * If a context was successfully created, the kernel writes back a handle to the
457 * context, which must be passed in for subsequent operations on that context. 686 * context, which must be passed in for subsequent operations on that context.
458 * 687 *
459 * For receive contexts, @header_size must be at least 4 and must be a multiple 688 * Limitations:
460 * of 4. 689 * No more than one iso context can be created per fd.
461 * 690 * The total number of contexts that all userspace and kernelspace drivers can
462 * Note that the effect of a @header_size > 4 depends on 691 * create on a card at a time is a hardware limit, typically 4 or 8 contexts per
463 * &fw_cdev_get_info.version, as documented at &fw_cdev_event_iso_interrupt. 692 * direction, and of them at most one multichannel receive context.
464 */ 693 */
465struct fw_cdev_create_iso_context { 694struct fw_cdev_create_iso_context {
466 __u32 type; 695 __u32 type;
@@ -471,6 +700,22 @@ struct fw_cdev_create_iso_context {
471 __u32 handle; 700 __u32 handle;
472}; 701};
473 702
703/**
704 * struct fw_cdev_set_iso_channels - Select channels in multichannel reception
705 * @channels: Bitmask of channels to listen to
706 * @handle: Handle of the mutichannel receive context
707 *
708 * @channels is the bitwise or of 1ULL << n for each channel n to listen to.
709 *
710 * The ioctl fails with errno %EBUSY if there is already another receive context
711 * on a channel in @channels. In that case, the bitmask of all unoccupied
712 * channels is returned in @channels.
713 */
714struct fw_cdev_set_iso_channels {
715 __u64 channels;
716 __u32 handle;
717};
718
474#define FW_CDEV_ISO_PAYLOAD_LENGTH(v) (v) 719#define FW_CDEV_ISO_PAYLOAD_LENGTH(v) (v)
475#define FW_CDEV_ISO_INTERRUPT (1 << 16) 720#define FW_CDEV_ISO_INTERRUPT (1 << 16)
476#define FW_CDEV_ISO_SKIP (1 << 17) 721#define FW_CDEV_ISO_SKIP (1 << 17)
@@ -481,42 +726,72 @@ struct fw_cdev_create_iso_context {
481 726
482/** 727/**
483 * struct fw_cdev_iso_packet - Isochronous packet 728 * struct fw_cdev_iso_packet - Isochronous packet
484 * @control: Contains the header length (8 uppermost bits), the sy field 729 * @control: Contains the header length (8 uppermost bits),
485 * (4 bits), the tag field (2 bits), a sync flag (1 bit), 730 * the sy field (4 bits), the tag field (2 bits), a sync flag
486 * a skip flag (1 bit), an interrupt flag (1 bit), and the 731 * or a skip flag (1 bit), an interrupt flag (1 bit), and the
487 * payload length (16 lowermost bits) 732 * payload length (16 lowermost bits)
488 * @header: Header and payload 733 * @header: Header and payload in case of a transmit context.
489 * 734 *
490 * &struct fw_cdev_iso_packet is used to describe isochronous packet queues. 735 * &struct fw_cdev_iso_packet is used to describe isochronous packet queues.
491 *
492 * Use the FW_CDEV_ISO_ macros to fill in @control. 736 * Use the FW_CDEV_ISO_ macros to fill in @control.
737 * The @header array is empty in case of receive contexts.
738 *
739 * Context type %FW_CDEV_ISO_CONTEXT_TRANSMIT:
740 *
741 * @control.HEADER_LENGTH must be a multiple of 4. It specifies the numbers of
742 * bytes in @header that will be prepended to the packet's payload. These bytes
743 * are copied into the kernel and will not be accessed after the ioctl has
744 * returned.
745 *
746 * The @control.SY and TAG fields are copied to the iso packet header. These
747 * fields are specified by IEEE 1394a and IEC 61883-1.
748 *
749 * The @control.SKIP flag specifies that no packet is to be sent in a frame.
750 * When using this, all other fields except @control.INTERRUPT must be zero.
751 *
752 * When a packet with the @control.INTERRUPT flag set has been completed, an
753 * &fw_cdev_event_iso_interrupt event will be sent.
754 *
755 * Context type %FW_CDEV_ISO_CONTEXT_RECEIVE:
756 *
757 * @control.HEADER_LENGTH must be a multiple of the context's header_size.
758 * If the HEADER_LENGTH is larger than the context's header_size, multiple
759 * packets are queued for this entry.
760 *
761 * The @control.SY and TAG fields are ignored.
762 *
763 * If the @control.SYNC flag is set, the context drops all packets until a
764 * packet with a sy field is received which matches &fw_cdev_start_iso.sync.
765 *
766 * @control.PAYLOAD_LENGTH defines how many payload bytes can be received for
767 * one packet (in addition to payload quadlets that have been defined as headers
768 * and are stripped and returned in the &fw_cdev_event_iso_interrupt structure).
769 * If more bytes are received, the additional bytes are dropped. If less bytes
770 * are received, the remaining bytes in this part of the payload buffer will not
771 * be written to, not even by the next packet. I.e., packets received in
772 * consecutive frames will not necessarily be consecutive in memory. If an
773 * entry has queued multiple packets, the PAYLOAD_LENGTH is divided equally
774 * among them.
493 * 775 *
494 * For transmit packets, the header length must be a multiple of 4 and specifies 776 * When a packet with the @control.INTERRUPT flag set has been completed, an
495 * the numbers of bytes in @header that will be prepended to the packet's
496 * payload; these bytes are copied into the kernel and will not be accessed
497 * after the ioctl has returned. The sy and tag fields are copied to the iso
498 * packet header (these fields are specified by IEEE 1394a and IEC 61883-1).
499 * The skip flag specifies that no packet is to be sent in a frame; when using
500 * this, all other fields except the interrupt flag must be zero.
501 *
502 * For receive packets, the header length must be a multiple of the context's
503 * header size; if the header length is larger than the context's header size,
504 * multiple packets are queued for this entry. The sy and tag fields are
505 * ignored. If the sync flag is set, the context drops all packets until
506 * a packet with a matching sy field is received (the sync value to wait for is
507 * specified in the &fw_cdev_start_iso structure). The payload length defines
508 * how many payload bytes can be received for one packet (in addition to payload
509 * quadlets that have been defined as headers and are stripped and returned in
510 * the &fw_cdev_event_iso_interrupt structure). If more bytes are received, the
511 * additional bytes are dropped. If less bytes are received, the remaining
512 * bytes in this part of the payload buffer will not be written to, not even by
513 * the next packet, i.e., packets received in consecutive frames will not
514 * necessarily be consecutive in memory. If an entry has queued multiple
515 * packets, the payload length is divided equally among them.
516 *
517 * When a packet with the interrupt flag set has been completed, the
518 * &fw_cdev_event_iso_interrupt event will be sent. An entry that has queued 777 * &fw_cdev_event_iso_interrupt event will be sent. An entry that has queued
519 * multiple receive packets is completed when its last packet is completed. 778 * multiple receive packets is completed when its last packet is completed.
779 *
780 * Context type %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL:
781 *
782 * Here, &fw_cdev_iso_packet would be more aptly named _iso_buffer_chunk since
783 * it specifies a chunk of the mmap()'ed buffer, while the number and alignment
784 * of packets to be placed into the buffer chunk is not known beforehand.
785 *
786 * @control.PAYLOAD_LENGTH is the size of the buffer chunk and specifies room
787 * for header, payload, padding, and trailer bytes of one or more packets.
788 * It must be a multiple of 4.
789 *
790 * @control.HEADER_LENGTH, TAG and SY are ignored. SYNC is treated as described
791 * for single-channel reception.
792 *
793 * When a buffer chunk with the @control.INTERRUPT flag set has been filled
794 * entirely, an &fw_cdev_event_iso_interrupt_mc event will be sent.
520 */ 795 */
521struct fw_cdev_iso_packet { 796struct fw_cdev_iso_packet {
522 __u32 control; 797 __u32 control;
@@ -525,9 +800,9 @@ struct fw_cdev_iso_packet {
525 800
526/** 801/**
527 * struct fw_cdev_queue_iso - Queue isochronous packets for I/O 802 * struct fw_cdev_queue_iso - Queue isochronous packets for I/O
528 * @packets: Userspace pointer to packet data 803 * @packets: Userspace pointer to an array of &fw_cdev_iso_packet
529 * @data: Pointer into mmap()'ed payload buffer 804 * @data: Pointer into mmap()'ed payload buffer
530 * @size: Size of packet data in bytes 805 * @size: Size of the @packets array, in bytes
531 * @handle: Isochronous context handle 806 * @handle: Isochronous context handle
532 * 807 *
533 * Queue a number of isochronous packets for reception or transmission. 808 * Queue a number of isochronous packets for reception or transmission.
@@ -540,6 +815,9 @@ struct fw_cdev_iso_packet {
540 * The kernel may or may not queue all packets, but will write back updated 815 * The kernel may or may not queue all packets, but will write back updated
541 * values of the @packets, @data and @size fields, so the ioctl can be 816 * values of the @packets, @data and @size fields, so the ioctl can be
542 * resubmitted easily. 817 * resubmitted easily.
818 *
819 * In case of a multichannel receive context, @data must be quadlet-aligned
820 * relative to the buffer start.
543 */ 821 */
544struct fw_cdev_queue_iso { 822struct fw_cdev_queue_iso {
545 __u64 packets; 823 __u64 packets;
@@ -698,4 +976,39 @@ struct fw_cdev_send_stream_packet {
698 __u32 speed; 976 __u32 speed;
699}; 977};
700 978
979/**
980 * struct fw_cdev_send_phy_packet - send a PHY packet
981 * @closure: Passed back to userspace in the PHY-packet-sent event
982 * @data: First and second quadlet of the PHY packet
983 * @generation: The bus generation where packet is valid
984 *
985 * The %FW_CDEV_IOC_SEND_PHY_PACKET ioctl sends a PHY packet to all nodes
986 * on the same card as this device. After transmission, an
987 * %FW_CDEV_EVENT_PHY_PACKET_SENT event is generated.
988 *
989 * The payload @data[] shall be specified in host byte order. Usually,
990 * @data[1] needs to be the bitwise inverse of @data[0]. VersaPHY packets
991 * are an exception to this rule.
992 *
993 * The ioctl is only permitted on device files which represent a local node.
994 */
995struct fw_cdev_send_phy_packet {
996 __u64 closure;
997 __u32 data[2];
998 __u32 generation;
999};
1000
1001/**
1002 * struct fw_cdev_receive_phy_packets - start reception of PHY packets
1003 * @closure: Passed back to userspace in phy packet events
1004 *
1005 * This ioctl activates issuing of %FW_CDEV_EVENT_PHY_PACKET_RECEIVED due to
1006 * incoming PHY packets from any node on the same bus as the device.
1007 *
1008 * The ioctl is only permitted on device files which represent a local node.
1009 */
1010struct fw_cdev_receive_phy_packets {
1011 __u64 closure;
1012};
1013
701#endif /* _LINUX_FIREWIRE_CDEV_H */ 1014#endif /* _LINUX_FIREWIRE_CDEV_H */