firewire-cdev.h 42 KB

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