Lines Matching refs:tunnel
112 struct tb_tunnel *tunnel = NULL; in tb_discover_tunnels() local
116 tunnel = tb_tunnel_discover_dp(tb, port); in tb_discover_tunnels()
120 tunnel = tb_tunnel_discover_pci(tb, port); in tb_discover_tunnels()
124 tunnel = tb_tunnel_discover_usb3(tb, port); in tb_discover_tunnels()
131 if (!tunnel) in tb_discover_tunnels()
134 if (tb_tunnel_is_pci(tunnel)) { in tb_discover_tunnels()
135 struct tb_switch *parent = tunnel->dst_port->sw; in tb_discover_tunnels()
137 while (parent != tunnel->src_port->sw) { in tb_discover_tunnels()
141 } else if (tb_tunnel_is_dp(tunnel)) { in tb_discover_tunnels()
143 pm_runtime_get_sync(&tunnel->src_port->sw->dev); in tb_discover_tunnels()
144 pm_runtime_get_sync(&tunnel->dst_port->sw->dev); in tb_discover_tunnels()
147 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_discover_tunnels()
261 struct tb_tunnel *tunnel; in tb_find_tunnel() local
263 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_find_tunnel()
264 if (tunnel->type == type && in tb_find_tunnel()
265 ((src_port && src_port == tunnel->src_port) || in tb_find_tunnel()
266 (dst_port && dst_port == tunnel->dst_port))) { in tb_find_tunnel()
267 return tunnel; in tb_find_tunnel()
306 struct tb_tunnel *tunnel; in tb_available_bandwidth() local
311 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_available_bandwidth()
312 if (tunnel) { in tb_available_bandwidth()
313 ret = tb_tunnel_consumed_bandwidth(tunnel, &usb3_consumed_up, in tb_available_bandwidth()
352 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_available_bandwidth()
355 if (!tb_tunnel_is_dp(tunnel)) in tb_available_bandwidth()
358 if (!tb_tunnel_port_on_path(tunnel, port)) in tb_available_bandwidth()
361 ret = tb_tunnel_consumed_bandwidth(tunnel, in tb_available_bandwidth()
398 struct tb_tunnel *tunnel; in tb_release_unused_usb3_bandwidth() local
400 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_release_unused_usb3_bandwidth()
401 return tunnel ? tb_tunnel_release_unused_bandwidth(tunnel) : 0; in tb_release_unused_usb3_bandwidth()
408 struct tb_tunnel *tunnel; in tb_reclaim_usb3_bandwidth() local
410 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_reclaim_usb3_bandwidth()
411 if (!tunnel) in tb_reclaim_usb3_bandwidth()
420 ret = tb_available_bandwidth(tb, tunnel->src_port, tunnel->dst_port, in tb_reclaim_usb3_bandwidth()
430 tb_tunnel_reclaim_available_bandwidth(tunnel, &available_up, &available_down); in tb_reclaim_usb3_bandwidth()
439 struct tb_tunnel *tunnel; in tb_tunnel_usb3() local
482 tunnel = tb_tunnel_alloc_usb3(tb, up, down, available_up, in tb_tunnel_usb3()
484 if (!tunnel) { in tb_tunnel_usb3()
489 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_usb3()
496 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_usb3()
503 tb_tunnel_free(tunnel); in tb_tunnel_usb3()
667 static void tb_deactivate_and_free_tunnel(struct tb_tunnel *tunnel) in tb_deactivate_and_free_tunnel() argument
672 if (!tunnel) in tb_deactivate_and_free_tunnel()
675 tb_tunnel_deactivate(tunnel); in tb_deactivate_and_free_tunnel()
676 list_del(&tunnel->list); in tb_deactivate_and_free_tunnel()
678 tb = tunnel->tb; in tb_deactivate_and_free_tunnel()
679 src_port = tunnel->src_port; in tb_deactivate_and_free_tunnel()
680 dst_port = tunnel->dst_port; in tb_deactivate_and_free_tunnel()
682 switch (tunnel->type) { in tb_deactivate_and_free_tunnel()
708 tb_tunnel_free(tunnel); in tb_deactivate_and_free_tunnel()
717 struct tb_tunnel *tunnel; in tb_free_invalid_tunnels() local
720 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_free_invalid_tunnels()
721 if (tb_tunnel_is_invalid(tunnel)) in tb_free_invalid_tunnels()
722 tb_deactivate_and_free_tunnel(tunnel); in tb_free_invalid_tunnels()
843 struct tb_tunnel *tunnel; in tb_tunnel_dp() local
911 tunnel = tb_tunnel_alloc_dp(tb, in, out, available_up, available_down); in tb_tunnel_dp()
912 if (!tunnel) { in tb_tunnel_dp()
917 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_dp()
922 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_dp()
927 tb_tunnel_free(tunnel); in tb_tunnel_dp()
942 struct tb_tunnel *tunnel; in tb_dp_resource_unavailable() local
954 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, out); in tb_dp_resource_unavailable()
955 tb_deactivate_and_free_tunnel(tunnel); in tb_dp_resource_unavailable()
989 struct tb_tunnel *tunnel, *n; in tb_disconnect_and_release_dp() local
995 list_for_each_entry_safe_reverse(tunnel, n, &tcm->tunnel_list, list) { in tb_disconnect_and_release_dp()
996 if (tb_tunnel_is_dp(tunnel)) in tb_disconnect_and_release_dp()
997 tb_deactivate_and_free_tunnel(tunnel); in tb_disconnect_and_release_dp()
1014 struct tb_tunnel *tunnel; in tb_tunnel_pci() local
1030 tunnel = tb_tunnel_alloc_pci(tb, up, down); in tb_tunnel_pci()
1031 if (!tunnel) in tb_tunnel_pci()
1034 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_pci()
1037 tb_tunnel_free(tunnel); in tb_tunnel_pci()
1041 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_pci()
1049 struct tb_tunnel *tunnel; in tb_approve_xdomain_paths() local
1057 tunnel = tb_tunnel_alloc_dma(tb, nhi_port, dst_port, xd->transmit_ring, in tb_approve_xdomain_paths()
1060 if (!tunnel) { in tb_approve_xdomain_paths()
1065 if (tb_tunnel_activate(tunnel)) { in tb_approve_xdomain_paths()
1068 tb_tunnel_free(tunnel); in tb_approve_xdomain_paths()
1073 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_approve_xdomain_paths()
1081 struct tb_tunnel *tunnel; in __tb_disconnect_xdomain_paths() local
1092 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DMA, NULL, dst_port); in __tb_disconnect_xdomain_paths()
1093 tb_deactivate_and_free_tunnel(tunnel); in __tb_disconnect_xdomain_paths()
1246 struct tb_tunnel *tunnel; in tb_stop() local
1251 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_stop()
1257 if (tb_tunnel_is_dma(tunnel)) in tb_stop()
1258 tb_tunnel_deactivate(tunnel); in tb_stop()
1259 tb_tunnel_free(tunnel); in tb_stop()
1381 struct tb_tunnel *tunnel, *n; in tb_resume_noirq() local
1392 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) in tb_resume_noirq()
1393 tb_tunnel_restart(tunnel); in tb_resume_noirq()
1488 struct tb_tunnel *tunnel, *n; in tb_runtime_resume() local
1494 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) in tb_runtime_resume()
1495 tb_tunnel_restart(tunnel); in tb_runtime_resume()