Lines Matching full:tunnel

17 #include "tunnel.h"
122 struct tb_tunnel *tunnel; in tb_attach_bandwidth_group() local
130 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_attach_bandwidth_group()
131 if (!tb_tunnel_is_dp(tunnel)) in tb_attach_bandwidth_group()
134 if (tunnel->src_port->sw == in->sw && in tb_attach_bandwidth_group()
135 tunnel->dst_port->sw == out->sw) { in tb_attach_bandwidth_group()
136 group = tunnel->src_port->group; in tb_attach_bandwidth_group()
268 struct tb_tunnel *tunnel; in tb_discover_dp_resources() local
270 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_discover_dp_resources()
271 if (tb_tunnel_is_dp(tunnel)) in tb_discover_dp_resources()
272 tb_discover_dp_resource(tb, tunnel->dst_port); in tb_discover_dp_resources()
281 const struct tb_tunnel *tunnel; in tb_enable_clx() local
302 * tunnel and in that case bail out. in tb_enable_clx()
304 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_enable_clx()
305 if (tb_tunnel_is_dma(tunnel)) { in tb_enable_clx()
306 if (tb_tunnel_port_on_path(tunnel, tb_upstream_port(sw))) in tb_enable_clx()
376 static void tb_increase_tmu_accuracy(struct tb_tunnel *tunnel) in tb_increase_tmu_accuracy() argument
380 if (!tunnel) in tb_increase_tmu_accuracy()
384 * Once first DP tunnel is established we change the TMU in tb_increase_tmu_accuracy()
392 sw = tunnel->tb->root_switch; in tb_increase_tmu_accuracy()
443 struct tb_tunnel *tunnel = NULL; in tb_switch_discover_tunnels() local
447 tunnel = tb_tunnel_discover_dp(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
448 tb_increase_tmu_accuracy(tunnel); in tb_switch_discover_tunnels()
452 tunnel = tb_tunnel_discover_pci(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
456 tunnel = tb_tunnel_discover_usb3(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
463 if (tunnel) in tb_switch_discover_tunnels()
464 list_add_tail(&tunnel->list, list); in tb_switch_discover_tunnels()
478 struct tb_tunnel *tunnel; in tb_discover_tunnels() local
482 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_discover_tunnels()
483 if (tb_tunnel_is_pci(tunnel)) { in tb_discover_tunnels()
484 struct tb_switch *parent = tunnel->dst_port->sw; in tb_discover_tunnels()
486 while (parent != tunnel->src_port->sw) { in tb_discover_tunnels()
490 } else if (tb_tunnel_is_dp(tunnel)) { in tb_discover_tunnels()
491 struct tb_port *in = tunnel->src_port; in tb_discover_tunnels()
492 struct tb_port *out = tunnel->dst_port; in tb_discover_tunnels()
584 struct tb_tunnel *tunnel; in tb_find_tunnel() local
586 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_find_tunnel()
587 if (tunnel->type == type && in tb_find_tunnel()
588 ((src_port && src_port == tunnel->src_port) || in tb_find_tunnel()
589 (dst_port && dst_port == tunnel->dst_port))) { in tb_find_tunnel()
590 return tunnel; in tb_find_tunnel()
634 * from @src_port to @dst_port. Does not take tunnel starting from
645 struct tb_tunnel *tunnel; in tb_consumed_usb3_pcie_bandwidth() local
649 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_consumed_usb3_pcie_bandwidth()
650 if (tunnel && tunnel->src_port != src_port && in tb_consumed_usb3_pcie_bandwidth()
651 tunnel->dst_port != dst_port) { in tb_consumed_usb3_pcie_bandwidth()
654 ret = tb_tunnel_consumed_bandwidth(tunnel, consumed_up, in tb_consumed_usb3_pcie_bandwidth()
682 * to @dst_port. Does not take tunnel starting from @src_port and ending
693 struct tb_tunnel *tunnel; in tb_consumed_dp_bandwidth() local
702 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_consumed_dp_bandwidth()
705 if (tb_tunnel_is_invalid(tunnel)) in tb_consumed_dp_bandwidth()
708 if (!tb_tunnel_is_dp(tunnel)) in tb_consumed_dp_bandwidth()
711 if (!tb_tunnel_port_on_path(tunnel, port)) in tb_consumed_dp_bandwidth()
715 * Ignore the DP tunnel between src_port and dst_port in tb_consumed_dp_bandwidth()
716 * because it is the same tunnel and we may be in tb_consumed_dp_bandwidth()
719 if (tunnel->src_port == src_port && in tb_consumed_dp_bandwidth()
720 tunnel->dst_port == dst_port) in tb_consumed_dp_bandwidth()
723 ret = tb_tunnel_consumed_bandwidth(tunnel, &dp_consumed_up, in tb_consumed_dp_bandwidth()
926 struct tb_tunnel *tunnel; in tb_release_unused_usb3_bandwidth() local
928 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_release_unused_usb3_bandwidth()
929 return tunnel ? tb_tunnel_release_unused_bandwidth(tunnel) : 0; in tb_release_unused_usb3_bandwidth()
936 struct tb_tunnel *tunnel; in tb_reclaim_usb3_bandwidth() local
938 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_reclaim_usb3_bandwidth()
939 if (!tunnel) in tb_reclaim_usb3_bandwidth()
942 tb_tunnel_dbg(tunnel, "reclaiming unused bandwidth\n"); in tb_reclaim_usb3_bandwidth()
945 * Calculate available bandwidth for the first hop USB3 tunnel. in tb_reclaim_usb3_bandwidth()
948 ret = tb_available_bandwidth(tb, tunnel->src_port, tunnel->dst_port, in tb_reclaim_usb3_bandwidth()
951 tb_tunnel_warn(tunnel, "failed to calculate available bandwidth\n"); in tb_reclaim_usb3_bandwidth()
955 tb_tunnel_dbg(tunnel, "available bandwidth %d/%d Mb/s\n", available_up, in tb_reclaim_usb3_bandwidth()
958 tb_tunnel_reclaim_available_bandwidth(tunnel, &available_up, &available_down); in tb_reclaim_usb3_bandwidth()
967 struct tb_tunnel *tunnel; in tb_tunnel_usb3() local
970 tb_dbg(tb, "USB3 tunneling disabled, not creating tunnel\n"); in tb_tunnel_usb3()
995 * there is no point setting up a new tunnel. in tb_tunnel_usb3()
1001 /* Make all unused bandwidth available for the new tunnel */ in tb_tunnel_usb3()
1012 tb_port_dbg(up, "available bandwidth for new USB3 tunnel %d/%d Mb/s\n", in tb_tunnel_usb3()
1015 tunnel = tb_tunnel_alloc_usb3(tb, up, down, available_up, in tb_tunnel_usb3()
1017 if (!tunnel) { in tb_tunnel_usb3()
1022 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_usb3()
1024 "USB3 tunnel activation failed, aborting\n"); in tb_tunnel_usb3()
1029 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_usb3()
1036 tb_tunnel_free(tunnel); in tb_tunnel_usb3()
1455 tb_sw_warn(sw, "USB3 tunnel creation failed\n"); in tb_scan_port()
1467 static void tb_deactivate_and_free_tunnel(struct tb_tunnel *tunnel) in tb_deactivate_and_free_tunnel() argument
1472 if (!tunnel) in tb_deactivate_and_free_tunnel()
1475 tb_tunnel_deactivate(tunnel); in tb_deactivate_and_free_tunnel()
1476 list_del(&tunnel->list); in tb_deactivate_and_free_tunnel()
1478 tb = tunnel->tb; in tb_deactivate_and_free_tunnel()
1479 src_port = tunnel->src_port; in tb_deactivate_and_free_tunnel()
1480 dst_port = tunnel->dst_port; in tb_deactivate_and_free_tunnel()
1482 switch (tunnel->type) { in tb_deactivate_and_free_tunnel()
1486 * In case of DP tunnel make sure the DP IN resource is in tb_deactivate_and_free_tunnel()
1514 tb_tunnel_free(tunnel); in tb_deactivate_and_free_tunnel()
1523 struct tb_tunnel *tunnel; in tb_free_invalid_tunnels() local
1526 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_free_invalid_tunnels()
1527 if (tb_tunnel_is_invalid(tunnel)) in tb_free_invalid_tunnels()
1528 tb_deactivate_and_free_tunnel(tunnel); in tb_free_invalid_tunnels()
1622 struct tb_tunnel *tunnel; in tb_recalc_estimated_bandwidth_for_group() local
1628 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL); in tb_recalc_estimated_bandwidth_for_group()
1629 if (WARN_ON(!tunnel)) in tb_recalc_estimated_bandwidth_for_group()
1638 * for each tunnel separately. in tb_recalc_estimated_bandwidth_for_group()
1640 first_tunnel = tunnel; in tb_recalc_estimated_bandwidth_for_group()
1644 tb_tunnel_warn(tunnel, in tb_recalc_estimated_bandwidth_for_group()
1650 out = tunnel->dst_port; in tb_recalc_estimated_bandwidth_for_group()
1654 tb_tunnel_warn(tunnel, in tb_recalc_estimated_bandwidth_for_group()
1661 * - already allocated bandwidth for the DP tunnel in tb_recalc_estimated_bandwidth_for_group()
1665 tb_tunnel_dbg(tunnel, in tb_recalc_estimated_bandwidth_for_group()
1675 tb_tunnel_warn(tunnel, in tb_recalc_estimated_bandwidth_for_group()
1723 * Keep the DP tunnel under the topology starting from in tb_find_dp_out()
1746 struct tb_tunnel *tunnel; in tb_tunnel_one_dp() local
1750 * establish a DP tunnel between them. in tb_tunnel_one_dp()
1789 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_tunnel_one_dp()
1790 if (tb_tunnel_is_dp(tunnel)) { in tb_tunnel_one_dp()
1798 * both ends of the tunnel. in tb_tunnel_one_dp()
1802 * tunnel is active. in tb_tunnel_one_dp()
1815 /* Make all unused USB3 bandwidth available for the new DP tunnel */ in tb_tunnel_one_dp()
1827 tb_dbg(tb, "available bandwidth for new DP tunnel %u/%u Mb/s\n", in tb_tunnel_one_dp()
1830 tunnel = tb_tunnel_alloc_dp(tb, in, out, link_nr, available_up, in tb_tunnel_one_dp()
1832 if (!tunnel) { in tb_tunnel_one_dp()
1833 tb_port_dbg(out, "could not allocate DP tunnel\n"); in tb_tunnel_one_dp()
1837 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_one_dp()
1838 tb_port_info(out, "DP tunnel activation failed, aborting\n"); in tb_tunnel_one_dp()
1842 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_one_dp()
1849 if (!tb_tunnel_consumed_bandwidth(tunnel, &consumed_up, &consumed_down)) in tb_tunnel_one_dp()
1856 * In case of DP tunnel exists, change host router's 1st children in tb_tunnel_one_dp()
1859 tb_increase_tmu_accuracy(tunnel); in tb_tunnel_one_dp()
1863 tb_tunnel_free(tunnel); in tb_tunnel_one_dp()
1882 tb_dbg(tb, "DP tunneling disabled, not creating tunnel\n"); in tb_tunnel_dp()
1893 struct tb_tunnel *tunnel; in tb_dp_resource_unavailable() local
1905 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, out); in tb_dp_resource_unavailable()
1906 tb_deactivate_and_free_tunnel(tunnel); in tb_dp_resource_unavailable()
1911 * to create another tunnel. in tb_dp_resource_unavailable()
1941 struct tb_tunnel *tunnel, *n; in tb_disconnect_and_release_dp() local
1947 list_for_each_entry_safe_reverse(tunnel, n, &tcm->tunnel_list, list) { in tb_disconnect_and_release_dp()
1948 if (tb_tunnel_is_dp(tunnel)) in tb_disconnect_and_release_dp()
1949 tb_deactivate_and_free_tunnel(tunnel); in tb_disconnect_and_release_dp()
1963 struct tb_tunnel *tunnel; in tb_disconnect_pci() local
1970 tunnel = tb_find_tunnel(tb, TB_TUNNEL_PCI, NULL, up); in tb_disconnect_pci()
1971 if (WARN_ON(!tunnel)) in tb_disconnect_pci()
1976 tb_tunnel_deactivate(tunnel); in tb_disconnect_pci()
1977 list_del(&tunnel->list); in tb_disconnect_pci()
1978 tb_tunnel_free(tunnel); in tb_disconnect_pci()
1986 struct tb_tunnel *tunnel; in tb_tunnel_pci() local
2001 tunnel = tb_tunnel_alloc_pci(tb, up, down); in tb_tunnel_pci()
2002 if (!tunnel) in tb_tunnel_pci()
2005 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_pci()
2007 "PCIe tunnel activation failed, aborting\n"); in tb_tunnel_pci()
2008 tb_tunnel_free(tunnel); in tb_tunnel_pci()
2022 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_pci()
2032 struct tb_tunnel *tunnel; in tb_approve_xdomain_paths() local
2048 tunnel = tb_tunnel_alloc_dma(tb, nhi_port, dst_port, transmit_path, in tb_approve_xdomain_paths()
2050 if (!tunnel) { in tb_approve_xdomain_paths()
2055 if (tb_tunnel_activate(tunnel)) { in tb_approve_xdomain_paths()
2057 "DMA tunnel activation failed, aborting\n"); in tb_approve_xdomain_paths()
2062 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_approve_xdomain_paths()
2067 tb_tunnel_free(tunnel); in tb_approve_xdomain_paths()
2081 struct tb_tunnel *tunnel, *n; in __tb_disconnect_xdomain_paths() local
2088 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in __tb_disconnect_xdomain_paths()
2089 if (!tb_tunnel_is_dma(tunnel)) in __tb_disconnect_xdomain_paths()
2091 if (tunnel->src_port != nhi_port || tunnel->dst_port != dst_port) in __tb_disconnect_xdomain_paths()
2094 if (tb_tunnel_match_dma(tunnel, transmit_path, transmit_ring, in __tb_disconnect_xdomain_paths()
2096 tb_deactivate_and_free_tunnel(tunnel); in __tb_disconnect_xdomain_paths()
2101 * because we may still have another DMA tunnel active through in __tb_disconnect_xdomain_paths()
2181 /* Maybe we can create another DP tunnel */ in tb_handle_hotplug()
2240 static int tb_alloc_dp_bandwidth(struct tb_tunnel *tunnel, int *requested_up, in tb_alloc_dp_bandwidth() argument
2246 struct tb *tb = tunnel->tb; in tb_alloc_dp_bandwidth()
2249 ret = tb_tunnel_allocated_bandwidth(tunnel, &allocated_up, &allocated_down); in tb_alloc_dp_bandwidth()
2253 in = tunnel->src_port; in tb_alloc_dp_bandwidth()
2254 out = tunnel->dst_port; in tb_alloc_dp_bandwidth()
2256 tb_tunnel_dbg(tunnel, "bandwidth allocated currently %d/%d Mb/s\n", in tb_alloc_dp_bandwidth()
2271 ret = tb_tunnel_maximum_bandwidth(tunnel, &max_up, &max_down); in tb_alloc_dp_bandwidth()
2298 tb_tunnel_dbg(tunnel, "corrected bandwidth request %d/%d Mb/s\n", in tb_alloc_dp_bandwidth()
2303 tb_tunnel_dbg(tunnel, in tb_alloc_dp_bandwidth()
2319 * currently allocated to that tunnel we simply change in tb_alloc_dp_bandwidth()
2320 * the reservation of the tunnel. Since all the tunnels in tb_alloc_dp_bandwidth()
2325 return tb_tunnel_alloc_bandwidth(tunnel, requested_up, in tb_alloc_dp_bandwidth()
2347 tb_tunnel_dbg(tunnel, "bandwidth available for allocation %d/%d Mb/s\n", in tb_alloc_dp_bandwidth()
2363 ret = tb_tunnel_alloc_bandwidth(tunnel, requested_up, in tb_alloc_dp_bandwidth()
2366 tb_tunnel_warn(tunnel, "failed to allocate bandwidth\n"); in tb_alloc_dp_bandwidth()
2383 struct tb_tunnel *tunnel; in tb_handle_dp_bandwidth_request() local
2426 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL); in tb_handle_dp_bandwidth_request()
2427 if (!tunnel) { in tb_handle_dp_bandwidth_request()
2428 tb_port_warn(in, "failed to find tunnel\n"); in tb_handle_dp_bandwidth_request()
2432 out = tunnel->dst_port; in tb_handle_dp_bandwidth_request()
2442 ret = tb_alloc_dp_bandwidth(tunnel, &requested_up, &requested_down); in tb_handle_dp_bandwidth_request()
2445 tb_tunnel_warn(tunnel, in tb_handle_dp_bandwidth_request()
2448 tb_tunnel_warn(tunnel, in tb_handle_dp_bandwidth_request()
2451 tb_tunnel_dbg(tunnel, in tb_handle_dp_bandwidth_request()
2544 struct tb_tunnel *tunnel; in tb_stop() local
2549 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_stop()
2555 if (tb_tunnel_is_dma(tunnel)) in tb_stop()
2556 tb_tunnel_deactivate(tunnel); in tb_stop()
2557 tb_tunnel_free(tunnel); in tb_stop()
2695 struct tb_tunnel *tunnel, *n; in tb_resume_noirq() local
2716 list_for_each_entry_safe_reverse(tunnel, n, &tunnels, list) { in tb_resume_noirq()
2717 if (tb_tunnel_is_usb3(tunnel)) in tb_resume_noirq()
2719 tb_tunnel_deactivate(tunnel); in tb_resume_noirq()
2720 tb_tunnel_free(tunnel); in tb_resume_noirq()
2724 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_resume_noirq()
2726 if (tb_tunnel_is_usb3(tunnel)) { in tb_resume_noirq()
2731 tb_tunnel_restart(tunnel); in tb_resume_noirq()
2827 struct tb_tunnel *tunnel, *n; in tb_runtime_resume() local
2833 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) in tb_runtime_resume()
2834 tb_tunnel_restart(tunnel); in tb_runtime_resume()