[ewg] [PATCH] ibdev2netdev: Support RNIC.

Steve Wise swise at opengridcomputing.com
Wed Jun 27 12:48:05 PDT 2012


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 at opengridcomputing.com>
---

 ofed_scripts/ibdev2netdev |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/ofed_scripts/ibdev2netdev b/ofed_scripts/ibdev2netdev
index 7cffa7e..515e170 100755
--- a/ofed_scripts/ibdev2netdev
+++ b/ofed_scripts/ibdev2netdev
@@ -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




More information about the ewg mailing list