2
* Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
4
* This file is part of ibsim.
6
* ibsim is available to you under a choice of one of two licenses.
7
* 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
38
#include <infiniband/common.h>
39
#include <infiniband/mad.h>
41
#define MAXNETNODES 2048
42
#define MAXNETSWITCHS 256
43
#define MAXNETPORTS (MAXNETSWITCHS*36+MAXNETNODES*2)
44
#define MAXNETALIASES MAXNETPORTS
46
#define MAXLINEARCAP (30*1024)
47
#define MAXMCASTCAP 1024
48
#define LASTBLOCK32 (MAXMCASTCAP/32-1)
49
// NUMBEROFPORTMASK means that 32port switches could only be build
50
#define NUMBEROFPORTMASK 2
51
#define LASTPORTMASK (NUMBEROFPORTMASK-1)
52
// linkwidth == 4X - must be one width only 1,2 or 8
53
#define LINKWIDTH_1x 1
54
#define LINKWIDTH_4x 2
55
#define LINKWIDTH_8x 4
56
#define LINKWIDTH_12x 8
57
#define LINKWIDTH_1x_4x 3
58
#define LINKWIDTH_1x_4x_12x 11
60
#define LINKSPEED_SDR 1
61
#define LINKSPEED_DDR 2
62
#define LINKSPEED_QDR 4
63
#define LINKSPEED_SDR_DDR 3
65
#define DEFAULT_LINKWIDTH LINKWIDTH_4x
66
#define DEFAULT_LINKSPEED LINKSPEED_SDR
90
/* some PortInfo capmask fields */
91
enum PORTINFO_CAPMASK {
92
CAPMASK_ISSM = (1<<1),
93
CAPMASK_ISNOTICE = (1<<2),
94
CAPMASK_ISTRAP = (1<<3),
95
CAPMASK_ISCAPMASKTRAP = (1<<22),
98
enum GS_PERF_COUNTER_SELECT_MASK {
99
GS_PERF_ERR_SYM_MASK = (1UL << 0), // SYMBOL_ERROR_COUNTER
100
GS_PERF_LINK_RECOVERS_MASK = (1UL << 1), // LINK_ERROR_RECOVERY_COUNTER
101
GS_PERF_LINK_DOWNED_MASK = (1UL << 2), // LINK_DOWNED_COUNTER
102
GS_PERF_ERR_RCV_MASK = (1UL << 3), // PORT_RCV_ERRORS
103
GS_PERF_ERR_PHYSRCV_MASK = (1UL << 4), // PORT_RCV_REMOTE_PHYSICAL_ERRORS
104
GS_PERF_ERR_SWITCH_REL_MASK = (1UL << 5), // PORT_RCV_SWITCH_RELAY_ERRORS
105
GS_PERF_XMT_DISCARDS_MASK = (1UL << 6), // PORT_XMIT_DISCARDS
106
GS_PERF_ERR_XMTCONSTR_MASK = (1UL << 7), // PORT_XMIT_CONSTRAINT_ERRORS
107
GS_PERF_ERR_RCVCONSTR_MASK = (1UL << 8), // PORT_RCV_CONSTRAINT_ERRORS
108
GS_PERF_ERR_LOCALINTEG_MASK = (1UL << 9), // LOCAL_LINK_INTEGRITY_ERRORS
109
GS_PERF_ERR_EXCESS_OVR_MASK = (1UL << 10), // EXCESSIVE_BUFFER_OVERRUN_ERRORS
110
GS_PERF_VL15_DROPPED_MASK = (1UL << 11),
111
GS_PERF_XMT_BYTES_MASK = (1UL << 12), // PORT_XMIT_DATA
112
GS_PERF_RCV_BYTES_MASK = (1UL << 13), // PORT_RCV_DATA
113
GS_PERF_XMT_PKTS_MASK = (1UL << 14), // PORT_XMIT_PKTS
114
GS_PERF_RCV_PKTS_MASK = (1UL << 15), // PORT_RCV_PKTS
117
enum GS_PC_EXT_SELECT_MASK {
118
GS_PC_EXT_XMIT_DATA = 1 << 0,
119
GS_PC_EXT_RECV_DATA = 1 << 1,
120
GS_PC_EXT_XMIT_PKTS = 1 << 2,
121
GS_PC_EXT_RECV_PKTS = 1 << 3,
122
GS_PC_EXT_UCAST_XMIT = 1 << 4,
123
GS_PC_EXT_UCAST_RECV = 1 << 5,
124
GS_PC_EXT_MCAST_XMIT = 1 << 6,
125
GS_PC_EXT_MCAST_RECV = 1 << 7,
128
enum GS_PERF_COUNTER_SELECT_LIMIT {
129
GS_PERF_ERR_SYM_LIMIT = 0xffff,
130
GS_PERF_LINK_RECOVERS_LIMIT = 0xff,
131
GS_PERF_LINK_DOWNED_LIMIT = 0xff,
132
GS_PERF_ERR_RCV_LIMIT = 0xffff,
133
GS_PERF_ERR_PHYSRCV_LIMIT = 0xffff,
134
GS_PERF_ERR_SWITCH_REL_LIMIT = 0xffff,
135
GS_PERF_XMT_DISCARDS_LIMIT = 0xffff,
136
GS_PERF_ERR_XMTCONSTR_LIMIT = 0xff,
137
GS_PERF_ERR_RCVCONSTR_LIMIT = 0xff,
138
GS_PERF_ERR_LOCALINTEG_LIMIT = 0xf,
139
GS_PERF_ERR_EXCESS_OVR_LIMIT = 0xf,
140
GS_PERF_VL15_DROPPED_LIMIT = 0xffff,
141
GS_PERF_XMT_BYTES_LIMIT = 0xffffffff,
142
GS_PERF_RCV_BYTES_LIMIT = 0xffffffff,
143
GS_PERF_XMT_PKTS_LIMIT = 0xffffffff,
144
GS_PERF_RCV_PKTS_LIMIT = 0xffffffff,
147
typedef struct Port Port;
148
typedef struct Portinfo Portinfo;
149
typedef struct Switch Switch;
150
typedef struct Nodeinfo Nodeinfo;
151
typedef struct Node Node;
152
typedef struct Client Client;
153
typedef struct Portcounters Portcounters;
161
struct Portcounters {
162
uint64_t ext_xmit_data;
163
uint64_t ext_recv_data;
164
uint64_t ext_xmit_pkts;
165
uint64_t ext_recv_pkts;
166
uint64_t ext_ucast_xmit;
167
uint64_t ext_ucast_recv;
168
uint64_t ext_mcast_xmit;
169
uint64_t ext_mcast_recv;
170
uint32_t flow_xmt_pkts;
171
uint32_t flow_xmt_bytes;
172
uint32_t flow_rcv_pkts;
173
uint32_t flow_rcv_bytes;
174
uint16_t xmitdiscards;
175
uint16_t vl15dropped;
176
uint16_t linkrecovers;
180
uint8_t errs_localinteg;
181
uint16_t errs_remphysrcv;
182
uint8_t errs_xmtconstraint;
183
uint8_t errs_rcvconstraint;
184
uint16_t errs_rcvswitchrelay;
185
uint8_t errs_excessbufovrrun;
202
uint8_t portinfo[64];
204
char remotenodeid[NODEIDLEN];
205
char remotealias[ALIASLEN + 1];
206
char alias[ALIASLEN + 1];
209
Node *previous_remotenode;
210
int previous_remoteport;
214
Portcounters portcounters;
220
} vlarb_high[64], vlarb_low[64];
230
uint8_t switchinfo[64];
240
uint64_t nodeguid; // also portguid
241
int portsbase; // in port table
242
char nodeid[NODEIDLEN]; // contain nodeid[NODEIDLEN]
243
uint8_t nodeinfo[64];
246
Client *clist; // client list
263
int list_connections(FILE * out);
264
Client *find_client(Port * port, int response, int qp, uint64_t trid);
265
int disconnect_client(int id);
268
Node *find_node(char *desc);
269
Node *find_node_by_desc(char *desc);
270
Node *find_node_by_guid(uint64_t guid);
271
const char *node_type_name(unsigned type);
272
Port *node_get_port(Node * node, int portnum);
273
void reset_port(Port * port);
274
int link_ports(Port * lport, Port * rport);
275
void update_portinfo(Port * p);
276
int build_net(char *netconf);
277
int connect_ports(void);
278
char *expand_name(char *base, char *name, char **portstr);
279
int read_netconf(char *name, FILE * out);
280
int set_default_port(char *nodeid);
281
int readline(int fd, char *buf, int sz);
284
int do_cmd(char *buf, FILE *f);
285
int sim_cmd_file(FILE * file, char *line);
286
void *sim_cmd_thread(void *file);
289
int process_packet(Client * cl, void *p, int size, Client ** dcl);
290
int send_trap(Port * port, int trapnum);
292
extern Port *default_port;
293
extern int simverb, modified;
294
extern int netstarted;
296
#endif /* __SIM_H__ */