Lines Matching refs:tunnel
13 #define __TB_TUNNEL_PRINT(level, tunnel, fmt, arg...) \ argument
15 struct tb_pci_tunnel *__tunnel = (tunnel); \
24 #define tb_tunnel_WARN(tunnel, fmt, arg...) \ argument
25 __TB_TUNNEL_PRINT(tb_WARN, tunnel, fmt, ##arg)
26 #define tb_tunnel_warn(tunnel, fmt, arg...) \ argument
27 __TB_TUNNEL_PRINT(tb_warn, tunnel, fmt, ##arg)
28 #define tb_tunnel_info(tunnel, fmt, arg...) \ argument
29 __TB_TUNNEL_PRINT(tb_info, tunnel, fmt, ##arg)
61 struct tb_pci_tunnel *tunnel = kzalloc(sizeof(*tunnel), GFP_KERNEL); in tb_pci_alloc() local
62 if (!tunnel) in tb_pci_alloc()
64 tunnel->tb = tb; in tb_pci_alloc()
65 tunnel->down_port = down; in tb_pci_alloc()
66 tunnel->up_port = up; in tb_pci_alloc()
67 INIT_LIST_HEAD(&tunnel->list); in tb_pci_alloc()
68 tunnel->path_to_up = tb_path_alloc(up->sw->tb, 2); in tb_pci_alloc()
69 if (!tunnel->path_to_up) in tb_pci_alloc()
71 tunnel->path_to_down = tb_path_alloc(up->sw->tb, 2); in tb_pci_alloc()
72 if (!tunnel->path_to_down) in tb_pci_alloc()
74 tb_pci_init_path(tunnel->path_to_up); in tb_pci_alloc()
75 tb_pci_init_path(tunnel->path_to_down); in tb_pci_alloc()
77 tunnel->path_to_up->hops[0].in_port = down; in tb_pci_alloc()
78 tunnel->path_to_up->hops[0].in_hop_index = 8; in tb_pci_alloc()
79 tunnel->path_to_up->hops[0].in_counter_index = -1; in tb_pci_alloc()
80 tunnel->path_to_up->hops[0].out_port = tb_upstream_port(up->sw)->remote; in tb_pci_alloc()
81 tunnel->path_to_up->hops[0].next_hop_index = 8; in tb_pci_alloc()
83 tunnel->path_to_up->hops[1].in_port = tb_upstream_port(up->sw); in tb_pci_alloc()
84 tunnel->path_to_up->hops[1].in_hop_index = 8; in tb_pci_alloc()
85 tunnel->path_to_up->hops[1].in_counter_index = -1; in tb_pci_alloc()
86 tunnel->path_to_up->hops[1].out_port = up; in tb_pci_alloc()
87 tunnel->path_to_up->hops[1].next_hop_index = 8; in tb_pci_alloc()
89 tunnel->path_to_down->hops[0].in_port = up; in tb_pci_alloc()
90 tunnel->path_to_down->hops[0].in_hop_index = 8; in tb_pci_alloc()
91 tunnel->path_to_down->hops[0].in_counter_index = -1; in tb_pci_alloc()
92 tunnel->path_to_down->hops[0].out_port = tb_upstream_port(up->sw); in tb_pci_alloc()
93 tunnel->path_to_down->hops[0].next_hop_index = 8; in tb_pci_alloc()
95 tunnel->path_to_down->hops[1].in_port = in tb_pci_alloc()
97 tunnel->path_to_down->hops[1].in_hop_index = 8; in tb_pci_alloc()
98 tunnel->path_to_down->hops[1].in_counter_index = -1; in tb_pci_alloc()
99 tunnel->path_to_down->hops[1].out_port = down; in tb_pci_alloc()
100 tunnel->path_to_down->hops[1].next_hop_index = 8; in tb_pci_alloc()
101 return tunnel; in tb_pci_alloc()
104 if (tunnel) { in tb_pci_alloc()
105 if (tunnel->path_to_down) in tb_pci_alloc()
106 tb_path_free(tunnel->path_to_down); in tb_pci_alloc()
107 if (tunnel->path_to_up) in tb_pci_alloc()
108 tb_path_free(tunnel->path_to_up); in tb_pci_alloc()
109 kfree(tunnel); in tb_pci_alloc()
119 void tb_pci_free(struct tb_pci_tunnel *tunnel) in tb_pci_free() argument
121 if (tunnel->path_to_up->activated || tunnel->path_to_down->activated) { in tb_pci_free()
122 tb_tunnel_WARN(tunnel, "trying to free an activated tunnel\n"); in tb_pci_free()
125 tb_path_free(tunnel->path_to_up); in tb_pci_free()
126 tb_path_free(tunnel->path_to_down); in tb_pci_free()
127 kfree(tunnel); in tb_pci_free()
133 bool tb_pci_is_invalid(struct tb_pci_tunnel *tunnel) in tb_pci_is_invalid() argument
135 WARN_ON(!tunnel->path_to_up->activated); in tb_pci_is_invalid()
136 WARN_ON(!tunnel->path_to_down->activated); in tb_pci_is_invalid()
138 return tb_path_is_invalid(tunnel->path_to_up) in tb_pci_is_invalid()
139 || tb_path_is_invalid(tunnel->path_to_down); in tb_pci_is_invalid()
161 int tb_pci_restart(struct tb_pci_tunnel *tunnel) in tb_pci_restart() argument
164 tunnel->path_to_up->activated = false; in tb_pci_restart()
165 tunnel->path_to_down->activated = false; in tb_pci_restart()
167 tb_tunnel_info(tunnel, "activating\n"); in tb_pci_restart()
169 res = tb_path_activate(tunnel->path_to_up); in tb_pci_restart()
172 res = tb_path_activate(tunnel->path_to_down); in tb_pci_restart()
176 res = tb_pci_port_active(tunnel->down_port, true); in tb_pci_restart()
180 res = tb_pci_port_active(tunnel->up_port, true); in tb_pci_restart()
185 tb_tunnel_warn(tunnel, "activation failed\n"); in tb_pci_restart()
186 tb_pci_deactivate(tunnel); in tb_pci_restart()
195 int tb_pci_activate(struct tb_pci_tunnel *tunnel) in tb_pci_activate() argument
198 if (tunnel->path_to_up->activated || tunnel->path_to_down->activated) { in tb_pci_activate()
199 tb_tunnel_WARN(tunnel, in tb_pci_activate()
204 res = tb_pci_restart(tunnel); in tb_pci_activate()
208 list_add(&tunnel->list, &tunnel->tb->tunnel_list); in tb_pci_activate()
217 void tb_pci_deactivate(struct tb_pci_tunnel *tunnel) in tb_pci_deactivate() argument
219 tb_tunnel_info(tunnel, "deactivating\n"); in tb_pci_deactivate()
224 tb_pci_port_active(tunnel->up_port, false); in tb_pci_deactivate()
225 tb_pci_port_active(tunnel->down_port, false); in tb_pci_deactivate()
226 if (tunnel->path_to_down->activated) in tb_pci_deactivate()
227 tb_path_deactivate(tunnel->path_to_down); in tb_pci_deactivate()
228 if (tunnel->path_to_up->activated) in tb_pci_deactivate()
229 tb_path_deactivate(tunnel->path_to_up); in tb_pci_deactivate()
230 list_del_init(&tunnel->list); in tb_pci_deactivate()