1
2
3
4
5
6
7#ifndef _TB_CFG
8#define _TB_CFG
9
10#include "nhi.h"
11
12
13struct tb_ctl;
14
15typedef void (*hotplug_cb)(void *data, u64 route, u8 port, bool unplug);
16
17struct tb_ctl *tb_ctl_alloc(struct tb_nhi *nhi, hotplug_cb cb, void *cb_data);
18void tb_ctl_start(struct tb_ctl *ctl);
19void tb_ctl_stop(struct tb_ctl *ctl);
20void tb_ctl_free(struct tb_ctl *ctl);
21
22
23
24#define TB_CFG_DEFAULT_TIMEOUT 5000
25
26enum tb_cfg_space {
27 TB_CFG_HOPS = 0,
28 TB_CFG_PORT = 1,
29 TB_CFG_SWITCH = 2,
30 TB_CFG_COUNTERS = 3,
31};
32
33enum tb_cfg_error {
34 TB_CFG_ERROR_PORT_NOT_CONNECTED = 0,
35 TB_CFG_ERROR_INVALID_CONFIG_SPACE = 2,
36 TB_CFG_ERROR_NO_SUCH_PORT = 4,
37 TB_CFG_ERROR_ACK_PLUG_EVENT = 7,
38 TB_CFG_ERROR_LOOP = 8,
39};
40
41struct tb_cfg_result {
42 u64 response_route;
43 u32 response_port;
44
45
46
47
48
49
50
51 int err;
52 enum tb_cfg_error tb_error;
53};
54
55
56int tb_cfg_error(struct tb_ctl *ctl, u64 route, u32 port,
57 enum tb_cfg_error error);
58struct tb_cfg_result tb_cfg_reset(struct tb_ctl *ctl, u64 route,
59 int timeout_msec);
60struct tb_cfg_result tb_cfg_read_raw(struct tb_ctl *ctl, void *buffer,
61 u64 route, u32 port,
62 enum tb_cfg_space space, u32 offset,
63 u32 length, int timeout_msec);
64struct tb_cfg_result tb_cfg_write_raw(struct tb_ctl *ctl, void *buffer,
65 u64 route, u32 port,
66 enum tb_cfg_space space, u32 offset,
67 u32 length, int timeout_msec);
68int tb_cfg_read(struct tb_ctl *ctl, void *buffer, u64 route, u32 port,
69 enum tb_cfg_space space, u32 offset, u32 length);
70int tb_cfg_write(struct tb_ctl *ctl, void *buffer, u64 route, u32 port,
71 enum tb_cfg_space space, u32 offset, u32 length);
72int tb_cfg_get_upstream_port(struct tb_ctl *ctl, u64 route);
73
74
75#endif
76