Lines Matching full:sw

384 	struct icm_fr_pkg_get_topology_response *switches, *sw;  in icm_fr_get_route()  local
401 sw = &switches[0]; in icm_fr_get_route()
402 index = icm_fr_get_switch_index(sw->ports[link]); in icm_fr_get_route()
408 sw = &switches[index]; in icm_fr_get_route()
412 if (!(sw->first_data & ICM_SWITCH_USED)) { in icm_fr_get_route()
417 for (j = 0; j < ARRAY_SIZE(sw->ports); j++) { in icm_fr_get_route()
418 index = icm_fr_get_switch_index(sw->ports[j]); in icm_fr_get_route()
419 if (index > sw->switch_index) { in icm_fr_get_route()
420 sw = &switches[index]; in icm_fr_get_route()
426 *route = get_route(sw->route_hi, sw->route_lo); in icm_fr_get_route()
460 static int icm_fr_approve_switch(struct tb *tb, struct tb_switch *sw) in icm_fr_approve_switch() argument
467 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_approve_switch()
469 request.connection_id = sw->connection_id; in icm_fr_approve_switch()
470 request.connection_key = sw->connection_key; in icm_fr_approve_switch()
487 static int icm_fr_add_switch_key(struct tb *tb, struct tb_switch *sw) in icm_fr_add_switch_key() argument
494 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_add_switch_key()
496 request.connection_id = sw->connection_id; in icm_fr_add_switch_key()
497 request.connection_key = sw->connection_key; in icm_fr_add_switch_key()
498 memcpy(request.key, sw->key, TB_SWITCH_KEY_SIZE); in icm_fr_add_switch_key()
514 static int icm_fr_challenge_switch_key(struct tb *tb, struct tb_switch *sw, in icm_fr_challenge_switch_key() argument
522 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_challenge_switch_key()
524 request.connection_id = sw->connection_id; in icm_fr_challenge_switch_key()
525 request.connection_key = sw->connection_key; in icm_fr_challenge_switch_key()
593 struct tb_switch *sw; in alloc_switch() local
595 sw = tb_switch_alloc(tb, &parent_sw->dev, route); in alloc_switch()
596 if (IS_ERR(sw)) { in alloc_switch()
598 return sw; in alloc_switch()
601 sw->uuid = kmemdup(uuid, sizeof(*uuid), GFP_KERNEL); in alloc_switch()
602 if (!sw->uuid) { in alloc_switch()
603 tb_switch_put(sw); in alloc_switch()
607 init_completion(&sw->rpm_complete); in alloc_switch()
608 return sw; in alloc_switch()
611 static int add_switch(struct tb_switch *parent_sw, struct tb_switch *sw) in add_switch() argument
613 u64 route = tb_route(sw); in add_switch()
617 tb_port_at(route, parent_sw)->remote = tb_upstream_port(sw); in add_switch()
618 tb_upstream_port(sw)->remote = tb_port_at(route, parent_sw); in add_switch()
620 ret = tb_switch_add(sw); in add_switch()
622 tb_port_at(tb_route(sw), parent_sw)->remote = NULL; in add_switch()
627 static void update_switch(struct tb_switch *parent_sw, struct tb_switch *sw, in update_switch() argument
632 tb_port_at(tb_route(sw), parent_sw)->remote = NULL; in update_switch()
634 tb_port_at(route, parent_sw)->remote = tb_upstream_port(sw); in update_switch()
637 sw->config.route_hi = upper_32_bits(route); in update_switch()
638 sw->config.route_lo = lower_32_bits(route); in update_switch()
639 sw->connection_id = connection_id; in update_switch()
640 sw->connection_key = connection_key; in update_switch()
641 sw->link = link; in update_switch()
642 sw->depth = depth; in update_switch()
643 sw->boot = boot; in update_switch()
646 sw->is_unplugged = false; in update_switch()
649 complete(&sw->rpm_complete); in update_switch()
652 static void remove_switch(struct tb_switch *sw) in remove_switch() argument
656 parent_sw = tb_to_switch(sw->dev.parent); in remove_switch()
657 tb_port_at(tb_route(sw), parent_sw)->remote = NULL; in remove_switch()
658 tb_switch_remove(sw); in remove_switch()
661 static void add_xdomain(struct tb_switch *sw, u64 route, in add_xdomain() argument
667 pm_runtime_get_sync(&sw->dev); in add_xdomain()
669 xd = tb_xdomain_alloc(sw->tb, &sw->dev, route, local_uuid, remote_uuid); in add_xdomain()
676 tb_port_at(route, sw)->xdomain = xd; in add_xdomain()
681 pm_runtime_mark_last_busy(&sw->dev); in add_xdomain()
682 pm_runtime_put_autosuspend(&sw->dev); in add_xdomain()
694 struct tb_switch *sw; in remove_xdomain() local
696 sw = tb_to_switch(xd->dev.parent); in remove_xdomain()
697 tb_port_at(xd->route, sw)->xdomain = NULL; in remove_xdomain()
707 struct tb_switch *sw, *parent_sw; in icm_fr_device_connected() local
734 sw = tb_switch_find_by_uuid(tb, &pkg->ep_uuid); in icm_fr_device_connected()
735 if (sw) { in icm_fr_device_connected()
738 parent_sw = tb_to_switch(sw->dev.parent); in icm_fr_device_connected()
739 sw_phy_port = tb_phy_port_from_link(sw->link); in icm_fr_device_connected()
750 if (sw->depth == depth && sw_phy_port == phy_port && in icm_fr_device_connected()
751 !!sw->authorized == authorized) { in icm_fr_device_connected()
756 if (sw->link != link) { in icm_fr_device_connected()
761 tb_switch_put(sw); in icm_fr_device_connected()
765 route = tb_route(sw); in icm_fr_device_connected()
768 update_switch(parent_sw, sw, route, pkg->connection_id, in icm_fr_device_connected()
770 tb_switch_put(sw); in icm_fr_device_connected()
779 remove_switch(sw); in icm_fr_device_connected()
780 tb_switch_put(sw); in icm_fr_device_connected()
789 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_device_connected()
790 if (!sw) { in icm_fr_device_connected()
795 sw = tb_switch_find_by_link_depth(tb, dual_link, depth); in icm_fr_device_connected()
797 if (sw) { in icm_fr_device_connected()
798 remove_switch(sw); in icm_fr_device_connected()
799 tb_switch_put(sw); in icm_fr_device_connected()
826 sw = alloc_switch(parent_sw, route, &pkg->ep_uuid); in icm_fr_device_connected()
827 if (!IS_ERR(sw)) { in icm_fr_device_connected()
828 sw->connection_id = pkg->connection_id; in icm_fr_device_connected()
829 sw->connection_key = pkg->connection_key; in icm_fr_device_connected()
830 sw->link = link; in icm_fr_device_connected()
831 sw->depth = depth; in icm_fr_device_connected()
832 sw->authorized = authorized; in icm_fr_device_connected()
833 sw->security_level = security_level; in icm_fr_device_connected()
834 sw->boot = boot; in icm_fr_device_connected()
835 sw->link_speed = speed_gen3 ? 20 : 10; in icm_fr_device_connected()
836 sw->link_width = dual_lane ? 2 : 1; in icm_fr_device_connected()
837 sw->rpm = intel_vss_is_rtd3(pkg->ep_name, sizeof(pkg->ep_name)); in icm_fr_device_connected()
839 if (add_switch(parent_sw, sw)) in icm_fr_device_connected()
840 tb_switch_put(sw); in icm_fr_device_connected()
854 struct tb_switch *sw; in icm_fr_device_disconnected() local
866 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_device_disconnected()
867 if (!sw) { in icm_fr_device_disconnected()
873 remove_switch(sw); in icm_fr_device_disconnected()
874 tb_switch_put(sw); in icm_fr_device_disconnected()
883 struct tb_switch *sw; in icm_fr_xdomain_connected() local
945 sw = tb_switch_find_by_route(tb, route); in icm_fr_xdomain_connected()
946 if (sw) { in icm_fr_xdomain_connected()
947 remove_switch(sw); in icm_fr_xdomain_connected()
948 tb_switch_put(sw); in icm_fr_xdomain_connected()
951 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_xdomain_connected()
952 if (!sw) { in icm_fr_xdomain_connected()
958 add_xdomain(sw, route, &pkg->local_uuid, &pkg->remote_uuid, link, in icm_fr_xdomain_connected()
960 tb_switch_put(sw); in icm_fr_xdomain_connected()
1014 static int icm_tr_approve_switch(struct tb *tb, struct tb_switch *sw) in icm_tr_approve_switch() argument
1021 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_approve_switch()
1023 request.route_lo = sw->config.route_lo; in icm_tr_approve_switch()
1024 request.route_hi = sw->config.route_hi; in icm_tr_approve_switch()
1025 request.connection_id = sw->connection_id; in icm_tr_approve_switch()
1041 static int icm_tr_add_switch_key(struct tb *tb, struct tb_switch *sw) in icm_tr_add_switch_key() argument
1048 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_add_switch_key()
1050 request.route_lo = sw->config.route_lo; in icm_tr_add_switch_key()
1051 request.route_hi = sw->config.route_hi; in icm_tr_add_switch_key()
1052 request.connection_id = sw->connection_id; in icm_tr_add_switch_key()
1053 memcpy(request.key, sw->key, TB_SWITCH_KEY_SIZE); in icm_tr_add_switch_key()
1069 static int icm_tr_challenge_switch_key(struct tb *tb, struct tb_switch *sw, in icm_tr_challenge_switch_key() argument
1077 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_challenge_switch_key()
1079 request.route_lo = sw->config.route_lo; in icm_tr_challenge_switch_key()
1080 request.route_hi = sw->config.route_hi; in icm_tr_challenge_switch_key()
1081 request.connection_id = sw->connection_id; in icm_tr_challenge_switch_key()
1174 struct tb_switch *sw, *parent_sw; in __icm_tr_device_connected() local
1202 sw = tb_switch_find_by_uuid(tb, &pkg->ep_uuid); in __icm_tr_device_connected()
1203 if (sw) { in __icm_tr_device_connected()
1205 if (tb_route(sw) == route && !!sw->authorized == authorized) { in __icm_tr_device_connected()
1206 parent_sw = tb_to_switch(sw->dev.parent); in __icm_tr_device_connected()
1207 update_switch(parent_sw, sw, route, pkg->connection_id, in __icm_tr_device_connected()
1209 tb_switch_put(sw); in __icm_tr_device_connected()
1213 remove_switch(sw); in __icm_tr_device_connected()
1214 tb_switch_put(sw); in __icm_tr_device_connected()
1218 sw = tb_switch_find_by_route(tb, route); in __icm_tr_device_connected()
1219 if (sw) { in __icm_tr_device_connected()
1220 remove_switch(sw); in __icm_tr_device_connected()
1221 tb_switch_put(sw); in __icm_tr_device_connected()
1239 sw = alloc_switch(parent_sw, route, &pkg->ep_uuid); in __icm_tr_device_connected()
1240 if (!IS_ERR(sw)) { in __icm_tr_device_connected()
1241 sw->connection_id = pkg->connection_id; in __icm_tr_device_connected()
1242 sw->authorized = authorized; in __icm_tr_device_connected()
1243 sw->security_level = security_level; in __icm_tr_device_connected()
1244 sw->boot = boot; in __icm_tr_device_connected()
1245 sw->link_speed = speed_gen3 ? 20 : 10; in __icm_tr_device_connected()
1246 sw->link_width = dual_lane ? 2 : 1; in __icm_tr_device_connected()
1247 sw->rpm = force_rtd3; in __icm_tr_device_connected()
1248 if (!sw->rpm) in __icm_tr_device_connected()
1249 sw->rpm = intel_vss_is_rtd3(pkg->ep_name, in __icm_tr_device_connected()
1252 if (add_switch(parent_sw, sw)) in __icm_tr_device_connected()
1253 tb_switch_put(sw); in __icm_tr_device_connected()
1273 struct tb_switch *sw; in icm_tr_device_disconnected() local
1278 sw = tb_switch_find_by_route(tb, route); in icm_tr_device_disconnected()
1279 if (!sw) { in icm_tr_device_disconnected()
1284 remove_switch(sw); in icm_tr_device_disconnected()
1285 tb_switch_put(sw); in icm_tr_device_disconnected()
1294 struct tb_switch *sw; in icm_tr_xdomain_connected() local
1326 sw = tb_switch_find_by_route(tb, route); in icm_tr_xdomain_connected()
1327 if (sw) { in icm_tr_xdomain_connected()
1328 remove_switch(sw); in icm_tr_xdomain_connected()
1329 tb_switch_put(sw); in icm_tr_xdomain_connected()
1332 sw = tb_switch_find_by_route(tb, get_parent_route(route)); in icm_tr_xdomain_connected()
1333 if (!sw) { in icm_tr_xdomain_connected()
1338 add_xdomain(sw, route, &pkg->local_uuid, &pkg->remote_uuid, 0, 0); in icm_tr_xdomain_connected()
1339 tb_switch_put(sw); in icm_tr_xdomain_connected()
1953 static void icm_unplug_children(struct tb_switch *sw) in icm_unplug_children() argument
1957 if (tb_route(sw)) in icm_unplug_children()
1958 sw->is_unplugged = true; in icm_unplug_children()
1960 tb_switch_for_each_port(sw, port) { in icm_unplug_children()
1964 icm_unplug_children(port->remote->sw); in icm_unplug_children()
1970 struct tb_switch *sw = tb_to_switch(dev); in complete_rpm() local
1972 if (sw) in complete_rpm()
1973 complete(&sw->rpm_complete); in complete_rpm()
1977 static void remove_unplugged_switch(struct tb_switch *sw) in remove_unplugged_switch() argument
1979 struct device *parent = get_device(sw->dev.parent); in remove_unplugged_switch()
1988 complete_rpm(&sw->dev, NULL); in remove_unplugged_switch()
1989 bus_for_each_dev(&tb_bus_type, &sw->dev, NULL, complete_rpm); in remove_unplugged_switch()
1990 tb_switch_remove(sw); in remove_unplugged_switch()
1998 static void icm_free_unplugged_children(struct tb_switch *sw) in icm_free_unplugged_children() argument
2002 tb_switch_for_each_port(sw, port) { in icm_free_unplugged_children()
2007 if (port->remote->sw->is_unplugged) { in icm_free_unplugged_children()
2008 remove_unplugged_switch(port->remote->sw); in icm_free_unplugged_children()
2011 icm_free_unplugged_children(port->remote->sw); in icm_free_unplugged_children()
2064 static int icm_runtime_suspend_switch(struct tb_switch *sw) in icm_runtime_suspend_switch() argument
2066 if (tb_route(sw)) in icm_runtime_suspend_switch()
2067 reinit_completion(&sw->rpm_complete); in icm_runtime_suspend_switch()
2071 static int icm_runtime_resume_switch(struct tb_switch *sw) in icm_runtime_resume_switch() argument
2073 if (tb_route(sw)) { in icm_runtime_resume_switch()
2074 if (!wait_for_completion_timeout(&sw->rpm_complete, in icm_runtime_resume_switch()
2076 dev_dbg(&sw->dev, "runtime resuming timed out\n"); in icm_runtime_resume_switch()