From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QYlvO-0003Xf-CC for garchives@archives.gentoo.org; Mon, 20 Jun 2011 21:22:26 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 609471C17A; Mon, 20 Jun 2011 21:22:13 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 207041C171 for ; Mon, 20 Jun 2011 21:22:13 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 87F161B4025 for ; Mon, 20 Jun 2011 21:22:12 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id DE3568003F for ; Mon, 20 Jun 2011 21:22:11 +0000 (UTC) From: "Wiktor W Brodlo" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Wiktor W Brodlo" Message-ID: Subject: [gentoo-commits] proj/anaconda:master commit in: / X-VCS-Repository: proj/anaconda X-VCS-Files: fcoe_edd.sh X-VCS-Directories: / X-VCS-Committer: wiktor X-VCS-Committer-Name: Wiktor W Brodlo X-VCS-Revision: ca4bdab20118cf89838b186ab254cddc3a3cc876 Date: Mon, 20 Jun 2011 21:22:11 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 4ccffbd506792e80edf8616947bc8c18 commit: ca4bdab20118cf89838b186ab254cddc3a3cc876 Author: wiktor w brodlo brodlo net> AuthorDate: Mon Jun 20 21:21:30 2011 +0000 Commit: Wiktor W Brodlo brodlo net> CommitDate: Mon Jun 20 21:21:30 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/anaconda.git;= a=3Dcommit;h=3Dca4bdab2 fcoe_edd.sh from open-fcoe until it works on Gentoo --- fcoe_edd.sh | 235 +++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++ 1 files changed, 235 insertions(+), 0 deletions(-) diff --git a/fcoe_edd.sh b/fcoe_edd.sh new file mode 100755 index 0000000..b571138 --- /dev/null +++ b/fcoe_edd.sh @@ -0,0 +1,235 @@ +#!/bin/bash + +# Script to read EDD information from sysfs and +# echo the FCoE interface name and target info. +# This is a work in progress and will be enhanced +# with more options as we progress further. +# +# Author: Supreeth Venkataraman +# Yi Zou +# Intel Corporation +# +# Usage: fcoe_edd.sh -t for getting FCoE boot target information. +# fcoe_edd.sh -i for getting FCoE boot NIC name. +# fcoe_edd.sh -m for getting FCoE boot NIC MAC. +# fcoe_edd.sh -e for getting FCoE boot EDD information. +# fcoe_edd.sh -r for getting FCoE boot EDD interface type and pat= h. +# fcoe_edd.sh -a for getting all FCoE boot information. +# fcoe_edd.sh -h for usage information. +# Optional: use -v to turn on verbose mode. +# +# Notes: +# FCoE Boot Disk is identified by the following format of boot informati= on +# in its corresponding sysfs firmware edd entry, i.e., +# /sys/firmware/edd/int13_dev??/interface +# which is formatted as (for FCoE): +# string format: FIBRE wwid: 8c1342b8a0001620 lun: 7f00 +# Please ref. to T13 BIOS Enhanced Disk Drive Specification v3.0 for mor= e +# defails on EDD. +# + +SYSEDD=3D/sys/firmware/edd +PREFIX=3D"FIBRE" +VERBOSE=3D +FCOE_INF=3D +FCOE_WWN=3D +FCOE_LUN=3D +FCOE_EDD=3D +FCOE_NIC=3D +FCOE_MAC=3D + + +# +# +# +LOG() { + if [ -n "$1" ] && [ -n "${VERBOSE}" ]; then + echo "LOG:$1" + fi +} + + +find_fcoe_boot_disk() { + local prefix=3D + + if [ ! -e $SYSEDD ]; then + LOG "Need kernel EDD support!" + return 1 + fi +# for disk in `find ${SYSEDD} -maxdepth 1 -name 'int13*'` + for disk in ${SYSEDD}/int13_* + do + LOG " checking $disk..." + if [ ! -e ${disk}/interface ]; then + continue; + fi + LOG " checking ${disk}/interface..." + prefix=3D`awk '{printf $1}' < ${disk}/interface` + if [ "${PREFIX}" !=3D "${prefix}" ]; then + LOG " The FCoE Boot prefix ${prefix} is invalid!" + continue; + fi + FCOE_INF=3D`cat ${disk}/interface` + LOG " found FCoE boot info. from boot rom:${FCOE_INF}..." + + FCOE_WWN=3D`awk '{printf $3}' < ${disk}/interface` + if [ ${#FCOE_WWN} -ne 16 ]; then + LOG " The FCoE Boot WWID ${FCOE_WWN} is invalid!" + continue; + fi + FCOE_LUN=3D`awk '{printf $5}' < ${disk}/interface` + if [ -z "${#FCOE_LUN}" ]; then + LOG " The FCoE Boot LUN ${FCOE_WWN} is invalid!" + continue; + fi + # look for the correponding nic + # FIXME: + # 1) only supporst PCI device? + # 2) at initrd time, the nic name is always eth*? + if [ ! -e ${disk}/pci_dev ]; then + LOG "Failed to locate the corresponing PCI device!" + continue; + fi + if [ ! -e ${disk}/pci_dev/net ]; then + LOG "Failed to detect any NIC device!" + continue; + fi + + for nic in ${disk}/pci_dev/net/* + do + if [ -e ${nic}/address ]; then + FCOE_MAC=3D`cat ${nic}/address` + FCOE_NIC=3D$(basename ${nic}) + break; + fi + done + if [ -z "${FCOE_MAC}" ] || [ -z "${FCOE_NIC}" ]; then + LOG "Failed to locate the corresponing NIC device!" + continue; + fi + # Found the FCoE Boot Device + FCOE_EDD=3D$(basename ${disk}) + return 0; + done + return 1 +} + +get_fcoe_boot_all(){ + echo "### FCoE Boot Information ###" + echo "EDD=3D${FCOE_EDD}" + echo "INF=3D${FCOE_INF}" + echo "WWN=3D${FCOE_WWN}" + echo "LUN=3D${FCOE_LUN}" + echo "NIC=3D${FCOE_NIC}" + echo "MAC=3D${FCOE_MAC}" + return 0 +} + +get_fcoe_boot_target() { + if [ -z "${FCOE_WWN}" ] || [ -z "${FCOE_LUN}" ]; then + LOG "No FCoE Boot Target information is found!" + return 1 + fi + echo "WWN=3D${FCOE_WWN}" + echo "LUN=3D${FCOE_LUN}" +} + +get_fcoe_boot_inf(){ + if [ -z "${FCOE_INF}" ]; then + LOG "No FCoE Boot INF information is found!" + return 1 + fi + echo "INF=3D${FCOE_INF}" + return 0 +} + +get_fcoe_boot_mac(){ + if [ -z "${FCOE_MAC}" ]; then + LOG "No FCoE Boot NIC MAC information is found!" + return 1 + fi + echo "MAC=3D${FCOE_MAC}" + return 0 +} + +get_fcoe_boot_ifname(){ + if [ -z "${FCOE_NIC}" ]; then + LOG "No FCoE Boot NIC information is found!" + return 1 + fi + echo "NIC=3D${FCOE_NIC}" + return 0 +} + +get_fcoe_boot_edd(){ + if [ -z "${FCOE_EDD}" ]; then + LOG "No FCoE Boot Disk EDD information is found!" + return 1 + fi + echo "EDD=3D${FCOE_EDD}" + return 0 +} + + +# parse options +prog=3D$(basename $0) +while getopts "timeravh" OptionName; do + case "$OptionName" in + t) + action=3Dget_fcoe_boot_target + ;; + i) + action=3Dget_fcoe_boot_ifname + ;; + m) + action=3Dget_fcoe_boot_mac + ;; + e) + action=3Dget_fcoe_boot_edd + ;; + r) + action=3Dget_fcoe_boot_inf + ;; + a) + action=3Dget_fcoe_boot_all + ;; + v) + VERBOSE=3D"yes" + ;; + h) + echo "Usage: ${prog} -t for getting FCoE boot target information." + echo " ${prog} -i for getting FCoE boot NIC name." + echo " ${prog} -m for getting FCoE boot NIC MAC." + echo " ${prog} -e for getting FCoE boot EDD information." + echo " ${prog} -r for getting FCoE boot EDD interface type and p= ath." + echo " ${prog} -a for getting all FCoE boot information." + echo " ${prog} -h for usage information." + echo " Optional: use -v to turn on verbose mode." + exit 0 + ;; + *) + echo "Invalid Option. Use -h option for help." + exit 1 + ;; + esac +done +if [ -z "${action}" ]; then + echo "Must specify at least -t, -i, -m, -e, -r, -a, or -h." + echo "Use -h option for help." + exit 1 +fi +# Locate FCoE boot disk and nic information +find_fcoe_boot_disk +if [ $? -ne 0 ]; then + echo "No FCoE boot disk information is found in EDD!" + exit 1 +fi +if [ -z "${FCOE_EDD}" ]; then + echo "No FCoE boot disk is found in EDD!" + exit 1; +fi + +${action} + +exit $? +