Lines Matching refs:sw

59 static void tb_discover_tunnels(struct tb_switch *sw)  in tb_discover_tunnels()  argument
61 struct tb *tb = sw->tb; in tb_discover_tunnels()
66 for (i = 1; i <= sw->config.max_port_number; i++) { in tb_discover_tunnels()
69 port = &sw->ports[i]; in tb_discover_tunnels()
87 struct tb_switch *parent = tunnel->dst_port->sw; in tb_discover_tunnels()
89 while (parent != tunnel->src_port->sw) { in tb_discover_tunnels()
98 for (i = 1; i <= sw->config.max_port_number; i++) { in tb_discover_tunnels()
99 if (tb_port_has_remote(&sw->ports[i])) in tb_discover_tunnels()
100 tb_discover_tunnels(sw->ports[i].remote->sw); in tb_discover_tunnels()
106 struct tb_switch *sw = port->sw; in tb_scan_xdomain() local
107 struct tb *tb = sw->tb; in tb_scan_xdomain()
118 xd = tb_xdomain_alloc(tb, &sw->dev, route, tb->root_switch->uuid, in tb_scan_xdomain()
121 tb_port_at(route, sw)->xdomain = xd; in tb_scan_xdomain()
131 static void tb_scan_switch(struct tb_switch *sw) in tb_scan_switch() argument
134 for (i = 1; i <= sw->config.max_port_number; i++) in tb_scan_switch()
135 tb_scan_port(&sw->ports[i]); in tb_scan_switch()
143 struct tb_cm *tcm = tb_priv(port->sw->tb); in tb_scan_port()
145 struct tb_switch *sw; in tb_scan_port() local
153 tb_queue_hotplug(port->sw->tb, tb_route(port->sw), port->port, in tb_scan_port()
171 sw = tb_switch_alloc(port->sw->tb, &port->sw->dev, in tb_scan_port()
173 if (IS_ERR(sw)) { in tb_scan_port()
179 if (PTR_ERR(sw) == -EIO || PTR_ERR(sw) == -EADDRNOTAVAIL) in tb_scan_port()
184 if (tb_switch_configure(sw)) { in tb_scan_port()
185 tb_switch_put(sw); in tb_scan_port()
204 dev_set_uevent_suppress(&sw->dev, true); in tb_scan_port()
206 if (tb_switch_add(sw)) { in tb_scan_port()
207 tb_switch_put(sw); in tb_scan_port()
212 upstream_port = tb_upstream_port(sw); in tb_scan_port()
220 tb_scan_switch(sw); in tb_scan_port()
264 static void tb_free_unplugged_children(struct tb_switch *sw) in tb_free_unplugged_children() argument
267 for (i = 1; i <= sw->config.max_port_number; i++) { in tb_free_unplugged_children()
268 struct tb_port *port = &sw->ports[i]; in tb_free_unplugged_children()
273 if (port->remote->sw->is_unplugged) { in tb_free_unplugged_children()
274 tb_switch_remove(port->remote->sw); in tb_free_unplugged_children()
279 tb_free_unplugged_children(port->remote->sw); in tb_free_unplugged_children()
289 static struct tb_port *tb_find_port(struct tb_switch *sw, in tb_find_port() argument
293 for (i = 1; i <= sw->config.max_port_number; i++) in tb_find_port()
294 if (sw->ports[i].config.type == type) in tb_find_port()
295 return &sw->ports[i]; in tb_find_port()
304 static struct tb_port *tb_find_unused_port(struct tb_switch *sw, in tb_find_unused_port() argument
309 for (i = 1; i <= sw->config.max_port_number; i++) { in tb_find_unused_port()
310 if (tb_is_upstream_port(&sw->ports[i])) in tb_find_unused_port()
312 if (sw->ports[i].config.type != type) in tb_find_unused_port()
314 if (!sw->ports[i].cap_adap) in tb_find_unused_port()
316 if (tb_port_is_enabled(&sw->ports[i])) in tb_find_unused_port()
318 return &sw->ports[i]; in tb_find_unused_port()
323 static struct tb_port *tb_find_pcie_down(struct tb_switch *sw, in tb_find_pcie_down() argument
331 if (!tb_route(sw)) { in tb_find_pcie_down()
339 if (tb_switch_is_cr(sw)) in tb_find_pcie_down()
341 else if (tb_switch_is_fr(sw)) in tb_find_pcie_down()
347 if (WARN_ON(index > sw->config.max_port_number)) in tb_find_pcie_down()
349 if (WARN_ON(!tb_port_is_pcie_down(&sw->ports[index]))) in tb_find_pcie_down()
351 if (WARN_ON(tb_pci_port_is_enabled(&sw->ports[index]))) in tb_find_pcie_down()
354 return &sw->ports[index]; in tb_find_pcie_down()
358 return tb_find_unused_port(sw, TB_TYPE_PCIE_DOWN); in tb_find_pcie_down()
364 struct tb_switch *sw = out->sw; in tb_tunnel_dp() local
372 sw = tb_to_switch(sw->dev.parent); in tb_tunnel_dp()
373 if (!sw) in tb_tunnel_dp()
375 in = tb_find_unused_port(sw, TB_TYPE_DP_HDMI_IN); in tb_tunnel_dp()
399 static int tb_tunnel_pci(struct tb *tb, struct tb_switch *sw) in tb_tunnel_pci() argument
406 up = tb_find_port(sw, TB_TYPE_PCIE_UP); in tb_tunnel_pci()
414 parent_sw = tb_to_switch(sw->dev.parent); in tb_tunnel_pci()
415 port = tb_port_at(tb_route(sw), parent_sw); in tb_tunnel_pci()
440 struct tb_switch *sw; in tb_approve_xdomain_paths() local
442 sw = tb_to_switch(xd->dev.parent); in tb_approve_xdomain_paths()
443 dst_port = tb_port_at(xd->route, sw); in tb_approve_xdomain_paths()
471 struct tb_switch *sw; in __tb_disconnect_xdomain_paths() local
473 sw = tb_to_switch(xd->dev.parent); in __tb_disconnect_xdomain_paths()
474 dst_port = tb_port_at(xd->route, sw); in __tb_disconnect_xdomain_paths()
506 struct tb_switch *sw; in tb_handle_hotplug() local
512 sw = tb_switch_find_by_route(tb, ev->route); in tb_handle_hotplug()
513 if (!sw) { in tb_handle_hotplug()
519 if (ev->port > sw->config.max_port_number) { in tb_handle_hotplug()
525 port = &sw->ports[ev->port]; in tb_handle_hotplug()
534 tb_sw_set_unplugged(port->remote->sw); in tb_handle_hotplug()
536 tb_switch_remove(port->remote->sw); in tb_handle_hotplug()
576 tb_switch_put(sw); in tb_handle_hotplug()
633 struct tb_switch *sw = tb_to_switch(dev); in tb_scan_finalize_switch() local
640 if (sw->boot) in tb_scan_finalize_switch()
641 sw->authorized = 1; in tb_scan_finalize_switch()
735 static int tb_free_unplugged_xdomains(struct tb_switch *sw) in tb_free_unplugged_xdomains() argument
739 for (i = 1; i <= sw->config.max_port_number; i++) { in tb_free_unplugged_xdomains()
740 struct tb_port *port = &sw->ports[i]; in tb_free_unplugged_xdomains()
749 ret += tb_free_unplugged_xdomains(port->remote->sw); in tb_free_unplugged_xdomains()