⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 klgraph.c

📁 linux-2.4.29操作系统的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	klhub_t *hub;	vertex_hdl_t node_vertex = NULL;	char path_buffer[100];	int rv;	char *s;	int board_disabled = 0;	klcpu_t *cpu;	nasid = COMPACT_TO_NASID_NODEID(cnode);	brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_SNIA);	ASSERT(brd);	do {		vertex_hdl_t cpu_dir;		/* 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("Node vertex creation failed.  Path == %s", path_buffer);		HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, node_vertex, NULL, "Created path for SHUB 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 * numnodes);			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));		}		/* Get the first CPU structure */		cpu = (klcpu_t *)find_first_component(brd, KLSTRUCT_CPU);		/*		* If there's at least 1 CPU, add a "cpu" directory to represent		* the collection of all CPUs attached to this node.		*/		if (cpu) {			graph_error_t rv;			rv = hwgraph_path_add(node_vertex, EDGE_LBL_CPU, &cpu_dir);			if (rv != GRAPH_SUCCESS)				panic("klhwg_add_node: Cannot create CPU directory\n");			HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, cpu_dir, NULL, "Created cpu directiry on SHUB node.\n"));		}		/* Add each CPU */		while (cpu) {			cpuid_t cpu_id;			cpu_id = nasid_slice_to_cpuid(nasid,cpu->cpu_info.physid);			if (cpu_online(cpu_id))				klhwg_add_cpu(node_vertex, cnode, cpu);			else				klhwg_add_disabled_cpu(node_vertex, cnode, cpu, brd->brd_slot);			cpu = (klcpu_t *)				find_component(brd, (klinfo_t *)cpu, KLSTRUCT_CPU);		} /* while */		if(!board_disabled)			klhwg_add_hub(node_vertex, hub, cnode);				brd = KLCF_NEXT(brd);		if (brd)			brd = find_lboard(brd, KLTYPE_SNIA);		else			break;	} while(brd);}/* ARGSUSED */voidklhwg_add_all_routers(vertex_hdl_t hwgraph_root){	nasid_t nasid;	cnodeid_t cnode;	lboard_t *brd;	vertex_hdl_t node_vertex;	char path_buffer[100];	int rv;	for (cnode = 0; cnode < numnodes; cnode++) {		nasid = COMPACT_TO_NASID_NODEID(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);			/* Don't add duplicate boards. */			if (brd->brd_flags & DUPLICATE_BOARD)				continue;			/* Generate a hardware graph path for this board. */			board_to_path(brd, path_buffer);			/* Add the router */			rv = hwgraph_path_add(hwgraph_root, path_buffer, &node_vertex);			if (rv != GRAPH_SUCCESS)				panic("Router vertex creation "						  "failed.  Path == %s",					path_buffer);			HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, node_vertex, NULL, "Created router path.\n"));		/* Find the rest of the routers stored on this node. */		} while ( (brd = find_lboard_class(KLCF_NEXT(brd),			 KLTYPE_ROUTER)) );	}}/* ARGSUSED */voidklhwg_connect_one_router(vertex_hdl_t hwgraph_root, lboard_t *brd,			 cnodeid_t cnode, nasid_t nasid){	klrou_t *router;	char path_buffer[50];	char dest_path[50];	vertex_hdl_t router_hndl;	vertex_hdl_t dest_hndl;	int rc;	int port;	lboard_t *dest_brd;	/* Don't add duplicate boards. */	if (brd->brd_flags & DUPLICATE_BOARD) {		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)		printk(KERN_WARNING  "Can't find router: %s", path_buffer);	/* We don't know what to do with multiple router components */	if (brd->brd_numcompts != 1) {		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;			panic("Can't find router: %s", 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))			panic("Can't create edge: %s/%s to vertex 0x%p error 0x%x\n",				path_buffer, dest_path, (void *)dest_hndl, rc);		HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, router_hndl, dest_hndl, "Created edge %s from vhdl1 to vhdl2.\n", dest_path));			}}voidklhwg_connect_routers(vertex_hdl_t hwgraph_root){	nasid_t nasid;	cnodeid_t cnode;	lboard_t *brd;	for (cnode = 0; cnode < numnodes; 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(vertex_hdl_t hwgraph_root){	nasid_t nasid;	cnodeid_t cnode;	lboard_t *brd;	klhub_t *hub;	lboard_t *dest_brd;	vertex_hdl_t hub_hndl;	vertex_hdl_t dest_hndl;	char path_buffer[50];	char dest_path[50];	graph_error_t rc;	int port;	for (cnode = 0; cnode < numionodes; cnode++) {		nasid = COMPACT_TO_NASID_NODEID(cnode);		if (!(nasid & 1)) {			brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_SNIA);			ASSERT(brd);		} else {			brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_TIO);			ASSERT(brd);		}		hub = (klhub_t *)find_first_component(brd, KLSTRUCT_HUB);		ASSERT(hub);		for (port = 1; port <= MAX_NI_PORTS; port++) {			/* See if the port's active */			if (hub->hub_port[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].port_nasid) == INVALID_CNODEID)				continue;			/* Generate a hardware graph path for this board. */			board_to_path(brd, path_buffer);			rc = hwgraph_traverse(hwgraph_root, path_buffer, &hub_hndl);			if (rc != GRAPH_SUCCESS)				printk(KERN_WARNING  "Can't find hub: %s", path_buffer);			dest_brd = (lboard_t *)NODE_OFFSET_TO_K0(					hub->hub_port[port].port_nasid,					hub->hub_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;				panic("Can't find board: %s", dest_path);			} else {				char buf[1024];						GRPRINTF(("klhwg_connect_hubs: Link from %s to %s.\n",			  	path_buffer, dest_path));				rc = hwgraph_path_add(hub_hndl, EDGE_LBL_INTERCONNECT, &hub_hndl);				HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, hub_hndl, NULL, "Created link path.\n"));				sprintf(buf,"%s/%s",path_buffer,EDGE_LBL_INTERCONNECT);				rc = hwgraph_traverse(hwgraph_root, buf, &hub_hndl);				sprintf(buf,"%d",port);				rc = hwgraph_edge_add(hub_hndl, dest_hndl, buf);				HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, hub_hndl, dest_hndl, "Created edge %s from vhdl1 to vhdl2.\n", buf));				if (rc != GRAPH_SUCCESS)					panic("Can't create edge: %s/%s to vertex 0x%p, error 0x%x\n",					path_buffer, dest_path, (void *)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];		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);#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(vertex_hdl_t hwgraph_root){	cmoduleid_t	cm;	char		name[128];	vertex_hdl_t	vhdl;	vertex_hdl_t  module_vhdl;	int		rc;	char		buffer[16];	/* Add devices under each module */	for (cm = 0; cm < nummodules; cm++) {		/* Use module as module vertex fastinfo */		memset(buffer, 0, 16);		format_module_id(buffer, modules[cm]->id, MODULE_FORMAT_BRIEF);		sprintf(name, EDGE_LBL_MODULE "/%s", buffer);		rc = hwgraph_path_add(hwgraph_root, name, &module_vhdl);		ASSERT(rc == GRAPH_SUCCESS);		rc = rc; /* Shut the compiler up */		HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, module_vhdl, NULL, "Created module path.\n"));		hwgraph_fastinfo_set(module_vhdl, (arbitrary_info_t) modules[cm]);		/* Add system controller */		sprintf(name,			EDGE_LBL_MODULE "/%s/" EDGE_LBL_L1,			buffer);		rc = hwgraph_path_add(hwgraph_root, name, &vhdl);		ASSERT_ALWAYS(rc == GRAPH_SUCCESS);		rc = rc; /* Shut the compiler up */		HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, vhdl, NULL, "Created L1 path.\n"));		hwgraph_info_add_LBL(vhdl,				     INFO_LBL_ELSC,				     (arbitrary_info_t) (int64_t) 1);	}}voidklhwg_add_all_nodes(vertex_hdl_t hwgraph_root){	cnodeid_t	cnode;	for (cnode = 0; cnode < numnodes; cnode++) {		klhwg_add_node(hwgraph_root, cnode);	}	for (cnode = numnodes; cnode < numionodes; cnode++) {		klhwg_add_tionode(hwgraph_root, cnode);	}	for (cnode = 0; cnode < numnodes; cnode++) {		klhwg_add_xbow(cnode, cnodeid_to_nasid(cnode));	}	for (cnode = numnodes; cnode < numionodes; cnode++) {		klhwg_add_coretalk(cnode, cnodeid_to_nasid(cnode));	}	/*	 * 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);	/* 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 + -