Lines Matching refs:sw

360 	struct icm_fr_pkg_get_topology_response *switches, *sw;  in icm_fr_get_route()  local
377 sw = &switches[0]; in icm_fr_get_route()
378 index = icm_fr_get_switch_index(sw->ports[link]); in icm_fr_get_route()
384 sw = &switches[index]; in icm_fr_get_route()
388 if (!(sw->first_data & ICM_SWITCH_USED)) { in icm_fr_get_route()
393 for (j = 0; j < ARRAY_SIZE(sw->ports); j++) { in icm_fr_get_route()
394 index = icm_fr_get_switch_index(sw->ports[j]); in icm_fr_get_route()
395 if (index > sw->switch_index) { in icm_fr_get_route()
396 sw = &switches[index]; in icm_fr_get_route()
402 *route = get_route(sw->route_hi, sw->route_lo); in icm_fr_get_route()
436 static int icm_fr_approve_switch(struct tb *tb, struct tb_switch *sw) in icm_fr_approve_switch() argument
443 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_approve_switch()
445 request.connection_id = sw->connection_id; in icm_fr_approve_switch()
446 request.connection_key = sw->connection_key; in icm_fr_approve_switch()
463 static int icm_fr_add_switch_key(struct tb *tb, struct tb_switch *sw) in icm_fr_add_switch_key() argument
470 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_add_switch_key()
472 request.connection_id = sw->connection_id; in icm_fr_add_switch_key()
473 request.connection_key = sw->connection_key; in icm_fr_add_switch_key()
474 memcpy(request.key, sw->key, TB_SWITCH_KEY_SIZE); in icm_fr_add_switch_key()
490 static int icm_fr_challenge_switch_key(struct tb *tb, struct tb_switch *sw, in icm_fr_challenge_switch_key() argument
498 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_challenge_switch_key()
500 request.connection_id = sw->connection_id; in icm_fr_challenge_switch_key()
501 request.connection_key = sw->connection_key; in icm_fr_challenge_switch_key()
573 struct tb_switch *sw; in add_switch() local
578 sw = tb_switch_alloc(parent_sw->tb, &parent_sw->dev, route); in add_switch()
579 if (IS_ERR(sw)) in add_switch()
582 sw->uuid = kmemdup(uuid, sizeof(*uuid), GFP_KERNEL); in add_switch()
583 if (!sw->uuid) { in add_switch()
584 tb_sw_warn(sw, "cannot allocate memory for switch\n"); in add_switch()
585 tb_switch_put(sw); in add_switch()
588 sw->connection_id = connection_id; in add_switch()
589 sw->connection_key = connection_key; in add_switch()
590 sw->link = link; in add_switch()
591 sw->depth = depth; in add_switch()
592 sw->authorized = authorized; in add_switch()
593 sw->security_level = security_level; in add_switch()
594 sw->boot = boot; in add_switch()
595 init_completion(&sw->rpm_complete); in add_switch()
599 sw->rpm = !!(vss->flags & INTEL_VSS_FLAGS_RTD3); in add_switch()
602 tb_port_at(route, parent_sw)->remote = tb_upstream_port(sw); in add_switch()
603 tb_upstream_port(sw)->remote = tb_port_at(route, parent_sw); in add_switch()
605 ret = tb_switch_add(sw); in add_switch()
607 tb_port_at(tb_route(sw), parent_sw)->remote = NULL; in add_switch()
608 tb_switch_put(sw); in add_switch()
609 sw = ERR_PTR(ret); in add_switch()
616 return sw; in add_switch()
619 static void update_switch(struct tb_switch *parent_sw, struct tb_switch *sw, in update_switch() argument
624 tb_port_at(tb_route(sw), parent_sw)->remote = NULL; in update_switch()
626 tb_port_at(route, parent_sw)->remote = tb_upstream_port(sw); in update_switch()
629 sw->config.route_hi = upper_32_bits(route); in update_switch()
630 sw->config.route_lo = lower_32_bits(route); in update_switch()
631 sw->connection_id = connection_id; in update_switch()
632 sw->connection_key = connection_key; in update_switch()
633 sw->link = link; in update_switch()
634 sw->depth = depth; in update_switch()
635 sw->boot = boot; in update_switch()
638 sw->is_unplugged = false; in update_switch()
641 complete(&sw->rpm_complete); in update_switch()
644 static void remove_switch(struct tb_switch *sw) in remove_switch() argument
648 parent_sw = tb_to_switch(sw->dev.parent); in remove_switch()
649 tb_port_at(tb_route(sw), parent_sw)->remote = NULL; in remove_switch()
650 tb_switch_remove(sw); in remove_switch()
653 static void add_xdomain(struct tb_switch *sw, u64 route, in add_xdomain() argument
659 pm_runtime_get_sync(&sw->dev); in add_xdomain()
661 xd = tb_xdomain_alloc(sw->tb, &sw->dev, route, local_uuid, remote_uuid); in add_xdomain()
668 tb_port_at(route, sw)->xdomain = xd; in add_xdomain()
673 pm_runtime_mark_last_busy(&sw->dev); in add_xdomain()
674 pm_runtime_put_autosuspend(&sw->dev); in add_xdomain()
686 struct tb_switch *sw; in remove_xdomain() local
688 sw = tb_to_switch(xd->dev.parent); in remove_xdomain()
689 tb_port_at(xd->route, sw)->xdomain = NULL; in remove_xdomain()
699 struct tb_switch *sw, *parent_sw; in icm_fr_device_connected() local
724 sw = tb_switch_find_by_uuid(tb, &pkg->ep_uuid); in icm_fr_device_connected()
725 if (sw) { in icm_fr_device_connected()
728 parent_sw = tb_to_switch(sw->dev.parent); in icm_fr_device_connected()
729 sw_phy_port = tb_phy_port_from_link(sw->link); in icm_fr_device_connected()
740 if (sw->depth == depth && sw_phy_port == phy_port && in icm_fr_device_connected()
741 !!sw->authorized == authorized) { in icm_fr_device_connected()
746 if (sw->link != link) { in icm_fr_device_connected()
751 tb_switch_put(sw); in icm_fr_device_connected()
755 route = tb_route(sw); in icm_fr_device_connected()
758 update_switch(parent_sw, sw, route, pkg->connection_id, in icm_fr_device_connected()
760 tb_switch_put(sw); in icm_fr_device_connected()
769 remove_switch(sw); in icm_fr_device_connected()
770 tb_switch_put(sw); in icm_fr_device_connected()
779 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_device_connected()
780 if (!sw) { in icm_fr_device_connected()
785 sw = tb_switch_find_by_link_depth(tb, dual_link, depth); in icm_fr_device_connected()
787 if (sw) { in icm_fr_device_connected()
788 remove_switch(sw); in icm_fr_device_connected()
789 tb_switch_put(sw); in icm_fr_device_connected()
827 struct tb_switch *sw; in icm_fr_device_disconnected() local
839 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_device_disconnected()
840 if (!sw) { in icm_fr_device_disconnected()
846 remove_switch(sw); in icm_fr_device_disconnected()
847 tb_switch_put(sw); in icm_fr_device_disconnected()
856 struct tb_switch *sw; in icm_fr_xdomain_connected() local
918 sw = tb_switch_find_by_route(tb, route); in icm_fr_xdomain_connected()
919 if (sw) { in icm_fr_xdomain_connected()
920 remove_switch(sw); in icm_fr_xdomain_connected()
921 tb_switch_put(sw); in icm_fr_xdomain_connected()
924 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_xdomain_connected()
925 if (!sw) { in icm_fr_xdomain_connected()
931 add_xdomain(sw, route, &pkg->local_uuid, &pkg->remote_uuid, link, in icm_fr_xdomain_connected()
933 tb_switch_put(sw); in icm_fr_xdomain_connected()
987 static int icm_tr_approve_switch(struct tb *tb, struct tb_switch *sw) in icm_tr_approve_switch() argument
994 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_approve_switch()
996 request.route_lo = sw->config.route_lo; in icm_tr_approve_switch()
997 request.route_hi = sw->config.route_hi; in icm_tr_approve_switch()
998 request.connection_id = sw->connection_id; in icm_tr_approve_switch()
1014 static int icm_tr_add_switch_key(struct tb *tb, struct tb_switch *sw) in icm_tr_add_switch_key() argument
1021 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_add_switch_key()
1023 request.route_lo = sw->config.route_lo; in icm_tr_add_switch_key()
1024 request.route_hi = sw->config.route_hi; in icm_tr_add_switch_key()
1025 request.connection_id = sw->connection_id; in icm_tr_add_switch_key()
1026 memcpy(request.key, sw->key, TB_SWITCH_KEY_SIZE); in icm_tr_add_switch_key()
1042 static int icm_tr_challenge_switch_key(struct tb *tb, struct tb_switch *sw, in icm_tr_challenge_switch_key() argument
1050 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_challenge_switch_key()
1052 request.route_lo = sw->config.route_lo; in icm_tr_challenge_switch_key()
1053 request.route_hi = sw->config.route_hi; in icm_tr_challenge_switch_key()
1054 request.connection_id = sw->connection_id; in icm_tr_challenge_switch_key()
1146 struct tb_switch *sw, *parent_sw; in __icm_tr_device_connected() local
1173 sw = tb_switch_find_by_uuid(tb, &pkg->ep_uuid); in __icm_tr_device_connected()
1174 if (sw) { in __icm_tr_device_connected()
1176 if (tb_route(sw) == route && !!sw->authorized == authorized) { in __icm_tr_device_connected()
1177 parent_sw = tb_to_switch(sw->dev.parent); in __icm_tr_device_connected()
1178 update_switch(parent_sw, sw, route, pkg->connection_id, in __icm_tr_device_connected()
1180 tb_switch_put(sw); in __icm_tr_device_connected()
1184 remove_switch(sw); in __icm_tr_device_connected()
1185 tb_switch_put(sw); in __icm_tr_device_connected()
1189 sw = tb_switch_find_by_route(tb, route); in __icm_tr_device_connected()
1190 if (sw) { in __icm_tr_device_connected()
1191 remove_switch(sw); in __icm_tr_device_connected()
1192 tb_switch_put(sw); in __icm_tr_device_connected()
1208 sw = add_switch(parent_sw, route, &pkg->ep_uuid, (const u8 *)pkg->ep_name, in __icm_tr_device_connected()
1211 if (!IS_ERR(sw) && force_rtd3) in __icm_tr_device_connected()
1212 sw->rpm = true; in __icm_tr_device_connected()
1228 struct tb_switch *sw; in icm_tr_device_disconnected() local
1233 sw = tb_switch_find_by_route(tb, route); in icm_tr_device_disconnected()
1234 if (!sw) { in icm_tr_device_disconnected()
1239 remove_switch(sw); in icm_tr_device_disconnected()
1240 tb_switch_put(sw); in icm_tr_device_disconnected()
1249 struct tb_switch *sw; in icm_tr_xdomain_connected() local
1281 sw = tb_switch_find_by_route(tb, route); in icm_tr_xdomain_connected()
1282 if (sw) { in icm_tr_xdomain_connected()
1283 remove_switch(sw); in icm_tr_xdomain_connected()
1284 tb_switch_put(sw); in icm_tr_xdomain_connected()
1287 sw = tb_switch_find_by_route(tb, get_parent_route(route)); in icm_tr_xdomain_connected()
1288 if (!sw) { in icm_tr_xdomain_connected()
1293 add_xdomain(sw, route, &pkg->local_uuid, &pkg->remote_uuid, 0, 0); in icm_tr_xdomain_connected()
1294 tb_switch_put(sw); in icm_tr_xdomain_connected()
1894 static void icm_unplug_children(struct tb_switch *sw) in icm_unplug_children() argument
1898 if (tb_route(sw)) in icm_unplug_children()
1899 sw->is_unplugged = true; in icm_unplug_children()
1901 for (i = 1; i <= sw->config.max_port_number; i++) { in icm_unplug_children()
1902 struct tb_port *port = &sw->ports[i]; in icm_unplug_children()
1907 icm_unplug_children(port->remote->sw); in icm_unplug_children()
1913 struct tb_switch *sw = tb_to_switch(dev); in complete_rpm() local
1915 if (sw) in complete_rpm()
1916 complete(&sw->rpm_complete); in complete_rpm()
1920 static void remove_unplugged_switch(struct tb_switch *sw) in remove_unplugged_switch() argument
1922 pm_runtime_get_sync(sw->dev.parent); in remove_unplugged_switch()
1929 complete_rpm(&sw->dev, NULL); in remove_unplugged_switch()
1930 bus_for_each_dev(&tb_bus_type, &sw->dev, NULL, complete_rpm); in remove_unplugged_switch()
1931 tb_switch_remove(sw); in remove_unplugged_switch()
1933 pm_runtime_mark_last_busy(sw->dev.parent); in remove_unplugged_switch()
1934 pm_runtime_put_autosuspend(sw->dev.parent); in remove_unplugged_switch()
1937 static void icm_free_unplugged_children(struct tb_switch *sw) in icm_free_unplugged_children() argument
1941 for (i = 1; i <= sw->config.max_port_number; i++) { in icm_free_unplugged_children()
1942 struct tb_port *port = &sw->ports[i]; in icm_free_unplugged_children()
1948 if (port->remote->sw->is_unplugged) { in icm_free_unplugged_children()
1949 remove_unplugged_switch(port->remote->sw); in icm_free_unplugged_children()
1952 icm_free_unplugged_children(port->remote->sw); in icm_free_unplugged_children()
2005 static int icm_runtime_suspend_switch(struct tb_switch *sw) in icm_runtime_suspend_switch() argument
2007 if (tb_route(sw)) in icm_runtime_suspend_switch()
2008 reinit_completion(&sw->rpm_complete); in icm_runtime_suspend_switch()
2012 static int icm_runtime_resume_switch(struct tb_switch *sw) in icm_runtime_resume_switch() argument
2014 if (tb_route(sw)) { in icm_runtime_resume_switch()
2015 if (!wait_for_completion_timeout(&sw->rpm_complete, in icm_runtime_resume_switch()
2017 dev_dbg(&sw->dev, "runtime resuming timed out\n"); in icm_runtime_resume_switch()