📄 klgraph.c
字号:
/* $Id$ * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved. *//* * klgraph.c- * This file specifies the interface between the kernel and the PROM's * configuration data structures. */#include <linux/types.h>#include <linux/slab.h>#include <asm/sn/sgi.h>#include <asm/sn/sn_sal.h>#include <asm/sn/io.h>#include <asm/sn/iograph.h>#include <asm/sn/invent.h>#include <asm/sn/hcl.h>#include <asm/sn/labelcl.h>#include <asm/sn/kldir.h>#include <asm/sn/klconfig.h>#include <asm/sn/router.h>#include <asm/sn/xtalk/xbow.h>#include <asm/sn/hcl_util.h>// #define KLGRAPH_DEBUG 1#ifdef KLGRAPH_DEBUG#define GRPRINTF(x) printk x#define CE_GRPANIC CE_PANIC#else#define GRPRINTF(x)#define CE_GRPANIC CE_PANIC#endif#include <asm/sn/sn_private.h>extern char arg_maxnodes[];extern u64 klgraph_addr[];void mark_cpuvertex_as_cpu(vertex_hdl_t vhdl, cpuid_t cpuid);extern int is_specified(char *);/* * Support for verbose inventory via hardware graph. * klhwg_invent_alloc allocates the necessary size of inventory information * and fills in the generic information. */invent_generic_t *klhwg_invent_alloc(cnodeid_t cnode, int class, int size){ invent_generic_t *invent; invent = kmalloc(size, GFP_KERNEL); if (!invent) return NULL; invent->ig_module = NODE_MODULEID(cnode); invent->ig_slot = SLOTNUM_GETSLOT(NODE_SLOTID(cnode)); invent->ig_invclass = class; return invent;}/* * Add detailed disabled cpu inventory info to the hardware graph. */voidklhwg_disabled_cpu_invent_info(vertex_hdl_t cpuv, cnodeid_t cnode, klcpu_t *cpu, slotid_t slot){ invent_cpuinfo_t *cpu_invent; diag_inv_t *diag_invent; cpu_invent = (invent_cpuinfo_t *) klhwg_invent_alloc(cnode, INV_PROCESSOR, sizeof(invent_cpuinfo_t)); if (!cpu_invent) return; /* Diag information on this processor */ diag_invent = (diag_inv_t *) klhwg_invent_alloc(cnode, INV_CPUDIAGVAL, sizeof(diag_inv_t)); if (!diag_invent) return; /* Disabled CPU */ cpu_invent->ic_gen.ig_flag = 0x0; cpu_invent->ic_gen.ig_slot = slot; cpu_invent->ic_cpu_info.cpuflavor = cpu->cpu_prid; cpu_invent->ic_cpu_info.cpufq = cpu->cpu_speed; cpu_invent->ic_cpu_info.sdfreq = cpu->cpu_scachespeed; cpu_invent->ic_cpu_info.sdsize = cpu->cpu_scachesz; cpu_invent->ic_cpuid = cpu->cpu_info.virtid; cpu_invent->ic_slice = cpu->cpu_info.physid; /* Disabled CPU label */ hwgraph_info_add_LBL(cpuv, INFO_LBL_DETAIL_INVENT, (arbitrary_info_t) cpu_invent); hwgraph_info_export_LBL(cpuv, INFO_LBL_DETAIL_INVENT, sizeof(invent_cpuinfo_t)); /* Diagval label - stores reason for disable +{virt,phys}id +diagval*/ hwgraph_info_add_LBL(cpuv, INFO_LBL_DIAGVAL, (arbitrary_info_t) diag_invent); hwgraph_info_export_LBL(cpuv, INFO_LBL_DIAGVAL, sizeof(diag_inv_t));}/* * Add detailed cpu inventory info to the hardware graph. */voidklhwg_cpu_invent_info(vertex_hdl_t cpuv, cnodeid_t cnode, klcpu_t *cpu){ invent_cpuinfo_t *cpu_invent; cpu_invent = (invent_cpuinfo_t *) klhwg_invent_alloc(cnode, INV_PROCESSOR, sizeof(invent_cpuinfo_t)); if (!cpu_invent) return; if (KLCONFIG_INFO_ENABLED((klinfo_t *)cpu)) cpu_invent->ic_gen.ig_flag = INVENT_ENABLED; else cpu_invent->ic_gen.ig_flag = 0x0; cpu_invent->ic_cpu_info.cpuflavor = cpu->cpu_prid; cpu_invent->ic_cpu_info.cpufq = cpu->cpu_speed; cpu_invent->ic_cpu_info.sdfreq = cpu->cpu_scachespeed; cpu_invent->ic_cpu_info.sdsize = cpu->cpu_scachesz; cpu_invent->ic_cpuid = cpu->cpu_info.virtid; cpu_invent->ic_slice = cpu_physical_id_to_slice(cpu->cpu_info.virtid); hwgraph_info_add_LBL(cpuv, INFO_LBL_DETAIL_INVENT, (arbitrary_info_t) cpu_invent); hwgraph_info_export_LBL(cpuv, INFO_LBL_DETAIL_INVENT, sizeof(invent_cpuinfo_t));}/* * Add information about the baseio prom version number * as a part of detailed inventory info in the hwgraph. */voidklhwg_baseio_inventory_add(vertex_hdl_t baseio_vhdl,cnodeid_t cnode){ invent_miscinfo_t *baseio_inventory; unsigned char version = 0,revision = 0; /* Allocate memory for the "detailed inventory" info * for the baseio */ baseio_inventory = (invent_miscinfo_t *) klhwg_invent_alloc(cnode, INV_PROM, sizeof(invent_miscinfo_t)); baseio_inventory->im_type = INV_IO6PROM; /* Store the revision info in the inventory */ baseio_inventory->im_version = version; baseio_inventory->im_rev = revision; /* Put the inventory info in the hardware graph */ hwgraph_info_add_LBL(baseio_vhdl, INFO_LBL_DETAIL_INVENT, (arbitrary_info_t) baseio_inventory); /* Make the information available to the user programs * thru hwgfs. */ hwgraph_info_export_LBL(baseio_vhdl, INFO_LBL_DETAIL_INVENT, sizeof(invent_miscinfo_t));}/* * Add detailed cpu inventory info to the hardware graph. */voidklhwg_hub_invent_info(vertex_hdl_t hubv, cnodeid_t cnode, klhub_t *hub){ invent_miscinfo_t *hub_invent; hub_invent = (invent_miscinfo_t *) klhwg_invent_alloc(cnode, INV_MISC, sizeof(invent_miscinfo_t)); if (!hub_invent) return; if (KLCONFIG_INFO_ENABLED((klinfo_t *)hub)) hub_invent->im_gen.ig_flag = INVENT_ENABLED; hub_invent->im_type = INV_HUB; hub_invent->im_rev = hub->hub_info.revision; hub_invent->im_speed = hub->hub_speed; hwgraph_info_add_LBL(hubv, INFO_LBL_DETAIL_INVENT, (arbitrary_info_t) hub_invent); hwgraph_info_export_LBL(hubv, INFO_LBL_DETAIL_INVENT, sizeof(invent_miscinfo_t));}/* ARGSUSED */voidklhwg_add_ice(vertex_hdl_t node_vertex, klhub_t *hub, cnodeid_t cnode){ vertex_hdl_t myicev; vertex_hdl_t ice_mon; int rc; extern struct file_operations shub_mon_fops; (void) hwgraph_path_add(node_vertex, EDGE_LBL_ICE, &myicev); HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, myicev, NULL, "Created path for ice vertex for TIO node.\n")); rc = device_master_set(myicev, node_vertex); if (rc) panic("klhwg_add_ice: Unable to create ice vertex.\n"); ice_mon = hwgraph_register(myicev, EDGE_LBL_PERFMON, 0, DEVFS_FL_AUTO_DEVNUM, 0, 0, S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, 0, 0, &shub_mon_fops, (void *)(long)cnode);}/* ARGSUSED */voidklhwg_add_hub(vertex_hdl_t node_vertex, klhub_t *hub, cnodeid_t cnode){ vertex_hdl_t myhubv; vertex_hdl_t hub_mon; int rc; extern struct file_operations shub_mon_fops; GRPRINTF(("klhwg_add_hub: adding %s\n", EDGE_LBL_HUB)); (void) hwgraph_path_add(node_vertex, EDGE_LBL_HUB, &myhubv); HWGRAPH_DEBUG((__FILE__, __FUNCTION__,__LINE__, myhubv, NULL, "Created path for hub vertex for Shub node.\n")); rc = device_master_set(myhubv, node_vertex); if (rc) panic("klhwg_add_hub: Unable to create hub vertex.\n"); hub_mon = hwgraph_register(myhubv, EDGE_LBL_PERFMON, 0, DEVFS_FL_AUTO_DEVNUM, 0, 0, S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, 0, 0, &shub_mon_fops, (void *)(long)cnode);}/* ARGSUSED */voidklhwg_add_disabled_cpu(vertex_hdl_t node_vertex, cnodeid_t cnode, klcpu_t *cpu, slotid_t slot){ vertex_hdl_t my_cpu; char name[120]; cpuid_t cpu_id; nasid_t nasid; nasid = COMPACT_TO_NASID_NODEID(cnode); cpu_id = nasid_slice_to_cpuid(nasid, cpu->cpu_info.physid); if(cpu_id != -1){ sprintf(name, "%s/%s/%c", EDGE_LBL_DISABLED, EDGE_LBL_CPU, 'a' + cpu->cpu_info.physid); (void) hwgraph_path_add(node_vertex, name, &my_cpu); HWGRAPH_DEBUG((__FILE__, __FUNCTION__,__LINE__, my_cpu, NULL, "Created path for disabled cpu slice.\n")); mark_cpuvertex_as_cpu(my_cpu, cpu_id); device_master_set(my_cpu, node_vertex); klhwg_disabled_cpu_invent_info(my_cpu, cnode, cpu, slot); return; }}/* ARGSUSED */voidklhwg_add_cpu(vertex_hdl_t node_vertex, cnodeid_t cnode, klcpu_t *cpu){ vertex_hdl_t my_cpu, cpu_dir; char name[120]; cpuid_t cpu_id; nasid_t nasid; nasid = COMPACT_TO_NASID_NODEID(cnode); cpu_id = nasid_slice_to_cpuid(nasid, cpu->cpu_info.physid); sprintf(name, "%s/%d/%c", EDGE_LBL_CPUBUS, 0, 'a' + cpu->cpu_info.physid); GRPRINTF(("klhwg_add_cpu: adding %s to vertex 0x%p\n", name, node_vertex)); (void) hwgraph_path_add(node_vertex, name, &my_cpu); HWGRAPH_DEBUG((__FILE__, __FUNCTION__,__LINE__, my_cpu, NULL, "Created path for active cpu slice.\n")); mark_cpuvertex_as_cpu(my_cpu, cpu_id); device_master_set(my_cpu, node_vertex); /* Add an alias under the node's CPU directory */ if (hwgraph_edge_get(node_vertex, EDGE_LBL_CPU, &cpu_dir) == GRAPH_SUCCESS) { sprintf(name, "%c", 'a' + cpu->cpu_info.physid); (void) hwgraph_edge_add(cpu_dir, my_cpu, name); HWGRAPH_DEBUG((__FILE__, __FUNCTION__,__LINE__, cpu_dir, my_cpu, "Created % from vhdl1 to vhdl2.\n", name)); } klhwg_cpu_invent_info(my_cpu, cnode, cpu);}voidklhwg_add_coretalk(cnodeid_t cnode, nasid_t tio_nasid){ lboard_t *brd; vertex_hdl_t coretalk_v, icev; /*REFERENCED*/ graph_error_t err; if ((brd = find_lboard((lboard_t *)KL_CONFIG_INFO(tio_nasid), KLTYPE_IOBRICK_XBOW)) == NULL) return; if (KL_CONFIG_DUPLICATE_BOARD(brd)) return; icev = cnodeid_to_vertex(cnode); err = hwgraph_path_add(icev, EDGE_LBL_CORETALK, &coretalk_v); if (err != GRAPH_SUCCESS) { if (err == GRAPH_DUP) printk(KERN_WARNING "klhwg_add_coretalk: Check for " "working routers and router links!"); panic("klhwg_add_coretalkk: Failed to add " "edge: vertex 0x%p to vertex 0x%p," "error %d\n", (void *)icev, (void *)coretalk_v, err); } HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, coretalk_v, NULL, "Created coretalk path for TIO node.\n")); NODEPDA(cnode)->xbow_vhdl = coretalk_v;}voidklhwg_add_xbow(cnodeid_t cnode, nasid_t nasid){ lboard_t *brd; klxbow_t *xbow_p; nasid_t hub_nasid; cnodeid_t hub_cnode; int widgetnum; vertex_hdl_t xbow_v, hubv; /*REFERENCED*/ graph_error_t err; if ((brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_IOBRICK_XBOW)) == NULL) return; if (KL_CONFIG_DUPLICATE_BOARD(brd)) return; if ((xbow_p = (klxbow_t *)find_component(brd, NULL, KLSTRUCT_XBOW)) == NULL) return; for (widgetnum = HUB_WIDGET_ID_MIN; widgetnum <= HUB_WIDGET_ID_MAX; widgetnum++) { if (!XBOW_PORT_TYPE_HUB(xbow_p, widgetnum)) continue; hub_nasid = XBOW_PORT_NASID(xbow_p, widgetnum); if (hub_nasid == INVALID_NASID) { printk(KERN_WARNING "hub widget %d, skipping xbow graph\n", widgetnum); continue; } hub_cnode = NASID_TO_COMPACT_NODEID(hub_nasid); if (is_specified(arg_maxnodes) && hub_cnode == INVALID_CNODEID) { continue; } hubv = cnodeid_to_vertex(hub_cnode); err = hwgraph_path_add(hubv, EDGE_LBL_XTALK, &xbow_v); if (err != GRAPH_SUCCESS) { if (err == GRAPH_DUP) printk(KERN_WARNING "klhwg_add_xbow: Check for " "working routers and router links!"); panic("klhwg_add_xbow: Failed to add " "edge: vertex 0x%p to vertex 0x%p," "error %d\n", (void *)hubv, (void *)xbow_v, err); } HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, xbow_v, NULL, "Created path for xtalk.\n")); xswitch_vertex_init(xbow_v); NODEPDA(hub_cnode)->xbow_vhdl = xbow_v; /* * XXX - This won't work is we ever hook up two hubs * by crosstown through a crossbow. */ if (hub_nasid != nasid) { NODEPDA(hub_cnode)->xbow_peer = nasid; NODEPDA(NASID_TO_COMPACT_NODEID(nasid))->xbow_peer = hub_nasid; } }}/* ARGSUSED */voidklhwg_add_tionode(vertex_hdl_t hwgraph_root, cnodeid_t cnode){ nasid_t tio_nasid; lboard_t *brd; klhub_t *hub; vertex_hdl_t node_vertex = NULL; char path_buffer[100]; int rv; char *s; int board_disabled = 0; tio_nasid = COMPACT_TO_NASID_NODEID(cnode); brd = find_lboard((lboard_t *)KL_CONFIG_INFO(tio_nasid), KLTYPE_TIO); ASSERT(brd); /* Generate a hardware graph path for this board. */ board_to_path(brd, path_buffer); rv = hwgraph_path_add(hwgraph_root, path_buffer, &node_vertex); if (rv != GRAPH_SUCCESS) panic("TIO Node vertex creation failed. " "Path == %s", path_buffer); HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, node_vertex, NULL, "Created path for TIO node.\n")); 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 * numionodes); s = dev_to_name(node_vertex, path_buffer, sizeof(path_buffer)); 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)->geoid = brd->brd_geoid; NODEPDA(cnode)->module = module_lookup(geo_module(brd->brd_geoid)); } if(!board_disabled) klhwg_add_ice(node_vertex, hub, cnode);}/* ARGSUSED */voidklhwg_add_node(vertex_hdl_t hwgraph_root, cnodeid_t cnode){ nasid_t nasid; lboard_t *brd;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -