Lines Matching full:tunnel
17 #include "tunnel.h"
126 struct tb_tunnel *tunnel; in tb_discover_dp_resources() local
128 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_discover_dp_resources()
129 if (tb_tunnel_is_dp(tunnel)) in tb_discover_dp_resources()
130 tb_discover_dp_resource(tb, tunnel->dst_port); in tb_discover_dp_resources()
142 struct tb_tunnel *tunnel = NULL; in tb_switch_discover_tunnels() local
146 tunnel = tb_tunnel_discover_dp(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
148 * In case of DP tunnel exists, change host router's in tb_switch_discover_tunnels()
151 if (tunnel) in tb_switch_discover_tunnels()
157 tunnel = tb_tunnel_discover_pci(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
161 tunnel = tb_tunnel_discover_usb3(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
168 if (tunnel) in tb_switch_discover_tunnels()
169 list_add_tail(&tunnel->list, list); in tb_switch_discover_tunnels()
183 struct tb_tunnel *tunnel; in tb_discover_tunnels() local
187 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_discover_tunnels()
188 if (tb_tunnel_is_pci(tunnel)) { in tb_discover_tunnels()
189 struct tb_switch *parent = tunnel->dst_port->sw; in tb_discover_tunnels()
191 while (parent != tunnel->src_port->sw) { in tb_discover_tunnels()
195 } else if (tb_tunnel_is_dp(tunnel)) { in tb_discover_tunnels()
197 pm_runtime_get_sync(&tunnel->src_port->sw->dev); in tb_discover_tunnels()
198 pm_runtime_get_sync(&tunnel->dst_port->sw->dev); in tb_discover_tunnels()
305 struct tb_tunnel *tunnel; in tb_find_tunnel() local
307 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_find_tunnel()
308 if (tunnel->type == type && in tb_find_tunnel()
309 ((src_port && src_port == tunnel->src_port) || in tb_find_tunnel()
310 (dst_port && dst_port == tunnel->dst_port))) { in tb_find_tunnel()
311 return tunnel; in tb_find_tunnel()
350 struct tb_tunnel *tunnel; in tb_available_bandwidth() local
355 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_available_bandwidth()
356 if (tunnel) { in tb_available_bandwidth()
357 ret = tb_tunnel_consumed_bandwidth(tunnel, &usb3_consumed_up, in tb_available_bandwidth()
396 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_available_bandwidth()
399 if (!tb_tunnel_is_dp(tunnel)) in tb_available_bandwidth()
402 if (!tb_tunnel_port_on_path(tunnel, port)) in tb_available_bandwidth()
405 ret = tb_tunnel_consumed_bandwidth(tunnel, in tb_available_bandwidth()
442 struct tb_tunnel *tunnel; in tb_release_unused_usb3_bandwidth() local
444 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_release_unused_usb3_bandwidth()
445 return tunnel ? tb_tunnel_release_unused_bandwidth(tunnel) : 0; in tb_release_unused_usb3_bandwidth()
452 struct tb_tunnel *tunnel; in tb_reclaim_usb3_bandwidth() local
454 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_reclaim_usb3_bandwidth()
455 if (!tunnel) in tb_reclaim_usb3_bandwidth()
461 * Calculate available bandwidth for the first hop USB3 tunnel. in tb_reclaim_usb3_bandwidth()
464 ret = tb_available_bandwidth(tb, tunnel->src_port, tunnel->dst_port, in tb_reclaim_usb3_bandwidth()
474 tb_tunnel_reclaim_available_bandwidth(tunnel, &available_up, &available_down); in tb_reclaim_usb3_bandwidth()
483 struct tb_tunnel *tunnel; in tb_tunnel_usb3() local
486 tb_dbg(tb, "USB3 tunneling disabled, not creating tunnel\n"); in tb_tunnel_usb3()
511 * there is no point setting up a new tunnel. in tb_tunnel_usb3()
517 /* Make all unused bandwidth available for the new tunnel */ in tb_tunnel_usb3()
528 tb_port_dbg(up, "available bandwidth for new USB3 tunnel %d/%d Mb/s\n", in tb_tunnel_usb3()
531 tunnel = tb_tunnel_alloc_usb3(tb, up, down, available_up, in tb_tunnel_usb3()
533 if (!tunnel) { in tb_tunnel_usb3()
538 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_usb3()
540 "USB3 tunnel activation failed, aborting\n"); in tb_tunnel_usb3()
545 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_usb3()
552 tb_tunnel_free(tunnel); in tb_tunnel_usb3()
732 tb_sw_warn(sw, "USB3 tunnel creation failed\n"); in tb_scan_port()
738 static void tb_deactivate_and_free_tunnel(struct tb_tunnel *tunnel) in tb_deactivate_and_free_tunnel() argument
743 if (!tunnel) in tb_deactivate_and_free_tunnel()
746 tb_tunnel_deactivate(tunnel); in tb_deactivate_and_free_tunnel()
747 list_del(&tunnel->list); in tb_deactivate_and_free_tunnel()
749 tb = tunnel->tb; in tb_deactivate_and_free_tunnel()
750 src_port = tunnel->src_port; in tb_deactivate_and_free_tunnel()
751 dst_port = tunnel->dst_port; in tb_deactivate_and_free_tunnel()
753 switch (tunnel->type) { in tb_deactivate_and_free_tunnel()
756 * In case of DP tunnel make sure the DP IN resource is in tb_deactivate_and_free_tunnel()
779 tb_tunnel_free(tunnel); in tb_deactivate_and_free_tunnel()
788 struct tb_tunnel *tunnel; in tb_free_invalid_tunnels() local
791 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_free_invalid_tunnels()
792 if (tb_tunnel_is_invalid(tunnel)) in tb_free_invalid_tunnels()
793 tb_deactivate_and_free_tunnel(tunnel); in tb_free_invalid_tunnels()
892 * Keep the DP tunnel under the topology starting from in tb_find_dp_out()
914 struct tb_tunnel *tunnel; in tb_tunnel_dp() local
917 tb_dbg(tb, "DP tunneling disabled, not creating tunnel\n"); in tb_tunnel_dp()
923 * establish a DP tunnel between them. in tb_tunnel_dp()
963 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_tunnel_dp()
964 if (tb_tunnel_is_dp(tunnel)) { in tb_tunnel_dp()
972 * both ends of the tunnel. in tb_tunnel_dp()
976 * tunnel is active. in tb_tunnel_dp()
986 /* Make all unused USB3 bandwidth available for the new DP tunnel */ in tb_tunnel_dp()
998 tb_dbg(tb, "available bandwidth for new DP tunnel %u/%u Mb/s\n", in tb_tunnel_dp()
1001 tunnel = tb_tunnel_alloc_dp(tb, in, out, link_nr, available_up, in tb_tunnel_dp()
1003 if (!tunnel) { in tb_tunnel_dp()
1004 tb_port_dbg(out, "could not allocate DP tunnel\n"); in tb_tunnel_dp()
1008 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_dp()
1009 tb_port_info(out, "DP tunnel activation failed, aborting\n"); in tb_tunnel_dp()
1013 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_dp()
1016 * In case of DP tunnel exists, change host router's 1st children in tb_tunnel_dp()
1024 tb_tunnel_free(tunnel); in tb_tunnel_dp()
1039 struct tb_tunnel *tunnel; in tb_dp_resource_unavailable() local
1051 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, out); in tb_dp_resource_unavailable()
1052 tb_deactivate_and_free_tunnel(tunnel); in tb_dp_resource_unavailable()
1057 * to create another tunnel. in tb_dp_resource_unavailable()
1086 struct tb_tunnel *tunnel, *n; in tb_disconnect_and_release_dp() local
1092 list_for_each_entry_safe_reverse(tunnel, n, &tcm->tunnel_list, list) { in tb_disconnect_and_release_dp()
1093 if (tb_tunnel_is_dp(tunnel)) in tb_disconnect_and_release_dp()
1094 tb_deactivate_and_free_tunnel(tunnel); in tb_disconnect_and_release_dp()
1108 struct tb_tunnel *tunnel; in tb_disconnect_pci() local
1115 tunnel = tb_find_tunnel(tb, TB_TUNNEL_PCI, NULL, up); in tb_disconnect_pci()
1116 if (WARN_ON(!tunnel)) in tb_disconnect_pci()
1121 tb_tunnel_deactivate(tunnel); in tb_disconnect_pci()
1122 list_del(&tunnel->list); in tb_disconnect_pci()
1123 tb_tunnel_free(tunnel); in tb_disconnect_pci()
1132 struct tb_tunnel *tunnel; in tb_tunnel_pci() local
1148 tunnel = tb_tunnel_alloc_pci(tb, up, down); in tb_tunnel_pci()
1149 if (!tunnel) in tb_tunnel_pci()
1152 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_pci()
1154 "PCIe tunnel activation failed, aborting\n"); in tb_tunnel_pci()
1155 tb_tunnel_free(tunnel); in tb_tunnel_pci()
1169 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_pci()
1179 struct tb_tunnel *tunnel; in tb_approve_xdomain_paths() local
1187 tunnel = tb_tunnel_alloc_dma(tb, nhi_port, dst_port, transmit_path, in tb_approve_xdomain_paths()
1189 if (!tunnel) { in tb_approve_xdomain_paths()
1194 if (tb_tunnel_activate(tunnel)) { in tb_approve_xdomain_paths()
1196 "DMA tunnel activation failed, aborting\n"); in tb_approve_xdomain_paths()
1197 tb_tunnel_free(tunnel); in tb_approve_xdomain_paths()
1202 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_approve_xdomain_paths()
1213 struct tb_tunnel *tunnel, *n; in __tb_disconnect_xdomain_paths() local
1220 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in __tb_disconnect_xdomain_paths()
1221 if (!tb_tunnel_is_dma(tunnel)) in __tb_disconnect_xdomain_paths()
1223 if (tunnel->src_port != nhi_port || tunnel->dst_port != dst_port) in __tb_disconnect_xdomain_paths()
1226 if (tb_tunnel_match_dma(tunnel, transmit_path, transmit_ring, in __tb_disconnect_xdomain_paths()
1228 tb_deactivate_and_free_tunnel(tunnel); in __tb_disconnect_xdomain_paths()
1305 /* Maybe we can create another DP tunnel */ in tb_handle_hotplug()
1392 struct tb_tunnel *tunnel; in tb_stop() local
1397 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_stop()
1403 if (tb_tunnel_is_dma(tunnel)) in tb_stop()
1404 tb_tunnel_deactivate(tunnel); in tb_stop()
1405 tb_tunnel_free(tunnel); in tb_stop()
1558 struct tb_tunnel *tunnel, *n; in tb_resume_noirq() local
1579 list_for_each_entry_safe_reverse(tunnel, n, &tunnels, list) { in tb_resume_noirq()
1580 if (tb_tunnel_is_usb3(tunnel)) in tb_resume_noirq()
1582 tb_tunnel_deactivate(tunnel); in tb_resume_noirq()
1583 tb_tunnel_free(tunnel); in tb_resume_noirq()
1587 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_resume_noirq()
1589 if (tb_tunnel_is_usb3(tunnel)) { in tb_resume_noirq()
1594 tb_tunnel_restart(tunnel); in tb_resume_noirq()
1690 struct tb_tunnel *tunnel, *n; in tb_runtime_resume() local
1696 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) in tb_runtime_resume()
1697 tb_tunnel_restart(tunnel); in tb_runtime_resume()