forked from Mellanox/mlnx-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 80fb22e
Showing
14 changed files
with
2,616 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Install Mellanox tools and scripts not yet part of an | ||
# Oracle or upstream RPM | ||
# | ||
# /usr/bin/tc_wrap.py | ||
# /usr/bin/mlnx_qos | ||
# /usr/sbin/cma_roce_mode | ||
# /usr/sbin/show_gids | ||
|
||
# This script does not make backups of any existing versions of | ||
# the tools. | ||
# | ||
# This script doesn't do any error checking. | ||
# | ||
# This script does not have an uninstaller. | ||
|
||
if [ "$EUID" -ne 0 ] | ||
then echo "Please run as root" | ||
exit | ||
fi | ||
|
||
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) | ||
|
||
echo "Installing cma_roce_mode..." | ||
install -o root -g root -m 0755 ${parent_path}/ofed_scripts/cma_roce_mode /usr/sbin/cma_roce_mode | ||
|
||
echo "Installing show_gids..." | ||
install -o root -g root -m 0755 ${parent_path}/ofed_scripts/show_gids /usr/sbin/show_gids | ||
|
||
echo "Installing Mellanox Python utils..." | ||
cd ${parent_path}/ofed_scripts/utils/ | ||
/usr/bin/env python setup.py install | ||
cd ${parent_path} | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2016 Mellanox Technologies. All rights reserved. | ||
# | ||
# This Software is licensed under one of the following licenses: | ||
# | ||
# 1) under the terms of the "Common Public License 1.0" a copy of which is | ||
# available from the Open Source Initiative, see | ||
# http://www.opensource.org/licenses/cpl.php. | ||
# | ||
# 2) under the terms of the "The BSD License" a copy of which is | ||
# available from the Open Source Initiative, see | ||
# http://www.opensource.org/licenses/bsd-license.php. | ||
# | ||
# 3) under the terms of the "GNU General Public License (GPL) Version 2" a | ||
# copy of which is available from the Open Source Initiative, see | ||
# http://www.opensource.org/licenses/gpl-license.php. | ||
# | ||
# Licensee has the right to choose one of the above licenses. | ||
# | ||
# Redistributions of source code must retain the above copyright | ||
# notice and one of the license notices. | ||
# | ||
# Redistributions in binary form must reproduce both the above copyright | ||
# notice, one of the license notices in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# Author: Moni Shoua <[email protected]> | ||
# | ||
|
||
DEVICE=mlx4_0 | ||
PORT=1 | ||
MODE=0 | ||
|
||
usage="Set/Show RoCE mode of RDMA_CM applications | ||
Usage: | ||
cma_roce_mode | ||
Options: | ||
-d <dev> use IB device <dev> (default mlx4_0) | ||
-p <port> use port <port> of IB device (default 1) | ||
-m <roce_mode> set RoCE mode of RDMA_CM applications (default 1)" | ||
|
||
|
||
while getopts "d:m:hp:" arg; do | ||
case $arg in | ||
h) | ||
echo "$usage" | ||
exit | ||
;; | ||
d) | ||
DEVICE=$OPTARG | ||
;; | ||
p) | ||
PORT=$OPTARG | ||
;; | ||
m) | ||
MODE=$OPTARG | ||
;; | ||
esac | ||
done | ||
|
||
ID=$(id -u) | ||
if [ $ID -ne 0 ] ; then | ||
echo you must be root to run this | ||
exit 1 | ||
fi | ||
|
||
if (! cat /proc/mounts |grep /sys/kernel/config > /dev/null) ; then | ||
if (! mount -t configfs none /sys/kernel/config) ; then | ||
echo "Fail to mount configfs" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
if (modinfo configfs &> /dev/null) ; then | ||
if (! cat /proc/modules|grep configfs > /dev/null) ; then | ||
modprobe configfs | ||
fi | ||
fi | ||
|
||
cd /sys/kernel/config/ | ||
|
||
if [ ! -d rdma_cm ] ; then | ||
echo module rdma_cm is not loaded or does not support configfs | ||
exit 1 | ||
fi | ||
|
||
cd rdma_cm | ||
|
||
if [ ! -d $DEVICE ] ; then | ||
sudo mkdir $DEVICE | ||
if [ $? -ne 0 ] ; then | ||
echo failed to creat configuration for $DEVICE | ||
exit 1 | ||
fi | ||
fi | ||
|
||
if [ ! -d $DEVICE/ports/$PORT ] ; then | ||
echo device $DEVICE port $PORT does not exist | ||
exit 1 | ||
fi | ||
|
||
cd $DEVICE/ports/$PORT | ||
|
||
if [ $MODE -eq 1 ] ; then | ||
echo "IB/RoCE v1" |sudo tee default_roce_mode | ||
elif [ $MODE -eq 2 ] ; then | ||
echo "RoCE v2" |sudo tee default_roce_mode | ||
else | ||
cat default_roce_mode | ||
fi | ||
|
||
cd ../../.. | ||
|
||
sudo rmdir $DEVICE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2016 Mellanox Technologies. All rights reserved. | ||
# | ||
# This Software is licensed under one of the following licenses: | ||
# | ||
# 1) under the terms of the "Common Public License 1.0" a copy of which is | ||
# available from the Open Source Initiative, see | ||
# http://www.opensource.org/licenses/cpl.php. | ||
# | ||
# 2) under the terms of the "The BSD License" a copy of which is | ||
# available from the Open Source Initiative, see | ||
# http://www.opensource.org/licenses/bsd-license.php. | ||
# | ||
# 3) under the terms of the "GNU General Public License (GPL) Version 2" a | ||
# copy of which is available from the Open Source Initiative, see | ||
# http://www.opensource.org/licenses/gpl-license.php. | ||
# | ||
# Licensee has the right to choose one of the above licenses. | ||
# | ||
# Redistributions of source code must retain the above copyright | ||
# notice and one of the license notices. | ||
# | ||
# Redistributions in binary form must reproduce both the above copyright | ||
# notice, one of the license notices in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# Author: Moni Shoua <[email protected]> | ||
# | ||
|
||
black='\E[30;50m' | ||
red='\E[31;50m' | ||
green='\E[32;50m' | ||
yellow='\E[33;50m' | ||
blue='\E[34;50m' | ||
magenta='\E[35;50m' | ||
cyan='\E[36;50m' | ||
white='\E[37;50m' | ||
|
||
bold='\033[1m' | ||
|
||
gid_count=0 | ||
|
||
# cecho (color echo) prints text in color. | ||
# first parameter should be the desired color followed by text | ||
function cecho () | ||
{ | ||
echo -en $1 | ||
shift | ||
echo -n $* | ||
tput sgr0 | ||
} | ||
|
||
# becho (color echo) prints text in bold. | ||
becho () | ||
{ | ||
echo -en $bold | ||
echo -n $* | ||
tput sgr0 | ||
} | ||
|
||
function print_gids() | ||
{ | ||
dev=$1 | ||
port=$2 | ||
for gf in /sys/class/infiniband/$dev/ports/$port/gids/* ; do | ||
gid=$(cat $gf); | ||
if [ $gid = 0000:0000:0000:0000:0000:0000:0000:0000 ] ; then | ||
continue | ||
fi | ||
echo -e $(basename $gf) "\t" $gid | ||
done | ||
} | ||
|
||
echo -e "DEV\tPORT\tINDEX\tGID\t\t\t\t\tIPv4 \t\tVER\tDEV" | ||
echo -e "---\t----\t-----\t---\t\t\t\t\t------------ \t---\t---" | ||
DEVS=$1 | ||
if [ -z "$DEVS" ] ; then | ||
DEVS=$(ls /sys/class/infiniband/) | ||
fi | ||
for d in $DEVS ; do | ||
for p in $(ls /sys/class/infiniband/$d/ports/) ; do | ||
for g in $(ls /sys/class/infiniband/$d/ports/$p/gids/) ; do | ||
gid=$(cat /sys/class/infiniband/$d/ports/$p/gids/$g); | ||
if [ $gid = 0000:0000:0000:0000:0000:0000:0000:0000 ] ; then | ||
continue | ||
fi | ||
if [ $gid = fe80:0000:0000:0000:0000:0000:0000:0000 ] ; then | ||
continue | ||
fi | ||
_ndev=$(cat /sys/class/infiniband/$d/ports/$p/gid_attrs/ndevs/$g 2>/dev/null) | ||
__type=$(cat /sys/class/infiniband/$d/ports/$p/gid_attrs/types/$g 2>/dev/null) | ||
_type=$(echo $__type| grep -o "[Vv].*") | ||
if [ $(echo $gid | cut -d ":" -f -1) = "0000" ] ; then | ||
ipv4=$(printf "%d.%d.%d.%d" 0x${gid:30:2} 0x${gid:32:2} 0x${gid:35:2} 0x${gid:37:2}) | ||
echo -e "$d\t$p\t$g\t$gid\t$ipv4 \t$_type\t$_ndev" | ||
else | ||
echo -e "$d\t$p\t$g\t$gid\t\t\t$_type\t$_ndev" | ||
fi | ||
gid_count=$(expr 1 + $gid_count) | ||
done #g (gid) | ||
done #p (port) | ||
done #d (dev) | ||
|
||
echo n_gids_found=$gid_count |
Oops, something went wrong.