Lines Matching refs:tb
66 sw = tb_switch_alloc(port->sw->tb, &port->sw->dev, in tb_scan_port()
91 static void tb_free_invalid_tunnels(struct tb *tb) in tb_free_invalid_tunnels() argument
93 struct tb_cm *tcm = tb_priv(tb); in tb_free_invalid_tunnels()
173 static void tb_activate_pcie_devices(struct tb *tb) in tb_activate_pcie_devices() argument
182 struct tb_cm *tcm = tb_priv(tb); in tb_activate_pcie_devices()
185 for (i = 1; i <= tb->root_switch->config.max_port_number; i++) { in tb_activate_pcie_devices()
186 if (tb_is_upstream_port(&tb->root_switch->ports[i])) in tb_activate_pcie_devices()
188 if (tb->root_switch->ports[i].config.type != TB_TYPE_PORT) in tb_activate_pcie_devices()
190 if (!tb->root_switch->ports[i].remote) in tb_activate_pcie_devices()
192 sw = tb->root_switch->ports[i].remote->sw; in tb_activate_pcie_devices()
211 down_port = tb_find_unused_down_port(tb->root_switch); in tb_activate_pcie_devices()
217 tunnel = tb_pci_alloc(tb, up_port, down_port); in tb_activate_pcie_devices()
239 struct tb *tb; member
253 struct tb *tb = ev->tb; in tb_handle_hotplug() local
254 struct tb_cm *tcm = tb_priv(tb); in tb_handle_hotplug()
257 mutex_lock(&tb->lock); in tb_handle_hotplug()
261 sw = get_switch_at_route(tb->root_switch, ev->route); in tb_handle_hotplug()
263 tb_warn(tb, in tb_handle_hotplug()
269 tb_warn(tb, in tb_handle_hotplug()
276 tb_warn(tb, in tb_handle_hotplug()
285 tb_free_invalid_tunnels(tb); in tb_handle_hotplug()
306 tb_activate_pcie_devices(tb); in tb_handle_hotplug()
310 mutex_unlock(&tb->lock); in tb_handle_hotplug()
319 static void tb_handle_event(struct tb *tb, enum tb_cfg_pkg_type type, in tb_handle_event() argument
327 tb_warn(tb, "unexpected event %#x, ignoring\n", type); in tb_handle_event()
333 if (tb_cfg_error(tb->ctl, route, pkg->port, in tb_handle_event()
335 tb_warn(tb, "could not ack plug event on %llx:%x\n", route, in tb_handle_event()
343 ev->tb = tb; in tb_handle_event()
347 queue_work(tb->wq, &ev->work); in tb_handle_event()
350 static void tb_stop(struct tb *tb) in tb_stop() argument
352 struct tb_cm *tcm = tb_priv(tb); in tb_stop()
361 tb_switch_remove(tb->root_switch); in tb_stop()
365 static int tb_start(struct tb *tb) in tb_start() argument
367 struct tb_cm *tcm = tb_priv(tb); in tb_start()
370 tb->root_switch = tb_switch_alloc(tb, &tb->dev, 0); in tb_start()
371 if (!tb->root_switch) in tb_start()
379 tb->root_switch->no_nvm_upgrade = true; in tb_start()
381 ret = tb_switch_configure(tb->root_switch); in tb_start()
383 tb_switch_put(tb->root_switch); in tb_start()
388 ret = tb_switch_add(tb->root_switch); in tb_start()
390 tb_switch_put(tb->root_switch); in tb_start()
395 tb_scan_switch(tb->root_switch); in tb_start()
396 tb_activate_pcie_devices(tb); in tb_start()
403 static int tb_suspend_noirq(struct tb *tb) in tb_suspend_noirq() argument
405 struct tb_cm *tcm = tb_priv(tb); in tb_suspend_noirq()
407 tb_info(tb, "suspending...\n"); in tb_suspend_noirq()
408 tb_switch_suspend(tb->root_switch); in tb_suspend_noirq()
410 tb_info(tb, "suspend finished\n"); in tb_suspend_noirq()
415 static int tb_resume_noirq(struct tb *tb) in tb_resume_noirq() argument
417 struct tb_cm *tcm = tb_priv(tb); in tb_resume_noirq()
420 tb_info(tb, "resuming...\n"); in tb_resume_noirq()
423 tb_switch_reset(tb, 0); in tb_resume_noirq()
425 tb_switch_resume(tb->root_switch); in tb_resume_noirq()
426 tb_free_invalid_tunnels(tb); in tb_resume_noirq()
427 tb_free_unplugged_children(tb->root_switch); in tb_resume_noirq()
435 tb_info(tb, "tunnels restarted, sleeping for 100ms\n"); in tb_resume_noirq()
440 tb_info(tb, "resume finished\n"); in tb_resume_noirq()
453 struct tb *tb_probe(struct tb_nhi *nhi) in tb_probe()
456 struct tb *tb; in tb_probe() local
461 tb = tb_domain_alloc(nhi, sizeof(*tcm)); in tb_probe()
462 if (!tb) in tb_probe()
465 tb->security_level = TB_SECURITY_NONE; in tb_probe()
466 tb->cm_ops = &tb_cm_ops; in tb_probe()
468 tcm = tb_priv(tb); in tb_probe()
471 return tb; in tb_probe()