📄 klgraph.c
字号:
GRPRINTF(("klhwg_add_node: adding %s to vertex 0x%p\n", path_buffer, hwgraph_root)); rv = hwgraph_path_add(hwgraph_root, path_buffer, &node_vertex); printk("klhwg_add_node: rv = %d graph success %d node_vertex 0x%p\n", rv, GRAPH_SUCCESS, node_vertex); if (rv != GRAPH_SUCCESS) cmn_err(CE_PANIC, "Node vertex creation failed. " "Path == %s", path_buffer); hub = (klhub_t *)find_first_component(brd, KLSTRUCT_HUB); ASSERT(hub); if(hub->hub_info.flags & KLINFO_ENABLE) board_disabled = 0; else board_disabled = 1; if(!board_disabled) { mark_nodevertex_as_node(node_vertex, cnode + board_disabled * numnodes); printk("klhwg_add_node: node_vertex %p, cnode %d numnodes %d\n", node_vertex, cnode, numnodes); s = dev_to_name(node_vertex, path_buffer, sizeof(path_buffer)); printk("klhwg_add_node: s %s\n", s); NODEPDA(cnode)->hwg_node_name = kmalloc(strlen(s) + 1, GFP_KERNEL); ASSERT_ALWAYS(NODEPDA(cnode)->hwg_node_name != NULL); strcpy(NODEPDA(cnode)->hwg_node_name, s); hubinfo_set(node_vertex, NODEPDA(cnode)->pdinfo); /* Set up node board's slot */ NODEPDA(cnode)->slotdesc = brd->brd_slot; /* Set up the module we're in */ NODEPDA(cnode)->module_id = brd->brd_module; NODEPDA(cnode)->module = module_lookup(brd->brd_module); } if(!board_disabled) klhwg_add_hub(node_vertex, hub, cnode); brd = KLCF_NEXT(brd); if (brd) brd = find_lboard(brd, KLTYPE_IP27); else break; } while(brd);}/* ARGSUSED */voidklhwg_add_all_routers(devfs_handle_t hwgraph_root){ nasid_t nasid; cnodeid_t cnode; lboard_t *brd; devfs_handle_t node_vertex; char path_buffer[100]; int rv; for (cnode = 0; cnode < maxnodes; cnode++) { nasid = COMPACT_TO_NASID_NODEID(cnode); GRPRINTF(("klhwg_add_all_routers: adding router on cnode %d\n", cnode)); brd = find_lboard_class((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_ROUTER); if (!brd) /* No routers stored in this node's memory */ continue; do { ASSERT(brd); GRPRINTF(("Router board struct is %p\n", brd)); /* Don't add duplicate boards. */ if (brd->brd_flags & DUPLICATE_BOARD) continue; GRPRINTF(("Router 0x%p module number is %d\n", brd, brd->brd_module)); /* Generate a hardware graph path for this board. */ board_to_path(brd, path_buffer); GRPRINTF(("Router path is %s\n", path_buffer)); /* Add the router */ GRPRINTF(("klhwg_add_all_routers: adding %s to vertex 0x%p\n", path_buffer, hwgraph_root)); rv = hwgraph_path_add(hwgraph_root, path_buffer, &node_vertex); if (rv != GRAPH_SUCCESS) cmn_err(CE_PANIC, "Router vertex creation " "failed. Path == %s", path_buffer); GRPRINTF(("klhwg_add_all_routers: get next board from 0x%p\n", brd)); /* Find the rest of the routers stored on this node. */ } while ( (brd = find_lboard_class(KLCF_NEXT(brd), KLTYPE_ROUTER)) ); GRPRINTF(("klhwg_add_all_routers: Done.\n")); }}/* ARGSUSED */voidklhwg_connect_one_router(devfs_handle_t hwgraph_root, lboard_t *brd, cnodeid_t cnode, nasid_t nasid){ klrou_t *router; char path_buffer[50]; char dest_path[50]; devfs_handle_t router_hndl; devfs_handle_t dest_hndl; int rc; int port; lboard_t *dest_brd; GRPRINTF(("klhwg_connect_one_router: Connecting router on cnode %d\n", cnode)); /* Don't add duplicate boards. */ if (brd->brd_flags & DUPLICATE_BOARD) { GRPRINTF(("klhwg_connect_one_router: Duplicate router 0x%p on cnode %d\n", brd, cnode)); return; } /* Generate a hardware graph path for this board. */ board_to_path(brd, path_buffer); rc = hwgraph_traverse(hwgraph_root, path_buffer, &router_hndl); if (rc != GRAPH_SUCCESS && is_specified(arg_maxnodes)) return; if (rc != GRAPH_SUCCESS) cmn_err(CE_WARN, "Can't find router: %s", path_buffer); /* We don't know what to do with multiple router components */ if (brd->brd_numcompts != 1) { cmn_err(CE_PANIC, "klhwg_connect_one_router: %d cmpts on router\n", brd->brd_numcompts); return; } /* Convert component 0 to klrou_t ptr */ router = (klrou_t *)NODE_OFFSET_TO_K0(NASID_GET(brd), brd->brd_compts[0]); for (port = 1; port <= MAX_ROUTER_PORTS; port++) { /* See if the port's active */ if (router->rou_port[port].port_nasid == INVALID_NASID) { GRPRINTF(("klhwg_connect_one_router: port %d inactive.\n", port)); continue; } if (is_specified(arg_maxnodes) && NASID_TO_COMPACT_NODEID(router->rou_port[port].port_nasid) == INVALID_CNODEID) { continue; } dest_brd = (lboard_t *)NODE_OFFSET_TO_K0( router->rou_port[port].port_nasid, router->rou_port[port].port_offset); /* Generate a hardware graph path for this board. */ board_to_path(dest_brd, dest_path); rc = hwgraph_traverse(hwgraph_root, dest_path, &dest_hndl); if (rc != GRAPH_SUCCESS) { if (is_specified(arg_maxnodes) && KL_CONFIG_DUPLICATE_BOARD(dest_brd)) continue; cmn_err(CE_PANIC, "Can't find router: %s", dest_path); } GRPRINTF(("klhwg_connect_one_router: Link from %s/%d to %s\n", path_buffer, port, dest_path)); sprintf(dest_path, "%d", port); rc = hwgraph_edge_add(router_hndl, dest_hndl, dest_path); if (rc == GRAPH_DUP) { GRPRINTF(("Skipping port %d. nasid %d %s/%s\n", port, router->rou_port[port].port_nasid, path_buffer, dest_path)); continue; } if (rc != GRAPH_SUCCESS && !is_specified(arg_maxnodes)) cmn_err(CE_GRPANIC, "Can't create edge: %s/%s to vertex 0x%p error 0x%x\n", path_buffer, dest_path, dest_hndl, rc); }}voidklhwg_connect_routers(devfs_handle_t hwgraph_root){ nasid_t nasid; cnodeid_t cnode; lboard_t *brd; for (cnode = 0; cnode < maxnodes; cnode++) { nasid = COMPACT_TO_NASID_NODEID(cnode); GRPRINTF(("klhwg_connect_routers: Connecting routers on cnode %d\n", cnode)); brd = find_lboard_class((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_ROUTER); if (!brd) continue; do { nasid = COMPACT_TO_NASID_NODEID(cnode); klhwg_connect_one_router(hwgraph_root, brd, cnode, nasid); /* Find the rest of the routers stored on this node. */ } while ( (brd = find_lboard_class(KLCF_NEXT(brd), KLTYPE_ROUTER)) ); }}voidklhwg_connect_hubs(devfs_handle_t hwgraph_root){ nasid_t nasid; cnodeid_t cnode; lboard_t *brd; klhub_t *hub; lboard_t *dest_brd; devfs_handle_t hub_hndl; devfs_handle_t dest_hndl; char path_buffer[50]; char dest_path[50]; graph_error_t rc; for (cnode = 0; cnode < maxnodes; cnode++) { nasid = COMPACT_TO_NASID_NODEID(cnode); GRPRINTF(("klhwg_connect_hubs: Connecting hubs on cnode %d\n", cnode)); brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_IP27); ASSERT(brd); hub = (klhub_t *)find_first_component(brd, KLSTRUCT_HUB); ASSERT(hub); /* See if the port's active */ if (hub->hub_port.port_nasid == INVALID_NASID) { GRPRINTF(("klhwg_connect_hubs: port inactive.\n")); continue; } if (is_specified(arg_maxnodes) && NASID_TO_COMPACT_NODEID(hub->hub_port.port_nasid) == INVALID_CNODEID) continue; /* Generate a hardware graph path for this board. */ board_to_path(brd, path_buffer); GRPRINTF(("klhwg_connect_hubs: Hub path is %s.\n", path_buffer)); rc = hwgraph_traverse(hwgraph_root, path_buffer, &hub_hndl); if (rc != GRAPH_SUCCESS) cmn_err(CE_WARN, "Can't find hub: %s", path_buffer); dest_brd = (lboard_t *)NODE_OFFSET_TO_K0( hub->hub_port.port_nasid, hub->hub_port.port_offset); /* Generate a hardware graph path for this board. */ board_to_path(dest_brd, dest_path); rc = hwgraph_traverse(hwgraph_root, dest_path, &dest_hndl); if (rc != GRAPH_SUCCESS) { if (is_specified(arg_maxnodes) && KL_CONFIG_DUPLICATE_BOARD(dest_brd)) continue; cmn_err(CE_PANIC, "Can't find board: %s", dest_path); } else { GRPRINTF(("klhwg_connect_hubs: Link from %s to %s.\n", path_buffer, dest_path)); rc = hwgraph_edge_add(hub_hndl, dest_hndl, EDGE_LBL_INTERCONNECT); if (rc != GRAPH_SUCCESS) cmn_err(CE_GRPANIC, "Can't create edge: %s/%s to vertex 0x%p, error 0x%x\n", path_buffer, dest_path, dest_hndl, rc); } }}/* Store the pci/vme disabled board information as extended administrative * hints which can later be used by the drivers using the device/driver * admin interface. */voidklhwg_device_disable_hints_add(void){ cnodeid_t cnode; /* node we are looking at */ nasid_t nasid; /* nasid of the node */ lboard_t *board; /* board we are looking at */ int comp_index; /* component index */ klinfo_t *component; /* component in the board we are * looking at */ char device_name[MAXDEVNAME]; #ifndef CONFIG_IA64_SGI_IO device_admin_table_init();#endif for(cnode = 0; cnode < numnodes; cnode++) { nasid = COMPACT_TO_NASID_NODEID(cnode); board = (lboard_t *)KL_CONFIG_INFO(nasid); /* Check out all the board info stored on a node */ while(board) { /* No need to look at duplicate boards or non-io * boards */ if (KL_CONFIG_DUPLICATE_BOARD(board) || KLCLASS(board->brd_type) != KLCLASS_IO) { board = KLCF_NEXT(board); continue; } /* Check out all the components of a board */ for (comp_index = 0; comp_index < KLCF_NUM_COMPS(board); comp_index++) { component = KLCF_COMP(board,comp_index); /* If the component is enabled move on to * the next component */ if (KLCONFIG_INFO_ENABLED(component)) continue; /* NOTE : Since the prom only supports * the disabling of pci devices the following * piece of code makes sense. * Make sure that this assumption is valid */ /* This component is disabled. Store this * hint in the extended device admin table */ /* Get the canonical name of the pci device */ device_component_canonical_name_get(board, component, device_name);#ifndef CONFIG_IA64_SGI_IO device_admin_table_update(device_name, ADMIN_LBL_DISABLED, "yes");#endif#ifdef DEBUG printf("%s DISABLED\n",device_name);#endif } /* go to the next board info stored on this * node */ board = KLCF_NEXT(board); } }}voidklhwg_add_all_modules(devfs_handle_t hwgraph_root){ cmoduleid_t cm; char name[128]; devfs_handle_t vhdl; int rc; /* Add devices under each module */ for (cm = 0; cm < nummodules; cm++) { /* Use module as module vertex fastinfo */ sprintf(name, EDGE_LBL_MODULE "/%x", modules[cm]->id); rc = hwgraph_path_add(hwgraph_root, name, &vhdl); ASSERT(rc == GRAPH_SUCCESS); rc = rc; hwgraph_fastinfo_set(vhdl, (arbitrary_info_t) modules[cm]); /* Add system controller */ sprintf(name, EDGE_LBL_MODULE "/%x/" EDGE_LBL_L1, modules[cm]->id); rc = hwgraph_path_add(hwgraph_root, name, &vhdl); ASSERT_ALWAYS(rc == GRAPH_SUCCESS); rc = rc; hwgraph_info_add_LBL(vhdl, INFO_LBL_ELSC, (arbitrary_info_t) (__psint_t) 1);#ifndef CONFIG_IA64_SGI_IO sndrv_attach(vhdl);#else /* * We need to call the drivers attach routine .. */ FIXME("klhwg_add_all_modules: Need code to call driver attach.\n");#endif }}voidklhwg_add_all_nodes(devfs_handle_t hwgraph_root){ //gda_t *gdap = GDA; gda_t *gdap; cnodeid_t cnode;#ifdef SIMULATED_KLGRAPH //gdap = 0xa800000000011000; gdap = (gda_t *)0xe000000000011000; printk("klhwg_add_all_nodes: SIMULATED_KLGRAPH FIXME: gdap= 0x%p\n", gdap);#else gdap = GDA;#endif /* SIMULATED_KLGRAPH */ for (cnode = 0; cnode < numnodes; cnode++) { ASSERT(gdap->g_nasidtable[cnode] != INVALID_NASID); klhwg_add_node(hwgraph_root, cnode, gdap); } for (cnode = 0; cnode < numnodes; cnode++) { ASSERT(gdap->g_nasidtable[cnode] != INVALID_NASID);#ifndef CONFIG_IA64_SGI_IO klhwg_add_xbow(cnode, gdap->g_nasidtable[cnode]);#else printk("klhwg_add_all_nodes: Fix me by getting real nasid\n"); klhwg_add_xbow(cnode, 0);#endif } /* * As for router hardware inventory information, we set this * up in router.c. */ klhwg_add_all_routers(hwgraph_root); klhwg_connect_routers(hwgraph_root); klhwg_connect_hubs(hwgraph_root); /* Assign guardian nodes to each of the * routers in the system. */#ifndef CONFIG_IA64_SGI_IO router_guardians_set(hwgraph_root);#endif /* Go through the entire system's klconfig * to figure out which pci components have been disabled */ klhwg_device_disable_hints_add();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -