diff mbox

[2/5] ofpath: Add support for ethernet and HFI devices

Message ID 201107111402.p6BE2NGK015015@d01av01.pok.ibm.com
State Superseded
Headers show

Commit Message

Brian King July 11, 2011, 2:02 p.m. UTC
Adds support for HFI and ethernet devices to ofpath for
IBM Power Systems.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 ybin/ofpath |   38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)
diff mbox

Patch

diff -puN ybin/ofpath~ofpath_net ybin/ofpath
--- yaboot/ybin/ofpath~ofpath_net	2011-06-24 13:03:06.000000000 -0500
+++ yaboot-bjking1/ybin/ofpath	2011-06-24 13:46:32.000000000 -0500
@@ -880,6 +880,29 @@  oldworld()
     return 0
 }
 
+eth_ofpath()
+{
+        read_attr devspec /sys/class/net/$DEVICE/device
+}
+
+hfi_ofpath()
+{
+        local hfnum=${DEVICE##hf}
+        local hfpath
+
+        if [[ $hfnum = "0" || $hfnum = "2" ]]; then
+                hfpath=$(find /proc/device-tree -name hfi-ethernet* | sort | head -n 1)
+        elif [[ $hfnum = "1" || $hfnum = "3" ]]; then
+                hfpath=$(find /proc/device-tree -name hfi-ethernet* | sort | tail -n 1)
+        else
+		echo 1>&2 "$PRG: Unsupported device: $DEVICE"
+		return 1
+        fi
+
+        hfpath=${hfpath##/proc/device-tree}
+        echo "$hfpath"
+}
+
 ## find OpenFirmware device path for IBM CHRP hardware (scsi only)
 chrp()
 {
@@ -893,6 +916,12 @@  chrp()
 	    ## find the actual OF path.
 	    scsi_ofpath || return 1
 	    ;;
+	eth*)
+	    eth_ofpath || return 1
+	    ;;
+	hfi*)
+	    hfi_ofpath || return 1
+	    ;;
 	*)
 	    echo 1>&2 "$PRG: Device: /dev/$DEVNODE is not supported"
 	    return 1
@@ -1084,15 +1113,6 @@  else
     exit 1
 fi
 
-## check that FILE is a block device and exists.
-if [ ! -e "$device" ] ; then
-    echo 1>&2 "$PRG: $device: No such file or directory"
-    exit 1
-elif [ ! -b "$device" ] ; then
-    echo 1>&2 "$PRG: $device is not a block device"
-    exit 1
-fi
-
 ## check that we are running on a GNU/Linux system, OSX/BSD does not
 ## have the same /proc stuff
 if [ `uname -s` != Linux ] ; then