firewire-cdev.h 42 KB

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