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

« back to all changes in this revision

Viewing changes to ibmgtsim/tests/osmMulticastRoutingTest.sim.tcl

  • 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
puts "Running Simulation flow for Muticast Routing test"
 
2
 
 
3
puts "Randomally Joining all the Fabric Ports with random delays"
 
4
 
 
5
# send a single port join request
 
6
proc sendJoinForPort {port smLid} {
 
7
   puts "-I- Joining port $port"
 
8
   # allocate a new mc member record:
 
9
   set mcm [new_madMcMemberRec]
 
10
 
 
11
   # join the IPoIB broadcast gid:
 
12
   madMcMemberRec_mgid_set $mcm 0xff12401bffff0000:00000000ffffffff
 
13
 
 
14
   # we must provide our own port gid
 
15
   madMcMemberRec_port_gid_set $mcm \
 
16
      "0xfe80000000000000:[string range [IBPort_guid_get $port] 2 end]"
 
17
 
 
18
   # must require full membership:
 
19
   madMcMemberRec_scope_state_set $mcm 0x1
 
20
 
 
21
   # we need port number and sim node for the mad send:
 
22
   set portNum [IBPort_num_get $port]
 
23
   set node [IBPort_p_node_get $port]
 
24
 
 
25
   # we need the comp_mask to include the mgid, port gid and join state:
 
26
   set compMask [format "0x%X" [expr (1<<16) | 3]]
 
27
 
 
28
   # send it
 
29
   madMcMemberRec_send_set $mcm sim$node $portNum $smLid $compMask
 
30
 
 
31
   # deallocate
 
32
   delete_madMcMemberRec $mcm
 
33
 
 
34
   return 0
 
35
}
 
36
 
 
37
# find all active HCA ports
 
38
proc getAllActiveHCAPorts {fabric} {
 
39
   set hcaPorts {}
 
40
 
 
41
   # go over all nodes:
 
42
   foreach nodeNameId [IBFabric_NodeByName_get $fabric] {
 
43
      set node [lindex $nodeNameId 1]
 
44
 
 
45
      # we do care about non switches only
 
46
      if {[IBNode_type_get $node] != 1} {
 
47
         # go over all ports:
 
48
         for {set pn 1} {$pn <= [IBNode_numPorts_get $node]} {incr pn} {
 
49
            set port [IBNode_getPort $node $pn]
 
50
            if {($port != "") && ([IBPort_p_remotePort_get $port] != "")} {
 
51
               lappend hcaPorts $port
 
52
            }
 
53
         }
 
54
      }
 
55
   }
 
56
   return $hcaPorts
 
57
}
 
58
 
 
59
# randomize join for all of the fabric HCA ports:
 
60
proc randomJoinAllHCAPorts {fabric maxDelay_ms} {
 
61
   # get all HCA ports:
 
62
   set hcaPorts [getAllActiveHCAPorts $fabric]
 
63
 
 
64
   # set a random order:
 
65
   set orederedPorts {}
 
66
   foreach port $hcaPorts {
 
67
      lappend orederedPorts [list $port [rmRand]]
 
68
   }
 
69
 
 
70
   # sort:
 
71
   set orederedPorts [lsort -index 1 -real $orederedPorts]
 
72
   set numHcasJoined 0
 
73
 
 
74
   # get the SM LID
 
75
   # HACK: Assumes the SM node is H-1/U1 Port 1
 
76
   set smNode [IBFabric_getNode $fabric "H-1/U1"]
 
77
   set smPort [IBNode_getPort $smNode 1]
 
78
   set smPortInfo [IBMSNode_getPortInfo sim$smNode 1]
 
79
   set smLid [ib_port_info_t_base_lid_get $smPortInfo]
 
80
 
 
81
   # Now do the joins - waiting random time between them:
 
82
   foreach portNOrder $orederedPorts {
 
83
      set port [lindex $portNOrder 0]
 
84
 
 
85
      if {![sendJoinForPort $port $smLid]} {
 
86
         incr numHcasJoined
 
87
      }
 
88
 
 
89
      after [expr int([rmRand]*$maxDelay_ms)]
 
90
   }
 
91
   return $numHcasJoined
 
92
}