Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:lafenghu
open-fcoe
fcoe-utils-beta3-update
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File fcoe-utils-beta3-update of Package open-fcoe
diff --git a/Makefile.am b/Makefile.am index aee2986..e5d0442 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,10 +46,6 @@ log.c include/log.h include/list.h fcoe_configdir = ${sysconfdir}/fcoe dist_fcoe_config_DATA = etc/config etc/cfg-ethx -## install fcoeplumb script in $(prefix)/etc/fcoe/scripts -fcoe_scriptsdir = ${sysconfdir}/fcoe/scripts -fcoe_scripts_SCRIPTS = fcoeplumb - ## man pages for fcoeadm and fcoemon dist_man_MANS = doc/fcoeadm.8 if WITH_DCB @@ -57,17 +53,15 @@ dist_man_MANS += doc/fcoemon.8 endif ## init script for fcoemon -dist_noinst_SCRIPTS = etc/initd/initd.fcoe etc/initd/initd.suse etc/initd/initd.fedora +dist_noinst_SCRIPTS = etc/initd/initd.suse etc/initd/initd.fedora CLEANFILES = etc/initd/fcoe etc/initd/fcoe: mkdir -p etc/initd - if [ -f /etc/fedora-release ]; then \ + if [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ]; then \ ln -s ${abs_srcdir}/etc/initd/initd.fedora $@; \ - elif [ -d /etc/SuSEconfig ]; then \ - ln -s ${abs_srcdir}/etc/initd/initd.suse $@; \ else \ - ln -s ${abs_srcdir}/etc/initd/initd.fcoe $@; \ + ln -s ${abs_srcdir}/etc/initd/initd.suse $@; \ fi init_ddir = ${sysconfdir}/init.d diff --git a/QUICKSTART b/QUICKSTART index e2f91c2..dffe24d 100644 --- a/QUICKSTART +++ b/QUICKSTART @@ -28,7 +28,7 @@ DEPENDENCIES PROCESS 1) Obtain the source tarball from sourceforge - http://sourceforge.net/project/shownotes.php?group_id=42302&release_id=605955 + http://sourceforge.net/projects/e1000/files/DCB%20Tools/0.9.19/dcbd-0.9.19.tar.gz/download 2) Untar the tarball and change into it's directory # tar -xvzf dcbd-x.y.z.tar.gz @@ -68,6 +68,7 @@ PROCESS # tar -xvzf hbaapi_src_2.2.tgz # mv hbaapi_src_2.2/* hbaapi_build/ # rmdir hbaapi_src_2.2/ + # cd hbaapi_build/ 3) Bootstrap, configure, make and make install # ./bootstrap.sh diff --git a/configure.ac b/configure.ac index 66d2e87..6d764e0 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([fcoe-utils], [1.0.9], [devel@open-fcoe.org]) +AC_INIT([fcoe-utils], [1.0.10], [devel@open-fcoe.org]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_PROG_CC @@ -19,6 +19,6 @@ AS_IF([test "X$with_dcb" != Xno], [PKG_CHECK_MODULES([DCBD], [dcbd]) AC_SUBST([DCBD_CFLAGS])]) -AC_CONFIG_FILES([Makefile fcoeplumb fcoe-utils.spec fcoe_utils.h]) +AC_CONFIG_FILES([Makefile fcoe-utils.spec fcoe_utils.h]) AC_OUTPUT diff --git a/contrib/fcc.sh b/contrib/fcc.sh new file mode 100644 index 0000000..053e3bd --- /dev/null +++ b/contrib/fcc.sh @@ -0,0 +1,499 @@ +#! /bin/bash +# +# Copyright 2008-2009 Cisco Systems, Inc. All rights reserved. +# +# This program is free software; you may redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# Author: Joe Eykholt (jeykholt at cisco dot com) +# +# Please send comments and changes to jeykholt at cisco dot com + +VERSION="fcc v1.0.2 10/07/2009" + +fcoe_dir=/sys/module/fcoe +fdir=/sys/class/fc_host +sdir=/sys/class/scsi_host +cmdname=`basename $0` + +usage() { +cat <<USAGE +usage: $cmdname '[<cmd> [<hba> ...]]' + +cmd: + create Start FCoE on an ethernet interface. + delete / del Delete an FCoE instance + destroy Same as destroy + enable / en Same as create + help Show this usage message + info Show HBA detailed info + list List the HBAs with remote port and LUN status + luns Show LUN list and status + stats Show HBA statistics + reset Reset the HBA + version Show version +USAGE +} + +verify_hba() { + local x=$1 + + if [ ! -d $fdir/$x ] + then + echo "$cmdname: invalid HBA name $x" >&2 + exit + fi +} + +hba_stats() { + local x=$1 + local y + + verify_hba $x + + printf "\n$x Statistics:\n" + ( + cd $fdir/$x/statistics + for y in * + do + # + # avoid the write-only files. + # test -r doesn't help if we're root + # + if [ "$y" == "reset_statistics" ] + then + continue + fi + val=`cat $y` + if [ "$val" != 0xffffffffffffffff ] + then + printf "%-30s%8lld\n" $y: $val + fi + done + ) +} + + +# +# format a /sys file containing a hex WWN or FC_ID +# from 0x123456\n to 12:34:56 or from 0xffffffff to - (unknown WWN or FC_ID) +# +fmt_hex() { + sed -e 's/^0xff*$/-/' -e 's/0x//' -e 's/../&:/g' -e 's/:$//' < $1 +} + +rport_list() { + local x + local hba=$1 + + rdir=/sys/class/fc_remote_ports + host=`echo $hba | sed -e 's/host//'` + rports=`ls -d $rdir/rport-$host:* 2>/dev/null` + if [ -z "$rports" ] + then + return + fi + + printf "\n$hba Remote Ports:\n" + + + fmt="%-8s %-23s %-8s %-8s %-15s\n" + + printf "$fmt" Path "Port Name" "Port ID" State Roles + for x in $rports + do + btl="`echo $x | sed -e 's/.*-\(.*-.*\)/\1/'`" + printf "$fmt" "$btl" \ + "`fmt_hex $x/port_name`" \ + "`fmt_hex $x/port_id`" \ + "`cat $x/port_state`" \ + "`cat $x/roles`" + done +} + +# +# Translate capacity to readable units. +# compute sizes in base-10 marketing units +# +lun_cap() { + local sizek=0 sizem=0 sizeg=0 sizet=0 + local size + local onek=1000 + local cap + + size=$1 + let sizek="$size * 512 / $onek" + let sizem="$sizek / $onek" + let sizeg="$sizem / $onek" + let sizet="$sizeg / $onek" + if [ "$sizet" -gt 0 ] + then + cap="$sizet TB" + elif [ "$sizeg" -gt 0 ] + then + cap="$sizeg GB" + elif [ "$sizem" -gt 0 ] + then + cap="$sizem MB" + else + cap="$sizek KB" + fi + echo $cap +} + +lun_list() { + local x + local lun + local hba=$1 + local ddir=/sys/class/scsi_device + + host=`echo $hba | sed -e 's/host//'` + + local luns=`(cd $ddir && ls -d $host:*) 2>/dev/null` + + if [ -z "$luns" ] + then + return + fi + + printf "\n$hba LUNs:\n" + + fmt="%-10s %-8s %6s %-15s %-20s %-8s\n" + + printf "$fmt" Path Device Size Vendor Model State + + for lun in $luns + do + ( + local size=0 + cap=- + + cd $ddir/$lun/device + if [ -d block ] + then + dev=`ls block | tail -1` + size=`cat block/$dev/size` + cap=`lun_cap $size` + elif [ -d char ] + then + dev=`ls char | tail -1` + cap=- + elif [ -d scsi_tape ] + then + dev=`ls scsi_tape | egrep '^st[0-9]*$'` + cap=- + elif [ -d scsi_generic ] + then + dev=`ls scsi_generic | tail -1` + cap=- + else + dev="`ls -d block:* char:* 2>/dev/null | + sed -e 's/.*\://'`" + if [ -L block:$dev -o -d block:$dev ] + then + size=`cat block:$dev/size` + cap=`lun_cap $size` + fi + fi + + printf "$fmt" "$lun" "$dev" "$cap"\ + "`cat vendor`" \ + "`cat model`" \ + "`cat state`" + ) + done +} + +sym_name() { + local hba=$1 + local file + + file=$fdir/$hba/symbolic_name + if [ -f "$file" ] + then + sed -e 's/.*over //' < $file + else + exit 1 + fi +} + +# +# Lookup the host name for a given symbolic name +# +hba_name() { + local sym=$1 + local hba + + if [ -d "$fdir/$sym" ] + then + echo $sym + exit + fi + + for hba in $all_hbas + do + if [ "`sym_name $hba`" = "$sym" ] + then + echo $hba + exit + fi + done + exit 1 +} + +hba_state() { + local x + + echo "FC HBAs:" + fmt="%-8s %-23s %-8s %-8s %-15s\n" + printf "$fmt" HBA "Port Name" "Port ID" State Device + for x in $hbas + do + ( + cd $fdir/$x + printf "$fmt" "$x" \ + "`fmt_hex $fdir/$x/port_name`" \ + "`fmt_hex $fdir/$x/port_id`" \ + "`cat $fdir/$x/port_state`" \ + "`sym_name $x`" + ) 2>/dev/null + done +} + +hba_info() { + local x=`hba_name $1` + local fmt="\t%-20s %s\n" + + verify_hba $x + printf "\n$x Info:\n" + ( + cd $fdir/$x + + printf "$fmt" "Symbolic Name" "`cat symbolic_name`" + printf "$fmt" "Port Name" "`fmt_hex port_name`" + printf "$fmt" "Node Name" "`fmt_hex node_name`" + printf "$fmt" "Port Type" "`cat port_type`" + echo + printf "$fmt" "Port State" "`cat port_state`" + printf "$fmt" "Port ID" "`fmt_hex port_id`" + printf "$fmt" "Fabric Name" "`fmt_hex fabric_name`" + echo + printf "$fmt" "Max Frame Size" "`cat maxframe_size`" + printf "$fmt" "Speed" "`cat speed`" + echo + ) +} + +scsi_state() { + local x + local dev + + printf "\nSCSI States:\n" + fmt="%-8s %-10s %-15s %-10s %8s\n" + printf "$fmt" HBA Device Mode State Busy + for x in $scsi_hbas + do + ( + cd $fdir/$x + dev="`cat $sdir/$x/proc_name``cat $sdir/$x/unique_id`" + printf "$fmt" "$x" "$dev" \ + "`cat $sdir/$x/active_mode`" \ + "`cat $sdir/$x/state`" \ + "`cat $sdir/$x/host_busy`" + ) 2>/dev/null + done +} + +hba_list() { + local x + + hba_state + # scsi_state + + for x in $hbas + do + rport_list $x + lun_list $x + done +} + +# +# Do a command for a list of arguments +# +repeat() { + local cmd=$1 + local x + shift + + for x + do + $cmd $x + done +} + +fcoe_ctl() { + local hba=$1 + local cmd=$2 + local file=$fcoe_dir/parameters/$2 + local old_file=$fcoe_dir/$2 + + if [ -w "$old_file" ] + then + file=$old_file + fi + + if [ -w "$file" ] + then + echo $hba > $file + elif [ -f "$file" ] + then + echo "$cmdname: no permission to $cmd $hba" >&2 + else + echo "$cmdname: file $file doesn't exist. " \ + "Check for fcoe module." >&2 + fi +} + +fc_host_ctl() { + local hba=$1 + local cmd=$2 + local value=$3 + local file + local dir + + dir=$fdir/$hba + if [ ! -d "$dir" ] + then + dir=$fdir/`hba_name $hba` + if [ $? != 0 ] + then + echo "$cmdname: hba $hba not found" >&2 + exit 1 + fi + fi + file=$dir/$cmd + + if [ -w "$file" ] + then + echo $value > $file + elif [ -f "$file" ] + then + echo "$cmdname: no permission to $cmd $hba" 1>&2 + exit 2 + else + echo "$cmdname: $cmd not supported for $hba" 1>&2 + exit 2 + fi +} + +# +# Start of main script code. +# +scsi_hbas= +if [ -d "$sdir" ] +then + scsi_hbas=`ls $sdir 2>/dev/null` +fi +if [ -d "$fdir" ] +then + all_hbas=`ls $fdir 2>/dev/null` +fi +hbas="$all_hbas" + +if [ $# -lt 1 ] +then + hba_list + exit 0 +fi + +if [ $# -lt 2 ] +then + cmd=$1 + hba_spec=no +else + cmd=$1 + hba=$2 + shift + if [ $# -eq 0 ] + then + hba_spec=n + elif [ $# -eq 1 -a "$1" = all ] + then + hba_spec=y + else + hba_spec=y + hbas="$@" + scsi_hbas="$@" + fi +fi + +case "$cmd" in + create | enable | en) + if [ ! -d $fcoe_dir ] + then + modprobe fcoe + echo "$cmdname: loading fcoe module" >&2 + sleep 1 + if [ ! -d $fcoe_dir ] + then + echo "$cmdname: $fcoe_dir not found" >&2 + exit 2 + fi + fi + fcoe_ctl $hba create + ;; + delete | del | destroy) + if [ ! -d $fcoe_dir ] + then + echo "$cmdname: $fcoe_dir not found" >&2 + exit 2 + fi + fcoe_ctl $hba destroy + ;; + info) + repeat hba_info $hbas + ;; + list) + hba_list + ;; + lun*) + repeat lun_list $hbas + ;; + names) + repeat echo $hbas + ;; + stat*) + repeat hba_stats $hbas + ;; + realname) + hba_name $hba + ;; + reset) + if [ "$hba_spec" != y ] + then + echo "$cmdname: reset requires hba name" >&2 + exit 2 + fi + for hba in $hbas + do + (fc_host_ctl $hba issue_lip 1 && + echo "reset $hba") || break + done + ;; + version) + echo $VERSION + ;; + *) + usage + ;; +esac diff --git a/debug/fcc.sh b/debug/fcc.sh deleted file mode 100755 index 053e3bd..0000000 --- a/debug/fcc.sh +++ /dev/null @@ -1,499 +0,0 @@ -#! /bin/bash -# -# Copyright 2008-2009 Cisco Systems, Inc. All rights reserved. -# -# This program is free software; you may redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# Author: Joe Eykholt (jeykholt at cisco dot com) -# -# Please send comments and changes to jeykholt at cisco dot com - -VERSION="fcc v1.0.2 10/07/2009" - -fcoe_dir=/sys/module/fcoe -fdir=/sys/class/fc_host -sdir=/sys/class/scsi_host -cmdname=`basename $0` - -usage() { -cat <<USAGE -usage: $cmdname '[<cmd> [<hba> ...]]' - -cmd: - create Start FCoE on an ethernet interface. - delete / del Delete an FCoE instance - destroy Same as destroy - enable / en Same as create - help Show this usage message - info Show HBA detailed info - list List the HBAs with remote port and LUN status - luns Show LUN list and status - stats Show HBA statistics - reset Reset the HBA - version Show version -USAGE -} - -verify_hba() { - local x=$1 - - if [ ! -d $fdir/$x ] - then - echo "$cmdname: invalid HBA name $x" >&2 - exit - fi -} - -hba_stats() { - local x=$1 - local y - - verify_hba $x - - printf "\n$x Statistics:\n" - ( - cd $fdir/$x/statistics - for y in * - do - # - # avoid the write-only files. - # test -r doesn't help if we're root - # - if [ "$y" == "reset_statistics" ] - then - continue - fi - val=`cat $y` - if [ "$val" != 0xffffffffffffffff ] - then - printf "%-30s%8lld\n" $y: $val - fi - done - ) -} - - -# -# format a /sys file containing a hex WWN or FC_ID -# from 0x123456\n to 12:34:56 or from 0xffffffff to - (unknown WWN or FC_ID) -# -fmt_hex() { - sed -e 's/^0xff*$/-/' -e 's/0x//' -e 's/../&:/g' -e 's/:$//' < $1 -} - -rport_list() { - local x - local hba=$1 - - rdir=/sys/class/fc_remote_ports - host=`echo $hba | sed -e 's/host//'` - rports=`ls -d $rdir/rport-$host:* 2>/dev/null` - if [ -z "$rports" ] - then - return - fi - - printf "\n$hba Remote Ports:\n" - - - fmt="%-8s %-23s %-8s %-8s %-15s\n" - - printf "$fmt" Path "Port Name" "Port ID" State Roles - for x in $rports - do - btl="`echo $x | sed -e 's/.*-\(.*-.*\)/\1/'`" - printf "$fmt" "$btl" \ - "`fmt_hex $x/port_name`" \ - "`fmt_hex $x/port_id`" \ - "`cat $x/port_state`" \ - "`cat $x/roles`" - done -} - -# -# Translate capacity to readable units. -# compute sizes in base-10 marketing units -# -lun_cap() { - local sizek=0 sizem=0 sizeg=0 sizet=0 - local size - local onek=1000 - local cap - - size=$1 - let sizek="$size * 512 / $onek" - let sizem="$sizek / $onek" - let sizeg="$sizem / $onek" - let sizet="$sizeg / $onek" - if [ "$sizet" -gt 0 ] - then - cap="$sizet TB" - elif [ "$sizeg" -gt 0 ] - then - cap="$sizeg GB" - elif [ "$sizem" -gt 0 ] - then - cap="$sizem MB" - else - cap="$sizek KB" - fi - echo $cap -} - -lun_list() { - local x - local lun - local hba=$1 - local ddir=/sys/class/scsi_device - - host=`echo $hba | sed -e 's/host//'` - - local luns=`(cd $ddir && ls -d $host:*) 2>/dev/null` - - if [ -z "$luns" ] - then - return - fi - - printf "\n$hba LUNs:\n" - - fmt="%-10s %-8s %6s %-15s %-20s %-8s\n" - - printf "$fmt" Path Device Size Vendor Model State - - for lun in $luns - do - ( - local size=0 - cap=- - - cd $ddir/$lun/device - if [ -d block ] - then - dev=`ls block | tail -1` - size=`cat block/$dev/size` - cap=`lun_cap $size` - elif [ -d char ] - then - dev=`ls char | tail -1` - cap=- - elif [ -d scsi_tape ] - then - dev=`ls scsi_tape | egrep '^st[0-9]*$'` - cap=- - elif [ -d scsi_generic ] - then - dev=`ls scsi_generic | tail -1` - cap=- - else - dev="`ls -d block:* char:* 2>/dev/null | - sed -e 's/.*\://'`" - if [ -L block:$dev -o -d block:$dev ] - then - size=`cat block:$dev/size` - cap=`lun_cap $size` - fi - fi - - printf "$fmt" "$lun" "$dev" "$cap"\ - "`cat vendor`" \ - "`cat model`" \ - "`cat state`" - ) - done -} - -sym_name() { - local hba=$1 - local file - - file=$fdir/$hba/symbolic_name - if [ -f "$file" ] - then - sed -e 's/.*over //' < $file - else - exit 1 - fi -} - -# -# Lookup the host name for a given symbolic name -# -hba_name() { - local sym=$1 - local hba - - if [ -d "$fdir/$sym" ] - then - echo $sym - exit - fi - - for hba in $all_hbas - do - if [ "`sym_name $hba`" = "$sym" ] - then - echo $hba - exit - fi - done - exit 1 -} - -hba_state() { - local x - - echo "FC HBAs:" - fmt="%-8s %-23s %-8s %-8s %-15s\n" - printf "$fmt" HBA "Port Name" "Port ID" State Device - for x in $hbas - do - ( - cd $fdir/$x - printf "$fmt" "$x" \ - "`fmt_hex $fdir/$x/port_name`" \ - "`fmt_hex $fdir/$x/port_id`" \ - "`cat $fdir/$x/port_state`" \ - "`sym_name $x`" - ) 2>/dev/null - done -} - -hba_info() { - local x=`hba_name $1` - local fmt="\t%-20s %s\n" - - verify_hba $x - printf "\n$x Info:\n" - ( - cd $fdir/$x - - printf "$fmt" "Symbolic Name" "`cat symbolic_name`" - printf "$fmt" "Port Name" "`fmt_hex port_name`" - printf "$fmt" "Node Name" "`fmt_hex node_name`" - printf "$fmt" "Port Type" "`cat port_type`" - echo - printf "$fmt" "Port State" "`cat port_state`" - printf "$fmt" "Port ID" "`fmt_hex port_id`" - printf "$fmt" "Fabric Name" "`fmt_hex fabric_name`" - echo - printf "$fmt" "Max Frame Size" "`cat maxframe_size`" - printf "$fmt" "Speed" "`cat speed`" - echo - ) -} - -scsi_state() { - local x - local dev - - printf "\nSCSI States:\n" - fmt="%-8s %-10s %-15s %-10s %8s\n" - printf "$fmt" HBA Device Mode State Busy - for x in $scsi_hbas - do - ( - cd $fdir/$x - dev="`cat $sdir/$x/proc_name``cat $sdir/$x/unique_id`" - printf "$fmt" "$x" "$dev" \ - "`cat $sdir/$x/active_mode`" \ - "`cat $sdir/$x/state`" \ - "`cat $sdir/$x/host_busy`" - ) 2>/dev/null - done -} - -hba_list() { - local x - - hba_state - # scsi_state - - for x in $hbas - do - rport_list $x - lun_list $x - done -} - -# -# Do a command for a list of arguments -# -repeat() { - local cmd=$1 - local x - shift - - for x - do - $cmd $x - done -} - -fcoe_ctl() { - local hba=$1 - local cmd=$2 - local file=$fcoe_dir/parameters/$2 - local old_file=$fcoe_dir/$2 - - if [ -w "$old_file" ] - then - file=$old_file - fi - - if [ -w "$file" ] - then - echo $hba > $file - elif [ -f "$file" ] - then - echo "$cmdname: no permission to $cmd $hba" >&2 - else - echo "$cmdname: file $file doesn't exist. " \ - "Check for fcoe module." >&2 - fi -} - -fc_host_ctl() { - local hba=$1 - local cmd=$2 - local value=$3 - local file - local dir - - dir=$fdir/$hba - if [ ! -d "$dir" ] - then - dir=$fdir/`hba_name $hba` - if [ $? != 0 ] - then - echo "$cmdname: hba $hba not found" >&2 - exit 1 - fi - fi - file=$dir/$cmd - - if [ -w "$file" ] - then - echo $value > $file - elif [ -f "$file" ] - then - echo "$cmdname: no permission to $cmd $hba" 1>&2 - exit 2 - else - echo "$cmdname: $cmd not supported for $hba" 1>&2 - exit 2 - fi -} - -# -# Start of main script code. -# -scsi_hbas= -if [ -d "$sdir" ] -then - scsi_hbas=`ls $sdir 2>/dev/null` -fi -if [ -d "$fdir" ] -then - all_hbas=`ls $fdir 2>/dev/null` -fi -hbas="$all_hbas" - -if [ $# -lt 1 ] -then - hba_list - exit 0 -fi - -if [ $# -lt 2 ] -then - cmd=$1 - hba_spec=no -else - cmd=$1 - hba=$2 - shift - if [ $# -eq 0 ] - then - hba_spec=n - elif [ $# -eq 1 -a "$1" = all ] - then - hba_spec=y - else - hba_spec=y - hbas="$@" - scsi_hbas="$@" - fi -fi - -case "$cmd" in - create | enable | en) - if [ ! -d $fcoe_dir ] - then - modprobe fcoe - echo "$cmdname: loading fcoe module" >&2 - sleep 1 - if [ ! -d $fcoe_dir ] - then - echo "$cmdname: $fcoe_dir not found" >&2 - exit 2 - fi - fi - fcoe_ctl $hba create - ;; - delete | del | destroy) - if [ ! -d $fcoe_dir ] - then - echo "$cmdname: $fcoe_dir not found" >&2 - exit 2 - fi - fcoe_ctl $hba destroy - ;; - info) - repeat hba_info $hbas - ;; - list) - hba_list - ;; - lun*) - repeat lun_list $hbas - ;; - names) - repeat echo $hbas - ;; - stat*) - repeat hba_stats $hbas - ;; - realname) - hba_name $hba - ;; - reset) - if [ "$hba_spec" != y ] - then - echo "$cmdname: reset requires hba name" >&2 - exit 2 - fi - for hba in $hbas - do - (fc_host_ctl $hba issue_lip 1 && - echo "reset $hba") || break - done - ;; - version) - echo $VERSION - ;; - *) - usage - ;; -esac diff --git a/doc/fcoemon.8 b/doc/fcoemon.8 index 556e067..80e3f58 100644 --- a/doc/fcoemon.8 +++ b/doc/fcoemon.8 @@ -12,14 +12,12 @@ \fBfcoemon\fR [\fB\-d\fR | \fB\-\-debug\fR] .P \fBfcoemon\fR [\fB\-s\fR | \fB\-\-syslog\fR] -.P -\fBfcoemon\fR [\fB\-e\fR | \fB\-\-exec\fR \fI<path\-to\-fcoeplumb\-script>\fR] .SH "DESCRIPTION" The \fBfcoemon\fR command is a FCoE management tool provided by the \fBfcoe-utils\fR package. \fBfcoemon\fR is the daemon of the \fBfcoe\fR system service. When \fBfcoemon\fR starts, it establishes a socket connection with the DCB daemon (\fBdcbd\fR). It then sends commands to, and receives responses and events from \fBdcbd\fR. \fBfcoemon\fR will process the responses -and events and will invoke the \fBfcoeplumb\fR script to create and destroy the FCoE interfaces as needed. +and events and will create or destroy the FCoE interfaces as needed. Since \fBfcoemon\fR can depend on \fBdcbd\fR, there may be settings required for \fBdcbd\fR before \fBfcoemon\fR can be started. See the \fIDCB Settings\fR section below. The \fBfcoe\fR system may or may not depend on the DCB service. \fBfcoemon\fR will be @@ -38,9 +36,6 @@ Enable debugging messages. .TP \fB\-s | \-\-syslog\fR Use syslogd for logging. The default behavior is to log to stdout and stderr. -.TP -\fB\-e | \-\-exec\fR \fI<path\-of\-fcoeplumb\-script>\fR -Specify the location of the \fBfcoeplumb\fR script. .SH "TERMINOLOGY" .TP \fBPFC\fR \- The DCB Priority Flow Control feature. @@ -139,7 +134,7 @@ Installation of the fcoe-utils management tools include the following files: .TP \fI/etc/fcoe/config\fR This is the primary configuration file for the \fBfcoe\fR system service. The default options in this file are: \fBDEBUG="no"\fR and \fBUSE_SYSLOG="yes"\fR. The former is used to enable -debugging messages from the \fBfcoe\fR service script, \fBfcoemon\fR, and the \fBfcoeplumb\fR script. The latter is +debugging messages from the \fBfcoe\fR service script and \fBfcoemon\fR. The latter is to indicate if the log messages are to be output to the system log. Any changes to this file will require a restart of the \fBfcoe\fR service. .TP \fI/etc/fcoe/cfg-<ifname>\fR @@ -159,9 +154,6 @@ This is the \fBfcoemon\fR daemon only invoked by the \fBfcoe\fR system service s .TP \fI/sbin/fcoeadm\fR This is the program used by the \fBfcoe\fR system service to create or destroy FCoE interfaces. -.TP -\fI/etc/fcoe/scripts/fcoeplumb\fR -This is a script only used by the \fBfcoemon\fR daemon. .SH "REPORTING BUGS" If you have identified a defect please file a bug with your distribution or engage the development mailing list at <http://www.Open\-FCoE.org>. diff --git a/etc/cfg-ethx b/etc/cfg-ethx index a9140f9..96eca59 100644 --- a/etc/cfg-ethx +++ b/etc/cfg-ethx @@ -1,7 +1,7 @@ ## Type: yes/no ## Default: no # Enable/Disable FCoE service at the Ethernet port -FCOE_ENABLE="no" +FCOE_ENABLE="yes" ## Type: yes/no ## Default: yes diff --git a/etc/initd/initd.fcoe b/etc/initd/initd.fcoe deleted file mode 100755 index 44e34ff..0000000 --- a/etc/initd/initd.fcoe +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/sh -# -# Copyright(c) 2009 Intel Corporation. All rights reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms and conditions of the GNU General Public License, -# version 2, as published by the Free Software Foundation. -# -# This program is distributed in the hope it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. -# -# Maintained at www.Open-FCoE.org -# -# -# chkconfig: 2345 92 19 -# description: OpenFC and FCoE: Fibre Channel over Ethernet SAN setup - -PATH=/sbin:/bin:/usr/sbin:/usr/bin - -HBA= -FCOEADM=fcoeadm -FCOE_CONF=/etc/fcoe/open-fcoe.conf - -# validates the ifname -fcoe_gethba() { - HBA= - if [ ! -e $FCOE_CONF ] - then - echo "Open-fcoe config file $FCOE_CONF not found!" - return - fi - # get HBA= - HBA=`grep -v "#" $FCOE_CONF | grep "HBA=" | cut -f2 -d=` - if ! ifconfig $HBA &> /dev/null - then - echo "HBA $HBA not found in $FCOE_CONF!" - HBA= - fi -} -# check fcoeadm -which $FCOEADM > /dev/null 2>&1 -if [ "$?" -eq "1" ] -then - echo "$0: $FCOEADM command not installed" >&2 - exit 1 -fi - -# Switch on start / stop argument -case "$1" in -start) - - # start fcmon - lsmod | grep fcoe &> /dev/null - if [ "$?" -eq "1" ] - then - modprobe -q fcoe 2> /dev/null - if [ "$?" -eq "1" ] - then - echo "Failed to load FCoE driver module!" - exit 1 - fi - fi - # get HBA from conf - fcoe_gethba - if [ -z "$HBA" ] - then - echo "Please setup the config file $FCOE_CONF first!" - exit 1 - else - $FCOEADM --create $HBA >&2 - fi - ;; - -stop) - lsmod | grep fcoe &> /dev/null - if [ "$?" -eq "1" ] - then - echo "Open-FCoE driver module not loaded!" - exit 1 - fi - fcoe_gethba - if [ -n "$HBA" ] - then - $FCOEADM --destroy $HBA >&2 - fi - ;; - -status) - lsmod | grep fcoe &> /dev/null - if [ "$?" -eq "1" ] - then - echo "Open-FCoE driver module not loaded!" - exit 1 - fi - fcoe_gethba - $FCOEADM --query $HBA >&2 - ;; - -restart | reload) - $0 stop - $0 start - ;; - -save) - ;; - -*) - echo "Usage: $0 {start|stop|reload|restart|status}" >&2 - exit 1 - ;; -esac diff --git a/etc/initd/initd.fedora b/etc/initd/initd.fedora index 67c3e5f..edc0f87 100755 --- a/etc/initd/initd.fedora +++ b/etc/initd/initd.fedora @@ -27,7 +27,6 @@ ### END INIT INFO CONFIG_DIR=/etc/fcoe -CONFIG_SCRIPT=$CONFIG_DIR/scripts/fcoeplumb PID_FILE="/var/run/fcoemon.pid" LOG_FILE="/var/log/fcoemon.log" FCOEMON=/usr/sbin/fcoemon @@ -94,14 +93,6 @@ if [ "$DEBUG" = "yes" ] || [ "$DEBUG" = "YES" ]; then FCOEMON_OPTS+=" --debug" fi -test -x $CONFIG_SCRIPT || { - $LOGGER "$CONFIG_SCRIPT not installed"; - if [ "$1" = "stop" ]; then exit 0; - else - failure - fi -} - test -x $FCOEADM || { $LOGGER "$FCOEADM not installed"; if [ "$1" = "stop" ]; then exit 0; @@ -141,15 +132,6 @@ service_stop() pidof $FCOEMON [ $? -eq 0 ] && kill -TERM `pidof $FCOEMON` - retry_count=5 - while true - do - [ $retry_count -eq 0 ] && break - ps | grep -q fcoeplumb - [ $? -ne 0 ] && [ ! -f $PID_FILE ] && break - sleep 1 - retry_count=$(($retry_count-1)) - done rm -f /var/run/fcoemon.* rm -f /tmp/fcoemon.dcbd.* } diff --git a/etc/initd/initd.suse b/etc/initd/initd.suse index b4b1b76..62cd4e5 100755 --- a/etc/initd/initd.suse +++ b/etc/initd/initd.suse @@ -40,7 +40,6 @@ ### END INIT INFO CONFIG_DIR=/etc/fcoe -CONFIG_SCRIPT=$CONFIG_DIR/scripts/fcoeplumb PID_FILE="/var/run/fcoemon.pid" LOG_FILE="/var/log/fcoemon.log" FCOEMON=/usr/sbin/fcoemon @@ -120,16 +119,6 @@ if [ "$DEBUG" = "yes" ] || [ "$DEBUG" = "YES" ]; then FCOEMON_OPTS+=" --debug" fi -test -x $CONFIG_SCRIPT || { - $LOGGER "$CONFIG_SCRIPT not installed"; - if [ "$1" = "stop" ]; then exit 0; - else - rc_failed - rc_status -v - rc_exit - fi -} - test -x $FCOEADM || { $LOGGER "$FCOEADM not installed"; if [ "$1" = "stop" ]; then exit 0; @@ -200,15 +189,6 @@ service_stop() checkproc $FCOEMON [ $? -eq 0 ] && killproc -TERM $FCOEMON - retry_count=5 - while true - do - [ $retry_count -eq 0 ] && break - ps | grep -q fcoeplumb - [ $? -ne 0 ] && [ ! -f $PID_FILE ] && break - sleep 1 - retry_count=$(($retry_count-1)) - done rm -f /var/run/fcoemon.* rm -f /tmp/fcoemon.dcbd.* diff --git a/fcoeadm.c b/fcoeadm.c index 9996e6e..8b2a6b6 100644 --- a/fcoeadm.c +++ b/fcoeadm.c @@ -76,27 +76,27 @@ static int fcoeadm_check(char *ifname) /* check if we have sysfs */ if (fcoeclif_checkdir(SYSFS_MOUNT)) { fprintf(stderr, - "%s: Sysfs mount point %s not found!\n", + "%s: Sysfs mount point %s not found\n", progname, SYSFS_MOUNT); status = -EINVAL; } /* check target interface */ if (!ifname) { - fprintf(stderr, "%s: Invalid interface name!\n", progname); + fprintf(stderr, "%s: Invalid interface name\n", progname); status = -EINVAL; } sprintf(path, "%s/%s", SYSFS_NET, ifname); if (fcoeclif_checkdir(path)) { fprintf(stderr, - "%s: Interface %s not found!\n", progname, ifname); + "%s: Interface %s not found\n", progname, ifname); status = -EINVAL; } fd = open(CLIF_PID_FILE, O_RDWR, S_IRUSR | S_IWUSR); if (fd < 0) { fprintf(stderr, - "%s: fcoemon was not running!\n", progname); + "%s: fcoemon was not running\n", progname); status = -EINVAL; } @@ -104,7 +104,7 @@ static int fcoeadm_check(char *ifname) } static int fcoeadm_clif_request(const struct clif_data *cmd, size_t cmd_len, - char *reply, size_t *reply_len) + char *reply, size_t *reply_len) { struct timeval tv; int ret; @@ -121,14 +121,11 @@ static int fcoeadm_clif_request(const struct clif_data *cmd, size_t cmd_len, ret = select(clif_conn->s + 1, &rfds, NULL, NULL, &tv); if (FD_ISSET(clif_conn->s, &rfds)) { ret = recv(clif_conn->s, reply, *reply_len, 0); - if (ret < 0) { - fprintf(stderr, "less then zero\n"); + if (ret < 0) return ret; - } *reply_len = ret; break; } else { - fprintf(stderr, "timeout\n"); return -2; } } @@ -144,7 +141,7 @@ static int fcoeadm_request(int cmd, char *s) int ret; if (clif_conn == NULL) { - printf("Not connected to fcoemon.\n"); + fprintf(stderr, "Not connected to fcoemon\n"); return -EINVAL; } @@ -160,10 +157,10 @@ static int fcoeadm_request(int cmd, char *s) ret = fcoeadm_clif_request(data, sizeof(struct clif_data), rbuf, &len); if (ret == -2) { - printf("%d command timed out.\n", cmd); + fprintf(stderr, "Command timed out\n"); goto fail; } else if (ret < 0) { - printf("%d command failed.\n", cmd); + fprintf(stderr, "Command failed\n"); goto fail; } @@ -271,7 +268,7 @@ static int fcoeadm_action(int cmd, char *device_name) if (clif_conn) { break; } else { - fprintf(stderr, "Failed to connect to fcoemon.\n"); + fprintf(stderr, "Failed to connect to fcoemon\n"); free(clif_ifname); return -1; } @@ -292,7 +289,7 @@ static int fcoeadm_create(char *ifname) { if (fcoeadm_check(ifname)) { fprintf(stderr, - "%s: Failed to create FCoE instance on %s!\n", + "%s: Failed to create FCoE instance on %s\n", progname, ifname); return -EINVAL; } @@ -306,7 +303,7 @@ static int fcoeadm_destroy(char *ifname) { if (fcoeadm_check(ifname)) { fprintf(stderr, - "%s: Failed to destroy FCoE instance on %s!\n", + "%s: Failed to destroy FCoE instance on %s\n", progname, ifname); return -EINVAL; } @@ -592,7 +589,7 @@ stats: goto done; error: - fprintf(stderr, "%s: Invalid command options!\n", progname); + fprintf(stderr, "%s: Invalid command options\n", progname); fcoeadm_help(); exit(-EINVAL); diff --git a/fcoemon.c b/fcoemon.c index 32ba930..2847da4 100644 --- a/fcoemon.c +++ b/fcoemon.c @@ -70,7 +70,6 @@ #define CONFIG_MAX_VAL_LEN (20 + 2) #define DCB_APP_0_DEFAULT_ENABLE 1 #define DCB_APP_0_DEFAULT_WILLING 1 -#define FCM_DEFAULT_QOS_MASK (1 << 3) #define FILE_NAME_LEN (NAME_MAX + 1) #define VLAN_DIR "/proc/net/vlan" @@ -86,6 +85,8 @@ #define FCOE_CREATE SYSFS_FCOE "/create" #define FCOE_DESTROY SYSFS_FCOE "/destroy" +#define FCOE_ENABLE SYSFS_FCOE "/enable" +#define FCOE_DISABLE SYSFS_FCOE "/disable" static char *fcoemon_version = "fcoemon v" FCOE_UTILS_VERSION "\n Copyright (c) 2009, Intel Corporation.\n"; @@ -125,8 +126,6 @@ enum fcoeport_ifname { FCP_REAL_IFNAME }; -static u_int8_t fcm_def_qos_mask = FCM_DEFAULT_QOS_MASK; - /* * Interact with DCB daemon. */ @@ -152,8 +151,6 @@ static struct fcm_clif fcm_clif_st; static struct fcm_clif *fcm_clif = &fcm_clif_st; static struct sa_timer fcm_dcbd_timer; -char *fcm_dcbd_cmd = CONFIG_DIR "/scripts/fcoeplumb"; - /* Debugging routine */ static void print_errors(int errors); @@ -274,6 +271,23 @@ static size_t fcm_read_config_variable(char *file, char *val_buf, size_t len, return 0; } +static struct fcoe_port *alloc_fcoe_port(char *ifname) +{ + struct fcoe_port *p = NULL; + + p = (struct fcoe_port *) calloc(1, sizeof(struct fcoe_port)); + if (p) { + snprintf(p->ifname, sizeof(p->ifname), "%s", ifname); + p->action = FCP_WAIT; + /* last_action is initialized to FCP_DESTROY_IF to indicate + * that the interface is not created yet. + */ + p->last_action = FCP_DESTROY_IF; + } + + return p; +} + static int fcm_read_config_files(void) { char file[80]; @@ -301,15 +315,13 @@ static int fcm_read_config_files(void) rc = strncmp(dp->d_name, "cfg-", strlen("cfg-")); if (rc) continue; - next = (struct fcoe_port *) - calloc(1, sizeof(struct fcoe_port)); + next = alloc_fcoe_port(dp->d_name + 4); if (!next) { FCM_LOG_ERR(errno, "failed to allocate fcoe_port %s", dp->d_name); continue; } - strncpy(next->ifname, dp->d_name + 4, sizeof(next->ifname)); strncpy(file, CONFIG_DIR "/", sizeof(file)); strncat(file, dp->d_name, sizeof(file) - strlen(file)); fp = fopen(file, "r"); @@ -510,13 +522,108 @@ int fcm_is_linkinfo_vlan(struct rtattr *ap) return 0; } + +/* fcm_set_next_action - determine the next action for the FCoE interface + * @p - pointer to the fcoe_port structure for the FCoE interface + * @action - requested next action to take on the FCoE interface + * + * Based on the last_action taken on the FCoE interface and the requested + * next action, the next action field in the FCoE interface's fcoe_port + * structure is set. + * Notes: last_action is initialized to FCP_DESTROY_IF when the fcoe_port is + * created and it is never set to FCP_WAIT. + * The requested action FCP_ACTIVATE_IF is resolved to either + * FCP_CREATE_IF or FCP_ENABLE_IF as appropriate. + */ +static void fcp_set_next_action(struct fcoe_port *p, enum fcp_action action) +{ + switch (p->last_action) { + case FCP_CREATE_IF: + switch (action) { + case FCP_DESTROY_IF: + case FCP_ENABLE_IF: + case FCP_DISABLE_IF: + case FCP_RESET_IF: + p->action = action; + break; + case FCP_ACTIVATE_IF: + p->action = FCP_ENABLE_IF; + break; + default: + p->action = FCP_WAIT; + break; + } + break; + case FCP_DESTROY_IF: + switch (action) { + case FCP_CREATE_IF: + p->action = action; + break; + case FCP_ACTIVATE_IF: + p->action = FCP_CREATE_IF; + break; + default: + p->action = FCP_WAIT; + break; + } + break; + case FCP_ENABLE_IF: + switch (action) { + case FCP_DESTROY_IF: + case FCP_DISABLE_IF: + case FCP_RESET_IF: + p->action = action; + break; + default: + p->action = FCP_WAIT; + break; + } + break; + case FCP_DISABLE_IF: + switch (action) { + case FCP_DESTROY_IF: + case FCP_ENABLE_IF: + case FCP_RESET_IF: + p->action = action; + break; + case FCP_ACTIVATE_IF: + p->action = FCP_ENABLE_IF; + break; + default: + p->action = FCP_WAIT; + break; + } + break; + case FCP_RESET_IF: + switch (action) { + case FCP_DESTROY_IF: + case FCP_ENABLE_IF: + case FCP_DISABLE_IF: + case FCP_RESET_IF: + p->action = action; + break; + case FCP_ACTIVATE_IF: + p->action = FCP_ENABLE_IF; + break; + default: + p->action = FCP_WAIT; + break; + } + break; + default: + /* last_action is never set to FCP_WAIT */ + break; + } +} + static void fcp_action_set(char *ifname, enum fcp_action action) { struct fcoe_port *p; p = fcm_find_fcoe_port(ifname, FCP_REAL_IFNAME); while (p) { - p->action = action; + if (p->fcoe_enable) + fcp_set_next_action(p, action); p = fcm_find_next_fcoe_port(p, ifname); } } @@ -588,7 +695,7 @@ static void update_fcoe_port_state(struct fcoe_port *p, unsigned int type, ff->ff_operstate = operstate; if (!p->fcoe_enable) { - p->action = FCP_DESTROY_IF; + fcp_set_next_action(p, FCP_DESTROY_IF); return; } @@ -607,11 +714,11 @@ static void update_fcoe_port_state(struct fcoe_port *p, unsigned int type, fcm_dcbd_state_set(ff, FCD_GET_DCB_STATE); } else { - p->action = FCP_CREATE_IF; + fcp_set_next_action(p, FCP_CREATE_IF); } } } else { - p->action = FCP_DESTROY_IF; + fcp_set_next_action(p, FCP_DESTROY_IF); } } @@ -624,6 +731,7 @@ void fcm_process_link_msg(struct ifinfomsg *ip, int len, unsigned type) u_int8_t operstate; u_int64_t mac; int is_vlan; + int dcb_required_cnt; mac = is_vlan = 0; operstate = IF_OPER_UNKNOWN; @@ -807,6 +915,7 @@ static int fcm_link_buf_check(size_t read_len) return 0; } + static void fcm_fcoe_init(void) { if (fcm_read_config_files()) @@ -822,7 +931,6 @@ static struct fcm_netif *fcm_netif_alloc(void) ff = calloc(1, sizeof(*ff)); if (ff) { - ff->ff_qos_mask = fcm_def_qos_mask; ff->ff_operstate = IF_OPER_UNKNOWN; TAILQ_INSERT_TAIL(&fcm_netif_head, ff, ff_list); } else { @@ -1244,8 +1352,9 @@ static int dcb_rsp_parser(struct fcm_netif *ff, char *rsp) /* * validate_dcbd_info - Validating DCBD configuration and status * - * Returns: FCP_CREATE_IF - if the dcb netif qualifies for an fcoe interface + * Returns: FCP_ACTIVATE_IF - if the dcb netif qualifies for an fcoe interface * FCP_DESTROY_IF - if the dcb netif should not support fcoe interface + * FCP_ERROR - if dcb configuration has errors * FCP_WAIT - if dcb criteria is inconclusive */ static enum fcp_action validate_dcbd_info(struct fcm_netif *ff) @@ -1290,10 +1399,7 @@ static enum fcp_action validate_dcbd_info(struct fcm_netif *ff) else FCM_LOG_DEV_DBG(ff, "DCB is configured correctly\n"); - ff->ff_qos_mask = - ff->ff_pfc_info.u.pfcup & ff->ff_app_info.u.appcfg; - - return FCP_CREATE_IF; + return FCP_ACTIVATE_IF; } /* check if dcb state qualifies to destroy the fcoe interface */ @@ -1316,7 +1422,7 @@ static enum fcp_action validate_dcbd_info(struct fcm_netif *ff) ff->ff_app_info.u.appcfg, ff->ff_pfc_info.u.pfcup); - return FCP_DESTROY_IF; + return FCP_DISABLE_IF; } /* The dcbd state does not match the create or destroy criteria. @@ -1702,34 +1808,31 @@ err_out: */ static void fcm_fcoe_action(struct fcm_netif *ff, struct fcoe_port *p) { - char *debug, *syslog = NULL; - char *qos_arg; - char qos[64]; char *ifname = p->ifname; char fchost[FCHOSTBUFLEN]; char path[256]; - u_int32_t mask; int rc; - int fd; rc = fcm_success; - qos_arg = "--qos-enable"; switch (p->action) { case FCP_CREATE_IF: - if (p->last_action == FCP_CREATE_IF) - break; - FCM_LOG_DBG("OP: CREATE\n"); + FCM_LOG_DBG("OP: CREATE %s\n", p->ifname); rc = fcm_fcoe_if_action(FCOE_CREATE, ifname); break; case FCP_DESTROY_IF: - if (p->last_action == FCP_DESTROY_IF) - break; - qos_arg = "--qos-disable"; - FCM_LOG_DBG("OP: DESTROY\n"); + FCM_LOG_DBG("OP: DESTROY %s\n", p->ifname); rc = fcm_fcoe_if_action(FCOE_DESTROY, ifname); break; + case FCP_ENABLE_IF: + FCM_LOG_DBG("OP: ENABLE %s\n", p->ifname); + rc = fcm_fcoe_if_action(FCOE_ENABLE, ifname); + break; + case FCP_DISABLE_IF: + FCM_LOG_DBG("OP: DISABLE %s\n", p->ifname); + rc = fcm_fcoe_if_action(FCOE_DISABLE, ifname); + break; case FCP_RESET_IF: - FCM_LOG_DBG("OP: RESET\n"); + FCM_LOG_DBG("OP: RESET %s\n", p->ifname); if (fcoeclif_validate_interface(ifname, fchost, FCHOSTBUFLEN)) { fcm_cli_reply(p->sock_reply, CLI_FAIL); return; @@ -1748,68 +1851,7 @@ static void fcm_fcoe_action(struct fcm_netif *ff, struct fcoe_port *p) p->sock_reply = NULL; } - if ((p->action != FCP_RESET_IF) && (p->last_action == p->action)) - return; - p->last_action = p->action; - - if (p->action && !ff->ff_qos_mask) - return; - if (fcm_dcbd_cmd == NULL) { - FCM_LOG_DEV_DBG(ff, "Should call fcoeplumb per op state"); - return; - } - - /* - * XXX should wait for child status - */ - rc = fork(); - if (rc < 0) { - FCM_LOG_ERR(errno, "fork error"); - } else if (rc == 0) { /* child process */ - for (fd = ulimit(4 /* __UL_GETOPENMAX */ , 0); fd > 2; fd--) - close(fd); - snprintf(qos, sizeof(qos), "%s", "0"); - mask = ff->ff_qos_mask; - if (mask) { - int off = 0; - char *sep = ""; - u_int32_t bit; - - while (mask != 0 && off < sizeof(qos) - 1) { - bit = ffs(mask) - 1; - off += - snprintf(qos + off, - sizeof(qos) - off, - "%s%u", - sep, bit); - mask &= ~(1 << bit); - sep = ","; - } - } - - if (fcoe_config.use_syslog) - syslog = "--syslog"; - - if (fcoe_config.debug) { - debug = "--debug"; - - FCM_LOG_DEV_DBG(ff, "%s %s %s %s\n", - fcm_dcbd_cmd, qos_arg, qos, - syslog); - } - - rc = fork(); - if (rc < 0) - FCM_LOG_ERR(errno, "fork error"); - else if (rc == 0) { /* child process */ - execlp(fcm_dcbd_cmd, fcm_dcbd_cmd, p->real_ifname, - qos_arg, qos, debug, syslog, (char *)NULL); - } - - exit(1); - } else - wait(NULL); } /* @@ -1845,10 +1887,9 @@ static void fcm_netif_advance(struct fcm_netif *ff) ff->response_pending = fcm_dcbd_request(buf); break; case FCD_SEND_CONF: - snprintf(params, sizeof(params), "%x1%x02%2.2x", + snprintf(params, sizeof(params), "%x1%x02", ff->ff_app_info.enable, - ff->ff_app_info.willing, - ff->ff_qos_mask); + ff->ff_app_info.willing); snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s%s", DCB_CMD, CLIF_RSP_VERSION, CMD_SET_CONFIG, FEATURE_APP, APP_FCOE_STYPE, @@ -1891,32 +1932,24 @@ static void fcm_netif_advance(struct fcm_netif *ff) ff->response_pending = fcm_dcbd_request(buf); break; case FCD_DONE: - /* keep qos_mask and see if it changed */ - old_qos_mask = ff->ff_qos_mask; switch (validate_dcbd_info(ff)) { case FCP_DESTROY_IF: fcp_action_set(ff->ifname, FCP_DESTROY_IF); fcm_dcbd_state_set(ff, FCD_INIT); break; - case FCP_CREATE_IF: - if (!old_qos_mask) { - FCM_LOG_DEV_DBG(ff, "Initial QOS = 0x%x\n", - ff->ff_qos_mask); - fcp_action_set(ff->ifname, FCP_CREATE_IF); - } else if (old_qos_mask == ff->ff_qos_mask) { - fcp_action_set(ff->ifname, FCP_CREATE_IF); - } else { - FCM_LOG_DEV_DBG(ff, "QOS changed to 0x%x\n", - ff->ff_qos_mask); - fcp_action_set(ff->ifname, FCP_RESET_IF); - } + case FCP_DISABLE_IF: + fcp_action_set(ff->ifname, FCP_DISABLE_IF); + fcm_dcbd_state_set(ff, FCD_INIT); + break; + case FCP_ACTIVATE_IF: + fcp_action_set(ff->ifname, FCP_ACTIVATE_IF); fcm_dcbd_state_set(ff, FCD_INIT); break; case FCP_ERROR: if (ff->dcbd_retry_cnt < DCBD_MAX_REQ_RETRIES) { fcm_dcbd_state_set(ff, FCD_ERROR); } else { - fcp_action_set(ff->ifname, FCP_DESTROY_IF); + fcp_action_set(ff->ifname, FCP_DISABLE_IF); fcm_dcbd_state_set(ff, FCD_INIT); } break; @@ -1992,6 +2025,7 @@ static void fcm_usage(void) static void fcm_sig(int sig) { + fcm_dcbd_shutdown(); sa_select_exit(); } @@ -2033,7 +2067,7 @@ static int fcm_cli_create(char *ifname, int cmd, struct sock_info **r) if (p) { if (!p->fcoe_enable) { p->fcoe_enable = 1; - p->action = cmd; + fcp_set_next_action(p, cmd); p->sock_reply = *r; if (p->dcb_required) { ff = fcm_netif_lookup(p->real_ifname); @@ -2041,28 +2075,27 @@ static int fcm_cli_create(char *ifname, int cmd, struct sock_info **r) return fcm_success; fcm_dcbd_state_set(ff, FCD_GET_DCB_STATE); if (ff->ff_dcbd_state == FCD_GET_DCB_STATE) - p->action = FCP_WAIT; + fcp_set_next_action(p, FCP_WAIT); } - return fcm_success; } else { - /* no action needed */ - return CLI_NO_ACTION; + p->fcoe_enable = 1; + fcp_set_next_action(p, cmd); } + return fcm_success; } - p = (struct fcoe_port *) calloc(1, sizeof(struct fcoe_port)); + p = alloc_fcoe_port(ifname); if (!p) { FCM_LOG_ERR(errno, "fail to allocate fcoe_port %s", ifname); return fcm_fail; } - snprintf(p->ifname, strlen(ifname)+1, "%s", ifname); fcm_vlan_dev_real_dev(ifname, p->real_ifname); if (!strlen(p->real_ifname)) snprintf(p->real_ifname, sizeof(p->real_ifname), "%s", ifname); p->fcoe_enable = 1; p->dcb_required = 0; - p->action = cmd; + fcp_set_next_action(p, cmd); p->sock_reply = *r; p->next = NULL; @@ -2093,7 +2126,7 @@ static int fcm_cli_destroy(char *ifname, int cmd, struct sock_info **r) if (p) { if (p->fcoe_enable) { p->fcoe_enable = 0; - p->action = cmd; + fcp_set_next_action(p, cmd); p->sock_reply = *r; return fcm_success; } else { @@ -2112,7 +2145,7 @@ static int fcm_cli_reset(char *ifname, int cmd, struct sock_info **r) p = fcm_find_fcoe_port(ifname, FCP_CFG_IFNAME); if (p) { - p->action = cmd; + fcp_set_next_action(p, cmd); p->sock_reply = *r; return fcm_success; } @@ -2348,7 +2381,7 @@ int main(int argc, char **argv) sa_log_flags = 0; openlog(sa_log_prefix, LOG_CONS, LOG_DAEMON); - while ((c = getopt_long(argc, argv, "fde:hv", + while ((c = getopt_long(argc, argv, "fd:hv", fcm_options, NULL)) != -1) { switch (c) { case 'f': @@ -2360,9 +2393,6 @@ int main(int argc, char **argv) fcoe_config.use_syslog = 1; enable_syslog(1); break; - case 'e': - fcm_dcbd_cmd = optarg; - break; case 'v': printf("%s\n", fcoemon_version); return 0; diff --git a/fcoemon.h b/fcoemon.h index 4f21634..74a3bad 100644 --- a/fcoemon.h +++ b/fcoemon.h @@ -88,6 +88,9 @@ enum fcp_action { FCP_CREATE_IF, /* create FCoE interface */ FCP_DESTROY_IF, /* destroy FCoE interface */ FCP_RESET_IF, /* reset FCoE interface */ + FCP_ENABLE_IF, /* enable FCoE interface */ + FCP_DISABLE_IF, /* disable FCoE interface */ + FCP_ACTIVATE_IF, /* create or enable FCoE interface */ FCP_ERROR, /* error condition */ }; @@ -130,7 +133,6 @@ struct fcm_netif { struct feature_info ff_pfc_info; /* PFC feature info */ struct feature_info ff_app_info; /* App feature info */ u_int8_t ff_operstate; /* RFC 2863 operational status */ - u_int8_t ff_qos_mask; /* 801.p priority mask */ enum fcm_dcbd_state ff_dcbd_state; /* DCB daemon state */ char ifname[IFNAMSIZ]; /* Ethernet interface name */ int response_pending; /* dcbd query in progress */ diff --git a/fcoeplumb.in b/fcoeplumb.in deleted file mode 100755 index 658bd9d..0000000 --- a/fcoeplumb.in +++ /dev/null @@ -1,350 +0,0 @@ -#! /bin/bash -# -# Copyright(c) 2009 Intel Corporation. All rights reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms and conditions of the GNU General Public License, -# version 2, as published by the Free Software Foundation. -# -# This program is distributed in the hope it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. -# -# Maintained at www.Open-FCoE.org - -cmdname=`basename $0` - -usage() -{ - echo usage: $cmdname \ - '[--debug] [--syslog]' \ - '[<ethX> --qos-disable | --qos-enable <pri>[,<pri>]...]' >&2 - exit 1 -} - -# -# Tunable parameters -# -QOS_DEF=3 # default user priority -FCOE_ETHERTYPE=35078 # Ethertype (0x8906): tc filter show is base 10 -FIP_ETHERTYPE=35092 # Ethertype (0x8914): tc filter show is base 10 -FCOE_FILTER=0xfc0e # filter handle (must be lower-case hex) - -FCOE_FILTER_KEY=12345 -FIP_FILTER_KEY=67890 - -qdisc_id=1: -qos_list= -cmd= -# automake paths -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -sbindir=@sbindir@ -sysconfdir=@sysconfdir@ -# make sure there's a sane path to find basic commands and system tools (tc) -PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin -LOGGER= -DEBUG_LOGGING= - -find_multiq_qdisc() -{ - ifname=$1 - - found=0 - type=unknown - if set -- `tc qdisc show dev $ifname` none none none - then - type=$2 - qdisc_id=$3 - fi - [ "$type" == "multiq" ] && found=1 - - return $found -} - -add_multiq_qdisc() -{ - ifname=$1 - qdisc_id=$2 - - [ ${DEBUG_LOGGING} ] && $LOGGER \ - "tc qdisc add dev $ifname root handle $qdisc_id multiq" - tc qdisc add dev $ifname root handle $qdisc_id multiq -} - -get_filter_id() -{ - ifname=$1 - filter_key=$2 - - retry_count=0 - while true - do - [ $retry_count -eq 0 ] && break - [ -f /var/run/fcoemon.pid ] && break - sleep 1 - retry_count=$(($retry_count-1)) - done - - echo "`echo "$ifname $filter_key" | \ - awk '{ printf("0x%x%06x", substr($1,4), $2) }'`" -} - -find_skbedit_filter() -{ - ifname=$1 - ethertype=$2 - filter_id=$3 - - found=`tc filter show dev $ifname | awk ' - BEGIN { - x1 = 0 - x2 = 0 - x3 = 0 - queue = 8 - } - /^filter.*parent.*protocol \['$ethertype'\].* handle '$filter_id'/ { - if (x1 == 0 && x2 == 0 && x3 == 0) - x1 = 1 - } - /cmp.*u16 at 12 layer 1 mask 0xffff eq '$ethertype'.*\)/ { - if (x1 == 1 && x2 == 0 && x3 == 0) - x2 = 1 - } - /action order [0-9][0-9]*: skbedit queue_mapping/ { - if (x1 == 1 && x2 == 1 && x3 == 0) { - x3 = 1 - queue = $6 - } - } - END { - print queue - }'` - - return $found -} - -delete_skbedit_filter() -{ - ifname=$1 - queue=$2 - ethertype=$3 - filter_id=$4 - - [ ${DEBUG_LOGGING} ] && $LOGGER \ - "tc filter delete dev $ifname skbedit queue_mapping $queue" - PARENT=`tc filter show dev $ifname | awk \ - '/^filter.*parent.*protocol \['$ethertype'\].* handle '$filter_id'/ \ - { print $3 }'` - PRIO=`tc filter show dev $ifname | awk \ - '/^filter.*parent.*protocol \['$ethertype'\].* handle '$filter_id'/ \ - { print $7 }'` - tc filter delete dev $ifname parent $PARENT \ - protocol $ethertype pref $PRIO handle $filter_id basic match \ - 'cmp(u16' at 12 layer 1 mask 0xffff eq $ethertype')' \ - action skbedit queue_mapping $queue - tc filter delete dev $ifname parent $PARENT \ - protocol $ethertype pref $PRIO basic -} - -add_skbedit_filter() -{ - ifname=$1 - qdisc_id=$2 - queue=$3 - ethertype=$4 - filter_id=$5 - - [ ${DEBUG_LOGGING} ] && $LOGGER \ - "tc filter add dev $ifname skbedit queue_mapping $queue" - tc filter add dev $ifname parent $qdisc_id protocol $ethertype \ - handle $filter_id basic match 'cmp(u16' at 12 \ - layer 1 mask 0xffff eq $ethertype')' \ - action skbedit queue_mapping $queue -} - -replace_skbedit_filter() -{ - ifname=$1 - queue=$2 - ethertype=$3 - filter_id=$4 - - [ ${DEBUG_LOGGING} ] && $LOGGER \ - "tc filter replace dev $ifname skbedit queue_mapping $queue" - PARENT=`tc filter show dev $ifname | awk \ - '/^filter.*parent.*protocol \['$ethertype'\].* handle '$filter_id'/ \ - { print $3 }'` - PRIO=`tc filter show dev $ifname | \ - awk '/^filter.*parent.*protocol \['$ethertype'\].* handle '$filter_id'/ \ - { print $7 }'` - tc filter replace dev $ifname parent $PARENT protocol \ - $ethertype pref $PRIO handle $filter_id basic match \ - 'cmp(u16' at 12 layer 1 mask 0xffff eq $ethertype')' \ - action skbedit queue_mapping $queue -} - -config_logging() -{ - if [ $DEBUG_LOGGING ] ; then - if [ $USE_SYSLOG ] ; then - LOGGER="logger -t fcoeplumb" - else - LOGGER="echo" - fi - else - LOGGER= - fi -} - -[ "$#" -lt 2 ] && usage - -[ ${DEBUG_LOGGING} ] && $LOGGER "fcoeplumb arguments: ($*)" - -net_ifname=$1 -shift - -while [ "$#" -ge 1 ] -do - case "$1" in - --qos-enable) - [ "$#" -lt 2 ] && usage - qos_list=$2 - shift - ;; - --qos-disable) - [[ "$2" =~ ^[0-9]+$ ]] && shift - qos_list="disable" - ;; - --debug) - DEBUG_LOGGING=1 - config_logging - ;; - --syslog) - USE_SYSLOG=1 - config_logging - ;; - *) - echo "$cmdname: unknown parameter '$1'" >&2 - usage - ;; - esac - shift -done - -# This must be the first to do after parsing the command arguments! -# Notice that the filter ID is used in find_skbedit_filter(), -# add_skbedit_filter(), replace_skbedit_filter(). -fcoe_filter_id=`get_filter_id $net_ifname $FCOE_FILTER_KEY` -fip_filter_id=`get_filter_id $net_ifname $FIP_FILTER_KEY` - -if [ "$qos_list" == "disable" ]; then - # Remove the FCoE filters - find_skbedit_filter $net_ifname $FCOE_ETHERTYPE $fcoe_filter_id - found_filter=$? - [ $found_filter -le 7 ] && delete_skbedit_filter $net_ifname \ - $found_filter $FCOE_ETHERTYPE $fcoe_filter_id - - # Remove the FIP filters - find_skbedit_filter $net_ifname $FIP_ETHERTYPE $fip_filter_id - found_filter=$? - [ $found_filter -le 7 ] && delete_skbedit_filter $net_ifname \ - $found_filter $FIP_ETHERTYPE $fip_filter_id - -elif [ -n $qos_list ]; then - # - # Choose the best QOS to use for FCoE out of the listed choices. - # - - # Parse QOS List - QOS_BEST= - if [ -n "$qos_list" ]; then - OLD_IFS="$IFS" - IFS=,"$IFS" - set -- $qos_list - IFS="$OLD_IFS" - - while [ "$#" -ge 1 ] - do - case "$1" in - [0-7]) - ;; - *) - echo "$cmdname: bad QOS value '$1'" >&2 - usage - ;; - esac - if [ -z "$QOS_BEST" ]; then - QOS_BEST=$1 - elif [ "$1" -eq "$QOS_DEF" ]; then - QOS_BEST=$1 - fi - shift - done - fi - - # If the best QOS is not found, do nothing. - [ -z "$QOS_BEST" ] && exit 0 - - [ ${DEBUG_LOGGING} ] && $LOGGER "$net_ifname - Choosing QOS '$QOS_BEST'" - - # - # Setup the traffic classifier for FCoE - # First see if it is already set up. - # - qos_queue=`expr $QOS_BEST` - - find_multiq_qdisc $net_ifname - found_qdisc=$? - - if [ $found_qdisc -eq 1 ]; then - # Adjust the FCoE filter - [ ${DEBUG_LOGGING} ] && $LOGGER "$net_ifname: Qdisc is found" - find_skbedit_filter $net_ifname $FCOE_ETHERTYPE $fcoe_filter_id - found_filter=$? - if [ $found_filter -gt 7 ]; then - add_skbedit_filter $net_ifname $qdisc_id $qos_queue \ - $FCOE_ETHERTYPE $fcoe_filter_id - elif [ $found_filter -ne $qos_queue ]; then - [ ${DEBUG_LOGGING} ] && $LOGGER \ - "$net_ifname: Filter is found and QOS is different" - replace_skbedit_filter $net_ifname $qos_queue \ - $FCOE_ETHERTYPE $fcoe_filter_id - else - [ ${DEBUG_LOGGING} ] && $LOGGER \ - "$net_ifname: Filter is found and is identical" - fi - - # Adjust the FIP filter - [ ${DEBUG_LOGGING} ] && $LOGGER "$net_ifname: Qdisc is found" - find_skbedit_filter $net_ifname $FIP_ETHERTYPE $fip_filter_id - found_filter=$? - if [ $found_filter -gt 7 ]; then - add_skbedit_filter $net_ifname $qdisc_id $qos_queue \ - $FIP_ETHERTYPE $fip_filter_id - elif [ $found_filter -ne $qos_queue ]; then - [ ${DEBUG_LOGGING} ] && $LOGGER \ - "$net_ifname: Filter is found and QOS is different" - replace_skbedit_filter $net_ifname $qos_queue \ - $FIP_ETHERTYPE $fip_filter_id - else - [ ${DEBUG_LOGGING} ] && $LOGGER \ - "$net_ifname: Filter is found and is identical" - fi - else - add_multiq_qdisc $net_ifname $qdisc_id - add_skbedit_filter $net_ifname $qdisc_id $qos_queue \ - $FCOE_ETHERTYPE $fcoe_filter_id - add_skbedit_filter $net_ifname $qdisc_id $qos_queue \ - $FIP_ETHERTYPE $fip_filter_id - fi -fi - -exit 0 -
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor