xref: /titanic_52/usr/src/uts/sun4v/sys/drctl.h (revision 2f172c55ef76964744bc62b4500ece87f3089b4d)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_DRCTL_H
28 #define	_SYS_DRCTL_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 
35 #define	DRCTL_DEV "/devices/pseudo/drctl@0:drctl"
36 
37 typedef enum {
38 	DRCTL_CPU_CONFIG_REQUEST = 1,
39 	DRCTL_CPU_CONFIG_NOTIFY,
40 	DRCTL_CPU_UNCONFIG_REQUEST,
41 	DRCTL_CPU_UNCONFIG_NOTIFY,
42 	DRCTL_MEM_CONFIG_REQUEST,
43 	DRCTL_MEM_CONFIG_NOTIFY,
44 	DRCTL_MEM_UNCONFIG_REQUEST,
45 	DRCTL_MEM_UNCONFIG_NOTIFY,
46 	DRCTL_IO_CONFIG_REQUEST,
47 	DRCTL_IO_CONFIG_NOTIFY,
48 	DRCTL_IO_UNCONFIG_REQUEST,
49 	DRCTL_IO_UNCONFIG_NOTIFY,
50 	DRCTL_DRC_BLOCK
51 } drctl_cmds_t;
52 
53 /*
54  * Responses to/from the daemon for a reconfig request.
55  */
56 typedef enum {
57 	DRCTL_STATUS_INIT,		/* to daemon */
58 	DRCTL_STATUS_ALLOW,		/* from daemon */
59 	DRCTL_STATUS_DENY,		/* from daemon */
60 	DRCTL_STATUS_CONFIG_SUCCESS,	/* to daemon */
61 	DRCTL_STATUS_CONFIG_FAILURE	/* to daemon */
62 } drctl_status_t;
63 
64 /*
65  * Each resource descriptor consists of a common header
66  * followed by a resource-specific structure.
67  */
68 
69 typedef struct drctl_rsrc_cpu {
70 	int		id;
71 } drctl_rsrc_cpu_t;
72 
73 typedef struct drctl_rsrc_memory {
74 	uint64_t	size;
75 	uint64_t	addr;
76 } drctl_rsrc_mem_t;
77 
78 typedef struct drctl_rsrc_dev {
79 	char		path[1];
80 } drctl_rsrc_dev_t;
81 
82 typedef struct drctl_rsrc {
83 	drctl_status_t	status;
84 	uint64_t	offset;
85 	union {
86 		drctl_rsrc_cpu_t cpu;
87 		drctl_rsrc_mem_t mem;
88 		drctl_rsrc_dev_t dev;
89 	} un;
90 } drctl_rsrc_t;
91 
92 #define	res_cpu_id	un.cpu.id
93 #define	res_mem_size	un.mem.size
94 #define	res_mem_addr	un.mem.addr
95 #define	res_dev_path	un.dev.path
96 
97 /*
98  * Response structure passed back by drctl to its clients
99  * (resource-specific DR modules).
100  */
101 typedef enum {
102 	DRCTL_RESP_ERR,
103 	DRCTL_RESP_OK
104 } drctl_resp_type_t;
105 
106 typedef struct drctl_resp {
107 	drctl_resp_type_t resp_type;
108 	union {
109 		char err_msg[1];
110 		drctl_rsrc_t  resources[1];
111 	} un;
112 } drctl_resp_t;
113 
114 #define	resp_err_msg		un.err_msg
115 #define	resp_resources		un.resources
116 
117 /*
118  * Message sent to DR daemon
119  */
120 typedef struct drd_msg {
121 	uint_t		cmd;
122 	uint_t		count;
123 	int		flags;
124 	drctl_rsrc_t	data[1];
125 } drd_msg_t;
126 
127 typedef void *drctl_cookie_t;
128 
129 /*
130  * DR RSMs (resource-specific modules) call these functions to
131  * initialize or finalize a DR request.  A request may include
132  * multiple resources of the same type.  The _init call returns
133  * a cookie which must be supplied on by the corresponding
134  * _fini call.
135  */
136 extern int drctl_config_init(int, int,
137     drctl_rsrc_t *, int, drctl_resp_t **, size_t *, drctl_cookie_t);
138 extern int drctl_config_fini(drctl_cookie_t, drctl_rsrc_t *, int);
139 extern void drctl_block(void);
140 extern void drctl_unblock(void);
141 
142 /*
143  * Values for the 2nd arg (flags) of drctl_config_init
144  */
145 #define	DRCTL_FLAG_FORCE 1
146 
147 
148 #ifdef	__cplusplus
149 }
150 #endif
151 
152 #endif	/* _SYS_DRCTL_H */
153