Lines Matching full:sw
400 struct icm_fr_pkg_get_topology_response *switches, *sw; in icm_fr_get_route() local
417 sw = &switches[0]; in icm_fr_get_route()
418 index = icm_fr_get_switch_index(sw->ports[link]); in icm_fr_get_route()
424 sw = &switches[index]; in icm_fr_get_route()
428 if (!(sw->first_data & ICM_SWITCH_USED)) { in icm_fr_get_route()
433 for (j = 0; j < ARRAY_SIZE(sw->ports); j++) { in icm_fr_get_route()
434 index = icm_fr_get_switch_index(sw->ports[j]); in icm_fr_get_route()
435 if (index > sw->switch_index) { in icm_fr_get_route()
436 sw = &switches[index]; in icm_fr_get_route()
442 *route = get_route(sw->route_hi, sw->route_lo); in icm_fr_get_route()
476 static int icm_fr_approve_switch(struct tb *tb, struct tb_switch *sw) in icm_fr_approve_switch() argument
483 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_approve_switch()
485 request.connection_id = sw->connection_id; in icm_fr_approve_switch()
486 request.connection_key = sw->connection_key; in icm_fr_approve_switch()
503 static int icm_fr_add_switch_key(struct tb *tb, struct tb_switch *sw) in icm_fr_add_switch_key() argument
510 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_add_switch_key()
512 request.connection_id = sw->connection_id; in icm_fr_add_switch_key()
513 request.connection_key = sw->connection_key; in icm_fr_add_switch_key()
514 memcpy(request.key, sw->key, TB_SWITCH_KEY_SIZE); in icm_fr_add_switch_key()
530 static int icm_fr_challenge_switch_key(struct tb *tb, struct tb_switch *sw, in icm_fr_challenge_switch_key() argument
538 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_challenge_switch_key()
540 request.connection_id = sw->connection_id; in icm_fr_challenge_switch_key()
541 request.connection_key = sw->connection_key; in icm_fr_challenge_switch_key()
613 struct tb_switch *sw; in alloc_switch() local
615 sw = tb_switch_alloc(tb, &parent_sw->dev, route); in alloc_switch()
616 if (IS_ERR(sw)) { in alloc_switch()
618 return sw; in alloc_switch()
621 sw->uuid = kmemdup(uuid, sizeof(*uuid), GFP_KERNEL); in alloc_switch()
622 if (!sw->uuid) { in alloc_switch()
623 tb_switch_put(sw); in alloc_switch()
627 init_completion(&sw->rpm_complete); in alloc_switch()
628 return sw; in alloc_switch()
631 static int add_switch(struct tb_switch *parent_sw, struct tb_switch *sw) in add_switch() argument
633 u64 route = tb_route(sw); in add_switch()
637 tb_port_at(route, parent_sw)->remote = tb_upstream_port(sw); in add_switch()
638 tb_upstream_port(sw)->remote = tb_port_at(route, parent_sw); in add_switch()
640 ret = tb_switch_add(sw); in add_switch()
642 tb_port_at(tb_route(sw), parent_sw)->remote = NULL; in add_switch()
647 static void update_switch(struct tb_switch *parent_sw, struct tb_switch *sw, in update_switch() argument
652 tb_port_at(tb_route(sw), parent_sw)->remote = NULL; in update_switch()
654 tb_port_at(route, parent_sw)->remote = tb_upstream_port(sw); in update_switch()
657 sw->config.route_hi = upper_32_bits(route); in update_switch()
658 sw->config.route_lo = lower_32_bits(route); in update_switch()
659 sw->connection_id = connection_id; in update_switch()
660 sw->connection_key = connection_key; in update_switch()
661 sw->link = link; in update_switch()
662 sw->depth = depth; in update_switch()
663 sw->boot = boot; in update_switch()
666 sw->is_unplugged = false; in update_switch()
669 complete(&sw->rpm_complete); in update_switch()
672 static void remove_switch(struct tb_switch *sw) in remove_switch() argument
676 parent_sw = tb_to_switch(sw->dev.parent); in remove_switch()
677 tb_port_at(tb_route(sw), parent_sw)->remote = NULL; in remove_switch()
678 tb_switch_remove(sw); in remove_switch()
681 static void add_xdomain(struct tb_switch *sw, u64 route, in add_xdomain() argument
687 pm_runtime_get_sync(&sw->dev); in add_xdomain()
689 xd = tb_xdomain_alloc(sw->tb, &sw->dev, route, local_uuid, remote_uuid); in add_xdomain()
696 tb_port_at(route, sw)->xdomain = xd; in add_xdomain()
701 pm_runtime_mark_last_busy(&sw->dev); in add_xdomain()
702 pm_runtime_put_autosuspend(&sw->dev); in add_xdomain()
714 struct tb_switch *sw; in remove_xdomain() local
716 sw = tb_to_switch(xd->dev.parent); in remove_xdomain()
717 tb_port_at(xd->route, sw)->xdomain = NULL; in remove_xdomain()
727 struct tb_switch *sw, *parent_sw; in icm_fr_device_connected() local
754 sw = tb_switch_find_by_uuid(tb, &pkg->ep_uuid); in icm_fr_device_connected()
755 if (sw) { in icm_fr_device_connected()
758 parent_sw = tb_to_switch(sw->dev.parent); in icm_fr_device_connected()
759 sw_phy_port = tb_phy_port_from_link(sw->link); in icm_fr_device_connected()
770 if (sw->depth == depth && sw_phy_port == phy_port && in icm_fr_device_connected()
771 !!sw->authorized == authorized) { in icm_fr_device_connected()
776 if (sw->link != link) { in icm_fr_device_connected()
781 tb_switch_put(sw); in icm_fr_device_connected()
785 route = tb_route(sw); in icm_fr_device_connected()
788 update_switch(parent_sw, sw, route, pkg->connection_id, in icm_fr_device_connected()
790 tb_switch_put(sw); in icm_fr_device_connected()
799 remove_switch(sw); in icm_fr_device_connected()
800 tb_switch_put(sw); in icm_fr_device_connected()
809 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_device_connected()
810 if (!sw) { in icm_fr_device_connected()
815 sw = tb_switch_find_by_link_depth(tb, dual_link, depth); in icm_fr_device_connected()
817 if (sw) { in icm_fr_device_connected()
818 remove_switch(sw); in icm_fr_device_connected()
819 tb_switch_put(sw); in icm_fr_device_connected()
846 sw = alloc_switch(parent_sw, route, &pkg->ep_uuid); in icm_fr_device_connected()
847 if (!IS_ERR(sw)) { in icm_fr_device_connected()
848 sw->connection_id = pkg->connection_id; in icm_fr_device_connected()
849 sw->connection_key = pkg->connection_key; in icm_fr_device_connected()
850 sw->link = link; in icm_fr_device_connected()
851 sw->depth = depth; in icm_fr_device_connected()
852 sw->authorized = authorized; in icm_fr_device_connected()
853 sw->security_level = security_level; in icm_fr_device_connected()
854 sw->boot = boot; in icm_fr_device_connected()
855 sw->link_speed = speed_gen3 ? 20 : 10; in icm_fr_device_connected()
856 sw->link_width = dual_lane ? 2 : 1; in icm_fr_device_connected()
857 sw->rpm = intel_vss_is_rtd3(pkg->ep_name, sizeof(pkg->ep_name)); in icm_fr_device_connected()
859 if (add_switch(parent_sw, sw)) in icm_fr_device_connected()
860 tb_switch_put(sw); in icm_fr_device_connected()
874 struct tb_switch *sw; in icm_fr_device_disconnected() local
886 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_device_disconnected()
887 if (!sw) { in icm_fr_device_disconnected()
893 pm_runtime_get_sync(sw->dev.parent); in icm_fr_device_disconnected()
895 remove_switch(sw); in icm_fr_device_disconnected()
897 pm_runtime_mark_last_busy(sw->dev.parent); in icm_fr_device_disconnected()
898 pm_runtime_put_autosuspend(sw->dev.parent); in icm_fr_device_disconnected()
900 tb_switch_put(sw); in icm_fr_device_disconnected()
909 struct tb_switch *sw; in icm_fr_xdomain_connected() local
971 sw = tb_switch_find_by_route(tb, route); in icm_fr_xdomain_connected()
972 if (sw) { in icm_fr_xdomain_connected()
973 remove_switch(sw); in icm_fr_xdomain_connected()
974 tb_switch_put(sw); in icm_fr_xdomain_connected()
977 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_xdomain_connected()
978 if (!sw) { in icm_fr_xdomain_connected()
984 add_xdomain(sw, route, &pkg->local_uuid, &pkg->remote_uuid, link, in icm_fr_xdomain_connected()
986 tb_switch_put(sw); in icm_fr_xdomain_connected()
1043 static int icm_tr_approve_switch(struct tb *tb, struct tb_switch *sw) in icm_tr_approve_switch() argument
1050 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_approve_switch()
1052 request.route_lo = sw->config.route_lo; in icm_tr_approve_switch()
1053 request.route_hi = sw->config.route_hi; in icm_tr_approve_switch()
1054 request.connection_id = sw->connection_id; in icm_tr_approve_switch()
1070 static int icm_tr_add_switch_key(struct tb *tb, struct tb_switch *sw) in icm_tr_add_switch_key() argument
1077 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_add_switch_key()
1079 request.route_lo = sw->config.route_lo; in icm_tr_add_switch_key()
1080 request.route_hi = sw->config.route_hi; in icm_tr_add_switch_key()
1081 request.connection_id = sw->connection_id; in icm_tr_add_switch_key()
1082 memcpy(request.key, sw->key, TB_SWITCH_KEY_SIZE); in icm_tr_add_switch_key()
1098 static int icm_tr_challenge_switch_key(struct tb *tb, struct tb_switch *sw, in icm_tr_challenge_switch_key() argument
1106 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_challenge_switch_key()
1108 request.route_lo = sw->config.route_lo; in icm_tr_challenge_switch_key()
1109 request.route_hi = sw->config.route_hi; in icm_tr_challenge_switch_key()
1110 request.connection_id = sw->connection_id; in icm_tr_challenge_switch_key()
1207 struct tb_switch *sw, *parent_sw; in __icm_tr_device_connected() local
1235 sw = tb_switch_find_by_uuid(tb, &pkg->ep_uuid); in __icm_tr_device_connected()
1236 if (sw) { in __icm_tr_device_connected()
1238 if (tb_route(sw) == route && !!sw->authorized == authorized) { in __icm_tr_device_connected()
1239 parent_sw = tb_to_switch(sw->dev.parent); in __icm_tr_device_connected()
1240 update_switch(parent_sw, sw, route, pkg->connection_id, in __icm_tr_device_connected()
1242 tb_switch_put(sw); in __icm_tr_device_connected()
1246 remove_switch(sw); in __icm_tr_device_connected()
1247 tb_switch_put(sw); in __icm_tr_device_connected()
1251 sw = tb_switch_find_by_route(tb, route); in __icm_tr_device_connected()
1252 if (sw) { in __icm_tr_device_connected()
1253 remove_switch(sw); in __icm_tr_device_connected()
1254 tb_switch_put(sw); in __icm_tr_device_connected()
1272 sw = alloc_switch(parent_sw, route, &pkg->ep_uuid); in __icm_tr_device_connected()
1273 if (!IS_ERR(sw)) { in __icm_tr_device_connected()
1274 sw->connection_id = pkg->connection_id; in __icm_tr_device_connected()
1275 sw->authorized = authorized; in __icm_tr_device_connected()
1276 sw->security_level = security_level; in __icm_tr_device_connected()
1277 sw->boot = boot; in __icm_tr_device_connected()
1278 sw->link_speed = speed_gen3 ? 20 : 10; in __icm_tr_device_connected()
1279 sw->link_width = dual_lane ? 2 : 1; in __icm_tr_device_connected()
1280 sw->rpm = force_rtd3; in __icm_tr_device_connected()
1281 if (!sw->rpm) in __icm_tr_device_connected()
1282 sw->rpm = intel_vss_is_rtd3(pkg->ep_name, in __icm_tr_device_connected()
1285 if (add_switch(parent_sw, sw)) in __icm_tr_device_connected()
1286 tb_switch_put(sw); in __icm_tr_device_connected()
1306 struct tb_switch *sw; in icm_tr_device_disconnected() local
1311 sw = tb_switch_find_by_route(tb, route); in icm_tr_device_disconnected()
1312 if (!sw) { in icm_tr_device_disconnected()
1316 pm_runtime_get_sync(sw->dev.parent); in icm_tr_device_disconnected()
1318 remove_switch(sw); in icm_tr_device_disconnected()
1320 pm_runtime_mark_last_busy(sw->dev.parent); in icm_tr_device_disconnected()
1321 pm_runtime_put_autosuspend(sw->dev.parent); in icm_tr_device_disconnected()
1323 tb_switch_put(sw); in icm_tr_device_disconnected()
1332 struct tb_switch *sw; in icm_tr_xdomain_connected() local
1364 sw = tb_switch_find_by_route(tb, route); in icm_tr_xdomain_connected()
1365 if (sw) { in icm_tr_xdomain_connected()
1366 remove_switch(sw); in icm_tr_xdomain_connected()
1367 tb_switch_put(sw); in icm_tr_xdomain_connected()
1370 sw = tb_switch_find_by_route(tb, get_parent_route(route)); in icm_tr_xdomain_connected()
1371 if (!sw) { in icm_tr_xdomain_connected()
1376 add_xdomain(sw, route, &pkg->local_uuid, &pkg->remote_uuid, 0, 0); in icm_tr_xdomain_connected()
1377 tb_switch_put(sw); in icm_tr_xdomain_connected()
2010 static void icm_unplug_children(struct tb_switch *sw) in icm_unplug_children() argument
2014 if (tb_route(sw)) in icm_unplug_children()
2015 sw->is_unplugged = true; in icm_unplug_children()
2017 tb_switch_for_each_port(sw, port) { in icm_unplug_children()
2021 icm_unplug_children(port->remote->sw); in icm_unplug_children()
2027 struct tb_switch *sw = tb_to_switch(dev); in complete_rpm() local
2029 if (sw) in complete_rpm()
2030 complete(&sw->rpm_complete); in complete_rpm()
2034 static void remove_unplugged_switch(struct tb_switch *sw) in remove_unplugged_switch() argument
2036 struct device *parent = get_device(sw->dev.parent); in remove_unplugged_switch()
2045 complete_rpm(&sw->dev, NULL); in remove_unplugged_switch()
2046 bus_for_each_dev(&tb_bus_type, &sw->dev, NULL, complete_rpm); in remove_unplugged_switch()
2047 tb_switch_remove(sw); in remove_unplugged_switch()
2055 static void icm_free_unplugged_children(struct tb_switch *sw) in icm_free_unplugged_children() argument
2059 tb_switch_for_each_port(sw, port) { in icm_free_unplugged_children()
2064 if (port->remote->sw->is_unplugged) { in icm_free_unplugged_children()
2065 remove_unplugged_switch(port->remote->sw); in icm_free_unplugged_children()
2068 icm_free_unplugged_children(port->remote->sw); in icm_free_unplugged_children()
2121 static int icm_runtime_suspend_switch(struct tb_switch *sw) in icm_runtime_suspend_switch() argument
2123 if (tb_route(sw)) in icm_runtime_suspend_switch()
2124 reinit_completion(&sw->rpm_complete); in icm_runtime_suspend_switch()
2128 static int icm_runtime_resume_switch(struct tb_switch *sw) in icm_runtime_resume_switch() argument
2130 if (tb_route(sw)) { in icm_runtime_resume_switch()
2131 if (!wait_for_completion_timeout(&sw->rpm_complete, in icm_runtime_resume_switch()
2133 dev_dbg(&sw->dev, "runtime resuming timed out\n"); in icm_runtime_resume_switch()
2260 static int icm_usb4_switch_op(struct tb_switch *sw, u16 opcode, u32 *metadata, in icm_usb4_switch_op() argument
2266 struct tb *tb = sw->tb; in icm_usb4_switch_op()
2268 u64 route = tb_route(sw); in icm_usb4_switch_op()
2322 static int icm_usb4_switch_nvm_authenticate_status(struct tb_switch *sw, in icm_usb4_switch_nvm_authenticate_status() argument
2326 struct tb *tb = sw->tb; in icm_usb4_switch_nvm_authenticate_status()
2336 if (auth && auth->reply.route_hi == sw->config.route_hi && in icm_usb4_switch_nvm_authenticate_status()
2337 auth->reply.route_lo == sw->config.route_lo) { in icm_usb4_switch_nvm_authenticate_status()
2339 tb_route(sw), auth->reply.hdr.flags, auth->reply.status); in icm_usb4_switch_nvm_authenticate_status()