xref: /onnv-gate/usr/src/uts/sun4v/sys/drctl.h (revision 12260:806de32452bd)
12309Srsmaeda /*
22309Srsmaeda  * CDDL HEADER START
32309Srsmaeda  *
42309Srsmaeda  * The contents of this file are subject to the terms of the
52309Srsmaeda  * Common Development and Distribution License (the "License").
62309Srsmaeda  * You may not use this file except in compliance with the License.
72309Srsmaeda  *
82309Srsmaeda  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92309Srsmaeda  * or http://www.opensolaris.org/os/licensing.
102309Srsmaeda  * See the License for the specific language governing permissions
112309Srsmaeda  * and limitations under the License.
122309Srsmaeda  *
132309Srsmaeda  * When distributing Covered Code, include this CDDL HEADER in each
142309Srsmaeda  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152309Srsmaeda  * If applicable, add the following below this CDDL HEADER, with the
162309Srsmaeda  * fields enclosed by brackets "[]" replaced with your own identifying
172309Srsmaeda  * information: Portions Copyright [yyyy] [name of copyright owner]
182309Srsmaeda  *
192309Srsmaeda  * CDDL HEADER END
202309Srsmaeda  */
212309Srsmaeda 
222309Srsmaeda /*
23*12260SHaik.Aftandilian@Sun.COM  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
242309Srsmaeda  */
252309Srsmaeda 
262309Srsmaeda #ifndef _SYS_DRCTL_H
272309Srsmaeda #define	_SYS_DRCTL_H
282309Srsmaeda 
292309Srsmaeda #ifdef	__cplusplus
302309Srsmaeda extern "C" {
312309Srsmaeda #endif
322309Srsmaeda 
332309Srsmaeda 
342309Srsmaeda #define	DRCTL_DEV "/devices/pseudo/drctl@0:drctl"
352309Srsmaeda 
362309Srsmaeda typedef enum {
372309Srsmaeda 	DRCTL_CPU_CONFIG_REQUEST = 1,
382309Srsmaeda 	DRCTL_CPU_CONFIG_NOTIFY,
392309Srsmaeda 	DRCTL_CPU_UNCONFIG_REQUEST,
402309Srsmaeda 	DRCTL_CPU_UNCONFIG_NOTIFY,
412309Srsmaeda 	DRCTL_MEM_CONFIG_REQUEST,
422309Srsmaeda 	DRCTL_MEM_CONFIG_NOTIFY,
432309Srsmaeda 	DRCTL_MEM_UNCONFIG_REQUEST,
442309Srsmaeda 	DRCTL_MEM_UNCONFIG_NOTIFY,
452309Srsmaeda 	DRCTL_IO_CONFIG_REQUEST,
462309Srsmaeda 	DRCTL_IO_CONFIG_NOTIFY,
472309Srsmaeda 	DRCTL_IO_UNCONFIG_REQUEST,
4811185SSean.McEnroe@Sun.COM 	DRCTL_IO_UNCONFIG_NOTIFY,
4911185SSean.McEnroe@Sun.COM 	DRCTL_DRC_BLOCK
502309Srsmaeda } drctl_cmds_t;
512309Srsmaeda 
522309Srsmaeda /*
532309Srsmaeda  * Responses to/from the daemon for a reconfig request.
542309Srsmaeda  */
552309Srsmaeda typedef enum {
562309Srsmaeda 	DRCTL_STATUS_INIT,		/* to daemon */
572309Srsmaeda 	DRCTL_STATUS_ALLOW,		/* from daemon */
582309Srsmaeda 	DRCTL_STATUS_DENY,		/* from daemon */
592309Srsmaeda 	DRCTL_STATUS_CONFIG_SUCCESS,	/* to daemon */
602309Srsmaeda 	DRCTL_STATUS_CONFIG_FAILURE	/* to daemon */
612309Srsmaeda } drctl_status_t;
622309Srsmaeda 
632309Srsmaeda /*
642309Srsmaeda  * Each resource descriptor consists of a common header
652309Srsmaeda  * followed by a resource-specific structure.
662309Srsmaeda  */
672309Srsmaeda 
682309Srsmaeda typedef struct drctl_rsrc_cpu {
692309Srsmaeda 	int		id;
702309Srsmaeda } drctl_rsrc_cpu_t;
712309Srsmaeda 
722309Srsmaeda typedef struct drctl_rsrc_memory {
732309Srsmaeda 	uint64_t	size;
742309Srsmaeda 	uint64_t	addr;
752309Srsmaeda } drctl_rsrc_mem_t;
762309Srsmaeda 
772309Srsmaeda typedef struct drctl_rsrc_dev {
782309Srsmaeda 	char		path[1];
792309Srsmaeda } drctl_rsrc_dev_t;
802309Srsmaeda 
812309Srsmaeda typedef struct drctl_rsrc {
822309Srsmaeda 	drctl_status_t	status;
832309Srsmaeda 	uint64_t	offset;
842309Srsmaeda 	union {
852309Srsmaeda 		drctl_rsrc_cpu_t cpu;
862309Srsmaeda 		drctl_rsrc_mem_t mem;
872309Srsmaeda 		drctl_rsrc_dev_t dev;
882309Srsmaeda 	} un;
892309Srsmaeda } drctl_rsrc_t;
902309Srsmaeda 
912309Srsmaeda #define	res_cpu_id	un.cpu.id
922309Srsmaeda #define	res_mem_size	un.mem.size
932309Srsmaeda #define	res_mem_addr	un.mem.addr
942309Srsmaeda #define	res_dev_path	un.dev.path
952309Srsmaeda 
962309Srsmaeda /*
977899SJames.Marks@Sun.COM  * Response structure passed back by drctl to its clients
987899SJames.Marks@Sun.COM  * (resource-specific DR modules).
997899SJames.Marks@Sun.COM  */
1007899SJames.Marks@Sun.COM typedef enum {
1017899SJames.Marks@Sun.COM 	DRCTL_RESP_ERR,
1027899SJames.Marks@Sun.COM 	DRCTL_RESP_OK
1037899SJames.Marks@Sun.COM } drctl_resp_type_t;
1047899SJames.Marks@Sun.COM 
1057899SJames.Marks@Sun.COM typedef struct drctl_resp {
1067899SJames.Marks@Sun.COM 	drctl_resp_type_t resp_type;
1077899SJames.Marks@Sun.COM 	union {
1087899SJames.Marks@Sun.COM 		char err_msg[1];
1097899SJames.Marks@Sun.COM 		drctl_rsrc_t  resources[1];
1107899SJames.Marks@Sun.COM 	} un;
1117899SJames.Marks@Sun.COM } drctl_resp_t;
1127899SJames.Marks@Sun.COM 
1137899SJames.Marks@Sun.COM #define	resp_err_msg		un.err_msg
1147899SJames.Marks@Sun.COM #define	resp_resources		un.resources
1157899SJames.Marks@Sun.COM 
1167899SJames.Marks@Sun.COM /*
1172309Srsmaeda  * Message sent to DR daemon
1182309Srsmaeda  */
1192309Srsmaeda typedef struct drd_msg {
1202309Srsmaeda 	uint_t		cmd;
1212309Srsmaeda 	uint_t		count;
1222309Srsmaeda 	int		flags;
1232309Srsmaeda 	drctl_rsrc_t	data[1];
1242309Srsmaeda } drd_msg_t;
1252309Srsmaeda 
1262309Srsmaeda typedef void *drctl_cookie_t;
1272309Srsmaeda 
1282309Srsmaeda /*
1292309Srsmaeda  * DR RSMs (resource-specific modules) call these functions to
1302309Srsmaeda  * initialize or finalize a DR request.  A request may include
1312309Srsmaeda  * multiple resources of the same type.  The _init call returns
1322309Srsmaeda  * a cookie which must be supplied on by the corresponding
1332309Srsmaeda  * _fini call.
1342309Srsmaeda  */
1352309Srsmaeda extern int drctl_config_init(int, int,
1367899SJames.Marks@Sun.COM     drctl_rsrc_t *, int, drctl_resp_t **, size_t *, drctl_cookie_t);
1372309Srsmaeda extern int drctl_config_fini(drctl_cookie_t, drctl_rsrc_t *, int);
13811185SSean.McEnroe@Sun.COM extern void drctl_block(void);
139*12260SHaik.Aftandilian@Sun.COM extern int drctl_tryblock(void);
14011185SSean.McEnroe@Sun.COM extern void drctl_unblock(void);
1412309Srsmaeda 
1422309Srsmaeda /*
1432309Srsmaeda  * Values for the 2nd arg (flags) of drctl_config_init
1442309Srsmaeda  */
1452309Srsmaeda #define	DRCTL_FLAG_FORCE 1
1462309Srsmaeda 
1472309Srsmaeda 
1482309Srsmaeda #ifdef	__cplusplus
1492309Srsmaeda }
1502309Srsmaeda #endif
1512309Srsmaeda 
1522309Srsmaeda #endif	/* _SYS_DRCTL_H */
153