Lines Matching refs:tunnel

16 #include "tunnel.h"
112 struct tb_tunnel *tunnel = NULL;
116 tunnel = tb_tunnel_discover_dp(tb, port);
120 tunnel = tb_tunnel_discover_pci(tb, port);
124 tunnel = tb_tunnel_discover_usb3(tb, port);
131 if (!tunnel)
134 if (tb_tunnel_is_pci(tunnel)) {
135 struct tb_switch *parent = tunnel->dst_port->sw;
137 while (parent != tunnel->src_port->sw) {
141 } else if (tb_tunnel_is_dp(tunnel)) {
143 pm_runtime_get_sync(&tunnel->src_port->sw->dev);
144 pm_runtime_get_sync(&tunnel->dst_port->sw->dev);
147 list_add_tail(&tunnel->list, &tcm->tunnel_list);
261 struct tb_tunnel *tunnel;
263 list_for_each_entry(tunnel, &tcm->tunnel_list, list) {
264 if (tunnel->type == type &&
265 ((src_port && src_port == tunnel->src_port) ||
266 (dst_port && dst_port == tunnel->dst_port))) {
267 return tunnel;
306 struct tb_tunnel *tunnel;
311 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port);
312 if (tunnel) {
313 ret = tb_tunnel_consumed_bandwidth(tunnel, &usb3_consumed_up,
352 list_for_each_entry(tunnel, &tcm->tunnel_list, list) {
355 if (!tb_tunnel_is_dp(tunnel))
358 if (!tb_tunnel_port_on_path(tunnel, port))
361 ret = tb_tunnel_consumed_bandwidth(tunnel,
398 struct tb_tunnel *tunnel;
400 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port);
401 return tunnel ? tb_tunnel_release_unused_bandwidth(tunnel) : 0;
408 struct tb_tunnel *tunnel;
410 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port);
411 if (!tunnel)
417 * Calculate available bandwidth for the first hop USB3 tunnel.
420 ret = tb_available_bandwidth(tb, tunnel->src_port, tunnel->dst_port,
430 tb_tunnel_reclaim_available_bandwidth(tunnel, &available_up, &available_down);
439 struct tb_tunnel *tunnel;
462 * there is no point setting up a new tunnel.
468 /* Make all unused bandwidth available for the new tunnel */
479 tb_port_dbg(up, "available bandwidth for new USB3 tunnel %d/%d Mb/s\n",
482 tunnel = tb_tunnel_alloc_usb3(tb, up, down, available_up,
484 if (!tunnel) {
489 if (tb_tunnel_activate(tunnel)) {
491 "USB3 tunnel activation failed, aborting\n");
496 list_add_tail(&tunnel->list, &tcm->tunnel_list);
503 tb_tunnel_free(tunnel);
661 tb_sw_warn(sw, "USB3 tunnel creation failed\n");
667 static void tb_deactivate_and_free_tunnel(struct tb_tunnel *tunnel)
672 if (!tunnel)
675 tb_tunnel_deactivate(tunnel);
676 list_del(&tunnel->list);
678 tb = tunnel->tb;
679 src_port = tunnel->src_port;
680 dst_port = tunnel->dst_port;
682 switch (tunnel->type) {
685 * In case of DP tunnel make sure the DP IN resource is
708 tb_tunnel_free(tunnel);
717 struct tb_tunnel *tunnel;
720 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) {
721 if (tb_tunnel_is_invalid(tunnel))
722 tb_deactivate_and_free_tunnel(tunnel);
821 * Keep the DP tunnel under the topology starting from
843 struct tb_tunnel *tunnel;
847 * establish a DP tunnel between them.
882 * both ends of the tunnel.
886 * tunnel is active.
896 /* Make all unused USB3 bandwidth available for the new DP tunnel */
908 tb_dbg(tb, "available bandwidth for new DP tunnel %u/%u Mb/s\n",
911 tunnel = tb_tunnel_alloc_dp(tb, in, out, available_up, available_down);
912 if (!tunnel) {
913 tb_port_dbg(out, "could not allocate DP tunnel\n");
917 if (tb_tunnel_activate(tunnel)) {
918 tb_port_info(out, "DP tunnel activation failed, aborting\n");
922 list_add_tail(&tunnel->list, &tcm->tunnel_list);
927 tb_tunnel_free(tunnel);
942 struct tb_tunnel *tunnel;
954 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, out);
955 tb_deactivate_and_free_tunnel(tunnel);
960 * to create another tunnel.
989 struct tb_tunnel *tunnel, *n;
995 list_for_each_entry_safe_reverse(tunnel, n, &tcm->tunnel_list, list) {
996 if (tb_tunnel_is_dp(tunnel))
997 tb_deactivate_and_free_tunnel(tunnel);
1014 struct tb_tunnel *tunnel;
1030 tunnel = tb_tunnel_alloc_pci(tb, up, down);
1031 if (!tunnel)
1034 if (tb_tunnel_activate(tunnel)) {
1036 "PCIe tunnel activation failed, aborting\n");
1037 tb_tunnel_free(tunnel);
1041 list_add_tail(&tunnel->list, &tcm->tunnel_list);
1049 struct tb_tunnel *tunnel;
1057 tunnel = tb_tunnel_alloc_dma(tb, nhi_port, dst_port, xd->transmit_ring,
1060 if (!tunnel) {
1065 if (tb_tunnel_activate(tunnel)) {
1067 "DMA tunnel activation failed, aborting\n");
1068 tb_tunnel_free(tunnel);
1073 list_add_tail(&tunnel->list, &tcm->tunnel_list);
1081 struct tb_tunnel *tunnel;
1088 * It is possible that the tunnel was already teared down (in
1092 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DMA, NULL, dst_port);
1093 tb_deactivate_and_free_tunnel(tunnel);
1165 /* Maybe we can create another DP tunnel */
1246 struct tb_tunnel *tunnel;
1251 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) {
1257 if (tb_tunnel_is_dma(tunnel))
1258 tb_tunnel_deactivate(tunnel);
1259 tb_tunnel_free(tunnel);
1381 struct tb_tunnel *tunnel, *n;
1392 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list)
1393 tb_tunnel_restart(tunnel);
1488 struct tb_tunnel *tunnel, *n;
1494 list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list)
1495 tb_tunnel_restart(tunnel);