xref: /titanic_52/usr/src/lib/librcm/librcm.h (revision 5093e10312724e92dd76c008a15bdb59d414708a)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5c0192a57Sericheng  * Common Development and Distribution License (the "License").
6c0192a57Sericheng  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*5093e103SCathy Zhou  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_LIBRCM_H
277c478bd9Sstevel@tonic-gate #define	_LIBRCM_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <libnvpair.h>
307c478bd9Sstevel@tonic-gate #include <sys/types.h>
317c478bd9Sstevel@tonic-gate #include <sys/processor.h>
327c478bd9Sstevel@tonic-gate #include <sys/pset.h>
337c478bd9Sstevel@tonic-gate #include <sys/time_impl.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * Flags for rcm requests
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate #define	RCM_INCLUDE_SUBTREE	0x0001
437c478bd9Sstevel@tonic-gate #define	RCM_INCLUDE_DEPENDENT	0x0002
447c478bd9Sstevel@tonic-gate #define	RCM_QUERY		0x0004
457c478bd9Sstevel@tonic-gate #define	RCM_FORCE		0x0008
467c478bd9Sstevel@tonic-gate #define	RCM_FILESYS		0x0010	/* private to filesys module */
477c478bd9Sstevel@tonic-gate #define	RCM_NOPID		0x0020
487c478bd9Sstevel@tonic-gate #define	RCM_DR_OPERATION	0x0040
497c478bd9Sstevel@tonic-gate #define	RCM_MOD_INFO		0x0080	/* private */
507c478bd9Sstevel@tonic-gate #define	RCM_CAPACITY_ADD	0x0100
517c478bd9Sstevel@tonic-gate #define	RCM_CAPACITY_DELETE	0x0200
527c478bd9Sstevel@tonic-gate #define	RCM_QUERY_CANCEL	0x0400	/* private */
537c478bd9Sstevel@tonic-gate #define	RCM_SCOPE		0x0800
547c478bd9Sstevel@tonic-gate #define	RCM_REGISTER_DR		0x1000	/* private */
557c478bd9Sstevel@tonic-gate #define	RCM_REGISTER_EVENT	0x2000	/* private */
567c478bd9Sstevel@tonic-gate #define	RCM_REGISTER_CAPACITY	0x4000	/* private */
577c478bd9Sstevel@tonic-gate #define	RCM_SUSPENDED		0x8000	/* private */
5825e8c5aaSvikram #define	RCM_RETIRE_REQUEST	0x10000
5925e8c5aaSvikram #define	RCM_RETIRE_NOTIFY	0x20000
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate /*
627c478bd9Sstevel@tonic-gate  * RCM return values
637c478bd9Sstevel@tonic-gate  */
647c478bd9Sstevel@tonic-gate #define	RCM_SUCCESS		0
657c478bd9Sstevel@tonic-gate #define	RCM_FAILURE		-1
667c478bd9Sstevel@tonic-gate #define	RCM_CONFLICT		-2
6725e8c5aaSvikram #define	RCM_NO_CONSTRAINT	-3
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate /*
707c478bd9Sstevel@tonic-gate  * RCM resource states
717c478bd9Sstevel@tonic-gate  */
727c478bd9Sstevel@tonic-gate #define	RCM_STATE_UNKNOWN		0
737c478bd9Sstevel@tonic-gate #define	RCM_STATE_ONLINE		1
747c478bd9Sstevel@tonic-gate #define	RCM_STATE_ONLINING		2
757c478bd9Sstevel@tonic-gate #define	RCM_STATE_OFFLINE_FAIL		3
767c478bd9Sstevel@tonic-gate #define	RCM_STATE_OFFLINING		4
777c478bd9Sstevel@tonic-gate #define	RCM_STATE_OFFLINE		5
787c478bd9Sstevel@tonic-gate #define	RCM_STATE_REMOVING		6
797c478bd9Sstevel@tonic-gate #define	RCM_STATE_RESUMING		10
807c478bd9Sstevel@tonic-gate #define	RCM_STATE_SUSPEND_FAIL		11
817c478bd9Sstevel@tonic-gate #define	RCM_STATE_SUSPENDING		12
827c478bd9Sstevel@tonic-gate #define	RCM_STATE_SUSPEND		13
837c478bd9Sstevel@tonic-gate #define	RCM_STATE_REMOVE		14	/* private to rcm_daemon */
847c478bd9Sstevel@tonic-gate #define	RCM_STATE_OFFLINE_QUERYING	15
857c478bd9Sstevel@tonic-gate #define	RCM_STATE_OFFLINE_QUERY_FAIL	16
867c478bd9Sstevel@tonic-gate #define	RCM_STATE_OFFLINE_QUERY		17
877c478bd9Sstevel@tonic-gate #define	RCM_STATE_SUSPEND_QUERYING	18
887c478bd9Sstevel@tonic-gate #define	RCM_STATE_SUSPEND_QUERY_FAIL	19
897c478bd9Sstevel@tonic-gate #define	RCM_STATE_SUSPEND_QUERY		20
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate /*
927c478bd9Sstevel@tonic-gate  * RCM event attr and properties
937c478bd9Sstevel@tonic-gate  */
947c478bd9Sstevel@tonic-gate #define	RCM_RSRCNAME		"rcm.rsrcname"
957c478bd9Sstevel@tonic-gate #define	RCM_CLIENT_NAME		"rcm.client_name"
967c478bd9Sstevel@tonic-gate #define	RCM_CLIENT_EXPORTS	"rcm.client_exports"
977c478bd9Sstevel@tonic-gate 
98*5093e103SCathy Zhou /* Resource name to register for new links reconfigured */
99d62bc4baSyz147064 #define	RCM_RESOURCE_LINK_NEW		"SUNW_event/resource/new/link"
1007c478bd9Sstevel@tonic-gate 
101*5093e103SCathy Zhou /* Resource name to register for new physical data-links */
102*5093e103SCathy Zhou #define	RCM_RESOURCE_PHYSLINK_NEW	"SUNW_event/resource/new/physlink"
103*5093e103SCathy Zhou 
1047c478bd9Sstevel@tonic-gate /* name-value pair definitions for rcm_notify_event() */
105d62bc4baSyz147064 #define	RCM_NV_LINKID		"linkid"
106*5093e103SCathy Zhou #define	RCM_NV_RECONFIGURED	"reconfigured"
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate /*
1097c478bd9Sstevel@tonic-gate  * rcm handles
1107c478bd9Sstevel@tonic-gate  */
1117c478bd9Sstevel@tonic-gate typedef struct rcm_handle rcm_handle_t;
1127c478bd9Sstevel@tonic-gate typedef struct rcm_info rcm_info_t;
1137c478bd9Sstevel@tonic-gate typedef rcm_info_t rcm_info_tuple_t;
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate /*
1167c478bd9Sstevel@tonic-gate  * Interface definitions
1177c478bd9Sstevel@tonic-gate  */
1187c478bd9Sstevel@tonic-gate int rcm_alloc_handle(char *, uint_t, void *, rcm_handle_t **);
1197c478bd9Sstevel@tonic-gate int rcm_free_handle(rcm_handle_t *);
1207c478bd9Sstevel@tonic-gate int rcm_get_info(rcm_handle_t *, char *, uint_t, rcm_info_t **);
1217c478bd9Sstevel@tonic-gate int rcm_get_info_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
1227c478bd9Sstevel@tonic-gate void rcm_free_info(rcm_info_t *);
1237c478bd9Sstevel@tonic-gate int rcm_append_info(rcm_info_t **, rcm_info_t *);
1247c478bd9Sstevel@tonic-gate rcm_info_tuple_t *rcm_info_next(rcm_info_t *, rcm_info_tuple_t *);
1257c478bd9Sstevel@tonic-gate const char *rcm_info_rsrc(rcm_info_tuple_t *);
1267c478bd9Sstevel@tonic-gate const char *rcm_info_info(rcm_info_tuple_t *);
1277c478bd9Sstevel@tonic-gate const char *rcm_info_error(rcm_info_tuple_t *);
1287c478bd9Sstevel@tonic-gate const char *rcm_info_modname(rcm_info_tuple_t *);
1297c478bd9Sstevel@tonic-gate pid_t rcm_info_pid(rcm_info_tuple_t *);
1307c478bd9Sstevel@tonic-gate int rcm_info_state(rcm_info_tuple_t *);
1317c478bd9Sstevel@tonic-gate int rcm_info_seqnum(rcm_info_tuple_t *);
1327c478bd9Sstevel@tonic-gate nvlist_t *rcm_info_properties(rcm_info_tuple_t *);
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate int rcm_request_offline(rcm_handle_t *, char *, uint_t, rcm_info_t **);
1357c478bd9Sstevel@tonic-gate int rcm_request_offline_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
1367c478bd9Sstevel@tonic-gate int rcm_notify_online(rcm_handle_t *, char *, uint_t, rcm_info_t **);
1377c478bd9Sstevel@tonic-gate int rcm_notify_online_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
1387c478bd9Sstevel@tonic-gate int rcm_notify_remove(rcm_handle_t *, char *, uint_t, rcm_info_t **);
1397c478bd9Sstevel@tonic-gate int rcm_notify_remove_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
1407c478bd9Sstevel@tonic-gate int rcm_request_suspend(rcm_handle_t *, char *, uint_t, timespec_t *,
1417c478bd9Sstevel@tonic-gate 	rcm_info_t **);
1427c478bd9Sstevel@tonic-gate int rcm_request_suspend_list(rcm_handle_t *, char **, uint_t, timespec_t *,
1437c478bd9Sstevel@tonic-gate 	rcm_info_t **);
1447c478bd9Sstevel@tonic-gate int rcm_notify_resume(rcm_handle_t *, char *, uint_t, rcm_info_t **);
1457c478bd9Sstevel@tonic-gate int rcm_notify_resume_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
1467c478bd9Sstevel@tonic-gate int rcm_notify_capacity_change(rcm_handle_t *, char *, uint_t, nvlist_t *,
1477c478bd9Sstevel@tonic-gate 	rcm_info_t **);
1487c478bd9Sstevel@tonic-gate int rcm_request_capacity_change(rcm_handle_t *, char *, uint_t, nvlist_t *,
1497c478bd9Sstevel@tonic-gate 	rcm_info_t **);
1507c478bd9Sstevel@tonic-gate int rcm_notify_event(rcm_handle_t *, char *, uint_t, nvlist_t *, rcm_info_t **);
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate int rcm_register_event(rcm_handle_t *, char *, uint_t, rcm_info_t **);
1537c478bd9Sstevel@tonic-gate int rcm_register_capacity(rcm_handle_t *, char *, uint_t, rcm_info_t **);
1547c478bd9Sstevel@tonic-gate int rcm_register_interest(rcm_handle_t *, char *, uint_t, rcm_info_t **);
1557c478bd9Sstevel@tonic-gate int rcm_unregister_event(rcm_handle_t *, char *, uint_t);
1567c478bd9Sstevel@tonic-gate int rcm_unregister_capacity(rcm_handle_t *, char *, uint_t);
1577c478bd9Sstevel@tonic-gate int rcm_unregister_interest(rcm_handle_t *, char *, uint_t);
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate int rcm_get_rsrcstate(rcm_handle_t *, char *, int *);
1607c478bd9Sstevel@tonic-gate int rcm_exec_cmd(char *);
1617c478bd9Sstevel@tonic-gate const char *rcm_get_client_name(rcm_handle_t *);
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1647c478bd9Sstevel@tonic-gate }
1657c478bd9Sstevel@tonic-gate #endif
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate #endif	/* _LIBRCM_H */
168