blob: e8a4c413a1c76d48aece57e8c79043c3a7e85f92 [file] [log] [blame]
Sam Ravnborga00736e2008-06-19 20:26:19 +02001#ifndef _SPARC64_MDESC_H
2#define _SPARC64_MDESC_H
3
4#include <linux/types.h>
5#include <linux/cpumask.h>
6#include <asm/prom.h>
7
8struct mdesc_handle;
9
10/* Machine description operations are to be surrounded by grab and
11 * release calls. The mdesc_handle returned from the grab is
12 * the first argument to all of the operational calls that work
13 * on mdescs.
14 */
Sam Ravnborgf05a6862014-05-16 23:25:50 +020015struct mdesc_handle *mdesc_grab(void);
16void mdesc_release(struct mdesc_handle *);
Sam Ravnborga00736e2008-06-19 20:26:19 +020017
18#define MDESC_NODE_NULL (~(u64)0)
Jag Raman411cb4a2017-06-23 14:58:32 -040019#define MDESC_MAX_STR_LEN 256
Sam Ravnborga00736e2008-06-19 20:26:19 +020020
Sam Ravnborgf05a6862014-05-16 23:25:50 +020021u64 mdesc_node_by_name(struct mdesc_handle *handle,
22 u64 from_node, const char *name);
Sam Ravnborga00736e2008-06-19 20:26:19 +020023#define mdesc_for_each_node_by_name(__hdl, __node, __name) \
24 for (__node = mdesc_node_by_name(__hdl, MDESC_NODE_NULL, __name); \
25 (__node) != MDESC_NODE_NULL; \
26 __node = mdesc_node_by_name(__hdl, __node, __name))
27
28/* Access to property values returned from mdesc_get_property() are
29 * only valid inside of a mdesc_grab()/mdesc_release() sequence.
30 * Once mdesc_release() is called, the memory backed up by these
31 * pointers may reference freed up memory.
32 *
33 * Therefore callers must make copies of any property values
34 * they need.
35 *
36 * These same rules apply to mdesc_node_name().
37 */
Sam Ravnborgf05a6862014-05-16 23:25:50 +020038const void *mdesc_get_property(struct mdesc_handle *handle,
39 u64 node, const char *name, int *lenp);
40const char *mdesc_node_name(struct mdesc_handle *hp, u64 node);
Sam Ravnborga00736e2008-06-19 20:26:19 +020041
42/* MD arc iteration, the standard sequence is:
43 *
44 * unsigned long arc;
45 * mdesc_for_each_arc(arc, handle, node, MDESC_ARC_TYPE_{FWD,BACK}) {
46 * unsigned long target = mdesc_arc_target(handle, arc);
47 * ...
48 * }
49 */
50
51#define MDESC_ARC_TYPE_FWD "fwd"
52#define MDESC_ARC_TYPE_BACK "back"
53
Sam Ravnborgf05a6862014-05-16 23:25:50 +020054u64 mdesc_next_arc(struct mdesc_handle *handle, u64 from,
55 const char *arc_type);
Sam Ravnborga00736e2008-06-19 20:26:19 +020056#define mdesc_for_each_arc(__arc, __hdl, __node, __type) \
57 for (__arc = mdesc_next_arc(__hdl, __node, __type); \
58 (__arc) != MDESC_NODE_NULL; \
59 __arc = mdesc_next_arc(__hdl, __arc, __type))
60
Sam Ravnborgf05a6862014-05-16 23:25:50 +020061u64 mdesc_arc_target(struct mdesc_handle *hp, u64 arc);
Sam Ravnborga00736e2008-06-19 20:26:19 +020062
Sam Ravnborgf05a6862014-05-16 23:25:50 +020063void mdesc_update(void);
Sam Ravnborga00736e2008-06-19 20:26:19 +020064
65struct mdesc_notifier_client {
Jag Raman06f3c3a2017-06-23 14:58:34 -040066 void (*add)(struct mdesc_handle *handle, u64 node,
67 const char *node_name);
68 void (*remove)(struct mdesc_handle *handle, u64 node,
69 const char *node_name);
Sam Ravnborga00736e2008-06-19 20:26:19 +020070 const char *node_name;
71 struct mdesc_notifier_client *next;
72};
73
Sam Ravnborgf05a6862014-05-16 23:25:50 +020074void mdesc_register_notifier(struct mdesc_notifier_client *client);
Sam Ravnborga00736e2008-06-19 20:26:19 +020075
Jag Raman411cb4a2017-06-23 14:58:32 -040076union md_node_info {
77 struct vdev_port {
78 u64 id; /* id */
79 u64 parent_cfg_hdl; /* parent config handle */
80 const char *name; /* name (property) */
81 } vdev_port;
82 struct ds_port {
83 u64 id; /* id */
84 } ds_port;
85};
86
87u64 mdesc_get_node(struct mdesc_handle *hp, const char *node_name,
88 union md_node_info *node_info);
89int mdesc_get_node_info(struct mdesc_handle *hp, u64 node,
90 const char *node_name, union md_node_info *node_info);
91
Sam Ravnborgf05a6862014-05-16 23:25:50 +020092void mdesc_fill_in_cpu_data(cpumask_t *mask);
93void mdesc_populate_present_mask(cpumask_t *mask);
94void mdesc_get_page_sizes(cpumask_t *mask, unsigned long *pgsz_mask);
Sam Ravnborga00736e2008-06-19 20:26:19 +020095
Sam Ravnborgf05a6862014-05-16 23:25:50 +020096void sun4v_mdesc_init(void);
Sam Ravnborga00736e2008-06-19 20:26:19 +020097
98#endif