Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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. |
| 13 | * |
| 14 | * Per-node interfaces can be implemented using a struct device_interface. |
| 15 | * See the following for how to do this: |
| 16 | * - drivers/base/intf.c |
| 17 | * - Documentation/driver-model/interface.txt |
| 18 | */ |
| 19 | #ifndef _LINUX_NODE_H_ |
| 20 | #define _LINUX_NODE_H_ |
| 21 | |
| 22 | #include <linux/sysdev.h> |
| 23 | #include <linux/cpumask.h> |
Lee Schermerhorn | 39da08c | 2009-12-14 17:58:36 -0800 | [diff] [blame] | 24 | #include <linux/workqueue.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | struct node { |
| 27 | struct sys_device sysdev; |
Lee Schermerhorn | 39da08c | 2009-12-14 17:58:36 -0800 | [diff] [blame] | 28 | |
| 29 | #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS) |
| 30 | struct work_struct node_work; |
| 31 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | }; |
| 33 | |
Gary Hade | c04fc58 | 2009-01-06 14:39:14 -0800 | [diff] [blame] | 34 | struct memory_block; |
Yasunori Goto | 0fc4415 | 2006-06-27 02:53:38 -0700 | [diff] [blame] | 35 | extern struct node node_devices[]; |
Lee Schermerhorn | 9a30523 | 2009-12-14 17:58:25 -0800 | [diff] [blame] | 36 | typedef void (*node_registration_func_t)(struct node *); |
Yasunori Goto | 0fc4415 | 2006-06-27 02:53:38 -0700 | [diff] [blame] | 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | extern int register_node(struct node *, int, struct node *); |
Keiichiro Tokunaga | 4b45099 | 2005-05-08 21:28:53 +0900 | [diff] [blame] | 39 | extern void unregister_node(struct node *node); |
KAMEZAWA Hiroyuki | 36920e0 | 2006-08-27 01:23:52 -0700 | [diff] [blame] | 40 | #ifdef CONFIG_NUMA |
Yasunori Goto | 0fc4415 | 2006-06-27 02:53:38 -0700 | [diff] [blame] | 41 | extern int register_one_node(int nid); |
| 42 | extern void unregister_one_node(int nid); |
KAMEZAWA Hiroyuki | 76b67ed | 2006-06-27 02:53:41 -0700 | [diff] [blame] | 43 | extern int register_cpu_under_node(unsigned int cpu, unsigned int nid); |
| 44 | extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid); |
Gary Hade | c04fc58 | 2009-01-06 14:39:14 -0800 | [diff] [blame] | 45 | extern int register_mem_sect_under_node(struct memory_block *mem_blk, |
| 46 | int nid); |
| 47 | extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk); |
Lee Schermerhorn | 9a30523 | 2009-12-14 17:58:25 -0800 | [diff] [blame] | 48 | |
| 49 | #ifdef CONFIG_HUGETLBFS |
| 50 | extern void register_hugetlbfs_with_node(node_registration_func_t doregister, |
| 51 | node_registration_func_t unregister); |
| 52 | #endif |
KAMEZAWA Hiroyuki | 76b67ed | 2006-06-27 02:53:41 -0700 | [diff] [blame] | 53 | #else |
KAMEZAWA Hiroyuki | 36920e0 | 2006-08-27 01:23:52 -0700 | [diff] [blame] | 54 | static inline int register_one_node(int nid) |
| 55 | { |
| 56 | return 0; |
| 57 | } |
| 58 | static inline int unregister_one_node(int nid) |
| 59 | { |
| 60 | return 0; |
| 61 | } |
KAMEZAWA Hiroyuki | 76b67ed | 2006-06-27 02:53:41 -0700 | [diff] [blame] | 62 | static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid) |
| 63 | { |
| 64 | return 0; |
| 65 | } |
| 66 | static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) |
| 67 | { |
| 68 | return 0; |
| 69 | } |
Gary Hade | c04fc58 | 2009-01-06 14:39:14 -0800 | [diff] [blame] | 70 | static inline int register_mem_sect_under_node(struct memory_block *mem_blk, |
| 71 | int nid) |
| 72 | { |
| 73 | return 0; |
| 74 | } |
| 75 | static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk) |
| 76 | { |
| 77 | return 0; |
| 78 | } |
Lee Schermerhorn | 9a30523 | 2009-12-14 17:58:25 -0800 | [diff] [blame] | 79 | |
| 80 | static inline void register_hugetlbfs_with_node(node_registration_func_t reg, |
| 81 | node_registration_func_t unreg) |
| 82 | { |
| 83 | } |
KAMEZAWA Hiroyuki | 76b67ed | 2006-06-27 02:53:41 -0700 | [diff] [blame] | 84 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
| 86 | #define to_node(sys_device) container_of(sys_device, struct node, sysdev) |
| 87 | |
| 88 | #endif /* _LINUX_NODE_H_ */ |