~ubuntu-branches/ubuntu/raring/ibutils/raring-proposed

« back to all changes in this revision

Viewing changes to ibmgtsim/src/mads.i

  • Committer: Bazaar Package Importer
  • Author(s): Benoit Mortier
  • Date: 2010-01-11 22:22:00 UTC
  • Revision ID: james.westby@ubuntu.com-20100111222200-53kum2et5nh13rv3
Tags: upstream-1.2-OFED-1.4.2
ImportĀ upstreamĀ versionĀ 1.2-OFED-1.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2004 Mellanox Technologies LTD. All rights reserved.
 
3
 *
 
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:
 
9
 *
 
10
 *     Redistribution and use in source and binary forms, with or
 
11
 *     without modification, are permitted provided that the following
 
12
 *     conditions are met:
 
13
 *
 
14
 *      - Redistributions of source code must retain the above
 
15
 *        copyright notice, this list of conditions and the following
 
16
 *        disclaimer.
 
17
 *
 
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.
 
22
 *
 
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
 
30
 * SOFTWARE.
 
31
 *
 
32
 * $Id$
 
33
 */
 
34
 
 
35
/*
 
36
 * MADS INTERFACE: Provide means for dispatching mads into the simulator
 
37
 */
 
38
 
 
39
%{
 
40
  /* the following code will place the mad into the dispatcher */
 
41
  int
 
42
    send_mad(
 
43
      IBMSNode *pFromNode,
 
44
      uint8_t   fromPort,
 
45
      uint16_t  destLid,
 
46
      uint8_t   mgmt_class,
 
47
      uint8_t   method,
 
48
      uint16_t  attr,
 
49
      uint32_t  attr_mod,
 
50
      uint8_t  *data,
 
51
      size_t    size)
 
52
    {
 
53
      ibms_mad_msg_t msg;
 
54
      IBPort *pPort;
 
55
      static uint64_t tid = 19927;
 
56
 
 
57
      /* initialize the message address vector */
 
58
      msg.addr.sl = 0;
 
59
      msg.addr.pkey_index = 0;
 
60
      msg.addr.dlid = destLid;
 
61
      msg.addr.sqpn = 0;
 
62
      msg.addr.dqpn = 0;
 
63
 
 
64
      pPort = pFromNode->getIBNode()->getPort(fromPort);
 
65
      if (! pPort)
 
66
      {
 
67
        cout << "-E- Given port:" << fromPort << " is down." << endl;
 
68
        return 1;
 
69
      }
 
70
      msg.addr.slid = pPort->base_lid;
 
71
 
 
72
      /* initialize the mad header */
 
73
      msg.header.base_ver = 1;
 
74
      msg.header.mgmt_class = mgmt_class;
 
75
      msg.header.class_ver = 1;
 
76
      msg.header.method = method;
 
77
      msg.header.status = 0;
 
78
      msg.header.class_spec = 0;
 
79
      msg.header.trans_id = tid++;
 
80
      msg.header.attr_id = cl_hton16(attr);
 
81
      msg.header.attr_mod = cl_hton32(attr_mod);
 
82
 
 
83
      memcpy(msg.payload, data, size);
 
84
      IBMSDispatcher *pDispatcher = Simulator.getDispatcher();
 
85
      if (! pDispatcher )
 
86
        return TCL_ERROR;
 
87
 
 
88
      return pDispatcher->dispatchMad(pFromNode, fromPort, msg);
 
89
    }
 
90
 
 
91
  int send_sa_mad(
 
92
    IBMSNode *pFromNode,
 
93
    uint8_t   fromPort,
 
94
    uint16_t  destLid,
 
95
    uint8_t   mgmt_class,
 
96
    uint8_t   method,
 
97
    uint16_t  attr,
 
98
    uint64_t  comp_mask,
 
99
    uint8_t  *sa_data,
 
100
    size_t    sa_data_size)
 
101
    {
 
102
      ib_sa_mad_t mad = {0}; /* includes std header and rmpp header */
 
103
 
 
104
      mad.attr_offset = ib_get_attr_offset(sa_data_size);
 
105
      mad.comp_mask = cl_hton64(comp_mask);
 
106
      memcpy(mad.data, sa_data, sa_data_size);
 
107
 
 
108
      return send_mad(
 
109
        pFromNode,
 
110
        fromPort,
 
111
        destLid,
 
112
        mgmt_class,
 
113
        method,
 
114
        attr,
 
115
        0,
 
116
        &mad.rmpp_version,
 
117
        MAD_RMPP_DATA_SIZE + 12);
 
118
    }
 
119
 
 
120
%}
 
121
 
 
122
%{
 
123
#define madMcMemberRec ib_member_rec_t
 
124
%}
 
125
 
 
126
struct madMcMemberRec
 
127
{
 
128
  madMcMemberRec();
 
129
  ~madMcMemberRec();
 
130
 
 
131
  ib_gid_t                              mgid;
 
132
  ib_gid_t                              port_gid;
 
133
  ib_net32_t                    qkey;
 
134
  ib_net16_t                    mlid;
 
135
  uint8_t                               mtu;
 
136
  uint8_t                               tclass;
 
137
  ib_net16_t                    pkey;
 
138
  uint8_t                               rate;
 
139
  uint8_t                               pkt_life;
 
140
  ib_net32_t                    sl_flow_hop;
 
141
  uint8_t                               scope_state;
 
142
  //  uint8_t                           proxy_join;  hard to get as it is defined as bit field
 
143
}
 
144
 
 
145
%addmethods madMcMemberRec {
 
146
  int send_set(
 
147
    IBMSNode *pFromNode,
 
148
    uint8_t   fromPort,
 
149
    uint16_t  destLid,
 
150
    uint64_t  comp_mask)
 
151
    {
 
152
      return( send_sa_mad(
 
153
                pFromNode,
 
154
                fromPort,
 
155
                destLid,
 
156
                IB_MCLASS_SUBN_ADM,
 
157
                IB_MAD_METHOD_SET,
 
158
                cl_ntoh16(IB_MAD_ATTR_MCMEMBER_RECORD),
 
159
                comp_mask,
 
160
                (uint8_t*)self,
 
161
                sizeof(madMcMemberRec)
 
162
                )
 
163
              );
 
164
    }
 
165
 
 
166
  int send_get(
 
167
    IBMSNode *pFromNode,
 
168
    uint8_t   fromPort,
 
169
    uint16_t  destLid,
 
170
    uint64_t  comp_mask)
 
171
    {
 
172
      return( send_sa_mad(
 
173
                pFromNode,
 
174
                fromPort,
 
175
                destLid,
 
176
                IB_MCLASS_SUBN_ADM,
 
177
                IB_MAD_METHOD_GET,
 
178
                cl_ntoh16(IB_MAD_ATTR_MCMEMBER_RECORD),
 
179
                comp_mask,
 
180
                (uint8_t*)self,
 
181
                sizeof(madMcMemberRec)
 
182
                )
 
183
              );
 
184
    }
 
185
 
 
186
  int send_del(
 
187
    IBMSNode *pFromNode,
 
188
    uint8_t   fromPort,
 
189
    uint16_t  destLid,
 
190
    uint64_t  comp_mask)
 
191
    {
 
192
      return( send_sa_mad(
 
193
                pFromNode,
 
194
                fromPort,
 
195
                destLid,
 
196
                IB_MCLASS_SUBN_ADM,
 
197
                IB_MAD_METHOD_DELETE,
 
198
                cl_ntoh16(IB_MAD_ATTR_MCMEMBER_RECORD),
 
199
                comp_mask,
 
200
                (uint8_t*)self,
 
201
                sizeof(madMcMemberRec)
 
202
                )
 
203
              );
 
204
    }
 
205
}
 
206
 
 
207
 
 
208
%{
 
209
#define madPathRec ib_path_rec_t
 
210
%}
 
211
 
 
212
struct madPathRec
 
213
{
 
214
  madPathRec();
 
215
  ~madPathRec();
 
216
  ib_net64_t service_id;
 
217
  ib_gid_t dgid;
 
218
  ib_gid_t sgid;
 
219
  ib_net16_t dlid;
 
220
  ib_net16_t slid;
 
221
  ib_net32_t hop_flow_raw;
 
222
  uint8_t tclass;
 
223
  uint8_t num_path;
 
224
  ib_net16_t pkey;
 
225
  ib_net16_t qos_class_sl;
 
226
  uint8_t mtu;
 
227
  uint8_t rate;
 
228
  uint8_t pkt_life;
 
229
  uint8_t preference;
 
230
  uint8_array_t resv2[6];
 
231
}
 
232
 
 
233
%addmethods madPathRec {
 
234
  int send_get(
 
235
    IBMSNode *pFromNode,
 
236
    uint8_t   fromPort,
 
237
    uint16_t  destLid,
 
238
    uint64_t  comp_mask)
 
239
    {
 
240
      return( send_sa_mad(
 
241
                pFromNode,
 
242
                fromPort,
 
243
                destLid,
 
244
                IB_MCLASS_SUBN_ADM,
 
245
                IB_MAD_METHOD_GET,
 
246
                cl_ntoh16(IB_MAD_ATTR_PATH_RECORD),
 
247
                comp_mask,
 
248
                (uint8_t*)self,
 
249
                sizeof(madPathRec)
 
250
                )
 
251
              );
 
252
    }
 
253
}
 
254
 
 
255
%{
 
256
#define madServiceRec ib_service_record_t
 
257
%}
 
258
 
 
259
struct madServiceRec
 
260
{
 
261
  madServiceRec();
 
262
  ~madServiceRec();
 
263
 
 
264
  ib_net64_t            service_id;
 
265
  ib_gid_t              service_gid;
 
266
  ib_net16_t            service_pkey;
 
267
  ib_net16_t            resv;
 
268
  ib_net32_t            service_lease;
 
269
  uint8_array_t         service_key[16];
 
270
  uint8_array_t         service_name[64];
 
271
  uint8_array_t         service_data8[16];
 
272
  uint16_array_t        service_data16[8];
 
273
  uint32_array_t        service_data32[4];
 
274
  uint64_array_t        service_data64[2];
 
275
}
 
276
 
 
277
%addmethods madServiceRec {
 
278
  int send_set(
 
279
    IBMSNode *pFromNode,
 
280
    uint8_t   fromPort,
 
281
    uint16_t  destLid,
 
282
    uint64_t  comp_mask)
 
283
    {
 
284
      return( send_sa_mad(
 
285
                pFromNode,
 
286
                fromPort,
 
287
                destLid,
 
288
                IB_MCLASS_SUBN_ADM,
 
289
                IB_MAD_METHOD_SET,
 
290
                cl_ntoh16(IB_MAD_ATTR_SERVICE_RECORD),
 
291
                comp_mask,
 
292
                (uint8_t*)self,
 
293
                sizeof(madServiceRec)
 
294
                )
 
295
              );
 
296
    }
 
297
 
 
298
  int send_get(
 
299
    IBMSNode *pFromNode,
 
300
    uint8_t   fromPort,
 
301
    uint16_t  destLid,
 
302
    uint64_t  comp_mask)
 
303
    {
 
304
      return( send_sa_mad(
 
305
                pFromNode,
 
306
                fromPort,
 
307
                destLid,
 
308
                IB_MCLASS_SUBN_ADM,
 
309
                IB_MAD_METHOD_GET,
 
310
                cl_ntoh16(IB_MAD_ATTR_SERVICE_RECORD),
 
311
                comp_mask,
 
312
                (uint8_t*)self,
 
313
                sizeof(madServiceRec)
 
314
                )
 
315
              );
 
316
    }
 
317
 
 
318
  int send_del(
 
319
    IBMSNode *pFromNode,
 
320
    uint8_t   fromPort,
 
321
    uint16_t  destLid,
 
322
    uint64_t  comp_mask)
 
323
    {
 
324
      return( send_sa_mad(
 
325
                pFromNode,
 
326
                fromPort,
 
327
                destLid,
 
328
                IB_MCLASS_SUBN_ADM,
 
329
                IB_MAD_METHOD_DELETE,
 
330
                cl_ntoh16(IB_MAD_ATTR_SERVICE_RECORD),
 
331
                comp_mask,
 
332
                (uint8_t*)self,
 
333
                sizeof(madServiceRec)
 
334
                )
 
335
              );
 
336
    }
 
337
}
 
338
 
 
339
 
 
340
%{
 
341
#include <complib/cl_packon.h>
 
342
typedef struct _ib_mad_notice_attr128
 
343
{
 
344
  uint8_t               generic_type;
 
345
  uint8_t               prod_type_msb;
 
346
  ib_net16_t            prod_type_lsb;
 
347
  ib_net16_t            trap_num;
 
348
  ib_net16_t            issuer_lid;
 
349
  ib_net16_t            toggle_count;
 
350
  ib_net16_t            sw_lid; // the sw lid of which link state changed - for 128 only
 
351
  ib_gid_t              issuer_gid;
 
352
}       PACK_SUFFIX ib_mad_notice_attr128_t;
 
353
#include <complib/cl_packoff.h>
 
354
 
 
355
#define madNotice128 ib_mad_notice_attr128_t
 
356
%}
 
357
 
 
358
struct madNotice128
 
359
{
 
360
  madNotice128();
 
361
  ~madNotice128();
 
362
 
 
363
  uint8_t               generic_type;
 
364
  uint8_t               prod_type_msb;
 
365
  ib_net16_t            prod_type_lsb;
 
366
  ib_net16_t            trap_num;
 
367
  ib_net16_t            issuer_lid;
 
368
  ib_net16_t            toggle_count;
 
369
  ib_net16_t            sw_lid; // the sw lid of which link state changed - for 128 only
 
370
  ib_gid_t              issuer_gid;
 
371
}
 
372
 
 
373
%addmethods madNotice128 {
 
374
  int send_trap(
 
375
    IBMSNode *pFromNode,
 
376
    uint8_t   fromPort,
 
377
    uint16_t  destLid)
 
378
    {
 
379
      return( send_mad(
 
380
                pFromNode,
 
381
                fromPort,
 
382
                destLid,
 
383
                IB_MCLASS_SUBN_LID,
 
384
                IB_MAD_METHOD_TRAP,
 
385
                cl_ntoh16(IB_MAD_ATTR_NOTICE),
 
386
                0,
 
387
                (uint8_t*)self,
 
388
                sizeof(madNotice128)
 
389
                )
 
390
              );
 
391
    }
 
392
}
 
393
 
 
394
%{
 
395
#include <complib/cl_packon.h>
 
396
typedef struct _ib_mad_notice_attr129
 
397
{
 
398
  uint8_t               generic_type;
 
399
  uint8_t               prod_type_msb;
 
400
  ib_net16_t            prod_type_lsb;
 
401
  ib_net16_t            trap_num;
 
402
  ib_net16_t            issuer_lid;
 
403
  ib_net16_t            toggle_count;
 
404
  ib_net16_t            pad;      //129
 
405
  ib_net16_t            lid;      // 129 lid and port number of the violation
 
406
  uint8_t               port_num; //129
 
407
  ib_gid_t              issuer_gid;
 
408
}       PACK_SUFFIX ib_mad_notice_attr129_t;
 
409
#include <complib/cl_packoff.h>
 
410
 
 
411
#define madNotice129 ib_mad_notice_attr129_t
 
412
%}
 
413
 
 
414
struct madNotice129
 
415
{
 
416
  madNotice129();
 
417
  ~madNotice129();
 
418
  uint8_t               generic_type;
 
419
  uint8_t               prod_type_msb;
 
420
  ib_net16_t            prod_type_lsb;
 
421
  ib_net16_t            trap_num;
 
422
  ib_net16_t            issuer_lid;
 
423
  ib_net16_t            toggle_count;
 
424
  ib_net16_t            pad;      //129
 
425
  ib_net16_t            lid;      // 129 lid and port number of the violation
 
426
  uint8_t               port_num; //129
 
427
  ib_gid_t              issuer_gid;
 
428
}
 
429
 
 
430
%addmethods madNotice129 {
 
431
  int send_trap(
 
432
    IBMSNode *pFromNode,
 
433
    uint8_t   fromPort,
 
434
    uint16_t  destLid)
 
435
    {
 
436
      return( send_mad(
 
437
                pFromNode,
 
438
                fromPort,
 
439
                destLid,
 
440
                IB_MCLASS_SUBN_LID,
 
441
                IB_MAD_METHOD_TRAP,
 
442
                cl_ntoh16(IB_MAD_ATTR_NOTICE),
 
443
                0,
 
444
                (uint8_t*)self,
 
445
                sizeof(madNotice129)
 
446
                )
 
447
              );
 
448
    }
 
449
}
 
450
 
 
451
%{
 
452
#include <complib/cl_packon.h>
 
453
typedef struct _ib_mad_notice_attr144
 
454
{
 
455
  uint8_t               generic_type;
 
456
  uint8_t               prod_type_msb;
 
457
  ib_net16_t            prod_type_lsb;
 
458
  ib_net16_t            trap_num;
 
459
  ib_net16_t            issuer_lid;
 
460
  ib_net16_t            toggle_count;
 
461
  ib_net16_t            pad1;         // 144
 
462
  ib_net16_t            lid;          // 144 lid where capability mask changed
 
463
  ib_net16_t            pad2;         // 144
 
464
  ib_net32_t            new_cap_mask; // 144 new capability mask
 
465
  ib_gid_t              issuer_gid;
 
466
}       PACK_SUFFIX ib_mad_notice_attr144_t;
 
467
#include <complib/cl_packoff.h>
 
468
 
 
469
#define madNotice144 ib_mad_notice_attr144_t
 
470
%}
 
471
 
 
472
struct madNotice144
 
473
{
 
474
  madNotice144();
 
475
  ~madNotice144();
 
476
 
 
477
  uint8_t               generic_type;
 
478
  uint8_t               prod_type_msb;
 
479
  ib_net16_t            prod_type_lsb;
 
480
  ib_net16_t            trap_num;
 
481
  ib_net16_t            issuer_lid;
 
482
  ib_net16_t            toggle_count;
 
483
  ib_net16_t            pad1;         // 144
 
484
  ib_net16_t            lid;          // 144 lid where capability mask changed
 
485
  ib_net16_t            pad2;         // 144
 
486
  ib_net32_t            new_cap_mask; // 144 new capability mask
 
487
  ib_gid_t              issuer_gid;
 
488
}
 
489
 
 
490
%addmethods madNotice144 {
 
491
  int send_trap(
 
492
    IBMSNode *pFromNode,
 
493
    uint8_t   fromPort,
 
494
    uint16_t  destLid)
 
495
    {
 
496
      return( send_mad(
 
497
                pFromNode,
 
498
                fromPort,
 
499
                destLid,
 
500
                IB_MCLASS_SUBN_LID,
 
501
                IB_MAD_METHOD_TRAP,
 
502
                cl_ntoh16(IB_MAD_ATTR_NOTICE),
 
503
                0,
 
504
                (uint8_t*)self,
 
505
                sizeof(madNotice144)
 
506
                )
 
507
              );
 
508
    }
 
509
}
 
510
 
 
511
%{
 
512
#include <complib/cl_packon.h>
 
513
typedef struct _ib_generic_inform_info
 
514
{
 
515
        ib_gid_t                        gid;
 
516
        ib_net16_t              lid_range_begin;
 
517
        ib_net16_t              lid_range_end;
 
518
        ib_net16_t              reserved1;
 
519
        uint8_t                 is_generic;
 
520
        uint8_t                 subscribe;
 
521
        ib_net16_t              trap_type;
 
522
        ib_net16_t              trap_num;
 
523
        ib_net32_t              qpn_resp_time_val;
 
524
        uint8_t        reserved2;
 
525
        uint8_t                 node_type_msb;
 
526
        ib_net16_t              node_type_lsb;
 
527
}       PACK_SUFFIX ib_generic_inform_info_t;
 
528
#include <complib/cl_packoff.h>
 
529
 
 
530
#define madGenericInform ib_generic_inform_info_t
 
531
%}
 
532
 
 
533
struct madGenericInform
 
534
{
 
535
  madGenericInform();
 
536
  ~madGenericInform();
 
537
 
 
538
        ib_gid_t                        gid;
 
539
        ib_net16_t              lid_range_begin;
 
540
        ib_net16_t              lid_range_end;
 
541
        ib_net16_t              reserved1;
 
542
        uint8_t                 is_generic;
 
543
        uint8_t                 subscribe;
 
544
        ib_net16_t              trap_type;
 
545
        ib_net16_t              trap_num;
 
546
        ib_net32_t              qpn_resp_time_val;
 
547
        uint8_t        reserved2;
 
548
        uint8_t                 node_type_msb;
 
549
        ib_net16_t              node_type_lsb;
 
550
}
 
551
 
 
552
#define IB_INFORM_INFO_COMP_GID 0x1
 
553
#define IB_INFORM_INFO_COMP_LID_BEGIN 0x2
 
554
#define IB_INFORM_INFO_COMP_LID_END 0x4
 
555
#define IB_INFORM_INFO_COMP_IS_GENERIC 0x10
 
556
#define IB_INFORM_INFO_COMP_TRAP_TYPE 0x40
 
557
#define IB_INFORM_INFO_COMP_TRAP_NUM 0x80
 
558
#define IB_INFORM_INFO_COMP_QPN 0x100
 
559
#define IB_INFORM_INFO_COMP_RESP_TIME 0x200
 
560
#define IB_INFORM_INFO_COMP_NODE_TYPE 0x800
 
561
 
 
562
%addmethods madGenericInform {
 
563
  int send_set(
 
564
    IBMSNode *pFromNode,
 
565
    uint8_t   fromPort,
 
566
    uint16_t  destLid,
 
567
    uint64_t  comp_mask)
 
568
    {
 
569
      return( send_sa_mad(
 
570
                pFromNode,
 
571
                fromPort,
 
572
                destLid,
 
573
                IB_MCLASS_SUBN_ADM,
 
574
                IB_MAD_METHOD_SET,
 
575
                cl_ntoh16(IB_MAD_ATTR_INFORM_INFO),
 
576
                comp_mask,
 
577
                (uint8_t*)self,
 
578
                sizeof(madGenericInform)
 
579
                )
 
580
              );
 
581
    }
 
582
}