xref: /illumos-gate/usr/src/uts/sun4v/sys/drctl.h (revision 533affcbc7fc4d0c8132976ea454aaa715fe2307)
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 (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef _SYS_DRCTL_H
27 #define	_SYS_DRCTL_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 
34 #define	DRCTL_DEV "/devices/pseudo/drctl@0:drctl"
35 
36 typedef enum {
37 	DRCTL_CPU_CONFIG_REQUEST = 1,
38 	DRCTL_CPU_CONFIG_NOTIFY,
39 	DRCTL_CPU_UNCONFIG_REQUEST,
40 	DRCTL_CPU_UNCONFIG_NOTIFY,
41 	DRCTL_MEM_CONFIG_REQUEST,
42 	DRCTL_MEM_CONFIG_NOTIFY,
43 	DRCTL_MEM_UNCONFIG_REQUEST,
44 	DRCTL_MEM_UNCONFIG_NOTIFY,
45 	DRCTL_IO_CONFIG_REQUEST,
46 	DRCTL_IO_CONFIG_NOTIFY,
47 	DRCTL_IO_UNCONFIG_REQUEST,
48 	DRCTL_IO_UNCONFIG_NOTIFY,
49 	DRCTL_DRC_BLOCK
50 } drctl_cmds_t;
51 
52 /*
53  * Responses to/from the daemon for a reconfig request.
54  */
55 typedef enum {
56 	DRCTL_STATUS_INIT,		/* to daemon */
57 	DRCTL_STATUS_ALLOW,		/* from daemon */
58 	DRCTL_STATUS_DENY,		/* from daemon */
59 	DRCTL_STATUS_CONFIG_SUCCESS,	/* to daemon */
60 	DRCTL_STATUS_CONFIG_FAILURE	/* to daemon */
61 } drctl_status_t;
62 
63 /*
64  * Each resource descriptor consists of a common header
65  * followed by a resource-specific structure.
66  */
67 
68 typedef struct drctl_rsrc_cpu {
69 	int		id;
70 } drctl_rsrc_cpu_t;
71 
72 typedef struct drctl_rsrc_memory {
73 	uint64_t	size;
74 	uint64_t	addr;
75 } drctl_rsrc_mem_t;
76 
77 typedef struct drctl_rsrc_dev {
78 	char		path[1];
79 } drctl_rsrc_dev_t;
80 
81 typedef struct drctl_rsrc {
82 	drctl_status_t	status;
83 	uint64_t	offset;
84 	union {
85 		drctl_rsrc_cpu_t cpu;
86 		drctl_rsrc_mem_t mem;
87 		drctl_rsrc_dev_t dev;
88 	} un;
89 } drctl_rsrc_t;
90 
91 #define	res_cpu_id	un.cpu.id
92 #define	res_mem_size	un.mem.size
93 #define	res_mem_addr	un.mem.addr
94 #define	res_dev_path	un.dev.path
95 
96 /*
97  * Response structure passed back by drctl to its clients
98  * (resource-specific DR modules).
99  */
100 typedef enum {
101 	DRCTL_RESP_ERR,
102 	DRCTL_RESP_OK
103 } drctl_resp_type_t;
104 
105 typedef struct drctl_resp {
106 	drctl_resp_type_t resp_type;
107 	union {
108 		char err_msg[1];
109 		drctl_rsrc_t  resources[1];
110 	} un;
111 } drctl_resp_t;
112 
113 #define	resp_err_msg		un.err_msg
114 #define	resp_resources		un.resources
115 
116 /*
117  * Message sent to DR daemon
118  */
119 typedef struct drd_msg {
120 	uint_t		cmd;
121 	uint_t		count;
122 	int		flags;
123 	drctl_rsrc_t	data[1];
124 } drd_msg_t;
125 
126 typedef void *drctl_cookie_t;
127 
128 /*
129  * DR RSMs (resource-specific modules) call these functions to
130  * initialize or finalize a DR request.  A request may include
131  * multiple resources of the same type.  The _init call returns
132  * a cookie which must be supplied on by the corresponding
133  * _fini call.
134  */
135 extern int drctl_config_init(int, int,
136     drctl_rsrc_t *, int, drctl_resp_t **, size_t *, drctl_cookie_t);
137 extern int drctl_config_fini(drctl_cookie_t, drctl_rsrc_t *, int);
138 extern void drctl_block(void);
139 extern int drctl_tryblock(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