Lines Matching refs:sw
24 static void tb_scan_switch(struct tb_switch *sw) in tb_scan_switch() argument
27 for (i = 1; i <= sw->config.max_port_number; i++) in tb_scan_switch()
28 tb_scan_port(&sw->ports[i]); in tb_scan_switch()
36 struct tb_switch *sw; in tb_scan_port() local
52 sw = tb_switch_alloc(port->sw->tb, tb_downstream_route(port)); in tb_scan_port()
53 if (!sw) in tb_scan_port()
55 port->remote = tb_upstream_port(sw); in tb_scan_port()
56 tb_upstream_port(sw)->remote = port; in tb_scan_port()
57 tb_scan_switch(sw); in tb_scan_port()
79 static void tb_free_unplugged_children(struct tb_switch *sw) in tb_free_unplugged_children() argument
82 for (i = 1; i <= sw->config.max_port_number; i++) { in tb_free_unplugged_children()
83 struct tb_port *port = &sw->ports[i]; in tb_free_unplugged_children()
88 if (port->remote->sw->is_unplugged) { in tb_free_unplugged_children()
89 tb_switch_free(port->remote->sw); in tb_free_unplugged_children()
92 tb_free_unplugged_children(port->remote->sw); in tb_free_unplugged_children()
101 static struct tb_port *tb_find_pci_up_port(struct tb_switch *sw) in tb_find_pci_up_port() argument
104 for (i = 1; i <= sw->config.max_port_number; i++) in tb_find_pci_up_port()
105 if (sw->ports[i].config.type == TB_TYPE_PCIE_UP) in tb_find_pci_up_port()
106 return &sw->ports[i]; in tb_find_pci_up_port()
113 static struct tb_port *tb_find_unused_down_port(struct tb_switch *sw) in tb_find_unused_down_port() argument
119 for (i = 1; i <= sw->config.max_port_number; i++) { in tb_find_unused_down_port()
120 if (tb_is_upstream_port(&sw->ports[i])) in tb_find_unused_down_port()
122 if (sw->ports[i].config.type != TB_TYPE_PCIE_DOWN) in tb_find_unused_down_port()
124 cap = tb_find_cap(&sw->ports[i], TB_CFG_PORT, TB_CAP_PCIE); in tb_find_unused_down_port()
127 res = tb_port_read(&sw->ports[i], &data, TB_CFG_PORT, cap, 1); in tb_find_unused_down_port()
132 return &sw->ports[i]; in tb_find_unused_down_port()
148 struct tb_switch *sw; in tb_activate_pcie_devices() local
160 sw = tb->root_switch->ports[i].remote->sw; in tb_activate_pcie_devices()
161 up_port = tb_find_pci_up_port(sw); in tb_activate_pcie_devices()
163 tb_sw_info(sw, "no PCIe devices found, aborting\n"); in tb_activate_pcie_devices()
220 struct tb_switch *sw; in tb_handle_hotplug() local
226 sw = get_switch_at_route(tb->root_switch, ev->route); in tb_handle_hotplug()
227 if (!sw) { in tb_handle_hotplug()
233 if (ev->port > sw->config.max_port_number) { in tb_handle_hotplug()
239 port = &sw->ports[ev->port]; in tb_handle_hotplug()
249 tb_sw_set_unpplugged(port->remote->sw); in tb_handle_hotplug()
251 tb_switch_free(port->remote->sw); in tb_handle_hotplug()
265 } else if (port->remote->sw->config.depth > 1) { in tb_handle_hotplug()
266 tb_sw_warn(port->remote->sw, in tb_handle_hotplug()
269 tb_sw_info(port->remote->sw, in tb_handle_hotplug()