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:51 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2010-07-23 07:36:28 -0400
commitbf54e1462b9192fdef7ea9e2bc44fdc16a4b87bc (patch)
tree31ec8e4e13b76d22b7bf9f93ea620e88911fe416 /include/linux/firewire-cdev.h
parent850bb6f23b93c04ce1e4509a87fa607dc17d97c1 (diff)
firewire: cdev: add PHY packet reception
Add an FW_CDEV_IOC_RECEIVE_PHY_PACKETS ioctl() and FW_CDEV_EVENT_PHY_PACKET_RECEIVED poll()/read() event for /dev/fw*. This can be used to get information from remote PHYs by remote access PHY packets. This is also the 2nd half of the functionality (the receive part) to support a userspace implementation of a VersaPHY transaction layer. Safety considerations: - PHY packets are generally broadcasts, hence some kind of elevated privileges should be required of a process to be able to listen in on 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. Other limitations: - PHY packet reception may be switched on by ioctl() but cannot be switched off again. It would be trivial to provide an off switch, but this is not worth the code. The client should simply close() the fd then, or just ignore further events. - For sake of simplicity of API and kernel-side implementation, no filter per packet content is provided. 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.h39
1 files changed, 32 insertions, 7 deletions
diff --git a/include/linux/firewire-cdev.h b/include/linux/firewire-cdev.h
index 5bc051b9a013..b87409160794 100644
--- a/include/linux/firewire-cdev.h
+++ b/include/linux/firewire-cdev.h
@@ -35,6 +35,7 @@
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#define FW_CDEV_EVENT_PHY_PACKET_SENT 0x07
38#define FW_CDEV_EVENT_PHY_PACKET_RECEIVED 0x08
38 39
39/** 40/**
40 * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types 41 * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types
@@ -285,16 +286,24 @@ struct fw_cdev_event_iso_resource {
285}; 286};
286 287
287/** 288/**
288 * struct fw_cdev_event_phy_packet - A PHY packet was transmitted 289 * struct fw_cdev_event_phy_packet - A PHY packet was transmitted or received
289 * @closure: See &fw_cdev_event_common; 290 * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_PHY_PACKET
290 * set by %FW_CDEV_IOC_SEND_PHY_PACKET ioctl 291 * or %FW_CDEV_IOC_RECEIVE_PHY_PACKETS ioctl
291 * @type: %FW_CDEV_EVENT_PHY_PACKET_SENT 292 * @type: %FW_CDEV_EVENT_PHY_PACKET_SENT or %..._RECEIVED
292 * @rcode: %RCODE_..., indicates success or failure of transmission 293 * @rcode: %RCODE_..., indicates success or failure of transmission
294 * @length: Data length in bytes
295 * @data: Incoming data
296 *
297 * If @type is %FW_CDEV_EVENT_PHY_PACKET_SENT, @length is 0 and @data empty.
298 * If @type is %FW_CDEV_EVENT_PHY_PACKET_RECEIVED, @length is 8 and @data
299 * consists of the two PHY packet quadlets, in host byte order.
293 */ 300 */
294struct fw_cdev_event_phy_packet { 301struct fw_cdev_event_phy_packet {
295 __u64 closure; 302 __u64 closure;
296 __u32 type; 303 __u32 type;
297 __u32 rcode; 304 __u32 rcode;
305 __u32 length;
306 __u32 data[0];
298}; 307};
299 308
300/** 309/**
@@ -308,7 +317,9 @@ struct fw_cdev_event_phy_packet {
308 * @iso_resource: Valid if @common.type == 317 * @iso_resource: Valid if @common.type ==
309 * %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or 318 * %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or
310 * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 319 * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED
311 * @phy_packet: Valid if @common.type == %FW_CDEV_EVENT_PHY_PACKET_SENT 320 * @phy_packet: Valid if @common.type ==
321 * %FW_CDEV_EVENT_PHY_PACKET_SENT or
322 * %FW_CDEV_EVENT_PHY_PACKET_RECEIVED
312 * 323 *
313 * Convenience union for userspace use. Events could be read(2) into an 324 * Convenience union for userspace use. Events could be read(2) into an
314 * appropriately aligned char buffer and then cast to this union for further 325 * appropriately aligned char buffer and then cast to this union for further
@@ -360,6 +371,7 @@ union fw_cdev_event {
360 371
361/* available since kernel version 2.6.36 */ 372/* available since kernel version 2.6.36 */
362#define FW_CDEV_IOC_SEND_PHY_PACKET _IOWR('#', 0x15, struct fw_cdev_send_phy_packet) 373#define FW_CDEV_IOC_SEND_PHY_PACKET _IOWR('#', 0x15, struct fw_cdev_send_phy_packet)
374#define FW_CDEV_IOC_RECEIVE_PHY_PACKETS _IOW('#', 0x16, struct fw_cdev_receive_phy_packets)
363 375
364/* 376/*
365 * ABI version history 377 * ABI version history
@@ -376,9 +388,9 @@ union fw_cdev_event {
376 * - shared use and auto-response for FCP registers 388 * - shared use and auto-response for FCP registers
377 * 3 (2.6.34) - made &fw_cdev_get_cycle_timer reliable 389 * 3 (2.6.34) - made &fw_cdev_get_cycle_timer reliable
378 * - added %FW_CDEV_IOC_GET_CYCLE_TIMER2 390 * - added %FW_CDEV_IOC_GET_CYCLE_TIMER2
379 * 4 (2.6.36) - added %FW_CDEV_EVENT_REQUEST2, %FW_CDEV_EVENT_PHY_PACKET_SENT 391 * 4 (2.6.36) - added %FW_CDEV_EVENT_REQUEST2, %FW_CDEV_EVENT_PHY_PACKET_*
380 * - implemented &fw_cdev_event_bus_reset.bm_node_id 392 * - implemented &fw_cdev_event_bus_reset.bm_node_id
381 * - added %FW_CDEV_IOC_SEND_PHY_PACKET 393 * - added %FW_CDEV_IOC_SEND_PHY_PACKET, _RECEIVE_PHY_PACKETS
382 */ 394 */
383#define FW_CDEV_VERSION 3 /* Meaningless; don't use this macro. */ 395#define FW_CDEV_VERSION 3 /* Meaningless; don't use this macro. */
384 396
@@ -850,4 +862,17 @@ struct fw_cdev_send_phy_packet {
850 __u32 generation; 862 __u32 generation;
851}; 863};
852 864
865/**
866 * struct fw_cdev_receive_phy_packets - start reception of PHY packets
867 * @closure: Passed back to userspace in phy packet events
868 *
869 * This ioctl activates issuing of %FW_CDEV_EVENT_PHY_PACKET_RECEIVED due to
870 * incoming PHY packets from any node on the same bus as the device.
871 *
872 * The ioctl is only permitted on device files which represent a local node.
873 */
874struct fw_cdev_receive_phy_packets {
875 __u64 closure;
876};
877
853#endif /* _LINUX_FIREWIRE_CDEV_H */ 878#endif /* _LINUX_FIREWIRE_CDEV_H */