net: ccwgroup: forward port changes from baselayout-1

Quite a bit of work happened in baselayout-1 on the ccwgroup module, but
seems it didn't make it into openrc.  So forward port all the existing
code so we can work with more than just qeth and layer2 options.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
Mike Frysinger 2011-05-16 01:21:20 -04:00
parent 40341fcd7e
commit 2493a1f32e

View File

@ -8,60 +8,89 @@ ccwgroup_depend()
before interface before interface
} }
ccwgroup_pre_start() ccwgroup_load_modules()
{ {
local ccwgroup="$(_get_array "ccwgroup_${IFVAR}")" # make sure we have ccwgroup support or this is a crap shoot
[ -z "${ccwgroup}" ] && return 0 if [ ! -d /sys/bus/ccwgroup ] ; then
modprobe -q ccwgroup
if [ ! -d /sys/bus/ccwgroup ]; then if [ ! -d /sys/bus/ccwgroup ] ; then
modprobe qeth
if [ ! -d /sys/bus/ccwgroup ]; then
eerror "ccwgroup support missing in kernel" eerror "ccwgroup support missing in kernel"
return 1 return 1
fi fi
fi fi
einfo "Enabling ccwgroup on ${IFACE}" # verify the specific interface is supported
local x= ccw= first= layer2= if [ ! -d /sys/bus/ccwgroup/drivers/$1 ] ; then
for x in ${ccwgroup}; do modprobe $1 >& /dev/null
[ -z "${first}" ] && first=${x} if [ ! -d /sys/bus/ccwgroup/drivers/$1 ] ; then
ccw="${ccw}${ccw:+,}${x}" eerror "$1 support missing in kernel"
done return 1
if [ -e /sys/devices/qeth/"${first}" ]; then fi
echo "0" >/sys/devices/qeth/"${first}"/online
else
echo "${ccw}" >/sys/bus/ccwgroup/drivers/qeth/group
fi fi
eval layer2=\$qeth_layer2_${IFVAR}
echo "${layer2:-0}" > /sys/devices/qeth/"${first}"/layer2 return 0
echo "1" >/sys/devices/qeth/"${first}"/online }
ccwgroup_pre_start()
{
local ccwgroup="$(_get_array "ccwgroup_${IFVAR}")"
[ -z "${ccwgroup}" ] && return 0
local ccw_type
eval ccw_type=\${ccwgroup_type_${IFVAR}:-qeth}
ccwgroup_load_modules ${ccw_type} || return 1
einfo "Enabling ccwgroup/${ccw_type} on ${IFACE}"
set -- ${ccwgroup}
local first=$1; shift
if [ -e /sys/devices/${ccw_type}/${first}/online ]; then
echo "0" >/sys/devices/${ccw_type}/${first}/online
else
echo "${first}$(printf ',%s' "$@")" >/sys/bus/ccwgroup/drivers/${ccw_type}/group
fi
local var val
for var in $(_get_array "ccwgroup_opts_${IFVAR}") online=1 ; do
val=${var#*=}
var=${var%%=*}
echo "${val}" > /sys/devices/${ccw_type}/${first}/${var}
done
eend $? eend $?
} }
ccwgroup_pre_stop() ccwgroup_pre_stop()
{ {
local path="/sys/class/net/${IFACE}"
# Erase any existing ccwgroup to be safe # Erase any existing ccwgroup to be safe
service_set_value ccwgroup_device "" service_set_value ccwgroup_device ""
service_set_value ccwgroup_type ""
[ ! -L /sys/class/net/"${FACE}"/driver ] && return 0 [ ! -L "${path}"/device/driver ] && return 0
local driver="$(readlink /sys/class/net/"${IFACE}"/driver)" case "$(readlink "${path}"/device/driver)" in
case "${diver}" in */bus/ccwgroup/*) ;;
*/bus/ccwgroup/*);;
*) return 0;; *) return 0;;
esac esac
local device="$(readlink /sys/class/net/"${IFACE}"/device)" local device
device="$(readlink "${path}"/device)"
device=${device##*/} device=${device##*/}
service_set_value ccwgroup_device "${device}" service_set_value ccwgroup_device "${device}"
device="$(readlink "${path}"/device/driver)"
device=${device##*/}
service_set_value ccwgroup_type "${device}"
} }
ccwgroup_post_stop() ccwgroup_post_stop()
{ {
local device="$(service_get_value ccwgroup_device)" local device="$(service_get_value ccwgroup_device)"
[ -z "${device}" ] && return 0 [ -z "${device}" ] && return 0
local ccw_type="$(service_get_value ccwgroup_type)"
einfo "Disabling ccwgroup on ${iface}" einfo "Disabling ccwgroup/${ccw_type} on ${IFACE}"
echo "0" >/sys/devices/qeth/"${device}"/online echo "0" >/sys/devices/${ccw_type}/"${device}"/online
echo "1" >/sys/devices/qeth/"${device}"/ungroup echo "1" >/sys/devices/${ccw_type}/"${device}"/ungroup
eend $? eend $?
} }