File: sm-link-setup.sim.tcl

package info (click to toggle)
ibutils 1.5.7%2B0.2.gbd7e502-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 38,728 kB
  • sloc: cpp: 159,552; ansic: 74,818; tcl: 13,816; sh: 13,204; makefile: 431; yacc: 333; lex: 169; awk: 53; perl: 49
file content (139 lines) | stat: -rw-r--r-- 4,612 bytes parent folder | download | duplicates (4)
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
#--
# 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.
#--

puts "Running Simulation flow for SM LINK SETUP test case"

proc setPortSpeed {fabric nodeName portNum speed} {
	set node [IBFabric_getNode $fabric $nodeName]
	if {$node == ""} {
		puts "-E- fail to find node $nodeName"
		return "ERR: fail to find node $nodeName"
	}
	set port [IBNode_getPort $node $portNum]
	if {$port == ""} {
		puts "-E- fail to find node $nodeName port $portNum"
		return "ERR: fail to find node $nodeName port $portNum"
	}

	switch $speed {
		2.5 {set code 1}
		5   {set code 2}
		10  {set code 4}
		default {
			return "ERR: unknown speed:$speed"
		}
	}
	set pi [IBMSNode_getPortInfo sim$node $portNum]
	set old [ib_port_info_t_link_speed_get $pi]
	set new [format %x [expr ($code << 4) | ($old & 0xf)]]
	ib_port_info_t_link_width_active_set $pi $new
	return "Set node:$nodeName port:$portNum LinkSpeedActive to ${speed}Gpbs was $old now $new"
}

proc setPortWidth {fabric nodeName portNum width} {
	set node [IBFabric_getNode $fabric $nodeName]
	if {$node == ""} {
		puts "-E- fail to find node $nodeName"
		return "ERR: fail to find node $nodeName"
	}
	set port [IBNode_getPort $node $portNum]
	if {$port == ""} {
		puts "-E- fail to find node $nodeName port $portNum"
		return "ERR: fail to find node $nodeName port $portNum"
	}

	switch $width {
		1x {set code 1}
		4x {set code 2}
		8x {set code 4}
		12x {set code 8}
		default {
			return "ERR: unknown width:$width"
		}
	}
	set pi [IBMSNode_getPortInfo sim$node $portNum]
	set old [ib_port_info_t_link_width_active_get $pi]
	ib_port_info_t_link_width_active_set $pi $code
	return "Set node:$nodeName port:$portNum LinkWidthActive to $width was $old now $code"
}

proc setPortOpVLs {fabric nodeName portNum vls} {
	set node [IBFabric_getNode $fabric $nodeName]
	if {$node == ""} {
		puts "-E- fail to find node $nodeName"
		return "ERR: fail to find node $nodeName"
	}
	set port [IBNode_getPort $node $portNum]
	if {$port == ""} {
		puts "-E- fail to find node $nodeName port $portNum"
		return "ERR: fail to find node $nodeName port $portNum"
	}

	set pi [IBMSNode_getPortInfo sim$node $portNum]
	set old [ib_port_info_t_vl_enforce_get $pi]
	set new [format %x [expr ($vls << 4) | ($old & 0xf)]]
	ib_port_info_t_vl_enforce_set $pi $new
	return "Set node:$nodeName port:$portNum OpVLs to $vls opvls_enforcement was $old now $new"
}

proc setPortMTU {fabric nodeName portNum mtu} {
	set node [IBFabric_getNode $fabric $nodeName]
	if {$node == ""} {
		puts "-E- fail to find node $nodeName"
		return "ERR: fail to find node $nodeName"
	}
	set port [IBNode_getPort $node $portNum]
	if {$port == ""} {
		puts "-E- fail to find node $nodeName port $portNum"
		return "ERR: fail to find node $nodeName port $portNum"
	}

	switch $mtu {
		256 {set mtuCode 1}
		512 {set mtuCode 2}
		1024 {set mtuCode 3}
		2048 {set mtuCode 4}
		4096 {set mtuCode 5}
		default {
			return "ERR: unknown MTU:$mtu"
		}
	}

	set pi [IBMSNode_getPortInfo sim$node $portNum]
	set old [ib_port_info_t_mtu_smsl_get $pi]
	set new [format %x [expr ($mtuCode << 4) | ($old & 0xf)]]
	ib_port_info_t_mtu_smsl_set $pi $new
	return "Set node:$nodeName port:$portNum NeighborMTU to $mtu mtu_smsl was $old now $new"
}


set fabric [IBMgtSimulator getFabric]