summaryrefslogtreecommitdiff
blob: 3eca96576becd03f01ffee44267d132f56937f8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Copyright (c) 2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Contributed by Roy Marples (uberlord@gentoo.org)

ccwgroup_depend() {
	before interface 
}
ccwgroup_expose() {
	variables ccwgroup
}

ccwgroup_pre_start() {
	local iface="$1" ifvar="$(bash_variable "$1")"
	local ccw="ccwgroup_${ifvar}[@]"
	local -a ccwgroup=( "${!ccw}" )

	[[ -z ${!ccw} ]] && return 0
	if [[ ! -d /sys/bus/ccwgroup ]] ; then
		eerror "ccwgroup support missing in kernel"
		return 1
	fi

	einfo "Enabling ccwgroup on ${iface}"
	echo "${!ccw// /,}" > /sys/bus/ccwgroup/drivers/qeth/group
	echo "1" > /sys/devices/qeth/"${ccwgroup[0]}"/online
	eend $?
}

ccwgroup_pre_stop() {
	local iface="$1"

	# Erase any existing ccwgroup to be safe
	save_options ccwgroup_device ""
	
	[[ ! -L /sys/class/net/"${iface}"/driver ]] && return 0
	local driver="$(readlink /sys/class/net/"${iface}"/driver)"
	[[ ${driver} != *"/bus/ccwgroup/"* ]] && return 0

	local device="$(readlink /sys/class/net/"${iface}"/device)"
	device="${device##*/}"
	save_options ccwgroup_device "${device}"
}

ccwgroup_post_stop() {
	local iface="$1" device="$(get_options ccwgroup_device)"
	
	[[ -z ${device} ]] && return 0
	
	einfo "Disabling ccwgroup on ${iface}"
	echo "0"  > /sys/devices/qeth/"${device}"/online
	echo "1"  > /sys/devices/qeth/"${device}"/ungroup
	eend $?
}

# vim: set ts=4 :