Lines Matching +full:in +full:- +full:ports

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2004-2006 Kristian Hoegsberg <krh@bitplanet.net>
11 #include <linux/firewire-constants.h>
23 #include "phy-packet-definitions.h"
30 node = kzalloc(struct_size(node, ports, port_count), GFP_ATOMIC); in fw_node_create()
34 node->color = color; in fw_node_create()
35 node->node_id = LOCAL_BUS | phy_packet_self_id_get_phy_id(sid); in fw_node_create()
36 node->link_on = phy_packet_self_id_zero_get_link_active(sid); in fw_node_create()
38 node->phy_speed = phy_packet_self_id_zero_get_scode(sid); in fw_node_create()
39 node->initiated_reset = phy_packet_self_id_zero_get_initiated_reset(sid); in fw_node_create()
40 node->port_count = port_count; in fw_node_create()
42 kref_init(&node->kref); in fw_node_create()
43 INIT_LIST_HEAD(&node->link); in fw_node_create()
51 * two nodes in the subtree rooted at this node. We need this for
52 * setting the gap count. As we build the tree bottom up in
56 * two cases: either the path goes through this node, in which case
59 * containted in a child tree, in which case the max hop count is just
64 int depths[2] = { -1, -1 }; in update_hop_count()
68 for (i = 0; i < node->port_count; i++) { in update_hop_count()
69 if (node->ports[i] == NULL) in update_hop_count()
72 if (node->ports[i]->max_hops > max_child_hops) in update_hop_count()
73 max_child_hops = node->ports[i]->max_hops; in update_hop_count()
75 if (node->ports[i]->max_depth > depths[0]) { in update_hop_count()
77 depths[0] = node->ports[i]->max_depth; in update_hop_count()
78 } else if (node->ports[i]->max_depth > depths[1]) in update_hop_count()
79 depths[1] = node->ports[i]->max_depth; in update_hop_count()
82 node->max_depth = depths[0] + 1; in update_hop_count()
83 node->max_hops = max(max_child_hops, depths[0] + depths[1] + 2); in update_hop_count()
134 if (PTR_ERR(self_id_sequence) != -ENODATA) { in build_tree()
143 trace_self_id_sequence(card->index, self_id_sequence, quadlet_count, generation); in build_tree()
163 fw_err(card, "PHY ID mismatch in self ID: %d != %d\n", in build_tree()
178 h = h->prev; in build_tree()
185 node = fw_node_create(self_id_sequence[0], total_port_count, card->color); in build_tree()
191 if (phy_id == (card->node_id & 0x3f)) in build_tree()
203 // we temporarily abuse node->color for remembering the entry in in build_tree()
204 // the node->ports array where the parent node should be. Later, in build_tree()
207 node->color = port_index; in build_tree()
211 node->ports[port_index] = child; in build_tree()
213 child->ports[child->color] = node; in build_tree()
214 child->color = card->color; in build_tree()
215 child = fw_node(child->link.next); in build_tree()
234 __list_del(h->prev, &stack); in build_tree()
235 list_add_tail(&node->link, &stack); in build_tree()
236 stack_depth += 1 - child_port_count; in build_tree()
238 if (node->phy_speed == SCODE_BETA && parent_count + child_port_count > 1) in build_tree()
251 card->root_node = node; in build_tree()
252 card->irm_node = irm_node; in build_tree()
253 card->gap_count = gap_count; in build_tree()
254 card->beta_repeaters_present = beta_repeaters_present; in build_tree()
273 list_add_tail(&root->link, &list); in for_each_fw_node()
276 node->color = card->color; in for_each_fw_node()
278 for (i = 0; i < node->port_count; i++) { in for_each_fw_node()
279 child = node->ports[i]; in for_each_fw_node()
282 if (child->color == card->color) in for_each_fw_node()
286 list_add_tail(&child->link, &list); in for_each_fw_node()
303 /* Topology has changed - reset bus manager retry counter */ in report_lost_node()
304 card->bm_retries = 0; in report_lost_node()
310 int b_path = (node->phy_speed == SCODE_BETA); in report_found_node()
314 node->max_speed = parent->max_speed < node->phy_speed ? in report_found_node()
315 parent->max_speed : node->phy_speed; in report_found_node()
316 node->b_path = parent->b_path && b_path; in report_found_node()
318 node->max_speed = node->phy_speed; in report_found_node()
319 node->b_path = b_path; in report_found_node()
324 /* Topology has changed - reset bus manager retry counter */ in report_found_node()
325 card->bm_retries = 0; in report_found_node()
328 /* Must be called with card->lock held */
331 card->color++; in fw_destroy_nodes()
332 if (card->local_node != NULL) in fw_destroy_nodes()
333 for_each_fw_node(card, card->local_node, report_lost_node); in fw_destroy_nodes()
334 card->local_node = NULL; in fw_destroy_nodes()
342 tree = node1->ports[port]; in move_tree()
343 node0->ports[port] = tree; in move_tree()
344 for (i = 0; i < tree->port_count; i++) { in move_tree()
345 if (tree->ports[i] == node1) { in move_tree()
346 tree->ports[i] = node0; in move_tree()
355 * Update the nodes in the card topology tree as we go.
364 list_add_tail(&card->local_node->link, &list0); in update_tree()
366 list_add_tail(&root->link, &list1); in update_tree()
371 while (&node0->link != &list0) { in update_tree()
372 WARN_ON(node0->port_count != node1->port_count); in update_tree()
374 if (node0->link_on && !node1->link_on) in update_tree()
376 else if (!node0->link_on && node1->link_on) in update_tree()
378 else if (node1->initiated_reset && node1->link_on) in update_tree()
383 node0->node_id = node1->node_id; in update_tree()
384 node0->color = card->color; in update_tree()
385 node0->link_on = node1->link_on; in update_tree()
386 node0->initiated_reset = node1->initiated_reset; in update_tree()
387 node0->max_hops = node1->max_hops; in update_tree()
388 node1->color = card->color; in update_tree()
391 if (card->root_node == node1) in update_tree()
392 card->root_node = node0; in update_tree()
393 if (card->irm_node == node1) in update_tree()
394 card->irm_node = node0; in update_tree()
396 for (i = 0; i < node0->port_count; i++) { in update_tree()
397 if (node0->ports[i] && node1->ports[i]) { in update_tree()
403 if (node0->ports[i]->color == card->color) in update_tree()
405 list_add_tail(&node0->ports[i]->link, &list0); in update_tree()
406 list_add_tail(&node1->ports[i]->link, &list1); in update_tree()
407 } else if (node0->ports[i]) { in update_tree()
415 for_each_fw_node(card, node0->ports[i], in update_tree()
417 node0->ports[i] = NULL; in update_tree()
418 } else if (node1->ports[i]) { in update_tree()
426 for_each_fw_node(card, node0->ports[i], in update_tree()
431 node0 = fw_node(node0->link.next); in update_tree()
432 next1 = fw_node(node1->link.next); in update_tree()
441 int node_count = (card->root_node->node_id & 0x3f) + 1; in update_topology_map()
442 __be32 *map = card->topology_map; in update_topology_map()
445 *map++ = cpu_to_be32(be32_to_cpu(card->topology_map[1]) + 1); in update_topology_map()
448 while (self_id_count--) in update_topology_map()
451 fw_compute_block_crc(card->topology_map); in update_topology_map()
459 trace_bus_reset_handle(card->index, generation, node_id, bm_abdicate, self_ids, self_id_count); in fw_core_handle_bus_reset()
461 guard(spinlock_irqsave)(&card->lock); in fw_core_handle_bus_reset()
468 if (!is_next_generation(generation, card->generation) && in fw_core_handle_bus_reset()
469 card->local_node != NULL) { in fw_core_handle_bus_reset()
471 card->bm_retries = 0; in fw_core_handle_bus_reset()
474 card->broadcast_channel_allocated = card->broadcast_channel_auto_allocated; in fw_core_handle_bus_reset()
475 card->node_id = node_id; in fw_core_handle_bus_reset()
481 card->generation = generation; in fw_core_handle_bus_reset()
482 card->reset_jiffies = get_jiffies_64(); in fw_core_handle_bus_reset()
483 card->bm_node_id = 0xffff; in fw_core_handle_bus_reset()
484 card->bm_abdicate = bm_abdicate; in fw_core_handle_bus_reset()
491 card->color++; in fw_core_handle_bus_reset()
495 /* FIXME: We need to issue a bus reset in this case. */ in fw_core_handle_bus_reset()
496 } else if (card->local_node == NULL) { in fw_core_handle_bus_reset()
497 card->local_node = local_node; in fw_core_handle_bus_reset()