]> Git Repo - linux.git/blob - drivers/thunderbolt/tb_msgs.h
ACPI: CPPC: Adjust debug messages in amd_set_max_freq_ratio() to warn
[linux.git] / drivers / thunderbolt / tb_msgs.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Thunderbolt control channel messages
4  *
5  * Copyright (C) 2014 Andreas Noever <[email protected]>
6  * Copyright (C) 2017, Intel Corporation
7  */
8
9 #ifndef _TB_MSGS
10 #define _TB_MSGS
11
12 #include <linux/types.h>
13 #include <linux/uuid.h>
14
15 enum tb_cfg_space {
16         TB_CFG_HOPS = 0,
17         TB_CFG_PORT = 1,
18         TB_CFG_SWITCH = 2,
19         TB_CFG_COUNTERS = 3,
20 };
21
22 enum tb_cfg_error {
23         TB_CFG_ERROR_PORT_NOT_CONNECTED = 0,
24         TB_CFG_ERROR_LINK_ERROR = 1,
25         TB_CFG_ERROR_INVALID_CONFIG_SPACE = 2,
26         TB_CFG_ERROR_NO_SUCH_PORT = 4,
27         TB_CFG_ERROR_ACK_PLUG_EVENT = 7, /* send as reply to TB_CFG_PKG_EVENT */
28         TB_CFG_ERROR_LOOP = 8,
29         TB_CFG_ERROR_HEC_ERROR_DETECTED = 12,
30         TB_CFG_ERROR_FLOW_CONTROL_ERROR = 13,
31         TB_CFG_ERROR_LOCK = 15,
32         TB_CFG_ERROR_DP_BW = 32,
33         TB_CFG_ERROR_ROP_CMPLT = 33,
34         TB_CFG_ERROR_POP_CMPLT = 34,
35         TB_CFG_ERROR_PCIE_WAKE = 35,
36         TB_CFG_ERROR_DP_CON_CHANGE = 36,
37         TB_CFG_ERROR_DPTX_DISCOVERY = 37,
38         TB_CFG_ERROR_LINK_RECOVERY = 38,
39         TB_CFG_ERROR_ASYM_LINK = 39,
40 };
41
42 /* common header */
43 struct tb_cfg_header {
44         u32 route_hi:22;
45         u32 unknown:10; /* highest order bit is set on replies */
46         u32 route_lo;
47 } __packed;
48
49 /* additional header for read/write packets */
50 struct tb_cfg_address {
51         u32 offset:13; /* in dwords */
52         u32 length:6; /* in dwords */
53         u32 port:6;
54         enum tb_cfg_space space:2;
55         u32 seq:2; /* sequence number  */
56         u32 zero:3;
57 } __packed;
58
59 /* TB_CFG_PKG_READ, response for TB_CFG_PKG_WRITE */
60 struct cfg_read_pkg {
61         struct tb_cfg_header header;
62         struct tb_cfg_address addr;
63 } __packed;
64
65 /* TB_CFG_PKG_WRITE, response for TB_CFG_PKG_READ */
66 struct cfg_write_pkg {
67         struct tb_cfg_header header;
68         struct tb_cfg_address addr;
69         u32 data[64]; /* maximum size, tb_cfg_address.length has 6 bits */
70 } __packed;
71
72 /* TB_CFG_PKG_ERROR */
73 struct cfg_error_pkg {
74         struct tb_cfg_header header;
75         enum tb_cfg_error error:8;
76         u32 port:6;
77         u32 reserved:16;
78         u32 pg:2;
79 } __packed;
80
81 struct cfg_ack_pkg {
82         struct tb_cfg_header header;
83 };
84
85 #define TB_CFG_ERROR_PG_HOT_PLUG        0x2
86 #define TB_CFG_ERROR_PG_HOT_UNPLUG      0x3
87
88 /* TB_CFG_PKG_EVENT */
89 struct cfg_event_pkg {
90         struct tb_cfg_header header;
91         u32 port:6;
92         u32 zero:25;
93         bool unplug:1;
94 } __packed;
95
96 /* TB_CFG_PKG_RESET */
97 struct cfg_reset_pkg {
98         struct tb_cfg_header header;
99 } __packed;
100
101 /* ICM messages */
102
103 enum icm_pkg_code {
104         ICM_GET_TOPOLOGY = 0x1,
105         ICM_DRIVER_READY = 0x3,
106         ICM_APPROVE_DEVICE = 0x4,
107         ICM_CHALLENGE_DEVICE = 0x5,
108         ICM_ADD_DEVICE_KEY = 0x6,
109         ICM_GET_ROUTE = 0xa,
110         ICM_APPROVE_XDOMAIN = 0x10,
111         ICM_DISCONNECT_XDOMAIN = 0x11,
112         ICM_PREBOOT_ACL = 0x18,
113         ICM_USB4_SWITCH_OP = 0x20,
114 };
115
116 enum icm_event_code {
117         ICM_EVENT_DEVICE_CONNECTED = 0x3,
118         ICM_EVENT_DEVICE_DISCONNECTED = 0x4,
119         ICM_EVENT_XDOMAIN_CONNECTED = 0x6,
120         ICM_EVENT_XDOMAIN_DISCONNECTED = 0x7,
121         ICM_EVENT_RTD3_VETO = 0xa,
122 };
123
124 struct icm_pkg_header {
125         u8 code;
126         u8 flags;
127         u8 packet_id;
128         u8 total_packets;
129 };
130
131 #define ICM_FLAGS_ERROR                 BIT(0)
132 #define ICM_FLAGS_NO_KEY                BIT(1)
133 #define ICM_FLAGS_SLEVEL_SHIFT          3
134 #define ICM_FLAGS_SLEVEL_MASK           GENMASK(4, 3)
135 #define ICM_FLAGS_DUAL_LANE             BIT(5)
136 #define ICM_FLAGS_SPEED_GEN3            BIT(7)
137 #define ICM_FLAGS_WRITE                 BIT(7)
138
139 struct icm_pkg_driver_ready {
140         struct icm_pkg_header hdr;
141 };
142
143 /* Falcon Ridge only messages */
144
145 struct icm_fr_pkg_driver_ready_response {
146         struct icm_pkg_header hdr;
147         u8 romver;
148         u8 ramver;
149         u16 security_level;
150 };
151
152 #define ICM_FR_SLEVEL_MASK              0xf
153
154 /* Falcon Ridge & Alpine Ridge common messages */
155
156 struct icm_fr_pkg_get_topology {
157         struct icm_pkg_header hdr;
158 };
159
160 #define ICM_GET_TOPOLOGY_PACKETS        14
161
162 struct icm_fr_pkg_get_topology_response {
163         struct icm_pkg_header hdr;
164         u32 route_lo;
165         u32 route_hi;
166         u8 first_data;
167         u8 second_data;
168         u8 drom_i2c_address_index;
169         u8 switch_index;
170         u32 reserved[2];
171         u32 ports[16];
172         u32 port_hop_info[16];
173 };
174
175 #define ICM_SWITCH_USED                 BIT(0)
176 #define ICM_SWITCH_UPSTREAM_PORT_MASK   GENMASK(7, 1)
177 #define ICM_SWITCH_UPSTREAM_PORT_SHIFT  1
178
179 #define ICM_PORT_TYPE_MASK              GENMASK(23, 0)
180 #define ICM_PORT_INDEX_SHIFT            24
181 #define ICM_PORT_INDEX_MASK             GENMASK(31, 24)
182
183 struct icm_fr_event_device_connected {
184         struct icm_pkg_header hdr;
185         uuid_t ep_uuid;
186         u8 connection_key;
187         u8 connection_id;
188         u16 link_info;
189         u32 ep_name[55];
190 };
191
192 #define ICM_LINK_INFO_LINK_MASK         0x7
193 #define ICM_LINK_INFO_DEPTH_SHIFT       4
194 #define ICM_LINK_INFO_DEPTH_MASK        GENMASK(7, 4)
195 #define ICM_LINK_INFO_APPROVED          BIT(8)
196 #define ICM_LINK_INFO_REJECTED          BIT(9)
197 #define ICM_LINK_INFO_BOOT              BIT(10)
198
199 struct icm_fr_pkg_approve_device {
200         struct icm_pkg_header hdr;
201         uuid_t ep_uuid;
202         u8 connection_key;
203         u8 connection_id;
204         u16 reserved;
205 };
206
207 struct icm_fr_event_device_disconnected {
208         struct icm_pkg_header hdr;
209         u16 reserved;
210         u16 link_info;
211 };
212
213 struct icm_fr_event_xdomain_connected {
214         struct icm_pkg_header hdr;
215         u16 reserved;
216         u16 link_info;
217         uuid_t remote_uuid;
218         uuid_t local_uuid;
219         u32 local_route_hi;
220         u32 local_route_lo;
221         u32 remote_route_hi;
222         u32 remote_route_lo;
223 };
224
225 struct icm_fr_event_xdomain_disconnected {
226         struct icm_pkg_header hdr;
227         u16 reserved;
228         u16 link_info;
229         uuid_t remote_uuid;
230 };
231
232 struct icm_fr_pkg_add_device_key {
233         struct icm_pkg_header hdr;
234         uuid_t ep_uuid;
235         u8 connection_key;
236         u8 connection_id;
237         u16 reserved;
238         u32 key[8];
239 };
240
241 struct icm_fr_pkg_add_device_key_response {
242         struct icm_pkg_header hdr;
243         uuid_t ep_uuid;
244         u8 connection_key;
245         u8 connection_id;
246         u16 reserved;
247 };
248
249 struct icm_fr_pkg_challenge_device {
250         struct icm_pkg_header hdr;
251         uuid_t ep_uuid;
252         u8 connection_key;
253         u8 connection_id;
254         u16 reserved;
255         u32 challenge[8];
256 };
257
258 struct icm_fr_pkg_challenge_device_response {
259         struct icm_pkg_header hdr;
260         uuid_t ep_uuid;
261         u8 connection_key;
262         u8 connection_id;
263         u16 reserved;
264         u32 challenge[8];
265         u32 response[8];
266 };
267
268 struct icm_fr_pkg_approve_xdomain {
269         struct icm_pkg_header hdr;
270         u16 reserved;
271         u16 link_info;
272         uuid_t remote_uuid;
273         u16 transmit_path;
274         u16 transmit_ring;
275         u16 receive_path;
276         u16 receive_ring;
277 };
278
279 struct icm_fr_pkg_approve_xdomain_response {
280         struct icm_pkg_header hdr;
281         u16 reserved;
282         u16 link_info;
283         uuid_t remote_uuid;
284         u16 transmit_path;
285         u16 transmit_ring;
286         u16 receive_path;
287         u16 receive_ring;
288 };
289
290 /* Alpine Ridge only messages */
291
292 struct icm_ar_pkg_driver_ready_response {
293         struct icm_pkg_header hdr;
294         u8 romver;
295         u8 ramver;
296         u16 info;
297 };
298
299 #define ICM_AR_FLAGS_RTD3               BIT(6)
300
301 #define ICM_AR_INFO_SLEVEL_MASK         GENMASK(3, 0)
302 #define ICM_AR_INFO_BOOT_ACL_SHIFT      7
303 #define ICM_AR_INFO_BOOT_ACL_MASK       GENMASK(11, 7)
304 #define ICM_AR_INFO_BOOT_ACL_SUPPORTED  BIT(13)
305
306 struct icm_ar_pkg_get_route {
307         struct icm_pkg_header hdr;
308         u16 reserved;
309         u16 link_info;
310 };
311
312 struct icm_ar_pkg_get_route_response {
313         struct icm_pkg_header hdr;
314         u16 reserved;
315         u16 link_info;
316         u32 route_hi;
317         u32 route_lo;
318 };
319
320 struct icm_ar_boot_acl_entry {
321         u32 uuid_lo;
322         u32 uuid_hi;
323 };
324
325 #define ICM_AR_PREBOOT_ACL_ENTRIES      16
326
327 struct icm_ar_pkg_preboot_acl {
328         struct icm_pkg_header hdr;
329         struct icm_ar_boot_acl_entry acl[ICM_AR_PREBOOT_ACL_ENTRIES];
330 };
331
332 struct icm_ar_pkg_preboot_acl_response {
333         struct icm_pkg_header hdr;
334         struct icm_ar_boot_acl_entry acl[ICM_AR_PREBOOT_ACL_ENTRIES];
335 };
336
337 /* Titan Ridge messages */
338
339 struct icm_tr_pkg_driver_ready_response {
340         struct icm_pkg_header hdr;
341         u16 reserved1;
342         u16 info;
343         u32 nvm_version;
344         u16 device_id;
345         u16 reserved2;
346 };
347
348 #define ICM_TR_FLAGS_RTD3               BIT(6)
349
350 #define ICM_TR_INFO_SLEVEL_MASK         GENMASK(2, 0)
351 #define ICM_TR_INFO_PROTO_VERSION_MASK  GENMASK(6, 4)
352 #define ICM_TR_INFO_PROTO_VERSION_SHIFT 4
353 #define ICM_TR_INFO_BOOT_ACL_SHIFT      7
354 #define ICM_TR_INFO_BOOT_ACL_MASK       GENMASK(12, 7)
355
356 struct icm_tr_event_device_connected {
357         struct icm_pkg_header hdr;
358         uuid_t ep_uuid;
359         u32 route_hi;
360         u32 route_lo;
361         u8 connection_id;
362         u8 reserved;
363         u16 link_info;
364         u32 ep_name[55];
365 };
366
367 struct icm_tr_event_device_disconnected {
368         struct icm_pkg_header hdr;
369         u32 route_hi;
370         u32 route_lo;
371 };
372
373 struct icm_tr_event_xdomain_connected {
374         struct icm_pkg_header hdr;
375         u16 reserved;
376         u16 link_info;
377         uuid_t remote_uuid;
378         uuid_t local_uuid;
379         u32 local_route_hi;
380         u32 local_route_lo;
381         u32 remote_route_hi;
382         u32 remote_route_lo;
383 };
384
385 struct icm_tr_event_xdomain_disconnected {
386         struct icm_pkg_header hdr;
387         u32 route_hi;
388         u32 route_lo;
389         uuid_t remote_uuid;
390 };
391
392 struct icm_tr_pkg_approve_device {
393         struct icm_pkg_header hdr;
394         uuid_t ep_uuid;
395         u32 route_hi;
396         u32 route_lo;
397         u8 connection_id;
398         u8 reserved1[3];
399 };
400
401 struct icm_tr_pkg_add_device_key {
402         struct icm_pkg_header hdr;
403         uuid_t ep_uuid;
404         u32 route_hi;
405         u32 route_lo;
406         u8 connection_id;
407         u8 reserved[3];
408         u32 key[8];
409 };
410
411 struct icm_tr_pkg_challenge_device {
412         struct icm_pkg_header hdr;
413         uuid_t ep_uuid;
414         u32 route_hi;
415         u32 route_lo;
416         u8 connection_id;
417         u8 reserved[3];
418         u32 challenge[8];
419 };
420
421 struct icm_tr_pkg_approve_xdomain {
422         struct icm_pkg_header hdr;
423         u32 route_hi;
424         u32 route_lo;
425         uuid_t remote_uuid;
426         u16 transmit_path;
427         u16 transmit_ring;
428         u16 receive_path;
429         u16 receive_ring;
430 };
431
432 struct icm_tr_pkg_disconnect_xdomain {
433         struct icm_pkg_header hdr;
434         u8 stage;
435         u8 reserved[3];
436         u32 route_hi;
437         u32 route_lo;
438         uuid_t remote_uuid;
439 };
440
441 struct icm_tr_pkg_challenge_device_response {
442         struct icm_pkg_header hdr;
443         uuid_t ep_uuid;
444         u32 route_hi;
445         u32 route_lo;
446         u8 connection_id;
447         u8 reserved[3];
448         u32 challenge[8];
449         u32 response[8];
450 };
451
452 struct icm_tr_pkg_add_device_key_response {
453         struct icm_pkg_header hdr;
454         uuid_t ep_uuid;
455         u32 route_hi;
456         u32 route_lo;
457         u8 connection_id;
458         u8 reserved[3];
459 };
460
461 struct icm_tr_pkg_approve_xdomain_response {
462         struct icm_pkg_header hdr;
463         u32 route_hi;
464         u32 route_lo;
465         uuid_t remote_uuid;
466         u16 transmit_path;
467         u16 transmit_ring;
468         u16 receive_path;
469         u16 receive_ring;
470 };
471
472 struct icm_tr_pkg_disconnect_xdomain_response {
473         struct icm_pkg_header hdr;
474         u8 stage;
475         u8 reserved[3];
476         u32 route_hi;
477         u32 route_lo;
478         uuid_t remote_uuid;
479 };
480
481 /* Ice Lake messages */
482
483 struct icm_icl_event_rtd3_veto {
484         struct icm_pkg_header hdr;
485         u32 veto_reason;
486 };
487
488 /* USB4 ICM messages */
489
490 struct icm_usb4_switch_op {
491         struct icm_pkg_header hdr;
492         u32 route_hi;
493         u32 route_lo;
494         u32 metadata;
495         u16 opcode;
496         u16 data_len_valid;
497         u32 data[16];
498 };
499
500 #define ICM_USB4_SWITCH_DATA_LEN_MASK   GENMASK(3, 0)
501 #define ICM_USB4_SWITCH_DATA_VALID      BIT(4)
502
503 struct icm_usb4_switch_op_response {
504         struct icm_pkg_header hdr;
505         u32 route_hi;
506         u32 route_lo;
507         u32 metadata;
508         u16 opcode;
509         u16 status;
510         u32 data[16];
511 };
512
513 /* XDomain messages */
514
515 struct tb_xdomain_header {
516         u32 route_hi;
517         u32 route_lo;
518         u32 length_sn;
519 };
520
521 #define TB_XDOMAIN_LENGTH_MASK  GENMASK(5, 0)
522 #define TB_XDOMAIN_SN_MASK      GENMASK(28, 27)
523 #define TB_XDOMAIN_SN_SHIFT     27
524
525 enum tb_xdp_type {
526         UUID_REQUEST_OLD = 1,
527         UUID_RESPONSE = 2,
528         PROPERTIES_REQUEST,
529         PROPERTIES_RESPONSE,
530         PROPERTIES_CHANGED_REQUEST,
531         PROPERTIES_CHANGED_RESPONSE,
532         ERROR_RESPONSE,
533         UUID_REQUEST = 12,
534         LINK_STATE_STATUS_REQUEST = 15,
535         LINK_STATE_STATUS_RESPONSE,
536         LINK_STATE_CHANGE_REQUEST,
537         LINK_STATE_CHANGE_RESPONSE,
538 };
539
540 struct tb_xdp_header {
541         struct tb_xdomain_header xd_hdr;
542         uuid_t uuid;
543         u32 type;
544 };
545
546 struct tb_xdp_error_response {
547         struct tb_xdp_header hdr;
548         u32 error;
549 };
550
551 struct tb_xdp_link_state_status {
552         struct tb_xdp_header hdr;
553 };
554
555 struct tb_xdp_link_state_status_response {
556         union {
557                 struct tb_xdp_error_response err;
558                 struct {
559                         struct tb_xdp_header hdr;
560                         u32 status;
561                         u8 slw;
562                         u8 tlw;
563                         u8 sls;
564                         u8 tls;
565                 };
566         };
567 };
568
569 struct tb_xdp_link_state_change {
570         struct tb_xdp_header hdr;
571         u8 tlw;
572         u8 tls;
573         u16 reserved;
574 };
575
576 struct tb_xdp_link_state_change_response {
577         union {
578                 struct tb_xdp_error_response err;
579                 struct {
580                         struct tb_xdp_header hdr;
581                         u32 status;
582                 };
583         };
584 };
585
586 struct tb_xdp_uuid {
587         struct tb_xdp_header hdr;
588 };
589
590 struct tb_xdp_uuid_response {
591         union {
592                 struct tb_xdp_error_response err;
593                 struct {
594                         struct tb_xdp_header hdr;
595                         uuid_t src_uuid;
596                         u32 src_route_hi;
597                         u32 src_route_lo;
598                 };
599         };
600 };
601
602 struct tb_xdp_properties {
603         struct tb_xdp_header hdr;
604         uuid_t src_uuid;
605         uuid_t dst_uuid;
606         u16 offset;
607         u16 reserved;
608 };
609
610 struct tb_xdp_properties_response {
611         union {
612                 struct tb_xdp_error_response err;
613                 struct {
614                         struct tb_xdp_header hdr;
615                         uuid_t src_uuid;
616                         uuid_t dst_uuid;
617                         u16 offset;
618                         u16 data_length;
619                         u32 generation;
620                         u32 data[];
621                 };
622         };
623 };
624
625 /*
626  * Max length of data array single XDomain property response is allowed
627  * to carry.
628  */
629 #define TB_XDP_PROPERTIES_MAX_DATA_LENGTH       \
630         (((256 - 4 - sizeof(struct tb_xdp_properties_response))) / 4)
631
632 /* Maximum size of the total property block in dwords we allow */
633 #define TB_XDP_PROPERTIES_MAX_LENGTH            500
634
635 struct tb_xdp_properties_changed {
636         struct tb_xdp_header hdr;
637         uuid_t src_uuid;
638 };
639
640 struct tb_xdp_properties_changed_response {
641         union {
642                 struct tb_xdp_error_response err;
643                 struct tb_xdp_header hdr;
644         };
645 };
646
647 enum tb_xdp_error {
648         ERROR_SUCCESS,
649         ERROR_UNKNOWN_PACKET,
650         ERROR_UNKNOWN_DOMAIN,
651         ERROR_NOT_SUPPORTED,
652         ERROR_NOT_READY,
653 };
654
655 #endif
This page took 0.068902 seconds and 4 git commands to generate.