firewire-cdev.h 43 KB

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