xref: /illumos-gate/usr/src/lib/libsrpt/common/libsrpt.h (revision 2a93c3751513f2cec775a429a244bec6f0f0a635)
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  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef	_LIBSRPT_H
26 #define	_LIBSRPT_H
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 #include <sys/types.h>
33 #include <libnvpair.h>
34 
35 /*
36  * Function:  srpt_GetConfig()
37  *
38  * Parameters:
39  *    cfg	Current SRPT configuration in nvlist form
40  *    token	Configuration generation number.  Use this token
41  *		if updating the configuration with srpt_SetConfig.
42  *
43  * Return Values:
44  *    0		Success
45  *    ENOMEM	Could not allocate resources
46  *    EINVAL	Invalid parameter
47  */
48 int
49 srpt_GetConfig(nvlist_t **cfg, uint64_t *token);
50 
51 /*
52  * Function:  srpt_SetConfig()
53  *
54  * Parameters:
55  *    cfg	SRPT configuration in nvlist form
56  *    token	Configuration generation number from srpt_GetConfig.
57  *		Use this token to ensure the configuration hasn't been
58  *		updated by another user since the time it was fetched.
59  *
60  * Return Values:
61  *    0		Success
62  *    ENOMEM	Could not allocate resources
63  *    EINVAL	Invalid parameter
64  *    ECANCELED Configuration updated by another user
65  */
66 int
67 srpt_SetConfig(nvlist_t *cfg, uint64_t token);
68 
69 /*
70  * Function:  srpt_GetDefaultState()
71  *
72  * Parameters:
73  *    enabled	If B_TRUE, indicates that targets will be created for all
74  *		discovered HCAs that have not been specifically disabled.
75  *		If B_FALSE, targets will not be created unless the HCA has
76  *		been specifically enabled.  See also srpt_SetDefaultState().
77  *
78  * Return Values:
79  *    0		Success
80  *    ENOMEM	Could not allocate resources
81  *    EINVAL	Invalid parameter
82  */
83 int
84 srpt_GetDefaultState(boolean_t *enabled);
85 
86 /*
87  * Function:  srpt_SetDefaultState()
88  *
89  * Parameters:
90  *    enabled	If B_TRUE, indicates that targets will be created for all
91  *		discovered HCAs that have not been specifically disabled.
92  *		If B_FALSE, targets will not be created unless the HCA has
93  *		been specifically enabled.  See also srpt_SetDefaultState().
94  *
95  * Return Values:
96  *    0		Success
97  *    ENOMEM	Could not allocate resources
98  *    EINVAL	Invalid parameter
99  */
100 int
101 srpt_SetDefaultState(boolean_t enabled);
102 
103 /*
104  * Function:  srpt_SetTargetState()
105  *
106  * Parameters:
107  *    hca_guid	HCA GUID.  See description of srpt_NormalizeGuid
108  *    enabled	If B_TRUE, indicates that a target will be created for
109  *		this HCA when the SRPT SMF service is enabled.  If B_FALSE,
110  *		a target will not be created
111  *
112  * Return Values:
113  *    0		Success
114  *    ENOMEM	Could not allocate resources
115  *    EINVAL	Invalid parameter
116  */
117 int
118 srpt_SetTargetState(char *hca_guid, boolean_t enabled);
119 
120 /*
121  * Function:  srpt_GetTargetState()
122  *
123  * Parameters:
124  *    hca_guid	HCA GUID.  See description of srpt_NormalizeGuid
125  *    enabled	If B_TRUE, indicates that a target will be created for
126  *		this HCA when the SRPT SMF service is enabled.  If B_FALSE,
127  *		a target will not be created
128  *
129  * Return Values:
130  *    0		Success
131  *    ENOMEM	Could not allocate resources
132  *    EINVAL	Invalid parameter
133  */
134 int
135 srpt_GetTargetState(char *hca_guid, boolean_t *enabled);
136 
137 /*
138  * Function:  srpt_ResetTarget()
139  *
140  * Clears the HCA-specific configuration.  Target creation will revert to
141  * the default.
142  *
143  * Parameters:
144  *    hca_guid	HCA GUID.  See description of srpt_NormalizeGuid
145  *
146  * Return Values:
147  *    0		Success
148  *    ENOMEM	Could not allocate resources
149  *    EINVAL	Invalid parameter
150  */
151 int
152 srpt_ResetTarget(char *hca_guid);
153 
154 /*
155  * srpt_NormalizeGuid()
156  *
157  * Parameters:
158  *    in	HCA GUID.  Must be in one of the following forms:
159  *		    3BA000100CD18	- base hex form
160  *		    0003BA000100CD18	- base hex form with leading zeroes
161  *		    hca:3BA000100CD18	- form from cfgadm and/or /dev/cfg
162  *		    eui.0003BA000100CD18 - EUI form
163  *
164  *    buf	Buffer to hold normalized guid string.  Must be at least
165  *		17 chars long.
166  *    buflen	Length of provided buffer
167  *    int_guid	Optional.  If not NULL, the integer form of the GUID will also
168  *		be returned.
169  * Return Values:
170  *    0		Success
171  *    EINVAL	Invalid HCA GUID or invalid parameter.
172  */
173 int
174 srpt_NormalizeGuid(char *in, char *buf, size_t buflen, uint64_t *int_guid);
175 
176 #ifdef	__cplusplus
177 }
178 #endif
179 
180 #endif	/* _LIBSRPT_H */
181