From ad973226cb9266ce5cf6946833387c0549c4f3f2 Mon Sep 17 00:00:00 2001 From: Brian King Date: Tue, 23 Aug 2011 04:45:14 +0000 Subject: [PATCH] ofpath: Add support for ethernet and HFI devices Adds support for HFI and ethernet devices to ofpath for IBM Power Systems. Signed-off-by: Brian King Signed-off-by: Tony Breeds --- ybin/ofpath | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/ybin/ofpath b/ybin/ofpath index 1bb33ba..1a601bb 100755 --- a/ybin/ofpath +++ b/ybin/ofpath @@ -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 -- 2.39.2