2009-05-01 19:41:40 +05:30
|
|
|
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
|
2011-06-30 05:16:31 +05:30
|
|
|
# Released under the 2-clause BSD license.
|
2007-11-14 20:52:04 +05:30
|
|
|
|
2007-04-05 16:48:42 +05:30
|
|
|
_config_vars="$_config_vars ccwgroup"
|
|
|
|
|
2008-01-11 20:38:57 +05:30
|
|
|
ccwgroup_depend()
|
|
|
|
{
|
2011-01-17 15:19:07 +05:30
|
|
|
before interface
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2011-05-16 10:51:20 +05:30
|
|
|
ccwgroup_load_modules()
|
2008-01-11 20:38:57 +05:30
|
|
|
{
|
2011-05-16 10:51:20 +05:30
|
|
|
# make sure we have ccwgroup support or this is a crap shoot
|
|
|
|
if [ ! -d /sys/bus/ccwgroup ] ; then
|
|
|
|
modprobe -q ccwgroup
|
|
|
|
if [ ! -d /sys/bus/ccwgroup ] ; then
|
2007-04-05 16:48:42 +05:30
|
|
|
eerror "ccwgroup support missing in kernel"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-05-16 10:51:20 +05:30
|
|
|
# verify the specific interface is supported
|
|
|
|
if [ ! -d /sys/bus/ccwgroup/drivers/$1 ] ; then
|
|
|
|
modprobe $1 >& /dev/null
|
|
|
|
if [ ! -d /sys/bus/ccwgroup/drivers/$1 ] ; then
|
|
|
|
eerror "$1 support missing in kernel"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2007-04-05 16:48:42 +05:30
|
|
|
else
|
2011-05-16 10:51:20 +05:30
|
|
|
echo "${first}$(printf ',%s' "$@")" >/sys/bus/ccwgroup/drivers/${ccw_type}/group
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
2011-05-16 10:51:20 +05:30
|
|
|
|
|
|
|
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
|
2007-04-05 16:48:42 +05:30
|
|
|
eend $?
|
2011-06-28 09:32:11 +05:30
|
|
|
|
|
|
|
# Now that we've properly configured the device, we can run
|
|
|
|
# bring the interface up. Common code tried to do this already,
|
|
|
|
# but it failed because we didn't setup sysfs yet.
|
|
|
|
_up
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 20:38:57 +05:30
|
|
|
ccwgroup_pre_stop()
|
|
|
|
{
|
2011-05-16 10:51:20 +05:30
|
|
|
local path="/sys/class/net/${IFACE}"
|
|
|
|
|
2007-04-05 16:48:42 +05:30
|
|
|
# Erase any existing ccwgroup to be safe
|
2007-12-19 19:58:38 +05:30
|
|
|
service_set_value ccwgroup_device ""
|
2011-05-16 10:51:20 +05:30
|
|
|
service_set_value ccwgroup_type ""
|
2011-01-17 15:19:07 +05:30
|
|
|
|
2011-05-16 10:51:20 +05:30
|
|
|
[ ! -L "${path}"/device/driver ] && return 0
|
|
|
|
case "$(readlink "${path}"/device/driver)" in
|
|
|
|
*/bus/ccwgroup/*) ;;
|
2007-11-28 21:15:03 +05:30
|
|
|
*) return 0;;
|
2007-04-05 16:48:42 +05:30
|
|
|
esac
|
|
|
|
|
2011-05-16 10:51:20 +05:30
|
|
|
local device
|
|
|
|
device="$(readlink "${path}"/device)"
|
2007-04-05 16:48:42 +05:30
|
|
|
device=${device##*/}
|
2007-12-19 19:58:38 +05:30
|
|
|
service_set_value ccwgroup_device "${device}"
|
2011-05-16 10:51:20 +05:30
|
|
|
device="$(readlink "${path}"/device/driver)"
|
|
|
|
device=${device##*/}
|
|
|
|
service_set_value ccwgroup_type "${device}"
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 20:38:57 +05:30
|
|
|
ccwgroup_post_stop()
|
|
|
|
{
|
2007-12-19 19:58:38 +05:30
|
|
|
local device="$(service_get_value ccwgroup_device)"
|
2007-04-05 16:48:42 +05:30
|
|
|
[ -z "${device}" ] && return 0
|
2011-05-16 10:51:20 +05:30
|
|
|
local ccw_type="$(service_get_value ccwgroup_type)"
|
2011-06-28 09:32:11 +05:30
|
|
|
local path="/sys/devices/${ccw_type}/${device}"
|
2011-01-17 15:19:07 +05:30
|
|
|
|
2011-05-16 10:51:20 +05:30
|
|
|
einfo "Disabling ccwgroup/${ccw_type} on ${IFACE}"
|
2011-06-28 09:32:11 +05:30
|
|
|
if echo "0" >"${path}"/online &&
|
|
|
|
echo "1" >"${path}"/ungroup ; then
|
|
|
|
# The device doesn't disappear right away which breaks
|
|
|
|
# restart, or a quick start up, so wait around.
|
|
|
|
while [ -e "${path}" ] ; do :; done
|
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
eend $?
|
|
|
|
}
|