aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/firewire-cdev.h
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2010-07-16 16:25:14 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2010-07-23 07:36:28 -0400
commit850bb6f23b93c04ce1e4509a87fa607dc17d97c1 (patch)
tree4ec66cea35e15ff095799bae4aec7c1071d4faa4 /include/linux/firewire-cdev.h
parentb9dc61cf404165fb77e80c853e9fec9af258f9ce (diff)
firewire: cdev: add PHY packet transmission
Add an FW_CDEV_IOC_SEND_PHY_PACKET ioctl() for /dev/fw* which can be used to implement bus management related functionality in userspace. This is also half of the functionality (the transmit part) that is needed to support a userspace implementation of a VersaPHY transaction layer. Safety considerations: - PHY packets are generally broadcasts and may have interesting effects on PHYs and the bus, e.g. make asynchronous arbitration impossible due to too low gap count. Hence some kind of elevated privileges should be required of a process to be able to send PHY packets. This implementation assumes that a process that is allowed to open the /dev/fw* of a local node does have this privilege. There was an inconclusive discussion about introducing POSIX capabilities as a means to check for user privileges for these kinds of operations. - The kernel does not check integrity of the supplied packet data. That would be far too much code, considering the many kinds of PHY packets. A process which got the privilege to send these packets is trusted to do it correctly. Just like with the other "send packet" ioctls, a non-blocking API is chosen; i.e. the ioctl may return even before AT DMA started. After transmission, an event for poll()/read() is enqueued. Most users are going to need a blocking API, but a blocking userspace wrapper is easy to implement, and the second of the two existing libraw1394 calls raw1394_phy_packet_write() and raw1394_start_phy_packet_write() can be better supported that way. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'include/linux/firewire-cdev.h')
-rw-r--r--include/linux/firewire-cdev.h44
1 files changed, 43 insertions, 1 deletions
diff --git a/include/linux/firewire-cdev.h b/include/linux/firewire-cdev.h
index fde9568151d5..5bc051b9a013 100644
--- a/include/linux/firewire-cdev.h
+++ b/include/linux/firewire-cdev.h
@@ -34,6 +34,7 @@
34 34
35/* available since kernel version 2.6.36 */ 35/* available since kernel version 2.6.36 */
36#define FW_CDEV_EVENT_REQUEST2 0x06 36#define FW_CDEV_EVENT_REQUEST2 0x06
37#define FW_CDEV_EVENT_PHY_PACKET_SENT 0x07
37 38
38/** 39/**
39 * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types 40 * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types
@@ -284,6 +285,19 @@ struct fw_cdev_event_iso_resource {
284}; 285};
285 286
286/** 287/**
288 * struct fw_cdev_event_phy_packet - A PHY packet was transmitted
289 * @closure: See &fw_cdev_event_common;
290 * set by %FW_CDEV_IOC_SEND_PHY_PACKET ioctl
291 * @type: %FW_CDEV_EVENT_PHY_PACKET_SENT
292 * @rcode: %RCODE_..., indicates success or failure of transmission
293 */
294struct fw_cdev_event_phy_packet {
295 __u64 closure;
296 __u32 type;
297 __u32 rcode;
298};
299
300/**
287 * union fw_cdev_event - Convenience union of fw_cdev_event_ types 301 * union fw_cdev_event - Convenience union of fw_cdev_event_ types
288 * @common: Valid for all types 302 * @common: Valid for all types
289 * @bus_reset: Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET 303 * @bus_reset: Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET
@@ -294,6 +308,7 @@ struct fw_cdev_event_iso_resource {
294 * @iso_resource: Valid if @common.type == 308 * @iso_resource: Valid if @common.type ==
295 * %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or 309 * %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or
296 * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 310 * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED
311 * @phy_packet: Valid if @common.type == %FW_CDEV_EVENT_PHY_PACKET_SENT
297 * 312 *
298 * Convenience union for userspace use. Events could be read(2) into an 313 * Convenience union for userspace use. Events could be read(2) into an
299 * appropriately aligned char buffer and then cast to this union for further 314 * appropriately aligned char buffer and then cast to this union for further
@@ -311,6 +326,7 @@ union fw_cdev_event {
311 struct fw_cdev_event_request2 request2; /* added in 2.6.36 */ 326 struct fw_cdev_event_request2 request2; /* added in 2.6.36 */
312 struct fw_cdev_event_iso_interrupt iso_interrupt; 327 struct fw_cdev_event_iso_interrupt iso_interrupt;
313 struct fw_cdev_event_iso_resource iso_resource; /* added in 2.6.30 */ 328 struct fw_cdev_event_iso_resource iso_resource; /* added in 2.6.30 */
329 struct fw_cdev_event_phy_packet phy_packet; /* added in 2.6.36 */
314}; 330};
315 331
316/* available since kernel version 2.6.22 */ 332/* available since kernel version 2.6.22 */
@@ -342,6 +358,9 @@ union fw_cdev_event {
342/* available since kernel version 2.6.34 */ 358/* available since kernel version 2.6.34 */
343#define FW_CDEV_IOC_GET_CYCLE_TIMER2 _IOWR('#', 0x14, struct fw_cdev_get_cycle_timer2) 359#define FW_CDEV_IOC_GET_CYCLE_TIMER2 _IOWR('#', 0x14, struct fw_cdev_get_cycle_timer2)
344 360
361/* available since kernel version 2.6.36 */
362#define FW_CDEV_IOC_SEND_PHY_PACKET _IOWR('#', 0x15, struct fw_cdev_send_phy_packet)
363
345/* 364/*
346 * ABI version history 365 * ABI version history
347 * 1 (2.6.22) - initial version 366 * 1 (2.6.22) - initial version
@@ -357,8 +376,9 @@ union fw_cdev_event {
357 * - shared use and auto-response for FCP registers 376 * - shared use and auto-response for FCP registers
358 * 3 (2.6.34) - made &fw_cdev_get_cycle_timer reliable 377 * 3 (2.6.34) - made &fw_cdev_get_cycle_timer reliable
359 * - added %FW_CDEV_IOC_GET_CYCLE_TIMER2 378 * - added %FW_CDEV_IOC_GET_CYCLE_TIMER2
360 * 4 (2.6.36) - added %FW_CDEV_EVENT_REQUEST2 379 * 4 (2.6.36) - added %FW_CDEV_EVENT_REQUEST2, %FW_CDEV_EVENT_PHY_PACKET_SENT
361 * - implemented &fw_cdev_event_bus_reset.bm_node_id 380 * - implemented &fw_cdev_event_bus_reset.bm_node_id
381 * - added %FW_CDEV_IOC_SEND_PHY_PACKET
362 */ 382 */
363#define FW_CDEV_VERSION 3 /* Meaningless; don't use this macro. */ 383#define FW_CDEV_VERSION 3 /* Meaningless; don't use this macro. */
364 384
@@ -808,4 +828,26 @@ struct fw_cdev_send_stream_packet {
808 __u32 speed; 828 __u32 speed;
809}; 829};
810 830
831/**
832 * struct fw_cdev_send_phy_packet - send a PHY packet
833 * @closure: Passed back to userspace in the PHY-packet-sent event
834 * @data: First and second quadlet of the PHY packet
835 * @generation: The bus generation where packet is valid
836 *
837 * The %FW_CDEV_IOC_SEND_PHY_PACKET ioctl sends a PHY packet to all nodes
838 * on the same card as this device. After transmission, an
839 * %FW_CDEV_EVENT_PHY_PACKET_SENT event is generated.
840 *
841 * The payload @data[] shall be specified in host byte order. Usually,
842 * @data[1] needs to be the bitwise inverse of @data[0]. VersaPHY packets
843 * are an exception to this rule.
844 *
845 * The ioctl is only permitted on device files which represent a local node.
846 */
847struct fw_cdev_send_phy_packet {
848 __u64 closure;
849 __u32 data[2];
850 __u32 generation;
851};
852
811#endif /* _LINUX_FIREWIRE_CDEV_H */ 853#endif /* _LINUX_FIREWIRE_CDEV_H */