Lines Matching refs:sw
258 struct icm_fr_pkg_get_topology_response *switches, *sw; in icm_fr_get_route() local
275 sw = &switches[0]; in icm_fr_get_route()
276 index = icm_fr_get_switch_index(sw->ports[link]); in icm_fr_get_route()
282 sw = &switches[index]; in icm_fr_get_route()
286 if (!(sw->first_data & ICM_SWITCH_USED)) { in icm_fr_get_route()
291 for (j = 0; j < ARRAY_SIZE(sw->ports); j++) { in icm_fr_get_route()
292 index = icm_fr_get_switch_index(sw->ports[j]); in icm_fr_get_route()
293 if (index > sw->switch_index) { in icm_fr_get_route()
294 sw = &switches[index]; in icm_fr_get_route()
300 *route = get_route(sw->route_hi, sw->route_lo); in icm_fr_get_route()
334 static int icm_fr_approve_switch(struct tb *tb, struct tb_switch *sw) in icm_fr_approve_switch() argument
341 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_approve_switch()
343 request.connection_id = sw->connection_id; in icm_fr_approve_switch()
344 request.connection_key = sw->connection_key; in icm_fr_approve_switch()
361 static int icm_fr_add_switch_key(struct tb *tb, struct tb_switch *sw) in icm_fr_add_switch_key() argument
368 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_add_switch_key()
370 request.connection_id = sw->connection_id; in icm_fr_add_switch_key()
371 request.connection_key = sw->connection_key; in icm_fr_add_switch_key()
372 memcpy(request.key, sw->key, TB_SWITCH_KEY_SIZE); in icm_fr_add_switch_key()
388 static int icm_fr_challenge_switch_key(struct tb *tb, struct tb_switch *sw, in icm_fr_challenge_switch_key() argument
396 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_fr_challenge_switch_key()
398 request.connection_id = sw->connection_id; in icm_fr_challenge_switch_key()
399 request.connection_key = sw->connection_key; in icm_fr_challenge_switch_key()
470 struct tb_switch *sw; in add_switch() local
474 sw = tb_switch_alloc(parent_sw->tb, &parent_sw->dev, route); in add_switch()
475 if (!sw) in add_switch()
478 sw->uuid = kmemdup(uuid, sizeof(*uuid), GFP_KERNEL); in add_switch()
479 sw->connection_id = connection_id; in add_switch()
480 sw->connection_key = connection_key; in add_switch()
481 sw->link = link; in add_switch()
482 sw->depth = depth; in add_switch()
483 sw->authorized = authorized; in add_switch()
484 sw->security_level = security_level; in add_switch()
485 sw->boot = boot; in add_switch()
489 sw->rpm = !!(vss->flags & INTEL_VSS_FLAGS_RTD3); in add_switch()
492 tb_port_at(route, parent_sw)->remote = tb_upstream_port(sw); in add_switch()
493 tb_upstream_port(sw)->remote = tb_port_at(route, parent_sw); in add_switch()
495 if (tb_switch_add(sw)) { in add_switch()
496 tb_port_at(tb_route(sw), parent_sw)->remote = NULL; in add_switch()
497 tb_switch_put(sw); in add_switch()
505 static void update_switch(struct tb_switch *parent_sw, struct tb_switch *sw, in update_switch() argument
510 tb_port_at(tb_route(sw), parent_sw)->remote = NULL; in update_switch()
512 tb_port_at(route, parent_sw)->remote = tb_upstream_port(sw); in update_switch()
515 sw->config.route_hi = upper_32_bits(route); in update_switch()
516 sw->config.route_lo = lower_32_bits(route); in update_switch()
517 sw->connection_id = connection_id; in update_switch()
518 sw->connection_key = connection_key; in update_switch()
519 sw->link = link; in update_switch()
520 sw->depth = depth; in update_switch()
521 sw->boot = boot; in update_switch()
524 sw->is_unplugged = false; in update_switch()
527 static void remove_switch(struct tb_switch *sw) in remove_switch() argument
531 parent_sw = tb_to_switch(sw->dev.parent); in remove_switch()
532 tb_port_at(tb_route(sw), parent_sw)->remote = NULL; in remove_switch()
533 tb_switch_remove(sw); in remove_switch()
536 static void add_xdomain(struct tb_switch *sw, u64 route, in add_xdomain() argument
542 pm_runtime_get_sync(&sw->dev); in add_xdomain()
544 xd = tb_xdomain_alloc(sw->tb, &sw->dev, route, local_uuid, remote_uuid); in add_xdomain()
551 tb_port_at(route, sw)->xdomain = xd; in add_xdomain()
556 pm_runtime_mark_last_busy(&sw->dev); in add_xdomain()
557 pm_runtime_put_autosuspend(&sw->dev); in add_xdomain()
569 struct tb_switch *sw; in remove_xdomain() local
571 sw = tb_to_switch(xd->dev.parent); in remove_xdomain()
572 tb_port_at(xd->route, sw)->xdomain = NULL; in remove_xdomain()
582 struct tb_switch *sw, *parent_sw; in icm_fr_device_connected() local
605 sw = tb_switch_find_by_uuid(tb, &pkg->ep_uuid); in icm_fr_device_connected()
606 if (sw) { in icm_fr_device_connected()
609 parent_sw = tb_to_switch(sw->dev.parent); in icm_fr_device_connected()
610 sw_phy_port = tb_phy_port_from_link(sw->link); in icm_fr_device_connected()
621 if (sw->depth == depth && sw_phy_port == phy_port && in icm_fr_device_connected()
622 !!sw->authorized == authorized) { in icm_fr_device_connected()
627 if (sw->link != link) { in icm_fr_device_connected()
632 tb_switch_put(sw); in icm_fr_device_connected()
636 route = tb_route(sw); in icm_fr_device_connected()
639 update_switch(parent_sw, sw, route, pkg->connection_id, in icm_fr_device_connected()
641 tb_switch_put(sw); in icm_fr_device_connected()
650 remove_switch(sw); in icm_fr_device_connected()
651 tb_switch_put(sw); in icm_fr_device_connected()
660 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_device_connected()
661 if (!sw) { in icm_fr_device_connected()
666 sw = tb_switch_find_by_link_depth(tb, dual_link, depth); in icm_fr_device_connected()
668 if (sw) { in icm_fr_device_connected()
669 remove_switch(sw); in icm_fr_device_connected()
670 tb_switch_put(sw); in icm_fr_device_connected()
708 struct tb_switch *sw; in icm_fr_device_disconnected() local
720 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_device_disconnected()
721 if (!sw) { in icm_fr_device_disconnected()
727 remove_switch(sw); in icm_fr_device_disconnected()
728 tb_switch_put(sw); in icm_fr_device_disconnected()
737 struct tb_switch *sw; in icm_fr_xdomain_connected() local
799 sw = get_switch_at_route(tb->root_switch, route); in icm_fr_xdomain_connected()
800 if (sw) in icm_fr_xdomain_connected()
801 remove_switch(sw); in icm_fr_xdomain_connected()
803 sw = tb_switch_find_by_link_depth(tb, link, depth); in icm_fr_xdomain_connected()
804 if (!sw) { in icm_fr_xdomain_connected()
810 add_xdomain(sw, route, &pkg->local_uuid, &pkg->remote_uuid, link, in icm_fr_xdomain_connected()
812 tb_switch_put(sw); in icm_fr_xdomain_connected()
861 static int icm_tr_approve_switch(struct tb *tb, struct tb_switch *sw) in icm_tr_approve_switch() argument
868 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_approve_switch()
870 request.route_lo = sw->config.route_lo; in icm_tr_approve_switch()
871 request.route_hi = sw->config.route_hi; in icm_tr_approve_switch()
872 request.connection_id = sw->connection_id; in icm_tr_approve_switch()
888 static int icm_tr_add_switch_key(struct tb *tb, struct tb_switch *sw) in icm_tr_add_switch_key() argument
895 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_add_switch_key()
897 request.route_lo = sw->config.route_lo; in icm_tr_add_switch_key()
898 request.route_hi = sw->config.route_hi; in icm_tr_add_switch_key()
899 request.connection_id = sw->connection_id; in icm_tr_add_switch_key()
900 memcpy(request.key, sw->key, TB_SWITCH_KEY_SIZE); in icm_tr_add_switch_key()
916 static int icm_tr_challenge_switch_key(struct tb *tb, struct tb_switch *sw, in icm_tr_challenge_switch_key() argument
924 memcpy(&request.ep_uuid, sw->uuid, sizeof(request.ep_uuid)); in icm_tr_challenge_switch_key()
926 request.route_lo = sw->config.route_lo; in icm_tr_challenge_switch_key()
927 request.route_hi = sw->config.route_hi; in icm_tr_challenge_switch_key()
928 request.connection_id = sw->connection_id; in icm_tr_challenge_switch_key()
1019 struct tb_switch *sw, *parent_sw; in icm_tr_device_connected() local
1044 sw = tb_switch_find_by_uuid(tb, &pkg->ep_uuid); in icm_tr_device_connected()
1045 if (sw) { in icm_tr_device_connected()
1047 if (tb_route(sw) == route && !!sw->authorized == authorized) { in icm_tr_device_connected()
1048 parent_sw = tb_to_switch(sw->dev.parent); in icm_tr_device_connected()
1049 update_switch(parent_sw, sw, route, pkg->connection_id, in icm_tr_device_connected()
1051 tb_switch_put(sw); in icm_tr_device_connected()
1055 remove_switch(sw); in icm_tr_device_connected()
1056 tb_switch_put(sw); in icm_tr_device_connected()
1060 sw = tb_switch_find_by_route(tb, route); in icm_tr_device_connected()
1061 if (sw) { in icm_tr_device_connected()
1062 remove_switch(sw); in icm_tr_device_connected()
1063 tb_switch_put(sw); in icm_tr_device_connected()
1091 struct tb_switch *sw; in icm_tr_device_disconnected() local
1096 sw = tb_switch_find_by_route(tb, route); in icm_tr_device_disconnected()
1097 if (!sw) { in icm_tr_device_disconnected()
1102 remove_switch(sw); in icm_tr_device_disconnected()
1103 tb_switch_put(sw); in icm_tr_device_disconnected()
1112 struct tb_switch *sw; in icm_tr_xdomain_connected() local
1144 sw = get_switch_at_route(tb->root_switch, route); in icm_tr_xdomain_connected()
1145 if (sw) in icm_tr_xdomain_connected()
1146 remove_switch(sw); in icm_tr_xdomain_connected()
1148 sw = tb_switch_find_by_route(tb, get_parent_route(route)); in icm_tr_xdomain_connected()
1149 if (!sw) { in icm_tr_xdomain_connected()
1154 add_xdomain(sw, route, &pkg->local_uuid, &pkg->remote_uuid, 0, 0); in icm_tr_xdomain_connected()
1155 tb_switch_put(sw); in icm_tr_xdomain_connected()
1749 static void icm_unplug_children(struct tb_switch *sw) in icm_unplug_children() argument
1753 if (tb_route(sw)) in icm_unplug_children()
1754 sw->is_unplugged = true; in icm_unplug_children()
1756 for (i = 1; i <= sw->config.max_port_number; i++) { in icm_unplug_children()
1757 struct tb_port *port = &sw->ports[i]; in icm_unplug_children()
1768 icm_unplug_children(port->remote->sw); in icm_unplug_children()
1772 static void icm_free_unplugged_children(struct tb_switch *sw) in icm_free_unplugged_children() argument
1776 for (i = 1; i <= sw->config.max_port_number; i++) { in icm_free_unplugged_children()
1777 struct tb_port *port = &sw->ports[i]; in icm_free_unplugged_children()
1791 if (port->remote->sw->is_unplugged) { in icm_free_unplugged_children()
1792 tb_switch_remove(port->remote->sw); in icm_free_unplugged_children()
1795 icm_free_unplugged_children(port->remote->sw); in icm_free_unplugged_children()