firewire-cdev.h 50 KB

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