firewire-cdev.h 36 KB

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