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.
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:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
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.
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
36 /****h* OpenSM/DB-Pack
41 * This module provides packing and unpacking of the database
42 * storage into specific types.
44 * The following domains/conversions are supported:
45 * guid2lid - key is a guid and data is a lid.
48 * Eitan Zahavi, Mellanox Technologies LTD
52 #ifndef _OSM_DB_PACK_H_
53 #define _OSM_DB_PACK_H_
55 #include <opensm/osm_db.h>
58 # define BEGIN_C_DECLS extern "C" {
59 # define END_C_DECLS }
60 #else /* !__cplusplus */
61 # define BEGIN_C_DECLS
63 #endif /* __cplusplus */
66 /****f* OpenSM: DB-Pack/osm_db_guid2lid_init
68 * osm_db_guid2lid_init
71 * Initialize a domain for the guid2lid table
75 static inline osm_db_domain_t *osm_db_guid2lid_init(IN osm_db_t * const p_db)
77 return (osm_db_domain_init(p_db, "guid2lid"));
83 * [in] Pointer to the database object to construct
86 * The pointer to the new allocated domain object or NULL.
88 * NOTE: DB domains are destroyed by the osm_db_destroy
91 * Database, osm_db_init, osm_db_destroy
94 /****f* OpenSM: DB-Pack/osm_db_guid2lid_init
96 * osm_db_guid2lid_init
99 * Initialize a domain for the guid2lid table
103 typedef struct osm_db_guid_elem {
106 } osm_db_guid_elem_t;
110 * required for list manipulations
116 /****f* OpenSM: DB-Pack/osm_db_guid2lid_guids
118 * osm_db_guid2lid_guids
121 * Provides back a list of guid elements.
126 osm_db_guid2lid_guids(IN osm_db_domain_t * const p_g2l,
127 OUT cl_qlist_t * p_guid_list);
131 * [in] Pointer to the guid2lid domain
134 * [out] A quick list of guid elements of type osm_db_guid_elem_t
139 * NOTE: the output qlist should be initialized and each item freed
140 * by the caller, then destroyed.
143 * osm_db_guid2lid_init, osm_db_guid2lid_guids, osm_db_guid2lid_get
144 * osm_db_guid2lid_set, osm_db_guid2lid_delete
147 /****f* OpenSM: DB-Pack/osm_db_guid2lid_get
149 * osm_db_guid2lid_get
152 * Get a lid range by given guid.
157 osm_db_guid2lid_get(IN osm_db_domain_t * const p_g2l,
159 OUT uint16_t * p_min_lid, OUT uint16_t * p_max_lid);
163 * [in] Pointer to the guid2lid domain
166 * [in] The guid to look for
169 * [out] Pointer to the resulting min lid in host order.
172 * [out] Pointer to the resulting max lid in host order.
175 * 0 if successful. The lid will be set to 0 if not found.
178 * osm_db_guid2lid_init, osm_db_guid2lid_guids
179 * osm_db_guid2lid_set, osm_db_guid2lid_delete
182 /****f* OpenSM: DB-Pack/osm_db_guid2lid_set
184 * osm_db_guid2lid_set
187 * Set a lid range for the given guid.
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);
197 * [in] Pointer to the guid2lid domain
200 * [in] The guid to look for
203 * [in] The min lid value to set
206 * [in] The max lid value to set
212 * osm_db_guid2lid_init, osm_db_guid2lid_guids
213 * osm_db_guid2lid_get, osm_db_guid2lid_delete
216 /****f* OpenSM: DB-Pack/osm_db_guid2lid_delete
218 * osm_db_guid2lid_delete
221 * Delete the entry by the given guid
225 int osm_db_guid2lid_delete(IN osm_db_domain_t * const p_g2l, IN uint64_t guid);
229 * [in] Pointer to the guid2lid domain
232 * [in] The guid to look for
235 * 0 if successful otherwise 1
238 * osm_db_guid2lid_init, osm_db_guid2lid_guids
239 * osm_db_guid2lid_get, osm_db_guid2lid_set
243 #endif /* _OSM_DB_PACK_H_ */