xref: /titanic_53/usr/src/uts/sun4v/sys/drctl.h (revision af4c679f647cf088543c762e33d41a3ac52cfa14)
11d4b38e0Srsmaeda /*
21d4b38e0Srsmaeda  * CDDL HEADER START
31d4b38e0Srsmaeda  *
41d4b38e0Srsmaeda  * The contents of this file are subject to the terms of the
51d4b38e0Srsmaeda  * Common Development and Distribution License (the "License").
61d4b38e0Srsmaeda  * You may not use this file except in compliance with the License.
71d4b38e0Srsmaeda  *
81d4b38e0Srsmaeda  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91d4b38e0Srsmaeda  * or http://www.opensolaris.org/os/licensing.
101d4b38e0Srsmaeda  * See the License for the specific language governing permissions
111d4b38e0Srsmaeda  * and limitations under the License.
121d4b38e0Srsmaeda  *
131d4b38e0Srsmaeda  * When distributing Covered Code, include this CDDL HEADER in each
141d4b38e0Srsmaeda  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151d4b38e0Srsmaeda  * If applicable, add the following below this CDDL HEADER, with the
161d4b38e0Srsmaeda  * fields enclosed by brackets "[]" replaced with your own identifying
171d4b38e0Srsmaeda  * information: Portions Copyright [yyyy] [name of copyright owner]
181d4b38e0Srsmaeda  *
191d4b38e0Srsmaeda  * CDDL HEADER END
201d4b38e0Srsmaeda  */
211d4b38e0Srsmaeda 
221d4b38e0Srsmaeda /*
23*af4c679fSSean McEnroe  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
241d4b38e0Srsmaeda  * Use is subject to license terms.
251d4b38e0Srsmaeda  */
261d4b38e0Srsmaeda 
271d4b38e0Srsmaeda #ifndef _SYS_DRCTL_H
281d4b38e0Srsmaeda #define	_SYS_DRCTL_H
291d4b38e0Srsmaeda 
301d4b38e0Srsmaeda #ifdef	__cplusplus
311d4b38e0Srsmaeda extern "C" {
321d4b38e0Srsmaeda #endif
331d4b38e0Srsmaeda 
341d4b38e0Srsmaeda 
351d4b38e0Srsmaeda #define	DRCTL_DEV "/devices/pseudo/drctl@0:drctl"
361d4b38e0Srsmaeda 
371d4b38e0Srsmaeda typedef enum {
381d4b38e0Srsmaeda 	DRCTL_CPU_CONFIG_REQUEST = 1,
391d4b38e0Srsmaeda 	DRCTL_CPU_CONFIG_NOTIFY,
401d4b38e0Srsmaeda 	DRCTL_CPU_UNCONFIG_REQUEST,
411d4b38e0Srsmaeda 	DRCTL_CPU_UNCONFIG_NOTIFY,
421d4b38e0Srsmaeda 	DRCTL_MEM_CONFIG_REQUEST,
431d4b38e0Srsmaeda 	DRCTL_MEM_CONFIG_NOTIFY,
441d4b38e0Srsmaeda 	DRCTL_MEM_UNCONFIG_REQUEST,
451d4b38e0Srsmaeda 	DRCTL_MEM_UNCONFIG_NOTIFY,
461d4b38e0Srsmaeda 	DRCTL_IO_CONFIG_REQUEST,
471d4b38e0Srsmaeda 	DRCTL_IO_CONFIG_NOTIFY,
481d4b38e0Srsmaeda 	DRCTL_IO_UNCONFIG_REQUEST,
49*af4c679fSSean McEnroe 	DRCTL_IO_UNCONFIG_NOTIFY,
50*af4c679fSSean McEnroe 	DRCTL_DRC_BLOCK
511d4b38e0Srsmaeda } drctl_cmds_t;
521d4b38e0Srsmaeda 
531d4b38e0Srsmaeda /*
541d4b38e0Srsmaeda  * Responses to/from the daemon for a reconfig request.
551d4b38e0Srsmaeda  */
561d4b38e0Srsmaeda typedef enum {
571d4b38e0Srsmaeda 	DRCTL_STATUS_INIT,		/* to daemon */
581d4b38e0Srsmaeda 	DRCTL_STATUS_ALLOW,		/* from daemon */
591d4b38e0Srsmaeda 	DRCTL_STATUS_DENY,		/* from daemon */
601d4b38e0Srsmaeda 	DRCTL_STATUS_CONFIG_SUCCESS,	/* to daemon */
611d4b38e0Srsmaeda 	DRCTL_STATUS_CONFIG_FAILURE	/* to daemon */
621d4b38e0Srsmaeda } drctl_status_t;
631d4b38e0Srsmaeda 
641d4b38e0Srsmaeda /*
651d4b38e0Srsmaeda  * Each resource descriptor consists of a common header
661d4b38e0Srsmaeda  * followed by a resource-specific structure.
671d4b38e0Srsmaeda  */
681d4b38e0Srsmaeda 
691d4b38e0Srsmaeda typedef struct drctl_rsrc_cpu {
701d4b38e0Srsmaeda 	int		id;
711d4b38e0Srsmaeda } drctl_rsrc_cpu_t;
721d4b38e0Srsmaeda 
731d4b38e0Srsmaeda typedef struct drctl_rsrc_memory {
741d4b38e0Srsmaeda 	uint64_t	size;
751d4b38e0Srsmaeda 	uint64_t	addr;
761d4b38e0Srsmaeda } drctl_rsrc_mem_t;
771d4b38e0Srsmaeda 
781d4b38e0Srsmaeda typedef struct drctl_rsrc_dev {
791d4b38e0Srsmaeda 	char		path[1];
801d4b38e0Srsmaeda } drctl_rsrc_dev_t;
811d4b38e0Srsmaeda 
821d4b38e0Srsmaeda typedef struct drctl_rsrc {
831d4b38e0Srsmaeda 	drctl_status_t	status;
841d4b38e0Srsmaeda 	uint64_t	offset;
851d4b38e0Srsmaeda 	union {
861d4b38e0Srsmaeda 		drctl_rsrc_cpu_t cpu;
871d4b38e0Srsmaeda 		drctl_rsrc_mem_t mem;
881d4b38e0Srsmaeda 		drctl_rsrc_dev_t dev;
891d4b38e0Srsmaeda 	} un;
901d4b38e0Srsmaeda } drctl_rsrc_t;
911d4b38e0Srsmaeda 
921d4b38e0Srsmaeda #define	res_cpu_id	un.cpu.id
931d4b38e0Srsmaeda #define	res_mem_size	un.mem.size
941d4b38e0Srsmaeda #define	res_mem_addr	un.mem.addr
951d4b38e0Srsmaeda #define	res_dev_path	un.dev.path
961d4b38e0Srsmaeda 
971d4b38e0Srsmaeda /*
9899c7e855SJames Marks - Sun Microsystems  * Response structure passed back by drctl to its clients
9999c7e855SJames Marks - Sun Microsystems  * (resource-specific DR modules).
10099c7e855SJames Marks - Sun Microsystems  */
10199c7e855SJames Marks - Sun Microsystems typedef enum {
10299c7e855SJames Marks - Sun Microsystems 	DRCTL_RESP_ERR,
10399c7e855SJames Marks - Sun Microsystems 	DRCTL_RESP_OK
10499c7e855SJames Marks - Sun Microsystems } drctl_resp_type_t;
10599c7e855SJames Marks - Sun Microsystems 
10699c7e855SJames Marks - Sun Microsystems typedef struct drctl_resp {
10799c7e855SJames Marks - Sun Microsystems 	drctl_resp_type_t resp_type;
10899c7e855SJames Marks - Sun Microsystems 	union {
10999c7e855SJames Marks - Sun Microsystems 		char err_msg[1];
11099c7e855SJames Marks - Sun Microsystems 		drctl_rsrc_t  resources[1];
11199c7e855SJames Marks - Sun Microsystems 	} un;
11299c7e855SJames Marks - Sun Microsystems } drctl_resp_t;
11399c7e855SJames Marks - Sun Microsystems 
11499c7e855SJames Marks - Sun Microsystems #define	resp_err_msg		un.err_msg
11599c7e855SJames Marks - Sun Microsystems #define	resp_resources		un.resources
11699c7e855SJames Marks - Sun Microsystems 
11799c7e855SJames Marks - Sun Microsystems /*
1181d4b38e0Srsmaeda  * Message sent to DR daemon
1191d4b38e0Srsmaeda  */
1201d4b38e0Srsmaeda typedef struct drd_msg {
1211d4b38e0Srsmaeda 	uint_t		cmd;
1221d4b38e0Srsmaeda 	uint_t		count;
1231d4b38e0Srsmaeda 	int		flags;
1241d4b38e0Srsmaeda 	drctl_rsrc_t	data[1];
1251d4b38e0Srsmaeda } drd_msg_t;
1261d4b38e0Srsmaeda 
1271d4b38e0Srsmaeda typedef void *drctl_cookie_t;
1281d4b38e0Srsmaeda 
1291d4b38e0Srsmaeda /*
1301d4b38e0Srsmaeda  * DR RSMs (resource-specific modules) call these functions to
1311d4b38e0Srsmaeda  * initialize or finalize a DR request.  A request may include
1321d4b38e0Srsmaeda  * multiple resources of the same type.  The _init call returns
1331d4b38e0Srsmaeda  * a cookie which must be supplied on by the corresponding
1341d4b38e0Srsmaeda  * _fini call.
1351d4b38e0Srsmaeda  */
1361d4b38e0Srsmaeda extern int drctl_config_init(int, int,
13799c7e855SJames Marks - Sun Microsystems     drctl_rsrc_t *, int, drctl_resp_t **, size_t *, drctl_cookie_t);
1381d4b38e0Srsmaeda extern int drctl_config_fini(drctl_cookie_t, drctl_rsrc_t *, int);
139*af4c679fSSean McEnroe extern void drctl_block(void);
140*af4c679fSSean McEnroe extern void drctl_unblock(void);
1411d4b38e0Srsmaeda 
1421d4b38e0Srsmaeda /*
1431d4b38e0Srsmaeda  * Values for the 2nd arg (flags) of drctl_config_init
1441d4b38e0Srsmaeda  */
1451d4b38e0Srsmaeda #define	DRCTL_FLAG_FORCE 1
1461d4b38e0Srsmaeda 
1471d4b38e0Srsmaeda 
1481d4b38e0Srsmaeda #ifdef	__cplusplus
1491d4b38e0Srsmaeda }
1501d4b38e0Srsmaeda #endif
1511d4b38e0Srsmaeda 
1521d4b38e0Srsmaeda #endif	/* _SYS_DRCTL_H */
153