fe8be630efaab3bce22454d32faaefd6219b2b0d
[linux-3.10.git] / tools / firewire / nosy-dump.h
1 #ifndef __nosy_dump_h__
2 #define __nosy_dump_h__
3
4 #define array_length(array) (sizeof(array) / sizeof(array[0]))
5
6 #define TCODE_WRITE_QUADLET         0x0
7 #define TCODE_WRITE_BLOCK           0x1
8 #define TCODE_WRITE_RESPONSE        0x2
9 #define TCODE_READ_QUADLET          0x4
10 #define TCODE_READ_BLOCK            0x5
11 #define TCODE_READ_QUADLET_RESPONSE 0x6
12 #define TCODE_READ_BLOCK_RESPONSE   0x7
13 #define TCODE_CYCLE_START           0x8
14 #define TCODE_LOCK_REQUEST          0x9
15 #define TCODE_ISO_DATA              0xa
16 #define TCODE_LOCK_RESPONSE         0xb
17 #define TCODE_PHY_PACKET            0x10
18
19 #define ACK_NO_ACK               0x0
20 #define ACK_COMPLETE             0x1
21 #define ACK_PENDING              0x2
22 #define ACK_BUSY_X               0x4
23 #define ACK_BUSY_A               0x5
24 #define ACK_BUSY_B               0x6
25 #define ACK_DATA_ERROR           0xd
26 #define ACK_TYPE_ERROR           0xe 
27
28 #define ACK_DONE(a)  ((a >> 2) == 0)
29 #define ACK_BUSY(a)  ((a >> 2) == 1)
30 #define ACK_ERROR(a) ((a >> 2) == 3)
31
32 #define SPEED_100                0x0
33 #define SPEED_200                0x1
34 #define SPEED_400                0x2
35
36 #include <stdint.h>
37
38 struct phy_packet {
39         uint32_t timestamp;
40         union {
41                 struct {
42                         uint32_t zero:24;
43                         uint32_t phy_id:6;
44                         uint32_t identifier:2;
45                 } common, link_on;
46
47                 struct {
48                         uint32_t zero:16;
49                         uint32_t gap_count:6;
50                         uint32_t set_gap_count:1;
51                         uint32_t set_root:1;
52                         uint32_t root_id:6;
53                         uint32_t identifier:2;
54                 } phy_config;
55
56                 struct {
57                         uint32_t more_packets:1;
58                         uint32_t initiated_reset:1;
59                         uint32_t port2:2;
60                         uint32_t port1:2;
61                         uint32_t port0:2;
62                         uint32_t power_class:3;
63                         uint32_t contender:1;
64                         uint32_t phy_delay:2;
65                         uint32_t phy_speed:2;
66                         uint32_t gap_count:6;
67                         uint32_t link_active:1;
68                         uint32_t extended:1;
69                         uint32_t phy_id:6;
70                         uint32_t identifier:2;
71                 } self_id;
72
73                 struct {
74                         uint32_t more_packets:1;
75                         uint32_t reserved1:1;
76                         uint32_t porth:2;
77                         uint32_t portg:2;
78                         uint32_t portf:2;
79                         uint32_t porte:2;
80                         uint32_t portd:2;
81                         uint32_t portc:2;
82                         uint32_t portb:2;
83                         uint32_t porta:2;
84                         uint32_t reserved0:2;
85                         uint32_t sequence:3;
86                         uint32_t extended:1;
87                         uint32_t phy_id:6;
88                         uint32_t identifier:2;
89                 } ext_self_id;
90         };
91         uint32_t inverted;
92         uint32_t ack;
93 };
94
95 #define PHY_PACKET_CONFIGURATION 0x00
96 #define PHY_PACKET_LINK_ON 0x01
97 #define PHY_PACKET_SELF_ID 0x02
98
99 struct link_packet {
100         uint32_t timestamp;
101         union {
102                 struct {
103                         uint32_t priority:4;
104                         uint32_t tcode:4;
105                         uint32_t rt:2;
106                         uint32_t tlabel:6;
107                         uint32_t destination:16;
108
109                         uint32_t offset_high:16;
110                         uint32_t source:16;
111
112                         uint32_t offset_low;
113                 } common;
114
115                 struct {
116                         uint32_t common[3];
117                         uint32_t crc;
118                 } read_quadlet;
119
120                 struct {
121                         uint32_t common[3];
122                         uint32_t data;
123                         uint32_t crc;
124                 } read_quadlet_response;
125
126                 struct {
127                         uint32_t common[3];
128                         uint32_t extended_tcode:16;
129                         uint32_t data_length:16;
130                         uint32_t crc;
131                 } read_block;
132
133                 struct {
134                         uint32_t common[3];
135                         uint32_t extended_tcode:16;
136                         uint32_t data_length:16;
137                         uint32_t crc;
138                         uint32_t data[0];
139                         /* crc and ack follows. */
140                 } read_block_response;
141
142                 struct {
143                         uint32_t common[3];
144                         uint32_t data;
145                         uint32_t crc;
146                 } write_quadlet;
147
148                 struct {
149                         uint32_t common[3];
150                         uint32_t extended_tcode:16;
151                         uint32_t data_length:16;
152                         uint32_t crc;
153                         uint32_t data[0];
154                         /* crc and ack follows. */
155                 } write_block;
156
157                 struct {
158                         uint32_t common[3];
159                         uint32_t crc;
160                 } write_response;
161
162                 struct {
163                         uint32_t common[3];
164                         uint32_t data;
165                         uint32_t crc;
166                 } cycle_start;
167
168                 struct {
169                         uint32_t sy:4;
170                         uint32_t tcode:4;
171                         uint32_t channel:6;
172                         uint32_t tag:2;
173                         uint32_t data_length:16;
174
175                         uint32_t crc;
176                 } iso_data;
177         };
178 };
179
180 struct subaction {
181         uint32_t ack;
182         size_t length;
183         struct list link;
184         struct link_packet packet;
185 };
186
187 struct link_transaction {
188         int request_node, response_node, tlabel;
189         struct subaction *request, *response;
190         struct list request_list, response_list;
191         struct list link;
192 };
193
194 int decode_fcp(struct link_transaction *t);
195
196 #endif /* __nosy_dump_h__ */