]> git.openfabrics.org - ~aditr/compat-rdma.git/commitdiff
ibdev2netdev: Support RNIC.
authorSteve Wise <swise@opengridcomputing.com>
Wed, 27 Jun 2012 19:48:05 +0000 (14:48 -0500)
committerVladimir Sokolovsky <vlad@mellanox.com>
Mon, 2 Jul 2012 12:45:43 +0000 (15:45 +0300)
The oldstyle=y logic in ibdev2netdev to match netdevs to ibdevs didn't
work for RNIC devices since their mac address is left justified in
the gid.  This patch uses the type attribute to do the right thing for
RNIC devices.  Note: the oldstyle=n logic works.

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
ofed_scripts/ibdev2netdev

index 7cffa7e74ddfb2e7dcff1c59188c5c1afee25d2a..515e17038fdfaa0d6836cce960b5480bceebfcdc 100755 (executable)
@@ -112,16 +112,21 @@ 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
-                               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
+                               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