Package list ibutils / upstream/1.5.7+0.2.gbd7e502 ibmgtsim / src / mads.i
upstream/1.5.7+0.2.gbd7e502

Tree @upstream/1.5.7+0.2.gbd7e502 (Download .tar.gz)

mads.i @upstream/1.5.7+0.2.gbd7e502raw · history · blame

  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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
/*
 * Copyright (c) 2004-2010 Mellanox Technologies LTD. All rights reserved.
 *
 * This software is available to you under a choice of one of two
 * licenses.  You may choose to be licensed under the terms of the GNU
 * General Public License (GPL) Version 2, available from the file
 * COPYING in the main directory of this source tree, or the
 * OpenIB.org BSD license below:
 *
 *     Redistribution and use in source and binary forms, with or
 *     without modification, are permitted provided that the following
 *     conditions are met:
 *
 *      - Redistributions of source code must retain the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer.
 *
 *      - Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer in the documentation and/or other materials
 *        provided with the distribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */

/*
 * MADS INTERFACE: Provide means for dispatching mads into the simulator
 */

%{
  /* the following code will place the mad into the dispatcher */
  int
    send_mad(
      IBMSNode *pFromNode,
      uint8_t   fromPort,
      uint16_t  destLid,
      uint8_t   mgmt_class,
      uint8_t   method,
      uint16_t  attr,
      uint32_t  attr_mod,
      uint8_t  *data,
      size_t    size)
    {
      ibms_mad_msg_t msg;
      IBPort *pPort;
      static uint64_t tid = 19927;

      /* initialize the message address vector */
      msg.addr.sl = 0;
      msg.addr.pkey_index = 0;
      msg.addr.dlid = destLid;
      msg.addr.sqpn = 0;
      msg.addr.dqpn = 0;

      pPort = pFromNode->getIBNode()->getPort(fromPort);
      if (! pPort)
      {
        cout << "-E- Given port:" << fromPort << " is down." << endl;
        return 1;
      }
      msg.addr.slid = pPort->base_lid;

      /* initialize the mad header */
      msg.header.base_ver = 1;
      msg.header.mgmt_class = mgmt_class;
      msg.header.class_ver = 1;
      msg.header.method = method;
      msg.header.status = 0;
      msg.header.class_spec = 0;
      msg.header.trans_id = tid++;
      msg.header.attr_id = cl_hton16(attr);
      msg.header.attr_mod = cl_hton32(attr_mod);

      memcpy(msg.payload, data, size);
      IBMSDispatcher *pDispatcher = Simulator.getDispatcher();
      if (! pDispatcher )
        return TCL_ERROR;

      return pDispatcher->dispatchMad(pFromNode, fromPort, msg);
    }

  int send_sa_mad(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid,
    uint8_t   mgmt_class,
    uint8_t   method,
    uint16_t  attr,
    uint64_t  comp_mask,
    uint8_t  *sa_data,
    size_t    sa_data_size)
    {
      ib_sa_mad_t mad = {0}; /* includes std header and rmpp header */

      mad.attr_offset = ib_get_attr_offset(sa_data_size);
      mad.comp_mask = cl_hton64(comp_mask);
      memcpy(mad.data, sa_data, sa_data_size);

      return send_mad(
        pFromNode,
        fromPort,
        destLid,
        mgmt_class,
        method,
        attr,
        0,
        &mad.rmpp_version,
        MAD_RMPP_DATA_SIZE + 12);
    }

%}

%{
#define madMcMemberRec ib_member_rec_t
%}

struct madMcMemberRec
{
  madMcMemberRec();
  ~madMcMemberRec();

  ib_gid_t				mgid;
  ib_gid_t				port_gid;
  ib_net32_t			qkey;
  ib_net16_t			mlid;
  uint8_t				mtu;
  uint8_t				tclass;
  ib_net16_t			pkey;
  uint8_t				rate;
  uint8_t				pkt_life;
  ib_net32_t			sl_flow_hop;
  uint8_t				scope_state;
  //  uint8_t				proxy_join;  hard to get as it is defined as bit field
}

%addmethods madMcMemberRec {
  int send_set(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid,
    uint64_t  comp_mask)
    {
      return( send_sa_mad(
                pFromNode,
                fromPort,
                destLid,
                IB_MCLASS_SUBN_ADM,
                IB_MAD_METHOD_SET,
                cl_ntoh16(IB_MAD_ATTR_MCMEMBER_RECORD),
                comp_mask,
                (uint8_t*)self,
                sizeof(madMcMemberRec)
                )
              );
    }

  int send_get(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid,
    uint64_t  comp_mask)
    {
      return( send_sa_mad(
                pFromNode,
                fromPort,
                destLid,
                IB_MCLASS_SUBN_ADM,
                IB_MAD_METHOD_GET,
                cl_ntoh16(IB_MAD_ATTR_MCMEMBER_RECORD),
                comp_mask,
                (uint8_t*)self,
                sizeof(madMcMemberRec)
                )
              );
    }

  int send_del(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid,
    uint64_t  comp_mask)
    {
      return( send_sa_mad(
                pFromNode,
                fromPort,
                destLid,
                IB_MCLASS_SUBN_ADM,
                IB_MAD_METHOD_DELETE,
                cl_ntoh16(IB_MAD_ATTR_MCMEMBER_RECORD),
                comp_mask,
                (uint8_t*)self,
                sizeof(madMcMemberRec)
                )
              );
    }
}


%{
#define madPathRec ib_path_rec_t
%}

struct madPathRec
{
  madPathRec();
  ~madPathRec();
  ib_net64_t service_id;
  ib_gid_t dgid;
  ib_gid_t sgid;
  ib_net16_t dlid;
  ib_net16_t slid;
  ib_net32_t hop_flow_raw;
  uint8_t tclass;
  uint8_t num_path;
  ib_net16_t pkey;
  ib_net16_t qos_class_sl;
  uint8_t mtu;
  uint8_t rate;
  uint8_t pkt_life;
  uint8_t preference;
  uint8_array_t resv2[6];
}

%addmethods madPathRec {
  int send_get(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid,
    uint64_t  comp_mask)
    {
      return( send_sa_mad(
                pFromNode,
                fromPort,
                destLid,
                IB_MCLASS_SUBN_ADM,
                IB_MAD_METHOD_GET,
                cl_ntoh16(IB_MAD_ATTR_PATH_RECORD),
                comp_mask,
                (uint8_t*)self,
                sizeof(madPathRec)
                )
              );
    }
}


%{
#define madGuidRec ib_guidinfo_record_t
#define guidRecGuidInfoBlock ib_guid_info_t
%}

struct guidRecGuidInfoBlock {
  guidRecGuidInfoBlock();
  ~guidRecGuidInfoBlock();
  ib_net64_array_t guid[GUID_TABLE_MAX_ENTRIES];
}

struct madGuidRec
{
  madGuidRec();
  ~madGuidRec();

  ib_net16_t lid;
  uint8_t block_num;
  uint8_t resv;
  uint32_t reserved;
  guidRecGuidInfoBlock guid_info;
}

%addmethods madGuidRec {
  int send_set(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid,
    uint64_t  comp_mask)
    {
      return( send_sa_mad(
                pFromNode,
                fromPort,
                destLid,
                IB_MCLASS_SUBN_ADM,
                IB_MAD_METHOD_SET,
                cl_ntoh16(IB_MAD_ATTR_GUIDINFO_RECORD),
                comp_mask,
                (uint8_t*)self,
                sizeof(madGuidRec)
                )
              );
    }

  int send_get(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid,
    uint64_t  comp_mask)
    {
      return( send_sa_mad(
                pFromNode,
                fromPort,
                destLid,
                IB_MCLASS_SUBN_ADM,
                IB_MAD_METHOD_GET,
                cl_ntoh16(IB_MAD_ATTR_GUIDINFO_RECORD),
                comp_mask,
                (uint8_t*)self,
                sizeof(madGuidRec)
                )
              );
    }

  int send_del(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid,
    uint64_t  comp_mask)
    {
      return( send_sa_mad(
                pFromNode,
                fromPort,
                destLid,
                IB_MCLASS_SUBN_ADM,
                IB_MAD_METHOD_DELETE,
                cl_ntoh16(IB_MAD_ATTR_GUIDINFO_RECORD),
                comp_mask,
                (uint8_t*)self,
                sizeof(madGuidRec)
                )
              );
    }
}


%{
#define madServiceRec ib_service_record_t
%}

struct madServiceRec
{
  madServiceRec();
  ~madServiceRec();

  ib_net64_t		service_id;
  ib_gid_t		service_gid;
  ib_net16_t		service_pkey;
  ib_net16_t		resv;
  ib_net32_t		service_lease;
  uint8_array_t	        service_key[16];
  uint8_array_t	        service_name[64];
  uint8_array_t		service_data8[16];
  uint16_array_t	service_data16[8];
  uint32_array_t	service_data32[4];
  uint64_array_t	service_data64[2];
}

%addmethods madServiceRec {
  int send_set(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid,
    uint64_t  comp_mask)
    {
      return( send_sa_mad(
                pFromNode,
                fromPort,
                destLid,
                IB_MCLASS_SUBN_ADM,
                IB_MAD_METHOD_SET,
                cl_ntoh16(IB_MAD_ATTR_SERVICE_RECORD),
                comp_mask,
                (uint8_t*)self,
                sizeof(madServiceRec)
                )
              );
    }

  int send_get(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid,
    uint64_t  comp_mask)
    {
      return( send_sa_mad(
                pFromNode,
                fromPort,
                destLid,
                IB_MCLASS_SUBN_ADM,
                IB_MAD_METHOD_GET,
                cl_ntoh16(IB_MAD_ATTR_SERVICE_RECORD),
                comp_mask,
                (uint8_t*)self,
                sizeof(madServiceRec)
                )
              );
    }

  int send_del(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid,
    uint64_t  comp_mask)
    {
      return( send_sa_mad(
                pFromNode,
                fromPort,
                destLid,
                IB_MCLASS_SUBN_ADM,
                IB_MAD_METHOD_DELETE,
                cl_ntoh16(IB_MAD_ATTR_SERVICE_RECORD),
                comp_mask,
                (uint8_t*)self,
                sizeof(madServiceRec)
                )
              );
    }
}


%{
#include <complib/cl_packon.h>
typedef struct _ib_mad_notice_attr128
{
  uint8_t	        generic_type;
  uint8_t		prod_type_msb;
  ib_net16_t	        prod_type_lsb;
  ib_net16_t	        trap_num;
  ib_net16_t		issuer_lid;
  ib_net16_t		toggle_count;
  ib_net16_t            sw_lid; // the sw lid of which link state changed - for 128 only
  ib_gid_t		issuer_gid;
}	PACK_SUFFIX ib_mad_notice_attr128_t;
#include <complib/cl_packoff.h>

#define madNotice128 ib_mad_notice_attr128_t
%}

struct madNotice128
{
  madNotice128();
  ~madNotice128();

  uint8_t	        generic_type;
  uint8_t		prod_type_msb;
  ib_net16_t	        prod_type_lsb;
  ib_net16_t	        trap_num;
  ib_net16_t		issuer_lid;
  ib_net16_t		toggle_count;
  ib_net16_t            sw_lid; // the sw lid of which link state changed - for 128 only
  ib_gid_t		issuer_gid;
}

%addmethods madNotice128 {
  int send_trap(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid)
    {
      return( send_mad(
                pFromNode,
                fromPort,
                destLid,
                IB_MCLASS_SUBN_LID,
                IB_MAD_METHOD_TRAP,
                cl_ntoh16(IB_MAD_ATTR_NOTICE),
                0,
                (uint8_t*)self,
                sizeof(madNotice128)
                )
              );
    }
}

%{
#include <complib/cl_packon.h>
typedef struct _ib_mad_notice_attr129
{
  uint8_t	        generic_type;
  uint8_t		prod_type_msb;
  ib_net16_t	        prod_type_lsb;
  ib_net16_t	        trap_num;
  ib_net16_t		issuer_lid;
  ib_net16_t		toggle_count;
  ib_net16_t            pad;      //129
  ib_net16_t            lid;	  // 129 lid and port number of the violation
  uint8_t               port_num; //129
  ib_gid_t		issuer_gid;
}	PACK_SUFFIX ib_mad_notice_attr129_t;
#include <complib/cl_packoff.h>

#define madNotice129 ib_mad_notice_attr129_t
%}

struct madNotice129
{
  madNotice129();
  ~madNotice129();
  uint8_t	        generic_type;
  uint8_t		prod_type_msb;
  ib_net16_t	        prod_type_lsb;
  ib_net16_t	        trap_num;
  ib_net16_t		issuer_lid;
  ib_net16_t		toggle_count;
  ib_net16_t            pad;      //129
  ib_net16_t            lid;	  // 129 lid and port number of the violation
  uint8_t               port_num; //129
  ib_gid_t		issuer_gid;
}

%addmethods madNotice129 {
  int send_trap(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid)
    {
      return( send_mad(
                pFromNode,
                fromPort,
                destLid,
                IB_MCLASS_SUBN_LID,
                IB_MAD_METHOD_TRAP,
                cl_ntoh16(IB_MAD_ATTR_NOTICE),
                0,
                (uint8_t*)self,
                sizeof(madNotice129)
                )
              );
    }
}

%{
#include <complib/cl_packon.h>
typedef struct _ib_mad_notice_attr144
{
  uint8_t	        generic_type;
  uint8_t		prod_type_msb;
  ib_net16_t	        prod_type_lsb;
  ib_net16_t	        trap_num;
  ib_net16_t		issuer_lid;
  ib_net16_t		toggle_count;
  ib_net16_t            pad1;         // 144
  ib_net16_t            lid;	      // 144 lid where capability mask changed
  ib_net16_t            pad2;         // 144
  ib_net32_t            new_cap_mask; // 144 new capability mask
  ib_gid_t		issuer_gid;
}	PACK_SUFFIX ib_mad_notice_attr144_t;
#include <complib/cl_packoff.h>

#define madNotice144 ib_mad_notice_attr144_t
%}

struct madNotice144
{
  madNotice144();
  ~madNotice144();

  uint8_t	        generic_type;
  uint8_t		prod_type_msb;
  ib_net16_t	        prod_type_lsb;
  ib_net16_t	        trap_num;
  ib_net16_t		issuer_lid;
  ib_net16_t		toggle_count;
  ib_net16_t            pad1;         // 144
  ib_net16_t            lid;	      // 144 lid where capability mask changed
  ib_net16_t            pad2;         // 144
  ib_net32_t            new_cap_mask; // 144 new capability mask
  ib_gid_t		issuer_gid;
}

%addmethods madNotice144 {
  int send_trap(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid)
    {
      return( send_mad(
                pFromNode,
                fromPort,
                destLid,
                IB_MCLASS_SUBN_LID,
                IB_MAD_METHOD_TRAP,
                cl_ntoh16(IB_MAD_ATTR_NOTICE),
                0,
                (uint8_t*)self,
                sizeof(madNotice144)
                )
              );
    }
}

%{
#include <complib/cl_packon.h>
typedef struct _ib_generic_inform_info
{
	ib_gid_t			gid;
	ib_net16_t		lid_range_begin;
	ib_net16_t		lid_range_end;
	ib_net16_t		reserved1;
	uint8_t			is_generic;
	uint8_t			subscribe;
	ib_net16_t		trap_type;
	ib_net16_t		trap_num;
	ib_net32_t		qpn_resp_time_val;
	uint8_t        reserved2;
	uint8_t			node_type_msb;
	ib_net16_t		node_type_lsb;
}	PACK_SUFFIX ib_generic_inform_info_t;
#include <complib/cl_packoff.h>

#define madGenericInform ib_generic_inform_info_t
%}

struct madGenericInform
{
  madGenericInform();
  ~madGenericInform();

	ib_gid_t			gid;
	ib_net16_t		lid_range_begin;
	ib_net16_t		lid_range_end;
	ib_net16_t		reserved1;
	uint8_t			is_generic;
	uint8_t			subscribe;
	ib_net16_t		trap_type;
	ib_net16_t		trap_num;
	ib_net32_t		qpn_resp_time_val;
	uint8_t        reserved2;
	uint8_t			node_type_msb;
	ib_net16_t		node_type_lsb;
}

#define IB_INFORM_INFO_COMP_GID 0x1
#define IB_INFORM_INFO_COMP_LID_BEGIN 0x2
#define IB_INFORM_INFO_COMP_LID_END 0x4
#define IB_INFORM_INFO_COMP_IS_GENERIC 0x10
#define IB_INFORM_INFO_COMP_TRAP_TYPE 0x40
#define IB_INFORM_INFO_COMP_TRAP_NUM 0x80
#define IB_INFORM_INFO_COMP_QPN 0x100
#define IB_INFORM_INFO_COMP_RESP_TIME 0x200
#define IB_INFORM_INFO_COMP_NODE_TYPE 0x800

%addmethods madGenericInform {
  int send_set(
    IBMSNode *pFromNode,
    uint8_t   fromPort,
    uint16_t  destLid,
    uint64_t  comp_mask)
    {
      return( send_sa_mad(
                pFromNode,
                fromPort,
                destLid,
                IB_MCLASS_SUBN_ADM,
                IB_MAD_METHOD_SET,
                cl_ntoh16(IB_MAD_ATTR_INFORM_INFO),
                comp_mask,
                (uint8_t*)self,
                sizeof(madGenericInform)
                )
              );
    }
}