summaryrefslogtreecommitdiffstats
path: root/tools/firewire/nosy-dump.h
blob: 3a4b5b33ba5d3a8e8e7936a119d40bec0c0e40da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#ifndef __nosy_dump_h__
#define __nosy_dump_h__

#define array_length(array) (sizeof(array) / sizeof(array[0]))

#define ACK_NO_ACK   0x0
#define ACK_DONE(a)  ((a >> 2) == 0)
#define ACK_BUSY(a)  ((a >> 2) == 1)
#define ACK_ERROR(a) ((a >> 2) == 3)

#include <stdint.h>

struct phy_packet {
	uint32_t timestamp;
	union {
		struct {
			uint32_t zero:24;
			uint32_t phy_id:6;
			uint32_t identifier:2;
		} common, link_on;

		struct {
			uint32_t zero:16;
			uint32_t gap_count:6;
			uint32_t set_gap_count:1;
			uint32_t set_root:1;
			uint32_t root_id:6;
			uint32_t identifier:2;
		} phy_config;

		struct {
			uint32_t more_packets:1;
			uint32_t initiated_reset:1;
			uint32_t port2:2;
			uint32_t port1:2;
			uint32_t port0:2;
			uint32_t power_class:3;
			uint32_t contender:1;
			uint32_t phy_delay:2;
			uint32_t phy_speed:2;
			uint32_t gap_count:6;
			uint32_t link_active:1;
			uint32_t extended:1;
			uint32_t phy_id:6;
			uint32_t identifier:2;
		} self_id;

		struct {
			uint32_t more_packets:1;
			uint32_t reserved1:1;
			uint32_t porth:2;
			uint32_t portg:2;
			uint32_t portf:2;
			uint32_t porte:2;
			uint32_t portd:2;
			uint32_t portc:2;
			uint32_t portb:2;
			uint32_t porta:2;
			uint32_t reserved0:2;
			uint32_t sequence:3;
			uint32_t extended:1;
			uint32_t phy_id:6;
			uint32_t identifier:2;
		} ext_self_id;
	};
	uint32_t inverted;
	uint32_t ack;
};

#define TCODE_PHY_PACKET 0x10

#define PHY_PACKET_CONFIGURATION 0x00
#define PHY_PACKET_LINK_ON 0x01
#define PHY_PACKET_SELF_ID 0x02

struct link_packet {
	uint32_t timestamp;
	union {
		struct {
			uint32_t priority:4;
			uint32_t tcode:4;
			uint32_t rt:2;
			uint32_t tlabel:6;
			uint32_t destination:16;

			uint32_t offset_high:16;
			uint32_t source:16;

			uint32_t offset_low;
		} common;

		struct {
			uint32_t common[3];
			uint32_t crc;
		} read_quadlet;

		struct {
			uint32_t common[3];
			uint32_t data;
			uint32_t crc;
		} read_quadlet_response;

		struct {
			uint32_t common[3];
			uint32_t extended_tcode:16;
			uint32_t data_length:16;
			uint32_t crc;
		} read_block;

		struct {
			uint32_t common[3];
			uint32_t extended_tcode:16;
			uint32_t data_length:16;
			uint32_t crc;
			uint32_t data[0];
			/* crc and ack follows. */
		} read_block_response;

		struct {
			uint32_t common[3];
			uint32_t data;
			uint32_t crc;
		} write_quadlet;

		struct {
			uint32_t common[3];
			uint32_t extended_tcode:16;
			uint32_t data_length:16;
			uint32_t crc;
			uint32_t data[0];
			/* crc and ack follows. */
		} write_block;

		struct {
			uint32_t common[3];
			uint32_t crc;
		} write_response;

		struct {
			uint32_t common[3];
			uint32_t data;
			uint32_t crc;
		} cycle_start;

		struct {
			uint32_t sy:4;
			uint32_t tcode:4;
			uint32_t channel:6;
			uint32_t tag:2;
			uint32_t data_length:16;

			uint32_t crc;
		} iso_data;
	};
};

struct subaction {
	uint32_t ack;
	size_t length;
	struct list link;
	struct link_packet packet;
};

struct link_transaction {
	int request_node, response_node, tlabel;
	struct subaction *request, *response;
	struct list request_list, response_list;
	struct list link;
};

int decode_fcp(struct link_transaction *t);

#endif /* __nosy_dump_h__ */