Lines Matching full:tunnel
17 #include "tunnel.h"
24 * retried if the DP tunnel is still activating.
175 struct tb_tunnel *tunnel; in tb_discover_dp_resources() local
177 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_discover_dp_resources()
178 if (tb_tunnel_is_dp(tunnel)) in tb_discover_dp_resources()
179 tb_discover_dp_resource(tb, tunnel->dst_port); in tb_discover_dp_resources()
188 const struct tb_tunnel *tunnel; in tb_enable_clx() local
209 * tunnel and in that case bail out. in tb_enable_clx()
211 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_enable_clx()
212 if (tb_tunnel_is_dma(tunnel)) { in tb_enable_clx()
213 if (tb_tunnel_port_on_path(tunnel, tb_upstream_port(sw))) in tb_enable_clx()
283 static void tb_increase_tmu_accuracy(struct tb_tunnel *tunnel) in tb_increase_tmu_accuracy() argument
287 if (!tunnel) in tb_increase_tmu_accuracy()
291 * Once first DP tunnel is established we change the TMU in tb_increase_tmu_accuracy()
299 sw = tunnel->tb->root_switch; in tb_increase_tmu_accuracy()
386 struct tb_tunnel *tunnel = NULL; in tb_switch_discover_tunnels() local
390 tunnel = tb_tunnel_discover_dp(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
391 tb_increase_tmu_accuracy(tunnel); in tb_switch_discover_tunnels()
395 tunnel = tb_tunnel_discover_pci(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
399 tunnel = tb_tunnel_discover_usb3(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
406 if (tunnel) in tb_switch_discover_tunnels()
407 list_add_tail(&tunnel->list, list); in tb_switch_discover_tunnels()
499 struct tb_tunnel *tunnel; in tb_find_tunnel() local
501 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_find_tunnel()
502 if (tunnel->type == type && in tb_find_tunnel()
503 ((src_port && src_port == tunnel->src_port) || in tb_find_tunnel()
504 (dst_port && dst_port == tunnel->dst_port))) { in tb_find_tunnel()
505 return tunnel; in tb_find_tunnel()
549 * from @src_port to @dst_port. Does not take USB3 tunnel starting from
551 * already included in as part of the "first hop" USB3 tunnel.
561 struct tb_tunnel *tunnel; in tb_consumed_usb3_pcie_bandwidth() local
565 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_consumed_usb3_pcie_bandwidth()
566 if (tunnel && !tb_port_is_usb3_down(src_port) && in tb_consumed_usb3_pcie_bandwidth()
570 ret = tb_tunnel_consumed_bandwidth(tunnel, consumed_up, in tb_consumed_usb3_pcie_bandwidth()
598 * to @dst_port. Does not take tunnel starting from @src_port and ending
614 struct tb_tunnel *tunnel; in tb_consumed_dp_bandwidth() local
624 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_consumed_dp_bandwidth()
628 if (tb_tunnel_is_invalid(tunnel)) in tb_consumed_dp_bandwidth()
631 if (!tb_tunnel_is_dp(tunnel)) in tb_consumed_dp_bandwidth()
634 if (!tb_tunnel_port_on_path(tunnel, port)) in tb_consumed_dp_bandwidth()
642 group = tunnel->src_port->group; in tb_consumed_dp_bandwidth()
647 * Ignore the DP tunnel between src_port and dst_port in tb_consumed_dp_bandwidth()
648 * because it is the same tunnel and we may be in tb_consumed_dp_bandwidth()
651 if (tunnel->src_port == src_port && in tb_consumed_dp_bandwidth()
652 tunnel->dst_port == dst_port) in tb_consumed_dp_bandwidth()
655 ret = tb_tunnel_consumed_bandwidth(tunnel, &dp_consumed_up, in tb_consumed_dp_bandwidth()
866 struct tb_tunnel *tunnel; in tb_release_unused_usb3_bandwidth() local
868 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_release_unused_usb3_bandwidth()
869 return tunnel ? tb_tunnel_release_unused_bandwidth(tunnel) : 0; in tb_release_unused_usb3_bandwidth()
876 struct tb_tunnel *tunnel; in tb_reclaim_usb3_bandwidth() local
878 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_reclaim_usb3_bandwidth()
879 if (!tunnel) in tb_reclaim_usb3_bandwidth()
882 tb_tunnel_dbg(tunnel, "reclaiming unused bandwidth\n"); in tb_reclaim_usb3_bandwidth()
885 * Calculate available bandwidth for the first hop USB3 tunnel. in tb_reclaim_usb3_bandwidth()
888 ret = tb_available_bandwidth(tb, tunnel->src_port, tunnel->dst_port, in tb_reclaim_usb3_bandwidth()
891 tb_tunnel_warn(tunnel, "failed to calculate available bandwidth\n"); in tb_reclaim_usb3_bandwidth()
895 tb_tunnel_dbg(tunnel, "available bandwidth %d/%d Mb/s\n", available_up, in tb_reclaim_usb3_bandwidth()
898 tb_tunnel_reclaim_available_bandwidth(tunnel, &available_up, &available_down); in tb_reclaim_usb3_bandwidth()
907 struct tb_tunnel *tunnel; in tb_tunnel_usb3() local
910 tb_dbg(tb, "USB3 tunneling disabled, not creating tunnel\n"); in tb_tunnel_usb3()
935 * there is no point setting up a new tunnel. in tb_tunnel_usb3()
941 /* Make all unused bandwidth available for the new tunnel */ in tb_tunnel_usb3()
952 tb_port_dbg(up, "available bandwidth for new USB3 tunnel %d/%d Mb/s\n", in tb_tunnel_usb3()
955 tunnel = tb_tunnel_alloc_usb3(tb, up, down, available_up, in tb_tunnel_usb3()
957 if (!tunnel) { in tb_tunnel_usb3()
962 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_usb3()
964 "USB3 tunnel activation failed, aborting\n"); in tb_tunnel_usb3()
969 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_usb3()
976 tb_tunnel_put(tunnel); in tb_tunnel_usb3()
1402 tb_sw_warn(sw, "USB3 tunnel creation failed\n"); in tb_scan_port()
1428 struct tb_tunnel *tunnel; in tb_recalc_estimated_bandwidth_for_group() local
1434 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL); in tb_recalc_estimated_bandwidth_for_group()
1435 if (WARN_ON(!tunnel)) in tb_recalc_estimated_bandwidth_for_group()
1444 * for each tunnel separately. in tb_recalc_estimated_bandwidth_for_group()
1446 first_tunnel = tunnel; in tb_recalc_estimated_bandwidth_for_group()
1450 tb_tunnel_warn(tunnel, in tb_recalc_estimated_bandwidth_for_group()
1456 out = tunnel->dst_port; in tb_recalc_estimated_bandwidth_for_group()
1460 tb_tunnel_warn(tunnel, in tb_recalc_estimated_bandwidth_for_group()
1467 * - already allocated bandwidth for the DP tunnel in tb_recalc_estimated_bandwidth_for_group()
1471 if (tb_tunnel_direction_downstream(tunnel)) in tb_recalc_estimated_bandwidth_for_group()
1480 tb_tunnel_dbg(tunnel, in tb_recalc_estimated_bandwidth_for_group()
1487 tb_tunnel_warn(tunnel, in tb_recalc_estimated_bandwidth_for_group()
1528 struct tb_tunnel *tunnel; in __configure_group_sym() local
1541 * if the graphics released bandwidth for other tunnel in the in __configure_group_sym()
1545 tunnel = tb_find_tunnel(group->tb, TB_TUNNEL_DP, in, NULL); in __configure_group_sym()
1546 if (tunnel) in __configure_group_sym()
1547 tb_configure_sym(group->tb, in, tunnel->dst_port, true); in __configure_group_sym()
1609 struct tb_tunnel *tunnel; in tb_attach_bandwidth_group() local
1617 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_attach_bandwidth_group()
1618 if (!tb_tunnel_is_dp(tunnel)) in tb_attach_bandwidth_group()
1621 if (tunnel->src_port->sw == in->sw && in tb_attach_bandwidth_group()
1622 tunnel->dst_port->sw == out->sw) { in tb_attach_bandwidth_group()
1623 group = tunnel->src_port->group; in tb_attach_bandwidth_group()
1680 struct tb_tunnel *tunnel; in tb_discover_tunnels() local
1684 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_discover_tunnels()
1685 if (tb_tunnel_is_pci(tunnel)) { in tb_discover_tunnels()
1686 struct tb_switch *parent = tunnel->dst_port->sw; in tb_discover_tunnels()
1688 while (parent != tunnel->src_port->sw) { in tb_discover_tunnels()
1692 } else if (tb_tunnel_is_dp(tunnel)) { in tb_discover_tunnels()
1693 struct tb_port *in = tunnel->src_port; in tb_discover_tunnels()
1694 struct tb_port *out = tunnel->dst_port; in tb_discover_tunnels()
1705 static void tb_deactivate_and_free_tunnel(struct tb_tunnel *tunnel) in tb_deactivate_and_free_tunnel() argument
1710 if (!tunnel) in tb_deactivate_and_free_tunnel()
1713 tb_tunnel_deactivate(tunnel); in tb_deactivate_and_free_tunnel()
1714 list_del(&tunnel->list); in tb_deactivate_and_free_tunnel()
1716 tb = tunnel->tb; in tb_deactivate_and_free_tunnel()
1717 src_port = tunnel->src_port; in tb_deactivate_and_free_tunnel()
1718 dst_port = tunnel->dst_port; in tb_deactivate_and_free_tunnel()
1720 switch (tunnel->type) { in tb_deactivate_and_free_tunnel()
1724 * In case of DP tunnel make sure the DP IN resource is in tb_deactivate_and_free_tunnel()
1752 tb_tunnel_put(tunnel); in tb_deactivate_and_free_tunnel()
1761 struct tb_tunnel *tunnel; in tb_free_invalid_tunnels() local
1764 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_free_invalid_tunnels()
1765 if (tb_tunnel_is_invalid(tunnel)) in tb_free_invalid_tunnels()
1766 tb_deactivate_and_free_tunnel(tunnel); in tb_free_invalid_tunnels()
1872 * Keep the DP tunnel under the topology starting from in tb_find_dp_out()
1889 static void tb_dp_tunnel_active(struct tb_tunnel *tunnel, void *data) in tb_dp_tunnel_active() argument
1891 struct tb_port *in = tunnel->src_port; in tb_dp_tunnel_active()
1892 struct tb_port *out = tunnel->dst_port; in tb_dp_tunnel_active()
1896 if (tb_tunnel_is_active(tunnel)) { in tb_dp_tunnel_active()
1899 tb_tunnel_dbg(tunnel, "DPRX capabilities read completed\n"); in tb_dp_tunnel_active()
1901 /* If fail reading tunnel's consumed bandwidth, tear it down */ in tb_dp_tunnel_active()
1902 ret = tb_tunnel_consumed_bandwidth(tunnel, &consumed_up, in tb_dp_tunnel_active()
1905 tb_tunnel_warn(tunnel, in tb_dp_tunnel_active()
1907 tb_deactivate_and_free_tunnel(tunnel); in tb_dp_tunnel_active()
1922 * In case of DP tunnel exists, change host in tb_dp_tunnel_active()
1926 tb_increase_tmu_accuracy(tunnel); in tb_dp_tunnel_active()
1929 struct tb_port *in = tunnel->src_port; in tb_dp_tunnel_active()
1932 * This tunnel failed to establish. This means DPRX in tb_dp_tunnel_active()
1940 * also tear down the tunnel and try to re-use the in tb_dp_tunnel_active()
1946 tb_tunnel_warn(tunnel, "not active, tearing down\n"); in tb_dp_tunnel_active()
1959 struct tb_tunnel *tunnel; in tb_tunnel_one_dp() local
1968 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_tunnel_one_dp()
1969 if (tb_tunnel_is_dp(tunnel)) { in tb_tunnel_one_dp()
1977 * both ends of the tunnel. in tb_tunnel_one_dp()
1981 * tunnel is active. in tb_tunnel_one_dp()
1994 /* Make all unused USB3 bandwidth available for the new DP tunnel */ in tb_tunnel_one_dp()
2006 tb_dbg(tb, "available bandwidth for new DP tunnel %u/%u Mb/s\n", in tb_tunnel_one_dp()
2009 tunnel = tb_tunnel_alloc_dp(tb, in, out, link_nr, available_up, in tb_tunnel_one_dp()
2012 if (!tunnel) { in tb_tunnel_one_dp()
2013 tb_port_dbg(out, "could not allocate DP tunnel\n"); in tb_tunnel_one_dp()
2017 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_one_dp()
2019 ret = tb_tunnel_activate(tunnel); in tb_tunnel_one_dp()
2021 tb_port_info(out, "DP tunnel activation failed, aborting\n"); in tb_tunnel_one_dp()
2022 list_del(&tunnel->list); in tb_tunnel_one_dp()
2029 tb_tunnel_put(tunnel); in tb_tunnel_one_dp()
2050 tb_dbg(tb, "DP tunneling disabled, not creating tunnel\n"); in tb_tunnel_dp()
2056 * establish a DP tunnel between them. in tb_tunnel_dp()
2163 struct tb_tunnel *tunnel; in tb_dp_resource_unavailable() local
2175 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, out); in tb_dp_resource_unavailable()
2176 if (tunnel) in tb_dp_resource_unavailable()
2177 tb_deactivate_and_free_tunnel(tunnel); in tb_dp_resource_unavailable()
2184 * to create another tunnel. in tb_dp_resource_unavailable()
2215 struct tb_tunnel *tunnel, *n; in tb_disconnect_and_release_dp() local
2221 list_for_each_entry_safe_reverse(tunnel, n, &tcm->tunnel_list, list) { in tb_disconnect_and_release_dp()
2222 if (tb_tunnel_is_dp(tunnel)) in tb_disconnect_and_release_dp()
2223 tb_deactivate_and_free_tunnel(tunnel); in tb_disconnect_and_release_dp()
2237 struct tb_tunnel *tunnel; in tb_disconnect_pci() local
2244 tunnel = tb_find_tunnel(tb, TB_TUNNEL_PCI, NULL, up); in tb_disconnect_pci()
2245 if (WARN_ON(!tunnel)) in tb_disconnect_pci()
2250 tb_tunnel_deactivate(tunnel); in tb_disconnect_pci()
2251 list_del(&tunnel->list); in tb_disconnect_pci()
2252 tb_tunnel_put(tunnel); in tb_disconnect_pci()
2260 struct tb_tunnel *tunnel; in tb_tunnel_pci() local
2275 tunnel = tb_tunnel_alloc_pci(tb, up, down); in tb_tunnel_pci()
2276 if (!tunnel) in tb_tunnel_pci()
2279 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_pci()
2281 "PCIe tunnel activation failed, aborting\n"); in tb_tunnel_pci()
2282 tb_tunnel_put(tunnel); in tb_tunnel_pci()
2296 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_pci()
2306 struct tb_tunnel *tunnel; in tb_approve_xdomain_paths() local
2322 tunnel = tb_tunnel_alloc_dma(tb, nhi_port, dst_port, transmit_path, in tb_approve_xdomain_paths()
2324 if (!tunnel) { in tb_approve_xdomain_paths()
2329 if (tb_tunnel_activate(tunnel)) { in tb_approve_xdomain_paths()
2331 "DMA tunnel activation failed, aborting\n"); in tb_approve_xdomain_paths()
2336 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_approve_xdomain_paths()
2341 tb_tunnel_put(tunnel); in tb_approve_xdomain_paths()
2355 struct tb_tunnel *tunnel, *n; in __tb_disconnect_xdomain_paths() local
2362 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in __tb_disconnect_xdomain_paths()
2363 if (!tb_tunnel_is_dma(tunnel)) in __tb_disconnect_xdomain_paths()
2365 if (tunnel->src_port != nhi_port || tunnel->dst_port != dst_port) in __tb_disconnect_xdomain_paths()
2368 if (tb_tunnel_match_dma(tunnel, transmit_path, transmit_ring, in __tb_disconnect_xdomain_paths()
2370 tb_deactivate_and_free_tunnel(tunnel); in __tb_disconnect_xdomain_paths()
2375 * because we may still have another DMA tunnel active through in __tb_disconnect_xdomain_paths()
2455 /* Maybe we can create another DP tunnel */ in tb_handle_hotplug()
2514 static int tb_alloc_dp_bandwidth(struct tb_tunnel *tunnel, int *requested_up, in tb_alloc_dp_bandwidth() argument
2521 struct tb *tb = tunnel->tb; in tb_alloc_dp_bandwidth()
2525 ret = tb_tunnel_allocated_bandwidth(tunnel, &allocated_up, &allocated_down); in tb_alloc_dp_bandwidth()
2529 in = tunnel->src_port; in tb_alloc_dp_bandwidth()
2530 out = tunnel->dst_port; in tb_alloc_dp_bandwidth()
2532 tb_tunnel_dbg(tunnel, "bandwidth allocated currently %d/%d Mb/s\n", in tb_alloc_dp_bandwidth()
2547 ret = tb_tunnel_maximum_bandwidth(tunnel, &max_up, &max_down); in tb_alloc_dp_bandwidth()
2574 tb_tunnel_dbg(tunnel, "corrected bandwidth request %d/%d Mb/s\n", in tb_alloc_dp_bandwidth()
2579 tb_tunnel_dbg(tunnel, in tb_alloc_dp_bandwidth()
2587 downstream = tb_tunnel_direction_downstream(tunnel); in tb_alloc_dp_bandwidth()
2592 if (tunnel->bw_mode) { in tb_alloc_dp_bandwidth()
2596 * what is currently allocated to that tunnel we in tb_alloc_dp_bandwidth()
2597 * simply change the reservation of the tunnel in tb_alloc_dp_bandwidth()
2625 return tb_tunnel_alloc_bandwidth(tunnel, requested_up, in tb_alloc_dp_bandwidth()
2647 tb_tunnel_dbg(tunnel, "bandwidth available for allocation %d/%d (+ %u reserved) Mb/s\n", in tb_alloc_dp_bandwidth()
2667 ret = tb_tunnel_alloc_bandwidth(tunnel, requested_up, in tb_alloc_dp_bandwidth()
2670 tb_tunnel_warn(tunnel, "failed to allocate bandwidth\n"); in tb_alloc_dp_bandwidth()
2698 tb_tunnel_dbg(tunnel, in tb_alloc_dp_bandwidth()
2701 tb_tunnel_alloc_bandwidth(tunnel, &allocated_up, &allocated_down); in tb_alloc_dp_bandwidth()
2711 struct tb_tunnel *tunnel; in tb_handle_dp_bandwidth_request() local
2738 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL); in tb_handle_dp_bandwidth_request()
2739 if (!tunnel) { in tb_handle_dp_bandwidth_request()
2740 tb_port_warn(in, "failed to find tunnel\n"); in tb_handle_dp_bandwidth_request()
2745 if (tunnel->bw_mode) { in tb_handle_dp_bandwidth_request()
2747 * Reset the tunnel back to use the legacy in tb_handle_dp_bandwidth_request()
2750 tunnel->bw_mode = false; in tb_handle_dp_bandwidth_request()
2779 if (tb_tunnel_direction_downstream(tunnel)) { in tb_handle_dp_bandwidth_request()
2787 ret = tb_alloc_dp_bandwidth(tunnel, &requested_up, &requested_down); in tb_handle_dp_bandwidth_request()
2790 tb_tunnel_warn(tunnel, in tb_handle_dp_bandwidth_request()
2793 tb_tunnel_dbg(tunnel, "not active yet\n"); in tb_handle_dp_bandwidth_request()
2796 * tunnel is not yet active. This means that in tb_handle_dp_bandwidth_request()
2798 * this tunnel. Allow it some time and retry in tb_handle_dp_bandwidth_request()
2802 tb_tunnel_dbg(tunnel, in tb_handle_dp_bandwidth_request()
2809 tb_tunnel_dbg(tunnel, in tb_handle_dp_bandwidth_request()
2813 tb_tunnel_warn(tunnel, in tb_handle_dp_bandwidth_request()
2817 tb_tunnel_dbg(tunnel, in tb_handle_dp_bandwidth_request()
2912 struct tb_tunnel *tunnel; in tb_stop() local
2917 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_stop()
2923 if (tb_tunnel_is_dma(tunnel)) in tb_stop()
2924 tb_tunnel_deactivate(tunnel); in tb_stop()
2925 tb_tunnel_put(tunnel); in tb_stop()
3092 struct tb_tunnel *tunnel, *n; in tb_resume_noirq() local
3117 list_for_each_entry_safe_reverse(tunnel, n, &tunnels, list) { in tb_resume_noirq()
3118 if (tb_tunnel_is_usb3(tunnel)) in tb_resume_noirq()
3120 tb_tunnel_deactivate(tunnel); in tb_resume_noirq()
3121 tb_tunnel_put(tunnel); in tb_resume_noirq()
3125 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_resume_noirq()
3127 if (tb_tunnel_is_usb3(tunnel)) { in tb_resume_noirq()
3132 tb_tunnel_activate(tunnel); in tb_resume_noirq()
3235 struct tb_tunnel *tunnel, *n; in tb_runtime_resume() local
3241 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) in tb_runtime_resume()
3242 tb_tunnel_activate(tunnel); in tb_runtime_resume()