1 /*
2 * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 *
34 */
35
36 /****h* OpenSM/DB-Pack
37 * NAME
38 * Database Types
39 *
40 * DESCRIPTION
41 * This module provides packing and unpacking of the database
42 * storage into specific types.
43 *
44 * The following domains/conversions are supported:
45 * guid2lid - key is a guid and data is a lid.
46 *
47 * AUTHOR
48 * Eitan Zahavi, Mellanox Technologies LTD
49 *
50 *********/
51
52 #ifndef _OSM_DB_PACK_H_
53 #define _OSM_DB_PACK_H_
54
55 #include <opensm/osm_db.h>
56
57 #ifdef __cplusplus
58 # define BEGIN_C_DECLS extern "C" {
59 # define END_C_DECLS }
60 #else /* !__cplusplus */
61 # define BEGIN_C_DECLS
62 # define END_C_DECLS
63 #endif /* __cplusplus */
64
65 BEGIN_C_DECLS
66 /****f* OpenSM: DB-Pack/osm_db_guid2lid_init
67 * NAME
68 * osm_db_guid2lid_init
69 *
70 * DESCRIPTION
71 * Initialize a domain for the guid2lid table
72 *
73 * SYNOPSIS
74 */
osm_db_guid2lid_init(IN osm_db_t * const p_db)75 static inline osm_db_domain_t *osm_db_guid2lid_init(IN osm_db_t * const p_db)
76 {
77 return (osm_db_domain_init(p_db, "guid2lid"));
78 }
79
80 /*
81 * PARAMETERS
82 * p_db
83 * [in] Pointer to the database object to construct
84 *
85 * RETURN VALUES
86 * The pointer to the new allocated domain object or NULL.
87 *
88 * NOTE: DB domains are destroyed by the osm_db_destroy
89 *
90 * SEE ALSO
91 * Database, osm_db_init, osm_db_destroy
92 *********/
93
94 /****f* OpenSM: DB-Pack/osm_db_guid2lid_init
95 * NAME
96 * osm_db_guid2lid_init
97 *
98 * DESCRIPTION
99 * Initialize a domain for the guid2lid table
100 *
101 * SYNOPSIS
102 */
103 typedef struct osm_db_guid_elem {
104 cl_list_item_t item;
105 uint64_t guid;
106 } osm_db_guid_elem_t;
107 /*
108 * FIELDS
109 * item
110 * required for list manipulations
111 *
112 * guid
113 *
114 ************/
115
116 /****f* OpenSM: DB-Pack/osm_db_guid2lid_guids
117 * NAME
118 * osm_db_guid2lid_guids
119 *
120 * DESCRIPTION
121 * Provides back a list of guid elements.
122 *
123 * SYNOPSIS
124 */
125 int
126 osm_db_guid2lid_guids(IN osm_db_domain_t * const p_g2l,
127 OUT cl_qlist_t * p_guid_list);
128 /*
129 * PARAMETERS
130 * p_g2l
131 * [in] Pointer to the guid2lid domain
132 *
133 * p_guid_list
134 * [out] A quick list of guid elements of type osm_db_guid_elem_t
135 *
136 * RETURN VALUES
137 * 0 if successful
138 *
139 * NOTE: the output qlist should be initialized and each item freed
140 * by the caller, then destroyed.
141 *
142 * SEE ALSO
143 * osm_db_guid2lid_init, osm_db_guid2lid_guids, osm_db_guid2lid_get
144 * osm_db_guid2lid_set, osm_db_guid2lid_delete
145 *********/
146
147 /****f* OpenSM: DB-Pack/osm_db_guid2lid_get
148 * NAME
149 * osm_db_guid2lid_get
150 *
151 * DESCRIPTION
152 * Get a lid range by given guid.
153 *
154 * SYNOPSIS
155 */
156 int
157 osm_db_guid2lid_get(IN osm_db_domain_t * const p_g2l,
158 IN uint64_t guid,
159 OUT uint16_t * p_min_lid, OUT uint16_t * p_max_lid);
160 /*
161 * PARAMETERS
162 * p_g2l
163 * [in] Pointer to the guid2lid domain
164 *
165 * guid
166 * [in] The guid to look for
167 *
168 * p_min_lid
169 * [out] Pointer to the resulting min lid in host order.
170 *
171 * p_max_lid
172 * [out] Pointer to the resulting max lid in host order.
173 *
174 * RETURN VALUES
175 * 0 if successful. The lid will be set to 0 if not found.
176 *
177 * SEE ALSO
178 * osm_db_guid2lid_init, osm_db_guid2lid_guids
179 * osm_db_guid2lid_set, osm_db_guid2lid_delete
180 *********/
181
182 /****f* OpenSM: DB-Pack/osm_db_guid2lid_set
183 * NAME
184 * osm_db_guid2lid_set
185 *
186 * DESCRIPTION
187 * Set a lid range for the given guid.
188 *
189 * SYNOPSIS
190 */
191 int
192 osm_db_guid2lid_set(IN osm_db_domain_t * const p_g2l,
193 IN uint64_t guid, IN uint16_t min_lid, IN uint16_t max_lid);
194 /*
195 * PARAMETERS
196 * p_g2l
197 * [in] Pointer to the guid2lid domain
198 *
199 * guid
200 * [in] The guid to look for
201 *
202 * min_lid
203 * [in] The min lid value to set
204 *
205 * max_lid
206 * [in] The max lid value to set
207 *
208 * RETURN VALUES
209 * 0 if successful
210 *
211 * SEE ALSO
212 * osm_db_guid2lid_init, osm_db_guid2lid_guids
213 * osm_db_guid2lid_get, osm_db_guid2lid_delete
214 *********/
215
216 /****f* OpenSM: DB-Pack/osm_db_guid2lid_delete
217 * NAME
218 * osm_db_guid2lid_delete
219 *
220 * DESCRIPTION
221 * Delete the entry by the given guid
222 *
223 * SYNOPSIS
224 */
225 int osm_db_guid2lid_delete(IN osm_db_domain_t * const p_g2l, IN uint64_t guid);
226 /*
227 * PARAMETERS
228 * p_g2l
229 * [in] Pointer to the guid2lid domain
230 *
231 * guid
232 * [in] The guid to look for
233 *
234 * RETURN VALUES
235 * 0 if successful otherwise 1
236 *
237 * SEE ALSO
238 * osm_db_guid2lid_init, osm_db_guid2lid_guids
239 * osm_db_guid2lid_get, osm_db_guid2lid_set
240 *********/
241
242 END_C_DECLS
243 #endif /* _OSM_DB_PACK_H_ */
244