xref: /onnv-gate/usr/src/lib/libsrpt/common/libsrpt.h (revision 12075:b143b9fb49fc)
1*12075SSusan.Gleeson@Sun.COM /*
2*12075SSusan.Gleeson@Sun.COM  * CDDL HEADER START
3*12075SSusan.Gleeson@Sun.COM  *
4*12075SSusan.Gleeson@Sun.COM  * The contents of this file are subject to the terms of the
5*12075SSusan.Gleeson@Sun.COM  * Common Development and Distribution License (the "License").
6*12075SSusan.Gleeson@Sun.COM  * You may not use this file except in compliance with the License.
7*12075SSusan.Gleeson@Sun.COM  *
8*12075SSusan.Gleeson@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*12075SSusan.Gleeson@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*12075SSusan.Gleeson@Sun.COM  * See the License for the specific language governing permissions
11*12075SSusan.Gleeson@Sun.COM  * and limitations under the License.
12*12075SSusan.Gleeson@Sun.COM  *
13*12075SSusan.Gleeson@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*12075SSusan.Gleeson@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*12075SSusan.Gleeson@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*12075SSusan.Gleeson@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*12075SSusan.Gleeson@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*12075SSusan.Gleeson@Sun.COM  *
19*12075SSusan.Gleeson@Sun.COM  * CDDL HEADER END
20*12075SSusan.Gleeson@Sun.COM  */
21*12075SSusan.Gleeson@Sun.COM /*
22*12075SSusan.Gleeson@Sun.COM  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23*12075SSusan.Gleeson@Sun.COM  */
24*12075SSusan.Gleeson@Sun.COM 
25*12075SSusan.Gleeson@Sun.COM #ifndef	_LIBSRPT_H
26*12075SSusan.Gleeson@Sun.COM #define	_LIBSRPT_H
27*12075SSusan.Gleeson@Sun.COM 
28*12075SSusan.Gleeson@Sun.COM #ifdef	__cplusplus
29*12075SSusan.Gleeson@Sun.COM extern "C" {
30*12075SSusan.Gleeson@Sun.COM #endif
31*12075SSusan.Gleeson@Sun.COM 
32*12075SSusan.Gleeson@Sun.COM #include <sys/types.h>
33*12075SSusan.Gleeson@Sun.COM #include <libnvpair.h>
34*12075SSusan.Gleeson@Sun.COM 
35*12075SSusan.Gleeson@Sun.COM /*
36*12075SSusan.Gleeson@Sun.COM  * Function:  srpt_GetConfig()
37*12075SSusan.Gleeson@Sun.COM  *
38*12075SSusan.Gleeson@Sun.COM  * Parameters:
39*12075SSusan.Gleeson@Sun.COM  *    cfg	Current SRPT configuration in nvlist form
40*12075SSusan.Gleeson@Sun.COM  *    token	Configuration generation number.  Use this token
41*12075SSusan.Gleeson@Sun.COM  *		if updating the configuration with srpt_SetConfig.
42*12075SSusan.Gleeson@Sun.COM  *
43*12075SSusan.Gleeson@Sun.COM  * Return Values:
44*12075SSusan.Gleeson@Sun.COM  *    0		Success
45*12075SSusan.Gleeson@Sun.COM  *    ENOMEM	Could not allocate resources
46*12075SSusan.Gleeson@Sun.COM  *    EINVAL	Invalid parameter
47*12075SSusan.Gleeson@Sun.COM  */
48*12075SSusan.Gleeson@Sun.COM int
49*12075SSusan.Gleeson@Sun.COM srpt_GetConfig(nvlist_t **cfg, uint64_t *token);
50*12075SSusan.Gleeson@Sun.COM 
51*12075SSusan.Gleeson@Sun.COM /*
52*12075SSusan.Gleeson@Sun.COM  * Function:  srpt_SetConfig()
53*12075SSusan.Gleeson@Sun.COM  *
54*12075SSusan.Gleeson@Sun.COM  * Parameters:
55*12075SSusan.Gleeson@Sun.COM  *    cfg	SRPT configuration in nvlist form
56*12075SSusan.Gleeson@Sun.COM  *    token	Configuration generation number from srpt_GetConfig.
57*12075SSusan.Gleeson@Sun.COM  *		Use this token to ensure the configuration hasn't been
58*12075SSusan.Gleeson@Sun.COM  *		updated by another user since the time it was fetched.
59*12075SSusan.Gleeson@Sun.COM  *
60*12075SSusan.Gleeson@Sun.COM  * Return Values:
61*12075SSusan.Gleeson@Sun.COM  *    0		Success
62*12075SSusan.Gleeson@Sun.COM  *    ENOMEM	Could not allocate resources
63*12075SSusan.Gleeson@Sun.COM  *    EINVAL	Invalid parameter
64*12075SSusan.Gleeson@Sun.COM  *    ECANCELED Configuration updated by another user
65*12075SSusan.Gleeson@Sun.COM  */
66*12075SSusan.Gleeson@Sun.COM int
67*12075SSusan.Gleeson@Sun.COM srpt_SetConfig(nvlist_t *cfg, uint64_t token);
68*12075SSusan.Gleeson@Sun.COM 
69*12075SSusan.Gleeson@Sun.COM /*
70*12075SSusan.Gleeson@Sun.COM  * Function:  srpt_GetDefaultState()
71*12075SSusan.Gleeson@Sun.COM  *
72*12075SSusan.Gleeson@Sun.COM  * Parameters:
73*12075SSusan.Gleeson@Sun.COM  *    enabled	If B_TRUE, indicates that targets will be created for all
74*12075SSusan.Gleeson@Sun.COM  *		discovered HCAs that have not been specifically disabled.
75*12075SSusan.Gleeson@Sun.COM  *		If B_FALSE, targets will not be created unless the HCA has
76*12075SSusan.Gleeson@Sun.COM  *		been specifically enabled.  See also srpt_SetDefaultState().
77*12075SSusan.Gleeson@Sun.COM  *
78*12075SSusan.Gleeson@Sun.COM  * Return Values:
79*12075SSusan.Gleeson@Sun.COM  *    0		Success
80*12075SSusan.Gleeson@Sun.COM  *    ENOMEM	Could not allocate resources
81*12075SSusan.Gleeson@Sun.COM  *    EINVAL	Invalid parameter
82*12075SSusan.Gleeson@Sun.COM  */
83*12075SSusan.Gleeson@Sun.COM int
84*12075SSusan.Gleeson@Sun.COM srpt_GetDefaultState(boolean_t *enabled);
85*12075SSusan.Gleeson@Sun.COM 
86*12075SSusan.Gleeson@Sun.COM /*
87*12075SSusan.Gleeson@Sun.COM  * Function:  srpt_SetDefaultState()
88*12075SSusan.Gleeson@Sun.COM  *
89*12075SSusan.Gleeson@Sun.COM  * Parameters:
90*12075SSusan.Gleeson@Sun.COM  *    enabled	If B_TRUE, indicates that targets will be created for all
91*12075SSusan.Gleeson@Sun.COM  *		discovered HCAs that have not been specifically disabled.
92*12075SSusan.Gleeson@Sun.COM  *		If B_FALSE, targets will not be created unless the HCA has
93*12075SSusan.Gleeson@Sun.COM  *		been specifically enabled.  See also srpt_SetDefaultState().
94*12075SSusan.Gleeson@Sun.COM  *
95*12075SSusan.Gleeson@Sun.COM  * Return Values:
96*12075SSusan.Gleeson@Sun.COM  *    0		Success
97*12075SSusan.Gleeson@Sun.COM  *    ENOMEM	Could not allocate resources
98*12075SSusan.Gleeson@Sun.COM  *    EINVAL	Invalid parameter
99*12075SSusan.Gleeson@Sun.COM  */
100*12075SSusan.Gleeson@Sun.COM int
101*12075SSusan.Gleeson@Sun.COM srpt_SetDefaultState(boolean_t enabled);
102*12075SSusan.Gleeson@Sun.COM 
103*12075SSusan.Gleeson@Sun.COM /*
104*12075SSusan.Gleeson@Sun.COM  * Function:  srpt_SetTargetState()
105*12075SSusan.Gleeson@Sun.COM  *
106*12075SSusan.Gleeson@Sun.COM  * Parameters:
107*12075SSusan.Gleeson@Sun.COM  *    hca_guid	HCA GUID.  See description of srpt_NormalizeGuid
108*12075SSusan.Gleeson@Sun.COM  *    enabled	If B_TRUE, indicates that a target will be created for
109*12075SSusan.Gleeson@Sun.COM  *		this HCA when the SRPT SMF service is enabled.  If B_FALSE,
110*12075SSusan.Gleeson@Sun.COM  *		a target will not be created
111*12075SSusan.Gleeson@Sun.COM  *
112*12075SSusan.Gleeson@Sun.COM  * Return Values:
113*12075SSusan.Gleeson@Sun.COM  *    0		Success
114*12075SSusan.Gleeson@Sun.COM  *    ENOMEM	Could not allocate resources
115*12075SSusan.Gleeson@Sun.COM  *    EINVAL	Invalid parameter
116*12075SSusan.Gleeson@Sun.COM  */
117*12075SSusan.Gleeson@Sun.COM int
118*12075SSusan.Gleeson@Sun.COM srpt_SetTargetState(char *hca_guid, boolean_t enabled);
119*12075SSusan.Gleeson@Sun.COM 
120*12075SSusan.Gleeson@Sun.COM /*
121*12075SSusan.Gleeson@Sun.COM  * Function:  srpt_GetTargetState()
122*12075SSusan.Gleeson@Sun.COM  *
123*12075SSusan.Gleeson@Sun.COM  * Parameters:
124*12075SSusan.Gleeson@Sun.COM  *    hca_guid	HCA GUID.  See description of srpt_NormalizeGuid
125*12075SSusan.Gleeson@Sun.COM  *    enabled	If B_TRUE, indicates that a target will be created for
126*12075SSusan.Gleeson@Sun.COM  *		this HCA when the SRPT SMF service is enabled.  If B_FALSE,
127*12075SSusan.Gleeson@Sun.COM  *		a target will not be created
128*12075SSusan.Gleeson@Sun.COM  *
129*12075SSusan.Gleeson@Sun.COM  * Return Values:
130*12075SSusan.Gleeson@Sun.COM  *    0		Success
131*12075SSusan.Gleeson@Sun.COM  *    ENOMEM	Could not allocate resources
132*12075SSusan.Gleeson@Sun.COM  *    EINVAL	Invalid parameter
133*12075SSusan.Gleeson@Sun.COM  */
134*12075SSusan.Gleeson@Sun.COM int
135*12075SSusan.Gleeson@Sun.COM srpt_GetTargetState(char *hca_guid, boolean_t *enabled);
136*12075SSusan.Gleeson@Sun.COM 
137*12075SSusan.Gleeson@Sun.COM /*
138*12075SSusan.Gleeson@Sun.COM  * Function:  srpt_ResetTarget()
139*12075SSusan.Gleeson@Sun.COM  *
140*12075SSusan.Gleeson@Sun.COM  * Clears the HCA-specific configuration.  Target creation will revert to
141*12075SSusan.Gleeson@Sun.COM  * the default.
142*12075SSusan.Gleeson@Sun.COM  *
143*12075SSusan.Gleeson@Sun.COM  * Parameters:
144*12075SSusan.Gleeson@Sun.COM  *    hca_guid	HCA GUID.  See description of srpt_NormalizeGuid
145*12075SSusan.Gleeson@Sun.COM  *
146*12075SSusan.Gleeson@Sun.COM  * Return Values:
147*12075SSusan.Gleeson@Sun.COM  *    0		Success
148*12075SSusan.Gleeson@Sun.COM  *    ENOMEM	Could not allocate resources
149*12075SSusan.Gleeson@Sun.COM  *    EINVAL	Invalid parameter
150*12075SSusan.Gleeson@Sun.COM  */
151*12075SSusan.Gleeson@Sun.COM int
152*12075SSusan.Gleeson@Sun.COM srpt_ResetTarget(char *hca_guid);
153*12075SSusan.Gleeson@Sun.COM 
154*12075SSusan.Gleeson@Sun.COM /*
155*12075SSusan.Gleeson@Sun.COM  * srpt_NormalizeGuid()
156*12075SSusan.Gleeson@Sun.COM  *
157*12075SSusan.Gleeson@Sun.COM  * Parameters:
158*12075SSusan.Gleeson@Sun.COM  *    in	HCA GUID.  Must be in one of the following forms:
159*12075SSusan.Gleeson@Sun.COM  *		    3BA000100CD18	- base hex form
160*12075SSusan.Gleeson@Sun.COM  *		    0003BA000100CD18	- base hex form with leading zeroes
161*12075SSusan.Gleeson@Sun.COM  *		    hca:3BA000100CD18	- form from cfgadm and/or /dev/cfg
162*12075SSusan.Gleeson@Sun.COM  *		    eui.0003BA000100CD18 - EUI form
163*12075SSusan.Gleeson@Sun.COM  *
164*12075SSusan.Gleeson@Sun.COM  *    buf	Buffer to hold normalized guid string.  Must be at least
165*12075SSusan.Gleeson@Sun.COM  *		17 chars long.
166*12075SSusan.Gleeson@Sun.COM  *    buflen	Length of provided buffer
167*12075SSusan.Gleeson@Sun.COM  *    int_guid	Optional.  If not NULL, the integer form of the GUID will also
168*12075SSusan.Gleeson@Sun.COM  *		be returned.
169*12075SSusan.Gleeson@Sun.COM  * Return Values:
170*12075SSusan.Gleeson@Sun.COM  *    0		Success
171*12075SSusan.Gleeson@Sun.COM  *    EINVAL	Invalid HCA GUID or invalid parameter.
172*12075SSusan.Gleeson@Sun.COM  */
173*12075SSusan.Gleeson@Sun.COM int
174*12075SSusan.Gleeson@Sun.COM srpt_NormalizeGuid(char *in, char *buf, size_t buflen, uint64_t *int_guid);
175*12075SSusan.Gleeson@Sun.COM 
176*12075SSusan.Gleeson@Sun.COM #ifdef	__cplusplus
177*12075SSusan.Gleeson@Sun.COM }
178*12075SSusan.Gleeson@Sun.COM #endif
179*12075SSusan.Gleeson@Sun.COM 
180*12075SSusan.Gleeson@Sun.COM #endif	/* _LIBSRPT_H */
181