2 * Copyright (c) 2008 Lawrence Livermore National Laboratory
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 /** =========================================================================
35 * Define the internal data structures.
41 #include <infiniband/ibnetdisc.h>
42 #include <complib/cl_qmap.h>
44 #define IBND_DEBUG(fmt, ...) \
46 printf("%s:%u; " fmt, __FILE__, __LINE__, ## __VA_ARGS__); \
48 #define IBND_ERROR(fmt, ...) \
49 fprintf(stderr, "%s:%u; " fmt, __FILE__, __LINE__, ## __VA_ARGS__)
51 /* HASH table defines */
52 #define HASHGUID(guid) ((uint32_t)(((uint32_t)(guid) * 101) ^ ((uint32_t)((guid) >> 32) * 103)))
56 #define DEFAULT_MAX_SMP_ON_WIRE 2
57 #define DEFAULT_TIMEOUT 1000
58 #define DEFAULT_RETRIES 3
60 #define GINT_TO_POINTER(x) ((void *)(uintptr_t)(x))
62 typedef struct GHashTable GHashTable;
64 #define g_hash_table_new_full(...) GHashTableNew()
65 #define g_hash_table_destroy(...) GHashTableDestroy(__VA_ARGS__)
66 #define g_hash_table_insert(...) GHashTableInsert(__VA_ARGS__)
67 #define g_hash_table_lookup(...) GHashTableLookup(__VA_ARGS__)
69 extern GHashTable *GHashTableNew(void);
70 extern void GHashTableDestroy(GHashTable *);
71 extern void GHashTableInsert(GHashTable *, void *key, void *value);
72 extern void *GHashTableLookup(GHashTable *, void *key);
74 typedef struct f_internal {
78 f_internal_t *allocate_fabric_internal(void);
79 void create_lid2guid(f_internal_t *f_int);
80 void destroy_lid2guid(f_internal_t *f_int);
81 void add_to_portlid_hash(ibnd_port_t * port, GHashTable *htable);
83 typedef struct ibnd_scan {
84 ib_portid_t selfportid;
86 struct ibnd_config *cfg;
87 unsigned initial_hops;
90 typedef struct ibnd_smp ibnd_smp_t;
91 typedef struct smp_engine smp_engine_t;
92 typedef int (*smp_comp_cb_t) (smp_engine_t * engine, ibnd_smp_t * smp,
93 uint8_t * mad_resp, void *cb_data);
95 cl_map_item_t on_wire;
96 struct ibnd_smp *qnext;
107 ibnd_smp_t *smp_queue_head;
108 ibnd_smp_t *smp_queue_tail;
110 cl_qmap_t smps_on_wire;
111 struct ibnd_config *cfg;
115 int smp_engine_init(smp_engine_t * engine, char * ca_name, int ca_port,
116 void *user_data, ibnd_config_t *cfg);
117 int issue_smp(smp_engine_t * engine, ib_portid_t * portid,
118 unsigned attrid, unsigned mod, smp_comp_cb_t cb, void *cb_data);
119 int process_mads(smp_engine_t * engine);
120 void smp_engine_destroy(smp_engine_t * engine);
122 int add_to_nodeguid_hash(ibnd_node_t * node, ibnd_node_t * hash[]);
124 int add_to_portguid_hash(ibnd_port_t * port, ibnd_port_t * hash[]);
126 void add_to_type_list(ibnd_node_t * node, f_internal_t * fabric);
128 void destroy_node(ibnd_node_t * node);
130 #endif /* _INTERNAL_H_ */