Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:Update
libibverbs
ibdev2netdev
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ibdev2netdev of Package libibverbs
#! /bin/bash usage() { echo "$(basename $0) <options>" echo "-h, --help print help message" echo "-v, --verbose print more info" } case $1 in "-h" | "--help") usage exit 0 ;; esac if (( $# > 1 )); then usage exit -1 fi if (( $# == 1 )) && [ "$1" != "-v" ]; then usage exit -1 fi ibdevs=$(ls /sys/class/infiniband/) devs=$(ls /sys/class/net/ | grep ^[ei]) if [ "x$devs" == "x" ]; then # no relevant devices - quit immediately exit fi for d in $devs; do if [ -f /sys/class/net/$d/dev_id ]; then oldstyle=n break fi done if [ "x$oldstyle" == "xn" ]; then for d in $ibdevs; do ibrsc=$(cat /sys/class/infiniband/$d/device/resource) eths=$(ls /sys/class/net/) for eth in $eths; do if [ -f /sys/class/net/$eth/device/resource ]; then ethrsc=$(cat /sys/class/net/$eth/device/resource) if [ "x$ethrsc" == "x$ibrsc" ]; then if [ -f /sys/class/net/$eth/dev_id ]; then port=$(cat /sys/class/net/$eth/dev_id) port=$(printf "%d" $port) port=$(( port + 1 )) if [ "$1" == "-v" ]; then ibstate=$(printf "%-6s" $(cat /sys/class/infiniband/$d/ports/$port/state | gawk '{print $2}')) devid=$(printf "MT%d" $(cat /sys/class/infiniband/$d/device/device)) fwver=$(cat /sys/class/infiniband/$d/fw_ver) tmp=$IFS IFS=":" devdesc=$(printf "%-15s" $(strings /sys/class/infiniband/$d/device/vpd | head -1)) partid=$(printf "%-11s" $(strings /sys/class/infiniband/$d/device/vpd | head -4 | tail -1 | gawk '{print $1}')) IFS=$tmp fi if [ -f /sys/class/net/$eth/carrier ]; then link_state=$(cat /sys/class/net/$eth/carrier 2> /dev/null) if (( link_state == 1 )); then link_state="Up" else link_state="Down" fi else link_state="NA" fi if [ "$1" == "-v" ]; then echo "$d ($devid - $partid) $devdesc fw $fwver port $port ($ibstate) ==> $eth ($link_state)" else echo "$d port $port ==> $eth ($link_state)" fi fi fi fi done done else ########################## ### old style ########################## function print_line() { echo "$1 port $2 <===> $3" } function find_guid() { ibdevs=$(ls /sys/class/infiniband/) for ibdev in $ibdevs; do ports=$(ls /sys/class/infiniband/$ibdev/ports/) for port in $ports; do gids=$(ls /sys/class/infiniband/$ibdev/ports/$port/gids) for gid in $gids; do pguid=$(cat /sys/class/infiniband/$ibdev/ports/$port/gids/$gid | cut -b 21- | sed -e 's/://g') if [ x$pguid == x$1 ]; then print_line $ibdev $port $2 fi done done done } function find_mac() { ibdevs=$(ls /sys/class/infiniband/) for ibdev in $ibdevs; do type=$(cat /sys/class/infiniband/$ibdev/node_type|cut -d ' ' -f 2) ports=$(ls /sys/class/infiniband/$ibdev/ports/) for port in $ports; do gids=$(ls /sys/class/infiniband/$ibdev/ports/$port/gids) for gid in $gids; do if [[ "$type" = "RNIC" ]]; then pmac=$(cat /sys/class/infiniband/$ibdev/ports/$port/gids/$gid | cut -b 1-14|sed -e 's/://g') else first=$(cat /sys/class/infiniband/$ibdev/ports/$port/gids/$gid | cut -b 21-22) first=$(( first ^ 2 )) first=$(printf "%02x" $first) second=$(cat /sys/class/infiniband/$ibdev/ports/$port/gids/$gid | cut -b 21- | sed -e 's/://g' | cut -b 3-6) third=$(cat /sys/class/infiniband/$ibdev/ports/$port/gids/$gid | cut -b 21- | sed -e 's/://g' | cut -b 11-) pmac=$first$second$third fi if [ x$pmac == x$1 ]; then print_line $ibdev $port $2 fi done done done } ifcs=$(ifconfig -a | egrep '^eth|^ib' | gawk '{print $1}') for ifc in $ifcs; do len=$(cat /sys/class/net/$ifc/addr_len) if (( len == 20 )); then guid=$(cat /sys/class/net/$ifc/address | cut -b 37- | sed -e 's/://g') find_guid $guid $ifc elif (( len == 6)); then mac=$(cat /sys/class/net/$ifc/address | sed -e 's/://g') find_mac $mac $ifc fi done fi
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor