blob: 60cf556e228eed6b1329835da200844ae0b809c2 [file] [log] [blame]
Stefan Richter9f6d3c42010-07-22 11:58:05 +02001#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
Stefan Richter1bcc69f2010-07-22 11:58:05 +020036#include <stdint.h>
Stefan Richter9f6d3c42010-07-22 11:58:05 +020037
Stefan Richter1bcc69f2010-07-22 11:58:05 +020038struct phy_packet {
39 uint32_t timestamp;
Stefan Richter9f6d3c42010-07-22 11:58:05 +020040 union {
41 struct {
Stefan Richter1bcc69f2010-07-22 11:58:05 +020042 uint32_t zero:24;
43 uint32_t phy_id:6;
44 uint32_t identifier:2;
Stefan Richter9f6d3c42010-07-22 11:58:05 +020045 } common, link_on;
Stefan Richter1bcc69f2010-07-22 11:58:05 +020046
Stefan Richter9f6d3c42010-07-22 11:58:05 +020047 struct {
Stefan Richter1bcc69f2010-07-22 11:58:05 +020048 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;
Stefan Richter9f6d3c42010-07-22 11:58:05 +020054 } phy_config;
Stefan Richter1bcc69f2010-07-22 11:58:05 +020055
Stefan Richter9f6d3c42010-07-22 11:58:05 +020056 struct {
Stefan Richter1bcc69f2010-07-22 11:58:05 +020057 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;
Stefan Richter9f6d3c42010-07-22 11:58:05 +020071 } self_id;
72
73 struct {
Stefan Richter1bcc69f2010-07-22 11:58:05 +020074 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;
Stefan Richter9f6d3c42010-07-22 11:58:05 +020089 } ext_self_id;
90 };
Stefan Richter1bcc69f2010-07-22 11:58:05 +020091 uint32_t inverted;
92 uint32_t ack;
Stefan Richter9f6d3c42010-07-22 11:58:05 +020093};
94
95#define PHY_PACKET_CONFIGURATION 0x00
96#define PHY_PACKET_LINK_ON 0x01
97#define PHY_PACKET_SELF_ID 0x02
98
99struct link_packet {
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200100 uint32_t timestamp;
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200101 union {
102 struct {
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200103 uint32_t priority:4;
104 uint32_t tcode:4;
105 uint32_t rt:2;
106 uint32_t tlabel:6;
107 uint32_t destination:16;
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200108
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200109 uint32_t offset_high:16;
110 uint32_t source:16;
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200111
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200112 uint32_t offset_low;
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200113 } common;
114
115 struct {
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200116 uint32_t common[3];
117 uint32_t crc;
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200118 } read_quadlet;
119
120 struct {
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200121 uint32_t common[3];
122 uint32_t data;
123 uint32_t crc;
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200124 } read_quadlet_response;
125
126 struct {
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200127 uint32_t common[3];
128 uint32_t extended_tcode:16;
129 uint32_t data_length:16;
130 uint32_t crc;
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200131 } read_block;
132
133 struct {
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200134 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];
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200139 /* crc and ack follows. */
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200140 } read_block_response;
141
142 struct {
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200143 uint32_t common[3];
144 uint32_t data;
145 uint32_t crc;
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200146 } write_quadlet;
147
148 struct {
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200149 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];
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200154 /* crc and ack follows. */
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200155 } write_block;
156
157 struct {
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200158 uint32_t common[3];
159 uint32_t crc;
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200160 } write_response;
161
162 struct {
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200163 uint32_t common[3];
164 uint32_t data;
165 uint32_t crc;
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200166 } cycle_start;
167
168 struct {
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200169 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;
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200174
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200175 uint32_t crc;
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200176 } iso_data;
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200177 };
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200178};
179
180struct subaction {
Stefan Richter1bcc69f2010-07-22 11:58:05 +0200181 uint32_t ack;
Stefan Richter9f6d3c42010-07-22 11:58:05 +0200182 size_t length;
183 struct list link;
184 struct link_packet packet;
185};
186
187struct 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
194int decode_fcp(struct link_transaction *t);
195
196#endif /* __nosy_dump_h__ */