]>
Commit | Line | Data |
---|---|---|
32af9434 MW |
1 | /* |
2 | * Thunderbolt control channel messages | |
3 | * | |
4 | * Copyright (C) 2014 Andreas Noever <andreas.noever@gmail.com> | |
5 | * Copyright (C) 2017, Intel Corporation | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License version 2 as | |
9 | * published by the Free Software Foundation. | |
10 | */ | |
11 | ||
12 | #ifndef _TB_MSGS | |
13 | #define _TB_MSGS | |
14 | ||
15 | #include <linux/types.h> | |
f67cf491 | 16 | #include <linux/uuid.h> |
32af9434 MW |
17 | |
18 | enum tb_cfg_pkg_type { | |
19 | TB_CFG_PKG_READ = 1, | |
20 | TB_CFG_PKG_WRITE = 2, | |
21 | TB_CFG_PKG_ERROR = 3, | |
22 | TB_CFG_PKG_NOTIFY_ACK = 4, | |
23 | TB_CFG_PKG_EVENT = 5, | |
24 | TB_CFG_PKG_XDOMAIN_REQ = 6, | |
25 | TB_CFG_PKG_XDOMAIN_RESP = 7, | |
26 | TB_CFG_PKG_OVERRIDE = 8, | |
27 | TB_CFG_PKG_RESET = 9, | |
f67cf491 MW |
28 | TB_CFG_PKG_ICM_EVENT = 10, |
29 | TB_CFG_PKG_ICM_CMD = 11, | |
30 | TB_CFG_PKG_ICM_RESP = 12, | |
32af9434 MW |
31 | TB_CFG_PKG_PREPARE_TO_SLEEP = 0xd, |
32 | ||
33 | }; | |
34 | ||
35 | enum tb_cfg_space { | |
36 | TB_CFG_HOPS = 0, | |
37 | TB_CFG_PORT = 1, | |
38 | TB_CFG_SWITCH = 2, | |
39 | TB_CFG_COUNTERS = 3, | |
40 | }; | |
41 | ||
42 | enum tb_cfg_error { | |
43 | TB_CFG_ERROR_PORT_NOT_CONNECTED = 0, | |
44 | TB_CFG_ERROR_LINK_ERROR = 1, | |
45 | TB_CFG_ERROR_INVALID_CONFIG_SPACE = 2, | |
46 | TB_CFG_ERROR_NO_SUCH_PORT = 4, | |
47 | TB_CFG_ERROR_ACK_PLUG_EVENT = 7, /* send as reply to TB_CFG_PKG_EVENT */ | |
48 | TB_CFG_ERROR_LOOP = 8, | |
49 | TB_CFG_ERROR_HEC_ERROR_DETECTED = 12, | |
50 | TB_CFG_ERROR_FLOW_CONTROL_ERROR = 13, | |
51 | }; | |
52 | ||
53 | /* common header */ | |
54 | struct tb_cfg_header { | |
55 | u32 route_hi:22; | |
56 | u32 unknown:10; /* highest order bit is set on replies */ | |
57 | u32 route_lo; | |
58 | } __packed; | |
59 | ||
60 | /* additional header for read/write packets */ | |
61 | struct tb_cfg_address { | |
62 | u32 offset:13; /* in dwords */ | |
63 | u32 length:6; /* in dwords */ | |
64 | u32 port:6; | |
65 | enum tb_cfg_space space:2; | |
66 | u32 seq:2; /* sequence number */ | |
67 | u32 zero:3; | |
68 | } __packed; | |
69 | ||
70 | /* TB_CFG_PKG_READ, response for TB_CFG_PKG_WRITE */ | |
71 | struct cfg_read_pkg { | |
72 | struct tb_cfg_header header; | |
73 | struct tb_cfg_address addr; | |
74 | } __packed; | |
75 | ||
76 | /* TB_CFG_PKG_WRITE, response for TB_CFG_PKG_READ */ | |
77 | struct cfg_write_pkg { | |
78 | struct tb_cfg_header header; | |
79 | struct tb_cfg_address addr; | |
80 | u32 data[64]; /* maximum size, tb_cfg_address.length has 6 bits */ | |
81 | } __packed; | |
82 | ||
83 | /* TB_CFG_PKG_ERROR */ | |
84 | struct cfg_error_pkg { | |
85 | struct tb_cfg_header header; | |
86 | enum tb_cfg_error error:4; | |
87 | u32 zero1:4; | |
88 | u32 port:6; | |
89 | u32 zero2:2; /* Both should be zero, still they are different fields. */ | |
90 | u32 zero3:16; | |
91 | } __packed; | |
92 | ||
93 | /* TB_CFG_PKG_EVENT */ | |
94 | struct cfg_event_pkg { | |
95 | struct tb_cfg_header header; | |
96 | u32 port:6; | |
97 | u32 zero:25; | |
98 | bool unplug:1; | |
99 | } __packed; | |
100 | ||
101 | /* TB_CFG_PKG_RESET */ | |
102 | struct cfg_reset_pkg { | |
103 | struct tb_cfg_header header; | |
104 | } __packed; | |
105 | ||
106 | /* TB_CFG_PKG_PREPARE_TO_SLEEP */ | |
107 | struct cfg_pts_pkg { | |
108 | struct tb_cfg_header header; | |
109 | u32 data; | |
110 | } __packed; | |
111 | ||
f67cf491 MW |
112 | /* ICM messages */ |
113 | ||
114 | enum icm_pkg_code { | |
115 | ICM_GET_TOPOLOGY = 0x1, | |
116 | ICM_DRIVER_READY = 0x3, | |
117 | ICM_APPROVE_DEVICE = 0x4, | |
118 | ICM_CHALLENGE_DEVICE = 0x5, | |
119 | ICM_ADD_DEVICE_KEY = 0x6, | |
120 | ICM_GET_ROUTE = 0xa, | |
121 | }; | |
122 | ||
123 | enum icm_event_code { | |
124 | ICM_EVENT_DEVICE_CONNECTED = 3, | |
125 | ICM_EVENT_DEVICE_DISCONNECTED = 4, | |
126 | }; | |
127 | ||
128 | struct icm_pkg_header { | |
129 | u8 code; | |
130 | u8 flags; | |
131 | u8 packet_id; | |
132 | u8 total_packets; | |
133 | } __packed; | |
134 | ||
135 | #define ICM_FLAGS_ERROR BIT(0) | |
136 | #define ICM_FLAGS_NO_KEY BIT(1) | |
137 | #define ICM_FLAGS_SLEVEL_SHIFT 3 | |
138 | #define ICM_FLAGS_SLEVEL_MASK GENMASK(4, 3) | |
139 | ||
140 | struct icm_pkg_driver_ready { | |
141 | struct icm_pkg_header hdr; | |
142 | } __packed; | |
143 | ||
144 | struct icm_pkg_driver_ready_response { | |
145 | struct icm_pkg_header hdr; | |
146 | u8 romver; | |
147 | u8 ramver; | |
148 | u16 security_level; | |
149 | } __packed; | |
150 | ||
151 | /* Falcon Ridge & Alpine Ridge common messages */ | |
152 | ||
153 | struct icm_fr_pkg_get_topology { | |
154 | struct icm_pkg_header hdr; | |
155 | } __packed; | |
156 | ||
157 | #define ICM_GET_TOPOLOGY_PACKETS 14 | |
158 | ||
159 | struct icm_fr_pkg_get_topology_response { | |
160 | struct icm_pkg_header hdr; | |
161 | u32 route_lo; | |
162 | u32 route_hi; | |
163 | u8 first_data; | |
164 | u8 second_data; | |
165 | u8 drom_i2c_address_index; | |
166 | u8 switch_index; | |
167 | u32 reserved[2]; | |
168 | u32 ports[16]; | |
169 | u32 port_hop_info[16]; | |
170 | } __packed; | |
171 | ||
172 | #define ICM_SWITCH_USED BIT(0) | |
173 | #define ICM_SWITCH_UPSTREAM_PORT_MASK GENMASK(7, 1) | |
174 | #define ICM_SWITCH_UPSTREAM_PORT_SHIFT 1 | |
175 | ||
176 | #define ICM_PORT_TYPE_MASK GENMASK(23, 0) | |
177 | #define ICM_PORT_INDEX_SHIFT 24 | |
178 | #define ICM_PORT_INDEX_MASK GENMASK(31, 24) | |
179 | ||
180 | struct icm_fr_event_device_connected { | |
181 | struct icm_pkg_header hdr; | |
182 | uuid_be ep_uuid; | |
183 | u8 connection_key; | |
184 | u8 connection_id; | |
185 | u16 link_info; | |
186 | u32 ep_name[55]; | |
187 | } __packed; | |
188 | ||
189 | #define ICM_LINK_INFO_LINK_MASK 0x7 | |
190 | #define ICM_LINK_INFO_DEPTH_SHIFT 4 | |
191 | #define ICM_LINK_INFO_DEPTH_MASK GENMASK(7, 4) | |
192 | #define ICM_LINK_INFO_APPROVED BIT(8) | |
193 | ||
194 | struct icm_fr_pkg_approve_device { | |
195 | struct icm_pkg_header hdr; | |
196 | uuid_be ep_uuid; | |
197 | u8 connection_key; | |
198 | u8 connection_id; | |
199 | u16 reserved; | |
200 | } __packed; | |
201 | ||
202 | struct icm_fr_event_device_disconnected { | |
203 | struct icm_pkg_header hdr; | |
204 | u16 reserved; | |
205 | u16 link_info; | |
206 | } __packed; | |
207 | ||
208 | struct icm_fr_pkg_add_device_key { | |
209 | struct icm_pkg_header hdr; | |
210 | uuid_be ep_uuid; | |
211 | u8 connection_key; | |
212 | u8 connection_id; | |
213 | u16 reserved; | |
214 | u32 key[8]; | |
215 | } __packed; | |
216 | ||
217 | struct icm_fr_pkg_add_device_key_response { | |
218 | struct icm_pkg_header hdr; | |
219 | uuid_be ep_uuid; | |
220 | u8 connection_key; | |
221 | u8 connection_id; | |
222 | u16 reserved; | |
223 | } __packed; | |
224 | ||
225 | struct icm_fr_pkg_challenge_device { | |
226 | struct icm_pkg_header hdr; | |
227 | uuid_be ep_uuid; | |
228 | u8 connection_key; | |
229 | u8 connection_id; | |
230 | u16 reserved; | |
231 | u32 challenge[8]; | |
232 | } __packed; | |
233 | ||
234 | struct icm_fr_pkg_challenge_device_response { | |
235 | struct icm_pkg_header hdr; | |
236 | uuid_be ep_uuid; | |
237 | u8 connection_key; | |
238 | u8 connection_id; | |
239 | u16 reserved; | |
240 | u32 challenge[8]; | |
241 | u32 response[8]; | |
242 | } __packed; | |
243 | ||
244 | /* Alpine Ridge only messages */ | |
245 | ||
246 | struct icm_ar_pkg_get_route { | |
247 | struct icm_pkg_header hdr; | |
248 | u16 reserved; | |
249 | u16 link_info; | |
250 | } __packed; | |
251 | ||
252 | struct icm_ar_pkg_get_route_response { | |
253 | struct icm_pkg_header hdr; | |
254 | u16 reserved; | |
255 | u16 link_info; | |
256 | u32 route_hi; | |
257 | u32 route_lo; | |
258 | } __packed; | |
259 | ||
32af9434 | 260 | #endif |