| 1 |
# Copyright 2006-2007 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# Contributed by Roy Marples (uberlord@gentoo.org)
|
| 4 |
|
| 5 |
_config_vars="$_config_vars ccwgroup"
|
| 6 |
|
| 7 |
ccwgroup_depend() {
|
| 8 |
before interface
|
| 9 |
}
|
| 10 |
|
| 11 |
ccwgroup_pre_start() {
|
| 12 |
eval $(_get_array "ccwgroup_${IFVAR}")
|
| 13 |
[ $# = "0" ] && return 0
|
| 14 |
|
| 15 |
if [ ! -d /sys/bus/ccwgroup ] ; then
|
| 16 |
modprobe qeth
|
| 17 |
if [ ! -d /sys/bus/ccwgroup ] ; then
|
| 18 |
eerror "ccwgroup support missing in kernel"
|
| 19 |
return 1
|
| 20 |
fi
|
| 21 |
fi
|
| 22 |
|
| 23 |
einfo "Enabling ccwgroup on ${IFACE}"
|
| 24 |
local x= ccw= first= layer2=
|
| 25 |
for x in "$@" ; do
|
| 26 |
[ -z "${first}" ] && first=${x}
|
| 27 |
ccw="${ccw}${ccw:+,}${x}"
|
| 28 |
done
|
| 29 |
if [ -e /sys/devices/qeth/"${first}" ] ; then
|
| 30 |
echo "0" > /sys/devices/qeth/"${first}"/online
|
| 31 |
else
|
| 32 |
echo "${ccw}" > /sys/bus/ccwgroup/drivers/qeth/group
|
| 33 |
fi
|
| 34 |
eval layer2=\$qeth_layer2_${IFVAR}
|
| 35 |
echo "${layer2:-0}" > /sys/devices/qeth/"${first}"/layer2
|
| 36 |
echo "1" > /sys/devices/qeth/"${first}"/online
|
| 37 |
eend $?
|
| 38 |
}
|
| 39 |
|
| 40 |
ccwgroup_pre_stop() {
|
| 41 |
# Erase any existing ccwgroup to be safe
|
| 42 |
save_options ccwgroup_device ""
|
| 43 |
|
| 44 |
[ ! -L /sys/class/net/"${FACE}"/driver ] && return 0
|
| 45 |
local driver="$(readlink /sys/class/net/"${IFACE}"/driver)"
|
| 46 |
case "${diver}" in
|
| 47 |
*/bus/ccwgroup/*) ;;
|
| 48 |
*) return 0 ;;
|
| 49 |
esac
|
| 50 |
|
| 51 |
local device="$(readlink /sys/class/net/"${IFACE}"/device)"
|
| 52 |
device=${device##*/}
|
| 53 |
save_options ccwgroup_device "${device}"
|
| 54 |
}
|
| 55 |
|
| 56 |
ccwgroup_post_stop() {
|
| 57 |
local device="$(get_options ccwgroup_device)"
|
| 58 |
[ -z "${device}" ] && return 0
|
| 59 |
|
| 60 |
einfo "Disabling ccwgroup on ${iface}"
|
| 61 |
echo "0" > /sys/devices/qeth/"${device}"/online
|
| 62 |
echo "1" > /sys/devices/qeth/"${device}"/ungroup
|
| 63 |
eend $?
|
| 64 |
}
|
| 65 |
|
| 66 |
# vim: set ts=4 :
|