ieee1394: move some comments from declaration to definition
[linux-2.6] / drivers / ieee1394 / ieee1394_core.h
1 #ifndef _IEEE1394_CORE_H
2 #define _IEEE1394_CORE_H
3
4 #include <linux/device.h>
5 #include <linux/fs.h>
6 #include <linux/list.h>
7 #include <linux/skbuff.h>
8 #include <linux/types.h>
9 #include <asm/atomic.h>
10
11 #include "hosts.h"
12 #include "ieee1394_types.h"
13
14 struct hpsb_packet {
15         /* This struct is basically read-only for hosts with the exception of
16          * the data buffer contents and xnext - see below. */
17
18         /* This can be used for host driver internal linking.
19          *
20          * NOTE: This must be left in init state when the driver is done
21          * with it (e.g. by using list_del_init()), since the core does
22          * some sanity checks to make sure the packet is not on a
23          * driver_list when free'ing it. */
24         struct list_head driver_list;
25
26         nodeid_t node_id;
27
28         /* Async and Iso types should be clear, raw means send-as-is, do not
29          * CRC!  Byte swapping shall still be done in this case. */
30         enum { hpsb_async, hpsb_iso, hpsb_raw } __attribute__((packed)) type;
31
32         /* Okay, this is core internal and a no care for hosts.
33          * queued   = queued for sending
34          * pending  = sent, waiting for response
35          * complete = processing completed, successful or not
36          */
37         enum {
38                 hpsb_unused, hpsb_queued, hpsb_pending, hpsb_complete
39         } __attribute__((packed)) state;
40
41         /* These are core internal. */
42         signed char tlabel;
43         signed char ack_code;
44         unsigned char tcode;
45
46         unsigned expect_response:1;
47         unsigned no_waiter:1;
48
49         /* Speed to transmit with: 0 = 100Mbps, 1 = 200Mbps, 2 = 400Mbps */
50         unsigned speed_code:2;
51
52         /*
53          * *header and *data are guaranteed to be 32-bit DMAable and may be
54          * overwritten to allow in-place byte swapping.  Neither of these is
55          * CRCed (the sizes also don't include CRC), but contain space for at
56          * least one additional quadlet to allow in-place CRCing.  The memory is
57          * also guaranteed to be DMA mappable.
58          */
59         quadlet_t *header;
60         quadlet_t *data;
61         size_t header_size;
62         size_t data_size;
63
64         struct hpsb_host *host;
65         unsigned int generation;
66
67         atomic_t refcnt;
68
69         /* Function (and possible data to pass to it) to call when this
70          * packet is completed.  */
71         void (*complete_routine)(void *);
72         void *complete_data;
73
74         /* XXX This is just a hack at the moment */
75         struct sk_buff *skb;
76
77         /* Store jiffies for implementing bus timeouts. */
78         unsigned long sendtime;
79
80         quadlet_t embedded_header[5];
81 };
82
83 void hpsb_set_packet_complete_task(struct hpsb_packet *packet,
84                                    void (*routine)(void *), void *data);
85 static inline struct hpsb_packet *driver_packet(struct list_head *l)
86 {
87         return list_entry(l, struct hpsb_packet, driver_list);
88 }
89 void abort_timedouts(unsigned long __opaque);
90 struct hpsb_packet *hpsb_alloc_packet(size_t data_size);
91 void hpsb_free_packet(struct hpsb_packet *packet);
92
93 /**
94  * get_hpsb_generation - generation counter for the complete 1394 subsystem
95  *
96  * Generation gets incremented on every change in the subsystem (notably on bus
97  * resets). Use the functions, not the variable.
98  */
99 static inline unsigned int get_hpsb_generation(struct hpsb_host *host)
100 {
101         return atomic_read(&host->generation);
102 }
103
104 int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt);
105 int hpsb_send_packet(struct hpsb_packet *packet);
106 int hpsb_send_packet_and_wait(struct hpsb_packet *packet);
107 int hpsb_reset_bus(struct hpsb_host *host, int type);
108 int hpsb_read_cycle_timer(struct hpsb_host *host, u32 *cycle_timer,
109                           u64 *local_time);
110
111 int hpsb_bus_reset(struct hpsb_host *host);
112 void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid);
113 void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot);
114 void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
115                       int ackcode);
116 void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
117                           int write_acked);
118
119 /*
120  * CHARACTER DEVICE DISPATCHING
121  *
122  * All ieee1394 character device drivers share the same major number
123  * (major 171).  The 256 minor numbers are allocated to the various
124  * task-specific interfaces (raw1394, video1394, dv1394, etc) in
125  * blocks of 16.
126  *
127  * The core ieee1394.o module allocates the device number region
128  * 171:0-255, the various drivers must then cdev_add() their cdev
129  * objects to handle their respective sub-regions.
130  *
131  * Minor device number block allocations:
132  *
133  * Block 0  (  0- 15)  raw1394
134  * Block 1  ( 16- 31)  video1394
135  * Block 2  ( 32- 47)  dv1394
136  *
137  * Blocks 3-14 free for future allocation
138  *
139  * Block 15 (240-255)  reserved for drivers under development, etc.
140  */
141
142 #define IEEE1394_MAJOR                   171
143
144 #define IEEE1394_MINOR_BLOCK_RAW1394       0
145 #define IEEE1394_MINOR_BLOCK_VIDEO1394     1
146 #define IEEE1394_MINOR_BLOCK_DV1394        2
147 #define IEEE1394_MINOR_BLOCK_EXPERIMENTAL 15
148
149 #define IEEE1394_CORE_DEV         MKDEV(IEEE1394_MAJOR, 0)
150 #define IEEE1394_RAW1394_DEV      MKDEV(IEEE1394_MAJOR, \
151                                         IEEE1394_MINOR_BLOCK_RAW1394 * 16)
152 #define IEEE1394_VIDEO1394_DEV    MKDEV(IEEE1394_MAJOR, \
153                                         IEEE1394_MINOR_BLOCK_VIDEO1394 * 16)
154 #define IEEE1394_DV1394_DEV       MKDEV(IEEE1394_MAJOR, \
155                                         IEEE1394_MINOR_BLOCK_DV1394 * 16)
156 #define IEEE1394_EXPERIMENTAL_DEV MKDEV(IEEE1394_MAJOR, \
157                                         IEEE1394_MINOR_BLOCK_EXPERIMENTAL * 16)
158
159 /**
160  * ieee1394_file_to_instance - get the index within a minor number block
161  */
162 static inline unsigned char ieee1394_file_to_instance(struct file *file)
163 {
164         return file->f_path.dentry->d_inode->i_cindex;
165 }
166
167 extern int hpsb_disable_irm;
168
169 /* Our sysfs bus entry */
170 extern struct bus_type ieee1394_bus_type;
171 extern struct class hpsb_host_class;
172 extern struct class *hpsb_protocol_class;
173
174 #endif /* _IEEE1394_CORE_H */