Lines Matching full:tunnel
17 #include "tunnel.h"
163 struct tb_tunnel *tunnel; in tb_discover_dp_resources() local
165 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_discover_dp_resources()
166 if (tb_tunnel_is_dp(tunnel)) in tb_discover_dp_resources()
167 tb_discover_dp_resource(tb, tunnel->dst_port); in tb_discover_dp_resources()
176 const struct tb_tunnel *tunnel; in tb_enable_clx() local
197 * tunnel and in that case bail out. in tb_enable_clx()
199 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_enable_clx()
200 if (tb_tunnel_is_dma(tunnel)) { in tb_enable_clx()
201 if (tb_tunnel_port_on_path(tunnel, tb_upstream_port(sw))) in tb_enable_clx()
271 static void tb_increase_tmu_accuracy(struct tb_tunnel *tunnel) in tb_increase_tmu_accuracy() argument
275 if (!tunnel) in tb_increase_tmu_accuracy()
279 * Once first DP tunnel is established we change the TMU in tb_increase_tmu_accuracy()
287 sw = tunnel->tb->root_switch; in tb_increase_tmu_accuracy()
374 struct tb_tunnel *tunnel = NULL; in tb_switch_discover_tunnels() local
378 tunnel = tb_tunnel_discover_dp(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
379 tb_increase_tmu_accuracy(tunnel); in tb_switch_discover_tunnels()
383 tunnel = tb_tunnel_discover_pci(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
387 tunnel = tb_tunnel_discover_usb3(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
394 if (tunnel) in tb_switch_discover_tunnels()
395 list_add_tail(&tunnel->list, list); in tb_switch_discover_tunnels()
487 struct tb_tunnel *tunnel; in tb_find_tunnel() local
489 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_find_tunnel()
490 if (tunnel->type == type && in tb_find_tunnel()
491 ((src_port && src_port == tunnel->src_port) || in tb_find_tunnel()
492 (dst_port && dst_port == tunnel->dst_port))) { in tb_find_tunnel()
493 return tunnel; in tb_find_tunnel()
537 * from @src_port to @dst_port. Does not take USB3 tunnel starting from
539 * already included in as part of the "first hop" USB3 tunnel.
549 struct tb_tunnel *tunnel; in tb_consumed_usb3_pcie_bandwidth() local
553 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_consumed_usb3_pcie_bandwidth()
554 if (tunnel && !tb_port_is_usb3_down(src_port) && in tb_consumed_usb3_pcie_bandwidth()
558 ret = tb_tunnel_consumed_bandwidth(tunnel, consumed_up, in tb_consumed_usb3_pcie_bandwidth()
586 * to @dst_port. Does not take tunnel starting from @src_port and ending
602 struct tb_tunnel *tunnel; in tb_consumed_dp_bandwidth() local
612 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_consumed_dp_bandwidth()
616 if (tb_tunnel_is_invalid(tunnel)) in tb_consumed_dp_bandwidth()
619 if (!tb_tunnel_is_dp(tunnel)) in tb_consumed_dp_bandwidth()
622 if (!tb_tunnel_port_on_path(tunnel, port)) in tb_consumed_dp_bandwidth()
630 group = tunnel->src_port->group; in tb_consumed_dp_bandwidth()
635 * Ignore the DP tunnel between src_port and dst_port in tb_consumed_dp_bandwidth()
636 * because it is the same tunnel and we may be in tb_consumed_dp_bandwidth()
639 if (tunnel->src_port == src_port && in tb_consumed_dp_bandwidth()
640 tunnel->dst_port == dst_port) in tb_consumed_dp_bandwidth()
643 ret = tb_tunnel_consumed_bandwidth(tunnel, &dp_consumed_up, in tb_consumed_dp_bandwidth()
854 struct tb_tunnel *tunnel; in tb_release_unused_usb3_bandwidth() local
856 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_release_unused_usb3_bandwidth()
857 return tunnel ? tb_tunnel_release_unused_bandwidth(tunnel) : 0; in tb_release_unused_usb3_bandwidth()
864 struct tb_tunnel *tunnel; in tb_reclaim_usb3_bandwidth() local
866 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_reclaim_usb3_bandwidth()
867 if (!tunnel) in tb_reclaim_usb3_bandwidth()
870 tb_tunnel_dbg(tunnel, "reclaiming unused bandwidth\n"); in tb_reclaim_usb3_bandwidth()
873 * Calculate available bandwidth for the first hop USB3 tunnel. in tb_reclaim_usb3_bandwidth()
876 ret = tb_available_bandwidth(tb, tunnel->src_port, tunnel->dst_port, in tb_reclaim_usb3_bandwidth()
879 tb_tunnel_warn(tunnel, "failed to calculate available bandwidth\n"); in tb_reclaim_usb3_bandwidth()
883 tb_tunnel_dbg(tunnel, "available bandwidth %d/%d Mb/s\n", available_up, in tb_reclaim_usb3_bandwidth()
886 tb_tunnel_reclaim_available_bandwidth(tunnel, &available_up, &available_down); in tb_reclaim_usb3_bandwidth()
895 struct tb_tunnel *tunnel; in tb_tunnel_usb3() local
898 tb_dbg(tb, "USB3 tunneling disabled, not creating tunnel\n"); in tb_tunnel_usb3()
923 * there is no point setting up a new tunnel. in tb_tunnel_usb3()
929 /* Make all unused bandwidth available for the new tunnel */ in tb_tunnel_usb3()
940 tb_port_dbg(up, "available bandwidth for new USB3 tunnel %d/%d Mb/s\n", in tb_tunnel_usb3()
943 tunnel = tb_tunnel_alloc_usb3(tb, up, down, available_up, in tb_tunnel_usb3()
945 if (!tunnel) { in tb_tunnel_usb3()
950 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_usb3()
952 "USB3 tunnel activation failed, aborting\n"); in tb_tunnel_usb3()
957 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_usb3()
964 tb_tunnel_free(tunnel); in tb_tunnel_usb3()
1380 tb_sw_warn(sw, "USB3 tunnel creation failed\n"); in tb_scan_port()
1406 struct tb_tunnel *tunnel; in tb_recalc_estimated_bandwidth_for_group() local
1412 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL); in tb_recalc_estimated_bandwidth_for_group()
1413 if (WARN_ON(!tunnel)) in tb_recalc_estimated_bandwidth_for_group()
1422 * for each tunnel separately. in tb_recalc_estimated_bandwidth_for_group()
1424 first_tunnel = tunnel; in tb_recalc_estimated_bandwidth_for_group()
1428 tb_tunnel_warn(tunnel, in tb_recalc_estimated_bandwidth_for_group()
1434 out = tunnel->dst_port; in tb_recalc_estimated_bandwidth_for_group()
1438 tb_tunnel_warn(tunnel, in tb_recalc_estimated_bandwidth_for_group()
1445 * - already allocated bandwidth for the DP tunnel in tb_recalc_estimated_bandwidth_for_group()
1449 if (tb_tunnel_direction_downstream(tunnel)) in tb_recalc_estimated_bandwidth_for_group()
1458 tb_tunnel_dbg(tunnel, in tb_recalc_estimated_bandwidth_for_group()
1465 tb_tunnel_warn(tunnel, in tb_recalc_estimated_bandwidth_for_group()
1506 struct tb_tunnel *tunnel; in __configure_group_sym() local
1519 * if the graphics released bandwidth for other tunnel in the in __configure_group_sym()
1523 tunnel = tb_find_tunnel(group->tb, TB_TUNNEL_DP, in, NULL); in __configure_group_sym()
1524 if (tunnel) in __configure_group_sym()
1525 tb_configure_sym(group->tb, in, tunnel->dst_port, true); in __configure_group_sym()
1587 struct tb_tunnel *tunnel; in tb_attach_bandwidth_group() local
1595 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_attach_bandwidth_group()
1596 if (!tb_tunnel_is_dp(tunnel)) in tb_attach_bandwidth_group()
1599 if (tunnel->src_port->sw == in->sw && in tb_attach_bandwidth_group()
1600 tunnel->dst_port->sw == out->sw) { in tb_attach_bandwidth_group()
1601 group = tunnel->src_port->group; in tb_attach_bandwidth_group()
1658 struct tb_tunnel *tunnel; in tb_discover_tunnels() local
1662 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_discover_tunnels()
1663 if (tb_tunnel_is_pci(tunnel)) { in tb_discover_tunnels()
1664 struct tb_switch *parent = tunnel->dst_port->sw; in tb_discover_tunnels()
1666 while (parent != tunnel->src_port->sw) { in tb_discover_tunnels()
1670 } else if (tb_tunnel_is_dp(tunnel)) { in tb_discover_tunnels()
1671 struct tb_port *in = tunnel->src_port; in tb_discover_tunnels()
1672 struct tb_port *out = tunnel->dst_port; in tb_discover_tunnels()
1683 static void tb_deactivate_and_free_tunnel(struct tb_tunnel *tunnel) in tb_deactivate_and_free_tunnel() argument
1688 if (!tunnel) in tb_deactivate_and_free_tunnel()
1691 tb_tunnel_deactivate(tunnel); in tb_deactivate_and_free_tunnel()
1692 list_del(&tunnel->list); in tb_deactivate_and_free_tunnel()
1694 tb = tunnel->tb; in tb_deactivate_and_free_tunnel()
1695 src_port = tunnel->src_port; in tb_deactivate_and_free_tunnel()
1696 dst_port = tunnel->dst_port; in tb_deactivate_and_free_tunnel()
1698 switch (tunnel->type) { in tb_deactivate_and_free_tunnel()
1702 * In case of DP tunnel make sure the DP IN resource is in tb_deactivate_and_free_tunnel()
1730 tb_tunnel_free(tunnel); in tb_deactivate_and_free_tunnel()
1739 struct tb_tunnel *tunnel; in tb_free_invalid_tunnels() local
1742 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_free_invalid_tunnels()
1743 if (tb_tunnel_is_invalid(tunnel)) in tb_free_invalid_tunnels()
1744 tb_deactivate_and_free_tunnel(tunnel); in tb_free_invalid_tunnels()
1850 * Keep the DP tunnel under the topology starting from in tb_find_dp_out()
1873 struct tb_tunnel *tunnel; in tb_tunnel_one_dp() local
1882 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_tunnel_one_dp()
1883 if (tb_tunnel_is_dp(tunnel)) { in tb_tunnel_one_dp()
1891 * both ends of the tunnel. in tb_tunnel_one_dp()
1895 * tunnel is active. in tb_tunnel_one_dp()
1908 /* Make all unused USB3 bandwidth available for the new DP tunnel */ in tb_tunnel_one_dp()
1920 tb_dbg(tb, "available bandwidth for new DP tunnel %u/%u Mb/s\n", in tb_tunnel_one_dp()
1923 tunnel = tb_tunnel_alloc_dp(tb, in, out, link_nr, available_up, in tb_tunnel_one_dp()
1925 if (!tunnel) { in tb_tunnel_one_dp()
1926 tb_port_dbg(out, "could not allocate DP tunnel\n"); in tb_tunnel_one_dp()
1930 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_one_dp()
1931 tb_port_info(out, "DP tunnel activation failed, aborting\n"); in tb_tunnel_one_dp()
1935 /* If fail reading tunnel's consumed bandwidth, tear it down */ in tb_tunnel_one_dp()
1936 ret = tb_tunnel_consumed_bandwidth(tunnel, &consumed_up, &consumed_down); in tb_tunnel_one_dp()
1940 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_one_dp()
1953 * In case of DP tunnel exists, change host router's 1st children in tb_tunnel_one_dp()
1956 tb_increase_tmu_accuracy(tunnel); in tb_tunnel_one_dp()
1960 tb_tunnel_deactivate(tunnel); in tb_tunnel_one_dp()
1962 tb_tunnel_free(tunnel); in tb_tunnel_one_dp()
1984 tb_dbg(tb, "DP tunneling disabled, not creating tunnel\n"); in tb_tunnel_dp()
1990 * establish a DP tunnel between them. in tb_tunnel_dp()
2065 struct tb_tunnel *tunnel; in tb_dp_resource_unavailable() local
2077 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, out); in tb_dp_resource_unavailable()
2078 if (tunnel) in tb_dp_resource_unavailable()
2079 tb_deactivate_and_free_tunnel(tunnel); in tb_dp_resource_unavailable()
2086 * to create another tunnel. in tb_dp_resource_unavailable()
2117 struct tb_tunnel *tunnel, *n; in tb_disconnect_and_release_dp() local
2123 list_for_each_entry_safe_reverse(tunnel, n, &tcm->tunnel_list, list) { in tb_disconnect_and_release_dp()
2124 if (tb_tunnel_is_dp(tunnel)) in tb_disconnect_and_release_dp()
2125 tb_deactivate_and_free_tunnel(tunnel); in tb_disconnect_and_release_dp()
2139 struct tb_tunnel *tunnel; in tb_disconnect_pci() local
2146 tunnel = tb_find_tunnel(tb, TB_TUNNEL_PCI, NULL, up); in tb_disconnect_pci()
2147 if (WARN_ON(!tunnel)) in tb_disconnect_pci()
2152 tb_tunnel_deactivate(tunnel); in tb_disconnect_pci()
2153 list_del(&tunnel->list); in tb_disconnect_pci()
2154 tb_tunnel_free(tunnel); in tb_disconnect_pci()
2162 struct tb_tunnel *tunnel; in tb_tunnel_pci() local
2177 tunnel = tb_tunnel_alloc_pci(tb, up, down); in tb_tunnel_pci()
2178 if (!tunnel) in tb_tunnel_pci()
2181 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_pci()
2183 "PCIe tunnel activation failed, aborting\n"); in tb_tunnel_pci()
2184 tb_tunnel_free(tunnel); in tb_tunnel_pci()
2198 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_pci()
2208 struct tb_tunnel *tunnel; in tb_approve_xdomain_paths() local
2224 tunnel = tb_tunnel_alloc_dma(tb, nhi_port, dst_port, transmit_path, in tb_approve_xdomain_paths()
2226 if (!tunnel) { in tb_approve_xdomain_paths()
2231 if (tb_tunnel_activate(tunnel)) { in tb_approve_xdomain_paths()
2233 "DMA tunnel activation failed, aborting\n"); in tb_approve_xdomain_paths()
2238 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_approve_xdomain_paths()
2243 tb_tunnel_free(tunnel); in tb_approve_xdomain_paths()
2257 struct tb_tunnel *tunnel, *n; in __tb_disconnect_xdomain_paths() local
2264 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in __tb_disconnect_xdomain_paths()
2265 if (!tb_tunnel_is_dma(tunnel)) in __tb_disconnect_xdomain_paths()
2267 if (tunnel->src_port != nhi_port || tunnel->dst_port != dst_port) in __tb_disconnect_xdomain_paths()
2270 if (tb_tunnel_match_dma(tunnel, transmit_path, transmit_ring, in __tb_disconnect_xdomain_paths()
2272 tb_deactivate_and_free_tunnel(tunnel); in __tb_disconnect_xdomain_paths()
2277 * because we may still have another DMA tunnel active through in __tb_disconnect_xdomain_paths()
2357 /* Maybe we can create another DP tunnel */ in tb_handle_hotplug()
2416 static int tb_alloc_dp_bandwidth(struct tb_tunnel *tunnel, int *requested_up, in tb_alloc_dp_bandwidth() argument
2423 struct tb *tb = tunnel->tb; in tb_alloc_dp_bandwidth()
2427 ret = tb_tunnel_allocated_bandwidth(tunnel, &allocated_up, &allocated_down); in tb_alloc_dp_bandwidth()
2431 in = tunnel->src_port; in tb_alloc_dp_bandwidth()
2432 out = tunnel->dst_port; in tb_alloc_dp_bandwidth()
2434 tb_tunnel_dbg(tunnel, "bandwidth allocated currently %d/%d Mb/s\n", in tb_alloc_dp_bandwidth()
2449 ret = tb_tunnel_maximum_bandwidth(tunnel, &max_up, &max_down); in tb_alloc_dp_bandwidth()
2476 tb_tunnel_dbg(tunnel, "corrected bandwidth request %d/%d Mb/s\n", in tb_alloc_dp_bandwidth()
2481 tb_tunnel_dbg(tunnel, in tb_alloc_dp_bandwidth()
2489 downstream = tb_tunnel_direction_downstream(tunnel); in tb_alloc_dp_bandwidth()
2494 if (tunnel->bw_mode) { in tb_alloc_dp_bandwidth()
2498 * what is currently allocated to that tunnel we in tb_alloc_dp_bandwidth()
2499 * simply change the reservation of the tunnel in tb_alloc_dp_bandwidth()
2527 return tb_tunnel_alloc_bandwidth(tunnel, requested_up, in tb_alloc_dp_bandwidth()
2549 tb_tunnel_dbg(tunnel, "bandwidth available for allocation %d/%d (+ %u reserved) Mb/s\n", in tb_alloc_dp_bandwidth()
2569 ret = tb_tunnel_alloc_bandwidth(tunnel, requested_up, in tb_alloc_dp_bandwidth()
2572 tb_tunnel_warn(tunnel, "failed to allocate bandwidth\n"); in tb_alloc_dp_bandwidth()
2600 tb_tunnel_dbg(tunnel, in tb_alloc_dp_bandwidth()
2603 tb_tunnel_alloc_bandwidth(tunnel, &allocated_up, &allocated_down); in tb_alloc_dp_bandwidth()
2613 struct tb_tunnel *tunnel; in tb_handle_dp_bandwidth_request() local
2640 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL); in tb_handle_dp_bandwidth_request()
2641 if (!tunnel) { in tb_handle_dp_bandwidth_request()
2642 tb_port_warn(in, "failed to find tunnel\n"); in tb_handle_dp_bandwidth_request()
2647 if (tunnel->bw_mode) { in tb_handle_dp_bandwidth_request()
2649 * Reset the tunnel back to use the legacy in tb_handle_dp_bandwidth_request()
2652 tunnel->bw_mode = false; in tb_handle_dp_bandwidth_request()
2681 if (tb_tunnel_direction_downstream(tunnel)) { in tb_handle_dp_bandwidth_request()
2689 ret = tb_alloc_dp_bandwidth(tunnel, &requested_up, &requested_down); in tb_handle_dp_bandwidth_request()
2692 tb_tunnel_warn(tunnel, in tb_handle_dp_bandwidth_request()
2695 tb_tunnel_warn(tunnel, in tb_handle_dp_bandwidth_request()
2698 tb_tunnel_dbg(tunnel, in tb_handle_dp_bandwidth_request()
2791 struct tb_tunnel *tunnel; in tb_stop() local
2796 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_stop()
2802 if (tb_tunnel_is_dma(tunnel)) in tb_stop()
2803 tb_tunnel_deactivate(tunnel); in tb_stop()
2804 tb_tunnel_free(tunnel); in tb_stop()
2969 struct tb_tunnel *tunnel, *n; in tb_resume_noirq() local
2994 list_for_each_entry_safe_reverse(tunnel, n, &tunnels, list) { in tb_resume_noirq()
2995 if (tb_tunnel_is_usb3(tunnel)) in tb_resume_noirq()
2997 tb_tunnel_deactivate(tunnel); in tb_resume_noirq()
2998 tb_tunnel_free(tunnel); in tb_resume_noirq()
3002 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_resume_noirq()
3004 if (tb_tunnel_is_usb3(tunnel)) { in tb_resume_noirq()
3009 tb_tunnel_restart(tunnel); in tb_resume_noirq()
3105 struct tb_tunnel *tunnel, *n; in tb_runtime_resume() local
3111 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) in tb_runtime_resume()
3112 tb_tunnel_restart(tunnel); in tb_runtime_resume()