blob: 2115ad5d6f1947a18185a59742293a52aab2a7a5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * include/linux/node.h - generic node definition
3 *
4 * This is mainly for topological representation. We define the
5 * basic 'struct node' here, which can be embedded in per-arch
6 * definitions of processors.
7 *
8 * Basic handling of the devices is done in drivers/base/node.c
9 * and system devices are handled in drivers/base/sys.c.
10 *
11 * Nodes are exported via driverfs in the class/node/devices/
12 * directory.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 */
14#ifndef _LINUX_NODE_H_
15#define _LINUX_NODE_H_
16
Kay Sievers10fbcf42011-12-21 14:48:43 -080017#include <linux/device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/cpumask.h>
Lee Schermerhorn39da08c2009-12-14 17:58:36 -080019#include <linux/workqueue.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21struct node {
Kay Sievers10fbcf42011-12-21 14:48:43 -080022 struct device dev;
Lee Schermerhorn39da08c2009-12-14 17:58:36 -080023
24#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
25 struct work_struct node_work;
26#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070027};
28
Gary Hadec04fc582009-01-06 14:39:14 -080029struct memory_block;
Wen Congyang87327942012-12-11 16:00:56 -080030extern struct node *node_devices[];
Lee Schermerhorn9a305232009-12-14 17:58:25 -080031typedef void (*node_registration_func_t)(struct node *);
Yasunori Goto0fc44152006-06-27 02:53:38 -070032
Keiichiro Tokunaga4b450992005-05-08 21:28:53 +090033extern void unregister_node(struct node *node);
KAMEZAWA Hiroyuki36920e02006-08-27 01:23:52 -070034#ifdef CONFIG_NUMA
Yasunori Goto0fc44152006-06-27 02:53:38 -070035extern int register_one_node(int nid);
36extern void unregister_one_node(int nid);
KAMEZAWA Hiroyuki76b67ed2006-06-27 02:53:41 -070037extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
38extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
Gary Hadec04fc582009-01-06 14:39:14 -080039extern int register_mem_sect_under_node(struct memory_block *mem_blk,
40 int nid);
Nathan Fontenotd3360162011-01-20 10:44:29 -060041extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
42 unsigned long phys_index);
Lee Schermerhorn9a305232009-12-14 17:58:25 -080043
44#ifdef CONFIG_HUGETLBFS
45extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
46 node_registration_func_t unregister);
47#endif
KAMEZAWA Hiroyuki76b67ed2006-06-27 02:53:41 -070048#else
KAMEZAWA Hiroyuki36920e02006-08-27 01:23:52 -070049static inline int register_one_node(int nid)
50{
51 return 0;
52}
53static inline int unregister_one_node(int nid)
54{
55 return 0;
56}
KAMEZAWA Hiroyuki76b67ed2006-06-27 02:53:41 -070057static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
58{
59 return 0;
60}
61static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
62{
63 return 0;
64}
Gary Hadec04fc582009-01-06 14:39:14 -080065static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
66 int nid)
67{
68 return 0;
69}
Nathan Fontenotd3360162011-01-20 10:44:29 -060070static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
71 unsigned long phys_index)
Gary Hadec04fc582009-01-06 14:39:14 -080072{
73 return 0;
74}
Lee Schermerhorn9a305232009-12-14 17:58:25 -080075
76static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
77 node_registration_func_t unreg)
78{
79}
KAMEZAWA Hiroyuki76b67ed2006-06-27 02:53:41 -070080#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
Kay Sievers10fbcf42011-12-21 14:48:43 -080082#define to_node(device) container_of(device, struct node, dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
84#endif /* _LINUX_NODE_H_ */