node.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #include <linux/sysdev.h>
  22. #include <linux/cpumask.h>
  23. struct node {
  24. struct sys_device sysdev;
  25. };
  26. struct memory_block;
  27. extern struct node node_devices[];
  28. typedef void (*node_registration_func_t)(struct node *);
  29. extern int register_node(struct node *, int, struct node *);
  30. extern void unregister_node(struct node *node);
  31. #ifdef CONFIG_NUMA
  32. extern int register_one_node(int nid);
  33. extern void unregister_one_node(int nid);
  34. extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
  35. extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
  36. extern int register_mem_sect_under_node(struct memory_block *mem_blk,
  37. int nid);
  38. extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk);
  39. #ifdef CONFIG_HUGETLBFS
  40. extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
  41. node_registration_func_t unregister);
  42. #endif
  43. #else
  44. static inline int register_one_node(int nid)
  45. {
  46. return 0;
  47. }
  48. static inline int unregister_one_node(int nid)
  49. {
  50. return 0;
  51. }
  52. static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
  53. {
  54. return 0;
  55. }
  56. static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
  57. {
  58. return 0;
  59. }
  60. static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
  61. int nid)
  62. {
  63. return 0;
  64. }
  65. static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk)
  66. {
  67. return 0;
  68. }
  69. static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
  70. node_registration_func_t unreg)
  71. {
  72. }
  73. #endif
  74. #define to_node(sys_device) container_of(sys_device, struct node, sysdev)
  75. #endif /* _LINUX_NODE_H_ */