1
2
3
4
5
6
7
8
9#ifndef TB_TUNNEL_H_
10#define TB_TUNNEL_H_
11
12#include "tb.h"
13
14enum tb_tunnel_type {
15 TB_TUNNEL_PCI,
16 TB_TUNNEL_DP,
17 TB_TUNNEL_DMA,
18 TB_TUNNEL_USB3,
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
44struct tb_tunnel {
45 struct tb *tb;
46 struct tb_port *src_port;
47 struct tb_port *dst_port;
48 struct tb_path **paths;
49 size_t npaths;
50 int (*init)(struct tb_tunnel *tunnel);
51 void (*deinit)(struct tb_tunnel *tunnel);
52 int (*activate)(struct tb_tunnel *tunnel, bool activate);
53 int (*consumed_bandwidth)(struct tb_tunnel *tunnel, int *consumed_up,
54 int *consumed_down);
55 int (*release_unused_bandwidth)(struct tb_tunnel *tunnel);
56 void (*reclaim_available_bandwidth)(struct tb_tunnel *tunnel,
57 int *available_up,
58 int *available_down);
59 struct list_head list;
60 enum tb_tunnel_type type;
61 int max_up;
62 int max_down;
63 int allocated_up;
64 int allocated_down;
65};
66
67struct tb_tunnel *tb_tunnel_discover_pci(struct tb *tb, struct tb_port *down);
68struct tb_tunnel *tb_tunnel_alloc_pci(struct tb *tb, struct tb_port *up,
69 struct tb_port *down);
70struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in);
71struct tb_tunnel *tb_tunnel_alloc_dp(struct tb *tb, struct tb_port *in,
72 struct tb_port *out, int max_up,
73 int max_down);
74struct tb_tunnel *tb_tunnel_alloc_dma(struct tb *tb, struct tb_port *nhi,
75 struct tb_port *dst, int transmit_path,
76 int transmit_ring, int receive_path,
77 int receive_ring);
78bool tb_tunnel_match_dma(const struct tb_tunnel *tunnel, int transmit_path,
79 int transmit_ring, int receive_path, int receive_ring);
80struct tb_tunnel *tb_tunnel_discover_usb3(struct tb *tb, struct tb_port *down);
81struct tb_tunnel *tb_tunnel_alloc_usb3(struct tb *tb, struct tb_port *up,
82 struct tb_port *down, int max_up,
83 int max_down);
84
85void tb_tunnel_free(struct tb_tunnel *tunnel);
86int tb_tunnel_activate(struct tb_tunnel *tunnel);
87int tb_tunnel_restart(struct tb_tunnel *tunnel);
88void tb_tunnel_deactivate(struct tb_tunnel *tunnel);
89bool tb_tunnel_is_invalid(struct tb_tunnel *tunnel);
90bool tb_tunnel_port_on_path(const struct tb_tunnel *tunnel,
91 const struct tb_port *port);
92int tb_tunnel_consumed_bandwidth(struct tb_tunnel *tunnel, int *consumed_up,
93 int *consumed_down);
94int tb_tunnel_release_unused_bandwidth(struct tb_tunnel *tunnel);
95void tb_tunnel_reclaim_available_bandwidth(struct tb_tunnel *tunnel,
96 int *available_up,
97 int *available_down);
98
99static inline bool tb_tunnel_is_pci(const struct tb_tunnel *tunnel)
100{
101 return tunnel->type == TB_TUNNEL_PCI;
102}
103
104static inline bool tb_tunnel_is_dp(const struct tb_tunnel *tunnel)
105{
106 return tunnel->type == TB_TUNNEL_DP;
107}
108
109static inline bool tb_tunnel_is_dma(const struct tb_tunnel *tunnel)
110{
111 return tunnel->type == TB_TUNNEL_DMA;
112}
113
114static inline bool tb_tunnel_is_usb3(const struct tb_tunnel *tunnel)
115{
116 return tunnel->type == TB_TUNNEL_USB3;
117}
118
119#endif
120
121