summaryrefslogtreecommitdiffstats
path: root/functions.sh
blob: 32bd30eafbc1162ffc2c9130b4b3ee1cb51c81dd (plain)
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
function mlxreload {
    rmmod mlx4_ib &> /dev/null
    rmmod mlx4_en &> /dev/null
    rmmod mlx4_core
    rmmod ib_ucm &> /dev/null
    rmmod rdma_ucm &> /dev/null
    rmmod ib_uverbs
    modprobe ib_uverbs disable_raw_qp_enforcement=1
#    modprobe ib_ucm
    modprobe rdma_ucm
    modprobe mlx4_core fast_drop=1 log_num_mgm_entry_size=-1
    modprobe mlx4_en
}

function mlxload {
    reload=0

    param=$(cat /sys/module/mlx4_core/parameters/log_num_mgm_entry_size)
    [ $param -ne -1 ] && reload=1

    [ $reload -eq 1 ] && mlxreload
}

function portset {
    pci=$1
    mode=$2
    ./connectx_port_config -d "$pci" -c "$mode,$mode" &> /dev/null
}

function mlxconf {
    mode=$1

    mlxload

    pci=$(./connectx_port_config -s | grep PCI | grep -Po "[\da-f]{4}:[\da-f]{2}:[\da-f]{2}\.[\da-f]")
    for dev in $pci; do
	echo "Configuring: $dev"
	portset $dev $mode
    done
}

function ipset {
    int="$1"
    ip="$2"

    if [ -n "$ip" ]; then
	ip link  set "$int"  up
	ip addr flush "$int"
	ip addr show dev "$int" | grep "$ip" || ip addr add "$ip/24" dev "$int"
    else
	ip addr flush "$int"
	ip link  set "$int"  down
    fi
}