1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _WRSM_COMMON_H
#define _WRSM_COMMON_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/param.h>
#include <sys/types.h>
#include <sys/dditypes.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/thread.h>
#include <sys/kstat.h>
#ifdef _KERNEL
#include <vm/page.h>
#include <sys/ddidevmap.h>
#include <sys/rsm/rsmpi.h>
#endif
#include <sys/wci_offsets.h>
#include <sys/wrsm_types.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef wrsm_ncslice_bitmask_t ncslice_bitmask_t;
typedef wrsm_cnode_bitmask_t cnode_bitmask_t;
typedef wrsm_wnode_bitmask_t wnode_bitmask_t;
typedef wrsm_fmnodeid_t fmnodeid_t;
typedef wrsm_cnodeid_t cnodeid_t;
typedef wrsm_wnodeid_t wnodeid_t;
typedef wrsm_gnid_t gnid_t;
typedef wrsm_ncslice_t ncslice_t;
typedef wrsm_linkid_t linkid_t;
typedef wrsm_safari_port_t safari_port_t;
/*
* Cacheline-size related constants
*/
#define WRSM_CACHELINE_SIZE 64
#define WRSM_CACHELINE_SHIFT 6
#define WRSM_CACHELINE_MASK (WRSM_CACHELINE_SIZE - 1)
/*
* This is a more meaningful name for the errno return value of 0. It
* is used by functions that return/expect errno values.
*/
#define WRSM_SUCCESS 0
/*
* Hash for fmnodeid to node pointer mapping.
* Most likely the fmnodeid will be a low integer.
*/
#define WRSM_CNODE_HASH_SIZE 0x100 /* number of entries in hash table */
#define WRSM_CNODE_HASH_MASK (WRSM_CNODE_HASH_SIZE - 1)
#define WRSM_CNODE_HASH_FUNC(r) \
(((uint_t)r) & WRSM_CNODE_HASH_MASK)
/*
* 8 is the lower bound allowed before we are required to start freezing
* Request Agent (RAG) instances per PRM
*/
#define WRSM_RAG_FREEZE_NODE_LIMIT 8
/*
* additional bit mask manipulation macros
*/
uint_t wrsmset_cmp(uint32_t *s1, uint32_t *s2, int masksize);
uint_t wrsmset_isnull(uint32_t *s, int masksize);
/* Copy bits from set1 to set2 */
#define WRSMSET_COPY(src, dest) bcopy(&(src), &(dest), sizeof (src))
#define WRSMSET_ISEQUAL(set1, set2) \
(wrsmset_cmp((uint32_t *)&(set1), (uint32_t *)&(set2), \
WRSMMASKSIZE(set1)))
#define WRSMSET_ISNULL(set) \
(wrsmset_isnull((uint32_t *)&(set), WRSMMASKSIZE(set)))
#define WRSMSET_OR(set1, set2) { \
int _i; \
uint32_t *_s1 = (uint32_t *)&(set1); \
uint32_t *_s2 = (uint32_t *)&(set2); \
for (_i = 0; _i < WRSMMASKSIZE(set1); _i++) \
*_s1++ |= *_s2++; \
}
#define WRSMSET_AND(set1, set2) { \
int _i; \
uint32_t *_s1 = (uint32_t *)&(set1); \
uint32_t *_s2 = (uint32_t *)&(set2); \
for (_i = 0; _i < WRSMMASKSIZE(set1); _i++) \
*_s1++ &= *_s2++; \
}
#define WRSMSET_DIFF(set1, set2) { \
int _i; \
uint32_t *_s1 = (uint32_t *)&(set1); \
uint32_t *_s2 = (uint32_t *)&(set2); \
for (_i = 0; _i < WRSMMASKSIZE(set1); _i++) \
*_s1++ &= ~*_s2++; \
}
/*
* in the node->link_stripes field, this is the number of bits to
* shift to get to the bit referring to the next link in the same wci
*/
#define BBIT_LINK_STRIDE 4
/* opaque type for LC's handle */
typedef struct wrsm_soft_state *lcwci_handle_t;
/* opaque type for NC's handle */
typedef struct wrsm_ncwci *ncwci_handle_t;
/*
* typedefs for opaque structure definitions (for structures private to
* particular wrsm modules, declared in module specific header files)
*/
typedef struct wrsm_node_routeinfo wrsm_node_routeinfo_t;
typedef struct wrsm_node_memseg wrsm_node_memseg_t;
typedef struct wrsm_transport wrsm_transport_t;
typedef struct wrsm_session wrsm_session_t;
typedef struct wrsm_cmmu_alloc wrsm_cmmu_alloc_t;
typedef struct wrsm_interrupt wrsm_interrupt_t;
typedef struct wrsm_nr wrsm_nr_t;
typedef struct wrsm_memseg wrsm_memseg_t;
typedef struct __rsm_controller_handle wrsm_network_t;
typedef struct wrsm_node wrsm_node_t;
typedef struct wrsm_cmmu_tuple wrsm_cmmu_tuple_t;
/*
* configuration states
*/
typedef enum {
wrsm_disabled, /* new config, no ncslice rerouting allowed */
wrsm_pending, /* can reroute using old/new config intersection */
wrsm_installed, /* ncslice routes are not using old config */
wrsm_installed_up, /* all links in new config are up */
wrsm_enabled /* ncslice routes are using new config */
} wrsm_availability_t;
#define WRSM_INSTALLED(n) \
((n)->availability == wrsm_enabled || \
(n)->availability == wrsm_installed || \
(n)->availability == wrsm_installed_up)
/*
* state of communication to node
*/
typedef enum {
wrsm_node_needroute, /* no ncslice routes to node */
wrsm_node_haveroute /* ncslice route set up */
} wrsm_node_comm_state_t;
#define WRSM_NODE_HAVE_ROUTE(n) ((n)->state == wrsm_node_haveroute)
/*
* information about a remote node participating in an RSM network
*/
struct wrsm_node {
wrsm_network_t *network; /* this node's RSM network */
wrsm_net_member_t *config; /* node config info */
wrsm_availability_t availability; /* configuration state */
wrsm_node_comm_state_t state; /* communication state */
uint32_t *link_stripesp; /* stripe info for barrier */
/*
* wrsm module private info about node
*/
wrsm_node_routeinfo_t *routeinfo; /* routing config for node */
/*
* The following structures are for tracking RSMPI data structures.
*/
wrsm_node_memseg_t *memseg; /* RSMPI segments */
caddr_t cesr_vaddr; /* vaddr of WCI CESRs for barriers */
caddr_t lockout_vaddr; /* vaddr of write lockout page */
/*
* links
*/
struct wrsm_node *hash; /* linked list for hash table */
};
/*
* The RSM controller's view of the RSM network it is participating in.
*/
#ifdef _KERNEL
struct __rsm_controller_handle {
uint32_t rsm_ctlr_id; /* ctlr id == device instance # */
kmutex_t lock;
dev_info_t *dip; /* dev_info_t for controller */
uint64_t version_stamp; /* configuration version number */
boolean_t registered; /* registered with RSMPI module */
wrsm_availability_t availability; /* state of the configuration */
cnodeid_t cnodeid; /* local node's cnodeid */
wrsm_node_t *mynode; /* local node info */
wrsm_node_ncslice_array_t exported_ncslices;
/* ncslices local node exports */
int wrsm_ncslice_users[WRSM_MAX_NCSLICES];
/* per ncslice count of ncslice users */
boolean_t have_lg_page_ncslice; /* any ncslices for large pages? */
wrsm_cmmu_tuple_t *errorpage_tuple; /* loopback error CMMU entry */
pfn_t errorpage_pfn; /* pfn for loopback error page */
kmutex_t errorpage_lock; /* updating errorpage_mappings */
uint_t errorpage_mappings; /* # mappings to error page */
wrsm_node_t *nodes[WRSM_MAX_CNODES]; /* array of remote node info */
wrsm_node_t *node_hash[WRSM_CNODE_HASH_SIZE]; /* nodeinfo hashtable */
/*
* route_umem is the kernel allocated address space that
* can also be mapped to user space. both route_countp
* and reroutingp will point to an address range within
* route_umem. the wrsm plug-in uses this address range
* when it mmaps route_counter and rerouting to user space
* the plug-in requires these fields when it must preform
* explicit barriers, as the plugin must check to see if the
* routing has changed.
*/
void *route_umem; /* returned by ddi_umem_alloc */
uint32_t *route_counterp; /* increment on ncslice route change */
uint32_t *reroutingp; /* in process of ncslice rerouting */
ddi_umem_cookie_t route_cookie; /* cookie needed to free *route_umem */
uint_t passthrough_routes; /* how many PT routes been set up? */
/* keeps track of controller opened by plugin library */
boolean_t is_controller_open;
/*
* wrsm module private info about network
*/
wrsm_interrupt_t *interrupt;
wrsm_transport_t *transport; /* transport info */
wrsm_session_t *session; /* session info */
wrsm_cmmu_alloc_t *cmmu; /* cmmu allocator info */
wrsm_nr_t *nr; /* network router info */
int wrsm_num_nodes; /* number of nodes in this network */
boolean_t free_rag_instance; /* frozen RAG instances can be freed */
/*
* NC info
*/
boolean_t auto_enable; /* links-up/timeout enables network */
timeout_id_t enable_timeout_id;
/*
* links
*/
wrsm_network_t *next;
/*
* RSMPI information
*/
wrsm_memseg_t *memseg; /* RSMPI segments */
rsm_controller_attr_t attr; /* RSMPI controller attributes */
/*
* Kstat for the controller
*/
kstat_t *wrsm_rsmpi_stat_ksp;
uint_t num_reconfigs;
uint_t sendqs_num;
uint_t handler_num;
};
#endif /* KERNEL */
extern dev_info_t *wrsm_ncslice_dip; /* devinfo for ncslice mappings */
#define PROTOCOLS_SUPPORTED 1
/*
* The protocol_versions_supported is a bit mask representing all the
* protocol versions that this driver supports.
*/
extern uint32_t protocol_versions_supported;
extern int protocol_version; /* version native to this driver */
wrsm_node_t *
wrsm_fmnodeid_to_node(wrsm_network_t *network,
fmnodeid_t fmnodeid);
int
wrsm_fmnodeid_to_cnodeid(wrsm_network_t *network,
fmnodeid_t fmnodeid, cnodeid_t *cnodeidp);
wrsm_network_t *wrsm_dip_to_network(dev_info_t *dip);
/*
* initialization and teardown functions for WRSM modules - called from
* driver _init and _fini
*/
extern void wrsm_nc_init(void);
extern int wrsm_nc_fini(void);
/*
* Functions which make up wrsm_nc_fini() - these can be called individually
* to separate checks from cleanup - called from driver _fini
*/
extern int wrsm_nc_check(void);
extern void wrsm_nc_cleanup(void);
#ifdef DEBUG
#define DEBUG_LOG
extern void dprintnodes(cnode_bitmask_t);
#define DPRINTNODES(c) dprintnodes(c)
extern kmutex_t wrsmdbglock;
extern int wrsmdbginit;
extern char wrsmdbgbuf[];
extern int wrsmdbgsize;
extern int wrsmdbgnext;
void wrsmdprintf(int ce, const char *fmt, ...);
#else
#define DPRINTNODES(c)
#endif
#ifdef __cplusplus
}
#endif
#endif /* _WRSM_COMMON_H */
|