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