• Home
  • Raw
  • Download

Lines Matching full:tunnel

17 #include "tunnel.h"
99 struct tb_tunnel *tunnel; in tb_attach_bandwidth_group() local
107 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_attach_bandwidth_group()
108 if (!tb_tunnel_is_dp(tunnel)) in tb_attach_bandwidth_group()
111 if (tunnel->src_port->sw == in->sw && in tb_attach_bandwidth_group()
112 tunnel->dst_port->sw == out->sw) { in tb_attach_bandwidth_group()
113 group = tunnel->src_port->group; in tb_attach_bandwidth_group()
235 struct tb_tunnel *tunnel; in tb_discover_dp_resources() local
237 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_discover_dp_resources()
238 if (tb_tunnel_is_dp(tunnel)) in tb_discover_dp_resources()
239 tb_discover_dp_resource(tb, tunnel->dst_port); in tb_discover_dp_resources()
248 const struct tb_tunnel *tunnel; in tb_enable_clx() local
269 * tunnel and in that case bail out. in tb_enable_clx()
271 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_enable_clx()
272 if (tb_tunnel_is_dma(tunnel)) { in tb_enable_clx()
273 if (tb_tunnel_port_on_path(tunnel, tb_upstream_port(sw))) in tb_enable_clx()
325 static void tb_increase_tmu_accuracy(struct tb_tunnel *tunnel) in tb_increase_tmu_accuracy() argument
329 if (!tunnel) in tb_increase_tmu_accuracy()
333 * Once first DP tunnel is established we change the TMU in tb_increase_tmu_accuracy()
341 sw = tunnel->tb->root_switch; in tb_increase_tmu_accuracy()
392 struct tb_tunnel *tunnel = NULL; in tb_switch_discover_tunnels() local
396 tunnel = tb_tunnel_discover_dp(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
397 tb_increase_tmu_accuracy(tunnel); in tb_switch_discover_tunnels()
401 tunnel = tb_tunnel_discover_pci(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
405 tunnel = tb_tunnel_discover_usb3(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
412 if (tunnel) in tb_switch_discover_tunnels()
413 list_add_tail(&tunnel->list, list); in tb_switch_discover_tunnels()
427 struct tb_tunnel *tunnel; in tb_discover_tunnels() local
431 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_discover_tunnels()
432 if (tb_tunnel_is_pci(tunnel)) { in tb_discover_tunnels()
433 struct tb_switch *parent = tunnel->dst_port->sw; in tb_discover_tunnels()
435 while (parent != tunnel->src_port->sw) { in tb_discover_tunnels()
439 } else if (tb_tunnel_is_dp(tunnel)) { in tb_discover_tunnels()
440 struct tb_port *in = tunnel->src_port; in tb_discover_tunnels()
441 struct tb_port *out = tunnel->dst_port; in tb_discover_tunnels()
535 struct tb_tunnel *tunnel; in tb_find_tunnel() local
537 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_find_tunnel()
538 if (tunnel->type == type && in tb_find_tunnel()
539 ((src_port && src_port == tunnel->src_port) || in tb_find_tunnel()
540 (dst_port && dst_port == tunnel->dst_port))) { in tb_find_tunnel()
541 return tunnel; in tb_find_tunnel()
580 struct tb_tunnel *tunnel; in tb_available_bandwidth() local
587 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_available_bandwidth()
588 if (tunnel && tunnel->src_port != src_port && in tb_available_bandwidth()
589 tunnel->dst_port != dst_port) { in tb_available_bandwidth()
590 ret = tb_tunnel_consumed_bandwidth(tunnel, &usb3_consumed_up, in tb_available_bandwidth()
658 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_available_bandwidth()
661 if (tb_tunnel_is_invalid(tunnel)) in tb_available_bandwidth()
664 if (!tb_tunnel_is_dp(tunnel)) in tb_available_bandwidth()
667 if (!tb_tunnel_port_on_path(tunnel, port)) in tb_available_bandwidth()
671 * Ignore the DP tunnel between src_port and in tb_available_bandwidth()
672 * dst_port because it is the same tunnel and we in tb_available_bandwidth()
675 if (tunnel->src_port == src_port && in tb_available_bandwidth()
676 tunnel->dst_port == dst_port) in tb_available_bandwidth()
679 ret = tb_tunnel_consumed_bandwidth(tunnel, in tb_available_bandwidth()
716 struct tb_tunnel *tunnel; in tb_release_unused_usb3_bandwidth() local
718 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_release_unused_usb3_bandwidth()
719 return tunnel ? tb_tunnel_release_unused_bandwidth(tunnel) : 0; in tb_release_unused_usb3_bandwidth()
726 struct tb_tunnel *tunnel; in tb_reclaim_usb3_bandwidth() local
728 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_reclaim_usb3_bandwidth()
729 if (!tunnel) in tb_reclaim_usb3_bandwidth()
735 * Calculate available bandwidth for the first hop USB3 tunnel. in tb_reclaim_usb3_bandwidth()
738 ret = tb_available_bandwidth(tb, tunnel->src_port, tunnel->dst_port, in tb_reclaim_usb3_bandwidth()
748 tb_tunnel_reclaim_available_bandwidth(tunnel, &available_up, &available_down); in tb_reclaim_usb3_bandwidth()
757 struct tb_tunnel *tunnel; in tb_tunnel_usb3() local
760 tb_dbg(tb, "USB3 tunneling disabled, not creating tunnel\n"); in tb_tunnel_usb3()
785 * there is no point setting up a new tunnel. in tb_tunnel_usb3()
791 /* Make all unused bandwidth available for the new tunnel */ in tb_tunnel_usb3()
802 tb_port_dbg(up, "available bandwidth for new USB3 tunnel %d/%d Mb/s\n", in tb_tunnel_usb3()
805 tunnel = tb_tunnel_alloc_usb3(tb, up, down, available_up, in tb_tunnel_usb3()
807 if (!tunnel) { in tb_tunnel_usb3()
812 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_usb3()
814 "USB3 tunnel activation failed, aborting\n"); in tb_tunnel_usb3()
819 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_usb3()
826 tb_tunnel_free(tunnel); in tb_tunnel_usb3()
1008 tb_sw_warn(sw, "USB3 tunnel creation failed\n"); in tb_scan_port()
1020 static void tb_deactivate_and_free_tunnel(struct tb_tunnel *tunnel) in tb_deactivate_and_free_tunnel() argument
1025 if (!tunnel) in tb_deactivate_and_free_tunnel()
1028 tb_tunnel_deactivate(tunnel); in tb_deactivate_and_free_tunnel()
1029 list_del(&tunnel->list); in tb_deactivate_and_free_tunnel()
1031 tb = tunnel->tb; in tb_deactivate_and_free_tunnel()
1032 src_port = tunnel->src_port; in tb_deactivate_and_free_tunnel()
1033 dst_port = tunnel->dst_port; in tb_deactivate_and_free_tunnel()
1035 switch (tunnel->type) { in tb_deactivate_and_free_tunnel()
1039 * In case of DP tunnel make sure the DP IN resource is in tb_deactivate_and_free_tunnel()
1062 tb_tunnel_free(tunnel); in tb_deactivate_and_free_tunnel()
1071 struct tb_tunnel *tunnel; in tb_free_invalid_tunnels() local
1074 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_free_invalid_tunnels()
1075 if (tb_tunnel_is_invalid(tunnel)) in tb_free_invalid_tunnels()
1076 tb_deactivate_and_free_tunnel(tunnel); in tb_free_invalid_tunnels()
1169 struct tb_tunnel *tunnel; in tb_recalc_estimated_bandwidth_for_group() local
1175 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL); in tb_recalc_estimated_bandwidth_for_group()
1176 if (WARN_ON(!tunnel)) in tb_recalc_estimated_bandwidth_for_group()
1185 * for each tunnel separately. in tb_recalc_estimated_bandwidth_for_group()
1187 first_tunnel = tunnel; in tb_recalc_estimated_bandwidth_for_group()
1197 out = tunnel->dst_port; in tb_recalc_estimated_bandwidth_for_group()
1208 * - already allocated bandwidth for the DP tunnel in tb_recalc_estimated_bandwidth_for_group()
1268 * Keep the DP tunnel under the topology starting from in tb_find_dp_out()
1290 struct tb_tunnel *tunnel; in tb_tunnel_dp() local
1293 tb_dbg(tb, "DP tunneling disabled, not creating tunnel\n"); in tb_tunnel_dp()
1299 * establish a DP tunnel between them. in tb_tunnel_dp()
1339 list_for_each_entry(tunnel, &tcm->tunnel_list, list) { in tb_tunnel_dp()
1340 if (tb_tunnel_is_dp(tunnel)) { in tb_tunnel_dp()
1348 * both ends of the tunnel. in tb_tunnel_dp()
1352 * tunnel is active. in tb_tunnel_dp()
1365 /* Make all unused USB3 bandwidth available for the new DP tunnel */ in tb_tunnel_dp()
1376 tb_dbg(tb, "available bandwidth for new DP tunnel %u/%u Mb/s\n", in tb_tunnel_dp()
1379 tunnel = tb_tunnel_alloc_dp(tb, in, out, link_nr, available_up, in tb_tunnel_dp()
1381 if (!tunnel) { in tb_tunnel_dp()
1382 tb_port_dbg(out, "could not allocate DP tunnel\n"); in tb_tunnel_dp()
1386 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_dp()
1387 tb_port_info(out, "DP tunnel activation failed, aborting\n"); in tb_tunnel_dp()
1391 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_dp()
1398 * In case of DP tunnel exists, change host router's 1st children in tb_tunnel_dp()
1401 tb_increase_tmu_accuracy(tunnel); in tb_tunnel_dp()
1405 tb_tunnel_free(tunnel); in tb_tunnel_dp()
1422 struct tb_tunnel *tunnel; in tb_dp_resource_unavailable() local
1434 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, out); in tb_dp_resource_unavailable()
1435 tb_deactivate_and_free_tunnel(tunnel); in tb_dp_resource_unavailable()
1440 * to create another tunnel. in tb_dp_resource_unavailable()
1470 struct tb_tunnel *tunnel, *n; in tb_disconnect_and_release_dp() local
1476 list_for_each_entry_safe_reverse(tunnel, n, &tcm->tunnel_list, list) { in tb_disconnect_and_release_dp()
1477 if (tb_tunnel_is_dp(tunnel)) in tb_disconnect_and_release_dp()
1478 tb_deactivate_and_free_tunnel(tunnel); in tb_disconnect_and_release_dp()
1492 struct tb_tunnel *tunnel; in tb_disconnect_pci() local
1499 tunnel = tb_find_tunnel(tb, TB_TUNNEL_PCI, NULL, up); in tb_disconnect_pci()
1500 if (WARN_ON(!tunnel)) in tb_disconnect_pci()
1505 tb_tunnel_deactivate(tunnel); in tb_disconnect_pci()
1506 list_del(&tunnel->list); in tb_disconnect_pci()
1507 tb_tunnel_free(tunnel); in tb_disconnect_pci()
1515 struct tb_tunnel *tunnel; in tb_tunnel_pci() local
1530 tunnel = tb_tunnel_alloc_pci(tb, up, down); in tb_tunnel_pci()
1531 if (!tunnel) in tb_tunnel_pci()
1534 if (tb_tunnel_activate(tunnel)) { in tb_tunnel_pci()
1536 "PCIe tunnel activation failed, aborting\n"); in tb_tunnel_pci()
1537 tb_tunnel_free(tunnel); in tb_tunnel_pci()
1551 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_tunnel_pci()
1561 struct tb_tunnel *tunnel; in tb_approve_xdomain_paths() local
1577 tunnel = tb_tunnel_alloc_dma(tb, nhi_port, dst_port, transmit_path, in tb_approve_xdomain_paths()
1579 if (!tunnel) { in tb_approve_xdomain_paths()
1584 if (tb_tunnel_activate(tunnel)) { in tb_approve_xdomain_paths()
1586 "DMA tunnel activation failed, aborting\n"); in tb_approve_xdomain_paths()
1591 list_add_tail(&tunnel->list, &tcm->tunnel_list); in tb_approve_xdomain_paths()
1596 tb_tunnel_free(tunnel); in tb_approve_xdomain_paths()
1610 struct tb_tunnel *tunnel, *n; in __tb_disconnect_xdomain_paths() local
1617 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in __tb_disconnect_xdomain_paths()
1618 if (!tb_tunnel_is_dma(tunnel)) in __tb_disconnect_xdomain_paths()
1620 if (tunnel->src_port != nhi_port || tunnel->dst_port != dst_port) in __tb_disconnect_xdomain_paths()
1623 if (tb_tunnel_match_dma(tunnel, transmit_path, transmit_ring, in __tb_disconnect_xdomain_paths()
1625 tb_deactivate_and_free_tunnel(tunnel); in __tb_disconnect_xdomain_paths()
1630 * because we may still have another DMA tunnel active through in __tb_disconnect_xdomain_paths()
1709 /* Maybe we can create another DP tunnel */ in tb_handle_hotplug()
1768 static int tb_alloc_dp_bandwidth(struct tb_tunnel *tunnel, int *requested_up, in tb_alloc_dp_bandwidth() argument
1774 struct tb *tb = tunnel->tb; in tb_alloc_dp_bandwidth()
1777 ret = tb_tunnel_allocated_bandwidth(tunnel, &allocated_up, &allocated_down); in tb_alloc_dp_bandwidth()
1781 in = tunnel->src_port; in tb_alloc_dp_bandwidth()
1782 out = tunnel->dst_port; in tb_alloc_dp_bandwidth()
1799 ret = tb_tunnel_maximum_bandwidth(tunnel, &max_up, &max_down); in tb_alloc_dp_bandwidth()
1841 * currently allocated to that tunnel we simply change in tb_alloc_dp_bandwidth()
1842 * the reservation of the tunnel. Since all the tunnels in tb_alloc_dp_bandwidth()
1847 return tb_tunnel_alloc_bandwidth(tunnel, requested_up, in tb_alloc_dp_bandwidth()
1873 ret = tb_tunnel_alloc_bandwidth(tunnel, requested_up, in tb_alloc_dp_bandwidth()
1889 struct tb_tunnel *tunnel; in tb_handle_dp_bandwidth_request() local
1932 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL); in tb_handle_dp_bandwidth_request()
1933 if (!tunnel) { in tb_handle_dp_bandwidth_request()
1934 tb_port_warn(in, "failed to find tunnel\n"); in tb_handle_dp_bandwidth_request()
1938 out = tunnel->dst_port; in tb_handle_dp_bandwidth_request()
1948 ret = tb_alloc_dp_bandwidth(tunnel, &requested_up, &requested_down); in tb_handle_dp_bandwidth_request()
2047 struct tb_tunnel *tunnel; in tb_stop() local
2052 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_stop()
2058 if (tb_tunnel_is_dma(tunnel)) in tb_stop()
2059 tb_tunnel_deactivate(tunnel); in tb_stop()
2060 tb_tunnel_free(tunnel); in tb_stop()
2197 struct tb_tunnel *tunnel, *n; in tb_resume_noirq() local
2218 list_for_each_entry_safe_reverse(tunnel, n, &tunnels, list) { in tb_resume_noirq()
2219 if (tb_tunnel_is_usb3(tunnel)) in tb_resume_noirq()
2221 tb_tunnel_deactivate(tunnel); in tb_resume_noirq()
2222 tb_tunnel_free(tunnel); in tb_resume_noirq()
2226 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { in tb_resume_noirq()
2228 if (tb_tunnel_is_usb3(tunnel)) { in tb_resume_noirq()
2233 tb_tunnel_restart(tunnel); in tb_resume_noirq()
2329 struct tb_tunnel *tunnel, *n; in tb_runtime_resume() local
2335 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) in tb_runtime_resume()
2336 tb_tunnel_restart(tunnel); in tb_runtime_resume()