Lines Matching full:sw

422 	struct icm_fr_pkg_get_topology_response *switches, *sw;  in icm_fr_get_route()  local
439 sw = &switches[0]; in icm_fr_get_route()
440 index = icm_fr_get_switch_index(sw->ports[link]); in icm_fr_get_route()
446 sw = &switches[index]; in icm_fr_get_route()
450 if (!(sw->first_data & ICM_SWITCH_USED)) { in icm_fr_get_route()
455 for (j = 0; j < ARRAY_SIZE(sw->ports); j++) { in icm_fr_get_route()
456 index = icm_fr_get_switch_index(sw->ports[j]); in icm_fr_get_route()
457 if (index > sw->switch_index) { in icm_fr_get_route()
458 sw = &switches[index]; in icm_fr_get_route()
464 *route = get_route(sw->route_hi, sw->route_lo); in icm_fr_get_route()
498 static int icm_fr_approve_switch(struct tb *tb, struct tb_switch *sw) in icm_fr_approve_switch() argument
505 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_approve_switch()
507 request.connection_id = sw->connection_id; in icm_fr_approve_switch()
508 request.connection_key = sw->connection_key; in icm_fr_approve_switch()
525 static int icm_fr_add_switch_key(struct tb *tb, struct tb_switch *sw) in icm_fr_add_switch_key() argument
532 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_add_switch_key()
534 request.connection_id = sw->connection_id; in icm_fr_add_switch_key()
535 request.connection_key = sw->connection_key; in icm_fr_add_switch_key()
536 memcpy(request.key, sw->key, TB_SWITCH_KEY_SIZE); in icm_fr_add_switch_key()
552 static int icm_fr_challenge_switch_key(struct tb *tb, struct tb_switch *sw, in icm_fr_challenge_switch_key() argument
560 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_challenge_switch_key()
562 request.connection_id = sw->connection_id; in icm_fr_challenge_switch_key()
563 request.connection_key = sw->connection_key; in icm_fr_challenge_switch_key()
638 struct tb_switch *sw; in alloc_switch() local
640 sw = tb_switch_alloc(tb, &parent_sw->dev, route); in alloc_switch()
641 if (IS_ERR(sw)) { in alloc_switch()
643 return sw; in alloc_switch()
646 sw->uuid = kmemdup(uuid, sizeof(*uuid), GFP_KERNEL); in alloc_switch()
647 if (!sw->uuid) { in alloc_switch()
648 tb_switch_put(sw); in alloc_switch()
652 init_completion(&sw->rpm_complete); in alloc_switch()
653 return sw; in alloc_switch()
656 static int add_switch(struct tb_switch *parent_sw, struct tb_switch *sw) in add_switch() argument
658 u64 route = tb_route(sw); in add_switch()
662 tb_port_at(route, parent_sw)->remote = tb_upstream_port(sw); in add_switch()
663 tb_upstream_port(sw)->remote = tb_port_at(route, parent_sw); in add_switch()
665 ret = tb_switch_add(sw); in add_switch()
667 tb_port_at(tb_route(sw), parent_sw)->remote = NULL; in add_switch()
672 static void update_switch(struct tb_switch *sw, u64 route, u8 connection_id, in update_switch() argument
675 struct tb_switch *parent_sw = tb_switch_parent(sw); in update_switch()
678 tb_switch_downstream_port(sw)->remote = NULL; in update_switch()
680 tb_port_at(route, parent_sw)->remote = tb_upstream_port(sw); in update_switch()
683 sw->config.route_hi = upper_32_bits(route); in update_switch()
684 sw->config.route_lo = lower_32_bits(route); in update_switch()
685 sw->connection_id = connection_id; in update_switch()
686 sw->connection_key = connection_key; in update_switch()
687 sw->link = link; in update_switch()
688 sw->depth = depth; in update_switch()
689 sw->boot = boot; in update_switch()
692 sw->is_unplugged = false; in update_switch()
695 complete(&sw->rpm_complete); in update_switch()
698 static void remove_switch(struct tb_switch *sw) in remove_switch() argument
700 tb_switch_downstream_port(sw)->remote = NULL; in remove_switch()
701 tb_switch_remove(sw); in remove_switch()
704 static void add_xdomain(struct tb_switch *sw, u64 route, in add_xdomain() argument
710 pm_runtime_get_sync(&sw->dev); in add_xdomain()
712 xd = tb_xdomain_alloc(sw->tb, &sw->dev, route, local_uuid, remote_uuid); in add_xdomain()
719 tb_port_at(route, sw)->xdomain = xd; in add_xdomain()
724 pm_runtime_mark_last_busy(&sw->dev); in add_xdomain()
725 pm_runtime_put_autosuspend(&sw->dev); in add_xdomain()
737 struct tb_switch *sw; in remove_xdomain() local
739 sw = tb_to_switch(xd->dev.parent); in remove_xdomain()
740 tb_port_at(xd->route, sw)->xdomain = NULL; in remove_xdomain()
750 struct tb_switch *sw, *parent_sw; in icm_fr_device_connected() local
777 sw = tb_switch_find_by_uuid(tb, &pkg->ep_uuid); in icm_fr_device_connected()
778 if (sw) { in icm_fr_device_connected()
781 sw_phy_port = tb_phy_port_from_link(sw->link); in icm_fr_device_connected()
792 if (sw->depth == depth && sw_phy_port == phy_port && in icm_fr_device_connected()
793 !!sw->authorized == authorized) { in icm_fr_device_connected()
798 if (sw->link != link) { in icm_fr_device_connected()
803 tb_switch_put(sw); in icm_fr_device_connected()
807 route = tb_route(sw); in icm_fr_device_connected()
810 update_switch(sw, route, pkg->connection_id, in icm_fr_device_connected()
812 tb_switch_put(sw); in icm_fr_device_connected()
821 remove_switch(sw); in icm_fr_device_connected()
822 tb_switch_put(sw); in icm_fr_device_connected()
831 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_device_connected()
832 if (!sw) { in icm_fr_device_connected()
837 sw = tb_switch_find_by_link_depth(tb, dual_link, depth); in icm_fr_device_connected()
839 if (sw) { in icm_fr_device_connected()
840 remove_switch(sw); in icm_fr_device_connected()
841 tb_switch_put(sw); in icm_fr_device_connected()
868 sw = alloc_switch(parent_sw, route, &pkg->ep_uuid); in icm_fr_device_connected()
869 if (!IS_ERR(sw)) { in icm_fr_device_connected()
870 sw->connection_id = pkg->connection_id; in icm_fr_device_connected()
871 sw->connection_key = pkg->connection_key; in icm_fr_device_connected()
872 sw->link = link; in icm_fr_device_connected()
873 sw->depth = depth; in icm_fr_device_connected()
874 sw->authorized = authorized; in icm_fr_device_connected()
875 sw->security_level = security_level; in icm_fr_device_connected()
876 sw->boot = boot; in icm_fr_device_connected()
877 sw->link_speed = speed_gen3 ? 20 : 10; in icm_fr_device_connected()
878 sw->link_width = dual_lane ? TB_LINK_WIDTH_DUAL : in icm_fr_device_connected()
880 sw->rpm = intel_vss_is_rtd3(pkg->ep_name, sizeof(pkg->ep_name)); in icm_fr_device_connected()
882 if (add_switch(parent_sw, sw)) in icm_fr_device_connected()
883 tb_switch_put(sw); in icm_fr_device_connected()
897 struct tb_switch *sw; in icm_fr_device_disconnected() local
909 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_device_disconnected()
910 if (!sw) { in icm_fr_device_disconnected()
916 pm_runtime_get_sync(sw->dev.parent); in icm_fr_device_disconnected()
918 remove_switch(sw); in icm_fr_device_disconnected()
920 pm_runtime_mark_last_busy(sw->dev.parent); in icm_fr_device_disconnected()
921 pm_runtime_put_autosuspend(sw->dev.parent); in icm_fr_device_disconnected()
923 tb_switch_put(sw); in icm_fr_device_disconnected()
932 struct tb_switch *sw; in icm_fr_xdomain_connected() local
994 sw = tb_switch_find_by_route(tb, route); in icm_fr_xdomain_connected()
995 if (sw) { in icm_fr_xdomain_connected()
996 remove_switch(sw); in icm_fr_xdomain_connected()
997 tb_switch_put(sw); in icm_fr_xdomain_connected()
1000 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_xdomain_connected()
1001 if (!sw) { in icm_fr_xdomain_connected()
1007 add_xdomain(sw, route, &pkg->local_uuid, &pkg->remote_uuid, link, in icm_fr_xdomain_connected()
1009 tb_switch_put(sw); in icm_fr_xdomain_connected()
1066 static int icm_tr_approve_switch(struct tb *tb, struct tb_switch *sw) in icm_tr_approve_switch() argument
1073 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_approve_switch()
1075 request.route_lo = sw->config.route_lo; in icm_tr_approve_switch()
1076 request.route_hi = sw->config.route_hi; in icm_tr_approve_switch()
1077 request.connection_id = sw->connection_id; in icm_tr_approve_switch()
1093 static int icm_tr_add_switch_key(struct tb *tb, struct tb_switch *sw) in icm_tr_add_switch_key() argument
1100 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_add_switch_key()
1102 request.route_lo = sw->config.route_lo; in icm_tr_add_switch_key()
1103 request.route_hi = sw->config.route_hi; in icm_tr_add_switch_key()
1104 request.connection_id = sw->connection_id; in icm_tr_add_switch_key()
1105 memcpy(request.key, sw->key, TB_SWITCH_KEY_SIZE); in icm_tr_add_switch_key()
1121 static int icm_tr_challenge_switch_key(struct tb *tb, struct tb_switch *sw, in icm_tr_challenge_switch_key() argument
1129 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_challenge_switch_key()
1131 request.route_lo = sw->config.route_lo; in icm_tr_challenge_switch_key()
1132 request.route_hi = sw->config.route_hi; in icm_tr_challenge_switch_key()
1133 request.connection_id = sw->connection_id; in icm_tr_challenge_switch_key()
1236 struct tb_switch *sw, *parent_sw; in __icm_tr_device_connected() local
1264 sw = tb_switch_find_by_uuid(tb, &pkg->ep_uuid); in __icm_tr_device_connected()
1265 if (sw) { in __icm_tr_device_connected()
1267 if (tb_route(sw) == route && !!sw->authorized == authorized) { in __icm_tr_device_connected()
1268 update_switch(sw, route, pkg->connection_id, 0, 0, 0, in __icm_tr_device_connected()
1270 tb_switch_put(sw); in __icm_tr_device_connected()
1274 remove_switch(sw); in __icm_tr_device_connected()
1275 tb_switch_put(sw); in __icm_tr_device_connected()
1279 sw = tb_switch_find_by_route(tb, route); in __icm_tr_device_connected()
1280 if (sw) { in __icm_tr_device_connected()
1281 remove_switch(sw); in __icm_tr_device_connected()
1282 tb_switch_put(sw); in __icm_tr_device_connected()
1300 sw = alloc_switch(parent_sw, route, &pkg->ep_uuid); in __icm_tr_device_connected()
1301 if (!IS_ERR(sw)) { in __icm_tr_device_connected()
1302 sw->connection_id = pkg->connection_id; in __icm_tr_device_connected()
1303 sw->authorized = authorized; in __icm_tr_device_connected()
1304 sw->security_level = security_level; in __icm_tr_device_connected()
1305 sw->boot = boot; in __icm_tr_device_connected()
1306 sw->link_speed = speed_gen3 ? 20 : 10; in __icm_tr_device_connected()
1307 sw->link_width = dual_lane ? TB_LINK_WIDTH_DUAL : in __icm_tr_device_connected()
1309 sw->rpm = force_rtd3; in __icm_tr_device_connected()
1310 if (!sw->rpm) in __icm_tr_device_connected()
1311 sw->rpm = intel_vss_is_rtd3(pkg->ep_name, in __icm_tr_device_connected()
1314 if (add_switch(parent_sw, sw)) in __icm_tr_device_connected()
1315 tb_switch_put(sw); in __icm_tr_device_connected()
1335 struct tb_switch *sw; in icm_tr_device_disconnected() local
1340 sw = tb_switch_find_by_route(tb, route); in icm_tr_device_disconnected()
1341 if (!sw) { in icm_tr_device_disconnected()
1345 pm_runtime_get_sync(sw->dev.parent); in icm_tr_device_disconnected()
1347 remove_switch(sw); in icm_tr_device_disconnected()
1349 pm_runtime_mark_last_busy(sw->dev.parent); in icm_tr_device_disconnected()
1350 pm_runtime_put_autosuspend(sw->dev.parent); in icm_tr_device_disconnected()
1352 tb_switch_put(sw); in icm_tr_device_disconnected()
1361 struct tb_switch *sw; in icm_tr_xdomain_connected() local
1393 sw = tb_switch_find_by_route(tb, route); in icm_tr_xdomain_connected()
1394 if (sw) { in icm_tr_xdomain_connected()
1395 remove_switch(sw); in icm_tr_xdomain_connected()
1396 tb_switch_put(sw); in icm_tr_xdomain_connected()
1399 sw = tb_switch_find_by_route(tb, get_parent_route(route)); in icm_tr_xdomain_connected()
1400 if (!sw) { in icm_tr_xdomain_connected()
1405 add_xdomain(sw, route, &pkg->local_uuid, &pkg->remote_uuid, 0, 0); in icm_tr_xdomain_connected()
1406 tb_switch_put(sw); in icm_tr_xdomain_connected()
2042 static void icm_unplug_children(struct tb_switch *sw) in icm_unplug_children() argument
2046 if (tb_route(sw)) in icm_unplug_children()
2047 sw->is_unplugged = true; in icm_unplug_children()
2049 tb_switch_for_each_port(sw, port) { in icm_unplug_children()
2053 icm_unplug_children(port->remote->sw); in icm_unplug_children()
2059 struct tb_switch *sw = tb_to_switch(dev); in complete_rpm() local
2061 if (sw) in complete_rpm()
2062 complete(&sw->rpm_complete); in complete_rpm()
2066 static void remove_unplugged_switch(struct tb_switch *sw) in remove_unplugged_switch() argument
2068 struct device *parent = get_device(sw->dev.parent); in remove_unplugged_switch()
2077 complete_rpm(&sw->dev, NULL); in remove_unplugged_switch()
2078 bus_for_each_dev(&tb_bus_type, &sw->dev, NULL, complete_rpm); in remove_unplugged_switch()
2079 tb_switch_remove(sw); in remove_unplugged_switch()
2087 static void icm_free_unplugged_children(struct tb_switch *sw) in icm_free_unplugged_children() argument
2091 tb_switch_for_each_port(sw, port) { in icm_free_unplugged_children()
2096 if (port->remote->sw->is_unplugged) { in icm_free_unplugged_children()
2097 remove_unplugged_switch(port->remote->sw); in icm_free_unplugged_children()
2100 icm_free_unplugged_children(port->remote->sw); in icm_free_unplugged_children()
2153 static int icm_runtime_suspend_switch(struct tb_switch *sw) in icm_runtime_suspend_switch() argument
2155 if (tb_route(sw)) in icm_runtime_suspend_switch()
2156 reinit_completion(&sw->rpm_complete); in icm_runtime_suspend_switch()
2160 static int icm_runtime_resume_switch(struct tb_switch *sw) in icm_runtime_resume_switch() argument
2162 if (tb_route(sw)) { in icm_runtime_resume_switch()
2163 if (!wait_for_completion_timeout(&sw->rpm_complete, in icm_runtime_resume_switch()
2165 dev_dbg(&sw->dev, "runtime resuming timed out\n"); in icm_runtime_resume_switch()
2292 static int icm_usb4_switch_op(struct tb_switch *sw, u16 opcode, u32 *metadata, in icm_usb4_switch_op() argument
2298 struct tb *tb = sw->tb; in icm_usb4_switch_op()
2300 u64 route = tb_route(sw); in icm_usb4_switch_op()
2354 static int icm_usb4_switch_nvm_authenticate_status(struct tb_switch *sw, in icm_usb4_switch_nvm_authenticate_status() argument
2358 struct tb *tb = sw->tb; in icm_usb4_switch_nvm_authenticate_status()
2368 if (auth && auth->reply.route_hi == sw->config.route_hi && in icm_usb4_switch_nvm_authenticate_status()
2369 auth->reply.route_lo == sw->config.route_lo) { in icm_usb4_switch_nvm_authenticate_status()
2371 tb_route(sw), auth->reply.hdr.flags, auth->reply.status); in icm_usb4_switch_nvm_authenticate_status()