-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqeth_configure
More file actions
executable file
·287 lines (260 loc) · 7.59 KB
/
qeth_configure
File metadata and controls
executable file
·287 lines (260 loc) · 7.59 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#! /bin/sh
#
# qeth_configure
#
# Configures a qeth device
#
# Usage:
# qeth_configure [-i] [-l] [-f -t <CARDTYPE> ] [-o "Values"] -n <portno> -p <portname> <read chan> <write chan> <data chan> <online>
# -i Configure IP takeover
# -l Configure Layer2 support
# -f force creation of udev rules, do not check values in /sys
# -t Valid cardtypes are: qeth, hsi, osn
# -o General QETH options, separated by spaces
# -n QETH port number to use, 0 or 1. Only needed for real, not virtual devices.
# -p QETH Portname to use. Only needed if sharing a real OSA with z/OS.
# read/write/data chan = x.y.ssss where
# x is always 0 until IBM creates something that uses that number
# y is the logical channel subsystem (lcss) number. Most often this is 0, but it could be non-zero
# ssss is the four digit subchannel address of the device, in hexidecimal, with leading zeros.
# online = 0 to take the device offline
# 1 to bring the device online
#
# Return values:
# 1 sysfs not mounted
# 2 Invalid status for <online>
# 3 No device found for read channel
# 4 No device found for write channel
# 5 No device found for data channel
# 6 Invalid device type
# 7 Could not load module
# 8 CCW devices grouped different devices
# 9 Could not group devices
# 10 Could not set device online
# 11 Could not set device offline
#
if [ "${DEBUG}" != "yes" ]; then
DEBUG="no"
fi
mesg () {
echo "$@"
}
exit_on_err() {
if [ "$2" == "online" ]; then
_state=10
else
_state=11
fi
case "$1" in
0) return 0 ;;
5) exit 6 ;;
21) exit 7 ;;
28) exit 8 ;;
31) exit 9 ;;
*) exit $_state ;;
esac
}
set_qeth_options() {
for opt in $QETH_OPTIONS; do
set -- $(IFS='='; echo $opt)
opt_name=$1
opt_val=$2
case "$opt_name" in
portname|ipa_takeover|layer2)
# These options are set above
debug_mesg "Invalid option $opt_name"
;;
*)
if [ "$opt_name" -a "$opt_val" ]; then
if [ -w "$_ccwgroup_dir/$opt_name" ]; then
mesg "($opt_name) "
echo "$opt_val" > $_ccwgroup_dir/$opt_name
else
debug_mesg "Invalid option $opt_name"
fi
fi
;;
esac
done
}
DATUM=$(date)
add_channel_for_cio() {
echo "$* # $DATUM" >> /boot/zipl/active_devices.txt
}
remove_channel_for_cio() {
[ -w /boot/zipl/active_devices.txt ] && sed -i -e "/^$1/d" /boot/zipl/active_devices.txt
}
debug_mesg () {
case "$DEBUG" in
yes) mesg "$@" ;;
*) ;;
esac
}
while [ $# -gt 0 ] ; do
case "$1" in
-i)
# Configure IP takeover
QETH_IPA_TAKEOVER=1
;;
-f) # force creation of udev rules, do not check values in /sys
echo "Warning: The -t option is deprecated and has no effect"
;;
-l)
# Configure Layer2 support
QETH_LAYER2_SUPPORT=1
;;
-n*)
# QETH port number to use
if [ "$1" = "-n" ] ; then
QETH_PORTNO=$2
shift
else
QETH_PORTNO=${1#-n}
fi
;;
-o)
# General QETH options, separated by spaces
QETH_OPTIONS=$2
shift
;;
-p*)
# QETH Portname to use
if [ "$1" = "-p" ] ; then
QETH_PORTNAME=$2
shift
else
QETH_PORTNAME=${1#-p}
fi
;;
-t*) # Card type. Obsolete
echo "Warning: The -t option is deprecated and has no effect"
[ "$1" = "-t" ] && shift
;;
*)
break;
;;
esac
shift
done
# Get the mount point for sysfs
grep -qe ^'sysfs /sys' < /proc/mounts
if [ $? -ne 0 ]; then
mesg "/sysfs not present"
exit 1
fi
QETH_READ_CHAN=$1
QETH_WRITE_CHAN=$2
QETH_DATA_CHAN=$3
ONLINE=$4
if [ $# -lt 4 ] ; then
echo "Usage: $0 [options] <read chan> <write chan> <data chan> <online>"
echo " -i Configure IP takeover"
echo " -l Configure Layer2 support"
echo " -f force creation of udev rules, do not check values in /sys"
echo " -t Valid cardtypes are: qeth, hsi, osn"
echo " -o General QETH options, separated by spaces"
echo " -n QETH port number to use, 0 or 1. Only needed for real, not virtual devices."
echo " -p QETH Portname to use. Only needed if sharing a real OSA with z/OS."
echo " read/write/data chan = x.y.ssss where"
echo " x is always 0 until IBM creates something that uses that number"
echo " y is the logical channel subsystem (lcss) number. Most often this is 0, but it could be non-zero"
echo " ssss is the four digit subchannel address of the device, in hexidecimal, with leading zeros."
echo " online = 0 to take the device offline"
echo " 1 to bring the device online"
exit 1
fi
if [ -z "$ONLINE" ] || [ "$ONLINE" -ne "1" -a "$ONLINE" -ne "0" ]; then
mesg "Invalid device status $ONLINE"
exit 2
fi
_ccw_dir=/sys/bus/ccw/devices
# Convert any hexidecimal numbers to lower case
QETH_READ_CHAN=$(echo ${QETH_READ_CHAN} | tr "[A-Z]" "[a-z]")
QETH_WRITE_CHAN=$(echo ${QETH_WRITE_CHAN} | tr "[A-Z]" "[a-z]")
QETH_DATA_CHAN=$(echo ${QETH_DATA_CHAN} | tr "[A-Z]" "[a-z]")
debug_mesg "Configuring QETH device ${QETH_READ_CHAN}/${QETH_WRITE_CHAN}/${QETH_DATA_CHAN}"
if test ! -d "$_ccw_dir/$QETH_READ_CHAN" ; then #to be replaced
mesg "No device ${QETH_READ_CHAN}"
exit 3
fi
if test ! -d "$_ccw_dir/$QETH_WRITE_CHAN" ; then #to be replaced
mesg "No device ${QETH_WRITE_CHAN}"
exit 4
fi
if test ! -d "$_ccw_dir/$QETH_DATA_CHAN" ; then #to be replaced
mesg "No device ${QETH_DATA_CHAN}"
exit 5
fi
# Portname is only required for OSA/Express
if [ -n "$QETH_PORTNAME" -a "$QETH_CARD" != "qeth" ] ; then
debug_mesg "No portname required for $QETH_CARD adapters"
QETH_PORTNAME=
fi
_online=$(lszdev --online|grep -c ${QETH_READ_CHAN}:${QETH_WRITE_CHAN}:${QETH_DATA_CHAN})
_opts=
if [ "$ONLINE" -eq 1 ]; then
# Check whether we need to do something
# We do not check for the value of CCW_CHAN_MODE, since we
# might want to switch back and forth between several modes
if test "$_online" -eq "0" ; then
# Set the portname
if [ "$QETH_PORTNAME" ]; then
mesg "(portname $QETH_PORTNAME) "
_opts="${_opts} portname=$QETH_PORTNAME"
fi
# Activate Layer2 support
if [ -w "$_ccwgroup_dir/layer2" ] ; then #to be replaced
if [ "$QETH_LAYER2_SUPPORT" = "1" ]; then
mesg "(Layer2) "
_opts="${_opts} layer2=1"
fi
fi
# Enable IP address takeover
if [ "$QETH_IPA_TAKEOVER" ]; then
if [ "$QETH_IPA_TAKEOVER" = "1" ]; then
mesg "(IP takeover) "
_opts="${_opts} ipa_takeover/enable=$QETH_IPA_TAKEOVER"
fi
fi
# Relative port number
if [ -w "$_ccwgroup_dir/portno" ] ; then #to be replaced
if [ -n "$QETH_PORTNO" ]; then
mesg "(Port $QETH_PORTNO) "
# This may fail, but trial and error is the only way to tell.
_opts="${_opts} portno=$QETH_PORTNO"
fi
fi
#run chzdev
chzdev --enable $QETH_READ_CHAN:$QETH_WRITE_CHAN:$QETH_DATA_CHAN ${_opts}
_ret=$?
map_chzdev_return $_ret online
if [ "$QETH_OPTIONS" ]; then
set_qeth_options
fi
else
debug_mesg "Device ${CCW_CHAN_ID} is already online"
fi
else
if [ "$_online" -eq 1 ]; then
# Set the device offline
debug_mesg "Setting device offline"
#echo "$ONLINE" > $_ccwgroup_dir/online
chzdev --disable $QETH_READ_CHAN:$QETH_WRITE_CHAN:$QETH_DATA_CHAN ${_opts}
exit_on_err $? offline
fi
fi
#check for 51-type rules
OLD_RULES_FILE=/etc/udev/rules.d/51-???-${QETH_READ_CHAN}.rules
NEW_RULES_FILE=/etc/udev/rules.d/41-???-${QETH_READ_CHAN}.rules
if [ -a $OLD_RULES_FILE ]; then
# only delete 51-type rules if 41-type ones have been written
if [ -a $NEW_RULES_FILE ]; then
rm -rf $OLD_RULES_FILE
#re-check
if [ -a $OLD_RULES_FILE ]; then
echo "$OLD_RULES_FILE could not be deleted."
fi
fi
fi
udevadm settle
exit 0